feat: 飞书凭证迁入 agents.json#212
Conversation
每个 agent 内嵌 feishu 字段(appId + appSecret),一个文件看到全貌。 系统启动时从 agents.json 推导 bot 账号和路由规则。 主要改动: - config-schema: 新增 FeishuAccountSchema + AgentBindingSchema - config-loader: deriveBotAccounts/deriveBindings 从 agent config 推导 - config.ts: 移除 FEISHU_APP_ID/SECRET、BOT_ACCOUNTS、AGENT_BINDINGS - index.ts: 启动顺序改为 agentConfig → deriveBotAccounts → accountManager - client.ts: FeishuClient 构造函数 appId/appSecret 改为必传,增加 initDefaultClient - server.ts: startServer 接收 primaryBot 参数 - oauth.ts: 从 deriveBotAccounts 获取凭证 - onboarding prompt: 飞书 keys 写入 agents.json 而非 .env Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Claude finished @lishuceo's task in 2m 5s —— View job PR Review: feat: 飞书凭证迁入 agents.json
|
| # | Severity | File | Issue | Confidence |
|---|---|---|---|---|
| 1 | 🔴 Critical | src/feishu/client.ts:907 |
Multi-bot mode crashes: initDefaultClient() is only called in single-bot branch, but the feishuClient proxy throws when _defaultClient is undefined. Any code using feishuClient outside AsyncLocalStorage context in multi-bot mode (e.g., OAuth feishuClient.raw) will crash. |
90 |
| 2 | 🟡 Warning | src/feishu/oauth.ts:37-38 |
Empty HMAC key degrades security: getPrimaryAppSecret() returns '' if no bot accounts exist, silently signing OAuth states with an empty key. Should throw instead. |
82 |
| 3 | 🟡 Warning | src/feishu/oauth.ts:38 |
Repeated computation: deriveBotAccounts() rebuilds a full Map from all agents on every signState()/verifyState() call. Should cache. |
80 |
| 4 | 🟡 Warning | src/feishu/event-handler.ts:689 |
Per-message overhead: deriveBindings() iterates all agents and builds arrays on every incoming message. Should cache and invalidate on config reload. |
78 |
What looks good:
- Clean Zod schema additions for
FeishuAccountSchemaandAgentBindingSchema - Proper deduplication logic in
deriveBotAccounts()(by appId) - Explicit bindings take precedence over auto-derived ones (spread order)
- Test updates correctly reflect the new source of truth
startServer()parameter design cleanly separates single/multi-bot paths
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Claude finished @lishuceo's task in 2m 51s —— View job PR Re-review: feat: 飞书凭证迁入 agents.json
|
| # | Severity | File | Issue | Status |
|---|---|---|---|---|
| 1 | 🔴 Critical | src/feishu/client.ts:907 |
Multi-bot mode crashes: initDefaultClient() only called in single-bot branch. Any feishuClient usage outside AsyncLocalStorage context in multi-bot mode throws. Concrete crash paths: interrupted session notifications (index.ts:193), cron sendMessage fallback to 'default' (index.ts:131), OAuth feishuClient.raw (oauth.ts:113). |
Still exists |
| 2 | 🟡 Warning | src/feishu/oauth.ts:37-38 |
Empty HMAC key degrades security: getPrimaryAppSecret() returns '' if no bot accounts, silently signing with vacuous key. |
Still exists |
| 3 | 🟡 Warning | src/feishu/oauth.ts:38 |
Repeated computation: deriveBotAccounts() rebuilds full Map on every signState()/verifyState() call. |
Still exists |
| 4 | 🟡 Warning | src/feishu/event-handler.ts:689 |
Per-message overhead: deriveBindings() iterates all agents on every incoming message without caching. |
Still exists |
No new issues found
The fix: 移除 index.ts 中未使用的 isMultiBotMode 导入 commit (2826257) is a clean import cleanup — no new issues introduced.
What looks good:
- Clean Zod schema additions (
FeishuAccountSchema,AgentBindingSchema) - Proper deduplication in
deriveBotAccounts()by appId - Explicit bindings take precedence over auto-derived (spread order in
index.ts:59) - Test updates correctly reflect the new source of truth (
deriveBotAccountsmock) .env.examplecleanup is thorough — clear migration comment at top- No credential leakage risk in logging (all log calls only output accountId/agentId, never secrets)
Recommendation: Fix the 🔴 critical issue (#1) before merging — multi-bot mode will crash at runtime on several code paths. The simplest fix: always call initDefaultClient() with the primary bot's credentials, even in multi-bot mode.
- 多 bot 模式也调用 initDefaultClient(修复 AsyncLocalStorage 无值时崩溃) - deriveBotAccounts/deriveBindings 改为缓存模式,reload 时刷新 - OAuth getPrimaryAppSecret 无账号时 throw 而非返回空字符串 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Claude finished @lishuceo's task in 2m 22s —— View job PR Re-review: feat: 飞书凭证迁入 agents.json
✅ All 4 previous issues fixed — no new issues foundCommit
All 4 review threads have been resolved. Overall assessment: The fix commit is clean and well-structured. The caching approach in |
description 字段解释 agent 的定位和特点: - PM: Chat Bot — 只读、直接回复、轻量对话 - Dev: Dev Bot — 完整读写、创建话题、编码任务 /config 命令也展示 description。 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- pm.example.md 已被 assistant.example.md 替代 - .gitkeep 不再需要(目录中已有 .example.md 文件) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Claude finished @lishuceo's task in 1m 22s —— View job PR Re-review: feat: 飞书凭证迁入 agents.json
✅ LGTM — All previous issues fixed, no new issues found3 new commits since last review (all clean):
Previous 4 issues (all resolved in
What looks good across the full PR:
|
都是去飞书后台操作不需要回传值,没必要分两轮等用户回复。 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Claude finished @lishuceo's task in 1m 46s —— View job PR Re-review: feat: 飞书凭证迁入 agents.json
✅ LGTM — All 4 previous issues fixed, 1 minor issue found4 previous issues (all resolved in
2 new commits since last review (both clean):
1 new minor issue (not in diff, can't inline comment):
What looks good across the full PR:
|
Alice/Bob/Carol 已从模板中移除,测试改为检查 "占位" 关键词。 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Claude finished @lishuceo's task in 2m 26s —— View job PR Re-review: feat: 飞书凭证迁入 agents.json
✅ All 4 previous issues fixed, 1 minor issue persists4 previous issues (all resolved in
1 issue still present (flagged in last review, not in diff so can't inline comment):
3 new commits since last full review (all clean):
What looks good across the full PR:
Recommendation: Fix the 🟡 Phase 6 issue before merging — it's a low-risk prompt bug but will confuse the onboarding agent on fresh deploys. |
* feat: 飞书凭证迁入 agents.json,统一配置入口 每个 agent 内嵌 feishu 字段(appId + appSecret),一个文件看到全貌。 系统启动时从 agents.json 推导 bot 账号和路由规则。 主要改动: - config-schema: 新增 FeishuAccountSchema + AgentBindingSchema - config-loader: deriveBotAccounts/deriveBindings 从 agent config 推导 - config.ts: 移除 FEISHU_APP_ID/SECRET、BOT_ACCOUNTS、AGENT_BINDINGS - index.ts: 启动顺序改为 agentConfig → deriveBotAccounts → accountManager - client.ts: FeishuClient 构造函数 appId/appSecret 改为必传,增加 initDefaultClient - server.ts: startServer 接收 primaryBot 参数 - oauth.ts: 从 deriveBotAccounts 获取凭证 - onboarding prompt: 飞书 keys 写入 agents.json 而非 .env Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: 移除 index.ts 中未使用的 isMultiBotMode 导入 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: address PR review — multi-bot initDefaultClient + 缓存优化 + OAuth 安全 - 多 bot 模式也调用 initDefaultClient(修复 AsyncLocalStorage 无值时崩溃) - deriveBotAccounts/deriveBindings 改为缓存模式,reload 时刷新 - OAuth getPrimaryAppSecret 无账号时 throw 而非返回空字符串 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * feat: agent 配置新增 description 字段,示例配置加角色说明 description 字段解释 agent 的定位和特点: - PM: Chat Bot — 只读、直接回复、轻量对话 - Dev: Dev Bot — 完整读写、创建话题、编码任务 /config 命令也展示 description。 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * chore: 删除 pm.example.md 和 .gitkeep - pm.example.md 已被 assistant.example.md 替代 - .gitkeep 不再需要(目录中已有 .example.md 文件) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * chore: team.example.md 占位符语义化,去掉 Alice/Bob/Carol 假数据 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: onboarding 权限和事件订阅合并为一步提示 都是去飞书后台操作不需要回传值,没必要分两轮等用户回复。 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: onboarding 先收集 Bot 人格再收集团队信息 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: bootstrap 测试适配模板占位符改动 Alice/Bob/Carol 已从模板中移除,测试改为检查 "占位" 关键词。 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

Summary
feishu: { appId, appSecret }字段,一个文件看到全貌.env中的FEISHU_APP_ID、FEISHU_APP_SECRET、BOT_ACCOUNTS、AGENT_BINDINGSTest plan
setup.sh→npm run onboard→ 飞书 key 写入 agents.json →npm run dev/config命令显示正确的 feishu appIdnpx vitest run全部通过(1320 passed,1 pre-existing flaky failure)🤖 Generated with Claude Code