eve
Version:
Filesystem-first framework for durable backend AI agents that run anywhere.
57 lines (56 loc) • 3.18 kB
TypeScript
import type { StandardJSONSchemaV1, StandardSchemaV1 } from "#compiled/@standard-schema/spec/index.js";
import { type JsonObject } from "#shared/json.js";
/**
* eve-owned schema contract for tool input and output schemas: a Standard
* Schema validator that can also emit JSON Schema. Zod implements both
* constituent protocols without exposing Zod through runtime-owned types.
*/
export type ToolSchema<Input = unknown, Output = Input> = StandardSchemaV1<Input, Output> & StandardJSONSchemaV1<Input, Output>;
/**
* Any value accepted at a schema boundary: a live {@link ToolSchema}, a
* JSON-Schema-capable Standard Schema, or plain JSON Schema data. Plain data
* is runtime-validated by {@link parseJsonObject} during conversion.
*/
export type ToolSchemaSource = StandardJSONSchemaV1 | Record<string, unknown>;
/** `null` and `undefined` pass through every conversion untouched. */
type SchemaResult<TSource, TResult> = TSource extends null | undefined ? TSource : TResult;
/**
* Resolves a source into a live input {@link ToolSchema}. Live schemas pass
* through unchanged; serialized JSON Schemas are rehydrated into vendored Zod
* validators. Serialized schemas outside Zod's conversion subset degrade to a
* validation-free schema that still advertises the source JSON Schema. `null`
* and `undefined` pass through untouched.
*/
export declare function toInputSchema<T extends ToolSchemaSource | null | undefined>(source: T): SchemaResult<T, ToolSchema>;
/**
* Resolves a source into a live output {@link ToolSchema}. Live schemas pass
* through unchanged; serialized JSON Schemas are rehydrated into vendored Zod
* validators. Serialized schemas outside Zod's conversion subset degrade to a
* validation-free schema that still advertises the source JSON Schema. `null`
* and `undefined` pass through untouched.
*/
export declare function toOutputSchema<T extends ToolSchemaSource | null | undefined>(source: T): SchemaResult<T, ToolSchema>;
/**
* Serializes an input schema source into canonical JSON Schema data (no
* `$schema` key) for compiled artifacts, durable state, and protocol
* responses. `null` and `undefined` pass through untouched.
*/
export declare function serializeInputSchema<T extends ToolSchemaSource | null | undefined>(source: T): SchemaResult<T, JsonObject>;
/**
* Serializes an output schema source into canonical JSON Schema data (no
* `$schema` key) for compiled artifacts, durable state, and protocol
* responses. `null` and `undefined` pass through untouched.
*/
export declare function serializeOutputSchema<T extends ToolSchemaSource | null | undefined>(source: T): SchemaResult<T, JsonObject>;
/**
* Returns whether a value implements the full {@link ToolSchema} contract:
* Standard Schema validation plus JSON Schema emission.
*/
export declare function isToolSchema(value: unknown): value is ToolSchema;
/**
* Permissive schema lowered onto model-visible tools whose definitions
* declare no input schema. Accepts any input — an absent schema declares no
* contract, so rejecting stray properties would only force needless retries.
*/
export declare const UNSPECIFIED_INPUT_SCHEMA: ToolSchema;
export {};