@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
|
@@ -69,11 +69,6 @@ export class RPCConnectionFailedError extends QvacErrorBase {
|
|
|
69
69
|
super(createErrorOptions(SDK_CLIENT_ERROR_CODES.RPC_CONNECTION_FAILED, [details], cause));
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
|
-
export class RPCInitTimeoutError extends QvacErrorBase {
|
|
73
|
-
constructor(timeoutMs, cause) {
|
|
74
|
-
super(createErrorOptions(SDK_CLIENT_ERROR_CODES.RPC_INIT_TIMEOUT, [timeoutMs], cause));
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
72
|
export class WorkerCrashedError extends QvacErrorBase {
|
|
78
73
|
exitCode;
|
|
79
74
|
exitSignal;
|
|
@@ -84,24 +79,23 @@ export class WorkerCrashedError extends QvacErrorBase {
|
|
|
84
79
|
}
|
|
85
80
|
}
|
|
86
81
|
/**
|
|
87
|
-
* A worker that failed before
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
* on the post-handshake path.
|
|
82
|
+
* A worker that failed to start: before signalling ready, or while applying its
|
|
83
|
+
* configuration. `cause` is the worker's own error. `exitCode` and `exitSignal`
|
|
84
|
+
* are set when the worker process exited without one.
|
|
91
85
|
*/
|
|
92
86
|
export class WorkerStartupError extends QvacErrorBase {
|
|
93
|
-
/** False while the process is still running and simply has not connected. */
|
|
94
|
-
workerExited;
|
|
95
87
|
exitCode;
|
|
96
88
|
exitSignal;
|
|
97
|
-
/**
|
|
89
|
+
/** The worker did not finish starting within `rpcInitTimeoutMs`. */
|
|
90
|
+
timedOut;
|
|
91
|
+
/** The end of a desktop worker process's stderr, when it wrote any. */
|
|
98
92
|
stderrTail;
|
|
99
|
-
constructor(details,
|
|
100
|
-
super(createErrorOptions(SDK_CLIENT_ERROR_CODES.WORKER_STARTUP_FAILED, [details
|
|
101
|
-
this.
|
|
102
|
-
this.
|
|
103
|
-
this.
|
|
104
|
-
this.stderrTail = stderrTail;
|
|
93
|
+
constructor(details, failure, cause) {
|
|
94
|
+
super(createErrorOptions(SDK_CLIENT_ERROR_CODES.WORKER_STARTUP_FAILED, [details], cause));
|
|
95
|
+
this.exitCode = failure.exitCode;
|
|
96
|
+
this.exitSignal = failure.exitSignal;
|
|
97
|
+
this.timedOut = failure.timedOut;
|
|
98
|
+
this.stderrTail = failure.stderrTail;
|
|
105
99
|
}
|
|
106
100
|
}
|
|
107
101
|
export class WorkerShutdownError extends QvacErrorBase {
|
|
@@ -109,6 +103,30 @@ export class WorkerShutdownError extends QvacErrorBase {
|
|
|
109
103
|
super(createErrorOptions(SDK_CLIENT_ERROR_CODES.WORKER_SHUTDOWN, undefined, cause));
|
|
110
104
|
}
|
|
111
105
|
}
|
|
106
|
+
/**
|
|
107
|
+
* The session handle can no longer reach its worker-side session: the caller
|
|
108
|
+
* closed it, the owner shut the runtime down, or the worker exited. Raised
|
|
109
|
+
* locally, before any wire traffic.
|
|
110
|
+
*/
|
|
111
|
+
export class SessionInvalidatedError extends QvacErrorBase {
|
|
112
|
+
sessionId;
|
|
113
|
+
reason;
|
|
114
|
+
constructor(sessionId, reason, cause) {
|
|
115
|
+
super(createErrorOptions(SDK_CLIENT_ERROR_CODES.SESSION_INVALIDATED, [sessionId, reason], cause));
|
|
116
|
+
this.sessionId = sessionId;
|
|
117
|
+
this.reason = reason;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
/** A model id that a now-invalid session loaded; the model is gone with it. */
|
|
121
|
+
export class ModelHandleInvalidatedError extends QvacErrorBase {
|
|
122
|
+
modelId;
|
|
123
|
+
sessionId;
|
|
124
|
+
constructor(modelId, sessionId, cause) {
|
|
125
|
+
super(createErrorOptions(SDK_CLIENT_ERROR_CODES.MODEL_HANDLE_INVALIDATED, [modelId, sessionId], cause));
|
|
126
|
+
this.modelId = modelId;
|
|
127
|
+
this.sessionId = sessionId;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
112
130
|
// ============== Build/Bundle Errors ==============
|
|
113
131
|
export class SDKNotFoundInNodeModulesError extends QvacErrorBase {
|
|
114
132
|
constructor(cause) {
|
|
@@ -125,29 +143,15 @@ export class WorkerFileNotFoundError extends QvacErrorBase {
|
|
|
125
143
|
super(createErrorOptions(SDK_CLIENT_ERROR_CODES.WORKER_FILE_NOT_FOUND, [workerPath], cause));
|
|
126
144
|
}
|
|
127
145
|
}
|
|
128
|
-
export class PearWorkerEntryRequiredError extends QvacErrorBase {
|
|
129
|
-
constructor(workerEntry, cause) {
|
|
130
|
-
super(createErrorOptions(SDK_CLIENT_ERROR_CODES.PEAR_WORKER_ENTRY_REQUIRED, [workerEntry], cause));
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
export class WorkerPluginsNotRegisteredError extends QvacErrorBase {
|
|
134
|
-
constructor(cause) {
|
|
135
|
-
super(createErrorOptions(SDK_CLIENT_ERROR_CODES.WORKER_PLUGINS_NOT_REGISTERED, [], cause));
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
146
|
export class BundleVerificationFailedError extends QvacErrorBase {
|
|
139
147
|
constructor(bundlePath, cause) {
|
|
140
148
|
super(createErrorOptions(SDK_CLIENT_ERROR_CODES.BUNDLE_VERIFICATION_FAILED, [bundlePath], cause));
|
|
141
149
|
}
|
|
142
150
|
}
|
|
143
|
-
export class
|
|
144
|
-
constructor(cause) {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
}
|
|
148
|
-
export class BarePackError extends QvacErrorBase {
|
|
149
|
-
constructor(exitCode, entryPath, outputPath, cause) {
|
|
150
|
-
super(createErrorOptions(SDK_CLIENT_ERROR_CODES.BARE_PACK_ERROR, [exitCode, entryPath, outputPath], cause));
|
|
151
|
+
export class BundleFailedError extends QvacErrorBase {
|
|
152
|
+
constructor(entryPath, cause) {
|
|
153
|
+
const reason = cause instanceof Error ? cause.message : String(cause);
|
|
154
|
+
super(createErrorOptions(SDK_CLIENT_ERROR_CODES.BUNDLE_FAILED, [entryPath, reason], cause));
|
|
151
155
|
}
|
|
152
156
|
}
|
|
153
157
|
export class BarePackNodeUnsupportedError extends QvacErrorBase {
|
|
@@ -155,6 +159,16 @@ export class BarePackNodeUnsupportedError extends QvacErrorBase {
|
|
|
155
159
|
super(createErrorOptions(SDK_CLIENT_ERROR_CODES.BARE_PACK_NODE_UNSUPPORTED, [nodeVersion, requiredRange], cause));
|
|
156
160
|
}
|
|
157
161
|
}
|
|
162
|
+
export class BundleTargetNotInstalledError extends QvacErrorBase {
|
|
163
|
+
constructor(target, packageName, cause) {
|
|
164
|
+
super(createErrorOptions(SDK_CLIENT_ERROR_CODES.BUNDLE_TARGET_NOT_INSTALLED, [target, packageName], cause));
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
export class ReactNativeBareKitUnsupportedError extends QvacErrorBase {
|
|
168
|
+
constructor(installedVersion, requiredRange, cause) {
|
|
169
|
+
super(createErrorOptions(SDK_CLIENT_ERROR_CODES.REACT_NATIVE_BARE_KIT_UNSUPPORTED, [installedVersion, requiredRange], cause));
|
|
170
|
+
}
|
|
171
|
+
}
|
|
158
172
|
export class InvalidPluginSpecifierError extends QvacErrorBase {
|
|
159
173
|
constructor(specifiers, cause) {
|
|
160
174
|
const list = specifiers.map((s) => ` - ${s}`).join('\n');
|
|
@@ -166,11 +180,6 @@ export class BareImportsMapNotFoundError extends QvacErrorBase {
|
|
|
166
180
|
super(createErrorOptions(SDK_CLIENT_ERROR_CODES.BARE_IMPORTS_MAP_NOT_FOUND, [sdkName, expectedPath], cause));
|
|
167
181
|
}
|
|
168
182
|
}
|
|
169
|
-
export class BareRuntimeBinaryNotFoundError extends QvacErrorBase {
|
|
170
|
-
constructor(platform, arch, cause) {
|
|
171
|
-
super(createErrorOptions(SDK_CLIENT_ERROR_CODES.BARE_RUNTIME_BINARY_NOT_FOUND, [platform, arch], cause));
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
183
|
/**
|
|
175
184
|
* Addon platform packages are missing and cannot be installed automatically:
|
|
176
185
|
* no supported package manager was detected, two installed versions of one
|
|
@@ -225,6 +225,12 @@ export declare class InvalidImageInputError extends QvacErrorBase {
|
|
|
225
225
|
export declare class InvalidAudioInputError extends QvacErrorBase {
|
|
226
226
|
constructor(details?: string, cause?: unknown);
|
|
227
227
|
}
|
|
228
|
+
export declare class AudioEncodeFailedError extends QvacErrorBase {
|
|
229
|
+
readonly format: string;
|
|
230
|
+
readonly details: string | undefined;
|
|
231
|
+
constructor(format: string, details?: string, cause?: unknown);
|
|
232
|
+
toErrorResponseFields(): Record<string, unknown>;
|
|
233
|
+
}
|
|
228
234
|
export declare class RAGSaveFailedError extends QvacErrorBase {
|
|
229
235
|
constructor(details?: string, cause?: unknown);
|
|
230
236
|
}
|
|
@@ -308,6 +314,20 @@ export declare class DeleteCacheFailedError extends QvacErrorBase {
|
|
|
308
314
|
export declare class InvalidDeleteCacheParamsError extends QvacErrorBase {
|
|
309
315
|
constructor(cause?: unknown);
|
|
310
316
|
}
|
|
317
|
+
export declare class InvalidSeedFromParamsError extends QvacErrorBase {
|
|
318
|
+
constructor(cause?: unknown);
|
|
319
|
+
}
|
|
320
|
+
export declare class KvCacheSeedSourceNotFoundError extends QvacErrorBase {
|
|
321
|
+
readonly seedFrom: string;
|
|
322
|
+
readonly modelId: string;
|
|
323
|
+
constructor(seedFrom: string, modelId: string, cause?: unknown);
|
|
324
|
+
toErrorResponseFields(): Record<string, unknown>;
|
|
325
|
+
}
|
|
326
|
+
export declare class KvCacheSeedSharingDisabledError extends QvacErrorBase {
|
|
327
|
+
readonly modelId: string;
|
|
328
|
+
constructor(modelId: string, cause?: unknown);
|
|
329
|
+
toErrorResponseFields(): Record<string, unknown>;
|
|
330
|
+
}
|
|
311
331
|
export declare class CacheDirNotAbsoluteError extends QvacErrorBase {
|
|
312
332
|
constructor(cause?: unknown);
|
|
313
333
|
}
|
|
@@ -338,6 +358,12 @@ export declare class RAGWorkspaceInUseError extends QvacErrorBase {
|
|
|
338
358
|
export declare class RAGWorkspaceNotOpenError extends QvacErrorBase {
|
|
339
359
|
constructor(workspace: string, cause?: unknown);
|
|
340
360
|
}
|
|
361
|
+
/** A RAG operation on a workspace that another session's operation is using. */
|
|
362
|
+
export declare class RAGWorkspaceBusyError extends QvacErrorBase {
|
|
363
|
+
readonly workspace: string;
|
|
364
|
+
constructor(workspace: string, cause?: unknown);
|
|
365
|
+
toErrorResponseFields(): Record<string, unknown>;
|
|
366
|
+
}
|
|
341
367
|
export declare class RPCNoDataReceivedError extends QvacErrorBase {
|
|
342
368
|
constructor(cause?: unknown);
|
|
343
369
|
}
|
|
@@ -380,6 +406,38 @@ export declare class LifecycleSuspendFailedError extends QvacErrorBase {
|
|
|
380
406
|
export declare class LifecycleResumeFailedError extends QvacErrorBase {
|
|
381
407
|
constructor(details?: string, cause?: unknown);
|
|
382
408
|
}
|
|
409
|
+
export declare class SessionIdConflictError extends QvacErrorBase {
|
|
410
|
+
readonly sessionId: string;
|
|
411
|
+
constructor(sessionId: string, cause?: unknown);
|
|
412
|
+
toErrorResponseFields(): Record<string, unknown>;
|
|
413
|
+
}
|
|
414
|
+
export declare class SessionNotOpenError extends QvacErrorBase {
|
|
415
|
+
readonly sessionId: string;
|
|
416
|
+
constructor(sessionId: string, cause?: unknown);
|
|
417
|
+
toErrorResponseFields(): Record<string, unknown>;
|
|
418
|
+
}
|
|
419
|
+
/** A `reloadConfig` on a model another session holds a lease on. */
|
|
420
|
+
export declare class ModelLeasedError extends QvacErrorBase {
|
|
421
|
+
readonly modelId: string;
|
|
422
|
+
readonly leaseCount: number;
|
|
423
|
+
constructor(modelId: string, leaseCount: number, cause?: unknown);
|
|
424
|
+
toErrorResponseFields(): Record<string, unknown>;
|
|
425
|
+
}
|
|
426
|
+
export declare class OwnerOnlyError extends QvacErrorBase {
|
|
427
|
+
readonly operation: string;
|
|
428
|
+
readonly sessionId: string;
|
|
429
|
+
constructor(operation: string, sessionId: string, cause?: unknown);
|
|
430
|
+
toErrorResponseFields(): Record<string, unknown>;
|
|
431
|
+
}
|
|
432
|
+
/**
|
|
433
|
+
* A load whose configuration hash names a model that a reload has since
|
|
434
|
+
* reconfigured, from a session that holds no lease on it.
|
|
435
|
+
*/
|
|
436
|
+
export declare class ModelReconfiguredError extends QvacErrorBase {
|
|
437
|
+
readonly modelId: string;
|
|
438
|
+
constructor(modelId: string, cause?: unknown);
|
|
439
|
+
toErrorResponseFields(): Record<string, unknown>;
|
|
440
|
+
}
|
|
383
441
|
export declare class LifecycleOperationBlockedError extends QvacErrorBase {
|
|
384
442
|
constructor(requestType: string, lifecycleState: string);
|
|
385
443
|
}
|
|
@@ -395,5 +453,5 @@ export declare class ModelRegistryModelNotFoundError extends QvacErrorBase {
|
|
|
395
453
|
constructor(registrySource: string, registryPath: string, cause?: unknown);
|
|
396
454
|
toErrorResponseFields(): Record<string, unknown>;
|
|
397
455
|
}
|
|
398
|
-
export { RpcServerOperationError } from '@qvac/inference/surface';
|
|
456
|
+
export { RpcServerOperationError, ModelRegistryBusyError } from '@qvac/inference/surface';
|
|
399
457
|
//# sourceMappingURL=errors-server.d.ts.map
|
|
@@ -349,6 +349,18 @@ export class InvalidAudioInputError extends QvacErrorBase {
|
|
|
349
349
|
super(createErrorOptions(SDK_SERVER_ERROR_CODES.INVALID_AUDIO_INPUT, details ? [details] : undefined, cause));
|
|
350
350
|
}
|
|
351
351
|
}
|
|
352
|
+
export class AudioEncodeFailedError extends QvacErrorBase {
|
|
353
|
+
format;
|
|
354
|
+
details;
|
|
355
|
+
constructor(format, details, cause) {
|
|
356
|
+
super(createErrorOptions(SDK_SERVER_ERROR_CODES.AUDIO_ENCODE_FAILED, details ? [format, details] : [format], cause));
|
|
357
|
+
this.format = format;
|
|
358
|
+
this.details = details;
|
|
359
|
+
}
|
|
360
|
+
toErrorResponseFields() {
|
|
361
|
+
return { format: this.format, ...(this.details !== undefined && { details: this.details }) };
|
|
362
|
+
}
|
|
363
|
+
}
|
|
352
364
|
// ============== RAG Operation Errors ==============
|
|
353
365
|
export class RAGSaveFailedError extends QvacErrorBase {
|
|
354
366
|
constructor(details, cause) {
|
|
@@ -491,6 +503,33 @@ export class InvalidDeleteCacheParamsError extends QvacErrorBase {
|
|
|
491
503
|
super(createErrorOptions(SDK_SERVER_ERROR_CODES.INVALID_DELETE_CACHE_PARAMS, undefined, cause));
|
|
492
504
|
}
|
|
493
505
|
}
|
|
506
|
+
export class InvalidSeedFromParamsError extends QvacErrorBase {
|
|
507
|
+
constructor(cause) {
|
|
508
|
+
super(createErrorOptions(SDK_SERVER_ERROR_CODES.INVALID_SEED_FROM_PARAMS, undefined, cause));
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
export class KvCacheSeedSourceNotFoundError extends QvacErrorBase {
|
|
512
|
+
seedFrom;
|
|
513
|
+
modelId;
|
|
514
|
+
constructor(seedFrom, modelId, cause) {
|
|
515
|
+
super(createErrorOptions(SDK_SERVER_ERROR_CODES.KV_CACHE_SEED_SOURCE_NOT_FOUND, [seedFrom, modelId], cause));
|
|
516
|
+
this.seedFrom = seedFrom;
|
|
517
|
+
this.modelId = modelId;
|
|
518
|
+
}
|
|
519
|
+
toErrorResponseFields() {
|
|
520
|
+
return { seedFrom: this.seedFrom, modelId: this.modelId };
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
export class KvCacheSeedSharingDisabledError extends QvacErrorBase {
|
|
524
|
+
modelId;
|
|
525
|
+
constructor(modelId, cause) {
|
|
526
|
+
super(createErrorOptions(SDK_SERVER_ERROR_CODES.KV_CACHE_SEED_SHARING_DISABLED, [modelId], cause));
|
|
527
|
+
this.modelId = modelId;
|
|
528
|
+
}
|
|
529
|
+
toErrorResponseFields() {
|
|
530
|
+
return { modelId: this.modelId };
|
|
531
|
+
}
|
|
532
|
+
}
|
|
494
533
|
export class CacheDirNotAbsoluteError extends QvacErrorBase {
|
|
495
534
|
constructor(cause) {
|
|
496
535
|
super(createErrorOptions(SDK_SERVER_ERROR_CODES.CACHE_DIR_NOT_ABSOLUTE, undefined, cause));
|
|
@@ -544,6 +583,17 @@ export class RAGWorkspaceNotOpenError extends QvacErrorBase {
|
|
|
544
583
|
super(createErrorOptions(SDK_SERVER_ERROR_CODES.RAG_WORKSPACE_NOT_OPEN, [workspace], cause));
|
|
545
584
|
}
|
|
546
585
|
}
|
|
586
|
+
/** A RAG operation on a workspace that another session's operation is using. */
|
|
587
|
+
export class RAGWorkspaceBusyError extends QvacErrorBase {
|
|
588
|
+
workspace;
|
|
589
|
+
constructor(workspace, cause) {
|
|
590
|
+
super(createErrorOptions(SDK_SERVER_ERROR_CODES.RAG_WORKSPACE_BUSY, [workspace], cause));
|
|
591
|
+
this.workspace = workspace;
|
|
592
|
+
}
|
|
593
|
+
toErrorResponseFields() {
|
|
594
|
+
return { workspace: this.workspace };
|
|
595
|
+
}
|
|
596
|
+
}
|
|
547
597
|
// ============== RPC Errors (Server-side) ==============
|
|
548
598
|
export class RPCNoDataReceivedError extends QvacErrorBase {
|
|
549
599
|
constructor(cause) {
|
|
@@ -618,6 +668,65 @@ export class LifecycleResumeFailedError extends QvacErrorBase {
|
|
|
618
668
|
super(createErrorOptions(SDK_SERVER_ERROR_CODES.LIFECYCLE_RESUME_FAILED, details ? [details] : undefined, cause));
|
|
619
669
|
}
|
|
620
670
|
}
|
|
671
|
+
export class SessionIdConflictError extends QvacErrorBase {
|
|
672
|
+
sessionId;
|
|
673
|
+
constructor(sessionId, cause) {
|
|
674
|
+
super(createErrorOptions(SDK_SERVER_ERROR_CODES.SESSION_ID_CONFLICT, [sessionId], cause));
|
|
675
|
+
this.sessionId = sessionId;
|
|
676
|
+
}
|
|
677
|
+
toErrorResponseFields() {
|
|
678
|
+
return { sessionId: this.sessionId };
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
export class SessionNotOpenError extends QvacErrorBase {
|
|
682
|
+
sessionId;
|
|
683
|
+
constructor(sessionId, cause) {
|
|
684
|
+
super(createErrorOptions(SDK_SERVER_ERROR_CODES.SESSION_NOT_OPEN, [sessionId], cause));
|
|
685
|
+
this.sessionId = sessionId;
|
|
686
|
+
}
|
|
687
|
+
toErrorResponseFields() {
|
|
688
|
+
return { sessionId: this.sessionId };
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
/** A `reloadConfig` on a model another session holds a lease on. */
|
|
692
|
+
export class ModelLeasedError extends QvacErrorBase {
|
|
693
|
+
modelId;
|
|
694
|
+
leaseCount;
|
|
695
|
+
constructor(modelId, leaseCount, cause) {
|
|
696
|
+
super(createErrorOptions(SDK_SERVER_ERROR_CODES.MODEL_LEASED, [modelId, String(leaseCount)], cause));
|
|
697
|
+
this.modelId = modelId;
|
|
698
|
+
this.leaseCount = leaseCount;
|
|
699
|
+
}
|
|
700
|
+
toErrorResponseFields() {
|
|
701
|
+
return { modelId: this.modelId, leaseCount: this.leaseCount };
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
export class OwnerOnlyError extends QvacErrorBase {
|
|
705
|
+
operation;
|
|
706
|
+
sessionId;
|
|
707
|
+
constructor(operation, sessionId, cause) {
|
|
708
|
+
super(createErrorOptions(SDK_SERVER_ERROR_CODES.OWNER_ONLY, [operation, sessionId], cause));
|
|
709
|
+
this.operation = operation;
|
|
710
|
+
this.sessionId = sessionId;
|
|
711
|
+
}
|
|
712
|
+
toErrorResponseFields() {
|
|
713
|
+
return { operation: this.operation, sessionId: this.sessionId };
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
/**
|
|
717
|
+
* A load whose configuration hash names a model that a reload has since
|
|
718
|
+
* reconfigured, from a session that holds no lease on it.
|
|
719
|
+
*/
|
|
720
|
+
export class ModelReconfiguredError extends QvacErrorBase {
|
|
721
|
+
modelId;
|
|
722
|
+
constructor(modelId, cause) {
|
|
723
|
+
super(createErrorOptions(SDK_SERVER_ERROR_CODES.MODEL_RECONFIGURED, [modelId], cause));
|
|
724
|
+
this.modelId = modelId;
|
|
725
|
+
}
|
|
726
|
+
toErrorResponseFields() {
|
|
727
|
+
return { modelId: this.modelId };
|
|
728
|
+
}
|
|
729
|
+
}
|
|
621
730
|
export class LifecycleOperationBlockedError extends QvacErrorBase {
|
|
622
731
|
constructor(requestType, lifecycleState) {
|
|
623
732
|
super(createErrorOptions(SDK_SERVER_ERROR_CODES.LIFECYCLE_OPERATION_BLOCKED, [
|
|
@@ -652,4 +761,4 @@ export class ModelRegistryModelNotFoundError extends QvacErrorBase {
|
|
|
652
761
|
return { registrySource: this.registrySource, registryPath: this.registryPath };
|
|
653
762
|
}
|
|
654
763
|
}
|
|
655
|
-
export { RpcServerOperationError } from '@qvac/inference/surface';
|
|
764
|
+
export { RpcServerOperationError, ModelRegistryBusyError } from '@qvac/inference/surface';
|
|
@@ -8,16 +8,6 @@ export class OperationTimeoutError extends Error {
|
|
|
8
8
|
this.name = 'OperationTimeoutError';
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
|
-
/**
|
|
12
|
-
* Creates a timeout promise that rejects after the specified duration
|
|
13
|
-
*/
|
|
14
|
-
function createTimeoutPromise(timeoutMs) {
|
|
15
|
-
return new Promise((_, reject) => {
|
|
16
|
-
setTimeout(() => {
|
|
17
|
-
reject(new OperationTimeoutError(timeoutMs));
|
|
18
|
-
}, timeoutMs);
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
11
|
/**
|
|
22
12
|
* Wraps a promise with an optional timeout
|
|
23
13
|
* If no timeout is provided, returns the original promise unchanged
|
|
@@ -26,8 +16,18 @@ export async function withTimeout(promise, timeoutMs) {
|
|
|
26
16
|
if (timeoutMs === undefined) {
|
|
27
17
|
return promise;
|
|
28
18
|
}
|
|
29
|
-
|
|
30
|
-
|
|
19
|
+
let timer;
|
|
20
|
+
try {
|
|
21
|
+
return await Promise.race([
|
|
22
|
+
promise,
|
|
23
|
+
new Promise((_, reject) => {
|
|
24
|
+
timer = setTimeout(() => reject(new OperationTimeoutError(timeoutMs)), timeoutMs);
|
|
25
|
+
})
|
|
26
|
+
]);
|
|
27
|
+
}
|
|
28
|
+
finally {
|
|
29
|
+
clearTimeout(timer);
|
|
30
|
+
}
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
33
33
|
* Wraps an async generator with optional timeout per iteration
|
|
@@ -38,10 +38,27 @@ export async function* withTimeoutStream(generator, timeoutMs) {
|
|
|
38
38
|
yield* generator;
|
|
39
39
|
return;
|
|
40
40
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
41
|
+
let timedOut = false;
|
|
42
|
+
try {
|
|
43
|
+
while (true) {
|
|
44
|
+
const result = await withTimeout(generator.next(), timeoutMs);
|
|
45
|
+
if (result.done)
|
|
46
|
+
return;
|
|
47
|
+
yield result.value;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
timedOut = error instanceof OperationTimeoutError;
|
|
52
|
+
throw error;
|
|
53
|
+
}
|
|
54
|
+
finally {
|
|
55
|
+
const closing = generator.return(undefined);
|
|
56
|
+
if (timedOut) {
|
|
57
|
+
// return() queues behind a pending next(); waiting would hide the timeout.
|
|
58
|
+
void closing.catch(() => { });
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
await closing;
|
|
62
|
+
}
|
|
46
63
|
}
|
|
47
64
|
}
|
|
@@ -2,9 +2,9 @@ import { PROFILING_KEY, nowMs } from '@qvac/inference/surface';
|
|
|
2
2
|
import { send, stream, duplex, dispatchTransport } from '@qvac/inference/engine';
|
|
3
3
|
import { sendErrorResponse, sendStreamErrorResponse } from '../server/error-handlers.js';
|
|
4
4
|
import { PluginHandlerTypeMismatchError } from '../utils/errors-server.js';
|
|
5
|
-
import { handleInitConfig, isInitConfigMessage
|
|
5
|
+
import { handleInitConfig, isInitConfigMessage } from './handler-utils.js';
|
|
6
6
|
import { createServerProfiler } from '../server/rpc/profiling/index.js';
|
|
7
|
-
import { isTerminalChunk,
|
|
7
|
+
import { createResponseStreamLoggingErrors, isTerminalChunk, signalOnCancelOrStreamClose } from '../server/rpc/rpc-utils.js';
|
|
8
8
|
import { createProgressThrottle } from '../server/rpc/progress-throttle.js';
|
|
9
9
|
export async function handleRequest(req) {
|
|
10
10
|
let profiler;
|
|
@@ -27,10 +27,6 @@ export async function handleRequest(req) {
|
|
|
27
27
|
handleInitConfig(req, jsonData);
|
|
28
28
|
return;
|
|
29
29
|
}
|
|
30
|
-
if (isShutdownMessage(jsonData)) {
|
|
31
|
-
await handleShutdown(req);
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
30
|
const { data: cleanData, profilingMeta } = extractProfilingMeta(jsonData);
|
|
35
31
|
profiler = createServerProfiler(profilingMeta);
|
|
36
32
|
profiler.markRequestParsed(jsonParseMs);
|
|
@@ -40,55 +36,54 @@ export async function handleRequest(req) {
|
|
|
40
36
|
attachProfilingMetaToRequest(request, profilingMeta);
|
|
41
37
|
transport = dispatchTransport(request);
|
|
42
38
|
if (transport === 'stream' || transport === 'progress') {
|
|
43
|
-
await
|
|
39
|
+
await streamToResponse(req, request, profiler, transport === 'progress');
|
|
44
40
|
}
|
|
45
41
|
else if (transport === 'duplex') {
|
|
46
42
|
throw new PluginHandlerTypeMismatchError(request.type, 'reply or stream', 'duplex');
|
|
47
43
|
}
|
|
48
44
|
else {
|
|
49
45
|
profiler.startHandler();
|
|
50
|
-
const response = await send(request);
|
|
46
|
+
const response = await send(request, transportOptions(req));
|
|
51
47
|
profiler.endHandler();
|
|
52
48
|
req.reply(profiler.serialize(response, true), 'utf-8');
|
|
53
49
|
}
|
|
54
50
|
}
|
|
55
51
|
catch (error) {
|
|
56
52
|
if (transport === 'stream' || transport === 'progress') {
|
|
57
|
-
sendStreamErrorResponse(req
|
|
53
|
+
sendStreamErrorResponse(createResponseStreamLoggingErrors(req), error, profiler);
|
|
58
54
|
}
|
|
59
55
|
else {
|
|
60
56
|
sendErrorResponse(req, error, profiler);
|
|
61
57
|
}
|
|
62
58
|
}
|
|
63
59
|
}
|
|
64
|
-
async function
|
|
65
|
-
const
|
|
60
|
+
async function streamToResponse(req, request, profiler, throttleProgress) {
|
|
61
|
+
const responseStream = createResponseStreamLoggingErrors(req);
|
|
66
62
|
profiler.startHandler();
|
|
67
63
|
let sentFinalChunk = false;
|
|
68
|
-
// Lets an `endsOnAbort` handler (log stream) release its source when the client aborts.
|
|
69
|
-
const signal = signalOnWireClose(wire);
|
|
70
64
|
// A progress stream (a reply op that streams because of `withProgress`) can
|
|
71
65
|
// emit hundreds of updates, so batch them on a time window before writing to
|
|
72
66
|
// keep IPC and UI churn down. Native data streams like completion tokens pass
|
|
73
67
|
// through immediately and are never throttled.
|
|
74
68
|
const throttle = throttleProgress
|
|
75
69
|
? createProgressThrottle((updates) => {
|
|
76
|
-
|
|
70
|
+
responseStream.write(updates.map((u) => profiler.serialize(u, false)).join('\n') + '\n', 'utf-8');
|
|
77
71
|
})
|
|
78
72
|
: undefined;
|
|
79
73
|
try {
|
|
74
|
+
const signal = signalOnCancelOrStreamClose(req, responseStream);
|
|
80
75
|
for await (const response of stream(request, { signal })) {
|
|
81
76
|
if (isTerminalChunk(response)) {
|
|
82
77
|
throttle?.flush();
|
|
83
78
|
profiler.endHandler();
|
|
84
|
-
|
|
79
|
+
responseStream.write(profiler.serialize(response, true) + '\n', 'utf-8');
|
|
85
80
|
sentFinalChunk = true;
|
|
86
81
|
}
|
|
87
82
|
else if (throttle) {
|
|
88
83
|
throttle.push(response);
|
|
89
84
|
}
|
|
90
85
|
else {
|
|
91
|
-
|
|
86
|
+
responseStream.write(profiler.serialize(response, false) + '\n', 'utf-8');
|
|
92
87
|
}
|
|
93
88
|
}
|
|
94
89
|
if (!sentFinalChunk) {
|
|
@@ -96,20 +91,20 @@ async function streamToWire(req, request, profiler, throttleProgress) {
|
|
|
96
91
|
profiler.endHandler();
|
|
97
92
|
const trailer = profiler.serialize();
|
|
98
93
|
if (trailer) {
|
|
99
|
-
|
|
94
|
+
responseStream.write(trailer + '\n', 'utf-8');
|
|
100
95
|
}
|
|
101
96
|
}
|
|
102
|
-
|
|
97
|
+
responseStream.end();
|
|
103
98
|
}
|
|
104
99
|
catch (error) {
|
|
105
100
|
throttle?.flush();
|
|
106
101
|
profiler.endHandler();
|
|
107
|
-
sendStreamErrorResponse(
|
|
102
|
+
sendStreamErrorResponse(responseStream, error, profiler);
|
|
108
103
|
}
|
|
109
104
|
}
|
|
110
105
|
async function handleDuplexRequest(req) {
|
|
111
106
|
const rpcInput = req.createRequestStream();
|
|
112
|
-
const rpcOutput = req
|
|
107
|
+
const rpcOutput = createResponseStreamLoggingErrors(req);
|
|
113
108
|
let profiler;
|
|
114
109
|
try {
|
|
115
110
|
const firstChunk = await new Promise((resolve, reject) => {
|
|
@@ -133,9 +128,9 @@ async function handleDuplexRequest(req) {
|
|
|
133
128
|
profiler.markRequestParsed(jsonParseMs);
|
|
134
129
|
const request = cleanData;
|
|
135
130
|
attachProfilingMetaToRequest(request, profilingMeta);
|
|
136
|
-
const session = await duplex(request);
|
|
131
|
+
const session = await duplex(request, { signal: signalOnCancelOrStreamClose(req, rpcOutput) });
|
|
137
132
|
// Feed the remaining RPC input into the engine's input stream, and forward
|
|
138
|
-
// the engine's newline-framed responses back out to the
|
|
133
|
+
// the engine's newline-framed responses back out to the response stream.
|
|
139
134
|
rpcInput.on('data', (chunk) => session.requestStream.write(chunk));
|
|
140
135
|
rpcInput.on('end', () => session.requestStream.end());
|
|
141
136
|
rpcInput.on('error', () => session.requestStream.destroy());
|
|
@@ -159,6 +154,14 @@ async function handleDuplexRequest(req) {
|
|
|
159
154
|
sendStreamErrorResponse(rpcOutput, error, profiler);
|
|
160
155
|
}
|
|
161
156
|
}
|
|
157
|
+
/**
|
|
158
|
+
* `req.signal` aborts when the client cancels the request, as a call that
|
|
159
|
+
* times out does, and when the client goes away. The engine cancels the
|
|
160
|
+
* request's work when it aborts.
|
|
161
|
+
*/
|
|
162
|
+
function transportOptions(req) {
|
|
163
|
+
return req.signal ? { signal: req.signal } : {};
|
|
164
|
+
}
|
|
162
165
|
function attachProfilingMetaToRequest(request, profilingMeta) {
|
|
163
166
|
if (!profilingMeta)
|
|
164
167
|
return;
|
|
@@ -2,15 +2,11 @@ import { type QvacConfig, type RuntimeContext } from '@qvac/inference/surface';
|
|
|
2
2
|
import type RPC from 'bare-rpc';
|
|
3
3
|
type InitConfigMessage = {
|
|
4
4
|
type: '__init_config';
|
|
5
|
-
config
|
|
5
|
+
config?: QvacConfig;
|
|
6
6
|
runtimeContext?: RuntimeContext;
|
|
7
|
+
homeDir?: string;
|
|
7
8
|
};
|
|
8
9
|
export declare function isInitConfigMessage(data: unknown): data is InitConfigMessage;
|
|
9
10
|
export declare function handleInitConfig(req: RPC.IncomingRequest, data: InitConfigMessage): void;
|
|
10
|
-
type ShutdownMessage = {
|
|
11
|
-
type: '__shutdown__';
|
|
12
|
-
};
|
|
13
|
-
export declare function isShutdownMessage(data: unknown): data is ShutdownMessage;
|
|
14
|
-
export declare function handleShutdown(req: RPC.IncomingRequest): Promise<void>;
|
|
15
11
|
export {};
|
|
16
12
|
//# sourceMappingURL=handler-utils.d.ts.map
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import {} from '@qvac/inference/surface';
|
|
2
|
-
import { setConfig, setRuntimeContext } from '@qvac/inference/engine';
|
|
2
|
+
import { initialize, setConfig, setRuntimeContext } from '@qvac/inference/engine';
|
|
3
3
|
export function isInitConfigMessage(data) {
|
|
4
4
|
return (typeof data === 'object' && data !== null && 'type' in data && data.type === '__init_config');
|
|
5
5
|
}
|
|
6
6
|
export function handleInitConfig(req, data) {
|
|
7
7
|
try {
|
|
8
|
+
initialize({ homeDir: data.homeDir });
|
|
8
9
|
if (data.config) {
|
|
9
10
|
setConfig(data.config);
|
|
10
11
|
}
|
|
@@ -20,22 +21,3 @@ export function handleInitConfig(req, data) {
|
|
|
20
21
|
}), 'utf-8');
|
|
21
22
|
}
|
|
22
23
|
}
|
|
23
|
-
export function isShutdownMessage(data) {
|
|
24
|
-
return (typeof data === 'object' &&
|
|
25
|
-
data !== null &&
|
|
26
|
-
'type' in data &&
|
|
27
|
-
data.type === '__shutdown__');
|
|
28
|
-
}
|
|
29
|
-
export async function handleShutdown(req) {
|
|
30
|
-
try {
|
|
31
|
-
const { cleanupForTerminate } = await import('../worker/lifecycle.js');
|
|
32
|
-
await cleanupForTerminate();
|
|
33
|
-
req.reply(JSON.stringify({ success: true }), 'utf-8');
|
|
34
|
-
}
|
|
35
|
-
catch (error) {
|
|
36
|
-
req.reply(JSON.stringify({
|
|
37
|
-
success: false,
|
|
38
|
-
error: error instanceof Error ? error.message : String(error)
|
|
39
|
-
}), 'utf-8');
|
|
40
|
-
}
|
|
41
|
-
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*/
|
|
4
|
-
export {};
|
|
1
|
+
import type { Duplex } from 'bare-stream';
|
|
2
|
+
export default function start(ipc: Duplex, ready: () => void): import("../worker/start.js").StopWorker;
|
|
5
3
|
//# sourceMappingURL=index.d.ts.map
|