/** * Session-scoped native Code Mode sessions. * * Primary path: in-process NAPI (`CodeModeSession` inside Node) — same model as * MCP linking core. Zero CLI spawn. * * Fallback: sticky `codemode-serve` child only when the `.node` addon is missing * (unsupported host / incomplete install). Doctor reports that as degraded. */ import type { MachineEnvelope } from "../runtime/runtime.js"; import { type StickyWorker } from "./dispatch.js"; import { type StickyWorkerOptions } from "./worker.js"; export type SessionPoolOptions = { /** Required only for CLI sticky fallback. */ binary?: string; env?: NodeJS.ProcessEnv; timeoutMs?: number; maxOutputBytes?: number; root?: string; indexPath?: string; useEmbed?: boolean; limit?: number; }; export type StickyStarter = (options: StickyWorkerOptions) => Promise; /** Unique search must not run on the JS thread; cache hits may. */ export declare function isUncachedSearchError(cause: unknown): boolean; export declare function isClosedWorkerError(cause: unknown): boolean; export declare class NativeSessionPool { #private; constructor(startFn?: StickyStarter); configure(options: SessionPoolOptions): void; configured(): boolean; /** Active backend after first successful acquire. */ backend(): "napi" | "cli" | "none"; /** Why the last start attempt failed — for doctor/status and error fidelity. */ lastStartError(root: string): string | undefined; acquire(root: string): Promise; call(root: string, tool: string, args?: Record, options?: { signal?: AbortSignal; }): Promise; invalidate(root: string): Promise; shutdown(): Promise; } /** Singleton for advanced hosts; tools registration uses a local pool. */ export declare const sharedNativePool: NativeSessionPool;