dsh-workplan 1.8.18 → 1.9.1
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 +159 -0
- package/README.en.md +1 -1
- package/README.md +1 -1
- package/client.js +1 -0
- package/docs/postmortem-1.8.7-20261031.md +113 -0
- package/docs/release-notes-1.9.1.md +67 -0
- package/lib/host.js +105 -5
- package/lib/plan.js +151 -1
- package/lib/runtime.js +390 -37
- package/lib/supersede-digest.js +115 -0
- package/lib/supersede.js +378 -0
- package/package.json +2 -2
- package/src/client.ts +1 -0
- package/src/host.ts +113 -4
- package/src/plan.ts +166 -1
- package/src/runtime.ts +416 -35
- package/src/supersede-digest.ts +116 -0
- package/src/supersede.ts +429 -0
package/src/host.ts
CHANGED
|
@@ -109,6 +109,7 @@ const PROMPT_SECTION = [
|
|
|
109
109
|
*/
|
|
110
110
|
'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 续跑剩余项。',
|
|
111
111
|
'6. 如果续跑被拒绝、受阻项无法恢复、证据补不齐、计划已取消但未完成,或用户要求先看中间结果:答复开头必须写「未完成:剩余 N 项(列出 ID)与原因」,正文只能按中间结果表述,不得包装成成品。取消不会给你交付许可。',
|
|
112
|
+
'7. 子任务有硬执行上限(默认 15 分钟/步)与整轮预算(默认 20 分钟):子 Agent 接近上限时应先把已完成内容落盘并在结论里列出路径。任何「达到执行上限」「本轮预算用尽」都不等于「什么都没做」:状态里的 error 会列出「声明产物已在盘上」,必须先用文件核对;若产物已覆盖验收标准,用 dsh_workplan_update 复核改判,只补缺失部分再续跑,禁止无视盘上产物把整步重跑。',
|
|
112
113
|
'结果消息里每个完成项都带 verification 与 acceptance:`structured` 是子 Agent 逐条自检通过,`unverified` 是自述但未逐条确认,`failed` 是自检失败(已按受阻处理),`legacy` 是旧格式回传。只有 structured 且 acceptance 每项 pass 才算可交付;其余必须你自己核对产物,并用 dsh_workplan_update 的 verification/acceptance/artifacts 字段把核对结果写回(这些字段会持久化、刷新后仍生效),不要把“看着没问题”当成证据。',
|
|
113
114
|
'子 Agent 通过 `needs` 提出的跨部门需求会列在结果消息的「跨部门待转达」里:由你逐条处理(补派、向用户确认或直接完成),不要忽略。',
|
|
114
115
|
'长任务可以用 `dsh_workplan_dispatch({ mode: "async" })` 先开跑并立即答复用户,再用 `dsh_workplan_status` 查看进度;async 返回的是“已开跑”,不是“已完成”。',
|
|
@@ -272,7 +273,12 @@ function createCancelTool(runtime: any) {
|
|
|
272
273
|
'取消当前会话尚未派发/正在等待派发的任务分解计划。仅取消计划记录,不伪造任何完成;'
|
|
273
274
|
+ '取消后计划在面板中显示为“已取消”,不会启动任何部门 Agent。'
|
|
274
275
|
+ '注意:取消不等于完成。取消后如仍有未完成项或证据缺口,present 仍会被拒绝,'
|
|
275
|
-
+ '答复必须按「未完成:剩余 N 项与原因」说明。'
|
|
276
|
+
+ '答复必须按「未完成:剩余 N 项与原因」说明。'
|
|
277
|
+
+ 'disposition="superseded" 是另一种处置:把交付责任转移给一个可验证的承接计划。'
|
|
278
|
+
+ '运行时逐条复算(V1–V8):源计划必须已取消且未全 done、承接计划必须定义更晚且非终态、'
|
|
279
|
+
+ '映射必须覆盖源计划全部子任务、每个映射目标必须有 done+structured 证据与全通过的验收、'
|
|
280
|
+
+ '且本会话存在同时含两个 planId 的用户确认消息。任一不满足即拒绝并返回 SUPERSEDE_* 码,'
|
|
281
|
+
+ '状态不变;被取代不等于完成。',
|
|
276
282
|
parameters: {
|
|
277
283
|
type: 'object',
|
|
278
284
|
properties: {
|
|
@@ -282,7 +288,39 @@ function createCancelTool(runtime: any) {
|
|
|
282
288
|
},
|
|
283
289
|
reason: {
|
|
284
290
|
type: 'string',
|
|
285
|
-
description: '
|
|
291
|
+
description: '取消/取代原因,会写入会话记录。',
|
|
292
|
+
},
|
|
293
|
+
disposition: {
|
|
294
|
+
type: 'string',
|
|
295
|
+
enum: ['cancelled', 'superseded'],
|
|
296
|
+
description: '处置方式:cancelled=用户撤销(默认);superseded=责任已转移给承接计划。',
|
|
297
|
+
},
|
|
298
|
+
supersededBy: {
|
|
299
|
+
type: 'object',
|
|
300
|
+
description: 'disposition=superseded 时必填:承接计划与逐项覆盖映射。'
|
|
301
|
+
+ '只给映射意图,requiredCount/coveredCount/coverage/digest 由运行时复算,不接受自报。',
|
|
302
|
+
properties: {
|
|
303
|
+
planId: {
|
|
304
|
+
type: 'string',
|
|
305
|
+
description: '承接计划的 planId(必须定义得过且未终止)。',
|
|
306
|
+
},
|
|
307
|
+
mapping: {
|
|
308
|
+
type: 'array',
|
|
309
|
+
description: '源计划每个定义子任务一条映射;from 必须恰好覆盖全部源项(各一次)。',
|
|
310
|
+
items: {
|
|
311
|
+
type: 'object',
|
|
312
|
+
properties: {
|
|
313
|
+
from: { type: 'string', description: '源计划子任务 ID。' },
|
|
314
|
+
to: { type: 'string', description: '承接计划子任务 ID。' },
|
|
315
|
+
basis: { type: 'string', description: '覆盖依据(为什么这两项是同一责任)。' },
|
|
316
|
+
},
|
|
317
|
+
required: ['from', 'to', 'basis'],
|
|
318
|
+
additionalProperties: false,
|
|
319
|
+
},
|
|
320
|
+
},
|
|
321
|
+
},
|
|
322
|
+
required: ['planId', 'mapping'],
|
|
323
|
+
additionalProperties: false,
|
|
286
324
|
},
|
|
287
325
|
},
|
|
288
326
|
additionalProperties: false,
|
|
@@ -291,8 +329,20 @@ function createCancelTool(runtime: any) {
|
|
|
291
329
|
schema: cancelToolOutputSchema(),
|
|
292
330
|
render(_args: any, value: any) {
|
|
293
331
|
const result = isRecord(value) ? value : {}
|
|
294
|
-
if (!result.ok)
|
|
332
|
+
if (!result.ok) {
|
|
333
|
+
return textContent(`处置失败${result.code ? `(${String(result.code)})` : ''}:`
|
|
334
|
+
+ `${String(result.error ?? '未知错误')}`)
|
|
335
|
+
}
|
|
295
336
|
const stats = isRecord(result.stats) ? result.stats : {}
|
|
337
|
+
if (result.phase === 'superseded') {
|
|
338
|
+
const by = isRecord(result.supersededBy) ? result.supersededBy : {}
|
|
339
|
+
return textContent(
|
|
340
|
+
`计划 ${String(result.planId ?? '')} 已被取代:承接计划 ${String(by.planId ?? '')}`
|
|
341
|
+
+ `(映射 ${Number(by.coveredCount ?? 0)}/${Number(by.requiredCount ?? 0)},digest 已复算)`
|
|
342
|
+
+ `|源计划仍是 ${Number(stats.done ?? 0)}/${Number(stats.total ?? 0)}:被取代不等于完成,`
|
|
343
|
+
+ '不得 present 源计划,只能使用承接计划通过交付就绪检查的产物。',
|
|
344
|
+
)
|
|
345
|
+
}
|
|
296
346
|
const cancelledIncomplete = result.phase !== 'done'
|
|
297
347
|
return textContent(
|
|
298
348
|
`已取消计划 ${String(result.planId ?? '')}:${String(result.reason ?? '用户取消')}`
|
|
@@ -311,6 +361,64 @@ function createCancelTool(runtime: any) {
|
|
|
311
361
|
}
|
|
312
362
|
}
|
|
313
363
|
|
|
364
|
+
function createFollowupTool(runtime: any) {
|
|
365
|
+
return {
|
|
366
|
+
name: 'dsh_workplan_followup',
|
|
367
|
+
description:
|
|
368
|
+
'把一条说明投递给本会话的某个**直接子会话**,让它继续跑一个正常回合。'
|
|
369
|
+
+ '用途仅限:子任务被预算/超时中止、但产物已在盘上,且用户明确同意补发 follow-up 时,'
|
|
370
|
+
+ '让子会话自己收尾,从而让它自己的 turn/end 变成 completed。'
|
|
371
|
+
+ '它不写计划状态、不触发交付、也不改变界面判定;投递本身不等于完成。'
|
|
372
|
+
+ '不是直接子会话(父会话 catalog 未登记)一律拒绝。',
|
|
373
|
+
parameters: {
|
|
374
|
+
type: 'object',
|
|
375
|
+
properties: {
|
|
376
|
+
sessionId: {
|
|
377
|
+
type: 'string',
|
|
378
|
+
description: '直接子会话 ID(父会话 subagent/catalog 中登记的那一个)。',
|
|
379
|
+
},
|
|
380
|
+
message: {
|
|
381
|
+
type: 'string',
|
|
382
|
+
description: '发给子会话的说明:确认已有产物、只补缺口、不要整步重跑;不要要求它伪造完成。',
|
|
383
|
+
},
|
|
384
|
+
},
|
|
385
|
+
required: ['sessionId', 'message'],
|
|
386
|
+
additionalProperties: false,
|
|
387
|
+
},
|
|
388
|
+
output: {
|
|
389
|
+
schema: {
|
|
390
|
+
type: 'object',
|
|
391
|
+
properties: {
|
|
392
|
+
ok: { type: 'boolean' },
|
|
393
|
+
sessionId: { type: 'string' },
|
|
394
|
+
messageId: { type: 'string' },
|
|
395
|
+
code: { type: 'string' },
|
|
396
|
+
error: { type: 'string' },
|
|
397
|
+
},
|
|
398
|
+
required: ['ok'],
|
|
399
|
+
additionalProperties: true,
|
|
400
|
+
},
|
|
401
|
+
render(_args: any, value: any) {
|
|
402
|
+
const result = isRecord(value) ? value : {}
|
|
403
|
+
if (!result.ok) {
|
|
404
|
+
return textContent(
|
|
405
|
+
`follow-up 未投递:${String(result.error ?? result.code ?? '未知错误')}`,
|
|
406
|
+
)
|
|
407
|
+
}
|
|
408
|
+
return textContent(
|
|
409
|
+
`已向子会话 ${String(result.sessionId ?? '')} 投递 follow-up`
|
|
410
|
+
+ (result.messageId ? `(messageId ${String(result.messageId)})` : '')
|
|
411
|
+
+ '。投递只代表消息被接收;界面状态要等该子会话自己的回合正常结束才会变化。',
|
|
412
|
+
)
|
|
413
|
+
},
|
|
414
|
+
},
|
|
415
|
+
async execute(args: any, exec: any) {
|
|
416
|
+
const parsed = asObject(args) ?? {}
|
|
417
|
+
return runtime.followupTool(exec.agent, parsed, exec.signal)
|
|
418
|
+
},
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
|
|
314
422
|
function createStatusTool(runtime: any) {
|
|
315
423
|
return {
|
|
316
424
|
name: 'dsh_workplan_status',
|
|
@@ -541,6 +649,7 @@ export function apply(ctx: any, config: WorkplanConfig = {}) {
|
|
|
541
649
|
ctx.effect(() => ctx.tools.register(createUpdateTool(runtime)))
|
|
542
650
|
ctx.effect(() => ctx.tools.register(createCancelTool(runtime)))
|
|
543
651
|
ctx.effect(() => ctx.tools.register(createStatusTool(runtime)))
|
|
652
|
+
ctx.effect(() => ctx.tools.register(createFollowupTool(runtime)))
|
|
544
653
|
ctx.effect(() => ctx.tools.register(createDispatchTool(runtime)))
|
|
545
654
|
|
|
546
655
|
/*
|
|
@@ -621,7 +730,7 @@ export function apply(ctx: any, config: WorkplanConfig = {}) {
|
|
|
621
730
|
|
|
622
731
|
export const meta = {
|
|
623
732
|
name,
|
|
624
|
-
version: '1.
|
|
733
|
+
version: '1.9.1',
|
|
625
734
|
promptOrder: PROMPT_ORDER,
|
|
626
735
|
routes: ['/dsh-workplan/plans', '/dsh-workplan/vendor/chart.umd.js'],
|
|
627
736
|
}
|
package/src/plan.ts
CHANGED
|
@@ -9,7 +9,71 @@
|
|
|
9
9
|
|
|
10
10
|
import { randomUUID } from 'node:crypto'
|
|
11
11
|
|
|
12
|
+
import { isMappingDigest, verifyMappingDigest } from './supersede-digest.js'
|
|
13
|
+
|
|
12
14
|
export const PLAN_VERSION = 1
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* [1.9.0] 处置终态:cancelled(用户撤销)与 superseded(责任已转移)。
|
|
18
|
+
*
|
|
19
|
+
* 两者都是终态:记录与计数原样保留,永不算完成,也永不被自动选为
|
|
20
|
+
* `present` 的判定对象;只有「本回合结构化点名」时才判定(cancelled 仍硬拦)。
|
|
21
|
+
* 规则依据:_rerun_20261101/GATE_rule_design.md §3.1。
|
|
22
|
+
*/
|
|
23
|
+
export const TERMINAL_PHASES: ReadonlySet<string> = new Set(['cancelled', 'superseded'])
|
|
24
|
+
|
|
25
|
+
export function isTerminalPhase(phase: any): boolean {
|
|
26
|
+
return typeof phase === 'string' && TERMINAL_PHASES.has(phase)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* [1.9.2] `present` 拒绝码(P1 统一)。
|
|
31
|
+
*
|
|
32
|
+
* 规则出处:`_rerun_20261101/GATE_rule_design.md` §4.3(P1/P2 与
|
|
33
|
+
* `judgeEffective`)及 §4.4 真值表;最小修法出处:
|
|
34
|
+
* `_rerun_20261101/GATE_case_matrix.md` §3.2(T9 的唯一不一致格
|
|
35
|
+
* `C05.denyCode`)。
|
|
36
|
+
*
|
|
37
|
+
* T8 原文的 P1 把「全部 done 但证据缺口」和「还有子任务没做完」合并成
|
|
38
|
+
* 一个码值 `ACTIVE_NOT_READY`,于是 R2/G02 的 `EVIDENCE_GAP` 在未点名时
|
|
39
|
+
* 永远走不到。修法只拆一个维度:`remaining` 为空且 `blockers` 非空
|
|
40
|
+
* ⇒ `EVIDENCE_GAP`,其余仍是 `ACTIVE_NOT_READY`。这本来就是 1.8.19 的
|
|
41
|
+
* 既有语义(`remaining.length === 0` 有独立文案),不是新增语义。
|
|
42
|
+
*
|
|
43
|
+
* 码值是对外契约:测试、日志与后续 UI 按字面值断言。所有拒绝点只能引用
|
|
44
|
+
* 这里的常量或 `activeDenyCode()`,不得再手写字符串。
|
|
45
|
+
*/
|
|
46
|
+
export const PRESENT_DENY_CODES = {
|
|
47
|
+
ACTIVE_NOT_READY: 'ACTIVE_NOT_READY',
|
|
48
|
+
EVIDENCE_GAP: 'EVIDENCE_GAP',
|
|
49
|
+
CANCELLED_NAMED: 'CANCELLED_NAMED',
|
|
50
|
+
SUPERSEDED_STALE: 'SUPERSEDED_STALE',
|
|
51
|
+
} as const
|
|
52
|
+
|
|
53
|
+
export type PresentDenyCode = (typeof PRESENT_DENY_CODES)[keyof typeof PRESENT_DENY_CODES]
|
|
54
|
+
|
|
55
|
+
/** `present` 判定结果:码值 + 拒绝文案(文案逐字保留,码值供断言/日志)。 */
|
|
56
|
+
export interface PresentDenialVerdict {
|
|
57
|
+
code: PresentDenyCode
|
|
58
|
+
message: string
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* P1 的单一映射:active 计划未就绪时,只由交付就绪结果决定拒绝码。
|
|
63
|
+
*
|
|
64
|
+
* 调用点(`present` 的未完成分支、点名 active 计划的判定)必须走这个函数,
|
|
65
|
+
* 不要在分支里各写一份判断——T9 的 C05 不一致正是「规则一个码、实现另一个
|
|
66
|
+
* 码」造成的。终态计划不走这里:cancelled 是 `CANCELLED_NAMED`,superseded
|
|
67
|
+
* 按覆盖链给 `SUPERSEDED_STALE` / `ACTIVE_NOT_READY`。
|
|
68
|
+
*/
|
|
69
|
+
export function activeDenyCode(readiness: {
|
|
70
|
+
remaining: readonly string[]
|
|
71
|
+
blockers: readonly string[]
|
|
72
|
+
}): PresentDenyCode {
|
|
73
|
+
return readiness.remaining.length === 0 && readiness.blockers.length > 0
|
|
74
|
+
? PRESENT_DENY_CODES.EVIDENCE_GAP
|
|
75
|
+
: PRESENT_DENY_CODES.ACTIVE_NOT_READY
|
|
76
|
+
}
|
|
13
77
|
export const MAX_STAGES = 6
|
|
14
78
|
export const MAX_SUBTASKS = 15
|
|
15
79
|
export const MAX_CONCURRENT = 5
|
|
@@ -1299,7 +1363,26 @@ export function parseResultMessage(message: any) {
|
|
|
1299
1363
|
}
|
|
1300
1364
|
}
|
|
1301
1365
|
|
|
1302
|
-
|
|
1366
|
+
/*
|
|
1367
|
+
* [1.9.2] `workplan-cancel` 信封是 cancelled / superseded 的**唯一写入出口**。
|
|
1368
|
+
*
|
|
1369
|
+
* 规则出处:`_rerun_20261101/GATE_rule_design.md` §6.1(字段 schema)、§7.2
|
|
1370
|
+
* 第 7 条(写入 durable 记录后 replay 仍为 superseded)。写侧任何地方都不得
|
|
1371
|
+
* 自己拼这段 JSON:一旦有第二条拼装路径,`disposition`/`supersededBy` 的字段
|
|
1372
|
+
* 形状就会分叉,replay 与 present 的读侧判定随之失效(正是本子任务要杜绝的
|
|
1373
|
+
* 「绕过」)。
|
|
1374
|
+
*
|
|
1375
|
+
* 语义边界:本函数只负责把**运行时已经核验过**的处置结果写成信封;V1–V8
|
|
1376
|
+
* 核验与 digest 复算在 `src/supersede.ts`(唯一写入者)。因此这里对 superseded
|
|
1377
|
+
* 再做一次防线:`supersededBy.mapping` 与 `digest` 必须能逐字复算,否则抛错、
|
|
1378
|
+
* 不写日志、不改状态(fail-closed)。
|
|
1379
|
+
*/
|
|
1380
|
+
export function buildCancelMessage(planId: any, reason: any = '用户取消', terminal: any = null) {
|
|
1381
|
+
const disposition = terminal?.disposition ?? 'cancelled'
|
|
1382
|
+
if (disposition === 'superseded') return buildSupersededMessage(planId, reason, terminal)
|
|
1383
|
+
if (disposition !== 'cancelled') {
|
|
1384
|
+
throw new Error(`buildCancelMessage: 非法处置 disposition=${String(disposition)}`)
|
|
1385
|
+
}
|
|
1303
1386
|
const summary = `【任务已取消】${truncate(String(reason || '用户取消'), 120)}`
|
|
1304
1387
|
const payload = {
|
|
1305
1388
|
kind: 'workplan-cancel',
|
|
@@ -1333,6 +1416,60 @@ export function buildCancelMessage(planId: any, reason: any = '用户取消') {
|
|
|
1333
1416
|
})
|
|
1334
1417
|
}
|
|
1335
1418
|
|
|
1419
|
+
/**
|
|
1420
|
+
* [1.9.2] `disposition:'superseded'` 的信封正文(由 `buildCancelMessage` 独占调用)。
|
|
1421
|
+
*
|
|
1422
|
+
* 与 cancelled 共用同一个 `kind:'workplan-cancel'`:旧版本解析器只校验 `kind`
|
|
1423
|
+
* (`parseCancelMessage`),新增字段被忽略后按 cancelled 读——不可派发、不可
|
|
1424
|
+
* 交付,属安全降级(规则文档 §10.3)。这也是「不得新增第二种信封 kind」的原因:
|
|
1425
|
+
* 换 kind 会让旧回放彻底读不到这条处置记录。
|
|
1426
|
+
*/
|
|
1427
|
+
function buildSupersededMessage(planId: any, reason: any, terminal: any) {
|
|
1428
|
+
const by = terminal?.supersededBy
|
|
1429
|
+
const verifiable = isRecord(by)
|
|
1430
|
+
&& typeof by.planId === 'string'
|
|
1431
|
+
&& by.planId !== ''
|
|
1432
|
+
&& Array.isArray(by.mapping)
|
|
1433
|
+
&& by.mapping.length > 0
|
|
1434
|
+
&& isMappingDigest(by.digest)
|
|
1435
|
+
&& verifyMappingDigest(by.mapping, by.digest)
|
|
1436
|
+
if (!verifiable) {
|
|
1437
|
+
throw new Error('buildCancelMessage: superseded 信封必须带可复算的 supersededBy.planId/mapping/digest')
|
|
1438
|
+
}
|
|
1439
|
+
const text = String(reason || '责任已转移')
|
|
1440
|
+
const supersededAt = Number.isFinite(Number(terminal?.supersededAt)) ? Number(terminal.supersededAt) : Date.now()
|
|
1441
|
+
const requiredCount = Number(by.requiredCount ?? 0)
|
|
1442
|
+
const coveredCount = Number(by.coveredCount ?? 0)
|
|
1443
|
+
const summary = `【计划已被取代】${truncate(text, 120)}|承接:${by.planId}`
|
|
1444
|
+
+ `(映射 ${coveredCount}/${requiredCount})`
|
|
1445
|
+
const payload = {
|
|
1446
|
+
kind: 'workplan-cancel',
|
|
1447
|
+
version: PLAN_VERSION,
|
|
1448
|
+
planId,
|
|
1449
|
+
reason: text,
|
|
1450
|
+
cancelledAt: supersededAt,
|
|
1451
|
+
disposition: 'superseded',
|
|
1452
|
+
supersededAt,
|
|
1453
|
+
supersededBy: by,
|
|
1454
|
+
}
|
|
1455
|
+
const lines = [
|
|
1456
|
+
summary,
|
|
1457
|
+
'',
|
|
1458
|
+
'这次任务分解的责任已转移给一个可验证的承接计划。被取代不等于完成:',
|
|
1459
|
+
'原计划的记录与计数原样保留,未完成项永远不会因为这次转移而变成完成。',
|
|
1460
|
+
'交付时只能使用承接计划通过交付就绪检查的产物;原计划不作为完成证据。',
|
|
1461
|
+
'',
|
|
1462
|
+
CANCEL_MARKER_BEGIN,
|
|
1463
|
+
JSON.stringify(payload),
|
|
1464
|
+
CANCEL_MARKER_END,
|
|
1465
|
+
]
|
|
1466
|
+
return makeUserMessage(lines.join('\n'), {
|
|
1467
|
+
kind: 'workplan-cancel',
|
|
1468
|
+
form: 'notice',
|
|
1469
|
+
summary,
|
|
1470
|
+
})
|
|
1471
|
+
}
|
|
1472
|
+
|
|
1336
1473
|
export function parseCancelMessage(message: any) {
|
|
1337
1474
|
const body = extractBetween(messageText(message), CANCEL_MARKER_BEGIN, CANCEL_MARKER_END)
|
|
1338
1475
|
if (!body) return null
|
|
@@ -2154,6 +2291,11 @@ export function planPhase(statuses: any, _resultSeen = false) {
|
|
|
2154
2291
|
* 它们携带状态列表里没有的信息(预算暂停、用户取消)。
|
|
2155
2292
|
*/
|
|
2156
2293
|
export function reconcilePhase(phase: any, statuses: any) {
|
|
2294
|
+
/*
|
|
2295
|
+
* [1.9.0] 终态优先:superseded 的记录即使状态全部 done,也不得被对账成
|
|
2296
|
+
* done(T8 §5.5 C6)。cancelled 保持 1.8.19 的既有对账语义不变。
|
|
2297
|
+
*/
|
|
2298
|
+
if (phase === 'superseded') return phase
|
|
2157
2299
|
const derived = planPhase(statuses)
|
|
2158
2300
|
if (derived === 'done') return 'done'
|
|
2159
2301
|
if (phase === 'done' || phase === 'integrating') return derived
|
|
@@ -2469,6 +2611,28 @@ export function buildChildPrompt({
|
|
|
2469
2611
|
'请针对上面这个原因调整做法,不要重复相同的失败路径;如果仍然无法完成,第一行输出 `BLOCKED: 原因` 并说明缺少什么。',
|
|
2470
2612
|
].join('\n')
|
|
2471
2613
|
: ''
|
|
2614
|
+
/*
|
|
2615
|
+
* [1.8.19] A retried subtask must not pretend the prior attempt never existed.
|
|
2616
|
+
*
|
|
2617
|
+
* The timeout/budget paths record the declared outputs that already landed on
|
|
2618
|
+
* disk (`artifacts[].exists === true`). Feeding them back into the next
|
|
2619
|
+
* attempt turns a 15-minute restart into "check what is there and finish",
|
|
2620
|
+
* which is the difference between a recoverable ceiling and silent rework.
|
|
2621
|
+
*/
|
|
2622
|
+
const previousStatus = Array.isArray(statuses)
|
|
2623
|
+
? statuses.find((item: any) => item && item.subtaskId === subtask?.id)
|
|
2624
|
+
: null
|
|
2625
|
+
const landedArtifacts = (Array.isArray(previousStatus?.artifacts) ? previousStatus.artifacts : [])
|
|
2626
|
+
.filter((item: any) => item && item.exists === true && typeof item.ref === 'string')
|
|
2627
|
+
.map((item: any) => String(item.ref))
|
|
2628
|
+
const resumeHint = landedArtifacts.length > 0
|
|
2629
|
+
? [
|
|
2630
|
+
'',
|
|
2631
|
+
'上一次这一子任务被中止,但以下声明产物已经在盘上(先用 read/grep 核对,不要重写):',
|
|
2632
|
+
...landedArtifacts.slice(0, 8).map((ref: string) => `- ${ref}`),
|
|
2633
|
+
'已经覆盖验收标准的部分保持原样,只补缺失部分;结尾按契约给出证据块。',
|
|
2634
|
+
].join('\n')
|
|
2635
|
+
: ''
|
|
2472
2636
|
/*
|
|
2473
2637
|
* [1.8.12] 提示词整体过一遍 session-reference 消毒。
|
|
2474
2638
|
*
|
|
@@ -2501,6 +2665,7 @@ export function buildChildPrompt({
|
|
|
2501
2665
|
dependencies,
|
|
2502
2666
|
...(team ? ['', '兄弟部门进展(同一计划内的其他子任务;不要直接联系它们,需要协作请写进 needs 由主 Agent 转达):', team] : []),
|
|
2503
2667
|
...(failure ? [failure] : []),
|
|
2668
|
+
...(resumeHint ? [resumeHint] : []),
|
|
2504
2669
|
'',
|
|
2505
2670
|
'执行要求:',
|
|
2506
2671
|
'- 只完成本子任务,不擅自扩大范围;不要派生新的 Agent。',
|