arcane-os 0.56.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 (41) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +1 -1
  3. package/browser-runtime/ai/core-local.mjs +306 -0
  4. package/docs/reference/README.md +20 -0
  5. package/docs/reference/cli.md +9 -1
  6. package/docs/reference/core-native-packaging.md +195 -11
  7. package/docs/reference/inventory/package-api.json +138 -12
  8. package/docs/reference/local-ai.md +197 -0
  9. package/docs/reference/protocols.md +69 -1
  10. package/docs/reference/runtime-modules.md +6 -5
  11. package/docs/reference/sdk-api.md +165 -26
  12. package/package.json +5 -1
  13. package/runtime/arcane/modules/LocalAIReadiness.js +3 -1
  14. package/schemas/arcane-app.schema.json +54 -0
  15. package/schemas/arcane-package.schema.json +44 -0
  16. package/src/app-descriptor.mjs +17 -1
  17. package/src/cli/main.mjs +8 -2
  18. package/src/core/host.mjs +23 -0
  19. package/src/core/hosts/macos/ArcaneCoreProcess.h +85 -0
  20. package/src/core/hosts/macos/ArcaneCoreProcess.m +357 -0
  21. package/src/core/hosts/windows/ArcaneCoreProcess.cs +3 -3
  22. package/src/core/hosts/windows/ArcaneHost.cs +695 -0
  23. package/src/core/hosts/windows/ArcaneHost.manifest +22 -0
  24. package/src/core/hosts/windows/ArcaneLauncher.cs +239 -0
  25. package/src/core/services/local-ai.mjs +543 -0
  26. package/src/dev-server.mjs +7 -0
  27. package/src/import-map.mjs +1 -0
  28. package/src/local-ai/archive.mjs +52 -0
  29. package/src/local-ai/config.mjs +62 -0
  30. package/src/local-ai/dev.mjs +390 -0
  31. package/src/local-ai/discover.mjs +71 -0
  32. package/src/local-ai/http.mjs +106 -0
  33. package/src/local-ai/install.mjs +344 -0
  34. package/src/local-ai/server.mjs +262 -0
  35. package/src/native/portable-layout.mjs +29 -4
  36. package/src/native/portable-provider.mjs +39 -8
  37. package/src/native/windows-provider.mjs +262 -0
  38. package/src/native-provider-loader.mjs +8 -2
  39. package/src/packager/core.mjs +6 -2
  40. package/src/process.mjs +66 -8
  41. package/src/toolchain.mjs +33 -5
@@ -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"
@@ -3835,14 +3905,14 @@
3835
3905
  "name": "createPortableNativeProvider",
3836
3906
  "displayName": "createPortableNativeProvider()",
3837
3907
  "kind": "function",
3838
- "signature": "createPortableNativeProvider({services=[]}={})",
3908
+ "signature": "createPortableNativeProvider({services}={})",
3839
3909
  "entrypoints": ["arcane-os/native/portable-provider"],
3840
3910
  "primaryImport": "arcane-os/native/portable-provider",
3841
3911
  "group": "Portable native provider",
3842
3912
  "summary": "Creates the SDK-owned provider that assembles one selected app and explicit services into a portable Core payload.",
3843
3913
  "availability": "Node; produces a portable payload rather than an executable host",
3844
3914
  "protocol": "arcane-native-builder/1 portable provider",
3845
- "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"
3846
3916
  },
3847
3917
  {
3848
3918
  "id": "native-portable-provider:arcaneNativeBuilderProvider",
@@ -3872,6 +3942,62 @@
3872
3942
  "protocol": "arcane-native-builder/1 portable provider",
3873
3943
  "normalization": "Binding identity is exactly equal to the named arcaneNativeBuilderProvider export"
3874
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
+ },
3875
4001
  {
3876
4002
  "id": "core-host:startCoreHost",
3877
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.
@@ -147,9 +147,70 @@ included resources without receiving application-document processing.
147
147
  Component processing and shared runtime-resource traversal retain their existing
148
148
  behavior. Offline inclusion still follows the app's PWA resource selection.
149
149
 
150
+ ## Native-only application resources
151
+
152
+ An application's schema-2 `arcane-app.json` can explicitly select server modules
153
+ and their complete app-owned source closure without adding them to its browser
154
+ or PWA output:
155
+
156
+ ```json
157
+ {
158
+ "package": {
159
+ "include": ["index.html", "modules", "css"],
160
+ "nativeResources": {
161
+ "include": ["server", "src", "package.json"],
162
+ "exclude": ["server/drafts"]
163
+ }
164
+ }
165
+ }
166
+ ```
167
+
168
+ This is a package excerpt. Each path is literal and relative to the application
169
+ root; a directory includes its descendants. The app selects the full required
170
+ closure explicitly. The SDK does not crawl imports to discover server source,
171
+ filter it by extension, install app dependencies or execute a service.
172
+ `nativeResources.include` is required and may be empty; `exclude` defaults to
173
+ `[]`. Descriptor projection writes the same record at the top level of schema-1
174
+ `arcane-package.json`, and package-only apps may author it there directly.
175
+ Omission remains omission. The native registry descriptor is unchanged.
176
+
177
+ `packageApp({target})` and `inspectApp({target})` default to `'browser'`. A
178
+ nonbrowser SDK target adds these resources to the ordinary app/shared selection.
179
+ Native exclusions apply only to the additional selection, not the browser
180
+ selection. A file selected by both is emitted once through its ordinary browser
181
+ processing. Files selected only as native resources retain their complete
182
+ original content, including imports, HTML, line endings and data. They are copied
183
+ after browser document discovery, module projection, asset rewriting and PWA
184
+ processing, and appear in the complete release inventory. A collision with
185
+ generated output reports an error instead of replacing that output.
186
+
187
+ Target and module representation are independent: `moduleFormat:'native'`
188
+ controls browser module/script packaging and does not select native resources.
189
+ Nonbrowser targets use effective `browserPwa:false`; ordinary browser calls keep
190
+ their configured PWA behavior. An app adapter receives `target` and effective
191
+ `browserPwa` in its existing `buildArcanePackage()` context. Its `copyBase()`
192
+ copies ordinary browser/shared files; the packager appends native-only files
193
+ after the adapter and browser transformations finish.
194
+
195
+ A nonbrowser target with a nonempty native include list writes its app input to
196
+ `dist/.native/<target>/<app-id>`, even when the saved browser `outputDirectory`
197
+ is custom. This keeps an existing browser/PWA output separate. An explicit
198
+ low-level `outputDirectory` override takes precedence; it must name the
199
+ dedicated output the caller intends to replace. Omitted or empty native
200
+ resources preserve the existing output rules. `inspectApp()` reports the
201
+ effective `output` and complete selected files without writing them.
202
+
203
+ Paired native `buildApplication()` applies the same selected target and output
204
+ resolution to the selected app and every explicitly bundled app. Each app keeps
205
+ its own declaration; the provider receives actual release roots and complete
206
+ release records. Native artifact `outputRoot` remains a different directory.
207
+ Use `verifyApp({workspaceRoot,appId,outputDirectory:release.output})` to inspect
208
+ that emitted app release; verification does not launch its services or host.
209
+ See [the portable service composition guide](core-native-packaging.md#native-only-application-resources).
210
+
150
211
  ## App-selected package output
151
212
 
152
- An app may set `"outputDirectory": "ai"` in its schema-1
213
+ For browser selection, an app may set `"outputDirectory": "ai"` in its schema-1
153
214
  `arcane-package.json`. This selects the final directory relative to the
154
215
  workspace: `<workspace>/ai`, not `<workspace>/ai/<app-id>`. Omitting the
155
216
  field retains `dist/<app-id>`. The root `arcane-packager.json` configuration
@@ -185,6 +246,10 @@ output must remain separate; a conflicting native assembly fails before it
185
246
  packages any app. App launch paths, resource URLs, and enabled PWA
186
247
  representations retain their package-relative layout.
187
248
 
249
+ The [native-only resource selection](#native-only-application-resources) above
250
+ adds a separate default native input directory when its include list is nonempty.
251
+ An explicit low-level output override still selects the exact directory to replace.
252
+
188
253
  ## Native-module package output
189
254
 
190
255
  The public `packageApp` operation accepts `moduleFormat:'native'`. Omission, or
@@ -193,6 +258,9 @@ The public `packageApp` operation accepts `moduleFormat:'native'`. Omission, or
193
258
  accepts that same override. Configuration, source layout, app identity, storage
194
259
  scope and previously generated sibling outputs remain unchanged.
195
260
 
261
+ This module format does not select a native target. Use the separate `target`
262
+ option for [native-only resources](#native-only-application-resources).
263
+
196
264
  The native transformation runs in the selected package stage after application
197
265
  adapter work, before the final inventory and any enabled PWA artifacts. It uses
198
266
  the existing selected document/runtime records and shared lexical/HTML owners.
@@ -2252,10 +2252,11 @@ and `read`, filters source metadata before calling
2252
2252
  ### Availability and normalization
2253
2253
 
2254
2254
  **Browser or compatible host with an injected DBOPFS adapter.** The adapter
2255
- keeps the existing `get`, `set`, `getAllKeys`, and `delete` method names; Node
2256
- can use the same class only through an explicitly imported runtime module and a
2257
- compatible storage adapter; SDK `0.5.12` publishes no Node package subpath or
2258
- Node storage implementation for it. Bootstrap uses a concurrent
2255
+ keeps the existing `get`, `set`, `getAllKeys`, and `delete` method names. Node
2256
+ callers import the same class and factory from the public
2257
+ `arcane-os/dbopfs-document-library` subpath and supply a compatible storage
2258
+ adapter. That export supplies no Node filesystem storage implementation.
2259
+ Bootstrap uses a concurrent
2259
2260
  generation, commits its manifest last, cleans partial data on failure, and
2260
2261
  rejects case-colliding IDs. Search
2261
2262
  returns `{failures,matches,total}` so one malformed record remains visible
@@ -2414,7 +2415,7 @@ const search = new DocumentLexicalSearch([{
2414
2415
  kind: 'guide',
2415
2416
  tags: ['intro']
2416
2417
  }]);
2417
- console.log(search.search('portable', {limit: 5}));
2418
+ console.log(search.search('portable'));
2418
2419
  ```
2419
2420
 
2420
2421
  ## DocumentNavigation.js