dsh-superagent-inbox 0.0.0-stage → 0.1.0

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,154 @@
1
- # Temporary Holding Version
1
+ # dsh-superagent-inbox
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
+ > 让 [DeepSeek Harness](https://www.deepseek.com/en/harness/) 上的 [dsh-superagent](https://github.com/deepseek-ai/dsh-superagent-prototype) **零外部依赖**跑起来:一个基于本地文件收件箱的 Source 插件。投放一条 JSON 消息,Super-agent 评估、建单、派出 Worker、把结果写回你的文件夹。
4
+
5
+ 本项目是 dsh-superagent(DeepSeek Harness 团队的 Super-agent 研究原型)的**扩展发行版**:在官方 bundle 之上新增了 `inbox` Source 插件(`./inbox-watch`),其余代码保持上游原样,MIT 许可,出处见文末。
6
+
7
+ ---
8
+
9
+ ## 1. 背景:这套东西解决什么问题
10
+
11
+ DeepSeek Harness 团队在 2026-10-31 发布了文章 [《Super-agent 设计探索:迈向更自主的 Agent 系统》](https://mp.weixin.qq.com/s/zoS7GlReWPhfCjENGxXCdg),并提出开源原型 dsh-superagent。其核心判断是:单任务 Coding Agent 已经可用,瓶颈转向**人的注意力**——一个人通常只能同时跟进 3–5 个活跃 Session。
12
+
13
+ Super-agent 用四个特征回应:**连续**(跨信道只有一个 Agent)、**高效**(多任务并发)、**主动**(事件驱动)、**持久**(异常自愈)。支撑它的五个模块:
14
+
15
+ | 模块 | 一句话 |
16
+ |---|---|
17
+ | 双层架构 | Router 层常驻路由(只分派、不执行),Worker 层上下文隔离并发执行 |
18
+ | 事件驱动 | 环境事件即 Trigger;两级过滤(程序 Fast Path + 模型 Slow Path)、订阅直通、Inline & Spill、链式召回 |
19
+ | 面向人的交互 | 异步 ReAct Loop;多信道带宽匹配(IM ≤100 词硬上限,只在需要人时说话) |
20
+ | 存算分离 | Agent Loop 无状态化,Session 状态入库,执行环境留在原地(BYOM) |
21
+ | Watchdog | 主系统外部的 Control Loop,既查基础设施也查任务实质进展 |
22
+
23
+ 官方原型内置 GitHub 与飞书两个 Source(事件来源),但都需要账号/机器人配置。**本项目新增的 `inbox` Source 补上"最后一公里":任何有终端的人,用一个文件夹就能驱动整条 Trigger → Eval → Ticket → Worker → Channel 链路。**
24
+
25
+ ## 2. inbox 插件设计
26
+
27
+ ### 2.1 目录协议
28
+
29
+ ```text
30
+ <root>/ ← 面板里配置的收件箱根目录
31
+ ops/ ← 一个"对话"(conversation)
32
+ in/ ← 你把消息 JSON 投到这里
33
+ done/ ← 已被 Agent 接收的消息(自动移入,相当于读取游标)
34
+ out/ ← Agent 的回复 JSON 出现在这里
35
+ town/ ← 另一个对话,可以有不同的接收策略
36
+ ```
37
+
38
+ ### 2.2 消息格式(投放 `in/*.json`)
39
+
40
+ ```json
41
+ {
42
+ "id": "m-001", // 必填,对话内唯一(重放安全:Trigger id 由 conversation+id 派生)
43
+ "from": "alice", // 必填,发送者身份(进入 Policy 白名单判断)
44
+ "text": "把设置页的保存按钮文案改成「保存更改」",
45
+ "to": "agent", // 可选:写 agent(或配置的 agentName)= 向智能体喊话 → 显式授权强度
46
+ "at": "2026-11-01T10:00:00+08:00",
47
+ "bot": false, // 可选:true 标记为机器人/CI,永远不能自行授权工作
48
+ "thread": "m-000", // 可选:所属话题的根消息 id(同话题后续消息直通 Worker)
49
+ "reply_to": "m-000", // 可选:直接回复哪条消息(评估时展示上下文)
50
+ "url": "https://..." // 可选:原文链接
51
+ }
52
+ ```
53
+
54
+ ### 2.3 回复格式(出现在 `out/*.json`,文件名即消息 id,天然幂等)
55
+
56
+ ```json
57
+ {
58
+ "id": "d402...c1",
59
+ "conversation": "ops",
60
+ "to": "m-001",
61
+ "thread": "m-001",
62
+ "reply_to": "m-001",
63
+ "from": "dsh-superagent",
64
+ "text": "已提交 <产物路径>,可验收。",
65
+ "at": "2026-11-01T10:12:33.000Z",
66
+ "ticket_id": "T-0001"
67
+ }
68
+ ```
69
+
70
+ ### 2.4 与 Super-agent 领域模型的集成点
71
+
72
+ | 领域概念 | inbox 的映射 |
73
+ |---|---|
74
+ | Trigger | 一个消息文件;id = `key('inbox', conversation, id)`,重放安全 |
75
+ | Thread | `<conversation>:<根消息 id>`——同话题连续消息构成事件流,**订阅直通**由此生效 |
76
+ | Actor / Policy | `from` 进白名单;`to: agent` 即显式喊话(explicit 强度);bot 消息最多成为推断候选 |
77
+ | Admission | 每个对话一行准入表:`mentions`(仅 @)或 `all`(全部消息) |
78
+ | Channel | 回复写 `out/`,以消息 id 幂等(`wx` 标志),永不"永久失败" |
79
+ | threadContext | 评估时读取该话题全部消息(含 Agent 回复,标记 bot),分页供链式召回 |
80
+ | Worker 环境变量 | `DSH_SUPERAGENT_INBOX_CONVERSATION` 告诉 Worker 工单来自哪个对话 |
81
+
82
+ 安全模型沿用 dsh-superagent 的完整 Policy:不在白名单里的人、bot、CI **不能授权工作**;白名单 + 显式喊话才产生 explicit 工单;观察性工作(auto 模式的规则匹配)只在你启用并写明规则后发生。
83
+
84
+ ## 3. 安装(DeepSeek Harness)
85
+
86
+ 前置:DeepSeek Harness `dsh ^0.2.1-alpha.2`、Node `^22.19 || >=24`、pnpm。
87
+
88
+ ```bash
89
+ git clone https://github.com/JHOpenDev/dsh-superagent-inbox.git
90
+ cd dsh-superagent-inbox
91
+ pnpm install && pnpm check # typecheck + 全部测试 + 构建 lib/
92
+ ```
93
+
94
+ 1. 按 [SETUP.md](SETUP.md) 完成 dsh-superagent 的基础部署(仓库、GitHub 账号;GitHub 账号是 Worker 提交 PR 用的,若只跑 inbox 也可以配一个最小权限账号)。
95
+ 2. 在 profile 的 `cordis.patch.yml`(`$DSH_HOME/profiles/<profile>/`)中启用 inbox:
96
+
97
+ ```yaml
98
+ - id: dsh-superagent
99
+ config:
100
+ stateDir: /home/me/.dsh/state/superagent
101
+ - id: dsh-superagent-inbox
102
+ disabled: false
103
+ ```
104
+
105
+ 3. 重启 Harness,打开 **Superagent 侧边栏面板 → Sources → Local inbox**,配置:
106
+ - `root`:收件箱根目录(绝对路径)
107
+ - `conversations`:至少一个对话,如 `{ id: "ops", listen: "mentions" }`
108
+ 4. **Eval → On each Source → Local inbox**:把你自己(`from` 的值)加入 allowed 名单。
109
+
110
+ ## 4. 使用
111
+
112
+ ```bash
113
+ # 1) 投放一条工作请求
114
+ cat > $ROOT/ops/in/m-001.json <<'EOF'
115
+ { "id": "m-001", "from": "alice", "to": "agent",
116
+ "text": "把 README 的安装命令从 npm 改成 pnpm" }
117
+ EOF
118
+
119
+ # 2) 等 Router pass(秒级轮询):面板会看到 Eval → accept → Ticket → Worker 运行
120
+ # 3) 结果出现在回复目录
121
+ cat $ROOT/ops/out/*.json
122
+ # 4) 在同话题追问(thread: "m-001")会直通该工单的 Worker,无需再 @
123
+ ```
124
+
125
+ 同话题后续消息(带 `thread` 字段)经**订阅直通**直达 Worker,不消耗 Router 判断;一段纯闲聊会被两级过滤安静丢弃(面板 Sources 页可见 `filtered` 审计)。
126
+
127
+ ## 5. 验证
128
+
129
+ **单元与构建**:`pnpm check`(tsc + vitest + tsdown)1202/1204 通过;唯一失败项是上游 `environment.spec` 的 git 报错文案断言(本机 git 文案差异,未修改的上游基线同样失败)。新增 `tests/inbox.spec.ts` 7 项全绿。
130
+
131
+ **真实运行时端到端**(DeepSeek Harness `dsh 0.2.1-rc.3`,专用 superagent profile):
132
+
133
+ ```text
134
+ 收件箱投放 m-015 → Trigger 接收(移入 done/) → 评估接单(白名单+to:agent=explicit)
135
+ → 创建工单 → Worker 会话(bash/fs/gh 可用) → 修改 README → 提交分支
136
+ → PR #1 创建 → out/ 收到交付回复(≤100词, 附 PR 链接)
137
+ ```
138
+
139
+ 期间同样验证了:同 Thread 追问被评估按"同一请求已由工单承接"去重;显式停止指令经评估收回授权;
140
+ 纯闲聊被两级过滤安静丢弃(面板可见 filtered 审计)。
141
+
142
+ **版本要求(重要)**:bundle 依赖的 `@deepseek-ai/dsh-*` 工具包必须与运行时 DSH 版本一致——
143
+ 加载器会禁用版本不匹配的预设插件行(症状:Worker 会话没有 bash/fs/gh 工具)。本仓库全部锁定
144
+ `0.2.1-rc.3` 并把它们放进 `dependencies`;使用其他 DSH 版本时请同步调整。
145
+
146
+ ## 6. ZCode 适配器(adapters/zcode-plugin)
147
+
148
+ 同一套架构思想在 ZCode 上的移植(技能 + 斜杠命令实现:Router=主会话、Worker=后台子代理、订阅直通=SendMessage、Watchdog=巡检命令)。它不依赖本 bundle,安装方法见 [adapters/zcode-plugin/README.md](adapters/zcode-plugin/README.md)。两个实现的领域术语保持一致(Trigger/Thread/Ticket/Mandate/Watchdog),可作为"harness 无关的 Super-agent 架构"的对照样本。
149
+
150
+ ## 7. 出处与致谢
151
+
152
+ - 架构与领域模型来自 DeepSeek Harness 团队的文章与实践:**《Super-agent 设计探索:迈向更自主的 Agent 系统》**(微信公众号「DeepSeek Harness 团队」,2026-10-31)与官方原型 [deepseek-ai/dsh-superagent-prototype](https://github.com/deepseek-ai/dsh-superagent-prototype)(MIT)。本仓库绝大部分代码属于他们——本项目的增量是 `src/sources/inbox.ts`、`tests/inbox.spec.ts`、bundle 接线与这份文档。
153
+ - 遵循原型的哲学:**尽可能少占用人的注意力,尽可能多地交付价值。** inbox Source 默认只接收配置过的对话、只让白名单里的人发起工作、只在需要人行动或结果可交付时写 `out/`。
154
+ - License: [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-inbox
7
+ - id: dsh-superagent-github
8
+ name: dsh-superagent-inbox/github-watch
9
+ # Optional Feishu Source; requires configuring a bot CLI after enabling.
10
+ - id: dsh-superagent-feishu
11
+ name: dsh-superagent-inbox/feishu-watch
12
+ disabled: true
13
+ # Optional local-inbox Source; point its root at a directory of message files after enabling.
14
+ - id: dsh-superagent-inbox
15
+ name: dsh-superagent-inbox/inbox-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