@readmagic/workmate 0.0.6 → 0.0.8

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 (556) hide show
  1. package/dist/chunks/AddWorkspaceDirectory-CwLtQld4.js +1 -0
  2. package/dist/chunks/App-Ba52HvYC.js +1 -0
  3. package/dist/chunks/{ApproveApiKey-Bsy8kr2a.js → ApproveApiKey-CEIfuUh0.js} +1 -1
  4. package/dist/chunks/ApproveApiKey-D2MLQu2P.js +1 -0
  5. package/dist/chunks/BackgroundTasksDialog-IGDrkbWl.js +2 -0
  6. package/dist/chunks/{BypassPermissionsModeDialog-BKj_3Idm.js → BypassPermissionsModeDialog-GYhq--JR.js} +1 -1
  7. package/dist/chunks/{ClaudeMdExternalIncludesDialog-BD-7yAZh.js → ClaudeMdExternalIncludesDialog-C-CTa-95.js} +1 -1
  8. package/dist/chunks/ClaudeMdExternalIncludesDialog-Catv6BCJ.js +1 -0
  9. package/dist/chunks/ConsoleOAuthFlow-BeQXqUtX.js +1 -0
  10. package/dist/chunks/{DiffDialog-C4XSSjvV.js → DiffDialog-AC5DSJrq.js} +6 -6
  11. package/dist/chunks/Doctor-B9Rxsoy0.js +1 -0
  12. package/dist/chunks/Doctor-lhUBhEy5.js +3 -0
  13. package/dist/chunks/{ExitFlow-BttnAv-O.js → ExitFlow-Cu8SoQHs.js} +2 -2
  14. package/dist/chunks/Grove-Bc4CofEj.js +11 -0
  15. package/dist/chunks/{HybridTransport-B8V6O6rM.js → HybridTransport-BJPOG2wl.js} +3 -3
  16. package/dist/chunks/{InvalidConfigDialog-CHzBSJDf.js → InvalidConfigDialog-BI13il58.js} +1 -1
  17. package/dist/chunks/{InvalidSettingsDialog-BKenH3bD.js → InvalidSettingsDialog-CtOheV1K.js} +1 -1
  18. package/dist/chunks/MCPConnectionManager-ao-P3xSA.js +1 -0
  19. package/dist/chunks/MCPToolListView-dkofcJs4.js +1 -0
  20. package/dist/chunks/{McpParsingWarnings-Bj2-YL8o.js → McpParsingWarnings-BS4JoR5l.js} +1 -1
  21. package/dist/chunks/MessageSelector-B88b2ypw.js +3 -0
  22. package/dist/chunks/Messages-BPeI7lLV.js +11 -0
  23. package/dist/chunks/Onboarding-c2fQ8Io_.js +1 -0
  24. package/dist/chunks/{PromptInputFooterSuggestions-egs9VvUs.js → PromptInputFooterSuggestions-D1cH9sDX.js} +1 -1
  25. package/dist/chunks/{PromptInputHelpMenu-SieM5NoY.js → PromptInputHelpMenu-DDD5WuK0.js} +1 -1
  26. package/dist/chunks/QueryEngine-Cv_meCam.js +1 -0
  27. package/dist/chunks/REPL-BXhAQOXb.js +139 -0
  28. package/dist/chunks/REPL-YqjLnr3A.js +1 -0
  29. package/dist/chunks/RemoteSessionManager-CT7T8BaR.js +2 -0
  30. package/dist/chunks/ResumeConversation-CIZCjms9.js +1 -0
  31. package/dist/chunks/{SSETransport-DtpMDekF.js → SSETransport-CrwbKuVt.js} +3 -3
  32. package/dist/chunks/SearchExtraToolsTool-Dx6093yw.js +1 -0
  33. package/dist/chunks/Settings-CyUm0AtU.js +2 -0
  34. package/dist/chunks/{TeleportProgress-rYaHIEfe.js → TeleportProgress-C3qyp5zy.js} +1 -1
  35. package/dist/chunks/TeleportRepoMismatchDialog-BV--nyYn.js +1 -0
  36. package/dist/chunks/TeleportResumeWrapper-Blo2cZg-.js +1 -0
  37. package/dist/chunks/ThemePicker-EQ6hPUeI.js +1 -0
  38. package/dist/chunks/TrustDialog-BukWGvHZ.js +1 -0
  39. package/dist/chunks/{ValidationErrorsList-B8pRiGuy.js → ValidationErrorsList-DokTJQwi.js} +1 -1
  40. package/dist/chunks/{WelcomeV2-DqnbSdIu.js → WelcomeV2-Ci9VwPYh.js} +1 -1
  41. package/dist/chunks/{add-dir-C2Hu3oE4.js → add-dir-DPQV0qml.js} +1 -1
  42. package/dist/chunks/{agentDisplay-XoDJhr03.js → agentDisplay-DBQYOaOh.js} +1 -1
  43. package/dist/chunks/agents-DmybpgDN.js +103 -0
  44. package/dist/chunks/{agents-C4QXeHIJ.js → agents-HlKk68Qc.js} +1 -1
  45. package/dist/chunks/allErrors-BPn_2TrB.js +1 -0
  46. package/dist/chunks/analytics-CkYUHW_U.js +1 -0
  47. package/dist/chunks/ant-DjdvlLOo.js +1 -0
  48. package/dist/chunks/api-AMgj1zf_.js +1 -0
  49. package/dist/chunks/api-CF5IVtj0.js +1 -0
  50. package/dist/chunks/{asciicast-CbAjUHT_.js → asciicast-BJNYO5sh.js} +1 -1
  51. package/dist/chunks/asciicast-CH6hdK0a.js +1 -0
  52. package/dist/chunks/auth-CNjDn1VY.js +15 -0
  53. package/dist/chunks/auth-CZzP483s.js +1 -0
  54. package/dist/chunks/auth-DDSBm_Yj.js +1 -0
  55. package/dist/chunks/{autoMode-BNukrVAB.js → autoMode-Cr0AhS1G.js} +5 -5
  56. package/dist/chunks/{autonomy-BEmI7WVW.js → autonomy-ARUQt-Lu.js} +1 -1
  57. package/dist/chunks/autonomy-D4xZLOdJ.js +15 -0
  58. package/dist/chunks/{autonomyPanel-fhge09AG.js → autonomyPanel-BQK9MoeB.js} +1 -1
  59. package/dist/chunks/backgroundHousekeeping--eBgphcg.js +17 -0
  60. package/dist/chunks/backgroundHousekeeping-VV1V_Y2Z.js +1 -0
  61. package/dist/chunks/{banner-CWkrK10u.js → banner-Ca7rki2V.js} +2 -2
  62. package/dist/chunks/bg-BK_9J6F6.js +1 -0
  63. package/dist/chunks/{bg-WnYN5ifx.js → bg-DxRHF1yn.js} +2 -2
  64. package/dist/chunks/{branch-Bpe-gocq.js → branch-BYq0zpzT.js} +1 -1
  65. package/dist/chunks/{break-cache-C_p7Kmx2.js → break-cache-BKvoMOZx.js} +2 -2
  66. package/dist/chunks/bridgeConfig-C82un7rJ.js +1 -0
  67. package/dist/chunks/{bridgeConfig-BhxRF2vm.js → bridgeConfig-jDEva6Eh.js} +1 -1
  68. package/dist/chunks/bridgeMessaging-YqYdl6ej.js +1 -0
  69. package/dist/chunks/bridgePointer-DIM0sj0x.js +1 -0
  70. package/dist/chunks/btw-CUV3nRrE.js +1 -0
  71. package/dist/chunks/caches-BZ59_En6.js +1 -0
  72. package/dist/chunks/caches-Cg-HtWKG.js +1 -0
  73. package/dist/chunks/capacityWake-CKOiRELo.js +3 -0
  74. package/dist/chunks/ccrClient-BC2q3k44.js +1 -0
  75. package/dist/chunks/{claudeDesktop-Cx31Ugjp.js → claudeDesktop-DQXL5bGm.js} +1 -1
  76. package/dist/chunks/{clear-B4d38ssF.js → clear-1etSJhdg.js} +1 -1
  77. package/dist/chunks/{cliLaunch-BkPAatcs.js → cliLaunch-CQjLYRzM.js} +1 -1
  78. package/dist/chunks/client-DQXvVKND.js +1 -0
  79. package/dist/chunks/client-DQwf_b9o.js +17 -0
  80. package/dist/chunks/client-DkgC-mFB.js +1 -0
  81. package/dist/chunks/color-CBsNbt1s.js +1 -0
  82. package/dist/chunks/commands-qM5z_Uld.js +1 -0
  83. package/dist/chunks/compact-BclJiRJe.js +2 -0
  84. package/dist/chunks/completionCache-BMHAktkM.js +1 -0
  85. package/dist/chunks/config-CE058cvr.js +3 -0
  86. package/dist/chunks/config-D81avYye.js +1 -0
  87. package/dist/chunks/config-DpOOllGk.js +1 -0
  88. package/dist/chunks/context-noninteractive-Ct_ttQfP.js +29 -0
  89. package/dist/chunks/context-noninteractive-DJb8H_hN.js +1 -0
  90. package/dist/chunks/context-sR9fJmXE.js +1 -0
  91. package/dist/chunks/conversation-D48Kt3ar.js +1 -0
  92. package/dist/chunks/conversation-fOFTa7k5.js +1 -0
  93. package/dist/chunks/{createSSHSession-BM-5pbv6.js → createSSHSession-BmHXA2me.js} +1 -1
  94. package/dist/chunks/createSession-C4rukWkv.js +1 -0
  95. package/dist/chunks/createSession-CSwlW2T2.js +1 -0
  96. package/dist/chunks/crossProjectResume-lDFB2ZcY.js +40 -0
  97. package/dist/chunks/cwd-5Xr-Qka6.js +1 -0
  98. package/dist/chunks/cwd-C5ce-7WB.js +1 -0
  99. package/dist/chunks/{daemon-YtZbMQtn.js → daemon-ZtpTZWgQ.js} +1 -1
  100. package/dist/chunks/{datadog-CpqEQbHa.js → datadog-BJn5ECIu.js} +1 -1
  101. package/dist/chunks/{debug-BrXObCdR.js → debug-RZ4NuXyS.js} +1 -1
  102. package/dist/chunks/debugUtils-D30M1cbN.js +1 -0
  103. package/dist/chunks/{detached-TYk4hMFj.js → detached-jrVP11oU.js} +1 -1
  104. package/dist/chunks/{detectRepository-BPr0VWNO.js → detectRepository-CFiHe6Rv.js} +1 -1
  105. package/dist/chunks/detectRepository-DqQvyj_a.js +1 -0
  106. package/dist/chunks/{diff-CVzOodeg.js → diff-BKiK3xHv.js} +1 -1
  107. package/dist/chunks/directoryCompletion-BagQcynj.js +1 -0
  108. package/dist/chunks/doctor-BEHYm34V.js +1 -0
  109. package/dist/chunks/{entry-DHVYCR26.js → entry-BzL1MFQG.js} +4 -4
  110. package/dist/chunks/esm-BLPbfHQd.js +1 -0
  111. package/dist/chunks/{execFileNoThrow-D244NytW.js → execFileNoThrow-CCX-JY8h.js} +1 -1
  112. package/dist/chunks/{execSyncWrapper-CCMQShK-.js → execSyncWrapper-dhRSYGFW.js} +1 -1
  113. package/dist/chunks/exit-DE2YiAhQ.js +1 -0
  114. package/dist/chunks/{lazySchema-DcIJE_0i.js → external-CEp-aPkt.js} +1 -1
  115. package/dist/chunks/extraUsage-Dw7AXiH7.js +1 -0
  116. package/dist/chunks/extractMemories-DxTUMiv3.js +1 -0
  117. package/dist/chunks/fast-CHmMkIpE.js +1 -0
  118. package/dist/chunks/fast-uQASHWqR.js +1 -0
  119. package/dist/chunks/fileSuggestions-Dyu2kQtE.js +3 -0
  120. package/dist/chunks/firstPartyEventLogger-D5ohKbIe.js +5 -0
  121. package/dist/chunks/firstPartyEventLogger-LsNY6yOt.js +1 -0
  122. package/dist/chunks/flushGate-Cnsu4HET.js +1 -0
  123. package/dist/chunks/gemini-Cudre91e.js +1 -0
  124. package/dist/chunks/{generateRecap-jGDLI_wU.js → generateRecap-CiFxXlmH.js} +1 -1
  125. package/dist/chunks/generateSessionName-DitoBxJT.js +1 -0
  126. package/dist/chunks/{genericProcessUtils-CdQTApYX.js → genericProcessUtils-DVfMHhfy.js} +1 -1
  127. package/dist/chunks/git-BerW9bId.js +6 -0
  128. package/dist/chunks/git-D6dOU2mT.js +1 -0
  129. package/dist/chunks/githubRepoPathMapping-DGr0kJ8D.js +1 -0
  130. package/dist/chunks/{goal-CFx4eRkf.js → goal-DuUayfDg.js} +3 -3
  131. package/dist/chunks/grok-tRbmZzEh.js +1 -0
  132. package/dist/chunks/grove-Cv19v6Sv.js +7 -0
  133. package/dist/chunks/help-DkqxbFDM.js +1 -0
  134. package/dist/chunks/{hooks-X6J03MnA.js → hooks-BZJTWD07.js} +2 -2
  135. package/dist/chunks/hooks-CsP42iOp.js +1 -0
  136. package/dist/chunks/initReplBridge-DdsSWVqN.js +1 -0
  137. package/dist/chunks/{install-D5YORIJL.js → install-BI---dv0.js} +1 -1
  138. package/dist/chunks/{instrumentation-Bw3CxPQf.js → instrumentation-CcWzhGfE.js} +4 -4
  139. package/dist/chunks/{job-DOWtcltx.js → job-B0ftcqPF.js} +1 -1
  140. package/dist/chunks/{jwtUtils-DE2GPUcx.js → jwtUtils-C0cE-1Ey.js} +1 -1
  141. package/dist/chunks/keybindings-DZU3vwo3.js +2 -0
  142. package/dist/chunks/language-DHhXLb_Y.js +1 -0
  143. package/dist/chunks/{language-C6Fq-XOZ.js → language-s-dLbdVz.js} +1 -1
  144. package/dist/chunks/launchLocalMemory-twLxpPvg.js +3 -0
  145. package/dist/chunks/{launchOnboarding-Cc6WwPX9.js → launchOnboarding-BWz2XSb9.js} +1 -1
  146. package/dist/chunks/lazySchema-B4D4qJVE.js +1 -0
  147. package/dist/chunks/{loadAgentsDir-D206qwP3.js → loadAgentsDir-ByO8eJqU.js} +1724 -1993
  148. package/dist/chunks/loadAgentsDir-CMNFLt7R.js +1 -0
  149. package/dist/chunks/loadPluginHooks-BPnxcgrL.js +1 -0
  150. package/dist/chunks/{localSearch-CzrbOklu.js → localSearch-CHHCH16D.js} +1 -1
  151. package/dist/chunks/localSearch-DzQODFap.js +1 -0
  152. package/dist/chunks/log-CZ0zYP_c.js +1 -0
  153. package/dist/chunks/logoV2Utils-CGUJ-5gY.js +1 -0
  154. package/dist/chunks/{magicDocs-DWjL2k7P.js → magicDocs-C5i5ruuU.js} +3 -3
  155. package/dist/chunks/{main-D862LI_d.js → main-BLD4QAQg.js} +2 -2
  156. package/dist/chunks/{main-BohPzJFF.js → main-D4Uk-WUs.js} +89 -86
  157. package/dist/chunks/managedEnv-C-9XSN14.js +1 -0
  158. package/dist/chunks/managedEnv-DLVRBaA9.js +1 -0
  159. package/dist/chunks/managedEnvConstants-BPwL2aWI.js +1 -0
  160. package/dist/chunks/{mappers-BDMZFgKx.js → mappers-CHRFic5q.js} +1 -1
  161. package/dist/chunks/mcp-BMVdGknC.js +1 -0
  162. package/dist/chunks/mcp-COS5RJFS.js +6 -0
  163. package/dist/chunks/mcp-tGsOW1GN.js +2 -0
  164. package/dist/chunks/memoize-B8hfb1JN.js +1 -0
  165. package/dist/chunks/memory-DR6poqeH.js +1 -0
  166. package/dist/chunks/{mode-CUkHFkju.js → mode-QV-NW1Wd.js} +2 -2
  167. package/dist/chunks/model-BF_4ebyl.js +1 -0
  168. package/dist/chunks/{model-BY3auM2c.js → model-BNU_ulDJ.js} +1 -1
  169. package/dist/chunks/model-CwO-g1RW.js +1 -0
  170. package/dist/chunks/nativeInstaller-B-lNJjM-.js +1 -0
  171. package/dist/chunks/observationStore-BpjlK0pG.js +3 -0
  172. package/dist/chunks/omit-DZCEXri5.js +1 -0
  173. package/dist/chunks/onChangeAppState-BmfM5g-D.js +1 -0
  174. package/dist/chunks/openai-DPH6rXOZ.js +10 -0
  175. package/dist/chunks/{panel-BSZGX6jN.js → panel-mD094ALT.js} +1 -1
  176. package/dist/chunks/{panelCall-BsVoL1uF.js → panelCall-SbffM7G4.js} +1 -1
  177. package/dist/chunks/parser-DrBC8nWp.js +1 -0
  178. package/dist/chunks/{parser-DFwaTGf7.js → parser-dbHRgXb8.js} +1 -1
  179. package/dist/chunks/partition-DKuAFJkc.js +1 -0
  180. package/dist/chunks/{path-D5U-tm91.js → path-Cv9QMBAX.js} +1 -1
  181. package/dist/chunks/permissions-ey-bfanE.js +3 -0
  182. package/dist/chunks/{pidLock-D5rUnDB-.js → pidLock-DJnS_38v.js} +2 -2
  183. package/dist/chunks/{pipeTransport-CqCnc-Ys.js → pipeTransport-DVOKR4c_.js} +1 -1
  184. package/dist/chunks/{plan-SYZ4DXR8.js → plan-Brg9XnRr.js} +1 -1
  185. package/dist/chunks/{platform-BrYefG_2.js → platform-DCXXznJg.js} +1 -1
  186. package/dist/chunks/plugin-CRwa39Y1.js +17 -0
  187. package/dist/chunks/pluginAutoupdate-D0LIP7cy.js +1 -0
  188. package/dist/chunks/{pluginBlocklist-C3H2afWG.js → pluginBlocklist-PwHHD3nj.js} +1 -1
  189. package/dist/chunks/pluginCliCommands-BJM5Bdpf.js +1 -0
  190. package/dist/chunks/pluginFlagging-pBxSselw.js +1 -0
  191. package/dist/chunks/pluginOperations-C7p_Qr2r.js +2 -0
  192. package/dist/chunks/pluginStartupCheck-C0HqhG6D.js +1 -0
  193. package/dist/chunks/pluginStartupCheck-Di4LjHXf.js +1 -0
  194. package/dist/chunks/{plugins-Dn6ceWrT.js → plugins-DUKNjLq6.js} +4 -4
  195. package/dist/chunks/pollConfig-BgpfHQPJ.js +1 -0
  196. package/dist/chunks/{poorMode-DhzFKpPl.js → poorMode-CYXmr_mU.js} +1 -1
  197. package/dist/chunks/poorMode-CejPNCp-.js +1 -0
  198. package/dist/chunks/print-gyTOCJzk.js +23 -0
  199. package/dist/chunks/processBashCommand-Cze9vCm6.js +1 -0
  200. package/dist/chunks/processSlashCommand-BRajh1v7.js +5 -0
  201. package/dist/chunks/prompt-B7joRiqj.js +139 -0
  202. package/dist/chunks/prompt-DqSMh2x9.js +1 -0
  203. package/dist/chunks/prompt-Eysh8Et_.js +1 -0
  204. package/dist/chunks/{promptEditor-DeMrXUir.js → promptEditor-R_acDAgI.js} +2 -2
  205. package/dist/chunks/{protocolHandler-BHxBy84Z.js → protocolHandler-RNKkhq91.js} +1 -1
  206. package/dist/chunks/{proxy-CRN7jYIi.js → proxy-BmtEnJ02.js} +1 -1
  207. package/dist/chunks/rcDebugLog-CARUIORE.js +1 -0
  208. package/dist/chunks/reconciler-BfkO6X2X.js +4 -0
  209. package/dist/chunks/refresh-C1X3sptR.js +1 -0
  210. package/dist/chunks/registerProtocol-DoKqmqu2.js +36 -0
  211. package/dist/chunks/{reload-plugins-B9IT9CFA.js → reload-plugins-C0osFcNh.js} +1 -1
  212. package/dist/chunks/remoteBridgeCore-Cddqv2WW.js +1 -0
  213. package/dist/chunks/remoteManagedSettings-B1mnRDmA.js +1 -0
  214. package/dist/chunks/rename-B3tf-YiD.js +1 -0
  215. package/dist/chunks/{renderOptions-BUJB9nAm.js → renderOptions-ChLwxtVu.js} +1 -1
  216. package/dist/chunks/replBridgeHandle-CNwNIijW.js +1 -0
  217. package/dist/chunks/{resume-y7MCTZHJ.js → resume-Be1G_GBL.js} +2 -2
  218. package/dist/chunks/ripgrep-C2PhTJDh.js +1 -0
  219. package/dist/chunks/{ripgrep-BXmXjAzA.js → ripgrep-gaT9Njwi.js} +1 -1
  220. package/dist/chunks/{runtimeObserver-BZcJ1FbH.js → runtimeObserver-CsIwinzh.js} +1 -1
  221. package/dist/chunks/runtimeObserver-Dbxxw4ls.js +10 -0
  222. package/dist/chunks/sandbox-adapter-C6GBuJPB.js +1 -0
  223. package/dist/chunks/sandbox-toggle-jEySONTW.js +1 -0
  224. package/dist/chunks/searchExtraTools-C_UTryh_.js +1 -0
  225. package/dist/chunks/session-DDI1Eb2x.js +2 -0
  226. package/dist/chunks/sessionFileAccessHooks-DfJ7Htfl.js +1 -0
  227. package/dist/chunks/sessionIdCompat-DMayYBrf.js +1 -0
  228. package/dist/chunks/sessionMemory-CQBxPkTQ.js +1 -0
  229. package/dist/chunks/sessionMemory-s0ALUHvc.js +1 -0
  230. package/dist/chunks/sessionMemoryUtils-xt7dTHGC.js +1 -0
  231. package/dist/chunks/sessionObserver-C2sYqWL3.js +1 -0
  232. package/dist/chunks/sessionObserver-DoYc0ZOP.js +20 -0
  233. package/dist/chunks/sessionState-CjNY991n.js +11 -0
  234. package/dist/chunks/sessionStorage-DqsY-7pi.js +1 -0
  235. package/dist/chunks/{sessionTitle-coed9IuJ.js → sessionTitle-B0OYf5nM.js} +3 -3
  236. package/dist/chunks/sessionTracing-CwsXt_uA.js +11 -0
  237. package/dist/chunks/settings-BWtOA9A7.js +1 -0
  238. package/dist/chunks/settings-hQDLwPVj.js +20 -0
  239. package/dist/chunks/settingsSync-DdFagwHV.js +1 -0
  240. package/dist/chunks/setup-DzC22EkN.js +3 -0
  241. package/dist/chunks/{shadowedRuleDetection-D1wsAdpp.js → shadowedRuleDetection-C86PTj1m.js} +1 -1
  242. package/dist/chunks/{shellQuote-DkSy9MYE.js → shellQuote-BUVKMu_P.js} +1 -1
  243. package/dist/chunks/{sideQuestion-wSi38p81.js → sideQuestion-C780iYwd.js} +3 -3
  244. package/dist/chunks/sinks-5G_xhc1Q.js +1 -0
  245. package/dist/chunks/{sinks-C_Dl1p4K.js → sinks-Cftq7Es0.js} +2 -2
  246. package/dist/chunks/skillChangeDetector-plLveEbf.js +1 -0
  247. package/dist/chunks/skillGapStore-Dc1arohs.js +5 -0
  248. package/dist/chunks/skillLifecycle-DP6mY1Kp.js +8 -0
  249. package/dist/chunks/{skillSearchPanel-CErRnUwo.js → skillSearchPanel-CpLTImaL.js} +4 -4
  250. package/dist/chunks/{skills-CBKhfg_a.js → skills-zGYaYfFV.js} +1 -1
  251. package/dist/chunks/{src-D06Xyj4g.js → src-BN7QRYLl.js} +1 -1
  252. package/dist/chunks/startupProfiler-DCn_NxMH.js +3 -0
  253. package/dist/chunks/startupProfiler-JbpAkfNE.js +1 -0
  254. package/dist/chunks/{state-ix0xIunV.js → state-C2OSZkV1.js} +1 -1
  255. package/dist/chunks/state-DU9lRJ9x.js +1 -0
  256. package/dist/chunks/{stats-BY4dskVg.js → stats-Duk7_xjQ.js} +1 -1
  257. package/dist/chunks/{status-BnJIXtKl.js → status-CFw-FpZM.js} +2 -2
  258. package/dist/chunks/{status-DU-B4SMW.js → status-peiVB_2j.js} +1 -1
  259. package/dist/chunks/statusNoticeHelpers-B5U5c9PE.js +1 -0
  260. package/dist/chunks/{stringUtils-DGLPkqJ4.js → stringUtils-B6FudhoZ.js} +1 -1
  261. package/dist/chunks/switcher-BAMqSX7Z.js +1 -0
  262. package/dist/chunks/switcher-hgBgVzLb.js +1 -0
  263. package/dist/chunks/syncCache-Zl9kZRRl.js +1 -0
  264. package/dist/chunks/{tasks-CBVL005y.js → tasks-BxpyRhmD.js} +1 -1
  265. package/dist/chunks/teleport-CwxeD5vL.js +1 -0
  266. package/dist/chunks/{templateJobs-D6998LcG.js → templateJobs-DR5fKFiO.js} +1 -1
  267. package/dist/chunks/{terminalSetup-0SBdyKF5.js → terminalSetup-DgRBt-JJ.js} +1 -1
  268. package/dist/chunks/terminalSetup-DlaFWI81.js +33 -0
  269. package/dist/chunks/{theme-p0AooruD.js → theme-Bz6esfST.js} +1 -1
  270. package/dist/chunks/{tmux-BY7IdQ1f.js → tmux-DSU9tYIo.js} +1 -1
  271. package/dist/chunks/{toolEventObserver-DTccwC3c.js → toolEventObserver-BSekCkM2.js} +1 -1
  272. package/dist/chunks/toolPool-B7SIoDw5.js +1 -0
  273. package/dist/chunks/{trustedDevice-BTYoQCkC.js → trustedDevice-B0x9X0fb.js} +1 -1
  274. package/dist/chunks/trustedDevice-CjHQtVkO.js +1 -0
  275. package/dist/chunks/{types-C-MRCL8J.js → types-D7_37tP2.js} +2 -2
  276. package/dist/chunks/{udsClient-BuCtv7dN.js → udsClient-CHoMMH28.js} +1 -1
  277. package/dist/chunks/{up-BHkC97_C.js → up-B8wBSpLg.js} +1 -1
  278. package/dist/chunks/{updateCCB-DFL5Wt_I.js → updateCCB-D_kGQKPT.js} +1 -1
  279. package/dist/chunks/{upstreamproxy-DyR_eXO8.js → upstreamproxy-Hmq-n8fw.js} +1 -1
  280. package/dist/chunks/useExitOnCtrlCDWithKeybindings-Cce612uS.js +1 -0
  281. package/dist/chunks/useMainLoopModel-BICP6_Fi.js +1 -0
  282. package/dist/chunks/useManagePlugins-DtbY_vPL.js +1 -0
  283. package/dist/chunks/useMergedTools-Ckx2IEhF.js +1 -0
  284. package/dist/chunks/{useSearchInput-D1Vr2Js1.js → useSearchInput-BAgljZUl.js} +1 -1
  285. package/dist/chunks/useSettingsErrors-CAJR_wpd.js +1 -0
  286. package/dist/chunks/userAgent-BxTG7IMk.js +1 -0
  287. package/dist/chunks/{util-BaDs-wL5.js → util-DDtmyq_r.js} +1 -1
  288. package/dist/chunks/validatePlugin-AHl-g4ct.js +1 -0
  289. package/dist/chunks/{vim-C-icQDz1.js → vim-kg-mRVbu.js} +1 -1
  290. package/dist/chunks/{which-CKQnSouy.js → which-CHLNJmtJ.js} +1 -1
  291. package/dist/chunks/windowsPaths-Pmx8LDR6.js +1 -0
  292. package/dist/chunks/{windowsPaths-DtapVxOo.js → windowsPaths-o62uq6LF.js} +1 -1
  293. package/dist/chunks/{workSecret-CNWiR2uQ.js → workSecret-DG9shvG0.js} +1 -1
  294. package/dist/chunks/workerRegistry-C7H_lsQX.js +6 -0
  295. package/dist/chunks/worktree-O2p-mJdF.js +1 -0
  296. package/dist/cli.js +1 -1
  297. package/package.json +1 -1
  298. package/dist/chunks/AddWorkspaceDirectory-ClHi-Dr6.js +0 -1
  299. package/dist/chunks/App-BP06lHmf.js +0 -1
  300. package/dist/chunks/ApproveApiKey-a2ZonQ3n.js +0 -1
  301. package/dist/chunks/AssistantSessionChooser-CcocKoTJ.js +0 -1
  302. package/dist/chunks/BackgroundTasksDialog-DNeBhGCf.js +0 -2
  303. package/dist/chunks/ClaudeMdExternalIncludesDialog-DFivNFuo.js +0 -1
  304. package/dist/chunks/ConsoleOAuthFlow-CS3zjEPF.js +0 -1
  305. package/dist/chunks/DesktopHandoff-BmPmCfT3.js +0 -1
  306. package/dist/chunks/Dialog-vfLXEPed.js +0 -1
  307. package/dist/chunks/Doctor-BhD-ZzZm.js +0 -1
  308. package/dist/chunks/Doctor-DEQe2q16.js +0 -3
  309. package/dist/chunks/Feedback-BaYA8-SU.js +0 -2
  310. package/dist/chunks/Grove-BJziCbZH.js +0 -11
  311. package/dist/chunks/Grove-sWm-oLBf.js +0 -1
  312. package/dist/chunks/ListItem-vfLXEPed.js +0 -1
  313. package/dist/chunks/MCPConnectionManager-CNh9dNlk.js +0 -1
  314. package/dist/chunks/MessageSelector-DdR6wJhh.js +0 -3
  315. package/dist/chunks/Messages-Ch6cboMV.js +0 -11
  316. package/dist/chunks/Onboarding-BrAJp0aL.js +0 -1
  317. package/dist/chunks/OverageCreditUpsell-Ds1cB7RC.js +0 -1
  318. package/dist/chunks/PluginSettings-CGqEzejq.js +0 -17
  319. package/dist/chunks/QueryEngine-CZZMl3PB.js +0 -1
  320. package/dist/chunks/REPL-CG2N7E4Q.js +0 -142
  321. package/dist/chunks/REPL-DvA910N_.js +0 -1
  322. package/dist/chunks/RemoteCallout-Cs-ro8_i.js +0 -1
  323. package/dist/chunks/RemoteSessionManager-B740Dp6m.js +0 -2
  324. package/dist/chunks/ResumeConversation-DzV2zmuX.js +0 -1
  325. package/dist/chunks/SearchExtraToolsTool-C4uO-Zx3.js +0 -1
  326. package/dist/chunks/Settings-XKw6FI_m.js +0 -2
  327. package/dist/chunks/TeleportRepoMismatchDialog-DY97YZMB.js +0 -1
  328. package/dist/chunks/TeleportResumeWrapper-jaQzyTCh.js +0 -1
  329. package/dist/chunks/ThemePicker-BViWzLp3.js +0 -1
  330. package/dist/chunks/TrustDialog-DGJ_BisZ.js +0 -1
  331. package/dist/chunks/TungstenTool-Cb7gJvq4.js +0 -1
  332. package/dist/chunks/TungstenTool-CxMQVCuF.js +0 -1
  333. package/dist/chunks/agents-BIHTGDYh.js +0 -103
  334. package/dist/chunks/allErrors-1896uQA1.js +0 -1
  335. package/dist/chunks/analytics-BotDBGh0.js +0 -1
  336. package/dist/chunks/ant-B6k6cBts.js +0 -1
  337. package/dist/chunks/api-BsFW57_Q.js +0 -1
  338. package/dist/chunks/api-gqTA-D7n.js +0 -1
  339. package/dist/chunks/asciicast-BsWpcxrc.js +0 -1
  340. package/dist/chunks/assistant-C83quuNj.js +0 -1
  341. package/dist/chunks/assistant-DJ9hd4uC.js +0 -1
  342. package/dist/chunks/assistant-z2o4-UJe.js +0 -1
  343. package/dist/chunks/auth-8Vd3_U8t.js +0 -1
  344. package/dist/chunks/auth-BnSrKyJe.js +0 -15
  345. package/dist/chunks/auth-DRTjfnGy.js +0 -1
  346. package/dist/chunks/autonomy-DGcy5Rml.js +0 -15
  347. package/dist/chunks/backgroundHousekeeping-3i_d_WW5.js +0 -1
  348. package/dist/chunks/backgroundHousekeeping-BVMf_Tjn.js +0 -17
  349. package/dist/chunks/bg-B0iMGM9C.js +0 -1
  350. package/dist/chunks/bridge-D12Shbkj.js +0 -2
  351. package/dist/chunks/bridgeConfig-CqIQ_rvD.js +0 -1
  352. package/dist/chunks/bridgeEnabled-D0XC5kNh.js +0 -1
  353. package/dist/chunks/bridgeEnabled-SbB-6zdY.js +0 -1
  354. package/dist/chunks/bridgeMain-DHUpZFgL.js +0 -68
  355. package/dist/chunks/bridgeMain-DUbQjgCp.js +0 -1
  356. package/dist/chunks/bridgeMessaging-DHc5dOhB.js +0 -1
  357. package/dist/chunks/bridgePointer-MqLe5Asm.js +0 -1
  358. package/dist/chunks/browser-BmZuQom6.js +0 -1
  359. package/dist/chunks/btw-D9hMM5d2.js +0 -1
  360. package/dist/chunks/caches-CWzT7e6Y.js +0 -1
  361. package/dist/chunks/caches-UeVVM3T0.js +0 -3
  362. package/dist/chunks/capacityWake-CV_x9H8j.js +0 -1
  363. package/dist/chunks/ccrClient-Iza0L8Zw.js +0 -1
  364. package/dist/chunks/client-BzKQTXzF.js +0 -1
  365. package/dist/chunks/color-D8VOyoYl.js +0 -1
  366. package/dist/chunks/commands-DDamMmo4.js +0 -1
  367. package/dist/chunks/commitAttribution-CgohL8vD.js +0 -1
  368. package/dist/chunks/commitAttribution-ChAgixdj.js +0 -2
  369. package/dist/chunks/compact-IFHwxjZ9.js +0 -2
  370. package/dist/chunks/completionCache-MN3_MqK8.js +0 -4
  371. package/dist/chunks/completionCache-c4aiyZ_f.js +0 -1
  372. package/dist/chunks/config-DY5-_kk_.js +0 -1
  373. package/dist/chunks/config-DmomySWC.js +0 -3
  374. package/dist/chunks/config-WxgxrQoP.js +0 -1
  375. package/dist/chunks/context-Cl6BJ2vm.js +0 -1
  376. package/dist/chunks/context-noninteractive-9hELVC29.js +0 -54
  377. package/dist/chunks/context-noninteractive-Beij5MfU.js +0 -1
  378. package/dist/chunks/conversation-BBB91hEw.js +0 -1
  379. package/dist/chunks/conversation-BWVTM40Y.js +0 -1
  380. package/dist/chunks/createSession-CoQtL5Rj.js +0 -1
  381. package/dist/chunks/createSession-Cvl1Q50F.js +0 -1
  382. package/dist/chunks/cron-3LntnnhJ.js +0 -1
  383. package/dist/chunks/crossProjectResume-BasMLl2n.js +0 -40
  384. package/dist/chunks/cwd--nvsx73T.js +0 -1
  385. package/dist/chunks/cwd-CYmmnQVS.js +0 -1
  386. package/dist/chunks/debugUtils-NO5KtXqi.js +0 -1
  387. package/dist/chunks/desktop-B_L6T6jI.js +0 -1
  388. package/dist/chunks/detectRepository-BTPgN89l.js +0 -1
  389. package/dist/chunks/directoryCompletion-CW2ckkQg.js +0 -1
  390. package/dist/chunks/doctor-1L0TFuGw.js +0 -1
  391. package/dist/chunks/envLessBridgeConfig-CN0_44-p.js +0 -1
  392. package/dist/chunks/envLessBridgeConfig-Ck2-KMq0.js +0 -1
  393. package/dist/chunks/esm-D5q6s4l8.js +0 -1
  394. package/dist/chunks/exit-Bm1S_f3i.js +0 -1
  395. package/dist/chunks/extra-usage-UHAWtypK.js +0 -1
  396. package/dist/chunks/extra-usage-core-BFOolqoi.js +0 -1
  397. package/dist/chunks/extra-usage-noninteractive-cUGZy0en.js +0 -1
  398. package/dist/chunks/extra-usage-zDHVtWKZ.js +0 -1
  399. package/dist/chunks/extraUsage-Dq66zzqR.js +0 -1
  400. package/dist/chunks/extractMemories-BcaklA33.js +0 -1
  401. package/dist/chunks/fast-DALAHO3d.js +0 -1
  402. package/dist/chunks/fast-MS7WZpD8.js +0 -1
  403. package/dist/chunks/feedback-Fw4m28ZC.js +0 -1
  404. package/dist/chunks/file-DcZWPH2V.js +0 -12
  405. package/dist/chunks/fileStateCache-DDW5toIs.js +0 -1
  406. package/dist/chunks/files-Cz1-PK3r.js +0 -2
  407. package/dist/chunks/firstPartyEventLogger-CS9jVz6D.js +0 -1
  408. package/dist/chunks/firstPartyEventLogger-CoSUd0a1.js +0 -5
  409. package/dist/chunks/flushGate-De-yppeo.js +0 -1
  410. package/dist/chunks/gemini-BPziscyN.js +0 -1
  411. package/dist/chunks/generateSessionName-hDJ6HBJ1.js +0 -1
  412. package/dist/chunks/git-CbcnOf0E.js +0 -1
  413. package/dist/chunks/git-Do0wJvux.js +0 -6
  414. package/dist/chunks/githubRepoPathMapping-qAoiyj6P.js +0 -1
  415. package/dist/chunks/grok-Byblph7F.js +0 -1
  416. package/dist/chunks/grove-CpqjcGCb.js +0 -7
  417. package/dist/chunks/heapdump-C4kPlqGt.js +0 -5
  418. package/dist/chunks/help-B1h-faJ3.js +0 -1
  419. package/dist/chunks/hooks-DPLIIpAD.js +0 -1
  420. package/dist/chunks/hostGuard-BHI6Q8Mt.js +0 -1
  421. package/dist/chunks/inboundAttachments-BekVc0W-.js +0 -1
  422. package/dist/chunks/inboundAttachments-CUJE3KaU.js +0 -1
  423. package/dist/chunks/index.min-D75yiGLN.js +0 -1
  424. package/dist/chunks/initReplBridge-JQ-afRx9.js +0 -1
  425. package/dist/chunks/keybindings-BLw5J-Zj.js +0 -2
  426. package/dist/chunks/language-Cqw5gYJR.js +0 -1
  427. package/dist/chunks/launchAgentsPlatform-jWWf-Lk9.js +0 -1
  428. package/dist/chunks/launchCommand-1qkTCKpf.js +0 -1
  429. package/dist/chunks/launchLocalMemory-kHeD0I0y.js +0 -3
  430. package/dist/chunks/launchLocalVault-DLqkOjmb.js +0 -3
  431. package/dist/chunks/launchMemoryStores-Ct7AVXrO.js +0 -1
  432. package/dist/chunks/launchSchedule-ZyvuvjgU.js +0 -1
  433. package/dist/chunks/launchSkillStore-BejQnLog.js +0 -1
  434. package/dist/chunks/launchTeleport-8CuYUfIR.js +0 -3
  435. package/dist/chunks/launchVault-DIvIOuPh.js +0 -1
  436. package/dist/chunks/loadAgentsDir-TZjwTqdr.js +0 -1
  437. package/dist/chunks/loadPluginHooks-Ddhsyn0_.js +0 -1
  438. package/dist/chunks/localSearch-DrOAL6f4.js +0 -1
  439. package/dist/chunks/log-BMCygSzM.js +0 -1
  440. package/dist/chunks/logoV2Utils-8M56V7oN.js +0 -1
  441. package/dist/chunks/mcp-Bt1ITh-Z.js +0 -1
  442. package/dist/chunks/mcp-CwJ-AIpt.js +0 -6
  443. package/dist/chunks/mcp-W0LFoyFR.js +0 -2
  444. package/dist/chunks/memoize-B0zhbT8Z.js +0 -1
  445. package/dist/chunks/memory-3wV7m7UU.js +0 -1
  446. package/dist/chunks/model-CKkOnnnx.js +0 -1
  447. package/dist/chunks/model-DRXcJyU9.js +0 -1
  448. package/dist/chunks/nativeInstaller-CA5d6_G7.js +0 -1
  449. package/dist/chunks/observationStore-DzCdXq8U.js +0 -4
  450. package/dist/chunks/onChangeAppState-DBmy2Ow_.js +0 -1
  451. package/dist/chunks/openai-Cbomn0Ws.js +0 -10
  452. package/dist/chunks/output-style-BM3qAHLA.js +0 -1
  453. package/dist/chunks/overageCreditGrant-DsUrmeBh.js +0 -1
  454. package/dist/chunks/panel-Be-OxtqL.js +0 -1
  455. package/dist/chunks/parser-Bf6iasPV.js +0 -1
  456. package/dist/chunks/partition-BAakXjvj.js +0 -1
  457. package/dist/chunks/passes-CLRt7Cvm.js +0 -1
  458. package/dist/chunks/permissions-BVSFuwNP.js +0 -3
  459. package/dist/chunks/permissions-CeYKbtSC.js +0 -1
  460. package/dist/chunks/permissions-Cn_6f8CB.js +0 -1
  461. package/dist/chunks/plugin-Bfjzhmrk.js +0 -1
  462. package/dist/chunks/pluginAutoupdate-reO2PgtQ.js +0 -1
  463. package/dist/chunks/pluginCliCommands-lqdxdkQp.js +0 -1
  464. package/dist/chunks/pluginFlagging-D9HKAGBC.js +0 -1
  465. package/dist/chunks/pluginOperations-EN3EKLux.js +0 -2
  466. package/dist/chunks/pluginStartupCheck-BY73BMT2.js +0 -1
  467. package/dist/chunks/pluginStartupCheck-CwWOlveD.js +0 -1
  468. package/dist/chunks/policyLimits-CkTI5KEt.js +0 -1
  469. package/dist/chunks/pollConfig-DH2oCtFS.js +0 -1
  470. package/dist/chunks/poor-j-y-bv8o.js +0 -1
  471. package/dist/chunks/poorMode-V11s-3cf.js +0 -1
  472. package/dist/chunks/print-Db_VXmfO.js +0 -23
  473. package/dist/chunks/privacy-settings-DHMJREbb.js +0 -1
  474. package/dist/chunks/processBashCommand-BcM_fhV9.js +0 -1
  475. package/dist/chunks/processSlashCommand-DEVo3GPX.js +0 -5
  476. package/dist/chunks/prompt-BNHtszmZ.js +0 -139
  477. package/dist/chunks/prompt-CrX31AGm.js +0 -1
  478. package/dist/chunks/prompt-IAvMxKDl.js +0 -1
  479. package/dist/chunks/rate-limit-options-DIudL9fb.js +0 -1
  480. package/dist/chunks/rcDebugLog-CUy1_F23.js +0 -11
  481. package/dist/chunks/reconciler-BXpPyfSY.js +0 -4
  482. package/dist/chunks/referral-CUaIo_vT.js +0 -1
  483. package/dist/chunks/refresh-CuaVBIQ0.js +0 -1
  484. package/dist/chunks/registerProtocol-B7Fzdofu.js +0 -36
  485. package/dist/chunks/release-notes-fbfv2DC0.js +0 -4
  486. package/dist/chunks/releaseNotes-CxAHFLPl.js +0 -2
  487. package/dist/chunks/remote-env-BOklGlll.js +0 -1
  488. package/dist/chunks/remoteBridgeCore-j0bG1zjv.js +0 -1
  489. package/dist/chunks/remoteManagedSettings-Cq994lyc.js +0 -1
  490. package/dist/chunks/rename-Iev7wQsI.js +0 -1
  491. package/dist/chunks/ripgrep-BfIpz5uC.js +0 -1
  492. package/dist/chunks/runtimeObserver-CyzLASla.js +0 -10
  493. package/dist/chunks/sandbox-adapter-Cu1FYrkh.js +0 -1
  494. package/dist/chunks/sandbox-toggle-CWpBO228.js +0 -1
  495. package/dist/chunks/sanitization-DV-94a9Z.js +0 -1
  496. package/dist/chunks/searchExtraTools-BUOUds7p.js +0 -1
  497. package/dist/chunks/semver-BMRJYn3q.js +0 -1
  498. package/dist/chunks/session-DL4cA_8l.js +0 -2
  499. package/dist/chunks/sessionDiscovery-DAfNKqp1.js +0 -1
  500. package/dist/chunks/sessionFileAccessHooks-2cgIIxPk.js +0 -1
  501. package/dist/chunks/sessionMemory-BS8_TbKj.js +0 -1
  502. package/dist/chunks/sessionMemory-D5fSHXvZ.js +0 -1
  503. package/dist/chunks/sessionMemoryUtils-BWUztNh6.js +0 -1
  504. package/dist/chunks/sessionObserver-ChfQtK2m.js +0 -1
  505. package/dist/chunks/sessionObserver-ShbCwJ8x.js +0 -20
  506. package/dist/chunks/sessionStorage-Cf5wmnyB.js +0 -1
  507. package/dist/chunks/sessionTracing-D9rUyiq0.js +0 -11
  508. package/dist/chunks/settings-BovzmwMP.js +0 -19
  509. package/dist/chunks/settingsSync-PqU9XGJq.js +0 -1
  510. package/dist/chunks/setup-B_FOvNpp.js +0 -3
  511. package/dist/chunks/sinks-BpcRrN_T.js +0 -1
  512. package/dist/chunks/skill-learning-B5tmc7EX.js +0 -5
  513. package/dist/chunks/skillChangeDetector-DNqohXxz.js +0 -1
  514. package/dist/chunks/skillGapStore-D-kQKVDZ.js +0 -1
  515. package/dist/chunks/skillGapStore-Df5BWAk5.js +0 -5
  516. package/dist/chunks/skillGenerator-DbcdpAkw.js +0 -8
  517. package/dist/chunks/skillLearning-C5cXZE6_.js +0 -1
  518. package/dist/chunks/skillLearning-ClRiDcJH.js +0 -1
  519. package/dist/chunks/skillPanel-LBd4E-MM.js +0 -28
  520. package/dist/chunks/slashCommandParsing-RQb_7Xzt.js +0 -1
  521. package/dist/chunks/startupProfiler-DIWVcO4e.js +0 -1
  522. package/dist/chunks/startupProfiler-xa3NmN7Z.js +0 -3
  523. package/dist/chunks/state-BOa-3Av3.js +0 -1
  524. package/dist/chunks/statusNoticeHelpers-CzTuGNuC.js +0 -1
  525. package/dist/chunks/stickers-D5teCKMN.js +0 -1
  526. package/dist/chunks/systemPromptSections-CR_AoPIX.js +0 -1
  527. package/dist/chunks/systemPromptSections-DN0HGVye.js +0 -1
  528. package/dist/chunks/tag-B-wVW9Aj.js +0 -11
  529. package/dist/chunks/teleport-dtqQXM4x.js +0 -1
  530. package/dist/chunks/terminalSetup-CuV-qU6v.js +0 -33
  531. package/dist/chunks/thinkback-Catprqs_.js +0 -1
  532. package/dist/chunks/thinkback-DI2NpvG-.js +0 -1
  533. package/dist/chunks/thinkback-play-CqrIRx2o.js +0 -1
  534. package/dist/chunks/toolEventObserver-DlH73w-S.js +0 -1
  535. package/dist/chunks/toolPool-B64V-jmK.js +0 -1
  536. package/dist/chunks/trustedDevice-CiwjT_Y6.js +0 -1
  537. package/dist/chunks/tui-C2yuCuOU.js +0 -6
  538. package/dist/chunks/types-Bh9S_JG5.js +0 -3
  539. package/dist/chunks/types-DHkZVzJe.js +0 -1
  540. package/dist/chunks/ultrareviewCommand-BDFUS3hf.js +0 -3
  541. package/dist/chunks/undercover-XYapZ_SS.js +0 -1
  542. package/dist/chunks/undercover-vuTpCnQJ.js +0 -31
  543. package/dist/chunks/upgrade-D5qwcaWQ.js +0 -1
  544. package/dist/chunks/upgrade-DIg3j929.js +0 -1
  545. package/dist/chunks/upload-B_yADHX9.js +0 -1
  546. package/dist/chunks/usage-C0SnnC-i.js +0 -1
  547. package/dist/chunks/usage-CYJKE8N6.js +0 -1
  548. package/dist/chunks/useExitOnCtrlCDWithKeybindings-DKIqRraH.js +0 -1
  549. package/dist/chunks/useMainLoopModel-XetDUXd-.js +0 -1
  550. package/dist/chunks/useManagePlugins-B2KhKiu5.js +0 -1
  551. package/dist/chunks/useMergedTools-CKvwz_Zt.js +0 -1
  552. package/dist/chunks/useSettingsErrors-B7BXHchG.js +0 -1
  553. package/dist/chunks/validatePlugin-DtiYlXby.js +0 -1
  554. package/dist/chunks/windowsPaths-9pEkw0oV.js +0 -1
  555. package/dist/chunks/workerRegistry-ChqPPIaO.js +0 -1
  556. package/dist/chunks/worktree-DAn8ooa1.js +0 -1
@@ -0,0 +1,17 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{a as t,l as n}from"./proxy-BmtEnJ02.js";import{r,t as i}from"./store-Z8rTjDHe.js";function a(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 o(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 s=e((()=>{})),c,l=e((()=>{c=function(){let{crypto:e}=globalThis;if(e?.randomUUID)return c=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 u(e){return typeof e==`object`&&!!e&&(`name`in e&&e.name===`AbortError`||`message`in e&&String(e.message).includes(`FetchRequestCanceledException`))}var d,f=e((()=>{d=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)}})),p,m,h,g,ee,_,v,y,te,ne,re,ie,ae,oe,se,ce,le,ue,de=e((()=>{f(),p=class extends Error{},m=class e extends p{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 g({message:r,cause:d(n)});let a=n?.error;return t===400?new _(t,a,r,i):t===401?new v(t,a,r,i):t===403?new y(t,a,r,i):t===404?new te(t,a,r,i):t===409?new ne(t,a,r,i):t===422?new re(t,a,r,i):t===429?new ie(t,a,r,i):t>=500?new ae(t,a,r,i):new e(t,a,r,i)}},h=class extends m{constructor({message:e}={}){super(void 0,void 0,e||`Request was aborted.`,void 0)}},g=class extends m{constructor({message:e,cause:t}){super(void 0,void 0,e||`Connection error.`,void 0),t&&(this.cause=t)}},ee=class extends g{constructor({message:e}={}){super({message:e??`Request timed out.`})}},_=class extends m{},v=class extends m{},y=class extends m{},te=class extends m{},ne=class extends m{},re=class extends m{},ie=class extends m{},ae=class extends m{},oe=class extends p{constructor(){super(`Could not parse response content as the length limit was reached`)}},se=class extends p{constructor(){super(`Could not parse response content as the request was rejected by the content filter`)}},ce=class extends Error{constructor(e){super(e)}},le=class extends m{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}},ue=class extends p{constructor(e,t,n){super(e),this.provider=t,this.cause=n}}}));function fe(e){return typeof e==`object`?e??{}:{}}function pe(e){if(!e)return!0;for(let t in e)return!1;return!0}function me(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function he(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var ge,_e,b,ve,ye,be,xe=e((()=>{de(),ge=/^[a-z][a-z0-9+.-]*:/i,_e=e=>ge.test(e),b=e=>(b=Array.isArray,b(e)),ve=b,ye=(e,t)=>{if(typeof t!=`number`||!Number.isInteger(t))throw new p(`${e} must be an integer`);if(t<0)throw new p(`${e} must be a positive integer`);return t},be=e=>{try{return JSON.parse(e)}catch{return}}})),Se,Ce=e((()=>{Se=e=>new Promise(t=>setTimeout(t,e))})),we,Te=e((()=>{we=`6.46.0`}));function Ee(){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 De(){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 Oe,ke,Ae,je,Me,Ne,Pe=e((()=>{Te(),Oe=()=>typeof window<`u`&&window.document!==void 0&&typeof navigator<`u`,ke=()=>{let e=Ee();if(e===`deno`)return{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":we,"X-Stainless-OS":je(Deno.build.os),"X-Stainless-Arch":Ae(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":we,"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":we,"X-Stainless-OS":je(globalThis.process.platform??`unknown`),"X-Stainless-Arch":Ae(globalThis.process.arch??`unknown`),"X-Stainless-Runtime":`node`,"X-Stainless-Runtime-Version":globalThis.process.version??`unknown`};let t=De();return t?{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":we,"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":we,"X-Stainless-OS":`Unknown`,"X-Stainless-Arch":`unknown`,"X-Stainless-Runtime":`unknown`,"X-Stainless-Runtime-Version":`unknown`}},Ae=e=>e===`x32`?`x32`:e===`x86_64`||e===`x64`?`x64`:e===`arm`?`arm`:e===`aarch64`||e===`arm64`?`arm64`:e?`other:${e}`:`unknown`,je=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`),Ne=()=>Me??(Me=ke())}));function Fe(){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 Ie(...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 Le(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator]();return Ie({start(){},async pull(e){let{done:n,value:r}=await t.next();n?e.close():e.enqueue(r)},async cancel(){await t.return?.()}})}function Re(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 ze(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 Be=e((()=>{})),Ve,He=e((()=>{Ve=({headers:e,body:t})=>({bodyHeaders:{"content-type":`application/json`},body:JSON.stringify(t)})})),Ue,We,Ge,Ke=e((()=>{Ue=`RFC3986`,We=e=>String(e),Ge={RFC1738:e=>String(e).replace(/%20/g,`+`),RFC3986:We}}));function qe(e){return!e||typeof e!=`object`?!1:!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))}function Je(e,t){if(b(e)){let n=[];for(let r=0;r<e.length;r+=1)n.push(t(e[r]));return n}return t(e)}var Ye,x,Xe,Ze,Qe=e((()=>{Ke(),xe(),Ye=(e,t)=>(Ye=Object.hasOwn??Function.prototype.call.bind(Object.prototype.hasOwnProperty),Ye(e,t)),x=(()=>{let e=[];for(let t=0;t<256;++t)e.push(`%`+((t<16?`0`:``)+t.toString(16)).toUpperCase());return e})(),Xe=1024,Ze=(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+=Xe){let t=a.length>=Xe?a.slice(e,e+Xe):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]=x[r];continue}if(r<2048){n[n.length]=x[192|r>>6]+x[128|r&63];continue}if(r<55296||r>=57344){n[n.length]=x[224|r>>12]+x[128|r>>6&63]+x[128|r&63];continue}e+=1,r=65536+((r&1023)<<10|t.charCodeAt(e)&1023),n[n.length]=x[240|r>>18]+x[128|r>>12&63]+x[128|r>>6&63]+x[128|r&63]}o+=n.join(``)}return o}}));function $e(e){return typeof e==`string`||typeof e==`number`||typeof e==`boolean`||typeof e==`symbol`||typeof e==`bigint`}function et(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,ee){let _=e,v=ee,y=0,te=!1;for(;(v=v.get(ot))!==void 0&&!te;){let t=v.get(e);if(y+=1,t!==void 0){if(t===y)throw RangeError(`Cyclic object value`);te=!0}v.get(ot)===void 0&&(y=0)}if(typeof l==`function`?_=l(t,_):_ instanceof Date?_=f?.(_):n===`comma`&&b(_)&&(_=Je(_,function(e){return e instanceof Date?f?.(e):e})),_===null){if(a)return c&&!h?c(t,S.encoder,g,`key`,p):t;_=``}if($e(_)||qe(_)){if(c){let e=h?t:c(t,S.encoder,g,`key`,p);return[m?.(e)+`=`+m?.(c(_,S.encoder,g,`value`,p))]}return[m?.(t)+`=`+m?.(String(_))]}let ne=[];if(_===void 0)return ne;let re;if(n===`comma`&&b(_))h&&c&&(_=Je(_,c)),re=[{value:_.length>0?_.join(`,`)||null:void 0}];else if(b(l))re=l;else{let e=Object.keys(_);re=u?e.sort(u):e}let ie=s?String(t).replace(/\./g,`%2E`):String(t),ae=r&&b(_)&&_.length===1?ie+`[]`:ie;if(i&&b(_)&&_.length===0)return ae+`[]`;for(let t=0;t<re.length;++t){let v=re[t],te=typeof v==`object`&&v.value!==void 0?v.value:_[v];if(o&&te===null)continue;let ie=d&&s?v.replace(/\./g,`%2E`):v,oe=b(_)?typeof n==`function`?n(ae,ie):ae:ae+(d?`.`+ie:`[`+ie+`]`);ee.set(e,y);let se=new WeakMap;se.set(ot,ee),it(ne,et(te,oe,n,r,i,a,o,s,n===`comma`&&h&&b(_)?null:c,l,u,d,f,p,m,h,g,se))}return ne}function tt(e=S){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||S.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=Ue;if(e.format!==void 0){if(!Ye(Ge,e.format))throw TypeError(`Unknown format option provided.`);n=e.format}let r=Ge[n],i=S.filter;(typeof e.filter==`function`||b(e.filter))&&(i=e.filter);let a;if(a=e.arrayFormat&&e.arrayFormat in rt?e.arrayFormat:`indices`in e?e.indices?`indices`:`repeat`:S.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:S.allowDots:!!e.allowDots;return{addQueryPrefix:typeof e.addQueryPrefix==`boolean`?e.addQueryPrefix:S.addQueryPrefix,allowDots:o,allowEmptyArrays:typeof e.allowEmptyArrays==`boolean`?!!e.allowEmptyArrays:S.allowEmptyArrays,arrayFormat:a,charset:t,charsetSentinel:typeof e.charsetSentinel==`boolean`?e.charsetSentinel:S.charsetSentinel,commaRoundTrip:!!e.commaRoundTrip,delimiter:e.delimiter===void 0?S.delimiter:e.delimiter,encode:typeof e.encode==`boolean`?e.encode:S.encode,encodeDotInKeys:typeof e.encodeDotInKeys==`boolean`?e.encodeDotInKeys:S.encodeDotInKeys,encoder:typeof e.encoder==`function`?e.encoder:S.encoder,encodeValuesOnly:typeof e.encodeValuesOnly==`boolean`?e.encodeValuesOnly:S.encodeValuesOnly,filter:i,format:n,formatter:r,serializeDate:typeof e.serializeDate==`function`?e.serializeDate:S.serializeDate,skipNulls:typeof e.skipNulls==`boolean`?e.skipNulls:S.skipNulls,sort:typeof e.sort==`function`?e.sort:null,strictNullHandling:typeof e.strictNullHandling==`boolean`?e.strictNullHandling:S.strictNullHandling}}function nt(e,t={}){let n=e,r=tt(t),i,a;typeof r.filter==`function`?(a=r.filter,n=a(``,n)):b(r.filter)&&(a=r.filter,i=a);let o=[];if(typeof n!=`object`||!n)return``;let s=rt[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||it(o,et(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 rt,it,at,S,ot,st=e((()=>{Qe(),Ke(),xe(),rt={brackets(e){return String(e)+`[]`},comma:`comma`,indices(e,t){return String(e)+`[`+t+`]`},repeat(e){return String(e)}},it=function(e,t){Array.prototype.push.apply(e,b(t)?t:[t])},S={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:`indices`,charset:`utf-8`,charsetSentinel:!1,delimiter:`&`,encode:!0,encodeDotInKeys:!1,encoder:Ze,encodeValuesOnly:!1,format:Ue,formatter:We,indices:!1,serializeDate(e){return(at??(at=Function.prototype.call.bind(Date.prototype.toISOString)))(e)},skipNulls:!1,strictNullHandling:!1},ot={}}));function ct(e){return nt(e,{arrayFormat:`brackets`})}var lt=e((()=>{st()}));function ut(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 dt(e){let t;return(pt??(t=new globalThis.TextEncoder,pt=t.encode.bind(t)))(e)}function ft(e){let t;return(mt??(t=new globalThis.TextDecoder,mt=t.decode.bind(t)))(e)}var pt,mt,ht=e((()=>{}));function gt(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 _t(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 C,w,vt,yt=e((()=>{s(),ht(),vt=class{constructor(){C.set(this,void 0),w.set(this,void 0),a(this,C,new Uint8Array,`f`),a(this,w,null,`f`)}decode(e){if(e==null)return[];let t=e instanceof ArrayBuffer?new Uint8Array(e):typeof e==`string`?dt(e):e;a(this,C,ut([o(this,C,`f`),t]),`f`);let n=[],r;for(;(r=gt(o(this,C,`f`),o(this,w,`f`)))!=null;){if(r.carriage&&o(this,w,`f`)==null){a(this,w,r.index,`f`);continue}if(o(this,w,`f`)!=null&&(r.index!==o(this,w,`f`)+1||r.carriage)){n.push(ft(o(this,C,`f`).subarray(0,o(this,w,`f`)-1))),a(this,C,o(this,C,`f`).subarray(o(this,w,`f`)),`f`),a(this,w,null,`f`);continue}let e=o(this,w,`f`)===null?r.preceding:r.preceding-1,t=ft(o(this,C,`f`).subarray(0,e));n.push(t),a(this,C,o(this,C,`f`).subarray(r.index),`f`),a(this,w,null,`f`)}return n}flush(){return o(this,C,`f`).length?this.decode(`
2
+ `):[]}},C=new WeakMap,w=new WeakMap,vt.NEWLINE_CHARS=new Set([`
3
+ `,`\r`]),vt.NEWLINE_REGEXP=/\r\n|[\n\r]/g}));function bt(){}function xt(e,t,n){return!t||St[e]>St[n]?bt:t[e].bind(t)}function T(e){let t=e.logger,n=e.logLevel??`off`;if(!t)return wt;let r=Tt.get(t);if(r&&r[0]===n)return r[1];let i={error:xt(`error`,t,n),warn:xt(`warn`,t,n),info:xt(`info`,t,n),debug:xt(`debug`,t,n)};return Tt.set(t,[n,i]),i}var St,Ct,wt,Tt,Et,Dt=e((()=>{xe(),St={off:0,error:200,warn:300,info:400,debug:500},Ct=(e,t,n)=>{if(e){if(me(St,e))return e;T(n).warn(`${t} was set to ${JSON.stringify(e)}, expected one of ${JSON.stringify(Object.keys(St))}`)}},wt={error:bt,warn:bt,info:bt,debug:bt},Tt=new WeakMap,Et=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()===`api-key`||e.toLowerCase()===`x-api-key`||e.toLowerCase()===`x-amz-security-token`||e.toLowerCase()===`cookie`||e.toLowerCase()===`set-cookie`?`***`:t]))),`retryOfRequestLogID`in e&&(e.retryOfRequestLogID&&(e.retryOf=e.retryOfRequestLogID),delete e.retryOfRequestLogID),e)}));async function*Ot(e,t){if(!e.body)throw t.abort(),globalThis.navigator!==void 0&&globalThis.navigator.product===`ReactNative`?new p(`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 p(`Attempted to iterate over a response with no body`);let n=new Nt,r=new vt,i=Re(e.body);for await(let e of kt(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*kt(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`?dt(n):n,r=new Uint8Array(t.length+e.length);r.set(t),r.set(e,t.length),t=r;let i;for(;(i=_t(t))!==-1;)yield t.slice(0,i),t=t.slice(i)}t.length>0&&(yield t)}function At(e,t){let n=e.indexOf(t);return n===-1?[e,``,``]:[e.substring(0,n),t,e.substring(n+t.length)]}var jt,Mt,Nt,Pt=e((()=>{s(),de(),Be(),yt(),f(),ht(),Dt(),Mt=class e{constructor(e,t,n){this.iterator=e,jt.set(this,void 0),this.controller=t,a(this,jt,n,`f`)}static fromSSEResponse(t,n,r,i){let a=!1,o=r?T(r):console;async function*s(){if(a)throw new p("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");a=!0;let e=!1;try{for await(let r of Ot(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 o.error(`Could not parse message into JSON:`,r.data),o.error(`From chunk:`,r.raw),e}if(e&&e.error)throw new m(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 m(void 0,e.error,e.message,void 0);yield{event:r.event,data:e}}}e=!0}catch(e){if(u(e))return;throw e}finally{e||n.abort()}}return new e(s,n,r)}static fromReadableStream(t,n,r){let i=!1;async function*a(){let e=new vt,n=Re(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*o(){if(i)throw new p("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(u(e))return;throw e}finally{e||n.abort()}}return new e(o,n,r)}[(jt=new WeakMap,Symbol.asyncIterator)](){return this.iterator()}tee(){let t=[],n=[],r=this.iterator(),i=e=>({next:()=>{if(e.length===0){let e=r.next();t.push(e),n.push(e)}return e.shift()}});return[new e(()=>i(t),this.controller,o(this,jt,`f`)),new e(()=>i(n),this.controller,o(this,jt,`f`))]}toReadableStream(){let e=this,t;return Ie({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=dt(JSON.stringify(n)+`
4
+ `);e.enqueue(i)}catch(t){e.error(t)}},async cancel(){await t.return?.()}})}},Nt=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]=At(e,`:`);return r.startsWith(` `)&&(r=r.substring(1)),t===`event`?this.event=r:t===`data`&&this.data.push(r),null}}}));async function Ft(e,t){let{response:n,requestLogID:r,retryOfRequestLogID:i,startTime:a}=t,o=await(async()=>{if(t.options.stream)return T(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):Mt.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:It(await n.json(),n):await n.text()})();return T(e).debug(`[${r}] response parsed`,Et({retryOfRequestLogID:i,url:n.url,status:n.status,body:o,durationMs:Date.now()-a})),o}function It(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 Lt=e((()=>{Pt(),Dt()})),Rt,zt,Bt=e((()=>{s(),Lt(),zt=class e extends Promise{constructor(e,t,n=Ft){super(e=>{e(null)}),this.responsePromise=t,this.parseResponse=n,Rt.set(this,void 0),a(this,Rt,e,`f`)}_thenUnwrap(t){return new e(o(this,Rt,`f`),this.responsePromise,async(e,n)=>It(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(o(this,Rt,`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)}},Rt=new WeakMap})),Vt,Ht,Ut,E,D,O,k,A=e((()=>{s(),de(),Lt(),Bt(),xe(),Ht=class{constructor(e,t,n,r){Vt.set(this,void 0),a(this,Vt,e,`f`),this.options=r,this.response=t,this.body=n}hasNextPage(){return this.getPaginatedItems().length?this.nextPageRequestOptions()!=null:!1}async getNextPage(){let e=this.nextPageRequestOptions();if(!e)throw new p("No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.");return await o(this,Vt,`f`).requestAPIList(this.constructor,e)}async*iterPages(){let e=this;for(yield e;e.hasNextPage();)e=await e.getNextPage(),yield e}async*[(Vt=new WeakMap,Symbol.asyncIterator)](){for await(let e of this.iterPages())for(let t of e.getPaginatedItems())yield t}},Ut=class extends zt{constructor(e,t,n){super(e,t,async(e,t)=>new n(e,t.response,await Ft(e,t),t.options))}async*[Symbol.asyncIterator](){let e=await this;for await(let t of e)yield t}},E=class extends Ht{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}},D=class extends Ht{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&&super.hasNextPage()}nextPageRequestOptions(){let e=this.getPaginatedItems(),t=e[e.length-1]?.id;return t?{...this.options,query:{...fe(this.options.query),after:t}}:null}},O=class extends Ht{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&&super.hasNextPage()}nextPageRequestOptions(){let e=this.last_id;return e?{...this.options,query:{...fe(this.options.query),after:e}}:null}},k=class extends Ht{constructor(e,t,n,r){super(e,t,n,r),this.data=n.data||[],this.has_more=n.has_more||!1,this.next=n.next||null}getPaginatedItems(){return this.data??[]}hasNextPage(){return this.has_more!==!1&&super.hasNextPage()}nextPageRequestOptions(){let e=this.next;return e?{...this.options,query:{...fe(this.options.query),after:e}}:null}}})),Wt,Gt,Kt,qt=e((()=>{Be(),de(),Wt={jwt:`urn:ietf:params:oauth:token-type:jwt`,id:`urn:ietf:params:oauth:token-type:id_token`},Gt=`urn:ietf:params:oauth:grant-type:token-exchange`,Kt=class{constructor(e,t){this.cachedToken=null,this.refreshPromise=null,this.tokenExchangeUrl=`https://auth.openai.com/oauth/token`,this.config=e,this.fetch=t??Fe()}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={grant_type:Gt,subject_token:e,subject_token_type:Wt[this.config.provider.tokenType],identity_provider_id:this.config.identityProviderId,service_account_id:this.config.serviceAccountId};this.config.clientId&&(t.client_id=this.config.clientId);let n=await this.fetch(this.tokenExchangeUrl,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!n.ok){let e=await n.text(),t;try{t=JSON.parse(e)}catch{}throw n.status===400||n.status===401||n.status===403?new le(n.status,t,n.headers):m.generate(n.status,t,`Token exchange failed with status ${n.status}`,n.headers)}let r=await n.json();if(typeof r!=`object`||!r||!(`access_token`in r)||typeof r.access_token!=`string`||r.access_token.trim().length===0)throw new p(`Token exchange response missing 'access_token' field`);let i=r.access_token,a=r.expires_in??3600,o=Date.now()+a*1e3;return this.cachedToken={token:i,expiresAt:o},i}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 Jt(e,t,n){return Zt(),new File(e,t??`unknown_file`,n)}function Yt(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 Xt(e){let t=typeof e==`function`?e:e.fetch,n=en.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 en.set(t,r),r}var Zt,Qt,$t,j,en,tn,nn,rn,an,on,M=e((()=>{Be(),Zt=()=>{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`.":``))}},Qt=e=>typeof e==`object`&&!!e&&typeof e[Symbol.asyncIterator]==`function`,$t=async(e,t)=>an(e.body)?{...e,body:await tn(e.body,t)}:e,j=async(e,t)=>({...e,body:await tn(e.body,t)}),en=new WeakMap,tn=async(e,t)=>{if(!await Xt(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])=>on(n,e,t))),n},nn=e=>e instanceof Blob&&`name`in e,rn=e=>typeof e==`object`&&!!e&&(e instanceof Response||Qt(e)||nn(e)),an=e=>{if(rn(e))return!0;if(Array.isArray(e))return e.some(an);if(e&&typeof e==`object`){for(let t in e)if(an(e[t]))return!0}return!1},on=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,Jt([await n.blob()],Yt(n)));else if(Qt(n))e.append(t,Jt([await new Response(Le(n)).blob()],Yt(n)));else if(nn(n))e.append(t,n,Yt(n));else if(Array.isArray(n))await Promise.all(n.map(n=>on(e,t+`[]`,n)));else if(typeof n==`object`)await Promise.all(Object.entries(n).map(([n,r])=>on(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 sn(e,t,n){if(Zt(),e=await e,dn(e))return e instanceof File?e:Jt([await e.arrayBuffer()],e.name);if(fn(e)){let r=await e.blob();return t||(t=new URL(e.url).pathname.split(/[\\/]/).pop()),Jt(await cn(r),t,n)}let r=await cn(e);if(t||(t=Yt(e)),!n?.type){let e=r.find(e=>typeof e==`object`&&`type`in e&&e.type);typeof e==`string`&&(n={...n,type:e})}return Jt(r,t,n)}async function cn(e){let t=[];if(typeof e==`string`||ArrayBuffer.isView(e)||e instanceof ArrayBuffer)t.push(e);else if(un(e))t.push(e instanceof Blob?e:await e.arrayBuffer());else if(Qt(e))for await(let n of e)t.push(...await cn(n));else{let t=e?.constructor?.name;throw Error(`Unexpected data type: ${typeof e}${t?`; constructor: ${t}`:``}${ln(e)}`)}return t}function ln(e){return typeof e!=`object`||!e?``:`; props: [${Object.getOwnPropertyNames(e).map(e=>`"${e}"`).join(`, `)}]`}var un,dn,fn,pn=e((()=>{M(),un=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`,dn=e=>typeof e==`object`&&!!e&&typeof e.name==`string`&&typeof e.lastModified==`number`&&un(e),fn=e=>typeof e==`object`&&!!e&&typeof e.url==`string`&&typeof e.blob==`function`})),mn=e((()=>{pn()})),N,P=e((()=>{N=class{constructor(e){this._client=e}}}));function hn(e){return e.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g,encodeURIComponent)}var gn,_n,F,I=e((()=>{de(),gn=Object.freeze(Object.create(null)),_n=(e=hn)=>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??gn)??gn)?.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 p(`Path parameters result in path with invalid segments:\n${i.map(e=>e.error).join(`
6
+ `)}\n${a}\n${t}`)}return a},F=_n(hn)})),vn,yn=e((()=>{P(),A(),I(),vn=class extends N{list(e,t={},n){return this._client.getAPIList(F`/chat/completions/${e}/messages`,D,{query:t,...n,__security:{bearerAuth:!0}})}}})),L=e((()=>{de()}));function bn(e){return e!==void 0&&`function`in e&&e.function!==void 0}function xn(e){return e?.$brand===`auto-parseable-response-format`}function Sn(e){return e?.$brand===`auto-parseable-tool`}function Cn(e,t){return!t||!On(t)?{...e,choices:e.choices.map(e=>(kn(e.message.tool_calls),{...e,message:{...e.message,parsed:null,...e.message.tool_calls?{tool_calls:e.message.tool_calls}:void 0}}))}:wn(e,t)}function wn(e,t){let n=e.choices.map(e=>{if(e.finish_reason===`length`)throw new oe;if(e.finish_reason===`content_filter`)throw new se;return kn(e.message.tool_calls),{...e,message:{...e.message,...e.message.tool_calls?{tool_calls:e.message.tool_calls?.map(e=>En(t,e))??void 0}:void 0,parsed:e.message.content&&!e.message.refusal?Tn(t,e.message.content):null}}});return{...e,choices:n}}function Tn(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 En(e,t){let n=e.tools?.find(e=>bn(e)&&e.function?.name===t.function.name);return{...t,function:{...t.function,parsed_arguments:Sn(n)?n.$parseRaw(t.function.arguments):n?.function.strict?JSON.parse(t.function.arguments):null}}}function Dn(e,t){if(!e||!(`tools`in e)||!e.tools)return!1;let n=e.tools?.find(e=>bn(e)&&e.function?.name===t.function.name);return bn(n)&&(Sn(n)||n?.function.strict||!1)}function On(e){return xn(e.response_format)?!0:e.tools?.some(e=>Sn(e)||e.type===`function`&&e.function.strict===!0)??!1}function kn(e){for(let t of e||[])if(t.type!==`function`)throw new p(`Currently only \`function\` tool calls are supported; Received \`${t.type}\``)}function An(e){for(let t of e??[]){if(t.type!==`function`)throw new p(`Currently only \`function\` tool types support auto-parsing; Received \`${t.type}\``);if(t.function.strict!==!0)throw new p(`The \`${t.function.name}\` tool is not marked with \`strict: true\`. Only strict function tools can be auto-parsed`)}}var jn=e((()=>{L()})),Mn,Nn,Pn=e((()=>{Mn=e=>e?.role===`assistant`,Nn=e=>e?.role===`tool`})),Fn,In,Ln,Rn,zn,Bn,Vn,R,Hn,Un,Wn,Gn,Kn,qn,Jn,Yn,Xn=e((()=>{s(),L(),Yn=class{constructor(){Fn.add(this),this.controller=new AbortController,In.set(this,void 0),Ln.set(this,()=>{}),Rn.set(this,()=>{}),zn.set(this,void 0),Bn.set(this,()=>{}),Vn.set(this,()=>{}),R.set(this,{}),Hn.set(this,[]),Un.set(this,!1),Wn.set(this,!1),Gn.set(this,!1),Kn.set(this,!1),a(this,In,new Promise((e,t)=>{a(this,Ln,e,`f`),a(this,Rn,t,`f`)}),`f`),a(this,zn,new Promise((e,t)=>{a(this,Bn,e,`f`),a(this,Vn,t,`f`)}),`f`),o(this,In,`f`).catch(()=>{}),o(this,zn,`f`).catch(()=>{})}_run(e){setTimeout(()=>{e().then(()=>{this._emitFinal(),this._emit(`end`)},o(this,Fn,`m`,Jn).bind(this))},0)}_connected(){this.ended||(o(this,Ln,`f`).call(this),this._emit(`connect`))}get ended(){return o(this,Un,`f`)}get errored(){return o(this,Wn,`f`)}get aborted(){return o(this,Gn,`f`)}abort(){this.controller.abort()}_listenForAbort(e){if(!e||this.ended)return;if(e.aborted){this.controller.abort();return}let t=()=>this.controller.abort();e.addEventListener(`abort`,t,{once:!0}),o(this,Hn,`f`).push({signal:e,listener:t})}on(e,t){return(o(this,R,`f`)[e]||(o(this,R,`f`)[e]=[])).push({listener:t}),this}off(e,t){let n=o(this,R,`f`)[e];if(!n)return this;let r=n.findIndex(e=>e.listener===t);return r>=0&&n.splice(r,1),this}once(e,t){return(o(this,R,`f`)[e]||(o(this,R,`f`)[e]=[])).push({listener:t,once:!0}),this}emitted(e){return new Promise((t,n)=>{a(this,Kn,!0,`f`),e!==`error`&&this.once(`error`,n),this.once(e,t)})}async done(){a(this,Kn,!0,`f`),await o(this,zn,`f`)}_emit(e,...t){if(o(this,Un,`f`))return;e===`end`&&(o(this,Fn,`m`,qn).call(this),a(this,Un,!0,`f`),o(this,Bn,`f`).call(this));let n=o(this,R,`f`)[e];if(n&&(o(this,R,`f`)[e]=n.filter(e=>!e.once),n.forEach(({listener:e})=>e(...t))),e===`abort`){let e=t[0];!o(this,Kn,`f`)&&!n?.length&&Promise.reject(e),o(this,Rn,`f`).call(this,e),o(this,Vn,`f`).call(this,e),this._emit(`end`);return}if(e===`error`){let e=t[0];!o(this,Kn,`f`)&&!n?.length&&Promise.reject(e),o(this,Rn,`f`).call(this,e),o(this,Vn,`f`).call(this,e),this._emit(`end`)}}_emitFinal(){}},In=new WeakMap,Ln=new WeakMap,Rn=new WeakMap,zn=new WeakMap,Bn=new WeakMap,Vn=new WeakMap,R=new WeakMap,Hn=new WeakMap,Un=new WeakMap,Wn=new WeakMap,Gn=new WeakMap,Kn=new WeakMap,Fn=new WeakSet,qn=function(){for(let{signal:e,listener:t}of o(this,Hn,`f`).splice(0))e.removeEventListener(`abort`,t)},Jn=function(e){if(a(this,Wn,!0,`f`),e instanceof Error&&e.name===`AbortError`&&(e=new h),e instanceof h)return a(this,Gn,!0,`f`),this._emit(`abort`,e);if(e instanceof p)return this._emit(`error`,e);if(e instanceof Error){let t=new p(e.message);return t.cause=e,this._emit(`error`,t)}return this._emit(`error`,new p(String(e)))}}));function Zn(e){return typeof e.parse==`function`}var Qn=e((()=>{}));function $n(e){for(let t of e.choices)for(let e of t.message.tool_calls??[])e.id||(e.id=`call_${c()}`)}var z,er,tr,nr,rr,ir,ar,or,sr,cr,lr=e((()=>{s(),L(),l(),jn(),Pn(),Xn(),Qn(),sr=10,cr=class extends Yn{constructor(){super(...arguments),z.add(this),this._chatCompletions=[],this.messages=[]}_addChatCompletion(e){$n(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),Nn(e)&&e.content)this._emit(`functionToolCallResult`,e.content);else if(Mn(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 p(`stream ended without producing a ChatCompletion`);return e}async finalContent(){return await this.done(),o(this,z,`m`,er).call(this)}async finalMessage(){return await this.done(),o(this,z,`m`,tr).call(this)}async finalFunctionToolCall(){return await this.done(),o(this,z,`m`,nr).call(this)}async finalFunctionToolCallResult(){return await this.done(),o(this,z,`m`,rr).call(this)}async totalUsage(){return await this.done(),o(this,z,`m`,ir).call(this)}allChatCompletions(){return[...this._chatCompletions]}_emitFinal(){let e=this._chatCompletions[this._chatCompletions.length-1];e&&this._emit(`finalChatCompletion`,e);let t=o(this,z,`m`,tr).call(this);t&&this._emit(`finalMessage`,t);let n=o(this,z,`m`,er).call(this);n&&this._emit(`finalContent`,n);let r=o(this,z,`m`,nr).call(this);r&&this._emit(`finalFunctionToolCall`,r);let i=o(this,z,`m`,rr).call(this);i!=null&&this._emit(`finalFunctionToolCallResult`,i),this._chatCompletions.some(e=>e.usage)&&this._emit(`totalUsage`,o(this,z,`m`,ir).call(this))}async _createChatCompletion(e,t,n){this._listenForAbort(n?.signal),o(this,z,`m`,ar).call(this,t);let r=await e.chat.completions.create({...t,stream:!1},{...n,signal:this.controller.signal});return this._connected(),this._addChatCompletion(wn(r,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,n,r){let i=`tool`,{tool_choice:a=`auto`,stream:s,...c}=t,l=typeof a!=`string`&&a.type===`function`&&a?.function?.name,{maxChatCompletions:u=sr,afterCompletion:d}=r||{},f=t.tools.map(e=>{if(Sn(e)){if(!e.$callback)throw new p("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}),m={};for(let e of f)e.type===`function`&&(m[e.function.name||e.function.function.name]=e.function);let h=`tools`in t?f.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);let g=async e=>{if(e.type!==`function`)return{message:void 0,functionCalled:!1};let t=e.id,{name:r,arguments:a}=e.function,s=m[r];if(!s){let e=`Invalid tool_call: ${JSON.stringify(r)}. Available options are: ${Object.keys(m).map(e=>JSON.stringify(e)).join(`, `)}. Please try again`;return{message:{role:i,tool_call_id:t,content:e},functionCalled:!1}}if(l&&l!==r){let e=`Invalid tool_call: ${JSON.stringify(r)}. ${JSON.stringify(l)} requested. Please try again`;return{message:{role:i,tool_call_id:t,content:e},functionCalled:!1}}let c;if(Zn(s)){let e;try{e=await s.parse(a)}catch(e){let n=e instanceof Error?e.message:String(e);return{message:{role:i,tool_call_id:t,content:n},functionCalled:!1}}c=await s.function(e,n)}else c=await s.function(a,n);let u=o(this,z,`m`,or).call(this,c);return{message:{role:i,tool_call_id:t,content:u},functionCalled:!0}};for(let i=0;i<u;++i){let i=await this._createChatCompletion(e,{...c,tool_choice:a,tools:h,messages:[...this.messages]},r),o=i.choices[0]?.message;if(!o)throw new p(`missing message in ChatCompletion response`);if(!o.tool_calls?.length){await d?.(i,n);return}if(l||t.parallel_tool_calls===!1)for(let e of o.tool_calls){let t=await g(e);if(t.message&&this._addMessage(t.message),l&&t.functionCalled){await d?.(i,n);return}}else{let e=await Promise.allSettled(o.tool_calls.map(g));for(let t of e)if(t.status===`rejected`)throw t.reason;for(let t of e)t.status===`fulfilled`&&t.value.message&&this._addMessage(t.value.message)}await d?.(i,n)}}},z=new WeakSet,er=function(){return o(this,z,`m`,tr).call(this).content??null},tr=function(){let e=this.messages.length;for(;e-->0;){let t=this.messages[e];if(Mn(t))return{...t,content:t.content??null,refusal:t.refusal??null}}throw new p(`stream ended without producing a ChatCompletionMessage with role=assistant`)},nr=function(){for(let e=this.messages.length-1;e>=0;e--){let t=this.messages[e];if(Mn(t)&&t?.tool_calls?.length)for(let e=t.tool_calls.length-1;e>=0;e--){let n=t.tool_calls[e];if(n?.type===`function`)return n.function}}},rr=function(){for(let e=this.messages.length-1;e>=0;e--){let t=this.messages[e];if(Nn(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}},ir=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},ar=function(e){if(e.n!=null&&e.n>1)throw new p(`ChatCompletion convenience helpers only support n=1 at this time. To use n>1, please use chat.completions.create() directly.`)},or=function(e){return typeof e==`string`?e:e===void 0?`undefined`:JSON.stringify(e)}})),ur,dr=e((()=>{lr(),Pn(),ur=class e extends cr{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,i,a)),i}_addMessage(e,t=!0){super._addMessage(e,t),Mn(e)&&e.content&&this._emit(`content`,e.content)}}}));function fr(e,t=B.ALL){if(typeof e!=`string`)throw TypeError(`expecting str, got ${typeof e}`);if(!e.trim())throw Error(`${e} is empty`);return hr(e.trim(),t)}var B,pr,mr,hr,gr,_r=e((()=>{B={STR:1,NUM:2,ARR:4,OBJ:8,NULL:16,BOOL:32,NAN:64,INFINITY:128,MINUS_INFINITY:256,INF:384,SPECIAL:496,ATOM:499,COLLECTION:12,ALL:511},pr=class extends Error{},mr=class extends Error{},hr=(e,t)=>{let n=e.length,r=0,i=e=>{throw new pr(`${e} at position ${r}`)},a=e=>{throw new mr(`${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`||B.NULL&t&&n-r<4&&`null`.startsWith(e.substring(r))?(r+=4,null):e.substring(r,r+4)===`true`||B.BOOL&t&&n-r<4&&`true`.startsWith(e.substring(r))?(r+=4,!0):e.substring(r,r+5)===`false`||B.BOOL&t&&n-r<5&&`false`.startsWith(e.substring(r))?(r+=5,!1):e.substring(r,r+8)===`Infinity`||B.INFINITY&t&&n-r<8&&`Infinity`.startsWith(e.substring(r))?(r+=8,1/0):e.substring(r,r+9)===`-Infinity`||B.MINUS_INFINITY&t&&1<n-r&&n-r<9&&`-Infinity`.startsWith(e.substring(r))?(r+=9,-1/0):e.substring(r,r+3)===`NaN`||B.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,r++;if(e.charAt(r)==`"`)try{return JSON.parse(e.substring(o,++r-Number(s)))}catch(e){a(String(e))}else if(B.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&&B.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(B.OBJ&t)return a;throw e}d(),e[r]===`,`&&r++}}catch{if(B.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(B.ARR&t)return n;i(`Expected ']' at end of array`)}return r++,n},u=()=>{if(r===0){e===`-`&&B.NUM&t&&i(`Not sure what '-' is`);try{return JSON.parse(e)}catch(n){if(B.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&&!(B.NUM&t)&&i(`Unterminated number literal`);try{return JSON.parse(e.substring(o,r))}catch{e.substring(o,r)===`-`&&B.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()},gr=e=>fr(e,B.ALL^B.NUM)})),vr=e((()=>{Pt()}));function yr(e,t){let{id:n,choices:r,created:i,model:a,system_fingerprint:o,...s}=e;return Cn({...s,id:n,choices:r.map(({message:t,finish_reason:n,index:r,logprobs:i,...a})=>{if(!n)throw new p(`missing finish_reason for choice ${r}`);let{content:o=null,function_call:s,tool_calls:l,...u}=t,d=t.role;if(!d)throw new p(`missing role for choice ${r}`);if(s){let{arguments:e,name:c}=s;if(e==null)throw new p(`missing function_call.arguments for choice ${r}`);if(!c)throw new p(`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 l?{...a,index:r,finish_reason:n,logprobs:i,message:{...u,role:d,content:o,refusal:t.refusal??null,tool_calls:l.map((t,n)=>{let{function:i,type:a,id:o,...s}=t,{arguments:l,name:u,...d}=i||{};if(a==null)throw new p(`missing choices[${r}].tool_calls[${n}].type\n${br(e)}`);if(u==null)throw new p(`missing choices[${r}].tool_calls[${n}].function.name\n${br(e)}`);if(l==null)throw new p(`missing choices[${r}].tool_calls[${n}].function.arguments\n${br(e)}`);return{...s,id:o||`call_${c()}`,type:a,function:{...d,name:u,arguments:l}}})}}:{...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 br(e){return JSON.stringify(e)}var V,xr,Sr,Cr,wr,Tr,Er,Dr,Or,kr,Ar,jr,Mr,Nr=e((()=>{s(),_r(),L(),l(),jn(),vr(),lr(),Mr=class e extends cr{constructor(e){super(),V.add(this),xr.set(this,void 0),Sr.set(this,void 0),Cr.set(this,void 0),a(this,xr,e,`f`),a(this,Sr,[],`f`)}get currentChatCompletionSnapshot(){return o(this,Cr,`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,n){super._createChatCompletion,this._listenForAbort(n?.signal),o(this,V,`m`,wr).call(this);let r=await e.chat.completions.create({...t,stream:!0},{...n,signal:this.controller.signal});this._connected();for await(let e of r)o(this,V,`m`,Er).call(this,e);if(r.controller.signal?.aborted)throw new h;return this._addChatCompletion(o(this,V,`m`,kr).call(this))}async _fromReadableStream(e,t){this._listenForAbort(t?.signal),o(this,V,`m`,wr).call(this),this._connected();let n=Mt.fromReadableStream(e,this.controller),r;for await(let e of n)r&&r!==e.id&&this._addChatCompletion(o(this,V,`m`,kr).call(this)),o(this,V,`m`,Er).call(this,e),r=e.id;if(n.controller.signal?.aborted)throw new h;return this._addChatCompletion(o(this,V,`m`,kr).call(this))}[(xr=new WeakMap,Sr=new WeakMap,Cr=new WeakMap,V=new WeakSet,wr=function(){this.ended||a(this,Cr,void 0,`f`)},Tr=function(e){let t=o(this,Sr,`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},o(this,Sr,`f`)[e.index]=t,t)},Er=function(e){if(this.ended)return;let t=o(this,V,`m`,jr).call(this,e);this._emit(`chunk`,e,t);for(let n of e.choices){let e=t.choices[n.index];n.delta.content!=null&&e.message?.role===`assistant`&&e.message?.content&&(this._emit(`content`,n.delta.content,e.message.content),this._emit(`content.delta`,{delta:n.delta.content,snapshot:e.message.content,parsed:e.message.parsed})),n.delta.refusal!=null&&e.message?.role===`assistant`&&e.message?.refusal&&this._emit(`refusal.delta`,{delta:n.delta.refusal,snapshot:e.message.refusal}),n.logprobs?.content!=null&&e.message?.role===`assistant`&&this._emit(`logprobs.content.delta`,{content:n.logprobs?.content,snapshot:e.logprobs?.content??[]}),n.logprobs?.refusal!=null&&e.message?.role===`assistant`&&this._emit(`logprobs.refusal.delta`,{refusal:n.logprobs?.refusal,snapshot:e.logprobs?.refusal??[]});let r=o(this,V,`m`,Tr).call(this,e);e.finish_reason&&(o(this,V,`m`,Or).call(this,e),r.current_tool_call_index!=null&&o(this,V,`m`,Dr).call(this,e,r.current_tool_call_index));for(let t of n.delta.tool_calls??[])r.current_tool_call_index!==t.index&&(o(this,V,`m`,Or).call(this,e),r.current_tool_call_index!=null&&o(this,V,`m`,Dr).call(this,e,r.current_tool_call_index)),r.current_tool_call_index=t.index;for(let t of n.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)}}},Dr=function(e,t){if(o(this,V,`m`,Tr).call(this,e).done_tool_calls.has(t))return;let n=e.message.tool_calls?.[t];if(!n)throw Error(`no tool call snapshot`);if(!n.type)throw Error("tool call snapshot missing `type`");if(n.type===`function`){let e=o(this,xr,`f`)?.tools?.find(e=>bn(e)&&e.function.name===n.function.name);this._emit(`tool_calls.function.arguments.done`,{name:n.function.name,index:t,arguments:n.function.arguments,parsed_arguments:Sn(e)?e.$parseRaw(n.function.arguments):e?.function.strict?JSON.parse(n.function.arguments):null})}else n.type},Or=function(e){let t=o(this,V,`m`,Tr).call(this,e);if(e.message.content&&!t.content_done){t.content_done=!0;let n=o(this,V,`m`,Ar).call(this);this._emit(`content.done`,{content:e.message.content,parsed:n?n.$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}))},kr=function(){if(this.ended)throw new p(`stream has ended, this shouldn't happen`);let e=o(this,Cr,`f`);if(!e)throw new p(`request ended without sending any chunks`);return a(this,Cr,void 0,`f`),a(this,Sr,[],`f`),yr(e,o(this,xr,`f`))},Ar=function(){let e=o(this,xr,`f`)?.response_format;return xn(e)?e:null},jr=function(e){var t,n,r,i;let s=o(this,Cr,`f`),{choices:c,...l}=e;s?Object.assign(s,l):s=a(this,Cr,{...l,choices:[]},`f`);for(let{delta:a,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:r,refusal:i,...a}=u;Object.assign(e.logprobs,a),r&&((t=e.logprobs).content??(t.content=[]),e.logprobs.content.push(...r)),i&&((n=e.logprobs).refusal??(n.refusal=[]),e.logprobs.refusal.push(...i))}if(c&&(e.finish_reason=c,o(this,xr,`f`)&&On(o(this,xr,`f`)))){if(c===`length`)throw new oe;if(c===`content_filter`)throw new se}if(Object.assign(e,d),!a)continue;let{content:f,refusal:p,function_call:m,role:h,tool_calls:g,...ee}=a;if(Object.assign(e.message,ee),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&&((r=e.message.function_call).arguments??(r.arguments=``),e.message.function_call.arguments+=m.arguments)):e.message.function_call=m),f&&(e.message.content=(e.message.content||``)+f,!e.message.refusal&&o(this,V,`m`,Ar).call(this)&&(e.message.parsed=e.message.content.trim()?gr(e.message.content):null)),g){e.message.tool_calls||(e.message.tool_calls=[]);for(let{index:t,id:n,type:r,function:a,...s}of g){let c=(i=e.message.tool_calls)[t]??(i[t]={});Object.assign(c,s),n&&(c.id=n),r&&(c.type=r),a&&(c.function??(c.function={name:a.name??``,arguments:``})),a?.name&&(c.function.name=a.name),a?.arguments&&(c.function.arguments+=a.arguments,Dn(o(this,xr,`f`),c)&&(c.function.parsed_arguments=gr(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 Mt(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}}})),Pr,Fr=e((()=>{Nr(),Pr=class e extends Mr{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,i,a)),i}}})),Ir,Lr=e((()=>{P(),yn(),A(),I(),dr(),Fr(),Nr(),jn(),Qn(),Ir=class extends N{constructor(){super(...arguments),this.messages=new vn(this._client)}create(e,t){return this._client.post(`/chat/completions`,{body:e,...t,stream:e.stream??!1,__security:{bearerAuth:!0}})}retrieve(e,t){return this._client.get(F`/chat/completions/${e}`,{...t,__security:{bearerAuth:!0}})}update(e,t,n){return this._client.post(F`/chat/completions/${e}`,{body:t,...n,__security:{bearerAuth:!0}})}list(e={},t){return this._client.getAPIList(`/chat/completions`,D,{query:e,...t,__security:{bearerAuth:!0}})}delete(e,t){return this._client.delete(F`/chat/completions/${e}`,{...t,__security:{bearerAuth:!0}})}parse(e,t){return An(e.tools),this._client.chat.completions.create(e,{...t,headers:{...t?.headers,"X-Stainless-Helper-Method":`chat.completions.parse`}})._thenUnwrap(t=>wn(t,e))}runTools(e,t){return e.stream?Pr.runTools(this._client,e,t):ur.runTools(this._client,e,t)}stream(e,t){return Mr.createChatCompletion(this._client,e,t)}},Ir.Messages=vn})),Rr,zr=e((()=>{P(),Lr(),Rr=class extends N{constructor(){super(...arguments),this.completions=new Ir(this._client)}},Rr.Completions=Ir})),Br=e((()=>{Lr(),Lr(),yn()})),Vr=e((()=>{zr(),Br()})),Hr=e((()=>{})),Ur,Wr=e((()=>{P(),A(),I(),Ur=class extends N{create(e,t){return this._client.post(`/organization/admin_api_keys`,{body:e,...t,__security:{adminAPIKeyAuth:!0}})}retrieve(e,t){return this._client.get(F`/organization/admin_api_keys/${e}`,{...t,__security:{adminAPIKeyAuth:!0}})}list(e={},t){return this._client.getAPIList(`/organization/admin_api_keys`,D,{query:e,...t,__security:{adminAPIKeyAuth:!0}})}delete(e,t){return this._client.delete(F`/organization/admin_api_keys/${e}`,{...t,__security:{adminAPIKeyAuth:!0}})}}})),Gr,Kr=e((()=>{P(),A(),Gr=class extends N{list(e={},t){return this._client.getAPIList(`/organization/audit_logs`,O,{query:e,...t,__security:{adminAPIKeyAuth:!0}})}}})),qr,Jr=e((()=>{P(),A(),I(),qr=class extends N{create(e,t){return this._client.post(`/organization/certificates`,{body:e,...t,__security:{adminAPIKeyAuth:!0}})}retrieve(e,t={},n){return this._client.get(F`/organization/certificates/${e}`,{query:t,...n,__security:{adminAPIKeyAuth:!0}})}update(e,t,n){return this._client.post(F`/organization/certificates/${e}`,{body:t,...n,__security:{adminAPIKeyAuth:!0}})}list(e={},t){return this._client.getAPIList(`/organization/certificates`,O,{query:e,...t,__security:{adminAPIKeyAuth:!0}})}delete(e,t){return this._client.delete(F`/organization/certificates/${e}`,{...t,__security:{adminAPIKeyAuth:!0}})}activate(e,t){return this._client.getAPIList(`/organization/certificates/activate`,E,{body:e,method:`post`,...t,__security:{adminAPIKeyAuth:!0}})}deactivate(e,t){return this._client.getAPIList(`/organization/certificates/deactivate`,E,{body:e,method:`post`,...t,__security:{adminAPIKeyAuth:!0}})}}})),Yr,Xr=e((()=>{P(),Yr=class extends N{retrieve(e){return this._client.get(`/organization/data_retention`,{...e,__security:{adminAPIKeyAuth:!0}})}update(e,t){return this._client.post(`/organization/data_retention`,{body:e,...t,__security:{adminAPIKeyAuth:!0}})}}})),Zr,Qr=e((()=>{P(),A(),I(),Zr=class extends N{create(e,t){return this._client.post(`/organization/invites`,{body:e,...t,__security:{adminAPIKeyAuth:!0}})}retrieve(e,t){return this._client.get(F`/organization/invites/${e}`,{...t,__security:{adminAPIKeyAuth:!0}})}list(e={},t){return this._client.getAPIList(`/organization/invites`,O,{query:e,...t,__security:{adminAPIKeyAuth:!0}})}delete(e,t){return this._client.delete(F`/organization/invites/${e}`,{...t,__security:{adminAPIKeyAuth:!0}})}}})),$r,ei=e((()=>{P(),A(),I(),$r=class extends N{create(e,t){return this._client.post(`/organization/roles`,{body:e,...t,__security:{adminAPIKeyAuth:!0}})}retrieve(e,t){return this._client.get(F`/organization/roles/${e}`,{...t,__security:{adminAPIKeyAuth:!0}})}update(e,t,n){return this._client.post(F`/organization/roles/${e}`,{body:t,...n,__security:{adminAPIKeyAuth:!0}})}list(e={},t){return this._client.getAPIList(`/organization/roles`,k,{query:e,...t,__security:{adminAPIKeyAuth:!0}})}delete(e,t){return this._client.delete(F`/organization/roles/${e}`,{...t,__security:{adminAPIKeyAuth:!0}})}}})),ti,ni=e((()=>{P(),A(),I(),ti=class extends N{create(e,t){return this._client.post(`/organization/spend_alerts`,{body:e,...t,__security:{adminAPIKeyAuth:!0}})}retrieve(e,t){return this._client.get(F`/organization/spend_alerts/${e}`,{...t,__security:{adminAPIKeyAuth:!0}})}update(e,t,n){return this._client.post(F`/organization/spend_alerts/${e}`,{body:t,...n,__security:{adminAPIKeyAuth:!0}})}list(e={},t){return this._client.getAPIList(`/organization/spend_alerts`,O,{query:e,...t,__security:{adminAPIKeyAuth:!0}})}delete(e,t){return this._client.delete(F`/organization/spend_alerts/${e}`,{...t,__security:{adminAPIKeyAuth:!0}})}}})),ri,ii=e((()=>{P(),ri=class extends N{audioSpeeches(e,t){return this._client.get(`/organization/usage/audio_speeches`,{query:e,...t,__security:{adminAPIKeyAuth:!0}})}audioTranscriptions(e,t){return this._client.get(`/organization/usage/audio_transcriptions`,{query:e,...t,__security:{adminAPIKeyAuth:!0}})}codeInterpreterSessions(e,t){return this._client.get(`/organization/usage/code_interpreter_sessions`,{query:e,...t,__security:{adminAPIKeyAuth:!0}})}completions(e,t){return this._client.get(`/organization/usage/completions`,{query:e,...t,__security:{adminAPIKeyAuth:!0}})}costs(e,t){return this._client.get(`/organization/costs`,{query:e,...t,__security:{adminAPIKeyAuth:!0}})}embeddings(e,t){return this._client.get(`/organization/usage/embeddings`,{query:e,...t,__security:{adminAPIKeyAuth:!0}})}fileSearchCalls(e,t){return this._client.get(`/organization/usage/file_search_calls`,{query:e,...t,__security:{adminAPIKeyAuth:!0}})}images(e,t){return this._client.get(`/organization/usage/images`,{query:e,...t,__security:{adminAPIKeyAuth:!0}})}moderations(e,t){return this._client.get(`/organization/usage/moderations`,{query:e,...t,__security:{adminAPIKeyAuth:!0}})}vectorStores(e,t){return this._client.get(`/organization/usage/vector_stores`,{query:e,...t,__security:{adminAPIKeyAuth:!0}})}webSearchCalls(e,t){return this._client.get(`/organization/usage/web_search_calls`,{query:e,...t,__security:{adminAPIKeyAuth:!0}})}}})),ai,oi=e((()=>{P(),A(),I(),ai=class extends N{create(e,t,n){return this._client.post(F`/organization/groups/${e}/roles`,{body:t,...n,__security:{adminAPIKeyAuth:!0}})}retrieve(e,t,n){let{group_id:r}=t;return this._client.get(F`/organization/groups/${r}/roles/${e}`,{...n,__security:{adminAPIKeyAuth:!0}})}list(e,t={},n){return this._client.getAPIList(F`/organization/groups/${e}/roles`,k,{query:t,...n,__security:{adminAPIKeyAuth:!0}})}delete(e,t,n){let{group_id:r}=t;return this._client.delete(F`/organization/groups/${r}/roles/${e}`,{...n,__security:{adminAPIKeyAuth:!0}})}}})),si,ci=e((()=>{P(),A(),I(),si=class extends N{create(e,t,n){return this._client.post(F`/organization/groups/${e}/users`,{body:t,...n,__security:{adminAPIKeyAuth:!0}})}retrieve(e,t,n){let{group_id:r}=t;return this._client.get(F`/organization/groups/${r}/users/${e}`,{...n,__security:{adminAPIKeyAuth:!0}})}list(e,t={},n){return this._client.getAPIList(F`/organization/groups/${e}/users`,k,{query:t,...n,__security:{adminAPIKeyAuth:!0}})}delete(e,t,n){let{group_id:r}=t;return this._client.delete(F`/organization/groups/${r}/users/${e}`,{...n,__security:{adminAPIKeyAuth:!0}})}}})),li,ui=e((()=>{P(),oi(),ci(),A(),I(),li=class extends N{constructor(){super(...arguments),this.users=new si(this._client),this.roles=new ai(this._client)}create(e,t){return this._client.post(`/organization/groups`,{body:e,...t,__security:{adminAPIKeyAuth:!0}})}retrieve(e,t){return this._client.get(F`/organization/groups/${e}`,{...t,__security:{adminAPIKeyAuth:!0}})}update(e,t,n){return this._client.post(F`/organization/groups/${e}`,{body:t,...n,__security:{adminAPIKeyAuth:!0}})}list(e={},t){return this._client.getAPIList(`/organization/groups`,k,{query:e,...t,__security:{adminAPIKeyAuth:!0}})}delete(e,t){return this._client.delete(F`/organization/groups/${e}`,{...t,__security:{adminAPIKeyAuth:!0}})}},li.Users=si,li.Roles=ai})),di,fi=e((()=>{P(),A(),I(),di=class extends N{retrieve(e,t,n){let{project_id:r}=t;return this._client.get(F`/organization/projects/${r}/api_keys/${e}`,{...n,__security:{adminAPIKeyAuth:!0}})}list(e,t={},n){return this._client.getAPIList(F`/organization/projects/${e}/api_keys`,O,{query:t,...n,__security:{adminAPIKeyAuth:!0}})}delete(e,t,n){let{project_id:r}=t;return this._client.delete(F`/organization/projects/${r}/api_keys/${e}`,{...n,__security:{adminAPIKeyAuth:!0}})}}})),pi,mi=e((()=>{P(),A(),I(),pi=class extends N{list(e,t={},n){return this._client.getAPIList(F`/organization/projects/${e}/certificates`,O,{query:t,...n,__security:{adminAPIKeyAuth:!0}})}activate(e,t,n){return this._client.getAPIList(F`/organization/projects/${e}/certificates/activate`,E,{body:t,method:`post`,...n,__security:{adminAPIKeyAuth:!0}})}deactivate(e,t,n){return this._client.getAPIList(F`/organization/projects/${e}/certificates/deactivate`,E,{body:t,method:`post`,...n,__security:{adminAPIKeyAuth:!0}})}}})),hi,gi=e((()=>{P(),I(),hi=class extends N{retrieve(e,t){return this._client.get(F`/organization/projects/${e}/data_retention`,{...t,__security:{adminAPIKeyAuth:!0}})}update(e,t,n){return this._client.post(F`/organization/projects/${e}/data_retention`,{body:t,...n,__security:{adminAPIKeyAuth:!0}})}}})),_i,vi=e((()=>{P(),I(),_i=class extends N{retrieve(e,t){return this._client.get(F`/organization/projects/${e}/hosted_tool_permissions`,{...t,__security:{adminAPIKeyAuth:!0}})}update(e,t,n){return this._client.post(F`/organization/projects/${e}/hosted_tool_permissions`,{body:t,...n,__security:{adminAPIKeyAuth:!0}})}}})),yi,bi=e((()=>{P(),I(),yi=class extends N{retrieve(e,t){return this._client.get(F`/organization/projects/${e}/model_permissions`,{...t,__security:{adminAPIKeyAuth:!0}})}update(e,t,n){return this._client.post(F`/organization/projects/${e}/model_permissions`,{body:t,...n,__security:{adminAPIKeyAuth:!0}})}delete(e,t){return this._client.delete(F`/organization/projects/${e}/model_permissions`,{...t,__security:{adminAPIKeyAuth:!0}})}}})),xi,Si=e((()=>{P(),A(),I(),xi=class extends N{listRateLimits(e,t={},n){return this._client.getAPIList(F`/organization/projects/${e}/rate_limits`,O,{query:t,...n,__security:{adminAPIKeyAuth:!0}})}updateRateLimit(e,t,n){let{project_id:r,...i}=t;return this._client.post(F`/organization/projects/${r}/rate_limits/${e}`,{body:i,...n,__security:{adminAPIKeyAuth:!0}})}}})),Ci,wi=e((()=>{P(),A(),I(),Ci=class extends N{create(e,t,n){return this._client.post(F`/projects/${e}/roles`,{body:t,...n,__security:{adminAPIKeyAuth:!0}})}retrieve(e,t,n){let{project_id:r}=t;return this._client.get(F`/projects/${r}/roles/${e}`,{...n,__security:{adminAPIKeyAuth:!0}})}update(e,t,n){let{project_id:r,...i}=t;return this._client.post(F`/projects/${r}/roles/${e}`,{body:i,...n,__security:{adminAPIKeyAuth:!0}})}list(e,t={},n){return this._client.getAPIList(F`/projects/${e}/roles`,k,{query:t,...n,__security:{adminAPIKeyAuth:!0}})}delete(e,t,n){let{project_id:r}=t;return this._client.delete(F`/projects/${r}/roles/${e}`,{...n,__security:{adminAPIKeyAuth:!0}})}}})),Ti,Ei=e((()=>{P(),A(),I(),Ti=class extends N{create(e,t,n){return this._client.post(F`/organization/projects/${e}/service_accounts`,{body:t,...n,__security:{adminAPIKeyAuth:!0}})}retrieve(e,t,n){let{project_id:r}=t;return this._client.get(F`/organization/projects/${r}/service_accounts/${e}`,{...n,__security:{adminAPIKeyAuth:!0}})}update(e,t,n){let{project_id:r,...i}=t;return this._client.post(F`/organization/projects/${r}/service_accounts/${e}`,{body:i,...n,__security:{adminAPIKeyAuth:!0}})}list(e,t={},n){return this._client.getAPIList(F`/organization/projects/${e}/service_accounts`,O,{query:t,...n,__security:{adminAPIKeyAuth:!0}})}delete(e,t,n){let{project_id:r}=t;return this._client.delete(F`/organization/projects/${r}/service_accounts/${e}`,{...n,__security:{adminAPIKeyAuth:!0}})}}})),Di,Oi=e((()=>{P(),A(),I(),Di=class extends N{create(e,t,n){return this._client.post(F`/organization/projects/${e}/spend_alerts`,{body:t,...n,__security:{adminAPIKeyAuth:!0}})}retrieve(e,t,n){let{project_id:r}=t;return this._client.get(F`/organization/projects/${r}/spend_alerts/${e}`,{...n,__security:{adminAPIKeyAuth:!0}})}update(e,t,n){let{project_id:r,...i}=t;return this._client.post(F`/organization/projects/${r}/spend_alerts/${e}`,{body:i,...n,__security:{adminAPIKeyAuth:!0}})}list(e,t={},n){return this._client.getAPIList(F`/organization/projects/${e}/spend_alerts`,O,{query:t,...n,__security:{adminAPIKeyAuth:!0}})}delete(e,t,n){let{project_id:r}=t;return this._client.delete(F`/organization/projects/${r}/spend_alerts/${e}`,{...n,__security:{adminAPIKeyAuth:!0}})}}})),ki,Ai=e((()=>{P(),A(),I(),ki=class extends N{create(e,t,n){let{project_id:r,...i}=t;return this._client.post(F`/projects/${r}/groups/${e}/roles`,{body:i,...n,__security:{adminAPIKeyAuth:!0}})}retrieve(e,t,n){let{project_id:r,group_id:i}=t;return this._client.get(F`/projects/${r}/groups/${i}/roles/${e}`,{...n,__security:{adminAPIKeyAuth:!0}})}list(e,t,n){let{project_id:r,...i}=t;return this._client.getAPIList(F`/projects/${r}/groups/${e}/roles`,k,{query:i,...n,__security:{adminAPIKeyAuth:!0}})}delete(e,t,n){let{project_id:r,group_id:i}=t;return this._client.delete(F`/projects/${r}/groups/${i}/roles/${e}`,{...n,__security:{adminAPIKeyAuth:!0}})}}})),ji,Mi=e((()=>{P(),Ai(),A(),I(),ji=class extends N{constructor(){super(...arguments),this.roles=new ki(this._client)}create(e,t,n){return this._client.post(F`/organization/projects/${e}/groups`,{body:t,...n,__security:{adminAPIKeyAuth:!0}})}retrieve(e,t,n){let{project_id:r,...i}=t;return this._client.get(F`/organization/projects/${r}/groups/${e}`,{query:i,...n,__security:{adminAPIKeyAuth:!0}})}list(e,t={},n){return this._client.getAPIList(F`/organization/projects/${e}/groups`,k,{query:t,...n,__security:{adminAPIKeyAuth:!0}})}delete(e,t,n){let{project_id:r}=t;return this._client.delete(F`/organization/projects/${r}/groups/${e}`,{...n,__security:{adminAPIKeyAuth:!0}})}},ji.Roles=ki})),Ni,Pi=e((()=>{P(),A(),I(),Ni=class extends N{create(e,t,n){let{project_id:r,...i}=t;return this._client.post(F`/projects/${r}/users/${e}/roles`,{body:i,...n,__security:{adminAPIKeyAuth:!0}})}retrieve(e,t,n){let{project_id:r,user_id:i}=t;return this._client.get(F`/projects/${r}/users/${i}/roles/${e}`,{...n,__security:{adminAPIKeyAuth:!0}})}list(e,t,n){let{project_id:r,...i}=t;return this._client.getAPIList(F`/projects/${r}/users/${e}/roles`,k,{query:i,...n,__security:{adminAPIKeyAuth:!0}})}delete(e,t,n){let{project_id:r,user_id:i}=t;return this._client.delete(F`/projects/${r}/users/${i}/roles/${e}`,{...n,__security:{adminAPIKeyAuth:!0}})}}})),Fi,Ii=e((()=>{P(),Pi(),A(),I(),Fi=class extends N{constructor(){super(...arguments),this.roles=new Ni(this._client)}create(e,t,n){return this._client.post(F`/organization/projects/${e}/users`,{body:t,...n,__security:{adminAPIKeyAuth:!0}})}retrieve(e,t,n){let{project_id:r}=t;return this._client.get(F`/organization/projects/${r}/users/${e}`,{...n,__security:{adminAPIKeyAuth:!0}})}update(e,t,n){let{project_id:r,...i}=t;return this._client.post(F`/organization/projects/${r}/users/${e}`,{body:i,...n,__security:{adminAPIKeyAuth:!0}})}list(e,t={},n){return this._client.getAPIList(F`/organization/projects/${e}/users`,O,{query:t,...n,__security:{adminAPIKeyAuth:!0}})}delete(e,t,n){let{project_id:r}=t;return this._client.delete(F`/organization/projects/${r}/users/${e}`,{...n,__security:{adminAPIKeyAuth:!0}})}},Fi.Roles=Ni})),H,Li=e((()=>{P(),fi(),mi(),gi(),vi(),bi(),Si(),wi(),Ei(),Oi(),Mi(),Ii(),A(),I(),H=class extends N{constructor(){super(...arguments),this.users=new Fi(this._client),this.serviceAccounts=new Ti(this._client),this.apiKeys=new di(this._client),this.rateLimits=new xi(this._client),this.modelPermissions=new yi(this._client),this.hostedToolPermissions=new _i(this._client),this.groups=new ji(this._client),this.roles=new Ci(this._client),this.dataRetention=new hi(this._client),this.spendAlerts=new Di(this._client),this.certificates=new pi(this._client)}create(e,t){return this._client.post(`/organization/projects`,{body:e,...t,__security:{adminAPIKeyAuth:!0}})}retrieve(e,t){return this._client.get(F`/organization/projects/${e}`,{...t,__security:{adminAPIKeyAuth:!0}})}update(e,t,n){return this._client.post(F`/organization/projects/${e}`,{body:t,...n,__security:{adminAPIKeyAuth:!0}})}list(e={},t){return this._client.getAPIList(`/organization/projects`,O,{query:e,...t,__security:{adminAPIKeyAuth:!0}})}archive(e,t){return this._client.post(F`/organization/projects/${e}/archive`,{...t,__security:{adminAPIKeyAuth:!0}})}},H.Users=Fi,H.ServiceAccounts=Ti,H.APIKeys=di,H.RateLimits=xi,H.ModelPermissions=yi,H.HostedToolPermissions=_i,H.Groups=ji,H.Roles=Ci,H.DataRetention=hi,H.SpendAlerts=Di,H.Certificates=pi})),Ri,zi=e((()=>{P(),A(),I(),Ri=class extends N{create(e,t,n){return this._client.post(F`/organization/users/${e}/roles`,{body:t,...n,__security:{adminAPIKeyAuth:!0}})}retrieve(e,t,n){let{user_id:r}=t;return this._client.get(F`/organization/users/${r}/roles/${e}`,{...n,__security:{adminAPIKeyAuth:!0}})}list(e,t={},n){return this._client.getAPIList(F`/organization/users/${e}/roles`,k,{query:t,...n,__security:{adminAPIKeyAuth:!0}})}delete(e,t,n){let{user_id:r}=t;return this._client.delete(F`/organization/users/${r}/roles/${e}`,{...n,__security:{adminAPIKeyAuth:!0}})}}})),Bi,Vi=e((()=>{P(),zi(),A(),I(),Bi=class extends N{constructor(){super(...arguments),this.roles=new Ri(this._client)}retrieve(e,t){return this._client.get(F`/organization/users/${e}`,{...t,__security:{adminAPIKeyAuth:!0}})}update(e,t,n){return this._client.post(F`/organization/users/${e}`,{body:t,...n,__security:{adminAPIKeyAuth:!0}})}list(e={},t){return this._client.getAPIList(`/organization/users`,O,{query:e,...t,__security:{adminAPIKeyAuth:!0}})}delete(e,t){return this._client.delete(F`/organization/users/${e}`,{...t,__security:{adminAPIKeyAuth:!0}})}},Bi.Roles=Ri})),U,Hi=e((()=>{P(),Wr(),Kr(),Jr(),Xr(),Qr(),ei(),ni(),ii(),ui(),Li(),Vi(),U=class extends N{constructor(){super(...arguments),this.auditLogs=new Gr(this._client),this.adminAPIKeys=new Ur(this._client),this.usage=new ri(this._client),this.invites=new Zr(this._client),this.users=new Bi(this._client),this.groups=new li(this._client),this.roles=new $r(this._client),this.dataRetention=new Yr(this._client),this.spendAlerts=new ti(this._client),this.certificates=new qr(this._client),this.projects=new H(this._client)}},U.AuditLogs=Gr,U.AdminAPIKeys=Ur,U.Usage=ri,U.Invites=Zr,U.Users=Bi,U.Groups=li,U.Roles=$r,U.DataRetention=Yr,U.SpendAlerts=ti,U.Certificates=qr,U.Projects=H})),Ui,Wi=e((()=>{P(),Hi(),Ui=class extends N{constructor(){super(...arguments),this.organization=new U(this._client)}},Ui.Organization=U}));function*Gi(e){if(!e)return;if(Ki 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():ve(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=ve(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 Ki,W,G=e((()=>{xe(),Ki=Symbol(`brand.privateNullableHeaders`),W=e=>{let t=new Headers,n=new Set;for(let r of e){let e=new Set;for(let[i,a]of Gi(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{[Ki]:!0,values:t,nulls:n}}})),qi,Ji=e((()=>{P(),G(),qi=class extends N{create(e,t){return this._client.post(`/audio/speech`,{body:e,...t,headers:W([{Accept:`application/octet-stream`},t?.headers]),__security:{bearerAuth:!0},__binaryResponse:!0})}}})),Yi,Xi=e((()=>{P(),M(),Yi=class extends N{create(e,t){return this._client.post(`/audio/transcriptions`,j({body:e,...t,stream:e.stream??!1,__metadata:{model:e.model},__security:{bearerAuth:!0}},this._client))}}})),Zi,Qi=e((()=>{P(),M(),Zi=class extends N{create(e,t){return this._client.post(`/audio/translations`,j({body:e,...t,__metadata:{model:e.model},__security:{bearerAuth:!0}},this._client))}}})),$i,ea=e((()=>{P(),Ji(),Xi(),Qi(),$i=class extends N{constructor(){super(...arguments),this.transcriptions=new Yi(this._client),this.translations=new Zi(this._client),this.speech=new qi(this._client)}},$i.Transcriptions=Yi,$i.Translations=Zi,$i.Speech=qi})),ta,na=e((()=>{P(),A(),I(),ta=class extends N{create(e,t){return this._client.post(`/batches`,{body:e,...t,__security:{bearerAuth:!0}})}retrieve(e,t){return this._client.get(F`/batches/${e}`,{...t,__security:{bearerAuth:!0}})}list(e={},t){return this._client.getAPIList(`/batches`,D,{query:e,...t,__security:{bearerAuth:!0}})}cancel(e,t){return this._client.post(F`/batches/${e}/cancel`,{...t,__security:{bearerAuth:!0}})}}})),ra,ia=e((()=>{P(),A(),G(),I(),ra=class extends N{create(e,t){return this._client.post(`/assistants`,{body:e,...t,headers:W([{"OpenAI-Beta":`assistants=v2`},t?.headers]),__security:{bearerAuth:!0}})}retrieve(e,t){return this._client.get(F`/assistants/${e}`,{...t,headers:W([{"OpenAI-Beta":`assistants=v2`},t?.headers]),__security:{bearerAuth:!0}})}update(e,t,n){return this._client.post(F`/assistants/${e}`,{body:t,...n,headers:W([{"OpenAI-Beta":`assistants=v2`},n?.headers]),__security:{bearerAuth:!0}})}list(e={},t){return this._client.getAPIList(`/assistants`,D,{query:e,...t,headers:W([{"OpenAI-Beta":`assistants=v2`},t?.headers]),__security:{bearerAuth:!0}})}delete(e,t){return this._client.delete(F`/assistants/${e}`,{...t,headers:W([{"OpenAI-Beta":`assistants=v2`},t?.headers]),__security:{bearerAuth:!0}})}}})),aa,oa=e((()=>{P(),G(),aa=class extends N{create(e,t){return this._client.post(`/realtime/sessions`,{body:e,...t,headers:W([{"OpenAI-Beta":`assistants=v2`},t?.headers]),__security:{bearerAuth:!0}})}}})),sa,ca=e((()=>{P(),G(),sa=class extends N{create(e,t){return this._client.post(`/realtime/transcription_sessions`,{body:e,...t,headers:W([{"OpenAI-Beta":`assistants=v2`},t?.headers]),__security:{bearerAuth:!0}})}}})),la,ua=e((()=>{P(),oa(),ca(),la=class extends N{constructor(){super(...arguments),this.sessions=new aa(this._client),this.transcriptionSessions=new sa(this._client)}},la.Sessions=aa,la.TranscriptionSessions=sa})),da,fa=e((()=>{P(),G(),I(),da=class extends N{create(e,t){return this._client.post(`/chatkit/sessions`,{body:e,...t,headers:W([{"OpenAI-Beta":`chatkit_beta=v1`},t?.headers]),__security:{bearerAuth:!0}})}cancel(e,t){return this._client.post(F`/chatkit/sessions/${e}/cancel`,{...t,headers:W([{"OpenAI-Beta":`chatkit_beta=v1`},t?.headers]),__security:{bearerAuth:!0}})}}})),pa,ma=e((()=>{P(),A(),G(),I(),pa=class extends N{retrieve(e,t){return this._client.get(F`/chatkit/threads/${e}`,{...t,headers:W([{"OpenAI-Beta":`chatkit_beta=v1`},t?.headers]),__security:{bearerAuth:!0}})}list(e={},t){return this._client.getAPIList(`/chatkit/threads`,O,{query:e,...t,headers:W([{"OpenAI-Beta":`chatkit_beta=v1`},t?.headers]),__security:{bearerAuth:!0}})}delete(e,t){return this._client.delete(F`/chatkit/threads/${e}`,{...t,headers:W([{"OpenAI-Beta":`chatkit_beta=v1`},t?.headers]),__security:{bearerAuth:!0}})}listItems(e,t={},n){return this._client.getAPIList(F`/chatkit/threads/${e}/items`,O,{query:t,...n,headers:W([{"OpenAI-Beta":`chatkit_beta=v1`},n?.headers]),__security:{bearerAuth:!0}})}}})),ha,ga=e((()=>{P(),fa(),ma(),ha=class extends N{constructor(){super(...arguments),this.sessions=new da(this._client),this.threads=new pa(this._client)}},ha.Sessions=da,ha.Threads=pa})),_a,va=e((()=>{P(),A(),G(),I(),_a=class extends N{list(e,t={},n){let{betas:r,...i}=t??{};return this._client.getAPIList(F`/responses/${e}/input_items?beta=true`,D,{query:i,...n,headers:W([{...r?.toString()==null?void 0:{"openai-beta":r?.toString()}},n?.headers]),__security:{bearerAuth:!0}})}}})),ya,ba=e((()=>{P(),G(),ya=class extends N{count(e={},t){let{betas:n,...r}=e??{};return this._client.post(`/responses/input_tokens?beta=true`,{body:r,...t,headers:W([{...n?.toString()==null?void 0:{"openai-beta":n?.toString()}},t?.headers]),__security:{bearerAuth:!0}})}}})),xa,Sa=e((()=>{P(),va(),ba(),G(),I(),xa=class extends N{constructor(){super(...arguments),this.inputItems=new _a(this._client),this.inputTokens=new ya(this._client)}create(e,t){let{betas:n,...r}=e;return this._client.post(`/responses?beta=true`,{body:r,...t,headers:W([{...n?.toString()==null?void 0:{"openai-beta":n?.toString()}},t?.headers]),stream:e.stream??!1,__security:{bearerAuth:!0}})}retrieve(e,t={},n){let{betas:r,...i}=t??{};return this._client.get(F`/responses/${e}?beta=true`,{query:i,...n,headers:W([{...r?.toString()==null?void 0:{"openai-beta":r?.toString()}},n?.headers]),stream:t?.stream??!1,__security:{bearerAuth:!0}})}delete(e,t={},n){let{betas:r}=t??{};return this._client.delete(F`/responses/${e}?beta=true`,{...n,headers:W([{Accept:`*/*`,...r?.toString()==null?void 0:{"openai-beta":r?.toString()}},n?.headers]),__security:{bearerAuth:!0}})}cancel(e,t={},n){let{betas:r}=t??{};return this._client.post(F`/responses/${e}/cancel?beta=true`,{...n,headers:W([{...r?.toString()==null?void 0:{"openai-beta":r?.toString()}},n?.headers]),__security:{bearerAuth:!0}})}compact(e,t){let{betas:n,...r}=e;return this._client.post(`/responses/compact?beta=true`,{body:r,...t,headers:W([{...n?.toString()==null?void 0:{"openai-beta":n?.toString()}},t?.headers]),__security:{bearerAuth:!0}})}},xa.InputItems=_a,xa.InputTokens=ya})),Ca,wa=e((()=>{P(),A(),G(),I(),Ca=class extends N{create(e,t,n){return this._client.post(F`/threads/${e}/messages`,{body:t,...n,headers:W([{"OpenAI-Beta":`assistants=v2`},n?.headers]),__security:{bearerAuth:!0}})}retrieve(e,t,n){let{thread_id:r}=t;return this._client.get(F`/threads/${r}/messages/${e}`,{...n,headers:W([{"OpenAI-Beta":`assistants=v2`},n?.headers]),__security:{bearerAuth:!0}})}update(e,t,n){let{thread_id:r,...i}=t;return this._client.post(F`/threads/${r}/messages/${e}`,{body:i,...n,headers:W([{"OpenAI-Beta":`assistants=v2`},n?.headers]),__security:{bearerAuth:!0}})}list(e,t={},n){return this._client.getAPIList(F`/threads/${e}/messages`,D,{query:t,...n,headers:W([{"OpenAI-Beta":`assistants=v2`},n?.headers]),__security:{bearerAuth:!0}})}delete(e,t,n){let{thread_id:r}=t;return this._client.delete(F`/threads/${r}/messages/${e}`,{...n,headers:W([{"OpenAI-Beta":`assistants=v2`},n?.headers]),__security:{bearerAuth:!0}})}}})),Ta,Ea=e((()=>{P(),A(),G(),I(),Ta=class extends N{retrieve(e,t,n){let{thread_id:r,run_id:i,...a}=t;return this._client.get(F`/threads/${r}/runs/${i}/steps/${e}`,{query:a,...n,headers:W([{"OpenAI-Beta":`assistants=v2`},n?.headers]),__security:{bearerAuth:!0}})}list(e,t,n){let{thread_id:r,...i}=t;return this._client.getAPIList(F`/threads/${r}/runs/${e}/steps`,D,{query:i,...n,headers:W([{"OpenAI-Beta":`assistants=v2`},n?.headers]),__security:{bearerAuth:!0}})}}})),Da,Oa=e((()=>{Da=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))}}})),ka,Aa=e((()=>{ka=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()||void 0}})),ja=e((()=>{xe(),Oa(),Aa(),Dt(),l(),Ce(),lt()})),K,Ma,Na,q,Pa,J,Fa,Ia,La,Ra,Y,za,Ba,Va,Ha,Ua,Wa,Ga,Ka,qa,Ja,Ya,Xa,Za,Qa=e((()=>{s(),vr(),L(),Xn(),ja(),Za=class extends Yn{constructor(){super(...arguments),K.add(this),Na.set(this,[]),q.set(this,{}),Pa.set(this,{}),J.set(this,void 0),Fa.set(this,void 0),Ia.set(this,void 0),La.set(this,void 0),Ra.set(this,void 0),Y.set(this,void 0),za.set(this,void 0),Ba.set(this,void 0),Va.set(this,void 0)}[(Na=new WeakMap,q=new WeakMap,Pa=new WeakMap,J=new WeakMap,Fa=new WeakMap,Ia=new WeakMap,La=new WeakMap,Ra=new WeakMap,Y=new WeakMap,za=new WeakMap,Ba=new WeakMap,Va=new WeakMap,K=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 Ma;return t._run(()=>t._fromReadableStream(e)),t}async _fromReadableStream(e,t){this._listenForAbort(t?.signal),this._connected();let n=Mt.fromReadableStream(e,this.controller);for await(let e of n)o(this,K,`m`,Ha).call(this,e);if(n.controller.signal?.aborted)throw new h;return this._addRun(o(this,K,`m`,Ua).call(this))}toReadableStream(){return new Mt(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}static createToolAssistantStream(e,t,n,r){let i=new Ma;return i._run(()=>i._runToolAssistantStream(e,t,n,{...r,headers:{...r?.headers,"X-Stainless-Helper-Method":`stream`}})),i}async _createToolAssistantStream(e,t,n,r){this._listenForAbort(r?.signal);let i={...n,stream:!0},a=await e.submitToolOutputs(t,i,{...r,signal:this.controller.signal});this._connected();for await(let e of a)o(this,K,`m`,Ha).call(this,e);if(a.controller.signal?.aborted)throw new h;return this._addRun(o(this,K,`m`,Ua).call(this))}static createThreadAssistantStream(e,t,n){let r=new Ma;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 Ma;return i._run(()=>i._runAssistantStream(e,t,n,{...r,headers:{...r?.headers,"X-Stainless-Helper-Method":`stream`}})),i}currentEvent(){return o(this,za,`f`)}currentRun(){return o(this,Ba,`f`)}currentMessageSnapshot(){return o(this,J,`f`)}currentRunStepSnapshot(){return o(this,Va,`f`)}async finalRunSteps(){return await this.done(),Object.values(o(this,q,`f`))}async finalMessages(){return await this.done(),Object.values(o(this,Pa,`f`))}async finalRun(){if(await this.done(),!o(this,Fa,`f`))throw Error(`Final run was not received.`);return o(this,Fa,`f`)}async _createThreadAssistantStream(e,t,n){this._listenForAbort(n?.signal);let r={...t,stream:!0},i=await e.createAndRun(r,{...n,signal:this.controller.signal});this._connected();for await(let e of i)o(this,K,`m`,Ha).call(this,e);if(i.controller.signal?.aborted)throw new h;return this._addRun(o(this,K,`m`,Ua).call(this))}async _createAssistantStream(e,t,n,r){this._listenForAbort(r?.signal);let i={...n,stream:!0},a=await e.create(t,i,{...r,signal:this.controller.signal});this._connected();for await(let e of a)o(this,K,`m`,Ha).call(this,e);if(a.controller.signal?.aborted)throw new h;return this._addRun(o(this,K,`m`,Ua).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(he(t)&&he(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(!he(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[n]=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)}},Ma=Za,Ha=function(e){if(!this.ended)switch(a(this,za,e,`f`),o(this,K,`m`,Ka).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`:o(this,K,`m`,Xa).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`:o(this,K,`m`,Ga).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`:o(this,K,`m`,Wa).call(this,e);break;case`error`:throw Error(`Encountered an error event in event processing - errors should be processed earlier`);default:}},Ua=function(){if(this.ended)throw new p(`stream has ended, this shouldn't happen`);if(!o(this,Fa,`f`))throw Error(`Final run has not been received`);return o(this,Fa,`f`)},Wa=function(e){let[t,n]=o(this,K,`m`,Ja).call(this,e,o(this,J,`f`));a(this,J,t,`f`),o(this,Pa,`f`)[t.id]=t;for(let e of n){let n=t.content[e.index];n?.type==`text`&&this._emit(`textCreated`,n.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,t),e.data.delta.content)for(let n of e.data.delta.content){if(n.type==`text`&&n.text){let e=n.text,r=t.content[n.index];if(r&&r.type==`text`)this._emit(`textDelta`,e,r.text);else throw Error(`The snapshot associated with this text delta is not text or missing`)}if(n.index!=o(this,Ia,`f`)){if(o(this,La,`f`))switch(o(this,La,`f`).type){case`text`:this._emit(`textDone`,o(this,La,`f`).text,o(this,J,`f`));break;case`image_file`:this._emit(`imageFileDone`,o(this,La,`f`).image_file,o(this,J,`f`));break}a(this,Ia,n.index,`f`)}a(this,La,t.content[n.index],`f`)}break;case`thread.message.completed`:case`thread.message.incomplete`:if(o(this,Ia,`f`)!==void 0){let t=e.data.content[o(this,Ia,`f`)];if(t)switch(t.type){case`image_file`:this._emit(`imageFileDone`,t.image_file,o(this,J,`f`));break;case`text`:this._emit(`textDone`,t.text,o(this,J,`f`));break}}o(this,J,`f`)&&this._emit(`messageDone`,e.data),a(this,J,void 0,`f`)}},Ga=function(e){let t=o(this,K,`m`,qa).call(this,e);switch(a(this,Va,t,`f`),e.event){case`thread.run.step.created`:this._emit(`runStepCreated`,e.data);break;case`thread.run.step.delta`:let n=e.data.delta;if(n.step_details&&n.step_details.type==`tool_calls`&&n.step_details.tool_calls&&t.step_details.type==`tool_calls`)for(let e of n.step_details.tool_calls)e.index==o(this,Ra,`f`)?this._emit(`toolCallDelta`,e,t.step_details.tool_calls[e.index]):(o(this,Y,`f`)&&this._emit(`toolCallDone`,o(this,Y,`f`)),a(this,Ra,e.index,`f`),a(this,Y,t.step_details.tool_calls[e.index],`f`),o(this,Y,`f`)&&this._emit(`toolCallCreated`,o(this,Y,`f`)));this._emit(`runStepDelta`,e.data.delta,t);break;case`thread.run.step.completed`:case`thread.run.step.failed`:case`thread.run.step.cancelled`:case`thread.run.step.expired`:a(this,Va,void 0,`f`),e.data.step_details.type==`tool_calls`&&o(this,Y,`f`)&&(this._emit(`toolCallDone`,o(this,Y,`f`)),a(this,Y,void 0,`f`)),this._emit(`runStepDone`,e.data,t);break;case`thread.run.step.in_progress`:break}},Ka=function(e){o(this,Na,`f`).push(e),this._emit(`event`,e)},qa=function(e){switch(e.event){case`thread.run.step.created`:return o(this,q,`f`)[e.data.id]=e.data,e.data;case`thread.run.step.delta`:let t=o(this,q,`f`)[e.data.id];if(!t)throw Error(`Received a RunStepDelta before creation of a snapshot`);let n=e.data;if(n.delta){let r=Ma.accumulateDelta(t,n.delta);o(this,q,`f`)[e.data.id]=r}return o(this,q,`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`:o(this,q,`f`)[e.data.id]=e.data;break}if(o(this,q,`f`)[e.data.id])return o(this,q,`f`)[e.data.id];throw Error(`No snapshot available`)},Ja=function(e,t){let n=[];switch(e.event){case`thread.message.created`:return[e.data,n];case`thread.message.delta`:if(!t)throw Error(`Received a delta with no existing snapshot (there should be one from message creation)`);let r=e.data;if(r.delta.content)for(let e of r.delta.content)if(e.index in t.content){let n=t.content[e.index];t.content[e.index]=o(this,K,`m`,Ya).call(this,e,n)}else t.content[e.index]=e,n.push(e);return[t,n];case`thread.message.in_progress`:case`thread.message.completed`:case`thread.message.incomplete`:if(t)return[t,n];throw Error(`Received thread message event with no existing snapshot`)}throw Error(`Tried to accumulate a non-message event`)},Ya=function(e,t){return Ma.accumulateDelta(t,e)},Xa=function(e){switch(a(this,Ba,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`:a(this,Fa,e.data,`f`),o(this,Y,`f`)&&(this._emit(`toolCallDone`,o(this,Y,`f`)),a(this,Y,void 0,`f`));break;case`thread.run.cancelling`:break}}})),$a,eo=e((()=>{P(),Ea(),A(),G(),Qa(),Ce(),I(),$a=class extends N{constructor(){super(...arguments),this.steps=new Ta(this._client)}create(e,t,n){let{include:r,...i}=t;return this._client.post(F`/threads/${e}/runs`,{query:{include:r},body:i,...n,headers:W([{"OpenAI-Beta":`assistants=v2`},n?.headers]),stream:t.stream??!1,__synthesizeEventData:!0,__security:{bearerAuth:!0}})}retrieve(e,t,n){let{thread_id:r}=t;return this._client.get(F`/threads/${r}/runs/${e}`,{...n,headers:W([{"OpenAI-Beta":`assistants=v2`},n?.headers]),__security:{bearerAuth:!0}})}update(e,t,n){let{thread_id:r,...i}=t;return this._client.post(F`/threads/${r}/runs/${e}`,{body:i,...n,headers:W([{"OpenAI-Beta":`assistants=v2`},n?.headers]),__security:{bearerAuth:!0}})}list(e,t={},n){return this._client.getAPIList(F`/threads/${e}/runs`,D,{query:t,...n,headers:W([{"OpenAI-Beta":`assistants=v2`},n?.headers]),__security:{bearerAuth:!0}})}cancel(e,t,n){let{thread_id:r}=t;return this._client.post(F`/threads/${r}/runs/${e}/cancel`,{...n,headers:W([{"OpenAI-Beta":`assistants=v2`},n?.headers]),__security:{bearerAuth:!0}})}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 Za.createAssistantStream(e,this._client.beta.threads.runs,t,n)}async poll(e,t,n){let r=W([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 Se(e);break;case`requires_action`:case`incomplete`:case`cancelled`:case`completed`:case`failed`:case`expired`:return i}}}stream(e,t,n){return Za.createAssistantStream(e,this._client.beta.threads.runs,t,n)}submitToolOutputs(e,t,n){let{thread_id:r,...i}=t;return this._client.post(F`/threads/${r}/runs/${e}/submit_tool_outputs`,{body:i,...n,headers:W([{"OpenAI-Beta":`assistants=v2`},n?.headers]),stream:t.stream??!1,__synthesizeEventData:!0,__security:{bearerAuth:!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 Za.createToolAssistantStream(e,this._client.beta.threads.runs,t,n)}},$a.Steps=Ta})),to,no=e((()=>{P(),wa(),eo(),G(),Qa(),I(),to=class extends N{constructor(){super(...arguments),this.runs=new $a(this._client),this.messages=new Ca(this._client)}create(e={},t){return this._client.post(`/threads`,{body:e,...t,headers:W([{"OpenAI-Beta":`assistants=v2`},t?.headers]),__security:{bearerAuth:!0}})}retrieve(e,t){return this._client.get(F`/threads/${e}`,{...t,headers:W([{"OpenAI-Beta":`assistants=v2`},t?.headers]),__security:{bearerAuth:!0}})}update(e,t,n){return this._client.post(F`/threads/${e}`,{body:t,...n,headers:W([{"OpenAI-Beta":`assistants=v2`},n?.headers]),__security:{bearerAuth:!0}})}delete(e,t){return this._client.delete(F`/threads/${e}`,{...t,headers:W([{"OpenAI-Beta":`assistants=v2`},t?.headers]),__security:{bearerAuth:!0}})}createAndRun(e,t){return this._client.post(`/threads/runs`,{body:e,...t,headers:W([{"OpenAI-Beta":`assistants=v2`},t?.headers]),stream:e.stream??!1,__synthesizeEventData:!0,__security:{bearerAuth:!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 Za.createThreadAssistantStream(e,this._client.beta.threads,t)}},to.Runs=$a,to.Messages=Ca})),ro,io=e((()=>{P(),ia(),ua(),ga(),Sa(),no(),ro=class extends N{constructor(){super(...arguments),this.realtime=new la(this._client),this.responses=new xa(this._client),this.chatkit=new ha(this._client),this.assistants=new ra(this._client),this.threads=new to(this._client)}},ro.Realtime=la,ro.Responses=xa,ro.ChatKit=ha,ro.Assistants=ra,ro.Threads=to})),ao,oo=e((()=>{P(),ao=class extends N{create(e,t){return this._client.post(`/completions`,{body:e,...t,stream:e.stream??!1,__security:{bearerAuth:!0}})}}})),so,co=e((()=>{P(),G(),I(),so=class extends N{retrieve(e,t,n){let{container_id:r}=t;return this._client.get(F`/containers/${r}/files/${e}/content`,{...n,headers:W([{Accept:`application/binary`},n?.headers]),__security:{bearerAuth:!0},__binaryResponse:!0})}}})),lo,uo=e((()=>{P(),co(),A(),G(),M(),I(),lo=class extends N{constructor(){super(...arguments),this.content=new so(this._client)}create(e,t,n){return this._client.post(F`/containers/${e}/files`,$t({body:t,...n,__security:{bearerAuth:!0}},this._client))}retrieve(e,t,n){let{container_id:r}=t;return this._client.get(F`/containers/${r}/files/${e}`,{...n,__security:{bearerAuth:!0}})}list(e,t={},n){return this._client.getAPIList(F`/containers/${e}/files`,D,{query:t,...n,__security:{bearerAuth:!0}})}delete(e,t,n){let{container_id:r}=t;return this._client.delete(F`/containers/${r}/files/${e}`,{...n,headers:W([{Accept:`*/*`},n?.headers]),__security:{bearerAuth:!0}})}},lo.Content=so})),fo,po=e((()=>{P(),uo(),A(),G(),I(),fo=class extends N{constructor(){super(...arguments),this.files=new lo(this._client)}create(e,t){return this._client.post(`/containers`,{body:e,...t,__security:{bearerAuth:!0}})}retrieve(e,t){return this._client.get(F`/containers/${e}`,{...t,__security:{bearerAuth:!0}})}list(e={},t){return this._client.getAPIList(`/containers`,D,{query:e,...t,__security:{bearerAuth:!0}})}delete(e,t){return this._client.delete(F`/containers/${e}`,{...t,headers:W([{Accept:`*/*`},t?.headers]),__security:{bearerAuth:!0}})}},fo.Files=lo})),mo,ho=e((()=>{P(),A(),I(),mo=class extends N{create(e,t,n){let{include:r,...i}=t;return this._client.post(F`/conversations/${e}/items`,{query:{include:r},body:i,...n,__security:{bearerAuth:!0}})}retrieve(e,t,n){let{conversation_id:r,...i}=t;return this._client.get(F`/conversations/${r}/items/${e}`,{query:i,...n,__security:{bearerAuth:!0}})}list(e,t={},n){return this._client.getAPIList(F`/conversations/${e}/items`,O,{query:t,...n,__security:{bearerAuth:!0}})}delete(e,t,n){let{conversation_id:r}=t;return this._client.delete(F`/conversations/${r}/items/${e}`,{...n,__security:{bearerAuth:!0}})}}})),go,_o=e((()=>{P(),ho(),I(),go=class extends N{constructor(){super(...arguments),this.items=new mo(this._client)}create(e={},t){return this._client.post(`/conversations`,{body:e,...t,__security:{bearerAuth:!0}})}retrieve(e,t){return this._client.get(F`/conversations/${e}`,{...t,__security:{bearerAuth:!0}})}update(e,t,n){return this._client.post(F`/conversations/${e}`,{body:t,...n,__security:{bearerAuth:!0}})}delete(e,t){return this._client.delete(F`/conversations/${e}`,{...t,__security:{bearerAuth:!0}})}},go.Items=mo})),vo,yo=e((()=>{P(),ja(),vo=class extends N{create(e,t){let n=!!e.encoding_format,r=n?e.encoding_format:`base64`;n&&T(this._client).debug(`embeddings/user defined encoding_format:`,e.encoding_format);let i=this._client.post(`/embeddings`,{body:{...e,encoding_format:r},...t,__security:{bearerAuth:!0}});return n?i:(T(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=Da(t)}),e)))}}})),bo,xo=e((()=>{P(),A(),I(),bo=class extends N{retrieve(e,t,n){let{eval_id:r,run_id:i}=t;return this._client.get(F`/evals/${r}/runs/${i}/output_items/${e}`,{...n,__security:{bearerAuth:!0}})}list(e,t,n){let{eval_id:r,...i}=t;return this._client.getAPIList(F`/evals/${r}/runs/${e}/output_items`,D,{query:i,...n,__security:{bearerAuth:!0}})}}})),So,Co=e((()=>{P(),xo(),A(),I(),So=class extends N{constructor(){super(...arguments),this.outputItems=new bo(this._client)}create(e,t,n){return this._client.post(F`/evals/${e}/runs`,{body:t,...n,__security:{bearerAuth:!0}})}retrieve(e,t,n){let{eval_id:r}=t;return this._client.get(F`/evals/${r}/runs/${e}`,{...n,__security:{bearerAuth:!0}})}list(e,t={},n){return this._client.getAPIList(F`/evals/${e}/runs`,D,{query:t,...n,__security:{bearerAuth:!0}})}delete(e,t,n){let{eval_id:r}=t;return this._client.delete(F`/evals/${r}/runs/${e}`,{...n,__security:{bearerAuth:!0}})}cancel(e,t,n){let{eval_id:r}=t;return this._client.post(F`/evals/${r}/runs/${e}`,{...n,__security:{bearerAuth:!0}})}},So.OutputItems=bo})),wo,To=e((()=>{P(),Co(),A(),I(),wo=class extends N{constructor(){super(...arguments),this.runs=new So(this._client)}create(e,t){return this._client.post(`/evals`,{body:e,...t,__security:{bearerAuth:!0}})}retrieve(e,t){return this._client.get(F`/evals/${e}`,{...t,__security:{bearerAuth:!0}})}update(e,t,n){return this._client.post(F`/evals/${e}`,{body:t,...n,__security:{bearerAuth:!0}})}list(e={},t){return this._client.getAPIList(`/evals`,D,{query:e,...t,__security:{bearerAuth:!0}})}delete(e,t){return this._client.delete(F`/evals/${e}`,{...t,__security:{bearerAuth:!0}})}},wo.Runs=So})),Eo,Do=e((()=>{P(),A(),G(),Ce(),L(),M(),I(),Eo=class extends N{create(e,t){return this._client.post(`/files`,j({body:e,...t,__security:{bearerAuth:!0}},this._client))}retrieve(e,t){return this._client.get(F`/files/${e}`,{...t,__security:{bearerAuth:!0}})}list(e={},t){return this._client.getAPIList(`/files`,D,{query:e,...t,__security:{bearerAuth:!0}})}delete(e,t){return this._client.delete(F`/files/${e}`,{...t,__security:{bearerAuth:!0}})}content(e,t){return this._client.get(F`/files/${e}/content`,{...t,headers:W([{Accept:`application/binary`},t?.headers]),__security:{bearerAuth:!0},__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 Se(t),a=await this.retrieve(e),Date.now()-i>n)throw new ee({message:`Giving up on waiting for file ${e} to finish processing after ${n} milliseconds.`});return a}}})),Oo,ko=e((()=>{P(),Oo=class extends N{}})),Ao,jo=e((()=>{P(),Ao=class extends N{run(e,t){return this._client.post(`/fine_tuning/alpha/graders/run`,{body:e,...t,__security:{bearerAuth:!0}})}validate(e,t){return this._client.post(`/fine_tuning/alpha/graders/validate`,{body:e,...t,__security:{bearerAuth:!0}})}}})),Mo,No=e((()=>{P(),jo(),Mo=class extends N{constructor(){super(...arguments),this.graders=new Ao(this._client)}},Mo.Graders=Ao})),Po,Fo=e((()=>{P(),A(),I(),Po=class extends N{create(e,t,n){return this._client.getAPIList(F`/fine_tuning/checkpoints/${e}/permissions`,E,{body:t,method:`post`,...n,__security:{adminAPIKeyAuth:!0}})}retrieve(e,t={},n){return this._client.get(F`/fine_tuning/checkpoints/${e}/permissions`,{query:t,...n,__security:{adminAPIKeyAuth:!0}})}list(e,t={},n){return this._client.getAPIList(F`/fine_tuning/checkpoints/${e}/permissions`,O,{query:t,...n,__security:{adminAPIKeyAuth:!0}})}delete(e,t,n){let{fine_tuned_model_checkpoint:r}=t;return this._client.delete(F`/fine_tuning/checkpoints/${r}/permissions/${e}`,{...n,__security:{adminAPIKeyAuth:!0}})}}})),Io,Lo=e((()=>{P(),Fo(),Io=class extends N{constructor(){super(...arguments),this.permissions=new Po(this._client)}},Io.Permissions=Po})),Ro,zo=e((()=>{P(),A(),I(),Ro=class extends N{list(e,t={},n){return this._client.getAPIList(F`/fine_tuning/jobs/${e}/checkpoints`,D,{query:t,...n,__security:{bearerAuth:!0}})}}})),Bo,Vo=e((()=>{P(),zo(),A(),I(),Bo=class extends N{constructor(){super(...arguments),this.checkpoints=new Ro(this._client)}create(e,t){return this._client.post(`/fine_tuning/jobs`,{body:e,...t,__security:{bearerAuth:!0}})}retrieve(e,t){return this._client.get(F`/fine_tuning/jobs/${e}`,{...t,__security:{bearerAuth:!0}})}list(e={},t){return this._client.getAPIList(`/fine_tuning/jobs`,D,{query:e,...t,__security:{bearerAuth:!0}})}cancel(e,t){return this._client.post(F`/fine_tuning/jobs/${e}/cancel`,{...t,__security:{bearerAuth:!0}})}listEvents(e,t={},n){return this._client.getAPIList(F`/fine_tuning/jobs/${e}/events`,D,{query:t,...n,__security:{bearerAuth:!0}})}pause(e,t){return this._client.post(F`/fine_tuning/jobs/${e}/pause`,{...t,__security:{bearerAuth:!0}})}resume(e,t){return this._client.post(F`/fine_tuning/jobs/${e}/resume`,{...t,__security:{bearerAuth:!0}})}},Bo.Checkpoints=Ro})),Ho,Uo=e((()=>{P(),ko(),No(),Lo(),Vo(),Ho=class extends N{constructor(){super(...arguments),this.methods=new Oo(this._client),this.jobs=new Bo(this._client),this.checkpoints=new Io(this._client),this.alpha=new Mo(this._client)}},Ho.Methods=Oo,Ho.Jobs=Bo,Ho.Checkpoints=Io,Ho.Alpha=Mo})),Wo,Go=e((()=>{P(),Wo=class extends N{}})),Ko,qo=e((()=>{P(),Go(),Ko=class extends N{constructor(){super(...arguments),this.graderModels=new Wo(this._client)}},Ko.GraderModels=Wo})),Jo,Yo=e((()=>{P(),M(),Jo=class extends N{createVariation(e,t){return this._client.post(`/images/variations`,j({body:e,...t,__security:{bearerAuth:!0}},this._client))}edit(e,t){return this._client.post(`/images/edits`,j({body:e,...t,stream:e.stream??!1,__security:{bearerAuth:!0}},this._client))}generate(e,t){return this._client.post(`/images/generations`,{body:e,...t,stream:e.stream??!1,__security:{bearerAuth:!0}})}}})),Xo,Zo=e((()=>{P(),A(),I(),Xo=class extends N{retrieve(e,t){return this._client.get(F`/models/${e}`,{...t,__security:{bearerAuth:!0}})}list(e){return this._client.getAPIList(`/models`,E,{...e,__security:{bearerAuth:!0}})}delete(e,t){return this._client.delete(F`/models/${e}`,{...t,__security:{bearerAuth:!0}})}}})),Qo,$o=e((()=>{P(),Qo=class extends N{create(e,t){return this._client.post(`/moderations`,{body:e,...t,__security:{bearerAuth:!0}})}}})),es,ts=e((()=>{P(),G(),I(),es=class extends N{accept(e,t,n){return this._client.post(F`/realtime/calls/${e}/accept`,{body:t,...n,headers:W([{Accept:`*/*`},n?.headers]),__security:{bearerAuth:!0}})}hangup(e,t){return this._client.post(F`/realtime/calls/${e}/hangup`,{...t,headers:W([{Accept:`*/*`},t?.headers]),__security:{bearerAuth:!0}})}refer(e,t,n){return this._client.post(F`/realtime/calls/${e}/refer`,{body:t,...n,headers:W([{Accept:`*/*`},n?.headers]),__security:{bearerAuth:!0}})}reject(e,t={},n){return this._client.post(F`/realtime/calls/${e}/reject`,{body:t,...n,headers:W([{Accept:`*/*`},n?.headers]),__security:{bearerAuth:!0}})}}})),ns,rs=e((()=>{P(),ns=class extends N{create(e,t){return this._client.post(`/realtime/client_secrets`,{body:e,...t,__security:{bearerAuth:!0}})}}})),is,as=e((()=>{P(),ts(),rs(),is=class extends N{constructor(){super(...arguments),this.clientSecrets=new ns(this._client),this.calls=new es(this._client)}},is.ClientSecrets=ns,is.Calls=es}));function os(e,t){if(!t||!ls(t)){let 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)};return ps(e,t)&&X(t),t}return ss(e,t)}function ss(e,t){let n=!e.status||e.status===`completed`,r=e.output.map(e=>{if(e.type===`function_call`)return{...e,parsed_arguments:n?fs(t,e):null};if(e.type===`message`){let r=e.content.map(e=>e.type===`output_text`?{...e,parsed:n?cs(t,e.text):null}:e);return{...e,content:r}}return e}),i=Object.assign({},e,{output:r});return ps(e,i)&&X(i),Object.defineProperty(i,"output_parsed",{enumerable:!0,get(){for(let e of i.output)if(e.type===`message`){for(let t of e.content)if(t.type===`output_text`&&t.parsed!==null)return t.parsed}return null}}),i}function cs(e,t){return e.text?.format?.type===`json_schema`?`$parseRaw`in e.text?.format?(e.text?.format).$parseRaw(t):JSON.parse(t):null}function ls(e){return!!xn(e.text?.format)}function us(e){return e?.$brand===`auto-parseable-tool`}function ds(e,t){return e.find(e=>e.type===`function`&&e.name===t)}function fs(e,t){let n=ds(e.tools??[],t.name);return{...t,...t,parsed_arguments:us(n)?n.$parseRaw(t.arguments):n?.strict?JSON.parse(t.arguments):null}}function ps(e,t){return!Object.getOwnPropertyDescriptor(e,`output_text`)||t.output_text==null}function X(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 ms=e((()=>{L(),jn()}));function hs(e,t){if(!t){if(e.type!==`response.created`)throw new p(`When snapshot hasn't been set yet, expected 'response.created' event, got ${e.type}`);return gs(e.response)}switch(e.type){case`response.output_item.added`:t.output.push(structuredClone(e.item)),e.item.type===`message`&&X(t);break;case`response.output_item.done`:Z(t,e.output_index),t.output[e.output_index]=structuredClone(e.item),e.item.type===`message`&&X(t);break;case`response.content_part.added`:{let n=Z(t,e.output_index),r=n.type,i=e.part;r===`message`&&i.type!==`reasoning_text`?(n.content.push(structuredClone(i)),i.type===`output_text`&&X(t)):r===`reasoning`&&i.type===`reasoning_text`&&(n.content||(n.content=[]),n.content.push(structuredClone(i)));break}case`response.content_part.done`:{let n=Z(t,e.output_index),r=e.part;if(n.type===`message`&&r.type!==`reasoning_text`)Q(n.content,e.content_index),n.content[e.content_index]=structuredClone(r),r.type===`output_text`&&X(t);else if(n.type===`reasoning`&&r.type===`reasoning_text`){let t=n.content;if(!t)throw new p(`missing content at index ${e.content_index}`);Q(t,e.content_index),t[e.content_index]=structuredClone(r)}break}case`response.output_text.delta`:{let n=Z(t,e.output_index);if(n.type===`message`){let r=Q(n.content,e.content_index);if(r.type!==`output_text`)throw new p(`expected content to be 'output_text', got ${r.type}`);r.text+=e.delta,t.output_text+=e.delta}break}case`response.output_text.done`:{let n=Z(t,e.output_index);if(n.type===`message`){let r=Q(n.content,e.content_index);if(r.type!==`output_text`)throw new p(`expected content to be 'output_text', got ${r.type}`);r.text=e.text,X(t)}break}case`response.output_text.annotation.added`:{let n=Z(t,e.output_index);if(n.type===`message`){let t=Q(n.content,e.content_index);if(t.type!==`output_text`)throw new p(`expected content to be 'output_text', got ${t.type}`);t.annotations[e.annotation_index]=structuredClone(e.annotation)}break}case`response.refusal.delta`:{let n=Z(t,e.output_index);if(n.type===`message`){let t=Q(n.content,e.content_index);if(t.type!==`refusal`)throw new p(`expected content to be 'refusal', got ${t.type}`);t.refusal+=e.delta}break}case`response.refusal.done`:{let n=Z(t,e.output_index);if(n.type===`message`){let t=Q(n.content,e.content_index);if(t.type!==`refusal`)throw new p(`expected content to be 'refusal', got ${t.type}`);t.refusal=e.refusal}break}case`response.function_call_arguments.delta`:{let n=Z(t,e.output_index);n.type===`function_call`&&(n.arguments+=e.delta);break}case`response.function_call_arguments.done`:{let n=Z(t,e.output_index);n.type===`function_call`&&(n.arguments=e.arguments);break}case`response.reasoning_text.delta`:{let n=Z(t,e.output_index);if(n.type===`reasoning`){if(!n.content)throw new p(`missing content at index ${e.content_index}`);let t=Q(n.content,e.content_index);if(t.type!==`reasoning_text`)throw new p(`expected content to be 'reasoning_text', got ${t.type}`);t.text+=e.delta}break}case`response.reasoning_text.done`:{let n=Z(t,e.output_index);if(n.type===`reasoning`){if(!n.content)throw new p(`missing content at index ${e.content_index}`);let t=Q(n.content,e.content_index);if(t.type!==`reasoning_text`)throw new p(`expected content to be 'reasoning_text', got ${t.type}`);t.text=e.text}break}case`response.reasoning_summary_part.added`:{let n=Z(t,e.output_index);n.type===`reasoning`&&n.summary.push(structuredClone(e.part));break}case`response.reasoning_summary_part.done`:{let n=Z(t,e.output_index);n.type===`reasoning`&&(Q(n.summary,e.summary_index),n.summary[e.summary_index]=structuredClone(e.part));break}case`response.reasoning_summary_text.delta`:{let n=Z(t,e.output_index);if(n.type===`reasoning`){let t=Q(n.summary,e.summary_index);t.text+=e.delta}break}case`response.reasoning_summary_text.done`:{let n=Z(t,e.output_index);if(n.type===`reasoning`){let t=Q(n.summary,e.summary_index);t.text=e.text}break}case`response.custom_tool_call_input.delta`:{let n=Z(t,e.output_index);n.type===`custom_tool_call`&&(n.input+=e.delta);break}case`response.custom_tool_call_input.done`:{let n=Z(t,e.output_index);n.type===`custom_tool_call`&&(n.input=e.input);break}case`response.mcp_call_arguments.delta`:{let n=Z(t,e.output_index);n.type===`mcp_call`&&(n.arguments+=e.delta);break}case`response.mcp_call_arguments.done`:{let n=Z(t,e.output_index);n.type===`mcp_call`&&(n.arguments=e.arguments);break}case`response.code_interpreter_call_code.delta`:{let n=Z(t,e.output_index);n.type===`code_interpreter_call`&&(n.code=(n.code??``)+e.delta);break}case`response.code_interpreter_call_code.done`:{let n=Z(t,e.output_index);n.type===`code_interpreter_call`&&(n.code=e.code);break}case`response.code_interpreter_call.in_progress`:{let n=Z(t,e.output_index);n.type===`code_interpreter_call`&&(n.status=`in_progress`);break}case`response.code_interpreter_call.interpreting`:{let n=Z(t,e.output_index);n.type===`code_interpreter_call`&&(n.status=`interpreting`);break}case`response.code_interpreter_call.completed`:{let n=Z(t,e.output_index);n.type===`code_interpreter_call`&&(n.status=`completed`);break}case`response.file_search_call.in_progress`:{let n=Z(t,e.output_index);n.type===`file_search_call`&&(n.status=`in_progress`);break}case`response.file_search_call.searching`:{let n=Z(t,e.output_index);n.type===`file_search_call`&&(n.status=`searching`);break}case`response.file_search_call.completed`:{let n=Z(t,e.output_index);n.type===`file_search_call`&&(n.status=`completed`);break}case`response.web_search_call.in_progress`:{let n=Z(t,e.output_index);n.type===`web_search_call`&&(n.status=`in_progress`);break}case`response.web_search_call.searching`:{let n=Z(t,e.output_index);n.type===`web_search_call`&&(n.status=`searching`);break}case`response.web_search_call.completed`:{let n=Z(t,e.output_index);n.type===`web_search_call`&&(n.status=`completed`);break}case`response.image_generation_call.in_progress`:{let n=Z(t,e.output_index);n.type===`image_generation_call`&&(n.status=`in_progress`);break}case`response.image_generation_call.generating`:{let n=Z(t,e.output_index);n.type===`image_generation_call`&&(n.status=`generating`);break}case`response.image_generation_call.completed`:{let n=Z(t,e.output_index);n.type===`image_generation_call`&&(n.status=`completed`);break}case`response.mcp_call.in_progress`:{let n=Z(t,e.output_index);n.type===`mcp_call`&&(n.status=`in_progress`);break}case`response.mcp_call.completed`:{let n=Z(t,e.output_index);n.type===`mcp_call`&&(n.status=`completed`);break}case`response.mcp_call.failed`:{let n=Z(t,e.output_index);n.type===`mcp_call`&&(n.status=`failed`);break}case`response.created`:case`response.queued`:case`response.in_progress`:case`response.completed`:case`response.failed`:case`response.incomplete`:t=gs(e.response);break;case`response.audio.delta`:case`response.audio.done`:case`response.audio.transcript.delta`:case`response.audio.transcript.done`:case`response.image_generation_call.partial_image`:case`response.mcp_list_tools.in_progress`:case`response.mcp_list_tools.completed`:case`response.mcp_list_tools.failed`:case`keepalive`:case`error`:break;default:_s(e)}return t}function gs(e){let t=structuredClone(e);return(!Object.getOwnPropertyDescriptor(t,`output_text`)||t.output_text==null)&&X(t),t}function Z(e,t){let n=e.output[t];if(!n)throw new p(`missing output at index ${t}`);return n}function Q(e,t){let n=e[t];if(!n)throw new p(`missing content at index ${t}`);return n}function _s(e){throw new p(`Unhandled response stream event: ${JSON.stringify(e)}`)}var vs=e((()=>{L(),ms()}));function ys(e,t){return os(e,t)}var bs,xs,Ss,Cs,ws,Ts,Es,Ds,Os=e((()=>{s(),L(),Xn(),vs(),ms(),Ds=class e extends Yn{constructor(e){super(),bs.add(this),xs.set(this,void 0),Ss.set(this,void 0),Cs.set(this,void 0),a(this,xs,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,n){this._listenForAbort(n?.signal),o(this,bs,`m`,ws).call(this);let r,i=null;`response_id`in t?(r=await e.responses.retrieve(t.response_id,{stream:!0},{...n,signal:this.controller.signal,stream:!0}),i=t.starting_after??null):r=await e.responses.create({...t,stream:!0},{...n,signal:this.controller.signal}),this._connected();for await(let e of r)o(this,bs,`m`,Ts).call(this,e,i);if(r.controller.signal?.aborted)throw new h;return o(this,bs,`m`,Es).call(this)}[(xs=new WeakMap,Ss=new WeakMap,Cs=new WeakMap,bs=new WeakSet,ws=function(){this.ended||a(this,Ss,void 0,`f`)},Ts=function(e,t){if(this.ended)return;let n=(e,n)=>{(t==null||n.sequence_number>t)&&this._emit(e,n)},r=hs(e,o(this,Ss,`f`));switch(a(this,Ss,r,`f`),n(`event`,e),e.type){case`response.output_text.delta`:{let t=r.output[e.output_index];if(!t)throw new p(`missing output at index ${e.output_index}`);if(t.type===`message`){let r=t.content[e.content_index];if(!r)throw new p(`missing content at index ${e.content_index}`);if(r.type!==`output_text`)throw new p(`expected content to be 'output_text', got ${r.type}`);n(`response.output_text.delta`,{...e,snapshot:r.text})}break}case`response.function_call_arguments.delta`:{let t=r.output[e.output_index];if(!t)throw new p(`missing output at index ${e.output_index}`);t.type===`function_call`&&n(`response.function_call_arguments.delta`,{...e,snapshot:t.arguments});break}default:n(e.type,e);break}},Es=function(){if(this.ended)throw new p(`stream has ended, this shouldn't happen`);let e=o(this,Ss,`f`);if(!e)throw new p(`request ended without sending any events`);a(this,Ss,void 0,`f`);let t=ys(e,o(this,xs,`f`));return a(this,Cs,t,`f`),t},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=o(this,Cs,`f`);if(!e)throw new p(`stream ended without producing a ChatCompletion`);return e}}})),ks,As=e((()=>{P(),A(),I(),ks=class extends N{list(e,t={},n){return this._client.getAPIList(F`/responses/${e}/input_items`,D,{query:t,...n,__security:{bearerAuth:!0}})}}})),js,Ms=e((()=>{P(),js=class extends N{count(e={},t){return this._client.post(`/responses/input_tokens`,{body:e,...t,__security:{bearerAuth:!0}})}}})),Ns,Ps=e((()=>{ms(),Os(),P(),As(),Ms(),G(),I(),Ns=class extends N{constructor(){super(...arguments),this.inputItems=new ks(this._client),this.inputTokens=new js(this._client)}create(e,t){return this._client.post(`/responses`,{body:e,...t,stream:e.stream??!1,__security:{bearerAuth:!0}})._thenUnwrap(e=>(`object`in e&&e.object===`response`&&X(e),e))}retrieve(e,t={},n){return this._client.get(F`/responses/${e}`,{query:t,...n,stream:t?.stream??!1,__security:{bearerAuth:!0}})._thenUnwrap(e=>(`object`in e&&e.object===`response`&&X(e),e))}delete(e,t){return this._client.delete(F`/responses/${e}`,{...t,headers:W([{Accept:`*/*`},t?.headers]),__security:{bearerAuth:!0}})}parse(e,t){return this._client.responses.create(e,t)._thenUnwrap(t=>ss(t,e))}stream(e,t){return Ds.createResponse(this._client,e,t)}cancel(e,t){return this._client.post(F`/responses/${e}/cancel`,{...t,__security:{bearerAuth:!0}})}compact(e,t){return this._client.post(`/responses/compact`,{body:e,...t,__security:{bearerAuth:!0}})}},Ns.InputItems=ks,Ns.InputTokens=js})),Fs,Is=e((()=>{P(),G(),I(),Fs=class extends N{retrieve(e,t){return this._client.get(F`/skills/${e}/content`,{...t,headers:W([{Accept:`application/binary`},t?.headers]),__security:{bearerAuth:!0},__binaryResponse:!0})}}})),Ls,Rs=e((()=>{P(),G(),I(),Ls=class extends N{retrieve(e,t,n){let{skill_id:r}=t;return this._client.get(F`/skills/${r}/versions/${e}/content`,{...n,headers:W([{Accept:`application/binary`},n?.headers]),__security:{bearerAuth:!0},__binaryResponse:!0})}}})),zs,Bs=e((()=>{P(),Rs(),A(),M(),I(),zs=class extends N{constructor(){super(...arguments),this.content=new Ls(this._client)}create(e,t={},n){return this._client.post(F`/skills/${e}/versions`,$t({body:t,...n,__security:{bearerAuth:!0}},this._client))}retrieve(e,t,n){let{skill_id:r}=t;return this._client.get(F`/skills/${r}/versions/${e}`,{...n,__security:{bearerAuth:!0}})}list(e,t={},n){return this._client.getAPIList(F`/skills/${e}/versions`,D,{query:t,...n,__security:{bearerAuth:!0}})}delete(e,t,n){let{skill_id:r}=t;return this._client.delete(F`/skills/${r}/versions/${e}`,{...n,__security:{bearerAuth:!0}})}},zs.Content=Ls})),Vs,Hs=e((()=>{P(),Is(),Bs(),A(),M(),I(),Vs=class extends N{constructor(){super(...arguments),this.content=new Fs(this._client),this.versions=new zs(this._client)}create(e={},t){return this._client.post(`/skills`,$t({body:e,...t,__security:{bearerAuth:!0}},this._client))}retrieve(e,t){return this._client.get(F`/skills/${e}`,{...t,__security:{bearerAuth:!0}})}update(e,t,n){return this._client.post(F`/skills/${e}`,{body:t,...n,__security:{bearerAuth:!0}})}list(e={},t){return this._client.getAPIList(`/skills`,D,{query:e,...t,__security:{bearerAuth:!0}})}delete(e,t){return this._client.delete(F`/skills/${e}`,{...t,__security:{bearerAuth:!0}})}},Vs.Content=Fs,Vs.Versions=zs})),Us,Ws=e((()=>{P(),M(),I(),Us=class extends N{create(e,t,n){return this._client.post(F`/uploads/${e}/parts`,j({body:t,...n,__security:{bearerAuth:!0}},this._client))}}})),Gs,Ks=e((()=>{P(),Ws(),I(),Gs=class extends N{constructor(){super(...arguments),this.parts=new Us(this._client)}create(e,t){return this._client.post(`/uploads`,{body:e,...t,__security:{bearerAuth:!0}})}cancel(e,t){return this._client.post(F`/uploads/${e}/cancel`,{...t,__security:{bearerAuth:!0}})}complete(e,t,n){return this._client.post(F`/uploads/${e}/complete`,{body:t,...n,__security:{bearerAuth:!0}})}},Gs.Parts=Us})),qs,Js=e((()=>{qs=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}})),Ys,Xs=e((()=>{P(),A(),G(),Ce(),Js(),I(),Ys=class extends N{create(e,t,n){return this._client.post(F`/vector_stores/${e}/file_batches`,{body:t,...n,headers:W([{"OpenAI-Beta":`assistants=v2`},n?.headers]),__security:{bearerAuth:!0}})}retrieve(e,t,n){let{vector_store_id:r}=t;return this._client.get(F`/vector_stores/${r}/file_batches/${e}`,{...n,headers:W([{"OpenAI-Beta":`assistants=v2`},n?.headers]),__security:{bearerAuth:!0}})}cancel(e,t,n){let{vector_store_id:r}=t;return this._client.post(F`/vector_stores/${r}/file_batches/${e}/cancel`,{...n,headers:W([{"OpenAI-Beta":`assistants=v2`},n?.headers]),__security:{bearerAuth:!0}})}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(F`/vector_stores/${r}/file_batches/${e}/files`,D,{query:i,...n,headers:W([{"OpenAI-Beta":`assistants=v2`},n?.headers]),__security:{bearerAuth:!0}})}async poll(e,t,n){let r=W([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 Se(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 qs(Array(a).fill(s).map(l)),await this.createAndPoll(e,{file_ids:c})}}})),Zs,Qs=e((()=>{P(),A(),G(),ja(),I(),Zs=class extends N{create(e,t,n){return this._client.post(F`/vector_stores/${e}/files`,{body:t,...n,headers:W([{"OpenAI-Beta":`assistants=v2`},n?.headers]),__security:{bearerAuth:!0}})}retrieve(e,t,n){let{vector_store_id:r}=t;return this._client.get(F`/vector_stores/${r}/files/${e}`,{...n,headers:W([{"OpenAI-Beta":`assistants=v2`},n?.headers]),__security:{bearerAuth:!0}})}update(e,t,n){let{vector_store_id:r,...i}=t;return this._client.post(F`/vector_stores/${r}/files/${e}`,{body:i,...n,headers:W([{"OpenAI-Beta":`assistants=v2`},n?.headers]),__security:{bearerAuth:!0}})}list(e,t={},n){return this._client.getAPIList(F`/vector_stores/${e}/files`,D,{query:t,...n,headers:W([{"OpenAI-Beta":`assistants=v2`},n?.headers]),__security:{bearerAuth:!0}})}delete(e,t,n){let{vector_store_id:r}=t;return this._client.delete(F`/vector_stores/${r}/files/${e}`,{...n,headers:W([{"OpenAI-Beta":`assistants=v2`},n?.headers]),__security:{bearerAuth:!0}})}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=W([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 Se(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(F`/vector_stores/${r}/files/${e}/content`,E,{...n,headers:W([{"OpenAI-Beta":`assistants=v2`},n?.headers]),__security:{bearerAuth:!0}})}}})),$s,ec=e((()=>{P(),Xs(),Qs(),A(),G(),I(),$s=class extends N{constructor(){super(...arguments),this.files=new Zs(this._client),this.fileBatches=new Ys(this._client)}create(e,t){return this._client.post(`/vector_stores`,{body:e,...t,headers:W([{"OpenAI-Beta":`assistants=v2`},t?.headers]),__security:{bearerAuth:!0}})}retrieve(e,t){return this._client.get(F`/vector_stores/${e}`,{...t,headers:W([{"OpenAI-Beta":`assistants=v2`},t?.headers]),__security:{bearerAuth:!0}})}update(e,t,n){return this._client.post(F`/vector_stores/${e}`,{body:t,...n,headers:W([{"OpenAI-Beta":`assistants=v2`},n?.headers]),__security:{bearerAuth:!0}})}list(e={},t){return this._client.getAPIList(`/vector_stores`,D,{query:e,...t,headers:W([{"OpenAI-Beta":`assistants=v2`},t?.headers]),__security:{bearerAuth:!0}})}delete(e,t){return this._client.delete(F`/vector_stores/${e}`,{...t,headers:W([{"OpenAI-Beta":`assistants=v2`},t?.headers]),__security:{bearerAuth:!0}})}search(e,t,n){return this._client.getAPIList(F`/vector_stores/${e}/search`,E,{body:t,method:`post`,...n,headers:W([{"OpenAI-Beta":`assistants=v2`},n?.headers]),__security:{bearerAuth:!0}})}},$s.Files=Zs,$s.FileBatches=Ys})),tc,nc=e((()=>{P(),A(),G(),M(),I(),tc=class extends N{create(e,t){return this._client.post(`/videos`,j({body:e,...t,__security:{bearerAuth:!0}},this._client))}retrieve(e,t){return this._client.get(F`/videos/${e}`,{...t,__security:{bearerAuth:!0}})}list(e={},t){return this._client.getAPIList(`/videos`,O,{query:e,...t,__security:{bearerAuth:!0}})}delete(e,t){return this._client.delete(F`/videos/${e}`,{...t,__security:{bearerAuth:!0}})}createCharacter(e,t){return this._client.post(`/videos/characters`,j({body:e,...t,__security:{bearerAuth:!0}},this._client))}downloadContent(e,t={},n){return this._client.get(F`/videos/${e}/content`,{query:t,...n,headers:W([{Accept:`application/binary`},n?.headers]),__security:{bearerAuth:!0},__binaryResponse:!0})}edit(e,t){return this._client.post(`/videos/edits`,j({body:e,...t,__security:{bearerAuth:!0}},this._client))}extend(e,t){return this._client.post(`/videos/extensions`,j({body:e,...t,__security:{bearerAuth:!0}},this._client))}getCharacter(e,t){return this._client.get(F`/videos/characters/${e}`,{...t,__security:{bearerAuth:!0}})}remix(e,t,n){return this._client.post(F`/videos/${e}/remix`,$t({body:t,...n,__security:{bearerAuth:!0}},this._client))}}})),rc,ic,ac,oc,sc=e((()=>{s(),L(),P(),G(),oc=class extends N{constructor(){super(...arguments),rc.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,n=this._client.webhookSecret,r=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");o(this,rc,`m`,ic).call(this,n);let i=W([t]).values,a=o(this,rc,`m`,ac).call(this,i,`webhook-signature`),s=o(this,rc,`m`,ac).call(this,i,`webhook-timestamp`),c=o(this,rc,`m`,ac).call(this,i,`webhook-id`),l=parseInt(s,10);if(isNaN(l))throw new ce(`Invalid webhook timestamp format`);let u=Math.floor(Date.now()/1e3);if(u-l>r)throw new ce(`Webhook timestamp is too old`);if(l>u+r)throw new ce(`Webhook timestamp is too new`);let d=a.split(` `).map(e=>e.startsWith(`v1,`)?e.substring(3):e),f=n.startsWith(`whsec_`)?Buffer.from(n.replace(`whsec_`,``),`base64`):Buffer.from(n,`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 ce(`The given webhook signature does not match the expected signature`)}},rc=new WeakSet,ic=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`)},ac=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}})),cc=e((()=>{sc()})),lc=e((()=>{cc()})),uc=e((()=>{Vr(),Hr(),Wi(),ea(),na(),io(),oo(),po(),_o(),yo(),To(),Do(),Uo(),qo(),Yo(),Zo(),$o(),as(),Ps(),Hs(),Ks(),ec(),nc(),lc()}));function dc(e){let t=hc.get(e);if(!t)throw Error(`Invalid provider. Providers must be created with createProvider().`);return t.configure()}var fc,pc,mc,hc,gc=e((()=>{fc=Symbol.for(`openai.node.providerDefinitions.v1`),pc=globalThis,mc=pc[fc],hc=mc??new WeakMap,mc||Object.defineProperty(pc,fc,{value:hc})}));function _c(e){if(vc(e))return`Connection error. This may be caused by passing an undici dispatcher, such as ProxyAgent, that is incompatible with the fetch implementation. If you are using undici's ProxyAgent, pass the fetch implementation from the same undici package: import { fetch, ProxyAgent } from 'undici'; new OpenAI({ fetch, fetchOptions: { dispatcher: new ProxyAgent(...) } });`}function vc(e){let t=e;for(let e=0;e<8&&t&&typeof t==`object`;e++){let e=t;if(e.code===`UND_ERR_INVALID_ARG`&&typeof e.message==`string`&&e.message.includes(`invalid onRequestStart method`))return!0;t=e.cause}return!1}var yc,bc,xc,Sc,Cc,$,wc=e((()=>{s(),l(),xe(),Ce(),f(),Pe(),Be(),He(),lt(),Te(),de(),A(),qt(),mn(),uc(),Bt(),na(),oo(),yo(),Do(),Yo(),Zo(),$o(),nc(),Wi(),ea(),io(),zr(),po(),_o(),To(),Uo(),qo(),as(),Ps(),Hs(),Ks(),ec(),sc(),G(),gc(),Aa(),Dt(),Cc=`workload-identity-auth`,$=class{constructor(e={}){yc.add(this),xc.set(this,void 0),this.completions=new ao(this),this.chat=new Rr(this),this.embeddings=new vo(this),this.files=new Eo(this),this.images=new Jo(this),this.audio=new $i(this),this.moderations=new Qo(this),this.models=new Xo(this),this.fineTuning=new Ho(this),this.graders=new Ko(this),this.vectorStores=new $s(this),this.webhooks=new oc(this),this.beta=new ro(this),this.batches=new ta(this),this.uploads=new Gs(this),this.admin=new Ui(this),this.responses=new Ns(this),this.realtime=new is(this),this.conversations=new go(this),this.evals=new wo(this),this.containers=new fo(this),this.skills=new Vs(this),this.videos=new tc(this);let t=e.provider;if(t){let t=[`apiKey`,`adminAPIKey`,`workloadIdentity`,`baseURL`].filter(t=>e[t]!=null);if(t.length)throw new p(`The \`provider\` option cannot be used with ${t.map(e=>`\`${e}\``).join(`, `)}. Configure authentication and the base URL through the provider instead.`)}let{baseURL:n=t?null:ka(`OPENAI_BASE_URL`),apiKey:r=t?null:ka(`OPENAI_API_KEY`)??null,adminAPIKey:i=t?null:ka(`OPENAI_ADMIN_KEY`)??null,organization:o=t?null:ka(`OPENAI_ORG_ID`)??null,project:s=t?null:ka(`OPENAI_PROJECT_ID`)??null,webhookSecret:c=ka(`OPENAI_WEBHOOK_SECRET`)??null,workloadIdentity:l,...u}=e,d=t?dc(t):void 0,f={apiKey:r,adminAPIKey:i,organization:o,project:s,webhookSecret:c,workloadIdentity:l,provider:t,...u,baseURL:d?.baseURL??(n||`https://api.openai.com/v1`)};if(r&&l)throw new p("The `apiKey` and `workloadIdentity` options are mutually exclusive");if(!d&&!r&&!i&&!l)throw new p("Missing credentials. Please pass an `apiKey`, `workloadIdentity`, `adminAPIKey`, or set the `OPENAI_API_KEY` or `OPENAI_ADMIN_KEY` environment variable.");if(!f.dangerouslyAllowBrowser&&Oe())throw new p(`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=f.baseURL,this.timeout=f.timeout??bc.DEFAULT_TIMEOUT,this.logger=f.logger??console;let m=`warn`;this.logLevel=m,this.logLevel=Ct(f.logLevel,`ClientOptions.logLevel`,this)??Ct(ka(`OPENAI_LOG`),`process.env['OPENAI_LOG']`,this)??m,this.fetchOptions=f.fetchOptions,this.maxRetries=f.maxRetries??2,this.fetch=f.fetch??Fe(),a(this,xc,Ve,`f`);let h=t?void 0:ka(`OPENAI_CUSTOM_HEADERS`);if(h){let e={};for(let t of h.split(`
17
+ `)){let n=t.indexOf(`:`);n>=0&&(e[t.substring(0,n).trim()]=t.substring(n+1).trim())}f.defaultHeaders=W([e,f.defaultHeaders])}this._options=f,this._provider=d,l&&(this._workloadIdentityAuth=new Kt(l,this.fetch)),this.apiKey=typeof r==`string`?r:null,this.adminAPIKey=i,this.organization=o,this.project=s,this.webhookSecret=c}withOptions(e){let t=this._options.provider,n=e.provider??t,r={...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._options.apiKey,adminAPIKey:this.adminAPIKey,workloadIdentity:this._options.workloadIdentity,organization:this.organization,project:this.project,webhookSecret:this.webhookSecret};return n&&(delete r.apiKey,delete r.adminAPIKey,delete r.workloadIdentity,delete r.baseURL,n!==t&&(delete r.organization,delete r.project,delete r.defaultHeaders)),new this.constructor({...r,...e,provider:n})}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:e,nulls:t},n={bearerAuth:!0,adminAPIKeyAuth:!0}){if(!(e.get(`authorization`)||e.get(`api-key`))&&!(t.has(`authorization`)||t.has(`api-key`))&&!(this._workloadIdentityAuth&&n.bearerAuth))throw Error(`Could not resolve authentication method. Expected either apiKey or adminAPIKey to be set. Or for one of the "Authorization" or "api-key" headers to be explicitly omitted`)}async authHeaders(e,t={bearerAuth:!0,adminAPIKeyAuth:!0}){return W([t.bearerAuth?await this.bearerAuth(e):null,t.adminAPIKeyAuth?await this.adminAPIKeyAuth(e):null])}async bearerAuth(e){if(this._workloadIdentityAuth)return W([{Authorization:`Bearer ${await this._workloadIdentityAuth.getToken()}`}]);if(this.apiKey!=null)return W([{Authorization:`Bearer ${this.apiKey}`}])}async adminAPIKeyAuth(e){if(this.adminAPIKey!=null)return W([{Authorization:`Bearer ${this.adminAPIKey}`}])}stringifyQuery(e){return ct(e)}getUserAgent(){return`${this.constructor.name}/JS ${we}`}defaultIdempotencyKey(){return`stainless-node-retry-${c()}`}makeStatusError(e,t,n,r){return m.generate(e,t,n,r)}async _callApiKey(){if(this._provider)return!1;let e=this._options.apiKey;if(typeof e!=`function`)return!1;let t;try{t=await e()}catch(e){throw e instanceof p?e:new p(`Failed to get token from 'apiKey' function: ${e.message}`,{cause:e})}if(typeof t!=`string`||!t)throw new p(`Expected 'apiKey' function argument to return a string but it returned ${t}`);return this.apiKey=t,!0}buildURL(e,t,n){let r=!o(this,yc,`m`,Sc).call(this)&&n||this.baseURL,i=_e(e)?new URL(e):new URL(r+(r.endsWith(`/`)&&e.startsWith(`/`)?e.slice(1):e)),a=this.defaultQuery(),s=Object.fromEntries(i.searchParams);return(!pe(a)||!pe(s))&&(t={...s,...a,...t}),typeof t==`object`&&t&&!Array.isArray(t)&&(i.search=this.stringifyQuery(t)),i.toString()}async prepareOptions(e){this._provider||(e.__security??{bearerAuth:!0}).bearerAuth&&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 zt(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:o,timeout:s}=await this.buildRequest(r,{retryCount:i-t});await this.prepareRequest(a,{url:o,options:r}),await this._provider?.prepareRequest?.(a,{url:o,options:r});let c=`log_`+(Math.random()*(1<<24)|0).toString(16).padStart(6,`0`),l=n===void 0?``:`, retryOf: ${n}`,f=Date.now();if(T(this).debug(`[${c}] sending request`,Et({retryOfRequestLogID:n,method:r.method,url:o,options:r,headers:a.headers})),r.signal?.aborted)throw new h;let p=r.__security??{bearerAuth:!0},m=new AbortController,_=await this.fetchWithAuth(o,a,s,m,p).catch(d),v=Date.now();if(_ instanceof globalThis.Error){let e=`retrying, ${t} attempts remaining`;if(r.signal?.aborted)throw new h;let i=u(_)||/timed? ?out/i.test(String(_)+(`cause`in _?String(_.cause):``));if(t)return T(this).info(`[${c}] connection ${i?`timed out`:`failed`} - ${e}`),T(this).debug(`[${c}] connection ${i?`timed out`:`failed`} (${e})`,Et({retryOfRequestLogID:n,url:o,durationMs:v-f,message:_.message})),this.retryRequest(r,t,n??c);throw T(this).info(`[${c}] connection ${i?`timed out`:`failed`} - error; no more retries left`),T(this).debug(`[${c}] connection ${i?`timed out`:`failed`} (error; no more retries left)`,Et({retryOfRequestLogID:n,url:o,durationMs:v-f,message:_.message})),_ instanceof le||_ instanceof ue?_:i?new ee:new g({message:_c(_),cause:_})}let y=`[${c}${l}${[..._.headers.entries()].filter(([e])=>e===`x-request-id`).map(([e,t])=>`, `+e+`: `+JSON.stringify(t)).join(``)}] ${a.method} ${o} ${_.ok?`succeeded`:`failed`} with status ${_.status} in ${v-f}ms`;if(!_.ok){if(_.status===401&&this._workloadIdentityAuth&&p.bearerAuth&&!r.__metadata?.hasStreamingBody&&!r.__metadata?.workloadIdentityTokenRefreshed)return await ze(_.body),this._workloadIdentityAuth.invalidateToken(),this.makeRequest({...r,__metadata:{...r.__metadata,workloadIdentityTokenRefreshed:!0}},t,n??c);let e=await this.shouldRetry(_);if(t&&e){let e=`retrying, ${t} attempts remaining`;return await ze(_.body),T(this).info(`${y} - ${e}`),T(this).debug(`[${c}] response error (${e})`,Et({retryOfRequestLogID:n,url:_.url,status:_.status,headers:_.headers,durationMs:v-f})),this.retryRequest(r,t,n??c,_.headers)}let i=e?`error; no more retries left`:`error; not retryable`;T(this).info(`${y} - ${i}`);let a=await _.text().catch(e=>d(e).message),o=be(a),s=o?void 0:a;throw T(this).debug(`[${c}] response error (${i})`,Et({retryOfRequestLogID:n,url:_.url,status:_.status,headers:_.headers,message:s,durationMs:Date.now()-f})),this.makeStatusError(_.status,o,s,_.headers)}return T(this).info(y),T(this).debug(`[${c}] response start`,Et({retryOfRequestLogID:n,url:_.url,status:_.status,headers:_.headers,durationMs:v-f})),{response:_,options:r,controller:m,requestLogID:c,retryOfRequestLogID:n,startTime:f}}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 Ut(this,n,e)}async fetchWithAuth(e,t,n,r,i={bearerAuth:!0,adminAPIKeyAuth:!0}){if(this._workloadIdentityAuth&&i.bearerAuth){let e=t.headers,n=e.get(`Authorization`);if(!n||n===`Bearer ${Cc}`){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 Se(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&&ye(`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=W([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))}:{},...Ne(),"OpenAI-Organization":this.organization,"OpenAI-Project":this.project},this._provider?void 0:await this.authHeaders(e,e.__security??{bearerAuth:!0}),this._options.defaultHeaders,n,e.headers]);return this._provider||this.validateHeaders(a,e.__security??{bearerAuth:!0}),a.values}_makeAbort(e){return()=>e.abort()}buildBody({options:e}){let{body:t,headers:n}=e;if(!t)return t===void 0&&`body`in e?{...o(this,xc,`f`).call(this,{body:t,headers:W([n])}),isStreamingBody:!1}:{bodyHeaders:void 0,body:void 0,isStreamingBody:!1};let r=W([n]),i=globalThis.ReadableStream!==void 0&&t instanceof globalThis.ReadableStream,a=!i&&(typeof t==`string`||t instanceof ArrayBuffer||ArrayBuffer.isView(t)||globalThis.Blob!==void 0&&t instanceof globalThis.Blob||t instanceof URLSearchParams||t instanceof FormData);return ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof DataView||typeof t==`string`&&r.values.has(`content-type`)||globalThis.Blob&&t instanceof globalThis.Blob||t instanceof FormData||t instanceof URLSearchParams||i?{bodyHeaders:void 0,body:t,isStreamingBody:!a}:typeof t==`object`&&(Symbol.asyncIterator in t||Symbol.iterator in t&&`next`in t&&typeof t.next==`function`)?{bodyHeaders:void 0,body:Le(t),isStreamingBody:!0}:typeof t==`object`&&r.values.get(`content-type`)===`application/x-www-form-urlencoded`?{bodyHeaders:{"content-type":`application/x-www-form-urlencoded`},body:this.stringifyQuery(t),isStreamingBody:!1}:{...o(this,xc,`f`).call(this,{body:t,headers:r}),isStreamingBody:!1}}},bc=$,xc=new WeakMap,yc=new WeakSet,Sc=function(){return this._provider!==void 0||this.baseURL!==`https://api.openai.com/v1`},$.OpenAI=bc,$.DEFAULT_TIMEOUT=6e5,$.OpenAIError=p,$.APIError=m,$.APIConnectionError=g,$.APIConnectionTimeoutError=ee,$.APIUserAbortError=h,$.NotFoundError=te,$.ConflictError=ne,$.RateLimitError=ie,$.BadRequestError=_,$.AuthenticationError=v,$.InternalServerError=ae,$.PermissionDeniedError=y,$.UnprocessableEntityError=re,$.InvalidWebhookSignatureError=ce,$.toFile=sn,$.Completions=ao,$.Chat=Rr,$.Embeddings=vo,$.Files=Eo,$.Images=Jo,$.Audio=$i,$.Moderations=Qo,$.Models=Xo,$.FineTuning=Ho,$.Graders=Ko,$.VectorStores=$s,$.Webhooks=oc,$.Beta=ro,$.Batches=ta,$.Uploads=Gs,$.Admin=Ui,$.Responses=Ns,$.Realtime=is,$.Conversations=go,$.Evals=wo,$.Containers=fo,$.Skills=Vs,$.Videos=tc})),Tc=e((()=>{L(),ja(),wc()})),Ec=e((()=>{L(),wc(),ja(),ms(),uc()})),Dc=e((()=>{wc(),mn(),Bt(),A(),de(),Tc(),Ec()}));function Oc(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 kc(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 Ac,jc=e((()=>{Ac={providerId:`openai`,parseHeaders(e){let t=[],n=kc(e.get(`x-ratelimit-remaining-requests`),e.get(`x-ratelimit-limit-requests`));n!==null&&t.push({kind:`requests`,label:`RPM`,utilization:n,resetsAt:Oc(e.get(`x-ratelimit-reset-requests`))||void 0});let r=kc(e.get(`x-ratelimit-remaining-tokens`),e.get(`x-ratelimit-limit-tokens`));return r!==null&&t.push({kind:`tokens`,label:`TPM`,utilization:r,resetsAt:Oc(e.get(`x-ratelimit-reset-tokens`))||void 0}),t}}}));function Mc(e){return async(...t)=>{let n=await e(...t);try{r(`openai`,Ac.parseHeaders(n.headers))}catch{}return n}}function Nc(e){if(Fc)return Fc;let n=process.env.OPENAI_API_KEY||``,r=process.env.OPENAI_BASE_URL,i=Mc(e?.fetchOverride??globalThis.fetch),a=new $({apiKey:n,...r&&{baseURL:r},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:t({forAnthropicAPI:!1}),fetch:i});return e?.fetchOverride||(Fc=a),a}function Pc(){Fc=null}var Fc,Ic=e((()=>{Dc(),jc(),i(),n(),Fc=null}));export{$ as a,Dc as i,Nc as n,wc as o,Ic as r,Pc as t};
@@ -0,0 +1 @@
1
+ import{r as e,t}from"./client-DQwf_b9o.js";e();export{t as clearOpenAIClientCache};
@@ -0,0 +1 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{$t as t,mt as n}from"./state-C2OSZkV1.js";import{Cf as r,Ef as i,Er as a,jr as o,mi as s}from"./loadAgentsDir-ByO8eJqU.js";async function c(e,t,i){if(!i||i.trim()===``)return e(`Please provide a color. Available colors: ${r.join(`, `)}, default`,{display:`system`}),null;let o=i.trim().toLowerCase();return l.includes(o)?(await s(n(),`default`,a()),t.setAppState(e=>({...e,standaloneAgentContext:{...e.standaloneAgentContext,name:e.standaloneAgentContext?.name??``,color:void 0}})),e(`Session color reset to default`,{display:`system`}),null):r.includes(o)?(await s(n(),o,a()),t.setAppState(e=>({...e,standaloneAgentContext:{...e.standaloneAgentContext,name:e.standaloneAgentContext?.name??``,color:o}})),e(`Session color set to: ${o}`,{display:`system`}),null):(e(`Invalid color "${o}". Available colors: ${r.join(`, `)}, default`,{display:`system`}),null)}var l;e((()=>{t(),i(),o(),l=[`default`,`reset`,`none`,`gray`,`grey`]}))();export{c as call};
@@ -0,0 +1 @@
1
+ import{Wi as e,Yi as t,zi as n}from"./loadAgentsDir-ByO8eJqU.js";t();export{n as clearCommandsCache,e as getCommands};
@@ -0,0 +1,2 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{di as t,ui as n}from"./src-CDCSSo0U2.js";import{$t as r,nn as i}from"./state-C2OSZkV1.js";import{By as a,Fy as o,Ga as s,Gy as c,Iy as l,Jg as u,Py as d,Rw as f,Ud as p,Vy as m,Wd as h,Wy as g,Yh as _,Zh as v,db as y,eo as b,fg as x,lg as S,lt as C,pg as w,qg as T,rg as E,sb as D,tb as O,tg as k,ub as A,ug as j,ut as M,yn as N,zw as P}from"./loadAgentsDir-ByO8eJqU.js";import{R as F,z as I}from"./debug-RZ4NuXyS.js";import{o as L,s as R}from"./log-CZ0zYP_c.js";function z(e,t){let r=p(`tip`),i=f(`app:toggleTranscript`,`Global`,`ctrl+o`),a=[...e.options.verbose?[]:[`(${i} to see full summary)`],...t?[t]:[],...r?[r]:[]];return n.dim(`Compacted `+a.join(`
2
+ `))}async function B(e,t){let n=e.getAppState(),r=await C(e.options.tools,e.options.mainLoopModel,Array.from(n.toolPermissionContext.additionalWorkingDirectories.keys()),e.options.mcpClients),i=T({mainThreadAgentDefinition:void 0,toolUseContext:e,customSystemPrompt:e.options.customSystemPrompt,defaultSystemPrompt:r,appendSystemPrompt:e.options.appendSystemPrompt}),[a,s]=await Promise.all([o(),d()]);return{systemPrompt:i,userContext:a,systemContext:s,toolUseContext:e,forkContextMessages:t}}var V;e((()=>{t(),r(),M(),l(),P(),A(),w(),g(),a(),k(),_(),O(),I(),N(),L(),b(),h(),u(),V=async(e,t)=>{let{abortController:n}=t,{messages:r}=t;if(r=s(r),r.length===0)throw Error(`No messages to compact`);let a=e.trim();try{if(!a){let e=await v(r,t.agentId);if(e)return o.cache.clear?.(),E(),y(t.options.querySource??`compact`,t.agentId),i(),c(),{type:`compact`,compactionResult:e,displayText:z(t)}}let e=(await m(r,t)).messages,n=await x(e,t,await B(t,e),!1,a,!1);return D(void 0),c(),o.cache.clear?.(),E(),{type:`compact`,compactionResult:n,displayText:z(t,n.userDisplayMessage)}}catch(e){throw n.signal.aborted?Error(`Compaction canceled.`):F(e,`Not enough messages to compact. Send a few more messages first, then try again.`)?Error(j):F(e,`Compaction interrupted · This may be due to network issues — please try again.`)?Error(S):(R(e),Error(`Error during compaction: ${e}`))}}}))();export{V as call};
@@ -0,0 +1 @@
1
+ import{t as e}from"./src-CDCSSo0U2.js";import{a as t,l as n,z as r}from"./debug-RZ4NuXyS.js";import{r as i,t as a}from"./execFileNoThrow-CCX-JY8h.js";import{o}from"./log-CZ0zYP_c.js";import{homedir as s}from"os";import{join as c}from"path";import"fs/promises";import"url";e(),t(),r(),i(),o();function l(){let e=process.env.SHELL||``,t=s(),n=c(t,`.claude`);if(e.endsWith(`/zsh`)||e.endsWith(`/zsh.exe`)){let e=c(n,`completion.zsh`);return{name:`zsh`,rcFile:c(t,`.zshrc`),cacheFile:e,completionLine:`[[ -f "${e}" ]] && source "${e}"`,shellFlag:`zsh`}}if(e.endsWith(`/bash`)||e.endsWith(`/bash.exe`)){let e=c(n,`completion.bash`);return{name:`bash`,rcFile:c(t,`.bashrc`),cacheFile:e,completionLine:`[ -f "${e}" ] && source "${e}"`,shellFlag:`bash`}}if(e.endsWith(`/fish`)||e.endsWith(`/fish.exe`)){let e=process.env.XDG_CONFIG_HOME||c(t,`.config`),r=c(n,`completion.fish`);return{name:`fish`,rcFile:c(e,`fish`,`config.fish`),cacheFile:r,completionLine:`[ -f "${r}" ] && source "${r}"`,shellFlag:`fish`}}return null}async function u(){let e=l();if(e){if(n(`update: Regenerating ${e.name} completion cache`),(await a(process.argv[1]||`claude`,[`completion`,e.shellFlag,`--output`,e.cacheFile])).code!==0){n(`update: Failed to regenerate ${e.name} completion cache`);return}n(`update: Regenerated ${e.name} completion cache at ${e.cacheFile}`)}}export{u as regenerateCompletionCache};
@@ -0,0 +1,3 @@
1
+ import{i as e,n as t,t as n}from"./rolldown-runtime-DaDcL9Zw.js";import{n as r,t as i}from"./isObject-C6qM3WEW.js";import{n as a,t as o}from"./memoize-BK3gG5ob.js";import{c as s,l as c,n as l,o as u}from"./envUtils-DSxRz_kt.js";import{t as d}from"./graceful-fs-DDVg0cja.js";import{$t as f,Br as p,Ci as m,Gr as h,Ir as g,Lr as _,Mi as v,Mr as ee,Ni as te,Nr as ne,Oi as re,Rr as ie,Si as ae,Ti as oe,Vr as se,Wr as ce,_i as le,_t as ue,at as y,gi as de,ki as fe,tt as pe,wi as me,zr as he}from"./state-C2OSZkV1.js";import{n as ge,t as _e}from"./cwd-C5ce-7WB.js";import{C as ve,I as b,S as ye,a as be,d as x,k as xe,l as S,nt as Se,p as Ce,rt as we,w as C,z as Te}from"./debug-RZ4NuXyS.js";import{Cn as Ee,Jt as De,Kt as w,Pn as Oe,Yt as ke,Zt as Ae,_r as je,br as Me,c as T,dr as Ne,g as Pe,gr as Fe,n as Ie,ur as Le,xr as Re}from"./settings-hQDLwPVj.js";import{O as ze,k as Be,m as Ve,n as He}from"./git-BerW9bId.js";import{d as Ue,o as We,s as Ge,u as Ke}from"./log-CZ0zYP_c.js";import{m as qe}from"./sessionStoragePortable-Cx6JQ5Ye.js";import{a as E,i as Je}from"./path-Cv9QMBAX.js";import{f as Ye,p as Xe,s as Ze,u as Qe}from"./types-D7_37tP2.js";import{n as $e,r as D}from"./analytics-CkYUHW_U.js";import{homedir as et}from"os";import{basename as O,dirname as k,isAbsolute as tt,join as A,normalize as nt,resolve as rt,sep as it}from"path";import{unwatchFile as at,watchFile as ot}from"fs";import{randomBytes as st}from"crypto";var j,ct=t((()=>{te(),Ne(),m(),me(),j=Object.getOwnPropertySymbols?function(e){for(var t=[];e;)v(t,ae(e)),e=Le(e);return t}:oe}));function lt(e){return re(e,je,j)}var ut=t((()=>{fe(),ct(),Fe()}));function dt(){let e=process.env.CLAUDE_CODE_DISABLE_AUTO_MEMORY;if(c(e))return!1;if(s(e))return!0;if(c(process.env.CLAUDE_CODE_SIMPLE)||c(process.env.CLAUDE_CODE_REMOTE)&&!process.env.CLAUDE_CODE_REMOTE_MEMORY_DIR)return!1;let t=Ie();return t.autoMemoryEnabled===void 0||t.autoMemoryEnabled}function ft(){return!1}function pt(){return process.env.CLAUDE_CODE_REMOTE_MEMORY_DIR?process.env.CLAUDE_CODE_REMOTE_MEMORY_DIR:l()}function mt(e,t){if(!e)return;let n=e;if(t&&(n.startsWith(`~/`)||n.startsWith(`~\\`))){let e=n.slice(2),t=nt(e||`.`);if(t===`.`||t===`..`)return;n=A(et(),e)}let r=nt(n).replace(/[/\\]+$/,``);if(!(!tt(r)||r.length<3||/^[A-Za-z]:$/.test(r)||r.startsWith(`\\\\`)||r.startsWith(`//`)||r.includes(`\0`)))return(r+it).normalize(`NFC`)}function ht(){return mt(process.env.CLAUDE_COWORK_MEMORY_PATH_OVERRIDE,!1)}function gt(){return mt(T(`policySettings`)?.autoMemoryDirectory??T(`flagSettings`)?.autoMemoryDirectory??T(`localSettings`)?.autoMemoryDirectory??T(`userSettings`)?.autoMemoryDirectory,!0)}function _t(){return ht()!==void 0}function vt(){return He(y())??y()}function yt(){return A(M(),St)}function bt(e){return nt(e).startsWith(M())}var xt,St,M,Ct=t((()=>{o(),f(),u(),Ve(),Je(),Pe(),xt=`memory`,St=`MEMORY.md`,M=a(()=>(ht()??gt())||(A(A(pt(),`projects`),qe(vt()),xt)+it).normalize(`NFC`),()=>y())}));function wt(e,t,n,i){if(!r(e))return e;t=p(t,e);for(var a=-1,o=t.length,s=o-1,c=e;c!=null&&++a<o;){var l=he(t[a]),u=n;if(l===`__proto__`||l===`constructor`||l===`prototype`)return e;if(a!=s){var d=c[l];u=i?i(d,l,c):void 0,u===void 0&&(u=r(d)?d:le(t[a+1])?[]:{})}Me(c,l,u),c=c[l]}return e}var Tt=t((()=>{Re(),se(),de(),i(),ie()}));function Et(e,t,n){for(var r=-1,i=t.length,a={};++r<i;){var o=t[r],s=g(e,o);n(s,o)&&wt(a,p(o,e),s)}return a}var Dt=t((()=>{_(),Tt(),se()}));function N(e,t){if(e==null)return{};var n=ce(lt(e),function(e){return[e]});return t=ee(t),Et(e,n,function(e,n){return t(e,n[0])})}var Ot=t((()=>{h(),ne(),Dt(),ut()})),kt=n(((e,t)=>{function n(e,t){typeof t==`boolean`&&(t={forever:t}),this._originalTimeouts=JSON.parse(JSON.stringify(e)),this._timeouts=e,this._options=t||{},this._maxRetryTime=t&&t.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}t.exports=n,n.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts},n.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timeouts=[],this._cachedTimeouts=null},n.prototype.retry=function(e){if(this._timeout&&clearTimeout(this._timeout),!e)return!1;var t=new Date().getTime();if(e&&t-this._operationStart>=this._maxRetryTime)return this._errors.unshift(Error(`RetryOperation timeout occurred`)),!1;this._errors.push(e);var n=this._timeouts.shift();if(n===void 0)if(this._cachedTimeouts)this._errors.splice(this._errors.length-1,this._errors.length),this._timeouts=this._cachedTimeouts.slice(0),n=this._timeouts.shift();else return!1;var r=this,i=setTimeout(function(){r._attempts++,r._operationTimeoutCb&&(r._timeout=setTimeout(function(){r._operationTimeoutCb(r._attempts)},r._operationTimeout),r._options.unref&&r._timeout.unref()),r._fn(r._attempts)},n);return this._options.unref&&i.unref(),!0},n.prototype.attempt=function(e,t){this._fn=e,t&&(t.timeout&&(this._operationTimeout=t.timeout),t.cb&&(this._operationTimeoutCb=t.cb));var n=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){n._operationTimeoutCb()},n._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)},n.prototype.try=function(e){console.log(`Using RetryOperation.try() is deprecated`),this.attempt(e)},n.prototype.start=function(e){console.log(`Using RetryOperation.start() is deprecated`),this.attempt(e)},n.prototype.start=n.prototype.try,n.prototype.errors=function(){return this._errors},n.prototype.attempts=function(){return this._attempts},n.prototype.mainError=function(){if(this._errors.length===0)return null;for(var e={},t=null,n=0,r=0;r<this._errors.length;r++){var i=this._errors[r],a=i.message,o=(e[a]||0)+1;e[a]=o,o>=n&&(t=i,n=o)}return t}})),At=n((e=>{var t=kt();e.operation=function(n){return new t(e.timeouts(n),{forever:n&&n.forever,unref:n&&n.unref,maxRetryTime:n&&n.maxRetryTime})},e.timeouts=function(e){if(e instanceof Array)return[].concat(e);var t={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var n in e)t[n]=e[n];if(t.minTimeout>t.maxTimeout)throw Error(`minTimeout is greater than maxTimeout`);for(var r=[],i=0;i<t.retries;i++)r.push(this.createTimeout(i,t));return e&&e.forever&&!r.length&&r.push(this.createTimeout(i,t)),r.sort(function(e,t){return e-t}),r},e.createTimeout=function(e,t){var n=t.randomize?Math.random()+1:1,r=Math.round(n*t.minTimeout*t.factor**+e);return r=Math.min(r,t.maxTimeout),r},e.wrap=function(t,n,r){if(n instanceof Array&&(r=n,n=null),!r)for(var i in r=[],t)typeof t[i]==`function`&&r.push(i);for(var a=0;a<r.length;a++){var o=r[a],s=t[o];t[o]=function(r){var i=e.operation(n),a=Array.prototype.slice.call(arguments,1),o=a.pop();a.push(function(e){i.retry(e)||(e&&(arguments[0]=i.mainError()),o.apply(this,arguments))}),i.attempt(function(){r.apply(t,a)})}.bind(t,s),t[o].options=n}}})),jt=n(((e,t)=>{t.exports=At()})),Mt=n(((e,t)=>{t.exports=[`SIGABRT`,`SIGALRM`,`SIGHUP`,`SIGINT`,`SIGTERM`],process.platform!==`win32`&&t.exports.push(`SIGVTALRM`,`SIGXCPU`,`SIGXFSZ`,`SIGUSR2`,`SIGTRAP`,`SIGSYS`,`SIGQUIT`,`SIGIOT`),process.platform===`linux`&&t.exports.push(`SIGIO`,`SIGPOLL`,`SIGPWR`,`SIGSTKFLT`,`SIGUNUSED`)})),Nt=n(((t,n)=>{var r=global.process,i=function(e){return e&&typeof e==`object`&&typeof e.removeListener==`function`&&typeof e.emit==`function`&&typeof e.reallyExit==`function`&&typeof e.listeners==`function`&&typeof e.kill==`function`&&typeof e.pid==`number`&&typeof e.on==`function`};if(!i(r))n.exports=function(){return function(){}};else{var a=e(`assert`),o=Mt(),s=/^win/i.test(r.platform),c=e(`events`);typeof c!=`function`&&(c=c.EventEmitter);var l;r.__signal_exit_emitter__?l=r.__signal_exit_emitter__:(l=r.__signal_exit_emitter__=new c,l.count=0,l.emitted={}),l.infinite||(l.setMaxListeners(1/0),l.infinite=!0),n.exports=function(e,t){if(!i(global.process))return function(){};a.equal(typeof e,`function`,`a callback must be provided for exit handler`),p===!1&&m();var n=`exit`;return t&&t.alwaysLast&&(n=`afterexit`),l.on(n,e),function(){l.removeListener(n,e),l.listeners(`exit`).length===0&&l.listeners(`afterexit`).length===0&&u()}};var u=function(){!p||!i(global.process)||(p=!1,o.forEach(function(e){try{r.removeListener(e,f[e])}catch{}}),r.emit=_,r.reallyExit=h,--l.count)};n.exports.unload=u;var d=function(e,t,n){l.emitted[e]||(l.emitted[e]=!0,l.emit(e,t,n))},f={};o.forEach(function(e){f[e]=function(){i(global.process)&&r.listeners(e).length===l.count&&(u(),d(`exit`,null,e),d(`afterexit`,null,e),s&&e===`SIGHUP`&&(e=`SIGINT`),r.kill(r.pid,e))}}),n.exports.signals=function(){return o};var p=!1,m=function(){p||!i(global.process)||(p=!0,l.count+=1,o=o.filter(function(e){try{return r.on(e,f[e]),!0}catch{return!1}}),r.emit=v,r.reallyExit=g)};n.exports.load=m;var h=r.reallyExit,g=function(e){i(global.process)&&(r.exitCode=e||0,d(`exit`,r.exitCode,null),d(`afterexit`,r.exitCode,null),h.call(r,r.exitCode))},_=r.emit,v=function(e,t){if(e===`exit`&&i(global.process)){t!==void 0&&(r.exitCode=t);var n=_.apply(this,arguments);return d(`exit`,r.exitCode,null),d(`afterexit`,r.exitCode,null),n}else return _.apply(this,arguments)}}})),Pt=n(((e,t)=>{var n=Symbol();function r(e,t,r){let i=t[n];if(i)return t.stat(e,(e,t)=>{if(e)return r(e);r(null,t.mtime,i)});let a=new Date(Math.ceil(Date.now()/1e3)*1e3+5);t.utimes(e,a,a,i=>{if(i)return r(i);t.stat(e,(e,i)=>{if(e)return r(e);let a=i.mtime.getTime()%1e3==0?`s`:`ms`;Object.defineProperty(t,n,{value:a}),r(null,i.mtime,a)})})}function i(e){let t=Date.now();return e===`s`&&(t=Math.ceil(t/1e3)*1e3),new Date(t)}t.exports.probe=r,t.exports.getMtime=i})),Ft=n(((t,n)=>{var r=e(`path`),i=d(),a=jt(),o=Nt(),s=Pt(),c={};function l(e,t){return t.lockfilePath||`${e}.lock`}function u(e,t,n){if(!t.realpath)return n(null,r.resolve(e));t.fs.realpath(e,n)}function f(e,t,n){let r=l(e,t);t.fs.mkdir(r,i=>{if(!i)return s.probe(r,t.fs,(e,i,a)=>{if(e)return t.fs.rmdir(r,()=>{}),n(e);n(null,i,a)});if(i.code!==`EEXIST`)return n(i);if(t.stale<=0)return n(Object.assign(Error(`Lock file is already being held`),{code:`ELOCKED`,file:e}));t.fs.stat(r,(r,i)=>{if(r)return r.code===`ENOENT`?f(e,{...t,stale:0},n):n(r);if(!p(i,t))return n(Object.assign(Error(`Lock file is already being held`),{code:`ELOCKED`,file:e}));m(e,t,r=>{if(r)return n(r);f(e,{...t,stale:0},n)})})})}function p(e,t){return e.mtime.getTime()<Date.now()-t.stale}function m(e,t,n){t.fs.rmdir(l(e,t),e=>{if(e&&e.code!==`ENOENT`)return n(e);n()})}function h(e,t){let n=c[e];n.updateTimeout||(n.updateDelay=n.updateDelay||t.update,n.updateTimeout=setTimeout(()=>{n.updateTimeout=null,t.fs.stat(n.lockfilePath,(r,i)=>{let a=n.lastUpdate+t.stale<Date.now();if(r)return r.code===`ENOENT`||a?g(e,n,Object.assign(r,{code:`ECOMPROMISED`})):(n.updateDelay=1e3,h(e,t));if(n.mtime.getTime()!==i.mtime.getTime())return g(e,n,Object.assign(Error(`Unable to update lock within the stale threshold`),{code:`ECOMPROMISED`}));let o=s.getMtime(n.mtimePrecision);t.fs.utimes(n.lockfilePath,o,o,r=>{let i=n.lastUpdate+t.stale<Date.now();if(!n.released){if(r)return r.code===`ENOENT`||i?g(e,n,Object.assign(r,{code:`ECOMPROMISED`})):(n.updateDelay=1e3,h(e,t));n.mtime=o,n.lastUpdate=Date.now(),n.updateDelay=null,h(e,t)}})})},n.updateDelay),n.updateTimeout.unref&&n.updateTimeout.unref())}function g(e,t,n){t.released=!0,t.updateTimeout&&clearTimeout(t.updateTimeout),c[e]===t&&delete c[e],t.options.onCompromised(n)}function _(e,t,n){t={stale:1e4,update:null,realpath:!0,retries:0,fs:i,onCompromised:e=>{throw e},...t},t.retries=t.retries||0,t.retries=typeof t.retries==`number`?{retries:t.retries}:t.retries,t.stale=Math.max(t.stale||0,2e3),t.update=t.update==null?t.stale/2:t.update||0,t.update=Math.max(Math.min(t.update,t.stale/2),1e3),u(e,t,(e,r)=>{if(e)return n(e);let i=a.operation(t.retries);i.attempt(()=>{f(r,t,(e,a,o)=>{if(i.retry(e))return;if(e)return n(i.mainError());let s=c[r]={lockfilePath:l(r,t),mtime:a,mtimePrecision:o,options:t,lastUpdate:Date.now()};h(r,t),n(null,e=>{if(s.released)return e&&e(Object.assign(Error(`Lock is already released`),{code:`ERELEASED`}));v(r,{...t,realpath:!1},e)})})})})}function v(e,t,n){t={fs:i,realpath:!0,...t},u(e,t,(e,r)=>{if(e)return n(e);let i=c[r];if(!i)return n(Object.assign(Error(`Lock is not acquired/owned by you`),{code:`ENOTACQUIRED`}));i.updateTimeout&&clearTimeout(i.updateTimeout),i.released=!0,delete c[r],m(r,t,n)})}function ee(e,t,n){t={stale:1e4,realpath:!0,fs:i,...t},t.stale=Math.max(t.stale||0,2e3),u(e,t,(e,r)=>{if(e)return n(e);t.fs.stat(l(r,t),(e,r)=>e?e.code===`ENOENT`?n(null,!1):n(e):n(null,!p(r,t)))})}function te(){return c}o(()=>{for(let e in c){let t=c[e].options;try{t.fs.rmdirSync(l(e,t))}catch{}}}),n.exports.lock=_,n.exports.unlock=v,n.exports.check=ee,n.exports.getLocks=te})),It=n(((e,t)=>{var n=d();function r(e){let t=[`mkdir`,`realpath`,`stat`,`rmdir`,`utimes`],n={...e};return t.forEach(t=>{n[t]=(...n)=>{let r=n.pop(),i;try{i=e[`${t}Sync`](...n)}catch(e){return r(e)}r(null,i)}}),n}function i(e){return(...t)=>new Promise((n,r)=>{t.push((e,t)=>{e?r(e):n(t)}),e(...t)})}function a(e){return(...t)=>{let n,r;if(t.push((e,t)=>{n=e,r=t}),e(...t),n)throw n;return r}}function o(e){if(e={...e},e.fs=r(e.fs||n),typeof e.retries==`number`&&e.retries>0||e.retries&&typeof e.retries.retries==`number`&&e.retries.retries>0)throw Object.assign(Error(`Cannot use retries with the sync api`),{code:`ESYNC`});return e}t.exports={toPromise:i,toSync:a,toSyncOptions:o}})),Lt=n(((e,t)=>{var n=Ft(),{toPromise:r,toSync:i,toSyncOptions:a}=It();async function o(e,t){return r(await r(n.lock)(e,t))}function s(e,t){return i(i(n.lock)(e,a(t)))}function c(e,t){return r(n.unlock)(e,t)}function l(e,t){return i(n.unlock)(e,a(t))}function u(e,t){return r(n.check)(e,t)}function d(e,t){return i(n.check)(e,a(t))}t.exports=o,t.exports.lock=o,t.exports.unlock=c,t.exports.lockSync=s,t.exports.unlockSync=l,t.exports.check=u,t.exports.checkSync=d}));function P(){return F||(F=Lt()),F}function Rt(e,t){return P().lock(e,t)}function zt(e,t){return P().lockSync(e,t)}function Bt(e,t){return P().unlock(e,t)}function Vt(e,t){return P().check(e,t)}var F,Ht=t((()=>{}));function I(){return{numStartups:0,installMethod:void 0,autoUpdates:void 0,theme:`dark`,preferredNotifChannel:`auto`,verbose:!1,editorMode:`normal`,autoCompactEnabled:!0,showTurnDuration:!0,hasSeenTasksHint:!1,hasUsedStash:!1,hasUsedBackgroundTask:!1,queuedCommandUpHintCount:0,diffTool:`auto`,customApiKeyResponses:{approved:[],rejected:[]},env:{},tipsHistory:{},memoryUsageCount:0,promptQueueUseCount:0,btwUseCount:0,todoFeatureEnabled:!0,showExpandedTodos:!1,messageIdleNotifThresholdMs:6e4,autoConnectIde:!1,autoInstallIdeExtension:!0,fileCheckpointingEnabled:!0,terminalProgressBarEnabled:!0,cachedStatsigGates:{},cachedDynamicConfigs:{},respectGitignore:!0}}function Ut(){return G||(G=Wt())}function Wt(){if(ue())return!0;let e=B(),t=$();if(e.projects?.[t]?.hasTrustDialogAccepted)return!0;let n=E(_e());for(;;){if(e.projects?.[n]?.hasTrustDialogAccepted)return!0;let t=E(rt(n,`..`));if(t===n)break;n=t}return!1}function L(e){let t=K.config;if(!t)return!1;let n=t.oauthAccount!==void 0&&e.oauthAccount===void 0,r=t.hasCompletedOnboarding===!0&&e.hasCompletedOnboarding!==!0;return n||r}function R(e){let t=null;try{$t(w(),I,n=>{let r=e(n);return r===n?n:(t={...r,projects:Jt(n.projects)},t)})&&t&&z(t)}catch(n){S(`Failed to save config with lock: ${n}`,{level:`error`});let r=V(w(),I);if(L(r)){S(`saveGlobalConfig fallback: re-read config is missing auth that cache has; refusing to write. See GH #3117.`,{level:`error`}),D(`tengu_config_auth_loss_prevented`,{});return}let i=e(r);if(i===r)return;t={...i,projects:Jt(r.projects)},Qt(w(),t,W),z(t)}}function Gt(){return X}function Kt(){let e=J+Y;e>0&&D(`tengu_config_cache_stats`,{cache_hits:J,cache_misses:Y,hit_rate:J/e}),J=0,Y=0}function qt(e){if(e.installMethod!==void 0)return e;let t=e,n=`unknown`,r=e.autoUpdates??!0;switch(t.autoUpdaterStatus){case`migrated`:n=`local`;break;case`installed`:n=`native`;break;case`disabled`:r=!1;break;case`enabled`:case`no_permissions`:case`not_configured`:n=`global`;break;case void 0:break}return{...e,installMethod:n,autoUpdates:r}}function Jt(e){if(!e)return e;let t={},n=!1;for(let[r,i]of Object.entries(e)){let e=i;if(e.history!==void 0){n=!0;let{history:i,...a}=e;t[r]=a}else t[r]=i}return n?t:e}function Yt(){if(Z)return;Z=!0;let e=w();ot(e,{interval:hn,persistent:!1},t=>{t.mtimeMs<=K.mtime||x().readFile(e,{encoding:`utf-8`}).then(e=>{if(t.mtimeMs<=K.mtime)return;let n=Qe(Xe(e));typeof n!=`object`||!n||(K={config:qt({...I(),...n}),mtime:t.mtimeMs},q={mtime:t.mtimeMs,size:t.size})}).catch(()=>{})}),we(async()=>{at(e),Z=!1})}function z(e){K={config:e,mtime:Date.now()},q=null}function B(){if(K.config)return J++,K.config;Y++;try{let e=null;try{e=x().statSync(w())}catch{}let t=qt(V(w(),I));return K={config:t,mtime:e?.mtimeMs??Date.now()},q=e?{mtime:e.mtimeMs,size:e.size}:null,Yt(),t}catch{return qt(V(w(),I))}}function Xt(){let e=B().remoteControlAtStartup;return e!==void 0&&e}function Zt(e){let t=B();return t.customApiKeyResponses?.approved?.includes(e)?`approved`:t.customApiKeyResponses?.rejected?.includes(e)?`rejected`:`new`}function Qt(e,t,n){let r=k(e);x().mkdirSync(r),Oe(e,C(N(t,(e,t)=>C(e)!==C(n[t])),null,2),{encoding:`utf-8`,mode:384}),e===w()&&X++}function $t(e,t,n){let r=t(),i=k(e),a=x();a.mkdirSync(i);let o;try{let i=`${e}.lock`,s=Date.now();o=zt(e,{lockfilePath:i,onCompromised:e=>{S(`Config lock compromised: ${e}`,{level:`error`})}});let c=Date.now()-s;if(c>100&&(S(`Lock acquisition took longer than expected - another Claude instance may be running`),D(`tengu_config_lock_contention`,{lock_time_ms:c})),q&&e===w())try{let t=a.statSync(e);(t.mtimeMs!==q.mtime||t.size!==q.size)&&D(`tengu_config_stale_write`,{read_mtime:q.mtime,write_mtime:t.mtimeMs,read_size:q.size,write_size:t.size})}catch(e){if(b(e)!==`ENOENT`)throw e}let l=V(e,t);if(e===w()&&L(l))return S(`saveConfigWithLock: re-read config is missing auth that cache has; refusing to write to avoid wiping ~/.claude.json. See GH #3117.`,{level:`error`}),D(`tengu_config_auth_loss_prevented`,{}),!1;let u=n(l);if(u===l)return!1;let d=N(u,(e,t)=>C(e)!==C(r[t]));try{let t=O(e),n=tn();try{a.mkdirSync(n)}catch(e){if(b(e)!==`EEXIST`)throw e}let r=a.readdirStringSync(n).filter(e=>e.startsWith(`${t}.backup.`)).sort().reverse(),i=r[0],o=i?Number(i.split(`.backup.`).pop()):0,s=Number.isNaN(o)||Date.now()-o>=6e4;if(s){let r=A(n,`${t}.backup.${Date.now()}`);a.copyFileSync(e,r)}let c=s?a.readdirStringSync(n).filter(e=>e.startsWith(`${t}.backup.`)).sort().reverse():r;for(let e of c.slice(5))try{a.unlinkSync(A(n,e))}catch{}}catch(e){b(e)!==`ENOENT`&&S(`Failed to backup config: ${e}`,{level:`error`})}return Oe(e,C(d,null,2),{encoding:`utf-8`,mode:384}),e===w()&&X++,!0}finally{o&&o()}}function en(){if(Q)return;let e=Date.now();Be(`info`,`enable_configs_started`),Q=!0,V(w(),I,!0),Be(`info`,`enable_configs_completed`,{duration_ms:Date.now()-e})}function tn(){return A(l(),`backups`)}function nn(e){let t=x(),n=O(e),r=tn();try{let e=t.readdirStringSync(r).filter(e=>e.startsWith(`${n}.backup.`)).sort().at(-1);if(e)return A(r,e)}catch{}let i=k(e);try{let r=t.readdirStringSync(i).filter(e=>e.startsWith(`${n}.backup.`)).sort().at(-1);if(r)return A(i,r);let a=`${e}.backup`;try{return t.statSync(a),a}catch{}}catch{}return null}function V(e,t,n){if(!Q)throw Error(`Config accessed before allowed.`);let r=x();try{let n=r.readFileSync(e,{encoding:`utf-8`});try{let e=ve(Xe(n));return{...t(),...e}}catch(n){throw new xe(n instanceof Error?n.message:String(n),e,t())}}catch(i){if(b(i)===`ENOENT`){let n=nn(e);return n&&process.stderr.write(`\nClaude configuration file not found at: ${e}\nA backup file exists at: ${n}\nYou can manually restore it by running: cp "${n}" "${e}"\n\n`),t()}if(i instanceof xe&&n)throw i;if(i instanceof xe){if(S(`Config file corrupted, resetting to defaults: ${i.message}`,{level:`error`}),!H){H=!0;try{Ge(i);let t=!1;try{r.statSync(`${e}.backup`),t=!0}catch{}D(`tengu_config_parse_error`,{has_backup:t})}finally{H=!1}}process.stderr.write(`\nClaude configuration file at ${e} is corrupted: ${i.message}\n`);let t=O(e),n=tn();try{r.mkdirSync(n)}catch(e){if(b(e)!==`EEXIST`)throw e}let a=r.readdirStringSync(n).filter(e=>e.startsWith(`${t}.corrupted.`)),o,s=!1,c=r.readFileSync(e,{encoding:`utf-8`});for(let e of a)try{if(c===r.readFileSync(A(n,e),{encoding:`utf-8`})){s=!0;break}}catch{}if(!s){o=A(n,`${t}.corrupted.${Date.now()}`);try{r.copyFileSync(e,o),S(`Corrupted config backed up to: ${o}`,{level:`error`})}catch{}}let l=nn(e);o?process.stderr.write(`The corrupted file has been backed up to: ${o}\n`):s&&process.stderr.write(`The corrupted file has already been backed up.
2
+ `),l?process.stderr.write(`A backup file exists at: ${l}\nYou can manually restore it by running: cp "${l}" "${e}"\n\n`):process.stderr.write(`
3
+ `)}return t()}}function rn(){let e=$(),t=B();if(!t.projects)return U;let n=t.projects[e]??U;return typeof n.allowedTools==`string`&&(n.allowedTools=Qe(n.allowedTools)??[]),n}function an(e){let t=$(),n=null;try{$t(w(),I,r=>{let i=r.projects?.[t]??U,a=e(i);return a===i?r:(n={...r,projects:{...r.projects,[t]:a}},n)})&&n&&z(n)}catch(r){S(`Failed to save config with lock: ${r}`,{level:`error`});let i=V(w(),I);if(L(i)){S(`saveCurrentProjectConfig fallback: re-read config is missing auth that cache has; refusing to write. See GH #3117.`,{level:`error`}),D(`tengu_config_auth_loss_prevented`,{});return}let a=i.projects?.[t]??U,o=e(a);if(o===a)return;n={...i,projects:{...i.projects,[t]:o}},Qt(w(),n,W),z(n)}}function on(){return ln()!==null}function sn(){return on()&&!c(process.env.FORCE_AUTOUPDATE_PLUGINS)}function cn(e){switch(e.type){case`development`:return`development build`;case`env`:return`${e.envVar} set`;case`config`:return`config`}}function ln(){if(!c(process.env.ENABLE_AUTOUPDATER))return{type:`config`};if(c(process.env.DISABLE_AUTOUPDATER))return{type:`env`,envVar:`DISABLE_AUTOUPDATER`};let e=Ke();if(e)return{type:`env`,envVar:e};let t=B();return t.autoUpdates===!1&&(t.installMethod!==`native`||t.autoUpdatesProtectedForNative!==!0)?{type:`config`}:null}function un(){let e=B();if(e.userID)return e.userID;let t=st(32).toString(`hex`);return R(e=>({...e,userID:t})),t}function dn(){if(!B().firstStartTime){let e=new Date().toISOString();R(t=>({...t,firstStartTime:t.firstStartTime??e}))}}function fn(e){let t=pe();switch(e){case`User`:return A(l(),`CLAUDE.md`);case`Local`:return A(t,`CLAUDE.local.md`);case`Project`:return A(t,`CLAUDE.md`);case`Managed`:return A(ke(),`CLAUDE.md`);case`AutoMem`:return yt();default:return A(l(),`CLAUDE.md`)}}function pn(){return A(ke(),`.claude`,`rules`)}function mn(){return A(l(),`rules`)}var H,U,W,G,K,q,J,Y,X,hn,Z,Q,$,gn=t((()=>{o(),Ot(),f(),Ct(),$e(),ge(),Se(),be(),ze(),De(),u(),Te(),Ee(),Ce(),Ve(),Ze(),Ye(),Ht(),We(),Je(),Ue(),Ae(),ye(),H=!1,U={allowedTools:[],mcpContextUris:[],mcpServers:{},enabledMcpjsonServers:[],disabledMcpjsonServers:[],hasTrustDialogAccepted:!1,projectOnboardingSeenCount:0,hasClaudeMdExternalIncludesApproved:!1,hasClaudeMdExternalIncludesWarningShown:!1},W=I(),G=!1,{...W},{...U},K={config:null,mtime:0},q=null,J=0,Y=0,X=0,we(async()=>{Kt()}),hn=1e3,Z=!1,Q=!1,$=a(()=>{let e=pe();return E(He(e)||rt(e))})}));export{yt as A,j as B,Ht as C,N as D,Ot as E,bt as F,dt as I,ft as L,pt as M,_t as N,wt as O,Ct as P,lt as R,Vt as S,Bt as T,ct as V,on as _,ln as a,R as b,B as c,fn as d,un as f,gn as g,mn as h,cn as i,M as j,Tt as k,Gt as l,Xt as m,Ut as n,rn as o,$ as p,en as r,Zt as s,W as t,pn as u,dn as v,Rt as w,sn as x,an as y,ut as z};
@@ -0,0 +1 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{t}from"./jsx-runtime-Bb4Xn-E0.js";import{n,t as r}from"./Settings-CyUm0AtU.js";var i,a;e((()=>{n(),i=t(),a=async(e,t)=>(0,i.jsx)(r,{onClose:e,context:t,defaultTab:`Config`})}))();export{a as call};
@@ -0,0 +1 @@
1
+ import"./loadAgentsDir-ByO8eJqU.js";import{b as e,c as t,g as n,n as r,o as i,r as a,y as o}from"./config-CE058cvr.js";n();export{r as checkHasTrustDialogAccepted,a as enableConfigs,i as getCurrentProjectConfig,t as getGlobalConfig,o as saveCurrentProjectConfig,e as saveGlobalConfig};
@@ -0,0 +1,29 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{By as t,Ga as n,Kg as r,Vy as i,Wg as a,eo as o}from"./loadAgentsDir-ByO8eJqU.js";import{cn as s,sn as c}from"./settings-hQDLwPVj.js";import{v as l,y as u}from"./startupProfiler-DCn_NxMH.js";async function d(e){let{messages:t,getAppState:r,options:{mainLoopModel:o,tools:s,agentDefinitions:c,customSystemPrompt:l,appendSystemPrompt:u}}=e,d=n(t),{messages:f}=await i(d),p=r();return a(f,o,async()=>p.toolPermissionContext,s,c,void 0,{options:{customSystemPrompt:l,appendSystemPrompt:u}},void 0,d)}async function f(e,t){return{type:`text`,value:p(await d(t))}}function p(e){let{categories:t,totalTokens:n,rawMaxTokens:r,percentage:i,model:a,memoryFiles:o,mcpTools:s,agents:u,skills:d}=e,f=`## Context Usage
2
+
3
+ `;f+=`**Model:** ${a} \n`,f+=`**Tokens:** ${l(n)} / ${l(r)} (${i}%)\n`,f+=`
4
+ `;let p=t.filter(e=>e.tokens>0&&e.name!==`Free space`&&e.name!==`Autocompact buffer`);if(p.length>0){f+=`### Estimated usage by category
5
+
6
+ `,f+=`| Category | Tokens | Percentage |
7
+ `,f+=`|----------|--------|------------|
8
+ `;for(let e of p){let t=(e.tokens/r*100).toFixed(1);f+=`| ${e.name} | ${l(e.tokens)} | ${t}% |\n`}let e=t.find(e=>e.name===`Free space`);if(e&&e.tokens>0){let t=(e.tokens/r*100).toFixed(1);f+=`| Free space | ${l(e.tokens)} | ${t}% |\n`}let n=t.find(e=>e.name===`Autocompact buffer`);if(n&&n.tokens>0){let e=(n.tokens/r*100).toFixed(1);f+=`| Autocompact buffer | ${l(n.tokens)} | ${e}% |\n`}f+=`
9
+ `}if(s.length>0){f+=`### MCP Tools
10
+
11
+ `,f+=`| Tool | Server | Tokens |
12
+ `,f+=`|------|--------|--------|
13
+ `;for(let e of s)f+=`| ${e.name} | ${e.serverName} | ${l(e.tokens)} |\n`;f+=`
14
+ `}if(u.length>0){f+=`### Custom Agents
15
+
16
+ `,f+=`| Agent Type | Source | Tokens |
17
+ `,f+=`|------------|--------|--------|
18
+ `;for(let e of u){let t;switch(e.source){case`projectSettings`:t=`Project`;break;case`userSettings`:t=`User`;break;case`localSettings`:t=`Local`;break;case`flagSettings`:t=`Flag`;break;case`policySettings`:t=`Policy`;break;case`plugin`:t=`Plugin`;break;case`built-in`:t=`Built-in`;break;default:t=String(e.source)}f+=`| ${e.agentType} | ${t} | ${l(e.tokens)} |\n`}f+=`
19
+ `}if(o.length>0){f+=`### Memory Files
20
+
21
+ `,f+=`| Type | Path | Tokens |
22
+ `,f+=`|------|------|--------|
23
+ `;for(let e of o)f+=`| ${e.type} | ${e.path} | ${l(e.tokens)} |\n`;f+=`
24
+ `}if(d&&d.tokens>0&&d.skillFrontmatter.length>0){f+=`### Skills
25
+
26
+ `,f+=`| Skill | Source | Tokens |
27
+ `,f+=`|-------|--------|--------|
28
+ `;for(let e of d.skillFrontmatter)f+=`| ${e.name} | ${c(e.source)} | ${l(e.tokens)} |\n`;f+=`
29
+ `}return f}var m=e((()=>{t(),r(),u(),o(),s()}));export{d as n,m as r,f as t};
@@ -0,0 +1 @@
1
+ import{n as e,r as t,t as n}from"./context-noninteractive-Ct_ttQfP.js";t();export{n as call,e as collectContextData};
@@ -0,0 +1 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./figures-5ThXQEtq.js";import{I as r,P as i,fi as a,s as o,t as s}from"./src-CDCSSo0U2.js";import{t as c}from"./jsx-runtime-Bb4Xn-E0.js";import{By as l,Ga as u,Kg as d,Vy as f,Wg as p,eo as m}from"./loadAgentsDir-ByO8eJqU.js";import{Cn as h,bn as g,cn as _,sn as v}from"./settings-hQDLwPVj.js";import{v as y,y as b}from"./startupProfiler-DCn_NxMH.js";import{Yt as x,fn as S,gn as C,hn as w,mn as T,tn as ee}from"./prompt-B7joRiqj.js";import{n as E,t as D}from"./staticRender-BIxpgNUq.js";function O(e){let t=[];return k(e,t),A(e,t),M(e,t),N(e,t),P(e,t),t.sort((e,t)=>e.severity===t.severity?(t.savingsTokens??0)-(e.savingsTokens??0):e.severity===`warning`?-1:1),t}function k(e,t){e.percentage>=R&&t.push({severity:`warning`,title:`Context is ${e.percentage}% full`,detail:e.isAutoCompactEnabled?`Autocompact will trigger soon, which discards older messages. Use /compact now to control what gets kept.`:`Autocompact is disabled. Use /compact to free space, or enable autocompact in /config.`})}function A(e,t){if(e.messageBreakdown)for(let n of e.messageBreakdown.toolCallsByType){let r=n.callTokens+n.resultTokens,i=r/e.rawMaxTokens*100;if(i<F||r<I)continue;let a=j(n.name,r,i);a&&t.push(a)}}function j(e,t,n){let r=y(t);switch(e){case w:return{severity:`warning`,title:`Bash results using ${r} tokens (${n.toFixed(0)}%)`,detail:`Pipe output through head, tail, or grep to reduce result size. Avoid cat on large files — use Read with offset/limit instead.`,savingsTokens:Math.floor(t*.5)};case x:return{severity:`info`,title:`Read results using ${r} tokens (${n.toFixed(0)}%)`,detail:`Use offset and limit parameters to read only the sections you need. Avoid re-reading entire files when you only need a few lines.`,savingsTokens:Math.floor(t*.3)};case S:return{severity:`info`,title:`Grep results using ${r} tokens (${n.toFixed(0)}%)`,detail:`Add more specific patterns or use the glob or type parameter to narrow file types. Consider Glob for file discovery instead of Grep.`,savingsTokens:Math.floor(t*.3)};default:return n>=20?{severity:`info`,title:`${e} using ${r} tokens (${n.toFixed(0)}%)`,detail:`This tool is consuming a significant portion of context.`,savingsTokens:Math.floor(t*.2)}:null}}function M(e,t){if(!e.messageBreakdown)return;let n=e.messageBreakdown.toolCallsByType.find(e=>e.name===x);if(!n)return;let r=n.callTokens+n.resultTokens,i=r/e.rawMaxTokens*100,a=n.resultTokens/e.rawMaxTokens*100;i>=F&&r>=I||a>=L&&n.resultTokens>=I&&t.push({severity:`info`,title:`File reads using ${y(n.resultTokens)} tokens (${a.toFixed(0)}%)`,detail:`If you are re-reading files, consider referencing earlier reads. Use offset/limit for large files.`,savingsTokens:Math.floor(n.resultTokens*.3)})}function N(e,t){let n=e.memoryFiles.reduce((e,t)=>e+t.tokens,0),r=n/e.rawMaxTokens*100;if(r>=z&&n>=B){let i=[...e.memoryFiles].sort((e,t)=>t.tokens-e.tokens).slice(0,3).map(e=>`${g(e.path)} (${y(e.tokens)})`).join(`, `);t.push({severity:`info`,title:`Memory files using ${y(n)} tokens (${r.toFixed(0)}%)`,detail:`Largest: ${i}. Use /memory to review and prune stale entries.`,savingsTokens:Math.floor(n*.3)})}}function P(e,t){!e.isAutoCompactEnabled&&e.percentage>=50&&e.percentage<R&&t.push({severity:`info`,title:`Autocompact is disabled`,detail:`Without autocompact, you will hit context limits and lose the conversation. Enable it in /config or use /compact manually.`})}var F,I,L,R,z,B,V=e((()=>{C(),ee(),T(),h(),b(),F=15,I=1e4,L=5,R=80,z=5,B=5e3}));function H({suggestions:e}){return e.length===0?null:(0,U.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,U.jsx)(i,{bold:!0,children:`Suggestions`}),e.map((e,t)=>(0,U.jsxs)(r,{flexDirection:`column`,marginTop:t===0?0:1,children:[(0,U.jsxs)(r,{children:[(0,U.jsx)(o,{status:e.severity,withSpace:!0}),(0,U.jsx)(i,{bold:!0,children:e.title}),e.savingsTokens?(0,U.jsxs)(i,{dimColor:!0,children:[` `,n.arrowRight,` save ~`,y(e.savingsTokens)]}):null]}),(0,U.jsx)(r,{marginLeft:2,children:(0,U.jsx)(i,{dimColor:!0,children:e.detail})})]},t))]})}var U,W=e((()=>{t(),a(),s(),b(),U=c()}));function G(){return null}function K(e){let t=new Map;for(let n of e){let e=v(n.source),r=t.get(e)||[];r.push(n),t.set(e,r)}for(let[e,n]of t.entries())t.set(e,n.sort((e,t)=>t.tokens-e.tokens));let n=new Map;for(let e of X){let r=t.get(e);r&&n.set(e,r)}return n}function q({data:e}){let{categories:t,totalTokens:n,rawMaxTokens:a,percentage:o,gridRows:s,model:c,memoryFiles:l,mcpTools:u,deferredBuiltinTools:d=[],systemTools:f,systemPromptSections:p,agents:m,skills:h,messageBreakdown:_,cacheHitRate:v,cacheThreshold:b}=e,x=t.filter(e=>e.tokens>0&&e.name!==`Free space`&&e.name!==Y&&!e.isDeferred),S=t.some(e=>e.isDeferred&&e.name.includes(`MCP`)),C=d.length>0,w=t.find(e=>e.name===Y);return(0,J.jsxs)(r,{flexDirection:`column`,paddingLeft:1,children:[(0,J.jsx)(i,{bold:!0,children:`Context Usage`}),(0,J.jsxs)(r,{flexDirection:`row`,gap:2,children:[(0,J.jsx)(r,{flexDirection:`column`,flexShrink:0,children:s.map((e,t)=>(0,J.jsx)(r,{flexDirection:`row`,marginLeft:-1,children:e.map((e,t)=>e.categoryName===`Free space`?(0,J.jsx)(i,{dimColor:!0,children:`⛶ `},t):e.categoryName===Y?(0,J.jsx)(i,{color:e.color,children:`⛝ `},t):(0,J.jsx)(i,{color:e.color,children:e.squareFullness>=.7?`⛁ `:`⛀ `},t))},t))}),(0,J.jsxs)(r,{flexDirection:`column`,gap:0,flexShrink:0,children:[(0,J.jsxs)(i,{dimColor:!0,children:[c,` · `,y(n),`/`,y(a),` tokens (`,o,`%)`]}),(0,J.jsx)(G,{}),v!==void 0&&b!==void 0&&(0,J.jsxs)(i,{color:v<b?`warning`:void 0,children:[`Cache hit rate: `,v.toFixed(0),`%`,v<b?` (below ${b}% threshold)`:``]}),(0,J.jsx)(i,{children:` `}),(0,J.jsx)(i,{dimColor:!0,italic:!0,children:`Estimated usage by category`}),x.map((e,t)=>{let n=y(e.tokens),o=e.isDeferred?`N/A`:`${(e.tokens/a*100).toFixed(1)}%`,s=e.name===Y,c=e.name,l=e.isDeferred?` `:s?`⛝`:`⛁`;return(0,J.jsxs)(r,{children:[(0,J.jsx)(i,{color:e.color,children:l}),(0,J.jsxs)(i,{children:[` `,c,`: `]}),(0,J.jsxs)(i,{dimColor:!0,children:[n,` tokens (`,o,`)`]})]},t)}),(t.find(e=>e.name===`Free space`)?.tokens??0)>0&&(0,J.jsxs)(r,{children:[(0,J.jsx)(i,{dimColor:!0,children:`⛶`}),(0,J.jsx)(i,{children:` Free space: `}),(0,J.jsxs)(i,{dimColor:!0,children:[y(t.find(e=>e.name===`Free space`)?.tokens||0),` (`,((t.find(e=>e.name===`Free space`)?.tokens||0)/a*100).toFixed(1),`%)`]})]}),w&&w.tokens>0&&(0,J.jsxs)(r,{children:[(0,J.jsx)(i,{color:w.color,children:`⛝`}),(0,J.jsxs)(i,{dimColor:!0,children:[` `,w.name,`: `]}),(0,J.jsxs)(i,{dimColor:!0,children:[y(w.tokens),` tokens (`,(w.tokens/a*100).toFixed(1),`%)`]})]})]})]}),(0,J.jsxs)(r,{flexDirection:`column`,marginLeft:-1,children:[u.length>0&&(0,J.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,J.jsxs)(r,{children:[(0,J.jsx)(i,{bold:!0,children:`MCP tools`}),(0,J.jsxs)(i,{dimColor:!0,children:[` · /mcp`,S?` (loaded on-demand)`:``]})]}),u.some(e=>e.isLoaded)&&(0,J.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,J.jsx)(i,{dimColor:!0,children:`Loaded`}),u.filter(e=>e.isLoaded).map((e,t)=>(0,J.jsxs)(r,{children:[(0,J.jsxs)(i,{children:[`└ `,e.name,`: `]}),(0,J.jsxs)(i,{dimColor:!0,children:[y(e.tokens),` tokens`]})]},t))]}),S&&u.some(e=>!e.isLoaded)&&(0,J.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,J.jsx)(i,{dimColor:!0,children:`Available`}),u.filter(e=>!e.isLoaded).map((e,t)=>(0,J.jsx)(r,{children:(0,J.jsxs)(i,{dimColor:!0,children:[`└ `,e.name]})},t))]}),!S&&u.map((e,t)=>(0,J.jsxs)(r,{children:[(0,J.jsxs)(i,{children:[`└ `,e.name,`: `]}),(0,J.jsxs)(i,{dimColor:!0,children:[y(e.tokens),` tokens`]})]},t))]}),(f&&f.length>0||C)&&process.env.USER_TYPE===`ant`&&(0,J.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,J.jsxs)(r,{children:[(0,J.jsx)(i,{bold:!0,children:`[ANT-ONLY] System tools`}),C&&(0,J.jsx)(i,{dimColor:!0,children:` (some loaded on-demand)`})]}),(0,J.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,J.jsx)(i,{dimColor:!0,children:`Loaded`}),f?.map((e,t)=>(0,J.jsxs)(r,{children:[(0,J.jsxs)(i,{children:[`└ `,e.name,`: `]}),(0,J.jsxs)(i,{dimColor:!0,children:[y(e.tokens),` tokens`]})]},`sys-${t}`)),d.filter(e=>e.isLoaded).map((e,t)=>(0,J.jsxs)(r,{children:[(0,J.jsxs)(i,{children:[`└ `,e.name,`: `]}),(0,J.jsxs)(i,{dimColor:!0,children:[y(e.tokens),` tokens`]})]},`def-${t}`))]}),C&&d.some(e=>!e.isLoaded)&&(0,J.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,J.jsx)(i,{dimColor:!0,children:`Available`}),d.filter(e=>!e.isLoaded).map((e,t)=>(0,J.jsx)(r,{children:(0,J.jsxs)(i,{dimColor:!0,children:[`└ `,e.name]})},t))]})]}),p&&p.length>0&&process.env.USER_TYPE===`ant`&&(0,J.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,J.jsx)(i,{bold:!0,children:`[ANT-ONLY] System prompt sections`}),p.map((e,t)=>(0,J.jsxs)(r,{children:[(0,J.jsxs)(i,{children:[`└ `,e.name,`: `]}),(0,J.jsxs)(i,{dimColor:!0,children:[y(e.tokens),` tokens`]})]},t))]}),m.length>0&&(0,J.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,J.jsxs)(r,{children:[(0,J.jsx)(i,{bold:!0,children:`Custom agents`}),(0,J.jsx)(i,{dimColor:!0,children:` · /agents`})]}),Array.from(K(m).entries()).map(([e,t])=>(0,J.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,J.jsx)(i,{dimColor:!0,children:e}),t.map((e,t)=>(0,J.jsxs)(r,{children:[(0,J.jsxs)(i,{children:[`└ `,e.agentType,`: `]}),(0,J.jsxs)(i,{dimColor:!0,children:[y(e.tokens),` tokens`]})]},t))]},e))]}),l.length>0&&(0,J.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,J.jsxs)(r,{children:[(0,J.jsx)(i,{bold:!0,children:`Memory files`}),(0,J.jsx)(i,{dimColor:!0,children:` · /memory`})]}),l.map((e,t)=>(0,J.jsxs)(r,{children:[(0,J.jsxs)(i,{children:[`└ `,g(e.path),`: `]}),(0,J.jsxs)(i,{dimColor:!0,children:[y(e.tokens),` tokens`]})]},t))]}),h&&h.tokens>0&&(0,J.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,J.jsxs)(r,{children:[(0,J.jsx)(i,{bold:!0,children:`Skills`}),(0,J.jsx)(i,{dimColor:!0,children:` · /skills`})]}),Array.from(K(h.skillFrontmatter).entries()).map(([e,t])=>(0,J.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,J.jsx)(i,{dimColor:!0,children:e}),t.map((e,t)=>(0,J.jsxs)(r,{children:[(0,J.jsxs)(i,{children:[`└ `,e.name,`: `]}),(0,J.jsxs)(i,{dimColor:!0,children:[y(e.tokens),` tokens`]})]},t))]},e))]}),_&&process.env.USER_TYPE===`ant`&&(0,J.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,J.jsx)(i,{bold:!0,children:`[ANT-ONLY] Message breakdown`}),(0,J.jsxs)(r,{flexDirection:`column`,marginLeft:1,children:[(0,J.jsxs)(r,{children:[(0,J.jsx)(i,{children:`Tool calls: `}),(0,J.jsxs)(i,{dimColor:!0,children:[y(_.toolCallTokens),` tokens`]})]}),(0,J.jsxs)(r,{children:[(0,J.jsx)(i,{children:`Tool results: `}),(0,J.jsxs)(i,{dimColor:!0,children:[y(_.toolResultTokens),` tokens`]})]}),(0,J.jsxs)(r,{children:[(0,J.jsx)(i,{children:`Attachments: `}),(0,J.jsxs)(i,{dimColor:!0,children:[y(_.attachmentTokens),` tokens`]})]}),(0,J.jsxs)(r,{children:[(0,J.jsx)(i,{children:`Assistant messages (non-tool): `}),(0,J.jsxs)(i,{dimColor:!0,children:[y(_.assistantMessageTokens),` tokens`]})]}),(0,J.jsxs)(r,{children:[(0,J.jsx)(i,{children:`User messages (non-tool-result): `}),(0,J.jsxs)(i,{dimColor:!0,children:[y(_.userMessageTokens),` tokens`]})]})]}),_.toolCallsByType.length>0&&(0,J.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,J.jsx)(i,{bold:!0,children:`[ANT-ONLY] Top tools`}),_.toolCallsByType.slice(0,5).map((e,t)=>(0,J.jsxs)(r,{marginLeft:1,children:[(0,J.jsxs)(i,{children:[`└ `,e.name,`: `]}),(0,J.jsxs)(i,{dimColor:!0,children:[`calls `,y(e.callTokens),`, results `,y(e.resultTokens)]})]},t))]}),_.attachmentsByType.length>0&&(0,J.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,J.jsx)(i,{bold:!0,children:`[ANT-ONLY] Top attachments`}),_.attachmentsByType.slice(0,5).map((e,t)=>(0,J.jsxs)(r,{marginLeft:1,children:[(0,J.jsxs)(i,{children:[`└ `,e.name,`: `]}),(0,J.jsxs)(i,{dimColor:!0,children:[y(e.tokens),` tokens`]})]},t))]})]})]}),(0,J.jsx)(H,{suggestions:O(e)})]})}var J,Y,X,Z=e((()=>{a(),s(),V(),h(),b(),_(),W(),J=c(),Y=`Autocompact buffer`,X=[`Project`,`User`,`Managed`,`Plugin`,`Built-in`]}));function Q(e){return u(e)}async function te(e,t){let{messages:n,getAppState:r,options:{mainLoopModel:i,tools:a}}=t,o=Q(n),{messages:s}=await f(o),c=process.stdout.columns||80,l=r();return e(await E((0,$.jsx)(q,{data:await p(s,i,async()=>l.toolPermissionContext,a,l.agentDefinitions,c,t,void 0,o)}))),null}var $;e((()=>{a(),Z(),l(),d(),m(),D(),$=c()}))();export{te as call};
@@ -0,0 +1 @@
1
+ import{n as e,t}from"./conversation-fOFTa7k5.js";e();export{t as clearConversation};
@@ -0,0 +1 @@
1
+ import{a as e,n as t}from"./rolldown-runtime-DaDcL9Zw.js";import{$t as n,In as r,K as i,Nn as a,Pn as o,ln as s,sn as c,tt as l}from"./state-C2OSZkV1.js";import{$s as u,Ci as d,Ct as f,Cy as p,ED as m,Ei as h,Et as g,IT as _,Mn as v,Mv as y,Ty as b,UT as x,Zt as S,_g as C,by as w,dn as T,dr as E,ec as D,fi as O,jn as k,jr as A,jv as j,kn as M,nr as N,vg as P,wD as F,yn as I,yy as L}from"./loadAgentsDir-ByO8eJqU.js";import{o as R,s as z}from"./log-CZ0zYP_c.js";import{n as B,r as V}from"./analytics-CkYUHW_U.js";import{C as H,D as U}from"./sessionState-CjNY991n.js";import{n as W,t as G}from"./caches-Cg-HtWKG.js";import{n as K,t as q}from"./replBridgeHandle-CNwNIijW.js";import{randomUUID as J}from"crypto";function Y(){let e=q();if(!e)return;e.markTranscriptReset?.();let t={type:`status`,subtype:`status`,status:`conversation_cleared`,message:`conversation_cleared`,uuid:J()};e.writeSdkMessages([t])}async function X({setMessages:t,readFileState:n,discoveredSkillNames:u,loadedNestedMemoryPaths:m,getAppState:g,setAppState:v,setConversationId:b}){let x=T();await S(`clear`,{getAppState:g,setAppState:v,signal:AbortSignal.timeout(x),timeoutMs:x});let C=i();C&&V(`tengu_cache_eviction_hint`,{scope:`conversation_clear`,last_request_id:C});let j=new Set,I=[],L=e=>`isBackgrounded`in e&&e.isBackgrounded===!1;if(g)for(let e of Object.values(g().tasks))L(e)||D(e)&&(j.add(e.agentId),I.push(e));t(()=>[]),Y();{let{setContextBlocked:t}=(H(),e(U));t(!1)}b&&b(J()),G(j),a(null),o(null),r(null),s(),y(l()),n.clear(),u?.clear(),m?.clear(),v&&v(e=>{let t={};for(let[n,r]of Object.entries(e.tasks)){if(!L(r)){t[n]=r;continue}try{r.status===`running`&&(w(r)&&(r.shellCommand?.kill(),r.shellCommand?.cleanup(),r.cleanupTimeoutId&&clearTimeout(r.cleanupTimeoutId)),`abortController`in r&&r.abortController?.abort(),`unregisterCleanup`in r&&r.unregisterCleanup?.())}catch(e){z(e)}M(n)}return{...e,tasks:t,attribution:F(),standaloneAgentContext:void 0,fileHistory:{snapshots:[],trackedFiles:new Set,snapshotSequence:0},mcp:{clients:[],tools:[],commands:[],resources:{},pluginReconnectKey:e.mcp.pluginReconnectKey}}}),_(),N(),c({setCurrentAsParent:!0}),await O();for(let e of I)e.status===`running`&&k(e.id,E(p(e.agentId)));let{saveMode:R}=(A(),e(h));R(`normal`);let B=f();B&&d(B);let W=await P(`clear`);W.length>0&&t(()=>W)}var Z=t((()=>{K(),n(),B(),u(),L(),b(),m(),I(),R(),x(),j(),C(),A(),v(),g(),W()}));export{Z as n,X as t};
@@ -1,4 +1,4 @@
1
- import{n as e,t}from"./defineProperty-C-QyHrDq.js";import{C as n,S as r,a as i,l as a,w as o}from"./debug-BrXObCdR.js";import{l as s,u as c}from"./oauth-BqJqV-2M.js";import{Bt as l,Ot as u}from"./model-CKkOnnnx.js";import{i as d,t as f}from"./cliLaunch-BkPAatcs.js";import{resolve as p}from"path";import{existsSync as m,unlinkSync as h}from"fs";import{randomUUID as g}from"crypto";i(),r(),e();function _(e){return typeof e==`object`&&!!e&&`type`in e&&typeof e.type==`string`}var v=2e3,y=15e3,b=3,x=class{constructor(e,n){t(this,`proc`,void 0),t(this,`options`,void 0),t(this,`connected`,!1),t(this,`disconnected`,!1),t(this,`readLoopAbort`,null),t(this,`reconnectAttempt`,0),t(this,`maxReconnectAttempts`,void 0),t(this,`userInitiatedDisconnect`,!1),t(this,`reconnecting`,!1),this.proc=e,this.options=n,this.maxReconnectAttempts=n.maxReconnectAttempts??b}connect(){this.connected||(this.readLoopAbort=new AbortController,this.startReadLoop(),this.monitorExit(),this.connected=!0,this.options.onConnected())}async startReadLoop(){let e=this.proc.stdout;if(!e){this.options.onError(Error(`SSH process stdout is not available`));return}let t=e.getReader(),n=new TextDecoder,r=``;try{for(;!this.disconnected;){let{done:e,value:i}=await t.read();if(e)break;r+=n.decode(i,{stream:!0});let a=r.split(`
1
+ import{n as e,t}from"./defineProperty-C-QyHrDq.js";import{C as n,S as r,a as i,l as a,w as o}from"./debug-RZ4NuXyS.js";import{l as s,u as c}from"./oauth-BqJqV-2M.js";import{Bt as l,Ot as u}from"./model-CwO-g1RW.js";import{i as d,t as f}from"./cliLaunch-CQjLYRzM.js";import{resolve as p}from"path";import{existsSync as m,unlinkSync as h}from"fs";import{randomUUID as g}from"crypto";i(),r(),e();function _(e){return typeof e==`object`&&!!e&&`type`in e&&typeof e.type==`string`}var v=2e3,y=15e3,b=3,x=class{constructor(e,n){t(this,`proc`,void 0),t(this,`options`,void 0),t(this,`connected`,!1),t(this,`disconnected`,!1),t(this,`readLoopAbort`,null),t(this,`reconnectAttempt`,0),t(this,`maxReconnectAttempts`,void 0),t(this,`userInitiatedDisconnect`,!1),t(this,`reconnecting`,!1),this.proc=e,this.options=n,this.maxReconnectAttempts=n.maxReconnectAttempts??b}connect(){this.connected||(this.readLoopAbort=new AbortController,this.startReadLoop(),this.monitorExit(),this.connected=!0,this.options.onConnected())}async startReadLoop(){let e=this.proc.stdout;if(!e){this.options.onError(Error(`SSH process stdout is not available`));return}let t=e.getReader(),n=new TextDecoder,r=``;try{for(;!this.disconnected;){let{done:e,value:i}=await t.read();if(e)break;r+=n.decode(i,{stream:!0});let a=r.split(`
2
2
  `);r=a.pop()??``;for(let e of a){let t=e.trim();t&&this.processLine(t)}}}catch(e){this.disconnected||this.options.onError(e instanceof Error?e:Error(String(e)))}finally{t.releaseLock(),!this.disconnected&&!this.userInitiatedDisconnect&&this.handleProcessExit()}}monitorExit(){if(this.proc.exitCode!==null){this.userInitiatedDisconnect||this.handleProcessExit();return}this.proc.exited.then(()=>{!this.disconnected&&!this.userInitiatedDisconnect&&this.handleProcessExit()}).catch(()=>{!this.disconnected&&!this.userInitiatedDisconnect&&this.handleProcessExit()})}async handleProcessExit(){if(!(this.disconnected||this.reconnecting)){if(this.connected=!1,!this.options.reconnect){this.disconnected=!0,this.options.onDisconnected();return}if(this.reconnectAttempt>=this.maxReconnectAttempts){this.disconnected=!0,this.options.onDisconnected();return}this.reconnecting=!0;try{await this.attemptReconnect()}finally{this.reconnecting=!1}}}async attemptReconnect(){let e=this.options.reconnect;for(;this.reconnectAttempt<this.maxReconnectAttempts;){this.reconnectAttempt++,this.options.onReconnecting(this.reconnectAttempt,this.maxReconnectAttempts);let t=Math.min(v*2**(this.reconnectAttempt-1),y);if(await new Promise(e=>setTimeout(e,t)),this.userInitiatedDisconnect)return;try{let t=await e();this.proc=t,this.reconnectAttempt=0,this.connected=!0,this.startReadLoop(),this.monitorExit(),this.options.onConnected();return}catch(e){a(`[SSH] reconnect attempt ${this.reconnectAttempt} failed: ${e instanceof Error?e.message:String(e)}`)}}this.disconnected=!0,this.options.onDisconnected()}processLine(e){let t;try{t=n(e)}catch{return}if(!_(t))return;let r=t;if(r.type===`control_request`){let e=r;e.request.subtype===`can_use_tool`?this.options.onPermissionRequest(e.request,e.request_id):(a(`[SSH] Unsupported control request subtype: ${e.request.subtype}`),this.sendErrorResponse(e.request_id,`Unsupported control request subtype: ${e.request.subtype}`));return}r.type!==`control_response`&&r.type!==`keep_alive`&&r.type!==`control_cancel_request`&&r.type!==`streamlined_text`&&r.type!==`streamlined_tool_use_summary`&&!(r.type===`system`&&r.subtype===`post_turn_summary`)&&this.options.onMessage(r)}writeToStdin(e){try{let t=this.proc.stdin;if(!t||typeof t==`number`||this.disconnected)return!1;let n=new TextEncoder().encode(e+`
3
3
  `);return t.write(n),t.flush?.(),!0}catch{return!1}}async sendMessage(e){let t=o({type:`user`,message:{role:`user`,content:e},parent_tool_use_id:null,session_id:``});return this.writeToStdin(t)}sendInterrupt(){let e=o({type:`control_request`,request_id:crypto.randomUUID(),request:{subtype:`interrupt`}});this.writeToStdin(e)}respondToPermissionRequest(e,t){let n=o({type:`control_response`,response:{subtype:`success`,request_id:e,response:{behavior:t.behavior,...t.behavior===`allow`?{updatedInput:t.updatedInput}:{message:t.message}}}});this.writeToStdin(n)}sendErrorResponse(e,t){let n=o({type:`control_response`,response:{subtype:`error`,request_id:e,error:t}});this.writeToStdin(n)}disconnect(){if(!this.disconnected){this.userInitiatedDisconnect=!0,this.disconnected=!0,this.connected=!1,this.readLoopAbort?.abort();try{let e=this.proc.stdin;e&&typeof e!=`number`&&e.end?.()}catch{}try{this.proc.kill()}catch{}}}isConnected(){return this.connected&&!this.disconnected}};l(),c(),i();var S=process.platform===`win32`;function C(){let e=process.env.ANTHROPIC_API_KEY;if(e)return{"x-api-key":e};let t=u();return t?.accessToken?{Authorization:`Bearer ${t.accessToken}`}:{}}function w(){return process.env.ANTHROPIC_BASE_URL||s().BASE_API_URL}async function T(e,t){if(t&&e.headers.get(`x-auth-nonce`)!==t)return new Response(`Forbidden`,{status:403});let n=w(),r=new URL(e.url),i=`${n}${r.pathname}${r.search}`,o=C();if(Object.keys(o).length===0)return new Response(JSON.stringify({error:`No API credentials available on local machine`}),{status:401,headers:{"content-type":`application/json`}});let s=new Headers(e.headers);for(let[e,t]of Object.entries(o))s.set(e,t);s.delete(`host`),s.delete(`x-auth-nonce`),a(`[SSHAuthProxy] ${e.method} ${r.pathname} -> ${i}`);try{let t=await fetch(i,{method:e.method,headers:s,body:e.body,duplex:`half`}),n=new Headers(t.headers);return n.delete(`content-encoding`),n.delete(`content-length`),new Response(t.body,{status:t.status,statusText:t.statusText,headers:n})}catch(e){let t=e instanceof Error?e.message:String(e);return a(`[SSHAuthProxy] upstream error: ${t}`),new Response(JSON.stringify({error:`Proxy upstream error: ${t}`}),{status:502,headers:{"content-type":`application/json`}})}}async function E(){let e=g();return S?O(e):D(e)}async function D(e){let t=`/tmp/claude-ssh-auth-${e}.sock`,n=Bun.serve({unix:t,fetch:e=>T(e,null)});return a(`[SSHAuthProxy] listening on unix:${t}`),{proxy:{stop(){n.stop(!0);try{h(t)}catch{}}},localAddress:t,authEnv:{ANTHROPIC_AUTH_SOCKET:t}}}async function O(e){let t=g(),n=Bun.serve({port:0,hostname:`127.0.0.1`,fetch:e=>T(e,t)}),r=n.port;return a(`[SSHAuthProxy] listening on TCP 127.0.0.1:${r} (nonce-protected)`),{proxy:{stop(){n.stop(!0)}},localAddress:`127.0.0.1:${r}`,authEnv:{ANTHROPIC_BASE_URL:`http://127.0.0.1:${r}`,ANTHROPIC_AUTH_NONCE:t}}}i();var k=15e3,A=class extends Error{constructor(e){super(e),this.name=`SSHProbeError`}};async function j(e,t){t?.(`Probing remote host…`);let n=Bun.spawn([`ssh`,`-o`,`BatchMode=yes`,`-o`,`ConnectTimeout=10`,e,`CLAUDE_BIN=$(test -x "$HOME/.local/bin/claude" && echo "$HOME/.local/bin/claude" || command -v claude 2>/dev/null); echo "$CLAUDE_BIN"; $CLAUDE_BIN --version 2>/dev/null; uname -sm; pwd`],{stdin:`ignore`,stdout:`pipe`,stderr:`pipe`}),r=await Promise.race([n.exited,new Promise((e,t)=>setTimeout(()=>t(new A(`SSH probe timed out after ${k/1e3}s`)),k))]),i=await new Response(n.stdout).text(),o=await new Response(n.stderr).text();if(r!==0)throw new A(`SSH probe failed: ${o.trim()||`exit code ${r}`}`);let s=i.split(`
4
4
  `).map(e=>e.trim()).filter(Boolean);a(`[SSHProbe] raw lines: ${JSON.stringify(s)}`);let c=s.findIndex(e=>/^(Linux|Darwin)\s/.test(e));if(c===-1)throw new A(`Could not detect remote platform (uname output missing)`);let l=c>=2&&s[c-2]||null,u=c>=1&&s[c-1]||null,d=u&&/^\d+\.\d+/.test(u)?u:null,f=l!==null&&l.startsWith(`/`),p=s[c+1]||`/`,[m,h]=s[c].split(/\s+/),g=m===`Darwin`?`darwin`:`linux`,_=h===`aarch64`||h===`arm64`?`arm64`:`x64`;return t?.(`Detected ${g}/${_}`),{hasBinary:f&&d!==null,remoteVersion:d,remotePlatform:g,remoteArch:_,defaultCwd:p,binaryPath:f?l:null}}i();var M=6e4,N=`~/.local/bin`,P=`claude-code-cli.js`,F=`claude`;async function I(e,t,n=M){let r=Bun.spawn([`ssh`,`-o`,`ConnectTimeout=10`,e,t],{stdout:`pipe`,stderr:`pipe`}),i=setTimeout(()=>r.kill(),n);try{let[e,t]=await Promise.all([new Response(r.stdout).text(),new Response(r.stderr).text()]),n=await r.exited;return{stdout:e.trim(),stderr:t.trim(),exitCode:n}}finally{clearTimeout(i)}}function L(){let e=p(import.meta.dir,`../..`),t=p(e,`dist/cli.js`);if(m(t))return t;let n=p(e,`src/entrypoints/cli.tsx`);if(m(n))return n;throw Error("Cannot find local CLI binary to deploy. Run `bun run build` first.")}async function R(e){let{host:t,remotePlatform:n,remoteArch:r,localVersion:i,onProgress:o}=e;if(n!==`linux`&&n!==`darwin`)throw Error(`Remote platform "${n}" is not supported. Only linux and darwin are supported.`);a(`[SSHDeploy] deploying to ${t} (${n}/${r}, v${i})`);let s=L();a(`[SSHDeploy] local binary: ${s}`),o?.(`Creating remote directory...`);let c=await I(t,`mkdir -p ${N}`);if(c.exitCode!==0)throw Error(`Failed to create remote directory: ${c.stderr}`);o?.(`Uploading binary...`);let l=`${N}/${P}`,u=Bun.spawn([`scp`,`-o`,`ConnectTimeout=10`,s,`${t}:${l}`],{stdout:`pipe`,stderr:`pipe`}),d=setTimeout(()=>u.kill(),M),f=await new Response(u.stderr).text(),p=await u.exited;if(clearTimeout(d),p!==0)throw Error(`SCP upload failed (exit ${p}): ${f.trim()}`);o?.(`Installing wrapper script...`);let m=await I(t,[`cat > ${N}/${F} << 'WRAPPER'`,`#!/bin/sh`,`exec bun ${N}/${P} "$@"`,`WRAPPER`,`chmod +x ${N}/${F}`].join(`