@azure/ai-projects 2.7.1 → 2.8.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 (493) hide show
  1. package/README.md +28 -0
  2. package/dist/browser/aiProjectClient.d.ts +4 -0
  3. package/dist/browser/aiProjectClient.d.ts.map +1 -1
  4. package/dist/browser/aiProjectClient.js +5 -0
  5. package/dist/browser/aiProjectClient.js.map +1 -1
  6. package/dist/browser/api/agents/index.d.ts +2 -2
  7. package/dist/browser/api/agents/index.d.ts.map +1 -1
  8. package/dist/browser/api/agents/index.js +1 -1
  9. package/dist/browser/api/agents/index.js.map +1 -1
  10. package/dist/browser/api/agents/operations.d.ts +41 -4
  11. package/dist/browser/api/agents/operations.d.ts.map +1 -1
  12. package/dist/browser/api/agents/operations.js +322 -21
  13. package/dist/browser/api/agents/operations.js.map +1 -1
  14. package/dist/browser/api/agents/options.d.ts +163 -93
  15. package/dist/browser/api/agents/options.d.ts.map +1 -1
  16. package/dist/browser/api/agents/options.js.map +1 -1
  17. package/dist/browser/api/beta/agents/index.d.ts +2 -2
  18. package/dist/browser/api/beta/agents/index.d.ts.map +1 -1
  19. package/dist/browser/api/beta/agents/index.js +1 -1
  20. package/dist/browser/api/beta/agents/index.js.map +1 -1
  21. package/dist/browser/api/beta/agents/operations.d.ts +2 -24
  22. package/dist/browser/api/beta/agents/operations.d.ts.map +1 -1
  23. package/dist/browser/api/beta/agents/operations.js +3 -185
  24. package/dist/browser/api/beta/agents/operations.js.map +1 -1
  25. package/dist/browser/api/beta/agents/options.d.ts +0 -56
  26. package/dist/browser/api/beta/agents/options.d.ts.map +1 -1
  27. package/dist/browser/api/beta/agents/options.js.map +1 -1
  28. package/dist/browser/api/beta/evaluators/index.d.ts +2 -2
  29. package/dist/browser/api/beta/evaluators/index.d.ts.map +1 -1
  30. package/dist/browser/api/beta/evaluators/index.js +1 -1
  31. package/dist/browser/api/beta/evaluators/index.js.map +1 -1
  32. package/dist/browser/api/beta/evaluators/operations.d.ts +2 -59
  33. package/dist/browser/api/beta/evaluators/operations.d.ts.map +1 -1
  34. package/dist/browser/api/beta/evaluators/operations.js +1 -388
  35. package/dist/browser/api/beta/evaluators/operations.js.map +1 -1
  36. package/dist/browser/api/beta/evaluators/options.d.ts +0 -84
  37. package/dist/browser/api/beta/evaluators/options.d.ts.map +1 -1
  38. package/dist/browser/api/beta/evaluators/options.js.map +1 -1
  39. package/dist/browser/api/datasets/index.d.ts +2 -2
  40. package/dist/browser/api/datasets/index.d.ts.map +1 -1
  41. package/dist/browser/api/datasets/index.js +1 -1
  42. package/dist/browser/api/datasets/index.js.map +1 -1
  43. package/dist/browser/api/datasets/operations.d.ts +23 -2
  44. package/dist/browser/api/datasets/operations.d.ts.map +1 -1
  45. package/dist/browser/api/datasets/operations.js +193 -1
  46. package/dist/browser/api/datasets/operations.js.map +1 -1
  47. package/dist/browser/api/datasets/options.d.ts +52 -0
  48. package/dist/browser/api/datasets/options.d.ts.map +1 -1
  49. package/dist/browser/api/datasets/options.js.map +1 -1
  50. package/dist/browser/api/evaluators/index.d.ts +3 -0
  51. package/dist/browser/api/evaluators/index.d.ts.map +1 -0
  52. package/dist/browser/api/evaluators/index.js +4 -0
  53. package/dist/browser/api/evaluators/index.js.map +1 -0
  54. package/dist/browser/api/evaluators/operations.d.ts +62 -0
  55. package/dist/browser/api/evaluators/operations.d.ts.map +1 -0
  56. package/dist/browser/api/evaluators/operations.js +373 -0
  57. package/dist/browser/api/evaluators/operations.js.map +1 -0
  58. package/dist/browser/api/evaluators/options.d.ts +70 -0
  59. package/dist/browser/api/evaluators/options.d.ts.map +1 -0
  60. package/dist/browser/api/evaluators/options.js.map +1 -0
  61. package/dist/browser/classic/agents/index.d.ts +21 -2
  62. package/dist/browser/classic/agents/index.d.ts.map +1 -1
  63. package/dist/browser/classic/agents/index.js +10 -1
  64. package/dist/browser/classic/agents/index.js.map +1 -1
  65. package/dist/browser/classic/beta/agents/index.d.ts +2 -14
  66. package/dist/browser/classic/beta/agents/index.d.ts.map +1 -1
  67. package/dist/browser/classic/beta/agents/index.js +2 -10
  68. package/dist/browser/classic/beta/agents/index.js.map +1 -1
  69. package/dist/browser/classic/beta/evaluators/index.d.ts +3 -38
  70. package/dist/browser/classic/beta/evaluators/index.d.ts.map +1 -1
  71. package/dist/browser/classic/beta/evaluators/index.js +2 -18
  72. package/dist/browser/classic/beta/evaluators/index.js.map +1 -1
  73. package/dist/browser/classic/beta/index.d.ts +0 -3
  74. package/dist/browser/classic/beta/index.d.ts.map +1 -1
  75. package/dist/browser/classic/beta/index.js +0 -3
  76. package/dist/browser/classic/beta/index.js.map +1 -1
  77. package/dist/browser/classic/datasets/index.d.ts +13 -2
  78. package/dist/browser/classic/datasets/index.d.ts.map +1 -1
  79. package/dist/browser/classic/datasets/index.js +6 -1
  80. package/dist/browser/classic/datasets/index.js.map +1 -1
  81. package/dist/browser/classic/evaluators/index.d.ts +43 -0
  82. package/dist/browser/classic/evaluators/index.d.ts.map +1 -0
  83. package/dist/browser/classic/evaluators/index.js +19 -0
  84. package/dist/browser/classic/evaluators/index.js.map +1 -0
  85. package/dist/browser/classic/index.d.ts +1 -1
  86. package/dist/browser/classic/index.d.ts.map +1 -1
  87. package/dist/browser/classic/index.js.map +1 -1
  88. package/dist/browser/constants.d.ts +1 -1
  89. package/dist/browser/constants.js +1 -1
  90. package/dist/browser/constants.js.map +1 -1
  91. package/dist/browser/index.d.ts +10 -17
  92. package/dist/browser/index.d.ts.map +1 -1
  93. package/dist/browser/index.js +1 -2
  94. package/dist/browser/index.js.map +1 -1
  95. package/dist/browser/models/index.d.ts +1 -3
  96. package/dist/browser/models/index.d.ts.map +1 -1
  97. package/dist/browser/models/index.js.map +1 -1
  98. package/dist/browser/models/models.d.ts +880 -380
  99. package/dist/browser/models/models.d.ts.map +1 -1
  100. package/dist/browser/models/models.js +1424 -534
  101. package/dist/browser/models/models.js.map +1 -1
  102. package/dist/browser/package.json +1 -1
  103. package/dist/browser/realtime/voiceAgentRealtimeClient.d.ts +24 -2
  104. package/dist/browser/realtime/voiceAgentRealtimeClient.d.ts.map +1 -1
  105. package/dist/browser/realtime/voiceAgentRealtimeClient.js +60 -11
  106. package/dist/browser/realtime/voiceAgentRealtimeClient.js.map +1 -1
  107. package/dist/browser/webSocketTransport.d.ts +1 -0
  108. package/dist/browser/webSocketTransport.d.ts.map +1 -1
  109. package/dist/browser/webSocketTransport.js +5 -13
  110. package/dist/browser/webSocketTransport.js.map +1 -1
  111. package/dist/commonjs/aiProjectClient.d.ts +4 -0
  112. package/dist/commonjs/aiProjectClient.d.ts.map +1 -1
  113. package/dist/commonjs/aiProjectClient.js +4 -0
  114. package/dist/commonjs/aiProjectClient.js.map +2 -2
  115. package/dist/commonjs/api/agents/index.d.ts +2 -2
  116. package/dist/commonjs/api/agents/index.d.ts.map +1 -1
  117. package/dist/commonjs/api/agents/index.js +18 -0
  118. package/dist/commonjs/api/agents/index.js.map +2 -2
  119. package/dist/commonjs/api/agents/operations.d.ts +41 -4
  120. package/dist/commonjs/api/agents/operations.d.ts.map +1 -1
  121. package/dist/commonjs/api/agents/operations.js +415 -19
  122. package/dist/commonjs/api/agents/operations.js.map +2 -2
  123. package/dist/commonjs/api/agents/options.d.ts +163 -93
  124. package/dist/commonjs/api/agents/options.d.ts.map +1 -1
  125. package/dist/commonjs/api/agents/options.js.map +1 -1
  126. package/dist/commonjs/api/beta/agents/index.d.ts +2 -2
  127. package/dist/commonjs/api/beta/agents/index.d.ts.map +1 -1
  128. package/dist/commonjs/api/beta/agents/index.js +2 -12
  129. package/dist/commonjs/api/beta/agents/index.js.map +2 -2
  130. package/dist/commonjs/api/beta/agents/operations.d.ts +2 -24
  131. package/dist/commonjs/api/beta/agents/operations.d.ts.map +1 -1
  132. package/dist/commonjs/api/beta/agents/operations.js +4 -239
  133. package/dist/commonjs/api/beta/agents/operations.js.map +2 -2
  134. package/dist/commonjs/api/beta/agents/options.d.ts +0 -56
  135. package/dist/commonjs/api/beta/agents/options.d.ts.map +1 -1
  136. package/dist/commonjs/api/beta/agents/options.js.map +1 -1
  137. package/dist/commonjs/api/beta/evaluators/index.d.ts +2 -2
  138. package/dist/commonjs/api/beta/evaluators/index.d.ts.map +1 -1
  139. package/dist/commonjs/api/beta/evaluators/index.js +2 -24
  140. package/dist/commonjs/api/beta/evaluators/index.js.map +2 -2
  141. package/dist/commonjs/api/beta/evaluators/operations.d.ts +2 -59
  142. package/dist/commonjs/api/beta/evaluators/operations.d.ts.map +1 -1
  143. package/dist/commonjs/api/beta/evaluators/operations.js +2 -497
  144. package/dist/commonjs/api/beta/evaluators/operations.js.map +2 -2
  145. package/dist/commonjs/api/beta/evaluators/options.d.ts +0 -84
  146. package/dist/commonjs/api/beta/evaluators/options.d.ts.map +1 -1
  147. package/dist/commonjs/api/beta/evaluators/options.js.map +1 -1
  148. package/dist/commonjs/api/datasets/index.d.ts +2 -2
  149. package/dist/commonjs/api/datasets/index.d.ts.map +1 -1
  150. package/dist/commonjs/api/datasets/index.js +10 -0
  151. package/dist/commonjs/api/datasets/index.js.map +2 -2
  152. package/dist/commonjs/api/datasets/operations.d.ts +23 -2
  153. package/dist/commonjs/api/datasets/operations.d.ts.map +1 -1
  154. package/dist/commonjs/api/datasets/operations.js +245 -0
  155. package/dist/commonjs/api/datasets/operations.js.map +2 -2
  156. package/dist/commonjs/api/datasets/options.d.ts +52 -0
  157. package/dist/commonjs/api/datasets/options.d.ts.map +1 -1
  158. package/dist/commonjs/api/datasets/options.js.map +1 -1
  159. package/dist/commonjs/api/evaluators/index.d.ts +3 -0
  160. package/dist/commonjs/api/evaluators/index.d.ts.map +1 -0
  161. package/dist/commonjs/api/{beta/datasets → evaluators}/index.js +17 -5
  162. package/dist/commonjs/api/evaluators/index.js.map +7 -0
  163. package/dist/commonjs/api/evaluators/operations.d.ts +62 -0
  164. package/dist/commonjs/api/evaluators/operations.d.ts.map +1 -0
  165. package/dist/commonjs/api/evaluators/operations.js +505 -0
  166. package/dist/commonjs/api/evaluators/operations.js.map +7 -0
  167. package/dist/commonjs/api/evaluators/options.d.ts +70 -0
  168. package/dist/commonjs/api/evaluators/options.d.ts.map +1 -0
  169. package/dist/commonjs/api/evaluators/options.js.map +7 -0
  170. package/dist/commonjs/classic/agents/index.d.ts +21 -2
  171. package/dist/commonjs/classic/agents/index.d.ts.map +1 -1
  172. package/dist/commonjs/classic/agents/index.js +9 -0
  173. package/dist/commonjs/classic/agents/index.js.map +2 -2
  174. package/dist/commonjs/classic/beta/agents/index.d.ts +2 -14
  175. package/dist/commonjs/classic/beta/agents/index.d.ts.map +1 -1
  176. package/dist/commonjs/classic/beta/agents/index.js +1 -9
  177. package/dist/commonjs/classic/beta/agents/index.js.map +2 -2
  178. package/dist/commonjs/classic/beta/evaluators/index.d.ts +3 -38
  179. package/dist/commonjs/classic/beta/evaluators/index.d.ts.map +1 -1
  180. package/dist/commonjs/classic/beta/evaluators/index.js +2 -18
  181. package/dist/commonjs/classic/beta/evaluators/index.js.map +2 -2
  182. package/dist/commonjs/classic/beta/index.d.ts +0 -3
  183. package/dist/commonjs/classic/beta/index.d.ts.map +1 -1
  184. package/dist/commonjs/classic/beta/index.js +0 -3
  185. package/dist/commonjs/classic/beta/index.js.map +2 -2
  186. package/dist/commonjs/classic/datasets/index.d.ts +13 -2
  187. package/dist/commonjs/classic/datasets/index.d.ts.map +1 -1
  188. package/dist/commonjs/classic/datasets/index.js +5 -0
  189. package/dist/commonjs/classic/datasets/index.js.map +2 -2
  190. package/dist/commonjs/classic/evaluators/index.d.ts +43 -0
  191. package/dist/commonjs/classic/evaluators/index.d.ts.map +1 -0
  192. package/dist/commonjs/classic/{beta/datasets → evaluators}/index.js +15 -14
  193. package/dist/commonjs/classic/evaluators/index.js.map +7 -0
  194. package/dist/commonjs/classic/index.d.ts +1 -1
  195. package/dist/commonjs/classic/index.d.ts.map +1 -1
  196. package/dist/commonjs/classic/index.js.map +1 -1
  197. package/dist/commonjs/constants.d.ts +1 -1
  198. package/dist/commonjs/constants.js +1 -1
  199. package/dist/commonjs/constants.js.map +1 -1
  200. package/dist/commonjs/index.d.ts +10 -17
  201. package/dist/commonjs/index.d.ts.map +1 -1
  202. package/dist/commonjs/index.js +1 -2
  203. package/dist/commonjs/index.js.map +3 -3
  204. package/dist/commonjs/models/index.d.ts +1 -3
  205. package/dist/commonjs/models/index.d.ts.map +1 -1
  206. package/dist/commonjs/models/index.js.map +1 -1
  207. package/dist/commonjs/models/models.d.ts +880 -380
  208. package/dist/commonjs/models/models.d.ts.map +1 -1
  209. package/dist/commonjs/models/models.js +1658 -616
  210. package/dist/commonjs/models/models.js.map +2 -2
  211. package/dist/commonjs/package.json +1 -1
  212. package/dist/commonjs/realtime/voiceAgentRealtimeClient.d.ts +24 -2
  213. package/dist/commonjs/realtime/voiceAgentRealtimeClient.d.ts.map +1 -1
  214. package/dist/commonjs/realtime/voiceAgentRealtimeClient.js +59 -16
  215. package/dist/commonjs/realtime/voiceAgentRealtimeClient.js.map +2 -2
  216. package/dist/commonjs/tsdoc-metadata.json +1 -1
  217. package/dist/esm/aiProjectClient.d.ts +4 -0
  218. package/dist/esm/aiProjectClient.d.ts.map +1 -1
  219. package/dist/esm/aiProjectClient.js +5 -0
  220. package/dist/esm/aiProjectClient.js.map +1 -1
  221. package/dist/esm/api/agents/index.d.ts +2 -2
  222. package/dist/esm/api/agents/index.d.ts.map +1 -1
  223. package/dist/esm/api/agents/index.js +1 -1
  224. package/dist/esm/api/agents/index.js.map +1 -1
  225. package/dist/esm/api/agents/operations.d.ts +41 -4
  226. package/dist/esm/api/agents/operations.d.ts.map +1 -1
  227. package/dist/esm/api/agents/operations.js +322 -21
  228. package/dist/esm/api/agents/operations.js.map +1 -1
  229. package/dist/esm/api/agents/options.d.ts +163 -93
  230. package/dist/esm/api/agents/options.d.ts.map +1 -1
  231. package/dist/esm/api/agents/options.js.map +1 -1
  232. package/dist/esm/api/beta/agents/index.d.ts +2 -2
  233. package/dist/esm/api/beta/agents/index.d.ts.map +1 -1
  234. package/dist/esm/api/beta/agents/index.js +1 -1
  235. package/dist/esm/api/beta/agents/index.js.map +1 -1
  236. package/dist/esm/api/beta/agents/operations.d.ts +2 -24
  237. package/dist/esm/api/beta/agents/operations.d.ts.map +1 -1
  238. package/dist/esm/api/beta/agents/operations.js +3 -185
  239. package/dist/esm/api/beta/agents/operations.js.map +1 -1
  240. package/dist/esm/api/beta/agents/options.d.ts +0 -56
  241. package/dist/esm/api/beta/agents/options.d.ts.map +1 -1
  242. package/dist/esm/api/beta/agents/options.js.map +1 -1
  243. package/dist/esm/api/beta/evaluators/index.d.ts +2 -2
  244. package/dist/esm/api/beta/evaluators/index.d.ts.map +1 -1
  245. package/dist/esm/api/beta/evaluators/index.js +1 -1
  246. package/dist/esm/api/beta/evaluators/index.js.map +1 -1
  247. package/dist/esm/api/beta/evaluators/operations.d.ts +2 -59
  248. package/dist/esm/api/beta/evaluators/operations.d.ts.map +1 -1
  249. package/dist/esm/api/beta/evaluators/operations.js +1 -388
  250. package/dist/esm/api/beta/evaluators/operations.js.map +1 -1
  251. package/dist/esm/api/beta/evaluators/options.d.ts +0 -84
  252. package/dist/esm/api/beta/evaluators/options.d.ts.map +1 -1
  253. package/dist/esm/api/beta/evaluators/options.js.map +1 -1
  254. package/dist/esm/api/datasets/index.d.ts +2 -2
  255. package/dist/esm/api/datasets/index.d.ts.map +1 -1
  256. package/dist/esm/api/datasets/index.js +1 -1
  257. package/dist/esm/api/datasets/index.js.map +1 -1
  258. package/dist/esm/api/datasets/operations.d.ts +23 -2
  259. package/dist/esm/api/datasets/operations.d.ts.map +1 -1
  260. package/dist/esm/api/datasets/operations.js +193 -1
  261. package/dist/esm/api/datasets/operations.js.map +1 -1
  262. package/dist/esm/api/datasets/options.d.ts +52 -0
  263. package/dist/esm/api/datasets/options.d.ts.map +1 -1
  264. package/dist/esm/api/datasets/options.js.map +1 -1
  265. package/dist/esm/api/evaluators/index.d.ts +3 -0
  266. package/dist/esm/api/evaluators/index.d.ts.map +1 -0
  267. package/dist/esm/api/evaluators/index.js +4 -0
  268. package/dist/esm/api/evaluators/index.js.map +1 -0
  269. package/dist/esm/api/evaluators/operations.d.ts +62 -0
  270. package/dist/esm/api/evaluators/operations.d.ts.map +1 -0
  271. package/dist/esm/api/evaluators/operations.js +373 -0
  272. package/dist/esm/api/evaluators/operations.js.map +1 -0
  273. package/dist/esm/api/evaluators/options.d.ts +70 -0
  274. package/dist/esm/api/evaluators/options.d.ts.map +1 -0
  275. package/dist/esm/api/evaluators/options.js.map +1 -0
  276. package/dist/esm/classic/agents/index.d.ts +21 -2
  277. package/dist/esm/classic/agents/index.d.ts.map +1 -1
  278. package/dist/esm/classic/agents/index.js +10 -1
  279. package/dist/esm/classic/agents/index.js.map +1 -1
  280. package/dist/esm/classic/beta/agents/index.d.ts +2 -14
  281. package/dist/esm/classic/beta/agents/index.d.ts.map +1 -1
  282. package/dist/esm/classic/beta/agents/index.js +2 -10
  283. package/dist/esm/classic/beta/agents/index.js.map +1 -1
  284. package/dist/esm/classic/beta/evaluators/index.d.ts +3 -38
  285. package/dist/esm/classic/beta/evaluators/index.d.ts.map +1 -1
  286. package/dist/esm/classic/beta/evaluators/index.js +2 -18
  287. package/dist/esm/classic/beta/evaluators/index.js.map +1 -1
  288. package/dist/esm/classic/beta/index.d.ts +0 -3
  289. package/dist/esm/classic/beta/index.d.ts.map +1 -1
  290. package/dist/esm/classic/beta/index.js +0 -3
  291. package/dist/esm/classic/beta/index.js.map +1 -1
  292. package/dist/esm/classic/datasets/index.d.ts +13 -2
  293. package/dist/esm/classic/datasets/index.d.ts.map +1 -1
  294. package/dist/esm/classic/datasets/index.js +6 -1
  295. package/dist/esm/classic/datasets/index.js.map +1 -1
  296. package/dist/esm/classic/evaluators/index.d.ts +43 -0
  297. package/dist/esm/classic/evaluators/index.d.ts.map +1 -0
  298. package/dist/esm/classic/evaluators/index.js +19 -0
  299. package/dist/esm/classic/evaluators/index.js.map +1 -0
  300. package/dist/esm/classic/index.d.ts +1 -1
  301. package/dist/esm/classic/index.d.ts.map +1 -1
  302. package/dist/esm/classic/index.js.map +1 -1
  303. package/dist/esm/constants.d.ts +1 -1
  304. package/dist/esm/constants.js +1 -1
  305. package/dist/esm/constants.js.map +1 -1
  306. package/dist/esm/index.d.ts +10 -17
  307. package/dist/esm/index.d.ts.map +1 -1
  308. package/dist/esm/index.js +1 -2
  309. package/dist/esm/index.js.map +1 -1
  310. package/dist/esm/models/index.d.ts +1 -3
  311. package/dist/esm/models/index.d.ts.map +1 -1
  312. package/dist/esm/models/index.js.map +1 -1
  313. package/dist/esm/models/models.d.ts +880 -380
  314. package/dist/esm/models/models.d.ts.map +1 -1
  315. package/dist/esm/models/models.js +1424 -534
  316. package/dist/esm/models/models.js.map +1 -1
  317. package/dist/esm/package.json +1 -1
  318. package/dist/esm/realtime/voiceAgentRealtimeClient.d.ts +24 -2
  319. package/dist/esm/realtime/voiceAgentRealtimeClient.d.ts.map +1 -1
  320. package/dist/esm/realtime/voiceAgentRealtimeClient.js +60 -11
  321. package/dist/esm/realtime/voiceAgentRealtimeClient.js.map +1 -1
  322. package/dist/react-native/aiProjectClient.d.ts +4 -0
  323. package/dist/react-native/aiProjectClient.d.ts.map +1 -1
  324. package/dist/react-native/aiProjectClient.js +5 -0
  325. package/dist/react-native/aiProjectClient.js.map +1 -1
  326. package/dist/react-native/api/agents/index.d.ts +2 -2
  327. package/dist/react-native/api/agents/index.d.ts.map +1 -1
  328. package/dist/react-native/api/agents/index.js +1 -1
  329. package/dist/react-native/api/agents/index.js.map +1 -1
  330. package/dist/react-native/api/agents/operations.d.ts +41 -4
  331. package/dist/react-native/api/agents/operations.d.ts.map +1 -1
  332. package/dist/react-native/api/agents/operations.js +322 -21
  333. package/dist/react-native/api/agents/operations.js.map +1 -1
  334. package/dist/react-native/api/agents/options.d.ts +163 -93
  335. package/dist/react-native/api/agents/options.d.ts.map +1 -1
  336. package/dist/react-native/api/agents/options.js.map +1 -1
  337. package/dist/react-native/api/beta/agents/index.d.ts +2 -2
  338. package/dist/react-native/api/beta/agents/index.d.ts.map +1 -1
  339. package/dist/react-native/api/beta/agents/index.js +1 -1
  340. package/dist/react-native/api/beta/agents/index.js.map +1 -1
  341. package/dist/react-native/api/beta/agents/operations.d.ts +2 -24
  342. package/dist/react-native/api/beta/agents/operations.d.ts.map +1 -1
  343. package/dist/react-native/api/beta/agents/operations.js +3 -185
  344. package/dist/react-native/api/beta/agents/operations.js.map +1 -1
  345. package/dist/react-native/api/beta/agents/options.d.ts +0 -56
  346. package/dist/react-native/api/beta/agents/options.d.ts.map +1 -1
  347. package/dist/react-native/api/beta/agents/options.js.map +1 -1
  348. package/dist/react-native/api/beta/evaluators/index.d.ts +2 -2
  349. package/dist/react-native/api/beta/evaluators/index.d.ts.map +1 -1
  350. package/dist/react-native/api/beta/evaluators/index.js +1 -1
  351. package/dist/react-native/api/beta/evaluators/index.js.map +1 -1
  352. package/dist/react-native/api/beta/evaluators/operations.d.ts +2 -59
  353. package/dist/react-native/api/beta/evaluators/operations.d.ts.map +1 -1
  354. package/dist/react-native/api/beta/evaluators/operations.js +1 -388
  355. package/dist/react-native/api/beta/evaluators/operations.js.map +1 -1
  356. package/dist/react-native/api/beta/evaluators/options.d.ts +0 -84
  357. package/dist/react-native/api/beta/evaluators/options.d.ts.map +1 -1
  358. package/dist/react-native/api/beta/evaluators/options.js.map +1 -1
  359. package/dist/react-native/api/datasets/index.d.ts +2 -2
  360. package/dist/react-native/api/datasets/index.d.ts.map +1 -1
  361. package/dist/react-native/api/datasets/index.js +1 -1
  362. package/dist/react-native/api/datasets/index.js.map +1 -1
  363. package/dist/react-native/api/datasets/operations.d.ts +23 -2
  364. package/dist/react-native/api/datasets/operations.d.ts.map +1 -1
  365. package/dist/react-native/api/datasets/operations.js +193 -1
  366. package/dist/react-native/api/datasets/operations.js.map +1 -1
  367. package/dist/react-native/api/datasets/options.d.ts +52 -0
  368. package/dist/react-native/api/datasets/options.d.ts.map +1 -1
  369. package/dist/react-native/api/datasets/options.js.map +1 -1
  370. package/dist/react-native/api/evaluators/index.d.ts +3 -0
  371. package/dist/react-native/api/evaluators/index.d.ts.map +1 -0
  372. package/dist/react-native/api/evaluators/index.js +4 -0
  373. package/dist/react-native/api/evaluators/index.js.map +1 -0
  374. package/dist/react-native/api/evaluators/operations.d.ts +62 -0
  375. package/dist/react-native/api/evaluators/operations.d.ts.map +1 -0
  376. package/dist/react-native/api/evaluators/operations.js +373 -0
  377. package/dist/react-native/api/evaluators/operations.js.map +1 -0
  378. package/dist/react-native/api/evaluators/options.d.ts +70 -0
  379. package/dist/react-native/api/evaluators/options.d.ts.map +1 -0
  380. package/dist/react-native/api/evaluators/options.js.map +1 -0
  381. package/dist/react-native/classic/agents/index.d.ts +21 -2
  382. package/dist/react-native/classic/agents/index.d.ts.map +1 -1
  383. package/dist/react-native/classic/agents/index.js +10 -1
  384. package/dist/react-native/classic/agents/index.js.map +1 -1
  385. package/dist/react-native/classic/beta/agents/index.d.ts +2 -14
  386. package/dist/react-native/classic/beta/agents/index.d.ts.map +1 -1
  387. package/dist/react-native/classic/beta/agents/index.js +2 -10
  388. package/dist/react-native/classic/beta/agents/index.js.map +1 -1
  389. package/dist/react-native/classic/beta/evaluators/index.d.ts +3 -38
  390. package/dist/react-native/classic/beta/evaluators/index.d.ts.map +1 -1
  391. package/dist/react-native/classic/beta/evaluators/index.js +2 -18
  392. package/dist/react-native/classic/beta/evaluators/index.js.map +1 -1
  393. package/dist/react-native/classic/beta/index.d.ts +0 -3
  394. package/dist/react-native/classic/beta/index.d.ts.map +1 -1
  395. package/dist/react-native/classic/beta/index.js +0 -3
  396. package/dist/react-native/classic/beta/index.js.map +1 -1
  397. package/dist/react-native/classic/datasets/index.d.ts +13 -2
  398. package/dist/react-native/classic/datasets/index.d.ts.map +1 -1
  399. package/dist/react-native/classic/datasets/index.js +6 -1
  400. package/dist/react-native/classic/datasets/index.js.map +1 -1
  401. package/dist/react-native/classic/evaluators/index.d.ts +43 -0
  402. package/dist/react-native/classic/evaluators/index.d.ts.map +1 -0
  403. package/dist/react-native/classic/evaluators/index.js +19 -0
  404. package/dist/react-native/classic/evaluators/index.js.map +1 -0
  405. package/dist/react-native/classic/index.d.ts +1 -1
  406. package/dist/react-native/classic/index.d.ts.map +1 -1
  407. package/dist/react-native/classic/index.js.map +1 -1
  408. package/dist/react-native/constants.d.ts +1 -1
  409. package/dist/react-native/constants.js +1 -1
  410. package/dist/react-native/constants.js.map +1 -1
  411. package/dist/react-native/index.d.ts +10 -17
  412. package/dist/react-native/index.d.ts.map +1 -1
  413. package/dist/react-native/index.js +1 -2
  414. package/dist/react-native/index.js.map +1 -1
  415. package/dist/react-native/models/index.d.ts +1 -3
  416. package/dist/react-native/models/index.d.ts.map +1 -1
  417. package/dist/react-native/models/index.js.map +1 -1
  418. package/dist/react-native/models/models.d.ts +880 -380
  419. package/dist/react-native/models/models.d.ts.map +1 -1
  420. package/dist/react-native/models/models.js +1424 -534
  421. package/dist/react-native/models/models.js.map +1 -1
  422. package/dist/react-native/package.json +1 -1
  423. package/dist/react-native/realtime/voiceAgentRealtimeClient.d.ts +24 -2
  424. package/dist/react-native/realtime/voiceAgentRealtimeClient.d.ts.map +1 -1
  425. package/dist/react-native/realtime/voiceAgentRealtimeClient.js +60 -11
  426. package/dist/react-native/realtime/voiceAgentRealtimeClient.js.map +1 -1
  427. package/dist/react-native/webSocketTransport-browser.d.mts +1 -0
  428. package/dist/react-native/webSocketTransport-browser.d.mts.map +1 -1
  429. package/dist/react-native/webSocketTransport-browser.mjs +5 -13
  430. package/dist/react-native/webSocketTransport-browser.mjs.map +1 -1
  431. package/package.json +4 -4
  432. package/dist/browser/api/beta/datasets/index.d.ts +0 -3
  433. package/dist/browser/api/beta/datasets/index.d.ts.map +0 -1
  434. package/dist/browser/api/beta/datasets/index.js +0 -4
  435. package/dist/browser/api/beta/datasets/index.js.map +0 -1
  436. package/dist/browser/api/beta/datasets/operations.d.ts +0 -27
  437. package/dist/browser/api/beta/datasets/operations.d.ts.map +0 -1
  438. package/dist/browser/api/beta/datasets/operations.js +0 -184
  439. package/dist/browser/api/beta/datasets/operations.js.map +0 -1
  440. package/dist/browser/api/beta/datasets/options.d.ts +0 -58
  441. package/dist/browser/api/beta/datasets/options.d.ts.map +0 -1
  442. package/dist/browser/api/beta/datasets/options.js.map +0 -1
  443. package/dist/browser/classic/beta/datasets/index.d.ts +0 -20
  444. package/dist/browser/classic/beta/datasets/index.d.ts.map +0 -1
  445. package/dist/browser/classic/beta/datasets/index.js +0 -18
  446. package/dist/browser/classic/beta/datasets/index.js.map +0 -1
  447. package/dist/commonjs/api/beta/datasets/index.d.ts +0 -3
  448. package/dist/commonjs/api/beta/datasets/index.d.ts.map +0 -1
  449. package/dist/commonjs/api/beta/datasets/index.js.map +0 -7
  450. package/dist/commonjs/api/beta/datasets/operations.d.ts +0 -27
  451. package/dist/commonjs/api/beta/datasets/operations.d.ts.map +0 -1
  452. package/dist/commonjs/api/beta/datasets/operations.js +0 -259
  453. package/dist/commonjs/api/beta/datasets/operations.js.map +0 -7
  454. package/dist/commonjs/api/beta/datasets/options.d.ts +0 -58
  455. package/dist/commonjs/api/beta/datasets/options.d.ts.map +0 -1
  456. package/dist/commonjs/api/beta/datasets/options.js.map +0 -7
  457. package/dist/commonjs/classic/beta/datasets/index.d.ts +0 -20
  458. package/dist/commonjs/classic/beta/datasets/index.d.ts.map +0 -1
  459. package/dist/commonjs/classic/beta/datasets/index.js.map +0 -7
  460. package/dist/esm/api/beta/datasets/index.d.ts +0 -3
  461. package/dist/esm/api/beta/datasets/index.d.ts.map +0 -1
  462. package/dist/esm/api/beta/datasets/index.js +0 -4
  463. package/dist/esm/api/beta/datasets/index.js.map +0 -1
  464. package/dist/esm/api/beta/datasets/operations.d.ts +0 -27
  465. package/dist/esm/api/beta/datasets/operations.d.ts.map +0 -1
  466. package/dist/esm/api/beta/datasets/operations.js +0 -184
  467. package/dist/esm/api/beta/datasets/operations.js.map +0 -1
  468. package/dist/esm/api/beta/datasets/options.d.ts +0 -58
  469. package/dist/esm/api/beta/datasets/options.d.ts.map +0 -1
  470. package/dist/esm/api/beta/datasets/options.js.map +0 -1
  471. package/dist/esm/classic/beta/datasets/index.d.ts +0 -20
  472. package/dist/esm/classic/beta/datasets/index.d.ts.map +0 -1
  473. package/dist/esm/classic/beta/datasets/index.js +0 -18
  474. package/dist/esm/classic/beta/datasets/index.js.map +0 -1
  475. package/dist/react-native/api/beta/datasets/index.d.ts +0 -3
  476. package/dist/react-native/api/beta/datasets/index.d.ts.map +0 -1
  477. package/dist/react-native/api/beta/datasets/index.js +0 -4
  478. package/dist/react-native/api/beta/datasets/index.js.map +0 -1
  479. package/dist/react-native/api/beta/datasets/operations.d.ts +0 -27
  480. package/dist/react-native/api/beta/datasets/operations.d.ts.map +0 -1
  481. package/dist/react-native/api/beta/datasets/operations.js +0 -184
  482. package/dist/react-native/api/beta/datasets/operations.js.map +0 -1
  483. package/dist/react-native/api/beta/datasets/options.d.ts +0 -58
  484. package/dist/react-native/api/beta/datasets/options.d.ts.map +0 -1
  485. package/dist/react-native/api/beta/datasets/options.js.map +0 -1
  486. package/dist/react-native/classic/beta/datasets/index.d.ts +0 -20
  487. package/dist/react-native/classic/beta/datasets/index.d.ts.map +0 -1
  488. package/dist/react-native/classic/beta/datasets/index.js +0 -18
  489. package/dist/react-native/classic/beta/datasets/index.js.map +0 -1
  490. /package/dist/browser/api/{beta/datasets → evaluators}/options.js +0 -0
  491. /package/dist/commonjs/api/{beta/datasets → evaluators}/options.js +0 -0
  492. /package/dist/esm/api/{beta/datasets → evaluators}/options.js +0 -0
  493. /package/dist/react-native/api/{beta/datasets → evaluators}/options.js +0 -0
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azure/ai-projects",
3
- "version": "2.7.1",
3
+ "version": "2.8.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  "./package.json": "./package.json"
@@ -1,7 +1,7 @@
1
1
  import type { AbortSignalLike } from "@azure/abort-controller";
2
2
  import type { TokenCredential } from "@azure/core-auth";
3
3
  import type { OperationOptions } from "@azure-rest/core-client";
4
- import type { VoiceAgentClientEvent, VoiceAgentResponseCreateParams, VoiceAgentSessionUpdateConfig } from "../models/models.js";
4
+ import type { VoiceAgentClientEvent, VoiceAgentResponseCreateParams, VoiceAgentSessionUpdateConfig, VoiceAgentTransport } from "../models/models.js";
5
5
  import type { VoiceAgentRealtimeEvent } from "./events.js";
6
6
  import type { VoiceAgentWebSocketFactory } from "./webSocketTransportLike.js";
7
7
  /** Known values of {@link VoiceAgentConnectionState} reported by a voice-agent realtime connection. */
@@ -40,8 +40,30 @@ export interface VoiceAgentRealtimeClientConnectOptions extends OperationOptions
40
40
  store?: boolean;
41
41
  /** Selects a specific immutable agent version. */
42
42
  agentVersionOverride?: string;
43
- /** Values used to render the agent's structured prompt inputs. */
43
+ /**
44
+ * Selects the transport used for the realtime connection. Defaults to `"websocket"`. Set to
45
+ * `"webrtc"` to negotiate a WebRTC peer connection instead; the caller is responsible for
46
+ * completing the SDP offer/answer exchange using the `rtc.call.sdp.create` and
47
+ * `rtc.call.sdp.created` events (see {@link VoiceAgentRealtimeEvent}).
48
+ */
49
+ transport?: VoiceAgentTransport;
50
+ /**
51
+ * Values used to render the agent's structured prompt inputs.
52
+ * Serialized when `connect()` is called, before authentication.
53
+ */
44
54
  structuredInputs?: Record<string, unknown>;
55
+ /**
56
+ * Additional query parameters for this connection's WebSocket upgrade URL.
57
+ * Provide a plain object, including a null-prototype object.
58
+ * Values override matching endpoint query parameters; `undefined` removes a parameter.
59
+ * Values are URL-encoded automatically. Numbers must be finite.
60
+ * SDK-managed parameters, authentication parameters, and names starting with `h-` are
61
+ * reserved (case-insensitively) and cause a `TypeError`. Use the corresponding typed
62
+ * options for session, version, storage, transport, and structured prompt inputs instead.
63
+ * Both `structured_input` and `structured_inputs` are reserved.
64
+ * Do not include secrets: query parameters can appear in server or proxy logs.
65
+ */
66
+ query?: Readonly<Record<string, string | number | boolean | undefined>>;
45
67
  /** Overrides the client connection timeout in milliseconds. */
46
68
  connectionTimeoutInMs?: number;
47
69
  /** Cancels the connection attempt. */
@@ -1 +1 @@
1
- {"version":3,"file":"voiceAgentRealtimeClient.d.ts","sourceRoot":"","sources":["../../../src/realtime/voiceAgentRealtimeClient.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAGhE,OAAO,KAAK,EAEV,qBAAqB,EACrB,8BAA8B,EAC9B,6BAA6B,EAC9B,MAAM,qBAAqB,CAAC;AAS7B,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,KAAK,EACV,0BAA0B,EAE3B,MAAM,6BAA6B,CAAC;AAKrC,uGAAuG;AACvG,eAAO,MAAM,8BAA8B;;;;;CAKjC,CAAC;AAEX,uEAAuE;AACvE,MAAM,MAAM,yBAAyB,GACnC,CAAC,OAAO,8BAA8B,CAAC,CAAC,MAAM,OAAO,8BAA8B,CAAC,CAAC;AAEvF,0DAA0D;AAC1D,MAAM,MAAM,uCAAuC,GAAG,CACpD,KAAK,EAAE,yBAAyB,EAChC,aAAa,EAAE,yBAAyB,KACrC,IAAI,CAAC;AAEV,oDAAoD;AACpD,MAAM,WAAW,+BAA+B;IAC9C,uEAAuE;IACvE,gBAAgB,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACrC,kDAAkD;IAClD,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,qDAAqD;IACrD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,2DAA2D;IAC3D,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,0BAA0B,CAAC;CAC/C;AAED,mEAAmE;AACnE,MAAM,WAAW,sCAAuC,SAAQ,g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AA+B,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACzE,kDAAkD;IAClD,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACrD,sDAAsD;IACtD,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B;AAED,mFAAmF;AACnF,qBAAa,wBAAwB;IACnC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAkB;IAC7C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAGU;gBAGhC,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,eAAe,EAC3B,OAAO,GAAE,+BAAoC;IAiB/C,mEAAmE;IACtD,OAAO,CAClB,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,sCAA2C,GACnD,OAAO,CAAC,oBAAoB,CAAC;CA4BjC"}
@@ -8,6 +8,23 @@ import { VoiceAgentAuthenticationError, VoiceAgentConnectionError, VoiceAgentPro
8
8
  import { deserializeVoiceAgentServerEvent, serializeVoiceAgentClientEvent } from "./protocol.js";
9
9
  const defaultCredentialScope = "https://ai.azure.com/.default";
10
10
  const voiceAgentsPreview = "VoiceAgents=V1Preview";
11
+ const reservedQueryParameters = new Set([
12
+ "api-version",
13
+ "agent_session_id",
14
+ "store",
15
+ "transport",
16
+ "x-agent-version-override",
17
+ "x-ms-client-sdk",
18
+ "authorization",
19
+ "api-key",
20
+ "foundry_features",
21
+ "foundry-features",
22
+ "client-request-id",
23
+ "x-ms-client-request-id",
24
+ "structured_input",
25
+ "structured_inputs",
26
+ "x-ms-voice-structured-inputs",
27
+ ]);
11
28
  /** Known values of {@link VoiceAgentConnectionState} reported by a voice-agent realtime connection. */
12
29
  export const KnownVoiceAgentConnectionState = {
13
30
  Disconnected: "disconnected",
@@ -40,19 +57,24 @@ export class VoiceAgentRealtimeClient {
40
57
  if (!agentName.trim()) {
41
58
  throw new TypeError("agentName must not be empty.");
42
59
  }
60
+ const url = buildWebSocketUrl(normalizeEndpoint(this.endpoint), agentName, this.options.apiVersion, options);
61
+ const serializedStructuredInputs = options.structuredInputs
62
+ ? JSON.stringify(options.structuredInputs)
63
+ : undefined;
43
64
  const factory = this.options.webSocketFactory ??
44
65
  (await import("../webSocketTransport.js")).createDefaultVoiceAgentWebSocketFactory();
45
- const connection = new VoiceAgentConnectionImpl(normalizeEndpoint(this.endpoint), agentName, this.credential, this.options, options, factory);
66
+ const connection = new VoiceAgentConnectionImpl(url, agentName, this.credential, this.options, options, serializedStructuredInputs, factory);
46
67
  await connection.open();
47
68
  return connection;
48
69
  }
49
70
  }
50
71
  class VoiceAgentConnectionImpl {
51
- endpoint;
72
+ url;
52
73
  agentName;
53
74
  credential;
54
75
  clientOptions;
55
76
  connectOptions;
77
+ serializedStructuredInputs;
56
78
  events;
57
79
  transport;
58
80
  closePromise;
@@ -60,12 +82,13 @@ class VoiceAgentConnectionImpl {
60
82
  currentState = KnownVoiceAgentConnectionState.Disconnected;
61
83
  iteratorStarted = false;
62
84
  finished = false;
63
- constructor(endpoint, agentName, credential, clientOptions, connectOptions, factory) {
64
- this.endpoint = endpoint;
85
+ constructor(url, agentName, credential, clientOptions, connectOptions, serializedStructuredInputs, factory) {
86
+ this.url = url;
65
87
  this.agentName = agentName;
66
88
  this.credential = credential;
67
89
  this.clientOptions = clientOptions;
68
90
  this.connectOptions = connectOptions;
91
+ this.serializedStructuredInputs = serializedStructuredInputs;
69
92
  this.events = new AsyncQueue(10_000, {
70
93
  onOverflow: (error) => this.handleEventQueueOverflow(error),
71
94
  });
@@ -111,9 +134,9 @@ class VoiceAgentConnectionImpl {
111
134
  }
112
135
  try {
113
136
  await this.transport.connect({
114
- url: buildWebSocketUrl(this.endpoint, this.agentName, this.clientOptions.apiVersion, this.connectOptions),
137
+ url: this.url,
115
138
  protocols: ["realtime"],
116
- headers: buildHeaders(token, this.clientOptions, this.connectOptions),
139
+ headers: buildHeaders(token, this.clientOptions, this.serializedStructuredInputs),
117
140
  connectionTimeoutInMs: this.connectOptions.connectionTimeoutInMs ?? this.clientOptions.connectionTimeoutInMs,
118
141
  abortSignal: this.connectOptions.abortSignal,
119
142
  });
@@ -335,12 +358,35 @@ function normalizeEndpoint(endpoint) {
335
358
  if (url.protocol !== "https:") {
336
359
  throw new TypeError("endpoint must use https; a plaintext endpoint would send the bearer token over an unencrypted connection.");
337
360
  }
338
- return url.toString().replace(/\/$/, "");
361
+ return url.toString();
339
362
  }
340
363
  function buildWebSocketUrl(endpoint, agentName, apiVersion, options) {
341
364
  const url = new URL(endpoint);
342
365
  url.protocol = "wss:";
343
- url.pathname = `${url.pathname.replace(/\/$/, "")}/agents/${encodeURIComponent(agentName)}/endpoint/protocols/voice`;
366
+ url.pathname = `${url.pathname.replace(/\/+$/, "")}/agents/${encodeURIComponent(agentName)}/endpoint/protocols/voice`;
367
+ if (options.query !== undefined &&
368
+ (options.query === null ||
369
+ typeof options.query !== "object" ||
370
+ ![Object.prototype, null].includes(Object.getPrototypeOf(options.query)))) {
371
+ throw new TypeError("query must be a record of query parameters.");
372
+ }
373
+ for (const [name, value] of Object.entries(options.query ?? {})) {
374
+ const normalizedName = name.toLowerCase();
375
+ if (reservedQueryParameters.has(normalizedName) || normalizedName.startsWith("h-")) {
376
+ throw new TypeError(`Query parameter "${name}" is reserved; use the SDK's typed options.`);
377
+ }
378
+ if (value === undefined) {
379
+ url.searchParams.delete(name);
380
+ }
381
+ else if (typeof value === "string" ||
382
+ typeof value === "boolean" ||
383
+ (typeof value === "number" && Number.isFinite(value))) {
384
+ url.searchParams.set(name, String(value));
385
+ }
386
+ else {
387
+ throw new TypeError(`Query parameter "${name}" must be a string, boolean, finite number, or undefined.`);
388
+ }
389
+ }
344
390
  url.searchParams.set("api-version", apiVersion);
345
391
  url.searchParams.set("x-ms-client-sdk", `azsdk-js-ai-projects/${SDK_VERSION}`);
346
392
  if (options.agentSessionId) {
@@ -352,9 +398,12 @@ function buildWebSocketUrl(endpoint, agentName, apiVersion, options) {
352
398
  if (options.agentVersionOverride) {
353
399
  url.searchParams.set("x-agent-version-override", options.agentVersionOverride);
354
400
  }
401
+ if (options.transport) {
402
+ url.searchParams.set("transport", options.transport);
403
+ }
355
404
  return url.toString();
356
405
  }
357
- function buildHeaders(token, clientOptions, connectOptions) {
406
+ function buildHeaders(token, clientOptions, serializedStructuredInputs) {
358
407
  const sdkUserAgent = `azsdk-js-ai-projects/${SDK_VERSION}`;
359
408
  const headers = {
360
409
  authorization: `Bearer ${token}`,
@@ -365,8 +414,8 @@ function buildHeaders(token, clientOptions, connectOptions) {
365
414
  ? `${clientOptions.userAgentPrefix} ${sdkUserAgent}`
366
415
  : sdkUserAgent,
367
416
  };
368
- if (connectOptions.structuredInputs) {
369
- headers["x-ms-voice-structured-inputs"] = JSON.stringify(connectOptions.structuredInputs);
417
+ if (serializedStructuredInputs !== undefined) {
418
+ headers["x-ms-voice-structured-inputs"] = serializedStructuredInputs;
370
419
  }
371
420
  return headers;
372
421
  }
@@ -1 +1 @@
1
- {"version":3,"file":"voiceAgentRealtimeClient.js","sourceRoot":"","sources":["../../../src/realtime/voiceAgentRealtimeClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAKlC,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAO9C,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EACL,6BAA6B,EAC7B,yBAAyB,EACzB,uBAAuB,GACxB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,gCAAgC,EAAE,8BAA8B,EAAE,MAAM,eAAe,CAAC;AAOjG,MAAM,sBAAsB,GAAG,+BAA+B,CAAC;AAC/D,MAAM,kBAAkB,GAAG,uBAAuB,CA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AI,GAAG,IAAI,CAAC,GAAG,EAAE,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAC5F,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { AbortSignalLike } from \"@azure/abort-controller\";\nimport type { TokenCredential } from \"@azure/core-auth\";\nimport type { OperationOptions } from \"@azure-rest/core-client\";\nimport { uint8ArrayToString } from \"@azure/core-util\";\nimport { SDK_VERSION } from \"../constants.js\";\nimport type {\n RealtimeConversationItemUnion,\n VoiceAgentClientEvent,\n VoiceAgentResponseCreateParams,\n VoiceAgentSessionUpdateConfig,\n} from \"../models/models.js\";\nimport { logger } from \"../logger.js\";\nimport { AsyncQueue } from \"./asyncQueue.js\";\nimport {\n VoiceAgentAuthenticationError,\n VoiceAgentConnectionError,\n VoiceAgentProtocolError,\n} from \"./errors.js\";\nimport { deserializeVoiceAgentServerEvent, serializeVoiceAgentClientEvent } from \"./protocol.js\";\nimport type { VoiceAgentRealtimeEvent } from \"./events.js\";\nimport type {\n VoiceAgentWebSocketFactory,\n VoiceAgentWebSocketTransport,\n} from \"./webSocketTransportLike.js\";\n\nconst defaultCredentialScope = \"https://ai.azure.com/.default\";\nconst voiceAgentsPreview = \"VoiceAgents=V1Preview\";\n\n/** Known values of {@link VoiceAgentConnectionState} reported by a voice-agent realtime connection. */\nexport const KnownVoiceAgentConnectionState = {\n Disconnected: \"disconnected\",\n Connecting: \"connecting\",\n Connected: \"connected\",\n Closing: \"closing\",\n} as const;\n\n/** Connection states reported by a voice-agent realtime connection. */\nexport type VoiceAgentConnectionState =\n (typeof KnownVoiceAgentConnectionState)[keyof typeof KnownVoiceAgentConnectionState];\n\n/** Called when a voice-agent connection changes state. */\nexport type VoiceAgentConnectionStateChangedHandler = (\n state: VoiceAgentConnectionState,\n previousState: VoiceAgentConnectionState,\n) => void;\n\n/** Options for the Voice Agents realtime client. */\nexport interface VoiceAgentRealtimeClientOptions {\n /** Microsoft Entra scopes used to acquire a WebSocket access token. */\n credentialScopes?: string | string[];\n /** Default connection timeout in milliseconds. */\n connectionTimeoutInMs?: number;\n /** API version sent during the WebSocket upgrade. */\n apiVersion?: string;\n /** Prefix added to the SDK user-agent value in Node.js. */\n userAgentPrefix?: string;\n /**\n * Overrides the transport used to establish the realtime WebSocket connection. Defaults to the\n * platform transport (`ws` in Node.js, the browser's native `WebSocket` in browsers/React Native).\n * Provide a custom factory to customize connection establishment.\n */\n webSocketFactory?: VoiceAgentWebSocketFactory;\n}\n\n/** Options for connecting the realtime client to a voice agent. */\nexport interface VoiceAgentRealtimeClientConnectOptions extends OperationOptions {\n /** Identifier used to correlate the voice session. */\n agentSessionId?: string;\n /** Overrides whether the conversation created by this session is persisted. */\n store?: boolean;\n /** Selects a specific immutable agent version. */\n agentVersionOverride?: string;\n /** Values used to render the agent's structured prompt inputs. */\n structuredInputs?: Record<string, unknown>;\n /** Overrides the client connection timeout in milliseconds. */\n connectionTimeoutInMs?: number;\n /** Cancels the connection attempt. */\n abortSignal?: AbortSignalLike;\n /** Receives connection-state transitions. */\n onConnectionStateChange?: VoiceAgentConnectionStateChangedHandler;\n}\n\n/** Result supplied when a voice-agent connection closes. */\nexport interface VoiceAgentCloseResult {\n /** WebSocket close code. */\n code: number;\n /** WebSocket close reason. */\n reason: string;\n /** Whether the peer completed a normal WebSocket close handshake. */\n wasClean: boolean;\n /** Transport or protocol error associated with the close, if any. */\n error?: Error;\n}\n\n/** Options shared by realtime send operations. */\nexport interface VoiceAgentSendOptions extends OperationOptions {}\n\n/** Options shared by operations that build a protocol event on the caller's behalf. */\nexport interface VoiceAgentEventOptions extends VoiceAgentSendOptions {\n /** Client-generated event identifier. */\n eventId?: string;\n}\n\n/** Options shared by operations that add a conversation item and, by default, request a response. */\nexport interface VoiceAgentSendItemOptions extends VoiceAgentEventOptions {\n /** Whether to request a response after adding the item. Defaults to true. */\n createResponse?: boolean;\n}\n\n/** Options for sending text input. */\nexport interface VoiceAgentSendTextOptions extends VoiceAgentSendItemOptions {\n /** Item after which the new text item is inserted. */\n previousItemId?: string;\n}\n\n/** Options for returning a function result. */\nexport interface VoiceAgentSendToolOutputOptions extends VoiceAgentSendItemOptions {}\n\n/** Options for updating the live session. */\nexport interface VoiceAgentSessionUpdateOptions extends VoiceAgentEventOptions {}\n\n/** Options for creating a response. */\nexport interface VoiceAgentResponseOptions extends VoiceAgentEventOptions {\n /** Response-specific configuration. */\n response?: VoiceAgentResponseCreateParams;\n}\n\n/** Options for cancelling a response. */\nexport interface VoiceAgentCancelResponseOptions extends VoiceAgentEventOptions {\n /** Specific response to cancel. The active default-conversation response is used when omitted. */\n responseId?: string;\n}\n\n/**\n * A connected, bidirectional voice-agent stream.\n *\n * Supports exactly one `for await` iteration over server events; a second attempt throws.\n * Exiting the loop early (`break`, `return`, or an uncaught error in the loop body) closes\n * the connection as a side effect.\n * Unrecognized server event types are delivered as {@link VoiceAgentUnknownEvent} without\n * interrupting the stream. Malformed events still fail the iteration with a protocol error.\n */\nexport interface VoiceAgentConnection extends AsyncIterable<VoiceAgentRealtimeEvent> {\n /** Current connection state. */\n readonly state: VoiceAgentConnectionState;\n /** Resolves once the connection is closed. */\n readonly closed: Promise<VoiceAgentCloseResult>;\n /** Sends any generated client protocol event. */\n sendEvent(event: VoiceAgentClientEvent, options?: VoiceAgentSendOptions): Promise<void>;\n /** Updates supported live-session settings. */\n configureSession(\n session: VoiceAgentSessionUpdateConfig,\n options?: VoiceAgentSessionUpdateOptions,\n ): Promise<void>;\n /** Adds a user text item and, by default, requests a response. */\n sendText(text: string, options?: VoiceAgentSendTextOptions): Promise<void>;\n /** Appends base64-encoded audio bytes to the input buffer. */\n sendAudio(audio: Uint8Array | ArrayBuffer, options?: VoiceAgentEventOptions): Promise<void>;\n /** Commits buffered input audio. */\n commitAudio(options?: VoiceAgentEventOptions): Promise<void>;\n /** Clears buffered input audio. */\n clearInputAudio(options?: VoiceAgentEventOptions): Promise<void>;\n /** Clears pending output audio at the service. */\n clearOutputAudio(options?: VoiceAgentEventOptions): Promise<void>;\n /** Returns a client-executed function result to the agent. */\n sendToolOutput(\n callId: string,\n output: string,\n options?: VoiceAgentSendToolOutputOptions,\n ): Promise<void>;\n /** Requests a new response. */\n requestResponse(options?: VoiceAgentResponseOptions): Promise<void>;\n /** Cancels an in-progress response. */\n cancelResponse(options?: VoiceAgentCancelResponseOptions): Promise<void>;\n /** Gracefully closes the WebSocket connection. */\n close(code?: number, reason?: string): Promise<void>;\n /** Releases the connection. Equivalent to close(). */\n dispose(): Promise<void>;\n}\n\n/** Client for establishing realtime sessions with managed Foundry voice agents. */\nexport class VoiceAgentRealtimeClient {\n private readonly endpoint: string;\n private readonly credential: TokenCredential;\n private readonly options: Required<\n Pick<VoiceAgentRealtimeClientOptions, \"connectionTimeoutInMs\" | \"apiVersion\">\n > &\n VoiceAgentRealtimeClientOptions;\n\n public constructor(\n endpoint: string,\n credential: TokenCredential,\n options: VoiceAgentRealtimeClientOptions = {},\n ) {\n // Endpoint validation (https-only) is deferred to connect() so that merely constructing an\n // AIProjectClient (which eagerly creates this client) doesn't reject callers who intentionally\n // use an insecure local endpoint for the REST surface and never touch realtime connections.\n if (!endpoint.trim()) {\n throw new TypeError(\"endpoint must not be empty.\");\n }\n this.endpoint = endpoint;\n this.credential = credential;\n this.options = {\n ...options,\n connectionTimeoutInMs: options.connectionTimeoutInMs ?? 30_000,\n apiVersion: options.apiVersion ?? \"v1\",\n };\n }\n\n /** Establishes a WebSocket connection to a managed voice agent. */\n public async connect(\n agentName: string,\n options: VoiceAgentRealtimeClientConnectOptions = {},\n ): Promise<VoiceAgentConnection> {\n if (!agentName.trim()) {\n throw new TypeError(\"agentName must not be empty.\");\n }\n const factory =\n this.options.webSocketFactory ??\n (await import(\"#platform/webSocketTransport\")).createDefaultVoiceAgentWebSocketFactory();\n const connection = new VoiceAgentConnectionImpl(\n normalizeEndpoint(this.endpoint),\n agentName,\n this.credential,\n this.options,\n options,\n factory,\n );\n await connection.open();\n return connection;\n }\n}\n\nclass VoiceAgentConnectionImpl implements VoiceAgentConnection {\n private readonly events: AsyncQueue<VoiceAgentRealtimeEvent>;\n private readonly transport: VoiceAgentWebSocketTransport;\n private readonly closePromise: Promise<VoiceAgentCloseResult>;\n private resolveClose!: (result: VoiceAgentCloseResult) => void;\n private currentState: VoiceAgentConnectionState = KnownVoiceAgentConnectionState.Disconnected;\n private iteratorStarted = false;\n private finished = false;\n\n public constructor(\n private readonly endpoint: string,\n private readonly agentName: string,\n private readonly credential: TokenCredential,\n private readonly clientOptions: VoiceAgentRealtimeClientOptions & {\n connectionTimeoutInMs: number;\n apiVersion: string;\n },\n private readonly connectOptions: VoiceAgentRealtimeClientConnectOptions,\n factory: VoiceAgentWebSocketFactory,\n ) {\n this.events = new AsyncQueue<VoiceAgentRealtimeEvent>(10_000, {\n onOverflow: (error) => this.handleEventQueueOverflow(error),\n });\n this.transport = factory.create();\n this.closePromise = new Promise<VoiceAgentCloseResult>((resolve) => {\n this.resolveClose = resolve;\n });\n this.transport.setHandlers({\n onMessage: (data) => this.handleMessage(data),\n onClose: (code, reason, wasClean) => this.handleClose(code, reason, wasClean),\n onError: (error) => this.handleTransportError(error),\n });\n }\n\n public get state(): VoiceAgentConnectionState {\n return this.currentState;\n }\n\n public get closed(): Promise<VoiceAgentCloseResult> {\n return this.closePromise;\n }\n\n public async open(): Promise<void> {\n this.setState(KnownVoiceAgentConnectionState.Connecting);\n let token: string;\n try {\n const accessToken = await this.credential.getToken(\n this.clientOptions.credentialScopes ?? defaultCredentialScope,\n { abortSignal: this.connectOptions.abortSignal },\n );\n if (!accessToken) {\n throw new VoiceAgentAuthenticationError(\"The credential returned no access token.\");\n }\n token = accessToken.token;\n } catch (error) {\n if (this.connectOptions.abortSignal?.aborted) {\n const cancelledError = new VoiceAgentConnectionError(\n \"Voice-agent connection was cancelled.\",\n \"operationCancelled\",\n { cause: error },\n );\n this.finish(1006, cancelledError.message, false, cancelledError);\n throw cancelledError;\n }\n const authenticationError =\n error instanceof VoiceAgentAuthenticationError\n ? error\n : new VoiceAgentAuthenticationError(\"Failed to acquire a Voice Agents access token.\", {\n cause: error,\n });\n this.finish(1006, authenticationError.message, false, authenticationError);\n throw authenticationError;\n }\n\n try {\n await this.transport.connect({\n url: buildWebSocketUrl(\n this.endpoint,\n this.agentName,\n this.clientOptions.apiVersion,\n this.connectOptions,\n ),\n protocols: [\"realtime\"],\n headers: buildHeaders(token, this.clientOptions, this.connectOptions),\n connectionTimeoutInMs:\n this.connectOptions.connectionTimeoutInMs ?? this.clientOptions.connectionTimeoutInMs,\n abortSignal: this.connectOptions.abortSignal,\n });\n this.setState(KnownVoiceAgentConnectionState.Connected);\n logger.info(\"Connected to voice agent\", { agentName: this.agentName });\n } catch (error) {\n const cancelled = this.connectOptions.abortSignal?.aborted === true;\n const connectionError = new VoiceAgentConnectionError(\n cancelled\n ? \"Voice-agent connection was cancelled.\"\n : \"Failed to connect to the voice agent.\",\n cancelled ? \"operationCancelled\" : \"connectionFailed\",\n { cause: error },\n );\n this.finish(1006, connectionError.message, false, connectionError);\n throw connectionError;\n }\n }\n\n public async sendEvent(\n event: VoiceAgentClientEvent,\n options: VoiceAgentSendOptions = {},\n ): Promise<void> {\n if (this.state !== KnownVoiceAgentConnectionState.Connected) {\n throw new VoiceAgentConnectionError(\n `Cannot send while the connection is ${this.state}.`,\n \"invalidState\",\n );\n }\n if (options.abortSignal?.aborted) {\n throw new VoiceAgentConnectionError(\"Send operation was cancelled.\", \"operationCancelled\");\n }\n\n try {\n await this.transport.send(serializeVoiceAgentClientEvent(event), options.abortSignal);\n } catch (error) {\n if (error instanceof VoiceAgentProtocolError) {\n throw error;\n }\n throw new VoiceAgentConnectionError(\"Failed to send a voice-agent event.\", \"sendFailed\", {\n cause: error,\n });\n }\n }\n\n public configureSession(\n session: VoiceAgentSessionUpdateConfig,\n options: VoiceAgentSessionUpdateOptions = {},\n ): Promise<void> {\n return this.sendEvent({ type: \"session.update\", event_id: options.eventId, session }, options);\n }\n\n public async sendText(text: string, options: VoiceAgentSendTextOptions = {}): Promise<void> {\n await this.sendEvent(\n {\n type: \"conversation.item.create\",\n event_id: options.eventId,\n previous_item_id: options.previousItemId,\n // `RealtimeConversationItemUnion` no longer enumerates a \"message\" item in the generated\n // models, but the wire protocol still accepts this shape; see the TypeSpec regeneration\n // report for details.\n item: {\n type: \"message\",\n role: \"user\",\n content: [{ type: \"input_text\", text }],\n } as unknown as RealtimeConversationItemUnion,\n },\n options,\n );\n if (options.createResponse !== false) {\n await this.requestResponse({ abortSignal: options.abortSignal });\n }\n }\n\n public sendAudio(\n audio: Uint8Array | ArrayBuffer,\n options: VoiceAgentEventOptions = {},\n ): Promise<void> {\n const bytes = audio instanceof Uint8Array ? audio : new Uint8Array(audio);\n return this.sendEvent(\n {\n type: \"input_audio_buffer.append\",\n event_id: options.eventId,\n audio: uint8ArrayToString(bytes, \"base64\"),\n },\n options,\n );\n }\n\n public commitAudio(options: VoiceAgentEventOptions = {}): Promise<void> {\n return this.sendEvent(\n { type: \"input_audio_buffer.commit\", event_id: options.eventId },\n options,\n );\n }\n\n public clearInputAudio(options: VoiceAgentEventOptions = {}): Promise<void> {\n return this.sendEvent({ type: \"input_audio_buffer.clear\", event_id: options.eventId }, options);\n }\n\n public clearOutputAudio(options: VoiceAgentEventOptions = {}): Promise<void> {\n return this.sendEvent(\n { type: \"output_audio_buffer.clear\", event_id: options.eventId },\n options,\n );\n }\n\n public async sendToolOutput(\n callId: string,\n output: string,\n options: VoiceAgentSendToolOutputOptions = {},\n ): Promise<void> {\n await this.sendEvent(\n {\n type: \"conversation.item.create\",\n event_id: options.eventId,\n item: { type: \"function_call_output\", call_id: callId, output },\n },\n options,\n );\n if (options.createResponse !== false) {\n await this.requestResponse({ abortSignal: options.abortSignal });\n }\n }\n\n public requestResponse(options: VoiceAgentResponseOptions = {}): Promise<void> {\n return this.sendEvent(\n { type: \"response.create\", event_id: options.eventId, response: options.response },\n options,\n );\n }\n\n public cancelResponse(options: VoiceAgentCancelResponseOptions = {}): Promise<void> {\n return this.sendEvent(\n { type: \"response.cancel\", event_id: options.eventId, response_id: options.responseId },\n options,\n );\n }\n\n public async close(\n code = 1000,\n reason = \"Client closed the voice-agent connection.\",\n ): Promise<void> {\n if (\n this.state === KnownVoiceAgentConnectionState.Disconnected ||\n this.state === KnownVoiceAgentConnectionState.Closing\n ) {\n await this.closed;\n return;\n }\n this.setState(KnownVoiceAgentConnectionState.Closing);\n try {\n await this.transport.close(code, reason);\n } finally {\n this.finish(code, reason, false);\n }\n }\n\n public dispose(): Promise<void> {\n return this.close();\n }\n\n public async *[Symbol.asyncIterator](): AsyncIterator<VoiceAgentRealtimeEvent> {\n if (this.iteratorStarted) {\n throw new VoiceAgentConnectionError(\n \"A voice-agent connection supports one active event iterator.\",\n \"invalidState\",\n );\n }\n this.iteratorStarted = true;\n try {\n while (true) {\n const result = await this.events.next();\n if (result.done) {\n return;\n }\n yield result.value;\n }\n } finally {\n if (this.state === KnownVoiceAgentConnectionState.Connected) {\n await this.close();\n }\n }\n }\n\n private handleMessage(data: string | ArrayBuffer): void {\n try {\n this.events.enqueue(deserializeVoiceAgentServerEvent(data));\n } catch (error) {\n const protocolError =\n error instanceof VoiceAgentProtocolError\n ? error\n : new VoiceAgentProtocolError(\"Failed to process a voice-agent event.\", { cause: error });\n // finish() closes the transport itself, so no additional close is needed here.\n this.finish(1002, protocolError.message, false, protocolError);\n }\n }\n\n private handleEventQueueOverflow(cause: Error): void {\n if (this.finished) {\n return;\n }\n const error = new VoiceAgentConnectionError(cause.message, \"connectionClosed\", {\n cause,\n });\n this.finish(1006, error.message, false, error);\n }\n\n private handleClose(code: number, reason: string, wasClean: boolean): void {\n if (this.finished) {\n return;\n }\n if (wasClean || this.state === KnownVoiceAgentConnectionState.Closing) {\n this.finish(code, reason, wasClean);\n } else {\n const error = new VoiceAgentConnectionError(\n `Voice-agent connection closed unexpectedly (${code}${reason ? `: ${reason}` : \"\"}).`,\n \"connectionClosed\",\n { closeCode: code },\n );\n this.finish(code, reason, false, error);\n }\n }\n\n private handleTransportError(cause: Error): void {\n if (this.finished) {\n return;\n }\n const error = new VoiceAgentConnectionError(\n \"Voice-agent WebSocket transport failed.\",\n \"connectionClosed\",\n {\n cause,\n },\n );\n this.finish(1006, cause.message, false, error);\n }\n\n private finish(code: number, reason: string, wasClean: boolean, error?: Error): void {\n if (this.finished) {\n return;\n }\n this.finished = true;\n if (error) {\n this.events.fail(error);\n } else {\n this.events.close();\n }\n this.setState(KnownVoiceAgentConnectionState.Disconnected);\n this.resolveClose({ code, reason, wasClean, error });\n logger.info(\"Voice-agent connection closed\", { code, reason, wasClean });\n // Ensure the socket never outlives the connection, even on paths that never closed it\n // themselves. Not awaited: finish() is synchronous because its callers are.\n void this.closeTransportQuietly(code, reason);\n }\n\n /**\n * Closes the transport, logging rather than rejecting: this is best-effort cleanup running after\n * the connection has already settled. A no-op if the transport is already closed.\n */\n private async closeTransportQuietly(code: number, reason: string): Promise<void> {\n try {\n await this.transport.close(code, reason);\n } catch (error) {\n logger.warning(\"Failed to close the voice-agent transport\", { error });\n }\n }\n\n private setState(state: VoiceAgentConnectionState): void {\n if (state === this.currentState) {\n return;\n }\n const previousState = this.currentState;\n this.currentState = state;\n try {\n this.connectOptions.onConnectionStateChange?.(state, previousState);\n } catch (error) {\n // A throwing caller callback must never interrupt connection lifecycle/cleanup.\n logger.warning(\"onConnectionStateChange callback threw an error\", { error });\n }\n }\n}\n\nfunction normalizeEndpoint(endpoint: string): string {\n const normalized = endpoint.trim();\n if (!normalized) {\n throw new TypeError(\"endpoint must not be empty.\");\n }\n const url = new URL(normalized.includes(\"://\") ? normalized : `https://${normalized}`);\n if (url.protocol !== \"https:\") {\n throw new TypeError(\n \"endpoint must use https; a plaintext endpoint would send the bearer token over an unencrypted connection.\",\n );\n }\n return url.toString().replace(/\\/$/, \"\");\n}\n\nfunction buildWebSocketUrl(\n endpoint: string,\n agentName: string,\n apiVersion: string,\n options: VoiceAgentRealtimeClientConnectOptions,\n): string {\n const url = new URL(endpoint);\n url.protocol = \"wss:\";\n url.pathname = `${url.pathname.replace(/\\/$/, \"\")}/agents/${encodeURIComponent(agentName)}/endpoint/protocols/voice`;\n url.searchParams.set(\"api-version\", apiVersion);\n url.searchParams.set(\"x-ms-client-sdk\", `azsdk-js-ai-projects/${SDK_VERSION}`);\n if (options.agentSessionId) {\n url.searchParams.set(\"agent_session_id\", options.agentSessionId);\n }\n if (options.store !== undefined) {\n url.searchParams.set(\"store\", String(options.store));\n }\n if (options.agentVersionOverride) {\n url.searchParams.set(\"x-agent-version-override\", options.agentVersionOverride);\n }\n return url.toString();\n}\n\nfunction buildHeaders(\n token: string,\n clientOptions: VoiceAgentRealtimeClientOptions,\n connectOptions: VoiceAgentRealtimeClientConnectOptions,\n): Record<string, string> {\n const sdkUserAgent = `azsdk-js-ai-projects/${SDK_VERSION}`;\n const headers: Record<string, string> = {\n authorization: `Bearer ${token}`,\n \"foundry-features\": voiceAgentsPreview,\n \"x-ms-client-request-id\": createRequestId(),\n \"x-ms-client-sdk\": sdkUserAgent,\n \"user-agent\": clientOptions.userAgentPrefix\n ? `${clientOptions.userAgentPrefix} ${sdkUserAgent}`\n : sdkUserAgent,\n };\n if (connectOptions.structuredInputs) {\n headers[\"x-ms-voice-structured-inputs\"] = JSON.stringify(connectOptions.structuredInputs);\n }\n return headers;\n}\n\nfunction createRequestId(): string {\n return (\n globalThis.crypto?.randomUUID?.() ?? `${Date.now()}-${Math.random().toString(36).slice(2)}`\n );\n}\n"]}
1
+ {"version":3,"file":"voiceAgentRealtimeClient.js","sourceRoot":"","sources":["../../../src/realtime/voiceAgentRealtimeClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAKlC,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AA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C;IACD,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;QACtB,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,WAAW,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;IACvD,CAAC;IACD,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAC;AACxB,CAAC;AAED,SAAS,YAAY,CACnB,KAAa,EACb,aAA8C,EAC9C,0BAA8C;IAE9C,MAAM,YAAY,GAAG,wBAAwB,WAAW,EAAE,CAAC;IAC3D,MAAM,OAAO,GAA2B;QACtC,aAAa,EAAE,UAAU,KAAK,EAAE;QAChC,kBAAkB,EAAE,kBAAkB;QACtC,wBAAwB,EAAE,eAAe,EAAE;QAC3C,iBAAiB,EAAE,YAAY;QAC/B,YAAY,EAAE,aAAa,CAAC,eAAe;YACzC,CAAC,CAAC,GAAG,aAAa,CAAC,eAAe,IAAI,YAAY,EAAE;YACpD,CAAC,CAAC,YAAY;KACjB,CAAC;IACF,IAAI,0BAA0B,KAAK,SAAS,EAAE,CAAC;QAC7C,OAAO,CAAC,8BAA8B,CAAC,GAAG,0BAA0B,CAAC;IACvE,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,SAAS,eAAe;IACtB,OAAO,CACL,UAAU,CAAC,MAAM,EAAE,UAAU,EAAE,EAAE,IAAI,GAAG,IAAI,CAAC,GAAG,EAAE,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAC5F,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { AbortSignalLike } from \"@azure/abort-controller\";\nimport type { TokenCredential } from \"@azure/core-auth\";\nimport type { OperationOptions } from \"@azure-rest/core-client\";\nimport { uint8ArrayToString } from \"@azure/core-util\";\nimport { SDK_VERSION } from \"../constants.js\";\nimport type {\n RealtimeConversationItemUnion,\n VoiceAgentClientEvent,\n VoiceAgentResponseCreateParams,\n VoiceAgentSessionUpdateConfig,\n VoiceAgentTransport,\n} from \"../models/models.js\";\nimport { logger } from \"../logger.js\";\nimport { AsyncQueue } from \"./asyncQueue.js\";\nimport {\n VoiceAgentAuthenticationError,\n VoiceAgentConnectionError,\n VoiceAgentProtocolError,\n} from \"./errors.js\";\nimport { deserializeVoiceAgentServerEvent, serializeVoiceAgentClientEvent } from \"./protocol.js\";\nimport type { VoiceAgentRealtimeEvent } from \"./events.js\";\nimport type {\n VoiceAgentWebSocketFactory,\n VoiceAgentWebSocketTransport,\n} from \"./webSocketTransportLike.js\";\n\nconst defaultCredentialScope = \"https://ai.azure.com/.default\";\nconst voiceAgentsPreview = \"VoiceAgents=V1Preview\";\nconst reservedQueryParameters = new Set([\n \"api-version\",\n \"agent_session_id\",\n \"store\",\n \"transport\",\n \"x-agent-version-override\",\n \"x-ms-client-sdk\",\n \"authorization\",\n \"api-key\",\n \"foundry_features\",\n \"foundry-features\",\n \"client-request-id\",\n \"x-ms-client-request-id\",\n \"structured_input\",\n \"structured_inputs\",\n \"x-ms-voice-structured-inputs\",\n]);\n\n/** Known values of {@link VoiceAgentConnectionState} reported by a voice-agent realtime connection. */\nexport const KnownVoiceAgentConnectionState = {\n Disconnected: \"disconnected\",\n Connecting: \"connecting\",\n Connected: \"connected\",\n Closing: \"closing\",\n} as const;\n\n/** Connection states reported by a voice-agent realtime connection. */\nexport type VoiceAgentConnectionState =\n (typeof KnownVoiceAgentConnectionState)[keyof typeof KnownVoiceAgentConnectionState];\n\n/** Called when a voice-agent connection changes state. */\nexport type VoiceAgentConnectionStateChangedHandler = (\n state: VoiceAgentConnectionState,\n previousState: VoiceAgentConnectionState,\n) => void;\n\n/** Options for the Voice Agents realtime client. */\nexport interface VoiceAgentRealtimeClientOptions {\n /** Microsoft Entra scopes used to acquire a WebSocket access token. */\n credentialScopes?: string | string[];\n /** Default connection timeout in milliseconds. */\n connectionTimeoutInMs?: number;\n /** API version sent during the WebSocket upgrade. */\n apiVersion?: string;\n /** Prefix added to the SDK user-agent value in Node.js. */\n userAgentPrefix?: string;\n /**\n * Overrides the transport used to establish the realtime WebSocket connection. Defaults to the\n * platform transport (`ws` in Node.js, the browser's native `WebSocket` in browsers/React Native).\n * Provide a custom factory to customize connection establishment.\n */\n webSocketFactory?: VoiceAgentWebSocketFactory;\n}\n\n/** Options for connecting the realtime client to a voice agent. */\nexport interface VoiceAgentRealtimeClientConnectOptions extends OperationOptions {\n /** Identifier used to correlate the voice session. */\n agentSessionId?: string;\n /** Overrides whether the conversation created by this session is persisted. */\n store?: boolean;\n /** Selects a specific immutable agent version. */\n agentVersionOverride?: string;\n /**\n * Selects the transport used for the realtime connection. Defaults to `\"websocket\"`. Set to\n * `\"webrtc\"` to negotiate a WebRTC peer connection instead; the caller is responsible for\n * completing the SDP offer/answer exchange using the `rtc.call.sdp.create` and\n * `rtc.call.sdp.created` events (see {@link VoiceAgentRealtimeEvent}).\n */\n transport?: VoiceAgentTransport;\n /**\n * Values used to render the agent's structured prompt inputs.\n * Serialized when `connect()` is called, before authentication.\n */\n structuredInputs?: Record<string, unknown>;\n /**\n * Additional query parameters for this connection's WebSocket upgrade URL.\n * Provide a plain object, including a null-prototype object.\n * Values override matching endpoint query parameters; `undefined` removes a parameter.\n * Values are URL-encoded automatically. Numbers must be finite.\n * SDK-managed parameters, authentication parameters, and names starting with `h-` are\n * reserved (case-insensitively) and cause a `TypeError`. Use the corresponding typed\n * options for session, version, storage, transport, and structured prompt inputs instead.\n * Both `structured_input` and `structured_inputs` are reserved.\n * Do not include secrets: query parameters can appear in server or proxy logs.\n */\n query?: Readonly<Record<string, string | number | boolean | undefined>>;\n /** Overrides the client connection timeout in milliseconds. */\n connectionTimeoutInMs?: number;\n /** Cancels the connection attempt. */\n abortSignal?: AbortSignalLike;\n /** Receives connection-state transitions. */\n onConnectionStateChange?: VoiceAgentConnectionStateChangedHandler;\n}\n\n/** Result supplied when a voice-agent connection closes. */\nexport interface VoiceAgentCloseResult {\n /** WebSocket close code. */\n code: number;\n /** WebSocket close reason. */\n reason: string;\n /** Whether the peer completed a normal WebSocket close handshake. */\n wasClean: boolean;\n /** Transport or protocol error associated with the close, if any. */\n error?: Error;\n}\n\n/** Options shared by realtime send operations. */\nexport interface VoiceAgentSendOptions extends OperationOptions {}\n\n/** Options shared by operations that build a protocol event on the caller's behalf. */\nexport interface VoiceAgentEventOptions extends VoiceAgentSendOptions {\n /** Client-generated event identifier. */\n eventId?: string;\n}\n\n/** Options shared by operations that add a conversation item and, by default, request a response. */\nexport interface VoiceAgentSendItemOptions extends VoiceAgentEventOptions {\n /** Whether to request a response after adding the item. Defaults to true. */\n createResponse?: boolean;\n}\n\n/** Options for sending text input. */\nexport interface VoiceAgentSendTextOptions extends VoiceAgentSendItemOptions {\n /** Item after which the new text item is inserted. */\n previousItemId?: string;\n}\n\n/** Options for returning a function result. */\nexport interface VoiceAgentSendToolOutputOptions extends VoiceAgentSendItemOptions {}\n\n/** Options for updating the live session. */\nexport interface VoiceAgentSessionUpdateOptions extends VoiceAgentEventOptions {}\n\n/** Options for creating a response. */\nexport interface VoiceAgentResponseOptions extends VoiceAgentEventOptions {\n /** Response-specific configuration. */\n response?: VoiceAgentResponseCreateParams;\n}\n\n/** Options for cancelling a response. */\nexport interface VoiceAgentCancelResponseOptions extends VoiceAgentEventOptions {\n /** Specific response to cancel. The active default-conversation response is used when omitted. */\n responseId?: string;\n}\n\n/**\n * A connected, bidirectional voice-agent stream.\n *\n * Supports exactly one `for await` iteration over server events; a second attempt throws.\n * Exiting the loop early (`break`, `return`, or an uncaught error in the loop body) closes\n * the connection as a side effect.\n * Unrecognized server event types are delivered as {@link VoiceAgentUnknownEvent} without\n * interrupting the stream. Malformed events still fail the iteration with a protocol error.\n */\nexport interface VoiceAgentConnection extends AsyncIterable<VoiceAgentRealtimeEvent> {\n /** Current connection state. */\n readonly state: VoiceAgentConnectionState;\n /** Resolves once the connection is closed. */\n readonly closed: Promise<VoiceAgentCloseResult>;\n /** Sends any generated client protocol event. */\n sendEvent(event: VoiceAgentClientEvent, options?: VoiceAgentSendOptions): Promise<void>;\n /** Updates supported live-session settings. */\n configureSession(\n session: VoiceAgentSessionUpdateConfig,\n options?: VoiceAgentSessionUpdateOptions,\n ): Promise<void>;\n /** Adds a user text item and, by default, requests a response. */\n sendText(text: string, options?: VoiceAgentSendTextOptions): Promise<void>;\n /** Appends base64-encoded audio bytes to the input buffer. */\n sendAudio(audio: Uint8Array | ArrayBuffer, options?: VoiceAgentEventOptions): Promise<void>;\n /** Commits buffered input audio. */\n commitAudio(options?: VoiceAgentEventOptions): Promise<void>;\n /** Clears buffered input audio. */\n clearInputAudio(options?: VoiceAgentEventOptions): Promise<void>;\n /** Clears pending output audio at the service. */\n clearOutputAudio(options?: VoiceAgentEventOptions): Promise<void>;\n /** Returns a client-executed function result to the agent. */\n sendToolOutput(\n callId: string,\n output: string,\n options?: VoiceAgentSendToolOutputOptions,\n ): Promise<void>;\n /** Requests a new response. */\n requestResponse(options?: VoiceAgentResponseOptions): Promise<void>;\n /** Cancels an in-progress response. */\n cancelResponse(options?: VoiceAgentCancelResponseOptions): Promise<void>;\n /** Gracefully closes the WebSocket connection. */\n close(code?: number, reason?: string): Promise<void>;\n /** Releases the connection. Equivalent to close(). */\n dispose(): Promise<void>;\n}\n\n/** Client for establishing realtime sessions with managed Foundry voice agents. */\nexport class VoiceAgentRealtimeClient {\n private readonly endpoint: string;\n private readonly credential: TokenCredential;\n private readonly options: Required<\n Pick<VoiceAgentRealtimeClientOptions, \"connectionTimeoutInMs\" | \"apiVersion\">\n > &\n VoiceAgentRealtimeClientOptions;\n\n public constructor(\n endpoint: string,\n credential: TokenCredential,\n options: VoiceAgentRealtimeClientOptions = {},\n ) {\n // Endpoint validation (https-only) is deferred to connect() so that merely constructing an\n // AIProjectClient (which eagerly creates this client) doesn't reject callers who intentionally\n // use an insecure local endpoint for the REST surface and never touch realtime connections.\n if (!endpoint.trim()) {\n throw new TypeError(\"endpoint must not be empty.\");\n }\n this.endpoint = endpoint;\n this.credential = credential;\n this.options = {\n ...options,\n connectionTimeoutInMs: options.connectionTimeoutInMs ?? 30_000,\n apiVersion: options.apiVersion ?? \"v1\",\n };\n }\n\n /** Establishes a WebSocket connection to a managed voice agent. */\n public async connect(\n agentName: string,\n options: VoiceAgentRealtimeClientConnectOptions = {},\n ): Promise<VoiceAgentConnection> {\n if (!agentName.trim()) {\n throw new TypeError(\"agentName must not be empty.\");\n }\n const url = buildWebSocketUrl(\n normalizeEndpoint(this.endpoint),\n agentName,\n this.options.apiVersion,\n options,\n );\n const serializedStructuredInputs = options.structuredInputs\n ? JSON.stringify(options.structuredInputs)\n : undefined;\n const factory =\n this.options.webSocketFactory ??\n (await import(\"#platform/webSocketTransport\")).createDefaultVoiceAgentWebSocketFactory();\n const connection = new VoiceAgentConnectionImpl(\n url,\n agentName,\n this.credential,\n this.options,\n options,\n serializedStructuredInputs,\n factory,\n );\n await connection.open();\n return connection;\n }\n}\n\nclass VoiceAgentConnectionImpl implements VoiceAgentConnection {\n private readonly events: AsyncQueue<VoiceAgentRealtimeEvent>;\n private readonly transport: VoiceAgentWebSocketTransport;\n private readonly closePromise: Promise<VoiceAgentCloseResult>;\n private resolveClose!: (result: VoiceAgentCloseResult) => void;\n private currentState: VoiceAgentConnectionState = KnownVoiceAgentConnectionState.Disconnected;\n private iteratorStarted = false;\n private finished = false;\n\n public constructor(\n private readonly url: string,\n private readonly agentName: string,\n private readonly credential: TokenCredential,\n private readonly clientOptions: VoiceAgentRealtimeClientOptions & {\n connectionTimeoutInMs: number;\n apiVersion: string;\n },\n private readonly connectOptions: VoiceAgentRealtimeClientConnectOptions,\n private readonly serializedStructuredInputs: string | undefined,\n factory: VoiceAgentWebSocketFactory,\n ) {\n this.events = new AsyncQueue<VoiceAgentRealtimeEvent>(10_000, {\n onOverflow: (error) => this.handleEventQueueOverflow(error),\n });\n this.transport = factory.create();\n this.closePromise = new Promise<VoiceAgentCloseResult>((resolve) => {\n this.resolveClose = resolve;\n });\n this.transport.setHandlers({\n onMessage: (data) => this.handleMessage(data),\n onClose: (code, reason, wasClean) => this.handleClose(code, reason, wasClean),\n onError: (error) => this.handleTransportError(error),\n });\n }\n\n public get state(): VoiceAgentConnectionState {\n return this.currentState;\n }\n\n public get closed(): Promise<VoiceAgentCloseResult> {\n return this.closePromise;\n }\n\n public async open(): Promise<void> {\n this.setState(KnownVoiceAgentConnectionState.Connecting);\n let token: string;\n try {\n const accessToken = await this.credential.getToken(\n this.clientOptions.credentialScopes ?? defaultCredentialScope,\n { abortSignal: this.connectOptions.abortSignal },\n );\n if (!accessToken) {\n throw new VoiceAgentAuthenticationError(\"The credential returned no access token.\");\n }\n token = accessToken.token;\n } catch (error) {\n if (this.connectOptions.abortSignal?.aborted) {\n const cancelledError = new VoiceAgentConnectionError(\n \"Voice-agent connection was cancelled.\",\n \"operationCancelled\",\n { cause: error },\n );\n this.finish(1006, cancelledError.message, false, cancelledError);\n throw cancelledError;\n }\n const authenticationError =\n error instanceof VoiceAgentAuthenticationError\n ? error\n : new VoiceAgentAuthenticationError(\"Failed to acquire a Voice Agents access token.\", {\n cause: error,\n });\n this.finish(1006, authenticationError.message, false, authenticationError);\n throw authenticationError;\n }\n\n try {\n await this.transport.connect({\n url: this.url,\n protocols: [\"realtime\"],\n headers: buildHeaders(token, this.clientOptions, this.serializedStructuredInputs),\n connectionTimeoutInMs:\n this.connectOptions.connectionTimeoutInMs ?? this.clientOptions.connectionTimeoutInMs,\n abortSignal: this.connectOptions.abortSignal,\n });\n this.setState(KnownVoiceAgentConnectionState.Connected);\n logger.info(\"Connected to voice agent\", { agentName: this.agentName });\n } catch (error) {\n const cancelled = this.connectOptions.abortSignal?.aborted === true;\n const connectionError = new VoiceAgentConnectionError(\n cancelled\n ? \"Voice-agent connection was cancelled.\"\n : \"Failed to connect to the voice agent.\",\n cancelled ? \"operationCancelled\" : \"connectionFailed\",\n { cause: error },\n );\n this.finish(1006, connectionError.message, false, connectionError);\n throw connectionError;\n }\n }\n\n public async sendEvent(\n event: VoiceAgentClientEvent,\n options: VoiceAgentSendOptions = {},\n ): Promise<void> {\n if (this.state !== KnownVoiceAgentConnectionState.Connected) {\n throw new VoiceAgentConnectionError(\n `Cannot send while the connection is ${this.state}.`,\n \"invalidState\",\n );\n }\n if (options.abortSignal?.aborted) {\n throw new VoiceAgentConnectionError(\"Send operation was cancelled.\", \"operationCancelled\");\n }\n\n try {\n await this.transport.send(serializeVoiceAgentClientEvent(event), options.abortSignal);\n } catch (error) {\n if (error instanceof VoiceAgentProtocolError) {\n throw error;\n }\n throw new VoiceAgentConnectionError(\"Failed to send a voice-agent event.\", \"sendFailed\", {\n cause: error,\n });\n }\n }\n\n public configureSession(\n session: VoiceAgentSessionUpdateConfig,\n options: VoiceAgentSessionUpdateOptions = {},\n ): Promise<void> {\n return this.sendEvent({ type: \"session.update\", event_id: options.eventId, session }, options);\n }\n\n public async sendText(text: string, options: VoiceAgentSendTextOptions = {}): Promise<void> {\n await this.sendEvent(\n {\n type: \"conversation.item.create\",\n event_id: options.eventId,\n previous_item_id: options.previousItemId,\n // `RealtimeConversationItemUnion` no longer enumerates a \"message\" item in the generated\n // models, but the wire protocol still accepts this shape; see the TypeSpec regeneration\n // report for details.\n item: {\n type: \"message\",\n role: \"user\",\n content: [{ type: \"input_text\", text }],\n } as unknown as RealtimeConversationItemUnion,\n },\n options,\n );\n if (options.createResponse !== false) {\n await this.requestResponse({ abortSignal: options.abortSignal });\n }\n }\n\n public sendAudio(\n audio: Uint8Array | ArrayBuffer,\n options: VoiceAgentEventOptions = {},\n ): Promise<void> {\n const bytes = audio instanceof Uint8Array ? audio : new Uint8Array(audio);\n return this.sendEvent(\n {\n type: \"input_audio_buffer.append\",\n event_id: options.eventId,\n audio: uint8ArrayToString(bytes, \"base64\"),\n },\n options,\n );\n }\n\n public commitAudio(options: VoiceAgentEventOptions = {}): Promise<void> {\n return this.sendEvent(\n { type: \"input_audio_buffer.commit\", event_id: options.eventId },\n options,\n );\n }\n\n public clearInputAudio(options: VoiceAgentEventOptions = {}): Promise<void> {\n return this.sendEvent({ type: \"input_audio_buffer.clear\", event_id: options.eventId }, options);\n }\n\n public clearOutputAudio(options: VoiceAgentEventOptions = {}): Promise<void> {\n return this.sendEvent(\n { type: \"output_audio_buffer.clear\", event_id: options.eventId },\n options,\n );\n }\n\n public async sendToolOutput(\n callId: string,\n output: string,\n options: VoiceAgentSendToolOutputOptions = {},\n ): Promise<void> {\n await this.sendEvent(\n {\n type: \"conversation.item.create\",\n event_id: options.eventId,\n item: { type: \"function_call_output\", call_id: callId, output },\n },\n options,\n );\n if (options.createResponse !== false) {\n await this.requestResponse({ abortSignal: options.abortSignal });\n }\n }\n\n public requestResponse(options: VoiceAgentResponseOptions = {}): Promise<void> {\n return this.sendEvent(\n { type: \"response.create\", event_id: options.eventId, response: options.response },\n options,\n );\n }\n\n public cancelResponse(options: VoiceAgentCancelResponseOptions = {}): Promise<void> {\n return this.sendEvent(\n { type: \"response.cancel\", event_id: options.eventId, response_id: options.responseId },\n options,\n );\n }\n\n public async close(\n code = 1000,\n reason = \"Client closed the voice-agent connection.\",\n ): Promise<void> {\n if (\n this.state === KnownVoiceAgentConnectionState.Disconnected ||\n this.state === KnownVoiceAgentConnectionState.Closing\n ) {\n await this.closed;\n return;\n }\n this.setState(KnownVoiceAgentConnectionState.Closing);\n try {\n await this.transport.close(code, reason);\n } finally {\n this.finish(code, reason, false);\n }\n }\n\n public dispose(): Promise<void> {\n return this.close();\n }\n\n public async *[Symbol.asyncIterator](): AsyncIterator<VoiceAgentRealtimeEvent> {\n if (this.iteratorStarted) {\n throw new VoiceAgentConnectionError(\n \"A voice-agent connection supports one active event iterator.\",\n \"invalidState\",\n );\n }\n this.iteratorStarted = true;\n try {\n while (true) {\n const result = await this.events.next();\n if (result.done) {\n return;\n }\n yield result.value;\n }\n } finally {\n if (this.state === KnownVoiceAgentConnectionState.Connected) {\n await this.close();\n }\n }\n }\n\n private handleMessage(data: string | ArrayBuffer): void {\n try {\n this.events.enqueue(deserializeVoiceAgentServerEvent(data));\n } catch (error) {\n const protocolError =\n error instanceof VoiceAgentProtocolError\n ? error\n : new VoiceAgentProtocolError(\"Failed to process a voice-agent event.\", { cause: error });\n // finish() closes the transport itself, so no additional close is needed here.\n this.finish(1002, protocolError.message, false, protocolError);\n }\n }\n\n private handleEventQueueOverflow(cause: Error): void {\n if (this.finished) {\n return;\n }\n const error = new VoiceAgentConnectionError(cause.message, \"connectionClosed\", {\n cause,\n });\n this.finish(1006, error.message, false, error);\n }\n\n private handleClose(code: number, reason: string, wasClean: boolean): void {\n if (this.finished) {\n return;\n }\n if (wasClean || this.state === KnownVoiceAgentConnectionState.Closing) {\n this.finish(code, reason, wasClean);\n } else {\n const error = new VoiceAgentConnectionError(\n `Voice-agent connection closed unexpectedly (${code}${reason ? `: ${reason}` : \"\"}).`,\n \"connectionClosed\",\n { closeCode: code },\n );\n this.finish(code, reason, false, error);\n }\n }\n\n private handleTransportError(cause: Error): void {\n if (this.finished) {\n return;\n }\n const error = new VoiceAgentConnectionError(\n \"Voice-agent WebSocket transport failed.\",\n \"connectionClosed\",\n {\n cause,\n },\n );\n this.finish(1006, cause.message, false, error);\n }\n\n private finish(code: number, reason: string, wasClean: boolean, error?: Error): void {\n if (this.finished) {\n return;\n }\n this.finished = true;\n if (error) {\n this.events.fail(error);\n } else {\n this.events.close();\n }\n this.setState(KnownVoiceAgentConnectionState.Disconnected);\n this.resolveClose({ code, reason, wasClean, error });\n logger.info(\"Voice-agent connection closed\", { code, reason, wasClean });\n // Ensure the socket never outlives the connection, even on paths that never closed it\n // themselves. Not awaited: finish() is synchronous because its callers are.\n void this.closeTransportQuietly(code, reason);\n }\n\n /**\n * Closes the transport, logging rather than rejecting: this is best-effort cleanup running after\n * the connection has already settled. A no-op if the transport is already closed.\n */\n private async closeTransportQuietly(code: number, reason: string): Promise<void> {\n try {\n await this.transport.close(code, reason);\n } catch (error) {\n logger.warning(\"Failed to close the voice-agent transport\", { error });\n }\n }\n\n private setState(state: VoiceAgentConnectionState): void {\n if (state === this.currentState) {\n return;\n }\n const previousState = this.currentState;\n this.currentState = state;\n try {\n this.connectOptions.onConnectionStateChange?.(state, previousState);\n } catch (error) {\n // A throwing caller callback must never interrupt connection lifecycle/cleanup.\n logger.warning(\"onConnectionStateChange callback threw an error\", { error });\n }\n }\n}\n\nfunction normalizeEndpoint(endpoint: string): string {\n const normalized = endpoint.trim();\n if (!normalized) {\n throw new TypeError(\"endpoint must not be empty.\");\n }\n const url = new URL(normalized.includes(\"://\") ? normalized : `https://${normalized}`);\n if (url.protocol !== \"https:\") {\n throw new TypeError(\n \"endpoint must use https; a plaintext endpoint would send the bearer token over an unencrypted connection.\",\n );\n }\n return url.toString();\n}\n\nfunction buildWebSocketUrl(\n endpoint: string,\n agentName: string,\n apiVersion: string,\n options: VoiceAgentRealtimeClientConnectOptions,\n): string {\n const url = new URL(endpoint);\n url.protocol = \"wss:\";\n url.pathname = `${url.pathname.replace(/\\/+$/, \"\")}/agents/${encodeURIComponent(agentName)}/endpoint/protocols/voice`;\n if (\n options.query !== undefined &&\n (options.query === null ||\n typeof options.query !== \"object\" ||\n ![Object.prototype, null].includes(Object.getPrototypeOf(options.query)))\n ) {\n throw new TypeError(\"query must be a record of query parameters.\");\n }\n for (const [name, value] of Object.entries(options.query ?? {})) {\n const normalizedName = name.toLowerCase();\n if (reservedQueryParameters.has(normalizedName) || normalizedName.startsWith(\"h-\")) {\n throw new TypeError(`Query parameter \"${name}\" is reserved; use the SDK's typed options.`);\n }\n if (value === undefined) {\n url.searchParams.delete(name);\n } else if (\n typeof value === \"string\" ||\n typeof value === \"boolean\" ||\n (typeof value === \"number\" && Number.isFinite(value))\n ) {\n url.searchParams.set(name, String(value));\n } else {\n throw new TypeError(\n `Query parameter \"${name}\" must be a string, boolean, finite number, or undefined.`,\n );\n }\n }\n url.searchParams.set(\"api-version\", apiVersion);\n url.searchParams.set(\"x-ms-client-sdk\", `azsdk-js-ai-projects/${SDK_VERSION}`);\n if (options.agentSessionId) {\n url.searchParams.set(\"agent_session_id\", options.agentSessionId);\n }\n if (options.store !== undefined) {\n url.searchParams.set(\"store\", String(options.store));\n }\n if (options.agentVersionOverride) {\n url.searchParams.set(\"x-agent-version-override\", options.agentVersionOverride);\n }\n if (options.transport) {\n url.searchParams.set(\"transport\", options.transport);\n }\n return url.toString();\n}\n\nfunction buildHeaders(\n token: string,\n clientOptions: VoiceAgentRealtimeClientOptions,\n serializedStructuredInputs: string | undefined,\n): Record<string, string> {\n const sdkUserAgent = `azsdk-js-ai-projects/${SDK_VERSION}`;\n const headers: Record<string, string> = {\n authorization: `Bearer ${token}`,\n \"foundry-features\": voiceAgentsPreview,\n \"x-ms-client-request-id\": createRequestId(),\n \"x-ms-client-sdk\": sdkUserAgent,\n \"user-agent\": clientOptions.userAgentPrefix\n ? `${clientOptions.userAgentPrefix} ${sdkUserAgent}`\n : sdkUserAgent,\n };\n if (serializedStructuredInputs !== undefined) {\n headers[\"x-ms-voice-structured-inputs\"] = serializedStructuredInputs;\n }\n return headers;\n}\n\nfunction createRequestId(): string {\n return (\n globalThis.crypto?.randomUUID?.() ?? `${Date.now()}-${Math.random().toString(36).slice(2)}`\n );\n}\n"]}
@@ -6,6 +6,7 @@ import type { VoiceAgentWebSocketConnectOptions, VoiceAgentWebSocketFactory, Voi
6
6
  * Browsers cannot set an `Authorization` header on a WebSocket upgrade request. This transport sends
7
7
  * the Microsoft Entra bearer token as the `authorization.bearer.<token>` WebSocket subprotocol,
8
8
  * which the service converts back into an `Authorization` header before forwarding the request.
9
+ * Only preview features, client request IDs, and structured inputs are mapped to query parameters.
9
10
  */
10
11
  export declare class BrowserWebSocketTransport implements VoiceAgentWebSocketTransport {
11
12
  private webSocket?;
@@ -1 +1 @@
1
- {"version":3,"file":"webSocketTransport-browser.d.mts","sourceRoot":"","sources":["../../src/webSocketTransport-browser.mts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAy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;;GAOG;AACH,qBAAa,yBAA0B,YAAW,4BAA4B;IAC5E,OAAO,CAAC,SAAS,CAAC,CAAY;IAC9B,OAAO,CAAC,QAAQ,CAAC,CAA8B;IAC/C,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAS;IAC1C,OAAO,CAAC,YAAY,CAAoC;IAIxD,OAAO,CAAC,aAAa,CAAoC;gBAEtC,gBAAgB,SAAQ;IAIpC,WAAW,CAAC,QAAQ,EAAE,2BAA2B,GAAG,IAAI;IAIlD,OAAO,CAAC,OAAO,EAAE,iCAAiC,GAAG,OAAO,CAAC,IAAI,CAAC;IAoClE,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAU7E,2FAA2F;YAC7E,cAAc;IAQ5B,iFAAiF;YACnE,YAAY;YAWZ,qBAAqB;IActB,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAyBhE;AA6DD,gBAAgB;AAChB,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAgBpF;AAsBD,gBAAgB;AAChB,wBAAgB,uCAAuC,IAAI,0BAA0B,CAEpF"}
@@ -7,6 +7,7 @@ import { logger } from "./logger.js";
7
7
  * Browsers cannot set an `Authorization` header on a WebSocket upgrade request. This transport sends
8
8
  * the Microsoft Entra bearer token as the `authorization.bearer.<token>` WebSocket subprotocol,
9
9
  * which the service converts back into an `Authorization` header before forwarding the request.
10
+ * Only preview features, client request IDs, and structured inputs are mapped to query parameters.
10
11
  */
11
12
  export class BrowserWebSocketTransport {
12
13
  webSocket;
@@ -171,29 +172,20 @@ async function waitForClose(webSocket, closeNotified, timeoutInMs) {
171
172
  /** @internal */
172
173
  export function addHeadersToUrl(url, headers) {
173
174
  const target = new URL(url);
174
- let foundryFeatures;
175
175
  for (const [name, value] of Object.entries(headers)) {
176
176
  switch (name.toLowerCase()) {
177
- case "authorization":
178
- break;
179
177
  case "foundry-features":
180
- foundryFeatures = value;
178
+ target.searchParams.set("foundry_features", value);
181
179
  break;
182
180
  case "x-ms-client-request-id":
183
181
  target.searchParams.set("client-request-id", value);
184
182
  break;
185
- default:
186
- target.searchParams.set(`h-${name.toLowerCase()}`, value);
183
+ case "x-ms-voice-structured-inputs":
184
+ target.searchParams.set("structured_input", value);
187
185
  break;
188
186
  }
189
187
  }
190
- const targetUrl = target.toString();
191
- if (foundryFeatures === undefined) {
192
- return targetUrl;
193
- }
194
- const separator = target.search ? "&" : "?";
195
- const encodedFeatures = encodeURIComponent(foundryFeatures).replace(/%3D/gi, "=");
196
- return `${targetUrl}${separator}foundry_features=${encodedFeatures}`;
188
+ return target.toString();
197
189
  }
198
190
  function addCredentialSubprotocol(protocols, headers) {
199
191
  const authorization = Object.entries(headers).find(([name]) => name.toLowerCase() === "authorization")?.[1];
@@ -1 +1 @@
1
- {"version":3,"file":"webSocketTransport-browser.mjs","sourceRoot":"","sources":["../../src/webSocketTransport-browser.mts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAerC;;;;;;GAMG;AACH,MAAM,OAAO,yBAAyB;IAC5B,SAAS,CAAa;IACtB,QAAQ,CAA+B;IAC9B,gBAAgB,CAAS;IAClC,YAAY,GAAkB,OAAO,CAAC,OAAO,EAAE,CAAC;IACxD,sFAAsF;IACtF,0FAA0F;IAC1F,gGAAgG;IACxF,aAAa,GAAkB,OAAO,CAAC,OAAO,EAAE,CAAC;IAEzD,YAAmB,gBAAgB,GAAG,KAAK;QACzC,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;IAC3C,CAAC;IAEM,WAAW,CAAC,QAAqC;QACtD,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IA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SAAS,CAAC;IAC/B,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,YAAY,CAAC,IAAI,aAAa,CAAC,MAAM,KAAK,YAAY,CAAC,MAAM,EAAE,CAAC;QAC5F,MAAM,IAAI,KAAK,CAAC,2EAA2E,CAAC,CAAC;IAC/F,CAAC;IACD,OAAO,CAAC,GAAG,SAAS,EAAE,wBAAwB,aAAa,CAAC,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAC5F,CAAC;AAED,MAAM,uBAAuB;IACpB,MAAM;QACX,OAAO,IAAI,yBAAyB,EAAE,CAAC;IACzC,CAAC;CACF;AAED,gBAAgB;AAChB,MAAM,UAAU,uCAAuC;IACrD,OAAO,IAAI,uBAAuB,EAAE,CAAC;AACvC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { AbortSignalLike } from \"@azure/abort-controller\";\nimport { logger } from \"./logger.js\";\nimport type {\n VoiceAgentWebSocketConnectOptions,\n VoiceAgentWebSocketFactory,\n VoiceAgentWebSocketHandlers,\n VoiceAgentWebSocketTransport,\n} from \"./realtime/webSocketTransportLike.js\";\n\n/** The `CloseEvent` fields this transport forwards; the DOM lib is not in scope here. */\ninterface NativeCloseEvent {\n code: number;\n reason: string;\n wasClean: boolean;\n}\n\n/**\n * Default browser transport for the Voice Agents realtime client.\n *\n * Browsers cannot set an `Authorization` header on a WebSocket upgrade request. This transport sends\n * the Microsoft Entra bearer token as the `authorization.bearer.<token>` WebSocket subprotocol,\n * which the service converts back into an `Authorization` header before forwarding the request.\n */\nexport class BrowserWebSocketTransport implements VoiceAgentWebSocketTransport {\n private webSocket?: WebSocket;\n private handlers?: VoiceAgentWebSocketHandlers;\n private readonly closeTimeoutInMs: number;\n private messageChain: Promise<void> = Promise.resolve();\n // Resolves once `onClose` has actually been invoked for the current connection (after\n // `messageChain` drains). `close()` awaits this - not just the raw native \"close\" event -\n // so it never resolves before the caller observes the authoritative close code/reason/wasClean.\n private closeNotified: Promise<void> = Promise.resolve();\n\n public constructor(closeTimeoutInMs = 5_000) {\n this.closeTimeoutInMs = closeTimeoutInMs;\n }\n\n public setHandlers(handlers: VoiceAgentWebSocketHandlers): void {\n this.handlers = handlers;\n }\n\n public async connect(options: VoiceAgentWebSocketConnectOptions): Promise<void> {\n if (options.abortSignal?.aborted) {\n throw new Error(\"WebSocket connection was cancelled.\");\n }\n const protocols = addCredentialSubprotocol(options.protocols, options.headers);\n const url = addHeadersToUrl(options.url, options.headers);\n\n let notifyClosed: () => void = () => {};\n this.closeNotified = new Promise<void>((resolve) => {\n notifyClosed = resolve;\n });\n\n const webSocket = new WebSocket(url, protocols);\n webSocket.binaryType = \"arraybuffer\";\n this.webSocket = webSocket;\n\n // These forward events for the lifetime of the connection, independent of whether connect()\n // itself is still pending.\n webSocket.addEventListener(\"message\", (event: MessageEvent) => {\n // Chain handling so an async Blob conversion can never let a later message be delivered to\n // the protocol parser out of arrival order.\n this.messageChain = this.deliverMessage(this.messageChain, event.data);\n });\n webSocket.addEventListener(\"close\", (event) => void this.deliverClose(event, notifyClosed));\n webSocket.addEventListener(\"error\", () => {\n this.handlers?.onError(new Error(\"WebSocket connection failed.\"));\n });\n\n try {\n await waitForOpen(webSocket, options.connectionTimeoutInMs, options.abortSignal);\n } catch (error) {\n webSocket.close();\n throw error;\n }\n }\n\n public async send(data: string, abortSignal?: AbortSignalLike): Promise<void> {\n if (!this.webSocket || this.webSocket.readyState !== WebSocket.OPEN) {\n throw new Error(\"WebSocket is not connected.\");\n }\n if (abortSignal?.aborted) {\n throw new Error(\"WebSocket send was cancelled.\");\n }\n this.webSocket.send(data);\n }\n\n /** Chains `data` behind `previous` so an async `Blob` conversion cannot reorder events. */\n private async deliverMessage(\n previous: Promise<void>,\n data: string | ArrayBuffer | Blob,\n ): Promise<void> {\n await previous;\n await this.handleIncomingMessage(data);\n }\n\n /** Reports the close only after every earlier message has reached the parser. */\n private async deliverClose(event: Event, notifyClosed: () => void): Promise<void> {\n const { code, reason, wasClean } = event as unknown as NativeCloseEvent;\n try {\n await this.messageChain;\n } catch {\n // handleIncomingMessage already reported the failure through onError.\n }\n this.handlers?.onClose(code, reason, wasClean);\n notifyClosed();\n }\n\n private async handleIncomingMessage(data: string | ArrayBuffer | Blob): Promise<void> {\n if (typeof data === \"string\" || data instanceof ArrayBuffer) {\n this.handlers?.onMessage(data);\n return;\n }\n if (data instanceof Blob) {\n try {\n this.handlers?.onMessage(await data.arrayBuffer());\n } catch (error) {\n this.handlers?.onError(error instanceof Error ? error : new Error(String(error)));\n }\n }\n }\n\n public async close(code: number, reason: string): Promise<void> {\n if (!this.webSocket) {\n return;\n }\n const webSocket = this.webSocket;\n try {\n if (webSocket.readyState !== WebSocket.CLOSING && webSocket.readyState !== WebSocket.CLOSED) {\n if (code === 1000 || (code >= 3000 && code <= 4999)) {\n webSocket.close(code, reason);\n } else {\n webSocket.close();\n }\n }\n await waitForClose(webSocket, this.closeNotified, this.closeTimeoutInMs);\n } catch (error) {\n // close() is a best-effort cleanup operation and must never throw (callers, including our\n // own VoiceAgentConnection.close()/dispose(), rely on it always resolving), so a transport\n // error here is logged for diagnosability rather than rejecting.\n logger.warning(\"Error while closing the voice-agent WebSocket transport\", { error });\n } finally {\n if (this.webSocket === webSocket) {\n this.webSocket = undefined;\n }\n }\n }\n}\n\n/** Waits for `webSocket` to open, or rejects early on an error, timeout, or abort. */\nfunction waitForOpen(\n webSocket: WebSocket,\n connectionTimeoutInMs: number,\n abortSignal?: AbortSignalLike,\n): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n const timeout = setTimeout(() => {\n finish(() =>\n reject(new Error(`WebSocket connection timed out after ${connectionTimeoutInMs}ms.`)),\n );\n }, connectionTimeoutInMs);\n const onOpen = (): void => finish(resolve);\n const onError = (): void => finish(() => reject(new Error(\"WebSocket connection failed.\")));\n const onAbort = (): void =>\n finish(() => reject(new Error(\"WebSocket connection was cancelled.\")));\n\n function finish(settle: () => void): void {\n clearTimeout(timeout);\n webSocket.removeEventListener(\"open\", onOpen);\n webSocket.removeEventListener(\"error\", onError);\n abortSignal?.removeEventListener(\"abort\", onAbort);\n settle();\n }\n\n webSocket.addEventListener(\"open\", onOpen, { once: true });\n webSocket.addEventListener(\"error\", onError, { once: true });\n abortSignal?.addEventListener(\"abort\", onAbort);\n });\n}\n\n/**\n * Waits until `onClose` has been delivered to the handlers, so `close()` never returns before the\n * caller observes the true close outcome. Resolves on timeout if the socket never closes; rejects\n * if it errors instead.\n */\nasync function waitForClose(\n webSocket: WebSocket,\n closeNotified: Promise<void>,\n timeoutInMs: number,\n): Promise<void> {\n let timeout: ReturnType<typeof setTimeout> | undefined;\n let onError: (() => void) | undefined;\n const errorOrTimeout = new Promise<void>((resolve, reject) => {\n timeout = setTimeout(resolve, timeoutInMs);\n onError = (): void => reject(new Error(\"WebSocket connection failed while closing.\"));\n webSocket.addEventListener(\"error\", onError, { once: true });\n });\n\n try {\n await Promise.race([closeNotified, errorOrTimeout]);\n } finally {\n clearTimeout(timeout);\n if (onError) {\n webSocket.removeEventListener(\"error\", onError);\n }\n }\n}\n\n/** @internal */\nexport function addHeadersToUrl(url: string, headers: Record<string, string>): string {\n const target = new URL(url);\n let foundryFeatures: string | undefined;\n for (const [name, value] of Object.entries(headers)) {\n switch (name.toLowerCase()) {\n case \"authorization\":\n break;\n case \"foundry-features\":\n foundryFeatures = value;\n break;\n case \"x-ms-client-request-id\":\n target.searchParams.set(\"client-request-id\", value);\n break;\n default:\n target.searchParams.set(`h-${name.toLowerCase()}`, value);\n break;\n }\n }\n const targetUrl = target.toString();\n if (foundryFeatures === undefined) {\n return targetUrl;\n }\n const separator = target.search ? \"&\" : \"?\";\n const encodedFeatures = encodeURIComponent(foundryFeatures).replace(/%3D/gi, \"=\");\n return `${targetUrl}${separator}foundry_features=${encodedFeatures}`;\n}\n\nfunction addCredentialSubprotocol(protocols: string[], headers: Record<string, string>): string[] {\n const authorization = Object.entries(headers).find(\n ([name]) => name.toLowerCase() === \"authorization\",\n )?.[1];\n if (authorization === undefined) {\n return protocols;\n }\n const bearerPrefix = \"Bearer \";\n if (!authorization.startsWith(bearerPrefix) || authorization.length === bearerPrefix.length) {\n throw new Error(\"Browser WebSocket authentication requires a Microsoft Entra bearer token.\");\n }\n return [...protocols, `authorization.bearer.${authorization.slice(bearerPrefix.length)}`];\n}\n\nclass BrowserWebSocketFactory implements VoiceAgentWebSocketFactory {\n public create(): VoiceAgentWebSocketTransport {\n return new BrowserWebSocketTransport();\n }\n}\n\n/** @internal */\nexport function createDefaultVoiceAgentWebSocketFactory(): VoiceAgentWebSocketFactory {\n return new BrowserWebSocketFactory();\n}\n"]}
1
+ {"version":3,"file":"webSocketTransport-browser.mjs","sourceRoot":"","sources":["../../src/webSocketTransport-browser.mts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAerC;;;;;;;GAOG;AACH,MAAM,OAAO,yBAAyB;IAC5B,SAAS,CAAa;IACtB,QAAQ,CAA+B;IAC9B,gBAAgB,CAAS;IAClC,YAAY,GAAkB,OAAO,CAAC,OAAO,EAAE,CAAC;IACxD,sFAAsF;IACtF,0FAA0F;IAC1F,gGAAgG;IACxF,aAAa,GAAkB,OAAO,CAAC,OAAO,EAAE,CAAC;IAEzD,YAAmB,gBAAgB,GAAG,KAAK;QACzC,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;IAC3C,CAAC;IAEM,WAAW,CAAC,QAAqC;QACtD,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAEM,KAAK,CAAC,OAAO,CAAC,OAA0C;QAC7D,IAAI,OAAO,CAAC,WAAW,EAAE,OAAO,EAAE,CAAC;YACjC,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;QACzD,CAAC;QACD,MAAM,SAAS,GAAG,wBAAwB,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,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D,MAAM;YACR,KAAK,wBAAwB;gBAC3B,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,mBAAmB,EAAE,KAAK,CAAC,CAAC;gBACpD,MAAM;YACR,KAAK,8BAA8B;gBACjC,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,kBAAkB,EAAE,KAAK,CAAC,CAAC;gBACnD,MAAM;QACV,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC,QAAQ,EAAE,CAAC;AAC3B,CAAC;AAED,SAAS,wBAAwB,CAAC,SAAmB,EAAE,OAA+B;IACpF,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,IAAI,CAChD,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,eAAe,CACnD,EAAE,CAAC,CAAC,CAAC,CAAC;IACP,IAAI,aAAa,KAAK,SAAS,EAAE,CAAC;QAChC,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,MAAM,YAAY,GAAG,SAAS,CAAC;IAC/B,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,YAAY,CAAC,IAAI,aAAa,CAAC,MAAM,KAAK,YAAY,CAAC,MAAM,EAAE,CAAC;QAC5F,MAAM,IAAI,KAAK,CAAC,2EAA2E,CAAC,CAAC;IAC/F,CAAC;IACD,OAAO,CAAC,GAAG,SAAS,EAAE,wBAAwB,aAAa,CAAC,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAC5F,CAAC;AAED,MAAM,uBAAuB;IACpB,MAAM;QACX,OAAO,IAAI,yBAAyB,EAAE,CAAC;IACzC,CAAC;CACF;AAED,gBAAgB;AAChB,MAAM,UAAU,uCAAuC;IACrD,OAAO,IAAI,uBAAuB,EAAE,CAAC;AACvC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { AbortSignalLike } from \"@azure/abort-controller\";\nimport { logger } from \"./logger.js\";\nimport type {\n VoiceAgentWebSocketConnectOptions,\n VoiceAgentWebSocketFactory,\n VoiceAgentWebSocketHandlers,\n VoiceAgentWebSocketTransport,\n} from \"./realtime/webSocketTransportLike.js\";\n\n/** The `CloseEvent` fields this transport forwards; the DOM lib is not in scope here. */\ninterface NativeCloseEvent {\n code: number;\n reason: string;\n wasClean: boolean;\n}\n\n/**\n * Default browser transport for the Voice Agents realtime client.\n *\n * Browsers cannot set an `Authorization` header on a WebSocket upgrade request. This transport sends\n * the Microsoft Entra bearer token as the `authorization.bearer.<token>` WebSocket subprotocol,\n * which the service converts back into an `Authorization` header before forwarding the request.\n * Only preview features, client request IDs, and structured inputs are mapped to query parameters.\n */\nexport class BrowserWebSocketTransport implements VoiceAgentWebSocketTransport {\n private webSocket?: WebSocket;\n private handlers?: VoiceAgentWebSocketHandlers;\n private readonly closeTimeoutInMs: number;\n private messageChain: Promise<void> = Promise.resolve();\n // Resolves once `onClose` has actually been invoked for the current connection (after\n // `messageChain` drains). `close()` awaits this - not just the raw native \"close\" event -\n // so it never resolves before the caller observes the authoritative close code/reason/wasClean.\n private closeNotified: Promise<void> = Promise.resolve();\n\n public constructor(closeTimeoutInMs = 5_000) {\n this.closeTimeoutInMs = closeTimeoutInMs;\n }\n\n public setHandlers(handlers: VoiceAgentWebSocketHandlers): void {\n this.handlers = handlers;\n }\n\n public async connect(options: VoiceAgentWebSocketConnectOptions): Promise<void> {\n if (options.abortSignal?.aborted) {\n throw new Error(\"WebSocket connection was cancelled.\");\n }\n const protocols = addCredentialSubprotocol(options.protocols, options.headers);\n const url = addHeadersToUrl(options.url, options.headers);\n\n let notifyClosed: () => void = () => {};\n this.closeNotified = new Promise<void>((resolve) => {\n notifyClosed = resolve;\n });\n\n const webSocket = new WebSocket(url, protocols);\n webSocket.binaryType = \"arraybuffer\";\n this.webSocket = webSocket;\n\n // These forward events for the lifetime of the connection, independent of whether connect()\n // itself is still pending.\n webSocket.addEventListener(\"message\", (event: MessageEvent) => {\n // Chain handling so an async Blob conversion can never let a later message be delivered to\n // the protocol parser out of arrival order.\n this.messageChain = this.deliverMessage(this.messageChain, event.data);\n });\n webSocket.addEventListener(\"close\", (event) => void this.deliverClose(event, notifyClosed));\n webSocket.addEventListener(\"error\", () => {\n this.handlers?.onError(new Error(\"WebSocket connection failed.\"));\n });\n\n try {\n await waitForOpen(webSocket, options.connectionTimeoutInMs, options.abortSignal);\n } catch (error) {\n webSocket.close();\n throw error;\n }\n }\n\n public async send(data: string, abortSignal?: AbortSignalLike): Promise<void> {\n if (!this.webSocket || this.webSocket.readyState !== WebSocket.OPEN) {\n throw new Error(\"WebSocket is not connected.\");\n }\n if (abortSignal?.aborted) {\n throw new Error(\"WebSocket send was cancelled.\");\n }\n this.webSocket.send(data);\n }\n\n /** Chains `data` behind `previous` so an async `Blob` conversion cannot reorder events. */\n private async deliverMessage(\n previous: Promise<void>,\n data: string | ArrayBuffer | Blob,\n ): Promise<void> {\n await previous;\n await this.handleIncomingMessage(data);\n }\n\n /** Reports the close only after every earlier message has reached the parser. */\n private async deliverClose(event: Event, notifyClosed: () => void): Promise<void> {\n const { code, reason, wasClean } = event as unknown as NativeCloseEvent;\n try {\n await this.messageChain;\n } catch {\n // handleIncomingMessage already reported the failure through onError.\n }\n this.handlers?.onClose(code, reason, wasClean);\n notifyClosed();\n }\n\n private async handleIncomingMessage(data: string | ArrayBuffer | Blob): Promise<void> {\n if (typeof data === \"string\" || data instanceof ArrayBuffer) {\n this.handlers?.onMessage(data);\n return;\n }\n if (data instanceof Blob) {\n try {\n this.handlers?.onMessage(await data.arrayBuffer());\n } catch (error) {\n this.handlers?.onError(error instanceof Error ? error : new Error(String(error)));\n }\n }\n }\n\n public async close(code: number, reason: string): Promise<void> {\n if (!this.webSocket) {\n return;\n }\n const webSocket = this.webSocket;\n try {\n if (webSocket.readyState !== WebSocket.CLOSING && webSocket.readyState !== WebSocket.CLOSED) {\n if (code === 1000 || (code >= 3000 && code <= 4999)) {\n webSocket.close(code, reason);\n } else {\n webSocket.close();\n }\n }\n await waitForClose(webSocket, this.closeNotified, this.closeTimeoutInMs);\n } catch (error) {\n // close() is a best-effort cleanup operation and must never throw (callers, including our\n // own VoiceAgentConnection.close()/dispose(), rely on it always resolving), so a transport\n // error here is logged for diagnosability rather than rejecting.\n logger.warning(\"Error while closing the voice-agent WebSocket transport\", { error });\n } finally {\n if (this.webSocket === webSocket) {\n this.webSocket = undefined;\n }\n }\n }\n}\n\n/** Waits for `webSocket` to open, or rejects early on an error, timeout, or abort. */\nfunction waitForOpen(\n webSocket: WebSocket,\n connectionTimeoutInMs: number,\n abortSignal?: AbortSignalLike,\n): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n const timeout = setTimeout(() => {\n finish(() =>\n reject(new Error(`WebSocket connection timed out after ${connectionTimeoutInMs}ms.`)),\n );\n }, connectionTimeoutInMs);\n const onOpen = (): void => finish(resolve);\n const onError = (): void => finish(() => reject(new Error(\"WebSocket connection failed.\")));\n const onAbort = (): void =>\n finish(() => reject(new Error(\"WebSocket connection was cancelled.\")));\n\n function finish(settle: () => void): void {\n clearTimeout(timeout);\n webSocket.removeEventListener(\"open\", onOpen);\n webSocket.removeEventListener(\"error\", onError);\n abortSignal?.removeEventListener(\"abort\", onAbort);\n settle();\n }\n\n webSocket.addEventListener(\"open\", onOpen, { once: true });\n webSocket.addEventListener(\"error\", onError, { once: true });\n abortSignal?.addEventListener(\"abort\", onAbort);\n });\n}\n\n/**\n * Waits until `onClose` has been delivered to the handlers, so `close()` never returns before the\n * caller observes the true close outcome. Resolves on timeout if the socket never closes; rejects\n * if it errors instead.\n */\nasync function waitForClose(\n webSocket: WebSocket,\n closeNotified: Promise<void>,\n timeoutInMs: number,\n): Promise<void> {\n let timeout: ReturnType<typeof setTimeout> | undefined;\n let onError: (() => void) | undefined;\n const errorOrTimeout = new Promise<void>((resolve, reject) => {\n timeout = setTimeout(resolve, timeoutInMs);\n onError = (): void => reject(new Error(\"WebSocket connection failed while closing.\"));\n webSocket.addEventListener(\"error\", onError, { once: true });\n });\n\n try {\n await Promise.race([closeNotified, errorOrTimeout]);\n } finally {\n clearTimeout(timeout);\n if (onError) {\n webSocket.removeEventListener(\"error\", onError);\n }\n }\n}\n\n/** @internal */\nexport function addHeadersToUrl(url: string, headers: Record<string, string>): string {\n const target = new URL(url);\n for (const [name, value] of Object.entries(headers)) {\n switch (name.toLowerCase()) {\n case \"foundry-features\":\n target.searchParams.set(\"foundry_features\", value);\n break;\n case \"x-ms-client-request-id\":\n target.searchParams.set(\"client-request-id\", value);\n break;\n case \"x-ms-voice-structured-inputs\":\n target.searchParams.set(\"structured_input\", value);\n break;\n }\n }\n return target.toString();\n}\n\nfunction addCredentialSubprotocol(protocols: string[], headers: Record<string, string>): string[] {\n const authorization = Object.entries(headers).find(\n ([name]) => name.toLowerCase() === \"authorization\",\n )?.[1];\n if (authorization === undefined) {\n return protocols;\n }\n const bearerPrefix = \"Bearer \";\n if (!authorization.startsWith(bearerPrefix) || authorization.length === bearerPrefix.length) {\n throw new Error(\"Browser WebSocket authentication requires a Microsoft Entra bearer token.\");\n }\n return [...protocols, `authorization.bearer.${authorization.slice(bearerPrefix.length)}`];\n}\n\nclass BrowserWebSocketFactory implements VoiceAgentWebSocketFactory {\n public create(): VoiceAgentWebSocketTransport {\n return new BrowserWebSocketTransport();\n }\n}\n\n/** @internal */\nexport function createDefaultVoiceAgentWebSocketFactory(): VoiceAgentWebSocketFactory {\n return new BrowserWebSocketFactory();\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azure/ai-projects",
3
- "version": "2.7.1",
3
+ "version": "2.8.0",
4
4
  "description": "Azure AI Projects client library.",
5
5
  "engines": {
6
6
  "node": ">=22.0.0"
@@ -75,8 +75,8 @@
75
75
  "@opentelemetry/sdk-trace-node": "^2.9.0",
76
76
  "@types/node": "^22.0.0",
77
77
  "@types/ws": "^8.18.1",
78
- "@vitest/browser-playwright": "^4.1.2",
79
- "@vitest/coverage-istanbul": "^4.1.2",
78
+ "@vitest/browser-playwright": "^5.0.0",
79
+ "@vitest/coverage-istanbul": "^5.0.0",
80
80
  "cross-env": "^10.1.0",
81
81
  "dotenv": "^16.6.1",
82
82
  "eslint": "^10.8.0",
@@ -87,7 +87,7 @@
87
87
  "rimraf": "^6.1.0",
88
88
  "typescript": "~6.0.2",
89
89
  "vite": "^8.0.0",
90
- "vitest": "^4.1.2",
90
+ "vitest": "^5.0.0",
91
91
  "zod": "^4.2.1"
92
92
  },
93
93
  "exports": {
@@ -1,3 +0,0 @@
1
- export { deleteGenerationJob, cancelGenerationJob, createGenerationJob, listGenerationJobs, getGenerationJob, } from "./operations.js";
2
- export type { BetaDatasetsDeleteGenerationJobOptionalParams, BetaDatasetsCancelGenerationJobOptionalParams, BetaDatasetsCreateGenerationJobOptionalParams, BetaDatasetsListGenerationJobsOptionalParams, BetaDatasetsGetGenerationJobOptionalParams, } from "./options.js";
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/api/beta/datasets/index.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,iBAAiB,CAAC;AACzB,YAAY,EACV,6CAA6C,EAC7C,6CAA6C,EAC7C,6CAA6C,EAC7C,4CAA4C,EAC5C,0CAA0C,GAC3C,MAAM,cAAc,CAAC"}
@@ -1,4 +0,0 @@
1
- // Copyright (c) Microsoft Corporation.
2
- // Licensed under the MIT License.
3
- export { deleteGenerationJob, cancelGenerationJob, createGenerationJob, listGenerationJobs, getGenerationJob, } from "./operations.js";
4
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/api/beta/datasets/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,iBAAiB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nexport {\n deleteGenerationJob,\n cancelGenerationJob,\n createGenerationJob,\n listGenerationJobs,\n getGenerationJob,\n} from \"./operations.js\";\nexport type {\n BetaDatasetsDeleteGenerationJobOptionalParams,\n BetaDatasetsCancelGenerationJobOptionalParams,\n BetaDatasetsCreateGenerationJobOptionalParams,\n BetaDatasetsListGenerationJobsOptionalParams,\n BetaDatasetsGetGenerationJobOptionalParams,\n} from \"./options.js\";\n"]}