Skip to content

Build browser and Node agents with TypeScript

The TypeScript package provides actions, typed streams, sessions, transports, serialization, and LLM client utilities for browsers and Node.js. It uses the same wire records and lifecycle statuses as the Python and C++ runtimes.

npm install @curiositystack/a11

All public symbols are available from one entry point:

import {
    Action,
    AsyncNode,
    Session,
    StatusException,
    valueOrThrow,
} from '@curiositystack/a11';

Choose what you want to build

API areas

Area Primary symbols
Actions Action, ActionRegistry, ActionSchema
Streams AsyncNode, NodeMap, Chunk
Connections Session, WebSocketWireStream, HttpSseClientWireStream, WebRtcWireStream
Data toChunk, fromChunk, SerializationRegistry
LLM clients Interaction, ToolAdapter, PresentationReducer
Errors Status, StatusCode, valueOrThrow

Open the complete TypeScript API reference

Handle statuses at boundaries

Runtime methods return Status or StatusOr<T> so failures can cross workers, transports, and language boundaries without losing their code or details. Use isOk while composing operations. Use valueOrThrow at an application boundary where exceptions fit the surrounding framework.

const node = valueOrThrow(await AsyncNode.create('answer'));

try {
    valueOrThrow(await node.finalize({text: 'Ready'}));
} catch (error) {
    if (error instanceof StatusException) {
        console.error(StatusCode[error.status.code], error.status.message);
    }
}

Action.signal is an AbortSignal for cooperative handler cancellation. Cancelling an action also cancels its active nested actions and sends a remote cancellation message for calls.