import type { Runtime } from '../runtime.ts'; import { baseTools } from '../tools.ts'; import type { ScenarioInfo } from '../types.ts'; import { evidenceRules, invoke, summarize } from './shared.ts'; export const background: ScenarioInfo = { id: 'background', task: '在后台从本机 Agent 会话定位本周活跃的仓库,再核对 Git 提交。等待期间先列出周报结构,收到结果后汇报工作线索。', system: `${evidenceRules} 先后台启动 weekly-evidence,再写周报结构。job_id 表示任务已启动。进程退出后,运行时会投递带有 job_id 的完成通知。`, tools: baseTools(true), }; // stage:start export async function runBackground(loop: Runtime) { const { ref: jobId } = await invoke(loop, 'bash', '调用 bash 运行 weekly-evidence,设置 run_in_background 为 true。', (call) => loop.runTool(call, (args) => loop.startBackground(call.id, args))); await summarize(loop, '先给出两行周报结构。'); await loop.waitForJob(jobId!); // callModel 会先把收件箱的完成通知加入历史。 return summarize(loop, '根据进程的真实退出码和输出,汇报仓库和工作线索。'); } // stage:end