666db0b939
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>
43 lines
1.4 KiB
JavaScript
43 lines
1.4 KiB
JavaScript
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');
|
||
}
|