Scenario and publication
A scenario is the authored experience in Cockpit (prompt, features, collections, voice settings). A publication is the live UUID your frontend embeds. One scenario can have multiple publications (staging vs production). Your app always uses the publication UUID — it’s thescenario option you pass to useScenaroSession.
Two-hop authentication
Scenaro separates identity from session:| Step | Endpoint | Output |
|---|---|---|
| Identify | POST /v1/public/token | user_token (JWT), user_id, application_id |
| Session | POST /v1/public/session | Transport credentials — livekit_token, livekit_url (LiveKit is the current Transport implementation) |
generateToken flow has been removed. Every integration must use identify then session — useScenaroSession runs both automatically when you call start().
Identification is idempotent on the client: if a valid JWT is already in storage, no network call is made.
Transport data channel
Once connected, the voice agent and frontend communicate over the Transport data channel — implemented with LiveKit data topics today (see Transport for the engine-agnostic boundary):config— agent sends feature definitions, collections, restore statemessage:new— conversation messages (user, assistant, tool, event)tool:{toolName}— dynamic tool response topicsstate:update— frontend sends experience checkpoints to the agent
useScenaroSession subscribes to these topics for you — you only see the results (messages, config, tool calls). See the Protocol reference if you’re building on the raw channel.
Feature registry
The SDK’sFeatureProvider manages feature state (history, visibility, tool execution) but does not ship business features. Your app provides a registry:
tools option of useScenaroSession.
Event bus
ScenaroProvider creates a scoped ScenaroEventBus (replacing the legacy window.__ global). Subscribe with useScenaroEvents() for config, messages, tool requests, and session events.
Sub-exports mental model
| Layer | Use when |
|---|---|
protocol | Defining cross-language contracts, agent development, type sharing |
client | Node scripts, non-React apps, API calls without UI |
react | Browser apps with voice sessions over Transport |
ScenaroSession class from @scenaro/sdk — see the Session reference.
Session lifecycle
- User calls
start()→ SDK identifies the visitor (cached JWT reused if valid) - SDK starts the session and connects the Transport →
statusbecomes'connecting'then'connected' - Agent joins → sends
config→ SDK registers your tool handlers - Conversation runs →
messagesaccumulates, tool RPCs fire your handlers - Agent or user ends →
onSessionEndfires,statusbecomes'ended'
What stays in your app
- Feature UI components (search, cart, comparison)
- Brand styling and layout
- Collection-specific API calls
- Tool handler implementations (passed via
toolsor the feature registry)