@copilotkit/aimock 1.45.0 → 1.46.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 (426) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/CHANGELOG.md +24 -0
  4. package/README.md +7 -1
  5. package/dist/agui-mock.cjs +25 -25
  6. package/dist/agui-mock.cjs.map +1 -1
  7. package/dist/agui-mock.d.cts.map +1 -1
  8. package/dist/agui-mock.d.ts.map +1 -1
  9. package/dist/agui-mock.js +25 -25
  10. package/dist/agui-mock.js.map +1 -1
  11. package/dist/agui-types.d.ts.map +1 -1
  12. package/dist/aimock-cli.cjs +15 -1
  13. package/dist/aimock-cli.cjs.map +1 -1
  14. package/dist/aimock-cli.d.cts.map +1 -1
  15. package/dist/aimock-cli.d.ts.map +1 -1
  16. package/dist/aimock-cli.js +16 -2
  17. package/dist/aimock-cli.js.map +1 -1
  18. package/dist/api-key-auth.cjs +10 -9
  19. package/dist/api-key-auth.cjs.map +1 -1
  20. package/dist/api-key-auth.d.cts.map +1 -1
  21. package/dist/api-key-auth.d.ts.map +1 -1
  22. package/dist/api-key-auth.js +11 -10
  23. package/dist/api-key-auth.js.map +1 -1
  24. package/dist/batches.cjs +2 -4
  25. package/dist/batches.cjs.map +1 -1
  26. package/dist/batches.d.cts.map +1 -1
  27. package/dist/batches.d.ts.map +1 -1
  28. package/dist/batches.js +2 -4
  29. package/dist/batches.js.map +1 -1
  30. package/dist/bedrock-converse.cjs +61 -80
  31. package/dist/bedrock-converse.cjs.map +1 -1
  32. package/dist/bedrock-converse.d.cts.map +1 -1
  33. package/dist/bedrock-converse.d.ts.map +1 -1
  34. package/dist/bedrock-converse.js +58 -77
  35. package/dist/bedrock-converse.js.map +1 -1
  36. package/dist/bedrock.cjs +65 -97
  37. package/dist/bedrock.cjs.map +1 -1
  38. package/dist/bedrock.d.cts.map +1 -1
  39. package/dist/bedrock.d.ts.map +1 -1
  40. package/dist/bedrock.js +62 -94
  41. package/dist/bedrock.js.map +1 -1
  42. package/dist/byteplus-video.cjs +11 -10
  43. package/dist/byteplus-video.cjs.map +1 -1
  44. package/dist/byteplus-video.d.cts.map +1 -1
  45. package/dist/byteplus-video.d.ts.map +1 -1
  46. package/dist/byteplus-video.js +5 -4
  47. package/dist/byteplus-video.js.map +1 -1
  48. package/dist/chaos.cjs +5 -4
  49. package/dist/chaos.cjs.map +1 -1
  50. package/dist/chaos.d.cts.map +1 -1
  51. package/dist/chaos.d.ts.map +1 -1
  52. package/dist/chaos.js +5 -4
  53. package/dist/chaos.js.map +1 -1
  54. package/dist/cli.cjs +15 -0
  55. package/dist/cli.cjs.map +1 -1
  56. package/dist/cli.js +15 -0
  57. package/dist/cli.js.map +1 -1
  58. package/dist/cohere.cjs +49 -74
  59. package/dist/cohere.cjs.map +1 -1
  60. package/dist/cohere.d.cts.map +1 -1
  61. package/dist/cohere.d.ts.map +1 -1
  62. package/dist/cohere.js +47 -72
  63. package/dist/cohere.js.map +1 -1
  64. package/dist/config-loader.cjs +29 -1
  65. package/dist/config-loader.cjs.map +1 -1
  66. package/dist/config-loader.d.cts +7 -1
  67. package/dist/config-loader.d.cts.map +1 -1
  68. package/dist/config-loader.d.ts +7 -1
  69. package/dist/config-loader.d.ts.map +1 -1
  70. package/dist/config-loader.js +29 -2
  71. package/dist/config-loader.js.map +1 -1
  72. package/dist/count-tokens.cjs +146 -0
  73. package/dist/count-tokens.cjs.map +1 -0
  74. package/dist/count-tokens.js +146 -0
  75. package/dist/count-tokens.js.map +1 -0
  76. package/dist/elevenlabs-audio.cjs +36 -34
  77. package/dist/elevenlabs-audio.cjs.map +1 -1
  78. package/dist/elevenlabs-audio.d.cts.map +1 -1
  79. package/dist/elevenlabs-audio.d.ts.map +1 -1
  80. package/dist/elevenlabs-audio.js +33 -31
  81. package/dist/elevenlabs-audio.js.map +1 -1
  82. package/dist/elevenlabs-voice.cjs +38 -37
  83. package/dist/elevenlabs-voice.cjs.map +1 -1
  84. package/dist/elevenlabs-voice.d.cts.map +1 -1
  85. package/dist/elevenlabs-voice.d.ts.map +1 -1
  86. package/dist/elevenlabs-voice.js +33 -32
  87. package/dist/elevenlabs-voice.js.map +1 -1
  88. package/dist/embedding-request.cjs +16 -0
  89. package/dist/embedding-request.cjs.map +1 -0
  90. package/dist/embedding-request.js +14 -0
  91. package/dist/embedding-request.js.map +1 -0
  92. package/dist/embeddings.cjs +30 -20
  93. package/dist/embeddings.cjs.map +1 -1
  94. package/dist/embeddings.d.cts.map +1 -1
  95. package/dist/embeddings.d.ts.map +1 -1
  96. package/dist/embeddings.js +30 -20
  97. package/dist/embeddings.js.map +1 -1
  98. package/dist/fal-audio.cjs +45 -43
  99. package/dist/fal-audio.cjs.map +1 -1
  100. package/dist/fal-audio.d.cts.map +1 -1
  101. package/dist/fal-audio.d.ts.map +1 -1
  102. package/dist/fal-audio.js +42 -40
  103. package/dist/fal-audio.js.map +1 -1
  104. package/dist/fal.cjs +17 -15
  105. package/dist/fal.cjs.map +1 -1
  106. package/dist/fal.js +16 -14
  107. package/dist/fal.js.map +1 -1
  108. package/dist/files.cjs +2 -4
  109. package/dist/files.cjs.map +1 -1
  110. package/dist/files.d.cts.map +1 -1
  111. package/dist/files.d.ts.map +1 -1
  112. package/dist/files.js +2 -4
  113. package/dist/files.js.map +1 -1
  114. package/dist/fine-tuning.cjs +2 -4
  115. package/dist/fine-tuning.cjs.map +1 -1
  116. package/dist/fine-tuning.d.cts.map +1 -1
  117. package/dist/fine-tuning.d.ts.map +1 -1
  118. package/dist/fine-tuning.js +2 -4
  119. package/dist/fine-tuning.js.map +1 -1
  120. package/dist/fixture-loader.cjs +37 -42
  121. package/dist/fixture-loader.cjs.map +1 -1
  122. package/dist/fixture-loader.d.cts.map +1 -1
  123. package/dist/fixture-loader.d.ts.map +1 -1
  124. package/dist/fixture-loader.js +37 -42
  125. package/dist/fixture-loader.js.map +1 -1
  126. package/dist/gemini-embeddings.cjs +26 -24
  127. package/dist/gemini-embeddings.cjs.map +1 -1
  128. package/dist/gemini-embeddings.js +26 -24
  129. package/dist/gemini-embeddings.js.map +1 -1
  130. package/dist/gemini-interactions.cjs +50 -35
  131. package/dist/gemini-interactions.cjs.map +1 -1
  132. package/dist/gemini-interactions.d.cts +0 -1
  133. package/dist/gemini-interactions.d.cts.map +1 -1
  134. package/dist/gemini-interactions.d.ts +0 -1
  135. package/dist/gemini-interactions.d.ts.map +1 -1
  136. package/dist/gemini-interactions.js +49 -34
  137. package/dist/gemini-interactions.js.map +1 -1
  138. package/dist/gemini.cjs +57 -67
  139. package/dist/gemini.cjs.map +1 -1
  140. package/dist/gemini.d.cts.map +1 -1
  141. package/dist/gemini.d.ts.map +1 -1
  142. package/dist/gemini.js +56 -67
  143. package/dist/gemini.js.map +1 -1
  144. package/dist/grok-video.cjs +14 -12
  145. package/dist/grok-video.cjs.map +1 -1
  146. package/dist/grok-video.d.cts.map +1 -1
  147. package/dist/grok-video.d.ts.map +1 -1
  148. package/dist/grok-video.js +8 -6
  149. package/dist/grok-video.js.map +1 -1
  150. package/dist/helpers.cjs +11 -68
  151. package/dist/helpers.cjs.map +1 -1
  152. package/dist/helpers.d.cts.map +1 -1
  153. package/dist/helpers.d.ts.map +1 -1
  154. package/dist/helpers.js +12 -67
  155. package/dist/helpers.js.map +1 -1
  156. package/dist/images.cjs +30 -28
  157. package/dist/images.cjs.map +1 -1
  158. package/dist/images.d.cts.map +1 -1
  159. package/dist/images.d.ts.map +1 -1
  160. package/dist/images.js +27 -25
  161. package/dist/images.js.map +1 -1
  162. package/dist/index.d.cts +2 -2
  163. package/dist/index.d.ts +2 -2
  164. package/dist/journal.cjs +3 -1
  165. package/dist/journal.cjs.map +1 -1
  166. package/dist/journal.d.cts.map +1 -1
  167. package/dist/journal.d.ts.map +1 -1
  168. package/dist/journal.js +2 -1
  169. package/dist/journal.js.map +1 -1
  170. package/dist/llmock.cjs +3 -0
  171. package/dist/llmock.cjs.map +1 -1
  172. package/dist/llmock.d.cts.map +1 -1
  173. package/dist/llmock.d.ts.map +1 -1
  174. package/dist/llmock.js +3 -0
  175. package/dist/llmock.js.map +1 -1
  176. package/dist/mcp-fakes.d.cts.map +1 -1
  177. package/dist/mcp-handler.cjs +14 -4
  178. package/dist/mcp-handler.cjs.map +1 -1
  179. package/dist/mcp-handler.js +14 -4
  180. package/dist/mcp-handler.js.map +1 -1
  181. package/dist/mcp-recorder.cjs +2 -1
  182. package/dist/mcp-recorder.cjs.map +1 -1
  183. package/dist/mcp-recorder.js +3 -2
  184. package/dist/mcp-recorder.js.map +1 -1
  185. package/dist/messages.cjs +111 -96
  186. package/dist/messages.cjs.map +1 -1
  187. package/dist/messages.d.cts.map +1 -1
  188. package/dist/messages.d.ts.map +1 -1
  189. package/dist/messages.js +109 -95
  190. package/dist/messages.js.map +1 -1
  191. package/dist/metrics.cjs +5 -2
  192. package/dist/metrics.cjs.map +1 -1
  193. package/dist/metrics.d.cts.map +1 -1
  194. package/dist/metrics.d.ts.map +1 -1
  195. package/dist/metrics.js +6 -3
  196. package/dist/metrics.js.map +1 -1
  197. package/dist/model-utils.cjs +1 -0
  198. package/dist/model-utils.cjs.map +1 -1
  199. package/dist/model-utils.js +1 -1
  200. package/dist/model-utils.js.map +1 -1
  201. package/dist/moderation.cjs +15 -12
  202. package/dist/moderation.cjs.map +1 -1
  203. package/dist/moderation.js +14 -11
  204. package/dist/moderation.js.map +1 -1
  205. package/dist/ollama.cjs +128 -68
  206. package/dist/ollama.cjs.map +1 -1
  207. package/dist/ollama.d.cts.map +1 -1
  208. package/dist/ollama.d.ts.map +1 -1
  209. package/dist/ollama.js +124 -64
  210. package/dist/ollama.js.map +1 -1
  211. package/dist/openapi.cjs +323 -3
  212. package/dist/openapi.cjs.map +1 -1
  213. package/dist/openapi.d.cts.map +1 -1
  214. package/dist/openapi.d.ts.map +1 -1
  215. package/dist/openapi.js +324 -4
  216. package/dist/openapi.js.map +1 -1
  217. package/dist/openrouter-chat.cjs +11 -155
  218. package/dist/openrouter-chat.cjs.map +1 -1
  219. package/dist/openrouter-chat.js +11 -155
  220. package/dist/openrouter-chat.js.map +1 -1
  221. package/dist/openrouter-video.cjs +76 -71
  222. package/dist/openrouter-video.cjs.map +1 -1
  223. package/dist/openrouter-video.d.cts.map +1 -1
  224. package/dist/openrouter-video.d.ts.map +1 -1
  225. package/dist/openrouter-video.js +63 -58
  226. package/dist/openrouter-video.js.map +1 -1
  227. package/dist/recorder.cjs +176 -95
  228. package/dist/recorder.cjs.map +1 -1
  229. package/dist/recorder.d.cts.map +1 -1
  230. package/dist/recorder.d.ts.map +1 -1
  231. package/dist/recorder.js +176 -95
  232. package/dist/recorder.js.map +1 -1
  233. package/dist/rerank.cjs +13 -11
  234. package/dist/rerank.cjs.map +1 -1
  235. package/dist/rerank.js +12 -10
  236. package/dist/rerank.js.map +1 -1
  237. package/dist/response/catalog/anthropic-page.cjs +39 -0
  238. package/dist/response/catalog/anthropic-page.cjs.map +1 -0
  239. package/dist/response/catalog/anthropic-page.js +38 -0
  240. package/dist/response/catalog/anthropic-page.js.map +1 -0
  241. package/dist/response/catalog/collect.cjs +61 -0
  242. package/dist/response/catalog/collect.cjs.map +1 -0
  243. package/dist/response/catalog/collect.js +59 -0
  244. package/dist/response/catalog/collect.js.map +1 -0
  245. package/dist/response/catalog/gemini-page.cjs +25 -0
  246. package/dist/response/catalog/gemini-page.cjs.map +1 -0
  247. package/dist/response/catalog/gemini-page.js +24 -0
  248. package/dist/response/catalog/gemini-page.js.map +1 -0
  249. package/dist/response/catalog/render.cjs +182 -0
  250. package/dist/response/catalog/render.cjs.map +1 -0
  251. package/dist/response/catalog/render.js +171 -0
  252. package/dist/response/catalog/render.js.map +1 -0
  253. package/dist/response/errors.cjs +225 -0
  254. package/dist/response/errors.cjs.map +1 -0
  255. package/dist/response/errors.js +224 -0
  256. package/dist/response/errors.js.map +1 -0
  257. package/dist/response/finish.cjs +39 -0
  258. package/dist/response/finish.cjs.map +1 -0
  259. package/dist/response/finish.js +35 -0
  260. package/dist/response/finish.js.map +1 -0
  261. package/dist/response/policy.cjs +126 -0
  262. package/dist/response/policy.cjs.map +1 -0
  263. package/dist/response/policy.js +120 -0
  264. package/dist/response/policy.js.map +1 -0
  265. package/dist/response/profiles.cjs +69 -0
  266. package/dist/response/profiles.cjs.map +1 -0
  267. package/dist/response/profiles.js +65 -0
  268. package/dist/response/profiles.js.map +1 -0
  269. package/dist/response/usage/codecs/anthropic.cjs +52 -0
  270. package/dist/response/usage/codecs/anthropic.cjs.map +1 -0
  271. package/dist/response/usage/codecs/anthropic.js +50 -0
  272. package/dist/response/usage/codecs/anthropic.js.map +1 -0
  273. package/dist/response/usage/codecs/cohere.cjs +36 -0
  274. package/dist/response/usage/codecs/cohere.cjs.map +1 -0
  275. package/dist/response/usage/codecs/cohere.js +35 -0
  276. package/dist/response/usage/codecs/cohere.js.map +1 -0
  277. package/dist/response/usage/codecs/converse.cjs +16 -0
  278. package/dist/response/usage/codecs/converse.cjs.map +1 -0
  279. package/dist/response/usage/codecs/converse.js +15 -0
  280. package/dist/response/usage/codecs/converse.js.map +1 -0
  281. package/dist/response/usage/codecs/gemini.cjs +31 -0
  282. package/dist/response/usage/codecs/gemini.cjs.map +1 -0
  283. package/dist/response/usage/codecs/gemini.js +31 -0
  284. package/dist/response/usage/codecs/gemini.js.map +1 -0
  285. package/dist/response/usage/codecs/interactions.cjs +22 -0
  286. package/dist/response/usage/codecs/interactions.cjs.map +1 -0
  287. package/dist/response/usage/codecs/interactions.js +21 -0
  288. package/dist/response/usage/codecs/interactions.js.map +1 -0
  289. package/dist/response/usage/codecs/ollama.cjs +17 -0
  290. package/dist/response/usage/codecs/ollama.cjs.map +1 -0
  291. package/dist/response/usage/codecs/ollama.js +17 -0
  292. package/dist/response/usage/codecs/ollama.js.map +1 -0
  293. package/dist/response/usage/codecs/openai.cjs +52 -0
  294. package/dist/response/usage/codecs/openai.cjs.map +1 -0
  295. package/dist/response/usage/codecs/openai.js +50 -0
  296. package/dist/response/usage/codecs/openai.js.map +1 -0
  297. package/dist/response/usage/codecs/openrouter.cjs +68 -0
  298. package/dist/response/usage/codecs/openrouter.cjs.map +1 -0
  299. package/dist/response/usage/codecs/openrouter.js +67 -0
  300. package/dist/response/usage/codecs/openrouter.js.map +1 -0
  301. package/dist/response/usage/codecs/realtime.cjs +19 -0
  302. package/dist/response/usage/codecs/realtime.cjs.map +1 -0
  303. package/dist/response/usage/codecs/realtime.js +18 -0
  304. package/dist/response/usage/codecs/realtime.js.map +1 -0
  305. package/dist/response/usage/codecs/responses.cjs +21 -0
  306. package/dist/response/usage/codecs/responses.cjs.map +1 -0
  307. package/dist/response/usage/codecs/responses.js +20 -0
  308. package/dist/response/usage/codecs/responses.js.map +1 -0
  309. package/dist/response/usage/estimate.cjs +23 -0
  310. package/dist/response/usage/estimate.cjs.map +1 -0
  311. package/dist/response/usage/estimate.js +21 -0
  312. package/dist/response/usage/estimate.js.map +1 -0
  313. package/dist/response/usage/fields.cjs +72 -0
  314. package/dist/response/usage/fields.cjs.map +1 -0
  315. package/dist/response/usage/fields.js +70 -0
  316. package/dist/response/usage/fields.js.map +1 -0
  317. package/dist/response/usage/recording.cjs +52 -0
  318. package/dist/response/usage/recording.cjs.map +1 -0
  319. package/dist/response/usage/recording.js +52 -0
  320. package/dist/response/usage/recording.js.map +1 -0
  321. package/dist/responses.cjs +45 -58
  322. package/dist/responses.cjs.map +1 -1
  323. package/dist/responses.d.cts.map +1 -1
  324. package/dist/responses.d.ts.map +1 -1
  325. package/dist/responses.js +44 -57
  326. package/dist/responses.js.map +1 -1
  327. package/dist/route-registry.cjs +45 -0
  328. package/dist/route-registry.cjs.map +1 -1
  329. package/dist/route-registry.d.cts.map +1 -1
  330. package/dist/route-registry.d.ts.map +1 -1
  331. package/dist/route-registry.js +41 -1
  332. package/dist/route-registry.js.map +1 -1
  333. package/dist/router.cjs +4 -0
  334. package/dist/router.cjs.map +1 -1
  335. package/dist/router.d.cts.map +1 -1
  336. package/dist/router.d.ts.map +1 -1
  337. package/dist/router.js +3 -0
  338. package/dist/router.js.map +1 -1
  339. package/dist/search.cjs +13 -11
  340. package/dist/search.cjs.map +1 -1
  341. package/dist/search.js +12 -10
  342. package/dist/search.js.map +1 -1
  343. package/dist/server.cjs +222 -146
  344. package/dist/server.cjs.map +1 -1
  345. package/dist/server.d.cts.map +1 -1
  346. package/dist/server.d.ts.map +1 -1
  347. package/dist/server.js +223 -147
  348. package/dist/server.js.map +1 -1
  349. package/dist/speech.cjs +20 -18
  350. package/dist/speech.cjs.map +1 -1
  351. package/dist/speech.d.cts.map +1 -1
  352. package/dist/speech.d.ts.map +1 -1
  353. package/dist/speech.js +19 -17
  354. package/dist/speech.js.map +1 -1
  355. package/dist/sse-writer.cjs +7 -0
  356. package/dist/sse-writer.cjs.map +1 -1
  357. package/dist/sse-writer.d.cts.map +1 -1
  358. package/dist/sse-writer.d.ts.map +1 -1
  359. package/dist/sse-writer.js +7 -1
  360. package/dist/sse-writer.js.map +1 -1
  361. package/dist/stream-collapse.cjs +118 -11
  362. package/dist/stream-collapse.cjs.map +1 -1
  363. package/dist/stream-collapse.d.cts +10 -9
  364. package/dist/stream-collapse.d.cts.map +1 -1
  365. package/dist/stream-collapse.d.ts +10 -9
  366. package/dist/stream-collapse.d.ts.map +1 -1
  367. package/dist/stream-collapse.js +118 -11
  368. package/dist/stream-collapse.js.map +1 -1
  369. package/dist/transcription.cjs +12 -10
  370. package/dist/transcription.cjs.map +1 -1
  371. package/dist/transcription.d.cts.map +1 -1
  372. package/dist/transcription.d.ts.map +1 -1
  373. package/dist/transcription.js +11 -9
  374. package/dist/transcription.js.map +1 -1
  375. package/dist/types.cjs.map +1 -1
  376. package/dist/types.d.cts +62 -3
  377. package/dist/types.d.cts.map +1 -1
  378. package/dist/types.d.ts +62 -3
  379. package/dist/types.d.ts.map +1 -1
  380. package/dist/types.js.map +1 -1
  381. package/dist/vector-mock.cjs +3 -8
  382. package/dist/vector-mock.cjs.map +1 -1
  383. package/dist/vector-mock.d.cts.map +1 -1
  384. package/dist/vector-mock.d.ts.map +1 -1
  385. package/dist/vector-mock.js +3 -8
  386. package/dist/vector-mock.js.map +1 -1
  387. package/dist/vector-stores.cjs +2 -4
  388. package/dist/vector-stores.cjs.map +1 -1
  389. package/dist/vector-stores.d.cts.map +1 -1
  390. package/dist/vector-stores.d.ts.map +1 -1
  391. package/dist/vector-stores.js +2 -4
  392. package/dist/vector-stores.js.map +1 -1
  393. package/dist/veo-video.cjs +16 -14
  394. package/dist/veo-video.cjs.map +1 -1
  395. package/dist/veo-video.js +10 -8
  396. package/dist/veo-video.js.map +1 -1
  397. package/dist/video.cjs +21 -19
  398. package/dist/video.cjs.map +1 -1
  399. package/dist/video.d.cts.map +1 -1
  400. package/dist/video.d.ts.map +1 -1
  401. package/dist/video.js +20 -18
  402. package/dist/video.js.map +1 -1
  403. package/dist/ws-gemini-live.cjs +11 -3
  404. package/dist/ws-gemini-live.cjs.map +1 -1
  405. package/dist/ws-gemini-live.d.cts +0 -1
  406. package/dist/ws-gemini-live.d.cts.map +1 -1
  407. package/dist/ws-gemini-live.d.ts +0 -1
  408. package/dist/ws-gemini-live.d.ts.map +1 -1
  409. package/dist/ws-gemini-live.js +10 -2
  410. package/dist/ws-gemini-live.js.map +1 -1
  411. package/dist/ws-live.cjs +6 -5
  412. package/dist/ws-live.cjs.map +1 -1
  413. package/dist/ws-live.js +5 -4
  414. package/dist/ws-live.js.map +1 -1
  415. package/dist/ws-realtime.cjs +28 -54
  416. package/dist/ws-realtime.cjs.map +1 -1
  417. package/dist/ws-realtime.d.cts.map +1 -1
  418. package/dist/ws-realtime.d.ts.map +1 -1
  419. package/dist/ws-realtime.js +25 -51
  420. package/dist/ws-realtime.js.map +1 -1
  421. package/dist/ws-responses.cjs +8 -6
  422. package/dist/ws-responses.cjs.map +1 -1
  423. package/dist/ws-responses.js +7 -5
  424. package/dist/ws-responses.js.map +1 -1
  425. package/package.json +4 -1
  426. package/skills/write-fixtures/SKILL.md +25 -16
@@ -1 +1 @@
1
- {"version":3,"file":"responses.cjs","names":["generateToolCallId","generateId","resolveFixtureBlocks","isReasoningModel","calculateDelay","delay","flattenHeaders","isJsonObject","getContext","getTestId","matchFixtureDiagnostic","recordMatchOptions","applyChaosAsync","resolveStrictMode","strictNoMatchMessage","strictNoMatchLogLine","strictOverrideField","proxyAndRecord","resolveResponse","withoutLegacyNamespaces","planMisbehavior","createInterruptionSignal","isErrorResponse","serializeErrorResponse","isCombinedFixtureResponse","extractOverrides","resolveReasoningForModel","resolveServedBlockOutcome","servedToolCalls","isTextResponse","isToolCallResponse","prepareOpenAIChatMisbehavior","toolCallFixtureBlock","resolveOpenAIChatMisbehaviorUsage"],"sources":["../src/responses.ts"],"sourcesContent":["/**\n * OpenAI Responses API support for aimock.\n *\n * Translates incoming /v1/responses requests into the ChatCompletionRequest\n * format used by the fixture router, and converts fixture responses back into\n * the Responses API streaming (or non-streaming) format expected by @ai-sdk/openai.\n */\n\nimport type * as http from \"node:http\";\nimport { randomBytes } from \"node:crypto\";\nimport type {\n ChatCompletionRequest,\n ChatMessage,\n ContentPart,\n CustomToolCall,\n CustomToolDefinition,\n Fixture,\n FixtureBlock,\n FixtureToolCall,\n HandlerDefaults,\n ResponseOverrides,\n ResponsesFixtureBlock,\n StreamingProfile,\n ToolCall,\n ToolDefinition,\n} from \"./types.js\";\nimport type { Logger } from \"./logger.js\";\nimport {\n generateId,\n generateToolCallId,\n resolveFixtureBlocks,\n assertResponsesToolCalls,\n extractOverrides,\n isTextResponse,\n isToolCallResponse,\n isCombinedFixtureResponse,\n isErrorResponse,\n serializeErrorResponse,\n flattenHeaders,\n isJsonObject,\n getTestId,\n resolveResponse,\n resolveStrictMode,\n resolveReasoningForModel,\n strictOverrideField,\n getContext,\n strictNoMatchMessage,\n strictNoMatchLogLine,\n prepareOpenAIChatMisbehavior,\n resolveOpenAIChatMisbehaviorUsage,\n assertCustomToolCalls,\n resolveServedBlockOutcome,\n servedToolCalls,\n toolCallFixtureBlock,\n withoutLegacyNamespaces,\n} from \"./helpers.js\";\nimport type { MisbehaviorPlan } from \"./misbehavior.js\";\nimport { isReasoningModel } from \"./model-utils.js\";\nimport { matchFixtureDiagnostic, recordMatchOptions, setResponsesOfferedTools } from \"./router.js\";\nimport { writeErrorResponse, delay, calculateDelay } from \"./sse-writer.js\";\nimport { createInterruptionSignal } from \"./interruption.js\";\nimport type { RecordedTimings } from \"./types.js\";\nimport type { Journal } from \"./journal.js\";\nimport { applyChaosAsync } from \"./chaos.js\";\nimport { proxyAndRecord } from \"./recorder.js\";\nimport { planMisbehavior, recordMisbehaviorOutcome } from \"./misbehavior.js\";\n\n// ─── Responses API request types ────────────────────────────────────────────\n\nexport interface ResponsesInputItem {\n role?: string;\n type?: string;\n content?: string | ResponsesContentPart[];\n call_id?: string;\n name?: string;\n /** `function_call` / `custom_tool_call`: the namespace of the called tool. */\n namespace?: string;\n arguments?: string;\n /** `custom_tool_call`: the free-text input. */\n input?: string;\n /** `function_call_output` / `custom_tool_call_output`: a string or content parts. */\n output?: string | ResponsesContentPart[];\n /** `additional_tools` / `tool_search_output`: tools made available at this item. */\n tools?: ResponsesToolDef[];\n id?: string;\n}\n\ninterface ResponsesContentPart {\n type: string;\n text?: string;\n}\n\ninterface ResponsesRequest {\n model: string;\n input: string | ResponsesInputItem[];\n instructions?: string;\n tools?: ResponsesToolDef[];\n tool_choice?: string | object;\n stream?: boolean;\n temperature?: number;\n max_output_tokens?: number;\n response_format?: { type: string; [key: string]: unknown };\n // Additional output data requested by the caller, e.g.\n // \"reasoning.encrypted_content\" (gates encrypted-reasoning emission).\n include?: string[];\n // Server-side storage flag. `false` (ZDR / stateless replay) is one of the\n // triggers for encrypted reasoning; see `requestWantsEncryptedReasoning`.\n store?: boolean;\n [key: string]: unknown;\n}\n\ninterface ResponsesFunctionToolDef {\n type: \"function\";\n name: string;\n description?: string;\n parameters?: object;\n strict?: boolean;\n}\n\ninterface ResponsesCustomToolDef {\n type: \"custom\";\n name: string;\n description?: string;\n format?: unknown;\n}\n\ninterface ResponsesNamespaceToolDef {\n type: \"namespace\";\n name: string;\n description?: string;\n tools: Array<ResponsesFunctionToolDef | ResponsesCustomToolDef>;\n}\n\n/**\n * A Responses request tool. `function`, `custom` and `namespace` tools are\n * flattened for matching; any other tool type is accepted and ignored.\n */\nexport type ResponsesToolDef =\n | ResponsesFunctionToolDef\n | ResponsesCustomToolDef\n | ResponsesNamespaceToolDef\n | { type: string; name?: string; [key: string]: unknown };\n\n// ─── Input conversion: Responses → ChatCompletions messages ─────────────────\n\nfunction extractTextContent(content: string | ResponsesContentPart[] | undefined): string {\n if (!content) return \"\";\n if (typeof content === \"string\") return content;\n return content\n .filter((p) => p.type === \"input_text\" || p.type === \"output_text\")\n .map((p) => p.text ?? \"\")\n .join(\"\");\n}\n\n/**\n * A `custom_tool_call_output.output` is a string or a list of content parts\n * (`input_text` / `input_image` / `input_file`). Flatten a list to its\n * concatenated `input_text` text so text matchers such as\n * `toolResultContains` see it.\n *\n * The value comes straight from the request body, so it is read as `unknown`.\n * Like `function_call_output`, a malformed output never fails the request:\n * any other value (null, an object, a number) yields empty text, and list\n * entries that are not `input_text` parts with string text are skipped.\n */\nfunction customToolOutputText(output: unknown): string {\n if (typeof output === \"string\") return output;\n if (!Array.isArray(output)) return \"\";\n return output\n .map((p: unknown) => {\n if (p === null || typeof p !== \"object\") return \"\";\n const part = p as { type?: unknown; text?: unknown };\n return part.type === \"input_text\" && typeof part.text === \"string\" ? part.text : \"\";\n })\n .join(\"\");\n}\n\n/** Options for converting a Responses request into the router's request shape. */\nexport interface ResponsesConversionOptions {\n /**\n * `responsesTools: \"extended\"`: count custom tool call history, keep history\n * namespaces, and offer namespaced, custom and `additional_tools` /\n * `tool_search_output` tools to `toolName` and predicates. Default false:\n * the conversion of earlier releases.\n */\n extended?: boolean;\n /** Receives one warning per malformed tool item dropped in extended mode. */\n logger?: Logger;\n}\n\n/**\n * Convert Responses input items into chat messages for fixture matching. The\n * default is the conversion of earlier releases: `custom_tool_call` and\n * `custom_tool_call_output` items are skipped, and history namespaces are not\n * kept. With `extended`, a custom tool call becomes an assistant message with\n * `custom_tool_calls` (so turn counting sees it), its output becomes a `tool`\n * message (so `hasToolResult` and `toolCallId` see it), and a `function_call`\n * keeps its `namespace`.\n */\nexport function responsesInputToMessages(req: ResponsesRequest, extended = false): ChatMessage[] {\n const messages: ChatMessage[] = [];\n // Track item_reference placeholders so we can upgrade or clean them up\n const itemReferencePlaceholders = new WeakSet<ChatMessage>();\n\n // instructions field → system message\n if (req.instructions) {\n messages.push({ role: \"system\", content: req.instructions });\n }\n\n // The OpenAI Responses API accepts either a plain string or an array of input items.\n // When a string is passed, treat it as a single user message.\n if (typeof req.input === \"string\") {\n messages.push({ role: \"user\", content: req.input });\n return messages;\n }\n\n /** A synthesized call for an output item that has no matching call. */\n const attachSynthesizedCall = (target: ChatMessage, item: ResponsesInputItem): void => {\n const id = item.call_id ?? generateToolCallId();\n if (item.type === \"custom_tool_call_output\") {\n (target.custom_tool_calls ??= []).push({ id, type: \"custom\", name: \"\", input: \"\" });\n } else {\n (target.tool_calls ??= []).push({\n id,\n type: \"function\",\n function: { name: \"\", arguments: \"\" },\n });\n }\n };\n const hasCalls = (m: ChatMessage): boolean =>\n m.tool_calls !== undefined || m.custom_tool_calls !== undefined;\n\n for (const item of req.input) {\n if (item.role === \"system\" || item.role === \"developer\") {\n messages.push({ role: \"system\", content: extractTextContent(item.content) });\n } else if (item.role === \"user\") {\n messages.push({ role: \"user\", content: extractTextContent(item.content) });\n } else if (item.role === \"assistant\") {\n messages.push({ role: \"assistant\", content: extractTextContent(item.content) });\n } else if (item.type === \"function_call\") {\n // Previous assistant tool call — emit as assistant message with tool_calls\n messages.push({\n role: \"assistant\",\n content: null,\n tool_calls: [\n {\n id: item.call_id ?? generateToolCallId(),\n type: \"function\",\n ...(extended && typeof item.namespace === \"string\"\n ? { namespace: item.namespace }\n : {}),\n function: { name: item.name ?? \"\", arguments: item.arguments ?? \"\" },\n },\n ],\n });\n } else if (extended && item.type === \"custom_tool_call\") {\n // Previous assistant custom tool call. The pushed assistant message makes\n // turn counting see the call. A non-string input (malformed history)\n // becomes \"\", the same coercion customToolOutputText applies to a\n // custom output.\n messages.push({\n role: \"assistant\",\n content: null,\n custom_tool_calls: [\n {\n id: item.call_id ?? generateToolCallId(),\n type: \"custom\",\n name: item.name ?? \"\",\n input: typeof item.input === \"string\" ? item.input : \"\",\n ...(typeof item.namespace === \"string\" ? { namespace: item.namespace } : {}),\n },\n ],\n });\n } else if (\n item.type === \"function_call_output\" ||\n (extended && item.type === \"custom_tool_call_output\")\n ) {\n // Bug 1 fix: If there's no preceding assistant message with a matching\n // tool_call for this call_id, synthesize one. This happens when the AI SDK\n // sends [user, item_reference, function_call_output] — the item_reference\n // placeholder (see below) has no tool_calls, so we need a real assistant\n // message with the tool_call for turnIndex counting. In extended mode a\n // custom_tool_call_output is handled the same way, and its synthesized\n // call is a custom one.\n const hasMatchingToolCall = messages.some(\n (m) =>\n m.role === \"assistant\" &&\n (m.tool_calls?.some((tc) => tc.id === item.call_id) ||\n m.custom_tool_calls?.some((tc) => tc.id === item.call_id)),\n );\n if (!hasMatchingToolCall) {\n // Check if the last message is an item_reference placeholder — if so,\n // upgrade it to carry the tool_call instead of synthesizing a duplicate.\n const lastMsg = messages[messages.length - 1];\n if (\n lastMsg &&\n lastMsg.role === \"assistant\" &&\n itemReferencePlaceholders.has(lastMsg) &&\n !hasCalls(lastMsg)\n ) {\n lastMsg.content = null;\n attachSynthesizedCall(lastMsg, item);\n itemReferencePlaceholders.delete(lastMsg);\n } else {\n // Multi-fco case: look for a recent assistant with tool_calls that\n // belongs to the same turn. After the first fco upgrades a placeholder,\n // subsequent fco's see [assistant(call_A), tool(call_A)] — the last\n // assistant with tool_calls (right before the trailing tool messages)\n // is the correct target.\n let appended = false;\n for (let k = messages.length - 1; k >= 0; k--) {\n const m = messages[k];\n if (m.role === \"assistant\" && hasCalls(m)) {\n attachSynthesizedCall(m, item);\n appended = true;\n break;\n }\n // Stop scanning if we hit a user message — different turn\n if (m.role === \"user\") break;\n }\n if (!appended) {\n const synthesized: ChatMessage = { role: \"assistant\", content: null };\n attachSynthesizedCall(synthesized, item);\n messages.push(synthesized);\n }\n }\n }\n messages.push({\n role: \"tool\",\n content:\n item.type === \"custom_tool_call_output\"\n ? customToolOutputText(item.output)\n : // function_call_output keeps its handling from earlier releases:\n // an array output passes through as content parts, so text\n // matchers do not see it.\n ((item.output ?? \"\") as string | ContentPart[]),\n tool_call_id: item.call_id,\n });\n } else if (item.type === \"item_reference\") {\n // Bug 6 fix: item_reference items represent prior assistant turns (text\n // or function_call). Push a placeholder so they count in assistantCount.\n // If a subsequent function_call_output arrives, the handler above will\n // upgrade this placeholder to carry tool_calls (avoiding double-count).\n const placeholder: ChatMessage = { role: \"assistant\", content: \"\" };\n itemReferencePlaceholders.add(placeholder);\n messages.push(placeholder);\n } else {\n // Skip local_shell_call, mcp_list_tools, etc. — not needed for fixture\n // matching. Without extended mode this includes custom tool call items.\n }\n }\n\n return messages;\n}\n\n/** The request tools of earlier releases: top-level `function` tools only. */\nfunction responsesToolsToCompletionsTools(\n tools?: ResponsesToolDef[],\n): ToolDefinition[] | undefined {\n if (!tools || tools.length === 0) return undefined;\n return tools\n .filter((t) => t.type === \"function\")\n .map((t) => ({\n type: \"function\" as const,\n function: {\n name: t.name as string,\n description: t.description as string | undefined,\n parameters: (t as { parameters?: object }).parameters,\n },\n }));\n}\n\n/** One Responses `function` or `custom` tool in aimock's normalized form. */\nfunction normalizeResponsesTool(\n tool: unknown,\n namespace?: string,\n): ToolDefinition | CustomToolDefinition | undefined {\n if (tool === null || typeof tool !== \"object\") return undefined;\n const t = tool as Record<string, unknown>;\n const ns = namespace !== undefined ? { namespace } : {};\n if (t.type === \"function\") {\n const fn = t as unknown as ResponsesFunctionToolDef;\n return {\n type: \"function\",\n ...ns,\n function: {\n name: fn.name,\n description: fn.description,\n parameters: fn.parameters,\n },\n };\n }\n if (t.type === \"custom\") {\n const custom = t as unknown as ResponsesCustomToolDef;\n return {\n type: \"custom\",\n name: custom.name,\n ...(custom.description !== undefined ? { description: custom.description } : {}),\n ...ns,\n ...(custom.format !== undefined ? { format: custom.format } : {}),\n };\n }\n return undefined;\n}\n\n/**\n * Input items whose `tools` add to the request's tools:\n * `additional_tools` (Codex responses-lite) and `tool_search_output` (tools\n * loaded by tool search, e.g. Codex's deferred MCP namespaces). Both carry the\n * same function / custom / namespace tool shapes as `req.tools`.\n */\nfunction isToolCarryingItemType(type: unknown): boolean {\n return type === \"additional_tools\" || type === \"tool_search_output\";\n}\n\n/**\n * Why a `namespace` tool cannot be flattened, or undefined when it can: its\n * name is not a non-empty string (OpenAI's `NamespaceToolParam` requires\n * `name` with `minLength: 1`), or its `tools` is not an array.\n */\nfunction namespaceToolProblem(tool: { name?: unknown; tools?: unknown }): string | undefined {\n if (typeof tool.name !== \"string\" || tool.name === \"\") return \"name is not a non-empty string\";\n if (!Array.isArray(tool.tools)) return \"tools is not an array\";\n return undefined;\n}\n\n/**\n * Flatten every Responses tool a request offers, for extended matching and for\n * `toolNamespace`. Sources, in order: `req.tools`, then the `tools` of every\n * `additional_tools` or `tool_search_output` input item, in input order.\n * `namespace` tools contribute one entry per inner function/custom tool, each\n * carrying the namespace; other tool types are ignored.\n *\n * Malformed items never fail the request (earlier releases ignored them): a\n * `namespace` tool without a non-empty string name or with a non-array\n * `tools`, a `null` entry, and a tool-carrying item whose `tools` is not an\n * array are dropped, with a warning when `warn` is given.\n */\nfunction flattenResponsesTools(\n req: ResponsesRequest,\n warn?: (message: string) => void,\n): { tools: ToolDefinition[]; customTools: CustomToolDefinition[]; sourceCount: number } {\n const tools: ToolDefinition[] = [];\n const customTools: CustomToolDefinition[] = [];\n const add = (normalized: ToolDefinition | CustomToolDefinition | undefined) => {\n if (!normalized) return;\n if (normalized.type === \"custom\") customTools.push(normalized);\n else tools.push(normalized);\n };\n const sources: Array<{ tool: unknown; path: string }> = [];\n if (Array.isArray(req.tools)) {\n req.tools.forEach((tool, i) => sources.push({ tool, path: `tools[${i}]` }));\n }\n if (Array.isArray(req.input)) {\n req.input.forEach((item, i) => {\n if (!isToolCarryingItemType(item?.type) || item?.tools === undefined) return;\n if (!Array.isArray(item.tools)) {\n warn?.(`Ignoring input[${i}].tools: not an array`);\n return;\n }\n item.tools.forEach((tool, j) => sources.push({ tool, path: `input[${i}].tools[${j}]` }));\n });\n }\n for (const { tool, path } of sources) {\n const t = tool as { type?: unknown; name?: unknown; tools?: unknown } | null;\n if (t === null) {\n warn?.(`Ignoring ${path}: null tool`);\n continue;\n }\n if (t?.type === \"namespace\") {\n const problem = namespaceToolProblem(t);\n if (problem) {\n warn?.(`Ignoring namespace tool ${path}: ${problem}`);\n continue;\n }\n (t.tools as unknown[]).forEach((inner, k) => {\n if (inner === null) warn?.(`Ignoring ${path}.tools[${k}]: null tool`);\n else add(normalizeResponsesTool(inner, t.name as string));\n });\n continue;\n }\n add(normalizeResponsesTool(tool));\n }\n return { tools, customTools, sourceCount: sources.length };\n}\n\nexport function responsesToCompletionRequest(\n req: ResponsesRequest,\n options: ResponsesConversionOptions = {},\n): ChatCompletionRequest {\n const extended = options.extended === true;\n const all = flattenResponsesTools(\n req,\n extended && options.logger\n ? (message) => options.logger?.warn(`Responses request: ${message}`)\n : undefined,\n );\n const completionReq: ChatCompletionRequest = {\n model: req.model,\n messages: responsesInputToMessages(req, extended),\n stream: req.stream,\n temperature: req.temperature,\n max_tokens: req.max_output_tokens,\n tools: extended\n ? all.sourceCount > 0\n ? all.tools\n : undefined\n : responsesToolsToCompletionsTools(req.tools),\n ...(extended && all.customTools.length > 0 ? { customTools: all.customTools } : {}),\n tool_choice: req.tool_choice,\n response_format: req.response_format,\n };\n setResponsesOfferedTools(completionReq, { tools: all.tools, customTools: all.customTools });\n return completionReq;\n}\n\n/**\n * The HTTP request check of earlier releases for `tools`: keep the\n * converter's empty/falsy bypass, and reject only a collection the legacy\n * converter would throw on (not an array, or a `null` entry). Malformed\n * nested tools (inside a `namespace` tool or a tool-carrying input item) are\n * dropped by the conversion instead.\n */\nexport function validateResponsesTools(tools: unknown): string | undefined {\n if (tools && (tools as { length?: unknown }).length !== 0) {\n if (!Array.isArray(tools)) return \"tools must be an array\";\n if (tools.some((tool) => tool === null)) return \"tools entries must not be null\";\n }\n return undefined;\n}\n\n// ─── Response building: fixture → Responses API format ──────────────────────\n\nfunction responsesStatus(finishReason: string | undefined, defaultStatus: string): string {\n if (!finishReason) return defaultStatus;\n if (finishReason === \"stop\") return \"completed\";\n if (finishReason === \"tool_calls\") return \"completed\";\n if (finishReason === \"length\") return \"incomplete\";\n if (finishReason === \"content_filter\") return \"failed\";\n return finishReason;\n}\n\nfunction responsesUsage(overrides?: ResponseOverrides): {\n input_tokens: number;\n output_tokens: number;\n total_tokens: number;\n} {\n if (!overrides?.usage) return { input_tokens: 0, output_tokens: 0, total_tokens: 0 };\n const input = overrides.usage.input_tokens ?? overrides.usage.prompt_tokens ?? 0;\n const output = overrides.usage.output_tokens ?? overrides.usage.completion_tokens ?? 0;\n return {\n input_tokens: input,\n output_tokens: output,\n total_tokens: overrides.usage.total_tokens ?? input + output,\n };\n}\n\nfunction responseId(): string {\n return generateId(\"resp\");\n}\n\nfunction itemId(): string {\n return generateId(\"msg\");\n}\n\n// Streaming events for Responses API\n\nexport interface ResponsesSSEEvent {\n type: string;\n [key: string]: unknown;\n}\n\nexport function buildTextStreamEvents(\n content: string,\n model: string,\n chunkSize: number,\n reasoning?: string,\n webSearches?: string[],\n overrides?: ResponseOverrides,\n emitEncryptedReasoning = false,\n synthesizeSummarylessReasoning = false,\n): ResponsesSSEEvent[] {\n const { respId, created, events, prefixOutputItems, nextOutputIndex } = buildResponsePreamble(\n model,\n chunkSize,\n reasoning,\n webSearches,\n overrides,\n emitEncryptedReasoning,\n synthesizeSummarylessReasoning,\n );\n\n const { events: msgEvents, msgItem } = buildMessageOutputEvents(\n content,\n chunkSize,\n nextOutputIndex,\n );\n events.push(...msgEvents);\n\n events.push({\n type: \"response.completed\",\n response: {\n id: respId,\n object: \"response\",\n created_at: created,\n model: overrides?.model ?? model,\n status: responsesStatus(overrides?.finishReason, \"completed\"),\n output: [...prefixOutputItems, msgItem],\n usage: responsesUsage(overrides),\n },\n });\n\n return events;\n}\n\nfunction requireFixtureToolArguments(value: unknown): string {\n if (typeof value !== \"string\") {\n throw new Error('Invalid fixture tool call: \"arguments\" must be a string after normalization');\n }\n return value;\n}\n\nfunction requireFixtureToolInput(value: unknown): string {\n if (typeof value !== \"string\") {\n throw new Error('Invalid fixture tool call: \"input\" must be a string for a custom tool call');\n }\n return value;\n}\n\n/**\n * A tool call to emit: a `toolCalls` entry, or a normalized `toolCall` /\n * `customToolCall` block passed through as-is.\n */\ntype EmittableToolCall = FixtureToolCall | Exclude<ResponsesFixtureBlock, { type: \"text\" }>;\n\nfunction isCustomEmittable(\n call: EmittableToolCall,\n): call is CustomToolCall | Extract<ResponsesFixtureBlock, { type: \"customToolCall\" }> {\n // A non-object entry (only reachable from an untyped fixture) takes the\n // function path, which fails on it exactly as earlier releases did.\n if (call === null || typeof call !== \"object\") return false;\n return call.type === \"custom\" || call.type === \"customToolCall\";\n}\n\n/**\n * A Responses `function_call` item. `namespace` is added only when the fixture\n * sets it, so a call without one keeps the keys and key order it had before\n * namespaces existed (existing fixtures stay byte-identical on the wire).\n */\nfunction functionCallItem(\n call: { name: string; namespace?: string },\n fcId: string,\n callId: string,\n args: string,\n status: \"in_progress\" | \"completed\",\n): Record<string, unknown> {\n return {\n type: \"function_call\",\n id: fcId,\n call_id: callId,\n ...(call.namespace !== undefined ? { namespace: call.namespace } : {}),\n name: call.name,\n arguments: args,\n status,\n };\n}\n\n/**\n * `ctc_…` item id, the prefix the OpenAI guide and Codex's item-id map use for\n * custom tool calls. The underscore separator is deliberate: it matches the\n * real id format, so this does not use `generateId` (which would give\n * `ctc-…`, like aimock's own `fc-…` ids).\n */\nfunction customToolCallItemId(): string {\n return `ctc_${randomBytes(12).toString(\"base64url\")}`;\n}\n\n/** A Responses `custom_tool_call` item; `namespace` is added only when set. */\nfunction customToolCallItem(\n call: { name: string; namespace?: string },\n ctcId: string,\n callId: string,\n input: string,\n status: \"in_progress\" | \"completed\",\n): Record<string, unknown> {\n return {\n type: \"custom_tool_call\",\n id: ctcId,\n call_id: callId,\n ...(call.namespace !== undefined ? { namespace: call.namespace } : {}),\n name: call.name,\n input,\n status,\n };\n}\n\n/**\n * A `toolCalls` entry as earlier releases served it: a function call whose\n * `type`, `input` and `namespace` are ignored. The exported builders take\n * fixtures in that form; the handler passes `namespace` (extended mode) and\n * custom calls to the internal builders instead.\n */\nfunction legacyFunctionCall(call: ToolCall): FixtureToolCall {\n if (call === null || typeof call !== \"object\") return call;\n const { name, arguments: args, id } = call;\n return id !== undefined ? { name, arguments: args, id } : { name, arguments: args };\n}\n\n/**\n * The exported builders' `toolCalls` as legacy function calls. It walks\n * `toolCalls` by index up to `toolCalls.length`, as earlier releases did, so an\n * untyped caller's non-array value gives the same calls: none for an object\n * without `length`, and entries by index for a string or array-like.\n */\nfunction legacyFunctionCalls(toolCalls: ToolCall[]): FixtureToolCall[] {\n const calls: FixtureToolCall[] = [];\n for (let idx = 0; idx < toolCalls.length; idx++) {\n calls.push(legacyFunctionCall(toolCalls[idx]));\n }\n return calls;\n}\n\n/** Resolve exported-builder `blocks` as earlier releases did (no namespace emitted). */\nfunction legacyOrderedBlocks(\n blocks: FixtureBlock[] | undefined,\n): ResponsesFixtureBlock[] | undefined {\n if (!blocks || blocks.length === 0) return undefined;\n return resolveFixtureBlocks(blocks).map((block) => {\n if (block.type === \"text\" || block.namespace === undefined) return block;\n const copy = { ...block };\n delete copy.namespace;\n return copy;\n });\n}\n\nexport function buildToolCallStreamEvents(\n toolCalls: ToolCall[],\n model: string,\n chunkSize: number,\n reasoning?: string,\n webSearches?: string[],\n overrides?: ResponseOverrides,\n emitEncryptedReasoning = false,\n synthesizeSummarylessReasoning = false,\n): ResponsesSSEEvent[] {\n return toolCallStreamEvents(\n legacyFunctionCalls(toolCalls),\n model,\n chunkSize,\n reasoning,\n webSearches,\n overrides,\n emitEncryptedReasoning,\n synthesizeSummarylessReasoning,\n );\n}\n\nexport function toolCallStreamEvents(\n toolCalls: FixtureToolCall[],\n model: string,\n chunkSize: number,\n reasoning?: string,\n webSearches?: string[],\n overrides?: ResponseOverrides,\n emitEncryptedReasoning = false,\n synthesizeSummarylessReasoning = false,\n): ResponsesSSEEvent[] {\n assertResponsesToolCalls(toolCalls);\n const { respId, created, events, prefixOutputItems, nextOutputIndex } = buildResponsePreamble(\n model,\n chunkSize,\n reasoning,\n webSearches,\n overrides,\n emitEncryptedReasoning,\n synthesizeSummarylessReasoning,\n );\n\n const fcOutputItems: object[] = [];\n\n for (let idx = 0; idx < toolCalls.length; idx++) {\n const { events: callEvents, item } = buildToolCallOutputEvents(\n toolCalls[idx],\n chunkSize,\n nextOutputIndex + idx,\n );\n events.push(...callEvents);\n fcOutputItems.push(item);\n }\n\n // response.completed\n events.push({\n type: \"response.completed\",\n response: {\n id: respId,\n object: \"response\",\n created_at: created,\n model: overrides?.model ?? model,\n status: responsesStatus(overrides?.finishReason, \"completed\"),\n output: [...prefixOutputItems, ...fcOutputItems],\n usage: responsesUsage(overrides),\n },\n });\n\n return events;\n}\n\n/**\n * Whether the incoming Responses request should receive encrypted reasoning.\n *\n * Two observed triggers, gated on EITHER:\n * - `include: [\"reasoning.encrypted_content\"]` — the explicit opt-in, and what\n * `agent-framework-openai` >= 1.11.0 auto-appends on its stateless-replay path\n * (it never sends `store`), so this is the branch that fires for real clients.\n * - `store: false` — captured responses carry the blob when not server-side\n * stored (ZDR) and omit it when stored; kept as a secondary trigger for\n * clients that go stateless without opting in via `include`.\n *\n * Stored / opted-out replays stay byte-identical. Exported so the WebSocket\n * Responses transport can share one gate.\n */\nexport function requestWantsEncryptedReasoning(req: ResponsesRequest): boolean {\n if (requestIncludesEncryptedReasoning(req)) return true;\n return req.store === false;\n}\n\n/**\n * Whether the request carries the EXPLICIT `include` opt-in — a strictly\n * narrower gate than `requestWantsEncryptedReasoning`, which also fires on\n * `store: false`.\n *\n * This is the gate for SYNTHESIZING a reasoning item that the fixture does not\n * declare (see `shouldSynthesizeBlobOnlyReasoning`), and it is deliberately the\n * narrow one. Attaching a field to an item aimock was already emitting is a much\n * smaller step than conjuring a whole output item that did not previously exist,\n * so the larger behavior change gets the gate that is directly observable in the\n * request rather than the inferred `store: false` one. `agent-framework-openai`\n * >= 1.11.0 auto-appends `include` on its stateless-replay path and never sends\n * `store` at all, so the motivating client is fully served by this branch — the\n * narrowing costs the feature nothing.\n *\n * Exported so the WebSocket Responses transport shares one gate.\n */\nexport function requestIncludesEncryptedReasoning(req: ResponsesRequest): boolean {\n const include = req.include;\n return Array.isArray(include) && include.includes(\"reasoning.encrypted_content\");\n}\n\n/**\n * Synthetic stand-in for OpenAI's opaque `reasoning.encrypted_content`. aimock\n * has no real ciphertext; it emits a base64 placeholder derived from the\n * reasoning id (stable for a given item, opaque like the real field). Consumers\n * store it (e.g. as agent-framework `protected_data`) and replay it verbatim;\n * aimock matches on content and ignores the echoed blob. Without it,\n * agent-framework-openai >= 1.11.0 hard-fails a reasoning + multi-tool chain on\n * the follow-up request. See microsoft/agent-framework#7233.\n *\n * aimock skips inbound reasoning items entirely, so it cannot reproduce\n * OpenAI's `invalid_encrypted_content` rejection of a mismatched blob/id — a\n * known replay-only limitation.\n */\nfunction syntheticEncryptedReasoning(reasoningId: string): string {\n return Buffer.from(`aimock-encrypted-reasoning:${reasoningId}`).toString(\"base64\");\n}\n\n/**\n * Build a Responses `reasoning` output item. `summaryText` controls the summary\n * (present for the terminal `done` / non-streaming item, omitted for the\n * in-progress `added` item); `emitEncrypted` controls the blob INDEPENDENTLY of\n * the summary, so a blob with an empty summary is expressible. aimock emits the\n * blob only on the terminal item and omits it on `added`: real OpenAI populates\n * `added` opportunistically, but the field is `anyOf: [string, null]` and\n * non-required, so consumers should read it at `done` and treat `added` as\n * best-effort — omitting there is legal and harmless.\n */\nfunction buildReasoningOutputItem(\n reasoningId: string,\n opts: { summaryText?: string; emitEncrypted?: boolean } = {},\n): Record<string, unknown> {\n const item: Record<string, unknown> = {\n type: \"reasoning\",\n id: reasoningId,\n summary:\n opts.summaryText === undefined ? [] : [{ type: \"summary_text\", text: opts.summaryText }],\n };\n if (opts.emitEncrypted) {\n item.encrypted_content = syntheticEncryptedReasoning(reasoningId);\n }\n return item;\n}\n\n/**\n * Whether to synthesize a summary-LESS reasoning item that exists purely to\n * carry the encrypted blob.\n *\n * Every reasoning item aimock emits otherwise originates in a fixture's declared\n * `reasoning` summary text. But a fixture RECORDED from the real stateless\n * agent-framework flow typically has NO summary — OpenAI returns `summary: []`\n * unless summaries are explicitly requested — so keying the item on a declared\n * summary starves the exact flow this feature exists to serve: fully opted in,\n * yet no reasoning item and therefore no blob. Real OpenAI, for a\n * reasoning-capable model, still returns a reasoning item (`summary: []`) with\n * the blob populated. So synthesize one, gated on:\n *\n * - the EXPLICIT `include` opt-in ONLY (`requestIncludesEncryptedReasoning`),\n * which is NARROWER than the `requestWantsEncryptedReasoning` gate that\n * controls the blob itself. A `store: false` request whose fixture declares no\n * summary therefore gets NO reasoning item, exactly as before this change.\n * Two reasons: (1) creating an output item that did not previously exist is a\n * bigger behavior change than adding a field to an item already being\n * emitted, so it earns the gate that is directly observable in the request\n * rather than the inferred one; (2) the `store: false` trigger's supporting\n * capture evidence is not verifiable from this repo, and a larger change must\n * not be stacked on an unverifiable premise. `agent-framework-openai` >=\n * 1.11.0 sends `include` and never `store`, so nothing is lost.\n * - the REQUESTED model's reasoning capability (aimock#254) — emitting a\n * reasoning item for gpt-4o would be LESS faithful, not more, since that\n * model has no reasoning channel at all. Unlike `resolveReasoningForModel`,\n * which fails open for a declared summary (a recorded summary is evidence the\n * model did reason), there is nothing to preserve here: a synthesized item on\n * a non-reasoning model would be pure fabrication, so this gate is hard.\n *\n * Note this is INDEPENDENT of `emitEncryptedReasoning`: when a fixture DOES\n * declare a summary, the blob still rides on it under either trigger (including\n * `store: false`), unchanged.\n */\nfunction shouldSynthesizeBlobOnlyReasoning(\n reasoning: string | undefined,\n model: string | undefined,\n synthesizeSummarylessReasoning: boolean,\n): boolean {\n if (reasoning) return false; // a declared summary already produces the item\n if (!synthesizeSummarylessReasoning) return false; // no explicit `include` opt-in\n return isReasoningModel(model);\n}\n\n/**\n * `reasoning` is `undefined` for a synthesized blob-only item (see\n * `shouldSynthesizeBlobOnlyReasoning`). In that case the item's `summary` is\n * `[]`, so the summary-part / summary-text events are SKIPPED entirely — they\n * would describe a part that does not exist on the item — leaving a coherent\n * `output_item.added` → `output_item.done` pair with nothing between.\n */\nfunction buildReasoningStreamEvents(\n reasoning: string | undefined,\n chunkSize: number,\n emitEncryptedReasoning = false,\n): ResponsesSSEEvent[] {\n const reasoningId = generateId(\"rs\");\n const events: ResponsesSSEEvent[] = [];\n\n events.push({\n type: \"response.output_item.added\",\n output_index: 0,\n item: buildReasoningOutputItem(reasoningId),\n });\n\n if (reasoning !== undefined) {\n events.push({\n type: \"response.reasoning_summary_part.added\",\n item_id: reasoningId,\n output_index: 0,\n summary_index: 0,\n part: { type: \"summary_text\", text: \"\" },\n });\n\n for (let i = 0; i < reasoning.length; i += chunkSize) {\n const slice = reasoning.slice(i, i + chunkSize);\n events.push({\n type: \"response.reasoning_summary_text.delta\",\n item_id: reasoningId,\n output_index: 0,\n summary_index: 0,\n delta: slice,\n });\n }\n\n events.push({\n type: \"response.reasoning_summary_text.done\",\n item_id: reasoningId,\n output_index: 0,\n summary_index: 0,\n text: reasoning,\n });\n\n events.push({\n type: \"response.reasoning_summary_part.done\",\n item_id: reasoningId,\n output_index: 0,\n summary_index: 0,\n part: { type: \"summary_text\", text: reasoning },\n });\n }\n\n events.push({\n type: \"response.output_item.done\",\n output_index: 0,\n item: buildReasoningOutputItem(reasoningId, {\n summaryText: reasoning,\n emitEncrypted: emitEncryptedReasoning,\n }),\n });\n\n return events;\n}\n\nfunction buildWebSearchStreamEvents(\n queries: string[],\n startOutputIndex: number,\n): ResponsesSSEEvent[] {\n const events: ResponsesSSEEvent[] = [];\n\n for (let i = 0; i < queries.length; i++) {\n const searchId = generateId(\"ws\");\n const outputIndex = startOutputIndex + i;\n\n events.push({\n type: \"response.output_item.added\",\n output_index: outputIndex,\n item: {\n type: \"web_search_call\",\n id: searchId,\n status: \"in_progress\",\n action: { type: \"search\", query: queries[i] },\n },\n });\n\n events.push({\n type: \"response.output_item.done\",\n output_index: outputIndex,\n item: {\n type: \"web_search_call\",\n id: searchId,\n status: \"completed\",\n action: { type: \"search\", query: queries[i] },\n },\n });\n }\n\n return events;\n}\n\n// ─── Shared streaming helpers ────────────────────────────────────────────────\n\ninterface PreambleResult {\n respId: string;\n created: number;\n events: ResponsesSSEEvent[];\n prefixOutputItems: object[];\n nextOutputIndex: number;\n}\n\nfunction buildResponsePreamble(\n model: string,\n chunkSize: number,\n reasoning?: string,\n webSearches?: string[],\n overrides?: ResponseOverrides,\n emitEncryptedReasoning = false,\n synthesizeSummarylessReasoning = false,\n forceReasoning = false,\n): PreambleResult {\n const respId = overrides?.id ?? responseId();\n const created = overrides?.created ?? Math.floor(Date.now() / 1000);\n const effectiveModel = overrides?.model ?? model;\n const events: ResponsesSSEEvent[] = [];\n const prefixOutputItems: object[] = [];\n let nextOutputIndex = 0;\n\n events.push({\n type: \"response.created\",\n response: {\n id: respId,\n object: \"response\",\n created_at: created,\n model: effectiveModel,\n status: \"in_progress\",\n output: [],\n },\n });\n events.push({\n type: \"response.in_progress\",\n response: {\n id: respId,\n object: \"response\",\n created_at: created,\n model: effectiveModel,\n status: \"in_progress\",\n output: [],\n },\n });\n\n if (\n reasoning ||\n forceReasoning ||\n shouldSynthesizeBlobOnlyReasoning(reasoning, model, synthesizeSummarylessReasoning)\n ) {\n const reasoningEvents = buildReasoningStreamEvents(\n reasoning,\n chunkSize,\n emitEncryptedReasoning,\n );\n events.push(...reasoningEvents);\n const doneEvent = reasoningEvents.find(\n (e) =>\n e.type === \"response.output_item.done\" &&\n (e.item as { type: string })?.type === \"reasoning\",\n );\n if (doneEvent) prefixOutputItems.push(doneEvent.item as object);\n nextOutputIndex++;\n }\n\n if (webSearches && webSearches.length > 0) {\n const searchEvents = buildWebSearchStreamEvents(webSearches, nextOutputIndex);\n events.push(...searchEvents);\n const doneEvents = searchEvents.filter(\n (e) =>\n e.type === \"response.output_item.done\" &&\n (e.item as { type: string })?.type === \"web_search_call\",\n );\n for (const de of doneEvents) prefixOutputItems.push(de.item as object);\n nextOutputIndex += webSearches.length;\n }\n\n return { respId, created, events, prefixOutputItems, nextOutputIndex };\n}\n\ninterface MessageBlockResult {\n events: ResponsesSSEEvent[];\n msgItem: object;\n}\n\nfunction buildMessageOutputEvents(\n content: string,\n chunkSize: number,\n outputIndex: number,\n): MessageBlockResult {\n const msgId = itemId();\n const events: ResponsesSSEEvent[] = [];\n\n events.push({\n type: \"response.output_item.added\",\n output_index: outputIndex,\n item: { type: \"message\", id: msgId, status: \"in_progress\", role: \"assistant\", content: [] },\n });\n events.push({\n type: \"response.content_part.added\",\n item_id: msgId,\n output_index: outputIndex,\n content_index: 0,\n part: { type: \"output_text\", text: \"\", annotations: [] },\n });\n\n for (let i = 0; i < content.length; i += chunkSize) {\n events.push({\n type: \"response.output_text.delta\",\n item_id: msgId,\n output_index: outputIndex,\n content_index: 0,\n delta: content.slice(i, i + chunkSize),\n });\n }\n\n events.push({\n type: \"response.output_text.done\",\n item_id: msgId,\n output_index: outputIndex,\n content_index: 0,\n text: content,\n });\n events.push({\n type: \"response.content_part.done\",\n item_id: msgId,\n output_index: outputIndex,\n content_index: 0,\n part: { type: \"output_text\", text: content, annotations: [] },\n });\n\n const msgItem = {\n type: \"message\",\n id: msgId,\n status: \"completed\",\n role: \"assistant\",\n content: [{ type: \"output_text\", text: content, annotations: [] }],\n };\n\n events.push({ type: \"response.output_item.done\", output_index: outputIndex, item: msgItem });\n\n return { events, msgItem };\n}\n\n/** One streamed tool-call item: a `function_call` or a `custom_tool_call`. */\ninterface ToolCallBlockResult {\n events: ResponsesSSEEvent[];\n item: object;\n}\n\n/**\n * Emit the output_item.added → arguments deltas → arguments.done →\n * output_item.done events for a single function_call at `outputIndex`,\n * returning the completed item for the final `output` array. Every Responses\n * streaming builder (tool-only, legacy content+toolCalls and ordered blocks)\n * reaches this through {@link buildToolCallOutputEvents}, so a given\n * (tool, outputIndex) has the same wire output on every path.\n */\nfunction buildFunctionCallOutputEvents(\n toolCall: { name: string; arguments: string; id?: string; namespace?: string },\n chunkSize: number,\n outputIndex: number,\n): ToolCallBlockResult {\n const callId = toolCall.id || generateToolCallId();\n const fcId = generateId(\"fc\");\n const args = requireFixtureToolArguments(toolCall.arguments);\n const events: ResponsesSSEEvent[] = [];\n\n events.push({\n type: \"response.output_item.added\",\n output_index: outputIndex,\n item: functionCallItem(toolCall, fcId, callId, \"\", \"in_progress\"),\n });\n\n for (let i = 0; i < args.length; i += chunkSize) {\n events.push({\n type: \"response.function_call_arguments.delta\",\n item_id: fcId,\n output_index: outputIndex,\n delta: args.slice(i, i + chunkSize),\n });\n }\n\n events.push({\n type: \"response.function_call_arguments.done\",\n item_id: fcId,\n output_index: outputIndex,\n arguments: args,\n });\n\n const item = functionCallItem(toolCall, fcId, callId, args, \"completed\");\n events.push({ type: \"response.output_item.done\", output_index: outputIndex, item });\n\n return { events, item };\n}\n\n/**\n * `text` cut into slices of at most `chunkSize` UTF-16 units, never between\n * the two halves of a surrogate pair: a cut that would land inside a pair\n * moves back before it, or, when that would leave the slice empty\n * (`chunkSize` 1), forward past it. The slices rejoin to `text` exactly.\n */\nfunction surrogateSafeChunks(text: string, chunkSize: number): string[] {\n const chunks: string[] = [];\n for (let i = 0; i < text.length; ) {\n let end = Math.min(i + chunkSize, text.length);\n const high = text.charCodeAt(end - 1);\n const low = text.charCodeAt(end);\n if (high >= 0xd800 && high <= 0xdbff && low >= 0xdc00 && low <= 0xdfff) {\n end = end - 1 > i ? end - 1 : end + 1;\n }\n chunks.push(text.slice(i, end));\n i = end;\n }\n return chunks;\n}\n\n/**\n * Emit output_item.added → custom_tool_call_input.delta×N →\n * custom_tool_call_input.done → output_item.done for one `custom_tool_call` at\n * `outputIndex`, returning the completed item. An empty `input`\n * yields no delta event.\n */\nfunction buildCustomToolCallOutputEvents(\n call: { name: string; input: string; id?: string; namespace?: string },\n chunkSize: number,\n outputIndex: number,\n): ToolCallBlockResult {\n const callId = call.id || generateToolCallId();\n const ctcId = customToolCallItemId();\n const input = requireFixtureToolInput(call.input);\n const events: ResponsesSSEEvent[] = [];\n\n events.push({\n type: \"response.output_item.added\",\n output_index: outputIndex,\n item: customToolCallItem(call, ctcId, callId, \"\", \"in_progress\"),\n });\n\n for (const delta of surrogateSafeChunks(input, chunkSize)) {\n events.push({\n type: \"response.custom_tool_call_input.delta\",\n item_id: ctcId,\n output_index: outputIndex,\n delta,\n });\n }\n\n events.push({\n type: \"response.custom_tool_call_input.done\",\n item_id: ctcId,\n output_index: outputIndex,\n input,\n });\n\n const item = customToolCallItem(call, ctcId, callId, input, \"completed\");\n events.push({ type: \"response.output_item.done\", output_index: outputIndex, item });\n\n return { events, item };\n}\n\n/** Streaming dispatcher: one function or custom tool call at `outputIndex`. */\nfunction buildToolCallOutputEvents(\n call: EmittableToolCall,\n chunkSize: number,\n outputIndex: number,\n): ToolCallBlockResult {\n return isCustomEmittable(call)\n ? buildCustomToolCallOutputEvents(call, chunkSize, outputIndex)\n : buildFunctionCallOutputEvents(call, chunkSize, outputIndex);\n}\n\n// ─── Non-streaming response builders ────────────────────────────────────────\n\nfunction buildOutputPrefix(\n content: string,\n model: string,\n reasoning?: string,\n webSearches?: string[],\n emitEncryptedReasoning = false,\n synthesizeSummarylessReasoning = false,\n): object[] {\n const output: object[] = [];\n\n if (\n reasoning ||\n shouldSynthesizeBlobOnlyReasoning(reasoning, model, synthesizeSummarylessReasoning)\n ) {\n output.push(\n buildReasoningOutputItem(generateId(\"rs\"), {\n summaryText: reasoning,\n emitEncrypted: emitEncryptedReasoning,\n }),\n );\n }\n\n if (webSearches && webSearches.length > 0) {\n for (const query of webSearches) {\n output.push({\n type: \"web_search_call\",\n id: generateId(\"ws\"),\n status: \"completed\",\n action: { type: \"search\", query },\n });\n }\n }\n\n output.push({\n type: \"message\",\n id: itemId(),\n status: \"completed\",\n role: \"assistant\",\n content: [{ type: \"output_text\", text: content, annotations: [] }],\n });\n\n return output;\n}\n\nfunction buildResponseEnvelope(\n model: string,\n output: object[],\n overrides?: ResponseOverrides,\n): object {\n return {\n id: overrides?.id ?? responseId(),\n object: \"response\",\n created_at: overrides?.created ?? Math.floor(Date.now() / 1000),\n model: overrides?.model ?? model,\n status: responsesStatus(overrides?.finishReason, \"completed\"),\n output,\n usage: responsesUsage(overrides),\n };\n}\n\nexport function buildTextResponse(\n content: string,\n model: string,\n reasoning?: string,\n webSearches?: string[],\n overrides?: ResponseOverrides,\n emitEncryptedReasoning = false,\n synthesizeSummarylessReasoning = false,\n): object {\n return buildResponseEnvelope(\n model,\n buildOutputPrefix(\n content,\n model,\n reasoning,\n webSearches,\n emitEncryptedReasoning,\n synthesizeSummarylessReasoning,\n ),\n overrides,\n );\n}\n\nfunction buildToolCallResponse(\n toolCalls: FixtureToolCall[],\n model: string,\n reasoning?: string,\n webSearches?: string[],\n overrides?: ResponseOverrides,\n emitEncryptedReasoning = false,\n synthesizeSummarylessReasoning = false,\n): object {\n assertResponsesToolCalls(toolCalls);\n const output: object[] = [];\n if (\n reasoning ||\n shouldSynthesizeBlobOnlyReasoning(reasoning, model, synthesizeSummarylessReasoning)\n ) {\n output.push(\n buildReasoningOutputItem(generateId(\"rs\"), {\n summaryText: reasoning,\n emitEncrypted: emitEncryptedReasoning,\n }),\n );\n }\n if (webSearches && webSearches.length > 0) {\n for (const query of webSearches) {\n output.push({\n type: \"web_search_call\",\n id: generateId(\"ws\"),\n status: \"completed\",\n action: { type: \"search\", query },\n });\n }\n }\n for (const tc of toolCalls) {\n output.push(buildToolCallOutputItem(tc));\n }\n return buildResponseEnvelope(model, output, overrides);\n}\n\nexport function buildContentWithToolCallsStreamEvents(\n content: string,\n toolCalls: ToolCall[],\n model: string,\n chunkSize: number,\n reasoning?: string,\n webSearches?: string[],\n overrides?: ResponseOverrides,\n blocks?: FixtureBlock[],\n emitEncryptedReasoning = false,\n synthesizeSummarylessReasoning = false,\n): ResponsesSSEEvent[] {\n const ordered = legacyOrderedBlocks(blocks);\n // With blocks, earlier releases never read `toolCalls`, so neither does this.\n return contentWithToolCallsStreamEvents(\n content,\n ordered && ordered.length > 0 ? [] : legacyFunctionCalls(toolCalls),\n model,\n chunkSize,\n reasoning,\n webSearches,\n overrides,\n ordered,\n emitEncryptedReasoning,\n synthesizeSummarylessReasoning,\n );\n}\n\n/**\n * Internal content+tool-calls builder. `ordered` is already resolved (see\n * {@link resolveServedBlockOutcome}); when non-empty it is streamed in array\n * order, otherwise the legacy message-first path runs over `toolCalls`.\n */\nexport function contentWithToolCallsStreamEvents(\n content: string,\n toolCalls: FixtureToolCall[],\n model: string,\n chunkSize: number,\n reasoning?: string,\n webSearches?: string[],\n overrides?: ResponseOverrides,\n ordered?: ResponsesFixtureBlock[],\n emitEncryptedReasoning = false,\n synthesizeSummarylessReasoning = false,\n): ResponsesSSEEvent[] {\n const { respId, created, events, prefixOutputItems, nextOutputIndex } = buildResponsePreamble(\n model,\n chunkSize,\n reasoning,\n webSearches,\n overrides,\n emitEncryptedReasoning,\n synthesizeSummarylessReasoning,\n );\n\n // The output items assembled in emission order (after any reasoning /\n // web-search prefix items). Each output_index is assigned sequentially as we\n // walk the chosen item order, so the `output_index` on every emitted event\n // matches that item's slot in the final `response.completed.output` array.\n const orderedOutputItems: object[] = [];\n\n if (ordered && ordered.length > 0) {\n // NEW PATH: stream items in the fixture's block ARRAY ORDER. A tool block\n // placed before a text block therefore yields a tool call item at\n // a LOWER output_index than the message — it leads the output array.\n let outputIndex = nextOutputIndex;\n for (const block of ordered) {\n if (block.type === \"text\") {\n const { events: msgEvents, msgItem } = buildMessageOutputEvents(\n block.text,\n chunkSize,\n outputIndex,\n );\n events.push(...msgEvents);\n orderedOutputItems.push(msgItem);\n } else {\n const { events: callEvents, item } = buildToolCallOutputEvents(\n block,\n chunkSize,\n outputIndex,\n );\n events.push(...callEvents);\n orderedOutputItems.push(item);\n }\n outputIndex += 1;\n }\n } else {\n assertResponsesToolCalls(toolCalls);\n // LEGACY PATH: message item first, then tool call items (function_call or\n // custom_tool_call). The message always leads the output; for fixtures\n // without custom calls or namespaces this is byte-for-byte the pre-blocks\n // output.\n const { events: msgEvents, msgItem } = buildMessageOutputEvents(\n content,\n chunkSize,\n nextOutputIndex,\n );\n events.push(...msgEvents);\n orderedOutputItems.push(msgItem);\n\n for (let idx = 0; idx < toolCalls.length; idx++) {\n const { events: callEvents, item } = buildToolCallOutputEvents(\n toolCalls[idx],\n chunkSize,\n nextOutputIndex + 1 + idx,\n );\n events.push(...callEvents);\n orderedOutputItems.push(item);\n }\n }\n\n events.push({\n type: \"response.completed\",\n response: {\n id: respId,\n object: \"response\",\n created_at: created,\n model: overrides?.model ?? model,\n status: responsesStatus(overrides?.finishReason, \"completed\"),\n output: [...prefixOutputItems, ...orderedOutputItems],\n usage: responsesUsage(overrides),\n },\n });\n\n return events;\n}\n\n/** Non-streaming dispatcher: the completed function or custom tool call item. */\nfunction buildToolCallOutputItem(tc: EmittableToolCall): object {\n if (isCustomEmittable(tc)) {\n return customToolCallItem(\n tc,\n customToolCallItemId(),\n tc.id || generateToolCallId(),\n requireFixtureToolInput(tc.input),\n \"completed\",\n );\n }\n return functionCallItem(\n tc,\n generateId(\"fc\"),\n tc.id || generateToolCallId(),\n requireFixtureToolArguments(tc.arguments),\n \"completed\",\n );\n}\n\nfunction buildMessageOutputItem(content: string): object {\n return {\n type: \"message\",\n id: itemId(),\n status: \"completed\",\n role: \"assistant\",\n content: [{ type: \"output_text\", text: content, annotations: [] }],\n };\n}\n\nfunction buildContentWithToolCallsResponse(\n content: string,\n toolCalls: FixtureToolCall[],\n model: string,\n reasoning?: string,\n webSearches?: string[],\n overrides?: ResponseOverrides,\n ordered?: ResponsesFixtureBlock[],\n emitEncryptedReasoning = false,\n synthesizeSummarylessReasoning = false,\n): object {\n if (ordered && ordered.length > 0) {\n // NEW PATH: the non-streaming `output[]` array is positionally observable,\n // so emit the prefix (reasoning / web_search_call), then the blocks in\n // fixture ARRAY ORDER. A tool block before a text block therefore\n // yields a tool call item ahead of the message — matching the streaming\n // path's ordering for the same `blocks` fixture.\n const output: object[] = [];\n if (\n reasoning ||\n shouldSynthesizeBlobOnlyReasoning(reasoning, model, synthesizeSummarylessReasoning)\n ) {\n output.push(\n buildReasoningOutputItem(generateId(\"rs\"), {\n summaryText: reasoning,\n emitEncrypted: emitEncryptedReasoning,\n }),\n );\n }\n if (webSearches && webSearches.length > 0) {\n for (const query of webSearches) {\n output.push({\n type: \"web_search_call\",\n id: generateId(\"ws\"),\n status: \"completed\",\n action: { type: \"search\", query },\n });\n }\n }\n for (const block of ordered) {\n if (block.type === \"text\") {\n output.push(buildMessageOutputItem(block.text));\n } else {\n output.push(buildToolCallOutputItem(block));\n }\n }\n return buildResponseEnvelope(model, output, overrides);\n }\n\n // LEGACY PATH: message item first, then tool call items (function_call or\n // custom_tool_call), as before blocks existed.\n assertResponsesToolCalls(toolCalls);\n const output = buildOutputPrefix(\n content,\n model,\n reasoning,\n webSearches,\n emitEncryptedReasoning,\n synthesizeSummarylessReasoning,\n );\n for (const tc of toolCalls) {\n output.push(buildToolCallOutputItem(tc));\n }\n return buildResponseEnvelope(model, output, overrides);\n}\n\n// ─── SSE writer for Responses API ───────────────────────────────────────────\n\ninterface ResponsesStreamOptions {\n latency?: number;\n streamingProfile?: StreamingProfile;\n recordedTimings?: RecordedTimings;\n replaySpeed?: number;\n signal?: AbortSignal;\n onChunkSent?: () => void;\n}\n\nasync function writeResponsesSSEStream(\n res: http.ServerResponse,\n events: ResponsesSSEEvent[],\n optionsOrLatency?: number | ResponsesStreamOptions,\n): Promise<boolean> {\n const opts: ResponsesStreamOptions =\n typeof optionsOrLatency === \"number\" ? { latency: optionsOrLatency } : (optionsOrLatency ?? {});\n const latency = opts.latency ?? 0;\n const profile = opts.streamingProfile;\n const { recordedTimings, replaySpeed } = opts;\n const signal = opts.signal;\n const onChunkSent = opts.onChunkSent;\n\n if (res.writableEnded) return true;\n res.setHeader(\"Content-Type\", \"text/event-stream\");\n res.setHeader(\"Cache-Control\", \"no-cache\");\n res.setHeader(\"Connection\", \"keep-alive\");\n\n let chunkIndex = 0;\n for (const event of events) {\n const chunkDelay = calculateDelay(chunkIndex, profile, latency, recordedTimings, replaySpeed);\n if (chunkDelay > 0) await delay(chunkDelay, signal);\n if (signal?.aborted) return false;\n if (res.writableEnded) return true;\n res.write(`event: ${event.type}\\ndata: ${JSON.stringify(event)}\\n\\n`);\n onChunkSent?.();\n if (signal?.aborted) return false;\n chunkIndex++;\n }\n\n if (!res.writableEnded) {\n res.end();\n }\n return true;\n}\n\n// ─── Request handler ────────────────────────────────────────────────────────\n\nexport async function handleResponses(\n req: http.IncomingMessage,\n res: http.ServerResponse,\n raw: string,\n fixtures: Fixture[],\n journal: Journal,\n defaults: HandlerDefaults,\n setCorsHeaders: (res: http.ServerResponse) => void,\n): Promise<void> {\n setCorsHeaders(res);\n\n let responsesReq: ResponsesRequest;\n try {\n responsesReq = JSON.parse(raw) as ResponsesRequest;\n } catch (parseErr) {\n const detail = parseErr instanceof Error ? parseErr.message : \"unknown\";\n journal.add({\n method: req.method ?? \"POST\",\n path: req.url ?? \"/v1/responses\",\n headers: flattenHeaders(req.headers),\n body: null,\n response: { status: 400, fixture: null },\n });\n writeErrorResponse(\n res,\n 400,\n JSON.stringify({\n error: {\n message: `Malformed JSON: ${detail}`,\n type: \"invalid_request_error\",\n code: \"invalid_json\",\n },\n }),\n );\n return;\n }\n\n // Reject bodies that parsed but are not a JSON object (e.g. `null`) before\n // touching fields — otherwise `responsesReq.model` throws a TypeError that\n // surfaces as a 500 instead of a 400.\n if (!isJsonObject(responsesReq)) {\n journal.add({\n method: req.method ?? \"POST\",\n path: req.url ?? \"/v1/responses\",\n headers: flattenHeaders(req.headers),\n body: null,\n response: { status: 400, fixture: null },\n });\n writeErrorResponse(\n res,\n 400,\n JSON.stringify({\n error: {\n message: \"Request body must be a JSON object\",\n type: \"invalid_request_error\",\n },\n }),\n );\n return;\n }\n\n // Guard only shapes consumed by input conversion. Other item fields may be\n // intentionally ignored, and falsy message content normalizes to empty text.\n let inputError: string | undefined;\n if (typeof responsesReq.input !== \"string\" && !Array.isArray(responsesReq.input)) {\n inputError = \"input must be a string or an array\";\n } else if (Array.isArray(responsesReq.input)) {\n for (const [index, item] of responsesReq.input.entries()) {\n if (item === null) {\n inputError = `input[${index}] must not be null`;\n break;\n }\n if (\n (item.role === \"system\" ||\n item.role === \"developer\" ||\n item.role === \"user\" ||\n item.role === \"assistant\") &&\n item.content &&\n typeof item.content !== \"string\" &&\n !Array.isArray(item.content)\n ) {\n inputError = `input[${index}].content must be a string or an array`;\n break;\n }\n }\n }\n const validationError = inputError ?? validateResponsesTools(responsesReq.tools);\n if (validationError) {\n journal.add({\n method: req.method ?? \"POST\",\n path: req.url ?? \"/v1/responses\",\n headers: flattenHeaders(req.headers),\n body: responsesReq,\n response: { status: 400, fixture: null },\n });\n writeErrorResponse(\n res,\n 400,\n JSON.stringify({ error: { message: validationError, type: \"invalid_request_error\" } }),\n );\n return;\n }\n\n // Convert to ChatCompletionRequest for fixture matching\n const extendedTools = defaults.responsesTools === \"extended\";\n const completionReq = responsesToCompletionRequest(responsesReq, {\n extended: extendedTools,\n logger: defaults.logger,\n });\n completionReq._endpointType = \"chat\";\n completionReq._context = getContext(req);\n\n // Emit a synthetic `reasoning.encrypted_content` only when the request wants it\n // (opted in via `include`, or stateless `store: false` — mirrors real OpenAI).\n // This is what agent-framework-openai >= 1.11.0 sends on stateless-replay\n // requests; without the blob it hard-fails a reasoning + multi-tool chain.\n // See microsoft/agent-framework#7233.\n const emitEncryptedReasoning = requestWantsEncryptedReasoning(responsesReq);\n // Synthesizing a reasoning item the fixture never declared is a bigger step\n // than adding a field to one already being emitted, so it takes the NARROWER\n // explicit-`include` gate: a `store: false` request with a summary-less fixture\n // keeps emitting no reasoning item at all. See\n // `shouldSynthesizeBlobOnlyReasoning`.\n const synthesizeSummarylessReasoning = requestIncludesEncryptedReasoning(responsesReq);\n\n const testId = getTestId(req);\n const { fixture, skippedBySequenceOrTurn } = matchFixtureDiagnostic(\n fixtures,\n completionReq,\n journal.getFixtureMatchCountsForTest(testId),\n defaults.requestTransform,\n // Record mode proxies on a miss to capture a fresh turn (see record gate\n // below), so keep turnIndex strict to prevent an earlier-turn fixture from\n // shadowing a longer request and skipping the new turn's recording.\n recordMatchOptions(!!defaults.record, defaults.logger),\n );\n\n if (fixture) {\n defaults.logger.debug(\n `Responses fixture matched for ${req.method ?? \"POST\"} ${req.url ?? \"/v1/responses\"}`,\n );\n journal.incrementFixtureMatchCount(fixture, fixtures, testId);\n } else {\n defaults.logger.debug(\n `No responses fixture matched for ${req.method ?? \"POST\"} ${req.url ?? \"/v1/responses\"}`,\n );\n }\n\n if (\n await applyChaosAsync(\n res,\n fixture,\n defaults.chaos,\n req.headers,\n req.url,\n journal,\n {\n method: req.method ?? \"POST\",\n path: req.url ?? \"/v1/responses\",\n headers: flattenHeaders(req.headers),\n body: completionReq,\n },\n fixture ? \"fixture\" : \"proxy\",\n defaults.registry,\n defaults.logger,\n )\n )\n return;\n\n if (!fixture) {\n const effectiveStrict = resolveStrictMode(defaults.strict, req.headers);\n if (effectiveStrict) {\n const strictStatus = 503;\n const strictMessage = strictNoMatchMessage(skippedBySequenceOrTurn);\n defaults.logger.error(\n strictNoMatchLogLine(\n req.method ?? \"POST\",\n req.url ?? \"/v1/responses\",\n skippedBySequenceOrTurn,\n ),\n );\n journal.add({\n method: req.method ?? \"POST\",\n path: req.url ?? \"/v1/responses\",\n headers: flattenHeaders(req.headers),\n body: completionReq,\n response: {\n status: strictStatus,\n fixture: null,\n ...strictOverrideField(defaults.strict, req.headers),\n },\n });\n writeErrorResponse(\n res,\n strictStatus,\n JSON.stringify({\n error: {\n message: strictMessage,\n type: \"invalid_request_error\",\n code: \"no_fixture_match\",\n },\n }),\n );\n return;\n }\n if (defaults.record) {\n const outcome = await proxyAndRecord(\n req,\n res,\n completionReq,\n \"openai\",\n req.url ?? \"/v1/responses\",\n fixtures,\n defaults,\n raw,\n );\n if (outcome === \"handled_by_hook\") return;\n if (outcome !== \"not_configured\") {\n journal.add({\n method: req.method ?? \"POST\",\n path: req.url ?? \"/v1/responses\",\n headers: flattenHeaders(req.headers),\n body: completionReq,\n response: { status: res.statusCode ?? 200, fixture: null, source: \"proxy\" },\n });\n return;\n }\n }\n journal.add({\n method: req.method ?? \"POST\",\n path: req.url ?? \"/v1/responses\",\n headers: flattenHeaders(req.headers),\n body: completionReq,\n response: {\n status: 404,\n fixture: null,\n ...strictOverrideField(defaults.strict, req.headers),\n },\n });\n writeErrorResponse(\n res,\n 404,\n JSON.stringify({\n error: {\n message: \"No fixture matched\",\n type: \"invalid_request_error\",\n code: \"no_fixture_match\",\n },\n }),\n );\n return;\n }\n\n // Without responsesTools \"extended\", a namespace on a toolCalls entry or a\n // toolCall block is not emitted, as in earlier releases.\n const resolvedResponse = await resolveResponse(fixture, completionReq);\n const response = extendedTools ? resolvedResponse : withoutLegacyNamespaces(resolvedResponse);\n const misbehavior = planMisbehavior({\n wire: \"openai-responses\",\n fixture,\n response,\n request: completionReq,\n stream: responsesReq.stream === true,\n emitsToolCallIds: true,\n defaults,\n rawHeaders: req.headers,\n url: req.url,\n });\n if (misbehavior.kind === \"error\") {\n const entry = journal.add({\n method: req.method ?? \"POST\",\n path: req.url ?? \"/v1/responses\",\n headers: flattenHeaders(req.headers),\n body: completionReq,\n response: { status: misbehavior.status, fixture },\n });\n recordMisbehaviorOutcome({ entry, summary: misbehavior.summary, defaults, testId });\n if (!misbehavior.summary?.evaluations.some((evaluation) => evaluation.outcome === \"error\")) {\n defaults.logger.error(misbehavior.message);\n }\n writeErrorResponse(\n res,\n misbehavior.status,\n JSON.stringify({\n error: {\n message: misbehavior.message,\n type: \"invalid_request_error\",\n code: misbehavior.code,\n },\n }),\n );\n return;\n }\n\n const latency = fixture.latency ?? defaults.latency;\n const chunkSize = Math.max(1, fixture.chunkSize ?? defaults.chunkSize);\n const fixtureTimings = fixture.recordedTimings;\n const effectiveReplaySpeed = fixture.replaySpeed ?? defaults.replaySpeed;\n\n if (misbehavior.kind === \"applied\") {\n const prepared = prepareResponsesMisbehavior(misbehavior);\n const output = buildResponsesMisbehavior(\n prepared,\n completionReq,\n chunkSize,\n emitEncryptedReasoning,\n );\n const entry = journal.add({\n method: req.method ?? \"POST\",\n path: req.url ?? \"/v1/responses\",\n headers: flattenHeaders(req.headers),\n body: completionReq,\n response: { status: 200, fixture },\n });\n recordMisbehaviorOutcome({ entry, summary: prepared.summary, defaults, testId });\n if (responsesReq.stream !== true) {\n res.writeHead(200, { \"Content-Type\": \"application/json\" });\n res.end(JSON.stringify(output.response));\n } else {\n const appliedTimings =\n prepared.duplicateId && fixtureTimings\n ? { ...fixtureTimings, interChunkDelaysMs: [...fixtureTimings.interChunkDelaysMs] }\n : fixtureTimings;\n if (prepared.duplicateId && appliedTimings) {\n const lastGap = appliedTimings.interChunkDelaysMs.at(-1) ?? 0;\n while (appliedTimings.interChunkDelaysMs.length < output.events.length - 1) {\n appliedTimings.interChunkDelaysMs.push(lastGap);\n }\n }\n const interruption = createInterruptionSignal(fixture);\n const completed = await writeResponsesSSEStream(res, output.events, {\n latency,\n streamingProfile: fixture.streamingProfile,\n recordedTimings: appliedTimings,\n replaySpeed: effectiveReplaySpeed,\n signal: interruption?.signal,\n onChunkSent: interruption?.tick,\n });\n if (!completed) {\n if (!res.writableEnded) res.destroy();\n entry.response.interrupted = true;\n entry.response.interruptReason = interruption?.reason();\n }\n interruption?.cleanup();\n }\n return;\n }\n\n // Error response\n if (isErrorResponse(response)) {\n const status = response.status ?? 500;\n const journalEntry = journal.add({\n method: req.method ?? \"POST\",\n path: req.url ?? \"/v1/responses\",\n headers: flattenHeaders(req.headers),\n body: completionReq,\n response: { status, fixture },\n });\n recordMisbehaviorOutcome({\n entry: journalEntry,\n summary: misbehavior.summary,\n defaults,\n testId,\n });\n writeErrorResponse(res, status, serializeErrorResponse(response), {\n retryAfter: response.retryAfter,\n });\n return;\n }\n\n // Combined content + tool calls response\n if (isCombinedFixtureResponse(response)) {\n const overrides = extractOverrides(response);\n // Gate reasoning emission on the requested model's capability (aimock#254).\n const effectiveStrict = resolveStrictMode(defaults.strict, req.headers);\n const effReasoning = resolveReasoningForModel(\n response.reasoning,\n completionReq.model,\n effectiveStrict,\n defaults.logger,\n );\n const journalEntry = journal.add({\n method: req.method ?? \"POST\",\n path: req.url ?? \"/v1/responses\",\n headers: flattenHeaders(req.headers),\n body: completionReq,\n response: { status: 200, fixture },\n });\n recordMisbehaviorOutcome({\n entry: journalEntry,\n summary: misbehavior.summary,\n defaults,\n testId,\n });\n // Resolve the served blocks (responsesBlocks, else legacy blocks) after\n // journaling, where earlier releases' builders resolved them.\n const ordered = resolveServedBlockOutcome(response)?.ordered;\n if (!ordered) assertCustomToolCalls(response);\n const toolCalls = servedToolCalls(response);\n if (responsesReq.stream !== true) {\n const body = buildContentWithToolCallsResponse(\n response.content ?? \"\",\n toolCalls,\n completionReq.model,\n effReasoning,\n response.webSearches,\n overrides,\n ordered,\n emitEncryptedReasoning,\n synthesizeSummarylessReasoning,\n );\n res.writeHead(200, { \"Content-Type\": \"application/json\" });\n res.end(JSON.stringify(body));\n } else {\n const events = contentWithToolCallsStreamEvents(\n response.content ?? \"\",\n toolCalls,\n completionReq.model,\n chunkSize,\n effReasoning,\n response.webSearches,\n overrides,\n ordered,\n emitEncryptedReasoning,\n synthesizeSummarylessReasoning,\n );\n const interruption = createInterruptionSignal(fixture);\n const completed = await writeResponsesSSEStream(res, events, {\n latency,\n streamingProfile: fixture.streamingProfile,\n recordedTimings: fixtureTimings,\n replaySpeed: effectiveReplaySpeed,\n signal: interruption?.signal,\n onChunkSent: interruption?.tick,\n });\n if (!completed) {\n if (!res.writableEnded) res.destroy();\n journalEntry.response.interrupted = true;\n journalEntry.response.interruptReason = interruption?.reason();\n }\n interruption?.cleanup();\n }\n return;\n }\n\n // Text response\n if (isTextResponse(response)) {\n const overrides = extractOverrides(response);\n // Gate reasoning emission on the requested model's capability (aimock#254).\n const effectiveStrict = resolveStrictMode(defaults.strict, req.headers);\n const effReasoning = resolveReasoningForModel(\n response.reasoning,\n completionReq.model,\n effectiveStrict,\n defaults.logger,\n );\n const journalEntry = journal.add({\n method: req.method ?? \"POST\",\n path: req.url ?? \"/v1/responses\",\n headers: flattenHeaders(req.headers),\n body: completionReq,\n response: { status: 200, fixture },\n });\n recordMisbehaviorOutcome({\n entry: journalEntry,\n summary: misbehavior.summary,\n defaults,\n testId,\n });\n if (responsesReq.stream !== true) {\n const body = buildTextResponse(\n response.content,\n completionReq.model,\n effReasoning,\n response.webSearches,\n overrides,\n emitEncryptedReasoning,\n synthesizeSummarylessReasoning,\n );\n res.writeHead(200, { \"Content-Type\": \"application/json\" });\n res.end(JSON.stringify(body));\n } else {\n const events = buildTextStreamEvents(\n response.content,\n completionReq.model,\n chunkSize,\n effReasoning,\n response.webSearches,\n overrides,\n emitEncryptedReasoning,\n synthesizeSummarylessReasoning,\n );\n const interruption = createInterruptionSignal(fixture);\n const completed = await writeResponsesSSEStream(res, events, {\n latency,\n streamingProfile: fixture.streamingProfile,\n recordedTimings: fixtureTimings,\n replaySpeed: effectiveReplaySpeed,\n signal: interruption?.signal,\n onChunkSent: interruption?.tick,\n });\n if (!completed) {\n if (!res.writableEnded) res.destroy();\n journalEntry.response.interrupted = true;\n journalEntry.response.interruptReason = interruption?.reason();\n }\n interruption?.cleanup();\n }\n return;\n }\n\n // Tool call response\n if (isToolCallResponse(response)) {\n const overrides = extractOverrides(response);\n // Gate reasoning emission on the requested model's capability (aimock#254).\n const effectiveStrict = resolveStrictMode(defaults.strict, req.headers);\n const effReasoning = resolveReasoningForModel(\n response.reasoning,\n completionReq.model,\n effectiveStrict,\n defaults.logger,\n );\n const journalEntry = journal.add({\n method: req.method ?? \"POST\",\n path: req.url ?? \"/v1/responses\",\n headers: flattenHeaders(req.headers),\n body: completionReq,\n response: { status: 200, fixture },\n });\n recordMisbehaviorOutcome({\n entry: journalEntry,\n summary: misbehavior.summary,\n defaults,\n testId,\n });\n assertCustomToolCalls(response);\n if (responsesReq.stream !== true) {\n const body = buildToolCallResponse(\n servedToolCalls(response),\n completionReq.model,\n effReasoning,\n response.webSearches,\n overrides,\n emitEncryptedReasoning,\n synthesizeSummarylessReasoning,\n );\n res.writeHead(200, { \"Content-Type\": \"application/json\" });\n res.end(JSON.stringify(body));\n } else {\n const events = toolCallStreamEvents(\n servedToolCalls(response),\n completionReq.model,\n chunkSize,\n effReasoning,\n response.webSearches,\n overrides,\n emitEncryptedReasoning,\n synthesizeSummarylessReasoning,\n );\n const interruption = createInterruptionSignal(fixture);\n const completed = await writeResponsesSSEStream(res, events, {\n latency,\n streamingProfile: fixture.streamingProfile,\n recordedTimings: fixtureTimings,\n replaySpeed: effectiveReplaySpeed,\n signal: interruption?.signal,\n onChunkSent: interruption?.tick,\n });\n if (!completed) {\n if (!res.writableEnded) res.destroy();\n journalEntry.response.interrupted = true;\n journalEntry.response.interruptReason = interruption?.reason();\n }\n interruption?.cleanup();\n }\n return;\n }\n\n // Unknown response type\n const journalEntry = journal.add({\n method: req.method ?? \"POST\",\n path: req.url ?? \"/v1/responses\",\n headers: flattenHeaders(req.headers),\n body: completionReq,\n response: { status: 500, fixture },\n });\n recordMisbehaviorOutcome({ entry: journalEntry, summary: misbehavior.summary, defaults, testId });\n writeErrorResponse(\n res,\n 500,\n JSON.stringify({\n error: { message: \"Fixture response did not match any known type\", type: \"server_error\" },\n }),\n );\n}\n\n/** Prepare call IDs once, retaining the engine's effective blocks and exact served-call metadata. */\nexport function prepareResponsesMisbehavior(plan: MisbehaviorPlan): MisbehaviorPlan {\n return prepareOpenAIChatMisbehavior(plan);\n}\n\n/** Build one faulted payload/event sequence for both HTTP and Responses WebSocket consumers. */\nexport function buildResponsesMisbehavior(\n plan: MisbehaviorPlan,\n request: ChatCompletionRequest,\n chunkSize: number,\n emitEncryptedReasoning = false,\n) {\n const response = plan.response;\n if (\n !(\n isCombinedFixtureResponse(response) ||\n isTextResponse(response) ||\n isToolCallResponse(response)\n )\n ) {\n throw new Error(\"Responses misbehavior requires a prepared chat response\");\n }\n const overrides = extractOverrides(response);\n const reasoning = plan.reasoning ?? (\"reasoning\" in response ? response.reasoning : undefined);\n const webSearches = \"webSearches\" in response ? response.webSearches : undefined;\n const { respId, created, events, prefixOutputItems, nextOutputIndex } = buildResponsePreamble(\n request.model,\n chunkSize,\n reasoning,\n webSearches,\n overrides,\n emitEncryptedReasoning,\n false,\n plan.reasoning !== undefined,\n );\n const output = [...prefixOutputItems];\n let outputIndex = nextOutputIndex;\n const incomplete = plan.stop === \"length\" || plan.stop === \"content_filter\";\n\n if (plan.refusal !== undefined) {\n const id = itemId();\n const part = { type: \"refusal\", refusal: plan.refusal };\n const item = { id, type: \"message\", role: \"assistant\", status: \"completed\", content: [part] };\n const position = { item_id: id, output_index: outputIndex, content_index: 0 };\n events.push(\n {\n type: \"response.output_item.added\",\n output_index: outputIndex,\n item: { ...item, status: \"in_progress\", content: [] },\n },\n { type: \"response.content_part.added\", ...position, part: { type: \"refusal\", refusal: \"\" } },\n );\n for (let i = 0; i < plan.refusal.length; i += chunkSize) {\n events.push({\n type: \"response.refusal.delta\",\n ...position,\n delta: plan.refusal.slice(i, i + chunkSize),\n });\n }\n events.push(\n { type: \"response.refusal.done\", ...position, refusal: plan.refusal },\n { type: \"response.content_part.done\", ...position, part },\n { type: \"response.output_item.done\", output_index: outputIndex, item },\n );\n output.push(item);\n } else if (\n plan.summary.fault !== \"empty-response\" &&\n plan.stop !== \"content_filter\" &&\n plan.reasoning === undefined\n ) {\n const combined = isCombinedFixtureResponse(response);\n // Custom tool calls and namespaces pass through a fault unchanged.\n const outcome = combined ? resolveServedBlockOutcome(response) : undefined;\n const blocks: ResponsesFixtureBlock[] = outcome?.ordered ?? [\n ...(\"content\" in response && typeof response.content === \"string\"\n ? [{ type: \"text\" as const, text: response.content }]\n : []),\n ...(combined || isToolCallResponse(response)\n ? servedToolCalls(response).map(toolCallFixtureBlock)\n : []),\n ];\n let callIndex = 0;\n for (const block of blocks) {\n if (block.type === \"text\") {\n const message = buildMessageOutputEvents(block.text, chunkSize, outputIndex);\n events.push(...message.events);\n output.push(message.msgItem);\n } else {\n const call =\n block.type === \"customToolCall\"\n ? buildCustomToolCallOutputEvents(block, chunkSize, outputIndex)\n : buildFunctionCallOutputEvents(block, chunkSize, outputIndex);\n const cut =\n plan.summary.fault === \"stop-length-mid-tool\" && callIndex === plan.target?.index;\n const item = cut ? { ...call.item, status: \"incomplete\" } : call.item;\n // Live K5 capture retains both done events, with an incomplete call item.\n events.push(\n ...call.events.map((event) =>\n cut && event.type === \"response.output_item.done\" ? { ...event, item } : event,\n ),\n );\n output.push(item);\n callIndex++;\n }\n outputIndex++;\n }\n }\n const usage = resolveOpenAIChatMisbehaviorUsage(plan, request);\n const body = {\n id: respId,\n object: \"response\",\n created_at: created,\n model: overrides?.model ?? request.model,\n status: incomplete ? \"incomplete\" : responsesStatus(overrides?.finishReason, \"completed\"),\n ...(incomplete\n ? {\n incomplete_details: {\n reason: plan.stop === \"content_filter\" ? \"content_filter\" : \"max_output_tokens\",\n },\n }\n : {}),\n output,\n usage: {\n input_tokens: usage.prompt_tokens,\n output_tokens: usage.completion_tokens,\n total_tokens: usage.total_tokens,\n },\n };\n events.push({ type: incomplete ? \"response.incomplete\" : \"response.completed\", response: body });\n return { response: body, events };\n}\n"],"mappings":";;;;;;;;;;;;AAiJA,SAAS,mBAAmB,SAA8D;AACxF,KAAI,CAAC,QAAS,QAAO;AACrB,KAAI,OAAO,YAAY,SAA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MAAM,SAAS,mBACX,gCAAgC,OAAO,WAAW,YAAY,GAC9D,8BAA8B,OAAO,WAAW,YAAY;IAClE,MAAM,MACJ,KAAK,QAAQ,UAAU,0BAA0B,cAAc,KAAK,QAAQ;IAC9E,MAAM,OAAO,MAAM;KAAE,GAAG,KAAK;KAAM,QAAQ;KAAc,GAAG,KAAK;AAEjE,WAAO,KACL,GAAG,KAAK,OAAO,KAAK,UAClB,OAAO,MAAM,SAAS,8BAA8B;KAAE,GAAG;KAAO;KAAM,GAAG,MAC1E,CACF;AACD,WAAO,KAAK,KAAK;AACjB;;AAEF;;;CAGJ,MAAM,QAAQC,kDAAkC,MAAM,QAAQ;CAC9D,MAAM,OAAO;EACX,IAAI;EACJ,QAAQ;EACR,YAAY;EACZ,OAAO,WAAW,SAAS,QAAQ;EACnC,QAAQ,aAAa,eAAe,gBAAgB,WAAW,cAAc,YAAY;EACzF,GAAI,aACA,EACE,oBAAoB,EAClB,QAAQ,KAAK,SAAS,mBAAmB,mBAAmB,qBAC7D,EACF,GACD,EAAE;EACN;EACA,OAAO;GACL,cAAc,MAAM;GACpB,eAAe,MAAM;GACrB,cAAc,MAAM;GACrB;EACF;AACD,QAAO,KAAK;EAAE,MAAM,aAAa,wBAAwB;EAAsB,UAAU;EAAM,CAAC;AAChG,QAAO;EAAE,UAAU;EAAM;EAAQ"}
1
+ {"version":3,"file":"responses.cjs","names":["generateToolCallId","mapResponsesFinish","generateId","renderResponsesUsage","resolveFixtureBlocks","isReasoningModel","calculateDelay","delay","flattenHeaders","renderError","isJsonObject","getContext","getTestId","matchFixtureDiagnostic","recordMatchOptions","applyChaosAsync","resolveRequestDecisions","strictNoMatchMessage","strictNoMatchLogLine","strictOverrideField","proxyAndRecord","resolveResponse","withoutLegacyNamespaces","planMisbehavior","createInterruptionSignal","isErrorResponse","serializeErrorResponse","isCombinedFixtureResponse","extractOverrides","resolveReasoningForModel","resolveServedBlockOutcome","servedToolCalls","isTextResponse","isToolCallResponse","prepareOpenAIChatMisbehavior","toolCallFixtureBlock","resolveOpenAIChatMisbehaviorUsage"],"sources":["../src/responses.ts"],"sourcesContent":["/**\n * OpenAI Responses API support for aimock.\n *\n * Translates incoming /v1/responses requests into the ChatCompletionRequest\n * format used by the fixture router, and converts fixture responses back into\n * the Responses API streaming (or non-streaming) format expected by @ai-sdk/openai.\n */\n\nimport type * as http from \"node:http\";\nimport { randomBytes } from \"node:crypto\";\nimport type {\n ChatCompletionRequest,\n ChatMessage,\n ContentPart,\n CustomToolCall,\n CustomToolDefinition,\n Fixture,\n FixtureBlock,\n FixtureToolCall,\n HandlerDefaults,\n ResponseOverrides,\n ResponsesFixtureBlock,\n StreamingProfile,\n ToolCall,\n ToolDefinition,\n} from \"./types.js\";\nimport type { Logger } from \"./logger.js\";\nimport {\n generateId,\n generateToolCallId,\n resolveFixtureBlocks,\n assertResponsesToolCalls,\n extractOverrides,\n isTextResponse,\n isToolCallResponse,\n isCombinedFixtureResponse,\n isErrorResponse,\n serializeErrorResponse,\n flattenHeaders,\n isJsonObject,\n getTestId,\n resolveResponse,\n resolveReasoningForModel,\n getContext,\n strictNoMatchMessage,\n strictNoMatchLogLine,\n prepareOpenAIChatMisbehavior,\n resolveOpenAIChatMisbehaviorUsage,\n assertCustomToolCalls,\n resolveServedBlockOutcome,\n servedToolCalls,\n toolCallFixtureBlock,\n withoutLegacyNamespaces,\n} from \"./helpers.js\";\nimport type { MisbehaviorPlan } from \"./misbehavior.js\";\nimport { isReasoningModel } from \"./model-utils.js\";\nimport { matchFixtureDiagnostic, recordMatchOptions, setResponsesOfferedTools } from \"./router.js\";\nimport { writeErrorResponse, delay, calculateDelay } from \"./sse-writer.js\";\nimport { createInterruptionSignal } from \"./interruption.js\";\nimport type { RecordedTimings } from \"./types.js\";\nimport type { Journal } from \"./journal.js\";\nimport { applyChaosAsync } from \"./chaos.js\";\nimport { proxyAndRecord } from \"./recorder.js\";\nimport { planMisbehavior, recordMisbehaviorOutcome } from \"./misbehavior.js\";\nimport { render as renderResponsesUsage } from \"./response/usage/codecs/responses.js\";\nimport { mapResponsesFinish } from \"./response/finish.js\";\nimport { resolveRequestDecisions, strictOverrideField } from \"./response/policy.js\";\nimport { renderError } from \"./response/errors.js\";\n\n// ─── Responses API request types ────────────────────────────────────────────\n\nexport interface ResponsesInputItem {\n role?: string;\n type?: string;\n content?: string | ResponsesContentPart[];\n call_id?: string;\n name?: string;\n /** `function_call` / `custom_tool_call`: the namespace of the called tool. */\n namespace?: string;\n arguments?: string;\n /** `custom_tool_call`: the free-text input. */\n input?: string;\n /** `function_call_output` / `custom_tool_call_output`: a string or content parts. */\n output?: string | ResponsesContentPart[];\n /** `additional_tools` / `tool_search_output`: tools made available at this item. */\n tools?: ResponsesToolDef[];\n id?: string;\n}\n\ninterface ResponsesContentPart {\n type: string;\n text?: string;\n}\n\ninterface ResponsesRequest {\n model: string;\n input: string | ResponsesInputItem[];\n instructions?: string;\n tools?: ResponsesToolDef[];\n tool_choice?: string | object;\n stream?: boolean;\n temperature?: number;\n max_output_tokens?: number;\n response_format?: { type: string; [key: string]: unknown };\n // Additional output data requested by the caller, e.g.\n // \"reasoning.encrypted_content\" (gates encrypted-reasoning emission).\n include?: string[];\n // Server-side storage flag. `false` (ZDR / stateless replay) is one of the\n // triggers for encrypted reasoning; see `requestWantsEncryptedReasoning`.\n store?: boolean;\n [key: string]: unknown;\n}\n\ninterface ResponsesFunctionToolDef {\n type: \"function\";\n name: string;\n description?: string;\n parameters?: object;\n strict?: boolean;\n}\n\ninterface ResponsesCustomToolDef {\n type: \"custom\";\n name: string;\n description?: string;\n format?: unknown;\n}\n\ninterface ResponsesNamespaceToolDef {\n type: \"namespace\";\n name: string;\n description?: string;\n tools: Array<ResponsesFunctionToolDef | ResponsesCustomToolDef>;\n}\n\n/**\n * A Responses request tool. `function`, `custom` and `namespace` tools are\n * flattened for matching; any other tool type is accepted and ignored.\n */\nexport type ResponsesToolDef =\n | ResponsesFunctionToolDef\n | ResponsesCustomToolDef\n | ResponsesNamespaceToolDef\n | { type: string; name?: string; [key: string]: unknown };\n\n// ─── Input conversion: Responses → ChatCompletions messages ─────────────────\n\nfunction extractTextContent(content: string | ResponsesContentPart[] | undefined): string {\n if (!content) return \"\";\n if (typeof content === \"string\") return content;\n return content\n .filter((p) => p.type === \"input_text\" || p.type === \"output_text\")\n .map((p) => p.text ?? \"\")\n .join(\"\");\n}\n\n/**\n * A `custom_tool_call_output.output` is a string or a list of content parts\n * (`input_text` / `input_image` / `input_file`). Flatten a list to its\n * concatenated `input_text` text so text matchers such as\n * `toolResultContains` see it.\n *\n * The value comes straight from the request body, so it is read as `unknown`.\n * Like `function_call_output`, a malformed output never fails the request:\n * any other value (null, an object, a number) yields empty text, and list\n * entries that are not `input_text` parts with string text are skipped.\n */\nfunction customToolOutputText(output: unknown): string {\n if (typeof output === \"string\") return output;\n if (!Array.isArray(output)) return \"\";\n return output\n .map((p: unknown) => {\n if (p === null || typeof p !== \"object\") return \"\";\n const part = p as { type?: unknown; text?: unknown };\n return part.type === \"input_text\" && typeof part.text === \"string\" ? part.text : \"\";\n })\n .join(\"\");\n}\n\n/** Options for converting a Responses request into the router's request shape. */\nexport interface ResponsesConversionOptions {\n /**\n * `responsesTools: \"extended\"`: count custom tool call history, keep history\n * namespaces, and offer namespaced, custom and `additional_tools` /\n * `tool_search_output` tools to `toolName` and predicates. Default false:\n * the conversion of earlier releases.\n */\n extended?: boolean;\n /** Receives one warning per malformed tool item dropped in extended mode. */\n logger?: Logger;\n}\n\n/**\n * Convert Responses input items into chat messages for fixture matching. The\n * default is the conversion of earlier releases: `custom_tool_call` and\n * `custom_tool_call_output` items are skipped, and history namespaces are not\n * kept. With `extended`, a custom tool call becomes an assistant message with\n * `custom_tool_calls` (so turn counting sees it), its output becomes a `tool`\n * message (so `hasToolResult` and `toolCallId` see it), and a `function_call`\n * keeps its `namespace`.\n */\nexport function responsesInputToMessages(req: ResponsesRequest, extended = false): ChatMessage[] {\n const messages: ChatMessage[] = [];\n // Track item_reference placeholders so we can upgrade or clean them up\n const itemReferencePlaceholders = new WeakSet<ChatMessage>();\n\n // instructions field → system message\n if (req.instructions) {\n messages.push({ role: \"system\", content: req.instructions });\n }\n\n // The OpenAI Responses API accepts either a plain string or an array of input items.\n // When a string is passed, treat it as a single user message.\n if (typeof req.input === \"string\") {\n messages.push({ role: \"user\", content: req.input });\n return messages;\n }\n\n /** A synthesized call for an output item that has no matching call. */\n const attachSynthesizedCall = (target: ChatMessage, item: ResponsesInputItem): void => {\n const id = item.call_id ?? generateToolCallId();\n if (item.type === \"custom_tool_call_output\") {\n (target.custom_tool_calls ??= []).push({ id, type: \"custom\", name: \"\", input: \"\" });\n } else {\n (target.tool_calls ??= []).push({\n id,\n type: \"function\",\n function: { name: \"\", arguments: \"\" },\n });\n }\n };\n const hasCalls = (m: ChatMessage): boolean =>\n m.tool_calls !== undefined || m.custom_tool_calls !== undefined;\n\n for (const item of req.input) {\n if (item.role === \"system\" || item.role === \"developer\") {\n messages.push({ role: \"system\", content: extractTextContent(item.content) });\n } else if (item.role === \"user\") {\n messages.push({ role: \"user\", content: extractTextContent(item.content) });\n } else if (item.role === \"assistant\") {\n messages.push({ role: \"assistant\", content: extractTextContent(item.content) });\n } else if (item.type === \"function_call\") {\n // Previous assistant tool call — emit as assistant message with tool_calls\n messages.push({\n role: \"assistant\",\n content: null,\n tool_calls: [\n {\n id: item.call_id ?? generateToolCallId(),\n type: \"function\",\n ...(extended && typeof item.namespace === \"string\"\n ? { namespace: item.namespace }\n : {}),\n function: { name: item.name ?? \"\", arguments: item.arguments ?? \"\" },\n },\n ],\n });\n } else if (extended && item.type === \"custom_tool_call\") {\n // Previous assistant custom tool call. The pushed assistant message makes\n // turn counting see the call. A non-string input (malformed history)\n // becomes \"\", the same coercion customToolOutputText applies to a\n // custom output.\n messages.push({\n role: \"assistant\",\n content: null,\n custom_tool_calls: [\n {\n id: item.call_id ?? generateToolCallId(),\n type: \"custom\",\n name: item.name ?? \"\",\n input: typeof item.input === \"string\" ? item.input : \"\",\n ...(typeof item.namespace === \"string\" ? { namespace: item.namespace } : {}),\n },\n ],\n });\n } else if (\n item.type === \"function_call_output\" ||\n (extended && item.type === \"custom_tool_call_output\")\n ) {\n // Bug 1 fix: If there's no preceding assistant message with a matching\n // tool_call for this call_id, synthesize one. This happens when the AI SDK\n // sends [user, item_reference, function_call_output] — the item_reference\n // placeholder (see below) has no tool_calls, so we need a real assistant\n // message with the tool_call for turnIndex counting. In extended mode a\n // custom_tool_call_output is handled the same way, and its synthesized\n // call is a custom one.\n const hasMatchingToolCall = messages.some(\n (m) =>\n m.role === \"assistant\" &&\n (m.tool_calls?.some((tc) => tc.id === item.call_id) ||\n m.custom_tool_calls?.some((tc) => tc.id === item.call_id)),\n );\n if (!hasMatchingToolCall) {\n // Check if the last message is an item_reference placeholder — if so,\n // upgrade it to carry the tool_call instead of synthesizing a duplicate.\n const lastMsg = messages[messages.length - 1];\n if (\n lastMsg &&\n lastMsg.role === \"assistant\" &&\n itemReferencePlaceholders.has(lastMsg) &&\n !hasCalls(lastMsg)\n ) {\n lastMsg.content = null;\n attachSynthesizedCall(lastMsg, item);\n itemReferencePlaceholders.delete(lastMsg);\n } else {\n // Multi-fco case: look for a recent assistant with tool_calls that\n // belongs to the same turn. After the first fco upgrades a placeholder,\n // subsequent fco's see [assistant(call_A), tool(call_A)] — the last\n // assistant with tool_calls (right before the trailing tool messages)\n // is the correct target.\n let appended = false;\n for (let k = messages.length - 1; k >= 0; k--) {\n const m = messages[k];\n if (m.role === \"assistant\" && hasCalls(m)) {\n attachSynthesizedCall(m, item);\n appended = true;\n break;\n }\n // Stop scanning if we hit a user message — different turn\n if (m.role === \"user\") break;\n }\n if (!appended) {\n const synthesized: ChatMessage = { role: \"assistant\", content: null };\n attachSynthesizedCall(synthesized, item);\n messages.push(synthesized);\n }\n }\n }\n messages.push({\n role: \"tool\",\n content:\n item.type === \"custom_tool_call_output\"\n ? customToolOutputText(item.output)\n : // function_call_output keeps its handling from earlier releases:\n // an array output passes through as content parts, so text\n // matchers do not see it.\n ((item.output ?? \"\") as string | ContentPart[]),\n tool_call_id: item.call_id,\n });\n } else if (item.type === \"item_reference\") {\n // Bug 6 fix: item_reference items represent prior assistant turns (text\n // or function_call). Push a placeholder so they count in assistantCount.\n // If a subsequent function_call_output arrives, the handler above will\n // upgrade this placeholder to carry tool_calls (avoiding double-count).\n const placeholder: ChatMessage = { role: \"assistant\", content: \"\" };\n itemReferencePlaceholders.add(placeholder);\n messages.push(placeholder);\n } else {\n // Skip local_shell_call, mcp_list_tools, etc. — not needed for fixture\n // matching. Without extended mode this includes custom tool call items.\n }\n }\n\n return messages;\n}\n\n/** The request tools of earlier releases: top-level `function` tools only. */\nfunction responsesToolsToCompletionsTools(\n tools?: ResponsesToolDef[],\n): ToolDefinition[] | undefined {\n if (!tools || tools.length === 0) return undefined;\n return tools\n .filter((t) => t.type === \"function\")\n .map((t) => ({\n type: \"function\" as const,\n function: {\n name: t.name as string,\n description: t.description as string | undefined,\n parameters: (t as { parameters?: object }).parameters,\n },\n }));\n}\n\n/** One Responses `function` or `custom` tool in aimock's normalized form. */\nfunction normalizeResponsesTool(\n tool: unknown,\n namespace?: string,\n): ToolDefinition | CustomToolDefinition | undefined {\n if (tool === null || typeof tool !== \"object\") return undefined;\n const t = tool as Record<string, unknown>;\n const ns = namespace !== undefined ? { namespace } : {};\n if (t.type === \"function\") {\n const fn = t as unknown as ResponsesFunctionToolDef;\n return {\n type: \"function\",\n ...ns,\n function: {\n name: fn.name,\n description: fn.description,\n parameters: fn.parameters,\n },\n };\n }\n if (t.type === \"custom\") {\n const custom = t as unknown as ResponsesCustomToolDef;\n return {\n type: \"custom\",\n name: custom.name,\n ...(custom.description !== undefined ? { description: custom.description } : {}),\n ...ns,\n ...(custom.format !== undefined ? { format: custom.format } : {}),\n };\n }\n return undefined;\n}\n\n/**\n * Input items whose `tools` add to the request's tools:\n * `additional_tools` (Codex responses-lite) and `tool_search_output` (tools\n * loaded by tool search, e.g. Codex's deferred MCP namespaces). Both carry the\n * same function / custom / namespace tool shapes as `req.tools`.\n */\nfunction isToolCarryingItemType(type: unknown): boolean {\n return type === \"additional_tools\" || type === \"tool_search_output\";\n}\n\n/**\n * Why a `namespace` tool cannot be flattened, or undefined when it can: its\n * name is not a non-empty string (OpenAI's `NamespaceToolParam` requires\n * `name` with `minLength: 1`), or its `tools` is not an array.\n */\nfunction namespaceToolProblem(tool: { name?: unknown; tools?: unknown }): string | undefined {\n if (typeof tool.name !== \"string\" || tool.name === \"\") return \"name is not a non-empty string\";\n if (!Array.isArray(tool.tools)) return \"tools is not an array\";\n return undefined;\n}\n\n/**\n * Flatten every Responses tool a request offers, for extended matching and for\n * `toolNamespace`. Sources, in order: `req.tools`, then the `tools` of every\n * `additional_tools` or `tool_search_output` input item, in input order.\n * `namespace` tools contribute one entry per inner function/custom tool, each\n * carrying the namespace; other tool types are ignored.\n *\n * Malformed items never fail the request (earlier releases ignored them): a\n * `namespace` tool without a non-empty string name or with a non-array\n * `tools`, a `null` entry, and a tool-carrying item whose `tools` is not an\n * array are dropped, with a warning when `warn` is given.\n */\nfunction flattenResponsesTools(\n req: ResponsesRequest,\n warn?: (message: string) => void,\n): { tools: ToolDefinition[]; customTools: CustomToolDefinition[]; sourceCount: number } {\n const tools: ToolDefinition[] = [];\n const customTools: CustomToolDefinition[] = [];\n const add = (normalized: ToolDefinition | CustomToolDefinition | undefined) => {\n if (!normalized) return;\n if (normalized.type === \"custom\") customTools.push(normalized);\n else tools.push(normalized);\n };\n const sources: Array<{ tool: unknown; path: string }> = [];\n if (Array.isArray(req.tools)) {\n req.tools.forEach((tool, i) => sources.push({ tool, path: `tools[${i}]` }));\n }\n if (Array.isArray(req.input)) {\n req.input.forEach((item, i) => {\n if (!isToolCarryingItemType(item?.type) || item?.tools === undefined) return;\n if (!Array.isArray(item.tools)) {\n warn?.(`Ignoring input[${i}].tools: not an array`);\n return;\n }\n item.tools.forEach((tool, j) => sources.push({ tool, path: `input[${i}].tools[${j}]` }));\n });\n }\n for (const { tool, path } of sources) {\n const t = tool as { type?: unknown; name?: unknown; tools?: unknown } | null;\n if (t === null) {\n warn?.(`Ignoring ${path}: null tool`);\n continue;\n }\n if (t?.type === \"namespace\") {\n const problem = namespaceToolProblem(t);\n if (problem) {\n warn?.(`Ignoring namespace tool ${path}: ${problem}`);\n continue;\n }\n (t.tools as unknown[]).forEach((inner, k) => {\n if (inner === null) warn?.(`Ignoring ${path}.tools[${k}]: null tool`);\n else add(normalizeResponsesTool(inner, t.name as string));\n });\n continue;\n }\n add(normalizeResponsesTool(tool));\n }\n return { tools, customTools, sourceCount: sources.length };\n}\n\nexport function responsesToCompletionRequest(\n req: ResponsesRequest,\n options: ResponsesConversionOptions = {},\n): ChatCompletionRequest {\n const extended = options.extended === true;\n const all = flattenResponsesTools(\n req,\n extended && options.logger\n ? (message) => options.logger?.warn(`Responses request: ${message}`)\n : undefined,\n );\n const completionReq: ChatCompletionRequest = {\n model: req.model,\n messages: responsesInputToMessages(req, extended),\n stream: req.stream,\n temperature: req.temperature,\n max_tokens: req.max_output_tokens,\n tools: extended\n ? all.sourceCount > 0\n ? all.tools\n : undefined\n : responsesToolsToCompletionsTools(req.tools),\n ...(extended && all.customTools.length > 0 ? { customTools: all.customTools } : {}),\n tool_choice: req.tool_choice,\n response_format: req.response_format,\n };\n setResponsesOfferedTools(completionReq, { tools: all.tools, customTools: all.customTools });\n return completionReq;\n}\n\n/**\n * The HTTP request check of earlier releases for `tools`: keep the\n * converter's empty/falsy bypass, and reject only a collection the legacy\n * converter would throw on (not an array, or a `null` entry). Malformed\n * nested tools (inside a `namespace` tool or a tool-carrying input item) are\n * dropped by the conversion instead.\n */\nexport function validateResponsesTools(tools: unknown): string | undefined {\n if (tools && (tools as { length?: unknown }).length !== 0) {\n if (!Array.isArray(tools)) return \"tools must be an array\";\n if (tools.some((tool) => tool === null)) return \"tools entries must not be null\";\n }\n return undefined;\n}\n\n// ─── Response building: fixture → Responses API format ──────────────────────\n\nfunction responsesStatus(finishReason: string | undefined, defaultStatus: string): string {\n if (!finishReason) return defaultStatus;\n return mapResponsesFinish(finishReason);\n}\n\nfunction responseId(): string {\n return generateId(\"resp\");\n}\n\nfunction itemId(): string {\n return generateId(\"msg\");\n}\n\n// Streaming events for Responses API\n\nexport interface ResponsesSSEEvent {\n type: string;\n [key: string]: unknown;\n}\n\nexport function buildTextStreamEvents(\n content: string,\n model: string,\n chunkSize: number,\n reasoning?: string,\n webSearches?: string[],\n overrides?: ResponseOverrides,\n emitEncryptedReasoning = false,\n synthesizeSummarylessReasoning = false,\n): ResponsesSSEEvent[] {\n const { respId, created, events, prefixOutputItems, nextOutputIndex } = buildResponsePreamble(\n model,\n chunkSize,\n reasoning,\n webSearches,\n overrides,\n emitEncryptedReasoning,\n synthesizeSummarylessReasoning,\n );\n\n const { events: msgEvents, msgItem } = buildMessageOutputEvents(\n content,\n chunkSize,\n nextOutputIndex,\n overrides?.phase,\n );\n events.push(...msgEvents);\n\n events.push({\n type: \"response.completed\",\n response: {\n id: respId,\n object: \"response\",\n created_at: created,\n model: overrides?.model ?? model,\n status: responsesStatus(overrides?.finishReason, \"completed\"),\n output: [...prefixOutputItems, msgItem],\n usage: renderResponsesUsage(overrides),\n },\n });\n\n return events;\n}\n\nfunction requireFixtureToolArguments(value: unknown): string {\n if (typeof value !== \"string\") {\n throw new Error('Invalid fixture tool call: \"arguments\" must be a string after normalization');\n }\n return value;\n}\n\nfunction requireFixtureToolInput(value: unknown): string {\n if (typeof value !== \"string\") {\n throw new Error('Invalid fixture tool call: \"input\" must be a string for a custom tool call');\n }\n return value;\n}\n\n/**\n * A tool call to emit: a `toolCalls` entry, or a normalized `toolCall` /\n * `customToolCall` block passed through as-is.\n */\ntype EmittableToolCall = FixtureToolCall | Exclude<ResponsesFixtureBlock, { type: \"text\" }>;\n\nfunction isCustomEmittable(\n call: EmittableToolCall,\n): call is CustomToolCall | Extract<ResponsesFixtureBlock, { type: \"customToolCall\" }> {\n // A non-object entry (only reachable from an untyped fixture) takes the\n // function path, which fails on it exactly as earlier releases did.\n if (call === null || typeof call !== \"object\") return false;\n return call.type === \"custom\" || call.type === \"customToolCall\";\n}\n\n/**\n * A Responses `function_call` item. `namespace` is added only when the fixture\n * sets it, so a call without one keeps the keys and key order it had before\n * namespaces existed (existing fixtures stay byte-identical on the wire).\n */\nfunction functionCallItem(\n call: { name: string; namespace?: string },\n fcId: string,\n callId: string,\n args: string,\n status: \"in_progress\" | \"completed\",\n): Record<string, unknown> {\n return {\n type: \"function_call\",\n id: fcId,\n call_id: callId,\n ...(call.namespace !== undefined ? { namespace: call.namespace } : {}),\n name: call.name,\n arguments: args,\n status,\n };\n}\n\n/**\n * `ctc_…` item id, the prefix the OpenAI guide and Codex's item-id map use for\n * custom tool calls. The underscore separator is deliberate: it matches the\n * real id format, so this does not use `generateId` (which would give\n * `ctc-…`, like aimock's own `fc-…` ids).\n */\nfunction customToolCallItemId(): string {\n return `ctc_${randomBytes(12).toString(\"base64url\")}`;\n}\n\n/** A Responses `custom_tool_call` item; `namespace` is added only when set. */\nfunction customToolCallItem(\n call: { name: string; namespace?: string },\n ctcId: string,\n callId: string,\n input: string,\n status: \"in_progress\" | \"completed\",\n): Record<string, unknown> {\n return {\n type: \"custom_tool_call\",\n id: ctcId,\n call_id: callId,\n ...(call.namespace !== undefined ? { namespace: call.namespace } : {}),\n name: call.name,\n input,\n status,\n };\n}\n\n/**\n * A `toolCalls` entry as earlier releases served it: a function call whose\n * `type`, `input` and `namespace` are ignored. The exported builders take\n * fixtures in that form; the handler passes `namespace` (extended mode) and\n * custom calls to the internal builders instead.\n */\nfunction legacyFunctionCall(call: ToolCall): FixtureToolCall {\n if (call === null || typeof call !== \"object\") return call;\n const { name, arguments: args, id } = call;\n return id !== undefined ? { name, arguments: args, id } : { name, arguments: args };\n}\n\n/**\n * The exported builders' `toolCalls` as legacy function calls. It walks\n * `toolCalls` by index up to `toolCalls.length`, as earlier releases did, so an\n * untyped caller's non-array value gives the same calls: none for an object\n * without `length`, and entries by index for a string or array-like.\n */\nfunction legacyFunctionCalls(toolCalls: ToolCall[]): FixtureToolCall[] {\n const calls: FixtureToolCall[] = [];\n for (let idx = 0; idx < toolCalls.length; idx++) {\n calls.push(legacyFunctionCall(toolCalls[idx]));\n }\n return calls;\n}\n\n/** Resolve exported-builder `blocks` as earlier releases did (no namespace emitted). */\nfunction legacyOrderedBlocks(\n blocks: FixtureBlock[] | undefined,\n): ResponsesFixtureBlock[] | undefined {\n if (!blocks || blocks.length === 0) return undefined;\n return resolveFixtureBlocks(blocks).map((block) => {\n if (block.type === \"text\" || block.namespace === undefined) return block;\n const copy = { ...block };\n delete copy.namespace;\n return copy;\n });\n}\n\nexport function buildToolCallStreamEvents(\n toolCalls: ToolCall[],\n model: string,\n chunkSize: number,\n reasoning?: string,\n webSearches?: string[],\n overrides?: ResponseOverrides,\n emitEncryptedReasoning = false,\n synthesizeSummarylessReasoning = false,\n): ResponsesSSEEvent[] {\n return toolCallStreamEvents(\n legacyFunctionCalls(toolCalls),\n model,\n chunkSize,\n reasoning,\n webSearches,\n overrides,\n emitEncryptedReasoning,\n synthesizeSummarylessReasoning,\n );\n}\n\nexport function toolCallStreamEvents(\n toolCalls: FixtureToolCall[],\n model: string,\n chunkSize: number,\n reasoning?: string,\n webSearches?: string[],\n overrides?: ResponseOverrides,\n emitEncryptedReasoning = false,\n synthesizeSummarylessReasoning = false,\n): ResponsesSSEEvent[] {\n assertResponsesToolCalls(toolCalls);\n const { respId, created, events, prefixOutputItems, nextOutputIndex } = buildResponsePreamble(\n model,\n chunkSize,\n reasoning,\n webSearches,\n overrides,\n emitEncryptedReasoning,\n synthesizeSummarylessReasoning,\n );\n\n const fcOutputItems: object[] = [];\n\n for (let idx = 0; idx < toolCalls.length; idx++) {\n const { events: callEvents, item } = buildToolCallOutputEvents(\n toolCalls[idx],\n chunkSize,\n nextOutputIndex + idx,\n );\n events.push(...callEvents);\n fcOutputItems.push(item);\n }\n\n // response.completed\n events.push({\n type: \"response.completed\",\n response: {\n id: respId,\n object: \"response\",\n created_at: created,\n model: overrides?.model ?? model,\n status: responsesStatus(overrides?.finishReason, \"completed\"),\n output: [...prefixOutputItems, ...fcOutputItems],\n usage: renderResponsesUsage(overrides),\n },\n });\n\n return events;\n}\n\n/**\n * Whether the incoming Responses request should receive encrypted reasoning.\n *\n * Two observed triggers, gated on EITHER:\n * - `include: [\"reasoning.encrypted_content\"]` — the explicit opt-in, and what\n * `agent-framework-openai` >= 1.11.0 auto-appends on its stateless-replay path\n * (it never sends `store`), so this is the branch that fires for real clients.\n * - `store: false` — captured responses carry the blob when not server-side\n * stored (ZDR) and omit it when stored; kept as a secondary trigger for\n * clients that go stateless without opting in via `include`.\n *\n * Stored / opted-out replays stay byte-identical. Exported so the WebSocket\n * Responses transport can share one gate.\n */\nexport function requestWantsEncryptedReasoning(req: ResponsesRequest): boolean {\n if (requestIncludesEncryptedReasoning(req)) return true;\n return req.store === false;\n}\n\n/**\n * Whether the request carries the EXPLICIT `include` opt-in — a strictly\n * narrower gate than `requestWantsEncryptedReasoning`, which also fires on\n * `store: false`.\n *\n * This is the gate for SYNTHESIZING a reasoning item that the fixture does not\n * declare (see `shouldSynthesizeBlobOnlyReasoning`), and it is deliberately the\n * narrow one. Attaching a field to an item aimock was already emitting is a much\n * smaller step than conjuring a whole output item that did not previously exist,\n * so the larger behavior change gets the gate that is directly observable in the\n * request rather than the inferred `store: false` one. `agent-framework-openai`\n * >= 1.11.0 auto-appends `include` on its stateless-replay path and never sends\n * `store` at all, so the motivating client is fully served by this branch — the\n * narrowing costs the feature nothing.\n *\n * Exported so the WebSocket Responses transport shares one gate.\n */\nexport function requestIncludesEncryptedReasoning(req: ResponsesRequest): boolean {\n const include = req.include;\n return Array.isArray(include) && include.includes(\"reasoning.encrypted_content\");\n}\n\n/**\n * Synthetic stand-in for OpenAI's opaque `reasoning.encrypted_content`. aimock\n * has no real ciphertext; it emits a base64 placeholder derived from the\n * reasoning id (stable for a given item, opaque like the real field). Consumers\n * store it (e.g. as agent-framework `protected_data`) and replay it verbatim;\n * aimock matches on content and ignores the echoed blob. Without it,\n * agent-framework-openai >= 1.11.0 hard-fails a reasoning + multi-tool chain on\n * the follow-up request. See microsoft/agent-framework#7233.\n *\n * aimock skips inbound reasoning items entirely, so it cannot reproduce\n * OpenAI's `invalid_encrypted_content` rejection of a mismatched blob/id — a\n * known replay-only limitation.\n */\nfunction syntheticEncryptedReasoning(reasoningId: string): string {\n return Buffer.from(`aimock-encrypted-reasoning:${reasoningId}`).toString(\"base64\");\n}\n\n/**\n * Build a Responses `reasoning` output item. `summaryText` controls the summary\n * (present for the terminal `done` / non-streaming item, omitted for the\n * in-progress `added` item); `emitEncrypted` controls the blob INDEPENDENTLY of\n * the summary, so a blob with an empty summary is expressible. aimock emits the\n * blob only on the terminal item and omits it on `added`: real OpenAI populates\n * `added` opportunistically, but the field is `anyOf: [string, null]` and\n * non-required, so consumers should read it at `done` and treat `added` as\n * best-effort — omitting there is legal and harmless.\n */\nfunction buildReasoningOutputItem(\n reasoningId: string,\n opts: { summaryText?: string; emitEncrypted?: boolean } = {},\n): Record<string, unknown> {\n const item: Record<string, unknown> = {\n type: \"reasoning\",\n id: reasoningId,\n summary:\n opts.summaryText === undefined ? [] : [{ type: \"summary_text\", text: opts.summaryText }],\n };\n if (opts.emitEncrypted) {\n item.encrypted_content = syntheticEncryptedReasoning(reasoningId);\n }\n return item;\n}\n\n/**\n * Whether to synthesize a summary-LESS reasoning item that exists purely to\n * carry the encrypted blob.\n *\n * Every reasoning item aimock emits otherwise originates in a fixture's declared\n * `reasoning` summary text. But a fixture RECORDED from the real stateless\n * agent-framework flow typically has NO summary — OpenAI returns `summary: []`\n * unless summaries are explicitly requested — so keying the item on a declared\n * summary starves the exact flow this feature exists to serve: fully opted in,\n * yet no reasoning item and therefore no blob. Real OpenAI, for a\n * reasoning-capable model, still returns a reasoning item (`summary: []`) with\n * the blob populated. So synthesize one, gated on:\n *\n * - the EXPLICIT `include` opt-in ONLY (`requestIncludesEncryptedReasoning`),\n * which is NARROWER than the `requestWantsEncryptedReasoning` gate that\n * controls the blob itself. A `store: false` request whose fixture declares no\n * summary therefore gets NO reasoning item, exactly as before this change.\n * Two reasons: (1) creating an output item that did not previously exist is a\n * bigger behavior change than adding a field to an item already being\n * emitted, so it earns the gate that is directly observable in the request\n * rather than the inferred one; (2) the `store: false` trigger's supporting\n * capture evidence is not verifiable from this repo, and a larger change must\n * not be stacked on an unverifiable premise. `agent-framework-openai` >=\n * 1.11.0 sends `include` and never `store`, so nothing is lost.\n * - the REQUESTED model's reasoning capability (aimock#254) — emitting a\n * reasoning item for gpt-4o would be LESS faithful, not more, since that\n * model has no reasoning channel at all. Unlike `resolveReasoningForModel`,\n * which fails open for a declared summary (a recorded summary is evidence the\n * model did reason), there is nothing to preserve here: a synthesized item on\n * a non-reasoning model would be pure fabrication, so this gate is hard.\n *\n * Note this is INDEPENDENT of `emitEncryptedReasoning`: when a fixture DOES\n * declare a summary, the blob still rides on it under either trigger (including\n * `store: false`), unchanged.\n */\nfunction shouldSynthesizeBlobOnlyReasoning(\n reasoning: string | undefined,\n model: string | undefined,\n synthesizeSummarylessReasoning: boolean,\n): boolean {\n if (reasoning) return false; // a declared summary already produces the item\n if (!synthesizeSummarylessReasoning) return false; // no explicit `include` opt-in\n return isReasoningModel(model);\n}\n\n/**\n * `reasoning` is `undefined` for a synthesized blob-only item (see\n * `shouldSynthesizeBlobOnlyReasoning`). In that case the item's `summary` is\n * `[]`, so the summary-part / summary-text events are SKIPPED entirely — they\n * would describe a part that does not exist on the item — leaving a coherent\n * `output_item.added` → `output_item.done` pair with nothing between.\n */\nfunction buildReasoningStreamEvents(\n reasoning: string | undefined,\n chunkSize: number,\n emitEncryptedReasoning = false,\n): ResponsesSSEEvent[] {\n const reasoningId = generateId(\"rs\");\n const events: ResponsesSSEEvent[] = [];\n\n events.push({\n type: \"response.output_item.added\",\n output_index: 0,\n item: buildReasoningOutputItem(reasoningId),\n });\n\n if (reasoning !== undefined) {\n events.push({\n type: \"response.reasoning_summary_part.added\",\n item_id: reasoningId,\n output_index: 0,\n summary_index: 0,\n part: { type: \"summary_text\", text: \"\" },\n });\n\n for (let i = 0; i < reasoning.length; i += chunkSize) {\n const slice = reasoning.slice(i, i + chunkSize);\n events.push({\n type: \"response.reasoning_summary_text.delta\",\n item_id: reasoningId,\n output_index: 0,\n summary_index: 0,\n delta: slice,\n });\n }\n\n events.push({\n type: \"response.reasoning_summary_text.done\",\n item_id: reasoningId,\n output_index: 0,\n summary_index: 0,\n text: reasoning,\n });\n\n events.push({\n type: \"response.reasoning_summary_part.done\",\n item_id: reasoningId,\n output_index: 0,\n summary_index: 0,\n part: { type: \"summary_text\", text: reasoning },\n });\n }\n\n events.push({\n type: \"response.output_item.done\",\n output_index: 0,\n item: buildReasoningOutputItem(reasoningId, {\n summaryText: reasoning,\n emitEncrypted: emitEncryptedReasoning,\n }),\n });\n\n return events;\n}\n\nfunction buildWebSearchStreamEvents(\n queries: string[],\n startOutputIndex: number,\n): ResponsesSSEEvent[] {\n const events: ResponsesSSEEvent[] = [];\n\n for (let i = 0; i < queries.length; i++) {\n const searchId = generateId(\"ws\");\n const outputIndex = startOutputIndex + i;\n\n events.push({\n type: \"response.output_item.added\",\n output_index: outputIndex,\n item: {\n type: \"web_search_call\",\n id: searchId,\n status: \"in_progress\",\n action: { type: \"search\", query: queries[i] },\n },\n });\n\n events.push({\n type: \"response.output_item.done\",\n output_index: outputIndex,\n item: {\n type: \"web_search_call\",\n id: searchId,\n status: \"completed\",\n action: { type: \"search\", query: queries[i] },\n },\n });\n }\n\n return events;\n}\n\n// ─── Shared streaming helpers ────────────────────────────────────────────────\n\ninterface PreambleResult {\n respId: string;\n created: number;\n events: ResponsesSSEEvent[];\n prefixOutputItems: object[];\n nextOutputIndex: number;\n}\n\nfunction buildResponsePreamble(\n model: string,\n chunkSize: number,\n reasoning?: string,\n webSearches?: string[],\n overrides?: ResponseOverrides,\n emitEncryptedReasoning = false,\n synthesizeSummarylessReasoning = false,\n forceReasoning = false,\n): PreambleResult {\n const respId = overrides?.id ?? responseId();\n const created = overrides?.created ?? Math.floor(Date.now() / 1000);\n const effectiveModel = overrides?.model ?? model;\n const events: ResponsesSSEEvent[] = [];\n const prefixOutputItems: object[] = [];\n let nextOutputIndex = 0;\n\n events.push({\n type: \"response.created\",\n response: {\n id: respId,\n object: \"response\",\n created_at: created,\n model: effectiveModel,\n status: \"in_progress\",\n output: [],\n },\n });\n events.push({\n type: \"response.in_progress\",\n response: {\n id: respId,\n object: \"response\",\n created_at: created,\n model: effectiveModel,\n status: \"in_progress\",\n output: [],\n },\n });\n\n if (\n reasoning ||\n forceReasoning ||\n shouldSynthesizeBlobOnlyReasoning(reasoning, model, synthesizeSummarylessReasoning)\n ) {\n const reasoningEvents = buildReasoningStreamEvents(\n reasoning,\n chunkSize,\n emitEncryptedReasoning,\n );\n events.push(...reasoningEvents);\n const doneEvent = reasoningEvents.find(\n (e) =>\n e.type === \"response.output_item.done\" &&\n (e.item as { type: string })?.type === \"reasoning\",\n );\n if (doneEvent) prefixOutputItems.push(doneEvent.item as object);\n nextOutputIndex++;\n }\n\n if (webSearches && webSearches.length > 0) {\n const searchEvents = buildWebSearchStreamEvents(webSearches, nextOutputIndex);\n events.push(...searchEvents);\n const doneEvents = searchEvents.filter(\n (e) =>\n e.type === \"response.output_item.done\" &&\n (e.item as { type: string })?.type === \"web_search_call\",\n );\n for (const de of doneEvents) prefixOutputItems.push(de.item as object);\n nextOutputIndex += webSearches.length;\n }\n\n return { respId, created, events, prefixOutputItems, nextOutputIndex };\n}\n\ninterface MessageBlockResult {\n events: ResponsesSSEEvent[];\n msgItem: object;\n}\n\nfunction buildMessageOutputEvents(\n content: string,\n chunkSize: number,\n outputIndex: number,\n phase?: ResponseOverrides[\"phase\"],\n): MessageBlockResult {\n const msgId = itemId();\n const events: ResponsesSSEEvent[] = [];\n\n events.push({\n type: \"response.output_item.added\",\n output_index: outputIndex,\n item: {\n type: \"message\",\n id: msgId,\n status: \"in_progress\",\n role: \"assistant\",\n ...(phase !== undefined ? { phase } : {}),\n content: [],\n },\n });\n events.push({\n type: \"response.content_part.added\",\n item_id: msgId,\n output_index: outputIndex,\n content_index: 0,\n part: { type: \"output_text\", text: \"\", annotations: [] },\n });\n\n for (let i = 0; i < content.length; i += chunkSize) {\n events.push({\n type: \"response.output_text.delta\",\n item_id: msgId,\n output_index: outputIndex,\n content_index: 0,\n delta: content.slice(i, i + chunkSize),\n });\n }\n\n events.push({\n type: \"response.output_text.done\",\n item_id: msgId,\n output_index: outputIndex,\n content_index: 0,\n text: content,\n });\n events.push({\n type: \"response.content_part.done\",\n item_id: msgId,\n output_index: outputIndex,\n content_index: 0,\n part: { type: \"output_text\", text: content, annotations: [] },\n });\n\n const msgItem = {\n type: \"message\",\n id: msgId,\n status: \"completed\",\n role: \"assistant\",\n ...(phase !== undefined ? { phase } : {}),\n content: [{ type: \"output_text\", text: content, annotations: [] }],\n };\n\n events.push({ type: \"response.output_item.done\", output_index: outputIndex, item: msgItem });\n\n return { events, msgItem };\n}\n\n/** One streamed tool-call item: a `function_call` or a `custom_tool_call`. */\ninterface ToolCallBlockResult {\n events: ResponsesSSEEvent[];\n item: object;\n}\n\n/**\n * Emit the output_item.added → arguments deltas → arguments.done →\n * output_item.done events for a single function_call at `outputIndex`,\n * returning the completed item for the final `output` array. Every Responses\n * streaming builder (tool-only, legacy content+toolCalls and ordered blocks)\n * reaches this through {@link buildToolCallOutputEvents}, so a given\n * (tool, outputIndex) has the same wire output on every path.\n */\nfunction buildFunctionCallOutputEvents(\n toolCall: { name: string; arguments: string; id?: string; namespace?: string },\n chunkSize: number,\n outputIndex: number,\n): ToolCallBlockResult {\n const callId = toolCall.id || generateToolCallId();\n const fcId = generateId(\"fc\");\n const args = requireFixtureToolArguments(toolCall.arguments);\n const events: ResponsesSSEEvent[] = [];\n\n events.push({\n type: \"response.output_item.added\",\n output_index: outputIndex,\n item: functionCallItem(toolCall, fcId, callId, \"\", \"in_progress\"),\n });\n\n for (let i = 0; i < args.length; i += chunkSize) {\n events.push({\n type: \"response.function_call_arguments.delta\",\n item_id: fcId,\n output_index: outputIndex,\n delta: args.slice(i, i + chunkSize),\n });\n }\n\n events.push({\n type: \"response.function_call_arguments.done\",\n item_id: fcId,\n output_index: outputIndex,\n arguments: args,\n });\n\n const item = functionCallItem(toolCall, fcId, callId, args, \"completed\");\n events.push({ type: \"response.output_item.done\", output_index: outputIndex, item });\n\n return { events, item };\n}\n\n/**\n * `text` cut into slices of at most `chunkSize` UTF-16 units, never between\n * the two halves of a surrogate pair: a cut that would land inside a pair\n * moves back before it, or, when that would leave the slice empty\n * (`chunkSize` 1), forward past it. The slices rejoin to `text` exactly.\n */\nfunction surrogateSafeChunks(text: string, chunkSize: number): string[] {\n const chunks: string[] = [];\n for (let i = 0; i < text.length; ) {\n let end = Math.min(i + chunkSize, text.length);\n const high = text.charCodeAt(end - 1);\n const low = text.charCodeAt(end);\n if (high >= 0xd800 && high <= 0xdbff && low >= 0xdc00 && low <= 0xdfff) {\n end = end - 1 > i ? end - 1 : end + 1;\n }\n chunks.push(text.slice(i, end));\n i = end;\n }\n return chunks;\n}\n\n/**\n * Emit output_item.added → custom_tool_call_input.delta×N →\n * custom_tool_call_input.done → output_item.done for one `custom_tool_call` at\n * `outputIndex`, returning the completed item. An empty `input`\n * yields no delta event.\n */\nfunction buildCustomToolCallOutputEvents(\n call: { name: string; input: string; id?: string; namespace?: string },\n chunkSize: number,\n outputIndex: number,\n): ToolCallBlockResult {\n const callId = call.id || generateToolCallId();\n const ctcId = customToolCallItemId();\n const input = requireFixtureToolInput(call.input);\n const events: ResponsesSSEEvent[] = [];\n\n events.push({\n type: \"response.output_item.added\",\n output_index: outputIndex,\n item: customToolCallItem(call, ctcId, callId, \"\", \"in_progress\"),\n });\n\n for (const delta of surrogateSafeChunks(input, chunkSize)) {\n events.push({\n type: \"response.custom_tool_call_input.delta\",\n item_id: ctcId,\n output_index: outputIndex,\n delta,\n });\n }\n\n events.push({\n type: \"response.custom_tool_call_input.done\",\n item_id: ctcId,\n output_index: outputIndex,\n input,\n });\n\n const item = customToolCallItem(call, ctcId, callId, input, \"completed\");\n events.push({ type: \"response.output_item.done\", output_index: outputIndex, item });\n\n return { events, item };\n}\n\n/** Streaming dispatcher: one function or custom tool call at `outputIndex`. */\nfunction buildToolCallOutputEvents(\n call: EmittableToolCall,\n chunkSize: number,\n outputIndex: number,\n): ToolCallBlockResult {\n return isCustomEmittable(call)\n ? buildCustomToolCallOutputEvents(call, chunkSize, outputIndex)\n : buildFunctionCallOutputEvents(call, chunkSize, outputIndex);\n}\n\n// ─── Non-streaming response builders ────────────────────────────────────────\n\nfunction buildOutputPrefix(\n content: string,\n model: string,\n reasoning?: string,\n webSearches?: string[],\n emitEncryptedReasoning = false,\n synthesizeSummarylessReasoning = false,\n phase?: ResponseOverrides[\"phase\"],\n): object[] {\n const output: object[] = [];\n\n if (\n reasoning ||\n shouldSynthesizeBlobOnlyReasoning(reasoning, model, synthesizeSummarylessReasoning)\n ) {\n output.push(\n buildReasoningOutputItem(generateId(\"rs\"), {\n summaryText: reasoning,\n emitEncrypted: emitEncryptedReasoning,\n }),\n );\n }\n\n if (webSearches && webSearches.length > 0) {\n for (const query of webSearches) {\n output.push({\n type: \"web_search_call\",\n id: generateId(\"ws\"),\n status: \"completed\",\n action: { type: \"search\", query },\n });\n }\n }\n\n output.push({\n type: \"message\",\n id: itemId(),\n status: \"completed\",\n role: \"assistant\",\n ...(phase !== undefined ? { phase } : {}),\n content: [{ type: \"output_text\", text: content, annotations: [] }],\n });\n\n return output;\n}\n\nfunction buildResponseEnvelope(\n model: string,\n output: object[],\n overrides?: ResponseOverrides,\n): object {\n return {\n id: overrides?.id ?? responseId(),\n object: \"response\",\n created_at: overrides?.created ?? Math.floor(Date.now() / 1000),\n model: overrides?.model ?? model,\n status: responsesStatus(overrides?.finishReason, \"completed\"),\n output,\n usage: renderResponsesUsage(overrides),\n };\n}\n\nexport function buildTextResponse(\n content: string,\n model: string,\n reasoning?: string,\n webSearches?: string[],\n overrides?: ResponseOverrides,\n emitEncryptedReasoning = false,\n synthesizeSummarylessReasoning = false,\n): object {\n return buildResponseEnvelope(\n model,\n buildOutputPrefix(\n content,\n model,\n reasoning,\n webSearches,\n emitEncryptedReasoning,\n synthesizeSummarylessReasoning,\n overrides?.phase,\n ),\n overrides,\n );\n}\n\nfunction buildToolCallResponse(\n toolCalls: FixtureToolCall[],\n model: string,\n reasoning?: string,\n webSearches?: string[],\n overrides?: ResponseOverrides,\n emitEncryptedReasoning = false,\n synthesizeSummarylessReasoning = false,\n): object {\n assertResponsesToolCalls(toolCalls);\n const output: object[] = [];\n if (\n reasoning ||\n shouldSynthesizeBlobOnlyReasoning(reasoning, model, synthesizeSummarylessReasoning)\n ) {\n output.push(\n buildReasoningOutputItem(generateId(\"rs\"), {\n summaryText: reasoning,\n emitEncrypted: emitEncryptedReasoning,\n }),\n );\n }\n if (webSearches && webSearches.length > 0) {\n for (const query of webSearches) {\n output.push({\n type: \"web_search_call\",\n id: generateId(\"ws\"),\n status: \"completed\",\n action: { type: \"search\", query },\n });\n }\n }\n for (const tc of toolCalls) {\n output.push(buildToolCallOutputItem(tc));\n }\n return buildResponseEnvelope(model, output, overrides);\n}\n\nexport function buildContentWithToolCallsStreamEvents(\n content: string,\n toolCalls: ToolCall[],\n model: string,\n chunkSize: number,\n reasoning?: string,\n webSearches?: string[],\n overrides?: ResponseOverrides,\n blocks?: FixtureBlock[],\n emitEncryptedReasoning = false,\n synthesizeSummarylessReasoning = false,\n): ResponsesSSEEvent[] {\n const ordered = legacyOrderedBlocks(blocks);\n // With blocks, earlier releases never read `toolCalls`, so neither does this.\n return contentWithToolCallsStreamEvents(\n content,\n ordered && ordered.length > 0 ? [] : legacyFunctionCalls(toolCalls),\n model,\n chunkSize,\n reasoning,\n webSearches,\n overrides,\n ordered,\n emitEncryptedReasoning,\n synthesizeSummarylessReasoning,\n );\n}\n\n/**\n * Internal content+tool-calls builder. `ordered` is already resolved (see\n * {@link resolveServedBlockOutcome}); when non-empty it is streamed in array\n * order, otherwise the legacy message-first path runs over `toolCalls`.\n */\nexport function contentWithToolCallsStreamEvents(\n content: string,\n toolCalls: FixtureToolCall[],\n model: string,\n chunkSize: number,\n reasoning?: string,\n webSearches?: string[],\n overrides?: ResponseOverrides,\n ordered?: ResponsesFixtureBlock[],\n emitEncryptedReasoning = false,\n synthesizeSummarylessReasoning = false,\n): ResponsesSSEEvent[] {\n const { respId, created, events, prefixOutputItems, nextOutputIndex } = buildResponsePreamble(\n model,\n chunkSize,\n reasoning,\n webSearches,\n overrides,\n emitEncryptedReasoning,\n synthesizeSummarylessReasoning,\n );\n\n // The output items assembled in emission order (after any reasoning /\n // web-search prefix items). Each output_index is assigned sequentially as we\n // walk the chosen item order, so the `output_index` on every emitted event\n // matches that item's slot in the final `response.completed.output` array.\n const orderedOutputItems: object[] = [];\n\n if (ordered && ordered.length > 0) {\n // NEW PATH: stream items in the fixture's block ARRAY ORDER. A tool block\n // placed before a text block therefore yields a tool call item at\n // a LOWER output_index than the message — it leads the output array.\n let outputIndex = nextOutputIndex;\n for (const block of ordered) {\n if (block.type === \"text\") {\n const { events: msgEvents, msgItem } = buildMessageOutputEvents(\n block.text,\n chunkSize,\n outputIndex,\n overrides?.phase,\n );\n events.push(...msgEvents);\n orderedOutputItems.push(msgItem);\n } else {\n const { events: callEvents, item } = buildToolCallOutputEvents(\n block,\n chunkSize,\n outputIndex,\n );\n events.push(...callEvents);\n orderedOutputItems.push(item);\n }\n outputIndex += 1;\n }\n } else {\n assertResponsesToolCalls(toolCalls);\n // LEGACY PATH: message item first, then tool call items (function_call or\n // custom_tool_call). The message always leads the output; for fixtures\n // without custom calls or namespaces this is byte-for-byte the pre-blocks\n // output.\n const { events: msgEvents, msgItem } = buildMessageOutputEvents(\n content,\n chunkSize,\n nextOutputIndex,\n overrides?.phase,\n );\n events.push(...msgEvents);\n orderedOutputItems.push(msgItem);\n\n for (let idx = 0; idx < toolCalls.length; idx++) {\n const { events: callEvents, item } = buildToolCallOutputEvents(\n toolCalls[idx],\n chunkSize,\n nextOutputIndex + 1 + idx,\n );\n events.push(...callEvents);\n orderedOutputItems.push(item);\n }\n }\n\n events.push({\n type: \"response.completed\",\n response: {\n id: respId,\n object: \"response\",\n created_at: created,\n model: overrides?.model ?? model,\n status: responsesStatus(overrides?.finishReason, \"completed\"),\n output: [...prefixOutputItems, ...orderedOutputItems],\n usage: renderResponsesUsage(overrides),\n },\n });\n\n return events;\n}\n\n/** Non-streaming dispatcher: the completed function or custom tool call item. */\nfunction buildToolCallOutputItem(tc: EmittableToolCall): object {\n if (isCustomEmittable(tc)) {\n return customToolCallItem(\n tc,\n customToolCallItemId(),\n tc.id || generateToolCallId(),\n requireFixtureToolInput(tc.input),\n \"completed\",\n );\n }\n return functionCallItem(\n tc,\n generateId(\"fc\"),\n tc.id || generateToolCallId(),\n requireFixtureToolArguments(tc.arguments),\n \"completed\",\n );\n}\n\nfunction buildMessageOutputItem(content: string, phase?: ResponseOverrides[\"phase\"]): object {\n return {\n type: \"message\",\n id: itemId(),\n status: \"completed\",\n role: \"assistant\",\n ...(phase !== undefined ? { phase } : {}),\n content: [{ type: \"output_text\", text: content, annotations: [] }],\n };\n}\n\nfunction buildContentWithToolCallsResponse(\n content: string,\n toolCalls: FixtureToolCall[],\n model: string,\n reasoning?: string,\n webSearches?: string[],\n overrides?: ResponseOverrides,\n ordered?: ResponsesFixtureBlock[],\n emitEncryptedReasoning = false,\n synthesizeSummarylessReasoning = false,\n): object {\n if (ordered && ordered.length > 0) {\n // NEW PATH: the non-streaming `output[]` array is positionally observable,\n // so emit the prefix (reasoning / web_search_call), then the blocks in\n // fixture ARRAY ORDER. A tool block before a text block therefore\n // yields a tool call item ahead of the message — matching the streaming\n // path's ordering for the same `blocks` fixture.\n const output: object[] = [];\n if (\n reasoning ||\n shouldSynthesizeBlobOnlyReasoning(reasoning, model, synthesizeSummarylessReasoning)\n ) {\n output.push(\n buildReasoningOutputItem(generateId(\"rs\"), {\n summaryText: reasoning,\n emitEncrypted: emitEncryptedReasoning,\n }),\n );\n }\n if (webSearches && webSearches.length > 0) {\n for (const query of webSearches) {\n output.push({\n type: \"web_search_call\",\n id: generateId(\"ws\"),\n status: \"completed\",\n action: { type: \"search\", query },\n });\n }\n }\n for (const block of ordered) {\n if (block.type === \"text\") {\n output.push(buildMessageOutputItem(block.text, overrides?.phase));\n } else {\n output.push(buildToolCallOutputItem(block));\n }\n }\n return buildResponseEnvelope(model, output, overrides);\n }\n\n // LEGACY PATH: message item first, then tool call items (function_call or\n // custom_tool_call), as before blocks existed.\n assertResponsesToolCalls(toolCalls);\n const output = buildOutputPrefix(\n content,\n model,\n reasoning,\n webSearches,\n emitEncryptedReasoning,\n synthesizeSummarylessReasoning,\n overrides?.phase,\n );\n for (const tc of toolCalls) {\n output.push(buildToolCallOutputItem(tc));\n }\n return buildResponseEnvelope(model, output, overrides);\n}\n\n// ─── SSE writer for Responses API ───────────────────────────────────────────\n\ninterface ResponsesStreamOptions {\n latency?: number;\n streamingProfile?: StreamingProfile;\n recordedTimings?: RecordedTimings;\n replaySpeed?: number;\n signal?: AbortSignal;\n onChunkSent?: () => void;\n}\n\nasync function writeResponsesSSEStream(\n res: http.ServerResponse,\n events: ResponsesSSEEvent[],\n optionsOrLatency?: number | ResponsesStreamOptions,\n): Promise<boolean> {\n const opts: ResponsesStreamOptions =\n typeof optionsOrLatency === \"number\" ? { latency: optionsOrLatency } : (optionsOrLatency ?? {});\n const latency = opts.latency ?? 0;\n const profile = opts.streamingProfile;\n const { recordedTimings, replaySpeed } = opts;\n const signal = opts.signal;\n const onChunkSent = opts.onChunkSent;\n\n if (res.writableEnded) return true;\n res.setHeader(\"Content-Type\", \"text/event-stream\");\n res.setHeader(\"Cache-Control\", \"no-cache\");\n res.setHeader(\"Connection\", \"keep-alive\");\n\n let chunkIndex = 0;\n for (const event of events) {\n const chunkDelay = calculateDelay(chunkIndex, profile, latency, recordedTimings, replaySpeed);\n if (chunkDelay > 0) await delay(chunkDelay, signal);\n if (signal?.aborted) return false;\n if (res.writableEnded) return true;\n res.write(`event: ${event.type}\\ndata: ${JSON.stringify(event)}\\n\\n`);\n onChunkSent?.();\n if (signal?.aborted) return false;\n chunkIndex++;\n }\n\n if (!res.writableEnded) {\n res.end();\n }\n return true;\n}\n\n// ─── Request handler ────────────────────────────────────────────────────────\n\nexport async function handleResponses(\n req: http.IncomingMessage,\n res: http.ServerResponse,\n raw: string,\n fixtures: Fixture[],\n journal: Journal,\n defaults: HandlerDefaults,\n setCorsHeaders: (res: http.ServerResponse) => void,\n): Promise<void> {\n setCorsHeaders(res);\n\n let responsesReq: ResponsesRequest;\n try {\n responsesReq = JSON.parse(raw) as ResponsesRequest;\n } catch (parseErr) {\n const detail = parseErr instanceof Error ? parseErr.message : \"unknown\";\n journal.add({\n method: req.method ?? \"POST\",\n path: req.url ?? \"/v1/responses\",\n headers: flattenHeaders(req.headers),\n body: null,\n response: { status: 400, fixture: null },\n });\n writeErrorResponse(\n res,\n 400,\n renderError(\"openai\", \"validation\", {\n message: `Malformed JSON: ${detail}`,\n type: \"invalid_request_error\",\n code: \"invalid_json\",\n }).body,\n );\n return;\n }\n\n // Reject bodies that parsed but are not a JSON object (e.g. `null`) before\n // touching fields — otherwise `responsesReq.model` throws a TypeError that\n // surfaces as a 500 instead of a 400.\n if (!isJsonObject(responsesReq)) {\n journal.add({\n method: req.method ?? \"POST\",\n path: req.url ?? \"/v1/responses\",\n headers: flattenHeaders(req.headers),\n body: null,\n response: { status: 400, fixture: null },\n });\n writeErrorResponse(\n res,\n 400,\n renderError(\"openai\", \"validation\", {\n message: \"Request body must be a JSON object\",\n type: \"invalid_request_error\",\n }).body,\n );\n return;\n }\n\n // Guard only shapes consumed by input conversion. Other item fields may be\n // intentionally ignored, and falsy message content normalizes to empty text.\n let inputError: string | undefined;\n if (typeof responsesReq.input !== \"string\" && !Array.isArray(responsesReq.input)) {\n inputError = \"input must be a string or an array\";\n } else if (Array.isArray(responsesReq.input)) {\n for (const [index, item] of responsesReq.input.entries()) {\n if (item === null) {\n inputError = `input[${index}] must not be null`;\n break;\n }\n if (\n (item.role === \"system\" ||\n item.role === \"developer\" ||\n item.role === \"user\" ||\n item.role === \"assistant\") &&\n item.content &&\n typeof item.content !== \"string\" &&\n !Array.isArray(item.content)\n ) {\n inputError = `input[${index}].content must be a string or an array`;\n break;\n }\n }\n }\n const validationError = inputError ?? validateResponsesTools(responsesReq.tools);\n if (validationError) {\n journal.add({\n method: req.method ?? \"POST\",\n path: req.url ?? \"/v1/responses\",\n headers: flattenHeaders(req.headers),\n body: responsesReq,\n response: { status: 400, fixture: null },\n });\n writeErrorResponse(\n res,\n 400,\n renderError(\"openai\", \"validation\", {\n message: validationError,\n type: \"invalid_request_error\",\n }).body,\n );\n return;\n }\n\n // Convert to ChatCompletionRequest for fixture matching\n const extendedTools = defaults.responsesTools === \"extended\";\n const completionReq = responsesToCompletionRequest(responsesReq, {\n extended: extendedTools,\n logger: defaults.logger,\n });\n completionReq._endpointType = \"chat\";\n completionReq._context = getContext(req);\n\n // Emit a synthetic `reasoning.encrypted_content` only when the request wants it\n // (opted in via `include`, or stateless `store: false` — mirrors real OpenAI).\n // This is what agent-framework-openai >= 1.11.0 sends on stateless-replay\n // requests; without the blob it hard-fails a reasoning + multi-tool chain.\n // See microsoft/agent-framework#7233.\n const emitEncryptedReasoning = requestWantsEncryptedReasoning(responsesReq);\n // Synthesizing a reasoning item the fixture never declared is a bigger step\n // than adding a field to one already being emitted, so it takes the NARROWER\n // explicit-`include` gate: a `store: false` request with a summary-less fixture\n // keeps emitting no reasoning item at all. See\n // `shouldSynthesizeBlobOnlyReasoning`.\n const synthesizeSummarylessReasoning = requestIncludesEncryptedReasoning(responsesReq);\n\n const testId = getTestId(req);\n const { fixture, skippedBySequenceOrTurn } = matchFixtureDiagnostic(\n fixtures,\n completionReq,\n journal.getFixtureMatchCountsForTest(testId),\n defaults.requestTransform,\n // Record mode proxies on a miss to capture a fresh turn (see record gate\n // below), so keep turnIndex strict to prevent an earlier-turn fixture from\n // shadowing a longer request and skipping the new turn's recording.\n recordMatchOptions(!!defaults.record, defaults.logger),\n );\n\n if (fixture) {\n defaults.logger.debug(\n `Responses fixture matched for ${req.method ?? \"POST\"} ${req.url ?? \"/v1/responses\"}`,\n );\n journal.incrementFixtureMatchCount(fixture, fixtures, testId);\n } else {\n defaults.logger.debug(\n `No responses fixture matched for ${req.method ?? \"POST\"} ${req.url ?? \"/v1/responses\"}`,\n );\n }\n\n if (\n await applyChaosAsync(\n res,\n fixture,\n defaults.chaos,\n req.headers,\n req.url,\n journal,\n {\n method: req.method ?? \"POST\",\n path: req.url ?? \"/v1/responses\",\n headers: flattenHeaders(req.headers),\n body: completionReq,\n },\n fixture ? \"fixture\" : \"proxy\",\n defaults.registry,\n defaults.logger,\n )\n )\n return;\n\n if (!fixture) {\n const decisions = resolveRequestDecisions(defaults.strict, req.headers);\n if (decisions.fixtureMiss) {\n const strictStatus = 503;\n const strictMessage = strictNoMatchMessage(skippedBySequenceOrTurn);\n defaults.logger.error(\n strictNoMatchLogLine(\n req.method ?? \"POST\",\n req.url ?? \"/v1/responses\",\n skippedBySequenceOrTurn,\n ),\n );\n journal.add({\n method: req.method ?? \"POST\",\n path: req.url ?? \"/v1/responses\",\n headers: flattenHeaders(req.headers),\n body: completionReq,\n response: {\n status: strictStatus,\n fixture: null,\n ...strictOverrideField(defaults.strict, req.headers),\n },\n });\n writeErrorResponse(\n res,\n strictStatus,\n renderError(\"openai\", \"strict-miss\", {\n message: strictMessage,\n type: \"invalid_request_error\",\n code: \"no_fixture_match\",\n }).body,\n );\n return;\n }\n if (defaults.record) {\n const outcome = await proxyAndRecord(\n req,\n res,\n completionReq,\n \"openai\",\n req.url ?? \"/v1/responses\",\n fixtures,\n defaults,\n raw,\n );\n if (outcome === \"handled_by_hook\") return;\n if (outcome !== \"not_configured\") {\n journal.add({\n method: req.method ?? \"POST\",\n path: req.url ?? \"/v1/responses\",\n headers: flattenHeaders(req.headers),\n body: completionReq,\n response: { status: res.statusCode ?? 200, fixture: null, source: \"proxy\" },\n });\n return;\n }\n }\n journal.add({\n method: req.method ?? \"POST\",\n path: req.url ?? \"/v1/responses\",\n headers: flattenHeaders(req.headers),\n body: completionReq,\n response: {\n status: 404,\n fixture: null,\n ...strictOverrideField(defaults.strict, req.headers),\n },\n });\n writeErrorResponse(\n res,\n 404,\n renderError(\"openai\", \"fixture-miss\", {\n message: \"No fixture matched\",\n type: \"invalid_request_error\",\n code: \"no_fixture_match\",\n }).body,\n );\n return;\n }\n\n // Without responsesTools \"extended\", a namespace on a toolCalls entry or a\n // toolCall block is not emitted, as in earlier releases.\n const resolvedResponse = await resolveResponse(fixture, completionReq);\n const response = extendedTools ? resolvedResponse : withoutLegacyNamespaces(resolvedResponse);\n const misbehavior = planMisbehavior({\n wire: \"openai-responses\",\n fixture,\n response,\n request: completionReq,\n stream: responsesReq.stream === true,\n emitsToolCallIds: true,\n defaults,\n rawHeaders: req.headers,\n url: req.url,\n });\n if (misbehavior.kind === \"error\") {\n const entry = journal.add({\n method: req.method ?? \"POST\",\n path: req.url ?? \"/v1/responses\",\n headers: flattenHeaders(req.headers),\n body: completionReq,\n response: { status: misbehavior.status, fixture },\n });\n recordMisbehaviorOutcome({ entry, summary: misbehavior.summary, defaults, testId });\n if (!misbehavior.summary?.evaluations.some((evaluation) => evaluation.outcome === \"error\")) {\n defaults.logger.error(misbehavior.message);\n }\n writeErrorResponse(\n res,\n misbehavior.status,\n renderError(\"openai\", \"misbehavior\", {\n message: misbehavior.message,\n type: \"invalid_request_error\",\n code: misbehavior.code,\n }).body,\n );\n return;\n }\n\n const latency = fixture.latency ?? defaults.latency;\n const chunkSize = Math.max(1, fixture.chunkSize ?? defaults.chunkSize);\n const fixtureTimings = fixture.recordedTimings;\n const effectiveReplaySpeed = fixture.replaySpeed ?? defaults.replaySpeed;\n\n if (misbehavior.kind === \"applied\") {\n const prepared = prepareResponsesMisbehavior(misbehavior);\n const output = buildResponsesMisbehavior(\n prepared,\n completionReq,\n chunkSize,\n emitEncryptedReasoning,\n );\n const entry = journal.add({\n method: req.method ?? \"POST\",\n path: req.url ?? \"/v1/responses\",\n headers: flattenHeaders(req.headers),\n body: completionReq,\n response: { status: 200, fixture },\n });\n recordMisbehaviorOutcome({ entry, summary: prepared.summary, defaults, testId });\n if (responsesReq.stream !== true) {\n res.writeHead(200, { \"Content-Type\": \"application/json\" });\n res.end(JSON.stringify(output.response));\n } else {\n const appliedTimings =\n prepared.duplicateId && fixtureTimings\n ? { ...fixtureTimings, interChunkDelaysMs: [...fixtureTimings.interChunkDelaysMs] }\n : fixtureTimings;\n if (prepared.duplicateId && appliedTimings) {\n const lastGap = appliedTimings.interChunkDelaysMs.at(-1) ?? 0;\n while (appliedTimings.interChunkDelaysMs.length < output.events.length - 1) {\n appliedTimings.interChunkDelaysMs.push(lastGap);\n }\n }\n const interruption = createInterruptionSignal(fixture);\n const completed = await writeResponsesSSEStream(res, output.events, {\n latency,\n streamingProfile: fixture.streamingProfile,\n recordedTimings: appliedTimings,\n replaySpeed: effectiveReplaySpeed,\n signal: interruption?.signal,\n onChunkSent: interruption?.tick,\n });\n if (!completed) {\n if (!res.writableEnded) res.destroy();\n entry.response.interrupted = true;\n entry.response.interruptReason = interruption?.reason();\n }\n interruption?.cleanup();\n }\n return;\n }\n\n // Error response\n if (isErrorResponse(response)) {\n const status = response.status ?? 500;\n const journalEntry = journal.add({\n method: req.method ?? \"POST\",\n path: req.url ?? \"/v1/responses\",\n headers: flattenHeaders(req.headers),\n body: completionReq,\n response: { status, fixture },\n });\n recordMisbehaviorOutcome({\n entry: journalEntry,\n summary: misbehavior.summary,\n defaults,\n testId,\n });\n writeErrorResponse(res, status, serializeErrorResponse(response), {\n retryAfter: response.retryAfter,\n });\n return;\n }\n\n // Combined content + tool calls response\n if (isCombinedFixtureResponse(response)) {\n const overrides = extractOverrides(response);\n // Gate reasoning emission on the requested model's capability (aimock#254).\n const effectiveStrict = resolveRequestDecisions(\n defaults.strict,\n req.headers,\n ).reasoningSuppression;\n const effReasoning = resolveReasoningForModel(\n response.reasoning,\n completionReq.model,\n effectiveStrict,\n defaults.logger,\n );\n const journalEntry = journal.add({\n method: req.method ?? \"POST\",\n path: req.url ?? \"/v1/responses\",\n headers: flattenHeaders(req.headers),\n body: completionReq,\n response: { status: 200, fixture },\n });\n recordMisbehaviorOutcome({\n entry: journalEntry,\n summary: misbehavior.summary,\n defaults,\n testId,\n });\n // Resolve the served blocks (responsesBlocks, else legacy blocks) after\n // journaling, where earlier releases' builders resolved them.\n const ordered = resolveServedBlockOutcome(response)?.ordered;\n if (!ordered) assertCustomToolCalls(response);\n const toolCalls = servedToolCalls(response);\n if (responsesReq.stream !== true) {\n const body = buildContentWithToolCallsResponse(\n response.content ?? \"\",\n toolCalls,\n completionReq.model,\n effReasoning,\n response.webSearches,\n overrides,\n ordered,\n emitEncryptedReasoning,\n synthesizeSummarylessReasoning,\n );\n res.writeHead(200, { \"Content-Type\": \"application/json\" });\n res.end(JSON.stringify(body));\n } else {\n const events = contentWithToolCallsStreamEvents(\n response.content ?? \"\",\n toolCalls,\n completionReq.model,\n chunkSize,\n effReasoning,\n response.webSearches,\n overrides,\n ordered,\n emitEncryptedReasoning,\n synthesizeSummarylessReasoning,\n );\n const interruption = createInterruptionSignal(fixture);\n const completed = await writeResponsesSSEStream(res, events, {\n latency,\n streamingProfile: fixture.streamingProfile,\n recordedTimings: fixtureTimings,\n replaySpeed: effectiveReplaySpeed,\n signal: interruption?.signal,\n onChunkSent: interruption?.tick,\n });\n if (!completed) {\n if (!res.writableEnded) res.destroy();\n journalEntry.response.interrupted = true;\n journalEntry.response.interruptReason = interruption?.reason();\n }\n interruption?.cleanup();\n }\n return;\n }\n\n // Text response\n if (isTextResponse(response)) {\n const overrides = extractOverrides(response);\n // Gate reasoning emission on the requested model's capability (aimock#254).\n const effectiveStrict = resolveRequestDecisions(\n defaults.strict,\n req.headers,\n ).reasoningSuppression;\n const effReasoning = resolveReasoningForModel(\n response.reasoning,\n completionReq.model,\n effectiveStrict,\n defaults.logger,\n );\n const journalEntry = journal.add({\n method: req.method ?? \"POST\",\n path: req.url ?? \"/v1/responses\",\n headers: flattenHeaders(req.headers),\n body: completionReq,\n response: { status: 200, fixture },\n });\n recordMisbehaviorOutcome({\n entry: journalEntry,\n summary: misbehavior.summary,\n defaults,\n testId,\n });\n if (responsesReq.stream !== true) {\n const body = buildTextResponse(\n response.content,\n completionReq.model,\n effReasoning,\n response.webSearches,\n overrides,\n emitEncryptedReasoning,\n synthesizeSummarylessReasoning,\n );\n res.writeHead(200, { \"Content-Type\": \"application/json\" });\n res.end(JSON.stringify(body));\n } else {\n const events = buildTextStreamEvents(\n response.content,\n completionReq.model,\n chunkSize,\n effReasoning,\n response.webSearches,\n overrides,\n emitEncryptedReasoning,\n synthesizeSummarylessReasoning,\n );\n const interruption = createInterruptionSignal(fixture);\n const completed = await writeResponsesSSEStream(res, events, {\n latency,\n streamingProfile: fixture.streamingProfile,\n recordedTimings: fixtureTimings,\n replaySpeed: effectiveReplaySpeed,\n signal: interruption?.signal,\n onChunkSent: interruption?.tick,\n });\n if (!completed) {\n if (!res.writableEnded) res.destroy();\n journalEntry.response.interrupted = true;\n journalEntry.response.interruptReason = interruption?.reason();\n }\n interruption?.cleanup();\n }\n return;\n }\n\n // Tool call response\n if (isToolCallResponse(response)) {\n const overrides = extractOverrides(response);\n // Gate reasoning emission on the requested model's capability (aimock#254).\n const effectiveStrict = resolveRequestDecisions(\n defaults.strict,\n req.headers,\n ).reasoningSuppression;\n const effReasoning = resolveReasoningForModel(\n response.reasoning,\n completionReq.model,\n effectiveStrict,\n defaults.logger,\n );\n const journalEntry = journal.add({\n method: req.method ?? \"POST\",\n path: req.url ?? \"/v1/responses\",\n headers: flattenHeaders(req.headers),\n body: completionReq,\n response: { status: 200, fixture },\n });\n recordMisbehaviorOutcome({\n entry: journalEntry,\n summary: misbehavior.summary,\n defaults,\n testId,\n });\n assertCustomToolCalls(response);\n if (responsesReq.stream !== true) {\n const body = buildToolCallResponse(\n servedToolCalls(response),\n completionReq.model,\n effReasoning,\n response.webSearches,\n overrides,\n emitEncryptedReasoning,\n synthesizeSummarylessReasoning,\n );\n res.writeHead(200, { \"Content-Type\": \"application/json\" });\n res.end(JSON.stringify(body));\n } else {\n const events = toolCallStreamEvents(\n servedToolCalls(response),\n completionReq.model,\n chunkSize,\n effReasoning,\n response.webSearches,\n overrides,\n emitEncryptedReasoning,\n synthesizeSummarylessReasoning,\n );\n const interruption = createInterruptionSignal(fixture);\n const completed = await writeResponsesSSEStream(res, events, {\n latency,\n streamingProfile: fixture.streamingProfile,\n recordedTimings: fixtureTimings,\n replaySpeed: effectiveReplaySpeed,\n signal: interruption?.signal,\n onChunkSent: interruption?.tick,\n });\n if (!completed) {\n if (!res.writableEnded) res.destroy();\n journalEntry.response.interrupted = true;\n journalEntry.response.interruptReason = interruption?.reason();\n }\n interruption?.cleanup();\n }\n return;\n }\n\n // Unknown response type\n const journalEntry = journal.add({\n method: req.method ?? \"POST\",\n path: req.url ?? \"/v1/responses\",\n headers: flattenHeaders(req.headers),\n body: completionReq,\n response: { status: 500, fixture },\n });\n recordMisbehaviorOutcome({ entry: journalEntry, summary: misbehavior.summary, defaults, testId });\n writeErrorResponse(\n res,\n 500,\n renderError(\"openai\", \"unknown-response\", {\n message: \"Fixture response did not match any known type\",\n type: \"server_error\",\n }).body,\n );\n}\n\n/** Prepare call IDs once, retaining the engine's effective blocks and exact served-call metadata. */\nexport function prepareResponsesMisbehavior(plan: MisbehaviorPlan): MisbehaviorPlan {\n return prepareOpenAIChatMisbehavior(plan);\n}\n\n/** Build one faulted payload/event sequence for both HTTP and Responses WebSocket consumers. */\nexport function buildResponsesMisbehavior(\n plan: MisbehaviorPlan,\n request: ChatCompletionRequest,\n chunkSize: number,\n emitEncryptedReasoning = false,\n) {\n const response = plan.response;\n if (\n !(\n isCombinedFixtureResponse(response) ||\n isTextResponse(response) ||\n isToolCallResponse(response)\n )\n ) {\n throw new Error(\"Responses misbehavior requires a prepared chat response\");\n }\n const overrides = extractOverrides(response);\n const reasoning = plan.reasoning ?? (\"reasoning\" in response ? response.reasoning : undefined);\n const webSearches = \"webSearches\" in response ? response.webSearches : undefined;\n const { respId, created, events, prefixOutputItems, nextOutputIndex } = buildResponsePreamble(\n request.model,\n chunkSize,\n reasoning,\n webSearches,\n overrides,\n emitEncryptedReasoning,\n false,\n plan.reasoning !== undefined,\n );\n const output = [...prefixOutputItems];\n let outputIndex = nextOutputIndex;\n const incomplete = plan.stop === \"length\" || plan.stop === \"content_filter\";\n\n if (plan.refusal !== undefined) {\n const id = itemId();\n const part = { type: \"refusal\", refusal: plan.refusal };\n const item = {\n id,\n type: \"message\",\n role: \"assistant\",\n status: \"completed\",\n ...(overrides.phase !== undefined ? { phase: overrides.phase } : {}),\n content: [part],\n };\n const position = { item_id: id, output_index: outputIndex, content_index: 0 };\n events.push(\n {\n type: \"response.output_item.added\",\n output_index: outputIndex,\n item: { ...item, status: \"in_progress\", content: [] },\n },\n { type: \"response.content_part.added\", ...position, part: { type: \"refusal\", refusal: \"\" } },\n );\n for (let i = 0; i < plan.refusal.length; i += chunkSize) {\n events.push({\n type: \"response.refusal.delta\",\n ...position,\n delta: plan.refusal.slice(i, i + chunkSize),\n });\n }\n events.push(\n { type: \"response.refusal.done\", ...position, refusal: plan.refusal },\n { type: \"response.content_part.done\", ...position, part },\n { type: \"response.output_item.done\", output_index: outputIndex, item },\n );\n output.push(item);\n } else if (\n plan.summary.fault !== \"empty-response\" &&\n plan.stop !== \"content_filter\" &&\n plan.reasoning === undefined\n ) {\n const combined = isCombinedFixtureResponse(response);\n // Custom tool calls and namespaces pass through a fault unchanged.\n const outcome = combined ? resolveServedBlockOutcome(response) : undefined;\n const blocks: ResponsesFixtureBlock[] = outcome?.ordered ?? [\n ...(\"content\" in response && typeof response.content === \"string\"\n ? [{ type: \"text\" as const, text: response.content }]\n : []),\n ...(combined || isToolCallResponse(response)\n ? servedToolCalls(response).map(toolCallFixtureBlock)\n : []),\n ];\n let callIndex = 0;\n for (const block of blocks) {\n if (block.type === \"text\") {\n const message = buildMessageOutputEvents(\n block.text,\n chunkSize,\n outputIndex,\n overrides.phase,\n );\n events.push(...message.events);\n output.push(message.msgItem);\n } else {\n const call =\n block.type === \"customToolCall\"\n ? buildCustomToolCallOutputEvents(block, chunkSize, outputIndex)\n : buildFunctionCallOutputEvents(block, chunkSize, outputIndex);\n const cut =\n plan.summary.fault === \"stop-length-mid-tool\" && callIndex === plan.target?.index;\n const item = cut ? { ...call.item, status: \"incomplete\" } : call.item;\n // Live K5 capture retains both done events, with an incomplete call item.\n events.push(\n ...call.events.map((event) =>\n cut && event.type === \"response.output_item.done\" ? { ...event, item } : event,\n ),\n );\n output.push(item);\n callIndex++;\n }\n outputIndex++;\n }\n }\n const usage = resolveOpenAIChatMisbehaviorUsage(plan, request);\n const body = {\n id: respId,\n object: \"response\",\n created_at: created,\n model: overrides?.model ?? request.model,\n status: incomplete ? \"incomplete\" : responsesStatus(overrides?.finishReason, \"completed\"),\n ...(incomplete\n ? {\n incomplete_details: {\n reason: plan.stop === \"content_filter\" ? \"content_filter\" : \"max_output_tokens\",\n },\n }\n : {}),\n output,\n usage: renderResponsesUsage({ usage }),\n };\n events.push({ type: incomplete ? \"response.incomplete\" : \"response.completed\", response: body });\n return { response: body, events };\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAmJA,SAAS,mBAAmB,SAA8D;AACxF,KAAI,CAAC,QAAS,QAAO;AACrB,KAAI,OAAO,YAAY,SAAU,QAAO;AACxC,QAAO,QACJ,QAAQ,MAAM,EAAE,SAAS,gBAAgB,EAAE,SAAS,cAAc,CAClE,KAAK,MAAM,EAAE,QAAQ,GAAG,CACxB,KAAK,GAAG;;;;;;;;;;;;;AAcb,SAAS,qBAAqB,QAAyB;AACrD,KAAI,OAAO,WAAW,SAAU,QAAO;AACvC,KAAI,CAAC,M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E,GAAG;KAAO;KAAM,GAAG,MAC1E,CACF;AACD,WAAO,KAAK,KAAK;AACjB;;AAEF;;;CAGJ,MAAM,QAAQC,kDAAkC,MAAM,QAAQ;CAC9D,MAAM,OAAO;EACX,IAAI;EACJ,QAAQ;EACR,YAAY;EACZ,OAAO,WAAW,SAAS,QAAQ;EACnC,QAAQ,aAAa,eAAe,gBAAgB,WAAW,cAAc,YAAY;EACzF,GAAI,aACA,EACE,oBAAoB,EAClB,QAAQ,KAAK,SAAS,mBAAmB,mBAAmB,qBAC7D,EACF,GACD,EAAE;EACN;EACA,OAAOjC,yBAAqB,EAAE,OAAO,CAAC;EACvC;AACD,QAAO,KAAK;EAAE,MAAM,aAAa,wBAAwB;EAAsB,UAAU;EAAM,CAAC;AAChG,QAAO;EAAE,UAAU;EAAM;EAAQ"}
@@ -1 +1 @@
1
- {"version":3,"file":"responses.d.cts","names":[],"sources":["../src/responses.ts"],"sourcesContent":[],"mappings":";;;;;;UAujBiB,iBAAA;;;;iBAKD,qBAAA,4GAMF,gGAGX;iBA0Ja,yBAAA,YACH,sGAKC,gGAGX;iBA0rBa,qCAAA,6BAEH,sGAKC,4BACH,6FAGR;;;;;;;iBAqQmB,eAAA,MACf,MAAA,CAAK,sBACL,MAAA,CAAK,uCAEA,oBACD,mBACC,uCACY,MAAA,CAAK,0BAC1B"}
1
+ {"version":3,"file":"responses.d.cts","names":[],"sources":["../src/responses.ts"],"sourcesContent":[],"mappings":";;;;;;UAsiBiB,iBAAA;;;;iBAKD,qBAAA,4GAMF,gGAGX;iBA2Ja,yBAAA,YACH,sGAKC,gGAGX;iBAssBa,qCAAA,6BAEH,sGAKC,4BACH,6FAGR;;;;;;;iBAyQmB,eAAA,MACf,MAAA,CAAK,sBACL,MAAA,CAAK,uCAEA,oBACD,mBACC,uCACY,MAAA,CAAK,0BAC1B"}
@@ -1 +1 @@
1
- {"version":3,"file":"responses.d.ts","names":[],"sources":["../src/responses.ts"],"sourcesContent":[],"mappings":";;;;;;UAujBiB,iBAAA;;;;iBAKD,qBAAA,4GAMF,gGAGX;iBA0Ja,yBAAA,YACH,sGAKC,gGAGX;iBA0rBa,qCAAA,6BAEH,sGAKC,4BACH,6FAGR;;;;;;;iBAqQmB,eAAA,MACf,MAAA,CAAK,sBACL,MAAA,CAAK,uCAEA,oBACD,mBACC,uCACY,MAAA,CAAK,0BAC1B"}
1
+ {"version":3,"file":"responses.d.ts","names":[],"sources":["../src/responses.ts"],"sourcesContent":[],"mappings":";;;;;;UAsiBiB,iBAAA;;;;iBAKD,qBAAA,4GAMF,gGAGX;iBA2Ja,yBAAA,YACH,sGAKC,gGAGX;iBAssBa,qCAAA,6BAEH,sGAKC,4BACH,6FAGR;;;;;;;iBAyQmB,eAAA,MACf,MAAA,CAAK,sBACL,MAAA,CAAK,uCAEA,oBACD,mBACC,uCACY,MAAA,CAAK,0BAC1B"}