export interface ClaudeSpawnArgs { pluginDirs: string[]; sandboxDir: string; model?: string; maxTurns?: number; maxBudgetUsd?: number; } /** * Pure assembly of the headless `claude -p` argv (spec §9). The prompt is never * inlined as an argv string (Windows cmd-quoting safety) and claude 2.x has no * `--prompt-file` flag — the prompt is fed to the child's stdin by * {@link spawnHeadlessClaude} instead. `--setting-sources ""` suppresses * user/project settings; built-in skills remain (§5). */ export declare function assembleClaudeArgs(opts: ClaudeSpawnArgs): string[]; export interface SpawnResult { status: number; timedOut: boolean; stalled: boolean; } /** * SIGKILL the child AND every process in its group. The child is spawned * `detached` (POSIX) so it leads a new process group; killing the negated pid * reaps backgrounded grandchildren (e.g. a skill that runs `nohup … &`) and * orphaned MCP subprocesses that a direct `child.kill()` would leave running. * * - Guards an undefined pid (child never spawned — nothing to kill). * - Swallows the throw (ESRCH) when the group is already gone. * - Windows has no POSIX process groups: fall back to `taskkill /T /F`, which * terminates the whole process tree. */ export declare function killProcessTree(child: { pid?: number | undefined; }): void; /** * SIGKILL every currently in-flight `claude` child (and its process tree, via * {@link killProcessTree}) and clear the registry. Idempotent — safe to call * when the registry is already empty (e.g. every child has already settled, * or this has already been called once on the current error path). */ export declare function killAllActiveClaudeChildren(): void; export interface SpawnHeadlessOptions extends ClaudeSpawnArgs { /** * The executor prompt, held IN MEMORY and streamed to the child's stdin * (claude 2.x reads the `-p` prompt from stdin; there is no `--prompt-file` * flag). Kept off argv so the prompt is never inlined (Windows cmd-quoting * safety) AND, deliberately, off disk: the harness stamps a per-run integrity * nonce into this prompt, and writing it to a file inside (or beside) the * skill-writable sandbox would let untrusted skill code read the nonce back and * forge a passing grading.json. Passing it in memory keeps the nonce out of any * file the skill can read. */ prompt: string; cwd: string; env: NodeJS.ProcessEnv; timeoutMs: number; /** If set, SIGKILL the child if no stdout/stderr output is received for this many ms. */ stallMs?: number; onStdout?: (chunk: string) => void; onStderr?: (chunk: string) => void; /** * INTERNAL test seam. When set, this executable is spawned instead of resolving * `claude` on PATH — letting tests exercise the wall-timeout / stall watchdog * against a tiny fake child without a real `claude` install. Production callers * never set this; `claude` is resolved via `which`. */ binPath?: string; } /** * Spawn the headless `claude`. The in-memory prompt is streamed to the child's * stdin so the session reads its prompt and then sees EOF (it cannot block on * input, §16). Wall-clock kill on timeout. If `stallMs` is set, a resettable * stall watchdog kills the child when no output is received for that duration * (stalled: true in result). */ export declare function spawnHeadlessClaude(opts: SpawnHeadlessOptions): Promise; //# sourceMappingURL=spawn-claude.d.ts.map