@qvac/sdk 0.23.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 +115 -58
- package/README.md +10 -13
- package/dist/examples/asr/parakeet-sortformer.js +24 -14
- package/dist/examples/asr/parakeet-transcribepsy-filesystem.js +40 -11
- 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-moss-image.d.ts +2 -0
- package/dist/examples/diffusion-moss-image.js +126 -0
- package/dist/examples/diffusion-qwen-image-21.js +15 -4
- 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/image/megaloc.d.ts +2 -0
- package/dist/examples/image/megaloc.js +37 -0
- package/dist/examples/llamacpp-multimodal.js +18 -0
- package/dist/examples/rag/rag-hyperdb/pipeline.js +2 -2
- package/dist/examples/rag/rag-turbovec.js +2 -2
- package/dist/examples/sessions.d.ts +17 -0
- package/dist/examples/sessions.js +63 -0
- package/dist/examples/tools/llamacpp-deferred-tools.js +8 -4
- 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 +17 -0
- package/dist/scripts/contract/constants-registry.js +8 -2
- package/dist/scripts/contract/method-shapes.d.ts +4 -0
- package/dist/scripts/contract/method-shapes.js +4 -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 +18 -31
- package/dist/src/client/api/audio-edit.d.ts +5 -3
- package/dist/src/client/api/audio-edit.js +5 -3
- package/dist/src/client/api/audio-gen-result.js +134 -45
- package/dist/src/client/api/audio-gen.d.ts +40 -3
- package/dist/src/client/api/audio-gen.js +40 -3
- package/dist/src/client/api/audio-understand.d.ts +2 -2
- package/dist/src/client/api/audio-understand.js +2 -2
- package/dist/src/client/api/batch-completion.js +2 -1
- 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 +2 -2
- package/dist/src/client/api/classify.d.ts +12 -5
- package/dist/src/client/api/classify.js +17 -5
- 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 +8 -1
- package/dist/src/client/api/completion-stream.js +10 -1
- package/dist/src/client/api/delete-cache.d.ts +9 -2
- package/dist/src/client/api/delete-cache.js +13 -3
- package/dist/src/client/api/diffusion.d.ts +20 -4
- package/dist/src/client/api/diffusion.js +23 -5
- package/dist/src/client/api/embed.d.ts +82 -29
- package/dist/src/client/api/embed.js +64 -19
- package/dist/src/client/api/get-model-info.d.ts +2 -2
- package/dist/src/client/api/get-model-info.js +2 -2
- package/dist/src/client/api/get-system-resources.d.ts +2 -2
- package/dist/src/client/api/get-system-resources.js +2 -2
- package/dist/src/client/api/heartbeat.d.ts +3 -2
- package/dist/src/client/api/heartbeat.js +3 -2
- package/dist/src/client/api/index.d.ts +4 -3
- package/dist/src/client/api/index.js +2 -1
- package/dist/src/client/api/invoke-plugin.d.ts +8 -2
- package/dist/src/client/api/invoke-plugin.js +17 -2
- package/dist/src/client/api/load-model.js +5 -2
- package/dist/src/client/api/ocr.d.ts +5 -3
- package/dist/src/client/api/ocr.js +44 -21
- package/dist/src/client/api/rag.d.ts +1 -1
- package/dist/src/client/api/rag.js +1 -1
- package/dist/src/client/api/registry.d.ts +17 -7
- package/dist/src/client/api/registry.js +37 -12
- package/dist/src/client/api/resume.d.ts +2 -1
- package/dist/src/client/api/resume.js +2 -2
- package/dist/src/client/api/rpc-server.d.ts +4 -4
- package/dist/src/client/api/rpc-server.js +10 -10
- package/dist/src/client/api/state.d.ts +2 -2
- package/dist/src/client/api/state.js +2 -2
- package/dist/src/client/api/subscribe-logs.d.ts +2 -2
- package/dist/src/client/api/subscribe-logs.js +2 -2
- package/dist/src/client/api/suspend.d.ts +4 -2
- package/dist/src/client/api/suspend.js +4 -3
- package/dist/src/client/api/text-to-speech.d.ts +14 -5
- package/dist/src/client/api/text-to-speech.js +83 -29
- package/dist/src/client/api/transcribe.d.ts +6 -2
- package/dist/src/client/api/transcribe.js +7 -1
- package/dist/src/client/api/unload-model.d.ts +19 -7
- package/dist/src/client/api/unload-model.js +29 -11
- package/dist/src/client/api/upscale.d.ts +6 -3
- package/dist/src/client/api/upscale.js +9 -4
- package/dist/src/client/api/vector-index.d.ts +50 -16
- package/dist/src/client/api/vector-index.js +100 -48
- 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 +3 -2
- 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.d.ts +5 -5
- package/dist/src/client/api/world.js +4 -4
- 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 +31 -12
- 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 +189 -135
- package/dist/src/client/rpc/node-rpc-client.js +322 -413
- 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 +5 -4
- package/dist/src/client/rpc/rpc-client.js +126 -23
- package/dist/src/client/rpc/rpc-error.js +21 -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 +1 -0
- package/dist/src/commands/bundle/entry-gen.d.ts +1 -5
- package/dist/src/commands/bundle/entry-gen.js +17 -50
- package/dist/src/commands/bundle/index.d.ts +59 -13
- package/dist/src/commands/bundle/index.js +345 -121
- 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/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 +5 -4
- package/dist/src/commands/host-prebuilds/index.js +9 -7
- package/dist/src/commands/index.d.ts +4 -3
- package/dist/src/commands/verify/abi.d.ts +20 -14
- package/dist/src/commands/verify/abi.js +11 -79
- 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.js +25 -21
- package/dist/src/commands/verify/engines-advice.d.ts +2 -8
- package/dist/src/commands/verify/engines-advice.js +7 -54
- package/dist/src/commands/verify/index.d.ts +30 -29
- package/dist/src/commands/verify/index.js +92 -200
- package/dist/src/commands/verify/prebuilds.d.ts +3 -5
- package/dist/src/commands/verify/prebuilds.js +1 -2
- package/dist/src/commands/verify/resource-collectors.d.ts +0 -6
- package/dist/src/commands/verify/resource-collectors.js +1 -50
- 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/withBareKit.d.ts +59 -0
- package/dist/src/expo/plugins/withBareKit.js +204 -0
- package/dist/src/expo/plugins/withMobileBundle.d.ts +4 -11
- package/dist/src/expo/plugins/withMobileBundle.js +36 -57
- package/dist/src/expo/plugins/withQvacSDK.d.ts +1 -0
- 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/utils.js +10 -2
- package/dist/src/plugin-ids.d.ts +2 -1
- package/dist/src/plugin-ids.js +2 -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 +11 -1
- package/dist/src/schemas/sdk-errors-server.js +60 -2
- package/dist/src/server/rpc/rpc-utils.d.ts +25 -4
- package/dist/src/server/rpc/rpc-utils.js +39 -5
- 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 +59 -1
- package/dist/src/utils/errors-server.js +110 -1
- package/dist/src/utils/withTimeout.js +34 -17
- package/dist/src/worker/handle-request.js +25 -22
- 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 +23 -35
- 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/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 +62 -51
- 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/ipc-socket-path.d.ts +0 -11
- package/dist/src/client/rpc/ipc-socket-path.js +0 -30
- 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 -450
- 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
|
@@ -15,30 +15,29 @@ export declare const SDK_CLIENT_ERROR_CODES: {
|
|
|
15
15
|
readonly RPC_REQUEST_NOT_SENT: 50201;
|
|
16
16
|
readonly RPC_RESPONSE_STREAM_NOT_CREATED: 50202;
|
|
17
17
|
readonly RPC_CONNECTION_FAILED: 50203;
|
|
18
|
-
readonly RPC_INIT_TIMEOUT: 50204;
|
|
19
18
|
readonly WORKER_CRASHED: 50205;
|
|
20
19
|
readonly WORKER_SHUTDOWN: 50206;
|
|
21
20
|
readonly WORKER_STARTUP_FAILED: 50207;
|
|
21
|
+
readonly SESSION_INVALIDATED: 50208;
|
|
22
|
+
readonly MODEL_HANDLE_INVALIDATED: 50209;
|
|
22
23
|
readonly SDK_NOT_FOUND_IN_NODE_MODULES: 50600;
|
|
23
24
|
readonly WORKER_FILE_NOT_FOUND: 50601;
|
|
24
25
|
readonly CONFIG_FILE_NOT_FOUND: 50602;
|
|
25
26
|
readonly CONFIG_FILE_INVALID: 50603;
|
|
26
27
|
readonly CONFIG_FILE_PARSE_FAILED: 50604;
|
|
27
28
|
readonly CONFIG_VALIDATION_FAILED: 50605;
|
|
28
|
-
readonly PEAR_WORKER_ENTRY_REQUIRED: 50606;
|
|
29
29
|
readonly MULTIPLE_SDK_INSTALLATIONS: 50607;
|
|
30
|
-
readonly WORKER_PLUGINS_NOT_REGISTERED: 50608;
|
|
31
30
|
readonly BUNDLE_VERIFICATION_FAILED: 50609;
|
|
32
|
-
readonly BARE_PACK_NOT_INSTALLED: 50610;
|
|
33
|
-
readonly BARE_PACK_ERROR: 50611;
|
|
34
31
|
readonly INVALID_PLUGIN_SPECIFIER: 50612;
|
|
35
32
|
readonly BARE_IMPORTS_MAP_NOT_FOUND: 50613;
|
|
36
|
-
readonly BARE_RUNTIME_BINARY_NOT_FOUND: 50614;
|
|
37
33
|
readonly HOST_PREBUILDS_INSTALL_REFUSED: 50615;
|
|
38
34
|
readonly HOST_PREBUILDS_INSTALL_FAILED: 50616;
|
|
39
35
|
readonly ADDON_LINK_FAILED: 50617;
|
|
40
36
|
readonly BARE_PACK_NODE_UNSUPPORTED: 50618;
|
|
41
37
|
readonly HOST_PREBUILDS_MISSING: 50619;
|
|
38
|
+
readonly REACT_NATIVE_BARE_KIT_UNSUPPORTED: 50620;
|
|
39
|
+
readonly BUNDLE_FAILED: 50621;
|
|
40
|
+
readonly BUNDLE_TARGET_NOT_INSTALLED: 50622;
|
|
42
41
|
readonly PROFILER_INVALID_CAPACITY: 50800;
|
|
43
42
|
};
|
|
44
43
|
declare const clientErrorDefinitions: ErrorCodesMap;
|
|
@@ -20,10 +20,11 @@ export const SDK_CLIENT_ERROR_CODES = {
|
|
|
20
20
|
RPC_REQUEST_NOT_SENT: 50201,
|
|
21
21
|
RPC_RESPONSE_STREAM_NOT_CREATED: 50202,
|
|
22
22
|
RPC_CONNECTION_FAILED: 50203,
|
|
23
|
-
RPC_INIT_TIMEOUT: 50204,
|
|
24
23
|
WORKER_CRASHED: 50205,
|
|
25
24
|
WORKER_SHUTDOWN: 50206,
|
|
26
25
|
WORKER_STARTUP_FAILED: 50207,
|
|
26
|
+
SESSION_INVALIDATED: 50208,
|
|
27
|
+
MODEL_HANDLE_INVALIDATED: 50209,
|
|
27
28
|
// Build/Bundle Errors (50,600-50,799)
|
|
28
29
|
SDK_NOT_FOUND_IN_NODE_MODULES: 50600,
|
|
29
30
|
WORKER_FILE_NOT_FOUND: 50601,
|
|
@@ -31,20 +32,18 @@ export const SDK_CLIENT_ERROR_CODES = {
|
|
|
31
32
|
CONFIG_FILE_INVALID: 50603,
|
|
32
33
|
CONFIG_FILE_PARSE_FAILED: 50604,
|
|
33
34
|
CONFIG_VALIDATION_FAILED: 50605,
|
|
34
|
-
PEAR_WORKER_ENTRY_REQUIRED: 50606,
|
|
35
35
|
MULTIPLE_SDK_INSTALLATIONS: 50607,
|
|
36
|
-
WORKER_PLUGINS_NOT_REGISTERED: 50608,
|
|
37
36
|
BUNDLE_VERIFICATION_FAILED: 50609,
|
|
38
|
-
BARE_PACK_NOT_INSTALLED: 50610,
|
|
39
|
-
BARE_PACK_ERROR: 50611,
|
|
40
37
|
INVALID_PLUGIN_SPECIFIER: 50612,
|
|
41
38
|
BARE_IMPORTS_MAP_NOT_FOUND: 50613,
|
|
42
|
-
BARE_RUNTIME_BINARY_NOT_FOUND: 50614,
|
|
43
39
|
HOST_PREBUILDS_INSTALL_REFUSED: 50615,
|
|
44
40
|
HOST_PREBUILDS_INSTALL_FAILED: 50616,
|
|
45
41
|
ADDON_LINK_FAILED: 50617,
|
|
46
42
|
BARE_PACK_NODE_UNSUPPORTED: 50618,
|
|
47
43
|
HOST_PREBUILDS_MISSING: 50619,
|
|
44
|
+
REACT_NATIVE_BARE_KIT_UNSUPPORTED: 50620,
|
|
45
|
+
BUNDLE_FAILED: 50621,
|
|
46
|
+
BUNDLE_TARGET_NOT_INSTALLED: 50622,
|
|
48
47
|
// Profiler Errors (50,800-50,899)
|
|
49
48
|
PROFILER_INVALID_CAPACITY: 50800
|
|
50
49
|
};
|
|
@@ -107,10 +106,6 @@ const clientErrorDefinitions = {
|
|
|
107
106
|
name: 'RPC_CONNECTION_FAILED',
|
|
108
107
|
message: (details) => `RPC connection failed: ${details}`
|
|
109
108
|
},
|
|
110
|
-
[SDK_CLIENT_ERROR_CODES.RPC_INIT_TIMEOUT]: {
|
|
111
|
-
name: 'RPC_INIT_TIMEOUT',
|
|
112
|
-
message: (timeoutMs) => `RPC initialization timed out after ${timeoutMs}ms — the worker process may have failed to start`
|
|
113
|
-
},
|
|
114
109
|
[SDK_CLIENT_ERROR_CODES.WORKER_CRASHED]: {
|
|
115
110
|
name: 'WORKER_CRASHED',
|
|
116
111
|
message: (code, signal) => `Bare worker exited mid-request (code=${code}, signal=${signal}) — in-flight calls were aborted`
|
|
@@ -119,11 +114,17 @@ const clientErrorDefinitions = {
|
|
|
119
114
|
name: 'WORKER_SHUTDOWN',
|
|
120
115
|
message: () => `SDK is shutting down — in-flight RPC call aborted`
|
|
121
116
|
},
|
|
117
|
+
[SDK_CLIENT_ERROR_CODES.SESSION_INVALIDATED]: {
|
|
118
|
+
name: 'SESSION_INVALIDATED',
|
|
119
|
+
message: (sessionId, reason) => `Session "${sessionId}" is no longer usable (${reason}); open a new session`
|
|
120
|
+
},
|
|
121
|
+
[SDK_CLIENT_ERROR_CODES.MODEL_HANDLE_INVALIDATED]: {
|
|
122
|
+
name: 'MODEL_HANDLE_INVALIDATED',
|
|
123
|
+
message: (modelId, sessionId) => `Model "${modelId}" is no longer loaded: the runtime or session that held it ("${sessionId}") is gone; load it again`
|
|
124
|
+
},
|
|
122
125
|
[SDK_CLIENT_ERROR_CODES.WORKER_STARTUP_FAILED]: {
|
|
123
126
|
name: 'WORKER_STARTUP_FAILED',
|
|
124
|
-
|
|
125
|
-
// `Worker stderr:` header when non-empty.
|
|
126
|
-
message: (details, stderrTail) => stderrTail ? `${details}\n\nWorker stderr:\n${stderrTail}` : details
|
|
127
|
+
message: (details) => details
|
|
127
128
|
},
|
|
128
129
|
// Build/Bundle Errors (50,600-50,799)
|
|
129
130
|
[SDK_CLIENT_ERROR_CODES.SDK_NOT_FOUND_IN_NODE_MODULES]: {
|
|
@@ -154,29 +155,17 @@ const clientErrorDefinitions = {
|
|
|
154
155
|
name: 'MULTIPLE_SDK_INSTALLATIONS',
|
|
155
156
|
message: (packages) => `Multiple QVAC SDK installations found: ${packages}. Remove all but one to avoid conflicts.`
|
|
156
157
|
},
|
|
157
|
-
[SDK_CLIENT_ERROR_CODES.PEAR_WORKER_ENTRY_REQUIRED]: {
|
|
158
|
-
name: 'PEAR_WORKER_ENTRY_REQUIRED',
|
|
159
|
-
message: (workerEntry) => `No plugins registered. Pear apps must spawn ${workerEntry} as the worker entry. Run \`npx qvac bundle sdk\` to generate it, then spawn the generated file instead of your worker directly.`
|
|
160
|
-
},
|
|
161
|
-
[SDK_CLIENT_ERROR_CODES.WORKER_PLUGINS_NOT_REGISTERED]: {
|
|
162
|
-
name: 'WORKER_PLUGINS_NOT_REGISTERED',
|
|
163
|
-
message: () => 'No plugins registered in the worker. For in-process Bare use `@qvac/inference` and register plugins with `plugins([...])` (or `registerPlugin(...)`). See https://docs.qvac.tether.io/configuration/plugins#runtime-registration-on-bare'
|
|
164
|
-
},
|
|
165
158
|
[SDK_CLIENT_ERROR_CODES.BUNDLE_VERIFICATION_FAILED]: {
|
|
166
159
|
name: 'BUNDLE_VERIFICATION_FAILED',
|
|
167
|
-
message: (bundlePath) => `
|
|
160
|
+
message: (bundlePath) => `Native addon verification failed for ${bundlePath}. The cause lists the failing addons and hosts; resolve them before shipping.`
|
|
168
161
|
},
|
|
169
|
-
[SDK_CLIENT_ERROR_CODES.
|
|
170
|
-
name: '
|
|
171
|
-
message:
|
|
172
|
-
},
|
|
173
|
-
[SDK_CLIENT_ERROR_CODES.BARE_PACK_ERROR]: {
|
|
174
|
-
name: 'BARE_PACK_ERROR',
|
|
175
|
-
message: (exitCode, entryPath, outputPath) => `bare-pack exited with code ${exitCode}\n\n Entry file: ${entryPath}\n Output file: ${outputPath}\n\n Run bare-pack manually for more details.`
|
|
162
|
+
[SDK_CLIENT_ERROR_CODES.BUNDLE_FAILED]: {
|
|
163
|
+
name: 'BUNDLE_FAILED',
|
|
164
|
+
message: (entryPath, reason) => `Bundling the worker failed\n\n Entry file: ${entryPath}\n Reason: ${reason}`
|
|
176
165
|
},
|
|
177
166
|
[SDK_CLIENT_ERROR_CODES.BARE_PACK_NODE_UNSUPPORTED]: {
|
|
178
167
|
name: 'BARE_PACK_NODE_UNSUPPORTED',
|
|
179
|
-
message: (nodeVersion, requiredRange) => `
|
|
168
|
+
message: (nodeVersion, requiredRange) => `Bundling needs Node ${requiredRange}; found Node v${nodeVersion}. Upgrade Node and run the bundle again.`
|
|
180
169
|
},
|
|
181
170
|
[SDK_CLIENT_ERROR_CODES.INVALID_PLUGIN_SPECIFIER]: {
|
|
182
171
|
name: 'INVALID_PLUGIN_SPECIFIER',
|
|
@@ -186,10 +175,6 @@ const clientErrorDefinitions = {
|
|
|
186
175
|
name: 'BARE_IMPORTS_MAP_NOT_FOUND',
|
|
187
176
|
message: (sdkName, expectedPath) => `bare-imports.json not found.\n\n Expected at: ${expectedPath}\n\n Make sure ${sdkName} is installed in your project.`
|
|
188
177
|
},
|
|
189
|
-
[SDK_CLIENT_ERROR_CODES.BARE_RUNTIME_BINARY_NOT_FOUND]: {
|
|
190
|
-
name: 'BARE_RUNTIME_BINARY_NOT_FOUND',
|
|
191
|
-
message: (platform, arch) => `Could not load the Bare runtime binary for ${platform}-${arch}. The platform package "bare-runtime-${platform}-${arch}" (or one of its dependencies) is missing from node_modules — commonly seen with pnpm, which does not always install nested optional dependencies. Fix it by installing the platform package directly (e.g. \`pnpm add bare-runtime-${platform}-${arch}\`) or by installing with npm or bun. See https://github.com/tetherto/qvac/issues/1492`
|
|
192
|
-
},
|
|
193
178
|
[SDK_CLIENT_ERROR_CODES.HOST_PREBUILDS_INSTALL_REFUSED]: {
|
|
194
179
|
name: 'HOST_PREBUILDS_INSTALL_REFUSED',
|
|
195
180
|
message: (reason, dependencies) => `Cannot install the addon platform packages automatically: ${reason}.` +
|
|
@@ -210,8 +195,17 @@ const clientErrorDefinitions = {
|
|
|
210
195
|
},
|
|
211
196
|
[SDK_CLIENT_ERROR_CODES.HOST_PREBUILDS_MISSING]: {
|
|
212
197
|
name: 'HOST_PREBUILDS_MISSING',
|
|
213
|
-
message: (dependencies) => "Bundling failed: split addons resolve their native code through `#host-addon`, which needs each
|
|
214
|
-
`\n\n Add them to the dependencies in package.json, pinned to these exact versions, and reinstall
|
|
198
|
+
message: (dependencies) => "Bundling failed: split addons resolve their native code through `#host-addon`, which needs each host's platform package installed." +
|
|
199
|
+
`\n\n Add them to the dependencies in package.json, pinned to these exact versions, and reinstall. installMissingPrebuilds does this for phone hosts; npm installs another desktop host's package only with --force:\n${dependencies}`
|
|
200
|
+
},
|
|
201
|
+
[SDK_CLIENT_ERROR_CODES.REACT_NATIVE_BARE_KIT_UNSUPPORTED]: {
|
|
202
|
+
name: 'REACT_NATIVE_BARE_KIT_UNSUPPORTED',
|
|
203
|
+
message: (installedVersion, requiredRange) => `The react-native worker bundle needs react-native-bare-kit ${requiredRange}; found ${installedVersion}. ` +
|
|
204
|
+
'Upgrade react-native-bare-kit and run the bundle again.'
|
|
205
|
+
},
|
|
206
|
+
[SDK_CLIENT_ERROR_CODES.BUNDLE_TARGET_NOT_INSTALLED]: {
|
|
207
|
+
name: 'BUNDLE_TARGET_NOT_INSTALLED',
|
|
208
|
+
message: (target, packageName) => `The ${target} target needs ${packageName}, which the project does not have. Install it and run the bundle again.`
|
|
215
209
|
},
|
|
216
210
|
// Profiler Errors (50,800-50,899)
|
|
217
211
|
[SDK_CLIENT_ERROR_CODES.PROFILER_INVALID_CAPACITY]: {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { type ErrorCodesMap } from '@qvac/error';
|
|
2
|
-
import '@qvac/inference/surface';
|
|
3
2
|
export declare const SDK_SERVER_ERROR_CODES: {
|
|
4
3
|
readonly MODEL_ALREADY_REGISTERED: 52001;
|
|
5
4
|
readonly MODEL_NOT_FOUND: 52002;
|
|
@@ -40,6 +39,7 @@ export declare const SDK_SERVER_ERROR_CODES: {
|
|
|
40
39
|
readonly REQUEST_REJECTED_BY_POLICY: 52420;
|
|
41
40
|
readonly CONTEXT_OVERFLOW: 52421;
|
|
42
41
|
readonly INVALID_AUDIO_INPUT: 52422;
|
|
42
|
+
readonly AUDIO_ENCODE_FAILED: 52424;
|
|
43
43
|
readonly RAG_SAVE_FAILED: 52800;
|
|
44
44
|
readonly RAG_SEARCH_FAILED: 52801;
|
|
45
45
|
readonly RAG_DELETE_FAILED: 52802;
|
|
@@ -52,6 +52,7 @@ export declare const SDK_SERVER_ERROR_CODES: {
|
|
|
52
52
|
readonly RAG_LIST_WORKSPACES_FAILED: 52809;
|
|
53
53
|
readonly RAG_CHUNK_FAILED: 52810;
|
|
54
54
|
readonly RAG_WORKSPACE_NOT_OPEN: 52811;
|
|
55
|
+
readonly RAG_WORKSPACE_BUSY: 52812;
|
|
55
56
|
readonly VECTOR_INDEX_PROVIDER_UNAVAILABLE: 52850;
|
|
56
57
|
readonly VECTOR_INDEX_NOT_FOUND: 52851;
|
|
57
58
|
readonly VECTOR_INDEX_INVALID_VECTORS: 52852;
|
|
@@ -78,6 +79,9 @@ export declare const SDK_SERVER_ERROR_CODES: {
|
|
|
78
79
|
readonly INVALID_DELETE_CACHE_PARAMS: 53201;
|
|
79
80
|
readonly CACHE_DIR_NOT_ABSOLUTE: 53202;
|
|
80
81
|
readonly CACHE_DIR_NOT_WRITABLE: 53203;
|
|
82
|
+
readonly INVALID_SEED_FROM_PARAMS: 53204;
|
|
83
|
+
readonly KV_CACHE_SEED_SOURCE_NOT_FOUND: 53205;
|
|
84
|
+
readonly KV_CACHE_SEED_SHARING_DISABLED: 53206;
|
|
81
85
|
readonly SET_CONFIG_FAILED: 53350;
|
|
82
86
|
readonly CONFIG_ALREADY_SET: 53351;
|
|
83
87
|
readonly FFMPEG_NOT_AVAILABLE: 53500;
|
|
@@ -99,9 +103,15 @@ export declare const SDK_SERVER_ERROR_CODES: {
|
|
|
99
103
|
readonly LIFECYCLE_SUSPEND_FAILED: 53600;
|
|
100
104
|
readonly LIFECYCLE_RESUME_FAILED: 53601;
|
|
101
105
|
readonly LIFECYCLE_OPERATION_BLOCKED: 53602;
|
|
106
|
+
readonly SESSION_ID_CONFLICT: 53620;
|
|
107
|
+
readonly SESSION_NOT_OPEN: 53621;
|
|
108
|
+
readonly MODEL_LEASED: 53622;
|
|
109
|
+
readonly OWNER_ONLY: 53623;
|
|
110
|
+
readonly MODEL_RECONFIGURED: 53624;
|
|
102
111
|
readonly PATH_TRAVERSAL: 53900;
|
|
103
112
|
readonly QVAC_MODEL_REGISTRY_QUERY_FAILED: 53950;
|
|
104
113
|
readonly QVAC_MODEL_REGISTRY_MODEL_NOT_FOUND: 53951;
|
|
114
|
+
readonly QVAC_MODEL_REGISTRY_BUSY: 53952;
|
|
105
115
|
};
|
|
106
116
|
declare const serverErrorDefinitions: ErrorCodesMap;
|
|
107
117
|
export { serverErrorDefinitions as SDK_SERVER_ERROR_DEFINITIONS };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { addCodes, isCodeRegistered } from '@qvac/error';
|
|
2
2
|
// Load @qvac/inference's registration first, then add only codes not already present, so a
|
|
3
3
|
// shared @qvac/error instance (packed consumers, the Bare worker) is not double-registered.
|
|
4
|
-
import '@qvac/inference/surface';
|
|
4
|
+
import { modelRegistryBusyMessage } from '@qvac/inference/surface';
|
|
5
5
|
// Server-side error codes (52,001-54,000 range for this SDK)
|
|
6
6
|
export const SDK_SERVER_ERROR_CODES = {
|
|
7
7
|
// Model Registry Errors (52,001-52,199)
|
|
@@ -46,6 +46,7 @@ export const SDK_SERVER_ERROR_CODES = {
|
|
|
46
46
|
REQUEST_REJECTED_BY_POLICY: 52420,
|
|
47
47
|
CONTEXT_OVERFLOW: 52421,
|
|
48
48
|
INVALID_AUDIO_INPUT: 52422,
|
|
49
|
+
AUDIO_ENCODE_FAILED: 52424,
|
|
49
50
|
// RAG Operations (52,800-52,999)
|
|
50
51
|
RAG_SAVE_FAILED: 52800,
|
|
51
52
|
RAG_SEARCH_FAILED: 52801,
|
|
@@ -59,6 +60,7 @@ export const SDK_SERVER_ERROR_CODES = {
|
|
|
59
60
|
RAG_LIST_WORKSPACES_FAILED: 52809,
|
|
60
61
|
RAG_CHUNK_FAILED: 52810,
|
|
61
62
|
RAG_WORKSPACE_NOT_OPEN: 52811,
|
|
63
|
+
RAG_WORKSPACE_BUSY: 52812,
|
|
62
64
|
// Vector index (52,850-52,899)
|
|
63
65
|
VECTOR_INDEX_PROVIDER_UNAVAILABLE: 52850,
|
|
64
66
|
VECTOR_INDEX_NOT_FOUND: 52851,
|
|
@@ -88,6 +90,9 @@ export const SDK_SERVER_ERROR_CODES = {
|
|
|
88
90
|
INVALID_DELETE_CACHE_PARAMS: 53201,
|
|
89
91
|
CACHE_DIR_NOT_ABSOLUTE: 53202,
|
|
90
92
|
CACHE_DIR_NOT_WRITABLE: 53203,
|
|
93
|
+
INVALID_SEED_FROM_PARAMS: 53204,
|
|
94
|
+
KV_CACHE_SEED_SOURCE_NOT_FOUND: 53205,
|
|
95
|
+
KV_CACHE_SEED_SHARING_DISABLED: 53206,
|
|
91
96
|
// Config Operations (53,350-53,499)
|
|
92
97
|
SET_CONFIG_FAILED: 53350,
|
|
93
98
|
CONFIG_ALREADY_SET: 53351,
|
|
@@ -114,12 +119,19 @@ export const SDK_SERVER_ERROR_CODES = {
|
|
|
114
119
|
LIFECYCLE_SUSPEND_FAILED: 53600,
|
|
115
120
|
LIFECYCLE_RESUME_FAILED: 53601,
|
|
116
121
|
LIFECYCLE_OPERATION_BLOCKED: 53602,
|
|
122
|
+
// Caller sessions and model leases (53,620-53,649)
|
|
123
|
+
SESSION_ID_CONFLICT: 53620,
|
|
124
|
+
SESSION_NOT_OPEN: 53621,
|
|
125
|
+
MODEL_LEASED: 53622,
|
|
126
|
+
OWNER_ONLY: 53623,
|
|
127
|
+
MODEL_RECONFIGURED: 53624,
|
|
117
128
|
// Security (53,900-53,949)
|
|
118
129
|
PATH_TRAVERSAL: 53900,
|
|
119
130
|
// QVAC Model Registry Operations (53,950-54,000)
|
|
120
131
|
// Note: Registry client errors (19,001-20,000) are re-thrown directly
|
|
121
132
|
QVAC_MODEL_REGISTRY_QUERY_FAILED: 53950,
|
|
122
|
-
QVAC_MODEL_REGISTRY_MODEL_NOT_FOUND: 53951
|
|
133
|
+
QVAC_MODEL_REGISTRY_MODEL_NOT_FOUND: 53951,
|
|
134
|
+
QVAC_MODEL_REGISTRY_BUSY: 53952
|
|
123
135
|
};
|
|
124
136
|
const serverErrorDefinitions = {
|
|
125
137
|
// Model Registry Errors (52,001-52,199)
|
|
@@ -307,6 +319,10 @@ const serverErrorDefinitions = {
|
|
|
307
319
|
name: 'INVALID_AUDIO_INPUT',
|
|
308
320
|
message: (details) => `Invalid audio input${details ? `: ${details}` : ''}`
|
|
309
321
|
},
|
|
322
|
+
[SDK_SERVER_ERROR_CODES.AUDIO_ENCODE_FAILED]: {
|
|
323
|
+
name: 'AUDIO_ENCODE_FAILED',
|
|
324
|
+
message: (format, details) => `Failed to encode audio as ${format}${details ? `: ${details}` : ''}`
|
|
325
|
+
},
|
|
310
326
|
// RAG Operations (52,800-52,999)
|
|
311
327
|
[SDK_SERVER_ERROR_CODES.RAG_SAVE_FAILED]: {
|
|
312
328
|
name: 'RAG_SAVE_FAILED',
|
|
@@ -356,6 +372,10 @@ const serverErrorDefinitions = {
|
|
|
356
372
|
name: 'RAG_WORKSPACE_NOT_OPEN',
|
|
357
373
|
message: (workspace) => `RAG workspace '${workspace}' is not open`
|
|
358
374
|
},
|
|
375
|
+
[SDK_SERVER_ERROR_CODES.RAG_WORKSPACE_BUSY]: {
|
|
376
|
+
name: 'RAG_WORKSPACE_BUSY',
|
|
377
|
+
message: (workspace) => `RAG workspace '${workspace}' is running another session's operation; retry when it finishes`
|
|
378
|
+
},
|
|
359
379
|
// Vector index (52,850-52,899)
|
|
360
380
|
[SDK_SERVER_ERROR_CODES.VECTOR_INDEX_PROVIDER_UNAVAILABLE]: {
|
|
361
381
|
name: 'VECTOR_INDEX_PROVIDER_UNAVAILABLE',
|
|
@@ -464,6 +484,18 @@ const serverErrorDefinitions = {
|
|
|
464
484
|
name: 'CACHE_DIR_NOT_WRITABLE',
|
|
465
485
|
message: (cacheDir, details) => `Cache directory is not writable: ${cacheDir}${details ? `. ${details}` : ''}`
|
|
466
486
|
},
|
|
487
|
+
[SDK_SERVER_ERROR_CODES.INVALID_SEED_FROM_PARAMS]: {
|
|
488
|
+
name: 'INVALID_SEED_FROM_PARAMS',
|
|
489
|
+
message: 'seedFrom needs a caller-managed kvCache key other than itself'
|
|
490
|
+
},
|
|
491
|
+
[SDK_SERVER_ERROR_CODES.KV_CACHE_SEED_SOURCE_NOT_FOUND]: {
|
|
492
|
+
name: 'KV_CACHE_SEED_SOURCE_NOT_FOUND',
|
|
493
|
+
message: (seedFrom, modelId) => `No cache named "${seedFrom}" exists for model "${modelId}" with this system prompt`
|
|
494
|
+
},
|
|
495
|
+
[SDK_SERVER_ERROR_CODES.KV_CACHE_SEED_SHARING_DISABLED]: {
|
|
496
|
+
name: 'KV_CACHE_SEED_SHARING_DISABLED',
|
|
497
|
+
message: (modelId) => `seedFrom has no effect on model "${modelId}": it was not loaded with cache_share_across_keys true`
|
|
498
|
+
},
|
|
467
499
|
// Config Operations (53,350-53,499)
|
|
468
500
|
[SDK_SERVER_ERROR_CODES.SET_CONFIG_FAILED]: {
|
|
469
501
|
name: 'SET_CONFIG_FAILED',
|
|
@@ -556,6 +588,27 @@ const serverErrorDefinitions = {
|
|
|
556
588
|
name: 'LIFECYCLE_OPERATION_BLOCKED',
|
|
557
589
|
message: (requestType, lifecycleState) => `Operation "${requestType}" is blocked while runtime state is "${lifecycleState}"`
|
|
558
590
|
},
|
|
591
|
+
// Caller sessions and model leases (53,620-53,649)
|
|
592
|
+
[SDK_SERVER_ERROR_CODES.SESSION_ID_CONFLICT]: {
|
|
593
|
+
name: 'SESSION_ID_CONFLICT',
|
|
594
|
+
message: (sessionId) => `Session id "${sessionId}" is already open`
|
|
595
|
+
},
|
|
596
|
+
[SDK_SERVER_ERROR_CODES.SESSION_NOT_OPEN]: {
|
|
597
|
+
name: 'SESSION_NOT_OPEN',
|
|
598
|
+
message: (sessionId) => `Session "${sessionId}" is not open`
|
|
599
|
+
},
|
|
600
|
+
[SDK_SERVER_ERROR_CODES.MODEL_LEASED]: {
|
|
601
|
+
name: 'MODEL_LEASED',
|
|
602
|
+
message: (modelId, leaseCount) => `Model "${modelId}" is held by ${leaseCount} other session(s); it cannot be reconfigured while another session uses it`
|
|
603
|
+
},
|
|
604
|
+
[SDK_SERVER_ERROR_CODES.OWNER_ONLY]: {
|
|
605
|
+
name: 'OWNER_ONLY',
|
|
606
|
+
message: (operation, sessionId) => `Operation "${operation}" is reserved for the runtime owner; session "${sessionId}" cannot call it`
|
|
607
|
+
},
|
|
608
|
+
[SDK_SERVER_ERROR_CODES.MODEL_RECONFIGURED]: {
|
|
609
|
+
name: 'MODEL_RECONFIGURED',
|
|
610
|
+
message: (modelId) => `Model "${modelId}" was reconfigured after it was loaded and no longer has the configuration this load asks for; load it again once it is unloaded`
|
|
611
|
+
},
|
|
559
612
|
// Security (53,900-53,949)
|
|
560
613
|
[SDK_SERVER_ERROR_CODES.PATH_TRAVERSAL]: {
|
|
561
614
|
name: 'PATH_TRAVERSAL',
|
|
@@ -570,6 +623,11 @@ const serverErrorDefinitions = {
|
|
|
570
623
|
[SDK_SERVER_ERROR_CODES.QVAC_MODEL_REGISTRY_MODEL_NOT_FOUND]: {
|
|
571
624
|
name: 'QVAC_MODEL_REGISTRY_MODEL_NOT_FOUND',
|
|
572
625
|
message: (registrySource, registryPath) => `QVAC model registry has no model at ${registrySource}/${registryPath}`
|
|
626
|
+
},
|
|
627
|
+
// Owned by @qvac/inference, which registers it first; kept here for the contract export.
|
|
628
|
+
[SDK_SERVER_ERROR_CODES.QVAC_MODEL_REGISTRY_BUSY]: {
|
|
629
|
+
name: 'QVAC_MODEL_REGISTRY_BUSY',
|
|
630
|
+
message: modelRegistryBusyMessage
|
|
573
631
|
}
|
|
574
632
|
};
|
|
575
633
|
const serverDefinitionsToRegister = Object.fromEntries(Object.entries(serverErrorDefinitions).filter(([code]) => !isCodeRegistered(Number(code))));
|
|
@@ -1,10 +1,31 @@
|
|
|
1
|
+
import RPC from 'bare-rpc';
|
|
1
2
|
import { type AbortSignal } from 'bare-abort-controller';
|
|
2
3
|
export declare function getNextCommandId(): number;
|
|
4
|
+
/**
|
|
5
|
+
* The worker's RPC session. Each incoming request gets a `signal` that aborts
|
|
6
|
+
* when the client cancels the request or the session ends.
|
|
7
|
+
*/
|
|
8
|
+
export declare function createWorkerRpc(stream: ConstructorParameters<typeof RPC>[0], onRequest: (req: RPC.IncomingRequest) => void | Promise<void>): RPC;
|
|
9
|
+
/**
|
|
10
|
+
* Aborts when the client cancels the request or goes away (`req.signal`), or
|
|
11
|
+
* when `responseStream` closes. A client without bare-rpc 2 cancellation, such
|
|
12
|
+
* as one on an older bare-rpc, stops a stream by destroying its end, which
|
|
13
|
+
* closes the stream without a cancel. The stream also closes after a normal
|
|
14
|
+
* end, once the engine has finished with the signal.
|
|
15
|
+
*/
|
|
16
|
+
export declare function signalOnCancelOrStreamClose(req: {
|
|
17
|
+
signal: AbortSignal | null;
|
|
18
|
+
}, responseStream: {
|
|
19
|
+
on(event: 'close', listener: () => void): unknown;
|
|
20
|
+
}): AbortSignal;
|
|
3
21
|
export declare function isTerminalChunk<T>(value: T): value is T & {
|
|
4
22
|
done: true;
|
|
5
23
|
};
|
|
6
|
-
/**
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
24
|
+
/**
|
|
25
|
+
* When the client goes away, bare-rpc destroys a response stream that is
|
|
26
|
+
* still open with the channel or cancel error. No one is left to read that
|
|
27
|
+
* error, and an `error` event without a listener is thrown as an uncaught
|
|
28
|
+
* exception, so it is logged here instead.
|
|
29
|
+
*/
|
|
30
|
+
export declare function createResponseStreamLoggingErrors(req: RPC.IncomingRequest): RPC.OutgoingStream;
|
|
10
31
|
//# sourceMappingURL=rpc-utils.d.ts.map
|
|
@@ -1,15 +1,49 @@
|
|
|
1
|
+
import RPC from 'bare-rpc';
|
|
1
2
|
import { AbortController } from 'bare-abort-controller';
|
|
3
|
+
import { getServerLogger } from '../../logging/index.js';
|
|
4
|
+
const logger = getServerLogger();
|
|
2
5
|
let commandCounter = 0;
|
|
3
6
|
export function getNextCommandId() {
|
|
4
7
|
commandCounter = (commandCounter + 1) % Number.MAX_SAFE_INTEGER;
|
|
5
8
|
return commandCounter;
|
|
6
9
|
}
|
|
7
|
-
|
|
8
|
-
|
|
10
|
+
/**
|
|
11
|
+
* The worker's RPC session. Each incoming request gets a `signal` that aborts
|
|
12
|
+
* when the client cancels the request or the session ends.
|
|
13
|
+
*/
|
|
14
|
+
export function createWorkerRpc(stream, onRequest) {
|
|
15
|
+
return new RPC(stream, onRequest, { AbortController });
|
|
9
16
|
}
|
|
10
|
-
/**
|
|
11
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Aborts when the client cancels the request or goes away (`req.signal`), or
|
|
19
|
+
* when `responseStream` closes. A client without bare-rpc 2 cancellation, such
|
|
20
|
+
* as one on an older bare-rpc, stops a stream by destroying its end, which
|
|
21
|
+
* closes the stream without a cancel. The stream also closes after a normal
|
|
22
|
+
* end, once the engine has finished with the signal.
|
|
23
|
+
*/
|
|
24
|
+
export function signalOnCancelOrStreamClose(req, responseStream) {
|
|
12
25
|
const controller = new AbortController();
|
|
13
|
-
|
|
26
|
+
const abort = () => controller.abort(undefined);
|
|
27
|
+
if (req.signal?.aborted)
|
|
28
|
+
abort();
|
|
29
|
+
else
|
|
30
|
+
req.signal?.addEventListener('abort', abort, { once: true });
|
|
31
|
+
responseStream.on('close', abort);
|
|
14
32
|
return controller.signal;
|
|
15
33
|
}
|
|
34
|
+
export function isTerminalChunk(value) {
|
|
35
|
+
return typeof value === 'object' && value !== null && 'done' in value && value.done === true;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* When the client goes away, bare-rpc destroys a response stream that is
|
|
39
|
+
* still open with the channel or cancel error. No one is left to read that
|
|
40
|
+
* error, and an `error` event without a listener is thrown as an uncaught
|
|
41
|
+
* exception, so it is logged here instead.
|
|
42
|
+
*/
|
|
43
|
+
export function createResponseStreamLoggingErrors(req) {
|
|
44
|
+
const responseStream = req.createResponseStream();
|
|
45
|
+
responseStream.on('error', (error) => {
|
|
46
|
+
logger.debug('Response stream closed with an error:', error);
|
|
47
|
+
});
|
|
48
|
+
return responseStream;
|
|
49
|
+
}
|
|
@@ -38,35 +38,49 @@ export declare class RPCResponseStreamNotCreatedError extends QvacErrorBase {
|
|
|
38
38
|
export declare class RPCConnectionFailedError extends QvacErrorBase {
|
|
39
39
|
constructor(details: string, cause?: unknown);
|
|
40
40
|
}
|
|
41
|
-
export declare class RPCInitTimeoutError extends QvacErrorBase {
|
|
42
|
-
constructor(timeoutMs: number, cause?: unknown);
|
|
43
|
-
}
|
|
44
41
|
export declare class WorkerCrashedError extends QvacErrorBase {
|
|
45
42
|
readonly exitCode: number | null;
|
|
46
43
|
readonly exitSignal: NodeJS.Signals | null;
|
|
47
44
|
constructor(exitCode: number | null, exitSignal: NodeJS.Signals | null, cause?: unknown);
|
|
48
45
|
}
|
|
49
46
|
/**
|
|
50
|
-
* A worker that failed before
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
* on the post-handshake path.
|
|
47
|
+
* A worker that failed to start: before signalling ready, or while applying its
|
|
48
|
+
* configuration. `cause` is the worker's own error. `exitCode` and `exitSignal`
|
|
49
|
+
* are set when the worker process exited without one.
|
|
54
50
|
*/
|
|
55
51
|
export declare class WorkerStartupError extends QvacErrorBase {
|
|
56
|
-
/** False while the process is still running and simply has not connected. */
|
|
57
|
-
readonly workerExited: boolean;
|
|
58
52
|
readonly exitCode: number | null;
|
|
59
53
|
readonly exitSignal: NodeJS.Signals | null;
|
|
60
|
-
/**
|
|
61
|
-
readonly
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
54
|
+
/** The worker did not finish starting within `rpcInitTimeoutMs`. */
|
|
55
|
+
readonly timedOut: boolean;
|
|
56
|
+
/** The end of a desktop worker process's stderr, when it wrote any. */
|
|
57
|
+
readonly stderrTail: string | undefined;
|
|
58
|
+
constructor(details: string, failure: {
|
|
59
|
+
exitCode: number | null;
|
|
60
|
+
exitSignal: NodeJS.Signals | null;
|
|
61
|
+
timedOut: boolean;
|
|
62
|
+
stderrTail?: string | undefined;
|
|
63
|
+
}, cause?: unknown);
|
|
66
64
|
}
|
|
67
65
|
export declare class WorkerShutdownError extends QvacErrorBase {
|
|
68
66
|
constructor(cause?: unknown);
|
|
69
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* The session handle can no longer reach its worker-side session: the caller
|
|
70
|
+
* closed it, the owner shut the runtime down, or the worker exited. Raised
|
|
71
|
+
* locally, before any wire traffic.
|
|
72
|
+
*/
|
|
73
|
+
export declare class SessionInvalidatedError extends QvacErrorBase {
|
|
74
|
+
readonly sessionId: string;
|
|
75
|
+
readonly reason: 'closed' | 'shutdown' | 'crashed';
|
|
76
|
+
constructor(sessionId: string, reason: 'closed' | 'shutdown' | 'crashed', cause?: unknown);
|
|
77
|
+
}
|
|
78
|
+
/** A model id that a now-invalid session loaded; the model is gone with it. */
|
|
79
|
+
export declare class ModelHandleInvalidatedError extends QvacErrorBase {
|
|
80
|
+
readonly modelId: string;
|
|
81
|
+
readonly sessionId: string;
|
|
82
|
+
constructor(modelId: string, sessionId: string, cause?: unknown);
|
|
83
|
+
}
|
|
70
84
|
export declare class SDKNotFoundInNodeModulesError extends QvacErrorBase {
|
|
71
85
|
constructor(cause?: unknown);
|
|
72
86
|
}
|
|
@@ -76,33 +90,27 @@ export declare class MultipleSDKInstallationsError extends QvacErrorBase {
|
|
|
76
90
|
export declare class WorkerFileNotFoundError extends QvacErrorBase {
|
|
77
91
|
constructor(workerPath: string, cause?: unknown);
|
|
78
92
|
}
|
|
79
|
-
export declare class PearWorkerEntryRequiredError extends QvacErrorBase {
|
|
80
|
-
constructor(workerEntry: string, cause?: unknown);
|
|
81
|
-
}
|
|
82
|
-
export declare class WorkerPluginsNotRegisteredError extends QvacErrorBase {
|
|
83
|
-
constructor(cause?: unknown);
|
|
84
|
-
}
|
|
85
93
|
export declare class BundleVerificationFailedError extends QvacErrorBase {
|
|
86
94
|
constructor(bundlePath: string, cause?: unknown);
|
|
87
95
|
}
|
|
88
|
-
export declare class
|
|
89
|
-
constructor(cause
|
|
90
|
-
}
|
|
91
|
-
export declare class BarePackError extends QvacErrorBase {
|
|
92
|
-
constructor(exitCode: number, entryPath: string, outputPath: string, cause?: unknown);
|
|
96
|
+
export declare class BundleFailedError extends QvacErrorBase {
|
|
97
|
+
constructor(entryPath: string, cause: unknown);
|
|
93
98
|
}
|
|
94
99
|
export declare class BarePackNodeUnsupportedError extends QvacErrorBase {
|
|
95
100
|
constructor(nodeVersion: string, requiredRange: string, cause?: unknown);
|
|
96
101
|
}
|
|
102
|
+
export declare class BundleTargetNotInstalledError extends QvacErrorBase {
|
|
103
|
+
constructor(target: string, packageName: string, cause?: unknown);
|
|
104
|
+
}
|
|
105
|
+
export declare class ReactNativeBareKitUnsupportedError extends QvacErrorBase {
|
|
106
|
+
constructor(installedVersion: string, requiredRange: string, cause?: unknown);
|
|
107
|
+
}
|
|
97
108
|
export declare class InvalidPluginSpecifierError extends QvacErrorBase {
|
|
98
109
|
constructor(specifiers: string[], cause?: unknown);
|
|
99
110
|
}
|
|
100
111
|
export declare class BareImportsMapNotFoundError extends QvacErrorBase {
|
|
101
112
|
constructor(sdkName: string, expectedPath: string, cause?: unknown);
|
|
102
113
|
}
|
|
103
|
-
export declare class BareRuntimeBinaryNotFoundError extends QvacErrorBase {
|
|
104
|
-
constructor(platform: string, arch: string, cause?: unknown);
|
|
105
|
-
}
|
|
106
114
|
/**
|
|
107
115
|
* Addon platform packages are missing and cannot be installed automatically:
|
|
108
116
|
* no supported package manager was detected, two installed versions of one
|