arcane-os 0.3.0 → 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 +27 -0
  2. package/README.md +86 -117
  3. package/bin/arcane-test.mjs +170 -46
  4. package/browser-runtime/ai/browser-speech-artifacts.mjs +887 -909
  5. package/browser-runtime/ai/browser-speech-providers.mjs +96 -152
  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 -146
  11. package/browser-runtime/ai/speech-worker-runtime.mjs +643 -363
  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 +1050 -427
  37. package/runtime/arcane/modules/AIProviderRuntime.js +658 -363
  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 +40 -62
  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 +112 -779
  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 -187
  120. package/docs/reference/ai/browser-speech-package-authority.json +0 -835
  121. package/docs/reference/ai/browser-speech.md +0 -1252
  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 -677
  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 -2960
  150. package/docs/reference/sdk-api.md +0 -6694
  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,2960 +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
-
499
- `start(options)` waits for prior speech-state and role unload work, applies the
500
- requested initial mute state, and returns the `startAIRuntime()` control handle
501
- `{barrier,settled,cancel}`. Startup does not request selected STT unless the
502
- caller explicitly opts in; it does not force an independently active STT role
503
- back to unloaded. The barrier and settled promises describe provider-startup
504
- readiness; cancellation remains cooperative through the supplied signal and
505
- returned control.
506
-
507
- Interactive requests are latest-request-wins per role. A newer valid request
508
- that reaches admission aborts the active request, waits for its provider promise
509
- to settle (or for bounded stream cleanup to be confirmed), and revalidates
510
- ready/loaded/not-busy state before it starts. Rapid intermediate requests are
511
- superseded, and their late results cannot restore or overwrite newer role state.
512
- Promise settlement proves only that the provider's exposed request promise
513
- completed; it does not by itself prove that underlying provider work stopped.
514
- Provider-specific positive cancellation acknowledgement remains
515
- provider-specific. Load and reconfiguration guards stay fail-closed while
516
- request ownership is active.
517
-
518
- ### Availability and normalization
519
-
520
- **Cross-host runtime with provider-specific execution.** The SDK source ships
521
- the browser-WASM LLM and browser Whisper/Kokoro adapters and supplies the
522
- narrow AI.js legacy OpenAI/Ollama/Core-speech adapters; other native, Core, or
523
- cloud adapters may be supplied externally only when they implement the same
524
- `arcane-ai-provider/2` boundary. A
525
- provider must prove a matching `arcane-ai-model-authority/1` inspection before load.
526
- `localOnly` routing fails closed; it never selects a cloud or non-local route as
527
- a fallback. A missing or mismatched explicit local-only route rejects load or
528
- request admission with `AI_LOCAL_MODEL_REQUIRED`. Role lifecycle and stream
529
- cleanup are normalized, while the
530
- selected provider retains its own capability, permission, download, and model
531
- requirements. [Deep protocol details](protocols.md#portable-ai-provider-runtime).
532
-
533
- ### Example
534
-
535
- ```javascript
536
- import {getAIProviderRuntime} from '/arcane/modules/AIProviderRuntime.js';
537
-
538
- const runtime = getAIProviderRuntime();
539
- console.log(runtime.protocol, runtime.status());
540
- ```
541
-
542
- ## AIResponseLength.js
543
-
544
- ### Overview
545
-
546
- Normalizes concise/short/medium/long response preferences and applies the matching system instruction.
547
-
548
- ### Public surface
549
-
550
- Response-length constants plus `normalizeAIResponseLength()`, `aiResponseLengthInstruction()`, and `applyAIResponseLength()`.
551
-
552
- Exact exports: `AI_RESPONSE_LENGTH_DEFAULT`, `AI_RESPONSE_LENGTH_OPTIONS`, `aiResponseLengthInstruction`, `applyAIResponseLength`, `normalizeAIResponseLength`.
553
-
554
- ### Availability and normalization
555
-
556
- **Cross-host.** Fully normalized string/instruction contract. Transport: In-process only. [Deep protocol details](protocols.md).
557
-
558
- ### Example
559
-
560
- ```javascript
561
- import * as module from '/arcane/modules/AIResponseLength.js';
562
-
563
- console.log(Object.keys(module));
564
- ```
565
-
566
- ## AIResponseURLPolicy.js
567
-
568
- ### Overview
569
-
570
- Extracts and audits links from AI Markdown, rendered HTML, CSS, srcset, bare URLs, and email text.
571
-
572
- ### Public surface
573
-
574
- `auditAIResponseLinks()`, `extractAIResponseLinks()`, `normalizeAIResponseLink()`, `decodeHTMLCharacterReferences()`.
575
-
576
- Exact exports: `auditAIResponseLinks`, `decodeHTMLCharacterReferences`, `extractAIResponseLinks`, `normalizeAIResponseLink`.
577
-
578
- ### Availability and normalization
579
-
580
- **Cross-host.** Normalized frozen allowlist audit. Transport: In-process; bundled Marked parser. [Deep protocol details](protocols.md).
581
-
582
- ### Example
583
-
584
- ```javascript
585
- import * as module from '/arcane/modules/AIResponseURLPolicy.js';
586
-
587
- console.log(Object.keys(module));
588
- ```
589
-
590
- ## AIRuntimeState.js
591
-
592
- ### Overview
593
-
594
- Publishes one sticky immutable state tree for `llm`, `stt`, and `tts`, transient
595
- load/unload/dispose intents, and a startup-settlement report. It makes lifecycle
596
- observable without exposing provider transports in application code.
597
-
598
- ### Public surface
599
-
600
- Exact exports: `AI_RUNTIME_INTENT_EVENT`, `AI_RUNTIME_PROTOCOL`,
601
- `AI_RUNTIME_ROLES`, `AI_RUNTIME_STARTUP_EVENT`, `AI_RUNTIME_STATES`,
602
- `AI_RUNTIME_STATE_EVENT`, `aiRuntimeEvents`, `getAIRuntimeState`,
603
- `publishAIRuntimeRoleState`, `publishAIRuntimeRolesState`,
604
- `requestAIRuntimeIntent`, `startAIRuntime`, `subscribeAIRuntimeIntents`, and
605
- `subscribeAIRuntimeState`.
606
-
607
- Each role record is exactly `{role,state,providerId,modelId,localOnly,loaded,
608
- busy,operationId,progress,error}`.
609
- `subscribeAIRuntimeState(listener,{signal=null,emitCurrent=true})` installs its
610
- subscription and synchronously replays the current frozen snapshot by default;
611
- `subscribeAIRuntimeIntents(listener,{signal=null})` is future-only. Both return
612
- one idempotent unsubscribe/dispose closure. `aiRuntimeEvents` is a deprecated,
613
- state-free EventTarget compatibility view over the same canonical source; it is
614
- not a second authority and owns no listener registry.
615
- `startAIRuntime({startMuted=true,startTranscription=false,signal})` returns
616
- `{barrier,settled,cancel}`: `barrier` settles for text chat, while `settled`
617
- covers every requested role. Muted startup does not request TTS, and STT startup
618
- is opt-in so selection and state observation do not begin a transcription-model
619
- load.
620
-
621
- ### Availability and normalization
622
-
623
- **Cross-host state contract.** States are `unavailable`, `unloaded`, `loading`,
624
- `ready`, `unloading`, `error`, and `disposed`. Revisions increase monotonically.
625
- The events `arcane-ai-runtime-state`, `arcane-ai-runtime-intent`, and
626
- `arcane-ai-runtime-startup-settled` normalize observation only: receiving one
627
- does not grant a native capability, prove browser support, or load a provider.
628
- `arcane-ai-runtime-startup-settled` reports the LLM/text-chat `barrier`.
629
- Await the returned `handle.settled` promise for every role requested by that
630
- startup; the all-role settlement has no separate public event.
631
- Intent records are exactly `{role,action,reason}` where roles are `llm`, `stt`,
632
- or `tts`; actions are `load`, `unload`, or `dispose`; and reasons are `startup`,
633
- `user`, or `teardown`. Invalid closed records fail with the stable prefix
634
- `ARCANE_AI_RUNTIME_STATE_INVALID`; startup cancellation is an `AbortError` with
635
- code `ARCANE_AI_REQUEST_ABORTED`.
636
-
637
- ### Example
638
-
639
- ```javascript
640
- import {
641
- getAIRuntimeState,
642
- subscribeAIRuntimeState
643
- } from '/arcane/modules/AIRuntimeState.js';
644
-
645
- const unsubscribe = subscribeAIRuntimeState(snapshot => {
646
- console.log(snapshot.roles.llm.state);
647
- });
648
- console.log(getAIRuntimeState().protocol);
649
- unsubscribe();
650
- ```
651
-
652
- ## AnsiText.js
653
-
654
- ### Overview
655
-
656
- Parses terminal ANSI sequences into display spans or strips them to plain text.
657
-
658
- ### Public surface
659
-
660
- `parseAnsi()`, `stripAnsi()`.
661
-
662
- Exact exports: `parseAnsi`, `stripAnsi`.
663
-
664
- ### Availability and normalization
665
-
666
- **Cross-host.** Normalized text/span output. Transport: In-process only. [Deep protocol details](protocols.md).
667
-
668
- ### Example
669
-
670
- ```javascript
671
- import * as module from '/arcane/modules/AnsiText.js';
672
-
673
- console.log(Object.keys(module));
674
- ```
675
-
676
- ## ApiModelDatabase.js
677
-
678
- ### Overview
679
-
680
- Fetches an injectable HTTP JSON model with parser, cache, redacted public endpoint records, and request lifecycle events.
681
-
682
- ### Public surface
683
-
684
- default `ApiModelDatabase`; `setEndpoint()`, `fetch()`, `cached()`; emits `api-model-request`, `api-model-success`, and `api-model-error`.
685
-
686
- Exact exports: `API_MODEL_ERRORS`, `API_MODEL_EVENTS`, `appendParameters`,
687
- `default`, `publicEndpoint`.
688
-
689
- ### Availability and normalization
690
-
691
- **Browser / native WebView / server with fetch.** Request records are normalized; fetch/provider failures remain mixed. Transport: HTTP(S) fetch. [Deep protocol details](protocols.md).
692
-
693
- ### Example
694
-
695
- ```javascript
696
- import * as module from '/arcane/modules/ApiModelDatabase.js';
697
-
698
- console.log(Object.keys(module));
699
- ```
700
-
701
- ## AppDataScope.js
702
-
703
- ### Overview
704
-
705
- Reconciles declared and native application identity and scopes OPFS/localStorage ownership fail-closed.
706
-
707
- ### Public surface
708
-
709
- Identity constants and `canonicalApplicationId()`, `resolveApplicationId()`, `resolveApplicationLocalStorageKey()`, `openApplicationDataDirectory()`.
710
-
711
- Exact exports: `APPLICATION_ID_MAX_LENGTH`, `APPLICATION_ID_PATTERN`, `APP_DATA_DIRECTORY`, `APP_LOCAL_STORAGE_PREFIX`, `canonicalApplicationId`, `declaredApplicationId`, `openApplicationDataDirectory`, `resolveApplicationId`, `resolveApplicationLocalStorageKey`, `resolveBrowserApplicationId`.
712
-
713
- ### Availability and normalization
714
-
715
- **Browser / native WebView hybrid.** Strict normalized identifiers and coded mismatch failures. Transport: Arcane.app.current, DOM declaration, OPFS. [Deep protocol details](protocols.md).
716
-
717
- ### Example
718
-
719
- ```javascript
720
- import * as module from '/arcane/modules/AppDataScope.js';
721
-
722
- console.log(Object.keys(module));
723
- ```
724
-
725
- ## AppearancePreferences.js
726
-
727
- ### Overview
728
-
729
- Defines, stores, and applies color scheme, density, reduced motion, and large-text preferences.
730
-
731
- ### Public surface
732
-
733
- `appearancePreferenceSchema`, `createAppearancePreferenceStore()`, `applyAppearancePreferences()`, `loadAndApplyAppearancePreferences()`.
734
-
735
- Exact exports: `appearancePreferenceSchema`, `applyAppearancePreferences`, `createAppearancePreferenceStore`, `loadAndApplyAppearancePreferences`.
736
-
737
- ### Availability and normalization
738
-
739
- **Browser / native WebView hybrid.** Normalized values; storage/host failures remain mixed. Transport: PreferenceStore, DOM, optional Arcane preferences. [Deep protocol details](protocols.md).
740
-
741
- ### Example
742
-
743
- ```javascript
744
- import * as module from '/arcane/modules/AppearancePreferences.js';
745
-
746
- console.log(Object.keys(module));
747
- ```
748
-
749
- ## ArcaneCommunicationBridge.js
750
-
751
- ### Overview
752
-
753
- Maps provider HTTP threads/messages/connect/disconnect endpoints to normalized communication entities.
754
-
755
- ### Public surface
756
-
757
- default `ArcaneCommunicationBridge`; `request()`, `listThreads()`, `getMessages()`, `send()`, `connect()`, `disconnect()`.
758
-
759
- Exact exports: `default`.
760
-
761
- ### Availability and normalization
762
-
763
- **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).
764
-
765
- ### Example
766
-
767
- ```javascript
768
- import * as module from '/arcane/modules/ArcaneCommunicationBridge.js';
769
-
770
- console.log(Object.keys(module));
771
- ```
772
-
773
- ## ArcaneNavigationPolicy.js
774
-
775
- ### Overview
776
-
777
- Creates a fail-closed HTTP(S) navigation guard with domain and CIDR policy decisions.
778
-
779
- ### Public surface
780
-
781
- `createArcaneNavigationGuard()`.
782
-
783
- Exact exports: `createArcaneNavigationGuard`.
784
-
785
- ### Availability and normalization
786
-
787
- **Cross-host.** Normalized frozen allow/block decision. Transport: Arcane network-policy document. [Deep protocol details](protocols.md).
788
-
789
- ### Example
790
-
791
- ```javascript
792
- import * as module from '/arcane/modules/ArcaneNavigationPolicy.js';
793
-
794
- console.log(Object.keys(module));
795
- ```
796
-
797
- ## ArcaneNetworkPolicy.js
798
-
799
- ### Overview
800
-
801
- Validates the Arcane domain/network deny policy and matches domain, IPv4/IPv6 CIDR, protocol, and port rules.
802
-
803
- ### Public surface
804
-
805
- Policy constants plus validate/load/cache/match helpers.
806
-
807
- Exact exports: `ARCANE_NETWORK_POLICY_SCHEMA_VERSION`, `ARCANE_NETWORK_POLICY_URL`, `canonicalNetworkHostname`, `emptyArcaneNetworkPolicy`, `findDeniedDomainRule`, `findDeniedNetworkRule`, `invalidateArcaneNetworkPolicyCache`, `loadArcaneNetworkPolicy`, `validateArcaneNetworkPolicy`.
808
-
809
- ### Availability and normalization
810
-
811
- **Cross-host.** Strict coded normalization. Transport: Same-origin policy fetch. [Deep protocol details](protocols.md).
812
-
813
- ### Example
814
-
815
- ```javascript
816
- import * as module from '/arcane/modules/ArcaneNetworkPolicy.js';
817
-
818
- console.log(Object.keys(module));
819
- ```
820
-
821
- ## AsyncBoundary.js
822
-
823
- ### Overview
824
-
825
- Runs one asynchronous operation with timeout, abort, result validation, and stable boundary errors.
826
-
827
- ### Public surface
828
-
829
- `AsyncBoundaryTimeoutError`, `AsyncBoundaryAbortError`, defaults, `runAsyncBoundary()`, and default alias.
830
-
831
- Exact exports: `AsyncBoundaryAbortError`, `AsyncBoundaryTimeoutError`, `asyncBoundaryDefaults`, `default`, `runAsyncBoundary`.
832
-
833
- ### Availability and normalization
834
-
835
- **Cross-host.** Fully normalized timeout/abort errors. Transport: AbortController and timers. [Deep protocol details](protocols.md).
836
-
837
- ### Example
838
-
839
- ```javascript
840
- import * as module from '/arcane/modules/AsyncBoundary.js';
841
-
842
- console.log(Object.keys(module));
843
- ```
844
-
845
- ## BrowserTestSuite.js
846
-
847
- ### Overview
848
-
849
- Runs a fixed sequential browser test list with cooperative abort, per-test timeout, and lifecycle events.
850
-
851
- ### Public surface
852
-
853
- default `BrowserTestSuite`; `list()`, `run()`; emits suite/test start/result/complete events.
854
-
855
- Exact exports: `BROWSER_TEST_SUITE_ERROR_CODES`,
856
- `BROWSER_TEST_SUITE_EVENT_TYPES`, `BROWSER_TEST_SUITE_REASONS`,
857
- `assertionError`, `default`, `skipError`.
858
-
859
- ### Availability and normalization
860
-
861
- **Browser / standard Web APIs.** Normalized result and skip/assertion errors. Transport: EventTarget and timers. [Deep protocol details](protocols.md).
862
-
863
- ### Example
864
-
865
- ```javascript
866
- import * as module from '/arcane/modules/BrowserTestSuite.js';
867
-
868
- console.log(Object.keys(module));
869
- ```
870
-
871
- ## CalculatorEngine.js
872
-
873
- ### Overview
874
-
875
- Evaluates bounded arithmetic, powers, constants, and common functions without `eval`.
876
-
877
- ### Public surface
878
-
879
- `new CalculatorEngine()` exposes synchronous
880
- `calculate(expression): Calculation`,
881
- `addEventListener(type,listener,options): void`,
882
- `removeEventListener(type,listener,options): void`,
883
- `on(type,listener,options): unsubscribe`,
884
- `dispatchEvent(event): boolean`, and idempotent
885
- `dispose(): boolean` / `destroy(): boolean`. `evaluateExpression(input): number`
886
- remains the parser-only helper. `CALCULATOR_ENGINE_ERROR_CODES` is one frozen
887
- record containing the stable `disposed`, `input`, `syntax`, `domain`, and
888
- `evaluation` codes.
889
-
890
- Exact exports: `CALCULATOR_ENGINE_ERROR_CODES`, `default`,
891
- `evaluateExpression`.
892
-
893
- ### Availability and normalization
894
-
895
- **Cross-host.** Each engine owns one `calculator-engine` source on the realm's
896
- branded `globalThis.arcaneEvents`. `calculator-result` publishes frozen public
897
- detail `{result}`; the legacy instance listener receives the same `Calculation`
898
- object returned by `calculate()`. `calculator-error` publishes frozen public
899
- detail `{code}`; the legacy listener receives frozen
900
- `{expression,error}` while `calculate()` rethrows that same `Error`. Both
901
- occurrences carry one source-instance `operationId`. Listener callbacks are
902
- synchronous observations; their failures are reported by the central event
903
- authority and do not rewrite calculation settlement. Listener registration
904
- supports `{once,signal}` and its returned unsubscribe also exposes `.dispose()`.
905
- Disposal removes instance listeners and rejects later calculations with
906
- `ARCANE_CALCULATOR_ENGINE_DISPOSED`. Invalid expression input, syntax, numeric
907
- domain, and unexpected evaluation boundaries use
908
- `ARCANE_CALCULATOR_EXPRESSION_INPUT_INVALID`,
909
- `ARCANE_CALCULATOR_EXPRESSION_SYNTAX_INVALID`,
910
- `ARCANE_CALCULATOR_EXPRESSION_DOMAIN_INVALID`, and
911
- `ARCANE_CALCULATOR_EXPRESSION_EVALUATION_FAILED`. Transport: in-process only.
912
- [Deep protocol details](protocols.md).
913
-
914
- ### Example
915
-
916
- ```javascript
917
- import * as module from '/arcane/modules/CalculatorEngine.js';
918
-
919
- console.log(Object.keys(module));
920
- ```
921
-
922
- ## CaseEvidenceIndexer.js
923
-
924
- ### Overview
925
-
926
- Pairs and indexes structured evidence records with rendered-page provenance and SHA-256 identity.
927
-
928
- ### Public surface
929
-
930
- Eight exported indexing, page, naming, stem, and digest helpers.
931
-
932
- Exact exports: `indexPairedRecord`, `nearestPageMarker`, `parseStructuredRecordName`, `renderedPageBlocks`, `resolveEvidenceSourcePage`, `safeName`, `sha256`, `stem`.
933
-
934
- ### Availability and normalization
935
-
936
- **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).
937
-
938
- ### Example
939
-
940
- ```javascript
941
- // From a repository-owned tools/*.mjs file:
942
- import {safeName, stem} from '../runtime/arcane/modules/CaseEvidenceIndexer.js';
943
-
944
- console.log(safeName('Evidence 01.pdf'), stem('Evidence 01.pdf'));
945
- ```
946
-
947
- ## ChartLibrary.js
948
-
949
- ### Overview
950
-
951
- Loads the bundled uPlot classic script once and returns its global constructor.
952
-
953
- ### Public surface
954
-
955
- default `loadChartLibrary()`.
956
-
957
- Exact exports: `default`.
958
-
959
- ### Availability and normalization
960
-
961
- **Browser / native WebView.** Load state/errors normalized; uPlot result is vendor-native. Transport: DOM script injection. [Deep protocol details](protocols.md).
962
-
963
- ### Example
964
-
965
- ```javascript
966
- import * as module from '/arcane/modules/ChartLibrary.js';
967
-
968
- console.log(Object.keys(module));
969
- ```
970
-
971
- ## ChatRecords.js
972
-
973
- ### Overview
974
-
975
- Detects whether a chat record contains a meaningful user entry.
976
-
977
- ### Public surface
978
-
979
- `hasUserEntry()`.
980
-
981
- Exact exports: `hasUserEntry`.
982
-
983
- ### Availability and normalization
984
-
985
- **Cross-host.** Boolean normalized result. Transport: In-process only. [Deep protocol details](protocols.md).
986
-
987
- ### Example
988
-
989
- ```javascript
990
- import * as module from '/arcane/modules/ChatRecords.js';
991
-
992
- console.log(Object.keys(module));
993
- ```
994
-
995
- ## CommunicationAppController.js
996
-
997
- ### Overview
998
-
999
- Binds shared inbox, conversation, settings, theme, and provider workflows into one UI controller.
1000
-
1001
- ### Public surface
1002
-
1003
- default controller with `start()`, `bind()`, `configure()`, `refresh()`, `select()`, `send()`, and settings actions.
1004
-
1005
- Exact exports: `COMMUNICATION_APP_CONTROLLER_ERROR_CODES`, `default`.
1006
-
1007
- ### Availability and normalization
1008
-
1009
- **Browser / native WebView hybrid.** Controller state normalized; provider/DOM failures mixed. Transport: DOM plus communication providers. [Deep protocol details](protocols.md).
1010
-
1011
- ### Example
1012
-
1013
- ```javascript
1014
- import * as module from '/arcane/modules/CommunicationAppController.js';
1015
-
1016
- console.log(Object.keys(module));
1017
- ```
1018
-
1019
- ## CommunicationHub.js
1020
-
1021
- ### Overview
1022
-
1023
- Fans out provider refresh/send operations and aggregates normalized threads/messages.
1024
-
1025
- ### Public surface
1026
-
1027
- default `CommunicationHub`; provider enablement, `refresh()`, `messages()`, and `send()`.
1028
-
1029
- Exact exports: `COMMUNICATION_HUB_ERROR_CODES`, `COMMUNICATION_HUB_EVENTS`,
1030
- `COMMUNICATION_HUB_REFRESH_REASONS`, `COMMUNICATION_HUB_REFRESH_STATES`, and
1031
- `default`.
1032
-
1033
- ### Availability and normalization
1034
-
1035
- **Cross-host with injected providers.** Normalized aggregates; refresh contains per-provider failures. Transport: Injected provider contract. [Deep protocol details](protocols.md).
1036
-
1037
- ### Example
1038
-
1039
- ```javascript
1040
- import * as module from '/arcane/modules/CommunicationHub.js';
1041
-
1042
- console.log(Object.keys(module));
1043
- ```
1044
-
1045
- ## CommunicationPreferences.js
1046
-
1047
- ### Overview
1048
-
1049
- Stores app-scoped, non-secret communication provider preferences.
1050
-
1051
- ### Public surface
1052
-
1053
- default `CommunicationPreferences`; `load()`, `save()`.
1054
-
1055
- Exact exports: `default`.
1056
-
1057
- ### Availability and normalization
1058
-
1059
- **Browser / native WebView hybrid.** Normalized preference record; storage failures mixed. Transport: Arcane.preferences or localStorage. [Deep protocol details](protocols.md).
1060
-
1061
- ### Example
1062
-
1063
- ```javascript
1064
- import * as module from '/arcane/modules/CommunicationPreferences.js';
1065
-
1066
- console.log(Object.keys(module));
1067
- ```
1068
-
1069
- ## CommunicationProviderRegistry.js
1070
-
1071
- ### Overview
1072
-
1073
- Registers and queries validated provider definitions, channels, and required methods.
1074
-
1075
- ### Public surface
1076
-
1077
- default registry with `register()`, `get()`, `has()`, `list()`.
1078
-
1079
- Exact exports: `default`.
1080
-
1081
- ### Availability and normalization
1082
-
1083
- **Cross-host.** Strict normalized registry. Transport: In-process only. [Deep protocol details](protocols.md).
1084
-
1085
- ### Example
1086
-
1087
- ```javascript
1088
- import * as module from '/arcane/modules/CommunicationProviderRegistry.js';
1089
-
1090
- console.log(Object.keys(module));
1091
- ```
1092
-
1093
- ## ComponentContracts.js
1094
-
1095
- ### Overview
1096
-
1097
- Owns normalized configuration/value contracts and shared explicit STT activation
1098
- behavior for chart, dashboard, Markdown, and voice components.
1099
-
1100
- ### Public surface
1101
-
1102
- Constant sets plus normalization, formatting, and explicit STT activation
1103
- helpers. `createSTTActivationController({host,button,onChange,EventClass=CustomEvent})`
1104
- consumes only normalized
1105
- [`AIRuntimeState`](#airuntimestatejs) `stt` role records. Its frozen controller
1106
- exposes `action`, `error`, `label`, `pending`, `selected`, `status`, `title`, and
1107
- `visible` getters plus `request(action)`, `synchronize(role)`, and `destroy()`.
1108
- `host` supplies `dispatchEvent(event)` and `requestSTTActivation(intent)`;
1109
- `button` supplies `addEventListener()` and `removeEventListener()`; and
1110
- `onChange()` is called whenever presentation should be rendered again. Browser
1111
- callers use the default `CustomEvent`; non-DOM callers must inject a compatible
1112
- `EventClass` constructor.
1113
-
1114
- `request('load'|'unload')` emits the cancelable
1115
- `speech-stt-activation-request` event with frozen `{intent,state}` before it
1116
- invokes `host.requestSTTActivation(intent)`. Callback failure emits
1117
- `speech-stt-activation-error` with frozen `{request,error,message}`. Syncing
1118
- sticky state only changes the controller's observation and presentation; it
1119
- never emits a lifecycle intent, chooses a provider, or starts a download.
1120
- `destroy()` removes its button listener and suppresses late callback effects.
1121
-
1122
- Exact exports: `CHART_LABELS`, `DASHBOARD_LABELS`, `MARKDOWN_FORMATS`,
1123
- `MARKDOWN_LABELS`, `STT_ACTIVATION_ERROR_CODES`,
1124
- `STT_ACTIVATION_EVENT_TYPES`, `STT_ACTIVATION_REASONS`, `VOICE_LABELS`,
1125
- `VOICE_MESSAGES`, `appendTranscription`, `applyMarkdownFormat`,
1126
- `createSTTActivationController`, `effectiveDashboardVisibility`,
1127
- `normalizeChartOptions`, `normalizeChartRows`, `normalizeDashboardDefinitions`,
1128
- `normalizeDashboardOptions`, `normalizeDashboardVisibility`,
1129
- `normalizeMarkdownFormats`, `normalizeMarkdownOptions`, and
1130
- `normalizeVoiceOptions`.
1131
-
1132
- ### Availability and normalization
1133
-
1134
- **Cross-host with an injected event constructor outside DOM hosts.** Fully
1135
- normalized labels, rows, definitions, visibility, formats, editor and voice
1136
- options, plus capability-neutral STT activation intent and presentation state.
1137
- Provider authority and lifecycle execution remain with the configured runtime
1138
- owner. Transport: In-process only. [Deep protocol details](protocols.md).
1139
-
1140
- ### Example
1141
-
1142
- ```javascript
1143
- import * as module from '/arcane/modules/ComponentContracts.js';
1144
-
1145
- console.log(Object.keys(module));
1146
- ```
1147
-
1148
- ## ConfiguredAIChatSession.js
1149
-
1150
- ### Overview
1151
-
1152
- Owns bounded in-memory AI turns, context construction, response-length instruction, and atomic history commit.
1153
-
1154
- ### Public surface
1155
-
1156
- default `ConfiguredAIChatSession`; `history()`, `clear()`, `prepare()`, `send()`.
1157
-
1158
- `new ConfiguredAIChatSession(options={})` admits exactly `chat`,
1159
- `contextBuilder`, `initialMessages`, `maxContextCharacters`,
1160
- `maxMessageCharacters`, `maxMessages`, `request`, `responseLength`, and
1161
- `systemPrompt`. `initialMessages` is an array of closed `user`, `assistant`, or
1162
- `tool` messages under the same message/context bounds. It excludes `system`,
1163
- allows exactly one structural assistant tool call, and requires a matching tool
1164
- result before another user turn or tool-call sequence; `systemPrompt` owns the
1165
- separate system message.
1166
-
1167
- `prepare(input,{signal})` performs the complete bounded request but does not
1168
- commit history immediately. It returns frozen `{response,commit,rollback}`;
1169
- exactly one terminal settlement is permitted. `send()` is the convenience path
1170
- that prepares and then commits the turn.
1171
-
1172
- An optional async `contextBuilder({input,history,signal})` receives a frozen
1173
- request snapshot and the same cancellation signal. Its returned context is
1174
- framed as untrusted data for only the current request and is never committed to
1175
- history.
1176
-
1177
- An injected `chat(request)` may return the prior normalized session result or
1178
- exactly one non-stream OpenAI-compatible choice. The prior form preserves its
1179
- explicit `done` boolean; OpenAI-compatible choice normalization sets
1180
- `done:true`. Both return frozen
1181
- `{provider,model,message:{role:'assistant',content,tool_calls?},done,
1182
- doneReason,promptEvalCount,evalCount}`. Tool calls remain structural data and
1183
- are never executed. When `tool_calls` is present it must contain exactly one
1184
- valid structural call. A malformed response fails `AI_CHAT_INVALID_RESPONSE`;
1185
- caller cancellation is `AbortError` with code `AI_CHAT_ABORTED`. A new user
1186
- turn cannot bypass a pending structural tool call
1187
- (`AI_CHAT_TOOL_RESULT_REQUIRED`), a mismatched tool result fails
1188
- `AI_CHAT_INVALID_TOOL_MESSAGE`, and a second terminal settlement of one
1189
- prepared transaction fails `AI_CHAT_TRANSACTION_SETTLED`.
1190
-
1191
- Exact exports: `default`.
1192
-
1193
- ### Availability and normalization
1194
-
1195
- **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).
1196
-
1197
- ### Example
1198
-
1199
- ```javascript
1200
- import ConfiguredAIChatSession from '/arcane/modules/ConfiguredAIChatSession.js';
1201
-
1202
- const session = new ConfiguredAIChatSession({
1203
- chat: async request => ({
1204
- provider: 'demo',
1205
- model: 'echo',
1206
- message: {
1207
- role: 'assistant',
1208
- content: `Received ${request.messages.length} messages.`
1209
- }
1210
- })
1211
- });
1212
- console.log(await session.send('Hello'));
1213
- ```
1214
-
1215
- ## ConversationActionItems.js
1216
-
1217
- ### Overview
1218
-
1219
- Normalizes, creates, updates, remembers, selects, and formats bounded conversation action items.
1220
-
1221
- ### Public surface
1222
-
1223
- Action-item constants and lifecycle/formatting helpers.
1224
-
1225
- 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`.
1226
-
1227
- ### Availability and normalization
1228
-
1229
- **Cross-host.** Fully normalized status/base/presentation contract. Transport: In-process only. [Deep protocol details](protocols.md).
1230
-
1231
- ### Example
1232
-
1233
- ```javascript
1234
- import * as module from '/arcane/modules/ConversationActionItems.js';
1235
-
1236
- console.log(Object.keys(module));
1237
- ```
1238
-
1239
- ## ConversationClosingReport.js
1240
-
1241
- ### Overview
1242
-
1243
- Defines the closing-report tool, instruction, result normalizer, call classifier, and formatter.
1244
-
1245
- ### Public surface
1246
-
1247
- Six constants/helpers for closing reports.
1248
-
1249
- Exact exports: `CONVERSATION_CLOSING_REPORT_TOOL_NAME`, `classifyConversationClosingReportCalls`, `conversationClosingReportInstruction`, `createConversationClosingReportTool`, `formatConversationClosingReport`, `normalizeConversationClosingReport`.
1250
-
1251
- ### Availability and normalization
1252
-
1253
- **Cross-host.** Fully normalized report contract. Transport: In-process only. [Deep protocol details](protocols.md).
1254
-
1255
- ### Example
1256
-
1257
- ```javascript
1258
- import * as module from '/arcane/modules/ConversationClosingReport.js';
1259
-
1260
- console.log(Object.keys(module));
1261
- ```
1262
-
1263
- ## ConversationTimebox.js
1264
-
1265
- ### Overview
1266
-
1267
- Owns conversation limits, control messages, submission barriers, elapsed formatting, and delivery proof.
1268
-
1269
- ### Public surface
1270
-
1271
- default `ConversationTimebox`, `ConversationSubmissionBarrier`, constants and control helpers.
1272
-
1273
- Exact exports: `CONVERSATION_TIMEBOX_ERROR_CODES`,
1274
- `CONVERSATION_TIMEBOX_EVENT_TYPES`, `CONVERSATION_TIMEBOX_LIMIT_MESSAGE`,
1275
- `CONVERSATION_TIMEBOX_OPENING_INSTRUCTION`, `CONVERSATION_TIMEBOX_REASONS`,
1276
- `CONVERSATION_TIMEBOX_TOOL_NAME`, `ConversationSubmissionBarrier`,
1277
- `appendConversationTimeboxOpeningInstruction`, `consumeConversationTimeboxCall`,
1278
- `conversationTimeboxSubmissionKey`, `conversationTimeboxTool`,
1279
- `createConversationTimeboxControlMessage`, `default`,
1280
- `formatConversationElapsed`, `normalizeConversationTimeboxCommand`, and
1281
- `requireConversationTimeboxDelivery`.
1282
-
1283
- ### Availability and normalization
1284
-
1285
- **Cross-host.** Fully normalized state/command/delivery errors. Transport: Clock/timers and callbacks. [Deep protocol details](protocols.md).
1286
-
1287
- ### Example
1288
-
1289
- ```javascript
1290
- import * as module from '/arcane/modules/ConversationTimebox.js';
1291
-
1292
- console.log(Object.keys(module));
1293
- ```
1294
-
1295
- ## CoreLocalModelCatalog.js
1296
-
1297
- ### Overview
1298
-
1299
- Projects Core local-AI status into UI-safe admitted model and speech availability catalogs.
1300
-
1301
- ### Public surface
1302
-
1303
- Provider-mode constant and four catalog/availability helpers.
1304
-
1305
- Exact exports: `USER_MANAGED_LOOPBACK_PROVIDER_MODE`, `getCoreLocalModelCatalog`, `getCoreLocalModelCatalogWithAdmissionFailures`, `getCoreLocalSpeechAvailability`, `isUserManagedLoopbackLocalAIStatus`.
1306
-
1307
- ### Availability and normalization
1308
-
1309
- **Cross-host.** Fully normalized descriptors and stable admission labels. Transport: In-process projection of Core status. [Deep protocol details](protocols.md).
1310
-
1311
- ### Example
1312
-
1313
- ```javascript
1314
- import * as module from '/arcane/modules/CoreLocalModelCatalog.js';
1315
-
1316
- console.log(Object.keys(module));
1317
- ```
1318
-
1319
- ## DataMaintenance.js
1320
-
1321
- ### Overview
1322
-
1323
- Deletes empty chats and associated/empty memory records inside the current app data scope.
1324
-
1325
- ### Public surface
1326
-
1327
- `clearEmptyChatsAndMemories()` plus content predicates.
1328
-
1329
- Exact exports: `clearEmptyChatsAndMemories`, `hasMemoryContent`, `hasUserEntry`.
1330
-
1331
- ### Availability and normalization
1332
-
1333
- **Browser / native WebView.** Normalized counts; destructive storage failures preserved. Transport: Global DBOPFS. [Deep protocol details](protocols.md).
1334
-
1335
- ### Example
1336
-
1337
- ```javascript
1338
- import * as module from '/arcane/modules/DataMaintenance.js';
1339
-
1340
- console.log(Object.keys(module));
1341
- ```
1342
-
1343
- ## DBLS.js
1344
-
1345
- ### Overview
1346
-
1347
- Provides app-scoped localStorage tables, batch reads/writes, filtering, deletion, and counts.
1348
-
1349
- ### Public surface
1350
-
1351
- default `DBLS`; installs `window.dbls`, emits `dbls-ready`; CRUD/batch/key APIs.
1352
-
1353
- Exact exports: `DBLS_EVENT_TYPES`, `DBLS_REASONS`, `default`.
1354
-
1355
- ### Availability and normalization
1356
-
1357
- **Browser / native WebView.** Scoped keys and values normalized; storage failures mixed. Transport: localStorage + AppDataScope. [Deep protocol details](protocols.md).
1358
-
1359
- ### Example
1360
-
1361
- ```javascript
1362
- import * as module from '/arcane/modules/DBLS.js';
1363
-
1364
- console.log(Object.keys(module));
1365
- ```
1366
-
1367
- ## DBOPFS.js
1368
-
1369
- ### Overview
1370
-
1371
- Provides app-scoped OPFS tables, worker I/O, backup/restore, compression, and CRUD/batch APIs.
1372
-
1373
- ### Public surface
1374
-
1375
- default `DBOPFS`; installs `window.dbopfs`, emits `dbopfs-ready`; table/file/backup APIs.
1376
-
1377
- Exact exports: `DBOPFS_EVENT_TYPES`, `DBOPFS_REASONS`, `default`.
1378
-
1379
- ### Availability and normalization
1380
-
1381
- **Browser / native WebView.** App scope normalized; DOM/storage errors preserved. Transport: OPFS, DBOPFSWorker, Compression Streams. [Deep protocol details](protocols.md).
1382
-
1383
- ### Example
1384
-
1385
- ```javascript
1386
- import * as module from '/arcane/modules/DBOPFS.js';
1387
-
1388
- console.log(Object.keys(module));
1389
- ```
1390
-
1391
- ## DBOPFSDocumentLibrary.js
1392
-
1393
- ### Overview
1394
-
1395
- Stores one application-defined document corpus through an existing DBOPFS-style
1396
- adapter, searches only a completed generation, and builds bounded context that
1397
- is explicitly labeled untrusted. Construction performs no read, write, fetch,
1398
- or search; applications call `bootstrap()` deliberately.
1399
-
1400
- ### Public surface
1401
-
1402
- Exact exports: `DBOPFSDocumentLibrary`, `createDBOPFSDocumentLibrary`,
1403
- `default`, and `normalizeDBOPFSDocumentSchema`.
1404
-
1405
- `new DBOPFSDocumentLibrary({concurrency,db,maxCorpusCharacters,
1406
- maxDocumentCharacters,maxSearchCharacters,schema})` exposes `schema`,
1407
- `bootstrap({files,onProgress,read,readFailurePolicy,signal})`,
1408
- `search(query,{kinds,limit,signal,tags})`,
1409
- `evaluate(query,{sources,read,maxCharacters,maxCorpusCharacters,
1410
- maxScoringCharacters,maxDocumentCharacters?,kinds?,tags?,readFailurePolicy?,
1411
- onProgress?,signal?})`,
1412
- `buildContext(query,{limit,maxCharacters,maxDocumentCharacters,signal})`, and
1413
- `createContextBuilder({limit,maxCharacters,maxDocumentCharacters})`.
1414
-
1415
- `evaluate()` requires `sources`, `read`, `maxCharacters`,
1416
- `maxCorpusCharacters`, and `maxScoringCharacters`. It filters source metadata
1417
- before calling
1418
- `read(source,{maxCharacters,maxCorpusCharacters,ordinal,signal})`, never accepts a
1419
- source body as implicit authority, and never persists a caller-owned body.
1420
- `maxDocumentCharacters` defaults to the smaller instance/output bound.
1421
-
1422
- ### Availability and normalization
1423
-
1424
- **Browser or compatible host with an injected DBOPFS adapter.** The adapter
1425
- keeps the existing `get`, `set`, `getAllKeys`, and `delete` method names; Node
1426
- can use the same class only through an explicitly imported runtime module and a
1427
- compatible storage adapter; SDK `0.3.0` publishes no Node package subpath or
1428
- Node storage implementation for it. Bootstrap uses a bounded concurrent
1429
- generation, commits its manifest last, cleans partial data on failure, and
1430
- rejects case-colliding IDs. Search
1431
- returns `{failures,matches,total}` so one corrupt record does not become a false
1432
- complete result. `bootstrap()` defaults to rejecting read failure; the explicit
1433
- `readFailurePolicy:'preserve-readable'` mode returns partial-success
1434
- `readCoverage`. `evaluate()` also defaults to rejecting a source-read failure;
1435
- its explicit `preserve-readable` mode instead ranks the readable records and
1436
- returns partial `failures` plus `coverage` in the evaluation result (not
1437
- bootstrap's `readCoverage`). It reads a caller-owned source list without
1438
- persisting its bodies and returns frozen `{authority:'sources',characters,
1439
- coverage,documents,failures,limits,query,scoringTruncated,text,truncated}`.
1440
- Read failure remains `DBOPFS_DOCUMENT_READ_FAILED`; invalid public input uses
1441
- `DBOPFS_DOCUMENT_INVALID`, invalid integer budgets use
1442
- `DBOPFS_DOCUMENT_INVALID_LIMIT`, and a preserved read failure without a usable
1443
- source code is reported as `failures[].code:'DBOPFS_DOCUMENT_ERROR'`.
1444
- Cancellation is `AbortError` with code `DBOPFS_DOCUMENT_ABORTED`. Construction
1445
- does not search.
1446
- When an application explicitly supplies the library's context builder, each
1447
- prepared chat send performs that bounded retrieval.
1448
-
1449
- ### Example
1450
-
1451
- ```javascript
1452
- import {
1453
- createDBOPFSDocumentLibrary
1454
- } from '/arcane/modules/DBOPFSDocumentLibrary.js';
1455
-
1456
- const documents = createDBOPFSDocumentLibrary({
1457
- db: globalThis.dbopfs,
1458
- schema: {id: 'help', version: '1', table: 'help_documents'}
1459
- });
1460
- async function replaceHelpCorpusAfterUserChoice() {
1461
- await documents.bootstrap({files: [{
1462
- id: 'welcome',
1463
- path: 'welcome.md',
1464
- title: 'Welcome',
1465
- body: 'Arcane applications are portable.'
1466
- }]});
1467
- console.log(await documents.search('portable'));
1468
-
1469
- const preview = await documents.evaluate('portable', {
1470
- sources: [{id:'draft', path:'draft.md', title:'Draft'}],
1471
- read: async source => source.id === 'draft' ? 'Portable app notes.' : '',
1472
- maxCharacters: 2048,
1473
- maxCorpusCharacters: 4096,
1474
- maxDocumentCharacters: 512,
1475
- maxScoringCharacters: 512
1476
- });
1477
- console.log(preview.coverage, preview.text);
1478
- }
1479
- ```
1480
-
1481
- ## DBOPFSWorker.js
1482
-
1483
- ### Overview
1484
-
1485
- Serializes OPFS sync-handle read/write requests from a MessagePort.
1486
-
1487
- ### Public surface
1488
-
1489
- No ESM exports; accepts `read` and `write` port requests.
1490
-
1491
- This is a dedicated worker protocol and has no ESM exports.
1492
-
1493
- ### Availability and normalization
1494
-
1495
- **Dedicated worker.** Responses normalize to `{success,fileData?}` or `{error:{name,message}}`. Transport: MessageChannel + OPFS sync access handle. [Deep protocol details](protocols.md).
1496
-
1497
- ### Example
1498
-
1499
- ```javascript
1500
- const worker = new Worker('/arcane/modules/DBOPFSWorker.js', {type: 'module'});
1501
- ```
1502
-
1503
- ## DevelopmentWorkspace.js
1504
-
1505
- ### Overview
1506
-
1507
- Provides bounded workspace inspection, context, setup task, and Node installer clients without arbitrary command execution.
1508
-
1509
- ### Public surface
1510
-
1511
- default `DevelopmentWorkspace` and input validators; `inspect()`, `context()`, `setup()`, `installNode()`.
1512
-
1513
- Exact exports: `contextQuery`, `default`, `setupTaskId`, `workspaceRoot`.
1514
-
1515
- ### Availability and normalization
1516
-
1517
- **Native bridge.** Inputs normalized; provider result/error preserved. Transport: Arcane.development. [Deep protocol details](protocols.md).
1518
-
1519
- ### Example
1520
-
1521
- ```javascript
1522
- import * as module from '/arcane/modules/DevelopmentWorkspace.js';
1523
-
1524
- console.log(Object.keys(module));
1525
- ```
1526
-
1527
- ## DirectoryPicker.js
1528
-
1529
- ### Overview
1530
-
1531
- Wraps the provider-owned native directory chooser and normalizes selected/cancelled/error results.
1532
-
1533
- ### Public surface
1534
-
1535
- default `DirectoryPicker`, `normalizeDirectoryPickerOptions()`, `normalizeDirectorySelection()`.
1536
-
1537
- Exact exports: `default`, `normalizeDirectoryPickerOptions`, `normalizeDirectorySelection`.
1538
-
1539
- ### Availability and normalization
1540
-
1541
- **Native bridge.** Strict normalized selection and coded errors. Transport: Arcane.filesystem.selectDirectory. [Deep protocol details](protocols.md).
1542
-
1543
- ### Example
1544
-
1545
- ```javascript
1546
- import * as module from '/arcane/modules/DirectoryPicker.js';
1547
-
1548
- console.log(Object.keys(module));
1549
- ```
1550
-
1551
- ## DocumentLexicalSearch.js
1552
-
1553
- ### Overview
1554
-
1555
- Provides deterministic, dependency-free metadata/body ranking and bounded
1556
- context excerpts for caller-owned document records.
1557
-
1558
- ### Public surface
1559
-
1560
- Exact exports: `DOCUMENT_SEARCH_FIELD_ORDER`, `DocumentLexicalSearch`,
1561
- `createDocumentLexicalIndex`, `default`, `documentContextExcerpt`,
1562
- `documentSearchTokens`, `normalizedDocumentSearchText`, `scoreDocumentBody`,
1563
- and `scoreDocumentLexicalIndex`.
1564
-
1565
- `new DocumentLexicalSearch(records,{maxResults=20})` exposes
1566
- `rank(query,{kinds,tags})` and `search(query,{kinds,limit,tags})`.
1567
-
1568
- ### Availability and normalization
1569
-
1570
- **Cross-host.** Indexing and search are in-process only. Text, tags, kinds,
1571
- scores, field ordering, truncation, and tie-breaking are normalized into frozen
1572
- records. This module performs no storage, network, model, Core, or DOM action.
1573
- The caller decides whether a result is merely displayed or explicitly injected
1574
- as untrusted AI context.
1575
-
1576
- ### Example
1577
-
1578
- ```javascript
1579
- import DocumentLexicalSearch from '/arcane/modules/DocumentLexicalSearch.js';
1580
-
1581
- const search = new DocumentLexicalSearch([{
1582
- id: 'welcome',
1583
- path: 'welcome.md',
1584
- title: 'Welcome',
1585
- body: 'Arcane applications are portable.',
1586
- kind: 'guide',
1587
- tags: ['intro']
1588
- }]);
1589
- console.log(search.search('portable', {limit: 5}));
1590
- ```
1591
-
1592
- ## DocumentNavigation.js
1593
-
1594
- ### Overview
1595
-
1596
- Binds document navigation, filtering, history, current-item reveal, and load initialization.
1597
-
1598
- ### Public surface
1599
-
1600
- Five binding/filter/reveal helpers.
1601
-
1602
- Exact exports: `applyDocumentNavigationFilter`, `bindDocumentNavigation`, `clearDocumentNavigationFilter`, `initializeDocumentNavigation`, `revealCurrentDocumentNavigationItem`.
1603
-
1604
- ### Availability and normalization
1605
-
1606
- **Browser / native WebView.** Normalized filter/navigation state; DOM effects preserved. Transport: DOM and history. [Deep protocol details](protocols.md).
1607
-
1608
- ### Example
1609
-
1610
- ```javascript
1611
- import * as module from '/arcane/modules/DocumentNavigation.js';
1612
-
1613
- console.log(Object.keys(module));
1614
- ```
1615
-
1616
- ## Errors.js
1617
-
1618
- ### Overview
1619
-
1620
- Normalizes global errors/rejections, fingerprints and deduplicates incidents, persists a ledger, and performs bounded delivery.
1621
-
1622
- ### Public surface
1623
-
1624
- default `Errors`; event normalizers/fingerprint plus lifecycle, capture, delivery and teardown methods.
1625
-
1626
- Exact exports: `GLOBAL_ERROR_EVENT_CODES`, `GLOBAL_ERROR_EVENT_TYPES`,
1627
- `GLOBAL_ERROR_REASONS`, `default`, `fingerprintIncident`,
1628
- `normalizeErrorEvent`, and `normalizeRejectionEvent`.
1629
-
1630
- ### Availability and normalization
1631
-
1632
- **Browser / native WebView hybrid.** Incident records normalized; storage/mail failures isolated. Transport: Window events, DBOPFS, Mail. [Deep protocol details](protocols.md).
1633
-
1634
- ### Example
1635
-
1636
- ```javascript
1637
- import * as module from '/arcane/modules/Errors.js';
1638
-
1639
- console.log(Object.keys(module));
1640
- ```
1641
-
1642
- ## GifEncoder.js
1643
-
1644
- ### Overview
1645
-
1646
- Encodes indexed frames into a bounded animated GIF using palette mapping and LZW.
1647
-
1648
- ### Public surface
1649
-
1650
- default `GifEncoder`, `indexPixels()`, `lzw()`.
1651
-
1652
- Exact exports: `default`, `indexPixels`, `lzw`.
1653
-
1654
- ### Availability and normalization
1655
-
1656
- **Cross-host.** Normalized byte output and bounds. Transport: In-process only. [Deep protocol details](protocols.md).
1657
-
1658
- ### Example
1659
-
1660
- ```javascript
1661
- import * as module from '/arcane/modules/GifEncoder.js';
1662
-
1663
- console.log(Object.keys(module));
1664
- ```
1665
-
1666
- ## HTMLImport.js
1667
-
1668
- ### Overview
1669
-
1670
- Defines the same-origin `<html-import>` loader with open shadow root, inline script execution, and readiness/error events.
1671
-
1672
- ### Public surface
1673
-
1674
- default `HTMLImport`; registers `html-import`; `connectedCallback()` and `ready`.
1675
-
1676
- Exact exports: `default`.
1677
-
1678
- ### Availability and normalization
1679
-
1680
- **Browser / native WebView.** Public error detail normalized; fetch/DOM failure preserved. Transport: Same-origin fetch + DOM. [Deep protocol details](protocols.md).
1681
-
1682
- ### Example
1683
-
1684
- ```javascript
1685
- import * as module from '/arcane/modules/HTMLImport.js';
1686
-
1687
- console.log(Object.keys(module));
1688
- ```
1689
-
1690
- ## InMemoryCommunicationProvider.js
1691
-
1692
- ### Overview
1693
-
1694
- Implements deterministic in-memory thread/message/send behavior for demos and tests.
1695
-
1696
- ### Public surface
1697
-
1698
- default provider with `listThreads()`, `getMessages()`, `send()`.
1699
-
1700
- Exact exports: `default`.
1701
-
1702
- ### Availability and normalization
1703
-
1704
- **Cross-host.** Normalized communication entities. Transport: In-process only. [Deep protocol details](protocols.md).
1705
-
1706
- ### Example
1707
-
1708
- ```javascript
1709
- import * as module from '/arcane/modules/InMemoryCommunicationProvider.js';
1710
-
1711
- console.log(Object.keys(module));
1712
- ```
1713
-
1714
- ## IsolatedModelQuestionRunner.js
1715
-
1716
- ### Overview
1717
-
1718
- Inspects one exact model and runs one isolated question with proof validation.
1719
-
1720
- ### Public surface
1721
-
1722
- default/named runner, `countSentences()`, `inspectModel()`, `runQuestion()`.
1723
-
1724
- Exact exports: `IsolatedModelQuestionRunner`, `countSentences`, `default`.
1725
-
1726
- ### Availability and normalization
1727
-
1728
- **Native bridge or injected provider.** Strict normalized proof/coded errors. Transport: localAI isolated-model methods. [Deep protocol details](protocols.md).
1729
-
1730
- ### Example
1731
-
1732
- ```javascript
1733
- import * as module from '/arcane/modules/IsolatedModelQuestionRunner.js';
1734
-
1735
- console.log(Object.keys(module));
1736
- ```
1737
-
1738
- ## LocalAIReadiness.js
1739
-
1740
- ### Overview
1741
-
1742
- Derives selected AI requirements and returns a frozen readiness/recovery report across browser, desktop, and Android modes.
1743
-
1744
- ### Public surface
1745
-
1746
- Endpoint constant plus requirements, speech-health, and readiness helpers.
1747
-
1748
- Exact exports: `LOCAL_AI_BROWSER_ENDPOINTS`, `checkLocalAIReadiness`, `deriveLocalAIRequirements`, `evaluateLocalSpeechHealth`.
1749
-
1750
- ### Availability and normalization
1751
-
1752
- **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).
1753
-
1754
- ### Example
1755
-
1756
- ```javascript
1757
- import * as module from '/arcane/modules/LocalAIReadiness.js';
1758
-
1759
- console.log(Object.keys(module));
1760
- ```
1761
-
1762
- ## LocalAIReadinessController.js
1763
-
1764
- ### Overview
1765
-
1766
- Coordinates local-AI status component checks, ensured recovery, availability projection, and teardown.
1767
-
1768
- ### Public surface
1769
-
1770
- `createLocalAIReadinessController()`, `availabilityFromReport()`.
1771
-
1772
- Exact exports: `LOCAL_AI_READINESS_CONTROLLER_ERROR_CODES`,
1773
- `LOCAL_AI_READINESS_CONTROLLER_EVENT_TYPES`,
1774
- `LOCAL_AI_READINESS_CONTROLLER_REASONS`, `availabilityFromReport`, and
1775
- `createLocalAIReadinessController`.
1776
-
1777
- ### Availability and normalization
1778
-
1779
- `availabilityFromReport()` returns `true` only for a slot whose local
1780
- requirement is explicitly `required:true` and whose report is explicitly
1781
- `ready:true`. Missing and non-local-required slots remain false: this projection
1782
- does not attest provider registration, selection, credentials, browser speech
1783
- authority, or model load state. Components must preserve selected sticky
1784
- `AIRuntimeState` roles as the readiness authority.
1785
-
1786
- **Browser/native hybrid.** Normalized controller state and change events.
1787
- Transport: LocalAIReadiness + component events. [Deep protocol details](protocols.md).
1788
-
1789
- ### Example
1790
-
1791
- ```javascript
1792
- import * as module from '/arcane/modules/LocalAIReadinessController.js';
1793
-
1794
- console.log(Object.keys(module));
1795
- ```
1796
-
1797
- ## Mail.js
1798
-
1799
- ### Overview
1800
-
1801
- Builds bounded reports and prefers the native mail capability with an explicit HTTP transport fallback.
1802
-
1803
- ### Public surface
1804
-
1805
- default `Mail`, `resolveMailConfig()`; installs `window.mail`; `send()`.
1806
-
1807
- Exact exports: `default`, `resolveMailConfig`.
1808
-
1809
- ### Availability and normalization
1810
-
1811
- **Browser/native hybrid + cloud.** Mail inputs/results normalized; transport failures mixed. Transport: Arcane.mail.send or MailTransport HTTP(S). [Deep protocol details](protocols.md).
1812
-
1813
- ### Example
1814
-
1815
- ```javascript
1816
- import * as module from '/arcane/modules/Mail.js';
1817
-
1818
- console.log(Object.keys(module));
1819
- ```
1820
-
1821
- ## MailOutbox.mjs
1822
-
1823
- ### Overview
1824
-
1825
- Persists each bounded provider-neutral mail report before delivery and owns its
1826
- idempotent enqueue, FIFO drain, retry-window, terminal-state, reconciliation,
1827
- and explicit invalid-record maintenance lifecycle. It selects no mail provider,
1828
- recipient, retention policy, retry timer, or transport fallback.
1829
-
1830
- ### Public surface
1831
-
1832
- Exact exports: `MAIL_OUTBOX_ACCEPTANCE_AUTHORITIES`,
1833
- `MAIL_OUTBOX_IDEMPOTENCY_WINDOW_MS`, `MAIL_OUTBOX_PROTOCOL`,
1834
- `MAIL_OUTBOX_STATES`, `MAIL_OUTBOX_TABLE`, `MailOutbox`, `createMailOutbox`, and
1835
- `default`.
1836
-
1837
- ```text
1838
- new MailOutbox({
1839
- storage,
1840
- deliver,
1841
- clock=Date.now,
1842
- isOnline=()=>globalThis.navigator?.onLine!==false,
1843
- lockManager=undefined,
1844
- onlineTarget=typeof globalThis.addEventListener==='function'?globalThis:null,
1845
- onRecordCommitted=null,
1846
- maxAttemptsPerDrain=16,
1847
- maxInvalidRecords=128,
1848
- maxRecords=512,
1849
- maxReportBytes=786432,
1850
- quarantineTable='mail_outbox_quarantine',
1851
- table=MAIL_OUTBOX_TABLE
1852
- }={})
1853
- ```
1854
-
1855
- `storage` must expose `get()`, `set()`, and `getAllKeys()`; explicit deletion or
1856
- quarantine additionally requires `delete()`. `lockManager` must expose the Web
1857
- Locks-compatible `request()` contract. The injected
1858
- `deliver({report,reportKey,serializedReport,signal})` callback receives the
1859
- frozen parsed report, its stable idempotency key, the exact stored JSON string,
1860
- and the caller-owned signal. Omitted `lockManager` resolves first from storage
1861
- and then from `navigator.locks`. A delivery result must identify a valid
1862
- `requestId` and one of `accepted`, `delivery_uncertain`,
1863
- `temporarily_rejected`, `permanently_rejected`, or `partially_accepted`;
1864
- accepted results additionally require a provider ID or the admitted
1865
- `arcane-core-mail-send-v1` acceptance authority.
1866
-
1867
- Read-only getters are `started`, `invalidRecords`, and `lastBackgroundError`.
1868
- Methods are `get(key)`, `list()`, `audit()`, `deleteInvalid(fileName)`,
1869
- `repairInvalid(fileName,replacement)`,
1870
- `quarantineInvalid({limit=64}={})`,
1871
- `enqueue({report,reportKey}={}, {attempt=true,signal=null}={})`,
1872
- `drain({reason='manual',signal=null}={})`, `start({signal=null}={})`, and
1873
- `stop()`. `createMailOutbox(options)` returns `new MailOutbox(options)`.
1874
-
1875
- Every returned durable record is deeply frozen and contains exactly
1876
- `{protocol,reportKey,serializedReport,state,createdAt,updatedAt,firstAttemptAt,
1877
- lastAttemptAt,nextAttemptAt,attempts,result,failure}`. Protocol is
1878
- `arcane-mail-outbox/1`; the default table is `mail_outbox`; the idempotency
1879
- window is 86,400,000 milliseconds. States are exactly `queued`, `sending`,
1880
- `retry_wait`, `accepted`, `failed`, and `reconciliation_required`. Accepted
1881
- means provider or admitted Core acceptance, not inbox delivery.
1882
-
1883
- `enqueue()` serializes same-instance persistence and binds one report key to one
1884
- exact serialized body. `drain()` runs or joins one bounded instance drain under
1885
- an exclusive shared lock and attempts at most 16 records by default. Startup,
1886
- an owned `online` listener, or an explicit call may trigger work; there is no
1887
- polling or retry timer. Abort before the delivery call prevents that call, and a
1888
- caller joining an existing drain may stop waiting without cancelling the shared
1889
- drain. Once an accepted result is committed, it outranks a racing cancellation;
1890
- cancellation never claims an admitted provider attempt stopped. An interrupted
1891
- or ambiguous attempt remains a same-key retry inside the 24-hour window and
1892
- becomes `reconciliation_required` when automatic retry would risk a duplicate.
1893
- `stop()` aborts only the owned online drain, removes its listener, preserves
1894
- durable records, and returns the instance.
1895
-
1896
- `audit()` reports valid records plus bounded invalid-file metadata. Repair,
1897
- deletion, and quarantine are explicit, revalidate the selected file under the
1898
- table lock, and never infer destructive authority from a storage read failure.
1899
- `onRecordCommitted(record)` is an observational callback after each durable
1900
- write; callback failure cannot change the committed operation result.
1901
-
1902
- ### Availability and normalization
1903
-
1904
- **Browser/native WebView or compatible injected host.** The default application
1905
- integration uses DBOPFS-compatible durable storage and `navigator.locks`; an
1906
- alternate adapter owns its own durability claim and must provide equivalent
1907
- storage and shared-lock semantics. Frozen records, bounds, state transitions,
1908
- retry/reconciliation classification, invalid-record maintenance, and
1909
- AbortSignal admission/join cancellation are normalized. Storage, lock,
1910
- online-check, and injected-delivery failures remain visible through concrete
1911
- `MAIL_OUTBOX_*` codes. Transport: injected durable storage, Web Locks,
1912
- AbortSignal, optional online EventTarget, and an injected delivery callback.
1913
- [Deep protocol details](mail.md#durable-send-semantics).
1914
-
1915
- ### Example
1916
-
1917
- ```javascript
1918
- import {createMailOutbox} from '/arcane/modules/MailOutbox.mjs';
1919
-
1920
- const outbox = createMailOutbox({storage, deliver});
1921
- await outbox.start({signal});
1922
- const record = await outbox.enqueue(
1923
- {report, reportKey: 'report-20260827-001'},
1924
- {attempt: true, signal}
1925
- );
1926
- console.log(record.state);
1927
- outbox.stop();
1928
- ```
1929
-
1930
- ## MailTransport.mjs
1931
-
1932
- ### Overview
1933
-
1934
- Sends one bounded mail report to a normalized HTTP(S) endpoint with timeout and response-size limits.
1935
-
1936
- ### Public surface
1937
-
1938
- Timeout/size constants, `MailTransportError`, `normalizeMailEndpoint()`,
1939
- `serializeMailReport()`, and `sendMailReport()`.
1940
-
1941
- Exact exports: `DEFAULT_MAIL_REQUEST_TIMEOUT_MS`, `MAX_MAIL_RESPONSE_BYTES`,
1942
- `MailTransportError`, `normalizeMailEndpoint`, `serializeMailReport`,
1943
- `sendMailReport`.
1944
-
1945
- ### Availability and normalization
1946
-
1947
- **Browser/server with fetch + cloud.** Normalized endpoint/timeout/size errors; remote detail bounded. Transport: HTTP(S) fetch + AbortController. [Deep protocol details](protocols.md).
1948
-
1949
- ### Example
1950
-
1951
- ```javascript
1952
- import * as module from '/arcane/modules/MailTransport.mjs';
1953
-
1954
- console.log(Object.keys(module));
1955
- ```
1956
-
1957
- ## Marked.min.js
1958
-
1959
- ### Overview
1960
-
1961
- Vendored Marked 18.0.5 Markdown lexer, parser, renderer, extension, and walk-token API.
1962
-
1963
- ### Public surface
1964
-
1965
- Twenty named/default-style Marked exports; see bundled license notice.
1966
-
1967
- Exact exports: `Hooks`, `Lexer`, `Marked`, `Parser`, `Renderer`, `TextRenderer`, `Tokenizer`, `defaults`, `getDefaults`, `lexer`, `marked`, `options`, `parse`, `parseInline`, `parser`, `setOptions`, `use`, `walkTokens`.
1968
-
1969
- ### Availability and normalization
1970
-
1971
- **Cross-host vendor module.** Vendor-native Marked contract. Transport: In-process only. [Deep protocol details](protocols.md).
1972
-
1973
- ### Example
1974
-
1975
- ```javascript
1976
- import * as module from '/arcane/modules/Marked.min.js';
1977
-
1978
- console.log(Object.keys(module));
1979
- ```
1980
-
1981
- ## MD.js
1982
-
1983
- ### Overview
1984
-
1985
- Renders Markdown with Marked and exposes a DOM-sanitized projection.
1986
-
1987
- ### Public surface
1988
-
1989
- default `MD`; `raw`, `rendered`, `safeRendered`, `append()`.
1990
-
1991
- Exact exports: `default`.
1992
-
1993
- ### Availability and normalization
1994
-
1995
- **Browser / native WebView.** Raw Marked behavior plus Arcane sanitization; parse errors vendor-native. Transport: Marked + DOM template sanitization. [Deep protocol details](protocols.md).
1996
-
1997
- ### Example
1998
-
1999
- ```javascript
2000
- import * as module from '/arcane/modules/MD.js';
2001
-
2002
- console.log(Object.keys(module));
2003
- ```
2004
-
2005
- ## MemoryRecords.js
2006
-
2007
- ### Overview
2008
-
2009
- Normalizes memory content and detects meaningful stored memory.
2010
-
2011
- ### Public surface
2012
-
2013
- `normalizeMemoryContent()`, `hasMemoryContent()`.
2014
-
2015
- Exact exports: `hasMemoryContent`, `normalizeMemoryContent`.
2016
-
2017
- ### Availability and normalization
2018
-
2019
- **Cross-host.** Fully normalized string/boolean results. Transport: In-process only. [Deep protocol details](protocols.md).
2020
-
2021
- ### Example
2022
-
2023
- ```javascript
2024
- import * as module from '/arcane/modules/MemoryRecords.js';
2025
-
2026
- console.log(Object.keys(module));
2027
- ```
2028
-
2029
- ## MessageAdvisory.js
2030
-
2031
- ### Overview
2032
-
2033
- Normalizes message content advisories and contains per-message inspection failures.
2034
-
2035
- ### Public surface
2036
-
2037
- Three advisory/inspection helpers.
2038
-
2039
- Exact exports: `inspectMessageRecords`, `normalizeContentAdvisory`, `unavailableMessageInspection`.
2040
-
2041
- ### Availability and normalization
2042
-
2043
- **Cross-host.** Normalized advisory records; inspector failures converted to unavailable results. Transport: Injected inspector. [Deep protocol details](protocols.md).
2044
-
2045
- ### Example
2046
-
2047
- ```javascript
2048
- import * as module from '/arcane/modules/MessageAdvisory.js';
2049
-
2050
- console.log(Object.keys(module));
2051
- ```
2052
-
2053
- ## ModelDefinition.js
2054
-
2055
- ### Overview
2056
-
2057
- Parses the deterministic packaged Modelfile subset and extracts the SYSTEM prompt.
2058
-
2059
- ### Public surface
2060
-
2061
- `parseModelDefinition()`, `loadModelDefinitionSystemPrompt()`.
2062
-
2063
- Exact exports: `loadModelDefinitionSystemPrompt`, `parseModelDefinition`.
2064
-
2065
- ### Availability and normalization
2066
-
2067
- **Cross-host.** Strict normalized definition with coded syntax errors. Transport: Optional same-origin read-only fetch. [Deep protocol details](protocols.md).
2068
-
2069
- ### Example
2070
-
2071
- ```javascript
2072
- import * as module from '/arcane/modules/ModelDefinition.js';
2073
-
2074
- console.log(Object.keys(module));
2075
- ```
2076
-
2077
- ## Ollama.js
2078
-
2079
- ### Overview
2080
-
2081
- Provides the first-class Arcane Ollama client without direct access to localhost:11434.
2082
-
2083
- ### Public surface
2084
-
2085
- `Ollama`, singleton/default `ollama`; 24 methods; installs `globalThis.arcaneOllama`, emits `arcane-ollama-ready`.
2086
-
2087
- Exact exports: `OLLAMA_EVENT_TYPES`, `OLLAMA_REASONS`, `Ollama`, `default`,
2088
- and `ollama`.
2089
-
2090
- ### Availability and normalization
2091
-
2092
- **Native bridge.** Principal methods preserve provider-native envelopes; readiness/text/unload helpers normalize. Transport: Arcane.ollama through Core. [Deep protocol details](protocols.md).
2093
-
2094
- ### Example
2095
-
2096
- ```javascript
2097
- import * as module from '/arcane/modules/Ollama.js';
2098
-
2099
- console.log(Object.keys(module));
2100
- ```
2101
-
2102
- ## OllamaModelIdentifier.js
2103
-
2104
- ### Overview
2105
-
2106
- Validates and canonicalizes the syntax of Ollama model identifiers without granting model admission.
2107
-
2108
- ### Public surface
2109
-
2110
- `normalizeOllamaModelIdentifier()`, `isOllamaModelIdentifier()`.
2111
-
2112
- Exact exports: `isOllamaModelIdentifier`, `normalizeOllamaModelIdentifier`.
2113
-
2114
- ### Availability and normalization
2115
-
2116
- **Cross-host.** Fully normalized string/boolean result. Transport: In-process only. [Deep protocol details](protocols.md).
2117
-
2118
- ### Example
2119
-
2120
- ```javascript
2121
- import * as module from '/arcane/modules/OllamaModelIdentifier.js';
2122
-
2123
- console.log(Object.keys(module));
2124
- ```
2125
-
2126
- ## OllamaSettings.js
2127
-
2128
- ### Overview
2129
-
2130
- Defines bounded runtime/service preference schemas and deterministic Arcane brain alias names.
2131
-
2132
- ### Public surface
2133
-
2134
- `ollamaRuntimeSchema`, `ollamaServiceSchema`, `arcaneBrainModelName()`.
2135
-
2136
- Exact exports: `arcaneBrainModelName`, `ollamaRuntimeSchema`, `ollamaServiceSchema`.
2137
-
2138
- ### Availability and normalization
2139
-
2140
- **Cross-host.** Fully normalized settings/name contract. Transport: In-process only. [Deep protocol details](protocols.md).
2141
-
2142
- ### Example
2143
-
2144
- ```javascript
2145
- import * as module from '/arcane/modules/OllamaSettings.js';
2146
-
2147
- console.log(Object.keys(module));
2148
- ```
2149
-
2150
- ## OpenMeteoWeatherProvider.js
2151
-
2152
- ### Overview
2153
-
2154
- Searches and loads Open-Meteo data into frozen Arcane weather entities.
2155
-
2156
- ### Public surface
2157
-
2158
- Endpoint constants, default provider, `mapForecast()`; search/load methods and lifecycle events.
2159
-
2160
- Exact exports: `OPEN_METEO_ENDPOINTS`, `OPEN_METEO_WEATHER_ERRORS`,
2161
- `OPEN_METEO_WEATHER_EVENTS`, `default`, and `mapForecast`.
2162
-
2163
- ### Availability and normalization
2164
-
2165
- **Browser / native WebView / server with fetch + cloud.** Provider data normalized to entities; transport errors mixed. Transport: Open-Meteo HTTPS. [Deep protocol details](protocols.md).
2166
-
2167
- ### Example
2168
-
2169
- ```javascript
2170
- import * as module from '/arcane/modules/OpenMeteoWeatherProvider.js';
2171
-
2172
- console.log(Object.keys(module));
2173
- ```
2174
-
2175
- ## PersistentAIChatSession.js
2176
-
2177
- ### Overview
2178
-
2179
- Composes `ConfiguredAIChatSession` with one `ChatEntity` so every user,
2180
- assistant, and structural tool-result turn has an explicit durable-persistence
2181
- choice. It preserves the existing DBOPFS method names and ChatEntity memory
2182
- semantics; it does not define a new storage protocol.
2183
-
2184
- ### Public surface
2185
-
2186
- Exact exports: `PersistentAIChatSession`, `createPersistentAIChatSession`, and
2187
- `default`.
2188
-
2189
- Constructor and factory options are `{chat,chatEntity,chatFileName,
2190
- contextBuilder,loadExisting,maxContextCharacters,maxMessageCharacters,
2191
- maxMessages,memory,request,responseLength,systemPrompt}`. Public members are
2192
- static `create()`, getters `chatEntity` and `fileName`, and `ready()`,
2193
- `history()`, `settleMemory()`, and `send(input)`.
2194
- `ready()` waits for initialization and resolves the same session instance.
2195
-
2196
- `send()` accepts `{message:{content,role:'user'|'tool',tool_call_id?,persist},
2197
- response:{persist},signal?}`. Message and response persistence must match.
2198
- `persist:false` still commits the coherent turn to live bounded model context,
2199
- but not to durable ChatEntity history or memory. A structural tool result must
2200
- use the persistence choice captured by its matching assistant tool call.
2201
-
2202
- ### Availability and normalization
2203
-
2204
- **Browser or native WebView with ChatEntity/DBOPFS and a configured chat
2205
- function.** The default chat calls normalized `Arcane.ai.chat()`; callers can
2206
- inject the browser-WASM controller, another provider-neutral adapter, or a
2207
- cloud chat function. There is no automatic provider or storage fallback.
2208
- Context builders are request-only, and document context remains explicitly
2209
- untrusted. Errors include `AI_CHAT_BUSY`, `AI_CHAT_TOOL_RESULT_REQUIRED`,
2210
- `AI_CHAT_INVALID_TOOL_MESSAGE`, and `AI_CHAT_INCOHERENT_PERSISTENCE`.
2211
-
2212
- ### Example
2213
-
2214
- ```javascript
2215
- import {
2216
- createPersistentAIChatSession
2217
- } from '/arcane/modules/PersistentAIChatSession.js';
2218
-
2219
- async function sendPersistentSupportTurnAfterUserChoice(documents) {
2220
- const session = await createPersistentAIChatSession({
2221
- chatFileName: 'support.jsonl',
2222
- loadExisting: true,
2223
- contextBuilder: documents.createContextBuilder()
2224
- });
2225
- const response = await session.send({
2226
- message: {role: 'user', content: 'Summarize the documents.', persist: true},
2227
- response: {persist: true}
2228
- });
2229
- console.log(response.message.content);
2230
- }
2231
- ```
2232
-
2233
- ## PreferenceStore.js
2234
-
2235
- ### Overview
2236
-
2237
- Loads and updates schema-defined app preferences through native storage with a narrow browser fallback.
2238
-
2239
- ### Public surface
2240
-
2241
- default `PreferenceStore`, re-exported `Preference`/schema; load/set/reset APIs and events.
2242
-
2243
- Exact exports: `PREFERENCE_STORE_ERROR_CODES`,
2244
- `PREFERENCE_STORE_EVENT_TYPES`, `Preference`, `default`, and
2245
- `preferenceSchema`.
2246
-
2247
- ### Availability and normalization
2248
-
2249
- **Browser/native hybrid.** Values normalized; only exact unsupported capability falls back. Transport: Arcane.preferences or app-scoped localStorage. [Deep protocol details](protocols.md).
2250
-
2251
- ### Example
2252
-
2253
- ```javascript
2254
- import * as module from '/arcane/modules/PreferenceStore.js';
2255
-
2256
- console.log(Object.keys(module));
2257
- ```
2258
-
2259
- ## QRCode.min.js
2260
-
2261
- ### Overview
2262
-
2263
- Vendored QRCode generator for DOM, canvas, SVG, and image output.
2264
-
2265
- ### Public surface
2266
-
2267
- No ESM exports; global `QRCode`, `makeCode()`, `makeImage()`, `clear()`, `CorrectLevel`.
2268
-
2269
- This is a classic global script and has no ESM exports.
2270
-
2271
- ### Availability and normalization
2272
-
2273
- **Browser vendor script.** Vendor-native. Transport: Classic script global + DOM/canvas/SVG. [Deep protocol details](protocols.md).
2274
-
2275
- ### Example
2276
-
2277
- ```html
2278
- <script src="/arcane/modules/QRCode.min.js"></script>
2279
- ```
2280
-
2281
- ## Questionnaire.js
2282
-
2283
- ### Overview
2284
-
2285
- Evaluates whether a one-time questionnaire prompt is due without performing the prompt.
2286
-
2287
- ### Public surface
2288
-
2289
- Notification default and `Questionnaire` with timing/check methods.
2290
-
2291
- Exact exports: `DEFAULT_QUESTIONNAIRE_NOTIFICATION_TIME_MS`, `Questionnaire`.
2292
-
2293
- ### Availability and normalization
2294
-
2295
- **Cross-host.** Normalized fail-closed boolean. Transport: In-process clock only. [Deep protocol details](protocols.md).
2296
-
2297
- ### Example
2298
-
2299
- ```javascript
2300
- import * as module from '/arcane/modules/Questionnaire.js';
2301
-
2302
- console.log(Object.keys(module));
2303
- ```
2304
-
2305
- ## RecordLinkIndex.js
2306
-
2307
- ### Overview
2308
-
2309
- Parses record links and builds their normalized index.
2310
-
2311
- ### Public surface
2312
-
2313
- `parseRecordLinks()`, `buildRecordLinkIndex()`.
2314
-
2315
- Exact exports: `buildRecordLinkIndex`, `parseRecordLinks`.
2316
-
2317
- ### Availability and normalization
2318
-
2319
- **Cross-host.** Fully normalized. Transport: In-process only. [Deep protocol details](protocols.md).
2320
-
2321
- ### Example
2322
-
2323
- ```javascript
2324
- import * as module from '/arcane/modules/RecordLinkIndex.js';
2325
-
2326
- console.log(Object.keys(module));
2327
- ```
2328
-
2329
- ## RecordPassageIndex.js
2330
-
2331
- ### Overview
2332
-
2333
- Indexes text lines, page markers, dates, rules, and excerpts for record review.
2334
-
2335
- ### Public surface
2336
-
2337
- Eight text/page/date/rule helper exports.
2338
-
2339
- Exact exports: `cleanExcerpt`, `extractDateMentions`, `findRulePassages`, `pageAtLine`, `pageMarkers`, `parseDateMention`, `textLines`, `validIsoDate`.
2340
-
2341
- ### Availability and normalization
2342
-
2343
- **Cross-host.** Fully normalized. Transport: In-process only. [Deep protocol details](protocols.md).
2344
-
2345
- ### Example
2346
-
2347
- ```javascript
2348
- import * as module from '/arcane/modules/RecordPassageIndex.js';
2349
-
2350
- console.log(Object.keys(module));
2351
- ```
2352
-
2353
- ## RecordReviewStore.js
2354
-
2355
- ### Overview
2356
-
2357
- Stores normalized record-review decisions through native storage or app-scoped local fallback.
2358
-
2359
- ### Public surface
2360
-
2361
- default store, record/review normalizers; `load()`, `get()`, `set()`, `snapshot()`, change event.
2362
-
2363
- Exact exports: `RECORD_REVIEW_STORE_ERROR_CODES`,
2364
- `RECORD_REVIEW_STORE_EVENT_TYPES`, `default`, `normalizeRecordId`, and
2365
- `normalizeReview`.
2366
-
2367
- ### Availability and normalization
2368
-
2369
- **Browser/native hybrid.** Normalized ids/reviews/snapshots; storage failures mixed. Transport: Arcane.storage or localStorage. [Deep protocol details](protocols.md).
2370
-
2371
- ### Example
2372
-
2373
- ```javascript
2374
- import * as module from '/arcane/modules/RecordReviewStore.js';
2375
-
2376
- console.log(Object.keys(module));
2377
- ```
2378
-
2379
- ## RevocableProjectionLedger.js
2380
-
2381
- ### Overview
2382
-
2383
- Implements an append-only bounded in-memory projection/revocation ledger safe for hostile descriptor inputs.
2384
-
2385
- ### Public surface
2386
-
2387
- Ledger classes, limits/status/reason constants, clone/fingerprint/port helpers, append/query/list APIs.
2388
-
2389
- 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`.
2390
-
2391
- ### Availability and normalization
2392
-
2393
- **Cross-host.** Strict normalization with stable `ProjectionLedgerError`. Transport: In-process or explicit port adapter. [Deep protocol details](protocols.md).
2394
-
2395
- ### Example
2396
-
2397
- ```javascript
2398
- import * as module from '/arcane/modules/RevocableProjectionLedger.js';
2399
-
2400
- console.log(Object.keys(module));
2401
- ```
2402
-
2403
- ## RiskSignalAnalyzer.js
2404
-
2405
- ### Overview
2406
-
2407
- Matches configured risk signals and levels against bounded text.
2408
-
2409
- ### Public surface
2410
-
2411
- `DEFAULT_LEVELS`, `analyzeRiskSignals()`.
2412
-
2413
- Exact exports: `DEFAULT_LEVELS`, `analyzeRiskSignals`.
2414
-
2415
- ### Availability and normalization
2416
-
2417
- **Cross-host.** Fully normalized. Transport: In-process only. [Deep protocol details](protocols.md).
2418
-
2419
- ### Example
2420
-
2421
- ```javascript
2422
- import * as module from '/arcane/modules/RiskSignalAnalyzer.js';
2423
-
2424
- console.log(Object.keys(module));
2425
- ```
2426
-
2427
- ## ScamRiskPolicy.js
2428
-
2429
- ### Overview
2430
-
2431
- Combines deterministic scam signals with Arcane blocked-domain evidence and safety guidance.
2432
-
2433
- ### Public surface
2434
-
2435
- Signals plus load, assess, and guidance helpers.
2436
-
2437
- Exact exports: `assessScamRisk`, `loadScamNetworkPolicy`, `scamRiskSignals`, `scamSafetyGuidance`.
2438
-
2439
- ### Availability and normalization
2440
-
2441
- **Cross-host.** Fully normalized. Transport: Arcane network policy fetch. [Deep protocol details](protocols.md).
2442
-
2443
- ### Example
2444
-
2445
- ```javascript
2446
- import * as module from '/arcane/modules/ScamRiskPolicy.js';
2447
-
2448
- console.log(Object.keys(module));
2449
- ```
2450
-
2451
- ## ScopedOPFSCache.js
2452
-
2453
- ### Overview
2454
-
2455
- Provides a narrow exact-key JSON cache inside one app-owned OPFS namespace.
2456
-
2457
- ### Public surface
2458
-
2459
- default `ScopedOPFSCache`; support check and get/set/delete APIs.
2460
-
2461
- Exact exports: `default`.
2462
-
2463
- ### Availability and normalization
2464
-
2465
- **Browser / native WebView.** Keys/limits/corruption handling normalized; storage errors mixed. Transport: OPFS + AppDataScope. [Deep protocol details](protocols.md).
2466
-
2467
- ### Example
2468
-
2469
- ```javascript
2470
- import * as module from '/arcane/modules/ScopedOPFSCache.js';
2471
-
2472
- console.log(Object.keys(module));
2473
- ```
2474
-
2475
- ## ScreenCapture.js
2476
-
2477
- ### Overview
2478
-
2479
- Captures a display surface as image, video, or GIF with explicit lifecycle events.
2480
-
2481
- ### Public surface
2482
-
2483
- default `ScreenCapture`; acquire/capture/start/stop/reset methods.
2484
-
2485
- Exact exports: `SCREEN_CAPTURE_ERROR_CODES`, `SCREEN_CAPTURE_ERRORS`,
2486
- `SCREEN_CAPTURE_EVENT_TYPES`, `SCREEN_CAPTURE_IMAGE_TYPE_FALLBACK`,
2487
- `SCREEN_CAPTURE_REASONS`, `SCREEN_CAPTURE_STATUSES`, and `default`.
2488
-
2489
- ### Availability and normalization
2490
-
2491
- **Browser / native WebView.** State/events normalized; permission and codec errors mixed. Transport: getDisplayMedia, MediaRecorder, canvas, GifEncoder. [Deep protocol details](protocols.md).
2492
-
2493
- ### Example
2494
-
2495
- ```javascript
2496
- import * as module from '/arcane/modules/ScreenCapture.js';
2497
-
2498
- console.log(Object.keys(module));
2499
- ```
2500
-
2501
- ## SpeechPlayback.js
2502
-
2503
- ### Overview
2504
-
2505
- Segments bounded text, queues latest-request speech synthesis, and controls lookahead HTML audio playback.
2506
-
2507
- ### Public surface
2508
-
2509
- `SpeechPlayback` class/default, voice/limit compatibility constants,
2510
- `SPEECH_PLAYBACK_STATE_EVENT`, `splitSpeechText()`, and playback lifecycle APIs.
2511
-
2512
- Exact exports: `MAX_SPEECH_CHARACTERS`, `MAX_SPEECH_CHUNKS`,
2513
- `MAX_SPEECH_INPUT`, `PREFERRED_STREAM_SEGMENT`, `SPEECH_PLAYBACK_STATE_EVENT`,
2514
- `SPEECH_VOICE_ALIASES`, `SPEECH_VOICE_OPTIONS`, `SpeechPlayback`, `default`,
2515
- and `splitSpeechText`.
2516
-
2517
- ```text
2518
- new SpeechPlayback({
2519
- audio,
2520
- speech=globalThis.Arcane?.speech,
2521
- model=null,
2522
- voice=null,
2523
- responseFormat=null,
2524
- speed=1,
2525
- onState=()=>{},
2526
- createObjectURL,
2527
- revokeObjectURL,
2528
- delay,
2529
- messages={}
2530
- })
2531
- ```
2532
-
2533
- `speech` must expose either `fetchTTS(payload, signal)` or
2534
- `synthesize(payload, {signal})`. `prepare({key,parts,model,voice,responseFormat,
2535
- speed,autoplay=true})` uses only caller-supplied model, voice, and response-format
2536
- values; those three omitted values remain omitted so the selected AI/model
2537
- catalog may admit its documented defaults. Speed defaults to `1`, is normalized
2538
- as a positive number, and is always sent. The legacy voice constants remain
2539
- exported for compatibility but are not selected by the class. There is no
2540
- hard-coded model, response format, voice, or cloud/browser fallback.
2541
-
2542
- Every preparation owns an operation ID and one AbortController for each active
2543
- synthesis segment or playback delay. Replacement,
2544
- `stop()`, `cancel()`, and `destroy()` abort their owned signals, suppress stale
2545
- settlement, release Blob URLs, and publish synchronous
2546
- `speech-playback-state` occurrences through `globalThis.arcaneEvents` before
2547
- calling the compatibility `onState(frozenDetail)` callback. The detail contains
2548
- `state`, `message`, `key`, `index`, `total`, `producing`, `buffered`, `hasAudio`,
2549
- `operationId`, `code`, and `reason`; the canonical public occurrence omits
2550
- provider response/error bodies. `destroy()` also removes every audio listener
2551
- and disposes its per-instance canonical source handle; repeated destroy returns
2552
- `false`. Signal abortion proves delivery suppression; whether provider work
2553
- actually stops remains the selected provider's cancellation boundary.
2554
-
2555
- Stable error codes are `ARCANE_SPEECH_PLAYBACK_DESTROYED`,
2556
- `ARCANE_SPEECH_PLAYBACK_OPERATION_SEQUENCE_EXHAUSTED`,
2557
- `ARCANE_SPEECH_PLAYBACK_SYNTHESIZER_UNAVAILABLE`,
2558
- `ARCANE_SPEECH_PLAYBACK_SYNTHESIZED_AUDIO_CONTRACT_MISMATCH`,
2559
- `ARCANE_SPEECH_PLAYBACK_AUDIO_PLAYBACK_REJECTED`,
2560
- `ARCANE_SPEECH_PLAYBACK_REQUEST_CONTRACT_MISMATCH`, and
2561
- `ARCANE_SPEECH_PLAYBACK_SYNTHESIS_REQUEST_REJECTED`, plus propagated
2562
- `ARCANE_AI_OPERATION_SUPERSEDED` and `ARCANE_AI_REQUEST_ABORTED`.
2563
- Exact lifecycle reasons are `playback-replaced`, `playback-stopped`,
2564
- `playback-destroyed`, `speech-playback-cancelled`,
2565
- `speech-synthesis-superseded`, `speech-synthesis-cancelled`,
2566
- `speech-synthesizer-unavailable`, `synthesized-audio-contract-mismatch`,
2567
- `audio-playback-rejected`, `audio-autoplay-rejected`,
2568
- `speech-playback-request-contract-mismatch`, and
2569
- `speech-synthesis-rejected`, as applicable to the emitted state.
2570
-
2571
- ### Availability and normalization
2572
-
2573
- **Browser + admitted AI/native bridge.** State, cancellation, lifecycle, and
2574
- playable Blob normalization are shared. Provider/model/runtime/voice admission
2575
- remains caller- and catalog-owned. Transport: `AI.fetchTTS`, compatible
2576
- `Arcane.speech.synthesize`, Blob URLs, audio element, and the singleton event
2577
- authority. [Deep protocol details](protocols.md).
2578
-
2579
- ### Example
2580
-
2581
- ```javascript
2582
- import SpeechPlayback from '/arcane/modules/SpeechPlayback.js';
2583
-
2584
- const audio = document.body.appendChild(document.createElement('audio'));
2585
- audio.controls = true;
2586
- const speech = new SpeechPlayback({
2587
- audio,
2588
- speech: globalThis.ai,
2589
- model: 'caller-selected-model',
2590
- voice: 'caller-selected-voice',
2591
- responseFormat: 'wav'
2592
- });
2593
- const speakButton = document.body.appendChild(document.createElement('button'));
2594
- speakButton.type = 'button';
2595
- speakButton.textContent = 'Speak';
2596
- speakButton.addEventListener('click', async () => {
2597
- await speech.prepare({
2598
- key: 'ready',
2599
- parts: ['Arcane is ready.'],
2600
- autoplay: true
2601
- });
2602
- });
2603
- ```
2604
-
2605
- ## StaticDocumentCatalog.js
2606
-
2607
- ### Overview
2608
-
2609
- Loads a positive static document inventory with byte/hash verification, cache, search, and bounded context.
2610
-
2611
- ### Public surface
2612
-
2613
- default catalog, schema constant, catalog normalizer/cache-key; list/get/search/hydrate/context APIs.
2614
-
2615
- Exact exports: `CATALOG_SCHEMA_VERSION`, `default`, `normalizeStaticDocumentCatalog`, `staticDocumentCacheKey`.
2616
-
2617
- ### Availability and normalization
2618
-
2619
- **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).
2620
-
2621
- ### Example
2622
-
2623
- ```javascript
2624
- import * as module from '/arcane/modules/StaticDocumentCatalog.js';
2625
-
2626
- console.log(Object.keys(module));
2627
- ```
2628
-
2629
- ## SystemAppearance.js
2630
-
2631
- ### Overview
2632
-
2633
- Reads or applies native appearance, returning an explicit unsupported browser state when no bridge exists.
2634
-
2635
- ### Public surface
2636
-
2637
- default `SystemAppearance`; `available()`, `current()`, `apply()`.
2638
-
2639
- Exact exports: `default`.
2640
-
2641
- ### Availability and normalization
2642
-
2643
- **Browser/native hybrid.** Absent bridge normalized; native result/error preserved. Transport: Arcane.appearance. [Deep protocol details](protocols.md).
2644
-
2645
- ### Example
2646
-
2647
- ```javascript
2648
- import * as module from '/arcane/modules/SystemAppearance.js';
2649
-
2650
- console.log(Object.keys(module));
2651
- ```
2652
-
2653
- ## SystemPlatformPresentation.js
2654
-
2655
- ### Overview
2656
-
2657
- Maps kernel names to presentation labels/classes without granting platform authority.
2658
-
2659
- ### Public surface
2660
-
2661
- No ESM exports; global `ArcaneSystemPlatformPresentation` with `kernelType()`, `displayName()`, `apply()`.
2662
-
2663
- This is a classic global script and has no ESM exports.
2664
-
2665
- ### Availability and normalization
2666
-
2667
- **Browser / native WebView classic script.** Fully normalized presentation only. Transport: DOM. [Deep protocol details](protocols.md).
2668
-
2669
- ### Example
2670
-
2671
- ```html
2672
- <script src="/arcane/modules/SystemPlatformPresentation.js"></script>
2673
- ```
2674
-
2675
- ## SystemToolRegistry.js
2676
-
2677
- ### Overview
2678
-
2679
- Registers validated command builders and constructs command strings without executing them.
2680
-
2681
- ### Public surface
2682
-
2683
- default registry, `quoteArgument()`, register/list/get/build APIs.
2684
-
2685
- Exact exports: `default`, `quoteArgument`.
2686
-
2687
- ### Availability and normalization
2688
-
2689
- **Cross-host.** Fully normalized definitions/quoting. Transport: In-process only. [Deep protocol details](protocols.md).
2690
-
2691
- ### Example
2692
-
2693
- ```javascript
2694
- import * as module from '/arcane/modules/SystemToolRegistry.js';
2695
-
2696
- console.log(Object.keys(module));
2697
- ```
2698
-
2699
- ## TerminalClient.js
2700
-
2701
- ### Overview
2702
-
2703
- Maps native terminal sessions and Arcane events into an EventTarget client.
2704
-
2705
- ### Public surface
2706
-
2707
- default `TerminalClient`; start/write/resize/signal/close/receive/destroy APIs and terminal events.
2708
-
2709
- Exact exports: `TERMINAL_CLIENT_ERROR_CODES`, `TERMINAL_CLIENT_EVENT_TYPES`,
2710
- `TERMINAL_CLIENT_REASONS`, and `default`.
2711
-
2712
- ### Availability and normalization
2713
-
2714
- **Native bridge.** Client events/state normalized; native result/error mixed. Transport: Arcane.terminal + Arcane.events. [Deep protocol details](protocols.md).
2715
-
2716
- ### Example
2717
-
2718
- ```javascript
2719
- import * as module from '/arcane/modules/TerminalClient.js';
2720
-
2721
- console.log(Object.keys(module));
2722
- ```
2723
-
2724
- ## TerminalCommandRegistry.js
2725
-
2726
- ### Overview
2727
-
2728
- Routes parsed command lines to injected handlers and provides definitions/completions.
2729
-
2730
- ### Public surface
2731
-
2732
- default registry, `splitCommandLine()`, register/resolve/definitions/completions/execute APIs.
2733
-
2734
- Exact exports: `default`, `splitCommandLine`.
2735
-
2736
- ### Availability and normalization
2737
-
2738
- **Cross-host.** Parsing/routing normalized; handler result/error preserved. Transport: Injected handlers. [Deep protocol details](protocols.md).
2739
-
2740
- ### Example
2741
-
2742
- ```javascript
2743
- import * as module from '/arcane/modules/TerminalCommandRegistry.js';
2744
-
2745
- console.log(Object.keys(module));
2746
- ```
2747
-
2748
- ## ThemeBootstrap.js
2749
-
2750
- ### Overview
2751
-
2752
- Performs import-time Arcane theme loading and subscribes to native appearance changes.
2753
-
2754
- ### Public surface
2755
-
2756
- `bootstrapArcaneTheme()`, `arcaneThemeReady`, default ready promise.
2757
-
2758
- Exact exports: `arcaneThemeReady`, `bootstrapArcaneTheme`, `default`, and
2759
- `disposeArcaneThemeBootstrap`.
2760
-
2761
- ### Availability and normalization
2762
-
2763
- **Browser/native hybrid.** Theme state normalized; storage/native errors mixed. Transport: ThemeManager + Arcane.events. [Deep protocol details](protocols.md).
2764
-
2765
- ### Example
2766
-
2767
- ```javascript
2768
- import * as module from '/arcane/modules/ThemeBootstrap.js';
2769
-
2770
- console.log(Object.keys(module));
2771
- ```
2772
-
2773
- ## ThemeManager.js
2774
-
2775
- ### Overview
2776
-
2777
- Loads, applies, previews, saves, resets, and synchronizes semantic Arcane themes.
2778
-
2779
- ### Public surface
2780
-
2781
- default `ThemeManager`, `loadAndApplyTheme()`; scheme/custom/system APIs and `arcane-theme-change`.
2782
-
2783
- Exact exports: `default`, `loadAndApplyTheme`.
2784
-
2785
- ### Availability and normalization
2786
-
2787
- **Browser/native hybrid.** Theme values/events normalized; storage/native failures mixed. Transport: PreferenceStore, DOM, Arcane.appearance. [Deep protocol details](protocols.md).
2788
-
2789
- ### Example
2790
-
2791
- ```javascript
2792
- import * as module from '/arcane/modules/ThemeManager.js';
2793
-
2794
- console.log(Object.keys(module));
2795
- ```
2796
-
2797
- ## TimeGuard.js
2798
-
2799
- ### Overview
2800
-
2801
- Persists and evaluates clock rollback and grace-period state.
2802
-
2803
- ### Public surface
2804
-
2805
- default `TimeGuard`; installs `window.timeguard`, emits `time-guard-ready`; clock methods.
2806
-
2807
- Exact exports: `default`.
2808
-
2809
- ### Availability and normalization
2810
-
2811
- **Browser / native WebView.** Time decisions normalized; storage lifecycle mixed. Transport: User + DBOPFS. [Deep protocol details](protocols.md).
2812
-
2813
- ### Example
2814
-
2815
- ```javascript
2816
- import * as module from '/arcane/modules/TimeGuard.js';
2817
-
2818
- console.log(Object.keys(module));
2819
- ```
2820
-
2821
- ## ToolCallRouter.js
2822
-
2823
- ### Overview
2824
-
2825
- Parses OpenAI-style tool calls and dispatches complete or streamed calls to injected handlers.
2826
-
2827
- ### Public surface
2828
-
2829
- `parseArguments()`, `handleResponse()`, `handleStreamedCalls()`.
2830
-
2831
- Exact exports: `handleResponse`, `handleStreamedCalls`, `parseArguments`.
2832
-
2833
- ### Availability and normalization
2834
-
2835
- **Cross-host.** Arguments/routing normalized; handler results returned or all-settled. Transport: Injected handlers. [Deep protocol details](protocols.md).
2836
-
2837
- ### Example
2838
-
2839
- ```javascript
2840
- import * as module from '/arcane/modules/ToolCallRouter.js';
2841
-
2842
- console.log(Object.keys(module));
2843
- ```
2844
-
2845
- ## uPlot.iife.min.js
2846
-
2847
- ### Overview
2848
-
2849
- Vendored uPlot chart constructor and rendering runtime.
2850
-
2851
- ### Public surface
2852
-
2853
- No ESM exports; global `uPlot` with data/series/scale/cursor/hook/selection/destroy APIs.
2854
-
2855
- This is a classic global script and has no ESM exports.
2856
-
2857
- ### Availability and normalization
2858
-
2859
- **Browser vendor script.** Vendor-native. Transport: Classic script + canvas/DOM. [Deep protocol details](protocols.md).
2860
-
2861
- ### Example
2862
-
2863
- ```html
2864
- <script src="/arcane/modules/uPlot.iife.min.js"></script>
2865
- ```
2866
-
2867
- ## uPlot.LICENSE.txt
2868
-
2869
- ### Overview
2870
-
2871
- License companion for the bundled uPlot vendor runtime.
2872
-
2873
- ### Public surface
2874
-
2875
- MIT license text.
2876
-
2877
- ### Availability and normalization
2878
-
2879
- **Documentation asset.** Not executable. Transport: None. [Deep protocol details](protocols.md).
2880
-
2881
- ### Example
2882
-
2883
- ```text
2884
- /arcane/modules/uPlot.LICENSE.txt
2885
- ```
2886
-
2887
- ## uPlot.min.css
2888
-
2889
- ### Overview
2890
-
2891
- Bundled uPlot presentation stylesheet.
2892
-
2893
- ### Public surface
2894
-
2895
- Load with a stylesheet link before rendering uPlot charts.
2896
-
2897
- ### Availability and normalization
2898
-
2899
- **Browser stylesheet.** Presentation only. Transport: CSS. [Deep protocol details](protocols.md).
2900
-
2901
- ### Example
2902
-
2903
- ```html
2904
- <link rel="stylesheet" href="/arcane/modules/uPlot.min.css">
2905
- ```
2906
-
2907
- ## WaitForComponent.js
2908
-
2909
- ### Overview
2910
-
2911
- Waits for a component property, method, or readiness event with optional error event and bounded timeout.
2912
-
2913
- ### Public surface
2914
-
2915
- default `waitForComponent()`.
2916
-
2917
- Exact exports: `COMPONENT_WAIT_ERROR_CODES`, `COMPONENT_WAIT_REASONS`, and
2918
- `default`.
2919
-
2920
- ### Availability and normalization
2921
-
2922
- **Cross-host EventTarget / browser component.** Normalized coded readiness, error, and timeout results. Transport: EventTarget + timers. [Deep protocol details](protocols.md).
2923
-
2924
- ### Example
2925
-
2926
- ```javascript
2927
- import * as module from '/arcane/modules/WaitForComponent.js';
2928
-
2929
- console.log(Object.keys(module));
2930
- ```
2931
-
2932
- ## YouTubeMedia.js
2933
-
2934
- ### Overview
2935
-
2936
- Validates YouTube video/playlist locators and constructs privacy-enhanced embed URLs.
2937
-
2938
- ### Public surface
2939
-
2940
- `parseYouTubeMedia()`, `youtubeEmbedUrl()`.
2941
-
2942
- Exact exports: `parseYouTubeMedia`, `youtubeEmbedUrl`.
2943
-
2944
- ### Availability and normalization
2945
-
2946
- **Cross-host.** Fully normalized. Transport: URL construction only. [Deep protocol details](protocols.md).
2947
-
2948
- ### Example
2949
-
2950
- ```javascript
2951
- import * as module from '/arcane/modules/YouTubeMedia.js';
2952
-
2953
- console.log(Object.keys(module));
2954
- ```
2955
-
2956
- ## Entity and component continuations
2957
-
2958
- - [Runtime entity modules](runtime-entities.md) explains all 15 modules, and [shared entity contracts](core/arcane-entities.md) owns all 35 exports.
2959
- - [Runtime components](runtime-components.md) owns all 39 HTML-import fragments, methods, slots, and events.
2960
- - [Arcane Ollama](arcane-ollama.md) expands the raw-versus-normalized behavior of `Ollama.js`.