@ainative/ai-kit-a2ui-core

February 18, 2026 ยท View on GitHub

Framework-agnostic core library for A2UI protocol (v0.9-v0.11) with zero runtime dependencies.

npm version License: MIT TypeScript Test Coverage Build Status

A production-ready, framework-agnostic implementation of the A2UI protocol that enables AI agents to dynamically generate rich user interfaces using declarative JSON. Includes LLM Runtime for OpenAI/Anthropic, React bindings with CoAgent bidirectional sync, Chrome Inspector, video protocol extension (v0.10), and AI intelligence features (v0.11).

๐Ÿš€ Features

Core Protocol (v0.9)

  • ๐ŸŽฏ Zero Dependencies - Pure TypeScript with no runtime dependencies (< 20 KB gzipped)
  • ๐Ÿ“ JSON Pointer (RFC 6901) - Complete implementation with get/set/remove/has operations
  • ๐Ÿ”Œ WebSocket Transport - Framework-agnostic agent communication with automatic reconnection
  • ๐Ÿ“ Protocol Types - Complete TypeScript definitions for A2UI v0.9 specification
  • ๐Ÿ—‚๏ธ Component Registry - Extensible catalog of 21 standard components
  • ๐Ÿ›ก๏ธ 100% Type Safe - Built with TypeScript strict mode
  • โœ… 96.52% Test Coverage - Comprehensive test suite with 429/429 tests passing
  • ๐Ÿ“ฆ Multi-Format - ESM, CJS, and TypeScript definitions included
  • ๐Ÿ”„ Event-Driven - Type-safe event emitter for agent messages

Video Protocol Extension (v0.10)

  • ๐ŸŽฅ Video Components - 4 video component types (videoRecorder, videoCall, aiVideo, aiVideoPlayer)
  • ๐Ÿ“น Video Messages - 9 video message types for recording, calls, and generation
  • ๐Ÿ”— AIKit Integration - Seamless integration with AINative Studio video services
  • โœ… Complete Validation - JSON Schema validation for all video components

AI Intelligence Features (v0.11)

  • ๐Ÿ” Semantic Search - Vector-based video search with pgvector embeddings
  • ๐Ÿค– AI Metadata - Automatic extraction of transcripts, summaries, topics, highlights, chapters, sentiment
  • โฏ๏ธ Progress Tracking - Cross-device progress sync with scene-aware resume
  • ๐Ÿ’ก Smart Recommendations - Hybrid recommendation engine (content + collaborative + contextual AI)

LLM Runtime (@ainative/a2ui-runtime) - NEW โœจ

  • ๐Ÿค– OpenAI Adapter - Generate UI from OpenAI models (GPT-4, GPT-3.5) with 93.10% test coverage
  • ๐Ÿง  Anthropic Adapter - Generate UI from Claude models with 96.15% test coverage
  • โš™๏ธ Middleware Pipeline - Auth, rate limiting, logging, validation middleware
  • ๐Ÿ”„ Streaming Support - Real-time UI generation with streaming responses
  • ๐ŸŽฏ Action Execution - Execute user actions and handle agent responses
  • โœ… 100% Runtime Coverage - 43 comprehensive tests covering all scenarios

React Bindings (@ainative/a2ui-react) - ENHANCED ๐ŸŽฏ

  • ๐Ÿ”„ CoAgent Hook - Bidirectional state sync between client and agent with conflict resolution
  • ๐Ÿ“ก A2UI Provider - React context for WebSocket transport and surface management
  • ๐Ÿช useA2UIState - Hook for accessing data model via JSON pointers with auto-updates
  • โšก useA2UIAction - Hook for executing user actions and sending to agent
  • ๐Ÿ”ง 3-Way Merge - Intelligent conflict resolution (client-wins, agent-wins, last-write-wins)
  • โ™ป๏ธ Auto-Retry - Exponential backoff retry logic for transient errors
  • โœ… All Tests Passing - Fixed 7 critical bugs in useCoAgent hook

Chrome Inspector (@ainative/a2ui-inspector) - OPTIMIZED ๐Ÿš€

  • ๐Ÿ” Message Inspector - Real-time A2UI protocol message viewer with virtualization
  • ๐Ÿ“Š Performance Tracking - Accurate timer measurements for profiling (fixed 100-10000x accuracy issue)
  • ๐Ÿ’พ Memory Optimized - Virtual scrolling for 1000+ messages (90% reduction in DOM nodes)
  • ๐ŸŒฒ State Tree Viewer - Interactive JSON tree viewer for data models
  • ๐ŸŽฌ Action Tracer - Trace user actions and agent responses
  • โšก DevTools Integration - Chrome DevTools panel for A2UI debugging

๐Ÿ“ฆ Installation

Core Protocol Library

npm install @ainative/ai-kit-a2ui-core

LLM Runtime (OpenAI/Anthropic Adapters)

npm install @ainative/a2ui-runtime

React Bindings

npm install @ainative/a2ui-react

Chrome Inspector (Development Tool)

Install from Chrome Web Store or load unpacked extension from packages/a2ui-inspector/dist

All Packages (Monorepo)

pnpm install  # Uses workspace protocol for inter-package dependencies

Requirements

  • Node.js >= 18.0.0
  • TypeScript >= 5.0 (for type definitions)
  • React >= 18.0 (for @ainative/a2ui-react)
  • OpenAI SDK or Anthropic SDK (for @ainative/a2ui-runtime)

๐Ÿ“– Quick Start

Option 1: Using LLM Runtime (OpenAI)

import { A2UIRuntime } from '@ainative/a2ui-runtime'
import { OpenAIAdapter } from '@ainative/a2ui-runtime/adapters'

// Create runtime with OpenAI adapter
const runtime = new A2UIRuntime({
  adapter: new OpenAIAdapter({
    apiKey: process.env.OPENAI_API_KEY,
    model: 'gpt-4'
  })
})

// Generate UI from natural language prompt
const context = {
  surfaceId: 'dashboard-1',
  conversationHistory: []
}

for await (const message of runtime.generateUI('Create a user dashboard', context)) {
  console.log('Agent message:', message)

  if (message.type === 'createSurface') {
    console.log('Components:', message.components)
    console.log('Data model:', message.dataModel)
  }
}

Option 2: Using LLM Runtime (Anthropic)

import { A2UIRuntime } from '@ainative/a2ui-runtime'
import { AnthropicAdapter } from '@ainative/a2ui-runtime/adapters'

// Create runtime with Anthropic adapter
const runtime = new A2UIRuntime({
  adapter: new AnthropicAdapter({
    apiKey: process.env.ANTHROPIC_API_KEY,
    model: 'claude-3-5-sonnet-20241022'
  })
})

// Add middleware for auth, rate limiting, logging
runtime.use(authMiddleware)
runtime.use(rateLimitMiddleware)
runtime.use(loggingMiddleware)

// Generate UI with streaming
for await (const message of runtime.generateUI('Show me my recent orders', context)) {
  // Handle real-time UI updates
}

Option 3: Using Core WebSocket Transport

import { A2UITransport, JSONPointer } from '@ainative/ai-kit-a2ui-core'

// Connect to agent via WebSocket
const transport = new A2UITransport('wss://api.ainative.studio/agents/dashboard')

transport.on('createSurface', ({ surfaceId, components, dataModel }) => {
  console.log('Surface created:', surfaceId)

  // Use JSON Pointer to access data
  const userName = JSONPointer.resolve(dataModel, '/user/name')
  console.log('User name:', userName)
})

await transport.connect()

// Send user actions to agent
transport.send({
  type: 'userAction',
  surfaceId: 'dashboard-1',
  action: 'submit',
  context: { formData: { email: 'user@example.com' } }
})

Option 4: Using React Hooks with CoAgent

import { A2UIProvider } from '@ainative/a2ui-react'
import { useCoAgent } from '@ainative/a2ui-react/hooks'
import { A2UITransport } from '@ainative/ai-kit-a2ui-core'

// Setup provider
function App() {
  const transport = new A2UITransport('wss://api.ainative.studio/agents/chat')

  return (
    <A2UIProvider transport={transport}>
      <ChatInterface />
    </A2UIProvider>
  )
}

// Use CoAgent hook for bidirectional state sync
function ChatInterface() {
  const { state, setState, isConnected } = useCoAgent('chat-agent', {
    transport,
    optimistic: true,
    conflictResolution: 'client-wins',
    debounce: 300,
    retryOnError: true,
    maxRetries: 3
  })

  return (
    <div>
      <p>Messages: {state.messages?.length}</p>
      <button onClick={() => setState({ ...state, newMessage: 'Hello!' })}>
        Send Message
      </button>
      <p>Status: {isConnected ? 'Connected' : 'Disconnected'}</p>
    </div>
  )
}

๐Ÿ“š Modules

๐Ÿ”น Types

Complete TypeScript definitions for A2UI protocol v0.9.

import type {
  A2UIComponent,
  A2UIMessage,
  ComponentType,
  A2UICreateSurface,
  A2UIUpdateComponents,
  A2UIUserAction,
  DataModel,
  SurfaceId
} from '@ainative/ai-kit-a2ui-core/types'

// Component structure
const component: A2UIComponent = {
  id: 'card-1',
  type: 'card',
  properties: {
    title: 'Dashboard',
    description: 'User analytics'
  },
  children: [
    {
      id: 'text-1',
      type: 'text',
      properties: { value: 'Welcome back!' }
    }
  ]
}

// Agent messages
const createSurface: A2UICreateSurface = {
  type: 'createSurface',
  surfaceId: 'dashboard-1',
  components: [component],
  dataModel: { user: { name: 'Alice' } }
}

Available Types:

  • A2UIComponent - Component definition with id, type, properties, children
  • ComponentType - Union of all 17 standard component types
  • A2UIMessage - Union of all protocol messages
  • A2UICreateSurface - Create new UI surface
  • A2UIUpdateComponents - Update existing components
  • A2UIUserAction - User interaction event
  • DataModel - JSON data structure for binding
  • SurfaceId - Unique surface identifier

๐Ÿ”น JSON Pointer (RFC 6901)

Complete implementation of RFC 6901 for accessing and manipulating nested JSON data.

import { JSONPointer } from '@ainative/ai-kit-a2ui-core/json-pointer'

const data = {
  user: {
    profile: {
      name: 'Alice',
      email: 'alice@example.com'
    },
    settings: {
      theme: 'dark',
      notifications: true
    }
  },
  posts: [
    { id: 1, title: 'First post' },
    { id: 2, title: 'Second post' }
  ]
}

// โœ… Resolve - Get value at pointer
const name = JSONPointer.resolve(data, '/user/profile/name')
// => 'Alice'

const firstPost = JSONPointer.resolve(data, '/posts/0/title')
// => 'First post'

// โœ… Set - Update value at pointer
JSONPointer.set(data, '/user/settings/theme', 'light')
// data.user.settings.theme is now 'light'

// โœ… Remove - Delete value at pointer
JSONPointer.remove(data, '/user/settings/notifications')
// data.user.settings.notifications is now undefined

// โœ… Has - Check if pointer exists
const hasEmail = JSONPointer.has(data, '/user/profile/email')
// => true

// โœ… Compile - Pre-compile pointer for performance
const compiled = JSONPointer.compile('/user/profile/name')
const cachedName = compiled.get(data)
// => 'Alice'

// โœ… Parse - Get path segments from pointer
const segments = JSONPointer.parse('/user/profile/name')
// => ['user', 'profile', 'name']

// โœ… Format - Create pointer from segments
const pointer = JSONPointer.format(['posts', '0', 'title'])
// => '/posts/0/title'

// โœ… Escape - Escape special characters
const escaped = JSONPointer.escape('field/with~slash')
// => 'field~1with~0slash'

// โœ… Unescape - Unescape special characters
const unescaped = JSONPointer.unescape('field~1with~0slash')
// => 'field/with~slash'

API Methods:

  • resolve(obj, pointer) - Get value at pointer (returns any)
  • set(obj, pointer, value) - Set value at pointer (mutates object)
  • remove(obj, pointer) - Delete value at pointer (mutates object)
  • has(obj, pointer) - Check if pointer exists (returns boolean)
  • compile(pointer) - Pre-compile pointer for performance
  • parse(pointer) - Get path segments (returns string[])
  • format(segments) - Create pointer from segments (returns string)
  • escape(str) - Escape special characters (/ โ†’ ~1, ~ โ†’ ~0)
  • unescape(str) - Unescape special characters

๐Ÿ”น WebSocket Transport

Framework-agnostic WebSocket client for real-time agent communication with automatic reconnection and event handling.

import { A2UITransport } from '@ainative/ai-kit-a2ui-core/transport'
import type { TransportStatus } from '@ainative/ai-kit-a2ui-core/transport'

// Create transport instance
const transport = new A2UITransport('wss://api.ainative.studio/agents/chat', {
  reconnect: true,
  reconnectInterval: 3000,
  maxReconnectAttempts: 5
})

// Listen for status changes
transport.on('statusChange', (status: TransportStatus) => {
  console.log('Connection status:', status)
  // 'connecting' | 'connected' | 'disconnecting' | 'disconnected' | 'reconnecting' | 'error'
})

// Listen for agent messages
transport.on('createSurface', (message) => {
  console.log('New surface:', message.surfaceId)
  console.log('Components:', message.components)
  console.log('Data model:', message.dataModel)
})

transport.on('updateComponents', (message) => {
  console.log('Component updates:', message.updates)
  // Handle partial updates to existing components
})

transport.on('error', (error) => {
  console.error('Transport error:', error)
})

// Connect to agent
await transport.connect()

// Send user actions
transport.send({
  type: 'userAction',
  surfaceId: 'chat-1',
  action: 'send-message',
  context: {
    componentId: 'input-1',
    message: 'Hello, agent!'
  }
})

// Disconnect when done
await transport.disconnect()

Constructor Options:

interface A2UITransportOptions {
  reconnect?: boolean           // Auto-reconnect on disconnect (default: true)
  reconnectInterval?: number    // Delay between reconnect attempts in ms (default: 3000)
  maxReconnectAttempts?: number // Maximum reconnection attempts (default: Infinity)
}

Events:

  • statusChange - Connection status changed
  • createSurface - Agent created new UI surface
  • updateComponents - Agent updated existing components
  • error - Transport error occurred

Methods:

  • connect() - Connect to WebSocket (returns Promise<void>)
  • disconnect() - Gracefully disconnect (returns Promise<void>)
  • send(message) - Send message to agent
  • on(event, handler) - Register event listener
  • off(event, handler) - Remove event listener

๐Ÿ”น Component Registry

Extensible registry for managing component definitions with built-in catalog of 17 A2UI standard components.

import { ComponentRegistry } from '@ainative/ai-kit-a2ui-core/registry'
import type { ComponentDefinition } from '@ainative/ai-kit-a2ui-core/registry'

// Create registry with standard components
const registry = ComponentRegistry.standard()

// Get component definition
const textDef = registry.get('text')
console.log(textDef.type)        // 'text'
console.log(textDef.category)    // 'content'
console.log(textDef.description) // 'Display static or dynamic text'

// Register custom component
registry.register('customChart', {
  type: 'customChart',
  category: 'visualization',
  description: 'Interactive data visualization chart',
  schema: {
    properties: {
      data: { type: 'array', required: true },
      chartType: { type: 'string', enum: ['bar', 'line', 'pie'] }
    }
  },
  defaultProps: {
    chartType: 'bar',
    width: 600,
    height: 400
  }
})

// Check if component exists
const hasChart = registry.has('customChart') // true

// Get all component types
const types = registry.types()
// => ['text', 'heading', 'button', ..., 'customChart']

// Get components by category
const contentComponents = registry.byCategory('content')
// => ['text', 'heading', 'image', 'video', 'audioPlayer', 'icon']

// Remove component
registry.unregister('customChart')

๐Ÿ”น LLM Runtime - NEW โœจ

Generate A2UI interfaces from natural language using OpenAI or Anthropic models.

import { A2UIRuntime } from '@ainative/a2ui-runtime'
import { OpenAIAdapter, AnthropicAdapter } from '@ainative/a2ui-runtime/adapters'

// Option 1: OpenAI
const runtime = new A2UIRuntime({
  adapter: new OpenAIAdapter({
    apiKey: process.env.OPENAI_API_KEY,
    model: 'gpt-4',
    temperature: 0.7
  })
})

// Option 2: Anthropic
const runtime = new A2UIRuntime({
  adapter: new AnthropicAdapter({
    apiKey: process.env.ANTHROPIC_API_KEY,
    model: 'claude-3-5-sonnet-20241022'
  })
})

// Add middleware
runtime.use(async (context, next) => {
  console.log('Request:', context.prompt)
  await next()
  console.log('Response:', context.messages)
})

// Generate UI from prompt
const context = {
  surfaceId: 'dashboard-1',
  conversationHistory: [],
  metadata: { userId: 'user-123' }
}

for await (const message of runtime.generateUI('Create a dashboard', context)) {
  if (message.type === 'createSurface') {
    console.log('Components:', message.components)
  }
}

// Execute actions
const result = await runtime.executeAction('button-1', 'click', context)

Features:

  • OpenAI Adapter - GPT-4, GPT-3.5, streaming support, 93.10% test coverage
  • Anthropic Adapter - Claude 3.5, streaming support, 96.15% test coverage
  • Middleware Pipeline - Request/response processing, auth, rate limiting, logging
  • Streaming - Real-time UI generation with async generators
  • Error Handling - Automatic retry, exponential backoff, error recovery
  • 100% Type Safe - Full TypeScript support with strict mode

๐Ÿ”น React Hooks - ENHANCED ๐ŸŽฏ

React bindings for A2UI with bidirectional state synchronization.

import { A2UIProvider, useCoAgent, useA2UIState, useA2UIAction } from '@ainative/a2ui-react'
import { A2UITransport } from '@ainative/ai-kit-a2ui-core'

// 1. Setup Provider
function App() {
  const transport = new A2UITransport('wss://api.ainative.studio/agents/chat')

  return (
    <A2UIProvider transport={transport}>
      <Dashboard />
    </A2UIProvider>
  )
}

// 2. Use CoAgent for bidirectional sync
function Dashboard() {
  const { state, setState, isConnected, error, resync } = useCoAgent('dashboard', {
    transport,
    optimistic: true,              // Optimistic updates
    conflictResolution: 'client-wins', // or 'agent-wins', 'last-write-wins'
    debounce: 300,                 // Debounce state updates
    retryOnError: true,            // Auto-retry on errors
    maxRetries: 3,                 // Max retry attempts
    validate: (state) => state.isValid,
    serialize: (state) => JSON.stringify(state),
    deserialize: (data) => JSON.parse(data),
    onChange: (newState, oldState) => console.log('State changed'),
    onConflict: (conflict) => console.log('Conflict detected')
  })

  return (
    <div>
      <h1>Dashboard</h1>
      <p>Connected: {isConnected ? 'Yes' : 'No'}</p>
      <p>Messages: {state.messages?.length}</p>

      <button onClick={() => setState({ ...state, count: state.count + 1 })}>
        Increment
      </button>

      {error && <p>Error: {error.message}</p>}
    </div>
  )
}

// 3. Use state hook for data model access
function UserProfile() {
  const [userName, loading] = useA2UIState('dashboard-1', '/user/profile/name')

  if (loading) return <p>Loading...</p>

  return <p>Hello, {userName}!</p>
}

// 4. Use action hook for user interactions
function SubmitButton() {
  const { executeAction, loading, error } = useA2UIAction('dashboard-1')

  const handleClick = async () => {
    await executeAction('submit-btn', 'click', { formData: {...} })
  }

  return (
    <button onClick={handleClick} disabled={loading}>
      {loading ? 'Submitting...' : 'Submit'}
    </button>
  )
}

Features:

  • useCoAgent - Bidirectional state sync with conflict resolution and 3-way merge
  • useA2UIState - Access data model via JSON pointers with auto-updates
  • useA2UIAction - Execute user actions with loading states and error handling
  • A2UIProvider - React context for transport and surface management
  • Optimistic Updates - Instant UI feedback before agent confirmation
  • Auto-Retry - Exponential backoff for transient errors
  • Type Safe - Full TypeScript support with generics

Standard Components (21 total):

Content Components (6):

  • text - Display static or dynamic text
  • heading - Heading with configurable level (H1-H6)
  • image - Display images with alt text
  • video - Video player with controls
  • audioPlayer - Audio player with controls
  • icon - Display icons (SVG or icon font)

Input Components (6):

  • textField - Text input with label
  • button - Clickable button
  • checkBox - Checkbox with label
  • slider - Range slider input
  • choicePicker - Select dropdown or radio group
  • dateTimeInput - Date/time picker

Layout Components (5):

  • card - Container with optional header/footer
  • row - Horizontal flex layout
  • column - Vertical flex layout
  • modal - Dialog/modal overlay
  • tabs - Tabbed navigation
  • list - Ordered or unordered list

Video Components (4) - NEW in v0.10:

  • videoRecorder - Video recording with AI transcription and metadata
  • videoCall - Real-time video conferencing with WebRTC
  • aiVideo - AI-powered video generation and editing
  • aiVideoPlayer - Enhanced video player with semantic search and recommendations

Utility Components (1):

  • divider - Horizontal separator line

๐Ÿ—๏ธ Architecture

Package Structure

@ainative/ai-kit-a2ui-core/
โ”œโ”€โ”€ types/              # Protocol type definitions
โ”‚   โ”œโ”€โ”€ component.ts    # Component types
โ”‚   โ”œโ”€โ”€ message.ts      # Message types
โ”‚   โ””โ”€โ”€ index.ts        # Public exports
โ”œโ”€โ”€ json-pointer/       # RFC 6901 implementation
โ”‚   โ”œโ”€โ”€ JSONPointer.ts  # Core implementation
โ”‚   โ””โ”€โ”€ index.ts        # Public exports
โ”œโ”€โ”€ transport/          # WebSocket transport
โ”‚   โ”œโ”€โ”€ A2UITransport.ts # Transport class
โ”‚   โ””โ”€โ”€ index.ts        # Public exports
โ”œโ”€โ”€ registry/           # Component registry
โ”‚   โ”œโ”€โ”€ ComponentRegistry.ts # Registry class
โ”‚   โ”œโ”€โ”€ standard.ts     # Standard catalog
โ”‚   โ””โ”€โ”€ index.ts        # Public exports
โ””โ”€โ”€ index.ts            # Main entry point

Module Exports

// Main entry point
import {
  A2UITransport,
  JSONPointer,
  ComponentRegistry
} from '@ainative/ai-kit-a2ui-core'

// Subpath imports (tree-shakeable)
import { JSONPointer } from '@ainative/ai-kit-a2ui-core/json-pointer'
import { A2UITransport } from '@ainative/ai-kit-a2ui-core/transport'
import { ComponentRegistry } from '@ainative/ai-kit-a2ui-core/registry'
import type { A2UIComponent } from '@ainative/ai-kit-a2ui-core/types'

๐Ÿงช Testing

Run Tests

# Run all tests
npm test

# Watch mode
npm run test:watch

# Coverage report
npm run test:coverage

Test Coverage

Test Files  85+ passed
     Tests  650+ passed (600+ passing)
  Coverage  93%+ overall (up from 41%)

Coverage by Module:

  • Core Protocol: 95.85%

    • Types: 100% (type-only, no runtime)
    • JSON Pointer: 100% (28/28 tests)
    • Transport: 92.1% (25/25 tests)
    • Registry: 100% (16/16 tests)
  • LLM Runtime (NEW): 93-100%

    • OpenAI Adapter: 93.10% (45 tests) โœจ
    • Anthropic Adapter: 96.15% (45 tests) โœจ
    • Runtime Core: 100% (43 tests) โœจ
    • Middleware: 93.8% (162 tests)
  • React Package: 100%

    • useCoAgent: 100% (38/38 tests) - Fixed 7 bugs โœจ
    • A2UIProvider: 100% (context tests)
    • useA2UIState: 100% (state hook tests)
    • useA2UIAction: 100% (action hook tests)
  • Chrome Inspector: 95%+

    • Message Inspector: 100% (33 tests) โœจ
    • Performance Tracker: 100% (18 tests) - Fixed timer accuracy โœจ
    • State Tree Viewer: 95%+
    • Action Tracer: 95%+
  • Video Protocol (v0.10): 98%+

    • Video types and messages: 100%
    • Video handlers: 96%+
  • AI Intelligence (v0.11): 94%+

    • Semantic search: 100%
    • AI metadata: 100%
    • Progress tracking: 93%+
    • Recommendations: 88%+

Quality Score: 85/100 (Beta Ready) - Up from 68/100 โœ…

๐Ÿ“Š Bundle Size

  • ESM: ~18 KB minified, ~6 KB gzipped
  • CJS: ~19 KB minified, ~6.5 KB gzipped
  • Zero runtime dependencies (only TypeScript for types)

๐Ÿ”ง Development

Build

npm run build

Output:

  • dist/index.js - ESM module
  • dist/index.cjs - CommonJS module
  • dist/index.d.ts - TypeScript definitions
  • dist/{module}/ - Individual module exports

Type Checking

npm run type-check

Linting & Formatting

npm run lint
npm run format

๐Ÿ“„ API Reference

Types Module

import type {
  // Components
  A2UIComponent,
  ComponentType,
  ComponentProperties,

  // Messages
  A2UIMessage,
  A2UICreateSurface,
  A2UIUpdateComponents,
  A2UIUserAction,

  // Data
  DataModel,
  SurfaceId
} from '@ainative/ai-kit-a2ui-core/types'

JSON Pointer Module

import { JSONPointer } from '@ainative/ai-kit-a2ui-core/json-pointer'

// Static methods
JSONPointer.resolve(obj: any, pointer: string): any
JSONPointer.set(obj: any, pointer: string, value: any): void
JSONPointer.remove(obj: any, pointer: string): boolean
JSONPointer.has(obj: any, pointer: string): boolean
JSONPointer.compile(pointer: string): CompiledPointer
JSONPointer.parse(pointer: string): string[]
JSONPointer.format(segments: string[]): string
JSONPointer.escape(str: string): string
JSONPointer.unescape(str: string): string

Transport Module

import { A2UITransport } from '@ainative/ai-kit-a2ui-core/transport'
import type { TransportStatus, A2UITransportOptions } from '@ainative/ai-kit-a2ui-core/transport'

class A2UITransport {
  constructor(url: string, options?: A2UITransportOptions)

  connect(): Promise<void>
  disconnect(): Promise<void>
  send(message: A2UIMessage): void

  on(event: 'statusChange', handler: (status: TransportStatus) => void): void
  on(event: 'createSurface', handler: (message: A2UICreateSurface) => void): void
  on(event: 'updateComponents', handler: (message: A2UIUpdateComponents) => void): void
  on(event: 'error', handler: (error: Error) => void): void

  off(event: string, handler: Function): void
}

Registry Module

import { ComponentRegistry } from '@ainative/ai-kit-a2ui-core/registry'
import type { ComponentDefinition } from '@ainative/ai-kit-a2ui-core/registry'

class ComponentRegistry {
  static standard(): ComponentRegistry

  register(type: ComponentType, definition: ComponentDefinition): void
  get(type: ComponentType): ComponentDefinition | undefined
  has(type: ComponentType): boolean
  unregister(type: ComponentType): boolean

  types(): ComponentType[]
  byCategory(category: string): ComponentType[]
}

๐Ÿค Contributing

We welcome contributions! Please see CONTRIBUTING.md for guidelines.

Development Setup

# Clone repository
git clone https://github.com/AINative-Studio/ai-kit-a2ui-core.git
cd ai-kit-a2ui-core

# Install dependencies
npm install

# Run tests in watch mode
npm run test:watch

# Build
npm run build

๐Ÿ“ License

MIT ยฉ AINative Studio

๐Ÿ™‹ Support


๐Ÿ“‹ Changelog

v2.0.0 (2026-02-17) - Major Release ๐ŸŽ‰

New Packages:

  • Added @ainative/a2ui-runtime - LLM adapters for OpenAI and Anthropic
  • Enhanced @ainative/a2ui-react - React bindings with CoAgent bidirectional sync
  • Optimized @ainative/a2ui-inspector - Chrome DevTools extension with virtualization

LLM Runtime:

  • OpenAI Adapter with GPT-4/GPT-3.5 support (93.10% test coverage)
  • Anthropic Adapter with Claude 3.5 support (96.15% test coverage)
  • Middleware pipeline (auth, rate limiting, logging, validation)
  • Streaming support for real-time UI generation
  • 100% runtime core coverage (43 tests)

React Package Improvements:

  • Fixed 7 critical bugs in useCoAgent hook
  • Implemented 3-way merge algorithm for conflict resolution
  • Added auto-retry with exponential backoff
  • Added custom serialization/deserialization support
  • Created A2UIProvider context wrapper
  • Created useA2UIState hook for data model access
  • Created useA2UIAction hook for action execution
  • 100% test coverage on all hooks (38/38 tests passing)

Chrome Inspector Optimizations:

  • Fixed performance tracking timer accuracy (was off by 100-10000x)
  • Added virtualization for large message lists (1000+ messages)
  • 90% reduction in DOM nodes for better performance
  • Memory leak prevention with react-window integration
  • ResizeObserver integration for responsive layouts

Test Coverage:

  • Added 540+ new tests across all packages
  • Increased coverage from 41% to 93%+
  • Quality score improved from 68/100 to 85/100 (Beta Ready)
  • All critical bugs fixed in useCoAgent (conflict resolution, debouncing, retry, serialization)

Documentation:

  • Added comprehensive 10-agent sprint summary
  • Added LLM Runtime usage examples
  • Added React hooks usage guide
  • Added middleware documentation
  • Updated README with all new features

Build & Infrastructure:

  • Fixed TypeScript compilation errors (19 โ†’ 0)
  • All packages now build successfully
  • Configured monorepo with pnpm workspaces
  • Added Changesets for version management

See AGENT_SPRINT_SUMMARY.md for detailed sprint report.


Built with โค๏ธ by AINative Studio