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
@@ -58,12 +58,12 @@ false when a probe throws; SDK branching continues through its owning error path
58
58
  policy, package-owned model policy, platform support, and dependency readiness
59
59
  are independent checks.
60
60
 
61
- The current executable host/target matrix covers Microsoft NT, Linux, and
62
- Android where listed. This SDK exposes no macOS executable target, native
63
- bridge, artifact, or run contract; WebKitGTK availability must not be
64
- generalized to macOS. The reusable Node Core runtime, framed stdio transport,
65
- host composition, and portable payload can be used by a separately composed
66
- macOS host, but they do not supply that native platform host or bridge.
61
+ Windows x64 has an SDK-owned precompiled WebView2/SEA host; Linux and Android
62
+ retain their explicit checkout providers where listed. The SDK also includes
63
+ macOS Foundation process-adapter source, separately from an executable target,
64
+ renderer bridge, artifact or run command. A composed macOS host may combine that
65
+ source with the reusable Node Core runtime, stdio transport and portable payload.
66
+ Source availability does not establish macOS compilation or execution.
67
67
 
68
68
  ## Capability-first matrix
69
69
 
@@ -89,6 +89,9 @@ macOS host, but they do not supply that native platform host or bridge.
89
89
  | Connect browser code to an existing Core transport | `arcane-os/core/client` and `arcane-os/core/contracts` | **Browser / native WebView** with an admitted transport; explicit development HTTP remains opt-in | The reusable client owns `arcane/1` correlation, readiness, cancellation, events, facades, and complete native error fidelity. It supplies no service, policy, or host process. |
90
90
  | Compose native Core services and framed stdio hosting | `arcane-os/core/runtime`, `arcane-os/core/stdio`, and `arcane-os/core/host` | **Node** on Windows, Linux, or macOS; the composing native host supplies its process and bridge | The SDK owns reusable dispatch, per-service lifecycle, request/service work ownership, cooperative cancellation, drain, and stdio framing. Product identity, policy, privileges, models, storage, and services remain host-owned. |
91
91
  | Assemble a portable Core payload from the installed SDK | `arcane-os/native/portable-provider` | **Node**; portable platform selection is currently Windows or Linux, while separately composed hosts may use the payload | The provider copies the selected app, dependencies, installed SDK runtime, Core client/runtime, and explicit service composition into a non-executable directory. It uses no `arcaneRoot` by default and does not prove host behavior or supply a platform bridge. |
92
+ | Assemble and run a Windows executable | [`arcane-os/native/windows-provider`](core-native-packaging.md#windows-executable) | **Node** for assembly; Windows x64, .NET Framework 4.6.2+ and WebView2 for execution | Uses the installed SDK version's precompiled release asset and explicit app services. Complete diagnostics and accepted service work drain on run cancellation; no OS checkout or application-side native compiler is required. |
93
+ | Use application-selected llama.cpp/Ollama through Core | [`arcane-os/core/local-ai`, `arcane-os/ai/core-local`](local-ai.md) | **Node** native service; **Browser / native WebView** provider through an explicit Core connection | Independent runtime/model lifecycle, complete streaming and cancellation. Official runtime preparation follows explicit app requirements; model selection and business policy stay app-owned. |
94
+ | Run native ONNX tensors | [`arcane-os/local-ai/onnx`, `arcane-os/ai/core-onnx`](local-ai.md#native-onnx-sessions) | **Node** Windows/Linux/macOS x64/arm64; **Browser / native WebView** through available Core | Explicit graph loading, retained workers and complete tensor outputs. Android requires host adaptation. Native calls can delay worker termination; cleanup observes actual exit. |
92
95
  | Use local AI without coupling app code to Ollama HTTP | `Arcane.localAI`, `Arcane.ai`, or `/arcane/modules/Ollama.js` | Primarily **Native**; Android exposes a narrower admitted inference projection | Admission, errors, and managed-operation events are normalized. Direct Ollama response envelopes remain **Provider-native**. |
93
96
  | Use TWiN Cloud from the renderer profile | `/arcane/modules/AI.js` | **Cloud** from an allowed browser/native renderer | High-level chat behavior is normalized by the module. The TWiN access key authenticates remote LLM chat; raw provider diagnostics remain provider-specific. No automatic cloud fallback is inferred from local failure. |
94
97
  | Send one TWiN Cloud request with an explicit key and model | `fetchRequest` from `arcane-os/ai/twin-cloud` | **Node** and **Browser**, using standard Fetch and a remote HTTPS provider | Keeps complete messages and returns the full parsed provider JSON. Rejected Fetch and HTTP 529 share three retries after 3000 ms; HTTP 429 overload retains unlimited three-second retries. Optional `onRetry` reports waiting/requesting phases without blocking recovery. Shared structured-output mapping and cancellation match browser TWiN transport. No browser profile, AI/user singleton, DBOPFS, or retained request history is created. |
@@ -49,7 +49,7 @@ meaning and cardinality rules:
49
49
  | `--app` | app id or label | Workspace/app operations except shared scope and `verify-bundle`; optional diagnostic label for `mail serve`. |
50
50
  | `--apps-root` | `.` or `apps` | `new`, `init`; standalone setup defaults to the repository root. |
51
51
  | `--sdk-runtime-source` | SDK checkout directory | `dev` only; maps live SDK source through the selected browser destinations for that server process. |
52
- | `--local-ai` | comma-separated runtime IDs | `dev` only; adds `llama.cpp` and/or `ollama` requirements to application configuration and prepares missing runtimes alongside serving. See [local AI through Core](local-ai.md). |
52
+ | `--local-ai` | comma-separated runtime IDs | `dev` only; adds `llama.cpp`, `ollama` and/or `onnx` requirements to application configuration and prepares missing runtimes alongside serving. See [local AI through Core](local-ai.md). |
53
53
  | `--arcane-root` | directory | `doctor`, native `build`/`run`, `native-doctor`, `native-prepare` |
54
54
  | `--host` / `--port` | host / integer 0–65535 | Browser `dev`/`run` default to HTTPS at `127.0.0.1:8000`; `mail serve` defaults to HTTPS with HTTP/2 at `0.0.0.0:4433` and accepts an explicit bind host. |
55
55
  | `--http-port` | integer 0–65535 | Browser `dev`/`run` HTTP redirect listener; defaults to `0`, which selects an available port. |
@@ -367,7 +367,7 @@ An explicit live-source SDK mapping follows the selected browser destinations
367
367
  while reading canonical SDK source; it never replaces installed files.
368
368
 
369
369
  ```text
370
- arcane dev [--app <id>] [--public] [--http | --https] [--cert <file> --key <file>] [--host <address>] [--port 8000] [--http-port 0] [--sdk-runtime-source <sdk-root>] [--local-ai llama.cpp,ollama]
370
+ arcane dev [--app <id>] [--public] [--http | --https] [--cert <file> --key <file>] [--host <address>] [--port 8000] [--http-port 0] [--sdk-runtime-source <sdk-root>] [--local-ai llama.cpp,ollama,onnx]
371
371
  ```
372
372
 
373
373
  `--local-ai` saves the selected requirements in `native.localAI`, or in
@@ -406,7 +406,7 @@ device, since `localhost` refers to that device and `0.0.0.0` is a bind address.
406
406
  Network URLs come from one interface snapshot at startup and do not establish
407
407
  remote reachability through the machine's firewall or network.
408
408
 
409
- HTTPS is the default for development and required for packaged browser previews.
409
+ HTTPS is the default for development and packaged browser previews.
410
410
  The published `node-http-server` 10.0.0 integration negotiates HTTP/2 or HTTP/1.1
411
411
  on the same HTTPS port using the configured PEM pair. Source routes, generated
412
412
  PWA resources, and conditional responses use the same serving pipeline.
@@ -448,6 +448,10 @@ close the owned HTTP listener and settle the same lifecycle.
448
448
  `--key`, or `--http-port` is a usage error. Omitting it preserves HTTPS;
449
449
  certificate errors never select HTTP automatically.
450
450
 
451
+ The public `startDevServer()` API also accepts `http:true` in packaged mode;
452
+ this does not add a CLI preview command or change `dev` into packaged serving.
453
+ See [the API contract](sdk-api.md#startdevserver).
454
+
451
455
  A LAN HTTP origin does not receive the browser's localhost secure-context
452
456
  exception. For Chrome development, Chromium documents
453
457
  `chrome://flags/#unsafely-treat-insecure-origin-as-secure` with the exact HTTP
@@ -700,10 +704,10 @@ npm exec -- arcane verify-bundle dist/hello-world-1.0.0.arcane-app.tar.gz
700
704
 
701
705
  ### Overview
702
706
 
703
- Loads the SDK package provider for portable by default, or the fixed provider
704
- from an explicitly selected Arcane OS checkout. It diagnoses the selected
705
- provider prerequisites without building an app. Executable targets still
706
- require `--arcane-root` and their platform toolchains.
707
+ Loads the SDK package provider for `portable` or `windows-x64` by default, or
708
+ the fixed provider from an explicitly selected Arcane OS checkout. It diagnoses
709
+ selected prerequisites without building an app. Windows uses the matching
710
+ precompiled SDK host; Linux and Android retain their checkout/toolchain routes.
707
711
 
708
712
  ```text
709
713
  arcane native-doctor --target <native-target> [--arcane-root <directory>]
@@ -719,8 +723,7 @@ is unavailable; it never returns a browser package as a substitute.
719
723
 
720
724
  ```bash
721
725
  npm exec -- arcane native-doctor \
722
- --target windows-x64 \
723
- --arcane-root "../Arcane OS"
726
+ --target windows-x64
724
727
  ```
725
728
 
726
729
  ## `arcane native-prepare`
@@ -762,6 +765,9 @@ The output remains target-specific inside the common plan contract.
762
765
  Portable uses the SDK package without an OS checkout, copies complete selected
763
766
  app/dependency payloads and generates the Core entry/classic client source.
764
767
  It adds no executable platform host or automatically discovered app services.
768
+ Windows x64 uses the SDK package provider and its matching precompiled release
769
+ asset without an OS checkout or application-side native compilation. See
770
+ [Windows requirements and artifact layout](core-native-packaging.md#windows-executable).
765
771
  An explicit `--arcane-root` continues to select the checkout provider.
766
772
  Integrated builds retain an output root outside the OS checkout; only an
767
773
  explicit checkout provider must share the workspace root.
@@ -775,7 +781,6 @@ rather than returning a fictional native artifact plan.
775
781
  ```bash
776
782
  npm exec -- arcane build \
777
783
  --target windows-x64 \
778
- --arcane-root "../Arcane OS" \
779
784
  --output-root "../arcane-native-output"
780
785
  ```
781
786
 
@@ -816,6 +821,13 @@ Android providers expose supported paired native run paths. Portable output is
816
821
  a directory and intentionally cannot run. Android run requires one
817
822
  connected physical/native ARM64 device for the current target.
818
823
 
824
+ `windows-x64` uses the package provider by default, launches `Arcane.exe`, and
825
+ streams complete diagnostics. Its cancellation closes input and waits for the
826
+ window/Core's accepted work to drain; it does not force-kill that host after a
827
+ timer. WebView2 Runtime and .NET Framework 4.6.2 or later must be available on
828
+ the Windows execution machine. Linux/Android retain their explicit provider
829
+ requirements. Build/launch completion does not prove application domain behavior.
830
+
819
831
  ### Example
820
832
 
821
833
  ```bash
@@ -124,6 +124,86 @@ developer diagnostics, rather than ordinary
124
124
  product status surfaces. The optional `onError(error)` callback observes
125
125
  transport/event-owner failures outside individual request promises.
126
126
 
127
+ ## Optional WebKit document lifetime
128
+
129
+ `webKitDocumentLifecycle:true` on `createCoreClient`, `installCoreClient` or
130
+ `createCoreClassicSource` selects document lifetime handling for the native
131
+ WebKit `arcane` handler with replies. It defaults to `false`; existing WebKit
132
+ plain-JSON and alternate acknowledgement transports, WebView2, Android,
133
+ development HTTP and supplied transports keep their existing behavior. The
134
+ selected host must implement this contract and the existing `runtime.replay`
135
+ control. Install the classic source at document start in the page's world.
136
+
137
+ The client owns a fresh activation for the current JavaScript realm and each
138
+ restoration from the browser's page cache. WithReply receives these transport
139
+ records; the Core JSON string remains unchanged in its separate `json` field:
140
+
141
+ | Record | Meaning |
142
+ | --- | --- |
143
+ | `{type:'activate', activation}` | Attach this activation before sending its Core frames. |
144
+ | `{type:'frame', activation, json}` | Send the complete serialized Core request or control. |
145
+ | `{type:'retire', activation, json}` | Retire this activation; `json` is the existing `requests.cancelAll` control. |
146
+
147
+ Reply with `{accepted:true}` or `{accepted:false,error}` on the initiating
148
+ WithReply promise. Frame and retirement acceptance follows the actual complete
149
+ process write. Queue admission alone is insufficient. Activation acceptance
150
+ follows the host's current-realm probe and any required prior-owner cancellation.
151
+ Only this activation's outgoing frames wait for attachment; page rendering,
152
+ facade installation and independent Core startup remain concurrent.
153
+ An aborted, timed-out or otherwise cancelled request awaiting attachment is
154
+ never submitted afterward; its existing cancellation control remains observable.
155
+
156
+ The host calls `__arcaneWebKitDocumentCurrent(activation)` in the current main
157
+ document's page world to probe a candidate. A token or native frame descriptor
158
+ alone does not identify the active document. Serialize candidate probes and
159
+ Core ingress ownership changes: finish each candidate's probe before processing
160
+ the next announcement, and leave the current owner unchanged when a probe is
161
+ false. Announcement arrival order cannot establish document order. A true
162
+ probe establishes the realm at that execution instant; every later delivery
163
+ still checks its target at execution time.
164
+
165
+ Before accepting a replacement activation, write the existing
166
+ `requests.cancelAll` control for the prior ingress owner. Do not wait for a
167
+ retirement announcement that a destroyed document may never send. Write a
168
+ retirement record's JSON only while that activation still owns ingress;
169
+ reject a late retirement without cancelling the replacement's requests.
170
+ Record request-ID-to-origin-activation correlation before submitting each
171
+ request to Core. Responses retain that origin. Existing generic service events
172
+ remain broadcasts to the current activation; no request association is added.
173
+ Complete native diagnostics retain frames received while no document is active;
174
+ restoration uses current-state replay rather than historical event delivery.
175
+
176
+ Deliver through `__arcaneReceive(json, activation)` and
177
+ `__arcaneTransportFailed(error, activation)`, passing payloads as native
178
+ JavaScript call arguments. Both return `false` for a retired or different
179
+ activation. Receive also returns `false` for an unrecognized frame or a
180
+ response with no pending request; `true` means the client accepted delivery,
181
+ which may still await its shared event owner. Failure returns `true` when it
182
+ ends that active installation. Preserve actual evaluation failures through the
183
+ native diagnostic owner; a `false` result is not a JavaScript exception.
184
+ `client.acceptsNativeDelivery(activation)` exposes the same synchronous lifetime
185
+ predicate. It accepts any activation while a client using an ordinary transport
186
+ is live. Direct owner calls to `client.failTransport(error)` retain their
187
+ existing terminal-failure semantics.
188
+
189
+ Page hide synchronously retires the activation even with no pending requests.
190
+ It clears completed ready state and rejects every pending renderer promise with
191
+ the existing `ARCANE_REQUEST_ABORTED`/`AbortError`. This ends the page's wait;
192
+ the runtime's cancellation skips service-lifetime work, so an accepted save
193
+ continues and participates in graceful drain. Its eventual response stays with
194
+ the retired activation and cannot settle a restored page's request. The client
195
+ does not claim that cancellation rolled back persistence.
196
+
197
+ Persisted page restoration creates a fresh activation and sends exactly one
198
+ `runtime.replay` after native attachment. Initial attachment sends that replay
199
+ only when `replayRuntimeState:true`. Application subscriptions survive page
200
+ hide and restoration, including registrations awaiting the shared event owner
201
+ and ready listeners awaiting their replay microtask. Queued deliveries from a
202
+ retired activation are no longer applicable to those subscriptions. Replay
203
+ supplies current Core/service state, not prior responses or request promises.
204
+ Closing the client retires once, removes lifecycle listeners and restores its
205
+ owned callbacks. It does not close the process or control application shutdown.
206
+
127
207
  ## Classic native-host injection
128
208
 
129
209
  ```js
@@ -6,7 +6,7 @@ executable. An application's explicit `native.localAI` selection can include
6
6
  its selected upstream runtimes through the SDK local-AI installer. Without that
7
7
  selection, assembly does no local-AI runtime preparation. Windows, Linux and macOS hosts may compose this
8
8
  Node-based payload; Android needs its separate native host adaptation. The
9
- current CLI's portable platform selections remain Windows and Linux. A portable
9
+ current CLI's portable platform selections include Windows, Linux and macOS. A portable
10
10
  artifact is not a Windows executable, Linux package or Android application.
11
11
 
12
12
  `loadArcaneNativeProvider({target:'portable'})` selects the installed SDK provider
@@ -18,10 +18,14 @@ providers; the loader does not substitute this payload for an unavailable host.
18
18
  ## Provider and selected input
19
19
 
20
20
  The default export and `arcaneNativeBuilderProvider` are the same provider.
21
- `createPortableNativeProvider({services})` creates one with application-owned
21
+ `createPortableNativeProvider({services,packagedWeb=false,webKitDocumentLifecycle=false})` creates one with application-owned
22
22
  service configuration. Without that override, the provider uses the selected
23
23
  app descriptor's `native.services`, or an empty selection when omitted. An
24
24
  explicit `services:[]` overrides the descriptor with no app services.
25
+ The Mac provider selects `packagedWeb:true` to compose the SDK's packaged-web
26
+ Core service and `webKitDocumentLifecycle:true` for the canonical classic-client
27
+ activation/replay contract. Both default to false, preserving ordinary portable
28
+ and Windows composition.
25
29
  All implement `arcane-native-builder/1`:
26
30
 
27
31
  - `describe()` identifies the portable target and `executable:false`.
@@ -242,6 +246,13 @@ factory. Applications without that selection have no generated local-AI import
242
246
  or service. Availability of a particular engine belongs to the selected
243
247
  local-AI installer and service; a generic ONNX runtime is not a speech model.
244
248
 
249
+ Selected `onnx` bundles its complete managed `onnxruntime-node` dependency tree.
250
+ Its `modulePath` resolves against the artifact root just as a server runtime's
251
+ `executable` does. Library/module records need no executable. The generated Core
252
+ service exposes retained worker sessions through `onnx.load/run/unload/status`;
253
+ model files remain caller-selected application resources. See
254
+ [native ONNX sessions](local-ai.md#native-onnx-sessions).
255
+
245
256
  ## Windows executable
246
257
 
247
258
  The ordinary application command is:
@@ -331,3 +342,100 @@ Linux, macOS, Android dispatch and each platform's output verification retain
331
342
  their separate delivery boundaries. Published
332
343
  consumers must adopt the numeric package that includes this increment; a source
333
344
  checkout or a successful source push is not that public package authority.
345
+
346
+ ## macOS process source
347
+
348
+ `src/core/hosts/macos/ArcaneCoreProcess.h` and `.m` provide a Foundation-only
349
+ adapter for macOS 11 or later, compiled with Objective-C ARC and blocks. A
350
+ composing host explicitly supplies the executable URL, arguments, working
351
+ directory and delegate; startup is asynchronous. Delegate callbacks deliver
352
+ every raw stdout/stderr chunk and complete opaque framed JSON bodies, plus
353
+ launch, error, exit and final completion observations. Each stream and accepted
354
+ write retains its own order; UI dispatch belongs to the host. Callbacks must
355
+ return normally and must not wait for another callback or completion.
356
+
357
+ `sendJSONData:completion:error:` accepts an ordered write or reports a
358
+ synchronous rejection. Write completion means the frame reached stdin, not that
359
+ the RPC succeeded. `closeInput` rejects new sends, finishes accepted writes and
360
+ closes stdin, then keeps observing output and child exit without a forced
361
+ termination deadline. The delegate is retained through final completion.
362
+ The AppKit `ArcaneHost` and launcher compose that source as described below.
363
+ Compilation and execution on macOS remain separate evidence from the selected
364
+ Windows output.
365
+
366
+ ## macOS application composition
367
+
368
+ `arcane-os/native/macos-provider` exports
369
+ `createMacOSNativeProvider({services,hostDirectory}={})`, its named
370
+ `arcaneNativeBuilderProvider`, and the same provider as default. The six-method
371
+ contract accepts `macos-arm64` or `macos-x64`, `platform:'macos'`, `format:'app'`
372
+ and the existing unsigned local development selection. Ordinary CLI routing
373
+ uses the SDK package, not an Arcane OS checkout:
374
+
375
+ ```sh
376
+ npm exec -- arcane build --target macos-arm64
377
+ npm exec -- arcane run --target macos-arm64
378
+ ```
379
+
380
+ Select `macos-x64` for Intel. The descriptor must declare the selected target.
381
+ Source implementation does not establish that an architecture's host artifact
382
+ has been built, executed or published. Consumer assembly needs the exact numeric
383
+ SDK release asset `arcane-native-macos-<architecture>.tar.gz`; unavailable assets
384
+ produce their actual download error. SDK collaborators may select an existing
385
+ `hostDirectory` explicitly. There is no fallback to source checkout, another
386
+ version, another architecture or a browser-only artifact.
387
+
388
+ The complete unchanged portable payload lives at
389
+ `<app-id>.app/Contents/Resources/`. That directory remains `target.rootDir` and
390
+ contains `arcane-native.json`, `app/`, dependency releases, installed SDK files,
391
+ Core entry/client and `runtime/node`. The additive `bundleRoot` identifies the
392
+ `.app` directory. `Contents/MacOS/Arcane` and `Contents/Info.plist` belong to the
393
+ bundle rather than the web root; the Mac owner checks these separately from the
394
+ Resources file inventory. Application identity supplies the stable bundle ID
395
+ `org.arcane.<app-id>`. Executable permissions are preserved for the launcher and
396
+ selected Node runtime.
397
+
398
+ The launcher opens its window immediately and starts one Core child. The
399
+ generated Core entry starts the `packaged-web` service alongside application
400
+ services, without waiting for models. Only `core.web.ready`, emitted after the
401
+ actual listener is ready and the initial port is saved, supplies the application
402
+ URL to WebKit. It serves the complete `manifest.webRoot` at `/` and resolves the
403
+ complete `manifest.start`, including query and fragment, against that origin.
404
+ The classic client selects current-document activation and sticky state replay;
405
+ navigation does not restart the Core service or replay retired requests.
406
+ The host's main-thread readonly `isClosing` accessor exposes its existing close
407
+ intent; an unsolicited Core exit is therefore reported separately from an
408
+ ordinary user-requested drain, even when the process exits successfully.
409
+
410
+ `createPackagedWebService({artifactRoot}, context={})` is available from
411
+ `arcane-os/core/packaged-web`. It uses the existing
412
+ `startDevServer({mode:'packaged',http:true,host:'127.0.0.1',port,releaseRoot})`
413
+ owner and published `node-http-server`, not a second HTTP implementation.
414
+ `context.stateRoot` takes precedence over the launcher's separate
415
+ `--arcane-host-state-root` argument. The launcher defaults to
416
+ `~/Library/Application Support/Arcane/<app-id>`; an explicitly supplied launch
417
+ file remains unchanged and is forwarded to Core. The first successful listener
418
+ stores its selected port in `packaged-web-origin.json`. Later launches reuse it;
419
+ a port conflict or unreadable saved record is reported without changing origins
420
+ or discarding stored state.
421
+
422
+ The app's persistent default `WKWebsiteDataStore` uses its bundle identity.
423
+ `stateRoot` selects Core state and diagnostics, not a custom WebKit profile
424
+ directory. Browser API availability, OPFS and secure-context behavior remain
425
+ WebKit-owned and require actual Mac verification; the SDK bypasses no browser
426
+ policy. Startup failures use `core.service.state` for `name:'packaged-web'`;
427
+ unexpected listener closure or failure uses `core.web.failed` with the complete
428
+ serialized error. Native alerts show a concise outcome, with full diagnostics
429
+ outside the conversation. Core drains accepted work and the listener before
430
+ the native close completes. The optional runner stdin-EOF signal uses that same
431
+ path; ordinary double-click startup does not wait on stdin.
432
+
433
+ `tools/build-core-macos-host.mjs` is SDK host-release tooling, not an application
434
+ compiler requirement. It accepts an explicit Darwin Node executable and its
435
+ license, compiler path, `arm64` or `x64`, and output directory. It uses Objective-C
436
+ ARC/blocks and Apple's Foundation, AppKit and WebKit frameworks. The host source
437
+ targets macOS 11; the selected Node runtime may require a newer macOS version.
438
+ Its actual runtime/platform/architecture and the SDK Node engine requirement
439
+ must agree. Compiler/runtime execution and redistribution belong to the
440
+ separately authorized selected host output. This source increment runs none of
441
+ them and claims no Mac build or execution result.
@@ -0,0 +1,49 @@
1
+ # Core preferences service
2
+
3
+ `createPreferencesService({file})` from `arcane-os/core/preferences` supplies the
4
+ existing `Arcane.preferences` RPC methods to a native Core host. The default
5
+ export is the same factory. Construction performs no filesystem work. The
6
+ application selects its writable file and owns preference names, defaults and
7
+ schemas; this service does not invent them or alter operating-system settings.
8
+
9
+ ```js
10
+ import path from 'node:path';
11
+ import {createPreferencesService} from 'arcane-os/core/preferences';
12
+
13
+ export default function createMoonPreferences(options, context) {
14
+ return createPreferencesService({
15
+ file: path.join(context.stateRoot, 'moon-preferences.json')
16
+ });
17
+ }
18
+ ```
19
+
20
+ Select this application-owned factory through `native.services`, and include it
21
+ in `package.nativeResources`. Supply the application's selected `stateRoot`
22
+ through the explicit launch configuration. See [native packaging](core-native-packaging.md#launch-time-locations).
23
+
24
+ | Method | Input | Result |
25
+ | --- | --- | --- |
26
+ | `preferences.list` | `{}` | `{keys}` in sorted order |
27
+ | `preferences.get` | `{key}` | `{key,found,value}`; missing value is `null` |
28
+ | `preferences.set` | `{key,value}` | `{key,value}` after file replacement |
29
+ | `preferences.setMany` | `{entries}` | `{keys,count}` after file replacement |
30
+ | `preferences.delete` | `{key}` | `{key,deleted}` |
31
+
32
+ Storage remains `{schemaVersion:1,entries}`. Exact keys, complete JSON values and
33
+ additional existing document metadata are retained. A missing file starts with
34
+ empty entries; reading it does not create a file. Unreadable or malformed files
35
+ report their real errors and are not replaced with an empty record. Values that
36
+ JSON cannot represent completely fail before replacement. There is no migration,
37
+ truncation, namespace rewrite, default injection or frozen result.
38
+
39
+ Operations selecting the same resolved filename share one ordered queue within
40
+ the Core process. This is not a cross-process file lock. Writes flush their new
41
+ content and replace the selected file before acknowledgment. Filesystem failures
42
+ remain observable, including cleanup errors; this is not a claim of survival
43
+ across every hardware or operating-system failure.
44
+
45
+ `set`, `setMany` and `delete` use `lifetime:'service'`: renderer cancellation does
46
+ not discard accepted writes. `drain()` and `dispose()` stop acceptance and wait
47
+ for accepted operations; later calls reject with `CORE_CLOSING`. Read operations
48
+ observe their request cancellation. Use the existing Core host shutdown owner
49
+ so saved preferences finish before the native process exits.
@@ -0,0 +1,206 @@
1
+ # Nemotron 3 speaker diarization
2
+
3
+ The native diarization API uses the NVIDIA `Nemotron-3-Diarization.q8_0.gguf`
4
+ model through the official NeMo-Speech.cpp 0.2.0 CPU libraries. It returns
5
+ generic, one-based speaker labels and timed segments, independently of speech
6
+ recognition. A speaker label does not identify a person. The model supports
7
+ eight speaker channels; the helper reports the loaded model's actual channel
8
+ count and output cadence.
9
+
10
+ ## Runtime and helper
11
+
12
+ Select the `nemo-speech` runtime through the existing local-AI installer. Keep
13
+ its complete upstream `bin`/`lib`/`include` and CMake layout. Model storage is
14
+ separate and caller-selected. Obtain the selected GGUF from the
15
+ [official NVIDIA model repository](https://huggingface.co/nvidia/Nemotron-3-Diarization).
16
+ This API does not select an ASR model, install Python, or enable a GPU backend.
17
+
18
+ `buildDiarizationHelper({runtime,outputRoot,signal,onEvent})` builds the
19
+ first-party helper for the current host with installed CMake and its C++17
20
+ toolchain. `runtime.cmakeDirectory` is the installer-discovered CMake package
21
+ directory, passed as `NeMoSpeech_DIR` without assuming an archive root. The result
22
+ is `{platform,architecture,root,executable,diagnostics}`; diagnostics retain the
23
+ complete configure/compile/install process results. The installed helper is under
24
+ `outputRoot/bin`; its build directory is under `outputRoot/build`. The helper
25
+ links the upstream `NeMoSpeech::Diarization` component and is separate from
26
+ the downloaded runtime. No compiler is downloaded by this function.
27
+
28
+ Official 0.2.0 CPU archives cover Windows x64, Linux x64/ARM64, and macOS
29
+ x64/ARM64. Linux requires glibc 2.31 or later. Android needs a host-adapted
30
+ runtime/helper; this release's official inventory does not supply an Android
31
+ or Windows ARM64 archive. Source portability is distinct from execution on an
32
+ actual platform.
33
+
34
+ The public Node flow uses the existing installer and one first-party helper:
35
+
36
+ ```javascript
37
+ import {ensureLocalAIRuntimes} from 'arcane-os/local-ai';
38
+ import {buildDiarizationHelper} from 'arcane-os/diarization/build';
39
+ import {createDiarization} from 'arcane-os/diarization';
40
+
41
+ const [runtime] = await ensureLocalAIRuntimes({
42
+ runtimes: [{id: 'nemo-speech', version: '0.2.0'}],
43
+ directory: selectedRuntimeDirectory
44
+ });
45
+ const helper = await buildDiarizationHelper({runtime, outputRoot: selectedHelperDirectory});
46
+ ```
47
+
48
+ Keep the selected directories and model path under their application/host
49
+ owner. A native artifact can place the first-party executable under
50
+ `runtime/diarization/bin`, independently of the complete upstream library tree
51
+ under `runtime/local-ai/nemo-speech`.
52
+
53
+ ## Retained model and audio streams
54
+
55
+ `createDiarization({executable,modelPath,runtime,onEvent})` returns immediately
56
+ and starts its owned helper. Supply absolute helper/model paths and the
57
+ installer's absolute `runtime.binaryDirectory`/`runtime.libraryDirectory` paths. They configure the
58
+ child's platform library search path; the parent environment is unchanged.
59
+
60
+ The returned model has `ready`, `completion`, `current()`,
61
+ `subscribe(listener,{emitCurrent=true,signal})`, `openStream(options)`,
62
+ `diarize(options)`, and `close()`. `ready` resolves when the actual model is
63
+ loaded; a failed load rejects. `completion` covers the complete helper lifetime.
64
+ The sticky state is `loading`, `ready`, `closing`, `closed`, or `error`.
65
+ Subscribe to this owner instead of polling or delaying unrelated UI startup.
66
+
67
+ ```javascript
68
+ const diarization = createDiarization({
69
+ executable: helper.executable,
70
+ modelPath: selectedModelPath,
71
+ runtime
72
+ });
73
+
74
+ const stream = await diarization.openStream({
75
+ sampleRate: 16000,
76
+ onUpdate: function showSpeakers(result) {
77
+ renderSpeakerTimeline(result.segments);
78
+ }
79
+ });
80
+
81
+ await stream.push(firstMonoSamples);
82
+ await stream.push(nextMonoSamples);
83
+ const final = await stream.finish();
84
+ await diarization.close();
85
+ ```
86
+
87
+ `push(audio)` accepts mono `Float32Array` samples and preserves their float32
88
+ representation. The caller owns decoding an encoded recording and choosing
89
+ its mono channel; this API does not alter the source recording, mix channels,
90
+ normalize amplitudes, or capture a microphone. Keep the supplied array stable
91
+ until `push` settles. Each stream accepts one fixed sample rate: 8000–96000 Hz,
92
+ or `0` for model-rate samples. The default is 16000 Hz. Upstream owns necessary
93
+ resampling. Await each push for backpressure; independent streams share the
94
+ retained model without sharing speaker/session state. Upstream serializes
95
+ model compute internally.
96
+
97
+ `openStream({sampleRate,onUpdate,onProbabilities,signal})` returns a stream with
98
+ `push`, `finish`, `cancel`, `completion`, and `current()`. A push resolves to
99
+ its latest segment snapshot, or `null` until native frames are available. `finish()`
100
+ flushes all remaining audio and resampler output, returns the complete final
101
+ result, and releases the native stream. It is idempotent. `current()` retains
102
+ only the latest successful snapshot. Results have:
103
+
104
+ ```text
105
+ {final, speakers, secondsPerFrame, frameCount,
106
+ segments:[{speaker,startTime,endTime}, ...]}
107
+ ```
108
+
109
+ Times are seconds from the start of that caller's stream. Intermediate segment
110
+ snapshots may revise earlier segment boundaries. Replace the displayed
111
+ snapshot; do not append whole snapshots as new segments. Final results include
112
+ all upstream segments, including those finalized before upstream probability
113
+ compaction. The API adds no diarization thresholds or segment filtering.
114
+
115
+ For recorded mono samples, `await diarization.diarize({audio,sampleRate,signal,
116
+ onUpdate,onProbabilities})` uses the same complete streaming path, then finishes
117
+ and closes that stream. It does not use upstream's length-constrained stateless
118
+ offline operation.
119
+
120
+ ## Probabilities, callbacks, and cancellation
121
+
122
+ Supply `onProbabilities` to receive every available probability frame as
123
+ `{startFrame,values,speakers,secondsPerFrame}`. Values are frame-major, with one
124
+ value per speaker channel per frame. Frame indices are absolute within the
125
+ stream. The adapter reads between 160 ms input pushes, before upstream's old
126
+ probability buffer can be compacted. It reports an error if an upstream gap is
127
+ ever observed; it does not manufacture missing values. Without this callback,
128
+ the helper does not request raw probabilities.
129
+
130
+ Callbacks are awaited and their failures propagate. The caller owns retaining
131
+ probability history, audio, and any earlier snapshots it needs. The SDK does
132
+ not accumulate a second transcript of continuous protocol output. `onEvent`
133
+ receives ordinary process lifecycle events and complete stderr diagnostics;
134
+ raw stdout protocol belongs to the result callbacks instead. Keep engineering
135
+ diagnostics in a selected developer surface, outside ordinary UI/chat history.
136
+
137
+ `cancel(reason)` and the stream's abort signal stop subsequent pushes and
138
+ suppress later result commits for that stream. Cancellation closes the stream
139
+ after native commands already ahead of its close have returned; the C ABI
140
+ does not offer an immediate interrupt. Other streams keep their own state.
141
+ An already-running caller callback finishes under its caller's ownership.
142
+ `cancel()` can be awaited inside a callback. Await the same stream's `push()`,
143
+ `finish()`, or model `close()`
144
+ only after the callback returns; a recursive wait reports
145
+ `DIARIZATION_CALLBACK_WAIT` instead of deadlocking. Stream `completion`
146
+ retains finish/cancellation cleanup failures.
147
+
148
+ `close()` stops new streams, drains in-flight openings and accepted stream work,
149
+ finishes the remaining streams, closes helper stdin, and waits for native
150
+ cleanup/process exit. The model always outlives its streams. Complete failures
151
+ from an operation and its cleanup remain available together.
152
+
153
+ ## Core service
154
+
155
+ Import the named or default factory from `arcane-os/core/diarization`.
156
+
157
+ `createDiarizationService({executable,modelPath,runtime,onEvent},launchContext)`
158
+ is a synchronous `native.services` factory. Relative executable/model paths
159
+ resolve against explicit `launchContext.workspaceRoot`, otherwise the native
160
+ launcher's `appRoot` (or the current directory for standalone factories). Model loading is lazy at the
161
+ first diarization operation, not a prerequisite for Core startup. The returned
162
+ service implements `drain()` and `dispose()` and the following methods:
163
+
164
+ | Method | Input / result |
165
+ | --- | --- |
166
+ | `diarization.status` | Current model lifecycle snapshot. |
167
+ | `diarization.load` | Load the configured model; return readiness. |
168
+ | `diarization.open` | `{sampleRate,probabilities}` → `{streamId,sampleRate}`. |
169
+ | `diarization.push` | `{streamId,audio}` → current timed segment snapshot. |
170
+ | `diarization.finish` | `{streamId}` → complete final result, releasing the stream. |
171
+ | `diarization.cancel` | `{streamId}` → cleanup completion for that stream. |
172
+ | `diarization.recording` | `{audio,sampleRate}` → complete final result. |
173
+
174
+ Core audio is `{encoding:'f32le',data:BASE64}`: transport encoding of the exact
175
+ little-endian float32 samples, with control metadata outside the audio. The
176
+ service emits `diarization.state`, `diarization.update` with `{streamId,result}`,
177
+ and optional `diarization.probabilities` with the stream ID and frame data.
178
+ Subscribe before opening a stream. Session operations have service lifetime;
179
+ renderer request cancellation does not discard accepted audio. Call the
180
+ explicit cancel method for a session. A recording operation has request
181
+ lifetime and its cancellation closes only that recording's stream.
182
+
183
+ ## Shared process transport
184
+
185
+ The existing internal `runProcess` owner accepts scalar input as before and
186
+ also an `AsyncIterable<string|Uint8Array>`. Iteration is backpressured by the
187
+ child's stdin writes; iterable completion sends EOF, including in `close-input`
188
+ mode. Cancellation/early child exit calls the iterator's `return()` and waits
189
+ for input cleanup. The producer must make a pending `next()` settle when it is
190
+ returned/cancelled. The diarization-owned producer does this explicitly.
191
+
192
+ `onOutput({stream,chunk})` receives complete decoded UTF-8 chunks with original
193
+ delimiters and is awaited per stream. It is not a binary stdout interface.
194
+ `captureOutput` and `emitOutputEvents` default to `true`; each also accepts
195
+ `{stdout,stderr}` overrides. Disabling capture requires an output consumer and
196
+ returns `null` for that process-result field; it does not return a shortened
197
+ transcript. Disabling output events leaves those events absent. Existing
198
+ scalar input, full text results and ordinary event defaults remain unchanged.
199
+ Failed output callbacks retain their complete input chunk and cause in the
200
+ process error, including when successful output is caller-owned.
201
+
202
+ ## Upstream contracts
203
+
204
+ The implementation follows the [stable C ABI](https://github.com/NVIDIA/NeMo-Speech.cpp/blob/v0.2.0/include/nemo_speech/diar.h),
205
+ [SDK linkage guide](https://github.com/NVIDIA/NeMo-Speech.cpp/blob/v0.2.0/docs/sdk.md),
206
+ and [official 0.2.0 release](https://github.com/NVIDIA/NeMo-Speech.cpp/releases/tag/v0.2.0).