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/src/replan.ts
CHANGED
|
@@ -237,7 +237,7 @@ function mergeReplacement(old: any, replacement: any, id: string, reason: string
|
|
|
237
237
|
* (T4 D-T4-03)。修复前 add 接受 14 条依赖、200 条 inputs 与 16 万字符
|
|
238
238
|
* 载荷,这些计划再也回灌不了 validatePlan,却能被真实派发。
|
|
239
239
|
*/
|
|
240
|
-
function replanFieldError(raw: any): string | null {
|
|
240
|
+
function replanFieldError(raw: any, allowedEfforts?: readonly string[] | null): string | null {
|
|
241
241
|
const list = (key: string, max: number, itemMax: number, required = false): string | null => {
|
|
242
242
|
const value = raw?.[key]
|
|
243
243
|
if (value === undefined) return required ? `${key} 不能为空` : null
|
|
@@ -260,6 +260,10 @@ function replanFieldError(raw: any): string | null {
|
|
|
260
260
|
}
|
|
261
261
|
/*
|
|
262
262
|
* [2.2.7][T4/五档+G1] reasoningEffort 入口白名单(replace/add 两路共用本函数):
|
|
263
|
+
* [2.3.9][T3/同步点] 此处按 REASONING_EFFORTS **存储全集五档**校验是刻意决策:
|
|
264
|
+
* 重规划的输入可能来自回放/他模型计划,删档会破坏零迁移契约;模型家族收窄
|
|
265
|
+
* 统一发生在派发入口(runtime.ts 静态收窄 + qwen-rule/non-qwen-rule 留痕)与
|
|
266
|
+
* 规划校验(validatePlan options.allowedEfforts),口径见 plan.ts L214-231 注释。
|
|
263
267
|
* 与 plan.ts readSubtasks 语义对齐——缺失/显式 null 合法(replace 继承旧行、
|
|
264
268
|
* add 留给派发期回落 high),非缺失值必须是 REASONING_EFFORTS 五档之一
|
|
265
269
|
* (low / medium / high / xhigh / max),非法值拒绝、不改写。补上此校验前,
|
|
@@ -269,10 +273,17 @@ function replanFieldError(raw: any): string | null {
|
|
|
269
273
|
const effortError = effort === undefined || effort === null
|
|
270
274
|
? null
|
|
271
275
|
: typeof effort !== 'string' || !REASONING_EFFORTS.includes(effort)
|
|
272
|
-
? 'reasoningEffort 必须是 low / medium / high / xhigh / max 之一(缺失合法:replace 继承旧行、add
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
+
? 'reasoningEffort 必须是 low / medium / high / xhigh / max 之一(缺失合法:replace 继承旧行、add 派发期回落;非法值拒绝,不改写;传入模型家族集合时进一步收窄为该集合)'
|
|
277
|
+
/*
|
|
278
|
+
* [2.3.9][T3] 模型感知收窄口径(用户要求 1/2;与 plan.ts validatePlan、
|
|
279
|
+
* runtime 派发侧同一真源):调用方传入当前模型家族等级集合时,五档合规
|
|
280
|
+
* 但家族越界的档位(如 qwen 系的 high/max)同样拒绝并点名集合,不改写。
|
|
281
|
+
*/
|
|
282
|
+
: Array.isArray(allowedEfforts) && allowedEfforts.length > 0 && !allowedEfforts.includes(effort)
|
|
283
|
+
? `reasoningEffort "${effort}" 不在当前模型家族的推理等级集合 {${allowedEfforts.join(' / ')}} 内(qwen 系仅 low / medium / xhigh;非 qwen 系仅 low / high / max),必须改用集合内档位`
|
|
284
|
+
: null
|
|
285
|
+
return list('dependsOn', 12, MAX_SUBTASKS - 1)
|
|
286
|
+
?? list('method', 8, 800)
|
|
276
287
|
?? list('inputs', 12, 800)
|
|
277
288
|
?? list('outputs', 12, 800)
|
|
278
289
|
?? list('acceptance', 8, 800)
|
|
@@ -360,7 +371,7 @@ export function planReplan(plan: any, changes: any, options: any = {}): ReplanRe
|
|
|
360
371
|
if (replacement.department !== undefined && replanDepartment(replacement.department) === null) {
|
|
361
372
|
return fail(REPLAN_CODES.INVALID_REPLACEMENT, `replacement.department 不是合法部门:${String(replacement.department)}`)
|
|
362
373
|
}
|
|
363
|
-
const replacementError = replanFieldError(replacement)
|
|
374
|
+
const replacementError = replanFieldError(replacement, options?.allowedEfforts)
|
|
364
375
|
if (replacementError) return fail(REPLAN_CODES.INVALID_REPLACEMENT, `replacement 字段不合规:${replacementError}`)
|
|
365
376
|
const requestedId = typeof replacement.id === 'string' ? replacement.id.trim() : ''
|
|
366
377
|
if (requestedId && (requestedId === subtaskId || orderMap(next).has(requestedId))) {
|
|
@@ -414,7 +425,7 @@ export function planReplan(plan: any, changes: any, options: any = {}): ReplanRe
|
|
|
414
425
|
if (department === null) {
|
|
415
426
|
return fail(REPLAN_CODES.INVALID_SUBTASK, `newSubtask.department 不是合法部门:${String(raw.department)}`)
|
|
416
427
|
}
|
|
417
|
-
const fieldError = replanFieldError(raw)
|
|
428
|
+
const fieldError = replanFieldError(raw, options?.allowedEfforts)
|
|
418
429
|
if (fieldError) return fail(REPLAN_CODES.INVALID_SUBTASK, `newSubtask 字段不合规:${fieldError}`)
|
|
419
430
|
const goal = typeof raw.objective === 'string' ? raw.objective.trim() : ''
|
|
420
431
|
const title = typeof raw.title === 'string' ? raw.title.trim() : ''
|
|
@@ -616,24 +627,25 @@ export function applyReplanStatuses(statuses: any, payload: ReplanPayload): any[
|
|
|
616
627
|
return next
|
|
617
628
|
}
|
|
618
629
|
|
|
619
|
-
/** durable `workplan-replan`
|
|
630
|
+
/** durable `workplan-replan` 消息:[T7] 可见文本置空(过程事件,C2),全量信封随 source.durable 落盘(选项 A)。 */
|
|
620
631
|
export function buildReplanMessage(payload: ReplanPayload) {
|
|
621
632
|
const changed = payload.marks.map((mark) => `${mark.subtaskId}→${mark.replacedBy.length ? mark.replacedBy.join('、') : '撤销'}`)
|
|
622
633
|
const summary = truncate(`【重规划 r${payload.revision}】${changed.join(',') || '新增子任务'}`, 300)
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
REPLAN_MARKER_BEGIN,
|
|
630
|
-
JSON.stringify(payload),
|
|
631
|
-
REPLAN_MARKER_END,
|
|
632
|
-
]
|
|
633
|
-
return makeUserMessage(lines.join('\n'), { kind: 'workplan-replan', form: 'notice', summary })
|
|
634
|
+
/*
|
|
635
|
+
* [T7] 重规划是过程事件:主 Agent 从 dsh_workplan_replan 的工具返回(按需
|
|
636
|
+
* 通道,不裁剪)已知晓新行与后续动作;注入正文置空,信封仍随事件落盘,
|
|
637
|
+
* parseReplanMessage 先读元数据回退旧文本标记(旧消息零迁移,C4)。
|
|
638
|
+
*/
|
|
639
|
+
return makeUserMessage('', { kind: 'workplan-replan', form: 'notice', summary, durable: payload })
|
|
634
640
|
}
|
|
635
641
|
|
|
636
642
|
export function parseReplanMessage(message: any): ReplanPayload | null {
|
|
643
|
+
/* [T7] 先读元数据信封(source.durable,选项 A),回退旧文本标记。 */
|
|
644
|
+
const durable = message?.source?.durable
|
|
645
|
+
if (isRecord(durable) && durable.kind === 'workplan-replan'
|
|
646
|
+
&& durable.plan && Array.isArray(durable.marks) && Array.isArray(durable.added)) {
|
|
647
|
+
return durable as ReplanPayload
|
|
648
|
+
}
|
|
637
649
|
const text = messageText(message)
|
|
638
650
|
const begin = text.indexOf(REPLAN_MARKER_BEGIN)
|
|
639
651
|
const end = text.indexOf(REPLAN_MARKER_END)
|
|
@@ -698,42 +710,52 @@ export function buildChangeRequestMessage(payload: ChangeRequestPayload, context
|
|
|
698
710
|
'1. 变更影响范围:调用 dsh_workplan_replan,用 cancel/replace/add 逐项说明受影响的子任务;旧行会保留为「已重规划」并可追溯。',
|
|
699
711
|
'2. 只是补充说明、不改范围:调用 dsh_workplan_update 把说明写进对应子任务的 note。',
|
|
700
712
|
'3. 变更尚未明确:先向用户确认,再重规划;不要用旧计划直接交付。',
|
|
701
|
-
'',
|
|
702
|
-
CHANGE_MARKER_BEGIN,
|
|
703
|
-
JSON.stringify(payload),
|
|
704
|
-
CHANGE_MARKER_END,
|
|
705
713
|
]
|
|
714
|
+
/*
|
|
715
|
+
* [T7] 变更原文是用户输入而非插件噪音:正文保留(闸门对 workplan-change
|
|
716
|
+
* 豁免上限),仅把 JSON 信封从正文移入 source.durable(选项 A);
|
|
717
|
+
* parseChangeRequestMessage 先读元数据回退旧文本标记(旧消息零迁移)。
|
|
718
|
+
*/
|
|
706
719
|
return makeUserMessage(lines.join('\n'), {
|
|
707
720
|
kind: 'workplan-change',
|
|
708
721
|
form: 'notice',
|
|
709
722
|
summary: truncate(`需求变更已记录 #${payload.seq}`, 200),
|
|
723
|
+
durable: payload,
|
|
710
724
|
})
|
|
711
725
|
}
|
|
712
726
|
|
|
713
727
|
export function parseChangeRequestMessage(message: any): ChangeRequestPayload | null {
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
const
|
|
720
|
-
if (
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
seq: Number.isInteger(Number(payload.seq)) ? Number(payload.seq) : 1,
|
|
726
|
-
at: Number(payload.at) || Date.now(),
|
|
727
|
-
turn: Number.isInteger(Number(payload.turn)) ? Number(payload.turn) : null,
|
|
728
|
-
text: truncate(payload.text, 4000),
|
|
728
|
+
/* [T7] 先读元数据信封(source.durable,选项 A),回退旧文本标记。 */
|
|
729
|
+
let payload: any = message?.source?.durable
|
|
730
|
+
if (!isRecord(payload) || payload.kind !== 'workplan-change') {
|
|
731
|
+
const text = messageText(message)
|
|
732
|
+
const begin = text.indexOf(CHANGE_MARKER_BEGIN)
|
|
733
|
+
const end = text.indexOf(CHANGE_MARKER_END)
|
|
734
|
+
if (begin < 0 || end <= begin) return null
|
|
735
|
+
try {
|
|
736
|
+
payload = JSON.parse(text.slice(begin + CHANGE_MARKER_BEGIN.length, end).trim())
|
|
737
|
+
} catch {
|
|
738
|
+
return null
|
|
729
739
|
}
|
|
730
|
-
}
|
|
731
|
-
|
|
740
|
+
}
|
|
741
|
+
if (!isRecord(payload) || payload.kind !== 'workplan-change') return null
|
|
742
|
+
if (typeof payload.text !== 'string' || !payload.text.trim()) return null
|
|
743
|
+
return {
|
|
744
|
+
kind: 'workplan-change',
|
|
745
|
+
planId: String(payload.planId ?? ''),
|
|
746
|
+
seq: Number.isInteger(Number(payload.seq)) ? Number(payload.seq) : 1,
|
|
747
|
+
at: Number(payload.at) || Date.now(),
|
|
748
|
+
turn: Number.isInteger(Number(payload.turn)) ? Number(payload.turn) : null,
|
|
749
|
+
text: truncate(payload.text, 4000),
|
|
732
750
|
}
|
|
733
751
|
}
|
|
734
752
|
|
|
735
|
-
/**
|
|
753
|
+
/**
|
|
754
|
+
* 从计划定义里读重规划修订号(写入时放在 plan.planRevision,见本文件
|
|
755
|
+
* planReplan() 的 next.planRevision = revision;runtime 消费侧同样读
|
|
756
|
+
* plan.planRevision,见 runtime.ts 的 Number(plan?.planRevision ?? 0))。
|
|
757
|
+
*/
|
|
736
758
|
export function planRevisionOf(plan: any): number {
|
|
737
|
-
const revision = Number(plan?.
|
|
759
|
+
const revision = Number(plan?.planRevision ?? 0)
|
|
738
760
|
return Number.isFinite(revision) && revision > 0 ? revision : 0
|
|
739
761
|
}
|