import { BaseCLIAdapter, SpawnConfig, AutoResponseRule, LoginDetection, BlockingPromptDetection, ParsedOutput, ToolRunningInfo } from 'adapter-types'; /** * Approval Presets * * Unified preset system for controlling tool permissions across all supported * coding agent CLIs. Each preset translates to the correct per-CLI config * format (JSON settings files, CLI flags, env vars). */ type ToolCategory = 'file_read' | 'file_write' | 'shell' | 'web' | 'agent' | 'planning' | 'user_interaction'; type RiskLevel = 'low' | 'medium' | 'high'; type ApprovalPreset = 'readonly' | 'standard' | 'permissive' | 'autonomous'; interface ToolCategoryInfo { category: ToolCategory; risk: RiskLevel; description: string; } interface PresetDefinition { preset: ApprovalPreset; description: string; autoApprove: ToolCategory[]; requireApproval: ToolCategory[]; blocked: ToolCategory[]; } interface ApprovalConfig { preset: ApprovalPreset; cliFlags: string[]; workspaceFiles: Array<{ relativePath: string; content: string; format: 'json' | 'yaml' | 'toml'; }>; envVars: Record; summary: string; } declare const TOOL_CATEGORIES: ToolCategoryInfo[]; declare const PRESET_DEFINITIONS: PresetDefinition[]; declare const CLAUDE_TOOL_CATEGORIES: Record; declare const GEMINI_TOOL_CATEGORIES: Record; declare const CODEX_TOOL_CATEGORIES: Record; declare const AIDER_COMMAND_CATEGORIES: Record; declare function generateClaudeApprovalConfig(preset: ApprovalPreset): ApprovalConfig; declare function generateGeminiApprovalConfig(preset: ApprovalPreset): ApprovalConfig; declare function generateCodexApprovalConfig(preset: ApprovalPreset): ApprovalConfig; declare function generateAiderApprovalConfig(preset: ApprovalPreset): ApprovalConfig; declare function generateHermesApprovalConfig(preset: ApprovalPreset): ApprovalConfig; declare function generateApprovalConfig(adapterType: AdapterType, preset: ApprovalPreset): ApprovalConfig; declare function listPresets(): PresetDefinition[]; declare function getPresetDefinition(preset: ApprovalPreset): PresetDefinition; /** * Base Coding Agent Adapter * * Extends pty-manager's BaseCLIAdapter with credential handling * for AI coding agents. */ /** * Supported adapter types */ type AdapterType = 'claude' | 'gemini' | 'codex' | 'aider' | 'hermes' | 'opencode'; /** * Authentication status for a CLI agent's subscription/login. */ interface AuthStatus { /** Whether auth status could be determined */ status: 'authenticated' | 'unauthenticated' | 'unknown'; /** Auth method if authenticated (e.g. "subscription", "api_key", "oauth") */ method?: string; /** Human-readable detail (e.g. email, account name) */ detail?: string; /** Instruction to authenticate if not logged in */ loginHint?: string; } /** * Credentials that can be passed via SpawnConfig.adapterConfig */ interface AgentCredentials { anthropicKey?: string; openaiKey?: string; googleKey?: string; githubToken?: string; custom?: Record; /** Override Anthropic API base URL (e.g. cloud proxy) */ anthropicBaseUrl?: string; /** Override OpenAI API base URL (e.g. cloud proxy) */ openaiBaseUrl?: string; /** * Extra TOML appended to the adapter's generated config file when the * adapter writes one (currently: Codex's per-spawn `config.toml` under * the isolated `CODEX_HOME`). * * Use this when the orchestrator needs to set CLI-specific knobs the * adapter does not model directly — for example disabling Codex's * experimental Responses API WebSocket transport when routing through * a proxy that does not support WebSocket upgrades: * * extraConfigToml: '[features]\nresponses_websockets_v2 = false\n' * * The string is appended verbatim with a leading newline; no merging * or validation is performed. Adapters that don't generate a config * file ignore this field. */ extraConfigToml?: string; } /** * Installation information for a CLI tool */ interface InstallationInfo { /** Command to install the CLI (e.g., "npm install -g @anthropic-ai/claude-code") */ command: string; /** Alternative installation methods */ alternatives?: string[]; /** URL to installation docs */ docsUrl: string; /** Minimum required version (if known) */ minVersion?: string; } /** * Model tier recommendations for an adapter */ interface ModelRecommendations { /** Most capable model for complex tasks */ powerful: string; /** Fastest/cheapest model for simple tasks */ fast: string; } /** * Describes a file that a coding agent CLI reads from the workspace. * Orchestration systems use this to write instructions/config before spawning agents. */ interface AgentFileDescriptor { /** File path relative to workspace root (e.g., "CLAUDE.md", ".aider.conf.yml") */ relativePath: string; /** Human-readable description of what this file does */ description: string; /** Whether the CLI reads this file automatically on startup */ autoLoaded: boolean; /** File category */ type: 'memory' | 'config' | 'rules'; /** File format */ format: 'markdown' | 'yaml' | 'json' | 'text'; } /** * Options for writing a memory file into a workspace */ interface WriteMemoryOptions { /** Custom file name override (default: adapter's primary memory file) */ fileName?: string; /** Append to existing file instead of overwriting */ append?: boolean; } /** * Extended config with credentials and mode support */ interface CodingAgentConfig extends SpawnConfig { adapterConfig?: AgentCredentials & { /** * Run in interactive mode (skip --print/--quiet/--non-interactive flags). * Use this when you want the full interactive CLI experience. */ interactive?: boolean; /** * Preferred provider for multi-provider adapters (e.g., Aider). * Only the API key for this provider is passed, letting the CLI * pick its best model for that provider automatically. */ provider?: 'anthropic' | 'openai' | 'google'; /** * Approval preset controlling tool permissions. * Translates to CLI-specific config files and flags. */ approvalPreset?: ApprovalPreset; /** * Claude-only: enable hook marker telemetry parsing. * Requires Claude hook config that emits PARALLAX_CLAUDE_HOOK lines. */ claudeHookTelemetry?: boolean; /** * Claude-only: override hook marker prefix token. */ claudeHookMarkerPrefix?: string; /** * Gemini-only: enable hook marker telemetry parsing. * Requires Gemini hook config that emits PARALLAX_GEMINI_HOOK markers. */ geminiHookTelemetry?: boolean; /** * Gemini-only: override hook marker prefix token. */ geminiHookMarkerPrefix?: string; } & Record; } /** * Base class for AI coding agent adapters */ declare abstract class BaseCodingAdapter extends BaseCLIAdapter { /** * Coding agent CLIs use TUI menus that require arrow-key navigation. */ readonly usesTuiMenus: boolean; /** * Ms of output silence after detectReady match before emitting session_ready. * Allows TUI rendering (status bar, shortcuts, update notices) to complete * before the orchestrator sends input. */ readonly readySettleMs: number; /** * Installation information for this CLI tool */ abstract readonly installation: InstallationInfo; /** * Workspace files this CLI reads automatically. * Orchestration systems use this to know where to write instructions/config * before spawning an agent. */ abstract getWorkspaceFiles(): AgentFileDescriptor[]; /** * The primary memory file for this CLI (the one it reads for project instructions). * Returns the relativePath of the first 'memory' type file from getWorkspaceFiles(). */ get memoryFilePath(): string; /** * Get credentials from config */ protected getCredentials(config: SpawnConfig): AgentCredentials; /** * Check if interactive mode is enabled. * When true, skip non-interactive flags (--print, --quiet, etc.) */ protected isInteractive(config: SpawnConfig): boolean; /** * Get recommended models for this adapter. * Returns powerful (most capable) and fast (cheapest/fastest) model names. */ abstract getRecommendedModels(credentials?: AgentCredentials): ModelRecommendations; /** * Check whether the CLI is authenticated via its subscription/login. * Override in subclasses that support a status check command. * Default: returns 'unknown' (no way to check). */ checkAuthStatus(): Promise; /** * Trigger the CLI's authentication flow. * Returns info about what was launched (URL to open, instructions, etc.). * Override in subclasses. Default: returns null (no auth flow available). */ triggerAuth(): Promise<{ launched: boolean; /** URL the user should open (if browser-based auth) */ url?: string; /** Device code to enter (Codex) */ deviceCode?: string; /** Human-readable instructions */ instructions: string; } | null>; /** * Helper: run a command and return stdout, or null on any failure. */ protected execQuiet(command: string, timeoutMs?: number): Promise; /** * Override stripAnsi to handle TUI cursor movement codes, spinner/box-drawing * characters, bare control characters, and extra whitespace. * * TUI CLIs (Claude Code, Gemini CLI, Codex) use cursor positioning * sequences instead of literal spaces, and render decorative Unicode * characters (spinners, box-drawing). All of these must be stripped so * adapter detection methods (detectReady, detectTaskComplete, etc.) can * match visible text with their regex patterns. * * Note: ❯ and › are preserved — they are prompt indicators used by * detectReady / detectTaskComplete. */ protected stripAnsi(str: string): string; /** * Generate hook telemetry protocol configuration. * Returns null by default — only Claude adapter supports hooks. */ getHookTelemetryProtocol(_options?: { scriptPath?: string; markerPrefix?: string; httpUrl?: string; sessionId?: string; }): { markerPrefix: string; scriptPath: string; scriptContent: string; settingsHooks: Record; } | null; /** * Override detectExit to include installation instructions */ detectExit(output: string): { exited: boolean; code?: number; error?: string; }; /** * Get formatted installation instructions */ getInstallInstructions(): string; /** * Check if response appears complete based on common patterns */ protected isResponseComplete(output: string): boolean; /** * Extract the main content from CLI output, removing common artifacts */ protected extractContent(output: string, promptPattern: RegExp): string; /** * Detect if the CLI is actively loading/processing (thinking spinner, * file reading, model streaming, etc.). When true, stall detection is * suppressed because the agent is provably working. */ abstract detectLoading(output: string): boolean; /** * Detect if the CLI has completed a task and returned to its idle prompt. * More specific than detectReady() — matches high-confidence completion indicators * (e.g. duration summaries, explicit "done" messages) alongside the idle prompt. * * Used as a fast-path in stall detection to avoid expensive LLM classifier calls. */ abstract detectTaskComplete(output: string): boolean; /** * Extract the approval preset from a spawn config, if set. */ protected getApprovalPreset(config: SpawnConfig): ApprovalPreset | undefined; /** * Generate the approval config for this adapter, if a preset is set. */ getApprovalConfig(config: SpawnConfig): ApprovalConfig | null; /** * Write approval config files to a workspace directory. * Returns the list of files written (absolute paths). */ writeApprovalConfig(workspacePath: string, config: SpawnConfig): Promise; /** * Write content to this agent's memory file in a workspace. * Creates parent directories as needed. * * @param workspacePath - Absolute path to the workspace root * @param content - The memory/instructions content to write * @param options - Optional: custom fileName, append mode * @returns The absolute path of the written file */ writeMemoryFile(workspacePath: string, content: string, options?: WriteMemoryOptions): Promise; } /** * Aider CLI Adapter * * Adapter for the Aider AI pair programming tool. * https://github.com/paul-gauthier/aider */ declare class AiderAdapter extends BaseCodingAdapter { readonly adapterType = "aider"; readonly displayName = "Aider"; /** Minimal TUI, mostly text output — shorter settle delay */ readonly readySettleMs: number; /** * Aider uses plain text [y/n] prompts, NOT TUI arrow-key menus. */ readonly usesTuiMenus: boolean; readonly installation: InstallationInfo; /** * Auto-response rules for Aider CLI. * Aider uses plain text prompts via io.py:832 with (Y)es/(N)o format. * All rules are responseType: 'text' — Aider never uses TUI menus. * * Decline rules come first to override the generic accept patterns. */ readonly autoResponseRules: AutoResponseRule[]; getWorkspaceFiles(): AgentFileDescriptor[]; getRecommendedModels(credentials?: AgentCredentials): ModelRecommendations; getCommand(): string; getArgs(config: SpawnConfig): string[]; getEnv(config: SpawnConfig): Record; detectLogin(output: string): LoginDetection; /** * Detect blocking prompts specific to Aider CLI. * * IMPORTANT: Does NOT fall back to base class detection because the base * class has broad heuristics (any line ending with "?") that trigger on * normal LLM output. Aider uses --yes-always to auto-accept most prompts, * so we only need to detect auth/login and the few prompts that bypass it. * * Source: io.py, onboarding.py, base_coder.py, report.py */ detectBlockingPrompt(output: string): BlockingPromptDetection; /** * Detect if Aider is actively loading/processing. * * Patterns from: AGENT_LOADING_STATUS_PATTERNS.json * - aider_active_waiting_model: "Waiting for " * - aider_active_waiting_llm_default: "Waiting for LLM" * - aider_active_generating_commit_message: "Generating commit message with ..." */ detectLoading(output: string): boolean; /** * Detect task completion for Aider. * * High-confidence patterns: * - "Aider is waiting for your input" notification (bell message) * - Edit-format mode prompts (ask>, code>, architect>) after output * * Patterns from: AGENT_LOADING_STATUS_PATTERNS.json * - aider_completed_llm_response_ready */ detectTaskComplete(output: string): boolean; detectReady(output: string): boolean; parseOutput(output: string): ParsedOutput | null; /** * Detect exit conditions specific to Aider. * Source: base_coder.py:994, base_coder.py:998, report.py:77, versioncheck.py:58 */ detectExit(output: string): { exited: boolean; code?: number; error?: string; }; getPromptPattern(): RegExp; getHealthCheckCommand(): string; } /** * Claude Code CLI Adapter * * Adapter for the Claude Code CLI (claude command). */ declare class ClaudeAdapter extends BaseCodingAdapter { readonly adapterType = "claude"; readonly displayName = "Claude Code"; /** Heaviest TUI — status bar, shortcuts, update notices, /ide suggestions. * 3000ms needed because detectReady fires early during boot rendering. */ readonly readySettleMs: number; readonly installation: InstallationInfo; /** * Auto-response rules for Claude Code CLI. * These handle common text-based [y/n] prompts that can be safely auto-responded. * Explicit responseType: 'text' prevents the usesTuiMenus default from kicking in. */ readonly autoResponseRules: AutoResponseRule[]; getWorkspaceFiles(): AgentFileDescriptor[]; getRecommendedModels(_credentials?: AgentCredentials): ModelRecommendations; checkAuthStatus(): Promise; triggerAuth(): Promise<{ launched: boolean; url?: string; instructions: string; } | null>; getCommand(): string; getArgs(config: SpawnConfig): string[]; getEnv(config: SpawnConfig): Record; getHookTelemetryProtocol(options?: { scriptPath?: string; markerPrefix?: string; httpUrl?: string; sessionId?: string; }): { markerPrefix: string; scriptPath: string; scriptContent: string; settingsHooks: Record; }; private getHookMarkers; private getLatestHookMarker; private stripHookMarkers; detectLogin(output: string): LoginDetection; /** * Detect blocking prompts specific to Claude Code CLI */ detectBlockingPrompt(output: string): BlockingPromptDetection; /** * Detect if Claude Code is actively loading/processing. * * Patterns from: AGENT_LOADING_STATUS_PATTERNS.json * - claude_active_reading_files: "Reading N files…" * - General: "esc to interrupt" spinner status line */ detectLoading(output: string): boolean; /** * Detect if an external tool/process is running within the Claude session. * * Claude Code can launch external tools (browser, bash, Node, Python, etc.) * that show status lines like "Claude in Chrome[javascript_tool]" or * "[bash_tool]", "[python_tool]", etc. * * When detected, stall detection is suppressed and the UI can display * which tool is active. */ detectToolRunning(output: string): ToolRunningInfo | null; /** * Detect task completion for Claude Code. * * High-confidence pattern: turn duration summary + idle prompt. * Claude Code shows " for Xm Ys" (e.g. "Cooked for 3m 12s") * when a turn completes, followed by the ❯ input prompt. * * Patterns from: AGENT_LOADING_STATUS_PATTERNS.json * - claude_completed_turn_duration * - claude_completed_turn_duration_custom_verb */ detectTaskComplete(output: string): boolean; detectReady(output: string): boolean; parseOutput(output: string): ParsedOutput | null; getPromptPattern(): RegExp; getHealthCheckCommand(): string; detectExit(output: string): { exited: boolean; code?: number; error?: string; }; } /** * OpenAI Codex CLI Adapter * * Adapter for the OpenAI Codex CLI tool. */ declare class CodexAdapter extends BaseCodingAdapter { readonly adapterType = "codex"; readonly displayName = "OpenAI Codex"; readonly readySettleMs: number; readonly installation: InstallationInfo; /** * Auto-response rules for OpenAI Codex CLI. * Codex uses ratatui/crossterm full-screen TUI with arrow-key menus. * Source: trust_directory.rs, update_prompt.rs, model_migration.rs, cwd_prompt.rs, chatwidget.rs, main.rs */ readonly autoResponseRules: AutoResponseRule[]; getWorkspaceFiles(): AgentFileDescriptor[]; getRecommendedModels(_credentials?: AgentCredentials): ModelRecommendations; checkAuthStatus(): Promise; triggerAuth(): Promise<{ launched: boolean; url?: string; deviceCode?: string; instructions: string; } | null>; getCommand(): string; /** * When using a cloud proxy, create an isolated CODEX_HOME directory with * an `auth.json` set to apikey mode and a `config.toml` pointing at the * proxy. This bypasses the user's `~/.codex/auth.json` (which may have a * persisted ChatGPT subscription session) so requests actually route * through the proxy with our API key instead of being silently routed * back to OpenAI's chat backend via the user's stored OAuth tokens. * * Returns the path to the temp dir, or null if no proxy is configured. */ private prepareIsolatedCodexHome; getArgs(config: SpawnConfig): string[]; getEnv(config: SpawnConfig): Record; detectLogin(output: string): LoginDetection; /** * Detect blocking prompts specific to OpenAI Codex CLI. * Source: approval_overlay.rs, chatwidget.rs, request_user_input/mod.rs */ detectBlockingPrompt(output: string): BlockingPromptDetection; /** * Detect if Codex CLI is actively loading/processing. * * Patterns from: AGENT_LOADING_STATUS_PATTERNS.json * - codex_active_status_row: "• Working (0s • esc to interrupt)" * - codex_active_booting_mcp: "Booting MCP server: ..." * - codex_active_web_search: "Searching the web" */ detectLoading(output: string): boolean; /** * Detect task completion for Codex CLI. * * High-confidence patterns: * - "Worked for Xm Ys" separator after work-heavy turns * - "› Ask Codex to do anything" ready prompt * * Patterns from: AGENT_LOADING_STATUS_PATTERNS.json * - codex_completed_worked_for_separator * - codex_ready_prompt */ detectTaskComplete(output: string): boolean; detectReady(output: string): boolean; parseOutput(output: string): ParsedOutput | null; /** * Detect exit conditions specific to Codex CLI. * Source: main.rs:404, main.rs:414, main.rs:461 */ detectExit(output: string): { exited: boolean; code?: number; error?: string; }; getPromptPattern(): RegExp; getHealthCheckCommand(): string; } /** * Google Gemini CLI Adapter * * Adapter for the Google Gemini CLI tool. */ declare class GeminiAdapter extends BaseCodingAdapter { readonly adapterType = "gemini"; readonly displayName = "Google Gemini"; readonly readySettleMs: number; readonly installation: InstallationInfo; /** * Auto-response rules for Gemini CLI. * Gemini uses Ink/React TUI with arrow-key radio menus. * Source: FolderTrustDialog.tsx, MultiFolderTrustDialog.tsx, CloudFreePrivacyNotice.tsx */ readonly autoResponseRules: AutoResponseRule[]; getWorkspaceFiles(): AgentFileDescriptor[]; getRecommendedModels(_credentials?: AgentCredentials): ModelRecommendations; checkAuthStatus(): Promise; triggerAuth(): Promise<{ launched: boolean; url?: string; instructions: string; } | null>; getCommand(): string; getArgs(config: SpawnConfig): string[]; getEnv(config: SpawnConfig): Record; getHookTelemetryProtocol(options?: { scriptPath?: string; markerPrefix?: string; httpUrl?: string; sessionId?: string; }): { markerPrefix: string; scriptPath: string; scriptContent: string; settingsHooks: Record; }; private getHookMarkers; private getLatestHookMarker; private stripHookMarkers; detectLogin(output: string): LoginDetection; detectBlockingPrompt(output: string): BlockingPromptDetection; /** * Detect if Gemini CLI is actively loading/processing. * * Patterns from: AGENT_LOADING_STATUS_PATTERNS.json * - gemini_active_loading_line: "(esc to cancel, Xs)" * - gemini_active_waiting_user_confirmation: "Waiting for user confirmation..." */ detectLoading(output: string): boolean; detectToolRunning(output: string): ToolRunningInfo | null; /** * Detect task completion for Gemini CLI. * * High-confidence patterns: * - "◇ Ready" window title signal (OSC sequence, may survive ANSI stripping) * - "Type your message" composer placeholder after agent output * * Patterns from: AGENT_LOADING_STATUS_PATTERNS.json * - gemini_ready_title */ detectTaskComplete(output: string): boolean; detectReady(output: string): boolean; parseOutput(output: string): ParsedOutput | null; /** * Detect exit conditions specific to Gemini CLI. * Source: FolderTrustDialog.tsx:127, LogoutConfirmationDialog.tsx:64 */ detectExit(output: string): { exited: boolean; code?: number; error?: string; }; getPromptPattern(): RegExp; getHealthCheckCommand(): string; } /** * Hermes Agent CLI Adapter * * Adapter for the Hermes Agent CLI tool. */ declare class HermesAdapter extends BaseCodingAdapter { readonly adapterType = "hermes"; readonly displayName = "Hermes Agent"; /** Prompt-toolkit TUI + spinner rendering needs a slightly longer settle. */ readonly readySettleMs: number; readonly installation: InstallationInfo; getWorkspaceFiles(): AgentFileDescriptor[]; getRecommendedModels(_credentials?: AgentCredentials): ModelRecommendations; getCommand(): string; getArgs(_config: SpawnConfig): string[]; getEnv(config: SpawnConfig): Record; detectLogin(output: string): LoginDetection; detectBlockingPrompt(output: string): BlockingPromptDetection; detectLoading(output: string): boolean; detectTaskComplete(output: string): boolean; detectReady(output: string): boolean; parseOutput(output: string): ParsedOutput | null; getPromptPattern(): RegExp; detectExit(output: string): { exited: boolean; code?: number; error?: string; }; getHealthCheckCommand(): string; } /** * OpenCode CLI Adapter * * Adapter for the OpenCode CLI (https://opencode.ai). OpenCode is a * provider-agnostic coding agent — it speaks OpenAI's chat-completions * protocol against any compatible endpoint (Anthropic, OpenAI, Cerebras, * OpenRouter, Groq, Together, DeepSeek, Ollama, vLLM, etc.) plus a * native Anthropic backend. Configuration is supplied to the binary via * the `OPENCODE_CONFIG_CONTENT` environment variable (a JSON object that * defines providers + the chosen model). The orchestrator constructs * that JSON from the user's standard provider env keys. * * Workspace-file convention matches Codex: `AGENTS.md` at the workdir * root is auto-loaded as project instructions on startup. * * Source: https://github.com/sst/opencode */ declare class OpencodeAdapter extends BaseCodingAdapter { readonly adapterType = "opencode"; readonly displayName = "OpenCode"; /** * OpenCode's TUI is light (no full-screen ratatui-style status bar), * so a short settle is sufficient — matches Gemini-CLI's 300ms baseline. */ readonly readySettleMs: number; readonly installation: InstallationInfo; getWorkspaceFiles(): AgentFileDescriptor[]; getRecommendedModels(credentials?: AgentCredentials): ModelRecommendations; getCommand(): string; getArgs(config: SpawnConfig): string[]; getEnv(config: SpawnConfig): Record; /** * OpenCode does not display its own login prompts when an API key is * pre-supplied (either via OPENCODE_CONFIG_CONTENT or a provider env * var). The bare `opencode auth` CLI exists for interactive setup, but * orchestrator-managed sessions never need it — credentials are * injected via env at spawn time. * * Auth-required signals are limited to error banners that surface * when an inbound request is rejected (401 / 403 / "invalid api key"). */ detectLogin(output: string): LoginDetection; /** * `--dangerously-skip-permissions` on `opencode run` short-circuits the * usual permission UI, so during normal orchestrator-spawned sessions * the adapter rarely encounters blocking prompts. The patterns below * cover the residual cases (interactive sessions, or provider auth * surfacing mid-run). */ detectBlockingPrompt(output: string): BlockingPromptDetection; detectLoading(output: string): boolean; detectTaskComplete(output: string): boolean; detectReady(output: string): boolean; parseOutput(output: string): ParsedOutput | null; getPromptPattern(): RegExp; getHealthCheckCommand(): string; } /** * Dynamic Pattern Loader * * Loads adapter patterns from @parallaxai/adapter-monitor snapshots when available, * with fallback to hardcoded baseline patterns. */ /** * Pattern set for an adapter */ interface AdapterPatterns { /** Ready state detection patterns */ ready: string[]; /** Auth/login detection patterns */ auth: string[]; /** Blocking prompt detection patterns */ blocking: string[]; /** Loading/active indicator patterns */ loading: string[]; /** Turn completion patterns */ turnComplete: string[]; /** Tool wait patterns */ toolWait: string[]; /** Exit/session complete patterns */ exit: string[]; /** Source of patterns */ source: 'snapshot' | 'baseline'; /** Version these patterns are from (if from snapshot) */ version?: string; } /** * Load patterns for an adapter * * Tries to load from @parallaxai/adapter-monitor snapshots first, * falls back to hardcoded baseline patterns. * * @param adapter - Adapter type * @param version - Optional specific CLI version to load patterns for * @param forceRefresh - Skip cache and reload */ declare function loadPatterns(adapter: AdapterType, version?: string, forceRefresh?: boolean): Promise; /** * Load patterns synchronously (uses cache or baseline only) * * Use this in constructors or synchronous code paths. * For best results, call loadPatterns() asynchronously during init. */ declare function loadPatternsSync(adapter: AdapterType): AdapterPatterns; /** * Preload patterns for all adapters * * Call this during application startup to warm the cache. */ declare function preloadAllPatterns(): Promise; /** * Clear the pattern cache */ declare function clearPatternCache(): void; /** * Get baseline patterns (always available, no async) */ declare function getBaselinePatterns(adapter: AdapterType): AdapterPatterns; /** * Check if dynamic patterns are available */ declare function hasDynamicPatterns(adapter: AdapterType): Promise; /** * coding-agent-adapters * * CLI adapters for AI coding agents. * Works with pty-manager to spawn and manage coding agents. * * @example * ```typescript * import { PTYManager } from 'pty-manager'; * import { ClaudeAdapter, GeminiAdapter } from 'coding-agent-adapters'; * * const manager = new PTYManager(); * manager.registerAdapter(new ClaudeAdapter()); * manager.registerAdapter(new GeminiAdapter()); * * // Non-interactive mode (default) - for automation * const session = await manager.spawn({ * name: 'my-agent', * type: 'claude', * workdir: '/path/to/project', * adapterConfig: { * anthropicKey: process.env.ANTHROPIC_API_KEY, * }, * }); * * // Interactive mode - full CLI experience * const interactiveSession = await manager.spawn({ * name: 'my-interactive-agent', * type: 'claude', * workdir: '/path/to/project', * adapterConfig: { * anthropicKey: process.env.ANTHROPIC_API_KEY, * interactive: true, // Skip --print/--quiet/--non-interactive flags * }, * }); * ``` */ /** * Create instances of all available adapters */ declare function createAllAdapters(): (ClaudeAdapter | GeminiAdapter | CodexAdapter | AiderAdapter | HermesAdapter | OpencodeAdapter)[]; declare const ADAPTER_TYPES: Record; /** * Create a specific adapter by type */ declare function createAdapter(type: AdapterType): ClaudeAdapter | GeminiAdapter | CodexAdapter | AiderAdapter | HermesAdapter | OpencodeAdapter; /** * Result of checking if a CLI is installed */ interface PreflightResult { adapter: string; installed: boolean; version?: string; error?: string; installCommand: string; docsUrl: string; /** Subscription/login auth status (only checked if installed) */ auth?: AuthStatus; } /** * Check if specific adapters are installed * * @example * ```typescript * const results = await checkAdapters(['claude', 'aider']); * for (const result of results) { * if (!result.installed) { * console.log(`${result.adapter} not found. Install: ${result.installCommand}`); * } * } * ``` */ declare function checkAdapters(types: AdapterType[]): Promise; /** * Check all available adapters * * @example * ```typescript * const results = await checkAllAdapters(); * const missing = results.filter(r => !r.installed); * * if (missing.length > 0) { * console.log('Missing CLI tools:'); * for (const m of missing) { * console.log(` ${m.adapter}: ${m.installCommand}`); * } * } * ``` */ declare function checkAllAdapters(): Promise; /** * Print installation instructions for missing adapters */ declare function printMissingAdapters(types?: AdapterType[]): Promise; export { ADAPTER_TYPES, AIDER_COMMAND_CATEGORIES, type AdapterPatterns, type AdapterType, type AgentCredentials, type AgentFileDescriptor, AiderAdapter, type ApprovalConfig, type ApprovalPreset, type AuthStatus, BaseCodingAdapter, CLAUDE_TOOL_CATEGORIES, CODEX_TOOL_CATEGORIES, ClaudeAdapter, CodexAdapter, type CodingAgentConfig, GEMINI_TOOL_CATEGORIES, GeminiAdapter, HermesAdapter, type InstallationInfo, type ModelRecommendations, OpencodeAdapter, PRESET_DEFINITIONS, type PreflightResult, type PresetDefinition, type RiskLevel, TOOL_CATEGORIES, type ToolCategory, type ToolCategoryInfo, type WriteMemoryOptions, checkAdapters, checkAllAdapters, clearPatternCache, createAdapter, createAllAdapters, generateAiderApprovalConfig, generateApprovalConfig, generateClaudeApprovalConfig, generateCodexApprovalConfig, generateGeminiApprovalConfig, generateHermesApprovalConfig, getBaselinePatterns, getPresetDefinition, hasDynamicPatterns, listPresets, loadPatterns, loadPatternsSync, preloadAllPatterns, printMissingAdapters };