arcane-os 0.57.0 → 0.58.0

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 (58) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +6 -2
  3. package/browser-runtime/ai/core-onnx.mjs +96 -0
  4. package/browser-runtime/ai/onnx-tensors.mjs +85 -0
  5. package/browser-runtime/core/client.mjs +151 -16
  6. package/docs/architecture.md +5 -2
  7. package/docs/platform-targets.md +30 -13
  8. package/docs/reference/README.md +18 -3
  9. package/docs/reference/availability-and-normalization.md +9 -6
  10. package/docs/reference/cli.md +22 -10
  11. package/docs/reference/core-client.md +80 -0
  12. package/docs/reference/core-native-packaging.md +110 -2
  13. package/docs/reference/core-preferences.md +49 -0
  14. package/docs/reference/diarization.md +206 -0
  15. package/docs/reference/git-text-snapshot.md +104 -0
  16. package/docs/reference/inventory/package-api.json +203 -21
  17. package/docs/reference/local-ai.md +145 -11
  18. package/docs/reference/protocols.md +28 -19
  19. package/docs/reference/pwa.md +5 -2
  20. package/docs/reference/sdk-api.md +448 -39
  21. package/package.json +11 -3
  22. package/schemas/arcane-app.schema.json +3 -3
  23. package/schemas/arcane-package.schema.json +2 -2
  24. package/schemas/native-build-plan.schema.json +27 -1
  25. package/schemas/target-adapter.schema.json +2 -0
  26. package/src/app-descriptor.mjs +1 -1
  27. package/src/cli/main.mjs +14 -4
  28. package/src/constants.mjs +2 -0
  29. package/src/core/hosts/macos/ArcaneHost.h +86 -0
  30. package/src/core/hosts/macos/ArcaneHost.m +455 -0
  31. package/src/core/hosts/macos/ArcaneLauncher.m +432 -0
  32. package/src/core/services/local-ai.mjs +82 -4
  33. package/src/core/services/packaged-web.mjs +89 -0
  34. package/src/core/services/preferences.mjs +201 -0
  35. package/src/core-classic-source.mjs +2 -2
  36. package/src/dev-server.mjs +2 -5
  37. package/src/diarization/build.mjs +35 -0
  38. package/src/diarization/index.mjs +432 -0
  39. package/src/diarization/native/CMakeLists.txt +9 -0
  40. package/src/diarization/native/main.cpp +269 -0
  41. package/src/diarization/service.mjs +129 -0
  42. package/src/git-text-snapshot.mjs +265 -0
  43. package/src/import-map.mjs +1 -0
  44. package/src/index.mjs +1 -0
  45. package/src/local-ai/config.mjs +1 -1
  46. package/src/local-ai/install.mjs +134 -19
  47. package/src/local-ai/onnx-worker.mjs +85 -0
  48. package/src/local-ai/onnx.mjs +368 -0
  49. package/src/native/macos-provider.mjs +291 -0
  50. package/src/native/portable-layout.mjs +10 -2
  51. package/src/native/portable-provider.mjs +10 -5
  52. package/src/native-plan.mjs +9 -1
  53. package/src/native-provider-loader.mjs +3 -1
  54. package/src/process.mjs +123 -17
  55. package/src/scaffold.mjs +1 -1
  56. package/src/targets/index.mjs +11 -1
  57. package/src/templates/workspace-template.mjs +6 -5
  58. package/src/toolchain.mjs +1 -1
@@ -1,13 +1,13 @@
1
1
  # Local AI through Core
2
2
 
3
- Core owns native llama.cpp and Ollama processes. The browser retains its own
3
+ Core owns native llama.cpp and Ollama processes and ONNX worker sessions. The browser retains its own
4
4
  Wllama and ONNX implementations, and can also use an explicitly connected Core
5
5
  when that system service is available. Runtime installation, model loading and
6
6
  inference are separate operations.
7
7
 
8
- This native service currently implements llama.cpp and Ollama. Native ONNX
9
- inference remains separate unfinished work. Browser ONNX continues through its
10
- existing browser implementation.
8
+ Native ONNX runs caller-selected graphs with complete named input/output tensors.
9
+ Applications own preprocessing, tokenization and model-specific pipelines.
10
+ Browser ONNX continues through its existing browser implementation.
11
11
 
12
12
  ## Application requirements
13
13
 
@@ -19,7 +19,8 @@ Existing native fields remain alongside this record:
19
19
  {
20
20
  "runtimes": [
21
21
  {"id": "llama.cpp"},
22
- {"id": "ollama"}
22
+ {"id": "ollama"},
23
+ {"id": "onnx"}
23
24
  ],
24
25
  "llamaCpp": {
25
26
  "modelsDirectory": "models/llama"
@@ -31,7 +32,8 @@ Existing native fields remain alongside this record:
31
32
  ```
32
33
 
33
34
  Each runtime requirement accepts `id`, optional upstream `version`, and an
34
- optional runtime archive `url`. A string runtime ID is also accepted.
35
+ optional runtime archive `url`. ONNX resolves its official npm package or an
36
+ explicitly supplied package archive. A string runtime ID is also accepted.
35
37
  Omitting the version allows reuse of an available runtime. Explicit versions
36
38
  select that upstream distribution; an existing service must match the requested
37
39
  version before it is reused. A service occupying the selected address is
@@ -48,7 +50,7 @@ application. Applications choose and provision their models explicitly.
48
50
  ## Development
49
51
 
50
52
  ```sh
51
- arcane dev --local-ai llama.cpp,ollama
53
+ arcane dev --local-ai llama.cpp,ollama,onnx
52
54
  ```
53
55
 
54
56
  The option adds those runtime requirements to the authored application
@@ -64,6 +66,13 @@ service or machine environment. Windows and macOS use the host archive utility;
64
66
  Linux requires `tar`, and `unzip` when extracting a selected Windows ZIP.
65
67
  Zstandard archives use the supported Node runtime's decompressor.
66
68
 
69
+ Selected ONNX preparation installs `onnxruntime-node@1.30.0` by default into a
70
+ managed npm prefix, retaining its complete published runtime dependency tree.
71
+ It uses the upstream CPU installation option to skip supplementary GPU downloads.
72
+ Node/npm must be available while preparing that runtime; a native app consumes
73
+ the bundled tree without installing it again. Applications that omit ONNX do
74
+ not install its package.
75
+
67
76
  For the optional development browser connection, load the bootstrap after the
68
77
  managed import map and before creating a Core-backed provider:
69
78
 
@@ -111,6 +120,9 @@ service and a loaded model are separate facts.
111
120
  `localai.services.recover({runtimes: ['llama.cpp']})` makes one explicit recovery
112
121
  attempt for the selected runtimes; omission selects all configured runtimes.
113
122
  Recovery restarts only SDK-owned processes and reconnects to external services.
123
+ Recovering ONNX releases its sessions; explicitly load models again afterward.
124
+ Its state is `recovering` and unavailable until the previous workers exit and
125
+ the new session owner is ready.
114
126
  An external llama.cpp server returns HTTP 503 during initial model loading and
115
127
  offers no readiness subscription at that stage. Core retains `state: 'loading'`;
116
128
  a subsequent explicit load or recovery request checks again. There is no
@@ -175,6 +187,106 @@ silently change the application's saved model choice. Release registration
175
187
  with `unregister()` and dispose the provider at the application's owning
176
188
  lifecycle boundary.
177
189
 
190
+ ## Native ONNX sessions
191
+
192
+ ```js
193
+ import {ensureLocalAIRuntimes} from 'arcane-os/local-ai';
194
+ import {createONNXRuntime} from 'arcane-os/local-ai/onnx';
195
+
196
+ const [runtime] = await ensureLocalAIRuntimes({
197
+ runtimes: ['onnx'], directory: '.arcane/local-ai/runtimes'
198
+ });
199
+ const onnx = createONNXRuntime({modulePath: runtime.modulePath});
200
+ try {
201
+ const loaded = await onnx.load({id: 'cheese-radar', model: absoluteModelPath});
202
+ // Supply the actual names, shapes and values expected by this graph.
203
+ const outputs = await onnx.run({id: loaded.id, feeds});
204
+ console.log(outputs);
205
+ } finally {
206
+ await onnx.close();
207
+ }
208
+ ```
209
+
210
+ The factory accepts `{modulePath,signal?,onEvent?}` and starts no worker until
211
+ `load({id,model,sessionOptions?,signal?})`. The model path is absolute for this
212
+ direct Node API. Session creation defaults to the CPU execution provider;
213
+ explicit native session options remain caller-owned. The returned session
214
+ record contains `id`, `model`, `state`, `loaded`, `error`, input/output names and
215
+ metadata. A live ID requires explicit unload before replacement. An ID may be
216
+ loaded again once its previous worker exits after a failed load or unload.
217
+ A run error retains the loaded session so a corrected request can use it.
218
+
219
+ `run({id,feeds,fetches?,runOptions?,signal?})` returns the complete output-name
220
+ map of `{type,dims,data}` tensors. Input records use that same shape with native
221
+ typed data or string arrays. Optional `fetches` selects output names or supplies
222
+ output tensors using the upstream API. Worker transport copies supplied tensor
223
+ data; returned output records contain the results, and caller-owned preallocated
224
+ buffers are not mutated in place. Each session retains its own worker and
225
+ loaded graph; work for independent sessions proceeds concurrently. Runs for one
226
+ session execute in order and wait at that session's loading boundary. There is
227
+ no token streaming in the generic tensor operation.
228
+
229
+ String input containing U+0000 reports an incompatibility at the native tensor
230
+ boundary: the Node binding uses null-terminated strings and cannot preserve
231
+ that input completely. The SDK does not alter the supplied string.
232
+
233
+ `current()` returns `{sessions,closed}`. `subscribe(listener)` replays current
234
+ state synchronously and returns an unsubscribe function. Load, readiness,
235
+ unload and failures remain observable. `unload({id,signal?})` releases that
236
+ session; `close()` owns all remaining workers and awaits their actual exits.
237
+
238
+ Cancelling a queued run removes that run. Cancelling active native work stops
239
+ delivery and retires its worker; the session becomes unavailable until loaded
240
+ again. ONNX Runtime's Node binding offers no native inference interruption:
241
+ worker termination can wait for a native call to return. Shutdown observes the
242
+ actual exit and does not claim that rejecting a request stopped native work.
243
+ Other sessions retain their own lifetimes.
244
+
245
+ ### ONNX through Core and the browser
246
+
247
+ | Core method | Parameters | Result |
248
+ | --- | --- | --- |
249
+ | `onnx.status` | `{}` | Runtime availability and current `models` session records |
250
+ | `onnx.load` | `{id,model,sessionOptions?}` | Loaded session; relative model paths resolve from `appRoot` |
251
+ | `onnx.run` | `{id,feeds,fetches?,runOptions?}` | Complete encoded tensor output map |
252
+ | `onnx.unload` | `{id}` | Released session record |
253
+
254
+ Use the browser accessor to handle the Core tensor transport:
255
+
256
+ ```js
257
+ import {createCoreONNXRuntime} from 'arcane-os/ai/core-onnx';
258
+
259
+ const onnx = createCoreONNXRuntime({client});
260
+ const stop = onnx.subscribe(function showRuntime(state) { console.log(state); });
261
+ await onnx.inspect();
262
+ await onnx.load({id: 'cheese-radar', model: 'models/cheese-radar.onnx'});
263
+ const outputs = await onnx.run({id: 'cheese-radar', feeds});
264
+ await onnx.unload({id: 'cheese-radar'});
265
+ stop();
266
+ onnx.close();
267
+ ```
268
+
269
+ The accessor exposes `load`, `run`, `unload`, `inspect`, `current`, `subscribe`
270
+ and `close`. Request methods accept `signal` and optional `timeoutMs` (default
271
+ `0`, no elapsed-time cutoff). It preserves full typed tensor values, including
272
+ 64-bit integers, floating-point special values and strings, through the
273
+ transport codec. `current()` adds `busy` and `closed` to its latest Core state.
274
+ Closing the accessor cancels its requests and subscriptions; model unloading
275
+ is explicit because other accessors may share the Core session. It never
276
+ closes the shared Core client.
277
+
278
+ Construction neither opens a connection nor installs a runtime. A browser needs
279
+ an already available native Core service or the explicit development bridge.
280
+ Unavailable native ONNX leaves browser ONNX/Wllama under the application's
281
+ existing selection. This tensor API does not select an LLM, tokenizer, speech,
282
+ image or avatar pipeline.
283
+
284
+ Native ONNX CPU package targets are Windows, Linux and macOS on `x64`/`arm64`,
285
+ as listed in Microsoft's [Node binding platform matrix](https://github.com/microsoft/onnxruntime/blob/v1.30.0/js/node/README.md).
286
+ Android needs its host's native ONNX adapter; the Node package contains no
287
+ Android binding. Platform support here describes upstream package targets,
288
+ not execution evidence on each platform.
289
+
178
290
  ## Native bundling
179
291
 
180
292
  The SDK portable native build includes selected official runtime trees under
@@ -191,7 +303,29 @@ Architectures are `x64` or `arm64`. Availability depends on the upstream
191
303
  runtime's published platform assets; Ollama has no official Android runtime
192
304
  archive in this installer.
193
305
 
194
- Ensure returns absolute `{id,version,platform,architecture,root,executable}`
195
- records. Bundle returns `{runtimes,files}`, with artifact-relative runtime paths
196
- and a complete emitted file inventory. Bundling requires a fresh native staging
197
- destination, preserving existing completed outputs.
306
+ Ensure returns absolute `{id,version,platform,architecture,root}` records.
307
+ Server runtimes also include `executable`; ONNX includes `modulePath` pointing
308
+ to its public package entry. Bundle returns `{runtimes,files}`,
309
+ with artifact-relative runtime paths and a complete emitted file inventory.
310
+ Bundling requires a fresh native staging destination, preserving existing
311
+ completed outputs.
312
+
313
+ ### NeMo Speech library runtime
314
+
315
+ The runtime helpers also accept `{id: 'nemo-speech', version: '0.2.0'}` to
316
+ prepare NVIDIA's official CPU library distribution. An omitted NeMo version
317
+ selects `0.2.0`. Its published targets are Windows `x64`, Linux `x64`/`arm64`,
318
+ and macOS `x64`/`arm64`.
319
+
320
+ NeMo records include `includeDirectory`, `libraryDirectory`, `binaryDirectory`,
321
+ and `cmakeDirectory`; they have no server `executable`. The complete upstream
322
+ tree remains under `root`, including any archive prefix directory. Use the
323
+ returned `cmakeDirectory` as `NeMoSpeech_DIR` when calling
324
+ `find_package(NeMoSpeech CONFIG REQUIRED COMPONENTS Diarization)`, then link
325
+ the upstream `NeMoSpeech::Diarization` target. Bundling preserves the complete
326
+ tree and makes all these paths relative to the native artifact root.
327
+
328
+ This helper installs the library. The application configuration and development
329
+ CLI select llama.cpp, Ollama and ONNX services described above;
330
+ NeMo model selection and a native diarization helper belong to their owning
331
+ integration.
@@ -47,12 +47,14 @@ These protocols normalize orchestration and results. They do not normalize a
47
47
  Windows EXE, Linux DEB, Android APK, and portable directory into the same
48
48
  artifact kind.
49
49
 
50
- Portable CLI operations load the installed SDK's
51
- `arcane-os/native/portable-provider` by default. Explicit `--arcane-root`
52
- selection retains the checkout provider route; executable targets still need
53
- their platform provider/toolchain. `arcane-os/core/host` composes the reusable
54
- native runtime with explicitly supplied app services. Neither export is a
55
- browser import, executable host or installer. The synchronous classic facade
50
+ Portable CLI operations load `arcane-os/native/portable-provider`; Windows x64
51
+ loads `arcane-os/native/windows-provider`, both from the installed SDK by
52
+ default. The Windows provider assembles the matching precompiled WebView2/SEA
53
+ host release asset. Explicit `--arcane-root` selection retains the checkout
54
+ route; Linux and Android still need their platform provider/toolchain.
55
+ `arcane-os/core/host` composes the reusable native runtime with explicitly
56
+ supplied app services. These Node entries remain separate from browser imports;
57
+ portable itself remains a non-executable payload. The synchronous classic facade
56
58
  and browser-safe client retain their separate public entries. Integrated
57
59
  shared checks keep their existing Arcane OS development provider.
58
60
 
@@ -1047,10 +1049,15 @@ or a dependency is ready.
1047
1049
 
1048
1050
  ### Microsoft NT / WebView2
1049
1051
 
1050
- The renderer uses the WebView2 host messaging surface. The host binds one app
1051
- identity and native policy to the session before Core dispatch. Microsoft NT
1052
- can expose managed-service and privileged platform operations that do not exist
1053
- in an ordinary browser.
1052
+ The SDK Windows host mounts the selected app at a virtual HTTPS origin and
1053
+ injects the canonical classic facade before application scripts. Ordered
1054
+ `arcane/1` requests and complete responses cross its owned WebView2/Core bridge;
1055
+ each connected document requests authoritative runtime/service replay. Its
1056
+ selected service composition supplies the actual methods. Closing the window
1057
+ cancels renderer requests and drains accepted service work before Core exits.
1058
+ See [Windows executable packaging](core-native-packaging.md#windows-executable).
1059
+ Arcane OS can separately compose product policy and privileged services; the
1060
+ generic SDK host does not copy that product composition.
1054
1061
 
1055
1062
  ### Linux / WebKitGTK
1056
1063
 
@@ -1070,12 +1077,13 @@ reachable.
1070
1077
 
1071
1078
  ### macOS
1072
1079
 
1073
- No macOS executable target, native bridge, platform host, artifact, or run
1074
- contract is exposed by this SDK version. A browser may still run browser-only
1075
- application code. A separately composed macOS host may use the reusable Node
1076
- Core runtime, framed stdio transport, host composition, and portable payload,
1077
- but those SDK primitives do not create a native bridge or executable host and
1078
- do not by themselves satisfy a native capability.
1080
+ This version includes Foundation-only `ArcaneCoreProcess` source for an
1081
+ explicit executable, framed pipes and graceful child lifecycle. It supplies no
1082
+ macOS renderer bridge, executable target, artifact or run command. A separately
1083
+ composed macOS host may combine that source with the reusable Node runtime,
1084
+ stdio transport, host composition and portable payload. Source delivery does
1085
+ not establish compilation or execution on macOS. See
1086
+ [the macOS process-source contract](core-native-packaging.md#macos-process-source).
1079
1087
 
1080
1088
  ## Development and remote HTTP transport
1081
1089
 
@@ -1159,9 +1167,10 @@ The common contract ends where platform truth must remain different:
1159
1167
  not run an unrelated browser implementation as a substitute;
1160
1168
  - the portable target defaults to the installed SDK provider and assembles a
1161
1169
  non-executable payload without an Arcane OS checkout;
1162
- - executable native targets require their explicit checkout/provider, and the
1163
- composed host must supply the protocol, version, features, capabilities,
1164
- methods, and services that its application contract requires;
1170
+ - Windows x64 defaults to the installed SDK's matching precompiled host;
1171
+ Linux/Android retain explicit checkout/providers. Every composed host must
1172
+ supply the protocol, version, features, capabilities, methods and services
1173
+ that its application contract requires;
1165
1174
  - that current-build compatibility does not promise that a future SDK will accept
1166
1175
  this Core or that this SDK will accept a future Core.
1167
1176
 
@@ -261,11 +261,14 @@ origin root and starts at the selected app entry: `/index.html` for a standalone
261
261
  root app with that entry, or `/apps/<id>/<entry>` for a nested app. Use one
262
262
  selected app per development origin. The SDK uses `node-http-server` for source
263
263
  and packaged-preview serving, including conditional resource responses.
264
- Arcane development servers default to HTTPS, including localhost, and packaged
265
- browser previews require HTTPS. Configure the workspace certificate pair before
264
+ Arcane development servers and packaged browser previews default to HTTPS,
265
+ including localhost. Configure the workspace certificate pair before
266
266
  starting the ordinary command; see [development HTTPS setup](cli.md#development-https-setup).
267
267
  Explicit source-only `arcane dev --http` serves the same generated PWA routes
268
268
  without loading certificates; see [explicit HTTP development](cli.md#explicit-http-development).
269
+ API callers may select `http:true` in packaged mode to serve the existing
270
+ packaged web root, without generating or changing its PWA files. Browser
271
+ secure-context and installation requirements remain browser-owned.
269
272
  `--public` selects the IPv4 wildcard bind address; it does not enable PWA
270
273
  configuration, change manifest metadata, or determine browser installability.
271
274