@chenkai114/dsh-superagent-dingtalk 0.0.0-stage → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 DeepSeek Harness Team
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,104 @@
1
- # Temporary Holding Version
1
+ # dsh-superagent-dingtalk
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ > **非官方 fork。** 基于 DeepSeek 的 [dsh-superagent-prototype](https://github.com/deepseek-ai/dsh-superagent-prototype)(MIT,研究原型),只做加法:上游的 GitHub 与飞书 Source 原样保留,新增一个**钉钉** Source。
4
+
5
+ 给 [DeepSeek Harness](https://www.deepseek.com/en/harness/) 加一条钉钉通道:在群里 @ 机器人派活,它自己开工作面、干活,再把结果以**机器人身份**发回原对话;需要你拍板时会发一条「需要你决定」,你回一句它就接着干。
6
+
7
+ ```sh
8
+ dsh plugin --profile superagent add @chenkai114/dsh-superagent-dingtalk
9
+ ```
10
+
11
+ 装完在 `cordis.patch.yml` 里把 `dsh-superagent-dingtalk` 那行的 `disabled` 去掉,重启后到面板 **来源 → 钉钉** 填配置。详细步骤见 [docs/006-deployment.md](docs/006-deployment.md) 的 DingTalk 小节。
12
+
13
+ ## 它解决的两个真问题
14
+
15
+ **读和写必须用不同身份。** 钉钉没有「机器人读群全量消息」的接口,但**操作者本人的 OAuth 身份**能读到自己在的群的全部消息;反过来,机器人只能收到 @ 它的消息,却能稳定发消息。所以:
16
+
17
+ - **读**:`dws` 以操作者身份轮询,拿到全量消息与历史;
18
+ - **写**:一律以**机器人身份**发出(`sessionWebhook`、群机器人 webhook、或 `dws ... send-by-bot`)。
19
+
20
+ 结果是 agent 说的话永远署名机器人,不会冒充操作者。
21
+
22
+ **「谁在说话」有三个正交信号。** `sendType: user` + 无标记是真人;`sendType: user` + `messageAiSendFlag` 是工具借你的账号发的(客户端显示「通过AI发送」),必须跳过,否则 agent 会把自己上一轮的输出当成新指令;`sendType: robot` 是机器人。详见下文。
23
+
24
+ ## 这个 fork 增加了什么
25
+
26
+ 本仓库是 [dsh-superagent-prototype](https://github.com/deepseek-ai/dsh-superagent-prototype) 的 fork,只做加法:官方模板里的 GitHub 与飞书 Source 原样保留,新增一个 **钉钉** Source(`dsh-superagent/dingtalk-watch`)。
27
+
28
+ | 需求 | 实现 |
29
+ | --- | --- |
30
+ | 支持 dws 通道 | `dws chat message list` 以**操作者本人身份**读群消息,含没有 @ 机器人的消息与历史;轮询游标存在 KV 里,重启不丢 |
31
+ | 可设置 Stream 模式的钉钉机器人 | `streamClientId` / `streamClientSecret`,走官方 `dingtalk-stream` 长连接接收 `/v1.0/im/bot/messages/get` |
32
+ | 设置监听的群 | `groups` 每行一个 `openConversationId`,可选「仅 @」或「全部消息」;另有「其他群」与「接收私聊」开关 |
33
+ | 设置群 Bot 的 token + * | `bots` 每行一个自定义机器人(`access_token` + 可选的加签 *),只管发不管收 |
34
+ | 待决策消息反馈给用户 | 工单的 `attention` 问题渲染成「需要你决定」的结构化消息,正文末尾写明如何回复;用户回复即为该工单的新输入,执行器继续 |
35
+ | 优化消息展示样式 | 回复按用途分三种标题(需要你决定 / 工单结果 / 已收到),Markdown 渲染,超长自动截断并指向面板 |
36
+
37
+ ### 为什么读和写用两种身份
38
+
39
+ 钉钉没有「以机器人身份读取群全量消息」的接口,但**操作者的 OAuth 身份**能读到自己在的群的全部消息;反过来,机器人身份只能收到 @ 它的消息,却可以稳定地发消息。
40
+
41
+ 所以这个 Source 把两件事拆开:
42
+
43
+ - **读**:`dws` 以操作者身份轮询,拿到全量消息与历史;
44
+ - **写**:一律以**机器人身份**发出(`sessionWebhook`、群机器人 webhook、或 `dws chat message send-by-bot`)。
45
+
46
+ 结果是 agent 说的话永远署名机器人,不会冒充操作者。同理,读到 `sendType: robot` 的消息时它属于机器人,执行器会把它排除在「谁在派活」之外,避免把自己的输出当成新指令。
47
+
48
+ ### 怎么分辨「谁在说话」
49
+
50
+ 钉钉给了三个正交信号,合起来能唯一判定一条消息是谁发的:
51
+
52
+ | `sendType` | `messageAiSendFlag` | 含义 | 本 Source 的处理 |
53
+ | --- | --- | --- | --- |
54
+ | `user` | 无 | 真人打的字 | 人可以派活 |
55
+ | `user` | `DWS` | **工具通过操作者账号发的**(客户端显示「通过AI发送」) | 跳过:这是 agent 自己的输出,当输入会自激 |
56
+ | `robot` | — | 机器人发的 | 只能作为候选,永远不能单独授权工作 |
57
+
58
+ 第二行是这套设计的关键。`dws chat message send` 以操作者身份发出,`sendType` 是 `user`,光看这个字段无法和自己的发言区分;钉钉用 `messageAiSendFlag` 补上了这层。所以:
59
+
60
+ - **本 Source 从不用 `dws chat message send`**,回复一律走机器人身份(`sendType: robot`);
61
+ - 历史读取时,带 `messageAiSendFlag` 的消息**直接跳过**,避免把自己的话读成新指令;
62
+ - 实测限制:Stream 回调的报文里**没有**这个字段,只有 `dws chat message list` 有。所以 Stream 路径靠「本 Source 不发操作者消息」来保证;轮询路径有结构化的双重保护。
63
+
64
+ ### 打开它
65
+
66
+ 钉钉 Source 在 bundle 里默认 `disabled: true`。启用方式:
67
+
68
+ 1. 在 profile 的 `cordis.patch.yml` 里把 `dsh-superagent-dingtalk` 那一行的 `disabled` 去掉;
69
+ 2. 重启 `dsh-superagent`,打开面板 → **来源 → 钉钉**;
70
+ 3. 填 `dws 命令`(通常是 `dws` 或包装脚本的绝对路径),至少填一个群;
71
+ 4. 二选一配收件:Stream 机器人(实时、只收 @)或群机器人 webhook(只发);
72
+ 5. 在**策略**里把能派活的钉钉账号(staffId 或 openDingTalkId)加进允许名单——名单为空时任何请求都不会变成工单。
73
+
74
+ 见 [docs/006-deployment.md](docs/006-deployment.md) 的 DingTalk 小节。
75
+
76
+ ## Setup
77
+
78
+ Setup has many steps, so an agent does it with you. Ask your coding agent:
79
+
80
+ > Read SETUP.md in this repository and set up dsh-superagent with me.
81
+
82
+ It asks one short question at a time, shows the full plan once, and then installs and configures everything. [SETUP.md](SETUP.md) is what it follows.
83
+
84
+ ## Documentation
85
+
86
+ Read the numbered documents in order; each builds only on the ones before it.
87
+
88
+ - [000 Philosophy](docs/000-philosophy.md)
89
+ - [001 Domain model](docs/001-domain.md)
90
+ - [002 Authorization](docs/002-authorization.md)
91
+ - [003 Execution](docs/003-execution.md)
92
+ - [004 Prompts](docs/004-prompts.md)
93
+ - [005 Panel](docs/005-panel.md)
94
+ - [006 Deployment](docs/006-deployment.md): manual setup, configuration, upgrades and troubleshooting
95
+ - [007 Architecture](docs/007-architecture.md)
96
+ - [008 Cookbook](docs/008-cookbook.md): adding a Source
97
+
98
+ ## Development
99
+
100
+ `pnpm check` runs the typecheck, the tests and the build.
101
+
102
+ ## License
103
+
104
+ [MIT](LICENSE)
@@ -0,0 +1,197 @@
1
+ # dsh-superagent bundle layer: inserts the plugins without configuration, and the agent presets its Sessions run under. The
2
+ # profile supplies the `dsh-superagent` entry's stateDir (see docs/006-deployment.md and examples/profile.cordis.patch.yml); the plugin
3
+ # refuses to start without stateDir.
4
+ - insert:
5
+ - id: dsh-superagent
6
+ name: dsh-superagent
7
+ - id: dsh-superagent-github
8
+ name: '@chenkai114/dsh-superagent-dingtalk/github-watch'
9
+ # Optional DingTalk Source; enable it, then set the groups, the dws CLI, and either a Stream robot or a group robot.
10
+ - id: dsh-superagent-dingtalk
11
+ name: '@chenkai114/dsh-superagent-dingtalk/dingtalk-watch'
12
+ disabled: true
13
+ # Optional Feishu Source; requires configuring a bot CLI after enabling.
14
+ - id: dsh-superagent-feishu
15
+ name: '@chenkai114/dsh-superagent-dingtalk/feishu-watch'
16
+ disabled: true
17
+ # The agent preset of every Executor Session (WORKER_PRESET in src/app/sessions.ts); the main Session has its own, below.
18
+ # It is DSH's `standard` preset with only what a worker needs, and a shell whose foreground command moves to a background job
19
+ # after 5 seconds, so a long command does not hold back a person's message, which the Session takes at its next step. Left
20
+ # out: questions to a person, presenting, plan mode, the plugin manager and market, scheduling, goals, workflows, web fetch,
21
+ # and forked subagents, which would run under this preset; spawned subagents run under `standard`, whose shell moves a
22
+ # command to a background job only after 60 seconds, as a subagent's jobs are killed when it ends. A preset row has no
23
+ # setting that hides it from the preset picker, so its name and description say whom it is for.
24
+ - id: dsh-superagent-worker-preset
25
+ name: '@deepseek-ai/dsh-agent-preset'
26
+ config:
27
+ id: dsh-superagent-worker
28
+ name: dsh-superagent 执行器
29
+ description: dsh-superagent 的执行器 Session 专用,不供手动选择。前台命令超 5 秒转入后台,只含执行工作所需的工具。
30
+ order: 90
31
+ plugins:
32
+ - id: persona
33
+ name: '@deepseek-ai/dsh-persona'
34
+ config:
35
+ prefix: You are a coding agent powered by the {{model}} model.
36
+ - id: agent-instructions
37
+ name: '@deepseek-ai/dsh-agent-instructions'
38
+ config:
39
+ maxBytes: 65536
40
+ - id: time-context
41
+ name: '@deepseek-ai/dsh-time-context'
42
+ # A foreground command waits at most 5 s, then the shell tool moves it to a background job.
43
+ - id: shell
44
+ name: cordis:group
45
+ group: true
46
+ isolate:
47
+ shell: true
48
+ config:
49
+ - id: bash-sandbox
50
+ name: '@deepseek-ai/dsh-bash-sandbox'
51
+ disabled: !!js process.platform === 'win32'
52
+ config:
53
+ timeoutMs: 5000
54
+ maxTimeoutMs: 5000
55
+ - id: pwsh-sandbox
56
+ name: '@deepseek-ai/dsh-pwsh-sandbox'
57
+ disabled: !!js process.platform !== 'win32'
58
+ config:
59
+ timeoutMs: 5000
60
+ maxTimeoutMs: 5000
61
+ - id: tool-bash
62
+ name: '@deepseek-ai/dsh-tool-bash'
63
+ disabled: !!js process.platform === 'win32'
64
+ - id: tool-pwsh
65
+ name: '@deepseek-ai/dsh-tool-pwsh'
66
+ disabled: !!js process.platform !== 'win32'
67
+ - id: tool-fs
68
+ name: '@deepseek-ai/dsh-tool-fs'
69
+ - id: tool-fs-search
70
+ name: '@deepseek-ai/dsh-tool-fs-search'
71
+ config:
72
+ sampleOverCapGlobResults: false
73
+ # A wait for a job ends after 5 s too; the job's end wakes the worker with its result.
74
+ - id: tool-jobs
75
+ name: '@deepseek-ai/dsh-tool-jobs'
76
+ config:
77
+ waitTimeoutMs: 5000
78
+ maxWaitTimeoutMs: 5000
79
+ - id: skill-filesystem
80
+ name: '@deepseek-ai/dsh-skill-filesystem'
81
+ - id: tool-skill
82
+ name: '@deepseek-ai/dsh-tool-skill'
83
+ - id: compaction
84
+ name: cordis:group
85
+ group: true
86
+ isolate:
87
+ compaction: true
88
+ toolResultPruner: true
89
+ config:
90
+ - id: compaction-basic
91
+ name: '@deepseek-ai/dsh-compaction-basic'
92
+ - id: command-compact
93
+ name: '@deepseek-ai/dsh-command-compact'
94
+ - id: tool-result-pruner
95
+ name: '@deepseek-ai/dsh-compaction-tool-result-pruner'
96
+ config:
97
+ thresholdChars: 8192
98
+ headChars: 4096
99
+ tailChars: 1024
100
+ - id: delegation
101
+ name: cordis:group
102
+ group: true
103
+ isolate:
104
+ workflowEngine: true
105
+ config:
106
+ - id: tool-subagent-control
107
+ name: '@deepseek-ai/dsh-tool-subagent-control'
108
+ - id: tool-subagent
109
+ name: '@deepseek-ai/dsh-tool-subagent'
110
+ config:
111
+ provider: spawn
112
+ toolName: subagent
113
+ modelSelection: true
114
+ modelDiscovery: true
115
+ agentPreset: standard
116
+ - id: tool-todo
117
+ name: '@deepseek-ai/dsh-tool-todo'
118
+ config:
119
+ allowParallelInProgress: true
120
+ - id: tool-web
121
+ name: '@deepseek-ai/dsh-tool-web'
122
+ config:
123
+ fetch: false
124
+ searchTimeoutMs: 60000
125
+ # The agent preset of the main Session (ROUTER_PRESET in src/app/sessions.ts). The worker's 5-second shell and job waits, so a command or a wait does not hold back the next candidates, and
126
+ # only what the main Session uses: no subagents, web, file search or writes, todo list, questions to a person, presenting,
127
+ # plan mode, plugin manager, scheduling, goals or workflows. No persona: the main Session's prompt is complete, so it has
128
+ # no other section.
129
+ - id: dsh-superagent-router-preset
130
+ name: '@deepseek-ai/dsh-agent-preset'
131
+ config:
132
+ id: dsh-superagent-router
133
+ name: dsh-superagent 主 Session
134
+ description: dsh-superagent 的主 Session 专用,不供手动选择。前台命令和任务等待超 5 秒转入后台,只含路由所需的工具。
135
+ order: 91
136
+ plugins:
137
+ - id: agent-instructions
138
+ name: '@deepseek-ai/dsh-agent-instructions'
139
+ config:
140
+ maxBytes: 65536
141
+ - id: time-context
142
+ name: '@deepseek-ai/dsh-time-context'
143
+ - id: shell
144
+ name: cordis:group
145
+ group: true
146
+ isolate:
147
+ shell: true
148
+ config:
149
+ - id: bash-sandbox
150
+ name: '@deepseek-ai/dsh-bash-sandbox'
151
+ disabled: !!js process.platform === 'win32'
152
+ config:
153
+ timeoutMs: 5000
154
+ maxTimeoutMs: 5000
155
+ - id: pwsh-sandbox
156
+ name: '@deepseek-ai/dsh-pwsh-sandbox'
157
+ disabled: !!js process.platform !== 'win32'
158
+ config:
159
+ timeoutMs: 5000
160
+ maxTimeoutMs: 5000
161
+ - id: tool-bash
162
+ name: '@deepseek-ai/dsh-tool-bash'
163
+ disabled: !!js process.platform === 'win32'
164
+ - id: tool-pwsh
165
+ name: '@deepseek-ai/dsh-tool-pwsh'
166
+ disabled: !!js process.platform !== 'win32'
167
+ - id: tool-fs
168
+ name: '@deepseek-ai/dsh-tool-fs'
169
+ config:
170
+ write: false
171
+ edit: false
172
+ - id: tool-jobs
173
+ name: '@deepseek-ai/dsh-tool-jobs'
174
+ config:
175
+ waitTimeoutMs: 5000
176
+ maxWaitTimeoutMs: 5000
177
+ - id: skill-filesystem
178
+ name: '@deepseek-ai/dsh-skill-filesystem'
179
+ - id: tool-skill
180
+ name: '@deepseek-ai/dsh-tool-skill'
181
+ - id: compaction
182
+ name: cordis:group
183
+ group: true
184
+ isolate:
185
+ compaction: true
186
+ toolResultPruner: true
187
+ config:
188
+ - id: compaction-basic
189
+ name: '@deepseek-ai/dsh-compaction-basic'
190
+ - id: command-compact
191
+ name: '@deepseek-ai/dsh-command-compact'
192
+ - id: tool-result-pruner
193
+ name: '@deepseek-ai/dsh-compaction-tool-result-pruner'
194
+ config:
195
+ thresholdChars: 8192
196
+ headChars: 4096
197
+ tailChars: 1024