import type { AgentResult, AskUserQuestionInfo } from '../../core/types/agent-types.js'; import type { CodexQuotaReading } from '../../domain/costs/codex-quota.js'; import type { AgentProcess, AgentProcessSpawner, InjectionAckSink, UserMessage } from '../types.js'; import type { NormalizedEvent } from '../normalize/event-types.js'; export declare const DEFAULT_PI_BINARY = "pi"; export declare const CLOSE_EXIT_WAIT_MS = 5000; export declare const SWITCH_SESSION_TIMEOUT_MS = 5000; export declare const PI_IDLE_SESSION_TIMEOUT: number; export declare const PI_TURN_IDLE_TIMEOUT: number; export declare const PI_MAX_TIMEOUT = 30000000; export declare const PI_CONTEXT_USAGE_TIMEOUT_MS = 1000; export declare const PI_CONTEXT_USAGE_SAMPLE_MS = 2000; export type SwitchResult = { ok: boolean; cancelled: boolean; }; /** P1 (ii): PI's spawner is the same `AgentProcessSpawner` Claude takes, so the containment * supervision handle survives the call instead of being discarded with the `ChildProcess`. */ export type SpawnFn = AgentProcessSpawner; /** Test seam default. A benchmark spawn never reaches it — `assertBenchmarkSpawn` requires * `spawnConfig.processSpawner`, so an unsupervised trial refuses rather than falling back here. */ export declare const defaultPiSpawn: SpawnFn; export interface PIAgentProcess extends AgentProcess { sendExtensionUiResponse(id: string, payload: Record): void; } export interface PISessionOptions { sessionKey: string; sessionDir: string; /** Absolute CLI path frozen by a trial policy, or the bare `pi` name for daemon sessions. */ command: string; cliArgs: string[]; cwd: string; env: NodeJS.ProcessEnv; spawner: SpawnFn; /** Explicit delta policy; a trial passes the frozen value rather than reading watched settings. */ streamDeltas: boolean; registry: Map; registrySessionDir: string; onClose?: (sessionKey: string) => void; /** Called with each provider quota reading the child reports; set only for gateway-routed runs. */ onProviderQuota?: (reading: CodexQuotaReading) => void; } export interface PendingPiTurn { resolve: (result: AgentResult) => void; reject: (error: Error) => void; planFilePath: string | null; askUserQuestions: AskUserQuestionInfo[]; numTurns: number; totalCostUsd: number | null; promptDispatched: boolean; openingUserSeen: boolean; deferredCompletion: boolean; } export declare function buildPromptText(message: UserMessage): string; export declare function parseRpcObject(line: string): Record | null; export declare function isPIContextSampleBoundary(raw: Record | null): boolean; /** Throttles live PI stats while independently correlating the final terminal-gating request. */ export declare class PIContextUsageProbe { private readonly write; private readonly emit; private readonly timeoutMs; private readonly sampleMs; private livePending; private terminalPending; private lastLiveRequestAt; private sequence; constructor(write: (command: Record) => void, emit: (event: NormalizedEvent) => void, timeoutMs?: number, sampleMs?: number); requestSnapshot(): void; deferTerminal(terminal: NormalizedEvent): void; observe(raw: Record | null): void; close(): void; private nextId; private clearLive; private releaseTerminal; } export declare class EventQueue { private readonly pending; private readonly waiters; private closed; push(event: NormalizedEvent): void; next(): Promise>; close(): void; } export interface PendingPiInjection { id: string; text: string; rejected: boolean; } /** FIFO steering lifecycle, including duplicate-safe deferred rejection delivery. */ export declare class PISteeringQueue { private sink; private readonly pending; private sequence; get hasPending(): boolean; setSink(sink: InjectionAckSink): void; clearSink(): void; begin(text: string): PendingPiInjection; rollback(entry: PendingPiInjection): void; /** Mark a correlated failed injection; rejected duplicates seal only after earlier entries. * Both RPC forms an injection can take (prompt+steer and the dedicated steer) are correlated. */ rejectFromResponse(raw: Record): boolean; consumeNext(): void; abandon(): void; private drainRejected; private notifyDelivered; private notifyUndelivered; }