import type { AgentEngine, EngineMessage } from "../agent/engine/types.js"; import { type AgentLoopUsage } from "../agent/production-agent.js"; import { type AgentPromptAttachment } from "../code-agents/prompt-attachments.js"; import { type McpToolInvocationPolicy } from "../mcp-client/index.js"; import { type ReasoningEffort } from "../shared/reasoning-effort.js"; import { type CodeAgentPermissionMode, type CodeAgentRunRecord } from "./code-agent-runs.js"; export interface ExecuteCodeAgentRunOptions { runId: string; prompt?: string; appendUserEvent?: boolean; engine?: AgentEngine; model?: string; reasoningEffort?: ReasoningEffort; attachments?: AgentPromptAttachment[]; stdout?: NodeJS.WritableStream; signal?: AbortSignal; } interface CodeAgentApprovalExecutionOptions { stdout?: NodeJS.WritableStream; signal?: AbortSignal; } export declare function executeCodeAgentRun(options: ExecuteCodeAgentRunOptions): Promise; export declare function codeAgentMcpInvocationPolicy(permissionMode: CodeAgentPermissionMode): McpToolInvocationPolicy; export declare function executeExistingCodeAgentRun(runId: string, options?: Omit): Promise; /** * Add the pending approval command to the per-project allowlist, then approve * and auto-resume. Future occurrences of this exact command will bypass the * approval gate without prompting. */ export declare function executeApproveAlwaysCodeAgentApproval(runId: string, options?: CodeAgentApprovalExecutionOptions): Promise; export declare function executePendingCodeAgentApproval(runId: string, options?: CodeAgentApprovalExecutionOptions): Promise; /** * Deny a pending approval: record the denial, feed it back to the model as a * "command denied by user" result, and immediately resume the run so the model * can adapt its plan without leaving the run dangling. */ export declare function executeDenyCodeAgentApproval(runId: string, options?: CodeAgentApprovalExecutionOptions): Promise; /** * Reconstruct a sequence of EngineMessage objects from transcript events, * preserving the native tool-call / tool-result pair structure that models * expect when replaying multi-turn conversations. * * Event mapping: * kind=user → user message with text content * kind=system, role=assistant → assistant message with text content * kind=status, type=tool_start → assistant message with a tool-call part * (grouped with any preceding assistant text) * kind=status, type=tool_done → user message with a tool-result part * kind=status, type=thinking → excluded (ephemeral reasoning) * everything else → excluded from model history * * Each tool_start generates a synthetic toolCallId derived from the event id so * that the matching tool_done can reference it. Old events that lack tool/input * metadata fall back gracefully to text content. */ /** @internal exported for unit tests */ export declare function buildStructuredMessagesFromEvents(events: readonly import("./code-agent-runs.js").CodeAgentTranscriptEvent[]): EngineMessage[]; /** * Build the coding agent system prompt, inlining AGENTS.md (or CLAUDE.md as * fallback) and a skills index from .agents/skills/ into the prompt so the * coding agent has the same repo-context awareness that Claude Code / Codex * provide when running locally. * * The bundle is read synchronously from the filesystem via `readAgentsBundleFromFs` * (same function used by the Vite build-time plugin) so there is no async I/O * on the hot path — the call is cheap and the result is used once per run leg. */ /** @internal exported for unit tests */ export declare function buildCodeAgentSystemPrompt(cwd: string, permissionMode: CodeAgentPermissionMode): Promise; /** @internal exported for unit tests */ export declare function buildRepoInstructionsBlock(agentsMdContent: string): string; /** @internal exported for unit tests */ export declare function codeAgentSystemPrompt(cwd: string, permissionMode: CodeAgentPermissionMode, repoInstructionsBlock?: string, skillsBlock?: string): string; export type CodeAgentCommandPermission = { kind: "read"; } | { kind: "write"; } | { kind: "approval-required"; reason: string; } | { kind: "forbidden"; reason: string; }; export declare function classifyCodeAgentCommandPermission(command: string): CodeAgentCommandPermission; export declare function writeCodeAgentUsageSnapshot(cwd: string, usage: AgentLoopUsage | null): void; export {}; //# sourceMappingURL=code-agent-executor.d.ts.map