mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 19:04:31 +00:00
refactor(pi): share session manager runtime registry
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user