feat: preserve source-bound experience drafts and reversible adoption

This commit is contained in:
Agent Workbench Dev
2026-11-06 17:06:29 +08:00
parent c1d30bbe82
commit 52cd60f226
9 changed files with 524 additions and 8 deletions
+13 -1
View File
@@ -55,7 +55,7 @@ const research = [
{ id: 'context', title: 'Claude Code:上下文与恢复', file: 'research/CONTEXT-RECOVERY.md', description: '压缩预算、摘要校验、会话链与未完成调用。' },
{ id: 'tools', title: 'Claude Code:工具循环', file: 'research/TOOL-LOOP.md', description: '参数校验、队列、并发安全与权限判断。' },
];
const memories = new ProjectMemoryManager(store);
const memories = new ProjectMemoryManager(store, { redact: value => provider.redact(value) });
function json(response, value, status = 200) {
response.writeHead(status, { 'Content-Type': 'application/json; charset=utf-8', 'Cache-Control': 'no-store',
@@ -168,6 +168,18 @@ return async (request, response) => {
return json(response, await memories.list(projectMemoryMatch[1], { includeExpired }));
}
const sessionMemoryMatch = route.match(/^\/api\/sessions\/([a-f0-9-]+)\/memories$/i);
const experienceMatch = route.match(/^\/api\/sessions\/([a-f0-9-]+)\/memories\/experiences(?:\/([a-f0-9-]+)\/(edit|adopt|withdraw|reject|counterexample|archive))?$/i);
if (experienceMatch) {
const session = store.session(experienceMatch[1]);
if (method === 'GET' && !experienceMatch[2]) return json(response, memories.experiences.sources(session));
if (method === 'POST') {
if (workerForProject(store, session.projectId)) throw workerConflict('请从来源项目的记忆入口管理经验。');
const input = await body(request);
return json(response, experienceMatch[2]
? await memories.experiences.change(session, experienceMatch[2], experienceMatch[3], input)
: await memories.experiences.create(session, input), experienceMatch[2] ? 200 : 201);
}
}
if (sessionMemoryMatch && method === 'GET') {
const session = store.session(sessionMemoryMatch[1]);
const includeExpired = url.searchParams.get('include_expired') !== '0';
+1 -1
View File
@@ -234,7 +234,7 @@ export class Runtime {
budgetResumes(){return this.resumes??=new BudgetResume(this.store,this.provider,this);}
resumeBudget(id,input){const session=this.store.session(id),plan=this.budgetResumes().verify(session,input);return this.start(id,'',true,{resumePlan:plan});}
engineRunner() { return this.controlledEngines ??= new EngineRunner(this.store, this.provider, { appDirectory: this.appDirectory }); }
memoryManager() { return this.projectMemories ??= new ProjectMemoryManager(this.store); }
memoryManager() { return this.projectMemories ??= new ProjectMemoryManager(this.store, { redact: value => this.provider.redact(value) }); }
checkpointManager() { return this.taskCheckpoints ??= new TaskCheckpointManager(this.store, {
taskPlans: this.taskPlanner(), redact: value => this.provider.redact(value) }); }
skillRegistry() { return this.skills ??= new SkillRegistry(this.store, {