import { Effect, Schema } from "effect"; import { type Services, type ToolDescription, ToolRuntime } from "./tool-runtime.js"; import type { Tools } from "./tools.js"; /** A tool call admitted during an execution. */ export type { ToolCall, ToolCallEnded, ToolCallHooks, ToolCallStarted, ToolDescription } from "./tool-runtime.js"; /** Signature-construction helpers for host-owned catalog instructions. */ export { searchSignature, toolExpression } from "./tool-runtime.js"; /** Resource budgets enforced independently during each CodeMode program execution. */ export type ExecutionLimits = { /** * Wall-clock milliseconds before interruption. Result delivery waits for tool cleanup. * No default: absent means no timeout. */ readonly timeoutMs?: number; /** Maximum number of tool calls admitted by the runtime. No default: absent means unlimited. */ readonly maxToolCalls?: number; /** * Maximum UTF-8 bytes retained from the result and logs. Warnings have a separate equal budget; * truncation notices and host formatting are additional. */ readonly maxOutputBytes?: number; }; export type ResolvedExecutionLimits = { readonly timeoutMs: number | undefined; readonly maxToolCalls: number | undefined; readonly maxOutputBytes: number | undefined; }; /** Options for one CodeMode execution. */ export type ExecuteOptions = {}> = { /** Source for one program in the supported JavaScript subset. */ code: string; /** Explicit tools exposed to the program as `tools`. */ tools?: Provided & Tools>; /** Per-execution overrides for the default resource limits. */ limits?: ExecutionLimits; /** Observes decoded tool input immediately before tool execution. */ onToolCallStart?: (call: ToolRuntime.ToolCallStarted) => Effect.Effect>; /** Observes each admitted tool call as it succeeds, fails, or is interrupted. */ onToolCallEnd?: (call: ToolRuntime.ToolCallEnded) => Effect.Effect>; }; /** A JSON value that can cross the confined interpreter boundary. */ export type DataValue = Schema.Json; /** Configuration shared by `CodeMode.make` and `CodeMode.execute`. */ export type Options = {}> = Omit, "code">; /** Schema for a host tool input containing CodeMode source. */ export declare const Input: Schema.Struct<{ readonly code: Schema.String; }>; export type Input = typeof Input.Type; export declare const DiagnosticKind: Schema.Literals; /** Stable categories produced by program, schema, tool, limit, and truncation diagnostics. */ export type DiagnosticKind = typeof DiagnosticKind.Type; export declare const Diagnostic: Schema.Struct<{ readonly kind: Schema.Literals; readonly message: Schema.String; readonly location: Schema.optionalKey>; readonly suggestions: Schema.optionalKey>; }>; /** A normalized program diagnostic safe to return across an agent tool boundary. */ export type Diagnostic = typeof Diagnostic.Type; export declare const Success: Schema.Struct<{ readonly ok: Schema.Literal; readonly value: Schema.Codec; readonly warnings: Schema.optionalKey; readonly message: Schema.String; readonly location: Schema.optionalKey>; readonly suggestions: Schema.optionalKey>; }>>>; readonly logs: Schema.optionalKey>; readonly truncated: Schema.optionalKey; readonly toolCalls: Schema.$Array>; }>; /** Successful execution after the result has crossed the plain-data boundary. */ export type Success = typeof Success.Type; export declare const Failure: Schema.Struct<{ readonly ok: Schema.Literal; readonly error: Schema.Struct<{ readonly kind: Schema.Literals; readonly message: Schema.String; readonly location: Schema.optionalKey>; readonly suggestions: Schema.optionalKey>; }>; readonly logs: Schema.optionalKey>; readonly truncated: Schema.optionalKey; readonly toolCalls: Schema.$Array>; }>; /** Failed execution with calls admitted before the diagnostic was produced. */ export type Failure = typeof Failure.Type; /** Schema for the structured success or diagnostic returned by CodeMode execution. */ export declare const Result: Schema.Union; readonly value: Schema.Codec; readonly warnings: Schema.optionalKey; readonly message: Schema.String; readonly location: Schema.optionalKey>; readonly suggestions: Schema.optionalKey>; }>>>; readonly logs: Schema.optionalKey>; readonly truncated: Schema.optionalKey; readonly toolCalls: Schema.$Array>; }>, Schema.Struct<{ readonly ok: Schema.Literal; readonly error: Schema.Struct<{ readonly kind: Schema.Literals; readonly message: Schema.String; readonly location: Schema.optionalKey>; readonly suggestions: Schema.optionalKey>; }>; readonly logs: Schema.optionalKey>; readonly truncated: Schema.optionalKey; readonly toolCalls: Schema.$Array>; }>]>; /** Result of executing a CodeMode program. Program failures are data, not Effect failures. */ export type Result = typeof Result.Type; /** Reusable confined runtime over explicit tools. */ export type Runtime = { readonly catalog: () => ReadonlyArray; readonly execute: (code: string) => Effect.Effect; }; /** Executes one Effect-native CodeMode program without constructing a reusable runtime. */ export declare const execute: >(options: ExecuteOptions) => Effect.Effect>; /** Creates an Effect-native runtime over explicit, schema-described tools. */ export declare const make: = {}>(options?: Options) => Runtime>;