Capsule SDK
The Capsule SDK (@allternit/capsule-sdk) is a headless library for building and controlling Allternit capsules. A capsule is a runtime-surface contract that declares where and when UI happens, while A2UI / AG-UI remains the source of visual truth. The SDK enforces lifecycle state, capabilities, event semantics, action registration, and UX minimums.
Overview
Use the Capsule SDK when you are building:- A custom renderer or agent-facing surface.
- A browser, desktop, or embedded capsule that must report its state to Allternit.
- A tool that needs to register actions and prevent dead UI buttons.
Installation
Quick start
Core concepts
Lifecycle
Every capsule follows the same state machine. Transitions are validated by the SDK.Capabilities
Capabilities declare what a capsule supports. A2UI queries these to decide how to render the surface.Events
State changes emit events on the capsule’s event bus. A2UI subscribes to these events and decides how to render.Actions
Actions must be registered before A2UI can render them. This prevents dead buttons.Controllers
Capsule controller options
Capsule controller methods
Guards
The SDK provides runtime guards that validate invariants and action usage.Error handling
Related pages
- Surfaces overview — how A2UI consumes capsules
- Agent Studio — design-time surface for capsule agents
- Gizzi Runtime — execution engine behind capsules
- Capsule Manager — operational surface for capsule fleets