@copilotkit/aimock 1.43.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 (396) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/CHANGELOG.md +46 -0
  4. package/README.md +14 -2
  5. package/dist/agui-handler.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 +344 -43
  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 +345 -44
  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 +9 -5
  25. package/dist/chaos.cjs.map +1 -1
  26. package/dist/chaos.d.cts.map +1 -1
  27. package/dist/chaos.d.ts.map +1 -1
  28. package/dist/chaos.js +10 -7
  29. package/dist/chaos.js.map +1 -1
  30. package/dist/cli.cjs +238 -9
  31. package/dist/cli.cjs.map +1 -1
  32. package/dist/cli.js +242 -13
  33. package/dist/cli.js.map +1 -1
  34. package/dist/cohere.cjs +159 -72
  35. package/dist/cohere.cjs.map +1 -1
  36. package/dist/cohere.d.cts.map +1 -1
  37. package/dist/cohere.d.ts.map +1 -1
  38. package/dist/cohere.js +160 -73
  39. package/dist/cohere.js.map +1 -1
  40. package/dist/config-loader.cjs +63 -5
  41. package/dist/config-loader.cjs.map +1 -1
  42. package/dist/config-loader.d.cts +37 -4
  43. package/dist/config-loader.d.cts.map +1 -1
  44. package/dist/config-loader.d.ts +37 -4
  45. package/dist/config-loader.d.ts.map +1 -1
  46. package/dist/config-loader.js +63 -5
  47. package/dist/config-loader.js.map +1 -1
  48. package/dist/constants.cjs +8 -0
  49. package/dist/constants.cjs.map +1 -1
  50. package/dist/constants.d.cts +6 -2
  51. package/dist/constants.d.ts +6 -2
  52. package/dist/constants.js +8 -1
  53. package/dist/constants.js.map +1 -1
  54. package/dist/echo-text.cjs +65 -0
  55. package/dist/echo-text.cjs.map +1 -0
  56. package/dist/echo-text.d.cts +22 -0
  57. package/dist/echo-text.d.cts.map +1 -0
  58. package/dist/echo-text.d.ts +22 -0
  59. package/dist/echo-text.d.ts.map +1 -0
  60. package/dist/echo-text.js +65 -0
  61. package/dist/echo-text.js.map +1 -0
  62. package/dist/embeddings.cjs +18 -1
  63. package/dist/embeddings.cjs.map +1 -1
  64. package/dist/embeddings.d.cts +1 -1
  65. package/dist/embeddings.d.cts.map +1 -1
  66. package/dist/embeddings.d.ts +1 -1
  67. package/dist/embeddings.d.ts.map +1 -1
  68. package/dist/embeddings.js +18 -1
  69. package/dist/embeddings.js.map +1 -1
  70. package/dist/fakes-plugin.cjs +131 -0
  71. package/dist/fakes-plugin.cjs.map +1 -0
  72. package/dist/fakes-plugin.d.cts +23 -0
  73. package/dist/fakes-plugin.d.cts.map +1 -0
  74. package/dist/fakes-plugin.d.ts +23 -0
  75. package/dist/fakes-plugin.d.ts.map +1 -0
  76. package/dist/fakes-plugin.js +127 -0
  77. package/dist/fakes-plugin.js.map +1 -0
  78. package/dist/files.cjs +9 -11
  79. package/dist/files.cjs.map +1 -1
  80. package/dist/files.d.cts.map +1 -1
  81. package/dist/files.d.ts.map +1 -1
  82. package/dist/files.js +10 -13
  83. package/dist/files.js.map +1 -1
  84. package/dist/fine-tuning.cjs +1 -19
  85. package/dist/fine-tuning.cjs.map +1 -1
  86. package/dist/fine-tuning.d.cts.map +1 -1
  87. package/dist/fine-tuning.d.ts.map +1 -1
  88. package/dist/fine-tuning.js +2 -20
  89. package/dist/fine-tuning.js.map +1 -1
  90. package/dist/fixture-loader-services.cjs +116 -0
  91. package/dist/fixture-loader-services.cjs.map +1 -0
  92. package/dist/fixture-loader-services.d.cts +48 -0
  93. package/dist/fixture-loader-services.d.cts.map +1 -0
  94. package/dist/fixture-loader-services.d.ts +48 -0
  95. package/dist/fixture-loader-services.d.ts.map +1 -0
  96. package/dist/fixture-loader-services.js +114 -0
  97. package/dist/fixture-loader-services.js.map +1 -0
  98. package/dist/fixture-loader.cjs +552 -29
  99. package/dist/fixture-loader.cjs.map +1 -1
  100. package/dist/fixture-loader.d.cts +140 -2
  101. package/dist/fixture-loader.d.cts.map +1 -1
  102. package/dist/fixture-loader.d.ts +140 -2
  103. package/dist/fixture-loader.d.ts.map +1 -1
  104. package/dist/fixture-loader.js +542 -31
  105. package/dist/fixture-loader.js.map +1 -1
  106. package/dist/gemini-embeddings.cjs +42 -2
  107. package/dist/gemini-embeddings.cjs.map +1 -1
  108. package/dist/gemini-embeddings.js +43 -3
  109. package/dist/gemini-embeddings.js.map +1 -1
  110. package/dist/gemini-interactions.cjs +288 -52
  111. package/dist/gemini-interactions.cjs.map +1 -1
  112. package/dist/gemini-interactions.d.cts.map +1 -1
  113. package/dist/gemini-interactions.d.ts.map +1 -1
  114. package/dist/gemini-interactions.js +289 -53
  115. package/dist/gemini-interactions.js.map +1 -1
  116. package/dist/gemini.cjs +234 -38
  117. package/dist/gemini.cjs.map +1 -1
  118. package/dist/gemini.d.cts.map +1 -1
  119. package/dist/gemini.d.ts.map +1 -1
  120. package/dist/gemini.js +235 -39
  121. package/dist/gemini.js.map +1 -1
  122. package/dist/helpers.cjs +1157 -12
  123. package/dist/helpers.cjs.map +1 -1
  124. package/dist/helpers.d.cts +85 -4
  125. package/dist/helpers.d.cts.map +1 -1
  126. package/dist/helpers.d.ts +85 -4
  127. package/dist/helpers.d.ts.map +1 -1
  128. package/dist/helpers.js +1113 -14
  129. package/dist/helpers.js.map +1 -1
  130. package/dist/images.cjs +3 -2
  131. package/dist/images.cjs.map +1 -1
  132. package/dist/images.js +3 -2
  133. package/dist/images.js.map +1 -1
  134. package/dist/index.cjs +39 -1
  135. package/dist/index.d.cts +11 -4
  136. package/dist/index.d.ts +11 -4
  137. package/dist/index.js +11 -4
  138. package/dist/jest.cjs +43 -14
  139. package/dist/jest.cjs.map +1 -1
  140. package/dist/jest.d.cts +47 -5
  141. package/dist/jest.d.cts.map +1 -1
  142. package/dist/jest.d.ts +47 -5
  143. package/dist/jest.d.ts.map +1 -1
  144. package/dist/jest.js +45 -16
  145. package/dist/jest.js.map +1 -1
  146. package/dist/journal.cjs +155 -13
  147. package/dist/journal.cjs.map +1 -1
  148. package/dist/journal.d.cts +54 -4
  149. package/dist/journal.d.cts.map +1 -1
  150. package/dist/journal.d.ts +54 -4
  151. package/dist/journal.d.ts.map +1 -1
  152. package/dist/journal.js +155 -13
  153. package/dist/journal.js.map +1 -1
  154. package/dist/live-sanitize.cjs +4 -32
  155. package/dist/live-sanitize.cjs.map +1 -1
  156. package/dist/live-sanitize.js +4 -32
  157. package/dist/live-sanitize.js.map +1 -1
  158. package/dist/llmock.cjs +204 -39
  159. package/dist/llmock.cjs.map +1 -1
  160. package/dist/llmock.d.cts +51 -1
  161. package/dist/llmock.d.cts.map +1 -1
  162. package/dist/llmock.d.ts +51 -1
  163. package/dist/llmock.d.ts.map +1 -1
  164. package/dist/llmock.js +206 -41
  165. package/dist/llmock.js.map +1 -1
  166. package/dist/mcp-fakes-mount.cjs +217 -0
  167. package/dist/mcp-fakes-mount.cjs.map +1 -0
  168. package/dist/mcp-fakes-mount.js +211 -0
  169. package/dist/mcp-fakes-mount.js.map +1 -0
  170. package/dist/mcp-fakes-report.cjs +111 -0
  171. package/dist/mcp-fakes-report.cjs.map +1 -0
  172. package/dist/mcp-fakes-report.d.cts +40 -0
  173. package/dist/mcp-fakes-report.d.cts.map +1 -0
  174. package/dist/mcp-fakes-report.d.ts +40 -0
  175. package/dist/mcp-fakes-report.d.ts.map +1 -0
  176. package/dist/mcp-fakes-report.js +107 -0
  177. package/dist/mcp-fakes-report.js.map +1 -0
  178. package/dist/mcp-fakes.cjs +1942 -0
  179. package/dist/mcp-fakes.cjs.map +1 -0
  180. package/dist/mcp-fakes.d.cts +504 -0
  181. package/dist/mcp-fakes.d.cts.map +1 -0
  182. package/dist/mcp-fakes.d.ts +504 -0
  183. package/dist/mcp-fakes.d.ts.map +1 -0
  184. package/dist/mcp-fakes.js +1937 -0
  185. package/dist/mcp-fakes.js.map +1 -0
  186. package/dist/mcp-handler.cjs +534 -27
  187. package/dist/mcp-handler.cjs.map +1 -1
  188. package/dist/mcp-handler.d.cts +49 -0
  189. package/dist/mcp-handler.d.cts.map +1 -0
  190. package/dist/mcp-handler.d.ts +49 -0
  191. package/dist/mcp-handler.d.ts.map +1 -0
  192. package/dist/mcp-handler.js +530 -28
  193. package/dist/mcp-handler.js.map +1 -1
  194. package/dist/mcp-mock.cjs +326 -47
  195. package/dist/mcp-mock.cjs.map +1 -1
  196. package/dist/mcp-mock.d.cts +97 -1
  197. package/dist/mcp-mock.d.cts.map +1 -1
  198. package/dist/mcp-mock.d.ts +97 -1
  199. package/dist/mcp-mock.d.ts.map +1 -1
  200. package/dist/mcp-mock.js +327 -48
  201. package/dist/mcp-mock.js.map +1 -1
  202. package/dist/mcp-recorder.cjs +1224 -0
  203. package/dist/mcp-recorder.cjs.map +1 -0
  204. package/dist/mcp-recorder.d.cts +108 -0
  205. package/dist/mcp-recorder.d.cts.map +1 -0
  206. package/dist/mcp-recorder.d.ts +108 -0
  207. package/dist/mcp-recorder.d.ts.map +1 -0
  208. package/dist/mcp-recorder.js +1215 -0
  209. package/dist/mcp-recorder.js.map +1 -0
  210. package/dist/mcp-stub.cjs +5 -1
  211. package/dist/mcp-stub.d.cts +3 -1
  212. package/dist/mcp-stub.d.ts +3 -1
  213. package/dist/mcp-stub.js +3 -1
  214. package/dist/mcp-types.d.cts +6 -0
  215. package/dist/mcp-types.d.ts +6 -0
  216. package/dist/message-text.cjs +192 -0
  217. package/dist/message-text.cjs.map +1 -0
  218. package/dist/message-text.d.cts +31 -0
  219. package/dist/message-text.d.cts.map +1 -0
  220. package/dist/message-text.d.ts +31 -0
  221. package/dist/message-text.d.ts.map +1 -0
  222. package/dist/message-text.js +184 -0
  223. package/dist/message-text.js.map +1 -0
  224. package/dist/messages.cjs +400 -56
  225. package/dist/messages.cjs.map +1 -1
  226. package/dist/messages.d.cts.map +1 -1
  227. package/dist/messages.d.ts.map +1 -1
  228. package/dist/messages.js +401 -58
  229. package/dist/messages.js.map +1 -1
  230. package/dist/metrics.cjs +46 -66
  231. package/dist/metrics.cjs.map +1 -1
  232. package/dist/metrics.d.cts +14 -6
  233. package/dist/metrics.d.cts.map +1 -1
  234. package/dist/metrics.d.ts +14 -6
  235. package/dist/metrics.d.ts.map +1 -1
  236. package/dist/metrics.js +32 -40
  237. package/dist/metrics.js.map +1 -1
  238. package/dist/misbehavior.cjs +1523 -0
  239. package/dist/misbehavior.cjs.map +1 -0
  240. package/dist/misbehavior.d.cts +43 -0
  241. package/dist/misbehavior.d.cts.map +1 -0
  242. package/dist/misbehavior.d.ts +43 -0
  243. package/dist/misbehavior.d.ts.map +1 -0
  244. package/dist/misbehavior.js +1511 -0
  245. package/dist/misbehavior.js.map +1 -0
  246. package/dist/ollama.cjs +315 -113
  247. package/dist/ollama.cjs.map +1 -1
  248. package/dist/ollama.d.cts.map +1 -1
  249. package/dist/ollama.d.ts.map +1 -1
  250. package/dist/ollama.js +316 -114
  251. package/dist/ollama.js.map +1 -1
  252. package/dist/openapi.cjs +3405 -0
  253. package/dist/openapi.cjs.map +1 -0
  254. package/dist/openapi.d.cts +30 -0
  255. package/dist/openapi.d.cts.map +1 -0
  256. package/dist/openapi.d.ts +30 -0
  257. package/dist/openapi.d.ts.map +1 -0
  258. package/dist/openapi.js +3404 -0
  259. package/dist/openapi.js.map +1 -0
  260. package/dist/openrouter-video.cjs +4 -4
  261. package/dist/openrouter-video.cjs.map +1 -1
  262. package/dist/openrouter-video.d.cts.map +1 -1
  263. package/dist/openrouter-video.d.ts.map +1 -1
  264. package/dist/openrouter-video.js +4 -4
  265. package/dist/openrouter-video.js.map +1 -1
  266. package/dist/record-sanitize.cjs +231 -0
  267. package/dist/record-sanitize.cjs.map +1 -0
  268. package/dist/record-sanitize.js +224 -0
  269. package/dist/record-sanitize.js.map +1 -0
  270. package/dist/recorder.cjs +115 -6
  271. package/dist/recorder.cjs.map +1 -1
  272. package/dist/recorder.d.cts +2 -1
  273. package/dist/recorder.d.cts.map +1 -1
  274. package/dist/recorder.d.ts +2 -1
  275. package/dist/recorder.d.ts.map +1 -1
  276. package/dist/recorder.js +116 -8
  277. package/dist/recorder.js.map +1 -1
  278. package/dist/responses.cjs +701 -166
  279. package/dist/responses.cjs.map +1 -1
  280. package/dist/responses.d.cts +5 -13
  281. package/dist/responses.d.cts.map +1 -1
  282. package/dist/responses.d.ts +5 -13
  283. package/dist/responses.d.ts.map +1 -1
  284. package/dist/responses.js +699 -169
  285. package/dist/responses.js.map +1 -1
  286. package/dist/route-registry.cjs +951 -0
  287. package/dist/route-registry.cjs.map +1 -0
  288. package/dist/route-registry.d.cts +33 -0
  289. package/dist/route-registry.d.cts.map +1 -0
  290. package/dist/route-registry.d.ts +33 -0
  291. package/dist/route-registry.d.ts.map +1 -0
  292. package/dist/route-registry.js +866 -0
  293. package/dist/route-registry.js.map +1 -0
  294. package/dist/router.cjs +24 -2
  295. package/dist/router.cjs.map +1 -1
  296. package/dist/router.d.cts.map +1 -1
  297. package/dist/router.d.ts.map +1 -1
  298. package/dist/router.js +25 -4
  299. package/dist/router.js.map +1 -1
  300. package/dist/server.cjs +1159 -264
  301. package/dist/server.cjs.map +1 -1
  302. package/dist/server.d.cts +4 -1
  303. package/dist/server.d.cts.map +1 -1
  304. package/dist/server.d.ts +4 -1
  305. package/dist/server.d.ts.map +1 -1
  306. package/dist/server.js +1067 -172
  307. package/dist/server.js.map +1 -1
  308. package/dist/speech.cjs +4 -2
  309. package/dist/speech.cjs.map +1 -1
  310. package/dist/speech.js +4 -2
  311. package/dist/speech.js.map +1 -1
  312. package/dist/stream-collapse.cjs +236 -34
  313. package/dist/stream-collapse.cjs.map +1 -1
  314. package/dist/stream-collapse.d.cts +39 -4
  315. package/dist/stream-collapse.d.cts.map +1 -1
  316. package/dist/stream-collapse.d.ts +39 -4
  317. package/dist/stream-collapse.d.ts.map +1 -1
  318. package/dist/stream-collapse.js +235 -35
  319. package/dist/stream-collapse.js.map +1 -1
  320. package/dist/suite.cjs +1 -1
  321. package/dist/suite.js +1 -1
  322. package/dist/transcription.cjs +2 -2
  323. package/dist/transcription.cjs.map +1 -1
  324. package/dist/transcription.d.cts.map +1 -1
  325. package/dist/transcription.d.ts.map +1 -1
  326. package/dist/transcription.js +2 -2
  327. package/dist/transcription.js.map +1 -1
  328. package/dist/types.cjs +18 -0
  329. package/dist/types.cjs.map +1 -0
  330. package/dist/types.d.cts +516 -5
  331. package/dist/types.d.cts.map +1 -1
  332. package/dist/types.d.ts +516 -5
  333. package/dist/types.d.ts.map +1 -1
  334. package/dist/types.js +17 -0
  335. package/dist/types.js.map +1 -0
  336. package/dist/validate-cli.cjs +123 -33
  337. package/dist/validate-cli.cjs.map +1 -1
  338. package/dist/validate-cli.js +125 -35
  339. package/dist/validate-cli.js.map +1 -1
  340. package/dist/vector-stores.cjs +1180 -0
  341. package/dist/vector-stores.cjs.map +1 -0
  342. package/dist/vector-stores.d.cts +106 -0
  343. package/dist/vector-stores.d.cts.map +1 -0
  344. package/dist/vector-stores.d.ts +106 -0
  345. package/dist/vector-stores.d.ts.map +1 -0
  346. package/dist/vector-stores.js +1164 -0
  347. package/dist/vector-stores.js.map +1 -0
  348. package/dist/vector-types.d.cts.map +1 -1
  349. package/dist/version.cjs +45 -0
  350. package/dist/version.cjs.map +1 -0
  351. package/dist/version.js +44 -0
  352. package/dist/version.js.map +1 -0
  353. package/dist/video.cjs +19 -0
  354. package/dist/video.cjs.map +1 -1
  355. package/dist/video.d.cts.map +1 -1
  356. package/dist/video.d.ts.map +1 -1
  357. package/dist/video.js +19 -0
  358. package/dist/video.js.map +1 -1
  359. package/dist/vitest.cjs +77 -16
  360. package/dist/vitest.cjs.map +1 -1
  361. package/dist/vitest.d.cts +38 -5
  362. package/dist/vitest.d.cts.map +1 -1
  363. package/dist/vitest.d.ts +38 -5
  364. package/dist/vitest.d.ts.map +1 -1
  365. package/dist/vitest.js +78 -17
  366. package/dist/vitest.js.map +1 -1
  367. package/dist/watcher.cjs +6 -2
  368. package/dist/watcher.cjs.map +1 -1
  369. package/dist/watcher.js +6 -2
  370. package/dist/watcher.js.map +1 -1
  371. package/dist/ws-gemini-live.cjs +210 -101
  372. package/dist/ws-gemini-live.cjs.map +1 -1
  373. package/dist/ws-gemini-live.d.cts +9 -3
  374. package/dist/ws-gemini-live.d.cts.map +1 -1
  375. package/dist/ws-gemini-live.d.ts +9 -3
  376. package/dist/ws-gemini-live.d.ts.map +1 -1
  377. package/dist/ws-gemini-live.js +211 -102
  378. package/dist/ws-gemini-live.js.map +1 -1
  379. package/dist/ws-realtime.cjs +175 -62
  380. package/dist/ws-realtime.cjs.map +1 -1
  381. package/dist/ws-realtime.d.cts +8 -3
  382. package/dist/ws-realtime.d.cts.map +1 -1
  383. package/dist/ws-realtime.d.ts +8 -3
  384. package/dist/ws-realtime.d.ts.map +1 -1
  385. package/dist/ws-realtime.js +176 -63
  386. package/dist/ws-realtime.js.map +1 -1
  387. package/dist/ws-responses.cjs +121 -16
  388. package/dist/ws-responses.cjs.map +1 -1
  389. package/dist/ws-responses.d.cts +8 -12
  390. package/dist/ws-responses.d.cts.map +1 -1
  391. package/dist/ws-responses.d.ts +8 -12
  392. package/dist/ws-responses.d.ts.map +1 -1
  393. package/dist/ws-responses.js +123 -18
  394. package/dist/ws-responses.js.map +1 -1
  395. package/package.json +13 -2
  396. package/skills/write-fixtures/SKILL.md +179 -21
package/dist/index.d.ts CHANGED
@@ -1,9 +1,13 @@
1
+ import { MisbehaviorRule } from "./misbehavior.js";
1
2
  import { DEFAULT_TEST_ID } from "./constants.js";
2
3
  import { Journal, isChatCompletionBody } from "./journal.js";
3
4
  import { LiveBinding, LiveEntry, LiveFailureCategory, LiveFixtureResponse, LiveJson, LiveMode, LiveObject, LiveOptions, LivePosition, LiveTranscript } from "./live-types.js";
4
5
  import { LogLevel, Logger } from "./logger.js";
6
+ import { ROUTE_DEFINITIONS, RouteDefinition } from "./route-registry.js";
5
7
  import { MetricsRegistry, createMetricsRegistry, normalizePathLabel } from "./metrics.js";
6
- import { ApiKeyAuthConfig, AudioResponse, ChaosAction, ChaosConfig, ChatCompletion, ChatCompletionChoice, ChatCompletionMessage, ChatCompletionRequest, ChatMessage, ContentPart, ContentWithToolCallsResponse, EmbeddingFixtureOpts, EmbeddingResponse, ErrorResponse, Fixture, FixtureBlock, FixtureFile, FixtureFileContentWithToolCallsResponse, FixtureFileEntry, FixtureFileResponse, FixtureFileTextResponse, FixtureFileToolCall, FixtureFileToolCallResponse, FixtureMatch, FixtureOpts, FixtureResponse, ImageItem, ImageResponse, JournalBody, JournalEntry, MockServerOptions, Mountable, RawJSONResponse, RecordConfig, RecordProviderKey, ResponseOverrides, SSEChoice, SSEChunk, SSEDelta, SSEToolCallDelta, StreamingProfile, TextResponse, ToolCall, ToolCallMessage, ToolCallResponse, ToolDefinition, TranscriptionResponse, VideoResponse, VoiceDesignPreview, VoiceDesignResponse } from "./types.js";
8
+ import { FixtureLoadError, FixtureLoadErrorJSON, MisbehaviorConfigError, MisbehaviorConfigErrorJSON, ValidationRef, ValidationResult, loadFixtureFile, loadFixturesFromDir, normalizeResponse, renderValidationRef, validateFixtures } from "./fixture-loader.js";
9
+ import { McpFakeAddOrigin, McpFakeAddResult, McpFakeBlockSnapshot, McpFakeDeclaredEntry, McpFakeIssue, McpFakeReportEvent, McpFakeReportPart, McpFakesAddError, McpFakesAddErrorJSON, RecordReplayLoadRule } from "./mcp-fakes.js";
10
+ import { ApiKeyAuthConfig, AudioResponse, ChaosAction, ChaosConfig, ChatCompletion, ChatCompletionChoice, ChatCompletionMessage, ChatCompletionRequest, ChatMessage, ContentPart, ContentWithToolCallsResponse, CustomToolCall, CustomToolCallMessage, CustomToolDefinition, EmbeddingFixtureOpts, EmbeddingResponse, ErrorResponse, Fixture, FixtureBlock, FixtureFile, FixtureFileContentWithToolCallsResponse, FixtureFileCustomToolCall, FixtureFileEntry, FixtureFileResponse, FixtureFileResponsesBlock, FixtureFileTextResponse, FixtureFileToolCall, FixtureFileToolCallResponse, FixtureMatch, FixtureOpts, FixtureResponse, FixtureToolCall, ImageItem, ImageResponse, JournalBody, JournalEntry, MCP_FAKE_ERROR_CODES, McpFakeAnnotations, McpFakeBlock, McpFakeCall, McpFakeCallAnswer, McpFakeCallMatch, McpFakeContentBlock, McpFakeDeepReadonly, McpFakeErrorCode, McpFakeFullResult, McpFakeIcon, McpFakeIdentity, McpFakeNotification, McpFakeOutcome, McpFakeRecorded, McpFakeResourceContents, McpFakeResult, McpFakeScope, McpFakeSource, McpFakeStructuredResult, McpFakeTool, McpFakeUndeclaredPolicy, McpRecordConfig, MisbehaviorConfig, MisbehaviorFault, MisbehaviorFaultId, MockServerOptions, Mountable, RawJSONResponse, RecordConfig, RecordProviderKey, ResponseOverrides, ResponsesFixtureBlock, ResponsesToolsMode, SSEChoice, SSEChunk, SSEDelta, SSEToolCallDelta, StreamingProfile, TextResponse, ToolCall, ToolCallMessage, ToolCallResponse, ToolDefinition, TranscriptionResponse, VideoResponse, VoiceDesignPreview, VoiceDesignResponse } from "./types.js";
7
11
  import { A2AAgentDefinition, A2AArtifact, A2AMessage, A2AMockOptions, A2APart, A2ARole, A2AStreamEvent, A2ATask, A2ATaskResponse, A2ATaskState } from "./a2a-types.js";
8
12
  import { A2AMock } from "./a2a-mock.js";
9
13
  import { AGUIActivityDeltaEvent, AGUIActivitySnapshotEvent, AGUIBaseEvent, AGUICustomEvent, AGUIEvent, AGUIEventType, AGUIFixture, AGUIFixtureMatch, AGUIInterrupt, AGUIMessage, AGUIMessageContentPart, AGUIMessageRole, AGUIMessagesSnapshotEvent, AGUIMockOptions, AGUIRawEvent, AGUIReasoningEncryptedValueEvent, AGUIReasoningEncryptedValueSubtype, AGUIReasoningEndEvent, AGUIReasoningMessageChunkEvent, AGUIReasoningMessageContentEvent, AGUIReasoningMessageEndEvent, AGUIReasoningMessageStartEvent, AGUIReasoningStartEvent, AGUIRecordConfig, AGUIResumeEntry, AGUIRunAgentInput, AGUIRunErrorEvent, AGUIRunFinishedEvent, AGUIRunFinishedOutcome, AGUIRunStartedEvent, AGUIStateDeltaEvent, AGUIStateSnapshotEvent, AGUIStepFinishedEvent, AGUIStepStartedEvent, AGUISubagentErrorEvent, AGUISubagentFinishedEvent, AGUISubagentFinishedOutcome, AGUISubagentStartedEvent, AGUITextMessageChunkEvent, AGUITextMessageContentEvent, AGUITextMessageEndEvent, AGUITextMessageRole, AGUITextMessageStartEvent, AGUIThinkingEndEvent, AGUIThinkingStartEvent, AGUIThinkingTextMessageContentEvent, AGUIThinkingTextMessageEndEvent, AGUIThinkingTextMessageStartEvent, AGUITokenUsage, AGUIToolCall, AGUIToolCallArgsEvent, AGUIToolCallChunkEvent, AGUIToolCallEndEvent, AGUIToolCallResultEvent, AGUIToolCallStartEvent, AGUIToolDefinition } from "./agui-types.js";
@@ -23,7 +27,7 @@ import { VEO_VIDEO_MAX_ENTRIES, VeoVideoJobMap, handleVeoVideoCreate, handleVeoV
23
27
  import { GROK_VIDEO_MAX_ENTRIES, GrokVideoJobMap, handleGrokVideoCreate, handleGrokVideoStatus } from "./grok-video.js";
24
28
  import { BYTEPLUS_VIDEO_MAX_ENTRIES, BYTEPLUS_VIDEO_TASKS_PATH, BytePlusVideoJobMap, buildBytePlusMatchText, handleBytePlusVideoCreate, handleBytePlusVideoStatus } from "./byteplus-video.js";
25
29
  import { ServerInstance, ServiceFixtures, createServer } from "./server.js";
26
- import { ValidationRef, ValidationResult, loadFixtureFile, loadFixturesFromDir, normalizeResponse, renderValidationRef, validateFixtures } from "./fixture-loader.js";
30
+ import { FixturesWithServices, loadFixtureFileWithServices, loadFixturesFromDirWithServices } from "./fixture-loader-services.js";
27
31
  import { MatchFixtureDiagnostic, getTextContent, matchFixture, matchFixtureDiagnostic } from "./router.js";
28
32
  import { ResponsesSSEEvent, buildContentWithToolCallsStreamEvents, buildTextStreamEvents, buildToolCallStreamEvents, handleResponses } from "./responses.js";
29
33
  import { handleMessages } from "./messages.js";
@@ -36,9 +40,11 @@ import { encodeEventStreamFrame, encodeEventStreamMessage, writeEventStream } fr
36
40
  import { NDJSONStreamOptions, writeNDJSONStream } from "./ndjson-writer.js";
37
41
  import { handleOllama, handleOllamaGenerate, ollamaToCompletionRequest } from "./ollama.js";
38
42
  import { cohereToCompletionRequest, handleCohere } from "./cohere.js";
43
+ import { CATALOG_ROUTES, CatalogRoute, buildOpenApiDocument } from "./openapi.js";
39
44
  import { BatchObject, clearBatchStore, handleBatchesCancel, handleBatchesCreate, handleBatchesList, handleBatchesRetrieve } from "./batches.js";
40
45
  import { FileObject, clearFileStore, handleFilesContent, handleFilesCreate, handleFilesDelete, handleFilesList, handleFilesRetrieve } from "./files.js";
41
46
  import { FineTuningJob, FineTuningJobError, FineTuningJobEvent, FineTuningJobHyperparameters, FineTuningJobStatus, clearFineTuningStore, handleFineTuningCancel, handleFineTuningCreate, handleFineTuningEvents, handleFineTuningList, handleFineTuningRetrieve } from "./fine-tuning.js";
47
+ import { VectorFileBatchObject, VectorFileBatchStatus, VectorSearchResult, VectorStoreFileObject, VectorStoreFileStatus, VectorStoreObject, VectorStoreStatus, clearVectorStoreStore, handleVectorFileBatchesCancel, handleVectorFileBatchesCreate, handleVectorFileBatchesFiles, handleVectorFileBatchesRetrieve, handleVectorStoreFilesCreate, handleVectorStoreFilesDelete, handleVectorStoreFilesList, handleVectorStoreFilesRetrieve, handleVectorStoresCreate, handleVectorStoresDelete, handleVectorStoresList, handleVectorStoresModify, handleVectorStoresRetrieve, handleVectorStoresSearch } from "./vector-stores.js";
42
48
  import { WebSocketConnection, WebSocketLimits, computeAcceptKey, upgradeToWebSocket } from "./ws-framing.js";
43
49
  import { handleWebSocketResponses } from "./ws-responses.js";
44
50
  import { handleWebSocketRealtime } from "./ws-realtime.js";
@@ -50,7 +56,7 @@ import { handleElevenLabsAudio } from "./elevenlabs-audio.js";
50
56
  import { clearElevenLabsVoices, handleElevenLabsVoiceCreate, handleElevenLabsVoiceDelete, handleElevenLabsVoiceDesign, handleElevenLabsVoiceGet, voiceDesignToJson } from "./elevenlabs-voice.js";
51
57
  import { handleFalQueue } from "./fal-audio.js";
52
58
  import { FalQueueStateMap, handleFal } from "./fal.js";
53
- import { 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 } from "./helpers.js";
59
+ import { 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 } from "./helpers.js";
54
60
  import { InterruptionControl, createInterruptionSignal } from "./interruption.js";
55
61
  import { ErrorResponseOptions, StreamOptions, calculateDelay, delay, writeErrorResponse, writeSSEStream } from "./sse-writer.js";
56
62
  import { ChaosAsyncOutcome, applyChaosAsync, applyChaosDeprecated, evaluateChaos, resolveChaosLatencyMs } from "./chaos.js";
@@ -58,7 +64,8 @@ import { proxyAndRecord } from "./recorder.js";
58
64
  import { resolveUpstreamUrl } from "./url.js";
59
65
  import { CollapseResult, MAX_COLLAPSE_STRING_LENGTH, collapseAnthropicSSE, collapseBedrockEventStream, collapseCohereSSE, collapseGeminiInteractionsSSE, collapseGeminiSSE, collapseOllamaNDJSON, collapseOpenAISSE, collapseStreamingResponse, setCollapseStringLimitForTests } from "./stream-collapse.js";
60
66
  import { MCPMock } from "./mcp-mock.js";
67
+ import { AimockFakesReportError, AimockTestIdCollisionError, McpFakesReport, assertFakesReport } from "./mcp-fakes-report.js";
61
68
  import { VectorMock } from "./vector-mock.js";
62
69
  import { JsonRpcDispatcherOptions, JsonRpcResponse, MethodHandler, createJsonRpcDispatcher } from "./jsonrpc.js";
63
70
  import { MockSuite, MockSuiteOptions, createMockSuite } from "./suite.js";
64
- export { type A2AAgentDefinition, type A2AArtifact, type A2AMessage, A2AMock, type A2AMockOptions, type A2APart, type A2ARole, type A2AStreamEvent, type A2ATask, type A2ATaskResponse, type A2ATaskState, type AGUIActivityDeltaEvent, type AGUIActivitySnapshotEvent, type AGUIBaseEvent, type AGUIBuildOpts, type AGUICustomEvent, type AGUIEvent, type AGUIEventType, type AGUIFixture, type AGUIFixtureMatch, type AGUIInterrupt, type AGUIMessage, type AGUIMessageContentPart, type AGUIMessageRole, type AGUIMessagesSnapshotEvent, AGUIMock, type AGUIMockOptions, type AGUIRawEvent, type AGUIReasoningEncryptedValueEvent, type AGUIReasoningEncryptedValueSubtype, type AGUIReasoningEndEvent, type AGUIReasoningMessageChunkEvent, type AGUIReasoningMessageContentEvent, type AGUIReasoningMessageEndEvent, type AGUIReasoningMessageStartEvent, type AGUIReasoningStartEvent, type AGUIRecordConfig, type AGUIResumeEntry, type AGUIRunAgentInput, type AGUIRunErrorEvent, type AGUIRunFinishedEvent, type AGUIRunFinishedOutcome, type AGUIRunStartedEvent, type AGUIStateDeltaEvent, type AGUIStateSnapshotEvent, type AGUIStepFinishedEvent, type AGUIStepStartedEvent, type AGUISubagentErrorEvent, type AGUISubagentFinishedEvent, type AGUISubagentFinishedOutcome, type AGUISubagentStartedEvent, type AGUITextMessageChunkEvent, type AGUITextMessageContentEvent, type AGUITextMessageEndEvent, type AGUITextMessageRole, type AGUITextMessageStartEvent, type AGUIThinkingEndEvent, type AGUIThinkingStartEvent, type AGUIThinkingTextMessageContentEvent, type AGUIThinkingTextMessageEndEvent, type AGUIThinkingTextMessageStartEvent, type AGUITokenUsage, type AGUIToolCall, type AGUIToolCallArgsEvent, type AGUIToolCallChunkEvent, type AGUIToolCallEndEvent, type AGUIToolCallResultEvent, type AGUIToolCallStartEvent, type AGUIToolDefinition, AGUI_RECORD_BUFFER_HARD_CEILING, type AimockConfig, type ApiKeyAuthConfig, type AudioResponse, BYTEPLUS_VIDEO_MAX_ENTRIES, BYTEPLUS_VIDEO_TASKS_PATH, type BatchObject, BytePlusVideoJobMap, type ChaosAction, type ChaosAsyncOutcome, type ChaosConfig, type ChatCompletion, type ChatCompletionChoice, type ChatCompletionMessage, type ChatCompletionRequest, type ChatMessage, type CollapseResult, type ContentPart, type ContentWithToolCallsResponse, DEFAULT_AGUI_RECORD_BUFFER_BYTES, DEFAULT_TEST_ID, type EmbeddingAPIResponse, type EmbeddingFixtureOpts, type EmbeddingResponse, type ErrorResponse, type ErrorResponseOptions, FORMAT_TO_CONTENT_TYPE, FalQueueStateMap, type FileObject, type FineTuningJob, type FineTuningJobError, type FineTuningJobEvent, type FineTuningJobHyperparameters, type FineTuningJobStatus, type Fixture, type FixtureBlock, type FixtureFile, type FixtureFileContentWithToolCallsResponse, type FixtureFileEntry, type FixtureFileResponse, type FixtureFileTextResponse, type FixtureFileToolCall, type FixtureFileToolCallResponse, type FixtureMatch, type FixtureOpts, type FixtureResponse, GROK_VIDEO_MAX_ENTRIES, GrokVideoJobMap, type ImageItem, type ImageResponse, type InterruptionControl, Journal, type JournalBody, type JournalEntry, type JsonRpcDispatcherOptions, type JsonRpcResponse, LLMock, type LiveBinding, type LiveEntry, type LiveFailureCategory, type LiveFixtureResponse, type LiveJson, type LiveMode, type LiveObject, type LiveOptions, type LivePosition, type LiveTranscript, type LogLevel, Logger, MAX_COLLAPSE_STRING_LENGTH, type MCPContent, MCPMock, type MCPMockOptions, type MCPPromptDefinition, type MCPPromptResult, type MCPResourceContent, type MCPResourceDefinition, type MCPSession, type MCPToolDefinition, type MatchFixtureDiagnostic, type MethodHandler, type MetricsRegistry, type MockServerOptions, type MockSuite, type MockSuiteOptions, type ModerationFixture, type ModerationResult, type Mountable, type NDJSONStreamOptions, OPENROUTER_VIDEO_DEFAULT_MAX_CONTENT_BYTES, OPENROUTER_VIDEO_MAX_ENTRIES, OpenRouterVideoJobMap, type QueryHandler, type QueryResult, type RawJSONResponse, type RecordConfig, type RecordProviderKey, type RerankFixture, type RerankResult, type ResponseOverrides, type ResponsesSSEEvent, type SSEChoice, type SSEChunk, type SSEDelta, type SSEToolCallDelta, type SearchFixture, type SearchResult, type ServerInstance, type ServiceFixtures, type StreamOptions, type StreamingProfile, type TextResponse, type ToolCall, type ToolCallMessage, type ToolCallResponse, type ToolDefinition, type TranscriptionResponse, VEO_VIDEO_MAX_ENTRIES, type ValidationRef, type ValidationResult, type VectorCollection, type VectorEntry, VectorMock, type VectorMockOptions, type VectorQuery, VeoVideoJobMap, type VideoResponse, VideoStateMap, type VoiceDesignPreview, type VoiceDesignResponse, WebSocketConnection, type WebSocketLimits, applyChaosDeprecated as applyChaos, applyChaosAsync, bedrockToCompletionRequest, buildActivityDelta as buildAGUIActivityDelta, buildActivityResponse as buildAGUIActivityResponse, buildCompositeResponse as buildAGUICompositeResponse, buildCustomEvent as buildAGUICustomEvent, buildErrorResponse as buildAGUIErrorResponse, buildMessagesSnapshot as buildAGUIMessagesSnapshot, buildRawEvent as buildAGUIRawEvent, buildReasoningChunk as buildAGUIReasoningChunk, buildReasoningEncryptedValue as buildAGUIReasoningEncryptedValue, buildReasoningResponse as buildAGUIReasoningResponse, buildStateDelta as buildAGUIStateDelta, buildStateUpdate as buildAGUIStateUpdate, buildStepWithText as buildAGUIStepWithText, buildTextChunkResponse as buildAGUITextChunkResponse, buildTextResponse as buildAGUITextResponse, buildToolCallChunk as buildAGUIToolCallChunk, buildToolCallResponse as buildAGUIToolCallResponse, buildBytePlusMatchText, buildContentWithToolCallsChunks, buildContentWithToolCallsCompletion, buildContentWithToolCallsStreamEvents, buildEmbeddingResponse, buildTextChunks, buildTextCompletion, buildTextStreamEvents, buildToolCallChunks, buildToolCallCompletion, buildToolCallStreamEvents, calculateDelay, clearBatchStore, clearElevenLabsVoices, clearFileStore, clearFineTuningStore, cohereToCompletionRequest, collapseAnthropicSSE, collapseBedrockEventStream, collapseCohereSSE, collapseGeminiInteractionsSSE, collapseGeminiSSE, collapseOllamaNDJSON, collapseOpenAISSE, collapseStreamingResponse, computeAcceptKey, converseToCompletionRequest, createInterruptionSignal, createJsonRpcDispatcher, createMetricsRegistry, createMockSuite, createServer, delay, encodeEventStreamFrame, encodeEventStreamMessage, evaluateChaos, extractLastUserMessage as extractAGUILastUserMessage, extractOverrides, findFixture as findAGUIFixture, flattenHeaders, formatToMime, geminiInteractionsToCompletionRequest, generateDeterministicEmbedding, generateId, generateMessageId, generateToolCallId, generateToolUseId, getLastMessageIfToolResult as getAGUILastMessageIfToolResult, getTextContent, handleBatchesCancel, handleBatchesCreate, handleBatchesList, handleBatchesRetrieve, handleBedrock, handleBedrockStream, handleBytePlusVideoCreate, handleBytePlusVideoStatus, handleCohere, handleConverse, handleConverseStream, handleElevenLabsAudio, handleElevenLabsVoiceCreate, handleElevenLabsVoiceDelete, handleElevenLabsVoiceDesign, handleElevenLabsVoiceGet, handleEmbeddings, handleFal, handleFalQueue, handleFilesContent, handleFilesCreate, handleFilesDelete, handleFilesList, handleFilesRetrieve, handleFineTuningCancel, handleFineTuningCreate, handleFineTuningEvents, handleFineTuningList, handleFineTuningRetrieve, handleGemini, handleGeminiInteractions, handleGrokVideoCreate, handleGrokVideoStatus, handleImages, handleMessages, handleModeration, handleOllama, handleOllamaGenerate, handleOpenRouterVideoContent, handleOpenRouterVideoCreate, handleOpenRouterVideoModels, handleOpenRouterVideoStatus, handleRerank, handleResponses, handleSearch, handleSpeech, handleTranscription, handleVeoVideoCreate, handleVeoVideoStatus, handleVideoCreate, handleVideoStatus, handleWebSocketGeminiLive, handleWebSocketRealtime, handleWebSocketResponses, isAudioResponse, isChatCompletionBody, isContentWithToolCallsResponse, isEmbeddingResponse, isErrorResponse, isImageResponse, isLiveResponse, isTextResponse, isToolCallResponse, isTranscriptionResponse, isVideoResponse, loadConfig, loadFixtureFile, loadFixturesFromDir, matchFixture, matchFixtureDiagnostic, matchesFixture as matchesAGUIFixture, normalizePathLabel, normalizeResponse, ollamaToCompletionRequest, proxyAndRecord, proxyAndRecordAGUI, renderValidationRef, resolveChaosLatencyMs, resolveFixtureBlocks, resolveRequestId, resolveUpstreamUrl, setAGUIRecordBufferCeilingForTests, setCollapseStringLimitForTests, startFromConfig, strictNoMatchLogLine, strictNoMatchMessage, upgradeToWebSocket, validateFixtures, voiceDesignToJson, writeAGUIEventStream, writeErrorResponse, writeEventStream, writeNDJSONStream, writeSSEStream };
71
+ export { type A2AAgentDefinition, type A2AArtifact, type A2AMessage, A2AMock, type A2AMockOptions, type A2APart, type A2ARole, type A2AStreamEvent, type A2ATask, type A2ATaskResponse, type A2ATaskState, type AGUIActivityDeltaEvent, type AGUIActivitySnapshotEvent, type AGUIBaseEvent, type AGUIBuildOpts, type AGUICustomEvent, type AGUIEvent, type AGUIEventType, type AGUIFixture, type AGUIFixtureMatch, type AGUIInterrupt, type AGUIMessage, type AGUIMessageContentPart, type AGUIMessageRole, type AGUIMessagesSnapshotEvent, AGUIMock, type AGUIMockOptions, type AGUIRawEvent, type AGUIReasoningEncryptedValueEvent, type AGUIReasoningEncryptedValueSubtype, type AGUIReasoningEndEvent, type AGUIReasoningMessageChunkEvent, type AGUIReasoningMessageContentEvent, type AGUIReasoningMessageEndEvent, type AGUIReasoningMessageStartEvent, type AGUIReasoningStartEvent, type AGUIRecordConfig, type AGUIResumeEntry, type AGUIRunAgentInput, type AGUIRunErrorEvent, type AGUIRunFinishedEvent, type AGUIRunFinishedOutcome, type AGUIRunStartedEvent, type AGUIStateDeltaEvent, type AGUIStateSnapshotEvent, type AGUIStepFinishedEvent, type AGUIStepStartedEvent, type AGUISubagentErrorEvent, type AGUISubagentFinishedEvent, type AGUISubagentFinishedOutcome, type AGUISubagentStartedEvent, type AGUITextMessageChunkEvent, type AGUITextMessageContentEvent, type AGUITextMessageEndEvent, type AGUITextMessageRole, type AGUITextMessageStartEvent, type AGUIThinkingEndEvent, type AGUIThinkingStartEvent, type AGUIThinkingTextMessageContentEvent, type AGUIThinkingTextMessageEndEvent, type AGUIThinkingTextMessageStartEvent, type AGUITokenUsage, type AGUIToolCall, type AGUIToolCallArgsEvent, type AGUIToolCallChunkEvent, type AGUIToolCallEndEvent, type AGUIToolCallResultEvent, type AGUIToolCallStartEvent, type AGUIToolDefinition, AGUI_RECORD_BUFFER_HARD_CEILING, type AimockConfig, AimockFakesReportError, AimockTestIdCollisionError, type ApiKeyAuthConfig, type AudioResponse, BYTEPLUS_VIDEO_MAX_ENTRIES, BYTEPLUS_VIDEO_TASKS_PATH, type BatchObject, BytePlusVideoJobMap, CATALOG_ROUTES, type CatalogRoute, type ChaosAction, type ChaosAsyncOutcome, type ChaosConfig, type ChatCompletion, type ChatCompletionChoice, type ChatCompletionMessage, type ChatCompletionRequest, type ChatMessage, type CollapseResult, type ContentPart, type ContentWithToolCallsResponse, type CustomToolCall, type CustomToolCallMessage, type CustomToolDefinition, DEFAULT_AGUI_RECORD_BUFFER_BYTES, DEFAULT_TEST_ID, type EmbeddingAPIResponse, type EmbeddingFixtureOpts, type EmbeddingResponse, type ErrorResponse, type ErrorResponseOptions, FORMAT_TO_CONTENT_TYPE, FalQueueStateMap, type FileObject, type FineTuningJob, type FineTuningJobError, type FineTuningJobEvent, type FineTuningJobHyperparameters, type FineTuningJobStatus, type Fixture, type FixtureBlock, type FixtureFile, type FixtureFileContentWithToolCallsResponse, type FixtureFileCustomToolCall, type FixtureFileEntry, type FixtureFileResponse, type FixtureFileResponsesBlock, type FixtureFileTextResponse, type FixtureFileToolCall, type FixtureFileToolCallResponse, FixtureLoadError, type FixtureLoadErrorJSON, type FixtureMatch, type FixtureOpts, type FixtureResponse, type FixtureToolCall, type FixturesWithServices, type FunctionFixtureBlock, GROK_VIDEO_MAX_ENTRIES, GrokVideoJobMap, type ImageItem, type ImageResponse, type InterruptionControl, InvalidFixtureToolCallError, Journal, type JournalBody, type JournalEntry, type JsonRpcDispatcherOptions, type JsonRpcResponse, LLMock, type LiveBinding, type LiveEntry, type LiveFailureCategory, type LiveFixtureResponse, type LiveJson, type LiveMode, type LiveObject, type LiveOptions, type LivePosition, type LiveTranscript, type LogLevel, Logger, MAX_COLLAPSE_STRING_LENGTH, type MCPContent, MCPMock, type MCPMockOptions, type MCPPromptDefinition, type MCPPromptResult, type MCPResourceContent, type MCPResourceDefinition, type MCPSession, type MCPToolDefinition, MCP_FAKE_ERROR_CODES, type MatchFixtureDiagnostic, type McpFakeAddOrigin, type McpFakeAddResult, type McpFakeAnnotations, type McpFakeBlock, type McpFakeBlockSnapshot, type McpFakeCall, type McpFakeCallAnswer, type McpFakeCallMatch, type McpFakeContentBlock, type McpFakeDeclaredEntry, type McpFakeDeepReadonly, type McpFakeErrorCode, type McpFakeFullResult, type McpFakeIcon, type McpFakeIdentity, type McpFakeIssue, type McpFakeNotification, type McpFakeOutcome, type McpFakeRecorded, type McpFakeReportEvent, type McpFakeReportPart, type McpFakeResourceContents, type McpFakeResult, type McpFakeScope, type McpFakeSource, type McpFakeStructuredResult, type McpFakeTool, type McpFakeUndeclaredPolicy, McpFakesAddError, type McpFakesAddErrorJSON, type McpFakesReport, type McpRecordConfig, type MethodHandler, type MetricsRegistry, type MisbehaviorConfig, MisbehaviorConfigError, type MisbehaviorConfigErrorJSON, type MisbehaviorFault, type MisbehaviorFaultId, type MisbehaviorRule, type MockServerOptions, type MockSuite, type MockSuiteOptions, type ModerationFixture, type ModerationResult, type Mountable, type NDJSONStreamOptions, OPENROUTER_VIDEO_DEFAULT_MAX_CONTENT_BYTES, OPENROUTER_VIDEO_MAX_ENTRIES, OpenRouterVideoJobMap, type QueryHandler, type QueryResult, ROUTE_DEFINITIONS, type RawJSONResponse, type RecordConfig, type RecordProviderKey, type RecordReplayLoadRule, type RerankFixture, type RerankResult, type ResponseOverrides, type ResponsesFixtureBlock, type ResponsesSSEEvent, type ResponsesToolsMode, type RouteDefinition, type SSEChoice, type SSEChunk, type SSEDelta, type SSEToolCallDelta, type SearchFixture, type SearchResult, type ServerInstance, type ServiceFixtures, type StreamOptions, type StreamingProfile, type TextResponse, type ToolCall, type ToolCallMessage, type ToolCallResponse, type ToolDefinition, type TranscriptionResponse, UnsupportedToolCallError, VEO_VIDEO_MAX_ENTRIES, type ValidationRef, type ValidationResult, type VectorCollection, type VectorEntry, type VectorFileBatchObject, type VectorFileBatchStatus, VectorMock, type VectorMockOptions, type VectorQuery, type VectorSearchResult, type VectorStoreFileObject, type VectorStoreFileStatus, type VectorStoreObject, type VectorStoreStatus, VeoVideoJobMap, type VideoResponse, VideoStateMap, type VoiceDesignPreview, type VoiceDesignResponse, WebSocketConnection, type WebSocketLimits, applyChaosDeprecated as applyChaos, applyChaosAsync, assertFakesReport, bedrockToCompletionRequest, buildActivityDelta as buildAGUIActivityDelta, buildActivityResponse as buildAGUIActivityResponse, buildCompositeResponse as buildAGUICompositeResponse, buildCustomEvent as buildAGUICustomEvent, buildErrorResponse as buildAGUIErrorResponse, buildMessagesSnapshot as buildAGUIMessagesSnapshot, buildRawEvent as buildAGUIRawEvent, buildReasoningChunk as buildAGUIReasoningChunk, buildReasoningEncryptedValue as buildAGUIReasoningEncryptedValue, buildReasoningResponse as buildAGUIReasoningResponse, buildStateDelta as buildAGUIStateDelta, buildStateUpdate as buildAGUIStateUpdate, buildStepWithText as buildAGUIStepWithText, buildTextChunkResponse as buildAGUITextChunkResponse, buildTextResponse as buildAGUITextResponse, buildToolCallChunk as buildAGUIToolCallChunk, buildToolCallResponse as buildAGUIToolCallResponse, buildBytePlusMatchText, buildContentWithToolCallsChunks, buildContentWithToolCallsCompletion, buildContentWithToolCallsStreamEvents, buildEmbeddingResponse, buildOpenApiDocument, buildTextChunks, buildTextCompletion, buildTextStreamEvents, buildToolCallChunks, buildToolCallCompletion, buildToolCallStreamEvents, calculateDelay, clearBatchStore, clearElevenLabsVoices, clearFileStore, clearFineTuningStore, clearVectorStoreStore, cohereToCompletionRequest, collapseAnthropicSSE, collapseBedrockEventStream, collapseCohereSSE, collapseGeminiInteractionsSSE, collapseGeminiSSE, collapseOllamaNDJSON, collapseOpenAISSE, collapseStreamingResponse, computeAcceptKey, converseToCompletionRequest, createInterruptionSignal, createJsonRpcDispatcher, createMetricsRegistry, createMockSuite, createServer, delay, encodeEventStreamFrame, encodeEventStreamMessage, evaluateChaos, extractLastUserMessage as extractAGUILastUserMessage, extractOverrides, findFixture as findAGUIFixture, flattenHeaders, formatToMime, geminiInteractionsToCompletionRequest, generateDeterministicEmbedding, generateId, generateMessageId, generateToolCallId, generateToolUseId, getLastMessageIfToolResult as getAGUILastMessageIfToolResult, getTextContent, handleBatchesCancel, handleBatchesCreate, handleBatchesList, handleBatchesRetrieve, handleBedrock, handleBedrockStream, handleBytePlusVideoCreate, handleBytePlusVideoStatus, handleCohere, handleConverse, handleConverseStream, handleElevenLabsAudio, handleElevenLabsVoiceCreate, handleElevenLabsVoiceDelete, handleElevenLabsVoiceDesign, handleElevenLabsVoiceGet, handleEmbeddings, handleFal, handleFalQueue, handleFilesContent, handleFilesCreate, handleFilesDelete, handleFilesList, handleFilesRetrieve, handleFineTuningCancel, handleFineTuningCreate, handleFineTuningEvents, handleFineTuningList, handleFineTuningRetrieve, handleGemini, handleGeminiInteractions, handleGrokVideoCreate, handleGrokVideoStatus, handleImages, handleMessages, handleModeration, handleOllama, handleOllamaGenerate, handleOpenRouterVideoContent, handleOpenRouterVideoCreate, handleOpenRouterVideoModels, handleOpenRouterVideoStatus, handleRerank, handleResponses, handleSearch, handleSpeech, handleTranscription, handleVectorFileBatchesCancel, handleVectorFileBatchesCreate, handleVectorFileBatchesFiles, handleVectorFileBatchesRetrieve, handleVectorStoreFilesCreate, handleVectorStoreFilesDelete, handleVectorStoreFilesList, handleVectorStoreFilesRetrieve, handleVectorStoresCreate, handleVectorStoresDelete, handleVectorStoresList, handleVectorStoresModify, handleVectorStoresRetrieve, handleVectorStoresSearch, handleVeoVideoCreate, handleVeoVideoStatus, handleVideoCreate, handleVideoStatus, handleWebSocketGeminiLive, handleWebSocketRealtime, handleWebSocketResponses, isAudioResponse, isChatCompletionBody, isContentWithToolCallsResponse, isEmbeddingResponse, isErrorResponse, isImageResponse, isLiveResponse, isTextResponse, isToolCallResponse, isTranscriptionResponse, isVideoResponse, loadConfig, loadFixtureFile, loadFixtureFileWithServices, loadFixturesFromDir, loadFixturesFromDirWithServices, matchFixture, matchFixtureDiagnostic, matchesFixture as matchesAGUIFixture, normalizePathLabel, normalizeResponse, ollamaToCompletionRequest, proxyAndRecord, proxyAndRecordAGUI, renderValidationRef, requireFunctionToolCalls, resolveChaosLatencyMs, resolveFixtureBlocks, resolveRequestId, resolveResponsesBlocks, resolveUpstreamUrl, setAGUIRecordBufferCeilingForTests, setCollapseStringLimitForTests, startFromConfig, strictNoMatchLogLine, strictNoMatchMessage, upgradeToWebSocket, validateFixtures, voiceDesignToJson, writeAGUIEventStream, writeErrorResponse, writeEventStream, writeNDJSONStream, writeSSEStream };
package/dist/index.js CHANGED
@@ -1,11 +1,11 @@
1
1
  import { DEFAULT_TEST_ID } from "./constants.js";
2
- import { 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 } from "./helpers.js";
2
+ import { FORMAT_TO_CONTENT_TYPE, 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 } from "./helpers.js";
3
3
  import { createJsonRpcDispatcher } from "./jsonrpc.js";
4
4
  import { A2AMock } from "./a2a-mock.js";
5
5
  import { buildActivityDelta, buildActivityResponse, buildCompositeResponse, buildCustomEvent, buildErrorResponse, buildMessagesSnapshot, buildRawEvent, buildReasoningChunk, buildReasoningEncryptedValue, buildReasoningResponse, buildStateDelta, buildStateUpdate, buildStepWithText, buildTextChunkResponse, buildTextResponse, buildToolCallChunk, buildToolCallResponse, extractLastUserMessage, findFixture, getLastMessageIfToolResult, matchesFixture, writeAGUIEventStream } from "./agui-handler.js";
6
6
  import { calculateDelay, delay, writeErrorResponse, writeSSEStream } from "./sse-writer.js";
7
7
  import { applyChaosAsync, applyChaosDeprecated, evaluateChaos, resolveChaosLatencyMs } from "./chaos.js";
8
- import { loadFixtureFile, loadFixturesFromDir, normalizeResponse, renderValidationRef, validateFixtures } from "./fixture-loader.js";
8
+ import { FixtureLoadError, MisbehaviorConfigError, loadFixtureFile, loadFixturesFromDir, normalizeResponse, renderValidationRef, validateFixtures } from "./fixture-loader.js";
9
9
  import { getTextContent, matchFixture, matchFixtureDiagnostic } from "./router.js";
10
10
  import { MAX_COLLAPSE_STRING_LENGTH, collapseAnthropicSSE, collapseBedrockEventStream, collapseCohereSSE, collapseGeminiInteractionsSSE, collapseGeminiSSE, collapseOllamaNDJSON, collapseOpenAISSE, collapseStreamingResponse, setCollapseStringLimitForTests } from "./stream-collapse.js";
11
11
  import { resolveUpstreamUrl } from "./url.js";
@@ -42,18 +42,25 @@ import { handleSearch } from "./search.js";
42
42
  import { handleRerank } from "./rerank.js";
43
43
  import { handleModeration } from "./moderation.js";
44
44
  import { clearFineTuningStore, handleFineTuningCancel, handleFineTuningCreate, handleFineTuningEvents, handleFineTuningList, handleFineTuningRetrieve } from "./fine-tuning.js";
45
+ import { clearVectorStoreStore, handleVectorFileBatchesCancel, handleVectorFileBatchesCreate, handleVectorFileBatchesFiles, handleVectorFileBatchesRetrieve, handleVectorStoreFilesCreate, handleVectorStoreFilesDelete, handleVectorStoreFilesList, handleVectorStoreFilesRetrieve, handleVectorStoresCreate, handleVectorStoresDelete, handleVectorStoresList, handleVectorStoresModify, handleVectorStoresRetrieve, handleVectorStoresSearch } from "./vector-stores.js";
45
46
  import { clearFileStore, handleFilesContent, handleFilesCreate, handleFilesDelete, handleFilesList, handleFilesRetrieve } from "./files.js";
46
47
  import { clearBatchStore, handleBatchesCancel, handleBatchesCreate, handleBatchesList, handleBatchesRetrieve } from "./batches.js";
47
48
  import { WebSocketConnection, computeAcceptKey, upgradeToWebSocket } from "./ws-framing.js";
48
49
  import { handleWebSocketResponses } from "./ws-responses.js";
49
50
  import { handleWebSocketRealtime } from "./ws-realtime.js";
50
51
  import { handleWebSocketGeminiLive } from "./ws-gemini-live.js";
52
+ import { ROUTE_DEFINITIONS } from "./route-registry.js";
53
+ import { CATALOG_ROUTES, buildOpenApiDocument } from "./openapi.js";
51
54
  import { createMetricsRegistry, normalizePathLabel } from "./metrics.js";
55
+ import { MCP_FAKE_ERROR_CODES } from "./types.js";
56
+ import { McpFakesAddError } from "./mcp-fakes.js";
57
+ import { MCPMock } from "./mcp-mock.js";
58
+ import { AimockFakesReportError, AimockTestIdCollisionError, assertFakesReport } from "./mcp-fakes-report.js";
52
59
  import { createServer } from "./server.js";
60
+ import { loadFixtureFileWithServices, loadFixturesFromDirWithServices } from "./fixture-loader-services.js";
53
61
  import { LLMock } from "./llmock.js";
54
- import { MCPMock } from "./mcp-mock.js";
55
62
  import { VectorMock } from "./vector-mock.js";
56
63
  import { loadConfig, startFromConfig } from "./config-loader.js";
57
64
  import { createMockSuite } from "./suite.js";
58
65
 
59
- export { A2AMock, AGUIMock, AGUI_RECORD_BUFFER_HARD_CEILING, BYTEPLUS_VIDEO_MAX_ENTRIES, BYTEPLUS_VIDEO_TASKS_PATH, BytePlusVideoJobMap, DEFAULT_AGUI_RECORD_BUFFER_BYTES, DEFAULT_TEST_ID, FORMAT_TO_CONTENT_TYPE, FalQueueStateMap, GROK_VIDEO_MAX_ENTRIES, GrokVideoJobMap, Journal, LLMock, Logger, MAX_COLLAPSE_STRING_LENGTH, MCPMock, OPENROUTER_VIDEO_DEFAULT_MAX_CONTENT_BYTES, OPENROUTER_VIDEO_MAX_ENTRIES, OpenRouterVideoJobMap, VEO_VIDEO_MAX_ENTRIES, VectorMock, VeoVideoJobMap, VideoStateMap, WebSocketConnection, applyChaosDeprecated as applyChaos, applyChaosAsync, bedrockToCompletionRequest, buildActivityDelta as buildAGUIActivityDelta, buildActivityResponse as buildAGUIActivityResponse, buildCompositeResponse as buildAGUICompositeResponse, buildCustomEvent as buildAGUICustomEvent, buildErrorResponse as buildAGUIErrorResponse, buildMessagesSnapshot as buildAGUIMessagesSnapshot, buildRawEvent as buildAGUIRawEvent, buildReasoningChunk as buildAGUIReasoningChunk, buildReasoningEncryptedValue as buildAGUIReasoningEncryptedValue, buildReasoningResponse as buildAGUIReasoningResponse, buildStateDelta as buildAGUIStateDelta, buildStateUpdate as buildAGUIStateUpdate, buildStepWithText as buildAGUIStepWithText, buildTextChunkResponse as buildAGUITextChunkResponse, buildTextResponse as buildAGUITextResponse, buildToolCallChunk as buildAGUIToolCallChunk, buildToolCallResponse as buildAGUIToolCallResponse, buildBytePlusMatchText, buildContentWithToolCallsChunks, buildContentWithToolCallsCompletion, buildContentWithToolCallsStreamEvents, buildEmbeddingResponse, buildTextChunks, buildTextCompletion, buildTextStreamEvents, buildToolCallChunks, buildToolCallCompletion, buildToolCallStreamEvents, calculateDelay, clearBatchStore, clearElevenLabsVoices, clearFileStore, clearFineTuningStore, cohereToCompletionRequest, collapseAnthropicSSE, collapseBedrockEventStream, collapseCohereSSE, collapseGeminiInteractionsSSE, collapseGeminiSSE, collapseOllamaNDJSON, collapseOpenAISSE, collapseStreamingResponse, computeAcceptKey, converseToCompletionRequest, createInterruptionSignal, createJsonRpcDispatcher, createMetricsRegistry, createMockSuite, createServer, delay, encodeEventStreamFrame, encodeEventStreamMessage, evaluateChaos, extractLastUserMessage as extractAGUILastUserMessage, extractOverrides, findFixture as findAGUIFixture, flattenHeaders, formatToMime, geminiInteractionsToCompletionRequest, generateDeterministicEmbedding, generateId, generateMessageId, generateToolCallId, generateToolUseId, getLastMessageIfToolResult as getAGUILastMessageIfToolResult, getTextContent, handleBatchesCancel, handleBatchesCreate, handleBatchesList, handleBatchesRetrieve, handleBedrock, handleBedrockStream, handleBytePlusVideoCreate, handleBytePlusVideoStatus, handleCohere, handleConverse, handleConverseStream, handleElevenLabsAudio, handleElevenLabsVoiceCreate, handleElevenLabsVoiceDelete, handleElevenLabsVoiceDesign, handleElevenLabsVoiceGet, handleEmbeddings, handleFal, handleFalQueue, handleFilesContent, handleFilesCreate, handleFilesDelete, handleFilesList, handleFilesRetrieve, handleFineTuningCancel, handleFineTuningCreate, handleFineTuningEvents, handleFineTuningList, handleFineTuningRetrieve, handleGemini, handleGeminiInteractions, handleGrokVideoCreate, handleGrokVideoStatus, handleImages, handleMessages, handleModeration, handleOllama, handleOllamaGenerate, handleOpenRouterVideoContent, handleOpenRouterVideoCreate, handleOpenRouterVideoModels, handleOpenRouterVideoStatus, handleRerank, handleResponses, handleSearch, handleSpeech, handleTranscription, handleVeoVideoCreate, handleVeoVideoStatus, handleVideoCreate, handleVideoStatus, handleWebSocketGeminiLive, handleWebSocketRealtime, handleWebSocketResponses, isAudioResponse, isChatCompletionBody, isContentWithToolCallsResponse, isEmbeddingResponse, isErrorResponse, isImageResponse, isLiveResponse, isTextResponse, isToolCallResponse, isTranscriptionResponse, isVideoResponse, loadConfig, loadFixtureFile, loadFixturesFromDir, matchFixture, matchFixtureDiagnostic, matchesFixture as matchesAGUIFixture, normalizePathLabel, normalizeResponse, ollamaToCompletionRequest, proxyAndRecord, proxyAndRecordAGUI, renderValidationRef, resolveChaosLatencyMs, resolveFixtureBlocks, resolveRequestId, resolveUpstreamUrl, setAGUIRecordBufferCeilingForTests, setCollapseStringLimitForTests, startFromConfig, strictNoMatchLogLine, strictNoMatchMessage, upgradeToWebSocket, validateFixtures, voiceDesignToJson, writeAGUIEventStream, writeErrorResponse, writeEventStream, writeNDJSONStream, writeSSEStream };
66
+ export { A2AMock, AGUIMock, AGUI_RECORD_BUFFER_HARD_CEILING, AimockFakesReportError, AimockTestIdCollisionError, BYTEPLUS_VIDEO_MAX_ENTRIES, BYTEPLUS_VIDEO_TASKS_PATH, BytePlusVideoJobMap, CATALOG_ROUTES, DEFAULT_AGUI_RECORD_BUFFER_BYTES, DEFAULT_TEST_ID, FORMAT_TO_CONTENT_TYPE, FalQueueStateMap, FixtureLoadError, GROK_VIDEO_MAX_ENTRIES, GrokVideoJobMap, InvalidFixtureToolCallError, Journal, LLMock, Logger, MAX_COLLAPSE_STRING_LENGTH, MCPMock, MCP_FAKE_ERROR_CODES, McpFakesAddError, MisbehaviorConfigError, OPENROUTER_VIDEO_DEFAULT_MAX_CONTENT_BYTES, OPENROUTER_VIDEO_MAX_ENTRIES, OpenRouterVideoJobMap, ROUTE_DEFINITIONS, UnsupportedToolCallError, VEO_VIDEO_MAX_ENTRIES, VectorMock, VeoVideoJobMap, VideoStateMap, WebSocketConnection, applyChaosDeprecated as applyChaos, applyChaosAsync, assertFakesReport, bedrockToCompletionRequest, buildActivityDelta as buildAGUIActivityDelta, buildActivityResponse as buildAGUIActivityResponse, buildCompositeResponse as buildAGUICompositeResponse, buildCustomEvent as buildAGUICustomEvent, buildErrorResponse as buildAGUIErrorResponse, buildMessagesSnapshot as buildAGUIMessagesSnapshot, buildRawEvent as buildAGUIRawEvent, buildReasoningChunk as buildAGUIReasoningChunk, buildReasoningEncryptedValue as buildAGUIReasoningEncryptedValue, buildReasoningResponse as buildAGUIReasoningResponse, buildStateDelta as buildAGUIStateDelta, buildStateUpdate as buildAGUIStateUpdate, buildStepWithText as buildAGUIStepWithText, buildTextChunkResponse as buildAGUITextChunkResponse, buildTextResponse as buildAGUITextResponse, buildToolCallChunk as buildAGUIToolCallChunk, buildToolCallResponse as buildAGUIToolCallResponse, buildBytePlusMatchText, buildContentWithToolCallsChunks, buildContentWithToolCallsCompletion, buildContentWithToolCallsStreamEvents, buildEmbeddingResponse, buildOpenApiDocument, buildTextChunks, buildTextCompletion, buildTextStreamEvents, buildToolCallChunks, buildToolCallCompletion, buildToolCallStreamEvents, calculateDelay, clearBatchStore, clearElevenLabsVoices, clearFileStore, clearFineTuningStore, clearVectorStoreStore, cohereToCompletionRequest, collapseAnthropicSSE, collapseBedrockEventStream, collapseCohereSSE, collapseGeminiInteractionsSSE, collapseGeminiSSE, collapseOllamaNDJSON, collapseOpenAISSE, collapseStreamingResponse, computeAcceptKey, converseToCompletionRequest, createInterruptionSignal, createJsonRpcDispatcher, createMetricsRegistry, createMockSuite, createServer, delay, encodeEventStreamFrame, encodeEventStreamMessage, evaluateChaos, extractLastUserMessage as extractAGUILastUserMessage, extractOverrides, findFixture as findAGUIFixture, flattenHeaders, formatToMime, geminiInteractionsToCompletionRequest, generateDeterministicEmbedding, generateId, generateMessageId, generateToolCallId, generateToolUseId, getLastMessageIfToolResult as getAGUILastMessageIfToolResult, getTextContent, handleBatchesCancel, handleBatchesCreate, handleBatchesList, handleBatchesRetrieve, handleBedrock, handleBedrockStream, handleBytePlusVideoCreate, handleBytePlusVideoStatus, handleCohere, handleConverse, handleConverseStream, handleElevenLabsAudio, handleElevenLabsVoiceCreate, handleElevenLabsVoiceDelete, handleElevenLabsVoiceDesign, handleElevenLabsVoiceGet, handleEmbeddings, handleFal, handleFalQueue, handleFilesContent, handleFilesCreate, handleFilesDelete, handleFilesList, handleFilesRetrieve, handleFineTuningCancel, handleFineTuningCreate, handleFineTuningEvents, handleFineTuningList, handleFineTuningRetrieve, handleGemini, handleGeminiInteractions, handleGrokVideoCreate, handleGrokVideoStatus, handleImages, handleMessages, handleModeration, handleOllama, handleOllamaGenerate, handleOpenRouterVideoContent, handleOpenRouterVideoCreate, handleOpenRouterVideoModels, handleOpenRouterVideoStatus, handleRerank, handleResponses, handleSearch, handleSpeech, handleTranscription, handleVectorFileBatchesCancel, handleVectorFileBatchesCreate, handleVectorFileBatchesFiles, handleVectorFileBatchesRetrieve, handleVectorStoreFilesCreate, handleVectorStoreFilesDelete, handleVectorStoreFilesList, handleVectorStoreFilesRetrieve, handleVectorStoresCreate, handleVectorStoresDelete, handleVectorStoresList, handleVectorStoresModify, handleVectorStoresRetrieve, handleVectorStoresSearch, handleVeoVideoCreate, handleVeoVideoStatus, handleVideoCreate, handleVideoStatus, handleWebSocketGeminiLive, handleWebSocketRealtime, handleWebSocketResponses, isAudioResponse, isChatCompletionBody, isContentWithToolCallsResponse, isEmbeddingResponse, isErrorResponse, isImageResponse, isLiveResponse, isTextResponse, isToolCallResponse, isTranscriptionResponse, isVideoResponse, loadConfig, loadFixtureFile, loadFixtureFileWithServices, loadFixturesFromDir, loadFixturesFromDirWithServices, matchFixture, matchFixtureDiagnostic, matchesFixture as matchesAGUIFixture, normalizePathLabel, normalizeResponse, ollamaToCompletionRequest, proxyAndRecord, proxyAndRecordAGUI, renderValidationRef, requireFunctionToolCalls, resolveChaosLatencyMs, resolveFixtureBlocks, resolveRequestId, resolveResponsesBlocks, resolveUpstreamUrl, setAGUIRecordBufferCeilingForTests, setCollapseStringLimitForTests, startFromConfig, strictNoMatchLogLine, strictNoMatchMessage, upgradeToWebSocket, validateFixtures, voiceDesignToJson, writeAGUIEventStream, writeErrorResponse, writeEventStream, writeNDJSONStream, writeSSEStream };
package/dist/jest.cjs CHANGED
@@ -1,17 +1,28 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
3
3
  const require_fixture_loader = require('./fixture-loader.cjs');
4
+ const require_mcp_fakes_report = require('./mcp-fakes-report.cjs');
4
5
  const require_llmock = require('./llmock.cjs');
6
+ const require_fakes_plugin = require('./fakes-plugin.cjs');
5
7
  let node_fs = require("node:fs");
6
8
  let node_path = require("node:path");
7
9
 
8
10
  //#region src/jest.ts
11
+ /** TI2: `<testPath relative to root, with "/"> › <currentTestName>`. */
12
+ function defaultJestId(root) {
13
+ const { testPath, currentTestName } = expect.getState();
14
+ if (!testPath || currentTestName === void 0) throw new require_mcp_fakes_report.AimockTestIdCollisionError("default test ids are not supported here (concurrent test or no running test); pass an explicit testId");
15
+ return (0, node_path.relative)(root, testPath).split(node_path.sep).join("/") + require_fakes_plugin.TEST_ID_SEPARATOR + currentTestName;
16
+ }
9
17
  /**
10
18
  * Start an aimock server for the duration of the test suite.
11
19
  *
12
- * - `beforeAll`: starts the server and optionally loads fixtures
13
- * - `beforeEach`: closes Live sessions and resets fixture match counts (not fixtures)
14
- * - `afterEach`: closes Live sessions owned by this helper's server
20
+ * - `beforeAll`: starts the server and optionally loads fixtures (LLM fixtures and
21
+ * `mcpFakes` blocks; a bad `mcpFakes` block fails `beforeAll`)
22
+ * - `beforeEach`: closes Live sessions and resets fixture match counts and MCP fake
23
+ * consumption (not fixtures or fakes)
24
+ * - `afterEach`: closes Live sessions owned by this helper's server, then checks
25
+ * the MCP fake report under `fakesReport: "warn" | "fail"`
15
26
  * - `afterAll`: stops the server
16
27
  *
17
28
  * Returns a getter function — call it inside tests to access the handle.
@@ -23,13 +34,13 @@ function useAimock(options = {}) {
23
34
  let handle = null;
24
35
  let origOpenaiUrl;
25
36
  let origAnthropicUrl;
37
+ const root = (0, node_path.resolve)(options.testIdRoot ?? process.cwd());
38
+ let state = new require_fakes_plugin.FakesPluginState("off");
26
39
  beforeAll(async () => {
27
- const { fixtures: fixturePath, patchEnv, ...serverOpts } = options;
40
+ const { fixtures: fixturePath, patchEnv, fakesReport, testIdRoot, ...serverOpts } = options;
41
+ state = new require_fakes_plugin.FakesPluginState(require_fakes_plugin.fakesReportMode(fakesReport));
28
42
  const llm = new require_llmock.LLMock(serverOpts);
29
- if (fixturePath) {
30
- const loadedFixtures = loadFixtures((0, node_path.resolve)(fixturePath), options.live);
31
- for (const f of loadedFixtures) llm.addFixture(f);
32
- }
43
+ if (fixturePath) loadFixtures(llm, (0, node_path.resolve)(fixturePath));
33
44
  const url = await llm.start();
34
45
  if (patchEnv !== false) {
35
46
  origOpenaiUrl = process.env.OPENAI_BASE_URL;
@@ -39,17 +50,27 @@ function useAimock(options = {}) {
39
50
  }
40
51
  handle = {
41
52
  llm,
42
- url
53
+ url,
54
+ fakesFor(testId, opts = {}) {
55
+ const id = testId ?? defaultJestId(root);
56
+ state.register(id, opts.context ?? null);
57
+ return require_fakes_plugin.fakesTarget(url, id, opts);
58
+ },
59
+ fakesReport(testId, opts = {}) {
60
+ return require_fakes_plugin.fetchFakesReport(url, testId ?? defaultJestId(root), opts.context ?? null);
61
+ }
43
62
  };
44
63
  });
45
64
  beforeEach(() => {
46
65
  if (handle) {
47
66
  handle.llm.closeLiveSessions();
48
67
  handle.llm.resetMatchCounts();
68
+ state.beforeEach(handle.llm);
49
69
  }
50
70
  });
51
- afterEach(() => {
71
+ afterEach(async () => {
52
72
  handle?.llm.closeLiveSessions();
73
+ if (handle) await state.afterEach(handle.llm, handle.url);
53
74
  });
54
75
  afterAll(async () => {
55
76
  if (handle) {
@@ -68,13 +89,21 @@ function useAimock(options = {}) {
68
89
  return handle;
69
90
  };
70
91
  }
71
- function loadFixtures(fixturePath, liveOptions) {
92
+ /**
93
+ * Load a fixture file or directory into `llm`: its LLM fixtures and its
94
+ * `mcpFakes` blocks, which the LLMock buffers and auto-mounts at start (F12).
95
+ * A `FixtureLoadError` (a bad `mcpFakes` block) or a `MisbehaviorConfigError`
96
+ * (a bad fixture `misbehavior` key, thrown only with `enableMisbehavior: true`)
97
+ * propagates and fails `beforeAll`; any other load failure is only warned
98
+ * about, as before.
99
+ */
100
+ function loadFixtures(llm, fixturePath) {
72
101
  try {
73
- if ((0, node_fs.statSync)(fixturePath).isDirectory()) return require_fixture_loader.loadFixturesFromDir(fixturePath, void 0, liveOptions);
74
- return require_fixture_loader.loadFixtureFile(fixturePath, void 0, liveOptions);
102
+ if ((0, node_fs.statSync)(fixturePath).isDirectory()) llm.loadFixtureDir(fixturePath);
103
+ else llm.loadFixtureFile(fixturePath);
75
104
  } catch (err) {
105
+ if (err instanceof require_fixture_loader.FixtureLoadError || err instanceof require_fixture_loader.MisbehaviorConfigError) throw err;
76
106
  console.warn(`[aimock] Failed to load fixtures from ${fixturePath}: ${err instanceof Error ? err.message : String(err)}`);
77
- return [];
78
107
  }
79
108
  }
80
109
 
package/dist/jest.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"jest.cjs","names":["LLMock","loadFixturesFromDir","loadFixtureFile"],"sources":["../src/jest.ts"],"sourcesContent":["/**\n * Jest integration for aimock.\n *\n * Usage:\n * import { useAimock } from \"@copilotkit/aimock/jest\";\n *\n * const mock = useAimock({ fixtures: \"./fixtures\" });\n *\n * it(\"responds\", async () => {\n * const res = await fetch(`${mock().url}/v1/chat/completions`, { ... });\n * });\n */\n\n/* eslint-disable no-var */\n// Jest globals — available at runtime in jest test files\ndeclare var beforeAll: (fn: () => Promise<void> | void, timeout?: number) => void;\ndeclare var afterAll: (fn: () => Promise<void> | void, timeout?: number) => void;\ndeclare var beforeEach: (fn: () => Promise<void> | void, timeout?: number) => void;\ndeclare var afterEach: (fn: () => Promise<void> | void, timeout?: number) => void;\n/* eslint-enable no-var */\n\nimport { LLMock } from \"./llmock.js\";\nimport { loadFixtureFile, loadFixturesFromDir } from \"./fixture-loader.js\";\nimport type { LiveOptions } from \"./live-types.js\";\nimport type { Fixture, MockServerOptions } from \"./types.js\";\nimport { statSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\n\nexport interface UseAimockOptions extends MockServerOptions {\n /** Path to fixture file or directory. Loaded automatically on start. */\n fixtures?: string;\n /** If true, sets process.env.OPENAI_BASE_URL to the mock URL + /v1. */\n patchEnv?: boolean;\n}\n\nexport interface AimockHandle {\n /** The LLMock instance. */\n readonly llm: LLMock;\n /** The server URL (e.g., http://127.0.0.1:4010). */\n readonly url: string;\n}\n\n/**\n * Start an aimock server for the duration of the test suite.\n *\n * - `beforeAll`: starts the server and optionally loads fixtures\n * - `beforeEach`: closes Live sessions and resets fixture match counts (not fixtures)\n * - `afterEach`: closes Live sessions owned by this helper's server\n * - `afterAll`: stops the server\n *\n * Returns a getter function — call it inside tests to access the handle.\n *\n * NOTE: Jest globals (beforeAll, afterAll, beforeEach, afterEach) must be available\n * in the test environment. This works with the default jest configuration.\n */\nexport function useAimock(options: UseAimockOptions = {}): () => AimockHandle {\n let handle: AimockHandle | null = null;\n let origOpenaiUrl: string | undefined;\n let origAnthropicUrl: string | undefined;\n\n beforeAll(async () => {\n const { fixtures: fixturePath, patchEnv, ...serverOpts } = options;\n const llm = new LLMock(serverOpts);\n\n if (fixturePath) {\n const resolved = resolve(fixturePath);\n const loadedFixtures = loadFixtures(resolved, options.live);\n for (const f of loadedFixtures) {\n llm.addFixture(f);\n }\n }\n\n const url = await llm.start();\n\n if (patchEnv !== false) {\n origOpenaiUrl = process.env.OPENAI_BASE_URL;\n origAnthropicUrl = process.env.ANTHROPIC_BASE_URL;\n process.env.OPENAI_BASE_URL = `${url}/v1`;\n process.env.ANTHROPIC_BASE_URL = `${url}/v1`;\n }\n\n handle = { llm, url };\n });\n\n beforeEach(() => {\n if (handle) {\n handle.llm.closeLiveSessions();\n handle.llm.resetMatchCounts();\n }\n });\n\n afterEach(() => {\n handle?.llm.closeLiveSessions();\n });\n\n afterAll(async () => {\n if (handle) {\n if (options.patchEnv !== false) {\n if (origOpenaiUrl !== undefined) process.env.OPENAI_BASE_URL = origOpenaiUrl;\n else delete process.env.OPENAI_BASE_URL;\n if (origAnthropicUrl !== undefined) process.env.ANTHROPIC_BASE_URL = origAnthropicUrl;\n else delete process.env.ANTHROPIC_BASE_URL;\n }\n await handle.llm.stop();\n handle = null;\n }\n });\n\n return () => {\n if (!handle) {\n throw new Error(\"useAimock(): server not started — are you calling this inside a test?\");\n }\n return handle;\n };\n}\n\nfunction loadFixtures(fixturePath: string, liveOptions?: LiveOptions): Fixture[] {\n try {\n const stat = statSync(fixturePath);\n if (stat.isDirectory()) {\n return loadFixturesFromDir(fixturePath, undefined, liveOptions);\n }\n return loadFixtureFile(fixturePath, undefined, liveOptions);\n } catch (err) {\n console.warn(\n `[aimock] Failed to load fixtures from ${fixturePath}: ${err instanceof Error ? err.message : String(err)}`,\n );\n return [];\n }\n}\n\nexport { LLMock } from \"./llmock.js\";\nexport type { MockServerOptions, Fixture } from \"./types.js\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAuDA,SAAgB,UAAU,UAA4B,EAAE,EAAsB;CAC5E,IAAI,SAA8B;CAClC,IAAI;CACJ,IAAI;AAEJ,WAAU,YAAY;EACpB,MAAM,EAAE,UAAU,aAAa,UAAU,GAAG,eAAe;EAC3D,MAAM,MAAM,IAAIA,sBAAO,WAAW;AAElC,MAAI,aAAa;GAEf,MAAM,iBAAiB,oCADE,YAAY,EACS,QAAQ,KAAK;AAC3D,QAAK,MAAM,KAAK,eACd,KAAI,WAAW,EAAE;;EAIrB,MAAM,MAAM,MAAM,IAAI,OAAO;AAE7B,MAAI,aAAa,OAAO;AACtB,mBAAgB,QAAQ,IAAI;AAC5B,sBAAmB,QAAQ,IAAI;AAC/B,WAAQ,IAAI,kBAAkB,GAAG,IAAI;AACrC,WAAQ,IAAI,qBAAqB,GAAG,IAAI;;AAG1C,WAAS;GAAE;GAAK;GAAK;GACrB;AAEF,kBAAiB;AACf,MAAI,QAAQ;AACV,UAAO,IAAI,mBAAmB;AAC9B,UAAO,IAAI,kBAAkB;;GAE/B;AAEF,iBAAgB;AACd,UAAQ,IAAI,mBAAmB;GAC/B;AAEF,UAAS,YAAY;AACnB,MAAI,QAAQ;AACV,OAAI,QAAQ,aAAa,OAAO;AAC9B,QAAI,kBAAkB,OAAW,SAAQ,IAAI,kBAAkB;QAC1D,QAAO,QAAQ,IAAI;AACxB,QAAI,qBAAqB,OAAW,SAAQ,IAAI,qBAAqB;QAChE,QAAO,QAAQ,IAAI;;AAE1B,SAAM,OAAO,IAAI,MAAM;AACvB,YAAS;;GAEX;AAEF,cAAa;AACX,MAAI,CAAC,OACH,OAAM,IAAI,MAAM,wEAAwE;AAE1F,SAAO;;;AAIX,SAAS,aAAa,aAAqB,aAAsC;AAC/E,KAAI;AAEF,4BADsB,YAAY,CACzB,aAAa,CACpB,QAAOC,2CAAoB,aAAa,QAAW,YAAY;AAEjE,SAAOC,uCAAgB,aAAa,QAAW,YAAY;UACpD,KAAK;AACZ,UAAQ,KACN,yCAAyC,YAAY,IAAI,eAAe,QAAQ,IAAI,UAAU,OAAO,IAAI,GAC1G;AACD,SAAO,EAAE"}
1
+ {"version":3,"file":"jest.cjs","names":["AimockTestIdCollisionError","sep","TEST_ID_SEPARATOR","FakesPluginState","fakesReportMode","LLMock","fakesTarget","fetchFakesReport","FixtureLoadError","MisbehaviorConfigError"],"sources":["../src/jest.ts"],"sourcesContent":["/**\n * Jest integration for aimock.\n *\n * Usage:\n * import { useAimock } from \"@copilotkit/aimock/jest\";\n *\n * const mock = useAimock({ fixtures: \"./fixtures\" });\n *\n * it(\"responds\", async () => {\n * const res = await fetch(`${mock().url}/v1/chat/completions`, { ... });\n * });\n */\n\n/* eslint-disable no-var */\n// Jest globals — available at runtime in jest test files\ndeclare var beforeAll: (fn: () => Promise<void> | void, timeout?: number) => void;\ndeclare var afterAll: (fn: () => Promise<void> | void, timeout?: number) => void;\ndeclare var beforeEach: (fn: () => Promise<void> | void, timeout?: number) => void;\ndeclare var afterEach: (fn: () => Promise<void> | void, timeout?: number) => void;\ndeclare var expect: { getState(): { testPath?: string; currentTestName?: string } };\n/* eslint-enable no-var */\n\nimport { LLMock } from \"./llmock.js\";\nimport { FixtureLoadError, MisbehaviorConfigError } from \"./fixture-loader.js\";\nimport type { MockServerOptions } from \"./types.js\";\nimport {\n FakesPluginState,\n TEST_ID_SEPARATOR,\n fakesReportMode,\n fakesTarget,\n fetchFakesReport,\n type FakesForOptions,\n type FakesReportMode,\n type FakesTarget,\n} from \"./fakes-plugin.js\";\nimport { AimockTestIdCollisionError, type McpFakesReport } from \"./mcp-fakes-report.js\";\nimport { statSync } from \"node:fs\";\nimport { relative, resolve, sep } from \"node:path\";\n\nexport interface UseAimockOptions extends MockServerOptions {\n /** Path to fixture file or directory. Loaded automatically on start. */\n fixtures?: string;\n /** If true, sets process.env.OPENAI_BASE_URL to the mock URL + /v1. */\n patchEnv?: boolean;\n /**\n * The per-test MCP fake report, read in `afterEach` (RP7): `\"off\"` (the\n * default), `\"warn\"` (print a failing report) or `\"fail\"` (throw\n * `AimockFakesReportError`). Not supported with `test.concurrent`: the\n * report keeps one state per `useAimock`, so concurrent tests clear and read\n * each other's identities, and Jest cannot tell this plugin that a test is\n * concurrent. Keep `\"off\"` for a suite with concurrent tests.\n */\n fakesReport?: FakesReportMode;\n /**\n * The directory default test ids are relative to (TI2). Defaults to\n * `process.cwd()` when `useAimock` is called; Jest does not expose\n * `rootDir` to test code.\n */\n testIdRoot?: string;\n}\n\nexport interface AimockHandle {\n /** The LLMock instance. */\n readonly llm: LLMock;\n /** The server URL (e.g., http://127.0.0.1:4010). */\n readonly url: string;\n}\n\n/**\n * The handle `useAimock` returns: an `AimockHandle` plus the MCP fakes\n * helpers (RP7). A separate type, so that `AimockHandle` stays as it was and\n * code that builds its own `AimockHandle` keeps compiling.\n */\nexport interface AimockFakesHandle extends AimockHandle {\n /**\n * The MCP URL and headers for the fakes scoped to `testId` (RP7), and\n * registers that identity for this test's report. With no `testId`, the\n * default is `<test file relative to testIdRoot> › <currentTestName>` (TI2);\n * it is used only here and in `fakesReport`, never on LLM traffic (TI4).\n * Two tests with the same full name in one file share a default id (TI5):\n * pass an explicit `testId` for them. In `test.concurrent`, Jest can\n * report another test's name, so pass an explicit `testId` there too (with\n * `fakesReport: \"off\"`; the report is not supported in concurrent tests).\n */\n fakesFor(testId?: string, opts?: FakesForOptions): FakesTarget;\n /** The MCP fake report for `testId` (default as in `fakesFor`). */\n fakesReport(testId?: string, opts?: { context?: string }): Promise<McpFakesReport>;\n}\n\n/** TI2: `<testPath relative to root, with \"/\"> › <currentTestName>`. */\nfunction defaultJestId(root: string): string {\n const { testPath, currentTestName } = expect.getState();\n if (!testPath || currentTestName === undefined) {\n throw new AimockTestIdCollisionError(\n \"default test ids are not supported here (concurrent test or no running test); pass an explicit testId\",\n );\n }\n return relative(root, testPath).split(sep).join(\"/\") + TEST_ID_SEPARATOR + currentTestName;\n}\n\n/**\n * Start an aimock server for the duration of the test suite.\n *\n * - `beforeAll`: starts the server and optionally loads fixtures (LLM fixtures and\n * `mcpFakes` blocks; a bad `mcpFakes` block fails `beforeAll`)\n * - `beforeEach`: closes Live sessions and resets fixture match counts and MCP fake\n * consumption (not fixtures or fakes)\n * - `afterEach`: closes Live sessions owned by this helper's server, then checks\n * the MCP fake report under `fakesReport: \"warn\" | \"fail\"`\n * - `afterAll`: stops the server\n *\n * Returns a getter function — call it inside tests to access the handle.\n *\n * NOTE: Jest globals (beforeAll, afterAll, beforeEach, afterEach) must be available\n * in the test environment. This works with the default jest configuration.\n */\nexport function useAimock(options: UseAimockOptions = {}): () => AimockFakesHandle {\n let handle: AimockFakesHandle | null = null;\n let origOpenaiUrl: string | undefined;\n let origAnthropicUrl: string | undefined;\n const root = resolve(options.testIdRoot ?? process.cwd());\n let state = new FakesPluginState(\"off\");\n\n beforeAll(async () => {\n const { fixtures: fixturePath, patchEnv, fakesReport, testIdRoot, ...serverOpts } = options;\n void testIdRoot; // read above, when useAimock is called\n state = new FakesPluginState(fakesReportMode(fakesReport));\n const llm = new LLMock(serverOpts);\n\n if (fixturePath) {\n loadFixtures(llm, resolve(fixturePath));\n }\n\n const url = await llm.start();\n\n if (patchEnv !== false) {\n origOpenaiUrl = process.env.OPENAI_BASE_URL;\n origAnthropicUrl = process.env.ANTHROPIC_BASE_URL;\n process.env.OPENAI_BASE_URL = `${url}/v1`;\n process.env.ANTHROPIC_BASE_URL = `${url}/v1`;\n }\n\n handle = {\n llm,\n url,\n fakesFor(testId?: string, opts: FakesForOptions = {}): FakesTarget {\n const id = testId ?? defaultJestId(root); // TI4: an explicit id wins\n state.register(id, opts.context ?? null);\n return fakesTarget(url, id, opts);\n },\n fakesReport(testId?: string, opts: { context?: string } = {}): Promise<McpFakesReport> {\n return fetchFakesReport(url, testId ?? defaultJestId(root), opts.context ?? null);\n },\n };\n });\n\n beforeEach(() => {\n if (handle) {\n handle.llm.closeLiveSessions();\n handle.llm.resetMatchCounts();\n state.beforeEach(handle.llm);\n }\n });\n\n afterEach(async () => {\n handle?.llm.closeLiveSessions();\n if (handle) await state.afterEach(handle.llm, handle.url);\n });\n\n afterAll(async () => {\n if (handle) {\n if (options.patchEnv !== false) {\n if (origOpenaiUrl !== undefined) process.env.OPENAI_BASE_URL = origOpenaiUrl;\n else delete process.env.OPENAI_BASE_URL;\n if (origAnthropicUrl !== undefined) process.env.ANTHROPIC_BASE_URL = origAnthropicUrl;\n else delete process.env.ANTHROPIC_BASE_URL;\n }\n await handle.llm.stop();\n handle = null;\n }\n });\n\n return () => {\n if (!handle) {\n throw new Error(\"useAimock(): server not started — are you calling this inside a test?\");\n }\n return handle;\n };\n}\n\n/**\n * Load a fixture file or directory into `llm`: its LLM fixtures and its\n * `mcpFakes` blocks, which the LLMock buffers and auto-mounts at start (F12).\n * A `FixtureLoadError` (a bad `mcpFakes` block) or a `MisbehaviorConfigError`\n * (a bad fixture `misbehavior` key, thrown only with `enableMisbehavior: true`)\n * propagates and fails `beforeAll`; any other load failure is only warned\n * about, as before.\n */\nfunction loadFixtures(llm: LLMock, fixturePath: string): void {\n try {\n const stat = statSync(fixturePath);\n if (stat.isDirectory()) {\n llm.loadFixtureDir(fixturePath);\n } else {\n llm.loadFixtureFile(fixturePath);\n }\n } catch (err) {\n if (err instanceof FixtureLoadError || err instanceof MisbehaviorConfigError) throw err;\n console.warn(\n `[aimock] Failed to load fixtures from ${fixturePath}: ${err instanceof Error ? err.message : String(err)}`,\n );\n }\n}\n\nexport { LLMock } from \"./llmock.js\";\nexport type { MockServerOptions, Fixture } from \"./types.js\";\nexport type { FakesForOptions, FakesReportMode, FakesTarget } from \"./fakes-plugin.js\";\nexport type { McpFakesReport } from \"./mcp-fakes-report.js\";\n"],"mappings":";;;;;;;;;;;AA0FA,SAAS,cAAc,MAAsB;CAC3C,MAAM,EAAE,UAAU,oBAAoB,OAAO,UAAU;AACvD,KAAI,CAAC,YAAY,oBAAoB,OACnC,OAAM,IAAIA,oDACR,wGACD;AAEH,gCAAgB,MAAM,SAAS,CAAC,MAAMC,cAAI,CAAC,KAAK,IAAI,GAAGC,yCAAoB;;;;;;;;;;;;;;;;;;AAmB7E,SAAgB,UAAU,UAA4B,EAAE,EAA2B;CACjF,IAAI,SAAmC;CACvC,IAAI;CACJ,IAAI;CACJ,MAAM,8BAAe,QAAQ,cAAc,QAAQ,KAAK,CAAC;CACzD,IAAI,QAAQ,IAAIC,sCAAiB,MAAM;AAEvC,WAAU,YAAY;EACpB,MAAM,EAAE,UAAU,aAAa,UAAU,aAAa,YAAY,GAAG,eAAe;AAEpF,UAAQ,IAAIA,sCAAiBC,qCAAgB,YAAY,CAAC;EAC1D,MAAM,MAAM,IAAIC,sBAAO,WAAW;AAElC,MAAI,YACF,cAAa,4BAAa,YAAY,CAAC;EAGzC,MAAM,MAAM,MAAM,IAAI,OAAO;AAE7B,MAAI,aAAa,OAAO;AACtB,mBAAgB,QAAQ,IAAI;AAC5B,sBAAmB,QAAQ,IAAI;AAC/B,WAAQ,IAAI,kBAAkB,GAAG,IAAI;AACrC,WAAQ,IAAI,qBAAqB,GAAG,IAAI;;AAG1C,WAAS;GACP;GACA;GACA,SAAS,QAAiB,OAAwB,EAAE,EAAe;IACjE,MAAM,KAAK,UAAU,cAAc,KAAK;AACxC,UAAM,SAAS,IAAI,KAAK,WAAW,KAAK;AACxC,WAAOC,iCAAY,KAAK,IAAI,KAAK;;GAEnC,YAAY,QAAiB,OAA6B,EAAE,EAA2B;AACrF,WAAOC,sCAAiB,KAAK,UAAU,cAAc,KAAK,EAAE,KAAK,WAAW,KAAK;;GAEpF;GACD;AAEF,kBAAiB;AACf,MAAI,QAAQ;AACV,UAAO,IAAI,mBAAmB;AAC9B,UAAO,IAAI,kBAAkB;AAC7B,SAAM,WAAW,OAAO,IAAI;;GAE9B;AAEF,WAAU,YAAY;AACpB,UAAQ,IAAI,mBAAmB;AAC/B,MAAI,OAAQ,OAAM,MAAM,UAAU,OAAO,KAAK,OAAO,IAAI;GACzD;AAEF,UAAS,YAAY;AACnB,MAAI,QAAQ;AACV,OAAI,QAAQ,aAAa,OAAO;AAC9B,QAAI,kBAAkB,OAAW,SAAQ,IAAI,kBAAkB;QAC1D,QAAO,QAAQ,IAAI;AACxB,QAAI,qBAAqB,OAAW,SAAQ,IAAI,qBAAqB;QAChE,QAAO,QAAQ,IAAI;;AAE1B,SAAM,OAAO,IAAI,MAAM;AACvB,YAAS;;GAEX;AAEF,cAAa;AACX,MAAI,CAAC,OACH,OAAM,IAAI,MAAM,wEAAwE;AAE1F,SAAO;;;;;;;;;;;AAYX,SAAS,aAAa,KAAa,aAA2B;AAC5D,KAAI;AAEF,4BADsB,YAAY,CACzB,aAAa,CACpB,KAAI,eAAe,YAAY;MAE/B,KAAI,gBAAgB,YAAY;UAE3B,KAAK;AACZ,MAAI,eAAeC,2CAAoB,eAAeC,8CAAwB,OAAM;AACpF,UAAQ,KACN,yCAAyC,YAAY,IAAI,eAAe,QAAQ,IAAI,UAAU,OAAO,IAAI,GAC1G"}
package/dist/jest.d.cts CHANGED
@@ -1,5 +1,7 @@
1
1
  import { Fixture, MockServerOptions } from "./types.cjs";
2
2
  import { LLMock } from "./llmock.cjs";
3
+ import { McpFakesReport } from "./mcp-fakes-report.cjs";
4
+ import { FakesForOptions, FakesReportMode, FakesTarget } from "./fakes-plugin.cjs";
3
5
 
4
6
  //#region src/jest.d.ts
5
7
 
@@ -8,6 +10,21 @@ interface UseAimockOptions extends MockServerOptions {
8
10
  fixtures?: string;
9
11
  /** If true, sets process.env.OPENAI_BASE_URL to the mock URL + /v1. */
10
12
  patchEnv?: boolean;
13
+ /**
14
+ * The per-test MCP fake report, read in `afterEach` (RP7): `"off"` (the
15
+ * default), `"warn"` (print a failing report) or `"fail"` (throw
16
+ * `AimockFakesReportError`). Not supported with `test.concurrent`: the
17
+ * report keeps one state per `useAimock`, so concurrent tests clear and read
18
+ * each other's identities, and Jest cannot tell this plugin that a test is
19
+ * concurrent. Keep `"off"` for a suite with concurrent tests.
20
+ */
21
+ fakesReport?: FakesReportMode;
22
+ /**
23
+ * The directory default test ids are relative to (TI2). Defaults to
24
+ * `process.cwd()` when `useAimock` is called; Jest does not expose
25
+ * `rootDir` to test code.
26
+ */
27
+ testIdRoot?: string;
11
28
  }
12
29
  interface AimockHandle {
13
30
  /** The LLMock instance. */
@@ -15,12 +32,37 @@ interface AimockHandle {
15
32
  /** The server URL (e.g., http://127.0.0.1:4010). */
16
33
  readonly url: string;
17
34
  }
35
+ /**
36
+ * The handle `useAimock` returns: an `AimockHandle` plus the MCP fakes
37
+ * helpers (RP7). A separate type, so that `AimockHandle` stays as it was and
38
+ * code that builds its own `AimockHandle` keeps compiling.
39
+ */
40
+ interface AimockFakesHandle extends AimockHandle {
41
+ /**
42
+ * The MCP URL and headers for the fakes scoped to `testId` (RP7), and
43
+ * registers that identity for this test's report. With no `testId`, the
44
+ * default is `<test file relative to testIdRoot> › <currentTestName>` (TI2);
45
+ * it is used only here and in `fakesReport`, never on LLM traffic (TI4).
46
+ * Two tests with the same full name in one file share a default id (TI5):
47
+ * pass an explicit `testId` for them. In `test.concurrent`, Jest can
48
+ * report another test's name, so pass an explicit `testId` there too (with
49
+ * `fakesReport: "off"`; the report is not supported in concurrent tests).
50
+ */
51
+ fakesFor(testId?: string, opts?: FakesForOptions): FakesTarget;
52
+ /** The MCP fake report for `testId` (default as in `fakesFor`). */
53
+ fakesReport(testId?: string, opts?: {
54
+ context?: string;
55
+ }): Promise<McpFakesReport>;
56
+ }
18
57
  /**
19
58
  * Start an aimock server for the duration of the test suite.
20
59
  *
21
- * - `beforeAll`: starts the server and optionally loads fixtures
22
- * - `beforeEach`: closes Live sessions and resets fixture match counts (not fixtures)
23
- * - `afterEach`: closes Live sessions owned by this helper's server
60
+ * - `beforeAll`: starts the server and optionally loads fixtures (LLM fixtures and
61
+ * `mcpFakes` blocks; a bad `mcpFakes` block fails `beforeAll`)
62
+ * - `beforeEach`: closes Live sessions and resets fixture match counts and MCP fake
63
+ * consumption (not fixtures or fakes)
64
+ * - `afterEach`: closes Live sessions owned by this helper's server, then checks
65
+ * the MCP fake report under `fakesReport: "warn" | "fail"`
24
66
  * - `afterAll`: stops the server
25
67
  *
26
68
  * Returns a getter function — call it inside tests to access the handle.
@@ -28,7 +70,7 @@ interface AimockHandle {
28
70
  * NOTE: Jest globals (beforeAll, afterAll, beforeEach, afterEach) must be available
29
71
  * in the test environment. This works with the default jest configuration.
30
72
  */
31
- declare function useAimock(options?: UseAimockOptions): () => AimockHandle;
73
+ declare function useAimock(options?: UseAimockOptions): () => AimockFakesHandle;
32
74
  //#endregion
33
- export { AimockHandle, type Fixture, LLMock, type MockServerOptions, UseAimockOptions, useAimock };
75
+ export { AimockFakesHandle, AimockHandle, type FakesForOptions, type FakesReportMode, type FakesTarget, type Fixture, LLMock, type McpFakesReport, type MockServerOptions, UseAimockOptions, useAimock };
34
76
  //# sourceMappingURL=jest.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"jest.d.cts","names":[],"sources":["../src/jest.ts"],"sourcesContent":[],"mappings":";;;;;UA4BiB,gBAAA,SAAyB;;;;;;UAOzB,YAAA;;gBAED;;;;;;;;;;;;;;;;;iBAkBA,SAAA,WAAmB,yBAA8B"}
1
+ {"version":3,"file":"jest.d.cts","names":[],"sources":["../src/jest.ts"],"sourcesContent":[],"mappings":";;;;;;;AAsFqE,UA/CpD,gBAAA,SAAyB,iBA+C2B,CAAA;;UAb1B,CAAA,EAAA,MAAA;EAAY;EA2CvC,QAAA,CAAA,EAAA,OAAS;EAAA;;;;;;;;gBAhET;;;;;;;;UASC,YAAA;;gBAED;;;;;;;;;UAUC,iBAAA,SAA0B;;;;;;;;;;;mCAWR,kBAAkB;;;;MAEQ,QAAQ;;;;;;;;;;;;;;;;;;iBA8BrD,SAAA,WAAmB,yBAA8B"}
package/dist/jest.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import { Fixture, MockServerOptions } from "./types.js";
2
2
  import { LLMock } from "./llmock.js";
3
+ import { McpFakesReport } from "./mcp-fakes-report.js";
4
+ import { FakesForOptions, FakesReportMode, FakesTarget } from "./fakes-plugin.js";
3
5
 
4
6
  //#region src/jest.d.ts
5
7
 
@@ -8,6 +10,21 @@ interface UseAimockOptions extends MockServerOptions {
8
10
  fixtures?: string;
9
11
  /** If true, sets process.env.OPENAI_BASE_URL to the mock URL + /v1. */
10
12
  patchEnv?: boolean;
13
+ /**
14
+ * The per-test MCP fake report, read in `afterEach` (RP7): `"off"` (the
15
+ * default), `"warn"` (print a failing report) or `"fail"` (throw
16
+ * `AimockFakesReportError`). Not supported with `test.concurrent`: the
17
+ * report keeps one state per `useAimock`, so concurrent tests clear and read
18
+ * each other's identities, and Jest cannot tell this plugin that a test is
19
+ * concurrent. Keep `"off"` for a suite with concurrent tests.
20
+ */
21
+ fakesReport?: FakesReportMode;
22
+ /**
23
+ * The directory default test ids are relative to (TI2). Defaults to
24
+ * `process.cwd()` when `useAimock` is called; Jest does not expose
25
+ * `rootDir` to test code.
26
+ */
27
+ testIdRoot?: string;
11
28
  }
12
29
  interface AimockHandle {
13
30
  /** The LLMock instance. */
@@ -15,12 +32,37 @@ interface AimockHandle {
15
32
  /** The server URL (e.g., http://127.0.0.1:4010). */
16
33
  readonly url: string;
17
34
  }
35
+ /**
36
+ * The handle `useAimock` returns: an `AimockHandle` plus the MCP fakes
37
+ * helpers (RP7). A separate type, so that `AimockHandle` stays as it was and
38
+ * code that builds its own `AimockHandle` keeps compiling.
39
+ */
40
+ interface AimockFakesHandle extends AimockHandle {
41
+ /**
42
+ * The MCP URL and headers for the fakes scoped to `testId` (RP7), and
43
+ * registers that identity for this test's report. With no `testId`, the
44
+ * default is `<test file relative to testIdRoot> › <currentTestName>` (TI2);
45
+ * it is used only here and in `fakesReport`, never on LLM traffic (TI4).
46
+ * Two tests with the same full name in one file share a default id (TI5):
47
+ * pass an explicit `testId` for them. In `test.concurrent`, Jest can
48
+ * report another test's name, so pass an explicit `testId` there too (with
49
+ * `fakesReport: "off"`; the report is not supported in concurrent tests).
50
+ */
51
+ fakesFor(testId?: string, opts?: FakesForOptions): FakesTarget;
52
+ /** The MCP fake report for `testId` (default as in `fakesFor`). */
53
+ fakesReport(testId?: string, opts?: {
54
+ context?: string;
55
+ }): Promise<McpFakesReport>;
56
+ }
18
57
  /**
19
58
  * Start an aimock server for the duration of the test suite.
20
59
  *
21
- * - `beforeAll`: starts the server and optionally loads fixtures
22
- * - `beforeEach`: closes Live sessions and resets fixture match counts (not fixtures)
23
- * - `afterEach`: closes Live sessions owned by this helper's server
60
+ * - `beforeAll`: starts the server and optionally loads fixtures (LLM fixtures and
61
+ * `mcpFakes` blocks; a bad `mcpFakes` block fails `beforeAll`)
62
+ * - `beforeEach`: closes Live sessions and resets fixture match counts and MCP fake
63
+ * consumption (not fixtures or fakes)
64
+ * - `afterEach`: closes Live sessions owned by this helper's server, then checks
65
+ * the MCP fake report under `fakesReport: "warn" | "fail"`
24
66
  * - `afterAll`: stops the server
25
67
  *
26
68
  * Returns a getter function — call it inside tests to access the handle.
@@ -28,7 +70,7 @@ interface AimockHandle {
28
70
  * NOTE: Jest globals (beforeAll, afterAll, beforeEach, afterEach) must be available
29
71
  * in the test environment. This works with the default jest configuration.
30
72
  */
31
- declare function useAimock(options?: UseAimockOptions): () => AimockHandle;
73
+ declare function useAimock(options?: UseAimockOptions): () => AimockFakesHandle;
32
74
  //#endregion
33
- export { AimockHandle, type Fixture, LLMock, type MockServerOptions, UseAimockOptions, useAimock };
75
+ export { AimockFakesHandle, AimockHandle, type FakesForOptions, type FakesReportMode, type FakesTarget, type Fixture, LLMock, type McpFakesReport, type MockServerOptions, UseAimockOptions, useAimock };
34
76
  //# sourceMappingURL=jest.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"jest.d.ts","names":[],"sources":["../src/jest.ts"],"sourcesContent":[],"mappings":";;;;;UA4BiB,gBAAA,SAAyB;;;;;;UAOzB,YAAA;;gBAED;;;;;;;;;;;;;;;;;iBAkBA,SAAA,WAAmB,yBAA8B"}
1
+ {"version":3,"file":"jest.d.ts","names":[],"sources":["../src/jest.ts"],"sourcesContent":[],"mappings":";;;;;;;AAsFqE,UA/CpD,gBAAA,SAAyB,iBA+C2B,CAAA;;UAb1B,CAAA,EAAA,MAAA;EAAY;EA2CvC,QAAA,CAAA,EAAA,OAAS;EAAA;;;;;;;;gBAhET;;;;;;;;UASC,YAAA;;gBAED;;;;;;;;;UAUC,iBAAA,SAA0B;;;;;;;;;;;mCAWR,kBAAkB;;;;MAEQ,QAAQ;;;;;;;;;;;;;;;;;;iBA8BrD,SAAA,WAAmB,yBAA8B"}
package/dist/jest.js CHANGED
@@ -1,15 +1,26 @@
1
- import { loadFixtureFile, loadFixturesFromDir } from "./fixture-loader.js";
1
+ import { FixtureLoadError, MisbehaviorConfigError } from "./fixture-loader.js";
2
+ import { AimockTestIdCollisionError } from "./mcp-fakes-report.js";
2
3
  import { LLMock } from "./llmock.js";
4
+ import { FakesPluginState, TEST_ID_SEPARATOR, fakesReportMode, fakesTarget, fetchFakesReport } from "./fakes-plugin.js";
3
5
  import { statSync } from "node:fs";
4
- import { resolve } from "node:path";
6
+ import { relative, resolve, sep } from "node:path";
5
7
 
6
8
  //#region src/jest.ts
9
+ /** TI2: `<testPath relative to root, with "/"> › <currentTestName>`. */
10
+ function defaultJestId(root) {
11
+ const { testPath, currentTestName } = expect.getState();
12
+ if (!testPath || currentTestName === void 0) throw new AimockTestIdCollisionError("default test ids are not supported here (concurrent test or no running test); pass an explicit testId");
13
+ return relative(root, testPath).split(sep).join("/") + TEST_ID_SEPARATOR + currentTestName;
14
+ }
7
15
  /**
8
16
  * Start an aimock server for the duration of the test suite.
9
17
  *
10
- * - `beforeAll`: starts the server and optionally loads fixtures
11
- * - `beforeEach`: closes Live sessions and resets fixture match counts (not fixtures)
12
- * - `afterEach`: closes Live sessions owned by this helper's server
18
+ * - `beforeAll`: starts the server and optionally loads fixtures (LLM fixtures and
19
+ * `mcpFakes` blocks; a bad `mcpFakes` block fails `beforeAll`)
20
+ * - `beforeEach`: closes Live sessions and resets fixture match counts and MCP fake
21
+ * consumption (not fixtures or fakes)
22
+ * - `afterEach`: closes Live sessions owned by this helper's server, then checks
23
+ * the MCP fake report under `fakesReport: "warn" | "fail"`
13
24
  * - `afterAll`: stops the server
14
25
  *
15
26
  * Returns a getter function — call it inside tests to access the handle.
@@ -21,13 +32,13 @@ function useAimock(options = {}) {
21
32
  let handle = null;
22
33
  let origOpenaiUrl;
23
34
  let origAnthropicUrl;
35
+ const root = resolve(options.testIdRoot ?? process.cwd());
36
+ let state = new FakesPluginState("off");
24
37
  beforeAll(async () => {
25
- const { fixtures: fixturePath, patchEnv, ...serverOpts } = options;
38
+ const { fixtures: fixturePath, patchEnv, fakesReport, testIdRoot, ...serverOpts } = options;
39
+ state = new FakesPluginState(fakesReportMode(fakesReport));
26
40
  const llm = new LLMock(serverOpts);
27
- if (fixturePath) {
28
- const loadedFixtures = loadFixtures(resolve(fixturePath), options.live);
29
- for (const f of loadedFixtures) llm.addFixture(f);
30
- }
41
+ if (fixturePath) loadFixtures(llm, resolve(fixturePath));
31
42
  const url = await llm.start();
32
43
  if (patchEnv !== false) {
33
44
  origOpenaiUrl = process.env.OPENAI_BASE_URL;
@@ -37,17 +48,27 @@ function useAimock(options = {}) {
37
48
  }
38
49
  handle = {
39
50
  llm,
40
- url
51
+ url,
52
+ fakesFor(testId, opts = {}) {
53
+ const id = testId ?? defaultJestId(root);
54
+ state.register(id, opts.context ?? null);
55
+ return fakesTarget(url, id, opts);
56
+ },
57
+ fakesReport(testId, opts = {}) {
58
+ return fetchFakesReport(url, testId ?? defaultJestId(root), opts.context ?? null);
59
+ }
41
60
  };
42
61
  });
43
62
  beforeEach(() => {
44
63
  if (handle) {
45
64
  handle.llm.closeLiveSessions();
46
65
  handle.llm.resetMatchCounts();
66
+ state.beforeEach(handle.llm);
47
67
  }
48
68
  });
49
- afterEach(() => {
69
+ afterEach(async () => {
50
70
  handle?.llm.closeLiveSessions();
71
+ if (handle) await state.afterEach(handle.llm, handle.url);
51
72
  });
52
73
  afterAll(async () => {
53
74
  if (handle) {
@@ -66,13 +87,21 @@ function useAimock(options = {}) {
66
87
  return handle;
67
88
  };
68
89
  }
69
- function loadFixtures(fixturePath, liveOptions) {
90
+ /**
91
+ * Load a fixture file or directory into `llm`: its LLM fixtures and its
92
+ * `mcpFakes` blocks, which the LLMock buffers and auto-mounts at start (F12).
93
+ * A `FixtureLoadError` (a bad `mcpFakes` block) or a `MisbehaviorConfigError`
94
+ * (a bad fixture `misbehavior` key, thrown only with `enableMisbehavior: true`)
95
+ * propagates and fails `beforeAll`; any other load failure is only warned
96
+ * about, as before.
97
+ */
98
+ function loadFixtures(llm, fixturePath) {
70
99
  try {
71
- if (statSync(fixturePath).isDirectory()) return loadFixturesFromDir(fixturePath, void 0, liveOptions);
72
- return loadFixtureFile(fixturePath, void 0, liveOptions);
100
+ if (statSync(fixturePath).isDirectory()) llm.loadFixtureDir(fixturePath);
101
+ else llm.loadFixtureFile(fixturePath);
73
102
  } catch (err) {
103
+ if (err instanceof FixtureLoadError || err instanceof MisbehaviorConfigError) throw err;
74
104
  console.warn(`[aimock] Failed to load fixtures from ${fixturePath}: ${err instanceof Error ? err.message : String(err)}`);
75
- return [];
76
105
  }
77
106
  }
78
107