@qvac/sdk 0.17.0 → 0.18.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 (154) hide show
  1. package/NOTICE +83 -18
  2. package/README.md +19 -0
  3. package/dist/client/api/audio-gen.d.ts +17 -0
  4. package/dist/client/api/audio-gen.js +17 -0
  5. package/dist/client/api/finetune.d.ts +2 -0
  6. package/dist/client/api/finetune.js +7 -1
  7. package/dist/client/api/index.d.ts +1 -1
  8. package/dist/client/api/index.js +1 -1
  9. package/dist/client/api/load-model.d.ts +8 -0
  10. package/dist/client/api/transcribe.d.ts +19 -2
  11. package/dist/client/api/transcribe.js +66 -27
  12. package/dist/client/api/translate.d.ts +3 -2
  13. package/dist/client/api/translate.js +42 -21
  14. package/dist/client/api/vla.d.ts +42 -1
  15. package/dist/client/api/vla.js +50 -1
  16. package/dist/commands/bundle/entry-gen.d.ts +4 -0
  17. package/dist/commands/bundle/entry-gen.js +6 -0
  18. package/dist/commands/bundle/index.js +19 -12
  19. package/dist/examples/asr/parakeet-indic-conformer-filesystem.d.ts +2 -0
  20. package/dist/examples/asr/parakeet-indic-conformer-filesystem.js +52 -0
  21. package/dist/examples/audiogen/generate-cover.d.ts +2 -0
  22. package/dist/examples/audiogen/generate-cover.js +100 -0
  23. package/dist/examples/llamacpp-fallback.d.ts +2 -0
  24. package/dist/examples/llamacpp-fallback.js +34 -0
  25. package/dist/examples/multi-job-completion.d.ts +28 -0
  26. package/dist/examples/multi-job-completion.js +128 -0
  27. package/dist/examples/profiling/basic.js +32 -1
  28. package/dist/examples/system-resources.d.ts +2 -0
  29. package/dist/examples/system-resources.js +86 -0
  30. package/dist/examples/tts/audio8.d.ts +2 -0
  31. package/dist/examples/tts/audio8.js +54 -0
  32. package/dist/examples/tts/cosyvoice3.d.ts +2 -0
  33. package/dist/examples/tts/cosyvoice3.js +52 -0
  34. package/dist/examples/vla-groot.js +92 -49
  35. package/dist/index.d.ts +2 -2
  36. package/dist/index.js +2 -2
  37. package/dist/models/registry/models.d.ts +782 -6
  38. package/dist/models/registry/models.js +2664 -1859
  39. package/dist/schemas/audio-gen.d.ts +103 -0
  40. package/dist/schemas/audio-gen.js +135 -4
  41. package/dist/schemas/common.d.ts +550 -11
  42. package/dist/schemas/constants-registry.d.ts +18 -4
  43. package/dist/schemas/constants-registry.js +16 -3
  44. package/dist/schemas/index.d.ts +1 -1
  45. package/dist/schemas/index.js +1 -1
  46. package/dist/schemas/llamacpp-config.d.ts +10 -10
  47. package/dist/schemas/llamacpp-config.js +12 -5
  48. package/dist/schemas/load-model.d.ts +3678 -323
  49. package/dist/schemas/load-model.js +21 -3
  50. package/dist/schemas/sdk-config.d.ts +60 -24
  51. package/dist/schemas/sdk-errors-server.d.ts +1 -0
  52. package/dist/schemas/sdk-errors-server.js +5 -0
  53. package/dist/schemas/text-to-speech.d.ts +1086 -110
  54. package/dist/schemas/text-to-speech.js +194 -4
  55. package/dist/schemas/tools.d.ts +0 -16
  56. package/dist/schemas/tools.js +0 -15
  57. package/dist/schemas/transcription-config.d.ts +2 -0
  58. package/dist/schemas/transcription-config.js +10 -4
  59. package/dist/schemas/transcription.d.ts +3 -0
  60. package/dist/schemas/vla.d.ts +83 -0
  61. package/dist/schemas/vla.js +105 -2
  62. package/dist/scripts/link-workspace-inference.d.ts +2 -0
  63. package/dist/scripts/link-workspace-inference.js +31 -0
  64. package/dist/server/bare/ops/cancel.d.ts +1 -1
  65. package/dist/server/bare/ops/cancel.js +1 -1
  66. package/dist/server/bare/ops/kv-cache-retention.js +11 -0
  67. package/dist/server/bare/ops/kv-cache-utils.d.ts +1 -1
  68. package/dist/server/bare/ops/kv-cache-utils.js +40 -12
  69. package/dist/server/bare/ops/transcribe.d.ts +2 -2
  70. package/dist/server/bare/ops/transcribe.js +54 -48
  71. package/dist/server/bare/ops/translate-stats.d.ts +5 -0
  72. package/dist/server/bare/ops/translate-stats.js +11 -0
  73. package/dist/server/bare/ops/translate.js +66 -38
  74. package/dist/server/bare/ops/unload-model.js +30 -24
  75. package/dist/server/bare/plugins/audiogen-ggml/ops/audio-gen-input.d.ts +20 -0
  76. package/dist/server/bare/plugins/audiogen-ggml/ops/audio-gen-input.js +153 -0
  77. package/dist/server/bare/plugins/audiogen-ggml/ops/audio-gen-stream.js +52 -1
  78. package/dist/server/bare/plugins/audiogen-ggml/plugin.d.ts +28 -0
  79. package/dist/server/bare/plugins/ggml-ocr/plugin.js +3 -1
  80. package/dist/server/bare/plugins/ggml-vla/ops/vla-set-embodiment.d.ts +3 -0
  81. package/dist/server/bare/plugins/ggml-vla/ops/vla-set-embodiment.js +9 -0
  82. package/dist/server/bare/plugins/ggml-vla/plugin.d.ts +37 -0
  83. package/dist/server/bare/plugins/ggml-vla/plugin.js +21 -4
  84. package/dist/server/bare/plugins/llamacpp-completion/ops/batch-completion-stream.js +16 -15
  85. package/dist/server/bare/plugins/llamacpp-completion/ops/cache-logger.d.ts +1 -1
  86. package/dist/server/bare/plugins/llamacpp-completion/ops/cache-logger.js +2 -2
  87. package/dist/server/bare/plugins/llamacpp-completion/ops/completion-stats.d.ts +6 -0
  88. package/dist/server/bare/plugins/llamacpp-completion/ops/completion-stats.js +10 -0
  89. package/dist/server/bare/plugins/llamacpp-completion/ops/completion-stream.d.ts +1 -0
  90. package/dist/server/bare/plugins/llamacpp-completion/ops/completion-stream.js +131 -123
  91. package/dist/server/bare/plugins/llamacpp-completion/ops/finetune.js +110 -20
  92. package/dist/server/bare/plugins/llamacpp-completion/ops/kv-cache-session.d.ts +49 -23
  93. package/dist/server/bare/plugins/llamacpp-completion/ops/kv-cache-session.js +308 -143
  94. package/dist/server/bare/plugins/llamacpp-completion/ops/kv-cache-state.d.ts +1 -0
  95. package/dist/server/bare/plugins/llamacpp-completion/ops/kv-cache-state.js +2 -2
  96. package/dist/server/bare/plugins/llamacpp-completion/plugin.d.ts +6 -6
  97. package/dist/server/bare/plugins/llamacpp-completion/plugin.js +55 -36
  98. package/dist/server/bare/plugins/llamacpp-completion/transform.js +1 -7
  99. package/dist/server/bare/plugins/llamacpp-embedding/plugin.js +2 -3
  100. package/dist/server/bare/plugins/nmtcpp-translation/plugin.js +6 -5
  101. package/dist/server/bare/plugins/parakeet-transcription/plugin.js +27 -16
  102. package/dist/server/bare/plugins/tts-ggml/ops/parler-options.js +23 -3
  103. package/dist/server/bare/plugins/tts-ggml/plugin.d.ts +302 -4
  104. package/dist/server/bare/plugins/tts-ggml/plugin.js +131 -0
  105. package/dist/server/bare/plugins/whispercpp-transcription/plugin.js +48 -39
  106. package/dist/server/bare/registry/model-registry.d.ts +1 -0
  107. package/dist/server/bare/runtime/request-registry-singleton.js +29 -15
  108. package/dist/server/bare/runtime/request-registry.d.ts +27 -0
  109. package/dist/server/bare/runtime/request-registry.js +246 -76
  110. package/dist/server/bare/types/addon-responses.d.ts +4 -12
  111. package/dist/server/rpc/handlers/load-model/handler.js +2 -2
  112. package/dist/server/rpc/handlers/load-model/resolve-session.d.ts +1 -1
  113. package/dist/server/rpc/handlers/load-model/resolve-session.js +3 -3
  114. package/dist/server/rpc/handlers/load-model/resolve.d.ts +12 -2
  115. package/dist/server/rpc/handlers/load-model/resolve.js +90 -12
  116. package/dist/server/utils/audio/decoder.d.ts +37 -1
  117. package/dist/server/utils/audio/decoder.js +81 -51
  118. package/dist/server/utils/config-transform.d.ts +3 -0
  119. package/dist/server/utils/config-transform.js +6 -0
  120. package/dist/server/utils/index.d.ts +0 -1
  121. package/dist/server/utils/index.js +0 -1
  122. package/dist/server/utils/shard-utils.d.ts +1 -0
  123. package/dist/server/utils/shard-utils.js +14 -0
  124. package/dist/server/utils/tool-integration.d.ts +3 -10
  125. package/dist/server/utils/tool-integration.js +3 -12
  126. package/dist/utils/errors-server.d.ts +3 -0
  127. package/dist/utils/errors-server.js +5 -0
  128. package/package.json +12 -14
  129. package/dist/examples/llamacpp-dynamic-tools.d.ts +0 -2
  130. package/dist/examples/llamacpp-dynamic-tools.js +0 -152
  131. package/dist/models/update-models/codegen.d.ts +0 -3
  132. package/dist/models/update-models/codegen.js +0 -196
  133. package/dist/models/update-models/companions.d.ts +0 -30
  134. package/dist/models/update-models/companions.js +0 -296
  135. package/dist/models/update-models/history.d.ts +0 -24
  136. package/dist/models/update-models/history.js +0 -107
  137. package/dist/models/update-models/index.d.ts +0 -2
  138. package/dist/models/update-models/index.js +0 -123
  139. package/dist/models/update-models/naming.d.ts +0 -4
  140. package/dist/models/update-models/naming.js +0 -396
  141. package/dist/models/update-models/processing.d.ts +0 -8
  142. package/dist/models/update-models/processing.js +0 -65
  143. package/dist/models/update-models/registry.d.ts +0 -5
  144. package/dist/models/update-models/registry.js +0 -87
  145. package/dist/models/update-models/shards.d.ts +0 -4
  146. package/dist/models/update-models/shards.js +0 -57
  147. package/dist/models/update-models/types.d.ts +0 -88
  148. package/dist/models/update-models/types.js +0 -1
  149. package/dist/models/update-models/utils.d.ts +0 -3
  150. package/dist/models/update-models/utils.js +0 -21
  151. package/dist/server/bare/plugins/llamacpp-completion/ops/batch-cancelled.d.ts +0 -23
  152. package/dist/server/bare/plugins/llamacpp-completion/ops/batch-cancelled.js +0 -30
  153. package/dist/server/utils/expand-gguf-shards.d.ts +0 -3
  154. package/dist/server/utils/expand-gguf-shards.js +0 -22
@@ -10,42 +10,65 @@ export interface TurnHandle {
10
10
  * to pick the message tail for the next addon call.
11
11
  */
12
12
  readonly savedCount: number;
13
+ /**
14
+ * Whether the cached prefix already holds a rendered static tool block, so
15
+ * this turn can leave it out of its payload. False on a fresh prime and
16
+ * whenever the previous turn couldn't confirm the block reached the model.
17
+ */
18
+ readonly toolBlockCached: boolean;
13
19
  }
14
20
  export interface BeginCustomTurnInput {
15
21
  kind: 'custom';
16
22
  /** User-provided session key (`completion({ kvCache: "session-a" })`). */
17
23
  customKey: string;
18
- /** Hash of system prompt + (static) tool names. */
24
+ /** Hash of system prompt + complete tool definitions. */
19
25
  configHash: string;
20
26
  /**
21
- * Prime the cache by sending system prompt + (static) tools to the
22
- * addon. Called when the cache doesn't exist in-memory OR on disk.
23
- * Kept as an injected closure so this module has no dependency on the
24
- * model registry / addon — the handler closes over `model` and tools.
27
+ * Prime the cache by sending the system prompt to the addon. Tools are not
28
+ * primed — a prefix with no user turn is not a renderable conversation for
29
+ * every template — so they travel with a turn instead. Called when the cache
30
+ * doesn't exist in-memory OR on disk. Kept as an injected closure so this
31
+ * module has no dependency on the model registry / addon.
25
32
  */
26
33
  primeIfMissing: (cachePath: string) => Promise<void>;
34
+ /**
35
+ * Request abort signal. When it aborts while this turn is queued behind a
36
+ * same-file peer's write lock, the wait is abandoned so the request's scope
37
+ * unwinds and releases its admission slot instead of blocking on the holder.
38
+ */
39
+ signal?: AbortSignal;
27
40
  }
28
41
  export interface BeginAutoTurnInput {
29
42
  kind: 'auto';
30
- /** Hash of system prompt + (static) tool names. */
43
+ /** Hash of system prompt + complete tool definitions. */
31
44
  configHash: string;
32
45
  /** Conversation history used to compute the pre-response cache key. */
33
46
  history: CacheMessage[];
34
47
  /** See `BeginCustomTurnInput.primeIfMissing`. */
35
48
  primeIfMissing: (cachePath: string) => Promise<void>;
49
+ /** See `BeginCustomTurnInput.signal`. */
50
+ signal?: AbortSignal;
36
51
  }
37
52
  export type BeginTurnInput = BeginCustomTurnInput | BeginAutoTurnInput;
38
- export interface StaticCommitResult {
53
+ /**
54
+ * Whether the committed prefix holds a rendered static tool block. The
55
+ * handler owns this because only it knows whether the payload carried the
56
+ * block and whether the message list was one the template renders tools for.
57
+ */
58
+ interface ToolBlockCommit {
59
+ toolBlockCached: boolean;
60
+ }
61
+ export interface StaticCommitResult extends ToolBlockCommit {
39
62
  kind: 'static';
40
63
  /** `history.length + 1` — recorded at the turn's current `cachePath`. */
41
64
  messageCount: number;
42
65
  }
43
- export interface AutoRenameCommitResult {
66
+ export interface AutoRenameCommitResult extends ToolBlockCommit {
44
67
  kind: 'autoRename';
45
68
  /**
46
69
  * Destination path the addon's pre-response cache file should be
47
70
  * renamed to (computed from `cacheMessages + responseText`). The
48
- * stale entry at the source path is dropped from `cachedMessageCounts`
71
+ * stale entry at the source path is dropped from `cachedPrefixes`
49
72
  * and the new count is recorded at this target path.
50
73
  */
51
74
  targetCachePath: string;
@@ -74,7 +97,7 @@ export interface KvCacheSession {
74
97
  /**
75
98
  * Roll back an in-flight turn — atomically deletes the on-disk cache
76
99
  * file, clears the in-memory `initializedCaches` entry, forgets the
77
- * `cachedMessageCounts` entry, releases the active-path ref, and
100
+ * `cachedPrefixes` entry, releases the active-path ref, and
78
101
  * removes orphaned marker metadata. Idempotent: a turn that has
79
102
  * already been committed or rolled back is a no-op on subsequent
80
103
  * calls. Handlers register this via `ctx.scope.defer(...)` so it
@@ -116,19 +139,21 @@ export declare function createKvCacheSession(modelId: string, options?: {
116
139
  * Layers cleared, in order:
117
140
  * 1. On-disk: `deleteCache(...)` removes the matching directory
118
141
  * tree (or wipes and recreates the root for `all: true`).
119
- * 2. `cachedMessageCounts`: prefix-cleanup by the removed directory
142
+ * 2. `cachedPrefixes`: prefix-cleanup by the removed directory
120
143
  * so any per-cache count under the deleted tree is forgotten.
121
- * 3. `initializedCaches`: scope clear by `(kvCacheKey[, modelId])`,
122
- * matching the on-disk scope.
144
+ * 3. `initializedCaches`: prefix-cleanup by the same removed
145
+ * directory, since it is keyed by the resolved cache path.
123
146
  *
124
- * Concurrency with in-flight turns: this delete is wire-async with
125
- * respect to any turn currently holding a `TurnHandle` for the same
126
- * cache key. Worst case the on-disk `.bin` is removed while a turn is
127
- * mid-write; the turn's eventual `commitTurn(...)` then fails the
128
- * `verifySaveAndRecord` probe (file gone) and rolls back idempotently.
129
- * No coordination primitive is needed because every layer's mutation
130
- * is idempotent (`unlink` no-ops if missing, `Map.delete` / `Set.delete`
131
- * no-op on absent keys).
147
+ * Concurrency with in-flight turns: this delete does not take the
148
+ * per-cache-path write locks, so it races any turn holding a `TurnHandle`
149
+ * for the same key. Deleting a key that is in active use is unsupported.
150
+ * Each individual mutation is idempotent (`unlink` no-ops if missing,
151
+ * `Map.delete` / `Set.delete` no-op on absent keys), but the layers are
152
+ * cleared without a lock, so an interleaving that lands the delete's
153
+ * in-memory cleanup after a concurrent turn has already renamed/committed
154
+ * its file splits state: the file stays on disk while its saved-count and
155
+ * init flag are cleared, so the next turn sees the file, skips priming, and
156
+ * reports `savedCount=0`. Callers must not delete a key that is in active use.
132
157
  */
133
158
  export declare function deleteKvCacheState(target: {
134
159
  kvCacheKey: string;
@@ -148,8 +173,9 @@ export declare function deleteKvCacheState(target: {
148
173
  export declare const __kvCacheSessionTestHooks: {
149
174
  getSavedCount(cachePath: string): number | undefined;
150
175
  setSavedCountForTest(cachePath: string, count: number): void;
151
- hasInitializedKey(modelId: string, configHash: string, cacheKey: string): boolean;
152
- markInitializedForTest(modelId: string, configHash: string, cacheKey: string): void;
176
+ getToolBlockCachedForTest(cachePath: string): boolean;
177
+ hasInitializedPath(cachePath: string): boolean;
178
+ getActivePathCountForTest(cachePath: string): number;
153
179
  getLastAutoCacheSweepMsForTest(): number;
154
180
  setLastAutoCacheSweepMsForTest(value: number): void;
155
181
  resetForTest(): void;