arcane-os 0.2.3 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -0
- package/README.md +8 -8
- package/browser-runtime/ARCANE_SDK_BROWSER_RELEASE.json +29 -22
- package/browser-runtime/ai/ARCANE_AI_BROWSER_SPEECH_COMPONENTS.json +203 -0
- package/browser-runtime/ai/browser-kokoro-worker.mjs +11 -2
- package/browser-runtime/ai/browser-speech-artifacts.mjs +3242 -391
- package/browser-runtime/ai/browser-speech-providers.mjs +1209 -157
- package/browser-runtime/ai/browser-speech.mjs +2 -0
- package/browser-runtime/ai/browser-whisper-worker.mjs +11 -2
- package/browser-runtime/ai/model-controller.mjs +285 -95
- package/browser-runtime/ai/speech-worker-client.mjs +249 -32
- package/browser-runtime/ai/speech-worker-runtime.mjs +2322 -167
- package/browser-runtime/event-manager.mjs +1097 -1
- package/docs/architecture.md +2 -2
- package/docs/event-manager.md +155 -27
- package/docs/reference/README.md +18 -20
- package/docs/reference/ai/browser-speech-package-authority.json +835 -0
- package/docs/reference/ai/browser-speech.md +1205 -246
- package/docs/reference/ai/browser-wasm.md +18 -7
- package/docs/reference/availability-and-normalization.md +2 -2
- package/docs/reference/behavioral-testing.md +28 -5
- package/docs/reference/cli.md +115 -7
- package/docs/reference/core/arcane-ai-contracts.md +1 -1
- package/docs/reference/event-manager.md +577 -32
- package/docs/reference/inventory/package-api.json +478 -2
- package/docs/reference/inventory/runtime-components.json +86 -37
- package/docs/reference/inventory/runtime-modules.json +126 -49
- package/docs/reference/mail.md +316 -0
- package/docs/reference/protocols.md +185 -33
- package/docs/reference/runtime-components.md +192 -80
- package/docs/reference/runtime-modules.md +589 -70
- package/docs/reference/sdk-api.md +1017 -24
- package/package.json +5 -4
- package/runtime/ARCANE_RUNTIME_RELEASE.json +145 -140
- package/runtime/arcane/components/app-bar.html +34 -13
- package/runtime/arcane/components/assistant-panel.html +110 -57
- package/runtime/arcane/components/calculator.html +7 -4
- package/runtime/arcane/components/chart.html +58 -17
- package/runtime/arcane/components/chat.html +606 -136
- package/runtime/arcane/components/conversation-view.html +13 -6
- package/runtime/arcane/components/dashboard-config.html +96 -59
- package/runtime/arcane/components/data-maintenance.html +69 -14
- package/runtime/arcane/components/data-view.html +53 -7
- package/runtime/arcane/components/directory-picker.html +118 -32
- package/runtime/arcane/components/document-inspector.html +47 -10
- package/runtime/arcane/components/file-drop.html +81 -35
- package/runtime/arcane/components/file-inspector.html +72 -22
- package/runtime/arcane/components/file-manager.html +374 -79
- package/runtime/arcane/components/integration-settings.html +12 -5
- package/runtime/arcane/components/local-ai-status.html +48 -19
- package/runtime/arcane/components/markdown-document.html +161 -68
- package/runtime/arcane/components/markdown-editor.html +110 -33
- package/runtime/arcane/components/media-embed.html +8 -5
- package/runtime/arcane/components/modal.html +15 -5
- package/runtime/arcane/components/output-panel.html +28 -23
- package/runtime/arcane/components/preferences-form.html +22 -4
- package/runtime/arcane/components/record-timeline.html +18 -2
- package/runtime/arcane/components/relationship-board.html +23 -3
- package/runtime/arcane/components/screen-capture.html +10 -4
- package/runtime/arcane/components/source-code-viewer.html +76 -9
- package/runtime/arcane/components/source-explanation.html +23 -3
- package/runtime/arcane/components/speech.html +453 -131
- package/runtime/arcane/components/summary-strip.html +22 -11
- package/runtime/arcane/components/table.html +39 -21
- package/runtime/arcane/components/task-progress.html +79 -21
- package/runtime/arcane/components/terminal-workspace.html +7 -4
- package/runtime/arcane/components/theme-editor.html +7 -3
- package/runtime/arcane/components/unified-inbox.html +9 -4
- package/runtime/arcane/components/voice-transcription.html +244 -72
- package/runtime/arcane/components/weather-widget.html +5 -3
- package/runtime/arcane/components/web-navigator.html +48 -8
- package/runtime/arcane/entities/Chat.js +1 -1
- package/runtime/arcane/entities/User.js +110 -23
- package/runtime/arcane/modules/AI.js +2117 -130
- package/runtime/arcane/modules/AIProviderRuntime.js +756 -13
- package/runtime/arcane/modules/AIRuntimeState.js +109 -52
- package/runtime/arcane/modules/ApiModelDatabase.js +390 -17
- package/runtime/arcane/modules/BrowserTestSuite.js +205 -28
- package/runtime/arcane/modules/CalculatorEngine.js +63 -3
- package/runtime/arcane/modules/CommunicationAppController.js +588 -28
- package/runtime/arcane/modules/CommunicationHub.js +590 -10
- package/runtime/arcane/modules/ComponentContracts.js +235 -37
- package/runtime/arcane/modules/ConversationTimebox.js +152 -33
- package/runtime/arcane/modules/DBLS.js +40 -7
- package/runtime/arcane/modules/DBOPFS.js +35 -11
- package/runtime/arcane/modules/DataMaintenance.js +12 -2
- package/runtime/arcane/modules/Errors.js +65 -7
- package/runtime/arcane/modules/HTMLImport.js +198 -14
- package/runtime/arcane/modules/LocalAIReadinessController.js +208 -29
- package/runtime/arcane/modules/Mail.js +738 -115
- package/runtime/arcane/modules/MailOutbox.mjs +1395 -0
- package/runtime/arcane/modules/MailTransport.mjs +197 -39
- package/runtime/arcane/modules/Ollama.js +36 -1
- package/runtime/arcane/modules/OpenMeteoWeatherProvider.js +583 -7
- package/runtime/arcane/modules/PreferenceStore.js +367 -33
- package/runtime/arcane/modules/RecordReviewStore.js +322 -23
- package/runtime/arcane/modules/ScreenCapture.js +1397 -15
- package/runtime/arcane/modules/SpeechPlayback.js +438 -41
- package/runtime/arcane/modules/TerminalClient.js +277 -12
- package/runtime/arcane/modules/ThemeBootstrap.js +80 -6
- package/runtime/arcane/modules/ThemeManager.js +39 -7
- package/runtime/arcane/modules/TimeGuard.js +131 -20
- package/runtime/arcane/modules/WaitForComponent.js +386 -33
- package/schemas/arcane-lock.schema.json +2 -2
- package/src/cli/main.mjs +435 -9
- package/src/event-manager.mjs +1097 -1
- package/src/import-map.mjs +21 -3
- package/src/index.mjs +13 -0
- package/src/installed-sdk-runtime.mjs +130 -0
- package/src/mail-api.mjs +22 -0
- package/src/mail-credentials.mjs +667 -0
- package/src/mail-server.mjs +1769 -0
- package/src/mail.mjs +261 -0
- package/src/sdk-browser-runtime.mjs +85 -41
- package/src/testing-loader.mjs +7 -0
- package/src/toolchain.mjs +3 -0
- package/src/workspace-runtime.mjs +804 -22
- package/src/workspace.mjs +1 -1
|
@@ -13,6 +13,29 @@ Apps import renderer ESM from `/arcane/modules/<file>`. Classic scripts, the OPF
|
|
|
13
13
|
- **Cloud** means the module can call an explicitly configured remote provider; it never implies automatic local-to-cloud fallback.
|
|
14
14
|
- **Node**, **worker**, and **vendor** identify specialized runtimes.
|
|
15
15
|
|
|
16
|
+
## Runtime semantic events and teardown
|
|
17
|
+
|
|
18
|
+
SDK runtime modules publish semantic state and lifecycle occurrences through the
|
|
19
|
+
one branded, versioned `globalThis.arcaneEvents` authority in each JavaScript
|
|
20
|
+
realm. A class can retain its existing `EventTarget` or `on()` compatibility
|
|
21
|
+
surface, but that surface delegates to a `createArcaneEventSource()` view scoped
|
|
22
|
+
by the module's source and instance identifiers; it does not own a second event
|
|
23
|
+
bus, listener `Map`, or listener `Set`. Every canonical occurrence and every
|
|
24
|
+
one-way DOM compatibility projection carries an occurrence ID. DOM input events
|
|
25
|
+
remain local UI/platform input, and projected DOM `CustomEvent`s must not be
|
|
26
|
+
mirrored back into the canonical source.
|
|
27
|
+
|
|
28
|
+
`arcaneEvents.subscribe(type,handler,{once,signal})` and source-scoped
|
|
29
|
+
`subscribe()`/`on()` registrations return one idempotent unsubscribe function
|
|
30
|
+
(also exposed as `.dispose`). The singleton's legacy `on()`/`once()` methods are
|
|
31
|
+
chainable compatibility APIs that return the manager; lifecycle-owned consumers
|
|
32
|
+
use `subscribe()`. Instance `dispose()`/`destroy()` methods remove owned
|
|
33
|
+
listeners, abort owned work, suppress stale settlement, and dispose the instance
|
|
34
|
+
source. Module-lifetime singleton sources instead expose a focused module
|
|
35
|
+
teardown function where teardown is supported. Event publication is synchronous
|
|
36
|
+
and observational; promises, `AbortSignal`, and `createEventQueue` continue to
|
|
37
|
+
own asynchronous work, cancellation, and backpressure.
|
|
38
|
+
|
|
16
39
|
## Canonical inventory
|
|
17
40
|
|
|
18
41
|
| Module | Kind | Capability | Availability | Normalization |
|
|
@@ -64,6 +87,7 @@ Apps import renderer ESM from `/arcane/modules/<file>`. Classic scripts, the OPF
|
|
|
64
87
|
| [`LocalAIReadiness.js`](#localaireadinessjs) | esm | Derives selected AI requirements and returns a frozen readiness/recovery report across browser, desktop, and Android modes. | Browser/native hybrid | Fully normalized report and stable error codes; browsers never probe Ollama. |
|
|
65
88
|
| [`LocalAIReadinessController.js`](#localaireadinesscontrollerjs) | esm | Coordinates local-AI status component checks, ensured recovery, availability projection, and teardown. | Browser/native hybrid | Normalized controller state and change events. |
|
|
66
89
|
| [`Mail.js`](#mailjs) | esm | Builds bounded reports and prefers the native mail capability with an explicit HTTP transport fallback. | Browser/native hybrid + cloud | Mail inputs/results normalized; transport failures mixed. |
|
|
90
|
+
| [`MailOutbox.mjs`](#mailoutboxmjs) | esm | Persists bounded mail reports before delivery and normalizes idempotent enqueue, retry, reconciliation, and invalid-record maintenance. | Browser/native WebView or compatible injected host | Frozen records, bounded work, cancellation, and lifecycle states normalized; storage, lock, and delivery failures coded. |
|
|
67
91
|
| [`MailTransport.mjs`](#mailtransportmjs) | esm | Sends one bounded mail report to a normalized HTTP(S) endpoint with timeout and response-size limits. | Browser/server with fetch + cloud | Normalized endpoint/timeout/size errors; remote detail bounded. |
|
|
68
92
|
| [`Marked.min.js`](#markedminjs) | esm | Vendored Marked 18.0.5 Markdown lexer, parser, renderer, extension, and walk-token API. | Cross-host vendor module | Vendor-native Marked contract. |
|
|
69
93
|
| [`MD.js`](#mdjs) | esm | Renders Markdown with Marked and exposes a DOM-sanitized projection. | Browser / native WebView | Raw Marked behavior plus Arcane sanitization; parse errors vendor-native. |
|
|
@@ -111,10 +135,13 @@ Provider-selectable chat, speech-to-text, text-to-speech, tool calling, structur
|
|
|
111
135
|
|
|
112
136
|
### Public surface
|
|
113
137
|
|
|
114
|
-
default `AI`; read-only `providerRuntime
|
|
115
|
-
`
|
|
138
|
+
default `AI`; read-only `providerRuntime`, `browserSpeechConfiguration`, and
|
|
139
|
+
`browserSpeechDescriptor`; `configureBrowserSpeech(configuration,{signal})`,
|
|
140
|
+
`disposeBrowserSpeech({signal})`, `setAI()`, `configureProviders()`,
|
|
141
|
+
`configureSpeechProviders()`, `transitionAI()`, `transitionProviders()`,
|
|
142
|
+
`transitionSpeechProviders()`, `startProviders()`, `setSpeechMuted()`,
|
|
116
143
|
`streamRequest()`, `streamMessage()`, `fetchRequest()`, `fetch()`,
|
|
117
|
-
`streamTTS()`, `finishTTS()`, `fetchSTT()`, `stopAudio()`, `resumeAudio()`,
|
|
144
|
+
`streamTTS()`, `finishTTS()`, `fetchTTS()`, `fetchSTT()`, `stopAudio()`, `resumeAudio()`,
|
|
118
145
|
`playAudio()`; consumes `user-entity-loaded` and `arcane-ollama-ready`,
|
|
119
146
|
installs `window.ai`, and emits `ai-ready`.
|
|
120
147
|
|
|
@@ -138,18 +165,200 @@ the exact selected provider/model catalog `defaultVoice`; a saved OpenAI voice
|
|
|
138
165
|
is used only by the selected OpenAI adapter and is never forwarded to another
|
|
139
166
|
provider route.
|
|
140
167
|
|
|
168
|
+
`configureSpeechProviders({stt,tts})` commits only the two speech routes and
|
|
169
|
+
leaves the current LLM route and sticky lifecycle record unchanged. Both speech
|
|
170
|
+
roles must be unloaded and own no request, load, unload, or dispose operation.
|
|
171
|
+
`transitionSpeechProviders({stt,tts})` stops queued audio, explicitly unloads
|
|
172
|
+
only STT and TTS, then commits that same closed speech route record. Neither
|
|
173
|
+
method loads a model, selects a fallback, or changes caller-owned model or voice
|
|
174
|
+
policy.
|
|
175
|
+
|
|
141
176
|
`startProviders({startMuted=true,startTranscription=false,signal=null}={})`
|
|
142
177
|
starts text chat without requesting an STT load by default; it does not undo an
|
|
143
|
-
already ready or independently loading
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
178
|
+
already ready or independently loading LLM or STT role. Its default
|
|
179
|
+
`startMuted:true` path cancels active TTS work and unloads TTS. Callers must opt
|
|
180
|
+
into eager STT startup with `startTranscription:true` or publish the explicit
|
|
181
|
+
user activation intent exposed by the shared speech component.
|
|
182
|
+
`setSpeechMuted(false)` records the public unmuted state only after the selected
|
|
183
|
+
TTS route reaches ready; a failed load leaves the public state muted. In contrast,
|
|
147
184
|
`setSpeechMuted(true)` cancels active TTS work and unloads that role.
|
|
185
|
+
`fetchTTS({model,voice,input,responseFormat,speed},signal)` accepts the public
|
|
186
|
+
provider-neutral synthesis shape, requires any explicit model to match the
|
|
187
|
+
admitted route, and admits an omitted voice only from the selected model
|
|
188
|
+
catalog's `defaultVoice`. An omitted response format preserves the instance's
|
|
189
|
+
existing `audioFormat` for a compatibility-only catalog. When the selected model
|
|
190
|
+
declares `speech.responseFormats`, that setting is used only when admitted; if
|
|
191
|
+
the setting is the legacy `opus` default and the model rejects it, the catalog's
|
|
192
|
+
`speech.defaultResponseFormat` is used, while any other unsupported setting is
|
|
193
|
+
rejected. It propagates the caller-owned signal and returns a playable `Blob`;
|
|
194
|
+
it does not independently choose a provider, cloud fallback, model, runtime, or
|
|
195
|
+
voice policy for the application. Existing `streamTTS()` and `finishTTS()` use
|
|
196
|
+
this same request boundary.
|
|
148
197
|
`fetchSTT(audioFile,responseHandler,signal)` propagates the caller-owned signal;
|
|
198
|
+
provider routes accept a `Blob` or `File` directly and leave media decoding,
|
|
199
|
+
PCM normalization, and WAV construction to the selected shared provider;
|
|
149
200
|
delivery suppression is guaranteed after abort, while underlying provider-stop
|
|
150
201
|
claims remain limited to that provider's cancellation contract.
|
|
151
202
|
|
|
152
|
-
|
|
203
|
+
#### Browser speech configuration
|
|
204
|
+
|
|
205
|
+
The caller constructs a frozen authority record for one or both roles and
|
|
206
|
+
retains ownership of it. This example configures both:
|
|
207
|
+
|
|
208
|
+
```javascript
|
|
209
|
+
import AI, {
|
|
210
|
+
AI_BROWSER_SPEECH_CONFIGURATION_PROTOCOL
|
|
211
|
+
} from '/arcane/modules/AI.js';
|
|
212
|
+
|
|
213
|
+
const speechConfiguration = Object.freeze({
|
|
214
|
+
protocol: AI_BROWSER_SPEECH_CONFIGURATION_PROTOCOL,
|
|
215
|
+
id: 'app-speech-authority',
|
|
216
|
+
dbopfs,
|
|
217
|
+
tableName: 'browser-speech-artifacts', // optional
|
|
218
|
+
stt: Object.freeze({
|
|
219
|
+
providerId: 'app-whisper',
|
|
220
|
+
graph: sttGraph,
|
|
221
|
+
security: Object.freeze({secure: true}),
|
|
222
|
+
offline: false
|
|
223
|
+
}),
|
|
224
|
+
tts: Object.freeze({
|
|
225
|
+
providerId: 'app-kokoro',
|
|
226
|
+
graph: ttsGraph,
|
|
227
|
+
security: Object.freeze({secure: true}),
|
|
228
|
+
offline: false
|
|
229
|
+
})
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
const ai = new AI(/* existing application AI preferences */);
|
|
233
|
+
const descriptor = await ai.configureBrowserSpeech(
|
|
234
|
+
speechConfiguration,
|
|
235
|
+
{signal}
|
|
236
|
+
);
|
|
237
|
+
|
|
238
|
+
// Configuration does not load either role. Activate only from an explicit UI.
|
|
239
|
+
await ai.providerRuntime.load('stt', {signal});
|
|
240
|
+
await ai.setSpeechMuted(false); // loads the selected TTS role, then unmutes
|
|
241
|
+
|
|
242
|
+
// Teardown unloads, unregisters, and disposes only this SDK-owned configuration.
|
|
243
|
+
await ai.disposeBrowserSpeech({signal});
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
The record must be a frozen plain data record with exactly
|
|
247
|
+
`{protocol,id,dbopfs,tableName?,stt?,tts?}` and at least one role. Each supplied
|
|
248
|
+
frozen role is exactly `{providerId,graph,security,offline}` or
|
|
249
|
+
`{providerId,model,runtime,security?,offline}`. The graph and direct authority
|
|
250
|
+
forms are mutually exclusive; `providerId` and `id` are trimmed 1-128 character
|
|
251
|
+
strings, `graph` is the role-matching frozen graph returned by the SDK browser
|
|
252
|
+
speech artifact API, graph `security` must explicitly select `secure:true`, and
|
|
253
|
+
`offline` is boolean. The direct form forwards its
|
|
254
|
+
caller-selected model, runtime, and optional security descriptors to the shared
|
|
255
|
+
provider. In warn-first mode it may use an empty `model.files` inventory and a
|
|
256
|
+
version-pinned upstream `runtime.wasmPaths`; secure graph mode remains the
|
|
257
|
+
closed, content-addressed path. The application chooses every artifact,
|
|
258
|
+
immutable graph or direct model/runtime authority, provider ID, offline policy,
|
|
259
|
+
sample rate, and TTS default voice. `configureBrowserSpeech()` imports the shared
|
|
260
|
+
browser-speech module, creates one DBOPFS store, constructs and registers the
|
|
261
|
+
supplied Whisper and/or Kokoro provider/2 instances, atomically replaces only
|
|
262
|
+
the supplied STT/TTS routes, and returns a frozen descriptor. An initial or
|
|
263
|
+
later call may supply only `stt` or only `tts`; the omitted external Cloud/Core
|
|
264
|
+
role remains unchanged and is not claimed as SDK browser-provider ownership.
|
|
265
|
+
A partial replacement of an existing browser-managed record retains the same
|
|
266
|
+
`dbopfs` and `tableName`, carries every omitted managed browser provider and
|
|
267
|
+
route unchanged, and unregisters and disposes only the replaced provider after
|
|
268
|
+
commit. Supplying both roles remains one atomic replacement. Applications do not register those
|
|
269
|
+
providers, decode `Blob`/`File` data into PCM, construct WAV, select Worker URLs,
|
|
270
|
+
or reproduce DBOPFS cache or artifact verification logic.
|
|
271
|
+
|
|
272
|
+
The returned descriptor is exactly `{protocol,configurationId,stt,tts}`; an
|
|
273
|
+
external, unmanaged role is `null`. A managed STT descriptor is
|
|
274
|
+
`{role:'stt',providerId,modelId,artifactGraphId?,offline}`; TTS adds
|
|
275
|
+
`defaultVoice`. `artifactGraphId` is present only for the graph form.
|
|
276
|
+
`browserSpeechConfiguration` returns the exact caller-owned record when no
|
|
277
|
+
managed role is carried. After a partial replacement that carries another
|
|
278
|
+
managed role, it returns a frozen merged record with the replacement call's
|
|
279
|
+
`id` and the carried role's unchanged authority. It is non-null only while the
|
|
280
|
+
SDK still owns every represented browser provider and route;
|
|
281
|
+
`browserSpeechDescriptor` returns that descriptor on the same condition.
|
|
282
|
+
Configuration never loads a role, auto-downloads, selects an alternative
|
|
283
|
+
provider/model/runtime/voice, or falls back to cloud/browser speech.
|
|
284
|
+
|
|
285
|
+
Calling `configureBrowserSpeech()` again with the same active record for every
|
|
286
|
+
supplied role is an idempotent descriptor read. A different call is serialized,
|
|
287
|
+
aborts the prior owned operation, unloads only the replaced speech roles, atomically
|
|
288
|
+
replaces provider ownership/routes, and suppresses stale settlement. A
|
|
289
|
+
single-role replacement does not reconstruct, unregister, dispose, or reroute
|
|
290
|
+
the omitted role or change its ready/selected state, provider identity,
|
|
291
|
+
operation generation, or lifecycle. STT-only replacement also preserves TTS
|
|
292
|
+
mute and playback state; TTS replacement invalidates current TTS speech control
|
|
293
|
+
before replacing that role. The caller's signal is
|
|
294
|
+
forwarded and detached on settlement. Cancellation proves delivery suppression,
|
|
295
|
+
not that provider work stopped beyond the provider's own cancellation contract.
|
|
296
|
+
Once SDK-owned browser speech is active, synchronous route mutation fails with
|
|
297
|
+
`ARCANE_AI_BROWSER_SPEECH_ASYNC_TRANSITION_REQUIRED`; use an asynchronous
|
|
298
|
+
transition method or await `disposeBrowserSpeech()`.
|
|
299
|
+
|
|
300
|
+
Browser speech publishes these exact event values through the AI instance's
|
|
301
|
+
canonical event source. Public consumers use
|
|
302
|
+
`arcaneEvents.subscribe(type,handler,{signal})`; `handler(occurrence)` receives
|
|
303
|
+
the frozen canonical occurrence and can correlate `source:'ai'`, `instanceId`,
|
|
304
|
+
and `operationId`:
|
|
305
|
+
|
|
306
|
+
| Constant member | Stable value |
|
|
307
|
+
| --- | --- |
|
|
308
|
+
| `configurationStarted` | `ai-browser-speech-configuration-started` |
|
|
309
|
+
| `configured` | `ai-browser-speech-configured` |
|
|
310
|
+
| `configurationCancelled` | `ai-browser-speech-configuration-cancelled` |
|
|
311
|
+
| `configurationError` | `ai-browser-speech-configuration-error` |
|
|
312
|
+
| `disposed` | `ai-browser-speech-disposed` |
|
|
313
|
+
|
|
314
|
+
Canonical public details are frozen and contain `configurationId`, optional
|
|
315
|
+
`descriptor`, optional exact `code`, and `reason`. The private source-local
|
|
316
|
+
compatibility view also carries the caller-owned configuration and optional
|
|
317
|
+
error, but `AI` does not expose that source handle and the global occurrence
|
|
318
|
+
does not publish those private values. Reasons are exactly `speech-configuration-added`,
|
|
319
|
+
`speech-configuration-replaced`, `speech-configuration-cancelled`,
|
|
320
|
+
`speech-configuration-disposed`, `speech-configuration-contract-mismatch`,
|
|
321
|
+
`speech-configuration-async-transition-required`,
|
|
322
|
+
`speech-operation-options-contract-mismatch`,
|
|
323
|
+
`speech-operation-sequence-exhausted`, `speech-module-import-rejected`,
|
|
324
|
+
`speech-artifact-store-construction-rejected`,
|
|
325
|
+
`speech-provider-construction-rejected`, `speech-provider-disposal-rejected`,
|
|
326
|
+
`speech-provider-route-ownership-mismatch`,
|
|
327
|
+
`speech-provider-unregistration-rejected`, `speech-route-commit-rejected`,
|
|
328
|
+
`speech-route-rollback-rejected`, and `speech-route-view-update-rejected`.
|
|
329
|
+
Their corresponding exact public codes are the values of
|
|
330
|
+
`AI_BROWSER_SPEECH_ERROR_CODES`: `ARCANE_AI_BROWSER_SPEECH_CONFIGURATION_CANCELLED`,
|
|
331
|
+
`ARCANE_AI_BROWSER_SPEECH_CONFIGURATION_SUPERSEDED`,
|
|
332
|
+
`ARCANE_AI_BROWSER_SPEECH_CONFIGURATION_CONTRACT_MISMATCH`,
|
|
333
|
+
`ARCANE_AI_BROWSER_SPEECH_ASYNC_TRANSITION_REQUIRED`,
|
|
334
|
+
`ARCANE_AI_BROWSER_SPEECH_OPERATION_OPTIONS_CONTRACT_MISMATCH`,
|
|
335
|
+
`ARCANE_AI_BROWSER_SPEECH_OPERATION_SEQUENCE_EXHAUSTED`,
|
|
336
|
+
`ARCANE_AI_BROWSER_SPEECH_MODULE_IMPORT_REJECTED`,
|
|
337
|
+
`ARCANE_AI_BROWSER_SPEECH_ARTIFACT_STORE_CONSTRUCTION_REJECTED`,
|
|
338
|
+
`ARCANE_AI_BROWSER_SPEECH_PROVIDER_CONSTRUCTION_REJECTED`,
|
|
339
|
+
`ARCANE_AI_BROWSER_SPEECH_PROVIDER_DISPOSAL_REJECTED`,
|
|
340
|
+
`ARCANE_AI_BROWSER_SPEECH_PROVIDER_ROUTE_OWNERSHIP_MISMATCH`,
|
|
341
|
+
`ARCANE_AI_BROWSER_SPEECH_PROVIDER_UNREGISTRATION_REJECTED`,
|
|
342
|
+
`ARCANE_AI_BROWSER_SPEECH_ROUTE_COMMIT_REJECTED`,
|
|
343
|
+
`ARCANE_AI_BROWSER_SPEECH_ROUTE_ROLLBACK_REJECTED`, and
|
|
344
|
+
`ARCANE_AI_BROWSER_SPEECH_ROUTE_VIEW_UPDATE_REJECTED`.
|
|
345
|
+
|
|
346
|
+
`fetchTTS()` rejects malformed request/signal/input/model/voice/format/speed
|
|
347
|
+
boundaries with `ARCANE_AI_TTS_REQUEST_INVALID`,
|
|
348
|
+
`ARCANE_AI_TTS_SIGNAL_INVALID`, `ARCANE_AI_TTS_INPUT_INVALID`,
|
|
349
|
+
`ARCANE_AI_TTS_MODEL_INVALID`, `ARCANE_AI_TTS_MODEL_REQUIRED`,
|
|
350
|
+
`ARCANE_AI_TTS_MODEL_SELECTION_MISMATCH`, `ARCANE_AI_TTS_VOICE_INVALID`,
|
|
351
|
+
`ARCANE_AI_TTS_VOICE_REQUIRED`, `ARCANE_AI_TTS_RESPONSE_FORMAT_INVALID`, or
|
|
352
|
+
`ARCANE_AI_TTS_SPEED_INVALID`; a non-playable provider result is
|
|
353
|
+
`ARCANE_AI_TTS_PROVIDER_AUDIO_INVALID`. `fetchSTT()` uses
|
|
354
|
+
`ARCANE_AI_STT_RESPONSE_HANDLER_INVALID`, `ARCANE_AI_STT_SIGNAL_INVALID`, and
|
|
355
|
+
`ARCANE_AI_STT_PROVIDER_TRANSCRIPT_INVALID` at those exact boundaries. Owned
|
|
356
|
+
request abortion is `ARCANE_AI_REQUEST_ABORTED`.
|
|
357
|
+
|
|
358
|
+
Exact exports: `AI_BROWSER_SPEECH_CONFIGURATION_PROTOCOL`,
|
|
359
|
+
`AI_BROWSER_SPEECH_ERROR_CODES`, `AI_BROWSER_SPEECH_EVENT_TYPES`,
|
|
360
|
+
`AI_BROWSER_SPEECH_REASONS`, `AI_INITIALIZATION_ERROR_CODES`,
|
|
361
|
+
`AI_INITIALIZATION_REASONS`, `AI_READY_EVENT`, and `default`.
|
|
153
362
|
|
|
154
363
|
### Availability and normalization
|
|
155
364
|
|
|
@@ -160,11 +369,7 @@ Arcane.speech, and the Android WebView bridge. [Deep protocol details](protocols
|
|
|
160
369
|
|
|
161
370
|
### Example
|
|
162
371
|
|
|
163
|
-
|
|
164
|
-
import * as module from '/arcane/modules/AI.js';
|
|
165
|
-
|
|
166
|
-
console.log(Object.keys(module));
|
|
167
|
-
```
|
|
372
|
+
The configuration example above is the minimal one-time application flow.
|
|
168
373
|
|
|
169
374
|
## AIPreferenceRuntime.js
|
|
170
375
|
|
|
@@ -226,20 +431,78 @@ shape, but application code uses the exported singleton returned by
|
|
|
226
431
|
|
|
227
432
|
### Public surface
|
|
228
433
|
|
|
229
|
-
Exact exports: `
|
|
230
|
-
`
|
|
434
|
+
Exact exports: `AI_MODEL_AUTHORITY_PROTOCOL`, `AI_PROVIDER_PROTOCOL`,
|
|
435
|
+
`AI_PROVIDER_RUNTIME_PROTOCOL`, `AIProviderRuntime`, `aiProviderRuntime`, and
|
|
231
436
|
`getAIProviderRuntime`.
|
|
232
437
|
|
|
233
|
-
The singleton exposes
|
|
234
|
-
|
|
235
|
-
`
|
|
236
|
-
`
|
|
438
|
+
The singleton exposes read-only `protocol`, `configured`, and `speechMuted`;
|
|
439
|
+
`register(provider)`; `unregister(role,providerId,expectedProvider=null)`;
|
|
440
|
+
`hasProvider(role,providerId)`; `ownsProvider(role,expectedProvider)`;
|
|
441
|
+
`providerIdentity(role,providerId)`; `selection(role,options={})`;
|
|
442
|
+
`ownsSelection(role,providerId,options={})`;
|
|
443
|
+
`validateConfiguration(value)`; `validateSpeechConfiguration(value)`;
|
|
444
|
+
`configure(value)`; `configureSpeech(value)`;
|
|
445
|
+
`replaceSpeechProvider(role,value)`; `replaceSpeechProviders(value)`;
|
|
446
|
+
`configureFromTuple(tuple)`;
|
|
447
|
+
`status(role=null)`; `catalog(role)`;
|
|
448
|
+
`inspect(role,options={})`; `start(options)`; `load(role,options={})`;
|
|
449
|
+
`unload(role,options={})`; `dispose(role,options={})`;
|
|
450
|
+
`disposeAll(options={})`; `cancel(role)`; `request(role,options={})`;
|
|
451
|
+
`chat(payload,options={})`; `stream(payload,options={})`;
|
|
452
|
+
`transcribe(payload,options={})`; `synthesize(payload,options={})`; and
|
|
453
|
+
`setSpeechMuted(muted)`. Provider payloads must
|
|
237
454
|
be data-only; callbacks, accessors, symbols, cycles, and excessive nesting are
|
|
238
455
|
rejected at the provider boundary.
|
|
239
456
|
|
|
240
|
-
`
|
|
241
|
-
|
|
242
|
-
|
|
457
|
+
Selection options admit `localOnly=false`; inspection admits
|
|
458
|
+
`{localOnly=false,signal=null}`; startup admits
|
|
459
|
+
`{startMuted=true,startTranscription=false,signal=null}` (including an omitted
|
|
460
|
+
`options` value); load admits `{signal=null,localOnly=false}`; unload, dispose,
|
|
461
|
+
and dispose-all admit `{signal=null}`. Request requires the exact
|
|
462
|
+
`{operation,payload,localOnly,signal}` options record; the four role-specific
|
|
463
|
+
request helpers admit `{localOnly=false,signal=null}`. Configuration `value`
|
|
464
|
+
records are the closed `{llm,stt,tts}`, `{stt,tts}`, or
|
|
465
|
+
`{provider,routes,expectedProvider}` and
|
|
466
|
+
`{providers,routes,expectedProviders}` shapes described below.
|
|
467
|
+
`configureFromTuple()` accepts exactly six provider/model preference entries.
|
|
468
|
+
|
|
469
|
+
`register()` returns the provider's single unregister closure; caller-
|
|
470
|
+
registered providers remain caller-owned. The high-level
|
|
471
|
+
`AI.configureBrowserSpeech()` boundary is different: AI constructs, registers,
|
|
472
|
+
atomically replaces, unregisters, and disposes those two SDK-owned providers.
|
|
473
|
+
`status()` is the sticky frozen AIRuntimeState snapshot (or one role record),
|
|
474
|
+
while `catalog()` synchronously returns frozen provider/model admissions and
|
|
475
|
+
never loads or downloads a model. `load()` forwards provider progress into the
|
|
476
|
+
sticky role record; `unload()` and `dispose()` abort owned work, await exposed
|
|
477
|
+
settlement, and verify provider status before publishing terminal state.
|
|
478
|
+
|
|
479
|
+
`validateSpeechConfiguration(value)` returns one frozen two-role selection
|
|
480
|
+
record without committing it, where `value` is the closed `{stt,tts}` record.
|
|
481
|
+
`configureSpeech(value)` accepts the same record, requires both speech roles to
|
|
482
|
+
own no ready/load/unload/dispose or request work, commits only STT/TTS, restores
|
|
483
|
+
muted speech admission, and returns the frozen selection record. The current LLM
|
|
484
|
+
routes, selection, readiness, operation generation, and sticky state remain
|
|
485
|
+
unchanged. A malformed top-level, route, or selection record preserves the
|
|
486
|
+
compatibility code
|
|
487
|
+
`ARCANE_AI_PROVIDER_RUNTIME_INVALID` and adds exact reason
|
|
488
|
+
`speech-configuration-contract-mismatch`; runtime-disposed, reentrant,
|
|
489
|
+
role-busy, and provider-locality failures retain their existing exact codes.
|
|
490
|
+
|
|
491
|
+
`replaceSpeechProvider(role,value)` accepts only `stt` or `tts` and atomically
|
|
492
|
+
replaces exactly that unloaded role using the closed
|
|
493
|
+
`{provider,routes,expectedProvider}` record. A null `provider` with empty routes
|
|
494
|
+
removes that role and requires its exact non-null expected provider. The method preserves the omitted role's
|
|
495
|
+
provider registration, routes, selection, readiness, generation, sticky state,
|
|
496
|
+
owned lifecycle work, and TTS mute state. `replaceSpeechProviders(value)` keeps
|
|
497
|
+
the existing atomic two-role boundary for a coordinated STT/TTS replacement.
|
|
498
|
+
Either replacement may hydrate an exact selected-but-unregistered speech route
|
|
499
|
+
whose saved locality is still `null`, but only when provider id, model id, and
|
|
500
|
+
every pending route agree with the replacement. Registration and route
|
|
501
|
+
publication remain one commit; a mismatched, already registered, local-only,
|
|
502
|
+
busy, or partially divergent selection rejects without changing either role.
|
|
503
|
+
|
|
504
|
+
`start(options)` waits for prior speech-state and role unload work, applies the
|
|
505
|
+
requested initial mute state, and returns the `startAIRuntime()` control handle
|
|
243
506
|
`{barrier,settled,cancel}`. Startup does not request selected STT unless the
|
|
244
507
|
caller explicitly opts in; it does not force an independently active STT role
|
|
245
508
|
back to unloaded. The barrier and settled promises describe provider-startup
|
|
@@ -259,14 +522,16 @@ request ownership is active.
|
|
|
259
522
|
|
|
260
523
|
### Availability and normalization
|
|
261
524
|
|
|
262
|
-
**Cross-host runtime with provider-specific execution.**
|
|
263
|
-
|
|
525
|
+
**Cross-host runtime with provider-specific execution.** The SDK source ships
|
|
526
|
+
the browser-WASM LLM and browser Whisper/Kokoro adapters and supplies the
|
|
264
527
|
narrow AI.js legacy OpenAI/Ollama/Core-speech adapters; other native, Core, or
|
|
265
528
|
cloud adapters may be supplied externally only when they implement the same
|
|
266
529
|
`arcane-ai-provider/2` boundary. A
|
|
267
530
|
provider must prove a matching `arcane-ai-model-authority/1` inspection before load.
|
|
268
531
|
`localOnly` routing fails closed; it never selects a cloud or non-local route as
|
|
269
|
-
a fallback.
|
|
532
|
+
a fallback. A missing or mismatched explicit local-only route rejects load or
|
|
533
|
+
request admission with `AI_LOCAL_MODEL_REQUIRED`. Role lifecycle and stream
|
|
534
|
+
cleanup are normalized, while the
|
|
270
535
|
selected provider retains its own capability, permission, download, and model
|
|
271
536
|
requirements. [Deep protocol details](protocols.md#portable-ai-provider-runtime).
|
|
272
537
|
|
|
@@ -337,15 +602,21 @@ observable without exposing provider transports in application code.
|
|
|
337
602
|
|
|
338
603
|
### Public surface
|
|
339
604
|
|
|
340
|
-
Exact exports: `
|
|
341
|
-
`
|
|
342
|
-
`
|
|
343
|
-
`
|
|
344
|
-
`
|
|
345
|
-
`
|
|
605
|
+
Exact exports: `AI_RUNTIME_INTENT_EVENT`, `AI_RUNTIME_PROTOCOL`,
|
|
606
|
+
`AI_RUNTIME_ROLES`, `AI_RUNTIME_STARTUP_EVENT`, `AI_RUNTIME_STATES`,
|
|
607
|
+
`AI_RUNTIME_STATE_EVENT`, `aiRuntimeEvents`, `getAIRuntimeState`,
|
|
608
|
+
`publishAIRuntimeRoleState`, `publishAIRuntimeRolesState`,
|
|
609
|
+
`requestAIRuntimeIntent`, `startAIRuntime`, `subscribeAIRuntimeIntents`, and
|
|
610
|
+
`subscribeAIRuntimeState`.
|
|
346
611
|
|
|
347
612
|
Each role record is exactly `{role,state,providerId,modelId,localOnly,loaded,
|
|
348
613
|
busy,operationId,progress,error}`.
|
|
614
|
+
`subscribeAIRuntimeState(listener,{signal=null,emitCurrent=true})` installs its
|
|
615
|
+
subscription and synchronously replays the current frozen snapshot by default;
|
|
616
|
+
`subscribeAIRuntimeIntents(listener,{signal=null})` is future-only. Both return
|
|
617
|
+
one idempotent unsubscribe/dispose closure. `aiRuntimeEvents` is a deprecated,
|
|
618
|
+
state-free EventTarget compatibility view over the same canonical source; it is
|
|
619
|
+
not a second authority and owns no listener registry.
|
|
349
620
|
`startAIRuntime({startMuted=true,startTranscription=false,signal})` returns
|
|
350
621
|
`{barrier,settled,cancel}`: `barrier` settles for text chat, while `settled`
|
|
351
622
|
covers every requested role. Muted startup does not request TTS, and STT startup
|
|
@@ -362,6 +633,11 @@ does not grant a native capability, prove browser support, or load a provider.
|
|
|
362
633
|
`arcane-ai-runtime-startup-settled` reports the LLM/text-chat `barrier`.
|
|
363
634
|
Await the returned `handle.settled` promise for every role requested by that
|
|
364
635
|
startup; the all-role settlement has no separate public event.
|
|
636
|
+
Intent records are exactly `{role,action,reason}` where roles are `llm`, `stt`,
|
|
637
|
+
or `tts`; actions are `load`, `unload`, or `dispose`; and reasons are `startup`,
|
|
638
|
+
`user`, or `teardown`. Invalid closed records fail with the stable prefix
|
|
639
|
+
`ARCANE_AI_RUNTIME_STATE_INVALID`; startup cancellation is an `AbortError` with
|
|
640
|
+
code `ARCANE_AI_REQUEST_ABORTED`.
|
|
365
641
|
|
|
366
642
|
### Example
|
|
367
643
|
|
|
@@ -412,7 +688,8 @@ Fetches an injectable HTTP JSON model with parser, cache, redacted public endpoi
|
|
|
412
688
|
|
|
413
689
|
default `ApiModelDatabase`; `setEndpoint()`, `fetch()`, `cached()`; emits `api-model-request`, `api-model-success`, and `api-model-error`.
|
|
414
690
|
|
|
415
|
-
Exact exports: `
|
|
691
|
+
Exact exports: `API_MODEL_ERRORS`, `API_MODEL_EVENTS`, `appendParameters`,
|
|
692
|
+
`default`, `publicEndpoint`.
|
|
416
693
|
|
|
417
694
|
### Availability and normalization
|
|
418
695
|
|
|
@@ -580,7 +857,9 @@ Runs a fixed sequential browser test list with cooperative abort, per-test timeo
|
|
|
580
857
|
|
|
581
858
|
default `BrowserTestSuite`; `list()`, `run()`; emits suite/test start/result/complete events.
|
|
582
859
|
|
|
583
|
-
Exact exports: `
|
|
860
|
+
Exact exports: `BROWSER_TEST_SUITE_ERROR_CODES`,
|
|
861
|
+
`BROWSER_TEST_SUITE_EVENT_TYPES`, `BROWSER_TEST_SUITE_REASONS`,
|
|
862
|
+
`assertionError`, `default`, `skipError`.
|
|
584
863
|
|
|
585
864
|
### Availability and normalization
|
|
586
865
|
|
|
@@ -602,13 +881,40 @@ Evaluates bounded arithmetic, powers, constants, and common functions without `e
|
|
|
602
881
|
|
|
603
882
|
### Public surface
|
|
604
883
|
|
|
605
|
-
|
|
884
|
+
`new CalculatorEngine()` exposes synchronous
|
|
885
|
+
`calculate(expression): Calculation`,
|
|
886
|
+
`addEventListener(type,listener,options): void`,
|
|
887
|
+
`removeEventListener(type,listener,options): void`,
|
|
888
|
+
`on(type,listener,options): unsubscribe`,
|
|
889
|
+
`dispatchEvent(event): boolean`, and idempotent
|
|
890
|
+
`dispose(): boolean` / `destroy(): boolean`. `evaluateExpression(input): number`
|
|
891
|
+
remains the parser-only helper. `CALCULATOR_ENGINE_ERROR_CODES` is one frozen
|
|
892
|
+
record containing the stable `disposed`, `input`, `syntax`, `domain`, and
|
|
893
|
+
`evaluation` codes.
|
|
606
894
|
|
|
607
|
-
Exact exports: `
|
|
895
|
+
Exact exports: `CALCULATOR_ENGINE_ERROR_CODES`, `default`,
|
|
896
|
+
`evaluateExpression`.
|
|
608
897
|
|
|
609
898
|
### Availability and normalization
|
|
610
899
|
|
|
611
|
-
**Cross-host.**
|
|
900
|
+
**Cross-host.** Each engine owns one `calculator-engine` source on the realm's
|
|
901
|
+
branded `globalThis.arcaneEvents`. `calculator-result` publishes frozen public
|
|
902
|
+
detail `{result}`; the legacy instance listener receives the same `Calculation`
|
|
903
|
+
object returned by `calculate()`. `calculator-error` publishes frozen public
|
|
904
|
+
detail `{code}`; the legacy listener receives frozen
|
|
905
|
+
`{expression,error}` while `calculate()` rethrows that same `Error`. Both
|
|
906
|
+
occurrences carry one source-instance `operationId`. Listener callbacks are
|
|
907
|
+
synchronous observations; their failures are reported by the central event
|
|
908
|
+
authority and do not rewrite calculation settlement. Listener registration
|
|
909
|
+
supports `{once,signal}` and its returned unsubscribe also exposes `.dispose()`.
|
|
910
|
+
Disposal removes instance listeners and rejects later calculations with
|
|
911
|
+
`ARCANE_CALCULATOR_ENGINE_DISPOSED`. Invalid expression input, syntax, numeric
|
|
912
|
+
domain, and unexpected evaluation boundaries use
|
|
913
|
+
`ARCANE_CALCULATOR_EXPRESSION_INPUT_INVALID`,
|
|
914
|
+
`ARCANE_CALCULATOR_EXPRESSION_SYNTAX_INVALID`,
|
|
915
|
+
`ARCANE_CALCULATOR_EXPRESSION_DOMAIN_INVALID`, and
|
|
916
|
+
`ARCANE_CALCULATOR_EXPRESSION_EVALUATION_FAILED`. Transport: in-process only.
|
|
917
|
+
[Deep protocol details](protocols.md).
|
|
612
918
|
|
|
613
919
|
### Example
|
|
614
920
|
|
|
@@ -701,7 +1007,7 @@ Binds shared inbox, conversation, settings, theme, and provider workflows into o
|
|
|
701
1007
|
|
|
702
1008
|
default controller with `start()`, `bind()`, `configure()`, `refresh()`, `select()`, `send()`, and settings actions.
|
|
703
1009
|
|
|
704
|
-
Exact exports: `default`.
|
|
1010
|
+
Exact exports: `COMMUNICATION_APP_CONTROLLER_ERROR_CODES`, `default`.
|
|
705
1011
|
|
|
706
1012
|
### Availability and normalization
|
|
707
1013
|
|
|
@@ -725,7 +1031,9 @@ Fans out provider refresh/send operations and aggregates normalized threads/mess
|
|
|
725
1031
|
|
|
726
1032
|
default `CommunicationHub`; provider enablement, `refresh()`, `messages()`, and `send()`.
|
|
727
1033
|
|
|
728
|
-
Exact exports: `
|
|
1034
|
+
Exact exports: `COMMUNICATION_HUB_ERROR_CODES`, `COMMUNICATION_HUB_EVENTS`,
|
|
1035
|
+
`COMMUNICATION_HUB_REFRESH_REASONS`, `COMMUNICATION_HUB_REFRESH_STATES`, and
|
|
1036
|
+
`default`.
|
|
729
1037
|
|
|
730
1038
|
### Availability and normalization
|
|
731
1039
|
|
|
@@ -816,7 +1124,15 @@ sticky state only changes the controller's observation and presentation; it
|
|
|
816
1124
|
never emits a lifecycle intent, chooses a provider, or starts a download.
|
|
817
1125
|
`destroy()` removes its button listener and suppresses late callback effects.
|
|
818
1126
|
|
|
819
|
-
Exact exports: `CHART_LABELS`, `DASHBOARD_LABELS`, `MARKDOWN_FORMATS`,
|
|
1127
|
+
Exact exports: `CHART_LABELS`, `DASHBOARD_LABELS`, `MARKDOWN_FORMATS`,
|
|
1128
|
+
`MARKDOWN_LABELS`, `STT_ACTIVATION_ERROR_CODES`,
|
|
1129
|
+
`STT_ACTIVATION_EVENT_TYPES`, `STT_ACTIVATION_REASONS`, `VOICE_LABELS`,
|
|
1130
|
+
`VOICE_MESSAGES`, `appendTranscription`, `applyMarkdownFormat`,
|
|
1131
|
+
`createSTTActivationController`, `effectiveDashboardVisibility`,
|
|
1132
|
+
`normalizeChartOptions`, `normalizeChartRows`, `normalizeDashboardDefinitions`,
|
|
1133
|
+
`normalizeDashboardOptions`, `normalizeDashboardVisibility`,
|
|
1134
|
+
`normalizeMarkdownFormats`, `normalizeMarkdownOptions`, and
|
|
1135
|
+
`normalizeVoiceOptions`.
|
|
820
1136
|
|
|
821
1137
|
### Availability and normalization
|
|
822
1138
|
|
|
@@ -959,7 +1275,15 @@ Owns conversation limits, control messages, submission barriers, elapsed formatt
|
|
|
959
1275
|
|
|
960
1276
|
default `ConversationTimebox`, `ConversationSubmissionBarrier`, constants and control helpers.
|
|
961
1277
|
|
|
962
|
-
Exact exports: `
|
|
1278
|
+
Exact exports: `CONVERSATION_TIMEBOX_ERROR_CODES`,
|
|
1279
|
+
`CONVERSATION_TIMEBOX_EVENT_TYPES`, `CONVERSATION_TIMEBOX_LIMIT_MESSAGE`,
|
|
1280
|
+
`CONVERSATION_TIMEBOX_OPENING_INSTRUCTION`, `CONVERSATION_TIMEBOX_REASONS`,
|
|
1281
|
+
`CONVERSATION_TIMEBOX_TOOL_NAME`, `ConversationSubmissionBarrier`,
|
|
1282
|
+
`appendConversationTimeboxOpeningInstruction`, `consumeConversationTimeboxCall`,
|
|
1283
|
+
`conversationTimeboxSubmissionKey`, `conversationTimeboxTool`,
|
|
1284
|
+
`createConversationTimeboxControlMessage`, `default`,
|
|
1285
|
+
`formatConversationElapsed`, `normalizeConversationTimeboxCommand`, and
|
|
1286
|
+
`requireConversationTimeboxDelivery`.
|
|
963
1287
|
|
|
964
1288
|
### Availability and normalization
|
|
965
1289
|
|
|
@@ -1031,7 +1355,7 @@ Provides app-scoped localStorage tables, batch reads/writes, filtering, deletion
|
|
|
1031
1355
|
|
|
1032
1356
|
default `DBLS`; installs `window.dbls`, emits `dbls-ready`; CRUD/batch/key APIs.
|
|
1033
1357
|
|
|
1034
|
-
Exact exports: `default`.
|
|
1358
|
+
Exact exports: `DBLS_EVENT_TYPES`, `DBLS_REASONS`, `default`.
|
|
1035
1359
|
|
|
1036
1360
|
### Availability and normalization
|
|
1037
1361
|
|
|
@@ -1055,7 +1379,7 @@ Provides app-scoped OPFS tables, worker I/O, backup/restore, compression, and CR
|
|
|
1055
1379
|
|
|
1056
1380
|
default `DBOPFS`; installs `window.dbopfs`, emits `dbopfs-ready`; table/file/backup APIs.
|
|
1057
1381
|
|
|
1058
|
-
Exact exports: `default`.
|
|
1382
|
+
Exact exports: `DBOPFS_EVENT_TYPES`, `DBOPFS_REASONS`, `default`.
|
|
1059
1383
|
|
|
1060
1384
|
### Availability and normalization
|
|
1061
1385
|
|
|
@@ -1080,8 +1404,8 @@ or search; applications call `bootstrap()` deliberately.
|
|
|
1080
1404
|
|
|
1081
1405
|
### Public surface
|
|
1082
1406
|
|
|
1083
|
-
Exact exports:
|
|
1084
|
-
`
|
|
1407
|
+
Exact exports: `DBOPFSDocumentLibrary`, `createDBOPFSDocumentLibrary`,
|
|
1408
|
+
`default`, and `normalizeDBOPFSDocumentSchema`.
|
|
1085
1409
|
|
|
1086
1410
|
`new DBOPFSDocumentLibrary({concurrency,db,maxCorpusCharacters,
|
|
1087
1411
|
maxDocumentCharacters,maxSearchCharacters,schema})` exposes `schema`,
|
|
@@ -1105,7 +1429,7 @@ source body as implicit authority, and never persists a caller-owned body.
|
|
|
1105
1429
|
**Browser or compatible host with an injected DBOPFS adapter.** The adapter
|
|
1106
1430
|
keeps the existing `get`, `set`, `getAllKeys`, and `delete` method names; Node
|
|
1107
1431
|
can use the same class only through an explicitly imported runtime module and a
|
|
1108
|
-
compatible storage adapter; SDK `0.
|
|
1432
|
+
compatible storage adapter; SDK `0.3.1` publishes no Node package subpath or
|
|
1109
1433
|
Node storage implementation for it. Bootstrap uses a bounded concurrent
|
|
1110
1434
|
generation, commits its manifest last, cleans partial data on failure, and
|
|
1111
1435
|
rejects case-colliding IDs. Search
|
|
@@ -1238,11 +1562,10 @@ context excerpts for caller-owned document records.
|
|
|
1238
1562
|
|
|
1239
1563
|
### Public surface
|
|
1240
1564
|
|
|
1241
|
-
Exact exports: `DOCUMENT_SEARCH_FIELD_ORDER`,
|
|
1242
|
-
`
|
|
1243
|
-
`
|
|
1244
|
-
|
|
1245
|
-
`scoreDocumentLexicalIndex()`.
|
|
1565
|
+
Exact exports: `DOCUMENT_SEARCH_FIELD_ORDER`, `DocumentLexicalSearch`,
|
|
1566
|
+
`createDocumentLexicalIndex`, `default`, `documentContextExcerpt`,
|
|
1567
|
+
`documentSearchTokens`, `normalizedDocumentSearchText`, `scoreDocumentBody`,
|
|
1568
|
+
and `scoreDocumentLexicalIndex`.
|
|
1246
1569
|
|
|
1247
1570
|
`new DocumentLexicalSearch(records,{maxResults=20})` exposes
|
|
1248
1571
|
`rank(query,{kinds,tags})` and `search(query,{kinds,limit,tags})`.
|
|
@@ -1305,7 +1628,9 @@ Normalizes global errors/rejections, fingerprints and deduplicates incidents, pe
|
|
|
1305
1628
|
|
|
1306
1629
|
default `Errors`; event normalizers/fingerprint plus lifecycle, capture, delivery and teardown methods.
|
|
1307
1630
|
|
|
1308
|
-
Exact exports: `
|
|
1631
|
+
Exact exports: `GLOBAL_ERROR_EVENT_CODES`, `GLOBAL_ERROR_EVENT_TYPES`,
|
|
1632
|
+
`GLOBAL_ERROR_REASONS`, `default`, `fingerprintIncident`,
|
|
1633
|
+
`normalizeErrorEvent`, and `normalizeRejectionEvent`.
|
|
1309
1634
|
|
|
1310
1635
|
### Availability and normalization
|
|
1311
1636
|
|
|
@@ -1449,7 +1774,10 @@ Coordinates local-AI status component checks, ensured recovery, availability pro
|
|
|
1449
1774
|
|
|
1450
1775
|
`createLocalAIReadinessController()`, `availabilityFromReport()`.
|
|
1451
1776
|
|
|
1452
|
-
Exact exports: `
|
|
1777
|
+
Exact exports: `LOCAL_AI_READINESS_CONTROLLER_ERROR_CODES`,
|
|
1778
|
+
`LOCAL_AI_READINESS_CONTROLLER_EVENT_TYPES`,
|
|
1779
|
+
`LOCAL_AI_READINESS_CONTROLLER_REASONS`, `availabilityFromReport`, and
|
|
1780
|
+
`createLocalAIReadinessController`.
|
|
1453
1781
|
|
|
1454
1782
|
### Availability and normalization
|
|
1455
1783
|
|
|
@@ -1495,6 +1823,115 @@ import * as module from '/arcane/modules/Mail.js';
|
|
|
1495
1823
|
console.log(Object.keys(module));
|
|
1496
1824
|
```
|
|
1497
1825
|
|
|
1826
|
+
## MailOutbox.mjs
|
|
1827
|
+
|
|
1828
|
+
### Overview
|
|
1829
|
+
|
|
1830
|
+
Persists each bounded provider-neutral mail report before delivery and owns its
|
|
1831
|
+
idempotent enqueue, FIFO drain, retry-window, terminal-state, reconciliation,
|
|
1832
|
+
and explicit invalid-record maintenance lifecycle. It selects no mail provider,
|
|
1833
|
+
recipient, retention policy, retry timer, or transport fallback.
|
|
1834
|
+
|
|
1835
|
+
### Public surface
|
|
1836
|
+
|
|
1837
|
+
Exact exports: `MAIL_OUTBOX_ACCEPTANCE_AUTHORITIES`,
|
|
1838
|
+
`MAIL_OUTBOX_IDEMPOTENCY_WINDOW_MS`, `MAIL_OUTBOX_PROTOCOL`,
|
|
1839
|
+
`MAIL_OUTBOX_STATES`, `MAIL_OUTBOX_TABLE`, `MailOutbox`, `createMailOutbox`, and
|
|
1840
|
+
`default`.
|
|
1841
|
+
|
|
1842
|
+
```text
|
|
1843
|
+
new MailOutbox({
|
|
1844
|
+
storage,
|
|
1845
|
+
deliver,
|
|
1846
|
+
clock=Date.now,
|
|
1847
|
+
isOnline=()=>globalThis.navigator?.onLine!==false,
|
|
1848
|
+
lockManager=undefined,
|
|
1849
|
+
onlineTarget=typeof globalThis.addEventListener==='function'?globalThis:null,
|
|
1850
|
+
onRecordCommitted=null,
|
|
1851
|
+
maxAttemptsPerDrain=16,
|
|
1852
|
+
maxInvalidRecords=128,
|
|
1853
|
+
maxRecords=512,
|
|
1854
|
+
maxReportBytes=786432,
|
|
1855
|
+
quarantineTable='mail_outbox_quarantine',
|
|
1856
|
+
table=MAIL_OUTBOX_TABLE
|
|
1857
|
+
}={})
|
|
1858
|
+
```
|
|
1859
|
+
|
|
1860
|
+
`storage` must expose `get()`, `set()`, and `getAllKeys()`; explicit deletion or
|
|
1861
|
+
quarantine additionally requires `delete()`. `lockManager` must expose the Web
|
|
1862
|
+
Locks-compatible `request()` contract. The injected
|
|
1863
|
+
`deliver({report,reportKey,serializedReport,signal})` callback receives the
|
|
1864
|
+
frozen parsed report, its stable idempotency key, the exact stored JSON string,
|
|
1865
|
+
and the caller-owned signal. Omitted `lockManager` resolves first from storage
|
|
1866
|
+
and then from `navigator.locks`. A delivery result must identify a valid
|
|
1867
|
+
`requestId` and one of `accepted`, `delivery_uncertain`,
|
|
1868
|
+
`temporarily_rejected`, `permanently_rejected`, or `partially_accepted`;
|
|
1869
|
+
accepted results additionally require a provider ID or the admitted
|
|
1870
|
+
`arcane-core-mail-send-v1` acceptance authority.
|
|
1871
|
+
|
|
1872
|
+
Read-only getters are `started`, `invalidRecords`, and `lastBackgroundError`.
|
|
1873
|
+
Methods are `get(key)`, `list()`, `audit()`, `deleteInvalid(fileName)`,
|
|
1874
|
+
`repairInvalid(fileName,replacement)`,
|
|
1875
|
+
`quarantineInvalid({limit=64}={})`,
|
|
1876
|
+
`enqueue({report,reportKey}={}, {attempt=true,signal=null}={})`,
|
|
1877
|
+
`drain({reason='manual',signal=null}={})`, `start({signal=null}={})`, and
|
|
1878
|
+
`stop()`. `createMailOutbox(options)` returns `new MailOutbox(options)`.
|
|
1879
|
+
|
|
1880
|
+
Every returned durable record is deeply frozen and contains exactly
|
|
1881
|
+
`{protocol,reportKey,serializedReport,state,createdAt,updatedAt,firstAttemptAt,
|
|
1882
|
+
lastAttemptAt,nextAttemptAt,attempts,result,failure}`. Protocol is
|
|
1883
|
+
`arcane-mail-outbox/1`; the default table is `mail_outbox`; the idempotency
|
|
1884
|
+
window is 86,400,000 milliseconds. States are exactly `queued`, `sending`,
|
|
1885
|
+
`retry_wait`, `accepted`, `failed`, and `reconciliation_required`. Accepted
|
|
1886
|
+
means provider or admitted Core acceptance, not inbox delivery.
|
|
1887
|
+
|
|
1888
|
+
`enqueue()` serializes same-instance persistence and binds one report key to one
|
|
1889
|
+
exact serialized body. `drain()` runs or joins one bounded instance drain under
|
|
1890
|
+
an exclusive shared lock and attempts at most 16 records by default. Startup,
|
|
1891
|
+
an owned `online` listener, or an explicit call may trigger work; there is no
|
|
1892
|
+
polling or retry timer. Abort before the delivery call prevents that call, and a
|
|
1893
|
+
caller joining an existing drain may stop waiting without cancelling the shared
|
|
1894
|
+
drain. Once an accepted result is committed, it outranks a racing cancellation;
|
|
1895
|
+
cancellation never claims an admitted provider attempt stopped. An interrupted
|
|
1896
|
+
or ambiguous attempt remains a same-key retry inside the 24-hour window and
|
|
1897
|
+
becomes `reconciliation_required` when automatic retry would risk a duplicate.
|
|
1898
|
+
`stop()` aborts only the owned online drain, removes its listener, preserves
|
|
1899
|
+
durable records, and returns the instance.
|
|
1900
|
+
|
|
1901
|
+
`audit()` reports valid records plus bounded invalid-file metadata. Repair,
|
|
1902
|
+
deletion, and quarantine are explicit, revalidate the selected file under the
|
|
1903
|
+
table lock, and never infer destructive authority from a storage read failure.
|
|
1904
|
+
`onRecordCommitted(record)` is an observational callback after each durable
|
|
1905
|
+
write; callback failure cannot change the committed operation result.
|
|
1906
|
+
|
|
1907
|
+
### Availability and normalization
|
|
1908
|
+
|
|
1909
|
+
**Browser/native WebView or compatible injected host.** The default application
|
|
1910
|
+
integration uses DBOPFS-compatible durable storage and `navigator.locks`; an
|
|
1911
|
+
alternate adapter owns its own durability claim and must provide equivalent
|
|
1912
|
+
storage and shared-lock semantics. Frozen records, bounds, state transitions,
|
|
1913
|
+
retry/reconciliation classification, invalid-record maintenance, and
|
|
1914
|
+
AbortSignal admission/join cancellation are normalized. Storage, lock,
|
|
1915
|
+
online-check, and injected-delivery failures remain visible through concrete
|
|
1916
|
+
`MAIL_OUTBOX_*` codes. Transport: injected durable storage, Web Locks,
|
|
1917
|
+
AbortSignal, optional online EventTarget, and an injected delivery callback.
|
|
1918
|
+
[Deep protocol details](mail.md#durable-send-semantics).
|
|
1919
|
+
|
|
1920
|
+
### Example
|
|
1921
|
+
|
|
1922
|
+
```javascript
|
|
1923
|
+
import {createMailOutbox} from '/arcane/modules/MailOutbox.mjs';
|
|
1924
|
+
|
|
1925
|
+
const outbox = createMailOutbox({storage, deliver});
|
|
1926
|
+
await outbox.start({signal});
|
|
1927
|
+
const record = await outbox.enqueue(
|
|
1928
|
+
{report, reportKey: 'report-20260827-001'},
|
|
1929
|
+
{attempt: true, signal}
|
|
1930
|
+
);
|
|
1931
|
+
console.log(record.state);
|
|
1932
|
+
outbox.stop();
|
|
1933
|
+
```
|
|
1934
|
+
|
|
1498
1935
|
## MailTransport.mjs
|
|
1499
1936
|
|
|
1500
1937
|
### Overview
|
|
@@ -1503,9 +1940,12 @@ Sends one bounded mail report to a normalized HTTP(S) endpoint with timeout and
|
|
|
1503
1940
|
|
|
1504
1941
|
### Public surface
|
|
1505
1942
|
|
|
1506
|
-
Timeout/size constants, `
|
|
1943
|
+
Timeout/size constants, `MailTransportError`, `normalizeMailEndpoint()`,
|
|
1944
|
+
`serializeMailReport()`, and `sendMailReport()`.
|
|
1507
1945
|
|
|
1508
|
-
Exact exports: `DEFAULT_MAIL_REQUEST_TIMEOUT_MS`, `MAX_MAIL_RESPONSE_BYTES`,
|
|
1946
|
+
Exact exports: `DEFAULT_MAIL_REQUEST_TIMEOUT_MS`, `MAX_MAIL_RESPONSE_BYTES`,
|
|
1947
|
+
`MailTransportError`, `normalizeMailEndpoint`, `serializeMailReport`,
|
|
1948
|
+
`sendMailReport`.
|
|
1509
1949
|
|
|
1510
1950
|
### Availability and normalization
|
|
1511
1951
|
|
|
@@ -1649,7 +2089,8 @@ Provides the first-class Arcane Ollama client without direct access to localhost
|
|
|
1649
2089
|
|
|
1650
2090
|
`Ollama`, singleton/default `ollama`; 24 methods; installs `globalThis.arcaneOllama`, emits `arcane-ollama-ready`.
|
|
1651
2091
|
|
|
1652
|
-
Exact exports: `Ollama`, `default`,
|
|
2092
|
+
Exact exports: `OLLAMA_EVENT_TYPES`, `OLLAMA_REASONS`, `Ollama`, `default`,
|
|
2093
|
+
and `ollama`.
|
|
1653
2094
|
|
|
1654
2095
|
### Availability and normalization
|
|
1655
2096
|
|
|
@@ -1721,7 +2162,8 @@ Searches and loads Open-Meteo data into frozen Arcane weather entities.
|
|
|
1721
2162
|
|
|
1722
2163
|
Endpoint constants, default provider, `mapForecast()`; search/load methods and lifecycle events.
|
|
1723
2164
|
|
|
1724
|
-
Exact exports: `OPEN_METEO_ENDPOINTS`, `
|
|
2165
|
+
Exact exports: `OPEN_METEO_ENDPOINTS`, `OPEN_METEO_WEATHER_ERRORS`,
|
|
2166
|
+
`OPEN_METEO_WEATHER_EVENTS`, `default`, and `mapForecast`.
|
|
1725
2167
|
|
|
1726
2168
|
### Availability and normalization
|
|
1727
2169
|
|
|
@@ -1746,8 +2188,8 @@ semantics; it does not define a new storage protocol.
|
|
|
1746
2188
|
|
|
1747
2189
|
### Public surface
|
|
1748
2190
|
|
|
1749
|
-
Exact exports:
|
|
1750
|
-
`
|
|
2191
|
+
Exact exports: `PersistentAIChatSession`, `createPersistentAIChatSession`, and
|
|
2192
|
+
`default`.
|
|
1751
2193
|
|
|
1752
2194
|
Constructor and factory options are `{chat,chatEntity,chatFileName,
|
|
1753
2195
|
contextBuilder,loadExisting,maxContextCharacters,maxMessageCharacters,
|
|
@@ -1803,7 +2245,9 @@ Loads and updates schema-defined app preferences through native storage with a n
|
|
|
1803
2245
|
|
|
1804
2246
|
default `PreferenceStore`, re-exported `Preference`/schema; load/set/reset APIs and events.
|
|
1805
2247
|
|
|
1806
|
-
Exact exports: `
|
|
2248
|
+
Exact exports: `PREFERENCE_STORE_ERROR_CODES`,
|
|
2249
|
+
`PREFERENCE_STORE_EVENT_TYPES`, `Preference`, `default`, and
|
|
2250
|
+
`preferenceSchema`.
|
|
1807
2251
|
|
|
1808
2252
|
### Availability and normalization
|
|
1809
2253
|
|
|
@@ -1921,7 +2365,9 @@ Stores normalized record-review decisions through native storage or app-scoped l
|
|
|
1921
2365
|
|
|
1922
2366
|
default store, record/review normalizers; `load()`, `get()`, `set()`, `snapshot()`, change event.
|
|
1923
2367
|
|
|
1924
|
-
Exact exports: `
|
|
2368
|
+
Exact exports: `RECORD_REVIEW_STORE_ERROR_CODES`,
|
|
2369
|
+
`RECORD_REVIEW_STORE_EVENT_TYPES`, `default`, `normalizeRecordId`, and
|
|
2370
|
+
`normalizeReview`.
|
|
1925
2371
|
|
|
1926
2372
|
### Availability and normalization
|
|
1927
2373
|
|
|
@@ -2041,7 +2487,9 @@ Captures a display surface as image, video, or GIF with explicit lifecycle event
|
|
|
2041
2487
|
|
|
2042
2488
|
default `ScreenCapture`; acquire/capture/start/stop/reset methods.
|
|
2043
2489
|
|
|
2044
|
-
Exact exports: `
|
|
2490
|
+
Exact exports: `SCREEN_CAPTURE_ERROR_CODES`, `SCREEN_CAPTURE_ERRORS`,
|
|
2491
|
+
`SCREEN_CAPTURE_EVENT_TYPES`, `SCREEN_CAPTURE_IMAGE_TYPE_FALLBACK`,
|
|
2492
|
+
`SCREEN_CAPTURE_REASONS`, `SCREEN_CAPTURE_STATUSES`, and `default`.
|
|
2045
2493
|
|
|
2046
2494
|
### Availability and normalization
|
|
2047
2495
|
|
|
@@ -2063,13 +2511,75 @@ Segments bounded text, queues latest-request speech synthesis, and controls look
|
|
|
2063
2511
|
|
|
2064
2512
|
### Public surface
|
|
2065
2513
|
|
|
2066
|
-
SpeechPlayback class/default, voice/limit constants,
|
|
2067
|
-
|
|
2068
|
-
Exact exports: `MAX_SPEECH_CHARACTERS`, `MAX_SPEECH_CHUNKS`, `MAX_SPEECH_INPUT`, `PREFERRED_STREAM_SEGMENT`, `SPEECH_VOICE_ALIASES`, `SPEECH_VOICE_OPTIONS`, `SpeechPlayback`, `default`, `splitSpeechText`.
|
|
2514
|
+
`SpeechPlayback` class/default, voice/limit compatibility constants,
|
|
2515
|
+
`SPEECH_PLAYBACK_STATE_EVENT`, `splitSpeechText()`, and playback lifecycle APIs.
|
|
2069
2516
|
|
|
2070
|
-
|
|
2517
|
+
Exact exports: `MAX_SPEECH_CHARACTERS`, `MAX_SPEECH_CHUNKS`,
|
|
2518
|
+
`MAX_SPEECH_INPUT`, `PREFERRED_STREAM_SEGMENT`, `SPEECH_PLAYBACK_STATE_EVENT`,
|
|
2519
|
+
`SPEECH_VOICE_ALIASES`, `SPEECH_VOICE_OPTIONS`, `SpeechPlayback`, `default`,
|
|
2520
|
+
and `splitSpeechText`.
|
|
2071
2521
|
|
|
2072
|
-
|
|
2522
|
+
```text
|
|
2523
|
+
new SpeechPlayback({
|
|
2524
|
+
audio,
|
|
2525
|
+
speech=globalThis.Arcane?.speech,
|
|
2526
|
+
model=null,
|
|
2527
|
+
voice=null,
|
|
2528
|
+
responseFormat=null,
|
|
2529
|
+
speed=1,
|
|
2530
|
+
onState=()=>{},
|
|
2531
|
+
createObjectURL,
|
|
2532
|
+
revokeObjectURL,
|
|
2533
|
+
delay,
|
|
2534
|
+
messages={}
|
|
2535
|
+
})
|
|
2536
|
+
```
|
|
2537
|
+
|
|
2538
|
+
`speech` must expose either `fetchTTS(payload, signal)` or
|
|
2539
|
+
`synthesize(payload, {signal})`. `prepare({key,parts,model,voice,responseFormat,
|
|
2540
|
+
speed,autoplay=true})` uses only caller-supplied model, voice, and response-format
|
|
2541
|
+
values; those three omitted values remain omitted so the selected AI/model
|
|
2542
|
+
catalog may admit its documented defaults. Speed defaults to `1`, is normalized
|
|
2543
|
+
as a positive number, and is always sent. The legacy voice constants remain
|
|
2544
|
+
exported for compatibility but are not selected by the class. There is no
|
|
2545
|
+
hard-coded model, response format, voice, or cloud/browser fallback.
|
|
2546
|
+
|
|
2547
|
+
Every preparation owns an operation ID and one AbortController for each active
|
|
2548
|
+
synthesis segment or playback delay. Replacement,
|
|
2549
|
+
`stop()`, `cancel()`, and `destroy()` abort their owned signals, suppress stale
|
|
2550
|
+
settlement, release Blob URLs, and publish synchronous
|
|
2551
|
+
`speech-playback-state` occurrences through `globalThis.arcaneEvents` before
|
|
2552
|
+
calling the compatibility `onState(frozenDetail)` callback. The detail contains
|
|
2553
|
+
`state`, `message`, `key`, `index`, `total`, `producing`, `buffered`, `hasAudio`,
|
|
2554
|
+
`operationId`, `code`, and `reason`; the canonical public occurrence omits
|
|
2555
|
+
provider response/error bodies. `destroy()` also removes every audio listener
|
|
2556
|
+
and disposes its per-instance canonical source handle; repeated destroy returns
|
|
2557
|
+
`false`. Signal abortion proves delivery suppression; whether provider work
|
|
2558
|
+
actually stops remains the selected provider's cancellation boundary.
|
|
2559
|
+
|
|
2560
|
+
Stable error codes are `ARCANE_SPEECH_PLAYBACK_DESTROYED`,
|
|
2561
|
+
`ARCANE_SPEECH_PLAYBACK_OPERATION_SEQUENCE_EXHAUSTED`,
|
|
2562
|
+
`ARCANE_SPEECH_PLAYBACK_SYNTHESIZER_UNAVAILABLE`,
|
|
2563
|
+
`ARCANE_SPEECH_PLAYBACK_SYNTHESIZED_AUDIO_CONTRACT_MISMATCH`,
|
|
2564
|
+
`ARCANE_SPEECH_PLAYBACK_AUDIO_PLAYBACK_REJECTED`,
|
|
2565
|
+
`ARCANE_SPEECH_PLAYBACK_REQUEST_CONTRACT_MISMATCH`, and
|
|
2566
|
+
`ARCANE_SPEECH_PLAYBACK_SYNTHESIS_REQUEST_REJECTED`, plus propagated
|
|
2567
|
+
`ARCANE_AI_OPERATION_SUPERSEDED` and `ARCANE_AI_REQUEST_ABORTED`.
|
|
2568
|
+
Exact lifecycle reasons are `playback-replaced`, `playback-stopped`,
|
|
2569
|
+
`playback-destroyed`, `speech-playback-cancelled`,
|
|
2570
|
+
`speech-synthesis-superseded`, `speech-synthesis-cancelled`,
|
|
2571
|
+
`speech-synthesizer-unavailable`, `synthesized-audio-contract-mismatch`,
|
|
2572
|
+
`audio-playback-rejected`, `audio-autoplay-rejected`,
|
|
2573
|
+
`speech-playback-request-contract-mismatch`, and
|
|
2574
|
+
`speech-synthesis-rejected`, as applicable to the emitted state.
|
|
2575
|
+
|
|
2576
|
+
### Availability and normalization
|
|
2577
|
+
|
|
2578
|
+
**Browser + admitted AI/native bridge.** State, cancellation, lifecycle, and
|
|
2579
|
+
playable Blob normalization are shared. Provider/model/runtime/voice admission
|
|
2580
|
+
remains caller- and catalog-owned. Transport: `AI.fetchTTS`, compatible
|
|
2581
|
+
`Arcane.speech.synthesize`, Blob URLs, audio element, and the singleton event
|
|
2582
|
+
authority. [Deep protocol details](protocols.md).
|
|
2073
2583
|
|
|
2074
2584
|
### Example
|
|
2075
2585
|
|
|
@@ -2078,7 +2588,13 @@ import SpeechPlayback from '/arcane/modules/SpeechPlayback.js';
|
|
|
2078
2588
|
|
|
2079
2589
|
const audio = document.body.appendChild(document.createElement('audio'));
|
|
2080
2590
|
audio.controls = true;
|
|
2081
|
-
const speech = new SpeechPlayback({
|
|
2591
|
+
const speech = new SpeechPlayback({
|
|
2592
|
+
audio,
|
|
2593
|
+
speech: globalThis.ai,
|
|
2594
|
+
model: 'caller-selected-model',
|
|
2595
|
+
voice: 'caller-selected-voice',
|
|
2596
|
+
responseFormat: 'wav'
|
|
2597
|
+
});
|
|
2082
2598
|
const speakButton = document.body.appendChild(document.createElement('button'));
|
|
2083
2599
|
speakButton.type = 'button';
|
|
2084
2600
|
speakButton.textContent = 'Speak';
|
|
@@ -2195,7 +2711,8 @@ Maps native terminal sessions and Arcane events into an EventTarget client.
|
|
|
2195
2711
|
|
|
2196
2712
|
default `TerminalClient`; start/write/resize/signal/close/receive/destroy APIs and terminal events.
|
|
2197
2713
|
|
|
2198
|
-
Exact exports: `
|
|
2714
|
+
Exact exports: `TERMINAL_CLIENT_ERROR_CODES`, `TERMINAL_CLIENT_EVENT_TYPES`,
|
|
2715
|
+
`TERMINAL_CLIENT_REASONS`, and `default`.
|
|
2199
2716
|
|
|
2200
2717
|
### Availability and normalization
|
|
2201
2718
|
|
|
@@ -2243,7 +2760,8 @@ Performs import-time Arcane theme loading and subscribes to native appearance ch
|
|
|
2243
2760
|
|
|
2244
2761
|
`bootstrapArcaneTheme()`, `arcaneThemeReady`, default ready promise.
|
|
2245
2762
|
|
|
2246
|
-
Exact exports: `arcaneThemeReady`, `bootstrapArcaneTheme`, `default
|
|
2763
|
+
Exact exports: `arcaneThemeReady`, `bootstrapArcaneTheme`, `default`, and
|
|
2764
|
+
`disposeArcaneThemeBootstrap`.
|
|
2247
2765
|
|
|
2248
2766
|
### Availability and normalization
|
|
2249
2767
|
|
|
@@ -2401,7 +2919,8 @@ Waits for a component property, method, or readiness event with optional error e
|
|
|
2401
2919
|
|
|
2402
2920
|
default `waitForComponent()`.
|
|
2403
2921
|
|
|
2404
|
-
Exact exports: `
|
|
2922
|
+
Exact exports: `COMPONENT_WAIT_ERROR_CODES`, `COMPONENT_WAIT_REASONS`, and
|
|
2923
|
+
`default`.
|
|
2405
2924
|
|
|
2406
2925
|
### Availability and normalization
|
|
2407
2926
|
|