import type { ActionEntry } from "../agent/production-agent.js"; export interface CodingCommandResult { code: number | null; stdout: string; stderr: string; timedOut: boolean; durationMs?: number; } /** * Structured metadata emitted on tool_start / tool_done events so the UI can * render bespoke cells (bash terminal, edit diff, etc.) instead of the generic * pill. Fields are additive — older consumers that don't know them are unaffected. */ export interface BashToolMetadata { toolKind: "bash"; command: string; cwd: string; exitCode?: number | null; durationMs?: number; timedOut?: boolean; } export interface EditToolMetadata { toolKind: "edit"; filePath: string; /** The exact old text replaced (capped at EDIT_CONTENT_MAX_CHARS). */ oldText?: string; /** The exact new text written (capped at EDIT_CONTENT_MAX_CHARS). */ newText?: string; truncated?: boolean; } export interface WriteToolMetadata { toolKind: "write"; filePath: string; /** Full file content written (capped at EDIT_CONTENT_MAX_CHARS). */ content?: string; truncated?: boolean; lineCount?: number; } export interface ReadToolMetadata { toolKind: "read"; filePath: string; lineCount?: number; } export type StructuredToolMetadata = BashToolMetadata | EditToolMetadata | WriteToolMetadata | ReadToolMetadata; /** Callback invoked with incremental bash output while the command is running. */ export type BashOutputChunkCallback = (chunk: string) => void; export interface CreateCodingToolRegistryOptions { cwd?: string; restrictToCwd?: boolean; commandTimeoutMs?: number; maxOutputChars?: number; maxFileReadChars?: number; bashThrowsOnNonZero?: boolean; canWrite?: (toolName: "edit" | "write") => string | null; beforeBash?: (input: { command: string; cwd: string; timeoutMs: number; }) => string | null | Promise; /** Called with incremental stdout+stderr chunks while a bash command runs. */ onBashOutputChunk?: BashOutputChunkCallback; /** * Called when structured metadata is available for a tool call. The * `phase` is "start" (right before execution) or "done" (after execution). * This is the side-channel used to populate bespoke tool-cell fields without * changing the string-result contract that the agent sees. */ onToolMetadata?: (toolName: string, phase: "start" | "done", meta: StructuredToolMetadata) => void; } /** * Output retention window for bash: keep first HEAD_CHARS + last TAIL_CHARS, * separated by a truncation marker. Replaces the old flat 4 000-char cap. */ export declare const BASH_OUTPUT_HEAD_CHARS = 4096; export declare const BASH_OUTPUT_TAIL_CHARS = 16384; /** Maximum chars stored per side of an edit/write for diff rendering. */ export declare const EDIT_CONTENT_MAX_CHARS = 49152; export declare function createCodingToolRegistry(options?: CreateCodingToolRegistryOptions): Record<"bash" | "read" | "edit" | "write", ActionEntry>; export declare function runCodingCommand(command: string, cwd: string, timeoutMs: number, options?: { stdin?: string; onChunk?: BashOutputChunkCallback; signal?: AbortSignal; }): Promise; /** * Spawn a command detached in the background. Returns immediately with the * process PID and a temporary log file path where stdout + stderr are written. * * The child process is intentionally detached from the parent's process group * (`detached: true`, `unref()`) so it continues running after the tool call * completes and is not killed if the agent run exits. The approval classifier * still applies before this function is reached (see `beforeBash` in the * calling registry). */ export declare function spawnBackgroundCommand(command: string, cwd: string): string; export declare function formatCodingCommandResult(result: CodingCommandResult, maxChars?: number, options?: { omitEmptyExitCode?: boolean; }): string; export declare function truncateCodingOutput(value: string, max: number): string; /** * Retain the first HEAD_CHARS and the last TAIL_CHARS of bash output, inserting * a truncation marker in the middle. This is a better window than a simple * prefix slice because the end of the output usually contains the most important * signal (error messages, test results, etc.). */ export declare function truncateBashOutput(value: string, headChars?: number, tailChars?: number): string; export declare function isReadOnlyShellCommand(command: string): boolean; //# sourceMappingURL=index.d.ts.map