import type { StandardSchemaV1 } from "@standard-schema/spec"; import * as fc from "fast-check"; import { type ActionOutputErrorStrategy, type ActionRunContext } from "./action.js"; /** An `undefined` entry means no override for that pointer. */ export type ArbitraryOverrides = Readonly | undefined>>; export interface ArbitraryFromJsonSchemaOptions { /** * Arbitraries keyed by JSON pointer into the generated input, for values * the generator cannot build. Array items use the `-` token: `/tags/-`. */ overrides?: ArbitraryOverrides; } export declare class UnsupportedSchemaError extends Error { readonly path: string; constructor(path: string, reason: string); } /** * Build a fast-check arbitrary for a JSON Schema, such as the one * `z.toJSONSchema(schema, { io: "input" })` produces for a zod schema. Any * keyword or shape it cannot generate throws `UnsupportedSchemaError` with * the JSON pointer of the value, unless `overrides` supplies that value. */ export declare function arbitraryFromJsonSchema(schema: unknown, options?: ArbitraryFromJsonSchemaOptions): fc.Arbitrary; export interface CheckActionPropertiesOptions { /** Generated inputs per property. Defaults to 50. */ runs?: number; /** Replays a run: fast-check reports the seed of any failure. */ seed?: number; /** Passed to every call, copied per call, as the caller would supply it. */ context: ActionRunContext; /** Arbitraries for JSON pointers the generator cannot build. */ overrides?: ArbitraryOverrides; } /** * The parts of an action this check reads. An action defined with * `defineAction` fits: its `run` takes its own input type, which `never` * accepts, and its zod `schema` is kept on the entry at runtime. */ export interface CheckableAction { readonly run: (args: never, ctx?: ActionRunContext) => unknown; readonly tool: { readonly description: string; }; readonly schema?: StandardSchemaV1; readonly outputSchema?: StandardSchemaV1; readonly outputErrorStrategy?: ActionOutputErrorStrategy; } /** * Check an action against inputs generated from its zod schema. Valid inputs * must return a value matching `outputSchema`, or throw an action contract * error. Invalid inputs (each required property of a plain object, nested * objects and array items included, removed or set to a wrong-type value) must * be rejected by input validation before the handler runs. The invalid cases * prove the handler sits behind validation; they do not re-test the schema's * own constraints (`min`, formats) or fields inside union branches. * Rejects with fast-check's shrunk counterexample and seed on failure. */ export declare function checkActionProperties(action: CheckableAction, options: CheckActionPropertiesOptions): Promise;