/** * Flow layer — questionnaire foundation (pure; no host/PI/network). * * The framework owns the "how to ask" contract: an annotated TypeBox target schema is the single * source of truth for asking, rendering, and validating structured user input. * * - {@link QuestionnaireSchema} is the canonical ask/block payload (a BATCH of questions). * - {@link questionnaireFromSchema} derives that batch from an annotated target `Type.Object`. * - {@link buildAskingProtocol} produces the prompt text injected into an agent so authors never * repeat the protocol. * - {@link validateAnswers} validates collected answers against the target schema. * * ## Annotation vocabulary (arbitrary TypeBox metadata on the target schema) * Standard JSON-Schema metadata: * - `title` → a field's `header` (and a nested object's `section` label; an option's `label`). * - `description` → a field's `question` text (and a literal option's `description`). * - `default` → on a single-choice field, marks the matching option `recommended`. * Framework metadata (pass through a schema's options object): * - `allowOther?: boolean` → the question permits a free-form "other" answer. * - `chat?: boolean` → render a free-form chat input (`kind: "chat"`) instead of text. * - `recommended?: boolean` → on a literal member, marks that option `recommended`. */ import { type Static, type TSchema, Type } from "typebox"; /** A selectable option for a single/multi question. */ export declare const QuestionOptionSchema: Type.TObject<{ value: Type.TString; label: Type.TString; description: Type.TOptional; recommended: Type.TOptional; }>; export type QuestionOption = Static; /** How a question is answered (spec §2.4/§10). */ export declare const QuestionKindSchema: Type.TUnion<[Type.TLiteral<"single">, Type.TLiteral<"multi">, Type.TLiteral<"text">, Type.TLiteral<"chat">]>; export type QuestionKind = Static; /** One question in a questionnaire batch. `key` addresses the answer field on the target schema. */ export declare const QuestionSchema: Type.TObject<{ key: Type.TString; header: Type.TString; question: Type.TString; kind: Type.TUnion<[Type.TLiteral<"single">, Type.TLiteral<"multi">, Type.TLiteral<"text">, Type.TLiteral<"chat">]>; options: Type.TOptional; recommended: Type.TOptional; }>>>; allowOther: Type.TOptional; section: Type.TOptional; }>; export type Question = Static; /** The canonical ask/block payload: a batch of questions with an optional title (mirrors AskUserQuestion). */ export declare const QuestionnaireSchema: Type.TObject<{ title: Type.TOptional; questions: Type.TArray, Type.TLiteral<"multi">, Type.TLiteral<"text">, Type.TLiteral<"chat">]>; options: Type.TOptional; recommended: Type.TOptional; }>>>; allowOther: Type.TOptional; section: Type.TOptional; }>>; }>; export type Questionnaire = Static; /** Result of validating collected answers against the target schema. */ export type AnswersCheck = { ok: true; } | { ok: false; violation: string; }; /** * Derive a {@link Questionnaire} batch from an annotated target `Type.Object` schema (pure). See the * module header for the annotation vocabulary and the construct → question mapping. */ export declare function questionnaireFromSchema(outputSchema: TSchema): Questionnaire; /** * The output contract appended to every non-`asks` agent step's fresh prompt (pure). The engine validates * the submitted payload against this schema regardless, so stating it is not decoration — it is the * difference between a model that knows the shape and one that has to guess it. Kept next to * {@link buildAskingProtocol} because the two are the same idea. */ export declare function buildOutputProtocol(outputSchema: TSchema): string; /** * The protocol text injected into an `asks` agent step's prompt (pure). Tells the model to ask by calling * `submit_questions` (batching them) and to finish by calling `submit_result`, embedding both the * {@link QuestionnaireSchema} and the target output schema (TypeBox schemas *are* JSON Schema). */ export declare function buildAskingProtocol(outputSchema: TSchema): string; /** Validate collected answers against the target schema (reuses `describeSchemaViolations`). */ export declare function validateAnswers(outputSchema: TSchema, answers: unknown): AnswersCheck; /** * Reassemble a flat `{ questionKey → value }` answers map into the target schema's shape (pure). * Top-level fields map directly by name; a nested `Type.Object` field pulls its sub-fields by the * dotted `"${parentKey}.${subKey}"` path that {@link questionnaireFromSchema} assigns — so two * sections that share a leaf name never collide. */ export declare function answersToOutput(outputSchema: TSchema, answers: Record): Record; /** * Render collected answers as a short message to feed back into an agent's loop (spec §8.4). * * This is the LAST instruction the model reads before it responds, so it must name the same channel the * engine reads — a resumed step told to reply in text submits nothing and fails. */ export declare function formatAnswers(answers: Record): string; //# sourceMappingURL=questionnaire.d.ts.map