import type { AgentTool } from '@earendil-works/pi-agent-core'; import type { ThinkingLevel } from '@earendil-works/pi-agent-core'; import { type AgentSession } from '@earendil-works/pi-coding-agent'; import type { Model, Api } from '@earendil-works/pi-ai'; import { type GuardedPiTranscriptManager } from './session-tool-result-guard.js'; export type EmbeddedRunnerFingerprintInput = { sessionId: string; workspaceDir: string; modelRef: string; toolNames: readonly string[]; systemPrompt: string; thinkingLevel: string; credentialRevision: string; }; export declare function buildEmbeddedRunnerFingerprint(input: EmbeddedRunnerFingerprintInput): string; export type AcquireEmbeddedSessionRunnerParams = { sessionKey: string; sessionId: string; workspaceDir: string; model: Model; modelRef: string; tools: AgentTool[]; systemPrompt: string; thinkingLevel: ThinkingLevel; }; export type AcquiredEmbeddedSessionRunner = { session: AgentSession; piSm: GuardedPiTranscriptManager; reused: boolean; release: () => void; }; export interface EmbeddedSessionRunnerPoolStats { acquires: number; reuses: number; creates: number; evictions: number; pooled: number; } export declare function isEmbeddedSessionRunnerEnabled(): boolean; export declare function getEmbeddedSessionRunnerIdleTtlMs(): number; export interface EmbeddedSessionRunnerPoolOptions { /** Override for the env-driven enable flag (testing). */ isEnabled?: () => boolean; /** Override for the env-driven idle TTL (testing). */ getIdleTtlMs?: () => number; } /** * Owns the per-session pool of pi `AgentSession` runners. The class is the supported, * injectable owner; {@link defaultEmbeddedSessionRunnerPool} keeps the historic * module-level free functions working until every caller is migrated to DI. */ export declare class EmbeddedSessionRunnerPool { private readonly pool; private readonly isEnabledFn; private readonly getIdleTtlMsFn; private stats; constructor(opts?: EmbeddedSessionRunnerPoolOptions); getStats(): Readonly; resetForTest(): void; evict(sessionKey: string, reason?: string): void; evictAll(reason?: string): void; acquire(params: AcquireEmbeddedSessionRunnerParams): Promise; private clearIdleTimer; private scheduleIdleEviction; private disposePooledRunner; private createPooledRunner; } export declare const defaultEmbeddedSessionRunnerPool: EmbeddedSessionRunnerPool; export declare function getEmbeddedSessionRunnerStats(): Readonly; export declare function resetEmbeddedSessionRunnerForTest(): void; export declare function evictEmbeddedSessionRunner(sessionKey: string, reason?: string): void; export declare function evictAllEmbeddedSessionRunners(reason?: string): void; export declare function acquireEmbeddedSessionRunner(params: AcquireEmbeddedSessionRunnerParams): Promise; /** Resolve session identity used by embedded runner acquire and turn execution. */ export declare function resolveEmbeddedTranscriptInputs(sessionStore: import('../../session/store.js').SessionStore, sessionKey: string): Promise<{ sessionId: string; sessionKey: string; }>;