/** * Per-cwd PI runtime registry. * * Holds the cwd-keyed `HooksRuntime` cache, the most-recent `ExtensionContext` * per cwd (so HostAdapter UI calls can reach `ctx.ui` outside the event * handler scope), and the LRU bookkeeping that bounds both maps. * * Exposes: * - `getRuntimeFor(cwd)` — lazy-construct + memoise the runtime for a cwd * - `rememberContext(cwd, ctx)` — record the freshest ctx for that cwd * - `getLatestContext(cwd)` — peek the freshest ctx (used by user-bash plumbing) * - `touchLruEntry` / `evictLruEntries` — pure helpers, exported for tests (P2-6) * * Extracted from `adapter.ts` as part of the P0/P1 refactor; behaviour and * eviction policy are unchanged. */ import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent"; import { type HooksRuntime } from "../core/runtime.js"; export interface RuntimeRegistry { getRuntimeFor(cwd: string): HooksRuntime; rememberContext(cwd: string, ctx: ExtensionContext): void; getLatestContext(cwd: string): ExtensionContext | undefined; } export declare function createRuntimeRegistry(pi: ExtensionAPI): RuntimeRegistry; /** * Promote `cwd` to most-recent. If the key exists, it is re-inserted so that * Map iteration order places it last (the freshest entry). Used by both the * production runtime (via `touchCwd`) and unit tests (via `__testing__`), * so the LRU eviction policy has a single source of truth (P2-6). */ export declare function touchLruEntry(map: Map, cwd: string): void; /** * Drop oldest entries from `map` (and `companion`, if provided) until at * most `maxEntries` remain. Returns the keys that were evicted. Shared * between the production `evictIfNeeded` and the test surface (P2-6). */ export declare function evictLruEntries(map: Map, maxEntries: number, companion?: Map): string[];