import type { ChildProcess } from 'node:child_process'; import type { Session, SessionOpts, TurnOpts, TurnResult, TokenUsage } from '../types/run-result.js'; import { type CodexCliConfig } from './codex-cli-launch.js'; import { type CodexCliEvent } from './codex-cli-event.js'; import { type BusLike } from './session-helpers.js'; export declare class CodexCliSession implements Session { private readonly args; private threadId?; private closed; private tempDir?; /** Active codex CLI subprocess for the currently-running turn. Captured so * close() can synchronously kill the child (SIGTERM then SIGKILL after * CLOSE_GRACE_MS). Undefined between turns. */ private activeProc?; private readonly cumulativeUsage; private codexSkillHomeReady; private skillHomePath; constructor(args: { cfg: CodexCliConfig; opts: SessionOpts; }); /** Returns task identity (taskId/taskIndex) from SessionOpts for event tagging. * The stall watchdog filters bus events by these fields — every emit must carry them * or stuck detection re-breaks under concurrent load. */ private taskTag; send(instruction: string, _turnOpts?: TurnOpts): Promise; close(): Promise; getSessionId(): string | null; /** OS pid of the currently-active codex CLI subprocess, if any. Undefined * between turns. Used by shutdown drain to SIGKILL stragglers. */ getPid(): number | undefined; private armGuards; private finalizeError; } declare function consumeStream(proc: ChildProcess, tracker: TurnTracker, stderrRef: { value: string; }): Promise; declare function killGracefully(proc: ChildProcess): void; /** Internal — visible only to the test harness via re-export. */ declare class TurnTracker { private readonly cumulative; private readonly bus?; private readonly tag; threadId?: string; turns: number; lastAgentMessage: string; filesWritten: Set; toolCalls: { turn: number; tool: string; }[]; usedShell: boolean; terminationReason: TurnResult['terminationReason']; errorCode?: string; errorMessage?: string; private readonly snapshot; constructor(cumulative: TokenUsage, bus?: BusLike | undefined, tag?: { taskId?: string; taskIndex?: number; }); consume(ev: CodexCliEvent): void; private absorbItem; /** Adds one turn's usage to the cumulative total and RETURNS what it added, so callers log * the normalized figures rather than re-deriving them from the raw event. */ private absorbUsage; flushUsageDelta(): TokenUsage; } export declare const __test: { TurnTracker: typeof TurnTracker; killGracefully: typeof killGracefully; consumeStream: typeof consumeStream; }; export {}; //# sourceMappingURL=codex-cli-session.d.ts.map