@qvac/sdk 0.22.0 → 0.24.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.
- package/NOTICE +194 -97
- package/README.md +29 -470
- package/dist/examples/asr/parakeet-sortformer.js +24 -14
- package/dist/examples/asr/parakeet-transcribepsy-filesystem.d.ts +2 -0
- package/dist/examples/asr/parakeet-transcribepsy-filesystem.js +105 -0
- package/dist/examples/asr/parakeet-unified-coreml.js +14 -9
- package/dist/examples/asr/whispercpp-prompt.js +9 -5
- package/dist/examples/assess-model-fit.d.ts +7 -9
- package/dist/examples/assess-model-fit.js +22 -43
- package/dist/examples/calc-tokens.d.ts +2 -0
- package/dist/examples/calc-tokens.js +21 -0
- package/dist/examples/classification/classify-image.js +11 -5
- package/dist/examples/completion-stop-reason.d.ts +3 -3
- package/dist/examples/completion-stop-reason.js +4 -4
- package/dist/examples/diffusion-flux3-klein.d.ts +2 -0
- package/dist/examples/diffusion-flux3-klein.js +102 -0
- package/dist/examples/diffusion-img2vid-ltx.js +7 -14
- package/dist/examples/diffusion-moss-image.d.ts +2 -0
- package/dist/examples/diffusion-moss-image.js +126 -0
- package/dist/examples/diffusion-qwen-image-21.d.ts +2 -0
- package/dist/examples/diffusion-qwen-image-21.js +115 -0
- package/dist/examples/diffusion-txt2vid-ltx.js +7 -14
- package/dist/examples/embed-multimodal.d.ts +2 -0
- package/dist/examples/embed-multimodal.js +80 -0
- package/dist/examples/embed-p2p.js +2 -2
- package/dist/examples/finetune/llamacpp-finetune.js +9 -4
- package/dist/examples/image/megaloc.d.ts +2 -0
- package/dist/examples/image/megaloc.js +37 -0
- package/dist/examples/llamacpp-multimodal.js +21 -1
- package/dist/examples/mcp-websearch.js +1 -1
- package/dist/examples/plugins.js +1 -1
- package/dist/examples/rag/rag-hyperdb/pipeline.js +2 -2
- package/dist/examples/rag/rag-turbovec.js +2 -2
- package/dist/examples/rerank.d.ts +2 -0
- package/dist/examples/rerank.js +33 -0
- package/dist/examples/sessions.d.ts +17 -0
- package/dist/examples/sessions.js +63 -0
- package/dist/examples/tools/llamacpp-deferred-tools.js +12 -8
- package/dist/examples/tools/llamacpp-tools-auto-dialect.js +4 -3
- package/dist/examples/tools/llamacpp-tools-gemma4.js +3 -3
- package/dist/examples/tools/llamacpp-tools-qwen35.js +4 -3
- package/dist/scripts/check-resource-collectors-packaging.js +7 -6
- package/dist/scripts/contract/build-contract.d.ts +2 -1
- package/dist/scripts/contract/build-contract.js +13 -1
- package/dist/scripts/contract/constants-registry.d.ts +19 -0
- package/dist/scripts/contract/constants-registry.js +9 -2
- package/dist/scripts/contract/method-shapes.d.ts +5 -0
- package/dist/scripts/contract/method-shapes.js +5 -0
- package/dist/scripts/enforce-inference-versions.d.ts +1 -1
- package/dist/scripts/enforce-inference-versions.js +28 -18
- package/dist/scripts/generate-bare-kit-runtimes.js +101 -69
- package/dist/src/client/api/assess-model-fit.d.ts +17 -17
- package/dist/src/client/api/assess-model-fit.js +19 -32
- package/dist/src/client/api/audio-edit.d.ts +5 -3
- package/dist/src/client/api/audio-edit.js +7 -5
- package/dist/src/client/api/audio-gen-result.js +136 -47
- package/dist/src/client/api/audio-gen.d.ts +40 -3
- package/dist/src/client/api/audio-gen.js +42 -5
- package/dist/src/client/api/audio-understand.d.ts +2 -2
- package/dist/src/client/api/audio-understand.js +4 -4
- package/dist/src/client/api/batch-completion.js +4 -3
- package/dist/src/client/api/bci-transcribe.js +3 -3
- package/dist/src/client/api/calc-tokens.d.ts +33 -0
- package/dist/src/client/api/calc-tokens.js +44 -0
- package/dist/src/client/api/cancel.d.ts +2 -2
- package/dist/src/client/api/cancel.js +3 -3
- package/dist/src/client/api/classify.d.ts +12 -5
- package/dist/src/client/api/classify.js +18 -6
- package/dist/src/client/api/client-request-id.d.ts +0 -15
- package/dist/src/client/api/client-request-id.js +15 -12
- package/dist/src/client/api/completion-stream.d.ts +9 -1
- package/dist/src/client/api/completion-stream.js +14 -3
- package/dist/src/client/api/decide.d.ts +1 -1
- package/dist/src/client/api/decide.js +3 -3
- package/dist/src/client/api/delete-cache.d.ts +9 -2
- package/dist/src/client/api/delete-cache.js +14 -4
- package/dist/src/client/api/diffusion.d.ts +38 -5
- package/dist/src/client/api/diffusion.js +42 -7
- package/dist/src/client/api/download-asset.js +3 -3
- package/dist/src/client/api/embed.d.ts +82 -29
- package/dist/src/client/api/embed.js +66 -21
- package/dist/src/client/api/finetune.js +3 -3
- package/dist/src/client/api/get-loaded-model-info.js +1 -1
- package/dist/src/client/api/get-model-info.d.ts +2 -2
- package/dist/src/client/api/get-model-info.js +3 -3
- package/dist/src/client/api/get-system-resources.d.ts +2 -2
- package/dist/src/client/api/get-system-resources.js +3 -3
- package/dist/src/client/api/heartbeat.d.ts +3 -2
- package/dist/src/client/api/heartbeat.js +4 -3
- package/dist/src/client/api/index.d.ts +8 -6
- package/dist/src/client/api/index.js +6 -4
- package/dist/src/client/api/invoke-plugin.d.ts +8 -2
- package/dist/src/client/api/invoke-plugin.js +18 -3
- package/dist/src/client/api/load-model.js +9 -6
- package/dist/src/client/api/logging-stream.d.ts +11 -2
- package/dist/src/client/api/logging-stream.js +12 -3
- package/dist/src/client/api/ocr.d.ts +5 -3
- package/dist/src/client/api/ocr.js +45 -22
- package/dist/src/client/api/rag.d.ts +1 -1
- package/dist/src/client/api/rag.js +3 -3
- package/dist/src/client/api/registry.d.ts +19 -8
- package/dist/src/client/api/registry.js +43 -17
- package/dist/src/client/api/rerank.d.ts +22 -0
- package/dist/src/client/api/rerank.js +39 -0
- package/dist/src/client/api/resume.d.ts +2 -1
- package/dist/src/client/api/resume.js +3 -3
- package/dist/src/client/api/rpc-server.d.ts +4 -4
- package/dist/src/client/api/rpc-server.js +12 -12
- package/dist/src/client/api/state.d.ts +2 -2
- package/dist/src/client/api/state.js +3 -3
- package/dist/src/client/api/subscribe-logs.d.ts +2 -2
- package/dist/src/client/api/subscribe-logs.js +4 -3
- package/dist/src/client/api/suspend.d.ts +4 -2
- package/dist/src/client/api/suspend.js +5 -4
- package/dist/src/client/api/text-to-speech.d.ts +14 -5
- package/dist/src/client/api/text-to-speech.js +86 -32
- package/dist/src/client/api/transcribe.d.ts +7 -3
- package/dist/src/client/api/transcribe.js +9 -3
- package/dist/src/client/api/translate.js +2 -2
- package/dist/src/client/api/unload-model.d.ts +19 -7
- package/dist/src/client/api/unload-model.js +31 -13
- package/dist/src/client/api/upscale.d.ts +6 -3
- package/dist/src/client/api/upscale.js +10 -5
- package/dist/src/client/api/vector-index.d.ts +51 -17
- package/dist/src/client/api/vector-index.js +101 -49
- package/dist/src/client/api/video-request.d.ts +5 -5
- package/dist/src/client/api/video.d.ts +3 -2
- package/dist/src/client/api/video.js +6 -5
- package/dist/src/client/api/vla.d.ts +9 -5
- package/dist/src/client/api/vla.js +17 -8
- package/dist/src/client/api/world-result.js +2 -2
- package/dist/src/client/api/world.d.ts +6 -6
- package/dist/src/client/api/world.js +6 -6
- package/dist/src/client/init-hooks.d.ts +6 -4
- package/dist/src/client/init-hooks.js +12 -15
- package/dist/src/client/logging-stream-registry.d.ts +6 -3
- package/dist/src/client/logging-stream-registry.js +36 -14
- package/dist/src/client/plugins-factory.d.ts +1 -1
- package/dist/src/client/plugins-factory.js +1 -1
- package/dist/src/client/rpc/bundle-stamp.d.ts +29 -0
- package/dist/src/client/rpc/bundle-stamp.js +75 -0
- package/dist/src/client/rpc/expo-home-dir.d.ts +2 -0
- package/dist/src/client/rpc/expo-home-dir.js +4 -0
- package/dist/src/client/rpc/expo-rpc-client.js +192 -138
- package/dist/src/client/rpc/node-rpc-client.js +324 -426
- package/dist/src/client/rpc/pear-runtime.d.ts +12 -0
- package/dist/src/client/rpc/pear-runtime.js +12 -0
- package/dist/src/client/rpc/rpc-client.d.ts +6 -4
- package/dist/src/client/rpc/rpc-client.js +168 -31
- package/dist/src/client/rpc/rpc-error.js +24 -2
- package/dist/src/client/rpc/unbundled-harness.d.ts +16 -0
- package/dist/src/client/rpc/unbundled-harness.js +27 -0
- package/dist/src/client/rpc/worker-failure.d.ts +27 -0
- package/dist/src/client/rpc/worker-failure.js +61 -0
- package/dist/src/client/session-registry.d.ts +75 -0
- package/dist/src/client/session-registry.js +149 -0
- package/dist/src/client/session.d.ts +125 -0
- package/dist/src/client/session.js +148 -0
- package/dist/src/commands/bundle/addons.d.ts +14 -0
- package/dist/src/commands/bundle/addons.js +65 -0
- package/dist/src/commands/bundle/constants.js +2 -0
- package/dist/src/commands/bundle/entry-gen.d.ts +1 -5
- package/dist/src/commands/bundle/entry-gen.js +18 -51
- package/dist/src/commands/bundle/index.d.ts +60 -14
- package/dist/src/commands/bundle/index.js +350 -126
- package/dist/src/commands/bundle/link.d.ts +58 -0
- package/dist/src/commands/bundle/link.js +135 -0
- package/dist/src/commands/bundle/node-support.d.ts +13 -0
- package/dist/src/commands/bundle/node-support.js +23 -0
- package/dist/src/commands/bundle/plugins.js +1 -1
- package/dist/src/commands/bundle/read-bundle.d.ts +9 -0
- package/dist/src/commands/bundle/read-bundle.js +27 -0
- package/dist/src/commands/bundle/resolve-sdk-import.d.ts +6 -0
- package/dist/src/commands/bundle/resolve-sdk-import.js +24 -28
- package/dist/src/commands/bundle/scratch.d.ts +35 -0
- package/dist/src/commands/bundle/scratch.js +178 -0
- package/dist/src/commands/bundle/targets.d.ts +14 -0
- package/dist/src/commands/bundle/targets.js +37 -0
- package/dist/src/commands/host-prebuilds/index.d.ts +8 -7
- package/dist/src/commands/host-prebuilds/index.js +13 -11
- package/dist/src/commands/index.d.ts +13 -12
- package/dist/src/commands/index.js +7 -7
- package/dist/src/commands/verify/abi.d.ts +21 -15
- package/dist/src/commands/verify/abi.js +12 -80
- package/dist/src/commands/verify/bare-kit-runtime.d.ts +20 -22
- package/dist/src/commands/verify/bare-kit-runtime.js +102 -150
- package/dist/src/commands/verify/bare-kit-runtimes.d.ts +10 -9
- package/dist/src/commands/verify/bare-kit-runtimes.js +21 -21
- package/dist/src/commands/verify/bundle-source.d.ts +1 -1
- package/dist/src/commands/verify/bundle-source.js +27 -23
- package/dist/src/commands/verify/engines-advice.d.ts +6 -12
- package/dist/src/commands/verify/engines-advice.js +9 -56
- package/dist/src/commands/verify/index.d.ts +34 -33
- package/dist/src/commands/verify/index.js +96 -204
- package/dist/src/commands/verify/node-modules-source.d.ts +1 -1
- package/dist/src/commands/verify/node-modules-source.js +1 -1
- package/dist/src/commands/verify/prebuilds.d.ts +4 -6
- package/dist/src/commands/verify/prebuilds.js +3 -4
- package/dist/src/commands/verify/resource-collectors.d.ts +0 -6
- package/dist/src/commands/verify/resource-collectors.js +3 -52
- package/dist/src/commands/verify/sidecar-runtime.d.ts +6 -0
- package/dist/src/commands/verify/sidecar-runtime.js +51 -0
- package/dist/src/expo/plugins/get-project-root.d.ts +1 -1
- package/dist/src/expo/plugins/withAndroidArchitecture.d.ts +1 -1
- package/dist/src/expo/plugins/withAndroidNdkVersion.d.ts +1 -1
- package/dist/src/expo/plugins/withAndroidNdkVersion.js +16 -10
- package/dist/src/expo/plugins/withBareKit.d.ts +59 -0
- package/dist/src/expo/plugins/withBareKit.js +204 -0
- package/dist/src/expo/plugins/withDeviceInfo.d.ts +1 -1
- package/dist/src/expo/plugins/withDeviceInfo.js +19 -5
- package/dist/src/expo/plugins/withMobileBundle.d.ts +5 -12
- package/dist/src/expo/plugins/withMobileBundle.js +38 -59
- package/dist/src/expo/plugins/withOpenCL.d.ts +1 -1
- package/dist/src/expo/plugins/withQvacSDK.d.ts +2 -1
- package/dist/src/expo/plugins/withQvacSDK.js +3 -0
- package/dist/src/index.d.ts +6 -5
- package/dist/src/index.js +10 -14
- package/dist/src/logging/addon.d.ts +1 -1
- package/dist/src/logging/base-logger.js +1 -1
- package/dist/src/logging/utils.js +11 -3
- package/dist/src/plugin-ids.d.ts +3 -1
- package/dist/src/plugin-ids.js +4 -0
- package/dist/src/schemas/public.d.ts +1 -1
- package/dist/src/schemas/public.js +1 -1
- package/dist/src/schemas/sdk-errors-client.d.ts +5 -6
- package/dist/src/schemas/sdk-errors-client.js +30 -36
- package/dist/src/schemas/sdk-errors-server.d.ts +12 -1
- package/dist/src/schemas/sdk-errors-server.js +65 -2
- package/dist/src/server/rpc/rpc-utils.d.ts +26 -0
- package/dist/src/server/rpc/rpc-utils.js +41 -0
- package/dist/src/utils/aggregate-events.d.ts +1 -1
- package/dist/src/utils/aggregate-events.js +2 -2
- package/dist/src/utils/errors-client.d.ts +37 -29
- package/dist/src/utils/errors-client.js +50 -41
- package/dist/src/utils/errors-server.d.ts +65 -1
- package/dist/src/utils/errors-server.js +122 -1
- package/dist/src/utils/mcp-adapter.d.ts +1 -1
- package/dist/src/utils/mcp-adapter.js +1 -1
- package/dist/src/utils/tool-helpers.js +1 -1
- package/dist/src/utils/withTimeout.js +34 -17
- package/dist/src/worker/handle-request.js +26 -21
- package/dist/src/worker/handler-utils.d.ts +2 -6
- package/dist/src/worker/handler-utils.js +2 -20
- package/dist/src/worker/index.d.ts +2 -4
- package/dist/src/worker/index.js +24 -34
- package/dist/src/worker/plugins/ggml-image-embedding.d.ts +2 -0
- package/dist/src/worker/plugins/ggml-image-embedding.js +1 -0
- package/dist/src/worker/plugins/llamacpp-rerank.d.ts +2 -0
- package/dist/src/worker/plugins/llamacpp-rerank.js +1 -0
- package/dist/src/worker/shim.d.ts +4 -0
- package/dist/src/worker/shim.js +7 -0
- package/dist/src/worker/start.d.ts +9 -0
- package/dist/src/worker/start.js +16 -0
- package/dist/src/worker/unbundled-shim.d.ts +2 -0
- package/dist/src/worker/unbundled-shim.js +4 -0
- package/docs/system-resources-support-matrix.md +27 -19
- package/package.json +91 -74
- package/src/electron-forge/index.cjs +65 -91
- package/dist/examples/model-fit-ui/server.d.ts +0 -24
- package/dist/examples/model-fit-ui/server.js +0 -221
- package/dist/src/client/rpc/ensure-worker-ready.d.ts +0 -9
- package/dist/src/client/rpc/ensure-worker-ready.js +0 -17
- package/dist/src/client/rpc/init-timeout.d.ts +0 -26
- package/dist/src/client/rpc/init-timeout.js +0 -25
- package/dist/src/client/rpc/worker-startup-error.d.ts +0 -12
- package/dist/src/client/rpc/worker-startup-error.js +0 -13
- package/dist/src/commands/bundle/bare-pack.d.ts +0 -21
- package/dist/src/commands/bundle/bare-pack.js +0 -77
- package/dist/src/commands/bundle/manifest.d.ts +0 -25
- package/dist/src/commands/bundle/manifest.js +0 -192
- package/dist/src/expo/plugins/link-addons.d.ts +0 -18
- package/dist/src/expo/plugins/link-addons.js +0 -65
- package/dist/src/pear/pre.d.ts +0 -21
- package/dist/src/pear/pre.js +0 -448
- package/dist/src/server/env.d.ts +0 -22
- package/dist/src/server/env.js +0 -59
- package/dist/src/server/utils/qvac-paths.d.ts +0 -2
- package/dist/src/server/utils/qvac-paths.js +0 -5
- package/dist/src/server/utils/worker-lock.d.ts +0 -3
- package/dist/src/server/utils/worker-lock.js +0 -67
- package/dist/src/worker/create-server.d.ts +0 -8
- package/dist/src/worker/create-server.js +0 -51
- package/dist/src/worker/lifecycle.d.ts +0 -23
- package/dist/src/worker/lifecycle.js +0 -149
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Two caller sessions on one runtime.
|
|
3
|
+
*
|
|
4
|
+
* Each session gets its own requests and model leases:
|
|
5
|
+
*
|
|
6
|
+
* - Both sessions load the same configuration and get the same `modelId`;
|
|
7
|
+
* the second load adds a lease instead of loading the model again.
|
|
8
|
+
* - A session's `cancel({ requestId })` reaches only its own requests, so
|
|
9
|
+
* the second session's cancel leaves the first session's completion
|
|
10
|
+
* running; the first session's own cancel stops it.
|
|
11
|
+
* - `unloadModel()` releases the caller's lease. The model unloads when its
|
|
12
|
+
* last lease is released, here when the second session closes.
|
|
13
|
+
*
|
|
14
|
+
* Only the module-level `close()` stops the runtime; it ends every session.
|
|
15
|
+
*/
|
|
16
|
+
import { close, getLoadedModelInfo, openSession, QWEN3_600M_INST_Q4 } from '@qvac/sdk';
|
|
17
|
+
try {
|
|
18
|
+
const harness = openSession({ name: 'harness' });
|
|
19
|
+
const skillRunner = openSession({ name: 'skill-runner' });
|
|
20
|
+
const modelId = await harness.loadModel({
|
|
21
|
+
modelSrc: QWEN3_600M_INST_Q4,
|
|
22
|
+
modelConfig: { ctx_size: 4096 }
|
|
23
|
+
});
|
|
24
|
+
const sameModelId = await skillRunner.loadModel({
|
|
25
|
+
modelSrc: QWEN3_600M_INST_Q4,
|
|
26
|
+
modelConfig: { ctx_size: 4096 }
|
|
27
|
+
});
|
|
28
|
+
const { leaseCount } = await getLoadedModelInfo({ modelId });
|
|
29
|
+
console.log(`▸ same model for both sessions: ${modelId === sameModelId}, leases: ${leaseCount}`);
|
|
30
|
+
const run = harness.completion({
|
|
31
|
+
modelId,
|
|
32
|
+
history: [{ role: 'user', content: 'Write a long essay about the history of Rome.' }],
|
|
33
|
+
stream: true
|
|
34
|
+
});
|
|
35
|
+
// The skill runner cannot reach the harness's request.
|
|
36
|
+
await skillRunner.cancel({ requestId: run.requestId });
|
|
37
|
+
let deltasAfterForeignCancel = 0;
|
|
38
|
+
let stopReason;
|
|
39
|
+
for await (const event of run.events) {
|
|
40
|
+
if (event.type === 'contentDelta') {
|
|
41
|
+
deltasAfterForeignCancel++;
|
|
42
|
+
// The harness stops its own completion after a few more tokens.
|
|
43
|
+
if (deltasAfterForeignCancel === 5)
|
|
44
|
+
await harness.cancel({ requestId: run.requestId });
|
|
45
|
+
}
|
|
46
|
+
else if (event.type === 'completionDone') {
|
|
47
|
+
stopReason = event.stopReason;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
console.log(`▸ ${deltasAfterForeignCancel} tokens arrived after skill-runner's cancel; harness's cancel ended the run: stopReason=${stopReason}`);
|
|
51
|
+
const result = await harness.unloadModel({ modelId });
|
|
52
|
+
console.log(`▸ harness unload: released=${result.released}, unloaded=${result.unloaded}`);
|
|
53
|
+
// Closing a session releases its leases; this was the model's last one.
|
|
54
|
+
await skillRunner.close();
|
|
55
|
+
console.log('▸ skill-runner closed and released the last lease');
|
|
56
|
+
await harness.close();
|
|
57
|
+
await close();
|
|
58
|
+
process.exit(0);
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
console.error('✖', error);
|
|
62
|
+
process.exit(1);
|
|
63
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// Deferred tool loading: a large tool set stays out of the prompt until the
|
|
2
2
|
// model asks for it. Only `get_weather` and the built-in `tool_search` (whose
|
|
3
3
|
// description carries a name-and-description catalog of the rest) are in the
|
|
4
|
-
// initial prompt;
|
|
5
|
-
//
|
|
4
|
+
// initial prompt; a deferred schema is declared in the prompt once the model
|
|
5
|
+
// has searched for it.
|
|
6
6
|
import { TOOL_SEARCH_NAME, completion, executeToolSearch, loadModel, unloadModel, QWEN3_1_7B_INST_Q4 } from '@qvac/sdk';
|
|
7
7
|
import { z } from 'zod';
|
|
8
8
|
import { weatherSchema, horoscopeSchema, mockExecute } from './shared.js';
|
|
@@ -33,6 +33,9 @@ try {
|
|
|
33
33
|
modelConfig: { ctx_size: 4096, tools: true }
|
|
34
34
|
});
|
|
35
35
|
console.log(`▸ Model loaded. Model ID: ${modelId}`);
|
|
36
|
+
// One search loads at most two definitions, one unless the model asks for
|
|
37
|
+
// more. Keep these the same for the whole conversation.
|
|
38
|
+
const params = { modelId, tools, toolSearch: { defaultLimit: 1, maxLimit: 2 } };
|
|
36
39
|
const history = [
|
|
37
40
|
{
|
|
38
41
|
role: 'system',
|
|
@@ -41,7 +44,7 @@ try {
|
|
|
41
44
|
{ role: 'user', content: "What's my horoscope for Aquarius?" }
|
|
42
45
|
];
|
|
43
46
|
console.log('\n▸ Turn 1 — only get_weather and tool_search are in the prompt\n');
|
|
44
|
-
const first = completion({
|
|
47
|
+
const first = completion({ ...params, history, stream: true });
|
|
45
48
|
for await (const token of first.tokenStream)
|
|
46
49
|
process.stdout.write(token);
|
|
47
50
|
const calls = await first.toolCalls;
|
|
@@ -52,15 +55,16 @@ try {
|
|
|
52
55
|
else {
|
|
53
56
|
console.log(`\n\n▸ The model searched: ${JSON.stringify(search.arguments)}`);
|
|
54
57
|
// Running the search is the SDK's job, not a tool handler's. The result is
|
|
55
|
-
// an ordinary tool message
|
|
56
|
-
//
|
|
58
|
+
// an ordinary tool message naming what it loaded: keeping it in the history
|
|
59
|
+
// is what declares those definitions on the next turn. Passing the same
|
|
60
|
+
// params applies the limits the model was told.
|
|
57
61
|
history.push({ role: 'assistant', content: await first.text });
|
|
58
62
|
history.push({
|
|
59
63
|
role: 'tool',
|
|
60
|
-
content: executeToolSearch(
|
|
64
|
+
content: executeToolSearch(params, search.arguments, history)
|
|
61
65
|
});
|
|
62
|
-
console.log('▸ Definitions
|
|
63
|
-
const second = completion({
|
|
66
|
+
console.log('▸ Definitions loaded. Turn 2 — the model can now call them directly.\n');
|
|
67
|
+
const second = completion({ ...params, history, stream: true });
|
|
64
68
|
for await (const token of second.tokenStream)
|
|
65
69
|
process.stdout.write(token);
|
|
66
70
|
for (const call of await second.toolCalls) {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Tool-calling example with automatic dialect detection.
|
|
3
3
|
*
|
|
4
|
-
* The SDK infers the tool-call format from the model name
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* The SDK infers the tool-call format from the model name or file name, and
|
|
5
|
+
* from the GGUF architecture when the name matches no known pattern. It
|
|
6
|
+
* supports model families such as Qwen3.5/3.6/3.8, Gemma4, GPT-OSS,
|
|
7
|
+
* DeepSeek V3.2/V4, and LFM without requiring a toolDialect override.
|
|
7
8
|
*
|
|
8
9
|
* Usage:
|
|
9
10
|
* node dist/examples/tools/llamacpp-tools-auto-dialect.js <model-src>
|
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
* frames, which are stripped from contentDelta and forwarded as thinkingDelta
|
|
9
9
|
* when captureThinking is true.
|
|
10
10
|
*
|
|
11
|
-
* The dialect is auto-detected
|
|
12
|
-
*
|
|
13
|
-
* completion() if
|
|
11
|
+
* The dialect is auto-detected when the model name or file name contains
|
|
12
|
+
* "gemma4" or "gemma-4", or when the GGUF architecture is `gemma4`. Pass
|
|
13
|
+
* toolDialect: "gemma4" explicitly to completion() if detection does not pick it up.
|
|
14
14
|
*
|
|
15
15
|
* Usage:
|
|
16
16
|
* node dist/examples/tools/llamacpp-tools-gemma4.js <model-url>
|
|
@@ -4,9 +4,10 @@
|
|
|
4
4
|
* Qwen3.5 emits tool calls in a Pythonic-XML format:
|
|
5
5
|
* <tool_call><function=NAME><parameter=KEY>VALUE</parameter></function></tool_call>
|
|
6
6
|
*
|
|
7
|
-
* The dialect is auto-detected
|
|
8
|
-
*
|
|
9
|
-
* toolDialect: "qwen35" explicitly if
|
|
7
|
+
* The dialect is auto-detected when the model name or file name contains
|
|
8
|
+
* "qwen3.5", "qwen3-5", "qwen3.6", or "qwen3-6", or when the GGUF architecture is
|
|
9
|
+
* `qwen35` or `qwen35moe`. Pass toolDialect: "qwen35" explicitly if detection
|
|
10
|
+
* does not pick it up.
|
|
10
11
|
*
|
|
11
12
|
* Usage:
|
|
12
13
|
* node dist/examples/tools/llamacpp-tools-qwen35.js <model-url>
|
|
@@ -60,21 +60,22 @@ export function resolveDesktopHost(platform, arch) {
|
|
|
60
60
|
return validateDesktopHost(`${platform}-${arch}`);
|
|
61
61
|
}
|
|
62
62
|
export async function runResourceCollectorPackagingCheck(options, dependencies = DEFAULT_DEPENDENCIES) {
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
: [resolveDesktopHost(options.platform ?? process.platform, options.arch ?? process.arch)];
|
|
63
|
+
const ownHost = resolveDesktopHost(options.platform ?? process.platform, options.arch ?? process.arch);
|
|
64
|
+
const hosts = options.hosts.length > 0 ? options.hosts : [ownHost];
|
|
66
65
|
const temporaryProjectRoot = await dependencies.createTemporaryProject(options.sdkPackageRoot);
|
|
67
66
|
try {
|
|
67
|
+
// Acceptance reads each host's prebuilds from the collector packages; the
|
|
68
|
+
// bundle only shows which collectors the worker links.
|
|
68
69
|
const bundle = await dependencies.bundleSdk({
|
|
69
70
|
projectRoot: temporaryProjectRoot,
|
|
70
71
|
sdkPath: options.sdkPackageRoot,
|
|
71
|
-
hosts,
|
|
72
|
-
quiet: true
|
|
72
|
+
hosts: [ownHost],
|
|
73
|
+
quiet: true,
|
|
74
|
+
verify: false
|
|
73
75
|
});
|
|
74
76
|
const report = await dependencies.acceptResourceCollectorPackaging({
|
|
75
77
|
projectRoot: temporaryProjectRoot,
|
|
76
78
|
bundlePath: bundle.bundlePath,
|
|
77
|
-
manifestPath: bundle.manifestPath,
|
|
78
79
|
hosts
|
|
79
80
|
});
|
|
80
81
|
const output = options.json
|
|
@@ -21,7 +21,8 @@ export declare function buildContract(): {
|
|
|
21
21
|
condition: string;
|
|
22
22
|
responseSchema: string;
|
|
23
23
|
};
|
|
24
|
-
|
|
24
|
+
ownerOnly?: boolean;
|
|
25
|
+
name: "audioGenStream" | "audioEditStream" | "audioUnderstand" | "startRpcServer" | "stopRpcServer" | "discoverRpcServers" | "heartbeat" | "calcTokens" | "openSession" | "closeSession" | "loadModel" | "downloadAsset" | "completionStream" | "completionOrchestrate" | "batchCompletionStream" | "unloadModel" | "transcribe" | "transcribeStream" | "bciTranscribe" | "bciTranscribeStream" | "loggingStream" | "embed" | "embedBatch" | "translate" | "textToSpeech" | "textToSpeechStream" | "cancel" | "rerank" | "vectorIndex" | "finetune" | "rag" | "deleteCache" | "getModelInfo" | "getLoadedModelInfo" | "getSystemResources" | "assessModelFit" | "ocrStream" | "diffusionStream" | "videoStream" | "upscaleStream" | "worldSceneStream" | "worldStepStream" | "resume" | "pluginInvoke" | "pluginInvokeStream" | "modelRegistryList" | "modelRegistrySearch" | "modelRegistryGetModel" | "suspend" | "state" | "classify" | "decide";
|
|
25
26
|
callShape: "duplex" | "request-reply" | "server-stream";
|
|
26
27
|
requestSchema: string;
|
|
27
28
|
responseSchema: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { fileURLToPath } from 'node:url';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import prettier from 'prettier';
|
|
4
|
-
import { requestSchema, responseSchema } from '@qvac/inference/surface';
|
|
4
|
+
import { OWNER_ONLY_OPERATIONS, requestSchema, responseSchema } from '@qvac/inference/surface';
|
|
5
5
|
import { methodShapes } from './method-shapes.js';
|
|
6
6
|
import { constantsRegistry } from './constants-registry.js';
|
|
7
7
|
import { buildModelsRegistry } from './build-models-registry.js';
|
|
@@ -525,6 +525,17 @@ const progressByMethod = {
|
|
|
525
525
|
responseType: 'finetune:progress'
|
|
526
526
|
}
|
|
527
527
|
};
|
|
528
|
+
/**
|
|
529
|
+
* Methods only the owner client may call: the ones the worker refuses from a
|
|
530
|
+
* session, and session management, since a session must not open or close
|
|
531
|
+
* sessions by naming their ids. Generated clients leave them off a session
|
|
532
|
+
* handle.
|
|
533
|
+
*/
|
|
534
|
+
const ownerOnlyMethods = new Set([
|
|
535
|
+
...OWNER_ONLY_OPERATIONS,
|
|
536
|
+
'openSession',
|
|
537
|
+
'closeSession'
|
|
538
|
+
]);
|
|
528
539
|
export function buildContract() {
|
|
529
540
|
const methodNames = Object.keys(methodShapes).sort();
|
|
530
541
|
const requestByType = collectByWireType(requestSchema.options, 'request');
|
|
@@ -612,6 +623,7 @@ export function buildContract() {
|
|
|
612
623
|
callShape: callShapeByHandlerType[methodShapes[name]],
|
|
613
624
|
requestSchema: `schema.json#/$defs/${name}.request`,
|
|
614
625
|
responseSchema: `schema.json#/$defs/${name}.response`,
|
|
626
|
+
...(ownerOnlyMethods.has(name) && { ownerOnly: true }),
|
|
615
627
|
...(progress && {
|
|
616
628
|
progress: {
|
|
617
629
|
condition: progress.condition,
|
|
@@ -30,6 +30,7 @@ export declare const constantsRegistry: {
|
|
|
30
30
|
readonly bciWhispercppTranscription: "bci-whispercpp-transcription";
|
|
31
31
|
readonly llamacppEmbedding: "llamacpp-embedding";
|
|
32
32
|
readonly llamacppDecision: "llamacpp-decision";
|
|
33
|
+
readonly llamacppRerank: "llamacpp-rerank";
|
|
33
34
|
readonly nmtcppTranslation: "nmtcpp-translation";
|
|
34
35
|
readonly onnxTts: "onnx-tts";
|
|
35
36
|
readonly ttsGgml: "tts-ggml";
|
|
@@ -39,6 +40,7 @@ export declare const constantsRegistry: {
|
|
|
39
40
|
readonly sdcppGeneration: "sdcpp-generation";
|
|
40
41
|
readonly audiogenGgml: "audiogen-ggml";
|
|
41
42
|
readonly ggmlVla: "ggml-vla";
|
|
43
|
+
readonly ggmlImageEmbedding: "ggml-image-embedding";
|
|
42
44
|
readonly ggmlClassification: "ggml-classification";
|
|
43
45
|
}>;
|
|
44
46
|
readonly Verbosity: z.ZodEnum<{
|
|
@@ -51,6 +53,8 @@ export declare const constantsRegistry: {
|
|
|
51
53
|
readonly LLM: "@qvac/sdk/llamacpp-completion/plugin";
|
|
52
54
|
readonly EMBEDDING: "@qvac/sdk/llamacpp-embedding/plugin";
|
|
53
55
|
readonly DECISION: "@qvac/sdk/llamacpp-decision/plugin";
|
|
56
|
+
readonly RERANK: "@qvac/sdk/llamacpp-rerank/plugin";
|
|
57
|
+
readonly IMAGE_EMBEDDING: "@qvac/sdk/ggml-image-embedding/plugin";
|
|
54
58
|
readonly WHISPER: "@qvac/sdk/whispercpp-transcription/plugin";
|
|
55
59
|
readonly BCI: "@qvac/sdk/bci-whispercpp-transcription/plugin";
|
|
56
60
|
readonly MOSS_TRANSCRIBE: "@qvac/sdk/moss-transcribe/plugin";
|
|
@@ -95,6 +99,15 @@ export declare const constantsRegistry: {
|
|
|
95
99
|
readonly TtsCosyvoice3InstructStyle: z.ZodEnum<{
|
|
96
100
|
[k: string]: string;
|
|
97
101
|
}>;
|
|
102
|
+
readonly TtsParlerCoremlComputeUnits: z.ZodEnum<{
|
|
103
|
+
[k: string]: string;
|
|
104
|
+
}>;
|
|
105
|
+
readonly TtsLavasrCoremlComputeUnits: z.ZodEnum<{
|
|
106
|
+
[k: string]: string;
|
|
107
|
+
}>;
|
|
108
|
+
readonly TtsSupertonicPrecision: z.ZodEnum<{
|
|
109
|
+
[k: string]: string;
|
|
110
|
+
}>;
|
|
98
111
|
readonly AudioGenEngine: z.ZodEnum<{
|
|
99
112
|
[k: string]: string;
|
|
100
113
|
}>;
|
|
@@ -110,6 +123,12 @@ export declare const constantsRegistry: {
|
|
|
110
123
|
readonly AudioGenTrack: z.ZodEnum<{
|
|
111
124
|
[k: string]: string;
|
|
112
125
|
}>;
|
|
126
|
+
readonly AudioGenOutputFormat: z.ZodEnum<{
|
|
127
|
+
[k: string]: string;
|
|
128
|
+
}>;
|
|
129
|
+
readonly AudioGenMinimaxCoremlComputeUnits: z.ZodEnum<{
|
|
130
|
+
[k: string]: string;
|
|
131
|
+
}>;
|
|
113
132
|
readonly VectorIndexStorage: z.ZodEnum<{
|
|
114
133
|
readonly F32: "f32";
|
|
115
134
|
readonly Q8: "q8";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { ModelType, VERBOSITY, SUPPORTED_AUDIO_FORMATS, AUDIOGEN_ENGINES, AUDIOGEN_TASK_TYPES, AUDIOGEN_EDIT_OPERATIONS, AUDIOGEN_REPAINT_MODES, AUDIOGEN_TRACKS, TTS_ENGINES, TTS_PACES, TTS_PARLER_EMOTIONS, TTS_SENTENCE_DELIMITER_PRESETS, TTS_CHATTERBOX_LANGUAGES, TTS_SUPERTONIC_LANGUAGES, TTS_COSYVOICE3_EMOTIONS, TTS_COSYVOICE3_INSTRUCT_DIALECTS, TTS_COSYVOICE3_INSTRUCT_VOLUMES, TTS_COSYVOICE3_INSTRUCT_STYLES, VectorIndexStorage } from '@qvac/inference/surface';
|
|
3
|
-
import { PLUGIN_LLM, PLUGIN_EMBEDDING, PLUGIN_DECISION, PLUGIN_WHISPER, PLUGIN_BCI, PLUGIN_MOSS_TRANSCRIBE, PLUGIN_NMT, PLUGIN_TTS, PLUGIN_OCR, PLUGIN_DIFFUSION, PLUGIN_AUDIOGEN, PLUGIN_VLA, PLUGIN_CLASSIFICATION } from '../../src/plugin-ids.js';
|
|
2
|
+
import { ModelType, VERBOSITY, SUPPORTED_AUDIO_FORMATS, AUDIOGEN_ENGINES, AUDIOGEN_TASK_TYPES, AUDIOGEN_EDIT_OPERATIONS, AUDIOGEN_REPAINT_MODES, AUDIOGEN_TRACKS, AUDIOGEN_OUTPUT_FORMATS, AUDIOGEN_MINIMAX_COREML_COMPUTE_UNITS, TTS_ENGINES, TTS_PACES, TTS_PARLER_EMOTIONS, TTS_SENTENCE_DELIMITER_PRESETS, TTS_CHATTERBOX_LANGUAGES, TTS_SUPERTONIC_LANGUAGES, TTS_COSYVOICE3_EMOTIONS, TTS_COSYVOICE3_INSTRUCT_DIALECTS, TTS_COSYVOICE3_INSTRUCT_VOLUMES, TTS_COSYVOICE3_INSTRUCT_STYLES, TTS_PARLER_COREML_COMPUTE_UNITS, TTS_LAVASR_COREML_COMPUTE_UNITS, TTS_SUPERTONIC_PRECISIONS, VectorIndexStorage } from '@qvac/inference/surface';
|
|
3
|
+
import { PLUGIN_LLM, PLUGIN_EMBEDDING, PLUGIN_DECISION, PLUGIN_RERANK, PLUGIN_IMAGE_EMBEDDING, PLUGIN_WHISPER, PLUGIN_BCI, PLUGIN_MOSS_TRANSCRIBE, PLUGIN_NMT, PLUGIN_TTS, PLUGIN_OCR, PLUGIN_DIFFUSION, PLUGIN_AUDIOGEN, PLUGIN_VLA, PLUGIN_CLASSIFICATION } from '../../src/plugin-ids.js';
|
|
4
4
|
// Uppercases each vocabulary value into an identifier-safe varname (e.g.
|
|
5
5
|
// 'slow' -> 'SLOW', 'cover-nofsq' -> 'COVER_NOFSQ'), mirroring the
|
|
6
6
|
// SupportedAudioFormat derivation so names can't drift from the single
|
|
@@ -39,6 +39,8 @@ export const constantsRegistry = {
|
|
|
39
39
|
LLM: PLUGIN_LLM,
|
|
40
40
|
EMBEDDING: PLUGIN_EMBEDDING,
|
|
41
41
|
DECISION: PLUGIN_DECISION,
|
|
42
|
+
RERANK: PLUGIN_RERANK,
|
|
43
|
+
IMAGE_EMBEDDING: PLUGIN_IMAGE_EMBEDDING,
|
|
42
44
|
WHISPER: PLUGIN_WHISPER,
|
|
43
45
|
BCI: PLUGIN_BCI,
|
|
44
46
|
MOSS_TRANSCRIBE: PLUGIN_MOSS_TRANSCRIBE,
|
|
@@ -66,10 +68,15 @@ export const constantsRegistry = {
|
|
|
66
68
|
TtsCosyvoice3InstructDialect: enumFromVocabulary(TTS_COSYVOICE3_INSTRUCT_DIALECTS),
|
|
67
69
|
TtsCosyvoice3InstructVolume: enumFromVocabulary(TTS_COSYVOICE3_INSTRUCT_VOLUMES),
|
|
68
70
|
TtsCosyvoice3InstructStyle: enumFromVocabulary(TTS_COSYVOICE3_INSTRUCT_STYLES),
|
|
71
|
+
TtsParlerCoremlComputeUnits: enumFromVocabulary(TTS_PARLER_COREML_COMPUTE_UNITS),
|
|
72
|
+
TtsLavasrCoremlComputeUnits: enumFromVocabulary(TTS_LAVASR_COREML_COMPUTE_UNITS),
|
|
73
|
+
TtsSupertonicPrecision: enumFromVocabulary(TTS_SUPERTONIC_PRECISIONS),
|
|
69
74
|
AudioGenEngine: enumFromVocabulary(AUDIOGEN_ENGINES),
|
|
70
75
|
AudioGenTaskType: enumFromVocabulary(AUDIOGEN_TASK_TYPES),
|
|
71
76
|
AudioGenEditOperation: enumFromVocabulary(AUDIOGEN_EDIT_OPERATIONS),
|
|
72
77
|
AudioGenRepaintMode: enumFromVocabulary(AUDIOGEN_REPAINT_MODES),
|
|
73
78
|
AudioGenTrack: enumFromVocabulary(AUDIOGEN_TRACKS),
|
|
79
|
+
AudioGenOutputFormat: enumFromVocabulary(AUDIOGEN_OUTPUT_FORMATS),
|
|
80
|
+
AudioGenMinimaxCoremlComputeUnits: enumFromVocabulary(AUDIOGEN_MINIMAX_COREML_COMPUTE_UNITS),
|
|
74
81
|
VectorIndexStorage: z.enum(VectorIndexStorage)
|
|
75
82
|
};
|
|
@@ -17,15 +17,19 @@ export declare const methodShapes: {
|
|
|
17
17
|
readonly batchCompletionStream: "stream";
|
|
18
18
|
readonly bciTranscribe: "stream";
|
|
19
19
|
readonly bciTranscribeStream: "duplex";
|
|
20
|
+
readonly calcTokens: "reply";
|
|
20
21
|
readonly cancel: "reply";
|
|
21
22
|
readonly classify: "stream";
|
|
23
|
+
readonly closeSession: "reply";
|
|
22
24
|
readonly completionOrchestrate: "duplex";
|
|
23
25
|
readonly completionStream: "stream";
|
|
24
26
|
readonly deleteCache: "reply";
|
|
25
27
|
readonly diffusionStream: "stream";
|
|
26
28
|
readonly downloadAsset: "reply";
|
|
27
29
|
readonly embed: "reply";
|
|
30
|
+
readonly embedBatch: "reply";
|
|
28
31
|
readonly decide: "reply";
|
|
32
|
+
readonly rerank: "reply";
|
|
29
33
|
readonly finetune: "reply";
|
|
30
34
|
readonly getLoadedModelInfo: "reply";
|
|
31
35
|
readonly getModelInfo: "reply";
|
|
@@ -37,6 +41,7 @@ export declare const methodShapes: {
|
|
|
37
41
|
readonly modelRegistryList: "reply";
|
|
38
42
|
readonly modelRegistrySearch: "reply";
|
|
39
43
|
readonly ocrStream: "stream";
|
|
44
|
+
readonly openSession: "reply";
|
|
40
45
|
readonly pluginInvoke: "reply";
|
|
41
46
|
readonly pluginInvokeStream: "stream";
|
|
42
47
|
readonly rag: "reply";
|
|
@@ -17,15 +17,19 @@ export const methodShapes = {
|
|
|
17
17
|
batchCompletionStream: 'stream',
|
|
18
18
|
bciTranscribe: 'stream',
|
|
19
19
|
bciTranscribeStream: 'duplex',
|
|
20
|
+
calcTokens: 'reply',
|
|
20
21
|
cancel: 'reply',
|
|
21
22
|
classify: 'stream',
|
|
23
|
+
closeSession: 'reply',
|
|
22
24
|
completionOrchestrate: 'duplex',
|
|
23
25
|
completionStream: 'stream',
|
|
24
26
|
deleteCache: 'reply',
|
|
25
27
|
diffusionStream: 'stream',
|
|
26
28
|
downloadAsset: 'reply',
|
|
27
29
|
embed: 'reply',
|
|
30
|
+
embedBatch: 'reply',
|
|
28
31
|
decide: 'reply',
|
|
32
|
+
rerank: 'reply',
|
|
29
33
|
finetune: 'reply',
|
|
30
34
|
getLoadedModelInfo: 'reply',
|
|
31
35
|
getModelInfo: 'reply',
|
|
@@ -37,6 +41,7 @@ export const methodShapes = {
|
|
|
37
41
|
modelRegistryList: 'reply',
|
|
38
42
|
modelRegistrySearch: 'reply',
|
|
39
43
|
ocrStream: 'stream',
|
|
44
|
+
openSession: 'reply',
|
|
40
45
|
pluginInvoke: 'reply',
|
|
41
46
|
pluginInvokeStream: 'stream',
|
|
42
47
|
rag: 'reply',
|
|
@@ -11,7 +11,7 @@ export interface Manifest {
|
|
|
11
11
|
}
|
|
12
12
|
export declare function checkAddonRanges(inferencePkg: Manifest, sdkPkg: Manifest): string[];
|
|
13
13
|
export declare function checkSharedMajorMinor(sdkPkg: Manifest): string[];
|
|
14
|
-
export declare function
|
|
14
|
+
export declare function checkDesktopBare(inferencePkg: Manifest, bareVersion: string | null): string[];
|
|
15
15
|
export declare function collectVersionFailures(inferencePkg: Manifest, sdkPkg: Manifest): string[];
|
|
16
16
|
export declare function runEnforceInferenceVersionsCli(): void;
|
|
17
17
|
export {};
|
|
@@ -14,9 +14,8 @@
|
|
|
14
14
|
// below 1.0.0 (^0.19.0 is >=0.19.0 <0.20.0) but not from 1.0.0 up (^1.19.0
|
|
15
15
|
// also allows 1.20.0), so a tilde is required there.
|
|
16
16
|
//
|
|
17
|
-
// 3. Bare runtime
|
|
18
|
-
// must satisfy inference's engines.bare
|
|
19
|
-
// retained by a consumer's existing lockfile.
|
|
17
|
+
// 3. Desktop Bare. The Bare runtime bare-sidecar ships, which runs the desktop
|
|
18
|
+
// worker, must satisfy inference's engines.bare.
|
|
20
19
|
//
|
|
21
20
|
// The second rule reads @qvac/sdk's manifest alone and never
|
|
22
21
|
// packages/inference's version. The two move independently between releases —
|
|
@@ -26,9 +25,10 @@
|
|
|
26
25
|
// The checks take manifests rather than reading them, so test/enforce-inference-
|
|
27
26
|
// versions.test.ts can drive them over manifest shapes the repo does not hold.
|
|
28
27
|
import { readFileSync } from 'fs';
|
|
28
|
+
import { createRequire } from 'module';
|
|
29
29
|
import { join, resolve, dirname } from 'path';
|
|
30
30
|
import { fileURLToPath } from 'url';
|
|
31
|
-
import {
|
|
31
|
+
import { satisfies, validRange } from 'semver';
|
|
32
32
|
const dependency = '@qvac/inference';
|
|
33
33
|
const sdkManifest = 'packages/sdk/package.json';
|
|
34
34
|
export function checkAddonRanges(inferencePkg, sdkPkg) {
|
|
@@ -111,39 +111,49 @@ export function checkSharedMajorMinor(sdkPkg) {
|
|
|
111
111
|
}
|
|
112
112
|
return [];
|
|
113
113
|
}
|
|
114
|
-
export function
|
|
114
|
+
export function checkDesktopBare(inferencePkg, bareVersion) {
|
|
115
115
|
const required = inferencePkg.engines?.['bare'];
|
|
116
116
|
if (required === undefined)
|
|
117
117
|
return [];
|
|
118
118
|
if (validRange(required) === null) {
|
|
119
|
-
return [
|
|
119
|
+
return [`${dependency} engines.bare "${required}" is not a valid semver range.`];
|
|
120
120
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
return [`${sdkManifest} must declare a valid bare-runtime dependency range.`];
|
|
121
|
+
if (bareVersion === null) {
|
|
122
|
+
return ['Could not read the Bare version that bare-sidecar ships.'];
|
|
124
123
|
}
|
|
125
|
-
if (!
|
|
124
|
+
if (!satisfies(bareVersion, required)) {
|
|
126
125
|
return [
|
|
127
|
-
`
|
|
128
|
-
'
|
|
126
|
+
`bare-sidecar ships Bare ${bareVersion}, outside ${dependency} engines.bare "${required}". ` +
|
|
127
|
+
'Move the SDK to a bare-sidecar release whose Bare satisfies it.'
|
|
129
128
|
];
|
|
130
129
|
}
|
|
131
130
|
return [];
|
|
132
131
|
}
|
|
133
132
|
export function collectVersionFailures(inferencePkg, sdkPkg) {
|
|
134
|
-
return [
|
|
135
|
-
...checkAddonRanges(inferencePkg, sdkPkg),
|
|
136
|
-
...checkSharedMajorMinor(sdkPkg),
|
|
137
|
-
...checkBareRuntimeRange(inferencePkg, sdkPkg)
|
|
138
|
-
];
|
|
133
|
+
return [...checkAddonRanges(inferencePkg, sdkPkg), ...checkSharedMajorMinor(sdkPkg)];
|
|
139
134
|
}
|
|
140
135
|
function readManifest(dir) {
|
|
141
136
|
return JSON.parse(readFileSync(join(dir, 'package.json'), 'utf8'));
|
|
142
137
|
}
|
|
138
|
+
/** The Bare the installed bare-sidecar ships, from its `versions.json`. */
|
|
139
|
+
function readSidecarBareVersion(sdkDir) {
|
|
140
|
+
try {
|
|
141
|
+
const sidecarDir = dirname(createRequire(join(sdkDir, 'package.json')).resolve('bare-sidecar/package'));
|
|
142
|
+
const { bare } = JSON.parse(readFileSync(join(sidecarDir, 'versions.json'), 'utf8'));
|
|
143
|
+
return typeof bare === 'string' ? bare : null;
|
|
144
|
+
}
|
|
145
|
+
catch {
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
143
149
|
export function runEnforceInferenceVersionsCli() {
|
|
144
150
|
const sdkDir = resolve(dirname(fileURLToPath(import.meta.url)), '..');
|
|
145
151
|
const inferenceDir = resolve(sdkDir, '..', 'inference');
|
|
146
|
-
const
|
|
152
|
+
const inferencePkg = readManifest(inferenceDir);
|
|
153
|
+
const failures = [
|
|
154
|
+
...collectVersionFailures(inferencePkg, readManifest(sdkDir)),
|
|
155
|
+
...checkDesktopBare(inferencePkg, readSidecarBareVersion(sdkDir))
|
|
156
|
+
];
|
|
147
157
|
if (failures.length > 0) {
|
|
148
158
|
console.error(failures.join('\n\n'));
|
|
149
159
|
process.exit(1);
|