feat: preserve bounded model requests and complete task history

This commit is contained in:
Agent Workbench Dev
2026-10-29 21:09:50 +08:00
parent 19b738b468
commit 8f32dec6cc
58 changed files with 1269 additions and 108 deletions
+18 -1
View File
@@ -72,7 +72,7 @@ return async (request, response) => {
eventCursor: store.eventCursor, storage: store.storageInfo(), runtimeRoot: appDirectory,
environment: executionEnvironment(),
projects: store.projects, sessions: store.listSessions(), exampleProjectId: exampleProject?.id ?? null,
capabilities: { changeSets: 'reviewed-recoverable-batches', fileChanges: 'review', exactPatches: 'sha256-unique-anchors', codeIndex: 'bounded-ast-and-candidates', commands: 'per-call-approval', recovery: 'durable-tool-results', model: 'chat-completions-compatible', execution: 'task-run-step', events: 'persistent-cursor', artifacts: 'sha256-verified', checks: 'npm-script-jobs', projectInspection: 'bounded-source-and-git', gitDelivery: 'reviewed-local-snapshot', deliveryReports: 'evidence-json-markdown' },
capabilities: { requestContext: 'bounded-whole-request-and-history-artifacts', changeSets: 'reviewed-recoverable-batches', fileChanges: 'review', exactPatches: 'sha256-unique-anchors', codeIndex: 'bounded-ast-and-candidates', commands: 'per-call-approval', recovery: 'durable-tool-results', model: 'chat-completions-compatible', execution: 'task-run-step', events: 'persistent-cursor', artifacts: 'sha256-verified', checks: 'npm-script-jobs', projectInspection: 'bounded-source-and-git', gitDelivery: 'reviewed-local-snapshot', deliveryReports: 'evidence-json-markdown' },
});
if (method === 'GET' && route === '/api/diagnostics') {
const selected = url.searchParams.get('session');
@@ -142,6 +142,23 @@ return async (request, response) => {
const session = store.session(id);
if (method === 'GET' && !action) return json(response, store.publicSession(session));
if (method === 'GET' && action === 'execution') return json(response, store.executionSnapshot(session));
if (method === 'GET' && action === 'context-plans') {
const runId = url.searchParams.get('run'); if (runId) store.owned('run', runId, id);
return json(response, [...store.core.context_plan.values()].filter(plan => plan.sessionId === id && (!runId || plan.runId === runId)).slice(-100));
}
const contextPlan = action.match(/^context-plans\/([a-f0-9-]+)(?:\/(history))?$/);
if (method === 'GET' && contextPlan) {
const plan = store.owned('context_plan', contextPlan[1], id);
if (!contextPlan[2]) return json(response, plan);
if (!plan.historyIndexArtifactId) return json(response, { planId: plan.id, groups: [], offset: 0, totalGroups: 0, truncated: false });
const artifact = store.owned('artifact', plan.historyIndexArtifactId, id);
if (artifact.sha256 !== plan.historyIndexSha256) throw new Error('历史索引身份与请求计划不一致。');
const index = JSON.parse(store.artifactStore.read(artifact));
if (index.kind !== 'request-history-index' || index.sessionId !== id || index.projectId !== session.projectId || index.taskId !== plan.taskId) throw new Error('历史索引不属于这个任务。');
const offset = cursorNumber(url.searchParams.get('offset')), limit = Math.min(50, Math.max(1, cursorNumber(url.searchParams.get('limit')) || 12));
return json(response, { planId: plan.id, groups: index.archivedGroups.slice(offset, offset + limit), offset,
totalGroups: index.archivedGroups.length, truncated: offset + limit < index.archivedGroups.length });
}
if (method === 'POST' && action === 'change-sets') {
const input = await body(request); await runtime.changeSetManager().prepare(session, input.changeIds);
return json(response, store.publicSession(session), 201);