dsh-workplan 2.1.3 → 2.2.6

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.
Files changed (38) hide show
  1. package/CHANGELOG.md +380 -1
  2. package/README.en.md +5 -2
  3. package/README.md +5 -2
  4. package/README.zh.md +5 -2
  5. package/client.js +143 -3
  6. package/docs/dsh-workplan_T4_runtime.patch +508 -0
  7. package/docs/release-records/_release_notes_2.1.2_20261106.md +44 -0
  8. package/docs/release-records/_t2_version_determination_20261106.md +39 -0
  9. package/docs/release-records/_t5_external_reverify_20261106.md +18 -0
  10. package/docs/release-records/release-dryrun-report-20261106.md +74 -0
  11. package/docs/release-records/release-notes-2.2.6-T3.md +128 -0
  12. package/docs/release-records/release-record-2.1.3-20261106.md +82 -0
  13. package/docs/release-records/release-steps-20261106.md +129 -0
  14. package/docs/release-records/version-freeze-20261109-T2.md +37 -0
  15. package/lib/client.js +143 -3
  16. package/lib/comm-format.js +17 -0
  17. package/lib/departments.js +19 -0
  18. package/lib/host.js +95 -17
  19. package/lib/notice-channel.js +290 -0
  20. package/lib/plan.js +541 -32
  21. package/lib/replan.js +4 -0
  22. package/lib/runtime.js +1481 -85
  23. package/lib/supersede.js +2 -2
  24. package/lib/understanding.js +8 -2
  25. package/lib/watchdog.js +52 -1
  26. package/package.json +3 -2
  27. package/scripts/repair-malformed-user-messages.mjs +312 -0
  28. package/src/client.ts +150 -2
  29. package/src/comm-format.ts +17 -0
  30. package/src/departments.ts +22 -0
  31. package/src/host.ts +90 -12
  32. package/src/notice-channel.ts +328 -0
  33. package/src/plan.ts +575 -24
  34. package/src/replan.ts +4 -0
  35. package/src/runtime.ts +1500 -86
  36. package/src/supersede.ts +2 -1
  37. package/src/understanding.ts +10 -2
  38. package/src/watchdog.ts +80 -1
package/src/client.ts CHANGED
@@ -71,6 +71,7 @@ window.__ModuleLoader__.load({
71
71
  "phase": {
72
72
  "pending": "还没开始",
73
73
  "planning": "正在安排",
74
+ "clarify": "等信息中",
74
75
  "executing": "正在做",
75
76
  "integrating": "正在收尾",
76
77
  "done": "已完成",
@@ -215,7 +216,27 @@ window.__ModuleLoader__.load({
215
216
  "vizStageTitle": "分步进度",
216
217
  "vizOverall": "总体进度",
217
218
  "allPlansHint": "上面是当前各会话最新计划的合计;历史计划不在此汇总,下面每张卡片只统计本计划。",
218
- "openHint": "打开左侧「任务进度」看完整安排。"
219
+ "openHint": "打开左侧「任务进度」看完整安排。",
220
+ "timeNegotiation": "时长协商",
221
+ "reasoningEffort": "推理等级",
222
+ "estimateMinutes": "预估时长",
223
+ "negotiatedCeiling": "协商上限",
224
+ "derived": "派生",
225
+ "negotiatedDeadline": "协商截止",
226
+ "startedAtLabel": "开始时间",
227
+ "remaining": "剩余",
228
+ "minutes": "分钟",
229
+ "seconds": "秒",
230
+ "timeExtensions": "延期记录",
231
+ "startNotice": "开工预告",
232
+ "timeWarning": "到点预警",
233
+ "pendingAdjudication": "待裁决",
234
+ "pendingAdjudicationHint": "到点后按安全兜底结算:等待主 Agent 决定延期 / 重试 / 接受。",
235
+ "noticeChannel": "预告通道",
236
+ "noticeChannelObserved": "已观测到送达",
237
+ "noticeChannelAwaiting": "等待观测",
238
+ "noticeChannelNotObserved": "未观测到送达",
239
+ "reason": "原因",
219
240
  },
220
241
  "en": {
221
242
  "groupLive": "In progress",
@@ -268,6 +289,7 @@ window.__ModuleLoader__.load({
268
289
  "phase": {
269
290
  "pending": "Not started",
270
291
  "planning": "Planning",
292
+ "clarify": "Waiting for info",
271
293
  "executing": "In progress",
272
294
  "integrating": "Wrapping up",
273
295
  "done": "Done",
@@ -411,7 +433,27 @@ window.__ModuleLoader__.load({
411
433
  "vizStageTitle": "Step progress",
412
434
  "vizOverall": "Overall progress",
413
435
  "allPlansHint": "These totals cover the latest plan in each live session; older plans are not included. Each card below counts only its own plan.",
414
- "openHint": "Open “Task progress” on the left for the full plan."
436
+ "openHint": "Open “Task progress” on the left for the full plan.",
437
+ "timeNegotiation": "Time negotiation",
438
+ "reasoningEffort": "Reasoning effort",
439
+ "estimateMinutes": "Estimate",
440
+ "negotiatedCeiling": "Negotiated ceiling",
441
+ "derived": "derived",
442
+ "negotiatedDeadline": "Negotiated deadline",
443
+ "startedAtLabel": "Started at",
444
+ "remaining": "remaining",
445
+ "minutes": "min",
446
+ "seconds": "s",
447
+ "timeExtensions": "Extensions",
448
+ "startNotice": "Start notice",
449
+ "timeWarning": "Approaching deadline",
450
+ "pendingAdjudication": "Awaiting decision",
451
+ "pendingAdjudicationHint": "Safety fallback at the deadline: the main agent will decide whether to extend, retry, or accept.",
452
+ "noticeChannel": "Notice channel",
453
+ "noticeChannelObserved": "Delivery observed",
454
+ "noticeChannelAwaiting": "Awaiting observation",
455
+ "noticeChannelNotObserved": "Delivery not observed",
456
+ "reason": "reason",
415
457
  }
416
458
  }
417
459
 
@@ -986,6 +1028,12 @@ window.__ModuleLoader__.load({
986
1028
  .dsh-wp-subtask-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; color: var(--dsw-alias-label-secondary); font-size: 12px; }
987
1029
  .dsh-wp-subtask-body { margin-top: 6px; }
988
1030
  .dsh-wp-subtask-body > div { margin-top: 4px; }
1031
+ /* [2.2.0][T3/O-2a][O-3b][O-4c] 时长协商信息块:预估 / 协商上限 / 延期 / 开工预告 / 预警 / 通道。
1032
+ 只做展示,全部由服务端状态行与计划定义提供;字段缺失时整块不渲染(降级不报错)。 */
1033
+ .dsh-wp-time { margin-top: 8px; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--dsw-alias-line-1, rgba(148,163,184,.22)); background: rgba(148,163,184,.06); }
1034
+ .dsh-wp-time-title { font-size: 12px; font-weight: 650; color: var(--dsw-alias-label-secondary, #475569); margin-bottom: 4px; }
1035
+ .dsh-wp-time-row { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--dsw-alias-label-primary, #0f172a); font-variant-numeric: tabular-nums; }
1036
+ .dsh-wp-time-note { margin: 4px 0 0; font-size: 12px; color: var(--dsw-alias-label-secondary, #475569); overflow-wrap: anywhere; }
989
1037
  .dsh-wp-subtask-body p { margin-top: 2px; overflow-wrap: anywhere; }
990
1038
  .dsh-wp-error-text { color: var(--dsw-alias-state-error-primary); overflow-wrap: anywhere; }
991
1039
  .dsh-wp-muted { color: var(--dsw-alias-label-secondary); }
@@ -1117,6 +1165,12 @@ window.__ModuleLoader__.load({
1117
1165
  return Number.isFinite(number) ? Math.max(0, Math.min(100, Math.round(number))) : 0
1118
1166
  }
1119
1167
 
1168
+ /** 只接受有限正数;0/NaN/负数一律视为「没有这个字段」,用于展示层降级。 */
1169
+ function positiveNumber(value: any) {
1170
+ const number = Number(value)
1171
+ return Number.isFinite(number) && number > 0 ? number : null
1172
+ }
1173
+
1120
1174
  function formatTime(value: any) {
1121
1175
  if (!value) return ''
1122
1176
  const date = new Date(value)
@@ -1540,6 +1594,95 @@ window.__ModuleLoader__.load({
1540
1594
  )
1541
1595
  }
1542
1596
 
1597
+ /*
1598
+ * [2.2.0][T3/O-2a][O-3b][O-4c] 看板:时长协商信息(T1 台账 A2 的可见入口)。
1599
+ *
1600
+ * 只展示服务端已经下发的计划字段与状态行字段:
1601
+ * - 计划定义:estimateMinutes(预估)、timeoutMs(协商上限)、reasoningEffort(推理等级);
1602
+ * - 状态行:startedAt/deadlineAt(协商截止)、timeJournal(延期/预告历史)、
1603
+ * timeNotice(开工预告)、timeWarning(到点预警)、noticeChannel(子→主通道是否送达)、
1604
+ * pendingAdjudication(到点后的待裁决标记)。
1605
+ *
1606
+ * 客户端不推导状态机、不补造字段:任何字段缺失就少显示一行;全部缺失整块不渲染,
1607
+ * 绝不出现 undefined / [object Object]。
1608
+ */
1609
+ function TimeNegotiation({ item, subtask, t }: any) {
1610
+ const estimate = positiveNumber(subtask?.estimateMinutes)
1611
+ const deadlineAt = positiveNumber(item?.deadlineAt)
1612
+ const startedAt = positiveNumber(item?.startedAt)
1613
+ const journal = Array.isArray(item?.timeJournal) ? item.timeJournal : []
1614
+ const extensions = journal
1615
+ .filter((entry: any) => entry?.action === 'extend' && positiveNumber(entry?.extendMs))
1616
+ .slice(-3)
1617
+ /*
1618
+ * [2.2.3][N2] D2「协商上限」结构性不可达:计划里没有 timeoutMs 时,
1619
+ * 用 deadlineAt - startedAt - 已延期 派生一个只读上限,明确标注“派生”,
1620
+ * 不写回计划、不把派生值冒充用户授权值。
1621
+ */
1622
+ const extensionTotal = extensions.reduce(
1623
+ (sum: number, entry: any) => sum + Number(positiveNumber(entry?.extendMs) ?? 0), 0)
1624
+ const declaredCeiling = positiveNumber(subtask?.timeoutMs)
1625
+ const derivedCeiling = !declaredCeiling && startedAt && deadlineAt
1626
+ ? Math.max(0, deadlineAt - startedAt - extensionTotal)
1627
+ : null
1628
+ const ceiling = declaredCeiling ?? derivedCeiling
1629
+ const ceilingLabel = declaredCeiling ? t('negotiatedCeiling') : `${t('negotiatedCeiling')}(${t('derived')})`
1630
+ const notice = item?.timeNotice && typeof item.timeNotice === 'object' ? item.timeNotice : null
1631
+ const warning = item?.timeWarning && typeof item.timeWarning === 'object' ? item.timeWarning : null
1632
+ const channel = item?.noticeChannel && typeof item.noticeChannel === 'object' ? item.noticeChannel : null
1633
+ const pending = item?.pendingAdjudication === true
1634
+ if (!estimate && !ceiling && !deadlineAt && !notice && !warning && !channel && !pending && extensions.length === 0) {
1635
+ return null
1636
+ }
1637
+ const remainingMs = deadlineAt ? Math.max(0, deadlineAt - Date.now()) : null
1638
+ const facts: string[] = []
1639
+ if (estimate) facts.push(`${t('estimateMinutes')}:${estimate} ${t('minutes')}`)
1640
+ if (ceiling) facts.push(`${ceilingLabel}:${Math.round(ceiling / 60000)} ${t('minutes')}`)
1641
+ if (deadlineAt) {
1642
+ const left = remainingMs && remainingMs > 0
1643
+ ? `(${t('remaining')} ${Math.max(1, Math.round(remainingMs / 60000))} ${t('minutes')})`
1644
+ : ''
1645
+ facts.push(`${t('negotiatedDeadline')}:${formatTime(deadlineAt)}${left}`)
1646
+ }
1647
+ const notes: any[] = []
1648
+ if (notice) {
1649
+ const declared = positiveNumber(notice.declaredMinutes)
1650
+ const reason = typeof notice.reason === 'string' && notice.reason
1651
+ ? `(${t('reason')}:${notice.reason.slice(0, 80)})`
1652
+ : ''
1653
+ notes.push(declared
1654
+ ? `${t('startNotice')}:${declared} ${t('minutes')}${reason}`
1655
+ : `${t('startNotice')}${reason}`)
1656
+ }
1657
+ if (extensions.length > 0) {
1658
+ notes.push(`${t('timeExtensions')}:${extensions.map((entry: any) =>
1659
+ `+${Math.round(Number(entry.extendMs) / 60000)} ${t('minutes')}`).join(';')}`)
1660
+ }
1661
+ if (warning) {
1662
+ const remaining = positiveNumber(warning.remainingMs)
1663
+ notes.push(`${t('timeWarning')}:${remaining
1664
+ ? `${t('remaining')} ${Math.round(remaining / 1000)} ${t('seconds')}`
1665
+ : t('pendingAdjudication')}`)
1666
+ }
1667
+ if (channel) {
1668
+ const stateText = channel.state === 'observed' ? t('noticeChannelObserved')
1669
+ : channel.state === 'awaiting' ? t('noticeChannelAwaiting') : t('noticeChannelNotObserved')
1670
+ const reason = typeof channel.reason === 'string' && channel.reason
1671
+ ? `(${t('reason')}:${channel.reason})`
1672
+ : ''
1673
+ notes.push(`${t('noticeChannel')}:${stateText}${reason}`)
1674
+ }
1675
+ if (pending) notes.push(`${t('pendingAdjudication')}:${t('pendingAdjudicationHint')}`)
1676
+ return h('div', { className: 'dsh-wp-time' },
1677
+ h('div', { className: 'dsh-wp-time-title' }, t('timeNegotiation')),
1678
+ facts.length > 0
1679
+ ? h('div', { className: 'dsh-wp-time-row' },
1680
+ facts.map((fact, factIndex) => h('span', { key: String(factIndex) }, fact)))
1681
+ : null,
1682
+ notes.map((note, noteIndex) => h('p', { key: String(noteIndex), className: 'dsh-wp-time-note' }, note)),
1683
+ )
1684
+ }
1685
+
1543
1686
  function SubtaskRow({ item, subtask, index, t }: any) {
1544
1687
  const status = item?.status ?? 'pending'
1545
1688
  /*
@@ -1590,6 +1733,9 @@ window.__ModuleLoader__.load({
1590
1733
  const instructionOverdue = item?.instructionOverdue === true
1591
1734
  const tone = closure === 'replanned' ? 'idle' : toneOfStatus(status)
1592
1735
  const pct = clampPct(item?.progress ?? 0)
1736
+ const effort = typeof subtask?.reasoningEffort === 'string' && ['low', 'high', 'max'].includes(subtask.reasoningEffort)
1737
+ ? subtask.reasoningEffort
1738
+ : null
1593
1739
  return h('div', { className: `dsh-wp-subtask dsh-wp-tone-${tone}` },
1594
1740
  h('div', { className: 'dsh-wp-subtask-head' },
1595
1741
  h('div', { className: 'dsh-wp-subtask-title' }, `${workLabel(t, index)}:${subtask.title}`),
@@ -1599,6 +1745,7 @@ window.__ModuleLoader__.load({
1599
1745
  ),
1600
1746
  h('div', { className: 'dsh-wp-subtask-meta' },
1601
1747
  h('span', null, `${t('who')}:${deptName(t, subtask.department)} · ${subtask.role}`),
1748
+ effort ? h(Pill, { tone: 'idle' }, `${t('reasoningEffort')}:${effort}`) : null,
1602
1749
  ),
1603
1750
  h('div', { className: 'dsh-wp-subtask-body' },
1604
1751
  h('p', null, h('strong', null, `${t('what')}:`), subtask.objective),
@@ -1607,6 +1754,7 @@ window.__ModuleLoader__.load({
1607
1754
  subtask.outputs?.length ? h('div', null, h('strong', null, `${t('willDeliver')}:`), h(Bullets, { items: subtask.outputs })) : null,
1608
1755
  subtask.dependsOn?.length ? h('p', { className: 'dsh-wp-muted' }, `${t('waitFor')}:先等前面的工作做完,才能开始这一步。`) : null,
1609
1756
  ),
1757
+ h(TimeNegotiation, { item, subtask, t }),
1610
1758
  status === 'in_progress' ? h(Progress, { value: pct, tone }) : null,
1611
1759
  status === 'in_progress' ? h('div', { className: 'dsh-wp-progress-meta' }, h('span', null, `${t('progressLabel')} ${pct}%`)) : null,
1612
1760
  /*
@@ -76,6 +76,23 @@ export const COMM_FORMAT_SPEC = Object.freeze({
76
76
  description: '不得编造、虚构或伪造任何证据、文件路径、命令输出或验收结果;无法确认的项目必须写 unverified',
77
77
  rationale: '虚假证据一旦通过交付门禁,用户拿到的就是不可信的成品' }),
78
78
  ]),
79
+ /*
80
+ * [2.2.0][T3/O-2c] 结果块可选字段(方案 §2.4:「模板增加 timeSpentMinutes、
81
+ * finalEstimateMinutes 字段」;方案 §2.5:「时间字段纯 advisory:不参与可
82
+ * 交付判定,不加拒绝码」)。
83
+ *
84
+ * 纯增量:不属于 F1-F9 门禁条目(requirements 冻结不动、版本号不升),
85
+ * 缺失或不合法一律不判不合规——仅供用时回填与协商审计,adjudicateResult
86
+ * 以 readAdvisoryMinutes 透传。
87
+ */
88
+ optionalFields: Object.freeze([
89
+ Object.freeze({ name: 'timeSpentMinutes', type: 'integer', unit: '分钟', required: false,
90
+ description: '实际耗时回填(完成即回报时如实填写;未知可省略)',
91
+ semantics: 'advisory:不参与可交付判定,缺失/非法不判不合规' }),
92
+ Object.freeze({ name: 'finalEstimateMinutes', type: 'integer', unit: '分钟', required: false,
93
+ description: '最终预估回填(与开工前预告不一致时以此为准,用于协商审计)',
94
+ semantics: 'advisory:不参与可交付判定,缺失/非法不判不合规' }),
95
+ ]),
79
96
  })
80
97
 
81
98
  /**
@@ -26,6 +26,28 @@
26
26
  * task growing a penetration-testing subtask).
27
27
  */
28
28
 
29
+ /**
30
+ * [2.1.5] Expert-persona standard: personnel who receive assigned work are top
31
+ * global experts in their field, not ordinary department staff.
32
+ *
33
+ * Single source of truth for the persona, consumed by the planner prompt (how
34
+ * the planner must staff and grade a subtask) and by the child-agent prompt
35
+ * (how the executing agent must hold itself). Keeping it here means both
36
+ * prompts cannot drift apart — the same rule the 1.12.0 catalogue applies to
37
+ * responsibilities.
38
+ */
39
+ export const DEPARTMENT_EXPERT_STANDARD = Object.freeze({
40
+ /** Shown to the planner: who receives each assignment and how to grade it. */
41
+ planner:
42
+ '每个部门的执行者都是该部门内来自全球相关领域的顶尖专家(不是普通部门人员):'
43
+ + '分配时按专家定位填写 role,验收时按专家水准要求根因、证据与可复核性。',
44
+ /** Shown to the executing child agent: the persona it must act as. */
45
+ child:
46
+ '你代表该领域来自全球的顶尖专家水准(不是普通部门人员):'
47
+ + '先抓根因与全局再落地,结论必须有可复核证据,方案要经得起同行评审,'
48
+ + '不留浅层补丁、不遗留问题。',
49
+ })
50
+
29
51
  export interface DepartmentCapability {
30
52
  id: string
31
53
  zh: string
package/src/host.ts CHANGED
@@ -111,7 +111,13 @@ const PROMPT_SECTION = [
111
111
  */
112
112
  '5. 「完成」只有一个判据:计划里全部子任务都是 done,**且** deliveryReady=true(每个 done 项 verification="structured"、acceptance 非空且逐项 result="pass"、无缺失产物)。用户取消 ≠ 完成:取消只停止执行,未完成项仍然是未完成。`dsh_workplan_dispatch` 返回 ok:true / complete:true 只表示调用成功或状态全 done,必须再看 deliveryReady 与 完成 X/Y;只要 deliveryReady=false 或还有 pending/blocked,就禁止 present 交付物、禁止写“已完成/最终版/已交付”、禁止给收尾性最终答复,必须先再次调用 dsh_workplan_dispatch 续跑剩余项。',
113
113
  '6. 如果续跑被拒绝、受阻项无法恢复、证据补不齐、计划已取消但未完成,或用户要求先看中间结果:答复开头必须写「未完成:剩余 N 项(列出 ID)与原因」,正文只能按中间结果表述,不得包装成成品。取消不会给你交付许可。',
114
- '7. 子任务有硬执行上限(默认 15 分钟/步)与整轮预算(默认 20 分钟):子 Agent 接近上限时应先把已完成内容落盘并在结论里列出路径。任何「达到执行上限」「本轮预算用尽」都不等于「什么都没做」:状态里的 error 会列出「声明产物已在盘上」,必须先用文件核对;若产物已覆盖验收标准,用 dsh_workplan_update 复核改判,只补缺失部分再续跑,禁止无视盘上产物把整步重跑。',
114
+ /*
115
+ * [2.2.0][T5/O-5a] E1:超时是安全兜底(防止任务无限运行),不是交付期限。
116
+ * 旧句把「每步 15 分钟」的规模参考写成硬性上限,等于对外承诺固定完成时间;
117
+ * 改为「协商上限+安全兜底」,并给出 extendMs 协商入口。安全概念与事故溯源
118
+ * (上方 1.8.7/1.8.13 注释)全部保留,不删。
119
+ */
120
+ '7. 子任务的时间是「协商上限」+「安全兜底」,不是固定交付期限:规模参考 15 分钟量级(仅供参考、非承诺,实际时长由执行专家开工预告协商决定),整轮预算(默认 20 分钟)同样只是安全兜底,不是交付期限。子 Agent 接近上限时应先把已完成内容落盘并在结论里列出路径。任何「达到协商上限」「本轮预算用尽」都不等于「什么都没做」:状态里的 error 会列出「声明产物已在盘上」,必须先用文件核对;若产物已覆盖验收标准,用 dsh_workplan_update 复核改判,只补缺失部分再续跑,禁止无视盘上产物把整步重跑。确认需要更多时间时,主 Agent 可用 dsh_workplan_update 的 extendMs 协商放宽(放宽永远有界:累计超过初始协商上限的一倍即拒绝,转新轮续跑或转 escalate 请主 Agent/用户裁决)。',
115
121
  '8. 出现「待指示」项(closure=escalated,左侧栏显示「待指示」并附问题摘录)时,必须在当轮处理:用 dsh_workplan_instruct 下发决定(投递到子会话并把该行恢复为执行中),或确认放弃后用 dsh_workplan_update 置 blocked。不要沉默略过,也不要把待指示当成普通失败——它是一条还没被回答的请示,会一直占着交付门禁。',
116
122
  '9. 出现「已下发未响应」(ackOverdue)时,不要重复派发:先用 dsh_workplan_status 看该行 childId 与已等待时长,必要时用 dsh_workplan_followup 投递一次说明;超过硬超时仍未响应会记为 blocked(blockedKind=no-ack),可以再下发指示复活。',
117
123
  /*
@@ -169,8 +175,10 @@ function asObject(value: any) {
169
175
 
170
176
  export type WorkplanConfig = {
171
177
  cwd?: string
172
- /** [2.1.3] 单次规划器调用上限(毫秒),亦可用 DSH_WORKPLAN_PLANNER_TIMEOUT_MS。 */
178
+ /** [2.1.3][2.1.6] 单次规划器调用的无进展窗口(毫秒),亦可用 DSH_WORKPLAN_PLANNER_TIMEOUT_MS。 */
173
179
  plannerTimeoutMs?: number
180
+ /** [2.1.6] 输出开始后的完全静默窗口(毫秒),亦可用 DSH_WORKPLAN_PLANNER_IDLE_TIMEOUT_MS。 */
181
+ plannerIdleTimeoutMs?: number
174
182
  childTimeoutMs?: number
175
183
  idleTimeoutMs?: number
176
184
  totalTimeoutMs?: number
@@ -224,6 +232,7 @@ function createUpdateTool(runtime: any) {
224
232
  + '当主 Agent 核对子任务结果、发现完成不实或需要修正时使用。'
225
233
  + '把子任务标成 done 时,必须同时给出真实的 verification 与 acceptance(每项 result="pass"),'
226
234
  + '否则计划不会变成可交付状态(deliveryReady=false,present 会被拒绝)。'
235
+ + '运行中的子任务需要更多时间时,传 extendMs(毫秒)即可协商放宽,不需要 force;放宽永远有界(累计 ≤ 初始协商上限 × 1),超出转新轮续跑或转 escalate 请主 Agent 裁决。'
227
236
  + '这些字段会写入会话日志,刷新/重启后仍然生效。',
228
237
  parameters: {
229
238
  type: 'object',
@@ -239,7 +248,7 @@ function createUpdateTool(runtime: any) {
239
248
  status: {
240
249
  type: 'string',
241
250
  enum: ['pending', 'in_progress', 'done', 'blocked'],
242
- description: '新的状态。',
251
+ description: '新的状态(普通改判必填;仅协商时限时可省略,改传 extendMs / timeNotice)。',
243
252
  },
244
253
  progress: {
245
254
  type: 'integer',
@@ -313,8 +322,40 @@ function createUpdateTool(runtime: any) {
313
322
  description: '待指示项(closure=escalated)的答复文本:与 status="in_progress" 一起使用,'
314
323
  + '会投递给子会话并把该行恢复为执行中。等价于 dsh_workplan_instruct。',
315
324
  },
325
+ /*
326
+ * [2.2.0][T5/O-4c] 延期事务(方案 §2.2 / §5.4;D-28 教训:runtime 会读取的
327
+ * 字段必须在这里显式声明,additionalProperties:false 会让未声明参数被严格
328
+ * 宿主直接拒收)。extendMs 只推移协商截止并重置计时,不改状态判定,运行中
329
+ * 无需 force(TASK_RUNNING 的唯一豁免);放宽永远有界(累计 ≤ 初始协商
330
+ * 上限 × 1),超出由 runtime 拒绝并转「请主 Agent 裁决」。
331
+ */
332
+ extendMs: {
333
+ type: 'integer',
334
+ description: '延期毫秒数(正整数,仅主 Agent 可用):只推移本子任务的协商截止并重置计时,'
335
+ + '不改状态判定;运行中可用,不需要 force。除非另传 status,否则可省略 status。'
336
+ + '放宽永远有界:累计延期 ≤ 初始协商上限的一倍,超出会被拒绝并提示转新轮续跑或转 escalate 请主 Agent 裁决。',
337
+ },
338
+ /*
339
+ * [2.2.0][T5/O-4c] O-2a 专家开工预告:{declaredMinutes, reason}。与 extendMs
340
+ * 同属「只记录、不改判定」的时限信息,运行中同样放行。
341
+ */
342
+ timeNotice: {
343
+ type: 'object',
344
+ description: '专家开工预告(O-2a):{ declaredMinutes, reason },只记入协商流水,不改状态与判定。',
345
+ properties: {
346
+ declaredMinutes: { type: 'number', description: '预计完成本子任务的分钟数(仅供参考、非承诺)。' },
347
+ reason: { type: 'string', description: '预告理由(可选)。' },
348
+ },
349
+ required: ['declaredMinutes'],
350
+ additionalProperties: false,
351
+ },
316
352
  },
317
- required: ['subtaskId', 'status'],
353
+ /*
354
+ * [2.2.0][T5/O-4c] status 不再是无条件必填:纯延期/纯预告事务(只带
355
+ * extendMs / timeNotice)是合法调用,runtime 会按「不改判定只改时限/记录」
356
+ * 处理;普通改判缺 status 仍由 runtime 以 INVALID_STATUS 拒绝。
357
+ */
358
+ required: ['subtaskId'],
318
359
  additionalProperties: false,
319
360
  },
320
361
  output: {
@@ -1120,7 +1161,38 @@ function createStatusTool(runtime: any) {
1120
1161
  )
1121
1162
  }
1122
1163
  const running = result.running === true
1123
- return textContent(
1164
+ const planner = isRecord(result.planner) ? result.planner : null
1165
+ const statuses = Array.isArray(result.statuses) ? result.statuses : []
1166
+ /*
1167
+ * [2.2.3][N1] 模型可见面补齐:planner 与 noticeChannel 之前只进结构化
1168
+ * value,DSH 只把 render 文本写进对话,导致 D5/D1-b 结构性不可读。
1169
+ * 这里只做只读展示,不改变状态机;缺失字段不编造。
1170
+ */
1171
+ const plannerLine = planner
1172
+ ? `规划器:推理等级 ${String(planner.reasoningEffort ?? '未记录')}`
1173
+ + `|来源 ${String(planner.reasoningEffortSource ?? '未记录')}`
1174
+ + `|判定 ${String(planner.outcome ?? '未记录')}`
1175
+ + (typeof planner.model === 'string' && planner.model ? `|模型 ${planner.model}` : '')
1176
+ : ''
1177
+ const channelLines = statuses
1178
+ .filter((item: any) => isRecord(item?.noticeChannel))
1179
+ .slice(0, 12)
1180
+ .map((item: any) => {
1181
+ const channel = item.noticeChannel
1182
+ const at = Number(channel.at) > 0
1183
+ ? new Date(Number(channel.at)).toLocaleString('zh-CN', { hour12: false })
1184
+ : '—'
1185
+ const observedAt = Number(channel.observedAt) > 0
1186
+ ? new Date(Number(channel.observedAt)).toLocaleString('zh-CN', { hour12: false })
1187
+ : '—'
1188
+ return `${String(item.subtaskId ?? '')} 通道:${String(channel.state ?? '')}`
1189
+ + `|target ${String(channel.target ?? '—')}`
1190
+ + `|caller ${String(channel.caller ?? '—')}`
1191
+ + `|at ${at}`
1192
+ + `|observedAt ${observedAt}`
1193
+ + `|reason ${String(channel.reason ?? '—')}`
1194
+ })
1195
+ return textContent([
1124
1196
  `计划 ${String(result.planId ?? '')}|${running ? '执行中' : '未在执行'}`
1125
1197
  + `|阶段:${phaseLabel(result.phase)}`
1126
1198
  + `|完成 ${Number(stats.done ?? 0)}/${Number(stats.total ?? 0)},受阻 ${Number(stats.blocked ?? 0)}`
@@ -1129,7 +1201,9 @@ function createStatusTool(runtime: any) {
1129
1201
  ? `|已 ${Math.round(Number(result.elapsedMs) / 1000)}s`
1130
1202
  : '')
1131
1203
  + (identity ? `|${identity}` : ''),
1132
- )
1204
+ plannerLine,
1205
+ ...channelLines,
1206
+ ].filter(Boolean).join('\n'))
1133
1207
  },
1134
1208
  },
1135
1209
  async execute(args: any, exec: any) {
@@ -1228,7 +1302,9 @@ function createDispatchTool(runtime: any) {
1228
1302
  * call is killed while the dispatcher is still legitimately working and the
1229
1303
  * plan looks stuck. Derive it from the resolved limits.
1230
1304
  */
1231
- timeoutMs: Number(runtime?.limits?.totalTimeoutMs ?? 1200000) + 20000,
1305
+ timeoutMs: Number(runtime?.limits?.totalTimeoutMs ?? 0) > 0
1306
+ ? Number(runtime.limits.totalTimeoutMs) + 20000
1307
+ : 24 * 60 * 60 * 1000,
1232
1308
  async execute(args: any, exec: any) {
1233
1309
  const parsed = asObject(args) ?? {}
1234
1310
  return runtime.dispatchTool(exec.agent, parsed, exec.signal)
@@ -1297,15 +1373,16 @@ function settingEnv(envName: string) {
1297
1373
  return typeof process !== 'undefined' ? process.env?.[envName] : undefined
1298
1374
  }
1299
1375
 
1300
- function numericSetting(configValue: any, envName: string) {
1376
+ function numericSetting(configValue: any, envName: string, allowZero = false) {
1377
+ const positive = (value: number) => Number.isFinite(value) && (allowZero ? value >= 0 : value > 0)
1301
1378
  if (configValue !== undefined && configValue !== null && configValue !== '') {
1302
1379
  const numeric = Number(configValue)
1303
- if (Number.isFinite(numeric) && numeric > 0) return numeric
1380
+ if (positive(numeric)) return numeric
1304
1381
  }
1305
1382
  const raw = typeof process !== 'undefined' ? process.env?.[envName] : undefined
1306
1383
  if (raw === undefined || raw === '') return undefined
1307
1384
  const numeric = Number(raw)
1308
- return Number.isFinite(numeric) && numeric > 0 ? numeric : undefined
1385
+ return positive(numeric) ? numeric : undefined
1309
1386
  }
1310
1387
 
1311
1388
  /**
@@ -1344,9 +1421,10 @@ export function apply(ctx: any, config: WorkplanConfig = {}) {
1344
1421
  },
1345
1422
  cwd: typeof config.cwd === 'string' ? config.cwd : undefined,
1346
1423
  plannerTimeoutMs: numericSetting(config.plannerTimeoutMs, 'DSH_WORKPLAN_PLANNER_TIMEOUT_MS'),
1424
+ plannerIdleTimeoutMs: numericSetting(config.plannerIdleTimeoutMs, 'DSH_WORKPLAN_PLANNER_IDLE_TIMEOUT_MS'),
1347
1425
  childTimeoutMs: numericSetting(config.childTimeoutMs, 'DSH_WORKPLAN_CHILD_TIMEOUT_MS'),
1348
1426
  idleTimeoutMs: numericSetting(config.idleTimeoutMs, 'DSH_WORKPLAN_IDLE_TIMEOUT_MS'),
1349
- totalTimeoutMs: numericSetting(config.totalTimeoutMs, 'DSH_WORKPLAN_TOTAL_TIMEOUT_MS'),
1427
+ totalTimeoutMs: numericSetting(config.totalTimeoutMs, 'DSH_WORKPLAN_TOTAL_TIMEOUT_MS', true),
1350
1428
  maxResumes: numericSetting(config.maxResumes, 'DSH_WORKPLAN_MAX_RESUMES'),
1351
1429
  /*
1352
1430
  * [1.10.6] 三态解析:显式配置 > 显式环境变量 > 默认开启。
@@ -1493,7 +1571,7 @@ export function apply(ctx: any, config: WorkplanConfig = {}) {
1493
1571
 
1494
1572
  export const meta = {
1495
1573
  name,
1496
- version: '2.1.3',
1574
+ version: '2.2.6',
1497
1575
  promptOrder: PROMPT_ORDER,
1498
1576
  routes: ['/dsh-workplan/plans', '/dsh-workplan/vendor/chart.umd.js'],
1499
1577
  }