mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-13 11:00:50 +00:00
Verified: - pnpm install --frozen-lockfile - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: yfge <1186273+yfge@users.noreply.github.com> Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
37 lines
939 B
TypeScript
37 lines
939 B
TypeScript
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 clearBootstrapSnapshotOnSessionRollover(params: {
|
|
sessionKey?: string;
|
|
previousSessionId?: string;
|
|
}): void {
|
|
if (!params.sessionKey || !params.previousSessionId) {
|
|
return;
|
|
}
|
|
|
|
clearBootstrapSnapshot(params.sessionKey);
|
|
}
|
|
|
|
export function clearAllBootstrapSnapshots(): void {
|
|
cache.clear();
|
|
}
|