claude-code-best 2.5.0 → 2.6.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 (614) hide show
  1. package/dist/chunks/AddWorkspaceDirectory-Cj5bvJgD.js +1 -0
  2. package/dist/chunks/App-2tgSv9lb.js +1 -0
  3. package/dist/chunks/ApproveApiKey-DWa-XTLb.js +1 -0
  4. package/dist/chunks/ApproveApiKey-SIUwkD8j.js +1 -0
  5. package/dist/chunks/AssistantSessionChooser-DF9eeJZS.js +1 -0
  6. package/dist/chunks/BackgroundTasksDialog-DXJdube9.js +2 -0
  7. package/dist/chunks/BypassPermissionsModeDialog-BOSW4Zdy.js +1 -0
  8. package/dist/chunks/ClaudeInChromeOnboarding-BW4XHmkw.js +1 -0
  9. package/dist/chunks/ClaudeMdExternalIncludesDialog-B8oAAHSI.js +1 -0
  10. package/dist/chunks/ClaudeMdExternalIncludesDialog-Bz0JyaOG.js +1 -0
  11. package/dist/chunks/ConsoleOAuthFlow-DYhmGSkx.js +1 -0
  12. package/dist/chunks/DesktopHandoff-CcsM_OAS.js +1 -0
  13. package/dist/chunks/DevChannelsDialog-DXRgY00D.js +1 -0
  14. package/dist/chunks/Dialog-DYFGqyDs.js +1 -0
  15. package/dist/chunks/DiffDialog-PvNZfZby.js +3 -0
  16. package/dist/chunks/Doctor--B1HUENo.js +1 -0
  17. package/dist/chunks/Doctor-CE_jL9jC.js +3 -0
  18. package/dist/chunks/ExitFlow-C4ybxKPn.js +2 -0
  19. package/dist/chunks/Feedback-B5rPGl_C.js +2 -0
  20. package/dist/chunks/Grove-C2YjB3zL.js +1 -0
  21. package/dist/chunks/Grove-CKVpREDU.js +11 -0
  22. package/dist/chunks/HybridTransport-Byjvz-DL.js +4 -0
  23. package/dist/chunks/ITermBackend-Co9XpeS4.js +1 -0
  24. package/dist/chunks/InProcessTransport-DB52dh4f.js +1 -0
  25. package/dist/chunks/InvalidConfigDialog-CNsqbNU3.js +1 -0
  26. package/dist/chunks/InvalidSettingsDialog-ClnZaN6b.js +1 -0
  27. package/dist/chunks/ListItem-OFARanN7.js +1 -0
  28. package/dist/chunks/MCPConnectionManager-CDsa79pu.js +1 -0
  29. package/dist/chunks/McpParsingWarnings-DZkzoeZf.js +1 -0
  30. package/dist/chunks/MessageSelector-CkeGQPNM.js +3 -0
  31. package/dist/chunks/Messages-PfbzLYOU.js +11 -0
  32. package/dist/chunks/Onboarding-BwoGQB4g.js +1 -0
  33. package/dist/chunks/OverageCreditUpsell-Q5g2YjQw.js +1 -0
  34. package/dist/chunks/PermissionDialog-5MlJf7ew.js +1 -0
  35. package/dist/chunks/PluginSettings-B2ASJ0Rx.js +17 -0
  36. package/dist/chunks/PressEnterToContinue-BdA9zDGs.js +1 -0
  37. package/dist/chunks/PromptInputFooterSuggestions-D4lMVCqj.js +1 -0
  38. package/dist/chunks/PromptInputHelpMenu-BvLtS6an.js +1 -0
  39. package/dist/chunks/QueryEngine-Av0G5fze.js +1 -0
  40. package/dist/chunks/REPL-DCwqua0C.js +1 -0
  41. package/dist/chunks/REPL-Dh8vzGmF.js +97 -0
  42. package/dist/chunks/RemoteCallout-BV_hoz98.js +1 -0
  43. package/dist/chunks/RemoteSessionManager-Cxoy1ud2.js +2 -0
  44. package/dist/chunks/ResumeConversation-B3WuB8rs.js +1 -0
  45. package/dist/chunks/SSETransport-pIm26VJq.js +4 -0
  46. package/dist/chunks/SearchBox-DfOmUoaI.js +1 -0
  47. package/dist/chunks/SearchExtraToolsTool-D70C-cmA.js +1 -0
  48. package/dist/chunks/SentryErrorBoundary-B6EWoJml.js +2 -0
  49. package/dist/chunks/SentryErrorBoundary-oJUBarGg.js +1 -0
  50. package/dist/chunks/Settings-CreAhCsb.js +2 -0
  51. package/dist/chunks/TeleportProgress-DPzGpyyM.js +1 -0
  52. package/dist/chunks/TeleportRepoMismatchDialog-DqWQX6j8.js +1 -0
  53. package/dist/chunks/TeleportResumeWrapper-DPSO0S49.js +1 -0
  54. package/dist/chunks/ThemePicker-DueihHcy.js +1 -0
  55. package/dist/chunks/TmuxBackend-BNaZNAeP.js +9 -0
  56. package/dist/chunks/TrustDialog-CIzAlGn9.js +1 -0
  57. package/dist/chunks/TungstenTool-C5IqKVr0.js +1 -0
  58. package/dist/chunks/TungstenTool-V-Bwqlx3.js +1 -0
  59. package/dist/chunks/ValidationErrorsList-1k1qbsRo.js +2 -0
  60. package/dist/chunks/WelcomeV2-CR6TtXXM.js +1 -0
  61. package/dist/chunks/WindowsTerminalBackend-C5SeTXqC.js +2 -0
  62. package/dist/chunks/add-dir-DAMizKzF.js +1 -0
  63. package/dist/chunks/agentDisplay-B9z7i8b_.js +1 -0
  64. package/dist/chunks/agents-D5u0p1UC.js +103 -0
  65. package/dist/chunks/agents-DCh_gEvJ.js +2 -0
  66. package/dist/chunks/ajv-B_OpU_Uh.js +8 -0
  67. package/dist/chunks/analytics-DqMQntaB.js +1 -0
  68. package/dist/chunks/ant-DRJq-cEg.js +1 -0
  69. package/dist/chunks/api-B6URs6nc.js +1 -0
  70. package/dist/chunks/api-Dz_3z1kl.js +1 -0
  71. package/dist/chunks/asciicast-aoKFhc7C.js +1 -0
  72. package/dist/chunks/asciicast-o5Zg4dJt.js +4 -0
  73. package/dist/chunks/assistant-BRGDWkKB.js +1 -0
  74. package/dist/chunks/assistant-tPxOUa-Z.js +1 -0
  75. package/dist/chunks/assistant-zVegFdAO.js +1 -0
  76. package/dist/chunks/attributionHooks-PygdohOh.js +1 -0
  77. package/dist/chunks/attributionTrailer-BpvhXgRP.js +1 -0
  78. package/dist/chunks/auth-CqURlg4d.js +1 -0
  79. package/dist/chunks/auth-D4isgfuK.js +1 -0
  80. package/dist/chunks/autoMode-DVt4K4I2.js +45 -0
  81. package/dist/chunks/autoModeDenials-Cp6VFdsm.js +1 -0
  82. package/dist/chunks/autonomy-BZzW8QJZ.js +1 -0
  83. package/dist/chunks/autonomy-Ffv0QIyl.js +19 -0
  84. package/dist/chunks/autonomyPanel-MwuzDvv_.js +1 -0
  85. package/dist/chunks/axios-DLnc2dVy.js +1 -0
  86. package/dist/chunks/axios-DhfaybwJ.js +12 -0
  87. package/dist/chunks/backgroundHousekeeping-CYnAG60-.js +17 -0
  88. package/dist/chunks/backgroundHousekeeping-DUmxC6h0.js +1 -0
  89. package/dist/chunks/banner-CVXH2xts.js +2 -0
  90. package/dist/chunks/base64-js-DIVSFswY.js +1 -0
  91. package/dist/chunks/bedrockClient-qi1-JCOK.js +15 -0
  92. package/dist/chunks/bg-DK0E4ZtW.js +9 -0
  93. package/dist/chunks/bg-Dbh5z3Y8.js +1 -0
  94. package/dist/chunks/branch-DXefFdDE.js +3 -0
  95. package/dist/chunks/break-cache-ByJ7U2Ts.js +8 -0
  96. package/dist/chunks/bridge-qr4GQW_c.js +2 -0
  97. package/dist/chunks/bridgeConfig-CJ-KznTS.js +1 -0
  98. package/dist/chunks/bridgeConfig-CNbOKpAg.js +1 -0
  99. package/dist/chunks/bridgeEnabled-5vsPrjuq.js +1 -0
  100. package/dist/chunks/bridgeEnabled-BUJTCUHY.js +1 -0
  101. package/dist/chunks/bridgeMain-BimZwc2P.js +68 -0
  102. package/dist/chunks/bridgeMain-DYL4fl6A.js +1 -0
  103. package/dist/chunks/bridgeMessaging-BiE0CTqq.js +1 -0
  104. package/dist/chunks/bridgePointer-FvAMj3re.js +1 -0
  105. package/dist/chunks/browser-fLRXxIsQ.js +1 -0
  106. package/dist/chunks/btw-FpimqEqk.js +1 -0
  107. package/dist/chunks/buddy-BA3Cr067.js +3 -0
  108. package/dist/chunks/bundledMode-kSQejuY4.js +1 -0
  109. package/dist/chunks/bypassPermissionsKillswitch-CSC9p8mO.js +1 -0
  110. package/dist/chunks/caches-BUBkfP2Q.js +3 -0
  111. package/dist/chunks/caches-CTfNpKhW.js +1 -0
  112. package/dist/chunks/capacityWake-BXlUpptF.js +1 -0
  113. package/dist/chunks/ccrClient-BOxUn9EJ.js +1 -0
  114. package/dist/chunks/ccshareResume-DWLjTF22.js +1 -0
  115. package/dist/chunks/changeDetector-Y9KV5LgG.js +1 -0
  116. package/dist/chunks/channelNotification-CC7Xb06W.js +1 -0
  117. package/dist/chunks/channelNotification-l3EXKDNB.js +1 -0
  118. package/dist/chunks/chokidar-BcI3rIKm.js +1 -0
  119. package/dist/chunks/chokidar-SzksMqYp.js +1 -0
  120. package/dist/chunks/chrome-BnKyWWQL.js +1 -0
  121. package/dist/chunks/chromeNativeHost-4U39yLtd.js +1 -0
  122. package/dist/chunks/chunk-DR8-3Aex.js +1 -0
  123. package/dist/chunks/classPrivateFieldSet2-EAQNhHs8.js +1 -0
  124. package/dist/chunks/claudeDesktop-D0S1eq1F.js +1 -0
  125. package/dist/chunks/cleanup-Bg_gFgcj.js +1 -0
  126. package/dist/chunks/clear-OUVFUt8Z.js +1 -0
  127. package/dist/chunks/cliLaunch-BQa48gsr.js +1 -0
  128. package/dist/chunks/client-B47ZvTMo.js +1 -0
  129. package/dist/chunks/client-CPn1wQyc.js +7 -0
  130. package/dist/chunks/client-_sjL0I7A.js +35 -0
  131. package/dist/chunks/color-D5MCzz9h.js +1 -0
  132. package/dist/chunks/color-convert-ULbeSgNC.js +1 -0
  133. package/dist/chunks/commands-FJGWgQsa.js +1 -0
  134. package/dist/chunks/commitAttribution-BFshsh2H.js +2 -0
  135. package/dist/chunks/commitAttribution-DSv9FggK.js +1 -0
  136. package/dist/chunks/common-B379wT22.js +1 -0
  137. package/dist/chunks/common-B_BC3eMY.js +1 -0
  138. package/dist/chunks/common-CMCv4N_v.js +1 -0
  139. package/dist/chunks/compact-DWNaf1wR.js +3 -0
  140. package/dist/chunks/companion-CyK_Dr1U.js +1 -0
  141. package/dist/chunks/completionCache-DHfUBBMH.js +1 -0
  142. package/dist/chunks/completionCache-DORrtxkS.js +4 -0
  143. package/dist/chunks/computerUseLock-BjoDJH2h.js +1 -0
  144. package/dist/chunks/config-BdCuh6eA.js +1 -0
  145. package/dist/chunks/config-DNz6Eitr.js +1 -0
  146. package/dist/chunks/connectHeadless-CwsFt-Mh.js +1 -0
  147. package/dist/chunks/constants-41VpZw2G.js +1 -0
  148. package/dist/chunks/context-BOjdTj0i.js +1 -0
  149. package/dist/chunks/context-noninteractive-Bd2HO-vU.js +1 -0
  150. package/dist/chunks/context-noninteractive-k2ibficU.js +54 -0
  151. package/dist/chunks/controlMessageCompat-BJhFiS7u.js +1 -0
  152. package/dist/chunks/conversation-BP0phkOY.js +1 -0
  153. package/dist/chunks/conversation-Ci8O_eZ-.js +1 -0
  154. package/dist/chunks/copy-B0VUJ2rH.js +7 -0
  155. package/dist/chunks/createSSHSession-DqmkCS_k.js +6 -0
  156. package/dist/chunks/createSession-B9MhWusY.js +1 -0
  157. package/dist/chunks/createSession-CJEsHz58.js +1 -0
  158. package/dist/chunks/cron-DiW7eIPP.js +1 -0
  159. package/dist/chunks/cronJitterConfig-BzPaa52I.js +6 -0
  160. package/dist/chunks/crossProjectResume-tWsqBUHc.js +40 -0
  161. package/dist/chunks/cwd--iizewsn.js +1 -0
  162. package/dist/chunks/cwd-BgpSJxd7.js +1 -0
  163. package/dist/chunks/daemon-VYRit6Aq.js +2 -0
  164. package/dist/chunks/dangerousBackend-BU_PHGR2.js +1 -0
  165. package/dist/chunks/datadog-Bd1s_VFj.js +1 -0
  166. package/dist/chunks/datadog-DJowkWhh.js +1 -0
  167. package/dist/chunks/debug-DM5ezCBS.js +1 -0
  168. package/dist/chunks/debug-UI3T040K.js +5 -0
  169. package/dist/chunks/debugUtils-BBMFODKH.js +1 -0
  170. package/dist/chunks/defineProperty-80gRi2ZW.js +1 -0
  171. package/dist/chunks/desktop-BDowrzvG.js +1 -0
  172. package/dist/chunks/detached-D300jlhj.js +5 -0
  173. package/dist/chunks/detect-libc-DNuQfUvI.js +1 -0
  174. package/dist/chunks/detectRepository-CBk3S2zv.js +1 -0
  175. package/dist/chunks/detectRepository-DCTvg4p0.js +1 -0
  176. package/dist/chunks/detection-CQsNad64.js +1 -0
  177. package/dist/chunks/detection-DJ-vTbBf.js +1 -0
  178. package/dist/chunks/diff-auU5sUOw.js +1 -0
  179. package/dist/chunks/directoryCompletion-DP_4B1GL.js +1 -0
  180. package/dist/chunks/dist-CanSxOZ1.js +5 -0
  181. package/dist/chunks/dist-Cg1a1Exw.js +29 -0
  182. package/dist/chunks/dist-Q7YNoZ0H.js +20 -0
  183. package/dist/chunks/dist-es-4z5T3Jzm.js +1 -0
  184. package/dist/chunks/dist-es-B2jg52tM2.js +1 -0
  185. package/dist/chunks/dist-es-B6OXHQ1S.js +1 -0
  186. package/dist/chunks/dist-es-B8NEy5hc.js +1 -0
  187. package/dist/chunks/dist-es-BVGppqE4.js +1 -0
  188. package/dist/chunks/dist-es-Bcw5GZko.js +1 -0
  189. package/dist/chunks/dist-es-BoIJpncb.js +9 -0
  190. package/dist/chunks/dist-es-Bu_Fshi1.js +1 -0
  191. package/dist/chunks/dist-es-C-1vn4OP2.js +1 -0
  192. package/dist/chunks/dist-es-C41b_0B5.js +1 -0
  193. package/dist/chunks/dist-es-CCZYybbG2.js +1 -0
  194. package/dist/chunks/dist-es-CLK1mey-.js +1 -0
  195. package/dist/chunks/dist-es-CQz2aNf72.js +1 -0
  196. package/dist/chunks/dist-es-CSfI8B8l.js +1 -0
  197. package/dist/chunks/dist-es-CUZBYppo.js +1 -0
  198. package/dist/chunks/dist-es-CZkzHpjF.js +1 -0
  199. package/dist/chunks/dist-es-Cbf0_D8d.js +5 -0
  200. package/dist/chunks/dist-es-ChHe-SVL.js +1 -0
  201. package/dist/chunks/dist-es-ClYOf0My.js +1 -0
  202. package/dist/chunks/dist-es-D-kJbj4A2.js +1 -0
  203. package/dist/chunks/dist-es-D1LN6CJd.js +1 -0
  204. package/dist/chunks/dist-es-DC1sC3ph.js +1 -0
  205. package/dist/chunks/dist-es-DGn8uOwQ2.js +1 -0
  206. package/dist/chunks/dist-es-DK5fTeKM2.js +1 -0
  207. package/dist/chunks/dist-es-DN7otr6F.js +1 -0
  208. package/dist/chunks/dist-es-DPM0mPK5.js +1 -0
  209. package/dist/chunks/dist-es-DqZAh3nG.js +1 -0
  210. package/dist/chunks/dist-es-DuAZyxJ02.js +5 -0
  211. package/dist/chunks/dist-es-HVQrM0oE.js +1 -0
  212. package/dist/chunks/dist-es-OVleIB54.js +1 -0
  213. package/dist/chunks/dist-es-UAs0rdXg.js +1 -0
  214. package/dist/chunks/dist-es-WvMMuHmx2.js +1 -0
  215. package/dist/chunks/dist-es-fjXft-jH.js +1 -0
  216. package/dist/chunks/dist-es-hdN_ShpZ.js +3 -0
  217. package/dist/chunks/dist-es-neiUvMJb.js +1 -0
  218. package/dist/chunks/dist-es-yMYpDtui2.js +1 -0
  219. package/dist/chunks/dist-es-zjcbuB72.js +1 -0
  220. package/dist/chunks/distRoot-CcxmnzqQ.js +1 -0
  221. package/dist/chunks/doctor-bKPp6AeL.js +1 -0
  222. package/dist/chunks/earlyInput-JGJo1zcC.js +1 -0
  223. package/dist/chunks/earlyInput-tRkbxFv2.js +2 -0
  224. package/dist/chunks/effort-BQj2QnnA.js +9 -0
  225. package/dist/chunks/entry-CUu6-QhT.js +14 -0
  226. package/dist/chunks/env-chR0gV31.js +1 -0
  227. package/dist/chunks/envLessBridgeConfig-CixkwbRF.js +1 -0
  228. package/dist/chunks/envLessBridgeConfig-Ju4W58xf.js +1 -0
  229. package/dist/chunks/envUtils-BWeoiL4Y.js +1 -0
  230. package/dist/chunks/escHotkey-Cyz0yyh1.js +259 -0
  231. package/dist/chunks/esm--xjzB1hI.js +1 -0
  232. package/dist/chunks/esm-B2HIF0XY.js +1 -0
  233. package/dist/chunks/esm-BGQPWnJy.js +1 -0
  234. package/dist/chunks/esm-C-1qL9Mn.js +1 -0
  235. package/dist/chunks/esm-C3jcs1DH.js +1 -0
  236. package/dist/chunks/esm-C97WL9nC.js +1 -0
  237. package/dist/chunks/esm-CIL-SKM8.js +1 -0
  238. package/dist/chunks/esm-CJlBxjtx.js +1 -0
  239. package/dist/chunks/esm-CsGLyWmS.js +56 -0
  240. package/dist/chunks/esm-DQHmDm-H.js +1 -0
  241. package/dist/chunks/esm-DcdOXSzi.js +1 -0
  242. package/dist/chunks/esm-DhNYgGTV.js +1 -0
  243. package/dist/chunks/esm-DxPW7qPs.js +1 -0
  244. package/dist/chunks/esm-FBUWr3vI.js +1 -0
  245. package/dist/chunks/esm-QgL6y---.js +10 -0
  246. package/dist/chunks/esm-v0kPjgVS.js +1 -0
  247. package/dist/chunks/esm-vIn-YV_h.js +1 -0
  248. package/dist/chunks/event-streams-BV7ngMXu.js +1 -0
  249. package/dist/chunks/eventLoopStallDetector-Dnh1fc31.js +1 -0
  250. package/dist/chunks/execAsync-BkA6ogic.js +1 -0
  251. package/dist/chunks/execFileNoThrow-CuQN1sz8.js +1 -0
  252. package/dist/chunks/execSyncWrapper-C2XQnFVo.js +1 -0
  253. package/dist/chunks/execa-CGue6Z3n.js +34 -0
  254. package/dist/chunks/executor-4EeD8GNm.js +1561 -0
  255. package/dist/chunks/executor-BHEuNh5F.js +1 -0
  256. package/dist/chunks/exit-DijkO8eo.js +1 -0
  257. package/dist/chunks/exit-_obETqBv.js +2 -0
  258. package/dist/chunks/export-DA-bBZkX.js +2 -0
  259. package/dist/chunks/exportRenderer-3y4tGdSB.js +1 -0
  260. package/dist/chunks/extra-usage-CS6VwKJt.js +1 -0
  261. package/dist/chunks/extra-usage-DGHEQOrY.js +1 -0
  262. package/dist/chunks/extra-usage-core-DOgT4u4i.js +1 -0
  263. package/dist/chunks/extra-usage-noninteractive-DYnfiRlV.js +1 -0
  264. package/dist/chunks/extraUsage-CfxgfpX_.js +1 -0
  265. package/dist/chunks/extractMemories-jvjCvtpC.js +1 -0
  266. package/dist/chunks/fast-Bbtx_Bs1.js +1 -0
  267. package/dist/chunks/fast-CzRUJBTK.js +1 -0
  268. package/dist/chunks/featureCheck-Cm0YNDXO.js +1 -0
  269. package/dist/chunks/featureCheck-p7OeCYzj.js +1 -0
  270. package/dist/chunks/feedback-FoXtdHAV.js +1 -0
  271. package/dist/chunks/figures-gfT9mM8P.js +1 -0
  272. package/dist/chunks/fileStateCache-C7-TxF8G.js +1 -0
  273. package/dist/chunks/files-DYvAZGxp.js +2 -0
  274. package/dist/chunks/firstPartyEventLogger-KIwaBY-E.js +1 -0
  275. package/dist/chunks/flushGate-C2Icy43G.js +1 -0
  276. package/dist/chunks/foundry-sdk-BFN5VDFQ.js +1 -0
  277. package/dist/chunks/fpsMetrics-DeezdcwV.js +1 -0
  278. package/dist/chunks/fuse-Ch_OAlm3.js +1 -0
  279. package/dist/chunks/gates-CbQLZHtm.js +1 -0
  280. package/dist/chunks/gates-DSI3vpwO.js +1 -0
  281. package/dist/chunks/gemini-BrNJGX4k.js +1 -0
  282. package/dist/chunks/generateRecap-B0fvSCjo.js +1 -0
  283. package/dist/chunks/generateSessionName-DvRYa39O.js +1 -0
  284. package/dist/chunks/genericProcessUtils-BGvcwuPt.js +23 -0
  285. package/dist/chunks/getMachineId-bsd-BMtYGBUL.js +1 -0
  286. package/dist/chunks/getMachineId-darwin-CiLdFH7z.js +2 -0
  287. package/dist/chunks/getMachineId-linux-Cr27rIeY.js +1 -0
  288. package/dist/chunks/getMachineId-unsupported-ceiBLwAN.js +1 -0
  289. package/dist/chunks/getMachineId-win-DFTmsQHq.js +1 -0
  290. package/dist/chunks/git-CN3qtTb_.js +6 -0
  291. package/dist/chunks/git-D23Mzu_K.js +1 -0
  292. package/dist/chunks/githubRepoPathMapping-Dut3d6nn.js +1 -0
  293. package/dist/chunks/graceful-fs-Cgc0rjGF.js +2 -0
  294. package/dist/chunks/grok-Ftoheab3.js +1 -0
  295. package/dist/chunks/growthbook-BynnuVTn.js +1 -0
  296. package/dist/chunks/hash-BRmOQc3c.js +1 -0
  297. package/dist/chunks/heapdump-hQ_w0LPC.js +5 -0
  298. package/dist/chunks/help-DQsHHv6r.js +1 -0
  299. package/dist/chunks/hooks-BLLL4iPv.js +1 -0
  300. package/dist/chunks/hooks-BhVDc8yb.js +79 -0
  301. package/dist/chunks/hostAdapter-D1eWmmhu.js +1 -0
  302. package/dist/chunks/hostGuard-zim_4F9V.js +1 -0
  303. package/dist/chunks/httpAuthSchemes-Wq4XWeLL.js +13 -0
  304. package/dist/chunks/ide-CPmMXLL-.js +2 -0
  305. package/dist/chunks/inboundAttachments-Bmf6vYsE.js +1 -0
  306. package/dist/chunks/inboundAttachments-D-p91z3w.js +1 -0
  307. package/dist/chunks/index.min-BJnb9GQI.js +1 -0
  308. package/dist/chunks/initReplBridge-BiHXpDEY.js +1 -0
  309. package/dist/chunks/insights-CTlTyvjj.js +822 -0
  310. package/dist/chunks/install-IPuD3Lq8.js +1 -0
  311. package/dist/chunks/install-github-app-Bmu_sA9e.js +147 -0
  312. package/dist/chunks/install-slack-app-Rfl81Jqo.js +1 -0
  313. package/dist/chunks/instinctParser-DHMa8xa0.js +1 -0
  314. package/dist/chunks/instrumentation-DWwmOmr0.js +12 -0
  315. package/dist/chunks/intl-Pse97ORk.js +1 -0
  316. package/dist/chunks/isObject-DaxDnPKm.js +1 -0
  317. package/dist/chunks/isSymbol-Dp3irZaY.js +1 -0
  318. package/dist/chunks/job-BXEt0izn.js +2 -0
  319. package/dist/chunks/json-bigint-OxRwRvup.js +8 -0
  320. package/dist/chunks/jsx-runtime-D-D469L8.js +1 -0
  321. package/dist/chunks/jws-2vqRyZtR.js +3 -0
  322. package/dist/chunks/jwtUtils-CpXwh_du.js +1 -0
  323. package/dist/chunks/keybindings-DRDgVvqz.js +2 -0
  324. package/dist/chunks/lang-D3ZHlfT6.js +1 -0
  325. package/dist/chunks/language-B_-BfBT4.js +1 -0
  326. package/dist/chunks/language-DcSjogBx.js +1 -0
  327. package/dist/chunks/launchAgentsPlatform-BPm_VMln.js +1 -0
  328. package/dist/chunks/launchAutofixPr-D2qac07g.js +2 -0
  329. package/dist/chunks/launchCommand-Du91jxMC.js +1 -0
  330. package/dist/chunks/launchLocalMemory-D_hBbXKE.js +3 -0
  331. package/dist/chunks/launchLocalVault-CPzNWvQ9.js +3 -0
  332. package/dist/chunks/launchMemoryStores-Djq2KhKb.js +1 -0
  333. package/dist/chunks/launchOnboarding-Bh6E7vdc.js +8 -0
  334. package/dist/chunks/launchSchedule-C988bQ-5.js +1 -0
  335. package/dist/chunks/launchSkillStore-DqrP6Gme.js +1 -0
  336. package/dist/chunks/launchTeleport-DFhybaq_.js +3 -0
  337. package/dist/chunks/launchVault-p_CSK4ZQ.js +1 -0
  338. package/dist/chunks/lazySchema-2sOku3cX.js +1 -0
  339. package/dist/chunks/lib-B4Q0Nrpb.js +14 -0
  340. package/dist/chunks/lib-Ca3QWJjN.js +2 -0
  341. package/dist/chunks/lib-inCisXen.js +8 -0
  342. package/dist/chunks/loadAgentsDir-Ci5mr0vm.js +4601 -0
  343. package/dist/chunks/loadAgentsDir-vB1QEZ7H.js +1 -0
  344. package/dist/chunks/loadPluginHooks-xYCEZ6t5.js +1 -0
  345. package/dist/chunks/loadSso-sDs471GC.js +1 -0
  346. package/dist/chunks/localSearch-DtVqtfvk.js +1 -0
  347. package/dist/chunks/localSearch-Vpn6W5aY.js +1 -0
  348. package/dist/chunks/lockfile-DBwdlC3K.js +1 -0
  349. package/dist/chunks/log-CzsijfHZ.js +1 -0
  350. package/dist/chunks/login-D-N78G6r.js +1 -0
  351. package/dist/chunks/login-D9IWjvza.js +1 -0
  352. package/dist/chunks/logoV2Utils-SAulcC5x.js +1 -0
  353. package/dist/chunks/logout-CFggVS-9.js +1 -0
  354. package/dist/chunks/magicDocs-BfoeYhin.js +57 -0
  355. package/dist/chunks/main-C6be1KFk.js +31 -0
  356. package/dist/chunks/main-DhMlhVj3.js +1108 -0
  357. package/dist/chunks/mappers-uIrAj-Wd.js +1 -0
  358. package/dist/chunks/mcp-CAYGNxCb.js +1 -0
  359. package/dist/chunks/mcp-COQap0SM.js +6 -0
  360. package/dist/chunks/mcp-DlM0OC6R.js +2 -0
  361. package/dist/chunks/mcpServer-1SnOWb8_.js +1 -0
  362. package/dist/chunks/mcpServer-DXvS3v4x.js +1 -0
  363. package/dist/chunks/memoize-DNnuA2aU.js +1 -0
  364. package/dist/chunks/memoize-DxwLawI2.js +1 -0
  365. package/dist/chunks/memory-XccPLQLt.js +1 -0
  366. package/dist/chunks/mobile-umu5P0cM.js +2 -0
  367. package/dist/chunks/modalContext-CmSKRyea.js +1 -0
  368. package/dist/chunks/model-CbiDGGJU.js +1 -0
  369. package/dist/chunks/model-DdbcxKub.js +1 -0
  370. package/dist/chunks/normalization-Cox8C0dP.js +1 -0
  371. package/dist/chunks/oauth-CdZEzMww.js +1 -0
  372. package/dist/chunks/oauth-CmensepG.js +1 -0
  373. package/dist/chunks/observationStore-tvkldXUo.js +4 -0
  374. package/dist/chunks/onChangeAppState-Dp0JIXd8.js +1 -0
  375. package/dist/chunks/open-CDditBQ-.js +1 -0
  376. package/dist/chunks/openai-6KcHd4Hw.js +10 -0
  377. package/dist/chunks/openaiShared-D5lOejS1.js +16 -0
  378. package/dist/chunks/output-style-XDb9-2Kk.js +1 -0
  379. package/dist/chunks/overageCreditGrant-DYiB4sr-.js +1 -0
  380. package/dist/chunks/p-map-9Ud1LOrJ.js +1 -0
  381. package/dist/chunks/p-map-D7WEmnBE.js +1 -0
  382. package/dist/chunks/package-BhL7chzt.js +1 -0
  383. package/dist/chunks/panel-ByW1omJn.js +1 -0
  384. package/dist/chunks/panel-Bz_8td5D.js +1 -0
  385. package/dist/chunks/parseConnectUrl-BS6i9JPo.js +1 -0
  386. package/dist/chunks/parser-CmngCwjB.js +1 -0
  387. package/dist/chunks/parser-SWIZo39J.js +1 -0
  388. package/dist/chunks/passes-Cbc6T_Tj.js +1 -0
  389. package/dist/chunks/path-C4kbwvSH.js +1 -0
  390. package/dist/chunks/paths-Q2255dD7.js +39 -0
  391. package/dist/chunks/permissions-BLzPHh_3.js +3 -0
  392. package/dist/chunks/permissions-DXLfdE7b.js +1 -0
  393. package/dist/chunks/permissions-Ps_D01ZB.js +1 -0
  394. package/dist/chunks/pipeTransport-D7NIp3aA.js +1 -0
  395. package/dist/chunks/plan-DloFVJK7.js +1 -0
  396. package/dist/chunks/platform-CuyedWpe.js +2 -0
  397. package/dist/chunks/plist-BO4ZqMZc.js +6 -0
  398. package/dist/chunks/plugin-XR9IBPMM.js +1 -0
  399. package/dist/chunks/pluginAutoupdate-Cr9hP0zG.js +1 -0
  400. package/dist/chunks/pluginBlocklist-CM9uP8CY.js +1 -0
  401. package/dist/chunks/pluginCliCommands-BQkrvES5.js +1 -0
  402. package/dist/chunks/pluginFlagging-CJ1--2Kw.js +1 -0
  403. package/dist/chunks/pluginOperations-B0rLuSvo.js +2 -0
  404. package/dist/chunks/pluginStartupCheck-Bjdc8zhz.js +1 -0
  405. package/dist/chunks/pluginStartupCheck-Cu2ezD51.js +1 -0
  406. package/dist/chunks/plugins-BgOP_8TX.js +4 -0
  407. package/dist/chunks/policyLimits-CKy_gTEt.js +1 -0
  408. package/dist/chunks/pollConfig-DhptuhFw.js +1 -0
  409. package/dist/chunks/poller-Ds0Y6Cir.js +1 -0
  410. package/dist/chunks/poor-DF0aqXDx.js +1 -0
  411. package/dist/chunks/poorMode-C5Frra4j.js +1 -0
  412. package/dist/chunks/poorMode-DJvjO2nW.js +1 -0
  413. package/dist/chunks/postCommitAttribution-Ehmwzzuq.js +1 -0
  414. package/dist/chunks/print-CPtR0KTa.js +39 -0
  415. package/dist/chunks/privacy-settings-e-7lc7Un.js +1 -0
  416. package/dist/chunks/process-CWupreF6.js +1 -0
  417. package/dist/chunks/process-DMKLUQIO.js +1 -0
  418. package/dist/chunks/processBashCommand-D5dC6Mya.js +1 -0
  419. package/dist/chunks/processSlashCommand-DHRUtZ-C.js +6 -0
  420. package/dist/chunks/projectContext-0fpRKUeH.js +1 -0
  421. package/dist/chunks/projectContext-eXMSfgdZ.js +1 -0
  422. package/dist/chunks/prompt-4tea6NJQ.js +54 -0
  423. package/dist/chunks/prompt-CQC-mh6u.js +1 -0
  424. package/dist/chunks/prompt-DEPUnJdB.js +222 -0
  425. package/dist/chunks/prompt-DawxLANl.js +1 -0
  426. package/dist/chunks/promptEditor-Ci-h04-5.js +4 -0
  427. package/dist/chunks/protocolHandler-DhqM32qE.js +13 -0
  428. package/dist/chunks/protocols-CAyQOlkr.js +7 -0
  429. package/dist/chunks/proxy-CfZp-wce.js +99 -0
  430. package/dist/chunks/rate-limit-options-B0l29Zx8.js +1 -0
  431. package/dist/chunks/rcDebugLog-BbPkkigY.js +11 -0
  432. package/dist/chunks/referral-ByevBJrE.js +1 -0
  433. package/dist/chunks/refresh-B_CwwIRX.js +1 -0
  434. package/dist/chunks/registerProtocol-DzhaQH02.js +36 -0
  435. package/dist/chunks/registry-DkHA4cRu.js +1 -0
  436. package/dist/chunks/release-notes-CZthYkei.js +4 -0
  437. package/dist/chunks/releaseNotes-CwKpIsyd.js +2 -0
  438. package/dist/chunks/reload-plugins-DxWfXvrN.js +1 -0
  439. package/dist/chunks/remote-env-BiRLWIrh.js +1 -0
  440. package/dist/chunks/remoteBridgeCore-nz1fPY1U.js +1 -0
  441. package/dist/chunks/remoteControlServer-FzLUxh2B.js +3 -0
  442. package/dist/chunks/rename-DmGuyncE.js +1 -0
  443. package/dist/chunks/renderOptions-BiyC2rj1.js +1 -0
  444. package/dist/chunks/resume-7GeU7RMS.js +2 -0
  445. package/dist/chunks/rewind-CXplHgh_.js +1 -0
  446. package/dist/chunks/rollback-DbSpxmJE.js +11 -0
  447. package/dist/chunks/runtimeObserver-Duod-ign.js +10 -0
  448. package/dist/chunks/runtimeObserver-OgM9ZYxZ.js +1 -0
  449. package/dist/chunks/sandbox-adapter-CxkhKgaa.js +1 -0
  450. package/dist/chunks/sandbox-toggle-Cc96R6Ox.js +1 -0
  451. package/dist/chunks/sanitization-CYp-9DbE.js +1 -0
  452. package/dist/chunks/satisfies-BaHgd_ie.js +1 -0
  453. package/dist/chunks/schemas-BGAvj1T4.js +40 -0
  454. package/dist/chunks/sdk-DEtgRZvI.js +1 -0
  455. package/dist/chunks/sdkHeapDumpMonitor--fevrC5z.js +1 -0
  456. package/dist/chunks/searchExtraTools-DQ6e601b.js +1 -0
  457. package/dist/chunks/semver-Cq33BYay.js +1 -0
  458. package/dist/chunks/semver-Tw0AFar5.js +1 -0
  459. package/dist/chunks/sentry-BUHYuYGj.js +13 -0
  460. package/dist/chunks/server-C5XZSlto.js +1 -0
  461. package/dist/chunks/server-DzOdtq8A.js +1 -0
  462. package/dist/chunks/serverBanner-WlSYP-f8.js +1 -0
  463. package/dist/chunks/serverLog-DtsUvDiY.js +1 -0
  464. package/dist/chunks/session-DgLqm7ZI.js +2 -0
  465. package/dist/chunks/sessionDataUploader-Ctjo1bgR.js +1 -0
  466. package/dist/chunks/sessionDiscovery-DgNea6qa.js +1 -0
  467. package/dist/chunks/sessionFileAccessHooks-7Svz-7S-.js +1 -0
  468. package/dist/chunks/sessionManager-Dw72ZUTg.js +1 -0
  469. package/dist/chunks/sessionMemory-DIrR3zvb.js +1 -0
  470. package/dist/chunks/sessionMemory-_dmj8lcH.js +1 -0
  471. package/dist/chunks/sessionMemoryUtils-BdQtSkRx.js +1 -0
  472. package/dist/chunks/sessionObserver-CuWMVPlT.js +20 -0
  473. package/dist/chunks/sessionObserver-_adufOGQ.js +1 -0
  474. package/dist/chunks/sessionStorage-W7okgAlQ.js +1 -0
  475. package/dist/chunks/sessionStoragePortable-BI9q2WcJ.js +3 -0
  476. package/dist/chunks/sessionTitle-DzkMzHer.js +14 -0
  477. package/dist/chunks/sessionTracing-DTjmc0EF.js +11 -0
  478. package/dist/chunks/settingsSync-CfYDkakY.js +1 -0
  479. package/dist/chunks/setup-BKUG46jQ.js +9 -0
  480. package/dist/chunks/setup-CmLngvpJ.js +1 -0
  481. package/dist/chunks/setup-TqJ7-Nxh.js +2 -0
  482. package/dist/chunks/shadowedRuleDetection-DesT0yKM.js +1 -0
  483. package/dist/chunks/shellQuote-DgjT8KBA.js +1 -0
  484. package/dist/chunks/sideQuestion-BAq0YyKY.js +20 -0
  485. package/dist/chunks/signin-QEeYpJZw.js +1 -0
  486. package/dist/chunks/sink-B3uP8Cf8.js +1 -0
  487. package/dist/chunks/sink-CaWMZBw_.js +1 -0
  488. package/dist/chunks/sinks-COcy5GnB.js +2 -0
  489. package/dist/chunks/sinks-oFfsKySL.js +1 -0
  490. package/dist/chunks/skill-learning-DOIMPtWE.js +5 -0
  491. package/dist/chunks/skillChangeDetector-CA_Tdx8N.js +1 -0
  492. package/dist/chunks/skillGapStore-CWuw1dYh.js +1 -0
  493. package/dist/chunks/skillGapStore-DpEoKhn-.js +5 -0
  494. package/dist/chunks/skillGenerator-9y3Q4YoO.js +8 -0
  495. package/dist/chunks/skillLearning-BhM09bQD.js +1 -0
  496. package/dist/chunks/skillLearning-_o2D06yM.js +1 -0
  497. package/dist/chunks/skillPanel-Dt24mZTZ.js +28 -0
  498. package/dist/chunks/skillSearchPanel-gaXN64Fu.js +21 -0
  499. package/dist/chunks/skills-Dx3dMHYk.js +1 -0
  500. package/dist/chunks/slashCommandParsing-Cari0pNg.js +1 -0
  501. package/dist/chunks/sleep-8Eb9j_Ly.js +1 -0
  502. package/dist/chunks/sprites-5OAB-Ui2.js +1 -0
  503. package/dist/chunks/src-BIPP3_mo.js +26 -0
  504. package/dist/chunks/src-BJz1KAd_.js +6 -0
  505. package/dist/chunks/src-BRAdBA8A.js +1 -0
  506. package/dist/chunks/src-BRC_BuUP.js +1 -0
  507. package/dist/chunks/src-BaB-bpCj.js +5 -0
  508. package/dist/chunks/src-BlLavFUS.js +7 -0
  509. package/dist/chunks/src-C5yhFG0C.js +19 -0
  510. package/dist/chunks/src-CI_jaaBj.js +2 -0
  511. package/dist/chunks/src-CRsA-Z4y.js +1 -0
  512. package/dist/chunks/src-CYLfL70h.js +1 -0
  513. package/dist/chunks/src-DJXCzwyJ.js +1 -0
  514. package/dist/chunks/src-DJXKJavk.js +1 -0
  515. package/dist/chunks/src-Di342QoJ.js +53 -0
  516. package/dist/chunks/src-DsMd9Q9e.js +2 -0
  517. package/dist/chunks/src-DzH9IdOo.js +1 -0
  518. package/dist/chunks/src-hdbPEvzO.js +9 -0
  519. package/dist/chunks/src-poaoYkuc.js +1 -0
  520. package/dist/chunks/src-x7u_sB6m.js +1 -0
  521. package/dist/chunks/sso-oidc-BX1MlBX0.js +1 -0
  522. package/dist/chunks/startupProfiler-DnXZaX4A.js +3 -0
  523. package/dist/chunks/startupProfiler-SOE--nM9.js +1 -0
  524. package/dist/chunks/state-B2GIOsTB.js +1 -0
  525. package/dist/chunks/state-Ce1HlR-H.js +1 -0
  526. package/dist/chunks/state-sIHsFpDu.js +1 -0
  527. package/dist/chunks/staticRender-Br64h1E1.js +1 -0
  528. package/dist/chunks/stats-TUExo9iU.js +1 -0
  529. package/dist/chunks/status-Dghaz1my.js +1 -0
  530. package/dist/chunks/statusNoticeHelpers-DVZSSXeK.js +1 -0
  531. package/dist/chunks/stdio-BEEzuxaZ.js +1 -0
  532. package/dist/chunks/stdio-D4cT86R0.js +3 -0
  533. package/dist/chunks/stickers-2K05wjSp.js +1 -0
  534. package/dist/chunks/store-DhI7Lcan.js +1 -0
  535. package/dist/chunks/sts-BDFJ-6QE.js +1 -0
  536. package/dist/chunks/subprocessEnv-CggQWZCx.js +1 -0
  537. package/dist/chunks/subprocessEnv-DV6q6o6w.js +1 -0
  538. package/dist/chunks/supports-color-lkzOMQ6u.js +1 -0
  539. package/dist/chunks/systemPromptSections-BcN_XBTx.js +1 -0
  540. package/dist/chunks/systemPromptSections-DB93ZNWP.js +1 -0
  541. package/dist/chunks/systemTheme-dDbitcxB.js +1 -0
  542. package/dist/chunks/tag-ZcVkzFjz.js +11 -0
  543. package/dist/chunks/tasks-DbB33ekt.js +1 -0
  544. package/dist/chunks/teamHelpers-BmN9nKz-.js +1 -0
  545. package/dist/chunks/teamHelpers-yeTNtZbb.js +1 -0
  546. package/dist/chunks/teammate-DMYOtLTK.js +1 -0
  547. package/dist/chunks/teammateModeSnapshot-CPjJJDL1.js +1 -0
  548. package/dist/chunks/teammateModeSnapshot-CsNIJTKi.js +1 -0
  549. package/dist/chunks/teleport-JHgpwZIh.js +1 -0
  550. package/dist/chunks/templateJobs-Db630FZD.js +12 -0
  551. package/dist/chunks/terminalSetup-DJqWE8fc.js +33 -0
  552. package/dist/chunks/terminalSetup-ygKHrVKR.js +1 -0
  553. package/dist/chunks/theme-MmfFhdTD.js +1 -0
  554. package/dist/chunks/thinkback-CrNirB0V.js +1 -0
  555. package/dist/chunks/thinkback-Quc7KPmi.js +1 -0
  556. package/dist/chunks/thinkback-play-CQ1s7oqg.js +1 -0
  557. package/dist/chunks/tmux-CvbhsfwG.js +1 -0
  558. package/dist/chunks/toolEventObserver-BqMplcIk.js +1 -0
  559. package/dist/chunks/toolEventObserver-DBq2XBYY.js +1 -0
  560. package/dist/chunks/toolPool-BkCtTKXz.js +1 -0
  561. package/dist/chunks/toolPool-C7bOwJfR.js +1 -0
  562. package/dist/chunks/trustedDevice-C9Zevohz.js +1 -0
  563. package/dist/chunks/trustedDevice-DEuQUTbz.js +1 -0
  564. package/dist/chunks/tui-BVc2q4Xv.js +6 -0
  565. package/dist/chunks/turndown.es-Bv06VjMb.js +69 -0
  566. package/dist/chunks/types-CQ1wrnQ0.js +1 -0
  567. package/dist/chunks/types-Csi32ZXh.js +17 -0
  568. package/dist/chunks/types-RJTEOuIt.js +3 -0
  569. package/dist/chunks/udsClient-BvG_Jip0.js +1 -0
  570. package/dist/chunks/ultrareviewCommand-DrlfRrXq.js +3 -0
  571. package/dist/chunks/undercover-CBeHiWUd.js +1 -0
  572. package/dist/chunks/undercover-DKn95mh9.js +31 -0
  573. package/dist/chunks/up-D-U4wUCe.js +12 -0
  574. package/dist/chunks/updateCCB-CJ7dCUan.js +11 -0
  575. package/dist/chunks/upgrade-Degqbu8S.js +1 -0
  576. package/dist/chunks/upgrade-ucJ-lnlY.js +1 -0
  577. package/dist/chunks/upload-pTZQCPLt.js +1 -0
  578. package/dist/chunks/upstreamproxy-DcLeL2XX.js +11 -0
  579. package/dist/chunks/usage-D96a7Cke.js +1 -0
  580. package/dist/chunks/usage-DVQMUMcC.js +1 -0
  581. package/dist/chunks/useKeybinding-FsOnjW6T.js +1 -0
  582. package/dist/chunks/useMainLoopModel-B7ch2o9K.js +1 -0
  583. package/dist/chunks/useManagePlugins-BfGzHMvO.js +1 -0
  584. package/dist/chunks/useMergedTools-TemEvCrX.js +1 -0
  585. package/dist/chunks/useSearchInput-B-V4kIa-.js +1 -0
  586. package/dist/chunks/useSettingsErrors-B2JGz1s8.js +1 -0
  587. package/dist/chunks/useVoice-BuwYDm2U.js +1 -0
  588. package/dist/chunks/util-CeIKZmj9.js +1 -0
  589. package/dist/chunks/utils-CwhszpkT.js +1 -0
  590. package/dist/chunks/v4-f1i_CNUT.js +1 -0
  591. package/dist/chunks/validatePlugin-BlVho93x.js +1 -0
  592. package/dist/chunks/vertex-sdk-CSGw3fvU.js +9 -0
  593. package/dist/chunks/vim-DUZQCWUP.js +1 -0
  594. package/dist/chunks/voice-BkRIHZiM.js +2 -0
  595. package/dist/chunks/voice-DXiiy8HX.js +8 -0
  596. package/dist/chunks/voiceModeEnabled-CPQUE3PU.js +1 -0
  597. package/dist/chunks/voiceModeEnabled-DB8GCzAF.js +1 -0
  598. package/dist/chunks/voiceStreamSTT-DgoDscHn.js +1 -0
  599. package/dist/chunks/voiceStreamSTT-Dr_wH1Kh.js +1 -0
  600. package/dist/chunks/which-DqSAIvp2.js +1 -0
  601. package/dist/chunks/windowsPaths-C9CigqoF.js +1 -0
  602. package/dist/chunks/windowsPaths-swxCp7bX.js +2 -0
  603. package/dist/chunks/workSecret-mS2OrpxF.js +1 -0
  604. package/dist/chunks/workerRegistry-CT7_kjvY.js +1 -0
  605. package/dist/chunks/worktree-DU3xtwKW.js +1 -0
  606. package/dist/chunks/worktreeModeEnabled-Db6b_Iy_.js +1 -0
  607. package/dist/chunks/worktreeModeEnabled-THQb19xR.js +1 -0
  608. package/dist/chunks/wrapper-BSK0MCQH.js +1 -0
  609. package/dist/chunks/wrapper-D5qL1aQL.js +6 -0
  610. package/dist/chunks/xdg-CBxMmQux.js +1 -0
  611. package/dist/chunks/xml-DD_ldd3X.js +1 -0
  612. package/dist/chunks/zod-DT6hytkp.js +1 -0
  613. package/dist/cli.js +1 -10978
  614. package/package.json +1 -1
@@ -0,0 +1 @@
1
+ import{n as e}from"./chunk-DR8-3Aex.js";import{Tn as t,wn as n}from"./src-Di342QoJ.js";import{Ct as r,cn as i}from"./state-sIHsFpDu.js";import{et as a}from"./log-CzsijfHZ.js";import{Hv as o,Lo as s,Rv as c,lo as l}from"./loadAgentsDir-Ci5mr0vm.js";import{tn as u}from"./prompt-DEPUnJdB.js";import{randomUUID as d}from"crypto";function f(e){return e.flatMap(e=>{switch(e.type){case`assistant`:return[{type:`assistant`,message:e.message,uuid:e.uuid,requestId:void 0,timestamp:new Date().toISOString()}];case`user`:return[{type:`user`,message:e.message,uuid:e.uuid??d(),timestamp:e.timestamp??new Date().toISOString(),isMeta:e.isSynthetic}];default:return[]}})}function p(e){let t=e.preservedSegment;return{trigger:e.trigger,pre_tokens:e.preTokens,...t&&{preserved_segment:{head_uuid:t.headUuid,anchor_uuid:t.anchorUuid,tail_uuid:t.tailUuid}}}}function m(e){let t=e,n=t.preserved_segment;return{trigger:t.trigger,preTokens:t.pre_tokens,...n&&{preservedSegment:{headUuid:n.head_uuid,anchorUuid:n.anchor_uuid,tailUuid:n.tail_uuid}}}}function h(e){return e.flatMap(e=>{switch(e.type){case`assistant`:return[{type:`assistant`,message:v(e),session_id:r(),parent_tool_use_id:null,uuid:e.uuid,error:e.error}];case`user`:return[{type:`user`,message:e.message,session_id:r(),parent_tool_use_id:null,uuid:e.uuid,timestamp:e.timestamp,isSynthetic:e.isMeta||e.isVisibleInTranscriptOnly,...e.toolUseResult===void 0?{}:{tool_use_result:e.toolUseResult}}];case`system`:return e.subtype===`compact_boundary`&&e.compactMetadata?[{type:`system`,subtype:`compact_boundary`,session_id:r(),uuid:e.uuid,compact_metadata:p(e.compactMetadata)}]:e.subtype===`local_command`&&(e.content.includes(`<local-command-stdout>`)||e.content.includes(`<local-command-stderr>`))?[g(e.content,e.uuid)]:[];default:return[]}})}function g(e,n){let i=l({content:t(e).replace(/<local-command-stdout>([\s\S]*?)<\/local-command-stdout>/,`$1`).replace(/<local-command-stderr>([\s\S]*?)<\/local-command-stderr>/,`$1`).trim()});return{type:`assistant`,content:i.message?.content,message:i.message,parent_tool_use_id:null,session_id:r(),uuid:n}}function _(e){if(e)return{type:`rate_limit`,status:e.status,...e.resetsAt!==void 0&&{resetsAt:e.resetsAt},...e.rateLimitType!==void 0&&{rateLimitType:e.rateLimitType},...e.utilization!==void 0&&{utilization:e.utilization},...e.overageStatus!==void 0&&{overageStatus:e.overageStatus},...e.overageResetsAt!==void 0&&{overageResetsAt:e.overageResetsAt},...e.overageDisabledReason!==void 0&&{overageDisabledReason:e.overageDisabledReason},...e.isUsingOverage!==void 0&&{isUsingOverage:e.isUsingOverage},...e.surpassedThreshold!==void 0&&{surpassedThreshold:e.surpassedThreshold}}}function v(e){let t=e.message.content;if(!Array.isArray(t))return e.message;let n=t.map(e=>{if(e.type!==`tool_use`)return e;if(e.name===`ExitPlanMode`){let t=c();if(t)return{...e,input:{...e.input,plan:t}}}return e});return{...e.message,content:n}}var y=e((()=>{i(),a(),u(),n(),s(),o()}));export{p as a,f as i,y as n,h as o,g as r,_ as s,m as t};
@@ -0,0 +1 @@
1
+ import{n as e,o as t}from"./chunk-DR8-3Aex.js";import{n,t as r}from"./figures-gfT9mM8P.js";import{Q as i,Rn as a,T as o,b as s,f as c,g as l,h as u,nt as d,t as f,tt as p,v as m,x as h}from"./src-Di342QoJ.js";import{t as g}from"./jsx-runtime-D-D469L8.js";import{Do as _,Po as v,jo as y}from"./paths-Q2255dD7.js";import{c as b,s as x}from"./debug-UI3T040K.js";import{Dx as S,GC as C,JS as w,MS as T,NS as E,RC as D,SC as ee,XC as O,YS as k,_C as A,cy as j,gC as M,gy as N,jS as P,my as te,qC as F,xC as I}from"./loadAgentsDir-Ci5mr0vm.js";import{D as ne,O as re}from"./rcDebugLog-BbPkkigY.js";import{t as ie}from"./useKeybinding-FsOnjW6T.js";import{i as ae,n as oe,r as se}from"./MCPConnectionManager-CDsa79pu.js";import{n as ce,t as le}from"./McpParsingWarnings-DZkzoeZf.js";import{a as ue,c as L,i as R,l as de,n as fe,o as z,r as pe,s as me,t as he,u as B}from"./PluginSettings-B2ASJ0Rx.js";function ge({agentServer:e,onCancel:t,onComplete:n}){let[a]=o(),[d,f]=(0,V.useState)(!1),[g,v]=(0,V.useState)(null),[y,b]=(0,V.useState)(null),x=(0,V.useRef)(null);(0,V.useEffect)(()=>()=>x.current?.abort(),[]),p(`confirm:no`,(0,V.useCallback)(()=>{d&&(x.current?.abort(),x.current=null,f(!1),b(null))},[d]),{context:`Confirmation`,isActive:d});let C=(0,V.useCallback)(async()=>{if(!e.needsAuth||!e.url)return;f(!0),v(null);let t=new AbortController;x.current=t;try{let r={type:e.transport,url:e.url};await ee(e.name,r,b,t.signal),n?.(`Authentication successful for ${e.name}. The server will connect when the agent runs.`)}catch(e){e instanceof Error&&!(e instanceof M)&&v(e.message)}finally{f(!1),x.current=null}},[e,n]),T=_(String(e.name));if(d)return(0,H.jsxs)(h,{flexDirection:`column`,gap:1,padding:1,children:[(0,H.jsxs)(s,{color:`claude`,children:[`Authenticating with `,e.name,`…`]}),(0,H.jsxs)(h,{children:[(0,H.jsx)(te,{}),(0,H.jsx)(s,{children:` A browser window will open for authentication`})]}),y&&(0,H.jsxs)(h,{flexDirection:`column`,children:[(0,H.jsx)(s,{dimColor:!0,children:`If your browser doesn't open automatically, copy this URL manually:`}),(0,H.jsx)(i,{url:y})]}),(0,H.jsx)(h,{marginLeft:3,children:(0,H.jsxs)(s,{dimColor:!0,children:[`Return here after authenticating in your browser.`,` `,(0,H.jsx)(w,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]})})]});let E=[];return e.needsAuth&&E.push({label:e.isAuthenticated?`Re-authenticate`:`Authenticate`,value:`auth`}),E.push({label:`Back`,value:`back`}),(0,H.jsxs)(c,{title:`${T} MCP Server`,subtitle:`agent-only`,onCancel:t,inputGuide:e=>e.pending?(0,H.jsxs)(s,{children:[`Press `,e.keyName,` again to exit`]}):(0,H.jsxs)(u,{children:[(0,H.jsx)(l,{shortcut:`↑↓`,action:`navigate`}),(0,H.jsx)(l,{shortcut:`Enter`,action:`confirm`}),(0,H.jsx)(w,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]}),children:[(0,H.jsxs)(h,{flexDirection:`column`,gap:0,children:[(0,H.jsxs)(h,{children:[(0,H.jsx)(s,{bold:!0,children:`Type: `}),(0,H.jsx)(s,{dimColor:!0,children:e.transport})]}),e.url&&(0,H.jsxs)(h,{children:[(0,H.jsx)(s,{bold:!0,children:`URL: `}),(0,H.jsx)(s,{dimColor:!0,children:e.url})]}),e.command&&(0,H.jsxs)(h,{children:[(0,H.jsx)(s,{bold:!0,children:`Command: `}),(0,H.jsx)(s,{dimColor:!0,children:e.command})]}),(0,H.jsxs)(h,{children:[(0,H.jsx)(s,{bold:!0,children:`Used by: `}),(0,H.jsx)(s,{dimColor:!0,children:e.sourceAgents.join(`, `)})]}),(0,H.jsxs)(h,{marginTop:1,children:[(0,H.jsx)(s,{bold:!0,children:`Status: `}),(0,H.jsxs)(s,{children:[m(`inactive`,a)(r.radioOff),` not connected (agent-only)`]})]}),e.needsAuth&&(0,H.jsxs)(h,{children:[(0,H.jsx)(s,{bold:!0,children:`Auth: `}),e.isAuthenticated?(0,H.jsxs)(s,{children:[m(`success`,a)(r.tick),` authenticated`]}):(0,H.jsxs)(s,{children:[m(`warning`,a)(r.triangleUpOutline),` may need authentication`]})]})]}),(0,H.jsx)(h,{children:(0,H.jsx)(s,{dimColor:!0,children:`This server connects only when running the agent.`})}),g&&(0,H.jsx)(h,{children:(0,H.jsxs)(s,{color:`error`,children:[`Error: `,g]})}),(0,H.jsx)(h,{children:(0,H.jsx)(S,{options:E,onChange:async e=>{switch(e){case`auth`:await C();break;case`back`:t();break}},onCancel:t})})]})}var V,H,U=e((()=>{n(),V=t(a(),1),f(),ie(),I(),y(),k(),j(),N(),H=g()}));function W(e){switch(e){case`project`:return{label:`Project MCPs`,path:D(e)};case`user`:return{label:`User MCPs`,path:D(e)};case`local`:return{label:`Local MCPs`,path:D(e)};case`enterprise`:return{label:`Enterprise MCPs`};case`dynamic`:return{label:`Built-in MCPs`,path:`always available`};default:return{label:e}}}function _e(e){let t=new Map;for(let n of e){let e=n.scope;t.has(e)||t.set(e,[]),t.get(e).push(n)}for(let[,e]of t)e.sort((e,t)=>e.name.localeCompare(t.name));return t}function ve({servers:e,agentServers:t=[],onSelectServer:n,onSelectAgentServer:a,onComplete:f}){let[p]=o(),[g,_]=(0,G.useState)(0),y=G.useMemo(()=>_e(e.filter(e=>e.client.config.type!==`claudeai-proxy`)),[e]),x=G.useMemo(()=>e.filter(e=>e.client.config.type===`claudeai-proxy`).sort((e,t)=>e.name.localeCompare(t.name)),[e]),S=G.useMemo(()=>(y.get(`dynamic`)??[]).sort((e,t)=>e.name.localeCompare(t.name)),[y]),C=W(`dynamic`),T=G.useMemo(()=>{let e=[];for(let t of q){let n=y.get(t)??[];for(let t of n)e.push({type:`server`,server:t})}for(let t of x)e.push({type:`server`,server:t});for(let n of t)e.push({type:`agent-server`,agentServer:n});for(let t of S)e.push({type:`server`,server:t});return e},[y,x,t,S]),E=(0,G.useCallback)(()=>{f(`MCP dialog dismissed`,{display:`system`})},[f]);d({"confirm:previous":()=>_(e=>e===0?T.length-1:e-1),"confirm:next":()=>_(e=>e===T.length-1?0:e+1),"confirm:yes":(0,G.useCallback)(()=>{let e=T[g];e&&(e.type===`server`?n(e.server):e.type===`agent-server`&&a&&a(e.agentServer))},[T,g,n,a]),"confirm:no":E},{context:`Confirmation`});let D=e=>T.findIndex(t=>t.type===`server`&&t.server===e),ee=e=>T.findIndex(t=>t.type===`agent-server`&&t.agentServer===e),O=b(),k=e.some(e=>e.client.type===`failed`);if(e.length===0&&t.length===0)return null;let A=e=>{let t=D(e),n=g===t,i=``,a=``;if(e.client.type===`disabled`)i=m(`inactive`,p)(r.radioOff),a=`disabled`;else if(e.client.type===`connected`)i=m(`success`,p)(r.tick),a=`connected`;else if(e.client.type===`pending`){i=m(`inactive`,p)(r.radioOff);let{reconnectAttempt:t,maxReconnectAttempts:n}=e.client;a=t&&n?`reconnecting (${t}/${n})…`:`connecting…`}else e.client.type===`needs-auth`?(i=m(`warning`,p)(r.triangleUpOutline),a=`needs authentication`):(i=m(`error`,p)(r.cross),a=`failed`);return(0,K.jsxs)(h,{children:[(0,K.jsx)(s,{color:n?`suggestion`:void 0,children:n?`${r.pointer} `:` `}),(0,K.jsx)(s,{color:n?`suggestion`:void 0,children:e.name}),(0,K.jsxs)(s,{dimColor:!n,children:[` · `,i,` `]}),(0,K.jsx)(s,{dimColor:!n,children:a})]},`${e.name}-${t}`)},j=e=>{let t=ee(e),n=g===t,i=e.needsAuth?m(`warning`,p)(r.triangleUpOutline):m(`inactive`,p)(r.radioOff),a=e.needsAuth?`may need auth`:`agent-only`;return(0,K.jsxs)(h,{children:[(0,K.jsx)(s,{color:n?`suggestion`:void 0,children:n?`${r.pointer} `:` `}),(0,K.jsx)(s,{color:n?`suggestion`:void 0,children:e.name}),(0,K.jsxs)(s,{dimColor:!n,children:[` · `,i,` `]}),(0,K.jsx)(s,{dimColor:!n,children:a})]},`agent-${e.name}-${t}`)},M=e.length+t.length;return(0,K.jsxs)(h,{flexDirection:`column`,children:[(0,K.jsx)(le,{}),(0,K.jsx)(c,{title:`Manage MCP servers`,subtitle:`${M} ${v(M,`server`)}`,onCancel:E,hideInputGuide:!0,children:(0,K.jsxs)(h,{flexDirection:`column`,children:[q.map(e=>{let t=y.get(e);if(!t||t.length===0)return null;let n=W(e);return(0,K.jsxs)(h,{flexDirection:`column`,marginBottom:1,children:[(0,K.jsxs)(h,{paddingLeft:2,children:[(0,K.jsx)(s,{bold:!0,children:n.label}),n.path&&(0,K.jsxs)(s,{dimColor:!0,children:[` (`,n.path,`)`]})]}),t.map(e=>A(e))]},e)}),x.length>0&&(0,K.jsxs)(h,{flexDirection:`column`,marginBottom:1,children:[(0,K.jsx)(h,{paddingLeft:2,children:(0,K.jsx)(s,{bold:!0,children:`claude.ai`})}),x.map(e=>A(e))]}),t.length>0&&(0,K.jsxs)(h,{flexDirection:`column`,marginBottom:1,children:[(0,K.jsx)(h,{paddingLeft:2,children:(0,K.jsx)(s,{bold:!0,children:`Agent MCPs`})}),[...new Set(t.flatMap(e=>e.sourceAgents))].map(e=>(0,K.jsxs)(h,{flexDirection:`column`,marginTop:1,children:[(0,K.jsx)(h,{paddingLeft:2,children:(0,K.jsxs)(s,{dimColor:!0,children:[`@`,e]})}),t.filter(t=>t.sourceAgents.includes(e)).map(e=>j(e))]},e))]}),S.length>0&&(0,K.jsxs)(h,{flexDirection:`column`,marginBottom:1,children:[(0,K.jsxs)(h,{paddingLeft:2,children:[(0,K.jsx)(s,{bold:!0,children:C.label}),C.path&&(0,K.jsxs)(s,{dimColor:!0,children:[` (`,C.path,`)`]})]}),S.map(e=>A(e))]}),(0,K.jsxs)(h,{flexDirection:`column`,children:[k&&(0,K.jsx)(s,{dimColor:!0,children:O?`※ Error logs shown inline with --debug`:`※ Run claude --debug to see error logs`}),(0,K.jsxs)(s,{dimColor:!0,children:[(0,K.jsx)(i,{url:`https://code.claude.com/docs/en/mcp`,children:`https://code.claude.com/docs/en/mcp`}),` for help`]})]})]})}),(0,K.jsx)(h,{paddingX:1,children:(0,K.jsx)(s,{dimColor:!0,italic:!0,children:(0,K.jsxs)(u,{children:[(0,K.jsx)(l,{shortcut:`↑↓`,action:`navigate`}),(0,K.jsx)(l,{shortcut:`Enter`,action:`confirm`}),(0,K.jsx)(w,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]})})})]})}var G,K,q,ye=e((()=>{n(),G=t(a(),1),f(),ie(),O(),x(),y(),k(),ce(),K=g(),q=[`project`,`local`,`user`,`enterprise`]}));function be({serverName:e,onComplete:t}){let[n]=o(),i=E(),a=se(),[c,l]=(0,J.useState)(!0),[u,d]=(0,J.useState)(null);return(0,J.useEffect)(()=>{async function n(){try{if(!i.getState().mcp.clients.find(t=>t.name===e)){d(`MCP server "${e}" not found`),l(!1),t(`MCP server "${e}" not found`);return}switch((await a(e)).client.type){case`connected`:l(!1),t(`Successfully reconnected to ${e}`);break;case`needs-auth`:d(`${e} requires authentication`),l(!1),t(`${e} requires authentication. Use /mcp to authenticate.`);break;case`pending`:case`failed`:case`disabled`:d(`Failed to reconnect to ${e}`),l(!1),t(`Failed to reconnect to ${e}`);break}}catch(e){let n=e instanceof Error?e.message:String(e);d(n),l(!1),t(`Error: ${n}`)}}n()},[e,a,i,t]),c?(0,Y.jsxs)(h,{flexDirection:`column`,gap:1,padding:1,children:[(0,Y.jsxs)(s,{color:`text`,children:[`Reconnecting to `,(0,Y.jsx)(s,{bold:!0,children:e})]}),(0,Y.jsxs)(h,{children:[(0,Y.jsx)(te,{}),(0,Y.jsx)(s,{children:` Establishing connection to MCP server`})]})]}):u?(0,Y.jsxs)(h,{flexDirection:`column`,gap:1,padding:1,children:[(0,Y.jsxs)(h,{children:[(0,Y.jsxs)(s,{children:[m(`error`,n)(r.cross),` `]}),(0,Y.jsxs)(s,{color:`error`,children:[`Failed to reconnect to `,e]})]}),(0,Y.jsxs)(s,{dimColor:!0,children:[`Error: `,u]})]}):null}var J,Y,xe=e((()=>{n(),J=t(a(),1),f(),oe(),P(),N(),Y=g()}));function Se({onComplete:e}){let t=T(e=>e.mcp),n=T(e=>e.agentDefinitions),r=t.clients,[i,a]=X.useState({type:`list`}),[o,s]=X.useState([]),c=(0,X.useMemo)(()=>C(n.allAgents),[n.allAgents]),l=X.useMemo(()=>r.filter(e=>e.name!==`ide`).sort((e,t)=>e.name.localeCompare(t.name)),[r]);switch(X.useEffect(()=>{let e=!1;async function n(){let n=await Promise.all(l.map(async e=>{let n=e.config.scope,r=e.config.type===`sse`,i=e.config.type===`http`,a=e.config.type===`claudeai-proxy`,o;if(r||i){let n=await new A(e.name,e.config).tokens(),r=ne()!==null&&e.type===`connected`,i=e.type===`connected`&&F(t.tools,e.name).length>0;o=!!n||r||i}let s={name:e.name,client:e,scope:n};return a?{...s,transport:`claudeai-proxy`,isAuthenticated:!1,config:e.config}:r?{...s,transport:`sse`,isAuthenticated:o,config:e.config}:i?{...s,transport:`http`,isAuthenticated:o,config:e.config}:{...s,transport:`stdio`,config:e.config}}));e||s(n)}return n(),()=>{e=!0}},[l,t.tools]),(0,X.useEffect)(()=>{o.length===0&&l.length>0||o.length===0&&c.length===0&&e("No MCP servers configured. Please run /doctor if this is unexpected. Otherwise, run `claude mcp --help` or visit https://code.claude.com/docs/en/mcp to learn more.")},[o.length,l.length,c.length,e]),i.type){case`list`:return(0,Z.jsx)(ve,{servers:o,agentServers:c,onSelectServer:e=>a({type:`server-menu`,server:e}),onSelectAgentServer:e=>a({type:`agent-server-menu`,agentServer:e}),onComplete:e,defaultTab:i.defaultTab});case`server-menu`:{let n=F(t.tools,i.server.name),r=i.server.transport===`claudeai-proxy`?`claude.ai`:`Claude Code`;return i.server.transport===`stdio`?(0,Z.jsx)(me,{server:i.server,serverToolsCount:n.length,onViewTools:()=>a({type:`server-tools`,server:i.server}),onCancel:()=>a({type:`list`,defaultTab:r}),onComplete:e}):(0,Z.jsx)(de,{server:i.server,serverToolsCount:n.length,onViewTools:()=>a({type:`server-tools`,server:i.server}),onCancel:()=>a({type:`list`,defaultTab:r}),onComplete:e})}case`server-tools`:return(0,Z.jsx)(pe,{server:i.server,onSelectTool:(e,t)=>a({type:`server-tool-detail`,server:i.server,toolIndex:t}),onBack:()=>a({type:`server-menu`,server:i.server})});case`server-tool-detail`:{let e=F(t.tools,i.server.name)[i.toolIndex];return e?(0,Z.jsx)(ue,{tool:e,server:i.server,onBack:()=>a({type:`server-tools`,server:i.server})}):(a({type:`server-tools`,server:i.server}),null)}case`agent-server-menu`:return(0,Z.jsx)(ge,{agentServer:i.agentServer,onCancel:()=>a({type:`list`,defaultTab:`Agents`}),onComplete:e})}}var X,Z,Ce=e((()=>{X=t(a(),1),I(),O(),P(),re(),U(),ye(),B(),L(),z(),R(),Z=g()})),we=e((()=>{U(),ye(),xe(),B(),Ce(),L(),z(),R()}));function Te({action:e,target:t,onComplete:n}){let r=T(e=>e.mcp.clients),i=ae(),a=(0,Q.useRef)(!1);return(0,Q.useEffect)(()=>{if(a.current)return;a.current=!0;let o=e===`enable`,s=r.filter(e=>e.name!==`ide`),c=t===`all`?s.filter(e=>o?e.type===`disabled`:e.type!==`disabled`):s.filter(e=>e.name===t);if(c.length===0){n(t===`all`?`All MCP servers are already ${o?`enabled`:`disabled`}`:`MCP server "${t}" not found`);return}for(let e of c)i(e.name);n(t===`all`?`${o?`Enabled`:`Disabled`} ${c.length} MCP server(s)`:`MCP server "${t}" ${o?`enabled`:`disabled`}`)},[e,t,r,i,n]),null}async function Ee(e,t,n){if(n){let t=n.trim().split(/\s+/);if(t[0]===`no-redirect`)return(0,$.jsx)(Se,{onComplete:e});if(t[0]===`reconnect`&&t[1])return(0,$.jsx)(be,{serverName:t.slice(1).join(` `),onComplete:e});if(t[0]===`enable`||t[0]===`disable`)return(0,$.jsx)(Te,{action:t[0],target:t.length>1?t.slice(1).join(` `):`all`,onComplete:e})}return process.env.USER_TYPE===`ant`?(0,$.jsx)(he,{onComplete:e,args:`manage`,showMcpRedirectMessage:!0}):(0,$.jsx)(Se,{onComplete:e})}var Q,$;e((()=>{Q=t(a(),1),we(),xe(),oe(),P(),fe(),$=g()}))();export{Ee as call};
@@ -0,0 +1,6 @@
1
+ import{o as e}from"./chunk-DR8-3Aex.js";import{n as t,t as n}from"./p-map-D7WEmnBE.js";import{Mt as r,Rn as i,T as a,b as o,f as s,g as c,h as l,t as u,v as ee,x as te}from"./src-Di342QoJ.js";import{t as d}from"./jsx-runtime-D-D469L8.js";import{Ac as f,Nc as p,Po as m,Sc as h,bc as g,jo as ne}from"./paths-Q2255dD7.js";import{V as re,W as ie}from"./debug-UI3T040K.js";import{n as _,r as v}from"./analytics-DqMQntaB.js";import{n as y,o as ae}from"./process-DMKLUQIO.js";import{i as b,o as x}from"./platform-CuyedWpe.js";import{s as S,u as C}from"./types-Csi32ZXh.js";import{$C as w,AS as T,CC as E,Cx as D,GT as O,JS as k,RC as A,TC as j,XC as M,YC as N,YS as P,_x as F,ay as I,bC as L,iw as R,iy as z,jS as B,lw as V,ly as H,ow as U,pw as W,qT as G,sw as K,uy as q,vC as oe,xC as se,xx as ce,yC as le,zC as J}from"./loadAgentsDir-Ci5mr0vm.js";import{n as Y,t as X}from"./exit-_obETqBv.js";import{stat as ue}from"fs/promises";import{cwd as de}from"process";n();var Z=e(i(),1);G(),y(),u(),V(),ne(),P(),q();var Q=d();function fe({servers:e,scope:t,onDone:n}){let r=Object.keys(e),[i,u]=(0,Z.useState)({});(0,Z.useEffect)(()=>{R().then(({servers:e})=>u(e))},[]);let d=r.filter(e=>i[e]!==void 0);async function f(n){let r=0;for(let a of n){let n=e[a];if(n){let e=a;if(i[e]!==void 0){let t=1;for(;i[`${a}_${t}`]!==void 0;)t++;e=`${a}_${t}`}await w(e,n,t),r++}}h(r)}let[p]=a(),h=(0,Z.useCallback)(e=>{ae(e>0?`\n${ee(`success`,p)(`Successfully imported ${e} MCP ${m(e,`server`)} to ${t} config.`)}\n`:`
2
+ No servers were imported.`),n(),O()},[p,t,n]),g=(0,Z.useCallback)(()=>{h(0)},[h]);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(s,{title:`Import MCP Servers from Claude Desktop`,subtitle:`Found ${r.length} MCP ${m(r.length,`server`)} in Claude Desktop.`,color:`success`,onCancel:g,hideInputGuide:!0,children:[d.length>0&&(0,Q.jsx)(o,{color:`warning`,children:`Note: Some servers already exist with the same name. If selected, they will be imported with a numbered suffix.`}),(0,Q.jsx)(o,{children:`Please select the servers you want to import:`}),(0,Q.jsx)(H,{options:r.map(e=>({label:`${e}${d.includes(e)?` (already exists)`:``}`,value:e})),defaultValue:r.filter(e=>!d.includes(e)),onSubmit:f,onCancel:g,hideIndexes:!0})]}),(0,Q.jsx)(te,{paddingX:1,children:(0,Q.jsx)(o,{dimColor:!0,italic:!0,children:(0,Q.jsxs)(l,{children:[(0,Q.jsx)(c,{shortcut:`Space`,action:`select`}),(0,Q.jsx)(c,{shortcut:`Enter`,action:`confirm`}),(0,Q.jsx)(k,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]})})})]})}u(),I(),_(),se(),D(),V(),M(),B(),f(),re(),G(),S(),x();async function $(e,t){try{let n=await F(e,t);return n.type===`connected`?`✓ Connected`:n.type===`needs-auth`?`! Needs authentication`:`✗ Failed to connect`}catch{return`✗ Connection error`}}async function pe({debug:e,verbose:t}){let n=de();v(`tengu_mcp_start`,{});try{await ue(n)}catch(e){throw ie(e)&&X(`Error: Directory ${n} does not exist`),e}try{let{setup:r}=await import(`./setup-TqJ7-Nxh.js`);await r(n,`default`,!1,!1,void 0,!1);let{startMCPServer:i}=await import(`./mcp-DlM0OC6R.js`);await i(n,e??!1,t??!1)}catch(e){X(`Error: Failed to start MCP server: ${e}`)}}async function me(e,t){let n=U(e),r=()=>{n&&(n.type===`sse`||n.type===`http`)&&(le(e,n),oe(e,n))};try{if(t.scope){let n=J(t.scope);v(`tengu_mcp_delete`,{name:e,scope:n}),await W(e,n),r(),process.stdout.write(`Removed MCP server ${e} from ${n} config\n`),Y(`File modified: ${A(n)}`)}let n=g(),i=h(),{servers:a}=K(`project`),o=!!a[e],s=[];if(n.mcpServers?.[e]&&s.push(`local`),o&&s.push(`project`),i.mcpServers?.[e]&&s.push(`user`),s.length===0)X(`No MCP server found with name: "${e}"`);else if(s.length===1){let t=s[0];v(`tengu_mcp_delete`,{name:e,scope:t}),await W(e,t),r(),process.stdout.write(`Removed MCP server "${e}" from ${t} config\n`),Y(`File modified: ${A(t)}`)}else process.stderr.write(`MCP server "${e}" exists in multiple scopes:\n`),s.forEach(e=>{process.stderr.write(` - ${N(e)} (${A(e)})\n`)}),process.stderr.write(`
3
+ To remove from a specific scope, use:
4
+ `),s.forEach(t=>{process.stderr.write(` claude mcp remove "${e}" -s ${t}\n`)}),X()}catch(e){X(e.message)}}async function he(){v(`tengu_mcp_list`,{});let{servers:e}=await R();if(Object.keys(e).length===0)console.log("No MCP servers configured. Use `claude mcp add` to add a server.");else{console.log(`Checking MCP server health...
5
+ `);let n=await t(Object.entries(e),async([e,t])=>({name:e,server:t,status:await $(e,t)}),{concurrency:ce()});for(let{name:e,server:t,status:r}of n)if(t.type===`sse`)console.log(`${e}: ${t.url} (SSE) - ${r}`);else if(t.type===`http`)console.log(`${e}: ${t.url} (HTTP) - ${r}`);else if(t.type===`claudeai-proxy`)console.log(`${e}: ${t.url} - ${r}`);else if(!t.type||t.type===`stdio`){let n=t,i=Array.isArray(n.args)?n.args:[];console.log(`${e}: ${n.command} ${i.join(` `)} - ${r}`)}}await O(0)}async function ge(e){v(`tengu_mcp_get`,{name:e});let t=U(e);t||X(`No MCP server found with name: ${e}`),console.log(`${e}:`),console.log(` Scope: ${N(t.scope)}`);let n=await $(e,t);if(console.log(` Status: ${n}`),t.type===`sse`){if(console.log(` Type: sse`),console.log(` URL: ${t.url}`),t.headers){console.log(` Headers:`);for(let[e,n]of Object.entries(t.headers))console.log(` ${e}: ${n}`)}if(t.oauth?.clientId||t.oauth?.callbackPort){let n=[];t.oauth.clientId&&(n.push(`client_id configured`),L(e,t)?.clientSecret&&n.push(`client_secret configured`)),t.oauth.callbackPort&&n.push(`callback_port ${t.oauth.callbackPort}`),console.log(` OAuth: ${n.join(`, `)}`)}}else if(t.type===`http`){if(console.log(` Type: http`),console.log(` URL: ${t.url}`),t.headers){console.log(` Headers:`);for(let[e,n]of Object.entries(t.headers))console.log(` ${e}: ${n}`)}if(t.oauth?.clientId||t.oauth?.callbackPort){let n=[];t.oauth.clientId&&(n.push(`client_id configured`),L(e,t)?.clientSecret&&n.push(`client_secret configured`)),t.oauth.callbackPort&&n.push(`callback_port ${t.oauth.callbackPort}`),console.log(` OAuth: ${n.join(`, `)}`)}}else if(t.type===`stdio`){console.log(` Type: stdio`),console.log(` Command: ${t.command}`);let e=Array.isArray(t.args)?t.args:[];if(console.log(` Args: ${e.join(` `)}`),t.env){console.log(` Environment:`);for(let[e,n]of Object.entries(t.env))console.log(` ${e}=${n}`)}}console.log(`\nTo remove this server, run: claude mcp remove "${e}" -s ${t.scope}`),await O(0)}async function _e(e,t,n){try{let r=J(n.scope),i=C(t),a=n.clientSecret&&i&&typeof i==`object`&&`type`in i&&(i.type===`sse`||i.type===`http`)&&`url`in i&&typeof i.url==`string`&&`oauth`in i&&i.oauth&&typeof i.oauth==`object`&&`clientId`in i.oauth?await E():void 0;await w(e,i,r);let o=i&&typeof i==`object`&&`type`in i?String(i.type||`stdio`):`stdio`;a&&i&&typeof i==`object`&&`type`in i&&(i.type===`sse`||i.type===`http`)&&`url`in i&&typeof i.url==`string`&&j(e,{type:i.type,url:i.url},a),v(`tengu_mcp_add`,{scope:r,source:`json`,type:o}),Y(`Added ${o} MCP server ${e} to ${r} config`)}catch(e){X(e.message)}}async function ve(e){try{let t=J(e.scope);v(`tengu_mcp_add`,{scope:t,platform:b(),source:`desktop`});let{readClaudeDesktopMcpServers:n}=await import(`./claudeDesktop-D0S1eq1F.js`),i=await n();Object.keys(i).length===0&&Y(`No MCP servers found in Claude Desktop configuration or configuration file does not exist.`);let{unmount:a}=await r((0,Q.jsx)(T,{children:(0,Q.jsx)(z,{children:(0,Q.jsx)(fe,{servers:i,scope:t,onDone:()=>{a()}})})}),{exitOnCtrlC:!0})}catch(e){X(e.message)}}async function ye(){v(`tengu_mcp_reset_mcpjson_choices`,{}),p(e=>({...e,enabledMcpjsonServers:[],disabledMcpjsonServers:[],enableAllProjectMcpServers:!1})),Y(`All project-scoped (.mcp.json) server approvals and rejections have been reset.
6
+ You will be prompted for approval next time you start Claude Code.`)}export{ve as mcpAddFromDesktopHandler,_e as mcpAddJsonHandler,ge as mcpGetHandler,he as mcpListHandler,me as mcpRemoveHandler,ye as mcpResetChoicesHandler,pe as mcpServeHandler};
@@ -0,0 +1,2 @@
1
+ import{B as e,M as t,d as n,n as r,t as i}from"./server-DzOdtq8A.js";import{Dr as a,Pr as o}from"./paths-Q2255dD7.js";import{E as s,w as c}from"./debug-UI3T040K.js";import{o as l,s as u}from"./log-CzsijfHZ.js";import{CD as d,G as f,HE as p,Hm as m,K as h,Ku as g,Lo as _,Na as v,Pa as y,SD as b,UE as x,Um as S,lo as C,nl as w,ou as T,qu as E,su as D,tl as O}from"./loadAgentsDir-Ci5mr0vm.js";import{Bn as k,Vn as A,zn as j}from"./prompt-DEPUnJdB.js";import{a as M,o as N}from"./fileStateCache-C7-TxF8G.js";import{n as P,t as F}from"./stdio-BEEzuxaZ.js";r(),P(),e(),x(),v(),A(),E(),d(),N(),l(),_(),o(),h(),m(),c(),D(),O();var I=[y];async function L(e,r,o){let c=M(100);S(e);let l=new i({name:`claude/tengu`,version:`2.6.0`},{capabilities:{tools:{}}});l.setRequestHandler(t,async()=>{let e=k(),t=g(e);return{tools:await Promise.all(t.map(async n=>{let r;if(n.outputSchema){let e=w(n.outputSchema);typeof e==`object`&&e&&`type`in e&&e.type===`object`&&(r=e)}return{...n,description:await n.prompt({getToolPermissionContext:async()=>e,tools:t,agents:[]}),inputSchema:w(n.inputSchema),outputSchema:r}}))}}),l.setRequestHandler(n,async({params:{name:e,arguments:t}})=>{let n=g(k()),i=j(n,e);if(!i)throw Error(`Tool ${e} not found`);let l={abortController:b(),options:{commands:I,tools:n,mainLoopModel:a(),thinkingConfig:{type:`disabled`},mcpClients:[],mcpResources:{},isNonInteractiveSession:!0,debug:r,verbose:o,agentDefinitions:{activeAgents:[],allAgents:[]}},getAppState:()=>p(),setAppState:()=>{},messages:[],readFileState:c,setInProgressToolUseIDs:()=>{},setResponseLength:()=>{},updateFileHistoryState:()=>{},updateAttributionState:()=>{}};try{if(!i.isEnabled())throw Error(`Tool ${e} is not enabled`);let n=await i.validateInput?.(t??{},l);if(n&&!n.result)throw Error(`Tool ${e} input is invalid: ${n.message}`);let r=await i.call(t??{},l,f,C({content:[]}));return{content:[{type:`text`,text:typeof r==`string`?r:s(r.data)}]}}catch(e){return u(e),{isError:!0,content:[{type:`text`,text:(e instanceof Error?T(e):[String(e)]).filter(Boolean).join(`
2
+ `).trim()||`Error`}]}}});async function d(){let e=new F;await l.connect(e)}return await d()}export{L as startMCPServer};
@@ -0,0 +1 @@
1
+ import{n as e}from"./chunk-DR8-3Aex.js";import{B as t,M as n}from"./server-DzOdtq8A.js";import{Ac as r,M as i,_c as a,z as o}from"./paths-Q2255dD7.js";import{d as s,s as c}from"./debug-UI3T040K.js";import{r as l,t as u}from"./datadog-Bd1s_VFj.js";import{i as d,r as f,t as p}from"./src-BlLavFUS.js";import{i as m,t as h}from"./gates-CbQLZHtm.js";import{n as g,t as _}from"./hostAdapter-D1eWmmhu.js";import{n as v,t as y}from"./stdio-BEEzuxaZ.js";import{r as b,t as x}from"./sink-B3uP8Cf8.js";import{homedir as S}from"os";function C(e,t){if(k.some(t=>e.startsWith(t)))return!0;if(t){let n=t.endsWith(`/`)?`${t}Applications/`:`${t}/Applications/`;if(e.startsWith(n))return!0}return!1}function w(e){return A.some(t=>t.test(e))}function T(e,t){let n=new Set;return e.map(e=>e.trim()).filter(e=>!e||e.length>N||t&&!M.test(e)||n.has(e)?!1:(n.add(e),!0)).sort((e,t)=>e.localeCompare(t))}function E(e){let t=T(e,!0);return t.length<=P?t:[...t.slice(0,P),`… and ${t.length-P} more`]}function D(e){return T(e,!1)}function O(e,t){let{alwaysKept:n,rest:r}=e.reduce((e,n)=>(j.has(n.bundleId)?e.alwaysKept.push(n.displayName):C(n.path,t)&&!w(n.displayName)&&e.rest.push(n.displayName),e),{alwaysKept:[],rest:[]}),i=D(n),a=new Set(i);return[...i,...E(r).filter(e=>!a.has(e))]}var k,A,j,M,N,P,F=e((()=>{k=[`/Applications/`,`/System/Applications/`],A=[/Helper(?:$|\s\()/,/Agent(?:$|\s\()/,/Service(?:$|\s\()/,/Uninstaller(?:$|\s\()/,/Updater(?:$|\s\()/,/^\./],j=new Set(`com.apple.Safari,com.google.Chrome,com.microsoft.edgemac,org.mozilla.firefox,company.thebrowser.Browser,com.tinyspeck.slackmacgap,us.zoom.xos,com.microsoft.teams2,com.microsoft.teams,com.apple.MobileSMS,com.apple.mail,com.microsoft.Word,com.microsoft.Excel,com.microsoft.Powerpoint,com.microsoft.Outlook,com.apple.iWork.Pages,com.apple.iWork.Numbers,com.apple.iWork.Keynote,com.google.GoogleDocs,notion.id,com.apple.Notes,md.obsidian,com.linear,com.figma.Desktop,com.microsoft.VSCode,com.apple.Terminal,com.googlecode.iterm2,com.github.GitHubDesktop,com.apple.finder,com.apple.iCal,com.apple.systempreferences`.split(`,`)),M=/^[\p{L}\p{M}\p{N}_ .&'()+-]+$/u,N=40,P=50}));async function I(){let e=_().executor.listInstalledApps(),t,n=new Promise(e=>{t=setTimeout(e,z,void 0)}),r=await Promise.race([e,n]).catch(()=>void 0).finally(()=>clearTimeout(t));if(!r){e.catch(()=>{}),s(`[Computer Use MCP] app enumeration exceeded ${z}ms or failed; tool description omits list`);return}return O(r,S())}async function L(){let e=_(),t=h(),r=f(e,t),i=await I(),a=d(e.executor.capabilities,t,i);return r.setRequestHandler(n,async()=>e.isDisabled()?{tools:[]}:{tools:a}),r}async function R(){a(),b();let e=await L(),t=new y,n=!1,r=async()=>{n||(n=!0,await Promise.all([o(),l()]),process.exit(0))};process.stdin.on(`end`,()=>void r()),process.stdin.on(`error`,()=>void r()),s(`[Computer Use MCP] Starting MCP server`),await e.connect(t),s(`[Computer Use MCP] MCP server started`)}var z;e((()=>{p(),x(),v(),t(),u(),i(),r(),c(),F(),m(),g(),z=1e3}))();export{L as createComputerUseMcpServerForCli,R as runComputerUseMcpServer};
@@ -0,0 +1 @@
1
+ import{n as e}from"./chunk-DR8-3Aex.js";import{s as t,u as n}from"./envUtils-BWeoiL4Y.js";import{r,t as i}from"./src-BJz1KAd_.js";import{Ac as a,Jt as o,M as s,Pc as c,S as l,Sc as u,_ as d,_c as f,on as p,z as m}from"./paths-Q2255dD7.js";import{d as h,s as g}from"./debug-UI3T040K.js";import{n as _,r as v}from"./analytics-DqMQntaB.js";import{m_ as y,p_ as b}from"./loadAgentsDir-Ci5mr0vm.js";import{r as x,t as S}from"./datadog-Bd1s_VFj.js";import{c as C,i as w,o as T}from"./common-CMCv4N_v.js";import{n as E,t as D}from"./stdio-BEEzuxaZ.js";import{r as O,t as k}from"./sink-B3uP8Cf8.js";import{format as A}from"util";function j(e){return z.some(t=>t===e)}function M(){if(process.env.USER_TYPE===`ant`||d(`tengu_copper_bridge`,!1))return n(process.env.USE_LOCAL_OAUTH)||n(process.env.LOCAL_BRIDGE)?`ws://localhost:8765`:n(process.env.USE_STAGING_OAUTH)?`wss://bridge-staging.claudeusercontent.com`:`wss://bridge.claudeusercontent.com`}function N(){return n(process.env.USE_LOCAL_OAUTH)||n(process.env.LOCAL_BRIDGE)}function P(e){let t=new B,n=M();t.info(`Bridge URL: ${n??`none (using native socket)`}`);let r=e?.CLAUDE_CHROME_PERMISSION_MODE??process.env.CLAUDE_CHROME_PERMISSION_MODE,i;return r&&(j(r)?i=r:t.warn(`Invalid CLAUDE_CHROME_PERMISSION_MODE "${r}". Valid values: ${z.join(`, `)}`)),{serverName:`Claude in Chrome`,logger:t,socketPath:T(),getSocketPaths:w,clientTypeId:`claude-code`,onAuthenticationError:()=>{t.warn(`Authentication error occurred. Please ensure you are logged into the Claude browser extension with the same claude.ai account as Claude Code.`)},onToolCallDisconnected:()=>`Browser extension is not connected. Please ensure the Claude browser extension is installed and running (${I}), and that you are logged into claude.ai with the same account as Claude Code. If this is your first time connecting to Chrome, you may need to restart Chrome for the installation to take effect. If you continue to experience issues, please report a bug: ${L}`,onExtensionPaired:(e,n)=>{c(t=>t.chromeExtension?.pairedDeviceId===e&&t.chromeExtension?.pairedDeviceName===n?t:{...t,chromeExtension:{pairedDeviceId:e,pairedDeviceName:n}}),t.info(`Paired with "${n}" (${e.slice(0,8)})`)},getPersistedDeviceId:()=>u().chromeExtension?.pairedDeviceId,...n&&{bridgeConfig:{url:n,getUserId:async()=>u().oauthAccount?.accountUuid,getOAuthToken:async()=>o()?.accessToken??``,...N()&&{devUserId:`dev_user_local`}}},...i&&{initialPermissionMode:i},...process.env.USER_TYPE===`ant`&&{callAnthropicMessages:async e=>{let t=await y({model:e.model,system:e.system,messages:e.messages,max_tokens:e.max_tokens,stop_sequences:e.stop_sequences,signal:e.signal,skipSystemPromptPrefix:!0,tools:[],querySource:`chrome_mcp`}),n=[];for(let e of t.content)e.type===`text`&&n.push({type:`text`,text:e.text});return{content:n,stop_reason:t.stop_reason,usage:{input_tokens:t.usage.input_tokens,output_tokens:t.usage.output_tokens}}}},trackEvent:(e,t)=>{let n={};if(t)for(let[e,r]of Object.entries(t)){let t=e===`status`?`bridge_status`:e;(typeof r==`boolean`||typeof r==`number`||typeof r==`string`&&R.has(t))&&(n[t]=r)}v(e,n)}}}async function F(){f(),O();let e=r(P()),t=new D,n=!1,i=async()=>{n||(n=!0,await m(),await x(),process.exit(0))};process.stdin.on(`end`,()=>void i()),process.stdin.on(`error`,()=>void i()),h(`[Claude in Chrome] Starting MCP server`),await e.connect(t),h(`[Claude in Chrome] MCP server started`)}var I,L,R,z,B;e((()=>{i(),k(),E(),S(),s(),l(),_(),p(),a(),g(),t(),b(),C(),I=`https://claude.ai/chrome`,L=`https://github.com/anthropics/claude-code/issues/new?labels=bug,claude-in-chrome`,R=new Set([`bridge_status`,`error_type`,`tool_name`]),z=[`ask`,`skip_all_permission_checks`,`follow_a_plan`],B=class{silly(e,t){h(A(e,t??``),{level:`debug`})}debug(e,t){h(A(e,t??``),{level:`debug`})}info(e,t){h(A(e,t??``),{level:`info`})}warn(e,t){h(A(e,t??``),{level:`warn`})}error(e,t){h(A(e,t??``),{level:`error`})}}}))();export{P as createChromeContext,F as runClaudeInChromeMcpServer};
@@ -0,0 +1 @@
1
+ import{n as e}from"./chunk-DR8-3Aex.js";import{c as t,i as n,n as r,r as i,s as a,t as o}from"./isObject-DaxDnPKm.js";function s(e){if(!r(e))return!1;var t=i(e);return t==l||t==u||t==c||t==d}var c,l,u,d,f=e((()=>{n(),o(),c=`[object AsyncFunction]`,l=`[object Function]`,u=`[object GeneratorFunction]`,d=`[object Proxy]`})),p,m=e((()=>{a(),p=t[`__core-js_shared__`]}));function ee(e){return!!h&&h in e}var h,te=e((()=>{m(),h=function(){var e=/[^.]+$/.exec(p&&p.keys&&p.keys.IE_PROTO||``);return e?`Symbol(src)_1.`+e:``}()}));function g(e){if(e!=null){try{return _.call(e)}catch{}try{return e+``}catch{}}return``}var _,v=e((()=>{_=Function.prototype.toString}));function ne(e){return!r(e)||ee(e)?!1:(s(e)?T:b).test(g(e))}var y,b,x,S,C,w,T,re=e((()=>{f(),te(),o(),v(),y=/[\\^$.*+?()[\]{}|]/g,b=/^\[object .+?Constructor\]$/,x=Function.prototype,S=Object.prototype,C=x.toString,w=S.hasOwnProperty,T=RegExp(`^`+C.call(w).replace(y,`\\$&`).replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,`$1.*?`)+`$`)}));function ie(e,t){return e?.[t]}var ae=e((()=>{}));function E(e,t){var n=ie(e,t);return ne(n)?n:void 0}var D=e((()=>{re(),ae()})),O,k=e((()=>{D(),O=E(Object,`create`)}));function oe(){this.__data__=O?O(null):{},this.size=0}var se=e((()=>{k()}));function ce(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=+!!t,t}var le=e((()=>{}));function ue(e){var t=this.__data__;if(O){var n=t[e];return n===A?void 0:n}return j.call(t,e)?t[e]:void 0}var A,j,de=e((()=>{k(),A=`__lodash_hash_undefined__`,j=Object.prototype.hasOwnProperty}));function fe(e){var t=this.__data__;return O?t[e]!==void 0:M.call(t,e)}var M,pe=e((()=>{k(),M=Object.prototype.hasOwnProperty}));function me(e,t){var n=this.__data__;return this.size+=+!this.has(e),n[e]=O&&t===void 0?N:t,this}var N,he=e((()=>{k(),N=`__lodash_hash_undefined__`}));function P(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}var F=e((()=>{se(),le(),de(),pe(),he(),P.prototype.clear=oe,P.prototype.delete=ce,P.prototype.get=ue,P.prototype.has=fe,P.prototype.set=me}));function I(){this.__data__=[],this.size=0}var L=e((()=>{}));function R(e,t){return e===t||e!==e&&t!==t}var z=e((()=>{}));function B(e,t){for(var n=e.length;n--;)if(R(e[n][0],t))return n;return-1}var V=e((()=>{z()}));function ge(e){var t=this.__data__,n=B(t,e);return n<0?!1:(n==t.length-1?t.pop():H.call(t,n,1),--this.size,!0)}var H,_e=e((()=>{V(),H=Array.prototype.splice}));function ve(e){var t=this.__data__,n=B(t,e);return n<0?void 0:t[n][1]}var ye=e((()=>{V()}));function be(e){return B(this.__data__,e)>-1}var xe=e((()=>{V()}));function Se(e,t){var n=this.__data__,r=B(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this}var Ce=e((()=>{V()}));function U(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}var W=e((()=>{L(),_e(),ye(),xe(),Ce(),U.prototype.clear=I,U.prototype.delete=ge,U.prototype.get=ve,U.prototype.has=be,U.prototype.set=Se})),G,K=e((()=>{D(),a(),G=E(t,`Map`)}));function we(){this.size=0,this.__data__={hash:new P,map:new(G||U),string:new P}}var Te=e((()=>{F(),W(),K()}));function Ee(e){var t=typeof e;return t==`string`||t==`number`||t==`symbol`||t==`boolean`?e!==`__proto__`:e===null}var De=e((()=>{}));function q(e,t){var n=e.__data__;return Ee(t)?n[typeof t==`string`?`string`:`hash`]:n.map}var J=e((()=>{De()}));function Oe(e){var t=q(this,e).delete(e);return this.size-=+!!t,t}var ke=e((()=>{J()}));function Ae(e){return q(this,e).get(e)}var je=e((()=>{J()}));function Y(e){return q(this,e).has(e)}var Me=e((()=>{J()}));function Ne(e,t){var n=q(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this}var Pe=e((()=>{J()}));function X(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}var Z=e((()=>{Te(),ke(),je(),Me(),Pe(),X.prototype.clear=we,X.prototype.delete=Oe,X.prototype.get=Ae,X.prototype.has=Y,X.prototype.set=Ne}));function Q(e,t){if(typeof e!=`function`||t!=null&&typeof t!=`function`)throw TypeError($);var n=function(){var r=arguments,i=t?t.apply(this,r):r[0],a=n.cache;if(a.has(i))return a.get(i);var o=e.apply(this,r);return n.cache=a.set(i,o)||a,o};return n.cache=new(Q.Cache||X),n}var $,Fe=e((()=>{Z(),$=`Expected a function`,Q.Cache=X}));export{G as a,W as c,E as d,D as f,s as g,f as h,Z as i,R as l,g as m,Q as n,K as o,v as p,X as r,U as s,Fe as t,z as u};
@@ -0,0 +1 @@
1
+ import{n as e}from"./chunk-DR8-3Aex.js";import{E as t,w as n}from"./debug-UI3T040K.js";import{o as r,s as i}from"./log-CzsijfHZ.js";import{n as a,t as o}from"./index.min-BJnb9GQI.js";function s(e,n=300*1e3){let r=new Map,a=new Map,o=async(...o)=>{let s=t(o),c=r.get(s),l=Date.now();if(!c){let t=a.get(s);if(t)return t;let n=e(...o);a.set(s,n);try{let e=await n;return a.get(s)===n&&r.set(s,{value:e,timestamp:l,refreshing:!1}),e}finally{a.get(s)===n&&a.delete(s)}}if(c&&l-c.timestamp>n&&!c.refreshing){c.refreshing=!0;let t=c;return e(...o).then(e=>{r.get(s)===t&&r.set(s,{value:e,timestamp:Date.now(),refreshing:!1})}).catch(e=>{i(e),r.get(s)===t&&r.delete(s)}),c.value}return r.get(s).value};return o.cache={clear:()=>{r.clear(),a.clear()}},o}function c(e,t,n=100){let r=new o({max:n}),i=(...n)=>{let i=t(...n),a=r.get(i);if(a!==void 0)return a;let o=e(...n);return r.set(i,o),o};return i.cache={clear:()=>r.clear(),size:()=>r.size,delete:e=>r.delete(e),get:e=>r.peek(e),has:e=>r.has(e)},i}var l=e((()=>{a(),r(),n()}));export{c as n,s as r,l as t};
@@ -0,0 +1 @@
1
+ import{n as e,o as t}from"./chunk-DR8-3Aex.js";import{n,s as r}from"./envUtils-BWeoiL4Y.js";import{In as i,Ln as a,Q as o,Rn as s,b as c,d as l,f as u,t as d,tt as f,x as p}from"./src-Di342QoJ.js";import{t as m}from"./jsx-runtime-D-D469L8.js";import{cn as h,ot as g}from"./state-sIHsFpDu.js";import{Zc as ee,a as _,el as v,lo as y,n as te,oo as b,s as x}from"./paths-Q2255dD7.js";import{R as S,V as C}from"./debug-UI3T040K.js";import{n as w,r as T}from"./analytics-DqMQntaB.js";import{n as E,t as D}from"./cwd--iizewsn.js";import{r as O,v as k}from"./git-CN3qtTb_.js";import{o as A,s as j}from"./log-CzsijfHZ.js";import{g as M,x as N}from"./startupProfiler-DnXZaX4A.js";import{Dx as ne,Hn as re,MS as P,Wn as F,cy as I,eu as L,gk as R,jS as z,lp as ie,tu as ae,up as oe,xk as B,yk as V}from"./loadAgentsDir-Ci5mr0vm.js";import{r as se,t as ce}from"./browser-fLRXxIsQ.js";import{t as le}from"./useKeybinding-FsOnjW6T.js";import{l as H,u as U}from"./referral-ByevBJrE.js";import{r as ue,t as de}from"./promptEditor-Ci-h04-5.js";import{homedir as fe}from"os";import{join as W,relative as pe}from"path";import{mkdir as G,writeFile as me}from"fs/promises";function he(e){return O(e)!==null}var ge=e((()=>{k()}));function _e({onSelect:e,onCancel:t}){let r=(0,K.use)(V()),a=W(n(),`CLAUDE.md`),o=W(g(),`CLAUDE.md`),s=r.some(e=>e.path===a),u=r.some(e=>e.path===o),d=[...r.filter(e=>e.type!==`AutoMem`&&e.type!==`TeamMem`).map(e=>({...e,exists:!0})),...s?[]:[{path:a,type:`User`,content:``,exists:!1}],...u?[]:[{path:o,type:`Project`,content:``,exists:!1}]],m=new Map,h=d.map(e=>{let t=ee(e.path),n=e.exists?``:` (new)`,r=e.parent?(m.get(e.parent)??0)+1:0;m.set(e.path,r);let i=r>0?` `.repeat(r-1):``,s;s=e.type===`User`&&!e.isNested&&e.path===a?`User memory`:e.type===`Project`&&!e.isNested&&e.path===o?`Project memory`:r>0?`${i}L ${t}${n}`:`${t}`;let c,l=he(g());return c=e.type===`User`&&!e.isNested?`Saved in ~/.claude/CLAUDE.md`:e.type===`Project`&&!e.isNested&&e.path===o?`${l?`Checked in at`:`Saved in`} ./CLAUDE.md`:e.parent?`@-imported`:e.isNested?`dynamically loaded`:``,{label:s,value:e.path,description:c}}),_=[],v=P(e=>e.agentDefinitions);if(x()){_.push({label:`Open auto-memory folder`,value:`${Y}${te()}`,description:``});for(let e of v.activeAgents)if(e.memory){let t=re(e.agentType,e.memory);_.push({label:`Open ${i.bold(e.agentType)} agent memory`,value:`${Y}${t}`,description:`${e.memory} scope`})}}h.push(..._);let b=J&&h.some(e=>e.value===J)?J:h[0]?.value||``,[S,C]=(0,K.useState)(x),[w,E]=(0,K.useState)(ae),[D]=(0,K.useState)(x),O=P(e=>Object.values(e.tasks).some(e=>e.type===`dream`&&e.status===`running`)),[k,A]=(0,K.useState)(null);(0,K.useEffect)(()=>{D&&oe().then(A)},[D,O]);let j=O?`running`:k===null?``:k===0?`never`:`last ran ${M(new Date(k))}`,[N,F]=(0,K.useState)(null),I=N!==null,L=+!!D;function R(){let e=!S;y(`userSettings`,{autoMemoryEnabled:e}),C(e),T(`tengu_auto_memory_toggled`,{enabled:e})}function z(){let e=!w;y(`userSettings`,{autoDreamEnabled:e}),E(e),T(`tengu_auto_dream_toggled`,{enabled:e})}return U(),f(`confirm:no`,t,{context:`Confirmation`}),f(`confirm:yes`,()=>{N===0?R():N===1&&z()},{context:`Confirmation`,isActive:I}),f(`select:next`,()=>{F(e=>e!==null&&e<L?e+1:null)},{context:`Select`,isActive:I}),f(`select:previous`,()=>{F(e=>e!==null&&e>0?e-1:e)},{context:`Select`,isActive:I}),(0,q.jsxs)(p,{flexDirection:`column`,width:`100%`,children:[(0,q.jsxs)(p,{flexDirection:`column`,marginBottom:1,children:[(0,q.jsx)(l,{isFocused:N===0,children:(0,q.jsxs)(c,{children:[`Auto-memory: `,S?`on`:`off`]})}),D&&(0,q.jsx)(l,{isFocused:N===1,styled:!1,children:(0,q.jsxs)(c,{color:N===1?`suggestion`:void 0,children:[`Auto-dream: `,w?`on`:`off`,j&&(0,q.jsxs)(c,{dimColor:!0,children:[` · `,j]}),!O&&w&&(0,q.jsx)(c,{dimColor:!0,children:` · /dream to run`})]})})]}),(0,q.jsx)(ne,{defaultFocusValue:b,options:h,isDisabled:I,onChange:t=>{if(t.startsWith(Y)){let e=t.slice(15);G(e,{recursive:!0}).catch(()=>{}).then(()=>se(e));return}J=t,e(t)},onCancel:t,onUpFromFirstItem:()=>F(L)})]})}var K,q,J,Y,X=e((()=>{a(),s(),K=t(s(),1),h(),H(),d(),le(),_(),w(),L(),ie(),z(),F(),ce(),B(),r(),v(),N(),ge(),b(),I(),q=m(),Y=`__open_folder__`}));function ve(e){let t=fe(),n=D(),r=e.startsWith(t)?`~`+e.slice(t.length):null,i=e.startsWith(n)?`./`+pe(n,e):null;return r&&i?r.length<=i.length?r:i:r||i||e}var ye=e((()=>{s(),d(),E(),m()}));function be({onDone:e}){let t=async t=>{try{t.includes(n())&&await G(n(),{recursive:!0});try{await me(t,``,{encoding:`utf8`,flag:`wx`})}catch(e){if(S(e)!==`EEXIST`)throw e}await de(t);let r=`default`,i=``;process.env.VISUAL?(r=`$VISUAL`,i=process.env.VISUAL):process.env.EDITOR&&(r=`$EDITOR`,i=process.env.EDITOR);let a=r===`default`?``:`Using ${r}="${i}".`,o=a?`> ${a} To change editor, set $EDITOR or $VISUAL environment variable.`:`> To use a different editor, set the $EDITOR or $VISUAL environment variable.`;e(`Opened memory file at ${ve(t)}\n\n${o}`,{display:`system`})}catch(t){j(t),e(`Error opening memory file: ${t}`)}},r=()=>{e(`Cancelled memory editing`,{display:`system`})};return(0,Q.jsx)(u,{title:`Memory`,onCancel:r,color:`remember`,children:(0,Q.jsxs)(p,{flexDirection:`column`,children:[(0,Q.jsx)(Z.Suspense,{fallback:null,children:(0,Q.jsx)(_e,{onSelect:t,onCancel:r})}),(0,Q.jsx)(p,{marginTop:1,children:(0,Q.jsxs)(c,{dimColor:!0,children:[`Learn more: `,(0,Q.jsx)(o,{url:`https://code.claude.com/docs/en/memory`})]})})]})})}var Z,Q,$;e((()=>{Z=t(s(),1),d(),X(),ye(),B(),r(),C(),A(),ue(),Q=m(),$=async e=>(R(),await V(),(0,Q.jsx)(be,{onDone:e}))}))();export{$ as call};
@@ -0,0 +1,2 @@
1
+ import{n as e,o as t}from"./chunk-DR8-3Aex.js";import{Rn as n,b as r,p as i,t as a,tt as o,x as s}from"./src-Di342QoJ.js";import{t as c}from"./jsx-runtime-D-D469L8.js";import{t as l}from"./useKeybinding-FsOnjW6T.js";import{t as u}from"./lib-B4Q0Nrpb.js";function d({onDone:e}){let[t,n]=(0,m.useState)(`ios`),[a,c]=(0,m.useState)({ios:``,android:``}),{url:l}=g[t],u=a[t];(0,m.useEffect)(()=>{async function e(){let[e,t]=await Promise.all([(0,p.toString)(g.ios.url,{type:`utf8`,errorCorrectionLevel:`L`}),(0,p.toString)(g.android.url,{type:`utf8`,errorCorrectionLevel:`L`})]);c({ios:e,android:t})}e().catch(()=>{})},[]),o(`confirm:no`,(0,m.useCallback)(()=>{e()},[e]),{context:`Confirmation`});function d(t){if(t.key===`q`||t.ctrl&&t.key===`c`){t.preventDefault(),e();return}(t.key===`tab`||t.key===`left`||t.key===`right`)&&(t.preventDefault(),n(e=>e===`ios`?`android`:`ios`))}let f=u.split(`
2
+ `).filter(e=>e.length>0);return(0,h.jsx)(i,{children:(0,h.jsxs)(s,{flexDirection:`column`,tabIndex:0,autoFocus:!0,onKeyDown:d,children:[(0,h.jsx)(r,{children:` `}),(0,h.jsx)(r,{children:` `}),f.map((e,t)=>(0,h.jsx)(r,{children:e},t)),(0,h.jsx)(r,{children:` `}),(0,h.jsx)(r,{children:` `}),(0,h.jsxs)(s,{flexDirection:`row`,gap:2,children:[(0,h.jsxs)(r,{children:[(0,h.jsx)(r,{bold:t===`ios`,underline:t===`ios`,children:`iOS`}),(0,h.jsx)(r,{dimColor:!0,children:` / `}),(0,h.jsx)(r,{bold:t===`android`,underline:t===`android`,children:`Android`})]}),(0,h.jsx)(r,{dimColor:!0,children:`(tab to switch, esc to close)`})]}),(0,h.jsx)(r,{dimColor:!0,children:l})]})})}async function f(e){return(0,h.jsx)(d,{onDone:e})}var p,m,h,g;e((()=>{p=u(),n(),m=t(n(),1),a(),l(),h=c(),g={ios:{url:`https://apps.apple.com/app/claude-by-anthropic/id6473753684`},android:{url:`https://play.google.com/store/apps/details?id=com.anthropic.claude`}}}))();export{f as call};
@@ -0,0 +1 @@
1
+ import{n as e,o as t}from"./chunk-DR8-3Aex.js";import{Rn as n}from"./src-Di342QoJ.js";function r(){return(0,a.useContext)(o)!==null}function i(e){let t=(0,a.useContext)(o);return t?{rows:t.rows,columns:t.columns}:e}var a,o,s=e((()=>{a=t(n(),1),o=(0,a.createContext)(null)}));export{i,s as n,r,o as t};
@@ -0,0 +1 @@
1
+ import{n as e,o as t}from"./chunk-DR8-3Aex.js";import{In as n,Ln as r,Rn as i}from"./src-Di342QoJ.js";import{t as a}from"./jsx-runtime-D-D469L8.js";import{$r as o,Lr as s,Pr as c,Qr as l,Si as u,Vr as d,Xr as f,Zr as p,ui as m,vi as h,wr as g,xi as _,yi as v}from"./paths-Q2255dD7.js";import{n as y,r as b}from"./analytics-DqMQntaB.js";import{A as x,et as S,j as C}from"./log-CzsijfHZ.js";import{Df as w,Ef as T,Jg as E,MS as D,PS as O,Yg as k,jS as A,qg as j}from"./loadAgentsDir-Ci5mr0vm.js";import{i as M,n as N,r as P,t as F}from"./extraUsage-CfxgfpX_.js";function I({onDone:e}){let t=D(e=>e.mainLoopModel),r=D(e=>e.mainLoopModelForSession),i=D(e=>e.fastMode),a=O();function o(){b(`tengu_model_command_menu`,{action:`cancel`});let r=H(t);e(`Kept model as ${n.bold(r)}`,{display:`system`})}function c(r,o){b(`tengu_model_command_menu`,{action:r,from_model:t,to_model:r}),a(e=>({...e,mainLoopModel:r,mainLoopModelForSession:null}));let c=`Set model to ${n.bold(H(r))}`;o!==void 0&&(c+=` with ${n.bold(o)} effort`);let l;_()&&(m(),!u(r)&&i?(a(e=>({...e,fastMode:!1})),l=!1):u(r)&&v()&&i&&(c+=` · Fast mode ON`,l=!0)),N(r,l===!0,s())&&(c+=` · Billed as extra usage`),l===!1&&(c+=` · Fast mode OFF`),e(c)}return(0,W.jsx)(P,{initial:t,sessionModel:r,onSelect:c,onCancel:o,isStandaloneCommand:!0,showFastModeNotice:_()&&i&&u(t)&&v()})}function L({args:e,onDone:t}){let r=D(e=>e.fastMode),i=O(),a=e===`default`?null:e;return U.useEffect(()=>{async function e(){if(a&&!p(a)){t(`Model '${a}' is not available. Your organization restricts model selection.`,{display:`system`});return}if(a&&z(a)){t(`Opus 4.7 with 1M context is not available for your account. Learn more: https://code.claude.com/docs/en/model-config#extended-context-with-1m`,{display:`system`});return}if(a&&B(a)){t(`Sonnet 4.6 with 1M context is not available for your account. Learn more: https://code.claude.com/docs/en/model-config#extended-context-with-1m`,{display:`system`});return}if(!a){o(null);return}if(R(a)){o(a);return}try{let{valid:e,error:n}=await w(a);e?o(a):t(n||`Model '${a}' not found`,{display:`system`})}catch(e){t(`Failed to validate model: ${e.message}`,{display:`system`})}}function o(e){i(t=>({...t,mainLoopModel:e,mainLoopModelForSession:null}));let a=`Set model to ${n.bold(H(e))}`,o;_()&&(m(),!u(e)&&r?(i(e=>({...e,fastMode:!1})),o=!1):u(e)&&r&&(a+=` · Fast mode ON`,o=!0)),N(e,o===!0,s())&&(a+=` · Billed as extra usage`),o===!1&&(a+=` · Fast mode OFF`),t(a)}e()},[a,t,i]),null}function R(e){return l.includes(e.toLowerCase().trim())}function z(e){let t=e.toLowerCase();return!j()&&!s()&&t.includes(`opus`)&&t.includes(`[1m]`)}function B(e){let t=e.toLowerCase();return!E()&&(t.includes(`sonnet[1m]`)||t.includes(`sonnet-4-6[1m]`))}function V({onDone:e}){let t=D(e=>e.mainLoopModel),r=D(e=>e.mainLoopModelForSession),i=D(e=>e.effortValue),a=H(t),o=i===void 0?``:` (effort: ${i})`;return e(r?`Current model: ${n.bold(H(r))} (session override from plan mode)\nBase model: ${a}${o}`:`Current model: ${a}${o}`),null}function H(e){let t=d(e??g());return e===null?`${t} (default)`:t}var U,W,G;e((()=>{r(),U=t(i(),1),M(),S(),y(),A(),F(),h(),o(),k(),c(),f(),T(),W=a(),G=async(e,t,n)=>{if(n=n?.trim()||``,C.includes(n))return b(`tengu_model_command_inline_help`,{args:n}),(0,W.jsx)(V,{onDone:e});if(x.includes(n)){e(`Run /model to open the model selection menu, or /model [modelName] to set the model.`,{display:`system`});return}return n?(b(`tengu_model_command_inline`,{args:n}),(0,W.jsx)(L,{args:n,onDone:e})):(0,W.jsx)(I,{onDone:e})}}))();export{G as call};
@@ -0,0 +1 @@
1
+ import{Dr as e,Pr as t}from"./paths-Q2255dD7.js";t();export{e as getMainLoopModel};
@@ -0,0 +1 @@
1
+ import{n as e}from"./chunk-DR8-3Aex.js";function t(e){let t=e.replace(/[^a-zA-Z0-9_-]/g,`_`);return e.startsWith(n)&&(t=t.replace(/_+/g,`_`).replace(/^_|_$/g,``)),t}var n,r=e((()=>{n=`claude.ai `}));export{t as n,r as t};
@@ -0,0 +1 @@
1
+ import{n as e}from"./chunk-DR8-3Aex.js";import{s as t,u as n}from"./envUtils-BWeoiL4Y.js";function r(){if(process.env.USER_TYPE===`ant`){if(n(process.env.USE_LOCAL_OAUTH))return`local`;if(n(process.env.USE_STAGING_OAUTH))return`staging`}return`prod`}function i(){if(process.env.CLAUDE_CODE_CUSTOM_OAUTH_URL)return`-custom-oauth`;switch(r()){case`local`:return`-local-oauth`;case`staging`:return`-staging-oauth`;case`prod`:return``}}function a(){let e=process.env.CLAUDE_LOCAL_OAUTH_API_BASE?.replace(/\/$/,``)??`http://localhost:8000`,t=process.env.CLAUDE_LOCAL_OAUTH_APPS_BASE?.replace(/\/$/,``)??`http://localhost:4000`,n=process.env.CLAUDE_LOCAL_OAUTH_CONSOLE_BASE?.replace(/\/$/,``)??`http://localhost:3000`;return{BASE_API_URL:e,CONSOLE_AUTHORIZE_URL:`${n}/oauth/authorize`,CLAUDE_AI_AUTHORIZE_URL:`${t}/oauth/authorize`,CLAUDE_AI_ORIGIN:t,TOKEN_URL:`${e}/v1/oauth/token`,API_KEY_URL:`${e}/api/oauth/claude_cli/create_api_key`,ROLES_URL:`${e}/api/oauth/claude_cli/roles`,CONSOLE_SUCCESS_URL:`${n}/buy_credits?returnUrl=/oauth/code/success%3Fapp%3Dclaude-code`,CLAUDEAI_SUCCESS_URL:`${n}/oauth/code/success?app=claude-code`,MANUAL_REDIRECT_URL:`${n}/oauth/code/callback`,CLIENT_ID:`22422756-60c9-4084-8eb7-27705fd5cf9a`,OAUTH_FILE_SUFFIX:`-local-oauth`,MCP_PROXY_URL:`http://localhost:8205`,MCP_PROXY_PATH:`/v1/toolbox/shttp/mcp/{server_id}`}}function o(){let e=(()=>{switch(r()){case`local`:return a();case`staging`:return g??m;case`prod`:return m}})(),t=process.env.CLAUDE_CODE_CUSTOM_OAUTH_URL;if(t){let n=t.replace(/\/$/,``);if(!_.includes(n))throw Error(`CLAUDE_CODE_CUSTOM_OAUTH_URL is not an approved endpoint.`);e={...e,BASE_API_URL:n,CONSOLE_AUTHORIZE_URL:`${n}/oauth/authorize`,CLAUDE_AI_AUTHORIZE_URL:`${n}/oauth/authorize`,CLAUDE_AI_ORIGIN:n,TOKEN_URL:`${n}/v1/oauth/token`,API_KEY_URL:`${n}/api/oauth/claude_cli/create_api_key`,ROLES_URL:`${n}/api/oauth/claude_cli/roles`,CONSOLE_SUCCESS_URL:`${n}/oauth/code/success?app=claude-code`,CLAUDEAI_SUCCESS_URL:`${n}/oauth/code/success?app=claude-code`,MANUAL_REDIRECT_URL:`${n}/oauth/code/callback`,OAUTH_FILE_SUFFIX:`-custom-oauth`}}let n=process.env.CLAUDE_CODE_OAUTH_CLIENT_ID;return n&&(e={...e,CLIENT_ID:n}),e}var s,c,l,u,d,f,p,m,h,g,_,v=e((()=>{t(),s=`user:inference`,c=`user:profile`,l=`org:create_api_key`,u=`oauth-2025-04-20`,d=[l,c],f=[c,s,`user:sessions:claude_code`,`user:mcp_servers`,`user:file_upload`],p=Array.from(new Set([...d,...f])),m={BASE_API_URL:`https://api.anthropic.com`,CONSOLE_AUTHORIZE_URL:`https://platform.claude.com/oauth/authorize`,CLAUDE_AI_AUTHORIZE_URL:`https://claude.com/cai/oauth/authorize`,CLAUDE_AI_ORIGIN:`https://claude.ai`,TOKEN_URL:`https://platform.claude.com/v1/oauth/token`,API_KEY_URL:`https://api.anthropic.com/api/oauth/claude_cli/create_api_key`,ROLES_URL:`https://api.anthropic.com/api/oauth/claude_cli/roles`,CONSOLE_SUCCESS_URL:`https://platform.claude.com/buy_credits?returnUrl=/oauth/code/success%3Fapp%3Dclaude-code`,CLAUDEAI_SUCCESS_URL:`https://platform.claude.com/oauth/code/success?app=claude-code`,MANUAL_REDIRECT_URL:`https://platform.claude.com/oauth/code/callback`,CLIENT_ID:`9d1c250a-e61b-44d9-88ed-5944d1962f5e`,OAUTH_FILE_SUFFIX:``,MCP_PROXY_URL:`https://mcp-proxy.anthropic.com`,MCP_PROXY_PATH:`/v1/mcp/{server_id}`},h=`https://claude.ai/oauth/claude-code-client-metadata`,g=process.env.USER_TYPE===`ant`?{BASE_API_URL:`https://api-staging.anthropic.com`,CONSOLE_AUTHORIZE_URL:`https://platform.staging.ant.dev/oauth/authorize`,CLAUDE_AI_AUTHORIZE_URL:`https://claude-ai.staging.ant.dev/oauth/authorize`,CLAUDE_AI_ORIGIN:`https://claude-ai.staging.ant.dev`,TOKEN_URL:`https://platform.staging.ant.dev/v1/oauth/token`,API_KEY_URL:`https://api-staging.anthropic.com/api/oauth/claude_cli/create_api_key`,ROLES_URL:`https://api-staging.anthropic.com/api/oauth/claude_cli/roles`,CONSOLE_SUCCESS_URL:`https://platform.staging.ant.dev/buy_credits?returnUrl=/oauth/code/success%3Fapp%3Dclaude-code`,CLAUDEAI_SUCCESS_URL:`https://platform.staging.ant.dev/oauth/code/success?app=claude-code`,MANUAL_REDIRECT_URL:`https://platform.staging.ant.dev/oauth/code/callback`,CLIENT_ID:`22422756-60c9-4084-8eb7-27705fd5cf9a`,OAUTH_FILE_SUFFIX:`-staging-oauth`,MCP_PROXY_URL:`https://mcp-proxy-staging.anthropic.com`,MCP_PROXY_PATH:`/v1/mcp/{server_id}`}:void 0,_=[`https://beacon.claude-ai.staging.ant.dev`,`https://claude.fedstart.com`,`https://claude-staging.fedstart.com`]}));export{d as a,i as c,c as i,o as l,s as n,h as o,f as r,u as s,p as t,v as u};
@@ -0,0 +1 @@
1
+ import{l as e,u as t}from"./oauth-CdZEzMww.js";t();export{e as getOauthConfig};
@@ -0,0 +1,4 @@
1
+ import{n as e}from"./chunk-DR8-3Aex.js";import{dirname as t,join as n}from"node:path";import{createHash as r,randomUUID as i}from"node:crypto";import{mkdir as a,readFile as o,rename as s,stat as c,writeFile as l}from"node:fs/promises";function u(e){return e?.rootDir?e.rootDir:process.env.CLAUDE_SKILL_LEARNING_HOME?process.env.CLAUDE_SKILL_LEARNING_HOME:n(process.env.HOME??process.cwd(),`.claude`,`skill-learning`)}function d(e){let t=u(e),r=e?.project;return!r||r.scope===`global`||r.projectId===`global`?n(t,`global`,`observations.jsonl`):n(t,`projects`,r.projectId,`observations.jsonl`)}function f(e,t=D){if(e===void 0)return;let n=e;for(let e of j)n=n.replace(e,e=>{let t=e.split(/[:=]/,1)[0];return/[:=]/.test(e)?`${t}: ${A}`:A});if(n.length<=t)return n;let r=E(n),i=n.slice(0,t);return n.includes(A)&&!i.includes(A)&&(i=`${A} ${i}`),`${i}\n[TRUNCATED length=${n.length} sha256=${r}]`}function p(e,t){let n=t?.maxFieldLength??D,r={...e,toolInput:f(e.toolInput,n),toolOutput:f(e.toolOutput,n),messageText:f(e.messageText,n)},i=[r.event,r.toolName??``,r.toolInput??``,r.toolOutput??``,r.messageText??``].join(`
2
+ `);return{...r,contentHash:E(i)}}async function m(e,n){let r=d(n);await a(t(r),{recursive:!0}),await v(n);let i=p(e,n),o=JSON.stringify(i);return Buffer.byteLength(o)>M||await l(r,`${o}\n`,{flag:`a`}),i}async function h(e){let t=d(e),n=``;try{n=await o(t,`utf8`)}catch(e){if(e.code===`ENOENT`)return[];throw e}let r=[];for(let e of n.split(/\r?\n/))if(e.trim())try{r.push(JSON.parse(e))}catch{}return r}async function g(e,t){let n=await o(e,`utf8`),r=[];for(let e of n.split(/\r?\n/)){if(!e.trim())continue;let n=JSON.parse(e);for(let e of y(n,t))r.push(await m(e,t))}return r}async function _(e){let t=d(e),n=e?.maxAgeDays??k,r=Date.now()-n*24*60*60*1e3,i=``;try{i=await o(t,`utf8`)}catch(e){if(e.code===`ENOENT`)return 0;throw e}let a=[],c=0;for(let e of i.split(/\r?\n/))if(e.trim())try{let t=JSON.parse(e),n=Date.parse(t.timestamp);if(!Number.isNaN(n)&&n<r){c+=1;continue}a.push(e)}catch{a.push(e)}if(c===0)return 0;let u=`${t}.tmp-${process.pid}-${Date.now()}`;return await l(u,a.length?`${a.join(`
3
+ `)}\n`:``),await s(u,t),c}async function v(e){let r=d(e),i=e?.archiveThresholdBytes??O,o;try{o=await c(r)}catch(e){if(e.code===`ENOENT`)return null;throw e}if(o.size<i)return null;let l=n(t(r),`observations.archive`);await a(l,{recursive:!0});let u=n(l,`observations-${new Date().toISOString().replace(/[:.]/g,`-`)}.jsonl`);return await s(r,u),u}function y(e,t){let n=t?.project,r={sessionId:e.sessionId??`unknown-session`,projectId:n?.projectId??`global`,projectName:n?.projectName??`global`,cwd:e.cwd??n?.cwd??process.cwd(),timestamp:e.timestamp??new Date().toISOString(),source:`transcript`},i=e.message?.role??e.type,a=e.message?.content,o=[];if(e.tool_name&&o.push({...r,id:T(),event:`tool_complete`,toolName:e.tool_name,toolInput:w(e.tool_input),toolOutput:w(e.tool_response),outcome:C(e.tool_response)}),i===`user`){let e=S(a);if(e.length>0){for(let t of e)o.push({...r,id:T(),event:`tool_complete`,toolName:t.name,toolOutput:t.output,outcome:t.isError?`failure`:`success`});return o}return o.push({...r,id:T(),event:`user_message`,messageText:b(a)}),o}if(i===`assistant`){let e=x(a);for(let t of e)o.push({...r,id:T(),event:`tool_start`,toolName:t.name,toolInput:t.input});let t=b(a);t.trim()&&o.push({...r,id:T(),event:`assistant_message`,messageText:t})}return o}function b(e){return typeof e==`string`?e:Array.isArray(e)?e.map(e=>{if(typeof e==`string`)return e;if(!e||typeof e!=`object`)return``;let t=e;return typeof t.text==`string`?t.text:``}).filter(Boolean).join(`
4
+ `):w(e)??``}function x(e){return Array.isArray(e)?e.flatMap(e=>{if(!e||typeof e!=`object`)return[];let t=e;return t.type===`tool_use`?[{name:String(t.name??`unknown_tool`),input:w(t.input)}]:[]}):[]}function S(e){return Array.isArray(e)?e.flatMap(e=>{if(!e||typeof e!=`object`)return[];let t=e;return t.type===`tool_result`?[{name:String(t.name??t.tool_name??`unknown_tool`),output:w(t.content),isError:t.is_error===!0}]:[]}):[]}function C(e){let t=w(e)?.toLowerCase()??``;return t.includes(`interrupted`)||t.includes(`aborted`)?`interrupted`:t.includes(`error`)||t.includes(`exception`)||t.includes(`failed`)?`failure`:`success`}function w(e){if(e!=null)return typeof e==`string`?e:JSON.stringify(e)}function T(){return typeof crypto<`u`&&`randomUUID`in crypto?crypto.randomUUID():i()}function E(e){return r(`sha256`).update(e).digest(`hex`)}var D,O,k,A,j,M,N=e((()=>{D=5e3,O=1e6,k=30,A=`[REDACTED]`,j=[/\b(?:sk|sk-ant|sk-proj|xox[baprs])-[A-Za-z0-9_-]{12,}\b/g,/\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g,/\b(?:api[_-]?key|token|secret|password|authorization)\b\s*[:=]\s*["']?[^"',\s}]+/gi,/\bBearer\s+[A-Za-z0-9._~+/=-]{12,}\b/gi],M=64*1024}));export{_ as a,f as c,N as i,w as l,u as n,h as o,g as r,p as s,m as t};
@@ -0,0 +1 @@
1
+ import{cn as e,tr as t}from"./state-sIHsFpDu.js";import{Ac as n,Is as r,It as i,Lt as a,Ns as o,Pc as s,Rt as c,Sc as l,Vs as u,on as d}from"./paths-Q2255dD7.js";import{K as f,V as p}from"./debug-UI3T040K.js";import{o as m,s as h}from"./log-CzsijfHZ.js";import{_a as g,ya as _}from"./loadAgentsDir-Ci5mr0vm.js";import{d as v,m as y,p as b}from"./rcDebugLog-BbPkkigY.js";e(),d(),n(),p(),m(),_(),o(),v();function x(e){return t=>({...t,...typeof e.permission_mode==`string`?{toolPermissionContext:{...t.toolPermissionContext,mode:r(e.permission_mode)}}:{},...typeof e.is_ultraplan_mode==`boolean`?{isUltraplanMode:e.is_ultraplan_mode}:{}})}function S({newState:e,oldState:n}){let r=n.toolPermissionContext.mode,o=e.toolPermissionContext.mode;if(r!==o){let t=u(r),i=u(o);t!==i&&y({permission_mode:i,is_ultraplan_mode:i===`plan`&&e.isUltraplanMode&&!n.isUltraplanMode?!0:null}),b(o)}if(e.mainLoopModel!==n.mainLoopModel&&t(e.mainLoopModel),e.expandedView!==n.expandedView){let t=e.expandedView===`tasks`,n=e.expandedView===`teammates`;(l().showExpandedTodos!==t||l().showSpinnerTree!==n)&&s(e=>({...e,showExpandedTodos:t,showSpinnerTree:n}))}if(e.verbose!==n.verbose&&l().verbose!==e.verbose){let t=e.verbose;s(e=>({...e,verbose:t}))}if(process.env.USER_TYPE===`ant`&&e.tungstenPanelVisible!==n.tungstenPanelVisible&&e.tungstenPanelVisible!==void 0&&l().tungstenPanelVisible!==e.tungstenPanelVisible){let t=e.tungstenPanelVisible;s(e=>({...e,tungstenPanelVisible:t}))}if(e.settings!==n.settings)try{i(),a(),c(),e.settings.env!==n.settings.env&&g()}catch(e){h(f(e))}}export{S as n,x as t};
@@ -0,0 +1 @@
1
+ import{n as e}from"./chunk-DR8-3Aex.js";import{promisify as t}from"node:util";import n from"node:process";import r from"node:path";import i,{execFile as a}from"node:child_process";import o from"node:fs";import s from"node:os";import c,{constants as l}from"node:fs/promises";import{fileURLToPath as u}from"node:url";import{Buffer as d}from"node:buffer";function ee(){try{return o.statSync(`/.dockerenv`),!0}catch{return!1}}function te(){try{return o.readFileSync(`/proc/self/cgroup`,`utf8`).includes(`docker`)}catch{return!1}}function f(){return p===void 0&&(p=ee()||te()),p}var p,ne=e((()=>{}));function m(){return h===void 0&&(h=g()||f()),h}var h,g,_=e((()=>{ne(),g=()=>{try{return o.statSync(`/run/.containerenv`),!0}catch{return!1}}})),v,y,b=e((()=>{_(),v=()=>{if(n.platform!==`linux`)return!1;if(s.release().toLowerCase().includes(`microsoft`))return!m();try{if(o.readFileSync(`/proc/version`,`utf8`).toLowerCase().includes(`microsoft`))return!m()}catch{}return o.existsSync(`/proc/sys/fs/binfmt_misc/WSLInterop`)||o.existsSync(`/run/WSL`)?!m():!1},y=n.env.__IS_WSL_TEST__?v:v()})),x,S,C,re=e((()=>{b(),x=(()=>{let e=`/mnt/`,t;return async function(){if(t)return t;let n=`/etc/wsl.conf`,r=!1;try{await c.access(n,l.F_OK),r=!0}catch{}if(!r)return e;let i=await c.readFile(n,{encoding:`utf8`}),a=/(?<!#.*)root\s*=\s*(?<mountPoint>.*)/g.exec(i);return a?(t=a.groups.mountPoint.trim(),t=t.endsWith(`/`)?t:`${t}/`,t):e}})(),S=async()=>`${await x()}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`,C=async()=>y?S():`${n.env.SYSTEMROOT||n.env.windir||String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`}));function w(e,t,n){let r=n=>Object.defineProperty(e,t,{value:n,enumerable:!0,writable:!0});return Object.defineProperty(e,t,{configurable:!0,enumerable:!0,get(){let e=n();return r(e),e},set(e){r(e)}}),e}var T=e((()=>{}));async function E(){if(n.platform!==`darwin`)throw Error(`macOS only`);let{stdout:e}=await D(`defaults`,[`read`,`com.apple.LaunchServices/com.apple.launchservices.secure`,`LSHandlers`]),t=/LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(e)?.groups.id??`com.apple.Safari`;return t===`com.apple.safari`?`com.apple.Safari`:t}var D,O=e((()=>{D=t(a)}));async function k(e,{humanReadableOutput:t=!0,signal:r}={}){if(n.platform!==`darwin`)throw Error(`macOS only`);let i=t?[]:[`-ss`],a={};r&&(a.signal=r);let{stdout:o}=await A(`osascript`,[`-e`,e,i],a);return o.trim()}var A,j=e((()=>{A=t(a)}));async function M(e){return k(`tell application "Finder" to set app_path to application file id "${e}" as string\ntell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`)}var N=e((()=>{j()}));async function P(e=F){let{stdout:t}=await e(`reg`,[`QUERY`,` HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice`,`/v`,`ProgId`]),n=/ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(t);if(!n)throw new L(`Cannot find Windows browser in stdout: ${JSON.stringify(t)}`);let{id:r}=n.groups,i=r.lastIndexOf(`.`),a=r.lastIndexOf(`-`),o=i===-1?void 0:r.slice(0,i),s=a===-1?void 0:r.slice(0,a);return I[r]??I[o]??I[s]??{name:r,id:r}}var F,I,L,R=e((()=>{F=t(a),I={MSEdgeHTM:{name:`Edge`,id:`com.microsoft.edge`},MSEdgeBHTML:{name:`Edge Beta`,id:`com.microsoft.edge.beta`},MSEdgeDHTML:{name:`Edge Dev`,id:`com.microsoft.edge.dev`},AppXq0fevzme2pys62n3e0fbqa7peapykr8v:{name:`Edge`,id:`com.microsoft.edge.old`},ChromeHTML:{name:`Chrome`,id:`com.google.chrome`},ChromeBHTML:{name:`Chrome Beta`,id:`com.google.chrome.beta`},ChromeDHTML:{name:`Chrome Dev`,id:`com.google.chrome.dev`},ChromiumHTM:{name:`Chromium`,id:`org.chromium.Chromium`},BraveHTML:{name:`Brave`,id:`com.brave.Browser`},BraveBHTML:{name:`Brave Beta`,id:`com.brave.Browser.beta`},BraveDHTML:{name:`Brave Dev`,id:`com.brave.Browser.dev`},BraveSSHTM:{name:`Brave Nightly`,id:`com.brave.Browser.nightly`},FirefoxURL:{name:`Firefox`,id:`org.mozilla.firefox`},OperaStable:{name:`Opera`,id:`com.operasoftware.Opera`},VivaldiHTM:{name:`Vivaldi`,id:`com.vivaldi.Vivaldi`},"IE.HTTP":{name:`Internet Explorer`,id:`com.microsoft.ie`}},new Map(Object.entries(I)),L=class extends Error{}}));async function z(){if(n.platform===`darwin`){let e=await E();return{name:await M(e),id:e}}if(n.platform===`linux`){let{stdout:e}=await B(`xdg-mime`,[`query`,`default`,`x-scheme-handler/http`]),t=e.trim();return{name:V(t.replace(/.desktop$/,``).replace(`-`,` `)),id:t}}if(n.platform===`win32`)return P();throw Error(`Only macOS, Linux, and Windows are supported`)}var B,V,H=e((()=>{O(),N(),R(),B=t(a),V=e=>e.toLowerCase().replaceAll(/(?:^|\s|-)\S/g,e=>e.toUpperCase())}));async function ie(){let e=await C(),t=String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`,{stdout:n}=await G(e,[`-NoProfile`,`-NonInteractive`,`-ExecutionPolicy`,`Bypass`,`-EncodedCommand`,d.from(t,`utf16le`).toString(`base64`)],{encoding:`utf8`}),r=n.trim(),i={ChromeHTML:`com.google.chrome`,BraveHTML:`com.brave.Browser`,MSEdgeHTM:`com.microsoft.edge`,FirefoxURL:`org.mozilla.firefox`};return i[r]?{id:i[r]}:{}}function U(e){if(typeof e==`string`||Array.isArray(e))return e;let{[Y]:t}=e;if(!t)throw Error(`${Y} is not supported`);return t}function W({[J]:e},{wsl:t}){if(t&&y)return U(t);if(!e)throw Error(`${J} is not supported`);return U(e)}var G,K,q,J,Y,X,Z,Q,$;e((()=>{re(),T(),H(),_(),G=t(i.execFile),K=r.dirname(u(import.meta.url)),q=r.join(K,`xdg-open`),{platform:J,arch:Y}=n,X=async(e,t)=>{let n;for(let r of e)try{return await t(r)}catch(e){n=e}throw n},Z=async e=>{if(e={wait:!1,background:!1,newInstance:!1,allowNonzeroExitCode:!1,...e},Array.isArray(e.app))return X(e.app,t=>Z({...e,app:t}));let{name:t,arguments:r=[]}=e.app??{};if(r=[...r],Array.isArray(t))return X(t,t=>Z({...e,app:{name:t,arguments:r}}));if(t===`browser`||t===`browserPrivate`){let n={"com.google.chrome":`chrome`,"google-chrome.desktop":`chrome`,"com.brave.Browser":`brave`,"org.mozilla.firefox":`firefox`,"firefox.desktop":`firefox`,"com.microsoft.msedge":`edge`,"com.microsoft.edge":`edge`,"com.microsoft.edgemac":`edge`,"microsoft-edge.desktop":`edge`},i={chrome:`--incognito`,brave:`--incognito`,firefox:`--private-window`,edge:`--inPrivate`},a=y?await ie():await z();if(a.id in n){let o=n[a.id];return t===`browserPrivate`&&r.push(i[o]),Z({...e,app:{name:$[o],arguments:r}})}throw Error(`${a.name} is not supported as a default browser`)}let a,o=[],s={};if(J===`darwin`)a=`open`,e.wait&&o.push(`--wait-apps`),e.background&&o.push(`--background`),e.newInstance&&o.push(`--new`),t&&o.push(`-a`,t);else if(J===`win32`||y&&!m()&&!t){a=await C(),o.push(`-NoProfile`,`-NonInteractive`,`-ExecutionPolicy`,`Bypass`,`-EncodedCommand`),y||(s.windowsVerbatimArguments=!0);let n=[`Start`];e.wait&&n.push(`-Wait`),t?(n.push(`"\`"${t}\`""`),e.target&&r.push(e.target)):e.target&&n.push(`"${e.target}"`),r.length>0&&(r=r.map(e=>`"\`"${e}\`""`),n.push(`-ArgumentList`,r.join(`,`))),e.target=d.from(n.join(` `),`utf16le`).toString(`base64`)}else{if(t)a=t;else{let e=!K||K===`/`,t=!1;try{await c.access(q,l.X_OK),t=!0}catch{}a=n.versions.electron??(J===`android`||e||!t)?`xdg-open`:q}r.length>0&&o.push(...r),e.wait||(s.stdio=`ignore`,s.detached=!0)}J===`darwin`&&r.length>0&&o.push(`--args`,...r),e.target&&o.push(e.target);let u=i.spawn(a,o,s);return e.wait?new Promise((t,n)=>{u.once(`error`,n),u.once(`close`,r=>{if(!e.allowNonzeroExitCode&&r>0){n(Error(`Exited with code ${r}`));return}t(u)})}):(u.unref(),u)},Q=(e,t)=>{if(typeof e!=`string`)throw TypeError("Expected a `target`");return Z({...t,target:e})},$={},w($,`chrome`,()=>W({darwin:`google chrome`,win32:`chrome`,linux:[`google-chrome`,`google-chrome-stable`,`chromium`]},{wsl:{ia32:`/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe`,x64:[`/mnt/c/Program Files/Google/Chrome/Application/chrome.exe`,`/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe`]}})),w($,`brave`,()=>W({darwin:`brave browser`,win32:`brave`,linux:[`brave-browser`,`brave`]},{wsl:{ia32:`/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe`,x64:[`/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe`,`/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe`]}})),w($,`firefox`,()=>W({darwin:`firefox`,win32:String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,linux:`firefox`},{wsl:`/mnt/c/Program Files/Mozilla Firefox/firefox.exe`})),w($,`edge`,()=>W({darwin:`microsoft edge`,win32:`msedge`,linux:[`microsoft-edge`,`microsoft-edge-dev`]},{wsl:`/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe`})),w($,`browser`,()=>`browser`),w($,`browserPrivate`,()=>`browserPrivate`)}))();export{Q as default};
@@ -0,0 +1,10 @@
1
+ import{n as e}from"./chunk-DR8-3Aex.js";import{l as t,s as n,u as r}from"./envUtils-BWeoiL4Y.js";import{ai as i,ci as a,cr as o,dr as s}from"./paths-Q2255dD7.js";import{d as c,s as l}from"./debug-UI3T040K.js";import{o as u,u as d}from"./proxy-CfZp-wce.js";import{AT as ee,Ko as f,Lo as p,NE as m,OT as h,PE as te,Wo as g,Xc as _,Yc as v,Zc as y,__ as b,_m as x,bo as S,co as C,g_ as ne,h_ as w,kT as T,pm as E,st as D,ut as O,v_ as k}from"./loadAgentsDir-Ci5mr0vm.js";import{Bn as A,Hn as re,Vn as j,i as ie,r as M,t as N}from"./prompt-DEPUnJdB.js";import{F as ae,I as P,L as F,P as I,R as L,Y as R}from"./rcDebugLog-BbPkkigY.js";import{r as z,t as B}from"./store-DhI7Lcan.js";import{i as V,n as H,r as U,t as W}from"./openaiShared-D5lOejS1.js";import{randomUUID as G}from"crypto";function K(e){if(!e)return 0;let t=0,n=/(\d+(?:\.\d+)?)(ms|s|m|h|d)/g,r;for(;(r=n.exec(e))!==null;){let e=Number(r[1]);switch(r[2]){case`ms`:t+=e/1e3;break;case`s`:t+=e;break;case`m`:t+=e*60;break;case`h`:t+=e*3600;break;case`d`:t+=e*86400;break}}if(t===0){let n=Number(e);Number.isFinite(n)&&(t=n)}return t<=0?0:Math.floor(Date.now()/1e3)+t}function q(e,t){if(e===null||t===null)return null;let n=Number(e),r=Number(t);if(!Number.isFinite(n)||!Number.isFinite(r)||r<=0)return null;let i=Math.max(0,r-n);return Math.min(1,Math.max(0,i/r))}var J,oe=e((()=>{J={providerId:`openai`,parseHeaders(e){let t=[],n=q(e.get(`x-ratelimit-remaining-requests`),e.get(`x-ratelimit-limit-requests`));n!==null&&t.push({kind:`requests`,label:`RPM`,utilization:n,resetsAt:K(e.get(`x-ratelimit-reset-requests`))||void 0});let r=q(e.get(`x-ratelimit-remaining-tokens`),e.get(`x-ratelimit-limit-tokens`));return r!==null&&t.push({kind:`tokens`,label:`TPM`,utilization:r,resetsAt:K(e.get(`x-ratelimit-reset-tokens`))||void 0}),t}}}));function se(e){return async(...t)=>{let n=await e(...t);try{z(`openai`,J.parseHeaders(n.headers))}catch{}return n}}function ce(e){if(Y)return Y;let t=process.env.OPENAI_API_KEY||``,n=process.env.OPENAI_BASE_URL,r=se(e?.fetchOverride??globalThis.fetch),i=new V({apiKey:t,...n&&{baseURL:n},maxRetries:e?.maxRetries??0,timeout:parseInt(process.env.API_TIMEOUT_MS||`600000`,10),dangerouslyAllowBrowser:!0,...process.env.OPENAI_ORG_ID&&{organization:process.env.OPENAI_ORG_ID},...process.env.OPENAI_PROJECT_ID&&{project:process.env.OPENAI_PROJECT_ID},fetchOptions:u({forAnthropicAPI:!1}),fetch:r});return e?.fetchOverride||(Y=i),i}var Y,le=e((()=>{U(),oe(),B(),d(),Y=null}));function X(e){return typeof e==`string`?e:Array.isArray(e)?e.map(e=>{if(!e||typeof e!=`object`)return``;let t=e;return typeof t.text==`string`?t.text:``}).filter(Boolean).join(`
2
+ `):``}function ue(e){if(typeof e==`string`)return e;if(!Array.isArray(e))return X(e);let t=[];for(let n of e){if(!n||typeof n!=`object`)continue;let e=n;if(e.type===`text`&&typeof e.text==`string`)t.push({type:`input_text`,text:e.text});else if(e.type===`image_url`){let n=e.image_url;typeof n?.url==`string`&&t.push({type:`input_image`,image_url:n.url})}}return t.length>0?t:X(e)}function de(e){let t=[],n=[];for(let r of e){if(!r||typeof r!=`object`)continue;let e=r,i=e.role;if(i===`system`||i===`developer`){let t=X(e.content);t&&n.push(t);continue}if(i===`tool`){let n=e.tool_call_id;typeof n==`string`&&t.push({type:`function_call_output`,call_id:n,output:X(e.content)});continue}if(i===`assistant`){let n=X(e.content);n&&t.push({role:`assistant`,content:n});let r=e.tool_calls;if(Array.isArray(r))for(let e of r){if(!e||typeof e!=`object`)continue;let n=e,r=n.function,i=typeof n.id==`string`?n.id:void 0,a=typeof r?.name==`string`?r.name:void 0;!i||!a||t.push({type:`function_call`,call_id:i,name:a,arguments:typeof r?.arguments==`string`?r.arguments:`{}`})}continue}i===`user`&&t.push({role:`user`,content:ue(e.content)})}return{input:t,instructions:n.length>0?n.join(`
3
+
4
+ `):void 0}}function fe(e){let t=[];for(let n of e){if(!n||typeof n!=`object`)continue;let e=n.function,r=typeof e?.name==`string`?e.name:void 0;r&&t.push({type:`function`,name:r,description:typeof e?.description==`string`?e.description:``,parameters:e?.parameters&&typeof e.parameters==`object`?e.parameters:{type:`object`,properties:{}},strict:!1})}return t}function pe(e){if(e===`required`)return`required`;if(e===`auto`)return`auto`;if(!e||typeof e!=`object`)return e;let t=e,n=t.function;return t.type===`function`&&typeof n?.name==`string`?{type:`function`,name:n.name}:e}function me(e){let{input:t,instructions:n}=de(e.messages),r=fe(e.tools);return{model:e.model,stream:!0,store:!1,input:t,...n?{instructions:n}:{},...r.length>0?{tools:r}:{},...e.toolChoice?{tool_choice:pe(e.toolChoice)}:{},...e.reasoningEffort?{reasoning:{effort:e.reasoningEffort}}:{},parallel_tool_calls:!0}}async function*he(e){if(!e.body)throw Error(`ChatGPT response did not include a body`);let t=e.body.getReader(),n=new TextDecoder,r=``;for(;;){let{done:e,value:i}=await t.read();if(e)break;r+=n.decode(i,{stream:!0});let a=r.indexOf(`
5
+
6
+ `);for(;a>=0;){let e=r.slice(0,a);r=r.slice(a+2);let t=e.split(/\r?\n/).filter(e=>e.startsWith(`data:`)).map(e=>e.slice(5).trimStart()).join(`
7
+ `);if(t&&t!==`[DONE]`){let e=JSON.parse(t);e&&typeof e==`object`&&(yield e)}a=r.indexOf(`
8
+
9
+ `)}}}function ge(e){let t=e?.usage,n=t?.input_tokens_details;return{input_tokens:typeof t?.input_tokens==`number`?t.input_tokens:0,output_tokens:typeof t?.output_tokens==`number`?t.output_tokens:0,cache_creation_input_tokens:0,cache_read_input_tokens:typeof n?.cached_tokens==`number`?n.cached_tokens:0}}function _e(e){return e?.status===`incomplete`?`max_tokens`:`end_turn`}async function*ve(e,t){let n=`msg_${G().replace(/-/g,``).slice(0,24)}`,r=new Map,i=!1,a=-1,o=!1,s=!1,c=async function*(){i||(i=!0,yield{type:`message_start`,message:{id:n,type:`message`,role:`assistant`,content:[],model:t,stop_reason:null,stop_sequence:null,usage:{input_tokens:0,output_tokens:0,cache_creation_input_tokens:0,cache_read_input_tokens:0}}})};for await(let t of e){for await(let e of c())yield e;let e=t.type;if(e===`response.output_text.delta`){o||(s&&(yield{type:`content_block_stop`,index:a},s=!1),a++,o=!0,yield{type:`content_block_start`,index:a,content_block:{type:`text`,text:``}}),yield{type:`content_block_delta`,index:a,delta:{type:`text_delta`,text:String(t.delta??``)}};continue}if(e===`response.reasoning_text.delta`){s||(o&&(yield{type:`content_block_stop`,index:a},o=!1),a++,s=!0,yield{type:`content_block_start`,index:a,content_block:{type:`thinking`,thinking:``,signature:``}}),yield{type:`content_block_delta`,index:a,delta:{type:`thinking_delta`,thinking:String(t.delta??``)}};continue}if(e===`response.output_item.added`){let e=t.item,n=typeof t.output_index==`number`?t.output_index:-1;if(e?.type===`function_call`&&n>=0){o&&(yield{type:`content_block_stop`,index:a},o=!1),s&&(yield{type:`content_block_stop`,index:a},s=!1),a++;let t=String(e.call_id??e.id??`call_${n}`),i=String(e.name??``);r.set(n,{contentIndex:a,open:!0,name:i,id:t}),yield{type:`content_block_start`,index:a,content_block:{type:`tool_use`,id:t,name:i,input:{}}}}continue}if(e===`response.function_call_arguments.delta`){let e=typeof t.output_index==`number`?t.output_index:-1,n=r.get(e);n&&(yield{type:`content_block_delta`,index:n.contentIndex,delta:{type:`input_json_delta`,partial_json:String(t.delta??``)}});continue}if(e===`response.output_item.done`){let e=typeof t.output_index==`number`?t.output_index:-1,n=r.get(e);n?.open&&(yield{type:`content_block_stop`,index:n.contentIndex},n.open=!1);continue}if(e===`response.error`){let e=t.error;throw Error(String(e?.message??`ChatGPT Responses API error`))}if(e===`response.failed`){let e=t.response?.error;throw Error(String(e?.message??`ChatGPT Responses API failed`))}if(e===`response.completed`||e===`response.incomplete`){o&&(yield{type:`content_block_stop`,index:a},o=!1),s&&(yield{type:`content_block_stop`,index:a},s=!1);let e=t.response;yield{type:`message_delta`,delta:{stop_reason:_e(e),stop_sequence:null},usage:ge(e)},yield{type:`message_stop`}}}}async function ye(e){let t=await h(),n=e.fetchOverride??globalThis.fetch,r={Authorization:`Bearer ${t.accessToken}`,"Content-Type":`application/json`,Accept:`text/event-stream`,"OpenAI-Beta":`responses=experimental`,Origin:`https://chatgpt.com`,Referer:`https://chatgpt.com/`,originator:`claude-code-best`};t.accountId&&(r[`ChatGPT-Account-Id`]=t.accountId);let i=await n(`https://chatgpt.com/backend-api/codex/responses`,{method:`POST`,headers:r,body:JSON.stringify(e.request),signal:e.signal});if(!i.ok){let e=await i.text().catch(()=>``);throw Error(`ChatGPT Responses API request failed (${i.status})${e?`: ${e.slice(0,500)}`:``}`)}return he(i)}var be=e((()=>{T()}));function xe(e){if(t(process.env.OPENAI_ENABLE_THINKING))return!1;if(r(process.env.OPENAI_ENABLE_THINKING))return!0;let n=e.toLowerCase();return n.includes(`deepseek`)||n.includes(`mimo`)}function Se(e,t){return t??(process.env.OPENAI_MAX_TOKENS&&parseInt(process.env.OPENAI_MAX_TOKENS,10)||void 0)??(process.env.CLAUDE_CODE_MAX_OUTPUT_TOKENS&&parseInt(process.env.CLAUDE_CODE_MAX_OUTPUT_TOKENS,10)||void 0)??e}function Z(e){let{model:t,messages:n,tools:r,toolChoice:i,enableThinking:a,maxTokens:o,temperatureOverride:s}=e;return{model:t,messages:n,max_tokens:o,...r.length>0&&{tools:r,...i&&{tool_choice:i}},stream:!0,stream_options:{include_usage:!0},...a&&{thinking:{type:`enabled`},enable_thinking:!0,chat_template_kwargs:{thinking:!0,enable_thinking:!0}},...!a&&s!==void 0&&{temperature:s}}}var Ce=e((()=>{n()}));function Q(e){if(e===`low`)return`low`;if(e===`medium`)return`medium`;if(e===`high`)return`high`;if(e===`xhigh`||e===`max`)return`xhigh`;if(typeof e==`number`)return`high`}function we(e){let t=process.env.CLAUDE_CODE_EFFORT_LEVEL?.toLowerCase();if(!(t===`auto`||t===`unset`))return Q(t)??Q(e)??`medium`}function Te(e,t,n,r){if(!r||_())return e;let i=t.filter(e=>n.has(e.name)).map(N).sort().join(`
10
+ `);return i?[S({content:`<available-deferred-tools>\n${i}\n</available-deferred-tools>`,isMeta:!0}),...e]:e}function Ee(e){return e.type===`assistant`||e.type===`user`}function $(e){let{partialMessage:t,contentBlocks:n,tools:r,agentId:i,usage:a,stopReason:o,maxTokens:s}=e,c=[],l=Object.keys(n).sort((e,t)=>Number(e)-Number(t)).map(e=>n[Number(e)]).filter(Boolean);return l.length>0&&c.push({message:{...t,content:g(l,r,i),usage:a,stop_reason:o,stop_sequence:null},requestId:void 0,type:`assistant`,uuid:G(),timestamp:new Date().toISOString()}),o===`max_tokens`&&c.push(C({content:`Output truncated: response exceeded the ${s} token limit. Set OPENAI_MAX_TOKENS or CLAUDE_CODE_MAX_OUTPUT_TOKENS to override.`,apiError:`max_output_tokens`,error:`max_output_tokens`})),c}async function*De(e,t,n,r,a){try{let s=R(a.model),l=f(e,n),u=await y(a.model,n,a.getToolPermissionContext||(async()=>A()),a.agents||[],a.querySource),d=new Set;if(u)for(let e of n)ie(e)&&d.add(e.name);let p=n;u&&d.size>0&&(p=n.filter(e=>!!(!d.has(e.name)||re(e,`SearchExtraTools`))));let m=await Promise.all(p.map(e=>O(e,{getToolPermissionContext:a.getToolPermissionContext,tools:n,agents:a.agents,allowedAgentTypes:a.allowedAgentTypes,model:a.model,deferLoading:u&&d.has(e.name)}))),h=m.filter(e=>{let t=e;return t.type!==`advisor_20260301`&&t.type!==`computer_20250124`}),g=xe(s),_=L(Te(l.filter(Ee),n,d,u),t,{enableThinking:g}),v=F(h),x=P(a.toolChoice),S=we(a.effortValue);if(u){let e=p.filter(e=>d.has(e.name)).length;c(`[OpenAI] Tool search enabled: ${e}/${d.size} deferred tools included, total tools=${v.length}`)}else c(`[OpenAI] Tool search disabled, total tools=${v.length}`);let{upperLimit:C}=o(s),T=Se(C,a.maxOutputTokensOverride);c(`[OpenAI] Calling model=${s}, messages=${_.length}, tools=${v.length}, thinking=${g}`);let D=ee()?ve(await ye({request:me({model:s,messages:_,tools:v,toolChoice:x,reasoningEffort:S}),signal:r,fetchOverride:a.fetchOverride}),s):ae(await ce({maxRetries:0,fetchOverride:a.fetchOverride,source:a.querySource}).chat.completions.create(Z({model:s,messages:_,tools:v,toolChoice:x,enableThinking:g,maxTokens:T,temperatureOverride:a.temperatureOverride}),{signal:r}),s),k={},j=[],M,N=null,I={input_tokens:0,output_tokens:0,cache_creation_input_tokens:0,cache_read_input_tokens:0},z=0,B=Date.now();for await(let e of D){switch(e.type){case`message_start`:M=e.message,z=Date.now()-B,e.message?.usage&&(I={...I,...e.message.usage});break;case`content_block_start`:{let t=e.index,n=e.content_block;n.type===`tool_use`?k[t]={...n,input:``}:n.type===`text`?k[t]={...n,text:``}:n.type===`thinking`?k[t]={...n,thinking:``,signature:``}:k[t]={...n};break}case`content_block_delta`:{let t=e.index,n=e.delta,r=k[t];if(!r)break;n.type===`text_delta`?r.text=(r.text||``)+n.text:n.type===`input_json_delta`?r.input=(r.input||``)+n.partial_json:n.type===`thinking_delta`?r.thinking=(r.thinking||``)+n.thinking:n.type===`signature_delta`&&(r.signature=n.signature);break}case`content_block_stop`:break;case`message_delta`:{let t=e.usage;t&&(I=H(I,t)),e.delta?.stop_reason!=null&&(N=e.delta.stop_reason);break}case`message_stop`:if(M){for(let e of $({partialMessage:M,contentBlocks:k,tools:n,agentId:a.agentId,usage:I,stopReason:N,maxTokens:T}))e.type===`assistant`&&j.push(e),yield e;M=null}I.input_tokens+I.output_tokens>0&&E(i(s,I),I,a.model);break}yield{type:`stream_event`,event:e,...e.type===`message_start`?{ttftMs:z}:void 0}}if(te(a.langfuseTrace??null,{model:s,provider:`openai`,input:w(_),output:ne(j),usage:{input_tokens:I.input_tokens,output_tokens:I.output_tokens,cache_creation_input_tokens:I.cache_creation_input_tokens,cache_read_input_tokens:I.cache_read_input_tokens},startTime:new Date(B),endTime:new Date,completionStartTime:z>0?new Date(B+z):void 0,tools:b(m),...g&&{thinking:{type:`enabled`}}}),M)for(let e of $({partialMessage:M,contentBlocks:k,tools:n,agentId:a.agentId,usage:I,stopReason:N,maxTokens:T}))yield e}catch(e){let t=e instanceof Error?e.message:String(e);c(`[OpenAI] Error: ${t}`,{level:`error`}),yield C({content:`API Error: ${t}`,apiError:`api_error`,error:e instanceof Error?e:Error(String(e))})}}e((()=>{le(),W(),I(),T(),be(),p(),D(),j(),l(),x(),a(),Ce(),m(),k(),s(),v(),M()}))();export{De as queryModelOpenAI};
@@ -0,0 +1,16 @@
1
+ import{n as e}from"./chunk-DR8-3Aex.js";function t(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n}function n(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)}var r=e((()=>{})),i,a=e((()=>{i=function(){let{crypto:e}=globalThis;if(e?.randomUUID)return i=e.randomUUID.bind(e),e.randomUUID();let t=new Uint8Array(1),n=e?()=>e.getRandomValues(t)[0]:()=>Math.random()*255&255;return`10000000-1000-4000-8000-100000000000`.replace(/[018]/g,e=>(e^n()&15>>e/4).toString(16))}}));function o(e){return typeof e==`object`&&!!e&&(`name`in e&&e.name===`AbortError`||`message`in e&&String(e.message).includes(`FetchRequestCanceledException`))}var s,c=e((()=>{s=e=>{if(e instanceof Error)return e;if(typeof e==`object`&&e){try{if(Object.prototype.toString.call(e)===`[object Error]`){let t=Error(e.message,e.cause?{cause:e.cause}:{});return e.stack&&(t.stack=e.stack),e.cause&&!t.cause&&(t.cause=e.cause),e.name&&(t.name=e.name),t}}catch{}try{return Error(JSON.stringify(e))}catch{}}return Error(e)}})),l,u,d,f,p,m,h,g,_,v,y,ee,b,te,x,S,ne,re,C=e((()=>{c(),l=class extends Error{},u=class e extends l{constructor(t,n,r,i){super(`${e.makeMessage(t,n,r)}`),this.status=t,this.headers=i,this.requestID=i?.get(`x-request-id`),this.error=n;let a=n;this.code=a?.code,this.param=a?.param,this.type=a?.type}static makeMessage(e,t,n){let r=t?.message?typeof t.message==`string`?t.message:JSON.stringify(t.message):t?JSON.stringify(t):n;return e&&r?`${e} ${r}`:e?`${e} status code (no body)`:r||`(no status code or body)`}static generate(t,n,r,i){if(!t||!i)return new f({message:r,cause:s(n)});let a=n?.error;return t===400?new m(t,a,r,i):t===401?new h(t,a,r,i):t===403?new g(t,a,r,i):t===404?new _(t,a,r,i):t===409?new v(t,a,r,i):t===422?new y(t,a,r,i):t===429?new ee(t,a,r,i):t>=500?new b(t,a,r,i):new e(t,a,r,i)}},d=class extends u{constructor({message:e}={}){super(void 0,void 0,e||`Request was aborted.`,void 0)}},f=class extends u{constructor({message:e,cause:t}){super(void 0,void 0,e||`Connection error.`,void 0),t&&(this.cause=t)}},p=class extends f{constructor({message:e}={}){super({message:e??`Request timed out.`})}},m=class extends u{},h=class extends u{},g=class extends u{},_=class extends u{},v=class extends u{},y=class extends u{},ee=class extends u{},b=class extends u{},te=class extends l{constructor(){super(`Could not parse response content as the length limit was reached`)}},x=class extends l{constructor(){super(`Could not parse response content as the request was rejected by the content filter`)}},S=class extends Error{constructor(e){super(e)}},ne=class extends u{constructor(e,t,n){let r=`OAuth2 authentication error`,i;if(t&&typeof t==`object`){let e=t;i=e.error;let n=e.error_description;n&&typeof n==`string`?r=n:i&&(r=i)}super(e,t,r,n),this.error_code=i}},re=class extends l{constructor(e,t,n){super(e),this.provider=t,this.cause=n}}}));function ie(e){return typeof e==`object`?e??{}:{}}function ae(e){if(!e)return!0;for(let t in e)return!1;return!0}function oe(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function se(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var ce,le,w,ue,de,fe,pe=e((()=>{C(),ce=/^[a-z][a-z0-9+.-]*:/i,le=e=>ce.test(e),w=e=>(w=Array.isArray,w(e)),ue=w,de=(e,t)=>{if(typeof t!=`number`||!Number.isInteger(t))throw new l(`${e} must be an integer`);if(t<0)throw new l(`${e} must be a positive integer`);return t},fe=e=>{try{return JSON.parse(e)}catch{return}}})),me,he=e((()=>{me=e=>new Promise(t=>setTimeout(t,e))})),ge,_e=e((()=>{ge=`6.34.0`}));function ve(){return typeof Deno<`u`&&Deno.build!=null?`deno`:typeof EdgeRuntime<`u`?`edge`:Object.prototype.toString.call(globalThis.process===void 0?0:globalThis.process)===`[object process]`?`node`:`unknown`}function ye(){if(typeof navigator>`u`||!navigator)return null;for(let{key:e,pattern:t}of[{key:`edge`,pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`ie`,pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`ie`,pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`chrome`,pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`firefox`,pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`safari`,pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}]){let n=t.exec(navigator.userAgent);if(n)return{browser:e,version:`${n[1]||0}.${n[2]||0}.${n[3]||0}`}}return null}var be,xe,Se,Ce,we,Te,Ee=e((()=>{_e(),be=()=>typeof window<`u`&&window.document!==void 0&&typeof navigator<`u`,xe=()=>{let e=ve();if(e===`deno`)return{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":ge,"X-Stainless-OS":Ce(Deno.build.os),"X-Stainless-Arch":Se(Deno.build.arch),"X-Stainless-Runtime":`deno`,"X-Stainless-Runtime-Version":typeof Deno.version==`string`?Deno.version:Deno.version?.deno??`unknown`};if(typeof EdgeRuntime<`u`)return{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":ge,"X-Stainless-OS":`Unknown`,"X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":`edge`,"X-Stainless-Runtime-Version":globalThis.process.version};if(e===`node`)return{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":ge,"X-Stainless-OS":Ce(globalThis.process.platform??`unknown`),"X-Stainless-Arch":Se(globalThis.process.arch??`unknown`),"X-Stainless-Runtime":`node`,"X-Stainless-Runtime-Version":globalThis.process.version??`unknown`};let t=ye();return t?{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":ge,"X-Stainless-OS":`Unknown`,"X-Stainless-Arch":`unknown`,"X-Stainless-Runtime":`browser:${t.browser}`,"X-Stainless-Runtime-Version":t.version}:{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":ge,"X-Stainless-OS":`Unknown`,"X-Stainless-Arch":`unknown`,"X-Stainless-Runtime":`unknown`,"X-Stainless-Runtime-Version":`unknown`}},Se=e=>e===`x32`?`x32`:e===`x86_64`||e===`x64`?`x64`:e===`arm`?`arm`:e===`aarch64`||e===`arm64`?`arm64`:e?`other:${e}`:`unknown`,Ce=e=>(e=e.toLowerCase(),e.includes(`ios`)?`iOS`:e===`android`?`Android`:e===`darwin`?`MacOS`:e===`win32`?`Windows`:e===`freebsd`?`FreeBSD`:e===`openbsd`?`OpenBSD`:e===`linux`?`Linux`:e?`Other:${e}`:`Unknown`),Te=()=>we??(we=xe())}));function De(){if(typeof fetch<`u`)return fetch;throw Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new OpenAI({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function Oe(...e){let t=globalThis.ReadableStream;if(t===void 0)throw Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new t(...e)}function ke(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator]();return Oe({start(){},async pull(e){let{done:n,value:r}=await t.next();n?e.close():e.enqueue(r)},async cancel(){await t.return?.()}})}function Ae(e){if(e[Symbol.asyncIterator])return e;let t=e.getReader();return{async next(){try{let e=await t.read();return e?.done&&t.releaseLock(),e}catch(e){throw t.releaseLock(),e}},async return(){let e=t.cancel();return t.releaseLock(),await e,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function je(e){if(typeof e!=`object`||!e)return;if(e[Symbol.asyncIterator]){await e[Symbol.asyncIterator]().return?.();return}let t=e.getReader(),n=t.cancel();t.releaseLock(),await n}var Me=e((()=>{})),Ne,Pe=e((()=>{Ne=({headers:e,body:t})=>({bodyHeaders:{"content-type":`application/json`},body:JSON.stringify(t)})})),Fe,Ie,Le,Re=e((()=>{Fe=`RFC3986`,Ie=e=>String(e),Le={RFC1738:e=>String(e).replace(/%20/g,`+`),RFC3986:Ie}}));function ze(e){return!e||typeof e!=`object`?!1:!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))}function Be(e,t){if(w(e)){let n=[];for(let r=0;r<e.length;r+=1)n.push(t(e[r]));return n}return t(e)}var Ve,T,He,Ue,We=e((()=>{Re(),pe(),Ve=(e,t)=>(Ve=Object.hasOwn??Function.prototype.call.bind(Object.prototype.hasOwnProperty),Ve(e,t)),T=(()=>{let e=[];for(let t=0;t<256;++t)e.push(`%`+((t<16?`0`:``)+t.toString(16)).toUpperCase());return e})(),He=1024,Ue=(e,t,n,r,i)=>{if(e.length===0)return e;let a=e;if(typeof e==`symbol`?a=Symbol.prototype.toString.call(e):typeof e!=`string`&&(a=String(e)),n===`iso-8859-1`)return escape(a).replace(/%u[0-9a-f]{4}/gi,function(e){return`%26%23`+parseInt(e.slice(2),16)+`%3B`});let o=``;for(let e=0;e<a.length;e+=He){let t=a.length>=He?a.slice(e,e+He):a,n=[];for(let e=0;e<t.length;++e){let r=t.charCodeAt(e);if(r===45||r===46||r===95||r===126||r>=48&&r<=57||r>=65&&r<=90||r>=97&&r<=122||i===`RFC1738`&&(r===40||r===41)){n[n.length]=t.charAt(e);continue}if(r<128){n[n.length]=T[r];continue}if(r<2048){n[n.length]=T[192|r>>6]+T[128|r&63];continue}if(r<55296||r>=57344){n[n.length]=T[224|r>>12]+T[128|r>>6&63]+T[128|r&63];continue}e+=1,r=65536+((r&1023)<<10|t.charCodeAt(e)&1023),n[n.length]=T[240|r>>18]+T[128|r>>12&63]+T[128|r>>6&63]+T[128|r&63]}o+=n.join(``)}return o}}));function Ge(e){return typeof e==`string`||typeof e==`number`||typeof e==`boolean`||typeof e==`symbol`||typeof e==`bigint`}function Ke(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_){let v=e,y=_,ee=0,b=!1;for(;(y=y.get(Qe))!==void 0&&!b;){let t=y.get(e);if(ee+=1,t!==void 0){if(t===ee)throw RangeError(`Cyclic object value`);b=!0}y.get(Qe)===void 0&&(ee=0)}if(typeof l==`function`?v=l(t,v):v instanceof Date?v=f?.(v):n===`comma`&&w(v)&&(v=Be(v,function(e){return e instanceof Date?f?.(e):e})),v===null){if(a)return c&&!h?c(t,E.encoder,g,`key`,p):t;v=``}if(Ge(v)||ze(v)){if(c){let e=h?t:c(t,E.encoder,g,`key`,p);return[m?.(e)+`=`+m?.(c(v,E.encoder,g,`value`,p))]}return[m?.(t)+`=`+m?.(String(v))]}let te=[];if(v===void 0)return te;let x;if(n===`comma`&&w(v))h&&c&&(v=Be(v,c)),x=[{value:v.length>0?v.join(`,`)||null:void 0}];else if(w(l))x=l;else{let e=Object.keys(v);x=u?e.sort(u):e}let S=s?String(t).replace(/\./g,`%2E`):String(t),ne=r&&w(v)&&v.length===1?S+`[]`:S;if(i&&w(v)&&v.length===0)return ne+`[]`;for(let t=0;t<x.length;++t){let y=x[t],b=typeof y==`object`&&y.value!==void 0?y.value:v[y];if(o&&b===null)continue;let S=d&&s?y.replace(/\./g,`%2E`):y,re=w(v)?typeof n==`function`?n(ne,S):ne:ne+(d?`.`+S:`[`+S+`]`);_.set(e,ee);let C=new WeakMap;C.set(Qe,_),Xe(te,Ke(b,re,n,r,i,a,o,s,n===`comma`&&h&&w(v)?null:c,l,u,d,f,p,m,h,g,C))}return te}function qe(e=E){if(e.allowEmptyArrays!==void 0&&typeof e.allowEmptyArrays!=`boolean`)throw TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(e.encodeDotInKeys!==void 0&&typeof e.encodeDotInKeys!=`boolean`)throw TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(e.encoder!==null&&e.encoder!==void 0&&typeof e.encoder!=`function`)throw TypeError(`Encoder has to be a function.`);let t=e.charset||E.charset;if(e.charset!==void 0&&e.charset!==`utf-8`&&e.charset!==`iso-8859-1`)throw TypeError(`The charset option must be either utf-8, iso-8859-1, or undefined`);let n=Fe;if(e.format!==void 0){if(!Ve(Le,e.format))throw TypeError(`Unknown format option provided.`);n=e.format}let r=Le[n],i=E.filter;(typeof e.filter==`function`||w(e.filter))&&(i=e.filter);let a;if(a=e.arrayFormat&&e.arrayFormat in Ye?e.arrayFormat:`indices`in e?e.indices?`indices`:`repeat`:E.arrayFormat,`commaRoundTrip`in e&&typeof e.commaRoundTrip!=`boolean`)throw TypeError("`commaRoundTrip` must be a boolean, or absent");let o=e.allowDots===void 0?e.encodeDotInKeys?!0:E.allowDots:!!e.allowDots;return{addQueryPrefix:typeof e.addQueryPrefix==`boolean`?e.addQueryPrefix:E.addQueryPrefix,allowDots:o,allowEmptyArrays:typeof e.allowEmptyArrays==`boolean`?!!e.allowEmptyArrays:E.allowEmptyArrays,arrayFormat:a,charset:t,charsetSentinel:typeof e.charsetSentinel==`boolean`?e.charsetSentinel:E.charsetSentinel,commaRoundTrip:!!e.commaRoundTrip,delimiter:e.delimiter===void 0?E.delimiter:e.delimiter,encode:typeof e.encode==`boolean`?e.encode:E.encode,encodeDotInKeys:typeof e.encodeDotInKeys==`boolean`?e.encodeDotInKeys:E.encodeDotInKeys,encoder:typeof e.encoder==`function`?e.encoder:E.encoder,encodeValuesOnly:typeof e.encodeValuesOnly==`boolean`?e.encodeValuesOnly:E.encodeValuesOnly,filter:i,format:n,formatter:r,serializeDate:typeof e.serializeDate==`function`?e.serializeDate:E.serializeDate,skipNulls:typeof e.skipNulls==`boolean`?e.skipNulls:E.skipNulls,sort:typeof e.sort==`function`?e.sort:null,strictNullHandling:typeof e.strictNullHandling==`boolean`?e.strictNullHandling:E.strictNullHandling}}function Je(e,t={}){let n=e,r=qe(t),i,a;typeof r.filter==`function`?(a=r.filter,n=a(``,n)):w(r.filter)&&(a=r.filter,i=a);let o=[];if(typeof n!=`object`||!n)return``;let s=Ye[r.arrayFormat],c=s===`comma`&&r.commaRoundTrip;i||(i=Object.keys(n)),r.sort&&i.sort(r.sort);let l=new WeakMap;for(let e=0;e<i.length;++e){let t=i[e];r.skipNulls&&n[t]===null||Xe(o,Ke(n[t],t,s,c,r.allowEmptyArrays,r.strictNullHandling,r.skipNulls,r.encodeDotInKeys,r.encode?r.encoder:null,r.filter,r.sort,r.allowDots,r.serializeDate,r.format,r.formatter,r.encodeValuesOnly,r.charset,l))}let u=o.join(r.delimiter),d=r.addQueryPrefix===!0?`?`:``;return r.charsetSentinel&&(r.charset===`iso-8859-1`?d+=`utf8=%26%2310003%3B&`:d+=`utf8=%E2%9C%93&`),u.length>0?d+u:``}var Ye,Xe,Ze,E,Qe,$e=e((()=>{We(),Re(),pe(),Ye={brackets(e){return String(e)+`[]`},comma:`comma`,indices(e,t){return String(e)+`[`+t+`]`},repeat(e){return String(e)}},Xe=function(e,t){Array.prototype.push.apply(e,w(t)?t:[t])},E={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:`indices`,charset:`utf-8`,charsetSentinel:!1,delimiter:`&`,encode:!0,encodeDotInKeys:!1,encoder:Ue,encodeValuesOnly:!1,format:Fe,formatter:Ie,indices:!1,serializeDate(e){return(Ze??(Ze=Function.prototype.call.bind(Date.prototype.toISOString)))(e)},skipNulls:!1,strictNullHandling:!1},Qe={}}));function et(e){return Je(e,{arrayFormat:`brackets`})}var tt=e((()=>{$e()}));function nt(e){let t=0;for(let n of e)t+=n.length;let n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}function rt(e){let t;return(at??(t=new globalThis.TextEncoder,at=t.encode.bind(t)))(e)}function it(e){let t;return(ot??(t=new globalThis.TextDecoder,ot=t.decode.bind(t)))(e)}var at,ot,st=e((()=>{}));function ct(e,t){for(let n=t??0;n<e.length;n++){if(e[n]===10)return{preceding:n,index:n+1,carriage:!1};if(e[n]===13)return{preceding:n,index:n+1,carriage:!0}}return null}function lt(e){for(let t=0;t<e.length-1;t++){if(e[t]===10&&e[t+1]===10||e[t]===13&&e[t+1]===13)return t+2;if(e[t]===13&&e[t+1]===10&&t+3<e.length&&e[t+2]===13&&e[t+3]===10)return t+4}return-1}var D,O,ut,dt=e((()=>{r(),st(),ut=class{constructor(){D.set(this,void 0),O.set(this,void 0),t(this,D,new Uint8Array,`f`),t(this,O,null,`f`)}decode(e){if(e==null)return[];let r=e instanceof ArrayBuffer?new Uint8Array(e):typeof e==`string`?rt(e):e;t(this,D,nt([n(this,D,`f`),r]),`f`);let i=[],a;for(;(a=ct(n(this,D,`f`),n(this,O,`f`)))!=null;){if(a.carriage&&n(this,O,`f`)==null){t(this,O,a.index,`f`);continue}if(n(this,O,`f`)!=null&&(a.index!==n(this,O,`f`)+1||a.carriage)){i.push(it(n(this,D,`f`).subarray(0,n(this,O,`f`)-1))),t(this,D,n(this,D,`f`).subarray(n(this,O,`f`)),`f`),t(this,O,null,`f`);continue}let e=n(this,O,`f`)===null?a.preceding:a.preceding-1,r=it(n(this,D,`f`).subarray(0,e));i.push(r),t(this,D,n(this,D,`f`).subarray(a.index),`f`),t(this,O,null,`f`)}return i}flush(){return n(this,D,`f`).length?this.decode(`
2
+ `):[]}},D=new WeakMap,O=new WeakMap,ut.NEWLINE_CHARS=new Set([`
3
+ `,`\r`]),ut.NEWLINE_REGEXP=/\r\n|[\n\r]/g}));function ft(){}function pt(e,t,n){return!t||mt[e]>mt[n]?ft:t[e].bind(t)}function k(e){let t=e.logger,n=e.logLevel??`off`;if(!t)return gt;let r=_t.get(t);if(r&&r[0]===n)return r[1];let i={error:pt(`error`,t,n),warn:pt(`warn`,t,n),info:pt(`info`,t,n),debug:pt(`debug`,t,n)};return _t.set(t,[n,i]),i}var mt,ht,gt,_t,A,vt=e((()=>{pe(),mt={off:0,error:200,warn:300,info:400,debug:500},ht=(e,t,n)=>{if(e){if(oe(mt,e))return e;k(n).warn(`${t} was set to ${JSON.stringify(e)}, expected one of ${JSON.stringify(Object.keys(mt))}`)}},gt={error:ft,warn:ft,info:ft,debug:ft},_t=new WeakMap,A=e=>(e.options&&(e.options={...e.options},delete e.options.headers),e.headers&&(e.headers=Object.fromEntries((e.headers instanceof Headers?[...e.headers]:Object.entries(e.headers)).map(([e,t])=>[e,e.toLowerCase()===`authorization`||e.toLowerCase()===`cookie`||e.toLowerCase()===`set-cookie`?`***`:t]))),`retryOfRequestLogID`in e&&(e.retryOfRequestLogID&&(e.retryOf=e.retryOfRequestLogID),delete e.retryOfRequestLogID),e)}));async function*yt(e,t){if(!e.body)throw t.abort(),globalThis.navigator!==void 0&&globalThis.navigator.product===`ReactNative`?new l(`The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api`):new l(`Attempted to iterate over a response with no body`);let n=new wt,r=new ut,i=Ae(e.body);for await(let e of bt(i))for(let t of r.decode(e)){let e=n.decode(t);e&&(yield e)}for(let e of r.flush()){let t=n.decode(e);t&&(yield t)}}async function*bt(e){let t=new Uint8Array;for await(let n of e){if(n==null)continue;let e=n instanceof ArrayBuffer?new Uint8Array(n):typeof n==`string`?rt(n):n,r=new Uint8Array(t.length+e.length);r.set(t),r.set(e,t.length),t=r;let i;for(;(i=lt(t))!==-1;)yield t.slice(0,i),t=t.slice(i)}t.length>0&&(yield t)}function xt(e,t){let n=e.indexOf(t);return n===-1?[e,``,``]:[e.substring(0,n),t,e.substring(n+t.length)]}var St,Ct,wt,Tt=e((()=>{r(),C(),Me(),dt(),c(),st(),vt(),Ct=class e{constructor(e,n,r){this.iterator=e,St.set(this,void 0),this.controller=n,t(this,St,r,`f`)}static fromSSEResponse(t,n,r,i){let a=!1,s=r?k(r):console;async function*c(){if(a)throw new l("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");a=!0;let e=!1;try{for await(let r of yt(t,n))if(!e){if(r.data.startsWith(`[DONE]`)){e=!0;continue}if(r.event===null||!r.event.startsWith(`thread.`)){let e;try{e=JSON.parse(r.data)}catch(e){throw s.error(`Could not parse message into JSON:`,r.data),s.error(`From chunk:`,r.raw),e}if(e&&e.error)throw new u(void 0,e.error,void 0,t.headers);yield i?{event:r.event,data:e}:e}else{let e;try{e=JSON.parse(r.data)}catch(e){throw console.error(`Could not parse message into JSON:`,r.data),console.error(`From chunk:`,r.raw),e}if(r.event==`error`)throw new u(void 0,e.error,e.message,void 0);yield{event:r.event,data:e}}}e=!0}catch(e){if(o(e))return;throw e}finally{e||n.abort()}}return new e(c,n,r)}static fromReadableStream(t,n,r){let i=!1;async function*a(){let e=new ut,n=Ae(t);for await(let t of n)for(let n of e.decode(t))yield n;for(let t of e.flush())yield t}async function*s(){if(i)throw new l("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");i=!0;let e=!1;try{for await(let t of a())e||t&&(yield JSON.parse(t));e=!0}catch(e){if(o(e))return;throw e}finally{e||n.abort()}}return new e(s,n,r)}[(St=new WeakMap,Symbol.asyncIterator)](){return this.iterator()}tee(){let t=[],r=[],i=this.iterator(),a=e=>({next:()=>{if(e.length===0){let e=i.next();t.push(e),r.push(e)}return e.shift()}});return[new e(()=>a(t),this.controller,n(this,St,`f`)),new e(()=>a(r),this.controller,n(this,St,`f`))]}toReadableStream(){let e=this,t;return Oe({async start(){t=e[Symbol.asyncIterator]()},async pull(e){try{let{value:n,done:r}=await t.next();if(r)return e.close();let i=rt(JSON.stringify(n)+`
4
+ `);e.enqueue(i)}catch(t){e.error(t)}},async cancel(){await t.return?.()}})}},wt=class{constructor(){this.event=null,this.data=[],this.chunks=[]}decode(e){if(e.endsWith(`\r`)&&(e=e.substring(0,e.length-1)),!e){if(!this.event&&!this.data.length)return null;let e={event:this.event,data:this.data.join(`
5
+ `),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],e}if(this.chunks.push(e),e.startsWith(`:`))return null;let[t,n,r]=xt(e,`:`);return r.startsWith(` `)&&(r=r.substring(1)),t===`event`?this.event=r:t===`data`&&this.data.push(r),null}}}));async function Et(e,t){let{response:n,requestLogID:r,retryOfRequestLogID:i,startTime:a}=t,o=await(async()=>{if(t.options.stream)return k(e).debug(`response`,n.status,n.url,n.headers,n.body),t.options.__streamClass?t.options.__streamClass.fromSSEResponse(n,t.controller,e,t.options.__synthesizeEventData):Ct.fromSSEResponse(n,t.controller,e,t.options.__synthesizeEventData);if(n.status===204)return null;if(t.options.__binaryResponse)return n;let r=n.headers.get(`content-type`)?.split(`;`)[0]?.trim();return r?.includes(`application/json`)||r?.endsWith(`+json`)?n.headers.get(`content-length`)===`0`?void 0:Dt(await n.json(),n):await n.text()})();return k(e).debug(`[${r}] response parsed`,A({retryOfRequestLogID:i,url:n.url,status:n.status,body:o,durationMs:Date.now()-a})),o}function Dt(e,t){return!e||typeof e!=`object`||Array.isArray(e)?e:Object.defineProperty(e,`_request_id`,{value:t.headers.get(`x-request-id`),enumerable:!1})}var Ot=e((()=>{Tt(),vt()})),kt,At,jt=e((()=>{r(),Ot(),At=class e extends Promise{constructor(e,n,r=Et){super(e=>{e(null)}),this.responsePromise=n,this.parseResponse=r,kt.set(this,void 0),t(this,kt,e,`f`)}_thenUnwrap(t){return new e(n(this,kt,`f`),this.responsePromise,async(e,n)=>Dt(t(await this.parseResponse(e,n),n),n.response))}asResponse(){return this.responsePromise.then(e=>e.response)}async withResponse(){let[e,t]=await Promise.all([this.parse(),this.asResponse()]);return{data:e,response:t,request_id:t.headers.get(`x-request-id`)}}parse(){return this.parsedPromise||(this.parsedPromise=this.responsePromise.then(e=>this.parseResponse(n(this,kt,`f`),e))),this.parsedPromise}then(e,t){return this.parse().then(e,t)}catch(e){return this.parse().catch(e)}finally(e){return this.parse().finally(e)}},kt=new WeakMap})),Mt,Nt,Pt,Ft,j,It,M=e((()=>{r(),C(),Ot(),jt(),pe(),Nt=class{constructor(e,n,r,i){Mt.set(this,void 0),t(this,Mt,e,`f`),this.options=i,this.response=n,this.body=r}hasNextPage(){return this.getPaginatedItems().length?this.nextPageRequestOptions()!=null:!1}async getNextPage(){let e=this.nextPageRequestOptions();if(!e)throw new l("No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.");return await n(this,Mt,`f`).requestAPIList(this.constructor,e)}async*iterPages(){let e=this;for(yield e;e.hasNextPage();)e=await e.getNextPage(),yield e}async*[(Mt=new WeakMap,Symbol.asyncIterator)](){for await(let e of this.iterPages())for(let t of e.getPaginatedItems())yield t}},Pt=class extends At{constructor(e,t,n){super(e,t,async(e,t)=>new n(e,t.response,await Et(e,t),t.options))}async*[Symbol.asyncIterator](){let e=await this;for await(let t of e)yield t}},Ft=class extends Nt{constructor(e,t,n,r){super(e,t,n,r),this.data=n.data||[],this.object=n.object}getPaginatedItems(){return this.data??[]}nextPageRequestOptions(){return null}},j=class extends Nt{constructor(e,t,n,r){super(e,t,n,r),this.data=n.data||[],this.has_more=n.has_more||!1}getPaginatedItems(){return this.data??[]}hasNextPage(){return this.has_more===!1?!1:super.hasNextPage()}nextPageRequestOptions(){let e=this.getPaginatedItems(),t=e[e.length-1]?.id;return t?{...this.options,query:{...ie(this.options.query),after:t}}:null}},It=class extends Nt{constructor(e,t,n,r){super(e,t,n,r),this.data=n.data||[],this.has_more=n.has_more||!1,this.last_id=n.last_id||``}getPaginatedItems(){return this.data??[]}hasNextPage(){return this.has_more===!1?!1:super.hasNextPage()}nextPageRequestOptions(){let e=this.last_id;return e?{...this.options,query:{...ie(this.options.query),after:e}}:null}}})),Lt,Rt,zt,Bt=e((()=>{Me(),C(),Lt={jwt:`urn:ietf:params:oauth:token-type:jwt`,id:`urn:ietf:params:oauth:token-type:id_token`},Rt=`urn:ietf:params:oauth:grant-type:token-exchange`,zt=class{constructor(e,t){this.cachedToken=null,this.refreshPromise=null,this.tokenExchangeUrl=`https://auth.openai.com/oauth/token`,this.config=e,this.fetch=t??De()}async getToken(){if(!this.cachedToken||this.isTokenExpired(this.cachedToken)){if(this.refreshPromise)return await this.refreshPromise;this.refreshPromise=this.refreshToken();try{return await this.refreshPromise}finally{this.refreshPromise=null}}return this.needsRefresh(this.cachedToken)&&!this.refreshPromise&&(this.refreshPromise=this.refreshToken().finally(()=>{this.refreshPromise=null})),this.cachedToken.token}async refreshToken(){let e=await this.config.provider.getToken(),t=await this.fetch(this.tokenExchangeUrl,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({grant_type:Rt,client_id:this.config.clientId,subject_token:e,subject_token_type:Lt[this.config.provider.tokenType],identity_provider_id:this.config.identityProviderId,service_account_id:this.config.serviceAccountId})});if(!t.ok){let e=await t.text(),n;try{n=JSON.parse(e)}catch{}throw t.status===400||t.status===401||t.status===403?new ne(t.status,n,t.headers):u.generate(t.status,n,`Token exchange failed with status ${t.status}`,t.headers)}let n=await t.json(),r=n.expires_in||3600,i=Date.now()+r*1e3;return this.cachedToken={token:n.access_token,expiresAt:i},n.access_token}isTokenExpired(e){return Date.now()>=e.expiresAt}needsRefresh(e){let t=(this.config.refreshBufferSeconds??1200)*1e3;return Date.now()>=e.expiresAt-t}invalidateToken(){this.cachedToken=null,this.refreshPromise=null}}}));function Vt(e,t,n){return Wt(),new File(e,t??`unknown_file`,n)}function Ht(e){return(typeof e==`object`&&!!e&&(`name`in e&&e.name&&String(e.name)||`url`in e&&e.url&&String(e.url)||`filename`in e&&e.filename&&String(e.filename)||`path`in e&&e.path&&String(e.path))||``).split(/[\\/]/).pop()||void 0}function Ut(e){let t=typeof e==`function`?e:e.fetch,n=qt.get(t);if(n)return n;let r=(async()=>{try{let e=`Response`in t?t.Response:(await t(`data:,`)).constructor,n=new FormData;return n.toString()!==await new e(n).text()}catch{return!0}})();return qt.set(t,r),r}var Wt,Gt,Kt,N,qt,Jt,Yt,Xt,Zt,Qt,P=e((()=>{Me(),Wt=()=>{if(typeof File>`u`){let{process:e}=globalThis,t=typeof e?.versions?.node==`string`&&parseInt(e.versions.node.split(`.`))<20;throw Error("`File` is not defined as a global, which is required for file uploads."+(t?" Update to Node 20 LTS or newer, or set `globalThis.File` to `import('node:buffer').File`.":``))}},Gt=e=>typeof e==`object`&&!!e&&typeof e[Symbol.asyncIterator]==`function`,Kt=async(e,t)=>Zt(e.body)?{...e,body:await Jt(e.body,t)}:e,N=async(e,t)=>({...e,body:await Jt(e.body,t)}),qt=new WeakMap,Jt=async(e,t)=>{if(!await Ut(t))throw TypeError(`The provided fetch function does not support file uploads with the current global FormData class.`);let n=new FormData;return await Promise.all(Object.entries(e||{}).map(([e,t])=>Qt(n,e,t))),n},Yt=e=>e instanceof Blob&&`name`in e,Xt=e=>typeof e==`object`&&!!e&&(e instanceof Response||Gt(e)||Yt(e)),Zt=e=>{if(Xt(e))return!0;if(Array.isArray(e))return e.some(Zt);if(e&&typeof e==`object`){for(let t in e)if(Zt(e[t]))return!0}return!1},Qt=async(e,t,n)=>{if(n!==void 0){if(n==null)throw TypeError(`Received null for "${t}"; to pass null in FormData, you must use the string 'null'`);if(typeof n==`string`||typeof n==`number`||typeof n==`boolean`)e.append(t,String(n));else if(n instanceof Response)e.append(t,Vt([await n.blob()],Ht(n)));else if(Gt(n))e.append(t,Vt([await new Response(ke(n)).blob()],Ht(n)));else if(Yt(n))e.append(t,n,Ht(n));else if(Array.isArray(n))await Promise.all(n.map(n=>Qt(e,t+`[]`,n)));else if(typeof n==`object`)await Promise.all(Object.entries(n).map(([n,r])=>Qt(e,`${t}[${n}]`,r)));else throw TypeError(`Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${n} instead`)}}}));async function $t(e,t,n){if(Wt(),e=await e,rn(e))return e instanceof File?e:Vt([await e.arrayBuffer()],e.name);if(an(e)){let r=await e.blob();return t||(t=new URL(e.url).pathname.split(/[\\/]/).pop()),Vt(await en(r),t,n)}let r=await en(e);if(t||(t=Ht(e)),!n?.type){let e=r.find(e=>typeof e==`object`&&`type`in e&&e.type);typeof e==`string`&&(n={...n,type:e})}return Vt(r,t,n)}async function en(e){let t=[];if(typeof e==`string`||ArrayBuffer.isView(e)||e instanceof ArrayBuffer)t.push(e);else if(nn(e))t.push(e instanceof Blob?e:await e.arrayBuffer());else if(Gt(e))for await(let n of e)t.push(...await en(n));else{let t=e?.constructor?.name;throw Error(`Unexpected data type: ${typeof e}${t?`; constructor: ${t}`:``}${tn(e)}`)}return t}function tn(e){return typeof e!=`object`||!e?``:`; props: [${Object.getOwnPropertyNames(e).map(e=>`"${e}"`).join(`, `)}]`}var nn,rn,an,on=e((()=>{P(),nn=e=>typeof e==`object`&&!!e&&typeof e.size==`number`&&typeof e.type==`string`&&typeof e.text==`function`&&typeof e.slice==`function`&&typeof e.arrayBuffer==`function`,rn=e=>typeof e==`object`&&!!e&&typeof e.name==`string`&&typeof e.lastModified==`number`&&nn(e),an=e=>typeof e==`object`&&!!e&&typeof e.url==`string`&&typeof e.blob==`function`})),sn=e((()=>{on()})),F,I=e((()=>{F=class{constructor(e){this._client=e}}}));function cn(e){return e.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g,encodeURIComponent)}var ln,un,L,R=e((()=>{C(),ln=Object.freeze(Object.create(null)),un=(e=cn)=>function(t,...n){if(t.length===1)return t[0];let r=!1,i=[],a=t.reduce((t,a,o)=>{/[?#]/.test(a)&&(r=!0);let s=n[o],c=(r?encodeURIComponent:e)(``+s);return o!==n.length&&(s==null||typeof s==`object`&&s.toString===Object.getPrototypeOf(Object.getPrototypeOf(s.hasOwnProperty??ln)??ln)?.toString)&&(c=s+``,i.push({start:t.length+a.length,length:c.length,error:`Value of type ${Object.prototype.toString.call(s).slice(8,-1)} is not a valid path parameter`})),t+a+(o===n.length?``:c)},``),o=a.split(/[?#]/,1)[0],s=/(?<=^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi,c;for(;(c=s.exec(o))!==null;)i.push({start:c.index,length:c[0].length,error:`Value "${c[0]}" can\'t be safely passed as a path parameter`});if(i.sort((e,t)=>e.start-t.start),i.length>0){let e=0,t=i.reduce((t,n)=>{let r=` `.repeat(n.start-e),i=`^`.repeat(n.length);return e=n.start+n.length,t+r+i},``);throw new l(`Path parameters result in path with invalid segments:\n${i.map(e=>e.error).join(`
6
+ `)}\n${a}\n${t}`)}return a},L=un(cn)})),dn,fn=e((()=>{I(),M(),R(),dn=class extends F{list(e,t={},n){return this._client.getAPIList(L`/chat/completions/${e}/messages`,j,{query:t,...n})}}})),z=e((()=>{C()}));function pn(e){return e!==void 0&&`function`in e&&e.function!==void 0}function mn(e){return e?.$brand===`auto-parseable-response-format`}function hn(e){return e?.$brand===`auto-parseable-tool`}function gn(e,t){return!t||!xn(t)?{...e,choices:e.choices.map(e=>(Sn(e.message.tool_calls),{...e,message:{...e.message,parsed:null,...e.message.tool_calls?{tool_calls:e.message.tool_calls}:void 0}}))}:_n(e,t)}function _n(e,t){let n=e.choices.map(e=>{if(e.finish_reason===`length`)throw new te;if(e.finish_reason===`content_filter`)throw new x;return Sn(e.message.tool_calls),{...e,message:{...e.message,...e.message.tool_calls?{tool_calls:e.message.tool_calls?.map(e=>yn(t,e))??void 0}:void 0,parsed:e.message.content&&!e.message.refusal?vn(t,e.message.content):null}}});return{...e,choices:n}}function vn(e,t){return e.response_format?.type===`json_schema`&&e.response_format?.type===`json_schema`?`$parseRaw`in e.response_format?e.response_format.$parseRaw(t):JSON.parse(t):null}function yn(e,t){let n=e.tools?.find(e=>pn(e)&&e.function?.name===t.function.name);return{...t,function:{...t.function,parsed_arguments:hn(n)?n.$parseRaw(t.function.arguments):n?.function.strict?JSON.parse(t.function.arguments):null}}}function bn(e,t){if(!e||!(`tools`in e)||!e.tools)return!1;let n=e.tools?.find(e=>pn(e)&&e.function?.name===t.function.name);return pn(n)&&(hn(n)||n?.function.strict||!1)}function xn(e){return mn(e.response_format)?!0:e.tools?.some(e=>hn(e)||e.type===`function`&&e.function.strict===!0)??!1}function Sn(e){for(let t of e||[])if(t.type!==`function`)throw new l(`Currently only \`function\` tool calls are supported; Received \`${t.type}\``)}function Cn(e){for(let t of e??[]){if(t.type!==`function`)throw new l(`Currently only \`function\` tool types support auto-parsing; Received \`${t.type}\``);if(t.function.strict!==!0)throw new l(`The \`${t.function.name}\` tool is not marked with \`strict: true\`. Only strict function tools can be auto-parsed`)}}var wn=e((()=>{z()})),Tn,En,Dn=e((()=>{Tn=e=>e?.role===`assistant`,En=e=>e?.role===`tool`})),On,kn,An,jn,Mn,Nn,Pn,B,Fn,In,Ln,Rn,zn,Bn,Vn=e((()=>{r(),z(),Bn=class{constructor(){On.add(this),this.controller=new AbortController,kn.set(this,void 0),An.set(this,()=>{}),jn.set(this,()=>{}),Mn.set(this,void 0),Nn.set(this,()=>{}),Pn.set(this,()=>{}),B.set(this,{}),Fn.set(this,!1),In.set(this,!1),Ln.set(this,!1),Rn.set(this,!1),t(this,kn,new Promise((e,n)=>{t(this,An,e,`f`),t(this,jn,n,`f`)}),`f`),t(this,Mn,new Promise((e,n)=>{t(this,Nn,e,`f`),t(this,Pn,n,`f`)}),`f`),n(this,kn,`f`).catch(()=>{}),n(this,Mn,`f`).catch(()=>{})}_run(e){setTimeout(()=>{e().then(()=>{this._emitFinal(),this._emit(`end`)},n(this,On,`m`,zn).bind(this))},0)}_connected(){this.ended||(n(this,An,`f`).call(this),this._emit(`connect`))}get ended(){return n(this,Fn,`f`)}get errored(){return n(this,In,`f`)}get aborted(){return n(this,Ln,`f`)}abort(){this.controller.abort()}on(e,t){return(n(this,B,`f`)[e]||(n(this,B,`f`)[e]=[])).push({listener:t}),this}off(e,t){let r=n(this,B,`f`)[e];if(!r)return this;let i=r.findIndex(e=>e.listener===t);return i>=0&&r.splice(i,1),this}once(e,t){return(n(this,B,`f`)[e]||(n(this,B,`f`)[e]=[])).push({listener:t,once:!0}),this}emitted(e){return new Promise((n,r)=>{t(this,Rn,!0,`f`),e!==`error`&&this.once(`error`,r),this.once(e,n)})}async done(){t(this,Rn,!0,`f`),await n(this,Mn,`f`)}_emit(e,...r){if(n(this,Fn,`f`))return;e===`end`&&(t(this,Fn,!0,`f`),n(this,Nn,`f`).call(this));let i=n(this,B,`f`)[e];if(i&&(n(this,B,`f`)[e]=i.filter(e=>!e.once),i.forEach(({listener:e})=>e(...r))),e===`abort`){let e=r[0];!n(this,Rn,`f`)&&!i?.length&&Promise.reject(e),n(this,jn,`f`).call(this,e),n(this,Pn,`f`).call(this,e),this._emit(`end`);return}if(e===`error`){let e=r[0];!n(this,Rn,`f`)&&!i?.length&&Promise.reject(e),n(this,jn,`f`).call(this,e),n(this,Pn,`f`).call(this,e),this._emit(`end`)}}_emitFinal(){}},kn=new WeakMap,An=new WeakMap,jn=new WeakMap,Mn=new WeakMap,Nn=new WeakMap,Pn=new WeakMap,B=new WeakMap,Fn=new WeakMap,In=new WeakMap,Ln=new WeakMap,Rn=new WeakMap,On=new WeakSet,zn=function(e){if(t(this,In,!0,`f`),e instanceof Error&&e.name===`AbortError`&&(e=new d),e instanceof d)return t(this,Ln,!0,`f`),this._emit(`abort`,e);if(e instanceof l)return this._emit(`error`,e);if(e instanceof Error){let t=new l(e.message);return t.cause=e,this._emit(`error`,t)}return this._emit(`error`,new l(String(e)))}}));function Hn(e){return typeof e.parse==`function`}var Un=e((()=>{})),V,Wn,Gn,Kn,qn,Jn,Yn,Xn,Zn,Qn,$n=e((()=>{r(),z(),wn(),Dn(),Vn(),Un(),Zn=10,Qn=class extends Bn{constructor(){super(...arguments),V.add(this),this._chatCompletions=[],this.messages=[]}_addChatCompletion(e){this._chatCompletions.push(e),this._emit(`chatCompletion`,e);let t=e.choices[0]?.message;return t&&this._addMessage(t),e}_addMessage(e,t=!0){if(`content`in e||(e.content=null),this.messages.push(e),t){if(this._emit(`message`,e),En(e)&&e.content)this._emit(`functionToolCallResult`,e.content);else if(Tn(e)&&e.tool_calls)for(let t of e.tool_calls)t.type===`function`&&this._emit(`functionToolCall`,t.function)}}async finalChatCompletion(){await this.done();let e=this._chatCompletions[this._chatCompletions.length-1];if(!e)throw new l(`stream ended without producing a ChatCompletion`);return e}async finalContent(){return await this.done(),n(this,V,`m`,Wn).call(this)}async finalMessage(){return await this.done(),n(this,V,`m`,Gn).call(this)}async finalFunctionToolCall(){return await this.done(),n(this,V,`m`,Kn).call(this)}async finalFunctionToolCallResult(){return await this.done(),n(this,V,`m`,qn).call(this)}async totalUsage(){return await this.done(),n(this,V,`m`,Jn).call(this)}allChatCompletions(){return[...this._chatCompletions]}_emitFinal(){let e=this._chatCompletions[this._chatCompletions.length-1];e&&this._emit(`finalChatCompletion`,e);let t=n(this,V,`m`,Gn).call(this);t&&this._emit(`finalMessage`,t);let r=n(this,V,`m`,Wn).call(this);r&&this._emit(`finalContent`,r);let i=n(this,V,`m`,Kn).call(this);i&&this._emit(`finalFunctionToolCall`,i);let a=n(this,V,`m`,qn).call(this);a!=null&&this._emit(`finalFunctionToolCallResult`,a),this._chatCompletions.some(e=>e.usage)&&this._emit(`totalUsage`,n(this,V,`m`,Jn).call(this))}async _createChatCompletion(e,t,r){let i=r?.signal;i&&(i.aborted&&this.controller.abort(),i.addEventListener(`abort`,()=>this.controller.abort())),n(this,V,`m`,Yn).call(this,t);let a=await e.chat.completions.create({...t,stream:!1},{...r,signal:this.controller.signal});return this._connected(),this._addChatCompletion(_n(a,t))}async _runChatCompletion(e,t,n){for(let e of t.messages)this._addMessage(e,!1);return await this._createChatCompletion(e,t,n)}async _runTools(e,t,r){let i=`tool`,{tool_choice:a=`auto`,stream:o,...s}=t,c=typeof a!=`string`&&a.type===`function`&&a?.function?.name,{maxChatCompletions:u=Zn}=r||{},d=t.tools.map(e=>{if(hn(e)){if(!e.$callback)throw new l("Tool given to `.runTools()` that does not have an associated function");return{type:`function`,function:{function:e.$callback,name:e.function.name,description:e.function.description||``,parameters:e.function.parameters,parse:e.$parseRaw,strict:!0}}}return e}),f={};for(let e of d)e.type===`function`&&(f[e.function.name||e.function.function.name]=e.function);let p=`tools`in t?d.map(e=>e.type===`function`?{type:`function`,function:{name:e.function.name||e.function.function.name,parameters:e.function.parameters,description:e.function.description,strict:e.function.strict}}:e):void 0;for(let e of t.messages)this._addMessage(e,!1);for(let t=0;t<u;++t){let t=(await this._createChatCompletion(e,{...s,tool_choice:a,tools:p,messages:[...this.messages]},r)).choices[0]?.message;if(!t)throw new l(`missing message in ChatCompletion response`);if(!t.tool_calls?.length)return;for(let e of t.tool_calls){if(e.type!==`function`)continue;let t=e.id,{name:r,arguments:a}=e.function,o=f[r];if(!o){let e=`Invalid tool_call: ${JSON.stringify(r)}. Available options are: ${Object.keys(f).map(e=>JSON.stringify(e)).join(`, `)}. Please try again`;this._addMessage({role:i,tool_call_id:t,content:e});continue}else if(c&&c!==r){let e=`Invalid tool_call: ${JSON.stringify(r)}. ${JSON.stringify(c)} requested. Please try again`;this._addMessage({role:i,tool_call_id:t,content:e});continue}let s;try{s=Hn(o)?await o.parse(a):a}catch(e){let n=e instanceof Error?e.message:String(e);this._addMessage({role:i,tool_call_id:t,content:n});continue}let l=await o.function(s,this),u=n(this,V,`m`,Xn).call(this,l);if(this._addMessage({role:i,tool_call_id:t,content:u}),c)return}}}},V=new WeakSet,Wn=function(){return n(this,V,`m`,Gn).call(this).content??null},Gn=function(){let e=this.messages.length;for(;e-- >0;){let t=this.messages[e];if(Tn(t))return{...t,content:t.content??null,refusal:t.refusal??null}}throw new l(`stream ended without producing a ChatCompletionMessage with role=assistant`)},Kn=function(){for(let e=this.messages.length-1;e>=0;e--){let t=this.messages[e];if(Tn(t)&&t?.tool_calls?.length)return t.tool_calls.filter(e=>e.type===`function`).at(-1)?.function}},qn=function(){for(let e=this.messages.length-1;e>=0;e--){let t=this.messages[e];if(En(t)&&t.content!=null&&typeof t.content==`string`&&this.messages.some(e=>e.role===`assistant`&&e.tool_calls?.some(e=>e.type===`function`&&e.id===t.tool_call_id)))return t.content}},Jn=function(){let e={completion_tokens:0,prompt_tokens:0,total_tokens:0};for(let{usage:t}of this._chatCompletions)t&&(e.completion_tokens+=t.completion_tokens,e.prompt_tokens+=t.prompt_tokens,e.total_tokens+=t.total_tokens);return e},Yn=function(e){if(e.n!=null&&e.n>1)throw new l(`ChatCompletion convenience helpers only support n=1 at this time. To use n>1, please use chat.completions.create() directly.`)},Xn=function(e){return typeof e==`string`?e:e===void 0?`undefined`:JSON.stringify(e)}})),er,tr=e((()=>{$n(),Dn(),er=class e extends Qn{static runTools(t,n,r){let i=new e,a={...r,headers:{...r?.headers,"X-Stainless-Helper-Method":`runTools`}};return i._run(()=>i._runTools(t,n,a)),i}_addMessage(e,t=!0){super._addMessage(e,t),Tn(e)&&e.content&&this._emit(`content`,e.content)}}}));function nr(e,t=H.ALL){if(typeof e!=`string`)throw TypeError(`expecting str, got ${typeof e}`);if(!e.trim())throw Error(`${e} is empty`);return vr(e.trim(),t)}var rr,ir,ar,or,sr,cr,lr,ur,dr,fr,pr,mr,hr,H,gr,_r,vr,yr,br=e((()=>{rr=1,ir=2,ar=4,or=8,sr=16,cr=32,lr=64,ur=128,dr=256,fr=ur|dr,pr=496,mr=ir|497,hr=ar|or,H={STR:rr,NUM:ir,ARR:ar,OBJ:or,NULL:sr,BOOL:cr,NAN:lr,INFINITY:ur,MINUS_INFINITY:dr,INF:fr,SPECIAL:pr,ATOM:mr,COLLECTION:hr,ALL:mr|hr},gr=class extends Error{},_r=class extends Error{},vr=(e,t)=>{let n=e.length,r=0,i=e=>{throw new gr(`${e} at position ${r}`)},a=e=>{throw new _r(`${e} at position ${r}`)},o=()=>(d(),r>=n&&i(`Unexpected end of input`),e[r]===`"`?s():e[r]===`{`?c():e[r]===`[`?l():e.substring(r,r+4)===`null`||H.NULL&t&&n-r<4&&`null`.startsWith(e.substring(r))?(r+=4,null):e.substring(r,r+4)===`true`||H.BOOL&t&&n-r<4&&`true`.startsWith(e.substring(r))?(r+=4,!0):e.substring(r,r+5)===`false`||H.BOOL&t&&n-r<5&&`false`.startsWith(e.substring(r))?(r+=5,!1):e.substring(r,r+8)===`Infinity`||H.INFINITY&t&&n-r<8&&`Infinity`.startsWith(e.substring(r))?(r+=8,1/0):e.substring(r,r+9)===`-Infinity`||H.MINUS_INFINITY&t&&1<n-r&&n-r<9&&`-Infinity`.startsWith(e.substring(r))?(r+=9,-1/0):e.substring(r,r+3)===`NaN`||H.NAN&t&&n-r<3&&`NaN`.startsWith(e.substring(r))?(r+=3,NaN):u()),s=()=>{let o=r,s=!1;for(r++;r<n&&(e[r]!==`"`||s&&e[r-1]===`\\`);)s=e[r]===`\\`?!s:!1,r++;if(e.charAt(r)==`"`)try{return JSON.parse(e.substring(o,++r-Number(s)))}catch(e){a(String(e))}else if(H.STR&t)try{return JSON.parse(e.substring(o,r-Number(s))+`"`)}catch{return JSON.parse(e.substring(o,e.lastIndexOf(`\\`))+`"`)}i(`Unterminated string literal`)},c=()=>{r++,d();let a={};try{for(;e[r]!==`}`;){if(d(),r>=n&&H.OBJ&t)return a;let i=s();d(),r++;try{let e=o();Object.defineProperty(a,i,{value:e,writable:!0,enumerable:!0,configurable:!0})}catch(e){if(H.OBJ&t)return a;throw e}d(),e[r]===`,`&&r++}}catch{if(H.OBJ&t)return a;i(`Expected '}' at end of object`)}return r++,a},l=()=>{r++;let n=[];try{for(;e[r]!==`]`;)n.push(o()),d(),e[r]===`,`&&r++}catch{if(H.ARR&t)return n;i(`Expected ']' at end of array`)}return r++,n},u=()=>{if(r===0){e===`-`&&H.NUM&t&&i(`Not sure what '-' is`);try{return JSON.parse(e)}catch(n){if(H.NUM&t)try{return e[e.length-1]===`.`?JSON.parse(e.substring(0,e.lastIndexOf(`.`))):JSON.parse(e.substring(0,e.lastIndexOf(`e`)))}catch{}a(String(n))}}let o=r;for(e[r]===`-`&&r++;e[r]&&!`,]}`.includes(e[r]);)r++;r==n&&!(H.NUM&t)&&i(`Unterminated number literal`);try{return JSON.parse(e.substring(o,r))}catch{e.substring(o,r)===`-`&&H.NUM&t&&i(`Not sure what '-' is`);try{return JSON.parse(e.substring(o,e.lastIndexOf(`e`)))}catch(e){a(String(e))}}},d=()=>{for(;r<n&&`
7
+ \r `.includes(e[r]);)r++};return o()},yr=e=>nr(e,H.ALL^H.NUM)})),xr=e((()=>{Tt()}));function Sr(e,t){let{id:n,choices:r,created:i,model:a,system_fingerprint:o,...s}=e;return gn({...s,id:n,choices:r.map(({message:t,finish_reason:n,index:r,logprobs:i,...a})=>{if(!n)throw new l(`missing finish_reason for choice ${r}`);let{content:o=null,function_call:s,tool_calls:c,...u}=t,d=t.role;if(!d)throw new l(`missing role for choice ${r}`);if(s){let{arguments:e,name:c}=s;if(e==null)throw new l(`missing function_call.arguments for choice ${r}`);if(!c)throw new l(`missing function_call.name for choice ${r}`);return{...a,message:{content:o,function_call:{arguments:e,name:c},role:d,refusal:t.refusal??null},finish_reason:n,index:r,logprobs:i}}return c?{...a,index:r,finish_reason:n,logprobs:i,message:{...u,role:d,content:o,refusal:t.refusal??null,tool_calls:c.map((t,n)=>{let{function:i,type:a,id:o,...s}=t,{arguments:c,name:u,...d}=i||{};if(o==null)throw new l(`missing choices[${r}].tool_calls[${n}].id\n${Cr(e)}`);if(a==null)throw new l(`missing choices[${r}].tool_calls[${n}].type\n${Cr(e)}`);if(u==null)throw new l(`missing choices[${r}].tool_calls[${n}].function.name\n${Cr(e)}`);if(c==null)throw new l(`missing choices[${r}].tool_calls[${n}].function.arguments\n${Cr(e)}`);return{...s,id:o,type:a,function:{...d,name:u,arguments:c}}})}}:{...a,message:{...u,content:o,role:d,refusal:t.refusal??null},finish_reason:n,index:r,logprobs:i}}),created:i,model:a,object:`chat.completion`,...o?{system_fingerprint:o}:{}},t)}function Cr(e){return JSON.stringify(e)}var U,W,wr,G,Tr,Er,Dr,Or,kr,Ar,jr,Mr,Nr,Pr=e((()=>{r(),br(),z(),wn(),xr(),$n(),Nr=class e extends Qn{constructor(e){super(),U.add(this),W.set(this,void 0),wr.set(this,void 0),G.set(this,void 0),t(this,W,e,`f`),t(this,wr,[],`f`)}get currentChatCompletionSnapshot(){return n(this,G,`f`)}static fromReadableStream(t){let n=new e(null);return n._run(()=>n._fromReadableStream(t)),n}static createChatCompletion(t,n,r){let i=new e(n);return i._run(()=>i._runChatCompletion(t,{...n,stream:!0},{...r,headers:{...r?.headers,"X-Stainless-Helper-Method":`stream`}})),i}async _createChatCompletion(e,t,r){super._createChatCompletion;let i=r?.signal;i&&(i.aborted&&this.controller.abort(),i.addEventListener(`abort`,()=>this.controller.abort())),n(this,U,`m`,Tr).call(this);let a=await e.chat.completions.create({...t,stream:!0},{...r,signal:this.controller.signal});this._connected();for await(let e of a)n(this,U,`m`,Dr).call(this,e);if(a.controller.signal?.aborted)throw new d;return this._addChatCompletion(n(this,U,`m`,Ar).call(this))}async _fromReadableStream(e,t){let r=t?.signal;r&&(r.aborted&&this.controller.abort(),r.addEventListener(`abort`,()=>this.controller.abort())),n(this,U,`m`,Tr).call(this),this._connected();let i=Ct.fromReadableStream(e,this.controller),a;for await(let e of i)a&&a!==e.id&&this._addChatCompletion(n(this,U,`m`,Ar).call(this)),n(this,U,`m`,Dr).call(this,e),a=e.id;if(i.controller.signal?.aborted)throw new d;return this._addChatCompletion(n(this,U,`m`,Ar).call(this))}[(W=new WeakMap,wr=new WeakMap,G=new WeakMap,U=new WeakSet,Tr=function(){this.ended||t(this,G,void 0,`f`)},Er=function(e){let t=n(this,wr,`f`)[e.index];return t||(t={content_done:!1,refusal_done:!1,logprobs_content_done:!1,logprobs_refusal_done:!1,done_tool_calls:new Set,current_tool_call_index:null},n(this,wr,`f`)[e.index]=t,t)},Dr=function(e){if(this.ended)return;let t=n(this,U,`m`,Mr).call(this,e);this._emit(`chunk`,e,t);for(let r of e.choices){let e=t.choices[r.index];r.delta.content!=null&&e.message?.role===`assistant`&&e.message?.content&&(this._emit(`content`,r.delta.content,e.message.content),this._emit(`content.delta`,{delta:r.delta.content,snapshot:e.message.content,parsed:e.message.parsed})),r.delta.refusal!=null&&e.message?.role===`assistant`&&e.message?.refusal&&this._emit(`refusal.delta`,{delta:r.delta.refusal,snapshot:e.message.refusal}),r.logprobs?.content!=null&&e.message?.role===`assistant`&&this._emit(`logprobs.content.delta`,{content:r.logprobs?.content,snapshot:e.logprobs?.content??[]}),r.logprobs?.refusal!=null&&e.message?.role===`assistant`&&this._emit(`logprobs.refusal.delta`,{refusal:r.logprobs?.refusal,snapshot:e.logprobs?.refusal??[]});let i=n(this,U,`m`,Er).call(this,e);e.finish_reason&&(n(this,U,`m`,kr).call(this,e),i.current_tool_call_index!=null&&n(this,U,`m`,Or).call(this,e,i.current_tool_call_index));for(let t of r.delta.tool_calls??[])i.current_tool_call_index!==t.index&&(n(this,U,`m`,kr).call(this,e),i.current_tool_call_index!=null&&n(this,U,`m`,Or).call(this,e,i.current_tool_call_index)),i.current_tool_call_index=t.index;for(let t of r.delta.tool_calls??[]){let n=e.message.tool_calls?.[t.index];n?.type&&(n?.type===`function`?this._emit(`tool_calls.function.arguments.delta`,{name:n.function?.name,index:t.index,arguments:n.function.arguments,parsed_arguments:n.function.parsed_arguments,arguments_delta:t.function?.arguments??``}):n?.type)}}},Or=function(e,t){if(n(this,U,`m`,Er).call(this,e).done_tool_calls.has(t))return;let r=e.message.tool_calls?.[t];if(!r)throw Error(`no tool call snapshot`);if(!r.type)throw Error("tool call snapshot missing `type`");if(r.type===`function`){let e=n(this,W,`f`)?.tools?.find(e=>pn(e)&&e.function.name===r.function.name);this._emit(`tool_calls.function.arguments.done`,{name:r.function.name,index:t,arguments:r.function.arguments,parsed_arguments:hn(e)?e.$parseRaw(r.function.arguments):e?.function.strict?JSON.parse(r.function.arguments):null})}else r.type},kr=function(e){let t=n(this,U,`m`,Er).call(this,e);if(e.message.content&&!t.content_done){t.content_done=!0;let r=n(this,U,`m`,jr).call(this);this._emit(`content.done`,{content:e.message.content,parsed:r?r.$parseRaw(e.message.content):null})}e.message.refusal&&!t.refusal_done&&(t.refusal_done=!0,this._emit(`refusal.done`,{refusal:e.message.refusal})),e.logprobs?.content&&!t.logprobs_content_done&&(t.logprobs_content_done=!0,this._emit(`logprobs.content.done`,{content:e.logprobs.content})),e.logprobs?.refusal&&!t.logprobs_refusal_done&&(t.logprobs_refusal_done=!0,this._emit(`logprobs.refusal.done`,{refusal:e.logprobs.refusal}))},Ar=function(){if(this.ended)throw new l(`stream has ended, this shouldn't happen`);let e=n(this,G,`f`);if(!e)throw new l(`request ended without sending any chunks`);return t(this,G,void 0,`f`),t(this,wr,[],`f`),Sr(e,n(this,W,`f`))},jr=function(){let e=n(this,W,`f`)?.response_format;return mn(e)?e:null},Mr=function(e){var r,i,a,o;let s=n(this,G,`f`),{choices:c,...l}=e;s?Object.assign(s,l):s=t(this,G,{...l,choices:[]},`f`);for(let{delta:t,finish_reason:c,index:l,logprobs:u=null,...d}of e.choices){let e=s.choices[l];if(e||(e=s.choices[l]={finish_reason:c,index:l,message:{},logprobs:u,...d}),u)if(!e.logprobs)e.logprobs=Object.assign({},u);else{let{content:t,refusal:n,...a}=u;Object.assign(e.logprobs,a),t&&((r=e.logprobs).content??(r.content=[]),e.logprobs.content.push(...t)),n&&((i=e.logprobs).refusal??(i.refusal=[]),e.logprobs.refusal.push(...n))}if(c&&(e.finish_reason=c,n(this,W,`f`)&&xn(n(this,W,`f`)))){if(c===`length`)throw new te;if(c===`content_filter`)throw new x}if(Object.assign(e,d),!t)continue;let{content:f,refusal:p,function_call:m,role:h,tool_calls:g,..._}=t;if(Object.assign(e.message,_),p&&(e.message.refusal=(e.message.refusal||``)+p),h&&(e.message.role=h),m&&(e.message.function_call?(m.name&&(e.message.function_call.name=m.name),m.arguments&&((a=e.message.function_call).arguments??(a.arguments=``),e.message.function_call.arguments+=m.arguments)):e.message.function_call=m),f&&(e.message.content=(e.message.content||``)+f,!e.message.refusal&&n(this,U,`m`,jr).call(this)&&(e.message.parsed=yr(e.message.content))),g){e.message.tool_calls||(e.message.tool_calls=[]);for(let{index:t,id:r,type:i,function:a,...s}of g){let c=(o=e.message.tool_calls)[t]??(o[t]={});Object.assign(c,s),r&&(c.id=r),i&&(c.type=i),a&&(c.function??(c.function={name:a.name??``,arguments:``})),a?.name&&(c.function.name=a.name),a?.arguments&&(c.function.arguments+=a.arguments,bn(n(this,W,`f`),c)&&(c.function.parsed_arguments=yr(c.function.arguments)))}}}return s},Symbol.asyncIterator)](){let e=[],t=[],n=!1;return this.on(`chunk`,n=>{let r=t.shift();r?r.resolve(n):e.push(n)}),this.on(`end`,()=>{n=!0;for(let e of t)e.resolve(void 0);t.length=0}),this.on(`abort`,e=>{n=!0;for(let n of t)n.reject(e);t.length=0}),this.on(`error`,e=>{n=!0;for(let n of t)n.reject(e);t.length=0}),{next:async()=>e.length?{value:e.shift(),done:!1}:n?{value:void 0,done:!0}:new Promise((e,n)=>t.push({resolve:e,reject:n})).then(e=>e?{value:e,done:!1}:{value:void 0,done:!0}),return:async()=>(this.abort(),{value:void 0,done:!0})}}toReadableStream(){return new Ct(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}}})),Fr,Ir=e((()=>{Pr(),Fr=class e extends Nr{static fromReadableStream(t){let n=new e(null);return n._run(()=>n._fromReadableStream(t)),n}static runTools(t,n,r){let i=new e(n),a={...r,headers:{...r?.headers,"X-Stainless-Helper-Method":`runTools`}};return i._run(()=>i._runTools(t,n,a)),i}}})),Lr,Rr=e((()=>{I(),fn(),M(),R(),tr(),Ir(),Pr(),wn(),Un(),Lr=class extends F{constructor(){super(...arguments),this.messages=new dn(this._client)}create(e,t){return this._client.post(`/chat/completions`,{body:e,...t,stream:e.stream??!1})}retrieve(e,t){return this._client.get(L`/chat/completions/${e}`,t)}update(e,t,n){return this._client.post(L`/chat/completions/${e}`,{body:t,...n})}list(e={},t){return this._client.getAPIList(`/chat/completions`,j,{query:e,...t})}delete(e,t){return this._client.delete(L`/chat/completions/${e}`,t)}parse(e,t){return Cn(e.tools),this._client.chat.completions.create(e,{...t,headers:{...t?.headers,"X-Stainless-Helper-Method":`chat.completions.parse`}})._thenUnwrap(t=>_n(t,e))}runTools(e,t){return e.stream?Fr.runTools(this._client,e,t):er.runTools(this._client,e,t)}stream(e,t){return Nr.createChatCompletion(this._client,e,t)}},Lr.Messages=dn})),zr,Br=e((()=>{I(),Rr(),zr=class extends F{constructor(){super(...arguments),this.completions=new Lr(this._client)}},zr.Completions=Lr})),Vr=e((()=>{Rr(),Rr(),fn()})),Hr=e((()=>{Br(),Vr()})),Ur=e((()=>{}));function*Wr(e){if(!e)return;if(Gr in e){let{values:t,nulls:n}=e;yield*t.entries();for(let e of n)yield[e,null];return}let t=!1,n;e instanceof Headers?n=e.entries():ue(e)?n=e:(t=!0,n=Object.entries(e??{}));for(let e of n){let n=e[0];if(typeof n!=`string`)throw TypeError(`expected header name to be a string`);let r=ue(e[1])?e[1]:[e[1]],i=!1;for(let e of r)e!==void 0&&(t&&!i&&(i=!0,yield[n,null]),yield[n,e])}}var Gr,K,q=e((()=>{pe(),Gr=Symbol(`brand.privateNullableHeaders`),K=e=>{let t=new Headers,n=new Set;for(let r of e){let e=new Set;for(let[i,a]of Wr(r)){let r=i.toLowerCase();e.has(r)||(t.delete(i),e.add(r)),a===null?(t.delete(i),n.add(r)):(t.append(i,a),n.delete(r))}}return{[Gr]:!0,values:t,nulls:n}}})),Kr,qr=e((()=>{I(),q(),Kr=class extends F{create(e,t){return this._client.post(`/audio/speech`,{body:e,...t,headers:K([{Accept:`application/octet-stream`},t?.headers]),__binaryResponse:!0})}}})),Jr,Yr=e((()=>{I(),P(),Jr=class extends F{create(e,t){return this._client.post(`/audio/transcriptions`,N({body:e,...t,stream:e.stream??!1,__metadata:{model:e.model}},this._client))}}})),Xr,Zr=e((()=>{I(),P(),Xr=class extends F{create(e,t){return this._client.post(`/audio/translations`,N({body:e,...t,__metadata:{model:e.model}},this._client))}}})),Qr,$r=e((()=>{I(),qr(),Yr(),Zr(),Qr=class extends F{constructor(){super(...arguments),this.transcriptions=new Jr(this._client),this.translations=new Xr(this._client),this.speech=new Kr(this._client)}},Qr.Transcriptions=Jr,Qr.Translations=Xr,Qr.Speech=Kr})),ei,ti=e((()=>{I(),M(),R(),ei=class extends F{create(e,t){return this._client.post(`/batches`,{body:e,...t})}retrieve(e,t){return this._client.get(L`/batches/${e}`,t)}list(e={},t){return this._client.getAPIList(`/batches`,j,{query:e,...t})}cancel(e,t){return this._client.post(L`/batches/${e}/cancel`,t)}}})),ni,ri=e((()=>{I(),M(),q(),R(),ni=class extends F{create(e,t){return this._client.post(`/assistants`,{body:e,...t,headers:K([{"OpenAI-Beta":`assistants=v2`},t?.headers])})}retrieve(e,t){return this._client.get(L`/assistants/${e}`,{...t,headers:K([{"OpenAI-Beta":`assistants=v2`},t?.headers])})}update(e,t,n){return this._client.post(L`/assistants/${e}`,{body:t,...n,headers:K([{"OpenAI-Beta":`assistants=v2`},n?.headers])})}list(e={},t){return this._client.getAPIList(`/assistants`,j,{query:e,...t,headers:K([{"OpenAI-Beta":`assistants=v2`},t?.headers])})}delete(e,t){return this._client.delete(L`/assistants/${e}`,{...t,headers:K([{"OpenAI-Beta":`assistants=v2`},t?.headers])})}}})),ii,ai=e((()=>{I(),q(),ii=class extends F{create(e,t){return this._client.post(`/realtime/sessions`,{body:e,...t,headers:K([{"OpenAI-Beta":`assistants=v2`},t?.headers])})}}})),oi,si=e((()=>{I(),q(),oi=class extends F{create(e,t){return this._client.post(`/realtime/transcription_sessions`,{body:e,...t,headers:K([{"OpenAI-Beta":`assistants=v2`},t?.headers])})}}})),ci,li=e((()=>{I(),ai(),si(),ci=class extends F{constructor(){super(...arguments),this.sessions=new ii(this._client),this.transcriptionSessions=new oi(this._client)}},ci.Sessions=ii,ci.TranscriptionSessions=oi})),ui,di=e((()=>{I(),q(),R(),ui=class extends F{create(e,t){return this._client.post(`/chatkit/sessions`,{body:e,...t,headers:K([{"OpenAI-Beta":`chatkit_beta=v1`},t?.headers])})}cancel(e,t){return this._client.post(L`/chatkit/sessions/${e}/cancel`,{...t,headers:K([{"OpenAI-Beta":`chatkit_beta=v1`},t?.headers])})}}})),fi,pi=e((()=>{I(),M(),q(),R(),fi=class extends F{retrieve(e,t){return this._client.get(L`/chatkit/threads/${e}`,{...t,headers:K([{"OpenAI-Beta":`chatkit_beta=v1`},t?.headers])})}list(e={},t){return this._client.getAPIList(`/chatkit/threads`,It,{query:e,...t,headers:K([{"OpenAI-Beta":`chatkit_beta=v1`},t?.headers])})}delete(e,t){return this._client.delete(L`/chatkit/threads/${e}`,{...t,headers:K([{"OpenAI-Beta":`chatkit_beta=v1`},t?.headers])})}listItems(e,t={},n){return this._client.getAPIList(L`/chatkit/threads/${e}/items`,It,{query:t,...n,headers:K([{"OpenAI-Beta":`chatkit_beta=v1`},n?.headers])})}}})),mi,hi=e((()=>{I(),di(),pi(),mi=class extends F{constructor(){super(...arguments),this.sessions=new ui(this._client),this.threads=new fi(this._client)}},mi.Sessions=ui,mi.Threads=fi})),gi,_i=e((()=>{I(),M(),q(),R(),gi=class extends F{create(e,t,n){return this._client.post(L`/threads/${e}/messages`,{body:t,...n,headers:K([{"OpenAI-Beta":`assistants=v2`},n?.headers])})}retrieve(e,t,n){let{thread_id:r}=t;return this._client.get(L`/threads/${r}/messages/${e}`,{...n,headers:K([{"OpenAI-Beta":`assistants=v2`},n?.headers])})}update(e,t,n){let{thread_id:r,...i}=t;return this._client.post(L`/threads/${r}/messages/${e}`,{body:i,...n,headers:K([{"OpenAI-Beta":`assistants=v2`},n?.headers])})}list(e,t={},n){return this._client.getAPIList(L`/threads/${e}/messages`,j,{query:t,...n,headers:K([{"OpenAI-Beta":`assistants=v2`},n?.headers])})}delete(e,t,n){let{thread_id:r}=t;return this._client.delete(L`/threads/${r}/messages/${e}`,{...n,headers:K([{"OpenAI-Beta":`assistants=v2`},n?.headers])})}}})),vi,yi=e((()=>{I(),M(),q(),R(),vi=class extends F{retrieve(e,t,n){let{thread_id:r,run_id:i,...a}=t;return this._client.get(L`/threads/${r}/runs/${i}/steps/${e}`,{query:a,...n,headers:K([{"OpenAI-Beta":`assistants=v2`},n?.headers])})}list(e,t,n){let{thread_id:r,...i}=t;return this._client.getAPIList(L`/threads/${r}/runs/${e}/steps`,j,{query:i,...n,headers:K([{"OpenAI-Beta":`assistants=v2`},n?.headers])})}}})),bi,xi=e((()=>{bi=e=>{if(typeof Buffer<`u`){let t=Buffer.from(e,`base64`);return Array.from(new Float32Array(t.buffer,t.byteOffset,t.length/Float32Array.BYTES_PER_ELEMENT))}else{let t=atob(e),n=t.length,r=new Uint8Array(n);for(let e=0;e<n;e++)r[e]=t.charCodeAt(e);return Array.from(new Float32Array(r.buffer))}}})),Si,Ci=e((()=>{Si=e=>{if(globalThis.process!==void 0)return globalThis.process.env?.[e]?.trim()??void 0;if(globalThis.Deno!==void 0)return globalThis.Deno.env?.get?.(e)?.trim()}})),wi=e((()=>{pe(),xi(),Ci(),vt(),a(),he(),tt()})),J,Ti,Ei,Y,Di,X,Oi,ki,Ai,ji,Z,Mi,Ni,Pi,Fi,Ii,Li,Ri,zi,Bi,Vi,Hi,Ui,Wi,Gi=e((()=>{r(),xr(),z(),Vn(),wi(),Wi=class extends Bn{constructor(){super(...arguments),J.add(this),Ei.set(this,[]),Y.set(this,{}),Di.set(this,{}),X.set(this,void 0),Oi.set(this,void 0),ki.set(this,void 0),Ai.set(this,void 0),ji.set(this,void 0),Z.set(this,void 0),Mi.set(this,void 0),Ni.set(this,void 0),Pi.set(this,void 0)}[(Ei=new WeakMap,Y=new WeakMap,Di=new WeakMap,X=new WeakMap,Oi=new WeakMap,ki=new WeakMap,Ai=new WeakMap,ji=new WeakMap,Z=new WeakMap,Mi=new WeakMap,Ni=new WeakMap,Pi=new WeakMap,J=new WeakSet,Symbol.asyncIterator)](){let e=[],t=[],n=!1;return this.on(`event`,n=>{let r=t.shift();r?r.resolve(n):e.push(n)}),this.on(`end`,()=>{n=!0;for(let e of t)e.resolve(void 0);t.length=0}),this.on(`abort`,e=>{n=!0;for(let n of t)n.reject(e);t.length=0}),this.on(`error`,e=>{n=!0;for(let n of t)n.reject(e);t.length=0}),{next:async()=>e.length?{value:e.shift(),done:!1}:n?{value:void 0,done:!0}:new Promise((e,n)=>t.push({resolve:e,reject:n})).then(e=>e?{value:e,done:!1}:{value:void 0,done:!0}),return:async()=>(this.abort(),{value:void 0,done:!0})}}static fromReadableStream(e){let t=new Ti;return t._run(()=>t._fromReadableStream(e)),t}async _fromReadableStream(e,t){let r=t?.signal;r&&(r.aborted&&this.controller.abort(),r.addEventListener(`abort`,()=>this.controller.abort())),this._connected();let i=Ct.fromReadableStream(e,this.controller);for await(let e of i)n(this,J,`m`,Fi).call(this,e);if(i.controller.signal?.aborted)throw new d;return this._addRun(n(this,J,`m`,Ii).call(this))}toReadableStream(){return new Ct(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}static createToolAssistantStream(e,t,n,r){let i=new Ti;return i._run(()=>i._runToolAssistantStream(e,t,n,{...r,headers:{...r?.headers,"X-Stainless-Helper-Method":`stream`}})),i}async _createToolAssistantStream(e,t,r,i){let a=i?.signal;a&&(a.aborted&&this.controller.abort(),a.addEventListener(`abort`,()=>this.controller.abort()));let o={...r,stream:!0},s=await e.submitToolOutputs(t,o,{...i,signal:this.controller.signal});this._connected();for await(let e of s)n(this,J,`m`,Fi).call(this,e);if(s.controller.signal?.aborted)throw new d;return this._addRun(n(this,J,`m`,Ii).call(this))}static createThreadAssistantStream(e,t,n){let r=new Ti;return r._run(()=>r._threadAssistantStream(e,t,{...n,headers:{...n?.headers,"X-Stainless-Helper-Method":`stream`}})),r}static createAssistantStream(e,t,n,r){let i=new Ti;return i._run(()=>i._runAssistantStream(e,t,n,{...r,headers:{...r?.headers,"X-Stainless-Helper-Method":`stream`}})),i}currentEvent(){return n(this,Mi,`f`)}currentRun(){return n(this,Ni,`f`)}currentMessageSnapshot(){return n(this,X,`f`)}currentRunStepSnapshot(){return n(this,Pi,`f`)}async finalRunSteps(){return await this.done(),Object.values(n(this,Y,`f`))}async finalMessages(){return await this.done(),Object.values(n(this,Di,`f`))}async finalRun(){if(await this.done(),!n(this,Oi,`f`))throw Error(`Final run was not received.`);return n(this,Oi,`f`)}async _createThreadAssistantStream(e,t,r){let i=r?.signal;i&&(i.aborted&&this.controller.abort(),i.addEventListener(`abort`,()=>this.controller.abort()));let a={...t,stream:!0},o=await e.createAndRun(a,{...r,signal:this.controller.signal});this._connected();for await(let e of o)n(this,J,`m`,Fi).call(this,e);if(o.controller.signal?.aborted)throw new d;return this._addRun(n(this,J,`m`,Ii).call(this))}async _createAssistantStream(e,t,r,i){let a=i?.signal;a&&(a.aborted&&this.controller.abort(),a.addEventListener(`abort`,()=>this.controller.abort()));let o={...r,stream:!0},s=await e.create(t,o,{...i,signal:this.controller.signal});this._connected();for await(let e of s)n(this,J,`m`,Fi).call(this,e);if(s.controller.signal?.aborted)throw new d;return this._addRun(n(this,J,`m`,Ii).call(this))}static accumulateDelta(e,t){for(let[n,r]of Object.entries(t)){if(!e.hasOwnProperty(n)){e[n]=r;continue}let t=e[n];if(t==null){e[n]=r;continue}if(n===`index`||n===`type`){e[n]=r;continue}if(typeof t==`string`&&typeof r==`string`)t+=r;else if(typeof t==`number`&&typeof r==`number`)t+=r;else if(se(t)&&se(r))t=this.accumulateDelta(t,r);else if(Array.isArray(t)&&Array.isArray(r)){if(t.every(e=>typeof e==`string`||typeof e==`number`)){t.push(...r);continue}for(let e of r){if(!se(e))throw Error(`Expected array delta entry to be an object but got: ${e}`);let n=e.index;if(n==null)throw console.error(e),Error("Expected array delta entry to have an `index` property");if(typeof n!=`number`)throw Error(`Expected array delta entry \`index\` property to be a number but got ${n}`);let r=t[n];r==null?t.push(e):t[n]=this.accumulateDelta(r,e)}continue}else throw Error(`Unhandled record type: ${n}, deltaValue: ${r}, accValue: ${t}`);e[n]=t}return e}_addRun(e){return e}async _threadAssistantStream(e,t,n){return await this._createThreadAssistantStream(t,e,n)}async _runAssistantStream(e,t,n,r){return await this._createAssistantStream(t,e,n,r)}async _runToolAssistantStream(e,t,n,r){return await this._createToolAssistantStream(t,e,n,r)}},Ti=Wi,Fi=function(e){if(!this.ended)switch(t(this,Mi,e,`f`),n(this,J,`m`,zi).call(this,e),e.event){case`thread.created`:break;case`thread.run.created`:case`thread.run.queued`:case`thread.run.in_progress`:case`thread.run.requires_action`:case`thread.run.completed`:case`thread.run.incomplete`:case`thread.run.failed`:case`thread.run.cancelling`:case`thread.run.cancelled`:case`thread.run.expired`:n(this,J,`m`,Ui).call(this,e);break;case`thread.run.step.created`:case`thread.run.step.in_progress`:case`thread.run.step.delta`:case`thread.run.step.completed`:case`thread.run.step.failed`:case`thread.run.step.cancelled`:case`thread.run.step.expired`:n(this,J,`m`,Ri).call(this,e);break;case`thread.message.created`:case`thread.message.in_progress`:case`thread.message.delta`:case`thread.message.completed`:case`thread.message.incomplete`:n(this,J,`m`,Li).call(this,e);break;case`error`:throw Error(`Encountered an error event in event processing - errors should be processed earlier`);default:}},Ii=function(){if(this.ended)throw new l(`stream has ended, this shouldn't happen`);if(!n(this,Oi,`f`))throw Error(`Final run has not been received`);return n(this,Oi,`f`)},Li=function(e){let[r,i]=n(this,J,`m`,Vi).call(this,e,n(this,X,`f`));t(this,X,r,`f`),n(this,Di,`f`)[r.id]=r;for(let e of i){let t=r.content[e.index];t?.type==`text`&&this._emit(`textCreated`,t.text)}switch(e.event){case`thread.message.created`:this._emit(`messageCreated`,e.data);break;case`thread.message.in_progress`:break;case`thread.message.delta`:if(this._emit(`messageDelta`,e.data.delta,r),e.data.delta.content)for(let i of e.data.delta.content){if(i.type==`text`&&i.text){let e=i.text,t=r.content[i.index];if(t&&t.type==`text`)this._emit(`textDelta`,e,t.text);else throw Error(`The snapshot associated with this text delta is not text or missing`)}if(i.index!=n(this,ki,`f`)){if(n(this,Ai,`f`))switch(n(this,Ai,`f`).type){case`text`:this._emit(`textDone`,n(this,Ai,`f`).text,n(this,X,`f`));break;case`image_file`:this._emit(`imageFileDone`,n(this,Ai,`f`).image_file,n(this,X,`f`));break}t(this,ki,i.index,`f`)}t(this,Ai,r.content[i.index],`f`)}break;case`thread.message.completed`:case`thread.message.incomplete`:if(n(this,ki,`f`)!==void 0){let t=e.data.content[n(this,ki,`f`)];if(t)switch(t.type){case`image_file`:this._emit(`imageFileDone`,t.image_file,n(this,X,`f`));break;case`text`:this._emit(`textDone`,t.text,n(this,X,`f`));break}}n(this,X,`f`)&&this._emit(`messageDone`,e.data),t(this,X,void 0,`f`)}},Ri=function(e){let r=n(this,J,`m`,Bi).call(this,e);switch(t(this,Pi,r,`f`),e.event){case`thread.run.step.created`:this._emit(`runStepCreated`,e.data);break;case`thread.run.step.delta`:let i=e.data.delta;if(i.step_details&&i.step_details.type==`tool_calls`&&i.step_details.tool_calls&&r.step_details.type==`tool_calls`)for(let e of i.step_details.tool_calls)e.index==n(this,ji,`f`)?this._emit(`toolCallDelta`,e,r.step_details.tool_calls[e.index]):(n(this,Z,`f`)&&this._emit(`toolCallDone`,n(this,Z,`f`)),t(this,ji,e.index,`f`),t(this,Z,r.step_details.tool_calls[e.index],`f`),n(this,Z,`f`)&&this._emit(`toolCallCreated`,n(this,Z,`f`)));this._emit(`runStepDelta`,e.data.delta,r);break;case`thread.run.step.completed`:case`thread.run.step.failed`:case`thread.run.step.cancelled`:case`thread.run.step.expired`:t(this,Pi,void 0,`f`),e.data.step_details.type==`tool_calls`&&n(this,Z,`f`)&&(this._emit(`toolCallDone`,n(this,Z,`f`)),t(this,Z,void 0,`f`)),this._emit(`runStepDone`,e.data,r);break;case`thread.run.step.in_progress`:break}},zi=function(e){n(this,Ei,`f`).push(e),this._emit(`event`,e)},Bi=function(e){switch(e.event){case`thread.run.step.created`:return n(this,Y,`f`)[e.data.id]=e.data,e.data;case`thread.run.step.delta`:let t=n(this,Y,`f`)[e.data.id];if(!t)throw Error(`Received a RunStepDelta before creation of a snapshot`);let r=e.data;if(r.delta){let i=Ti.accumulateDelta(t,r.delta);n(this,Y,`f`)[e.data.id]=i}return n(this,Y,`f`)[e.data.id];case`thread.run.step.completed`:case`thread.run.step.failed`:case`thread.run.step.cancelled`:case`thread.run.step.expired`:case`thread.run.step.in_progress`:n(this,Y,`f`)[e.data.id]=e.data;break}if(n(this,Y,`f`)[e.data.id])return n(this,Y,`f`)[e.data.id];throw Error(`No snapshot available`)},Vi=function(e,t){let r=[];switch(e.event){case`thread.message.created`:return[e.data,r];case`thread.message.delta`:if(!t)throw Error(`Received a delta with no existing snapshot (there should be one from message creation)`);let i=e.data;if(i.delta.content)for(let e of i.delta.content)if(e.index in t.content){let r=t.content[e.index];t.content[e.index]=n(this,J,`m`,Hi).call(this,e,r)}else t.content[e.index]=e,r.push(e);return[t,r];case`thread.message.in_progress`:case`thread.message.completed`:case`thread.message.incomplete`:if(t)return[t,r];throw Error(`Received thread message event with no existing snapshot`)}throw Error(`Tried to accumulate a non-message event`)},Hi=function(e,t){return Ti.accumulateDelta(t,e)},Ui=function(e){switch(t(this,Ni,e.data,`f`),e.event){case`thread.run.created`:break;case`thread.run.queued`:break;case`thread.run.in_progress`:break;case`thread.run.requires_action`:case`thread.run.cancelled`:case`thread.run.failed`:case`thread.run.completed`:case`thread.run.expired`:case`thread.run.incomplete`:t(this,Oi,e.data,`f`),n(this,Z,`f`)&&(this._emit(`toolCallDone`,n(this,Z,`f`)),t(this,Z,void 0,`f`));break;case`thread.run.cancelling`:break}}})),Ki,qi=e((()=>{I(),yi(),M(),q(),Gi(),he(),R(),Ki=class extends F{constructor(){super(...arguments),this.steps=new vi(this._client)}create(e,t,n){let{include:r,...i}=t;return this._client.post(L`/threads/${e}/runs`,{query:{include:r},body:i,...n,headers:K([{"OpenAI-Beta":`assistants=v2`},n?.headers]),stream:t.stream??!1,__synthesizeEventData:!0})}retrieve(e,t,n){let{thread_id:r}=t;return this._client.get(L`/threads/${r}/runs/${e}`,{...n,headers:K([{"OpenAI-Beta":`assistants=v2`},n?.headers])})}update(e,t,n){let{thread_id:r,...i}=t;return this._client.post(L`/threads/${r}/runs/${e}`,{body:i,...n,headers:K([{"OpenAI-Beta":`assistants=v2`},n?.headers])})}list(e,t={},n){return this._client.getAPIList(L`/threads/${e}/runs`,j,{query:t,...n,headers:K([{"OpenAI-Beta":`assistants=v2`},n?.headers])})}cancel(e,t,n){let{thread_id:r}=t;return this._client.post(L`/threads/${r}/runs/${e}/cancel`,{...n,headers:K([{"OpenAI-Beta":`assistants=v2`},n?.headers])})}async createAndPoll(e,t,n){let r=await this.create(e,t,n);return await this.poll(r.id,{thread_id:e},n)}createAndStream(e,t,n){return Wi.createAssistantStream(e,this._client.beta.threads.runs,t,n)}async poll(e,t,n){let r=K([n?.headers,{"X-Stainless-Poll-Helper":`true`,"X-Stainless-Custom-Poll-Interval":n?.pollIntervalMs?.toString()??void 0}]);for(;;){let{data:i,response:a}=await this.retrieve(e,t,{...n,headers:{...n?.headers,...r}}).withResponse();switch(i.status){case`queued`:case`in_progress`:case`cancelling`:let e=5e3;if(n?.pollIntervalMs)e=n.pollIntervalMs;else{let t=a.headers.get(`openai-poll-after-ms`);if(t){let n=parseInt(t);isNaN(n)||(e=n)}}await me(e);break;case`requires_action`:case`incomplete`:case`cancelled`:case`completed`:case`failed`:case`expired`:return i}}}stream(e,t,n){return Wi.createAssistantStream(e,this._client.beta.threads.runs,t,n)}submitToolOutputs(e,t,n){let{thread_id:r,...i}=t;return this._client.post(L`/threads/${r}/runs/${e}/submit_tool_outputs`,{body:i,...n,headers:K([{"OpenAI-Beta":`assistants=v2`},n?.headers]),stream:t.stream??!1,__synthesizeEventData:!0})}async submitToolOutputsAndPoll(e,t,n){let r=await this.submitToolOutputs(e,t,n);return await this.poll(r.id,t,n)}submitToolOutputsStream(e,t,n){return Wi.createToolAssistantStream(e,this._client.beta.threads.runs,t,n)}},Ki.Steps=vi})),Ji,Yi=e((()=>{I(),_i(),qi(),q(),Gi(),R(),Ji=class extends F{constructor(){super(...arguments),this.runs=new Ki(this._client),this.messages=new gi(this._client)}create(e={},t){return this._client.post(`/threads`,{body:e,...t,headers:K([{"OpenAI-Beta":`assistants=v2`},t?.headers])})}retrieve(e,t){return this._client.get(L`/threads/${e}`,{...t,headers:K([{"OpenAI-Beta":`assistants=v2`},t?.headers])})}update(e,t,n){return this._client.post(L`/threads/${e}`,{body:t,...n,headers:K([{"OpenAI-Beta":`assistants=v2`},n?.headers])})}delete(e,t){return this._client.delete(L`/threads/${e}`,{...t,headers:K([{"OpenAI-Beta":`assistants=v2`},t?.headers])})}createAndRun(e,t){return this._client.post(`/threads/runs`,{body:e,...t,headers:K([{"OpenAI-Beta":`assistants=v2`},t?.headers]),stream:e.stream??!1,__synthesizeEventData:!0})}async createAndRunPoll(e,t){let n=await this.createAndRun(e,t);return await this.runs.poll(n.id,{thread_id:n.thread_id},t)}createAndRunStream(e,t){return Wi.createThreadAssistantStream(e,this._client.beta.threads,t)}},Ji.Runs=Ki,Ji.Messages=gi})),Xi,Zi=e((()=>{I(),ri(),li(),hi(),Yi(),Xi=class extends F{constructor(){super(...arguments),this.realtime=new ci(this._client),this.chatkit=new mi(this._client),this.assistants=new ni(this._client),this.threads=new Ji(this._client)}},Xi.Realtime=ci,Xi.ChatKit=mi,Xi.Assistants=ni,Xi.Threads=Ji})),Qi,$i=e((()=>{I(),Qi=class extends F{create(e,t){return this._client.post(`/completions`,{body:e,...t,stream:e.stream??!1})}}})),ea,ta=e((()=>{I(),q(),R(),ea=class extends F{retrieve(e,t,n){let{container_id:r}=t;return this._client.get(L`/containers/${r}/files/${e}/content`,{...n,headers:K([{Accept:`application/binary`},n?.headers]),__binaryResponse:!0})}}})),na,ra=e((()=>{I(),ta(),M(),q(),P(),R(),na=class extends F{constructor(){super(...arguments),this.content=new ea(this._client)}create(e,t,n){return this._client.post(L`/containers/${e}/files`,Kt({body:t,...n},this._client))}retrieve(e,t,n){let{container_id:r}=t;return this._client.get(L`/containers/${r}/files/${e}`,n)}list(e,t={},n){return this._client.getAPIList(L`/containers/${e}/files`,j,{query:t,...n})}delete(e,t,n){let{container_id:r}=t;return this._client.delete(L`/containers/${r}/files/${e}`,{...n,headers:K([{Accept:`*/*`},n?.headers])})}},na.Content=ea})),ia,aa=e((()=>{I(),ra(),M(),q(),R(),ia=class extends F{constructor(){super(...arguments),this.files=new na(this._client)}create(e,t){return this._client.post(`/containers`,{body:e,...t})}retrieve(e,t){return this._client.get(L`/containers/${e}`,t)}list(e={},t){return this._client.getAPIList(`/containers`,j,{query:e,...t})}delete(e,t){return this._client.delete(L`/containers/${e}`,{...t,headers:K([{Accept:`*/*`},t?.headers])})}},ia.Files=na})),oa,sa=e((()=>{I(),M(),R(),oa=class extends F{create(e,t,n){let{include:r,...i}=t;return this._client.post(L`/conversations/${e}/items`,{query:{include:r},body:i,...n})}retrieve(e,t,n){let{conversation_id:r,...i}=t;return this._client.get(L`/conversations/${r}/items/${e}`,{query:i,...n})}list(e,t={},n){return this._client.getAPIList(L`/conversations/${e}/items`,It,{query:t,...n})}delete(e,t,n){let{conversation_id:r}=t;return this._client.delete(L`/conversations/${r}/items/${e}`,n)}}})),ca,la=e((()=>{I(),sa(),R(),ca=class extends F{constructor(){super(...arguments),this.items=new oa(this._client)}create(e={},t){return this._client.post(`/conversations`,{body:e,...t})}retrieve(e,t){return this._client.get(L`/conversations/${e}`,t)}update(e,t,n){return this._client.post(L`/conversations/${e}`,{body:t,...n})}delete(e,t){return this._client.delete(L`/conversations/${e}`,t)}},ca.Items=oa})),ua,da=e((()=>{I(),wi(),ua=class extends F{create(e,t){let n=!!e.encoding_format,r=n?e.encoding_format:`base64`;n&&k(this._client).debug(`embeddings/user defined encoding_format:`,e.encoding_format);let i=this._client.post(`/embeddings`,{body:{...e,encoding_format:r},...t});return n?i:(k(this._client).debug(`embeddings/decoding base64 embeddings from base64`),i._thenUnwrap(e=>(e&&e.data&&e.data.forEach(e=>{let t=e.embedding;e.embedding=bi(t)}),e)))}}})),fa,pa=e((()=>{I(),M(),R(),fa=class extends F{retrieve(e,t,n){let{eval_id:r,run_id:i}=t;return this._client.get(L`/evals/${r}/runs/${i}/output_items/${e}`,n)}list(e,t,n){let{eval_id:r,...i}=t;return this._client.getAPIList(L`/evals/${r}/runs/${e}/output_items`,j,{query:i,...n})}}})),ma,ha=e((()=>{I(),pa(),M(),R(),ma=class extends F{constructor(){super(...arguments),this.outputItems=new fa(this._client)}create(e,t,n){return this._client.post(L`/evals/${e}/runs`,{body:t,...n})}retrieve(e,t,n){let{eval_id:r}=t;return this._client.get(L`/evals/${r}/runs/${e}`,n)}list(e,t={},n){return this._client.getAPIList(L`/evals/${e}/runs`,j,{query:t,...n})}delete(e,t,n){let{eval_id:r}=t;return this._client.delete(L`/evals/${r}/runs/${e}`,n)}cancel(e,t,n){let{eval_id:r}=t;return this._client.post(L`/evals/${r}/runs/${e}`,n)}},ma.OutputItems=fa})),ga,_a=e((()=>{I(),ha(),M(),R(),ga=class extends F{constructor(){super(...arguments),this.runs=new ma(this._client)}create(e,t){return this._client.post(`/evals`,{body:e,...t})}retrieve(e,t){return this._client.get(L`/evals/${e}`,t)}update(e,t,n){return this._client.post(L`/evals/${e}`,{body:t,...n})}list(e={},t){return this._client.getAPIList(`/evals`,j,{query:e,...t})}delete(e,t){return this._client.delete(L`/evals/${e}`,t)}},ga.Runs=ma})),va,ya=e((()=>{I(),M(),q(),he(),z(),P(),R(),va=class extends F{create(e,t){return this._client.post(`/files`,N({body:e,...t},this._client))}retrieve(e,t){return this._client.get(L`/files/${e}`,t)}list(e={},t){return this._client.getAPIList(`/files`,j,{query:e,...t})}delete(e,t){return this._client.delete(L`/files/${e}`,t)}content(e,t){return this._client.get(L`/files/${e}/content`,{...t,headers:K([{Accept:`application/binary`},t?.headers]),__binaryResponse:!0})}async waitForProcessing(e,{pollInterval:t=5e3,maxWait:n=1800*1e3}={}){let r=new Set([`processed`,`error`,`deleted`]),i=Date.now(),a=await this.retrieve(e);for(;!a.status||!r.has(a.status);)if(await me(t),a=await this.retrieve(e),Date.now()-i>n)throw new p({message:`Giving up on waiting for file ${e} to finish processing after ${n} milliseconds.`});return a}}})),ba,xa=e((()=>{I(),ba=class extends F{}})),Sa,Ca=e((()=>{I(),Sa=class extends F{run(e,t){return this._client.post(`/fine_tuning/alpha/graders/run`,{body:e,...t})}validate(e,t){return this._client.post(`/fine_tuning/alpha/graders/validate`,{body:e,...t})}}})),wa,Ta=e((()=>{I(),Ca(),wa=class extends F{constructor(){super(...arguments),this.graders=new Sa(this._client)}},wa.Graders=Sa})),Ea,Da=e((()=>{I(),M(),R(),Ea=class extends F{create(e,t,n){return this._client.getAPIList(L`/fine_tuning/checkpoints/${e}/permissions`,Ft,{body:t,method:`post`,...n})}retrieve(e,t={},n){return this._client.get(L`/fine_tuning/checkpoints/${e}/permissions`,{query:t,...n})}list(e,t={},n){return this._client.getAPIList(L`/fine_tuning/checkpoints/${e}/permissions`,It,{query:t,...n})}delete(e,t,n){let{fine_tuned_model_checkpoint:r}=t;return this._client.delete(L`/fine_tuning/checkpoints/${r}/permissions/${e}`,n)}}})),Oa,ka=e((()=>{I(),Da(),Oa=class extends F{constructor(){super(...arguments),this.permissions=new Ea(this._client)}},Oa.Permissions=Ea})),Aa,ja=e((()=>{I(),M(),R(),Aa=class extends F{list(e,t={},n){return this._client.getAPIList(L`/fine_tuning/jobs/${e}/checkpoints`,j,{query:t,...n})}}})),Ma,Na=e((()=>{I(),ja(),M(),R(),Ma=class extends F{constructor(){super(...arguments),this.checkpoints=new Aa(this._client)}create(e,t){return this._client.post(`/fine_tuning/jobs`,{body:e,...t})}retrieve(e,t){return this._client.get(L`/fine_tuning/jobs/${e}`,t)}list(e={},t){return this._client.getAPIList(`/fine_tuning/jobs`,j,{query:e,...t})}cancel(e,t){return this._client.post(L`/fine_tuning/jobs/${e}/cancel`,t)}listEvents(e,t={},n){return this._client.getAPIList(L`/fine_tuning/jobs/${e}/events`,j,{query:t,...n})}pause(e,t){return this._client.post(L`/fine_tuning/jobs/${e}/pause`,t)}resume(e,t){return this._client.post(L`/fine_tuning/jobs/${e}/resume`,t)}},Ma.Checkpoints=Aa})),Pa,Fa=e((()=>{I(),xa(),Ta(),ka(),Na(),Pa=class extends F{constructor(){super(...arguments),this.methods=new ba(this._client),this.jobs=new Ma(this._client),this.checkpoints=new Oa(this._client),this.alpha=new wa(this._client)}},Pa.Methods=ba,Pa.Jobs=Ma,Pa.Checkpoints=Oa,Pa.Alpha=wa})),Ia,La=e((()=>{I(),Ia=class extends F{}})),Ra,za=e((()=>{I(),La(),Ra=class extends F{constructor(){super(...arguments),this.graderModels=new Ia(this._client)}},Ra.GraderModels=Ia})),Ba,Va=e((()=>{I(),P(),Ba=class extends F{createVariation(e,t){return this._client.post(`/images/variations`,N({body:e,...t},this._client))}edit(e,t){return this._client.post(`/images/edits`,N({body:e,...t,stream:e.stream??!1},this._client))}generate(e,t){return this._client.post(`/images/generations`,{body:e,...t,stream:e.stream??!1})}}})),Ha,Ua=e((()=>{I(),M(),R(),Ha=class extends F{retrieve(e,t){return this._client.get(L`/models/${e}`,t)}list(e){return this._client.getAPIList(`/models`,Ft,e)}delete(e,t){return this._client.delete(L`/models/${e}`,t)}}})),Wa,Ga=e((()=>{I(),Wa=class extends F{create(e,t){return this._client.post(`/moderations`,{body:e,...t})}}})),Ka,qa=e((()=>{I(),q(),R(),Ka=class extends F{accept(e,t,n){return this._client.post(L`/realtime/calls/${e}/accept`,{body:t,...n,headers:K([{Accept:`*/*`},n?.headers])})}hangup(e,t){return this._client.post(L`/realtime/calls/${e}/hangup`,{...t,headers:K([{Accept:`*/*`},t?.headers])})}refer(e,t,n){return this._client.post(L`/realtime/calls/${e}/refer`,{body:t,...n,headers:K([{Accept:`*/*`},n?.headers])})}reject(e,t={},n){return this._client.post(L`/realtime/calls/${e}/reject`,{body:t,...n,headers:K([{Accept:`*/*`},n?.headers])})}}})),Ja,Ya=e((()=>{I(),Ja=class extends F{create(e,t){return this._client.post(`/realtime/client_secrets`,{body:e,...t})}}})),Xa,Za=e((()=>{I(),qa(),Ya(),Xa=class extends F{constructor(){super(...arguments),this.clientSecrets=new Ja(this._client),this.calls=new Ka(this._client)}},Xa.ClientSecrets=Ja,Xa.Calls=Ka}));function Qa(e,t){return!t||!to(t)?{...e,output_parsed:null,output:e.output.map(e=>e.type===`function_call`?{...e,parsed_arguments:null}:e.type===`message`?{...e,content:e.content.map(e=>({...e,parsed:null}))}:e)}:$a(e,t)}function $a(e,t){let n=e.output.map(e=>{if(e.type===`function_call`)return{...e,parsed_arguments:io(t,e)};if(e.type===`message`){let n=e.content.map(e=>e.type===`output_text`?{...e,parsed:eo(t,e.text)}:e);return{...e,content:n}}return e}),r=Object.assign({},e,{output:n});return Object.getOwnPropertyDescriptor(e,`output_text`)||ao(r),Object.defineProperty(r,`output_parsed`,{enumerable:!0,get(){for(let e of r.output)if(e.type===`message`){for(let t of e.content)if(t.type===`output_text`&&t.parsed!==null)return t.parsed}return null}}),r}function eo(e,t){return e.text?.format?.type===`json_schema`?`$parseRaw`in e.text?.format?(e.text?.format).$parseRaw(t):JSON.parse(t):null}function to(e){return!!mn(e.text?.format)}function no(e){return e?.$brand===`auto-parseable-tool`}function ro(e,t){return e.find(e=>e.type===`function`&&e.name===t)}function io(e,t){let n=ro(e.tools??[],t.name);return{...t,...t,parsed_arguments:no(n)?n.$parseRaw(t.arguments):n?.strict?JSON.parse(t.arguments):null}}function ao(e){let t=[];for(let n of e.output)if(n.type===`message`)for(let e of n.content)e.type===`output_text`&&t.push(e.text);e.output_text=t.join(``)}var oo=e((()=>{z(),wn()}));function so(e,t){return Qa(e,t)}var co,lo,Q,uo,fo,po,mo,ho,go,_o=e((()=>{r(),z(),Vn(),oo(),go=class e extends Bn{constructor(e){super(),co.add(this),lo.set(this,void 0),Q.set(this,void 0),uo.set(this,void 0),t(this,lo,e,`f`)}static createResponse(t,n,r){let i=new e(n);return i._run(()=>i._createOrRetrieveResponse(t,n,{...r,headers:{...r?.headers,"X-Stainless-Helper-Method":`stream`}})),i}async _createOrRetrieveResponse(e,t,r){let i=r?.signal;i&&(i.aborted&&this.controller.abort(),i.addEventListener(`abort`,()=>this.controller.abort())),n(this,co,`m`,fo).call(this);let a,o=null;`response_id`in t?(a=await e.responses.retrieve(t.response_id,{stream:!0},{...r,signal:this.controller.signal,stream:!0}),o=t.starting_after??null):a=await e.responses.create({...t,stream:!0},{...r,signal:this.controller.signal}),this._connected();for await(let e of a)n(this,co,`m`,po).call(this,e,o);if(a.controller.signal?.aborted)throw new d;return n(this,co,`m`,mo).call(this)}[(lo=new WeakMap,Q=new WeakMap,uo=new WeakMap,co=new WeakSet,fo=function(){this.ended||t(this,Q,void 0,`f`)},po=function(e,t){if(this.ended)return;let r=(e,n)=>{(t==null||n.sequence_number>t)&&this._emit(e,n)},i=n(this,co,`m`,ho).call(this,e);switch(r(`event`,e),e.type){case`response.output_text.delta`:{let t=i.output[e.output_index];if(!t)throw new l(`missing output at index ${e.output_index}`);if(t.type===`message`){let n=t.content[e.content_index];if(!n)throw new l(`missing content at index ${e.content_index}`);if(n.type!==`output_text`)throw new l(`expected content to be 'output_text', got ${n.type}`);r(`response.output_text.delta`,{...e,snapshot:n.text})}break}case`response.function_call_arguments.delta`:{let t=i.output[e.output_index];if(!t)throw new l(`missing output at index ${e.output_index}`);t.type===`function_call`&&r(`response.function_call_arguments.delta`,{...e,snapshot:t.arguments});break}default:r(e.type,e);break}},mo=function(){if(this.ended)throw new l(`stream has ended, this shouldn't happen`);let e=n(this,Q,`f`);if(!e)throw new l(`request ended without sending any events`);t(this,Q,void 0,`f`);let r=so(e,n(this,lo,`f`));return t(this,uo,r,`f`),r},ho=function(e){let r=n(this,Q,`f`);if(!r){if(e.type!==`response.created`)throw new l(`When snapshot hasn't been set yet, expected 'response.created' event, got ${e.type}`);return r=t(this,Q,e.response,`f`),r}switch(e.type){case`response.output_item.added`:r.output.push(e.item);break;case`response.content_part.added`:{let t=r.output[e.output_index];if(!t)throw new l(`missing output at index ${e.output_index}`);let n=t.type,i=e.part;n===`message`&&i.type!==`reasoning_text`?t.content.push(i):n===`reasoning`&&i.type===`reasoning_text`&&(t.content||(t.content=[]),t.content.push(i));break}case`response.output_text.delta`:{let t=r.output[e.output_index];if(!t)throw new l(`missing output at index ${e.output_index}`);if(t.type===`message`){let n=t.content[e.content_index];if(!n)throw new l(`missing content at index ${e.content_index}`);if(n.type!==`output_text`)throw new l(`expected content to be 'output_text', got ${n.type}`);n.text+=e.delta}break}case`response.function_call_arguments.delta`:{let t=r.output[e.output_index];if(!t)throw new l(`missing output at index ${e.output_index}`);t.type===`function_call`&&(t.arguments+=e.delta);break}case`response.reasoning_text.delta`:{let t=r.output[e.output_index];if(!t)throw new l(`missing output at index ${e.output_index}`);if(t.type===`reasoning`){let n=t.content?.[e.content_index];if(!n)throw new l(`missing content at index ${e.content_index}`);if(n.type!==`reasoning_text`)throw new l(`expected content to be 'reasoning_text', got ${n.type}`);n.text+=e.delta}break}case`response.completed`:t(this,Q,e.response,`f`);break}return r},Symbol.asyncIterator)](){let e=[],t=[],n=!1;return this.on(`event`,n=>{let r=t.shift();r?r.resolve(n):e.push(n)}),this.on(`end`,()=>{n=!0;for(let e of t)e.resolve(void 0);t.length=0}),this.on(`abort`,e=>{n=!0;for(let n of t)n.reject(e);t.length=0}),this.on(`error`,e=>{n=!0;for(let n of t)n.reject(e);t.length=0}),{next:async()=>e.length?{value:e.shift(),done:!1}:n?{value:void 0,done:!0}:new Promise((e,n)=>t.push({resolve:e,reject:n})).then(e=>e?{value:e,done:!1}:{value:void 0,done:!0}),return:async()=>(this.abort(),{value:void 0,done:!0})}}async finalResponse(){await this.done();let e=n(this,uo,`f`);if(!e)throw new l(`stream ended without producing a ChatCompletion`);return e}}})),vo,yo=e((()=>{I(),M(),R(),vo=class extends F{list(e,t={},n){return this._client.getAPIList(L`/responses/${e}/input_items`,j,{query:t,...n})}}})),bo,xo=e((()=>{I(),bo=class extends F{count(e={},t){return this._client.post(`/responses/input_tokens`,{body:e,...t})}}})),So,Co=e((()=>{oo(),_o(),I(),yo(),xo(),q(),R(),So=class extends F{constructor(){super(...arguments),this.inputItems=new vo(this._client),this.inputTokens=new bo(this._client)}create(e,t){return this._client.post(`/responses`,{body:e,...t,stream:e.stream??!1})._thenUnwrap(e=>(`object`in e&&e.object===`response`&&ao(e),e))}retrieve(e,t={},n){return this._client.get(L`/responses/${e}`,{query:t,...n,stream:t?.stream??!1})._thenUnwrap(e=>(`object`in e&&e.object===`response`&&ao(e),e))}delete(e,t){return this._client.delete(L`/responses/${e}`,{...t,headers:K([{Accept:`*/*`},t?.headers])})}parse(e,t){return this._client.responses.create(e,t)._thenUnwrap(t=>$a(t,e))}stream(e,t){return go.createResponse(this._client,e,t)}cancel(e,t){return this._client.post(L`/responses/${e}/cancel`,t)}compact(e,t){return this._client.post(`/responses/compact`,{body:e,...t})}},So.InputItems=vo,So.InputTokens=bo})),wo,To=e((()=>{I(),q(),R(),wo=class extends F{retrieve(e,t){return this._client.get(L`/skills/${e}/content`,{...t,headers:K([{Accept:`application/binary`},t?.headers]),__binaryResponse:!0})}}})),Eo,Do=e((()=>{I(),q(),R(),Eo=class extends F{retrieve(e,t,n){let{skill_id:r}=t;return this._client.get(L`/skills/${r}/versions/${e}/content`,{...n,headers:K([{Accept:`application/binary`},n?.headers]),__binaryResponse:!0})}}})),Oo,ko=e((()=>{I(),Do(),M(),P(),R(),Oo=class extends F{constructor(){super(...arguments),this.content=new Eo(this._client)}create(e,t={},n){return this._client.post(L`/skills/${e}/versions`,Kt({body:t,...n},this._client))}retrieve(e,t,n){let{skill_id:r}=t;return this._client.get(L`/skills/${r}/versions/${e}`,n)}list(e,t={},n){return this._client.getAPIList(L`/skills/${e}/versions`,j,{query:t,...n})}delete(e,t,n){let{skill_id:r}=t;return this._client.delete(L`/skills/${r}/versions/${e}`,n)}},Oo.Content=Eo})),Ao,jo=e((()=>{I(),To(),ko(),M(),P(),R(),Ao=class extends F{constructor(){super(...arguments),this.content=new wo(this._client),this.versions=new Oo(this._client)}create(e={},t){return this._client.post(`/skills`,Kt({body:e,...t},this._client))}retrieve(e,t){return this._client.get(L`/skills/${e}`,t)}update(e,t,n){return this._client.post(L`/skills/${e}`,{body:t,...n})}list(e={},t){return this._client.getAPIList(`/skills`,j,{query:e,...t})}delete(e,t){return this._client.delete(L`/skills/${e}`,t)}},Ao.Content=wo,Ao.Versions=Oo})),Mo,No=e((()=>{I(),P(),R(),Mo=class extends F{create(e,t,n){return this._client.post(L`/uploads/${e}/parts`,N({body:t,...n},this._client))}}})),Po,Fo=e((()=>{I(),No(),R(),Po=class extends F{constructor(){super(...arguments),this.parts=new Mo(this._client)}create(e,t){return this._client.post(`/uploads`,{body:e,...t})}cancel(e,t){return this._client.post(L`/uploads/${e}/cancel`,t)}complete(e,t,n){return this._client.post(L`/uploads/${e}/complete`,{body:t,...n})}},Po.Parts=Mo})),Io,Lo=e((()=>{Io=async e=>{let t=await Promise.allSettled(e),n=t.filter(e=>e.status===`rejected`);if(n.length){for(let e of n)console.error(e.reason);throw Error(`${n.length} promise(s) failed - see the above errors`)}let r=[];for(let e of t)e.status===`fulfilled`&&r.push(e.value);return r}})),Ro,zo=e((()=>{I(),M(),q(),he(),Lo(),R(),Ro=class extends F{create(e,t,n){return this._client.post(L`/vector_stores/${e}/file_batches`,{body:t,...n,headers:K([{"OpenAI-Beta":`assistants=v2`},n?.headers])})}retrieve(e,t,n){let{vector_store_id:r}=t;return this._client.get(L`/vector_stores/${r}/file_batches/${e}`,{...n,headers:K([{"OpenAI-Beta":`assistants=v2`},n?.headers])})}cancel(e,t,n){let{vector_store_id:r}=t;return this._client.post(L`/vector_stores/${r}/file_batches/${e}/cancel`,{...n,headers:K([{"OpenAI-Beta":`assistants=v2`},n?.headers])})}async createAndPoll(e,t,n){let r=await this.create(e,t);return await this.poll(e,r.id,n)}listFiles(e,t,n){let{vector_store_id:r,...i}=t;return this._client.getAPIList(L`/vector_stores/${r}/file_batches/${e}/files`,j,{query:i,...n,headers:K([{"OpenAI-Beta":`assistants=v2`},n?.headers])})}async poll(e,t,n){let r=K([n?.headers,{"X-Stainless-Poll-Helper":`true`,"X-Stainless-Custom-Poll-Interval":n?.pollIntervalMs?.toString()??void 0}]);for(;;){let{data:i,response:a}=await this.retrieve(t,{vector_store_id:e},{...n,headers:r}).withResponse();switch(i.status){case`in_progress`:let e=5e3;if(n?.pollIntervalMs)e=n.pollIntervalMs;else{let t=a.headers.get(`openai-poll-after-ms`);if(t){let n=parseInt(t);isNaN(n)||(e=n)}}await me(e);break;case`failed`:case`cancelled`:case`completed`:return i}}}async uploadAndPoll(e,{files:t,fileIds:n=[]},r){if(t==null||t.length==0)throw Error("No `files` provided to process. If you've already uploaded files you should use `.createAndPoll()` instead");let i=r?.maxConcurrency??5,a=Math.min(i,t.length),o=this._client,s=t.values(),c=[...n];async function l(e){for(let t of e){let e=await o.files.create({file:t,purpose:`assistants`},r);c.push(e.id)}}return await Io(Array(a).fill(s).map(l)),await this.createAndPoll(e,{file_ids:c})}}})),Bo,Vo=e((()=>{I(),M(),q(),wi(),R(),Bo=class extends F{create(e,t,n){return this._client.post(L`/vector_stores/${e}/files`,{body:t,...n,headers:K([{"OpenAI-Beta":`assistants=v2`},n?.headers])})}retrieve(e,t,n){let{vector_store_id:r}=t;return this._client.get(L`/vector_stores/${r}/files/${e}`,{...n,headers:K([{"OpenAI-Beta":`assistants=v2`},n?.headers])})}update(e,t,n){let{vector_store_id:r,...i}=t;return this._client.post(L`/vector_stores/${r}/files/${e}`,{body:i,...n,headers:K([{"OpenAI-Beta":`assistants=v2`},n?.headers])})}list(e,t={},n){return this._client.getAPIList(L`/vector_stores/${e}/files`,j,{query:t,...n,headers:K([{"OpenAI-Beta":`assistants=v2`},n?.headers])})}delete(e,t,n){let{vector_store_id:r}=t;return this._client.delete(L`/vector_stores/${r}/files/${e}`,{...n,headers:K([{"OpenAI-Beta":`assistants=v2`},n?.headers])})}async createAndPoll(e,t,n){let r=await this.create(e,t,n);return await this.poll(e,r.id,n)}async poll(e,t,n){let r=K([n?.headers,{"X-Stainless-Poll-Helper":`true`,"X-Stainless-Custom-Poll-Interval":n?.pollIntervalMs?.toString()??void 0}]);for(;;){let i=await this.retrieve(t,{vector_store_id:e},{...n,headers:r}).withResponse(),a=i.data;switch(a.status){case`in_progress`:let e=5e3;if(n?.pollIntervalMs)e=n.pollIntervalMs;else{let t=i.response.headers.get(`openai-poll-after-ms`);if(t){let n=parseInt(t);isNaN(n)||(e=n)}}await me(e);break;case`failed`:case`completed`:return a}}}async upload(e,t,n){let r=await this._client.files.create({file:t,purpose:`assistants`},n);return this.create(e,{file_id:r.id},n)}async uploadAndPoll(e,t,n){let r=await this.upload(e,t,n);return await this.poll(e,r.id,n)}content(e,t,n){let{vector_store_id:r}=t;return this._client.getAPIList(L`/vector_stores/${r}/files/${e}/content`,Ft,{...n,headers:K([{"OpenAI-Beta":`assistants=v2`},n?.headers])})}}})),Ho,Uo=e((()=>{I(),zo(),Vo(),M(),q(),R(),Ho=class extends F{constructor(){super(...arguments),this.files=new Bo(this._client),this.fileBatches=new Ro(this._client)}create(e,t){return this._client.post(`/vector_stores`,{body:e,...t,headers:K([{"OpenAI-Beta":`assistants=v2`},t?.headers])})}retrieve(e,t){return this._client.get(L`/vector_stores/${e}`,{...t,headers:K([{"OpenAI-Beta":`assistants=v2`},t?.headers])})}update(e,t,n){return this._client.post(L`/vector_stores/${e}`,{body:t,...n,headers:K([{"OpenAI-Beta":`assistants=v2`},n?.headers])})}list(e={},t){return this._client.getAPIList(`/vector_stores`,j,{query:e,...t,headers:K([{"OpenAI-Beta":`assistants=v2`},t?.headers])})}delete(e,t){return this._client.delete(L`/vector_stores/${e}`,{...t,headers:K([{"OpenAI-Beta":`assistants=v2`},t?.headers])})}search(e,t,n){return this._client.getAPIList(L`/vector_stores/${e}/search`,Ft,{body:t,method:`post`,...n,headers:K([{"OpenAI-Beta":`assistants=v2`},n?.headers])})}},Ho.Files=Bo,Ho.FileBatches=Ro})),Wo,Go=e((()=>{I(),M(),q(),P(),R(),Wo=class extends F{create(e,t){return this._client.post(`/videos`,N({body:e,...t},this._client))}retrieve(e,t){return this._client.get(L`/videos/${e}`,t)}list(e={},t){return this._client.getAPIList(`/videos`,It,{query:e,...t})}delete(e,t){return this._client.delete(L`/videos/${e}`,t)}createCharacter(e,t){return this._client.post(`/videos/characters`,N({body:e,...t},this._client))}downloadContent(e,t={},n){return this._client.get(L`/videos/${e}/content`,{query:t,...n,headers:K([{Accept:`application/binary`},n?.headers]),__binaryResponse:!0})}edit(e,t){return this._client.post(`/videos/edits`,N({body:e,...t},this._client))}extend(e,t){return this._client.post(`/videos/extensions`,N({body:e,...t},this._client))}getCharacter(e,t){return this._client.get(L`/videos/characters/${e}`,t)}remix(e,t,n){return this._client.post(L`/videos/${e}/remix`,Kt({body:t,...n},this._client))}}})),Ko,qo,Jo,Yo,Xo=e((()=>{r(),z(),I(),q(),Yo=class extends F{constructor(){super(...arguments),Ko.add(this)}async unwrap(e,t,n=this._client.webhookSecret,r=300){return await this.verifySignature(e,t,n,r),JSON.parse(e)}async verifySignature(e,t,r=this._client.webhookSecret,i=300){if(typeof crypto>`u`||typeof crypto.subtle.importKey!=`function`||typeof crypto.subtle.verify!=`function`)throw Error("Webhook signature verification is only supported when the `crypto` global is defined");n(this,Ko,`m`,qo).call(this,r);let a=K([t]).values,o=n(this,Ko,`m`,Jo).call(this,a,`webhook-signature`),s=n(this,Ko,`m`,Jo).call(this,a,`webhook-timestamp`),c=n(this,Ko,`m`,Jo).call(this,a,`webhook-id`),l=parseInt(s,10);if(isNaN(l))throw new S(`Invalid webhook timestamp format`);let u=Math.floor(Date.now()/1e3);if(u-l>i)throw new S(`Webhook timestamp is too old`);if(l>u+i)throw new S(`Webhook timestamp is too new`);let d=o.split(` `).map(e=>e.startsWith(`v1,`)?e.substring(3):e),f=r.startsWith(`whsec_`)?Buffer.from(r.replace(`whsec_`,``),`base64`):Buffer.from(r,`utf-8`),p=c?`${c}.${s}.${e}`:`${s}.${e}`,m=await crypto.subtle.importKey(`raw`,f,{name:`HMAC`,hash:`SHA-256`},!1,[`verify`]);for(let e of d)try{let t=Buffer.from(e,`base64`);if(await crypto.subtle.verify(`HMAC`,m,t,new TextEncoder().encode(p)))return}catch{continue}throw new S(`The given webhook signature does not match the expected signature`)}},Ko=new WeakSet,qo=function(e){if(typeof e!=`string`||e.length===0)throw Error(`The webhook secret must either be set using the env var, OPENAI_WEBHOOK_SECRET, on the client class, OpenAI({ webhookSecret: '123' }), or passed to this function`)},Jo=function(e,t){if(!e)throw Error(`Headers are required`);let n=e.get(t);if(n==null)throw Error(`Missing required header: ${t}`);return n}})),Zo=e((()=>{Xo()})),Qo=e((()=>{Zo()})),$o=e((()=>{Hr(),Ur(),$r(),ti(),Zi(),$i(),aa(),la(),da(),_a(),ya(),Fa(),za(),Va(),Ua(),Ga(),Za(),Co(),jo(),Fo(),Uo(),Go(),Qo()})),es,ts,ns,rs,is,$,as=e((()=>{r(),a(),pe(),he(),c(),Ee(),Me(),Pe(),tt(),_e(),C(),M(),Bt(),sn(),$o(),jt(),ti(),$i(),da(),ya(),Va(),Ua(),Ga(),Go(),$r(),Zi(),Br(),aa(),la(),_a(),Fa(),za(),Za(),Co(),jo(),Fo(),Uo(),Xo(),q(),Ci(),vt(),is=`workload-identity-auth`,$=class{constructor({baseURL:e=Si(`OPENAI_BASE_URL`),apiKey:n=Si(`OPENAI_API_KEY`),organization:r=Si(`OPENAI_ORG_ID`)??null,project:i=Si(`OPENAI_PROJECT_ID`)??null,webhookSecret:a=Si(`OPENAI_WEBHOOK_SECRET`)??null,workloadIdentity:o,...s}={}){if(es.add(this),ns.set(this,void 0),this.completions=new Qi(this),this.chat=new zr(this),this.embeddings=new ua(this),this.files=new va(this),this.images=new Ba(this),this.audio=new Qr(this),this.moderations=new Wa(this),this.models=new Ha(this),this.fineTuning=new Pa(this),this.graders=new Ra(this),this.vectorStores=new Ho(this),this.webhooks=new Yo(this),this.beta=new Xi(this),this.batches=new ei(this),this.uploads=new Po(this),this.responses=new So(this),this.realtime=new Xa(this),this.conversations=new ca(this),this.evals=new ga(this),this.containers=new ia(this),this.skills=new Ao(this),this.videos=new Wo(this),o){if(n&&n!==is)throw new l("The `apiKey` and `workloadIdentity` arguments are mutually exclusive; only one can be passed at a time.");n=is}else if(n===void 0)throw new l("Missing credentials. Please pass an `apiKey`, `workloadIdentity`, or set the `OPENAI_API_KEY` environment variable.");let c={apiKey:n,organization:r,project:i,webhookSecret:a,workloadIdentity:o,...s,baseURL:e||`https://api.openai.com/v1`};if(!c.dangerouslyAllowBrowser&&be())throw new l(`It looks like you're running in a browser-like environment.
8
+
9
+ This is disabled by default, as it risks exposing your secret API credentials to attackers.
10
+ If you understand the risks and have appropriate mitigations in place,
11
+ you can set the \`dangerouslyAllowBrowser\` option to \`true\`, e.g.,
12
+
13
+ new OpenAI({ apiKey, dangerouslyAllowBrowser: true });
14
+
15
+ https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety
16
+ `);this.baseURL=c.baseURL,this.timeout=c.timeout??ts.DEFAULT_TIMEOUT,this.logger=c.logger??console;let u=`warn`;this.logLevel=u,this.logLevel=ht(c.logLevel,`ClientOptions.logLevel`,this)??ht(Si(`OPENAI_LOG`),`process.env['OPENAI_LOG']`,this)??u,this.fetchOptions=c.fetchOptions,this.maxRetries=c.maxRetries??2,this.fetch=c.fetch??De(),t(this,ns,Ne,`f`),this._options=c,o&&(this._workloadIdentityAuth=new zt(o,this.fetch)),this.apiKey=typeof n==`string`?n:`Missing Key`,this.organization=r,this.project=i,this.webhookSecret=a}withOptions(e){return new this.constructor({...this._options,baseURL:this.baseURL,maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,apiKey:this.apiKey,workloadIdentity:this._options.workloadIdentity,organization:this.organization,project:this.project,webhookSecret:this.webhookSecret,...e})}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:e,nulls:t}){}async authHeaders(e){return K([{Authorization:`Bearer ${this.apiKey}`}])}stringifyQuery(e){return et(e)}getUserAgent(){return`${this.constructor.name}/JS ${ge}`}defaultIdempotencyKey(){return`stainless-node-retry-${i()}`}makeStatusError(e,t,n,r){return u.generate(e,t,n,r)}async _callApiKey(){let e=this._options.apiKey;if(typeof e!=`function`)return!1;let t;try{t=await e()}catch(e){throw e instanceof l?e:new l(`Failed to get token from 'apiKey' function: ${e.message}`,{cause:e})}if(typeof t!=`string`||!t)throw new l(`Expected 'apiKey' function argument to return a string but it returned ${t}`);return this.apiKey=t,!0}buildURL(e,t,r){let i=!n(this,es,`m`,rs).call(this)&&r||this.baseURL,a=le(e)?new URL(e):new URL(i+(i.endsWith(`/`)&&e.startsWith(`/`)?e.slice(1):e)),o=this.defaultQuery(),s=Object.fromEntries(a.searchParams);return(!ae(o)||!ae(s))&&(t={...s,...o,...t}),typeof t==`object`&&t&&!Array.isArray(t)&&(a.search=this.stringifyQuery(t)),a.toString()}async prepareOptions(e){await this._callApiKey()}async prepareRequest(e,{url:t,options:n}){}get(e,t){return this.methodRequest(`get`,e,t)}post(e,t){return this.methodRequest(`post`,e,t)}patch(e,t){return this.methodRequest(`patch`,e,t)}put(e,t){return this.methodRequest(`put`,e,t)}delete(e,t){return this.methodRequest(`delete`,e,t)}methodRequest(e,t,n){return this.request(Promise.resolve(n).then(n=>({method:e,path:t,...n})))}request(e,t=null){return new At(this,this.makeRequest(e,t,void 0))}async makeRequest(e,t,n){let r=await e,i=r.maxRetries??this.maxRetries;t??(t=i),await this.prepareOptions(r);let{req:a,url:c,timeout:l}=await this.buildRequest(r,{retryCount:i-t});await this.prepareRequest(a,{url:c,options:r});let u=`log_`+(Math.random()*(1<<24)|0).toString(16).padStart(6,`0`),m=n===void 0?``:`, retryOf: ${n}`,h=Date.now();if(k(this).debug(`[${u}] sending request`,A({retryOfRequestLogID:n,method:r.method,url:c,options:r,headers:a.headers})),r.signal?.aborted)throw new d;let g=new AbortController,_=await this.fetchWithAuth(c,a,l,g).catch(s),v=Date.now();if(_ instanceof globalThis.Error){let e=`retrying, ${t} attempts remaining`;if(r.signal?.aborted)throw new d;let i=o(_)||/timed? ?out/i.test(String(_)+(`cause`in _?String(_.cause):``));if(t)return k(this).info(`[${u}] connection ${i?`timed out`:`failed`} - ${e}`),k(this).debug(`[${u}] connection ${i?`timed out`:`failed`} (${e})`,A({retryOfRequestLogID:n,url:c,durationMs:v-h,message:_.message})),this.retryRequest(r,t,n??u);throw k(this).info(`[${u}] connection ${i?`timed out`:`failed`} - error; no more retries left`),k(this).debug(`[${u}] connection ${i?`timed out`:`failed`} (error; no more retries left)`,A({retryOfRequestLogID:n,url:c,durationMs:v-h,message:_.message})),_ instanceof ne||_ instanceof re?_:i?new p:new f({cause:_})}let y=`[${u}${m}${[..._.headers.entries()].filter(([e])=>e===`x-request-id`).map(([e,t])=>`, `+e+`: `+JSON.stringify(t)).join(``)}] ${a.method} ${c} ${_.ok?`succeeded`:`failed`} with status ${_.status} in ${v-h}ms`;if(!_.ok){if(_.status===401&&this._workloadIdentityAuth&&!r.__metadata?.hasStreamingBody&&!r.__metadata?.workloadIdentityTokenRefreshed)return await je(_.body),this._workloadIdentityAuth.invalidateToken(),this.makeRequest({...r,__metadata:{...r.__metadata,workloadIdentityTokenRefreshed:!0}},t,n??u);let e=await this.shouldRetry(_);if(t&&e){let e=`retrying, ${t} attempts remaining`;return await je(_.body),k(this).info(`${y} - ${e}`),k(this).debug(`[${u}] response error (${e})`,A({retryOfRequestLogID:n,url:_.url,status:_.status,headers:_.headers,durationMs:v-h})),this.retryRequest(r,t,n??u,_.headers)}let i=e?`error; no more retries left`:`error; not retryable`;k(this).info(`${y} - ${i}`);let a=await _.text().catch(e=>s(e).message),o=fe(a),c=o?void 0:a;throw k(this).debug(`[${u}] response error (${i})`,A({retryOfRequestLogID:n,url:_.url,status:_.status,headers:_.headers,message:c,durationMs:Date.now()-h})),this.makeStatusError(_.status,o,c,_.headers)}return k(this).info(y),k(this).debug(`[${u}] response start`,A({retryOfRequestLogID:n,url:_.url,status:_.status,headers:_.headers,durationMs:v-h})),{response:_,options:r,controller:g,requestLogID:u,retryOfRequestLogID:n,startTime:h}}getAPIList(e,t,n){return this.requestAPIList(t,n&&`then`in n?n.then(t=>({method:`get`,path:e,...t})):{method:`get`,path:e,...n})}requestAPIList(e,t){let n=this.makeRequest(t,null,void 0);return new Pt(this,n,e)}async fetchWithAuth(e,t,n,r){if(this._workloadIdentityAuth){let e=t.headers,n=e.get(`Authorization`);if(!n||n===`Bearer ${is}`){let t=await this._workloadIdentityAuth.getToken();e.set(`Authorization`,`Bearer ${t}`)}}return await this.fetchWithTimeout(e,t,n,r)}async fetchWithTimeout(e,t,n,r){let{signal:i,method:a,...o}=t||{},s=this._makeAbort(r);i&&i.addEventListener(`abort`,s,{once:!0});let c=setTimeout(s,n),l=globalThis.ReadableStream&&o.body instanceof globalThis.ReadableStream||typeof o.body==`object`&&o.body!==null&&Symbol.asyncIterator in o.body,u={signal:r.signal,...l?{duplex:`half`}:{},method:`GET`,...o};a&&(u.method=a.toUpperCase());try{return await this.fetch.call(void 0,e,u)}finally{clearTimeout(c)}}async shouldRetry(e){let t=e.headers.get(`x-should-retry`);return t===`true`?!0:t===`false`?!1:e.status===408||e.status===409||e.status===429||e.status>=500}async retryRequest(e,t,n,r){let i,a=r?.get(`retry-after-ms`);if(a){let e=parseFloat(a);Number.isNaN(e)||(i=e)}let o=r?.get(`retry-after`);if(o&&!i){let e=parseFloat(o);i=Number.isNaN(e)?Date.parse(o)-Date.now():e*1e3}if(i===void 0){let n=e.maxRetries??this.maxRetries;i=this.calculateDefaultRetryTimeoutMillis(t,n)}return await me(i),this.makeRequest(e,t-1,n)}calculateDefaultRetryTimeoutMillis(e,t){let n=t-e;return Math.min(.5*2**n,8)*(1-Math.random()*.25)*1e3}async buildRequest(e,{retryCount:t=0}={}){let n={...e},{method:r,path:i,query:a,defaultBaseURL:o}=n,s=this.buildURL(i,a,o);`timeout`in n&&de(`timeout`,n.timeout),n.timeout=n.timeout??this.timeout;let{bodyHeaders:c,body:l,isStreamingBody:u}=this.buildBody({options:n});return u&&(e.__metadata={...e.__metadata,hasStreamingBody:!0}),{req:{method:r,headers:await this.buildHeaders({options:e,method:r,bodyHeaders:c,retryCount:t}),...n.signal&&{signal:n.signal},...globalThis.ReadableStream&&l instanceof globalThis.ReadableStream&&{duplex:`half`},...l&&{body:l},...this.fetchOptions??{},...n.fetchOptions??{}},url:s,timeout:n.timeout}}async buildHeaders({options:e,method:t,bodyHeaders:n,retryCount:r}){let i={};this.idempotencyHeader&&t!==`get`&&(e.idempotencyKey||(e.idempotencyKey=this.defaultIdempotencyKey()),i[this.idempotencyHeader]=e.idempotencyKey);let a=K([i,{Accept:`application/json`,"User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(r),...e.timeout?{"X-Stainless-Timeout":String(Math.trunc(e.timeout/1e3))}:{},...Te(),"OpenAI-Organization":this.organization,"OpenAI-Project":this.project},await this.authHeaders(e),this._options.defaultHeaders,n,e.headers]);return this.validateHeaders(a),a.values}_makeAbort(e){return()=>e.abort()}buildBody({options:{body:e,headers:t}}){if(!e)return{bodyHeaders:void 0,body:void 0,isStreamingBody:!1};let r=K([t]),i=globalThis.ReadableStream!==void 0&&e instanceof globalThis.ReadableStream,a=!i&&(typeof e==`string`||e instanceof ArrayBuffer||ArrayBuffer.isView(e)||globalThis.Blob!==void 0&&e instanceof globalThis.Blob||e instanceof URLSearchParams||e instanceof FormData);return ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof DataView||typeof e==`string`&&r.values.has(`content-type`)||globalThis.Blob&&e instanceof globalThis.Blob||e instanceof FormData||e instanceof URLSearchParams||i?{bodyHeaders:void 0,body:e,isStreamingBody:!a}:typeof e==`object`&&(Symbol.asyncIterator in e||Symbol.iterator in e&&`next`in e&&typeof e.next==`function`)?{bodyHeaders:void 0,body:ke(e),isStreamingBody:!0}:typeof e==`object`&&r.values.get(`content-type`)===`application/x-www-form-urlencoded`?{bodyHeaders:{"content-type":`application/x-www-form-urlencoded`},body:this.stringifyQuery(e),isStreamingBody:!1}:{...n(this,ns,`f`).call(this,{body:e,headers:r}),isStreamingBody:!1}}},ts=$,ns=new WeakMap,es=new WeakSet,rs=function(){return this.baseURL!==`https://api.openai.com/v1`},$.OpenAI=ts,$.DEFAULT_TIMEOUT=6e5,$.OpenAIError=l,$.APIError=u,$.APIConnectionError=f,$.APIConnectionTimeoutError=p,$.APIUserAbortError=d,$.NotFoundError=_,$.ConflictError=v,$.RateLimitError=ee,$.BadRequestError=m,$.AuthenticationError=h,$.InternalServerError=b,$.PermissionDeniedError=g,$.UnprocessableEntityError=y,$.InvalidWebhookSignatureError=S,$.toFile=$t,$.Completions=Qi,$.Chat=zr,$.Embeddings=ua,$.Files=va,$.Images=Ba,$.Audio=Qr,$.Moderations=Wa,$.Models=Ha,$.FineTuning=Pa,$.Graders=Ra,$.VectorStores=Ho,$.Webhooks=Yo,$.Beta=Xi,$.Batches=ei,$.Uploads=Po,$.Responses=So,$.Realtime=Xa,$.Conversations=ca,$.Evals=ga,$.Containers=ia,$.Skills=Ao,$.Videos=Wo})),os=e((()=>{z(),wi(),as()})),ss=e((()=>{as(),sn(),jt(),M(),C(),os()}));function cs(e,t){return{input_tokens:t.input_tokens??e.input_tokens,output_tokens:t.output_tokens??e.output_tokens,cache_creation_input_tokens:t.cache_creation_input_tokens!==void 0&&t.cache_creation_input_tokens>0?t.cache_creation_input_tokens:e.cache_creation_input_tokens,cache_read_input_tokens:t.cache_read_input_tokens!==void 0&&t.cache_read_input_tokens>0?t.cache_read_input_tokens:e.cache_read_input_tokens}}var ls=e((()=>{}));export{$ as i,cs as n,ss as r,ls as t};
@@ -0,0 +1 @@
1
+ import{n as e}from"./chunk-DR8-3Aex.js";async function t(e){e(`/output-style has been deprecated. Use /config to change your output style, or set it in your settings file. Changes take effect on the next session.`,{display:`system`})}e((()=>{}))();export{t as call};
@@ -0,0 +1 @@
1
+ import{n as e}from"./chunk-DR8-3Aex.js";import{n as t,t as n}from"./axios-DhfaybwJ.js";import{Ac as r,Pc as i,Sc as a,Zt as o,on as s}from"./paths-Q2255dD7.js";import{l as c,u as l}from"./oauth-CdZEzMww.js";import{d as u,f as d,o as f,s as p}from"./log-CzsijfHZ.js";import{a as m,l as h,o as g}from"./api-B6URs6nc.js";async function _(){try{let{accessToken:e,orgUUID:n}=await h(),r=`${c().BASE_API_URL}/api/oauth/organizations/${n}/overage_credit_grant`;return(await t.get(r,{headers:m(e)})).data}catch(e){return p(e),null}}function v(){let e=o()?.organizationUuid;if(!e)return null;let t=a().overageCreditGrantCache?.[e];return!t||Date.now()-t.timestamp>S?null:t.info}function y(){let e=o()?.organizationUuid;if(!e)return;let t=a().overageCreditGrantCache;!t||!(e in t)||i(t=>{let n={...t.overageCreditGrantCache};return delete n[e],{...t,overageCreditGrantCache:n}})}async function b(){if(d())return;let e=o()?.organizationUuid;if(!e)return;let t=await _();t&&i(n=>{let r=n.overageCreditGrantCache?.[e],i=r?.info,a=i&&i.available===t.available&&i.eligible===t.eligible&&i.granted===t.granted&&i.amount_minor_units===t.amount_minor_units&&i.currency===t.currency;if(a&&r&&Date.now()-r.timestamp<=S)return n;let o={info:a?i:t,timestamp:Date.now()};return{...n,overageCreditGrantCache:{...n.overageCreditGrantCache,[e]:o}}})}function x(e){if(e.amount_minor_units==null||!e.currency)return null;if(e.currency.toUpperCase()===`USD`){let t=e.amount_minor_units/100;return Number.isInteger(t)?`$${t}`:`$${t.toFixed(2)}`}return null}var S,C=e((()=>{n(),l(),s(),r(),f(),u(),g(),S=3600*1e3}));export{b as a,y as i,v as n,C as r,x as t};
@@ -0,0 +1 @@
1
+ import{n as e,t}from"./p-map-D7WEmnBE.js";t();export{e as default};