UNPKG

@adonis-agora/agent

Version:

Governed, durable-backed AI agent (chat + tool-calling + governance) for AdonisJS — part of the Agora ecosystem.

69 lines • 4.06 kB
/** * Typed answers for a question set: a question that asks for a number, a date, an email or a * sentence instead of offering options to pick. * * Answers stay `string[]` on the wire whatever the type — the signal that carries them, the row that * records them and the model that reads them back all see strings — so this module fixes ONE * canonical string per type and validates against it: * * | `type` | canonical value | * |------------|----------------------------------------------| * | `text` | the text | * | `textarea` | the text (newlines kept) | * | `number` | a finite decimal, e.g. `"42"`, `"-1.5"` | * | `boolean` | `"true"` or `"false"` | * | `date` | `YYYY-MM-DD` | * | `email` | an address with one `@` and a dotted domain | * | `url` | an absolute `http:`/`https:` URL | * | `select` | one of the question's `options[].value` | * * Pure and dependency-free, so the loop (which filters what it settles on), the HTTP surface (which * refuses what it cannot settle) and a client (which says so before sending) all agree. */ import type { ElicitationOption, ElicitationQuestion } from './elicitation.js'; export declare const ELICITATION_INPUT_TYPES: readonly ['text', 'textarea', 'number', 'boolean', 'date', 'email', 'url', 'select']; export type ElicitationInputType = (typeof ELICITATION_INPUT_TYPES)[number]; /** How a question takes its answer when it is not (only) a pick from `options`. */ export interface ElicitationInput { type: ElicitationInputType; /** Hint shown in an empty field. Advisory. */ placeholder?: string; /** Submitting without a value is refused. Skipping the whole set is still allowed. */ required?: boolean; /** * Lower bound: the smallest number for `number`, the shortest length for `text`/`textarea`, the * earliest `YYYY-MM-DD` for `date`. Ignored for the other types. */ min?: number | string; /** Upper bound, read like {@link min}. */ max?: number | string; /** A regular expression the WHOLE value must match (`text`, `textarea`, `email`, `url`). */ pattern?: string; } /** The question's options, or none — `options` may be omitted on a typed question. */ export declare function questionOptions(question: ElicitationQuestion): ElicitationOption[]; /** A question answered by a typed value rather than by picking one of its options. */ export declare function isTypedQuestion(question: ElicitationQuestion): boolean; /** * Why `value` is not an acceptable answer to `question`, or `null` when it is. Checks ONE value; * {@link validateElicitationAnswer} checks the list (required, single choice). */ export declare function validateElicitationValue(question: ElicitationQuestion, value: string): string | null; /** * Why `values` is not an acceptable answer to `question`, or `null` when it is: a `required` * question left empty, more than one value for a single-choice question, or any value * {@link validateElicitationValue} refuses. An empty string counts as no value. */ export declare function validateElicitationAnswer(question: ElicitationQuestion, values: readonly string[]): string | null; /** * Read an {@link ElicitationInput} from untrusted JSON, or `undefined` when it is not one. Unknown * keys are dropped; a malformed optional field is dropped rather than failing the input. */ export declare function readElicitationInput(raw: unknown): ElicitationInput | undefined; /** * The questions a parked call carries, read leniently from its recorded input (`{ questions }` — * what both an intake and an `ask` persist). Used where a reply is checked against the questions it * answers; a question that cannot be read is left out rather than failing the rest. */ export declare function readElicitationQuestions(input: unknown): ElicitationQuestion[]; //# sourceMappingURL=elicitation-input.d.ts.map