@hanzo/ui

Protocol

import { A2UI_BUILTIN_FUNCTIONS, A2UI_PROTOCOL_VERSION, HANZO_A2UI_CATALOG_ID, STANDARD_A2UI_CATALOG_IDS, applyA2UIMessages, decodeV09DataContents, deletePointer, escapePointerSegment, extractA2UIBlocks, extractBindingPath, getPointer, isA2UIMessage, isSafeImageUrl, isSafePointer, isSafePointerSegment, joinPointer, normalizeComponent, parseA2UI, parsePointer, resolveA2UIAction, resolveBoolean, resolveNumber, resolveString, resolveValue, setPointer, unescapePointerSegment, validateChecks, validateSurface } from '@hanzo/ui/a2ui'

No examples yet.

Types

export interface A2UIPathBinding {
  '@path'?: string
  path?: string
  literalString?: string
  literalNumber?: number
  literalBoolean?: boolean
  literalArray?: unknown[]
  literal?: unknown
}
export interface A2UICallSpec {
  name: string
  args?: unknown[] | Record<string, unknown>
}
export interface A2UICallBinding {
  '@call'?: A2UICallSpec
  call?: string
  args?: unknown[] | Record<string, unknown>
}
export type A2UIBinding<T = unknown> =
  | T
  | A2UIPathBinding
  | A2UICallBinding
export interface A2UICheck {
  /** Validation rule name (`required`, `minLength`, `maxLength`, `regex`, `min`, `max`, `email`). */
  call?: string
  rule?: string
  type?: string
  /** Optional arguments or parameters for the rule. */
  args?: Record<string, unknown> | unknown[]
  value?: unknown
  min?: number
  max?: number
  pattern?: string
  /** Human-readable error message shown when check fails. */
  message?: string
}
export interface A2UIComponentInput {
  id: string
  component: string | Record<string, Record<string, unknown>>
  weight?: number
  checks?: A2UICheck[]
  [key: string]: unknown
}
export interface A2UIComponentNode {
  id: string
  type: string
  props: Record<string, unknown>
  weight?: number
  checks?: A2UICheck[]
}
export interface A2UIActionContextEntry {
  key: string
  value: unknown
}
export interface A2UIActionEventSpec {
  name: string
  context?: Record<string, unknown> | A2UIActionContextEntry[]
}
export interface A2UIAction {
  /** A2UI v1.0 nested event envelope. */
  event?: A2UIActionEventSpec
  /** A2UI v0.9 / shorthand flat action. */
  name?: string
  context?: Record<string, unknown> | A2UIActionContextEntry[]
  /** Skip form check validation before firing (e.g. Cancel/Back buttons). */
  skipValidation?: boolean
}
export interface A2UIActionEvent {
  surfaceId: string
  name: string
  context: Record<string, unknown>
  timestamp: string
  sourceComponentId?: string
  /** Included ONLY when the surface explicitly sets `sendDataModel: true`. */
  dataModel?: Record<string, unknown>
}
export interface A2UICreateSurfacePayload {
  surfaceId: string
  catalogId?: string
  theme?: Record<string, unknown>
  sendDataModel?: boolean
  root?: string
  components?: A2UIComponentInput[]
  dataModel?: Record<string, unknown>
}
export interface A2UIUpdateComponentsPayload {
  surfaceId: string
  components: A2UIComponentInput[]
}
export interface A2UIUpdateDataModelPayload {
  surfaceId: string
  path?: string
  value?: unknown
  op?: 'replace' | 'add' | 'remove'
}
export interface A2UIDeleteSurfacePayload {
  surfaceId: string
}
export interface A2UIV09DataEntry {
  key: string
  valueString?: string
  valueNumber?: number
  valueBoolean?: boolean
  valueMap?: A2UIV09DataEntry[]
  valueList?: unknown[]
  value?: unknown
}
export interface A2UIV09SurfaceUpdatePayload {
  surfaceId: string
  components: A2UIComponentInput[]
}
export interface A2UIV09DataModelUpdatePayload {
  surfaceId: string
  path?: string
  contents?: A2UIV09DataEntry[] | Record<string, unknown>
  value?: unknown
}
export interface A2UIV09BeginRenderingPayload {
  surfaceId: string
  root: string
  catalogId?: string
  styles?: Record<string, unknown>
}
export interface A2UIMessage {
  version?: string
  // v1.0
  createSurface?: A2UICreateSurfacePayload
  updateComponents?: A2UIUpdateComponentsPayload
  updateDataModel?: A2UIUpdateDataModelPayload
  deleteSurface?: A2UIDeleteSurfacePayload
  // v0.8 / v0.9 compat
  surfaceUpdate?: A2UIV09SurfaceUpdatePayload
  dataModelUpdate?: A2UIV09DataModelUpdatePayload
  beginRendering?: A2UIV09BeginRenderingPayload
}
export interface A2UISurfaceState {
  surfaceId: string
  version: string
  catalogId: string
  rootId: string | null
  theme?: Record<string, unknown>
  sendDataModel: boolean
  components: Record<string, A2UIComponentNode>
  componentOrder: string[]
  dataModel: Record<string, unknown>
}
export type A2UISegment =
  | { type: 'markdown'; content: string }
  | { type: 'a2ui'; raw: string; surfaces: A2UISurfaceState[] }
export interface A2UIValidationResult {
  valid: boolean
  errors: string[]
}

Exports

A2UI_BUILTIN_FUNCTIONSA2UI_PROTOCOL_VERSIONHANZO_A2UI_CATALOG_IDSTANDARD_A2UI_CATALOG_IDSapplyA2UIMessagesdecodeV09DataContentsdeletePointerescapePointerSegmentextractA2UIBlocksextractBindingPathgetPointerisA2UIMessageisSafeImageUrlisSafePointerisSafePointerSegmentjoinPointernormalizeComponentparseA2UIparsePointerresolveA2UIActionresolveBooleanresolveNumberresolveStringresolveValuesetPointerunescapePointerSegmentvalidateChecksvalidateSurfacetype A2UIActiontype A2UIActionContextEntrytype A2UIActionEventtype A2UIActionEventSpectype A2UIBindingtype A2UICallBindingtype A2UICallSpectype A2UIChecktype A2UIComponentInputtype A2UIComponentNodetype A2UICreateSurfacePayloadtype A2UIDeleteSurfacePayloadtype A2UIMessagetype A2UIPathBindingtype A2UISegmenttype A2UISurfaceStatetype A2UIUpdateComponentsPayloadtype A2UIUpdateDataModelPayloadtype A2UIV09BeginRenderingPayloadtype A2UIV09DataEntrytype A2UIV09DataModelUpdatePayloadtype A2UIV09SurfaceUpdatePayloadtype A2UIValidationResult