@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.
Files changed (284) hide show
  1. package/NOTICE +194 -97
  2. package/README.md +29 -470
  3. package/dist/examples/asr/parakeet-sortformer.js +24 -14
  4. package/dist/examples/asr/parakeet-transcribepsy-filesystem.d.ts +2 -0
  5. package/dist/examples/asr/parakeet-transcribepsy-filesystem.js +105 -0
  6. package/dist/examples/asr/parakeet-unified-coreml.js +14 -9
  7. package/dist/examples/asr/whispercpp-prompt.js +9 -5
  8. package/dist/examples/assess-model-fit.d.ts +7 -9
  9. package/dist/examples/assess-model-fit.js +22 -43
  10. package/dist/examples/calc-tokens.d.ts +2 -0
  11. package/dist/examples/calc-tokens.js +21 -0
  12. package/dist/examples/classification/classify-image.js +11 -5
  13. package/dist/examples/completion-stop-reason.d.ts +3 -3
  14. package/dist/examples/completion-stop-reason.js +4 -4
  15. package/dist/examples/diffusion-flux3-klein.d.ts +2 -0
  16. package/dist/examples/diffusion-flux3-klein.js +102 -0
  17. package/dist/examples/diffusion-img2vid-ltx.js +7 -14
  18. package/dist/examples/diffusion-moss-image.d.ts +2 -0
  19. package/dist/examples/diffusion-moss-image.js +126 -0
  20. package/dist/examples/diffusion-qwen-image-21.d.ts +2 -0
  21. package/dist/examples/diffusion-qwen-image-21.js +115 -0
  22. package/dist/examples/diffusion-txt2vid-ltx.js +7 -14
  23. package/dist/examples/embed-multimodal.d.ts +2 -0
  24. package/dist/examples/embed-multimodal.js +80 -0
  25. package/dist/examples/embed-p2p.js +2 -2
  26. package/dist/examples/finetune/llamacpp-finetune.js +9 -4
  27. package/dist/examples/image/megaloc.d.ts +2 -0
  28. package/dist/examples/image/megaloc.js +37 -0
  29. package/dist/examples/llamacpp-multimodal.js +21 -1
  30. package/dist/examples/mcp-websearch.js +1 -1
  31. package/dist/examples/plugins.js +1 -1
  32. package/dist/examples/rag/rag-hyperdb/pipeline.js +2 -2
  33. package/dist/examples/rag/rag-turbovec.js +2 -2
  34. package/dist/examples/rerank.d.ts +2 -0
  35. package/dist/examples/rerank.js +33 -0
  36. package/dist/examples/sessions.d.ts +17 -0
  37. package/dist/examples/sessions.js +63 -0
  38. package/dist/examples/tools/llamacpp-deferred-tools.js +12 -8
  39. package/dist/examples/tools/llamacpp-tools-auto-dialect.js +4 -3
  40. package/dist/examples/tools/llamacpp-tools-gemma4.js +3 -3
  41. package/dist/examples/tools/llamacpp-tools-qwen35.js +4 -3
  42. package/dist/scripts/check-resource-collectors-packaging.js +7 -6
  43. package/dist/scripts/contract/build-contract.d.ts +2 -1
  44. package/dist/scripts/contract/build-contract.js +13 -1
  45. package/dist/scripts/contract/constants-registry.d.ts +19 -0
  46. package/dist/scripts/contract/constants-registry.js +9 -2
  47. package/dist/scripts/contract/method-shapes.d.ts +5 -0
  48. package/dist/scripts/contract/method-shapes.js +5 -0
  49. package/dist/scripts/enforce-inference-versions.d.ts +1 -1
  50. package/dist/scripts/enforce-inference-versions.js +28 -18
  51. package/dist/scripts/generate-bare-kit-runtimes.js +101 -69
  52. package/dist/src/client/api/assess-model-fit.d.ts +17 -17
  53. package/dist/src/client/api/assess-model-fit.js +19 -32
  54. package/dist/src/client/api/audio-edit.d.ts +5 -3
  55. package/dist/src/client/api/audio-edit.js +7 -5
  56. package/dist/src/client/api/audio-gen-result.js +136 -47
  57. package/dist/src/client/api/audio-gen.d.ts +40 -3
  58. package/dist/src/client/api/audio-gen.js +42 -5
  59. package/dist/src/client/api/audio-understand.d.ts +2 -2
  60. package/dist/src/client/api/audio-understand.js +4 -4
  61. package/dist/src/client/api/batch-completion.js +4 -3
  62. package/dist/src/client/api/bci-transcribe.js +3 -3
  63. package/dist/src/client/api/calc-tokens.d.ts +33 -0
  64. package/dist/src/client/api/calc-tokens.js +44 -0
  65. package/dist/src/client/api/cancel.d.ts +2 -2
  66. package/dist/src/client/api/cancel.js +3 -3
  67. package/dist/src/client/api/classify.d.ts +12 -5
  68. package/dist/src/client/api/classify.js +18 -6
  69. package/dist/src/client/api/client-request-id.d.ts +0 -15
  70. package/dist/src/client/api/client-request-id.js +15 -12
  71. package/dist/src/client/api/completion-stream.d.ts +9 -1
  72. package/dist/src/client/api/completion-stream.js +14 -3
  73. package/dist/src/client/api/decide.d.ts +1 -1
  74. package/dist/src/client/api/decide.js +3 -3
  75. package/dist/src/client/api/delete-cache.d.ts +9 -2
  76. package/dist/src/client/api/delete-cache.js +14 -4
  77. package/dist/src/client/api/diffusion.d.ts +38 -5
  78. package/dist/src/client/api/diffusion.js +42 -7
  79. package/dist/src/client/api/download-asset.js +3 -3
  80. package/dist/src/client/api/embed.d.ts +82 -29
  81. package/dist/src/client/api/embed.js +66 -21
  82. package/dist/src/client/api/finetune.js +3 -3
  83. package/dist/src/client/api/get-loaded-model-info.js +1 -1
  84. package/dist/src/client/api/get-model-info.d.ts +2 -2
  85. package/dist/src/client/api/get-model-info.js +3 -3
  86. package/dist/src/client/api/get-system-resources.d.ts +2 -2
  87. package/dist/src/client/api/get-system-resources.js +3 -3
  88. package/dist/src/client/api/heartbeat.d.ts +3 -2
  89. package/dist/src/client/api/heartbeat.js +4 -3
  90. package/dist/src/client/api/index.d.ts +8 -6
  91. package/dist/src/client/api/index.js +6 -4
  92. package/dist/src/client/api/invoke-plugin.d.ts +8 -2
  93. package/dist/src/client/api/invoke-plugin.js +18 -3
  94. package/dist/src/client/api/load-model.js +9 -6
  95. package/dist/src/client/api/logging-stream.d.ts +11 -2
  96. package/dist/src/client/api/logging-stream.js +12 -3
  97. package/dist/src/client/api/ocr.d.ts +5 -3
  98. package/dist/src/client/api/ocr.js +45 -22
  99. package/dist/src/client/api/rag.d.ts +1 -1
  100. package/dist/src/client/api/rag.js +3 -3
  101. package/dist/src/client/api/registry.d.ts +19 -8
  102. package/dist/src/client/api/registry.js +43 -17
  103. package/dist/src/client/api/rerank.d.ts +22 -0
  104. package/dist/src/client/api/rerank.js +39 -0
  105. package/dist/src/client/api/resume.d.ts +2 -1
  106. package/dist/src/client/api/resume.js +3 -3
  107. package/dist/src/client/api/rpc-server.d.ts +4 -4
  108. package/dist/src/client/api/rpc-server.js +12 -12
  109. package/dist/src/client/api/state.d.ts +2 -2
  110. package/dist/src/client/api/state.js +3 -3
  111. package/dist/src/client/api/subscribe-logs.d.ts +2 -2
  112. package/dist/src/client/api/subscribe-logs.js +4 -3
  113. package/dist/src/client/api/suspend.d.ts +4 -2
  114. package/dist/src/client/api/suspend.js +5 -4
  115. package/dist/src/client/api/text-to-speech.d.ts +14 -5
  116. package/dist/src/client/api/text-to-speech.js +86 -32
  117. package/dist/src/client/api/transcribe.d.ts +7 -3
  118. package/dist/src/client/api/transcribe.js +9 -3
  119. package/dist/src/client/api/translate.js +2 -2
  120. package/dist/src/client/api/unload-model.d.ts +19 -7
  121. package/dist/src/client/api/unload-model.js +31 -13
  122. package/dist/src/client/api/upscale.d.ts +6 -3
  123. package/dist/src/client/api/upscale.js +10 -5
  124. package/dist/src/client/api/vector-index.d.ts +51 -17
  125. package/dist/src/client/api/vector-index.js +101 -49
  126. package/dist/src/client/api/video-request.d.ts +5 -5
  127. package/dist/src/client/api/video.d.ts +3 -2
  128. package/dist/src/client/api/video.js +6 -5
  129. package/dist/src/client/api/vla.d.ts +9 -5
  130. package/dist/src/client/api/vla.js +17 -8
  131. package/dist/src/client/api/world-result.js +2 -2
  132. package/dist/src/client/api/world.d.ts +6 -6
  133. package/dist/src/client/api/world.js +6 -6
  134. package/dist/src/client/init-hooks.d.ts +6 -4
  135. package/dist/src/client/init-hooks.js +12 -15
  136. package/dist/src/client/logging-stream-registry.d.ts +6 -3
  137. package/dist/src/client/logging-stream-registry.js +36 -14
  138. package/dist/src/client/plugins-factory.d.ts +1 -1
  139. package/dist/src/client/plugins-factory.js +1 -1
  140. package/dist/src/client/rpc/bundle-stamp.d.ts +29 -0
  141. package/dist/src/client/rpc/bundle-stamp.js +75 -0
  142. package/dist/src/client/rpc/expo-home-dir.d.ts +2 -0
  143. package/dist/src/client/rpc/expo-home-dir.js +4 -0
  144. package/dist/src/client/rpc/expo-rpc-client.js +192 -138
  145. package/dist/src/client/rpc/node-rpc-client.js +324 -426
  146. package/dist/src/client/rpc/pear-runtime.d.ts +12 -0
  147. package/dist/src/client/rpc/pear-runtime.js +12 -0
  148. package/dist/src/client/rpc/rpc-client.d.ts +6 -4
  149. package/dist/src/client/rpc/rpc-client.js +168 -31
  150. package/dist/src/client/rpc/rpc-error.js +24 -2
  151. package/dist/src/client/rpc/unbundled-harness.d.ts +16 -0
  152. package/dist/src/client/rpc/unbundled-harness.js +27 -0
  153. package/dist/src/client/rpc/worker-failure.d.ts +27 -0
  154. package/dist/src/client/rpc/worker-failure.js +61 -0
  155. package/dist/src/client/session-registry.d.ts +75 -0
  156. package/dist/src/client/session-registry.js +149 -0
  157. package/dist/src/client/session.d.ts +125 -0
  158. package/dist/src/client/session.js +148 -0
  159. package/dist/src/commands/bundle/addons.d.ts +14 -0
  160. package/dist/src/commands/bundle/addons.js +65 -0
  161. package/dist/src/commands/bundle/constants.js +2 -0
  162. package/dist/src/commands/bundle/entry-gen.d.ts +1 -5
  163. package/dist/src/commands/bundle/entry-gen.js +18 -51
  164. package/dist/src/commands/bundle/index.d.ts +60 -14
  165. package/dist/src/commands/bundle/index.js +350 -126
  166. package/dist/src/commands/bundle/link.d.ts +58 -0
  167. package/dist/src/commands/bundle/link.js +135 -0
  168. package/dist/src/commands/bundle/node-support.d.ts +13 -0
  169. package/dist/src/commands/bundle/node-support.js +23 -0
  170. package/dist/src/commands/bundle/plugins.js +1 -1
  171. package/dist/src/commands/bundle/read-bundle.d.ts +9 -0
  172. package/dist/src/commands/bundle/read-bundle.js +27 -0
  173. package/dist/src/commands/bundle/resolve-sdk-import.d.ts +6 -0
  174. package/dist/src/commands/bundle/resolve-sdk-import.js +24 -28
  175. package/dist/src/commands/bundle/scratch.d.ts +35 -0
  176. package/dist/src/commands/bundle/scratch.js +178 -0
  177. package/dist/src/commands/bundle/targets.d.ts +14 -0
  178. package/dist/src/commands/bundle/targets.js +37 -0
  179. package/dist/src/commands/host-prebuilds/index.d.ts +8 -7
  180. package/dist/src/commands/host-prebuilds/index.js +13 -11
  181. package/dist/src/commands/index.d.ts +13 -12
  182. package/dist/src/commands/index.js +7 -7
  183. package/dist/src/commands/verify/abi.d.ts +21 -15
  184. package/dist/src/commands/verify/abi.js +12 -80
  185. package/dist/src/commands/verify/bare-kit-runtime.d.ts +20 -22
  186. package/dist/src/commands/verify/bare-kit-runtime.js +102 -150
  187. package/dist/src/commands/verify/bare-kit-runtimes.d.ts +10 -9
  188. package/dist/src/commands/verify/bare-kit-runtimes.js +21 -21
  189. package/dist/src/commands/verify/bundle-source.d.ts +1 -1
  190. package/dist/src/commands/verify/bundle-source.js +27 -23
  191. package/dist/src/commands/verify/engines-advice.d.ts +6 -12
  192. package/dist/src/commands/verify/engines-advice.js +9 -56
  193. package/dist/src/commands/verify/index.d.ts +34 -33
  194. package/dist/src/commands/verify/index.js +96 -204
  195. package/dist/src/commands/verify/node-modules-source.d.ts +1 -1
  196. package/dist/src/commands/verify/node-modules-source.js +1 -1
  197. package/dist/src/commands/verify/prebuilds.d.ts +4 -6
  198. package/dist/src/commands/verify/prebuilds.js +3 -4
  199. package/dist/src/commands/verify/resource-collectors.d.ts +0 -6
  200. package/dist/src/commands/verify/resource-collectors.js +3 -52
  201. package/dist/src/commands/verify/sidecar-runtime.d.ts +6 -0
  202. package/dist/src/commands/verify/sidecar-runtime.js +51 -0
  203. package/dist/src/expo/plugins/get-project-root.d.ts +1 -1
  204. package/dist/src/expo/plugins/withAndroidArchitecture.d.ts +1 -1
  205. package/dist/src/expo/plugins/withAndroidNdkVersion.d.ts +1 -1
  206. package/dist/src/expo/plugins/withAndroidNdkVersion.js +16 -10
  207. package/dist/src/expo/plugins/withBareKit.d.ts +59 -0
  208. package/dist/src/expo/plugins/withBareKit.js +204 -0
  209. package/dist/src/expo/plugins/withDeviceInfo.d.ts +1 -1
  210. package/dist/src/expo/plugins/withDeviceInfo.js +19 -5
  211. package/dist/src/expo/plugins/withMobileBundle.d.ts +5 -12
  212. package/dist/src/expo/plugins/withMobileBundle.js +38 -59
  213. package/dist/src/expo/plugins/withOpenCL.d.ts +1 -1
  214. package/dist/src/expo/plugins/withQvacSDK.d.ts +2 -1
  215. package/dist/src/expo/plugins/withQvacSDK.js +3 -0
  216. package/dist/src/index.d.ts +6 -5
  217. package/dist/src/index.js +10 -14
  218. package/dist/src/logging/addon.d.ts +1 -1
  219. package/dist/src/logging/base-logger.js +1 -1
  220. package/dist/src/logging/utils.js +11 -3
  221. package/dist/src/plugin-ids.d.ts +3 -1
  222. package/dist/src/plugin-ids.js +4 -0
  223. package/dist/src/schemas/public.d.ts +1 -1
  224. package/dist/src/schemas/public.js +1 -1
  225. package/dist/src/schemas/sdk-errors-client.d.ts +5 -6
  226. package/dist/src/schemas/sdk-errors-client.js +30 -36
  227. package/dist/src/schemas/sdk-errors-server.d.ts +12 -1
  228. package/dist/src/schemas/sdk-errors-server.js +65 -2
  229. package/dist/src/server/rpc/rpc-utils.d.ts +26 -0
  230. package/dist/src/server/rpc/rpc-utils.js +41 -0
  231. package/dist/src/utils/aggregate-events.d.ts +1 -1
  232. package/dist/src/utils/aggregate-events.js +2 -2
  233. package/dist/src/utils/errors-client.d.ts +37 -29
  234. package/dist/src/utils/errors-client.js +50 -41
  235. package/dist/src/utils/errors-server.d.ts +65 -1
  236. package/dist/src/utils/errors-server.js +122 -1
  237. package/dist/src/utils/mcp-adapter.d.ts +1 -1
  238. package/dist/src/utils/mcp-adapter.js +1 -1
  239. package/dist/src/utils/tool-helpers.js +1 -1
  240. package/dist/src/utils/withTimeout.js +34 -17
  241. package/dist/src/worker/handle-request.js +26 -21
  242. package/dist/src/worker/handler-utils.d.ts +2 -6
  243. package/dist/src/worker/handler-utils.js +2 -20
  244. package/dist/src/worker/index.d.ts +2 -4
  245. package/dist/src/worker/index.js +24 -34
  246. package/dist/src/worker/plugins/ggml-image-embedding.d.ts +2 -0
  247. package/dist/src/worker/plugins/ggml-image-embedding.js +1 -0
  248. package/dist/src/worker/plugins/llamacpp-rerank.d.ts +2 -0
  249. package/dist/src/worker/plugins/llamacpp-rerank.js +1 -0
  250. package/dist/src/worker/shim.d.ts +4 -0
  251. package/dist/src/worker/shim.js +7 -0
  252. package/dist/src/worker/start.d.ts +9 -0
  253. package/dist/src/worker/start.js +16 -0
  254. package/dist/src/worker/unbundled-shim.d.ts +2 -0
  255. package/dist/src/worker/unbundled-shim.js +4 -0
  256. package/docs/system-resources-support-matrix.md +27 -19
  257. package/package.json +91 -74
  258. package/src/electron-forge/index.cjs +65 -91
  259. package/dist/examples/model-fit-ui/server.d.ts +0 -24
  260. package/dist/examples/model-fit-ui/server.js +0 -221
  261. package/dist/src/client/rpc/ensure-worker-ready.d.ts +0 -9
  262. package/dist/src/client/rpc/ensure-worker-ready.js +0 -17
  263. package/dist/src/client/rpc/init-timeout.d.ts +0 -26
  264. package/dist/src/client/rpc/init-timeout.js +0 -25
  265. package/dist/src/client/rpc/worker-startup-error.d.ts +0 -12
  266. package/dist/src/client/rpc/worker-startup-error.js +0 -13
  267. package/dist/src/commands/bundle/bare-pack.d.ts +0 -21
  268. package/dist/src/commands/bundle/bare-pack.js +0 -77
  269. package/dist/src/commands/bundle/manifest.d.ts +0 -25
  270. package/dist/src/commands/bundle/manifest.js +0 -192
  271. package/dist/src/expo/plugins/link-addons.d.ts +0 -18
  272. package/dist/src/expo/plugins/link-addons.js +0 -65
  273. package/dist/src/pear/pre.d.ts +0 -21
  274. package/dist/src/pear/pre.js +0 -448
  275. package/dist/src/server/env.d.ts +0 -22
  276. package/dist/src/server/env.js +0 -59
  277. package/dist/src/server/utils/qvac-paths.d.ts +0 -2
  278. package/dist/src/server/utils/qvac-paths.js +0 -5
  279. package/dist/src/server/utils/worker-lock.d.ts +0 -3
  280. package/dist/src/server/utils/worker-lock.js +0 -67
  281. package/dist/src/worker/create-server.d.ts +0 -8
  282. package/dist/src/worker/create-server.js +0 -51
  283. package/dist/src/worker/lifecycle.d.ts +0 -23
  284. package/dist/src/worker/lifecycle.js +0 -149
@@ -1,9 +1,10 @@
1
1
  /**
2
2
  * @qvac/sdk/electron-forge
3
3
  *
4
- * Electron Forge plugin: bundles the QVAC worker, verifies its native addons,
5
- * then configures Electron Packager to tree-shake unused @qvac/* addons
6
- * (per-platform packages of split addons included) and non-target prebuilds.
4
+ * Electron Forge plugin: bundles the QVAC worker into `qvac/worker/` with
5
+ * bare-stow's `bare-sidecar` target, verifies its native addons, then
6
+ * configures Electron Packager to leave out the @qvac/* addon packages (the
7
+ * bundled worker carries their binaries) and other hosts' prebuilds.
7
8
  *
8
9
  * macOS universal (`arch: "universal"`) is not supported — native addon
9
10
  * prebuilds are arch-specific. Build darwin-arm64 and darwin-x64 separately.
@@ -194,41 +195,14 @@ function discoverQvacAddonPackages(projectDir) {
194
195
  }
195
196
 
196
197
  /**
197
- * Pure diff: addons that are installed but not in the required set.
198
- * Exposed for unit testing.
198
+ * Every installed @qvac addon, split addons' platform packages included. The
199
+ * bundled worker carries the binaries it loads in `qvac/worker/`, and nothing
200
+ * else in the app loads them.
199
201
  */
200
- function diffAddons(installed, required) {
201
- const requiredSet = new Set(required)
202
- const exclusions = []
203
- for (const pkg of installed) {
204
- if (!requiredSet.has(pkg)) exclusions.push(pkg)
205
- }
206
- return exclusions
207
- }
208
-
209
- /**
210
- * Computes the list of installed @qvac addons that aren't in `required`.
211
- * Logs include/exclude decisions for each discovered package.
212
- */
213
- function computeExclusions(required, projectDir) {
202
+ function computeExclusions(projectDir) {
214
203
  const { addons } = discoverQvacAddonPackages(projectDir)
215
-
216
- if (addons.length === 0) {
217
- logger.warn('No @qvac addon packages discovered. Skipping addon exclusions.')
218
- return []
219
- }
220
-
221
- const requiredSet = new Set(required)
222
- const exclusions = []
223
- for (const pkg of addons) {
224
- if (requiredSet.has(pkg)) {
225
- logger.info(`Including required addon: ${pkg}`)
226
- } else {
227
- logger.info(`Excluding unused addon: ${pkg}`)
228
- exclusions.push(pkg)
229
- }
230
- }
231
- return exclusions
204
+ for (const name of addons) logger.info(`Excluding ${name}`)
205
+ return addons
232
206
  }
233
207
 
234
208
  // ============================================
@@ -241,6 +215,10 @@ const MOBILE_PREBUILD_PATTERNS = [/[\\/]prebuilds[\\/]android-/, /[\\/]prebuilds
241
215
  /** Forge's default output dir — always exclude to avoid recursive packaging. */
242
216
  const OUT_DIR_PATTERN = /^\/out\//
243
217
 
218
+ /** bundleSdk's scratch folders in `qvac/` (`.worker-<uuid>/`), which a killed run leaves behind. */
219
+ const QVAC_SCRATCH_PATTERN =
220
+ /^[\\/]qvac[\\/]\.[^\\/]+-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}([\\/]|$)/
221
+
244
222
  function toArray(value) {
245
223
  if (value === undefined) return []
246
224
  return Array.isArray(value) ? value : [value]
@@ -250,11 +228,18 @@ function escapeRegExp(str) {
250
228
  return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
251
229
  }
252
230
 
231
+ /** The bundled worker's own addon binaries live under `qvac/worker/index.bundle.d/`. */
232
+ const WORKER_DIR_PREFIX = '(?![\\\\/]qvac[\\\\/]worker[\\\\/])'
233
+
253
234
  function createAddonIgnorePatterns(exclusions) {
254
235
  const patterns = []
255
236
  for (const addon of exclusions) {
256
237
  const parts = addon.split('/').map(escapeRegExp)
257
- patterns.push(new RegExp(`[\\\\/]node_modules[\\\\/]${parts.join('[\\\\/]')}([\\\\/]|$)`))
238
+ patterns.push(
239
+ new RegExp(
240
+ `^${WORKER_DIR_PREFIX}.*[\\\\/]node_modules[\\\\/]${parts.join('[\\\\/]')}([\\\\/]|$)`
241
+ )
242
+ )
258
243
  }
259
244
  return patterns
260
245
  }
@@ -271,6 +256,7 @@ function createIgnore(exclusions, existingIgnore) {
271
256
  return (filePath) => {
272
257
  if (existingIgnore(filePath)) return true
273
258
  if (OUT_DIR_PATTERN.test(filePath)) return true
259
+ if (QVAC_SCRATCH_PATTERN.test(filePath)) return true
274
260
  for (const pattern of addonIgnorePatterns) {
275
261
  if (pattern.test(filePath)) return true
276
262
  }
@@ -284,6 +270,7 @@ function createIgnore(exclusions, existingIgnore) {
284
270
  return [
285
271
  ...toArray(existingIgnore),
286
272
  OUT_DIR_PATTERN,
273
+ QVAC_SCRATCH_PATTERN,
287
274
  ...MOBILE_PREBUILD_PATTERNS,
288
275
  ...addonIgnorePatterns
289
276
  ]
@@ -360,6 +347,10 @@ function getDirSize(dirPath) {
360
347
  return size
361
348
  }
362
349
 
350
+ function bareHostPlatform(platform) {
351
+ return platform === 'mas' ? 'darwin' : platform
352
+ }
353
+
363
354
  /** Prunes prebuilds for a given path, keeping only target platform-arch. */
364
355
  function prunePrebuildsForPath(buildPath, platform, arch) {
365
356
  const nodeModulesPath = path.join(buildPath, 'node_modules')
@@ -369,7 +360,7 @@ function prunePrebuildsForPath(buildPath, platform, arch) {
369
360
  return { deleted: 0, bytes: 0 }
370
361
  }
371
362
 
372
- const keepPrefix = `${platform}-${arch}`
363
+ const keepPrefix = `${bareHostPlatform(platform)}-${arch}`
373
364
  logger.debug(`Keeping prefix: ${keepPrefix}`)
374
365
 
375
366
  const prebuildsDirs = findPrebuildsDirs(nodeModulesPath)
@@ -413,8 +404,8 @@ function prunePrebuildsForPath(buildPath, platform, arch) {
413
404
  * Removes excluded addon directories from the packaged node_modules.
414
405
  *
415
406
  * Electron Packager's `ignore` filter excludes file contents but leaves the
416
- * empty parent directory in the output. This sweep removes those shells so
417
- * the packaged tree matches the manifest exactly. Idempotent.
407
+ * empty parent directory in the output. This sweep removes those shells.
408
+ * Idempotent.
418
409
  */
419
410
  function removeExcludedAddonDirs(buildPath, exclusions) {
420
411
  const nodeModulesPath = path.join(buildPath, 'node_modules')
@@ -455,8 +446,6 @@ function removeExcludedAddonDirs(buildPath, exclusions) {
455
446
  *
456
447
  * @returns {Promise<{
457
448
  * bundleSdk: Function,
458
- * verifyBundle: Function,
459
- * hasErrors: Function,
460
449
  * formatVerifyBundleResult: Function,
461
450
  * }>}
462
451
  */
@@ -478,11 +467,8 @@ function defaultHosts() {
478
467
  }
479
468
 
480
469
  /**
481
- * Single source of truth for the hosts list used by both bundleSdk and
482
- * verifyBundle. Keeping these in sync matters: bundleSdk's `hosts` drives
483
- * the bare-pack content (which prebuilds end up in the bundle), and
484
- * verifyBundle checks the same set. Passing different lists silently
485
- * produces inconsistent builds — bundle for one set, verify for another.
470
+ * The hosts bundleSdk bundles and verifies for: which addon binaries the
471
+ * bundled worker carries.
486
472
  *
487
473
  * @param {string[]|null|undefined} explicitHosts
488
474
  * @returns {string[]}
@@ -531,7 +517,7 @@ function detectTargetHosts(forgeConfig, argv = process.argv.slice(2)) {
531
517
 
532
518
  if (!platform && !archSpec) return null
533
519
 
534
- const p = platform || process.platform
520
+ const p = bareHostPlatform(platform || process.platform)
535
521
  const archs = (archSpec || process.arch)
536
522
  .split(',')
537
523
  .map((s) => s.trim())
@@ -541,26 +527,27 @@ function detectTargetHosts(forgeConfig, argv = process.argv.slice(2)) {
541
527
  }
542
528
 
543
529
  /**
544
- * Runs `bundleSdk` then `verifyBundle` with the same resolved `hosts` list.
545
- * Throws QvacForgePluginError on bundle failure or verify errors.
530
+ * Runs `bundleSdk` for the resolved `hosts`, which verifies the bundle before
531
+ * it replaces `qvac/worker/`. Throws QvacForgePluginError on a bundle or
532
+ * verification failure, leaving the previous `qvac/worker/` in place.
546
533
  *
547
534
  * Commands are injected (rather than dynamically imported here) so tests
548
535
  * can assert the host-list wiring without touching the SDK runtime.
549
536
  *
550
- * @param {{ bundleSdk: Function, verifyBundle: Function, hasErrors: Function, formatVerifyBundleResult: Function }} commands
537
+ * @param {{ bundleSdk: Function, formatVerifyBundleResult: Function }} commands
551
538
  * @param {string} projectDir
552
539
  * @param {{ configPath?: string|null, hosts?: string[]|null }} options
553
- * @returns {Promise<{ addons: string[], bundlePath: string, manifestPath: string }>}
540
+ * @returns {Promise<{ addons: string[], bundlePath: string }>}
554
541
  */
555
542
  async function runBundleAndVerify(commands, projectDir, options) {
556
- const { bundleSdk, verifyBundle, hasErrors, formatVerifyBundleResult } = commands
543
+ const { bundleSdk, formatVerifyBundleResult } = commands
557
544
 
558
545
  const hosts = resolveHosts(options.hosts)
559
546
 
560
547
  logger.info(`Running bundleSdk (hosts: ${hosts.join(', ')})...`)
561
548
  let bundleResult
562
549
  try {
563
- const bundleOpts = { projectRoot: projectDir, hosts }
550
+ const bundleOpts = { projectRoot: projectDir, target: 'bare-sidecar', hosts }
564
551
  if (options.configPath) bundleOpts.configPath = options.configPath
565
552
  bundleResult = await bundleSdk(bundleOpts)
566
553
  } catch (err) {
@@ -570,26 +557,7 @@ async function runBundleAndVerify(commands, projectDir, options) {
570
557
  const addonCount = bundleResult.addons.length
571
558
  logger.info(`bundleSdk: ${addonCount} native addon${addonCount === 1 ? '' : 's'} in bundle`)
572
559
 
573
- logger.info(`Running verifyBundle (hosts: ${hosts.join(', ')})...`)
574
- let verifyResult
575
- try {
576
- const verifyOpts = {
577
- projectRoot: projectDir,
578
- addonsSource: bundleResult.bundlePath,
579
- hosts
580
- }
581
- if (options.configPath) verifyOpts.configPath = options.configPath
582
- verifyResult = await verifyBundle(verifyOpts)
583
- } catch (err) {
584
- throw new QvacForgePluginError(`verifyBundle threw: ${err?.message || err}`)
585
- }
586
-
587
- if (hasErrors(verifyResult)) {
588
- throw new QvacForgePluginError(
589
- `verifyBundle reported errors:\n${formatVerifyBundleResult(verifyResult)}`
590
- )
591
- }
592
-
560
+ const verifyResult = bundleResult.verification
593
561
  if (verifyResult.issues.length > 0) {
594
562
  logger.warn(`verifyBundle produced warnings:\n${formatVerifyBundleResult(verifyResult)}`)
595
563
  } else {
@@ -620,8 +588,8 @@ class QvacForgePlugin extends PluginBase {
620
588
  /**
621
589
  * @param {object} [config]
622
590
  * @param {string} [config.projectDir] Project root (default: process.cwd()).
623
- * @param {string} [config.configPath] Path to a qvac config file (`.ts`, `.mjs`, `.js`, or `.json`). Forwarded to bundleSdk + verifyBundle. Default: auto-discover in `projectDir`.
624
- * @param {string[]} [config.hosts] Hosts to verify against (default: `${process.platform}-${process.arch}`).
591
+ * @param {string} [config.configPath] Path to a qvac config file (`.ts`, `.mjs`, `.js`, or `.json`). Forwarded to bundleSdk. Default: auto-discover in `projectDir`.
592
+ * @param {string[]} [config.hosts] Hosts to bundle and verify for (default: `${process.platform}-${process.arch}`).
625
593
  * @param {"off"|"error"|"warn"|"info"|"debug"} [config.logLevel]
626
594
  */
627
595
  constructor(config = {}) {
@@ -632,7 +600,7 @@ class QvacForgePlugin extends PluginBase {
632
600
 
633
601
  if (config.logLevel) setLogLevel(config.logLevel)
634
602
 
635
- // Cache for resolveForgeConfig double-fire (package + make).
603
+ // Cache for Forge 7's resolveForgeConfig double-fire (package + make).
636
604
  this._cache = null
637
605
  this._pruneHook = null
638
606
 
@@ -656,8 +624,9 @@ class QvacForgePlugin extends PluginBase {
656
624
  // 1. Block macOS universal builds early.
657
625
  this.checkForUniversalArch(forgeConfig)
658
626
 
659
- // 2. Force asar: false (Bare worker can't load from asar). Truthy check
660
- // catches both `asar: true` and `asar: { unpack: ... }` object configs.
627
+ // 2. Force asar: false (bare-sidecar runs `bare` and the worker bundle from
628
+ // real files). Truthy check catches both `asar: true` and
629
+ // `asar: { unpack: ... }` object configs.
661
630
  if (forgeConfig.packagerConfig.asar) {
662
631
  logger.warn('asar is enabled — Bare worker may fail to load. Overriding to false.')
663
632
  }
@@ -665,10 +634,7 @@ class QvacForgePlugin extends PluginBase {
665
634
 
666
635
  // 3. Bundle + verify (cached across resolveForgeConfig invocations).
667
636
  // `hosts` resolution: explicit config wins, then CLI/config-derived
668
- // target, then host fallback inside runBundleAndVerify. Hosts are
669
- // threaded into BOTH bundleSdk (drives bare-pack content) and
670
- // verifyBundle (asserts prebuild availability) — passing different
671
- // sets silently produces inconsistent builds.
637
+ // target, then host fallback inside runBundleAndVerify.
672
638
  if (this._cache === null) {
673
639
  const detected = this.hosts ? null : detectTargetHosts(forgeConfig)
674
640
  if (detected && !this.hosts) {
@@ -679,19 +645,19 @@ class QvacForgePlugin extends PluginBase {
679
645
  configPath: this.configPath,
680
646
  hosts: this.hosts || detected
681
647
  })
682
- const exclusions = computeExclusions(bundleResult.addons, this.projectDir)
648
+ const exclusions = computeExclusions(this.projectDir)
683
649
  this._cache = { bundleResult, exclusions }
684
650
  } else {
685
651
  logger.debug('Reusing cached bundleSdk result.')
686
652
  }
687
653
  const { exclusions } = this._cache
688
654
 
689
- // 4. Merge ignore patterns to exclude unused addons + mobile prebuilds.
655
+ // 4. Merge ignore patterns to exclude the @qvac addons + mobile prebuilds.
690
656
  const existingIgnore = forgeConfig.packagerConfig.ignore
691
657
  forgeConfig.packagerConfig.ignore = createIgnore(exclusions, existingIgnore)
692
658
 
693
659
  // 5. afterPrune hook for prebuild pruning + excluded addon dir cleanup.
694
- // Forge calls resolveForgeConfig multiple times during `make` (once for
660
+ // Forge 7 calls resolveForgeConfig multiple times during `make` (once for
695
661
  // `Loading configuration`, then again for `Preparing to package`). We
696
662
  // must not append the hook on each pass, otherwise Packager's afterPrune
697
663
  // fires it N times and we walk the already-pruned tree on every repeat.
@@ -748,8 +714,14 @@ class QvacForgePlugin extends PluginBase {
748
714
  }
749
715
  }
750
716
 
717
+ /**
718
+ * Electron Packager 19+ (Forge 8) calls each hook with one
719
+ * `{ buildPath, electronVersion, platform, arch }` object and awaits it.
720
+ * Packager 18 (Forge 7) passes positional args and a `done` callback.
721
+ * The returned hook accepts both.
722
+ */
751
723
  createPruneHook(exclusions = []) {
752
- return (buildPath, electronVersion, platform, arch, done) => {
724
+ const prune = async ({ buildPath, platform, arch }) => {
753
725
  logger.info(`Pruning prebuilds for ${platform}-${arch}...`)
754
726
 
755
727
  try {
@@ -764,13 +736,16 @@ class QvacForgePlugin extends PluginBase {
764
736
  `Removed ${cleanup.removed} excluded addon dir${cleanup.removed === 1 ? '' : 's'} (~${cleanupMb} MB reclaimed)`
765
737
  )
766
738
  }
767
-
768
- done()
769
739
  } catch (err) {
770
740
  logger.error(`Prebuild pruning failed: ${err.message}`)
771
- done(err)
741
+ throw err
772
742
  }
773
743
  }
744
+
745
+ return (hookArgs, electronVersion, platform, arch, done) => {
746
+ if (typeof hookArgs === 'object' && hookArgs !== null) return prune(hookArgs)
747
+ prune({ buildPath: hookArgs, platform, arch }).then(() => done(), done)
748
+ }
774
749
  }
775
750
  }
776
751
 
@@ -784,7 +759,6 @@ module.exports.QvacForgePluginError = QvacForgePluginError
784
759
 
785
760
  // Internal helpers exposed for unit tests. Not part of the stable API.
786
761
  module.exports.createIgnore = createIgnore
787
- module.exports.diffAddons = diffAddons
788
762
  module.exports.detectTargetHosts = detectTargetHosts
789
763
  module.exports.resolveHosts = resolveHosts
790
764
  module.exports.runBundleAndVerify = runBundleAndVerify
@@ -1,24 +0,0 @@
1
- /**
2
- * Demo: assessModelFit's verdict next to what actually happens.
3
- *
4
- * Serves a page listing catalog models with two buttons. "Estimate" calls
5
- * `assessModelFit` — no weights, no load. "Run" loads the model for real and
6
- * runs one completion, so the verdict can be checked against the outcome.
7
- *
8
- * Expect `likely-too-large` to mean "will not go well" rather than "will not
9
- * load": an OS with swap usually runs it anyway. Measured here, a 1.7B called
10
- * too-large took 519s against 7.8s for a 600M called fits — same 32 tokens.
11
- * The verdict is about the interactive budget, not about whether the load
12
- * throws.
13
- *
14
- * Memory is read through `getSystemResources`, not `process.memoryUsage()`:
15
- * inference runs in a spawned worker, so this process's own RSS never sees the
16
- * model. The numbers are therefore system-wide and include whatever else the
17
- * machine is doing — fine for a demo, not a measurement.
18
- *
19
- * Run (Node or Bun, not Bare — this uses node:http):
20
- * npx tsx examples/model-fit-ui/server.ts
21
- * node dist/examples/model-fit-ui/server.js
22
- */
23
- export {};
24
- //# sourceMappingURL=server.d.ts.map
@@ -1,221 +0,0 @@
1
- /**
2
- * Demo: assessModelFit's verdict next to what actually happens.
3
- *
4
- * Serves a page listing catalog models with two buttons. "Estimate" calls
5
- * `assessModelFit` — no weights, no load. "Run" loads the model for real and
6
- * runs one completion, so the verdict can be checked against the outcome.
7
- *
8
- * Expect `likely-too-large` to mean "will not go well" rather than "will not
9
- * load": an OS with swap usually runs it anyway. Measured here, a 1.7B called
10
- * too-large took 519s against 7.8s for a 600M called fits — same 32 tokens.
11
- * The verdict is about the interactive budget, not about whether the load
12
- * throws.
13
- *
14
- * Memory is read through `getSystemResources`, not `process.memoryUsage()`:
15
- * inference runs in a spawned worker, so this process's own RSS never sees the
16
- * model. The numbers are therefore system-wide and include whatever else the
17
- * machine is doing — fine for a demo, not a measurement.
18
- *
19
- * Run (Node or Bun, not Bare — this uses node:http):
20
- * npx tsx examples/model-fit-ui/server.ts
21
- * node dist/examples/model-fit-ui/server.js
22
- */
23
- import { createServer } from 'node:http';
24
- import { readFileSync, readdirSync, statSync } from 'node:fs';
25
- import { homedir } from 'node:os';
26
- import { join } from 'node:path';
27
- import { assessModelFit, getSystemResources, loadModel, unloadModel, completion, close, QWEN3_600M_INST_Q4, QWEN3_1_7B_INST_Q4, QWEN3_4B_INST_Q4_K_M, QWEN3_8B_INST_Q4_K_M, GEMMA4_31B_MULTIMODAL_Q4_K_M } from '@qvac/sdk';
28
- const PORT = 8712;
29
- // A ladder ending past what a laptop has, so one screen shows every verdict.
30
- // The 31B is here to be refused: 18 GiB against a 24 GiB machine leaves the OS
31
- // no way to satisfy it without paging.
32
- const CATALOG = [
33
- QWEN3_600M_INST_Q4,
34
- QWEN3_1_7B_INST_Q4,
35
- QWEN3_4B_INST_Q4_K_M,
36
- QWEN3_8B_INST_Q4_K_M,
37
- GEMMA4_31B_MULTIMODAL_Q4_K_M
38
- ];
39
- const PAGE_PATH = new URL('index.html', import.meta.url);
40
- // Read per request, not once at startup: editing the page and reloading is the
41
- // normal way to poke at this, and a cached copy makes that silently not work.
42
- function page() {
43
- return readFileSync(PAGE_PATH);
44
- }
45
- // Download progress for a run in flight. `loadModel` only streams it when
46
- // `onProgress` is passed, and without it a 29 GiB download, a stall and a dead
47
- // worker all look identical from the browser: "loading…" forever.
48
- const progress = new Map();
49
- // Whether the weights are already on disk, so a Run costs no download. The
50
- // cache layout is not API, so this matches on file size — enough to label a
51
- // button, and it errs towards promising a download that may not happen.
52
- function cachedSizes() {
53
- try {
54
- const dir = join(homedir(), '.qvac', 'models');
55
- return new Set(readdirSync(dir).map((file) => statSync(join(dir, file)).size));
56
- }
57
- catch {
58
- return new Set();
59
- }
60
- }
61
- function byName(name) {
62
- const model = CATALOG.find((entry) => entry.name === name);
63
- if (!model)
64
- throw new Error(`unknown model: ${name}`);
65
- return model;
66
- }
67
- async function systemUsedBytes() {
68
- const resources = await getSystemResources({ sample: true });
69
- const used = resources.sample?.memory.usedBytes;
70
- return used?.status === 'supported' ? used.value : undefined;
71
- }
72
- function readBody(request) {
73
- return new Promise((resolve, reject) => {
74
- const chunks = [];
75
- request.on('data', (chunk) => chunks.push(chunk));
76
- request.on('error', reject);
77
- request.on('end', () => {
78
- try {
79
- resolve(chunks.length > 0 ? JSON.parse(Buffer.concat(chunks).toString()) : {});
80
- }
81
- catch (error) {
82
- reject(error);
83
- }
84
- });
85
- });
86
- }
87
- // The demo reports which error happened, never its message: a message can carry
88
- // a path or a host detail, and this server answers a browser. The full error
89
- // goes to the console, where the person running the demo can read it.
90
- function errorLabel(error) {
91
- console.error(error);
92
- if (!(error instanceof Error))
93
- return 'unknown error';
94
- const code = error.code;
95
- return typeof code === 'number' ? `${error.name} (${code})` : error.name;
96
- }
97
- function sendJson(response, status, payload) {
98
- const body = JSON.stringify(payload);
99
- response.writeHead(status, { 'content-type': 'application/json' });
100
- response.end(body);
101
- }
102
- async function estimate(body) {
103
- const names = Array.isArray(body['names']) ? body['names'] : [];
104
- const contextTokens = Number(body['contextTokens'] ?? 8192);
105
- return assessModelFit({
106
- models: names.map((name) => ({
107
- modelSrc: byName(name),
108
- modelType: 'llamacpp-completion',
109
- modelConfig: { ctx_size: contextTokens }
110
- })),
111
- // Declared for aggregation only. 'sequential' counts the largest operation
112
- // peak; 'concurrent' counts one per model.
113
- execution: 'sequential',
114
- policy: 'interactive-v1'
115
- });
116
- }
117
- /** Loads for real, generates a few tokens, unloads. The reality check. */
118
- async function run(body) {
119
- const model = byName(String(body['name']));
120
- const contextTokens = Number(body['contextTokens'] ?? 8192);
121
- const startedAt = Date.now();
122
- const before = await systemUsedBytes();
123
- let modelId;
124
- try {
125
- modelId = await loadModel({
126
- modelSrc: model,
127
- modelType: 'llm',
128
- modelConfig: { ctx_size: contextTokens },
129
- onProgress: (update) => {
130
- progress.set(model.name, {
131
- percentage: update.percentage,
132
- downloaded: update.downloaded,
133
- total: update.total,
134
- at: Date.now()
135
- });
136
- }
137
- });
138
- const afterLoad = await systemUsedBytes();
139
- const result = completion({
140
- modelId,
141
- history: [{ role: 'user', content: 'Reply with one short sentence about maps.' }],
142
- stream: false,
143
- generationParams: { predict: 32 }
144
- });
145
- const final = await result.final;
146
- return {
147
- ok: true,
148
- elapsedMs: Date.now() - startedAt,
149
- systemUsedBeforeBytes: before,
150
- systemUsedAfterLoadBytes: afterLoad,
151
- backendDevice: final.stats?.backendDevice,
152
- // The engine's own numbers for the run: tokens/s, time to first token,
153
- // token counts. Worth showing next to the memory figures.
154
- stats: final.stats,
155
- // `cacheableAssistantContent` is the same text with <think> blocks
156
- // stripped; a reasoning model otherwise leads with its scratchpad.
157
- sample: (final.cacheableAssistantContent ?? final.contentText).trim().slice(0, 160) ||
158
- '(no plain text — the model returned reasoning only)'
159
- };
160
- }
161
- catch (error) {
162
- // The interesting negative case: the estimate said too large, and the load
163
- // proves it. Report it as a result, not a crash.
164
- return {
165
- ok: false,
166
- elapsedMs: Date.now() - startedAt,
167
- systemUsedBeforeBytes: before,
168
- error: errorLabel(error)
169
- };
170
- }
171
- finally {
172
- progress.delete(model.name);
173
- if (modelId)
174
- await unloadModel({ modelId }).catch(() => { });
175
- }
176
- }
177
- const server = createServer((request, response) => {
178
- const url = request.url ?? '/';
179
- if (request.method === 'GET' && (url === '/' || url.startsWith('/?'))) {
180
- response.writeHead(200, { 'content-type': 'text/html; charset=utf-8' });
181
- response.end(page());
182
- return;
183
- }
184
- // Polled while a run is in flight; `at` lets the page say "no progress for
185
- // 30s" instead of implying the download is still moving.
186
- if (request.method === 'GET' && url === '/api/progress') {
187
- sendJson(response, 200, Object.fromEntries(progress));
188
- return;
189
- }
190
- if (request.method === 'GET' && url === '/api/models') {
191
- const sizes = cachedSizes();
192
- sendJson(response, 200, CATALOG.map((model) => ({
193
- name: model.name,
194
- expectedSize: model.expectedSize,
195
- cached: sizes.has(model.expectedSize)
196
- })));
197
- return;
198
- }
199
- if (request.method === 'POST' && (url === '/api/assess' || url === '/api/run')) {
200
- readBody(request)
201
- .then(async (body) => (url === '/api/assess' ? await estimate(body) : await run(body)))
202
- .then((payload) => sendJson(response, 200, payload))
203
- .catch((error) => {
204
- sendJson(response, 500, { error: errorLabel(error) });
205
- });
206
- return;
207
- }
208
- sendJson(response, 404, { error: 'not found' });
209
- });
210
- server.listen(PORT, () => {
211
- console.log(`▸ assessModelFit demo on http://localhost:${PORT}`);
212
- console.log('▸ "Run" downloads weights on first use — the 8B is ~4.7 GiB.');
213
- });
214
- for (const signal of ['SIGINT', 'SIGTERM']) {
215
- process.on(signal, () => {
216
- server.close();
217
- close()
218
- .catch(() => { })
219
- .finally(() => process.exit(0));
220
- });
221
- }
@@ -1,9 +0,0 @@
1
- /**
2
- * Throw if no plugins are registered before an SDK call. On Pear,
3
- * point at the generated worker entry; otherwise raise a generic
4
- * registration error. `isPear` is overridable for tests.
5
- */
6
- export declare function ensurePluginsRegistered(opts?: {
7
- isPear?: boolean;
8
- }): Promise<void>;
9
- //# sourceMappingURL=ensure-worker-ready.d.ts.map
@@ -1,17 +0,0 @@
1
- import { getAllPlugins } from '../../server/plugins/index.js';
2
- import { PearWorkerEntryRequiredError, WorkerPluginsNotRegisteredError } from '../../utils/errors-client.js';
3
- const PEAR_WORKER_ENTRY_PATH = 'qvac/worker.pear.entry.mjs';
4
- /**
5
- * Throw if no plugins are registered before an SDK call. On Pear,
6
- * point at the generated worker entry; otherwise raise a generic
7
- * registration error. `isPear` is overridable for tests.
8
- */
9
- export async function ensurePluginsRegistered(opts) {
10
- if (getAllPlugins().length > 0)
11
- return;
12
- const isPear = opts?.isPear ?? (await import('which-runtime')).isPear;
13
- if (isPear) {
14
- throw new PearWorkerEntryRequiredError(PEAR_WORKER_ENTRY_PATH);
15
- }
16
- throw new WorkerPluginsNotRegisteredError();
17
- }
@@ -1,26 +0,0 @@
1
- /** Fallback when neither the environment nor `qvac.config.*` sets a value. */
2
- export declare const DEFAULT_RPC_INIT_TIMEOUT_MS = 30000;
3
- /**
4
- * Overrides `rpcInitTimeoutMs` from the config file. Read before the worker is
5
- * spawned, so it is the only knob available to hosts that cannot ship a config
6
- * file (packaged apps, CI images, one-off debugging runs).
7
- */
8
- export declare const RPC_INIT_TIMEOUT_ENV_VAR = "QVAC_RPC_INIT_TIMEOUT_MS";
9
- interface ResolveRPCInitTimeoutOptions {
10
- envValue?: string | undefined;
11
- /** Already checked against `z.number().int().positive()` by config validation. */
12
- configValue?: number | undefined;
13
- /** Invoked for a rejected environment value, so this module needs no logger. */
14
- onInvalidEnvValue?: (envValue: string) => void;
15
- }
16
- /**
17
- * Resolve the worker handshake timeout: environment variable, then config file,
18
- * then the built-in default.
19
- *
20
- * Only the environment is checked, being free text that reaches here
21
- * unvalidated. It is reported and skipped rather than thrown, because a
22
- * mistyped tuning value must not become a hard SDK initialization failure.
23
- */
24
- export declare function resolveRPCInitTimeoutMs({ envValue, configValue, onInvalidEnvValue }?: ResolveRPCInitTimeoutOptions): number;
25
- export {};
26
- //# sourceMappingURL=init-timeout.d.ts.map
@@ -1,25 +0,0 @@
1
- /** Fallback when neither the environment nor `qvac.config.*` sets a value. */
2
- export const DEFAULT_RPC_INIT_TIMEOUT_MS = 30_000;
3
- /**
4
- * Overrides `rpcInitTimeoutMs` from the config file. Read before the worker is
5
- * spawned, so it is the only knob available to hosts that cannot ship a config
6
- * file (packaged apps, CI images, one-off debugging runs).
7
- */
8
- export const RPC_INIT_TIMEOUT_ENV_VAR = 'QVAC_RPC_INIT_TIMEOUT_MS';
9
- /**
10
- * Resolve the worker handshake timeout: environment variable, then config file,
11
- * then the built-in default.
12
- *
13
- * Only the environment is checked, being free text that reaches here
14
- * unvalidated. It is reported and skipped rather than thrown, because a
15
- * mistyped tuning value must not become a hard SDK initialization failure.
16
- */
17
- export function resolveRPCInitTimeoutMs({ envValue, configValue, onInvalidEnvValue } = {}) {
18
- if (envValue !== undefined && envValue.trim() !== '') {
19
- const parsed = Number(envValue);
20
- if (Number.isInteger(parsed) && parsed > 0)
21
- return parsed;
22
- onInvalidEnvValue?.(envValue);
23
- }
24
- return configValue ?? DEFAULT_RPC_INIT_TIMEOUT_MS;
25
- }