//#region src/ir.d.ts /** * The generative-ui intermediate representation: a model-emitted, cross-platform * UI tree. React-free, so converters and non-web runtimes consume it without * pulling React. The flat `$type` shape is the canonical form; the legacy * `component` shape is accepted as a backward-compatible alias. * * Reserved keys are partitioned off from component props so the component prop * namespace stays fully free: * * - `$`-prefixed keys are framework-reserved (`$type`, `$key`, `$action`, * `$status`). Components never declare `$`-prefixed props, so a component * can use `type`, `status`, `variant`, etc. as ordinary props without * colliding with the framework. * - `children` is additionally reserved (the JSX convention). * - every other key is an inline prop passed straight to the component. */ export declare const TEXT_SIZES: readonly ["sm", "md", "lg", "xl", "2xl", "3xl"]; export type TextSize = (typeof TEXT_SIZES)[number]; export declare const IMAGE_SIZE_TOKENS: readonly ["sm", "md", "lg"]; export type ImageSize = (typeof IMAGE_SIZE_TOKENS)[number] | number; export declare const WEIGHTS: readonly ["normal", "medium", "semibold", "bold"]; export type Weight = (typeof WEIGHTS)[number]; export declare const COLORS: readonly ["emphasis", "secondary", "alpha-70", "white", "white-70", "white-50"]; export type Color = (typeof COLORS)[number]; export declare const ALIGNS: readonly ["start", "center", "end"]; export type Align = (typeof ALIGNS)[number]; export declare const JUSTIFIES: readonly ["start", "center", "end", "between"]; export type Justify = (typeof JUSTIFIES)[number]; export declare const BUTTON_STYLES: readonly ["primary", "secondary", "outline", "ghost", "danger"]; export type ButtonStyle = (typeof BUTTON_STYLES)[number]; export declare const ALERT_TONES: readonly ["info", "success", "warning", "danger"]; /** A severity level, from informational to destructive. */ export type AlertTone = (typeof ALERT_TONES)[number]; export declare const ICON_NAMES: readonly ["sun", "moon", "cloud", "rain", "snow", "wind", "play", "pause", "check", "x", "star", "heart", "arrow-right", "arrow-up-right", "chevron-right", "calendar", "clock", "map-pin", "plane", "truck", "credit-card", "user", "search", "bell"]; /** A name from the built-in icon set; the closed enum lets the model see exactly which icons exist. */ export type IconName = (typeof ICON_NAMES)[number]; /** * Behavior payload carried by an interactive node. `type` is resolved by the host's action registry, not the renderer; keeping behavior as data keeps the tree serializable, so the same node renders on web while converters may bind the type to a native action id on other platforms. */ export interface Action { readonly type: string; readonly [payload: string]: unknown; } /** * Anything renderable as generative UI, as the model emits it. The renderer * also accepts `number`, `boolean`, `null`, `undefined`, and arrays at the * input boundary (numbers render as text, falsy/boolean as nothing, arrays as * lists); {@link normalizeUINode} accepts that full range. */ export type UINode = string | number | UIElement | LegacyComponentNode; export type UIChildren = UINode | readonly UINode[]; /** The flat node shape: inline props keep the tree compact and natural for a * model to emit, instead of a nested `{ type, props }` bag. Reserved keys are * stripped before props reach the component (see the module header). */ export interface UIElement { readonly $type: string; readonly $key?: string | number; readonly children?: UIChildren; readonly $action?: Action; readonly [prop: string]: unknown; } /** * The legacy node shape: a `component` name plus a nested `props` bag. Kept * for backward compatibility. New code authors the flat {@link UIElement} * shape instead. */ export interface LegacyComponentNode { readonly component: string; readonly props?: Record; readonly children?: UIChildren; readonly key?: string; } export type UISpec = UINode | readonly UINode[]; /** * A node normalized to a single canonical shape: a `type` string, an inline * `props` bag, recursive `children`, an optional `key`, and an optional * `action`. Renderers and platform converters consume this form, so they never * branch on whether the model emitted the flat `$type` shape or the legacy * `component` shape, and they never see the reserved `$`-prefixed keys leak * into component props. */ export interface NormalizedUIElement { readonly type: string; readonly props: Readonly>; readonly children?: NormalizedUINode | undefined; readonly key?: string | number | undefined; readonly action?: Action | undefined; } export type NormalizedUINode = string | number | readonly NormalizedUINode[] | NormalizedUIElement | null; /** * Normalizes a generative-ui input to {@link NormalizedUINode}. The flat * `$type` shape and the legacy `component` shape both map to the same canonical * element, with reserved keys (`$type`, `$key`, `$action`, `children`) stripped * from the prop bag. A node that carries neither a `$type` nor a `component` * string is not renderable and resolves to `null` rather than throwing, so a * partially-streamed or malformed node degrades to "render nothing". * * `partialPath` carries streaming state from the tool-args parse meta: a node * whose `$type` is still mid-arrival is held back (resolves to `null`) until it * completes, and the path is threaded into `children` so a nested streaming * node is held back while completed siblings render. Omit it for a * non-streaming (converter) normalize. */ export declare function normalizeUINode(node: unknown, partialPath?: readonly string[] | undefined, depth?: number): NormalizedUINode; /** * Normalizes the root of a {@link UISpec}, preserving whether the root was a * single node or a list. */ export declare function normalizeSpec(spec: UISpec): { readonly root: NormalizedUINode | readonly NormalizedUINode[]; }; //#endregion //# sourceMappingURL=ir.d.ts.map