/**
 * The tools' schema builder: one definition gives a tool's published JSON
 * Schema, its TypeScript type, and the validation of its arguments and
 * results. In-house, so `run402-mcp` carries no schema library of its own.
 *
 * The API is the subset of zod 3 the tools use, with zod 3's semantics:
 * methods return new schemas; `optional()`, `nullable()` and `catch`-free
 * wrappers copy the description, as zod 3 did; an object strips undeclared
 * keys unless `strict()` (refuse them) or `loose()` (keep them).
 *
 * `toJsonSchema` reproduces what zod-to-json-schema 3 (draft-07, `$ref`
 * strategy `root`, `strictUnions`) emitted for the same definitions, byte for
 * byte: `src/fixtures/tools-list-4.142.0.json` pins it for all eight tools.
 * A schema object used twice in one tool is emitted once and referenced by
 * `$ref` to the path where it first appeared.
 */
type Path = ReadonlyArray<string | number>;
export interface SchemaIssue {
    path: Array<string | number>;
    message: string;
    /** `unrecognized_keys` for a strict object's undeclared keys (with `keys`, and `declared`, the keys that object declares); `invalid` otherwise. */
    code: "unrecognized_keys" | "invalid";
    keys?: string[];
    declared?: string[];
}
export type SafeParseResult<T> = {
    success: true;
    data: T;
} | {
    success: false;
    issues: SchemaIssue[];
    error: {
        issues: SchemaIssue[];
    };
};
type JsonSchema = Record<string, unknown>;
interface ParseCtx {
    issues: SchemaIssue[];
}
export declare class SchemaError extends Error {
    readonly issues: SchemaIssue[];
    constructor(issues: SchemaIssue[]);
}
/** Marker returned by a parse that failed; never escapes `safeParse`. */
declare const INVALID: unique symbol;
export declare abstract class Schema<O> {
    /** The TypeScript type this schema accepts; type-level only. */
    readonly _output: O;
    description: string | undefined;
    protected abstract copy(): this;
    /** True when `undefined` passes, which makes an object member optional (zod 3's `isOptional`). */
    acceptsUndefined(): boolean;
    describe(description: string): this;
    optional(): OptionalSchema<this>;
    nullable(): NullableSchema<this>;
    refine(check: (value: O) => boolean, opts: {
        message: string;
        path?: Array<string | number>;
    }): RefinedSchema<O>;
    safeParse(value: unknown): SafeParseResult<O>;
    /** The parsed value, or a thrown `SchemaError` listing every issue. */
    parse(value: unknown): O;
    /** @internal */
    abstract parseAt(value: unknown, path: Path, ctx: ParseCtx): unknown;
    /** @internal The JSON Schema for this node, before its description is added. */
    abstract emitBody(refs: EmitRefs): JsonSchema | undefined;
    protected fail(ctx: ParseCtx, path: Path, message: string): typeof INVALID;
}
export type Infer<S> = S extends Schema<infer O> ? O : never;
/** Any schema, whatever it accepts. `refine`'s callback makes `Schema<O>` invariant, so constraints need `any`, as zod's do. */
export type AnySchema = Schema<any>;
export type RawShape = Record<string, AnySchema>;
type StringCheck = {
    kind: "min" | "max";
    value: number;
} | {
    kind: "regex";
    value: RegExp;
} | {
    kind: "url";
};
export declare class StringSchema extends Schema<string> {
    readonly checks: readonly StringCheck[];
    constructor(checks?: readonly StringCheck[]);
    protected copy(): this;
    private with;
    min(value: number): StringSchema;
    max(value: number): StringSchema;
    regex(value: RegExp): StringSchema;
    url(): StringSchema;
    parseAt(value: unknown, path: Path, ctx: ParseCtx): unknown;
    emitBody(): JsonSchema;
}
type NumberCheck = {
    kind: "int";
} | {
    kind: "min" | "max";
    value: number;
};
export declare class NumberSchema extends Schema<number> {
    readonly checks: readonly NumberCheck[];
    constructor(checks?: readonly NumberCheck[]);
    protected copy(): this;
    private with;
    int(): NumberSchema;
    min(value: number): NumberSchema;
    max(value: number): NumberSchema;
    nonnegative(): NumberSchema;
    parseAt(value: unknown, path: Path, ctx: ParseCtx): unknown;
    emitBody(): JsonSchema;
}
export declare class BooleanSchema extends Schema<boolean> {
    protected copy(): this;
    parseAt(value: unknown, path: Path, ctx: ParseCtx): unknown;
    emitBody(): JsonSchema;
}
export declare class NullSchema extends Schema<null> {
    protected copy(): this;
    parseAt(value: unknown, path: Path, ctx: ParseCtx): unknown;
    emitBody(): JsonSchema;
}
export declare class UnknownSchema extends Schema<unknown> {
    protected copy(): this;
    acceptsUndefined(): boolean;
    parseAt(value: unknown): unknown;
    emitBody(): JsonSchema;
}
type Literal = string | number | boolean;
export declare class LiteralSchema<L extends Literal> extends Schema<L> {
    readonly value: L;
    constructor(value: L);
    protected copy(): this;
    parseAt(value: unknown, path: Path, ctx: ParseCtx): unknown;
    emitBody(): JsonSchema;
}
export declare class EnumSchema<V extends string> extends Schema<V> {
    readonly values: readonly V[];
    constructor(values: readonly V[]);
    protected copy(): this;
    parseAt(value: unknown, path: Path, ctx: ParseCtx): unknown;
    emitBody(): JsonSchema;
}
export declare class ArraySchema<I extends AnySchema> extends Schema<Array<Infer<I>>> {
    readonly item: I;
    readonly minItems?: number | undefined;
    readonly maxItems?: number | undefined;
    constructor(item: I, minItems?: number | undefined, maxItems?: number | undefined);
    protected copy(): this;
    min(value: number): ArraySchema<I>;
    max(value: number): ArraySchema<I>;
    parseAt(value: unknown, path: Path, ctx: ParseCtx): unknown;
    emitBody(refs: EmitRefs): JsonSchema;
}
export declare class RecordSchema<V extends AnySchema> extends Schema<Record<string, Infer<V>>> {
    readonly valueSchema: V;
    constructor(valueSchema: V);
    protected copy(): this;
    parseAt(value: unknown, path: Path, ctx: ParseCtx): unknown;
    emitBody(refs: EmitRefs): JsonSchema;
}
type UnknownKeys = "strip" | "strict" | "loose";
type IsOptional<S> = S extends OptionalSchema<AnySchema> ? true : S extends UnknownSchema ? true : false;
type Flatten<T> = {
    [K in keyof T]: T[K];
} & {};
type ObjectOutput<S extends RawShape> = Flatten<{
    [K in keyof S as IsOptional<S[K]> extends true ? never : K]: Infer<S[K]>;
} & {
    [K in keyof S as IsOptional<S[K]> extends true ? K : never]?: Infer<S[K]>;
}>;
export declare class ObjectSchema<S extends RawShape, M extends UnknownKeys = "strip"> extends Schema<M extends "loose" ? ObjectOutput<S> & Record<string, unknown> : ObjectOutput<S>> {
    readonly shape: S;
    readonly unknownKeys: M;
    constructor(shape: S, unknownKeys: M);
    protected copy(): this;
    strict(): ObjectSchema<S, "strict">;
    loose(): ObjectSchema<S, "loose">;
    parseAt(value: unknown, path: Path, ctx: ParseCtx): unknown;
    emitBody(refs: EmitRefs): JsonSchema;
}
export declare class UnionSchema<T extends readonly AnySchema[]> extends Schema<Infer<T[number]>> {
    readonly options: T;
    constructor(options: T);
    protected copy(): this;
    acceptsUndefined(): boolean;
    parseAt(value: unknown, path: Path, ctx: ParseCtx): unknown;
    emitBody(refs: EmitRefs): JsonSchema | undefined;
}
export declare class OptionalSchema<I extends AnySchema> extends Schema<Infer<I> | undefined> {
    readonly inner: I;
    constructor(inner: I, description: string | undefined);
    protected copy(): this;
    acceptsUndefined(): boolean;
    parseAt(value: unknown, path: Path, ctx: ParseCtx): unknown;
    emitBody(refs: EmitRefs): JsonSchema | undefined;
}
export declare class NullableSchema<I extends AnySchema> extends Schema<Infer<I> | null> {
    readonly inner: I;
    constructor(inner: I, description: string | undefined);
    protected copy(): this;
    acceptsUndefined(): boolean;
    parseAt(value: unknown, path: Path, ctx: ParseCtx): unknown;
    emitBody(refs: EmitRefs): JsonSchema | undefined;
}
export declare class RefinedSchema<O> extends Schema<O> {
    readonly inner: Schema<O>;
    readonly check: (value: O) => boolean;
    readonly opts: {
        message: string;
        path?: Array<string | number>;
    };
    constructor(inner: Schema<O>, check: (value: O) => boolean, opts: {
        message: string;
        path?: Array<string | number>;
    });
    protected copy(): this;
    acceptsUndefined(): boolean;
    parseAt(value: unknown, path: Path, ctx: ParseCtx): unknown;
    emitBody(refs: EmitRefs): JsonSchema | undefined;
}
interface EmitRefs {
    currentPath: string[];
    propertyPath: string[] | undefined;
    seen: Map<AnySchema, string[]>;
}
/** The draft-07 JSON Schema a tool publishes for this schema. */
export declare function toJsonSchema(schema: AnySchema): JsonSchema;
export declare const z: {
    string: () => StringSchema;
    number: () => NumberSchema;
    boolean: () => BooleanSchema;
    null: () => NullSchema;
    unknown: () => UnknownSchema;
    literal: <L extends Literal>(value: L) => LiteralSchema<L>;
    enum: <const V extends string>(values: readonly [V, ...V[]]) => EnumSchema<V>;
    array: <I extends AnySchema>(item: I) => ArraySchema<I>;
    record: <V extends AnySchema>(_key: StringSchema, value: V) => RecordSchema<V>;
    union: <const T extends readonly [AnySchema, ...AnySchema[]]>(options: T) => UnionSchema<T>;
    object: <S extends RawShape>(shape: S) => ObjectSchema<S, "strip">;
};
export {};
//# sourceMappingURL=schema.d.ts.map