Capability first · transport second

AIRuntimeState.js

Sticky mutable LLM, speech-to-text, and text-to-speech lifecycle snapshots, intents, subscriptions, and startup-settlement barriers.

SDK 0.5.18Runtime 0.8.12Protocol arcane/1
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

JavaScript
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

BindingFormDeclaration or signatureParameter syntax
AI_RUNTIME_PROTOCOLvariable · valuevariable AI_RUNTIME_PROTOCOL
AI_RUNTIME_STATE_EVENTvariable · valuevariable AI_RUNTIME_STATE_EVENT
AI_RUNTIME_INTENT_EVENTvariable · valuevariable AI_RUNTIME_INTENT_EVENT
AI_RUNTIME_STARTUP_EVENTvariable · valuevariable AI_RUNTIME_STARTUP_EVENT
AI_RUNTIME_ROLESvariable · valuevariable AI_RUNTIME_ROLES
AI_RUNTIME_STATESvariable · valuevariable AI_RUNTIME_STATES
getAIRuntimeStatefunctionfunction getAIRuntimeState()
subscribeAIRuntimeStatefunctionfunction subscribeAIRuntimeState(listener, options)listener, options
publishAIRuntimeRoleStatefunctionfunction publishAIRuntimeRoleState(role, completeRecord)role, completeRecord
publishAIRuntimeRolesStatefunctionfunction publishAIRuntimeRolesState(completeRecords)completeRecords
requestAIRuntimeIntentfunctionfunction requestAIRuntimeIntent(intent)intent
subscribeAIRuntimeIntentsfunctionfunction subscribeAIRuntimeIntents(listener, options)listener, options
startAIRuntimefunctionfunction startAIRuntime(options)options
CallableKindExact public signatureParameter syntax
getAIRuntimeStateexported-functionfunction getAIRuntimeState()
subscribeAIRuntimeStateexported-functionfunction subscribeAIRuntimeState(listener, options)listener, options
publishAIRuntimeRoleStateexported-functionfunction publishAIRuntimeRoleState(role, completeRecord)role, completeRecord
publishAIRuntimeRolesStateexported-functionfunction publishAIRuntimeRolesState(completeRecords)completeRecords
requestAIRuntimeIntentexported-functionfunction requestAIRuntimeIntent(intent)intent
subscribeAIRuntimeIntentsexported-functionfunction subscribeAIRuntimeIntents(listener, options)listener, options
startAIRuntimeexported-functionfunction 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

JavaScript
import {
    getAIRuntimeState,
    subscribeAIRuntimeState
} from '/arcane/modules/AIRuntimeState.js';

const release=subscribeAIRuntimeState(snapshot=>console.log(snapshot.roles),{
    emitCurrent:true
});
console.log(getAIRuntimeState().protocol);
release();

No direct Core call is claimed for this artifact. Any injected provider or consuming module retains its own documented authority.