feat(goal-run): add multi-checkpoint goal orchestration with H5 and admin surfaces.

Persist goal runs in MySQL, bind agent runs to checkpoints, expose awaiting-approval
UX in chat, and add admin inspection routes with local verify scripts.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
john
2026-08-01 17:03:16 +08:00
parent 43bc8bbc2b
commit 666db0b939
47 changed files with 4417 additions and 4 deletions
+42
View File
@@ -0,0 +1,42 @@
const CHECKPOINT_STATUS_LABELS = {
pending: '待开始',
running: '进行中',
awaiting_approval: '待确认',
approved: '已完成',
skipped: '已跳过',
failed: '失败',
};
export function buildGoalContextEnvelope(goal) {
if (!goal) return '';
const checkpoints = Array.isArray(goal.checkpoints) ? goal.checkpoints : [];
const current = checkpoints.find((item) => item.id === goal.currentCheckpointId)
?? checkpoints.find((item) => item.status === 'running')
?? checkpoints.find((item) => item.status === 'pending');
const completed = checkpoints.filter((item) =>
['approved', 'awaiting_approval'].includes(item.status));
const awaiting = checkpoints.find((item) => item.status === 'awaiting_approval');
const lines = [
'【Goal Context】',
`目标:${goal.title}`,
];
if (current) {
const statusLabel = CHECKPOINT_STATUS_LABELS[current.status] ?? current.status;
lines.push(`当前阶段:${current.title}${statusLabel}`);
}
if (completed.length) {
lines.push('已完成摘要:');
for (const checkpoint of completed) {
if (checkpoint.outputSummary) {
lines.push(`- ${checkpoint.outputSummary}`);
} else {
lines.push(`- ${checkpoint.title}`);
}
}
}
if (awaiting) {
lines.push(`待你确认:${awaiting.description || awaiting.title}`);
}
return lines.join('\n');
}