import type { RenderInterfacePayload } from './protocol.js'; export type StateValue = string | number | boolean; /** A prop value that is either a literal or a live reference to a state key. */ export type ValueRef = T | { $state: string; }; /** An action embedded in a Button / Table row — carried OPAQUELY through the * projection (stuffed into the A2UI event context verbatim, restored on the * way back). The app narrows it to its full AgentAction union; hosts treat it * as data to hand back, never to interpret. */ export interface EmbeddedAction { type: string; } export type GenuiTextTone = 'default' | 'muted' | 'strong'; export type GenuiButtonVariant = 'primary' | 'secondary' | 'ghost' | 'danger'; export type GenuiProgressVariant = 'default' | 'affection' | 'energy' | 'health' | 'tier'; export interface GenuiTextNode { type: 'Text'; text?: string; /** Template with `{key}` placeholders resolved against interface state. */ template?: string; tone?: GenuiTextTone; } export interface GenuiButtonNode { type: 'Button'; label: string; variant?: GenuiButtonVariant; action: EmbeddedAction | null; } export interface GenuiProgressNode { type: 'Progress'; value: ValueRef; max?: number; variant?: GenuiProgressVariant; } export interface GenuiIconNode { type: 'Icon'; name: string; size?: number; } export interface GenuiSliderNode { type: 'Slider'; bind: string; min?: number; max?: number; step?: number; label?: string; } export interface GenuiSwitchNode { type: 'Switch'; bind: string; label?: string; } export interface GenuiSelectOption { value: string; label: string; } export interface GenuiSelectNode { type: 'Select'; bind: string; options: GenuiSelectOption[]; placeholder?: string; } export interface GenuiTextInputNode { type: 'TextInput'; bind: string; label?: string; placeholder?: string; multiline?: boolean; maxLength?: number; } export type GenuiGroupDirection = 'row' | 'column'; export interface GenuiGroupNode { type: 'Group'; direction: GenuiGroupDirection; gap?: number; wrap?: boolean; children: GenuiNode[]; } export interface GenuiImageNode { type: 'Image'; src: string; alt?: string; ratio?: number; } export interface GenuiVideoNode { type: 'Video'; src: string; ratio?: number; } export interface GenuiAudioNode { type: 'AudioPlayer'; src: string; title?: string; } export interface GenuiMarkdownNode { type: 'Markdown'; text: string; } export type GenuiChartKind = 'bar' | 'line' | 'area' | 'pie' | 'donut'; export interface GenuiChartDatum { label?: string; value: number; } export interface GenuiChartNode { type: 'Chart'; chart: GenuiChartKind; data: GenuiChartDatum[]; max?: number; title?: string; } export interface GenuiTableNode { type: 'Table'; columns: string[]; rows: string[][]; title?: string; rowActions?: (EmbeddedAction | null)[]; } export interface GenuiDatePickerNode { type: 'DatePicker'; bind: string; label?: string; min?: string; max?: string; } export interface GenuiWhen { key: string; equals?: StateValue; truthy?: boolean; } export interface GenuiTab { label: string; children: GenuiNode[]; } export interface GenuiTabsNode { type: 'Tabs'; tabs: GenuiTab[]; bind?: string; } export interface GenuiAccordionSection { label: string; children: GenuiNode[]; open?: boolean; } export interface GenuiAccordionNode { type: 'Accordion'; sections: GenuiAccordionSection[]; multi?: boolean; } export interface GenuiDividerNode { type: 'Divider'; } export interface GenuiCardNode { type: 'Card'; title?: string; children: GenuiNode[]; } export type GenuiNode = (GenuiTextNode | GenuiButtonNode | GenuiProgressNode | GenuiIconNode | GenuiSliderNode | GenuiSwitchNode | GenuiSelectNode | GenuiTextInputNode | GenuiGroupNode | GenuiImageNode | GenuiChartNode | GenuiTableNode | GenuiDatePickerNode | GenuiTabsNode | GenuiAccordionNode | GenuiDividerNode | GenuiCardNode | GenuiVideoNode | GenuiAudioNode | GenuiMarkdownNode) & { when?: GenuiWhen; }; export interface GenuiComputed { op: 'mul' | 'add' | 'sub' | 'div'; args: (string | number)[]; round?: number; } /** The Instant UI panel — what `companion.ui_action` carries in * `payload.interface` (typed strictly here; the event payload declares the * loose wire shape). */ export interface DynamicInterface { title?: string; nodes: GenuiNode[]; state?: Record; computed?: Record; reportChanges?: boolean; allowedActions?: string[]; } /** What `toA2UI` accepts: the strict panel type, or the loose * `payload.interface` exactly as `onRender` delivers it (already validated * and clamped server-side, so the structural cast inside is safe). */ export type InstantUIInput = DynamicInterface | RenderInterfacePayload['interface']; /** The Instant UI node-type catalog, as data — drift-pinned against the app's * canonical GENUI_NODE_SET so the mirror can never silently lag a new atom. */ export declare const INSTANT_UI_NODE_TYPES: readonly ["Text", "Button", "Progress", "Icon", "Slider", "Switch", "Select", "TextInput", "Group", "Image", "Chart", "Table", "DatePicker", "Tabs", "Accordion", "Divider", "Card", "Video", "AudioPlayer", "Markdown"]; /** A2UI binding: a literal, a JSON-Pointer data binding, or a function call. */ export type A2UIValue = StateValue | { path: string; } | { call: string; args?: unknown; }; export interface A2UIComponent { id: string; /** A2UI component type, e.g. "Text" / "Button" / "Row" / "pouchy/Progress". */ component: string; /** Standard A2UI property bag (component-specific; see the mapping per type). */ [key: string]: unknown; /** Pouchy-only reconstruction data for concepts A2UI has no standard for. * A2UI renderers ignore it; fromA2UI() uses it to rebuild the exact node. */ _pouchy?: Record; } /** An A2UI surface = a flat component map + a root id + the data model. The * `pouchy` block carries panel-level extensions A2UI has no slot for. */ export interface A2UISurface { root: string; components: Record; dataModel: Record; pouchy?: { title?: string; computed?: Record; reportChanges?: boolean; allowedActions?: string[]; }; } export declare function toA2UI(input: InstantUIInput): A2UISurface; export declare function fromA2UI(surface: A2UISurface): DynamicInterface; //# sourceMappingURL=a2ui.d.ts.map