/** * Test doubles for the session host: a fake `claude` child and a spawner that * records every launch. Shared by the session-manager, connection, and server * tests so they all drive the same fake. */ import type { ChildProcessPort, SpawnPort } from "./session-host-sessions.js"; type ExitListener = (code: number | null, signal: NodeJS.Signals | null) => void; export interface FakeChildOptions { /** Keep process startup pending until a test marks it successful or failed. */ waitForSpawn?: boolean; } export declare class FakeChild implements ChildProcessPort { readonly pid = 4242; /** Raw stdin writes, in order. */ readonly stdin: string[]; stdinClosed: boolean; /** Signals sent through `kill`, in order. */ readonly signals: NodeJS.Signals[]; exited: boolean; private readonly stdoutListeners; private readonly stderrListeners; private readonly exitListeners; private resolveSpawn?; private rejectSpawn?; private spawnResult; private spawnPromise?; whenSpawned?: () => Promise; constructor(options?: FakeChildOptions); writeStdin(data: string): void; closeStdin(): void; kill(signal: NodeJS.Signals): void; onStdoutLine(listener: (line: string) => void): void; onStderrLine(listener: (line: string) => void): void; onExit(listener: ExitListener): void; /** Print one stdout line: objects are JSON-encoded, strings go out verbatim. */ emit(frame: unknown): void; emitStderr(line: string): void; exit(code: number | null, signal?: NodeJS.Signals | null): void; /** Resolve a startup a test deliberately held pending. */ markSpawned(): void; /** Reject a startup a test deliberately held pending. */ failSpawn(error: Error): void; /** Everything written to stdin, decoded back into frames. */ stdinFrames(): unknown[]; } export interface SpawnCall { command: string; args: string[]; cwd: string; env: Record; child: FakeChild; } /** A spawner that hands out FakeChild processes and records every launch. */ export declare function fakeSpawner(fakeOptions?: FakeChildOptions): { spawn: SpawnPort; calls: SpawnCall[]; }; /** The `system/init` frame `claude --output-format stream-json` prints first. */ export declare function initFrame(sessionId: string, extra?: Record): Record; export {}; //# sourceMappingURL=session-host-fakes.d.ts.map