dsh-workplan 2.3.2 → 3.0.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 +123 -0
- package/README.en.md +2 -2
- package/README.md +2 -2
- package/README.zh.md +2 -2
- package/client.js +103 -3
- package/docs/cc/ADV-FSP-FUNCTIONAL-SPEC.md +3 -2
- package/docs/cc/AVA-VULNERABILITY-ANALYSIS.md +12 -2
- package/docs/cc/SECURITY-TARGET.md +1 -0
- package/docs/release-record-2.3.2-20261110.md +25 -0
- package/lib/client.js +103 -3
- package/lib/comm-format.js +58 -6
- package/lib/criterion.js +215 -0
- package/lib/dept-journal.js +319 -0
- package/lib/host.js +279 -15
- package/lib/llm-rules.js +478 -0
- package/lib/plan.js +1537 -136
- package/lib/replan.js +66 -44
- package/lib/runtime.js +3458 -628
- package/lib/three-phase.js +106 -20
- package/lib/understanding.js +18 -3
- package/lib/v3-contract.js +431 -0
- package/lib/watchdog.js +6 -1
- package/package.json +2 -2
- package/src/client.ts +110 -3
- package/src/comm-format.ts +63 -5
- package/src/criterion.ts +262 -0
- package/src/dept-journal.ts +373 -0
- package/src/host.ts +288 -16
- package/src/llm-rules.ts +667 -0
- package/src/plan.ts +1560 -130
- package/src/replan.ts +64 -42
- package/src/runtime.ts +2958 -200
- package/src/three-phase.ts +147 -20
- package/src/understanding.ts +20 -3
- package/src/v3-contract.ts +470 -0
- package/src/watchdog.ts +6 -1
package/lib/replan.js
CHANGED
|
@@ -188,7 +188,7 @@ function mergeReplacement(old, replacement, id, reason) {
|
|
|
188
188
|
* (T4 D-T4-03)。修复前 add 接受 14 条依赖、200 条 inputs 与 16 万字符
|
|
189
189
|
* 载荷,这些计划再也回灌不了 validatePlan,却能被真实派发。
|
|
190
190
|
*/
|
|
191
|
-
function replanFieldError(raw) {
|
|
191
|
+
function replanFieldError(raw, allowedEfforts) {
|
|
192
192
|
const list = (key, max, itemMax, required = false) => {
|
|
193
193
|
const value = raw?.[key];
|
|
194
194
|
if (value === undefined)
|
|
@@ -221,6 +221,10 @@ function replanFieldError(raw) {
|
|
|
221
221
|
};
|
|
222
222
|
/*
|
|
223
223
|
* [2.2.7][T4/五档+G1] reasoningEffort 入口白名单(replace/add 两路共用本函数):
|
|
224
|
+
* [2.3.9][T3/同步点] 此处按 REASONING_EFFORTS **存储全集五档**校验是刻意决策:
|
|
225
|
+
* 重规划的输入可能来自回放/他模型计划,删档会破坏零迁移契约;模型家族收窄
|
|
226
|
+
* 统一发生在派发入口(runtime.ts 静态收窄 + qwen-rule/non-qwen-rule 留痕)与
|
|
227
|
+
* 规划校验(validatePlan options.allowedEfforts),口径见 plan.ts L214-231 注释。
|
|
224
228
|
* 与 plan.ts readSubtasks 语义对齐——缺失/显式 null 合法(replace 继承旧行、
|
|
225
229
|
* add 留给派发期回落 high),非缺失值必须是 REASONING_EFFORTS 五档之一
|
|
226
230
|
* (low / medium / high / xhigh / max),非法值拒绝、不改写。补上此校验前,
|
|
@@ -230,10 +234,17 @@ function replanFieldError(raw) {
|
|
|
230
234
|
const effortError = effort === undefined || effort === null
|
|
231
235
|
? null
|
|
232
236
|
: typeof effort !== 'string' || !REASONING_EFFORTS.includes(effort)
|
|
233
|
-
? 'reasoningEffort 必须是 low / medium / high / xhigh / max 之一(缺失合法:replace 继承旧行、add
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
+
? 'reasoningEffort 必须是 low / medium / high / xhigh / max 之一(缺失合法:replace 继承旧行、add 派发期回落;非法值拒绝,不改写;传入模型家族集合时进一步收窄为该集合)'
|
|
238
|
+
/*
|
|
239
|
+
* [2.3.9][T3] 模型感知收窄口径(用户要求 1/2;与 plan.ts validatePlan、
|
|
240
|
+
* runtime 派发侧同一真源):调用方传入当前模型家族等级集合时,五档合规
|
|
241
|
+
* 但家族越界的档位(如 qwen 系的 high/max)同样拒绝并点名集合,不改写。
|
|
242
|
+
*/
|
|
243
|
+
: Array.isArray(allowedEfforts) && allowedEfforts.length > 0 && !allowedEfforts.includes(effort)
|
|
244
|
+
? `reasoningEffort "${effort}" 不在当前模型家族的推理等级集合 {${allowedEfforts.join(' / ')}} 内(qwen 系仅 low / medium / xhigh;非 qwen 系仅 low / high / max),必须改用集合内档位`
|
|
245
|
+
: null;
|
|
246
|
+
return list('dependsOn', 12, MAX_SUBTASKS - 1)
|
|
247
|
+
?? list('method', 8, 800)
|
|
237
248
|
?? list('inputs', 12, 800)
|
|
238
249
|
?? list('outputs', 12, 800)
|
|
239
250
|
?? list('acceptance', 8, 800)
|
|
@@ -323,7 +334,7 @@ export function planReplan(plan, changes, options = {}) {
|
|
|
323
334
|
if (replacement.department !== undefined && replanDepartment(replacement.department) === null) {
|
|
324
335
|
return fail(REPLAN_CODES.INVALID_REPLACEMENT, `replacement.department 不是合法部门:${String(replacement.department)}`);
|
|
325
336
|
}
|
|
326
|
-
const replacementError = replanFieldError(replacement);
|
|
337
|
+
const replacementError = replanFieldError(replacement, options?.allowedEfforts);
|
|
327
338
|
if (replacementError)
|
|
328
339
|
return fail(REPLAN_CODES.INVALID_REPLACEMENT, `replacement 字段不合规:${replacementError}`);
|
|
329
340
|
const requestedId = typeof replacement.id === 'string' ? replacement.id.trim() : '';
|
|
@@ -382,7 +393,7 @@ export function planReplan(plan, changes, options = {}) {
|
|
|
382
393
|
if (department === null) {
|
|
383
394
|
return fail(REPLAN_CODES.INVALID_SUBTASK, `newSubtask.department 不是合法部门:${String(raw.department)}`);
|
|
384
395
|
}
|
|
385
|
-
const fieldError = replanFieldError(raw);
|
|
396
|
+
const fieldError = replanFieldError(raw, options?.allowedEfforts);
|
|
386
397
|
if (fieldError)
|
|
387
398
|
return fail(REPLAN_CODES.INVALID_SUBTASK, `newSubtask 字段不合规:${fieldError}`);
|
|
388
399
|
const goal = typeof raw.objective === 'string' ? raw.objective.trim() : '';
|
|
@@ -593,23 +604,24 @@ export function applyReplanStatuses(statuses, payload) {
|
|
|
593
604
|
}
|
|
594
605
|
return next;
|
|
595
606
|
}
|
|
596
|
-
/** durable `workplan-replan`
|
|
607
|
+
/** durable `workplan-replan` 消息:[T7] 可见文本置空(过程事件,C2),全量信封随 source.durable 落盘(选项 A)。 */
|
|
597
608
|
export function buildReplanMessage(payload) {
|
|
598
609
|
const changed = payload.marks.map((mark) => `${mark.subtaskId}→${mark.replacedBy.length ? mark.replacedBy.join('、') : '撤销'}`);
|
|
599
610
|
const summary = truncate(`【重规划 r${payload.revision}】${changed.join(',') || '新增子任务'}`, 300);
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
REPLAN_MARKER_BEGIN,
|
|
607
|
-
JSON.stringify(payload),
|
|
608
|
-
REPLAN_MARKER_END,
|
|
609
|
-
];
|
|
610
|
-
return makeUserMessage(lines.join('\n'), { kind: 'workplan-replan', form: 'notice', summary });
|
|
611
|
+
/*
|
|
612
|
+
* [T7] 重规划是过程事件:主 Agent 从 dsh_workplan_replan 的工具返回(按需
|
|
613
|
+
* 通道,不裁剪)已知晓新行与后续动作;注入正文置空,信封仍随事件落盘,
|
|
614
|
+
* parseReplanMessage 先读元数据回退旧文本标记(旧消息零迁移,C4)。
|
|
615
|
+
*/
|
|
616
|
+
return makeUserMessage('', { kind: 'workplan-replan', form: 'notice', summary, durable: payload });
|
|
611
617
|
}
|
|
612
618
|
export function parseReplanMessage(message) {
|
|
619
|
+
/* [T7] 先读元数据信封(source.durable,选项 A),回退旧文本标记。 */
|
|
620
|
+
const durable = message?.source?.durable;
|
|
621
|
+
if (isRecord(durable) && durable.kind === 'workplan-replan'
|
|
622
|
+
&& durable.plan && Array.isArray(durable.marks) && Array.isArray(durable.added)) {
|
|
623
|
+
return durable;
|
|
624
|
+
}
|
|
613
625
|
const text = messageText(message);
|
|
614
626
|
const begin = text.indexOf(REPLAN_MARKER_BEGIN);
|
|
615
627
|
const end = text.indexOf(REPLAN_MARKER_END);
|
|
@@ -666,44 +678,54 @@ export function buildChangeRequestMessage(payload, context = {}) {
|
|
|
666
678
|
'1. 变更影响范围:调用 dsh_workplan_replan,用 cancel/replace/add 逐项说明受影响的子任务;旧行会保留为「已重规划」并可追溯。',
|
|
667
679
|
'2. 只是补充说明、不改范围:调用 dsh_workplan_update 把说明写进对应子任务的 note。',
|
|
668
680
|
'3. 变更尚未明确:先向用户确认,再重规划;不要用旧计划直接交付。',
|
|
669
|
-
'',
|
|
670
|
-
CHANGE_MARKER_BEGIN,
|
|
671
|
-
JSON.stringify(payload),
|
|
672
|
-
CHANGE_MARKER_END,
|
|
673
681
|
];
|
|
682
|
+
/*
|
|
683
|
+
* [T7] 变更原文是用户输入而非插件噪音:正文保留(闸门对 workplan-change
|
|
684
|
+
* 豁免上限),仅把 JSON 信封从正文移入 source.durable(选项 A);
|
|
685
|
+
* parseChangeRequestMessage 先读元数据回退旧文本标记(旧消息零迁移)。
|
|
686
|
+
*/
|
|
674
687
|
return makeUserMessage(lines.join('\n'), {
|
|
675
688
|
kind: 'workplan-change',
|
|
676
689
|
form: 'notice',
|
|
677
690
|
summary: truncate(`需求变更已记录 #${payload.seq}`, 200),
|
|
691
|
+
durable: payload,
|
|
678
692
|
});
|
|
679
693
|
}
|
|
680
694
|
export function parseChangeRequestMessage(message) {
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
if (!isRecord(payload) || payload.kind !== 'workplan-change')
|
|
695
|
+
/* [T7] 先读元数据信封(source.durable,选项 A),回退旧文本标记。 */
|
|
696
|
+
let payload = message?.source?.durable;
|
|
697
|
+
if (!isRecord(payload) || payload.kind !== 'workplan-change') {
|
|
698
|
+
const text = messageText(message);
|
|
699
|
+
const begin = text.indexOf(CHANGE_MARKER_BEGIN);
|
|
700
|
+
const end = text.indexOf(CHANGE_MARKER_END);
|
|
701
|
+
if (begin < 0 || end <= begin)
|
|
689
702
|
return null;
|
|
690
|
-
|
|
703
|
+
try {
|
|
704
|
+
payload = JSON.parse(text.slice(begin + CHANGE_MARKER_BEGIN.length, end).trim());
|
|
705
|
+
}
|
|
706
|
+
catch {
|
|
691
707
|
return null;
|
|
692
|
-
|
|
693
|
-
kind: 'workplan-change',
|
|
694
|
-
planId: String(payload.planId ?? ''),
|
|
695
|
-
seq: Number.isInteger(Number(payload.seq)) ? Number(payload.seq) : 1,
|
|
696
|
-
at: Number(payload.at) || Date.now(),
|
|
697
|
-
turn: Number.isInteger(Number(payload.turn)) ? Number(payload.turn) : null,
|
|
698
|
-
text: truncate(payload.text, 4000),
|
|
699
|
-
};
|
|
708
|
+
}
|
|
700
709
|
}
|
|
701
|
-
|
|
710
|
+
if (!isRecord(payload) || payload.kind !== 'workplan-change')
|
|
702
711
|
return null;
|
|
703
|
-
|
|
712
|
+
if (typeof payload.text !== 'string' || !payload.text.trim())
|
|
713
|
+
return null;
|
|
714
|
+
return {
|
|
715
|
+
kind: 'workplan-change',
|
|
716
|
+
planId: String(payload.planId ?? ''),
|
|
717
|
+
seq: Number.isInteger(Number(payload.seq)) ? Number(payload.seq) : 1,
|
|
718
|
+
at: Number(payload.at) || Date.now(),
|
|
719
|
+
turn: Number.isInteger(Number(payload.turn)) ? Number(payload.turn) : null,
|
|
720
|
+
text: truncate(payload.text, 4000),
|
|
721
|
+
};
|
|
704
722
|
}
|
|
705
|
-
/**
|
|
723
|
+
/**
|
|
724
|
+
* 从计划定义里读重规划修订号(写入时放在 plan.planRevision,见本文件
|
|
725
|
+
* planReplan() 的 next.planRevision = revision;runtime 消费侧同样读
|
|
726
|
+
* plan.planRevision,见 runtime.ts 的 Number(plan?.planRevision ?? 0))。
|
|
727
|
+
*/
|
|
706
728
|
export function planRevisionOf(plan) {
|
|
707
|
-
const revision = Number(plan?.
|
|
729
|
+
const revision = Number(plan?.planRevision ?? 0);
|
|
708
730
|
return Number.isFinite(revision) && revision > 0 ? revision : 0;
|
|
709
731
|
}
|