dsh-workplan 2.2.8 → 2.3.0
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 +12 -0
- package/README.en.md +2 -2
- package/README.md +2 -2
- package/README.zh.md +242 -0
- package/docs/handle-policy-fix-20261110-T2.md +50 -0
- package/docs/handle-policy-fix-20261110-T2.patch +1050 -0
- package/docs/release-notes-2.3.0.md +7 -0
- package/docs/release-record-2.2.8-20261110.md +66 -0
- package/docs/release-record-2.2.9-20261110.md +48 -0
- package/docs/rootcause-red-x-recurrence-20261110-T1.md +110 -0
- package/lib/host.js +13 -3
- package/lib/plan.js +22 -0
- package/lib/runtime.js +282 -13
- package/lib/watchdog.js +2 -1
- package/package.json +2 -2
- package/src/host.ts +13 -3
- package/src/plan.ts +21 -0
- package/src/runtime.ts +285 -13
- package/src/watchdog.ts +2 -1
package/lib/runtime.js
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* in this file is allowed to escape as an unhandled rejection from a listener.
|
|
13
13
|
*/
|
|
14
14
|
import { randomUUID } from 'node:crypto';
|
|
15
|
-
import { existsSync, realpathSync, statSync } from 'node:fs';
|
|
15
|
+
import { existsSync, readFileSync, realpathSync, statSync } from 'node:fs';
|
|
16
16
|
import { basename, dirname, isAbsolute, join, resolve } from 'node:path';
|
|
17
17
|
import { createNoticeChannel, finaliseNoticeChannel, formatNoticeChannelLog, observeRelayedNotice, readLeadAgentId, resolveLeadAgentId, validateNoticeChannel, } from './notice-channel.js';
|
|
18
18
|
import { MAX_CONCURRENT, PlanError, aggregateInvariantViolations, appendUserMessage, applyStatus, attachPlanMeta, blockCancelledDependents, buildChildPrompt, buildCancelMessage, buildClarifyMessage, createPlannerProgressReporter, buildDegradedMessage, buildPlanMessage, buildPlannerPrompt, buildResultMessage, buildStopSteerText, createStatuses, DEFAULT_REASONING_EFFORT, deliveryReadiness, derivePlanSnapshot,
|
|
@@ -1098,7 +1098,8 @@ async function disposeActivation(activation, record, subtaskId, guard) {
|
|
|
1098
1098
|
activation.dispose(),
|
|
1099
1099
|
new Promise((_, reject) => {
|
|
1100
1100
|
timer = setTimeout(() => reject(new Error('dispose timeout')), DISPOSE_TIMEOUT_MS);
|
|
1101
|
-
|
|
1101
|
+
// [2.2.9][handle-policy] 收束类(T1 报告 R6):dispose 超时臂必须真实触发,
|
|
1102
|
+
// unref 时裸事件循环下进程先排空、race 永不 settle 也不报错。下方 finally 照常 clearTimeout。
|
|
1102
1103
|
}),
|
|
1103
1104
|
]);
|
|
1104
1105
|
}
|
|
@@ -1644,6 +1645,16 @@ export function shouldRetryAttempt(error, attempt, remainingMs, idleTimeoutMs) {
|
|
|
1644
1645
|
if (code === 'EVIDENCE_UNPARSABLE') {
|
|
1645
1646
|
return Number(remainingMs) > Number(idleTimeoutMs);
|
|
1646
1647
|
}
|
|
1648
|
+
/*
|
|
1649
|
+
* [2.2.9] 结果块缺失与 unparsable 同闸(用户 2026-11-10 红字复发族):
|
|
1650
|
+
* 结算的唯一载体是收尾消息块,任何异常收尾(error/截断/超时)都会丢;
|
|
1651
|
+
* 旧实现 missing 一次即 blocked 并级联冻结下游(看板红字「待裁决/需处理」
|
|
1652
|
+
* 反复出现的结构根因之一)。回喂补报(勿重做已完成工作)同样要求剩余
|
|
1653
|
+
* 预算大于一个空闲窗口;「最多两次」由函数开头 attempt 上限统一把关。
|
|
1654
|
+
*/
|
|
1655
|
+
if (code === 'EVIDENCE_MISSING') {
|
|
1656
|
+
return Number(remainingMs) > Number(idleTimeoutMs);
|
|
1657
|
+
}
|
|
1647
1658
|
return true;
|
|
1648
1659
|
}
|
|
1649
1660
|
/*
|
|
@@ -2056,6 +2067,7 @@ async function executeSubtask(ctx, record, stage, subtask, options) {
|
|
|
2056
2067
|
return;
|
|
2057
2068
|
writeSubtaskStatus(record, subtask.id, { ackOverdue: true }, guard);
|
|
2058
2069
|
}, ASSIGN_ACK_NOTICE_MS);
|
|
2070
|
+
// [2.2.9][handle-policy] 卫生类(T1 报告 R7):只丢一次「已下发未响应」提示,保留 unref。
|
|
2059
2071
|
noticeTimer.unref?.();
|
|
2060
2072
|
ackTimers.push(noticeTimer);
|
|
2061
2073
|
/*
|
|
@@ -2090,7 +2102,8 @@ async function executeSubtask(ctx, record, stage, subtask, options) {
|
|
|
2090
2102
|
child.controller.abort(new PlanError(message, 'CHILD_NO_ACK', { subtaskId: subtask.id }));
|
|
2091
2103
|
}
|
|
2092
2104
|
}, ASSIGN_ACK_DEADLINE_MS);
|
|
2093
|
-
|
|
2105
|
+
// [2.2.9][handle-policy] 收束类(T1 报告 R2):180s no-ack 判定必须真实触发;unref 时
|
|
2106
|
+
// 裸循环在判定前排空、行悬死(CI cancelled 红叉根因族)。ack 与收束路径均有 clearAckTimers 清理。
|
|
2094
2107
|
ackTimers.push(deadlineTimer);
|
|
2095
2108
|
const idleTimeoutMs = normaliseIdleTimeout(options.idleTimeoutMs);
|
|
2096
2109
|
// [2.2.0][T4/O-3b][O-4d] 双计时同源(方案 §2.5):看门狗 hardMs 与本次尝试的
|
|
@@ -2267,6 +2280,56 @@ async function executeSubtask(ctx, record, stage, subtask, options) {
|
|
|
2267
2280
|
settleFromOutput(record, subtask, output, guard, options, settleVerdict, probeInterruptedEvidence(output, subtask, options.cwd, options.artifactExists));
|
|
2268
2281
|
return;
|
|
2269
2282
|
}
|
|
2283
|
+
/*
|
|
2284
|
+
* [2.2.9] 结果块**缺失**(子会话收尾异常:error/截断/超时)= 与 unparsable
|
|
2285
|
+
* 同族的有界回喂重试,且优先采纳盘上结算备份。
|
|
2286
|
+
*
|
|
2287
|
+
* 红字复发族根因(用户 2026-11-10 截图:T1 超时/缺失结算→blocked→级联
|
|
2288
|
+
* 冻结→「已结束·需处理」):结算唯一载体是收尾消息块,单点、原子、无
|
|
2289
|
+
* 盘上备份;丢块后旧实现一次即 blocked。现在两层恢复:
|
|
2290
|
+
* ① 盘上备份优先:子会话按提示词约定在收尾前把结果块 JSON 写入
|
|
2291
|
+
* reports/wp-settlement-<subtaskId>.json(见 plan.ts 子提示词);
|
|
2292
|
+
* 消息块缺失时读该文件重裁决,合法即照常结算(来源留档);
|
|
2293
|
+
* ② 无备份且预算够一个空闲窗口 → 抛 EVIDENCE_MISSING 回喂同一子会话,
|
|
2294
|
+
* 附在盘产物清单与「只补交结果块、勿重做已完成工作」;重试耗尽才
|
|
2295
|
+
* 按实 blocked(既有 settleFromOutput 路径,严格性不变:缺失永不计 done)。
|
|
2296
|
+
*/
|
|
2297
|
+
if (settleVerdict && settleVerdict.verification === 'unverified'
|
|
2298
|
+
&& /结果块缺失/.test(String(settleVerdict.error ?? ''))) {
|
|
2299
|
+
const settleBackup = join(options.cwd ?? process.cwd(), 'reports', `wp-settlement-${subtask.id}.json`);
|
|
2300
|
+
let backupVerdict = null;
|
|
2301
|
+
let backupText = '';
|
|
2302
|
+
try {
|
|
2303
|
+
backupText = readFileSync(settleBackup, 'utf8');
|
|
2304
|
+
backupVerdict = adjudicateResult({
|
|
2305
|
+
output: backupText,
|
|
2306
|
+
strict: true,
|
|
2307
|
+
expectedAcceptance: Array.isArray(subtask?.acceptance) ? subtask.acceptance : [],
|
|
2308
|
+
});
|
|
2309
|
+
if (!backupVerdict || /结果块缺失|无法解析/.test(String(backupVerdict.error ?? '')))
|
|
2310
|
+
backupVerdict = null;
|
|
2311
|
+
}
|
|
2312
|
+
catch {
|
|
2313
|
+
backupVerdict = null;
|
|
2314
|
+
}
|
|
2315
|
+
if (backupVerdict) {
|
|
2316
|
+
settleFromOutput(record, subtask, backupText, guard, options, backupVerdict, probeInterruptedEvidence(backupText, subtask, options.cwd, options.artifactExists));
|
|
2317
|
+
record.errors = [
|
|
2318
|
+
...(record.errors ?? []),
|
|
2319
|
+
`${subtask.id}: 消息结果块缺失,已采纳盘上结算备份 ${settleBackup}([2.2.9] 恢复路径)`,
|
|
2320
|
+
].slice(-20);
|
|
2321
|
+
return;
|
|
2322
|
+
}
|
|
2323
|
+
const missingLanded = probeInterruptedArtifacts(output, subtask, options.cwd, options.artifactExists);
|
|
2324
|
+
const missingError = new PlanError('结果块缺失,本次回报不能结算(工作本身不计失败)'
|
|
2325
|
+
+ (missingLanded.length > 0
|
|
2326
|
+
? `;已核到在盘产物:${missingLanded.slice(0, 6).join('、')}`
|
|
2327
|
+
: '')
|
|
2328
|
+
+ '——请勿重做已完成的工作,只补交完整结构化结果块(WORKPLAN_EVIDENCE 标记成对、JSON 合法)后重新回报', 'EVIDENCE_MISSING', { subtaskId: subtask.id });
|
|
2329
|
+
if (shouldRetryAttempt(missingError, attempt, deadline - Date.now(), idleTimeoutMs)) {
|
|
2330
|
+
throw missingError;
|
|
2331
|
+
}
|
|
2332
|
+
}
|
|
2270
2333
|
/*
|
|
2271
2334
|
* [1.7.0] Evidence decides the verdict.
|
|
2272
2335
|
*
|
|
@@ -2513,6 +2576,105 @@ export function extendDeadline(record, subtaskId, extendMs, meta = {}) {
|
|
|
2513
2576
|
record.updatedAt = Date.now();
|
|
2514
2577
|
return { ok: true, deadlineAt, timerRearmed: true, watchdogRearmed: Boolean(handle.watchdog) };
|
|
2515
2578
|
}
|
|
2579
|
+
/*
|
|
2580
|
+
* [2.3.0][T1] 专家执行时间机制 v2.3.0(用户 2026-11-10 四项要求,全链路):
|
|
2581
|
+
* (a) 预估上报 → 告知用户:recordTimeNotice 落档后向主会话推送「请把预期用时
|
|
2582
|
+
* 转告用户」的即时通知;
|
|
2583
|
+
* (b) 超时 → 放宽 → 告知专家:延期事务成功后把最新执行时限推送给执行中的专家
|
|
2584
|
+
* 子会话,并附「必须在保证工作质量的前提下高效率执行」硬要求;
|
|
2585
|
+
* (c) 二次超时 → 主 Agent 接手:runSubtaskAttempt 的到点收束对每行计数
|
|
2586
|
+
* (timeoutCount),第二次超时置 takeoverRequired,并用 buildTakeoverBrief
|
|
2587
|
+
* 登记专家已完成产物、mergePreservedArtifacts 做「禁止丢弃已完成部分」的
|
|
2588
|
+
* 只读保护合并。
|
|
2589
|
+
* 向后兼容:全部走 StatusEntry 未知字段直写通道(与 deadlineAt/timeJournal
|
|
2590
|
+
* 同族),回放白名单同步透传;不改任何既有判定与既有字段语义。
|
|
2591
|
+
*/
|
|
2592
|
+
export const TAKEOVER_AFTER_TIMEOUTS = 2;
|
|
2593
|
+
/**
|
|
2594
|
+
* [2.3.0][T1] 组装「主 Agent 接手包」:已完成部分(专家已落盘产物 + 已登记
|
|
2595
|
+
* artifacts)逐条快照,未完成部分按 outputs 反推。instruction 是硬约束文案:
|
|
2596
|
+
* 禁止丢弃已完成部分——接手只补缺口,不整步重跑、不删除或覆盖专家产物。
|
|
2597
|
+
*/
|
|
2598
|
+
export function buildTakeoverBrief(subtask, row, landedRefs, timeoutCount) {
|
|
2599
|
+
const refs = (Array.isArray(landedRefs) ? landedRefs : [])
|
|
2600
|
+
.map((item) => String(item ?? ''))
|
|
2601
|
+
.filter(Boolean)
|
|
2602
|
+
.slice(0, 20);
|
|
2603
|
+
const completedArtifacts = (Array.isArray(row?.artifacts) ? row.artifacts : [])
|
|
2604
|
+
.filter((item) => item?.kind === 'file' && typeof item?.ref === 'string' && item.ref)
|
|
2605
|
+
.map((item) => ({ kind: 'file', ref: item.ref, exists: item.exists !== false }))
|
|
2606
|
+
.slice(0, 20);
|
|
2607
|
+
const outputs = (Array.isArray(subtask?.outputs) ? subtask.outputs : [])
|
|
2608
|
+
.map((item) => String(item ?? ''))
|
|
2609
|
+
.filter(Boolean);
|
|
2610
|
+
const remainingOutputs = outputs.filter((ref) => !refs.includes(ref));
|
|
2611
|
+
return {
|
|
2612
|
+
at: Date.now(),
|
|
2613
|
+
timeoutCount: Number(timeoutCount) || 0,
|
|
2614
|
+
landedRefs: refs,
|
|
2615
|
+
completedArtifacts,
|
|
2616
|
+
remainingOutputs,
|
|
2617
|
+
instruction: '主 Agent 只接手未完成部分:landedRefs/completedArtifacts 是专家已'
|
|
2618
|
+
+ '完成并登记保护的产物,只读、禁止丢弃、禁止删除或覆盖、禁止整步重跑;'
|
|
2619
|
+
+ '仅继续 remainingOutputs 与未满足的验收标准。',
|
|
2620
|
+
};
|
|
2621
|
+
}
|
|
2622
|
+
/**
|
|
2623
|
+
* [2.3.0][T1] 「禁止丢弃已完成部分」的只读保护合并(A4 硬编码点):
|
|
2624
|
+
* 接手登记的保护清单(takeoverBrief.landedRefs)与行上 artifacts 取并集,
|
|
2625
|
+
* 只增不减——任何后续对 artifacts 的写入都不可能丢掉已完成部分。
|
|
2626
|
+
* 纯函数,可脱离宿主回归。
|
|
2627
|
+
*/
|
|
2628
|
+
export function mergePreservedArtifacts(artifacts, preservedRefs) {
|
|
2629
|
+
const list = (Array.isArray(artifacts) ? artifacts : [])
|
|
2630
|
+
.filter((item) => item && typeof item === 'object' && typeof item.ref === 'string')
|
|
2631
|
+
.map((item) => ({ ...item }));
|
|
2632
|
+
const seen = new Set(list.map((item) => String(item.ref)));
|
|
2633
|
+
for (const rawRef of Array.isArray(preservedRefs) ? preservedRefs : []) {
|
|
2634
|
+
const ref = String(rawRef ?? '');
|
|
2635
|
+
if (!ref || seen.has(ref))
|
|
2636
|
+
continue;
|
|
2637
|
+
// 保护条目固定 kind:'file'/exists:true:登记发生在产物确认在盘的时刻。
|
|
2638
|
+
list.push({ kind: 'file', ref, exists: true, preservedByTakeover: true });
|
|
2639
|
+
seen.add(ref);
|
|
2640
|
+
}
|
|
2641
|
+
return list.slice(-40);
|
|
2642
|
+
}
|
|
2643
|
+
/**
|
|
2644
|
+
* [2.3.0][T1] 放宽成功后告知执行中的专家最新时限(A2 的「告知」半边)。
|
|
2645
|
+
* 走 ctx.subagents.sendMessage 与 follow-up 同一投递通道:运行中的子会话在下一
|
|
2646
|
+
* 步收到。投递失败不阻断延期事务(时限已经推移),只留档 record.errors。
|
|
2647
|
+
*/
|
|
2648
|
+
async function notifyExpertOfExtension(ctx, agent, record, subtaskId, deadlineAt) {
|
|
2649
|
+
const row = Array.isArray(record?.statuses)
|
|
2650
|
+
? record.statuses.find((item) => item?.subtaskId === subtaskId)
|
|
2651
|
+
: null;
|
|
2652
|
+
const childId = String(row?.childId ?? '');
|
|
2653
|
+
const service = ctx?.subagents;
|
|
2654
|
+
if (!childId) {
|
|
2655
|
+
return { ok: false, error: '该行没有活跃子会话(childId 缺失),专家续跑时可从状态行 deadlineAt 读取最新时限' };
|
|
2656
|
+
}
|
|
2657
|
+
if (!service || typeof service.sendMessage !== 'function') {
|
|
2658
|
+
return { ok: false, error: '当前部署没有可用的 subagent 服务,无法投递延期告知' };
|
|
2659
|
+
}
|
|
2660
|
+
const remainingMin = Math.max(1, Math.ceil((Number(deadlineAt) - Date.now()) / 60000));
|
|
2661
|
+
const text = `【dsh-workplan·延期告知】子任务 ${subtaskId} 的执行时限已由主 Agent 放宽:`
|
|
2662
|
+
+ `最新执行时间为 ${new Date(Number(deadlineAt)).toISOString()}(约剩 ${remainingMin} 分钟)。`
|
|
2663
|
+
+ '你必须在保证工作质量的前提下高效率执行:优先推进高价值步骤,已完成内容及时落盘,'
|
|
2664
|
+
+ '并在回报中明确区分「已完成 / 未完成」。收到本通知后请继续当前工作,不要重新开始。';
|
|
2665
|
+
try {
|
|
2666
|
+
await service.sendMessage(agent, childId, [{ type: 'text', text }], {});
|
|
2667
|
+
if (row) {
|
|
2668
|
+
const journal = Array.isArray(row.timeJournal) ? row.timeJournal : [];
|
|
2669
|
+
journal.push({ at: Date.now(), action: 'notify-expert', deadlineAt: Number(deadlineAt), by: 'system' });
|
|
2670
|
+
row.timeJournal = journal.slice(-20);
|
|
2671
|
+
}
|
|
2672
|
+
return { ok: true };
|
|
2673
|
+
}
|
|
2674
|
+
catch (error) {
|
|
2675
|
+
return { ok: false, error: truncate(error instanceof Error ? error.message : String(error), 300) };
|
|
2676
|
+
}
|
|
2677
|
+
}
|
|
2516
2678
|
/*
|
|
2517
2679
|
* One attempt under a deadline that belongs to that attempt alone.
|
|
2518
2680
|
*
|
|
@@ -2584,7 +2746,15 @@ async function runSubtaskAttempt(ctx, record, stage, subtask, options, timeoutMs
|
|
|
2584
2746
|
// 续跑、人工裁决)。Reached only when the child ignored both its idle window
|
|
2585
2747
|
// and its abort signal; the message says so, otherwise the cause looks like
|
|
2586
2748
|
// a plain "too slow" and the next investigation goes down the wrong path.
|
|
2587
|
-
|
|
2749
|
+
// [2.3.0][T1] 计数在组装文案前预读:第 1 次超时的文案要求「必须放宽并
|
|
2750
|
+
// 告知专家」;第 2 次及以后的文案要求「主 Agent 接手、已完成部分只读
|
|
2751
|
+
// 保护、禁止丢弃」。错误文本是结果消息/看板/续跑判定的共同来源,所以
|
|
2752
|
+
// 接手语义必须在这里就落进 message,而不是只进即时通知。
|
|
2753
|
+
const preRow = record.statuses.find((item) => item?.subtaskId === subtask.id);
|
|
2754
|
+
const timeoutCountAtFire = Number(preRow?.timeoutCount ?? 0) + 1;
|
|
2755
|
+
const message = timeoutCountAtFire >= TAKEOVER_AFTER_TIMEOUTS
|
|
2756
|
+
? `子任务 ${subtask.id} 第 ${timeoutCountAtFire} 次达到协商执行上限(${timeoutMs}ms),已按安全兜底结算(待裁决:takeoverRequired——预估时间已两次超时,请主 Agent 直接接手完成尚未完成的部分;专家已完成并落盘的部分已登记只读保护,禁止丢弃、禁止整步重跑)`
|
|
2757
|
+
: `子任务 ${subtask.id} 第 ${timeoutCountAtFire} 次达到协商执行上限(${timeoutMs}ms),已按安全兜底结算(待裁决:请主 Agent 立即放宽(extendMs,放宽后插件自动告知专家最新时限与保证质量高效率要求)/ 重试 / 接受,或转新轮续跑、人工裁决)`;
|
|
2588
2758
|
try {
|
|
2589
2759
|
// [1.8.19] Keep the evidence of what already landed on disk.
|
|
2590
2760
|
const { patch, landed } = timeoutBlockedPatch(subtask, options.cwd, message, options.artifactExists);
|
|
@@ -2617,6 +2787,41 @@ async function runSubtaskAttempt(ctx, record, stage, subtask, options, timeoutMs
|
|
|
2617
2787
|
const settleRow = record.statuses.find((item) => item?.subtaskId === subtask.id);
|
|
2618
2788
|
if (settleRow)
|
|
2619
2789
|
settleRow.pendingAdjudication = true;
|
|
2790
|
+
/*
|
|
2791
|
+
* [2.3.0][T1] 超时计数与二次超时接手(用户要求 1/2 的机读落点):
|
|
2792
|
+
* 每次到点收束给状态行 timeoutCount +1 并记入 timeJournal(action:'timeout')。
|
|
2793
|
+
* 第 1 次超时 → 即时通知主 Agent「必须放宽(extendMs)并告知专家最新时限」,
|
|
2794
|
+
* 告知专家由延期事务自动投递(notifyExpertOfExtension);
|
|
2795
|
+
* 第 2 次超时 → takeoverRequired=true + buildTakeoverBrief 登记已完成部分,
|
|
2796
|
+
* mergePreservedArtifacts 把已落盘产物并入行 artifacts(只读保护、只增不减),
|
|
2797
|
+
* 主 Agent 接手只继续 remainingOutputs 与未满足验收,禁止丢弃已完成部分。
|
|
2798
|
+
* 计数走 StatusEntry 未知字段直写通道,回放白名单同步透传。
|
|
2799
|
+
*/
|
|
2800
|
+
if (settleRow) {
|
|
2801
|
+
const timeoutCount = timeoutCountAtFire;
|
|
2802
|
+
settleRow.timeoutCount = timeoutCount;
|
|
2803
|
+
const timeoutJournal = Array.isArray(settleRow.timeJournal) ? settleRow.timeJournal : [];
|
|
2804
|
+
timeoutJournal.push({ at: Date.now(), action: 'timeout', timeoutCount, by: 'system' });
|
|
2805
|
+
settleRow.timeJournal = timeoutJournal.slice(-20);
|
|
2806
|
+
if (timeoutCount >= TAKEOVER_AFTER_TIMEOUTS) {
|
|
2807
|
+
// 禁止丢弃已完成部分:接手包 + artifacts 只增不减的并集合并。
|
|
2808
|
+
settleRow.takeoverRequired = true;
|
|
2809
|
+
settleRow.takeoverBrief = buildTakeoverBrief(subtask, settleRow, ceilingLanded, timeoutCount);
|
|
2810
|
+
settleRow.artifacts = mergePreservedArtifacts(settleRow.artifacts, settleRow.takeoverBrief.landedRefs);
|
|
2811
|
+
}
|
|
2812
|
+
try {
|
|
2813
|
+
const takeoverText = timeoutCount >= TAKEOVER_AFTER_TIMEOUTS
|
|
2814
|
+
? `子任务 ${subtask.id} 已第 ${timeoutCount} 次达到协商时限(二次超时):按 2.3.0 机制本行已置「主 Agent 接手」(takeoverRequired)。`
|
|
2815
|
+
+ `专家已完成并登记保护的部分(只读、禁止丢弃):${ceilingLanded.slice(0, 8).join('、') || '(见 takeoverBrief)'};`
|
|
2816
|
+
+ '请主 Agent 直接接手继续未完成部分,不要整步重跑、不要删除或覆盖已登记产物。'
|
|
2817
|
+
: `子任务 ${subtask.id} 第 1 次达到协商时限:按 2.3.0 机制请主 Agent 尽快用 dsh_workplan_update(extendMs) 放宽,`
|
|
2818
|
+
+ '延期成功后插件会自动把最新时限与「保证质量、高效率执行」要求告知专家;如判断无需再放宽,请接手继续未完成部分(已完成产物将只读保护)。';
|
|
2819
|
+
announceSubtaskInterrupt(record, options.session ?? options.agent?.session, subtask.id, takeoverText);
|
|
2820
|
+
}
|
|
2821
|
+
catch {
|
|
2822
|
+
// 通知失败不影响结算(与预警同一纪律)。
|
|
2823
|
+
}
|
|
2824
|
+
}
|
|
2620
2825
|
record.updatedAt = Date.now();
|
|
2621
2826
|
}
|
|
2622
2827
|
catch (error) {
|
|
@@ -2857,6 +3062,23 @@ export function modelStatusLines(statuses) {
|
|
|
2857
3062
|
timeWarning: item.timeWarning ?? null,
|
|
2858
3063
|
timeJournal: Array.isArray(item.timeJournal) ? item.timeJournal.slice(-10) : [],
|
|
2859
3064
|
pendingAdjudication: item.pendingAdjudication === true,
|
|
3065
|
+
// [2.3.0][T1] 预估上报(A1)也要进模型可读面:主 Agent 告知用户前先读这里。
|
|
3066
|
+
timeNotice: item.timeNotice ?? null,
|
|
3067
|
+
/*
|
|
3068
|
+
* [2.3.0][T1] 超时计数 / 二次超时接手进入模型可读面:主 Agent 一眼能看出
|
|
3069
|
+
* 该行第几次超时、是否必须接手、接手包里哪些是只读保护的已完成产物。
|
|
3070
|
+
*/
|
|
3071
|
+
timeoutCount: Number(item.timeoutCount ?? 0),
|
|
3072
|
+
takeoverRequired: item.takeoverRequired === true,
|
|
3073
|
+
takeoverBrief: item.takeoverBrief ?? null,
|
|
3074
|
+
/*
|
|
3075
|
+
* [2.3.0][T1] 已完成产物的只读保护登记必须进模型可读面:statusTool 的行
|
|
3076
|
+
* 来自本函数,此前不序列化 artifacts,导致 takeoverRequired 的「禁止丢弃
|
|
3077
|
+
* 已完成部分」清单对主 Agent 不可见。只透出对象形条目,照录不改写。
|
|
3078
|
+
*/
|
|
3079
|
+
artifacts: (Array.isArray(item.artifacts) ? item.artifacts : [])
|
|
3080
|
+
.filter((entry) => entry && typeof entry === 'object' && typeof entry.ref === 'string')
|
|
3081
|
+
.map((entry) => ({ ...entry })),
|
|
2860
3082
|
/*
|
|
2861
3083
|
* [2.2.0][T3/O-2a] 子→主预告通道的结论必须进入模型可读面。
|
|
2862
3084
|
*
|
|
@@ -3037,7 +3259,9 @@ export async function dispatchPlan(ctx, record, options) {
|
|
|
3037
3259
|
// [2.2.5][热修] 双重保险:即使哨兵值/配置未来被改成超限值,也把延时钳在
|
|
3038
3260
|
// Node setTimeout 上限之内,杜绝“1ms 触发”的整轮秒杀。
|
|
3039
3261
|
}, Math.min(Math.max(1000, deadline - Date.now()), ROUND_TIMER_MAX_MS));
|
|
3040
|
-
|
|
3262
|
+
// [2.2.9][handle-policy] 收束类(T1 报告 R1,P0):轮次总预算计时器必须真实触发(与 2.2.8
|
|
3263
|
+
// 已修的 attempt 上限计时器同构);unref 时裸循环在 TOTAL_TIMEOUT 前排空 → node:test 判
|
|
3264
|
+
// cancelledByParent → CI 红叉。收束路径 finally 有 clearTimeout(totalTimer),不会悬挂宿主。
|
|
3041
3265
|
record.dispatchedAt = Date.now();
|
|
3042
3266
|
record.phase = 'executing';
|
|
3043
3267
|
record.updatedAt = record.dispatchedAt;
|
|
@@ -3789,7 +4013,7 @@ export function reconstructFromSession(session, targetPlanId) {
|
|
|
3789
4013
|
const rebuiltRow = snap.statuses.find((item) => item?.subtaskId === entry?.subtaskId);
|
|
3790
4014
|
if (!rebuiltRow || !isRecord(entry))
|
|
3791
4015
|
continue;
|
|
3792
|
-
for (const field of ['deadlineAt', 'timeNotice', 'timeWarning', 'timeJournal', 'pendingAdjudication']) {
|
|
4016
|
+
for (const field of ['deadlineAt', 'timeNotice', 'timeWarning', 'timeJournal', 'pendingAdjudication', 'timeoutCount', 'takeoverRequired', 'takeoverBrief']) {
|
|
3793
4017
|
if (entry[field] !== undefined)
|
|
3794
4018
|
rebuiltRow[field] = entry[field];
|
|
3795
4019
|
}
|
|
@@ -3959,7 +4183,7 @@ export function reconstructFromSession(session, targetPlanId) {
|
|
|
3959
4183
|
*/
|
|
3960
4184
|
const replayRow = snap.statuses.find((item) => item?.subtaskId === update.subtaskId);
|
|
3961
4185
|
if (replayRow) {
|
|
3962
|
-
for (const field of ['deadlineAt', 'timeNotice', 'timeWarning', 'timeJournal', 'pendingAdjudication']) {
|
|
4186
|
+
for (const field of ['deadlineAt', 'timeNotice', 'timeWarning', 'timeJournal', 'pendingAdjudication', 'timeoutCount', 'takeoverRequired', 'takeoverBrief']) {
|
|
3963
4187
|
if (update[field] !== undefined)
|
|
3964
4188
|
replayRow[field] = update[field];
|
|
3965
4189
|
}
|
|
@@ -4563,7 +4787,7 @@ export function createWorkplanRuntime(ctx, options = {}) {
|
|
|
4563
4787
|
* 路由分支,按 T4 直写通道写行(StatusEntry 保留未知字段;回放白名单已透传
|
|
4564
4788
|
* timeNotice,刷新后不丢)。
|
|
4565
4789
|
*/
|
|
4566
|
-
function recordTimeNotice(record, subtaskId, notice) {
|
|
4790
|
+
function recordTimeNotice(record, subtaskId, notice, session) {
|
|
4567
4791
|
const row = Array.isArray(record?.statuses)
|
|
4568
4792
|
? record.statuses.find((item) => item?.subtaskId === subtaskId)
|
|
4569
4793
|
: null;
|
|
@@ -4587,6 +4811,24 @@ export function createWorkplanRuntime(ctx, options = {}) {
|
|
|
4587
4811
|
});
|
|
4588
4812
|
row.timeJournal = journal.slice(-20);
|
|
4589
4813
|
record.updatedAt = at;
|
|
4814
|
+
/*
|
|
4815
|
+
* [2.3.0][T1] 预估上报 → 告知用户(用户要求 1 的前半段闭环):专家的开工
|
|
4816
|
+
* 预告落档后,插件立即向主会话推送一条即时通知,明确「请把此预期执行
|
|
4817
|
+
* 时间告知用户」;新预告覆盖旧预告(每条新预告各通知一次,与「开工预告」
|
|
4818
|
+
* 协议一致)。通知是观测设施:写失败只留档 errors,绝不影响记录与执行。
|
|
4819
|
+
*/
|
|
4820
|
+
if (session) {
|
|
4821
|
+
try {
|
|
4822
|
+
appendUserMessage(session, `【dsh-workplan·专家预估上报】子任务 ${subtaskId} 的执行专家`
|
|
4823
|
+
+ `预估执行时间 ${Number(notice?.declaredMinutes)} 分钟`
|
|
4824
|
+
+ (reason ? `(${reason})` : '')
|
|
4825
|
+
+ `;请把此预期执行时间告知用户。若执行中超时,请主 Agent 放宽(extendMs)`
|
|
4826
|
+
+ '并告知专家最新时限,连续两次超时则由主 Agent 接手未完成部分(已完成产物只读保护,禁止丢弃)。');
|
|
4827
|
+
}
|
|
4828
|
+
catch (error) {
|
|
4829
|
+
record.errors = [...(record.errors ?? []), `${subtaskId} 预估上报通知写入失败:${truncate(String(error?.message ?? error), 200)}`].slice(-20);
|
|
4830
|
+
}
|
|
4831
|
+
}
|
|
4590
4832
|
}
|
|
4591
4833
|
async function updateStatus(agent, args) {
|
|
4592
4834
|
const session = agent?.session;
|
|
@@ -4764,7 +5006,7 @@ export function createWorkplanRuntime(ctx, options = {}) {
|
|
|
4764
5006
|
* 指示失败不该留下一笔「专家已预告」的记录。
|
|
4765
5007
|
*/
|
|
4766
5008
|
if (hasTimeNotice && instructed?.ok !== false)
|
|
4767
|
-
recordTimeNotice(record, subtaskId, timeNoticeArg);
|
|
5009
|
+
recordTimeNotice(record, subtaskId, timeNoticeArg, session);
|
|
4768
5010
|
return instructed;
|
|
4769
5011
|
}
|
|
4770
5012
|
if (current?.closure === 'escalated') {
|
|
@@ -4831,10 +5073,18 @@ export function createWorkplanRuntime(ctx, options = {}) {
|
|
|
4831
5073
|
};
|
|
4832
5074
|
}
|
|
4833
5075
|
extension = extended;
|
|
5076
|
+
/*
|
|
5077
|
+
* [2.3.0][T1] 用户要求 1 后半段:放宽成功后必须把「最新执行时间」告知
|
|
5078
|
+
* 专家,同时附「必须在保证工作质量的前提下高效率执行」硬要求,让专家
|
|
5079
|
+
* 有准备(收到通知继续当前工作,不重新开始)。投递失败不回滚延期——
|
|
5080
|
+
* 时限已经推移,只是告知通道未达:留档 errors,回执带 childNotified
|
|
5081
|
+
* 供主 Agent 决定是否用 dsh_workplan_followup 补发。
|
|
5082
|
+
*/
|
|
5083
|
+
extension.childNotified = (await notifyExpertOfExtension(ctx, agent, record, subtaskId, extension.deadlineAt)).ok;
|
|
4834
5084
|
}
|
|
4835
5085
|
if (!statusRequested) {
|
|
4836
5086
|
if (hasTimeNotice)
|
|
4837
|
-
recordTimeNotice(record, subtaskId, timeNoticeArg);
|
|
5087
|
+
recordTimeNotice(record, subtaskId, timeNoticeArg, session);
|
|
4838
5088
|
/*
|
|
4839
5089
|
* 纯时限事务到此结束。方案 §2.2 效果 3:状态行 revision +1(延期/预告也是
|
|
4840
5090
|
* 行变更,同样受 STALE_WRITE 乐观锁保护);状态与判定一个字段都不改。
|
|
@@ -4860,6 +5110,7 @@ export function createWorkplanRuntime(ctx, options = {}) {
|
|
|
4860
5110
|
deadlineAt: extension.deadlineAt,
|
|
4861
5111
|
timerRearmed: extension.timerRearmed,
|
|
4862
5112
|
watchdogRearmed: extension.watchdogRearmed,
|
|
5113
|
+
childNotified: extension.childNotified === true,
|
|
4863
5114
|
}
|
|
4864
5115
|
: {}),
|
|
4865
5116
|
...(hasTimeNotice ? { timeNotice: written?.timeNotice ?? null } : {}),
|
|
@@ -4907,12 +5158,25 @@ export function createWorkplanRuntime(ctx, options = {}) {
|
|
|
4907
5158
|
revision,
|
|
4908
5159
|
updatedBy: 'agent',
|
|
4909
5160
|
});
|
|
5161
|
+
/*
|
|
5162
|
+
* [2.3.0][T1] 禁止丢弃已完成部分(A4 的第二个硬编码保护点):接手行
|
|
5163
|
+
* (takeoverRequired)后续任何一次 artifacts 写入,都把 takeoverBrief 登记
|
|
5164
|
+
* 的保护产物并集合并回来——只增不减,主 Agent 改判时不可能删掉专家已完成
|
|
5165
|
+
* 的产物清单,只能在其基础上补缺口。
|
|
5166
|
+
*/
|
|
5167
|
+
if (args?.artifacts !== undefined) {
|
|
5168
|
+
const protectedRow = record.statuses.find((item) => item?.subtaskId === subtaskId);
|
|
5169
|
+
if (protectedRow?.takeoverRequired === true && Array.isArray(protectedRow?.takeoverBrief?.landedRefs)
|
|
5170
|
+
&& protectedRow.takeoverBrief.landedRefs.length > 0) {
|
|
5171
|
+
protectedRow.artifacts = mergePreservedArtifacts(protectedRow.artifacts, protectedRow.takeoverBrief.landedRefs);
|
|
5172
|
+
}
|
|
5173
|
+
}
|
|
4910
5174
|
/*
|
|
4911
5175
|
* [2.2.0][T5/O-4c] 带 status 的调用同时带 timeNotice 时,预告记录在改判落行
|
|
4912
5176
|
* 之后写入:applyStatus 抛错(如非法 verification)时不会留下半写的预告。
|
|
4913
5177
|
*/
|
|
4914
5178
|
if (hasTimeNotice)
|
|
4915
|
-
recordTimeNotice(record, subtaskId, timeNoticeArg);
|
|
5179
|
+
recordTimeNotice(record, subtaskId, timeNoticeArg, session);
|
|
4916
5180
|
if (status === 'blocked') {
|
|
4917
5181
|
record.statuses = markDependentsBlocked(record.plan, record.statuses, subtaskId, { reason: summary || '主 Agent 标记受阻' });
|
|
4918
5182
|
}
|
|
@@ -5525,7 +5789,9 @@ export function createWorkplanRuntime(ctx, options = {}) {
|
|
|
5525
5789
|
ctx.logger?.warn?.(`dsh-workplan: 自动续跑失败:${error instanceof Error ? error.message : String(error)}`);
|
|
5526
5790
|
}
|
|
5527
5791
|
}, decision.delayMs);
|
|
5528
|
-
|
|
5792
|
+
// [2.2.9][handle-policy] 收束类(T1 报告 R3):自动续跑计时器是计划走向下一轮的唯一驱动,
|
|
5793
|
+
// unref 时裸循环下续跑永不发生、计划静默停摆。clearAutoResumeTimer 在人工派发/状态写入/
|
|
5794
|
+
// 取消/指示/dispose/rearm 各路径统一撤销;延时自身有界,不会悬挂宿主。
|
|
5529
5795
|
book.timer = timer;
|
|
5530
5796
|
return decision;
|
|
5531
5797
|
}
|
|
@@ -6155,6 +6421,7 @@ export function createWorkplanRuntime(ctx, options = {}) {
|
|
|
6155
6421
|
}
|
|
6156
6422
|
stop();
|
|
6157
6423
|
}, INSTRUCTION_POLL_MS);
|
|
6424
|
+
// [2.2.9][handle-policy] 卫生类(T1 报告 R8):回执轮询只提供提前确认,deadline 判定兜底,保留 unref。
|
|
6158
6425
|
poll.unref?.();
|
|
6159
6426
|
timers.push(poll);
|
|
6160
6427
|
const notice = setTimeout(() => {
|
|
@@ -6167,6 +6434,7 @@ export function createWorkplanRuntime(ctx, options = {}) {
|
|
|
6167
6434
|
// The row moved on between the read and the write; nothing to report.
|
|
6168
6435
|
}
|
|
6169
6436
|
}, INSTRUCTION_ACK_NOTICE_MS);
|
|
6437
|
+
// [2.2.9][handle-policy] 卫生类(T1 报告 R9):只丢一次「指示未回执」提示,保留 unref。
|
|
6170
6438
|
notice.unref?.();
|
|
6171
6439
|
timers.push(notice);
|
|
6172
6440
|
const deadline = setTimeout(() => {
|
|
@@ -6194,7 +6462,8 @@ export function createWorkplanRuntime(ctx, options = {}) {
|
|
|
6194
6462
|
}
|
|
6195
6463
|
stop();
|
|
6196
6464
|
}, INSTRUCTION_ACK_DEADLINE_MS);
|
|
6197
|
-
|
|
6465
|
+
// [2.2.9][handle-policy] 收束类(T1 报告 R5):指示 no-ack 判定必须真实触发;触发/回执即 stop()
|
|
6466
|
+
// 清掉整组计时器,延时有界(INSTRUCTION_ACK_DEADLINE_MS),不会悬挂宿主。
|
|
6198
6467
|
timers.push(deadline);
|
|
6199
6468
|
}
|
|
6200
6469
|
/**
|
package/lib/watchdog.js
CHANGED
|
@@ -211,7 +211,8 @@ export function createProgressWatchdog(input) {
|
|
|
211
211
|
finish(reason);
|
|
212
212
|
};
|
|
213
213
|
timer = setInterval(poll, pollMs);
|
|
214
|
-
|
|
214
|
+
// [2.2.9][handle-policy] 收束类(T1 报告 R4):看门狗是卡死子任务的最后收束保证,unref 时
|
|
215
|
+
// 裸循环下看门狗失效。finish()/stop() 均 clearInterval,生命周期与子任务尝试绑定,不会悬挂宿主。
|
|
215
216
|
return {
|
|
216
217
|
fired,
|
|
217
218
|
stop() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-workplan",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
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",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"clean": "rm -rf dist dist-tests",
|
|
69
69
|
"build": "rm -rf dist && tsc -p tsconfig.json && cp dist/*.js lib/ && cp dist/client.js client.js",
|
|
70
70
|
"check": "tsc -p tsconfig.json --noEmit",
|
|
71
|
-
"test": "npm run build && rm -rf dist-tests && tsc -p tsconfig.test.json && node
|
|
71
|
+
"test": "npm run build && rm -rf dist-tests && tsc -p tsconfig.test.json && node scripts/run-tests.mjs",
|
|
72
72
|
"verify": "npm run check && npm test",
|
|
73
73
|
"preview": "node scripts/render-preview.ts --emit"
|
|
74
74
|
},
|
package/src/host.ts
CHANGED
|
@@ -118,6 +118,12 @@ const PROMPT_SECTION = [
|
|
|
118
118
|
* (上方 1.8.7/1.8.13 注释)全部保留,不删。
|
|
119
119
|
*/
|
|
120
120
|
'7. 子任务的时间是「协商上限」+「安全兜底」,不是固定交付期限:规模参考 15 分钟量级(仅供参考、非承诺,实际时长由执行专家开工预告协商决定),整轮预算(默认 20 分钟)同样只是安全兜底,不是交付期限。子 Agent 接近上限时应先把已完成内容落盘并在结论里列出路径。任何「达到协商上限」「本轮预算用尽」都不等于「什么都没做」:状态里的 error 会列出「声明产物已在盘上」,必须先用文件核对;若产物已覆盖验收标准,用 dsh_workplan_update 复核改判,只补缺失部分再续跑,禁止无视盘上产物把整步重跑。确认需要更多时间时,主 Agent 可用 dsh_workplan_update 的 extendMs 协商放宽(放宽永远有界:累计超过初始协商上限的一倍即拒绝,转新轮续跑或转 escalate 请主 Agent/用户裁决)。',
|
|
121
|
+
/*
|
|
122
|
+
* [2.3.0][T1] 专家执行时间机制三条款(用户 2026-11-10 要求 1/2 的主 Agent 侧义务):
|
|
123
|
+
* 预估上报后必须转告用户;第 1 次超时必须放宽并告知专家(插件自动投递最新时限
|
|
124
|
+
* 与质量效率要求);第 2 次超时由主 Agent 接手,已完成部分只读保护、禁止丢弃。
|
|
125
|
+
*/
|
|
126
|
+
'7a. [2.3.0] 专家时间机制:专家开工预告(timeNotice/【专家预估上报】通知)到达后,必须把该预估执行时间告知用户;专家第一次超时(【执行中断】通知与状态行 timeoutCount=1)时,必须用 extendMs 放宽——延期成功后插件自动把最新执行时限与「必须在保证工作质量的前提下高效率执行」告知专家,回执 childNotified=false 时用 dsh_workplan_followup 补发;同一子任务第二次超时(timeoutCount≥2,takeoverRequired=true)后不再重派专家,由主 Agent 直接接手:只继续 takeoverBrief.remainingOutputs 与未满足的验收,专家已完成产物已登记为只读保护(landedRefs 并入 artifacts,只增不减),禁止丢弃、禁止删除或覆盖、禁止整步重跑。',
|
|
121
127
|
'8. 出现「待指示」项(closure=escalated,左侧栏显示「待指示」并附问题摘录)时,必须在当轮处理:用 dsh_workplan_instruct 下发决定(投递到子会话并把该行恢复为执行中),或确认放弃后用 dsh_workplan_update 置 blocked。不要沉默略过,也不要把待指示当成普通失败——它是一条还没被回答的请示,会一直占着交付门禁。',
|
|
122
128
|
'9. 出现「已下发未响应」(ackOverdue)时,不要重复派发:先用 dsh_workplan_status 看该行 childId 与已等待时长,必要时用 dsh_workplan_followup 投递一次说明;超过硬超时仍未响应会记为 blocked(blockedKind=no-ack),可以再下发指示复活。',
|
|
123
129
|
/*
|
|
@@ -233,6 +239,8 @@ function createUpdateTool(runtime: any) {
|
|
|
233
239
|
+ '把子任务标成 done 时,必须同时给出真实的 verification 与 acceptance(每项 result="pass"),'
|
|
234
240
|
+ '否则计划不会变成可交付状态(deliveryReady=false,present 会被拒绝)。'
|
|
235
241
|
+ '运行中的子任务需要更多时间时,传 extendMs(毫秒)即可协商放宽,不需要 force;放宽永远有界(累计 ≤ 初始协商上限 × 1),超出转新轮续跑或转 escalate 请主 Agent 裁决。'
|
|
242
|
+
+ '[2.3.0] 延期成功后插件自动向执行中的专家投递最新执行时限与「保证质量、高效率执行」要求(回执 childNotified);'
|
|
243
|
+
+ '同一子任务第二次超时自动置 takeoverRequired,由主 Agent 接手未完成部分,已完成产物只读保护、禁止丢弃。'
|
|
236
244
|
+ '这些字段会写入会话日志,刷新/重启后仍然生效。',
|
|
237
245
|
parameters: {
|
|
238
246
|
type: 'object',
|
|
@@ -333,7 +341,8 @@ function createUpdateTool(runtime: any) {
|
|
|
333
341
|
type: 'integer',
|
|
334
342
|
description: '延期毫秒数(正整数,仅主 Agent 可用):只推移本子任务的协商截止并重置计时,'
|
|
335
343
|
+ '不改状态判定;运行中可用,不需要 force。除非另传 status,否则可省略 status。'
|
|
336
|
-
+ '放宽永远有界:累计延期 ≤ 初始协商上限的一倍,超出会被拒绝并提示转新轮续跑或转 escalate 请主 Agent 裁决。'
|
|
344
|
+
+ '放宽永远有界:累计延期 ≤ 初始协商上限的一倍,超出会被拒绝并提示转新轮续跑或转 escalate 请主 Agent 裁决。'
|
|
345
|
+
+ '[2.3.0] 延期成功后插件自动告知专家最新执行时限(含保证质量、高效率执行要求);每次超时计一行内 timeoutCount,第二次触发 takeoverRequired(主 Agent 接手,已完成部分只读保护)。',
|
|
337
346
|
},
|
|
338
347
|
/*
|
|
339
348
|
* [2.2.0][T5/O-4c] O-2a 专家开工预告:{declaredMinutes, reason}。与 extendMs
|
|
@@ -341,7 +350,8 @@ function createUpdateTool(runtime: any) {
|
|
|
341
350
|
*/
|
|
342
351
|
timeNotice: {
|
|
343
352
|
type: 'object',
|
|
344
|
-
description: '专家开工预告(O-2a):{ declaredMinutes, reason },只记入协商流水,不改状态与判定。'
|
|
353
|
+
description: '专家开工预告(O-2a):{ declaredMinutes, reason },只记入协商流水,不改状态与判定。'
|
|
354
|
+
+ '[2.3.0] 落档后插件立即向主会话推送【专家预估上报】通知,提醒主 Agent 把该预期执行时间告知用户。',
|
|
345
355
|
properties: {
|
|
346
356
|
declaredMinutes: { type: 'number', description: '预计完成本子任务的分钟数(仅供参考、非承诺)。' },
|
|
347
357
|
reason: { type: 'string', description: '预告理由(可选)。' },
|
|
@@ -1571,7 +1581,7 @@ export function apply(ctx: any, config: WorkplanConfig = {}) {
|
|
|
1571
1581
|
|
|
1572
1582
|
export const meta = {
|
|
1573
1583
|
name,
|
|
1574
|
-
version: '2.
|
|
1584
|
+
version: '2.3.0',
|
|
1575
1585
|
promptOrder: PROMPT_ORDER,
|
|
1576
1586
|
routes: ['/dsh-workplan/plans', '/dsh-workplan/vendor/chart.umd.js'],
|
|
1577
1587
|
}
|
package/src/plan.ts
CHANGED
|
@@ -4678,6 +4678,16 @@ export function resetBlockedStatuses(statuses: any) {
|
|
|
4678
4678
|
* (给出指示改判 instructed,或明确放弃改判 blocked)后才离开这个状态。
|
|
4679
4679
|
*/
|
|
4680
4680
|
if (item?.closure === 'escalated' || item?.closure === 'instructed') continue
|
|
4681
|
+
/*
|
|
4682
|
+
* [2.3.0][T1] 二次超时 = 主 Agent 接手,不再把专家重派一遍。
|
|
4683
|
+
*
|
|
4684
|
+
* 用户要求 2:预估时间超时两次后由主 Agent 接手尚未完成的事,且禁止丢弃
|
|
4685
|
+
* 专家已完成部分。若续跑把这行重置为 pending 重派,等于让新专家从零重做、
|
|
4686
|
+
* 绕开 takeoverBrief 的只读保护——这里直接跳过:行保持 blocked,
|
|
4687
|
+
* takeoverRequired/takeoverBrief/artifacts 保护登记原样保留,由主 Agent
|
|
4688
|
+
* 用 dsh_workplan_update 复核改判(只补缺口)或人工裁决后离开该状态。
|
|
4689
|
+
*/
|
|
4690
|
+
if (item?.takeoverRequired === true) continue
|
|
4681
4691
|
next = applyStatus(next, item.subtaskId, {
|
|
4682
4692
|
status: 'pending',
|
|
4683
4693
|
progress: 0,
|
|
@@ -4991,6 +5001,16 @@ export function buildChildPrompt({
|
|
|
4991
5001
|
: []),
|
|
4992
5002
|
// [T3 扩展点·T6] 供 T6 在此行之后追加「完成即时通知」条款(O-1a 插件兜底通道语义);上方三条款为 O-1a①+O-2a+O-4a 合并协议段(矩阵 Z1),既有条款不得删改。
|
|
4993
5003
|
// [2.2.0][T6/O-1a] 完成即时通知条款(插件兜底通道):完成即报是第一通道(见上方「完成即回报」);插件另设兜底——子任务结算成功后立即向主会话推送一条含子任务 ID、摘要、验收计数与用时的即时通知,不等待整轮结束。兜底不替代主动回报。
|
|
5004
|
+
/*
|
|
5005
|
+
* [2.3.0][T1] 超时放宽告知与二次超时接手条款(用户 2026-11-10 要求 1/2):
|
|
5006
|
+
* 预告会由插件自动转告主 Agent「请把预期时间告知用户」;超时后主 Agent
|
|
5007
|
+
* 放宽时插件会把最新执行时限推送给你;连续两次超时改由主 Agent 接手,
|
|
5008
|
+
* 因此专家任何时候都要把已完成内容及时落盘并在回报中列路径——已完成部分
|
|
5009
|
+
* 会被登记为只读保护,禁止被丢弃。以下既有条款零删改。
|
|
5010
|
+
*/
|
|
5011
|
+
'- 预估上报会被插件即时转告主 Agent(含「请把此预期执行时间告知用户」提示),主 Agent 会把你报的预估时间告知用户,让双方都有准备。',
|
|
5012
|
+
'- 超时后主 Agent 放宽时,插件会向你的会话推送【延期告知】:内含最新执行时间与剩余余量,并要求你在保证工作质量的前提下高效率执行——收到通知继续当前工作,不要重新开始;已完成内容及时落盘。',
|
|
5013
|
+
'- 连续两次超时后本行转为「主 Agent 接手」(takeoverRequired):你已完成的产物会被登记为只读保护(禁止丢弃),主 Agent 只继续未完成部分;所以每个阶段都要及时落盘并在回报中列出已完成路径。',
|
|
4994
5014
|
'',
|
|
4995
5015
|
'遇阻上报(强制,先于继续动作):',
|
|
4996
5016
|
'- 出现以下任一情况,第一动作是上报,不是猜测、绕过或静默继续:缺少权限/输入/依赖产物;需求自相矛盾;无法验证;同一命令连续两次失败;需要主 Agent 决定方向。',
|
|
@@ -5003,6 +5023,7 @@ export function buildChildPrompt({
|
|
|
5003
5023
|
EVIDENCE_MARKER_BEGIN,
|
|
5004
5024
|
'{"status":"done","blockedReason":"","phases":{"planning":{"problemAnalysis":["要解决的问题 1(含现状/约束/未知/主要矛盾)"],"constraints":["..."],"unknowns":["..."],"approach":["第 1 步:做什么 → 产出什么 → 如何证明"]},"execution":{"steps":["实际执行的步骤"],"deviations":[]},"verification":{"allPassed":true,"checks":[{"criterion":"A1","method":"怎么验证","evidence":"命令输出/文件/引用"}],"requirementCheck":"逐条核对用户原要求的结果","retrospective":{"problems":["本次遇到的问题(现象+根因)"],"detours":["走过的弯路/返工/无效尝试;确实没有就写 []"],"resolutions":["最终是如何解决的"],"prevention":["以后如何预防再犯:遇到…先…"]}}},"acceptance":[{"criterion":"A1 把上面的验收标准原文抄在这里","result":"pass","evidence":"用命令输出、文件路径或引用证明"}],"artifacts":[{"kind":"file","ref":"相对工作目录的路径"}],"needs":[],"question":"","options":[],"timeSpentMinutes":0,"finalEstimateMinutes":0}',
|
|
5005
5025
|
EVIDENCE_MARKER_END,
|
|
5026
|
+
'- [2.2.9] 盘上结算备份(必做):发送结果块之前,先把同一份 JSON 写入 reports/wp-settlement-<你的子任务 ID>.json(相对工作目录)。收尾消息因异常(error/截断/超时)丢失时,宿主会自动采纳该备份结算,避免「已完成的工作」被误判为「缺失回报」而受阻并级联冻结下游。',
|
|
5006
5027
|
'- status 只能是 done / blocked / partial;partial 会被当作受阻处理。',
|
|
5007
5028
|
'- acceptance 必须逐条覆盖上面的验收标准:criterion 以 A1、A2… 开头对号入座(编号不可省略);result 只能是 pass / fail / unverified。无法确认就写 unverified,不要写 pass。',
|
|
5008
5029
|
'- artifacts 写你实际产出或修改的文件(kind=file,ref 用相对路径)、链接(kind=url)或说明(kind=note)。',
|