import { T as ToolHost } from '../tool-host-BBSaU7IJ.cjs'; import { B as Bridge } from '../types-D_H2f-wF.cjs'; import '../types-ITRQFAir.cjs'; /** * Field descriptor — what the host says about each form field. Mirrors the * subset of HTML / react-fancy input shapes agents care about. */ type FormFieldDescriptor = { /** Form-local field name. Matches the key the host uses in its values map. */ name: string; /** Display label. */ label?: string; /** Logical type. Drives validation + agent expectations. */ type: "text" | "textarea" | "number" | "email" | "password" | "url" | "date" | "select" | "multi-select" | "checkbox" | "switch" | "radio" | "file" | "json"; /** Allowed values for select / radio. */ options?: Array<{ value: string; label: string; }>; /** Whether the field must be filled before submit. */ required?: boolean; /** Free-text hint surfaced to the agent. */ description?: string; /** Default value (presented in get_value when nothing set). */ defaultValue?: unknown; }; /** * Adapter the host wires per form. Matches the controlled-state pattern * react-fancy already uses (`value` / `onValueChange`); this adapter just * exposes those state slots in a form-shaped way the bridge can call. */ type FormBridgeAdapter = { /** Stable id for the form (used in form_describe + presence target). */ id: string; /** Display title for human-readable logs. */ title?: string; /** Optional fancy-screens screen id this form belongs to. */ screenId?: string; /** Field descriptors. The bridge uses these for schema introspection * (form_describe). Agents call this first to know what to fill. */ getFields: () => FormFieldDescriptor[]; /** Read a single field's current value. */ getValue: (name: string) => unknown; /** Read all values as { fieldName: value }. */ getValues: () => Record; /** Set a single field's value. The host wires this to its setState. */ setValue: (name: string, value: unknown) => void; /** Set many at once. Defaults to calling setValue in a loop. */ setValues?: (values: Record) => void; /** Programmatically focus a field (host implements DOM focus). Optional. */ focus?: (name: string) => void; /** Submit the form. Returns the values that were submitted (or rejection). */ submit?: () => Promise<{ ok: boolean; values?: Record; error?: string; }>; /** * Human confirm gate for `form_submit` (trust-but-verify). When `pendingMode` * is on, the bridge calls this before submitting; return false to decline. * Wire it to a human control — submitting a form is a human-visible, * often-destructive action (checkout, delete, invite). */ confirm?: (request: FormConfirmRequest) => Promise | boolean; }; /** What a `form_submit` confirm gate is asked to approve. */ type FormConfirmRequest = { action: "submit"; form: string; title?: string; values: Record; }; type FormBridgeOptions = { adapter: FormBridgeAdapter; /** Identity tagged into activity events. */ agent?: { id: string; name?: string; color?: string; }; /** * Stage `form_submit` for human confirmation via `adapter.confirm` instead of * submitting immediately. **Default: ON** (matches the navigation bridge and * the Human+ trust-but-verify contract). Set false only when auto-submit is * safe. If on without an `adapter.confirm`, submit proceeds (nothing to gate). */ pendingMode?: boolean; }; /** * registerFormBridge — wires schema-driven MCP access to a single form. * Hosts can register multiple bridges (one per form on the screen) by * giving each adapter a distinct `id`. */ declare function registerFormBridge(host: ToolHost, options: FormBridgeOptions): Bridge; export { type FormBridgeAdapter, type FormBridgeOptions, type FormConfirmRequest, type FormFieldDescriptor, registerFormBridge };