@azure/ai-agents 1.0.0 → 1.1.0-beta.2

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 (323) hide show
  1. package/README.md +104 -1
  2. package/dist/browser/agentsClient.js +24 -3
  3. package/dist/browser/agentsClient.js.map +1 -1
  4. package/dist/browser/api/agentsContext.js +13 -10
  5. package/dist/browser/api/agentsContext.js.map +1 -1
  6. package/dist/browser/api/files/operations.js +51 -26
  7. package/dist/browser/api/files/operations.js.map +1 -1
  8. package/dist/browser/api/messages/operations.js +54 -30
  9. package/dist/browser/api/messages/operations.js.map +1 -1
  10. package/dist/browser/api/operations.d.ts.map +1 -1
  11. package/dist/browser/api/operations.js +147 -134
  12. package/dist/browser/api/operations.js.map +1 -1
  13. package/dist/browser/api/poller.js +12 -15
  14. package/dist/browser/api/poller.js.map +1 -1
  15. package/dist/browser/api/runSteps/operations.js +30 -20
  16. package/dist/browser/api/runSteps/operations.js.map +1 -1
  17. package/dist/browser/api/runs/operations.d.ts.map +1 -1
  18. package/dist/browser/api/runs/operations.js +108 -67
  19. package/dist/browser/api/runs/operations.js.map +1 -1
  20. package/dist/browser/api/runs/options.d.ts +7 -1
  21. package/dist/browser/api/runs/options.d.ts.map +1 -1
  22. package/dist/browser/api/runs/options.js.map +1 -1
  23. package/dist/browser/api/threads/operations.js +71 -42
  24. package/dist/browser/api/threads/operations.js.map +1 -1
  25. package/dist/browser/api/vectorStoreFileBatches/operations.d.ts +2 -2
  26. package/dist/browser/api/vectorStoreFileBatches/operations.d.ts.map +1 -1
  27. package/dist/browser/api/vectorStoreFileBatches/operations.js +50 -33
  28. package/dist/browser/api/vectorStoreFileBatches/operations.js.map +1 -1
  29. package/dist/browser/api/vectorStoreFiles/operations.js +49 -29
  30. package/dist/browser/api/vectorStoreFiles/operations.js.map +1 -1
  31. package/dist/browser/api/vectorStores/operations.js +68 -44
  32. package/dist/browser/api/vectorStores/operations.js.map +1 -1
  33. package/dist/browser/classic/files/index.js +3 -1
  34. package/dist/browser/classic/files/index.js.map +1 -1
  35. package/dist/browser/classic/messages/index.js +3 -1
  36. package/dist/browser/classic/messages/index.js.map +1 -1
  37. package/dist/browser/classic/runSteps/index.js +3 -1
  38. package/dist/browser/classic/runSteps/index.js.map +1 -1
  39. package/dist/browser/classic/runs/index.js +3 -1
  40. package/dist/browser/classic/runs/index.js.map +1 -1
  41. package/dist/browser/classic/threads/index.js +3 -1
  42. package/dist/browser/classic/threads/index.js.map +1 -1
  43. package/dist/browser/classic/vectorStoreFileBatches/index.d.ts +2 -2
  44. package/dist/browser/classic/vectorStoreFileBatches/index.d.ts.map +1 -1
  45. package/dist/browser/classic/vectorStoreFileBatches/index.js +3 -1
  46. package/dist/browser/classic/vectorStoreFileBatches/index.js.map +1 -1
  47. package/dist/browser/classic/vectorStoreFiles/index.js +3 -1
  48. package/dist/browser/classic/vectorStoreFiles/index.js.map +1 -1
  49. package/dist/browser/classic/vectorStores/index.js +3 -1
  50. package/dist/browser/classic/vectorStores/index.js.map +1 -1
  51. package/dist/browser/constants.d.ts +1 -1
  52. package/dist/browser/constants.d.ts.map +1 -1
  53. package/dist/browser/constants.js +1 -1
  54. package/dist/browser/constants.js.map +1 -1
  55. package/dist/browser/index.d.ts +3 -2
  56. package/dist/browser/index.d.ts.map +1 -1
  57. package/dist/browser/index.js +2 -1
  58. package/dist/browser/index.js.map +1 -1
  59. package/dist/browser/models/index.d.ts +1 -1
  60. package/dist/browser/models/index.d.ts.map +1 -1
  61. package/dist/browser/models/index.js.map +1 -1
  62. package/dist/browser/models/models.d.ts +260 -22
  63. package/dist/browser/models/models.d.ts.map +1 -1
  64. package/dist/browser/models/models.js +337 -14
  65. package/dist/browser/models/models.js.map +1 -1
  66. package/dist/browser/static-helpers/multipartHelpers.js +1 -2
  67. package/dist/browser/static-helpers/multipartHelpers.js.map +1 -1
  68. package/dist/browser/static-helpers/pagingHelpers.js +31 -50
  69. package/dist/browser/static-helpers/pagingHelpers.js.map +1 -1
  70. package/dist/browser/static-helpers/urlTemplate.js +2 -2
  71. package/dist/browser/static-helpers/urlTemplate.js.map +1 -1
  72. package/dist/browser/utils/MCPTool.d.ts +78 -0
  73. package/dist/browser/utils/MCPTool.d.ts.map +1 -0
  74. package/dist/browser/utils/MCPTool.js +133 -0
  75. package/dist/browser/utils/MCPTool.js.map +1 -0
  76. package/dist/browser/{utils.d.ts → utils/utils.d.ts} +61 -1
  77. package/dist/browser/utils/utils.d.ts.map +1 -0
  78. package/dist/{esm → browser/utils}/utils.js +104 -16
  79. package/dist/browser/utils/utils.js.map +1 -0
  80. package/dist/commonjs/agentsClient.js +24 -3
  81. package/dist/commonjs/agentsClient.js.map +1 -1
  82. package/dist/commonjs/api/agentsContext.js +13 -10
  83. package/dist/commonjs/api/agentsContext.js.map +1 -1
  84. package/dist/commonjs/api/files/operations.js +51 -26
  85. package/dist/commonjs/api/files/operations.js.map +1 -1
  86. package/dist/commonjs/api/messages/operations.js +54 -30
  87. package/dist/commonjs/api/messages/operations.js.map +1 -1
  88. package/dist/commonjs/api/operations.d.ts.map +1 -1
  89. package/dist/commonjs/api/operations.js +146 -133
  90. package/dist/commonjs/api/operations.js.map +1 -1
  91. package/dist/commonjs/api/poller.js +12 -15
  92. package/dist/commonjs/api/poller.js.map +1 -1
  93. package/dist/commonjs/api/runSteps/operations.js +30 -20
  94. package/dist/commonjs/api/runSteps/operations.js.map +1 -1
  95. package/dist/commonjs/api/runs/operations.d.ts.map +1 -1
  96. package/dist/commonjs/api/runs/operations.js +107 -66
  97. package/dist/commonjs/api/runs/operations.js.map +1 -1
  98. package/dist/commonjs/api/runs/options.d.ts +7 -1
  99. package/dist/commonjs/api/runs/options.d.ts.map +1 -1
  100. package/dist/commonjs/api/runs/options.js.map +1 -1
  101. package/dist/commonjs/api/threads/operations.js +71 -42
  102. package/dist/commonjs/api/threads/operations.js.map +1 -1
  103. package/dist/commonjs/api/vectorStoreFileBatches/operations.d.ts +2 -2
  104. package/dist/commonjs/api/vectorStoreFileBatches/operations.d.ts.map +1 -1
  105. package/dist/commonjs/api/vectorStoreFileBatches/operations.js +50 -33
  106. package/dist/commonjs/api/vectorStoreFileBatches/operations.js.map +1 -1
  107. package/dist/commonjs/api/vectorStoreFiles/operations.js +49 -29
  108. package/dist/commonjs/api/vectorStoreFiles/operations.js.map +1 -1
  109. package/dist/commonjs/api/vectorStores/operations.js +68 -44
  110. package/dist/commonjs/api/vectorStores/operations.js.map +1 -1
  111. package/dist/commonjs/classic/files/index.js +3 -1
  112. package/dist/commonjs/classic/files/index.js.map +1 -1
  113. package/dist/commonjs/classic/messages/index.js +3 -1
  114. package/dist/commonjs/classic/messages/index.js.map +1 -1
  115. package/dist/commonjs/classic/runSteps/index.js +3 -1
  116. package/dist/commonjs/classic/runSteps/index.js.map +1 -1
  117. package/dist/commonjs/classic/runs/index.js +3 -1
  118. package/dist/commonjs/classic/runs/index.js.map +1 -1
  119. package/dist/commonjs/classic/threads/index.js +3 -1
  120. package/dist/commonjs/classic/threads/index.js.map +1 -1
  121. package/dist/commonjs/classic/vectorStoreFileBatches/index.d.ts +2 -2
  122. package/dist/commonjs/classic/vectorStoreFileBatches/index.d.ts.map +1 -1
  123. package/dist/commonjs/classic/vectorStoreFileBatches/index.js +3 -1
  124. package/dist/commonjs/classic/vectorStoreFileBatches/index.js.map +1 -1
  125. package/dist/commonjs/classic/vectorStoreFiles/index.js +3 -1
  126. package/dist/commonjs/classic/vectorStoreFiles/index.js.map +1 -1
  127. package/dist/commonjs/classic/vectorStores/index.js +3 -1
  128. package/dist/commonjs/classic/vectorStores/index.js.map +1 -1
  129. package/dist/commonjs/constants.d.ts +1 -1
  130. package/dist/commonjs/constants.d.ts.map +1 -1
  131. package/dist/commonjs/constants.js +1 -1
  132. package/dist/commonjs/constants.js.map +1 -1
  133. package/dist/commonjs/index.d.ts +3 -2
  134. package/dist/commonjs/index.d.ts.map +1 -1
  135. package/dist/commonjs/index.js +4 -2
  136. package/dist/commonjs/index.js.map +1 -1
  137. package/dist/commonjs/models/index.d.ts +1 -1
  138. package/dist/commonjs/models/index.d.ts.map +1 -1
  139. package/dist/commonjs/models/index.js.map +1 -1
  140. package/dist/commonjs/models/models.d.ts +260 -22
  141. package/dist/commonjs/models/models.d.ts.map +1 -1
  142. package/dist/commonjs/models/models.js +382 -16
  143. package/dist/commonjs/models/models.js.map +1 -1
  144. package/dist/commonjs/static-helpers/multipartHelpers.js +1 -2
  145. package/dist/commonjs/static-helpers/multipartHelpers.js.map +1 -1
  146. package/dist/commonjs/static-helpers/pagingHelpers.js +31 -50
  147. package/dist/commonjs/static-helpers/pagingHelpers.js.map +1 -1
  148. package/dist/commonjs/static-helpers/urlTemplate.js +2 -2
  149. package/dist/commonjs/static-helpers/urlTemplate.js.map +1 -1
  150. package/dist/commonjs/tsdoc-metadata.json +11 -11
  151. package/dist/commonjs/utils/MCPTool.d.ts +78 -0
  152. package/dist/commonjs/utils/MCPTool.d.ts.map +1 -0
  153. package/dist/commonjs/utils/MCPTool.js +137 -0
  154. package/dist/commonjs/utils/MCPTool.js.map +1 -0
  155. package/dist/commonjs/{utils.d.ts → utils/utils.d.ts} +61 -1
  156. package/dist/commonjs/utils/utils.d.ts.map +1 -0
  157. package/dist/commonjs/{utils.js → utils/utils.js} +104 -16
  158. package/dist/commonjs/utils/utils.js.map +1 -0
  159. package/dist/esm/agentsClient.js +24 -3
  160. package/dist/esm/agentsClient.js.map +1 -1
  161. package/dist/esm/api/agentsContext.js +13 -10
  162. package/dist/esm/api/agentsContext.js.map +1 -1
  163. package/dist/esm/api/files/operations.js +51 -26
  164. package/dist/esm/api/files/operations.js.map +1 -1
  165. package/dist/esm/api/messages/operations.js +54 -30
  166. package/dist/esm/api/messages/operations.js.map +1 -1
  167. package/dist/esm/api/operations.d.ts.map +1 -1
  168. package/dist/esm/api/operations.js +147 -134
  169. package/dist/esm/api/operations.js.map +1 -1
  170. package/dist/esm/api/poller.js +12 -15
  171. package/dist/esm/api/poller.js.map +1 -1
  172. package/dist/esm/api/runSteps/operations.js +30 -20
  173. package/dist/esm/api/runSteps/operations.js.map +1 -1
  174. package/dist/esm/api/runs/operations.d.ts.map +1 -1
  175. package/dist/esm/api/runs/operations.js +108 -67
  176. package/dist/esm/api/runs/operations.js.map +1 -1
  177. package/dist/esm/api/runs/options.d.ts +7 -1
  178. package/dist/esm/api/runs/options.d.ts.map +1 -1
  179. package/dist/esm/api/runs/options.js.map +1 -1
  180. package/dist/esm/api/threads/operations.js +71 -42
  181. package/dist/esm/api/threads/operations.js.map +1 -1
  182. package/dist/esm/api/vectorStoreFileBatches/operations.d.ts +2 -2
  183. package/dist/esm/api/vectorStoreFileBatches/operations.d.ts.map +1 -1
  184. package/dist/esm/api/vectorStoreFileBatches/operations.js +50 -33
  185. package/dist/esm/api/vectorStoreFileBatches/operations.js.map +1 -1
  186. package/dist/esm/api/vectorStoreFiles/operations.js +49 -29
  187. package/dist/esm/api/vectorStoreFiles/operations.js.map +1 -1
  188. package/dist/esm/api/vectorStores/operations.js +68 -44
  189. package/dist/esm/api/vectorStores/operations.js.map +1 -1
  190. package/dist/esm/classic/files/index.js +3 -1
  191. package/dist/esm/classic/files/index.js.map +1 -1
  192. package/dist/esm/classic/messages/index.js +3 -1
  193. package/dist/esm/classic/messages/index.js.map +1 -1
  194. package/dist/esm/classic/runSteps/index.js +3 -1
  195. package/dist/esm/classic/runSteps/index.js.map +1 -1
  196. package/dist/esm/classic/runs/index.js +3 -1
  197. package/dist/esm/classic/runs/index.js.map +1 -1
  198. package/dist/esm/classic/threads/index.js +3 -1
  199. package/dist/esm/classic/threads/index.js.map +1 -1
  200. package/dist/esm/classic/vectorStoreFileBatches/index.d.ts +2 -2
  201. package/dist/esm/classic/vectorStoreFileBatches/index.d.ts.map +1 -1
  202. package/dist/esm/classic/vectorStoreFileBatches/index.js +3 -1
  203. package/dist/esm/classic/vectorStoreFileBatches/index.js.map +1 -1
  204. package/dist/esm/classic/vectorStoreFiles/index.js +3 -1
  205. package/dist/esm/classic/vectorStoreFiles/index.js.map +1 -1
  206. package/dist/esm/classic/vectorStores/index.js +3 -1
  207. package/dist/esm/classic/vectorStores/index.js.map +1 -1
  208. package/dist/esm/constants.d.ts +1 -1
  209. package/dist/esm/constants.d.ts.map +1 -1
  210. package/dist/esm/constants.js +1 -1
  211. package/dist/esm/constants.js.map +1 -1
  212. package/dist/esm/index.d.ts +3 -2
  213. package/dist/esm/index.d.ts.map +1 -1
  214. package/dist/esm/index.js +2 -1
  215. package/dist/esm/index.js.map +1 -1
  216. package/dist/esm/models/index.d.ts +1 -1
  217. package/dist/esm/models/index.d.ts.map +1 -1
  218. package/dist/esm/models/index.js.map +1 -1
  219. package/dist/esm/models/models.d.ts +260 -22
  220. package/dist/esm/models/models.d.ts.map +1 -1
  221. package/dist/esm/models/models.js +337 -14
  222. package/dist/esm/models/models.js.map +1 -1
  223. package/dist/esm/static-helpers/multipartHelpers.js +1 -2
  224. package/dist/esm/static-helpers/multipartHelpers.js.map +1 -1
  225. package/dist/esm/static-helpers/pagingHelpers.js +31 -50
  226. package/dist/esm/static-helpers/pagingHelpers.js.map +1 -1
  227. package/dist/esm/static-helpers/urlTemplate.js +2 -2
  228. package/dist/esm/static-helpers/urlTemplate.js.map +1 -1
  229. package/dist/esm/utils/MCPTool.d.ts +78 -0
  230. package/dist/esm/utils/MCPTool.d.ts.map +1 -0
  231. package/dist/esm/utils/MCPTool.js +133 -0
  232. package/dist/esm/utils/MCPTool.js.map +1 -0
  233. package/dist/{react-native → esm/utils}/utils.d.ts +61 -1
  234. package/dist/esm/utils/utils.d.ts.map +1 -0
  235. package/dist/{react-native → esm/utils}/utils.js +104 -16
  236. package/dist/esm/utils/utils.js.map +1 -0
  237. package/dist/react-native/agentsClient.js +24 -3
  238. package/dist/react-native/agentsClient.js.map +1 -1
  239. package/dist/react-native/api/agentsContext.js +13 -10
  240. package/dist/react-native/api/agentsContext.js.map +1 -1
  241. package/dist/react-native/api/files/operations.js +51 -26
  242. package/dist/react-native/api/files/operations.js.map +1 -1
  243. package/dist/react-native/api/messages/operations.js +54 -30
  244. package/dist/react-native/api/messages/operations.js.map +1 -1
  245. package/dist/react-native/api/operations.d.ts.map +1 -1
  246. package/dist/react-native/api/operations.js +147 -134
  247. package/dist/react-native/api/operations.js.map +1 -1
  248. package/dist/react-native/api/poller.js +12 -15
  249. package/dist/react-native/api/poller.js.map +1 -1
  250. package/dist/react-native/api/runSteps/operations.js +30 -20
  251. package/dist/react-native/api/runSteps/operations.js.map +1 -1
  252. package/dist/react-native/api/runs/operations.d.ts.map +1 -1
  253. package/dist/react-native/api/runs/operations.js +108 -67
  254. package/dist/react-native/api/runs/operations.js.map +1 -1
  255. package/dist/react-native/api/runs/options.d.ts +7 -1
  256. package/dist/react-native/api/runs/options.d.ts.map +1 -1
  257. package/dist/react-native/api/runs/options.js.map +1 -1
  258. package/dist/react-native/api/threads/operations.js +71 -42
  259. package/dist/react-native/api/threads/operations.js.map +1 -1
  260. package/dist/react-native/api/vectorStoreFileBatches/operations.d.ts +2 -2
  261. package/dist/react-native/api/vectorStoreFileBatches/operations.d.ts.map +1 -1
  262. package/dist/react-native/api/vectorStoreFileBatches/operations.js +50 -33
  263. package/dist/react-native/api/vectorStoreFileBatches/operations.js.map +1 -1
  264. package/dist/react-native/api/vectorStoreFiles/operations.js +49 -29
  265. package/dist/react-native/api/vectorStoreFiles/operations.js.map +1 -1
  266. package/dist/react-native/api/vectorStores/operations.js +68 -44
  267. package/dist/react-native/api/vectorStores/operations.js.map +1 -1
  268. package/dist/react-native/classic/files/index.js +3 -1
  269. package/dist/react-native/classic/files/index.js.map +1 -1
  270. package/dist/react-native/classic/messages/index.js +3 -1
  271. package/dist/react-native/classic/messages/index.js.map +1 -1
  272. package/dist/react-native/classic/runSteps/index.js +3 -1
  273. package/dist/react-native/classic/runSteps/index.js.map +1 -1
  274. package/dist/react-native/classic/runs/index.js +3 -1
  275. package/dist/react-native/classic/runs/index.js.map +1 -1
  276. package/dist/react-native/classic/threads/index.js +3 -1
  277. package/dist/react-native/classic/threads/index.js.map +1 -1
  278. package/dist/react-native/classic/vectorStoreFileBatches/index.d.ts +2 -2
  279. package/dist/react-native/classic/vectorStoreFileBatches/index.d.ts.map +1 -1
  280. package/dist/react-native/classic/vectorStoreFileBatches/index.js +3 -1
  281. package/dist/react-native/classic/vectorStoreFileBatches/index.js.map +1 -1
  282. package/dist/react-native/classic/vectorStoreFiles/index.js +3 -1
  283. package/dist/react-native/classic/vectorStoreFiles/index.js.map +1 -1
  284. package/dist/react-native/classic/vectorStores/index.js +3 -1
  285. package/dist/react-native/classic/vectorStores/index.js.map +1 -1
  286. package/dist/react-native/constants.d.ts +1 -1
  287. package/dist/react-native/constants.d.ts.map +1 -1
  288. package/dist/react-native/constants.js +1 -1
  289. package/dist/react-native/constants.js.map +1 -1
  290. package/dist/react-native/index.d.ts +3 -2
  291. package/dist/react-native/index.d.ts.map +1 -1
  292. package/dist/react-native/index.js +2 -1
  293. package/dist/react-native/index.js.map +1 -1
  294. package/dist/react-native/models/index.d.ts +1 -1
  295. package/dist/react-native/models/index.d.ts.map +1 -1
  296. package/dist/react-native/models/index.js.map +1 -1
  297. package/dist/react-native/models/models.d.ts +260 -22
  298. package/dist/react-native/models/models.d.ts.map +1 -1
  299. package/dist/react-native/models/models.js +337 -14
  300. package/dist/react-native/models/models.js.map +1 -1
  301. package/dist/react-native/static-helpers/multipartHelpers.js +1 -2
  302. package/dist/react-native/static-helpers/multipartHelpers.js.map +1 -1
  303. package/dist/react-native/static-helpers/pagingHelpers.js +31 -50
  304. package/dist/react-native/static-helpers/pagingHelpers.js.map +1 -1
  305. package/dist/react-native/static-helpers/urlTemplate.js +2 -2
  306. package/dist/react-native/static-helpers/urlTemplate.js.map +1 -1
  307. package/dist/react-native/utils/MCPTool.d.ts +78 -0
  308. package/dist/react-native/utils/MCPTool.d.ts.map +1 -0
  309. package/dist/react-native/utils/MCPTool.js +133 -0
  310. package/dist/react-native/utils/MCPTool.js.map +1 -0
  311. package/dist/{esm → react-native/utils}/utils.d.ts +61 -1
  312. package/dist/react-native/utils/utils.d.ts.map +1 -0
  313. package/dist/{browser → react-native/utils}/utils.js +104 -16
  314. package/dist/react-native/utils/utils.js.map +1 -0
  315. package/package.json +2 -2
  316. package/dist/browser/utils.d.ts.map +0 -1
  317. package/dist/browser/utils.js.map +0 -1
  318. package/dist/commonjs/utils.d.ts.map +0 -1
  319. package/dist/commonjs/utils.js.map +0 -1
  320. package/dist/esm/utils.d.ts.map +0 -1
  321. package/dist/esm/utils.js.map +0 -1
  322. package/dist/react-native/utils.d.ts.map +0 -1
  323. package/dist/react-native/utils.js.map +0 -1
package/README.md CHANGED
@@ -27,6 +27,7 @@ Use the AI Agents client library to:
27
27
  - [File Search](#create-agent-with-file-search)
28
28
  - [Code interpreter](#create-agent-with-code-interpreter)
29
29
  - [Bing grounding](#create-agent-with-bing-grounding)
30
+ - [Deep research](#create-agent-with-deep-research)
30
31
  - [Azure AI Search](#create-agent-with-azure-ai-search)
31
32
  - [Function call](#create-agent-with-function-call)
32
33
  - [Create thread](#create-thread) with
@@ -143,6 +144,34 @@ const agent = await client.createAgent("gpt-4o", {
143
144
  console.log(`Created agent, agent ID: ${agent.id}`);
144
145
  ```
145
146
 
147
+ #### Multiple Agents
148
+ You can create multiple Agents with different tools and then connect them together.
149
+
150
+ ```ts snippet:MultiAgents
151
+ import { ToolUtility } from "@azure/ai-agents";
152
+
153
+ const connectedAgentName = "stock_price_bot";
154
+ const modelDeploymentName = process.env["MODEL_DEPLOYMENT_NAME"] || "gpt-4o";
155
+ const stockAgent = await client.createAgent(modelDeploymentName, {
156
+ name: "stock-price-agent",
157
+ instructions:
158
+ "Your job is to get the stock price of a company. If you don't know the realtime stock price, return the last known stock price.",
159
+ });
160
+ // Initialize Connected Agent tool with the agent id, name, and description
161
+ const connectedAgentTool = ToolUtility.createConnectedAgentTool(
162
+ stockAgent.id,
163
+ connectedAgentName,
164
+ "Gets the stock price of a company",
165
+ );
166
+ // Create agent with the Connected Agent tool and process assistant run
167
+ const agent = await client.createAgent(modelDeploymentName, {
168
+ name: "my-agent",
169
+ instructions: "You are a helpful assistant, and use the connected agent to get stock prices.",
170
+ tools: [connectedAgentTool.definition],
171
+ });
172
+ console.log(`Created agent, agent ID: ${agent.id}`);
173
+ ```
174
+
146
175
  #### Create Agent with File Search
147
176
 
148
177
  To perform file search by an Agent, we first need to upload a file, create a vector store, and associate the file to the vector store. Here is an example:
@@ -223,6 +252,80 @@ const agent = await client.createAgent("gpt-4o", {
223
252
  });
224
253
  console.log(`Created agent, agent ID : ${agent.id}`);
225
254
  ```
255
+ #### Create Agent with Deep Research
256
+
257
+ To enable your Agent to do a detailed research of a topic, use the `DeepResearchTool` along with a connection to a Bing Grounding resource.
258
+ This scenario requires you to specify two model deployments. One is the generic chat model that does arbitration, and is
259
+ specified as usual when you call the `createAgent` method. The other is the Deep Research model, which is specified
260
+ when you define the `DeepResearchTool`.
261
+
262
+ Here is an example to integrate Deep ReSearch:
263
+
264
+ ```ts snippet:DeepResearch
265
+ import { DeepResearchToolDefinition } from "@azure/ai-agents";
266
+
267
+ const bingConnectionId = process.env["AZURE_BING_CONNECTION_ID"] || "<connection-name>";
268
+ const deepResearchModelDeploymentName =
269
+ process.env["DEEP_RESEARCH_MODEL_DEPLOYMENT_NAME"] || "gpt-4o";
270
+ const modelDeploymentName = process.env["MODEL_DEPLOYMENT_NAME"] || "gpt-4o";
271
+ // Create Deep Research tool definition
272
+ const deepResearchTool: DeepResearchToolDefinition = {
273
+ type: "deep_research",
274
+ deepResearch: {
275
+ deepResearchModel: deepResearchModelDeploymentName,
276
+ deepResearchBingGroundingConnections: [
277
+ {
278
+ connectionId: bingConnectionId,
279
+ },
280
+ ],
281
+ },
282
+ };
283
+ // Create agent with the Deep Research tool
284
+ const agent = await client.createAgent(modelDeploymentName, {
285
+ name: "my-agent",
286
+ instructions: "You are a helpful Agent that assists in researching scientific topics.",
287
+ tools: [deepResearchTool],
288
+ });
289
+ console.log(`Created agent, ID: ${agent.id}`);
290
+ ```
291
+
292
+ #### Create Agent with MCP tool
293
+
294
+ To enable your Agent to use the MCP tool, you can create an instance of the MCP tool and pass it to the agent during creation.
295
+ Here is an example to integrate MCP tool:
296
+
297
+ ```ts snippet:MCPTool
298
+ import { AgentsClient, ToolUtility } from "@azure/ai-agents";
299
+ import { DefaultAzureCredential } from "@azure/identity";
300
+
301
+ // Get MCP server configuration from environment variables
302
+ const mcpServerUrl =
303
+ process.env["MCP_SERVER_URL"] || "https://gitmcp.io/Azure/azure-rest-api-specs";
304
+ const mcpServerLabel = process.env["MCP_SERVER_LABEL"] || "github";
305
+ // Create an Azure AI Client
306
+ const client = new AgentsClient(projectEndpoint, new DefaultAzureCredential());
307
+ // Initialize agent MCP tool
308
+ const mcpTool = ToolUtility.createMCPTool({
309
+ serverLabel: mcpServerLabel,
310
+ serverUrl: mcpServerUrl,
311
+ allowedTools: [], // Optional: specify allowed tools
312
+ });
313
+ // You can also add or remove allowed tools dynamically
314
+ const searchApiCode = "search_azure_rest_api_code";
315
+ mcpTool.allowTool(searchApiCode);
316
+ console.log(`Allowed tools: ${mcpTool.allowedTools}`);
317
+ // Create agent with MCP tool
318
+ const agent = await client.createAgent(modelDeploymentName, {
319
+ name: "my-mcp-agent",
320
+ instructions:
321
+ "You are a helpful agent that can use MCP tools to assist users. Use the available MCP tools to answer questions and perform tasks.",
322
+ tools: mcpTool.definitions,
323
+ });
324
+ console.log(`Created agent, agent ID : ${agent.id}`);
325
+ ```
326
+
327
+
328
+
226
329
 
227
330
  #### Create Agent with Azure AI Search
228
331
 
@@ -580,7 +683,7 @@ const content = [
580
683
  },
581
684
  {
582
685
  type: "image_url",
583
- image_url: {
686
+ imageUrl: {
584
687
  url: imageDataUrl,
585
688
  detail: "high",
586
689
  },
@@ -11,13 +11,18 @@ import { _getRunsOperations } from "./classic/runs/index.js";
11
11
  import { _getMessagesOperations } from "./classic/messages/index.js";
12
12
  import { _getThreadsOperations } from "./classic/threads/index.js";
13
13
  export class AgentsClient {
14
+ _client;
15
+ /** The pipeline used by this client to make requests */
16
+ pipeline;
14
17
  constructor(endpointParam, credential, options = {}) {
15
- var _a;
16
- const prefixFromOptions = (_a = options === null || options === void 0 ? void 0 : options.userAgentOptions) === null || _a === void 0 ? void 0 : _a.userAgentPrefix;
18
+ const prefixFromOptions = options?.userAgentOptions?.userAgentPrefix;
17
19
  const userAgentPrefix = prefixFromOptions
18
20
  ? `${prefixFromOptions} azsdk-js-client`
19
21
  : `azsdk-js-client`;
20
- this._client = createAgents(endpointParam, credential, Object.assign(Object.assign({}, options), { userAgentOptions: { userAgentPrefix } }));
22
+ this._client = createAgents(endpointParam, credential, {
23
+ ...options,
24
+ userAgentOptions: { userAgentPrefix },
25
+ });
21
26
  this.pipeline = this._client.pipeline;
22
27
  this.vectorStoreFileBatches = _getVectorStoreFileBatchesOperations(this._client);
23
28
  this.vectorStoreFiles = _getVectorStoreFilesOperations(this._client);
@@ -28,6 +33,22 @@ export class AgentsClient {
28
33
  this.messages = _getMessagesOperations(this._client);
29
34
  this.threads = _getThreadsOperations(this._client);
30
35
  }
36
+ /** The operation groups for vectorStoreFileBatches */
37
+ vectorStoreFileBatches;
38
+ /** The operation groups for vectorStoreFiles */
39
+ vectorStoreFiles;
40
+ /** The operation groups for vectorStores */
41
+ vectorStores;
42
+ /** The operation groups for files */
43
+ files;
44
+ /** The operation groups for runSteps */
45
+ runSteps;
46
+ /** The operation groups for runs */
47
+ runs;
48
+ /** The operation groups for messages */
49
+ messages;
50
+ /** The operation groups for threads */
51
+ threads;
31
52
  /** Deletes an agent. */
32
53
  deleteAgent(assistantId, options = { requestOptions: {} }) {
33
54
  return deleteAgent(this._client, assistantId, options);
@@ -1 +1 @@
1
- {"version":3,"file":"agentsClient.js","sourceRoot":"","sources":["../../src/agentsClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAS9C,OAAO,E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copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { AgentsContext, AgentsClientOptionalParams } from \"./api/index.js\";\nimport { createAgents } from \"./api/index.js\";\nimport type { Agent, AgentDeletionStatus } from \"./models/models.js\";\nimport type {\n DeleteAgentOptionalParams,\n UpdateAgentOptionalParams,\n GetAgentOptionalParams,\n ListAgentsOptionalParams,\n CreateAgentOptionalParams,\n} from \"./api/options.js\";\nimport { deleteAgent, updateAgent, getAgent, listAgents, createAgent } from \"./api/operations.js\";\nimport type { VectorStoreFileBatchesOperations } from \"./classic/vectorStoreFileBatches/index.js\";\nimport { _getVectorStoreFileBatchesOperations } from \"./classic/vectorStoreFileBatches/index.js\";\nimport type { VectorStoreFilesOperations } from \"./classic/vectorStoreFiles/index.js\";\nimport { _getVectorStoreFilesOperations } from \"./classic/vectorStoreFiles/index.js\";\nimport type { VectorStoresOperations } from \"./classic/vectorStores/index.js\";\nimport { _getVectorStoresOperations } from \"./classic/vectorStores/index.js\";\nimport type { FilesOperations } from \"./classic/files/index.js\";\nimport { _getFilesOperations } from \"./classic/files/index.js\";\nimport type { RunStepsOperations } from \"./classic/runSteps/index.js\";\nimport { _getRunStepsOperations } from \"./classic/runSteps/index.js\";\nimport type { RunsOperations } from \"./classic/runs/index.js\";\nimport { _getRunsOperations } from \"./classic/runs/index.js\";\nimport type { MessagesOperations } from \"./classic/messages/index.js\";\nimport { _getMessagesOperations } from \"./classic/messages/index.js\";\nimport type { ThreadsOperations } from \"./classic/threads/index.js\";\nimport { _getThreadsOperations } from \"./classic/threads/index.js\";\nimport type { PagedAsyncIterableIterator } from \"./static-helpers/pagingHelpers.js\";\nimport type { Pipeline } from \"@azure/core-rest-pipeline\";\nimport type { TokenCredential } from \"@azure/core-auth\";\n\nexport { AgentsClientOptionalParams } from \"./api/agentsContext.js\";\n\nexport class AgentsClient {\n private _client: AgentsContext;\n /** The pipeline used by this client to make requests */\n public readonly pipeline: Pipeline;\n\n constructor(\n endpointParam: string,\n credential: TokenCredential,\n options: AgentsClientOptionalParams = {},\n ) {\n const prefixFromOptions = options?.userAgentOptions?.userAgentPrefix;\n const userAgentPrefix = prefixFromOptions\n ? `${prefixFromOptions} azsdk-js-client`\n : `azsdk-js-client`;\n this._client = createAgents(endpointParam, credential, {\n ...options,\n userAgentOptions: { userAgentPrefix },\n });\n this.pipeline = this._client.pipeline;\n this.vectorStoreFileBatches = _getVectorStoreFileBatchesOperations(this._client);\n this.vectorStoreFiles = _getVectorStoreFilesOperations(this._client);\n this.vectorStores = _getVectorStoresOperations(this._client);\n this.files = _getFilesOperations(this._client);\n this.runSteps = _getRunStepsOperations(this._client);\n this.runs = _getRunsOperations(this._client);\n this.messages = _getMessagesOperations(this._client);\n this.threads = _getThreadsOperations(this._client);\n }\n\n /** The operation groups for vectorStoreFileBatches */\n public readonly vectorStoreFileBatches: VectorStoreFileBatchesOperations;\n /** The operation groups for vectorStoreFiles */\n public readonly vectorStoreFiles: VectorStoreFilesOperations;\n /** The operation groups for vectorStores */\n public readonly vectorStores: VectorStoresOperations;\n /** The operation groups for files */\n public readonly files: FilesOperations;\n /** The operation groups for runSteps */\n public readonly runSteps: RunStepsOperations;\n /** The operation groups for runs */\n public readonly runs: RunsOperations;\n /** The operation groups for messages */\n public readonly messages: MessagesOperations;\n /** The operation groups for threads */\n public readonly threads: ThreadsOperations;\n\n /** Deletes an agent. */\n deleteAgent(\n assistantId: string,\n options: DeleteAgentOptionalParams = { requestOptions: {} },\n ): Promise<AgentDeletionStatus> {\n return deleteAgent(this._client, assistantId, options);\n }\n\n /** Modifies an existing agent. */\n updateAgent(\n assistantId: string,\n options: UpdateAgentOptionalParams = { requestOptions: {} },\n ): Promise<Agent> {\n return updateAgent(this._client, assistantId, options);\n }\n\n /** Retrieves an existing agent. */\n getAgent(\n assistantId: string,\n options: GetAgentOptionalParams = { requestOptions: {} },\n ): Promise<Agent> {\n return getAgent(this._client, assistantId, options);\n }\n\n /** Gets a list of agents that were previously created. */\n listAgents(\n options: ListAgentsOptionalParams = { requestOptions: {} },\n ): PagedAsyncIterableIterator<Agent> {\n return listAgents(this._client, options);\n }\n\n /** Creates a new agent. */\n createAgent(\n model: string,\n options: CreateAgentOptionalParams = { requestOptions: {} },\n ): Promise<Agent> {\n return createAgent(this._client, model, options);\n }\n}\n"]}
1
+ {"version":3,"file":"agentsClient.js","sourceRoot":"","sources":["../../src/agentsClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAS9C,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElG,OAAO,EAAE,oCAAoC,EAAE,MAAM,2CAA2C,CAAC;AAEjG,OAAO,EAAE,8BAA8B,EAAE,MAAM,qCAAqC,CAAC;AAErF,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAE7E,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAErE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAErE,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAOnE,MAAM,OAAO,YAAY;IACf,OAAO,CAAgB;IAC/B,wDAAwD;IACxC,QAAQ,CAAW;IAEnC,YACE,aAAqB,EACrB,UAA2B,EAC3B,UAAsC,EAAE;QAExC,MAAM,iBAAiB,GAAG,OAAO,EAAE,gBAAgB,EAAE,eAAe,CAAC;QACrE,MAAM,eAAe,GAAG,iBAAiB;YACvC,CAAC,CAAC,GAAG,iBAAiB,kBAAkB;YACxC,CAAC,CAAC,iBAAiB,CAAC;QACtB,IAAI,CAAC,OAAO,GAAG,YAAY,CAAC,aAAa,EAAE,UAAU,EA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IAClC,WAAW,CACT,WAAmB,EACnB,UAAqC,EAAE,cAAc,EAAE,EAAE,EAAE;QAE3D,OAAO,WAAW,CAAC,IAAI,CAAC,OAAO,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;IACzD,CAAC;IAED,mCAAmC;IACnC,QAAQ,CACN,WAAmB,EACnB,UAAkC,EAAE,cAAc,EAAE,EAAE,EAAE;QAExD,OAAO,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;IACtD,CAAC;IAED,0DAA0D;IAC1D,UAAU,CACR,UAAoC,EAAE,cAAc,EAAE,EAAE,EAAE;QAE1D,OAAO,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC3C,CAAC;IAED,2BAA2B;IAC3B,WAAW,CACT,KAAa,EACb,UAAqC,EAAE,cAAc,EAAE,EAAE,EAAE;QAE3D,OAAO,WAAW,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IACnD,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { AgentsContext, AgentsClientOptionalParams } from \"./api/index.js\";\nimport { createAgents } from \"./api/index.js\";\nimport type { Agent, AgentDeletionStatus } from \"./models/models.js\";\nimport type {\n DeleteAgentOptionalParams,\n UpdateAgentOptionalParams,\n GetAgentOptionalParams,\n ListAgentsOptionalParams,\n CreateAgentOptionalParams,\n} from \"./api/options.js\";\nimport { deleteAgent, updateAgent, getAgent, listAgents, createAgent } from \"./api/operations.js\";\nimport type { VectorStoreFileBatchesOperations } from \"./classic/vectorStoreFileBatches/index.js\";\nimport { _getVectorStoreFileBatchesOperations } from \"./classic/vectorStoreFileBatches/index.js\";\nimport type { VectorStoreFilesOperations } from \"./classic/vectorStoreFiles/index.js\";\nimport { _getVectorStoreFilesOperations } from \"./classic/vectorStoreFiles/index.js\";\nimport type { VectorStoresOperations } from \"./classic/vectorStores/index.js\";\nimport { _getVectorStoresOperations } from \"./classic/vectorStores/index.js\";\nimport type { FilesOperations } from \"./classic/files/index.js\";\nimport { _getFilesOperations } from \"./classic/files/index.js\";\nimport type { RunStepsOperations } from \"./classic/runSteps/index.js\";\nimport { _getRunStepsOperations } from \"./classic/runSteps/index.js\";\nimport type { RunsOperations } from \"./classic/runs/index.js\";\nimport { _getRunsOperations } from \"./classic/runs/index.js\";\nimport type { MessagesOperations } from \"./classic/messages/index.js\";\nimport { _getMessagesOperations } from \"./classic/messages/index.js\";\nimport type { ThreadsOperations } from \"./classic/threads/index.js\";\nimport { _getThreadsOperations } from \"./classic/threads/index.js\";\nimport type { PagedAsyncIterableIterator } from \"./static-helpers/pagingHelpers.js\";\nimport type { Pipeline } from \"@azure/core-rest-pipeline\";\nimport type { TokenCredential } from \"@azure/core-auth\";\n\nexport { AgentsClientOptionalParams } from \"./api/agentsContext.js\";\n\nexport class AgentsClient {\n private _client: AgentsContext;\n /** The pipeline used by this client to make requests */\n public readonly pipeline: Pipeline;\n\n constructor(\n endpointParam: string,\n credential: TokenCredential,\n options: AgentsClientOptionalParams = {},\n ) {\n const prefixFromOptions = options?.userAgentOptions?.userAgentPrefix;\n const userAgentPrefix = prefixFromOptions\n ? `${prefixFromOptions} azsdk-js-client`\n : `azsdk-js-client`;\n this._client = createAgents(endpointParam, credential, {\n ...options,\n userAgentOptions: { userAgentPrefix },\n });\n this.pipeline = this._client.pipeline;\n this.vectorStoreFileBatches = _getVectorStoreFileBatchesOperations(this._client);\n this.vectorStoreFiles = _getVectorStoreFilesOperations(this._client);\n this.vectorStores = _getVectorStoresOperations(this._client);\n this.files = _getFilesOperations(this._client);\n this.runSteps = _getRunStepsOperations(this._client);\n this.runs = _getRunsOperations(this._client);\n this.messages = _getMessagesOperations(this._client);\n this.threads = _getThreadsOperations(this._client);\n }\n\n /** The operation groups for vectorStoreFileBatches */\n public readonly vectorStoreFileBatches: VectorStoreFileBatchesOperations;\n /** The operation groups for vectorStoreFiles */\n public readonly vectorStoreFiles: VectorStoreFilesOperations;\n /** The operation groups for vectorStores */\n public readonly vectorStores: VectorStoresOperations;\n /** The operation groups for files */\n public readonly files: FilesOperations;\n /** The operation groups for runSteps */\n public readonly runSteps: RunStepsOperations;\n /** The operation groups for runs */\n public readonly runs: RunsOperations;\n /** The operation groups for messages */\n public readonly messages: MessagesOperations;\n /** The operation groups for threads */\n public readonly threads: ThreadsOperations;\n\n /** Deletes an agent. */\n deleteAgent(\n assistantId: string,\n options: DeleteAgentOptionalParams = { requestOptions: {} },\n ): Promise<AgentDeletionStatus> {\n return deleteAgent(this._client, assistantId, options);\n }\n\n /** Modifies an existing agent. */\n updateAgent(\n assistantId: string,\n options: UpdateAgentOptionalParams = { requestOptions: {} },\n ): Promise<Agent> {\n return updateAgent(this._client, assistantId, options);\n }\n\n /** Retrieves an existing agent. */\n getAgent(\n assistantId: string,\n options: GetAgentOptionalParams = { requestOptions: {} },\n ): Promise<Agent> {\n return getAgent(this._client, assistantId, options);\n }\n\n /** Gets a list of agents that were previously created. */\n listAgents(\n options: ListAgentsOptionalParams = { requestOptions: {} },\n ): PagedAsyncIterableIterator<Agent> {\n return listAgents(this._client, options);\n }\n\n /** Creates a new agent. */\n createAgent(\n model: string,\n options: CreateAgentOptionalParams = { requestOptions: {} },\n ): Promise<Agent> {\n return createAgent(this._client, model, options);\n }\n}\n"]}
@@ -1,22 +1,25 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
2
  // Licensed under the MIT License.
3
- import { __rest } from "tslib";
4
3
  import { logger } from "../logger.js";
5
4
  import { getClient } from "@azure-rest/core-client";
6
5
  export function createAgents(endpointParam, credential, options = {}) {
7
- var _a, _b, _c, _d, _e, _f, _g, _h;
8
- const endpointUrl = (_b = (_a = options.endpoint) !== null && _a !== void 0 ? _a : options.baseUrl) !== null && _b !== void 0 ? _b : String(endpointParam);
9
- const prefixFromOptions = (_c = options === null || options === void 0 ? void 0 : options.userAgentOptions) === null || _c === void 0 ? void 0 : _c.userAgentPrefix;
10
- const userAgentInfo = `azsdk-js-ai-agents/1.0.0`;
6
+ const endpointUrl = options.endpoint ?? options.baseUrl ?? String(endpointParam);
7
+ const prefixFromOptions = options?.userAgentOptions?.userAgentPrefix;
8
+ const userAgentInfo = `azsdk-js-ai-agents/1.1.0-beta.1`;
11
9
  const userAgentPrefix = prefixFromOptions
12
10
  ? `${prefixFromOptions} azsdk-js-api ${userAgentInfo}`
13
11
  : `azsdk-js-api ${userAgentInfo}`;
14
- const _j = Object.assign(Object.assign({}, options), { userAgentOptions: { userAgentPrefix }, loggingOptions: { logger: (_e = (_d = options.loggingOptions) === null || _d === void 0 ? void 0 : _d.logger) !== null && _e !== void 0 ? _e : logger.info }, credentials: {
15
- scopes: (_g = (_f = options.credentials) === null || _f === void 0 ? void 0 : _f.scopes) !== null && _g !== void 0 ? _g : ["https://ai.azure.com/.default"],
16
- } }), { apiVersion: _ } = _j, updatedOptions = __rest(_j, ["apiVersion"]);
12
+ const { apiVersion: _, ...updatedOptions } = {
13
+ ...options,
14
+ userAgentOptions: { userAgentPrefix },
15
+ loggingOptions: { logger: options.loggingOptions?.logger ?? logger.info },
16
+ credentials: {
17
+ scopes: options.credentials?.scopes ?? ["https://ai.azure.com/.default"],
18
+ },
19
+ };
17
20
  const clientContext = getClient(endpointUrl, credential, updatedOptions);
18
21
  clientContext.pipeline.removePolicy({ name: "ApiVersionPolicy" });
19
- const apiVersion = (_h = options.apiVersion) !== null && _h !== void 0 ? _h : "v1";
22
+ const apiVersion = options.apiVersion ?? "2025-05-15-preview";
20
23
  clientContext.pipeline.addPolicy({
21
24
  name: "ClientApiVersionPolicy",
22
25
  sendRequest: (req, next) => {
@@ -29,6 +32,6 @@ export function createAgents(endpointParam, credential, options = {}) {
29
32
  return next(req);
30
33
  },
31
34
  });
32
- return Object.assign(Object.assign({}, clientContext), { apiVersion });
35
+ return { ...clientContext, apiVersion };
33
36
  }
34
37
  //# sourceMappingURL=agentsContext.js.map
@@ -1 +1 @@
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,CAAC,UAAU,mCAAI,IAAI,CAAC;IAC9C,aAAa,CAAC,QAAQ,CAAC,SAAS,CAAC;QAC/B,IAAI,EAAE,wBAAwB;QAC9B,WAAW,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;YACzB,qDAAqD;YACrD,yEAAyE;YACzE,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YAC7B,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,CAAC;gBACzC,GAAG,CAAC,GAAG,GAAG,GAAG,GAAG,CAAC,GAAG,GAClB,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GACzD,eAAe,UAAU,EAAE,CAAC;YAC9B,CAAC;YAED,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;QACnB,CAAC;KACF,CAAC,CAAC;IACH,OAAO,gCAAK,aAAa,KAAE,UAAU,GAAmB,CAAC;AAC3D,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { logger } from \"../logger.js\";\nimport { KnownVersions } from \"../models/models.js\";\nimport { Client, ClientOptions, getClient } from \"@azure-rest/core-client\";\nimport { TokenCredential } from \"@azure/core-auth\";\n\nexport interface AgentsContext extends Client {\n /** The API version to use for this operation. */\n /** Known values of {@link KnownVersions} that the service accepts. */\n apiVersion: string;\n}\n\n/** Optional parameters for the client. */\nexport interface AgentsClientOptionalParams extends ClientOptions {\n /** The API version to use for this operation. */\n /** Known values of {@link KnownVersions} that the service accepts. */\n apiVersion?: string;\n}\n\nexport function createAgents(\n endpointParam: string,\n credential: TokenCredential,\n options: AgentsClientOptionalParams = {},\n): AgentsContext {\n const endpointUrl = options.endpoint ?? options.baseUrl ?? String(endpointParam);\n const prefixFromOptions = options?.userAgentOptions?.userAgentPrefix;\n const userAgentInfo = `azsdk-js-ai-agents/1.0.0`;\n const userAgentPrefix = prefixFromOptions\n ? `${prefixFromOptions} azsdk-js-api ${userAgentInfo}`\n : `azsdk-js-api ${userAgentInfo}`;\n const { apiVersion: _, ...updatedOptions } = {\n ...options,\n userAgentOptions: { userAgentPrefix },\n loggingOptions: { logger: options.loggingOptions?.logger ?? logger.info },\n credentials: {\n scopes: options.credentials?.scopes ?? [\"https://ai.azure.com/.default\"],\n },\n };\n const clientContext = getClient(endpointUrl, credential, updatedOptions);\n clientContext.pipeline.removePolicy({ name: \"ApiVersionPolicy\" });\n const apiVersion = options.apiVersion ?? \"v1\";\n clientContext.pipeline.addPolicy({\n name: \"ClientApiVersionPolicy\",\n sendRequest: (req, next) => {\n // Use the apiVersion defined in request url directly\n // Append one if there is no apiVersion and we have one at client options\n const url = new URL(req.url);\n if (!url.searchParams.get(\"api-version\")) {\n req.url = `${req.url}${\n Array.from(url.searchParams.keys()).length > 0 ? \"&\" : \"?\"\n }api-version=${apiVersion}`;\n }\n\n return next(req);\n },\n });\n return { ...clientContext, apiVersion } as AgentsContext;\n}\n"]}
1
+ {"version":3,"file":"agentsContext.js","sourceRoot":"","sources":["../../../src/api/agentsContext.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,OAAO,EAAyB,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAgB3E,MAAM,UAAU,YAAY,CAC1B,aAAqB,EACrB,UAA2B,EAC3B,UAAsC,EAAE;IAExC,MAAM,WAAW,GAAG,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,OAAO,IAAI,MAAM,CAAC,aAAa,CAAC,CAAC;IACjF,MAAM,iBAAiB,GAAG,OAAO,EAAE,gBAAgB,EAAE,eAAe,CAAC;IACrE,MAAM,aAAa,GAAG,iCAAiC,CAAC;IACxD,MAAM,eAAe,GAAG,iBAAiB;Q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AAC;QACnB,CAAC;KACF,CAAC,CAAC;IACH,OAAO,EAAE,GAAG,aAAa,EAAE,UAAU,EAAmB,CAAC;AAC3D,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { logger } from \"../logger.js\";\nimport { KnownVersions } from \"../models/models.js\";\nimport { Client, ClientOptions, getClient } from \"@azure-rest/core-client\";\nimport { TokenCredential } from \"@azure/core-auth\";\n\nexport interface AgentsContext extends Client {\n /** The API version to use for this operation. */\n /** Known values of {@link KnownVersions} that the service accepts. */\n apiVersion: string;\n}\n\n/** Optional parameters for the client. */\nexport interface AgentsClientOptionalParams extends ClientOptions {\n /** The API version to use for this operation. */\n /** Known values of {@link KnownVersions} that the service accepts. */\n apiVersion?: string;\n}\n\nexport function createAgents(\n endpointParam: string,\n credential: TokenCredential,\n options: AgentsClientOptionalParams = {},\n): AgentsContext {\n const endpointUrl = options.endpoint ?? options.baseUrl ?? String(endpointParam);\n const prefixFromOptions = options?.userAgentOptions?.userAgentPrefix;\n const userAgentInfo = `azsdk-js-ai-agents/1.1.0-beta.1`;\n const userAgentPrefix = prefixFromOptions\n ? `${prefixFromOptions} azsdk-js-api ${userAgentInfo}`\n : `azsdk-js-api ${userAgentInfo}`;\n const { apiVersion: _, ...updatedOptions } = {\n ...options,\n userAgentOptions: { userAgentPrefix },\n loggingOptions: { logger: options.loggingOptions?.logger ?? logger.info },\n credentials: {\n scopes: options.credentials?.scopes ?? [\"https://ai.azure.com/.default\"],\n },\n };\n const clientContext = getClient(endpointUrl, credential, updatedOptions);\n clientContext.pipeline.removePolicy({ name: \"ApiVersionPolicy\" });\n const apiVersion = options.apiVersion ?? \"2025-05-15-preview\";\n clientContext.pipeline.addPolicy({\n name: \"ClientApiVersionPolicy\",\n sendRequest: (req, next) => {\n // Use the apiVersion defined in request url directly\n // Append one if there is no apiVersion and we have one at client options\n const url = new URL(req.url);\n if (!url.searchParams.get(\"api-version\")) {\n req.url = `${req.url}${\n Array.from(url.searchParams.keys()).length > 0 ? \"&\" : \"?\"\n }api-version=${apiVersion}`;\n }\n\n return next(req);\n },\n });\n return { ...clientContext, apiVersion } as AgentsContext;\n}\n"]}
@@ -5,14 +5,19 @@ import { expandUrlTemplate } from "../../static-helpers/urlTemplate.js";
5
5
  import { createRestError, operationOptionsToRequestParameters } from "@azure-rest/core-client";
6
6
  import { createPoller } from "../poller.js";
7
7
  export function _getFileContentSend(context, fileId, options = { requestOptions: {} }) {
8
- var _a, _b;
9
- const path = expandUrlTemplate("/files/{fileId}/content{?api%2Dversion}", {
8
+ const path = expandUrlTemplate("/files/{fileId}/content{?api-version}", {
10
9
  fileId: fileId,
11
- "api%2Dversion": context.apiVersion,
10
+ "api-version": context.apiVersion,
12
11
  }, {
13
- allowReserved: (_a = options === null || options === void 0 ? void 0 : options.requestOptions) === null || _a === void 0 ? void 0 : _a.skipUrlEncoding,
12
+ allowReserved: options?.requestOptions?.skipUrlEncoding,
13
+ });
14
+ return context.path(path).get({
15
+ ...operationOptionsToRequestParameters(options),
16
+ headers: {
17
+ accept: "application/octet-stream",
18
+ ...options.requestOptions?.headers,
19
+ },
14
20
  });
15
- return context.path(path).get(Object.assign(Object.assign({}, operationOptionsToRequestParameters(options)), { headers: Object.assign({ accept: "application/octet-stream" }, (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.headers) }));
16
21
  }
17
22
  /** Retrieves the raw content of a specific file. */
18
23
  export function getFileContent(context, fileId, options = { requestOptions: {} }) {
@@ -20,14 +25,19 @@ export function getFileContent(context, fileId, options = { requestOptions: {} }
20
25
  return result;
21
26
  }
22
27
  export function _getFileSend(context, fileId, options = { requestOptions: {} }) {
23
- var _a, _b;
24
- const path = expandUrlTemplate("/files/{fileId}{?api%2Dversion}", {
28
+ const path = expandUrlTemplate("/files/{fileId}{?api-version}", {
25
29
  fileId: fileId,
26
- "api%2Dversion": context.apiVersion,
30
+ "api-version": context.apiVersion,
27
31
  }, {
28
- allowReserved: (_a = options === null || options === void 0 ? void 0 : options.requestOptions) === null || _a === void 0 ? void 0 : _a.skipUrlEncoding,
32
+ allowReserved: options?.requestOptions?.skipUrlEncoding,
33
+ });
34
+ return context.path(path).get({
35
+ ...operationOptionsToRequestParameters(options),
36
+ headers: {
37
+ accept: "application/json",
38
+ ...options.requestOptions?.headers,
39
+ },
29
40
  });
30
- return context.path(path).get(Object.assign(Object.assign({}, operationOptionsToRequestParameters(options)), { headers: Object.assign({ accept: "application/json" }, (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.headers) }));
31
41
  }
32
42
  export async function _getFileDeserialize(result) {
33
43
  const expectedStatuses = ["200"];
@@ -44,14 +54,19 @@ export async function getFile(context, fileId, options = { requestOptions: {} })
44
54
  return _getFileDeserialize(result);
45
55
  }
46
56
  export function _deleteFileSend(context, fileId, options = { requestOptions: {} }) {
47
- var _a, _b;
48
57
  const path = expandUrlTemplate("/files/{fileId}{?api%2Dversion}", {
49
58
  fileId: fileId,
50
59
  "api%2Dversion": context.apiVersion,
51
60
  }, {
52
- allowReserved: (_a = options === null || options === void 0 ? void 0 : options.requestOptions) === null || _a === void 0 ? void 0 : _a.skipUrlEncoding,
61
+ allowReserved: options?.requestOptions?.skipUrlEncoding,
62
+ });
63
+ return context.path(path).delete({
64
+ ...operationOptionsToRequestParameters(options),
65
+ headers: {
66
+ accept: "application/json",
67
+ ...options.requestOptions?.headers,
68
+ },
53
69
  });
54
- return context.path(path).delete(Object.assign(Object.assign({}, operationOptionsToRequestParameters(options)), { headers: Object.assign({ accept: "application/json" }, (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.headers) }));
55
70
  }
56
71
  export async function _deleteFileDeserialize(result) {
57
72
  const expectedStatuses = ["200"];
@@ -68,13 +83,20 @@ export async function deleteFile(context, fileId, options = { requestOptions: {}
68
83
  return _deleteFileDeserialize(result);
69
84
  }
70
85
  export function _uploadFileSend(context, body, options = { requestOptions: {} }) {
71
- var _a, _b;
72
- const path = expandUrlTemplate("/files{?api%2Dversion}", {
73
- "api%2Dversion": context.apiVersion,
86
+ const path = expandUrlTemplate("/files{?api-version}", {
87
+ "api-version": context.apiVersion,
74
88
  }, {
75
- allowReserved: (_a = options === null || options === void 0 ? void 0 : options.requestOptions) === null || _a === void 0 ? void 0 : _a.skipUrlEncoding,
89
+ allowReserved: options?.requestOptions?.skipUrlEncoding,
90
+ });
91
+ return context.path(path).post({
92
+ ...operationOptionsToRequestParameters(options),
93
+ contentType: "multipart/form-data",
94
+ headers: {
95
+ accept: "application/json",
96
+ ...options.requestOptions?.headers,
97
+ },
98
+ body: _uploadFileRequestSerializer(body),
76
99
  });
77
- return context.path(path).post(Object.assign(Object.assign({}, operationOptionsToRequestParameters(options)), { contentType: "multipart/form-data", headers: Object.assign({ accept: "application/json" }, (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.headers), body: _uploadFileRequestSerializer(body) }));
78
100
  }
79
101
  export async function _uploadFileDeserialize(result) {
80
102
  const expectedStatuses = ["200"];
@@ -92,7 +114,6 @@ export async function uploadFileInternal(context, body, options = { requestOptio
92
114
  }
93
115
  /** Uploads a file for use by other operations. */
94
116
  export function uploadFile(context, body, options = { requestOptions: {} }) {
95
- var _a;
96
117
  return createPoller({
97
118
  initOperation: async () => {
98
119
  return uploadFileInternal(context, body, options);
@@ -106,12 +127,11 @@ export function uploadFile(context, body, options = { requestOptions: {} }) {
106
127
  ? new Error(`Operation failed: ${result.statusDetails}`)
107
128
  : undefined;
108
129
  },
109
- intervalInMs: (_a = options.pollingOptions) === null || _a === void 0 ? void 0 : _a.intervalInMs,
130
+ intervalInMs: options.pollingOptions?.intervalInMs,
110
131
  });
111
132
  }
112
133
  /** Uploads a file for use by other operations with polling */
113
134
  export function uploadFileAndPoll(context, body, options = { requestOptions: {} }) {
114
- var _a;
115
135
  return createPoller({
116
136
  initOperation: async () => {
117
137
  return uploadFileInternal(context, body, options);
@@ -125,18 +145,23 @@ export function uploadFileAndPoll(context, body, options = { requestOptions: {}
125
145
  ? new Error(`Operation failed: ${result.statusDetails}`)
126
146
  : undefined;
127
147
  },
128
- intervalInMs: (_a = options.pollingOptions) === null || _a === void 0 ? void 0 : _a.intervalInMs,
148
+ intervalInMs: options.pollingOptions?.intervalInMs,
129
149
  });
130
150
  }
131
151
  export function _listFilesSend(context, options = { requestOptions: {} }) {
132
- var _a, _b;
133
152
  const path = expandUrlTemplate("/files{?api%2Dversion,purpose}", {
134
153
  "api%2Dversion": context.apiVersion,
135
- purpose: options === null || options === void 0 ? void 0 : options.purpose,
154
+ purpose: options?.purpose,
136
155
  }, {
137
- allowReserved: (_a = options === null || options === void 0 ? void 0 : options.requestOptions) === null || _a === void 0 ? void 0 : _a.skipUrlEncoding,
156
+ allowReserved: options?.requestOptions?.skipUrlEncoding,
157
+ });
158
+ return context.path(path).get({
159
+ ...operationOptionsToRequestParameters(options),
160
+ headers: {
161
+ accept: "application/json",
162
+ ...options.requestOptions?.headers,
163
+ },
138
164
  });
139
- return context.path(path).get(Object.assign(Object.assign({}, operationOptionsToRequestParameters(options)), { headers: Object.assign({ accept: "application/json" }, (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.headers) }));
140
165
  }
141
166
  export async function _listFilesDeserialize(result) {
142
167
  const expectedStatuses = ["200"];
@@ -1 +1 @@
1
- {"version":3,"file":"operations.js","sourceRoot":"","sources":["../../../../src/api/files/operations.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AASlC,OAAO,EACL,wBAAwB,EACxB,4BAA4B,EAC5B,oBAAoB,EACpB,4BAA4B,EAC5B,8BAA8B,GAC/B,MAAM,wBAAwB,CAAC;AAQhC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAExE,OAAO,EAAE,eAAe,EAAE,mCAAmC,EAAE,MAAM,yBAAyB,CAAC;AAE/F,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,MAAM,UAAU,mBAAmB,CACjC,OAAe,EACf,MAAc,EACd,UAA6C,EAAE,cAA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AAmC,CAAC,OAAO,CAAC,KAC/C,OAAO,kBACL,MAAM,EAAE,kBAAkB,IACvB,MAAA,OAAO,CAAC,cAAc,0CAAE,OAAO,KAEpC,CAAC;AACL,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,MAA6B;IAE7B,MAAM,gBAAgB,GAAG,CAAC,KAAK,CAAC,CAAC;IACjC,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;QAC9C,MAAM,KAAK,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;QACtC,KAAK,CAAC,OAAO,GAAG,wBAAwB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACtD,MAAM,KAAK,CAAC;IACd,CAAC;IAED,OAAO,4BAA4B,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AACnD,CAAC;AAED,gDAAgD;AAChD,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,OAAe,EACf,UAAwC,EAAE,cAAc,EAAE,EAAE,EAAE;IAE9D,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACtD,OAAO,qBAAqB,CAAC,MAAM,CAAC,CAAC;AACvC,CAAC;AAED,SAAS,qBAAqB,CAAC,MAAgB;IAC7C,QAAQ,MAAM,CAAC,MAAM,EAAE,CAAC;QACtB,KAAK,SAAS,CAAC;QACf,KAAK,SAAS;YACZ,OAAO,SAAS,CAAC;QACnB,KAAK,UAAU,CAAC;QAChB,KAAK,WAAW;YACd,OAAO,WAAW,CAAC;QACrB;YACE,OAAO,QAAQ,CAAC;IACpB,CAAC;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { AgentsContext as Client } from \"../index.js\";\nimport type {\n FileListResponse,\n FileInfo,\n FilePurpose,\n FileDeletionStatus,\n} from \"../../models/models.js\";\nimport {\n agentV1ErrorDeserializer,\n fileListResponseDeserializer,\n fileInfoDeserializer,\n _uploadFileRequestSerializer,\n fileDeletionStatusDeserializer,\n} from \"../../models/models.js\";\nimport type {\n FilesGetFileContentOptionalParams,\n FilesGetFileOptionalParams,\n FilesDeleteFileOptionalParams,\n FilesUploadFileOptionalParams,\n FilesListFilesOptionalParams,\n} from \"./options.js\";\nimport { expandUrlTemplate } from \"../../static-helpers/urlTemplate.js\";\nimport type { StreamableMethod, PathUncheckedResponse } from \"@azure-rest/core-client\";\nimport { createRestError, operationOptionsToRequestParameters } from \"@azure-rest/core-client\";\nimport type { OperationState, OperationStatus, PollerLike } from \"@azure/core-lro\";\nimport { createPoller } from \"../poller.js\";\n\nexport function _getFileContentSend(\n context: Client,\n fileId: string,\n options: FilesGetFileContentOptionalParams = { requestOptions: {} },\n): StreamableMethod<string | Uint8Array> {\n const path = expandUrlTemplate(\n \"/files/{fileId}/content{?api%2Dversion}\",\n {\n fileId: fileId,\n \"api%2Dversion\": context.apiVersion,\n },\n {\n allowReserved: options?.requestOptions?.skipUrlEncoding,\n },\n );\n return context.path(path).get({\n ...operationOptionsToRequestParameters(options),\n headers: {\n accept: \"application/octet-stream\",\n ...options.requestOptions?.headers,\n },\n });\n}\n\n/** Retrieves the raw content of a specific file. */\nexport function getFileContent(\n context: Client,\n fileId: string,\n options: FilesGetFileContentOptionalParams = { requestOptions: {} },\n): StreamableMethod<string | Uint8Array> {\n const result = _getFileContentSend(context, fileId, options);\n return result;\n}\n\nexport function _getFileSend(\n context: Client,\n fileId: string,\n options: FilesGetFileOptionalParams = { requestOptions: {} },\n): StreamableMethod {\n const path = expandUrlTemplate(\n \"/files/{fileId}{?api%2Dversion}\",\n {\n fileId: fileId,\n \"api%2Dversion\": context.apiVersion,\n },\n {\n allowReserved: options?.requestOptions?.skipUrlEncoding,\n },\n );\n return context.path(path).get({\n ...operationOptionsToRequestParameters(options),\n headers: {\n accept: \"application/json\",\n ...options.requestOptions?.headers,\n },\n });\n}\n\nexport async function _getFileDeserialize(result: PathUncheckedResponse): Promise<FileInfo> {\n const expectedStatuses = [\"200\"];\n if (!expectedStatuses.includes(result.status)) {\n const error = createRestError(result);\n error.details = agentV1ErrorDeserializer(result.body);\n throw error;\n }\n\n return fileInfoDeserializer(result.body);\n}\n\n/** Returns information about a specific file. Does not retrieve file content. */\nexport async function getFile(\n context: Client,\n fileId: string,\n options: FilesGetFileOptionalParams = { requestOptions: {} },\n): Promise<FileInfo> {\n const result = await _getFileSend(context, fileId, options);\n return _getFileDeserialize(result);\n}\n\nexport function _deleteFileSend(\n context: Client,\n fileId: string,\n options: FilesDeleteFileOptionalParams = { requestOptions: {} },\n): StreamableMethod {\n const path = expandUrlTemplate(\n \"/files/{fileId}{?api%2Dversion}\",\n {\n fileId: fileId,\n \"api%2Dversion\": context.apiVersion,\n },\n {\n allowReserved: options?.requestOptions?.skipUrlEncoding,\n },\n );\n return context.path(path).delete({\n ...operationOptionsToRequestParameters(options),\n headers: {\n accept: \"application/json\",\n ...options.requestOptions?.headers,\n },\n });\n}\n\nexport async function _deleteFileDeserialize(\n result: PathUncheckedResponse,\n): Promise<FileDeletionStatus> {\n const expectedStatuses = [\"200\"];\n if (!expectedStatuses.includes(result.status)) {\n const error = createRestError(result);\n error.details = agentV1ErrorDeserializer(result.body);\n throw error;\n }\n\n return fileDeletionStatusDeserializer(result.body);\n}\n\n/** Delete a previously uploaded file. */\nexport async function deleteFile(\n context: Client,\n fileId: string,\n options: FilesDeleteFileOptionalParams = { requestOptions: {} },\n): Promise<FileDeletionStatus> {\n const result = await _deleteFileSend(context, fileId, options);\n return _deleteFileDeserialize(result);\n}\n\nexport function _uploadFileSend(\n context: Client,\n body: {\n file: ReadableStream<Uint8Array> | NodeJS.ReadableStream;\n purpose: FilePurpose;\n filename?: string;\n },\n options: FilesUploadFileOptionalParams = { requestOptions: {} },\n): StreamableMethod {\n const path = expandUrlTemplate(\n \"/files{?api%2Dversion}\",\n {\n \"api%2Dversion\": context.apiVersion,\n },\n {\n allowReserved: options?.requestOptions?.skipUrlEncoding,\n },\n );\n return context.path(path).post({\n ...operationOptionsToRequestParameters(options),\n contentType: \"multipart/form-data\",\n headers: {\n accept: \"application/json\",\n ...options.requestOptions?.headers,\n },\n body: _uploadFileRequestSerializer(body),\n });\n}\n\nexport async function _uploadFileDeserialize(result: PathUncheckedResponse): Promise<FileInfo> {\n const expectedStatuses = [\"200\"];\n if (!expectedStatuses.includes(result.status)) {\n const error = createRestError(result);\n error.details = agentV1ErrorDeserializer(result.body);\n throw error;\n }\n\n return fileInfoDeserializer(result.body);\n}\n\n/** Uploads a file for use by other operations. */\nexport async function uploadFileInternal(\n context: Client,\n body: {\n file: ReadableStream<Uint8Array> | NodeJS.ReadableStream;\n purpose: FilePurpose;\n filename?: string;\n },\n options: FilesUploadFileOptionalParams = { requestOptions: {} },\n): Promise<FileInfo> {\n const result = await _uploadFileSend(context, body, options);\n return _uploadFileDeserialize(result);\n}\n\n/** Uploads a file for use by other operations. */\nexport function uploadFile(\n context: Client,\n body: {\n file: ReadableStream<Uint8Array> | NodeJS.ReadableStream;\n purpose: FilePurpose;\n filename?: string;\n },\n options: FilesUploadFileOptionalParams = { requestOptions: {} },\n): PollerLike<OperationState<FileInfo>, FileInfo> {\n return createPoller<FileInfo>({\n initOperation: async () => {\n return uploadFileInternal(context, body, options);\n },\n pollOperation: async (currentResult: FileInfo) => {\n return getFile(context, currentResult.id, options);\n },\n getOperationStatus: getLroOperationStatus,\n getOperationError: (result: FileInfo) => {\n return getLroOperationStatus(result) === \"failed\" && result.statusDetails\n ? new Error(`Operation failed: ${result.statusDetails}`)\n : undefined;\n },\n intervalInMs: options.pollingOptions?.intervalInMs,\n });\n}\n\n/** Uploads a file for use by other operations with polling */\nexport function uploadFileAndPoll(\n context: Client,\n body: {\n file: ReadableStream<Uint8Array> | NodeJS.ReadableStream;\n purpose: FilePurpose;\n filename?: string;\n },\n options: FilesUploadFileOptionalParams = { requestOptions: {} },\n): PollerLike<OperationState<FileInfo>, FileInfo> {\n return createPoller<FileInfo>({\n initOperation: async () => {\n return uploadFileInternal(context, body, options);\n },\n pollOperation: async (currentResult: FileInfo) => {\n return getFile(context, currentResult.id, options);\n },\n getOperationStatus: getLroOperationStatus,\n getOperationError: (result: FileInfo) => {\n return getLroOperationStatus(result) === \"failed\" && result.statusDetails\n ? new Error(`Operation failed: ${result.statusDetails}`)\n : undefined;\n },\n intervalInMs: options.pollingOptions?.intervalInMs,\n });\n}\n\nexport function _listFilesSend(\n context: Client,\n options: FilesListFilesOptionalParams = { requestOptions: {} },\n): StreamableMethod {\n const path = expandUrlTemplate(\n \"/files{?api%2Dversion,purpose}\",\n {\n \"api%2Dversion\": context.apiVersion,\n purpose: options?.purpose,\n },\n {\n allowReserved: options?.requestOptions?.skipUrlEncoding,\n },\n );\n return context.path(path).get({\n ...operationOptionsToRequestParameters(options),\n headers: {\n accept: \"application/json\",\n ...options.requestOptions?.headers,\n },\n });\n}\n\nexport async function _listFilesDeserialize(\n result: PathUncheckedResponse,\n): Promise<FileListResponse> {\n const expectedStatuses = [\"200\"];\n if (!expectedStatuses.includes(result.status)) {\n const error = createRestError(result);\n error.details = agentV1ErrorDeserializer(result.body);\n throw error;\n }\n\n return fileListResponseDeserializer(result.body);\n}\n\n/** Gets a list of previously uploaded files. */\nexport async function listFiles(\n context: Client,\n options: FilesListFilesOptionalParams = { requestOptions: {} },\n): Promise<FileListResponse> {\n const result = await _listFilesSend(context, options);\n return _listFilesDeserialize(result);\n}\n\nfunction getLroOperationStatus(result: FileInfo): OperationStatus {\n switch (result.status) {\n case \"running\":\n case \"pending\":\n return \"running\";\n case \"uploaded\":\n case \"processed\":\n return \"succeeded\";\n default:\n return \"failed\";\n }\n}\n"]}
1
+ {"version":3,"file":"operations.js","sourceRoot":"","sources":["../../../../src/api/files/operations.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AASlC,OAAO,EACL,wBAAwB,EACxB,4BAA4B,EAC5B,oBAAoB,EACpB,4BAA4B,EAC5B,8BAA8B,G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esContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { AgentsContext as Client } from \"../index.js\";\nimport type {\n FileListResponse,\n FileInfo,\n FilePurpose,\n FileDeletionStatus,\n} from \"../../models/models.js\";\nimport {\n agentV1ErrorDeserializer,\n fileListResponseDeserializer,\n fileInfoDeserializer,\n _uploadFileRequestSerializer,\n fileDeletionStatusDeserializer,\n} from \"../../models/models.js\";\nimport type {\n FilesGetFileContentOptionalParams,\n FilesGetFileOptionalParams,\n FilesDeleteFileOptionalParams,\n FilesUploadFileOptionalParams,\n FilesListFilesOptionalParams,\n} from \"./options.js\";\nimport { expandUrlTemplate } from \"../../static-helpers/urlTemplate.js\";\nimport type { StreamableMethod, PathUncheckedResponse } from \"@azure-rest/core-client\";\nimport { createRestError, operationOptionsToRequestParameters } from \"@azure-rest/core-client\";\nimport type { OperationState, OperationStatus, PollerLike } from \"@azure/core-lro\";\nimport { createPoller } from \"../poller.js\";\n\nexport function _getFileContentSend(\n context: Client,\n fileId: string,\n options: FilesGetFileContentOptionalParams = { requestOptions: {} },\n): StreamableMethod<string | Uint8Array> {\n const path = expandUrlTemplate(\n \"/files/{fileId}/content{?api-version}\",\n {\n fileId: fileId,\n \"api-version\": context.apiVersion,\n },\n {\n allowReserved: options?.requestOptions?.skipUrlEncoding,\n },\n );\n return context.path(path).get({\n ...operationOptionsToRequestParameters(options),\n headers: {\n accept: \"application/octet-stream\",\n ...options.requestOptions?.headers,\n },\n });\n}\n\n/** Retrieves the raw content of a specific file. */\nexport function getFileContent(\n context: Client,\n fileId: string,\n options: FilesGetFileContentOptionalParams = { requestOptions: {} },\n): StreamableMethod<string | Uint8Array> {\n const result = _getFileContentSend(context, fileId, options);\n return result;\n}\n\nexport function _getFileSend(\n context: Client,\n fileId: string,\n options: FilesGetFileOptionalParams = { requestOptions: {} },\n): StreamableMethod {\n const path = expandUrlTemplate(\n \"/files/{fileId}{?api-version}\",\n {\n fileId: fileId,\n \"api-version\": context.apiVersion,\n },\n {\n allowReserved: options?.requestOptions?.skipUrlEncoding,\n },\n );\n return context.path(path).get({\n ...operationOptionsToRequestParameters(options),\n headers: {\n accept: \"application/json\",\n ...options.requestOptions?.headers,\n },\n });\n}\n\nexport async function _getFileDeserialize(result: PathUncheckedResponse): Promise<FileInfo> {\n const expectedStatuses = [\"200\"];\n if (!expectedStatuses.includes(result.status)) {\n const error = createRestError(result);\n error.details = agentV1ErrorDeserializer(result.body);\n throw error;\n }\n\n return fileInfoDeserializer(result.body);\n}\n\n/** Returns information about a specific file. Does not retrieve file content. */\nexport async function getFile(\n context: Client,\n fileId: string,\n options: FilesGetFileOptionalParams = { requestOptions: {} },\n): Promise<FileInfo> {\n const result = await _getFileSend(context, fileId, options);\n return _getFileDeserialize(result);\n}\n\nexport function _deleteFileSend(\n context: Client,\n fileId: string,\n options: FilesDeleteFileOptionalParams = { requestOptions: {} },\n): StreamableMethod {\n const path = expandUrlTemplate(\n \"/files/{fileId}{?api%2Dversion}\",\n {\n fileId: fileId,\n \"api%2Dversion\": context.apiVersion,\n },\n {\n allowReserved: options?.requestOptions?.skipUrlEncoding,\n },\n );\n return context.path(path).delete({\n ...operationOptionsToRequestParameters(options),\n headers: {\n accept: \"application/json\",\n ...options.requestOptions?.headers,\n },\n });\n}\n\nexport async function _deleteFileDeserialize(\n result: PathUncheckedResponse,\n): Promise<FileDeletionStatus> {\n const expectedStatuses = [\"200\"];\n if (!expectedStatuses.includes(result.status)) {\n const error = createRestError(result);\n error.details = agentV1ErrorDeserializer(result.body);\n throw error;\n }\n\n return fileDeletionStatusDeserializer(result.body);\n}\n\n/** Delete a previously uploaded file. */\nexport async function deleteFile(\n context: Client,\n fileId: string,\n options: FilesDeleteFileOptionalParams = { requestOptions: {} },\n): Promise<FileDeletionStatus> {\n const result = await _deleteFileSend(context, fileId, options);\n return _deleteFileDeserialize(result);\n}\n\nexport function _uploadFileSend(\n context: Client,\n body: {\n file: ReadableStream<Uint8Array> | NodeJS.ReadableStream;\n purpose: FilePurpose;\n filename?: string;\n },\n options: FilesUploadFileOptionalParams = { requestOptions: {} },\n): StreamableMethod {\n const path = expandUrlTemplate(\n \"/files{?api-version}\",\n {\n \"api-version\": context.apiVersion,\n },\n {\n allowReserved: options?.requestOptions?.skipUrlEncoding,\n },\n );\n return context.path(path).post({\n ...operationOptionsToRequestParameters(options),\n contentType: \"multipart/form-data\",\n headers: {\n accept: \"application/json\",\n ...options.requestOptions?.headers,\n },\n body: _uploadFileRequestSerializer(body),\n });\n}\n\nexport async function _uploadFileDeserialize(result: PathUncheckedResponse): Promise<FileInfo> {\n const expectedStatuses = [\"200\"];\n if (!expectedStatuses.includes(result.status)) {\n const error = createRestError(result);\n error.details = agentV1ErrorDeserializer(result.body);\n throw error;\n }\n\n return fileInfoDeserializer(result.body);\n}\n\n/** Uploads a file for use by other operations. */\nexport async function uploadFileInternal(\n context: Client,\n body: {\n file: ReadableStream<Uint8Array> | NodeJS.ReadableStream;\n purpose: FilePurpose;\n filename?: string;\n },\n options: FilesUploadFileOptionalParams = { requestOptions: {} },\n): Promise<FileInfo> {\n const result = await _uploadFileSend(context, body, options);\n return _uploadFileDeserialize(result);\n}\n\n/** Uploads a file for use by other operations. */\nexport function uploadFile(\n context: Client,\n body: {\n file: ReadableStream<Uint8Array> | NodeJS.ReadableStream;\n purpose: FilePurpose;\n filename?: string;\n },\n options: FilesUploadFileOptionalParams = { requestOptions: {} },\n): PollerLike<OperationState<FileInfo>, FileInfo> {\n return createPoller<FileInfo>({\n initOperation: async () => {\n return uploadFileInternal(context, body, options);\n },\n pollOperation: async (currentResult: FileInfo) => {\n return getFile(context, currentResult.id, options);\n },\n getOperationStatus: getLroOperationStatus,\n getOperationError: (result: FileInfo) => {\n return getLroOperationStatus(result) === \"failed\" && result.statusDetails\n ? new Error(`Operation failed: ${result.statusDetails}`)\n : undefined;\n },\n intervalInMs: options.pollingOptions?.intervalInMs,\n });\n}\n\n/** Uploads a file for use by other operations with polling */\nexport function uploadFileAndPoll(\n context: Client,\n body: {\n file: ReadableStream<Uint8Array> | NodeJS.ReadableStream;\n purpose: FilePurpose;\n filename?: string;\n },\n options: FilesUploadFileOptionalParams = { requestOptions: {} },\n): PollerLike<OperationState<FileInfo>, FileInfo> {\n return createPoller<FileInfo>({\n initOperation: async () => {\n return uploadFileInternal(context, body, options);\n },\n pollOperation: async (currentResult: FileInfo) => {\n return getFile(context, currentResult.id, options);\n },\n getOperationStatus: getLroOperationStatus,\n getOperationError: (result: FileInfo) => {\n return getLroOperationStatus(result) === \"failed\" && result.statusDetails\n ? new Error(`Operation failed: ${result.statusDetails}`)\n : undefined;\n },\n intervalInMs: options.pollingOptions?.intervalInMs,\n });\n}\n\nexport function _listFilesSend(\n context: Client,\n options: FilesListFilesOptionalParams = { requestOptions: {} },\n): StreamableMethod {\n const path = expandUrlTemplate(\n \"/files{?api%2Dversion,purpose}\",\n {\n \"api%2Dversion\": context.apiVersion,\n purpose: options?.purpose,\n },\n {\n allowReserved: options?.requestOptions?.skipUrlEncoding,\n },\n );\n return context.path(path).get({\n ...operationOptionsToRequestParameters(options),\n headers: {\n accept: \"application/json\",\n ...options.requestOptions?.headers,\n },\n });\n}\n\nexport async function _listFilesDeserialize(\n result: PathUncheckedResponse,\n): Promise<FileListResponse> {\n const expectedStatuses = [\"200\"];\n if (!expectedStatuses.includes(result.status)) {\n const error = createRestError(result);\n error.details = agentV1ErrorDeserializer(result.body);\n throw error;\n }\n\n return fileListResponseDeserializer(result.body);\n}\n\n/** Gets a list of previously uploaded files. */\nexport async function listFiles(\n context: Client,\n options: FilesListFilesOptionalParams = { requestOptions: {} },\n): Promise<FileListResponse> {\n const result = await _listFilesSend(context, options);\n return _listFilesDeserialize(result);\n}\n\nfunction getLroOperationStatus(result: FileInfo): OperationStatus {\n switch (result.status) {\n case \"running\":\n case \"pending\":\n return \"running\";\n case \"uploaded\":\n case \"processed\":\n return \"succeeded\";\n default:\n return \"failed\";\n }\n}\n"]}