Skip to content

飞书:Agent 工作台(默认关)——每个 Agent 一个话题,话题里转发、作答和 /ls /tail /stop - #62

Merged
NginxL merged 4 commits into
mainfrom
feat/agent-workbench
Dec 4, 2026
Merged

NginxL merged 4 commits into
mainfrom
feat/agent-workbench

Conversation

@NginxL

@NginxL NginxL commented Dec 4, 2026 •

Copy link
Copy Markdown
Owner

做了什么

把同事「飞书打通 Claude」方案(lark-cli 长连接 + Claude Code Hook + tmux)里好用的部分吸收进飞书扩展,做成 Agent 工作台。实现上只用 Persona hub 已有接口和扩展已声明的权限,不依赖 tmux,不装 Claude Code Hook,不改任何电脑上的 ~/.claude 或 ~/.codex。所有新功能都是扩展设置开关,默认关闭;关着时什么都不读、不发,/agent、自动代答、收件箱、Persona 渠道、话题追问转发都和原来一样。

新设置(只在飞书扩展里):

设置 默认 作用
workbench「Agent 工作台」 关(打开时弹确认) 总开关
workbench_chat「工作台话题群」 空 工作台用的群(会话 id);不能和「Persona 渠道会话」相同
workbench_asks「工作台:话题里作答」 关 第 2 点
workbench_commands「工作台:指令不过模型」 关 第 3 点
  1. 工作台话题群(core/openmate_core/workbench.py):每 15 秒用 agents.read 读一次 hub 的 Agent 列表(和「Agent 进度」页同一个接口,不限 Claude Code,含 Codex、各台电脑)。正在执行、等你确认的 Agent,以及打开工作台之后有过动静的 Agent,各开一个话题(每轮最多新开 5 个,打开时不会刷屏)。首楼是状态消息,原地编辑:🟡 执行中 / 🟠 等你确认 / 🟢 待命 / ⚫ 已结束,加项目、分支、Agent 和模型、电脑、最近指令、更新时间。状态一变就改,同一状态最多 5 分钟改一次。你在话题里发的话用 agents.control 发给这个 Agent:每条消息带一个 client_msg_id,重试不会发重复;接单时贴 🤔,回复后换成 ✅。这一轮的回复带 AI 标记回到话题。不在 Agent 话题里的消息照旧交给 /agent。
  2. 等确认时远程作答:读 GET /api/v1/interactions,把 Agent 等你回答或批准的问题和选项发到它的话题。在话题里回复编号,走 POST …/choose(带 rev,算法移植自 Persona 的 askRev,已和 Go encoding/json 的结果逐位核对)。回复 y/n 批准或拒绝,n 后面可以写原因,走 POST …/resolve 的 allow 或 approve。直接写文字就作为回答。作答后问题消息改成「✅ 已作答:…」。在别处答了的问题,用和 Persona 渠道同一套逻辑撤回:channel.py 里的 _ended 和 _take_back 抽成了模块函数 ended_for_good 和 take_back,行为不变,渠道测试全过。只有你能决定的卡片,hub 不让扩展批准(agents.control 只允许拒绝),话题里会提示去 App 处理。
    • /tail:hub 有读终端的接口 GET /api/v1/sessions/{mid}/{sid}/screen,属 agents.read,见 Persona 的 server/internal/extwire/scopes.go。读不到画面时(比如 Codex app-server 会话没有终端),改给它最近几条记录。
  3. 纯指令不过模型:/ls(列 Agent 状态)、/tail [行数](默认 40,最多 120)、/stop(…/interrupt)、/help,都由扩展直接回答,不调用模型。
  4. 长回复分片:现有 /agent 发送没有分片,这次只用在工作台的回复上,/agent 的行为没改。按字符(6500)和 UTF-8 字节(18000)两个上限切分;切点落在代码块里时,前一片补上闭合,后一片用原来的开头行(```python)重新打开。超过 10 片时只发前 9 片,加一句「后面还有约 N 字,请在 Persona App 里看全文」。先发 Markdown 格式,飞书不收格式时改发纯文本。

工作台发出的每条消息(包括状态编辑)都以你的身份发在这个群里,都记进 hub 的「以你身份发出的消息」记录(setting: "workbench"),同一个 key 只发一次。README 写明了这是第五种不逐条确认的消息,默认关闭。

权限

  • 没有新增 hub 权限:用到的接口都在已声明的 agents.read / agents.control 里,test_feishu.ManifestTest.test_permissions 固定了权限列表,没有改。
  • 没有新增飞书应用权限:照旧通过 LarkAgentX 以本人身份收发,没有新增 LarkAgentX 接口;在话题群里发新话题用的是已获同意的 newer_post。

怎么验证的

  • bash scripts/test.sh 全部通过。
  • 新增 tests/test_workbench.py,共 28 个测试:
    • 分片:字符和字节上限、代码块闭合和续接、超长行;ask_rev 和 Go 算出的值一致;各类问题的回答方式。
    • 开关关闭时的回归:设置默认值都是关;关着时即使填了群,也不读 Agent 列表、不开话题,/agent 照常开对话;工作台群和渠道群相同时,渠道照旧接管所有消息;其他群和工作台群主消息里的 /agent 照旧。
    • 打开后:状态消息原地编辑、节流;转发并带回回复;长回复分片,格式被拒时改纯文本;按编号选择、ask_changed 时按标签作答、y/n 和被 hub 拒绝时的提示、在别处答了自动撤回;/ls、/tail(读到画面和读不到画面两种)、/stop;指令开关关着时,这些话和普通消息一样发给 Agent。
    • 这些测试在旧代码上会失败,因为 workbench 模块不存在。其中「关着时行为不变」那一组测的就是行为没变,换成旧代码的等价写法也会通过。
    • 审查后补的 5 个测试:换账号后不再作答或打断;开话题结果不确定时不重发,从回声里认领;分片发送失败后补发;撤回失败重试;引用哪条问题就答哪条。这 5 个在修正前的提交 2e7983b 上都失败。
  • test_feishu.ManifestTest.test_configuration 的设置列表加上四个新设置,并断言默认都是关。

审查

本机 codex 只读审查了两轮。AGENTS.md 指定的 gpt-6.2-astra 在本机中转上返回 404 Model not found,改用本机默认模型(auto_model/alwaysday1_max)。

  • 第一轮找出 7 个问题:

    • 换账号后旧线程仍会调 hub;
    • 开话题结果不确定时换 key 重发;
    • 发送记录的 key 跨账号复用;
    • 回复卡在 posting;
    • 分片中途失败被标成完成;
    • 撤回不重试;
    • 多个待答问题时总答最新的。

    都在 77fccfa 修了。

  • 第二轮确认 7 个都修好,默认关闭时现有行为没有回归,也没有重复发送或发到群外。另外提了两个低概率边界问题,在 bd79aea 里收紧:认领话题根只在发送前后 5 分钟内找最早的一条;撤回前再确认一次账号。

  • 没改的一条:Agent 超过 200 个时只读前 200 个,和「Agent 进度」页一样。

版本

openmate-feishu 0.11.79、openmate-wechat 0.1.72。改了 core/,两个扩展都升了版本;微信扩展没有新设置,行为不变。

没做的

  • 截图和文件直传给 Agent:话题里发图片或文件时,只回一句「现在只转发文字」。
  • /rename、/new、/resume、/kill:不在这次范围里;其中 /new 和 /resume 要新开会话,会改变 Agent 的生命周期。
  • 终端按键(Esc、Ctrl-C、方向键):hub 的 …/keys 只给完整凭据,不给扩展,见 scopes.go。
  • 没开工作台的 Agent 在终端里发起的那一轮,回复不推到话题(避免刷屏);状态消息照常更新。

🤖 Generated with Claude Code

NginxL and others added 4 commits December 4, 2026 21:53
…ls from the topic, /ls /tail /stop

All behind new extension settings, off by default (workbench, workbench_chat, workbench_asks,
workbench_commands); while off nothing is read or sent and /agent, 自动代答, the inbox, Persona's
channel and thread follow-ups behave as before.

- workbench.py: the hub's Agent list (agents.read) as one topic per Agent in the user's own group,
  the first message the status edited in place; the user's lines in a topic go to that Agent
  (agents.control, one client_msg_id each) and its answer comes back split by characters and UTF-8
  bytes with code fences closed and reopened, formatted or plain when the format is refused.
- workbench_asks: waiting questions put in their topic; a number answers through
  POST /api/v1/interactions/{id}/choose (rev as Persona's askRev), y/n through …/resolve; answered
  elsewhere is taken back with the channel's own logic (channel.ended_for_good / take_back, moved
  out of ChannelBridge unchanged).
- workbench_commands: /ls, /tail (GET …/screen, agents.read), /stop (…/interrupt), /help answered
  by the extension, no model.
- No new hub or Feishu permission.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Nothing is asked of the hub (an answer, a line, /stop) nor reacted for a line of the account signed
  in before another one did (checked right before each call).
- A topic whose opening send has an unknown outcome is never sent again under another key: its echo
  is looked for among the group's last messages and adopted as the topic's root.
- The send journal's keys are each account's own.
- An answer that did not all go out (or a restart cut off) is posted again the next rounds, at most
  3 times; each piece still goes once.
- A question answered elsewhere: the history read again each round, a failed take-back tried again
  (5 rounds), one cut off by a restart looked at again.
- A reply that quotes one of several waiting questions answers that one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nt right before a take-back

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- 飞书:新设置「Agent 工作台」「工作台话题群」「工作台:话题里作答」「工作台:指令不过模型」,全部默认关。
  打开后每个 Agent 在你指定的群里有一个话题,首楼原地显示状态;话题里的话转给这个 Agent,回复分片回到话题;
  可选在话题里回答 Agent 的问题和批准(编号、y/n),以及 /ls、/tail、/stop 不经过模型。
- 核心:渠道的「问题是否结束」「撤回」抽成共用函数,行为不变;不新增 hub 或飞书权限。
- 微信:只因核心改动升版本,行为不变。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant