Files
memind/goal-run-context.mjs
T
john 666db0b939 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>
2026-08-01 17:03:16 +08:00

43 lines
1.4 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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');
}