feat: add reviewed Task Git delivery and verified evidence reports
This commit is contained in:
+7
-3
@@ -11,7 +11,7 @@ const defaultConfig: Config = { mode: 'demo', baseUrl: 'http://127.0.0.1:11434/v
|
||||
|
||||
export default function App() {
|
||||
const [token, setAccess] = useState('');
|
||||
const [version, setVersion] = useState('1.1.0');
|
||||
const [version, setVersion] = useState('1.2.0');
|
||||
const [diagnosticsOpen, setDiagnosticsOpen] = useState(false);
|
||||
const [diagnostics, setDiagnostics] = useState<RuntimeDiagnostics | null>(null);
|
||||
const [diagnosticsBusy, setDiagnosticsBusy] = useState(false);
|
||||
@@ -71,7 +71,8 @@ export default function App() {
|
||||
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) || session.execution?.checks.some(job => ['queued', 'running'].includes(job.status)) === true);
|
||||
const isRunning = !!session && (activeStates.includes(session.status) || session.execution?.checks.some(job => ['queued', 'running'].includes(job.status)) === true
|
||||
|| session.execution?.deliveries?.some(job => ['queued', 'preparing', 'prepared', 'publishing', 'committed', 'reporting'].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);
|
||||
@@ -101,6 +102,7 @@ export default function App() {
|
||||
function notify(message: string) { setToast(message); }
|
||||
function failure(error: unknown) { notify(error instanceof Error ? error.message : String(error)); }
|
||||
function selectSession(id: string) {
|
||||
if (selectedSessionRef.current === id) return;
|
||||
selectedSessionRef.current = id; setSessionId(id); setSession(null);
|
||||
localStorage.setItem('awb-session', id); setChangeId(''); setEventId('');
|
||||
}
|
||||
@@ -140,7 +142,9 @@ export default function App() {
|
||||
if (window.innerWidth <= 620) setSidebarOpen(false);
|
||||
}
|
||||
async function chooseSession(id: string) {
|
||||
selectSession(id);
|
||||
if (selectedSessionRef.current === id) {
|
||||
try { acceptSession(await api<Session>('/sessions/' + id)); } catch (error) { failure(error); }
|
||||
} else selectSession(id);
|
||||
if (window.innerWidth <= 620) setSidebarOpen(false);
|
||||
}
|
||||
async function newSession() {
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
.git-delivery .record-footnote { display: block; }
|
||||
.delivery-route { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; font-size: 10px; margin: 13px 0 16px; color: var(--muted); }
|
||||
.delivery-route span { border: 1px solid var(--line); border-radius: 4px; padding: 5px 7px; }
|
||||
.delivery-route .done { background: #edf7ef; border-color: #b8d6c4; color: #277958; }
|
||||
.delivery-route i { font-style: normal; }
|
||||
.delivery-message { margin: 10px 0; font-size: 11px; }
|
||||
.delivery-message textarea { resize: vertical; min-height: 58px; max-height: 150px; width: 100%; font-size: 11px; line-height: 1.7; padding: 9px; border: 1px solid var(--line); border-radius: 5px; background: white; }
|
||||
.delivery-author { font-size: 11px; margin: 10px 0 15px; }
|
||||
.delivery-author summary { cursor: pointer; color: var(--teal); }
|
||||
.delivery-author p { color: var(--muted); font-size: 10px; line-height: 1.8; margin: 8px 0; }
|
||||
.delivery-author .form-field { font-size: 11px; margin: 8px 0; }
|
||||
.delivery-author input { padding: 7px 9px; font-size: 11px; }
|
||||
.delivery-job { font-size: 11px; line-height: 1.8; padding: 14px 0; border-top: 1px solid var(--line); margin-top: 15px; }
|
||||
.delivery-job .record-heading { flex-wrap: wrap; margin-bottom: 5px; }
|
||||
.delivery-job time { color: var(--muted); font-size: 10px; }
|
||||
.delivery-job > p { margin: 7px 0; overflow-wrap: anywhere; }
|
||||
.delivery-current { display: flex; align-items: center; gap: 6px; color: var(--teal); }
|
||||
.delivery-commit { display: flex; align-items: flex-start; gap: 6px; background: #edf3f1; padding: 8px; border-radius: 4px; margin-top: 8px; color: var(--teal); }
|
||||
.delivery-commit svg { flex: none; margin-top: 3px; }
|
||||
.delivery-commit code { overflow-wrap: anywhere; font-size: 10px; }
|
||||
.delivery-paths { padding-left: 14px; margin: 10px 0; color: var(--muted); }
|
||||
.delivery-paths li { overflow-wrap: anywhere; }
|
||||
.delivery-preserved { display: flex; align-items: flex-start; gap: 6px; color: #277958; }
|
||||
.delivery-preserved svg, .delivery-warning svg { flex: none; margin-top: 3px; }
|
||||
.delivery-report-actions { display: flex; gap: 4px 10px; flex-wrap: wrap; margin-top: 8px; }
|
||||
.delivery-report-actions .text-button { padding: 3px 0; }
|
||||
.delivery-attention { padding: 12px; border: 1px solid #e7d8b8; background: #fffaf0; border-radius: 5px; }
|
||||
.delivery-warning { display: flex; align-items: flex-start; gap: 6px; color: #805d22; font-size: 11px; line-height: 1.8; }
|
||||
.delivery-report-summary { border-top: 1px solid var(--line); padding-top: 16px; margin-top: 15px; }
|
||||
.delivery-report-summary > .text-button { display: flex; margin-top: 8px; padding-left: 0; }
|
||||
.delivery-confirm { flex: 1; min-height: 0; overflow: auto; font-size: 12px; }
|
||||
.delivery-confirm-overview { display: flex; flex-direction: column; gap: 5px; border-left: 2px solid #7da89c; padding-left: 11px; margin-bottom: 16px; line-height: 1.7; }
|
||||
.delivery-confirm-overview span { color: var(--muted); font-size: 11px; }
|
||||
.delivery-confirm-message { white-space: pre-wrap; }
|
||||
.delivery-checks { list-style: none; padding: 0; margin: 17px 0; font-size: 11px; }
|
||||
.delivery-checks li { display: flex; align-items: flex-start; gap: 7px; margin-top: 9px; color: #277958; flex-wrap: wrap; }
|
||||
.delivery-checks strong { font-family: "Cascadia Code", Consolas, monospace; font-size: 11px; }
|
||||
.delivery-checks span { color: var(--muted); }
|
||||
.delivery-policy { background: #faf7ef; color: #805d22; border-left: 2px solid #bd9654; padding: 10px 12px; font-size: 11px; line-height: 1.8; margin: 14px 0; }
|
||||
.delivery-diffs details { border: 1px solid var(--line); border-radius: 5px; margin: 9px 0; overflow: hidden; }
|
||||
.delivery-diffs summary { padding: 11px; background: #edf3f1; cursor: pointer; font-size: 11px; line-height: 1.6; }
|
||||
.delivery-diffs summary span { overflow-wrap: anywhere; }
|
||||
.delivery-diffs summary small { float: right; color: var(--muted); margin-left: 9px; font-size: 10px; }
|
||||
.delivery-diffs p { font-size: 11px; line-height: 1.8; margin: 10px 12px; overflow-wrap: anywhere; }
|
||||
.delivery-diffs pre { font-size: 11px; line-height: 1.7; overflow: auto; max-height: 340px; padding: 12px; background: #fcfdfc; }
|
||||
.delivery-file-hash { display: block; padding: 9px 12px; font-size: 10px; color: var(--muted); overflow-wrap: anywhere; border-top: 1px solid var(--line); }
|
||||
.status-preparing, .status-prepared, .status-publishing, .status-committed, .status-reporting { background: #edf3f1; color: var(--teal); }
|
||||
@media (max-width: 620px) {
|
||||
.delivery-confirm .record-fields { grid-template-columns: 76px minmax(0, 1fr); }
|
||||
.delivery-confirm-overview strong { font-size: 12px; }
|
||||
.delivery-checks li { column-gap: 5px; }
|
||||
.delivery-checks span { width: 100%; padding-left: 18px; }
|
||||
.delivery-diffs summary small { float: none; display: block; margin: 4px 0 0 13px; }
|
||||
.delivery-report-actions { column-gap: 12px; }
|
||||
}
|
||||
@media (prefers-reduced-motion: reduce) { .delivery-current .spin { animation: none; } }
|
||||
@@ -0,0 +1,122 @@
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
import { ArrowDownToLine, Check, FileCheck2, FileText, GitCommitHorizontal, LoaderCircle, RefreshCw, ShieldQuestion } from 'lucide-react';
|
||||
import { api, downloadArtifact } from './api';
|
||||
import { Modal, Status } from './components';
|
||||
import type { DeliveryPlan, Session } from './types';
|
||||
import './DeliveryPanel.css';
|
||||
|
||||
const active = ['queued', 'preparing', 'prepared', 'publishing', 'committed', 'reporting'];
|
||||
const stageLabel: Record<string, string> = { queued: '正在核对提交基线', preparing: '正在准备已审核文件', prepared: '文件快照已准备', publishing: '正在生成本地提交', committed: '正在核对实际提交', reporting: '正在生成交付报告' };
|
||||
const date = (value: string | null) => value ? new Date(value).toLocaleString('zh-CN', { month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit' }) : '执行中';
|
||||
|
||||
export function DeliveryPanel({ session, busy, onSession, onError, openArtifact }: {
|
||||
session: Session; busy: boolean; onSession: (value: Session) => void; onError: (error: unknown) => void; openArtifact: (id: string) => void;
|
||||
}) {
|
||||
const task = session.execution?.task;
|
||||
const jobs = session.execution?.deliveries ?? [];
|
||||
const [message, setMessage] = useState('');
|
||||
const [authorName, setAuthorName] = useState('');
|
||||
const [authorEmail, setAuthorEmail] = useState('');
|
||||
const [planning, setPlanning] = useState(false);
|
||||
const [confirm, setConfirm] = useState<DeliveryPlan | null>(null);
|
||||
const [submitting, setSubmitting] = useState(false);
|
||||
const [reporting, setReporting] = useState(false);
|
||||
const [reconciling, setReconciling] = useState('');
|
||||
const [downloading, setDownloading] = useState(false);
|
||||
const identity = useRef(0);
|
||||
const inFlight = useRef(false);
|
||||
const running = jobs.some(job => active.includes(job.status));
|
||||
const unresolved = jobs.some(job => job.requiresVerification);
|
||||
const pending = session.changes.some(change => ['pending', 'conflict'].includes(change.status));
|
||||
const hasApplied = session.changes.some(change => change.taskId === task?.id && change.status === 'applied');
|
||||
const reports = session.execution?.artifacts.filter(artifact => artifact.kind === 'delivery-report-markdown') ?? [];
|
||||
const latestReport = reports.at(-1);
|
||||
|
||||
useEffect(() => {
|
||||
identity.current++; setConfirm(null); setPlanning(false); setSubmitting(false); setReporting(false); setReconciling('');
|
||||
setMessage(task ? '完成:' + task.goal.replace(/\s+/g, ' ').slice(0, 90) : ''); setAuthorName(''); setAuthorEmail('');
|
||||
inFlight.current = false;
|
||||
}, [session.id, task?.id]);
|
||||
|
||||
async function prepare() {
|
||||
if (inFlight.current) return;
|
||||
inFlight.current = true; setPlanning(true); const request = identity.current;
|
||||
try {
|
||||
const result = await api<Session>('/sessions/' + session.id + '/delivery-plans', { message, ...(authorName.trim() ? { authorName: authorName.trim() } : {}), ...(authorEmail.trim() ? { authorEmail: authorEmail.trim() } : {}) });
|
||||
if (request !== identity.current) return;
|
||||
onSession(result); setConfirm(result.execution?.deliveryPlans?.at(-1) ?? null);
|
||||
} catch (error) { if (request === identity.current) onError(error); }
|
||||
finally { if (request === identity.current) { inFlight.current = false; setPlanning(false); } }
|
||||
}
|
||||
async function commit() {
|
||||
if (!confirm || inFlight.current) return;
|
||||
inFlight.current = true; setSubmitting(true); const request = identity.current;
|
||||
try {
|
||||
const result = await api<Session>('/sessions/' + session.id + '/delivery-jobs', { planId: confirm.id });
|
||||
if (request === identity.current) { onSession(result); setConfirm(null); }
|
||||
} catch (error) { if (request === identity.current) onError(error); }
|
||||
finally { if (request === identity.current) { inFlight.current = false; setSubmitting(false); } }
|
||||
}
|
||||
async function report() {
|
||||
if (inFlight.current) return;
|
||||
inFlight.current = true; setReporting(true); const request = identity.current;
|
||||
try {
|
||||
const result = await api<Session>('/sessions/' + session.id + '/delivery-reports', {});
|
||||
if (request !== identity.current) return;
|
||||
onSession(result);
|
||||
const artifact = result.execution?.artifacts.filter(value => value.kind === 'delivery-report-markdown').at(-1);
|
||||
if (artifact) openArtifact(artifact.id);
|
||||
} catch (error) { if (request === identity.current) onError(error); }
|
||||
finally { if (request === identity.current) { inFlight.current = false; setReporting(false); } }
|
||||
}
|
||||
async function reconcile(jobId: string) {
|
||||
if (inFlight.current) return;
|
||||
inFlight.current = true; setReconciling(jobId); const request = identity.current;
|
||||
try {
|
||||
const result = await api<Session>('/sessions/' + session.id + '/delivery-jobs/' + jobId + '/reconcile', {});
|
||||
if (request === identity.current) onSession(result);
|
||||
} catch (error) { if (request === identity.current) onError(error); }
|
||||
finally { if (request === identity.current) { inFlight.current = false; setReconciling(''); } }
|
||||
}
|
||||
async function download(id: string, extension: string) {
|
||||
setDownloading(true);
|
||||
try { await downloadArtifact(session.id, id, 'Agent-Workbench-delivery-' + (task?.id.slice(0, 8) ?? session.id.slice(0, 8)) + extension); }
|
||||
catch (error) { onError(error); } finally { setDownloading(false); }
|
||||
}
|
||||
|
||||
return <section className="task-record-section git-delivery" aria-label="Git交付">
|
||||
<div className="record-heading"><GitCommitHorizontal size={16} /><h3>审核提交与交付</h3></div>
|
||||
<p className="record-footnote">核对当前任务已应用的文件和实际测试,预览后生成本地提交。其他项目改动保留。</p>
|
||||
<div className="delivery-route" aria-label="交付步骤"><span className={hasApplied && !pending ? 'done' : ''}>文件已审查</span><i>→</i><span className={task?.verification.status === 'passed' ? 'done' : ''}>实际检查</span><i>→</i><span className={jobs.some(job => job.status === 'completed') ? 'done' : ''}>本地提交</span></div>
|
||||
<label className="form-field delivery-message">提交说明<textarea aria-label="提交说明" rows={2} value={message} maxLength={1600} disabled={busy || running} onChange={event => setMessage(event.target.value)} /></label>
|
||||
<details className="delivery-author"><summary>Git署名</summary><p>默认采用项目Git署名;尚未配置时使用 Agent Workbench 本地身份。预览会展示实际署名。</p><label className="form-field">提交者姓名<input value={authorName} disabled={busy || running} onChange={event => setAuthorName(event.target.value)} placeholder="采用默认署名" autoComplete="off" /></label><label className="form-field">提交者邮箱<input type="email" value={authorEmail} disabled={busy || running} onChange={event => setAuthorEmail(event.target.value)} placeholder="采用默认邮箱" autoComplete="off" /></label></details>
|
||||
<button type="button" className="button primary" aria-label="预览Git提交" disabled={!task || !hasApplied || pending || busy || running || unresolved || planning || !message.trim()} onClick={prepare}>{planning ? <LoaderCircle size={14} className="spin" /> : <GitCommitHorizontal size={14} />}预览Git提交</button>
|
||||
{(!hasApplied || pending) && <p className="record-footnote">应用本任务的文件提案后,可以准备Git提交。</p>}
|
||||
{jobs.slice().reverse().map(job => <div key={job.id} className={'delivery-job ' + (job.requiresVerification ? 'delivery-attention' : '')}>
|
||||
<div className="record-heading"><Status value={job.status} /><code>{job.id.slice(0, 8)}</code>{active.includes(job.status) && <button type="button" className="text-button" onClick={() => api<Session>('/sessions/' + session.id + '/delivery-jobs/' + job.id + '/stop', {}).then(onSession).catch(onError)}>停止提交</button>}</div>
|
||||
<time>{date(job.startedAt)} · {job.branch}</time>
|
||||
{active.includes(job.status) && <p className="delivery-current"><LoaderCircle size={13} className="spin" />{stageLabel[job.status]}</p>}
|
||||
{job.commit && <div className="delivery-commit"><GitCommitHorizontal size={14} /><code title={job.commit}>{job.commit}</code></div>}
|
||||
<ul className="delivery-paths">{job.paths.map(relative => <li key={relative}>{relative}</li>)}</ul>
|
||||
{job.summary && <p>{job.summary}</p>}
|
||||
{job.requiresVerification && <><p className="delivery-warning"><ShieldQuestion size={14} />先核对实际提交;本次不会再次提交文件。匹配本次遗留索引锁时会完成索引恢复。</p><button type="button" className="button secondary" disabled={busy || !!reconciling} onClick={() => reconcile(job.id)}>{reconciling === job.id ? <LoaderCircle size={14} className="spin" /> : <RefreshCw size={14} />}核对提交结果</button></>}
|
||||
{job.status === 'completed' && <p className="delivery-preserved"><FileCheck2 size={13} />实际提交已核对 · 无关修改已保留</p>}
|
||||
{job.reportError && <p className="delivery-warning">提交已保存;报告生成失败,可以再次生成报告。</p>}
|
||||
{job.reportMarkdownArtifactId && <div className="delivery-report-actions"><button type="button" className="text-button" onClick={() => openArtifact(job.reportMarkdownArtifactId!)}><FileText size={13} />查看交付报告</button><button type="button" className="text-button" disabled={downloading} onClick={() => download(job.reportMarkdownArtifactId!, '.md')}><ArrowDownToLine size={13} />下载Markdown</button>{job.reportArtifactId && <button type="button" className="text-button" disabled={downloading} onClick={() => download(job.reportArtifactId!, '.json')}>下载JSON</button>}</div>}
|
||||
</div>)}
|
||||
<div className="delivery-report-summary"><button type="button" className="button secondary" disabled={!task || busy || running || reporting || planning} onClick={report}>{reporting ? <LoaderCircle size={14} className="spin" /> : <FileText size={14} />}生成交付报告</button>
|
||||
{latestReport && <button type="button" className="text-button" onClick={() => openArtifact(latestReport.id)}>查看最新报告</button>}
|
||||
<p className="record-footnote">报告记录实际源码、检查、提交和模型用量,注明尚待确认的结果。</p>
|
||||
</div>
|
||||
{confirm && <Modal title="确认本地Git提交" description="核对以下文件、实际检查和提交署名后确认。" wide onClose={() => { if (!submitting) setConfirm(null); }}>
|
||||
<div className="delivery-confirm">
|
||||
<div className="delivery-confirm-overview"><strong>{confirm.paths.length} 个文件 · {confirm.baseline.branch}</strong><span>Task {confirm.taskId.slice(0, 8)} · HEAD {confirm.baseline.head.slice(0, 12)}</span></div>
|
||||
<dl className="record-fields"><dt>提交说明</dt><dd className="delivery-confirm-message">{confirm.message}</dd><dt>实际署名</dt><dd>{confirm.author.name} <{confirm.author.email}>{confirm.author.source === 'workbench-local' && <small> · 工作台本地默认身份</small>}</dd><dt>源文件指纹</dt><dd><code>{confirm.sourceFingerprint}</code></dd><dt>检查记录</dt><dd><code>{confirm.checkJobId}</code></dd></dl>
|
||||
<ul className="delivery-checks">{confirm.checkSummary.map(check => <li key={check.name}><Check size={13} /><strong>{check.command}</strong><span>退出码 {check.exitCode}{check.tests ? ' · ' + check.tests.passed + '/' + check.tests.total + ' 测试通过' : ''}</span></li>)}</ul>
|
||||
<p className="delivery-policy">{confirm.policy.note}</p>
|
||||
<div className="delivery-diffs">{confirm.files.map(file => <details key={file.path} open={confirm.files.length === 1}><summary><span>{file.path}</span><small>+{file.additions} / −{file.deletions}</small></summary><p>{file.reason}</p><pre aria-label={'提交差异 ' + file.path}>{file.diff}</pre><code className="delivery-file-hash">SHA256 {file.sha256}</code></details>)}</div>
|
||||
</div>
|
||||
<div className="modal-actions"><button type="button" className="button secondary" disabled={submitting} onClick={() => setConfirm(null)}>返回修改</button><button type="button" className="button primary" aria-label="确认创建本地提交" disabled={submitting} onClick={commit}>{submitting ? <LoaderCircle size={14} className="spin" /> : <Check size={14} />}确认创建本地提交</button></div>
|
||||
</Modal>}
|
||||
</section>;
|
||||
}
|
||||
@@ -3,6 +3,7 @@ import { Check, ClipboardCheck, FileText, GitBranch, LoaderCircle, Play, Refresh
|
||||
import type { ArtifactPreview, CheckPlan, Run, Session } from './types';
|
||||
import { api } from './api';
|
||||
import { Modal, Status } from './components';
|
||||
import { DeliveryPanel } from './DeliveryPanel';
|
||||
import './TaskPanel.css';
|
||||
|
||||
const stopReasons: Record<string, string> = { time_limit: '到达运行时间预算', token_limit: '到达本次 token 预算', task_token_limit: '到达任务累计预算', step_limit: '到达工具轮次上限', cancelled: '用户停止', model_error: '模型请求失败', interrupted: '进程中断' };
|
||||
@@ -81,7 +82,8 @@ export function TaskPanel({ session, onSession, onError, busy }: { session: Sess
|
||||
</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>}
|
||||
{task && <DeliveryPanel session={session} busy={busy} onSession={onSession} onError={onError} openArtifact={openArtifact} />}
|
||||
{!!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' ? '工程识别' : artifact.kind === 'delivery-report' ? '交付报告 · JSON' : artifact.kind === 'delivery-report-markdown' ? '交付报告 · Markdown' : artifact.kind === 'delivery-diff' ? '提交差异' : '工具结果'}<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>;
|
||||
|
||||
@@ -16,6 +16,14 @@ export async function exportSession(id: string) {
|
||||
const blob = await response.blob();
|
||||
downloadBlob(blob, 'agent-workbench-session-' + id + '.json');
|
||||
}
|
||||
export async function downloadArtifact(sessionId: string, artifactId: string, name: string) {
|
||||
const response = await fetch('/api/artifacts/' + artifactId + '?session=' + sessionId + '&download=1', { headers: { 'X-Workbench-Token': accessToken } });
|
||||
if (!response.ok) {
|
||||
const value = await response.json().catch(() => ({}));
|
||||
throw new Error(value.error || '工件下载失败。');
|
||||
}
|
||||
downloadBlob(await response.blob(), name);
|
||||
}
|
||||
export function downloadBlob(blob: Blob, name: string) {
|
||||
const url = URL.createObjectURL(blob);
|
||||
const link = document.createElement('a'); link.href = url; link.download = name; link.click();
|
||||
|
||||
@@ -11,6 +11,8 @@ const statusNames: Record<string, string> = {
|
||||
retrying: '自动重试',
|
||||
queued: '待执行', validating: '核对中', unknown: '结果待核对', unverified: '未验证',
|
||||
not_configured: '尚未检查', passed: '检查通过', cancelled: '已取消', stale: '需重新检查',
|
||||
planned: '待确认', preparing: '准备提交', prepared: '准备完成', publishing: '发布本地提交', committed: '已生成提交',
|
||||
reporting: '生成报告',
|
||||
};
|
||||
export function Status({ value }: { value: string }) {
|
||||
return <span className={'status status-' + value}><span className="status-dot" />{statusNames[value] || value}</span>;
|
||||
|
||||
+14
-2
@@ -58,6 +58,18 @@ export interface Task { id: string; goal: string; status: string; instructions:
|
||||
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 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; sourceFingerprint?: 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 }
|
||||
export interface DeliveryPlan {
|
||||
id: string; sessionId: string; projectId: string; taskId: string; runId: string; status: string; message: string;
|
||||
author: { name: string; email: string; source: string }; baseline: { head: string; branch: string; reference: string };
|
||||
paths: string[]; files: { path: string; changeIds: string[]; mode: string; sha256: string; additions: number; deletions: number; reason: string; diff: string }[];
|
||||
checkJobId: string; checkSummary: { name: string; command: string; exitCode: number; tests: CheckResult['tests']; logArtifactId: string }[];
|
||||
sourceFingerprint: string; diffArtifactId: string; policy: { note: string; hooks: string; signing: string };
|
||||
}
|
||||
export interface DeliveryJob {
|
||||
id: string; sessionId: string; taskId: string; runId: string; planId: string; status: string; parent: string; branch: string; paths: string[];
|
||||
commit: string | null; expectedCommit?: string | null; summary?: string; requiresVerification: boolean; startedAt: string; finishedAt: string | null;
|
||||
reportArtifactId?: string; reportMarkdownArtifactId?: string; reportError?: string; indexPreserved?: boolean; workspacePreserved?: boolean;
|
||||
}
|
||||
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[]; deliveries?: DeliveryJob[]; deliveryPlans?: DeliveryPlan[]; accountedTaskTokens: number }
|
||||
|
||||
Reference in New Issue
Block a user