import { execFile, type ChildProcess } from 'node:child_process'; import type { ExecResult } from '../types/index.js'; export declare const execFileAsync: typeof execFile.__promisify__; export declare const DEFAULT_MODEL = "sonnet"; export declare const JUDGE_MODEL = "haiku"; export declare const DEFAULT_TIMEOUT_MS = 600000; export declare const MAX_BUFFER: number; export type ExecutorVendor = 'anthropic' | 'openai' | 'google' | 'unknown'; export declare function executorVendor(executor: string): ExecutorVendor; export interface TokenUsage { input_tokens?: number; output_tokens?: number; cache_read_input_tokens?: number; cache_creation_input_tokens?: number; } export interface ClaudeCliResponse { is_error?: boolean; duration_ms?: number; duration_api_ms?: number; usage?: TokenUsage; total_cost_usd?: number; result?: string; stop_reason?: string | null; num_turns?: number; } export interface OpenAiUsage { prompt_tokens?: number; completion_tokens?: number; prompt_tokens_details?: { cached_tokens?: number; }; } export interface OpenAiResponse { usage?: OpenAiUsage; choices?: Array<{ message?: { content?: string | null; refusal?: string | null; }; finish_reason?: string; }>; error?: { message?: string; }; } export interface GeminiResponse { response?: string; stats?: { inputTokens?: number; outputTokens?: number; }; } export interface AnthropicResponse { usage?: TokenUsage; content?: Array<{ type?: string; text?: string; }>; stop_reason?: string; error?: { message?: string; }; } export interface ClaudeSdkQueryOptions { model?: string; systemPrompt?: string; cwd: string; permissionMode: 'bypassPermissions'; allowDangerouslySkipPermissions: true; abortController: AbortController; env: NodeJS.ProcessEnv; } export interface ClaudeSdkQueryInput { prompt: string; options: ClaudeSdkQueryOptions; } export interface ClaudeSdkBaseMessage { type: string; message?: { role?: string; content?: Array<{ type: string; text?: string; id?: string; name?: string; input?: unknown; }>; }; tool_use_id?: string; content?: string | Array<{ type: string; text?: string; }>; is_error?: boolean; } export interface ClaudeSdkResultMessage extends ClaudeSdkBaseMessage { type: 'result'; result?: string; usage?: TokenUsage; total_cost_usd?: number; duration_api_ms?: number; duration_ms?: number; num_turns?: number; stop_reason?: string | null; modelUsage?: Record; subtype?: string; errors?: string[]; } export interface ClaudeSdkModule { query: (opts: ClaudeSdkQueryInput) => AsyncIterable; } export interface CodexEvent { type?: string; turn_id?: string; usage?: { input_tokens?: number; cached_input_tokens?: number; output_tokens?: number; reasoning_output_tokens?: number; }; elapsed_ms?: number; stop_reason?: string; item?: { id?: string; type?: string; text?: string; command?: string; aggregated_output?: string; exit_code?: number | null; status?: string; path?: string; content?: string; query?: string; results?: unknown[]; changes?: Array<{ path?: string; changeKind?: string; }>; server?: string; tool?: string; name?: string; arguments?: unknown; result?: unknown; message?: string; error?: { message?: string; }; }; error?: { message?: string; }; message?: string; ts?: number; } /** * Translate Codex's external event shape into omk's internal protocol model. * Codex currently calls file-change discriminators `kind`; omk reserves bare * `kind` for ArtifactKind, so the raw field is qualified at the boundary. */ export declare function normalizeCodexProtocolEvent(value: unknown): CodexEvent | null; export interface ExecutorErrorLike { message?: string; name?: string; killed?: boolean; stdout?: string; } export declare function asErrorLike(err: unknown): ExecutorErrorLike; export declare function errorMessage(err: unknown, fallback?: string): string; export declare function parseJson(content: string): T; export interface JsonResponseBody { data: T | null; rawBody: string; } export declare function readJsonResponse(response: Response): Promise>; export declare function responseBodyPreview(rawBody: string, maxLength?: number): string; export declare function buildExecEnv(skillDir?: string | null): NodeJS.ProcessEnv; export declare function timeoutExecResult(timeoutMs: number, durationMs: number): ExecResult; export declare function interruptedExecResult(durationMs: number): ExecResult; /** * Register an in-process runtime (for example an SDK-owned child) with the * same SIGINT coordinator used by spawned executors. */ export declare function registerSigintSubscriber(subscriber: () => void): () => void; export declare function __resetSigintRegistryForTest(): void; export interface SpawnHelperResult { stdout: string; stderr: string; code: number | null; signal: NodeJS.Signals | null; killedByTimeout: boolean; killedBySignal: NodeJS.Signals | null; } export interface SpawnHelperError extends Error { stdout?: string; stderr?: string; code?: number | null; signal?: NodeJS.Signals | null; killedByTimeout?: boolean; killedBySignal?: NodeJS.Signals | null; } export interface SpawnHelperOptions { cwd?: string; env?: NodeJS.ProcessEnv; /** kill child after this many ms; reject with killedByTimeout=true */ timeoutMs?: number; /** per-stream stdout/stderr byte limit; reject when either stream exceeds it */ maxBuffer?: number; /** external abort signal; abort() 走跟 SIGINT 同一 grace 路径 */ abortSignal?: AbortSignal; } /** * spawn child + 注册到全局 SIGINT registry。返回 { child, done } 让 caller 自己 * 操作 stdin(写入 / 关闭),通过 done 等结果。 * * 适用:claude / codex / gemini / script CLI 子进程。HTTP executor(*-api)用 fetch + * AbortSignal.timeout,自带 abort,不走这个。claude-sdk in-process 也不走。 */ export declare function spawnWithSigintPropagation(command: string, args: string[], options?: SpawnHelperOptions): { child: ChildProcess; done: Promise; };