/** * SCHEMAS * ======= * * A tool needs two things from its schema: JSON Schema to describe itself to the * model, and a way to check the arguments that come back. Both are obtained * without depending on any validation library — a Standard Schema (zod 3.24+, * valibot, arktype, ...) provides validation through `~standard`, and a plain * JSON Schema object is accepted as-is. */ export type JSONSchema = Record; /** * The Standard Schema v1 interface, vendored so this SDK needs no dependency. * @see https://standardschema.dev */ export interface StandardSchemaV1 { readonly "~standard": { readonly version: 1; readonly vendor: string; readonly validate: (value: unknown) => { value: Output; issues?: undefined; } | { issues: ReadonlyArray<{ message: string; path?: ReadonlyArray; }>; } | Promise<{ value: Output; issues?: undefined; } | { issues: ReadonlyArray<{ message: string; path?: ReadonlyArray; }>; }>; readonly types?: { readonly input: Input; readonly output: Output; }; }; } /** Anything accepted as a tool or hook schema. */ export type ToolSchema = StandardSchemaV1 | { toJSONSchema(): JSONSchema; } | JSONSchema; /** * The argument type a schema produces, so `run({ args })` is typed from the * schema rather than left as a bag of unknowns. Falls back to a loose record for * a raw JSON Schema, which carries no type information. */ export type InferSchemaOutput = S extends StandardSchemaV1 ? Output : S extends { _output: infer Output; } ? Output : Record; /** * Derives JSON Schema from whatever the caller supplied. * * Order matters: an explicit converter or a raw JSON Schema is used verbatim, and * zod is only reached for when nothing else can answer. */ export declare function toJSONSchema(schema: ToolSchema, label: string): JSONSchema; export type ValidationResult = { ok: true; value: T; } | { ok: false; error: string; }; /** * Validates arguments if the schema can validate at all. * * The server deliberately does not check a client's tool arguments — the client * authored the schema, so it owns the check. This is the only place it can happen, * which is why a Standard Schema is worth passing. */ export declare function validateArgs(schema: ToolSchema | undefined, args: unknown): Promise>;