Files
openclaw b5bf96e882 fix: 修复飞书配置层级问题,确保 dmPolicy 正确生效
- 修复 configureFeishuAccount 函数,同时设置顶层和账户级配置
- 原因:default 账户不会合并 accounts.default 的覆盖值
- 新增 --allow-from 和 --group-policy 参数
- 默认 dmPolicy 改为 allowlist(安全优先)
- 更新 SKILL.md 文档,添加配置层级说明
- 新增 FIXES.md 记录修复详情
2026-03-17 22:17:10 +08:00

6.3 KiB
Raw Permalink Blame History

name, description, invocations
name description invocations
agent-creator-with-binding 创建新 Agent 并配置飞书机器人绑定(整合版,无需额外 skill
words description
创建 agent
创建子 agent
新 agent 绑定
agent 绑定飞书
添加飞书机器人
配置飞书机器人
创建新 Agent 并配置飞书机器人绑定(整合 feishu-agent-binding 功能)

agent-creator-with-binding

一站式创建 OpenClaw Agent 并配置飞书机器人绑定。

整合功能:

  • Agent 创建
  • 飞书机器人配置(原 feishu-agent-binding 功能)
  • 路由绑定配置
  • 会话隔离配置
  • Agent 间调用配置

无需额外 skill

完整工作流程

模式 1创建新 Agent + 账户级绑定(新机器人)

1. 输入 Agent 基础信息ID、名称、描述
   ↓
2. 选择绑定模式account
   ↓
3. 选择:新飞书机器人
   ↓
4. 输入飞书凭证App ID、App Secret
   ↓
5. 预览配置
   ↓
6. 确认执行
   ↓
7. 创建 Agent + 配置飞书账户 + 更新 bindings + 重启 Gateway

模式 2创建新 Agent + 账户级绑定(现有机器人)

1. 输入 Agent 基础信息
   ↓
2. 选择绑定模式account
   ↓
3. 选择:现有飞书机器人
   ↓
4. 从列表选择账户
   ↓
5. 预览配置
   ↓
6. 确认执行
   ↓
7. 创建 Agent + 更新 bindings + 重启 Gateway

模式 3创建新 Agent + 群聊级绑定

1. 输入 Agent 基础信息
   ↓
2. 选择绑定模式group
   ↓
3. 选择飞书账户
   ↓
4. 输入群聊 ID
   ↓
5. 预览配置
   ↓
6. 确认执行
   ↓
7. 创建 Agent + 更新 bindings + 重启 Gateway

模式 4创建新 Agent不绑定后台 Agent

1. 输入 Agent 基础信息
   ↓
2. 选择绑定模式none
   ↓
3. 预览配置
   ↓
4. 确认执行
   ↓
5. 创建 Agent + 重启 Gateway

使用方式

交互模式

openclaw skills run agent-creator-with-binding

命令行模式

# 模式 1账户级绑定新机器人
openclaw skills run agent-creator-with-binding -- \
  --agent-id email-assistant \
  --agent-name "邮件助手" \
  --binding-mode account \
  --new-bot \
  --app-id cli_xxx \
  --app-secret yyy

# 模式 2账户级绑定现有机器人
openclaw skills run agent-creator-with-binding -- \
  --agent-id email-assistant \
  --binding-mode account \
  --account-id bot-existing

# 模式 3群聊级绑定
openclaw skills run agent-creator-with-binding -- \
  --agent-id project-assistant \
  --agent-name "项目助手" \
  --binding-mode group \
  --account-id bot-main \
  --chat-id oc_xxx

# 模式 4不绑定后台 Agent
openclaw skills run agent-creator-with-binding -- \
  --agent-id data-processor \
  --agent-name "数据处理器" \
  --binding-mode none

参数说明

参数 必填 说明
--agent-id Agent 唯一标识
--agent-name 显示名称(默认同 agent-id
--binding-mode 绑定模式account/group/none
--new-bot 是否创建新飞书机器人
--app-id 飞书 App ID新机器人时需要
--app-secret 飞书 App Secret新机器人时需要
--account-id 飞书账户 ID现有机器人时需要
--chat-id 群聊 ID群聊绑定时需要
--bot-name 机器人名称
--dm-policy DM 策略allowlist/open/pairing默认 allowlist
--allow-from 白名单用户逗号分隔ou_xxx,ou_yyy
--group-policy 群聊策略open/allowlist/disabled默认 open
--skip-confirm 跳过确认
--skip-restart 跳过重启

配置层级说明

⚠️ 重要: 飞书配置必须同时设置顶层和账户级配置!

{
  "channels": {
    "feishu": {
      // ★ 顶层配置(必须设置!)
      // 原因default 账户不会合并 accounts.default 的覆盖值
      "dmPolicy": "allowlist",
      "allowFrom": ["ou_xxx", "ou_yyy"],
      "groupPolicy": "open",
      "groupAllowFrom": [],
      
      "accounts": {
        // 账户级配置(可覆盖顶层设置)
        "default": {
          "appId": "cli_xxx",
          "appSecret": "xxx",
          "dmPolicy": "allowlist",  // 继承顶层或覆盖
          "allowFrom": ["ou_xxx"]   // 继承顶层或覆盖
        },
        "bot-other": {
          "appId": "cli_yyy",
          "appSecret": "yyy",
          "dmPolicy": "open"  // 可独立设置
        }
      }
    }
  }
}

修复前的问题:

  • 只在 accounts.<accountId> 中设置 dmPolicy
  • default 账户读取不到配置(代码 bug
  • 导致配对提示而不是拒绝访问

修复后的行为:

  • 自动设置顶层 channels.feishu.dmPolicy
  • 同时设置账户级配置(可覆盖)
  • 确保所有账户(包括 default正确继承

配置变更

执行后会修改:

  • ~/.openclaw/openclaw.json
    • 添加 agents.list 条目
    • 添加 bindings 规则
    • 添加/更新 channels.feishu.accounts
    • 配置 session.dmScope
    • 启用 tools.agentToAgent
  • ~/.openclaw/workspace-<agent-id>/ - 创建 agent 工作空间
  • ~/.openclaw/agents/<agent-id>/ - 创建 agent 状态目录

备份和回退

自动备份

执行任何修改前自动备份!

  • 备份位置:~/.openclaw/backups/openclaw.json.<timestamp>
  • 备份时机:在创建 Agent 之前
  • 备份内容:完整的 openclaw.json

自动回退

任何步骤失败自动回退!

失败场景 回退操作
创建 Agent 失败 恢复 openclaw.json
更新配置失败 删除 Agent 目录 + 恢复 openclaw.json
配置飞书账户失败 删除 Agent 目录 + 恢复 openclaw.json
Gateway 重启失败 不回退(配置正确,需手动重启)

手动回退

如配置有误,可从备份恢复:

# 找到最近的备份
ls -lt ~/.openclaw/backups/openclaw.json.* | head -1

# 恢复配置
cp ~/.openclaw/backups/openclaw.json.<timestamp> ~/.openclaw/openclaw.json

# 重启 Gateway
openclaw gateway restart

验证

# 查看 agent 列表和绑定
openclaw agents list --bindings

# 查看 Gateway 状态
openclaw gateway status

# 查看飞书账户状态
openclaw channels status --probe