import type { HarnessResumeRequest, ResumeSpec } from './resume'; export type HarnessName = 'auto' | 'opencode' | 'claude' | 'codex' | 'gemini' | 'antigravity' | 'copilot' | 'cursor' | 'goose' | 'openhands' | 'aider' | 'openrouter' | 'none'; /** * Harnesses that run the built-in headless LLM loop (`--self`, `runLlmSession`) * instead of spawning a local CLI binary. OpenRouter is an API gateway - there * is no adapter to spawn - so `harness = 'openrouter'` is the explicit, * discoverable alias for the self-mode execution path (vs `none`, which skips * execution entirely). */ export declare const SELF_MODE_HARNESSES: Set; /** True when this harness executes through the headless LLM loop (no CLI). */ export declare function isSelfModeHarness(name: string): boolean; export interface SpawnOpts { model?: string; temperature?: number; cwd?: string; timeoutMin?: number; title?: string; agentKey?: string; apiBaseUrl?: string; /** BYOK provider API key — wired to the harness-specific env var (e.g. GEMINI_API_KEY). */ providerKey?: string; /** Session mode for the MCP config header ('run' | 'build' | 'chat' | 'doc'). */ sessionMode?: string; /** * Harness session id - sent as X-TeamShare-Session-Id on MCP calls so * claims made during this session can be released in one call at exit. */ sessionId?: string; /** Reasoning effort for harnesses that expose it (codex: low|medium|high|xhigh). */ effort?: string; /** Override the default workspace MCP config path (.agents/mcp_config.json). */ mcpConfigPath?: string; /** * Raw stdout line callback — fires with each unformatted line from the * harness process BEFORE formatHarnessEvent processes it. Used by * chat-reply/doc-reply to capture raw output for parseHarnessOutput * while reusing the same spawn logic as run/build. */ onRawLine?: (line: string) => void; /** * Resume a previous harness session instead of starting a new one. The * adapter's headlessArgs() translates this into the right argv (flag, * subcommand, or history restore). Omitted = fresh session. */ resume?: HarnessResumeRequest; /** * Machine-local session resume scope. When set, spawnHarness() loads/saves * the harness session id for (agentId, taskId, mode) so a later run of the * same task resumes. Omitted = always a fresh session. */ sessionStore?: { agentId: string; taskId: string; mode: string; }; /** Force a fresh session (ignore + clear any stored record). */ fresh?: boolean; /** Branch the stored session instead of continuing in place (where supported). */ fork?: boolean; } export interface HarnessAdapter { /** Display name. */ name: string; /** CLI binary name (must be on PATH). */ binary: string; /** Include in 'auto' detection order. */ autoDetect: boolean; /** Priority (lower = detected first in auto mode). */ priority: number; /** * Build the CLI args for a non-interactive headless run. * When `excludePrompt` is true, return args WITHOUT the prompt element — * the caller handles prompt delivery (temp file path or native file flag). */ headlessArgs(prompt: string, opts: SpawnOpts, excludePrompt?: boolean): string[]; /** Extra env vars for this session. */ envForSession(opts: SpawnOpts): Record; /** Whether this harness supports MCP tool injection. */ supportsMcp: boolean; /** * Write a per-session MCP config override (returns file path + cleanup). * `opts` carries cwd for workspace-scoped configs (antigravity merges * `.agents/mcp_config.json` inside the working folder and restores it). */ writeMcpConfig?(agentKey: string, apiBaseUrl: string, sessionMode?: string, opts?: SpawnOpts, relayUrl?: string, sessionToken?: string): { file: string; cleanup: () => void; } | null; /** * Resume capability metadata (session addressing, id capture, failure * signatures). The argv itself is built by headlessArgs() from opts.resume. */ resume?: ResumeSpec; /** Whether the harness produces structured JSON output. */ structuredOutput: boolean; /** * The harness gates its stdout on isatty() (e.g. agy prints nothing when * piped) — spawn through a pseudo-terminal when node-pty is available. */ needsTty?: boolean; /** * Whether the harness can receive the full prompt from a temp file. * When true and the prompt exceeds argv limits, spawnHarness() writes * the prompt to a temp file and passes the path instead. */ supportsPromptFile?: boolean; /** * Native file flag for prompt delivery (e.g. '-i' for goose, '-f' for * aider/openhands). When set, spawnHarness() uses this flag directly * instead of embedding the path in the prompt text. */ promptFileFlag?: string; } /** Installed Claude Code version (e.g. "2.1.276"), or null when unknown. */ export declare function claudeVersion(): string | null; /** True when the installed Claude Code is at least major.minor.patch. */ export declare function claudeAtLeast(major: number, minor: number, patch: number): boolean; /** `--strict-mcp-config` (exclusive MCP + no project approval) needs v2.1.246+. */ export declare function claudeStrictMcpSupported(): boolean; /** * Tools the bridge auto-approves for Claude Code. Combined with `dontAsk` * mode (which denies anything else that would prompt), this gives an * unattended run the same reach as the other adapters WITHOUT the bypass * confirmation dialog that parks a headless session. `mcp__teamshare` grants * every TeamShare MCP tool; a literal server segment is required for allow * globs (bare `mcp__*` is rejected). */ export declare const CLAUDE_ALLOWED_TOOLS: string; declare const adapters: Record; /** Get a specific adapter by name. Throws if unknown. */ export declare function getAdapter(name: string): HarnessAdapter; /** All registered adapter names (excludes 'auto' and 'none'). */ export declare const HARNESS_NAMES: (keyof typeof adapters)[]; /** Auto-detect the first available harness on PATH. Returns 'none' if nothing found. */ export declare function detectHarness(): string; /** Resolve 'auto' to a concrete harness, or pass through an explicit name. */ export declare function resolveHarness(name: string): string; /** Check if a harness binary exists on PATH. */ export declare function harnessAvailable(name: string): boolean; export {};