arcane-os 0.3.1 → 0.3.2

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.
Files changed (153) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +86 -117
  3. package/bin/arcane-test.mjs +170 -46
  4. package/browser-runtime/ai/browser-speech-artifacts.mjs +855 -895
  5. package/browser-runtime/ai/browser-speech-providers.mjs +80 -204
  6. package/browser-runtime/ai/browser-wasm-llm-provider.mjs +627 -819
  7. package/browser-runtime/ai/browser-wasm.mjs +24 -35
  8. package/browser-runtime/ai/browser-wllama-runtime.mjs +64 -316
  9. package/browser-runtime/ai/model-controller.mjs +584 -181
  10. package/browser-runtime/ai/speech-worker-client.mjs +8 -148
  11. package/browser-runtime/ai/speech-worker-runtime.mjs +642 -374
  12. package/browser-runtime/dom-event-instrumentation.mjs +55 -147
  13. package/browser-runtime/event-manager.mjs +239 -624
  14. package/package.json +5 -6
  15. package/runtime/arcane/components/app-bar.html +3 -15
  16. package/runtime/arcane/components/assistant-panel.html +10 -10
  17. package/runtime/arcane/components/calculator.html +1 -1
  18. package/runtime/arcane/components/chat.html +1359 -135
  19. package/runtime/arcane/components/conversation-view.html +2 -2
  20. package/runtime/arcane/components/document-inspector.html +11 -17
  21. package/runtime/arcane/components/file-manager.html +13 -56
  22. package/runtime/arcane/components/markdown-document.html +82 -281
  23. package/runtime/arcane/components/markdown-editor.html +7 -10
  24. package/runtime/arcane/components/media-embed.html +6 -6
  25. package/runtime/arcane/components/screen-capture.html +4 -4
  26. package/runtime/arcane/components/source-explanation.html +2 -2
  27. package/runtime/arcane/components/speech.html +112 -68
  28. package/runtime/arcane/components/terminal-workspace.html +4 -4
  29. package/runtime/arcane/components/theme-editor.html +1 -1
  30. package/runtime/arcane/components/unified-inbox.html +2 -2
  31. package/runtime/arcane/components/voice-transcription.html +31 -21
  32. package/runtime/arcane/entities/Calculation.js +2 -3
  33. package/runtime/arcane/entities/Chat.js +228 -43
  34. package/runtime/arcane/entities/Preference.js +3 -5
  35. package/runtime/arcane/entities/Weather.js +5 -5
  36. package/runtime/arcane/modules/AI.js +1042 -427
  37. package/runtime/arcane/modules/AIProviderRuntime.js +618 -359
  38. package/runtime/arcane/modules/AIResponseLength.js +9 -19
  39. package/runtime/arcane/modules/AIRuntimeState.js +109 -72
  40. package/runtime/arcane/modules/ArcaneNavigationPolicy.js +45 -32
  41. package/runtime/arcane/modules/BrowserTestSuite.js +78 -122
  42. package/runtime/arcane/modules/CalculatorEngine.js +9 -9
  43. package/runtime/arcane/modules/CommunicationAppController.js +3 -7
  44. package/runtime/arcane/modules/ComponentContracts.js +30 -32
  45. package/runtime/arcane/modules/ConfiguredAIChatSession.js +281 -230
  46. package/runtime/arcane/modules/ConversationActionItems.js +26 -59
  47. package/runtime/arcane/modules/ConversationClosingReport.js +34 -61
  48. package/runtime/arcane/modules/ConversationTimebox.js +27 -15
  49. package/runtime/arcane/modules/DBOPFSDocumentLibrary.js +152 -344
  50. package/runtime/arcane/modules/DocumentLexicalSearch.js +25 -91
  51. package/runtime/arcane/modules/HTMLImport.js +54 -1
  52. package/runtime/arcane/modules/IsolatedModelQuestionRunner.js +40 -203
  53. package/runtime/arcane/modules/LocalAIReadiness.js +40 -60
  54. package/runtime/arcane/modules/LocalAIReadinessController.js +15 -13
  55. package/runtime/arcane/modules/MD.js +1 -45
  56. package/runtime/arcane/modules/Mail.js +51 -103
  57. package/runtime/arcane/modules/MailOutbox.mjs +95 -193
  58. package/runtime/arcane/modules/MailTransport.mjs +36 -57
  59. package/runtime/arcane/modules/ModelDefinition.js +22 -106
  60. package/runtime/arcane/modules/OpenMeteoWeatherProvider.js +39 -101
  61. package/runtime/arcane/modules/PersistentAIChatSession.js +281 -18
  62. package/runtime/arcane/modules/PreferenceStore.js +102 -30
  63. package/runtime/arcane/modules/RiskSignalAnalyzer.js +8 -9
  64. package/runtime/arcane/modules/ScopedOPFSCache.js +7 -42
  65. package/runtime/arcane/modules/ScreenCapture.js +175 -128
  66. package/runtime/arcane/modules/SpeechPlayback.js +46 -149
  67. package/runtime/arcane/modules/StaticDocumentCatalog.js +173 -407
  68. package/runtime/arcane/modules/ToolCallRouter.js +25 -12
  69. package/runtime/arcane/modules/YouTubeMedia.js +6 -5
  70. package/schemas/arcane-app-bundle.schema.json +13 -78
  71. package/schemas/arcane-app.schema.json +9 -25
  72. package/schemas/arcane-lock.schema.json +18 -151
  73. package/schemas/arcane-package.schema.json +2 -16
  74. package/schemas/native-build-plan.schema.json +119 -122
  75. package/src/app-descriptor.mjs +75 -132
  76. package/src/application-tests.mjs +200 -0
  77. package/src/cli/main.mjs +27 -46
  78. package/src/constants.mjs +3 -4
  79. package/src/dev-server.mjs +30 -324
  80. package/src/doctor.mjs +92 -154
  81. package/src/dom-event-instrumentation.mjs +55 -147
  82. package/src/errors.mjs +2 -3
  83. package/src/event-manager.mjs +239 -624
  84. package/src/event-queue.mjs +3 -3
  85. package/src/import-map.mjs +273 -1028
  86. package/src/index.mjs +14 -16
  87. package/src/installed-sdk-runtime.mjs +27 -67
  88. package/src/integrated-provider-loader.mjs +53 -382
  89. package/src/mail-api.mjs +0 -2
  90. package/src/mail-server.mjs +224 -580
  91. package/src/mail.mjs +4 -10
  92. package/src/native-plan.mjs +163 -598
  93. package/src/native-provider-loader.mjs +104 -1063
  94. package/src/packager/core.mjs +485 -3229
  95. package/src/process.mjs +5 -10
  96. package/src/release-bundle.mjs +292 -2405
  97. package/src/runtime.mjs +76 -396
  98. package/src/scaffold.mjs +30 -80
  99. package/src/sdk-browser-runtime.mjs +70 -626
  100. package/src/source-server.mjs +588 -0
  101. package/src/targets/index.mjs +78 -188
  102. package/src/templates/workspace-template.mjs +19 -135
  103. package/src/testing-loader.mjs +164 -0
  104. package/src/testing.mjs +1 -1
  105. package/src/toolchain.mjs +131 -544
  106. package/src/update-check.mjs +26 -64
  107. package/src/workspace-operation-lock.mjs +139 -430
  108. package/src/workspace-runtime.mjs +109 -1558
  109. package/src/workspace.mjs +40 -302
  110. package/browser-runtime/ARCANE_SDK_BROWSER_RELEASE.json +0 -218
  111. package/browser-runtime/ai/ARCANE_AI_BROWSER_SPEECH_COMPONENTS.json +0 -203
  112. package/browser-runtime/ai/ARCANE_AI_BROWSER_WASM_COMPONENTS.json +0 -80
  113. package/browser-runtime/ai/internal/sha256.mjs +0 -166
  114. package/docs/architecture.md +0 -344
  115. package/docs/compatibility.md +0 -36
  116. package/docs/event-manager.md +0 -294
  117. package/docs/platform-targets.md +0 -108
  118. package/docs/publishing.md +0 -201
  119. package/docs/reference/README.md +0 -185
  120. package/docs/reference/ai/browser-speech-package-authority.json +0 -835
  121. package/docs/reference/ai/browser-speech.md +0 -1295
  122. package/docs/reference/ai/browser-wasm.md +0 -530
  123. package/docs/reference/arcane-ollama.md +0 -288
  124. package/docs/reference/availability-and-normalization.md +0 -183
  125. package/docs/reference/behavioral-testing.md +0 -133
  126. package/docs/reference/cli.md +0 -779
  127. package/docs/reference/core/README.md +0 -62
  128. package/docs/reference/core/arcane-ai-contracts.md +0 -907
  129. package/docs/reference/core/arcane-api.md +0 -601
  130. package/docs/reference/core/arcane-entities.md +0 -65
  131. package/docs/reference/core/arcane-events.md +0 -134
  132. package/docs/reference/core/ollama-module.md +0 -181
  133. package/docs/reference/core/reference/arcane-api/ai-and-ollama.md +0 -1909
  134. package/docs/reference/core/reference/arcane-api/applications-terminal-capabilities.md +0 -1057
  135. package/docs/reference/core/reference/arcane-api/core-and-events.md +0 -320
  136. package/docs/reference/core/reference/arcane-api/filesystem-storage-preferences-appearance.md +0 -610
  137. package/docs/reference/core/reference/arcane-api/namespaces.md +0 -1157
  138. package/docs/reference/core/reference/arcane-api/platform-installation-users-system.md +0 -1423
  139. package/docs/reference/core/reference/arcane-api/session-provisioning-diagnostics-development.md +0 -315
  140. package/docs/reference/event-manager.md +0 -1511
  141. package/docs/reference/inventory/package-api.json +0 -3284
  142. package/docs/reference/inventory/runtime-components.json +0 -1011
  143. package/docs/reference/inventory/runtime-entities.json +0 -26
  144. package/docs/reference/inventory/runtime-modules.json +0 -1431
  145. package/docs/reference/mail.md +0 -316
  146. package/docs/reference/protocols.md +0 -719
  147. package/docs/reference/runtime-components.md +0 -1366
  148. package/docs/reference/runtime-entities.md +0 -303
  149. package/docs/reference/runtime-modules.md +0 -2965
  150. package/docs/reference/sdk-api.md +0 -6698
  151. package/docs/roadmap.md +0 -79
  152. package/docs/work-amplification.md +0 -129
  153. package/runtime/ARCANE_RUNTIME_RELEASE.json +0 -826
@@ -1,2965 +0,0 @@
1
- # Arcane runtime module catalog
2
-
3
- Every file shipped under `runtime/arcane/modules/` appears here. Start with the capability and example; expand into [protocol and host architecture](protocols.md) only when transport detail matters.
4
-
5
- Apps import renderer ESM from `/arcane/modules/<file>`. Classic scripts, the OPFS worker, uPlot stylesheet, and vendor license are called out explicitly. Importing a module does not grant a native capability.
6
-
7
- ## Availability shorthand
8
-
9
- - **Cross-host** means in-process logic built from standard JavaScript/Web APIs.
10
- - **Browser / native WebView** means DOM, storage, media, or component behavior available in a browser renderer and in supported native WebViews.
11
- - **Native bridge** means the module requires an admitted `globalThis.Arcane` method.
12
- - **Hybrid** means one public helper deliberately selects a documented native or browser/provider path.
13
- - **Cloud** means the module can call an explicitly configured remote provider; it never implies automatic local-to-cloud fallback.
14
- - **Node**, **worker**, and **vendor** identify specialized runtimes.
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
-
39
- ## Canonical inventory
40
-
41
- | Module | Kind | Capability | Availability | Normalization |
42
- | --- | --- | --- | --- | --- |
43
- | [`AI.js`](#aijs) | esm | Provider-selectable chat, speech-to-text, text-to-speech, tool calling, structured output, streaming, and queued audio playback. | Browser + native bridge + cloud | High-level chat/speech behavior is normalized; provider diagnostics and media errors remain mixed. |
44
- | [`AIPreferenceRuntime.js`](#aipreferenceruntimejs) | esm | Applies and reads non-persistent per-user AI preference overrides. | Cross-host | Normalized six-slot preference state. |
45
- | [`AIPreferenceTuple.js`](#aipreferencetuplejs) | esm | Normalizes and compares the six provider/model preference slots. | Cross-host | Fully normalized frozen tuple. |
46
- | [`AIProviderRuntime.js`](#aiproviderruntimejs) | esm | Owns provider-neutral selection, lifecycle, routing, startup, requests, streaming, cancellation, and independent LLM/STT/TTS state. | Cross-host runtime; provider-specific availability | Normalized required provider members plus closed route/status contracts, with fail-closed local-only selection and no implicit fallback. |
47
- | [`AIResponseLength.js`](#airesponselengthjs) | esm | Normalizes concise/short/medium/long response preferences and applies the matching system instruction. | Cross-host | Fully normalized string/instruction contract. |
48
- | [`AIResponseURLPolicy.js`](#airesponseurlpolicyjs) | esm | Extracts and audits links from AI Markdown, rendered HTML, CSS, srcset, bare URLs, and email text. | Cross-host | Normalized frozen allowlist audit. |
49
- | [`AIRuntimeState.js`](#airuntimestatejs) | esm | Publishes sticky immutable role snapshots, lifecycle intents, and startup-settlement barriers. | Cross-host state contract | Closed monotonic state records; events report state but grant no authority. |
50
- | [`AnsiText.js`](#ansitextjs) | esm | Parses terminal ANSI sequences into display spans or strips them to plain text. | Cross-host | Normalized text/span output. |
51
- | [`ApiModelDatabase.js`](#apimodeldatabasejs) | esm | Fetches an injectable HTTP JSON model with parser, cache, redacted public endpoint records, and request lifecycle events. | Browser / native WebView / server with fetch | Request records are normalized; fetch/provider failures remain mixed. |
52
- | [`AppDataScope.js`](#appdatascopejs) | esm | Reconciles declared and native application identity and scopes OPFS/localStorage ownership fail-closed. | Browser / native WebView hybrid | Strict normalized identifiers and coded mismatch failures. |
53
- | [`AppearancePreferences.js`](#appearancepreferencesjs) | esm | Defines, stores, and applies color scheme, density, reduced motion, and large-text preferences. | Browser / native WebView hybrid | Normalized values; storage/host failures remain mixed. |
54
- | [`ArcaneCommunicationBridge.js`](#arcanecommunicationbridgejs) | esm | Maps provider HTTP threads/messages/connect/disconnect endpoints to normalized communication entities. | Browser / native WebView / server with fetch | Entity results are normalized; provider/transport failures remain mixed. |
55
- | [`ArcaneNavigationPolicy.js`](#arcanenavigationpolicyjs) | esm | Creates a fail-closed HTTP(S) navigation guard with domain and CIDR policy decisions. | Cross-host | Normalized frozen allow/block decision. |
56
- | [`ArcaneNetworkPolicy.js`](#arcanenetworkpolicyjs) | esm | Validates the Arcane domain/network deny policy and matches domain, IPv4/IPv6 CIDR, protocol, and port rules. | Cross-host | Strict coded normalization. |
57
- | [`AsyncBoundary.js`](#asyncboundaryjs) | esm | Runs one asynchronous operation with timeout, abort, result validation, and stable boundary errors. | Cross-host | Fully normalized timeout/abort errors. |
58
- | [`BrowserTestSuite.js`](#browsertestsuitejs) | esm | Runs a fixed sequential browser test list with cooperative abort, per-test timeout, and lifecycle events. | Browser / standard Web APIs | Normalized result and skip/assertion errors. |
59
- | [`CalculatorEngine.js`](#calculatorenginejs) | esm | Evaluates bounded arithmetic, powers, constants, and common functions without `eval`. | Cross-host | Normalized `Calculation` result and parser errors. |
60
- | [`CaseEvidenceIndexer.js`](#caseevidenceindexerjs) | esm | Pairs and indexes structured evidence records with rendered-page provenance and SHA-256 identity. | Node only | Normalized naming/page helpers; filesystem errors preserved. |
61
- | [`ChartLibrary.js`](#chartlibraryjs) | esm | Loads the bundled uPlot classic script once and returns its global constructor. | Browser / native WebView | Load state/errors normalized; uPlot result is vendor-native. |
62
- | [`ChatRecords.js`](#chatrecordsjs) | esm | Detects whether a chat record contains a meaningful user entry. | Cross-host | Boolean normalized result. |
63
- | [`CommunicationAppController.js`](#communicationappcontrollerjs) | esm | Binds shared inbox, conversation, settings, theme, and provider workflows into one UI controller. | Browser / native WebView hybrid | Controller state normalized; provider/DOM failures mixed. |
64
- | [`CommunicationHub.js`](#communicationhubjs) | esm | Fans out provider refresh/send operations and aggregates normalized threads/messages. | Cross-host with injected providers | Normalized aggregates; refresh contains per-provider failures. |
65
- | [`CommunicationPreferences.js`](#communicationpreferencesjs) | esm | Stores app-scoped, non-secret communication provider preferences. | Browser / native WebView hybrid | Normalized preference record; storage failures mixed. |
66
- | [`CommunicationProviderRegistry.js`](#communicationproviderregistryjs) | esm | Registers and queries validated provider definitions, channels, and required methods. | Cross-host | Strict normalized registry. |
67
- | [`ComponentContracts.js`](#componentcontractsjs) | esm | Owns normalized configuration/value contracts and shared explicit STT activation behavior for chart, dashboard, Markdown, and voice components. | Cross-host | Fully normalized labels, rows, definitions, visibility, formats, editor and voice options, plus capability-neutral STT activation intent and presentation state. |
68
- | [`ConfiguredAIChatSession.js`](#configuredaichatsessionjs) | esm | Owns bounded in-memory AI turns, context construction, response-length instruction, and atomic history commit. | Native bridge by default; cross-host with injected chat | Normalized session/result; provider rejection preserved. |
69
- | [`ConversationActionItems.js`](#conversationactionitemsjs) | esm | Normalizes, creates, updates, remembers, selects, and formats bounded conversation action items. | Cross-host | Fully normalized status/base/presentation contract. |
70
- | [`ConversationClosingReport.js`](#conversationclosingreportjs) | esm | Defines the closing-report tool, instruction, result normalizer, call classifier, and formatter. | Cross-host | Fully normalized report contract. |
71
- | [`ConversationTimebox.js`](#conversationtimeboxjs) | esm | Owns conversation limits, control messages, submission barriers, elapsed formatting, and delivery proof. | Cross-host | Fully normalized state/command/delivery errors. |
72
- | [`CoreLocalModelCatalog.js`](#corelocalmodelcatalogjs) | esm | Projects Core local-AI status into UI-safe admitted model and speech availability catalogs. | Cross-host | Fully normalized descriptors and stable admission labels. |
73
- | [`DataMaintenance.js`](#datamaintenancejs) | esm | Deletes empty chats and associated/empty memory records inside the current app data scope. | Browser / native WebView | Normalized counts; destructive storage failures preserved. |
74
- | [`DBLS.js`](#dblsjs) | esm | Provides app-scoped localStorage tables, batch reads/writes, filtering, deletion, and counts. | Browser / native WebView | Scoped keys and values normalized; storage failures mixed. |
75
- | [`DBOPFS.js`](#dbopfsjs) | esm | Provides app-scoped OPFS tables, worker I/O, backup/restore, compression, and CRUD/batch APIs. | Browser / native WebView | App scope normalized; DOM/storage errors preserved. |
76
- | [`DBOPFSDocumentLibrary.js`](#dbopfsdocumentlibraryjs) | esm | Bootstraps and searches an app-defined DBOPFS corpus and builds explicitly untrusted chat context. | Browser or compatible DBOPFS host | Existing DBOPFS semantics; manifest-last generations and bounded search only after the app calls it or wires its context builder. |
77
- | [`DBOPFSWorker.js`](#dbopfsworkerjs) | worker | Serializes OPFS sync-handle read/write requests from a MessagePort. | Dedicated worker | Responses normalize to `{success,fileData?}` or `{error:{name,message}}`. |
78
- | [`DevelopmentWorkspace.js`](#developmentworkspacejs) | esm | Provides bounded workspace inspection, context, setup task, and Node installer clients without arbitrary command execution. | Native bridge | Inputs normalized; provider result/error preserved. |
79
- | [`DirectoryPicker.js`](#directorypickerjs) | esm | Wraps the provider-owned native directory chooser and normalizes selected/cancelled/error results. | Native bridge | Strict normalized selection and coded errors. |
80
- | [`DocumentLexicalSearch.js`](#documentlexicalsearchjs) | esm | Provides dependency-free deterministic metadata/body ranking and bounded excerpts. | Cross-host | Frozen stable results with no storage, provider, or network side effects. |
81
- | [`DocumentNavigation.js`](#documentnavigationjs) | esm | Binds document navigation, filtering, history, current-item reveal, and load initialization. | Browser / native WebView | Normalized filter/navigation state; DOM effects preserved. |
82
- | [`Errors.js`](#errorsjs) | esm | Normalizes global errors/rejections, fingerprints and deduplicates incidents, persists a ledger, and performs bounded delivery. | Browser / native WebView hybrid | Incident records normalized; storage/mail failures isolated. |
83
- | [`GifEncoder.js`](#gifencoderjs) | esm | Encodes indexed frames into a bounded animated GIF using palette mapping and LZW. | Cross-host | Normalized byte output and bounds. |
84
- | [`HTMLImport.js`](#htmlimportjs) | esm | Defines the same-origin `<html-import>` loader with open shadow root, inline script execution, and readiness/error events. | Browser / native WebView | Public error detail normalized; fetch/DOM failure preserved. |
85
- | [`InMemoryCommunicationProvider.js`](#inmemorycommunicationproviderjs) | esm | Implements deterministic in-memory thread/message/send behavior for demos and tests. | Cross-host | Normalized communication entities. |
86
- | [`IsolatedModelQuestionRunner.js`](#isolatedmodelquestionrunnerjs) | esm | Inspects one exact model and runs one isolated question with proof validation. | Native bridge or injected provider | Strict normalized proof/coded errors. |
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. |
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. |
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. |
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. |
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. |
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. |
94
- | [`MemoryRecords.js`](#memoryrecordsjs) | esm | Normalizes memory content and detects meaningful stored memory. | Cross-host | Fully normalized string/boolean results. |
95
- | [`MessageAdvisory.js`](#messageadvisoryjs) | esm | Normalizes message content advisories and contains per-message inspection failures. | Cross-host | Normalized advisory records; inspector failures converted to unavailable results. |
96
- | [`ModelDefinition.js`](#modeldefinitionjs) | esm | Parses the deterministic packaged Modelfile subset and extracts the SYSTEM prompt. | Cross-host | Strict normalized definition with coded syntax errors. |
97
- | [`Ollama.js`](#ollamajs) | esm | Provides the first-class Arcane Ollama client without direct access to localhost:11434. | Native bridge | Principal methods preserve provider-native envelopes; readiness/text/unload helpers normalize. |
98
- | [`OllamaModelIdentifier.js`](#ollamamodelidentifierjs) | esm | Validates and canonicalizes the syntax of Ollama model identifiers without granting model admission. | Cross-host | Fully normalized string/boolean result. |
99
- | [`OllamaSettings.js`](#ollamasettingsjs) | esm | Defines bounded runtime/service preference schemas and deterministic Arcane brain alias names. | Cross-host | Fully normalized settings/name contract. |
100
- | [`OpenMeteoWeatherProvider.js`](#openmeteoweatherproviderjs) | esm | Searches and loads Open-Meteo data into frozen Arcane weather entities. | Browser / native WebView / server with fetch + cloud | Provider data normalized to entities; transport errors mixed. |
101
- | [`PersistentAIChatSession.js`](#persistentaichatsessionjs) | esm | Adds explicit durable history/memory policy to bounded configured chat without changing DBOPFS or ChatEntity semantics. | Browser / native WebView with DBOPFS and configured chat | Live context commits atomically; persistence stays coherent across user/assistant/tool turns. |
102
- | [`PreferenceStore.js`](#preferencestorejs) | esm | Loads and updates schema-defined app preferences through native storage with a narrow browser fallback. | Browser/native hybrid | Values normalized; only exact unsupported capability falls back. |
103
- | [`QRCode.min.js`](#qrcodeminjs) | classic-script | Vendored QRCode generator for DOM, canvas, SVG, and image output. | Browser vendor script | Vendor-native. |
104
- | [`Questionnaire.js`](#questionnairejs) | esm | Evaluates whether a one-time questionnaire prompt is due without performing the prompt. | Cross-host | Normalized fail-closed boolean. |
105
- | [`RecordLinkIndex.js`](#recordlinkindexjs) | esm | Parses record links and builds their normalized index. | Cross-host | Fully normalized. |
106
- | [`RecordPassageIndex.js`](#recordpassageindexjs) | esm | Indexes text lines, page markers, dates, rules, and excerpts for record review. | Cross-host | Fully normalized. |
107
- | [`RecordReviewStore.js`](#recordreviewstorejs) | esm | Stores normalized record-review decisions through native storage or app-scoped local fallback. | Browser/native hybrid | Normalized ids/reviews/snapshots; storage failures mixed. |
108
- | [`RevocableProjectionLedger.js`](#revocableprojectionledgerjs) | esm | Implements an append-only bounded in-memory projection/revocation ledger safe for hostile descriptor inputs. | Cross-host | Strict normalization with stable `ProjectionLedgerError`. |
109
- | [`RiskSignalAnalyzer.js`](#risksignalanalyzerjs) | esm | Matches configured risk signals and levels against bounded text. | Cross-host | Fully normalized. |
110
- | [`ScamRiskPolicy.js`](#scamriskpolicyjs) | esm | Combines deterministic scam signals with Arcane blocked-domain evidence and safety guidance. | Cross-host | Fully normalized. |
111
- | [`ScopedOPFSCache.js`](#scopedopfscachejs) | esm | Provides a narrow exact-key JSON cache inside one app-owned OPFS namespace. | Browser / native WebView | Keys/limits/corruption handling normalized; storage errors mixed. |
112
- | [`ScreenCapture.js`](#screencapturejs) | esm | Captures a display surface as image, video, or GIF with explicit lifecycle events. | Browser / native WebView | State/events normalized; permission and codec errors mixed. |
113
- | [`SpeechPlayback.js`](#speechplaybackjs) | esm | Segments bounded text, queues latest-request speech synthesis, and controls lookahead HTML audio playback. | Browser + native bridge | State/limits normalized; provider/media failures mixed. |
114
- | [`StaticDocumentCatalog.js`](#staticdocumentcatalogjs) | esm | Loads a positive static document inventory with byte/hash verification, cache, search, and bounded context. | Browser / native WebView / server with fetch | Strict catalog/content normalization; transport failures mixed. |
115
- | [`SystemAppearance.js`](#systemappearancejs) | esm | Reads or applies native appearance, returning an explicit unsupported browser state when no bridge exists. | Browser/native hybrid | Absent bridge normalized; native result/error preserved. |
116
- | [`SystemPlatformPresentation.js`](#systemplatformpresentationjs) | classic-script | Maps kernel names to presentation labels/classes without granting platform authority. | Browser / native WebView classic script | Fully normalized presentation only. |
117
- | [`SystemToolRegistry.js`](#systemtoolregistryjs) | esm | Registers validated command builders and constructs command strings without executing them. | Cross-host | Fully normalized definitions/quoting. |
118
- | [`TerminalClient.js`](#terminalclientjs) | esm | Maps native terminal sessions and Arcane events into an EventTarget client. | Native bridge | Client events/state normalized; native result/error mixed. |
119
- | [`TerminalCommandRegistry.js`](#terminalcommandregistryjs) | esm | Routes parsed command lines to injected handlers and provides definitions/completions. | Cross-host | Parsing/routing normalized; handler result/error preserved. |
120
- | [`ThemeBootstrap.js`](#themebootstrapjs) | esm | Performs import-time Arcane theme loading and subscribes to native appearance changes. | Browser/native hybrid | Theme state normalized; storage/native errors mixed. |
121
- | [`ThemeManager.js`](#thememanagerjs) | esm | Loads, applies, previews, saves, resets, and synchronizes semantic Arcane themes. | Browser/native hybrid | Theme values/events normalized; storage/native failures mixed. |
122
- | [`TimeGuard.js`](#timeguardjs) | esm | Persists and evaluates clock rollback and grace-period state. | Browser / native WebView | Time decisions normalized; storage lifecycle mixed. |
123
- | [`ToolCallRouter.js`](#toolcallrouterjs) | esm | Parses OpenAI-style tool calls and dispatches complete or streamed calls to injected handlers. | Cross-host | Arguments/routing normalized; handler results returned or all-settled. |
124
- | [`uPlot.iife.min.js`](#uplotiifeminjs) | classic-script | Vendored uPlot chart constructor and rendering runtime. | Browser vendor script | Vendor-native. |
125
- | [`uPlot.LICENSE.txt`](#uplotlicensetxt) | license | License companion for the bundled uPlot vendor runtime. | Documentation asset | Not executable. |
126
- | [`uPlot.min.css`](#uplotmincss) | stylesheet | Bundled uPlot presentation stylesheet. | Browser stylesheet | Presentation only. |
127
- | [`WaitForComponent.js`](#waitforcomponentjs) | esm | Waits for a component property, method, or readiness event with optional error event and bounded timeout. | Cross-host EventTarget / browser component | Normalized coded readiness, error, and timeout results. |
128
- | [`YouTubeMedia.js`](#youtubemediajs) | esm | Validates YouTube video/playlist locators and constructs privacy-enhanced embed URLs. | Cross-host | Fully normalized. |
129
-
130
- ## AI.js
131
-
132
- ### Overview
133
-
134
- Provider-selectable chat, speech-to-text, text-to-speech, tool calling, structured output, streaming, and queued audio playback.
135
-
136
- ### Public surface
137
-
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()`,
143
- `streamRequest()`, `streamMessage()`, `fetchRequest()`, `fetch()`,
144
- `streamTTS()`, `finishTTS()`, `fetchTTS()`, `fetchSTT()`, `stopAudio()`, `resumeAudio()`,
145
- `playAudio()`; consumes `user-entity-loaded` and `arcane-ollama-ready`,
146
- installs `window.ai`, and emits `ai-ready`.
147
-
148
- The provider-runtime methods keep LLM, STT, and TTS selection explicit. They do
149
- not reinterpret one provider's failure as permission to select another
150
- provider. `transitionAI()` and `transitionProviders()` are deliberate
151
- cross-role transitions: each stops queued audio, unloads the current LLM, STT,
152
- and TTS roles, then applies the replacement configuration. `transitionAI()`
153
- returns aggregate runtime status; `transitionProviders()` returns the admitted
154
- three-role route configuration. Selected `OPENAI` LLM/STT/TTS, `OLLAMA` LLM,
155
- and admitted Core `LOCAL_SPEACH` STT/TTS legacy routes expose truthful
156
- capability-only readiness through internal provider/2 adapters without probing,
157
- downloading, or hiding a load. Cloud speech admission requires the selected
158
- route, its model, a credential, and `fetch`; Core speech admission requires the
159
- exact selected `Arcane.speech.transcribe` or `synthesize` method. `fetchRequest()`
160
- keeps the selected provider's public response shape. Browser speech routes
161
- translate the existing AI.js STT `{audio:Blob|File,mimeType,model}` and TTS
162
- `{model,input,responseFormat,voice?,speed?}` requests at the provider boundary;
163
- only WAV is accepted for the shared TTS result. TTS voice selection comes from
164
- the exact selected provider/model catalog `defaultVoice`; a saved OpenAI voice
165
- is used only by the selected OpenAI adapter and is never forwarded to another
166
- provider route.
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
-
176
- `startProviders({startMuted=true,startTranscription=false,signal=null}={})`
177
- starts text chat without requesting an STT load by default; it does not undo an
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,
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.
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;
200
- delivery suppression is guaranteed after abort, while underlying provider-stop
201
- claims remain limited to that provider's cancellation contract.
202
-
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`.
362
-
363
- ### Availability and normalization
364
-
365
- **Browser + native bridge + cloud.** High-level chat/speech behavior is
366
- normalized; provider diagnostics and media errors remain mixed. Transport:
367
- AIProviderRuntime `arcane-ai-provider/2` routes, OpenAI HTTPS, Arcane.ollama,
368
- Arcane.speech, and the Android WebView bridge. [Deep protocol details](protocols.md).
369
-
370
- ### Example
371
-
372
- The configuration example above is the minimal one-time application flow.
373
-
374
- ## AIPreferenceRuntime.js
375
-
376
- ### Overview
377
-
378
- Applies and reads non-persistent per-user AI preference overrides.
379
-
380
- ### Public surface
381
-
382
- `setAIPreferenceRuntimeOverride()`, `getAIPreferencesForRuntime()`.
383
-
384
- Exact exports: `getAIPreferencesForRuntime`, `setAIPreferenceRuntimeOverride`.
385
-
386
- ### Availability and normalization
387
-
388
- **Cross-host.** Normalized six-slot preference state. Transport: In-process only. [Deep protocol details](protocols.md).
389
-
390
- ### Example
391
-
392
- ```javascript
393
- import * as module from '/arcane/modules/AIPreferenceRuntime.js';
394
-
395
- console.log(Object.keys(module));
396
- ```
397
-
398
- ## AIPreferenceTuple.js
399
-
400
- ### Overview
401
-
402
- Normalizes and compares the six provider/model preference slots.
403
-
404
- ### Public surface
405
-
406
- `AI_PREFERENCE_SLOT_KEYS`, `normalizeAIPreferenceTuple()`, `aiPreferenceTuplesEqual()`.
407
-
408
- Exact exports: `AI_PREFERENCE_SLOT_KEYS`, `aiPreferenceTuplesEqual`, `normalizeAIPreferenceTuple`.
409
-
410
- ### Availability and normalization
411
-
412
- **Cross-host.** Fully normalized frozen tuple. Transport: In-process only. [Deep protocol details](protocols.md).
413
-
414
- ### Example
415
-
416
- ```javascript
417
- import * as module from '/arcane/modules/AIPreferenceTuple.js';
418
-
419
- console.log(Object.keys(module));
420
- ```
421
-
422
- ## AIProviderRuntime.js
423
-
424
- ### Overview
425
-
426
- Owns the portable provider-neutral runtime for independently selected LLM,
427
- speech-to-text, and text-to-speech providers. The exported class documents the
428
- shape, but application code uses the exported singleton returned by
429
- `getAIProviderRuntime()`; direct construction fails with
430
- `ARCANE_AI_RUNTIME_SINGLETON_REQUIRED`.
431
-
432
- ### Public surface
433
-
434
- Exact exports: `AI_MODEL_AUTHORITY_PROTOCOL`, `AI_PROVIDER_PROTOCOL`,
435
- `AI_PROVIDER_RUNTIME_PROTOCOL`, `AIProviderRuntime`, `aiProviderRuntime`, and
436
- `getAIProviderRuntime`.
437
-
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
454
- be data-only; callbacks, accessors, symbols, cycles, and excessive nesting are
455
- rejected at the provider boundary.
456
-
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
506
- `{barrier,settled,cancel}`. Startup does not request selected STT unless the
507
- caller explicitly opts in; it does not force an independently active STT role
508
- back to unloaded. The barrier and settled promises describe provider-startup
509
- readiness; cancellation remains cooperative through the supplied signal and
510
- returned control.
511
-
512
- Interactive requests are latest-request-wins per role. A newer valid request
513
- that reaches admission aborts the active request, waits for its provider promise
514
- to settle (or for bounded stream cleanup to be confirmed), and revalidates
515
- ready/loaded/not-busy state before it starts. Rapid intermediate requests are
516
- superseded, and their late results cannot restore or overwrite newer role state.
517
- Promise settlement proves only that the provider's exposed request promise
518
- completed; it does not by itself prove that underlying provider work stopped.
519
- Provider-specific positive cancellation acknowledgement remains
520
- provider-specific. Load and reconfiguration guards stay fail-closed while
521
- request ownership is active.
522
-
523
- ### Availability and normalization
524
-
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
527
- narrow AI.js legacy OpenAI/Ollama/Core-speech adapters; other native, Core, or
528
- cloud adapters may be supplied externally only when they implement the same
529
- `arcane-ai-provider/2` boundary. A
530
- provider must prove a matching `arcane-ai-model-authority/1` inspection before load.
531
- `localOnly` routing fails closed; it never selects a cloud or non-local route as
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
535
- selected provider retains its own capability, permission, download, and model
536
- requirements. [Deep protocol details](protocols.md#portable-ai-provider-runtime).
537
-
538
- ### Example
539
-
540
- ```javascript
541
- import {getAIProviderRuntime} from '/arcane/modules/AIProviderRuntime.js';
542
-
543
- const runtime = getAIProviderRuntime();
544
- console.log(runtime.protocol, runtime.status());
545
- ```
546
-
547
- ## AIResponseLength.js
548
-
549
- ### Overview
550
-
551
- Normalizes concise/short/medium/long response preferences and applies the matching system instruction.
552
-
553
- ### Public surface
554
-
555
- Response-length constants plus `normalizeAIResponseLength()`, `aiResponseLengthInstruction()`, and `applyAIResponseLength()`.
556
-
557
- Exact exports: `AI_RESPONSE_LENGTH_DEFAULT`, `AI_RESPONSE_LENGTH_OPTIONS`, `aiResponseLengthInstruction`, `applyAIResponseLength`, `normalizeAIResponseLength`.
558
-
559
- ### Availability and normalization
560
-
561
- **Cross-host.** Fully normalized string/instruction contract. Transport: In-process only. [Deep protocol details](protocols.md).
562
-
563
- ### Example
564
-
565
- ```javascript
566
- import * as module from '/arcane/modules/AIResponseLength.js';
567
-
568
- console.log(Object.keys(module));
569
- ```
570
-
571
- ## AIResponseURLPolicy.js
572
-
573
- ### Overview
574
-
575
- Extracts and audits links from AI Markdown, rendered HTML, CSS, srcset, bare URLs, and email text.
576
-
577
- ### Public surface
578
-
579
- `auditAIResponseLinks()`, `extractAIResponseLinks()`, `normalizeAIResponseLink()`, `decodeHTMLCharacterReferences()`.
580
-
581
- Exact exports: `auditAIResponseLinks`, `decodeHTMLCharacterReferences`, `extractAIResponseLinks`, `normalizeAIResponseLink`.
582
-
583
- ### Availability and normalization
584
-
585
- **Cross-host.** Normalized frozen allowlist audit. Transport: In-process; bundled Marked parser. [Deep protocol details](protocols.md).
586
-
587
- ### Example
588
-
589
- ```javascript
590
- import * as module from '/arcane/modules/AIResponseURLPolicy.js';
591
-
592
- console.log(Object.keys(module));
593
- ```
594
-
595
- ## AIRuntimeState.js
596
-
597
- ### Overview
598
-
599
- Publishes one sticky immutable state tree for `llm`, `stt`, and `tts`, transient
600
- load/unload/dispose intents, and a startup-settlement report. It makes lifecycle
601
- observable without exposing provider transports in application code.
602
-
603
- ### Public surface
604
-
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`.
611
-
612
- Each role record is exactly `{role,state,providerId,modelId,localOnly,loaded,
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.
620
- `startAIRuntime({startMuted=true,startTranscription=false,signal})` returns
621
- `{barrier,settled,cancel}`: `barrier` settles for text chat, while `settled`
622
- covers every requested role. Muted startup does not request TTS, and STT startup
623
- is opt-in so selection and state observation do not begin a transcription-model
624
- load.
625
-
626
- ### Availability and normalization
627
-
628
- **Cross-host state contract.** States are `unavailable`, `unloaded`, `loading`,
629
- `ready`, `unloading`, `error`, and `disposed`. Revisions increase monotonically.
630
- The events `arcane-ai-runtime-state`, `arcane-ai-runtime-intent`, and
631
- `arcane-ai-runtime-startup-settled` normalize observation only: receiving one
632
- does not grant a native capability, prove browser support, or load a provider.
633
- `arcane-ai-runtime-startup-settled` reports the LLM/text-chat `barrier`.
634
- Await the returned `handle.settled` promise for every role requested by that
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`.
641
-
642
- ### Example
643
-
644
- ```javascript
645
- import {
646
- getAIRuntimeState,
647
- subscribeAIRuntimeState
648
- } from '/arcane/modules/AIRuntimeState.js';
649
-
650
- const unsubscribe = subscribeAIRuntimeState(snapshot => {
651
- console.log(snapshot.roles.llm.state);
652
- });
653
- console.log(getAIRuntimeState().protocol);
654
- unsubscribe();
655
- ```
656
-
657
- ## AnsiText.js
658
-
659
- ### Overview
660
-
661
- Parses terminal ANSI sequences into display spans or strips them to plain text.
662
-
663
- ### Public surface
664
-
665
- `parseAnsi()`, `stripAnsi()`.
666
-
667
- Exact exports: `parseAnsi`, `stripAnsi`.
668
-
669
- ### Availability and normalization
670
-
671
- **Cross-host.** Normalized text/span output. Transport: In-process only. [Deep protocol details](protocols.md).
672
-
673
- ### Example
674
-
675
- ```javascript
676
- import * as module from '/arcane/modules/AnsiText.js';
677
-
678
- console.log(Object.keys(module));
679
- ```
680
-
681
- ## ApiModelDatabase.js
682
-
683
- ### Overview
684
-
685
- Fetches an injectable HTTP JSON model with parser, cache, redacted public endpoint records, and request lifecycle events.
686
-
687
- ### Public surface
688
-
689
- default `ApiModelDatabase`; `setEndpoint()`, `fetch()`, `cached()`; emits `api-model-request`, `api-model-success`, and `api-model-error`.
690
-
691
- Exact exports: `API_MODEL_ERRORS`, `API_MODEL_EVENTS`, `appendParameters`,
692
- `default`, `publicEndpoint`.
693
-
694
- ### Availability and normalization
695
-
696
- **Browser / native WebView / server with fetch.** Request records are normalized; fetch/provider failures remain mixed. Transport: HTTP(S) fetch. [Deep protocol details](protocols.md).
697
-
698
- ### Example
699
-
700
- ```javascript
701
- import * as module from '/arcane/modules/ApiModelDatabase.js';
702
-
703
- console.log(Object.keys(module));
704
- ```
705
-
706
- ## AppDataScope.js
707
-
708
- ### Overview
709
-
710
- Reconciles declared and native application identity and scopes OPFS/localStorage ownership fail-closed.
711
-
712
- ### Public surface
713
-
714
- Identity constants and `canonicalApplicationId()`, `resolveApplicationId()`, `resolveApplicationLocalStorageKey()`, `openApplicationDataDirectory()`.
715
-
716
- Exact exports: `APPLICATION_ID_MAX_LENGTH`, `APPLICATION_ID_PATTERN`, `APP_DATA_DIRECTORY`, `APP_LOCAL_STORAGE_PREFIX`, `canonicalApplicationId`, `declaredApplicationId`, `openApplicationDataDirectory`, `resolveApplicationId`, `resolveApplicationLocalStorageKey`, `resolveBrowserApplicationId`.
717
-
718
- ### Availability and normalization
719
-
720
- **Browser / native WebView hybrid.** Strict normalized identifiers and coded mismatch failures. Transport: Arcane.app.current, DOM declaration, OPFS. [Deep protocol details](protocols.md).
721
-
722
- ### Example
723
-
724
- ```javascript
725
- import * as module from '/arcane/modules/AppDataScope.js';
726
-
727
- console.log(Object.keys(module));
728
- ```
729
-
730
- ## AppearancePreferences.js
731
-
732
- ### Overview
733
-
734
- Defines, stores, and applies color scheme, density, reduced motion, and large-text preferences.
735
-
736
- ### Public surface
737
-
738
- `appearancePreferenceSchema`, `createAppearancePreferenceStore()`, `applyAppearancePreferences()`, `loadAndApplyAppearancePreferences()`.
739
-
740
- Exact exports: `appearancePreferenceSchema`, `applyAppearancePreferences`, `createAppearancePreferenceStore`, `loadAndApplyAppearancePreferences`.
741
-
742
- ### Availability and normalization
743
-
744
- **Browser / native WebView hybrid.** Normalized values; storage/host failures remain mixed. Transport: PreferenceStore, DOM, optional Arcane preferences. [Deep protocol details](protocols.md).
745
-
746
- ### Example
747
-
748
- ```javascript
749
- import * as module from '/arcane/modules/AppearancePreferences.js';
750
-
751
- console.log(Object.keys(module));
752
- ```
753
-
754
- ## ArcaneCommunicationBridge.js
755
-
756
- ### Overview
757
-
758
- Maps provider HTTP threads/messages/connect/disconnect endpoints to normalized communication entities.
759
-
760
- ### Public surface
761
-
762
- default `ArcaneCommunicationBridge`; `request()`, `listThreads()`, `getMessages()`, `send()`, `connect()`, `disconnect()`.
763
-
764
- Exact exports: `default`.
765
-
766
- ### Availability and normalization
767
-
768
- **Browser / native WebView / server with fetch.** Entity results are normalized; provider/transport failures remain mixed. Transport: JSON HTTP(S), default loopback 127.0.0.1:8020. [Deep protocol details](protocols.md).
769
-
770
- ### Example
771
-
772
- ```javascript
773
- import * as module from '/arcane/modules/ArcaneCommunicationBridge.js';
774
-
775
- console.log(Object.keys(module));
776
- ```
777
-
778
- ## ArcaneNavigationPolicy.js
779
-
780
- ### Overview
781
-
782
- Creates a fail-closed HTTP(S) navigation guard with domain and CIDR policy decisions.
783
-
784
- ### Public surface
785
-
786
- `createArcaneNavigationGuard()`.
787
-
788
- Exact exports: `createArcaneNavigationGuard`.
789
-
790
- ### Availability and normalization
791
-
792
- **Cross-host.** Normalized frozen allow/block decision. Transport: Arcane network-policy document. [Deep protocol details](protocols.md).
793
-
794
- ### Example
795
-
796
- ```javascript
797
- import * as module from '/arcane/modules/ArcaneNavigationPolicy.js';
798
-
799
- console.log(Object.keys(module));
800
- ```
801
-
802
- ## ArcaneNetworkPolicy.js
803
-
804
- ### Overview
805
-
806
- Validates the Arcane domain/network deny policy and matches domain, IPv4/IPv6 CIDR, protocol, and port rules.
807
-
808
- ### Public surface
809
-
810
- Policy constants plus validate/load/cache/match helpers.
811
-
812
- Exact exports: `ARCANE_NETWORK_POLICY_SCHEMA_VERSION`, `ARCANE_NETWORK_POLICY_URL`, `canonicalNetworkHostname`, `emptyArcaneNetworkPolicy`, `findDeniedDomainRule`, `findDeniedNetworkRule`, `invalidateArcaneNetworkPolicyCache`, `loadArcaneNetworkPolicy`, `validateArcaneNetworkPolicy`.
813
-
814
- ### Availability and normalization
815
-
816
- **Cross-host.** Strict coded normalization. Transport: Same-origin policy fetch. [Deep protocol details](protocols.md).
817
-
818
- ### Example
819
-
820
- ```javascript
821
- import * as module from '/arcane/modules/ArcaneNetworkPolicy.js';
822
-
823
- console.log(Object.keys(module));
824
- ```
825
-
826
- ## AsyncBoundary.js
827
-
828
- ### Overview
829
-
830
- Runs one asynchronous operation with timeout, abort, result validation, and stable boundary errors.
831
-
832
- ### Public surface
833
-
834
- `AsyncBoundaryTimeoutError`, `AsyncBoundaryAbortError`, defaults, `runAsyncBoundary()`, and default alias.
835
-
836
- Exact exports: `AsyncBoundaryAbortError`, `AsyncBoundaryTimeoutError`, `asyncBoundaryDefaults`, `default`, `runAsyncBoundary`.
837
-
838
- ### Availability and normalization
839
-
840
- **Cross-host.** Fully normalized timeout/abort errors. Transport: AbortController and timers. [Deep protocol details](protocols.md).
841
-
842
- ### Example
843
-
844
- ```javascript
845
- import * as module from '/arcane/modules/AsyncBoundary.js';
846
-
847
- console.log(Object.keys(module));
848
- ```
849
-
850
- ## BrowserTestSuite.js
851
-
852
- ### Overview
853
-
854
- Runs a fixed sequential browser test list with cooperative abort, per-test timeout, and lifecycle events.
855
-
856
- ### Public surface
857
-
858
- default `BrowserTestSuite`; `list()`, `run()`; emits suite/test start/result/complete events.
859
-
860
- Exact exports: `BROWSER_TEST_SUITE_ERROR_CODES`,
861
- `BROWSER_TEST_SUITE_EVENT_TYPES`, `BROWSER_TEST_SUITE_REASONS`,
862
- `assertionError`, `default`, `skipError`.
863
-
864
- ### Availability and normalization
865
-
866
- **Browser / standard Web APIs.** Normalized result and skip/assertion errors. Transport: EventTarget and timers. [Deep protocol details](protocols.md).
867
-
868
- ### Example
869
-
870
- ```javascript
871
- import * as module from '/arcane/modules/BrowserTestSuite.js';
872
-
873
- console.log(Object.keys(module));
874
- ```
875
-
876
- ## CalculatorEngine.js
877
-
878
- ### Overview
879
-
880
- Evaluates bounded arithmetic, powers, constants, and common functions without `eval`.
881
-
882
- ### Public surface
883
-
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.
894
-
895
- Exact exports: `CALCULATOR_ENGINE_ERROR_CODES`, `default`,
896
- `evaluateExpression`.
897
-
898
- ### Availability and normalization
899
-
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).
918
-
919
- ### Example
920
-
921
- ```javascript
922
- import * as module from '/arcane/modules/CalculatorEngine.js';
923
-
924
- console.log(Object.keys(module));
925
- ```
926
-
927
- ## CaseEvidenceIndexer.js
928
-
929
- ### Overview
930
-
931
- Pairs and indexes structured evidence records with rendered-page provenance and SHA-256 identity.
932
-
933
- ### Public surface
934
-
935
- Eight exported indexing, page, naming, stem, and digest helpers.
936
-
937
- Exact exports: `indexPairedRecord`, `nearestPageMarker`, `parseStructuredRecordName`, `renderedPageBlocks`, `resolveEvidenceSourcePage`, `safeName`, `sha256`, `stem`.
938
-
939
- ### Availability and normalization
940
-
941
- **Node only and host-internal.** Normalized naming/page helpers; filesystem errors preserved. The file imports `node:fs/promises`, `node:path`, and `node:crypto`, so a renderer must not import it from `/arcane/modules/`. This SDK version does not expose it as an npm subpath; the example applies to repository-owned Node tooling. [Deep protocol details](protocols.md).
942
-
943
- ### Example
944
-
945
- ```javascript
946
- // From a repository-owned tools/*.mjs file:
947
- import {safeName, stem} from '../runtime/arcane/modules/CaseEvidenceIndexer.js';
948
-
949
- console.log(safeName('Evidence 01.pdf'), stem('Evidence 01.pdf'));
950
- ```
951
-
952
- ## ChartLibrary.js
953
-
954
- ### Overview
955
-
956
- Loads the bundled uPlot classic script once and returns its global constructor.
957
-
958
- ### Public surface
959
-
960
- default `loadChartLibrary()`.
961
-
962
- Exact exports: `default`.
963
-
964
- ### Availability and normalization
965
-
966
- **Browser / native WebView.** Load state/errors normalized; uPlot result is vendor-native. Transport: DOM script injection. [Deep protocol details](protocols.md).
967
-
968
- ### Example
969
-
970
- ```javascript
971
- import * as module from '/arcane/modules/ChartLibrary.js';
972
-
973
- console.log(Object.keys(module));
974
- ```
975
-
976
- ## ChatRecords.js
977
-
978
- ### Overview
979
-
980
- Detects whether a chat record contains a meaningful user entry.
981
-
982
- ### Public surface
983
-
984
- `hasUserEntry()`.
985
-
986
- Exact exports: `hasUserEntry`.
987
-
988
- ### Availability and normalization
989
-
990
- **Cross-host.** Boolean normalized result. Transport: In-process only. [Deep protocol details](protocols.md).
991
-
992
- ### Example
993
-
994
- ```javascript
995
- import * as module from '/arcane/modules/ChatRecords.js';
996
-
997
- console.log(Object.keys(module));
998
- ```
999
-
1000
- ## CommunicationAppController.js
1001
-
1002
- ### Overview
1003
-
1004
- Binds shared inbox, conversation, settings, theme, and provider workflows into one UI controller.
1005
-
1006
- ### Public surface
1007
-
1008
- default controller with `start()`, `bind()`, `configure()`, `refresh()`, `select()`, `send()`, and settings actions.
1009
-
1010
- Exact exports: `COMMUNICATION_APP_CONTROLLER_ERROR_CODES`, `default`.
1011
-
1012
- ### Availability and normalization
1013
-
1014
- **Browser / native WebView hybrid.** Controller state normalized; provider/DOM failures mixed. Transport: DOM plus communication providers. [Deep protocol details](protocols.md).
1015
-
1016
- ### Example
1017
-
1018
- ```javascript
1019
- import * as module from '/arcane/modules/CommunicationAppController.js';
1020
-
1021
- console.log(Object.keys(module));
1022
- ```
1023
-
1024
- ## CommunicationHub.js
1025
-
1026
- ### Overview
1027
-
1028
- Fans out provider refresh/send operations and aggregates normalized threads/messages.
1029
-
1030
- ### Public surface
1031
-
1032
- default `CommunicationHub`; provider enablement, `refresh()`, `messages()`, and `send()`.
1033
-
1034
- Exact exports: `COMMUNICATION_HUB_ERROR_CODES`, `COMMUNICATION_HUB_EVENTS`,
1035
- `COMMUNICATION_HUB_REFRESH_REASONS`, `COMMUNICATION_HUB_REFRESH_STATES`, and
1036
- `default`.
1037
-
1038
- ### Availability and normalization
1039
-
1040
- **Cross-host with injected providers.** Normalized aggregates; refresh contains per-provider failures. Transport: Injected provider contract. [Deep protocol details](protocols.md).
1041
-
1042
- ### Example
1043
-
1044
- ```javascript
1045
- import * as module from '/arcane/modules/CommunicationHub.js';
1046
-
1047
- console.log(Object.keys(module));
1048
- ```
1049
-
1050
- ## CommunicationPreferences.js
1051
-
1052
- ### Overview
1053
-
1054
- Stores app-scoped, non-secret communication provider preferences.
1055
-
1056
- ### Public surface
1057
-
1058
- default `CommunicationPreferences`; `load()`, `save()`.
1059
-
1060
- Exact exports: `default`.
1061
-
1062
- ### Availability and normalization
1063
-
1064
- **Browser / native WebView hybrid.** Normalized preference record; storage failures mixed. Transport: Arcane.preferences or localStorage. [Deep protocol details](protocols.md).
1065
-
1066
- ### Example
1067
-
1068
- ```javascript
1069
- import * as module from '/arcane/modules/CommunicationPreferences.js';
1070
-
1071
- console.log(Object.keys(module));
1072
- ```
1073
-
1074
- ## CommunicationProviderRegistry.js
1075
-
1076
- ### Overview
1077
-
1078
- Registers and queries validated provider definitions, channels, and required methods.
1079
-
1080
- ### Public surface
1081
-
1082
- default registry with `register()`, `get()`, `has()`, `list()`.
1083
-
1084
- Exact exports: `default`.
1085
-
1086
- ### Availability and normalization
1087
-
1088
- **Cross-host.** Strict normalized registry. Transport: In-process only. [Deep protocol details](protocols.md).
1089
-
1090
- ### Example
1091
-
1092
- ```javascript
1093
- import * as module from '/arcane/modules/CommunicationProviderRegistry.js';
1094
-
1095
- console.log(Object.keys(module));
1096
- ```
1097
-
1098
- ## ComponentContracts.js
1099
-
1100
- ### Overview
1101
-
1102
- Owns normalized configuration/value contracts and shared explicit STT activation
1103
- behavior for chart, dashboard, Markdown, and voice components.
1104
-
1105
- ### Public surface
1106
-
1107
- Constant sets plus normalization, formatting, and explicit STT activation
1108
- helpers. `createSTTActivationController({host,button,onChange,EventClass=CustomEvent})`
1109
- consumes only normalized
1110
- [`AIRuntimeState`](#airuntimestatejs) `stt` role records. Its frozen controller
1111
- exposes `action`, `error`, `label`, `pending`, `selected`, `status`, `title`, and
1112
- `visible` getters plus `request(action)`, `synchronize(role)`, and `destroy()`.
1113
- `host` supplies `dispatchEvent(event)` and `requestSTTActivation(intent)`;
1114
- `button` supplies `addEventListener()` and `removeEventListener()`; and
1115
- `onChange()` is called whenever presentation should be rendered again. Browser
1116
- callers use the default `CustomEvent`; non-DOM callers must inject a compatible
1117
- `EventClass` constructor.
1118
-
1119
- `request('load'|'unload')` emits the cancelable
1120
- `speech-stt-activation-request` event with frozen `{intent,state}` before it
1121
- invokes `host.requestSTTActivation(intent)`. Callback failure emits
1122
- `speech-stt-activation-error` with frozen `{request,error,message}`. Syncing
1123
- sticky state only changes the controller's observation and presentation; it
1124
- never emits a lifecycle intent, chooses a provider, or starts a download.
1125
- `destroy()` removes its button listener and suppresses late callback effects.
1126
-
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`.
1136
-
1137
- ### Availability and normalization
1138
-
1139
- **Cross-host with an injected event constructor outside DOM hosts.** Fully
1140
- normalized labels, rows, definitions, visibility, formats, editor and voice
1141
- options, plus capability-neutral STT activation intent and presentation state.
1142
- Provider authority and lifecycle execution remain with the configured runtime
1143
- owner. Transport: In-process only. [Deep protocol details](protocols.md).
1144
-
1145
- ### Example
1146
-
1147
- ```javascript
1148
- import * as module from '/arcane/modules/ComponentContracts.js';
1149
-
1150
- console.log(Object.keys(module));
1151
- ```
1152
-
1153
- ## ConfiguredAIChatSession.js
1154
-
1155
- ### Overview
1156
-
1157
- Owns bounded in-memory AI turns, context construction, response-length instruction, and atomic history commit.
1158
-
1159
- ### Public surface
1160
-
1161
- default `ConfiguredAIChatSession`; `history()`, `clear()`, `prepare()`, `send()`.
1162
-
1163
- `new ConfiguredAIChatSession(options={})` admits exactly `chat`,
1164
- `contextBuilder`, `initialMessages`, `maxContextCharacters`,
1165
- `maxMessageCharacters`, `maxMessages`, `request`, `responseLength`, and
1166
- `systemPrompt`. `initialMessages` is an array of closed `user`, `assistant`, or
1167
- `tool` messages under the same message/context bounds. It excludes `system`,
1168
- allows exactly one structural assistant tool call, and requires a matching tool
1169
- result before another user turn or tool-call sequence; `systemPrompt` owns the
1170
- separate system message.
1171
-
1172
- `prepare(input,{signal})` performs the complete bounded request but does not
1173
- commit history immediately. It returns frozen `{response,commit,rollback}`;
1174
- exactly one terminal settlement is permitted. `send()` is the convenience path
1175
- that prepares and then commits the turn.
1176
-
1177
- An optional async `contextBuilder({input,history,signal})` receives a frozen
1178
- request snapshot and the same cancellation signal. Its returned context is
1179
- framed as untrusted data for only the current request and is never committed to
1180
- history.
1181
-
1182
- An injected `chat(request)` may return the prior normalized session result or
1183
- exactly one non-stream OpenAI-compatible choice. The prior form preserves its
1184
- explicit `done` boolean; OpenAI-compatible choice normalization sets
1185
- `done:true`. Both return frozen
1186
- `{provider,model,message:{role:'assistant',content,tool_calls?},done,
1187
- doneReason,promptEvalCount,evalCount}`. Tool calls remain structural data and
1188
- are never executed. When `tool_calls` is present it must contain exactly one
1189
- valid structural call. A malformed response fails `AI_CHAT_INVALID_RESPONSE`;
1190
- caller cancellation is `AbortError` with code `AI_CHAT_ABORTED`. A new user
1191
- turn cannot bypass a pending structural tool call
1192
- (`AI_CHAT_TOOL_RESULT_REQUIRED`), a mismatched tool result fails
1193
- `AI_CHAT_INVALID_TOOL_MESSAGE`, and a second terminal settlement of one
1194
- prepared transaction fails `AI_CHAT_TRANSACTION_SETTLED`.
1195
-
1196
- Exact exports: `default`.
1197
-
1198
- ### Availability and normalization
1199
-
1200
- **Native bridge by default; cross-host with injected chat.** Normalized session/result; provider rejection preserved. Transport: Arcane.ai.chat or injected provider. [Deep protocol details](protocols.md).
1201
-
1202
- ### Example
1203
-
1204
- ```javascript
1205
- import ConfiguredAIChatSession from '/arcane/modules/ConfiguredAIChatSession.js';
1206
-
1207
- const session = new ConfiguredAIChatSession({
1208
- chat: async request => ({
1209
- provider: 'demo',
1210
- model: 'echo',
1211
- message: {
1212
- role: 'assistant',
1213
- content: `Received ${request.messages.length} messages.`
1214
- }
1215
- })
1216
- });
1217
- console.log(await session.send('Hello'));
1218
- ```
1219
-
1220
- ## ConversationActionItems.js
1221
-
1222
- ### Overview
1223
-
1224
- Normalizes, creates, updates, remembers, selects, and formats bounded conversation action items.
1225
-
1226
- ### Public surface
1227
-
1228
- Action-item constants and lifecycle/formatting helpers.
1229
-
1230
- Exact exports: `CONVERSATION_ACTION_ITEM_BASES`, `CONVERSATION_ACTION_ITEM_PRESENTATION_COOLDOWN_MS`, `CONVERSATION_ACTION_ITEM_STATUSES`, `MAX_CONVERSATION_ACTION_ITEMS`, `MAX_CONVERSATION_ACTION_ITEM_CHARACTERS`, `MAX_CONVERSATION_REMEMBERED_ACTIONS`, `conversationActionItemsInstruction`, `createConversationActionItem`, `formatConversationActionItemCheckIn`, `markConversationActionItemsPresented`, `normalizeConversationActionItem`, `normalizeConversationActionItems`, `normalizeRememberedConversationActions`, `outstandingConversationActionItems`, `rememberConversationActionItems`, `removeConversationActionItem`, `selectConversationActionItemsForPresentation`, `updateConversationActionItem`.
1231
-
1232
- ### Availability and normalization
1233
-
1234
- **Cross-host.** Fully normalized status/base/presentation contract. Transport: In-process only. [Deep protocol details](protocols.md).
1235
-
1236
- ### Example
1237
-
1238
- ```javascript
1239
- import * as module from '/arcane/modules/ConversationActionItems.js';
1240
-
1241
- console.log(Object.keys(module));
1242
- ```
1243
-
1244
- ## ConversationClosingReport.js
1245
-
1246
- ### Overview
1247
-
1248
- Defines the closing-report tool, instruction, result normalizer, call classifier, and formatter.
1249
-
1250
- ### Public surface
1251
-
1252
- Six constants/helpers for closing reports.
1253
-
1254
- Exact exports: `CONVERSATION_CLOSING_REPORT_TOOL_NAME`, `classifyConversationClosingReportCalls`, `conversationClosingReportInstruction`, `createConversationClosingReportTool`, `formatConversationClosingReport`, `normalizeConversationClosingReport`.
1255
-
1256
- ### Availability and normalization
1257
-
1258
- **Cross-host.** Fully normalized report contract. Transport: In-process only. [Deep protocol details](protocols.md).
1259
-
1260
- ### Example
1261
-
1262
- ```javascript
1263
- import * as module from '/arcane/modules/ConversationClosingReport.js';
1264
-
1265
- console.log(Object.keys(module));
1266
- ```
1267
-
1268
- ## ConversationTimebox.js
1269
-
1270
- ### Overview
1271
-
1272
- Owns conversation limits, control messages, submission barriers, elapsed formatting, and delivery proof.
1273
-
1274
- ### Public surface
1275
-
1276
- default `ConversationTimebox`, `ConversationSubmissionBarrier`, constants and control helpers.
1277
-
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`.
1287
-
1288
- ### Availability and normalization
1289
-
1290
- **Cross-host.** Fully normalized state/command/delivery errors. Transport: Clock/timers and callbacks. [Deep protocol details](protocols.md).
1291
-
1292
- ### Example
1293
-
1294
- ```javascript
1295
- import * as module from '/arcane/modules/ConversationTimebox.js';
1296
-
1297
- console.log(Object.keys(module));
1298
- ```
1299
-
1300
- ## CoreLocalModelCatalog.js
1301
-
1302
- ### Overview
1303
-
1304
- Projects Core local-AI status into UI-safe admitted model and speech availability catalogs.
1305
-
1306
- ### Public surface
1307
-
1308
- Provider-mode constant and four catalog/availability helpers.
1309
-
1310
- Exact exports: `USER_MANAGED_LOOPBACK_PROVIDER_MODE`, `getCoreLocalModelCatalog`, `getCoreLocalModelCatalogWithAdmissionFailures`, `getCoreLocalSpeechAvailability`, `isUserManagedLoopbackLocalAIStatus`.
1311
-
1312
- ### Availability and normalization
1313
-
1314
- **Cross-host.** Fully normalized descriptors and stable admission labels. Transport: In-process projection of Core status. [Deep protocol details](protocols.md).
1315
-
1316
- ### Example
1317
-
1318
- ```javascript
1319
- import * as module from '/arcane/modules/CoreLocalModelCatalog.js';
1320
-
1321
- console.log(Object.keys(module));
1322
- ```
1323
-
1324
- ## DataMaintenance.js
1325
-
1326
- ### Overview
1327
-
1328
- Deletes empty chats and associated/empty memory records inside the current app data scope.
1329
-
1330
- ### Public surface
1331
-
1332
- `clearEmptyChatsAndMemories()` plus content predicates.
1333
-
1334
- Exact exports: `clearEmptyChatsAndMemories`, `hasMemoryContent`, `hasUserEntry`.
1335
-
1336
- ### Availability and normalization
1337
-
1338
- **Browser / native WebView.** Normalized counts; destructive storage failures preserved. Transport: Global DBOPFS. [Deep protocol details](protocols.md).
1339
-
1340
- ### Example
1341
-
1342
- ```javascript
1343
- import * as module from '/arcane/modules/DataMaintenance.js';
1344
-
1345
- console.log(Object.keys(module));
1346
- ```
1347
-
1348
- ## DBLS.js
1349
-
1350
- ### Overview
1351
-
1352
- Provides app-scoped localStorage tables, batch reads/writes, filtering, deletion, and counts.
1353
-
1354
- ### Public surface
1355
-
1356
- default `DBLS`; installs `window.dbls`, emits `dbls-ready`; CRUD/batch/key APIs.
1357
-
1358
- Exact exports: `DBLS_EVENT_TYPES`, `DBLS_REASONS`, `default`.
1359
-
1360
- ### Availability and normalization
1361
-
1362
- **Browser / native WebView.** Scoped keys and values normalized; storage failures mixed. Transport: localStorage + AppDataScope. [Deep protocol details](protocols.md).
1363
-
1364
- ### Example
1365
-
1366
- ```javascript
1367
- import * as module from '/arcane/modules/DBLS.js';
1368
-
1369
- console.log(Object.keys(module));
1370
- ```
1371
-
1372
- ## DBOPFS.js
1373
-
1374
- ### Overview
1375
-
1376
- Provides app-scoped OPFS tables, worker I/O, backup/restore, compression, and CRUD/batch APIs.
1377
-
1378
- ### Public surface
1379
-
1380
- default `DBOPFS`; installs `window.dbopfs`, emits `dbopfs-ready`; table/file/backup APIs.
1381
-
1382
- Exact exports: `DBOPFS_EVENT_TYPES`, `DBOPFS_REASONS`, `default`.
1383
-
1384
- ### Availability and normalization
1385
-
1386
- **Browser / native WebView.** App scope normalized; DOM/storage errors preserved. Transport: OPFS, DBOPFSWorker, Compression Streams. [Deep protocol details](protocols.md).
1387
-
1388
- ### Example
1389
-
1390
- ```javascript
1391
- import * as module from '/arcane/modules/DBOPFS.js';
1392
-
1393
- console.log(Object.keys(module));
1394
- ```
1395
-
1396
- ## DBOPFSDocumentLibrary.js
1397
-
1398
- ### Overview
1399
-
1400
- Stores one application-defined document corpus through an existing DBOPFS-style
1401
- adapter, searches only a completed generation, and builds bounded context that
1402
- is explicitly labeled untrusted. Construction performs no read, write, fetch,
1403
- or search; applications call `bootstrap()` deliberately.
1404
-
1405
- ### Public surface
1406
-
1407
- Exact exports: `DBOPFSDocumentLibrary`, `createDBOPFSDocumentLibrary`,
1408
- `default`, and `normalizeDBOPFSDocumentSchema`.
1409
-
1410
- `new DBOPFSDocumentLibrary({concurrency,db,maxCorpusCharacters,
1411
- maxDocumentCharacters,maxSearchCharacters,schema})` exposes `schema`,
1412
- `bootstrap({files,onProgress,read,readFailurePolicy,signal})`,
1413
- `search(query,{kinds,limit,signal,tags})`,
1414
- `evaluate(query,{sources,read,maxCharacters,maxCorpusCharacters,
1415
- maxScoringCharacters,maxDocumentCharacters?,kinds?,tags?,readFailurePolicy?,
1416
- onProgress?,signal?})`,
1417
- `buildContext(query,{limit,maxCharacters,maxDocumentCharacters,signal})`, and
1418
- `createContextBuilder({limit,maxCharacters,maxDocumentCharacters})`.
1419
-
1420
- `evaluate()` requires `sources`, `read`, `maxCharacters`,
1421
- `maxCorpusCharacters`, and `maxScoringCharacters`. It filters source metadata
1422
- before calling
1423
- `read(source,{maxCharacters,maxCorpusCharacters,ordinal,signal})`, never accepts a
1424
- source body as implicit authority, and never persists a caller-owned body.
1425
- `maxDocumentCharacters` defaults to the smaller instance/output bound.
1426
-
1427
- ### Availability and normalization
1428
-
1429
- **Browser or compatible host with an injected DBOPFS adapter.** The adapter
1430
- keeps the existing `get`, `set`, `getAllKeys`, and `delete` method names; Node
1431
- can use the same class only through an explicitly imported runtime module and a
1432
- compatible storage adapter; SDK `0.3.1` publishes no Node package subpath or
1433
- Node storage implementation for it. Bootstrap uses a bounded concurrent
1434
- generation, commits its manifest last, cleans partial data on failure, and
1435
- rejects case-colliding IDs. Search
1436
- returns `{failures,matches,total}` so one corrupt record does not become a false
1437
- complete result. `bootstrap()` defaults to rejecting read failure; the explicit
1438
- `readFailurePolicy:'preserve-readable'` mode returns partial-success
1439
- `readCoverage`. `evaluate()` also defaults to rejecting a source-read failure;
1440
- its explicit `preserve-readable` mode instead ranks the readable records and
1441
- returns partial `failures` plus `coverage` in the evaluation result (not
1442
- bootstrap's `readCoverage`). It reads a caller-owned source list without
1443
- persisting its bodies and returns frozen `{authority:'sources',characters,
1444
- coverage,documents,failures,limits,query,scoringTruncated,text,truncated}`.
1445
- Read failure remains `DBOPFS_DOCUMENT_READ_FAILED`; invalid public input uses
1446
- `DBOPFS_DOCUMENT_INVALID`, invalid integer budgets use
1447
- `DBOPFS_DOCUMENT_INVALID_LIMIT`, and a preserved read failure without a usable
1448
- source code is reported as `failures[].code:'DBOPFS_DOCUMENT_ERROR'`.
1449
- Cancellation is `AbortError` with code `DBOPFS_DOCUMENT_ABORTED`. Construction
1450
- does not search.
1451
- When an application explicitly supplies the library's context builder, each
1452
- prepared chat send performs that bounded retrieval.
1453
-
1454
- ### Example
1455
-
1456
- ```javascript
1457
- import {
1458
- createDBOPFSDocumentLibrary
1459
- } from '/arcane/modules/DBOPFSDocumentLibrary.js';
1460
-
1461
- const documents = createDBOPFSDocumentLibrary({
1462
- db: globalThis.dbopfs,
1463
- schema: {id: 'help', version: '1', table: 'help_documents'}
1464
- });
1465
- async function replaceHelpCorpusAfterUserChoice() {
1466
- await documents.bootstrap({files: [{
1467
- id: 'welcome',
1468
- path: 'welcome.md',
1469
- title: 'Welcome',
1470
- body: 'Arcane applications are portable.'
1471
- }]});
1472
- console.log(await documents.search('portable'));
1473
-
1474
- const preview = await documents.evaluate('portable', {
1475
- sources: [{id:'draft', path:'draft.md', title:'Draft'}],
1476
- read: async source => source.id === 'draft' ? 'Portable app notes.' : '',
1477
- maxCharacters: 2048,
1478
- maxCorpusCharacters: 4096,
1479
- maxDocumentCharacters: 512,
1480
- maxScoringCharacters: 512
1481
- });
1482
- console.log(preview.coverage, preview.text);
1483
- }
1484
- ```
1485
-
1486
- ## DBOPFSWorker.js
1487
-
1488
- ### Overview
1489
-
1490
- Serializes OPFS sync-handle read/write requests from a MessagePort.
1491
-
1492
- ### Public surface
1493
-
1494
- No ESM exports; accepts `read` and `write` port requests.
1495
-
1496
- This is a dedicated worker protocol and has no ESM exports.
1497
-
1498
- ### Availability and normalization
1499
-
1500
- **Dedicated worker.** Responses normalize to `{success,fileData?}` or `{error:{name,message}}`. Transport: MessageChannel + OPFS sync access handle. [Deep protocol details](protocols.md).
1501
-
1502
- ### Example
1503
-
1504
- ```javascript
1505
- const worker = new Worker('/arcane/modules/DBOPFSWorker.js', {type: 'module'});
1506
- ```
1507
-
1508
- ## DevelopmentWorkspace.js
1509
-
1510
- ### Overview
1511
-
1512
- Provides bounded workspace inspection, context, setup task, and Node installer clients without arbitrary command execution.
1513
-
1514
- ### Public surface
1515
-
1516
- default `DevelopmentWorkspace` and input validators; `inspect()`, `context()`, `setup()`, `installNode()`.
1517
-
1518
- Exact exports: `contextQuery`, `default`, `setupTaskId`, `workspaceRoot`.
1519
-
1520
- ### Availability and normalization
1521
-
1522
- **Native bridge.** Inputs normalized; provider result/error preserved. Transport: Arcane.development. [Deep protocol details](protocols.md).
1523
-
1524
- ### Example
1525
-
1526
- ```javascript
1527
- import * as module from '/arcane/modules/DevelopmentWorkspace.js';
1528
-
1529
- console.log(Object.keys(module));
1530
- ```
1531
-
1532
- ## DirectoryPicker.js
1533
-
1534
- ### Overview
1535
-
1536
- Wraps the provider-owned native directory chooser and normalizes selected/cancelled/error results.
1537
-
1538
- ### Public surface
1539
-
1540
- default `DirectoryPicker`, `normalizeDirectoryPickerOptions()`, `normalizeDirectorySelection()`.
1541
-
1542
- Exact exports: `default`, `normalizeDirectoryPickerOptions`, `normalizeDirectorySelection`.
1543
-
1544
- ### Availability and normalization
1545
-
1546
- **Native bridge.** Strict normalized selection and coded errors. Transport: Arcane.filesystem.selectDirectory. [Deep protocol details](protocols.md).
1547
-
1548
- ### Example
1549
-
1550
- ```javascript
1551
- import * as module from '/arcane/modules/DirectoryPicker.js';
1552
-
1553
- console.log(Object.keys(module));
1554
- ```
1555
-
1556
- ## DocumentLexicalSearch.js
1557
-
1558
- ### Overview
1559
-
1560
- Provides deterministic, dependency-free metadata/body ranking and bounded
1561
- context excerpts for caller-owned document records.
1562
-
1563
- ### Public surface
1564
-
1565
- Exact exports: `DOCUMENT_SEARCH_FIELD_ORDER`, `DocumentLexicalSearch`,
1566
- `createDocumentLexicalIndex`, `default`, `documentContextExcerpt`,
1567
- `documentSearchTokens`, `normalizedDocumentSearchText`, `scoreDocumentBody`,
1568
- and `scoreDocumentLexicalIndex`.
1569
-
1570
- `new DocumentLexicalSearch(records,{maxResults=20})` exposes
1571
- `rank(query,{kinds,tags})` and `search(query,{kinds,limit,tags})`.
1572
-
1573
- ### Availability and normalization
1574
-
1575
- **Cross-host.** Indexing and search are in-process only. Text, tags, kinds,
1576
- scores, field ordering, truncation, and tie-breaking are normalized into frozen
1577
- records. This module performs no storage, network, model, Core, or DOM action.
1578
- The caller decides whether a result is merely displayed or explicitly injected
1579
- as untrusted AI context.
1580
-
1581
- ### Example
1582
-
1583
- ```javascript
1584
- import DocumentLexicalSearch from '/arcane/modules/DocumentLexicalSearch.js';
1585
-
1586
- const search = new DocumentLexicalSearch([{
1587
- id: 'welcome',
1588
- path: 'welcome.md',
1589
- title: 'Welcome',
1590
- body: 'Arcane applications are portable.',
1591
- kind: 'guide',
1592
- tags: ['intro']
1593
- }]);
1594
- console.log(search.search('portable', {limit: 5}));
1595
- ```
1596
-
1597
- ## DocumentNavigation.js
1598
-
1599
- ### Overview
1600
-
1601
- Binds document navigation, filtering, history, current-item reveal, and load initialization.
1602
-
1603
- ### Public surface
1604
-
1605
- Five binding/filter/reveal helpers.
1606
-
1607
- Exact exports: `applyDocumentNavigationFilter`, `bindDocumentNavigation`, `clearDocumentNavigationFilter`, `initializeDocumentNavigation`, `revealCurrentDocumentNavigationItem`.
1608
-
1609
- ### Availability and normalization
1610
-
1611
- **Browser / native WebView.** Normalized filter/navigation state; DOM effects preserved. Transport: DOM and history. [Deep protocol details](protocols.md).
1612
-
1613
- ### Example
1614
-
1615
- ```javascript
1616
- import * as module from '/arcane/modules/DocumentNavigation.js';
1617
-
1618
- console.log(Object.keys(module));
1619
- ```
1620
-
1621
- ## Errors.js
1622
-
1623
- ### Overview
1624
-
1625
- Normalizes global errors/rejections, fingerprints and deduplicates incidents, persists a ledger, and performs bounded delivery.
1626
-
1627
- ### Public surface
1628
-
1629
- default `Errors`; event normalizers/fingerprint plus lifecycle, capture, delivery and teardown methods.
1630
-
1631
- Exact exports: `GLOBAL_ERROR_EVENT_CODES`, `GLOBAL_ERROR_EVENT_TYPES`,
1632
- `GLOBAL_ERROR_REASONS`, `default`, `fingerprintIncident`,
1633
- `normalizeErrorEvent`, and `normalizeRejectionEvent`.
1634
-
1635
- ### Availability and normalization
1636
-
1637
- **Browser / native WebView hybrid.** Incident records normalized; storage/mail failures isolated. Transport: Window events, DBOPFS, Mail. [Deep protocol details](protocols.md).
1638
-
1639
- ### Example
1640
-
1641
- ```javascript
1642
- import * as module from '/arcane/modules/Errors.js';
1643
-
1644
- console.log(Object.keys(module));
1645
- ```
1646
-
1647
- ## GifEncoder.js
1648
-
1649
- ### Overview
1650
-
1651
- Encodes indexed frames into a bounded animated GIF using palette mapping and LZW.
1652
-
1653
- ### Public surface
1654
-
1655
- default `GifEncoder`, `indexPixels()`, `lzw()`.
1656
-
1657
- Exact exports: `default`, `indexPixels`, `lzw`.
1658
-
1659
- ### Availability and normalization
1660
-
1661
- **Cross-host.** Normalized byte output and bounds. Transport: In-process only. [Deep protocol details](protocols.md).
1662
-
1663
- ### Example
1664
-
1665
- ```javascript
1666
- import * as module from '/arcane/modules/GifEncoder.js';
1667
-
1668
- console.log(Object.keys(module));
1669
- ```
1670
-
1671
- ## HTMLImport.js
1672
-
1673
- ### Overview
1674
-
1675
- Defines the same-origin `<html-import>` loader with open shadow root, inline script execution, and readiness/error events.
1676
-
1677
- ### Public surface
1678
-
1679
- default `HTMLImport`; registers `html-import`; `connectedCallback()` and `ready`.
1680
-
1681
- Exact exports: `default`.
1682
-
1683
- ### Availability and normalization
1684
-
1685
- **Browser / native WebView.** Public error detail normalized; fetch/DOM failure preserved. Transport: Same-origin fetch + DOM. [Deep protocol details](protocols.md).
1686
-
1687
- ### Example
1688
-
1689
- ```javascript
1690
- import * as module from '/arcane/modules/HTMLImport.js';
1691
-
1692
- console.log(Object.keys(module));
1693
- ```
1694
-
1695
- ## InMemoryCommunicationProvider.js
1696
-
1697
- ### Overview
1698
-
1699
- Implements deterministic in-memory thread/message/send behavior for demos and tests.
1700
-
1701
- ### Public surface
1702
-
1703
- default provider with `listThreads()`, `getMessages()`, `send()`.
1704
-
1705
- Exact exports: `default`.
1706
-
1707
- ### Availability and normalization
1708
-
1709
- **Cross-host.** Normalized communication entities. Transport: In-process only. [Deep protocol details](protocols.md).
1710
-
1711
- ### Example
1712
-
1713
- ```javascript
1714
- import * as module from '/arcane/modules/InMemoryCommunicationProvider.js';
1715
-
1716
- console.log(Object.keys(module));
1717
- ```
1718
-
1719
- ## IsolatedModelQuestionRunner.js
1720
-
1721
- ### Overview
1722
-
1723
- Inspects one exact model and runs one isolated question with proof validation.
1724
-
1725
- ### Public surface
1726
-
1727
- default/named runner, `countSentences()`, `inspectModel()`, `runQuestion()`.
1728
-
1729
- Exact exports: `IsolatedModelQuestionRunner`, `countSentences`, `default`.
1730
-
1731
- ### Availability and normalization
1732
-
1733
- **Native bridge or injected provider.** Strict normalized proof/coded errors. Transport: localAI isolated-model methods. [Deep protocol details](protocols.md).
1734
-
1735
- ### Example
1736
-
1737
- ```javascript
1738
- import * as module from '/arcane/modules/IsolatedModelQuestionRunner.js';
1739
-
1740
- console.log(Object.keys(module));
1741
- ```
1742
-
1743
- ## LocalAIReadiness.js
1744
-
1745
- ### Overview
1746
-
1747
- Derives selected AI requirements and returns a frozen readiness/recovery report across browser, desktop, and Android modes.
1748
-
1749
- ### Public surface
1750
-
1751
- Endpoint constant plus requirements, speech-health, and readiness helpers.
1752
-
1753
- Exact exports: `LOCAL_AI_BROWSER_ENDPOINTS`, `checkLocalAIReadiness`, `deriveLocalAIRequirements`, `evaluateLocalSpeechHealth`.
1754
-
1755
- ### Availability and normalization
1756
-
1757
- **Browser/native hybrid.** Fully normalized report and stable error codes; browsers never probe Ollama. Transport: Arcane.localAI, Arcane.speech, bounded browser speech health. [Deep protocol details](protocols.md).
1758
-
1759
- ### Example
1760
-
1761
- ```javascript
1762
- import * as module from '/arcane/modules/LocalAIReadiness.js';
1763
-
1764
- console.log(Object.keys(module));
1765
- ```
1766
-
1767
- ## LocalAIReadinessController.js
1768
-
1769
- ### Overview
1770
-
1771
- Coordinates local-AI status component checks, ensured recovery, availability projection, and teardown.
1772
-
1773
- ### Public surface
1774
-
1775
- `createLocalAIReadinessController()`, `availabilityFromReport()`.
1776
-
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`.
1781
-
1782
- ### Availability and normalization
1783
-
1784
- `availabilityFromReport()` returns `true` only for a slot whose local
1785
- requirement is explicitly `required:true` and whose report is explicitly
1786
- `ready:true`. Missing and non-local-required slots remain false: this projection
1787
- does not attest provider registration, selection, credentials, browser speech
1788
- authority, or model load state. Components must preserve selected sticky
1789
- `AIRuntimeState` roles as the readiness authority.
1790
-
1791
- **Browser/native hybrid.** Normalized controller state and change events.
1792
- Transport: LocalAIReadiness + component events. [Deep protocol details](protocols.md).
1793
-
1794
- ### Example
1795
-
1796
- ```javascript
1797
- import * as module from '/arcane/modules/LocalAIReadinessController.js';
1798
-
1799
- console.log(Object.keys(module));
1800
- ```
1801
-
1802
- ## Mail.js
1803
-
1804
- ### Overview
1805
-
1806
- Builds bounded reports and prefers the native mail capability with an explicit HTTP transport fallback.
1807
-
1808
- ### Public surface
1809
-
1810
- default `Mail`, `resolveMailConfig()`; installs `window.mail`; `send()`.
1811
-
1812
- Exact exports: `default`, `resolveMailConfig`.
1813
-
1814
- ### Availability and normalization
1815
-
1816
- **Browser/native hybrid + cloud.** Mail inputs/results normalized; transport failures mixed. Transport: Arcane.mail.send or MailTransport HTTP(S). [Deep protocol details](protocols.md).
1817
-
1818
- ### Example
1819
-
1820
- ```javascript
1821
- import * as module from '/arcane/modules/Mail.js';
1822
-
1823
- console.log(Object.keys(module));
1824
- ```
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
-
1935
- ## MailTransport.mjs
1936
-
1937
- ### Overview
1938
-
1939
- Sends one bounded mail report to a normalized HTTP(S) endpoint with timeout and response-size limits.
1940
-
1941
- ### Public surface
1942
-
1943
- Timeout/size constants, `MailTransportError`, `normalizeMailEndpoint()`,
1944
- `serializeMailReport()`, and `sendMailReport()`.
1945
-
1946
- Exact exports: `DEFAULT_MAIL_REQUEST_TIMEOUT_MS`, `MAX_MAIL_RESPONSE_BYTES`,
1947
- `MailTransportError`, `normalizeMailEndpoint`, `serializeMailReport`,
1948
- `sendMailReport`.
1949
-
1950
- ### Availability and normalization
1951
-
1952
- **Browser/server with fetch + cloud.** Normalized endpoint/timeout/size errors; remote detail bounded. Transport: HTTP(S) fetch + AbortController. [Deep protocol details](protocols.md).
1953
-
1954
- ### Example
1955
-
1956
- ```javascript
1957
- import * as module from '/arcane/modules/MailTransport.mjs';
1958
-
1959
- console.log(Object.keys(module));
1960
- ```
1961
-
1962
- ## Marked.min.js
1963
-
1964
- ### Overview
1965
-
1966
- Vendored Marked 18.0.5 Markdown lexer, parser, renderer, extension, and walk-token API.
1967
-
1968
- ### Public surface
1969
-
1970
- Twenty named/default-style Marked exports; see bundled license notice.
1971
-
1972
- Exact exports: `Hooks`, `Lexer`, `Marked`, `Parser`, `Renderer`, `TextRenderer`, `Tokenizer`, `defaults`, `getDefaults`, `lexer`, `marked`, `options`, `parse`, `parseInline`, `parser`, `setOptions`, `use`, `walkTokens`.
1973
-
1974
- ### Availability and normalization
1975
-
1976
- **Cross-host vendor module.** Vendor-native Marked contract. Transport: In-process only. [Deep protocol details](protocols.md).
1977
-
1978
- ### Example
1979
-
1980
- ```javascript
1981
- import * as module from '/arcane/modules/Marked.min.js';
1982
-
1983
- console.log(Object.keys(module));
1984
- ```
1985
-
1986
- ## MD.js
1987
-
1988
- ### Overview
1989
-
1990
- Renders Markdown with Marked and exposes a DOM-sanitized projection.
1991
-
1992
- ### Public surface
1993
-
1994
- default `MD`; `raw`, `rendered`, `safeRendered`, `append()`.
1995
-
1996
- Exact exports: `default`.
1997
-
1998
- ### Availability and normalization
1999
-
2000
- **Browser / native WebView.** Raw Marked behavior plus Arcane sanitization; parse errors vendor-native. Transport: Marked + DOM template sanitization. [Deep protocol details](protocols.md).
2001
-
2002
- ### Example
2003
-
2004
- ```javascript
2005
- import * as module from '/arcane/modules/MD.js';
2006
-
2007
- console.log(Object.keys(module));
2008
- ```
2009
-
2010
- ## MemoryRecords.js
2011
-
2012
- ### Overview
2013
-
2014
- Normalizes memory content and detects meaningful stored memory.
2015
-
2016
- ### Public surface
2017
-
2018
- `normalizeMemoryContent()`, `hasMemoryContent()`.
2019
-
2020
- Exact exports: `hasMemoryContent`, `normalizeMemoryContent`.
2021
-
2022
- ### Availability and normalization
2023
-
2024
- **Cross-host.** Fully normalized string/boolean results. Transport: In-process only. [Deep protocol details](protocols.md).
2025
-
2026
- ### Example
2027
-
2028
- ```javascript
2029
- import * as module from '/arcane/modules/MemoryRecords.js';
2030
-
2031
- console.log(Object.keys(module));
2032
- ```
2033
-
2034
- ## MessageAdvisory.js
2035
-
2036
- ### Overview
2037
-
2038
- Normalizes message content advisories and contains per-message inspection failures.
2039
-
2040
- ### Public surface
2041
-
2042
- Three advisory/inspection helpers.
2043
-
2044
- Exact exports: `inspectMessageRecords`, `normalizeContentAdvisory`, `unavailableMessageInspection`.
2045
-
2046
- ### Availability and normalization
2047
-
2048
- **Cross-host.** Normalized advisory records; inspector failures converted to unavailable results. Transport: Injected inspector. [Deep protocol details](protocols.md).
2049
-
2050
- ### Example
2051
-
2052
- ```javascript
2053
- import * as module from '/arcane/modules/MessageAdvisory.js';
2054
-
2055
- console.log(Object.keys(module));
2056
- ```
2057
-
2058
- ## ModelDefinition.js
2059
-
2060
- ### Overview
2061
-
2062
- Parses the deterministic packaged Modelfile subset and extracts the SYSTEM prompt.
2063
-
2064
- ### Public surface
2065
-
2066
- `parseModelDefinition()`, `loadModelDefinitionSystemPrompt()`.
2067
-
2068
- Exact exports: `loadModelDefinitionSystemPrompt`, `parseModelDefinition`.
2069
-
2070
- ### Availability and normalization
2071
-
2072
- **Cross-host.** Strict normalized definition with coded syntax errors. Transport: Optional same-origin read-only fetch. [Deep protocol details](protocols.md).
2073
-
2074
- ### Example
2075
-
2076
- ```javascript
2077
- import * as module from '/arcane/modules/ModelDefinition.js';
2078
-
2079
- console.log(Object.keys(module));
2080
- ```
2081
-
2082
- ## Ollama.js
2083
-
2084
- ### Overview
2085
-
2086
- Provides the first-class Arcane Ollama client without direct access to localhost:11434.
2087
-
2088
- ### Public surface
2089
-
2090
- `Ollama`, singleton/default `ollama`; 24 methods; installs `globalThis.arcaneOllama`, emits `arcane-ollama-ready`.
2091
-
2092
- Exact exports: `OLLAMA_EVENT_TYPES`, `OLLAMA_REASONS`, `Ollama`, `default`,
2093
- and `ollama`.
2094
-
2095
- ### Availability and normalization
2096
-
2097
- **Native bridge.** Principal methods preserve provider-native envelopes; readiness/text/unload helpers normalize. Transport: Arcane.ollama through Core. [Deep protocol details](protocols.md).
2098
-
2099
- ### Example
2100
-
2101
- ```javascript
2102
- import * as module from '/arcane/modules/Ollama.js';
2103
-
2104
- console.log(Object.keys(module));
2105
- ```
2106
-
2107
- ## OllamaModelIdentifier.js
2108
-
2109
- ### Overview
2110
-
2111
- Validates and canonicalizes the syntax of Ollama model identifiers without granting model admission.
2112
-
2113
- ### Public surface
2114
-
2115
- `normalizeOllamaModelIdentifier()`, `isOllamaModelIdentifier()`.
2116
-
2117
- Exact exports: `isOllamaModelIdentifier`, `normalizeOllamaModelIdentifier`.
2118
-
2119
- ### Availability and normalization
2120
-
2121
- **Cross-host.** Fully normalized string/boolean result. Transport: In-process only. [Deep protocol details](protocols.md).
2122
-
2123
- ### Example
2124
-
2125
- ```javascript
2126
- import * as module from '/arcane/modules/OllamaModelIdentifier.js';
2127
-
2128
- console.log(Object.keys(module));
2129
- ```
2130
-
2131
- ## OllamaSettings.js
2132
-
2133
- ### Overview
2134
-
2135
- Defines bounded runtime/service preference schemas and deterministic Arcane brain alias names.
2136
-
2137
- ### Public surface
2138
-
2139
- `ollamaRuntimeSchema`, `ollamaServiceSchema`, `arcaneBrainModelName()`.
2140
-
2141
- Exact exports: `arcaneBrainModelName`, `ollamaRuntimeSchema`, `ollamaServiceSchema`.
2142
-
2143
- ### Availability and normalization
2144
-
2145
- **Cross-host.** Fully normalized settings/name contract. Transport: In-process only. [Deep protocol details](protocols.md).
2146
-
2147
- ### Example
2148
-
2149
- ```javascript
2150
- import * as module from '/arcane/modules/OllamaSettings.js';
2151
-
2152
- console.log(Object.keys(module));
2153
- ```
2154
-
2155
- ## OpenMeteoWeatherProvider.js
2156
-
2157
- ### Overview
2158
-
2159
- Searches and loads Open-Meteo data into frozen Arcane weather entities.
2160
-
2161
- ### Public surface
2162
-
2163
- Endpoint constants, default provider, `mapForecast()`; search/load methods and lifecycle events.
2164
-
2165
- Exact exports: `OPEN_METEO_ENDPOINTS`, `OPEN_METEO_WEATHER_ERRORS`,
2166
- `OPEN_METEO_WEATHER_EVENTS`, `default`, and `mapForecast`.
2167
-
2168
- ### Availability and normalization
2169
-
2170
- **Browser / native WebView / server with fetch + cloud.** Provider data normalized to entities; transport errors mixed. Transport: Open-Meteo HTTPS. [Deep protocol details](protocols.md).
2171
-
2172
- ### Example
2173
-
2174
- ```javascript
2175
- import * as module from '/arcane/modules/OpenMeteoWeatherProvider.js';
2176
-
2177
- console.log(Object.keys(module));
2178
- ```
2179
-
2180
- ## PersistentAIChatSession.js
2181
-
2182
- ### Overview
2183
-
2184
- Composes `ConfiguredAIChatSession` with one `ChatEntity` so every user,
2185
- assistant, and structural tool-result turn has an explicit durable-persistence
2186
- choice. It preserves the existing DBOPFS method names and ChatEntity memory
2187
- semantics; it does not define a new storage protocol.
2188
-
2189
- ### Public surface
2190
-
2191
- Exact exports: `PersistentAIChatSession`, `createPersistentAIChatSession`, and
2192
- `default`.
2193
-
2194
- Constructor and factory options are `{chat,chatEntity,chatFileName,
2195
- contextBuilder,loadExisting,maxContextCharacters,maxMessageCharacters,
2196
- maxMessages,memory,request,responseLength,systemPrompt}`. Public members are
2197
- static `create()`, getters `chatEntity` and `fileName`, and `ready()`,
2198
- `history()`, `settleMemory()`, and `send(input)`.
2199
- `ready()` waits for initialization and resolves the same session instance.
2200
-
2201
- `send()` accepts `{message:{content,role:'user'|'tool',tool_call_id?,persist},
2202
- response:{persist},signal?}`. Message and response persistence must match.
2203
- `persist:false` still commits the coherent turn to live bounded model context,
2204
- but not to durable ChatEntity history or memory. A structural tool result must
2205
- use the persistence choice captured by its matching assistant tool call.
2206
-
2207
- ### Availability and normalization
2208
-
2209
- **Browser or native WebView with ChatEntity/DBOPFS and a configured chat
2210
- function.** The default chat calls normalized `Arcane.ai.chat()`; callers can
2211
- inject the browser-WASM controller, another provider-neutral adapter, or a
2212
- cloud chat function. There is no automatic provider or storage fallback.
2213
- Context builders are request-only, and document context remains explicitly
2214
- untrusted. Errors include `AI_CHAT_BUSY`, `AI_CHAT_TOOL_RESULT_REQUIRED`,
2215
- `AI_CHAT_INVALID_TOOL_MESSAGE`, and `AI_CHAT_INCOHERENT_PERSISTENCE`.
2216
-
2217
- ### Example
2218
-
2219
- ```javascript
2220
- import {
2221
- createPersistentAIChatSession
2222
- } from '/arcane/modules/PersistentAIChatSession.js';
2223
-
2224
- async function sendPersistentSupportTurnAfterUserChoice(documents) {
2225
- const session = await createPersistentAIChatSession({
2226
- chatFileName: 'support.jsonl',
2227
- loadExisting: true,
2228
- contextBuilder: documents.createContextBuilder()
2229
- });
2230
- const response = await session.send({
2231
- message: {role: 'user', content: 'Summarize the documents.', persist: true},
2232
- response: {persist: true}
2233
- });
2234
- console.log(response.message.content);
2235
- }
2236
- ```
2237
-
2238
- ## PreferenceStore.js
2239
-
2240
- ### Overview
2241
-
2242
- Loads and updates schema-defined app preferences through native storage with a narrow browser fallback.
2243
-
2244
- ### Public surface
2245
-
2246
- default `PreferenceStore`, re-exported `Preference`/schema; load/set/reset APIs and events.
2247
-
2248
- Exact exports: `PREFERENCE_STORE_ERROR_CODES`,
2249
- `PREFERENCE_STORE_EVENT_TYPES`, `Preference`, `default`, and
2250
- `preferenceSchema`.
2251
-
2252
- ### Availability and normalization
2253
-
2254
- **Browser/native hybrid.** Values normalized; only exact unsupported capability falls back. Transport: Arcane.preferences or app-scoped localStorage. [Deep protocol details](protocols.md).
2255
-
2256
- ### Example
2257
-
2258
- ```javascript
2259
- import * as module from '/arcane/modules/PreferenceStore.js';
2260
-
2261
- console.log(Object.keys(module));
2262
- ```
2263
-
2264
- ## QRCode.min.js
2265
-
2266
- ### Overview
2267
-
2268
- Vendored QRCode generator for DOM, canvas, SVG, and image output.
2269
-
2270
- ### Public surface
2271
-
2272
- No ESM exports; global `QRCode`, `makeCode()`, `makeImage()`, `clear()`, `CorrectLevel`.
2273
-
2274
- This is a classic global script and has no ESM exports.
2275
-
2276
- ### Availability and normalization
2277
-
2278
- **Browser vendor script.** Vendor-native. Transport: Classic script global + DOM/canvas/SVG. [Deep protocol details](protocols.md).
2279
-
2280
- ### Example
2281
-
2282
- ```html
2283
- <script src="/arcane/modules/QRCode.min.js"></script>
2284
- ```
2285
-
2286
- ## Questionnaire.js
2287
-
2288
- ### Overview
2289
-
2290
- Evaluates whether a one-time questionnaire prompt is due without performing the prompt.
2291
-
2292
- ### Public surface
2293
-
2294
- Notification default and `Questionnaire` with timing/check methods.
2295
-
2296
- Exact exports: `DEFAULT_QUESTIONNAIRE_NOTIFICATION_TIME_MS`, `Questionnaire`.
2297
-
2298
- ### Availability and normalization
2299
-
2300
- **Cross-host.** Normalized fail-closed boolean. Transport: In-process clock only. [Deep protocol details](protocols.md).
2301
-
2302
- ### Example
2303
-
2304
- ```javascript
2305
- import * as module from '/arcane/modules/Questionnaire.js';
2306
-
2307
- console.log(Object.keys(module));
2308
- ```
2309
-
2310
- ## RecordLinkIndex.js
2311
-
2312
- ### Overview
2313
-
2314
- Parses record links and builds their normalized index.
2315
-
2316
- ### Public surface
2317
-
2318
- `parseRecordLinks()`, `buildRecordLinkIndex()`.
2319
-
2320
- Exact exports: `buildRecordLinkIndex`, `parseRecordLinks`.
2321
-
2322
- ### Availability and normalization
2323
-
2324
- **Cross-host.** Fully normalized. Transport: In-process only. [Deep protocol details](protocols.md).
2325
-
2326
- ### Example
2327
-
2328
- ```javascript
2329
- import * as module from '/arcane/modules/RecordLinkIndex.js';
2330
-
2331
- console.log(Object.keys(module));
2332
- ```
2333
-
2334
- ## RecordPassageIndex.js
2335
-
2336
- ### Overview
2337
-
2338
- Indexes text lines, page markers, dates, rules, and excerpts for record review.
2339
-
2340
- ### Public surface
2341
-
2342
- Eight text/page/date/rule helper exports.
2343
-
2344
- Exact exports: `cleanExcerpt`, `extractDateMentions`, `findRulePassages`, `pageAtLine`, `pageMarkers`, `parseDateMention`, `textLines`, `validIsoDate`.
2345
-
2346
- ### Availability and normalization
2347
-
2348
- **Cross-host.** Fully normalized. Transport: In-process only. [Deep protocol details](protocols.md).
2349
-
2350
- ### Example
2351
-
2352
- ```javascript
2353
- import * as module from '/arcane/modules/RecordPassageIndex.js';
2354
-
2355
- console.log(Object.keys(module));
2356
- ```
2357
-
2358
- ## RecordReviewStore.js
2359
-
2360
- ### Overview
2361
-
2362
- Stores normalized record-review decisions through native storage or app-scoped local fallback.
2363
-
2364
- ### Public surface
2365
-
2366
- default store, record/review normalizers; `load()`, `get()`, `set()`, `snapshot()`, change event.
2367
-
2368
- Exact exports: `RECORD_REVIEW_STORE_ERROR_CODES`,
2369
- `RECORD_REVIEW_STORE_EVENT_TYPES`, `default`, `normalizeRecordId`, and
2370
- `normalizeReview`.
2371
-
2372
- ### Availability and normalization
2373
-
2374
- **Browser/native hybrid.** Normalized ids/reviews/snapshots; storage failures mixed. Transport: Arcane.storage or localStorage. [Deep protocol details](protocols.md).
2375
-
2376
- ### Example
2377
-
2378
- ```javascript
2379
- import * as module from '/arcane/modules/RecordReviewStore.js';
2380
-
2381
- console.log(Object.keys(module));
2382
- ```
2383
-
2384
- ## RevocableProjectionLedger.js
2385
-
2386
- ### Overview
2387
-
2388
- Implements an append-only bounded in-memory projection/revocation ledger safe for hostile descriptor inputs.
2389
-
2390
- ### Public surface
2391
-
2392
- Ledger classes, limits/status/reason constants, clone/fingerprint/port helpers, append/query/list APIs.
2393
-
2394
- Exact exports: `DEFAULT_PROJECTION_LEDGER_CAPACITY`, `DEFAULT_PROJECTION_LEDGER_STORED_CHARACTERS`, `DEFAULT_PROJECTION_LEDGER_STORED_NODES`, `DEFAULT_PROJECTION_LEDGER_STORED_UTF8_BYTES`, `MAX_PROJECTION_LEDGER_CAPACITY`, `MAX_PROJECTION_LEDGER_STORED_CHARACTERS`, `MAX_PROJECTION_LEDGER_STORED_NODES`, `MAX_PROJECTION_LEDGER_STORED_UTF8_BYTES`, `PROJECTION_LEDGER_LIMITS`, `PROJECTION_LEDGER_REASON_CODES`, `PROJECTION_LEDGER_SCHEMA_VERSION`, `PROJECTION_LEDGER_STATUSES`, `ProjectionLedgerError`, `RevocableProjectionLedger`, `cloneProjectionLedgerValue`, `createProjectionLedgerFingerprint`, `createRevocableProjectionLedgerPortAdapter`, `default`.
2395
-
2396
- ### Availability and normalization
2397
-
2398
- **Cross-host.** Strict normalization with stable `ProjectionLedgerError`. Transport: In-process or explicit port adapter. [Deep protocol details](protocols.md).
2399
-
2400
- ### Example
2401
-
2402
- ```javascript
2403
- import * as module from '/arcane/modules/RevocableProjectionLedger.js';
2404
-
2405
- console.log(Object.keys(module));
2406
- ```
2407
-
2408
- ## RiskSignalAnalyzer.js
2409
-
2410
- ### Overview
2411
-
2412
- Matches configured risk signals and levels against bounded text.
2413
-
2414
- ### Public surface
2415
-
2416
- `DEFAULT_LEVELS`, `analyzeRiskSignals()`.
2417
-
2418
- Exact exports: `DEFAULT_LEVELS`, `analyzeRiskSignals`.
2419
-
2420
- ### Availability and normalization
2421
-
2422
- **Cross-host.** Fully normalized. Transport: In-process only. [Deep protocol details](protocols.md).
2423
-
2424
- ### Example
2425
-
2426
- ```javascript
2427
- import * as module from '/arcane/modules/RiskSignalAnalyzer.js';
2428
-
2429
- console.log(Object.keys(module));
2430
- ```
2431
-
2432
- ## ScamRiskPolicy.js
2433
-
2434
- ### Overview
2435
-
2436
- Combines deterministic scam signals with Arcane blocked-domain evidence and safety guidance.
2437
-
2438
- ### Public surface
2439
-
2440
- Signals plus load, assess, and guidance helpers.
2441
-
2442
- Exact exports: `assessScamRisk`, `loadScamNetworkPolicy`, `scamRiskSignals`, `scamSafetyGuidance`.
2443
-
2444
- ### Availability and normalization
2445
-
2446
- **Cross-host.** Fully normalized. Transport: Arcane network policy fetch. [Deep protocol details](protocols.md).
2447
-
2448
- ### Example
2449
-
2450
- ```javascript
2451
- import * as module from '/arcane/modules/ScamRiskPolicy.js';
2452
-
2453
- console.log(Object.keys(module));
2454
- ```
2455
-
2456
- ## ScopedOPFSCache.js
2457
-
2458
- ### Overview
2459
-
2460
- Provides a narrow exact-key JSON cache inside one app-owned OPFS namespace.
2461
-
2462
- ### Public surface
2463
-
2464
- default `ScopedOPFSCache`; support check and get/set/delete APIs.
2465
-
2466
- Exact exports: `default`.
2467
-
2468
- ### Availability and normalization
2469
-
2470
- **Browser / native WebView.** Keys/limits/corruption handling normalized; storage errors mixed. Transport: OPFS + AppDataScope. [Deep protocol details](protocols.md).
2471
-
2472
- ### Example
2473
-
2474
- ```javascript
2475
- import * as module from '/arcane/modules/ScopedOPFSCache.js';
2476
-
2477
- console.log(Object.keys(module));
2478
- ```
2479
-
2480
- ## ScreenCapture.js
2481
-
2482
- ### Overview
2483
-
2484
- Captures a display surface as image, video, or GIF with explicit lifecycle events.
2485
-
2486
- ### Public surface
2487
-
2488
- default `ScreenCapture`; acquire/capture/start/stop/reset methods.
2489
-
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`.
2493
-
2494
- ### Availability and normalization
2495
-
2496
- **Browser / native WebView.** State/events normalized; permission and codec errors mixed. Transport: getDisplayMedia, MediaRecorder, canvas, GifEncoder. [Deep protocol details](protocols.md).
2497
-
2498
- ### Example
2499
-
2500
- ```javascript
2501
- import * as module from '/arcane/modules/ScreenCapture.js';
2502
-
2503
- console.log(Object.keys(module));
2504
- ```
2505
-
2506
- ## SpeechPlayback.js
2507
-
2508
- ### Overview
2509
-
2510
- Segments bounded text, queues latest-request speech synthesis, and controls lookahead HTML audio playback.
2511
-
2512
- ### Public surface
2513
-
2514
- `SpeechPlayback` class/default, voice/limit compatibility constants,
2515
- `SPEECH_PLAYBACK_STATE_EVENT`, `splitSpeechText()`, and playback lifecycle APIs.
2516
-
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`.
2521
-
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).
2583
-
2584
- ### Example
2585
-
2586
- ```javascript
2587
- import SpeechPlayback from '/arcane/modules/SpeechPlayback.js';
2588
-
2589
- const audio = document.body.appendChild(document.createElement('audio'));
2590
- audio.controls = true;
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
- });
2598
- const speakButton = document.body.appendChild(document.createElement('button'));
2599
- speakButton.type = 'button';
2600
- speakButton.textContent = 'Speak';
2601
- speakButton.addEventListener('click', async () => {
2602
- await speech.prepare({
2603
- key: 'ready',
2604
- parts: ['Arcane is ready.'],
2605
- autoplay: true
2606
- });
2607
- });
2608
- ```
2609
-
2610
- ## StaticDocumentCatalog.js
2611
-
2612
- ### Overview
2613
-
2614
- Loads a positive static document inventory with byte/hash verification, cache, search, and bounded context.
2615
-
2616
- ### Public surface
2617
-
2618
- default catalog, schema constant, catalog normalizer/cache-key; list/get/search/hydrate/context APIs.
2619
-
2620
- Exact exports: `CATALOG_SCHEMA_VERSION`, `default`, `normalizeStaticDocumentCatalog`, `staticDocumentCacheKey`.
2621
-
2622
- ### Availability and normalization
2623
-
2624
- **Browser / native WebView / server with fetch.** Strict catalog/content normalization; transport failures mixed. Transport: HTTP(S), crypto.subtle, optional cache. [Deep protocol details](protocols.md).
2625
-
2626
- ### Example
2627
-
2628
- ```javascript
2629
- import * as module from '/arcane/modules/StaticDocumentCatalog.js';
2630
-
2631
- console.log(Object.keys(module));
2632
- ```
2633
-
2634
- ## SystemAppearance.js
2635
-
2636
- ### Overview
2637
-
2638
- Reads or applies native appearance, returning an explicit unsupported browser state when no bridge exists.
2639
-
2640
- ### Public surface
2641
-
2642
- default `SystemAppearance`; `available()`, `current()`, `apply()`.
2643
-
2644
- Exact exports: `default`.
2645
-
2646
- ### Availability and normalization
2647
-
2648
- **Browser/native hybrid.** Absent bridge normalized; native result/error preserved. Transport: Arcane.appearance. [Deep protocol details](protocols.md).
2649
-
2650
- ### Example
2651
-
2652
- ```javascript
2653
- import * as module from '/arcane/modules/SystemAppearance.js';
2654
-
2655
- console.log(Object.keys(module));
2656
- ```
2657
-
2658
- ## SystemPlatformPresentation.js
2659
-
2660
- ### Overview
2661
-
2662
- Maps kernel names to presentation labels/classes without granting platform authority.
2663
-
2664
- ### Public surface
2665
-
2666
- No ESM exports; global `ArcaneSystemPlatformPresentation` with `kernelType()`, `displayName()`, `apply()`.
2667
-
2668
- This is a classic global script and has no ESM exports.
2669
-
2670
- ### Availability and normalization
2671
-
2672
- **Browser / native WebView classic script.** Fully normalized presentation only. Transport: DOM. [Deep protocol details](protocols.md).
2673
-
2674
- ### Example
2675
-
2676
- ```html
2677
- <script src="/arcane/modules/SystemPlatformPresentation.js"></script>
2678
- ```
2679
-
2680
- ## SystemToolRegistry.js
2681
-
2682
- ### Overview
2683
-
2684
- Registers validated command builders and constructs command strings without executing them.
2685
-
2686
- ### Public surface
2687
-
2688
- default registry, `quoteArgument()`, register/list/get/build APIs.
2689
-
2690
- Exact exports: `default`, `quoteArgument`.
2691
-
2692
- ### Availability and normalization
2693
-
2694
- **Cross-host.** Fully normalized definitions/quoting. Transport: In-process only. [Deep protocol details](protocols.md).
2695
-
2696
- ### Example
2697
-
2698
- ```javascript
2699
- import * as module from '/arcane/modules/SystemToolRegistry.js';
2700
-
2701
- console.log(Object.keys(module));
2702
- ```
2703
-
2704
- ## TerminalClient.js
2705
-
2706
- ### Overview
2707
-
2708
- Maps native terminal sessions and Arcane events into an EventTarget client.
2709
-
2710
- ### Public surface
2711
-
2712
- default `TerminalClient`; start/write/resize/signal/close/receive/destroy APIs and terminal events.
2713
-
2714
- Exact exports: `TERMINAL_CLIENT_ERROR_CODES`, `TERMINAL_CLIENT_EVENT_TYPES`,
2715
- `TERMINAL_CLIENT_REASONS`, and `default`.
2716
-
2717
- ### Availability and normalization
2718
-
2719
- **Native bridge.** Client events/state normalized; native result/error mixed. Transport: Arcane.terminal + Arcane.events. [Deep protocol details](protocols.md).
2720
-
2721
- ### Example
2722
-
2723
- ```javascript
2724
- import * as module from '/arcane/modules/TerminalClient.js';
2725
-
2726
- console.log(Object.keys(module));
2727
- ```
2728
-
2729
- ## TerminalCommandRegistry.js
2730
-
2731
- ### Overview
2732
-
2733
- Routes parsed command lines to injected handlers and provides definitions/completions.
2734
-
2735
- ### Public surface
2736
-
2737
- default registry, `splitCommandLine()`, register/resolve/definitions/completions/execute APIs.
2738
-
2739
- Exact exports: `default`, `splitCommandLine`.
2740
-
2741
- ### Availability and normalization
2742
-
2743
- **Cross-host.** Parsing/routing normalized; handler result/error preserved. Transport: Injected handlers. [Deep protocol details](protocols.md).
2744
-
2745
- ### Example
2746
-
2747
- ```javascript
2748
- import * as module from '/arcane/modules/TerminalCommandRegistry.js';
2749
-
2750
- console.log(Object.keys(module));
2751
- ```
2752
-
2753
- ## ThemeBootstrap.js
2754
-
2755
- ### Overview
2756
-
2757
- Performs import-time Arcane theme loading and subscribes to native appearance changes.
2758
-
2759
- ### Public surface
2760
-
2761
- `bootstrapArcaneTheme()`, `arcaneThemeReady`, default ready promise.
2762
-
2763
- Exact exports: `arcaneThemeReady`, `bootstrapArcaneTheme`, `default`, and
2764
- `disposeArcaneThemeBootstrap`.
2765
-
2766
- ### Availability and normalization
2767
-
2768
- **Browser/native hybrid.** Theme state normalized; storage/native errors mixed. Transport: ThemeManager + Arcane.events. [Deep protocol details](protocols.md).
2769
-
2770
- ### Example
2771
-
2772
- ```javascript
2773
- import * as module from '/arcane/modules/ThemeBootstrap.js';
2774
-
2775
- console.log(Object.keys(module));
2776
- ```
2777
-
2778
- ## ThemeManager.js
2779
-
2780
- ### Overview
2781
-
2782
- Loads, applies, previews, saves, resets, and synchronizes semantic Arcane themes.
2783
-
2784
- ### Public surface
2785
-
2786
- default `ThemeManager`, `loadAndApplyTheme()`; scheme/custom/system APIs and `arcane-theme-change`.
2787
-
2788
- Exact exports: `default`, `loadAndApplyTheme`.
2789
-
2790
- ### Availability and normalization
2791
-
2792
- **Browser/native hybrid.** Theme values/events normalized; storage/native failures mixed. Transport: PreferenceStore, DOM, Arcane.appearance. [Deep protocol details](protocols.md).
2793
-
2794
- ### Example
2795
-
2796
- ```javascript
2797
- import * as module from '/arcane/modules/ThemeManager.js';
2798
-
2799
- console.log(Object.keys(module));
2800
- ```
2801
-
2802
- ## TimeGuard.js
2803
-
2804
- ### Overview
2805
-
2806
- Persists and evaluates clock rollback and grace-period state.
2807
-
2808
- ### Public surface
2809
-
2810
- default `TimeGuard`; installs `window.timeguard`, emits `time-guard-ready`; clock methods.
2811
-
2812
- Exact exports: `default`.
2813
-
2814
- ### Availability and normalization
2815
-
2816
- **Browser / native WebView.** Time decisions normalized; storage lifecycle mixed. Transport: User + DBOPFS. [Deep protocol details](protocols.md).
2817
-
2818
- ### Example
2819
-
2820
- ```javascript
2821
- import * as module from '/arcane/modules/TimeGuard.js';
2822
-
2823
- console.log(Object.keys(module));
2824
- ```
2825
-
2826
- ## ToolCallRouter.js
2827
-
2828
- ### Overview
2829
-
2830
- Parses OpenAI-style tool calls and dispatches complete or streamed calls to injected handlers.
2831
-
2832
- ### Public surface
2833
-
2834
- `parseArguments()`, `handleResponse()`, `handleStreamedCalls()`.
2835
-
2836
- Exact exports: `handleResponse`, `handleStreamedCalls`, `parseArguments`.
2837
-
2838
- ### Availability and normalization
2839
-
2840
- **Cross-host.** Arguments/routing normalized; handler results returned or all-settled. Transport: Injected handlers. [Deep protocol details](protocols.md).
2841
-
2842
- ### Example
2843
-
2844
- ```javascript
2845
- import * as module from '/arcane/modules/ToolCallRouter.js';
2846
-
2847
- console.log(Object.keys(module));
2848
- ```
2849
-
2850
- ## uPlot.iife.min.js
2851
-
2852
- ### Overview
2853
-
2854
- Vendored uPlot chart constructor and rendering runtime.
2855
-
2856
- ### Public surface
2857
-
2858
- No ESM exports; global `uPlot` with data/series/scale/cursor/hook/selection/destroy APIs.
2859
-
2860
- This is a classic global script and has no ESM exports.
2861
-
2862
- ### Availability and normalization
2863
-
2864
- **Browser vendor script.** Vendor-native. Transport: Classic script + canvas/DOM. [Deep protocol details](protocols.md).
2865
-
2866
- ### Example
2867
-
2868
- ```html
2869
- <script src="/arcane/modules/uPlot.iife.min.js"></script>
2870
- ```
2871
-
2872
- ## uPlot.LICENSE.txt
2873
-
2874
- ### Overview
2875
-
2876
- License companion for the bundled uPlot vendor runtime.
2877
-
2878
- ### Public surface
2879
-
2880
- MIT license text.
2881
-
2882
- ### Availability and normalization
2883
-
2884
- **Documentation asset.** Not executable. Transport: None. [Deep protocol details](protocols.md).
2885
-
2886
- ### Example
2887
-
2888
- ```text
2889
- /arcane/modules/uPlot.LICENSE.txt
2890
- ```
2891
-
2892
- ## uPlot.min.css
2893
-
2894
- ### Overview
2895
-
2896
- Bundled uPlot presentation stylesheet.
2897
-
2898
- ### Public surface
2899
-
2900
- Load with a stylesheet link before rendering uPlot charts.
2901
-
2902
- ### Availability and normalization
2903
-
2904
- **Browser stylesheet.** Presentation only. Transport: CSS. [Deep protocol details](protocols.md).
2905
-
2906
- ### Example
2907
-
2908
- ```html
2909
- <link rel="stylesheet" href="/arcane/modules/uPlot.min.css">
2910
- ```
2911
-
2912
- ## WaitForComponent.js
2913
-
2914
- ### Overview
2915
-
2916
- Waits for a component property, method, or readiness event with optional error event and bounded timeout.
2917
-
2918
- ### Public surface
2919
-
2920
- default `waitForComponent()`.
2921
-
2922
- Exact exports: `COMPONENT_WAIT_ERROR_CODES`, `COMPONENT_WAIT_REASONS`, and
2923
- `default`.
2924
-
2925
- ### Availability and normalization
2926
-
2927
- **Cross-host EventTarget / browser component.** Normalized coded readiness, error, and timeout results. Transport: EventTarget + timers. [Deep protocol details](protocols.md).
2928
-
2929
- ### Example
2930
-
2931
- ```javascript
2932
- import * as module from '/arcane/modules/WaitForComponent.js';
2933
-
2934
- console.log(Object.keys(module));
2935
- ```
2936
-
2937
- ## YouTubeMedia.js
2938
-
2939
- ### Overview
2940
-
2941
- Validates YouTube video/playlist locators and constructs privacy-enhanced embed URLs.
2942
-
2943
- ### Public surface
2944
-
2945
- `parseYouTubeMedia()`, `youtubeEmbedUrl()`.
2946
-
2947
- Exact exports: `parseYouTubeMedia`, `youtubeEmbedUrl`.
2948
-
2949
- ### Availability and normalization
2950
-
2951
- **Cross-host.** Fully normalized. Transport: URL construction only. [Deep protocol details](protocols.md).
2952
-
2953
- ### Example
2954
-
2955
- ```javascript
2956
- import * as module from '/arcane/modules/YouTubeMedia.js';
2957
-
2958
- console.log(Object.keys(module));
2959
- ```
2960
-
2961
- ## Entity and component continuations
2962
-
2963
- - [Runtime entity modules](runtime-entities.md) explains all 15 modules, and [shared entity contracts](core/arcane-entities.md) owns all 35 exports.
2964
- - [Runtime components](runtime-components.md) owns all 39 HTML-import fragments, methods, slots, and events.
2965
- - [Arcane Ollama](arcane-ollama.md) expands the raw-versus-normalized behavior of `Ollama.js`.