dsh-workplan 2.1.1 → 2.1.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/CHANGELOG.md CHANGED
@@ -1,3 +1,52 @@
1
+ ## 2.1.3 — 2026-11-06
2
+
3
+ **修复规划器超时复发的真正根因:把单次规划器调用的墙钟上限从写死的常量改成可配置项。**
4
+
5
+ ### 问题
6
+
7
+ 2.1.1 把规划器超时常量从 120 秒提到 300 秒,只是推迟了超时,没解决
8
+ 「单次 LLM 调用被固定超时卡死」的结构性问题。复杂任务(长上下文 /
9
+ 多子任务 JSON)仍会在 5 分钟处稳定触发超时,导致自动任务分解反复降级。
10
+
11
+ ### 改了什么
12
+
13
+ 新增 `DSH_WORKPLAN_PLANNER_TIMEOUT_MS` 环境变量(毫秒,>0),
14
+ 未配置时回落到默认值 300000。复杂任务可按需放宽时限,无需重新编译发布。
15
+
16
+ ### 安装
17
+
18
+ ```bash
19
+ npm install dsh-workplan@2.1.3
20
+ ```
21
+
22
+ ## 2.1.2 — 2026-11-06
23
+
24
+ **修复自动任务拆分「稳定超时被误报成意外中断」的问题:把规划器的思考时间上限从 2 分钟放宽到 5 分钟,并让真正超时时报出明确原因。**
25
+
26
+ ### 一、问题是什么(通俗版)
27
+
28
+ 插件在接到一个复杂任务时,会先花一段时间自动把它「拆分」成几个子任务,再分派给各部门去执行。这一步是有时间上限的:
29
+
30
+ 1. 之前的上限只有 **2 分钟(120 秒)**。当任务描述特别长、要求特别多时,拆分还没做完,就被定时器强制打断了;
31
+ 2. 更糟的是,底层的大模型接口把「超时被打断」这件事,**误报成了「请求意外中断」**(`DeepSeek Messages request aborted`),看起来像网络偶发故障,根本看不出真正原因是「时间到了」。
32
+
33
+ 结果就是:复杂任务每次都会稳定失败,但日志却让人以为是「偶发中断」,排查方向被带偏。
34
+
35
+ ### 二、改了什么(只有这两处)
36
+
37
+ 1. 把拆分的时间上限从 **2 分钟(120 秒)放宽到 5 分钟(300 秒)**,给复杂任务留足拆分时间。
38
+ 2. 当确实是「超时」被打断时,不再被误报成「意外中断」,而是明确抛出「规划器超时:任务分解未在时限内完成」的清晰报错。
39
+
40
+ 改动只涉及 `lib/runtime.js` 与 `src/runtime.ts` 两个文件(+14/−2),没有改其它任何功能。
41
+
42
+ ### 三、安装
43
+
44
+ ```bash
45
+ npm install dsh-workplan@2.1.2
46
+ ```
47
+
48
+ (版本号 2.1.2 为 patch 升级,属 bug 修复级别。)
49
+
1
50
  ## 2.1.1 — 2026-11-06
2
51
 
3
52
  **修复 2.1.0 的三处「说到了但没做到」:格式退回通知在续跑时送不到部门人员、中文 README 的安装命令仍指旧版本、安全文档里有一句「当前 1.12.0」的错误陈述。**
package/README.en.md CHANGED
@@ -3,7 +3,7 @@
3
3
  > **Two selling points, one line: a full ISO/IEC 15408:2026 evidence pack you can verify with 5 commands, and a one-command install with zero runtime dependencies.**
4
4
 
5
5
  [![verify](https://github.com/abbaababa/dsh-workplan/actions/workflows/verify.yml/badge.svg)](https://github.com/abbaababa/dsh-workplan/actions/workflows/verify.yml)
6
- [![version](https://img.shields.io/badge/version-2.1.1-blue.svg)](https://github.com/abbaababa/dsh-workplan/releases/tag/v2.1.1)
6
+ [![version](https://img.shields.io/badge/version-2.1.3-blue.svg)](https://github.com/abbaababa/dsh-workplan/releases/tag/v2.1.3)
7
7
 
8
8
  Adds "plan first → dispatch real department subagents → watch progress in the sidebar" to **DeepSeek Harness (DSH)**. No app, no DSH source patch, no page replacement.
9
9
 
@@ -80,7 +80,7 @@ The full contract — roles, data shapes, state machine, recovery, and the three
80
80
  ## Install
81
81
 
82
82
  ```bash
83
- dsh plugin --profile web add dsh-workplan@2.1.1
83
+ dsh plugin --profile web add dsh-workplan@2.1.3
84
84
  ```
85
85
 
86
86
  Restart the DSH Web process (or reload the page) so the bundle is picked up.
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  > **两个卖点,一句话:ISO/IEC 15408:2026 全套安全证据,5 条命令自己验;安装一条命令、零第三方运行时依赖。**
4
4
 
5
5
  [![verify](https://github.com/abbaababa/dsh-workplan/actions/workflows/verify.yml/badge.svg)](https://github.com/abbaababa/dsh-workplan/actions/workflows/verify.yml)
6
- [![version](https://img.shields.io/badge/version-2.1.1-blue.svg)](https://github.com/abbaababa/dsh-workplan/releases/tag/v2.1.1)
6
+ [![version](https://img.shields.io/badge/version-2.1.3-blue.svg)](https://github.com/abbaababa/dsh-workplan/releases/tag/v2.1.3)
7
7
 
8
8
  给 **DeepSeek Harness(DSH)** 加一段「先拆计划 → 真派部门子 Agent 去做 → 左侧栏实时看进度」的能力。不装 App、不改 DSH 源码、不换页面。
9
9
 
@@ -69,7 +69,7 @@ grep -RInE "child_process|execSync|eval\(|writeFileSync" src || echo "0 命中
69
69
  ## 一键安装
70
70
 
71
71
  ```bash
72
- dsh plugin --profile web add dsh-workplan@2.1.1
72
+ dsh plugin --profile web add dsh-workplan@2.1.3
73
73
  ```
74
74
 
75
75
  装完**重启一次 DSH Web**(或重新载入当前页面)让插件生效。
package/README.zh.md CHANGED
@@ -3,7 +3,7 @@
3
3
  > **两个卖点,一句话:ISO/IEC 15408:2026 全套安全证据,5 条命令自己验;安装一条命令、零第三方运行时依赖。**
4
4
 
5
5
  [![verify](https://github.com/abbaababa/dsh-workplan/actions/workflows/verify.yml/badge.svg)](https://github.com/abbaababa/dsh-workplan/actions/workflows/verify.yml)
6
- [![version](https://img.shields.io/badge/version-2.1.1-blue.svg)](https://github.com/abbaababa/dsh-workplan/releases/tag/v2.1.1)
6
+ [![version](https://img.shields.io/badge/version-2.1.3-blue.svg)](https://github.com/abbaababa/dsh-workplan/releases/tag/v2.1.3)
7
7
 
8
8
  给 **DeepSeek Harness(DSH)** 加一段「先拆计划 → 真派部门子 Agent 去做 → 左侧栏实时看进度」的能力。不装 App、不改 DSH 源码、不换页面。
9
9
 
@@ -69,7 +69,7 @@ grep -RInE "child_process|execSync|eval\(|writeFileSync" src || echo "0 命中
69
69
  ## 一键安装
70
70
 
71
71
  ```bash
72
- dsh plugin --profile web add dsh-workplan@2.1.1
72
+ dsh plugin --profile web add dsh-workplan@2.1.3
73
73
  ```
74
74
 
75
75
  装完**重启一次 DSH Web**(或重新载入当前页面)让插件生效。
@@ -0,0 +1,104 @@
1
+ # Release record — dsh-workplan 2.1.1 (2026-11-06)
2
+
3
+ ## 1. 变更主题
4
+
5
+ 修复 2.1.0 的三处「说到了但没做到」:
6
+
7
+ 1. **格式退回通知在续跑时送不到部门人员**(功能缺陷,用户要求 2 的「通知」环节断链)。
8
+ 2. `README.zh.md:72` 的安装命令仍是 `dsh-workplan@1.12.3`(同文件徽章已是新版本,用户会照着装错)。
9
+ 3. `docs/cc/AGD-OPS-SECURE-OPERATION.md` 安装校验步骤写着「当前 1.12.0」,是唯一一处面向用户的过期「当前版本」陈述。
10
+
11
+ ## 2. 缺陷 1 的根因与修复(治本,不治标)
12
+
13
+ ### 根因(按执行顺序)
14
+
15
+ | # | 环节 | 2.1.0 的实际行为 |
16
+ |---|---|---|
17
+ | 1 | 子 Agent 交回不合规结果 | `adjudicateResult` 判 `blocked`,并把 `blockedKind:'comm-format'` + 逐条不合规项写进 `error`(这一步是对的) |
18
+ | 2 | 主 Agent 再次派发 | `dispatchPlan` 先调用 `resetBlockedStatuses`,把受阻行连同 `blockedKind` / `error` 一起清成待跑 |
19
+ | 3 | `executeSubtask` 想读「上次是不是格式退回」 | 信息已被第 2 步清掉,`lastFailure` 恒为 `null` |
20
+ | 4 | 结果 | 第 2 次激活的提示词与第 1 次逐字相同(实测均 4374 字符),子 Agent 不知道要改哪几条格式,只能把同样的错误再交一遍 → 退回只剩状态行一个记号 |
21
+
22
+ ### 修复(`src/runtime.ts`,两处)
23
+
24
+ - `dispatchPlan`:在 `resetBlockedStatuses` **之前**扫描 `blockedKind === 'comm-format'` 的行,把退回原因抄进本轮的 `record.commFormatRejections`。
25
+ - `executeSubtask`:行内 `blockedKind` 已被清掉时改读这份记录,构造 `{attempt:1, code:'COMM_FORMAT_REJECTED', message:退回原因}` 交给 `buildChildPrompt` 的 `previousFailure`;消费一次即删,避免后续无关重试重复带上。
26
+
27
+ ### 修复证据
28
+
29
+ - 端到端探针(真实 `createWorkplanRuntime` + 假子会话,2 轮):
30
+ - 第 1 轮:`status=blocked`、`blockedKind=comm-format`、`error` 点名 F4;
31
+ - 第 2 轮:`status=done`、`blockedKind=null`;
32
+ - 第 2 次激活提示词含「上一次尝试失败」段、`COMM_FORMAT_REJECTED`、逐条不合规项;长度 4374 → 4584。
33
+ - 新增 `tests/workplan-comm-format-e2e.test.ts`(2 条)把上述断言固化:不合规 → 退回不计完成、合规 → 通过、第 2 次激活必须带退回段与失败类型。
34
+
35
+ ## 3. 另两处修正的判据
36
+
37
+ - `README.zh.md:72`:`dsh-workplan@1.12.3` → `dsh-workplan@2.1.1`。漏检原因:`tests/version-sync.test.ts` 只校验 `README.md` 与 `README.en.md`,不校验中文 README——这是测试覆盖面缺口,本次未扩大该测试(避免超范围改动)。
38
+ - `docs/cc/AGD-OPS-SECURE-OPERATION.md`:删除「当前 1.12.0」的过期断言,改为「与 README 徽章一致的最新版本号」;文首补一条带日期的版本说明,声明正文其余 1.12.0 是 v1.12.0 评估快照,不改写历史。**未**批量替换 31 处 1.12.0:那些是带日期的历史证据,改写会伪造评估记录。
39
+
40
+ ## 4. 版本与提交
41
+
42
+ | 项目 | 值 |
43
+ |---|---|
44
+ | package.json version | 2.1.1 |
45
+ | meta.version(src/host.ts) | 2.1.1 |
46
+ | git commit | d3a3b32 |
47
+ | git tag | v2.1.1 |
48
+ | 远程 | `git@github.com:abbaababa/dsh-workplan.git`(main) |
49
+
50
+ 版本同步点:`package.json`、`package-lock.json` 两处、`src/host.ts`、`tests/fixtures/tool-surface.json`、README 三语(徽章 + 安装命令)、CHANGELOG 的 `## 2.1.1 — 2026-11-06`。
51
+
52
+ ## 5. 验证
53
+
54
+ - `npm run check`(tsc -p tsconfig.json --noEmit):退出码 0。
55
+ - `npm test`:tests 580 / pass 580 / fail 0(2.1.0 为 578;新增 e2e 文件 2 条)。
56
+ - `npm run build`:`lib/host.js` 内 `version: '2.1.1'`,`lib/runtime.js` 含本次修复。
57
+
58
+ ## 6. 发布渠道(均已核验)
59
+
60
+ | 渠道 | 状态 | 证据 |
61
+ |---|---|---|
62
+ | npm | 已发布 | registry 原始元数据 `dist-tags.latest = 2.1.1`,`versions` 列表含 `2.1.1`;`https://registry.npmjs.org/-/package/dsh-workplan/dist-tags` → `{"latest":"2.1.1"}` |
63
+ | GitHub Release | 已发布 | https://github.com/abbaababa/dsh-workplan/releases/tag/v2.1.1 |
64
+ | git tag | 已推送 | `git ls-remote --tags origin` → `refs/tags/v2.1.1`(tag 对象 72f5992,peel 到 d3a3b32) |
65
+ | Release 制品 | 已上传且校验一致 | `dsh-workplan-2.1.1.tgz`,GitHub 记录 `digest: sha256:9db23eed0c22a8f38b7a2aeef892f1d8277d1469605cf5518577e634f3071d03`,与本机 `npm pack` 复算一致 |
66
+ | npm tarball sha1 | 与本地 pack 一致 | `c9a8a627648477a28837583ca388a4f6f673fba4` |
67
+
68
+ 注:npm publish 返回 `202 Accepted`(异步处理),registry 约 4 分钟后才出现 2.1.1;以 registry 原始响应为准,`npm view` 的本地缓存可能更慢。
69
+
70
+ ## 7. 复验命令
71
+
72
+ ```bash
73
+ # 1) registry 最新版与版本列表
74
+ curl -s https://registry.npmjs.org/dsh-workplan | node -e "let d='';process.stdin.on('data',c=>d+=c).on('end',()=>{const j=JSON.parse(d);console.log(j['dist-tags'].latest, Object.keys(j.versions).includes('2.1.1'))})"
75
+
76
+ # 2) dist-tags
77
+ curl -s https://registry.npmjs.org/-/package/dsh-workplan/dist-tags
78
+
79
+ # 3) 远程 tag
80
+ git ls-remote --tags origin | grep v2.1.1
81
+
82
+ # 4) 制品摘要(GitHub 侧记录)
83
+ gh release view v2.1.1 --json assets | grep -o 'sha256:[0-9a-f]*'
84
+
85
+ # 5) 本地复现
86
+ cd /Users/open/Documents/Stocks/plugins/dsh-workplan
87
+ npm run check && npm test
88
+ ```
89
+
90
+ ## 8. 回滚方案
91
+
92
+ - 代码:`git revert d3a3b32` 并推送;撤销 tag:`git tag -d v2.1.1 && git push origin :refs/tags/v2.1.1`。
93
+ - npm:发布 72 小时内可 `npm unpublish dsh-workplan@2.1.1`;超时则 `npm deprecate dsh-workplan@2.1.1 "请升级到修复版本"` 并另发修复版。
94
+ - 用户侧:可回退到 `dsh-workplan@2.1.0`,但请注意 2.1.0 存在「退回通知送不到」的缺陷。
95
+
96
+ ## 9. 已知问题(如实记录,未解决)
97
+
98
+ 本次会话里 dsh-workplan 自己的自动任务分解(部门子 Agent 调度)持续不可靠:
99
+
100
+ - 计划 `wp-b7750256`(10 项):全部 blocked,错误 `cannot get required service "subagents" in inactive context` / `子 Agent 结束状态为 error`。
101
+ - 计划 `wp-80e484d9`(9 项):3 项 done、6 项 blocked(T4/T5 子 Agent 结束状态为 error,其余为上游级联),并留下一条跨部门需求 H1(docs/cc 版本锚点同步)。
102
+ - 计划 `wp-295e0e44`(5 项):本轮执行中。
103
+
104
+ 这些子 Agent 的产物中有真实可用的部分(T1 变更盘点、T2 测试复核、T3 版本引用清单、T4 的 e2e 测试文件),主 Agent 已逐项核对后并入 2.1.1;但调度链路本身的失败原因(`subagents` 服务在 inactive context 取不到、子 Agent 频繁以 error 结束)属于运行环境/宿主层问题,本次未修复,需单独排查。**不得**把上述计划读作「已完成」。
package/lib/host.js CHANGED
@@ -1229,6 +1229,7 @@ export function apply(ctx, config = {}) {
1229
1229
  buildHash: LOADED_BUILD.buildHash,
1230
1230
  },
1231
1231
  cwd: typeof config.cwd === 'string' ? config.cwd : undefined,
1232
+ plannerTimeoutMs: numericSetting(config.plannerTimeoutMs, 'DSH_WORKPLAN_PLANNER_TIMEOUT_MS'),
1232
1233
  childTimeoutMs: numericSetting(config.childTimeoutMs, 'DSH_WORKPLAN_CHILD_TIMEOUT_MS'),
1233
1234
  idleTimeoutMs: numericSetting(config.idleTimeoutMs, 'DSH_WORKPLAN_IDLE_TIMEOUT_MS'),
1234
1235
  totalTimeoutMs: numericSetting(config.totalTimeoutMs, 'DSH_WORKPLAN_TOTAL_TIMEOUT_MS'),
@@ -1363,7 +1364,7 @@ export function apply(ctx, config = {}) {
1363
1364
  }
1364
1365
  export const meta = {
1365
1366
  name,
1366
- version: '2.1.1',
1367
+ version: '2.1.3',
1367
1368
  promptOrder: PROMPT_ORDER,
1368
1369
  routes: ['/dsh-workplan/plans', '/dsh-workplan/vendor/chart.umd.js'],
1369
1370
  };
package/lib/runtime.js CHANGED
@@ -94,7 +94,16 @@ function readinessOf(record, snapshot) {
94
94
  expectedAcceptance: record?.plan ? expectedAcceptanceOf(record.plan) : undefined,
95
95
  });
96
96
  }
97
- export const PLANNER_TIMEOUT_MS = 120000;
97
+ export const PLANNER_TIMEOUT_MS = 300000;
98
+ /**
99
+ * Wall-clock ceiling for ONE planner attempt (a single LLM stream).
100
+ *
101
+ * 2.1.1 把固定 120s 提到 300s,只是推迟了超时,没解决「单次调用被固定超时
102
+ * 卡死」的结构性问题。2.1.3 起改为可配置:DSH_WORKPLAN_PLANNER_TIMEOUT_MS
103
+ * (毫秒,>0),未配置时回落到这里的默认值。这样复杂任务可以按需放宽,
104
+ * 而不必改代码重新发布。
105
+ */
106
+ export const PLANNER_IDLE_TIMEOUT_MS = 90000;
98
107
  /**
99
108
  * Absolute ceiling for one child execution.
100
109
  *
@@ -367,6 +376,7 @@ function contextGuardStrict() {
367
376
  }
368
377
  async function runPlanner(ctx, options) {
369
378
  const { taskText, cwd, sessionId, modelSelection, signal, conversationContext = '', budget = {}, sourceMessageIds = [] } = options;
379
+ const plannerTimeoutMs = Number(options.plannerTimeoutMs ?? PLANNER_TIMEOUT_MS);
370
380
  let lastErrors = [];
371
381
  for (let attempt = 1; attempt <= 2; attempt += 1) {
372
382
  if (signal.aborted)
@@ -376,7 +386,7 @@ async function runPlanner(ctx, options) {
376
386
  signal.addEventListener('abort', onAbort, { once: true });
377
387
  const timeout = setTimeout(() => {
378
388
  controller.abort(new PlanError('规划器超时', 'PLANNER_TIMEOUT'));
379
- }, PLANNER_TIMEOUT_MS);
389
+ }, plannerTimeoutMs);
380
390
  try {
381
391
  let prompt = buildPlannerPrompt(taskText, cwd, conversationContext, budget);
382
392
  if (lastErrors.length > 0) {
@@ -422,6 +432,12 @@ async function runPlanner(ctx, options) {
422
432
  lastErrors = validated.errors ?? [];
423
433
  }
424
434
  catch (error) {
435
+ // 规划器自身的墙钟超时:LLM 层会把 abort 掩码成泛化的
436
+ // "DeepSeek Messages request aborted",丢失真实原因。这里优先识别
437
+ // PLANNER_TIMEOUT,抛出明确错误,避免误报成“偶发中断”。
438
+ if (controller.signal.aborted && controller.signal.reason?.code === 'PLANNER_TIMEOUT') {
439
+ throw new PlanError('规划器超时:任务分解未在时限内完成,请缩短任务文本或提高 PLANNER_TIMEOUT_MS', 'PLANNER_TIMEOUT');
440
+ }
425
441
  if (signal.aborted || (controller.signal.aborted && controller.signal.reason?.code === 'ABORTED')) {
426
442
  throw abortError();
427
443
  }
@@ -6271,6 +6287,7 @@ async function maybePlan(ctx, state, payload, downstream, options) {
6271
6287
  sessionId: session.id,
6272
6288
  modelSelection,
6273
6289
  signal: payload.signal,
6290
+ plannerTimeoutMs: Number(options?.limits?.plannerTimeoutMs ?? options?.plannerTimeoutMs ?? PLANNER_TIMEOUT_MS),
6274
6291
  conversationContext,
6275
6292
  sourceMessageIds: human.map((message) => message.id).filter((id) => typeof id === 'string'),
6276
6293
  /*
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-workplan",
3
- "version": "2.1.1",
3
+ "version": "2.1.3",
4
4
  "description": "Automatic task decomposition, real department subagents, and a responsive workplan dashboard for DeepSeek Harness.",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/host.ts CHANGED
@@ -169,6 +169,8 @@ function asObject(value: any) {
169
169
 
170
170
  export type WorkplanConfig = {
171
171
  cwd?: string
172
+ /** [2.1.3] 单次规划器调用上限(毫秒),亦可用 DSH_WORKPLAN_PLANNER_TIMEOUT_MS。 */
173
+ plannerTimeoutMs?: number
172
174
  childTimeoutMs?: number
173
175
  idleTimeoutMs?: number
174
176
  totalTimeoutMs?: number
@@ -1341,6 +1343,7 @@ export function apply(ctx: any, config: WorkplanConfig = {}) {
1341
1343
  buildHash: LOADED_BUILD.buildHash,
1342
1344
  },
1343
1345
  cwd: typeof config.cwd === 'string' ? config.cwd : undefined,
1346
+ plannerTimeoutMs: numericSetting(config.plannerTimeoutMs, 'DSH_WORKPLAN_PLANNER_TIMEOUT_MS'),
1344
1347
  childTimeoutMs: numericSetting(config.childTimeoutMs, 'DSH_WORKPLAN_CHILD_TIMEOUT_MS'),
1345
1348
  idleTimeoutMs: numericSetting(config.idleTimeoutMs, 'DSH_WORKPLAN_IDLE_TIMEOUT_MS'),
1346
1349
  totalTimeoutMs: numericSetting(config.totalTimeoutMs, 'DSH_WORKPLAN_TOTAL_TIMEOUT_MS'),
@@ -1490,7 +1493,7 @@ export function apply(ctx: any, config: WorkplanConfig = {}) {
1490
1493
 
1491
1494
  export const meta = {
1492
1495
  name,
1493
- version: '2.1.1',
1496
+ version: '2.1.3',
1494
1497
  promptOrder: PROMPT_ORDER,
1495
1498
  routes: ['/dsh-workplan/plans', '/dsh-workplan/vendor/chart.umd.js'],
1496
1499
  }
package/src/runtime.ts CHANGED
@@ -172,7 +172,16 @@ function readinessOf(record: any, snapshot?: any) {
172
172
  })
173
173
  }
174
174
 
175
- export const PLANNER_TIMEOUT_MS = 120000
175
+ export const PLANNER_TIMEOUT_MS = 300000
176
+ /**
177
+ * Wall-clock ceiling for ONE planner attempt (a single LLM stream).
178
+ *
179
+ * 2.1.1 把固定 120s 提到 300s,只是推迟了超时,没解决「单次调用被固定超时
180
+ * 卡死」的结构性问题。2.1.3 起改为可配置:DSH_WORKPLAN_PLANNER_TIMEOUT_MS
181
+ * (毫秒,>0),未配置时回落到这里的默认值。这样复杂任务可以按需放宽,
182
+ * 而不必改代码重新发布。
183
+ */
184
+ export const PLANNER_IDLE_TIMEOUT_MS = 90000
176
185
  /**
177
186
  * Absolute ceiling for one child execution.
178
187
  *
@@ -433,6 +442,7 @@ function contextGuardStrict() {
433
442
 
434
443
  async function runPlanner(ctx: any, options: any) {
435
444
  const { taskText, cwd, sessionId, modelSelection, signal, conversationContext = '', budget = {}, sourceMessageIds = [] } = options
445
+ const plannerTimeoutMs = Number(options.plannerTimeoutMs ?? PLANNER_TIMEOUT_MS)
436
446
  let lastErrors: string[] = []
437
447
  for (let attempt = 1; attempt <= 2; attempt += 1) {
438
448
  if (signal.aborted) throw abortError()
@@ -441,7 +451,7 @@ async function runPlanner(ctx: any, options: any) {
441
451
  signal.addEventListener('abort', onAbort, { once: true })
442
452
  const timeout = setTimeout(() => {
443
453
  controller.abort(new PlanError('规划器超时', 'PLANNER_TIMEOUT'))
444
- }, PLANNER_TIMEOUT_MS)
454
+ }, plannerTimeoutMs)
445
455
  try {
446
456
  let prompt = buildPlannerPrompt(taskText, cwd, conversationContext, budget)
447
457
  if (lastErrors.length > 0) {
@@ -486,6 +496,12 @@ async function runPlanner(ctx: any, options: any) {
486
496
  }
487
497
  lastErrors = validated.errors ?? []
488
498
  } catch (error) {
499
+ // 规划器自身的墙钟超时:LLM 层会把 abort 掩码成泛化的
500
+ // "DeepSeek Messages request aborted",丢失真实原因。这里优先识别
501
+ // PLANNER_TIMEOUT,抛出明确错误,避免误报成“偶发中断”。
502
+ if (controller.signal.aborted && (controller.signal.reason as any)?.code === 'PLANNER_TIMEOUT') {
503
+ throw new PlanError('规划器超时:任务分解未在时限内完成,请缩短任务文本或提高 PLANNER_TIMEOUT_MS', 'PLANNER_TIMEOUT')
504
+ }
489
505
  if (signal.aborted || (controller.signal.aborted && (controller.signal.reason as any)?.code === 'ABORTED')) {
490
506
  throw abortError()
491
507
  }
@@ -2929,6 +2945,12 @@ function respondJson(res: any, status: any, payload: any) {
2929
2945
 
2930
2946
  export type WorkplanRuntimeOptions = {
2931
2947
  cwd?: string
2948
+ /**
2949
+ * [2.1.3] 单次规划器调用的墙钟上限(毫秒)。来自
2950
+ * `DSH_WORKPLAN_PLANNER_TIMEOUT_MS` 或显式配置;缺省回落到
2951
+ * `PLANNER_TIMEOUT_MS`。复杂任务(长上下文 / 多子任务 JSON)可按需放宽。
2952
+ */
2953
+ plannerTimeoutMs?: number
2932
2954
  /** Absolute ceiling per child execution, clamped by `normaliseChildTimeout`. */
2933
2955
  childTimeoutMs?: number
2934
2956
  /** No-progress window per child execution, clamped by `normaliseIdleTimeout`. */
@@ -6301,6 +6323,7 @@ async function maybePlan(ctx: any, state: any, payload: any, downstream: any, op
6301
6323
  sessionId: session.id,
6302
6324
  modelSelection,
6303
6325
  signal: payload.signal,
6326
+ plannerTimeoutMs: Number(options?.limits?.plannerTimeoutMs ?? options?.plannerTimeoutMs ?? PLANNER_TIMEOUT_MS),
6304
6327
  conversationContext,
6305
6328
  sourceMessageIds: human.map((message: any) => message.id).filter((id: any) => typeof id === 'string'),
6306
6329
  /*