import { type PromptResponse } from "@agentclientprotocol/sdk"; import type { AgentAdapter, AgentInput, IsolationPaths, TokenUsage } from "../../types/agent.js"; import type { SetupContext } from "./agent-adapter.js"; export type { SetupContext } from "./agent-adapter.js"; /** * A declarative spec for an ACP-based agent adapter. Pass to * `createAcpBasedAdapter` to get back an `AgentAdapter` that speaks the * Agent Client Protocol over stdio. * * Much simpler than `AgentAdapterSpec` because ACP handles the protocol — * no `streamConfig`, `getResult`, or `initialState`. */ export interface AcpAdapterSpec { /** Adapter name. Used in logs, error messages, and `AgentAdapter.name`. */ name: string; /** * CLI binary resolved via `resolveCommand` + npx fallback. Omit if the * adapter gets its command from `input.config.command` at runtime. */ cliCommand?: string; /** Build CLI arguments for launching the agent in ACP mode. */ buildArgs?: (input: AgentInput) => string[]; /** Execution timeout. Defaults to 10 minutes. */ timeoutMs?: number; /** Env vars the adapter requires (validated by runner pre-flight). */ requiredEnv?: () => string[]; /** * Detect a usable local CLI login. Runner calls this only when * `requiredEnv` is missing — API keys always take precedence. */ hasLocalSession?: () => boolean | Promise; /** Workspace isolation env vars (merged into child env by runner). */ isolationEnv?: (paths: IsolationPaths) => Record; /** * Pre-spawn side effects: mkdir, config writers, etc. * Runs after env is finalized and before the process is spawned. */ prepare?: (ctx: SetupContext) => void | Promise; /** * Extract token usage from a vendor-specific `PromptResponse._meta` payload. * The standard `PromptResponse.usage` field is already consumed; this hook * runs only when `usage` is absent. Return `undefined` if no usage can be * derived. */ extractUsage?: (promptResult: PromptResponse) => TokenUsage | undefined; } /** * Build an `AgentAdapter` from an ACP-based spec. The returned adapter: * - Spawns the agent binary with bidirectional stdio * - Runs the ACP lifecycle: initialize → session/new → session/prompt * - Maps `session/update` notifications to AXIS `TranscriptEntry[]` * - Auto-approves permission requests * - Provides filesystem access to the agent workspace * - Manages timeout, cleanup, token estimation */ export declare function createAcpBasedAdapter(spec: AcpAdapterSpec): AgentAdapter; //# sourceMappingURL=acp-adapter.d.ts.map