useScenaroSession handles the Transport data channel, config handshake, and tool RPC internally. You consume events through hook callbacks, returned state, and the scoped event bus.

Session events via the hook

FieldDescription
messagesAccumulated conversation — no separate hook needed
configCurated session config after handshake
rawConfigFull wire ConfigPayload (restore_state, tool wiring)
status'idle' | 'connecting' | 'connected' | 'reconnecting' | 'ended'
agentState'idle' | 'listening' | 'thinking' | 'speaking'
Outside React, the headless ScenaroSession class emits the same events: status-change, agent-state, message, config, session-end, error. See the ScenaroSession reference.

Event bus

ScenaroProvider creates one ScenaroEventBus per provider tree. Subscribe with useScenaroEvents():

Event catalog

EventEmitterPayload
configSessionEventBridgeRaw ConfigPayload
message:newSessionEventBridgeConversationMessage
session:endSessionEventBridge{ reason: string }
tool:executeuseFeatureToolRpc{ toolName, requestId, args }
tool:responseFeatureProvider{ requestId, response }
tool:errorFeatureProvider{ requestId, toolName, error }
feature:showFeatureProvider{ reason, toolName, requestId }
suggestions:showFeatureProvider{ suggestions }
conversation:resetYour app (manual)— triggers FeatureProvider.reset()
session.on('config') delivers the curated SessionConfig. events.on('config') delivers the raw wire payload. See Tools and features.

Tool RPC flow

For session tools, declare plain functions on useScenaroSession: For feature tools via FeatureProvider, see Tools and features. RPC timeout for frontend tools: 10 seconds (RPC_TIMEOUTS.FRONTEND_TOOL_MS). The context.signal (AbortSignal) is aborted on timeout or session end.

Text input

Send user text with sendText(text) from the hook. It publishes on the lk.chat topic via the Transport data channel.

Session end detection

The SDK ends the session on:
  • Transport disconnected event
  • Agent participant leaving (2s grace period)
  • session:end data topic
status becomes 'ended' and onSessionEnd fires with the end payload.

Pre-0.3 migration note

useScenarioSession, AgentListener, and useConversationMessages were removed in 0.3.0. Use useScenaroSession for session lifecycle and messages for conversation UI. See the migration guide.