import { D as WorkspaceRuntimeValue, E as WorkspaceRuntimeTruncation, M as WorkspaceBackendInfo } from "./shared-BP8PrtyI.js"; import { z } from "zod"; //#region src/tools/common/exec.d.ts type ExecStreamEvent = { name: "stdout"; value: string; } | { name: "stderr"; value: string; } | { name: "exit"; code: number; result?: unknown; truncated?: WorkspaceRuntimeTruncation; }; interface ExecRuntimeHandle extends Partial> { result(): Promise<{ exitCode: number; stdout: string; stderr: string; value?: unknown; truncated?: WorkspaceRuntimeTruncation; }>; kill?(): Promise; } interface ExecWorkspaceLike { runtime: { exec(command: string, options: { cwd?: string; encoding: "utf8"; backend?: string; env?: Record; input?: WorkspaceRuntimeValue; output?: { maxBytes: number; maxLines: number; }; }): Promise; backends?(): readonly WorkspaceBackendInfo[]; }; } /** Options for one backend the exec tool may run on. */ interface ExecBackendOptions { /** Shown to the model before the backend's own description. */ readonly description?: string; } /** * The backends the exec tool may run on, keyed by backend id: * `{ "worker-javascript": { description: "Use for data work." } }`. * Pass `{}` for a backend that needs nothing beyond its own * description. */ type ExecBackends = Readonly>; interface ExecToolOptions { workspace: ExecWorkspaceLike; backends?: ExecBackends; maxBytes?: number; maxLines?: number; /** * @deprecated Ignored. Memory per stream is now bounded by a few * times `maxBytes`. */ streamMaxBytes?: number; now?: () => number; } type ExecToolOutput = { command: string; cwd: string | null; backend: string; exitCode: number | null; stdout: string; stderr: string; result?: unknown; } | { command: string; cwd: string | null; backend: string; error: string; }; interface ExecInput { command: string; cwd?: string; backend?: string; env?: Record; input?: { [key: string]: WorkspaceRuntimeValue; }; } interface ExecCallContext { abortSignal?: AbortSignal; } /** The exec tool with no agent library attached. Each library wraps it in its own tool shape. */ interface ExecDefinition { description: string; inputSchema: z.ZodType; prepareArguments(args: unknown): unknown; /** * Yields running snapshots while the command streams, then one * terminal snapshot. Every snapshot is a complete result, so a * library that cannot stream tool output keeps the last one. */ execute(input: ExecInput, context?: ExecCallContext): AsyncGenerator; } /** * Resolve the backends once and build the exec tool's description, * input schema, and executor. Throws when no backend is left or an id * is unknown, so a misconfigured tool fails when it is built. */ declare function defineExec(options: ExecToolOptions): ExecDefinition; //#endregion export { ExecInput as a, ExecToolOptions as c, defineExec as d, ExecDefinition as i, ExecToolOutput as l, ExecBackends as n, ExecRuntimeHandle as o, ExecCallContext as r, ExecStreamEvent as s, ExecBackendOptions as t, ExecWorkspaceLike as u }; //# sourceMappingURL=shared-r-ii1gfO.d.ts.map