@copilotkit/aimock 1.42.1 → 1.44.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 (442) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/CHANGELOG.md +65 -0
  4. package/README.md +108 -16
  5. package/dist/agui-handler.d.ts.map +1 -1
  6. package/dist/agui-mock.cjs +1 -1
  7. package/dist/agui-mock.cjs.map +1 -1
  8. package/dist/agui-mock.d.cts.map +1 -1
  9. package/dist/agui-mock.d.ts.map +1 -1
  10. package/dist/agui-mock.js +1 -1
  11. package/dist/agui-mock.js.map +1 -1
  12. package/dist/agui-recorder.cjs +33 -11
  13. package/dist/agui-recorder.cjs.map +1 -1
  14. package/dist/agui-recorder.d.cts +10 -1
  15. package/dist/agui-recorder.d.cts.map +1 -1
  16. package/dist/agui-recorder.d.ts +10 -1
  17. package/dist/agui-recorder.d.ts.map +1 -1
  18. package/dist/agui-recorder.js +33 -11
  19. package/dist/agui-recorder.js.map +1 -1
  20. package/dist/agui-types.d.cts +1 -0
  21. package/dist/agui-types.d.cts.map +1 -1
  22. package/dist/agui-types.d.ts +1 -0
  23. package/dist/agui-types.d.ts.map +1 -1
  24. package/dist/aimock-cli.cjs +38 -10
  25. package/dist/aimock-cli.cjs.map +1 -1
  26. package/dist/aimock-cli.d.cts +5 -0
  27. package/dist/aimock-cli.d.cts.map +1 -1
  28. package/dist/aimock-cli.d.ts +5 -0
  29. package/dist/aimock-cli.d.ts.map +1 -1
  30. package/dist/aimock-cli.js +38 -10
  31. package/dist/aimock-cli.js.map +1 -1
  32. package/dist/batches.cjs +458 -0
  33. package/dist/batches.cjs.map +1 -0
  34. package/dist/batches.d.cts +57 -0
  35. package/dist/batches.d.cts.map +1 -0
  36. package/dist/batches.d.ts +57 -0
  37. package/dist/batches.d.ts.map +1 -0
  38. package/dist/batches.js +453 -0
  39. package/dist/batches.js.map +1 -0
  40. package/dist/bedrock-converse.cjs +44 -12
  41. package/dist/bedrock-converse.cjs.map +1 -1
  42. package/dist/bedrock-converse.d.cts.map +1 -1
  43. package/dist/bedrock-converse.d.ts.map +1 -1
  44. package/dist/bedrock-converse.js +46 -14
  45. package/dist/bedrock-converse.js.map +1 -1
  46. package/dist/bedrock.cjs +10 -8
  47. package/dist/bedrock.cjs.map +1 -1
  48. package/dist/bedrock.d.cts.map +1 -1
  49. package/dist/bedrock.d.ts.map +1 -1
  50. package/dist/bedrock.js +12 -10
  51. package/dist/bedrock.js.map +1 -1
  52. package/dist/byteplus-video.cjs +3 -3
  53. package/dist/byteplus-video.cjs.map +1 -1
  54. package/dist/byteplus-video.js +4 -4
  55. package/dist/byteplus-video.js.map +1 -1
  56. package/dist/chaos.cjs +625 -72
  57. package/dist/chaos.cjs.map +1 -1
  58. package/dist/chaos.d.cts +164 -7
  59. package/dist/chaos.d.cts.map +1 -1
  60. package/dist/chaos.d.ts +164 -7
  61. package/dist/chaos.d.ts.map +1 -1
  62. package/dist/chaos.js +616 -74
  63. package/dist/chaos.js.map +1 -1
  64. package/dist/cli.cjs +131 -30
  65. package/dist/cli.cjs.map +1 -1
  66. package/dist/cli.js +132 -31
  67. package/dist/cli.js.map +1 -1
  68. package/dist/cohere.cjs +37 -9
  69. package/dist/cohere.cjs.map +1 -1
  70. package/dist/cohere.d.cts.map +1 -1
  71. package/dist/cohere.d.ts.map +1 -1
  72. package/dist/cohere.js +39 -11
  73. package/dist/cohere.js.map +1 -1
  74. package/dist/config-loader.cjs +1 -1
  75. package/dist/config-loader.js +1 -1
  76. package/dist/constants.cjs +8 -0
  77. package/dist/constants.cjs.map +1 -1
  78. package/dist/constants.d.cts +6 -2
  79. package/dist/constants.d.ts +6 -2
  80. package/dist/constants.js +8 -1
  81. package/dist/constants.js.map +1 -1
  82. package/dist/convert.cjs +1 -1
  83. package/dist/convert.cjs.map +1 -1
  84. package/dist/convert.js +1 -1
  85. package/dist/convert.js.map +1 -1
  86. package/dist/echo-text.cjs +65 -0
  87. package/dist/echo-text.cjs.map +1 -0
  88. package/dist/echo-text.d.cts +22 -0
  89. package/dist/echo-text.d.cts.map +1 -0
  90. package/dist/echo-text.d.ts +22 -0
  91. package/dist/echo-text.d.ts.map +1 -0
  92. package/dist/echo-text.js +65 -0
  93. package/dist/echo-text.js.map +1 -0
  94. package/dist/elevenlabs-audio.cjs +3 -3
  95. package/dist/elevenlabs-audio.cjs.map +1 -1
  96. package/dist/elevenlabs-audio.js +4 -4
  97. package/dist/elevenlabs-audio.js.map +1 -1
  98. package/dist/elevenlabs-voice.cjs +1053 -0
  99. package/dist/elevenlabs-voice.cjs.map +1 -0
  100. package/dist/elevenlabs-voice.d.cts +72 -0
  101. package/dist/elevenlabs-voice.d.cts.map +1 -0
  102. package/dist/elevenlabs-voice.d.ts +72 -0
  103. package/dist/elevenlabs-voice.d.ts.map +1 -0
  104. package/dist/elevenlabs-voice.js +1048 -0
  105. package/dist/elevenlabs-voice.js.map +1 -0
  106. package/dist/embeddings.cjs +26 -5
  107. package/dist/embeddings.cjs.map +1 -1
  108. package/dist/embeddings.d.cts +1 -1
  109. package/dist/embeddings.d.cts.map +1 -1
  110. package/dist/embeddings.d.ts +1 -1
  111. package/dist/embeddings.d.ts.map +1 -1
  112. package/dist/embeddings.js +27 -6
  113. package/dist/embeddings.js.map +1 -1
  114. package/dist/fal-audio.cjs +3 -3
  115. package/dist/fal-audio.cjs.map +1 -1
  116. package/dist/fal-audio.js +4 -4
  117. package/dist/fal-audio.js.map +1 -1
  118. package/dist/fal.cjs +28 -4
  119. package/dist/fal.cjs.map +1 -1
  120. package/dist/fal.d.cts +16 -1
  121. package/dist/fal.d.cts.map +1 -1
  122. package/dist/fal.d.ts +16 -1
  123. package/dist/fal.d.ts.map +1 -1
  124. package/dist/fal.js +28 -5
  125. package/dist/fal.js.map +1 -1
  126. package/dist/files.cjs +1069 -0
  127. package/dist/files.cjs.map +1 -0
  128. package/dist/files.d.cts +68 -0
  129. package/dist/files.d.cts.map +1 -0
  130. package/dist/files.d.ts +68 -0
  131. package/dist/files.d.ts.map +1 -0
  132. package/dist/files.js +1056 -0
  133. package/dist/files.js.map +1 -0
  134. package/dist/fine-tuning.cjs +1033 -0
  135. package/dist/fine-tuning.cjs.map +1 -0
  136. package/dist/fine-tuning.d.cts +96 -0
  137. package/dist/fine-tuning.d.cts.map +1 -0
  138. package/dist/fine-tuning.d.ts +96 -0
  139. package/dist/fine-tuning.d.ts.map +1 -0
  140. package/dist/fine-tuning.js +1026 -0
  141. package/dist/fine-tuning.js.map +1 -0
  142. package/dist/fixture-loader-services.cjs +116 -0
  143. package/dist/fixture-loader-services.cjs.map +1 -0
  144. package/dist/fixture-loader-services.d.cts +48 -0
  145. package/dist/fixture-loader-services.d.cts.map +1 -0
  146. package/dist/fixture-loader-services.d.ts +48 -0
  147. package/dist/fixture-loader-services.d.ts.map +1 -0
  148. package/dist/fixture-loader-services.js +114 -0
  149. package/dist/fixture-loader-services.js.map +1 -0
  150. package/dist/fixture-loader.cjs +0 -0
  151. package/dist/fixture-loader.cjs.map +1 -1
  152. package/dist/fixture-loader.d.cts +131 -5
  153. package/dist/fixture-loader.d.cts.map +1 -1
  154. package/dist/fixture-loader.d.ts +131 -5
  155. package/dist/fixture-loader.d.ts.map +1 -1
  156. package/dist/fixture-loader.js +0 -0
  157. package/dist/fixture-loader.js.map +1 -1
  158. package/dist/gemini-embeddings.cjs +44 -4
  159. package/dist/gemini-embeddings.cjs.map +1 -1
  160. package/dist/gemini-embeddings.js +46 -6
  161. package/dist/gemini-embeddings.js.map +1 -1
  162. package/dist/gemini-interactions.cjs +51 -7
  163. package/dist/gemini-interactions.cjs.map +1 -1
  164. package/dist/gemini-interactions.d.cts.map +1 -1
  165. package/dist/gemini-interactions.d.ts.map +1 -1
  166. package/dist/gemini-interactions.js +53 -9
  167. package/dist/gemini-interactions.js.map +1 -1
  168. package/dist/gemini.cjs +19 -8
  169. package/dist/gemini.cjs.map +1 -1
  170. package/dist/gemini.d.cts.map +1 -1
  171. package/dist/gemini.d.ts.map +1 -1
  172. package/dist/gemini.js +21 -10
  173. package/dist/gemini.js.map +1 -1
  174. package/dist/grok-video.cjs +14 -14
  175. package/dist/grok-video.cjs.map +1 -1
  176. package/dist/grok-video.js +15 -15
  177. package/dist/grok-video.js.map +1 -1
  178. package/dist/helpers.cjs +497 -10
  179. package/dist/helpers.cjs.map +1 -1
  180. package/dist/helpers.d.cts +38 -2
  181. package/dist/helpers.d.cts.map +1 -1
  182. package/dist/helpers.d.ts +38 -2
  183. package/dist/helpers.d.ts.map +1 -1
  184. package/dist/helpers.js +487 -12
  185. package/dist/helpers.js.map +1 -1
  186. package/dist/images.cjs +57 -125
  187. package/dist/images.cjs.map +1 -1
  188. package/dist/images.d.cts.map +1 -1
  189. package/dist/images.d.ts.map +1 -1
  190. package/dist/images.js +58 -126
  191. package/dist/images.js.map +1 -1
  192. package/dist/index.cjs +71 -9
  193. package/dist/index.d.cts +17 -7
  194. package/dist/index.d.ts +17 -7
  195. package/dist/index.js +21 -11
  196. package/dist/jest.cjs +24 -12
  197. package/dist/jest.cjs.map +1 -1
  198. package/dist/jest.d.cts +6 -3
  199. package/dist/jest.d.cts.map +1 -1
  200. package/dist/jest.d.ts +6 -3
  201. package/dist/jest.d.ts.map +1 -1
  202. package/dist/jest.js +25 -13
  203. package/dist/jest.js.map +1 -1
  204. package/dist/journal.cjs +61 -4
  205. package/dist/journal.cjs.map +1 -1
  206. package/dist/journal.d.cts +60 -3
  207. package/dist/journal.d.cts.map +1 -1
  208. package/dist/journal.d.ts +60 -3
  209. package/dist/journal.d.ts.map +1 -1
  210. package/dist/journal.js +61 -5
  211. package/dist/journal.js.map +1 -1
  212. package/dist/live-fixture.cjs +1192 -0
  213. package/dist/live-fixture.cjs.map +1 -0
  214. package/dist/live-fixture.js +1187 -0
  215. package/dist/live-fixture.js.map +1 -0
  216. package/dist/live-recorder.cjs +256 -0
  217. package/dist/live-recorder.cjs.map +1 -0
  218. package/dist/live-recorder.js +254 -0
  219. package/dist/live-recorder.js.map +1 -0
  220. package/dist/live-replay.cjs +286 -0
  221. package/dist/live-replay.cjs.map +1 -0
  222. package/dist/live-replay.js +285 -0
  223. package/dist/live-replay.js.map +1 -0
  224. package/dist/live-sanitize.cjs +196 -0
  225. package/dist/live-sanitize.cjs.map +1 -0
  226. package/dist/live-sanitize.js +196 -0
  227. package/dist/live-sanitize.js.map +1 -0
  228. package/dist/live-types.d.cts +71 -0
  229. package/dist/live-types.d.cts.map +1 -0
  230. package/dist/live-types.d.ts +71 -0
  231. package/dist/live-types.d.ts.map +1 -0
  232. package/dist/llmock.cjs +132 -49
  233. package/dist/llmock.cjs.map +1 -1
  234. package/dist/llmock.d.cts +51 -5
  235. package/dist/llmock.d.cts.map +1 -1
  236. package/dist/llmock.d.ts +51 -5
  237. package/dist/llmock.d.ts.map +1 -1
  238. package/dist/llmock.js +133 -50
  239. package/dist/llmock.js.map +1 -1
  240. package/dist/mcp-fakes-mount.cjs +216 -0
  241. package/dist/mcp-fakes-mount.cjs.map +1 -0
  242. package/dist/mcp-fakes-mount.js +210 -0
  243. package/dist/mcp-fakes-mount.js.map +1 -0
  244. package/dist/mcp-fakes.cjs +1619 -0
  245. package/dist/mcp-fakes.cjs.map +1 -0
  246. package/dist/mcp-fakes.d.cts +101 -0
  247. package/dist/mcp-fakes.d.cts.map +1 -0
  248. package/dist/mcp-fakes.d.ts +101 -0
  249. package/dist/mcp-fakes.d.ts.map +1 -0
  250. package/dist/mcp-fakes.js +1614 -0
  251. package/dist/mcp-fakes.js.map +1 -0
  252. package/dist/mcp-handler.cjs +331 -17
  253. package/dist/mcp-handler.cjs.map +1 -1
  254. package/dist/mcp-handler.js +330 -18
  255. package/dist/mcp-handler.js.map +1 -1
  256. package/dist/mcp-mock.cjs +217 -49
  257. package/dist/mcp-mock.cjs.map +1 -1
  258. package/dist/mcp-mock.d.cts +66 -1
  259. package/dist/mcp-mock.d.cts.map +1 -1
  260. package/dist/mcp-mock.d.ts +66 -1
  261. package/dist/mcp-mock.d.ts.map +1 -1
  262. package/dist/mcp-mock.js +218 -50
  263. package/dist/mcp-mock.js.map +1 -1
  264. package/dist/mcp-stub.cjs +5 -1
  265. package/dist/mcp-stub.d.cts +3 -1
  266. package/dist/mcp-stub.d.ts +3 -1
  267. package/dist/mcp-stub.js +3 -1
  268. package/dist/mcp-types.d.cts +6 -0
  269. package/dist/mcp-types.d.ts +6 -0
  270. package/dist/message-text.cjs +192 -0
  271. package/dist/message-text.cjs.map +1 -0
  272. package/dist/message-text.d.cts +31 -0
  273. package/dist/message-text.d.cts.map +1 -0
  274. package/dist/message-text.d.ts +31 -0
  275. package/dist/message-text.d.ts.map +1 -0
  276. package/dist/message-text.js +184 -0
  277. package/dist/message-text.js.map +1 -0
  278. package/dist/messages.cjs +49 -7
  279. package/dist/messages.cjs.map +1 -1
  280. package/dist/messages.d.cts.map +1 -1
  281. package/dist/messages.d.ts.map +1 -1
  282. package/dist/messages.js +51 -9
  283. package/dist/messages.js.map +1 -1
  284. package/dist/metrics.cjs +278 -45
  285. package/dist/metrics.cjs.map +1 -1
  286. package/dist/metrics.d.cts +17 -7
  287. package/dist/metrics.d.cts.map +1 -1
  288. package/dist/metrics.d.ts +17 -7
  289. package/dist/metrics.d.ts.map +1 -1
  290. package/dist/metrics.js +270 -29
  291. package/dist/metrics.js.map +1 -1
  292. package/dist/moderation.cjs +10 -1
  293. package/dist/moderation.cjs.map +1 -1
  294. package/dist/moderation.d.cts.map +1 -1
  295. package/dist/moderation.d.ts.map +1 -1
  296. package/dist/moderation.js +10 -1
  297. package/dist/moderation.js.map +1 -1
  298. package/dist/ollama.cjs +10 -6
  299. package/dist/ollama.cjs.map +1 -1
  300. package/dist/ollama.d.cts.map +1 -1
  301. package/dist/ollama.d.ts.map +1 -1
  302. package/dist/ollama.js +11 -7
  303. package/dist/ollama.js.map +1 -1
  304. package/dist/openapi.cjs +3405 -0
  305. package/dist/openapi.cjs.map +1 -0
  306. package/dist/openapi.d.cts +30 -0
  307. package/dist/openapi.d.cts.map +1 -0
  308. package/dist/openapi.d.ts +30 -0
  309. package/dist/openapi.d.ts.map +1 -0
  310. package/dist/openapi.js +3404 -0
  311. package/dist/openapi.js.map +1 -0
  312. package/dist/openrouter-video.cjs +9 -9
  313. package/dist/openrouter-video.cjs.map +1 -1
  314. package/dist/openrouter-video.d.cts.map +1 -1
  315. package/dist/openrouter-video.d.ts.map +1 -1
  316. package/dist/openrouter-video.js +10 -10
  317. package/dist/openrouter-video.js.map +1 -1
  318. package/dist/recorder.cjs +54 -10
  319. package/dist/recorder.cjs.map +1 -1
  320. package/dist/recorder.d.cts.map +1 -1
  321. package/dist/recorder.d.ts.map +1 -1
  322. package/dist/recorder.js +52 -12
  323. package/dist/recorder.js.map +1 -1
  324. package/dist/responses.cjs +47 -7
  325. package/dist/responses.cjs.map +1 -1
  326. package/dist/responses.d.cts.map +1 -1
  327. package/dist/responses.d.ts.map +1 -1
  328. package/dist/responses.js +48 -9
  329. package/dist/responses.js.map +1 -1
  330. package/dist/route-registry.cjs +951 -0
  331. package/dist/route-registry.cjs.map +1 -0
  332. package/dist/route-registry.d.cts +33 -0
  333. package/dist/route-registry.d.cts.map +1 -0
  334. package/dist/route-registry.d.ts +33 -0
  335. package/dist/route-registry.d.ts.map +1 -0
  336. package/dist/route-registry.js +866 -0
  337. package/dist/route-registry.js.map +1 -0
  338. package/dist/router.cjs +21 -34
  339. package/dist/router.cjs.map +1 -1
  340. package/dist/router.d.cts +4 -1
  341. package/dist/router.d.cts.map +1 -1
  342. package/dist/router.d.ts +4 -1
  343. package/dist/router.d.ts.map +1 -1
  344. package/dist/router.js +21 -35
  345. package/dist/router.js.map +1 -1
  346. package/dist/server.cjs +1252 -777
  347. package/dist/server.cjs.map +1 -1
  348. package/dist/server.d.cts +5 -1
  349. package/dist/server.d.cts.map +1 -1
  350. package/dist/server.d.ts +5 -1
  351. package/dist/server.d.ts.map +1 -1
  352. package/dist/server.js +1185 -710
  353. package/dist/server.js.map +1 -1
  354. package/dist/speech.cjs +6 -4
  355. package/dist/speech.cjs.map +1 -1
  356. package/dist/speech.js +7 -5
  357. package/dist/speech.js.map +1 -1
  358. package/dist/suite.cjs +1 -1
  359. package/dist/suite.js +1 -1
  360. package/dist/transcription.cjs +6 -6
  361. package/dist/transcription.cjs.map +1 -1
  362. package/dist/transcription.d.cts.map +1 -1
  363. package/dist/transcription.d.ts.map +1 -1
  364. package/dist/transcription.js +7 -7
  365. package/dist/transcription.js.map +1 -1
  366. package/dist/types.cjs +18 -0
  367. package/dist/types.cjs.map +1 -0
  368. package/dist/types.d.cts +320 -17
  369. package/dist/types.d.cts.map +1 -1
  370. package/dist/types.d.ts +320 -17
  371. package/dist/types.d.ts.map +1 -1
  372. package/dist/types.js +17 -0
  373. package/dist/types.js.map +1 -0
  374. package/dist/validate-cli.cjs +983 -0
  375. package/dist/validate-cli.cjs.map +1 -0
  376. package/dist/validate-cli.js +982 -0
  377. package/dist/validate-cli.js.map +1 -0
  378. package/dist/vector-stores.cjs +1180 -0
  379. package/dist/vector-stores.cjs.map +1 -0
  380. package/dist/vector-stores.d.cts +106 -0
  381. package/dist/vector-stores.d.cts.map +1 -0
  382. package/dist/vector-stores.d.ts +106 -0
  383. package/dist/vector-stores.d.ts.map +1 -0
  384. package/dist/vector-stores.js +1164 -0
  385. package/dist/vector-stores.js.map +1 -0
  386. package/dist/vector-types.d.cts.map +1 -1
  387. package/dist/vector-types.d.ts.map +1 -1
  388. package/dist/veo-video.cjs +13 -13
  389. package/dist/veo-video.cjs.map +1 -1
  390. package/dist/veo-video.js +14 -14
  391. package/dist/veo-video.js.map +1 -1
  392. package/dist/video.cjs +23 -4
  393. package/dist/video.cjs.map +1 -1
  394. package/dist/video.d.cts +1 -1
  395. package/dist/video.d.cts.map +1 -1
  396. package/dist/video.d.ts +1 -1
  397. package/dist/video.d.ts.map +1 -1
  398. package/dist/video.js +24 -5
  399. package/dist/video.js.map +1 -1
  400. package/dist/vitest.cjs +23 -11
  401. package/dist/vitest.cjs.map +1 -1
  402. package/dist/vitest.d.cts +5 -2
  403. package/dist/vitest.d.cts.map +1 -1
  404. package/dist/vitest.d.ts +5 -2
  405. package/dist/vitest.d.ts.map +1 -1
  406. package/dist/vitest.js +25 -13
  407. package/dist/vitest.js.map +1 -1
  408. package/dist/watcher.cjs +2 -1
  409. package/dist/watcher.cjs.map +1 -1
  410. package/dist/watcher.js +2 -1
  411. package/dist/watcher.js.map +1 -1
  412. package/dist/ws-framing.cjs +150 -35
  413. package/dist/ws-framing.cjs.map +1 -1
  414. package/dist/ws-framing.d.cts +18 -3
  415. package/dist/ws-framing.d.cts.map +1 -1
  416. package/dist/ws-framing.d.ts +18 -3
  417. package/dist/ws-framing.d.ts.map +1 -1
  418. package/dist/ws-framing.js +151 -36
  419. package/dist/ws-framing.js.map +1 -1
  420. package/dist/ws-gemini-live.cjs +2 -2
  421. package/dist/ws-gemini-live.js +2 -2
  422. package/dist/ws-live.cjs +401 -0
  423. package/dist/ws-live.cjs.map +1 -0
  424. package/dist/ws-live.js +400 -0
  425. package/dist/ws-live.js.map +1 -0
  426. package/dist/ws-realtime.cjs +46 -2
  427. package/dist/ws-realtime.cjs.map +1 -1
  428. package/dist/ws-realtime.d.cts.map +1 -1
  429. package/dist/ws-realtime.d.ts.map +1 -1
  430. package/dist/ws-realtime.js +46 -2
  431. package/dist/ws-realtime.js.map +1 -1
  432. package/dist/ws-responses.cjs +16 -4
  433. package/dist/ws-responses.cjs.map +1 -1
  434. package/dist/ws-responses.js +16 -4
  435. package/dist/ws-responses.js.map +1 -1
  436. package/dist/ws-upstream.cjs +118 -0
  437. package/dist/ws-upstream.cjs.map +1 -0
  438. package/dist/ws-upstream.js +115 -0
  439. package/dist/ws-upstream.js.map +1 -0
  440. package/fixtures/openai-live-client.json +390 -0
  441. package/fixtures/openai-live-managed.json +709 -0
  442. package/package.json +4 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.cjs","names":[],"sources":["../src/types.ts"],"sourcesContent":["import type * as http from \"node:http\";\nimport type * as net from \"node:net\";\nimport type { Journal } from \"./journal.js\";\nimport type { LiveFixtureResponse, LiveOptions } from \"./live-types.js\";\nimport type { Logger } from \"./logger.js\";\nimport type { MetricsRegistry } from \"./metrics.js\";\nimport type { McpFakeAddOrigin, McpFakeAddResult } from \"./mcp-fakes.js\";\n\n// aimock type definitions — shared across all provider adapters and the fixture router.\n\nexport interface Mountable {\n handleRequest(\n req: http.IncomingMessage,\n res: http.ServerResponse,\n pathname: string,\n ): Promise<boolean>;\n handleUpgrade?(socket: net.Socket, head: Buffer, pathname: string): Promise<boolean>;\n health?(): { status: string; [key: string]: unknown };\n setJournal?(journal: Journal): void;\n setBaseUrl?(url: string): void;\n setRegistry?(registry: MetricsRegistry): void;\n /**\n * MCP fakes. A mount \"is an MCPMock\" for fakes if and only if it\n * implements `addMcpFakes`. Always appends. `origin` picks the entry-id\n * source and its counter: `file` keeps each block's `source` (`@<k>` load\n * counter); `code` / `control-api` is one run-time addition (`code#<n>` /\n * `control-api#<n>`). Returns the shadowed-entry warnings with the real\n * entry ids. When any block is bad, or the input holds no blocks, throws one\n * `FixtureLoadError` (an `McpFakesAddError` carrying every error found and\n * the warnings) and adds nothing.\n */\n addMcpFakes?(blocks: McpFakeSource[], origin: McpFakeAddOrigin): McpFakeAddResult;\n /** Unload every fake on this mount. The entry-id counters are kept. */\n clearMcpFakes?(): void;\n /** Reset fake consumption state for one test id, or for all when omitted. */\n resetScenarioState?(testId?: string): void;\n /** Hands an MCP mount a `Logger`. Nothing in the server calls it. */\n setLogger?(logger: Logger): void;\n}\n\nexport interface ContentPart {\n type: string;\n text?: string;\n [key: string]: unknown;\n}\n\nexport interface ChatMessage {\n role: \"system\" | \"user\" | \"assistant\" | \"tool\";\n content: string | ContentPart[] | null;\n name?: string;\n tool_calls?: ToolCallMessage[];\n tool_call_id?: string;\n}\n\nexport interface ToolCallMessage {\n id: string;\n type: \"function\";\n function: { name: string; arguments: string };\n}\n\nexport interface ChatCompletionRequest {\n model: string;\n messages: ChatMessage[];\n stream?: boolean;\n /**\n * OpenRouter fallback model list. When present (and the request arrived on\n * the OpenRouter `/api/v1/...` base), the candidate list `[model, ...models]`\n * is attempted in order. A NON-error fixture match wins; an ERROR fixture\n * candidate falls through to the next candidate by default — UNLESS it is\n * terminal, in which case that error is served with no failover. An error is\n * terminal when its fixture sets `fallthrough: false` (per-error-class gate)\n * or when the request sets `provider.allow_fallbacks: false` (request-level\n * gate). A winning (non-error) slug is echoed back as the response `model`;\n * when the chain terminates on an error, the response is the OpenRouter error\n * envelope (`{ error: { code, message, metadata? } }`), which carries no\n * `model` field. Purely additive: a request without `models` behaves as a\n * single-model match. Every other\n * OpenRouter request extension (`route`, `reasoning`, `plugins`,\n * `prediction`, `usage`, and any unknown key) is accepted and journaled via\n * the index signature below — never required, never rejected. aimock does not\n * model those sub-shapes; unknown body keys pass straight through.\n */\n models?: string[];\n /**\n * OpenRouter provider-routing preferences. Accepted loosely and journaled\n * verbatim; the ONLY sub-field aimock reads behaviorally is\n * `allow_fallbacks`. When `allow_fallbacks === false` on an OpenRouter\n * request, the `models[]` fallback loop is suppressed — only the primary is\n * tried, and a primary error fixture is served as terminal instead of\n * falling through (the fail-CLOSED half of the feature). Absent/`true` keeps\n * the default fall-through behavior. Every other provider-prefs key\n * (`order`, `only`, `ignore`, `sort`, …) passes straight through unread.\n */\n provider?: { allow_fallbacks?: boolean; [key: string]: unknown };\n stream_options?: { include_usage?: boolean; [key: string]: unknown };\n temperature?: number;\n max_tokens?: number;\n tools?: ToolDefinition[];\n tool_choice?: string | object;\n response_format?: { type: string; [key: string]: unknown };\n /** Embedding input text, set by the embeddings handler for fixture matching. */\n embeddingInput?: string;\n /** Endpoint type, set by handlers for fixture endpoint filtering. */\n _endpointType?: string;\n /** Context identifier, set by handlers for fixture context routing. */\n _context?: string;\n /**\n * Video-provider discriminator, set by the async video handlers for journal\n * and dispatch clarity only. NOT a fixture match key — `buildFixtureMatch`\n * derives the endpoint from `_endpointType` and never reads this field; the\n * model string is the provider disambiguator (veo-* / grok-imagine-* /\n * openrouter ids do not overlap).\n */\n _videoProvider?: \"openrouter\" | \"veo\" | \"grok\" | \"byteplus\";\n [key: string]: unknown;\n}\n\nexport interface ToolDefinition {\n type: \"function\";\n function: { name: string; description?: string; parameters?: object };\n}\n\n// Fixture matching\n\nexport interface FixtureMatch {\n userMessage?: string | RegExp;\n /**\n * Substring, regexp, or array of substrings matched against the concatenated\n * text content of every `system` role message in the request. Gates fixture\n * activation on values the host plumbs in via system messages (agent\n * context, persona, dynamic config) instead of the user-typed prompt — so\n * changing context state in the calling app causes stale fixtures to fall\n * through to a real upstream instead of silently returning a baked response\n * that no longer reflects reality.\n *\n * When given an array of strings, ALL substrings must be present (AND\n * semantics). Useful when the gate must combine multiple non-adjacent\n * tokens — e.g., a default name AND a default activity list whose JSON\n * positions vary across requests.\n */\n systemMessage?: string | string[] | RegExp;\n inputText?: string | RegExp;\n toolCallId?: string;\n /**\n * Substring matched against the text content of the LAST message when that\n * message is a `tool` result (same last-message rule as `toolCallId`).\n * Discriminates fixtures whose requests differ ONLY inside the tool-result\n * payload — e.g. a human-in-the-loop tool where approve and cancel resume\n * with the same toolCallId but different result JSON.\n */\n toolResultContains?: string;\n toolName?: string;\n model?: string | RegExp;\n responseFormat?: string;\n predicate?: (req: ChatCompletionRequest) => boolean;\n /** Which occurrence of this match to respond to (0-indexed). Undefined means match any. */\n sequenceIndex?: number;\n turnIndex?: number;\n /**\n * Turn-scoped tool-result presence gate: matches on whether the CURRENT turn\n * (the messages after the last `role: \"user\"` message) contains a `role: \"tool\"`\n * message. Scoping to the current turn — rather than the whole conversation —\n * lets a leg-1 (`false`) / leg-2 (`true`) fixture pair keep discriminating on\n * later turns whose history still carries earlier turns' tool results. If the\n * request has no user message, it falls back to scanning the whole conversation.\n */\n hasToolResult?: boolean;\n endpoint?:\n | \"chat\"\n | \"image\"\n | \"speech\"\n | \"transcription\"\n | \"translation\"\n | \"video\"\n | \"embedding\"\n | \"audio-gen\"\n | \"elevenlabs-tts\"\n | \"elevenlabs-voice-design\"\n | \"elevenlabs-voice\"\n | \"elevenlabs-voice-get\"\n | \"elevenlabs-voice-delete\"\n | \"fal-audio\"\n | \"fal\"\n | \"realtime\"\n | \"realtime-transcription\"\n | \"realtime-translation\"\n | \"openai-live\";\n context?: string;\n}\n\n// Fixture response types\n\n/**\n * Fields that override auto-generated envelope values in the built response.\n * Scalar fields (finishReason, role) use OpenAI-canonical values — provider\n * handlers translate automatically. For usage, provide field names native to\n * your target provider (OpenAI Chat: prompt_tokens, completion_tokens;\n * Responses API: input_tokens, output_tokens; Anthropic: input_tokens,\n * output_tokens; Gemini: promptTokenCount, candidatesTokenCount).\n *\n * When total_tokens (or provider equivalent) is omitted, it is auto-computed\n * from the component fields.\n *\n * Provider support: seven fields are common (id, created, model, usage,\n * systemFingerprint, finishReason, role); provider and nativeFinishReason are\n * OpenRouter-only and ignored elsewhere. OpenAI Chat honors the seven common\n * fields; OpenRouter additionally honors provider/nativeFinishReason; Responses\n * API (5: no role, systemFingerprint); Claude (5: no created,\n * systemFingerprint); Gemini (2: only finishReason, usage).\n */\nexport interface ResponseOverrides {\n id?: string;\n created?: number;\n model?: string;\n usage?: {\n prompt_tokens?: number;\n completion_tokens?: number;\n total_tokens?: number;\n input_tokens?: number;\n output_tokens?: number;\n promptTokenCount?: number;\n candidatesTokenCount?: number;\n totalTokenCount?: number;\n /**\n * OpenRouter per-request cost (USD/credits). Fixture-scriptable — powers\n * budget-guard demos (\"assert the guard trips at $5 without spending $5\").\n * Emitted on OpenRouter-shaped responses only, and ONLY when supplied —\n * `cost`/`cost_details` are nullable and omitted by default (never 0).\n */\n cost?: number;\n /**\n * OpenRouter cost breakdown. When the response emits `cost_details` at all\n * it MUST carry all three upstream fields (the canonical `@openrouter/sdk`\n * throws on a partial object); a fixture may supply any subset and the rest\n * default to 0. Only emitted when the fixture supplies a `cost`.\n */\n cost_details?: {\n upstream_inference_cost?: number;\n upstream_inference_prompt_cost?: number;\n upstream_inference_completions_cost?: number;\n [key: string]: unknown;\n };\n /**\n * OpenRouter prompt-token breakdown. Emitted ONLY when overridden — the\n * default response never asserts a fake cache state.\n */\n prompt_tokens_details?: {\n cached_tokens?: number;\n cache_write_tokens?: number;\n audio_tokens?: number;\n [key: string]: unknown;\n };\n /**\n * OpenRouter completion-token breakdown. Emitted ONLY when overridden.\n */\n completion_tokens_details?: { reasoning_tokens?: number; [key: string]: unknown };\n /**\n * OpenRouter bring-your-own-key flag on the usage object. Emitted ONLY when\n * overridden (avoids asserting a fake BYOK state by default).\n */\n is_byok?: boolean;\n /**\n * Forward-compat escape hatch for provider usage fields aimock does not\n * model (OpenRouter `native_tokens_prompt` / `native_tokens_completion`,\n * future breakdowns, …). The recorder persists such fields when an upstream\n * usage frame carries them, and OpenRouter-shaped replays pass any extra key\n * through verbatim onto the emitted `usage` object. The load-time validator\n * still requires extra scalars to be numbers (see fixture-loader.ts), so a\n * typo'd field is caught rather than silently emitted as a string.\n */\n [key: string]: unknown;\n };\n systemFingerprint?: string;\n finishReason?: string;\n role?: string;\n /**\n * OpenRouter top-level `provider` override. When omitted, OpenRouter-shaped\n * responses default it to the author segment of the winning model slug\n * (`openai/gpt-4o` → `\"openai\"`). Ignored for OpenAI (`/v1/...`) responses.\n */\n provider?: string;\n /**\n * OpenRouter `native_finish_reason` override (the raw upstream finish reason).\n * When omitted, OpenRouter-shaped responses mirror `finish_reason`. Ignored\n * for OpenAI responses.\n */\n nativeFinishReason?: string;\n}\n\nexport interface TextResponse extends ResponseOverrides {\n content: string;\n reasoning?: string;\n /**\n * The real cryptographic `signature` captured from a recorded Anthropic\n * thinking turn. When present it is emitted on the replayed thinking block;\n * otherwise replay falls back to aimock's round-trip-safe placeholder.\n * Persisted only alongside a non-empty `reasoning`: a signature captured\n * without plaintext reasoning (e.g. whitespace-only thinking) is intentionally\n * discarded at the persistence layer, since replay attaches signatures only to\n * plaintext thinking blocks.\n */\n reasoningSignature?: string;\n /**\n * Opaque `data` payload(s) of any Anthropic `redacted_thinking` blocks\n * captured from a recorded thinking turn, in stream order. When present they\n * are replayed as faithful `redacted_thinking` content blocks so the encrypted\n * reasoning round-trips; absent for non-Anthropic providers and turns without\n * redacted thinking. Recorded redacted blocks replay as a leading group: the\n * original interleaving of `thinking` and `redacted_thinking` blocks is not\n * preserved (see the CHANGELOG fidelity caveat).\n */\n redactedThinking?: string[];\n webSearches?: string[];\n}\n\nexport interface ToolCall {\n name: string;\n arguments: string;\n id?: string;\n}\n\n/**\n * A single ordered streaming block for a {@link ContentWithToolCallsResponse}.\n *\n * When a combined content+toolCalls fixture sets the optional `blocks` field,\n * builders stream the blocks in array order — enabling tool-call-before-text\n * and interleaved orderings that the legacy `{ content, toolCalls }` shape\n * (always text-first) cannot express. A `text` block carries a text segment; a\n * `toolCall` block mirrors {@link ToolCall} (`name` + JSON-string `arguments`,\n * optional `id`).\n */\nexport type FixtureBlock =\n | { type: \"text\"; text: string }\n | { type: \"toolCall\"; name: string; arguments: string; id?: string };\n\nexport interface ToolCallResponse extends ResponseOverrides {\n toolCalls: ToolCall[];\n reasoning?: string;\n /** Real Anthropic thinking-block signature; see {@link TextResponse.reasoningSignature}. */\n reasoningSignature?: string;\n /** Anthropic redacted_thinking block data; see {@link TextResponse.redactedThinking}. */\n redactedThinking?: string[];\n webSearches?: string[];\n}\n\nexport interface ContentWithToolCallsResponse extends ResponseOverrides {\n /**\n * Combined-turn text. Required for the legacy `{ content, toolCalls }` shape\n * and the combined `{ content, toolCalls, blocks }` shape. OPTIONAL only for a\n * BLOCKS-ONLY fixture (`{ blocks: [...] }` with no `content`/`toolCalls`),\n * where the ordered `blocks` array is the sole source of streamed output and\n * the legacy text-first builder branch is never taken. The runtime guard\n * `isContentWithToolCallsResponse` enforces this: it matches when BOTH\n * `content` + `toolCalls` are present (legacy/combined) OR when a non-empty\n * `blocks` array is present (blocks-only).\n */\n content?: string;\n /** See {@link ContentWithToolCallsResponse.content} — optional only for the blocks-only shape. */\n toolCalls?: ToolCall[];\n /**\n * Optional ordered streaming blocks. When present, builders stream these in\n * array order (tool-first / interleaved); when absent, the legacy\n * `{ content, toolCalls }` text-first path runs unchanged. Purely additive.\n * A non-empty `blocks` array also makes this a FIRST-CLASS blocks-only\n * response even without `content`/`toolCalls` (see those fields above).\n */\n blocks?: FixtureBlock[];\n reasoning?: string;\n /** Real Anthropic thinking-block signature; see {@link TextResponse.reasoningSignature}. */\n reasoningSignature?: string;\n /** Anthropic redacted_thinking block data; see {@link TextResponse.redactedThinking}. */\n redactedThinking?: string[];\n webSearches?: string[];\n}\n\nexport interface ErrorResponse {\n error: {\n message: string;\n type?: string;\n param?: string | null;\n code?: string;\n /**\n * OpenRouter error metadata. Emitted verbatim inside the OpenRouter error\n * envelope (`{ error: { code, message, metadata } }`) when the request\n * arrived on the OpenRouter base. Moderation blocks carry\n * `{ reasons, flagged_input, provider_name, model_slug }` on a 403.\n * Ignored for OpenAI-shaped error responses.\n */\n metadata?: Record<string, unknown>;\n };\n status?: number;\n /** Override the Retry-After header value on 429 responses. Default: 1. */\n retryAfter?: number;\n /**\n * OpenRouter `models[]` failover eligibility for THIS error class. Real\n * OpenRouter fails over INCONSISTENTLY by error class — a `403 budget-exceeded`\n * or a generic \"provider returned error\" is served as terminal (it does NOT\n * advance to the next `models[]` candidate), while 429/503 usually do fail\n * over (openclaw #60191). This flag lets a fixture reproduce that:\n * - absent / `true` (default) — the error candidate FALLS THROUGH to the next\n * `models[]` candidate (backward-compatible; existing fixtures unchanged).\n * - `false` — the error is TERMINAL: the fallback loop stops and serves this\n * error with no failover, even if a later candidate would match.\n *\n * Composes with the request-level `provider.allow_fallbacks`: fall-through\n * happens only when BOTH allow it (if EITHER says don't, don't). Only\n * consulted for OpenRouter `models[]` fallback; ignored elsewhere.\n */\n fallthrough?: boolean;\n}\n\nexport interface EmbeddingResponse {\n embedding: number[];\n}\n\nexport interface ImageItem {\n url?: string;\n b64Json?: string;\n revisedPrompt?: string;\n}\n\nexport interface ImageResponse {\n image?: ImageItem;\n images?: ImageItem[];\n}\n\n// ORDERING CONTRACT: audio fixtures MUST be discriminated by `isAudioResponse`\n// BEFORE the `isContentWithToolCallsResponse` / `isToolCallResponse` / text\n// guards, because the optional companion fields below make these shapes\n// structurally overlap (an AudioResponse with `toolCalls`/`content` would also\n// satisfy those guards otherwise).\nexport interface VoiceDesignPreview {\n generated_voice_id: string;\n // Optional like its siblings below: `voiceDesignToJson` substitutes `\"\"`\n // when it is absent, so requiring it here made that documented fallback\n // unreachable from TypeScript.\n audio_base_64?: string;\n media_type?: string;\n duration_secs?: number;\n language?: string | null;\n}\n\n/**\n * Convenience shape for `LLMock.onElevenLabsVoiceDesign`. Stored as a\n * {@link RawJSONResponse} wrapping `{ previews, text }` — the ElevenLabs\n * `/v1/text-to-voice/design` envelope.\n */\nexport interface VoiceDesignResponse {\n previews: VoiceDesignPreview[];\n text?: string;\n}\n\nexport interface AudioResponse {\n audio: string | { b64Json: string; contentType?: string };\n format?: string;\n /**\n * Companion modalities that can accompany streamed audio. A single Gemini turn\n * may interleave inlineData audio with a functionCall and/or text/thought\n * parts; the recorder preserves them here so the tool call / content / reasoning\n * are not silently discarded when audio is also present.\n */\n toolCalls?: ToolCall[];\n content?: string;\n reasoning?: string;\n}\n\nexport interface TranscriptionResponse {\n transcription: {\n text: string;\n language?: string;\n languages?: Array<{ code: string }>;\n duration?: number;\n usage?: Record<string, unknown>;\n words?: Array<{ word: string; start: number; end: number }>;\n segments?: Array<{ id: number; text: string; start: number; end: number }>;\n };\n}\n\nexport interface VideoResponse {\n video: {\n id: string;\n status: \"processing\" | \"completed\" | \"failed\";\n url?: string;\n /** Failure message surfaced by async video jobs (e.g. OpenRouter `error`). */\n error?: string;\n /** Base64-encoded video bytes served by content-download endpoints. */\n b64?: string;\n /** Generation cost surfaced in usage envelopes (e.g. OpenRouter `usage.cost`). */\n cost?: number;\n /** Clip duration in seconds surfaced by some providers (e.g. Grok `video.duration`). */\n duration?: number;\n };\n}\n\n/**\n * Pass-through JSON response. Used by handlers (e.g. fal.ai) that record\n * arbitrary upstream JSON payloads and replay them verbatim, without the\n * provider-specific shape coercion the other response types impose.\n */\nexport interface RawJSONResponse extends ResponseOverrides {\n json: unknown;\n status?: number;\n /**\n * Billed quantity surfaced on the completed fal `queue-result` response via\n * the `x-fal-billable-units` header (emitted alongside `x-fal-request-id` on\n * the completed result). Real fal sets this header on its queue responses;\n * recent versions of `@tanstack/ai-fal` read it to populate a consumer-side\n * billed-units field (e.g. `usage.unitsBilled`). Omit it to preserve the\n * header-less default — present only to let a fixture opt into exercising a\n * consumer's cost/billing accounting path on replay.\n */\n billableUnits?: number;\n}\n\nexport type FixtureResponse =\n | TextResponse\n | ToolCallResponse\n | ContentWithToolCallsResponse\n | ErrorResponse\n | EmbeddingResponse\n | ImageResponse\n | AudioResponse\n | TranscriptionResponse\n | VideoResponse\n | RawJSONResponse\n | LiveFixtureResponse;\n\n// GA Realtime session types\n\nexport type RealtimePhase = \"final_answer\" | \"commentary\";\n\nexport interface GASessionAudioConfig {\n voice: string | null;\n input_audio_format: { type: string; rate?: number; [key: string]: unknown } | null;\n output_audio_format: { type: string; rate?: number; [key: string]: unknown } | null;\n input_audio_noise_reduction: { type: string } | null;\n input_audio_transcription: { model: string } | null;\n}\n\nexport interface GASessionConfig {\n model: string;\n modalities: string[];\n instructions: string;\n tools: unknown[];\n temperature: number;\n max_response_output_tokens: number | \"inf\";\n audio: GASessionAudioConfig;\n turn_detection: unknown | null;\n input_audio_transcription: { model: string } | null;\n type: \"conversation\" | \"transcription\" | \"translation\";\n reasoning: { effort: string } | null;\n}\n\n// Streaming physics\n\nexport interface StreamingProfile {\n ttft?: number; // Time to first token (ms)\n tps?: number; // Tokens per second\n jitter?: number; // Random variance factor (0-1), default 0\n}\n\n/**\n * Per-frame arrival timestamps captured during proxy recording.\n * Used during replay to reproduce real-world streaming timing instead of\n * the synthetic model (StreamingProfile / flat latency).\n */\nexport interface RecordedTimings {\n ttftMs: number;\n interChunkDelaysMs: number[];\n totalDurationMs: number;\n}\n\n/**\n * Probabilistic chaos injection rates.\n *\n * Rates are evaluated sequentially per request — drop → malformed → rateLimit\n * → disconnect — as four separate draws in that order, and the first draw that\n * hits wins and short-circuits the rest. Each rate is therefore the probability\n * that its OWN draw hits GIVEN that no earlier rate fired, not the share of\n * requests that end in that fault; only `dropRate`, first in the chain, is\n * unconditional. A config of `{ dropRate: 0.5, malformedRate: 0.5 }` yields a\n * ~25 % effective malformed rate, not 50 %, and the same compounding applies to\n * `{ dropRate: 0.5, rateLimitRate: 0.5 }` (~25 % rate limits).\n */\n/**\n * Probabilistic (and one deterministic) fault injection knobs.\n *\n * VALIDATION — ONE policy, whatever the source. Each field is a finite number\n * in its range: the rates in [0, 1], `latencyMs` in [0, 30000]. A value outside\n * it, or one that is not a number at all (`\"0.5abc\"`, `\"Infinity\"`, `NaN`), is\n * REJECTED, never clamped — silent clamping substitutes a fault rate nobody\n * asked for and hides the misconfiguration that produced it.\n *\n * Rejection is reported in the loudest way each source allows, and the three\n * agree: `POST /__aimock/chaos` answers 400, the `--chaos-*` CLI flags refuse\n * to start, and a per-request header or a fixture/server value is refused with\n * a `[chaos]` warning and left unset so the next level of precedence (header >\n * fixture > server) applies.\n */\nexport interface ChaosConfig {\n dropRate?: number;\n malformedRate?: number;\n disconnectRate?: number;\n /**\n * Deterministic delay (ms) injected before the request is handled.\n * Applied when > 0 — header > fixture > server precedence, same as rates.\n * Unlike rates it is not probabilistic: a set latency always fires so\n * timeout/retry suites get a stable signal. Must be in [0, 30000]; a value\n * outside that range is rejected, not clamped (see above).\n */\n latencyMs?: number;\n /**\n * Chance of a 429 rate-limit rejection with `Retry-After`, CONDITIONAL on\n * neither `dropRate` nor `malformedRate` having fired first: it is the third\n * draw in the drop → malformed → rateLimit → disconnect order, and the first\n * hit wins. Paired with a 0.5 `dropRate` a 0.5 `rateLimitRate` produces ~25 %\n * rate limits, not 50 % (see the interface docstring above).\n */\n rateLimitRate?: number;\n}\n\n/**\n * Server-level chaos as the handlers see it: a baseline plus per-`X-Test-Id`\n * overrides installed at runtime via `POST /__aimock/chaos`.\n *\n * Chaos is the LAST link in the precedence chain (request headers > fixture >\n * server), and this makes that last link test-scoped, the way every other\n * mutable axis in aimock is (fixture match-counts, video job maps). Under the\n * shipped topology — one shared `aimock` process serving a parallel suite — a\n * purely global switch would mean one test's chaos failing every other test.\n *\n * Scoping is by testId on BOTH sides: the traffic being evaluated and the\n * control request that installed the override. Both resolve the tag the way\n * `getTestId` does — the `X-Test-Id` header, else `?testId=` in the query\n * string — so a harness that can only tag one of those two ways still lands in\n * the same scope on both sides, and the two can never silently disagree.\n */\nexport interface ChaosScope {\n /** Server-wide baseline: the construction config, or the untagged override. */\n base?: ChaosConfig;\n /**\n * Per-testId overrides, consulted INSTEAD OF `base` — never merged over it.\n *\n * An installed override REPLACES the baseline wholesale for that testId: a\n * server started with `--chaos-latency 500` whose test `t1` installs\n * `{ dropRate: 1 }` gives `t1` traffic a drop and NO latency, because\n * `latencyMs` is not restated. To keep a baseline field, restate it in the\n * override body.\n *\n * Replacement — not a field-wise merge — is deliberate, and it is what makes\n * `POST /__aimock/chaos {}` (\"explicitly no chaos for my test\") different\n * from `DELETE /__aimock/chaos` (\"forget I said anything, fall back to the\n * baseline\"). Under a merge, `POST {}` would be a no-op and that distinction\n * would collapse. It also matches the untagged case, where an override\n * likewise replaces the construction-time config rather than layering on it.\n *\n * The two chain links ABOVE this one — fixture chaos over server chaos, and\n * request headers over both — DO merge field-wise (see `resolveChaosConfig`).\n * Only the scope lookup replaces, because it selects a config rather than\n * refining one. `GET /__aimock/chaos` with the same testId always reports the\n * config actually in effect for that scope, so the replacement is auditable.\n */\n byTestId?: ReadonlyMap<string, ChaosConfig>;\n}\n\n/**\n * What `evaluateChaos` / `applyChaos` accept as server defaults. A plain\n * `ChaosConfig` still works (it is what external callers pass); the server\n * itself passes a `ChaosScope`.\n */\nexport type ChaosDefaults = ChaosConfig | ChaosScope;\n\nexport type ChaosAction = \"drop\" | \"malformed\" | \"rateLimit\" | \"disconnect\";\n\n// Response factory — allows dynamic fixture responses based on the incoming request\n\nexport type ResponseFactory = (\n req: ChatCompletionRequest,\n) => FixtureResponse | Promise<FixtureResponse>;\n\n// Fixture\n\nexport interface Fixture {\n match: FixtureMatch;\n response: FixtureResponse | ResponseFactory;\n latency?: number;\n chunkSize?: number;\n truncateAfterChunks?: number;\n disconnectAfterMs?: number;\n streamingProfile?: StreamingProfile;\n recordedTimings?: RecordedTimings;\n replaySpeed?: number;\n chaos?: ChaosConfig;\n /**\n * Opt into OpenRouter's `: OPENROUTER PROCESSING` SSE keepalive comment\n * lines on this fixture's streamed OpenRouter responses (default OFF).\n * A faithful client skips `:`-prefixed lines before JSON-parsing; enabling\n * this exercises that path. No effect on non-streaming or OpenAI responses.\n */\n openRouterProcessing?: boolean;\n metadata?: {\n systemHash?: string;\n toolsHash?: string;\n };\n}\n\nexport type FixtureOpts = Omit<Fixture, \"match\" | \"response\">;\nexport type EmbeddingFixtureOpts = Pick<FixtureOpts, \"latency\" | \"chaos\">;\n/**\n * Options for the fal queue/run fixture builders. Adds `billableUnits`, which\n * is emitted as the `x-fal-billable-units` header on the completed\n * `queue-result` response (see {@link RawJSONResponse.billableUnits}).\n */\nexport type FalQueueOpts = FixtureOpts & { billableUnits?: number };\n\n// Fixture file format (JSON on disk)\n//\n// File-entry types are intentionally relaxed compared to their runtime\n// counterparts so that fixture authors can write JSON objects where the\n// API ultimately expects a JSON *string*. The fixture loader auto-\n// stringifies these before building the runtime Fixture.\n\nexport interface FixtureFileToolCall {\n name: string;\n /** Accepts a JSON object or array for convenience — the loader will JSON.stringify it. */\n arguments: string | Record<string, unknown> | unknown[];\n id?: string;\n}\n\n/**\n * On-disk counterpart of {@link FixtureBlock}. A `toolCall` block's\n * `arguments` is relaxed exactly like {@link FixtureFileToolCall} so authors\n * may write a JSON object/array; the loader JSON.stringifies it into the\n * runtime string form. Normalizes to a {@link FixtureBlock}.\n */\nexport type FixtureFileBlock =\n | { type: \"text\"; text: string }\n | {\n type: \"toolCall\";\n name: string;\n /** Accepts a JSON object or array for convenience — the loader will JSON.stringify it. */\n arguments: string | Record<string, unknown> | unknown[];\n id?: string;\n };\n\nexport interface FixtureFileToolCallResponse extends ResponseOverrides {\n toolCalls: FixtureFileToolCall[];\n reasoning?: string;\n /** Real Anthropic thinking-block signature; see {@link TextResponse.reasoningSignature}. */\n reasoningSignature?: string;\n /** Anthropic redacted_thinking block data; see {@link TextResponse.redactedThinking}. */\n redactedThinking?: string[];\n webSearches?: string[];\n}\n\nexport interface FixtureFileTextResponse extends ResponseOverrides {\n /** Accepts a JSON object or array (structured output) — the loader will JSON.stringify it. */\n content: string | Record<string, unknown> | unknown[];\n reasoning?: string;\n /** Real Anthropic thinking-block signature; see {@link TextResponse.reasoningSignature}. */\n reasoningSignature?: string;\n /** Anthropic redacted_thinking block data; see {@link TextResponse.redactedThinking}. */\n redactedThinking?: string[];\n webSearches?: string[];\n}\n\nexport interface FixtureFileContentWithToolCallsResponse extends ResponseOverrides {\n /**\n * Accepts a JSON object or array (structured output) — the loader will\n * JSON.stringify it. OPTIONAL only for a BLOCKS-ONLY fixture (mirrors\n * {@link ContentWithToolCallsResponse.content}); required for the\n * legacy/combined shapes.\n */\n content?: string | Record<string, unknown> | unknown[];\n /** See {@link FixtureFileContentWithToolCallsResponse.content} — optional only for the blocks-only shape. */\n toolCalls?: FixtureFileToolCall[];\n /**\n * Optional ordered streaming blocks (mirrors the in-memory\n * {@link ContentWithToolCallsResponse.blocks}). When present, builders stream\n * these in array order (tool-first / interleaved); a `toolCall` block's\n * object `arguments` is auto-stringified just like `toolCalls[].arguments`.\n * Absent → legacy text-first path runs unchanged. Purely additive. Uses the\n * on-disk {@link FixtureFileBlock} shape with relaxed `arguments`. A non-empty\n * `blocks` array alone makes this a first-class blocks-only fixture.\n */\n blocks?: FixtureFileBlock[];\n reasoning?: string;\n /** Real Anthropic thinking-block signature; see {@link TextResponse.reasoningSignature}. */\n reasoningSignature?: string;\n /** Anthropic redacted_thinking block data; see {@link TextResponse.redactedThinking}. */\n redactedThinking?: string[];\n webSearches?: string[];\n}\n\nexport type FixtureFileResponse =\n | FixtureFileTextResponse\n | FixtureFileToolCallResponse\n | FixtureFileContentWithToolCallsResponse\n | ErrorResponse\n | EmbeddingResponse\n | ImageResponse\n | AudioResponse\n | TranscriptionResponse\n | VideoResponse\n | RawJSONResponse\n | LiveFixtureResponse;\n\nexport interface FixtureFile {\n fixtures: FixtureFileEntry[];\n}\n\nexport interface FixtureFileEntry {\n match: {\n userMessage?: string;\n /**\n * String (single substring) or array of strings (all must be present).\n * Mirrors the runtime FixtureMatch.systemMessage but without the RegExp\n * form, which JSON cannot express.\n */\n systemMessage?: string | string[];\n inputText?: string;\n toolCallId?: string;\n /**\n * Substring matched against the last tool-result message's text content.\n * Mirrors the runtime FixtureMatch.toolResultContains.\n */\n toolResultContains?: string;\n toolName?: string;\n model?: string;\n responseFormat?: string;\n sequenceIndex?: number;\n turnIndex?: number;\n /**\n * Turn-scoped tool-result presence gate: matches on whether the CURRENT turn\n * (the messages after the last `role: \"user\"` message) contains a `role: \"tool\"`\n * message, not the whole conversation. Falls back to scanning the whole\n * conversation when the request has no user message. Mirrors the runtime\n * `FixtureMatch.hasToolResult`.\n */\n hasToolResult?: boolean;\n endpoint?:\n | \"chat\"\n | \"image\"\n | \"speech\"\n | \"transcription\"\n | \"translation\"\n | \"video\"\n | \"embedding\"\n | \"audio-gen\"\n | \"elevenlabs-tts\"\n | \"elevenlabs-voice-design\"\n | \"elevenlabs-voice\"\n | \"elevenlabs-voice-get\"\n | \"elevenlabs-voice-delete\"\n | \"fal-audio\"\n | \"fal\"\n | \"realtime\"\n | \"realtime-transcription\"\n | \"realtime-translation\"\n | \"openai-live\";\n context?: string;\n // predicate not supported in JSON files\n };\n response: FixtureFileResponse;\n latency?: number;\n chunkSize?: number;\n truncateAfterChunks?: number;\n disconnectAfterMs?: number;\n streamingProfile?: StreamingProfile;\n recordedTimings?: RecordedTimings;\n replaySpeed?: number;\n chaos?: ChaosConfig;\n /** See {@link Fixture.openRouterProcessing}. */\n openRouterProcessing?: boolean;\n metadata?: {\n systemHash?: string;\n toolsHash?: string;\n };\n}\n\n// Request journal\n\n/**\n * A recorded request body.\n *\n * Most journal entries carry a chat-completion request, but every service\n * journals through one entry type and several of them record a body that is\n * not one: the fine-tuning create payload is recorded verbatim so the journal\n * reports what the caller actually sent, and the journal's own size cap\n * substitutes a truncation marker for an oversized body. Neither shape has a\n * `model`/`messages` pair, so typing the field as `ChatCompletionRequest`\n * alone forces those writers through a cast that claims fields that are not\n * there — the second member exists so they do not have to lie.\n *\n * TypeScript collapses the two for ASSIGNMENT (`ChatCompletionRequest` has an\n * index signature, so it is itself a `Record<string, unknown>`); the union is\n * kept two-membered because it is what the field means, not because it narrows\n * anything. For READING, treat the body as opaque JSON — that is already how\n * every consumer uses it (the journal cap re-serializes it, `GET\n * /__aimock/journal` hands it back) — and property-check before reaching for a\n * chat-request field.\n */\nexport type JournalBody = ChatCompletionRequest | Record<string, unknown>;\n\nexport interface JournalEntry {\n id: string;\n timestamp: number;\n method: string;\n path: string;\n headers: Record<string, string>;\n body: JournalBody | null;\n service?: string;\n /**\n * Resolved test id of an MCP request (`\"__default__\"` when none), for an\n * MCP mount to set. Journal test-id filtering does not read it: it\n * re-derives the id from the headers and path (`journalEntryTestId`).\n */\n testId?: string;\n /** Resolved context of an MCP request, `null` when none; for an MCP mount to set. */\n context?: string | null;\n response: {\n status: number;\n fixture: Fixture | null;\n /** For an MCP mount to set on `tools/call` entries a fake answered or failed. */\n mcpFake?: { id: string | null; outcome: McpFakeOutcome };\n /**\n * What was going to serve this request. \"fixture\" = a fixture matched (or\n * would have, before chaos intervened). \"proxy\" = no fixture matched and\n * proxy was configured. \"internal\" = entries where the request was served\n * by aimock's own synthetic logic — neither a matched fixture nor a\n * configured proxy: chaos-path entries (e.g. chaos on the OpenRouter\n * video lifecycle endpoints; in REPLAY mode their normal 200/400/401/404\n * entries omit source, while record-mode 200s on those endpoints carry\n * source:\"proxy\"), the OpenRouter video models listing synthesized as the\n * fallback after a FAILED proxy attempt, and the services whose responses\n * are synthesized outright — every fine-tuning entry carries it, success\n * and error alike, since that store is aimock's own and no fixture or\n * proxy ever serves it. Absent when the distinction doesn't apply\n * (e.g. 404/503 fallback where nothing was going to serve).\n */\n source?: \"fixture\" | \"proxy\" | \"internal\";\n interrupted?: boolean;\n interruptReason?: string;\n /**\n * The handler crashed AFTER the response completed. The client received\n * `status` in full, so this is not an interruption; the message is what\n * the crash said.\n */\n error?: string;\n chaosAction?: ChaosAction;\n /** When the X-AIMock-Strict header overrode the server default. */\n strictOverride?: boolean;\n };\n}\n\n// SSE chunk types (OpenAI format)\n\n/**\n * OpenRouter-only additions layered onto a `usage` object when a response is\n * shaped for the OpenRouter `/api/v1/...` base. `cost`/`cost_details` are\n * NULLABLE and emitted only when a fixture supplies a cost (default: omitted).\n * When `cost_details` is emitted it carries all three upstream fields (partial\n * objects break the canonical SDK). The detail breakdowns and `is_byok` appear\n * only when a fixture overrides them; an emitted `prompt_tokens_details` always\n * carries `cached_tokens` and an emitted `completion_tokens_details` always\n * carries `reasoning_tokens` (required-if-present in the AI SDK provider).\n */\nexport interface OpenRouterUsageExtras {\n cost?: number;\n cost_details?: {\n upstream_inference_cost: number;\n upstream_inference_prompt_cost: number;\n upstream_inference_completions_cost: number;\n [key: string]: unknown;\n };\n prompt_tokens_details?: {\n cached_tokens: number;\n cache_write_tokens?: number;\n audio_tokens?: number;\n [key: string]: unknown;\n };\n completion_tokens_details?: { reasoning_tokens: number; [key: string]: unknown };\n is_byok?: boolean;\n /**\n * Provider usage fields aimock does not model, passed through verbatim from a\n * fixture's `response.usage` (typically written by the recorder from a real\n * upstream usage frame — e.g. OpenRouter `native_tokens_prompt`).\n */\n [key: string]: unknown;\n}\n\nexport interface SSEChunk {\n id: string;\n object: \"chat.completion.chunk\";\n created: number;\n model: string;\n choices: SSEChoice[];\n /** Nullable: OpenRouter shaping emits this on every chunk (null when unset). */\n system_fingerprint?: string | null;\n usage?: {\n prompt_tokens: number;\n completion_tokens: number;\n total_tokens: number;\n } & OpenRouterUsageExtras;\n /** OpenRouter top-level provider that served the chunk. OpenRouter shaping only. */\n provider?: string;\n /** OpenRouter emits `service_tier: null` on the final (usage-bearing) chunk. Shaping only. */\n service_tier?: string | null;\n}\n\nexport interface SSEChoice {\n index: number;\n delta: SSEDelta;\n logprobs: null;\n finish_reason: string | null;\n /** OpenRouter raw upstream finish reason, alongside the normalized one. */\n native_finish_reason?: string | null;\n}\n\nexport interface SSEDelta {\n role?: string;\n content?: string | null;\n reasoning_content?: string;\n tool_calls?: SSEToolCallDelta[];\n}\n\nexport interface SSEToolCallDelta {\n index: number;\n id?: string;\n type?: \"function\";\n function?: { name?: string; arguments?: string };\n}\n\n// Non-streaming completion response types (OpenAI format)\n\nexport interface ChatCompletion {\n id: string;\n object: \"chat.completion\";\n created: number;\n model: string;\n choices: ChatCompletionChoice[];\n usage: {\n prompt_tokens: number;\n completion_tokens: number;\n total_tokens: number;\n } & OpenRouterUsageExtras;\n /**\n * Nullable: OpenRouter shaping always emits this on the non-streaming\n * response (null when no override) because the canonical `@openrouter/sdk`\n * requires the field. OpenAI responses omit it unless overridden.\n */\n system_fingerprint?: string | null;\n /** OpenRouter top-level provider that served the request. OpenRouter shaping only. */\n provider?: string;\n /** OpenRouter emits `service_tier: null` on the non-streaming response. Shaping only. */\n service_tier?: string | null;\n}\n\nexport interface ChatCompletionChoice {\n index: number;\n message: ChatCompletionMessage;\n logprobs: null;\n finish_reason: string;\n /** OpenRouter raw upstream finish reason, alongside the normalized one. */\n native_finish_reason?: string;\n}\n\nexport interface ChatCompletionMessage {\n role: string;\n content: string | null;\n refusal: string | null;\n reasoning_content?: string;\n /**\n * OpenRouter emits `reasoning` (null when absent) on the response message.\n * OpenRouter shaping mirrors `reasoning_content` here (or null). Omitted for\n * OpenAI responses.\n */\n reasoning?: string | null;\n tool_calls?: ToolCallMessage[];\n}\n\n// Server options\n\nexport type RecordProviderKey =\n | \"openai\"\n | \"anthropic\"\n | \"gemini\"\n | \"gemini-interactions\"\n | \"vertexai\"\n | \"bedrock\"\n | \"azure\"\n | \"ollama\"\n | \"cohere\"\n | \"elevenlabs\"\n | \"fal\"\n | \"openrouter\"\n | \"veo\"\n | \"grok\"\n | \"byteplus\";\n\nexport interface RecordConfig {\n providers: Partial<Record<RecordProviderKey, string>>;\n /**\n * aimock's own built-in upstream API keys, keyed by provider. Opt-in and\n * backward-compatible: when set for a provider, aimock injects the key on a\n * fixture-miss passthrough IF the caller sent no credential or a dummy\n * placeholder (see `applyProviderAuth`); a real caller key always overrides.\n * Only static-key providers are eligible: OpenAI/OpenRouter/Cohere/Grok/BytePlus/Ollama\n * (bearer), Anthropic (x-api-key), Gemini/Gemini-Interactions/Veo\n * (x-goog-api-key), Azure OpenAI (api-key), ElevenLabs (xi-api-key), and fal\n * (Authorization: Key). Signed/OAuth providers (Bedrock SigV4, Vertex AI\n * OAuth) are never rewritten. Sourced from AIMOCK_PROVIDER_*_KEY env vars by\n * the CLI (secrets stay out of `ps`).\n */\n providerKeys?: Partial<Record<RecordProviderKey, string>>;\n fixturePath?: string;\n /** Proxy unmatched requests without saving fixtures or caching in memory. */\n proxyOnly?: boolean;\n /**\n * When true, record the exact model version string returned by the provider\n * (e.g. \"gpt-4o-2024-08-06\") instead of stripping the date suffix to a\n * canonical alias (e.g. \"gpt-4o\"). Default: false.\n */\n recordFullModelVersion?: boolean;\n /**\n * fal-specific recording knobs for the queue-walk recorder. During recording\n * the queue handler POSTs submit, polls `status_url` until COMPLETED, then\n * GETs `response_url` for the final job body — saved as the fixture. Tune\n * the poll cadence and timeout here if upstream is unusually slow or fast.\n */\n fal?: FalRecordConfig;\n /**\n * OpenRouter-video-specific recording knobs for the live lifecycle proxy on\n * `/api/v1/videos` (submit/poll proxied 1:1; completed jobs are captured\n * eagerly as fixtures).\n */\n openRouterVideo?: OpenRouterVideoRecordConfig;\n /**\n * Connection idle timeout (ms) on the upstream request socket — fires if the\n * socket is inactive for this duration at any point before the response body\n * begins. Default: 30_000 (30s). Increase for upstreams with slow initial\n * responses (reasoning models, queue-backed providers).\n *\n * Nuance on the OpenRouter video surface: the small-JSON lifecycle fetches\n * (submit, status poll, models listing) apply this value as a TOTAL\n * deadline on the whole fetch — indistinguishable from an idle timeout for\n * envelope-sized bodies. The byte-bearing content fetches (eager capture,\n * proxy-only content relay) gate only the response HEADERS on this value;\n * their body progress is governed by `bodyTimeoutMs` idle semantics.\n *\n * Ceiling note: the fetch-based OpenRouter proxy paths run on Node's\n * built-in undici dispatcher, which carries its own ~300s\n * headers/body-timeout defaults — values above that ceiling do not take\n * effect on those paths without installing a custom undici dispatcher\n * (out of aimock's scope).\n */\n upstreamTimeoutMs?: number;\n /**\n * Idle timeout (ms) on the upstream response body — fires if the upstream\n * goes silent (no bytes) for this long after the response has started.\n * Default: 30_000 (30s). Reasoning models under concurrent load can leave\n * 30s+ gaps between streaming chunks while the model is thinking; lift this\n * to e.g. 180_000 in those setups. The OpenRouter video content fetches use\n * the same idle semantics: the timer re-arms on every chunk, so a steadily\n * downloading multi-minute video never times out — only a silent stall does.\n */\n bodyTimeoutMs?: number;\n /**\n * Maximum number of bytes aimock will accumulate in memory from a single\n * proxied upstream response on the record/proxy path. The full response is\n * still relayed to the client byte-for-byte; this cap only bounds the\n * in-memory buffer used to collapse/journal the response. Once the cap is\n * exceeded aimock stops appending to the buffer, marks the response as\n * truncated, and skips collapse/recording — preventing both unbounded heap\n * growth and the `RangeError: Invalid string length` that a >512MB string\n * would otherwise throw. Default: 64 MiB.\n */\n maxProxyBufferBytes?: number;\n /**\n * Maximum number of SSE/NDJSON/EventStream frames whose per-frame state\n * (`frameTimestamps`, parse buffers) aimock retains for a single proxied\n * response. Frame state is count-indexed, not byte-sized, so a long-lived or\n * never-ending stream accumulates it unbounded even when `maxProxyBufferBytes`\n * is generous. Tripping truncation on EITHER bytes OR frame count bounds both;\n * on the trip the accumulated frame state is freed and collapse/recording is\n * skipped (the full response is still relayed to the client byte-for-byte).\n * Default: 5,000,000 frames.\n */\n maxProxyBufferFrames?: number;\n}\n\nexport interface OpenRouterVideoRecordConfig {\n /**\n * Maximum decoded video size (bytes) embedded as `b64` in a recorded\n * fixture. Captures larger than the cap are persisted WITHOUT `b64` (with a\n * `_warning` in the fixture file) so a multi-hundred-MB video cannot bloat\n * the fixture directory. The cap is also a memory guard: an upstream\n * response that DECLARES an over-cap Content-Length is skipped without\n * downloading, and a response with no declared length is streamed with the\n * byte count enforced during the read — on exceed the download is aborted\n * and nothing oversized is retained in memory. In both cases the\n * same-session job serves the placeholder MP4. Default: 33554432 (32 MB\n * decoded). Set 0 for unlimited. Negative or non-integer values are treated\n * as the default (createServer warns at startup).\n */\n maxContentBytes?: number;\n}\n\nexport interface FalRecordConfig {\n /** Interval between status polls upstream during recording. Default: 1000ms. */\n pollIntervalMs?: number;\n /** Total budget for an upstream queue walk before aborting. Default: 900000ms (15 min) to accommodate video generation. */\n timeoutMs?: number;\n}\n\nexport interface MockServerOptions {\n live?: LiveOptions;\n /** Optional inbound test-client access keys. Omit to preserve permissive behavior. */\n auth?: ApiKeyAuthConfig;\n port?: number;\n host?: string;\n latency?: number;\n chunkSize?: number;\n replaySpeed?: number;\n /** Log verbosity. CLI default is \"info\"; programmatic default (when omitted) is \"silent\". */\n logLevel?: \"silent\" | \"warn\" | \"info\" | \"debug\";\n chaos?: ChaosConfig;\n /** Enable Prometheus-compatible /metrics endpoint. */\n metrics?: boolean;\n /** Strict mode: return 503 instead of 404 when no fixture matches. */\n strict?: boolean;\n /** Record-and-replay: proxy unmatched requests to upstream and save fixtures. */\n record?: RecordConfig;\n /**\n * Maximum number of request/response entries to retain in the in-memory\n * journal. Oldest entries are dropped FIFO when the cap is exceeded.\n * Set to 0 (or omit) for unbounded retention. Negative values are\n * rejected at the CLI parse layer; programmatically they are treated\n * as 0 (unbounded) for back-compat.\n *\n * Default: 1000 (applied by `createServer` when omitted). The CLI passes\n * through its own default. Short-lived test harnesses that want every\n * request recorded can opt in to unbounded retention by passing 0.\n */\n journalMaxEntries?: number;\n /**\n * Maximum number of unique testIds retained in the journal's fixture\n * match-count map. Oldest testIds are dropped FIFO when the cap is\n * exceeded. Set to 0 (or omit) for unbounded retention. Negative values\n * are rejected at the CLI parse layer; programmatically they are treated\n * as 0 (unbounded) for back-compat.\n *\n * Default: 500 (applied by `createServer` when omitted). Without a cap\n * this map can grow over time in long-running servers that see many\n * unique testIds.\n */\n fixtureCountsMaxTestIds?: number;\n /**\n * Normalize requests before matching and recording. Useful for stripping\n * dynamic data (timestamps, UUIDs, session IDs) that would cause fixture\n * mismatches on replay.\n *\n * When set, string matching for `userMessage` and `inputText` uses exact\n * equality (`===`) instead of substring (`includes`) to prevent false\n * positives from shortened keys.\n */\n requestTransform?: (req: ChatCompletionRequest) => ChatCompletionRequest;\n /**\n * Configure fal.ai queue polling progression. By default a job completes\n * on submit (preserves the legacy `COMPLETED`-on-submit shape). Opt into a\n * realistic `IN_QUEUE → IN_PROGRESS → COMPLETED` progression by setting\n * positive poll thresholds — useful for exercising client code that polls\n * `/status` and reacts to intermediate states.\n *\n * Applies to the general fal handler (`x-fal-target-host`-routed); the\n * legacy `/fal/queue/...` audio handler is unaffected.\n */\n falQueue?: FalQueueConfig;\n /**\n * Configure OpenRouter async video job polling progression\n * (`pending → in_progress → completed | failed` on `GET /api/v1/videos/{id}`).\n * Same threshold semantics as `falQueue`. By default (0/0) the job is\n * seeded terminal at submit — content is downloadable with zero polls, and\n * the first status poll merely reports the already-terminal status.\n */\n openRouterVideo?: FalQueueConfig;\n /**\n * Configure Google Veo async video job polling progression\n * (`done:false → done:true` on `GET /v1beta/operations/{name}`). Same\n * threshold semantics as `openRouterVideo`; the internal\n * `pending → in_progress → completed | failed` model is serialized to the\n * two-state Veo wire.\n */\n veoVideo?: FalQueueConfig;\n /**\n * Configure xAI Grok Imagine async video job polling progression\n * (`pending → done | failed` on `GET /v1/videos/{request_id}`). Same\n * threshold semantics as `openRouterVideo`; progress is synthesized from the\n * poll count.\n */\n grokVideo?: FalQueueConfig;\n /**\n * Configure BytePlus Ark (Seedance) async video task polling progression\n * (`queued → running → <recorded terminal status>` on\n * `GET /api/v3/contents/generations/tasks/{id}`). Same threshold semantics as\n * `grokVideo`; unlike the others the TERMINAL status is not synthesized — it\n * is whatever the recorded/authored envelope carries.\n */\n bytePlusVideo?: FalQueueConfig;\n}\n\nexport interface ApiKeyAuthConfig {\n apiKeys: readonly string[];\n}\n\n/**\n * Poll-progression thresholds, documented below in fal queue terms; when used\n * as `openRouterVideo` the states map to `pending` / `in_progress` /\n * `completed | failed`.\n */\nexport interface FalQueueConfig {\n /**\n * Status polls before transitioning `IN_QUEUE → IN_PROGRESS`. Unset and an\n * explicit `0` differ: when BOTH fields are unset the job completes\n * synchronously on submit (no IN_QUEUE / IN_PROGRESS polls emitted), but\n * explicitly setting this field — even to `0` — enables progression when\n * `pollsBeforeCompleted` is unset, with `pollsBeforeCompleted` defaulting\n * to `pollsBeforeInProgress + 1` so the job passes through IN_PROGRESS\n * (an explicit `pollsBeforeCompleted: 0` completes on submit only when\n * `pollsBeforeInProgress` is `0` or unset — otherwise the clamp below\n * lifts it to `pollsBeforeInProgress`).\n */\n pollsBeforeInProgress?: number;\n /**\n * Status polls before transitioning to `COMPLETED`. Default: 0 when\n * `pollsBeforeInProgress` is also unset (no progression), otherwise\n * `pollsBeforeInProgress + 1` so the job spends one poll in IN_PROGRESS.\n * An explicit value lower than `pollsBeforeInProgress` is clamped up so\n * IN_PROGRESS is never skipped. When equal to a nonzero\n * `pollsBeforeInProgress` — or when `pollsBeforeInProgress` is unset or 0\n * and this field is 1 (the IN_PROGRESS branch consumes the first poll) —\n * the job still spends one poll in IN_PROGRESS, so the terminal status\n * lands one poll later than configured.\n */\n pollsBeforeCompleted?: number;\n}\n\n// Handler defaults — the common shape passed from server.ts to every handler\n\nexport interface HandlerDefaults {\n latency: number;\n chunkSize: number;\n replaySpeed: number;\n logger: Logger;\n /**\n * Reads resolve to a `ChaosScope` on a real server (baseline + per-testId\n * overrides); assigning `undefined` drops every runtime override.\n */\n chaos?: ChaosDefaults;\n /**\n * Live per-testId chaos overrides, owned by the server instance so the\n * control API can install one without reaching through the getter.\n */\n chaosByTestId?: Map<string, ChaosConfig>;\n registry?: MetricsRegistry;\n record?: RecordConfig;\n strict?: boolean;\n requestTransform?: (req: ChatCompletionRequest) => ChatCompletionRequest;\n falQueue?: FalQueueConfig;\n openRouterVideo?: FalQueueConfig;\n veoVideo?: FalQueueConfig;\n grokVideo?: FalQueueConfig;\n /**\n * Configure BytePlus Ark (Seedance) async video task polling progression\n * (`queued → running → <recorded terminal status>` on\n * `GET /api/v3/contents/generations/tasks/{id}`). Same threshold semantics as\n * `grokVideo`; unlike the others the TERMINAL status is not synthesized — it\n * is whatever the recorded/authored envelope carries.\n */\n bytePlusVideo?: FalQueueConfig;\n}\n\n// MCP fakes — scenario-scoped MCP tool fakes in fixture files (`mcpFakes`)\n\n/**\n * Block scope: `\"shared\"`, or exact test id and/or context (at least one;\n * `{}` is not a scope). Readonly: validated scopes are frozen.\n */\nexport type McpFakeScope =\n | \"shared\"\n | Readonly<{ testId: string; context?: string }>\n | Readonly<{ testId?: string; context: string }>;\n\n/**\n * `T` with every nested property and array read-only: the type of a value the\n * MCP fakes store deep-freezes before it hands it out.\n */\nexport type McpFakeDeepReadonly<T> = T extends (...args: never[]) => unknown\n ? T\n : T extends object\n ? { readonly [K in keyof T]: McpFakeDeepReadonly<T[K]> }\n : T;\n\n/** MCP `Annotations` on a content block. */\nexport interface McpFakeAnnotations {\n audience?: Array<\"user\" | \"assistant\">;\n /** From 0 (least) to 1 (most important). */\n priority?: number;\n /** RFC 3339 date-time with seconds and a `Z` or `±hh:mm` offset. */\n lastModified?: string;\n}\n\n/** MCP `Icon` on a `resource_link` content block. */\nexport interface McpFakeIcon {\n src: string;\n mimeType?: string;\n sizes?: string[];\n theme?: \"light\" | \"dark\";\n}\n\n/** MCP `TextResourceContents` / `BlobResourceContents`: exactly one of `text` / `blob`. */\nexport type McpFakeResourceContents = {\n uri: string;\n mimeType?: string;\n _meta?: Record<string, unknown>;\n} & ({ text: string; blob?: never } | { blob: string; text?: never });\n\ntype McpFakeContentCommon = {\n annotations?: McpFakeAnnotations;\n _meta?: Record<string, unknown>;\n};\n\n/** One MCP content block of a tool result (`ContentBlock`); `data` and `blob` are base64. */\nexport type McpFakeContentBlock = McpFakeContentCommon &\n (\n | { type: \"text\"; text: string }\n | { type: \"image\"; data: string; mimeType: string }\n | { type: \"audio\"; data: string; mimeType: string }\n | {\n type: \"resource_link\";\n uri: string;\n name: string;\n title?: string;\n description?: string;\n mimeType?: string;\n size?: number;\n icons?: McpFakeIcon[];\n }\n | { type: \"resource\"; resource: McpFakeResourceContents }\n );\n\n/** A full MCP `CallToolResult`, served unchanged. No other keys. */\nexport interface McpFakeFullResult {\n content: McpFakeContentBlock[];\n isError?: boolean;\n structuredContent?: Record<string, unknown>;\n _meta?: Record<string, unknown>;\n}\n\n/**\n * Structured data: any JSON object without the `CallToolResult`\n * keys, served as text plus `structuredContent`.\n */\nexport type McpFakeStructuredResult = Record<string, unknown> & {\n content?: never;\n isError?: never;\n structuredContent?: never;\n _meta?: never;\n};\n\n/**\n * A call entry's `result` value. Validation also checks what the type cannot\n * say: base64 `data` / `blob`, `priority` from 0 to 1, the `lastModified`\n * format, and plain JSON throughout. Unknown keys inside a content item are\n * allowed and served as given.\n */\nexport type McpFakeResult =\n | string\n | McpFakeContentBlock[]\n | McpFakeFullResult\n | McpFakeStructuredResult;\n\n/** How a call entry matches: exactly one of `args` / `anyArgs`. */\nexport type McpFakeCallMatch =\n | { args: Record<string, unknown>; anyArgs?: never }\n | { anyArgs: true; args?: never };\n\n/** What a call entry answers: exactly one of `result` / `error`. */\nexport type McpFakeCallAnswer =\n | { result: McpFakeResult; error?: never }\n | { error: string; result?: never };\n\n/** One ordered answer for a tool. */\nexport type McpFakeCall = McpFakeCallMatch & McpFakeCallAnswer & { id?: string };\n\n/** One faked tool in a block. */\nexport interface McpFakeTool {\n name: string;\n description?: string;\n inputSchema?: Record<string, unknown>;\n calls: McpFakeCall[];\n}\n\n/** One `mcpFakes` block. */\nexport interface McpFakeBlock {\n scope: McpFakeScope;\n mount?: string;\n undeclaredTools?: McpFakeUndeclaredPolicy;\n tools: McpFakeTool[];\n}\n\nexport type McpFakeUndeclaredPolicy = \"allow\" | \"deny\";\n\n/**\n * The resolved identity of one MCP request: test id, context and undeclared\n * override, each from the request or else from the session.\n * `null` means \"not supplied\". The identity shape the fake store's matching\n * methods take (`applicable`, `selectTier`, `claim`, `policy`, `declaredTools`,\n * `listTools`).\n */\nexport interface McpFakeIdentity {\n testId: string | null;\n context: string | null;\n undeclared: McpFakeUndeclaredPolicy | null;\n}\n\n/**\n * One raw block as a loader hands it off, before validation. `source` is the\n * entry-id source string; `blockIndex` is `null` when `mcpFakes` is a single object.\n */\nexport interface McpFakeSource {\n source: string;\n blockIndex: number | null;\n raw: unknown;\n}\n\n/**\n * `response.mcpFake.outcome` on a `tools/call` journal entry. `evicted`:\n * the request's test id lost its consumption state to the FIFO test-id cap.\n */\nexport type McpFakeOutcome = \"answered\" | \"mismatch\" | \"exhausted\" | \"not_declared\" | \"evicted\";\n\n/**\n * JSON-RPC error codes of the four fake failures, keyed by\n * `error.data.aimock.code`. `-31010` and `-31011` sit outside the JSON-RPC\n * reserved range. `MCP_FAKE_EVICTED` is for a lookup of a declared tool by a\n * test id whose state the FIFO test-id cap evicted, until it is reset.\n */\nexport const MCP_FAKE_ERROR_CODES = {\n MCP_FAKE_NOT_DECLARED: -32602,\n MCP_FAKE_MISMATCH: -32602,\n MCP_FAKE_EXHAUSTED: -31010,\n MCP_FAKE_EVICTED: -31011,\n} as const;\n\nexport type McpFakeErrorCode = keyof typeof MCP_FAKE_ERROR_CODES;\n"],"mappings":";;;;;;;;AA4gDA,MAAa,uBAAuB;CAClC,uBAAuB;CACvB,mBAAmB;CACnB,oBAAoB;CACpB,kBAAkB;CACnB"}
package/dist/types.d.cts CHANGED
@@ -1,6 +1,8 @@
1
1
  import { Journal } from "./journal.cjs";
2
+ import { LiveFixtureResponse, LiveOptions } from "./live-types.cjs";
2
3
  import { Logger } from "./logger.cjs";
3
4
  import { MetricsRegistry } from "./metrics.cjs";
5
+ import { McpFakeAddOrigin, McpFakeAddResult } from "./mcp-fakes.cjs";
4
6
  import * as http$1 from "node:http";
5
7
  import * as net from "node:net";
6
8
 
@@ -15,6 +17,23 @@ interface Mountable {
15
17
  setJournal?(journal: Journal): void;
16
18
  setBaseUrl?(url: string): void;
17
19
  setRegistry?(registry: MetricsRegistry): void;
20
+ /**
21
+ * MCP fakes. A mount "is an MCPMock" for fakes if and only if it
22
+ * implements `addMcpFakes`. Always appends. `origin` picks the entry-id
23
+ * source and its counter: `file` keeps each block's `source` (`@<k>` load
24
+ * counter); `code` / `control-api` is one run-time addition (`code#<n>` /
25
+ * `control-api#<n>`). Returns the shadowed-entry warnings with the real
26
+ * entry ids. When any block is bad, or the input holds no blocks, throws one
27
+ * `FixtureLoadError` (an `McpFakesAddError` carrying every error found and
28
+ * the warnings) and adds nothing.
29
+ */
30
+ addMcpFakes?(blocks: McpFakeSource[], origin: McpFakeAddOrigin): McpFakeAddResult;
31
+ /** Unload every fake on this mount. The entry-id counters are kept. */
32
+ clearMcpFakes?(): void;
33
+ /** Reset fake consumption state for one test id, or for all when omitted. */
34
+ resetScenarioState?(testId?: string): void;
35
+ /** Hands an MCP mount a `Logger`. Nothing in the server calls it. */
36
+ setLogger?(logger: Logger): void;
18
37
  }
19
38
  interface ContentPart {
20
39
  type: string;
@@ -152,7 +171,7 @@ interface FixtureMatch {
152
171
  * request has no user message, it falls back to scanning the whole conversation.
153
172
  */
154
173
  hasToolResult?: boolean;
155
- endpoint?: "chat" | "image" | "speech" | "transcription" | "translation" | "video" | "embedding" | "audio-gen" | "elevenlabs-tts" | "fal-audio" | "fal" | "realtime" | "realtime-transcription" | "realtime-translation";
174
+ endpoint?: "chat" | "image" | "speech" | "transcription" | "translation" | "video" | "embedding" | "audio-gen" | "elevenlabs-tts" | "elevenlabs-voice-design" | "elevenlabs-voice" | "elevenlabs-voice-get" | "elevenlabs-voice-delete" | "fal-audio" | "fal" | "realtime" | "realtime-transcription" | "realtime-translation" | "openai-live";
156
175
  context?: string;
157
176
  }
158
177
  /**
@@ -388,6 +407,22 @@ interface ImageResponse {
388
407
  image?: ImageItem;
389
408
  images?: ImageItem[];
390
409
  }
410
+ interface VoiceDesignPreview {
411
+ generated_voice_id: string;
412
+ audio_base_64?: string;
413
+ media_type?: string;
414
+ duration_secs?: number;
415
+ language?: string | null;
416
+ }
417
+ /**
418
+ * Convenience shape for `LLMock.onElevenLabsVoiceDesign`. Stored as a
419
+ * {@link RawJSONResponse} wrapping `{ previews, text }` — the ElevenLabs
420
+ * `/v1/text-to-voice/design` envelope.
421
+ */
422
+ interface VoiceDesignResponse {
423
+ previews: VoiceDesignPreview[];
424
+ text?: string;
425
+ }
391
426
  interface AudioResponse {
392
427
  audio: string | {
393
428
  b64Json: string;
@@ -460,7 +495,7 @@ interface RawJSONResponse extends ResponseOverrides {
460
495
  */
461
496
  billableUnits?: number;
462
497
  }
463
- type FixtureResponse = TextResponse | ToolCallResponse | ContentWithToolCallsResponse | ErrorResponse | EmbeddingResponse | ImageResponse | AudioResponse | TranscriptionResponse | VideoResponse | RawJSONResponse;
498
+ type FixtureResponse = TextResponse | ToolCallResponse | ContentWithToolCallsResponse | ErrorResponse | EmbeddingResponse | ImageResponse | AudioResponse | TranscriptionResponse | VideoResponse | RawJSONResponse | LiveFixtureResponse;
464
499
  interface StreamingProfile {
465
500
  ttft?: number;
466
501
  tps?: number;
@@ -479,16 +514,50 @@ interface RecordedTimings {
479
514
  /**
480
515
  * Probabilistic chaos injection rates.
481
516
  *
482
- * Rates are evaluated sequentially per request — drop → malformed → disconnect
483
- * — and the first hit wins. Consequently malformedRate is conditional on drop
484
- * not firing, and disconnectRate is conditional on neither drop nor malformed
485
- * firing. A config of `{ dropRate: 0.5, malformedRate: 0.5 }` yields a ~25 %
486
- * effective malformed rate, not 50 %.
517
+ * Rates are evaluated sequentially per request — drop → malformed → rateLimit
518
+ * → disconnect — as four separate draws in that order, and the first draw that
519
+ * hits wins and short-circuits the rest. Each rate is therefore the probability
520
+ * that its OWN draw hits GIVEN that no earlier rate fired, not the share of
521
+ * requests that end in that fault; only `dropRate`, first in the chain, is
522
+ * unconditional. A config of `{ dropRate: 0.5, malformedRate: 0.5 }` yields a
523
+ * ~25 % effective malformed rate, not 50 %, and the same compounding applies to
524
+ * `{ dropRate: 0.5, rateLimitRate: 0.5 }` (~25 % rate limits).
525
+ */
526
+ /**
527
+ * Probabilistic (and one deterministic) fault injection knobs.
528
+ *
529
+ * VALIDATION — ONE policy, whatever the source. Each field is a finite number
530
+ * in its range: the rates in [0, 1], `latencyMs` in [0, 30000]. A value outside
531
+ * it, or one that is not a number at all (`"0.5abc"`, `"Infinity"`, `NaN`), is
532
+ * REJECTED, never clamped — silent clamping substitutes a fault rate nobody
533
+ * asked for and hides the misconfiguration that produced it.
534
+ *
535
+ * Rejection is reported in the loudest way each source allows, and the three
536
+ * agree: `POST /__aimock/chaos` answers 400, the `--chaos-*` CLI flags refuse
537
+ * to start, and a per-request header or a fixture/server value is refused with
538
+ * a `[chaos]` warning and left unset so the next level of precedence (header >
539
+ * fixture > server) applies.
487
540
  */
488
541
  interface ChaosConfig {
489
542
  dropRate?: number;
490
543
  malformedRate?: number;
491
544
  disconnectRate?: number;
545
+ /**
546
+ * Deterministic delay (ms) injected before the request is handled.
547
+ * Applied when > 0 — header > fixture > server precedence, same as rates.
548
+ * Unlike rates it is not probabilistic: a set latency always fires so
549
+ * timeout/retry suites get a stable signal. Must be in [0, 30000]; a value
550
+ * outside that range is rejected, not clamped (see above).
551
+ */
552
+ latencyMs?: number;
553
+ /**
554
+ * Chance of a 429 rate-limit rejection with `Retry-After`, CONDITIONAL on
555
+ * neither `dropRate` nor `malformedRate` having fired first: it is the third
556
+ * draw in the drop → malformed → rateLimit → disconnect order, and the first
557
+ * hit wins. Paired with a 0.5 `dropRate` a 0.5 `rateLimitRate` produces ~25 %
558
+ * rate limits, not 50 % (see the interface docstring above).
559
+ */
560
+ rateLimitRate?: number;
492
561
  }
493
562
  /**
494
563
  * Server-level chaos as the handlers see it: a baseline plus per-`X-Test-Id`
@@ -509,7 +578,28 @@ interface ChaosConfig {
509
578
  interface ChaosScope {
510
579
  /** Server-wide baseline: the construction config, or the untagged override. */
511
580
  base?: ChaosConfig;
512
- /** Per-testId overrides, consulted before `base`. */
581
+ /**
582
+ * Per-testId overrides, consulted INSTEAD OF `base` — never merged over it.
583
+ *
584
+ * An installed override REPLACES the baseline wholesale for that testId: a
585
+ * server started with `--chaos-latency 500` whose test `t1` installs
586
+ * `{ dropRate: 1 }` gives `t1` traffic a drop and NO latency, because
587
+ * `latencyMs` is not restated. To keep a baseline field, restate it in the
588
+ * override body.
589
+ *
590
+ * Replacement — not a field-wise merge — is deliberate, and it is what makes
591
+ * `POST /__aimock/chaos {}` ("explicitly no chaos for my test") different
592
+ * from `DELETE /__aimock/chaos` ("forget I said anything, fall back to the
593
+ * baseline"). Under a merge, `POST {}` would be a no-op and that distinction
594
+ * would collapse. It also matches the untagged case, where an override
595
+ * likewise replaces the construction-time config rather than layering on it.
596
+ *
597
+ * The two chain links ABOVE this one — fixture chaos over server chaos, and
598
+ * request headers over both — DO merge field-wise (see `resolveChaosConfig`).
599
+ * Only the scope lookup replaces, because it selects a config rather than
600
+ * refining one. `GET /__aimock/chaos` with the same testId always reports the
601
+ * config actually in effect for that scope, so the replacement is auditable.
602
+ */
513
603
  byTestId?: ReadonlyMap<string, ChaosConfig>;
514
604
  }
515
605
  /**
@@ -518,7 +608,7 @@ interface ChaosScope {
518
608
  * itself passes a `ChaosScope`.
519
609
  */
520
610
  type ChaosDefaults = ChaosConfig | ChaosScope;
521
- type ChaosAction = "drop" | "malformed" | "disconnect";
611
+ type ChaosAction = "drop" | "malformed" | "rateLimit" | "disconnect";
522
612
  type ResponseFactory = (req: ChatCompletionRequest) => FixtureResponse | Promise<FixtureResponse>;
523
613
  interface Fixture {
524
614
  match: FixtureMatch;
@@ -621,7 +711,7 @@ interface FixtureFileContentWithToolCallsResponse extends ResponseOverrides {
621
711
  redactedThinking?: string[];
622
712
  webSearches?: string[];
623
713
  }
624
- type FixtureFileResponse = FixtureFileTextResponse | FixtureFileToolCallResponse | FixtureFileContentWithToolCallsResponse | ErrorResponse | EmbeddingResponse | ImageResponse | AudioResponse | TranscriptionResponse | VideoResponse | RawJSONResponse;
714
+ type FixtureFileResponse = FixtureFileTextResponse | FixtureFileToolCallResponse | FixtureFileContentWithToolCallsResponse | ErrorResponse | EmbeddingResponse | ImageResponse | AudioResponse | TranscriptionResponse | VideoResponse | RawJSONResponse | LiveFixtureResponse;
625
715
  interface FixtureFile {
626
716
  fixtures: FixtureFileEntry[];
627
717
  }
@@ -654,7 +744,7 @@ interface FixtureFileEntry {
654
744
  * `FixtureMatch.hasToolResult`.
655
745
  */
656
746
  hasToolResult?: boolean;
657
- endpoint?: "chat" | "image" | "speech" | "transcription" | "translation" | "video" | "embedding" | "audio-gen" | "elevenlabs-tts" | "fal-audio" | "fal" | "realtime" | "realtime-transcription" | "realtime-translation";
747
+ endpoint?: "chat" | "image" | "speech" | "transcription" | "translation" | "video" | "embedding" | "audio-gen" | "elevenlabs-tts" | "elevenlabs-voice-design" | "elevenlabs-voice" | "elevenlabs-voice-get" | "elevenlabs-voice-delete" | "fal-audio" | "fal" | "realtime" | "realtime-transcription" | "realtime-translation" | "openai-live";
658
748
  context?: string;
659
749
  };
660
750
  response: FixtureFileResponse;
@@ -673,17 +763,51 @@ interface FixtureFileEntry {
673
763
  toolsHash?: string;
674
764
  };
675
765
  }
766
+ /**
767
+ * A recorded request body.
768
+ *
769
+ * Most journal entries carry a chat-completion request, but every service
770
+ * journals through one entry type and several of them record a body that is
771
+ * not one: the fine-tuning create payload is recorded verbatim so the journal
772
+ * reports what the caller actually sent, and the journal's own size cap
773
+ * substitutes a truncation marker for an oversized body. Neither shape has a
774
+ * `model`/`messages` pair, so typing the field as `ChatCompletionRequest`
775
+ * alone forces those writers through a cast that claims fields that are not
776
+ * there — the second member exists so they do not have to lie.
777
+ *
778
+ * TypeScript collapses the two for ASSIGNMENT (`ChatCompletionRequest` has an
779
+ * index signature, so it is itself a `Record<string, unknown>`); the union is
780
+ * kept two-membered because it is what the field means, not because it narrows
781
+ * anything. For READING, treat the body as opaque JSON — that is already how
782
+ * every consumer uses it (the journal cap re-serializes it, `GET
783
+ * /__aimock/journal` hands it back) — and property-check before reaching for a
784
+ * chat-request field.
785
+ */
786
+ type JournalBody = ChatCompletionRequest | Record<string, unknown>;
676
787
  interface JournalEntry {
677
788
  id: string;
678
789
  timestamp: number;
679
790
  method: string;
680
791
  path: string;
681
792
  headers: Record<string, string>;
682
- body: ChatCompletionRequest | null;
793
+ body: JournalBody | null;
683
794
  service?: string;
795
+ /**
796
+ * Resolved test id of an MCP request (`"__default__"` when none), for an
797
+ * MCP mount to set. Journal test-id filtering does not read it: it
798
+ * re-derives the id from the headers and path (`journalEntryTestId`).
799
+ */
800
+ testId?: string;
801
+ /** Resolved context of an MCP request, `null` when none; for an MCP mount to set. */
802
+ context?: string | null;
684
803
  response: {
685
804
  status: number;
686
805
  fixture: Fixture | null;
806
+ /** For an MCP mount to set on `tools/call` entries a fake answered or failed. */
807
+ mcpFake?: {
808
+ id: string | null;
809
+ outcome: McpFakeOutcome;
810
+ };
687
811
  /**
688
812
  * What was going to serve this request. "fixture" = a fixture matched (or
689
813
  * would have, before chaos intervened). "proxy" = no fixture matched and
@@ -692,13 +816,22 @@ interface JournalEntry {
692
816
  * configured proxy: chaos-path entries (e.g. chaos on the OpenRouter
693
817
  * video lifecycle endpoints; in REPLAY mode their normal 200/400/401/404
694
818
  * entries omit source, while record-mode 200s on those endpoints carry
695
- * source:"proxy") AND the OpenRouter video models listing synthesized as
696
- * the fallback after a FAILED proxy attempt. Absent when the distinction
697
- * doesn't apply (e.g. 404/503 fallback where nothing was going to serve).
819
+ * source:"proxy"), the OpenRouter video models listing synthesized as the
820
+ * fallback after a FAILED proxy attempt, and the services whose responses
821
+ * are synthesized outright — every fine-tuning entry carries it, success
822
+ * and error alike, since that store is aimock's own and no fixture or
823
+ * proxy ever serves it. Absent when the distinction doesn't apply
824
+ * (e.g. 404/503 fallback where nothing was going to serve).
698
825
  */
699
826
  source?: "fixture" | "proxy" | "internal";
700
827
  interrupted?: boolean;
701
828
  interruptReason?: string;
829
+ /**
830
+ * The handler crashed AFTER the response completed. The client received
831
+ * `status` in full, so this is not an interruption; the message is what
832
+ * the crash said.
833
+ */
834
+ error?: string;
702
835
  chaosAction?: ChaosAction;
703
836
  /** When the X-AIMock-Strict header overrode the server default. */
704
837
  strictOverride?: boolean;
@@ -938,6 +1071,7 @@ interface FalRecordConfig {
938
1071
  timeoutMs?: number;
939
1072
  }
940
1073
  interface MockServerOptions {
1074
+ live?: LiveOptions;
941
1075
  /** Optional inbound test-client access keys. Omit to preserve permissive behavior. */
942
1076
  auth?: ApiKeyAuthConfig;
943
1077
  port?: number;
@@ -1097,7 +1231,176 @@ interface HandlerDefaults {
1097
1231
  */
1098
1232
  bytePlusVideo?: FalQueueConfig;
1099
1233
  }
1100
- //# sourceMappingURL=types.d.ts.map
1234
+ /**
1235
+ * Block scope: `"shared"`, or exact test id and/or context (at least one;
1236
+ * `{}` is not a scope). Readonly: validated scopes are frozen.
1237
+ */
1238
+ type McpFakeScope = "shared" | Readonly<{
1239
+ testId: string;
1240
+ context?: string;
1241
+ }> | Readonly<{
1242
+ testId?: string;
1243
+ context: string;
1244
+ }>;
1245
+ /**
1246
+ * `T` with every nested property and array read-only: the type of a value the
1247
+ * MCP fakes store deep-freezes before it hands it out.
1248
+ */
1249
+ type McpFakeDeepReadonly<T> = T extends ((...args: never[]) => unknown) ? T : T extends object ? { readonly [K in keyof T]: McpFakeDeepReadonly<T[K]> } : T;
1250
+ /** MCP `Annotations` on a content block. */
1251
+ interface McpFakeAnnotations {
1252
+ audience?: Array<"user" | "assistant">;
1253
+ /** From 0 (least) to 1 (most important). */
1254
+ priority?: number;
1255
+ /** RFC 3339 date-time with seconds and a `Z` or `±hh:mm` offset. */
1256
+ lastModified?: string;
1257
+ }
1258
+ /** MCP `Icon` on a `resource_link` content block. */
1259
+ interface McpFakeIcon {
1260
+ src: string;
1261
+ mimeType?: string;
1262
+ sizes?: string[];
1263
+ theme?: "light" | "dark";
1264
+ }
1265
+ /** MCP `TextResourceContents` / `BlobResourceContents`: exactly one of `text` / `blob`. */
1266
+ type McpFakeResourceContents = {
1267
+ uri: string;
1268
+ mimeType?: string;
1269
+ _meta?: Record<string, unknown>;
1270
+ } & ({
1271
+ text: string;
1272
+ blob?: never;
1273
+ } | {
1274
+ blob: string;
1275
+ text?: never;
1276
+ });
1277
+ type McpFakeContentCommon = {
1278
+ annotations?: McpFakeAnnotations;
1279
+ _meta?: Record<string, unknown>;
1280
+ };
1281
+ /** One MCP content block of a tool result (`ContentBlock`); `data` and `blob` are base64. */
1282
+ type McpFakeContentBlock = McpFakeContentCommon & ({
1283
+ type: "text";
1284
+ text: string;
1285
+ } | {
1286
+ type: "image";
1287
+ data: string;
1288
+ mimeType: string;
1289
+ } | {
1290
+ type: "audio";
1291
+ data: string;
1292
+ mimeType: string;
1293
+ } | {
1294
+ type: "resource_link";
1295
+ uri: string;
1296
+ name: string;
1297
+ title?: string;
1298
+ description?: string;
1299
+ mimeType?: string;
1300
+ size?: number;
1301
+ icons?: McpFakeIcon[];
1302
+ } | {
1303
+ type: "resource";
1304
+ resource: McpFakeResourceContents;
1305
+ });
1306
+ /** A full MCP `CallToolResult`, served unchanged. No other keys. */
1307
+ interface McpFakeFullResult {
1308
+ content: McpFakeContentBlock[];
1309
+ isError?: boolean;
1310
+ structuredContent?: Record<string, unknown>;
1311
+ _meta?: Record<string, unknown>;
1312
+ }
1313
+ /**
1314
+ * Structured data: any JSON object without the `CallToolResult`
1315
+ * keys, served as text plus `structuredContent`.
1316
+ */
1317
+ type McpFakeStructuredResult = Record<string, unknown> & {
1318
+ content?: never;
1319
+ isError?: never;
1320
+ structuredContent?: never;
1321
+ _meta?: never;
1322
+ };
1323
+ /**
1324
+ * A call entry's `result` value. Validation also checks what the type cannot
1325
+ * say: base64 `data` / `blob`, `priority` from 0 to 1, the `lastModified`
1326
+ * format, and plain JSON throughout. Unknown keys inside a content item are
1327
+ * allowed and served as given.
1328
+ */
1329
+ type McpFakeResult = string | McpFakeContentBlock[] | McpFakeFullResult | McpFakeStructuredResult;
1330
+ /** How a call entry matches: exactly one of `args` / `anyArgs`. */
1331
+ type McpFakeCallMatch = {
1332
+ args: Record<string, unknown>;
1333
+ anyArgs?: never;
1334
+ } | {
1335
+ anyArgs: true;
1336
+ args?: never;
1337
+ };
1338
+ /** What a call entry answers: exactly one of `result` / `error`. */
1339
+ type McpFakeCallAnswer = {
1340
+ result: McpFakeResult;
1341
+ error?: never;
1342
+ } | {
1343
+ error: string;
1344
+ result?: never;
1345
+ };
1346
+ /** One ordered answer for a tool. */
1347
+ type McpFakeCall = McpFakeCallMatch & McpFakeCallAnswer & {
1348
+ id?: string;
1349
+ };
1350
+ /** One faked tool in a block. */
1351
+ interface McpFakeTool {
1352
+ name: string;
1353
+ description?: string;
1354
+ inputSchema?: Record<string, unknown>;
1355
+ calls: McpFakeCall[];
1356
+ }
1357
+ /** One `mcpFakes` block. */
1358
+ interface McpFakeBlock {
1359
+ scope: McpFakeScope;
1360
+ mount?: string;
1361
+ undeclaredTools?: McpFakeUndeclaredPolicy;
1362
+ tools: McpFakeTool[];
1363
+ }
1364
+ type McpFakeUndeclaredPolicy = "allow" | "deny";
1365
+ /**
1366
+ * The resolved identity of one MCP request: test id, context and undeclared
1367
+ * override, each from the request or else from the session.
1368
+ * `null` means "not supplied". The identity shape the fake store's matching
1369
+ * methods take (`applicable`, `selectTier`, `claim`, `policy`, `declaredTools`,
1370
+ * `listTools`).
1371
+ */
1372
+ interface McpFakeIdentity {
1373
+ testId: string | null;
1374
+ context: string | null;
1375
+ undeclared: McpFakeUndeclaredPolicy | null;
1376
+ }
1377
+ /**
1378
+ * One raw block as a loader hands it off, before validation. `source` is the
1379
+ * entry-id source string; `blockIndex` is `null` when `mcpFakes` is a single object.
1380
+ */
1381
+ interface McpFakeSource {
1382
+ source: string;
1383
+ blockIndex: number | null;
1384
+ raw: unknown;
1385
+ }
1386
+ /**
1387
+ * `response.mcpFake.outcome` on a `tools/call` journal entry. `evicted`:
1388
+ * the request's test id lost its consumption state to the FIFO test-id cap.
1389
+ */
1390
+ type McpFakeOutcome = "answered" | "mismatch" | "exhausted" | "not_declared" | "evicted";
1391
+ /**
1392
+ * JSON-RPC error codes of the four fake failures, keyed by
1393
+ * `error.data.aimock.code`. `-31010` and `-31011` sit outside the JSON-RPC
1394
+ * reserved range. `MCP_FAKE_EVICTED` is for a lookup of a declared tool by a
1395
+ * test id whose state the FIFO test-id cap evicted, until it is reset.
1396
+ */
1397
+ declare const MCP_FAKE_ERROR_CODES: {
1398
+ readonly MCP_FAKE_NOT_DECLARED: -32602;
1399
+ readonly MCP_FAKE_MISMATCH: -32602;
1400
+ readonly MCP_FAKE_EXHAUSTED: -31010;
1401
+ readonly MCP_FAKE_EVICTED: -31011;
1402
+ };
1403
+ type McpFakeErrorCode = keyof typeof MCP_FAKE_ERROR_CODES;
1101
1404
  //#endregion
1102
- export { ApiKeyAuthConfig, AudioResponse, ChaosAction, ChaosConfig, ChaosDefaults, ChatCompletion, ChatCompletionChoice, ChatCompletionMessage, ChatCompletionRequest, ChatMessage, ContentPart, ContentWithToolCallsResponse, EmbeddingFixtureOpts, EmbeddingResponse, ErrorResponse, FalQueueOpts, Fixture, FixtureBlock, FixtureFile, FixtureFileBlock, FixtureFileContentWithToolCallsResponse, FixtureFileEntry, FixtureFileResponse, FixtureFileTextResponse, FixtureFileToolCall, FixtureFileToolCallResponse, FixtureMatch, FixtureOpts, FixtureResponse, HandlerDefaults, ImageItem, ImageResponse, JournalEntry, MockServerOptions, Mountable, RawJSONResponse, RecordConfig, RecordProviderKey, RecordedTimings, ResponseFactory, ResponseOverrides, SSEChoice, SSEChunk, SSEDelta, SSEToolCallDelta, StreamingProfile, TextResponse, ToolCall, ToolCallMessage, ToolCallResponse, ToolDefinition, TranscriptionResponse, VideoResponse };
1405
+ export { ApiKeyAuthConfig, AudioResponse, ChaosAction, ChaosConfig, ChaosDefaults, ChatCompletion, ChatCompletionChoice, ChatCompletionMessage, ChatCompletionRequest, ChatMessage, ContentPart, ContentWithToolCallsResponse, EmbeddingFixtureOpts, EmbeddingResponse, ErrorResponse, FalQueueOpts, Fixture, FixtureBlock, FixtureFile, FixtureFileBlock, FixtureFileContentWithToolCallsResponse, FixtureFileEntry, FixtureFileResponse, FixtureFileTextResponse, FixtureFileToolCall, FixtureFileToolCallResponse, FixtureMatch, FixtureOpts, FixtureResponse, HandlerDefaults, ImageItem, ImageResponse, JournalBody, JournalEntry, MCP_FAKE_ERROR_CODES, McpFakeAnnotations, McpFakeBlock, McpFakeCall, McpFakeCallAnswer, McpFakeCallMatch, McpFakeContentBlock, McpFakeDeepReadonly, McpFakeErrorCode, McpFakeFullResult, McpFakeIcon, McpFakeIdentity, McpFakeOutcome, McpFakeResourceContents, McpFakeResult, McpFakeScope, McpFakeSource, McpFakeStructuredResult, McpFakeTool, McpFakeUndeclaredPolicy, MockServerOptions, Mountable, RawJSONResponse, RecordConfig, RecordProviderKey, RecordedTimings, ResponseFactory, ResponseOverrides, SSEChoice, SSEChunk, SSEDelta, SSEToolCallDelta, StreamingProfile, TextResponse, ToolCall, ToolCallMessage, ToolCallResponse, ToolDefinition, TranscriptionResponse, VideoResponse, VoiceDesignPreview, VoiceDesignResponse };
1103
1406
  //# sourceMappingURL=types.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.cts","names":[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