feat(client): materialize restarted plans

This commit is contained in:
baiyanyun
2026-06-08 18:58:39 +08:00
parent 913c6da8f3
commit 451cda7aa6
6 changed files with 233 additions and 45 deletions

View File

@@ -2146,7 +2146,7 @@ async function handleGovernanceCommand(
if (body.command_kind === 'activate_plan' || body.command_kind === 'run_schedule_now') {
const targetPlanId = planId || runtimeDebugPlans(snapshot)[0]?.plan_id || templatePlans(snapshot)[0]?.plan_id || 'qimingclaw-client-readiness';
const dispatch = await dispatchPlan(targetPlanId, snapshot);
const dispatch = await dispatchPlan(targetPlanId, snapshot, { recordCommand: false });
const response = governanceAccepted(commandId, correlationId, '已映射为 qimingclaw 本地任务激活。', {
plan_id: targetPlanId,
status: 'active',
@@ -2429,7 +2429,11 @@ function buildTaskFlow(taskId: string, snapshot: QimingclawSnapshot | null = nul
};
}
async function dispatchPlan(planId: string, snapshot: QimingclawSnapshot | null = null): Promise<PlanDispatchResponse> {
async function dispatchPlan(
planId: string,
snapshot: QimingclawSnapshot | null = null,
options: { recordCommand?: boolean } = {},
): Promise<PlanDispatchResponse> {
const state = snapshot?.uiState ?? await readBridgeUiState() ?? readState();
const date = todayInputDate();
const plan = mergedDebugPlans(snapshot).find((candidate) => candidate.plan_id === planId);
@@ -2445,30 +2449,32 @@ async function dispatchPlan(planId: string, snapshot: QimingclawSnapshot | null
title: task.title,
status: task.status === 'pending' ? 'running' : task.status,
}));
await recordGovernanceCommand(
{
command_kind: 'activate_plan',
context_refs: { plan_id: planId },
payload: {
plan_id: planId,
title: plan?.title,
objective: plan?.objective,
requested_action: 'dispatch_plan',
},
correlation_id: correlationId,
},
governanceAccepted(
`qimingclaw-digital-dispatch-${slugifyIdPart(planId)}-${activatedAt}`,
correlationId,
'已将数字员工模板执行写入 qimingclaw 本地运行记录。',
if (options.recordCommand !== false) {
await recordGovernanceCommand(
{
plan_id: planId,
status: 'active',
dispatched_tasks: dispatchedTasks,
source: 'qimingclaw-adapter',
command_kind: 'activate_plan',
context_refs: { plan_id: planId },
payload: {
plan_id: planId,
title: plan?.title,
objective: plan?.objective,
requested_action: 'dispatch_plan',
},
correlation_id: correlationId,
},
),
);
governanceAccepted(
`qimingclaw-digital-dispatch-${slugifyIdPart(planId)}-${activatedAt}`,
correlationId,
'已将数字员工模板执行写入 qimingclaw 本地运行记录。',
{
plan_id: planId,
status: 'active',
dispatched_tasks: dispatchedTasks,
source: 'qimingclaw-adapter',
},
),
);
}
return {
ok: true,