/** * Coercion of an agent-supplied `request_input` schema onto the flow contract. * * `request_input` used to cast whatever the agent passed straight into * `InputSchema`, so a choice gate could be persisted with option ids no host * could render — a run parked forever on a question no human could answer. * This module tolerates the shapes agents actually reach for (a bare string per * option, an option with a label and no id) and refuses the rest, because a * refusal the agent can read and retry beats a stored gate nobody can answer. * * Exported because hosts normalize the same payloads when they read a stored * gate; one shared rule is what keeps the write and read sides in agreement. */ import type { InputSchema } from "@skaile/workspaces/types"; /** * The shapes `request_input` accepts, phrased for an agent retrying a refused * call. Every optional key the contract admits is listed, because validation is * strict: an agent refused for one unknown key would otherwise read a key it * omitted here as illegal too. */ export declare const INPUT_SCHEMA_SHAPES_HINT = "{ kind: 'text', multiline? }, { kind: 'choice', options: [{ id, label, description? }], multiple? }, { kind: 'form', fields: [{ id, label, type: text|textarea|number|choice|file|date|boolean, required?, options?, accept? }] }, or { kind: 'file', accept?, maxSize?, multiple? }"; /** * Outcome of {@link coerceInputSchema}: either a schema in the contract shape, * or the reasons it was refused — one entry per problem, each naming its path, * closed by a final entry naming the accepted shapes. The hint travels with the * issues so every caller's refusal is actionable without re-appending it. */ export type InputSchemaCoercion = { ok: true; schema: InputSchema; } | { ok: false; issues: string[]; }; /** * Brings an untrusted `request_input` schema into the `InputSchema` contract. * * Tolerated: a JSON string wrapper, a choice option given as a bare string, and * an option or form field whose id is missing but whose label can supply one. * Refused: an unknown `kind`, an option or field that carries no usable label, a * duplicate explicit id, an id or label of the wrong type, and a choice or form * with nothing to answer — anything a host could not turn into an answerable * control. Options are never dropped: every unusable one produces an issue. * * @param value Raw `schema` argument as the agent supplied it. * @returns The contract-shaped schema, or the issues that make it unanswerable. */ export declare function coerceInputSchema(value: unknown): InputSchemaCoercion; //# sourceMappingURL=input-schema.d.ts.map