Skip to content

RealtimeInstance

Defined in: packages/realtime/src/lib/realtime-session/realtime-session.types.ts:53

The minimal bridge RealtimeSession needs from a Maelstrom instance. Orchestrator maps onto this via a small wrapper (submitIntent -> processIntent, createIntentScope -> the shared scheduler scope, and idle waits -> commandProcessor.waitForIdle) — this interface exists so the realtime package depends on a narrow seam rather than the whole Orchestrator surface. getStructuralSnapshot backs the get_ui_state pull (what’s on screen); getCapabilitySnapshot backs the get_capabilities pull (what CAN be shown).

submitIntent resolves with a SubmitIntentResult carrying the engine’s conversational userMessage, so the session can speak the engine’s own reply instead of a structural summary once the change settles. It still rejects with RequestInFlightError while a prior intent is applying. Legacy instances are attempted once and report busy as not-submitted, without retry. Supply createIntentScope for bounded cross-source FIFO and exact outcomes.

readonly optional applicationWork?: VoiceApplicationWorkSource

Defined in: packages/realtime/src/lib/realtime-session/realtime-session.types.ts:55

Optional application-wide current work observations, including non-voice input.

addAssistantMessageAcknowledged(args): Promise<AssistantMessageOutcome>

Defined in: packages/realtime/src/lib/realtime-session/realtime-session.types.ts:96

Persist an assistant message with the engine’s existing MessageId dedup. 'inserted' is positive evidence this runtime owns first insertion; 'deduped' means an earlier attempt already landed.

MessageId

string

Promise<AssistantMessageOutcome>


optional createIntentScope(): IntentScope

Defined in: packages/realtime/src/lib/realtime-session/realtime-session.types.ts:63

Creates one connection-owned lifetime backed by the application’s shared scheduler. Preferred over submitIntent when present. Retirement settles only pending work; active results remain observable after voice ends. Ticket results include response application settlement and must never reject. Queue capacity, wait and connection-loss bounds belong to the client policy.

IntentScope


getCapabilitySnapshot(): CapabilitySnapshot

Defined in: packages/realtime/src/lib/realtime-session/realtime-session.types.ts:89

CapabilitySnapshot


getStructuralSnapshot(): UIStructuralSnapshot

Defined in: packages/realtime/src/lib/realtime-session/realtime-session.types.ts:88

UIStructuralSnapshot


observeEngineConnection(cb): Unsubscribe

Defined in: packages/realtime/src/lib/realtime-session/realtime-session.types.ts:106

Observe engine connection readiness. Subscribe first, then the current status is delivered synchronously (subscribe-then-snapshot), so an already-connected engine resolves immediately and a not-connected engine delivers false now and true on the next transition.

(connected) => void

Unsubscribe


onSettled(cb): Unsubscribe

Defined in: packages/realtime/src/lib/realtime-session/realtime-session.types.ts:90

() => void

Unsubscribe


submitIntent(intent): Promise<SubmitIntentResult>

Defined in: packages/realtime/src/lib/realtime-session/realtime-session.types.ts:65

Legacy immediate admission; called once, with no busy retry or FIFO guarantee.

string

Promise<SubmitIntentResult>


waitForIdle(): Promise<void>

Defined in: packages/realtime/src/lib/realtime-session/realtime-session.types.ts:67

Legacy global settle wait, unused for scoped ticket results.

Promise<void>


optional waitForIdleResult(): Promise<Result<void, Error>>

Defined in: packages/realtime/src/lib/realtime-session/realtime-session.types.ts:87

Result-bearing settle wait, preferred over RealtimeInstance.waitForIdle wherever the session needs to know whether the settled work succeeded.

It is optional so that an instance written against the void-only RealtimeInstance.waitForIdle still satisfies this interface; a session that finds it absent falls back to that wait and can only treat every settle as successful. An Orchestrator-backed instance supplies it directly, because commandProcessor.waitForIdle() already resolves with this Result.

A !ok result means the settled work failed — a refused set_layout (duplicate tiling leaf, malformed weight token) being the ordinary case. Such a refusal neither throws nor rejects and leaves the previous screen in place, so this is the only signal that the intent changed nothing, and RealtimeSession answers the update_ui tool call as a failure rather than describing a snapshot the intent never produced. A rejection leaves the application outcome unconfirmed and must not trigger automatic replay.

Promise<Result<void, Error>>