@xiangyixie/dsh-superagent 0.14.1 → 0.14.3

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/cordis.patch.yml CHANGED
@@ -1,9 +1,32 @@
1
- # dsh-superagent bundle layer.
2
- #
3
- # Inserts one tools-only plugin row at PROFILE scope, so every session in the
4
- # profile can start a run. The package never edits the profile's `bundles`
5
- # list — that entry is the operator's action (`dsh plugin --profile <name> add
6
- # @xiangyixie/dsh-superagent`).
7
- - insert:
8
- - id: superagent
9
- name: '@xiangyixie/dsh-superagent'
1
+ # dsh-superagent bundle layer.
2
+ #
3
+ # Inserts one tools-only plugin row at PROFILE scope, so every session in the
4
+ # profile can start a run. The package never edits the profile's `bundles`
5
+ # list — that entry is the operator's action (`dsh plugin --profile <name> add
6
+ # @xiangyixie/dsh-superagent`).
7
+ #
8
+ # It also declares the tool-less planner preset that `plannerPreset` points at.
9
+ # The host preset schema has no `hidden`/`internal` field, so this preset cannot
10
+ # be removed from the mode picker; naming it in Chinese, describing it, and
11
+ # sorting it last is the closest the schema allows. Without this row a fresh
12
+ # install shows a bare `planner` entry (empty description, first in the list),
13
+ # and picking it leaves the session with no tools at all.
14
+ - insert:
15
+ - id: superagent
16
+ name: '@xiangyixie/dsh-superagent'
17
+ - id: preset-planner
18
+ name: '@deepseek-ai/dsh-agent-preset'
19
+ config:
20
+ id: planner
21
+ name: 插件内部:规划器(请勿选择)
22
+ description: >-
23
+ dsh-superagent 生成计划专用,没有工具权限;手动选中后对话里没有任何工具,请保持使用「标准模式」。
24
+ order: 9999
25
+ plugins:
26
+ - id: persona
27
+ name: '@deepseek-ai/dsh-persona'
28
+ config:
29
+ prefix: >-
30
+ You are a planning assistant. You receive a goal and answer with
31
+ one JSON plan object. You have no tools, so answer from the
32
+ prompt alone.
package/docs/DETAIL.md CHANGED
@@ -1,9 +1,12 @@
1
+ [中文](https://github.com/LittleChenLiya/dsh-superagent/blob/main/docs/DETAIL.zh.md) | English
2
+
1
3
  # Superagent
2
4
 
3
5
  Long-horizon autonomous runs: give it one goal and it plans parallel subtasks, runs them in workers, and merges the outcome into one report. A restart does not throw the work away.
4
6
 
5
7
  ## What it solves
6
8
 
9
+ - **Your work spans several domains, and managing sessions costs more than doing the work.** Code, documents, data, and browser steps each get their own session, progress notes, and context; the more of them you run, the easier it is to lose track of where you stopped. The plugin works as a dispatch desk: you state the result you want, and it splits the work, runs it in parallel, tracks progress, and merges the result. You give the orders, make the key calls, and accept the outcome, without tending the conversational details.
7
10
  - **A goal that does not fit one step.** The goal is planned into dependent subtasks and advanced step by step instead of being crammed into one conversation.
8
11
  - **Work that runs too slowly in sequence.** Independent subtasks run in parallel, each in its own worktree, without overwriting one another.
9
12
  - **Runs that get interrupted.** The plan, progress, and produced files are durable; a host restart or a closed conversation does not reset the run.
package/docs/DETAIL.zh.md CHANGED
@@ -1,9 +1,12 @@
1
+ 中文 | [English](https://github.com/LittleChenLiya/dsh-superagent/blob/main/docs/DETAIL.md)
2
+
1
3
  # 超级智能体
2
4
 
3
5
  长周期自主执行插件:给出一个目标,它把目标拆成可并行的子任务,交给 worker 执行,最后合并成一份报告。进程重启后仍能从断点继续,不必从头再来。
4
6
 
5
7
  ## 它解决什么问题
6
8
 
9
+ - **你的事横跨好几个领域,管会话比干活还累。** 代码、文档、数据、网页上的操作,各自都要开会话、记进度、接上下文,一多就乱,还容易忘掉上次做到哪。这个插件当一个调度台用:你说清要什么结果,它拆活、并行、盯进度、最后汇总;你只管下命令、做关键判断、验收结果,不必操心对话里的细枝末节。
7
10
  - **目标大,一步做不完。** 把一句话目标拆成有依赖关系的子任务,按计划推进,而不是把所有事塞进一次对话。
8
11
  - **串行太慢。** 互不依赖的子任务并行执行,各自在自己的工作区里干活,互不覆盖。
9
12
  - **中途会断。** 计划、进度和已产出的文件都落盘;宿主重启或对话结束之后可以继续。
@@ -0,0 +1,327 @@
1
+ /**
2
+ * dsh-superagent — the Chinese copy the board shows to a person.
3
+ *
4
+ * Every string here answers "what happened, why do I care, what can I do".
5
+ * Raw error text is kept as `detail` so the page can fold it away instead of
6
+ * leading with a stack trace.
7
+ *
8
+ * @module dsh-superagent/board-messages
9
+ */
10
+
11
+ export const RUN_STATUS = Object.freeze({
12
+ queued: '排队中',
13
+ planning: '正在拆解任务',
14
+ running: '正在执行',
15
+ aggregating: '正在汇总结果',
16
+ completed: '已完成',
17
+ partial: '部分完成',
18
+ failed: '失败',
19
+ cancelled: '已取消',
20
+ interrupted: '被中断,可继续',
21
+ })
22
+
23
+ export const SUBTASK_STATUS = Object.freeze({
24
+ pending: '等待执行',
25
+ waiting: '等待前置任务',
26
+ running: '正在执行',
27
+ completed: '已完成',
28
+ failed: '失败',
29
+ skipped: '已跳过',
30
+ unverified: '等你确认',
31
+ cancelled: '已取消',
32
+ blocked: '缺少能力,未启动',
33
+ })
34
+
35
+ export const INBOX_KIND = Object.freeze({
36
+ question: '需要你回答',
37
+ review: '需要你验收',
38
+ permission: '需要你授权',
39
+ human: '需要你亲自操作',
40
+ resume: '需要你继续',
41
+ })
42
+
43
+ export function runStatusLabel(status) {
44
+ return RUN_STATUS[status] ?? (status ? `未知状态(${status})` : '未知状态')
45
+ }
46
+
47
+ export function subtaskStatusLabel(status) {
48
+ return SUBTASK_STATUS[status] ?? (status ? `未知状态(${status})` : '未知状态')
49
+ }
50
+
51
+ const CAPABILITY_HINTS = Object.freeze({
52
+ browser: '在宿主的工具配置里启用 runtime.browser,或换一个带浏览器工具的会话。',
53
+ desktop: '在宿主配置里启用 runtime.desktop,或在有桌面控制能力的会话里重跑。',
54
+ shell: '给当前会话加上命令执行工具,或在支持命令的会话里重跑。',
55
+ network: '当前会话禁用了联网工具;换一个有联网能力的会话再重跑。',
56
+ })
57
+
58
+ export function capabilityHint(name) {
59
+ return CAPABILITY_HINTS[name] ?? `给当前会话加上提供「${name}」的工具,然后从待办里点重跑。`
60
+ }
61
+
62
+ function textOf(value) {
63
+ return typeof value === 'string' ? value.trim() : ''
64
+ }
65
+
66
+ function firstMissing(subtask) {
67
+ return Array.isArray(subtask?.missingCapabilities) ? subtask.missingCapabilities.filter(Boolean) : []
68
+ }
69
+
70
+ /**
71
+ * Explain one failure in plain Chinese.
72
+ *
73
+ * @param {object} run - run record, or a subtask-bearing view.
74
+ * @param {object | null} [subtask] - the subtask the failure belongs to.
75
+ * @returns {{ code: string, title: string, what: string, why: string, action: object | null, detail: string | null }}
76
+ */
77
+ export function explainFailure(run, subtask = null) {
78
+ const raw = textOf(subtask?.error) || textOf(subtask?.blockedReason) || textOf(subtask?.unverifiedReason)
79
+ || textOf(run?.error) || ''
80
+ const missing = firstMissing(subtask)
81
+ const source = subtask ?? {}
82
+ const where = source.title ? `「${source.title}」` : '这个任务'
83
+
84
+ if (missing.length > 0 || source.blockKind === 'capability') {
85
+ return {
86
+ code: 'capability-missing',
87
+ title: '缺少这项能力,任务没有开始',
88
+ what: `${where}需要 ${missing.join('、') || '一个当前会话没有的工具'},当前会话没有提供,所以它没有启动,也没有花 token。`,
89
+ why: '能力预检在开工前就拦住了它,这是有意的:让一个没有工具的模型硬做,只会编造结果。',
90
+ action: { kind: 'config', label: '看看怎么补上这项能力' },
91
+ detail: raw || null,
92
+ }
93
+ }
94
+
95
+ if (/plan rejected|no parsable plan|planner did not return a usable plan|planner reply|plan is not|unparsable/i.test(raw)) {
96
+ return {
97
+ code: 'plan-unusable',
98
+ title: '规划器没有给出能执行的计划',
99
+ what: '任务在拆解阶段就停了,一个子任务都没有启动。常见原因是模型回复不是合法 JSON,或计划里出现了循环依赖。',
100
+ why: '与其拿一份看不懂的计划硬跑,不如停下来把原因告给你,这样不会白花钱。',
101
+ action: { kind: 'retry', label: '重新规划并重试' },
102
+ detail: raw || null,
103
+ }
104
+ }
105
+
106
+ if (/empty deliverable|deliverable|交付物|expected a .* file|not a file|misplaced/i.test(raw)) {
107
+ return {
108
+ code: 'deliverable-missing',
109
+ title: '子任务说做完了,但交付物没通过检查',
110
+ what: `${where}声明要交出的文件或结果没有通过校验:可能不存在、是空的、类型不对,或被写到了别的目录。`,
111
+ why: '完成与否看的是产物,不是模型说自己做完了。没有产物的「完成」会污染最后的报告。',
112
+ action: { kind: 'rerun', label: '让这条子任务重做' },
113
+ detail: raw || null,
114
+ }
115
+ }
116
+
117
+ if (/spawn\s+EPERM/i.test(raw)) {
118
+ return {
119
+ code: 'spawn-eperm',
120
+ title: '系统拒绝了启动子任务进程',
121
+ what: '宿主沙箱不允许再启动一个子进程(spawn EPERM)。这是宿主的权限边界,不是任务本身做错了。',
122
+ why: '常见于沙箱权限过严或临时目录不可写;子任务需要在自己的会话里启动。',
123
+ action: { kind: 'config', label: '查看沙箱设置说明' },
124
+ detail: raw || null,
125
+ }
126
+ }
127
+
128
+ if (/sandbox|EPERM|EACCES|not writable|cannot write|write denied|ACL|permission denied|access is denied/i.test(raw)) {
129
+ return {
130
+ code: 'sandbox-write',
131
+ title: '沙箱不允许写入这个目录',
132
+ what: `${where}需要写文件,但目标目录不在当前会话的可写范围里,写入被拒绝了。`,
133
+ why: '沙箱的可写边界跟随父会话的工作目录;工作目录和任务目录不一致时会这样。',
134
+ action: { kind: 'config', label: '查看工作目录设置' },
135
+ detail: raw || null,
136
+ }
137
+ }
138
+
139
+ if (/child stopped with reason "?error"?|subagent (failed|stopped)|nothing came back from the child/i.test(raw)) {
140
+ return {
141
+ code: 'model-unavailable',
142
+ title: '子任务没能跑起来,可能是模型或端点不可用',
143
+ what: `${where}在第一次调用模型时就停下了,没有产出。常见原因是模型名写错、端点连不上、密钥或额度失效,也可能是启动子会话失败。`,
144
+ why: '任务本身还没开始做,重试的成本很低;先确认模型配置,再让它重跑。',
145
+ action: { kind: 'model', label: '检查模型配置' },
146
+ detail: raw || null,
147
+ }
148
+ }
149
+
150
+ if (/subagent-unavailable|ECONNREFUSED|ENOTFOUND|ETIMEDOUT|unauthorized|401|403|429|model.*(not found|unavailable)|endpoint|provider|api key|rate limit|额度/i.test(raw)) {
151
+ return {
152
+ code: 'model-unavailable',
153
+ title: '模型或接口暂时不可用',
154
+ what: '子任务需要调用模型,但请求被拒绝、超时,或这个模型在当前配置里找不到。',
155
+ why: '这通常是地址、密钥、额度或模型名的问题,任务本身没有被执行。',
156
+ action: { kind: 'model', label: '检查模型配置' },
157
+ detail: raw || null,
158
+ }
159
+ }
160
+
161
+ if (/deadline|timed? ?out|budget|max(imum)? (spend|tokens|model calls)|quota|额度|超时/i.test(raw)) {
162
+ return {
163
+ code: 'budget-or-timeout',
164
+ title: '预算或时间用完了',
165
+ what: '运行达到了时间、token 或花费上限,剩下的工作没有继续。已经完成的部分会保留。',
166
+ why: '上限是为了避免一次运行花掉太多;提高上限或缩小目标后可以继续。',
167
+ action: { kind: 'retry', label: '继续未完成的工作' },
168
+ detail: raw || null,
169
+ }
170
+ }
171
+
172
+ if (/owning session .* is not live|owner session|not live/i.test(raw)) {
173
+ return {
174
+ code: 'schedule-owner-gone',
175
+ title: '定时计划的发起会话已经关闭',
176
+ what: '定时任务由创建它的会话发起;那个会话已经不在了,所以这次窗口没有执行。',
177
+ why: '定时运行需要一个活着的会话来承载权限和模型配置。',
178
+ action: { kind: 'config', label: '查看定时任务说明' },
179
+ detail: raw || null,
180
+ }
181
+ }
182
+
183
+ if (/host process stopped while the run was active|run was interrupted|interrupted while running/i.test(raw)) {
184
+ return {
185
+ code: 'interrupted',
186
+ title: '宿主在运行中途停下来了',
187
+ what: '这次运行还没结束,宿主进程就退出了。子任务的记录都在,可以接着做。',
188
+ why: '重启、升级或手动关掉宿主都会这样;已完成的子任务不会重跑。',
189
+ action: { kind: 'retry', label: '接着跑完这次运行' },
190
+ detail: raw || null,
191
+ }
192
+ }
193
+
194
+ if (source.status === 'cancelled') {
195
+ return {
196
+ code: 'cancelled',
197
+ title: '这条子任务被你取消了',
198
+ what: '它停下了,同一次运行里的其他子任务不受影响。依赖它的子任务会被跳过,并注明原因。',
199
+ why: '取消只停这一条,不会重跑整个任务。',
200
+ action: { kind: 'rerun', label: '重新运行这一条' },
201
+ detail: null,
202
+ }
203
+ }
204
+
205
+ if (source.status === 'unverified') {
206
+ return {
207
+ code: 'needs-review',
208
+ title: '交付物需要你确认',
209
+ what: `${where}写出了文件,但当前会话没有能力判断它是否正确,所以没有算作完成。`,
210
+ why: '让一个无法验证的模型自称完成,会污染最终报告;这一票留给你。',
211
+ action: { kind: 'review', label: '去验收' },
212
+ detail: raw || null,
213
+ }
214
+ }
215
+
216
+ return {
217
+ code: 'unknown',
218
+ title: '运行失败了',
219
+ what: raw ? `失败信息:${raw}` : '没有拿到具体错误。可以先重试;如果重复出现,把诊断信息复制出来。',
220
+ why: '这条错误不在已知类型里,原始信息保留在下面。',
221
+ action: { kind: 'retry', label: '重试' },
222
+ detail: raw || null,
223
+ }
224
+ }
225
+
226
+ /**
227
+ * Explain a whole run. Subtask failures win over the run's own summary because
228
+ * they name the thing that actually broke.
229
+ *
230
+ * @param {object} run - run record.
231
+ * @returns {object | null} an explanation, or null when nothing failed.
232
+ */
233
+ export function explainRun(run) {
234
+ const failed = (run?.subtasks ?? []).find(subtask => subtask.status === 'failed' && subtask.error)
235
+ if (failed) return { ...explainFailure(run, failed), subtaskKey: failed.key ?? null }
236
+ const blocked = (run?.subtasks ?? []).find(subtask => subtask.status === 'blocked')
237
+ if (blocked) return { ...explainFailure(run, blocked), subtaskKey: blocked.key ?? null }
238
+ const unverified = (run?.subtasks ?? []).find(subtask => subtask.status === 'unverified')
239
+ if (unverified) return { ...explainFailure(run, unverified), subtaskKey: unverified.key ?? null }
240
+ if (run?.error) return explainFailure(run, null)
241
+ return null
242
+ }
243
+
244
+ /** A short, non-technical label for why a subtask never ran. */
245
+ export function skipReason(subtask, run) {
246
+ if (subtask?.status !== 'skipped') return null
247
+ const upstream = Array.isArray(subtask.waitingOn) && subtask.waitingOn.length > 0
248
+ ? subtask.waitingOn
249
+ : (subtask.dependsOn ?? [])
250
+ const names = upstream.map(key => {
251
+ const other = (run?.subtasks ?? []).find(item => item.key === key)
252
+ if (!other) return key
253
+ return `${other.title || key}(${subtaskStatusLabel(other.status)})`
254
+ })
255
+ if (names.length > 0) return `前置任务没有完成:${names.join('、')}`
256
+ return subtask.skippedReason || '前置任务没有完成'
257
+ }
258
+
259
+ const PARAM_COPY = Object.freeze({
260
+ symptom: { label: '故障现象', hint: '粘贴真实报错或错误输出,不要转述' },
261
+ reproduction: { label: '复现步骤', hint: '能触发问题的命令或操作步骤' },
262
+ expected: { label: '期望结果', hint: '正确时应有的行为' },
263
+ scope: { label: '允许改动的范围', hint: '可改的文件或模块,以及不能碰的部分' },
264
+ target: { label: '要审查的对象', hint: 'diff、文件或模块' },
265
+ focus: { label: '审查重点', hint: '正确性、安全、性能、兼容性等' },
266
+ verification: { label: '验证方式', hint: '证明修复有效的命令或检查' },
267
+ change: { label: '改了什么', hint: '代码或配置的变更内容' },
268
+ audience: { label: '读者是谁', hint: '他们已具备哪些背景知识' },
269
+ sources: { label: '权威来源', hint: '保存当前事实的文件' },
270
+ question: { label: '要研究的问题', hint: '报告必须回答的问题' },
271
+ scope_research: { label: '范围与限制', hint: '时间范围、可用或不可用的来源' },
272
+ purpose: { label: '报告用途', hint: '这份报告要支持哪个决定' },
273
+ })
274
+
275
+ export function parameterCopy(name, templateId) {
276
+ // "scope" means different things: files a fix may touch, versus the range a
277
+ // report covers. The label has to match the template that asks for it.
278
+ if (name === 'scope' && templateId === 'research-report') return PARAM_COPY.scope_research
279
+ return PARAM_COPY[name] ?? { label: name, hint: '按模板要求填写' }
280
+ }
281
+
282
+ const TEMPLATE_COPY = Object.freeze({
283
+ 'bugfix-verify': {
284
+ title: '缺陷修复并验证',
285
+ purpose: '修一个已知的缺陷,并用测试证明修好了',
286
+ bestFor: '有稳定复现步骤的 bug',
287
+ estimate: 3,
288
+ translated: true,
289
+ },
290
+ 'review-fix': {
291
+ title: '审查并修复代码问题',
292
+ purpose: '审查一段代码,并把确认的问题直接修掉',
293
+ bestFor: '提交前审查、模块体检',
294
+ estimate: 3,
295
+ translated: true,
296
+ },
297
+ 'docs-examples': {
298
+ title: '更新文档与示例',
299
+ purpose: '让文档和示例与代码的真实行为一致',
300
+ bestFor: '改了接口、配置或命令之后',
301
+ estimate: 2,
302
+ translated: true,
303
+ },
304
+ 'research-report': {
305
+ title: '调研并写报告',
306
+ purpose: '比较多个来源,产出一份有证据的调研报告',
307
+ bestFor: '需要结论和推荐动作的问题',
308
+ estimate: 3,
309
+ translated: true,
310
+ },
311
+ })
312
+
313
+ export function templateCopy(id) {
314
+ return TEMPLATE_COPY[id] ?? {
315
+ title: null,
316
+ purpose: '按模板发起一次多子任务运行',
317
+ bestFor: '不确定时先看模板说明',
318
+ estimate: 3,
319
+ translated: false,
320
+ }
321
+ }
322
+
323
+ /** One sentence a person can act on, without reading the stack. */
324
+ export function humanizeErrorText(text) {
325
+ const explanation = explainFailure({ error: text }, null)
326
+ return explanation.title
327
+ }