feat: add task records and verified engineering check jobs

This commit is contained in:
Agent Workbench Dev
2026-10-29 14:03:50 +08:00
parent 93f4d90ccb
commit 2ea34850c4
26 changed files with 2703 additions and 56 deletions
+50 -16
View File
@@ -1,12 +1,13 @@
import { useEffect, useMemo, useRef, useState } from 'react';
import { Activity, RotateCw, ArrowDownToLine, ArrowRight, ArrowUp, BookOpenText, Check, ChevronDown, ChevronRight, Code2, Copy, File, FileCode2, Folder, FolderOpen, GitBranch, Link2, LoaderCircle, Maximize2, MessageSquare, Minimize2, PanelLeftClose, PanelLeftOpen, Pencil, Play, Plus, Search, Settings2, ShieldCheck, Square, SquareTerminal, Trash2, X } from 'lucide-react';
import { Activity, ClipboardCheck, RotateCw, ArrowDownToLine, ArrowRight, ArrowUp, BookOpenText, Check, ChevronDown, ChevronRight, Code2, Copy, File, FileCode2, Folder, FolderOpen, GitBranch, Link2, LoaderCircle, Maximize2, MessageSquare, Minimize2, PanelLeftClose, PanelLeftOpen, Pencil, Play, Plus, Search, Settings2, ShieldCheck, Square, SquareTerminal, Trash2, X } from 'lucide-react';
import type { Bootstrap, Change, Config, FileEntry, OpenFile, Project, ResearchDoc, Session, SessionBrief, ToolEvent, RuntimeDiagnostics, RuntimeFailure } from './types';
import { api, downloadBlob, exportSession, setToken } from './api';
import { DiffView, EmptyInspector, IconButton, Modal, ResearchContent, Status, ToolRow, FailureCard } from './components';
import { DiagnosticsPanel } from './DiagnosticsPanel';
import { TaskPanel } from './TaskPanel';
const activeStates = ['running', 'awaiting_approval', 'stopping'];
const defaultConfig: Config = { mode: 'demo', baseUrl: 'http://127.0.0.1:11434/v1', model: '', contextLimit: 16000, maxSteps: 12, maxOutputTokens: 2048, hasKey: false };
const defaultConfig: Config = { mode: 'demo', baseUrl: 'http://127.0.0.1:11434/v1', model: '', contextLimit: 16000, maxSteps: 12, maxOutputTokens: 2048, hasKey: false, maxRunDurationMs: 600000, maxRunTokens: 200000, maxTaskTokens: 1000000 };
export default function App() {
const [token, setAccess] = useState('');
@@ -36,7 +37,7 @@ export default function App() {
const [composer, setComposer] = useState('');
const [sending, setSending] = useState(false);
const [creatingSession, setCreatingSession] = useState(false);
const [tab, setTab] = useState<'file' | 'changes' | 'trace'>('file');
const [tab, setTab] = useState<'file' | 'changes' | 'trace' | 'task'>('file');
const [changeId, setChangeId] = useState('');
const [eventId, setEventId] = useState('');
const [wide, setWide] = useState(false);
@@ -63,13 +64,15 @@ export default function App() {
const selectedSessionRef = useRef('');
const selectedProjectRef = useRef('');
const revisions = useRef(new Map<string, number>());
const archivedSessions = useRef(new Set<string>());
const eventCursor = useRef(0);
const filesRequest = useRef(0);
const fileRequest = useRef(0);
const reportRequest = useRef(0);
const sessionCreation = useRef<Promise<Session | null> | null>(null);
const selectedProject = projects.find(project => project.id === projectId);
const isRunning = !!session && activeStates.includes(session.status);
const anyRunning = briefs.some(item => activeStates.includes(item.status));
const isRunning = !!session && (activeStates.includes(session.status) || session.execution?.checks.some(job => ['queued', 'running'].includes(job.status)) === true);
const anyRunning = isRunning || briefs.some(item => activeStates.includes(item.status));
const pending = session?.changes.filter(change => ['pending', 'conflict'].includes(change.status)) || [];
const selectedChange = session?.changes.find(change => change.id === changeId) || pending[0] || session?.changes.at(-1);
const selectedEvent = session?.events.find(event => event.id === eventId) || session?.events.at(-1);
@@ -105,6 +108,7 @@ export default function App() {
const revision = updated.revision ?? 0;
if (revision < (revisions.current.get(updated.id) ?? 0)) return;
revisions.current.set(updated.id, revision);
if (updated.archived) archivedSessions.current.add(updated.id); else archivedSessions.current.delete(updated.id);
if (selectedSessionRef.current === updated.id && selectedProjectRef.current === updated.projectId) {
setSession(previous => previous?.id === updated.id && previous.revision > revision ? previous : updated);
}
@@ -116,7 +120,7 @@ export default function App() {
.sort((a, b) => b.updatedAt.localeCompare(a.updatedAt));
});
}
function showInspector(next: 'file' | 'changes' | 'trace') {
function showInspector(next: 'file' | 'changes' | 'trace' | 'task') {
setTab(next);
if (window.innerWidth <= 940) setWide(true);
if (window.innerWidth <= 620) setSidebarOpen(false);
@@ -285,6 +289,9 @@ export default function App() {
api<Bootstrap>('/bootstrap').then(result => {
if (!alive) return;
setToken(result.token); setAccess(result.token); setVersion(result.version); setProjects(result.projects); setBriefs(result.sessions); setConfig(result.config); setSettings(result.config); setExampleId(result.exampleProjectId);
const savedCursor = Number(sessionStorage.getItem('awb-event-cursor:' + location.origin));
eventCursor.current = Number.isSafeInteger(savedCursor) && savedCursor >= 0 && savedCursor <= (result.eventCursor ?? 0) ? savedCursor : result.eventCursor ?? 0;
for (const brief of result.sessions) revisions.current.set(brief.id, brief.revision);
const savedProject = localStorage.getItem('awb-project');
const id = result.projects.some(project => project.id === savedProject) ? savedProject! : result.exampleProjectId || result.projects[0]?.id || '';
selectedProjectRef.current = id; setProjectId(id);
@@ -303,19 +310,44 @@ export default function App() {
}, [token, sessionId]);
useEffect(() => {
if (!token) return;
const source = new EventSource('/api/events?token=' + encodeURIComponent(token));
let alive = true, refreshTimer: ReturnType<typeof setTimeout> | null = null;
async function resync() {
const seen = new Map(revisions.current), current = selectedSessionRef.current;
try {
const [list, selected] = await Promise.all([api<SessionBrief[]>('/sessions'), current ? api<Session>('/sessions/' + current) : Promise.resolve(null)]);
if (!alive) return;
setBriefs(previous => {
const merged = new Map(list.filter(item => !archivedSessions.current.has(item.id)).map(item => [item.id, item]));
for (const item of previous) {
const incoming = merged.get(item.id);
if (!archivedSessions.current.has(item.id) && (incoming && item.revision > incoming.revision || !incoming && item.revision > (seen.get(item.id) ?? -1))) merged.set(item.id, item);
}
return [...merged.values()].sort((a, b) => b.updatedAt.localeCompare(a.updatedAt));
});
if (selected) acceptSession(selected);
} catch (error) { if (alive) failure(error); }
}
function scheduleSync() {
if (refreshTimer !== null) return;
refreshTimer = setTimeout(() => { refreshTimer = null; void resync(); }, 80);
}
const source = new EventSource('/api/events?token=' + encodeURIComponent(token) + '&after=' + eventCursor.current);
source.onopen = () => {
setConnected(true);
const current = selectedSessionRef.current;
if (current) api<Session>('/sessions/' + current).then(acceptSession).catch(failure);
scheduleSync();
};
source.onerror = () => setConnected(false);
source.onmessage = event => {
const update = JSON.parse(event.data);
if (update.kind !== 'session') return;
acceptSession(update.session as Session);
if (update.kind === 'session') acceptSession(update.session as Session);
else if (update.kind === 'session_changed') scheduleSync();
else if (update.kind === 'ready' && update.replayIncomplete) scheduleSync();
const cursor = Number(event.lastEventId || update.seq || update.eventCursor);
if (Number.isSafeInteger(cursor) && cursor >= eventCursor.current) {
eventCursor.current = cursor; sessionStorage.setItem('awb-event-cursor:' + location.origin, String(cursor));
}
};
return () => source.close();
return () => { alive = false; source.close(); if (refreshTimer !== null) clearTimeout(refreshTimer); };
}, [token]);
useEffect(() => { if (toast) { const timeout = setTimeout(() => setToast(''), 6000); return () => clearTimeout(timeout); } }, [toast]);
useEffect(() => {
@@ -342,7 +374,7 @@ export default function App() {
const entries = [...(session?.messages || []).map(message => ({ id: message.id, date: message.createdAt, message })),
...(session?.events || []).filter(event => event.kind !== 'error').map(event => ({ id: event.id, date: event.createdAt, event }))].sort((a, b) => a.date.localeCompare(b.date));
const toolEvents = session?.events || [];
const toolEvents = session?.events.filter(event => event.kind === 'tool') || [];
const lineCount = openFile?.content.split('\n').length || 0;
const ready = !!token && connected;
return (
@@ -371,6 +403,7 @@ export default function App() {
</header>
<div className="task-toolbar"><span className="task-local"><GitBranch size={13} />本地项目</span>{session ? <Status value={session.status} /> : <span className="subtle">等待新任务</span>}<div className="toolbar-actions">
<IconButton label="运行诊断" onClick={() => openDiagnostics()}><Activity size={15} /></IconButton>
<IconButton label="查看任务记录" onClick={() => showInspector('task')}><ClipboardCheck size={15} /></IconButton>
{narrow && <><IconButton label="查看文件" onClick={() => showInspector('file')}><FileCode2 size={16} /></IconButton><IconButton label="查看改动" onClick={() => showInspector('changes')}><GitBranch size={16} /></IconButton><IconButton label="查看执行轨迹" onClick={() => showInspector('trace')}><SquareTerminal size={16} /></IconButton></>}
{pending.length > 0 && <button className="text-button review-toolbar" onClick={() => { setChangeId(pending[0].id); showInspector('changes'); }}><FileCode2 size={13} />审核 {pending.length} 项</button>}
{session && <><IconButton label="导出会话" onClick={() => exportSession(session.id).catch(failure)}><ArrowDownToLine size={15} /></IconButton>
@@ -392,16 +425,17 @@ export default function App() {
</main>
{((mobile && sidebarOpen) || (narrow && wide)) && <button type="button" className="panel-scrim" aria-label="关闭侧边面板" onClick={() => { setSidebarOpen(false); setWide(false); }} />}
<aside className="inspector">
<div className="inspector-tabs"><button className={tab === 'file' ? 'selected' : ''} onClick={() => setTab('file')}><FileCode2 size={14} />文件</button><button className={tab === 'changes' ? 'selected' : ''} onClick={() => setTab('changes')}><GitBranch size={14} />改动{pending.length > 0 && <b>{pending.length}</b>}</button><button className={tab === 'trace' ? 'selected' : ''} onClick={() => setTab('trace')}><SquareTerminal size={14} />轨迹</button><IconButton label={narrow ? '关闭检视区' : wide ? '缩小检视区' : '放大检视区'} onClick={() => setWide(previous => !previous)}>{narrow ? <X size={16} /> : wide ? <Minimize2 size={14} /> : <Maximize2 size={14} />}</IconButton></div>
<div className="inspector-tabs"><button className={tab === 'file' ? 'selected' : ''} onClick={() => setTab('file')}><FileCode2 size={14} />文件</button><button className={tab === 'changes' ? 'selected' : ''} onClick={() => setTab('changes')}><GitBranch size={14} />改动{pending.length > 0 && <b>{pending.length}</b>}</button><button className={tab === 'trace' ? 'selected' : ''} onClick={() => setTab('trace')}><SquareTerminal size={14} />轨迹</button><button className={tab === 'task' ? 'selected' : ''} onClick={() => setTab('task')}><ClipboardCheck size={14} />任务</button><IconButton label={narrow ? '关闭检视区' : wide ? '缩小检视区' : '放大检视区'} onClick={() => setWide(previous => !previous)}>{narrow ? <X size={16} /> : wide ? <Minimize2 size={14} /> : <Maximize2 size={14} />}</IconButton></div>
{tab === 'file' && (fileLoading ? <div className="loading-inspector"><LoaderCircle className="spin" size={24} />正在读取文件</div> : openFile ? <div className="file-inspector"><div className="file-heading"><FileCode2 size={15} /><span title={openFile.path}>{openFile.path}</span><IconButton label="复制文件内容" onClick={() => navigator.clipboard.writeText(openFile.content).then(() => notify('已复制文件内容。')).catch(failure)}><Copy size={14} /></IconButton><IconButton label={editing ? '取消编辑' : '编辑文件'} onClick={() => { setEditing(previous => !previous); setDraft(openFile.content); }}><Pencil size={14} /></IconButton></div><div className="file-details"><span>{lineCount} 行 · {openFile.bytes.toLocaleString()} B</span><span className="code-utility">{openFile.sha256.slice(0, 10)}</span></div>{editing ? <><textarea className="code-editor" aria-label="编辑文件内容" spellCheck={false} value={draft} onChange={event => setDraft(event.target.value)} /><div className="editor-actions"><button className="button primary" onClick={saveDraft} disabled={draft === openFile.content || draftSaving}><GitBranch size={14} />保存为提案</button></div></> : <div className="code-view">{openFile.content.split('\n').map((line, index) => <div key={index}><span>{index + 1}</span><code>{line.replace(/\r$/, '') || ' '}</code></div>)}</div>}</div> : <EmptyInspector kind="file" />)}
{tab === 'changes' && (selectedChange ? <div className="changes-inspector"><div className="change-list">{session?.changes.map(change => <button key={change.id} className={selectedChange.id === change.id ? 'selected' : ''} onClick={() => setChangeId(change.id)}><FileCode2 size={14} /><span>{change.path}</span><span className="change-stats"><b>+{change.additions}</b><i>−{change.deletions}</i></span></button>)}</div><div className="change-summary"><div><strong>{selectedChange.path}</strong><Status value={selectedChange.status} /></div><p>{selectedChange.reason}</p></div><DiffView change={selectedChange} /><div className="change-actions">{['pending', 'conflict'].includes(selectedChange.status) ? <><button className="button secondary" onClick={() => changeAction(selectedChange, 'reject')} disabled={!!changeBusy || isRunning}>撤回提案</button><button className="button primary" disabled={selectedChange.status !== 'pending' || !!changeBusy || isRunning} onClick={() => changeAction(selectedChange, 'apply')}><Check size={14} />应用这项改动</button></> : <span className="subtle">{selectedChange.status === 'applied' ? '这项改动已写入项目。' : '这项提案已结束。'}</span>}<IconButton label="下载建议内容" onClick={() => downloadBlob(new Blob([selectedChange.content], { type: 'text/plain;charset=utf-8' }), selectedChange.path.split('/').at(-1) || 'proposal.txt')}><ArrowDownToLine size={15} /></IconButton></div></div> : <EmptyInspector kind="changes" />)}
{tab === 'trace' && (session?.events.length ? <div className="trace-inspector"><div className="trace-caption"><span>完整执行记录</span><span>{toolEvents.length} 次工具调用</span></div><div className="trace-list">{session.events.map(event => <ToolRow key={event.id} event={event} selected={selectedEvent?.id === event.id} onSelect={() => setEventId(event.id)} />)}</div>{selectedEvent && <div className="event-details"><div className="event-detail-heading"><strong>{selectedEvent.label}</strong><Status value={selectedEvent.phase} /></div>{selectedEvent.input && <><h4>输入</h4><pre>{JSON.stringify(selectedEvent.input, null, 2)}</pre></>}<h4>结果</h4><pre>{selectedEvent.output || (selectedEvent.phase === 'waiting' ? '等待确认后执行。' : '正在等待工具结果。')}</pre>{selectedEvent.durationMs !== undefined && <p className="subtle">耗时 {(selectedEvent.durationMs / 1000).toFixed(2)} 秒,包含确认等待。</p>}</div>}</div> : <EmptyInspector kind="trace" />)}
<div className="inspector-footer"><ShieldCheck size={13} /><span>{tab === 'changes' ? '应用前会核对文件基线' : tab === 'trace' ? '中断调用保留待核实状态' : '读取范围限定在当前项目'}</span></div>
{tab === 'task' && (session ? <TaskPanel key={session.id} session={session} onSession={acceptSession} onError={failure} busy={isRunning} /> : <EmptyInspector kind="trace" />)}
<div className="inspector-footer"><ShieldCheck size={13} /><span>{tab === 'changes' ? '应用前会核对文件基线' : tab === 'trace' ? '中断调用保留待核实状态' : tab === 'task' ? '任务目标、检查与结果持久保存' : '读取范围限定在当前项目'}</span></div>
</aside>
{projectOpen && <Modal title="打开项目" description="选择要在本机读取和开发的项目文件夹。" onClose={() => setProjectOpen(false)}><form onSubmit={event => { event.preventDefault(); openProject(); }}><label className="form-field">项目文件夹<input autoFocus value={projectInput} onChange={event => setProjectInput(event.target.value)} placeholder="C:\Projects\my-app" aria-label="项目文件夹路径" /></label><div className="modal-actions">{exampleId && <button type="button" className="button secondary" onClick={() => { chooseProject(exampleId); setProjectOpen(false); }}>打开示例项目</button>}<button type="submit" className="button primary" disabled={!projectInput.trim()}><FolderOpen size={15} />打开项目</button></div></form></Modal>}
{settingsOpen && <Modal title="模型连接" description="同一套项目工具,可以使用离线演示或你自己的模型服务。" onClose={() => setSettingsOpen(false)}><form onSubmit={event => { event.preventDefault(); saveSettings(); }}><div className="mode-picker"><button type="button" className={settings.mode === 'demo' ? 'selected' : ''} onClick={() => setSettings(previous => ({ ...previous, mode: 'demo' }))}><Play size={18} /><strong>离线演示</strong><span>固定脚本,真实本地工具</span></button><button type="button" className={settings.mode === 'compatible' ? 'selected' : ''} onClick={() => setSettings(previous => ({ ...previous, mode: 'compatible' }))}><Link2 size={18} /><strong>兼容模型服务</strong><span>使用自己的本地或远程模型</span></button></div>
{settings.mode === 'compatible' && <><div className="connection-presets"><button type="button" onClick={() => setSettings(previous => ({ ...previous, baseUrl: 'http://127.0.0.1:11434/v1' }))}>Ollama</button><button type="button" onClick={() => setSettings(previous => ({ ...previous, baseUrl: 'http://127.0.0.1:8000/v1' }))}>vLLM</button><span>Chat Completions 兼容接口</span></div><label className="form-field">接口根地址<input type="url" value={settings.baseUrl} onChange={event => setSettings(previous => ({ ...previous, baseUrl: event.target.value }))} placeholder="http://127.0.0.1:11434/v1" /></label><label className="form-field">API Key(按服务要求填写)<input type="password" autoComplete="off" value={keyValue} onChange={event => { setKeyValue(event.target.value); setClearKey(false); }} placeholder={config.hasKey ? '本次运行已设置,留空保留' : '本地服务可以不填'} /></label><div className="key-note"><span>只在本次服务内存中使用,不写入会话与配置。</span>{config.hasKey && <button type="button" onClick={() => { setClearKey(true); setKeyValue(''); }}>{clearKey ? '保存后清除' : '清除 Key'}</button>}</div><div className="model-field"><label className="form-field">模型名称<input list="model-list" value={settings.model} onChange={event => setSettings(previous => ({ ...previous, model: event.target.value }))} placeholder="例如 qwen3:8b" /><datalist id="model-list">{models.map(model => <option key={model} value={model} />)}</datalist></label><button className="button secondary" type="button" onClick={readModels} disabled={settingsBusy || anyRunning}>{settingsBusy ? <LoaderCircle size={14} className="spin" /> : <Search size={14} />}读取模型列表</button></div><div className="model-test-row"><span>填写服务提供的接口根地址。</span><button type="button" className="button secondary" onClick={testModel} disabled={settingsBusy || anyRunning || !settings.model}><Activity size={14} />验证模型响应</button></div>{modelCheck && <div className={'model-check model-check-' + modelCheck.kind} role="status">{modelCheck.message}</div>}</>}
<details className="budget-settings"><summary>上下文与任务预算<ChevronDown size={13} /></summary><div className="budget-fields"><label>上下文预算<input type="number" min={1000} max={200000} value={settings.contextLimit} onChange={event => setSettings(previous => ({ ...previous, contextLimit: Number(event.target.value) }))} /></label><label>最大工具轮次<input type="number" min={1} max={30} value={settings.maxSteps} onChange={event => setSettings(previous => ({ ...previous, maxSteps: Number(event.target.value) }))} /></label><label>输出上限<input type="number" min={256} max={16000} value={settings.maxOutputTokens} onChange={event => setSettings(previous => ({ ...previous, maxOutputTokens: Number(event.target.value) }))} /></label></div><p>上下文使用本地估算,服务返回的实际 usage 另行保留。</p></details>{anyRunning && <p className="form-warning">有任务在执行,请先停止任务再改变连接。</p>}<div className="modal-actions"><button type="button" className="button secondary" onClick={() => setSettingsOpen(false)}>取消</button><button type="submit" className="button primary" disabled={settingsBusy || anyRunning}><Check size={15} />保存连接</button></div></form></Modal>}
<details className="budget-settings"><summary>上下文与任务预算<ChevronDown size={13} /></summary><div className="budget-fields"><label>上下文预算<input type="number" min={1000} max={200000} value={settings.contextLimit} onChange={event => setSettings(previous => ({ ...previous, contextLimit: Number(event.target.value) }))} /></label><label>最大工具轮次<input type="number" min={1} max={30} value={settings.maxSteps} onChange={event => setSettings(previous => ({ ...previous, maxSteps: Number(event.target.value) }))} /></label><label>输出上限<input type="number" min={256} max={16000} value={settings.maxOutputTokens} onChange={event => setSettings(previous => ({ ...previous, maxOutputTokens: Number(event.target.value) }))} /></label><label>运行时间(分钟)<input aria-label="运行时间预算" type="number" min={1} max={60} value={settings.maxRunDurationMs / 60000} onChange={event => setSettings(previous => ({ ...previous, maxRunDurationMs: Number(event.target.value) * 60000 }))} /></label><label>单次运行 tokens<input aria-label="单次运行token预算" type="number" min={1000} max={2000000} value={settings.maxRunTokens} onChange={event => setSettings(previous => ({ ...previous, maxRunTokens: Number(event.target.value) }))} /></label><label>任务累计 tokens<input aria-label="任务累计token预算" type="number" min={1000} max={10000000} value={settings.maxTaskTokens} onChange={event => setSettings(previous => ({ ...previous, maxTaskTokens: Number(event.target.value) }))} /></label></div><p>上下文使用本地估算;实际用量与未知用量分开保存。达到预算会暂停,已完成的工具结果保留。</p></details>{anyRunning && <p className="form-warning">有任务在执行,请先停止任务再改变连接。</p>}<div className="modal-actions"><button type="button" className="button secondary" onClick={() => setSettingsOpen(false)}>取消</button><button type="submit" className="button primary" disabled={settingsBusy || anyRunning}><Check size={15} />保存连接</button></div></form></Modal>}
{diagnosticsOpen && <Modal title="运行诊断" description="查看工作台的模型连接、终端环境、最近错误和文件实际状态。" wide onClose={() => setDiagnosticsOpen(false)}><DiagnosticsPanel value={diagnostics} busy={diagnosticsBusy} onRefresh={() => openDiagnostics()} /></Modal>}
{researchOpen && <Modal title="机制研究与独立设计" description="从分发客户端的静态证据提炼产品机制。运行时与远端服务的未知部分在报告中说明。" wide onClose={() => setResearchOpen(false)}><div className="research-layout"><nav>{researchDocs.map(document => <button className={report?.title === document.title ? 'selected' : ''} key={document.id} onClick={() => loadReport(document.id)}><BookOpenText size={15} /><span><strong>{document.title}</strong><small>{document.description}</small></span></button>)}</nav><article className="research-document">{report && <ResearchContent content={report.content} />}</article></div></Modal>}
{toast && <div className="toast" role="status"><span>{toast}</span><IconButton label="关闭提示" onClick={() => setToast('')}><X size={14} /></IconButton></div>}
+61
View File
@@ -0,0 +1,61 @@
.task-record { flex: 1; min-height: 0; overflow: auto; padding: 4px 18px 20px; }
.task-record-section { padding: 18px 0; border-bottom: 1px solid var(--line); }
.record-heading { display: flex; gap: 7px; align-items: center; margin-bottom: 12px; color: var(--teal); }
.record-heading h3 { font-size: 12px; font-weight: 600; flex: 1; }
.record-heading > span:not(.status) { margin-left: auto; font-size: 11px; color: var(--muted); }
.record-heading > code { margin-left: auto; font-size: 11px; color: var(--muted); }
.task-goal { line-height: 1.85; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 12px; }
.record-id { display: inline-block; font-size: 10px; color: var(--muted); margin-top: 9px; }
.task-instructions { margin-top: 14px; font-size: 11px; }
.task-instructions summary { cursor: pointer; color: var(--teal); }
.task-instructions p { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.8; padding: 8px 0; }
.record-empty, .record-footnote { display: flex; gap: 7px; align-items: flex-start; color: var(--muted); font-size: 11px; line-height: 1.85; margin: 9px 0; }
.verification-note { display: flex; gap: 10px; padding: 14px 12px; margin-top: 15px; background: #faf4e8; border: 1px solid #e7d8b8; border-radius: 7px; color: #805d22; }
.verification-note strong { font-size: 12px; }
.verification-note p { font-size: 11px; line-height: 1.8; margin-top: 6px; }
.verification-note code { display: block; font-size: 10px; margin-top: 5px; }
.run-picker { display: flex; flex-direction: column; gap: 7px; color: var(--muted); font-size: 11px; }
.run-picker select { border: 1px solid var(--line); background: #fff; border-radius: 5px; padding: 8px; width: 100%; min-width: 0; font-size: 11px; }
.run-status { display: flex; justify-content: space-between; align-items: center; margin: 13px 0; }
.run-status > code { font-size: 10px; color: var(--muted); }
.record-fields { display: grid; grid-template-columns: 90px minmax(0, 1fr); gap: 9px 10px; font-size: 11px; line-height: 1.7; margin: 0; }
.record-fields dt { color: var(--muted); }
.record-fields dd { margin: 0; overflow-wrap: anywhere; }
.record-fields small { color: var(--muted); font-size: 10px; }
.record-endpoint { font-family: "Cascadia Code", Consolas, monospace; font-size: 10px; }
.run-stop { padding: 9px; margin-top: 11px; font-size: 11px; line-height: 1.7; border-left: 2px solid #bd9654; background: #faf7ef; }
.check-plan { margin-top: 14px; border-left: 2px solid #7da89c; padding-left: 12px; font-size: 11px; line-height: 1.8; }
.check-baseline { display: flex; gap: 5px; align-items: flex-start; color: var(--muted); margin-top: 7px; overflow-wrap: anywhere; }
.check-baseline svg { margin-top: 4px; }
.check-plan ul { padding: 0; margin: 12px 0; list-style: none; }
.check-plan li { display: flex; flex-direction: column; gap: 4px; margin: 10px 0; }
.check-plan li code { color: var(--teal); background: #edf3f1; padding: 5px 8px; border-radius: 4px; font-size: 11px; overflow-wrap: anywhere; }
.check-job { padding: 13px 0 0; margin-top: 15px; border-top: 1px solid var(--line); font-size: 11px; line-height: 1.7; }
.check-job .record-heading { margin-bottom: 6px; flex-wrap: wrap; }
.check-job > time { color: var(--muted); font-size: 10px; }
.check-job > p { margin: 7px 0; }
.check-current { display: flex; align-items: center; gap: 6px; color: var(--teal); }
.check-result { border: 1px solid var(--line); border-radius: 6px; padding: 9px; margin-top: 10px; }
.check-result > div { display: flex; gap: 5px; align-items: center; justify-content: space-between; }
.check-result > p { margin-top: 6px; color: var(--muted); }
.check-result .text-button { margin-top: 6px; padding-left: 0; }
.artifact-list { display: flex; flex-direction: column; gap: 5px; }
.artifact-list button { width: 100%; display: flex; justify-content: space-between; align-items: center; text-align: left; border: 1px solid var(--line); border-radius: 5px; padding: 9px; font-size: 11px; }
.artifact-list button:hover { background: #edf3f1; }
.artifact-list code { display: block; color: var(--muted); font-size: 10px; margin-top: 4px; }
.artifact-list small { color: var(--muted); font-size: 10px; }
.artifact-preview { min-height: 100px; min-width: 0; max-width: 100%; overflow: auto; flex: 1; padding: 15px; background: #edf3f1; border: 1px solid var(--line); border-radius: 5px; font-size: 11px; line-height: 1.8; }
.modal-heading > div { min-width: 0; }
.modal-heading p { overflow-wrap: anywhere; }
.artifact-pagination { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding-top: 13px; font-size: 11px; flex-wrap: wrap; }
.artifact-pagination > span { margin-right: auto; color: var(--muted); }
.check-confirm { flex: 1; min-height: 0; overflow: auto; font-size: 12px; }
.check-confirm > div { margin-bottom: 14px; }
.check-confirm pre { margin: 6px 0 0; padding: 10px; background: #edf3f1; border: 1px solid var(--line); border-radius: 5px; font-size: 11px; }
.check-confirm p { color: var(--muted); line-height: 1.8; }
.status-unknown, .status-unverified, .status-stale { color: #805d22; background: #faf4e8; }
.status-passed { color: #277958; background: #edf7ef; }
.status-queued, .status-validating, .status-not_configured, .status-cancelled { color: #626c7c; background: #eef0f4; }
.tool-unknown .tool-symbol { color: #805d22; background: #faf4e8; }
@media (max-width: 1120px) { .inspector-tabs > button:not(.icon-button) { padding-left: 7px; padding-right: 7px; gap: 4px; } .task-record { padding-left: 13px; padding-right: 13px; } }
@media (max-width: 620px) { .toolbar-actions { gap: 1px; } .toolbar-actions .icon-button { width: 24px; } .task-record { padding: 4px 16px 20px; } .record-fields { grid-template-columns: 83px minmax(0, 1fr); } .artifact-pagination .button { height: 32px; } }
+88
View File
@@ -0,0 +1,88 @@
import { useEffect, useRef, useState } from 'react';
import { Check, ClipboardCheck, FileText, GitBranch, LoaderCircle, Play, RefreshCw, ShieldQuestion } from 'lucide-react';
import type { ArtifactPreview, CheckPlan, Run, Session } from './types';
import { api } from './api';
import { Modal, Status } from './components';
import './TaskPanel.css';
const stopReasons: Record<string, string> = { time_limit: '到达运行时间预算', token_limit: '到达本次 token 预算', task_token_limit: '到达任务累计预算', step_limit: '到达工具轮次上限', cancelled: '用户停止', model_error: '模型请求失败', interrupted: '进程中断' };
const number = (value: number | undefined) => (value ?? 0).toLocaleString('zh-CN');
const time = (value: string | null | undefined) => value ? new Date(value).toLocaleString('zh-CN', { month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit', second: '2-digit' }) : '执行中';
export function TaskPanel({ session, onSession, onError, busy }: { session: Session; onSession: (value: Session) => void; onError: (error: unknown) => void; busy: boolean }) {
const execution = session.execution, task = execution?.task;
const [runId, setRunId] = useState('');
const [historicalRun, setHistoricalRun] = useState<Run | null>(null);
const [preview, setPreview] = useState<ArtifactPreview | null>(null);
const [previewBusy, setPreviewBusy] = useState(false);
const [planning, setPlanning] = useState(false);
const [confirmPlan, setConfirmPlan] = useState<CheckPlan | null>(null);
const [starting, setStarting] = useState(false);
const artifactRequest = useRef(0);
const id = runId || execution?.run?.id || '';
const run = id === execution?.run?.id ? execution.run : historicalRun;
const plans = execution?.plans ?? [];
const latestPlan = plans.filter(plan => plan.taskId === task?.id).at(-1);
const jobs = execution?.checks ?? [];
const checkRunning = jobs.some(job => ['queued', 'running'].includes(job.status));
useEffect(() => { setRunId(''); setHistoricalRun(null); setPreview(null); setConfirmPlan(null); artifactRequest.current++; }, [session.id, task?.id]);
useEffect(() => {
if (!id || id === execution?.run?.id) return;
let alive = true; setHistoricalRun(null);
api<Run>('/sessions/' + session.id + '/runs/' + id).then(value => { if (alive) setHistoricalRun(value); }).catch(error => { if (alive) onError(error); });
return () => { alive = false; };
}, [session.id, id, execution?.run?.id]);
async function openArtifact(artifactId: string, offset = 0) {
const request = ++artifactRequest.current; setPreviewBusy(true);
try {
const value = await api<ArtifactPreview>('/artifacts/' + artifactId + '?session=' + session.id + '&offset=' + offset + '&limit=16000');
if (artifactRequest.current === request) setPreview(value);
} catch (error) { if (artifactRequest.current === request) onError(error); }
finally { if (artifactRequest.current === request) setPreviewBusy(false); }
}
async function planChecks() {
setPlanning(true);
try { const value = await api<Session>('/sessions/' + session.id + '/check-plans', {}); onSession(value); }
catch (error) { onError(error); } finally { setPlanning(false); }
}
async function runChecks() {
if (!confirmPlan) return; setStarting(true);
try { onSession(await api<Session>('/sessions/' + session.id + '/check-jobs', { planId: confirmPlan.id })); setConfirmPlan(null); }
catch (error) { onError(error); } finally { setStarting(false); }
}
return <div className="task-record" aria-label="任务记录">
<section className="task-record-section">
<div className="record-heading"><ClipboardCheck size={15} /><h3>任务目标</h3>{task && <Status value={task.status} />}</div>
{task ? <><p className="task-goal">{task.goal}</p><code className="record-id" title={task.id}>{task.id.slice(0, 8)} · 任务</code>
{!!task.instructions.length && <details className="task-instructions"><summary>追加要求 · {task.instructions.length}</summary>{task.instructions.map(instruction => <p key={instruction.id}>{instruction.content}</p>)}</details>}
</> : <p className="record-empty">发送任务后,这里保存目标、每次运行和实际结果。</p>}
</section>
{execution?.progress.requiresVerification.length ? <section className="verification-note" role="status"><ShieldQuestion size={17} /><div><strong>{execution.progress.requiresVerification.length} 项结果需要核对</strong><p>这些调用已进入执行,但缺少可靠结果。继续任务会保留记录。</p>{execution.progress.requiresVerification.map(tool => <code key={tool.id}>{tool.tool} · {tool.id.slice(0, 8)}</code>)}</div></section> : null}
{task && <section className="task-record-section">
<div className="record-heading"><h3>运行记录</h3><span>{execution?.runs.filter(item => item.taskId === task.id).length} 次</span></div>
<label className="run-picker">选择一次运行<select aria-label="选择运行记录" value={id} onChange={event => setRunId(event.target.value)}>{execution?.runs.filter(item => item.taskId === task.id).map((item, index) => <option key={item.id} value={item.id}>第 {index + 1} 次 · {time(item.startedAt)}{item.resumeOf ? ' · 接续' : ''}</option>)}</select></label>
{run ? <><div className="run-status"><Status value={run.status} /><code title={run.id}>{run.id.slice(0, 8)}</code></div>
<dl className="record-fields"><dt>实际模型</dt><dd>{run.model?.verified === false ? '历史模型信息未记录' : run.model?.mode === 'demo' ? '离线演示 · 固定脚本' : run.model?.model || '未记录'}</dd><dt>接口</dt><dd className="record-endpoint">{run.model?.verified === false ? '未记录' : run.model?.baseUrl || '本地演示'}</dd><dt>开始 / 结束</dt><dd>{time(run.startedAt)}<br />{time(run.finishedAt)}</dd><dt>模型轮次 / 工具</dt><dd>{run.steps} / {run.toolCalls}</dd><dt>已报告用量</dt><dd>{number(run.usage?.totalTokens)} tokens<br /><small>输入 {number(run.usage?.inputTokens)} · 输出 {number(run.usage?.outputTokens)}</small></dd>
{!!run.usage?.unknownRequests && <><dt>未报告用量</dt><dd>{run.usage.unknownRequests} 次请求 · 估算 {number(run.usage.estimatedUnknownTokens)} tokens</dd></>}
<dt>本次预算</dt><dd>{number(run.budget?.maxTokens)} tokens · {Math.round((run.budget?.maxDurationMs ?? 0) / 60000)} 分钟 · {run.budget?.maxSteps} 轮</dd><dt>任务累计</dt><dd>{number(execution?.accountedTaskTokens)} / {number(task.budget.maxTokens)} tokens</dd>
</dl>{run.stopReason && <p className="run-stop">{stopReasons[run.stopReason] || run.stopReason}</p>}
<p className="record-footnote">用量以服务返回为准;未报告的请求单独估算。</p>
</> : <p className="record-empty"><LoaderCircle size={14} className="spin" />正在读取运行记录</p>}
</section>}
<section className="task-record-section project-checks">
<div className="record-heading"><GitBranch size={15} /><h3>工程检查</h3><Status value={task?.verification.status || 'not_configured'} /></div>
<p className="record-footnote">检查对应当时的工程快照。先识别项目脚本,再执行检查;项目变化后重新检查。</p>
<button type="button" className="button secondary" disabled={!task || busy || planning || checkRunning} onClick={planChecks}>{planning ? <LoaderCircle size={14} className="spin" /> : <RefreshCw size={14} />}{latestPlan ? '重新识别检查计划' : '识别工程与检查'}</button>
{latestPlan && <div className="check-plan"><p><strong>{latestPlan.project.name}</strong> · {latestPlan.project.languages.join(' / ') || '待识别'}</p><p className="check-baseline"><GitBranch size={12} />{latestPlan.project.git.available ? `${latestPlan.project.git.branch || 'detached'} · ${latestPlan.project.git.head?.slice(0, 8) || '尚无提交'}${latestPlan.project.git.dirty ? ' · 有未提交改动' : ' · 工作区干净'}` : '项目尚未启用 Git'}</p>
{latestPlan.checks.length ? <><ul>{latestPlan.checks.map(check => <li key={check.id}><span>{check.name}</span><code>{check.command}</code></li>)}</ul><button type="button" className="button primary" disabled={busy || starting || checkRunning} onClick={() => setConfirmPlan(latestPlan)}><Play size={14} />执行这些检查</button></> : <p className="record-empty">没有识别到可执行的检查脚本。请在项目中配置测试或构建命令。</p>}
</div>}
{jobs.slice().reverse().map(job => <div key={job.id} className="check-job"><div className="record-heading"><Status value={job.stale ? 'stale' : job.status} /><code title={job.id}>{job.id.slice(0, 8)}</code>{['queued', 'running'].includes(job.status) && <button type="button" className="text-button" onClick={() => api<Session>('/sessions/' + session.id + '/check-jobs/' + job.id + '/stop', {}).then(onSession).catch(onError)}>停止检查</button>}</div><time>{time(job.startedAt)}</time>{job.currentCheck && <p className="check-current"><LoaderCircle size={12} className="spin" />正在执行 <code>{job.currentCheck.command}</code></p>}{job.summary && <p>{job.summary}</p>}{job.results.map(result => <div key={result.id} className="check-result"><div><strong>{result.name}</strong><Status value={result.status} /></div><p>退出码 {result.exitCode === null ? '未返回' : result.exitCode} · {(result.durationMs / 1000).toFixed(1)} 秒{result.tests && ` · 测试 ${result.tests.passed}/${result.tests.total} 通过`}</p>{result.reason && <p>{result.reason}</p>}{result.logArtifactId && <button type="button" className="text-button" disabled={previewBusy} onClick={() => openArtifact(result.logArtifactId!)}><FileText size={13} />查看检查日志</button>}</div>)}</div>)}
</section>
{!!execution?.artifacts.length && <section className="task-record-section"><div className="record-heading"><FileText size={15} /><h3>结果工件</h3><span>最近 {execution.artifacts.length} 项</span></div><div className="artifact-list">{execution.artifacts.slice().reverse().map(artifact => <button type="button" key={artifact.id} disabled={previewBusy} onClick={() => openArtifact(artifact.id)}><span>{artifact.kind === 'check-log' ? '检查日志' : artifact.kind === 'project-inspection' ? '工程识别' : '工具结果'}<code>{artifact.sha256.slice(0, 10)}</code></span><small>{number(artifact.bytes)} B</small></button>)}</div></section>}
{confirmPlan && <Modal title="执行工程检查" description="以下项目脚本在当前工程目录执行;检查记录保存退出码和日志。" onClose={() => setConfirmPlan(null)}><div className="check-confirm">{confirmPlan.checks.map(check => <div key={check.id}><strong>{check.command}</strong><pre>{check.script}{check.lifecycle?.length ? '\n\n' + check.lifecycle.map(item => item.name + ': ' + item.script).join('\n') : ''}</pre></div>)}<p>{confirmPlan.project.name} · {confirmPlan.project.packageManager}</p></div><div className="modal-actions"><button type="button" className="button secondary" disabled={starting} onClick={() => setConfirmPlan(null)}>取消</button><button type="button" className="button primary" disabled={starting} onClick={runChecks}><Check size={14} />确认执行检查</button></div></Modal>}
{preview && <Modal title="执行结果工件" description={`SHA256 ${preview.sha256}`} wide onClose={() => { artifactRequest.current++; setPreview(null); setPreviewBusy(false); }}><pre className="artifact-preview">{preview.content}</pre><div className="artifact-pagination"><span>字符 {number(preview.offset)}–{number(preview.offset + preview.content.length)} / {number(preview.totalCharacters)}</span><button type="button" className="button secondary" disabled={previewBusy || preview.offset === 0} onClick={() => openArtifact(preview.id, Math.max(0, preview.offset - 16000))}>上一段</button><button type="button" className="button secondary" disabled={previewBusy || !preview.truncated} onClick={() => openArtifact(preview.id, preview.offset + preview.content.length)}>下一段</button></div></Modal>}
</div>;
}
+6 -3
View File
@@ -1,5 +1,6 @@
import { useEffect, useRef } from 'react';
import type { ReactNode, ButtonHTMLAttributes } from 'react';
import { createPortal } from 'react-dom';
import { AlertTriangle, Check, ChevronRight, Circle, Clock3, FileCode2, LoaderCircle, RotateCw, ShieldQuestion, SquareTerminal, X, XCircle } from 'lucide-react';
import type { Change, ToolEvent, RuntimeFailure } from './types';
@@ -8,6 +9,8 @@ const statusNames: Record<string, string> = {
paused: '已暂停', failed: '需要处理', stopping: '正在停止', pending: '待审查', applied: '已应用',
rejected: '已撤回', conflict: '文件已变化', waiting: '等待确认', denied: '已拒绝', interrupted: '已中断',
retrying: '自动重试',
queued: '待执行', validating: '核对中', unknown: '结果待核对', unverified: '未验证',
not_configured: '尚未检查', passed: '检查通过', cancelled: '已取消', stale: '需重新检查',
};
export function Status({ value }: { value: string }) {
return <span className={'status status-' + value}><span className="status-dot" />{statusNames[value] || value}</span>;
@@ -34,12 +37,12 @@ export function Modal({ title, description, children, onClose, wide = false }: {
document.addEventListener('keydown', handle);
return () => { document.removeEventListener('keydown', handle); previous?.focus(); };
}, []);
return <div className="modal-backdrop" onMouseDown={event => { if (event.target === event.currentTarget) onClose(); }}>
return createPortal(<div className="modal-backdrop" onMouseDown={event => { if (event.target === event.currentTarget) onClose(); }}>
<div ref={panel} role="dialog" aria-modal="true" aria-label={title} className={'modal ' + (wide ? 'modal-wide' : '')}>
<div className="modal-heading"><div><h2>{title}</h2>{description && <p>{description}</p>}</div><IconButton label="关闭窗口" onClick={onClose}><X size={18} /></IconButton></div>
{children}
</div>
</div>;
</div>, document.body);
}
export function DiffView({ change }: { change: Change }) {
let before = 1, after = 1;
@@ -62,7 +65,7 @@ export function DiffView({ change }: { change: Change }) {
}
export function ToolRow({ event, selected = false, onSelect }: { event: ToolEvent; selected?: boolean; onSelect: () => void }) {
const phase = event.phase;
const Symbol = phase === 'waiting' ? ShieldQuestion : ['running', 'retrying'].includes(phase) ? LoaderCircle
const Symbol = ['waiting', 'unknown', 'unverified', 'queued', 'validating'].includes(phase) ? ShieldQuestion : ['running', 'retrying'].includes(phase) ? LoaderCircle
: ['failed', 'denied', 'interrupted'].includes(phase) ? XCircle : Check;
const detail = event.tool === 'run_command' ? String(event.input?.command || '')
: event.tool === 'read_file' || event.tool === 'propose_file' ? String(event.input?.path || '')
+18 -2
View File
@@ -1,6 +1,7 @@
export interface Config {
mode: 'demo' | 'compatible'; baseUrl: string; model: string;
contextLimit: number; maxSteps: number; maxOutputTokens: number; hasKey: boolean;
maxRunDurationMs: number; maxRunTokens: number; maxTaskTokens: number;
}
export interface Project { id: string; root: string; name: string; addedAt: string }
export interface SessionBrief { id: string; projectId: string; title: string; status: string; revision: number; updatedAt: string; changeCount: number }
@@ -9,6 +10,7 @@ export interface ToolEvent {
id: string; kind: string; label: string; phase: string; createdAt: string; tool?: string;
input?: Record<string, unknown>; output?: string; durationMs?: number; startedAt?: string; finishedAt?: string;
source?: string; attempts?: number; diagnostic?: RuntimeFailure; exitCode?: number;
taskId?: string; runId?: string; invocationId?: string; artifactId?: string;
}
export interface DiffPart { value: string; count: number; added?: boolean; removed?: boolean }
export interface Change {
@@ -16,13 +18,14 @@ export interface Change {
baseContent: string; content: string; sha256: string; diff: DiffPart[]; additions: number; deletions: number;
createdAt: string; appliedAt?: string;
}
export interface Approval { id: string; command: string; reason: string; cwd: string; shell?: string; status: string; createdAt: string }
export interface Approval { id: string; command: string; reason: string; cwd: string; shell?: string; status: string; createdAt: string; checkPlanId?: string; checkScripts?: { name: string; script: string; lifecycle: { name: string; script: string }[] }[] }
export interface Session {
id: string; projectId: string; title: string; status: string; revision: number; updatedAt: string; createdAt: string;
messages: Message[]; events: ToolEvent[]; changes: Change[]; approvals: Approval[];
compactions: number; estimatedTokens: number; usage: { prompt_tokens?: number; completion_tokens?: number } | null;
archived: boolean; recoveryNotice?: string | null; executionMode?: string;
failure?: RuntimeFailure | null; lastFailure?: RuntimeFailure | null;
execution?: ExecutionSnapshot;
}
export interface RuntimeFailure {
source: string; stage: string; kind: string; title: string; message: string; messageId?: string;
@@ -42,5 +45,18 @@ export interface RuntimeDiagnostics {
}
export interface FileEntry { path: string; name: string; kind: string; bytes: number }
export interface OpenFile { path: string; content: string; sha256: string; bytes: number }
export interface Bootstrap { token: string; version: string; config: Config; projects: Project[]; sessions: SessionBrief[]; exampleProjectId: string | null; environment?: ExecutionEnvironment }
export interface Bootstrap { token: string; version: string; config: Config; projects: Project[]; sessions: SessionBrief[]; exampleProjectId: string | null; environment?: ExecutionEnvironment; eventCursor?: number; storage?: { engine: string; schemaVersion: number }; runtimeRoot?: string }
export interface ResearchDoc { id: string; title: string; description: string }
export interface ModelSnapshot { mode: string; model: string; baseUrl: string; verified?: boolean; contextLimit?: number; maxOutputTokens?: number }
export interface Usage { requests: number; inputTokens: number; outputTokens: number; totalTokens: number; unknownRequests: number; estimatedUnknownTokens: number }
export interface RunBudget { maxSteps: number; maxDurationMs: number; maxTokens: number; maxTaskTokens: number }
export interface RunBrief { id: string; taskId: string; status: string; startedAt: string; finishedAt: string | null; steps: number; toolCalls: number; usage: Usage; stopReason: string | null; model: ModelSnapshot; budget: RunBudget; resumeOf: string | null }
export interface Run extends RunBrief { engine: string; checkpoint: { completedToolIds: string[]; pendingToolIds: string[]; requiresVerification: string[] } }
export interface Task { id: string; goal: string; status: string; instructions: { id: string; content: string; createdAt: string }[]; usage: Usage; budget: { maxTokens: number }; verification: { status: string; checkJobId: string | null }; origin: string }
export interface Artifact { id: string; taskId: string | null; runId: string | null; kind: string; mediaType: string; sha256: string; bytes: number; createdAt: string; status: string }
export interface ArtifactPreview extends Artifact { content: string; offset: number; totalCharacters: number; truncated: boolean }
export interface CheckResult { id: string; name: string; kind: string; command: string; status: string; exitCode: number | null; durationMs: number; tests: { total: number; passed: number; failed: number; skipped: number; cancelled: number } | null; logArtifactId?: string; reason?: string }
export interface CheckJob { id: string; taskId: string; runId: string; planId: string; status: string; startedAt: string; finishedAt: string | null; results: CheckResult[]; summary?: string; stale?: boolean; currentCheck?: { name: string; command: string; startedAt: string } | null; baseline?: { head: string | null; dirty: boolean; branch: string | null }; fingerprint?: string }
export interface CheckPlan { id: string; taskId: string; runId: string; status: string; fingerprint: string; createdAt: string; checks: { id: string; name: string; kind: string; command: string; script: string; lifecycle: { name: string; script: string }[] }[]; project: { name: string; languages: string[]; packageManager: string; rules: { path: string; sha256: string; excerpt: string }[]; scope: { complete: boolean; scannedFiles: number }; git: { available: boolean; head: string | null; dirty: boolean; branch: string | null; status: string } } }
export interface ExecutionSnapshot { schemaVersion: number; task: Task | null; run: Run | null; runs: RunBrief[]; progress: { totalTools: number; completedTools: number; requiresVerification: { id: string; tool: string; state: string; callId: string }[] }; artifacts: Artifact[]; checks: CheckJob[]; plans?: CheckPlan[]; accountedTaskTokens: number }