@copilotkit/aimock 1.42.1 → 1.44.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (442) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/CHANGELOG.md +65 -0
  4. package/README.md +108 -16
  5. package/dist/agui-handler.d.ts.map +1 -1
  6. package/dist/agui-mock.cjs +1 -1
  7. package/dist/agui-mock.cjs.map +1 -1
  8. package/dist/agui-mock.d.cts.map +1 -1
  9. package/dist/agui-mock.d.ts.map +1 -1
  10. package/dist/agui-mock.js +1 -1
  11. package/dist/agui-mock.js.map +1 -1
  12. package/dist/agui-recorder.cjs +33 -11
  13. package/dist/agui-recorder.cjs.map +1 -1
  14. package/dist/agui-recorder.d.cts +10 -1
  15. package/dist/agui-recorder.d.cts.map +1 -1
  16. package/dist/agui-recorder.d.ts +10 -1
  17. package/dist/agui-recorder.d.ts.map +1 -1
  18. package/dist/agui-recorder.js +33 -11
  19. package/dist/agui-recorder.js.map +1 -1
  20. package/dist/agui-types.d.cts +1 -0
  21. package/dist/agui-types.d.cts.map +1 -1
  22. package/dist/agui-types.d.ts +1 -0
  23. package/dist/agui-types.d.ts.map +1 -1
  24. package/dist/aimock-cli.cjs +38 -10
  25. package/dist/aimock-cli.cjs.map +1 -1
  26. package/dist/aimock-cli.d.cts +5 -0
  27. package/dist/aimock-cli.d.cts.map +1 -1
  28. package/dist/aimock-cli.d.ts +5 -0
  29. package/dist/aimock-cli.d.ts.map +1 -1
  30. package/dist/aimock-cli.js +38 -10
  31. package/dist/aimock-cli.js.map +1 -1
  32. package/dist/batches.cjs +458 -0
  33. package/dist/batches.cjs.map +1 -0
  34. package/dist/batches.d.cts +57 -0
  35. package/dist/batches.d.cts.map +1 -0
  36. package/dist/batches.d.ts +57 -0
  37. package/dist/batches.d.ts.map +1 -0
  38. package/dist/batches.js +453 -0
  39. package/dist/batches.js.map +1 -0
  40. package/dist/bedrock-converse.cjs +44 -12
  41. package/dist/bedrock-converse.cjs.map +1 -1
  42. package/dist/bedrock-converse.d.cts.map +1 -1
  43. package/dist/bedrock-converse.d.ts.map +1 -1
  44. package/dist/bedrock-converse.js +46 -14
  45. package/dist/bedrock-converse.js.map +1 -1
  46. package/dist/bedrock.cjs +10 -8
  47. package/dist/bedrock.cjs.map +1 -1
  48. package/dist/bedrock.d.cts.map +1 -1
  49. package/dist/bedrock.d.ts.map +1 -1
  50. package/dist/bedrock.js +12 -10
  51. package/dist/bedrock.js.map +1 -1
  52. package/dist/byteplus-video.cjs +3 -3
  53. package/dist/byteplus-video.cjs.map +1 -1
  54. package/dist/byteplus-video.js +4 -4
  55. package/dist/byteplus-video.js.map +1 -1
  56. package/dist/chaos.cjs +625 -72
  57. package/dist/chaos.cjs.map +1 -1
  58. package/dist/chaos.d.cts +164 -7
  59. package/dist/chaos.d.cts.map +1 -1
  60. package/dist/chaos.d.ts +164 -7
  61. package/dist/chaos.d.ts.map +1 -1
  62. package/dist/chaos.js +616 -74
  63. package/dist/chaos.js.map +1 -1
  64. package/dist/cli.cjs +131 -30
  65. package/dist/cli.cjs.map +1 -1
  66. package/dist/cli.js +132 -31
  67. package/dist/cli.js.map +1 -1
  68. package/dist/cohere.cjs +37 -9
  69. package/dist/cohere.cjs.map +1 -1
  70. package/dist/cohere.d.cts.map +1 -1
  71. package/dist/cohere.d.ts.map +1 -1
  72. package/dist/cohere.js +39 -11
  73. package/dist/cohere.js.map +1 -1
  74. package/dist/config-loader.cjs +1 -1
  75. package/dist/config-loader.js +1 -1
  76. package/dist/constants.cjs +8 -0
  77. package/dist/constants.cjs.map +1 -1
  78. package/dist/constants.d.cts +6 -2
  79. package/dist/constants.d.ts +6 -2
  80. package/dist/constants.js +8 -1
  81. package/dist/constants.js.map +1 -1
  82. package/dist/convert.cjs +1 -1
  83. package/dist/convert.cjs.map +1 -1
  84. package/dist/convert.js +1 -1
  85. package/dist/convert.js.map +1 -1
  86. package/dist/echo-text.cjs +65 -0
  87. package/dist/echo-text.cjs.map +1 -0
  88. package/dist/echo-text.d.cts +22 -0
  89. package/dist/echo-text.d.cts.map +1 -0
  90. package/dist/echo-text.d.ts +22 -0
  91. package/dist/echo-text.d.ts.map +1 -0
  92. package/dist/echo-text.js +65 -0
  93. package/dist/echo-text.js.map +1 -0
  94. package/dist/elevenlabs-audio.cjs +3 -3
  95. package/dist/elevenlabs-audio.cjs.map +1 -1
  96. package/dist/elevenlabs-audio.js +4 -4
  97. package/dist/elevenlabs-audio.js.map +1 -1
  98. package/dist/elevenlabs-voice.cjs +1053 -0
  99. package/dist/elevenlabs-voice.cjs.map +1 -0
  100. package/dist/elevenlabs-voice.d.cts +72 -0
  101. package/dist/elevenlabs-voice.d.cts.map +1 -0
  102. package/dist/elevenlabs-voice.d.ts +72 -0
  103. package/dist/elevenlabs-voice.d.ts.map +1 -0
  104. package/dist/elevenlabs-voice.js +1048 -0
  105. package/dist/elevenlabs-voice.js.map +1 -0
  106. package/dist/embeddings.cjs +26 -5
  107. package/dist/embeddings.cjs.map +1 -1
  108. package/dist/embeddings.d.cts +1 -1
  109. package/dist/embeddings.d.cts.map +1 -1
  110. package/dist/embeddings.d.ts +1 -1
  111. package/dist/embeddings.d.ts.map +1 -1
  112. package/dist/embeddings.js +27 -6
  113. package/dist/embeddings.js.map +1 -1
  114. package/dist/fal-audio.cjs +3 -3
  115. package/dist/fal-audio.cjs.map +1 -1
  116. package/dist/fal-audio.js +4 -4
  117. package/dist/fal-audio.js.map +1 -1
  118. package/dist/fal.cjs +28 -4
  119. package/dist/fal.cjs.map +1 -1
  120. package/dist/fal.d.cts +16 -1
  121. package/dist/fal.d.cts.map +1 -1
  122. package/dist/fal.d.ts +16 -1
  123. package/dist/fal.d.ts.map +1 -1
  124. package/dist/fal.js +28 -5
  125. package/dist/fal.js.map +1 -1
  126. package/dist/files.cjs +1069 -0
  127. package/dist/files.cjs.map +1 -0
  128. package/dist/files.d.cts +68 -0
  129. package/dist/files.d.cts.map +1 -0
  130. package/dist/files.d.ts +68 -0
  131. package/dist/files.d.ts.map +1 -0
  132. package/dist/files.js +1056 -0
  133. package/dist/files.js.map +1 -0
  134. package/dist/fine-tuning.cjs +1033 -0
  135. package/dist/fine-tuning.cjs.map +1 -0
  136. package/dist/fine-tuning.d.cts +96 -0
  137. package/dist/fine-tuning.d.cts.map +1 -0
  138. package/dist/fine-tuning.d.ts +96 -0
  139. package/dist/fine-tuning.d.ts.map +1 -0
  140. package/dist/fine-tuning.js +1026 -0
  141. package/dist/fine-tuning.js.map +1 -0
  142. package/dist/fixture-loader-services.cjs +116 -0
  143. package/dist/fixture-loader-services.cjs.map +1 -0
  144. package/dist/fixture-loader-services.d.cts +48 -0
  145. package/dist/fixture-loader-services.d.cts.map +1 -0
  146. package/dist/fixture-loader-services.d.ts +48 -0
  147. package/dist/fixture-loader-services.d.ts.map +1 -0
  148. package/dist/fixture-loader-services.js +114 -0
  149. package/dist/fixture-loader-services.js.map +1 -0
  150. package/dist/fixture-loader.cjs +0 -0
  151. package/dist/fixture-loader.cjs.map +1 -1
  152. package/dist/fixture-loader.d.cts +131 -5
  153. package/dist/fixture-loader.d.cts.map +1 -1
  154. package/dist/fixture-loader.d.ts +131 -5
  155. package/dist/fixture-loader.d.ts.map +1 -1
  156. package/dist/fixture-loader.js +0 -0
  157. package/dist/fixture-loader.js.map +1 -1
  158. package/dist/gemini-embeddings.cjs +44 -4
  159. package/dist/gemini-embeddings.cjs.map +1 -1
  160. package/dist/gemini-embeddings.js +46 -6
  161. package/dist/gemini-embeddings.js.map +1 -1
  162. package/dist/gemini-interactions.cjs +51 -7
  163. package/dist/gemini-interactions.cjs.map +1 -1
  164. package/dist/gemini-interactions.d.cts.map +1 -1
  165. package/dist/gemini-interactions.d.ts.map +1 -1
  166. package/dist/gemini-interactions.js +53 -9
  167. package/dist/gemini-interactions.js.map +1 -1
  168. package/dist/gemini.cjs +19 -8
  169. package/dist/gemini.cjs.map +1 -1
  170. package/dist/gemini.d.cts.map +1 -1
  171. package/dist/gemini.d.ts.map +1 -1
  172. package/dist/gemini.js +21 -10
  173. package/dist/gemini.js.map +1 -1
  174. package/dist/grok-video.cjs +14 -14
  175. package/dist/grok-video.cjs.map +1 -1
  176. package/dist/grok-video.js +15 -15
  177. package/dist/grok-video.js.map +1 -1
  178. package/dist/helpers.cjs +497 -10
  179. package/dist/helpers.cjs.map +1 -1
  180. package/dist/helpers.d.cts +38 -2
  181. package/dist/helpers.d.cts.map +1 -1
  182. package/dist/helpers.d.ts +38 -2
  183. package/dist/helpers.d.ts.map +1 -1
  184. package/dist/helpers.js +487 -12
  185. package/dist/helpers.js.map +1 -1
  186. package/dist/images.cjs +57 -125
  187. package/dist/images.cjs.map +1 -1
  188. package/dist/images.d.cts.map +1 -1
  189. package/dist/images.d.ts.map +1 -1
  190. package/dist/images.js +58 -126
  191. package/dist/images.js.map +1 -1
  192. package/dist/index.cjs +71 -9
  193. package/dist/index.d.cts +17 -7
  194. package/dist/index.d.ts +17 -7
  195. package/dist/index.js +21 -11
  196. package/dist/jest.cjs +24 -12
  197. package/dist/jest.cjs.map +1 -1
  198. package/dist/jest.d.cts +6 -3
  199. package/dist/jest.d.cts.map +1 -1
  200. package/dist/jest.d.ts +6 -3
  201. package/dist/jest.d.ts.map +1 -1
  202. package/dist/jest.js +25 -13
  203. package/dist/jest.js.map +1 -1
  204. package/dist/journal.cjs +61 -4
  205. package/dist/journal.cjs.map +1 -1
  206. package/dist/journal.d.cts +60 -3
  207. package/dist/journal.d.cts.map +1 -1
  208. package/dist/journal.d.ts +60 -3
  209. package/dist/journal.d.ts.map +1 -1
  210. package/dist/journal.js +61 -5
  211. package/dist/journal.js.map +1 -1
  212. package/dist/live-fixture.cjs +1192 -0
  213. package/dist/live-fixture.cjs.map +1 -0
  214. package/dist/live-fixture.js +1187 -0
  215. package/dist/live-fixture.js.map +1 -0
  216. package/dist/live-recorder.cjs +256 -0
  217. package/dist/live-recorder.cjs.map +1 -0
  218. package/dist/live-recorder.js +254 -0
  219. package/dist/live-recorder.js.map +1 -0
  220. package/dist/live-replay.cjs +286 -0
  221. package/dist/live-replay.cjs.map +1 -0
  222. package/dist/live-replay.js +285 -0
  223. package/dist/live-replay.js.map +1 -0
  224. package/dist/live-sanitize.cjs +196 -0
  225. package/dist/live-sanitize.cjs.map +1 -0
  226. package/dist/live-sanitize.js +196 -0
  227. package/dist/live-sanitize.js.map +1 -0
  228. package/dist/live-types.d.cts +71 -0
  229. package/dist/live-types.d.cts.map +1 -0
  230. package/dist/live-types.d.ts +71 -0
  231. package/dist/live-types.d.ts.map +1 -0
  232. package/dist/llmock.cjs +132 -49
  233. package/dist/llmock.cjs.map +1 -1
  234. package/dist/llmock.d.cts +51 -5
  235. package/dist/llmock.d.cts.map +1 -1
  236. package/dist/llmock.d.ts +51 -5
  237. package/dist/llmock.d.ts.map +1 -1
  238. package/dist/llmock.js +133 -50
  239. package/dist/llmock.js.map +1 -1
  240. package/dist/mcp-fakes-mount.cjs +216 -0
  241. package/dist/mcp-fakes-mount.cjs.map +1 -0
  242. package/dist/mcp-fakes-mount.js +210 -0
  243. package/dist/mcp-fakes-mount.js.map +1 -0
  244. package/dist/mcp-fakes.cjs +1619 -0
  245. package/dist/mcp-fakes.cjs.map +1 -0
  246. package/dist/mcp-fakes.d.cts +101 -0
  247. package/dist/mcp-fakes.d.cts.map +1 -0
  248. package/dist/mcp-fakes.d.ts +101 -0
  249. package/dist/mcp-fakes.d.ts.map +1 -0
  250. package/dist/mcp-fakes.js +1614 -0
  251. package/dist/mcp-fakes.js.map +1 -0
  252. package/dist/mcp-handler.cjs +331 -17
  253. package/dist/mcp-handler.cjs.map +1 -1
  254. package/dist/mcp-handler.js +330 -18
  255. package/dist/mcp-handler.js.map +1 -1
  256. package/dist/mcp-mock.cjs +217 -49
  257. package/dist/mcp-mock.cjs.map +1 -1
  258. package/dist/mcp-mock.d.cts +66 -1
  259. package/dist/mcp-mock.d.cts.map +1 -1
  260. package/dist/mcp-mock.d.ts +66 -1
  261. package/dist/mcp-mock.d.ts.map +1 -1
  262. package/dist/mcp-mock.js +218 -50
  263. package/dist/mcp-mock.js.map +1 -1
  264. package/dist/mcp-stub.cjs +5 -1
  265. package/dist/mcp-stub.d.cts +3 -1
  266. package/dist/mcp-stub.d.ts +3 -1
  267. package/dist/mcp-stub.js +3 -1
  268. package/dist/mcp-types.d.cts +6 -0
  269. package/dist/mcp-types.d.ts +6 -0
  270. package/dist/message-text.cjs +192 -0
  271. package/dist/message-text.cjs.map +1 -0
  272. package/dist/message-text.d.cts +31 -0
  273. package/dist/message-text.d.cts.map +1 -0
  274. package/dist/message-text.d.ts +31 -0
  275. package/dist/message-text.d.ts.map +1 -0
  276. package/dist/message-text.js +184 -0
  277. package/dist/message-text.js.map +1 -0
  278. package/dist/messages.cjs +49 -7
  279. package/dist/messages.cjs.map +1 -1
  280. package/dist/messages.d.cts.map +1 -1
  281. package/dist/messages.d.ts.map +1 -1
  282. package/dist/messages.js +51 -9
  283. package/dist/messages.js.map +1 -1
  284. package/dist/metrics.cjs +278 -45
  285. package/dist/metrics.cjs.map +1 -1
  286. package/dist/metrics.d.cts +17 -7
  287. package/dist/metrics.d.cts.map +1 -1
  288. package/dist/metrics.d.ts +17 -7
  289. package/dist/metrics.d.ts.map +1 -1
  290. package/dist/metrics.js +270 -29
  291. package/dist/metrics.js.map +1 -1
  292. package/dist/moderation.cjs +10 -1
  293. package/dist/moderation.cjs.map +1 -1
  294. package/dist/moderation.d.cts.map +1 -1
  295. package/dist/moderation.d.ts.map +1 -1
  296. package/dist/moderation.js +10 -1
  297. package/dist/moderation.js.map +1 -1
  298. package/dist/ollama.cjs +10 -6
  299. package/dist/ollama.cjs.map +1 -1
  300. package/dist/ollama.d.cts.map +1 -1
  301. package/dist/ollama.d.ts.map +1 -1
  302. package/dist/ollama.js +11 -7
  303. package/dist/ollama.js.map +1 -1
  304. package/dist/openapi.cjs +3405 -0
  305. package/dist/openapi.cjs.map +1 -0
  306. package/dist/openapi.d.cts +30 -0
  307. package/dist/openapi.d.cts.map +1 -0
  308. package/dist/openapi.d.ts +30 -0
  309. package/dist/openapi.d.ts.map +1 -0
  310. package/dist/openapi.js +3404 -0
  311. package/dist/openapi.js.map +1 -0
  312. package/dist/openrouter-video.cjs +9 -9
  313. package/dist/openrouter-video.cjs.map +1 -1
  314. package/dist/openrouter-video.d.cts.map +1 -1
  315. package/dist/openrouter-video.d.ts.map +1 -1
  316. package/dist/openrouter-video.js +10 -10
  317. package/dist/openrouter-video.js.map +1 -1
  318. package/dist/recorder.cjs +54 -10
  319. package/dist/recorder.cjs.map +1 -1
  320. package/dist/recorder.d.cts.map +1 -1
  321. package/dist/recorder.d.ts.map +1 -1
  322. package/dist/recorder.js +52 -12
  323. package/dist/recorder.js.map +1 -1
  324. package/dist/responses.cjs +47 -7
  325. package/dist/responses.cjs.map +1 -1
  326. package/dist/responses.d.cts.map +1 -1
  327. package/dist/responses.d.ts.map +1 -1
  328. package/dist/responses.js +48 -9
  329. package/dist/responses.js.map +1 -1
  330. package/dist/route-registry.cjs +951 -0
  331. package/dist/route-registry.cjs.map +1 -0
  332. package/dist/route-registry.d.cts +33 -0
  333. package/dist/route-registry.d.cts.map +1 -0
  334. package/dist/route-registry.d.ts +33 -0
  335. package/dist/route-registry.d.ts.map +1 -0
  336. package/dist/route-registry.js +866 -0
  337. package/dist/route-registry.js.map +1 -0
  338. package/dist/router.cjs +21 -34
  339. package/dist/router.cjs.map +1 -1
  340. package/dist/router.d.cts +4 -1
  341. package/dist/router.d.cts.map +1 -1
  342. package/dist/router.d.ts +4 -1
  343. package/dist/router.d.ts.map +1 -1
  344. package/dist/router.js +21 -35
  345. package/dist/router.js.map +1 -1
  346. package/dist/server.cjs +1252 -777
  347. package/dist/server.cjs.map +1 -1
  348. package/dist/server.d.cts +5 -1
  349. package/dist/server.d.cts.map +1 -1
  350. package/dist/server.d.ts +5 -1
  351. package/dist/server.d.ts.map +1 -1
  352. package/dist/server.js +1185 -710
  353. package/dist/server.js.map +1 -1
  354. package/dist/speech.cjs +6 -4
  355. package/dist/speech.cjs.map +1 -1
  356. package/dist/speech.js +7 -5
  357. package/dist/speech.js.map +1 -1
  358. package/dist/suite.cjs +1 -1
  359. package/dist/suite.js +1 -1
  360. package/dist/transcription.cjs +6 -6
  361. package/dist/transcription.cjs.map +1 -1
  362. package/dist/transcription.d.cts.map +1 -1
  363. package/dist/transcription.d.ts.map +1 -1
  364. package/dist/transcription.js +7 -7
  365. package/dist/transcription.js.map +1 -1
  366. package/dist/types.cjs +18 -0
  367. package/dist/types.cjs.map +1 -0
  368. package/dist/types.d.cts +320 -17
  369. package/dist/types.d.cts.map +1 -1
  370. package/dist/types.d.ts +320 -17
  371. package/dist/types.d.ts.map +1 -1
  372. package/dist/types.js +17 -0
  373. package/dist/types.js.map +1 -0
  374. package/dist/validate-cli.cjs +983 -0
  375. package/dist/validate-cli.cjs.map +1 -0
  376. package/dist/validate-cli.js +982 -0
  377. package/dist/validate-cli.js.map +1 -0
  378. package/dist/vector-stores.cjs +1180 -0
  379. package/dist/vector-stores.cjs.map +1 -0
  380. package/dist/vector-stores.d.cts +106 -0
  381. package/dist/vector-stores.d.cts.map +1 -0
  382. package/dist/vector-stores.d.ts +106 -0
  383. package/dist/vector-stores.d.ts.map +1 -0
  384. package/dist/vector-stores.js +1164 -0
  385. package/dist/vector-stores.js.map +1 -0
  386. package/dist/vector-types.d.cts.map +1 -1
  387. package/dist/vector-types.d.ts.map +1 -1
  388. package/dist/veo-video.cjs +13 -13
  389. package/dist/veo-video.cjs.map +1 -1
  390. package/dist/veo-video.js +14 -14
  391. package/dist/veo-video.js.map +1 -1
  392. package/dist/video.cjs +23 -4
  393. package/dist/video.cjs.map +1 -1
  394. package/dist/video.d.cts +1 -1
  395. package/dist/video.d.cts.map +1 -1
  396. package/dist/video.d.ts +1 -1
  397. package/dist/video.d.ts.map +1 -1
  398. package/dist/video.js +24 -5
  399. package/dist/video.js.map +1 -1
  400. package/dist/vitest.cjs +23 -11
  401. package/dist/vitest.cjs.map +1 -1
  402. package/dist/vitest.d.cts +5 -2
  403. package/dist/vitest.d.cts.map +1 -1
  404. package/dist/vitest.d.ts +5 -2
  405. package/dist/vitest.d.ts.map +1 -1
  406. package/dist/vitest.js +25 -13
  407. package/dist/vitest.js.map +1 -1
  408. package/dist/watcher.cjs +2 -1
  409. package/dist/watcher.cjs.map +1 -1
  410. package/dist/watcher.js +2 -1
  411. package/dist/watcher.js.map +1 -1
  412. package/dist/ws-framing.cjs +150 -35
  413. package/dist/ws-framing.cjs.map +1 -1
  414. package/dist/ws-framing.d.cts +18 -3
  415. package/dist/ws-framing.d.cts.map +1 -1
  416. package/dist/ws-framing.d.ts +18 -3
  417. package/dist/ws-framing.d.ts.map +1 -1
  418. package/dist/ws-framing.js +151 -36
  419. package/dist/ws-framing.js.map +1 -1
  420. package/dist/ws-gemini-live.cjs +2 -2
  421. package/dist/ws-gemini-live.js +2 -2
  422. package/dist/ws-live.cjs +401 -0
  423. package/dist/ws-live.cjs.map +1 -0
  424. package/dist/ws-live.js +400 -0
  425. package/dist/ws-live.js.map +1 -0
  426. package/dist/ws-realtime.cjs +46 -2
  427. package/dist/ws-realtime.cjs.map +1 -1
  428. package/dist/ws-realtime.d.cts.map +1 -1
  429. package/dist/ws-realtime.d.ts.map +1 -1
  430. package/dist/ws-realtime.js +46 -2
  431. package/dist/ws-realtime.js.map +1 -1
  432. package/dist/ws-responses.cjs +16 -4
  433. package/dist/ws-responses.cjs.map +1 -1
  434. package/dist/ws-responses.js +16 -4
  435. package/dist/ws-responses.js.map +1 -1
  436. package/dist/ws-upstream.cjs +118 -0
  437. package/dist/ws-upstream.cjs.map +1 -0
  438. package/dist/ws-upstream.js +115 -0
  439. package/dist/ws-upstream.js.map +1 -0
  440. package/fixtures/openai-live-client.json +390 -0
  441. package/fixtures/openai-live-managed.json +709 -0
  442. package/package.json +4 -1
@@ -0,0 +1,1187 @@
1
+ //#region src/live-fixture.ts
2
+ const DEFAULT_LIVE_OPTIONS = Object.freeze({
3
+ maxSessions: 16,
4
+ maxMessageBytes: 1024 * 1024,
5
+ maxBufferedBytes: 2 * 1024 * 1024,
6
+ maxWriteBytes: 1024 * 1024,
7
+ maxDecodedAudioBytes: 16 * 1024 * 1024,
8
+ maxDurationMs: 12e4,
9
+ idleTimeoutMs: 3e4,
10
+ mismatchTimeoutMs: 3e4
11
+ });
12
+ const DEFINITIONS = {
13
+ Pcm24: {
14
+ type: "object",
15
+ properties: {
16
+ type: { const: "audio/pcm" },
17
+ rate: { const: 24e3 }
18
+ },
19
+ required: ["type", "rate"],
20
+ additionalProperties: true
21
+ },
22
+ Voice: { anyOf: [{ type: "string" }, {
23
+ type: "object",
24
+ properties: { id: { type: "string" } },
25
+ required: ["id"],
26
+ additionalProperties: true
27
+ }] },
28
+ Audio: {
29
+ type: "object",
30
+ properties: {
31
+ format: { $ref: "#/$defs/Pcm24" },
32
+ output: {
33
+ type: "object",
34
+ properties: { voice: { $ref: "#/$defs/Voice" } },
35
+ required: [],
36
+ additionalProperties: true
37
+ }
38
+ },
39
+ required: [],
40
+ additionalProperties: true
41
+ },
42
+ FunctionTool: {
43
+ type: "object",
44
+ properties: {
45
+ type: { const: "function" },
46
+ name: { type: "string" },
47
+ description: { type: ["string", "null"] },
48
+ parameters: { type: ["object", "null"] },
49
+ strict: { type: ["boolean", "null"] }
50
+ },
51
+ required: ["type", "name"],
52
+ additionalProperties: true
53
+ },
54
+ Backend: {
55
+ type: "object",
56
+ properties: {
57
+ model: { type: "string" },
58
+ instructions: { type: ["string", "null"] },
59
+ max_output_tokens: { type: ["number", "null"] },
60
+ parallel_tool_calls: { type: ["boolean", "null"] },
61
+ reasoning: { anyOf: [{ type: "null" }, {
62
+ type: "object",
63
+ properties: {
64
+ effort: { enum: [
65
+ "none",
66
+ "minimal",
67
+ "low",
68
+ "medium",
69
+ "high",
70
+ "xhigh",
71
+ null
72
+ ] },
73
+ summary: { enum: [
74
+ "concise",
75
+ "detailed",
76
+ "auto",
77
+ null
78
+ ] }
79
+ },
80
+ required: [],
81
+ additionalProperties: true
82
+ }] },
83
+ service_tier: { enum: [
84
+ "auto",
85
+ "default",
86
+ "fast_tier_temp_pilot",
87
+ "flex",
88
+ "priority",
89
+ "ultrafast",
90
+ null
91
+ ] },
92
+ text: { anyOf: [{ type: "null" }, {
93
+ type: "object",
94
+ properties: { verbosity: { enum: [
95
+ "low",
96
+ "medium",
97
+ "high",
98
+ null
99
+ ] } },
100
+ required: [],
101
+ additionalProperties: true
102
+ }] },
103
+ tool_choice: { anyOf: [
104
+ { enum: [
105
+ "auto",
106
+ "none",
107
+ "required"
108
+ ] },
109
+ {
110
+ type: "object",
111
+ properties: {
112
+ type: { const: "function" },
113
+ name: { type: "string" }
114
+ },
115
+ required: ["type", "name"],
116
+ additionalProperties: true
117
+ },
118
+ {
119
+ type: "object",
120
+ properties: {
121
+ type: { const: "mcp" },
122
+ name: { type: "string" },
123
+ server_label: { type: "string" }
124
+ },
125
+ required: [
126
+ "type",
127
+ "name",
128
+ "server_label"
129
+ ],
130
+ additionalProperties: true
131
+ }
132
+ ] },
133
+ tools: {
134
+ type: "array",
135
+ items: { anyOf: [{ $ref: "#/$defs/FunctionTool" }, {
136
+ type: "object",
137
+ properties: { type: { const: "web_search" } },
138
+ required: ["type"],
139
+ additionalProperties: true
140
+ }] }
141
+ }
142
+ },
143
+ required: ["model"],
144
+ additionalProperties: true
145
+ },
146
+ BackendPatch: {
147
+ type: "object",
148
+ properties: {
149
+ model: { type: "string" },
150
+ instructions: { type: ["string", "null"] },
151
+ max_output_tokens: { type: ["number", "null"] },
152
+ parallel_tool_calls: { type: ["boolean", "null"] },
153
+ reasoning: { anyOf: [{ type: "null" }, {
154
+ type: "object",
155
+ properties: {
156
+ effort: { enum: [
157
+ "none",
158
+ "minimal",
159
+ "low",
160
+ "medium",
161
+ "high",
162
+ "xhigh",
163
+ null
164
+ ] },
165
+ summary: { enum: [
166
+ "concise",
167
+ "detailed",
168
+ "auto",
169
+ null
170
+ ] }
171
+ },
172
+ required: [],
173
+ additionalProperties: true
174
+ }] },
175
+ service_tier: { enum: [
176
+ "auto",
177
+ "default",
178
+ "fast_tier_temp_pilot",
179
+ "flex",
180
+ "priority",
181
+ "ultrafast",
182
+ null
183
+ ] },
184
+ text: { anyOf: [{ type: "null" }, {
185
+ type: "object",
186
+ properties: { verbosity: { enum: [
187
+ "low",
188
+ "medium",
189
+ "high",
190
+ null
191
+ ] } },
192
+ required: [],
193
+ additionalProperties: true
194
+ }] },
195
+ tool_choice: { anyOf: [
196
+ { enum: [
197
+ "auto",
198
+ "none",
199
+ "required"
200
+ ] },
201
+ {
202
+ type: "object",
203
+ properties: {
204
+ type: { const: "function" },
205
+ name: { type: "string" }
206
+ },
207
+ required: ["type", "name"],
208
+ additionalProperties: true
209
+ },
210
+ {
211
+ type: "object",
212
+ properties: {
213
+ type: { const: "mcp" },
214
+ name: { type: "string" },
215
+ server_label: { type: "string" }
216
+ },
217
+ required: [
218
+ "type",
219
+ "name",
220
+ "server_label"
221
+ ],
222
+ additionalProperties: true
223
+ }
224
+ ] },
225
+ tools: {
226
+ type: "array",
227
+ items: { anyOf: [{ $ref: "#/$defs/FunctionTool" }, {
228
+ type: "object",
229
+ properties: { type: { const: "web_search" } },
230
+ required: ["type"],
231
+ additionalProperties: true
232
+ }] }
233
+ }
234
+ },
235
+ required: [],
236
+ additionalProperties: true
237
+ },
238
+ Delegation: { anyOf: [
239
+ { type: "null" },
240
+ {
241
+ type: "object",
242
+ properties: { type: { const: "client" } },
243
+ required: ["type"],
244
+ additionalProperties: true
245
+ },
246
+ {
247
+ type: "object",
248
+ properties: {
249
+ type: { const: "responses" },
250
+ responses: { $ref: "#/$defs/Backend" }
251
+ },
252
+ required: ["type", "responses"],
253
+ additionalProperties: true
254
+ }
255
+ ] },
256
+ DelegationPatch: { anyOf: [
257
+ { type: "null" },
258
+ {
259
+ type: "object",
260
+ properties: { type: { const: "client" } },
261
+ required: ["type"],
262
+ additionalProperties: true
263
+ },
264
+ {
265
+ type: "object",
266
+ properties: {
267
+ type: { const: "responses" },
268
+ responses: { $ref: "#/$defs/BackendPatch" }
269
+ },
270
+ required: ["type"],
271
+ additionalProperties: true
272
+ }
273
+ ] },
274
+ SessionConfig: {
275
+ type: "object",
276
+ properties: {
277
+ model: { const: "gpt-live-1" },
278
+ audio: { $ref: "#/$defs/Audio" },
279
+ delegation: { $ref: "#/$defs/Delegation" },
280
+ instructions: { type: ["string", "null"] },
281
+ store: { type: "boolean" },
282
+ input: {
283
+ type: "array",
284
+ items: { type: "object" }
285
+ },
286
+ client: { type: "object" }
287
+ },
288
+ required: ["model"],
289
+ additionalProperties: true
290
+ },
291
+ SessionResource: {
292
+ type: "object",
293
+ properties: {
294
+ model: { const: "gpt-live-1" },
295
+ audio: { $ref: "#/$defs/Audio" },
296
+ delegation: { $ref: "#/$defs/Delegation" },
297
+ instructions: { type: ["string", "null"] },
298
+ store: { type: "boolean" },
299
+ input: {
300
+ type: "array",
301
+ items: { type: "object" }
302
+ },
303
+ client: { type: "object" },
304
+ id: { type: "string" },
305
+ expires_at: { type: "number" },
306
+ status: { const: "active" }
307
+ },
308
+ required: [
309
+ "id",
310
+ "expires_at",
311
+ "model",
312
+ "status"
313
+ ],
314
+ additionalProperties: true
315
+ },
316
+ SessionPatch: {
317
+ type: "object",
318
+ properties: { delegation: { $ref: "#/$defs/DelegationPatch" } },
319
+ required: [],
320
+ additionalProperties: true
321
+ },
322
+ Usage: {
323
+ type: "object",
324
+ properties: { seconds: { type: "number" } },
325
+ required: ["seconds"],
326
+ additionalProperties: true
327
+ },
328
+ DelegationEventBody: {
329
+ type: "object",
330
+ properties: {
331
+ id: { type: "string" },
332
+ type: { const: "delegation" },
333
+ target: { enum: ["client", "responses"] },
334
+ response_id: { type: "string" }
335
+ },
336
+ required: [
337
+ "id",
338
+ "type",
339
+ "target"
340
+ ],
341
+ additionalProperties: true
342
+ },
343
+ Error: {
344
+ type: "object",
345
+ properties: {
346
+ type: { type: "string" },
347
+ code: { type: "string" },
348
+ message: { type: "string" },
349
+ param: { type: ["string", "null"] },
350
+ client_event_id: { type: "string" }
351
+ },
352
+ required: [
353
+ "type",
354
+ "code",
355
+ "message"
356
+ ],
357
+ additionalProperties: true
358
+ },
359
+ FunctionOutput: {
360
+ type: "object",
361
+ properties: {
362
+ type: { const: "function_call_output" },
363
+ call_id: { type: "string" },
364
+ output: { type: "string" },
365
+ id: { type: "string" },
366
+ status: { enum: [
367
+ "in_progress",
368
+ "completed",
369
+ "incomplete"
370
+ ] }
371
+ },
372
+ required: [
373
+ "type",
374
+ "call_id",
375
+ "output"
376
+ ],
377
+ additionalProperties: true
378
+ },
379
+ NestedResponse: {
380
+ type: "object",
381
+ properties: {
382
+ type: { type: "string" },
383
+ sequence_number: { type: "number" },
384
+ response: {
385
+ type: "object",
386
+ properties: {
387
+ id: { type: "string" },
388
+ previous_response_id: { type: ["string", "null"] },
389
+ status: { type: "string" },
390
+ usage: { type: ["object", "null"] },
391
+ output: { type: "array" },
392
+ instructions: { type: ["string", "null"] },
393
+ tools: { type: "array" }
394
+ },
395
+ required: [],
396
+ additionalProperties: true
397
+ },
398
+ item: {
399
+ type: "object",
400
+ properties: {
401
+ id: { type: "string" },
402
+ type: { type: "string" },
403
+ call_id: { type: "string" },
404
+ arguments: { type: "string" },
405
+ name: { type: "string" },
406
+ status: { type: "string" }
407
+ },
408
+ required: [],
409
+ additionalProperties: true
410
+ },
411
+ item_id: { type: "string" },
412
+ output_index: { type: "number" },
413
+ delta: { type: "string" },
414
+ arguments: { type: "string" }
415
+ },
416
+ required: [],
417
+ additionalProperties: true
418
+ }
419
+ };
420
+ const CLIENT_SCHEMAS = {
421
+ "session.start": {
422
+ type: "object",
423
+ properties: {
424
+ type: { const: "session.start" },
425
+ event_id: { type: ["string", "null"] },
426
+ session: { $ref: "#/$defs/SessionConfig" }
427
+ },
428
+ required: ["type", "session"],
429
+ additionalProperties: true
430
+ },
431
+ "session.update": {
432
+ type: "object",
433
+ properties: {
434
+ type: { const: "session.update" },
435
+ event_id: { type: ["string", "null"] },
436
+ session: { $ref: "#/$defs/SessionPatch" }
437
+ },
438
+ required: ["type", "session"],
439
+ additionalProperties: true
440
+ },
441
+ "session.input_audio.append": {
442
+ type: "object",
443
+ properties: {
444
+ type: { const: "session.input_audio.append" },
445
+ event_id: { type: ["string", "null"] },
446
+ audio: { type: "string" }
447
+ },
448
+ required: ["type", "audio"],
449
+ additionalProperties: true
450
+ },
451
+ "response.item.create": {
452
+ type: "object",
453
+ properties: {
454
+ type: { const: "response.item.create" },
455
+ event_id: { type: ["string", "null"] },
456
+ item: { $ref: "#/$defs/FunctionOutput" }
457
+ },
458
+ required: ["type", "item"],
459
+ additionalProperties: true
460
+ },
461
+ "response.create": {
462
+ type: "object",
463
+ properties: {
464
+ type: { const: "response.create" },
465
+ event_id: { type: ["string", "null"] }
466
+ },
467
+ required: ["type"],
468
+ additionalProperties: true
469
+ },
470
+ "session.close": {
471
+ type: "object",
472
+ properties: {
473
+ type: { const: "session.close" },
474
+ event_id: { type: ["string", "null"] }
475
+ },
476
+ required: ["type"],
477
+ additionalProperties: true
478
+ },
479
+ "session.instructions.append": {
480
+ type: "object",
481
+ properties: {
482
+ type: { const: "session.instructions.append" },
483
+ event_id: { type: ["string", "null"] },
484
+ content: { type: "string" },
485
+ delegation_id: { type: ["string", "null"] }
486
+ },
487
+ required: [
488
+ "type",
489
+ "content",
490
+ "delegation_id"
491
+ ],
492
+ additionalProperties: true
493
+ },
494
+ "session.thinking.append": {
495
+ type: "object",
496
+ properties: {
497
+ type: { const: "session.thinking.append" },
498
+ event_id: { type: ["string", "null"] },
499
+ content: { type: "string" },
500
+ delegation_id: { type: ["string", "null"] }
501
+ },
502
+ required: [
503
+ "type",
504
+ "content",
505
+ "delegation_id"
506
+ ],
507
+ additionalProperties: true
508
+ },
509
+ "session.commentary.append": {
510
+ type: "object",
511
+ properties: {
512
+ type: { const: "session.commentary.append" },
513
+ event_id: { type: ["string", "null"] },
514
+ content: { type: "string" },
515
+ delegation_id: { type: ["string", "null"] }
516
+ },
517
+ required: [
518
+ "type",
519
+ "content",
520
+ "delegation_id"
521
+ ],
522
+ additionalProperties: true
523
+ },
524
+ "session.input_audio.mute": {
525
+ type: "object",
526
+ properties: {
527
+ type: { const: "session.input_audio.mute" },
528
+ event_id: { type: ["string", "null"] }
529
+ },
530
+ required: ["type"],
531
+ additionalProperties: true
532
+ },
533
+ "session.input_audio.unmute": {
534
+ type: "object",
535
+ properties: {
536
+ type: { const: "session.input_audio.unmute" },
537
+ event_id: { type: ["string", "null"] }
538
+ },
539
+ required: ["type"],
540
+ additionalProperties: true
541
+ }
542
+ };
543
+ const SERVER_SCHEMAS = {
544
+ "session.started": {
545
+ type: "object",
546
+ properties: {
547
+ type: { const: "session.started" },
548
+ event_id: { type: "string" },
549
+ client_event_id: { type: "string" },
550
+ session: { $ref: "#/$defs/SessionResource" }
551
+ },
552
+ required: [
553
+ "type",
554
+ "event_id",
555
+ "session"
556
+ ],
557
+ additionalProperties: true
558
+ },
559
+ "session.updated": {
560
+ type: "object",
561
+ properties: {
562
+ type: { const: "session.updated" },
563
+ event_id: { type: "string" },
564
+ client_event_id: { type: "string" },
565
+ session: { $ref: "#/$defs/SessionResource" }
566
+ },
567
+ required: [
568
+ "type",
569
+ "event_id",
570
+ "session"
571
+ ],
572
+ additionalProperties: true
573
+ },
574
+ "session.closed": {
575
+ type: "object",
576
+ properties: {
577
+ type: { const: "session.closed" },
578
+ event_id: { type: "string" },
579
+ client_event_id: { type: "string" },
580
+ session: { $ref: "#/$defs/SessionResource" },
581
+ usage: { $ref: "#/$defs/Usage" },
582
+ reason: { enum: [
583
+ "close_requested",
584
+ "expired",
585
+ "content",
586
+ "remote_hangup",
587
+ "connection_lost"
588
+ ] }
589
+ },
590
+ required: [
591
+ "type",
592
+ "event_id",
593
+ "session",
594
+ "usage",
595
+ "reason"
596
+ ],
597
+ additionalProperties: true
598
+ },
599
+ "session.output_audio.delta": {
600
+ type: "object",
601
+ properties: {
602
+ type: { const: "session.output_audio.delta" },
603
+ delta: { type: "string" },
604
+ start_ms: { type: "number" },
605
+ end_ms: { type: "number" }
606
+ },
607
+ required: ["type", "delta"],
608
+ additionalProperties: true
609
+ },
610
+ "session.input_transcript.delta": {
611
+ type: "object",
612
+ properties: {
613
+ type: { const: "session.input_transcript.delta" },
614
+ event_id: { type: "string" },
615
+ client_event_id: { type: "string" },
616
+ start_ms: { type: "number" },
617
+ end_ms: { type: "number" },
618
+ delta: { type: "string" }
619
+ },
620
+ required: [
621
+ "type",
622
+ "event_id",
623
+ "start_ms",
624
+ "end_ms",
625
+ "delta"
626
+ ],
627
+ additionalProperties: true
628
+ },
629
+ "session.output_transcript.delta": {
630
+ type: "object",
631
+ properties: {
632
+ type: { const: "session.output_transcript.delta" },
633
+ event_id: { type: "string" },
634
+ client_event_id: { type: "string" },
635
+ start_ms: { type: "number" },
636
+ end_ms: { type: "number" },
637
+ delta: { type: "string" }
638
+ },
639
+ required: [
640
+ "type",
641
+ "event_id",
642
+ "start_ms",
643
+ "end_ms",
644
+ "delta"
645
+ ],
646
+ additionalProperties: true
647
+ },
648
+ "session.instructions.appended": {
649
+ type: "object",
650
+ properties: {
651
+ type: { const: "session.instructions.appended" },
652
+ event_id: { type: "string" },
653
+ client_event_id: { type: "string" },
654
+ start_ms: { type: "number" },
655
+ end_ms: { type: "number" }
656
+ },
657
+ required: [
658
+ "type",
659
+ "event_id",
660
+ "start_ms",
661
+ "end_ms"
662
+ ],
663
+ additionalProperties: true
664
+ },
665
+ "session.thinking.appended": {
666
+ type: "object",
667
+ properties: {
668
+ type: { const: "session.thinking.appended" },
669
+ event_id: { type: "string" },
670
+ client_event_id: { type: "string" },
671
+ start_ms: { type: "number" },
672
+ end_ms: { type: "number" }
673
+ },
674
+ required: [
675
+ "type",
676
+ "event_id",
677
+ "start_ms",
678
+ "end_ms"
679
+ ],
680
+ additionalProperties: true
681
+ },
682
+ "session.commentary.appended": {
683
+ type: "object",
684
+ properties: {
685
+ type: { const: "session.commentary.appended" },
686
+ event_id: { type: "string" },
687
+ client_event_id: { type: "string" },
688
+ start_ms: { type: "number" },
689
+ end_ms: { type: "number" }
690
+ },
691
+ required: [
692
+ "type",
693
+ "event_id",
694
+ "start_ms",
695
+ "end_ms"
696
+ ],
697
+ additionalProperties: true
698
+ },
699
+ "session.input_audio.muted": {
700
+ type: "object",
701
+ properties: {
702
+ type: { const: "session.input_audio.muted" },
703
+ event_id: { type: "string" },
704
+ client_event_id: { type: "string" }
705
+ },
706
+ required: ["type", "event_id"],
707
+ additionalProperties: true
708
+ },
709
+ "session.input_audio.unmuted": {
710
+ type: "object",
711
+ properties: {
712
+ type: { const: "session.input_audio.unmuted" },
713
+ event_id: { type: "string" },
714
+ client_event_id: { type: "string" }
715
+ },
716
+ required: ["type", "event_id"],
717
+ additionalProperties: true
718
+ },
719
+ "session.delegation.created": {
720
+ type: "object",
721
+ properties: {
722
+ type: { const: "session.delegation.created" },
723
+ event_id: { type: "string" },
724
+ client_event_id: { type: "string" },
725
+ delegation: { $ref: "#/$defs/DelegationEventBody" },
726
+ offset_ms: { type: "number" }
727
+ },
728
+ required: [
729
+ "type",
730
+ "event_id",
731
+ "delegation",
732
+ "offset_ms"
733
+ ],
734
+ additionalProperties: true
735
+ },
736
+ "session.usage.updated": {
737
+ type: "object",
738
+ properties: {
739
+ type: { const: "session.usage.updated" },
740
+ event_id: { type: "string" },
741
+ client_event_id: { type: "string" },
742
+ usage: { $ref: "#/$defs/Usage" },
743
+ context_window: {
744
+ type: "object",
745
+ properties: { usage_ratio: { type: "number" } },
746
+ required: ["usage_ratio"],
747
+ additionalProperties: true
748
+ }
749
+ },
750
+ required: [
751
+ "type",
752
+ "event_id",
753
+ "usage"
754
+ ],
755
+ additionalProperties: true
756
+ },
757
+ "response.event": {
758
+ type: "object",
759
+ properties: {
760
+ type: { const: "response.event" },
761
+ event_id: { type: "string" },
762
+ client_event_id: { type: "string" },
763
+ event: { $ref: "#/$defs/NestedResponse" },
764
+ delegation_id: { type: ["string", "null"] }
765
+ },
766
+ required: [
767
+ "type",
768
+ "event_id",
769
+ "event"
770
+ ],
771
+ additionalProperties: true
772
+ },
773
+ error: {
774
+ type: "object",
775
+ properties: {
776
+ type: { const: "error" },
777
+ event_id: { type: "string" },
778
+ client_event_id: { type: "string" },
779
+ error: { $ref: "#/$defs/Error" }
780
+ },
781
+ required: [
782
+ "type",
783
+ "event_id",
784
+ "error"
785
+ ],
786
+ additionalProperties: true
787
+ }
788
+ };
789
+ const DOCUMENTED_ONLY = new Set([
790
+ "session.instructions.append",
791
+ "session.input_audio.mute",
792
+ "session.input_audio.unmute"
793
+ ]);
794
+ const MAX_JSON_BYTES = 64 * 1024 * 1024;
795
+ const MAX_ENTRIES = 5e6;
796
+ const dangerous = new Set([
797
+ "__proto__",
798
+ "prototype",
799
+ "constructor"
800
+ ]);
801
+ function fail(path, message) {
802
+ throw new Error(`Live fixture ${path}: ${message}`);
803
+ }
804
+ function object(value, path) {
805
+ if (!value || typeof value !== "object" || Array.isArray(value)) fail(path, "must be an object");
806
+ return value;
807
+ }
808
+ function string(value, path) {
809
+ if (typeof value !== "string" || !value.length) fail(path, "must be a nonempty string");
810
+ return value;
811
+ }
812
+ function integer(value, path) {
813
+ if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 0) fail(path, "must be a nonnegative safe integer");
814
+ return value;
815
+ }
816
+ function array(value, path) {
817
+ if (!Array.isArray(value)) fail(path, "must be an array");
818
+ return value;
819
+ }
820
+ /** Clone before registration; reject getters, prototypes, cycles and oversized JSON before allocating. */
821
+ function cloneJson(value, maxBytes = MAX_JSON_BYTES, rootPath = "live") {
822
+ let bytes = 0;
823
+ const ancestors = /* @__PURE__ */ new Set();
824
+ function charge(count, path) {
825
+ bytes += count;
826
+ if (bytes > maxBytes) fail(path, "exceeds JSON byte limit");
827
+ }
828
+ function visit(current, path, depth) {
829
+ if (depth > 32) fail(path, "exceeds JSON depth 32");
830
+ if (current === null || typeof current === "boolean" || typeof current === "number" || typeof current === "string") {
831
+ if (typeof current === "number" && !Number.isFinite(current)) fail(path, "must be finite JSON");
832
+ if (typeof current === "string" && current.length > maxBytes - bytes) fail(path, "exceeds JSON byte limit");
833
+ charge(Buffer.byteLength(JSON.stringify(current)), path);
834
+ return current;
835
+ }
836
+ if (typeof current !== "object") fail(path, "must be JSON");
837
+ if (ancestors.has(current)) fail(path, "contains a cycle");
838
+ const isArray = Array.isArray(current);
839
+ if (Object.getPrototypeOf(current) !== (isArray ? Array.prototype : Object.prototype) && Object.getPrototypeOf(current) !== null) fail(path, "must have a plain JSON prototype");
840
+ if (Object.getOwnPropertySymbols(current).length) fail(path, "symbol properties are not JSON");
841
+ ancestors.add(current);
842
+ charge(2, path);
843
+ const result = isArray ? [] : {};
844
+ const keys = Object.getOwnPropertyNames(current);
845
+ if (isArray && current.length > MAX_ENTRIES) fail(path, "exceeds array entry limit");
846
+ let count = 0;
847
+ for (const key of keys) {
848
+ if (isArray && key === "length") continue;
849
+ if (dangerous.has(key)) fail(`${path}.${key}`, "unsafe property");
850
+ const desc = Object.getOwnPropertyDescriptor(current, key);
851
+ if (!desc || !desc.enumerable || !("value" in desc)) fail(`${path}.${key}`, "must be an enumerable data property");
852
+ if (isArray && key !== String(count)) fail(path, "must be a dense JSON array");
853
+ charge((count++ ? 1 : 0) + (isArray ? 0 : Buffer.byteLength(JSON.stringify(key)) + 1), path);
854
+ const child = visit(desc.value, isArray ? `${path}[${key}]` : `${path}.${key}`, depth + 1);
855
+ if (Array.isArray(result)) result.push(child);
856
+ else result[key] = child;
857
+ }
858
+ if (isArray && count !== current.length) fail(path, "must be a dense JSON array");
859
+ ancestors.delete(current);
860
+ return result;
861
+ }
862
+ return visit(value, rootPath, 0);
863
+ }
864
+ function shape(value, schema, path) {
865
+ if (schema.$ref) return shape(value, DEFINITIONS[schema.$ref.slice(8)], path);
866
+ if (schema.anyOf) {
867
+ for (const option of schema.anyOf) try {
868
+ shape(value, option, path);
869
+ return;
870
+ } catch {}
871
+ fail(path, "does not match documented shape");
872
+ }
873
+ if ("const" in schema && value !== schema.const) fail(path, `must equal ${JSON.stringify(schema.const)}`);
874
+ if (schema.enum && !schema.enum.includes(value ?? null)) fail(path, "is not a documented value");
875
+ if (schema.type) {
876
+ const types = typeof schema.type === "string" ? [schema.type] : schema.type;
877
+ const actual = value === null ? "null" : Array.isArray(value) ? "array" : typeof value;
878
+ if (!types.includes(actual)) fail(path, `must be ${types.join(" or ")}`);
879
+ }
880
+ if (schema.properties || schema.required) {
881
+ const obj = object(value, path);
882
+ for (const key of schema.required ?? []) if (!Object.hasOwn(obj, key)) fail(`${path}.${key}`, "is required");
883
+ for (const [key, child] of Object.entries(schema.properties ?? {})) if (Object.hasOwn(obj, key)) shape(obj[key], child, `${path}.${key}`);
884
+ }
885
+ if (schema.items) array(value, path).forEach((item, i) => shape(item, schema.items, `${path}[${i}]`));
886
+ }
887
+ function normalizeLiveOptions(options = {}) {
888
+ const result = { ...DEFAULT_LIVE_OPTIONS };
889
+ for (const key of Object.keys(DEFAULT_LIVE_OPTIONS)) {
890
+ const value = options[key];
891
+ if (value !== void 0) {
892
+ if (!Number.isSafeInteger(value) || value <= 0) fail(`options.${key}`, "must be a positive safe integer");
893
+ result[key] = value;
894
+ }
895
+ }
896
+ if (options.secretValues !== void 0 && (!Array.isArray(options.secretValues) || options.secretValues.some((value) => typeof value !== "string"))) fail("options.secretValues", "must be strings");
897
+ return {
898
+ ...result,
899
+ secretValues: options.secretValues?.slice() ?? []
900
+ };
901
+ }
902
+ /** Canonical object ordering without changing arrays or literal unknown fields. */
903
+ function canonical(value) {
904
+ if (Array.isArray(value)) return `[${value.map(canonical).join(",")}]`;
905
+ if (value && typeof value === "object") return `{${Object.keys(value).sort().map((key) => `${JSON.stringify(key)}:${canonical(value[key])}`).join(",")}}`;
906
+ return JSON.stringify(value);
907
+ }
908
+ function matchConfiguration(expected, actual, path) {
909
+ if (expected && typeof expected === "object" && !Array.isArray(expected)) {
910
+ const actualObject = object(actual, path);
911
+ for (const [key, value] of Object.entries(expected)) matchConfiguration(value, actualObject[key], `${path}.${key}`);
912
+ } else if (actual === void 0 || canonical(expected) !== canonical(actual)) fail(path, "differs from accepted configuration");
913
+ }
914
+ function pcmBytes(value, path, remaining) {
915
+ if (typeof value !== "string") fail(path, "must be canonical base64 PCM");
916
+ if (value.length % 4 || !/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(value)) fail(path, "must be canonical base64 PCM");
917
+ const bytes = value.length / 4 * 3 - (value.endsWith("==") ? 2 : value.endsWith("=") ? 1 : 0);
918
+ if (bytes > remaining) fail(path, "exceeds decoded audio byte limit");
919
+ if (bytes % 2) fail(path, "must contain complete PCM16 samples");
920
+ const alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
921
+ if (value.endsWith("==") && alphabet.indexOf(value.at(-3)) & 15 || value.endsWith("=") && !value.endsWith("==") && alphabet.indexOf(value.at(-2)) & 3) fail(path, "must be canonical base64 PCM");
922
+ return bytes;
923
+ }
924
+ /** Shared shape check; callers retain capture source, mode and lifecycle policy. */
925
+ function validateClientShape(event, path) {
926
+ const type = string(event.type, `${path}.type`);
927
+ if (!Object.hasOwn(CLIENT_SCHEMAS, type)) fail(`${path}.type`, "unsupported client command");
928
+ shape(event, CLIENT_SCHEMAS[type], path);
929
+ }
930
+ /** Validate one inbound command before matching a fixture or starting a recording.
931
+ * Per-session audio totals, startup configuration and update/lifecycle policy belong to the caller.
932
+ */
933
+ function validateLiveClientEvent(value, options = {}) {
934
+ const limits = normalizeLiveOptions(options);
935
+ const event = object(cloneJson(value, Math.min(limits.maxMessageBytes, MAX_JSON_BYTES), "event"), "event");
936
+ validateClientShape(event, "event");
937
+ if (event.type === "session.input_audio.append") pcmBytes(event.audio, "event.audio", limits.maxDecodedAudioBytes);
938
+ return event;
939
+ }
940
+ function pointer(event, path) {
941
+ if (!path.startsWith("/") || /~(?![01])/u.test(path)) fail("bindings.pointer", "must be a JSON Pointer");
942
+ let value = event;
943
+ for (const segment of path.slice(1).split("/")) {
944
+ const key = segment.replace(/~1/g, "/").replace(/~0/g, "~");
945
+ if (dangerous.has(key)) fail("bindings.pointer", "unsafe segment");
946
+ if (!value || typeof value !== "object" || !Object.hasOwn(value, key)) return void 0;
947
+ value = Array.isArray(value) ? value[Number(key)] : value[key];
948
+ }
949
+ return value;
950
+ }
951
+ const lifecycle = new Set([
952
+ "response.created",
953
+ "response.in_progress",
954
+ "response.completed"
955
+ ]);
956
+ function bindingSites(event, direction) {
957
+ const sites = /* @__PURE__ */ new Map();
958
+ const server = direction === "server";
959
+ function add(path, namespace, define = false, owner = "server", imported = false) {
960
+ if (typeof pointer(event, path) === "string") sites.set(path, {
961
+ namespace,
962
+ owner,
963
+ define,
964
+ imported
965
+ });
966
+ }
967
+ add("/event_id", server ? "server-event" : "client-event", true, server ? "server" : "client");
968
+ if (server) add("/client_event_id", "client-event", false, "client");
969
+ if (server && event.type === "error") add("/error/client_event_id", "client-event", false, "client");
970
+ if (server && [
971
+ "session.started",
972
+ "session.updated",
973
+ "session.closed"
974
+ ].includes(String(event.type))) add("/session/id", "session", event.type === "session.started");
975
+ if (server && event.type === "session.delegation.created") {
976
+ add("/delegation/id", "delegation", true);
977
+ add("/delegation/response_id", "response", true);
978
+ }
979
+ if (!server && [
980
+ "session.thinking.append",
981
+ "session.commentary.append",
982
+ "session.instructions.append"
983
+ ].includes(String(event.type)) || server && event.type === "response.event") add("/delegation_id", "delegation");
984
+ if (!server && event.type === "response.item.create") add("/item/call_id", "tool-call");
985
+ if (server && event.type === "response.event") {
986
+ const nested = object(event.event, "event.event");
987
+ add("/event/response/id", "response", nested.type === "response.created");
988
+ add("/event/response/previous_response_id", "response", false, "server", lifecycle.has(String(nested.type)));
989
+ add("/event/item/id", "response-item", nested.type === "response.output_item.added");
990
+ add("/event/item_id", "response-item");
991
+ add("/event/item/call_id", "tool-call", nested.type === "response.output_item.added");
992
+ }
993
+ return sites;
994
+ }
995
+ function validateLiveTranscript(value, options = {}) {
996
+ const limits = normalizeLiveOptions(options);
997
+ const root = object(cloneJson(value), "live");
998
+ if (root.version !== 1) fail("version", "must equal 1");
999
+ if (root.model !== "gpt-live-1") fail("model", "must equal gpt-live-1");
1000
+ if (root.mode !== "client" && root.mode !== "managed") fail("mode", "must be client or managed");
1001
+ const audio = object(root.audio, "audio");
1002
+ if (audio.encoding !== "pcm16le" || audio.sampleRateHz !== 24e3 || audio.channels !== 1) fail("audio", "requires mono PCM16LE at 24000 Hz");
1003
+ const config = object(root.configuration, "configuration");
1004
+ shape(config, DEFINITIONS.SessionConfig, "configuration");
1005
+ shape(object(config.audio, "configuration.audio").format, DEFINITIONS.Pcm24, "configuration.audio.format");
1006
+ if (object(config.delegation, "configuration.delegation").type !== (root.mode === "managed" ? "responses" : "client")) fail("configuration.delegation", "must match mode explicitly");
1007
+ let effectiveConfiguration = structuredClone(config);
1008
+ const capture = object(root.capture, "capture");
1009
+ if (capture.complete !== true) fail("capture.complete", "only complete successful captures are loadable");
1010
+ if (capture.source !== "authored" && capture.source !== "provider") fail("capture.source", "must be authored or provider");
1011
+ if (capture.provenance !== void 0) {
1012
+ const provenance = object(capture.provenance, "capture.provenance");
1013
+ string(provenance.host, "capture.provenance.host");
1014
+ string(provenance.referenceVersion, "capture.provenance.referenceVersion");
1015
+ if (!Number.isFinite(Date.parse(string(provenance.observedAt, "capture.provenance.observedAt")))) fail("capture.provenance.observedAt", "must be a timestamp");
1016
+ if (provenance.path !== "/v1/live/sessions" || provenance.sanitationVersion !== 1) fail("capture.provenance", "invalid path or sanitationVersion");
1017
+ }
1018
+ const entries = array(root.entries, "entries");
1019
+ if (!entries.length || entries.length > MAX_ENTRIES) fail("entries", "invalid entry count");
1020
+ const terminal = integer(capture.terminalEntry, "capture.terminalEntry");
1021
+ if (terminal !== entries.length - 1) fail("capture.terminalEntry", "must identify the final session.closed event");
1022
+ const bindings = array(root.bindings, "bindings");
1023
+ const byEntry = /* @__PURE__ */ new Map();
1024
+ bindings.forEach((raw, index) => {
1025
+ const path = `bindings[${index}]`;
1026
+ const binding = object(raw, path);
1027
+ const entry = integer(binding.entry, `${path}.entry`);
1028
+ if (entry >= entries.length) fail(`${path}.entry`, "out of range");
1029
+ const bucket = byEntry.get(entry) ?? [];
1030
+ bucket.push({
1031
+ binding,
1032
+ path
1033
+ });
1034
+ byEntry.set(entry, bucket);
1035
+ });
1036
+ const identities = /* @__PURE__ */ new Map();
1037
+ const names = /* @__PURE__ */ new Map();
1038
+ let command = 0, audioBytes = 0, previousTime = -1, previousServerCommand = 0, previousServerAudio = 0;
1039
+ const runBytes = new Map([[0, 0]]);
1040
+ const totals = {
1041
+ client: 0,
1042
+ server: 0
1043
+ };
1044
+ for (let i = 0; i < entries.length; i++) {
1045
+ const path = `entries[${i}]`;
1046
+ const entry = object(entries[i], path);
1047
+ if (entry.direction !== "client" && entry.direction !== "server") fail(`${path}.direction`, "must be client or server");
1048
+ const atMs = integer(entry.atMs, `${path}.atMs`);
1049
+ if (atMs < previousTime || atMs > limits.maxDurationMs) fail(`${path}.atMs`, "must be monotonic and within duration limit");
1050
+ previousTime = atMs;
1051
+ const event = object(entry.event, `${path}.event`);
1052
+ const type = string(event.type, `${path}.event.type`);
1053
+ const client = entry.direction === "client";
1054
+ if (client) {
1055
+ validateClientShape(event, `${path}.event`);
1056
+ if (capture.source === "provider" && DOCUMENTED_ONLY.has(type)) fail(`${path}.event.type`, "unsupported client command for this capture source");
1057
+ } else if (Object.hasOwn(SERVER_SCHEMAS, type)) shape(event, SERVER_SCHEMAS[type], `${path}.event`);
1058
+ if (Buffer.byteLength(JSON.stringify(event)) > limits.maxMessageBytes) fail(`${path}.event`, "exceeds message byte limit");
1059
+ if (type === "error") fail(`${path}.event`, "error probes are not successful fixtures");
1060
+ if (i === 0 && (!client || type !== "session.start")) fail(path, "must begin with client session.start");
1061
+ if (type === "session.start") {
1062
+ if (!client || i !== 0) fail(`${path}.event.type`, "session.start is only valid at startup");
1063
+ if (canonical(event.session) !== canonical(config)) fail(`${path}.event.session`, "must equal configuration");
1064
+ }
1065
+ if (type === "session.update" && client) {
1066
+ const patch = object(event.session, `${path}.event.session`);
1067
+ const del = object(patch.delegation, `${path}.event.session.delegation`);
1068
+ const backend = object(del.responses, `${path}.event.session.delegation.responses`);
1069
+ if (root.mode !== "managed" || Object.keys(patch).some((key) => key !== "delegation") || Object.keys(del).some((key) => key !== "type" && key !== "responses") || del.type !== void 0 && del.type !== "responses" || Object.keys(backend).some((key) => key !== "instructions") || !Object.hasOwn(backend, "instructions")) fail(`${path}.event.session`, "only observed backend instructions update is supported");
1070
+ }
1071
+ if (client && type === "session.update") {
1072
+ const backend = object(object(object(event.session, `${path}.event.session`).delegation, `${path}.event.session.delegation`).responses, `${path}.event.session.delegation.responses`);
1073
+ const del = object(effectiveConfiguration.delegation, "configuration.delegation");
1074
+ effectiveConfiguration = {
1075
+ ...effectiveConfiguration,
1076
+ delegation: {
1077
+ ...del,
1078
+ responses: {
1079
+ ...object(del.responses, "configuration.delegation.responses"),
1080
+ instructions: backend.instructions
1081
+ }
1082
+ }
1083
+ };
1084
+ }
1085
+ if (!client && [
1086
+ "session.started",
1087
+ "session.updated",
1088
+ "session.closed"
1089
+ ].includes(type)) matchConfiguration(effectiveConfiguration, event.session, `${path}.event.session`);
1090
+ if (!client && type === "response.event") {
1091
+ const nested = object(event.event, `${path}.event.event`);
1092
+ if (lifecycle.has(String(nested.type))) string(object(nested.response, `${path}.event.event.response`).id, `${path}.event.event.response.id`);
1093
+ if (["response.output_item.added", "response.output_item.done"].includes(String(nested.type)) && object(nested.item, `${path}.event.event.item`).type === "function_call") {
1094
+ const item = object(nested.item, `${path}.event.event.item`);
1095
+ for (const field of [
1096
+ "id",
1097
+ "call_id",
1098
+ "name"
1099
+ ]) string(item[field], `${path}.event.event.item.${field}`);
1100
+ if (typeof item.arguments !== "string") fail(`${path}.event.event.item.arguments`, "must be a string");
1101
+ }
1102
+ if (["response.function_call_arguments.delta", "response.function_call_arguments.done"].includes(String(nested.type))) string(nested.item_id, `${path}.event.event.item_id`);
1103
+ }
1104
+ let decoded = 0;
1105
+ if (client && type === "session.input_audio.append" || !client && type === "session.output_audio.delta") {
1106
+ decoded = pcmBytes(event[client ? "audio" : "delta"], `${path}.event.${client ? "audio" : "delta"}`, limits.maxDecodedAudioBytes - totals[entry.direction]);
1107
+ totals[entry.direction] += decoded;
1108
+ }
1109
+ if (client) {
1110
+ if (entry.barrier !== void 0) fail(`${path}.barrier`, "client entries cannot have barriers");
1111
+ if (type === "session.input_audio.append") audioBytes += decoded;
1112
+ else {
1113
+ command++;
1114
+ audioBytes = 0;
1115
+ }
1116
+ runBytes.set(command, audioBytes);
1117
+ } else {
1118
+ const barrier = object(entry.barrier, `${path}.barrier`);
1119
+ const c = integer(barrier.command, `${path}.barrier.command`);
1120
+ const a = integer(barrier.audioBytes, `${path}.barrier.audioBytes`);
1121
+ if (a % 2 || c > command || a > (runBytes.get(c) ?? -1) || c < previousServerCommand || c === previousServerCommand && a < previousServerAudio) fail(`${path}.barrier`, "must be monotonic, sample-aligned and within preceding client prefix");
1122
+ previousServerCommand = c;
1123
+ previousServerAudio = a;
1124
+ }
1125
+ if (i === terminal && (client || type !== "session.closed" || !["close_requested", "remote_hangup"].includes(String(event.reason)))) fail("capture.terminalEntry", "must identify successful server session.closed");
1126
+ if (i !== terminal && type === "session.closed") fail(`${path}.event.type`, "session.closed must be terminal");
1127
+ const sites = bindingSites(event, entry.direction);
1128
+ const annotated = /* @__PURE__ */ new Set();
1129
+ const ordered = (byEntry.get(i) ?? []).slice().sort((a, b) => {
1130
+ const rank = (binding) => binding.action === "reference" ? 2 : binding.origin === "imported-context" ? 1 : 0;
1131
+ return rank(a.binding) - rank(b.binding);
1132
+ });
1133
+ for (const { binding, path: bindingPath } of ordered) {
1134
+ const ptr = string(binding.pointer, `${bindingPath}.pointer`);
1135
+ const value = pointer(event, ptr);
1136
+ const site = sites.get(ptr);
1137
+ if (!site || typeof value !== "string" || !value.length) fail(`${bindingPath}.pointer`, "not a non-null described identifier field");
1138
+ if (annotated.has(ptr)) fail(bindingPath, "duplicate pointer annotation");
1139
+ annotated.add(ptr);
1140
+ const name = string(binding.name, `${bindingPath}.name`);
1141
+ if (binding.owner !== site.owner) fail(`${bindingPath}.owner`, "does not match descriptor");
1142
+ if (binding.action !== "define" && binding.action !== "reference") fail(`${bindingPath}.action`, "must be define or reference");
1143
+ if (binding.origin !== void 0 && binding.origin !== "observed" && binding.origin !== "imported-context") fail(`${bindingPath}.origin`, "invalid origin");
1144
+ const imported = binding.origin === "imported-context";
1145
+ if (imported && (binding.action !== "define" || !site.imported || client || site.owner !== "server")) fail(`${bindingPath}.origin`, "illegal imported-context site");
1146
+ const key = JSON.stringify([site.namespace, value]);
1147
+ const prior = identities.get(key);
1148
+ const named = names.get(name);
1149
+ if (binding.action === "define") {
1150
+ if (!site.define && !imported || prior || named) fail(bindingPath, "invalid or duplicate identity definition");
1151
+ identities.set(key, {
1152
+ name,
1153
+ owner: site.owner,
1154
+ value
1155
+ });
1156
+ names.set(name, {
1157
+ namespace: site.namespace,
1158
+ owner: site.owner,
1159
+ value,
1160
+ ...client ? { acceptedAt: {
1161
+ command,
1162
+ audioBytes
1163
+ } } : {}
1164
+ });
1165
+ } else if (!prior || !named || prior.name !== name || named.namespace !== site.namespace || named.owner !== site.owner || named.value !== value) fail(bindingPath, "reference precedes definition or violates identifier bijection");
1166
+ else if (!client && named.acceptedAt && (previousServerCommand < named.acceptedAt.command || previousServerCommand === named.acceptedAt.command && previousServerAudio < named.acceptedAt.audioBytes)) fail(`${path}.barrier`, `precedes referenced client input at ${ptr}`);
1167
+ }
1168
+ for (const ptr of sites.keys()) if (!annotated.has(ptr)) fail(`${path}.event${ptr}`, "missing identifier binding");
1169
+ }
1170
+ return root;
1171
+ }
1172
+ function normalizeLiveFixture(value, options = {}) {
1173
+ if (!value || typeof value !== "object" || Array.isArray(value)) fail("response", "must be an object");
1174
+ const descriptor = Object.getOwnPropertyDescriptor(value, "live");
1175
+ if (!descriptor || !("value" in descriptor)) fail("response.live", "must be an own data property");
1176
+ const timing = Object.getOwnPropertyDescriptor(value, "liveTiming");
1177
+ if (timing && (!("value" in timing) || timing.value !== "recorded" && timing.value !== "immediate")) fail("response.liveTiming", "must be recorded or immediate");
1178
+ const live = validateLiveTranscript(descriptor.value, options);
1179
+ return timing ? {
1180
+ live,
1181
+ liveTiming: timing.value
1182
+ } : { live };
1183
+ }
1184
+
1185
+ //#endregion
1186
+ export { bindingSites, normalizeLiveFixture, normalizeLiveOptions, validateLiveClientEvent, validateLiveTranscript };
1187
+ //# sourceMappingURL=live-fixture.js.map