arcane-os 0.55.0 → 0.57.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 (56) hide show
  1. package/CHANGELOG.md +51 -0
  2. package/README.md +5 -3
  3. package/browser-runtime/ai/core-local.mjs +306 -0
  4. package/browser-runtime/core/client.mjs +75 -14
  5. package/browser-runtime/core/contracts.mjs +2 -1
  6. package/docs/consumer-updates.md +82 -0
  7. package/docs/publishing.md +41 -18
  8. package/docs/reference/README.md +31 -1
  9. package/docs/reference/availability-and-normalization.md +11 -3
  10. package/docs/reference/cli.md +9 -1
  11. package/docs/reference/core-client.md +45 -2
  12. package/docs/reference/core-native-packaging.md +195 -11
  13. package/docs/reference/core-runtime.md +10 -0
  14. package/docs/reference/inventory/package-api.json +160 -20
  15. package/docs/reference/local-ai.md +197 -0
  16. package/docs/reference/protocols.md +91 -14
  17. package/docs/reference/pwa.md +17 -0
  18. package/docs/reference/runtime-modules.md +6 -5
  19. package/docs/reference/sdk-api.md +165 -26
  20. package/package.json +5 -1
  21. package/runtime/arcane/modules/LocalAIReadiness.js +3 -1
  22. package/schemas/arcane-app.schema.json +64 -0
  23. package/schemas/arcane-package.schema.json +54 -0
  24. package/src/app-descriptor.mjs +35 -2
  25. package/src/app-layout.mjs +6 -2
  26. package/src/cli/main.mjs +8 -2
  27. package/src/core/host.mjs +23 -0
  28. package/src/core/hosts/arcane-core-loader.cjs +2 -0
  29. package/src/core/hosts/linux/arcane_core_process.c +568 -0
  30. package/src/core/hosts/linux/arcane_core_process.h +127 -0
  31. package/src/core/hosts/macos/ArcaneCoreProcess.h +85 -0
  32. package/src/core/hosts/macos/ArcaneCoreProcess.m +357 -0
  33. package/src/core/hosts/sea-launcher.cjs +17 -0
  34. package/src/core/hosts/windows/ArcaneCoreProcess.cs +416 -0
  35. package/src/core/hosts/windows/ArcaneHost.cs +695 -0
  36. package/src/core/hosts/windows/ArcaneHost.manifest +22 -0
  37. package/src/core/hosts/windows/ArcaneLauncher.cs +239 -0
  38. package/src/core/runtime.mjs +15 -3
  39. package/src/core/services/local-ai.mjs +543 -0
  40. package/src/core-classic-source.mjs +2 -2
  41. package/src/dev-server.mjs +7 -0
  42. package/src/import-map.mjs +1 -0
  43. package/src/local-ai/archive.mjs +52 -0
  44. package/src/local-ai/config.mjs +62 -0
  45. package/src/local-ai/dev.mjs +390 -0
  46. package/src/local-ai/discover.mjs +71 -0
  47. package/src/local-ai/http.mjs +106 -0
  48. package/src/local-ai/install.mjs +344 -0
  49. package/src/local-ai/server.mjs +262 -0
  50. package/src/native/portable-layout.mjs +29 -4
  51. package/src/native/portable-provider.mjs +39 -8
  52. package/src/native/windows-provider.mjs +262 -0
  53. package/src/native-provider-loader.mjs +8 -2
  54. package/src/packager/core.mjs +89 -15
  55. package/src/process.mjs +74 -12
  56. package/src/toolchain.mjs +38 -8
@@ -1,17 +1,87 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
- "sdkVersion": "0.55.0",
3
+ "sdkVersion": "0.56.0",
4
4
  "environment": {
5
5
  "runtime": "Node.js for Node entrypoints; browser for browser-only entrypoints",
6
6
  "minimumVersion": "22.23.2 for Node entrypoints",
7
7
  "moduleSystem": "ESM"
8
8
  },
9
- "memberCount": 244,
9
+ "memberCount": 254,
10
10
  "runtimeSubpathPatterns": {
11
11
  "arcane-os/modules/*": "./runtime/arcane/modules/*",
12
12
  "arcane-os/entities/*": "./runtime/arcane/entities/*"
13
13
  },
14
14
  "members": [
15
+ {
16
+ "id": "core-local:createCoreLocalAIProvider",
17
+ "name": "createCoreLocalAIProvider",
18
+ "displayName": "createCoreLocalAIProvider()",
19
+ "kind": "function",
20
+ "signature": "createCoreLocalAIProvider({client,id='llama.cpp'}={})",
21
+ "entrypoints": ["arcane-os/ai/core-local"],
22
+ "primaryImport": "arcane-os/ai/core-local",
23
+ "group": "Core local AI",
24
+ "summary": "Browser llama.cpp provider through an explicitly connected Core, with application-owned model selection and complete response streaming.",
25
+ "availability": "Browser with an available Core local AI service; construction installs no runtime or model",
26
+ "protocol": "arcane-ai-provider/2 LLM lifecycle over arcane/1",
27
+ "normalization": "Preserves complete payloads and original parsed chunks; waits for the exact requested model and cancels on observed readiness loss"
28
+ },
29
+ {
30
+ "id": "core-local-ai:createLocalAIService",
31
+ "name": "createLocalAIService",
32
+ "displayName": "createLocalAIService()",
33
+ "kind": "function",
34
+ "signature": "createLocalAIService(configuration,{appRoot,runtimes=[],signal,onEvent}={})",
35
+ "entrypoints": ["arcane-os/core/local-ai"],
36
+ "primaryImport": "arcane-os/core/local-ai",
37
+ "group": "Core local AI",
38
+ "summary": "Composes selected native llama.cpp and Ollama engines as a Core service with retained process ownership and model lifecycle.",
39
+ "availability": "Node with selected upstream runtime distributions or available configured system services",
40
+ "protocol": "arcane/1 methods and events; llama.cpp OpenAI HTTP/SSE and Ollama native HTTP/NDJSON",
41
+ "normalization": "Application-owned runtime and model requirements; independent startup, complete responses and exact owned-process cleanup"
42
+ },
43
+ {
44
+ "id": "core-local-ai:default",
45
+ "name": "default",
46
+ "displayName": "createLocalAIService default export",
47
+ "kind": "function",
48
+ "signature": "default as createLocalAIService",
49
+ "entrypoints": ["arcane-os/core/local-ai"],
50
+ "primaryImport": "arcane-os/core/local-ai",
51
+ "group": "Core local AI",
52
+ "summary": "Default binding for the same native Core local AI service factory.",
53
+ "availability": "Node",
54
+ "protocol": "arcane/1 service definition",
55
+ "normalization": "Binding identity equals the named createLocalAIService export"
56
+ },
57
+ {
58
+ "id": "local-ai:ensureLocalAIRuntimes",
59
+ "name": "ensureLocalAIRuntimes",
60
+ "displayName": "ensureLocalAIRuntimes()",
61
+ "kind": "function",
62
+ "signature": "ensureLocalAIRuntimes({runtimes=[],directory,platform,architecture,signal,onEvent}={})",
63
+ "entrypoints": ["arcane-os/local-ai"],
64
+ "primaryImport": "arcane-os/local-ai",
65
+ "group": "Core local AI",
66
+ "summary": "Reuses selected managed native runtimes or installs complete official llama.cpp and Ollama distributions.",
67
+ "availability": "Node; upstream platform and architecture assets determine runtime availability",
68
+ "protocol": "Official upstream release downloads and host archive extraction",
69
+ "normalization": "Returns absolute runtime records; shares matching concurrent installs, preserves libraries and reports failures without changing global PATH or services"
70
+ },
71
+ {
72
+ "id": "local-ai:bundleLocalAIRuntimes",
73
+ "name": "bundleLocalAIRuntimes",
74
+ "displayName": "bundleLocalAIRuntimes()",
75
+ "kind": "function",
76
+ "signature": "bundleLocalAIRuntimes({runtimes=[],directory,outputRoot,platform,architecture,signal,onEvent}={})",
77
+ "entrypoints": ["arcane-os/local-ai"],
78
+ "primaryImport": "arcane-os/local-ai",
79
+ "group": "Core local AI",
80
+ "summary": "Copies selected complete runtime distributions into a fresh native artifact staging root.",
81
+ "availability": "Node; supports bundling published upstream platform assets independently of the build host",
82
+ "protocol": "Artifact-relative runtime/local-ai layout",
83
+ "normalization": "Returns {runtimes,files} with relative runtime records and the complete emitted inventory; model resources remain application-owned"
84
+ },
15
85
  {
16
86
  "id": "root:WS",
17
87
  "name": "WS",
@@ -380,7 +450,7 @@
380
450
  ],
381
451
  "primaryImport": "arcane-os",
382
452
  "group": "Headless toolchain operations",
383
- "summary": "Packages the selected app and builds one explicitly selected target; tests or checks run only when explicitly requested or required for the selected release output.",
453
+ "summary": "Packages the selected app and builds one explicitly selected target; paired native assembly applies each selected and bundled app's nativeResources and separate input output directory, preserving complete release records and explicit providers. Tests or checks run only when explicitly requested or required for the selected release output.",
384
454
  "availability": "Node; selected operation may produce browser or native output",
385
455
  "protocol": "Shared headless operation API + arcane-cli-events/1",
386
456
  "normalization": "SDK-normalized inputs, errors, events, and documented result"
@@ -937,14 +1007,14 @@
937
1007
  "name": "inspectApp",
938
1008
  "displayName": "inspectApp()",
939
1009
  "kind": "function",
940
- "signature": "async inspectApp({workspaceRoot, appId, signal}={})",
1010
+ "signature": "async inspectApp({workspaceRoot, appId, signal, target, outputDirectory}={})",
941
1011
  "entrypoints": [
942
1012
  "arcane-os",
943
1013
  "arcane-os/packager"
944
1014
  ],
945
1015
  "primaryImport": "arcane-os",
946
1016
  "group": "Packaging and release bundles",
947
- "summary": "Loads one validated packager app plan, including the shared descriptor-admitted browser document inventory and final workspace-relative output selected by app outputDirectory or default dist/appId.",
1017
+ "summary": "Inspects one complete app plan without copying files. Target defaults to browser; nonbrowser selection adds explicit nativeResources outside browserDocuments and uses dist/.native/target/appId for a nonempty native include list. Explicit operation outputDirectory wins; other calls retain the saved outputDirectory or dist/appId.",
948
1018
  "availability": "Node",
949
1019
  "protocol": "SDK packager and deterministic bundle contract",
950
1020
  "normalization": "Normalized SDK validation with complete canonical archive and release content"
@@ -1239,7 +1309,7 @@
1239
1309
  ],
1240
1310
  "primaryImport": "arcane-os",
1241
1311
  "group": "Packaging and release bundles",
1242
- "summary": "Builds one selected browser application release into app outputDirectory or default dist/appId through staged whole-directory replacement, preserving source and unrelated prior destinations; it never runs tests or checks automatically.",
1312
+ "summary": "Builds one complete app release with browser selection by default. Nonbrowser targets add explicit nativeResources through a late complete-content copy and separate native input output; moduleFormat is independent. Adapters receive actual target and effective browserPwa. Explicit operation outputDirectory wins; staged replacement preserves source and unrelated outputs. No tests or checks run automatically.",
1243
1313
  "availability": "Node",
1244
1314
  "protocol": "SDK packager and deterministic bundle contract",
1245
1315
  "normalization": "Normalized SDK validation with complete canonical archive and release content"
@@ -1256,7 +1326,7 @@
1256
1326
  ],
1257
1327
  "primaryImport": "arcane-os",
1258
1328
  "group": "Headless toolchain operations",
1259
- "summary": "Runs the high-level package operation for one selected application using the same app-selected final outputDirectory, defaulting to dist/appId, with no separate destination override.",
1329
+ "summary": "Runs the high-level browser package operation for one selected application using the saved outputDirectory or dist/appId, with no separate destination override. Paired native buildApplication separately applies actual target and nativeResources selection.",
1260
1330
  "availability": "Node; selected operation may produce browser or native output",
1261
1331
  "protocol": "Shared headless operation API + arcane-cli-events/1",
1262
1332
  "normalization": "SDK-normalized inputs, errors, events, and documented result"
@@ -1370,7 +1440,7 @@
1370
1440
  ],
1371
1441
  "primaryImport": "arcane-os",
1372
1442
  "group": "Runtime and app descriptors",
1373
- "summary": "Projects a schema-2 descriptor into the compatible schema-1 application package contract.",
1443
+ "summary": "Projects a schema-2 descriptor into the compatible schema-1 package contract, including optional package.nativeResources as top-level nativeResources; omitted selection stays omitted, empty include stays empty, and omitted exclude becomes an empty array.",
1374
1444
  "availability": "Node",
1375
1445
  "protocol": "Node ESM",
1376
1446
  "normalization": "SDK-normalized inputs, errors, events, and documented result"
@@ -2073,7 +2143,7 @@
2073
2143
  ],
2074
2144
  "primaryImport": "arcane-os/packager",
2075
2145
  "group": "Packaging and release bundles",
2076
- "summary": "Validates one schema-1 packager app configuration and its relationship to the root config, including optional workspace-relative final outputDirectory without changing source layout or app identity.",
2146
+ "summary": "Validates one schema-1 packager app configuration, optional nativeResources literal include/exclude selection and workspace-relative outputDirectory without changing source layout or app identity. Native include may be empty; exclude defaults to an empty array.",
2077
2147
  "availability": "Node",
2078
2148
  "protocol": "SDK packager and deterministic bundle contract",
2079
2149
  "normalization": "Normalized SDK validation with complete canonical archive and release content"
@@ -2172,7 +2242,7 @@
2172
2242
  ],
2173
2243
  "primaryImport": "arcane-os",
2174
2244
  "group": "Packaging and release bundles",
2175
- "summary": "Authenticates one existing browser app release through the low-level packager API.",
2245
+ "summary": "Reads an existing app release and compares its complete file inventory with its manifest. Pass a target-selected native release's output as outputDirectory; this API does not infer a native target or execute services or hosts.",
2176
2246
  "availability": "Node",
2177
2247
  "protocol": "SDK packager and deterministic bundle contract",
2178
2248
  "normalization": "Normalized SDK validation with complete canonical archive and release content"
@@ -3657,7 +3727,7 @@
3657
3727
  "entrypoints": ["arcane-os/core/contracts"],
3658
3728
  "primaryImport": "arcane-os/core/contracts",
3659
3729
  "group": "Core protocol contracts",
3660
- "summary": "Describes the public fields on Core request, response, event and cancellation frames.",
3730
+ "summary": "Describes the public fields on Core request, response, event, cancellation and runtime.replay control frames.",
3661
3731
  "availability": "Node and browser/bundler",
3662
3732
  "protocol": "arcane/1 wire descriptions",
3663
3733
  "normalization": "Descriptive data only; it does not admit methods, validate application policy or create a transport"
@@ -3709,14 +3779,14 @@
3709
3779
  "name": "createCoreClient",
3710
3780
  "displayName": "createCoreClient()",
3711
3781
  "kind": "function",
3712
- "signature": "createCoreClient({global=globalThis,transport=null,eventOwner=arcaneEvents,eventOwnerReady,autoConnect=true,onError}={})",
3782
+ "signature": "createCoreClient({global=globalThis,transport=null,eventOwner=arcaneEvents,eventOwnerReady,autoConnect=true,replayRuntimeState=false,onError}={})",
3713
3783
  "entrypoints": ["arcane-os/core/client"],
3714
3784
  "primaryImport": "arcane-os/core/client",
3715
3785
  "group": "Core browser client",
3716
3786
  "summary": "Creates one correlated Arcane Core RPC client with explicit transport, readiness, events, cancellation and lifetime ownership.",
3717
3787
  "availability": "Browser and native WebView JavaScript hosts; custom transports require a callable send(frame)",
3718
3788
  "protocol": "arcane/1 over the selected host transport",
3719
- "normalization": "Preserves complete request, result and event data; rejects invalid transports before readiness, retains FIFO handoff to the shared event owner and reports transport failures that arrive after request settlement"
3789
+ "normalization": "Preserves complete request, result and event data; retains FIFO event-owner handoff; failTransport(error) settles pending RPCs and acknowledgements with the complete failure and releases the client lifetime; opt-in replayRuntimeState sends one observed nonblocking runtime.replay control after transport readiness"
3720
3790
  },
3721
3791
  {
3722
3792
  "id": "core-client:createCoreFacade",
@@ -3741,24 +3811,38 @@
3741
3811
  "entrypoints": ["arcane-os/core/client"],
3742
3812
  "primaryImport": "arcane-os/core/client",
3743
3813
  "group": "Core browser client",
3744
- "summary": "Installs one synchronous global Arcane facade and native receive callback for the selected renderer lifetime.",
3814
+ "summary": "Installs one synchronous global Arcane facade, native receive callback and terminal transport-failure callback for the selected renderer lifetime.",
3745
3815
  "availability": "Browser and native WebView JavaScript hosts",
3746
3816
  "protocol": "arcane/1 renderer facade",
3747
- "normalization": "Repeated installation returns the same client; closing releases subscriptions, callbacks, timers and pending renderer requests without killing Core"
3817
+ "normalization": "Repeated installation returns the same client; close/failTransport release owned resources and restore prior globals only while still owned; __arcaneTransportFailed preserves the complete host failure without killing Core"
3818
+ },
3819
+ {
3820
+ "id": "core-client:getInstalledCoreClient",
3821
+ "name": "getInstalledCoreClient",
3822
+ "displayName": "getInstalledCoreClient()",
3823
+ "kind": "function",
3824
+ "signature": "getInstalledCoreClient(global=globalThis)",
3825
+ "entrypoints": ["arcane-os/core/client"],
3826
+ "primaryImport": "arcane-os/core/client",
3827
+ "group": "Core browser client",
3828
+ "summary": "Returns the exact live SDK-installed client or null without installing, connecting or changing globals.",
3829
+ "availability": "Browser and native WebView JavaScript hosts",
3830
+ "protocol": "arcane/1 renderer client ownership",
3831
+ "normalization": "Recognizes ESM and classic SDK installation identity; returns null after close or terminal failure and does not treat a foreign Arcane facade as an SDK client"
3748
3832
  },
3749
3833
  {
3750
3834
  "id": "core-classic-source:createCoreClassicSource",
3751
3835
  "name": "createCoreClassicSource",
3752
3836
  "displayName": "createCoreClassicSource()",
3753
3837
  "kind": "function",
3754
- "signature": "async createCoreClassicSource({eventOwnerModuleURL}={})",
3838
+ "signature": "async createCoreClassicSource({eventOwnerModuleURL,replayRuntimeState=false}={})",
3755
3839
  "entrypoints": ["arcane-os/core/classic-source"],
3756
3840
  "primaryImport": "arcane-os/core/classic-source",
3757
3841
  "group": "Core classic client projection",
3758
3842
  "summary": "Generates the native host's classic injection script from the installed canonical Core client and contracts.",
3759
3843
  "availability": "Node; generated source runs in browser and native WebView renderers",
3760
3844
  "protocol": "arcane/1 classic-script injection",
3761
- "normalization": "Returns the complete canonical client projection; installs synchronous facade shapes while deferring only the shared event-owner module connection when document parsing is incomplete"
3845
+ "normalization": "Returns the complete canonical client projection; installs synchronous facade shapes while deferring only the event-owner module connection when document parsing is incomplete; forwards explicit runtime replay selection with a false default"
3762
3846
  },
3763
3847
  {
3764
3848
  "id": "core-runtime:createCoreRuntime",
@@ -3772,7 +3856,7 @@
3772
3856
  "summary": "Creates an app-neutral Core dispatcher with explicit services, request lifetimes, events and graceful drain.",
3773
3857
  "availability": "Node on Windows, Linux and macOS native hosts; Android requires its host adaptation",
3774
3858
  "protocol": "arcane/1 dispatcher and service lifecycle",
3775
- "normalization": "Starts services independently, preserves request correlation and complete results/errors, cancels only request-lifetime work and waits accepted service-lifetime responses before ordered service drain and disposal"
3859
+ "normalization": "Starts services independently, preserves complete results/errors, cancels only request-lifetime work and drains accepted service work; runtime.replay publishes current dispatcher/service state without restart and preserves reentrant lifecycle publication order"
3776
3860
  },
3777
3861
  {
3778
3862
  "id": "core-stdio:encodeCoreFrame",
@@ -3821,14 +3905,14 @@
3821
3905
  "name": "createPortableNativeProvider",
3822
3906
  "displayName": "createPortableNativeProvider()",
3823
3907
  "kind": "function",
3824
- "signature": "createPortableNativeProvider({services=[]}={})",
3908
+ "signature": "createPortableNativeProvider({services}={})",
3825
3909
  "entrypoints": ["arcane-os/native/portable-provider"],
3826
3910
  "primaryImport": "arcane-os/native/portable-provider",
3827
3911
  "group": "Portable native provider",
3828
3912
  "summary": "Creates the SDK-owned provider that assembles one selected app and explicit services into a portable Core payload.",
3829
3913
  "availability": "Node; produces a portable payload rather than an executable host",
3830
3914
  "protocol": "arcane-native-builder/1 portable provider",
3831
- "normalization": "Preserves complete selected app and dependency releases, uses explicit service module factories, reports executable:false and never substitutes for an unavailable platform host"
3915
+ "normalization": "Preserves complete selected app and dependency releases; an explicit services selection overrides appDescriptor.native.services, otherwise the descriptor selection is used; reports executable:false and never substitutes for an unavailable platform host"
3832
3916
  },
3833
3917
  {
3834
3918
  "id": "native-portable-provider:arcaneNativeBuilderProvider",
@@ -3858,6 +3942,62 @@
3858
3942
  "protocol": "arcane-native-builder/1 portable provider",
3859
3943
  "normalization": "Binding identity is exactly equal to the named arcaneNativeBuilderProvider export"
3860
3944
  },
3945
+ {
3946
+ "id": "native-windows-provider:createWindowsNativeProvider",
3947
+ "name": "createWindowsNativeProvider",
3948
+ "displayName": "createWindowsNativeProvider()",
3949
+ "kind": "function",
3950
+ "signature": "createWindowsNativeProvider({services,hostDirectory}={})",
3951
+ "entrypoints": ["arcane-os/native/windows-provider"],
3952
+ "primaryImport": "arcane-os/native/windows-provider",
3953
+ "group": "Windows native provider",
3954
+ "summary": "Assembles selected application services and browser content with the SDK-owned Windows x64 WebView2 and SEA host.",
3955
+ "availability": "Node for assembly; Windows x64 with WebView2 Runtime for execution",
3956
+ "protocol": "arcane-native-builder/1 windows-x64 provider",
3957
+ "normalization": "Uses a selected hostDirectory or the exact installed SDK version's numeric release asset; preserves complete payloads; run cancellation closes stdin and waits for host-owned graceful shutdown"
3958
+ },
3959
+ {
3960
+ "id": "native-windows-provider:arcaneNativeBuilderProvider",
3961
+ "name": "arcaneNativeBuilderProvider",
3962
+ "displayName": "arcaneNativeBuilderProvider",
3963
+ "kind": "singleton",
3964
+ "signature": "const arcaneNativeBuilderProvider",
3965
+ "entrypoints": ["arcane-os/native/windows-provider"],
3966
+ "primaryImport": "arcane-os/native/windows-provider",
3967
+ "group": "Windows native provider",
3968
+ "summary": "SDK-owned Windows provider selected by the ordinary windows-x64 build command without an OS checkout.",
3969
+ "availability": "Node for assembly; Windows x64 with WebView2 Runtime for execution",
3970
+ "protocol": "arcane-native-builder/1 windows-x64 provider",
3971
+ "normalization": "Uses appDescriptor.native.services and the exact SDK release host asset; binding is identical to the default export"
3972
+ },
3973
+ {
3974
+ "id": "native-windows-provider:default",
3975
+ "name": "default",
3976
+ "displayName": "arcaneNativeBuilderProvider default export",
3977
+ "kind": "singleton",
3978
+ "signature": "default as arcaneNativeBuilderProvider",
3979
+ "entrypoints": ["arcane-os/native/windows-provider"],
3980
+ "primaryImport": "arcane-os/native/windows-provider",
3981
+ "group": "Windows native provider",
3982
+ "summary": "Default binding for the SDK Windows executable provider.",
3983
+ "availability": "Node for assembly; Windows x64 with WebView2 Runtime for execution",
3984
+ "protocol": "arcane-native-builder/1 windows-x64 provider",
3985
+ "normalization": "Binding identity is exactly equal to the named arcaneNativeBuilderProvider export"
3986
+ },
3987
+ {
3988
+ "id": "core-host:readCoreLaunchContext",
3989
+ "name": "readCoreLaunchContext",
3990
+ "displayName": "readCoreLaunchContext()",
3991
+ "kind": "function",
3992
+ "signature": "readCoreLaunchContext({argv=process.argv.slice(2)}={})",
3993
+ "entrypoints": ["arcane-os/core/host"],
3994
+ "primaryImport": "arcane-os/core/host",
3995
+ "group": "Native Core host composition",
3996
+ "summary": "Reads the complete JSON object explicitly selected by --arcane-launch-config for native service launch context.",
3997
+ "availability": "Node, including the selected external-entry SEA launcher",
3998
+ "protocol": "Explicit launch arguments and JSON configuration",
3999
+ "normalization": "Returns an empty record without the flag; preserves every supplied field and value, surfaces file and JSON failures, and performs no configuration search, rewrite or environment mutation"
4000
+ },
3861
4001
  {
3862
4002
  "id": "core-host:startCoreHost",
3863
4003
  "name": "startCoreHost",
@@ -0,0 +1,197 @@
1
+ # Local AI through Core
2
+
3
+ Core owns native llama.cpp and Ollama processes. The browser retains its own
4
+ Wllama and ONNX implementations, and can also use an explicitly connected Core
5
+ when that system service is available. Runtime installation, model loading and
6
+ inference are separate operations.
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.
11
+
12
+ ## Application requirements
13
+
14
+ Declare required native runtimes in `arcane-app.json` under `native.localAI`.
15
+ The package projection retains the same record as `arcane-package.json.localAI`.
16
+ Existing native fields remain alongside this record:
17
+
18
+ ```json
19
+ {
20
+ "runtimes": [
21
+ {"id": "llama.cpp"},
22
+ {"id": "ollama"}
23
+ ],
24
+ "llamaCpp": {
25
+ "modelsDirectory": "models/llama"
26
+ },
27
+ "ollama": {
28
+ "modelsDirectory": "models/ollama"
29
+ }
30
+ }
31
+ ```
32
+
33
+ Each runtime requirement accepts `id`, optional upstream `version`, and an
34
+ optional runtime archive `url`. A string runtime ID is also accepted.
35
+ Omitting the version allows reuse of an available runtime. Explicit versions
36
+ select that upstream distribution; an existing service must match the requested
37
+ version before it is reused. A service occupying the selected address is
38
+ preserved when its version cannot be established.
39
+
40
+ `llamaCpp` accepts `url`, `model`, `modelsDirectory`, and an `args` string array.
41
+ `model` selects a single GGUF file; `modelsDirectory` selects llama.cpp router
42
+ mode. Paths resolve from the application root. Ollama accepts `url`,
43
+ `modelsDirectory`, and `args`. The default endpoints are
44
+ `http://127.0.0.1:8080` and `http://127.0.0.1:11434`, respectively. Default model
45
+ directories are `.arcane/models/llama.cpp` and `.arcane/models/ollama` inside the
46
+ application. Applications choose and provision their models explicitly.
47
+
48
+ ## Development
49
+
50
+ ```sh
51
+ arcane dev --local-ai llama.cpp,ollama
52
+ ```
53
+
54
+ The option adds those runtime requirements to the authored application
55
+ configuration. Subsequent `arcane dev` runs reuse the saved requirements.
56
+ Development checks selected endpoints and existing executable paths, then
57
+ installs missing runtimes under the application's `.arcane/local-ai/runtimes`.
58
+ Runtime preparation runs alongside HTTP serving. Browser rendering continues
59
+ while installation and model readiness are pending.
60
+
61
+ The SDK downloads the official llama.cpp or Ollama distribution directly and
62
+ preserves its runtime libraries. Installation changes no global PATH, system
63
+ service or machine environment. Windows and macOS use the host archive utility;
64
+ Linux requires `tar`, and `unzip` when extracting a selected Windows ZIP.
65
+ Zstandard archives use the supported Node runtime's decompressor.
66
+
67
+ For the optional development browser connection, load the bootstrap after the
68
+ managed import map and before creating a Core-backed provider:
69
+
70
+ ```js
71
+ const {client} = await import('/arcane-local-ai.js');
72
+ const status = await client.invoke('localai.status');
73
+ console.log(status);
74
+ ```
75
+
76
+ The bootstrap uses the existing Core client with RPC and ordered SSE events.
77
+ Each browser connection owns its requests and cancellation. Closing a tab
78
+ cancels that tab's requests; closing development stops its owned runtime
79
+ processes. An already running external service remains running.
80
+
81
+ `developApplication()` returns its usual server handle and an optional `localAI`
82
+ handle with `ready`, `current()`, `handler()` and `close()`. Its `ready` promise
83
+ means installation and Core composition completed. Runtime/model readiness is
84
+ reported separately by Core status and lifecycle events. Preparation failures
85
+ remain on that promise and the operation event stream.
86
+
87
+ ## Core service
88
+
89
+ ```js
90
+ import {createLocalAIService} from 'arcane-os/core/local-ai';
91
+
92
+ const service = createLocalAIService(application.native.localAI, {
93
+ appRoot,
94
+ runtimes,
95
+ signal,
96
+ onEvent
97
+ });
98
+ ```
99
+
100
+ The result is a Core service definition. The launch context contains resolved
101
+ runtime records; the native builder supplies them automatically for a selected
102
+ application. `current()` returns the current snapshot without starting another
103
+ process. The service starts each selected runtime independently, retains its
104
+ process between requests, and joins cleanup during disposal.
105
+
106
+ `localai.status` returns `{runtimes}` and, when Ollama is selected, the existing
107
+ `ollama` and `models.ollama` catalog fields. Runtime records distinguish
108
+ `installed`, `available`, `state`, `models`, ownership and errors. A listening
109
+ service and a loaded model are separate facts.
110
+
111
+ `localai.services.recover({runtimes: ['llama.cpp']})` makes one explicit recovery
112
+ attempt for the selected runtimes; omission selects all configured runtimes.
113
+ Recovery restarts only SDK-owned processes and reconnects to external services.
114
+ An external llama.cpp server returns HTTP 503 during initial model loading and
115
+ offers no readiness subscription at that stage. Core retains `state: 'loading'`;
116
+ a subsequent explicit load or recovery request checks again. There is no
117
+ background health polling.
118
+
119
+ | Method | Parameters | Result |
120
+ | --- | --- | --- |
121
+ | `llama.status` | `{}` | Runtime state and model catalog |
122
+ | `llama.models` | `{}` | `{models}` |
123
+ | `llama.load` | `{model}` | State after the exact model reports loaded |
124
+ | `llama.unload` | `{model}` | Current state after release |
125
+ | `llama.chat` | `{model,payload,stream?,streamId?}` | Complete OpenAI-shaped completion |
126
+
127
+ The `payload` is the complete request. SDK option names are translated only at
128
+ the upstream protocol boundary; messages, tool definitions and documents remain
129
+ unchanged. An explicit `payload.model` selects that request's model. Core waits
130
+ for its actual readiness before inference. Router model-load work is shared
131
+ between concurrent callers for the same model. Cancelling a caller stops its
132
+ wait; explicit unloading releases the model.
133
+
134
+ Streaming publishes every actual parsed upstream chunk as
135
+ `llama.chunk: {streamId,chunk}` and assembles the terminal completion. Upstream
136
+ stream errors remain visible as their original chunks and fail the request.
137
+ `localai.state` carries current runtime/model state. Router lifecycle events
138
+ observe load, sleep and unload changes. Direct servers expose readiness at
139
+ request boundaries; they do not offer the router's passive model event stream.
140
+
141
+ Unloading a model from an owned single-model server closes that owned process;
142
+ a subsequent load can start it again. Releasing an externally owned direct
143
+ server returns `released: true, unloaded: false`, retaining the real catalog
144
+ and leaving that server running.
145
+
146
+ Ollama retains the existing Core calls for `version`, `models`/`list`, `running`,
147
+ `show`, `chat`, `generate`, `embed`, `pull`, `push`, `create`, `copy`, and `delete`.
148
+ Those methods use Ollama's native API. Streaming uses the existing
149
+ `ollama.chunk: {streamId,chunk}` event. Application/OS preference operations
150
+ such as selection, settings and brain creation remain with their existing
151
+ owners; they are separate from this runtime service.
152
+
153
+ ## Browser llama.cpp provider
154
+
155
+ ```js
156
+ import {createCoreLocalAIProvider} from 'arcane-os/ai/core-local';
157
+ import {getAIProviderRuntime} from 'arcane-os/ai-provider-runtime';
158
+
159
+ const provider = createCoreLocalAIProvider({client});
160
+ const runtime = getAIProviderRuntime();
161
+ const unregister = runtime.register(provider);
162
+ ```
163
+
164
+ The provider implements `arcane-ai-provider/2` for the LLM role, with ID
165
+ `llama.cpp` by default. Configure an exact model through the existing provider
166
+ runtime, then load it. `catalog()`, `status()`, `inspect()`, `load()`, `request()`,
167
+ `unload()` and `dispose()` retain the shared lifecycle. Creating the provider
168
+ does not install software or select a model. A missing Core connection reports
169
+ unavailability, leaving browser Wllama/ONNX routes available for the application
170
+ to select.
171
+
172
+ If a router evicts the primary model while serving a request-specific model,
173
+ reload the primary selection before its next request. The provider does not
174
+ silently change the application's saved model choice. Release registration
175
+ with `unregister()` and dispose the provider at the application's owning
176
+ lifecycle boundary.
177
+
178
+ ## Native bundling
179
+
180
+ The SDK portable native build includes selected official runtime trees under
181
+ `runtime/local-ai/<runtime-id>`. Runtime records in the artifact are relative
182
+ to the artifact root and resolve on the destination machine. The generated
183
+ Core entry composes the local AI service only when the application selects it.
184
+ Model files remain application-selected native resources.
185
+
186
+ `ensureLocalAIRuntimes()` and `bundleLocalAIRuntimes()` are exported from
187
+ `arcane-os/local-ai`. Both accept `{runtimes,directory,platform,architecture,
188
+ signal,onEvent}`; bundling also requires `outputRoot`. Platform names follow
189
+ Node: `win32`, `linux`, `darwin`, and supported Android distributions.
190
+ Architectures are `x64` or `arm64`. Availability depends on the upstream
191
+ runtime's published platform assets; Ollama has no official Android runtime
192
+ archive in this installer.
193
+
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.