Skip to content

QVAC-18554 fix: bundle SDK worker.js for packaged consumers#2011

Merged
opaninakuffo merged 4 commits into
tetherto:mainfrom
opaninakuffo:fix/sdk-worker-path-bundling
May 13, 2026
Merged

QVAC-18554 fix: bundle SDK worker.js for packaged consumers#2011
opaninakuffo merged 4 commits into
tetherto:mainfrom
opaninakuffo:fix/sdk-worker-path-bundling

Conversation

@opaninakuffo

@opaninakuffo opaninakuffo commented May 12, 2026

Copy link
Copy Markdown
Contributor

🎯 What problem does this PR solve?

  • Packaged consumers (Expo/Metro, electron-builder, webpack/Vite) shipped without worker.js because getDefaultWorkerPath() resolved via path.resolve(__dirname, ...), which bundler static analysis cannot see. SDK init fails at runtime with a missing-worker error.
  • @qvac/rag v0.5.0 ships the new package.json imports map for bare-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 via bare-module-lexer)
    • new URL('../../server/worker.js', import.meta.url) for Node / Electron / Metro / Webpack / Vite
  • Runtime feature detection (typeof import.meta.asset === 'function') picks the right branch — single code path, no per-runtime fork at build time.
  • Bumps @qvac/rag dependency: ^0.4.4^0.5.0.

🧪 How was it tested?

  • bun run lint + bun run typecheck + bun run build — pass
  • bun run test:security:bare — pass
  • Node ESM module-load smoke on compiled dist/client/rpc/node-rpc-client.js — pass
  • bare-pack asset smoke against a minimal consumer — bare-module-lexer extracts the import.meta.asset('../../server/worker.js') literal and pulls worker.js into the bundle
  • qvac-test run:local:desktop --filter rag9/9 rag tests pass (3 smoke-tagged), worker resolution exercised end-to-end on Bare runtime

…on imports-map fix for bare-crypto / bare-fetch.
…c analysis can pull worker.js into the bundle.

@simon-iribarren simon-iribarren left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

  • build workflow still WAITING on both pipelines — first time real bun install + bundler runs against this PR head. Worth waiting for green before merging.
  • Branch is CONFLICTING with main, needs a rebase.
  • Labels tier1 + verify are 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_PATHresolvePackagedWorkerPath (Electron app.asar.unpacked/qvac/worker.entry.mjs) → <projectRoot>/qvac/worker.entry.mjsgetDefaultWorkerPath (this PR). Workbench typically hits step 2 or 3, so this fix shouldn't directly affect it.

NamelsKing
NamelsKing previously approved these changes May 13, 2026
@github-actions

github-actions Bot commented May 13, 2026

Copy link
Copy Markdown
Contributor

QVAC E2E — ios⚠️ no results

Config: suite=smoke · filter=(none) · exclude=(none)
View run

The test job did not produce a results artifact. Check the run for job-level failures.

@github-actions

github-actions Bot commented May 13, 2026

Copy link
Copy Markdown
Contributor

QVAC E2E — android⚠️ no results

Config: suite=smoke · filter=(none) · exclude=(none)
View run · Artifacts: reports

The test job did not produce a results artifact. Check the run for job-level failures.

@github-actions

github-actions Bot commented May 13, 2026

Copy link
Copy Markdown
Contributor

QVAC E2E — windows — ✅ all tests passed (91/91, 424s)

Config: suite=smoke · filter=(none) · exclude=(none)
View run · Artifacts: reports

@github-actions

github-actions Bot commented May 13, 2026

Copy link
Copy Markdown
Contributor

QVAC E2E — linux — ✅ all tests passed (91/91, 356s)

Config: suite=smoke · filter=(none) · exclude=(none)
View run · Artifacts: reports

@github-actions

github-actions Bot commented May 13, 2026

Copy link
Copy Markdown
Contributor

QVAC E2E — macos — ✅ all tests passed (91/91, 322s)

Config: suite=smoke · filter=(none) · exclude=(none)
View run · Artifacts: reports

@opaninakuffo

Copy link
Copy Markdown
Contributor Author

review

@github-actions

Copy link
Copy Markdown
Contributor

Tier-based Approval Status

**PR Tier:** TIER1

**Current Status:** ✅ APPROVED

**Requirements:**
- 1 Team Member approval ✅ (1/1)
- 1 Team Lead OR Management approval ✅ (1/1)



---
*This comment is automatically updated when reviews change.*

@opaninakuffo opaninakuffo merged commit 3148850 into tetherto:main May 13, 2026
12 of 13 checks passed
GustavoA1604 added a commit that referenced this pull request May 14, 2026
* 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>
NamelsKing added a commit that referenced this pull request May 15, 2026
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>
Proletter pushed a commit that referenced this pull request May 24, 2026
* 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.
Proletter pushed a commit that referenced this pull request May 24, 2026
* 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>
Proletter pushed a commit that referenced this pull request May 24, 2026
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test-e2e-smoke Triggers smoke e2e test suite [Currently SDK-only] tier1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants