QVAC-18554 fix: bundle SDK worker.js for packaged consumers#2011
Conversation
…on imports-map fix for bare-crypto / bare-fetch.
…c analysis can pull worker.js into the bundle.
simon-iribarren
left a comment
There was a problem hiding this comment.
The change itself is correct and minimal — swaps a runtime path.resolve(__dirname, …) for bundler-visible new URL(literal, import.meta.url) / import.meta.asset(literal) references so static analyzers (Vite, Webpack 5, electron-builder, bare-pack) trace dist/server/worker.js into consumer bundles. Module load semantics are preserved (same target file on disk in all three layouts: compiled-dist, source-tsx, packaged-electron). No public-API surface change — getDefaultWorkerPath stays internal, exports/files/peerDependencies unchanged, fix: (no [api]/[bc]/[mod] tag) is right.
Approving on substance, but a few things to clear before merge:
Merge gates (not blocking review, but blocking merge)
buildworkflow stillWAITINGon both pipelines — first time realbun install+ bundler runs against this PR head. Worth waiting for green before merging.- Branch is
CONFLICTINGwithmain, needs a rebase. - Labels
tier1+verifyare missing (workspace rule) —gh pr edit 2011 --add-label tier1,verify.
Nits (non-blocking)
1. @qvac/rag 0.4.4 → 0.5.0 bump piggybacked. The title says "bundle SDK worker.js" but the diff also carries a minor dep bump, which muddies bisect/revert. Worth either splitting into a separate chore(deps): bump @qvac/rag PR (preferred — easier to revert independently if 0.5.0 regresses), or retitling something like QVAC-18554 fix: bundle SDK worker.js + bump @qvac/rag.
2. packages/sdk/client/rpc/node-rpc-client.ts:91-98 — dev/source fallback is wrong when compiled output runs. new URL("../../dist/server/worker.js", import.meta.url) resolves to <sdk>/dist/dist/server/worker.js when the compiled dist/client/rpc/node-rpc-client.js runs. Pre-existing latent bug (path.resolve(__dirname, "../../dist/server/worker.js") had the same off-by-one), so not a regression — but worth either dropping the dev branch entirely or leaving a TODO/logger.debug so the next reader knows it's only reachable from source via tsx.
3. No automated packaging regression test. You ran bare-pack smoke + 9/9 rag tests locally, but nothing committed prevents the regression from coming back (e.g. if someone reverts to path.resolve(__dirname, ...) later, or refactors the literal into a const that breaks the lexer). A tiny scripts/test-packaging.ts that greps the compiled output for "../../server/worker.js" literal and fails if missing, wired into bun run build (or a test:packaging script), would lock it in. Follow-up is fine.
Verified consumer impact
Workbench-desktop's worker resolution sits upstream of getDefaultWorkerPath(): QVAC_WORKER_PATH → resolvePackagedWorkerPath (Electron app.asar.unpacked/qvac/worker.entry.mjs) → <projectRoot>/qvac/worker.entry.mjs → getDefaultWorkerPath (this PR). Workbench typically hits step 2 or 3, so this fix shouldn't directly affect it.
dc1e7c8
QVAC E2E —
|
|
review |
Tier-based Approval Status |
* QVAC-17869 revert[bc]: roll SDK parakeet plugin back to 0.3.1 ONNX engine Reverts e9c9254 ("QVAC-17869 feat[bc]: migrate SDK parakeet plugin to 0.4.0 GGML + duplex streaming (#2018)") in full, restoring the multi-file ONNX-era parakeet integration: - @qvac/transcription-parakeet pinned back to ^0.3.1. - packages/sdk/server/bare/plugins/parakeet-transcription/plugin.ts restored to the ONNX-era multi-model loader (encoder/decoder/ preprocessor/tokenizer/vocab + sortformer/EOU shards) instead of the single-GGUF mmap path. - packages/sdk/server/bare/ops/transcribe.ts, client/api/transcribe.ts and the transcription/load-model/plugin schemas reverted to the pre-duplex shape: endOfTurnEventSchema is back to the flat (non- discriminated) form and transcribeStream() returns the legacy async generator instead of a duplex TranscribeStreamSession. - LegacyParakeetModelDeprecatedError (server code 52210) and parakeetLoadConfigSchema removed; sdk-errors-server, errors-server and the parakeet-schemas / transcribe-vad-events unit tests revert to their pre-migration content. - Model registry entries for the GGML Q8_0 GGUFs (PARAKEET_{TDT,CTC,SORTFORMER,EOU}_*_Q8_0) and the 8272e45 history snapshot are removed; the FP32 / INT8 ONNX constants (PARAKEET_TDT_ENCODER_*, PARAKEET_CTC_*, PARAKEET_SORTFORMER_*, PARAKEET_EOU_*) are reinstated as the canonical model set. - Examples (parakeet-ctc-filesystem, parakeet-tdt-filesystem, parakeet-sortformer, parakeet-microphone-record, whispercpp- microphone-conversation) revert to the multi-file modelConfig shape; parakeet-microphone-stream.ts is removed. - e2e: parakeet-stream-tests.ts, shared/parakeet-stream-runner.ts, desktop+mobile parakeet-stream-executor.ts and the four stream test ids in test-definitions.ts are removed; desktop/mobile consumer.ts dispatch tables and shared/transcribe-stream-events- runner.ts revert accordingly. - Docs (ai-capabilities/transcription.mdx, reference/api/index.mdx) and the SDK .gitignore demo-artifact entries reverted. Auto-merge against main was clean (only the unrelated @qvac/rag ^0.5.0 bump from #2011 was preserved in package.json). No dangling references to GGML-only symbols (LegacyParakeetModelDeprecatedError, PARAKEET_*_Q8_0, ParakeetStreamExecutor, MobileParakeetStreamExecutor) remain in the tree. Co-authored-by: Cursor <cursoragent@cursor.com> * fix set multilingual flag to true when using supertonic 2 --------- Co-authored-by: Ishan Vohra <ishanvohra@Ishans-MacBook-Air.local> Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: GustavoA1604 <54457676+GustavoA1604@users.noreply.github.com>
Pulls in the peers-cleaned registry-client release (#1905, #2035) so hyperswarm, corestore, hyperdb, hyperblobs are not duplicated in consumer apps. Pairs with the @qvac/rag@^0.5.0 bump already on main from #2011. Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: Dmytro Medvinskyi <functionsilence@gmail.com>
* chore: Bump @qvac/rag from ^0.4.4 to ^0.5.0 to pick up its package.json imports-map fix for bare-crypto / bare-fetch. * fix: Use bundler-visible asset references in node-rpc-client so static analysis can pull worker.js into the bundle.
* QVAC-17869 revert[bc]: roll SDK parakeet plugin back to 0.3.1 ONNX engine Reverts 45d84ef ("QVAC-17869 feat[bc]: migrate SDK parakeet plugin to 0.4.0 GGML + duplex streaming (#2018)") in full, restoring the multi-file ONNX-era parakeet integration: - @qvac/transcription-parakeet pinned back to ^0.3.1. - packages/sdk/server/bare/plugins/parakeet-transcription/plugin.ts restored to the ONNX-era multi-model loader (encoder/decoder/ preprocessor/tokenizer/vocab + sortformer/EOU shards) instead of the single-GGUF mmap path. - packages/sdk/server/bare/ops/transcribe.ts, client/api/transcribe.ts and the transcription/load-model/plugin schemas reverted to the pre-duplex shape: endOfTurnEventSchema is back to the flat (non- discriminated) form and transcribeStream() returns the legacy async generator instead of a duplex TranscribeStreamSession. - LegacyParakeetModelDeprecatedError (server code 52210) and parakeetLoadConfigSchema removed; sdk-errors-server, errors-server and the parakeet-schemas / transcribe-vad-events unit tests revert to their pre-migration content. - Model registry entries for the GGML Q8_0 GGUFs (PARAKEET_{TDT,CTC,SORTFORMER,EOU}_*_Q8_0) and the 61a50fe history snapshot are removed; the FP32 / INT8 ONNX constants (PARAKEET_TDT_ENCODER_*, PARAKEET_CTC_*, PARAKEET_SORTFORMER_*, PARAKEET_EOU_*) are reinstated as the canonical model set. - Examples (parakeet-ctc-filesystem, parakeet-tdt-filesystem, parakeet-sortformer, parakeet-microphone-record, whispercpp- microphone-conversation) revert to the multi-file modelConfig shape; parakeet-microphone-stream.ts is removed. - e2e: parakeet-stream-tests.ts, shared/parakeet-stream-runner.ts, desktop+mobile parakeet-stream-executor.ts and the four stream test ids in test-definitions.ts are removed; desktop/mobile consumer.ts dispatch tables and shared/transcribe-stream-events- runner.ts revert accordingly. - Docs (ai-capabilities/transcription.mdx, reference/api/index.mdx) and the SDK .gitignore demo-artifact entries reverted. Auto-merge against main was clean (only the unrelated @qvac/rag ^0.5.0 bump from #2011 was preserved in package.json). No dangling references to GGML-only symbols (LegacyParakeetModelDeprecatedError, PARAKEET_*_Q8_0, ParakeetStreamExecutor, MobileParakeetStreamExecutor) remain in the tree. Co-authored-by: Cursor <cursoragent@cursor.com> * fix set multilingual flag to true when using supertonic 2 --------- Co-authored-by: Ishan Vohra <ishanvohra@Ishans-MacBook-Air.local> Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: GustavoA1604 <54457676+GustavoA1604@users.noreply.github.com>
Pulls in the peers-cleaned registry-client release (#1905, #2035) so hyperswarm, corestore, hyperdb, hyperblobs are not duplicated in consumer apps. Pairs with the @qvac/rag@^0.5.0 bump already on main from #2011. Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: Dmytro Medvinskyi <functionsilence@gmail.com>
🎯 What problem does this PR solve?
worker.jsbecausegetDefaultWorkerPath()resolved viapath.resolve(__dirname, ...), which bundler static analysis cannot see. SDK init fails at runtime with a missing-worker error.@qvac/ragv0.5.0 ships the newpackage.jsonimportsmap forbare-crypto/bare-fetch. SDK was still pinned to^0.4.4.📝 How does it solve it?
getDefaultWorkerPath()now uses bundler-visible asset references with string literals at the call site:import.meta.asset('../../server/worker.js')under Bare-pack (detected viabare-module-lexer)new URL('../../server/worker.js', import.meta.url)for Node / Electron / Metro / Webpack / Vitetypeof import.meta.asset === 'function') picks the right branch — single code path, no per-runtime fork at build time.@qvac/ragdependency:^0.4.4→^0.5.0.🧪 How was it tested?
bun run lint+bun run typecheck+bun run build— passbun run test:security:bare— passdist/client/rpc/node-rpc-client.js— passbare-packasset smoke against a minimal consumer —bare-module-lexerextracts theimport.meta.asset('../../server/worker.js')literal and pullsworker.jsinto the bundleqvac-test run:local:desktop --filter rag— 9/9 rag tests pass (3 smoke-tagged), worker resolution exercised end-to-end on Bare runtime