import type { ToolExecutionOptions } from "ai"; import type { StandardJSONSchemaV1 } from "#compiled/@standard-schema/spec/index.js"; import type { JsonObject } from "#shared/json.js"; /** * Options forwarded from the AI SDK to the tool's {@link ToolDefinition.execute} * function. These are the same options the SDK passes to every tool call. */ export type ToolExecuteOptions = Omit, "context">; export type ToolExecuteFn = (input: TInput, options?: ToolExecuteOptions) => Promise | TOutput; interface ToolDefinitionBase { readonly description: string; } /** * Internal/compiled tool definition shape. Carries `name` because the * compiler stamps a path-derived identifier onto every tool entry. * * Authored public definitions (see {@link PublicToolDefinition}) do not * carry `name`; identity comes from the file path. */ export interface InternalToolDefinition extends ToolDefinitionBase { name: string; inputSchema: JsonObject | null; outputSchema?: JsonObject; } export type PublicToolInputSchema = StandardJSONSchemaV1 | JsonObject; export type PublicToolOutputSchema = StandardJSONSchemaV1 | JsonObject; /** * Authored public tool definition shape. Identity is derived from the * file path at compile time, so `name` is intentionally absent here. */ export interface PublicToolDefinition extends ToolDefinitionBase { inputSchema: PublicToolInputSchema; /** * Optional schema describing the value returned by the tool executor. * Code mode uses this to expose typed host-tool return values to the * generated program, and the AI SDK can use it for tool result typing. */ outputSchema?: PublicToolOutputSchema; } export interface InternalToolDefinitionWithExecuteFn extends InternalToolDefinition { execute: ToolExecuteFn; } export interface PublicToolDefinitionWithExecuteFn extends PublicToolDefinition { execute: ToolExecuteFn; } /** * eve-owned shape for the model-facing tool result produced by * `toModelOutput`. Structurally compatible with the AI SDK's * `ToolResultOutput` so the harness can forward it without conversion. */ export type ToolModelOutput = { readonly type: "text"; readonly value: string; } | { readonly type: "json"; readonly value: unknown; }; export {};