cc-haha/docs/im/dingtalk.md
程序员阿江(Relakkes) 6d9aa98022 Support DingTalk IM without blocking on project history
DingTalk uses QR registration to store client credentials, then reuses the existing IM pairing and session bridge. The merged main implementation keeps the existing WeChat QR binding path intact while adding DingTalk as a peer IM platform. The default IM workdir now falls back to the local user working directory so a newly bound chat can start immediately even when recent-project history is empty.

Constraint: Local main already carries WeChat IM, so the merge keeps WeChat config, QR binding, sidecar args, and unbind behavior intact while adding DingTalk.
Rejected: Keep empty defaultProjectDir as project-picker-only | newly bound IM users can hit a dead end with no recent projects.
Confidence: high
Scope-risk: moderate
Directive: Keep IM platform unions synchronized across config, pairing, sidecar args, desktop settings, and docs.
Tested: bun test common/ dingtalk/ wechat/; bun test src/server/__tests__/adapters.test.ts; cd adapters && bunx tsc --noEmit; bun run check:policy; bun run check:server; bun run check:desktop; bun run check:adapters; bun run check:native; bun run check:docs
Not-tested: quality:pr full gate was blocked by existing local main CLI-core diff requiring allow-cli-core-change maintainer approval; live post-fix DingTalk second-message delivery was not repeated after the merge.
2026-05-03 17:56:22 +08:00

1.4 KiB
Raw Blame History

钉钉接入

钉钉接入走 DingTalk Stream不需要公网回调地址。桌面端设置页支持扫码创建并授权机器人授权成功后会把 clientId / clientSecret 写入 ~/.claude/adapters.json

配置方式

打开 Desktop Webapp 的 Settings -> IM 接入 -> 钉钉

推荐方式:

  1. 点击“扫码绑定”
  2. 使用钉钉手机 App 扫码
  3. 在钉钉里确认创建机器人
  4. 等待桌面端显示已绑定

如果扫码不可用,也可以手动填写:

  • Client ID
  • Client Secret
  • 可选 Stream Endpoint
  • 可选 Allowed Users

配对用户

钉钉机器人绑定完成后,还需要让具体用户通过 IM 配对码授权:

  1. 配对管理 里生成配对码
  2. 在钉钉私聊里把配对码发给机器人
  3. 显示配对成功后即可开始聊天

配对用户会出现在“已配对用户”列表里,可以随时解绑。解绑后该用户需要重新发送新的配对码才能使用。

运行 adapter

桌面端发布版会通过 sidecar 自动启动。开发时可以手动运行:

cd adapters
bun install
bun run dingtalk

当前行为

  • 只处理钉钉单聊消息
  • 使用 sessionWebhook 回复文本 / Markdown
  • 支持 /new/projects/status/clear/stop/help
  • 权限确认通过 /allow <requestId>/deny <requestId> 回复
  • 群聊、媒体附件、AI Card 流式卡片后续再扩展