export interface Meta { description?: string; title?: string; /** What `check` says when this value is wrong. */ message?: string; } /** A JSON-Schema-shaped object; `T` is the TypeScript type of the values it accepts (never present at run time). */ export interface Schema extends Meta { readonly "~type": T; type?: "string" | "number" | "integer" | "boolean" | "null" | "array" | "object"; const?: string | number | boolean; enum?: string[]; anyOf?: Schema[]; items?: Schema; properties?: Record; required?: string[]; additionalProperties?: Schema; minLength?: number; maxLength?: number; pattern?: string; minimum?: number; maximum?: number; minItems?: number; maxItems?: number; /** M76: `check` passes any value (no check today: a bad one is dropped where it is read). */ "x-loose"?: true; /** M76: the limits apply to the value trimmed (the daemon trims it first). */ "x-trim"?: true; /** M76: maxLength is not refused here: the daemon cuts the value ("cut"), or the op refuses it with its own code ("op"). */ "x-max"?: "cut" | "op"; /** M76: a union picked by this field alone; another value fails with the union's message. */ "x-discriminant"?: string; /** M77: `check` asks only that the value be an object (an array too); its fields are the op's to check. */ "x-shallow"?: true; } export type Infer = S extends Schema ? T : never; declare const OPTIONAL: unique symbol; /** A field that may be left out (see `optional`). */ export interface OptionalField { readonly [OPTIONAL]: true; readonly schema: S; } type Field = Schema | OptionalField; type Fields = Record; type Plain = F extends OptionalField ? S : F; type Flat = { [K in keyof T]: T[K]; } & {}; type ObjectOf

= Flat<{ [K in keyof P as P[K] extends OptionalField ? never : K]: Infer>; } & { [K in keyof P as P[K] extends OptionalField ? K : never]?: Infer>; }>; export declare const str: (o?: Meta & { min?: number; max?: number; pattern?: string; trim?: boolean; maxBy?: "cut" | "op"; }) => Schema; export declare const num: (o?: Meta & { int?: boolean; min?: number; max?: number; }) => Schema; export declare const bool: (o?: Meta) => Schema; export declare const nul: (o?: Meta) => Schema; export declare const literal: (v: V, o?: Meta) => Schema; /** A string that is one of these. */ export declare const oneOf: (values: readonly V[], o?: Meta) => Schema; /** Plain, or discriminated by a literal field (`check` then reports the matching member's error). */ export declare const union: (members: M, o?: Meta & { discriminant?: string; }) => Schema>; /** M76: the same schema (its type, its doc), not checked: a bad value is dropped where the daemon reads it. */ export declare const loose: (s: S) => S; /** The schema a loose (or shallow, or relaxed) one was made from (the doc names a shared shape by it). */ export declare const looseOf: WeakMap, Schema>; /** M77: the same schema, checked only for being an object (an array passes, as `typeof` let it), in these words. */ export declare const shallow: (s: S, o?: Meta) => S; /** M77: an object schema whose fields are loose, but a literal one (a union's discriminant) and those given in `keep` (in their place). */ export declare const relax: (s: S, keep?: Record, o?: Meta) => S; /** M77: a schema as plain JSON Schema for a tool's parameters: without `message` and the `x-` marks; a maximum the daemon cuts is left out. */ export declare function jsonSchemaOf(s: Schema): Record; export declare const nullable: (s: S, o?: Meta) => Schema | null>; export declare const arr: (item: S, o?: Meta & { min?: number; max?: number; }) => Schema[]>; /** A string-keyed record. */ export declare const rec: (value: S, o?: Meta) => Schema>>; export declare const optional: (schema: S) => OptionalField; export declare const obj:

(fields: P, o?: Meta) => Schema>; /** An object with no fields (`Record`); like `obj({})` to `check`: other keys are ignored. */ export declare const empty: (o?: Meta) => Schema>; /** A type another module owns (its interface stays there): checked only as an object. */ export declare const opaque: (title: string, description: string) => Schema; /** Anything. */ export declare const unknown: (o?: Meta) => Schema; export type CheckResult = { ok: true; } | { ok: false; path: string; message: string; }; /** Whether `value` is what `schema` says; the first failure's path ("launch.env", "ids[2]") and message. Unknown fields are ignored. */ export declare function check(schema: Schema, value: unknown, path?: string): CheckResult; /** The values a discriminated union's members take on `key`, in their order. */ export declare function discriminantValues(union: Schema, key: string): string[]; export {};