dsh-workplan 2.3.9 → 3.0.1
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 +161 -0
- package/README.en.md +20 -18
- package/README.md +33 -19
- package/README.zh.md +15 -19
- package/client.js +88 -59
- package/docs/cc/ADV-FSP-FUNCTIONAL-SPEC.md +19 -6
- package/docs/cc/ADV-TDS-TOE-DESIGN.md +3 -3
- package/docs/cc/AGD-OPS-SECURE-OPERATION.md +3 -7
- package/docs/cc/AVA-VULNERABILITY-ANALYSIS.md +22 -3
- package/docs/cc/SECURITY-TARGET.md +6 -6
- package/docs/collaboration.md +17 -16
- package/lib/approval-gate.js +144 -0
- package/lib/client.js +88 -59
- package/lib/comm-format.js +58 -6
- package/lib/criterion.js +210 -0
- package/lib/dept-journal.js +319 -0
- package/lib/host.js +333 -63
- package/lib/llm-rules.js +281 -24
- package/lib/plan.js +1468 -219
- package/lib/replan.js +50 -39
- package/lib/runtime.js +3474 -1088
- package/lib/three-phase.js +106 -20
- package/lib/understanding.js +18 -3
- package/lib/v3-contract.js +431 -0
- package/lib/watchdog.js +9 -1
- package/package.json +4 -3
- package/src/approval-gate.ts +168 -0
- package/src/client.ts +88 -59
- package/src/comm-format.ts +63 -5
- package/src/criterion.ts +261 -0
- package/src/dept-journal.ts +373 -0
- package/src/host.ts +341 -64
- package/src/llm-rules.ts +349 -27
- package/src/plan.ts +1464 -210
- package/src/replan.ts +48 -37
- package/src/runtime.ts +3028 -699
- package/src/three-phase.ts +147 -20
- package/src/understanding.ts +20 -3
- package/src/v3-contract.ts +470 -0
- package/src/watchdog.ts +13 -1
package/src/replan.ts
CHANGED
|
@@ -282,8 +282,8 @@ function replanFieldError(raw: any, allowedEfforts?: readonly string[] | null):
|
|
|
282
282
|
: Array.isArray(allowedEfforts) && allowedEfforts.length > 0 && !allowedEfforts.includes(effort)
|
|
283
283
|
? `reasoningEffort "${effort}" 不在当前模型家族的推理等级集合 {${allowedEfforts.join(' / ')}} 内(qwen 系仅 low / medium / xhigh;非 qwen 系仅 low / high / max),必须改用集合内档位`
|
|
284
284
|
: null
|
|
285
|
-
return list('dependsOn', 12,
|
|
286
|
-
?? list('method',
|
|
285
|
+
return list('dependsOn', 12, MAX_SUBTASKS - 1)
|
|
286
|
+
?? list('method', 8, 800)
|
|
287
287
|
?? list('inputs', 12, 800)
|
|
288
288
|
?? list('outputs', 12, 800)
|
|
289
289
|
?? list('acceptance', 8, 800)
|
|
@@ -627,24 +627,25 @@ export function applyReplanStatuses(statuses: any, payload: ReplanPayload): any[
|
|
|
627
627
|
return next
|
|
628
628
|
}
|
|
629
629
|
|
|
630
|
-
/** durable `workplan-replan`
|
|
630
|
+
/** durable `workplan-replan` 消息:[T7] 可见文本置空(过程事件,C2),全量信封随 source.durable 落盘(选项 A)。 */
|
|
631
631
|
export function buildReplanMessage(payload: ReplanPayload) {
|
|
632
632
|
const changed = payload.marks.map((mark) => `${mark.subtaskId}→${mark.replacedBy.length ? mark.replacedBy.join('、') : '撤销'}`)
|
|
633
633
|
const summary = truncate(`【重规划 r${payload.revision}】${changed.join(',') || '新增子任务'}`, 300)
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
REPLAN_MARKER_BEGIN,
|
|
641
|
-
JSON.stringify(payload),
|
|
642
|
-
REPLAN_MARKER_END,
|
|
643
|
-
]
|
|
644
|
-
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 })
|
|
645
640
|
}
|
|
646
641
|
|
|
647
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
|
+
}
|
|
648
649
|
const text = messageText(message)
|
|
649
650
|
const begin = text.indexOf(REPLAN_MARKER_BEGIN)
|
|
650
651
|
const end = text.indexOf(REPLAN_MARKER_END)
|
|
@@ -709,42 +710,52 @@ export function buildChangeRequestMessage(payload: ChangeRequestPayload, context
|
|
|
709
710
|
'1. 变更影响范围:调用 dsh_workplan_replan,用 cancel/replace/add 逐项说明受影响的子任务;旧行会保留为「已重规划」并可追溯。',
|
|
710
711
|
'2. 只是补充说明、不改范围:调用 dsh_workplan_update 把说明写进对应子任务的 note。',
|
|
711
712
|
'3. 变更尚未明确:先向用户确认,再重规划;不要用旧计划直接交付。',
|
|
712
|
-
'',
|
|
713
|
-
CHANGE_MARKER_BEGIN,
|
|
714
|
-
JSON.stringify(payload),
|
|
715
|
-
CHANGE_MARKER_END,
|
|
716
713
|
]
|
|
714
|
+
/*
|
|
715
|
+
* [T7] 变更原文是用户输入而非插件噪音:正文保留(闸门对 workplan-change
|
|
716
|
+
* 豁免上限),仅把 JSON 信封从正文移入 source.durable(选项 A);
|
|
717
|
+
* parseChangeRequestMessage 先读元数据回退旧文本标记(旧消息零迁移)。
|
|
718
|
+
*/
|
|
717
719
|
return makeUserMessage(lines.join('\n'), {
|
|
718
720
|
kind: 'workplan-change',
|
|
719
721
|
form: 'notice',
|
|
720
722
|
summary: truncate(`需求变更已记录 #${payload.seq}`, 200),
|
|
723
|
+
durable: payload,
|
|
721
724
|
})
|
|
722
725
|
}
|
|
723
726
|
|
|
724
727
|
export function parseChangeRequestMessage(message: any): ChangeRequestPayload | null {
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
const
|
|
731
|
-
if (
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
seq: Number.isInteger(Number(payload.seq)) ? Number(payload.seq) : 1,
|
|
737
|
-
at: Number(payload.at) || Date.now(),
|
|
738
|
-
turn: Number.isInteger(Number(payload.turn)) ? Number(payload.turn) : null,
|
|
739
|
-
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
|
|
740
739
|
}
|
|
741
|
-
}
|
|
742
|
-
|
|
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),
|
|
743
750
|
}
|
|
744
751
|
}
|
|
745
752
|
|
|
746
|
-
/**
|
|
753
|
+
/**
|
|
754
|
+
* 从计划定义里读重规划修订号(写入时放在 plan.planRevision,见本文件
|
|
755
|
+
* planReplan() 的 next.planRevision = revision;runtime 消费侧同样读
|
|
756
|
+
* plan.planRevision,见 runtime.ts 的 Number(plan?.planRevision ?? 0))。
|
|
757
|
+
*/
|
|
747
758
|
export function planRevisionOf(plan: any): number {
|
|
748
|
-
const revision = Number(plan?.
|
|
759
|
+
const revision = Number(plan?.planRevision ?? 0)
|
|
749
760
|
return Number.isFinite(revision) && revision > 0 ? revision : 0
|
|
750
761
|
}
|