From 6d1e31dd36ef02c477a862492df159576e509e0a Mon Sep 17 00:00:00 2001 From: hailin Date: Mon, 9 Mar 2026 05:51:21 -0700 Subject: [PATCH] feat(iagent): add Feishu to channel binding flow in system prompt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit After creating an instance, iAgent now asks user to choose: 钉钉 / 飞书 / 都绑定 / 跳过 - DingTalk: existing OAuth card push flow - Feishu: bind-code flow (user sends code to Feishu bot) - Also adds Feishu status/unbind API references Co-Authored-By: Claude Sonnet 4.6 --- .../claude-code-cli/system-prompt-builder.ts | 31 +++++++++++++------ 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/packages/services/agent-service/src/infrastructure/engines/claude-code-cli/system-prompt-builder.ts b/packages/services/agent-service/src/infrastructure/engines/claude-code-cli/system-prompt-builder.ts index cbafa75..6be3b40 100644 --- a/packages/services/agent-service/src/infrastructure/engines/claude-code-cli/system-prompt-builder.ts +++ b/packages/services/agent-service/src/infrastructure/engines/claude-code-cli/system-prompt-builder.ts @@ -71,22 +71,35 @@ export class SystemPromptBuilder { '1. Ask for a name if not given\n' + '2. Use the Current User ID from this prompt as userId\n' + '3. Call the create API with Bash and report the result (id, status, containerName)\n\n' + - '## 招募小龙虾 + 钉钉绑定 (全语音/文字引导)\n' + - 'When a user says "帮我招募一只小龙虾" / "创建小龙虾" / "recruit agent" / "bind DingTalk":\n\n' + + '## 招募小龙虾 + 渠道绑定 (全语音/文字引导)\n' + + 'When a user says "帮我招募一只小龙虾" / "创建小龙虾" / "recruit agent" / "bind DingTalk" / "bind Feishu":\n\n' + ' Step 1 — Ask for a name if not provided:\n' + ' "你想给这只小龙虾取个什么名字?"\n\n' + ' Step 2 — Create the instance (Bash tool):\n' + ' wget -q -O- --post-data=\'{"name":"","userId":"","usePool":true}\' --header="Content-Type: application/json" http://localhost:3002/api/v1/agent/instances\n' + ' Parse JSON to get "id" (instanceId) and "name".\n' + - ' Say: "好的,小龙虾「」已经创建好了!"\n\n' + + ' Say: "好的,小龙虾「」已经创建好了!接下来把它和你的即时通讯工具绑定,方便直接对话。你想绑定钉钉、飞书,还是都绑定?"\n\n' + + ' Step 3 — Channel binding (based on user choice):\n\n' + + ' [DingTalk / both]\n' + `${dingtalkOauthStep}\n\n` + - ' Step 4 — Confirm (after user says they authorized):\n' + - ' wget -q -O- http://localhost:3002/api/v1/agent/channels/dingtalk/status/\n' + - ' If { "bound": true }: "太好了!小龙虾「」已成功绑定钉钉,现在可以在钉钉里和它对话了!"\n' + - ' If still false: "授权还没完成,请确认是否点击了钉钉里的授权按钮。"\n\n' + + ' DingTalk confirm:\n' + + ' wget -q -O- http://localhost:3002/api/v1/agent/channels/dingtalk/status/\n' + + ' If { "bound": true }: "钉钉绑定成功!"\n' + + ' If still false: "授权还没完成,请确认是否点击了钉钉里的授权按钮。"\n\n' + + ' [Feishu / both]\n' + + ' Call the bind-code API to get a 6-character code:\n' + + ' wget -q -O- --post-data="" http://localhost:3002/api/v1/agent/channels/feishu/bind/\n' + + ' Parse JSON: { "code": "", "expiresAt": }\n' + + ' Say: "飞书绑定验证码是「」,有效15分钟。请打开飞书,找到 iAgent 机器人,把这个验证码发给它,就完成绑定啦。"\n' + + ' Then poll every 5s (up to 3 min) to confirm:\n' + + ' wget -q -O- http://localhost:3002/api/v1/agent/channels/feishu/status/\n' + + ' If { "bound": true }: "太好了!飞书绑定成功了!"\n\n' + + ' [skip / neither]: "好的,之后想绑定随时可以在 IT0 App 里操作。"\n\n' + ' Check/unbind:\n' + - ' Status: wget -q -O- http://localhost:3002/api/v1/agent/channels/dingtalk/status/\n' + - ' Unbind: wget -q -O- --post-data="" http://localhost:3002/api/v1/agent/channels/dingtalk/unbind/', + ' DingTalk status: wget -q -O- http://localhost:3002/api/v1/agent/channels/dingtalk/status/\n' + + ' DingTalk unbind: wget -q -O- --post-data="" http://localhost:3002/api/v1/agent/channels/dingtalk/unbind/\n' + + ' Feishu status: wget -q -O- http://localhost:3002/api/v1/agent/channels/feishu/status/\n' + + ' Feishu unbind: wget -q -O- --post-data="" http://localhost:3002/api/v1/agent/channels/feishu/unbind/', ); // Tenant + user context