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';
import { type SessionManagerCache } from './session-manager-cache.js';
export type EmbeddedRunnerFingerprintInput = {
    sessionFile: string;
    workspaceDir: string;
    modelRef: string;
    toolNames: readonly string[];
    systemPrompt: string;
    thinkingLevel: string;
};
export declare function buildEmbeddedRunnerFingerprint(input: EmbeddedRunnerFingerprintInput): string;
export type AcquireEmbeddedSessionRunnerParams = {
    sessionKey: string;
    sessionId: string;
    sessionFile: string;
    sessionsDir: string;
    hadSessionFile: boolean;
    workspaceDir: string;
    model: Model<Api>;
    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 {
    /** File-exists cache shared with prewarmSessionFile callers. */
    sessionManagerCache?: SessionManagerCache;
    /** 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 cache;
    private readonly isEnabledFn;
    private readonly getIdleTtlMsFn;
    private stats;
    constructor(opts?: EmbeddedSessionRunnerPoolOptions);
    getStats(): Readonly<EmbeddedSessionRunnerPoolStats>;
    resetForTest(): void;
    evict(sessionKey: string, reason?: string): void;
    evictAll(reason?: string): void;
    acquire(params: AcquireEmbeddedSessionRunnerParams): Promise<AcquiredEmbeddedSessionRunner>;
    private clearIdleTimer;
    private scheduleIdleEviction;
    private disposePooledRunner;
    private createPooledRunner;
}
export declare const defaultEmbeddedSessionRunnerPool: EmbeddedSessionRunnerPool;
export declare function getEmbeddedSessionRunnerStats(): Readonly<EmbeddedSessionRunnerPoolStats>;
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<AcquiredEmbeddedSessionRunner>;
/** Resolve transcript path inputs used by both runner acquire and turn execution. */
export declare function resolveEmbeddedTranscriptInputs(sessionStore: import('../../session/store.js').SessionStore, sessionKey: string): Promise<{
    sessionId: string;
    sessionFile: string;
    sessionsDir: string;
    hadSessionFile: boolean;
}>;
