arcane-os 0.62.0 → 0.63.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.
@@ -0,0 +1,114 @@
1
+ # Native speech service
2
+
3
+ `createSpeechService({stt, tts, signal} = {})` composes independently selected
4
+ native speech engines into one Core service. It is the named and default export
5
+ from `arcane-os/core/speech`.
6
+
7
+ The host supplies an STT engine, a TTS engine, or both. Construction performs no
8
+ installation, model download, model loading, or inference. Core registration
9
+ exposes `speech.status`, `speech.transcribe`, and `speech.synthesize`; an
10
+ operation whose engine was omitted rejects with `SPEECH_ENGINE_UNAVAILABLE`.
11
+ The optional `signal` controls the service lifetime.
12
+
13
+ ```js
14
+ import {createCoreRuntime} from 'arcane-os/core/runtime';
15
+ import {createSpeechService} from 'arcane-os/core/speech';
16
+
17
+ // The host prepares and constructs its selected transcription engine.
18
+ const speech = createSpeechService({stt: transcriptionEngine});
19
+ const core = createCoreRuntime({services: [speech]});
20
+ core.start();
21
+ ```
22
+
23
+ This service is the shared integration layer. It does not supply or install a
24
+ Kokoro or Sherpa-ONNX engine. Engine preparation, model resources, device
25
+ selection, supported formats, and native process ownership remain with the
26
+ selected engine and its host composition. Browser-only operation remains
27
+ independent of this native service.
28
+
29
+ ## Startup and status
30
+
31
+ `start(context)` subscribes to each configured engine and starts their loads
32
+ independently. It returns immediately, allowing Core and `speech.status` to
33
+ respond while models load. A failure in one role leaves the other role usable.
34
+ Each engine publishes the actual state of its selected model.
35
+
36
+ `current()` and `speech.status` return the same snapshot:
37
+
38
+ | Field | Meaning |
39
+ |---|---|
40
+ | `ready` | Both speech roles are available. A service configured with only STT or only TTS retains `ready: false`. |
41
+ | `transcriptionAvailable` | The STT engine reports a loaded model in `ready` or `running` state, and the service is accepting work. |
42
+ | `synthesisAvailable` | The equivalent independent TTS readiness. |
43
+ | `status` | `created`, `ok`, `closing`, or `closed`. `ok` describes the operational service; model loading and failures are reported per role. |
44
+ | `sttEngine`, `ttsEngine` | The configured engines' `providerId` values, or an empty string for an omitted engine. |
45
+ | `roles.stt`, `roles.tts` | Each engine's complete current state plus the service's `available` boolean. |
46
+ | `closed` | Whether the service has completed its shutdown attempt. Any engine cleanup failure remains observable. |
47
+
48
+ An engine's state includes `providerId`, `modelId`, `state`, `loaded`, and
49
+ `busy`, with its complete error or progress information when present. An
50
+ omitted role has `state: 'unavailable'`, `loaded: false`, and `busy: false`.
51
+ File presence, a spawned process, and a callable bridge do not establish loaded
52
+ model readiness. Existing readiness consumers additionally recognize
53
+ the engine IDs `whisper.cpp` and `kokoro-onnx`; another engine ID requires the
54
+ corresponding consumer integration.
55
+
56
+ ## Events and subscriptions
57
+
58
+ `subscribe(listener, {replay = true, signal} = {})` immediately delivers the
59
+ current snapshot by default and returns an unsubscribe function. The optional
60
+ subscription signal removes only that listener. Closed services can still
61
+ replay their final snapshot. Promise rejections from listeners are reported
62
+ through developer diagnostics.
63
+
64
+ Changes are published through the SDK's existing event owner and Core as
65
+ `speech.state`. A Core client observes them with
66
+ `Arcane.events.on('speech.state', listener)`. Core's generic runtime replay
67
+ does not replay custom speech state. A browser consumer should subscribe first,
68
+ then request `Arcane.speech.status()`, retaining any newer event received while
69
+ that initial request is pending.
70
+
71
+ `speech.progress` carries `{requestId, role, status: 'Thinking', progress}`.
72
+ The service emits `progress: {phase: 'accepted'}` synchronously when accepting
73
+ a speech request. Subsequent progress is the selected engine's actual report;
74
+ cancelled requests publish no later progress.
75
+
76
+ ## Engine interface
77
+
78
+ Each supplied engine implements:
79
+
80
+ - `current()` returning the actual selected-model state.
81
+ - `subscribe(listener)` with immediate current-state replay and an unsubscribe
82
+ function.
83
+ - `load({signal})`, resolving only after the constructor-selected model has
84
+ loaded. Independent engines may load concurrently.
85
+ - `transcribe(request, {signal, onProgress})` for STT, or
86
+ `synthesize(request, {signal, onProgress})` for TTS.
87
+ - `close()`, cancelling and joining its native work and releasing its resources.
88
+
89
+ The service forwards each complete request and result unchanged. It applies
90
+ no input trimming, content limits, model or voice substitution, transcript
91
+ rewriting, or audio conversion. The engine owns any format decoding,
92
+ phonemization, required model segmentation, output encoding, and supported
93
+ model selection. Necessary processing must preserve complete ordered input
94
+ and output through that engine's public contract.
95
+
96
+ ## Cancellation and shutdown
97
+
98
+ The request's `context.signal` reaches its engine together with the service's
99
+ lifetime signal. A request waiting for its role's shared startup load can
100
+ cancel promptly without cancelling another request or the other speech role.
101
+ The retained startup load remains observed by the service. Queued and active
102
+ inference cancellation belongs to the engine; it must stop the actual native
103
+ operation and settle independently of service disposal.
104
+
105
+ This matters because Core cancels and awaits active requests before calling
106
+ service shutdown hooks. An engine that interrupts requests only in `close()`
107
+ would prevent Core from reaching that cleanup hook.
108
+
109
+ `close()` and `drain()` stop acceptance, abort the service lifetime, close both
110
+ engines concurrently, and await their startup and request tasks. Repeated calls
111
+ share one shutdown promise. Actual engine cleanup failures reject with an
112
+ `AggregateError` and remain in role diagnostics. `dispose()` additionally
113
+ releases the service's event subscriptions. New work after shutdown begins
114
+ rejects with `CORE_CLOSING`.
@@ -63,9 +63,14 @@ runtime layouts.
63
63
  | `arcane-os/diarization` | Retained Nemotron model helper and independent caller-fed audio streams. |
64
64
  | `arcane-os/diarization/build` | First-party helper compilation against explicitly installed NeMo-Speech.cpp libraries. |
65
65
  | `arcane-os/core/local-ai` | Native llama.cpp, Ollama and ONNX Core service, model readiness, complete responses and owned lifecycle. See [local AI through Core](local-ai.md). |
66
- | `arcane-os/local-ai` | Official runtime installation and native artifact bundling for selected llama.cpp/Ollama/ONNX requirements and NeMo libraries. |
66
+ | `arcane-os/local-ai` | Official runtime installation and native artifact bundling for selected llama.cpp/Ollama/ONNX/image requirements and NeMo libraries. |
67
67
  | `arcane-os/local-ai/onnx` | Retained native ONNX worker sessions with explicit graph loading and complete tensor inference. |
68
68
  | `arcane-os/ai/core-onnx` | Optional browser access to system ONNX through an existing Core connection. |
69
+ | `arcane-os/local-ai/image` | Retained native stable-diffusion.cpp context, complete PNG generation and owned worker lifetime. |
70
+ | `arcane-os/ai/core-image` | Browser image lifecycle and complete PNG Blobs through an available Core service. |
71
+ | `arcane-os/core/image` | Native image Core service with independent runtime preparation and retained model ownership. |
72
+ | `arcane-os/ai/core-model-assets` | Complete stored browser model members projected through Core into native working files. |
73
+ | `arcane-os/core/model-assets` | Native working-file preparation, engine retain handles and joined cleanup. |
69
74
  | `arcane-os/integrated-provider` | Fixed integrated shared-development provider. |
70
75
  | `arcane-os/packager` | Low-level browser app packager. |
71
76
  | `arcane-os/release-bundle` | Deterministic external release bundles. |
@@ -403,6 +408,13 @@ The remaining data-only subpaths are eight JSON Schemas and package metadata.
403
408
  | `createLocalAIService()` | function | `arcane-os/core/local-ai` | Core local AI | Node with selected llama.cpp/Ollama/ONNX runtimes |
404
409
  | `createONNXRuntime()` | function | `arcane-os/local-ai/onnx` | Core local AI | Node with prepared Microsoft ONNX runtime |
405
410
  | `createCoreONNXRuntime()` | function | `arcane-os/ai/core-onnx` | Core local AI | Browser with an available Core ONNX service |
411
+ | `createImageRuntime()` | function | `arcane-os/local-ai/image` | Core local images | Node with a prepared native image runtime and caller-selected model |
412
+ | `createCoreImageRuntime()` | function | `arcane-os/ai/core-image` | Core local images | Browser with an available Core image service |
413
+ | `createLocalImageService()` | function | `arcane-os/core/image` | Core local images | Node Core with selected stable-diffusion.cpp requirements |
414
+ | `createLocalImageService default export` | function | `arcane-os/core/image` | Core local images | Same native image service factory |
415
+ | `prepareCoreModelAssets()` | function | `arcane-os/ai/core-model-assets` | Core model assets | Browser with complete Blob/File members and available Core service |
416
+ | `createModelAssetService()` | function | `arcane-os/core/model-assets` | Core model assets | Node Core with an application-selected working directory |
417
+ | `createModelAssetService default export` | function | `arcane-os/core/model-assets` | Core model assets | Same native working-file service factory |
406
418
  | `createLocalAIService default export` | function | `arcane-os/core/local-ai` | Core local AI | Same native service factory |
407
419
  | `ensureLocalAIRuntimes()` | function | `arcane-os/local-ai` | Core local AI | Node; selected upstream platform assets |
408
420
  | `bundleLocalAIRuntimes()` | function | `arcane-os/local-ai` | Core local AI | Node; complete native runtime assembly |
@@ -7708,7 +7720,7 @@ separate states; prompts, models and application policy remain caller-owned.
7708
7720
  ### Signature and result
7709
7721
 
7710
7722
  ```text
7711
- createLocalAIService(configuration,{appRoot,runtimes=[],signal,onEvent}={})
7723
+ createLocalAIService(configuration,{appRoot,runtimes=[],signal,onEvent,prepare}={})
7712
7724
  ```
7713
7725
 
7714
7726
  Import it from `arcane-os/core/local-ai`. `configuration` is the authored local-AI
@@ -7718,6 +7730,13 @@ resolved installed runtime records. It returns a Core service definition with
7718
7730
  existing Core lifecycle. Shutdown cancels owned work and joins owned processes;
7719
7731
  an already running external service remains under its external owner.
7720
7732
 
7733
+ Optional `prepare({signal,onEvent})` supplies resolved runtime records during
7734
+ this service's startup. Only operations depending on that service wait for its
7735
+ preparation; the development listener and independently composed image/model
7736
+ asset services keep their own lifetimes. Pass only llama.cpp/Ollama/ONNX
7737
+ requirements to this factory; `createLocalImageService()` owns selected image
7738
+ requirements. The managed development and native entrypoints separate them.
7739
+
7721
7740
  The service provides `localai.status`, explicit `localai.services.recover`,
7722
7741
  `llama.status/models/load/unload/chat`, `onnx.status/load/run/unload`, and the documented native Ollama methods.
7723
7742
  `localai.state` reports runtime/model changes. `llama.chunk` and `ollama.chunk`
@@ -7761,6 +7780,145 @@ accessor's requests and subscriptions; unloading shared models is explicit.
7761
7780
  Construction installs no runtime and opens no transport. Existing browser
7762
7781
  ONNX/Wllama remain independent. See [Core and browser usage](local-ai.md#onnx-through-core-and-the-browser).
7763
7782
 
7783
+ ## createImageRuntime()
7784
+
7785
+ `createImageRuntime({libraryPath,bindingModulePath,variants=[],models=[],backend='auto',signal?,onEvent?})`
7786
+ from `arcane-os/local-ai/image` retains the native image owner for the selected
7787
+ library. Prepare the installed record through `ensureLocalAIRuntimes()` and
7788
+ supply complete model descriptors with actual native resource paths. The
7789
+ factory installs no software and starts its worker when an operation needs it.
7790
+
7791
+ It returns `load({model,context?,signal?})`, `generate({model,prompt,parameters?,
7792
+ signal?,onProgress?})`, `edit({model,image,prompt,strength,parameters?,signal?,onProgress?})`,
7793
+ `unload({signal?})`, `current()`,
7794
+ `subscribe(listener,{replay=true})` and asynchronous `close()`. A model ID uses
7795
+ its supplied descriptor; a complete descriptor may be passed directly.
7796
+ Generation returns all PNG results as `images: [{data,mediaType,width,height}]`
7797
+ with native result metadata. Prompts and parameters remain complete.
7798
+
7799
+ `edit()` accepts the original complete PNG as `image: {data: Uint8Array,
7800
+ mediaType}` and copies the supplied view at acceptance. Its explicit finite
7801
+ `strength` is from `0` through `1`, takes precedence over model/parameter
7802
+ defaults and is never clamped. It decodes in the existing worker and uses the
7803
+ same selected context, queue, progress, cancellation and complete result
7804
+ contract. SD1.4 advertises `txt2img` and `img2img`. See the
7805
+ [editing contract](local-image-editing.md#core-and-native-request) for supported
7806
+ PNG input, native preprocessing, alpha and strength-zero semantics; the
7807
+ original file remains unchanged.
7808
+
7809
+ Accessors for the same library share its worker and selected context. Competing
7810
+ native operations are ordered at that owner; unrelated services remain
7811
+ concurrent. State observation replays synchronously by default. Cancellation
7812
+ joins the owning native operation; a model constructor may finish before its
7813
+ new context can be released. Native accessor `close()` cancels its requests,
7814
+ joins them and releases the shared selected context before its working files
7815
+ can be retired. The final reference closes the worker. This differs from the
7816
+ browser accessor's detach-only ownership below. See the
7817
+ [image lifecycle, backend and error contract](local-image-generation.md).
7818
+
7819
+ ## createCoreImageRuntime()
7820
+
7821
+ `createCoreImageRuntime({client=getInstalledCoreClient(),signal?,onEvent?})`
7822
+ from `arcane-os/ai/core-image` returns immediately with `load`, `generate`, `edit`,
7823
+ `unload`, `inspect`, `current`, `subscribe` and `close`. It subscribes before
7824
+ requesting an initial status snapshot so newer lifecycle events win. It opens
7825
+ no connection and installs or selects no model.
7826
+
7827
+ `load({model,context?,assetProjectionId?,resourcePaths?,signal?})` and
7828
+ `generate({model,prompt,parameters?,assetProjectionId?,resourcePaths?,signal?,
7829
+ onProgress?})` use the selected Core service. Generation acknowledges with
7830
+ transient `Thinking` synchronously and returns complete
7831
+ `images: [{blob,mediaType,width,height}]` plus native result metadata.
7832
+ `unload({signal?})` explicitly releases the shared selected model;
7833
+ `inspect({signal?})` reads authoritative state without waiting for preparation.
7834
+ All request methods use `timeoutMs:0`. `current()` includes transient requests,
7835
+ status, busy and closed state; no prompt or image history is saved.
7836
+
7837
+ `edit({model,image,prompt,strength,parameters?,assetProjectionId?,resourcePaths?,
7838
+ signal?,onProgress?})` accepts the original PNG Blob or File and returns the
7839
+ same complete Blob result shape. It publishes `Thinking` before reading that
7840
+ input, preserves its complete encoded content through Core, and performs no
7841
+ browser drawing, re-encoding, resizing or saving. The request signal covers
7842
+ input preparation and native cancellation; an in-flight `Blob.arrayBuffer()`
7843
+ finishes before cancellation can be observed. No aborted result or late
7844
+ progress reaches the caller. See [full editing usage and format limits](local-image-editing.md).
7845
+
7846
+ `subscribe(listener,{replay=true,signal?})` returns an unsubscribe function.
7847
+ `close()` cancels and joins only this accessor's requests and subscriptions,
7848
+ leaving the shared Core client and selected model with their owners. Request
7849
+ errors retain complete details; an unavailable Core reports
7850
+ `ARCANE_IMAGE_CORE_UNAVAILABLE`. Aborted operations deliver no late result or
7851
+ progress. See the [complete browser example and events](local-image-generation.md#browser-accessor).
7852
+
7853
+ ## createLocalImageService()
7854
+
7855
+ `createLocalImageService(configuration,{appRoot,runtimes=[],signal?,onEvent?,prepare?,modelAssets?})`
7856
+ from `arcane-os/core/image` returns a Core service with `current()`, replaying
7857
+ `subscribe(listener)`, native preparation, request methods and joined disposal.
7858
+ `configuration` is the selected `localAI` record. Optional
7859
+ `prepare({appRoot,configuration,requirement,signal,onEvent})` returns one
7860
+ installed image-runtime record. Startup retains this preparation in the
7861
+ background; `image.status` and unrelated services remain responsive.
7862
+
7863
+ The service owns `image.status/load/generate/edit/unload` and
7864
+ `image.state/progress`. Pass the same `createModelAssetService()` instance that
7865
+ Core exposes when using `assetProjectionId` and `resourcePaths`. It retains
7866
+ prepared model files through actual native completion, replacement, unload and
7867
+ shutdown. PNG base64 is transport-only framing; the complete result is decoded
7868
+ by the browser accessor. See [parameters, results and ownership](local-image-generation.md#core-service-and-transport).
7869
+
7870
+ `image.edit` takes `{model,image,prompt,strength,parameters?,streamId?,
7871
+ assetProjectionId?,resourcePaths?}`. Only the Core JSON boundary encodes the
7872
+ input as `{data: completeBase64PNG,encoding:'base64',mediaType}`. The service
7873
+ acknowledges accepted work through `image.progress`, preserves the original
7874
+ prompt and complete image, and retains existing model-assets ownership through
7875
+ native completion. Its complete encoded PNG result has the same shape as
7876
+ `image.generate`; [editing semantics](local-image-editing.md) remain with the
7877
+ selected model and native engine.
7878
+
7879
+ ## createLocalImageService default export
7880
+
7881
+ The default export from `arcane-os/core/image` is the same
7882
+ `createLocalImageService` factory and lifecycle described above.
7883
+
7884
+ ## prepareCoreModelAssets()
7885
+
7886
+ `prepareCoreModelAssets({client=getInstalledCoreClient(),workingDirectory,members,signal?,onProgress?})`
7887
+ from `arcane-os/ai/core-model-assets` projects ordered complete
7888
+ `members: [{path,file}]` through an available Core connection. Each `file` is a
7889
+ Blob or File. It returns `{id,directory,members:[{path,nativePath}],release}`
7890
+ after all members finish writing and close. Independent members transfer
7891
+ concurrently; each member's writes remain ordered.
7892
+
7893
+ The caller releases preparation ownership with asynchronous idempotent
7894
+ `release()`. Native engines acquire their own retain handle before loading,
7895
+ and files remain until their actual native use ends. Cancellation and failure
7896
+ join transfers and uncancelled cleanup, preserving complete original errors.
7897
+ The helper downloads no model, changes no DBOPFS original and selects no
7898
+ engine. See [complete preparation and cleanup usage](model-assets.md).
7899
+
7900
+ ## createModelAssetService()
7901
+
7902
+ `createModelAssetService({appRoot=process.cwd()}={})` from
7903
+ `arcane-os/core/model-assets` returns the Core service for
7904
+ `modelAssets.open/write/complete/release/status` and `modelAssets.state`.
7905
+ Relative working directories resolve from `appRoot`; explicit absolute
7906
+ directories remain caller-selected. Each projection has its own child
7907
+ directory and complete member files.
7908
+
7909
+ `current()` returns `{closing,projections}`. `retain(id)` accepts a completed
7910
+ projection and returns `{id,directory,members,release}` for a native owner.
7911
+ `dispose()` releases preparation ownership and joins file writes, closes and
7912
+ all native retain lifetimes before cleanup. The native owner releases its
7913
+ handle only after its actual context/worker use ends. Original stored model
7914
+ files remain with their application owner. See
7915
+ [working-file service and wire operations](model-assets.md#native-ownership).
7916
+
7917
+ ## createModelAssetService default export
7918
+
7919
+ The default export from `arcane-os/core/model-assets` is the same
7920
+ `createModelAssetService` factory and lifecycle described above.
7921
+
7764
7922
  ## createLocalAIService default export
7765
7923
 
7766
7924
  The default binding from `arcane-os/core/local-ai` is exactly the named
@@ -7776,7 +7934,7 @@ import createLocalAIService from 'arcane-os/core/local-ai';
7776
7934
  ### Overview
7777
7935
 
7778
7936
  Reuses matching managed runtimes or installs complete selected official
7779
- llama.cpp/Ollama/ONNX distributions or NeMo libraries in an explicitly supplied directory.
7937
+ llama.cpp/Ollama/ONNX/image distributions or NeMo libraries in an explicitly supplied directory.
7780
7938
 
7781
7939
  ### Signature and result
7782
7940
 
@@ -7787,7 +7945,11 @@ async ensureLocalAIRuntimes({runtimes=[],directory,platform=process.platform,arc
7787
7945
  Import it from `arcane-os/local-ai`. Runtime requirements accept IDs or
7788
7946
  `{id,version?,url?}` records. The result is an array of absolute
7789
7947
  `{id,version,platform,architecture,root}` records, with `executable` for servers,
7790
- `modulePath` for ONNX, or NeMo library directories. Matching concurrent
7948
+ `modulePath` for ONNX, image `libraryPath`/`bindingModulePath`/`variants`/`models`,
7949
+ or NeMo library directories. Image requirements also accept `backend` and
7950
+ `models`; their pinned default runtime, CPU/Metal selection and separate model
7951
+ preparation are described in [local image generation](local-image-generation.md).
7952
+ Matching concurrent
7791
7953
  installs share their work. Downloads retain runtime libraries and surface
7792
7954
  network/archive failures; cancellation and operation events remain observable.
7793
7955
  Installation changes no global PATH or system service and loads no model.
@@ -7825,6 +7987,13 @@ contains the complete emitted inventory. Existing runtime destinations are
7825
7987
  preserved and reported as a conflict. Copying settles all started work and
7826
7988
  reports failures/cancellation without executing app services or models.
7827
7989
 
7990
+ Image records relocate the complete library, binding and variant paths. Model
7991
+ URL descriptors retain their original acquisition metadata for preparation
7992
+ after launch. Runtime-contained native model paths become artifact-relative;
7993
+ external working paths report their portability incompatibility rather than
7994
+ embedding this machine's path. Use the application-owned native-resource or
7995
+ post-launch model-assets workflow for those files.
7996
+
7828
7997
  ```javascript
7829
7998
  import {bundleLocalAIRuntimes} from 'arcane-os/local-ai';
7830
7999
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "arcane-os",
3
- "version": "0.62.0",
3
+ "version": "0.63.0",
4
4
  "description": "Arcane OS JavaScript SDK, project-local CLI, browser runtime, and repository-portable application packager.",
5
5
  "type": "module",
6
6
  "main": "./src/index.mjs",
@@ -66,6 +66,7 @@
66
66
  "./core/diarization": "./src/diarization/service.mjs",
67
67
  "./core/local-ai": "./src/core/services/local-ai.mjs",
68
68
  "./core/image": "./src/core/services/image.mjs",
69
+ "./core/speech": "./src/core/services/speech.mjs",
69
70
  "./core/model-assets": "./src/core/services/model-assets.mjs",
70
71
  "./diarization": "./src/diarization/index.mjs",
71
72
  "./diarization/build": "./src/diarization/build.mjs",