返回顶部
o

openclaw-configOpenClaw配置编辑

Edit and validate OpenClaw Gateway config (openclaw.json / JSON5). Use when adding/changing config keys (gateway.*, agents.*, models.*, channels.*, tools.*, skills.*, plugins.*, $include) or diagnosing openclaw doctor/config validation errors, to avoid schema mismatches that prevent the Gateway from starting or weaken security policies.

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 0.1.0
安全检测
已通过
3,597
下载量
免费
免费
5
收藏
概述
安装方式
版本历史

openclaw-config

OpenClaw Config

概述

使用模式优先的工作流安全编辑 ~/.openclaw/openclaw.json(或由 OPENCLAWCONFIGPATH 设置的路径)。在变更前后进行验证,以避免可能导致启动失败或改变安全行为的无效键/类型。

工作流(安全编辑)

  1. 1. 确定当前配置路径
  • - 优先级:OPENCLAWCONFIGPATH > OPENCLAWSTATEDIR/openclaw.json > ~/.openclaw/openclaw.json
  • 配置文件为 JSON5 格式(允许注释和尾随逗号)。
  1. 2. 获取权威模式(不要猜测键)
  • - 如果网关正在运行:使用 openclaw gateway call config.schema --params {} 获取与当前运行版本匹配的 JSON Schema。
  • 否则:使用 openclaw/openclaw 权威来源,主要包括:
- src/config/zod-schema.ts(OpenClawSchema 根键,如 gateway/skills/plugins) - src/config/zod-schema.*.ts(子模块:channels/providers/models/agents/tools) - docs/gateway/configuration.md(仓库文档 + 示例)
  1. 3. 以最小安全范围应用变更
  • - 优先使用小范围编辑:openclaw config get|set|unset(点路径或括号表示法)。
  • 如果网关在线且希望一步完成写入 + 验证 + 重启:使用 RPC config.patch(合并补丁)或 config.apply(替换整个配置;请谨慎使用)。
  • 对于复杂配置,使用 $include 拆分配置(见下文)。
  1. 4. 严格验证
  • - 运行 openclaw doctor,然后根据报告的 path + message 修复问题。
  • 未经用户明确同意,不要运行 openclaw doctor --fix/--yes(它会写入配置/状态文件)。

防护措施(避免模式错误)

  • - 大多数对象是严格的(.strict()):未知键通常会验证失败,网关将拒绝启动。
  • channels 是 .passthrough():扩展频道(matrix/zalo/nostr 等)可以添加自定义键,但大多数提供者配置仍然是严格的。
  • env 是 .catchall(z.string()):可以直接在 env 下放置字符串环境变量,也可以使用 env.vars。
  • 密钥:优先使用环境变量/凭证文件。避免将长期有效的令牌/API 密钥提交到 openclaw.json 中。

$include(模块化配置)

$include 在模式验证之前解析,允许将配置拆分到多个 JSON5 文件中:

  • - 支持 $include: ./base.json5 或 $include: [./a.json5, ./b.json5]
  • 相对路径基于当前配置文件所在目录解析。
  • 深度合并规则(按实现方式):
- 对象:递归合并 - 数组:拼接(不替换) - 基本类型:后值优先
  • - 如果 $include 旁边存在同级键,则同级键会覆盖包含的值。
  • 限制:最大深度为 10;循环包含会被检测并拒绝。

常用方案(示例)

  1. 1. 设置默认工作空间

bash
openclaw config set agents.defaults.workspace ~/.openclaw/workspace --json
openclaw doctor

  1. 2. 更改网关端口

bash
openclaw config set gateway.port 18789 --json
openclaw doctor

  1. 3. 拆分配置(示例)

json5
// ~/.openclaw/openclaw.json
{
$include: [./gateway.json5, ./channels/telegram.json5],
}

  1. 4. Telegram 开放私信(必须明确允许发送者)

模式约束:当 dmPolicy=open 时,allowFrom 必须包含 *。

bash
openclaw config set channels.telegram.dmPolicy open --json
openclaw config set channels.telegram.allowFrom [*] --json
openclaw doctor

  1. 5. Discord 令牌(配置或环境变量回退)

bash

选项 A:写入配置


openclaw config set channels.discord.token YOURDISCORDBOT_TOKEN --json

选项 B:环境变量回退(仍建议存在 channels.discord 部分)

export DISCORDBOTTOKEN=...

openclaw doctor

  1. 6. 启用网络搜索(Brave / Perplexity)

bash
openclaw config set tools.web.search.enabled true --json
openclaw config set tools.web.search.provider brave --json

建议:通过环境变量提供密钥(或写入 tools.web.search.apiKey)

export BRAVEAPIKEY=...

openclaw doctor

资源

当需要字段索引或源代码位置时,请加载以下内容:

  • - references/openclaw-config-fields.md(根键索引 + 带来源的键字段列表)
  • references/schema-sources.md(如何在 openclaw 仓库中定位模式和约束)
  • scripts/openclaw-config-check.sh(打印配置路径并运行 doctor)

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 openclaw-config-1776346767 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 openclaw-config-1776346767 技能

通过命令行安装

skillhub install openclaw-config-1776346767

下载

⬇ 下载 openclaw-config v0.1.0(免费)

文件大小: 7.23 KB | 发布时间: 2026-4-17 14:57

v0.1.0 最新 2026-4-17 14:57
- Initial release of openclaw-config skill.
- Edit and validate OpenClaw Gateway config (openclaw.json / JSON5) with schema-first workflow.
- Guides users through safe config editing, strict validation, and use of $include for modular configuration.
- Includes best practices, troubleshooting steps, and common configuration examples for channels, tools, and security.
- Comprehensive documentation for locating schemas, resolving validation errors, and maintaining strict security policies.

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部