@aseity/agent-ui-protocol
v0.1.0
Published
Transport-neutral event protocol and state utilities for agent UIs.
Readme
Agent UI Protocol
Transport-neutral event schemas and state helpers for rendering realtime agent sessions.
Install
npm install @agent/agent-ui-protocol zodzod is a peer dependency because the package exports Zod schemas.
Usage
import { UIEvent, emptySession, reduce } from '@agent/agent-ui-protocol';
let session = emptySession('session-1');
const event = UIEvent.parse({ type: 'turn_start', turn_id: 'turn-1' });
session = reduce(session, event).next;Protocol
The package exports these protocol primitives:
UIEvent: Zod discriminated union for all realtime events.InteractionRequestDataandInteractionResponseData: request and response schemas for user/tool interactions.SessionHistory: persisted history schema for non-streaming hydration.AgentTransport: transport interface for clients.MockTransport: deterministic in-memory transport for demos and tests.
Realtime event types:
session_eventturn_startturn_endpart_addpart_updatepart_completetool_input_deltatool_input_completetool_resultsession_errorcompact_startcompact_endinteraction_request
State helpers:
emptySession(id)hydrate(history)reduce(session, event)applyOptimisticUserMessage(session, id, text)confirmOptimisticUserMessage(session, id)rollbackOptimisticUserMessage(session, id)
Development
bun run test
bun run typecheck
bun run build
npm pack --dry-run