RealtimeInstance
Defined in: packages/realtime/src/lib/realtime-session/realtime-session.types.ts:54
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.
Properties
Section titled “Properties”applicationWork?
Section titled “applicationWork?”
readonlyoptionalapplicationWork?:VoiceApplicationWorkSource
Defined in: packages/realtime/src/lib/realtime-session/realtime-session.types.ts:56
Optional application-wide current work observations, including non-voice input.
Methods
Section titled “Methods”addAssistantMessageAcknowledged()
Section titled “addAssistantMessageAcknowledged()”addAssistantMessageAcknowledged(
args):Promise<AssistantMessageOutcome>
Defined in: packages/realtime/src/lib/realtime-session/realtime-session.types.ts:108
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.
Parameters
Section titled “Parameters”MessageId
message
Section titled “message”string
Returns
Section titled “Returns”Promise<AssistantMessageOutcome>
createIntentScope()?
Section titled “createIntentScope()?”
optionalcreateIntentScope():IntentScope
Defined in: packages/realtime/src/lib/realtime-session/realtime-session.types.ts:64
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.
Returns
Section titled “Returns”IntentScope
getCapabilitySnapshot()
Section titled “getCapabilitySnapshot()”getCapabilitySnapshot():
CapabilitySnapshot
Defined in: packages/realtime/src/lib/realtime-session/realtime-session.types.ts:101
Returns
Section titled “Returns”CapabilitySnapshot
getStructuralSnapshot()
Section titled “getStructuralSnapshot()”getStructuralSnapshot():
UIStructuralSnapshot
Defined in: packages/realtime/src/lib/realtime-session/realtime-session.types.ts:100
Returns
Section titled “Returns”UIStructuralSnapshot
observeEngineConnection()
Section titled “observeEngineConnection()”observeEngineConnection(
cb):Unsubscribe
Defined in: packages/realtime/src/lib/realtime-session/realtime-session.types.ts:118
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.
Parameters
Section titled “Parameters”(connected) => void
Returns
Section titled “Returns”Unsubscribe
onSettled()
Section titled “onSettled()”onSettled(
cb):Unsubscribe
Defined in: packages/realtime/src/lib/realtime-session/realtime-session.types.ts:102
Parameters
Section titled “Parameters”() => void
Returns
Section titled “Returns”Unsubscribe
sendAgentMessage()?
Section titled “sendAgentMessage()?”
optionalsendAgentMessage(text):Promise<SettledAgentRun>
Defined in: packages/realtime/src/lib/realtime-session/realtime-session.types.ts:75
Sends one submit_intent intent as an agent message and resolves with the
input’s Agent Run state once it settled, the result that
Orchestrator.sendMessage returns. A run can finish before its UI
changes are applied. Preferred over createIntentScope and
submitIntent when present. Must never reject. A lost state is an
unknown outcome and is never replayed.
The agent loop is experimental in 0.3 and may change in any minor release.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Promise<SettledAgentRun>
submitIntent()
Section titled “submitIntent()”submitIntent(
intent):Promise<SubmitIntentResult>
Defined in: packages/realtime/src/lib/realtime-session/realtime-session.types.ts:77
Legacy immediate admission; called once, with no busy retry or FIFO guarantee.
Parameters
Section titled “Parameters”intent
Section titled “intent”string
Returns
Section titled “Returns”Promise<SubmitIntentResult>
waitForIdle()
Section titled “waitForIdle()”waitForIdle():
Promise<void>
Defined in: packages/realtime/src/lib/realtime-session/realtime-session.types.ts:79
Legacy global settle wait, unused for scoped ticket results.
Returns
Section titled “Returns”Promise<void>
waitForIdleResult()?
Section titled “waitForIdleResult()?”
optionalwaitForIdleResult():Promise<Result<void,Error>>
Defined in: packages/realtime/src/lib/realtime-session/realtime-session.types.ts:99
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 submit_intent 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.
Returns
Section titled “Returns”Promise<Result<void, Error>>