/** * Agent that delegates task execution to external coding CLIs * (Claude Code, OpenCode) or an in-process mock for tests and demos. */ import { Task } from '..'; import { AgentLoopResult } from '../utils/llm.types'; import { BaseAgent } from './baseAgent'; export type ExternalCodingBackend = 'claude-code' | 'opencode' | 'codex' | 'mock'; export interface ClaudeCodeCliOptions { /** When true (default), passes `--bare` for reproducible scripted runs. */ useBare?: boolean; allowedTools?: string; permissionMode?: string; maxTurns?: number; maxBudgetUsd?: number; extraArgs?: string[]; } export interface OpenCodeCliOptions { model?: string; /** OpenCode `--agent` flag value (named agent in OpenCode config). */ agentName?: string; attachUrl?: string; extraArgs?: string[]; } export interface CodexCliOptions { model?: string; /** * Sandbox policy for `codex exec --sandbox`. * `'read-only'` (default) — safe for read-only tasks. * `'workspace-write'` — lets the agent edit files in `workspaceRoot`. * `'danger-full-access'` — no sandboxing (use only in isolated environments). */ sandboxMode?: 'read-only' | 'workspace-write' | 'danger-full-access'; /** * Keep the session on disk (`--no-ephemeral`). * Defaults to `true` (ephemeral) for reproducible scripted runs. */ ephemeral?: boolean; /** Pass `--skip-git-repo-check` when `workspaceRoot` is not a git repo. */ skipGitRepoCheck?: boolean; extraArgs?: string[]; } export interface ExternalCodingAgentParams { type?: 'ExternalCodingAgent'; name: string; role: string; goal: string; background: string; codingBackend: ExternalCodingBackend; /** Current working directory for the external CLI (usually the repo root). */ workspaceRoot: string; /** * Executable name or absolute path. * Defaults: `claude` (Claude Code), `opencode` (OpenCode). Ignored for `mock`. */ cliPath?: string; /** Max time for one CLI invocation (default 600_000 ms). */ timeoutMs?: number; claude?: ClaudeCodeCliOptions; opencode?: OpenCodeCliOptions; codex?: CodexCliOptions; } export declare class ExternalCodingAgent extends BaseAgent { private readonly codingBackend; private readonly workspaceRoot; private readonly cliPath?; private readonly timeoutMs; private readonly claude?; private readonly opencode?; private readonly codex?; constructor(config: ExternalCodingAgentParams); workOnTask(task: Task, inputs: Record, context: string): Promise; workOnFeedback(task: Task, feedbackList: Array<{ content: string; }>, context: string): Promise; workOnTaskResume(task: Task): Promise; getCleanedAgent(): Partial; private buildPrompt; private mergeEnv; private executePrompt; private invokeBackend; }