refactor(pi): share session manager runtime registry

This commit is contained in:
Peter Steinberger
2026-02-15 17:39:10 +00:00
parent c6b3736fe7
commit 9084c4e345
4 changed files with 60 additions and 55 deletions

View File

@@ -1,35 +1,12 @@
import { createSessionManagerRuntimeRegistry } from "./session-manager-runtime-registry.js";
export type CompactionSafeguardRuntimeValue = {
maxHistoryShare?: number;
contextWindowTokens?: number;
};
// Session-scoped runtime registry keyed by object identity.
// Follows the same WeakMap pattern as context-pruning/runtime.ts.
const REGISTRY = new WeakMap<object, CompactionSafeguardRuntimeValue>();
const registry = createSessionManagerRuntimeRegistry<CompactionSafeguardRuntimeValue>();
export function setCompactionSafeguardRuntime(
sessionManager: unknown,
value: CompactionSafeguardRuntimeValue | null,
): void {
if (!sessionManager || typeof sessionManager !== "object") {
return;
}
export const setCompactionSafeguardRuntime = registry.set;
const key = sessionManager;
if (value === null) {
REGISTRY.delete(key);
return;
}
REGISTRY.set(key, value);
}
export function getCompactionSafeguardRuntime(
sessionManager: unknown,
): CompactionSafeguardRuntimeValue | null {
if (!sessionManager || typeof sessionManager !== "object") {
return null;
}
return REGISTRY.get(sessionManager) ?? null;
}
export const getCompactionSafeguardRuntime = registry.get;