/** Default validity window for a round of questions — mirrors the challenge-token TTL policy. */ export declare const DEFAULT_MRTR_TTL_MS: number; /** A single field a question asks for (the restricted primitive schema elicitation allows). */ export interface AskField { type: "string" | "number" | "integer" | "boolean"; description?: string; /** Closed set of acceptable values — rendered as a picker by MRTR-aware clients. */ enum?: string[]; enumNames?: string[]; } /** One question to put to the human. `fields` become the elicitation's `requestedSchema`. */ export interface Ask { message: string; fields: Record; /** Which fields must come back. Default: all of them. */ required?: string[]; } /** The server→client requests of an `input_required` result (spec: `InputRequests`). */ export type InputRequests = Record; required: string[]; }; }; }>; /** The result that says "ask the human this, then call me again" (spec: `InputRequiredResult`). */ export interface InputRequiredResult { resultType: "input_required"; inputRequests: InputRequests; /** Opaque to the client: it MUST echo this back verbatim and MUST NOT parse it. */ requestState: string; } /** Why a presented `requestState` was refused — a typed union, never a bare string. */ export type MultiRoundTripRefusal = "tampered" | "expired" | "wrong-request" | "wrong-principal"; export interface OpenRoundArgs { /** What this state may be presented on — e.g. the tool name. */ request: string; /** The salient params a retry must repeat. Digested, never stored in the clear. */ params?: unknown; /** The authenticated principal (session id / user). Absent = not bound to one. */ principal?: string; /** `params.requestState` as the client echoed it back (absent on the first call). */ state?: unknown; /** `params.inputResponses` — the client's answers to the last round's questions. */ responses?: unknown; /** * Flat fallback for clients that do not implement MRTR yet: `{ size: "US 40" }`, gathered by * the agent instead of by the client's own elicitation UI. Filtered by the SAME allowlist — * a field this flow never asked for is dropped — but note the honesty caveat: these answers * are attested by the AGENT, not by the human. */ answers?: Record; /** Injectable clock (tests); defaults to `Date.now()`. */ now?: number; } /** An open round: what is known so far, and the door to ask for the rest. */ export type Round = { ok: true; /** Everything gathered so far — earlier rounds merged with this call's accepted answers. */ answers: Record; /** * Facts the SERVER sealed into the state on an earlier `ask()` (`carry`). Attested by the * signature, so — unlike `answers` — the client can neither set nor edit them. Use for * server-side context a later round needs back (e.g. the id of a record already created). */ carried: Record; /** Question keys the human declined or cancelled in THIS round. */ declined: string[]; /** How many times this flow has already asked (0 on the first call) — cap your own loops. */ round: number; /** Build the `input_required` result: these questions + a freshly sealed state. */ ask(requests: Record, opts?: AskOptions): InputRequiredResult; } | { ok: false; code: MultiRoundTripRefusal; }; export interface AskOptions { /** * Server-attested facts to seal into the new state, surfaced as `carried` next round. * Omitted = whatever was already carried rides forward unchanged. */ carry?: Record; } export interface MultiRoundTripOptions { /** * HMAC key the state is sealed with. On a multi-instance deployment this MUST be stable and * shared, or a state minted on one instance is refused (`tampered`) by the next. */ secret: string; /** How long a round of questions stays answerable. Default 15 minutes. */ ttlMs?: number; } /** * The MRTR engine: turns "I still need X" into a spec-shaped `input_required` result, and turns * a client's retry back into the answers gathered so far — with no server-side session. */ export declare class MultiRoundTrip { #private; constructor(opts: MultiRoundTripOptions); /** Open the round: verify any presented state, merge the new answers, expose `ask()`. */ open(args: OpenRoundArgs): Round; }