@qvac/sdk 0.13.5 → 0.14.1

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 (226) hide show
  1. package/NOTICE +95 -1151
  2. package/README.md +1 -2
  3. package/bare-imports.json +0 -5
  4. package/dist/client/api/bci-transcribe.js +2 -1
  5. package/dist/client/api/download-asset.js +2 -1
  6. package/dist/client/api/finetune.js +6 -5
  7. package/dist/client/api/index.d.ts +1 -0
  8. package/dist/client/api/index.js +1 -0
  9. package/dist/client/api/load-model.d.ts +11 -8
  10. package/dist/client/api/load-model.js +6 -6
  11. package/dist/client/api/subscribe-logs.d.ts +28 -0
  12. package/dist/client/api/subscribe-logs.js +43 -0
  13. package/dist/client/api/text-to-speech.js +2 -1
  14. package/dist/client/config-loader/config-utils.js +2 -4
  15. package/dist/client/config-loader/resolve-config.bare.js +4 -3
  16. package/dist/client/parse-input.d.ts +3 -0
  17. package/dist/client/parse-input.js +14 -0
  18. package/dist/client/rpc/expo-rpc-client.js +2 -11
  19. package/dist/client/rpc/node-rpc-client.js +8 -2
  20. package/dist/client/rpc/rpc-client.js +39 -7
  21. package/dist/commands/bundle/constants.js +2 -1
  22. package/dist/commands/bundle/entry-gen.d.ts +1 -1
  23. package/dist/commands/bundle/entry-gen.js +6 -6
  24. package/dist/commands/bundle/index.js +3 -1
  25. package/dist/commands/bundle/resolve-sdk-import.d.ts +6 -0
  26. package/dist/commands/bundle/resolve-sdk-import.js +60 -0
  27. package/dist/examples/bci/bci-filesystem-streaming.js +14 -14
  28. package/dist/examples/bci/bci-filesystem.js +17 -13
  29. package/dist/examples/cache-management.js +38 -38
  30. package/dist/examples/cancel-by-request-id.js +9 -9
  31. package/dist/examples/completion-events.js +20 -14
  32. package/dist/examples/completion-stop-reason.js +13 -7
  33. package/dist/examples/concurrent-completion-collision.js +7 -7
  34. package/dist/examples/config-reload.js +7 -8
  35. package/dist/examples/default-config-usage.js +4 -4
  36. package/dist/examples/delegated-inference/composite.js +14 -10
  37. package/dist/examples/delegated-inference/consumer-profiled.js +13 -13
  38. package/dist/examples/delegated-inference/consumer.js +16 -12
  39. package/dist/examples/delegated-inference/provider.js +12 -12
  40. package/dist/examples/diffusion-esrgan-upscale.js +19 -15
  41. package/dist/examples/diffusion-flux2-klein-img2img.js +16 -11
  42. package/dist/examples/diffusion-flux2-klein.js +14 -9
  43. package/dist/examples/diffusion-img2img.js +9 -10
  44. package/dist/examples/diffusion-img2vid.js +17 -12
  45. package/dist/examples/diffusion-simple.js +1 -1
  46. package/dist/examples/diffusion-txt2img.js +14 -9
  47. package/dist/examples/diffusion-txt2vid.js +15 -10
  48. package/dist/examples/download-with-blind-relays.js +16 -21
  49. package/dist/examples/download-with-cancel.js +15 -16
  50. package/dist/examples/embed-multi-gpu.js +3 -4
  51. package/dist/examples/embed-p2p.js +11 -7
  52. package/dist/examples/finetune/llamacpp-finetune.js +7 -7
  53. package/dist/examples/kv-cache-cleanup.js +35 -35
  54. package/dist/examples/kv-cache-custom-key.js +24 -24
  55. package/dist/examples/kv-cache-example.js +9 -9
  56. package/dist/examples/llamacpp-cache.js +18 -14
  57. package/dist/examples/llamacpp-dynamic-tools.js +15 -9
  58. package/dist/examples/llamacpp-filesystem.js +15 -9
  59. package/dist/examples/llamacpp-http.js +12 -10
  60. package/dist/examples/llamacpp-multi-gpu.js +4 -4
  61. package/dist/examples/llamacpp-multimodal.js +13 -9
  62. package/dist/examples/llamacpp-p2p.js +8 -4
  63. package/dist/examples/llamacpp-sharded.js +5 -5
  64. package/dist/examples/llamacpp-structured-output.js +15 -9
  65. package/dist/examples/logging-file-transport.js +3 -3
  66. package/dist/examples/logging-global.d.ts +2 -0
  67. package/dist/examples/logging-global.js +34 -0
  68. package/dist/examples/logging-streaming.js +7 -10
  69. package/dist/examples/mcp-websearch.js +24 -18
  70. package/dist/examples/multi-model-demo.js +17 -11
  71. package/dist/examples/ocr-fasttext.js +14 -16
  72. package/dist/examples/parallel-download.js +7 -7
  73. package/dist/examples/plugins.js +40 -28
  74. package/dist/examples/profiling/basic.js +16 -10
  75. package/dist/examples/profiling/per-call.js +17 -11
  76. package/dist/examples/quickstart.bare.d.ts +2 -0
  77. package/dist/examples/quickstart.bare.js +18 -0
  78. package/dist/examples/quickstart.js +10 -3
  79. package/dist/examples/rag/rag-chromadb.js +18 -14
  80. package/dist/examples/rag/rag-hyperdb/cancellation.js +17 -14
  81. package/dist/examples/rag/rag-hyperdb/ingest.js +14 -12
  82. package/dist/examples/rag/rag-hyperdb/pipeline.js +19 -17
  83. package/dist/examples/rag/rag-hyperdb/workspaces.js +31 -27
  84. package/dist/examples/rag/rag-lancedb.js +12 -8
  85. package/dist/examples/rag/rag-sqlite.js +11 -7
  86. package/dist/examples/registry-query.js +17 -17
  87. package/dist/examples/seed-p2p.js +10 -6
  88. package/dist/examples/suspend-resume.js +20 -16
  89. package/dist/examples/tools/llamacpp-native-tools.js +24 -18
  90. package/dist/examples/tools/llamacpp-tools-gemma4.js +14 -8
  91. package/dist/examples/tools/llamacpp-tools-harmony-multiturn.js +20 -14
  92. package/dist/examples/tools/llamacpp-tools-pythonic.js +14 -8
  93. package/dist/examples/tools/llamacpp-tools-qwen35.js +14 -8
  94. package/dist/examples/transcription/parakeet-ctc-filesystem.js +12 -9
  95. package/dist/examples/transcription/parakeet-microphone-record.js +15 -9
  96. package/dist/examples/transcription/parakeet-microphone-stream.js +15 -9
  97. package/dist/examples/transcription/parakeet-sortformer-streaming.js +12 -6
  98. package/dist/examples/transcription/parakeet-sortformer.js +3 -5
  99. package/dist/examples/transcription/parakeet-tdt-filesystem.js +13 -10
  100. package/dist/examples/transcription/whispercpp-filesystem-streaming.js +16 -17
  101. package/dist/examples/transcription/whispercpp-filesystem.js +14 -10
  102. package/dist/examples/transcription/whispercpp-microphone-conversation.js +10 -10
  103. package/dist/examples/transcription/whispercpp-microphone-record.js +6 -6
  104. package/dist/examples/transcription/whispercpp-prompt.js +14 -10
  105. package/dist/examples/translation/translation-bergamot-batch.js +11 -7
  106. package/dist/examples/translation/translation-bergamot-pivot.js +13 -9
  107. package/dist/examples/translation/translation-bergamot.js +8 -4
  108. package/dist/examples/translation/translation-indic.js +8 -4
  109. package/dist/examples/translation/translation-llm-afriquegemma.js +7 -3
  110. package/dist/examples/translation/translation-llm-context.js +8 -4
  111. package/dist/examples/translation/translation-llm.js +7 -3
  112. package/dist/examples/translation/translation-stream.js +4 -4
  113. package/dist/examples/tts/chatterbox.js +19 -11
  114. package/dist/examples/tts/llm-to-tts-streaming.js +27 -14
  115. package/dist/examples/tts/supertonic-multilingual.js +18 -14
  116. package/dist/examples/tts/supertonic.js +19 -15
  117. package/dist/examples/tts/utils.js +1 -1
  118. package/dist/examples/vla-pi05.js +18 -14
  119. package/dist/examples/vla-smolvla.js +18 -14
  120. package/dist/examples/voice-assistant/voice-assistant.js +12 -12
  121. package/dist/index.d.ts +3 -4
  122. package/dist/index.js +3 -4
  123. package/dist/logging/client-logger.js +2 -1
  124. package/dist/logging/index.d.ts +1 -1
  125. package/dist/logging/index.js +1 -1
  126. package/dist/logging/namespaces.d.ts +1 -0
  127. package/dist/logging/namespaces.js +2 -0
  128. package/dist/logging/server-logger.js +1 -4
  129. package/dist/logging/utils.js +6 -1
  130. package/dist/models/registry/index.d.ts +17 -0
  131. package/dist/models/registry/index.js +20 -1
  132. package/dist/models/registry/models.d.ts +1062 -38
  133. package/dist/models/registry/models.js +3546 -2490
  134. package/dist/pear/pre.js +2 -2
  135. package/dist/schemas/bci-config.d.ts +37 -0
  136. package/dist/schemas/bci-config.js +2 -0
  137. package/dist/schemas/bci.d.ts +2 -0
  138. package/dist/schemas/common.d.ts +171 -94
  139. package/dist/schemas/completion-stream.d.ts +6 -3
  140. package/dist/schemas/completion-stream.js +10 -2
  141. package/dist/schemas/download-asset.d.ts +5 -5
  142. package/dist/schemas/engine-addon-map.d.ts +1 -1
  143. package/dist/schemas/engine-addon-map.js +6 -3
  144. package/dist/schemas/error.js +6 -1
  145. package/dist/schemas/llamacpp-config.d.ts +27 -8
  146. package/dist/schemas/llamacpp-config.js +19 -2
  147. package/dist/schemas/load-model.d.ts +4170 -570
  148. package/dist/schemas/load-model.js +85 -26
  149. package/dist/schemas/logging-stream.js +7 -1
  150. package/dist/schemas/model-src-utils.d.ts +6 -6
  151. package/dist/schemas/model-types.d.ts +14 -15
  152. package/dist/schemas/model-types.js +10 -11
  153. package/dist/schemas/ocr.d.ts +10 -8
  154. package/dist/schemas/ocr.js +8 -6
  155. package/dist/schemas/plugin.d.ts +6 -5
  156. package/dist/schemas/plugin.js +4 -4
  157. package/dist/schemas/rag.d.ts +4 -4
  158. package/dist/schemas/registry.d.ts +8 -8
  159. package/dist/schemas/registry.js +1 -1
  160. package/dist/schemas/reload-config.d.ts +6 -6
  161. package/dist/schemas/sdcpp-config.d.ts +12 -12
  162. package/dist/schemas/sdk-config.d.ts +171 -117
  163. package/dist/schemas/sdk-config.js +5 -5
  164. package/dist/schemas/sdk-errors-client.d.ts +1 -0
  165. package/dist/schemas/sdk-errors-client.js +7 -2
  166. package/dist/schemas/text-to-speech.d.ts +157 -13
  167. package/dist/schemas/text-to-speech.js +70 -7
  168. package/dist/schemas/transcription-config.d.ts +5 -1
  169. package/dist/schemas/transcription-config.js +2 -0
  170. package/dist/schemas/transcription.d.ts +3 -0
  171. package/dist/schemas/transcription.js +2 -1
  172. package/dist/schemas/translate.d.ts +6 -6
  173. package/dist/schemas/translate.js +2 -3
  174. package/dist/schemas/translation-config.d.ts +20 -20
  175. package/dist/server/bare/hyperswarm.js +3 -3
  176. package/dist/server/bare/ops/transcribe.js +46 -15
  177. package/dist/server/bare/plugins/bci-whispercpp-transcription/args.d.ts +3 -0
  178. package/dist/server/bare/plugins/bci-whispercpp-transcription/args.js +13 -0
  179. package/dist/server/bare/plugins/bci-whispercpp-transcription/plugin.d.ts +41 -0
  180. package/dist/server/bare/plugins/bci-whispercpp-transcription/plugin.js +6 -11
  181. package/dist/server/bare/plugins/bci-whispercpp-transcription/resolve-config.d.ts +75 -0
  182. package/dist/server/bare/plugins/bci-whispercpp-transcription/resolve-config.js +11 -0
  183. package/dist/server/bare/plugins/{onnx-ocr → ggml-ocr}/plugin.d.ts +16 -10
  184. package/dist/server/bare/plugins/{onnx-ocr → ggml-ocr}/plugin.js +25 -18
  185. package/dist/server/bare/plugins/index.d.ts +1 -1
  186. package/dist/server/bare/plugins/index.js +1 -1
  187. package/dist/server/bare/plugins/llamacpp-completion/ops/completion-stats.d.ts +10 -0
  188. package/dist/server/bare/plugins/llamacpp-completion/ops/completion-stats.js +29 -0
  189. package/dist/server/bare/plugins/llamacpp-completion/ops/completion-stream.js +4 -22
  190. package/dist/server/bare/plugins/llamacpp-completion/plugin.d.ts +15 -7
  191. package/dist/server/bare/plugins/nmtcpp-translation/plugin.d.ts +7 -7
  192. package/dist/server/bare/plugins/parakeet-transcription/plugin.d.ts +2 -0
  193. package/dist/server/bare/plugins/sdcpp-generation/plugin.d.ts +10 -10
  194. package/dist/server/bare/plugins/tts-ggml/plugin.d.ts +14 -8
  195. package/dist/server/bare/plugins/tts-ggml/plugin.js +12 -0
  196. package/dist/server/bare/plugins/whispercpp-transcription/plugin.d.ts +3 -1
  197. package/dist/server/bare/registry/logging-stream-registry.d.ts +4 -2
  198. package/dist/server/bare/registry/logging-stream-registry.js +12 -7
  199. package/dist/server/bare/registry/model-config-utils.js +2 -2
  200. package/dist/server/bare/registry/registry-client.js +1 -1
  201. package/dist/server/bare/runtime-lifecycle.d.ts +9 -0
  202. package/dist/server/bare/runtime-lifecycle.js +24 -0
  203. package/dist/server/bare/types/addon-responses.d.ts +1 -0
  204. package/dist/server/env.js +7 -10
  205. package/dist/server/plugins/registry.js +2 -4
  206. package/dist/server/rpc/handlers/load-model/handler.js +2 -4
  207. package/dist/server/rpc/handlers/load-model/http.js +253 -51
  208. package/dist/server/rpc/handlers/logging-stream.js +4 -2
  209. package/dist/server/rpc/handlers/plugin-invoke.js +5 -16
  210. package/dist/server/utils/completion-normalizer.js +13 -4
  211. package/dist/server/utils/worker-lock.js +5 -5
  212. package/dist/server/worker-core.d.ts +1 -1
  213. package/dist/server/worker-core.js +28 -18
  214. package/dist/utils/errors-client.d.ts +3 -0
  215. package/dist/utils/errors-client.js +5 -0
  216. package/dist/utils/errors-server.d.ts +2 -0
  217. package/dist/utils/errors-server.js +3 -0
  218. package/dist/utils/zod-error.d.ts +3 -0
  219. package/dist/utils/zod-error.js +4 -0
  220. package/package.json +21 -24
  221. package/dist/polyfills/bare-globals.d.ts +0 -2
  222. package/dist/polyfills/bare-globals.js +0 -4
  223. package/dist/polyfills/bare-globals.noop.d.ts +0 -2
  224. package/dist/polyfills/bare-globals.noop.js +0 -1
  225. /package/dist/server/bare/plugins/{onnx-ocr → ggml-ocr}/ops/ocr-stream.d.ts +0 -0
  226. /package/dist/server/bare/plugins/{onnx-ocr → ggml-ocr}/ops/ocr-stream.js +0 -0
@@ -25,14 +25,18 @@ const DIALECT_SPECS = {
25
25
  ],
26
26
  contentFrames: [
27
27
  { open: "<|channel|>final<|message|>", close: "<|return|>" },
28
+ { open: "<|channel|>assistant<|message|>", close: "<|end|>" },
28
29
  ],
29
- // Role headers between channel frames + stray `<|return|>` closes.
30
+ // Role headers and stray Harmony control tokens between frames.
30
31
  dropTokens: [
32
+ "<|message|>",
33
+ "<|end|>",
31
34
  "<|start|>assistant",
32
35
  "<|start|>system",
33
36
  "<|start|>user",
34
37
  "<|return|>",
35
38
  ],
39
+ contentDropTokens: ["<|channel|>"],
36
40
  },
37
41
  qwen35: {
38
42
  // Same <tool_call>…</tool_call> framing as hermes; inner content is XML.
@@ -88,6 +92,7 @@ export function createCompletionNormalizer(config) {
88
92
  ];
89
93
  const contentFrames = dialectSpec.contentFrames ?? [];
90
94
  const dropTokens = dialectSpec.dropTokens ?? [];
95
+ const contentDropTokens = dialectSpec.contentDropTokens ?? [];
91
96
  const markerToEntry = new Map();
92
97
  const dropTokenSet = new Set();
93
98
  const contentMarkers = [];
@@ -112,10 +117,14 @@ export function createCompletionNormalizer(config) {
112
117
  return seq++;
113
118
  }
114
119
  function emitContent(events, text) {
115
- if (!text)
120
+ let normalized = text;
121
+ for (const token of contentDropTokens) {
122
+ normalized = normalized.split(token).join("");
123
+ }
124
+ if (!normalized)
116
125
  return;
117
- contentParts.push(text);
118
- events.push({ type: "contentDelta", seq: nextSeq(), text });
126
+ contentParts.push(normalized);
127
+ events.push({ type: "contentDelta", seq: nextSeq(), text: normalized });
119
128
  }
120
129
  // Capture-gated: thinking frames may register even when `captureThinking`
121
130
  // is false (e.g. harmony's analysis channel, to strip markers from
@@ -1,6 +1,6 @@
1
1
  import fs from "bare-fs";
2
2
  import path from "bare-path";
3
- import process from "bare-process";
3
+ import os from "bare-os";
4
4
  import { getServerLogger } from "../../logging/index.js";
5
5
  import { getQvacPath } from "./qvac-paths.js";
6
6
  const logger = getServerLogger();
@@ -10,7 +10,7 @@ function getLockFilePath() {
10
10
  }
11
11
  function isProcessAlive(pid) {
12
12
  try {
13
- process.kill(pid, 0);
13
+ os.kill(pid, 0);
14
14
  return true;
15
15
  }
16
16
  catch {
@@ -40,13 +40,13 @@ export function acquireWorkerLock() {
40
40
  }
41
41
  }
42
42
  const content = {
43
- pid: process.pid,
43
+ pid: os.pid(),
44
44
  startedAt: new Date().toISOString(),
45
45
  };
46
46
  try {
47
47
  fs.mkdirSync(path.dirname(lockPath), { recursive: true });
48
48
  fs.writeFileSync(lockPath, JSON.stringify(content));
49
- logger.debug(`Worker lock acquired (PID ${process.pid})`);
49
+ logger.debug(`Worker lock acquired (PID ${os.pid()})`);
50
50
  }
51
51
  catch (error) {
52
52
  logger.error("Failed to write worker lock file:", error instanceof Error ? error.message : String(error));
@@ -56,7 +56,7 @@ export function releaseWorkerLock() {
56
56
  const lockPath = getLockFilePath();
57
57
  try {
58
58
  const existing = readLockFile(lockPath);
59
- if (existing && existing.pid === process.pid) {
59
+ if (existing && existing.pid === os.pid()) {
60
60
  fs.unlinkSync(lockPath);
61
61
  logger.debug("Worker lock released");
62
62
  }
@@ -8,7 +8,7 @@ export type BareDirectShutdownReason = "signal" | "rpc-close" | "uncaught-except
8
8
  * Pre-terminate cleanup, callable while the worker is still alive.
9
9
  *
10
10
  * On platforms where the worker lives in the same OS process as the JS host
11
- * (i.e. mobile via react-native-bare-kit Worklet), `process.exit()` would
11
+ * (i.e. mobile via react-native-bare-kit Worklet), `Bare.exit()` would
12
12
  * kill the entire app. This path runs the same registry/model cleanup as
13
13
  * `shutdownBareDirectWorker` but skips the lock release + exit, leaving the
14
14
  * caller (typically the SDK client about to call `worklet.terminate()`)
@@ -1,4 +1,5 @@
1
- import process from "bare-process";
1
+ import os from "bare-os";
2
+ import Signal from "bare-signals";
2
3
  import { createBareKitRPCServer, createIPCClient, } from "./rpc/create-server.js";
3
4
  import { destroySwarm } from "./bare/hyperswarm.js";
4
5
  import { initEnv, getValidatedEnv } from "./env.js";
@@ -6,8 +7,8 @@ import { closeAllRagInstances } from "./bare/rag-hyperdb/index.js";
6
7
  import { cleanupDownloads } from "./rpc/handlers/load-model/download-manager.js";
7
8
  import { unloadAllModels } from "./bare/registry/model-registry.js";
8
9
  import { closeRegistryClient } from "./bare/registry/registry-client.js";
9
- import { clearAllLoggingStreams, startLogBuffering, } from "./bare/registry/logging-stream-registry.js";
10
- import { clearAllAddonLoggers, getServerLogger, SDK_LOG_ID } from "../logging/index.js";
10
+ import { clearAllLoggingStreams, startLogBuffering, stopLogBufferingWithTimeout, } from "./bare/registry/logging-stream-registry.js";
11
+ import { clearAllAddonLoggers, getServerLogger, SDK_LOG_ID, SDK_ALL_LOG_ID, } from "../logging/index.js";
11
12
  import { clearPlugins } from "./plugins/index.js";
12
13
  import { acquireWorkerLock, releaseWorkerLock, } from "./utils/worker-lock.js";
13
14
  let coreInitialized = false;
@@ -19,11 +20,11 @@ let cleanupRan = false;
19
20
  // Set true when shutdownBareDirectWorker is in flight. Distinct from
20
21
  // cleanupRan: cleanupForTerminate must NOT set this, otherwise a later
21
22
  // SIGTERM/SIGINT/uncaught-exception would early-return at the guard
22
- // in shutdownBareDirectWorker and skip releaseWorkerLock + process.exit.
23
+ // in shutdownBareDirectWorker and skip releaseWorkerLock + Bare.exit.
23
24
  let isShuttingDown = false;
24
25
  const logger = getServerLogger();
25
26
  // Defense-in-depth grace period for the SIGKILL safety net armed before
26
- // process.exit() in shutdownBareDirectWorker. If process.exit cannot
27
+ // Bare.exit() in shutdownBareDirectWorker. If Bare.exit cannot
27
28
  // terminate the worker within this window — typically because some path
28
29
  // holds a non-cancellable native handle (e.g. a libuv worker thread
29
30
  // blocked on flock; see QVAC-18197) — we force-kill the OS process to
@@ -31,10 +32,10 @@ const logger = getServerLogger();
31
32
  const FORCE_EXIT_GRACE_MS = 3_000;
32
33
  function scheduleForceExit() {
33
34
  const timer = setTimeout(() => {
34
- logger.error(`process.exit did not terminate the worker within ${FORCE_EXIT_GRACE_MS}ms — ` +
35
+ logger.error(`Bare.exit did not terminate the worker within ${FORCE_EXIT_GRACE_MS}ms — ` +
35
36
  `force-killing self (likely blocked native handle)`);
36
37
  try {
37
- process.kill(process.pid, "SIGKILL");
38
+ os.kill(os.pid(), "SIGKILL");
38
39
  }
39
40
  catch {
40
41
  // best-effort — if SIGKILL itself fails, there's nothing more to do
@@ -52,12 +53,13 @@ export function initializeWorkerCore() {
52
53
  return { hasRPCConfig: !!validatedEnv.QVAC_IPC_SOCKET_PATH };
53
54
  }
54
55
  startLogBuffering(SDK_LOG_ID);
56
+ startLogBuffering(SDK_ALL_LOG_ID);
55
57
  const { hasRPCConfig } = initEnv();
56
58
  acquireWorkerLock();
57
59
  setupShutdownHandlers();
58
60
  coreInitialized = true;
59
61
  logger.debug("Worker core initialized");
60
- logger.debug("Arguments to worker:", process.argv);
62
+ logger.debug("Arguments to worker:", Bare.argv);
61
63
  return { hasRPCConfig };
62
64
  }
63
65
  export function ensureRPCSetup() {
@@ -81,12 +83,18 @@ export function ensureRPCSetup() {
81
83
  createBareKitRPCServer();
82
84
  }
83
85
  logger.info("Bare worker started and listening for RPC requests");
84
- logger.debug("Working directory:", process.cwd());
86
+ logger.debug("Working directory:", os.cwd());
85
87
  rpcInitialized = true;
88
+ // The worker is now reachable, so a `subscribeServerLogs` client can connect.
89
+ // Bound the global startup buffer the same way model-load buffering is bounded:
90
+ // if nothing subscribes within the grace window, stop buffering so every server
91
+ // log doesn't keep churning that buffer for the worker's whole lifetime. A
92
+ // subscriber that connects in time cancels the timeout and flushes the buffer.
93
+ stopLogBufferingWithTimeout(SDK_ALL_LOG_ID);
86
94
  }
87
95
  catch (error) {
88
96
  logger.error("Worker error:", error);
89
- process.exit(1);
97
+ Bare.exit(1);
90
98
  }
91
99
  }
92
100
  export function isCoreInitialized() {
@@ -102,7 +110,7 @@ function clearRegistries() {
102
110
  * Clears plugin registries (which calls each addon's `releaseLogger` →
103
111
  * frees env-bound js_ref_t state), unloads all loaded models (which calls
104
112
  * each addon's `destroyInstance`), and closes infra (swarm, rag, downloads,
105
- * registry client). Does NOT touch the worker lock or call `process.exit`.
113
+ * registry client). Does NOT touch the worker lock or call `Bare.exit`.
106
114
  *
107
115
  * Idempotent: subsequent calls are no-ops via the `cleanupRan` flag. The
108
116
  * underlying clearPlugins / unloadAllModels / closers are also idempotent
@@ -126,7 +134,7 @@ async function runCleanup() {
126
134
  * Pre-terminate cleanup, callable while the worker is still alive.
127
135
  *
128
136
  * On platforms where the worker lives in the same OS process as the JS host
129
- * (i.e. mobile via react-native-bare-kit Worklet), `process.exit()` would
137
+ * (i.e. mobile via react-native-bare-kit Worklet), `Bare.exit()` would
130
138
  * kill the entire app. This path runs the same registry/model cleanup as
131
139
  * `shutdownBareDirectWorker` but skips the lock release + exit, leaving the
132
140
  * caller (typically the SDK client about to call `worklet.terminate()`)
@@ -139,7 +147,7 @@ async function runCleanup() {
139
147
  export async function cleanupForTerminate() {
140
148
  // Intentionally does NOT set isShuttingDown — that flag is reserved for
141
149
  // shutdownBareDirectWorker so a later SIGTERM/SIGINT still gets to run
142
- // the lock release + process.exit path. runCleanup is idempotent on its
150
+ // the lock release + Bare.exit path. runCleanup is idempotent on its
143
151
  // own, so a follow-up shutdownBareDirectWorker call won't redo the body.
144
152
  if (cleanupRan)
145
153
  return;
@@ -175,16 +183,18 @@ export async function shutdownBareDirectWorker(reason) {
175
183
  releaseWorkerLock();
176
184
  scheduleForceExit();
177
185
  const isGraceful = reason === "signal" || reason === "rpc-close";
178
- process.exit(isGraceful ? 0 : 1);
186
+ Bare.exit(isGraceful ? 0 : 1);
179
187
  }
180
188
  function setupShutdownHandlers() {
181
- process.once("SIGTERM", () => void shutdownBareDirectWorker("signal"));
182
- process.once("SIGINT", () => void shutdownBareDirectWorker("signal"));
183
- process.on("uncaughtException", (err) => {
189
+ const signals = new Signal.Emitter();
190
+ signals.unref();
191
+ signals.once("SIGTERM", () => void shutdownBareDirectWorker("signal"));
192
+ signals.once("SIGINT", () => void shutdownBareDirectWorker("signal"));
193
+ Bare.on("uncaughtException", (err) => {
184
194
  logger.error("Uncaught exception in worker:", err);
185
195
  void shutdownBareDirectWorker("uncaught-exception");
186
196
  });
187
- process.on("unhandledRejection", (reason) => {
197
+ Bare.on("unhandledRejection", (reason) => {
188
198
  logger.error("Unhandled rejection in worker:", reason);
189
199
  void shutdownBareDirectWorker("unhandled-rejection");
190
200
  });
@@ -109,6 +109,9 @@ export declare class ConfigFileParseFailedError extends QvacErrorBase {
109
109
  export declare class ConfigValidationFailedError extends QvacErrorBase {
110
110
  constructor(errors: string, cause?: unknown);
111
111
  }
112
+ export declare class RequestValidationFailedError extends QvacErrorBase {
113
+ constructor(errors: string, cause?: unknown);
114
+ }
112
115
  export declare class ModelUnloadFailedError extends QvacErrorBase {
113
116
  constructor(modelId?: string, cause?: unknown);
114
117
  }
@@ -191,6 +191,11 @@ export class ConfigValidationFailedError extends QvacErrorBase {
191
191
  super(createErrorOptions(SDK_CLIENT_ERROR_CODES.CONFIG_VALIDATION_FAILED, [errors], cause));
192
192
  }
193
193
  }
194
+ export class RequestValidationFailedError extends QvacErrorBase {
195
+ constructor(errors, cause) {
196
+ super(createErrorOptions(SDK_CLIENT_ERROR_CODES.REQUEST_VALIDATION_FAILED, [errors], cause));
197
+ }
198
+ }
194
199
  // ============== Operation Errors (Client-side wrappers for server operations) ==============
195
200
  // These are used by client API to throw errors based on server responses
196
201
  // They reference server error codes but are thrown on client side
@@ -234,6 +234,8 @@ export declare class ChecksumValidationFailedError extends QvacErrorBase {
234
234
  constructor(fileName: string, cause?: unknown);
235
235
  }
236
236
  export declare class HTTPError extends QvacErrorBase {
237
+ /** HTTP status code; `0` denotes a connection/network failure (no response). */
238
+ readonly httpStatus: number;
237
239
  constructor(status: number, statusText: string, cause?: unknown);
238
240
  }
239
241
  export declare class NoResponseBodyError extends QvacErrorBase {
@@ -361,8 +361,11 @@ export class ChecksumValidationFailedError extends QvacErrorBase {
361
361
  }
362
362
  }
363
363
  export class HTTPError extends QvacErrorBase {
364
+ /** HTTP status code; `0` denotes a connection/network failure (no response). */
365
+ httpStatus;
364
366
  constructor(status, statusText, cause) {
365
367
  super(createErrorOptions(SDK_SERVER_ERROR_CODES.HTTP_ERROR, [status, statusText], cause));
368
+ this.httpStatus = status;
366
369
  }
367
370
  }
368
371
  export class NoResponseBodyError extends QvacErrorBase {
@@ -0,0 +1,3 @@
1
+ import { z } from "zod";
2
+ export declare function formatZodError(error: z.ZodError): string;
3
+ //# sourceMappingURL=zod-error.d.ts.map
@@ -0,0 +1,4 @@
1
+ import { z } from "zod";
2
+ export function formatZodError(error) {
3
+ return z.prettifyError(error);
4
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qvac/sdk",
3
- "version": "0.13.5",
3
+ "version": "0.14.1",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -8,7 +8,7 @@
8
8
  "directory": "packages/sdk"
9
9
  },
10
10
  "bugs": "https://github.com/tetherto/qvac/issues",
11
- "homepage": "https://github.com/tetherto/qvac/tree/main/packages/sdk#readme",
11
+ "homepage": "https://qvac.tether.io",
12
12
  "keywords": [
13
13
  "ai",
14
14
  "bare",
@@ -100,9 +100,9 @@
100
100
  "types": "./dist/server/bare/plugins/tts-ggml/plugin.d.ts",
101
101
  "import": "./dist/server/bare/plugins/tts-ggml/plugin.js"
102
102
  },
103
- "./onnx-ocr/plugin": {
104
- "types": "./dist/server/bare/plugins/onnx-ocr/plugin.d.ts",
105
- "import": "./dist/server/bare/plugins/onnx-ocr/plugin.js"
103
+ "./ggml-ocr/plugin": {
104
+ "types": "./dist/server/bare/plugins/ggml-ocr/plugin.d.ts",
105
+ "import": "./dist/server/bare/plugins/ggml-ocr/plugin.js"
106
106
  },
107
107
  "./sdcpp-generation/plugin": {
108
108
  "types": "./dist/server/bare/plugins/sdcpp-generation/plugin.d.ts",
@@ -148,12 +148,6 @@
148
148
  "./pear-pre": "./dist/pear/pre.js"
149
149
  },
150
150
  "imports": {
151
- "#polyfill-bare-globals": {
152
- "bun": "./dist/polyfills/bare-globals.noop.js",
153
- "node": "./dist/polyfills/bare-globals.noop.js",
154
- "bare": "./dist/polyfills/bare-globals.js",
155
- "default": "./dist/polyfills/bare-globals.noop.js"
156
- },
157
151
  "#rpc": {
158
152
  "react-native": "./dist/client/rpc/expo-rpc-client.js",
159
153
  "bare": "./dist/client/rpc/bare-client.js",
@@ -206,34 +200,35 @@
206
200
  "changelog:generate": "node ../../scripts/sdk/generate-changelog-sdk-pod.cjs --package=sdk && prettier --write changelog"
207
201
  },
208
202
  "dependencies": {
209
- "@qvac/bci-whispercpp": "^0.2.0",
210
- "@qvac/classification-ggml": "^0.3.1",
203
+ "@qvac/bci-whispercpp": "^0.3.2",
204
+ "@qvac/classification-ggml": "^0.7.0",
211
205
  "@qvac/decoder-audio": "^0.5.0",
212
- "@qvac/diffusion-cpp": "^0.11.2",
213
- "@qvac/embed-llamacpp": "^0.19.1",
206
+ "@qvac/diffusion-cpp": "^0.12.0",
207
+ "@qvac/embed-llamacpp": "^0.23.0",
214
208
  "@qvac/error": "^0.1.1",
215
209
  "@qvac/langdetect-text": "^0.1.2",
216
- "@qvac/llm-llamacpp": "^0.24.0",
210
+ "@qvac/llm-llamacpp": "^0.30.0",
217
211
  "@qvac/logging": "^0.1.0",
218
- "@qvac/ocr-onnx": "^0.6.0",
212
+ "@qvac/ocr-ggml": "^0.7.0",
219
213
  "@qvac/rag": "^0.6.4",
220
- "@qvac/registry-client": "^0.6.0",
221
- "@qvac/transcription-parakeet": "^0.7.1",
222
- "@qvac/transcription-whispercpp": "^0.9.0",
223
- "@qvac/translation-nmtcpp": "^5.0.1",
224
- "@qvac/tts-ggml": "^0.2.0",
225
- "@qvac/vla-ggml": "^0.3.2",
214
+ "@qvac/registry-client": "^0.6.1",
215
+ "@qvac/transcription-parakeet": "^0.8.1",
216
+ "@qvac/transcription-whispercpp": "^0.10.0",
217
+ "@qvac/translation-nmtcpp": "^6.3.0",
218
+ "@qvac/tts-ggml": "^0.3.1",
219
+ "@qvac/vla-ggml": "^0.7.0",
226
220
  "bare-abort-controller": "^1.0.0",
227
221
  "bare-crypto": "^1.15.0",
222
+ "bare-env": "^3.0.0",
228
223
  "bare-fetch": "^3.0.1",
229
224
  "bare-fs": "^4.5.1",
230
225
  "bare-net": "^2.3.2",
231
226
  "bare-os": "^3.6.2",
232
227
  "bare-pack": "^2.0.1",
233
228
  "bare-path": "^3.0.1",
234
- "bare-process": "^4.2.2",
235
229
  "bare-rpc": "^1.3.2",
236
230
  "bare-runtime": "^1.24.2",
231
+ "bare-signals": "^4.2.0",
237
232
  "bare-stream": "^2.7.0",
238
233
  "bare-zlib": "^1.3.1",
239
234
  "compact-encoding": "^3.0.0",
@@ -256,7 +251,9 @@
256
251
  "@types/node": "^24.2.1",
257
252
  "@types/semver": "^7.7.1",
258
253
  "@types/tar-stream": "^3.1.4",
254
+ "bare-process": "^4.4.1",
259
255
  "bare-readline": "^1.2.0",
256
+ "bare-stdio": "^1.0.2",
260
257
  "bare-subprocess": "^6.1.0",
261
258
  "bare-url": "^2.4.3",
262
259
  "brittle": "^4.0.0",
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=bare-globals.d.ts.map
@@ -1,4 +0,0 @@
1
- import process from "bare-process";
2
- if (typeof globalThis.process === "undefined") {
3
- globalThis.process = process;
4
- }
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=bare-globals.noop.d.ts.map
@@ -1 +0,0 @@
1
- export {};