@copilotkit/aimock 1.44.0 → 1.45.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 (272) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/CHANGELOG.md +31 -0
  4. package/README.md +6 -0
  5. package/dist/agui-types.d.ts.map +1 -1
  6. package/dist/aimock-cli.cjs +31 -5
  7. package/dist/aimock-cli.cjs.map +1 -1
  8. package/dist/aimock-cli.d.cts.map +1 -1
  9. package/dist/aimock-cli.d.ts.map +1 -1
  10. package/dist/aimock-cli.js +31 -5
  11. package/dist/aimock-cli.js.map +1 -1
  12. package/dist/bedrock-converse.cjs +312 -39
  13. package/dist/bedrock-converse.cjs.map +1 -1
  14. package/dist/bedrock-converse.d.cts.map +1 -1
  15. package/dist/bedrock-converse.d.ts.map +1 -1
  16. package/dist/bedrock-converse.js +313 -40
  17. package/dist/bedrock-converse.js.map +1 -1
  18. package/dist/bedrock.cjs +195 -42
  19. package/dist/bedrock.cjs.map +1 -1
  20. package/dist/bedrock.d.cts.map +1 -1
  21. package/dist/bedrock.d.ts.map +1 -1
  22. package/dist/bedrock.js +196 -43
  23. package/dist/bedrock.js.map +1 -1
  24. package/dist/chaos.cjs +1 -0
  25. package/dist/chaos.js +1 -1
  26. package/dist/cli.cjs +152 -5
  27. package/dist/cli.cjs.map +1 -1
  28. package/dist/cli.js +155 -8
  29. package/dist/cli.js.map +1 -1
  30. package/dist/cohere.cjs +132 -71
  31. package/dist/cohere.cjs.map +1 -1
  32. package/dist/cohere.d.cts.map +1 -1
  33. package/dist/cohere.d.ts.map +1 -1
  34. package/dist/cohere.js +133 -72
  35. package/dist/cohere.js.map +1 -1
  36. package/dist/config-loader.cjs +62 -4
  37. package/dist/config-loader.cjs.map +1 -1
  38. package/dist/config-loader.d.cts +37 -4
  39. package/dist/config-loader.d.cts.map +1 -1
  40. package/dist/config-loader.d.ts +37 -4
  41. package/dist/config-loader.d.ts.map +1 -1
  42. package/dist/config-loader.js +62 -4
  43. package/dist/config-loader.js.map +1 -1
  44. package/dist/fakes-plugin.cjs +131 -0
  45. package/dist/fakes-plugin.cjs.map +1 -0
  46. package/dist/fakes-plugin.d.cts +23 -0
  47. package/dist/fakes-plugin.d.cts.map +1 -0
  48. package/dist/fakes-plugin.d.ts +23 -0
  49. package/dist/fakes-plugin.d.ts.map +1 -0
  50. package/dist/fakes-plugin.js +127 -0
  51. package/dist/fakes-plugin.js.map +1 -0
  52. package/dist/fixture-loader-services.cjs +1 -1
  53. package/dist/fixture-loader-services.cjs.map +1 -1
  54. package/dist/fixture-loader-services.js +1 -1
  55. package/dist/fixture-loader-services.js.map +1 -1
  56. package/dist/fixture-loader.cjs +389 -27
  57. package/dist/fixture-loader.cjs.map +1 -1
  58. package/dist/fixture-loader.d.cts +47 -3
  59. package/dist/fixture-loader.d.cts.map +1 -1
  60. package/dist/fixture-loader.d.ts +47 -3
  61. package/dist/fixture-loader.d.ts.map +1 -1
  62. package/dist/fixture-loader.js +384 -29
  63. package/dist/fixture-loader.js.map +1 -1
  64. package/dist/gemini-interactions.cjs +250 -52
  65. package/dist/gemini-interactions.cjs.map +1 -1
  66. package/dist/gemini-interactions.d.cts.map +1 -1
  67. package/dist/gemini-interactions.d.ts.map +1 -1
  68. package/dist/gemini-interactions.js +251 -53
  69. package/dist/gemini-interactions.js.map +1 -1
  70. package/dist/gemini.cjs +226 -37
  71. package/dist/gemini.cjs.map +1 -1
  72. package/dist/gemini.d.cts.map +1 -1
  73. package/dist/gemini.d.ts.map +1 -1
  74. package/dist/gemini.js +227 -38
  75. package/dist/gemini.js.map +1 -1
  76. package/dist/helpers.cjs +881 -7
  77. package/dist/helpers.cjs.map +1 -1
  78. package/dist/helpers.d.cts +85 -4
  79. package/dist/helpers.d.cts.map +1 -1
  80. package/dist/helpers.d.ts +85 -4
  81. package/dist/helpers.d.ts.map +1 -1
  82. package/dist/helpers.js +839 -8
  83. package/dist/helpers.js.map +1 -1
  84. package/dist/index.cjs +9 -0
  85. package/dist/index.d.cts +7 -5
  86. package/dist/index.d.ts +7 -5
  87. package/dist/index.js +4 -3
  88. package/dist/jest.cjs +31 -7
  89. package/dist/jest.cjs.map +1 -1
  90. package/dist/jest.d.cts +43 -3
  91. package/dist/jest.d.cts.map +1 -1
  92. package/dist/jest.d.ts +43 -3
  93. package/dist/jest.d.ts.map +1 -1
  94. package/dist/jest.js +33 -9
  95. package/dist/jest.js.map +1 -1
  96. package/dist/journal.cjs +135 -13
  97. package/dist/journal.cjs.map +1 -1
  98. package/dist/journal.d.cts +38 -4
  99. package/dist/journal.d.cts.map +1 -1
  100. package/dist/journal.d.ts +38 -4
  101. package/dist/journal.d.ts.map +1 -1
  102. package/dist/journal.js +135 -13
  103. package/dist/journal.js.map +1 -1
  104. package/dist/live-sanitize.cjs +4 -32
  105. package/dist/live-sanitize.cjs.map +1 -1
  106. package/dist/live-sanitize.js +4 -32
  107. package/dist/live-sanitize.js.map +1 -1
  108. package/dist/llmock.cjs +123 -30
  109. package/dist/llmock.cjs.map +1 -1
  110. package/dist/llmock.d.cts +16 -1
  111. package/dist/llmock.d.cts.map +1 -1
  112. package/dist/llmock.d.ts +16 -1
  113. package/dist/llmock.d.ts.map +1 -1
  114. package/dist/llmock.js +125 -32
  115. package/dist/llmock.js.map +1 -1
  116. package/dist/mcp-fakes-mount.cjs +1 -0
  117. package/dist/mcp-fakes-mount.cjs.map +1 -1
  118. package/dist/mcp-fakes-mount.js +1 -0
  119. package/dist/mcp-fakes-mount.js.map +1 -1
  120. package/dist/mcp-fakes-report.cjs +111 -0
  121. package/dist/mcp-fakes-report.cjs.map +1 -0
  122. package/dist/mcp-fakes-report.d.cts +40 -0
  123. package/dist/mcp-fakes-report.d.cts.map +1 -0
  124. package/dist/mcp-fakes-report.d.ts +40 -0
  125. package/dist/mcp-fakes-report.d.ts.map +1 -0
  126. package/dist/mcp-fakes-report.js +107 -0
  127. package/dist/mcp-fakes-report.js.map +1 -0
  128. package/dist/mcp-fakes.cjs +331 -8
  129. package/dist/mcp-fakes.cjs.map +1 -1
  130. package/dist/mcp-fakes.d.cts +406 -3
  131. package/dist/mcp-fakes.d.cts.map +1 -1
  132. package/dist/mcp-fakes.d.ts +406 -3
  133. package/dist/mcp-fakes.d.ts.map +1 -1
  134. package/dist/mcp-fakes.js +331 -8
  135. package/dist/mcp-fakes.js.map +1 -1
  136. package/dist/mcp-handler.cjs +209 -16
  137. package/dist/mcp-handler.cjs.map +1 -1
  138. package/dist/mcp-handler.d.cts +49 -0
  139. package/dist/mcp-handler.d.cts.map +1 -0
  140. package/dist/mcp-handler.d.ts +49 -0
  141. package/dist/mcp-handler.d.ts.map +1 -0
  142. package/dist/mcp-handler.js +207 -17
  143. package/dist/mcp-handler.js.map +1 -1
  144. package/dist/mcp-mock.cjs +112 -1
  145. package/dist/mcp-mock.cjs.map +1 -1
  146. package/dist/mcp-mock.d.cts +33 -2
  147. package/dist/mcp-mock.d.cts.map +1 -1
  148. package/dist/mcp-mock.d.ts +33 -2
  149. package/dist/mcp-mock.d.ts.map +1 -1
  150. package/dist/mcp-mock.js +112 -1
  151. package/dist/mcp-mock.js.map +1 -1
  152. package/dist/mcp-recorder.cjs +1224 -0
  153. package/dist/mcp-recorder.cjs.map +1 -0
  154. package/dist/mcp-recorder.d.cts +108 -0
  155. package/dist/mcp-recorder.d.cts.map +1 -0
  156. package/dist/mcp-recorder.d.ts +108 -0
  157. package/dist/mcp-recorder.d.ts.map +1 -0
  158. package/dist/mcp-recorder.js +1215 -0
  159. package/dist/mcp-recorder.js.map +1 -0
  160. package/dist/messages.cjs +362 -56
  161. package/dist/messages.cjs.map +1 -1
  162. package/dist/messages.d.cts.map +1 -1
  163. package/dist/messages.d.ts.map +1 -1
  164. package/dist/messages.js +363 -58
  165. package/dist/messages.js.map +1 -1
  166. package/dist/misbehavior.cjs +1523 -0
  167. package/dist/misbehavior.cjs.map +1 -0
  168. package/dist/misbehavior.d.cts +43 -0
  169. package/dist/misbehavior.d.cts.map +1 -0
  170. package/dist/misbehavior.d.ts +43 -0
  171. package/dist/misbehavior.d.ts.map +1 -0
  172. package/dist/misbehavior.js +1511 -0
  173. package/dist/misbehavior.js.map +1 -0
  174. package/dist/ollama.cjs +310 -112
  175. package/dist/ollama.cjs.map +1 -1
  176. package/dist/ollama.d.cts.map +1 -1
  177. package/dist/ollama.d.ts.map +1 -1
  178. package/dist/ollama.js +311 -113
  179. package/dist/ollama.js.map +1 -1
  180. package/dist/record-sanitize.cjs +231 -0
  181. package/dist/record-sanitize.cjs.map +1 -0
  182. package/dist/record-sanitize.js +224 -0
  183. package/dist/record-sanitize.js.map +1 -0
  184. package/dist/recorder.cjs +106 -5
  185. package/dist/recorder.cjs.map +1 -1
  186. package/dist/recorder.d.cts +2 -1
  187. package/dist/recorder.d.cts.map +1 -1
  188. package/dist/recorder.d.ts +2 -1
  189. package/dist/recorder.d.ts.map +1 -1
  190. package/dist/recorder.js +107 -7
  191. package/dist/recorder.js.map +1 -1
  192. package/dist/responses.cjs +667 -171
  193. package/dist/responses.cjs.map +1 -1
  194. package/dist/responses.d.cts +5 -13
  195. package/dist/responses.d.cts.map +1 -1
  196. package/dist/responses.d.ts +5 -13
  197. package/dist/responses.d.ts.map +1 -1
  198. package/dist/responses.js +665 -174
  199. package/dist/responses.js.map +1 -1
  200. package/dist/router.cjs +24 -2
  201. package/dist/router.cjs.map +1 -1
  202. package/dist/router.d.cts.map +1 -1
  203. package/dist/router.d.ts.map +1 -1
  204. package/dist/router.js +25 -4
  205. package/dist/router.js.map +1 -1
  206. package/dist/server.cjs +572 -76
  207. package/dist/server.cjs.map +1 -1
  208. package/dist/server.d.cts.map +1 -1
  209. package/dist/server.d.ts.map +1 -1
  210. package/dist/server.js +574 -78
  211. package/dist/server.js.map +1 -1
  212. package/dist/stream-collapse.cjs +236 -34
  213. package/dist/stream-collapse.cjs.map +1 -1
  214. package/dist/stream-collapse.d.cts +39 -4
  215. package/dist/stream-collapse.d.cts.map +1 -1
  216. package/dist/stream-collapse.d.ts +39 -4
  217. package/dist/stream-collapse.d.ts.map +1 -1
  218. package/dist/stream-collapse.js +235 -35
  219. package/dist/stream-collapse.js.map +1 -1
  220. package/dist/types.cjs.map +1 -1
  221. package/dist/types.d.cts +315 -4
  222. package/dist/types.d.cts.map +1 -1
  223. package/dist/types.d.ts +315 -4
  224. package/dist/types.d.ts.map +1 -1
  225. package/dist/types.js.map +1 -1
  226. package/dist/validate-cli.cjs +36 -4
  227. package/dist/validate-cli.cjs.map +1 -1
  228. package/dist/validate-cli.js +37 -5
  229. package/dist/validate-cli.js.map +1 -1
  230. package/dist/vector-types.d.ts.map +1 -1
  231. package/dist/version.cjs +45 -0
  232. package/dist/version.cjs.map +1 -0
  233. package/dist/version.js +44 -0
  234. package/dist/version.js.map +1 -0
  235. package/dist/vitest.cjs +66 -10
  236. package/dist/vitest.cjs.map +1 -1
  237. package/dist/vitest.d.cts +35 -4
  238. package/dist/vitest.d.cts.map +1 -1
  239. package/dist/vitest.d.ts +35 -4
  240. package/dist/vitest.d.ts.map +1 -1
  241. package/dist/vitest.js +67 -11
  242. package/dist/vitest.js.map +1 -1
  243. package/dist/watcher.cjs +6 -2
  244. package/dist/watcher.cjs.map +1 -1
  245. package/dist/watcher.js +6 -2
  246. package/dist/watcher.js.map +1 -1
  247. package/dist/ws-gemini-live.cjs +210 -101
  248. package/dist/ws-gemini-live.cjs.map +1 -1
  249. package/dist/ws-gemini-live.d.cts +9 -3
  250. package/dist/ws-gemini-live.d.cts.map +1 -1
  251. package/dist/ws-gemini-live.d.ts +9 -3
  252. package/dist/ws-gemini-live.d.ts.map +1 -1
  253. package/dist/ws-gemini-live.js +211 -102
  254. package/dist/ws-gemini-live.js.map +1 -1
  255. package/dist/ws-realtime.cjs +175 -62
  256. package/dist/ws-realtime.cjs.map +1 -1
  257. package/dist/ws-realtime.d.cts +8 -3
  258. package/dist/ws-realtime.d.cts.map +1 -1
  259. package/dist/ws-realtime.d.ts +8 -3
  260. package/dist/ws-realtime.d.ts.map +1 -1
  261. package/dist/ws-realtime.js +176 -63
  262. package/dist/ws-realtime.js.map +1 -1
  263. package/dist/ws-responses.cjs +109 -16
  264. package/dist/ws-responses.cjs.map +1 -1
  265. package/dist/ws-responses.d.cts +8 -12
  266. package/dist/ws-responses.d.cts.map +1 -1
  267. package/dist/ws-responses.d.ts +8 -12
  268. package/dist/ws-responses.d.ts.map +1 -1
  269. package/dist/ws-responses.js +111 -18
  270. package/dist/ws-responses.js.map +1 -1
  271. package/package.json +10 -2
  272. package/skills/write-fixtures/SKILL.md +179 -21
@@ -1,9 +1,60 @@
1
1
  import { LiveFixtureResponse } from "./live-types.cjs";
2
- import { AudioResponse, ChatCompletion, ChatCompletionRequest, ContentWithToolCallsResponse, EmbeddingResponse, ErrorResponse, FixtureBlock, FixtureFileBlock, FixtureResponse, ImageResponse, ResponseOverrides, SSEChunk, TextResponse, ToolCall, ToolCallResponse, TranscriptionResponse, VideoResponse } from "./types.cjs";
2
+ import { AudioResponse, ChatCompletion, ChatCompletionRequest, ContentWithToolCallsResponse, EmbeddingResponse, ErrorResponse, FixtureBlock, FixtureFileBlock, FixtureFileResponsesBlock, FixtureResponse, ImageResponse, ResponseOverrides, ResponsesFixtureBlock, SSEChunk, TextResponse, ToolCall, ToolCallResponse, TranscriptionResponse, VideoResponse } from "./types.cjs";
3
3
  import * as http$1 from "node:http";
4
4
 
5
5
  //#region src/helpers.d.ts
6
6
 
7
+ /**
8
+ * A custom (freeform) tool call reached a wire that has no faithful projection
9
+ * for it. Only the OpenAI Responses API (HTTP and WebSocket) emits custom tool
10
+ * calls, from a fixture's `customToolCalls` or a `customToolCall` block in its
11
+ * `responsesBlocks`. The handlers of the other wires raise this through
12
+ * {@link rejectResponsesOnlyToolCalls} (usually via
13
+ * {@link requireEmittedFunctionToolCalls}) before they write any content.
14
+ * Ollama `/api/generate` is the exception: it rejects every tool-call fixture
15
+ * with a 400 before this check.
16
+ */
17
+ declare class UnsupportedToolCallError extends Error {
18
+ readonly toolName: string;
19
+ readonly wire: string;
20
+ constructor(toolName: string, wire: string);
21
+ }
22
+ /**
23
+ * A fixture tool call is malformed: a `toolCalls` entry that is not an object,
24
+ * a malformed `customToolCalls` entry, or a malformed tool block in
25
+ * `responsesBlocks`. Programmatic and factory fixtures skip load validation,
26
+ * so this request-time guard is their validation for the rules
27
+ * {@link assertResponsesToolCalls} and {@link resolveResponsesBlocks} check.
28
+ * An HTTP request then fails with a 500 that carries this message and `code`;
29
+ * a WebSocket turn gets the transport's error message with the code. A
30
+ * malformed legacy `blocks` entry keeps the plain Error of
31
+ * {@link resolveFixtureBlocks}.
32
+ */
33
+ declare class InvalidFixtureToolCallError extends Error {
34
+ readonly code = "aimock_invalid_fixture_tool_call";
35
+ constructor(index: number, problem: string, carrier?: "toolCalls" | "customToolCalls" | "blocks");
36
+ }
37
+ /**
38
+ * Validate a response's `customToolCalls` (OpenAI Responses only) before it is
39
+ * served. Throws {@link InvalidFixtureToolCallError} on the first malformed
40
+ * entry. The key is new, so no fixture of an earlier release reaches this.
41
+ */
42
+
43
+ /**
44
+ * A fixture's `toolCalls` for a wire that cannot carry custom tool calls.
45
+ * Every entry is a function call and passes through unchanged, exactly as in
46
+ * earlier releases (the builders read its `name`, `arguments` and `id`; its
47
+ * Responses-only `namespace` is not emitted). Custom calls live in
48
+ * `customToolCalls`, which {@link rejectResponsesOnlyToolCalls} rejects.
49
+ */
50
+ declare function requireFunctionToolCalls(calls: ToolCall[]): ToolCall[];
51
+ /**
52
+ * Reject the Responses-only custom tool calls on a wire that cannot carry
53
+ * them: a non-empty `customToolCalls`, or a `customToolCall` block in
54
+ * `responsesBlocks`. Throws {@link UnsupportedToolCallError} naming `wire`.
55
+ * Both keys are new, so no fixture of an earlier release reaches this error.
56
+ */
57
+
7
58
  /**
8
59
  * Build the strict-mode 503 error message, distinguishing a true no-match from
9
60
  * a sequence/turn-exhausted miss.
@@ -76,7 +127,20 @@ declare function generateMessageId(): string;
76
127
  declare function generateToolUseId(): string;
77
128
  declare function isTextResponse(r: FixtureResponse): r is TextResponse;
78
129
  declare function isToolCallResponse(r: FixtureResponse): r is ToolCallResponse;
130
+ /**
131
+ * Whether `r` is a combined content + tool calls response: a string `content`
132
+ * with a `toolCalls` array, or a non-empty `blocks` array. Public, with the
133
+ * 1.44.0 result for every input; `responsesBlocks` does not count. aimock's
134
+ * own handlers use {@link isCombinedFixtureResponse}, which also counts it.
135
+ */
79
136
  declare function isContentWithToolCallsResponse(r: FixtureResponse): r is ContentWithToolCallsResponse;
137
+ /**
138
+ * @internal The combined-response guard aimock's handlers, validation and
139
+ * misbehavior use: {@link isContentWithToolCallsResponse} plus a non-empty
140
+ * `responsesBlocks`. In legacy mode those keys are dropped before serving, so
141
+ * only `responsesTools: "extended"` sees the extra clause.
142
+ */
143
+
80
144
  /**
81
145
  * Validate and pass through the ordered `blocks` field of a combined
82
146
  * content+toolCalls fixture. Used ONLY on the new block-iteration path (when a
@@ -104,10 +168,25 @@ declare function isContentWithToolCallsResponse(r: FixtureResponse): r is Conten
104
168
  * optional string `id`. The return type guarantees `arguments: string` — every
105
169
  * caller relies on that. Throws on a malformed array or entry — same fail-fast
106
170
  * idiom as the other fixture validators in this module (see e.g. the factory
107
- * guard at {@link resolveResponse}).
171
+ * guard at {@link resolveResponse}). A `customToolCall` block is not a
172
+ * `blocks` entry (it belongs in `responsesBlocks`, see
173
+ * {@link resolveResponsesBlocks}) and fails as an unknown type.
108
174
  */
109
175
  declare function resolveFixtureBlocks(blocks: FixtureFileBlock[]): FixtureBlock[];
110
- /** Project normalized ordered blocks without changing the fixture or generating ids. */
176
+ /** A normalized block on a wire that cannot carry custom tool calls. */
177
+ type FunctionFixtureBlock = FixtureBlock;
178
+ /**
179
+ * Validate and normalize a fixture's `responsesBlocks` (OpenAI Responses
180
+ * only). Same rules and normalized copy as {@link resolveFixtureBlocks}, plus:
181
+ * a `customToolCall` block with a non-empty string `name`, a string `input`
182
+ * (never parsed or stringified), no `arguments` and an optional string `id`;
183
+ * on either tool block, `namespace` must be a non-empty string when present,
184
+ * and a `toolCall` block carries no `input`. The key is new, so a malformed
185
+ * tool block throws the coded {@link InvalidFixtureToolCallError}; a malformed
186
+ * text block or an unknown type throws a plain Error.
187
+ */
188
+ declare function resolveResponsesBlocks(blocks: readonly (FixtureFileResponsesBlock | ResponsesFixtureBlock)[]): ResponsesFixtureBlock[];
189
+ /** Allocate the exact OpenAI call identities once for both wire output and observations. */
111
190
 
112
191
  declare function isErrorResponse(r: FixtureResponse): r is ErrorResponse;
113
192
  /**
@@ -138,6 +217,8 @@ declare function extractOverrides(response: TextResponse | ToolCallResponse | Co
138
217
  */
139
218
 
140
219
  declare function buildTextChunks(content: string, model: string, chunkSize: number, reasoning?: string, overrides?: ResponseOverrides): SSEChunk[];
220
+ /** K9 exposure is selected by the provider path, never the echoed response model. */
221
+
141
222
  declare function buildToolCallChunks(toolCalls: ToolCall[], model: string, chunkSize: number, reasoning?: string, overrides?: ResponseOverrides): SSEChunk[];
142
223
  declare function buildTextCompletion(content: string, model: string, reasoning?: string, overrides?: ResponseOverrides, requestMessages?: ChatCompletionRequest["messages"]): ChatCompletion;
143
224
  declare function buildToolCallCompletion(toolCalls: ToolCall[], model: string, reasoning?: string, overrides?: ResponseOverrides, requestMessages?: ChatCompletionRequest["messages"]): ChatCompletion;
@@ -179,5 +260,5 @@ declare function buildEmbeddingResponse(embeddings: number[][], model: string, u
179
260
  total_tokens?: number;
180
261
  }): EmbeddingAPIResponse;
181
262
  //#endregion
182
- export { EmbeddingAPIResponse, FORMAT_TO_CONTENT_TYPE, buildContentWithToolCallsChunks, buildContentWithToolCallsCompletion, buildEmbeddingResponse, buildTextChunks, buildTextCompletion, buildToolCallChunks, buildToolCallCompletion, extractOverrides, flattenHeaders, formatToMime, generateDeterministicEmbedding, generateId, generateMessageId, generateToolCallId, generateToolUseId, isAudioResponse, isContentWithToolCallsResponse, isEmbeddingResponse, isErrorResponse, isImageResponse, isLiveResponse, isTextResponse, isToolCallResponse, isTranscriptionResponse, isVideoResponse, resolveFixtureBlocks, resolveRequestId, strictNoMatchLogLine, strictNoMatchMessage };
263
+ export { EmbeddingAPIResponse, FORMAT_TO_CONTENT_TYPE, FunctionFixtureBlock, InvalidFixtureToolCallError, UnsupportedToolCallError, buildContentWithToolCallsChunks, buildContentWithToolCallsCompletion, buildEmbeddingResponse, buildTextChunks, buildTextCompletion, buildToolCallChunks, buildToolCallCompletion, extractOverrides, flattenHeaders, formatToMime, generateDeterministicEmbedding, generateId, generateMessageId, generateToolCallId, generateToolUseId, isAudioResponse, isContentWithToolCallsResponse, isEmbeddingResponse, isErrorResponse, isImageResponse, isLiveResponse, isTextResponse, isToolCallResponse, isTranscriptionResponse, isVideoResponse, requireFunctionToolCalls, resolveFixtureBlocks, resolveRequestId, resolveResponsesBlocks, strictNoMatchLogLine, strictNoMatchMessage };
183
264
  //# sourceMappingURL=helpers.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.d.cts","names":[],"sources":["../src/helpers.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;AAmjBA;;;;;AAUA;AAaA;AAIA;;;;AAAuF,iBAtcvE,oBAAA,CAscuE,uBAAA,EAAA,MAAA,CAAA,EAAA,MAAA;AAQvF;;;;AAAuE,iBAncvD,oBAAA,CAmcuD,MAAA,EAAA,MAAA,EAAA,GAAA,EAAA,MAAA,EAAA,uBAAA,EAAA,MAAA,CAAA,EAAA,MAAA;AAYvE;;;;;;;AAqHA;;;;;AA2EA;;;;;;;iBA7iBgB,cAAA,UAAwB,MAAA,CAAK,sBAAsB;;iBAcnD,cAAA,2BAAyC;iBA0DzC,UAAA;;;;;;;;;;;;;;;;;;iBAqBA,gBAAA,aAA6B,MAAA,CAAK;;;;;;iBAqClC,kBAAA,CAAA;iBAIA,iBAAA,CAAA;iBAIA,iBAAA,CAAA;iBAIA,cAAA,IAAkB,uBAAuB;iBAIzC,kBAAA,IAAsB,uBAAuB;iBA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ts CHANGED
@@ -1,9 +1,60 @@
1
1
  import { LiveFixtureResponse } from "./live-types.js";
2
- import { AudioResponse, ChatCompletion, ChatCompletionRequest, ContentWithToolCallsResponse, EmbeddingResponse, ErrorResponse, FixtureBlock, FixtureFileBlock, FixtureResponse, ImageResponse, ResponseOverrides, SSEChunk, TextResponse, ToolCall, ToolCallResponse, TranscriptionResponse, VideoResponse } from "./types.js";
2
+ import { AudioResponse, ChatCompletion, ChatCompletionRequest, ContentWithToolCallsResponse, EmbeddingResponse, ErrorResponse, FixtureBlock, FixtureFileBlock, FixtureFileResponsesBlock, FixtureResponse, ImageResponse, ResponseOverrides, ResponsesFixtureBlock, SSEChunk, TextResponse, ToolCall, ToolCallResponse, TranscriptionResponse, VideoResponse } from "./types.js";
3
3
  import * as http$1 from "node:http";
4
4
 
5
5
  //#region src/helpers.d.ts
6
6
 
7
+ /**
8
+ * A custom (freeform) tool call reached a wire that has no faithful projection
9
+ * for it. Only the OpenAI Responses API (HTTP and WebSocket) emits custom tool
10
+ * calls, from a fixture's `customToolCalls` or a `customToolCall` block in its
11
+ * `responsesBlocks`. The handlers of the other wires raise this through
12
+ * {@link rejectResponsesOnlyToolCalls} (usually via
13
+ * {@link requireEmittedFunctionToolCalls}) before they write any content.
14
+ * Ollama `/api/generate` is the exception: it rejects every tool-call fixture
15
+ * with a 400 before this check.
16
+ */
17
+ declare class UnsupportedToolCallError extends Error {
18
+ readonly toolName: string;
19
+ readonly wire: string;
20
+ constructor(toolName: string, wire: string);
21
+ }
22
+ /**
23
+ * A fixture tool call is malformed: a `toolCalls` entry that is not an object,
24
+ * a malformed `customToolCalls` entry, or a malformed tool block in
25
+ * `responsesBlocks`. Programmatic and factory fixtures skip load validation,
26
+ * so this request-time guard is their validation for the rules
27
+ * {@link assertResponsesToolCalls} and {@link resolveResponsesBlocks} check.
28
+ * An HTTP request then fails with a 500 that carries this message and `code`;
29
+ * a WebSocket turn gets the transport's error message with the code. A
30
+ * malformed legacy `blocks` entry keeps the plain Error of
31
+ * {@link resolveFixtureBlocks}.
32
+ */
33
+ declare class InvalidFixtureToolCallError extends Error {
34
+ readonly code = "aimock_invalid_fixture_tool_call";
35
+ constructor(index: number, problem: string, carrier?: "toolCalls" | "customToolCalls" | "blocks");
36
+ }
37
+ /**
38
+ * Validate a response's `customToolCalls` (OpenAI Responses only) before it is
39
+ * served. Throws {@link InvalidFixtureToolCallError} on the first malformed
40
+ * entry. The key is new, so no fixture of an earlier release reaches this.
41
+ */
42
+
43
+ /**
44
+ * A fixture's `toolCalls` for a wire that cannot carry custom tool calls.
45
+ * Every entry is a function call and passes through unchanged, exactly as in
46
+ * earlier releases (the builders read its `name`, `arguments` and `id`; its
47
+ * Responses-only `namespace` is not emitted). Custom calls live in
48
+ * `customToolCalls`, which {@link rejectResponsesOnlyToolCalls} rejects.
49
+ */
50
+ declare function requireFunctionToolCalls(calls: ToolCall[]): ToolCall[];
51
+ /**
52
+ * Reject the Responses-only custom tool calls on a wire that cannot carry
53
+ * them: a non-empty `customToolCalls`, or a `customToolCall` block in
54
+ * `responsesBlocks`. Throws {@link UnsupportedToolCallError} naming `wire`.
55
+ * Both keys are new, so no fixture of an earlier release reaches this error.
56
+ */
57
+
7
58
  /**
8
59
  * Build the strict-mode 503 error message, distinguishing a true no-match from
9
60
  * a sequence/turn-exhausted miss.
@@ -76,7 +127,20 @@ declare function generateMessageId(): string;
76
127
  declare function generateToolUseId(): string;
77
128
  declare function isTextResponse(r: FixtureResponse): r is TextResponse;
78
129
  declare function isToolCallResponse(r: FixtureResponse): r is ToolCallResponse;
130
+ /**
131
+ * Whether `r` is a combined content + tool calls response: a string `content`
132
+ * with a `toolCalls` array, or a non-empty `blocks` array. Public, with the
133
+ * 1.44.0 result for every input; `responsesBlocks` does not count. aimock's
134
+ * own handlers use {@link isCombinedFixtureResponse}, which also counts it.
135
+ */
79
136
  declare function isContentWithToolCallsResponse(r: FixtureResponse): r is ContentWithToolCallsResponse;
137
+ /**
138
+ * @internal The combined-response guard aimock's handlers, validation and
139
+ * misbehavior use: {@link isContentWithToolCallsResponse} plus a non-empty
140
+ * `responsesBlocks`. In legacy mode those keys are dropped before serving, so
141
+ * only `responsesTools: "extended"` sees the extra clause.
142
+ */
143
+
80
144
  /**
81
145
  * Validate and pass through the ordered `blocks` field of a combined
82
146
  * content+toolCalls fixture. Used ONLY on the new block-iteration path (when a
@@ -104,10 +168,25 @@ declare function isContentWithToolCallsResponse(r: FixtureResponse): r is Conten
104
168
  * optional string `id`. The return type guarantees `arguments: string` — every
105
169
  * caller relies on that. Throws on a malformed array or entry — same fail-fast
106
170
  * idiom as the other fixture validators in this module (see e.g. the factory
107
- * guard at {@link resolveResponse}).
171
+ * guard at {@link resolveResponse}). A `customToolCall` block is not a
172
+ * `blocks` entry (it belongs in `responsesBlocks`, see
173
+ * {@link resolveResponsesBlocks}) and fails as an unknown type.
108
174
  */
109
175
  declare function resolveFixtureBlocks(blocks: FixtureFileBlock[]): FixtureBlock[];
110
- /** Project normalized ordered blocks without changing the fixture or generating ids. */
176
+ /** A normalized block on a wire that cannot carry custom tool calls. */
177
+ type FunctionFixtureBlock = FixtureBlock;
178
+ /**
179
+ * Validate and normalize a fixture's `responsesBlocks` (OpenAI Responses
180
+ * only). Same rules and normalized copy as {@link resolveFixtureBlocks}, plus:
181
+ * a `customToolCall` block with a non-empty string `name`, a string `input`
182
+ * (never parsed or stringified), no `arguments` and an optional string `id`;
183
+ * on either tool block, `namespace` must be a non-empty string when present,
184
+ * and a `toolCall` block carries no `input`. The key is new, so a malformed
185
+ * tool block throws the coded {@link InvalidFixtureToolCallError}; a malformed
186
+ * text block or an unknown type throws a plain Error.
187
+ */
188
+ declare function resolveResponsesBlocks(blocks: readonly (FixtureFileResponsesBlock | ResponsesFixtureBlock)[]): ResponsesFixtureBlock[];
189
+ /** Allocate the exact OpenAI call identities once for both wire output and observations. */
111
190
 
112
191
  declare function isErrorResponse(r: FixtureResponse): r is ErrorResponse;
113
192
  /**
@@ -138,6 +217,8 @@ declare function extractOverrides(response: TextResponse | ToolCallResponse | Co
138
217
  */
139
218
 
140
219
  declare function buildTextChunks(content: string, model: string, chunkSize: number, reasoning?: string, overrides?: ResponseOverrides): SSEChunk[];
220
+ /** K9 exposure is selected by the provider path, never the echoed response model. */
221
+
141
222
  declare function buildToolCallChunks(toolCalls: ToolCall[], model: string, chunkSize: number, reasoning?: string, overrides?: ResponseOverrides): SSEChunk[];
142
223
  declare function buildTextCompletion(content: string, model: string, reasoning?: string, overrides?: ResponseOverrides, requestMessages?: ChatCompletionRequest["messages"]): ChatCompletion;
143
224
  declare function buildToolCallCompletion(toolCalls: ToolCall[], model: string, reasoning?: string, overrides?: ResponseOverrides, requestMessages?: ChatCompletionRequest["messages"]): ChatCompletion;
@@ -179,5 +260,5 @@ declare function buildEmbeddingResponse(embeddings: number[][], model: string, u
179
260
  total_tokens?: number;
180
261
  }): EmbeddingAPIResponse;
181
262
  //#endregion
182
- export { EmbeddingAPIResponse, FORMAT_TO_CONTENT_TYPE, buildContentWithToolCallsChunks, buildContentWithToolCallsCompletion, buildEmbeddingResponse, buildTextChunks, buildTextCompletion, buildToolCallChunks, buildToolCallCompletion, extractOverrides, flattenHeaders, formatToMime, generateDeterministicEmbedding, generateId, generateMessageId, generateToolCallId, generateToolUseId, isAudioResponse, isContentWithToolCallsResponse, isEmbeddingResponse, isErrorResponse, isImageResponse, isLiveResponse, isTextResponse, isToolCallResponse, isTranscriptionResponse, isVideoResponse, resolveFixtureBlocks, resolveRequestId, strictNoMatchLogLine, strictNoMatchMessage };
263
+ export { EmbeddingAPIResponse, FORMAT_TO_CONTENT_TYPE, FunctionFixtureBlock, InvalidFixtureToolCallError, UnsupportedToolCallError, buildContentWithToolCallsChunks, buildContentWithToolCallsCompletion, buildEmbeddingResponse, buildTextChunks, buildTextCompletion, buildToolCallChunks, buildToolCallCompletion, extractOverrides, flattenHeaders, formatToMime, generateDeterministicEmbedding, generateId, generateMessageId, generateToolCallId, generateToolUseId, isAudioResponse, isContentWithToolCallsResponse, isEmbeddingResponse, isErrorResponse, isImageResponse, isLiveResponse, isTextResponse, isToolCallResponse, isTranscriptionResponse, isVideoResponse, requireFunctionToolCalls, resolveFixtureBlocks, resolveRequestId, resolveResponsesBlocks, strictNoMatchLogLine, strictNoMatchMessage };
183
264
  //# sourceMappingURL=helpers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.d.ts","names":[],"sources":["../src/helpers.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;AAmjBA;;;;;AAUA;AAaA;AAIA;;;;AAAuF,iBAtcvE,oBAAA,CAscuE,uBAAA,EAAA,MAAA,CAAA,EAAA,MAAA;AAQvF;;;;AAAuE,iBAncvD,oBAAA,CAmcuD,MAAA,EAAA,MAAA,EAAA,GAAA,EAAA,MAAA,EAAA,uBAAA,EAAA,MAAA,CAAA,EAAA,MAAA;AAYvE;;;;;;;AAqHA;;;;;AA2EA;;;;;;;iBA7iBgB,cAAA,UAAwB,MAAA,CAAK,sBAAsB;;iBAcnD,cAAA,2BAAyC;iBA0DzC,UAAA;;;;;;;;;;;;;;;;;;iBAqBA,gBAAA,aAA6B,MAAA,CAAK;;;;;;iBAqClC,kBAAA,CAAA;iBAIA,iBAAA,CAAA;iBAIA,iBAAA,CAAA;iBAIA,cAAA,IAAkB,uBAAuB;iBAIzC,kBAAA,IAAsB,uBAAuB;iBAQ7C,8BAAA,IACX,uBACG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAmDQ,oBAAA,SAA6B,qBAAqB;;;iBA0ElD,eAAA,IAAmB,uBAAuB;;;;;;;iBA0B1C,mBAAA,IAAuB,uBAAuB;iBAI9C,eAAA,IAAmB,uBAAuB;iBAO1C,eAAA,IAAmB,uBAAuB;;;;;cAU7C,wBAAwB;;;;;iBAarB,YAAA;iBAIA,uBAAA,IAA2B,uBAAuB;iBAQlD,eAAA,IAAmB,uBAAuB;iBAY1C,gBAAA,WACJ,eAAe,mBAAmB,+BAC3C;;;;;;iBAmHa,e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