dsh-workplan 2.2.9 → 2.3.2
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 +15 -0
- package/README.en.md +2 -2
- package/README.md +2 -2
- package/README.zh.md +242 -0
- package/docs/release-notes-2.3.0.md +7 -0
- package/docs/release-notes-2.3.2.md +7 -0
- package/docs/release-record-2.2.9-20261110.md +48 -0
- package/docs/release-record-2.3.0-20261110.md +23 -0
- package/lib/host.js +13 -3
- package/lib/plan.js +195 -8
- package/lib/runtime.js +227 -9
- package/package.json +1 -1
- package/src/host.ts +13 -3
- package/src/plan.ts +187 -7
- package/src/runtime.ts +227 -9
package/src/runtime.ts
CHANGED
|
@@ -1044,7 +1044,9 @@ export async function runPlanner(ctx: any, options: any) {
|
|
|
1044
1044
|
message,
|
|
1045
1045
|
`输出共 ${lastText.length} 字符,末尾原文:${JSON.stringify(tail)}`,
|
|
1046
1046
|
closed
|
|
1047
|
-
|
|
1047
|
+
// [2.3.2][D2-P1] 定向修复指令:message 已含「错误位置 + 断点附近原文」(extractJson
|
|
1048
|
+
// 的 parseFailureHint),这里明确要求只修语法、不动内容,替代旧「整段重掷」。
|
|
1049
|
+
? '末尾已闭合 → 断点在正文中间,属语法写错(漏逗号/括号不匹配):请按上文「错误位置/断点附近原文」只修复该处语法,禁止改动字段值与整体结构'
|
|
1048
1050
|
: '末尾未闭合(没有结尾 })→ 疑似输出被截断,请给出更紧凑的完整 JSON',
|
|
1049
1051
|
]
|
|
1050
1052
|
}
|
|
@@ -2663,6 +2665,107 @@ export function extendDeadline(record: any, subtaskId: any, extendMs: any, meta:
|
|
|
2663
2665
|
return { ok: true, deadlineAt, timerRearmed: true, watchdogRearmed: Boolean(handle.watchdog) }
|
|
2664
2666
|
}
|
|
2665
2667
|
|
|
2668
|
+
/*
|
|
2669
|
+
* [2.3.0][T1] 专家执行时间机制 v2.3.0(用户 2026-11-10 四项要求,全链路):
|
|
2670
|
+
* (a) 预估上报 → 告知用户:recordTimeNotice 落档后向主会话推送「请把预期用时
|
|
2671
|
+
* 转告用户」的即时通知;
|
|
2672
|
+
* (b) 超时 → 放宽 → 告知专家:延期事务成功后把最新执行时限推送给执行中的专家
|
|
2673
|
+
* 子会话,并附「必须在保证工作质量的前提下高效率执行」硬要求;
|
|
2674
|
+
* (c) 二次超时 → 主 Agent 接手:runSubtaskAttempt 的到点收束对每行计数
|
|
2675
|
+
* (timeoutCount),第二次超时置 takeoverRequired,并用 buildTakeoverBrief
|
|
2676
|
+
* 登记专家已完成产物、mergePreservedArtifacts 做「禁止丢弃已完成部分」的
|
|
2677
|
+
* 只读保护合并。
|
|
2678
|
+
* 向后兼容:全部走 StatusEntry 未知字段直写通道(与 deadlineAt/timeJournal
|
|
2679
|
+
* 同族),回放白名单同步透传;不改任何既有判定与既有字段语义。
|
|
2680
|
+
*/
|
|
2681
|
+
export const TAKEOVER_AFTER_TIMEOUTS = 2
|
|
2682
|
+
|
|
2683
|
+
/**
|
|
2684
|
+
* [2.3.0][T1] 组装「主 Agent 接手包」:已完成部分(专家已落盘产物 + 已登记
|
|
2685
|
+
* artifacts)逐条快照,未完成部分按 outputs 反推。instruction 是硬约束文案:
|
|
2686
|
+
* 禁止丢弃已完成部分——接手只补缺口,不整步重跑、不删除或覆盖专家产物。
|
|
2687
|
+
*/
|
|
2688
|
+
export function buildTakeoverBrief(subtask: any, row: any, landedRefs: any, timeoutCount: any) {
|
|
2689
|
+
const refs = (Array.isArray(landedRefs) ? landedRefs : [])
|
|
2690
|
+
.map((item: any) => String(item ?? ''))
|
|
2691
|
+
.filter(Boolean)
|
|
2692
|
+
.slice(0, 20)
|
|
2693
|
+
const completedArtifacts = (Array.isArray(row?.artifacts) ? row.artifacts : [])
|
|
2694
|
+
.filter((item: any) => item?.kind === 'file' && typeof item?.ref === 'string' && item.ref)
|
|
2695
|
+
.map((item: any) => ({ kind: 'file', ref: item.ref, exists: item.exists !== false }))
|
|
2696
|
+
.slice(0, 20)
|
|
2697
|
+
const outputs = (Array.isArray(subtask?.outputs) ? subtask.outputs : [])
|
|
2698
|
+
.map((item: any) => String(item ?? ''))
|
|
2699
|
+
.filter(Boolean)
|
|
2700
|
+
const remainingOutputs = outputs.filter((ref: string) => !refs.includes(ref))
|
|
2701
|
+
return {
|
|
2702
|
+
at: Date.now(),
|
|
2703
|
+
timeoutCount: Number(timeoutCount) || 0,
|
|
2704
|
+
landedRefs: refs,
|
|
2705
|
+
completedArtifacts,
|
|
2706
|
+
remainingOutputs,
|
|
2707
|
+
instruction: '主 Agent 只接手未完成部分:landedRefs/completedArtifacts 是专家已'
|
|
2708
|
+
+ '完成并登记保护的产物,只读、禁止丢弃、禁止删除或覆盖、禁止整步重跑;'
|
|
2709
|
+
+ '仅继续 remainingOutputs 与未满足的验收标准。',
|
|
2710
|
+
}
|
|
2711
|
+
}
|
|
2712
|
+
|
|
2713
|
+
/**
|
|
2714
|
+
* [2.3.0][T1] 「禁止丢弃已完成部分」的只读保护合并(A4 硬编码点):
|
|
2715
|
+
* 接手登记的保护清单(takeoverBrief.landedRefs)与行上 artifacts 取并集,
|
|
2716
|
+
* 只增不减——任何后续对 artifacts 的写入都不可能丢掉已完成部分。
|
|
2717
|
+
* 纯函数,可脱离宿主回归。
|
|
2718
|
+
*/
|
|
2719
|
+
export function mergePreservedArtifacts(artifacts: any, preservedRefs: any) {
|
|
2720
|
+
const list = (Array.isArray(artifacts) ? artifacts : [])
|
|
2721
|
+
.filter((item: any) => item && typeof item === 'object' && typeof item.ref === 'string')
|
|
2722
|
+
.map((item: any) => ({ ...item }))
|
|
2723
|
+
const seen = new Set(list.map((item: any) => String(item.ref)))
|
|
2724
|
+
for (const rawRef of Array.isArray(preservedRefs) ? preservedRefs : []) {
|
|
2725
|
+
const ref = String(rawRef ?? '')
|
|
2726
|
+
if (!ref || seen.has(ref)) continue
|
|
2727
|
+
// 保护条目固定 kind:'file'/exists:true:登记发生在产物确认在盘的时刻。
|
|
2728
|
+
list.push({ kind: 'file', ref, exists: true, preservedByTakeover: true })
|
|
2729
|
+
seen.add(ref)
|
|
2730
|
+
}
|
|
2731
|
+
return list.slice(-40)
|
|
2732
|
+
}
|
|
2733
|
+
|
|
2734
|
+
/**
|
|
2735
|
+
* [2.3.0][T1] 放宽成功后告知执行中的专家最新时限(A2 的「告知」半边)。
|
|
2736
|
+
* 走 ctx.subagents.sendMessage 与 follow-up 同一投递通道:运行中的子会话在下一
|
|
2737
|
+
* 步收到。投递失败不阻断延期事务(时限已经推移),只留档 record.errors。
|
|
2738
|
+
*/
|
|
2739
|
+
async function notifyExpertOfExtension(ctx: any, agent: any, record: any, subtaskId: string, deadlineAt: number) {
|
|
2740
|
+
const row = Array.isArray(record?.statuses)
|
|
2741
|
+
? record.statuses.find((item: any) => item?.subtaskId === subtaskId)
|
|
2742
|
+
: null
|
|
2743
|
+
const childId = String(row?.childId ?? '')
|
|
2744
|
+
const service: any = ctx?.subagents
|
|
2745
|
+
if (!childId) {
|
|
2746
|
+
return { ok: false, error: '该行没有活跃子会话(childId 缺失),专家续跑时可从状态行 deadlineAt 读取最新时限' }
|
|
2747
|
+
}
|
|
2748
|
+
if (!service || typeof service.sendMessage !== 'function') {
|
|
2749
|
+
return { ok: false, error: '当前部署没有可用的 subagent 服务,无法投递延期告知' }
|
|
2750
|
+
}
|
|
2751
|
+
const remainingMin = Math.max(1, Math.ceil((Number(deadlineAt) - Date.now()) / 60000))
|
|
2752
|
+
const text = `【dsh-workplan·延期告知】子任务 ${subtaskId} 的执行时限已由主 Agent 放宽:`
|
|
2753
|
+
+ `最新执行时间为 ${new Date(Number(deadlineAt)).toISOString()}(约剩 ${remainingMin} 分钟)。`
|
|
2754
|
+
+ '你必须在保证工作质量的前提下高效率执行:优先推进高价值步骤,已完成内容及时落盘,'
|
|
2755
|
+
+ '并在回报中明确区分「已完成 / 未完成」。收到本通知后请继续当前工作,不要重新开始。'
|
|
2756
|
+
try {
|
|
2757
|
+
await service.sendMessage(agent, childId, [{ type: 'text', text }], {})
|
|
2758
|
+
if (row) {
|
|
2759
|
+
const journal = Array.isArray(row.timeJournal) ? row.timeJournal : []
|
|
2760
|
+
journal.push({ at: Date.now(), action: 'notify-expert', deadlineAt: Number(deadlineAt), by: 'system' })
|
|
2761
|
+
row.timeJournal = journal.slice(-20)
|
|
2762
|
+
}
|
|
2763
|
+
return { ok: true }
|
|
2764
|
+
} catch (error: any) {
|
|
2765
|
+
return { ok: false, error: truncate(error instanceof Error ? error.message : String(error), 300) }
|
|
2766
|
+
}
|
|
2767
|
+
}
|
|
2768
|
+
|
|
2666
2769
|
/*
|
|
2667
2770
|
* One attempt under a deadline that belongs to that attempt alone.
|
|
2668
2771
|
*
|
|
@@ -2740,7 +2843,15 @@ async function runSubtaskAttempt(
|
|
|
2740
2843
|
// 续跑、人工裁决)。Reached only when the child ignored both its idle window
|
|
2741
2844
|
// and its abort signal; the message says so, otherwise the cause looks like
|
|
2742
2845
|
// a plain "too slow" and the next investigation goes down the wrong path.
|
|
2743
|
-
|
|
2846
|
+
// [2.3.0][T1] 计数在组装文案前预读:第 1 次超时的文案要求「必须放宽并
|
|
2847
|
+
// 告知专家」;第 2 次及以后的文案要求「主 Agent 接手、已完成部分只读
|
|
2848
|
+
// 保护、禁止丢弃」。错误文本是结果消息/看板/续跑判定的共同来源,所以
|
|
2849
|
+
// 接手语义必须在这里就落进 message,而不是只进即时通知。
|
|
2850
|
+
const preRow = record.statuses.find((item: any) => item?.subtaskId === subtask.id)
|
|
2851
|
+
const timeoutCountAtFire = Number(preRow?.timeoutCount ?? 0) + 1
|
|
2852
|
+
const message = timeoutCountAtFire >= TAKEOVER_AFTER_TIMEOUTS
|
|
2853
|
+
? `子任务 ${subtask.id} 第 ${timeoutCountAtFire} 次达到协商执行上限(${timeoutMs}ms),已按安全兜底结算(待裁决:takeoverRequired——预估时间已两次超时,请主 Agent 直接接手完成尚未完成的部分;专家已完成并落盘的部分已登记只读保护,禁止丢弃、禁止整步重跑)`
|
|
2854
|
+
: `子任务 ${subtask.id} 第 ${timeoutCountAtFire} 次达到协商执行上限(${timeoutMs}ms),已按安全兜底结算(待裁决:请主 Agent 立即放宽(extendMs,放宽后插件自动告知专家最新时限与保证质量高效率要求)/ 重试 / 接受,或转新轮续跑、人工裁决)`
|
|
2744
2855
|
try {
|
|
2745
2856
|
// [1.8.19] Keep the evidence of what already landed on disk.
|
|
2746
2857
|
const { patch, landed } = timeoutBlockedPatch(subtask, options.cwd, message, options.artifactExists)
|
|
@@ -2771,6 +2882,40 @@ async function runSubtaskAttempt(
|
|
|
2771
2882
|
*/
|
|
2772
2883
|
const settleRow = record.statuses.find((item: any) => item?.subtaskId === subtask.id)
|
|
2773
2884
|
if (settleRow) settleRow.pendingAdjudication = true
|
|
2885
|
+
/*
|
|
2886
|
+
* [2.3.0][T1] 超时计数与二次超时接手(用户要求 1/2 的机读落点):
|
|
2887
|
+
* 每次到点收束给状态行 timeoutCount +1 并记入 timeJournal(action:'timeout')。
|
|
2888
|
+
* 第 1 次超时 → 即时通知主 Agent「必须放宽(extendMs)并告知专家最新时限」,
|
|
2889
|
+
* 告知专家由延期事务自动投递(notifyExpertOfExtension);
|
|
2890
|
+
* 第 2 次超时 → takeoverRequired=true + buildTakeoverBrief 登记已完成部分,
|
|
2891
|
+
* mergePreservedArtifacts 把已落盘产物并入行 artifacts(只读保护、只增不减),
|
|
2892
|
+
* 主 Agent 接手只继续 remainingOutputs 与未满足验收,禁止丢弃已完成部分。
|
|
2893
|
+
* 计数走 StatusEntry 未知字段直写通道,回放白名单同步透传。
|
|
2894
|
+
*/
|
|
2895
|
+
if (settleRow) {
|
|
2896
|
+
const timeoutCount = timeoutCountAtFire
|
|
2897
|
+
settleRow.timeoutCount = timeoutCount
|
|
2898
|
+
const timeoutJournal = Array.isArray(settleRow.timeJournal) ? settleRow.timeJournal : []
|
|
2899
|
+
timeoutJournal.push({ at: Date.now(), action: 'timeout', timeoutCount, by: 'system' })
|
|
2900
|
+
settleRow.timeJournal = timeoutJournal.slice(-20)
|
|
2901
|
+
if (timeoutCount >= TAKEOVER_AFTER_TIMEOUTS) {
|
|
2902
|
+
// 禁止丢弃已完成部分:接手包 + artifacts 只增不减的并集合并。
|
|
2903
|
+
settleRow.takeoverRequired = true
|
|
2904
|
+
settleRow.takeoverBrief = buildTakeoverBrief(subtask, settleRow, ceilingLanded, timeoutCount)
|
|
2905
|
+
settleRow.artifacts = mergePreservedArtifacts(settleRow.artifacts, settleRow.takeoverBrief.landedRefs)
|
|
2906
|
+
}
|
|
2907
|
+
try {
|
|
2908
|
+
const takeoverText = timeoutCount >= TAKEOVER_AFTER_TIMEOUTS
|
|
2909
|
+
? `子任务 ${subtask.id} 已第 ${timeoutCount} 次达到协商时限(二次超时):按 2.3.0 机制本行已置「主 Agent 接手」(takeoverRequired)。`
|
|
2910
|
+
+ `专家已完成并登记保护的部分(只读、禁止丢弃):${(ceilingLanded as string[]).slice(0, 8).join('、') || '(见 takeoverBrief)'};`
|
|
2911
|
+
+ '请主 Agent 直接接手继续未完成部分,不要整步重跑、不要删除或覆盖已登记产物。'
|
|
2912
|
+
: `子任务 ${subtask.id} 第 1 次达到协商时限:按 2.3.0 机制请主 Agent 尽快用 dsh_workplan_update(extendMs) 放宽,`
|
|
2913
|
+
+ '延期成功后插件会自动把最新时限与「保证质量、高效率执行」要求告知专家;如判断无需再放宽,请接手继续未完成部分(已完成产物将只读保护)。'
|
|
2914
|
+
announceSubtaskInterrupt(record, options.session ?? options.agent?.session, subtask.id, takeoverText)
|
|
2915
|
+
} catch {
|
|
2916
|
+
// 通知失败不影响结算(与预警同一纪律)。
|
|
2917
|
+
}
|
|
2918
|
+
}
|
|
2774
2919
|
record.updatedAt = Date.now()
|
|
2775
2920
|
} catch (error: any) {
|
|
2776
2921
|
record.errors = [
|
|
@@ -3007,6 +3152,23 @@ export function modelStatusLines(statuses: any) {
|
|
|
3007
3152
|
timeWarning: item.timeWarning ?? null,
|
|
3008
3153
|
timeJournal: Array.isArray(item.timeJournal) ? item.timeJournal.slice(-10) : [],
|
|
3009
3154
|
pendingAdjudication: item.pendingAdjudication === true,
|
|
3155
|
+
// [2.3.0][T1] 预估上报(A1)也要进模型可读面:主 Agent 告知用户前先读这里。
|
|
3156
|
+
timeNotice: item.timeNotice ?? null,
|
|
3157
|
+
/*
|
|
3158
|
+
* [2.3.0][T1] 超时计数 / 二次超时接手进入模型可读面:主 Agent 一眼能看出
|
|
3159
|
+
* 该行第几次超时、是否必须接手、接手包里哪些是只读保护的已完成产物。
|
|
3160
|
+
*/
|
|
3161
|
+
timeoutCount: Number(item.timeoutCount ?? 0),
|
|
3162
|
+
takeoverRequired: item.takeoverRequired === true,
|
|
3163
|
+
takeoverBrief: item.takeoverBrief ?? null,
|
|
3164
|
+
/*
|
|
3165
|
+
* [2.3.0][T1] 已完成产物的只读保护登记必须进模型可读面:statusTool 的行
|
|
3166
|
+
* 来自本函数,此前不序列化 artifacts,导致 takeoverRequired 的「禁止丢弃
|
|
3167
|
+
* 已完成部分」清单对主 Agent 不可见。只透出对象形条目,照录不改写。
|
|
3168
|
+
*/
|
|
3169
|
+
artifacts: (Array.isArray(item.artifacts) ? item.artifacts : [])
|
|
3170
|
+
.filter((entry: any) => entry && typeof entry === 'object' && typeof entry.ref === 'string')
|
|
3171
|
+
.map((entry: any) => ({ ...entry })),
|
|
3010
3172
|
/*
|
|
3011
3173
|
* [2.2.0][T3/O-2a] 子→主预告通道的结论必须进入模型可读面。
|
|
3012
3174
|
*
|
|
@@ -3939,7 +4101,7 @@ export function reconstructFromSession(session: any, targetPlanId?: string) {
|
|
|
3939
4101
|
for (const entry of (Array.isArray(result.statuses) ? result.statuses : [])) {
|
|
3940
4102
|
const rebuiltRow = snap.statuses.find((item: any) => item?.subtaskId === entry?.subtaskId)
|
|
3941
4103
|
if (!rebuiltRow || !isRecord(entry)) continue
|
|
3942
|
-
for (const field of ['deadlineAt', 'timeNotice', 'timeWarning', 'timeJournal', 'pendingAdjudication']) {
|
|
4104
|
+
for (const field of ['deadlineAt', 'timeNotice', 'timeWarning', 'timeJournal', 'pendingAdjudication', 'timeoutCount', 'takeoverRequired', 'takeoverBrief']) {
|
|
3943
4105
|
if (entry[field] !== undefined) rebuiltRow[field] = entry[field]
|
|
3944
4106
|
}
|
|
3945
4107
|
/*
|
|
@@ -4037,6 +4199,23 @@ export function reconstructFromSession(session: any, targetPlanId?: string) {
|
|
|
4037
4199
|
})
|
|
4038
4200
|
continue
|
|
4039
4201
|
}
|
|
4202
|
+
/*
|
|
4203
|
+
* [2.3.0][hotfix] 回放兼容「已回报行 + 旧版 closure:'done' 错误快照」(用户 2026-11-10 截图:
|
|
4204
|
+
* wp-3080d01d T6/T7「非法闭环迁移:reported → done」回放忽略)。
|
|
4205
|
+
*
|
|
4206
|
+
* 2.0.4 之前 live 侧 applyStatus 把 reported 行的 closure 误写回 'done',durable 改判
|
|
4207
|
+
* 消息因此嵌着这个错误快照。2.2.6 D-1 给回放补了 closure 透传,但没有豁免这一组合:
|
|
4208
|
+
* 回放大方把 'done' 当显式闭环意图传给迁移表 → reported → done 被拒 → 整条改判
|
|
4209
|
+
* (含 verification/acceptance 证据)被裸 catch 吞掉,重启后行退回缺证据态。
|
|
4210
|
+
*
|
|
4211
|
+
* 口径与 2.0.4 live 侧镜像:事件 closure='done' 且当前行 closure='reported' 时,这是
|
|
4212
|
+
* 「复核补齐」而非「退回未回报」,丢弃该显式值,让 done 分支按 2.0.4 保留已回报事实。
|
|
4213
|
+
* 其余透传分支(escalated/instructed 等,D-1 语义)零改动。
|
|
4214
|
+
*/
|
|
4215
|
+
const preReplayRow = snap.statuses.find((item: any) => item?.subtaskId === update.subtaskId)
|
|
4216
|
+
const replayClosure: string | undefined = typeof update.closure === 'string'
|
|
4217
|
+
? (update.closure === 'done' && preReplayRow?.closure === 'reported' ? undefined : update.closure)
|
|
4218
|
+
: undefined
|
|
4040
4219
|
snap.statuses = applyStatus(snap.statuses, update.subtaskId, {
|
|
4041
4220
|
/*
|
|
4042
4221
|
* handoff 的 durable 记录携带的是状态快照,不是一次状态迁移。
|
|
@@ -4055,7 +4234,7 @@ export function reconstructFromSession(session: any, targetPlanId?: string) {
|
|
|
4055
4234
|
* 重启后「待指示」行永久卡死(2026-11-08 wp-3c8c84b2 T2 实证,
|
|
4056
4235
|
* 见 artifacts/2.2.5-post-restart-regression.md §4 D-1)。
|
|
4057
4236
|
*/
|
|
4058
|
-
closure:
|
|
4237
|
+
closure: replayClosure,
|
|
4059
4238
|
progress: typeof update.progress === 'number' ? update.progress : undefined,
|
|
4060
4239
|
summary: typeof update.note === 'string' ? update.note : undefined,
|
|
4061
4240
|
// [1.8.13] Evidence written through the update tool must survive replay.
|
|
@@ -4106,7 +4285,7 @@ export function reconstructFromSession(session: any, targetPlanId?: string) {
|
|
|
4106
4285
|
*/
|
|
4107
4286
|
const replayRow = snap.statuses.find((item: any) => item?.subtaskId === update.subtaskId)
|
|
4108
4287
|
if (replayRow) {
|
|
4109
|
-
for (const field of ['deadlineAt', 'timeNotice', 'timeWarning', 'timeJournal', 'pendingAdjudication']) {
|
|
4288
|
+
for (const field of ['deadlineAt', 'timeNotice', 'timeWarning', 'timeJournal', 'pendingAdjudication', 'timeoutCount', 'takeoverRequired', 'takeoverBrief']) {
|
|
4110
4289
|
if (update[field] !== undefined) replayRow[field] = update[field]
|
|
4111
4290
|
}
|
|
4112
4291
|
const replayExtend = Number(update.extendMs)
|
|
@@ -4806,7 +4985,7 @@ export function createWorkplanRuntime(ctx: any, options: WorkplanRuntimeOptions
|
|
|
4806
4985
|
* 路由分支,按 T4 直写通道写行(StatusEntry 保留未知字段;回放白名单已透传
|
|
4807
4986
|
* timeNotice,刷新后不丢)。
|
|
4808
4987
|
*/
|
|
4809
|
-
function recordTimeNotice(record: any, subtaskId: string, notice: any) {
|
|
4988
|
+
function recordTimeNotice(record: any, subtaskId: string, notice: any, session?: any) {
|
|
4810
4989
|
const row = Array.isArray(record?.statuses)
|
|
4811
4990
|
? record.statuses.find((item: any) => item?.subtaskId === subtaskId)
|
|
4812
4991
|
: null
|
|
@@ -4829,6 +5008,23 @@ export function createWorkplanRuntime(ctx: any, options: WorkplanRuntimeOptions
|
|
|
4829
5008
|
})
|
|
4830
5009
|
row.timeJournal = journal.slice(-20)
|
|
4831
5010
|
record.updatedAt = at
|
|
5011
|
+
/*
|
|
5012
|
+
* [2.3.0][T1] 预估上报 → 告知用户(用户要求 1 的前半段闭环):专家的开工
|
|
5013
|
+
* 预告落档后,插件立即向主会话推送一条即时通知,明确「请把此预期执行
|
|
5014
|
+
* 时间告知用户」;新预告覆盖旧预告(每条新预告各通知一次,与「开工预告」
|
|
5015
|
+
* 协议一致)。通知是观测设施:写失败只留档 errors,绝不影响记录与执行。
|
|
5016
|
+
*/
|
|
5017
|
+
if (session) {
|
|
5018
|
+
try {
|
|
5019
|
+
appendUserMessage(session, `【dsh-workplan·专家预估上报】子任务 ${subtaskId} 的执行专家`
|
|
5020
|
+
+ `预估执行时间 ${Number(notice?.declaredMinutes)} 分钟`
|
|
5021
|
+
+ (reason ? `(${reason})` : '')
|
|
5022
|
+
+ `;请把此预期执行时间告知用户。若执行中超时,请主 Agent 放宽(extendMs)`
|
|
5023
|
+
+ '并告知专家最新时限,连续两次超时则由主 Agent 接手未完成部分(已完成产物只读保护,禁止丢弃)。')
|
|
5024
|
+
} catch (error: any) {
|
|
5025
|
+
record.errors = [...(record.errors ?? []), `${subtaskId} 预估上报通知写入失败:${truncate(String(error?.message ?? error), 200)}`].slice(-20)
|
|
5026
|
+
}
|
|
5027
|
+
}
|
|
4832
5028
|
}
|
|
4833
5029
|
|
|
4834
5030
|
async function updateStatus(agent: any, args: any): Promise<any> {
|
|
@@ -5003,7 +5199,7 @@ export function createWorkplanRuntime(ctx: any, options: WorkplanRuntimeOptions
|
|
|
5003
5199
|
* [2.2.0][T5/O-4c] 预告与指示同一次到达时,指示成功落行后再记预告:
|
|
5004
5200
|
* 指示失败不该留下一笔「专家已预告」的记录。
|
|
5005
5201
|
*/
|
|
5006
|
-
if (hasTimeNotice && instructed?.ok !== false) recordTimeNotice(record, subtaskId, timeNoticeArg)
|
|
5202
|
+
if (hasTimeNotice && instructed?.ok !== false) recordTimeNotice(record, subtaskId, timeNoticeArg, session)
|
|
5007
5203
|
return instructed
|
|
5008
5204
|
}
|
|
5009
5205
|
if (current?.closure === 'escalated') {
|
|
@@ -5070,9 +5266,17 @@ export function createWorkplanRuntime(ctx: any, options: WorkplanRuntimeOptions
|
|
|
5070
5266
|
}
|
|
5071
5267
|
}
|
|
5072
5268
|
extension = extended
|
|
5269
|
+
/*
|
|
5270
|
+
* [2.3.0][T1] 用户要求 1 后半段:放宽成功后必须把「最新执行时间」告知
|
|
5271
|
+
* 专家,同时附「必须在保证工作质量的前提下高效率执行」硬要求,让专家
|
|
5272
|
+
* 有准备(收到通知继续当前工作,不重新开始)。投递失败不回滚延期——
|
|
5273
|
+
* 时限已经推移,只是告知通道未达:留档 errors,回执带 childNotified
|
|
5274
|
+
* 供主 Agent 决定是否用 dsh_workplan_followup 补发。
|
|
5275
|
+
*/
|
|
5276
|
+
extension.childNotified = (await notifyExpertOfExtension(ctx, agent, record, subtaskId, extension.deadlineAt)).ok
|
|
5073
5277
|
}
|
|
5074
5278
|
if (!statusRequested) {
|
|
5075
|
-
if (hasTimeNotice) recordTimeNotice(record, subtaskId, timeNoticeArg)
|
|
5279
|
+
if (hasTimeNotice) recordTimeNotice(record, subtaskId, timeNoticeArg, session)
|
|
5076
5280
|
/*
|
|
5077
5281
|
* 纯时限事务到此结束。方案 §2.2 效果 3:状态行 revision +1(延期/预告也是
|
|
5078
5282
|
* 行变更,同样受 STALE_WRITE 乐观锁保护);状态与判定一个字段都不改。
|
|
@@ -5098,6 +5302,7 @@ export function createWorkplanRuntime(ctx: any, options: WorkplanRuntimeOptions
|
|
|
5098
5302
|
deadlineAt: extension.deadlineAt,
|
|
5099
5303
|
timerRearmed: extension.timerRearmed,
|
|
5100
5304
|
watchdogRearmed: extension.watchdogRearmed,
|
|
5305
|
+
childNotified: extension.childNotified === true,
|
|
5101
5306
|
}
|
|
5102
5307
|
: {}),
|
|
5103
5308
|
...(hasTimeNotice ? { timeNotice: written?.timeNotice ?? null } : {}),
|
|
@@ -5141,11 +5346,24 @@ export function createWorkplanRuntime(ctx: any, options: WorkplanRuntimeOptions
|
|
|
5141
5346
|
revision,
|
|
5142
5347
|
updatedBy: 'agent',
|
|
5143
5348
|
})
|
|
5349
|
+
/*
|
|
5350
|
+
* [2.3.0][T1] 禁止丢弃已完成部分(A4 的第二个硬编码保护点):接手行
|
|
5351
|
+
* (takeoverRequired)后续任何一次 artifacts 写入,都把 takeoverBrief 登记
|
|
5352
|
+
* 的保护产物并集合并回来——只增不减,主 Agent 改判时不可能删掉专家已完成
|
|
5353
|
+
* 的产物清单,只能在其基础上补缺口。
|
|
5354
|
+
*/
|
|
5355
|
+
if (args?.artifacts !== undefined) {
|
|
5356
|
+
const protectedRow = record.statuses.find((item: any) => item?.subtaskId === subtaskId)
|
|
5357
|
+
if (protectedRow?.takeoverRequired === true && Array.isArray(protectedRow?.takeoverBrief?.landedRefs)
|
|
5358
|
+
&& protectedRow.takeoverBrief.landedRefs.length > 0) {
|
|
5359
|
+
protectedRow.artifacts = mergePreservedArtifacts(protectedRow.artifacts, protectedRow.takeoverBrief.landedRefs)
|
|
5360
|
+
}
|
|
5361
|
+
}
|
|
5144
5362
|
/*
|
|
5145
5363
|
* [2.2.0][T5/O-4c] 带 status 的调用同时带 timeNotice 时,预告记录在改判落行
|
|
5146
5364
|
* 之后写入:applyStatus 抛错(如非法 verification)时不会留下半写的预告。
|
|
5147
5365
|
*/
|
|
5148
|
-
if (hasTimeNotice) recordTimeNotice(record, subtaskId, timeNoticeArg)
|
|
5366
|
+
if (hasTimeNotice) recordTimeNotice(record, subtaskId, timeNoticeArg, session)
|
|
5149
5367
|
if (status === 'blocked') {
|
|
5150
5368
|
record.statuses = markDependentsBlocked(record.plan, record.statuses, subtaskId, { reason: summary || '主 Agent 标记受阻' })
|
|
5151
5369
|
}
|