mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 10:51:23 +00:00
fix(agents): cache bootstrap snapshots per session key
Co-authored-by: Isis Anisoptera <github@lotuswind.net>
This commit is contained in:
25
src/agents/bootstrap-cache.ts
Normal file
25
src/agents/bootstrap-cache.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { loadWorkspaceBootstrapFiles, type WorkspaceBootstrapFile } from "./workspace.js";
|
||||
|
||||
const cache = new Map<string, WorkspaceBootstrapFile[]>();
|
||||
|
||||
export async function getOrLoadBootstrapFiles(params: {
|
||||
workspaceDir: string;
|
||||
sessionKey: string;
|
||||
}): Promise<WorkspaceBootstrapFile[]> {
|
||||
const existing = cache.get(params.sessionKey);
|
||||
if (existing) {
|
||||
return existing;
|
||||
}
|
||||
|
||||
const files = await loadWorkspaceBootstrapFiles(params.workspaceDir);
|
||||
cache.set(params.sessionKey, files);
|
||||
return files;
|
||||
}
|
||||
|
||||
export function clearBootstrapSnapshot(sessionKey: string): void {
|
||||
cache.delete(sessionKey);
|
||||
}
|
||||
|
||||
export function clearAllBootstrapSnapshots(): void {
|
||||
cache.clear();
|
||||
}
|
||||
Reference in New Issue
Block a user