arcane-os 0.3.1 → 0.3.3

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 +855 -895
  5. package/browser-runtime/ai/browser-speech-providers.mjs +80 -204
  6. package/browser-runtime/ai/browser-wasm-llm-provider.mjs +627 -819
  7. package/browser-runtime/ai/browser-wasm.mjs +24 -35
  8. package/browser-runtime/ai/browser-wllama-runtime.mjs +64 -316
  9. package/browser-runtime/ai/model-controller.mjs +584 -181
  10. package/browser-runtime/ai/speech-worker-client.mjs +8 -148
  11. package/browser-runtime/ai/speech-worker-runtime.mjs +642 -374
  12. package/browser-runtime/dom-event-instrumentation.mjs +55 -147
  13. package/browser-runtime/event-manager.mjs +239 -624
  14. package/package.json +5 -6
  15. package/runtime/arcane/components/app-bar.html +3 -15
  16. package/runtime/arcane/components/assistant-panel.html +10 -10
  17. package/runtime/arcane/components/calculator.html +1 -1
  18. package/runtime/arcane/components/chat.html +1359 -135
  19. package/runtime/arcane/components/conversation-view.html +2 -2
  20. package/runtime/arcane/components/document-inspector.html +11 -17
  21. package/runtime/arcane/components/file-manager.html +13 -56
  22. package/runtime/arcane/components/markdown-document.html +82 -281
  23. package/runtime/arcane/components/markdown-editor.html +7 -10
  24. package/runtime/arcane/components/media-embed.html +6 -6
  25. package/runtime/arcane/components/screen-capture.html +4 -4
  26. package/runtime/arcane/components/source-explanation.html +2 -2
  27. package/runtime/arcane/components/speech.html +113 -69
  28. package/runtime/arcane/components/terminal-workspace.html +4 -4
  29. package/runtime/arcane/components/theme-editor.html +1 -1
  30. package/runtime/arcane/components/unified-inbox.html +2 -2
  31. package/runtime/arcane/components/voice-transcription.html +31 -21
  32. package/runtime/arcane/entities/Calculation.js +2 -3
  33. package/runtime/arcane/entities/Chat.js +228 -43
  34. package/runtime/arcane/entities/Preference.js +3 -5
  35. package/runtime/arcane/entities/Weather.js +5 -5
  36. package/runtime/arcane/modules/AI.js +1042 -427
  37. package/runtime/arcane/modules/AIProviderRuntime.js +618 -359
  38. package/runtime/arcane/modules/AIResponseLength.js +9 -19
  39. package/runtime/arcane/modules/AIRuntimeState.js +109 -72
  40. package/runtime/arcane/modules/ArcaneNavigationPolicy.js +45 -32
  41. package/runtime/arcane/modules/BrowserTestSuite.js +78 -122
  42. package/runtime/arcane/modules/CalculatorEngine.js +9 -9
  43. package/runtime/arcane/modules/CommunicationAppController.js +3 -7
  44. package/runtime/arcane/modules/ComponentContracts.js +30 -32
  45. package/runtime/arcane/modules/ConfiguredAIChatSession.js +281 -230
  46. package/runtime/arcane/modules/ConversationActionItems.js +26 -59
  47. package/runtime/arcane/modules/ConversationClosingReport.js +34 -61
  48. package/runtime/arcane/modules/ConversationTimebox.js +27 -15
  49. package/runtime/arcane/modules/DBOPFSDocumentLibrary.js +152 -344
  50. package/runtime/arcane/modules/DocumentLexicalSearch.js +25 -91
  51. package/runtime/arcane/modules/HTMLImport.js +54 -1
  52. package/runtime/arcane/modules/IsolatedModelQuestionRunner.js +40 -203
  53. package/runtime/arcane/modules/LocalAIReadiness.js +40 -60
  54. package/runtime/arcane/modules/LocalAIReadinessController.js +15 -13
  55. package/runtime/arcane/modules/MD.js +1 -45
  56. package/runtime/arcane/modules/Mail.js +51 -103
  57. package/runtime/arcane/modules/MailOutbox.mjs +95 -193
  58. package/runtime/arcane/modules/MailTransport.mjs +36 -57
  59. package/runtime/arcane/modules/ModelDefinition.js +22 -106
  60. package/runtime/arcane/modules/OpenMeteoWeatherProvider.js +39 -101
  61. package/runtime/arcane/modules/PersistentAIChatSession.js +281 -18
  62. package/runtime/arcane/modules/PreferenceStore.js +102 -30
  63. package/runtime/arcane/modules/RiskSignalAnalyzer.js +8 -9
  64. package/runtime/arcane/modules/ScopedOPFSCache.js +7 -42
  65. package/runtime/arcane/modules/ScreenCapture.js +175 -128
  66. package/runtime/arcane/modules/SpeechPlayback.js +46 -149
  67. package/runtime/arcane/modules/StaticDocumentCatalog.js +173 -407
  68. package/runtime/arcane/modules/ToolCallRouter.js +25 -12
  69. package/runtime/arcane/modules/YouTubeMedia.js +6 -5
  70. package/schemas/arcane-app-bundle.schema.json +13 -78
  71. package/schemas/arcane-app.schema.json +9 -25
  72. package/schemas/arcane-lock.schema.json +19 -149
  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 +42 -327
  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 +48 -66
  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 +492 -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 +48 -79
  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 +55 -135
  103. package/src/testing-loader.mjs +164 -0
  104. package/src/testing.mjs +1 -1
  105. package/src/toolchain.mjs +133 -544
  106. package/src/update-check.mjs +26 -64
  107. package/src/workspace-operation-lock.mjs +139 -430
  108. package/src/workspace-runtime.mjs +109 -1558
  109. package/src/workspace.mjs +40 -302
  110. package/browser-runtime/ARCANE_SDK_BROWSER_RELEASE.json +0 -218
  111. package/browser-runtime/ai/ARCANE_AI_BROWSER_SPEECH_COMPONENTS.json +0 -203
  112. package/browser-runtime/ai/ARCANE_AI_BROWSER_WASM_COMPONENTS.json +0 -80
  113. package/browser-runtime/ai/internal/sha256.mjs +0 -166
  114. package/docs/architecture.md +0 -344
  115. package/docs/compatibility.md +0 -36
  116. package/docs/event-manager.md +0 -294
  117. package/docs/platform-targets.md +0 -108
  118. package/docs/publishing.md +0 -201
  119. package/docs/reference/README.md +0 -185
  120. package/docs/reference/ai/browser-speech-package-authority.json +0 -835
  121. package/docs/reference/ai/browser-speech.md +0 -1295
  122. package/docs/reference/ai/browser-wasm.md +0 -530
  123. package/docs/reference/arcane-ollama.md +0 -288
  124. package/docs/reference/availability-and-normalization.md +0 -183
  125. package/docs/reference/behavioral-testing.md +0 -133
  126. package/docs/reference/cli.md +0 -779
  127. package/docs/reference/core/README.md +0 -62
  128. package/docs/reference/core/arcane-ai-contracts.md +0 -907
  129. package/docs/reference/core/arcane-api.md +0 -601
  130. package/docs/reference/core/arcane-entities.md +0 -65
  131. package/docs/reference/core/arcane-events.md +0 -134
  132. package/docs/reference/core/ollama-module.md +0 -181
  133. package/docs/reference/core/reference/arcane-api/ai-and-ollama.md +0 -1909
  134. package/docs/reference/core/reference/arcane-api/applications-terminal-capabilities.md +0 -1057
  135. package/docs/reference/core/reference/arcane-api/core-and-events.md +0 -320
  136. package/docs/reference/core/reference/arcane-api/filesystem-storage-preferences-appearance.md +0 -610
  137. package/docs/reference/core/reference/arcane-api/namespaces.md +0 -1157
  138. package/docs/reference/core/reference/arcane-api/platform-installation-users-system.md +0 -1423
  139. package/docs/reference/core/reference/arcane-api/session-provisioning-diagnostics-development.md +0 -315
  140. package/docs/reference/event-manager.md +0 -1511
  141. package/docs/reference/inventory/package-api.json +0 -3284
  142. package/docs/reference/inventory/runtime-components.json +0 -1011
  143. package/docs/reference/inventory/runtime-entities.json +0 -26
  144. package/docs/reference/inventory/runtime-modules.json +0 -1431
  145. package/docs/reference/mail.md +0 -316
  146. package/docs/reference/protocols.md +0 -719
  147. package/docs/reference/runtime-components.md +0 -1366
  148. package/docs/reference/runtime-entities.md +0 -303
  149. package/docs/reference/runtime-modules.md +0 -2965
  150. package/docs/reference/sdk-api.md +0 -6698
  151. package/docs/roadmap.md +0 -79
  152. package/docs/work-amplification.md +0 -129
  153. package/runtime/ARCANE_RUNTIME_RELEASE.json +0 -826
@@ -1,907 +0,0 @@
1
- # Arcane AI Data Contracts
2
-
3
- This reference defines the request and result objects used by Arcane's
4
- provider-neutral AI, local AI, speech, isolated-inference, and direct Ollama
5
- APIs. Start with the method index in the [Arcane API Reference](arcane-api.md).
6
-
7
- The type names below are documentation notation for plain JavaScript values.
8
- They are not TypeScript declarations.
9
-
10
- ## Portable SDK AI and Core AI
11
-
12
- The SDK `0.3.1` has two related but separate normalized boundaries:
13
-
14
- | Boundary | Use | Host |
15
- |---|---|---|
16
- | [`AIProviderRuntime.js`](../runtime-modules.md#aiproviderruntimejs) plus [`AIRuntimeState.js`](../runtime-modules.md#airuntimestatejs) | Register and control independent LLM, STT, and TTS providers through `arcane-ai-provider/2`; observe sticky state and startup barriers. | Cross-host controller/state; each provider retains its own browser, native, or cloud requirements. |
17
- | `globalThis.Arcane.ai` and `globalThis.Arcane.speech` | Call an admitted Core-normalized AI or native speech method. | Native/Core only when the current app, method, capability, provider, and host are admitted. |
18
-
19
- The browser-only [`arcane-os/ai/browser-wasm`](../ai/browser-wasm.md)
20
- entrypoint provides a caller-authenticated local LLM adapter, and
21
- [`arcane-os/ai/browser-speech`](../ai/browser-speech.md) provides
22
- caller-authenticated Whisper/Kokoro provider mechanisms. Neither browser
23
- entrypoint grants Core authority or silently falls back to native/cloud.
24
-
25
- [`PersistentAIChatSession.js`](../runtime-modules.md#persistentaichatsessionjs)
26
- can bind the same chat API to existing ChatEntity/DBOPFS history and memory.
27
- [`DBOPFSDocumentLibrary.js`](../runtime-modules.md#dbopfsdocumentlibraryjs)
28
- provides explicit bounded retrieval context. Those mechanisms preserve the
29
- existing storage semantics. Construction alone performs no search. When an
30
- application explicitly supplies the document library's context builder, each
31
- prepared send performs its bounded lexical retrieval automatically; neither
32
- mechanism executes a tool.
33
-
34
- ## Contract conventions
35
-
36
- | Input style | Unknown keys | Object rules |
37
- |---|---|---|
38
- | Exact record | Rejected | A plain object with exactly the documented own data properties. Every field is required unless marked optional. Arrays, accessors, symbol keys, and non-plain objects are rejected. |
39
- | Closed object | Rejected at the documented level | A plain object containing only the documented top-level keys. Provider-native nested values may have additional provider-defined structure. |
40
- | Settings object | Currently ignored | A plain object whose documented keys are read. Callers should still send only documented keys. |
41
-
42
- `Required` means the caller must supply the field. `Conditional` means the field
43
- is required only under the condition in its constraints. A safe integer passes
44
- `Number.isSafeInteger`. Byte limits use UTF-8 unless a row says characters,
45
- encoded text, or decoded bytes.
46
-
47
- Authorization and host admission occur before method-specific validation. An
48
- unauthorized caller can therefore receive a capability or host error before an
49
- input error. Rejections use `Arcane.Error`; never parse its human-readable
50
- message as a protocol value.
51
-
52
- These rows define the portable caller contract. Some provider-settings and
53
- speech validators currently coerce or ignore particular off-contract values
54
- differently on desktop Core and Android. Callers must send the documented types
55
- and keys and must not depend on permissive host behavior or uniform rejection of
56
- invalid input. The provider-neutral AI, local-AI, speech, and direct Ollama
57
- methods in this document currently use method-local validators rather than
58
- canonical entries in `method-contracts.json`; catalog metadata must not invent
59
- semantic attributes that the registry does not define.
60
-
61
- ## Provider-neutral AI
62
-
63
- ### AI chat request
64
-
65
- `Arcane.ai.chat(request)` accepts a closed `AIChatRequest`.
66
-
67
- | Field | Type | Required | Constraints / default | Description |
68
- |---|---|---:|---|---|
69
- | `messages` | [`AIChatMessage[]`](#ai-chat-message) | Yes | 1-128 records; combined content at most 512 KiB | Conversation sent to the configured provider. |
70
- | `expectedProvider` | `"ollama" \| "openai"` | No | Omitted means no caller-side provider binding | Rejects with `AI_PROVIDER_CHANGED` when the configured provider changed before dispatch. |
71
- | `format` | `"json" \| "" \| null` | No | Omit, `null`, or `""` for text | Portable output-format control. |
72
- | `model` | `string` | No | Local model pattern `[A-Za-z0-9][A-Za-z0-9._:/-]{0,255}` | Local Ollama override. The OpenAI path always uses the configured, account-validated model. |
73
- | `options` | JSON object | No | Ollama only | Provider-native generation options. |
74
- | `tools` | JSON array | No | Ollama only | Provider-native tool definitions. |
75
- | `keep_alive` | JSON value | No | Ollama only | Provider-native model-residency control. |
76
- | `think` | JSON value | No | Ollama only | Provider-native reasoning control. |
77
- | `logprobs` | JSON value | No | Ollama only | Provider-native log-probability control. |
78
- | `top_logprobs` | JSON value | No | Ollama only | Provider-native log-probability count. |
79
-
80
- For a provider-portable request, send only `messages`, optional
81
- `expectedProvider`, and optional `format`.
82
-
83
- ```js
84
- async function askAvailableModelsAfterUserChoice() {
85
- const profile = await Arcane.ai.profile();
86
-
87
- return Arcane.ai.chat({
88
- expectedProvider: profile.provider,
89
- messages: [
90
- { role: "system", content: "Answer briefly and accurately." },
91
- { role: "user", content: "What models are available?" }
92
- ]
93
- });
94
- }
95
- ```
96
-
97
- ### AI chat message
98
-
99
- Every `AIChatMessage` is an exact record.
100
-
101
- | Field | Type | Required | Constraints / default | Description |
102
- |---|---|---:|---|---|
103
- | `role` | `"system" \| "user" \| "assistant"` | Yes | Exact lowercase value | Message author role. |
104
- | `content` | `string` | Yes | Nonempty; at most 131,072 characters | Message text. |
105
-
106
- No other message fields are accepted.
107
-
108
- ### AI chat result
109
-
110
- `AIChatResult` is normalized across configured Ollama and OpenAI chat.
111
-
112
- | Field | Type | Required | Constraints / default | Description |
113
- |---|---|---:|---|---|
114
- | `provider` | `"arcane-ollama" \| "openai"` | Yes | - | Provider that completed the request. |
115
- | `model` | `string` | Yes | Bounded provider model identifier | Model used for the response. |
116
- | `message.role` | `"assistant"` | Yes | - | Normalized response role. |
117
- | `message.content` | `string` | Yes | At most 4 MiB retained | Assistant response text. |
118
- | `message.thinking` | `string` | No | Ollama only; at most 4 MiB retained | Provider reasoning text when present. |
119
- | `message.toolCalls` | `array` | No | Ollama provider-native records | Tool calls when present. |
120
- | `done` | `boolean` | Yes | OpenAI returns `true` | Completion flag. |
121
- | `doneReason` | `string \| null` | Yes | At most 128 characters | Completion reason. |
122
- | `promptEvalCount` | `integer \| null` | Yes | Nonnegative when present | Prompt token/evaluation count. |
123
- | `evalCount` | `integer \| null` | Yes | Nonnegative when present | Completion token/evaluation count. |
124
-
125
- ### AI profile
126
-
127
- `Arcane.ai.profile()` returns `AIProfile`.
128
-
129
- | Field | Type | Required | Constraints / default | Description |
130
- |---|---|---:|---|---|
131
- | `provider` | `"ollama" \| "openai"` | Yes | - | Selected provider. |
132
- | `model` | `string` | Yes | Effective configured model | Model used by provider-neutral chat. |
133
- | `configured` | `boolean` | Yes | - | Required provider configuration is present. |
134
- | `local` | `boolean` | Yes | `true` only for Ollama | Whether inference remains local. |
135
- | `responseLength` | `"low" \| "medium" \| "high"` | Yes | Legacy invalid/missing state resolves to `"medium"` | Conversational response target, not a provider token limit. |
136
-
137
- An OpenAI profile is returned only after Arcane proves a protected credential
138
- exists and the configured model is available to that account.
139
-
140
- ### AI provider settings input
141
-
142
- `Arcane.ai.saveProviderSettings(settings)` reads the documented fields from an
143
- `AIProviderSettingsInput` patch. Omitted keys preserve the current value. Send
144
- only these keys and the documented value types; do not rely on a host ignoring
145
- unknown fields or coercing `removeToken`.
146
-
147
- | Field | Type | Required | Constraints / default | Description |
148
- |---|---|---:|---|---|
149
- | `provider` | `"ollama" \| "openai"` | No | Current provider | Provider to select. |
150
- | `openAIModel` | `string` | Conditional | Pattern `[A-Za-z0-9][A-Za-z0-9._:-]{0,127}`; required for OpenAI | Account-accessible OpenAI model. |
151
- | `responseLength` | `"low" \| "medium" \| "high"` | No | Current value | Conversational response target. |
152
- | `token` | `string` | No | Trimmed, starts with `sk-`, 20-512 characters | Replacement OpenAI credential. It is protected and never returned. |
153
- | `removeToken` | `boolean` | No | Only `true` requests deletion | Removes the stored credential. A supplied `token` becomes the final credential. |
154
-
155
- Arcane verifies the selected OpenAI model when OpenAI is selected and validates
156
- a supplied replacement credential before persistence. Ollama-selected settings
157
- may retain a dormant OpenAI model; Arcane revalidates it before a later switch
158
- to OpenAI. Credential and settings mutations are rolled back together when
159
- possible if the save fails.
160
-
161
- ### AI provider settings result
162
-
163
- `Arcane.ai.providerSettings()` and a successful save return
164
- `AIProviderSettingsResult`.
165
-
166
- | Field | Type | Required | Constraints / default | Description |
167
- |---|---|---:|---|---|
168
- | `provider` | `"ollama" \| "openai"` | Yes | - | Selected provider. |
169
- | `openAIModel` | `string` | Yes | May be empty when OpenAI is not selected | Saved OpenAI model. |
170
- | `openAIConfigured` | `boolean` | Yes | - | A protected credential exists. |
171
- | `responseLength` | `"low" \| "medium" \| "high"` | Yes | - | Saved response target. |
172
-
173
- Credentials are never included.
174
-
175
- ### Local AI inventory
176
-
177
- `Arcane.ai.models()` returns `LocalAIInventory`, not a bare array. This is raw
178
- diagnostic inventory, not the admitted application selector catalog.
179
-
180
- | Field | Type | Required | Constraints / default | Description |
181
- |---|---|---:|---|---|
182
- | `provider` | `"arcane-ollama"` | Yes | - | Catalog source. |
183
- | `models` | `OllamaInventoryModel[]` | Yes | At most 512 records | Normalized installed inventory. |
184
-
185
- Each `OllamaInventoryModel` contains:
186
-
187
- | Field | Type | Required | Constraints / default | Description |
188
- |---|---|---:|---|---|
189
- | `name` | `string` | Yes | Local model-name pattern | Installed model identifier. |
190
- | `modifiedAt` | `string \| null` | Yes | At most 64 characters | Provider timestamp when available. |
191
- | `sizeBytes` | `integer \| null` | Yes | Nonnegative safe integer | Installed size when valid. |
192
- | `digest` | `string \| null` | Yes | Lowercase 64-character hexadecimal digest | Model digest when valid. |
193
- | `family` | `string \| null` | Yes | At most 128 characters | Provider-reported family. |
194
- | `parameterSize` | `string \| null` | Yes | At most 64 characters | Provider parameter-size label. |
195
- | `quantization` | `string \| null` | Yes | At most 64 characters | Provider quantization label. |
196
-
197
- ### AI provider model catalog
198
-
199
- `Arcane.ai.providerModels()` returns `AIProviderModelCatalog` after querying the
200
- protected OpenAI credential's account.
201
-
202
- | Field | Type | Required | Constraints / default | Description |
203
- |---|---|---:|---|---|
204
- | `provider` | `"openai"` | Yes | - | Catalog source. |
205
- | `models` | `string[]` | Yes | Each value matches the OpenAI model pattern | Sorted account-accessible identifiers. |
206
-
207
- This method can perform a network request. It does not return Ollama models.
208
-
209
- ## Local AI discovery and lifecycle
210
-
211
- ### Local AI status v2
212
-
213
- `Arcane.localAI.status()` takes no arguments and returns `LocalAIStatusV2`.
214
- Concurrent callers in one Core process can share the same active discovery.
215
- An admitted development Android provider uses the same schema version with the
216
- exact `user-managed-loopback` discriminator described below.
217
-
218
- | Field | Type | Required | Constraints / default | Description |
219
- |---|---|---:|---|---|
220
- | `schemaVersion` | `2` | Yes | Literal | Status schema. |
221
- | `providerMode` | `"user-managed-loopback"` | Android only | Omitted by desktop Core | Identifies the narrow Android provider without changing `Arcane.runtime.current().managedLocalAI`, which remains false. |
222
- | `runtime` | object | Yes | Desktop Core or bounded Android provider identity | Runtime authority and whether desktop native resource admission is active. |
223
- | `policy` | object | Yes | See below | Package-bound model policy. |
224
- | `ollama` | object | Yes | See below | Ollama discovery state. |
225
- | `admission` | object | Yes | See below | Native-admission summary. |
226
- | `speech` | object | Yes | See below | Independent speech readiness. |
227
- | `models` | object | Yes | `{ollama, speech, transcription}` arrays | Admitted catalogs. |
228
-
229
- `policy` fields:
230
-
231
- | Field | Type | Required | Constraints / default | Description |
232
- |---|---|---:|---|---|
233
- | `verified_only` | `boolean` | Yes | Package policy | Whether only declared verified models are considered. |
234
- | `source` | `"package-bound-application-policy"` | Yes | Literal | Policy source. |
235
- | `unverifiedInferenceAuthorized` | `boolean` | Yes | Requires explicit package authority | Whether installed unverified models may be considered for inference. |
236
-
237
- `ollama` fields:
238
-
239
- | Field | Type | Required | Constraints / default | Description |
240
- |---|---|---:|---|---|
241
- | `available` | `boolean` | Yes | - | Core obtained a valid bounded catalog. |
242
- | `modelCapabilitiesVerified` | `boolean` | Yes | - | Capability discovery completed. |
243
- | `nativeAdmissionEnforced` | `boolean` | Yes | `true` for desktop Core; `false` for Android user-managed loopback | Whether desktop native resource admission is enforced. Android still applies its generated package-policy and provider-inspection boundary. |
244
- | `activeParallelRequests` | `integer` | Desktop Core | Positive safe integer | Current machine-wide managed Ollama parallel request count used for active-fit evidence. |
245
- | `errorCode` | `string \| null` | Yes | Normalized code | Discovery failure code. |
246
-
247
- `admission` fields:
248
-
249
- | Field | Type | Required | Constraints / default | Description |
250
- |---|---|---:|---|---|
251
- | `policyVersion` | `integer` | Yes | Currently `1` | Resource-policy version. |
252
- | `enforcedBy` | `string` | Yes | Bounded host-owned identifier | Admission authority; renderers must not interpret it as reusable authorization. |
253
- | `evaluatedModels` | `integer` | Yes | Nonnegative | Candidate count evaluated. |
254
- | `admittedModels` | `integer` | Yes | 0 through `evaluatedModels` | Candidate count admitted at one parallel request. A model can still have `runnable:false` when the active machine-wide parallel count exceeds its current model-specific ceiling. |
255
- | `rejected` | `array` | Yes | `{id, compatibility}` records | Rejected candidates and admission evidence. |
256
-
257
- `speech` fields:
258
-
259
- | Field | Type | Required | Constraints / default | Description |
260
- |---|---|---:|---|---|
261
- | `available` | `boolean` | Yes | - | Synthesis or transcription is available. |
262
- | `reachable` | `boolean` | Yes | - | Core validated the health endpoint. |
263
- | `synthesisAvailable` | `boolean` | Yes | - | Kokoro readiness. |
264
- | `transcriptionAvailable` | `boolean` | Yes | - | Whisper readiness. |
265
- | `synthesisErrorCode` | `string \| null` | Yes | - | Synthesis failure/readiness code. |
266
- | `transcriptionErrorCode` | `string \| null` | Yes | - | Transcription failure/readiness code. |
267
- | `errorCode` | `string \| null` | Yes | - | Overall speech failure code. |
268
-
269
- `models.ollama` contains [`LocalAIModel`](#local-ai-model) records.
270
- `models.speech` and `models.transcription` contain
271
- [`LocalAIServiceModel`](#local-ai-service-model) records. An unavailable service
272
- resolves as service-local status data where possible; it never silently changes
273
- providers.
274
-
275
- For `providerMode:"user-managed-loopback"`, the Android host calls only the
276
- fixed `127.0.0.1:11434` Ollama service and fixed host-owned loopback speech
277
- service. It returns only installed package-policy models that passed its bounded
278
- provider inspection, repeats model admission before `ollama.chat`, and merges
279
- the independently bounded Kokoro and Whisper role health and catalogs. The host
280
- does not expose recovery or model mutation. The renderer never calls either
281
- loopback API directly.
282
-
283
- Android Linux Terminal, Ollama, and every model lifecycle action remain user-owned. Plain
284
- loopback Ollama has no caller authentication; other local applications or
285
- processes may call it, race the host's checks, contend for resources, or deny
286
- service. This is unsigned development behavior, not release support, managed
287
- service ownership, or an isolated-inference guarantee. Android exposes no
288
- application-owned isolated-question or repository extension unless generated
289
- package and method policy explicitly admit it.
290
-
291
- ### Local AI model
292
-
293
- | Field | Type | Required | Constraints / default | Description |
294
- |---|---|---:|---|---|
295
- | `id`, `name` | `string` | Yes | Equal model identifiers | Snapshot selection identifier and Ollama name. |
296
- | `provider` | `"ollama"` | Yes | Literal | Provider. |
297
- | `roles` | `array` | Yes | Currently empty | Reserved role catalog. |
298
- | `managed` | `boolean` | Yes | - | Declared by package policy. |
299
- | `installed` | `boolean` | Yes | - | Runnable alias or authorized model is installed. |
300
- | `admitted` | `true` | Yes | Literal | Current serial-fit admission. This is not proof that the active parallel setting fits. |
301
- | `runnable`, `creatable`, `pullable`, `verified` | `boolean` | Yes | - | Managed lifecycle state. `runnable:false` can mean the active parallel setting exceeds the model's current ceiling. |
302
- | `capabilitiesVerified`, `available` | `true` | Yes | Literal | Capability and availability proof. |
303
- | `modifiedAt` | `string \| null` | Yes | - | Installed timestamp. |
304
- | `sizeBytes` | `integer \| null` | Yes | Nonnegative safe integer | Model size. |
305
- | `digest` | `string \| null` | Yes | 64-character hexadecimal value | Installed digest. |
306
- | `family`, `parameterSize`, `quantization` | `string \| null` | Yes | Bounded diagnostic strings | Provider metadata. |
307
- | `compatibility` | [`ModelResourceAdmission`](#model-resource-admission) | Yes | `admitted:true` | Native resource and definition evidence. |
308
-
309
- This record is snapshot evidence, not reusable authorization. Core re-admits the
310
- exact model and requested context before inference.
311
-
312
- ### Local AI service model
313
-
314
- | Field | Type | Required | Constraints / default | Description |
315
- |---|---|---:|---|---|
316
- | `id` | `"kokoro" \| "whisper-small"` | Yes | - | Model identifier. |
317
- | `name` | `"Kokoro" \| "Whisper Small"` | Yes | - | Display name. |
318
- | `provider` | `"speech"` | Yes | Literal | Service provider. |
319
- | `roles` | `["tts"] \| ["stt"]` | Yes | One role | Supported operation. |
320
- | `available` | `true` | Yes | Literal | Availability in this snapshot. |
321
- | `engine` | `string` | Yes | Health-validated identifier | Native engine. |
322
-
323
- ### Model resource admission
324
-
325
- `ModelResourceAdmission` is a union. Early failures can omit diagnostic fields;
326
- callers must not assume every field exists.
327
-
328
- | Field | Type | Required | Constraints / default | Description |
329
- |---|---|---:|---|---|
330
- | `policyVersion` | `integer` | Yes | Currently `1` | Resource-policy version. |
331
- | `admitted` | `boolean` | Yes | - | Current fit decision. |
332
- | `status` | `"compatible" \| "incompatible" \| "evidence-unavailable"` | Yes | - | Admission classification. |
333
- | `code` | `string \| null` | Yes | `null` on success | Stable result code. |
334
- | `message` | `string` | Yes | At most 512 characters | Human-readable result. |
335
- | `resolution` | `string \| null` | Yes | At most 512 characters | Suggested remediation. |
336
- | `operation` | `"inference" \| "create" \| "pull"` | No | Evidence-dependent | Evaluated operation. |
337
- | `model` | `string` | No | At most 256 characters | Evaluated model. |
338
- | `modelBytes`, `downloadBytes`, `contextTokens`, `nativeContextTokens`, `kvCacheBytes` | `integer \| null` | No | Positive when present | Model, transfer, requested/native context, and K/V-cache evidence. |
339
- | `parallelism` | `integer` | No | Positive safe integer | Parallel request count evaluated by this admission record. |
340
- | `activeParallelRequests` | `integer` | No | Positive safe integer | Current machine-wide managed Ollama setting observed for the snapshot. |
341
- | `maxAllowedParallelRequests` | `integer \| null` | No | `null`, 0, or a positive safe integer | Largest count admitted by the same immutable model/resource snapshot. It is solved directly from the model's K/V-cache equation and available working-set bytes, without a product ceiling. `null` means evidence was unavailable; `0` means even one request was proven memory-incompatible. |
342
- | `activeParallelRequestsAllowed` | `boolean \| null` | No | - | Whether the active count is within `maxAllowedParallelRequests`; `null` preserves unknown evidence. |
343
- | `runtimeHeadroomBytes`, `requiredWorkingSetBytes` | `integer` | No | Positive | Derived working-set requirements. |
344
- | `requiredAdditionalBytes`, `availableWorkingSetBytes` | `integer` | No | Nonnegative | Additional requirement and available capacity. |
345
- | `loadedModelBytes`, `targetResidentBytes` | `integer` | No | Nonnegative | Current residency evidence. |
346
- | `checks` | [`ModelResourceCheck[]`](#model-resource-checks) | No | - | Individual capacity checks. |
347
- | `definitionVerified`, `baseModelInstalled`, `creationRequired`, `pullRequired` | `boolean` | No | Managed workflows | Managed lifecycle evidence. |
348
- | `registryEvidence` | object | No | Opaque diagnostic shape | Preflight detail; never an authorization token. |
349
-
350
- Other bounded diagnostics may appear on failures. Branch on `admitted`,
351
- `status`, and `code`; treat additional evidence as display-only.
352
-
353
- ### Model resource checks
354
-
355
- A working-set `ModelResourceCheck` contains:
356
-
357
- | Field | Type | Required | Constraints / default | Description |
358
- |---|---|---:|---|---|
359
- | `id` | `"working-set"` | Yes | Literal | Check identifier. |
360
- | `ok` | `boolean` | Yes | - | Pass/fail result. |
361
- | `requiredBytes`, `totalRequiredBytes`, `availableBytes` | `integer` | Yes | Nonnegative | Required additional, required total, and available bytes. |
362
- | `systemFreeBytes`, `systemReserveBytes`, `usableSystemBytes` | `integer` | Yes | Nonnegative | System-memory evidence. |
363
- | `usableGpuBytes`, `loadedModelBytes`, `targetResidentBytes` | `integer` | Yes | Nonnegative | Accelerator and residency evidence. |
364
-
365
- A pull may add a `"model-store"` check with `ok`, `requiredBytes`,
366
- `availableBytes`, `storageFreeBytes`, and `storageReserveBytes`.
367
-
368
- Admission proves only current fit. It does not prove safety, output quality,
369
- license, provenance, supplier identity, future capacity, or stability under
370
- later concurrent workloads.
371
-
372
- ### Local AI platform result
373
-
374
- `Arcane.localAI.ensurePlatform()` takes no arguments. It is a Provisioner-only,
375
- exclusive post-install reconciliation. It retries when settings change during
376
- the operation and rejects with `ARCANE_AI_PROFILE_CHANGED` after three stale
377
- plans instead of overwriting newer settings.
378
-
379
- `LocalAIPlatformResult` always contains an [`ArcaneOperation`](#arcane-operation)
380
- and one of these branches.
381
-
382
- OpenAI-selected branch:
383
-
384
- | Field | Type | Required | Constraints / default | Description |
385
- |---|---|---:|---|---|
386
- | `local` | object | Yes | `{available:false, reason:"openai-selected"}` | Local reconciliation was intentionally skipped. |
387
- | `fallback.provider` | `"openai"` | Yes | Literal | Explicit selected provider. |
388
- | `fallback.model` | `string` | Yes | Protected-credential account-validated model | Selected OpenAI model. |
389
- | `fallback.configured` | `true` | Yes | Literal | Required credential and model are valid. |
390
- | `loaded` | object | Yes | `{loaded:false, provider:"openai", model}` | No local model was loaded. |
391
- | `operation` | [`ArcaneOperation`](#arcane-operation) | Yes | Completed | Exclusive operation receipt. |
392
-
393
- Local branch:
394
-
395
- | Field | Type | Required | Constraints / default | Description |
396
- |---|---|---:|---|---|
397
- | `local.available` | `true` | Yes | Literal | Local AI is available. |
398
- | `local.model` | `string` | Yes | Managed selected model | Ready model definition. |
399
- | `local.alias` | `string` | Yes | Managed alias | Selected runtime alias. |
400
- | `local.variant` | `string` | Yes | Arcane model variant | Selected size. |
401
- | `local.compatibility` | [`ModelResourceAdmission`](#model-resource-admission) | Yes | `admitted:true` | Final native admission. |
402
- | `local.recommendationDegraded` | `boolean` | Yes | - | Automatic selection used a smaller candidate after capacity rejection. |
403
- | `local.candidateFailures` | `array` | Yes | Empty unless an earlier automatic candidate failed | Bounded prior failures. |
404
- | `fallback` | `null` | Yes | - | Arcane did not silently change providers. |
405
- | `loaded` | object | Yes | See below | Managed boot-load result. |
406
- | `operation` | [`ArcaneOperation`](#arcane-operation) | Yes | Completed | Exclusive operation receipt. |
407
-
408
- Each candidate failure is `{variant, kind, code, message, resolution}`. `kind`
409
- is `"capacity"`, `"evidence-unavailable"`, or `"fatal"`; only a capacity
410
- failure allows Automatic mode to try the next smaller candidate.
411
-
412
- `loaded` is a union. Both branches contain `loaded`, `provider`, and `model`.
413
- The successful local branch also contains `keepAlive` and `contextLength`, where
414
- `contextLength:null` means Automatic.
415
-
416
- ### Local AI recovery request
417
-
418
- `Arcane.localAI.recover(request)` accepts an exact `LocalAIRecoveryRequest`.
419
-
420
- | Field | Type | Required | Constraints / default | Description |
421
- |---|---|---:|---|---|
422
- | `services` | `string[]` | Yes | Nonempty, duplicate-free subset of `"ollama"` and `"speech"` | Existing Arcane-managed services to start and verify. |
423
-
424
- ### Local AI recovery result
425
-
426
- | Field | Type | Required | Constraints / default | Description |
427
- |---|---|---:|---|---|
428
- | `ready` | `true` | Yes | Literal | All requested services are ready. |
429
- | `services` | `array` | Yes | Canonical Ollama-then-speech order | Per-service results. |
430
- | `operation` | [`ArcaneOperation`](#arcane-operation) | Yes | Completed | Privileged exclusive operation. |
431
-
432
- Every service result is exact:
433
-
434
- | Field | Type | Required | Constraints / default | Description |
435
- |---|---|---:|---|---|
436
- | `id` | `"ollama" \| "speech"` | Yes | - | Service identifier. |
437
- | `serviceName` | `"ArcaneOllama" \| "ArcaneLocalSpeech"` | Yes | - | Operating-system service name. |
438
- | `endpoint` | `string` | Yes | Fixed `127.0.0.1` health/version endpoint | Verified loopback endpoint. |
439
- | `state` | `"running"` | Yes | Literal | Verified state. |
440
- | `ready` | `true` | Yes | Literal | Readiness proof. |
441
- | `started` | `boolean` | Yes | - | This request issued the start. |
442
-
443
- Recovery starts an existing approved registration. It does not install,
444
- replace, stop, or silently reconfigure a service.
445
-
446
- ### Local AI parallel request configuration
447
-
448
- `Arcane.localAI.setParallelRequests(request)` accepts an exact
449
- `LocalAIParallelRequestsRequest`:
450
-
451
- | Field | Type | Required | Constraints / default | Description |
452
- |---|---|---:|---|---|
453
- | `model` | `string` | Yes | Exact app-owned verified model identifier | Model whose declared definition and native metadata govern the calculation and subsequent load. |
454
- | `parallelRequests` | `integer` | Yes | Nonnegative safe integer | `0` requests the maximum currently allowed; a positive value is a requested ceiling and is clamped down when necessary. |
455
- | `contextTokens` | `integer` | No | Positive safe integer; defaults to verified Modelfile `num_ctx` | Exact per-request context evaluated and used to load the model. The model's native metadata, rather than an Arcane product range, supplies the maximum. |
456
-
457
- A successful `LocalAIParallelRequestsResult` contains:
458
-
459
- | Field | Type | Required | Constraints / default | Description |
460
- |---|---|---:|---|---|
461
- | `schemaVersion` | `1` | Yes | Literal | Result schema. |
462
- | `model` | `string` | Yes | Exact verified alias | Model ensured and loaded. |
463
- | `contextTokens`, `nativeContextTokens` | `integer \| null` | Yes | Positive safe integers when present | Requested context and model-native limit when metadata provides one. |
464
- | `requestedParallelRequests` | `integer` | Yes | Nonnegative safe integer | Caller input. |
465
- | `requestMode` | `"maximum-allowed" \| "requested-ceiling"` | Yes | Derived from input | Interpretation of the request. |
466
- | `previousParallelRequests` | `integer` | Yes | Positive safe integer | Proven setting before the operation. |
467
- | `maxAllowedParallelRequests` | `integer` | Yes | Positive safe integer | Largest count admitted by the resource state used for the effective decision. A changed path uses a fresh stopped-service snapshot. |
468
- | `allowedParallelRequests`, `effectiveParallelRequests` | `integer` | Yes | Positive safe integers; equal | Clamped target and proven effective count used for the load. |
469
- | `requestedAllowed`, `clamped` | `boolean` | Yes | - | Whether a positive request fit without reduction and whether reduction occurred. Auto (`0`) is allowed and is not called clamped. |
470
- | `changed`, `restarted` | `boolean` | Yes | - | Whether the final service setting changed and whether the managed service actually restarted. A resource change observed after stopping can make `restarted:true` and `changed:false`; the receipt reports both facts independently. |
471
- | `healthy`, `loaded` | `true` | Yes | Literal | Post-operation service and model readiness. |
472
- | `loadedModel` | object | Yes | `{name,contextLength}` | Bounded `/api/ps` confirmation; provider-reported `contextLength` may represent runner allocation. |
473
- | `serviceScope` | `"machine"` | Yes | Literal | The Ollama setting is global even though Arcane selected it from one model's evidence. |
474
- | `unloadedModels` | `string[]` | Yes | Bounded pre-restart identifiers | Resident models evicted by the restart; empty on a no-op. |
475
- | `definitionVerified` | `true` | Yes | Literal | Exact alias was verified after any required create/repair. |
476
- | `modelSource` | `"verified-alias" \| "installed-base" \| "registry-preflight"` | Yes | - | Evidence source used for the pre-change capacity calculation. |
477
- | `admission` | [`ModelResourceAdmission`](#model-resource-admission) | Yes | `admitted:true` | Fresh active-setting admission after ensure/repair and before load. |
478
- | `operation` | [`ArcaneOperation`](#arcane-operation) | Yes | Completed | Privileged exclusive operation receipt. |
479
-
480
- Core snapshots one exact model/resource state and solves the maximum directly
481
- from the model metadata's K/V-cache byte ratio and the snapshot's available
482
- working-set bytes. There is no candidate-count search and no Arcane product
483
- ceiling. The largest exact integer representable by the JavaScript/JSON API is a
484
- transport constraint, not a model-capacity claim. The result is a current
485
- memory/resource admission with explicit reserves, not a performance optimum or
486
- a promise of future availability. If the tentative target already equals the
487
- current setting, Core does not stop Ollama. Otherwise the guarded transaction
488
- stops and proves the service, takes one fresh stopped-service resource snapshot,
489
- re-solves the effective count, changes only `OLLAMA_NUM_PARALLEL` when that final
490
- count differs, and starts/proves the service. This unloads every resident Ollama
491
- model and can terminate in-flight local inference.
492
- It then ensures or repairs the exact alias, loads it with the requested context
493
- and indefinite residency, and returns only after `/api/ps` confirms the model.
494
- If loading fails after a setting change, Core attempts to restore the prior count.
495
- The operation does not drain unrelated Core processes or direct loopback clients.
496
- Automatic mutation is currently implemented only by the managed Microsoft NT
497
- adapter. Linux validates the request but returns a `501` manual-systemd error;
498
- Android's user-managed loopback mode does not invoke this desktop Core method.
499
-
500
- ### Arcane operation
501
-
502
- Successful mutating AI methods include `ArcaneOperation`.
503
-
504
- | Field | Type | Required | Constraints / default | Description |
505
- |---|---|---:|---|---|
506
- | `id` | `string` | Yes | UUID | Operation identifier. |
507
- | `type` | `string` | Yes | Method-specific | Operation type. |
508
- | `status` | `string` | Yes | Successful returned operations are `"completed"` | State. |
509
- | `startedAt` | ISO timestamp `string` | Yes | - | Start time. |
510
- | `completedAt` | ISO timestamp `string \| null` | Yes | Present on completion | Completion time. |
511
- | `progress` | `number` | Yes | 0-100; success is 100 | Latest progress. |
512
- | `currentStep` | `string \| null` | Yes | - | Latest visible step. |
513
- | `progressDetails` | `object \| null` | Yes | Operation-specific | Structured progress. |
514
- | `credentials` | `array` | Yes | Normally empty for AI lifecycle work | Host-issued credential artifacts, if any; do not log or persist them. |
515
- | `error` | `object \| null` | Yes | `null` on success | Normalized operation error. |
516
-
517
- ## Speech
518
-
519
- This section documents admitted, capability-gated Core/native speech calls.
520
- For caller-owned browser-local STT/TTS providers, use the separate
521
- [browser speech package](../ai/browser-speech.md). Those browser providers
522
- directly implement the provider-neutral runtime contract. `Arcane.speech`
523
- remains a separate Core/native API unless an application explicitly supplies
524
- an adapter; their transport, artifact authority, capability, and error
525
- boundaries are not interchangeable.
526
-
527
- ### Speech status
528
-
529
- `Arcane.speech.status()` takes no arguments and returns `SpeechStatus`.
530
-
531
- | Field | Type | Required | Constraints / default | Description |
532
- |---|---|---:|---|---|
533
- | `ready` | `boolean` | Yes | `true` only when TTS and STT are ready | Aggregate readiness. |
534
- | `synthesisAvailable` | `boolean` | Yes | Core/native-host field | Independent Kokoro readiness. |
535
- | `transcriptionAvailable` | `boolean` | Yes | Core/native-host field | Independent Whisper readiness. |
536
- | `status` | `string` | Yes | Bounded health identifier | Native service state. |
537
- | `ttsEngine` | `string` | Yes | Health-validated | Text-to-speech engine. |
538
- | `sttEngine` | `string` | Yes | Health-validated | Speech-to-text engine. |
539
-
540
- Unlike `localAI.status()`, this direct call rejects when Core cannot reach and
541
- validate the speech health response.
542
-
543
- ### Speech synthesis request
544
-
545
- `Arcane.speech.synthesize(request)` accepts the portable
546
- `SpeechSynthesisRequest` fields below. Supply the documented primitive types and
547
- lowercase values; do not rely on host-specific coercion or empty-string
548
- defaulting.
549
-
550
- | Field | Type | Required | Constraints / default | Description |
551
- |---|---|---:|---|---|
552
- | `input` | `string` | Yes | Trimmed, nonempty, at most 4,000 characters | Text to synthesize. |
553
- | `model` | `"kokoro"` | No | Default `"kokoro"`; only supported value | Synthesis model. |
554
- | `voice` | `string` | No | Default `"af_heart"`; `[a-z0-9][a-z0-9_-]{0,63}` | Kokoro voice. |
555
- | `responseFormat` | `"opus" \| "wav"` | No | Default `"opus"` | Audio format. |
556
- | `speed` | `number` | No | Default `1`; 0.5-2 inclusive | Speaking speed. |
557
-
558
- ### Speech synthesis result
559
-
560
- | Field | Type | Required | Constraints / default | Description |
561
- |---|---|---:|---|---|
562
- | `audioBase64` | `string` | Yes | Base64 for 1 byte through 6 MiB of audio | Encoded audio. |
563
- | `contentType` | `"audio/ogg" \| "audio/wav"` | Yes | Matches the result encoding | Media type. |
564
-
565
- ### Speech transcription request
566
-
567
- `Arcane.speech.transcribe(request)` accepts an exact
568
- `SpeechTranscriptionRequest`.
569
-
570
- | Field | Type | Required | Constraints / default | Description |
571
- |---|---|---:|---|---|
572
- | `audioBase64` | `string` | Yes | Canonical base64; encoded at most 8 MiB; decoded 1 byte through 6 MiB | Media bytes labeled as WebM. The bridge validates encoding and bounds, while the fixed speech service parses the container. |
573
- | `mimeType` | `string` | No | Default `"audio/webm"`; base type must be `audio/webm` | Media type; codec parameters may follow. |
574
- | `model` | `string` | No | Default `"whisper-small"`; `whisper(?:[._-][a-z0-9]+)*` | Whisper identifier. The fixed service rejects unsupported variants. |
575
-
576
- ### Speech transcription result
577
-
578
- | Field | Type | Required | Constraints / default | Description |
579
- |---|---|---:|---|---|
580
- | `text` | `string` | Yes | Trimmed; response limited to 64 KiB | Transcript. |
581
-
582
- Application-owned inference extensions define their request, callback, proof,
583
- and isolation schemas with the owning package. They are included in the same
584
- developer-reference completeness check but do not become generic Arcane AI
585
- contracts merely because Core transports them.
586
-
587
- ## Direct Ollama API
588
-
589
- Direct Ollama calls are local Core APIs, not provider-neutral contracts. Their
590
- request objects are closed top-level plain objects. Core rejects unknown
591
- top-level fields, non-JSON-compatible values, and encoded requests larger than
592
- 8 MiB. Nested provider-native objects are forwarded for Ollama to validate.
593
-
594
- ### Ollama model name
595
-
596
- Every required `OllamaModelName` matches:
597
-
598
- ```text
599
- [A-Za-z0-9][A-Za-z0-9._:/-]{0,255}
600
- ```
601
-
602
- ### Ollama show options
603
-
604
- `Arcane.ollama.show(model, options)` accepts `OllamaShowOptions`:
605
-
606
- | Field | Type | Required | Constraints / default | Description |
607
- |---|---|---:|---|---|
608
- | `verbose` | `boolean` | No | Provider default | Requests verbose metadata. |
609
-
610
- The wrapper supplies the validated `model` field.
611
-
612
- ### Ollama generate request
613
-
614
- | Field | Type | Required | Constraints / default | Description |
615
- |---|---|---:|---|---|
616
- | `model` | [`OllamaModelName`](#ollama-model-name) | Yes | - | Model to run. |
617
- | `prompt` | `string` | Provider | - | Generation prompt. |
618
- | `suffix` | `string` | No | Provider-native | Text after the generated insertion. |
619
- | `images` | `array` | No | Provider-native base64 values | Multimodal input. |
620
- | `format` | JSON value | No | Text, JSON, or schema format | Output format. |
621
- | `options` | object | No | Provider-native; `num_ctx` is 1,024-262,144 when supplied | Runtime options. |
622
- | `system`, `template` | `string` | No | Provider-native | Prompt controls. |
623
- | `context` | `array` | No | Provider-native | Legacy context tokens. |
624
- | `raw` | `boolean` | No | Provider-native | Raw prompt mode. |
625
- | `keep_alive` | `string \| number` | No | Provider-native | Residency. |
626
- | `think`, `logprobs`, `top_logprobs` | JSON value | No | Provider-native | Reasoning/log-probability controls. |
627
-
628
- See [Ollama's generate API](https://docs.ollama.com/api/generate).
629
-
630
- ### Ollama chat request
631
-
632
- | Field | Type | Required | Constraints / default | Description |
633
- |---|---|---:|---|---|
634
- | `model` | [`OllamaModelName`](#ollama-model-name) | Yes | - | Model to run. |
635
- | `messages` | `array` | Provider | Provider-native records | Conversation. |
636
- | `tools` | `array` | No | Provider-native | Tool definitions. |
637
- | `format` | JSON value | No | Provider-native | Output format or schema. |
638
- | `options` | object | No | Provider-native; `num_ctx` is 1,024-262,144 when supplied | Runtime options. |
639
- | `keep_alive` | `string \| number` | No | Provider-native | Residency. |
640
- | `think`, `logprobs`, `top_logprobs` | JSON value | No | Provider-native | Reasoning/log-probability controls. |
641
-
642
- See [Ollama's chat API](https://docs.ollama.com/api/chat).
643
-
644
- ### Ollama embed request
645
-
646
- | Field | Type | Required | Constraints / default | Description |
647
- |---|---|---:|---|---|
648
- | `model` | [`OllamaModelName`](#ollama-model-name) | Yes | - | Embedding model. |
649
- | `input` | `string \| array` | Provider | Provider-native | Text or batch to embed. |
650
- | `truncate` | `boolean` | No | Provider-native | Allow truncation. |
651
- | `dimensions` | `integer` | No | Provider-native | Embedding dimensions. |
652
- | `keep_alive` | `string \| number` | No | Provider-native | Residency. |
653
- | `options` | object | No | Provider-native; `num_ctx` is 1,024-262,144 when supplied | Runtime options. |
654
-
655
- See [Ollama's embed API](https://docs.ollama.com/api/embed).
656
-
657
- ### Ollama pull options
658
-
659
- `Arcane.ollama.pull(model, options, streamOptions)` accepts:
660
-
661
- | Field | Type | Required | Constraints / default | Description |
662
- |---|---|---:|---|---|
663
- | `insecure` | `boolean` | No | Provider-native | Insecure-registry control. |
664
-
665
- The raw application call always rejects; see
666
- [Raw Ollama management restrictions](#raw-ollama-management-restrictions).
667
-
668
- ### Ollama push options
669
-
670
- `Arcane.ollama.push(model, options, streamOptions)` accepts:
671
-
672
- | Field | Type | Required | Constraints / default | Description |
673
- |---|---|---:|---|---|
674
- | `insecure` | `boolean` | No | Provider-native | Insecure-registry control. |
675
-
676
- Push is allowed only for a model authorized by verified package policy.
677
-
678
- ### Ollama create request
679
-
680
- | Field | Type | Required | Constraints / default | Description |
681
- |---|---|---:|---|---|
682
- | `model` | [`OllamaModelName`](#ollama-model-name) | Yes | - | Alias to create. |
683
- | `from` | [`OllamaModelName`](#ollama-model-name) | Conditional | Required by Arcane's managed verified workflow | Base model. |
684
- | `files`, `adapters` | object | No | Provider-native; forbidden by Arcane's managed path | File/adapter mappings. |
685
- | `template`, `system` | `string` | No | Provider-native | Stored prompt configuration. |
686
- | `license` | `string \| array` | No | Provider-native | License text. |
687
- | `parameters` | object | No | Provider-native | Model parameters. |
688
- | `messages` | `array` | No | Provider-native | Stored messages. |
689
- | `quantize` | `string` | No | Provider-native | Quantization request. |
690
-
691
- Arcane permits creation only when alias, base, SYSTEM text, and parameters
692
- exactly match the package-owned verified definition. Reserved Arcane and
693
- rollback aliases reject. See [Ollama's create API](https://docs.ollama.com/api/create).
694
-
695
- ### Ollama stream controls
696
-
697
- Generate, chat, pull, push, and create accept `OllamaStreamControls` in the
698
- document; these controls are not sent as provider request fields.
699
-
700
- | Field | Type | Required | Constraints / default | Description |
701
- |---|---|---:|---|---|
702
- | `onChunk` | [`OllamaChunkCallback`](#ollama-chunk-callback) | No | - | Receives provider-native chunks. |
703
- | `signal` | `AbortSignal` | No | Genuine signal object | Stops renderer observation and sends a best-effort host cancellation control. Whether host work stops depends on the method. |
704
- | `timeoutMs` | `number` | No | Callers must supply a positive finite number; method default otherwise | Renderer request timeout. The current wrapper coerces this value, so do not depend on acceptance of another type. |
705
-
706
- Callers must not send internal `stream` or `streamId`; the wrapper creates them.
707
-
708
- ### Ollama chunk callback
709
-
710
- An `OllamaChunkCallback` is called as `onChunk(chunk, metadata)`. `chunk` is a
711
- provider-native JSON object. `metadata` is `{operation, streamId}`. A callback
712
- may be passed directly in place of `OllamaStreamControls`.
713
-
714
- ### Ollama provider responses
715
-
716
- Direct Ollama methods return bounded provider-native envelopes. Arcane does not
717
- normalize their nested fields into the provider-neutral entities above. Core
718
- requires valid JSON, caps a response at 12 MiB, parses newline-delimited stream
719
- data, and resolves a stream with its final provider chunk.
720
-
721
- Fields can change with the installed Ollama version. Use the official
722
- [Ollama API reference](https://docs.ollama.com/api/introduction) for the
723
- provider response entities.
724
-
725
- - `version()` returns the version envelope.
726
- - `models()` and `list()` return the tags envelope, not `model[]`.
727
- - `running()` returns the running-model envelope, not `model[]`.
728
- - `show`, `generate`, `chat`, `embed`, `push`, `create`, and `delete` return
729
- their corresponding provider-native envelope.
730
-
731
- ### Raw Ollama management restrictions
732
-
733
- `Arcane.ollama.pull()` and `Arcane.ollama.copy()` always reject and therefore
734
- return `Promise<never>` to an application. A raw pull lacks integrity-bound
735
- pre-download evidence; the managed lifecycle owns registry/GGUF preflight and
736
- native admission. Raw alias copy is reserved to the managed selection workflow.
737
-
738
- `push`, `create`, and `delete` require verified package policy and reject
739
- reserved aliases. Unverified-model mode is inference-only and never pulls,
740
- creates, copies, pushes, deletes, or repairs a model.
741
-
742
- ## Ollama selection and settings
743
-
744
- ### Arcane model preference
745
-
746
- `Arcane.ollama.select(preference)` accepts `ArcaneModelPreference`:
747
-
748
- | Value | Meaning |
749
- |---|---|
750
- | `"auto"` | Try the bounded automatic candidate sequence. |
751
- | `"3b"`, `"8b"`, `"12b"`, `"20b"`, `"120b"` | Explicit managed Arcane model size. |
752
-
753
- The value is a preference enum, not an arbitrary model name.
754
-
755
- ### Arcane model selection
756
-
757
- `Arcane.ollama.selection()` and `settings()` return `ArcaneModelSelection`.
758
-
759
- | Field | Type | Required | Constraints / default | Description |
760
- |---|---|---:|---|---|
761
- | `preference` | [`ArcaneModelPreference`](#arcane-model-preference) | Yes | - | Saved preference. |
762
- | `recommendedVariant`, `effectiveVariant` | `string` | Yes | Managed variants | Recommended and resolved sizes. |
763
- | `model`, `alias` | `string` | Yes | - | Variant model and stable managed alias. |
764
- | `activeVariant` | `string \| null` | Yes | Managed variant | Persisted active state. |
765
- | `defaultModel` | [`OllamaModelName`](#ollama-model-name) | Yes | - | Default inference model. |
766
- | `bootLoad` | `boolean` | Yes | - | Load during managed startup. |
767
- | `bootKeepAlive` | `"5m" \| "30m" \| "1h" \| "24h" \| "-1"` | Yes | - | Boot residency. |
768
- | `contextLength` | `integer` | Yes | `0` or 1,024-262,144; `0` is Automatic | Saved context. |
769
- | `provider` | `"ollama" \| "openai"` | Yes | - | Saved provider. |
770
- | `openAIModel` | `string` | Yes | - | Saved OpenAI model. |
771
- | `responseLength` | `"low" \| "medium" \| "high"` | Yes | - | Response target. |
772
- | `openAIConfigured` | `boolean` | Yes | - | Protected credential exists. |
773
- | `gpu` | object | Yes | Bounded diagnostic snapshot | Accelerator evidence. |
774
- | `recommendationPending` | `boolean` | Yes | - | Automatic selection awaits persisted admission. |
775
-
776
- `gpu` contains `devices` (at most 16 `{name, memoryBytes}` records),
777
- `totalMemoryBytes`, `largestMemoryBytes`, `memoryReliable`, and `source`.
778
-
779
- ### Arcane model selection result
780
-
781
- A successful `select()` returns `ArcaneModelSelectionResult` plus
782
- [`ArcaneOperation`](#arcane-operation).
783
-
784
- | Field | Type | Required | Constraints / default | Description |
785
- |---|---|---:|---|---|
786
- | `model`, `alias`, `variant`, `preference`, `recommendedVariant` | `string` | Yes | Managed values | Selected model identity. |
787
- | `created`, `aliasChanged` | `boolean` | Yes | - | Mutation effects. |
788
- | `baseModel` | `string` | Yes | - | Verified base. |
789
- | `modelsRoot` | `string \| null` | Yes | Host path | Model store. |
790
- | `gpu`, `evidence` | object | Yes | Bounded diagnostics | Native and definition evidence. |
791
- | `compatibility` | [`ModelResourceAdmission`](#model-resource-admission) | Yes | `admitted:true` | Final admission. |
792
- | `recommendationDegraded` | `boolean` | No | Automatic only | Smaller capacity candidate selected. |
793
- | `candidateFailures` | `array` | No | Automatic only | Earlier bounded failures. |
794
- | `rollbackSnapshotRetained` | `boolean` | Yes | - | A recovery snapshot remains because cleanup could not be proven. |
795
- | `recoveryAlias` | `string \| null` | Yes | Reserved alias when retained | Alias an administrator can use for recovery. |
796
- | `operation` | [`ArcaneOperation`](#arcane-operation) | Yes | Completed | Selection operation. |
797
-
798
- ### Arcane AI settings input
799
-
800
- `Arcane.ollama.saveSettings(settings)` reads only runtime-owned fields. Unknown
801
- keys, including stale provider/model preference fields from an old screen, are
802
- ignored so they cannot overwrite newer provider selection.
803
-
804
- | Field | Type | Required | Constraints / default | Description |
805
- |---|---|---:|---|---|
806
- | `defaultModel` | [`OllamaModelName`](#ollama-model-name) | No | Current value | Default runtime model. |
807
- | `bootLoad` | `boolean` | No | Current value | Load at managed startup. |
808
- | `bootKeepAlive` | `"5m" \| "30m" \| "1h" \| "24h" \| "-1"` | No | Current value | Boot residency. |
809
- | `contextLength` | `integer` | No | `0` or 1,024-262,144 | Runtime context; `0` is Automatic. |
810
-
811
- Use `select()` for the managed size preference and
812
- `saveProviderSettings()` for provider, OpenAI model, credential, and response
813
- length.
814
-
815
- ### Arcane AI settings result
816
-
817
- A successful settings save returns `ArcaneAISettingsResult`: the complete
818
- [`ArcaneModelSelection`](#arcane-model-selection) snapshot after the mutation,
819
- plus `operation` as an [`ArcaneOperation`](#arcane-operation). It does not return
820
- the selection-only mutation fields such as `created`, `baseModel`, or
821
- `aliasChanged`.
822
-
823
- ### Arcane brain definition
824
-
825
- `Arcane.ollama.createBrain(definition)` reads `ArcaneBrainDefinition`; unknown
826
- keys are currently ignored and should not be sent.
827
-
828
- | Field | Type | Required | Constraints / default | Description |
829
- |---|---|---:|---|---|
830
- | `baseModel` | [`OllamaModelName`](#ollama-model-name) | Yes | - | Base model. |
831
- | `name` | `string` | No | Default `"my-brain"`; normalized to a 1-64 character slug | Brain name. |
832
- | `contextLength` | `integer` | No | `0` for inherited/automatic; use 1,024-262,144 explicitly | Requested context. |
833
- | `makeDefault` | `boolean` | No | Default `false` | Make the created model the default. |
834
-
835
- ### Arcane brain result
836
-
837
- | Field | Type | Required | Constraints / default | Description |
838
- |---|---|---:|---|---|
839
- | `model` | `string` | Yes | `arcane-<slug>:latest` | Created model. |
840
- | `baseModel` | `string` | Yes | - | Base model. |
841
- | `defaultModel` | `boolean` | Yes | - | Became the default. |
842
- | `operation` | [`ArcaneOperation`](#arcane-operation) | Yes | Completed | Creation operation. |
843
-
844
- ### Ollama service settings state
845
-
846
- `Arcane.ollama.serviceSettings()` returns a platform-dependent native state.
847
- Microsoft NT reports effective settings and support state. Callers must
848
- feature-detect platform-specific fields rather than assume one cross-platform
849
- exact object.
850
-
851
- ### Ollama service settings input
852
-
853
- `Arcane.ollama.saveServiceSettings(settings)` applies defaults to omitted fields;
854
- send the complete desired `OllamaServiceSettingsInput`. Unknown keys are
855
- currently ignored and should not be sent.
856
-
857
- | Field | Type | Required | Constraints / default | Description |
858
- |---|---|---:|---|---|
859
- | `contextLength` | `integer` | No | Default `0`; 0-262,144 | Service context. |
860
- | `keepAlive` | `string` | No | Default `"5m"`; `"-1"`, `"0"`, or 1-9,999 plus `m`/`h` | Residency. |
861
- | `maxLoadedModels` | `integer` | No | Default `1`; 0-16 | Loaded-model limit. |
862
- | `numParallel` | `integer` | No | Default `1`; 1-16 | Parallel requests. |
863
- | `maxQueue` | `integer` | No | Default `512`; 1-4,096 | Queue limit. |
864
- | `flashAttention` | `boolean` | No | Default `false` | Flash attention. |
865
- | `kvCacheType` | `"f16" \| "q8_0" \| "q4_0"` | No | Default `"f16"` | K/V-cache format. |
866
- | `noCloud` | `boolean` | No | Default `true` | Prevent Ollama cloud behavior. |
867
-
868
- ### Ollama service settings result
869
-
870
- A successful save returns the platform result plus
871
- [`ArcaneOperation`](#arcane-operation). Microsoft NT currently reports requested
872
- and effective settings, support/clamping detail, restart state, and post-change
873
- health. Require `healthy === true` where that field exists.
874
-
875
- ## Errors and capability boundaries
876
-
877
- | Method group | Required authority | Additional restriction |
878
- |---|---|---|
879
- | Provider-neutral chat/profile and local status | `ai.inference` | Configured provider; local status is served by desktop Core or an explicitly admitted Android `user-managed-loopback` host, distinguished by `providerMode` and runtime fields. |
880
- | Raw local inventory | `ai.models.read` | Settings, Shell, and Terminal diagnostics. |
881
- | Provider settings/OpenAI model catalog | `ai.settings.manage` | Settings only. |
882
- | `localAI.ensurePlatform()` | `provisioning.manage` | Provisioner type; exclusive. |
883
- | `localAI.recover()` | `ai.inference` | Approved recovery apps; privileged and exclusive. |
884
- | `localAI.setParallelRequests()` | `ai.runtime.manage` | Sole registered grantee; desktop Core only; privileged and exclusive. |
885
- | Speech | `ai.inference` | Requires local speech host. |
886
- | Raw Ollama reads | `ai.models.read` | Diagnostic apps only. |
887
- | Raw Ollama inference | `ai.inference` | Exact model is re-admitted. |
888
- | Ollama mutations | `ai.models.manage` | Verified package policy; raw pull/copy reject. |
889
- | Runtime/provider/service settings | `ai.settings.manage` | Settings restrictions; service mutation is privileged/exclusive. |
890
-
891
- Additional invariants:
892
-
893
- - Raw inventory must not populate an application model selector. Use the
894
- admitted `Arcane.localAI.status().models.ollama` catalog.
895
- - Browser runtimes gain no local Ollama authority from the shared API
896
- vocabulary. Android exposes only its explicitly admitted projection (currently
897
- `ollama.chat()` for approved applications), not desktop lifecycle or model
898
- mutation authority.
899
- - Unverified installed-model inference additionally requires
900
- `ai.models.unverified.inference` and remains inference-only.
901
- - Arcane never silently changes from Ollama to OpenAI after local discovery or
902
- admission failure.
903
- - Provider credentials are never returned to renderers.
904
- - Status, admission, progress, registry evidence, and model records are
905
- observations, not grants or reusable authorization.
906
- - Core rechecks current package policy, model identity, and resources at the
907
- operation boundary.