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.
- package/CHANGELOG.md +380 -1
- package/README.en.md +5 -2
- package/README.md +5 -2
- package/README.zh.md +5 -2
- package/client.js +143 -3
- package/docs/dsh-workplan_T4_runtime.patch +508 -0
- package/docs/release-records/_release_notes_2.1.2_20261106.md +44 -0
- package/docs/release-records/_t2_version_determination_20261106.md +39 -0
- package/docs/release-records/_t5_external_reverify_20261106.md +18 -0
- package/docs/release-records/release-dryrun-report-20261106.md +74 -0
- package/docs/release-records/release-notes-2.2.6-T3.md +128 -0
- package/docs/release-records/release-record-2.1.3-20261106.md +82 -0
- package/docs/release-records/release-steps-20261106.md +129 -0
- package/docs/release-records/version-freeze-20261109-T2.md +37 -0
- package/lib/client.js +143 -3
- package/lib/comm-format.js +17 -0
- package/lib/departments.js +19 -0
- package/lib/host.js +95 -17
- package/lib/notice-channel.js +290 -0
- package/lib/plan.js +541 -32
- package/lib/replan.js +4 -0
- package/lib/runtime.js +1481 -85
- package/lib/supersede.js +2 -2
- package/lib/understanding.js +8 -2
- package/lib/watchdog.js +52 -1
- package/package.json +3 -2
- package/scripts/repair-malformed-user-messages.mjs +312 -0
- package/src/client.ts +150 -2
- package/src/comm-format.ts +17 -0
- package/src/departments.ts +22 -0
- package/src/host.ts +90 -12
- package/src/notice-channel.ts +328 -0
- package/src/plan.ts +575 -24
- package/src/replan.ts +4 -0
- package/src/runtime.ts +1500 -86
- package/src/supersede.ts +2 -1
- package/src/understanding.ts +10 -2
- package/src/watchdog.ts +80 -1
package/lib/plan.js
CHANGED
|
@@ -7,10 +7,11 @@
|
|
|
7
7
|
* runtime and by unit tests.
|
|
8
8
|
*/
|
|
9
9
|
import { createHash, randomUUID } from 'node:crypto';
|
|
10
|
-
import { DEPARTMENT_CAPABILITIES, departmentCapability } from './departments.js';
|
|
10
|
+
import { DEPARTMENT_CAPABILITIES, DEPARTMENT_EXPERT_STANDARD, departmentCapability } from './departments.js';
|
|
11
11
|
import { MAX_TASK_ANCHOR_CHARS } from './understanding.js';
|
|
12
12
|
import { isMappingDigest, verifyMappingDigest } from './supersede-digest.js';
|
|
13
13
|
import { phaseSummaryLine, threePhasePromptLines, validatePhaseEvidence } from './three-phase.js';
|
|
14
|
+
import { NOTICE_TARGET_MISSING_TEXT, leadNoticeCallForm, readLeadAgentId, validateNoticeChannel, } from './notice-channel.js';
|
|
14
15
|
import { checkCommFormatCompliance, renderCommFormatRejection, renderCommFormatSpec, } from './comm-format.js';
|
|
15
16
|
export const PLAN_VERSION = 1;
|
|
16
17
|
/**
|
|
@@ -160,6 +161,16 @@ export const HANDOFF_STATUSES = Object.freeze(['open', 'routed', 'answered', 'cl
|
|
|
160
161
|
export const MAX_HANDOFFS = MAX_EVIDENCE_NEEDS;
|
|
161
162
|
export const MAX_HANDOFF_RESPONSE_CHARS = 4000;
|
|
162
163
|
export const LIKELIHOODS = Object.freeze(['low', 'medium', 'high']);
|
|
164
|
+
/*
|
|
165
|
+
* [2.2.0][T13/推理等级] 子 Agent 的推理等级只有三档(用户强制规则)。
|
|
166
|
+
*
|
|
167
|
+
* 用户规则原文:「禁止子agent继承主agent的推理等级,子agent必须根据自身任务的
|
|
168
|
+
* 复杂度,自己使用推理等级为low、high或者是Max,其中,轻度复杂的任务使用low,
|
|
169
|
+
* 中等复杂的任务使用high,非常复杂的任务使用Max。」
|
|
170
|
+
* 子任务未声明该字段时回落 high(中等默认);执行侧绝不读取主 Agent 的等级。
|
|
171
|
+
*/
|
|
172
|
+
export const REASONING_EFFORTS = Object.freeze(['low', 'high', 'max']);
|
|
173
|
+
export const DEFAULT_REASONING_EFFORT = 'high';
|
|
163
174
|
export const DEPARTMENTS = Object.freeze({
|
|
164
175
|
engineering: { zh: '工程研发', en: 'Engineering' },
|
|
165
176
|
research: { zh: '研究分析', en: 'Research' },
|
|
@@ -600,6 +611,63 @@ function readSubtasks(value, stageIndex, errors) {
|
|
|
600
611
|
if (!DEPARTMENTS[department]) {
|
|
601
612
|
push(errors, `${base}.department`, `必须是 ${DEPARTMENT_IDS.join(' / ')} 之一`);
|
|
602
613
|
}
|
|
614
|
+
/*
|
|
615
|
+
* [2.2.0][T3/O-2b] 预估区间改判:1-240 整数,越界拒绝、区间内原样保留。
|
|
616
|
+
*
|
|
617
|
+
* 方案原文(docs/dsh-workplan_优化方案_20261107.md):
|
|
618
|
+
* - §2.2「estimateMinutes 钳制放宽为 1–240 整数(仅防离谱值,advisory 不变)」;
|
|
619
|
+
* - §1⑤ O-5c「固定区间去钳制:同 O-2b」;
|
|
620
|
+
* - §1② B2「estimateMinutes: 90 的计划通过校验且原样保留(不再被钳成 15)」。
|
|
621
|
+
* 「去钳制 + 原样保留 + 仅防离谱值」的唯一自洽合成:合法区间内不再改写值,
|
|
622
|
+
* 0/241 等离谱值**拒绝**并点名字段(不是钳成 1/240 蒙混通过)——与同源用例
|
|
623
|
+
* tests/time-estimate-negotiation.test.ts(0 与 241 被拒、1/90/240 原样保留)一致。
|
|
624
|
+
* 可选与缺省合法的宽容面保留(旧计划零回归,验收 ②B4):没有 estimateMinutes
|
|
625
|
+
* 的计划照旧通过校验。歧义链与 Z8 红线取舍见
|
|
626
|
+
* docs/dsh-workplan_T3_plan改动说明_20261107.md。
|
|
627
|
+
*/
|
|
628
|
+
const hasEstimate = source.estimateMinutes !== undefined && source.estimateMinutes !== null;
|
|
629
|
+
const estimateValue = hasEstimate ? Number(source.estimateMinutes) : NaN;
|
|
630
|
+
const estimateOk = hasEstimate
|
|
631
|
+
&& typeof source.estimateMinutes === 'number'
|
|
632
|
+
&& Number.isInteger(estimateValue)
|
|
633
|
+
&& estimateValue >= 1
|
|
634
|
+
&& estimateValue <= 240;
|
|
635
|
+
if (hasEstimate && !estimateOk) {
|
|
636
|
+
push(errors, `${base}.estimateMinutes`, '必须是 1-240 的整数(仅防离谱值:越界或非整数拒绝、不改写;该字段可选,缺失合法)');
|
|
637
|
+
}
|
|
638
|
+
/*
|
|
639
|
+
* [2.2.0][T3/O-3a] per-subtask 协商上限(timeoutMs,毫秒)可选透传。
|
|
640
|
+
*
|
|
641
|
+
* 方案 §2.2:「timeoutMs(可选)|本子任务的协商上限;缺省由 estimateMinutes
|
|
642
|
+
* × 2.0 派生并钳制|readSubtasks + validatePlan 只校验类型与范围,缺省合法」。
|
|
643
|
+
* 原样透传、不在此处钳到 MAX(同源用例 tests/time-estimate-negotiation.test.ts
|
|
644
|
+
* 固化 timeoutMs: 3600000 原样保留);只校验类型与范围:正数毫秒,缺失合法。
|
|
645
|
+
* 范围上界方案未给定(未知/待核实,见改动说明歧义点 3)。
|
|
646
|
+
*/
|
|
647
|
+
const hasTimeout = source.timeoutMs !== undefined && source.timeoutMs !== null;
|
|
648
|
+
const timeoutValue = hasTimeout ? Number(source.timeoutMs) : NaN;
|
|
649
|
+
const timeoutOk = hasTimeout
|
|
650
|
+
&& typeof source.timeoutMs === 'number'
|
|
651
|
+
&& Number.isFinite(timeoutValue)
|
|
652
|
+
&& timeoutValue > 0;
|
|
653
|
+
if (hasTimeout && !timeoutOk) {
|
|
654
|
+
push(errors, `${base}.timeoutMs`, '必须是正数毫秒(协商上限,可选字段,缺失合法)');
|
|
655
|
+
}
|
|
656
|
+
/*
|
|
657
|
+
* [2.2.0][T13/推理等级] 子任务自带的推理等级(可选,仅 low / high / max)。
|
|
658
|
+
*
|
|
659
|
+
* 用户规则原文见 REASONING_EFFORTS 上方注释。语义与 estimateMinutes 同风格:
|
|
660
|
+
* 缺失合法(旧计划/回放零回归),但非法值**拒绝**并点名字段,不静默改写成
|
|
661
|
+
* 其它档位;执行侧对缺失值回落 DEFAULT_REASONING_EFFORT(high),绝不继承
|
|
662
|
+
* 主 Agent 的等级。
|
|
663
|
+
*/
|
|
664
|
+
const hasEffort = source.reasoningEffort !== undefined && source.reasoningEffort !== null;
|
|
665
|
+
const effortOk = hasEffort
|
|
666
|
+
&& typeof source.reasoningEffort === 'string'
|
|
667
|
+
&& REASONING_EFFORTS.includes(source.reasoningEffort);
|
|
668
|
+
if (hasEffort && !effortOk) {
|
|
669
|
+
push(errors, `${base}.reasoningEffort`, '必须是 low / high / max 之一(可选字段,缺失时回落 high;非法值拒绝,不改写)');
|
|
670
|
+
}
|
|
603
671
|
return {
|
|
604
672
|
id: readString(source.id, `${base}.id`, 1, 16, errors),
|
|
605
673
|
title: readString(source.title, `${base}.title`, 1, 200, errors),
|
|
@@ -633,13 +701,43 @@ function readSubtasks(value, stageIndex, errors) {
|
|
|
633
701
|
* [1.7.0] Optional time estimate, advisory only. Validation never fails on
|
|
634
702
|
* a missing or out-of-range value: a plan that cannot be dispatched is
|
|
635
703
|
* worse than one carrying a rough estimate.
|
|
704
|
+
* [2.2.0][T3/O-2b] 语义演进(上方校验块注释引方案原文):缺省仍然合法;
|
|
705
|
+
* 越界自 2.2.0 起拒绝而非钳制(§1⑤ O-5c 固定区间去钳制),本注释保留为
|
|
706
|
+
* [1.7.0] 历史记录。
|
|
636
707
|
*/
|
|
637
|
-
...(
|
|
638
|
-
|
|
639
|
-
|
|
708
|
+
...(estimateOk ? { estimateMinutes: estimateValue } : {}),
|
|
709
|
+
...(timeoutOk ? { timeoutMs: timeoutValue } : {}),
|
|
710
|
+
reasoningEffort: effortOk ? String(source.reasoningEffort) : DEFAULT_REASONING_EFFORT,
|
|
640
711
|
};
|
|
641
712
|
});
|
|
642
713
|
}
|
|
714
|
+
/**
|
|
715
|
+
* [2.2.0][T3/O-3a] per-subtask 协商上限(negotiated ceiling)派生公式。
|
|
716
|
+
*
|
|
717
|
+
* 方案 §1③ O-3a:「缺省时由预估派生:协商上限 = clamp(预估分钟 × 安全系数
|
|
718
|
+
* (建议 2.0), 全局下限, 单次绝对上限)」;§2.2 timeoutMs 行:「缺省由
|
|
719
|
+
* `estimateMinutes × 2.0` 派生并钳制」。分钟→毫秒按 ×60000 换算(同源用例
|
|
720
|
+
* tests/time-estimate-negotiation.test.ts 的 expected 公式逐字一致)。
|
|
721
|
+
*
|
|
722
|
+
* 消费序(O-3b 接线契约,runtime 侧):显式 subtask.timeoutMs(O-3c:预告经
|
|
723
|
+
* 主 Agent 确认后写入,原样透传)→ 缺省调用本函数派生(钳在 [minMs, maxMs],
|
|
724
|
+
* 验收 ③C3)→ 两者皆无(旧计划无 estimateMinutes 也无 timeoutMs)返回
|
|
725
|
+
* undefined,消费侧回落原行为(normaliseChildTimeout 全局兜底,验收 ③C2)。
|
|
726
|
+
* 本函数只做「预估→派生值」纯换算,不读 subtask 对象。
|
|
727
|
+
*
|
|
728
|
+
* MIN_CHILD_TIMEOUT_MS=1,000 毫秒不变(与 src/runtime.ts:220 现状同值)。
|
|
729
|
+
* MAX_CHILD_TIMEOUT_MS=7,200,000 毫秒(120 分钟)=plan.ts 侧派生上限——
|
|
730
|
+
* 【用户 2026-11-07 决断】方案 §6 未知第 4 条已由用户拍板上调;runtime.ts:221
|
|
731
|
+
* 常量本体由 T4 波次同步改(改前两处不同值时以本决断为准)。
|
|
732
|
+
* plan.ts 被 runtime.ts 反向依赖(runtime.ts import './plan.js'),不能反向
|
|
733
|
+
* import,故此处带默认值、调用方可传入权威常量。
|
|
734
|
+
*/
|
|
735
|
+
export function deriveSubtaskTimeoutMs(estimateMinutes, minMs = 1000, maxMs = 7200000) {
|
|
736
|
+
const estimate = Number(estimateMinutes);
|
|
737
|
+
if (!Number.isFinite(estimate) || estimate <= 0)
|
|
738
|
+
return undefined;
|
|
739
|
+
return Math.min(maxMs, Math.max(minMs, estimate * 2.0 * 60_000));
|
|
740
|
+
}
|
|
643
741
|
function readStages(value, errors) {
|
|
644
742
|
if (!Array.isArray(value)) {
|
|
645
743
|
push(errors, 'stages', '必须是数组');
|
|
@@ -1042,7 +1140,10 @@ export function buildPlannerPrompt(taskText, cwd, conversationContext = '', budg
|
|
|
1042
1140
|
const departments = DEPARTMENT_CAPABILITIES
|
|
1043
1141
|
.map((entry) => `- ${entry.id}(${entry.zh} / ${entry.en}):职责 ${entry.responsibilities.join(';')};典型产物 ${entry.outputs.join(';')}`)
|
|
1044
1142
|
.join('\n');
|
|
1045
|
-
const
|
|
1143
|
+
const rawTotalMinutes = Number(budget?.totalMinutes);
|
|
1144
|
+
const totalMinutes = Number.isFinite(rawTotalMinutes) && rawTotalMinutes > 0
|
|
1145
|
+
? Math.max(1, Math.round(rawTotalMinutes))
|
|
1146
|
+
: 0;
|
|
1046
1147
|
const childMinutes = Math.max(1, Math.round(Number(budget?.childMinutes) || 15));
|
|
1047
1148
|
const concurrency = Math.max(1, Number(budget?.concurrency) || MAX_CONCURRENT);
|
|
1048
1149
|
const resumes = Number.isFinite(Number(budget?.maxResumes)) ? Number(budget.maxResumes) : MAX_PLAN_RESUMES;
|
|
@@ -1079,16 +1180,29 @@ export function buildPlannerPrompt(taskText, cwd, conversationContext = '', budg
|
|
|
1079
1180
|
'- unknowns 和 assumptions 必须如实列出;没有就写空数组,不能把假设写成事实。',
|
|
1080
1181
|
'- 子任务必须可独立执行、可验收;不要为了凑数拆无意义任务。',
|
|
1081
1182
|
'- 子任务由子 Agent 独立执行:它们没有派发权限、不能重启服务、不能安装或升级依赖。禁止把「调用 dsh_workplan_dispatch」「重启/停止 dsh web」「安装或升级插件」这类只有主 Agent 才能执行的动作写进子任务;确实需要时,写成“给出结论或建议,由主 Agent 执行”。',
|
|
1082
|
-
'-
|
|
1183
|
+
'- 单个子任务无须在 10 分钟内完成——10 分钟只是拆步规模建议,不是完成期限、也不构成承诺;实际时长由执行专家开工预告协商决定,不设固定完成时间;动手重的任务要拆成多个小步,避免整条计划被一个慢子任务拖住。',
|
|
1083
1184
|
'- 不要输出 Markdown 代码围栏、解释或前后缀;只输出一个 JSON 对象。',
|
|
1084
1185
|
'',
|
|
1085
1186
|
'本轮时间预算(硬事实,请据此规划规模):',
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1187
|
+
totalMinutes > 0
|
|
1188
|
+
? `- 一轮总预算约 ${totalMinutes} 分钟(安全兜底,不是交付期限);单个子任务规模参考 ${childMinutes} 分钟量级(仅供参考、非承诺,实际时长由执行专家开工预告协商决定);同时最多 ${concurrency} 个子任务并行。`
|
|
1189
|
+
: `- 本轮不设固定总预算;单个子任务按自身 estimateMinutes 与协商截止/延期执行;同时最多 ${concurrency} 个子任务并行。`,
|
|
1190
|
+
resumes > 0
|
|
1191
|
+
? `- 受阻后自动续跑额度 ${resumes} 次;需要时计划会暂停并在下一轮继续。`
|
|
1192
|
+
: '- 自动续跑额度为 0;计划不会因轮次预算被暂停。',
|
|
1193
|
+
'- 每个子任务必须写 estimateMinutes(整数 1-240,宁可估高):你预估它需要多少分钟。宁可估高,不要估低。取值必须是整数,越界或非整数会被校验拒绝(仅防离谱值),缺失不报错。',
|
|
1194
|
+
/*
|
|
1195
|
+
* [2.2.0][T13/推理等级] 子 Agent 必须自决推理等级,禁止继承主 Agent。
|
|
1196
|
+
* 用户规则原文见 plan.ts 顶部 REASONING_EFFORTS 注释;三档映射与三个示例
|
|
1197
|
+
* 按用户规则逐字展开,规划器输出由 readSubtasks 校验(只收 low/high/max)。
|
|
1198
|
+
*/
|
|
1199
|
+
'- 每个子任务必须按它自身的复杂度写 reasoningEffort(推理等级,只允许 low / high / max 三档):轻度复杂="low",中等复杂="high",非常复杂="max"。',
|
|
1200
|
+
'- reasoningEffort 三档示例:整理并校对一份已有清单="low";独立实现一个模块并补齐测试="high";跨多个系统排查根因并给出架构级修复方案="max"。',
|
|
1201
|
+
'- 禁止沿用/继承主 Agent 的推理等级:reasoningEffort 只由该子任务自身的复杂度决定,不得因为主 Agent 当前是某一档就照抄;缺失时执行侧回落 "high",但你必须显式写出该字段。',
|
|
1089
1202
|
'- 规模大就如实拆成多轮,不要为了塞进一轮而把多个交付物压进一个子任务。',
|
|
1090
1203
|
'',
|
|
1091
|
-
'
|
|
1204
|
+
'可用部门(每个部门的执行者都是来自全球相关领域的顶尖专家,不是普通部门人员):',
|
|
1205
|
+
DEPARTMENT_EXPERT_STANDARD.planner,
|
|
1092
1206
|
departments,
|
|
1093
1207
|
'',
|
|
1094
1208
|
`工作目录:${directory}`,
|
|
@@ -1135,7 +1249,7 @@ export function buildPlannerPrompt(taskText, cwd, conversationContext = '', budg
|
|
|
1135
1249
|
' "title": "子任务",',
|
|
1136
1250
|
' "department": "engineering",',
|
|
1137
1251
|
' "departmentRationale": "为什么是该部门:命中哪条职责、对应任务哪个要素",',
|
|
1138
|
-
' "role": "
|
|
1252
|
+
' "role": "部门内角色(按该领域全球顶尖专家定位填写,如「资深架构师·全球顶尖水准」)",',
|
|
1139
1253
|
' "objective": "目标",',
|
|
1140
1254
|
' "method": ["具体方法/步骤"],',
|
|
1141
1255
|
' "inputs": ["输入;未知写待确认"],',
|
|
@@ -1143,7 +1257,8 @@ export function buildPlannerPrompt(taskText, cwd, conversationContext = '', budg
|
|
|
1143
1257
|
' "dependsOn": [],',
|
|
1144
1258
|
' "acceptance": ["可测试的验收标准"],',
|
|
1145
1259
|
' "risk": "主要风险",',
|
|
1146
|
-
' "estimateMinutes": 5',
|
|
1260
|
+
' "estimateMinutes": 5,',
|
|
1261
|
+
' "reasoningEffort": "high"',
|
|
1147
1262
|
' }',
|
|
1148
1263
|
' ]',
|
|
1149
1264
|
' }',
|
|
@@ -1177,6 +1292,122 @@ export function makeUserMessage(text, source) {
|
|
|
1177
1292
|
source,
|
|
1178
1293
|
};
|
|
1179
1294
|
}
|
|
1295
|
+
/**
|
|
1296
|
+
* [2.2.1] Validate the exact payload shape DSH requires for a `user/message`
|
|
1297
|
+
* event before it reaches the append-only log.
|
|
1298
|
+
*
|
|
1299
|
+
* Incident it prevents (2026-11-08, session-a404d49d…): the plugin appended
|
|
1300
|
+
* plain strings as `user/message` data. `Session.append()` only validates
|
|
1301
|
+
* payloads that are records, so the strings were persisted; on replay the
|
|
1302
|
+
* `goal` projection read `event.data.source.kind` and threw
|
|
1303
|
+
* "Cannot read properties of undefined (reading 'kind')", which surfaced as
|
|
1304
|
+
* "历史加载失败 / failed to project session". A malformed event is
|
|
1305
|
+
* unrecoverable once appended, so rejection must happen here, before append.
|
|
1306
|
+
*/
|
|
1307
|
+
function userMessageShapeProblem(message) {
|
|
1308
|
+
if (!isRecord(message))
|
|
1309
|
+
return 'payload must be a plain object';
|
|
1310
|
+
if (typeof message.id !== 'string' || message.id.length === 0)
|
|
1311
|
+
return 'missing message id';
|
|
1312
|
+
if (message.role !== 'user')
|
|
1313
|
+
return 'role must be "user"';
|
|
1314
|
+
if (!Array.isArray(message.content) || message.content.length === 0)
|
|
1315
|
+
return 'content must be a non-empty array';
|
|
1316
|
+
if (!isRecord(message.source))
|
|
1317
|
+
return 'missing source';
|
|
1318
|
+
if (typeof message.source.kind !== 'string' || message.source.kind.length === 0)
|
|
1319
|
+
return 'missing source.kind';
|
|
1320
|
+
return null;
|
|
1321
|
+
}
|
|
1322
|
+
/**
|
|
1323
|
+
* [2.2.1] The single approved writer for `user/message` events in this plugin.
|
|
1324
|
+
*
|
|
1325
|
+
* A raw string is wrapped into a complete DSH `UserMessage` (stable id, role,
|
|
1326
|
+
* text content, source with a nonempty `kind`); an already-built message is
|
|
1327
|
+
* shape-checked. Either way a malformed payload throws BEFORE `session.append`,
|
|
1328
|
+
* so a bad notice can never corrupt a session log again. All appends use
|
|
1329
|
+
* `surfaceOp: 'append'`, matching the previous call sites.
|
|
1330
|
+
*/
|
|
1331
|
+
export function appendUserMessage(session, payload, source) {
|
|
1332
|
+
if (!session || typeof session.append !== 'function')
|
|
1333
|
+
return undefined;
|
|
1334
|
+
let message = payload;
|
|
1335
|
+
if (typeof payload === 'string') {
|
|
1336
|
+
const summary = truncate(String(payload).replace(/\s+/g, ' ').trim() || '(无摘要)', 120);
|
|
1337
|
+
message = makeUserMessage(payload, source ?? { kind: 'workplan', form: 'notice', summary });
|
|
1338
|
+
}
|
|
1339
|
+
const problem = userMessageShapeProblem(message);
|
|
1340
|
+
if (problem !== null)
|
|
1341
|
+
throw new Error(`dsh-workplan: refusing to append malformed user/message (${problem})`);
|
|
1342
|
+
return session.append('user/message', message, { surfaceOp: 'append' });
|
|
1343
|
+
}
|
|
1344
|
+
/*
|
|
1345
|
+
* [2.2.5][T5] 分解期间进度文案与回报器(T3 交互规范 §3 C2/C3、§4 频率规则)。
|
|
1346
|
+
*
|
|
1347
|
+
* 缺陷:runPlanner 全程(最长 3 次尝试 × 300s 窗口 + 退避)插件既不写会话
|
|
1348
|
+
* 消息也不放内存记录(T1 断点层判定=未发出),用户无法区分「正在重试」与
|
|
1349
|
+
* 「卡死」。本组函数只负责「把一次失败尝试翻译成用户能看懂的两句话」:
|
|
1350
|
+
* - cardLine:通道 A(侧栏占位卡片的 errors 区,4 秒轮询可见,保底通道);
|
|
1351
|
+
* - notice:通道 B(appendUserMessage 聊天通知,仅「会退避重试」的失败才
|
|
1352
|
+
* 发,每轮至多 2 条——第 3 次失败直接进降级文案,不再叠加通知)。
|
|
1353
|
+
* 文案硬规则(T3 §3):真因链截断 ≤120 字符(错误码原样保留,供用户报障);
|
|
1354
|
+
* 分母 3 由 maxAttempts 参数注入,不在文案里硬编码;等待时长按实际退避
|
|
1355
|
+
* 四舍五入到秒;aborted 由调用方(回报器)静默,本函数不涉及。
|
|
1356
|
+
*/
|
|
1357
|
+
export function plannerProgressLines(report, maxAttempts) {
|
|
1358
|
+
const attempt = Number(report?.attempt) || 0;
|
|
1359
|
+
const outcome = String(report?.outcome ?? 'PLANNER_ERROR');
|
|
1360
|
+
const causes = Array.isArray(report?.lastErrors) ? report.lastErrors : [];
|
|
1361
|
+
const cause = truncate(causes.join(';').replace(/\s+/g, ' ').trim(), 120);
|
|
1362
|
+
if (attempt <= 0 || !cause)
|
|
1363
|
+
return { cardLine: '', notice: null };
|
|
1364
|
+
const terminal = report?.terminal === true;
|
|
1365
|
+
const backoffMs = Number(report?.retryBackoffMs) || 0;
|
|
1366
|
+
const total = Number(maxAttempts) || attempt;
|
|
1367
|
+
const willRetry = !terminal && backoffMs > 0 && attempt < total;
|
|
1368
|
+
const waitSecs = Math.max(1, Math.round(backoffMs / 1000));
|
|
1369
|
+
const prefix = `第 ${attempt} 次尝试失败(${outcome}):${cause}`;
|
|
1370
|
+
const cardLine = willRetry
|
|
1371
|
+
? `${prefix};正在重试(约 ${waitSecs} 秒后),第 ${attempt + 1}/${total} 次`
|
|
1372
|
+
: backoffMs > 0
|
|
1373
|
+
? `${prefix};正在重试`
|
|
1374
|
+
: `${prefix}`;
|
|
1375
|
+
const notice = willRetry
|
|
1376
|
+
? `【自动分解】第 ${attempt} 次尝试失败:${cause};正在重试(约 ${waitSecs} 秒后),第 ${attempt + 1}/${total} 次`
|
|
1377
|
+
: null;
|
|
1378
|
+
return { cardLine, notice };
|
|
1379
|
+
}
|
|
1380
|
+
/*
|
|
1381
|
+
* [2.2.5][T5] 进度回报器工厂:把 runPlanner 的 onProgress 回调落到两个既有
|
|
1382
|
+
* 通道上(T3 §2 S2、§4 频率规则)。依赖全部以参数注入(signal / 落记录 /
|
|
1383
|
+
* 发通知),便于脱离宿主运行态做单元回归:
|
|
1384
|
+
* - signal.aborted 后一律静默(用户自己取消的,不再打扰,也不写记录);
|
|
1385
|
+
* - 通道 A 每轮至多 2 行(maxLines),通道 B 每轮至多 2 条(maxNotices);
|
|
1386
|
+
* - 记录更新走 setRecord 回调(maybePlan 侧即 state.records.set),失败
|
|
1387
|
+
* 尝试的摘要在成功/降级后被既有 records.set 整体覆盖,无残留。
|
|
1388
|
+
*/
|
|
1389
|
+
export function createPlannerProgressReporter(options) {
|
|
1390
|
+
const maxLines = Math.max(1, Number(options.maxLines) || 2);
|
|
1391
|
+
const maxNotices = Math.max(0, Number(options.maxNotices) || 2);
|
|
1392
|
+
const errors = [];
|
|
1393
|
+
let notices = 0;
|
|
1394
|
+
return (report) => {
|
|
1395
|
+
if (options.signal?.aborted)
|
|
1396
|
+
return;
|
|
1397
|
+
const lines = plannerProgressLines(report, options.maxAttempts);
|
|
1398
|
+
if (!lines.cardLine)
|
|
1399
|
+
return;
|
|
1400
|
+
if (errors.length < maxLines)
|
|
1401
|
+
errors.push(lines.cardLine);
|
|
1402
|
+
options.record.errors = [...errors];
|
|
1403
|
+
options.record.updatedAt = Date.now();
|
|
1404
|
+
options.setRecord(options.record);
|
|
1405
|
+
if (lines.notice && notices < maxNotices) {
|
|
1406
|
+
notices += 1;
|
|
1407
|
+
options.appendNotice(lines.notice);
|
|
1408
|
+
}
|
|
1409
|
+
};
|
|
1410
|
+
}
|
|
1180
1411
|
export function buildPlanSummary(plan) {
|
|
1181
1412
|
const total = flattenSubtasks(plan).length;
|
|
1182
1413
|
const primary = plan.contradictions.primary.statement;
|
|
@@ -1204,18 +1435,32 @@ export function estimatePlanMinutes(plan, fallbackMinutes = 15, concurrency = MA
|
|
|
1204
1435
|
const totalEstimate = estimates.reduce((sum, value) => sum + value, 0);
|
|
1205
1436
|
return Math.max(waves * maxEstimate, Math.ceil(totalEstimate / Math.max(1, concurrency)));
|
|
1206
1437
|
}
|
|
1207
|
-
export function buildBudgetWarning(plan, totalBudgetMinutes =
|
|
1438
|
+
export function buildBudgetWarning(plan, totalBudgetMinutes = 0, maxResumes = MAX_PLAN_RESUMES) {
|
|
1208
1439
|
const minutes = estimatePlanMinutes(plan);
|
|
1209
|
-
const
|
|
1210
|
-
|
|
1211
|
-
|
|
1440
|
+
const rawBudget = Number(totalBudgetMinutes);
|
|
1441
|
+
const budget = Number.isFinite(rawBudget) && rawBudget > 0 ? Math.max(1, Math.round(rawBudget)) : 0;
|
|
1442
|
+
/*
|
|
1443
|
+
* [2.2.0][T3/O-5b] 固定预算措辞改为「预估仅供参考,非承诺;实际时长协商
|
|
1444
|
+
* 决定」(方案 §2.6 #5 的目标措辞;O-5b 三处承诺禁令之一):预算提示只讲
|
|
1445
|
+
* 估算与轮次,不构成任何固定交付承诺。
|
|
1446
|
+
*
|
|
1447
|
+
* 标注行是输出的固定组成部分——预算内也返回(验收 E2「预算预告/计划消息
|
|
1448
|
+
* 把预估标注为仅供参考/非承诺」:凡 buildBudgetWarning 有输出必带该标注,
|
|
1449
|
+
* 计划消息经 warning 路径同享,不再按超预算与否吞掉)。
|
|
1450
|
+
*/
|
|
1451
|
+
const advisory = '(子任务 estimateMinutes 预估仅供参考,非承诺;实际时长协商决定:由执行专家开工预告协商,不设固定完成时间。)';
|
|
1452
|
+
// [2.2.5] 0 = 本轮不设固定总预算:只保留“预估仅供参考”的标注,不再输出
|
|
1453
|
+
// “超过本轮预算/需要 N 轮”的提示,避免与“不强制限制”的目标矛盾。
|
|
1454
|
+
if (budget === 0 || minutes <= budget)
|
|
1455
|
+
return advisory;
|
|
1212
1456
|
const rounds = Math.max(1, Math.ceil(minutes / budget));
|
|
1213
1457
|
const missing = flattenSubtasks(plan).some((entry) => !Number.isFinite(Number(entry.subtask?.estimateMinutes)));
|
|
1214
1458
|
return [
|
|
1215
1459
|
`⚠ 预算提示:本计划 ${flattenSubtasks(plan).length} 项,按其估计约需 ${minutes} 分钟 > 本轮 ${budget} 分钟,`
|
|
1216
1460
|
+ `预计需要约 ${rounds} 轮(续跑额度 ${maxResumes} 次)。`,
|
|
1461
|
+
advisory,
|
|
1217
1462
|
'建议:拆成多轮,或减少同时进行的子任务。',
|
|
1218
|
-
...(missing ? ['(部分子任务缺少 estimateMinutes
|
|
1463
|
+
...(missing ? ['(部分子任务缺少 estimateMinutes,已按每项 15 分钟默认值估算。)'] : []),
|
|
1219
1464
|
].join('\n');
|
|
1220
1465
|
}
|
|
1221
1466
|
export function buildPlanMessage(plan, options = {}) {
|
|
@@ -1229,9 +1474,15 @@ export function buildPlanMessage(plan, options = {}) {
|
|
|
1229
1474
|
createdAt: plan.createdAt,
|
|
1230
1475
|
plan,
|
|
1231
1476
|
};
|
|
1232
|
-
const warning = buildBudgetWarning(plan, options.totalBudgetMinutes ??
|
|
1477
|
+
const warning = buildBudgetWarning(plan, options.totalBudgetMinutes ?? 0, options.maxResumes ?? MAX_PLAN_RESUMES);
|
|
1233
1478
|
const text = [
|
|
1234
1479
|
summary,
|
|
1480
|
+
/*
|
|
1481
|
+
* [2.2.0][T3/O-5b/E2] 计划消息中的预估一律标注「非承诺」(方案 §1⑤ O-5b:
|
|
1482
|
+
* 「预估一律标注『仅供参考,实际时长由执行专家预告协商』」;验收 E2)。
|
|
1483
|
+
* 标注由 buildBudgetWarning 的固定 advisory 行携带(预算内也返回,见该
|
|
1484
|
+
* 函数注释),warning 恒非空随消息带出,此处不再重复一份。
|
|
1485
|
+
*/
|
|
1235
1486
|
...(warning ? ['', warning] : []),
|
|
1236
1487
|
'',
|
|
1237
1488
|
/*
|
|
@@ -1255,6 +1506,11 @@ export function buildPlanMessage(plan, options = {}) {
|
|
|
1255
1506
|
}
|
|
1256
1507
|
export function buildDegradedMessage(options) {
|
|
1257
1508
|
const error = truncate(options.error ?? '未知错误', 600);
|
|
1509
|
+
/*
|
|
1510
|
+
* [2.1.6] 失败现场:模型、耗时、收到几个输出块、判定码。没有它,用户只看到
|
|
1511
|
+
* 一句「超时」,既不知道是不是模型太慢,也不知道该改哪个旋钮。
|
|
1512
|
+
*/
|
|
1513
|
+
const detail = truncate(options.detail ?? '', 400);
|
|
1258
1514
|
const summary = truncate(`【自动分解降级】${error}`, 300);
|
|
1259
1515
|
const payload = {
|
|
1260
1516
|
kind: 'workplan',
|
|
@@ -1265,6 +1521,7 @@ export function buildDegradedMessage(options) {
|
|
|
1265
1521
|
createdAt: options.createdAt,
|
|
1266
1522
|
degraded: true,
|
|
1267
1523
|
error,
|
|
1524
|
+
...(detail ? { detail } : {}),
|
|
1268
1525
|
title: '自动分解降级',
|
|
1269
1526
|
taskUnderstanding: {
|
|
1270
1527
|
originalRequest: truncate(options.taskText ?? '', 2000),
|
|
@@ -1278,6 +1535,7 @@ export function buildDegradedMessage(options) {
|
|
|
1278
1535
|
};
|
|
1279
1536
|
const text = [
|
|
1280
1537
|
summary,
|
|
1538
|
+
...(detail ? ['', detail] : []),
|
|
1281
1539
|
'',
|
|
1282
1540
|
'自动任务分解失败,部门 Agent 未启动。',
|
|
1283
1541
|
'请先向用户说明失败原因,并询问是否重试;在用户确认前不要开始执行任务。',
|
|
@@ -1437,7 +1695,10 @@ export function buildResultMessage(result) {
|
|
|
1437
1695
|
if (handoffs.length > 0) {
|
|
1438
1696
|
return handoffs.map((handoff) => `${item.subtaskId} ${String(handoff?.id ?? 'H?')}(${String(handoff?.status ?? 'open')}):${String(handoff?.request ?? '')}`);
|
|
1439
1697
|
}
|
|
1440
|
-
|
|
1698
|
+
// [2.2.6][T4] needs 条目自本版起可能为结构化对象 {request, department},
|
|
1699
|
+
// 旧记录仍是字符串;统一经 needEntryText 渲染,两条形状都不会再出现
|
|
1700
|
+
// "[object Object]"(字符串路径逐字不变)。
|
|
1701
|
+
return (Array.isArray(item?.needs) ? item.needs : []).map((need) => `${item.subtaskId}:${needEntryText(need)}`);
|
|
1441
1702
|
});
|
|
1442
1703
|
const review = [];
|
|
1443
1704
|
if (escalations.length > 0) {
|
|
@@ -1940,11 +2201,94 @@ function readEvidenceArtifacts(value) {
|
|
|
1940
2201
|
return artifact;
|
|
1941
2202
|
}).filter((item) => item.ref !== '');
|
|
1942
2203
|
}
|
|
2204
|
+
/*
|
|
2205
|
+
* [2.2.6][T4] 循环引用/undefined 安全的 JSON 文本化兜底(缺陷二修复件)。
|
|
2206
|
+
*
|
|
2207
|
+
* 对象形 needs 的兜底路径不允许再用隐式 String()——它把任意对象变成字面量
|
|
2208
|
+
* "[object Object]",department 等字段当场丢失(wp-db6de2f0 的 T1–T4 四条
|
|
2209
|
+
* handoff 即因此损坏)。JSON.stringify 对循环引用会抛错、对顶层 undefined
|
|
2210
|
+
* 返回 undefined,这里统一兜成可读文本,任何形状都不会炸掉结果块解析。
|
|
2211
|
+
*/
|
|
2212
|
+
function safeJsonText(value) {
|
|
2213
|
+
const seen = new WeakSet();
|
|
2214
|
+
try {
|
|
2215
|
+
return JSON.stringify(value, (_key, entry) => {
|
|
2216
|
+
if (entry !== null && typeof entry === 'object') {
|
|
2217
|
+
if (seen.has(entry))
|
|
2218
|
+
return '[Circular]';
|
|
2219
|
+
seen.add(entry);
|
|
2220
|
+
}
|
|
2221
|
+
return entry === undefined ? null : entry;
|
|
2222
|
+
}) ?? '';
|
|
2223
|
+
}
|
|
2224
|
+
catch {
|
|
2225
|
+
return '[Unserializable object]';
|
|
2226
|
+
}
|
|
2227
|
+
}
|
|
2228
|
+
/** [2.2.6][T4] 本插件 readEvidenceNeeds 产出的规范化条目形状(回放幂等判定)。 */
|
|
2229
|
+
function isStructuredNeedEntry(item) {
|
|
2230
|
+
return isRecord(item) && typeof item.request === 'string' && item.request.trim() !== ''
|
|
2231
|
+
&& Object.keys(item).every((key) => key === 'request' || key === 'department');
|
|
2232
|
+
}
|
|
2233
|
+
/*
|
|
2234
|
+
* [2.2.6][T4] 对象感知的 needs/options 文本提取(取代一切 String(对象))。
|
|
2235
|
+
*
|
|
2236
|
+
* 字符串原样返回(历史行为逐字不变);对象优先读取 need/request/text/
|
|
2237
|
+
* message/question 中首个非空文本字段,拼上 purpose(用途)与 department
|
|
2238
|
+
* (部门)前缀,与子 Agent 实际写入的 {"department","need","purpose"} 形状
|
|
2239
|
+
* 对齐(T1 §2.4 子会话日志原文实证);完全无法识别的形状回退受控 JSON 文本。
|
|
2240
|
+
* 注意:本插件自己的结构化条目 {request, department} 视为已定稿文本原样返回,
|
|
2241
|
+
* 否则 mergeHandoffsFromNeeds 会二次拼「部门:」前缀。
|
|
2242
|
+
*/
|
|
2243
|
+
export function needEntryText(item) {
|
|
2244
|
+
if (typeof item === 'string')
|
|
2245
|
+
return item;
|
|
2246
|
+
if (typeof item === 'number' || typeof item === 'boolean')
|
|
2247
|
+
return String(item);
|
|
2248
|
+
if (!isRecord(item))
|
|
2249
|
+
return item == null ? '' : safeJsonText(item);
|
|
2250
|
+
if (isStructuredNeedEntry(item))
|
|
2251
|
+
return item.request;
|
|
2252
|
+
const text = [item.need, item.request, item.text, item.message, item.question]
|
|
2253
|
+
.find((entry) => typeof entry === 'string' && entry.trim() !== '');
|
|
2254
|
+
const purpose = typeof item.purpose === 'string' && item.purpose.trim() !== '' ? item.purpose.trim() : '';
|
|
2255
|
+
const department = typeof item.department === 'string' && item.department.trim() !== '' ? item.department.trim() : '';
|
|
2256
|
+
if (typeof text === 'string') {
|
|
2257
|
+
const body = purpose !== '' ? `${text.trim()}(用途:${purpose})` : text.trim();
|
|
2258
|
+
return department !== '' ? `${department}:${body}` : body;
|
|
2259
|
+
}
|
|
2260
|
+
return safeJsonText(item);
|
|
2261
|
+
}
|
|
2262
|
+
/** [2.2.6][T4] 对象形 needs 的合法部门键提取(与 normaliseHandoffs 同一判定)。 */
|
|
2263
|
+
export function needEntryDepartment(item) {
|
|
2264
|
+
if (!isRecord(item))
|
|
2265
|
+
return null;
|
|
2266
|
+
const department = item.department;
|
|
2267
|
+
return typeof department === 'string' && DEPARTMENTS[department]
|
|
2268
|
+
? department
|
|
2269
|
+
: null;
|
|
2270
|
+
}
|
|
1943
2271
|
function readEvidenceNeeds(value) {
|
|
1944
2272
|
if (!Array.isArray(value))
|
|
1945
2273
|
return [];
|
|
1946
2274
|
return value.slice(0, MAX_EVIDENCE_NEEDS)
|
|
1947
|
-
.map((item) =>
|
|
2275
|
+
.map((item) => {
|
|
2276
|
+
if (typeof item === 'string')
|
|
2277
|
+
return truncate(item, 300);
|
|
2278
|
+
/*
|
|
2279
|
+
* [2.2.6][T4] 回放/重读幂等:本插件自己产出的结构化条目(仅含
|
|
2280
|
+
* request/department 两个键)原样保留,不二次拼「部门:」前缀——
|
|
2281
|
+
* 否则结果消息回放时文本会变化,绕过去重键造成重复登记。
|
|
2282
|
+
*/
|
|
2283
|
+
if (isStructuredNeedEntry(item)) {
|
|
2284
|
+
return { request: truncate(item.request, 300), department: needEntryDepartment(item) };
|
|
2285
|
+
}
|
|
2286
|
+
const request = truncate(needEntryText(item), 300).trim();
|
|
2287
|
+
if (!request)
|
|
2288
|
+
return null;
|
|
2289
|
+
const department = needEntryDepartment(item);
|
|
2290
|
+
return department !== null ? { request, department } : request;
|
|
2291
|
+
})
|
|
1948
2292
|
.filter(Boolean);
|
|
1949
2293
|
}
|
|
1950
2294
|
/**
|
|
@@ -1994,9 +2338,18 @@ export function mergeHandoffsFromNeeds(current, needs, overflow = []) {
|
|
|
1994
2338
|
const next = normaliseHandoffs(current);
|
|
1995
2339
|
const list = Array.isArray(needs) ? needs : [];
|
|
1996
2340
|
for (const raw of list) {
|
|
1997
|
-
|
|
2341
|
+
/*
|
|
2342
|
+
* [2.2.6][T4] 对象安全序列化(缺陷二第二触点 W2):needs 条目可能是子
|
|
2343
|
+
* Agent 直接写的对象({"department","need","purpose"}),也可能是
|
|
2344
|
+
* readEvidenceNeeds 产出的结构化条目 {request, department}。request 一律
|
|
2345
|
+
* 经 needEntryText 取文本、department 经 needEntryDepartment 提取合法
|
|
2346
|
+
* 部门键——本函数不再有任何 String(对象) 分支,对象不再被写成
|
|
2347
|
+
* "[object Object]"、department 不再被丢弃。去重键仍是 request 文本。
|
|
2348
|
+
*/
|
|
2349
|
+
const request = truncate(typeof raw === 'string' ? raw : needEntryText(raw), 300).trim();
|
|
1998
2350
|
if (!request)
|
|
1999
2351
|
continue;
|
|
2352
|
+
const department = needEntryDepartment(raw);
|
|
2000
2353
|
if (next.some((item) => item.request === request))
|
|
2001
2354
|
continue;
|
|
2002
2355
|
/*
|
|
@@ -2013,7 +2366,7 @@ export function mergeHandoffsFromNeeds(current, needs, overflow = []) {
|
|
|
2013
2366
|
next.push({
|
|
2014
2367
|
id: `H${next.length + 1}`,
|
|
2015
2368
|
request,
|
|
2016
|
-
department
|
|
2369
|
+
department,
|
|
2017
2370
|
status: 'open',
|
|
2018
2371
|
response: null,
|
|
2019
2372
|
at: Date.now(),
|
|
@@ -2038,10 +2391,28 @@ export function openHandoffs(status) {
|
|
|
2038
2391
|
function readEvidenceOptions(value) {
|
|
2039
2392
|
if (!Array.isArray(value))
|
|
2040
2393
|
return [];
|
|
2394
|
+
// [2.2.6][T4] 同模式共犯(T1 W3):对象感知读取,消灭 String(对象) 分支。
|
|
2041
2395
|
return value.slice(0, MAX_ESCALATION_OPTIONS)
|
|
2042
|
-
.map((item) => truncate(
|
|
2396
|
+
.map((item) => truncate(needEntryText(item), 300))
|
|
2043
2397
|
.filter(Boolean);
|
|
2044
2398
|
}
|
|
2399
|
+
/**
|
|
2400
|
+
* [2.2.0][T3/O-2c] 用时回填字段(timeSpentMinutes / finalEstimateMinutes)
|
|
2401
|
+
* 的 advisory 读取器。
|
|
2402
|
+
*
|
|
2403
|
+
* 方案 §2.5:「时间字段纯 advisory:不参与可交付判定,不加拒绝码」;方案
|
|
2404
|
+
* §2.4 结果块契约「模板增加 timeSpentMinutes、finalEstimateMinutes 字段」。
|
|
2405
|
+
* 只在给出合法非负有限数值时以整数分钟透传;缺失/非法一律省略(返回
|
|
2406
|
+
* undefined、不占键名),不判不合规——字段本来就是可选的。
|
|
2407
|
+
*/
|
|
2408
|
+
function readAdvisoryMinutes(value) {
|
|
2409
|
+
if (value === undefined || value === null)
|
|
2410
|
+
return undefined;
|
|
2411
|
+
const num = Number(value);
|
|
2412
|
+
if (!Number.isFinite(num) || num < 0)
|
|
2413
|
+
return undefined;
|
|
2414
|
+
return Math.round(num);
|
|
2415
|
+
}
|
|
2045
2416
|
/**
|
|
2046
2417
|
* [2.1.0] 顶层证据字段被误写进 `phases` 时,把它们提回顶层(用户 2026-11-05)。
|
|
2047
2418
|
*
|
|
@@ -2282,13 +2653,6 @@ export function parseEvidenceBlock(output) {
|
|
|
2282
2653
|
}
|
|
2283
2654
|
}
|
|
2284
2655
|
const BLOCKED_LINE = /^\s*(BLOCKED|受阻|无法完成)\s*[::]\s*/i;
|
|
2285
|
-
/**
|
|
2286
|
-
* Deterministic verdict for one child result.
|
|
2287
|
-
*
|
|
2288
|
-
* This is the single place that decides done vs blocked, so the eight cases in
|
|
2289
|
-
* the acceptance table cannot drift apart between the runtime and the replay.
|
|
2290
|
-
* It never invents evidence and never upgrades a failed self-check to done.
|
|
2291
|
-
*/
|
|
2292
2656
|
export function adjudicateResult({ output, strict = true, expectedAcceptance = [], requirePhases = true }) {
|
|
2293
2657
|
const text = typeof output === 'string' ? output : '';
|
|
2294
2658
|
const parsed = parseEvidenceBlock(text);
|
|
@@ -2372,8 +2736,24 @@ export function adjudicateResult({ output, strict = true, expectedAcceptance = [
|
|
|
2372
2736
|
const question = truncate(String(payload.question ?? ''), MAX_QUESTION_CHARS);
|
|
2373
2737
|
const options = readEvidenceOptions(payload.options);
|
|
2374
2738
|
const blockedReason = truncate(String(payload.blockedReason ?? payload.error ?? ''), 2000);
|
|
2739
|
+
/*
|
|
2740
|
+
* [2.2.0][T3/O-2c] 用时回填字段(方案 §2.2/§2.4:「模板增加
|
|
2741
|
+
* timeSpentMinutes、finalEstimateMinutes 字段」)。纯 advisory(方案 §2.5
|
|
2742
|
+
* 「时间字段纯 advisory:不参与可交付判定,不加拒绝码」):合法即整数分钟
|
|
2743
|
+
* 透传到判定结果的每一个 payload 分支,缺失/非法即省略(不占键名),既有
|
|
2744
|
+
* 字段与 F1-F9 零改动。
|
|
2745
|
+
*/
|
|
2746
|
+
const timeSpentMinutes = readAdvisoryMinutes(payload.timeSpentMinutes);
|
|
2747
|
+
const finalEstimateMinutes = readAdvisoryMinutes(payload.finalEstimateMinutes);
|
|
2748
|
+
const advisoryTime = timeSpentMinutes === undefined && finalEstimateMinutes === undefined
|
|
2749
|
+
? {}
|
|
2750
|
+
: {
|
|
2751
|
+
...(timeSpentMinutes === undefined ? {} : { timeSpentMinutes }),
|
|
2752
|
+
...(finalEstimateMinutes === undefined ? {} : { finalEstimateMinutes }),
|
|
2753
|
+
};
|
|
2375
2754
|
if (payload.status === 'blocked') {
|
|
2376
2755
|
return {
|
|
2756
|
+
...advisoryTime,
|
|
2377
2757
|
status: 'blocked',
|
|
2378
2758
|
verification: 'structured',
|
|
2379
2759
|
acceptance,
|
|
@@ -2387,6 +2767,7 @@ export function adjudicateResult({ output, strict = true, expectedAcceptance = [
|
|
|
2387
2767
|
if (payload.status === 'partial') {
|
|
2388
2768
|
const detail = truncate(String(payload.summary ?? payload.blockedReason ?? ''), 2000);
|
|
2389
2769
|
return {
|
|
2770
|
+
...advisoryTime,
|
|
2390
2771
|
status: 'blocked',
|
|
2391
2772
|
verification: 'structured',
|
|
2392
2773
|
acceptance,
|
|
@@ -2400,6 +2781,7 @@ export function adjudicateResult({ output, strict = true, expectedAcceptance = [
|
|
|
2400
2781
|
const failed = acceptance.filter((item) => item.result === 'fail');
|
|
2401
2782
|
if (failed.length > 0) {
|
|
2402
2783
|
return {
|
|
2784
|
+
...advisoryTime,
|
|
2403
2785
|
status: 'blocked',
|
|
2404
2786
|
verification: 'failed',
|
|
2405
2787
|
acceptance,
|
|
@@ -2445,6 +2827,7 @@ export function adjudicateResult({ output, strict = true, expectedAcceptance = [
|
|
|
2445
2827
|
? '(结果块 JSON 有语法错误,已修复;若 acceptance 位于错误点之后,会被一起裁掉)'
|
|
2446
2828
|
: '';
|
|
2447
2829
|
return {
|
|
2830
|
+
...advisoryTime,
|
|
2448
2831
|
status: 'blocked',
|
|
2449
2832
|
verification: 'unverified',
|
|
2450
2833
|
acceptance,
|
|
@@ -2469,6 +2852,7 @@ export function adjudicateResult({ output, strict = true, expectedAcceptance = [
|
|
|
2469
2852
|
: validatePhaseEvidence(payload.phases, expectedAcceptance);
|
|
2470
2853
|
if (phaseCheck && !phaseCheck.ok) {
|
|
2471
2854
|
return {
|
|
2855
|
+
...advisoryTime,
|
|
2472
2856
|
status: 'blocked',
|
|
2473
2857
|
verification: 'unverified',
|
|
2474
2858
|
acceptance,
|
|
@@ -2500,6 +2884,7 @@ export function adjudicateResult({ output, strict = true, expectedAcceptance = [
|
|
|
2500
2884
|
: checkCommFormatCompliance(payload, text, Array.isArray(expectedAcceptance) ? expectedAcceptance.length : 0);
|
|
2501
2885
|
if (!commFormat.compliant) {
|
|
2502
2886
|
return {
|
|
2887
|
+
...advisoryTime,
|
|
2503
2888
|
status: 'blocked',
|
|
2504
2889
|
verification: 'unverified',
|
|
2505
2890
|
acceptance,
|
|
@@ -2515,6 +2900,7 @@ export function adjudicateResult({ output, strict = true, expectedAcceptance = [
|
|
|
2515
2900
|
};
|
|
2516
2901
|
}
|
|
2517
2902
|
return {
|
|
2903
|
+
...advisoryTime,
|
|
2518
2904
|
status: 'done',
|
|
2519
2905
|
verification: hasUnverified ? 'unverified' : 'structured',
|
|
2520
2906
|
acceptance,
|
|
@@ -2576,6 +2962,17 @@ export function buildUpdateMessage(update) {
|
|
|
2576
2962
|
...(update.instructionOverdue === undefined ? {} : { instructionOverdue: update.instructionOverdue }),
|
|
2577
2963
|
...(update.handoffs === undefined ? {} : { handoffs: update.handoffs }),
|
|
2578
2964
|
...(update.reportedAt === undefined ? {} : { reportedAt: update.reportedAt }),
|
|
2965
|
+
/*
|
|
2966
|
+
* [2.2.0][T3/O-3c] 协商上限持久化臂(方案 §1③ O-3c:「专家预告(O-2a)经
|
|
2967
|
+
* 主 Agent 确认后写入 timeoutMs(经 dsh_workplan_update 新字段或计划消息)」)。
|
|
2968
|
+
*
|
|
2969
|
+
* 主 Agent 把确认后的 timeoutMs 随改判/进度更新记录留档,刷新/重启后按同
|
|
2970
|
+
* 顺序回放(回放侧 update 载荷的字段透传白名单在 src/runtime.ts:2931,属
|
|
2971
|
+
* T4 接线范围;applyStatus 侧已接受该字段);缺省合法(undefined 跳过,
|
|
2972
|
+
* 不改 2.1.x 语义)。计划内该字段的读取/派生见 readSubtasks +
|
|
2973
|
+
* deriveSubtaskTimeoutMs。
|
|
2974
|
+
*/
|
|
2975
|
+
...(update.timeoutMs === undefined ? {} : { timeoutMs: update.timeoutMs }),
|
|
2579
2976
|
...(update.revision === undefined ? {} : { revision: update.revision }),
|
|
2580
2977
|
at: update.at ?? Date.now(),
|
|
2581
2978
|
};
|
|
@@ -2693,6 +3090,20 @@ export function applyResultStatuses(statuses, result) {
|
|
|
2693
3090
|
const replayedClosure = entry.status === 'done' && entry.closure === undefined
|
|
2694
3091
|
? 'reported'
|
|
2695
3092
|
: entry.closure;
|
|
3093
|
+
/*
|
|
3094
|
+
* [2.2.1][T5][F1] 回放容错:结果载荷里的通道字段可能是 null / 非法值
|
|
3095
|
+
* (旧版本遗留、人工改日志、或早期重建写回的脏值)。applyStatus 是写入
|
|
3096
|
+
* 单点校验,遇到非法值会整条抛错,被下面的 catch 吞掉后这一行的
|
|
3097
|
+
* done / summary / verification / acceptance 全都不落地 —— 一条完成行
|
|
3098
|
+
* 回放成 pending 的假阴性(T4 残余项复核 A2/B2 实测)。
|
|
3099
|
+
*
|
|
3100
|
+
* 这里在进入 patch 之前判定:只有能通过校验的值才参与回放,null / 非法值
|
|
3101
|
+
* 按「字段缺失」处理。applyStatus 的 fail-closed 校验保持不变(其它写入方
|
|
3102
|
+
* 仍然不能写脏值),本改动只影响「读旧日志」这一侧。
|
|
3103
|
+
*/
|
|
3104
|
+
const replayedNoticeChannel = entry.noticeChannel !== undefined && validateNoticeChannel(entry.noticeChannel).ok
|
|
3105
|
+
? entry.noticeChannel
|
|
3106
|
+
: undefined;
|
|
2696
3107
|
try {
|
|
2697
3108
|
next = applyStatus(next, entry.subtaskId, {
|
|
2698
3109
|
status: entry.status,
|
|
@@ -2724,6 +3135,16 @@ export function applyResultStatuses(statuses, result) {
|
|
|
2724
3135
|
instructionSeq: entry.instructionSeq,
|
|
2725
3136
|
instructionOverdue: entry.instructionOverdue,
|
|
2726
3137
|
reportedAt: entry.reportedAt,
|
|
3138
|
+
// [2.2.0][T3/O-2c/O-3c] 柔性时长协商留档字段随结果快照回放(方案 §2.5
|
|
3139
|
+
// 「旧消息回放零改动读取」:字段缺失时 applyStatus 分支自动跳过)。
|
|
3140
|
+
timeSpentMinutes: entry.timeSpentMinutes,
|
|
3141
|
+
finalEstimateMinutes: entry.finalEstimateMinutes,
|
|
3142
|
+
timeoutMs: entry.timeoutMs,
|
|
3143
|
+
// [2.2.0][T3/O-2a] 子→主预告通道结论必须随结果快照回放;写入由
|
|
3144
|
+
// applyStatus 单点校验,非法值在 catch 中 fail-closed(不落脏值)。
|
|
3145
|
+
// [2.2.1][T5][F1] 但非法值只能丢「这个字段」,不能丢「整条结果行」:
|
|
3146
|
+
// 上面的 replayedNoticeChannel 已把 null / 非法值归一为 undefined。
|
|
3147
|
+
noticeChannel: replayedNoticeChannel,
|
|
2727
3148
|
// [1.11.0] 回报证据与重规划留档必须随结果快照回放(T7 C-06/C-11)。
|
|
2728
3149
|
report: entry.report,
|
|
2729
3150
|
replannedReason: entry.replannedReason,
|
|
@@ -2863,6 +3284,47 @@ export function applyStatus(statuses, subtaskId, patch) {
|
|
|
2863
3284
|
}
|
|
2864
3285
|
if (patch.reportedAt !== undefined)
|
|
2865
3286
|
next.reportedAt = numberOrNull(patch.reportedAt);
|
|
3287
|
+
/*
|
|
3288
|
+
* [2.2.0][T3/O-2c/O-3c] 柔性时长协商的留档字段(方案 §2.2/§2.4/§2.5)。
|
|
3289
|
+
*
|
|
3290
|
+
* timeSpentMinutes/finalEstimateMinutes 是结果块回填的实际耗时与收尾预估
|
|
3291
|
+
* (纯 advisory:缺失或非法不判不合规,按缺省处理;不参与可交付判定,
|
|
3292
|
+
* 方案 §2.5「时间字段纯 advisory:不参与可交付判定,不加拒绝码」);
|
|
3293
|
+
* timeoutMs 是 O-3c「预告经主 Agent 确认后写入」的协商上限留档,校验与
|
|
3294
|
+
* readSubtasks 同口径(正数毫秒;null 表示清除)。三者只写同一条状态条目,
|
|
3295
|
+
* 走 StatusEntry 未知字段保留通道,旧消息回放零改动。
|
|
3296
|
+
*/
|
|
3297
|
+
if (patch.timeSpentMinutes !== undefined) {
|
|
3298
|
+
next.timeSpentMinutes = readAdvisoryMinutes(patch.timeSpentMinutes) ?? null;
|
|
3299
|
+
}
|
|
3300
|
+
if (patch.finalEstimateMinutes !== undefined) {
|
|
3301
|
+
next.finalEstimateMinutes = readAdvisoryMinutes(patch.finalEstimateMinutes) ?? null;
|
|
3302
|
+
}
|
|
3303
|
+
if (patch.timeoutMs !== undefined) {
|
|
3304
|
+
if (patch.timeoutMs === null)
|
|
3305
|
+
next.timeoutMs = null;
|
|
3306
|
+
else {
|
|
3307
|
+
const value = Number(patch.timeoutMs);
|
|
3308
|
+
if (!Number.isFinite(value) || value <= 0) {
|
|
3309
|
+
throw new PlanError('timeoutMs 必须是正数毫秒(协商上限)', 'INVALID_TIMEOUT_MS');
|
|
3310
|
+
}
|
|
3311
|
+
next.timeoutMs = value;
|
|
3312
|
+
}
|
|
3313
|
+
}
|
|
3314
|
+
/*
|
|
3315
|
+
* [2.2.0][T3/O-2a] 子→主预告通道的可观测条目(方案 §2.4 状态行字段)。
|
|
3316
|
+
*
|
|
3317
|
+
* 这条字段存在的理由就是「不静默丢失」:旧实现里预告发不出去,主 Agent
|
|
3318
|
+
* 只能从子 Agent 的自述里猜,计划记录上没有任何痕迹。现在通道的
|
|
3319
|
+
* target / caller / at / observedAt / reason 全部落在状态行,写入前统一
|
|
3320
|
+
* 校验(未知状态或未知原因直接拒绝),回放与刷新都不会丢。
|
|
3321
|
+
*/
|
|
3322
|
+
if (patch.noticeChannel !== undefined) {
|
|
3323
|
+
const checked = validateNoticeChannel(patch.noticeChannel);
|
|
3324
|
+
if (!checked.ok)
|
|
3325
|
+
throw new PlanError(`非法 noticeChannel:${checked.error}`, 'INVALID_NOTICE_CHANNEL');
|
|
3326
|
+
next.noticeChannel = checked.value;
|
|
3327
|
+
}
|
|
2866
3328
|
/*
|
|
2867
3329
|
* [1.11.0] 完成回报与重规划的留档字段(T7 C-06/C-11)。
|
|
2868
3330
|
*
|
|
@@ -4064,7 +4526,21 @@ export function findSubtask(plan, subtaskId) {
|
|
|
4064
4526
|
}
|
|
4065
4527
|
return null;
|
|
4066
4528
|
}
|
|
4067
|
-
export function buildChildPrompt({ plan, subtask, stage, dependencyResults, cwd, conversationContext = '', statuses = null, previousFailure = null, lessonsBrief = '',
|
|
4529
|
+
export function buildChildPrompt({ plan, subtask, stage, dependencyResults, cwd, conversationContext = '', statuses = null, previousFailure = null, lessonsBrief = '',
|
|
4530
|
+
/*
|
|
4531
|
+
* [2.2.0][T3/O-2a] 子→主预告通道的目标。
|
|
4532
|
+
*
|
|
4533
|
+
* 宿主只对**非 caller** 投递注入父会话 id(dsh-subagent/lib/index.js:1466),
|
|
4534
|
+
* 而本插件用 `delivery: 'caller'` 派发,所以这段 id 必须由插件自己注入。
|
|
4535
|
+
* 不注入时的旧行为是让子 Agent 去喊 `"lead"`——那不是任何会话的 id,
|
|
4536
|
+
* 真实派发中只会得到 `subagent "lead" is unavailable`。
|
|
4537
|
+
*/
|
|
4538
|
+
leadAgentId = '', leadAgentIdSource = 'none', }) {
|
|
4539
|
+
const noticeTarget = readLeadAgentId(leadAgentId);
|
|
4540
|
+
const noticeCall = leadNoticeCallForm(noticeTarget);
|
|
4541
|
+
const noticeTargetLine = noticeTarget
|
|
4542
|
+
? `- 目标会话 id(**由插件注入,唯一合法目标**):\`${noticeTarget}\`(来源:${leadAgentIdSource || 'unknown'})。它就是本轮主 Agent 的会话 id,宿主的父子血缘校验只认它。`
|
|
4543
|
+
: `- **本提示词没有注入父会话 id**(来源:${leadAgentIdSource || 'none'}):禁止猜测、禁止自行拼一个 id。跳过 send_message 预告,改为在结果块首行写 \`noticeChannel: {"target":"${NOTICE_TARGET_MISSING_TEXT}","at":<毫秒时间戳>,"error":"LEAD_ID_MISSING"}\`——供主 Agent 阅读;**插件不解析这一行**,通道结论以状态行观测为准。`;
|
|
4068
4544
|
/*
|
|
4069
4545
|
* Every field below is read defensively.
|
|
4070
4546
|
*
|
|
@@ -4197,6 +4673,7 @@ export function buildChildPrompt({ plan, subtask, stage, dependencyResults, cwd,
|
|
|
4197
4673
|
*/
|
|
4198
4674
|
return defuseSessionReferenceText([
|
|
4199
4675
|
`你是「${departmentLabel(subtask.department)}」部门的执行 Agent,只负责下面这一个子任务。`,
|
|
4676
|
+
`专家定位:${DEPARTMENT_EXPERT_STANDARD.child}`,
|
|
4200
4677
|
'',
|
|
4201
4678
|
`全局任务:${understanding.originalRequest ?? '(未记录)'}`,
|
|
4202
4679
|
`最终交付物:${understanding.deliverable ?? '(未记录)'}`,
|
|
@@ -4233,6 +4710,7 @@ export function buildChildPrompt({ plan, subtask, stage, dependencyResults, cwd,
|
|
|
4233
4710
|
: []),
|
|
4234
4711
|
'',
|
|
4235
4712
|
'执行要求:',
|
|
4713
|
+
'- 以全球顶尖专家标准执行:先诊断根因再动手,产出与证据要能通过同行复核,不交浅层补丁、不遗留问题。',
|
|
4236
4714
|
'- 只完成本子任务,不擅自扩大范围;不要派生新的 Agent。',
|
|
4237
4715
|
'- 你没有派发权限,也不能重启或安装任何服务;遇到这类步骤,必须先上报(见下方「遇阻上报」),再停止推进等待指示,不要空转。',
|
|
4238
4716
|
'- 不得编造事实、文件、命令结果或证据;无法确认时明确写“未验证”。',
|
|
@@ -4242,6 +4720,30 @@ export function buildChildPrompt({ plan, subtask, stage, dependencyResults, cwd,
|
|
|
4242
4720
|
'- 如果确实无法完成,第一行输出 `BLOCKED: 原因`,并按下方「遇阻上报」给出 question。',
|
|
4243
4721
|
'- 完成后用简洁中文汇报:做了什么、证据/文件、验收结果、遗留问题。',
|
|
4244
4722
|
'',
|
|
4723
|
+
/*
|
|
4724
|
+
* [2.2.0][T3/O-2a] 柔性时长协商协议(方案 §2.6 #3:「开工前预告、超预期
|
|
4725
|
+
* 预警、完成即回报」;O-1a①+O-2a+O-4a 合并一段,矩阵 Z1 三条款一次插入)。
|
|
4726
|
+
* 时间是协商出来的安全兜底,不是固定交付期限(方案 §0/§3.2)。
|
|
4727
|
+
*
|
|
4728
|
+
* 2026-11-08 修复(真实环境复现 `subagent "lead" is unavailable`):
|
|
4729
|
+
* 旧文案写的是 `send_message(target: "lead")`——字段名与宿主 schema
|
|
4730
|
+
* 不一致(宿主只有 `agent_id`),值 `"lead"` 也不是任何会话 id,于是
|
|
4731
|
+
* 预告在目标解析阶段必然失败。现在改为:注入真实父会话 id + 用宿主
|
|
4732
|
+
* 契约里的字段名 + 明确失败后的确定性重试与留痕,不再有「猜目标」的余地。
|
|
4733
|
+
*/
|
|
4734
|
+
'柔性时长协商协议(不设固定完成时间;时间是协商出来的安全兜底,不是固定交付期限):',
|
|
4735
|
+
noticeTargetLine,
|
|
4736
|
+
`- 开工前先报预估时长(预计完成本子任务要多久就报多久):用 \`${noticeCall}\` 报预估完成时长,新预估覆盖旧预估;预估仅供参考、非承诺,实际时长协商决定。`,
|
|
4737
|
+
`- 发现预计将超预估时,立即用同一个目标报新预估并申请延期(说明还要多久、为什么),不要等超时才预警。`,
|
|
4738
|
+
`- 完成即回报:用同一个目标报核心结论(做了什么、证据/文件、验收结果),不要等整轮结束。`,
|
|
4739
|
+
...(noticeTarget
|
|
4740
|
+
? [
|
|
4741
|
+
'- 失败后的确定性处理(禁止静默丢弃):`send_message` 若返回错误(`is unavailable` / `UNAUTHORIZED` / 工具不存在),先在汇报首行原样记录 `noticeChannel: {"target":"' + noticeTarget + '","at":<毫秒时间戳>,"error":"<错误原文>"}`,再用**同一个** agent_id 重试一次;仍失败就继续把子任务做完,把这条记录留在结果里(供主 Agent 阅读;插件不解析这一行,通道结论以状态行观测为准)。**不得改用其它目标,也不得向任何非本轮父会话发送**——那是越权发送,会触发宿主 lineage 拒绝。',
|
|
4742
|
+
]
|
|
4743
|
+
: []),
|
|
4744
|
+
// [T3 扩展点·T6] 供 T6 在此行之后追加「完成即时通知」条款(O-1a 插件兜底通道语义);上方三条款为 O-1a①+O-2a+O-4a 合并协议段(矩阵 Z1),既有条款不得删改。
|
|
4745
|
+
// [2.2.0][T6/O-1a] 完成即时通知条款(插件兜底通道):完成即报是第一通道(见上方「完成即回报」);插件另设兜底——子任务结算成功后立即向主会话推送一条含子任务 ID、摘要、验收计数与用时的即时通知,不等待整轮结束。兜底不替代主动回报。
|
|
4746
|
+
'',
|
|
4245
4747
|
'遇阻上报(强制,先于继续动作):',
|
|
4246
4748
|
'- 出现以下任一情况,第一动作是上报,不是猜测、绕过或静默继续:缺少权限/输入/依赖产物;需求自相矛盾;无法验证;同一命令连续两次失败;需要主 Agent 决定方向。',
|
|
4247
4749
|
'- 优先调用工具:`dsh_workplan_escalate({ "subtaskId": "<你的子任务 ID>", "question": "需要主 Agent 回答的单个问题", "options": ["可选项 A", "可选项 B"], "needs": ["需要谁提供什么"] })`。调用成功后停止推进,只做只读核对。',
|
|
@@ -4251,13 +4753,20 @@ export function buildChildPrompt({ plan, subtask, stage, dependencyResults, cwd,
|
|
|
4251
4753
|
'',
|
|
4252
4754
|
'结果回传(必填):在汇报的最后附上一个结构化结果块,主 Agent 会按它逐项核对,不再只依赖自述。',
|
|
4253
4755
|
EVIDENCE_MARKER_BEGIN,
|
|
4254
|
-
'{"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":[]}',
|
|
4756
|
+
'{"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}',
|
|
4255
4757
|
EVIDENCE_MARKER_END,
|
|
4256
4758
|
'- status 只能是 done / blocked / partial;partial 会被当作受阻处理。',
|
|
4257
4759
|
'- acceptance 必须逐条覆盖上面的验收标准:criterion 以 A1、A2… 开头对号入座(编号不可省略);result 只能是 pass / fail / unverified。无法确认就写 unverified,不要写 pass。',
|
|
4258
4760
|
'- artifacts 写你实际产出或修改的文件(kind=file,ref 用相对路径)、链接(kind=url)或说明(kind=note)。',
|
|
4259
4761
|
'- needs 写需要其他部门配合的事项,每条写清「哪个部门 + 需要什么 + 用来做什么」;它会被登记为待处理需求,主 Agent 必须处置后计划才能交付。不要直连其他子 Agent。',
|
|
4260
4762
|
'- question/options 只在受阻上报时填写;done 时保持空字符串/空数组。',
|
|
4763
|
+
/*
|
|
4764
|
+
* [2.2.0][T3/O-2c] 用时回填字段(方案 §2.2/§2.4 结果块契约:「模板增加
|
|
4765
|
+
* timeSpentMinutes、finalEstimateMinutes 字段」)。纯 advisory:F1-F9 与
|
|
4766
|
+
* 既有字段零改动,缺失/非法即省略,不判不合规、不影响验收判定(方案 §2.5
|
|
4767
|
+
* 「时间字段纯 advisory」)。
|
|
4768
|
+
*/
|
|
4769
|
+
'- timeSpentMinutes / finalEstimateMinutes(可选,整数分钟):完成后把实际耗时与最终预估回填进结果块,未知可省略;两项仅供参考与协商审计,不影响验收判定。',
|
|
4261
4770
|
'- 整块不超过 12000 字符;不要把这段模板本身抄进结果块。',
|
|
4262
4771
|
'',
|
|
4263
4772
|
/*
|