@qvac/inference 0.21.0 → 0.22.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 (246) hide show
  1. package/NOTICE +50 -25
  2. package/README.md +44 -1
  3. package/dist/api/assess-model-fit.d.ts +4 -4
  4. package/dist/api/assess-model-fit.js +4 -4
  5. package/dist/api/audio-gen.d.ts +4 -1
  6. package/dist/api/audio-gen.js +4 -1
  7. package/dist/api/batch-completion.js +1 -1
  8. package/dist/api/completion-stream.js +1 -1
  9. package/dist/api/decide.d.ts +26 -0
  10. package/dist/api/decide.js +26 -0
  11. package/dist/api/get-model-info.d.ts +1 -1
  12. package/dist/api/index.d.ts +1 -0
  13. package/dist/api/index.js +1 -0
  14. package/dist/api/text-to-speech.d.ts +1 -0
  15. package/dist/api/text-to-speech.js +15 -19
  16. package/dist/api/transcribe.js +5 -2
  17. package/dist/api/video-request.d.ts +5 -5
  18. package/dist/api/video.d.ts +5 -4
  19. package/dist/api/video.js +5 -4
  20. package/dist/errors/index.d.ts +3 -0
  21. package/dist/errors/index.js +5 -0
  22. package/dist/handlers/assess-model-fit.d.ts +5 -3
  23. package/dist/handlers/assess-model-fit.js +80 -28
  24. package/dist/handlers/get-loaded-model-info.js +1 -2
  25. package/dist/handlers/load-model/safe-fetch.js +5 -6
  26. package/dist/handlers/registry.d.ts +3 -1
  27. package/dist/handlers/registry.js +3 -3
  28. package/dist/index.d.ts +1 -1
  29. package/dist/index.js +1 -1
  30. package/dist/logging/logger.js +1 -1
  31. package/dist/logging/utils.js +1 -1
  32. package/dist/models/registry/models.d.ts +563 -816
  33. package/dist/models/registry/models.js +2873 -3110
  34. package/dist/models/registry/resource-profiles.d.ts +1 -2
  35. package/dist/models/registry/resource-profiles.js +203 -2
  36. package/dist/plugins/builtin/asr-ggml/config.d.ts +7 -1
  37. package/dist/plugins/builtin/asr-ggml/config.js +6 -0
  38. package/dist/plugins/builtin/asr-ggml/logging.d.ts +1 -1
  39. package/dist/plugins/builtin/audiogen-ggml/config.d.ts +1 -0
  40. package/dist/plugins/builtin/audiogen-ggml/ops/audio-edit-stream.js +28 -10
  41. package/dist/plugins/builtin/audiogen-ggml/ops/audio-gen-input.d.ts +27 -0
  42. package/dist/plugins/builtin/audiogen-ggml/ops/audio-gen-input.js +23 -0
  43. package/dist/plugins/builtin/audiogen-ggml/ops/audio-gen-stream.js +6 -27
  44. package/dist/plugins/builtin/audiogen-ggml/plugin.d.ts +147 -60
  45. package/dist/plugins/builtin/audiogen-ggml/plugin.js +1 -0
  46. package/dist/plugins/builtin/bci-whispercpp-transcription/plugin.d.ts +40 -24
  47. package/dist/plugins/builtin/bci-whispercpp-transcription/plugin.js +1 -1
  48. package/dist/plugins/builtin/ggml-classification/plugin.d.ts +4 -4
  49. package/dist/plugins/builtin/ggml-ocr/params.d.ts +18 -0
  50. package/dist/plugins/builtin/ggml-ocr/params.js +37 -0
  51. package/dist/plugins/builtin/ggml-ocr/plugin.d.ts +18 -10
  52. package/dist/plugins/builtin/ggml-ocr/plugin.js +16 -38
  53. package/dist/plugins/builtin/ggml-vla/plugin.d.ts +21 -14
  54. package/dist/plugins/builtin/ggml-vla/plugin.js +1 -1
  55. package/dist/plugins/builtin/index.d.ts +2 -0
  56. package/dist/plugins/builtin/index.js +2 -0
  57. package/dist/plugins/builtin/llamacpp-completion/ops/completion-stream.d.ts +9 -7
  58. package/dist/plugins/builtin/llamacpp-completion/ops/completion-stream.js +109 -189
  59. package/dist/plugins/builtin/llamacpp-completion/ops/kv-cache-session.d.ts +32 -90
  60. package/dist/plugins/builtin/llamacpp-completion/ops/kv-cache-session.js +60 -211
  61. package/dist/plugins/builtin/llamacpp-completion/ops/kv-cache-state.d.ts +2 -49
  62. package/dist/plugins/builtin/llamacpp-completion/ops/kv-cache-state.js +2 -46
  63. package/dist/plugins/builtin/llamacpp-completion/plugin.d.ts +185 -87
  64. package/dist/plugins/builtin/llamacpp-completion/plugin.js +4 -5
  65. package/dist/plugins/builtin/llamacpp-completion/transform.js +1 -1
  66. package/dist/plugins/builtin/llamacpp-decision/helpers.d.ts +6 -0
  67. package/dist/plugins/builtin/llamacpp-decision/helpers.js +97 -0
  68. package/dist/plugins/builtin/llamacpp-decision/ops/decide.d.ts +91 -0
  69. package/dist/plugins/builtin/llamacpp-decision/ops/decide.js +129 -0
  70. package/dist/plugins/builtin/llamacpp-decision/plugin.d.ts +216 -0
  71. package/dist/plugins/builtin/llamacpp-decision/plugin.js +43 -0
  72. package/dist/plugins/builtin/llamacpp-embedding/plugin.d.ts +12 -5
  73. package/dist/plugins/builtin/llamacpp-embedding/plugin.js +1 -1
  74. package/dist/plugins/builtin/llamacpp-embedding/transform.js +3 -0
  75. package/dist/plugins/builtin/moss-transcribe/plugin.d.ts +143 -0
  76. package/dist/plugins/builtin/moss-transcribe/plugin.js +96 -0
  77. package/dist/plugins/builtin/nmtcpp-translation/load-files.d.ts +6 -0
  78. package/dist/plugins/builtin/nmtcpp-translation/load-files.js +70 -0
  79. package/dist/plugins/builtin/nmtcpp-translation/plugin.d.ts +25 -13
  80. package/dist/plugins/builtin/nmtcpp-translation/plugin.js +9 -73
  81. package/dist/plugins/builtin/parakeet-transcription/plugin.d.ts +52 -31
  82. package/dist/plugins/builtin/parakeet-transcription/plugin.js +18 -3
  83. package/dist/plugins/builtin/sdcpp-generation/ops/video.js +10 -6
  84. package/dist/plugins/builtin/sdcpp-generation/ops/world.d.ts +2 -2
  85. package/dist/plugins/builtin/sdcpp-generation/ops/world.js +1 -1
  86. package/dist/plugins/builtin/sdcpp-generation/plugin.d.ts +59 -33
  87. package/dist/plugins/builtin/sdcpp-generation/plugin.js +12 -9
  88. package/dist/plugins/builtin/tts-ggml/ops/moss-options.d.ts +22 -0
  89. package/dist/plugins/builtin/tts-ggml/ops/moss-options.js +79 -0
  90. package/dist/plugins/builtin/tts-ggml/ops/text-to-speech-stream.js +4 -1
  91. package/dist/plugins/builtin/tts-ggml/ops/text-to-speech.js +17 -5
  92. package/dist/plugins/builtin/tts-ggml/plugin.d.ts +164 -29
  93. package/dist/plugins/builtin/tts-ggml/plugin.js +38 -1
  94. package/dist/plugins/builtin/whispercpp-transcription/plugin.d.ts +58 -35
  95. package/dist/plugins/builtin/whispercpp-transcription/plugin.js +6 -2
  96. package/dist/plugins/ops/kv-cache-utils.d.ts +1 -1
  97. package/dist/plugins/ops/kv-cache-utils.js +10 -25
  98. package/dist/plugins/ops/load-model.js +21 -16
  99. package/dist/plugins/ops/transcribe.js +17 -1
  100. package/dist/registry.js +1 -0
  101. package/dist/resources/model-fit/assess.d.ts +15 -23
  102. package/dist/resources/model-fit/assess.js +207 -271
  103. package/dist/resources/model-fit/fit-stub/fetch-fit-stub.d.ts +3 -1
  104. package/dist/resources/model-fit/fit-stub/fetch-fit-stub.js +6 -1
  105. package/dist/resources/model-fit/fit-stub/project-fit-from-load.js +2 -0
  106. package/dist/resources/model-fit/fit-stub/resolve-load-from-stubs.d.ts +5 -3
  107. package/dist/resources/model-fit/fit-stub/resolve-load-from-stubs.js +9 -1
  108. package/dist/resources/model-fit/floor.d.ts +10 -10
  109. package/dist/resources/model-fit/floor.js +13 -13
  110. package/dist/resources/model-fit/kv-cache.d.ts +23 -0
  111. package/dist/resources/model-fit/kv-cache.js +85 -0
  112. package/dist/resources/model-fit/native-probe/advisory-fit.d.ts +11 -6
  113. package/dist/resources/model-fit/native-probe/advisory-fit.js +12 -27
  114. package/dist/resources/model-fit/native-probe/child-engine-fit.js +8 -0
  115. package/dist/resources/model-fit/native-probe/classify-fit.js +32 -1
  116. package/dist/resources/model-fit/native-probe/create-fit-request.d.ts +4 -1
  117. package/dist/resources/model-fit/native-probe/create-fit-request.js +24 -14
  118. package/dist/resources/model-fit/native-probe/engine-fit.d.ts +14 -0
  119. package/dist/resources/model-fit/native-probe/engine-fit.js +1 -1
  120. package/dist/resources/model-fit/native-probe/engines/asr.d.ts +4 -0
  121. package/dist/resources/model-fit/native-probe/engines/asr.js +23 -0
  122. package/dist/resources/model-fit/native-probe/engines/audiogen.js +29 -1
  123. package/dist/resources/model-fit/native-probe/engines/diffusion.js +16 -6
  124. package/dist/resources/model-fit/native-probe/engines/llama.d.ts +0 -1
  125. package/dist/resources/model-fit/native-probe/engines/llama.js +19 -123
  126. package/dist/resources/model-fit/native-probe/engines/nmt.d.ts +8 -0
  127. package/dist/resources/model-fit/native-probe/engines/nmt.js +11 -0
  128. package/dist/resources/model-fit/native-probe/engines/ocr.d.ts +9 -0
  129. package/dist/resources/model-fit/native-probe/engines/ocr.js +13 -0
  130. package/dist/resources/model-fit/native-probe/engines/tts.d.ts +2 -0
  131. package/dist/resources/model-fit/native-probe/engines/tts.js +49 -3
  132. package/dist/resources/model-fit/native-probe/run-in-process-fit.d.ts +5 -3
  133. package/dist/resources/model-fit/native-probe/run-in-process-fit.js +38 -23
  134. package/dist/resources/model-fit/platform.d.ts +4 -4
  135. package/dist/resources/model-fit/platform.js +6 -8
  136. package/dist/resources/model-fit/types.d.ts +3 -117
  137. package/dist/rpc/inventory.js +5 -7
  138. package/dist/runtime/env.d.ts +0 -2
  139. package/dist/runtime/env.js +2 -9
  140. package/dist/runtime/model-config-utils.js +6 -1
  141. package/dist/runtime/request-context.d.ts +1 -1
  142. package/dist/runtime/request-context.js +8 -0
  143. package/dist/runtime/state.js +5 -0
  144. package/dist/schemas/assess-model-fit.d.ts +100 -43
  145. package/dist/schemas/assess-model-fit.js +66 -29
  146. package/dist/schemas/audio-gen.d.ts +186 -18
  147. package/dist/schemas/audio-gen.js +180 -48
  148. package/dist/schemas/batch-completion-stream.d.ts +202 -34
  149. package/dist/schemas/bci-config.d.ts +2 -0
  150. package/dist/schemas/bci.d.ts +23 -2
  151. package/dist/schemas/cancel.d.ts +5 -0
  152. package/dist/schemas/cancel.js +1 -0
  153. package/dist/schemas/common.d.ts +1083 -158
  154. package/dist/schemas/common.js +5 -2
  155. package/dist/schemas/completion-stream.d.ts +232 -37
  156. package/dist/schemas/completion-stream.js +64 -20
  157. package/dist/schemas/config.d.ts +477 -12
  158. package/dist/schemas/config.js +21 -1
  159. package/dist/schemas/decision.d.ts +602 -0
  160. package/dist/schemas/decision.js +205 -0
  161. package/dist/schemas/download-asset.d.ts +7 -3
  162. package/dist/schemas/engine-addon-map.d.ts +7 -0
  163. package/dist/schemas/engine-addon-map.js +23 -3
  164. package/dist/schemas/errors.d.ts +1 -0
  165. package/dist/schemas/errors.js +5 -0
  166. package/dist/schemas/index.d.ts +2 -0
  167. package/dist/schemas/index.js +2 -0
  168. package/dist/schemas/llamacpp-config.d.ts +42 -2
  169. package/dist/schemas/llamacpp-config.js +27 -0
  170. package/dist/schemas/load-model.d.ts +5247 -1309
  171. package/dist/schemas/load-model.js +88 -9
  172. package/dist/schemas/model-config-schemas.d.ts +233 -8
  173. package/dist/schemas/model-config-schemas.js +4 -1
  174. package/dist/schemas/model-fit-policy.d.ts +17 -0
  175. package/dist/schemas/model-fit-policy.js +17 -0
  176. package/dist/schemas/model-info.d.ts +20 -2
  177. package/dist/schemas/model-info.js +2 -1
  178. package/dist/schemas/model-resource-profile.d.ts +3 -4
  179. package/dist/schemas/model-resource-profile.js +1 -4
  180. package/dist/schemas/model-src-utils.d.ts +10 -2
  181. package/dist/schemas/model-types.d.ts +10 -1
  182. package/dist/schemas/model-types.js +3 -0
  183. package/dist/schemas/ocr.d.ts +74 -0
  184. package/dist/schemas/ocr.js +42 -0
  185. package/dist/schemas/plugin.d.ts +8 -2
  186. package/dist/schemas/plugin.js +6 -0
  187. package/dist/schemas/profiling.d.ts +4 -4
  188. package/dist/schemas/registry.d.ts +26 -0
  189. package/dist/schemas/registry.js +3 -0
  190. package/dist/schemas/reload-config.d.ts +10 -2
  191. package/dist/schemas/rpc-server.js +3 -3
  192. package/dist/schemas/sdcpp-config.d.ts +26 -0
  193. package/dist/schemas/sdcpp-config.js +8 -7
  194. package/dist/schemas/system-resources.d.ts +4 -4
  195. package/dist/schemas/text-to-speech.d.ts +402 -3
  196. package/dist/schemas/text-to-speech.js +129 -11
  197. package/dist/schemas/tools.d.ts +13 -4
  198. package/dist/schemas/tools.js +18 -6
  199. package/dist/schemas/transcription-config.d.ts +15 -0
  200. package/dist/schemas/transcription-config.js +38 -3
  201. package/dist/schemas/transcription.d.ts +46 -4
  202. package/dist/schemas/transcription.js +51 -4
  203. package/dist/schemas/translation-config.d.ts +30 -10
  204. package/dist/schemas/vla.d.ts +9 -2
  205. package/dist/schemas/vla.js +9 -5
  206. package/dist/surface.d.ts +1 -1
  207. package/dist/surface.js +1 -1
  208. package/dist/utils/addon-responses.d.ts +1 -0
  209. package/dist/utils/asr-events.d.ts +1 -0
  210. package/dist/utils/asr-events.js +2 -1
  211. package/dist/utils/cache/types.d.ts +7 -0
  212. package/dist/utils/mcp-adapter.js +12 -8
  213. package/dist/utils/tool-helpers.d.ts +1 -1
  214. package/dist/utils/tool-helpers.js +20 -52
  215. package/dist/utils/tools/parsers/dsml.js +8 -5
  216. package/dist/utils/tools/parsers/qwen35.js +7 -4
  217. package/dist/utils/tools/shared.d.ts +3 -0
  218. package/dist/utils/tools/shared.js +62 -0
  219. package/dist/utils/transcribe-metadata.d.ts +8 -1
  220. package/dist/utils/transcribe-metadata.js +13 -3
  221. package/dist/utils/tts-stats.d.ts +1 -0
  222. package/package.json +41 -32
  223. package/dist/resources/model-fit/calibration/darwin-arm64.d.ts +0 -8
  224. package/dist/resources/model-fit/calibration/darwin-arm64.js +0 -36
  225. package/dist/resources/model-fit/calibration/darwin-x64.d.ts +0 -8
  226. package/dist/resources/model-fit/calibration/darwin-x64.js +0 -38
  227. package/dist/resources/model-fit/calibration/fit.d.ts +0 -73
  228. package/dist/resources/model-fit/calibration/fit.js +0 -152
  229. package/dist/resources/model-fit/calibration/index.d.ts +0 -37
  230. package/dist/resources/model-fit/calibration/index.js +0 -75
  231. package/dist/resources/model-fit/calibration/linux-arm64.d.ts +0 -8
  232. package/dist/resources/model-fit/calibration/linux-arm64.js +0 -38
  233. package/dist/resources/model-fit/calibration/linux-x64-vulkan.d.ts +0 -8
  234. package/dist/resources/model-fit/calibration/linux-x64-vulkan.js +0 -39
  235. package/dist/resources/model-fit/calibration/linux-x64.d.ts +0 -8
  236. package/dist/resources/model-fit/calibration/linux-x64.js +0 -38
  237. package/dist/resources/model-fit/calibration/win32-x64-vulkan-shared.d.ts +0 -8
  238. package/dist/resources/model-fit/calibration/win32-x64-vulkan-shared.js +0 -39
  239. package/dist/resources/model-fit/calibration/win32-x64-vulkan.d.ts +0 -8
  240. package/dist/resources/model-fit/calibration/win32-x64-vulkan.js +0 -36
  241. package/dist/resources/model-fit/calibration/win32-x64.d.ts +0 -8
  242. package/dist/resources/model-fit/calibration/win32-x64.js +0 -38
  243. package/dist/resources/model-fit/estimators/llm.d.ts +0 -46
  244. package/dist/resources/model-fit/estimators/llm.js +0 -222
  245. package/dist/resources/model-fit/estimators/whisper.d.ts +0 -10
  246. package/dist/resources/model-fit/estimators/whisper.js +0 -76
@@ -26,6 +26,7 @@ import { finetuneRequestSchema, finetuneResponseSchema, finetuneProgressResponse
26
26
  import { pluginInvokeRequestSchema, pluginInvokeResponseSchema, pluginInvokeStreamRequestSchema, pluginInvokeStreamResponseSchema } from './plugin.js';
27
27
  import { modelRegistryListRequestSchema, modelRegistryListResponseSchema, modelRegistrySearchRequestSchema, modelRegistrySearchResponseSchema, modelRegistryGetModelRequestSchema, modelRegistryGetModelResponseSchema } from './registry.js';
28
28
  import { suspendRequestSchema, suspendResponseSchema, resumeRequestSchema, resumeResponseSchema, stateRequestSchema, stateResponseSchema } from './lifecycle.js';
29
+ import { decideRequestSchema, decideResponseSchema } from './decision.js';
29
30
  import { classifyRequestSchema, classifyResponseSchema } from './classification.js';
30
31
  import { audioEditStreamRequestSchema, audioEditStreamResponseSchema, audioGenStreamRequestSchema, audioGenStreamResponseSchema, audioUnderstandRequestSchema, audioUnderstandResponseSchema } from './audio-gen.js';
31
32
  export const requestSchema = z.union([
@@ -74,7 +75,8 @@ export const requestSchema = z.union([
74
75
  suspendRequestSchema,
75
76
  resumeRequestSchema,
76
77
  stateRequestSchema,
77
- classifyRequestSchema
78
+ classifyRequestSchema,
79
+ decideRequestSchema
78
80
  ]);
79
81
  export const responseSchema = z.discriminatedUnion('type', [
80
82
  audioGenStreamResponseSchema,
@@ -126,7 +128,8 @@ export const responseSchema = z.discriminatedUnion('type', [
126
128
  suspendResponseSchema,
127
129
  resumeResponseSchema,
128
130
  stateResponseSchema,
129
- classifyResponseSchema
131
+ classifyResponseSchema,
132
+ decideResponseSchema
130
133
  ]);
131
134
  export const rpcOptionsSchema = z.object({
132
135
  timeout: z
@@ -15,9 +15,9 @@ export { completionStatsSchema, type CompletionStats } from './completion-event.
15
15
  * (DeepSeek Markup Language, emitted by DeepSeek V3.2 / V4)
16
16
  */
17
17
  export declare const toolDialectSchema: z.ZodEnum<{
18
+ json: "json";
18
19
  hermes: "hermes";
19
20
  pythonic: "pythonic";
20
- json: "json";
21
21
  harmony: "harmony";
22
22
  qwen35: "qwen35";
23
23
  gemma4: "gemma4";
@@ -36,14 +36,9 @@ export declare const generationParamsSchema: z.ZodObject<{
36
36
  presence_penalty: z.ZodOptional<z.ZodNumber>;
37
37
  repeat_penalty: z.ZodOptional<z.ZodNumber>;
38
38
  reasoning_budget: z.ZodOptional<z.ZodNumber>;
39
- remove_thinking_from_context: z.ZodOptional<z.ZodBoolean>;
40
39
  tool_choice: z.ZodOptional<z.ZodString>;
40
+ parallel_tool_calls: z.ZodOptional<z.ZodBoolean>;
41
41
  }, z.core.$strict>;
42
- /**
43
- * Whether a `tool_choice` demands a tool call (`required` or a named tool),
44
- * as opposed to `auto` / `none`, which only shape how the model may call one.
45
- */
46
- export declare function toolChoiceDemandsCall(toolChoice: string | undefined): boolean;
47
42
  type ToolChoiceTool = {
48
43
  type: 'function';
49
44
  name: string;
@@ -79,25 +74,132 @@ export declare const responseFormatSchema: z.ZodDiscriminatedUnion<[z.ZodObject<
79
74
  strict: z.ZodOptional<z.ZodBoolean>;
80
75
  }, z.core.$strict>;
81
76
  }, z.core.$strict>], "type">;
77
+ export declare const historyMessageSchema: z.ZodPipe<z.ZodObject<{
78
+ role: z.ZodString;
79
+ content: z.ZodOptional<z.ZodNullable<z.ZodString>>;
80
+ attachments: z.ZodOptional<z.ZodArray<z.ZodObject<{
81
+ path: z.ZodString;
82
+ }, z.core.$strip>>>;
83
+ toolCalls: z.ZodOptional<z.ZodArray<z.ZodObject<{
84
+ id: z.ZodOptional<z.ZodString>;
85
+ name: z.ZodString;
86
+ arguments: z.ZodRecord<z.ZodString, z.ZodUnknown>;
87
+ }, z.core.$strip>>>;
88
+ toolCallId: z.ZodOptional<z.ZodString>;
89
+ toolName: z.ZodOptional<z.ZodString>;
90
+ }, z.core.$strip>, z.ZodTransform<{
91
+ content: string;
92
+ role: string;
93
+ attachments?: {
94
+ path: string;
95
+ }[] | undefined;
96
+ toolCalls?: {
97
+ name: string;
98
+ arguments: Record<string, unknown>;
99
+ id?: string | undefined;
100
+ }[] | undefined;
101
+ toolCallId?: string | undefined;
102
+ toolName?: string | undefined;
103
+ }, {
104
+ role: string;
105
+ content?: string | null | undefined;
106
+ attachments?: {
107
+ path: string;
108
+ }[] | undefined;
109
+ toolCalls?: {
110
+ name: string;
111
+ arguments: Record<string, unknown>;
112
+ id?: string | undefined;
113
+ }[] | undefined;
114
+ toolCallId?: string | undefined;
115
+ toolName?: string | undefined;
116
+ }>>;
117
+ export type HistoryMessage = z.infer<typeof historyMessageSchema>;
82
118
  export declare const completionParamsSchema: z.ZodObject<{
83
- history: z.ZodArray<z.ZodObject<{
119
+ history: z.ZodArray<z.ZodPipe<z.ZodObject<{
84
120
  role: z.ZodString;
85
- content: z.ZodString;
121
+ content: z.ZodOptional<z.ZodNullable<z.ZodString>>;
86
122
  attachments: z.ZodOptional<z.ZodArray<z.ZodObject<{
87
123
  path: z.ZodString;
88
124
  }, z.core.$strip>>>;
89
- }, z.core.$strip>>;
125
+ toolCalls: z.ZodOptional<z.ZodArray<z.ZodObject<{
126
+ id: z.ZodOptional<z.ZodString>;
127
+ name: z.ZodString;
128
+ arguments: z.ZodRecord<z.ZodString, z.ZodUnknown>;
129
+ }, z.core.$strip>>>;
130
+ toolCallId: z.ZodOptional<z.ZodString>;
131
+ toolName: z.ZodOptional<z.ZodString>;
132
+ }, z.core.$strip>, z.ZodTransform<{
133
+ content: string;
134
+ role: string;
135
+ attachments?: {
136
+ path: string;
137
+ }[] | undefined;
138
+ toolCalls?: {
139
+ name: string;
140
+ arguments: Record<string, unknown>;
141
+ id?: string | undefined;
142
+ }[] | undefined;
143
+ toolCallId?: string | undefined;
144
+ toolName?: string | undefined;
145
+ }, {
146
+ role: string;
147
+ content?: string | null | undefined;
148
+ attachments?: {
149
+ path: string;
150
+ }[] | undefined;
151
+ toolCalls?: {
152
+ name: string;
153
+ arguments: Record<string, unknown>;
154
+ id?: string | undefined;
155
+ }[] | undefined;
156
+ toolCallId?: string | undefined;
157
+ toolName?: string | undefined;
158
+ }>>>;
90
159
  modelId: z.ZodString;
91
160
  kvCache: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodString]>>;
92
161
  }, z.core.$strip>;
93
162
  export declare const completionClientParamsSchema: z.ZodObject<{
94
- history: z.ZodArray<z.ZodObject<{
163
+ history: z.ZodArray<z.ZodPipe<z.ZodObject<{
95
164
  role: z.ZodString;
96
- content: z.ZodString;
165
+ content: z.ZodOptional<z.ZodNullable<z.ZodString>>;
97
166
  attachments: z.ZodOptional<z.ZodArray<z.ZodObject<{
98
167
  path: z.ZodString;
99
168
  }, z.core.$strip>>>;
100
- }, z.core.$strip>>;
169
+ toolCalls: z.ZodOptional<z.ZodArray<z.ZodObject<{
170
+ id: z.ZodOptional<z.ZodString>;
171
+ name: z.ZodString;
172
+ arguments: z.ZodRecord<z.ZodString, z.ZodUnknown>;
173
+ }, z.core.$strip>>>;
174
+ toolCallId: z.ZodOptional<z.ZodString>;
175
+ toolName: z.ZodOptional<z.ZodString>;
176
+ }, z.core.$strip>, z.ZodTransform<{
177
+ content: string;
178
+ role: string;
179
+ attachments?: {
180
+ path: string;
181
+ }[] | undefined;
182
+ toolCalls?: {
183
+ name: string;
184
+ arguments: Record<string, unknown>;
185
+ id?: string | undefined;
186
+ }[] | undefined;
187
+ toolCallId?: string | undefined;
188
+ toolName?: string | undefined;
189
+ }, {
190
+ role: string;
191
+ content?: string | null | undefined;
192
+ attachments?: {
193
+ path: string;
194
+ }[] | undefined;
195
+ toolCalls?: {
196
+ name: string;
197
+ arguments: Record<string, unknown>;
198
+ id?: string | undefined;
199
+ }[] | undefined;
200
+ toolCallId?: string | undefined;
201
+ toolName?: string | undefined;
202
+ }>>>;
101
203
  modelId: z.ZodString;
102
204
  tools: z.ZodOptional<z.ZodArray<z.ZodObject<{
103
205
  type: z.ZodLiteral<"function">;
@@ -108,19 +210,28 @@ export declare const completionClientParamsSchema: z.ZodObject<{
108
210
  parameters: z.ZodObject<{
109
211
  type: z.ZodLiteral<"object">;
110
212
  properties: z.ZodRecord<z.ZodString, z.ZodObject<{
111
- type: z.ZodEnum<{
213
+ type: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
112
214
  string: "string";
113
215
  number: "number";
114
216
  boolean: "boolean";
115
217
  object: "object";
218
+ null: "null";
116
219
  array: "array";
117
220
  integer: "integer";
118
- }>;
221
+ }>, z.ZodArray<z.ZodEnum<{
222
+ string: "string";
223
+ number: "number";
224
+ boolean: "boolean";
225
+ object: "object";
226
+ null: "null";
227
+ array: "array";
228
+ integer: "integer";
229
+ }>>]>>;
119
230
  description: z.ZodOptional<z.ZodString>;
120
231
  enum: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>>;
121
- }, z.core.$strip>>;
232
+ }, z.core.$loose>>;
122
233
  required: z.ZodOptional<z.ZodArray<z.ZodString>>;
123
- }, z.core.$strip>;
234
+ }, z.core.$loose>;
124
235
  }, z.core.$strip>>>;
125
236
  stream: z.ZodBoolean;
126
237
  kvCache: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodString]>>;
@@ -134,15 +245,15 @@ export declare const completionClientParamsSchema: z.ZodObject<{
134
245
  presence_penalty: z.ZodOptional<z.ZodNumber>;
135
246
  repeat_penalty: z.ZodOptional<z.ZodNumber>;
136
247
  reasoning_budget: z.ZodOptional<z.ZodNumber>;
137
- remove_thinking_from_context: z.ZodOptional<z.ZodBoolean>;
138
248
  tool_choice: z.ZodOptional<z.ZodString>;
249
+ parallel_tool_calls: z.ZodOptional<z.ZodBoolean>;
139
250
  }, z.core.$strict>>;
140
251
  captureThinking: z.ZodOptional<z.ZodBoolean>;
141
252
  emitRawDeltas: z.ZodOptional<z.ZodBoolean>;
142
253
  toolDialect: z.ZodOptional<z.ZodEnum<{
254
+ json: "json";
143
255
  hermes: "hermes";
144
256
  pythonic: "pythonic";
145
- json: "json";
146
257
  harmony: "harmony";
147
258
  qwen35: "qwen35";
148
259
  gemma4: "gemma4";
@@ -164,13 +275,46 @@ export declare const completionClientParamsSchema: z.ZodObject<{
164
275
  requestId: z.ZodOptional<z.ZodString>;
165
276
  }, z.core.$strip>;
166
277
  export declare const completionStreamRequestSchema: z.ZodObject<{
167
- history: z.ZodArray<z.ZodObject<{
278
+ history: z.ZodArray<z.ZodPipe<z.ZodObject<{
168
279
  role: z.ZodString;
169
- content: z.ZodString;
280
+ content: z.ZodOptional<z.ZodNullable<z.ZodString>>;
170
281
  attachments: z.ZodOptional<z.ZodArray<z.ZodObject<{
171
282
  path: z.ZodString;
172
283
  }, z.core.$strip>>>;
173
- }, z.core.$strip>>;
284
+ toolCalls: z.ZodOptional<z.ZodArray<z.ZodObject<{
285
+ id: z.ZodOptional<z.ZodString>;
286
+ name: z.ZodString;
287
+ arguments: z.ZodRecord<z.ZodString, z.ZodUnknown>;
288
+ }, z.core.$strip>>>;
289
+ toolCallId: z.ZodOptional<z.ZodString>;
290
+ toolName: z.ZodOptional<z.ZodString>;
291
+ }, z.core.$strip>, z.ZodTransform<{
292
+ content: string;
293
+ role: string;
294
+ attachments?: {
295
+ path: string;
296
+ }[] | undefined;
297
+ toolCalls?: {
298
+ name: string;
299
+ arguments: Record<string, unknown>;
300
+ id?: string | undefined;
301
+ }[] | undefined;
302
+ toolCallId?: string | undefined;
303
+ toolName?: string | undefined;
304
+ }, {
305
+ role: string;
306
+ content?: string | null | undefined;
307
+ attachments?: {
308
+ path: string;
309
+ }[] | undefined;
310
+ toolCalls?: {
311
+ name: string;
312
+ arguments: Record<string, unknown>;
313
+ id?: string | undefined;
314
+ }[] | undefined;
315
+ toolCallId?: string | undefined;
316
+ toolName?: string | undefined;
317
+ }>>>;
174
318
  modelId: z.ZodString;
175
319
  tools: z.ZodOptional<z.ZodArray<z.ZodObject<{
176
320
  type: z.ZodLiteral<"function">;
@@ -181,19 +325,28 @@ export declare const completionStreamRequestSchema: z.ZodObject<{
181
325
  parameters: z.ZodObject<{
182
326
  type: z.ZodLiteral<"object">;
183
327
  properties: z.ZodRecord<z.ZodString, z.ZodObject<{
184
- type: z.ZodEnum<{
328
+ type: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
329
+ string: "string";
330
+ number: "number";
331
+ boolean: "boolean";
332
+ object: "object";
333
+ null: "null";
334
+ array: "array";
335
+ integer: "integer";
336
+ }>, z.ZodArray<z.ZodEnum<{
185
337
  string: "string";
186
338
  number: "number";
187
339
  boolean: "boolean";
188
340
  object: "object";
341
+ null: "null";
189
342
  array: "array";
190
343
  integer: "integer";
191
- }>;
344
+ }>>]>>;
192
345
  description: z.ZodOptional<z.ZodString>;
193
346
  enum: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>>;
194
- }, z.core.$strip>>;
347
+ }, z.core.$loose>>;
195
348
  required: z.ZodOptional<z.ZodArray<z.ZodString>>;
196
- }, z.core.$strip>;
349
+ }, z.core.$loose>;
197
350
  }, z.core.$strip>>>;
198
351
  stream: z.ZodBoolean;
199
352
  kvCache: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodString]>>;
@@ -207,15 +360,15 @@ export declare const completionStreamRequestSchema: z.ZodObject<{
207
360
  presence_penalty: z.ZodOptional<z.ZodNumber>;
208
361
  repeat_penalty: z.ZodOptional<z.ZodNumber>;
209
362
  reasoning_budget: z.ZodOptional<z.ZodNumber>;
210
- remove_thinking_from_context: z.ZodOptional<z.ZodBoolean>;
211
363
  tool_choice: z.ZodOptional<z.ZodString>;
364
+ parallel_tool_calls: z.ZodOptional<z.ZodBoolean>;
212
365
  }, z.core.$strict>>;
213
366
  captureThinking: z.ZodOptional<z.ZodBoolean>;
214
367
  emitRawDeltas: z.ZodOptional<z.ZodBoolean>;
215
368
  toolDialect: z.ZodOptional<z.ZodEnum<{
369
+ json: "json";
216
370
  hermes: "hermes";
217
371
  pythonic: "pythonic";
218
- json: "json";
219
372
  harmony: "harmony";
220
373
  qwen35: "qwen35";
221
374
  gemma4: "gemma4";
@@ -316,13 +469,46 @@ export declare const completionStreamResponseSchema: z.ZodObject<{
316
469
  }, z.core.$strict>]>>;
317
470
  }, z.core.$strict>;
318
471
  export declare const completionOrchestrateRequestSchema: z.ZodObject<{
319
- history: z.ZodArray<z.ZodObject<{
472
+ history: z.ZodArray<z.ZodPipe<z.ZodObject<{
320
473
  role: z.ZodString;
321
- content: z.ZodString;
474
+ content: z.ZodOptional<z.ZodNullable<z.ZodString>>;
322
475
  attachments: z.ZodOptional<z.ZodArray<z.ZodObject<{
323
476
  path: z.ZodString;
324
477
  }, z.core.$strip>>>;
325
- }, z.core.$strip>>;
478
+ toolCalls: z.ZodOptional<z.ZodArray<z.ZodObject<{
479
+ id: z.ZodOptional<z.ZodString>;
480
+ name: z.ZodString;
481
+ arguments: z.ZodRecord<z.ZodString, z.ZodUnknown>;
482
+ }, z.core.$strip>>>;
483
+ toolCallId: z.ZodOptional<z.ZodString>;
484
+ toolName: z.ZodOptional<z.ZodString>;
485
+ }, z.core.$strip>, z.ZodTransform<{
486
+ content: string;
487
+ role: string;
488
+ attachments?: {
489
+ path: string;
490
+ }[] | undefined;
491
+ toolCalls?: {
492
+ name: string;
493
+ arguments: Record<string, unknown>;
494
+ id?: string | undefined;
495
+ }[] | undefined;
496
+ toolCallId?: string | undefined;
497
+ toolName?: string | undefined;
498
+ }, {
499
+ role: string;
500
+ content?: string | null | undefined;
501
+ attachments?: {
502
+ path: string;
503
+ }[] | undefined;
504
+ toolCalls?: {
505
+ name: string;
506
+ arguments: Record<string, unknown>;
507
+ id?: string | undefined;
508
+ }[] | undefined;
509
+ toolCallId?: string | undefined;
510
+ toolName?: string | undefined;
511
+ }>>>;
326
512
  modelId: z.ZodString;
327
513
  tools: z.ZodOptional<z.ZodArray<z.ZodObject<{
328
514
  type: z.ZodLiteral<"function">;
@@ -333,19 +519,28 @@ export declare const completionOrchestrateRequestSchema: z.ZodObject<{
333
519
  parameters: z.ZodObject<{
334
520
  type: z.ZodLiteral<"object">;
335
521
  properties: z.ZodRecord<z.ZodString, z.ZodObject<{
336
- type: z.ZodEnum<{
522
+ type: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
523
+ string: "string";
524
+ number: "number";
525
+ boolean: "boolean";
526
+ object: "object";
527
+ null: "null";
528
+ array: "array";
529
+ integer: "integer";
530
+ }>, z.ZodArray<z.ZodEnum<{
337
531
  string: "string";
338
532
  number: "number";
339
533
  boolean: "boolean";
340
534
  object: "object";
535
+ null: "null";
341
536
  array: "array";
342
537
  integer: "integer";
343
- }>;
538
+ }>>]>>;
344
539
  description: z.ZodOptional<z.ZodString>;
345
540
  enum: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>>;
346
- }, z.core.$strip>>;
541
+ }, z.core.$loose>>;
347
542
  required: z.ZodOptional<z.ZodArray<z.ZodString>>;
348
- }, z.core.$strip>;
543
+ }, z.core.$loose>;
349
544
  }, z.core.$strip>>>;
350
545
  stream: z.ZodBoolean;
351
546
  kvCache: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodString]>>;
@@ -359,15 +554,15 @@ export declare const completionOrchestrateRequestSchema: z.ZodObject<{
359
554
  presence_penalty: z.ZodOptional<z.ZodNumber>;
360
555
  repeat_penalty: z.ZodOptional<z.ZodNumber>;
361
556
  reasoning_budget: z.ZodOptional<z.ZodNumber>;
362
- remove_thinking_from_context: z.ZodOptional<z.ZodBoolean>;
363
557
  tool_choice: z.ZodOptional<z.ZodString>;
558
+ parallel_tool_calls: z.ZodOptional<z.ZodBoolean>;
364
559
  }, z.core.$strict>>;
365
560
  captureThinking: z.ZodOptional<z.ZodBoolean>;
366
561
  emitRawDeltas: z.ZodOptional<z.ZodBoolean>;
367
562
  toolDialect: z.ZodOptional<z.ZodEnum<{
563
+ json: "json";
368
564
  hermes: "hermes";
369
565
  pythonic: "pythonic";
370
- json: "json";
371
566
  harmony: "harmony";
372
567
  qwen35: "qwen35";
373
568
  gemma4: "gemma4";
@@ -62,25 +62,18 @@ export const generationParamsSchema = z
62
62
  .max(REASONING_BUDGET_MAX)
63
63
  .optional()
64
64
  .describe("Per-request reasoning channel budget. `-1` keeps the model's reasoning channel on; `0` disables it for this request; any positive integer caps the reasoning channel at that many tokens. Equivalent to the load-time `reasoning_budget` config but scoped to a single `run()` call; the prior value is restored afterwards."),
65
- remove_thinking_from_context: z
66
- .boolean()
67
- .optional()
68
- .describe('When the model emits a reasoning block during generation (e.g. `<think>...</think>` for the Qwen3 family, `<|channel>thought ... <channel|>` for Gemma 4), drop those tokens from the KV cache at end-of-generation so subsequent turns do not accumulate reasoning history. Defaults to `false`, except the Qwen3 reasoning family (Qwen3, Qwen3.5, Qwen3.6, including MoE variants), which defaults to `true`. No-op for models without a recognised reasoning channel. Supported on recurrent / hybrid-SSM models (e.g. Qwen3.5) via a state snapshot and replay when the reasoning close marker is a single token; on such a model with a multi-token close marker, enabling this fails with an error.'),
69
65
  tool_choice: z
70
66
  .string()
71
67
  .min(1)
72
68
  .optional()
73
- .describe('Controls tool calling for a request that declares `tools`, in the OpenAI style. `"auto"` (default) lets the model decide and constrains output to the tool-call grammar only once it starts a call; `"required"` forces a tool call; `"none"` leaves the tool definitions in the prompt but disables the tool-call grammar; any other value names one declared tool and forces a call to it. `"required"` and a tool name are rejected when the request declares no tools, and fail the request rather than answering in prose when the model cannot honour them. Only honoured by llama.cpp-backed models; other backends ignore it.')
69
+ .describe('Controls tool calling for a request that declares `tools`, in the OpenAI style. `"auto"` (default) lets the model decide and constrains output to the tool-call grammar only once it starts a call; `"required"` forces a tool call; `"none"` leaves the tool definitions in the prompt but disables the tool-call grammar; any other value names one declared tool and forces a call to it. `"required"` and a tool name are rejected when the request declares no tools, and fail the request rather than answering in prose when the model cannot honour them. Only honoured by llama.cpp-backed models; other backends ignore it.'),
70
+ parallel_tool_calls: z
71
+ .boolean()
72
+ .optional()
73
+ .describe('Whether one response may carry more than one tool call. `true` lets the chat template and tool-call grammar accept several; unset or `false` keeps one. Only honoured by llama.cpp-backed models; other backends ignore it.')
74
74
  })
75
75
  .strict();
76
76
  const TOOL_CHOICE_MODES = new Set(['auto', 'none', 'required']);
77
- /**
78
- * Whether a `tool_choice` demands a tool call (`required` or a named tool),
79
- * as opposed to `auto` / `none`, which only shape how the model may call one.
80
- */
81
- export function toolChoiceDemandsCall(toolChoice) {
82
- return toolChoice !== undefined && toolChoice !== 'auto' && toolChoice !== 'none';
83
- }
84
77
  export function refineToolChoiceMatchesTools(data, ctx) {
85
78
  const toolChoice = data.generationParams?.tool_choice;
86
79
  if (toolChoice === undefined || TOOL_CHOICE_MODES.has(toolChoice)) {
@@ -161,16 +154,67 @@ export const responseFormatSchema = z.discriminatedUnion('type', [
161
154
  })
162
155
  .strict()
163
156
  ]);
157
+ const historyToolCallSchema = z.object({
158
+ id: z.string().optional().describe('Call id, echoed by the `tool` message that answers it.'),
159
+ name: z.string().min(1).describe('Name of the tool that was called.'),
160
+ arguments: z.record(z.string(), z.unknown()).describe('Arguments the tool was called with.')
161
+ });
162
+ export const historyMessageSchema = z
163
+ .object({
164
+ role: z
165
+ .string()
166
+ .describe('Message role (e.g., `"user"`, `"assistant"`, `"system"`, `"tool"`).'),
167
+ content: z
168
+ .string()
169
+ .nullish()
170
+ .describe('Message content. May be `null` or omitted only on an `assistant` turn that carries `toolCalls`, as OpenAI histories send it; it then reads as an empty string.'),
171
+ attachments: z
172
+ .array(attachmentSchema)
173
+ .optional()
174
+ .describe('Optional file attachments for multimodal models.'),
175
+ toolCalls: z
176
+ .array(historyToolCallSchema)
177
+ .optional()
178
+ .describe("Tool calls an `assistant` turn made. Rendered by llama.cpp-backed models' chat templates in their own tool-call format; `content` may be empty."),
179
+ toolCallId: z
180
+ .string()
181
+ .optional()
182
+ .describe('On a `tool` turn: the id of the call this result answers.'),
183
+ toolName: z
184
+ .string()
185
+ .optional()
186
+ .describe('On a `tool` turn: the name of the tool that produced the result.')
187
+ })
188
+ .superRefine((message, ctx) => {
189
+ const callsOnly = message.role === 'assistant' && (message.toolCalls?.length ?? 0) > 0;
190
+ if ((message.content === null || message.content === undefined) && !callsOnly) {
191
+ ctx.addIssue({
192
+ code: 'custom',
193
+ message: '`content` is required unless an assistant message carries `toolCalls`.',
194
+ path: ['content']
195
+ });
196
+ }
197
+ if (message.toolCalls !== undefined && message.role !== 'assistant') {
198
+ ctx.addIssue({
199
+ code: 'custom',
200
+ message: '`toolCalls` is only valid on an assistant message.',
201
+ path: ['toolCalls']
202
+ });
203
+ }
204
+ for (const key of ['toolCallId', 'toolName']) {
205
+ if (message[key] !== undefined && message.role !== 'tool') {
206
+ ctx.addIssue({
207
+ code: 'custom',
208
+ message: `\`${key}\` is only valid on a tool message.`,
209
+ path: [key]
210
+ });
211
+ }
212
+ }
213
+ })
214
+ .transform((message) => ({ ...message, content: message.content ?? '' }));
164
215
  export const completionParamsSchema = z.object({
165
216
  history: z
166
- .array(z.object({
167
- role: z.string().describe('Message role (e.g., `"user"`, `"assistant"`, `"system"`).'),
168
- content: z.string().describe('Message content.'),
169
- attachments: z
170
- .array(attachmentSchema)
171
- .optional()
172
- .describe('Optional file attachments for multimodal models.')
173
- }))
217
+ .array(historyMessageSchema)
174
218
  .describe('Array of conversation messages sent to the model.'),
175
219
  modelId: z.string().describe('The identifier of the model to use for completion.'),
176
220
  kvCache: kvCacheSchema