On this page
Overview
Sticky mutable LLM, speech-to-text, and text-to-speech lifecycle snapshots, intents, subscriptions, and startup-settlement barriers.
- Artifact
AIRuntimeState.js· esm - Classification
public first party - Availability
Cross-host in-process state contract; actual role readiness remains provider specific - Normalization
Closed monotonic sticky role snapshots, transient lifecycle intents, synchronous current-state replay, AbortSignal cleanup, and startup settlement are normalized; events report state but grant no authority.
Import and lifecycle
import * as module from '/arcane/modules/AIRuntimeState.js';
Import creates one EventTarget-backed sticky state owner. Publishing replaces one or all complete role records with a monotonic revision; subscriptions attach listeners until their returned release function or AbortSignal removes them. startAIRuntime requests startup intents and exposes separate text-chat and all-requested-role settlement promises.
Application-facing behavior: Protocol/event/role/state constants; snapshot, state subscribe/publish, intent request/subscribe, and startAIRuntime({startMuted,startTranscription,signal}) returning {barrier,settled,cancel}.
Protocol and host implementation
arcane-ai-runtime-state/1 over the per-realm globalThis.arcaneEvents authority This detail does not widen the application-facing API or grant authority.
Exports, signatures, parameters, and results
| Binding | Form | Declaration or signature | Parameter syntax |
|---|---|---|---|
AI_RUNTIME_PROTOCOL | variable · value | variable AI_RUNTIME_PROTOCOL | — |
AI_RUNTIME_STATE_EVENT | variable · value | variable AI_RUNTIME_STATE_EVENT | — |
AI_RUNTIME_INTENT_EVENT | variable · value | variable AI_RUNTIME_INTENT_EVENT | — |
AI_RUNTIME_STARTUP_EVENT | variable · value | variable AI_RUNTIME_STARTUP_EVENT | — |
AI_RUNTIME_ROLES | variable · value | variable AI_RUNTIME_ROLES | — |
AI_RUNTIME_STATES | variable · value | variable AI_RUNTIME_STATES | — |
getAIRuntimeState | function | function getAIRuntimeState() | — |
subscribeAIRuntimeState | function | function subscribeAIRuntimeState(listener, options) | listener, options |
publishAIRuntimeRoleState | function | function publishAIRuntimeRoleState(role, completeRecord) | role, completeRecord |
publishAIRuntimeRolesState | function | function publishAIRuntimeRolesState(completeRecords) | completeRecords |
requestAIRuntimeIntent | function | function requestAIRuntimeIntent(intent) | intent |
subscribeAIRuntimeIntents | function | function subscribeAIRuntimeIntents(listener, options) | listener, options |
startAIRuntime | function | function startAIRuntime(options) | options |
| Callable | Kind | Exact public signature | Parameter syntax |
|---|---|---|---|
getAIRuntimeState | exported-function | function getAIRuntimeState() | — |
subscribeAIRuntimeState | exported-function | function subscribeAIRuntimeState(listener, options) | listener, options |
publishAIRuntimeRoleState | exported-function | function publishAIRuntimeRoleState(role, completeRecord) | role, completeRecord |
publishAIRuntimeRolesState | exported-function | function publishAIRuntimeRolesState(completeRecords) | completeRecords |
requestAIRuntimeIntent | exported-function | function requestAIRuntimeIntent(intent) | intent |
subscribeAIRuntimeIntents | exported-function | function subscribeAIRuntimeIntents(listener, options) | listener, options |
startAIRuntime | exported-function | function startAIRuntime(options) | options |
Parameter meanings and results
getAIRuntimeState() returns mutable {protocol,revision,roles:{llm,stt,tts}} with complete role records. subscribeAIRuntimeState(listener,{signal,emitCurrent=true}) returns an unsubscribe function. requestAIRuntimeIntent({role,action,reason}) accepts load/unload/dispose and startup/user/teardown. startAIRuntime({startMuted=true,startTranscription=false,signal=null}) returns mutable {barrier,settled,cancel}; barrier settles for LLM only, while settled covers every requested role. STT startup is opt-in so selection and observation alone never request its load.
Events, side effects, and errors
Source-literal CustomEvent dispatches
No source-literal CustomEvent dispatch is part of this artifact.
Lifecycle and event flow
- arcane-ai-runtime-state
- arcane-ai-runtime-intent
- arcane-ai-runtime-startup-settled
Direct coded failures
ARCANE_AI_REQUEST_ABORTED
Exported Error subclasses
This artifact exports no Error subclass.
Documented failure behavior
- TypeError message prefix ARCANE_AI_RUNTIME_STATE_INVALID
- ARCANE_AI_REQUEST_ABORTED
Availability and capabilities
Cross-host in-process state contract; actual role readiness remains provider specific. Closed monotonic sticky role snapshots, transient lifecycle intents, synchronous current-state replay, AbortSignal cleanup, and startup settlement are normalized; events report state but grant no authority.
Cross-host state normalization only. Events describe current intent/state; they do not grant a capability, select a provider, or prove native/browser readiness.
Contract example
import {
getAIRuntimeState,
subscribeAIRuntimeState
} from '/arcane/modules/AIRuntimeState.js';
const release=subscribeAIRuntimeState(snapshot=>console.log(snapshot.roles),{
emitCurrent:true
});
console.log(getAIRuntimeState().protocol);
release();
Related reference
No direct Core call is claimed for this artifact. Any injected provider or consuming module retains its own documented authority.