前言

codex不能直接原生接入飞书,需要一个中间插件实现,也就是需要lark-channel-bridge监听作为桥梁实现

组件 用途 是否必需
飞书企业自建应用/机器人 接收和回复消息 必需
Node.js 20+ 运行 Bridge 和 Codex CLI 必需
lark-channel-bridge 0.7.0 飞书与 Codex 之间的消息桥接 必需
lark-cli 调用飞书消息接口,由 Bridge 自动安装和绑定 必需
@openai/codex 本地 Codex CLI 必需
Bridge 加密密钥库 保存飞书 App Secret,由 Bridge 自动创建 必需

飞书设置(可选)

如果重头创建一个新的机器人,后面lark-channel-bridge会有一个引导创建的链接,可以跳过这步

  1. 开启机器人能力。
  2. 开通接收消息、发送消息和回复消息权限。
  3. 在事件订阅中选择长连接,并订阅消息接收事件。
  4. 发布应用,将机器人加入需要使用的群。
  5. 记录 App IDApp Secret

部署

如果有图形化的codex,也需要安装cli版本,不过不用设置登录了

1
2
3
4
5
6
7
8
9
10
11
# 检查 Node.js,要求 20+
node --version

# 安装并登录 Codex
npm install -g @openai/codex
codex login
codex --version

# 安装 Bridge
npm install -g lark-channel-bridge@0.7.0
lark-channel-bridge --version

创建 Bridge Profile

创建 Bridge Profile,将 App IDworkspace替换为实际值:
下面是两种格式的命令,任选其一即可

1
2
3
4
5
lark-channel-bridge profile create codex-feishu `
--agent codex `
--workspace D:\Your-Workspace `
--app-id cli_xxxxxxxxxxxxx `
--tenant feishu
1
lark-channel-bridge profile create codex-feishu --agent codex --workspace D:\Your-Workspace --app-id cli_xxxxxxxxxxxxx --tenant feishu

创建错了可以使用命令删除

1
lark-channel-bridge profile delete codex-feishu

打开并启动 Bridge

  • 前台启动

    1
    lark-channel-bridge run --profile codex-feishu
  • 打开 Bridge Web UI 并启动

    1
    lark-channel-bridge run --web-ui
  • 后台启动

    1
    2
    lark-channel-bridge start --profile codex-feishu
    lark-channel-bridge status --profile codex-feishu