@readmagic/workmate 0.0.9 → 0.0.11

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 (445) hide show
  1. package/dist/chunks/{AddWorkspaceDirectory-qFZy3FOD.js → AddWorkspaceDirectory-ag2JTpmU.js} +1 -1
  2. package/dist/chunks/{App-DW4elk6E.js → App-BuKmqFPm.js} +1 -1
  3. package/dist/chunks/ApproveApiKey-CIWOi_7v.js +1 -0
  4. package/dist/chunks/ApproveApiKey-M6U-NafA.js +1 -0
  5. package/dist/chunks/BackgroundTasksDialog-Pnpl3Ixx.js +2 -0
  6. package/dist/chunks/{BypassPermissionsModeDialog-BuRFF1fQ.js → BypassPermissionsModeDialog-B05t83wa.js} +1 -1
  7. package/dist/chunks/{ClaudeMdExternalIncludesDialog-CDrArsSX.js → ClaudeMdExternalIncludesDialog-CSywJdVL.js} +1 -1
  8. package/dist/chunks/ClaudeMdExternalIncludesDialog-D-w166RC.js +1 -0
  9. package/dist/chunks/ConsoleOAuthFlow-CV6PcJOP.js +1 -0
  10. package/dist/chunks/{DiffDialog-BIcwpgSr.js → DiffDialog-DUbFrzKu.js} +3 -3
  11. package/dist/chunks/Doctor-BcnUfJ4I.js +1 -0
  12. package/dist/chunks/Doctor-Dz4TuYas.js +3 -0
  13. package/dist/chunks/ExitFlow-BwyAtIHx.js +2 -0
  14. package/dist/chunks/{Grove-BmirUB6V.js → Grove-BDoVj02t.js} +2 -2
  15. package/dist/chunks/{HybridTransport-BVmSUHf0.js → HybridTransport-C_U0IJfz.js} +4 -4
  16. package/dist/chunks/{InvalidConfigDialog-WRywkKeS.js → InvalidConfigDialog-bih293Xt.js} +1 -1
  17. package/dist/chunks/{InvalidSettingsDialog-C4n3A72C.js → InvalidSettingsDialog-Br8kQOHz.js} +1 -1
  18. package/dist/chunks/MCPConnectionManager-B9n4SXN4.js +1 -0
  19. package/dist/chunks/MCPToolListView-DJ06N1DG.js +1 -0
  20. package/dist/chunks/{McpParsingWarnings-CH4yyMAL.js → McpParsingWarnings-COa71S9q.js} +1 -1
  21. package/dist/chunks/MessageSelector-o4ULADFg.js +3 -0
  22. package/dist/chunks/Messages-qqwHuAW5.js +11 -0
  23. package/dist/chunks/{Onboarding-BboWs1pp.js → Onboarding-BzuQjney.js} +1 -1
  24. package/dist/chunks/{PromptInputFooterSuggestions-BpC9COmh.js → PromptInputFooterSuggestions-to5eYBvI.js} +1 -1
  25. package/dist/chunks/PromptInputHelpMenu-CfMFx-TF.js +1 -0
  26. package/dist/chunks/QueryEngine-Dt0BKUeF.js +1 -0
  27. package/dist/chunks/REPL-CUbEDqEl.js +133 -0
  28. package/dist/chunks/REPL-DMaKNhTa.js +1 -0
  29. package/dist/chunks/RemoteSessionManager-Bf44A0Ol.js +2 -0
  30. package/dist/chunks/ResumeConversation-Ctw5Q1g9.js +1 -0
  31. package/dist/chunks/{SSETransport-1KBBUikF.js → SSETransport-DN4tCDEh.js} +3 -3
  32. package/dist/chunks/SearchExtraToolsTool-C80OdtPZ.js +1 -0
  33. package/dist/chunks/Settings-DfdcmvOV.js +2 -0
  34. package/dist/chunks/{TeleportProgress-BmgPAZAi.js → TeleportProgress-C2LQVLav.js} +1 -1
  35. package/dist/chunks/{TeleportRepoMismatchDialog-sgxNOeM_.js → TeleportRepoMismatchDialog-BZL8Zblz.js} +1 -1
  36. package/dist/chunks/{TeleportResumeWrapper-GptvrUdv.js → TeleportResumeWrapper-wPiIs8xg.js} +1 -1
  37. package/dist/chunks/{ThemePicker-gAMqqD1P.js → ThemePicker-BT_NaRQC.js} +1 -1
  38. package/dist/chunks/{TrustDialog-CWt-4Evl.js → TrustDialog-ACaJ_m7A.js} +1 -1
  39. package/dist/chunks/{ValidationErrorsList-De3kzHtz.js → ValidationErrorsList-C-hWdy_8.js} +1 -1
  40. package/dist/chunks/WelcomeV2-ZQRKlcT4.js +1 -0
  41. package/dist/chunks/add-dir-SAKTkw0S.js +1 -0
  42. package/dist/chunks/{agentDisplay-5gnCQwUY.js → agentDisplay-CuSHqgZc.js} +1 -1
  43. package/dist/chunks/{agents-Bz1MLp4A.js → agents-CMC0iQP4.js} +1 -1
  44. package/dist/chunks/agents-ZgRKpjHv.js +103 -0
  45. package/dist/chunks/allErrors-_cOQksHC.js +1 -0
  46. package/dist/chunks/{api-DzccRM_z.js → api-BbJfMXRS.js} +1 -1
  47. package/dist/chunks/api-DS1MiW01.js +1 -0
  48. package/dist/chunks/{auth-Cjnyy10u.js → auth-7mJGtlZp.js} +2 -2
  49. package/dist/chunks/auth-DGZzCbU0.js +1 -0
  50. package/dist/chunks/auth-DN1MUpB8.js +1 -0
  51. package/dist/chunks/{autoMode-CQ5nqP9c.js → autoMode-CBtY7ACs.js} +6 -6
  52. package/dist/chunks/autonomy-DuQmYhq6.js +15 -0
  53. package/dist/chunks/{autonomy-CPUCe-YU.js → autonomy-lJV7yWUl.js} +1 -1
  54. package/dist/chunks/autonomyPanel-DAQm6lDz.js +1 -0
  55. package/dist/chunks/backgroundHousekeeping-BTy71bcY.js +1 -0
  56. package/dist/chunks/backgroundHousekeeping-Cc7Ag7JG.js +17 -0
  57. package/dist/chunks/{banner-BJZNMppT.js → banner-1Wyeyawe.js} +1 -1
  58. package/dist/chunks/{bg-w3Vlsm3Y.js → bg-CJ0YWFli.js} +2 -2
  59. package/dist/chunks/bg-CeUrRz_7.js +1 -0
  60. package/dist/chunks/branch-k3kirqbA.js +3 -0
  61. package/dist/chunks/{break-cache-DXV0brco.js → break-cache-CAoZ9b72.js} +2 -2
  62. package/dist/chunks/bridgeConfig-CzRUPn-D.js +1 -0
  63. package/dist/chunks/{bridgeConfig-vORehbGG.js → bridgeConfig-UgaUfuP6.js} +1 -1
  64. package/dist/chunks/bridgeMessaging-Ci5H68MX.js +1 -0
  65. package/dist/chunks/{bridgePointer-D4W9GpWw.js → bridgePointer-BL8-lGvN.js} +1 -1
  66. package/dist/chunks/bridgeStatusUtil-C36w15ge.js +1 -0
  67. package/dist/chunks/{btw-DDUC_t0w.js → btw-nVoVuIae.js} +1 -1
  68. package/dist/chunks/caches-B8sM3Zys.js +1 -0
  69. package/dist/chunks/caches-Bp9MZ7IE.js +1 -0
  70. package/dist/chunks/{capacityWake-L7b1mMft.js → capacityWake-BOySRJUJ.js} +1 -1
  71. package/dist/chunks/ccrClient-Br4LAofR.js +1 -0
  72. package/dist/chunks/{claudeDesktop-CAmnheYx.js → claudeDesktop-Bgds1-YT.js} +1 -1
  73. package/dist/chunks/{clear-DdWexxbM.js → clear-C4Vtnbye.js} +1 -1
  74. package/dist/chunks/{cliLaunch-BWWOgBFh.js → cliLaunch-BTpfAGGI.js} +1 -1
  75. package/dist/chunks/{client-CoXtVRzi.js → client-B9404qIP.js} +1 -1
  76. package/dist/chunks/client-BCAbKdNz.js +1 -0
  77. package/dist/chunks/client-CJE6gEvU.js +1 -0
  78. package/dist/chunks/commands-DL-BzoMQ.js +1 -0
  79. package/dist/chunks/compact-Cx7BPXLU.js +2 -0
  80. package/dist/chunks/config-S5OW4Xqr.js +1 -0
  81. package/dist/chunks/config-aRiTrtCv.js +3 -0
  82. package/dist/chunks/{config-CVvUNkj2.js → config-kB2eazPX.js} +1 -1
  83. package/dist/chunks/{context-BWcfhhDj.js → context-BN7DEjoH.js} +1 -1
  84. package/dist/chunks/{context-noninteractive-c7jGVWHQ.js → context-noninteractive-D91W2B8e.js} +5 -5
  85. package/dist/chunks/context-noninteractive-DPacEFJ1.js +1 -0
  86. package/dist/chunks/conversation-D5Nbu9eT.js +1 -0
  87. package/dist/chunks/conversation-hcUx9e-C.js +1 -0
  88. package/dist/chunks/{createSSHSession-DP7B8yvb.js → createSSHSession-DecOR6M5.js} +6 -6
  89. package/dist/chunks/createSession-D27zvmOs.js +1 -0
  90. package/dist/chunks/createSession-DRqkLZWt.js +1 -0
  91. package/dist/chunks/crossProjectResume-Bw3U0Ty6.js +40 -0
  92. package/dist/chunks/cwd-Cfdf7z7s.js +1 -0
  93. package/dist/chunks/cwd-ClLru_7T.js +1 -0
  94. package/dist/chunks/datadog-bm551AVV.js +1 -0
  95. package/dist/chunks/debug-BecbSVoN.js +39 -0
  96. package/dist/chunks/{debugUtils-CezNYZ-4.js → debugUtils-CmJfIUxW.js} +1 -1
  97. package/dist/chunks/{detached-CkPpYMJj.js → detached-CIyF0M5O.js} +1 -1
  98. package/dist/chunks/detectRepository-C15umvKN.js +1 -0
  99. package/dist/chunks/detectRepository-DDfLfKcM.js +1 -0
  100. package/dist/chunks/{diff-DHzz9WAp.js → diff-DeK4bwjw.js} +1 -1
  101. package/dist/chunks/{directoryCompletion-D5AvL7TF.js → directoryCompletion-BJCu19HJ.js} +1 -1
  102. package/dist/chunks/doctor-BJORBomU.js +1 -0
  103. package/dist/chunks/earlyInput-BEjRkAtH.js +1 -0
  104. package/dist/chunks/{earlyInput-BTC_Wucv.js → earlyInput-IghoCjG5.js} +1 -1
  105. package/dist/chunks/entry-mdegyj8z.js +14 -0
  106. package/dist/chunks/esm-Ka3lhafK.js +1 -0
  107. package/dist/chunks/{execFileNoThrow-5SylUnAI.js → execFileNoThrow-DHyW8FMX.js} +2 -2
  108. package/dist/chunks/execSyncWrapper-CDzB0BM1.js +1 -0
  109. package/dist/chunks/exit-CF3KBl-S.js +1 -0
  110. package/dist/chunks/{extraUsage-Dt5mw35U.js → extraUsage-BrKbpBK-.js} +1 -1
  111. package/dist/chunks/extractMemories-4lBn134y.js +1 -0
  112. package/dist/chunks/fast-0Vi354KI.js +1 -0
  113. package/dist/chunks/{fast-ClYQcEv5.js → fast-DWn40OcQ.js} +1 -1
  114. package/dist/chunks/featureCheck-D6FjD-nt.js +1 -0
  115. package/dist/chunks/featureCheck-JOur3pHb.js +1 -0
  116. package/dist/chunks/{fileSuggestions-fNxREjpe.js → fileSuggestions-C7Pwq2yj.js} +3 -3
  117. package/dist/chunks/firstPartyEventLogger-BHjBQH0J.js +5 -0
  118. package/dist/chunks/firstPartyEventLogger-BNBnLYPK.js +1 -0
  119. package/dist/chunks/flushGate-DdJjxCes.js +1 -0
  120. package/dist/chunks/{gemini-fZ0VPU2A.js → gemini-DHv2iVfy.js} +1 -1
  121. package/dist/chunks/generateSessionName-DhS_6oHd.js +1 -0
  122. package/dist/chunks/{genericProcessUtils-BmDSLcMf.js → genericProcessUtils-B2HcDYhg.js} +1 -1
  123. package/dist/chunks/git-DBlOv64X.js +6 -0
  124. package/dist/chunks/git-DF4RFFaT.js +1 -0
  125. package/dist/chunks/githubRepoPathMapping-CK56bUDe.js +1 -0
  126. package/dist/chunks/{goal-IasZVqKh.js → goal-BZG4gtnb.js} +3 -3
  127. package/dist/chunks/{grok-Dk3LyzMa.js → grok-BS57ZhyW.js} +1 -1
  128. package/dist/chunks/{grove-BE4fQ6tG.js → grove-_zlQ83yR.js} +2 -2
  129. package/dist/chunks/help-C_2tdXHC.js +1 -0
  130. package/dist/chunks/{hooks-BrKy5XWQ.js → hooks-C7Bn7MBe.js} +2 -2
  131. package/dist/chunks/hooks-DT80Arzc.js +1 -0
  132. package/dist/chunks/initReplBridge-NkZRcM77.js +1 -0
  133. package/dist/chunks/{install-CVGZ55wV.js → install-Du-DSVzj.js} +1 -1
  134. package/dist/chunks/{instrumentation-BmWotlxR.js → instrumentation-DMs3b82f.js} +5 -5
  135. package/dist/chunks/intl-D2kgJmX7.js +1 -0
  136. package/dist/chunks/{job-DEXxW_Zo.js → job-rbX1VZmp.js} +1 -1
  137. package/dist/chunks/jwtUtils-OzxN2zts.js +1 -0
  138. package/dist/chunks/keybindings-CwdC_8S0.js +2 -0
  139. package/dist/chunks/{launchLocalMemory-CLSSVFoj.js → launchLocalMemory-BLRCK1_o.js} +2 -2
  140. package/dist/chunks/{launchOnboarding-BkJfKviO.js → launchOnboarding-Al_X75Vz.js} +1 -1
  141. package/dist/chunks/{loadAgentsDir-CKSb56Gp.js → loadAgentsDir-BL93ulMm.js} +2197 -2332
  142. package/dist/chunks/loadAgentsDir-eVKq8efm.js +1 -0
  143. package/dist/chunks/loadPluginHooks-B0au35a4.js +1 -0
  144. package/dist/chunks/{localSearch-CPOnyi8I.js → localSearch-C5ipegd9.js} +1 -1
  145. package/dist/chunks/localSearch-CZlFfR_X.js +1 -0
  146. package/dist/chunks/log-Dauqle-Z.js +1 -0
  147. package/dist/chunks/{logoV2Utils-we1sfJvf.js → logoV2Utils-CkvOihX7.js} +1 -1
  148. package/dist/chunks/{magicDocs-DmKlTQvK.js → magicDocs-DLav5QK0.js} +3 -3
  149. package/dist/chunks/main-CVNWNAoh.js +513 -0
  150. package/dist/chunks/{main-ClXu1ilx.js → main-LMyE3jXY.js} +4 -4
  151. package/dist/chunks/managedEnv-CYepSnm8.js +1 -0
  152. package/dist/chunks/{managedEnv-Cl7YbYzf.js → managedEnv-DJSCuqCb.js} +1 -1
  153. package/dist/chunks/{mappers-xQC-Z4-h.js → mappers-DQxMcezy.js} +1 -1
  154. package/dist/chunks/mcp-BAbbEaBA.js +1 -0
  155. package/dist/chunks/mcp-Ct4Sum6A.js +6 -0
  156. package/dist/chunks/mcp-D5HkCqUh.js +2 -0
  157. package/dist/chunks/{memoize-FJv2HV1u.js → memoize-FeyE7JEh.js} +1 -1
  158. package/dist/chunks/memory-COa7aUbx.js +1 -0
  159. package/dist/chunks/{mode-lYTs0XHs.js → mode-Bl2RZC8M.js} +2 -2
  160. package/dist/chunks/model-B7rtZ7KV.js +1 -0
  161. package/dist/chunks/model-Bgh_r4lg.js +1 -0
  162. package/dist/chunks/model-DiuEAv6h.js +1 -0
  163. package/dist/chunks/{modelOptions-efCGKnXT.js → modelOptions-BtEZe5BB.js} +1 -1
  164. package/dist/chunks/nativeInstaller-BEwayifa.js +1 -0
  165. package/dist/chunks/omit--yH_T4rf.js +1 -0
  166. package/dist/chunks/onChangeAppState-ZdwI7boX.js +1 -0
  167. package/dist/chunks/{openai-DJLYqiRl.js → openai-DWs4D-nQ.js} +3 -3
  168. package/dist/chunks/panel-CoNfXy3K.js +1 -0
  169. package/dist/chunks/{parser-BdCj2GrE.js → parser-BH4u7QiV.js} +1 -1
  170. package/dist/chunks/parser-BMIaRErw.js +1 -0
  171. package/dist/chunks/partition-DLcW5Oo_.js +1 -0
  172. package/dist/chunks/permissions-CaucYK3s.js +3 -0
  173. package/dist/chunks/pidLock-DgOBc1Xo.js +3 -0
  174. package/dist/chunks/{plan-BeoIjNPv.js → plan-BNYDTnQd.js} +1 -1
  175. package/dist/chunks/{platform-D6IMiyqT.js → platform-B0uTQc9P.js} +1 -1
  176. package/dist/chunks/plugin-BN-of1_H.js +17 -0
  177. package/dist/chunks/pluginAutoupdate-BBU9Jn4p.js +1 -0
  178. package/dist/chunks/pluginBlocklist-DXQlbG0P.js +1 -0
  179. package/dist/chunks/pluginCliCommands-CfdVNs8D.js +1 -0
  180. package/dist/chunks/pluginFlagging-DcJ_FQuv.js +1 -0
  181. package/dist/chunks/pluginOperations-DnhzFbYI.js +2 -0
  182. package/dist/chunks/pluginStartupCheck-CKBFaMFr.js +1 -0
  183. package/dist/chunks/pluginStartupCheck-CpNB4jxG.js +1 -0
  184. package/dist/chunks/{plugins-pmipe7kE.js → plugins-CBW7kPyp.js} +4 -4
  185. package/dist/chunks/{poorMode-BxsyllUK.js → poorMode-B_xEvuEV.js} +1 -1
  186. package/dist/chunks/poorMode-yH1o41cQ.js +1 -0
  187. package/dist/chunks/print-BZOx09SU.js +26 -0
  188. package/dist/chunks/processBashCommand-dcCNCiBp.js +1 -0
  189. package/dist/chunks/processSlashCommand-YDiM63Qr.js +5 -0
  190. package/dist/chunks/prompt-CXGy0llt.js +1 -0
  191. package/dist/chunks/prompt-DovNDmcx.js +1 -0
  192. package/dist/chunks/{prompt-CybUvG8G.js → prompt-Dx7IWhBt.js} +34 -34
  193. package/dist/chunks/{promptEditor-0Ug93P2I.js → promptEditor-WCkmpejM.js} +2 -2
  194. package/dist/chunks/{protocolHandler-ClfbHTjI.js → protocolHandler-BiVWrpHi.js} +4 -4
  195. package/dist/chunks/{proxy-Blq4W6Ox.js → proxy-CVn7o19p.js} +3 -3
  196. package/dist/chunks/reconciler-C2Nd_e4n.js +1 -0
  197. package/dist/chunks/refresh-B84H2Ezd.js +1 -0
  198. package/dist/chunks/{registerProtocol-3_ozAuDK.js → registerProtocol-E0Iu5hEx.js} +2 -2
  199. package/dist/chunks/{reload-plugins-Dn1ibOiI.js → reload-plugins-D-3AUT9g.js} +1 -1
  200. package/dist/chunks/{remoteBridgeCore-Dpg6Se9C.js → remoteBridgeCore-CV6we3ZA.js} +1 -1
  201. package/dist/chunks/remoteManagedSettings-D26Q09-7.js +1 -0
  202. package/dist/chunks/rename-CSavuBIE.js +1 -0
  203. package/dist/chunks/{renderOptions-CLcco6fc.js → renderOptions-DDLbSMQU.js} +1 -1
  204. package/dist/chunks/resume-CROylN3J.js +2 -0
  205. package/dist/chunks/ripgrep-2M1GkXqJ.js +1 -0
  206. package/dist/chunks/{ripgrep-DkL2S7-I.js → ripgrep-C1ydIMzT.js} +5 -5
  207. package/dist/chunks/{runtimeObserver-DonWCJOx.js → runtimeObserver-L7pSIWBT.js} +4 -4
  208. package/dist/chunks/{runtimeObserver-B0xfyLiA.js → runtimeObserver-OU8KrZQG.js} +1 -1
  209. package/dist/chunks/sandbox-adapter-6UwMLh6e.js +1 -0
  210. package/dist/chunks/{sandbox-toggle-CSdnHWp-.js → sandbox-toggle-YrQNWGsr.js} +1 -1
  211. package/dist/chunks/searchExtraTools-Bdv5HJ74.js +1 -0
  212. package/dist/chunks/{session-BbQlh2S5.js → session-DUYsfPy_.js} +2 -2
  213. package/dist/chunks/sessionFileAccessHooks-Czen7Ejz.js +1 -0
  214. package/dist/chunks/sessionObserver-B0zucj_c.js +1 -0
  215. package/dist/chunks/{sessionObserver-XV6N0XER.js → sessionObserver-Dv3Ba8eA.js} +2 -2
  216. package/dist/chunks/sessionState-D-SaBzWD.js +11 -0
  217. package/dist/chunks/sessionStorage-BM1x51Z7.js +1 -0
  218. package/dist/chunks/{sessionTitle-E1FvsKM9.js → sessionTitle-uCuYaNif.js} +2 -2
  219. package/dist/chunks/{sessionTracing-ClGQ08jM.js → sessionTracing-Bqb3vJTt.js} +3 -3
  220. package/dist/chunks/settings-BG15IFYx.js +1 -0
  221. package/dist/chunks/settings-D4CpDv2y.js +20 -0
  222. package/dist/chunks/settingsSync-BSrpnyqo.js +1 -0
  223. package/dist/chunks/setup-C62oq4AZ.js +3 -0
  224. package/dist/chunks/{shadowedRuleDetection-B9iSx6mB.js → shadowedRuleDetection-BzAZ57p2.js} +1 -1
  225. package/dist/chunks/{shellQuote-Bth6IZgX.js → shellQuote-DS6WrivY.js} +2 -2
  226. package/dist/chunks/{sideQuestion-D2dPToW8.js → sideQuestion-CvMBBjI8.js} +3 -3
  227. package/dist/chunks/sinks-WJ7nzLQs.js +1 -0
  228. package/dist/chunks/sinks-f7qYjbKJ.js +2 -0
  229. package/dist/chunks/skillChangeDetector-U5kRU5nd.js +1 -0
  230. package/dist/chunks/{skillGapStore-DylpOKJ6.js → skillGapStore-CqaT8c0C.js} +2 -2
  231. package/dist/chunks/{skillLifecycle-GK-8eyyn.js → skillLifecycle-CnR8IqJM.js} +2 -2
  232. package/dist/chunks/skillSearchPanel-D9qrOXpI.js +21 -0
  233. package/dist/chunks/{skills-t6krW8GZ.js → skills-BgcFh0vy.js} +1 -1
  234. package/dist/chunks/startupProfiler-B4HBBbHN.js +1 -0
  235. package/dist/chunks/{startupProfiler-jeId9f2i.js → startupProfiler-CmH_aVy2.js} +3 -3
  236. package/dist/chunks/state-BemZdQIl.js +1 -0
  237. package/dist/chunks/state-D_lk6z-C.js +1 -0
  238. package/dist/chunks/{stats-BJBhl-Lc.js → stats-B8uQ-UDi.js} +1 -1
  239. package/dist/chunks/{status-BtsnKNVY.js → status-BekdWoIj.js} +1 -1
  240. package/dist/chunks/{status-nZQEar7T.js → status-D6KlRJmR.js} +2 -2
  241. package/dist/chunks/statusNoticeHelpers-BMM8_uJ1.js +1 -0
  242. package/dist/chunks/{stringUtils-CbS6OkmE.js → stringUtils-C8PaYpQF.js} +1 -1
  243. package/dist/chunks/switcher-Ck9CrXrr.js +1 -0
  244. package/dist/chunks/{switcher-77h2J5HC.js → switcher-DnAhkyIn.js} +1 -1
  245. package/dist/chunks/syncCache-ClP9aBqK.js +1 -0
  246. package/dist/chunks/{tasks-BNrdmF9p.js → tasks-Dmh6qikm.js} +1 -1
  247. package/dist/chunks/teleport-DH3IuAUQ.js +1 -0
  248. package/dist/chunks/{templateJobs-Dkv4I9c1.js → templateJobs-CxqU-s5i.js} +1 -1
  249. package/dist/chunks/{terminalSetup-DQopnSPR.js → terminalSetup-BKGcmlWp.js} +1 -1
  250. package/dist/chunks/{terminalSetup-DTGm1Eo2.js → terminalSetup-Cy19F1Js.js} +4 -4
  251. package/dist/chunks/{theme-BjpBVRf5.js → theme-U7lMFHQ0.js} +1 -1
  252. package/dist/chunks/{tmux-CMRiI6CD.js → tmux-D5EvHWi3.js} +1 -1
  253. package/dist/chunks/{toolEventObserver-D-sNBvOe.js → toolEventObserver-D9qjoVl5.js} +1 -1
  254. package/dist/chunks/toolPool-69mfSPAs.js +1 -0
  255. package/dist/chunks/trustedDevice-B6AKlsl_.js +1 -0
  256. package/dist/chunks/trustedDevice-DL0pWP4_.js +1 -0
  257. package/dist/chunks/{types-DWRxAH0E.js → types-DafcFtmb.js} +2 -2
  258. package/dist/chunks/udsClient-CWnfsgFP.js +1 -0
  259. package/dist/chunks/updateCCB-C6XftzIG.js +11 -0
  260. package/dist/chunks/{upstreamproxy-DDVMwoRi.js → upstreamproxy-CXmjxHpl.js} +2 -2
  261. package/dist/chunks/{useExitOnCtrlCDWithKeybindings-D2FvHieH.js → useExitOnCtrlCDWithKeybindings-DEEJhm_W.js} +1 -1
  262. package/dist/chunks/useMainLoopModel-6w7mhwhU.js +1 -0
  263. package/dist/chunks/useManagePlugins-CjnsO-Of.js +1 -0
  264. package/dist/chunks/{useMergedTools-B-Z9XQ6U.js → useMergedTools-DbhqKk1-.js} +1 -1
  265. package/dist/chunks/{useSearchInput-C6d6nt9S.js → useSearchInput-gUDbkLaC.js} +1 -1
  266. package/dist/chunks/useSettingsErrors-CgPad-H0.js +1 -0
  267. package/dist/chunks/{userAgent-Ng_TTjWr.js → userAgent-CU7Ndh79.js} +1 -1
  268. package/dist/chunks/util-B4oMhJKh.js +1 -0
  269. package/dist/chunks/validatePlugin-y_O_tCEL.js +1 -0
  270. package/dist/chunks/{vim-3mUqsEJm.js → vim-w37BfGZ5.js} +1 -1
  271. package/dist/chunks/{which-DznMOwny.js → which-BRWBO7Gu.js} +1 -1
  272. package/dist/chunks/windowsPaths-BY-IVNwQ.js +1 -0
  273. package/dist/chunks/windowsPaths-DtWHLjmE.js +1 -0
  274. package/dist/chunks/{workSecret-DtiFreRl.js → workSecret-BEhXgH2M.js} +1 -1
  275. package/dist/chunks/workerRegistry-Bq9bS5pw.js +6 -0
  276. package/dist/chunks/worktree-4SUJ4dtz.js +1 -0
  277. package/dist/cli.js +1 -1
  278. package/package.json +2 -3
  279. package/dist/chunks/ApproveApiKey-D05WywHU.js +0 -1
  280. package/dist/chunks/ApproveApiKey-DHAbdwkC.js +0 -1
  281. package/dist/chunks/BackgroundTasksDialog-QgFwoaaC.js +0 -2
  282. package/dist/chunks/ClaudeMdExternalIncludesDialog-DpecRCAt.js +0 -1
  283. package/dist/chunks/ConsoleOAuthFlow-D1MYL1dJ.js +0 -1
  284. package/dist/chunks/Doctor-D160J8Ad.js +0 -3
  285. package/dist/chunks/Doctor-VhJi2cmL.js +0 -1
  286. package/dist/chunks/ExitFlow-CoWHhKHJ.js +0 -2
  287. package/dist/chunks/MCPConnectionManager-DPFe4hPh.js +0 -1
  288. package/dist/chunks/MCPToolListView-BPmE0C2o.js +0 -1
  289. package/dist/chunks/MessageSelector-kOn2GaU-.js +0 -3
  290. package/dist/chunks/Messages-4EnHFeh1.js +0 -11
  291. package/dist/chunks/PromptInputHelpMenu-BvcAzbSi.js +0 -1
  292. package/dist/chunks/QueryEngine-J6ElcO16.js +0 -1
  293. package/dist/chunks/REPL-DBjbAJsm.js +0 -133
  294. package/dist/chunks/REPL-oBemMXvp.js +0 -1
  295. package/dist/chunks/RemoteSessionManager-CoIyFKKa.js +0 -2
  296. package/dist/chunks/ResumeConversation-wBG8OD9P.js +0 -1
  297. package/dist/chunks/SearchExtraToolsTool-BugrzImr.js +0 -1
  298. package/dist/chunks/Settings-DptKuJE7.js +0 -2
  299. package/dist/chunks/WelcomeV2-BWF-cJOu.js +0 -1
  300. package/dist/chunks/add-dir-DBVT1cEK.js +0 -1
  301. package/dist/chunks/agents-CnwTOlqO.js +0 -103
  302. package/dist/chunks/allErrors-DYw_q14e.js +0 -1
  303. package/dist/chunks/api-DXDXTFGa.js +0 -1
  304. package/dist/chunks/attributionTrailer-oKKrF3z8.js +0 -1
  305. package/dist/chunks/auth-CnLb6RWc.js +0 -1
  306. package/dist/chunks/auth-D-SGHS0K.js +0 -1
  307. package/dist/chunks/autonomy-dSJl0hN1.js +0 -15
  308. package/dist/chunks/autonomyPanel-Ccr9ilei.js +0 -1
  309. package/dist/chunks/backgroundHousekeeping--cs5crp7.js +0 -17
  310. package/dist/chunks/backgroundHousekeeping-CcbHitKC.js +0 -1
  311. package/dist/chunks/bg-DWloqGwk.js +0 -1
  312. package/dist/chunks/branch-CG0AKS1J.js +0 -3
  313. package/dist/chunks/bridgeConfig-Dmc1ZDev.js +0 -1
  314. package/dist/chunks/bridgeMessaging-DlczTV9X.js +0 -1
  315. package/dist/chunks/caches-1IFb6_M_.js +0 -1
  316. package/dist/chunks/caches-CB8MHqy2.js +0 -1
  317. package/dist/chunks/ccrClient-CG6HTv_n.js +0 -1
  318. package/dist/chunks/client-Crrwkw7g.js +0 -1
  319. package/dist/chunks/client-D8hKghba.js +0 -1
  320. package/dist/chunks/color-Cuq0c6xy.js +0 -1
  321. package/dist/chunks/commands-D3sESsTp.js +0 -1
  322. package/dist/chunks/compact-DIpwuBDq.js +0 -2
  323. package/dist/chunks/config-D4G8_MqJ.js +0 -3
  324. package/dist/chunks/config-q9D4hFiK.js +0 -1
  325. package/dist/chunks/context-noninteractive-Bwt9A3XD.js +0 -1
  326. package/dist/chunks/conversation-Bjo_8kia.js +0 -1
  327. package/dist/chunks/conversation-DrHZIQX2.js +0 -1
  328. package/dist/chunks/createSession-CPo6GBSb.js +0 -1
  329. package/dist/chunks/createSession-DnykRoia.js +0 -1
  330. package/dist/chunks/crossProjectResume-D2A-qjgP.js +0 -40
  331. package/dist/chunks/cwd--q1ONL7P.js +0 -1
  332. package/dist/chunks/cwd-L4wygFqJ.js +0 -1
  333. package/dist/chunks/daemon-D2vFIVOz.js +0 -2
  334. package/dist/chunks/datadog-DrmHyl3_.js +0 -1
  335. package/dist/chunks/debug-BdqxZ7rV.js +0 -39
  336. package/dist/chunks/detectRepository-DA1Q_Skc.js +0 -1
  337. package/dist/chunks/detectRepository-DvxoaPlk.js +0 -1
  338. package/dist/chunks/doctor-PWqB46xd.js +0 -1
  339. package/dist/chunks/earlyInput-xcoTbKQn.js +0 -1
  340. package/dist/chunks/entry-4JtoJONR.js +0 -14
  341. package/dist/chunks/esm-DcIr7tVd.js +0 -1
  342. package/dist/chunks/execSyncWrapper-DKuxVTaf.js +0 -1
  343. package/dist/chunks/exit-OW9g7b9A.js +0 -1
  344. package/dist/chunks/extractMemories-1VlmCGwa.js +0 -1
  345. package/dist/chunks/fast-CrvLdpy3.js +0 -1
  346. package/dist/chunks/featureCheck-CrJeuheQ.js +0 -1
  347. package/dist/chunks/featureCheck-HslM03dr.js +0 -1
  348. package/dist/chunks/firstPartyEventLogger-BBXEQUf0.js +0 -1
  349. package/dist/chunks/firstPartyEventLogger-DhEPWcit.js +0 -5
  350. package/dist/chunks/flushGate-ch-Tvwjj.js +0 -1
  351. package/dist/chunks/generateRecap-BIBVlB__.js +0 -1
  352. package/dist/chunks/generateSessionName-nZj_VvKZ.js +0 -1
  353. package/dist/chunks/git-B9uvt96d.js +0 -6
  354. package/dist/chunks/git-BfS5Hk4S.js +0 -1
  355. package/dist/chunks/githubRepoPathMapping-Cqx3pSfc.js +0 -1
  356. package/dist/chunks/help-D2-v9Ug9.js +0 -1
  357. package/dist/chunks/hooks-DGd02IKF.js +0 -1
  358. package/dist/chunks/initReplBridge-RhCAlmHE.js +0 -1
  359. package/dist/chunks/intl-cKc-V6Mq.js +0 -1
  360. package/dist/chunks/jwtUtils-C9sdGhvT.js +0 -1
  361. package/dist/chunks/keybindings-BRdSOSUD.js +0 -2
  362. package/dist/chunks/language-C0cIpKE2.js +0 -1
  363. package/dist/chunks/language-CxThoWRC.js +0 -1
  364. package/dist/chunks/loadAgentsDir-8UprzS4w.js +0 -1
  365. package/dist/chunks/loadPluginHooks-LbaURHVH.js +0 -1
  366. package/dist/chunks/localSearch-DNjbr4S9.js +0 -1
  367. package/dist/chunks/log-CTFl4qpD.js +0 -1
  368. package/dist/chunks/main-BIiwW4mM.js +0 -605
  369. package/dist/chunks/managedEnv-CpiiQx_v.js +0 -1
  370. package/dist/chunks/mcp-B_m1XBDt.js +0 -6
  371. package/dist/chunks/mcp-BiyfH9Sd.js +0 -1
  372. package/dist/chunks/mcp-BjlaPUWX.js +0 -2
  373. package/dist/chunks/memory-LN8f_p2b.js +0 -1
  374. package/dist/chunks/model-C2e73CJD.js +0 -1
  375. package/dist/chunks/model-CvmS-Esk.js +0 -1
  376. package/dist/chunks/model-DJ8mFfuR.js +0 -1
  377. package/dist/chunks/nativeInstaller-DQIFwdat.js +0 -1
  378. package/dist/chunks/omit-CLPZGevl.js +0 -1
  379. package/dist/chunks/onChangeAppState-DhBO34OK.js +0 -1
  380. package/dist/chunks/panel-q0_iT9cg.js +0 -1
  381. package/dist/chunks/panelCall-sum-3zvi.js +0 -1
  382. package/dist/chunks/parser-BcdhBGx0.js +0 -1
  383. package/dist/chunks/partition-CpfoVrg1.js +0 -1
  384. package/dist/chunks/permissions-DTb9wkAP.js +0 -3
  385. package/dist/chunks/pidLock-BR5M6RQw.js +0 -3
  386. package/dist/chunks/pipeTransport-B3TIkTAp.js +0 -1
  387. package/dist/chunks/plugin-D_dHjTud.js +0 -17
  388. package/dist/chunks/pluginAutoupdate-BHKlOOXI.js +0 -1
  389. package/dist/chunks/pluginBlocklist-D93Hd1GF.js +0 -1
  390. package/dist/chunks/pluginCliCommands-vv0wNt4O.js +0 -1
  391. package/dist/chunks/pluginFlagging-CxuRF2Vc.js +0 -1
  392. package/dist/chunks/pluginOperations-BTq4AjYB.js +0 -2
  393. package/dist/chunks/pluginStartupCheck-B6leNWq9.js +0 -1
  394. package/dist/chunks/pluginStartupCheck-DBOCHUHQ.js +0 -1
  395. package/dist/chunks/poorMode-iV1NwC5L.js +0 -1
  396. package/dist/chunks/print-CAUvczBM.js +0 -23
  397. package/dist/chunks/processBashCommand-CdeQg_c6.js +0 -1
  398. package/dist/chunks/processSlashCommand-CbkshIC6.js +0 -5
  399. package/dist/chunks/prompt-RBn4JdEg.js +0 -1
  400. package/dist/chunks/prompt-Rb8zXlDo.js +0 -1
  401. package/dist/chunks/reconciler-Drq3HSkj.js +0 -4
  402. package/dist/chunks/refresh-D8TLHO_T.js +0 -1
  403. package/dist/chunks/remoteManagedSettings-CCrq-qL-.js +0 -1
  404. package/dist/chunks/rename-CKsSc7Z3.js +0 -1
  405. package/dist/chunks/replBridgeHandle-DNC797_T.js +0 -1
  406. package/dist/chunks/resume-B1a5gLVR.js +0 -2
  407. package/dist/chunks/ripgrep-BisRODQ2.js +0 -1
  408. package/dist/chunks/sandbox-adapter-BnBOSkKJ.js +0 -1
  409. package/dist/chunks/searchExtraTools-DbgfnQkH.js +0 -1
  410. package/dist/chunks/sessionFileAccessHooks-Xfr1NiXG.js +0 -1
  411. package/dist/chunks/sessionMemory-7UOFdp29.js +0 -1
  412. package/dist/chunks/sessionMemory-fAzgAS7Q.js +0 -1
  413. package/dist/chunks/sessionMemoryUtils-DVjFw5Bd.js +0 -1
  414. package/dist/chunks/sessionObserver-Cl26OdaW.js +0 -1
  415. package/dist/chunks/sessionState-BvECKycx.js +0 -11
  416. package/dist/chunks/sessionStorage-DSj9yZkl.js +0 -1
  417. package/dist/chunks/settings-B-R9ZJNY.js +0 -1
  418. package/dist/chunks/settings-Xbq6AaD-.js +0 -20
  419. package/dist/chunks/settingsSync-NCN0a4sc.js +0 -1
  420. package/dist/chunks/setup-uZ0dSekt.js +0 -3
  421. package/dist/chunks/sinks-C7q46rvE.js +0 -2
  422. package/dist/chunks/sinks-D3bXeHlQ.js +0 -1
  423. package/dist/chunks/skillChangeDetector-C1EJ7rUL.js +0 -1
  424. package/dist/chunks/skillSearchPanel-mpaC62y4.js +0 -21
  425. package/dist/chunks/startupProfiler-BaiXZ9tr.js +0 -1
  426. package/dist/chunks/state-B4HwLt8i.js +0 -1
  427. package/dist/chunks/state-Bs5xweDL.js +0 -1
  428. package/dist/chunks/statusNoticeHelpers-DMqRGFOh.js +0 -1
  429. package/dist/chunks/switcher-B2CYzCC_.js +0 -1
  430. package/dist/chunks/syncCache-By_-buUC.js +0 -1
  431. package/dist/chunks/teleport-mdnhIZBj.js +0 -1
  432. package/dist/chunks/toolPool-Di30gn_Y.js +0 -1
  433. package/dist/chunks/trustedDevice-CupLMpO8.js +0 -1
  434. package/dist/chunks/trustedDevice-j1u2TG5U.js +0 -1
  435. package/dist/chunks/udsClient-Cm3HqYUu.js +0 -1
  436. package/dist/chunks/updateCCB-BlUAU2Vp.js +0 -11
  437. package/dist/chunks/useMainLoopModel-ylPQNj7Z.js +0 -1
  438. package/dist/chunks/useManagePlugins-BbWJNLe8.js +0 -1
  439. package/dist/chunks/useSettingsErrors-DKh4rkGi.js +0 -1
  440. package/dist/chunks/util-D-X8i5Z2.js +0 -1
  441. package/dist/chunks/validatePlugin-DSw08u76.js +0 -1
  442. package/dist/chunks/windowsPaths-1mgenSWa.js +0 -1
  443. package/dist/chunks/windowsPaths-BVztIhXM.js +0 -1
  444. package/dist/chunks/workerRegistry-DdOYjLm3.js +0 -6
  445. package/dist/chunks/worktree-BX1ULzrw.js +0 -1
@@ -0,0 +1,39 @@
1
+ import{n as e,r as t}from"./rolldown-runtime-DaDcL9Zw.js";import{n,t as r}from"./memoize-BK3gG5ob.js";import{l as i,n as a,o}from"./envUtils-BDhHQY0-.js";import{n as s,t as c}from"./defineProperty-C-QyHrDq.js";import{Wt as l,pt as u}from"./state-BemZdQIl.js";import{a as ee,n as d}from"./process-gEbdy6uY.js";import{homedir as f}from"os";import*as p from"path";import{dirname as te,join as ne,resolve as re}from"path";import*as m from"fs";import{closeSync as ie,fsyncSync as ae,openSync as oe,writeFileSync as se}from"fs";import{appendFile as ce,mkdir as le,open as ue,readFile as de,readdir as fe,rename as pe,rm as me,rmdir as he,stat as ge,symlink as _e,unlink as ve}from"fs/promises";function ye({writeFn:e,flushIntervalMs:t=1e3,maxBufferSize:n=100,maxBufferBytes:r=1/0,immediateMode:i=!1}){let a=[],o=0,s=null,c=null;function l(){s&&(clearTimeout(s),s=null)}function u(){c&&(e(c.join(``)),c=null),a.length!==0&&(e(a.join(``)),a=[],o=0,l())}function ee(){s||(s=setTimeout(u,t))}function d(){if(c){c.push(...a),a=[],o=0,l();return}let t=a;a=[],o=0,l(),c=t,setImmediate(()=>{let t=c;c=null,t&&e(t.join(``))})}return{write(t){if(i){e(t);return}a.push(t),o+=t.length,ee(),(a.length>=n||o>=r)&&d()},flush:u,dispose(){u()}}}var be=e((()=>{}));function xe(e){return Ce.add(e),()=>Ce.delete(e)}async function Se(){await Promise.all(Array.from(Ce).map(e=>e()))}var Ce,we=e((()=>{Ce=new Set}));function Te(e){let t=[],n=e.match(/^MCP server ["']([^"']+)["']/);if(n&&n[1])t.push(`mcp`),t.push(n[1].toLowerCase());else{let n=e.match(/^([^:[]+):/);n&&n[1]&&t.push(n[1].trim().toLowerCase())}let r=e.match(/^\[([^\]]+)]/);r&&r[1]&&t.push(r[1].trim().toLowerCase()),e.toLowerCase().includes(`1p event:`)&&t.push(`1p`);let i=e.match(/:\s*([^:]+?)(?:\s+(?:type|mode|status|event))?:/);if(i&&i[1]){let e=i[1].trim().toLowerCase();e.length<30&&!e.includes(` `)&&t.push(e)}return Array.from(new Set(t))}function Ee(e,t){return t?e.length===0?!1:t.isExclusive?!e.some(e=>t.exclude.includes(e)):e.some(e=>t.include.includes(e)):!0}function De(e,t){return!t||Ee(Te(e),t)}var Oe,ke=e((()=>{r(),Oe=n(e=>{if(!e||e.trim()===``)return null;let t=e.split(`,`).map(e=>e.trim()).filter(Boolean);if(t.length===0)return null;let n=t.some(e=>e.startsWith(`!`)),r=t.some(e=>!e.startsWith(`!`));if(n&&r)return null;let i=t.map(e=>e.replace(/^!/,``).toLowerCase());return{include:n?[]:i,exclude:n?i:[],isExclusive:n}})}));function h(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 g(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 _=e((()=>{})),Ae,je=e((()=>{Ae=function(){let{crypto:e}=globalThis;if(e?.randomUUID)return Ae=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 Me(e){return typeof e==`object`&&!!e&&(`name`in e&&e.name===`AbortError`||`message`in e&&String(e.message).includes(`FetchRequestCanceledException`))}var Ne,Pe=e((()=>{Ne=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)}})),v,y,b,x,Fe,Ie,Le,Re,ze,Be,Ve,He,Ue,S=e((()=>{Pe(),v=class extends Error{},y=class e extends v{constructor(t,n,r,i,a){super(`${e.makeMessage(t,n,r)}`),this.status=t,this.headers=i,this.requestID=i?.get(`request-id`),this.error=n,this.type=a??null}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 x({message:r,cause:Ne(n)});let a=n,o=a?.error?.type;return t===400?new Ie(t,a,r,i,o):t===401?new Le(t,a,r,i,o):t===403?new Re(t,a,r,i,o):t===404?new ze(t,a,r,i,o):t===409?new Be(t,a,r,i,o):t===422?new Ve(t,a,r,i,o):t===429?new He(t,a,r,i,o):t>=500?new Ue(t,a,r,i,o):new e(t,a,r,i,o)}},b=class extends y{constructor({message:e}={}){super(void 0,void 0,e||`Request was aborted.`,void 0)}},x=class extends y{constructor({message:e,cause:t}){super(void 0,void 0,e||`Connection error.`,void 0),t&&(this.cause=t)}},Fe=class extends x{constructor({message:e}={}){super({message:e??`Request timed out.`})}},Ie=class extends y{},Le=class extends y{},Re=class extends y{},ze=class extends y{},Be=class extends y{},Ve=class extends y{},He=class extends y{},Ue=class extends y{}}));function We(e){return typeof e==`object`?e??{}:{}}function Ge(e){if(!e)return!0;for(let t in e)return!1;return!0}function Ke(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var qe,Je,Ye,Xe,Ze,Qe,$e=e((()=>{S(),qe=/^[a-z][a-z0-9+.-]*:/i,Je=e=>qe.test(e),Ye=e=>(Ye=Array.isArray,Ye(e)),Xe=Ye,Ze=(e,t)=>{if(typeof t!=`number`||!Number.isInteger(t))throw new v(`${e} must be an integer`);if(t<0)throw new v(`${e} must be a positive integer`);return t},Qe=e=>{try{return JSON.parse(e)}catch{return}}})),et,tt=e((()=>{et=e=>new Promise(t=>setTimeout(t,e))})),C,nt=e((()=>{C=`0.81.0`}));function rt(){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 it(){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 at,ot,st,ct,lt,ut,dt=e((()=>{nt(),at=()=>typeof window<`u`&&window.document!==void 0&&typeof navigator<`u`,ot=()=>{let e=rt();if(e===`deno`)return{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":C,"X-Stainless-OS":ct(Deno.build.os),"X-Stainless-Arch":st(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":C,"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":C,"X-Stainless-OS":ct(globalThis.process.platform??`unknown`),"X-Stainless-Arch":st(globalThis.process.arch??`unknown`),"X-Stainless-Runtime":`node`,"X-Stainless-Runtime-Version":globalThis.process.version??`unknown`};let t=it();return t?{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":C,"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":C,"X-Stainless-OS":`Unknown`,"X-Stainless-Arch":`unknown`,"X-Stainless-Runtime":`unknown`,"X-Stainless-Runtime-Version":`unknown`}},st=e=>e===`x32`?`x32`:e===`x86_64`||e===`x64`?`x64`:e===`arm`?`arm`:e===`aarch64`||e===`arm64`?`arm64`:e?`other:${e}`:`unknown`,ct=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`),ut=()=>lt??(lt=ot())}));function ft(){if(typeof fetch<`u`)return fetch;throw Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new Anthropic({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function pt(...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 mt(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator]();return pt({start(){},async pull(e){let{done:n,value:r}=await t.next();n?e.close():e.enqueue(r)},async cancel(){await t.return?.()}})}function ht(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 gt(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 _t=e((()=>{})),vt,yt=e((()=>{vt=({headers:e,body:t})=>({bodyHeaders:{"content-type":`application/json`},body:JSON.stringify(t)})}));function bt(e){return Object.entries(e).filter(([e,t])=>t!==void 0).map(([e,t])=>{if(typeof t==`string`||typeof t==`number`||typeof t==`boolean`)return`${encodeURIComponent(e)}=${encodeURIComponent(t)}`;if(t===null)return`${encodeURIComponent(e)}=`;throw new v(`Cannot stringify type ${typeof t}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`)}).join(`&`)}var xt=e((()=>{S()}));function St(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 Ct(e){let t;return(Tt??(t=new globalThis.TextEncoder,Tt=t.encode.bind(t)))(e)}function wt(e){let t;return(Et??(t=new globalThis.TextDecoder,Et=t.decode.bind(t)))(e)}var Tt,Et,Dt=e((()=>{}));function Ot(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 kt(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 w,T,At,jt=e((()=>{_(),Dt(),At=class{constructor(){w.set(this,void 0),T.set(this,void 0),h(this,w,new Uint8Array,`f`),h(this,T,null,`f`)}decode(e){if(e==null)return[];let t=e instanceof ArrayBuffer?new Uint8Array(e):typeof e==`string`?Ct(e):e;h(this,w,St([g(this,w,`f`),t]),`f`);let n=[],r;for(;(r=Ot(g(this,w,`f`),g(this,T,`f`)))!=null;){if(r.carriage&&g(this,T,`f`)==null){h(this,T,r.index,`f`);continue}if(g(this,T,`f`)!=null&&(r.index!==g(this,T,`f`)+1||r.carriage)){n.push(wt(g(this,w,`f`).subarray(0,g(this,T,`f`)-1))),h(this,w,g(this,w,`f`).subarray(g(this,T,`f`)),`f`),h(this,T,null,`f`);continue}let e=g(this,T,`f`)===null?r.preceding:r.preceding-1,t=wt(g(this,w,`f`).subarray(0,e));n.push(t),h(this,w,g(this,w,`f`).subarray(r.index),`f`),h(this,T,null,`f`)}return n}flush(){return g(this,w,`f`).length?this.decode(`
2
+ `):[]}},w=new WeakMap,T=new WeakMap,At.NEWLINE_CHARS=new Set([`
3
+ `,`\r`]),At.NEWLINE_REGEXP=/\r\n|[\n\r]/g}));function Mt(){}function Nt(e,t,n){return!t||Pt[e]>Pt[n]?Mt:t[e].bind(t)}function E(e){let t=e.logger,n=e.logLevel??`off`;if(!t)return It;let r=Lt.get(t);if(r&&r[0]===n)return r[1];let i={error:Nt(`error`,t,n),warn:Nt(`warn`,t,n),info:Nt(`info`,t,n),debug:Nt(`debug`,t,n)};return Lt.set(t,[n,i]),i}var Pt,Ft,It,Lt,D,Rt=e((()=>{$e(),Pt={off:0,error:200,warn:300,info:400,debug:500},Ft=(e,t,n)=>{if(e){if(Ke(Pt,e))return e;E(n).warn(`${t} was set to ${JSON.stringify(e)}, expected one of ${JSON.stringify(Object.keys(Pt))}`)}},It={error:Mt,warn:Mt,info:Mt,debug:Mt},Lt=new WeakMap,D=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()===`x-api-key`||e.toLowerCase()===`authorization`||e.toLowerCase()===`cookie`||e.toLowerCase()===`set-cookie`?`***`:t]))),`retryOfRequestLogID`in e&&(e.retryOfRequestLogID&&(e.retryOf=e.retryOfRequestLogID),delete e.retryOfRequestLogID),e)}));async function*zt(e,t){if(!e.body)throw t.abort(),globalThis.navigator!==void 0&&globalThis.navigator.product===`ReactNative`?new v(`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 v(`Attempted to iterate over a response with no body`);let n=new Wt,r=new At,i=ht(e.body);for await(let e of Bt(i))for(let t of r.decode(e)){let e=n.decode(t);e&&(yield e)}for(let e of r.flush()){let t=n.decode(e);t&&(yield t)}}async function*Bt(e){let t=new Uint8Array;for await(let n of e){if(n==null)continue;let e=n instanceof ArrayBuffer?new Uint8Array(n):typeof n==`string`?Ct(n):n,r=new Uint8Array(t.length+e.length);r.set(t),r.set(e,t.length),t=r;let i;for(;(i=kt(t))!==-1;)yield t.slice(0,i),t=t.slice(i)}t.length>0&&(yield t)}function Vt(e,t){let n=e.indexOf(t);return n===-1?[e,``,``]:[e.substring(0,n),t,e.substring(n+t.length)]}var Ht,Ut,Wt,Gt=e((()=>{_(),S(),_t(),jt(),Pe(),$e(),Dt(),Rt(),Ut=class e{constructor(e,t,n){this.iterator=e,Ht.set(this,void 0),this.controller=t,h(this,Ht,n,`f`)}static fromSSEResponse(t,n,r){let i=!1,a=r?E(r):console;async function*o(){if(i)throw new v("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");i=!0;let e=!1;try{for await(let e of zt(t,n)){if(e.event===`completion`)try{yield JSON.parse(e.data)}catch(t){throw a.error(`Could not parse message into JSON:`,e.data),a.error(`From chunk:`,e.raw),t}if(e.event===`message_start`||e.event===`message_delta`||e.event===`message_stop`||e.event===`content_block_start`||e.event===`content_block_delta`||e.event===`content_block_stop`)try{yield JSON.parse(e.data)}catch(t){throw a.error(`Could not parse message into JSON:`,e.data),a.error(`From chunk:`,e.raw),t}if(e.event!==`ping`&&e.event===`error`){let n=Qe(e.data)??e.data,r=n?.error?.type;throw new y(void 0,n,void 0,t.headers,r)}}e=!0}catch(e){if(Me(e))return;throw e}finally{e||n.abort()}}return new e(o,n,r)}static fromReadableStream(t,n,r){let i=!1;async function*a(){let e=new At,n=ht(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 v("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(Me(e))return;throw e}finally{e||n.abort()}}return new e(o,n,r)}[(Ht=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,g(this,Ht,`f`)),new e(()=>i(n),this.controller,g(this,Ht,`f`))]}toReadableStream(){let e=this,t;return pt({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=Ct(JSON.stringify(n)+`
4
+ `);e.enqueue(i)}catch(t){e.error(t)}},async cancel(){await t.return?.()}})}},Wt=class{constructor(){this.event=null,this.data=[],this.chunks=[]}decode(e){if(e.endsWith(`\r`)&&(e=e.substring(0,e.length-1)),!e){if(!this.event&&!this.data.length)return null;let e={event:this.event,data:this.data.join(`
5
+ `),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],e}if(this.chunks.push(e),e.startsWith(`:`))return null;let[t,n,r]=Vt(e,`:`);return r.startsWith(` `)&&(r=r.substring(1)),t===`event`?this.event=r:t===`data`&&this.data.push(r),null}}}));async function Kt(e,t){let{response:n,requestLogID:r,retryOfRequestLogID:i,startTime:a}=t,o=await(async()=>{if(t.options.stream)return E(e).debug(`response`,n.status,n.url,n.headers,n.body),t.options.__streamClass?t.options.__streamClass.fromSSEResponse(n,t.controller):Ut.fromSSEResponse(n,t.controller);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:qt(await n.json(),n):await n.text()})();return E(e).debug(`[${r}] response parsed`,D({retryOfRequestLogID:i,url:n.url,status:n.status,body:o,durationMs:Date.now()-a})),o}function qt(e,t){return!e||typeof e!=`object`||Array.isArray(e)?e:Object.defineProperty(e,"_request_id",{value:t.headers.get(`request-id`),enumerable:!1})}var Jt=e((()=>{Gt(),Rt()})),Yt,Xt,Zt=e((()=>{_(),Jt(),Xt=class e extends Promise{constructor(e,t,n=Kt){super(e=>{e(null)}),this.responsePromise=t,this.parseResponse=n,Yt.set(this,void 0),h(this,Yt,e,`f`)}_thenUnwrap(t){return new e(g(this,Yt,`f`),this.responsePromise,async(e,n)=>qt(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(`request-id`)}}parse(){return this.parsedPromise||(this.parsedPromise=this.responsePromise.then(e=>this.parseResponse(g(this,Yt,`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)}},Yt=new WeakMap})),Qt,$t,en,tn,nn,O=e((()=>{_(),S(),Jt(),Zt(),$e(),$t=class{constructor(e,t,n,r){Qt.set(this,void 0),h(this,Qt,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 v("No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.");return await g(this,Qt,`f`).requestAPIList(this.constructor,e)}async*iterPages(){let e=this;for(yield e;e.hasNextPage();)e=await e.getNextPage(),yield e}async*[(Qt=new WeakMap,Symbol.asyncIterator)](){for await(let e of this.iterPages())for(let t of e.getPaginatedItems())yield t}},en=class extends Xt{constructor(e,t,n){super(e,t,async(e,t)=>new n(e,t.response,await Kt(e,t),t.options))}async*[Symbol.asyncIterator](){let e=await this;for await(let t of e)yield t}},tn=class extends $t{constructor(e,t,n,r){super(e,t,n,r),this.data=n.data||[],this.has_more=n.has_more||!1,this.first_id=n.first_id||null,this.last_id=n.last_id||null}getPaginatedItems(){return this.data??[]}hasNextPage(){return this.has_more!==!1&&super.hasNextPage()}nextPageRequestOptions(){if(this.options.query?.before_id){let e=this.first_id;return e?{...this.options,query:{...We(this.options.query),before_id:e}}:null}let e=this.last_id;return e?{...this.options,query:{...We(this.options.query),after_id:e}}:null}},nn=class extends $t{constructor(e,t,n,r){super(e,t,n,r),this.data=n.data||[],this.has_more=n.has_more||!1,this.next_page=n.next_page||null}getPaginatedItems(){return this.data??[]}hasNextPage(){return this.has_more!==!1&&super.hasNextPage()}nextPageRequestOptions(){let e=this.next_page;return e?{...this.options,query:{...We(this.options.query),page:e}}:null}}}));function k(e,t,n){return on(),new File(e,t??`unknown_file`,n)}function rn(e,t){let n=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))||``;return t?n.split(/[\\/]/).pop()||void 0:n}function an(e){let t=typeof e==`function`?e:e.fetch,n=ln.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 ln.set(t,r),r}var on,sn,cn,ln,un,dn,fn,pn=e((()=>{_t(),on=()=>{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`.":``))}},sn=e=>typeof e==`object`&&!!e&&typeof e[Symbol.asyncIterator]==`function`,cn=async(e,t,n=!0)=>({...e,body:await un(e.body,t,n)}),ln=new WeakMap,un=async(e,t,n=!0)=>{if(!await an(t))throw TypeError(`The provided fetch function does not support file uploads with the current global FormData class.`);let r=new FormData;return await Promise.all(Object.entries(e||{}).map(([e,t])=>fn(r,e,t,n))),r},dn=e=>e instanceof Blob&&`name`in e,fn=async(e,t,n,r)=>{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){let i={},a=n.headers.get(`Content-Type`);a&&(i={type:a}),e.append(t,k([await n.blob()],rn(n,r),i))}else if(sn(n))e.append(t,k([await new Response(mt(n)).blob()],rn(n,r)));else if(dn(n))e.append(t,k([n],rn(n,r),{type:n.type}));else if(Array.isArray(n))await Promise.all(n.map(n=>fn(e,t+`[]`,n,r)));else if(typeof n==`object`)await Promise.all(Object.entries(n).map(([n,i])=>fn(e,`${t}[${n}]`,i,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 mn(e,t,n){if(on(),e=await e,t||(t=rn(e,!0)),vn(e))return e instanceof File&&t==null&&n==null?e:k([await e.arrayBuffer()],t??e.name,{type:e.type,lastModified:e.lastModified,...n});if(yn(e)){let r=await e.blob();return t||(t=new URL(e.url).pathname.split(/[\\/]/).pop()),k(await hn(r),t,n)}let r=await hn(e);if(!n?.type){let e=r.find(e=>typeof e==`object`&&`type`in e&&e.type);typeof e==`string`&&(n={...n,type:e})}return k(r,t,n)}async function hn(e){let t=[];if(typeof e==`string`||ArrayBuffer.isView(e)||e instanceof ArrayBuffer)t.push(e);else if(_n(e))t.push(e instanceof Blob?e:await e.arrayBuffer());else if(sn(e))for await(let n of e)t.push(...await hn(n));else{let t=e?.constructor?.name;throw Error(`Unexpected data type: ${typeof e}${t?`; constructor: ${t}`:``}${gn(e)}`)}return t}function gn(e){return typeof e!=`object`||!e?``:`; props: [${Object.getOwnPropertyNames(e).map(e=>`"${e}"`).join(`, `)}]`}var _n,vn,yn,bn=e((()=>{pn(),_n=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`,vn=e=>typeof e==`object`&&!!e&&typeof e.name==`string`&&typeof e.lastModified==`number`&&_n(e),yn=e=>typeof e==`object`&&!!e&&typeof e.url==`string`&&typeof e.blob==`function`})),xn=e((()=>{bn()})),Sn=e((()=>{})),A,j=e((()=>{A=class{constructor(e){this._client=e}}}));function*Cn(e){if(!e)return;if(wn 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():Xe(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=Xe(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 wn,M,N=e((()=>{$e(),wn=Symbol.for(`brand.privateNullableHeaders`),M=e=>{let t=new Headers,n=new Set;for(let r of e){let e=new Set;for(let[i,a]of Cn(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{[wn]:!0,values:t,nulls:n}}}));function Tn(e){return typeof e==`object`&&!!e&&kn in e}function En(e,t){let n=new Set;if(e)for(let t of e)Tn(t)&&n.add(t[kn]);if(t){for(let e of t)if(Tn(e)&&n.add(e[kn]),Array.isArray(e.content))for(let t of e.content)Tn(t)&&n.add(t[kn])}return Array.from(n)}function Dn(e,t){let n=En(e,t);return n.length===0?{}:{"x-stainless-helper":n.join(`, `)}}function On(e){return Tn(e)?{"x-stainless-helper":e[kn]}:{}}var kn,An=e((()=>{kn=Symbol(`anthropic.sdk.stainlessHelper`)}));function jn(e){return e.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g,encodeURIComponent)}var Mn,Nn,P,F=e((()=>{S(),Mn=Object.freeze(Object.create(null)),Nn=(e=jn)=>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??Mn)??Mn)?.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 v(`Path parameters result in path with invalid segments:\n${i.map(e=>e.error).join(`
6
+ `)}\n${a}\n${t}`)}return a},P=Nn(jn)})),Pn,Fn=e((()=>{j(),O(),N(),An(),pn(),F(),Pn=class extends A{list(e={},t){let{betas:n,...r}=e??{};return this._client.getAPIList(`/v1/files`,tn,{query:r,...t,headers:M([{"anthropic-beta":[...n??[],`files-api-2025-04-14`].toString()},t?.headers])})}delete(e,t={},n){let{betas:r}=t??{};return this._client.delete(P`/v1/files/${e}`,{...n,headers:M([{"anthropic-beta":[...r??[],`files-api-2025-04-14`].toString()},n?.headers])})}download(e,t={},n){let{betas:r}=t??{};return this._client.get(P`/v1/files/${e}/content`,{...n,headers:M([{"anthropic-beta":[...r??[],`files-api-2025-04-14`].toString(),Accept:`application/binary`},n?.headers]),__binaryResponse:!0})}retrieveMetadata(e,t={},n){let{betas:r}=t??{};return this._client.get(P`/v1/files/${e}`,{...n,headers:M([{"anthropic-beta":[...r??[],`files-api-2025-04-14`].toString()},n?.headers])})}upload(e,t){let{betas:n,...r}=e;return this._client.post(`/v1/files`,cn({body:r,...t,headers:M([{"anthropic-beta":[...n??[],`files-api-2025-04-14`].toString()},On(r.file),t?.headers])},this._client))}}})),In,Ln=e((()=>{j(),O(),N(),F(),In=class extends A{retrieve(e,t={},n){let{betas:r}=t??{};return this._client.get(P`/v1/models/${e}?beta=true`,{...n,headers:M([{...r?.toString()==null?void 0:{"anthropic-beta":r?.toString()}},n?.headers])})}list(e={},t){let{betas:n,...r}=e??{};return this._client.getAPIList(`/v1/models?beta=true`,tn,{query:r,...t,headers:M([{...n?.toString()==null?void 0:{"anthropic-beta":n?.toString()}},t?.headers])})}}})),Rn=e((()=>{S()})),zn,Bn=e((()=>{zn={"claude-opus-4-20250514":8192,"claude-opus-4-0":8192,"claude-4-opus-20250514":8192,"anthropic.claude-opus-4-20250514-v1:0":8192,"claude-opus-4@20250514":8192,"claude-opus-4-1-20250805":8192,"anthropic.claude-opus-4-1-20250805-v1:0":8192,"claude-opus-4-1@20250805":8192}}));function Vn(e){return e?.output_format??e?.output_config?.format}function Hn(e,t,n){let r=Vn(t);return!t||!(`parse`in(r??{}))?{...e,content:e.content.map(e=>{if(e.type===`text`){let t=Object.defineProperty({...e},"parsed_output",{value:null,enumerable:!1});return Object.defineProperty(t,"parsed",{get(){return n.logger.warn("The `parsed` property on `text` blocks is deprecated, please use `parsed_output` instead."),null},enumerable:!1})}return e}),parsed_output:null}:Un(e,t,n)}function Un(e,t,n){let r=null,i=e.content.map(e=>{if(e.type===`text`){let i=Wn(t,e.text);r===null&&(r=i);let a=Object.defineProperty({...e},"parsed_output",{value:i,enumerable:!1});return Object.defineProperty(a,"parsed",{get(){return n.logger.warn("The `parsed` property on `text` blocks is deprecated, please use `parsed_output` instead."),i},enumerable:!1})}return e});return{...e,content:i,parsed_output:r}}function Wn(e,t){let n=Vn(e);if(n?.type!==`json_schema`)return null;try{return`parse`in n?n.parse(t):JSON.parse(t)}catch(e){throw new v(`Failed to parse structured output: ${e}`)}}var Gn=e((()=>{S()})),Kn,qn,Jn,Yn,Xn,Zn=e((()=>{Kn=e=>{let t=0,n=[];for(;t<e.length;){let r=e[t];if(r===`\\`){t++;continue}if(r===`{`){n.push({type:`brace`,value:`{`}),t++;continue}if(r===`}`){n.push({type:`brace`,value:`}`}),t++;continue}if(r===`[`){n.push({type:`paren`,value:`[`}),t++;continue}if(r===`]`){n.push({type:`paren`,value:`]`}),t++;continue}if(r===`:`){n.push({type:`separator`,value:`:`}),t++;continue}if(r===`,`){n.push({type:`delimiter`,value:`,`}),t++;continue}if(r===`"`){let i=``,a=!1;for(r=e[++t];r!==`"`;){if(t===e.length){a=!0;break}if(r===`\\`){if(t++,t===e.length){a=!0;break}i+=r+e[t],r=e[++t]}else i+=r,r=e[++t]}r=e[++t],a||n.push({type:`string`,value:i});continue}if(r&&/\s/.test(r)){t++;continue}let i=/[0-9]/;if(r&&i.test(r)||r===`-`||r===`.`){let a=``;for(r===`-`&&(a+=r,r=e[++t]);r&&i.test(r)||r===`.`;)a+=r,r=e[++t];n.push({type:`number`,value:a});continue}let a=/[a-z]/i;if(r&&a.test(r)){let i=``;for(;r&&a.test(r)&&t!==e.length;)i+=r,r=e[++t];if(i==`true`||i==`false`||i===`null`)n.push({type:`name`,value:i});else{t++;continue}continue}t++}return n},qn=e=>{if(e.length===0)return e;let t=e[e.length-1];switch(t.type){case`separator`:return e=e.slice(0,e.length-1),qn(e);case`number`:let n=t.value[t.value.length-1];if(n===`.`||n===`-`)return e=e.slice(0,e.length-1),qn(e);case`string`:let r=e[e.length-2];if(r?.type===`delimiter`||r?.type===`brace`&&r.value===`{`)return e=e.slice(0,e.length-1),qn(e);break;case`delimiter`:return e=e.slice(0,e.length-1),qn(e)}return e},Jn=e=>{let t=[];return e.map(e=>{e.type===`brace`&&(e.value===`{`?t.push(`}`):t.splice(t.lastIndexOf(`}`),1)),e.type===`paren`&&(e.value===`[`?t.push(`]`):t.splice(t.lastIndexOf(`]`),1))}),t.length>0&&t.reverse().map(t=>{t===`}`?e.push({type:`brace`,value:`}`}):t===`]`&&e.push({type:`paren`,value:`]`})}),e},Yn=e=>{let t=``;return e.map(e=>{switch(e.type){case`string`:t+=`"`+e.value+`"`;break;default:t+=e.value;break}}),t},Xn=e=>JSON.parse(Yn(Jn(qn(Kn(e)))))})),Qn=e((()=>{Gt()}));function $n(e){return e.type===`tool_use`||e.type===`server_tool_use`||e.type===`mcp_tool_use`}var I,L,er,tr,nr,rr,ir,ar,or,R,sr,cr,lr,z,ur,dr,fr,pr,mr,hr,gr,_r,vr,yr,br,xr,Sr=e((()=>{_(),Zn(),Rn(),Pe(),Qn(),Gn(),br=`__json_buf`,xr=class e{constructor(e,t){I.add(this),this.messages=[],this.receivedMessages=[],L.set(this,void 0),er.set(this,null),this.controller=new AbortController,tr.set(this,void 0),nr.set(this,()=>{}),rr.set(this,()=>{}),ir.set(this,void 0),ar.set(this,()=>{}),or.set(this,()=>{}),R.set(this,{}),sr.set(this,!1),cr.set(this,!1),lr.set(this,!1),z.set(this,!1),ur.set(this,void 0),dr.set(this,void 0),fr.set(this,void 0),hr.set(this,e=>{if(h(this,cr,!0,`f`),Me(e)&&(e=new b),e instanceof b)return h(this,lr,!0,`f`),this._emit(`abort`,e);if(e instanceof v)return this._emit(`error`,e);if(e instanceof Error){let t=new v(e.message);return t.cause=e,this._emit(`error`,t)}return this._emit(`error`,new v(String(e)))}),h(this,tr,new Promise((e,t)=>{h(this,nr,e,`f`),h(this,rr,t,`f`)}),`f`),h(this,ir,new Promise((e,t)=>{h(this,ar,e,`f`),h(this,or,t,`f`)}),`f`),g(this,tr,`f`).catch(()=>{}),g(this,ir,`f`).catch(()=>{}),h(this,er,e,`f`),h(this,fr,t?.logger??console,`f`)}get response(){return g(this,ur,`f`)}get request_id(){return g(this,dr,`f`)}async withResponse(){h(this,z,!0,`f`);let e=await g(this,tr,`f`);if(!e)throw Error("Could not resolve a `Response` object");return{data:this,response:e,request_id:e.headers.get(`request-id`)}}static fromReadableStream(t){let n=new e(null);return n._run(()=>n._fromReadableStream(t)),n}static createMessage(t,n,r,{logger:i}={}){let a=new e(n,{logger:i});for(let e of n.messages)a._addMessageParam(e);return h(a,er,{...n,stream:!0},`f`),a._run(()=>a._createMessage(t,{...n,stream:!0},{...r,headers:{...r?.headers,"X-Stainless-Helper-Method":`stream`}})),a}_run(e){e().then(()=>{this._emitFinal(),this._emit(`end`)},g(this,hr,`f`))}_addMessageParam(e){this.messages.push(e)}_addMessage(e,t=!0){this.receivedMessages.push(e),t&&this._emit(`message`,e)}async _createMessage(e,t,n){let r=n?.signal,i;r&&(r.aborted&&this.controller.abort(),i=this.controller.abort.bind(this.controller),r.addEventListener(`abort`,i));try{g(this,I,`m`,gr).call(this);let{response:r,data:i}=await e.create({...t,stream:!0},{...n,signal:this.controller.signal}).withResponse();this._connected(r);for await(let e of i)g(this,I,`m`,_r).call(this,e);if(i.controller.signal?.aborted)throw new b;g(this,I,`m`,vr).call(this)}finally{r&&i&&r.removeEventListener(`abort`,i)}}_connected(e){this.ended||(h(this,ur,e,`f`),h(this,dr,e?.headers.get(`request-id`),`f`),g(this,nr,`f`).call(this,e),this._emit(`connect`))}get ended(){return g(this,sr,`f`)}get errored(){return g(this,cr,`f`)}get aborted(){return g(this,lr,`f`)}abort(){this.controller.abort()}on(e,t){return(g(this,R,`f`)[e]||(g(this,R,`f`)[e]=[])).push({listener:t}),this}off(e,t){let n=g(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(g(this,R,`f`)[e]||(g(this,R,`f`)[e]=[])).push({listener:t,once:!0}),this}emitted(e){return new Promise((t,n)=>{h(this,z,!0,`f`),e!==`error`&&this.once(`error`,n),this.once(e,t)})}async done(){h(this,z,!0,`f`),await g(this,ir,`f`)}get currentMessage(){return g(this,L,`f`)}async finalMessage(){return await this.done(),g(this,I,`m`,pr).call(this)}async finalText(){return await this.done(),g(this,I,`m`,mr).call(this)}_emit(e,...t){if(g(this,sr,`f`))return;e===`end`&&(h(this,sr,!0,`f`),g(this,ar,`f`).call(this));let n=g(this,R,`f`)[e];if(n&&(g(this,R,`f`)[e]=n.filter(e=>!e.once),n.forEach(({listener:e})=>e(...t))),e===`abort`){let e=t[0];!g(this,z,`f`)&&!n?.length&&Promise.reject(e),g(this,rr,`f`).call(this,e),g(this,or,`f`).call(this,e),this._emit(`end`);return}if(e===`error`){let e=t[0];!g(this,z,`f`)&&!n?.length&&Promise.reject(e),g(this,rr,`f`).call(this,e),g(this,or,`f`).call(this,e),this._emit(`end`)}}_emitFinal(){this.receivedMessages.at(-1)&&this._emit(`finalMessage`,g(this,I,`m`,pr).call(this))}async _fromReadableStream(e,t){let n=t?.signal,r;n&&(n.aborted&&this.controller.abort(),r=this.controller.abort.bind(this.controller),n.addEventListener(`abort`,r));try{g(this,I,`m`,gr).call(this),this._connected(null);let t=Ut.fromReadableStream(e,this.controller);for await(let e of t)g(this,I,`m`,_r).call(this,e);if(t.controller.signal?.aborted)throw new b;g(this,I,`m`,vr).call(this)}finally{n&&r&&n.removeEventListener(`abort`,r)}}[(L=new WeakMap,er=new WeakMap,tr=new WeakMap,nr=new WeakMap,rr=new WeakMap,ir=new WeakMap,ar=new WeakMap,or=new WeakMap,R=new WeakMap,sr=new WeakMap,cr=new WeakMap,lr=new WeakMap,z=new WeakMap,ur=new WeakMap,dr=new WeakMap,fr=new WeakMap,hr=new WeakMap,I=new WeakSet,pr=function(){if(this.receivedMessages.length===0)throw new v(`stream ended without producing a Message with role=assistant`);return this.receivedMessages.at(-1)},mr=function(){if(this.receivedMessages.length===0)throw new v(`stream ended without producing a Message with role=assistant`);let e=this.receivedMessages.at(-1).content.filter(e=>e.type===`text`).map(e=>e.text);if(e.length===0)throw new v(`stream ended without producing a content block with type=text`);return e.join(` `)},gr=function(){this.ended||h(this,L,void 0,`f`)},_r=function(e){if(this.ended)return;let t=g(this,I,`m`,yr).call(this,e);switch(this._emit(`streamEvent`,e,t),e.type){case`content_block_delta`:{let n=t.content.at(-1);switch(e.delta.type){case`text_delta`:n.type===`text`&&this._emit(`text`,e.delta.text,n.text||``);break;case`citations_delta`:n.type===`text`&&this._emit(`citation`,e.delta.citation,n.citations??[]);break;case`input_json_delta`:$n(n)&&n.input&&this._emit(`inputJson`,e.delta.partial_json,n.input);break;case`thinking_delta`:n.type===`thinking`&&this._emit(`thinking`,e.delta.thinking,n.thinking);break;case`signature_delta`:n.type===`thinking`&&this._emit(`signature`,n.signature);break;case`compaction_delta`:n.type===`compaction`&&n.content&&this._emit(`compaction`,n.content);break;default:e.delta}break}case`message_stop`:this._addMessageParam(t),this._addMessage(Hn(t,g(this,er,`f`),{logger:g(this,fr,`f`)}),!0);break;case`content_block_stop`:this._emit(`contentBlock`,t.content.at(-1));break;case`message_start`:h(this,L,t,`f`);break;case`content_block_start`:case`message_delta`:break}},vr=function(){if(this.ended)throw new v(`stream has ended, this shouldn't happen`);let e=g(this,L,`f`);if(!e)throw new v(`request ended without sending any chunks`);return h(this,L,void 0,`f`),Hn(e,g(this,er,`f`),{logger:g(this,fr,`f`)})},yr=function(e){let t=g(this,L,`f`);if(e.type===`message_start`){if(t)throw new v(`Unexpected event order, got ${e.type} before receiving "message_stop"`);return e.message}if(!t)throw new v(`Unexpected event order, got ${e.type} before "message_start"`);switch(e.type){case`message_stop`:return t;case`message_delta`:return t.container=e.delta.container,t.stop_reason=e.delta.stop_reason,t.stop_sequence=e.delta.stop_sequence,t.usage.output_tokens=e.usage.output_tokens,t.context_management=e.context_management,e.usage.input_tokens!=null&&(t.usage.input_tokens=e.usage.input_tokens),e.usage.cache_creation_input_tokens!=null&&(t.usage.cache_creation_input_tokens=e.usage.cache_creation_input_tokens),e.usage.cache_read_input_tokens!=null&&(t.usage.cache_read_input_tokens=e.usage.cache_read_input_tokens),e.usage.server_tool_use!=null&&(t.usage.server_tool_use=e.usage.server_tool_use),e.usage.iterations!=null&&(t.usage.iterations=e.usage.iterations),t;case`content_block_start`:return t.content.push(e.content_block),t;case`content_block_delta`:{let n=t.content.at(e.index);switch(e.delta.type){case`text_delta`:n?.type===`text`&&(t.content[e.index]={...n,text:(n.text||``)+e.delta.text});break;case`citations_delta`:n?.type===`text`&&(t.content[e.index]={...n,citations:[...n.citations??[],e.delta.citation]});break;case`input_json_delta`:if(n&&$n(n)){let r=n[br]||``;r+=e.delta.partial_json;let i={...n};if(Object.defineProperty(i,br,{value:r,enumerable:!1,writable:!0}),r)try{i.input=Xn(r)}catch(e){let t=new v(`Unable to parse tool parameter JSON from model. Please retry your request or adjust your prompt. Error: ${e}. JSON: ${r}`);g(this,hr,`f`).call(this,t)}t.content[e.index]=i}break;case`thinking_delta`:n?.type===`thinking`&&(t.content[e.index]={...n,thinking:n.thinking+e.delta.thinking});break;case`signature_delta`:n?.type===`thinking`&&(t.content[e.index]={...n,signature:e.delta.signature});break;case`compaction_delta`:n?.type===`compaction`&&(t.content[e.index]={...n,content:(n.content||``)+e.delta.content});break;default:e.delta}return t}case`content_block_stop`:return t}},Symbol.asyncIterator)](){let e=[],t=[],n=!1;return this.on(`streamEvent`,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 Ut(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}}})),Cr,wr=e((()=>{Cr=class extends Error{constructor(e){let t=typeof e==`string`?e:e.map(e=>e.type===`text`?e.text:`[${e.type}]`).join(` `);super(t),this.name=`ToolError`,this.content=e}}})),Tr,Er=e((()=>{Tr=`You have been working on the task described above but have not yet completed it. Write a continuation summary that will allow you (or another instance of yourself) to resume work efficiently in a future context window where the conversation history will be replaced with this summary. Your summary should be structured, concise, and actionable. Include:
7
+ 1. Task Overview
8
+ The user's core request and success criteria
9
+ Any clarifications or constraints they specified
10
+ 2. Current State
11
+ What has been completed so far
12
+ Files created, modified, or analyzed (with paths if relevant)
13
+ Key outputs or artifacts produced
14
+ 3. Important Discoveries
15
+ Technical constraints or requirements uncovered
16
+ Decisions made and their rationale
17
+ Errors encountered and how they were resolved
18
+ What approaches were tried that didn't work (and why)
19
+ 4. Next Steps
20
+ Specific actions needed to complete the task
21
+ Any blockers or open questions to resolve
22
+ Priority order if multiple steps remain
23
+ 5. Context to Preserve
24
+ User preferences or style requirements
25
+ Domain-specific details that aren't obvious
26
+ Any promises made to the user
27
+ Be concise but complete—err on the side of including information that would prevent duplicate work or repeated mistakes. Write in a way that enables immediate resumption of the task.
28
+ Wrap your summary in <summary></summary> tags.`}));function Dr(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}async function Or(e,t=e.messages.at(-1)){if(!t||t.role!==`assistant`||!t.content||typeof t.content==`string`)return null;let n=t.content.filter(e=>e.type===`tool_use`);return n.length===0?null:{role:`user`,content:await Promise.all(n.map(async t=>{let n=e.tools.find(e=>(`name`in e?e.name:e.mcp_server_name)===t.name);if(!n||!(`run`in n))return{type:`tool_result`,tool_use_id:t.id,content:`Error: Tool '${t.name}' not found`,is_error:!0};try{let e=t.input;`parse`in n&&n.parse&&(e=n.parse(e));let r=await n.run(e);return{type:`tool_result`,tool_use_id:t.id,content:r}}catch(e){return{type:`tool_result`,tool_use_id:t.id,content:e instanceof Cr?e.content:`Error: ${e instanceof Error?e.message:String(e)}`,is_error:!0}}}))}}var kr,B,V,H,Ar,U,W,G,jr,Mr,Nr,Pr,Fr=e((()=>{_(),wr(),S(),N(),Er(),An(),Pr=class{constructor(e,t,n){kr.add(this),this.client=e,B.set(this,!1),V.set(this,!1),H.set(this,void 0),Ar.set(this,void 0),U.set(this,void 0),W.set(this,void 0),G.set(this,void 0),jr.set(this,0),h(this,H,{params:{...t,messages:structuredClone(t.messages)}},`f`);let r=[`BetaToolRunner`,...En(t.tools,t.messages)].join(`, `);h(this,Ar,{...n,headers:M([{"x-stainless-helper":r},n?.headers])},`f`),h(this,G,Dr(),`f`)}async*[(B=new WeakMap,V=new WeakMap,H=new WeakMap,Ar=new WeakMap,U=new WeakMap,W=new WeakMap,G=new WeakMap,jr=new WeakMap,kr=new WeakSet,Mr=async function(){let e=g(this,H,`f`).params.compactionControl;if(!e||!e.enabled)return!1;let t=0;if(g(this,U,`f`)!==void 0)try{let e=await g(this,U,`f`);t=e.usage.input_tokens+(e.usage.cache_creation_input_tokens??0)+(e.usage.cache_read_input_tokens??0)+e.usage.output_tokens}catch{return!1}let n=e.contextTokenThreshold??1e5;if(t<n)return!1;let r=e.model??g(this,H,`f`).params.model,i=e.summaryPrompt??Tr,a=g(this,H,`f`).params.messages;if(a[a.length-1].role===`assistant`){let e=a[a.length-1];if(Array.isArray(e.content)){let t=e.content.filter(e=>e.type!==`tool_use`);t.length===0?a.pop():e.content=t}}let o=await this.client.beta.messages.create({model:r,messages:[...a,{role:`user`,content:[{type:`text`,text:i}]}],max_tokens:g(this,H,`f`).params.max_tokens},{headers:{"x-stainless-helper":`compaction`}});if(o.content[0]?.type!==`text`)throw new v(`Expected text response for compaction`);return g(this,H,`f`).params.messages=[{role:`user`,content:o.content}],!0},Symbol.asyncIterator)](){var e;if(g(this,B,`f`))throw new v(`Cannot iterate over a consumed stream`);h(this,B,!0,`f`),h(this,V,!0,`f`),h(this,W,void 0,`f`);try{for(;;){let t;try{if(g(this,H,`f`).params.max_iterations&&g(this,jr,`f`)>=g(this,H,`f`).params.max_iterations)break;h(this,V,!1,`f`),h(this,W,void 0,`f`),h(this,jr,(e=g(this,jr,`f`),e++,e),`f`),h(this,U,void 0,`f`);let{max_iterations:n,compactionControl:r,...i}=g(this,H,`f`).params;if(i.stream?(t=this.client.beta.messages.stream({...i},g(this,Ar,`f`)),h(this,U,t.finalMessage(),`f`),g(this,U,`f`).catch(()=>{}),yield t):(h(this,U,this.client.beta.messages.create({...i,stream:!1},g(this,Ar,`f`)),`f`),yield g(this,U,`f`)),!await g(this,kr,`m`,Mr).call(this)){if(!g(this,V,`f`)){let{role:e,content:t}=await g(this,U,`f`);g(this,H,`f`).params.messages.push({role:e,content:t})}let e=await g(this,kr,`m`,Nr).call(this,g(this,H,`f`).params.messages.at(-1));if(e)g(this,H,`f`).params.messages.push(e);else if(!g(this,V,`f`))break}}finally{t&&t.abort()}}if(!g(this,U,`f`))throw new v(`ToolRunner concluded without a message from the server`);g(this,G,`f`).resolve(await g(this,U,`f`))}catch(e){throw h(this,B,!1,`f`),g(this,G,`f`).promise.catch(()=>{}),g(this,G,`f`).reject(e),h(this,G,Dr(),`f`),e}}setMessagesParams(e){typeof e==`function`?g(this,H,`f`).params=e(g(this,H,`f`).params):g(this,H,`f`).params=e,h(this,V,!0,`f`),h(this,W,void 0,`f`)}async generateToolResponse(){let e=await g(this,U,`f`)??this.params.messages.at(-1);return e?g(this,kr,`m`,Nr).call(this,e):null}done(){return g(this,G,`f`).promise}async runUntilDone(){if(!g(this,B,`f`))for await(let e of this);return this.done()}get params(){return g(this,H,`f`).params}pushMessages(...e){this.setMessagesParams(t=>({...t,messages:[...t.messages,...e]}))}then(e,t){return this.runUntilDone().then(e,t)}},Nr=async function(e){return g(this,W,`f`)===void 0&&h(this,W,Or(g(this,H,`f`).params,e),`f`),g(this,W,`f`)}})),Ir,Lr=e((()=>{S(),_t(),jt(),Ir=class e{constructor(e,t){this.iterator=e,this.controller=t}async*decoder(){let e=new At;for await(let t of this.iterator)for(let n of e.decode(t))yield JSON.parse(n);for(let t of e.flush())yield JSON.parse(t)}[Symbol.asyncIterator](){return this.decoder()}static fromResponse(t,n){if(!t.body)throw n.abort(),globalThis.navigator!==void 0&&globalThis.navigator.product===`ReactNative`?new v(`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 v(`Attempted to iterate over a response with no body`);return new e(ht(t.body),n)}}})),Rr,zr=e((()=>{j(),O(),N(),Lr(),Rn(),F(),Rr=class extends A{create(e,t){let{betas:n,...r}=e;return this._client.post(`/v1/messages/batches?beta=true`,{body:r,...t,headers:M([{"anthropic-beta":[...n??[],`message-batches-2024-09-24`].toString()},t?.headers])})}retrieve(e,t={},n){let{betas:r}=t??{};return this._client.get(P`/v1/messages/batches/${e}?beta=true`,{...n,headers:M([{"anthropic-beta":[...r??[],`message-batches-2024-09-24`].toString()},n?.headers])})}list(e={},t){let{betas:n,...r}=e??{};return this._client.getAPIList(`/v1/messages/batches?beta=true`,tn,{query:r,...t,headers:M([{"anthropic-beta":[...n??[],`message-batches-2024-09-24`].toString()},t?.headers])})}delete(e,t={},n){let{betas:r}=t??{};return this._client.delete(P`/v1/messages/batches/${e}?beta=true`,{...n,headers:M([{"anthropic-beta":[...r??[],`message-batches-2024-09-24`].toString()},n?.headers])})}cancel(e,t={},n){let{betas:r}=t??{};return this._client.post(P`/v1/messages/batches/${e}/cancel?beta=true`,{...n,headers:M([{"anthropic-beta":[...r??[],`message-batches-2024-09-24`].toString()},n?.headers])})}async results(e,t={},n){let r=await this.retrieve(e);if(!r.results_url)throw new v(`No batch \`results_url\`; Has it finished processing? ${r.processing_status} - ${r.id}`);let{betas:i}=t??{};return this._client.get(r.results_url,{...n,headers:M([{"anthropic-beta":[...i??[],`message-batches-2024-09-24`].toString(),Accept:`application/binary`},n?.headers]),stream:!0,__binaryResponse:!0})._thenUnwrap((e,t)=>Ir.fromResponse(t.response,t.controller))}}}));function Br(e){if(!e.output_format)return e;if(e.output_config?.format)throw new v(`Both output_format and output_config.format were provided. Please use only output_config.format (output_format is deprecated).`);let{output_format:t,...n}=e;return{...n,output_config:{...e.output_config,format:t}}}var Vr,Hr,Ur,Wr=e((()=>{Rn(),j(),Bn(),N(),An(),Gn(),Sr(),Fr(),wr(),zr(),Vr={"claude-1.3":`November 6th, 2024`,"claude-1.3-100k":`November 6th, 2024`,"claude-instant-1.1":`November 6th, 2024`,"claude-instant-1.1-100k":`November 6th, 2024`,"claude-instant-1.2":`November 6th, 2024`,"claude-3-sonnet-20240229":`July 21st, 2025`,"claude-3-opus-20240229":`January 5th, 2026`,"claude-2.1":`July 21st, 2025`,"claude-2.0":`July 21st, 2025`,"claude-3-7-sonnet-latest":`February 19th, 2026`,"claude-3-7-sonnet-20250219":`February 19th, 2026`},Hr=[`claude-opus-4-6`],Ur=class extends A{constructor(){super(...arguments),this.batches=new Rr(this._client)}create(e,t){let n=Br(e),{betas:r,...i}=n;i.model in Vr&&console.warn(`The model '${i.model}' is deprecated and will reach end-of-life on ${Vr[i.model]}\nPlease migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`),i.model in Hr&&i.thinking&&i.thinking.type===`enabled`&&console.warn(`Using Claude with ${i.model} and 'thinking.type=enabled' is deprecated. Use 'thinking.type=adaptive' instead which results in better model performance in our testing: https://platform.claude.com/docs/en/build-with-claude/adaptive-thinking`);let a=this._client._options.timeout;if(!i.stream&&a==null){let e=zn[i.model]??void 0;a=this._client.calculateNonstreamingTimeout(i.max_tokens,e)}let o=Dn(i.tools,i.messages);return this._client.post(`/v1/messages?beta=true`,{body:i,timeout:a??6e5,...t,headers:M([{...r?.toString()==null?void 0:{"anthropic-beta":r?.toString()}},o,t?.headers]),stream:n.stream??!1})}parse(e,t){return t={...t,headers:M([{"anthropic-beta":[...e.betas??[],`structured-outputs-2025-12-15`].toString()},t?.headers])},this.create(e,t).then(t=>Un(t,e,{logger:this._client.logger??console}))}stream(e,t){return xr.createMessage(this,e,t)}countTokens(e,t){let{betas:n,...r}=Br(e);return this._client.post(`/v1/messages/count_tokens?beta=true`,{body:r,...t,headers:M([{"anthropic-beta":[...n??[],`token-counting-2024-11-01`].toString()},t?.headers])})}toolRunner(e,t){return new Pr(this._client,e,t)}},Ur.Batches=Rr,Ur.BetaToolRunner=Pr,Ur.ToolError=Cr})),Gr,Kr=e((()=>{j(),O(),N(),pn(),F(),Gr=class extends A{create(e,t={},n){let{betas:r,...i}=t??{};return this._client.post(P`/v1/skills/${e}/versions?beta=true`,cn({body:i,...n,headers:M([{"anthropic-beta":[...r??[],`skills-2025-10-02`].toString()},n?.headers])},this._client))}retrieve(e,t,n){let{skill_id:r,betas:i}=t;return this._client.get(P`/v1/skills/${r}/versions/${e}?beta=true`,{...n,headers:M([{"anthropic-beta":[...i??[],`skills-2025-10-02`].toString()},n?.headers])})}list(e,t={},n){let{betas:r,...i}=t??{};return this._client.getAPIList(P`/v1/skills/${e}/versions?beta=true`,nn,{query:i,...n,headers:M([{"anthropic-beta":[...r??[],`skills-2025-10-02`].toString()},n?.headers])})}delete(e,t,n){let{skill_id:r,betas:i}=t;return this._client.delete(P`/v1/skills/${r}/versions/${e}?beta=true`,{...n,headers:M([{"anthropic-beta":[...i??[],`skills-2025-10-02`].toString()},n?.headers])})}}})),qr,Jr=e((()=>{j(),Kr(),O(),N(),pn(),F(),qr=class extends A{constructor(){super(...arguments),this.versions=new Gr(this._client)}create(e={},t){let{betas:n,...r}=e??{};return this._client.post(`/v1/skills?beta=true`,cn({body:r,...t,headers:M([{"anthropic-beta":[...n??[],`skills-2025-10-02`].toString()},t?.headers])},this._client,!1))}retrieve(e,t={},n){let{betas:r}=t??{};return this._client.get(P`/v1/skills/${e}?beta=true`,{...n,headers:M([{"anthropic-beta":[...r??[],`skills-2025-10-02`].toString()},n?.headers])})}list(e={},t){let{betas:n,...r}=e??{};return this._client.getAPIList(`/v1/skills?beta=true`,nn,{query:r,...t,headers:M([{"anthropic-beta":[...n??[],`skills-2025-10-02`].toString()},t?.headers])})}delete(e,t={},n){let{betas:r}=t??{};return this._client.delete(P`/v1/skills/${e}?beta=true`,{...n,headers:M([{"anthropic-beta":[...r??[],`skills-2025-10-02`].toString()},n?.headers])})}},qr.Versions=Gr})),K,Yr=e((()=>{j(),Fn(),Ln(),Wr(),Jr(),K=class extends A{constructor(){super(...arguments),this.models=new In(this._client),this.messages=new Ur(this._client),this.files=new Pn(this._client),this.skills=new qr(this._client)}},K.Models=In,K.Messages=Ur,K.Files=Pn,K.Skills=qr})),Xr,Zr=e((()=>{j(),N(),Xr=class extends A{create(e,t){let{betas:n,...r}=e;return this._client.post(`/v1/complete`,{body:r,timeout:this._client._options.timeout??6e5,...t,headers:M([{...n?.toString()==null?void 0:{"anthropic-beta":n?.toString()}},t?.headers]),stream:e.stream??!1})}}}));function Qr(e){return e?.output_config?.format}function $r(e,t,n){let r=Qr(t);return!t||!(`parse`in(r??{}))?{...e,content:e.content.map(e=>e.type===`text`?Object.defineProperty({...e},"parsed_output",{value:null,enumerable:!1}):e),parsed_output:null}:ei(e,t,n)}function ei(e,t,n){let r=null,i=e.content.map(e=>{if(e.type===`text`){let n=ti(t,e.text);return r===null&&(r=n),Object.defineProperty({...e},"parsed_output",{value:n,enumerable:!1})}return e});return{...e,content:i,parsed_output:r}}function ti(e,t){let n=Qr(e);if(n?.type!==`json_schema`)return null;try{return`parse`in n?n.parse(t):JSON.parse(t)}catch(e){throw new v(`Failed to parse structured output: ${e}`)}}var ni=e((()=>{S()}));function ri(e){return e.type===`tool_use`||e.type===`server_tool_use`}var q,J,ii,ai,oi,si,ci,li,ui,Y,di,fi,pi,X,mi,hi,gi,_i,vi,yi,bi,xi,Si,Ci,wi,Ti,Ei=e((()=>{_(),Pe(),Rn(),Qn(),Zn(),ni(),wi=`__json_buf`,Ti=class e{constructor(e,t){q.add(this),this.messages=[],this.receivedMessages=[],J.set(this,void 0),ii.set(this,null),this.controller=new AbortController,ai.set(this,void 0),oi.set(this,()=>{}),si.set(this,()=>{}),ci.set(this,void 0),li.set(this,()=>{}),ui.set(this,()=>{}),Y.set(this,{}),di.set(this,!1),fi.set(this,!1),pi.set(this,!1),X.set(this,!1),mi.set(this,void 0),hi.set(this,void 0),gi.set(this,void 0),yi.set(this,e=>{if(h(this,fi,!0,`f`),Me(e)&&(e=new b),e instanceof b)return h(this,pi,!0,`f`),this._emit(`abort`,e);if(e instanceof v)return this._emit(`error`,e);if(e instanceof Error){let t=new v(e.message);return t.cause=e,this._emit(`error`,t)}return this._emit(`error`,new v(String(e)))}),h(this,ai,new Promise((e,t)=>{h(this,oi,e,`f`),h(this,si,t,`f`)}),`f`),h(this,ci,new Promise((e,t)=>{h(this,li,e,`f`),h(this,ui,t,`f`)}),`f`),g(this,ai,`f`).catch(()=>{}),g(this,ci,`f`).catch(()=>{}),h(this,ii,e,`f`),h(this,gi,t?.logger??console,`f`)}get response(){return g(this,mi,`f`)}get request_id(){return g(this,hi,`f`)}async withResponse(){h(this,X,!0,`f`);let e=await g(this,ai,`f`);if(!e)throw Error("Could not resolve a `Response` object");return{data:this,response:e,request_id:e.headers.get(`request-id`)}}static fromReadableStream(t){let n=new e(null);return n._run(()=>n._fromReadableStream(t)),n}static createMessage(t,n,r,{logger:i}={}){let a=new e(n,{logger:i});for(let e of n.messages)a._addMessageParam(e);return h(a,ii,{...n,stream:!0},`f`),a._run(()=>a._createMessage(t,{...n,stream:!0},{...r,headers:{...r?.headers,"X-Stainless-Helper-Method":`stream`}})),a}_run(e){e().then(()=>{this._emitFinal(),this._emit(`end`)},g(this,yi,`f`))}_addMessageParam(e){this.messages.push(e)}_addMessage(e,t=!0){this.receivedMessages.push(e),t&&this._emit(`message`,e)}async _createMessage(e,t,n){let r=n?.signal,i;r&&(r.aborted&&this.controller.abort(),i=this.controller.abort.bind(this.controller),r.addEventListener(`abort`,i));try{g(this,q,`m`,bi).call(this);let{response:r,data:i}=await e.create({...t,stream:!0},{...n,signal:this.controller.signal}).withResponse();this._connected(r);for await(let e of i)g(this,q,`m`,xi).call(this,e);if(i.controller.signal?.aborted)throw new b;g(this,q,`m`,Si).call(this)}finally{r&&i&&r.removeEventListener(`abort`,i)}}_connected(e){this.ended||(h(this,mi,e,`f`),h(this,hi,e?.headers.get(`request-id`),`f`),g(this,oi,`f`).call(this,e),this._emit(`connect`))}get ended(){return g(this,di,`f`)}get errored(){return g(this,fi,`f`)}get aborted(){return g(this,pi,`f`)}abort(){this.controller.abort()}on(e,t){return(g(this,Y,`f`)[e]||(g(this,Y,`f`)[e]=[])).push({listener:t}),this}off(e,t){let n=g(this,Y,`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(g(this,Y,`f`)[e]||(g(this,Y,`f`)[e]=[])).push({listener:t,once:!0}),this}emitted(e){return new Promise((t,n)=>{h(this,X,!0,`f`),e!==`error`&&this.once(`error`,n),this.once(e,t)})}async done(){h(this,X,!0,`f`),await g(this,ci,`f`)}get currentMessage(){return g(this,J,`f`)}async finalMessage(){return await this.done(),g(this,q,`m`,_i).call(this)}async finalText(){return await this.done(),g(this,q,`m`,vi).call(this)}_emit(e,...t){if(g(this,di,`f`))return;e===`end`&&(h(this,di,!0,`f`),g(this,li,`f`).call(this));let n=g(this,Y,`f`)[e];if(n&&(g(this,Y,`f`)[e]=n.filter(e=>!e.once),n.forEach(({listener:e})=>e(...t))),e===`abort`){let e=t[0];!g(this,X,`f`)&&!n?.length&&Promise.reject(e),g(this,si,`f`).call(this,e),g(this,ui,`f`).call(this,e),this._emit(`end`);return}if(e===`error`){let e=t[0];!g(this,X,`f`)&&!n?.length&&Promise.reject(e),g(this,si,`f`).call(this,e),g(this,ui,`f`).call(this,e),this._emit(`end`)}}_emitFinal(){this.receivedMessages.at(-1)&&this._emit(`finalMessage`,g(this,q,`m`,_i).call(this))}async _fromReadableStream(e,t){let n=t?.signal,r;n&&(n.aborted&&this.controller.abort(),r=this.controller.abort.bind(this.controller),n.addEventListener(`abort`,r));try{g(this,q,`m`,bi).call(this),this._connected(null);let t=Ut.fromReadableStream(e,this.controller);for await(let e of t)g(this,q,`m`,xi).call(this,e);if(t.controller.signal?.aborted)throw new b;g(this,q,`m`,Si).call(this)}finally{n&&r&&n.removeEventListener(`abort`,r)}}[(J=new WeakMap,ii=new WeakMap,ai=new WeakMap,oi=new WeakMap,si=new WeakMap,ci=new WeakMap,li=new WeakMap,ui=new WeakMap,Y=new WeakMap,di=new WeakMap,fi=new WeakMap,pi=new WeakMap,X=new WeakMap,mi=new WeakMap,hi=new WeakMap,gi=new WeakMap,yi=new WeakMap,q=new WeakSet,_i=function(){if(this.receivedMessages.length===0)throw new v(`stream ended without producing a Message with role=assistant`);return this.receivedMessages.at(-1)},vi=function(){if(this.receivedMessages.length===0)throw new v(`stream ended without producing a Message with role=assistant`);let e=this.receivedMessages.at(-1).content.filter(e=>e.type===`text`).map(e=>e.text);if(e.length===0)throw new v(`stream ended without producing a content block with type=text`);return e.join(` `)},bi=function(){this.ended||h(this,J,void 0,`f`)},xi=function(e){if(this.ended)return;let t=g(this,q,`m`,Ci).call(this,e);switch(this._emit(`streamEvent`,e,t),e.type){case`content_block_delta`:{let n=t.content.at(-1);switch(e.delta.type){case`text_delta`:n.type===`text`&&this._emit(`text`,e.delta.text,n.text||``);break;case`citations_delta`:n.type===`text`&&this._emit(`citation`,e.delta.citation,n.citations??[]);break;case`input_json_delta`:ri(n)&&n.input&&this._emit(`inputJson`,e.delta.partial_json,n.input);break;case`thinking_delta`:n.type===`thinking`&&this._emit(`thinking`,e.delta.thinking,n.thinking);break;case`signature_delta`:n.type===`thinking`&&this._emit(`signature`,n.signature);break;default:e.delta}break}case`message_stop`:this._addMessageParam(t),this._addMessage($r(t,g(this,ii,`f`),{logger:g(this,gi,`f`)}),!0);break;case`content_block_stop`:this._emit(`contentBlock`,t.content.at(-1));break;case`message_start`:h(this,J,t,`f`);break;case`content_block_start`:case`message_delta`:break}},Si=function(){if(this.ended)throw new v(`stream has ended, this shouldn't happen`);let e=g(this,J,`f`);if(!e)throw new v(`request ended without sending any chunks`);return h(this,J,void 0,`f`),$r(e,g(this,ii,`f`),{logger:g(this,gi,`f`)})},Ci=function(e){let t=g(this,J,`f`);if(e.type===`message_start`){if(t)throw new v(`Unexpected event order, got ${e.type} before receiving "message_stop"`);return e.message}if(!t)throw new v(`Unexpected event order, got ${e.type} before "message_start"`);switch(e.type){case`message_stop`:return t;case`message_delta`:return t.stop_reason=e.delta.stop_reason,t.stop_sequence=e.delta.stop_sequence,t.usage.output_tokens=e.usage.output_tokens,e.usage.input_tokens!=null&&(t.usage.input_tokens=e.usage.input_tokens),e.usage.cache_creation_input_tokens!=null&&(t.usage.cache_creation_input_tokens=e.usage.cache_creation_input_tokens),e.usage.cache_read_input_tokens!=null&&(t.usage.cache_read_input_tokens=e.usage.cache_read_input_tokens),e.usage.server_tool_use!=null&&(t.usage.server_tool_use=e.usage.server_tool_use),t;case`content_block_start`:return t.content.push({...e.content_block}),t;case`content_block_delta`:{let n=t.content.at(e.index);switch(e.delta.type){case`text_delta`:n?.type===`text`&&(t.content[e.index]={...n,text:(n.text||``)+e.delta.text});break;case`citations_delta`:n?.type===`text`&&(t.content[e.index]={...n,citations:[...n.citations??[],e.delta.citation]});break;case`input_json_delta`:if(n&&ri(n)){let r=n[wi]||``;r+=e.delta.partial_json;let i={...n};Object.defineProperty(i,wi,{value:r,enumerable:!1,writable:!0}),r&&(i.input=Xn(r)),t.content[e.index]=i}break;case`thinking_delta`:n?.type===`thinking`&&(t.content[e.index]={...n,thinking:n.thinking+e.delta.thinking});break;case`signature_delta`:n?.type===`thinking`&&(t.content[e.index]={...n,signature:e.delta.signature});break;default:e.delta}return t}case`content_block_stop`:return t}},Symbol.asyncIterator)](){let e=[],t=[],n=!1;return this.on(`streamEvent`,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 Ut(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}}})),Di,Oi=e((()=>{j(),O(),N(),Lr(),Rn(),F(),Di=class extends A{create(e,t){return this._client.post(`/v1/messages/batches`,{body:e,...t})}retrieve(e,t){return this._client.get(P`/v1/messages/batches/${e}`,t)}list(e={},t){return this._client.getAPIList(`/v1/messages/batches`,tn,{query:e,...t})}delete(e,t){return this._client.delete(P`/v1/messages/batches/${e}`,t)}cancel(e,t){return this._client.post(P`/v1/messages/batches/${e}/cancel`,t)}async results(e,t){let n=await this.retrieve(e);if(!n.results_url)throw new v(`No batch \`results_url\`; Has it finished processing? ${n.processing_status} - ${n.id}`);return this._client.get(n.results_url,{...t,headers:M([{Accept:`application/binary`},t?.headers]),stream:!0,__binaryResponse:!0})._thenUnwrap((e,t)=>Ir.fromResponse(t.response,t.controller))}}})),ki,Ai,ji,Mi=e((()=>{j(),N(),An(),Ei(),ni(),Oi(),Bn(),ki=class extends A{constructor(){super(...arguments),this.batches=new Di(this._client)}create(e,t){e.model in Ai&&console.warn(`The model '${e.model}' is deprecated and will reach end-of-life on ${Ai[e.model]}\nPlease migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`),e.model in ji&&e.thinking&&e.thinking.type===`enabled`&&console.warn(`Using Claude with ${e.model} and 'thinking.type=enabled' is deprecated. Use 'thinking.type=adaptive' instead which results in better model performance in our testing: https://platform.claude.com/docs/en/build-with-claude/adaptive-thinking`);let n=this._client._options.timeout;if(!e.stream&&n==null){let t=zn[e.model]??void 0;n=this._client.calculateNonstreamingTimeout(e.max_tokens,t)}let r=Dn(e.tools,e.messages);return this._client.post(`/v1/messages`,{body:e,timeout:n??6e5,...t,headers:M([r,t?.headers]),stream:e.stream??!1})}parse(e,t){return this.create(e,t).then(t=>ei(t,e,{logger:this._client.logger??console}))}stream(e,t){return Ti.createMessage(this,e,t,{logger:this._client.logger??console})}countTokens(e,t){return this._client.post(`/v1/messages/count_tokens`,{body:e,...t})}},Ai={"claude-1.3":`November 6th, 2024`,"claude-1.3-100k":`November 6th, 2024`,"claude-instant-1.1":`November 6th, 2024`,"claude-instant-1.1-100k":`November 6th, 2024`,"claude-instant-1.2":`November 6th, 2024`,"claude-3-sonnet-20240229":`July 21st, 2025`,"claude-3-opus-20240229":`January 5th, 2026`,"claude-2.1":`July 21st, 2025`,"claude-2.0":`July 21st, 2025`,"claude-3-7-sonnet-latest":`February 19th, 2026`,"claude-3-7-sonnet-20250219":`February 19th, 2026`,"claude-3-5-haiku-latest":`February 19th, 2026`,"claude-3-5-haiku-20241022":`February 19th, 2026`},ji=[`claude-opus-4-6`],ki.Batches=Di})),Ni,Pi=e((()=>{j(),O(),N(),F(),Ni=class extends A{retrieve(e,t={},n){let{betas:r}=t??{};return this._client.get(P`/v1/models/${e}`,{...n,headers:M([{...r?.toString()==null?void 0:{"anthropic-beta":r?.toString()}},n?.headers])})}list(e={},t){let{betas:n,...r}=e??{};return this._client.getAPIList(`/v1/models`,tn,{query:r,...t,headers:M([{...n?.toString()==null?void 0:{"anthropic-beta":n?.toString()}},t?.headers])})}}})),Fi=e((()=>{Sn(),Yr(),Zr(),Mi(),Pi()})),Ii,Li=e((()=>{Ii=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()}})),Ri,zi,Bi,Vi,Hi,Ui,Z,Wi,Gi=e((()=>{_(),je(),$e(),tt(),Pe(),dt(),_t(),yt(),xt(),nt(),S(),O(),xn(),Fi(),Zt(),Zr(),Pi(),Yr(),Mi(),N(),Li(),Rt(),Hi=`\\n\\nHuman:`,Ui=`\\n\\nAssistant:`,Z=class{constructor({baseURL:e=Ii(`ANTHROPIC_BASE_URL`),apiKey:t=Ii(`ANTHROPIC_API_KEY`)??null,authToken:n=Ii(`ANTHROPIC_AUTH_TOKEN`)??null,...r}={}){Ri.add(this),Bi.set(this,void 0);let i={apiKey:t,authToken:n,...r,baseURL:e||`https://api.anthropic.com`};if(!i.dangerouslyAllowBrowser&&at())throw new v(`It looks like you're running in a browser-like environment.
29
+
30
+ This is disabled by default, as it risks exposing your secret API credentials to attackers.
31
+ If you understand the risks and have appropriate mitigations in place,
32
+ you can set the \`dangerouslyAllowBrowser\` option to \`true\`, e.g.,
33
+
34
+ new Anthropic({ apiKey, dangerouslyAllowBrowser: true });
35
+ `);this.baseURL=i.baseURL,this.timeout=i.timeout??zi.DEFAULT_TIMEOUT,this.logger=i.logger??console;let a=`warn`;this.logLevel=a,this.logLevel=Ft(i.logLevel,`ClientOptions.logLevel`,this)??Ft(Ii(`ANTHROPIC_LOG`),`process.env['ANTHROPIC_LOG']`,this)??a,this.fetchOptions=i.fetchOptions,this.maxRetries=i.maxRetries??2,this.fetch=i.fetch??ft(),h(this,Bi,vt,`f`),this._options=i,this.apiKey=typeof t==`string`?t:null,this.authToken=n}withOptions(e){return new this.constructor({...this._options,baseURL:this.baseURL,maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,apiKey:this.apiKey,authToken:this.authToken,...e})}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:e,nulls:t}){if(!(e.get(`x-api-key`)||e.get(`authorization`))&&!(this.apiKey&&e.get(`x-api-key`))&&!t.has(`x-api-key`)&&!(this.authToken&&e.get(`authorization`))&&!t.has(`authorization`))throw Error(`Could not resolve authentication method. Expected either apiKey or authToken to be set. Or for one of the "X-Api-Key" or "Authorization" headers to be explicitly omitted`)}async authHeaders(e){return M([await this.apiKeyAuth(e),await this.bearerAuth(e)])}async apiKeyAuth(e){if(this.apiKey!=null)return M([{"X-Api-Key":this.apiKey}])}async bearerAuth(e){if(this.authToken!=null)return M([{Authorization:`Bearer ${this.authToken}`}])}stringifyQuery(e){return bt(e)}getUserAgent(){return`${this.constructor.name}/JS ${C}`}defaultIdempotencyKey(){return`stainless-node-retry-${Ae()}`}makeStatusError(e,t,n,r){return y.generate(e,t,n,r)}buildURL(e,t,n){let r=!g(this,Ri,`m`,Vi).call(this)&&n||this.baseURL,i=Je(e)?new URL(e):new URL(r+(r.endsWith(`/`)&&e.startsWith(`/`)?e.slice(1):e)),a=this.defaultQuery(),o=Object.fromEntries(i.searchParams);return(!Ge(a)||!Ge(o))&&(t={...o,...a,...t}),typeof t==`object`&&t&&!Array.isArray(t)&&(i.search=this.stringifyQuery(t)),i.toString()}_calculateNonstreamingTimeout(e){if(3600*e/128e3>600)throw new v(`Streaming is required for operations that may take longer than 10 minutes. See https://github.com/anthropics/anthropic-sdk-typescript#streaming-responses for more details`);return 600*1e3}async prepareOptions(e){}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 Xt(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});let c=`log_`+(Math.random()*(1<<24)|0).toString(16).padStart(6,`0`),l=n===void 0?``:`, retryOf: ${n}`,u=Date.now();if(E(this).debug(`[${c}] sending request`,D({retryOfRequestLogID:n,method:r.method,url:o,options:r,headers:a.headers})),r.signal?.aborted)throw new b;let ee=new AbortController,d=await this.fetchWithTimeout(o,a,s,ee).catch(Ne),f=Date.now();if(d instanceof globalThis.Error){let e=`retrying, ${t} attempts remaining`;if(r.signal?.aborted)throw new b;let i=Me(d)||/timed? ?out/i.test(String(d)+(`cause`in d?String(d.cause):``));if(t)return E(this).info(`[${c}] connection ${i?`timed out`:`failed`} - ${e}`),E(this).debug(`[${c}] connection ${i?`timed out`:`failed`} (${e})`,D({retryOfRequestLogID:n,url:o,durationMs:f-u,message:d.message})),this.retryRequest(r,t,n??c);throw E(this).info(`[${c}] connection ${i?`timed out`:`failed`} - error; no more retries left`),E(this).debug(`[${c}] connection ${i?`timed out`:`failed`} (error; no more retries left)`,D({retryOfRequestLogID:n,url:o,durationMs:f-u,message:d.message})),i?new Fe:new x({cause:d})}let p=`[${c}${l}${[...d.headers.entries()].filter(([e])=>e===`request-id`).map(([e,t])=>`, `+e+`: `+JSON.stringify(t)).join(``)}] ${a.method} ${o} ${d.ok?`succeeded`:`failed`} with status ${d.status} in ${f-u}ms`;if(!d.ok){let e=await this.shouldRetry(d);if(t&&e){let e=`retrying, ${t} attempts remaining`;return await gt(d.body),E(this).info(`${p} - ${e}`),E(this).debug(`[${c}] response error (${e})`,D({retryOfRequestLogID:n,url:d.url,status:d.status,headers:d.headers,durationMs:f-u})),this.retryRequest(r,t,n??c,d.headers)}let i=e?`error; no more retries left`:`error; not retryable`;E(this).info(`${p} - ${i}`);let a=await d.text().catch(e=>Ne(e).message),o=Qe(a),s=o?void 0:a;throw E(this).debug(`[${c}] response error (${i})`,D({retryOfRequestLogID:n,url:d.url,status:d.status,headers:d.headers,message:s,durationMs:Date.now()-u})),this.makeStatusError(d.status,o,s,d.headers)}return E(this).info(p),E(this).debug(`[${c}] response start`,D({retryOfRequestLogID:n,url:d.url,status:d.status,headers:d.headers,durationMs:f-u})),{response:d,options:r,controller:ee,requestLogID:c,retryOfRequestLogID:n,startTime:u}}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 en(this,n,e)}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 et(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}calculateNonstreamingTimeout(e,t){let n=600*1e3;if(36e5*e/128e3>n||t!=null&&e>t)throw new v(`Streaming is required for operations that may take longer than 10 minutes. See https://github.com/anthropics/anthropic-sdk-typescript#long-requests for more details`);return n}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&&Ze(`timeout`,n.timeout),n.timeout=n.timeout??this.timeout;let{bodyHeaders:c,body:l}=this.buildBody({options:n});return{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=M([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))}:{},...ut(),...this._options.dangerouslyAllowBrowser?{"anthropic-dangerous-direct-browser-access":`true`}:void 0,"anthropic-version":`2023-06-01`},await this.authHeaders(e),this._options.defaultHeaders,n,e.headers]);return this.validateHeaders(a),a.values}_makeAbort(e){return()=>e.abort()}buildBody({options:{body:e,headers:t}}){if(!e)return{bodyHeaders:void 0,body:void 0};let n=M([t]);return ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof DataView||typeof e==`string`&&n.values.has(`content-type`)||globalThis.Blob&&e instanceof globalThis.Blob||e instanceof FormData||e instanceof URLSearchParams||globalThis.ReadableStream&&e instanceof globalThis.ReadableStream?{bodyHeaders:void 0,body:e}:typeof e==`object`&&(Symbol.asyncIterator in e||Symbol.iterator in e&&`next`in e&&typeof e.next==`function`)?{bodyHeaders:void 0,body:mt(e)}:typeof e==`object`&&n.values.get(`content-type`)===`application/x-www-form-urlencoded`?{bodyHeaders:{"content-type":`application/x-www-form-urlencoded`},body:this.stringifyQuery(e)}:g(this,Bi,`f`).call(this,{body:e,headers:n})}},zi=Z,Bi=new WeakMap,Ri=new WeakSet,Vi=function(){return this.baseURL!==`https://api.anthropic.com`},Z.Anthropic=zi,Z.HUMAN_PROMPT=Hi,Z.AI_PROMPT=Ui,Z.DEFAULT_TIMEOUT=6e5,Z.AnthropicError=v,Z.APIError=y,Z.APIConnectionError=x,Z.APIConnectionTimeoutError=Fe,Z.APIUserAbortError=b,Z.NotFoundError=ze,Z.ConflictError=Be,Z.RateLimitError=He,Z.BadRequestError=Ie,Z.AuthenticationError=Le,Z.InternalServerError=Ue,Z.PermissionDeniedError=Re,Z.UnprocessableEntityError=Ve,Z.toFile=mn,Wi=class extends Z{constructor(){super(...arguments),this.completions=new Xr(this),this.messages=new ki(this),this.models=new Ni(this),this.beta=new K(this)}},Wi.Completions=Xr,Wi.Messages=ki,Wi.Models=Ni,Wi.Beta=K})),Ki=e((()=>{Gi(),xn(),Zt(),O(),S()}));function qi(e){return e instanceof aa||e instanceof b||e instanceof Error&&e.name===`AbortError`}function Ji(e,t){return e instanceof Error&&e.message===t}function Yi(e){return e instanceof Error?e:Error(String(e))}function Xi(e){return e instanceof Error?e.message:String(e)}function Zi(e){if(e&&typeof e==`object`&&`code`in e&&typeof e.code==`string`)return e.code}function Qi(e){return Zi(e)===`ENOENT`}function $i(e){if(e&&typeof e==`object`&&`path`in e&&typeof e.path==`string`)return e.path}function ea(e,t=5){if(!(e instanceof Error))return String(e);if(!e.stack)return e.message;let n=e.stack.split(`
36
+ `),r=n[0]??e.message,i=n.slice(1).filter(e=>e.trim().startsWith(`at `));return i.length<=t?e.stack:[r,...i.slice(0,t)].join(`
37
+ `)}function ta(e){let t=Zi(e);return t===`ENOENT`||t===`EACCES`||t===`EPERM`||t===`ENOTDIR`||t===`ELOOP`}function na(e){let t=Xi(e);if(!e||typeof e!=`object`||!(`isAxiosError`in e)||!e.isAxiosError)return{kind:`other`,message:t};let n=e,r=n.response?.status;return r===401||r===403?{kind:`auth`,status:r,message:t}:n.code===`ECONNABORTED`?{kind:`timeout`,status:r,message:t}:n.code===`ECONNREFUSED`||n.code===`ENOTFOUND`?{kind:`network`,status:r,message:t}:{kind:`http`,status:r,message:t}}var ra,ia,aa,oa,sa,ca,la,ua=e((()=>{Ki(),s(),ra=class extends Error{constructor(e){super(e),this.name=this.constructor.name}},ia=class extends Error{},aa=class extends Error{constructor(e){super(e),this.name=`AbortError`}},oa=class extends Error{constructor(e,t,n){super(e),c(this,`filePath`,void 0),c(this,`defaultConfig`,void 0),this.name=`ConfigParseError`,this.filePath=t,this.defaultConfig=n}},sa=class extends Error{constructor(e,t,n,r){super(`Shell command failed`),c(this,`stdout`,void 0),c(this,`stderr`,void 0),c(this,`code`,void 0),c(this,`interrupted`,void 0),this.stdout=e,this.stderr=t,this.code=n,this.interrupted=r,this.name=`ShellError`}},ca=class extends Error{constructor(e,t){super(e),c(this,`formattedMessage`,void 0),this.formattedMessage=t,this.name=`TeleportOperationError`}},la=class extends Error{constructor(e,t){super(e),c(this,`telemetryMessage`,void 0),this.name=`TelemetrySafeError`,this.telemetryMessage=t??e}}}));function da(){return ha}function fa(e,t,n){return Q`JSON.stringify(${e})`,JSON.stringify(e,t,n)}function pa(e,t){return Q`structuredClone(${e})`,structuredClone(e,t)}function ma(e,t,n){if(Q`fs.writeFileSync(${e}, ${t})`,typeof n==`object`&&n&&`flush`in n&&n.flush===!0){let r=typeof n==`object`&&`encoding`in n?n.encoding:void 0,i=typeof n==`object`&&`mode`in n?n.mode:void 0,a;try{a=oe(e,`w`,i),se(a,t,{encoding:r??void 0}),ae(a)}finally{a!==void 0&&ie(a)}}else se(e,t,n)}var ha,Q,ga,_a=e((()=>{l(),Za(),(()=>{let e=process.env.CLAUDE_CODE_SLOW_OPERATION_THRESHOLD_MS;if(e!==void 0){let t=Number(e);if(!Number.isNaN(t)&&t>=0)return t}return 1/0})(),ha={[Symbol.dispose](){}},Q=da,ga=(e,t)=>(Q`JSON.parse(${e})`,t===void 0?JSON.parse(e):JSON.parse(e,t))}));function va(){var e=typeof SuppressedError==`function`?SuppressedError:function(e,t){var n=Error();return n.name=`SuppressedError`,n.error=e,n.suppressed=t,n},t={},n=[];function r(e,t){if(t!=null){if(Object(t)!==t)throw TypeError(`using declarations can only be used with objects, functions, null, or undefined.`);if(e)var r=t[Symbol.asyncDispose||Symbol.for(`Symbol.asyncDispose`)];if(r===void 0&&(r=t[Symbol.dispose||Symbol.for(`Symbol.dispose`)],e))var i=r;if(typeof r!=`function`)throw TypeError(`Object is not disposable.`);i&&(r=function(){try{i.call(t)}catch(e){return Promise.reject(e)}}),n.push({v:t,d:r,a:e})}else e&&n.push({d:t,a:e});return t}return{e:t,u:r.bind(null,!1),a:r.bind(null,!0),d:function(){var r,i=this.e,a=0;function o(){for(;r=n.pop();)try{if(!r.a&&a===1)return a=0,n.push(r),Promise.resolve().then(o);if(r.d){var e=r.d.call(r.v);if(r.a)return a|=2,Promise.resolve(e).then(o,s)}else a|=1}catch(e){return s(e)}if(a===1)return i===t?Promise.resolve():Promise.reject(i);if(i!==t)throw i}function s(n){return i=i===t?n:new e(n,i),o()}return o()}}}var ya=e((()=>{}));function ba(e,t){if(t.startsWith(`//`)||t.startsWith(`\\\\`))return{resolvedPath:t,isSymlink:!1,isCanonical:!1};try{let n=e.lstatSync(t);if(n.isFIFO()||n.isSocket()||n.isCharacterDevice()||n.isBlockDevice())return{resolvedPath:t,isSymlink:!1,isCanonical:!1};let r=e.realpathSync(t);return{resolvedPath:r,isSymlink:r!==t,isCanonical:!0}}catch{return{resolvedPath:t,isSymlink:!1,isCanonical:!1}}}function xa(e,t,n){let{resolvedPath:r}=ba(e,t);return n.has(r)?!0:(n.add(r),!1)}function Sa(e,t){let n=t,r=[];for(;n!==p.dirname(n);){let t;try{t=e.lstatSync(n)}catch{r.unshift(p.basename(n)),n=p.dirname(n);continue}if(t.isSymbolicLink())try{let t=e.realpathSync(n);return r.length===0?t:p.join(t,...r)}catch{let t=e.readlinkSync(n),i=p.isAbsolute(t)?t:p.resolve(p.dirname(n),t);return r.length===0?i:p.join(i,...r)}try{let t=e.realpathSync(n);if(t!==n)return r.length===0?t:p.join(t,...r)}catch{}return}}function Ca(e){let t=e;t===`~`?t=f().normalize(`NFC`):t.startsWith(`~/`)&&(t=p.join(f().normalize(`NFC`),t.slice(2)));let n=new Set,r=wa();if(n.add(t),t.startsWith(`//`)||t.startsWith(`\\\\`))return Array.from(n);try{let e=t,i=new Set;for(let a=0;a<40&&!i.has(e);a++){if(i.add(e),!r.existsSync(e)){if(e===t){let e=Sa(r,t);e!==void 0&&n.add(e)}break}let a=r.lstatSync(e);if(a.isFIFO()||a.isSocket()||a.isCharacterDevice()||a.isBlockDevice()||!a.isSymbolicLink())break;let o=r.readlinkSync(e),s=p.isAbsolute(o)?o:p.resolve(p.dirname(e),o);n.add(s),e=s}}catch{}let{resolvedPath:i,isSymlink:a}=ba(r,t);return a&&i!==t&&n.add(i),Array.from(n)}function wa(){return ka}async function Ta(e,t,n){try{var r=va();let i=r.a(await ue(e,`r`)),a=(await i.stat()).size;if(a<=t)return null;let o=Math.min(a-t,n),s=Buffer.allocUnsafe(o),c=0;for(;c<o;){let{bytesRead:e}=await i.read(s,c,o-c,t+c);if(e===0)break;c+=e}return{content:s.toString(`utf8`,0,c),bytesRead:c,bytesTotal:a}}catch(e){r.e=e}finally{await r.d()}}async function Ea(e,t){try{var n=va();let r=n.a(await ue(e,`r`)),i=(await r.stat()).size;if(i===0)return{content:``,bytesRead:0,bytesTotal:0};let a=Math.max(0,i-t),o=i-a,s=Buffer.allocUnsafe(o),c=0;for(;c<o;){let{bytesRead:e}=await r.read(s,c,o-c,a+c);if(e===0)break;c+=e}return{content:s.toString(`utf8`,0,c),bytesRead:c,bytesTotal:i}}catch(e){n.e=e}finally{await n.d()}}async function*Da(e){let t=1024*4,n=await ue(e,`r`);try{let e=(await n.stat()).size,r=Buffer.alloc(0),i=Buffer.alloc(t);for(;e>0;){let a=Math.min(t,e);e-=a,await n.read(i,0,a,e);let o=Buffer.concat([i.subarray(0,a),r]),s=o.indexOf(10);if(s===-1){r=o;continue}r=Buffer.from(o.subarray(0,s));let c=o.toString(`utf8`,s+1).split(`
38
+ `);for(let e=c.length-1;e>=0;e--){let t=c[e];t&&(yield t)}}r.length>0&&(yield r.toString(`utf8`))}finally{await n.close()}}var Oa,ka,Aa=e((()=>{ua(),_a(),ya(),Oa={cwd(){return process.cwd()},existsSync(e){return Q`fs.existsSync(${e})`,m.existsSync(e)},async stat(e){return ge(e)},async readdir(e){return fe(e,{withFileTypes:!0})},async unlink(e){return ve(e)},async rmdir(e){return he(e)},async rm(e,t){return me(e,t)},async mkdir(e,t){try{await le(e,{recursive:!0,...t})}catch(e){if(Zi(e)!==`EEXIST`)throw e}},async readFile(e,t){return de(e,{encoding:t.encoding})},async rename(e,t){return pe(e,t)},statSync(e){return Q`fs.statSync(${e})`,m.statSync(e)},lstatSync(e){return Q`fs.lstatSync(${e})`,m.lstatSync(e)},readFileSync(e,t){return Q`fs.readFileSync(${e})`,m.readFileSync(e,{encoding:t.encoding})},readFileBytesSync(e){return Q`fs.readFileBytesSync(${e})`,m.readFileSync(e)},readSync(e,t){Q`fs.readSync(${e}, ${t.length} bytes)`;let n;try{n=m.openSync(e,`r`);let r=Buffer.alloc(t.length);return{buffer:r,bytesRead:m.readSync(n,r,0,t.length,0)}}finally{n&&m.closeSync(n)}},appendFileSync(e,t,n){if(Q`fs.appendFileSync(${e}, ${t.length} chars)`,n?.mode!==void 0)try{let r=m.openSync(e,`ax`,n.mode);try{m.appendFileSync(r,t)}finally{m.closeSync(r)}return}catch(e){if(Zi(e)!==`EEXIST`)throw e}m.appendFileSync(e,t)},copyFileSync(e,t){Q`fs.copyFileSync(${e} → ${t})`,m.copyFileSync(e,t)},unlinkSync(e){Q`fs.unlinkSync(${e})`,m.unlinkSync(e)},renameSync(e,t){Q`fs.renameSync(${e} → ${t})`,m.renameSync(e,t)},linkSync(e,t){Q`fs.linkSync(${e} → ${t})`,m.linkSync(e,t)},symlinkSync(e,t,n){Q`fs.symlinkSync(${e} → ${t})`,m.symlinkSync(e,t,n)},readlinkSync(e){return Q`fs.readlinkSync(${e})`,m.readlinkSync(e)},realpathSync(e){return Q`fs.realpathSync(${e})`,m.realpathSync(e).normalize(`NFC`)},mkdirSync(e,t){Q`fs.mkdirSync(${e})`;let n={recursive:!0};t?.mode!==void 0&&(n.mode=t.mode);try{m.mkdirSync(e,n)}catch(e){if(Zi(e)!==`EEXIST`)throw e}},readdirSync(e){return Q`fs.readdirSync(${e})`,m.readdirSync(e,{withFileTypes:!0})},readdirStringSync(e){return Q`fs.readdirStringSync(${e})`,m.readdirSync(e)},isDirEmptySync(e){return Q`fs.isDirEmptySync(${e})`,this.readdirSync(e).length===0},rmdirSync(e){Q`fs.rmdirSync(${e})`,m.rmdirSync(e)},rmSync(e,t){Q`fs.rmSync(${e})`,m.rmSync(e,t)},createWriteStream(e){return m.createWriteStream(e)},async readFileBytes(e,t){if(t===void 0)return de(e);let n=await ue(e,`r`);try{let{size:e}=await n.stat(),r=Math.min(e,t),i=Buffer.allocUnsafe(r),a=0;for(;a<r;){let{bytesRead:e}=await n.read(i,a,r-a,a);if(e===0)break;a+=e}return a<r?i.subarray(0,a):i}finally{await n.close()}}},ka=Oa})),ja=t({flushDebugLogs:()=>Ra,getDebugFilePath:()=>qa,getDebugFilter:()=>Ga,getDebugLogPath:()=>Ba,getHasFormattedOutput:()=>Pa,getMinDebugLogLevel:()=>Ua,isDebugMode:()=>Wa,isDebugToStdErr:()=>Ka,logAntError:()=>Va,logForDebugging:()=>za,setHasFormattedOutput:()=>Na});function Ma(e){return!Wa()||typeof process>`u`||process.versions===void 0||process.versions.node===void 0?!1:De(e,Ga())}function Na(e){Ja=e}function Pa(){return Ja}async function Fa(e,t,n,r){e&&await le(t,{recursive:!0}).catch(()=>{}),await ce(n,r),Xa()}function Ia(){}function La(){if(!$){let e=null;$=ye({writeFn:t=>{let n=Ba(),r=te(n),i=e!==r;if(e=r,Wa()){if(i)try{wa().mkdirSync(r)}catch{}try{wa().appendFileSync(n,t)}catch{try{wa().mkdirSync(r),wa().appendFileSync(n,t)}catch{}}Xa();return}Ya=Ya.then(Fa.bind(null,i,r,n,t)).catch(Ia)},flushIntervalMs:1e3,maxBufferSize:100,immediateMode:Wa()}),xe(async()=>{$?.dispose(),await Ya})}return $}async function Ra(){$?.flush(),await Ya}function za(e,{level:t}={level:`debug`}){if(Ha[t]<Ha[Ua()]||!Ma(e))return;Ja&&e.includes(`
39
+ `)&&(e=fa(e));let n=`${new Date().toISOString()} [${t.toUpperCase()}] ${e.trim()}\n`;if(Ka()){ee(n);return}La().write(n)}function Ba(){return qa()??(process.env.CLAUDE_CODE_DEBUG_LOGS_DIR?re(process.env.CLAUDE_CODE_DEBUG_LOGS_DIR):null)??ne(a(),`debug`,`${u()}.txt`)}function Va(e,t){t instanceof Error&&t.stack&&za(`[ANT-ONLY] ${e} stack trace:\n${t.stack}`,{level:`error`})}var Ha,Ua,Wa,Ga,Ka,qa,Ja,$,Ya,Xa,Za=e((()=>{r(),l(),be(),we(),ke(),o(),Aa(),d(),_a(),Ha={verbose:0,debug:1,info:2,warn:3,error:4},Ua=n(()=>{let e=process.env.CLAUDE_CODE_DEBUG_LOG_LEVEL?.toLowerCase().trim();return e&&Object.hasOwn(Ha,e)?e:`debug`}),Wa=n(()=>i(process.env.DEBUG)||i(process.env.DEBUG_SDK)||process.argv.includes(`--debug`)||process.argv.includes(`-d`)||Ka()||process.argv.some(e=>e.startsWith(`--debug=`))||qa()!==null),Ga=n(()=>{let e=process.argv.find(e=>e.startsWith(`--debug=`));return e?Oe(e.substring(8)):null}),Ka=n(()=>process.argv.includes(`--debug-to-stderr`)),qa=n(()=>{for(let e=0;e<process.argv.length;e++){let t=process.argv[e];if(t.startsWith(`--debug-file=`))return re(t.substring(13));if(t===`--debug-file`&&e+1<process.argv.length)return re(process.argv[e+1])}return null}),Ja=!1,$=null,Ya=Promise.resolve(),Xa=n(async()=>{try{let e=Ba(),t=ne(te(e),`latest`);await ve(t).catch(()=>{}),await _e(e,t)}catch{}})}));export{ze as $,sa as A,Qi as B,fa as C,ra as D,aa as E,Zi as F,Wi as G,ea as H,$i as I,x as J,Gi as K,Ji as L,ca as M,na as N,oa as O,Xi as P,Le as Q,ua as R,ga as S,ma as T,Yi as U,ta as V,Ki as W,y as X,Fe as Y,b as Z,Ea as _,Wa as a,be as at,pa as b,za as c,Ca as d,S as et,Aa as f,ba as g,Da as h,Za as i,ye as it,la as j,ia as k,Na as l,Ta as m,Ba as n,xe as nt,Ka as o,xa as p,Rn as q,Pa as r,Se as rt,Va as s,ja as t,we as tt,wa as u,va as v,Q as w,_a as x,ya as y,qi as z};
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{F as t,S as n,a as r,l as i,w as a,z as o}from"./debug-BdqxZ7rV.js";import{n as s,r as c}from"./analytics-DJobLaWP.js";function l(e){return e.replace(_,(e,t,n)=>n.length<v?`"${t}":"[REDACTED]"`:`"${t}":"${`${n.slice(0,8)}...${n.slice(-4)}`}"`)}function u(e){let t=e.replace(/\n/g,`\\n`);return t.length<=g?t:t.slice(0,g)+`... (${t.length} chars)`}function d(e){let t=l(typeof e==`string`?e:a(e));return t.length<=g?t:t.slice(0,g)+`... (${t.length} chars)`}function f(e){let n=t(e);if(e&&typeof e==`object`&&`response`in e){let t=e.response;if(t?.data&&typeof t.data==`object`){let e=t.data,r=typeof e.message==`string`?e.message:typeof e.error==`object`&&e.error&&`message`in e.error&&typeof e.error.message==`string`?e.error.message:void 0;if(r)return`${n}: ${r}`}}return n}function p(e){if(e&&typeof e==`object`&&`response`in e&&e.response&&typeof e.response.status==`number`)return e.response.status}function m(e){if(!(!e||typeof e!=`object`)){if(`message`in e&&typeof e.message==`string`)return e.message;if(`error`in e&&e.error!==null&&typeof e.error==`object`&&`message`in e.error&&typeof e.error.message==`string`)return e.error.message}}function h(e,t,n){t&&i(t),c(`tengu_bridge_repl_skipped`,{reason:e,...n!==void 0&&{v2:n}})}var g,_,v,y=e((()=>{s(),r(),o(),n(),g=2e3,_=RegExp(`"(${[`session_ingress_token`,`environment_secret`,`access_token`,`secret`,`token`].join(`|`)})"\\s*:\\s*"([^"]*)"`,`g`),v=16}));export{p as a,m as i,u as n,y as o,f as r,h as s,d as t};
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{C as t,P as n,R as r,c as i,i as a,x as o}from"./debug-BecbSVoN.js";import{n as s,r as c}from"./analytics-DJobLaWP.js";function l(e){return e.replace(_,(e,t,n)=>n.length<v?`"${t}":"[REDACTED]"`:`"${t}":"${`${n.slice(0,8)}...${n.slice(-4)}`}"`)}function u(e){let t=e.replace(/\n/g,`\\n`);return t.length<=g?t:t.slice(0,g)+`... (${t.length} chars)`}function d(e){let n=l(typeof e==`string`?e:t(e));return n.length<=g?n:n.slice(0,g)+`... (${n.length} chars)`}function f(e){let t=n(e);if(e&&typeof e==`object`&&`response`in e){let n=e.response;if(n?.data&&typeof n.data==`object`){let e=n.data,r=typeof e.message==`string`?e.message:typeof e.error==`object`&&e.error&&`message`in e.error&&typeof e.error.message==`string`?e.error.message:void 0;if(r)return`${t}: ${r}`}}return t}function p(e){if(e&&typeof e==`object`&&`response`in e&&e.response&&typeof e.response.status==`number`)return e.response.status}function m(e){if(!(!e||typeof e!=`object`)){if(`message`in e&&typeof e.message==`string`)return e.message;if(`error`in e&&e.error!==null&&typeof e.error==`object`&&`message`in e.error&&typeof e.error.message==`string`)return e.error.message}}function h(e,t,n){t&&i(t),c(`tengu_bridge_repl_skipped`,{reason:e,...n!==void 0&&{v2:n}})}var g,_,v,y=e((()=>{s(),a(),r(),o(),g=2e3,_=RegExp(`"(${[`session_ingress_token`,`environment_secret`,`access_token`,`secret`,`token`].join(`|`)})"\\s*:\\s*"([^"]*)"`,`g`),v=16}));export{p as a,m as i,u as n,y as o,f as r,h as s,d as t};
@@ -1,4 +1,4 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./defineProperty-C-QyHrDq.js";import{i as r,o as i,t as a}from"./cliLaunch-BWWOgBFh.js";import{dirname as o}from"path";import{closeSync as s,createReadStream as c,mkdirSync as l,openSync as u,readSync as d,statSync as f,unwatchFile as p,watchFile as m}from"fs";import{createInterface as h}from"readline";async function g(e){let t=0;try{if(t=f(e).size,t>0){let n=h({input:c(e,{start:0,end:t-1})});for await(let e of n)process.stdout.write(e+`
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./defineProperty-C-QyHrDq.js";import{i as r,o as i,t as a}from"./cliLaunch-BTpfAGGI.js";import{dirname as o}from"path";import{closeSync as s,createReadStream as c,mkdirSync as l,openSync as u,readSync as d,statSync as f,unwatchFile as p,watchFile as m}from"fs";import{createInterface as h}from"readline";async function g(e){let t=0;try{if(t=f(e).size,t>0){let n=h({input:c(e,{start:0,end:t-1})});for await(let e of n)process.stdout.write(e+`
2
2
  `)}}catch{}return console.log(`
3
3
  [tail] Watching for new output... (Ctrl+C to detach)
4
4
  `),new Promise(n=>{let r=()=>{p(e),process.removeListener(`SIGINT`,r),console.log(`
@@ -0,0 +1 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./cwd-Cfdf7z7s.js";import{c as r,i}from"./debug-BecbSVoN.js";import{m as a,u as o}from"./git-DBlOv64X.js";function s(){p.clear()}async function c(){let e=await l();return!e||e.host!==`github.com`?null:`${e.owner}/${e.name}`}async function l(){let e=n();if(p.has(e))return p.get(e)??null;try{let t=await o();if(r(`Git remote URL: ${t}`),!t)return r(`No git remote URL found`),p.set(e,null),null;let n=u(t);return r(`Parsed repository: ${n?`${n.host}/${n.owner}/${n.name}`:null} from URL: ${t}`),p.set(e,n),n}catch(t){return r(`Error detecting repository: ${t}`),p.set(e,null),null}}function u(e){let t=e.trim(),n=t.match(/^git@([^:]+):([^/]+)\/([^/]+?)(?:\.git)?$/);if(n?.[1]&&n[2]&&n[3])return f(n[1])?{host:n[1],owner:n[2],name:n[3]}:null;let r=t.match(/^(https?|ssh|git):\/\/(?:[^@]+@)?([^/:]+(?::\d+)?)\/([^/]+)\/([^/]+?)(?:\.git)?$/);if(r?.[1]&&r[2]&&r[3]&&r[4]){let e=r[1],t=r[2],n=t.split(`:`)[0]??``;return f(n)?{host:e===`https`||e===`http`?t:n,owner:r[3],name:r[4]}:null}return null}function d(e){let t=e.trim(),n=u(t);if(n)return n.host===`github.com`?`${n.owner}/${n.name}`:null;if(!t.includes(`://`)&&!t.includes(`@`)&&t.includes(`/`)){let e=t.split(`/`);if(e.length===2&&e[0]&&e[1]){let t=e[1].replace(/\.git$/,``);return`${e[0]}/${t}`}}return r(`Could not parse repository from: ${t}`),null}function f(e){if(!e.includes(`.`))return!1;let t=e.split(`.`).pop();return t?/^[a-zA-Z]+$/.test(t):!1}var p,m=e((()=>{t(),i(),a(),p=new Map}));export{d as a,m as i,c as n,u as o,l as r,s as t};
@@ -0,0 +1 @@
1
+ import{a as e,i as t,o as n}from"./detectRepository-C15umvKN.js";t();export{e as parseGitHubRepository,n as parseGitRemote};
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{t}from"./jsx-runtime-Bb4Xn-E0.js";var n,r;e((()=>{n=t(),r=async(e,t)=>{let{DiffDialog:r}=await import(`./DiffDialog-BIcwpgSr.js`);return(0,n.jsx)(r,{messages:t.messages,onDone:e})}}))();export{r as call};
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{t}from"./jsx-runtime-Bb4Xn-E0.js";var n,r;e((()=>{n=t(),r=async(e,t)=>{let{DiffDialog:r}=await import(`./DiffDialog-DUbFrzKu.js`);return(0,n.jsx)(r,{messages:t.messages,onDone:e})}}))();export{r as call};
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./cwd-L4wygFqJ.js";import{d as r,p as i}from"./debug-BdqxZ7rV.js";import{ar as a,sr as o}from"./settings-Xbq6AaD-.js";import{o as s,s as c}from"./log-CTFl4qpD.js";import{a as l,i as u}from"./memoize-FJv2HV1u.js";import{basename as d,dirname as f,join as p,sep as m}from"path";function h(e,t){if(!e)return{directory:t||n(),prefix:``};let r=a(e,t);return e.endsWith(`/`)||e.endsWith(m)?{directory:r,prefix:``}:{directory:f(r),prefix:d(e)}}async function g(e){let t=C.get(e);if(t)return t;try{let t=(await r().readdir(e)).filter(e=>e.isDirectory()&&!e.name.startsWith(`.`)).map(t=>({name:t.name,path:p(e,t.name),type:`directory`})).slice(0,100);return C.set(e,t),t}catch(e){return c(e),[]}}async function _(e,t={}){let{basePath:r=n(),maxResults:i=10}=t,{directory:a,prefix:o}=h(e,r),s=await g(a),c=o.toLowerCase();return s.filter(e=>e.name.toLowerCase().startsWith(c)).slice(0,i).map(e=>({id:e.path,displayText:e.name+`/`,description:`directory`,metadata:{type:`directory`}}))}function v(e){return e.startsWith(`~/`)||e.startsWith(`/`)||e.startsWith(`./`)||e.startsWith(`../`)||e===`~`||e===`.`||e===`..`}async function y(e,t=!1){let n=`${e}:${t}`,i=w.get(n);if(i)return i;try{let i=(await r().readdir(e)).filter(e=>t||!e.name.startsWith(`.`)).map(t=>({name:t.name,path:p(e,t.name),type:t.isDirectory()?`directory`:`file`})).sort((e,t)=>e.type===`directory`&&t.type!==`directory`?-1:e.type!==`directory`&&t.type===`directory`?1:e.name.localeCompare(t.name)).slice(0,100);return w.set(n,i),i}catch(e){return c(e),[]}}async function b(e,t={}){let{basePath:r=n(),maxResults:i=10,includeFiles:a=!0,includeHidden:o=!1}=t,{directory:s,prefix:c}=h(e,r),l=await y(s,o),u=c.toLowerCase(),d=l.filter(e=>!a&&e.type===`file`?!1:e.name.toLowerCase().startsWith(u)).slice(0,i),f=e.includes(`/`)||e.includes(m),p=``;if(f){let t=e.lastIndexOf(`/`),n=e.lastIndexOf(m),r=Math.max(t,n);p=e.substring(0,r+1)}return(p.startsWith(`./`)||p.startsWith(`.`+m))&&(p=p.slice(2)),d.map(e=>{let t=p+e.name;return{id:t,displayText:e.type===`directory`?t+`/`:t,metadata:{type:e.type}}})}var x,S,C,w,T=e((()=>{l(),t(),i(),s(),o(),x=500,S=300*1e3,C=new u({max:x,ttl:S}),w=new u({max:x,ttl:S})}));export{v as i,b as n,T as r,_ as t};
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./cwd-Cfdf7z7s.js";import{f as r,u as i}from"./debug-BecbSVoN.js";import{cr as a,or as o}from"./settings-D4CpDv2y.js";import{o as s,s as c}from"./log-Dauqle-Z.js";import{a as l,i as u}from"./memoize-FeyE7JEh.js";import{basename as d,dirname as f,join as p,sep as m}from"path";function h(e,t){if(!e)return{directory:t||n(),prefix:``};let r=o(e,t);return e.endsWith(`/`)||e.endsWith(m)?{directory:r,prefix:``}:{directory:f(r),prefix:d(e)}}async function g(e){let t=C.get(e);if(t)return t;try{let t=(await i().readdir(e)).filter(e=>e.isDirectory()&&!e.name.startsWith(`.`)).map(t=>({name:t.name,path:p(e,t.name),type:`directory`})).slice(0,100);return C.set(e,t),t}catch(e){return c(e),[]}}async function _(e,t={}){let{basePath:r=n(),maxResults:i=10}=t,{directory:a,prefix:o}=h(e,r),s=await g(a),c=o.toLowerCase();return s.filter(e=>e.name.toLowerCase().startsWith(c)).slice(0,i).map(e=>({id:e.path,displayText:e.name+`/`,description:`directory`,metadata:{type:`directory`}}))}function v(e){return e.startsWith(`~/`)||e.startsWith(`/`)||e.startsWith(`./`)||e.startsWith(`../`)||e===`~`||e===`.`||e===`..`}async function y(e,t=!1){let n=`${e}:${t}`,r=w.get(n);if(r)return r;try{let r=(await i().readdir(e)).filter(e=>t||!e.name.startsWith(`.`)).map(t=>({name:t.name,path:p(e,t.name),type:t.isDirectory()?`directory`:`file`})).sort((e,t)=>e.type===`directory`&&t.type!==`directory`?-1:e.type!==`directory`&&t.type===`directory`?1:e.name.localeCompare(t.name)).slice(0,100);return w.set(n,r),r}catch(e){return c(e),[]}}async function b(e,t={}){let{basePath:r=n(),maxResults:i=10,includeFiles:a=!0,includeHidden:o=!1}=t,{directory:s,prefix:c}=h(e,r),l=await y(s,o),u=c.toLowerCase(),d=l.filter(e=>!a&&e.type===`file`?!1:e.name.toLowerCase().startsWith(u)).slice(0,i),f=e.includes(`/`)||e.includes(m),p=``;if(f){let t=e.lastIndexOf(`/`),n=e.lastIndexOf(m),r=Math.max(t,n);p=e.substring(0,r+1)}return(p.startsWith(`./`)||p.startsWith(`.`+m))&&(p=p.slice(2)),d.map(e=>{let t=p+e.name;return{id:t,displayText:e.type===`directory`?t+`/`:t,metadata:{type:e.type}}})}var x,S,C,w,T=e((()=>{l(),t(),r(),s(),a(),x=500,S=300*1e3,C=new u({max:x,ttl:S}),w=new u({max:x,ttl:S})}));export{v as i,b as n,T as r,_ as t};
@@ -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"./Doctor-Dz4TuYas.js";var i,a;e((()=>{n(),i=t(),a=(e,t,n)=>Promise.resolve((0,i.jsx)(r,{onDone:e}))}))();export{a as call};
@@ -0,0 +1 @@
1
+ import{r as e}from"./earlyInput-IghoCjG5.js";export{e as startCapturingEarlyInput};
@@ -1,2 +1,2 @@
1
- import{c as e,s as t}from"./intl-cKc-V6Mq.js";t();var n=``,r=!1,i=null,a=null;function o(){if(!(!process.stdin.isTTY||r||process.argv.includes(`-p`)||process.argv.includes(`--print`))){r=!0,n=``;try{process.stdin.setEncoding(`utf8`),process.stdin.setRawMode(!0),process.stdin.ref(),i=()=>{let e=process.stdin.read();for(;e!==null;)typeof e==`string`&&s(e),e=process.stdin.read()},process.stdin.on(`readable`,i),a=setTimeout(()=>{r&&c()},1e4),a&&typeof a==`object`&&`unref`in a&&a.unref()}catch{r=!1}}}function s(t){let r=0;for(;r<t.length;){let i=t[r],a=i.charCodeAt(0);if(a===3){c(),process.exit(130);return}if(a===4){c();return}if(a===127||a===8){if(n.length>0){let t=e(n);n=n.slice(0,-(t.length||1))}r++;continue}if(a===27){if(r++,r>=t.length)continue;let e=t.charCodeAt(r);if(e===91){for(r++;r<t.length&&t.charCodeAt(r)>=32&&t.charCodeAt(r)<=63;)r++;r<t.length&&t.charCodeAt(r)>=64&&t.charCodeAt(r)<=126&&r++;continue}if(e===80||e===93||e===88||e===94){for(r++;r<t.length;){if(t.charCodeAt(r)===7){r++;break}if(t.charCodeAt(r)===27&&r+1<t.length&&t.charCodeAt(r+1)===92){r+=2;break}r++}continue}r<t.length&&r++;continue}if(a<32&&a!==9&&a!==10&&a!==13){r++;continue}if(a===13){n+=`
1
+ import{o as e,s as t}from"./intl-D2kgJmX7.js";e();var n=``,r=!1,i=null,a=null;function o(){if(!(!process.stdin.isTTY||r||process.argv.includes(`-p`)||process.argv.includes(`--print`))){r=!0,n=``;try{process.stdin.setEncoding(`utf8`),process.stdin.setRawMode(!0),process.stdin.ref(),i=()=>{let e=process.stdin.read();for(;e!==null;)typeof e==`string`&&s(e),e=process.stdin.read()},process.stdin.on(`readable`,i),a=setTimeout(()=>{r&&c()},1e4),a&&typeof a==`object`&&`unref`in a&&a.unref()}catch{r=!1}}}function s(e){let r=0;for(;r<e.length;){let i=e[r],a=i.charCodeAt(0);if(a===3){c(),process.exit(130);return}if(a===4){c();return}if(a===127||a===8){if(n.length>0){let e=t(n);n=n.slice(0,-(e.length||1))}r++;continue}if(a===27){if(r++,r>=e.length)continue;let t=e.charCodeAt(r);if(t===91){for(r++;r<e.length&&e.charCodeAt(r)>=32&&e.charCodeAt(r)<=63;)r++;r<e.length&&e.charCodeAt(r)>=64&&e.charCodeAt(r)<=126&&r++;continue}if(t===80||t===93||t===88||t===94){for(r++;r<e.length;){if(e.charCodeAt(r)===7){r++;break}if(e.charCodeAt(r)===27&&r+1<e.length&&e.charCodeAt(r+1)===92){r+=2;break}r++}continue}r<e.length&&r++;continue}if(a<32&&a!==9&&a!==10&&a!==13){r++;continue}if(a===13){n+=`
2
2
  `,r++;continue}n+=i,r++}}function c(){if(r){r=!1,a&&(clearTimeout(a),a=null),i&&(process.stdin.removeListener(`readable`,i),i=null);try{process.stdin.unref()}catch{}}}function l(){c();let e=n.trim();return n=``,e}function u(e){n=e}export{c as i,u as n,o as r,l as t};
@@ -0,0 +1,14 @@
1
+ import{n as e,t}from"./defineProperty-C-QyHrDq.js";import{Bi as n,Cf as r,Cr as i,Eu as a,Fi as o,Sf as s,Tb as c,Tu as l,U as u,W as d,cr as f,ec as p,el as m,i as h,kb as g,o as _,tc as v,tl as ee}from"./loadAgentsDir-BL93ulMm.js";import{A as y,C as b,M as x,O as S,P as C,b as w,j as T,l as te,m as E,p as D,v as O,w as k}from"./external-CEp-aPkt.js";import{r as ne}from"./lazySchema-B4D4qJVE.js";import{Bn as re,Wt as A,_r as ie,et as ae,gr as oe,ht as se,or as j}from"./state-BemZdQIl.js";import{f as ce,g as le}from"./settings-D4CpDv2y.js";import{h as ue,r as de}from"./config-aRiTrtCv.js";import{l as fe,p as M,r as pe}from"./sessionStoragePortable-JZnGwqUM.js";import{_ as me,u as he}from"./model-Bgh_r4lg.js";import{bn as ge,yn as _e}from"./prompt-Dx7IWhBt.js";import{n as ve,r as ye}from"./managedEnv-DJSCuqCb.js";import{t as be}from"./QueryEngine-Dt0BKUeF.js";import{n as xe,t as Se}from"./modelOptions-BtEZe5BB.js";import{dirname as Ce}from"node:path";import{randomUUID as N}from"node:crypto";import{Readable as we,Writable as Te}from"node:stream";import{unlink as Ee}from"node:fs/promises";import*as P from"node:path/posix";import{isAbsolute as De,resolve as Oe}from"node:path/posix";ne();var F={authenticate:`authenticate`,document_did_change:`document/didChange`,document_did_close:`document/didClose`,document_did_focus:`document/didFocus`,document_did_open:`document/didOpen`,document_did_save:`document/didSave`,initialize:`initialize`,logout:`logout`,nes_accept:`nes/accept`,nes_close:`nes/close`,nes_reject:`nes/reject`,nes_start:`nes/start`,nes_suggest:`nes/suggest`,session_cancel:`session/cancel`,session_close:`session/close`,session_fork:`session/fork`,session_list:`session/list`,session_load:`session/load`,session_new:`session/new`,session_prompt:`session/prompt`,session_resume:`session/resume`,session_set_config_option:`session/set_config_option`,session_set_mode:`session/set_mode`,session_set_model:`session/set_model`},I={elicitation_complete:`elicitation/complete`,elicitation_create:`elicitation/create`,fs_read_text_file:`fs/read_text_file`,fs_write_text_file:`fs/write_text_file`,session_request_permission:`session/request_permission`,session_update:`session/update`,terminal_create:`terminal/create`,terminal_kill:`terminal/kill`,terminal_output:`terminal/output`,terminal_release:`terminal/release`,terminal_wait_for_exit:`terminal/wait_for_exit`},ke=k({_meta:S(y(),x()).nullish(),terminal:E().optional().default(!1)}),Ae=k({_meta:S(y(),x()).nullish(),label:y().nullish(),name:y(),optional:E().optional().default(!1),secret:E().optional().default(!0)}),je=k({_meta:S(y(),x()).nullish(),description:y().nullish(),id:y(),name:y()}),Me=k({_meta:S(y(),x()).nullish(),description:y().nullish(),id:y(),link:y().nullish(),name:y(),vars:D(Ae)}),Ne=k({_meta:S(y(),x()).nullish(),args:D(y()).optional(),description:y().nullish(),env:S(y(),y()).optional(),id:y(),name:y()}),Pe=T([Me.and(k({type:w(`env_var`)})),Ne.and(k({type:w(`terminal`)})),je]),Fe=k({_meta:S(y(),x()).nullish(),methodId:y()}),Ie=k({_meta:S(y(),x()).nullish()}),Le=k({_meta:S(y(),x()).nullish(),blob:y(),mimeType:y().nullish(),uri:y()}),Re=k({default:E().nullish(),description:y().nullish(),title:y().nullish()}),ze=k({_meta:S(y(),x()).nullish()}),Be=k({_meta:S(y(),x()).nullish()}),Ve=k({amount:b(),currency:y()}),He=k({_meta:S(y(),x()).nullish(),terminalId:y()}),Ue=k({_meta:S(y(),x()).nullish(),newText:y(),oldText:y().nullish(),path:y()}),We=T([y(),b(),b(),E(),D(y())]),Ge=O(T([k({content:S(y(),We).nullish()}).and(k({action:w(`accept`)})),k({action:w(`decline`)}),k({action:w(`cancel`)})]),k({_meta:S(y(),x()).nullish()})),Ke=k({_meta:S(y(),x()).nullish()}),qe=y(),Je=k({_meta:S(y(),x()).nullish(),elicitationId:qe}),Ye=w(`object`),Xe=w(`string`),Ze=k({_meta:S(y(),x()).nullish()}),Qe=k({_meta:S(y(),x()).nullish(),form:Ke.nullish(),url:Ze.nullish()}),$e=k({const:y(),title:y()}),et=k({_meta:S(y(),x()).nullish(),name:y(),value:y()}),tt=k({code:T([w(-32700),w(-32600),w(-32601),w(-32602),w(-32603),w(-32800),w(-32e3),w(-32002),w(-32042),b().int().min(-2147483648,{message:`Invalid value: Expected int32 to be >= -2147483648`}).max(2147483647,{message:`Invalid value: Expected int32 to be <= 2147483647`})]),data:x().optional(),message:y()}),nt=x(),rt=x(),it=x(),at=k({_meta:S(y(),x()).nullish(),readTextFile:E().optional().default(!1),writeTextFile:E().optional().default(!1)}),ot=k({_meta:S(y(),x()).nullish(),name:y(),value:y()}),st=k({_meta:S(y(),x()).nullish(),name:y(),title:y().nullish(),version:y()}),ct=k({default:b().nullish(),description:y().nullish(),maximum:b().nullish(),minimum:b().nullish(),title:y().nullish()}),lt=k({_meta:S(y(),x()).nullish()}),ut=k({_meta:S(y(),x()).nullish(),additionalDirectories:D(y()).optional(),cursor:y().nullish(),cwd:y().nullish()}),dt=k({_meta:S(y(),x()).nullish()}),ft=k({_meta:S(y(),x()).nullish(),logout:dt.nullish()}),pt=k({_meta:S(y(),x()).nullish()}),mt=k({_meta:S(y(),x()).nullish()}),ht=k({_meta:S(y(),x()).nullish(),http:E().optional().default(!1),sse:E().optional().default(!1)}),gt=k({_meta:S(y(),x()).nullish(),headers:D(ot),name:y(),url:y()}),_t=k({_meta:S(y(),x()).nullish(),headers:D(ot),name:y(),url:y()}),vt=k({_meta:S(y(),x()).nullish(),args:D(y()),command:y(),env:D(et),name:y()}),L=T([gt.and(k({type:w(`http`)})),_t.and(k({type:w(`sse`)})),vt]),yt=y(),bt=k({_meta:S(y(),x()).nullish(),description:y().nullish(),modelId:yt,name:y()}),xt=T([w(`error`),w(`warning`),w(`information`),w(`hint`)]),St=k({_meta:S(y(),x()).nullish()}),Ct=k({_meta:S(y(),x()).nullish()}),wt=k({_meta:S(y(),x()).nullish()}),Tt=k({_meta:S(y(),x()).nullish()}),Et=k({_meta:S(y(),x()).nullish()}),Dt=k({_meta:S(y(),x()).nullish(),maxCount:b().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish()}),Ot=k({diff:y(),uri:y()}),kt=k({endLine:b().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}),startLine:b().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}),text:y()}),At=k({_meta:S(y(),x()).nullish()}),jt=k({_meta:S(y(),x()).nullish()}),Mt=k({languageId:y(),text:y(),uri:y()}),Nt=k({_meta:S(y(),x()).nullish(),maxCount:b().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish()}),Pt=T([w(`rejected`),w(`ignored`),w(`replaced`),w(`cancelled`)]),Ft=k({excerpts:D(kt),uri:y()}),It=k({_meta:S(y(),x()).nullish()}),Lt=k({_meta:S(y(),x()).nullish()}),Rt=k({name:y(),owner:y(),remoteUrl:y()}),zt=k({_meta:S(y(),x()).nullish()}),Bt=k({_meta:S(y(),x()).nullish(),jump:At.nullish(),rename:Lt.nullish(),searchAndReplace:zt.nullish()}),Vt=k({id:y(),isRegex:E().nullish(),replace:y(),search:y(),uri:y()}),Ht=T([w(`automatic`),w(`diagnostic`),w(`manual`)]),Ut=k({_meta:S(y(),x()).nullish(),maxCount:b().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish()}),Wt=k({_meta:S(y(),x()).nullish(),diagnostics:St.nullish(),editHistory:Dt.nullish(),openFiles:jt.nullish(),recentFiles:Nt.nullish(),relatedSnippets:It.nullish(),userActions:Ut.nullish()}),Gt=k({_meta:S(y(),x()).nullish(),additionalDirectories:D(y()).optional(),cwd:y(),mcpServers:D(L)}),Kt=k({default:b().nullish(),description:y().nullish(),maximum:b().nullish(),minimum:b().nullish(),title:y().nullish()}),qt=y(),Jt=T([w(`allow_once`),w(`allow_always`),w(`reject_once`),w(`reject_always`)]),Yt=k({_meta:S(y(),x()).nullish(),kind:Jt,name:y(),optionId:qt}),Xt=T([w(`high`),w(`medium`),w(`low`)]),Zt=T([w(`pending`),w(`in_progress`),w(`completed`)]),Qt=k({_meta:S(y(),x()).nullish(),content:y(),priority:Xt,status:Zt}),$t=k({_meta:S(y(),x()).nullish(),entries:D(Qt)}),R=k({character:b().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}),line:b().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`})}),en=k({id:y(),position:R,uri:y()}),tn=k({id:y(),newName:y(),position:R,uri:y()}),nn=k({action:y(),position:R,timestampMs:b(),uri:y()}),rn=T([w(`utf-16`),w(`utf-32`),w(`utf-8`)]),an=k({_meta:S(y(),x()).nullish(),auth:ke.optional().default({terminal:!1}),elicitation:Qe.nullish(),fs:at.optional().default({readTextFile:!1,writeTextFile:!1}),nes:Bt.nullish(),positionEncodings:D(rn).optional(),terminal:E().optional().default(!1)}),on=k({_meta:S(y(),x()).nullish(),audio:E().optional().default(!1),embeddedContext:E().optional().default(!1),image:E().optional().default(!1)}),sn=b().int().gte(0).lte(65535),cn=k({_meta:S(y(),x()).nullish(),clientCapabilities:an.optional().default({auth:{terminal:!1},fs:{readTextFile:!1,writeTextFile:!1},terminal:!1}),clientInfo:st.nullish(),protocolVersion:sn}),z=k({end:R,start:R}),ln=k({message:y(),range:z,severity:xt,uri:y()}),un=k({languageId:y(),lastFocusedMs:b().nullish(),uri:y(),visibleRange:z.nullish()}),dn=k({_meta:S(y(),x()).nullish(),diagnostics:D(ln).nullish(),editHistory:D(Ot).nullish(),openFiles:D(un).nullish(),recentFiles:D(Mt).nullish(),relatedSnippets:D(Ft).nullish(),userActions:D(nn).nullish()}),fn=k({newText:y(),range:z}),pn=T([k({cursorPosition:R.nullish(),edits:D(fn),id:y(),uri:y()}).and(k({kind:w(`edit`)})),en.and(k({kind:w(`jump`)})),tn.and(k({kind:w(`rename`)})),Vt.and(k({kind:w(`searchAndReplace`)}))]),mn=k({_meta:S(y(),x()).nullish(),content:y()}),hn=k({_meta:S(y(),x()).nullish()}),B=T([b(),y()]).nullable();k({_meta:S(y(),x()).nullish(),requestId:B});var gn=k({requestId:B}),_n=te([`assistant`,`user`]),V=k({_meta:S(y(),x()).nullish(),audience:D(_n).nullish(),lastModified:y().nullish(),priority:b().nullish()}),vn=k({_meta:S(y(),x()).nullish(),annotations:V.nullish(),data:y(),mimeType:y()}),yn=k({_meta:S(y(),x()).nullish(),annotations:V.nullish(),data:y(),mimeType:y(),uri:y().nullish()}),bn=k({_meta:S(y(),x()).nullish(),annotations:V.nullish(),description:y().nullish(),mimeType:y().nullish(),name:y(),size:b().nullish(),title:y().nullish(),uri:y()}),xn=k({_meta:S(y(),x()).nullish(),optionId:qt}),Sn=T([k({outcome:w(`cancelled`)}),xn.and(k({outcome:w(`selected`)}))]),Cn=k({_meta:S(y(),x()).nullish(),outcome:Sn}),wn=k({_meta:S(y(),x()).nullish()}),Tn=k({_meta:S(y(),x()).nullish()}),En=k({currentValue:E()}),Dn=y(),On=y(),kn=T([w(`mode`),w(`model`),w(`thought_level`),y()]),An=y(),jn=k({_meta:S(y(),x()).nullish(),description:y().nullish(),name:y(),value:An}),Mn=k({_meta:S(y(),x()).nullish(),group:Dn,name:y(),options:D(jn)}),H=O(T([k({currentValue:An,options:T([D(jn),D(Mn)])}).and(k({type:w(`select`)})),En.and(k({type:w(`boolean`)}))]),k({_meta:S(y(),x()).nullish(),category:kn.nullish(),description:y().nullish(),id:On,name:y()})),Nn=k({_meta:S(y(),x()).nullish(),configOptions:D(H)}),Pn=k({_meta:S(y(),x()).nullish()}),U=y(),Fn=k({_meta:S(y(),x()).nullish(),id:y(),sessionId:U}),In=k({_meta:S(y(),x()).nullish(),sessionId:U}),Ln=k({_meta:S(y(),x()).nullish(),sessionId:U}),Rn=k({_meta:S(y(),x()).nullish(),sessionId:U}),zn=k({_meta:S(y(),x()).nullish(),args:D(y()).optional(),command:y(),cwd:y().nullish(),env:D(et).optional(),outputByteLimit:b().nullish(),sessionId:U}),Bn=k({_meta:S(y(),x()).nullish(),sessionId:U,uri:y()}),Vn=k({_meta:S(y(),x()).nullish(),position:R,sessionId:U,uri:y(),version:b(),visibleRange:z}),Hn=k({_meta:S(y(),x()).nullish(),languageId:y(),sessionId:U,text:y(),uri:y(),version:b()}),Un=k({_meta:S(y(),x()).nullish(),sessionId:U,uri:y()}),Wn=k({_meta:S(y(),x()).nullish(),additionalDirectories:D(y()).optional(),cwd:y(),mcpServers:D(L).optional(),sessionId:U}),Gn=k({_meta:S(y(),x()).nullish(),sessionId:U,terminalId:y()}),Kn=k({_meta:S(y(),x()).nullish(),additionalDirectories:D(y()).optional(),cwd:y(),mcpServers:D(L),sessionId:U}),qn=k({_meta:S(y(),x()).nullish(),limit:b().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),line:b().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),path:y(),sessionId:U}),Jn=k({_meta:S(y(),x()).nullish(),id:y(),reason:Pt.nullish(),sessionId:U}),Yn=k({_meta:S(y(),x()).nullish(),sessionId:U,terminalId:y()}),Xn=k({_meta:S(y(),x()).nullish(),additionalDirectories:D(y()).optional(),cwd:y(),mcpServers:D(L).optional(),sessionId:U}),Zn=k({_meta:S(y(),x()).nullish(),additionalDirectories:D(y()).optional(),cwd:y(),sessionId:U,title:y().nullish(),updatedAt:y().nullish()}),Qn=k({_meta:S(y(),x()).nullish(),nextCursor:y().nullish(),sessions:D(Zn)}),$n=k({_meta:S(y(),x()).nullish(),title:y().nullish(),updatedAt:y().nullish()}),er=k({_meta:S(y(),x()).nullish()}),W=y(),tr=k({_meta:S(y(),x()).nullish(),currentModeId:W}),nr=k({_meta:S(y(),x()).nullish(),description:y().nullish(),id:W,name:y()}),G=k({_meta:S(y(),x()).nullish(),availableModes:D(nr),currentModeId:W}),K=k({_meta:S(y(),x()).nullish(),availableModels:D(bt),currentModelId:yt}),rr=k({_meta:S(y(),x()).nullish(),configOptions:D(H).nullish(),models:K.nullish(),modes:G.nullish(),sessionId:U}),ir=k({_meta:S(y(),x()).nullish(),configOptions:D(H).nullish(),models:K.nullish(),modes:G.nullish()}),ar=k({_meta:S(y(),x()).nullish(),configOptions:D(H).nullish(),models:K.nullish(),modes:G.nullish(),sessionId:U}),or=k({_meta:S(y(),x()).nullish(),configOptions:D(H).nullish(),models:K.nullish(),modes:G.nullish()}),sr=k({_meta:S(y(),x()).nullish()}),cr=k({_meta:S(y(),x()).nullish(),additionalDirectories:wn.nullish(),close:Tn.nullish(),fork:Pn.nullish(),list:er.nullish(),resume:sr.nullish()}),lr=O(T([k({type:w(`boolean`),value:E()}),k({value:An})]),k({_meta:S(y(),x()).nullish(),configId:On,sessionId:U})),ur=k({_meta:S(y(),x()).nullish(),configOptions:D(H)}),dr=k({_meta:S(y(),x()).nullish(),modeId:W,sessionId:U}),fr=k({_meta:S(y(),x()).nullish()}),pr=k({_meta:S(y(),x()).nullish(),modelId:yt,sessionId:U}),mr=k({_meta:S(y(),x()).nullish()}),hr=k({_meta:S(y(),x()).nullish(),sessionId:U}),gr=T([w(`end_turn`),w(`max_tokens`),w(`max_turn_requests`),w(`refusal`),w(`cancelled`)]),_r=T([w(`email`),w(`uri`),w(`date`),w(`date-time`)]),vr=k({default:y().nullish(),description:y().nullish(),enum:D(y()).nullish(),format:_r.nullish(),maxLength:b().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),minLength:b().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),oneOf:D($e).nullish(),pattern:y().nullish(),title:y().nullish()}),yr=k({_meta:S(y(),x()).nullish(),context:dn.nullish(),position:R,selection:z.nullish(),sessionId:U,triggerKind:Ht,uri:y(),version:b()}),br=k({_meta:S(y(),x()).nullish(),suggestions:D(pn)}),xr=k({_meta:S(y(),x()).nullish(),terminalId:y()}),Sr=k({_meta:S(y(),x()).nullish(),exitCode:b().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),signal:y().nullish()}),Cr=k({_meta:S(y(),x()).nullish(),sessionId:U,terminalId:y()}),wr=k({_meta:S(y(),x()).nullish(),exitStatus:Sr.nullish(),output:y(),truncated:E()}),Tr=k({_meta:S(y(),x()).nullish(),annotations:V.nullish(),text:y()}),Er=k({range:z.nullish(),text:y()}),Dr=k({_meta:S(y(),x()).nullish(),contentChanges:D(Er),sessionId:U,uri:y(),version:b()});k({method:y(),params:T([In,Hn,Dr,Bn,Un,Vn,Fn,Jn,nt]).nullish()});var Or=T([w(`full`),w(`incremental`)]),kr=k({_meta:S(y(),x()).nullish(),syncKind:Or}),Ar=k({_meta:S(y(),x()).nullish(),didChange:kr.nullish(),didClose:Ct.nullish(),didFocus:wt.nullish(),didOpen:Tt.nullish(),didSave:Et.nullish()}),jr=k({_meta:S(y(),x()).nullish(),document:Ar.nullish()}),Mr=k({_meta:S(y(),x()).nullish(),context:Wt.nullish(),events:jr.nullish()}),Nr=k({_meta:S(y(),x()).nullish(),auth:ft.optional().default({}),loadSession:E().optional().default(!1),mcpCapabilities:ht.optional().default({http:!1,sse:!1}),nes:Mr.nullish(),positionEncoding:rn.nullish(),promptCapabilities:on.optional().default({audio:!1,embeddedContext:!1,image:!1}),sessionCapabilities:cr.optional().default({})}),Pr=k({_meta:S(y(),x()).nullish(),agentCapabilities:Nr.optional().default({auth:{},loadSession:!1,mcpCapabilities:{http:!1,sse:!1},promptCapabilities:{audio:!1,embeddedContext:!1,image:!1},sessionCapabilities:{}}),agentInfo:st.nullish(),authMethods:D(Pe).optional().default([]),protocolVersion:sn}),Fr=T([k({_meta:S(y(),x()).nullish(),mimeType:y().nullish(),text:y(),uri:y()}),Le]),Ir=k({_meta:S(y(),x()).nullish(),annotations:V.nullish(),resource:Fr}),Lr=T([Tr.and(k({type:w(`text`)})),yn.and(k({type:w(`image`)})),vn.and(k({type:w(`audio`)})),bn.and(k({type:w(`resource_link`)})),Ir.and(k({type:w(`resource`)}))]),Rr=k({_meta:S(y(),x()).nullish(),content:Lr}),zr=k({_meta:S(y(),x()).nullish(),content:Lr,messageId:y().nullish()}),Br=k({_meta:S(y(),x()).nullish(),messageId:y().nullish(),prompt:D(Lr),sessionId:U}),Vr=k({anyOf:D($e)}),Hr=T([Rr.and(k({type:w(`content`)})),Ue.and(k({type:w(`diff`)})),xr.and(k({type:w(`terminal`)}))]),Ur=y(),Wr=k({sessionId:U,toolCallId:Ur.nullish()}),Gr=O(T([Wr,gn]),k({elicitationId:qe,url:y().url()})),Kr=k({_meta:S(y(),x()).nullish(),line:b().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),path:y()}),qr=T([w(`pending`),w(`in_progress`),w(`completed`),w(`failed`)]),Jr=T([w(`read`),w(`edit`),w(`delete`),w(`move`),w(`search`),w(`execute`),w(`think`),w(`fetch`),w(`switch_mode`),w(`other`)]),Yr=k({_meta:S(y(),x()).nullish(),content:D(Hr).optional(),kind:Jr.optional(),locations:D(Kr).optional(),rawInput:x().optional(),rawOutput:x().optional(),status:qr.optional(),title:y(),toolCallId:Ur}),Xr=k({_meta:S(y(),x()).nullish(),content:D(Hr).nullish(),kind:Jr.nullish(),locations:D(Kr).nullish(),rawInput:x().optional(),rawOutput:x().optional(),status:qr.nullish(),title:y().nullish(),toolCallId:Ur}),Zr=k({_meta:S(y(),x()).nullish(),options:D(Yt),sessionId:U,toolCall:Xr}),Qr=k({_meta:S(y(),x()).nullish(),hint:y()}),$r=k({_meta:S(y(),x()).nullish(),description:y(),input:Qr.nullish(),name:y()}),ei=k({_meta:S(y(),x()).nullish(),availableCommands:D($r)}),ti=T([k({enum:D(y()),type:Xe}),Vr]),ni=k({default:D(y()).nullish(),description:y().nullish(),items:ti,maxItems:b().nullish(),minItems:b().nullish(),title:y().nullish()}),ri=T([vr.and(k({type:w(`string`)})),Kt.and(k({type:w(`number`)})),ct.and(k({type:w(`integer`)})),Re.and(k({type:w(`boolean`)})),ni.and(k({type:w(`array`)}))]),ii=k({description:y().nullish(),properties:S(y(),ri).optional().default({}),required:D(y()).nullish(),title:y().nullish(),type:Ye.optional().default(`object`)}),ai=O(T([O(T([Wr,gn]),k({requestedSchema:ii})).and(k({mode:w(`form`)})),Gr.and(k({mode:w(`url`)}))]),k({_meta:S(y(),x()).nullish(),message:y()})),oi=k({cachedReadTokens:b().nullish(),cachedWriteTokens:b().nullish(),inputTokens:b(),outputTokens:b(),thoughtTokens:b().nullish(),totalTokens:b()});T([k({id:B,result:T([Pr,Ie,mt,ar,ir,Qn,rr,or,Be,fr,ur,k({_meta:S(y(),x()).nullish(),stopReason:gr,usage:oi.nullish(),userMessageId:y().nullish()}),mr,hr,br,ze,it])}),k({error:tt,id:B})]);var si=k({_meta:S(y(),x()).nullish(),cost:Ve.nullish(),size:b(),used:b()}),ci=T([zr.and(k({sessionUpdate:w(`user_message_chunk`)})),zr.and(k({sessionUpdate:w(`agent_message_chunk`)})),zr.and(k({sessionUpdate:w(`agent_thought_chunk`)})),Yr.and(k({sessionUpdate:w(`tool_call`)})),Xr.and(k({sessionUpdate:w(`tool_call_update`)})),$t.and(k({sessionUpdate:w(`plan`)})),ei.and(k({sessionUpdate:w(`available_commands_update`)})),tr.and(k({sessionUpdate:w(`current_mode_update`)})),Nn.and(k({sessionUpdate:w(`config_option_update`)})),$n.and(k({sessionUpdate:w(`session_info_update`)})),si.and(k({sessionUpdate:w(`usage_update`)}))]),li=k({_meta:S(y(),x()).nullish(),sessionId:U,update:ci});k({method:y(),params:T([li,Je,nt]).nullish()});var ui=k({_meta:S(y(),x()).nullish(),sessionId:U,terminalId:y()}),di=k({_meta:S(y(),x()).nullish(),exitCode:b().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),signal:y().nullish()}),fi=k({name:y(),uri:y()}),pi=k({_meta:S(y(),x()).nullish(),repository:Rt.nullish(),workspaceFolders:D(fi).nullish(),workspaceUri:y().nullish()});k({id:B,method:y(),params:T([cn,Fe,pt,Gt,Kn,ut,Wn,Xn,Rn,dr,lr,Br,pr,pi,yr,Ln,rt]).nullish()});var mi=k({_meta:S(y(),x()).nullish(),content:y(),path:y(),sessionId:U});k({id:B,method:y(),params:T([mi,qn,Zr,zn,Cr,Yn,ui,Gn,ai,rt]).nullish()}),T([k({id:B,result:T([k({_meta:S(y(),x()).nullish()}),mn,Cn,He,wr,hn,di,lt,Ge,it])}),k({error:tt,id:B})]),e();function hi(e,t){let n=new TextEncoder,r=new TextDecoder;return{readable:new ReadableStream({async start(e){let n=``,i=t.getReader();try{for(;;){let{value:t,done:a}=await i.read();if(a){n+=r.decode();break}if(!t)continue;n+=r.decode(t,{stream:!0});let o=n.split(`
2
+ `);n=o.pop()||``;for(let t of o){let n=t.trim();if(n)try{let t=JSON.parse(n);e.enqueue(t)}catch(e){console.error(`Failed to parse JSON message:`,n,e)}}}let t=n.trim();if(t)try{let n=JSON.parse(t);e.enqueue(n)}catch(e){console.error(`Failed to parse JSON message:`,t,e)}}catch(t){e.error(t);return}finally{i.releaseLock()}e.close()}}),writable:new WritableStream({async write(t){let r=JSON.stringify(t)+`
3
+ `,i=e.getWriter();try{await i.write(n.encode(r))}finally{i.releaseLock()}}})}}ne();var gi,_i=class{constructor(e,n){t(this,`connection`,void 0);let r=e(this),i=async(e,t)=>{switch(e){case F.initialize:{let e=cn.parse(t);return r.initialize(e)}case F.session_new:{let e=Gt.parse(t);return r.newSession(e)}case F.session_load:{if(!r.loadSession)throw q.methodNotFound(e);let n=Kn.parse(t);return r.loadSession(n)}case F.session_list:{if(!r.listSessions)throw q.methodNotFound(e);let n=ut.parse(t);return r.listSessions(n)}case F.session_fork:{if(!r.unstable_forkSession)throw q.methodNotFound(e);let n=Wn.parse(t);return r.unstable_forkSession(n)}case F.session_resume:{if(!r.unstable_resumeSession)throw q.methodNotFound(e);let n=Xn.parse(t);return r.unstable_resumeSession(n)}case F.session_close:{if(!r.unstable_closeSession)throw q.methodNotFound(e);let n=Rn.parse(t);return r.unstable_closeSession(n)}case F.session_set_mode:{if(!r.setSessionMode)throw q.methodNotFound(e);let n=dr.parse(t);return await r.setSessionMode(n)??{}}case F.authenticate:{let e=Fe.parse(t);return await r.authenticate(e)??{}}case F.logout:{if(!r.unstable_logout)throw q.methodNotFound(e);let n=pt.parse(t);return await r.unstable_logout(n)??{}}case F.session_prompt:{let e=Br.parse(t);return r.prompt(e)}case F.session_set_model:{if(!r.unstable_setSessionModel)throw q.methodNotFound(e);let n=pr.parse(t);return await r.unstable_setSessionModel(n)??{}}case F.session_set_config_option:{if(!r.setSessionConfigOption)throw q.methodNotFound(e);let n=lr.parse(t);return r.setSessionConfigOption(n)}case F.nes_start:{if(!r.unstable_startNes)throw q.methodNotFound(e);let n=pi.parse(t);return r.unstable_startNes(n)}case F.nes_suggest:{if(!r.unstable_suggestNes)throw q.methodNotFound(e);let n=yr.parse(t);return r.unstable_suggestNes(n)}case F.nes_close:{if(!r.unstable_closeNes)throw q.methodNotFound(e);let n=Ln.parse(t);return await r.unstable_closeNes(n)??{}}default:if(r.extMethod)return r.extMethod(e,t);throw q.methodNotFound(e)}},a=async(e,t)=>{switch(e){case F.session_cancel:{let e=In.parse(t);return r.cancel(e)}case F.document_did_open:{if(!r.unstable_didOpenDocument)return;let e=Hn.parse(t);return r.unstable_didOpenDocument(e)}case F.document_did_change:{if(!r.unstable_didChangeDocument)return;let e=Dr.parse(t);return r.unstable_didChangeDocument(e)}case F.document_did_close:{if(!r.unstable_didCloseDocument)return;let e=Bn.parse(t);return r.unstable_didCloseDocument(e)}case F.document_did_save:{if(!r.unstable_didSaveDocument)return;let e=Un.parse(t);return r.unstable_didSaveDocument(e)}case F.document_did_focus:{if(!r.unstable_didFocusDocument)return;let e=Vn.parse(t);return r.unstable_didFocusDocument(e)}case F.nes_accept:{if(!r.unstable_acceptNes)return;let e=Fn.parse(t);return r.unstable_acceptNes(e)}case F.nes_reject:{if(!r.unstable_rejectNes)return;let e=Jn.parse(t);return r.unstable_rejectNes(e)}default:if(r.extNotification)return r.extNotification(e,t);throw q.methodNotFound(e)}};this.connection=new yi(i,a,n)}async sessionUpdate(e){return await this.connection.sendNotification(I.session_update,e)}async requestPermission(e){return await this.connection.sendRequest(I.session_request_permission,e)}async readTextFile(e){return await this.connection.sendRequest(I.fs_read_text_file,e)}async writeTextFile(e){return await this.connection.sendRequest(I.fs_write_text_file,e)??{}}async createTerminal(e){return new vi((await this.connection.sendRequest(I.terminal_create,e)).terminalId,e.sessionId,this.connection)}async unstable_createElicitation(e){return await this.connection.sendRequest(I.elicitation_create,e)}async unstable_completeElicitation(e){return await this.connection.sendNotification(I.elicitation_complete,e)}async extMethod(e,t){return await this.connection.sendRequest(e,t)}async extNotification(e,t){return await this.connection.sendNotification(e,t)}get signal(){return this.connection.signal}get closed(){return this.connection.closed}};gi=Symbol.asyncDispose;var vi=class{constructor(e,n,r){t(this,`id`,void 0),t(this,`sessionId`,void 0),t(this,`connection`,void 0),this.id=e,this.sessionId=n,this.connection=r}async currentOutput(){return await this.connection.sendRequest(I.terminal_output,{sessionId:this.sessionId,terminalId:this.id})}async waitForExit(){return await this.connection.sendRequest(I.terminal_wait_for_exit,{sessionId:this.sessionId,terminalId:this.id})}async kill(){return await this.connection.sendRequest(I.terminal_kill,{sessionId:this.sessionId,terminalId:this.id})??{}}async release(){return await this.connection.sendRequest(I.terminal_release,{sessionId:this.sessionId,terminalId:this.id})??{}}async[gi](){await this.release()}},yi=class{constructor(e,n,r){t(this,`pendingResponses`,new Map),t(this,`nextRequestId`,0),t(this,`requestHandler`,void 0),t(this,`notificationHandler`,void 0),t(this,`stream`,void 0),t(this,`writeQueue`,Promise.resolve()),t(this,`abortController`,new AbortController),t(this,`closedPromise`,void 0),this.requestHandler=e,this.notificationHandler=n,this.stream=r,this.closedPromise=new Promise(e=>{this.abortController.signal.addEventListener(`abort`,()=>e())}),this.receive()}get signal(){return this.abortController.signal}get closed(){return this.closedPromise}async receive(){let e;try{let e=this.stream.readable.getReader();try{for(;!this.abortController.signal.aborted;){let{value:t,done:n}=await e.read();if(n)break;if(t)try{this.processMessage(t)}catch(e){console.error(`Unexpected error during message processing:`,t,e),`id`in t&&t.id!==void 0&&this.sendMessage({jsonrpc:`2.0`,id:t.id,error:{code:-32700,message:`Parse error`}})}}}finally{e.releaseLock()}}catch(t){e=t}finally{this.close(e)}}close(e){if(this.abortController.signal.aborted)return;let t=e??Error(`ACP connection closed`);for(let e of this.pendingResponses.values())e.reject(t);this.pendingResponses.clear(),this.abortController.abort(t)}async processMessage(e){if(`method`in e&&`id`in e){let t=await this.tryCallRequestHandler(e.method,e.params);`error`in t&&console.error(`Error handling request`,e,t.error),await this.sendMessage({jsonrpc:`2.0`,id:e.id,...t})}else if(`method`in e){let t=await this.tryCallNotificationHandler(e.method,e.params);`error`in t&&console.error(`Error handling notification`,e,t.error)}else`id`in e?this.handleResponse(e):console.error(`Invalid message`,{message:e})}async tryCallRequestHandler(e,t){try{return{result:await this.requestHandler(e,t)??null}}catch(e){if(e instanceof q)return e.toResult();if(e instanceof C)return q.invalidParams(e.format()).toResult();let t;(e instanceof Error||typeof e==`object`&&e&&`message`in e&&typeof e.message==`string`)&&(t=e.message);try{return q.internalError(t?JSON.parse(t):{}).toResult()}catch{return q.internalError({details:t}).toResult()}}}async tryCallNotificationHandler(e,t){try{return await this.notificationHandler(e,t),{result:null}}catch(e){if(e instanceof q)return e.toResult();if(e instanceof C)return q.invalidParams(e.format()).toResult();let t;(e instanceof Error||typeof e==`object`&&e&&`message`in e&&typeof e.message==`string`)&&(t=e.message);try{return q.internalError(t?JSON.parse(t):{}).toResult()}catch{return q.internalError({details:t}).toResult()}}}handleResponse(e){let t=this.pendingResponses.get(e.id);if(t){if(`result`in e)t.resolve(e.result);else if(`error`in e){let{code:n,message:r,data:i}=e.error;t.reject(new q(n,r,i))}this.pendingResponses.delete(e.id)}else console.error(`Got response to unknown request`,e.id)}sendRequest(e,t){this.throwIfClosed();let n=this.nextRequestId++,r=new Promise((e,t)=>{this.pendingResponses.set(n,{resolve:e,reject:t})});return r.catch(()=>{}),this.sendMessage({jsonrpc:`2.0`,id:n,method:e,params:t}),r}async sendNotification(e,t){this.throwIfClosed(),await this.sendMessage({jsonrpc:`2.0`,method:e,params:t})}throwIfClosed(){if(this.abortController.signal.aborted)throw this.abortController.signal.reason??Error(`ACP connection closed`)}async sendMessage(e){return this.writeQueue=this.writeQueue.then(async()=>{let t=this.stream.writable.getWriter();try{await t.write(e)}finally{t.releaseLock()}}).catch(e=>{this.close(e)}),this.writeQueue}},q=class e extends Error{constructor(e,n,r){super(n),t(this,`code`,void 0),t(this,`data`,void 0),this.code=e,this.name=`RequestError`,this.data=r}static parseError(t,n){return new e(-32700,`Parse error${n?`: ${n}`:``}`,t)}static invalidRequest(t,n){return new e(-32600,`Invalid request${n?`: ${n}`:``}`,t)}static methodNotFound(t){return new e(-32601,`"Method not found": ${t}`,{method:t})}static invalidParams(t,n){return new e(-32602,`Invalid params${n?`: ${n}`:``}`,t)}static internalError(t,n){return new e(-32603,`Internal error${n?`: ${n}`:``}`,t)}static authRequired(t,n){return new e(-32e3,`Authentication required${n?`: ${n}`:``}`,t)}static resourceNotFound(t){return new e(-32002,`Resource not found${t?`: ${t}`:``}`,t&&{uri:t})}toResult(){return{error:{code:this.code,message:this.message,data:this.data}}}toErrorResponse(){return{code:this.code,message:this.message,data:this.data}}};oe(),A(),le(),ge(),ue(),g(),ee(),v(),n(),d(),_(),ye();function J(e,t){if(e)return t?De(e)?e:Oe(t,e):e}var bi=!(typeof process.geteuid==`function`?process.geteuid()===0:typeof process.getuid==`function`&&process.getuid()===0)||!!process.env.IS_SANDBOX,xi={auto:`auto`,default:`default`,acceptedits:`acceptEdits`,dontask:`dontAsk`,plan:`plan`,bypasspermissions:`bypassPermissions`,bypass:`bypassPermissions`};function Si(e,t=`permissions.defaultMode`){if(e===void 0)return`default`;if(typeof e!=`string`)throw Error(`Invalid ${t}: expected a string.`);let n=e.trim().toLowerCase();if(n===``)throw Error(`Invalid ${t}: expected a non-empty string.`);let r=xi[n];if(!r)throw Error(`Invalid ${t}: ${e}.`);if(r===`bypassPermissions`&&!bi)throw Error(`Invalid ${t}: bypassPermissions is not available when running as root.`);return r}function Ci(e){let t=[...e.mcpServers??[]].sort((e,t)=>e.name.localeCompare(t.name));return JSON.stringify({cwd:e.cwd,mcpServers:t})}var wi=256;function Ti(e){let t=e.replace(/[\r\n]+/g,` `).replace(/\s+/g,` `).trim();return t.length<=wi?t:t.slice(0,wi-1)+`…`}function Ei(e,t){if(!t)return e;let n=P.resolve(t),r=P.resolve(e);return r.startsWith(n+P.sep)||r===n?P.relative(n,r):e}function Di(e){let t="```";for(let n of e.matchAll(/^```+/gm)??[])for(;n[0].length>=t.length;)t+="`";return t+`
4
+ `+e+(e.endsWith(`
5
+ `)?``:`
6
+ `)+t}function Y(e,t=!1,n){let r=e.name,i=e.input;switch(r){case`Agent`:case`Task`:{let e=i?.description??`Task`,t=i?.prompt;return{title:e,kind:`think`,content:t?[{type:`content`,content:{type:`text`,text:t}}]:[]}}case`Bash`:{let e=i?.command??`Terminal`,t=i?.description;return{title:e,kind:`execute`,content:t?[{type:`content`,content:{type:`text`,text:t}}]:[]}}case`Read`:{let e=i?.file_path,t=e??`File`,r=i?.offset,a=i?.limit,o=``;a&&a>0?o=` (${r??1} - ${(r??1)+a-1})`:r&&(o=` (from line ${r})`);let s=t?Ei(t,n):`File`,c=J(e,n);return{title:`Read ${s}${o}`,kind:`read`,locations:c?[{path:c,line:r??1}]:[],content:[]}}case`Write`:{let e=i?.file_path??``,t=i?.content??``,r=e?Ei(e,n):void 0,a=J(e,n);return{title:r?`Write ${r}`:`Write`,kind:`edit`,content:a?[{type:`diff`,path:a,oldText:null,newText:t}]:[{type:`content`,content:{type:`text`,text:t}}],locations:a?[{path:a}]:[]}}case`Edit`:{let e=i?.file_path??``,t=i?.old_string??``,r=i?.new_string??``,a=e?Ei(e,n):void 0,o=J(e,n);return{title:a?`Edit ${a}`:`Edit`,kind:`edit`,content:o?[{type:`diff`,path:o,oldText:t||null,newText:r}]:[],locations:o?[{path:o}]:[]}}case`Glob`:{let e=i?.path??``,t=i?.pattern??``,r=J(e,n),a=`Find`;return e&&(a+=` \`${e}\``),t&&(a+=` \`${t}\``),{title:a,kind:`search`,content:[],locations:r?[{path:r}]:[]}}case`Grep`:{let e=i?.pattern??``,t=i?.path??``,n=`grep`;return i?.[`-i`]&&(n+=` -i`),i?.[`-n`]&&(n+=` -n`),i?.[`-A`]!==void 0&&(n+=` -A ${i[`-A`]}`),i?.[`-B`]!==void 0&&(n+=` -B ${i[`-B`]}`),i?.[`-C`]!==void 0&&(n+=` -C ${i[`-C`]}`),i?.output_mode===`files_with_matches`?n+=` -l`:i?.output_mode===`count`&&(n+=` -c`),i?.head_limit!==void 0&&(n+=` | head -${i.head_limit}`),i?.glob&&(n+=` --include="${i.glob}"`),i?.type&&(n+=` --type=${i.type}`),i?.multiline&&(n+=` -P`),e&&(n+=` "${e}"`),t&&(n+=` ${t}`),{title:n,kind:`search`,content:[]}}case`TodoWrite`:{let e=i?.todos;return{title:Array.isArray(e)?`Update TODOs: ${e.map(e=>e.content).join(`, `)}`:`Update TODOs`,kind:`think`,content:[]}}case`ExitPlanMode`:{let e=i?.plan;return{title:`Ready to code?`,kind:`switch_mode`,content:e?[{type:`content`,content:{type:`text`,text:e}}]:[]}}default:return{title:r||`Unknown Tool`,kind:`other`,content:[]}}}function Oi(e,t){return Array.isArray(e)&&e.length>0?{content:e.map(e=>({type:`content`,content:ki(e,t)}))}:typeof e==`string`&&e.length>0?{content:[{type:`content`,content:{type:`text`,text:t?`\`\`\`\n${e}\n\`\`\``:e}}]}:{}}function ki(e,t){let n=e=>({type:`text`,text:t?`\`\`\`\n${e}\n\`\`\``:e});switch(e.type){case`text`:{let n=e.text;return{type:`text`,text:t?`\`\`\`\n${n}\n\`\`\``:n}}case`image`:{let t=e.source;return t?.type===`base64`?{type:`image`,data:t.data,mimeType:t.media_type}:n(t?.type===`url`?`[image: ${t.url}]`:`[image: file reference]`)}case`resource_link`:{let t=e.uri;return{type:`resource_link`,uri:t,name:e.name??t,mimeType:e.mimeType}}case`resource`:{let t=e.resource;return{type:`resource`,resource:{uri:t?.uri??``,mimeType:t?.mimeType,...typeof t?.text==`string`?{text:t.text}:{},...typeof t?.blob==`string`?{blob:t.blob}:{}}}}case`tool_reference`:return n(`Tool: ${e.tool_name}`);case`tool_search_tool_search_result`:{let t=e.tool_references;return n(`Tools found: ${t?.map(e=>e.tool_name).join(`, `)||`none`}`)}case`tool_search_tool_result_error`:return n(`Error: ${e.error_code}${e.error_message?` - ${e.error_message}`:``}`);case`web_fetch_result`:return n(`Fetched: ${e.url}`);case`web_fetch_tool_result_error`:return n(`Error: ${e.error_code}`);case`code_execution_result`:case`bash_code_execution_result`:return n(`Output: ${e.stdout||e.stderr||``}`);case`code_execution_tool_result_error`:case`bash_code_execution_tool_result_error`:return n(`Error: ${e.error_code}`);case`text_editor_code_execution_view_result`:return n(e.content);case`text_editor_code_execution_create_result`:return n(e.is_file_update?`File updated`:`File created`);case`text_editor_code_execution_str_replace_result`:{let t=e.lines;return n(t?.join(`
7
+ `)||``)}case`text_editor_code_execution_tool_result_error`:return n(`Error: ${e.error_code}${e.error_message?` - ${e.error_message}`:``}`);default:try{return{type:`text`,text:JSON.stringify(e)}}catch{return{type:`text`,text:`[content]`}}}}function Ai(e,t,n=!1){if(!t)return{};let r=e.is_error===!0,i=e.content;if(r&&i)return Oi(i,!0);switch(t.name){case`Read`:return typeof i==`string`&&i.length>0?{content:[{type:`content`,content:{type:`text`,text:Di(i)}}]}:Array.isArray(i)&&i.length>0?{content:i.map(e=>({type:`content`,content:e.type===`text`?{type:`text`,text:Di(e.text)}:ki(e,!1)}))}:{};case`Bash`:{let e=``;if(i&&typeof i==`object`&&!Array.isArray(i)&&i.type===`bash_code_execution_result`){let t=i;e=[t.stdout,t.stderr].filter(Boolean).join(`
8
+ `)}else typeof i==`string`?e=i:Array.isArray(i)&&i.length>0&&(e=i.map(e=>e.type===`text`?e.text:``).join(`
9
+ `));return e.trim()?{content:[{type:`content`,content:{type:`text`,text:`\`\`\`console\n${e.trimEnd()}\n\`\`\``}}]}:{}}case`Edit`:case`Write`:return{};case`ExitPlanMode`:return{title:`Exited Plan Mode`};default:return Oi(i??``,r)}}function ji(e){return e===`in_progress`?`in_progress`:e===`completed`?`completed`:`pending`}function X(e,t,n,r,i,a,o){let s=[];for(let i of e){let e=i.type,a=null;switch(e){case`text`:case`text_delta`:{let e=i.text??``;a={sessionUpdate:t===`assistant`?`agent_message_chunk`:`user_message_chunk`,...o?.messageId?{messageId:o.messageId}:{},content:{type:`text`,text:e}};break}case`thinking`:case`thinking_delta`:{let e=i.thinking??``;a={sessionUpdate:`agent_thought_chunk`,...o?.messageId?{messageId:o.messageId}:{},content:{type:`text`,text:e}};break}case`image`:{let e=i.source;e?.type===`base64`&&(a={sessionUpdate:t===`assistant`?`agent_message_chunk`:`user_message_chunk`,...o?.messageId?{messageId:o.messageId}:{},content:{type:`image`,data:e.data,mimeType:e.media_type}});break}case`tool_use`:case`server_tool_use`:case`mcp_tool_use`:{let t=i.id??``,n=i.name??`unknown`,s=i.input,c=t in r;if(r[t]={type:e,id:t,name:n,input:s},n===`TodoWrite`){let e=s?.todos;Array.isArray(e)&&(a={sessionUpdate:`plan`,entries:e.map(e=>({content:e.content,status:ji(e.status),priority:`medium`}))})}else{let e=s?{...s}:{};a=c?{_meta:{claudeCode:{toolName:n}},toolCallId:t,sessionUpdate:`tool_call_update`,status:`in_progress`,rawInput:e,...Y({name:n,id:t,input:s??{}},!1,o?.cwd)}:{_meta:{claudeCode:{toolName:n}},toolCallId:t,sessionUpdate:`tool_call`,rawInput:e,status:`pending`,...Y({name:n,id:t,input:s??{}},!1,o?.cwd)}}break}case`tool_result`:case`mcp_tool_result`:{let e=i.tool_use_id??``,t=r[e];if(!t)break;if(t.name!==`TodoWrite`){let n=Ai(i,{name:t.name,id:t.id},!1);a={_meta:{claudeCode:{toolName:t.name}},toolCallId:e,sessionUpdate:`tool_call_update`,status:i.is_error===!0?`failed`:`completed`,rawOutput:i.content,...n}}break}case`redacted_thinking`:case`input_json_delta`:case`citations_delta`:case`signature_delta`:case`container_upload`:case`compaction`:case`compaction_delta`:break}if(a){if(o?.parentToolUseId){let e=a._meta;a._meta={...e,claudeCode:{...e?.claudeCode??{},parentToolUseId:o.parentToolUseId}}}s.push({sessionId:n,update:a})}}return s}function Mi(e,t,n,r,i){let a=e.message;if(!a)return[];let o=a.content;if(!o)return[];if(typeof o==`string`)return[{sessionId:t,update:{sessionUpdate:`agent_message_chunk`,...i?.messageId?{messageId:i.messageId}:{},content:{type:`text`,text:o}}}];let s=i?.streamingActive?o.filter(e=>e.type!==`text`&&e.type!==`thinking`):o;return s.length===0?[]:X(s,`assistant`,t,n,r,void 0,i)}function Ni(e,t,n,r,i){let a=e.event;if(!a)return[];switch(a.type){case`content_block_start`:{let o=a.content_block;return o?X([o],`assistant`,t,n,r,void 0,{clientCapabilities:i?.clientCapabilities,parentToolUseId:e.parent_tool_use_id,cwd:i?.cwd,messageId:i?.messageId}):[]}case`content_block_delta`:{let o=a.delta;return o?X([o],`assistant`,t,n,r,void 0,{clientCapabilities:i?.clientCapabilities,parentToolUseId:e.parent_tool_use_id,cwd:i?.cwd,messageId:i?.messageId}):[]}case`message_start`:case`message_delta`:case`message_stop`:case`content_block_stop`:return[];default:return[]}}function Pi(e,t){let n=0,r=Math.min(e.length,t.length);for(;n<r&&e[n]===t[n];)n++;return n}function Fi(e,t){let n=null,r=0;for(let i of Object.keys(e)){let e=Pi(i,t);e>r&&(r=e,n=i)}return n?e[n]??null:null}var Ii=console;function Li(e,t){if(t.aborted)return Promise.resolve({done:!0,value:void 0});let n,r=new Promise(e=>{n=()=>e({done:!0,value:void 0}),t.addEventListener(`abort`,n,{once:!0})});return Promise.race([e.next(),r]).finally(()=>{n&&t.removeEventListener(`abort`,n)})}async function Ri(e,t,n,r,i,a,o,s){let c=`end_turn`,l={inputTokens:0,outputTokens:0,cachedReadTokens:0,cachedWriteTokens:0},u=null,d=null,f=2e5,p=!1,m=null;try{for(;!r.aborted;){let s=await Li(t,r);if(s.done||r.aborted)break;let h=s.value;if(h==null)continue;let g=h;switch(g.type){case`system`:g.subtype===`compact_boundary`&&(u=0,await n.sessionUpdate({sessionId:e,update:{sessionUpdate:`agent_message_chunk`,content:{type:`text`,text:`
10
+
11
+ Compacting completed.`}}}));break;case`result`:{let t=g.usage;t&&(l.inputTokens+=t.input_tokens??0,l.outputTokens+=t.output_tokens??0,l.cachedReadTokens+=t.cache_read_input_tokens??0,l.cachedWriteTokens+=t.cache_creation_input_tokens??0);let i=g.modelUsage;if(i&&d){let e=Fi(i,d);e?.contextWindow&&(f=e.contextWindow)}u!==null&&await n.sessionUpdate({sessionId:e,update:{sessionUpdate:`usage_update`,used:u,size:f}});let a=g.subtype,o=g.is_error;if(r.aborted){c=`cancelled`;break}switch(a){case`success`:{let e=g.stop_reason;c=e===`max_tokens`?`max_tokens`:e===`refusal`?`refusal`:`end_turn`,o&&(c=`end_turn`);break}case`error_during_execution`:c=g.stop_reason===`max_tokens`?`max_tokens`:`end_turn`;break;case`error_max_budget_usd`:case`error_max_turns`:case`error_max_structured_output_retries`:c=`max_turn_requests`;break}break}case`stream_event`:{let t=g.parent_tool_use_id;t===null&&m===null&&(m=N());let r=Ni(g,e,i,n,{clientCapabilities:a,cwd:o,messageId:t===null?m??void 0:void 0});for(let e of r)await n.sessionUpdate(e);p=!0;break}case`assistant`:{let t=g.message,r=g.parent_tool_use_id;if(t?.usage&&r===null){let e=t.usage;u=(typeof e.input_tokens==`number`?e.input_tokens:0)+(typeof e.output_tokens==`number`?e.output_tokens:0)+(typeof e.cache_read_input_tokens==`number`?e.cache_read_input_tokens:0)+(typeof e.cache_creation_input_tokens==`number`?e.cache_creation_input_tokens:0)}r===null&&t?.model&&t.model!==`<synthetic>`&&(d=t.model);let s;r===null&&(m===null&&(m=N()),s=m);let c=Mi(g,e,i,n,{clientCapabilities:a,cwd:o,parentToolUseId:r,streamingActive:p,messageId:s});for(let e of c)await n.sessionUpdate(e);r===null&&(m=null);break}case`user`:break;case`progress`:{let t=g.data;if(!t)break;let r=t.type;if(r===`agent_progress`||r===`skill_progress`){let r=t.message;if(r){let t=r.content;if(t)for(let r of t)r.type===`text`&&await n.sessionUpdate({sessionId:e,update:{sessionUpdate:`agent_message_chunk`,content:{type:`text`,text:r.text}}})}}break}case`tool_use_summary`:break;case`attachment`:break;case`compact_boundary`:u=0,await n.sessionUpdate({sessionId:e,update:{sessionUpdate:`agent_message_chunk`,content:{type:`text`,text:`
12
+
13
+ Compacting completed.`}}});break;default:Ii.debug(`Ignoring unknown SDK message type`);break}}if(r.aborted||s?.())return{stopReason:`cancelled`,usage:l}}catch(e){if(r.aborted)return{stopReason:`cancelled`,usage:l};throw e}return{stopReason:c,usage:l}}async function zi(e,t,n,r,i,a){for(let o of t){let t=o;if(t.type!==`user`&&t.type!==`assistant`){Ii.debug(`Ignoring unknown SDK message type`);continue}if(t.isMeta===!0)continue;let s=t.message?.content;if(!s)continue;let c=t.type===`assistant`?`assistant`:`user`;if(typeof s==`string`){if(!s.trim())continue;let t=N();await n.sessionUpdate({sessionId:e,update:{sessionUpdate:c===`assistant`?`agent_message_chunk`:`user_message_chunk`,...t?{messageId:t}:{},content:{type:`text`,text:s}}});continue}if(Array.isArray(s)){let t=X(s,c,e,r,n,void 0,{clientCapabilities:i,cwd:a,messageId:N()});for(let e of t)await n.sessionUpdate(e)}}}function Bi(e,t,n,r,i,a,o,s){return async(n,c,l,d,f,p)=>{let m=Hi(r);if(n.name===`ExitPlanMode`)return Vi(e,t,f,c,m,i,a,o,s);if(p!==void 0)return p;try{let e=await u(n,c,l,d,f);if(e.behavior===`allow`||e.behavior===`deny`)return e}catch(e){return console.error(`[ACP Permissions] Pipeline error:`,e),{behavior:`deny`,message:`Permission pipeline failed`,decisionReason:{type:`other`,reason:`Permission pipeline failed`},toolUseID:f}}let h=Y({name:n.name,id:f,input:c},m,i),g={toolCallId:f,title:h.title,kind:h.kind,status:`pending`,rawInput:c},_=[{kind:`allow_always`,name:`Always Allow`,optionId:`allow_always`},{kind:`allow_once`,name:`Allow`,optionId:`allow`},{kind:`reject_once`,name:`Reject`,optionId:`reject`},{kind:`reject_always`,name:`Always Reject`,optionId:`reject_always`}];try{let n=await e.requestPermission({sessionId:t,toolCall:g,options:_});if(n.outcome.outcome===`cancelled`)return s?.(),{behavior:`deny`,message:`Permission request cancelled by client`,decisionReason:{type:`mode`,mode:`default`},toolUseID:f};if(n.outcome.outcome===`selected`&&`optionId`in n.outcome&&n.outcome.optionId!==void 0){let e=n.outcome.optionId;if(e===`allow`||e===`allow_always`)return{behavior:`allow`,updatedInput:c}}return{behavior:`deny`,message:`Permission denied by client`,decisionReason:{type:`mode`,mode:`default`}}}catch(e){return console.error(`[ACP Permissions] Client request error:`,e),{behavior:`deny`,message:`Permission request failed`,decisionReason:{type:`mode`,mode:`default`}}}}}async function Vi(e,t,n,r,i,a,o,s,c){let l=[{kind:`allow_always`,name:`Yes, and use "auto" mode`,optionId:`auto`},{kind:`allow_always`,name:`Yes, and auto-accept edits`,optionId:`acceptEdits`},{kind:`allow_once`,name:`Yes, and manually approve edits`,optionId:`default`},{kind:`reject_once`,name:`No, keep planning`,optionId:`plan`}];s?.()===!0&&l.unshift({kind:`allow_always`,name:`Yes, and bypass permissions`,optionId:`bypassPermissions`});let u=Y({name:`ExitPlanMode`,id:n,input:r},i,a),d={toolCallId:n,title:u.title,kind:u.kind,status:`pending`,rawInput:r},f=await e.requestPermission({sessionId:t,toolCall:d,options:l});if(f.outcome.outcome===`cancelled`)return c?.(),{behavior:`deny`,message:`Tool use aborted`,decisionReason:{type:`mode`,mode:`default`}};if(f.outcome.outcome===`selected`&&`optionId`in f.outcome&&f.outcome.optionId!==void 0){let n=f.outcome.optionId;if(l.some(e=>e.optionId===n)&&(n==="default"||n===`acceptEdits`||n===`auto`||n===`bypassPermissions`))return o?.(n),await e.sessionUpdate({sessionId:t,update:{sessionUpdate:`current_mode_update`,currentModeId:n}}),{behavior:`allow`,updatedInput:r}}return{behavior:`deny`,message:`User rejected request to exit plan mode.`,decisionReason:{type:`mode`,mode:`plan`}}}function Hi(e){if(!e)return!1;if(e.terminal===!0)return!0;let t=e._meta;return!t||typeof t!=`object`?!1:t.terminal_output===!0}me(),xe(),s(),fe(),e(),a(),i();var Z=class{constructor(e){t(this,`conn`,void 0),t(this,`sessions`,new Map),t(this,`clientCapabilities`,void 0),this.conn=e}async initialize(e){return this.clientCapabilities=e.clientCapabilities,{protocolVersion:1,authMethods:[],agentInfo:{name:`claude-code`,title:`Work Mate`,version:typeof globalThis.MACRO==`object`&&globalThis.MACRO!==null?String(globalThis.MACRO.VERSION??`0.0.0`):`0.0.0`},agentCapabilities:{_meta:{claudeCode:{promptQueueing:!0,forkSession:!0}},promptCapabilities:{image:!1,embeddedContext:!0},mcpCapabilities:{http:!0,sse:!0},loadSession:!0,sessionCapabilities:{list:{},resume:{},close:{},delete:{}}}}}async authenticate(e){return{}}async newSession(e){let t=await this.createSession(e);return this.scheduleAvailableCommandsUpdate(t.sessionId),t}async unstable_resumeSession(e){let t=await this.getOrCreateSession({...e,replay:!1});return this.scheduleAvailableCommandsUpdate(t.sessionId),t}async loadSession(e){let t=await this.getOrCreateSession(e);return this.scheduleAvailableCommandsUpdate(t.sessionId),t}async listSessions(e){if(e.cursor!==void 0&&e.cursor!==null)throw Error(`Pagination cursor not supported: listSessions returns all results in a single page.`);let t=e.cwd||ae(),n=await pe(t),i=await r({dir:t}),a=[];for(let e of i){if(!e.cwd||await pe(e.cwd)!==n)continue;let t=Ti(e.summary??``);a.push({sessionId:e.sessionId,cwd:e.cwd,...t?{title:t}:{},updatedAt:new Date(e.lastModified).toISOString()})}return{sessions:a}}async unstable_forkSession(e){let{initialMessages:t}=await Ui(e.sessionId),n=await this.createSession({cwd:e.cwd,mcpServers:e.mcpServers??[],_meta:e._meta},{initialMessages:t});return this.scheduleAvailableCommandsUpdate(n.sessionId),n}async unstable_closeSession(e){if(!this.sessions.get(e.sessionId))throw Error(`Session not found`);return await this.teardownSession(e.sessionId),{}}async unstable_deleteSession(e){let t=await M(e.sessionId);if(t)try{await Ee(t.filePath)}catch(e){if(e.code!==`ENOENT`)throw e}return this.sessions.has(e.sessionId)&&await this.teardownSession(e.sessionId),{}}async extMethod(e,t){if(e===`session/delete`){let e=t.sessionId;if(typeof e!=`string`||e.length===0)throw Error(`session/delete requires a non-empty sessionId`);return this.unstable_deleteSession({sessionId:e})}throw q.methodNotFound(e)}async cancel(e){let t=this.sessions.get(e.sessionId);if(t){t.cancelled=!0,t.cancelGeneration+=1;for(let[,e]of t.pendingMessages)e.resolve(!0);t.pendingMessages.clear(),t.pendingQueue=[],t.pendingQueueHead=0,t.queryEngine.interrupt()}}async setSessionMode(e){if(!this.sessions.get(e.sessionId))throw Error(`Session not found`);return this.applySessionMode(e.sessionId,e.modeId),await this.conn.sessionUpdate({sessionId:e.sessionId,update:{sessionUpdate:`current_mode_update`,currentModeId:e.modeId}}),await this.updateConfigOption(e.sessionId,`mode`,e.modeId),{}}async unstable_setSessionModel(e){let t=this.sessions.get(e.sessionId);if(!t)throw Error(`Session not found`);return t.queryEngine.setModel(e.modelId),await this.updateConfigOption(e.sessionId,`model`,e.modelId),{}}async sendAvailableCommandsUpdate(e){let t=this.sessions.get(e);if(!t)return;let n=t.commands.filter(e=>e.type===`prompt`&&!e.isHidden&&e.userInvocable!==!1).map(e=>({name:e.name,description:e.description,input:e.argumentHint?{hint:e.argumentHint}:void 0}));await this.conn.sessionUpdate({sessionId:e,update:{sessionUpdate:`available_commands_update`,availableCommands:n}})}scheduleAvailableCommandsUpdate(e){setTimeout(()=>{this.sendAvailableCommandsUpdate(e).catch(e=>{console.error(`[ACP] Failed to send available commands update:`,e)})},0)}};async function Ui(e){let t;try{let n=await f(e);n&&n.messages.length>0&&(t=l(n.messages))}catch(e){console.error(`[ACP] fork source load failed:`,e)}return{initialMessages:t}}var Wi=[`auto`,`default`,`acceptEdits`,`bypassPermissions`,`dontAsk`,`plan`];function Gi(e){return Wi.includes(e)}function Ki(e,t,n){if(t){let t=qi(e,`_meta.permissionMode`);if(t===`bypassPermissions`&&!Xi())throw Error(`Mode not available: bypassPermissions cannot run as root (start the agent as a non-root user, or set IS_SANDBOX=1).`);return t}return Ji(n)??`default`}function qi(e,t){if(e==null)throw Error(`Invalid ${t}: expected a string.`);return Si(e,t)}function Ji(e){if(e!=null)try{return Si(e,`permissions.defaultMode`)}catch(e){let t=e instanceof Error?e.message:String(e);console.error(`[ACP] Invalid permissions.defaultMode, using default:`,t);return}}function Yi(e,t){return!!e&&Object.hasOwn(e,t)}function Xi(){return Zi()}function Zi(){return process.env.IS_SANDBOX?!0:typeof process.geteuid==`function`?process.geteuid()!==0:typeof process.getuid!=`function`||process.getuid()!==0}function Qi(e,t){return[{id:`mode`,name:`Mode`,description:`Session permission mode`,category:`mode`,type:`select`,currentValue:e.currentModeId,options:e.availableModes.map(e=>({value:e.id,name:e.name,description:e.description}))},{id:`model`,name:`Model`,description:`AI model to use`,category:`model`,type:`select`,currentValue:t.currentModelId,options:t.availableModels.map(e=>({value:e.modelId,name:e.name,description:e.description??void 0}))}]}function $i(e){let t=[];if(!Array.isArray(e))return t;for(let n of e){if(typeof n!=`object`||!n)continue;let e=n;if(Array.isArray(e.options))for(let n of e.options)n&&typeof n==`object`&&typeof n.value==`string`&&t.push(n.value);else typeof n.value==`string`&&t.push(n.value)}return t}function Q(e){return e.conn}function $(e){return e.clientCapabilities}function ea(e,t,n,r){n===`mode`?t.modes={...t.modes,currentModeId:r}:n===`model`&&(t.models={...t.models,currentModelId:r})}A();function ta(){return ce().permissions?.defaultMode}async function na(e,t={}){de();let n=t.sessionId??N(),r=e.cwd;j(n,se()),re(r);let i=process.cwd(),a=!1;try{process.chdir(r),a=!0}catch{}ie(),ve();try{let i=_e(),a=m(i),s=e._meta,l=Yi(s,`permissionMode`),u=Ki(l?s?.permissionMode:void 0,l,ta()),d=$(this),f=this.conn,g=Bi(f,n,()=>this.sessions.get(n)?.modes.currentModeId??`default`,d,r,e=>{this.applySessionMode(n,e)},()=>this.sessions.get(n)?.appState.toolPermissionContext.isBypassPermissionsModeAvailable??!1),_=Xi(),v={...p(),toolPermissionContext:{...i,mode:u,isBypassPermissionsModeAvailable:_}},[ee,y]=await Promise.all([o(r),h(r)]);v.agentDefinitions=y;let b=new be({cwd:r,tools:a,commands:ee,mcpClients:[],agents:y.activeAgents,canUseTool:g,getAppState:()=>v,setAppState:e=>{let t=e(v);Object.assign(v,t)},readFileCache:new c(500,50*1024*1024),includePartialMessages:!0,replayUserMessages:!0,initialMessages:t.initialMessages}),x={currentModeId:u,availableModes:[{id:`default`,name:`Default`,description:`Standard behavior, prompts for dangerous operations`},{id:`acceptEdits`,name:`Accept Edits`,description:`Auto-accept file edit operations`},{id:`plan`,name:`Plan Mode`,description:`Planning mode, no actual tool execution`},{id:`auto`,name:`Auto`,description:`Use a model classifier to approve/deny permission prompts.`},..._?[{id:`bypassPermissions`,name:`Bypass Permissions`,description:`Skip all permission checks`}]:[],{id:`dontAsk`,name:`Don't Ask`,description:`Don't prompt for permissions, deny if not pre-approved`}]},S=Se(),C=he(),w={availableModels:S.map(e=>({modelId:String(e.value??``),name:e.label??String(e.value??``),description:e.description??void 0})),currentModelId:C};b.setModel(C);let T=Qi(x,w),te={queryEngine:b,cancelled:!1,cancelGeneration:0,cwd:r,modes:x,models:w,configOptions:T,promptRunning:!1,pendingMessages:new Map,pendingQueue:[],pendingQueueHead:0,toolUseCache:{},clientCapabilities:d,appState:v,commands:ee,sessionFingerprint:Ci({cwd:r,mcpServers:e.mcpServers})};return this.sessions.set(n,te),{sessionId:n,modes:x,models:w,configOptions:T}}finally{a&&process.chdir(i)}}Object.assign(Z.prototype,{createSession:na}),a(),i(),A(),fe();async function ra(e){let t=e.replay!==!1,n=this.sessions.get(e.sessionId);if(n){if(Ci({cwd:e.cwd,mcpServers:e.mcpServers})===n.sessionFingerprint){let r=await M(e.sessionId,e.cwd);return j(e.sessionId,r?Ce(r.filePath):null),re(e.cwd),t&&await this.replaySessionHistory(e),{sessionId:e.sessionId,modes:n.modes,models:n.models,configOptions:n.configOptions}}await this.teardownSession(e.sessionId)}let r=await M(e.sessionId,e.cwd),i=r?Ce(r.filePath):null;j(e.sessionId,i),re(e.cwd);let a;if(r)try{let t=await f(e.sessionId);t&&t.messages.length>0&&(a=l(t.messages))}catch(e){console.error(`[ACP] Failed to load session history:`,e)}let o=await this.createSession({cwd:e.cwd,mcpServers:e.mcpServers??[],_meta:e._meta},{sessionId:e.sessionId,initialMessages:a});if(t&&a&&a.length>0){let t=this.sessions.get(e.sessionId);t&&await zi(e.sessionId,a,Q(this),t.toolUseCache,$(this),t.cwd)}return{sessionId:o.sessionId,modes:o.modes,models:o.models,configOptions:o.configOptions}}async function ia(e){this.sessions.get(e)&&(await this.cancel({sessionId:e}),this.sessions.delete(e))}async function aa(e){try{let t=await f(e.sessionId);if(!t||t.messages.length===0)return;let n=l(t.messages);if(n.length===0)return;let r=this.sessions.get(e.sessionId);if(!r)return;await zi(e.sessionId,n,Q(this),r.toolUseCache,$(this),r.cwd)}catch(e){console.error(`[ACP] Failed to replay session history:`,e)}}function oa(e,t){if(!Gi(t))throw Error(`Invalid mode: ${t}`);let n=this.sessions.get(e);if(n){if(t===`bypassPermissions`&&!n.appState.toolPermissionContext.isBypassPermissionsModeAvailable||!n.modes.availableModes.some(e=>e.id===t))throw Error(`Mode not available: ${t}`);n.modes={...n.modes,currentModeId:t},n.appState.toolPermissionContext={...n.appState.toolPermissionContext,mode:t}}}async function sa(e,t,n){let r=this.sessions.get(e);r&&(ea(this,r,t,n),r.configOptions=r.configOptions.map(e=>e.id===t&&typeof e.currentValue==`string`?{...e,currentValue:n}:e),await Q(this).sessionUpdate({sessionId:e,update:{sessionUpdate:`config_option_update`,configOptions:r.configOptions}}))}Object.assign(Z.prototype,{getOrCreateSession:ra,teardownSession:ia,replaySessionHistory:aa,applySessionMode:oa,updateConfigOption:sa});function ca(e){if(!e||e.length===0)return``;let t=[];for(let n of e){let e=n;if(e.type===`text`)t.push(String(e.text??``));else if(e.type===`resource_link`){let n=typeof e.name==`string`?e.name:void 0,r=typeof e.uri==`string`?e.uri:void 0;t.push(la(n,r))}else if(e.type===`resource`){let n=e.resource;if(n&&typeof n.text==`string`)t.push(n.text);else if(n&&typeof n.blob==`string`){let e=typeof n.mimeType==`string`?n.mimeType:`application/octet-stream`,r=typeof n.uri==`string`?n.uri:`(unknown uri)`;t.push(`Embedded resource: ${r} (${e}, base64 blob, ${n.blob.length} chars)`)}}}return t.filter(e=>e.length>0).join(`
14
+ `)}function la(e,t){let n=[];return e&&e.length>0&&n.push(`name=${e}`),t&&t.length>0&&n.push(`uri=${t}`),n.length>0?`Resource link: ${n.join(`, `)}`:`Resource link`}function ua(e){for(;e.pendingQueueHead<e.pendingQueue.length;){let t=e.pendingQueue[e.pendingQueueHead++];if(!t)continue;let n=e.pendingMessages.get(t);if(n)return e.pendingMessages.delete(t),da(e),n}da(e)}function da(e){if(e.pendingQueueHead!==0){if(e.pendingQueueHead>=e.pendingQueue.length){e.pendingQueue=[],e.pendingQueueHead=0;return}e.pendingQueueHead>1024&&e.pendingQueueHead*2>e.pendingQueue.length&&(e.pendingQueue=e.pendingQueue.slice(e.pendingQueueHead),e.pendingQueueHead=0)}}A();async function fa(e){let t=this.sessions.get(e.sessionId);if(!t)throw Error(`Session ${e.sessionId} not found`);let n=e.messageId??void 0,r=ca(e.prompt);if(!r.trim())throw Error(`Prompt content is empty`);let i=t.cancelGeneration;if(t.promptRunning){let e=N();if(await new Promise(n=>{t.pendingQueue.push(e),t.pendingMessages.set(e,{resolve:n})}))return{stopReason:`cancelled`}}if(t.cancelGeneration!==i)return{stopReason:`cancelled`};t.cancelled=!1,t.promptRunning=!0;try{t.queryEngine.resetAbortController(),j(e.sessionId,se());let i=t.queryEngine.submitMessage(r),{stopReason:a,usage:o}=await Ri(e.sessionId,i,Q(this),t.queryEngine.getAbortSignal(),t.toolUseCache,$(this),t.cwd,()=>t.cancelled);if(t.cancelled)return{stopReason:`cancelled`};if(await ma(this,e.sessionId,r),o){let e={inputTokens:o.inputTokens,outputTokens:o.outputTokens,cachedReadTokens:o.cachedReadTokens,cachedWriteTokens:o.cachedWriteTokens,thoughtTokens:0,totalTokens:o.inputTokens+o.outputTokens+o.cachedReadTokens+o.cachedWriteTokens+0};return{stopReason:a,usage:e,...n?{userMessageId:n}:{},_meta:{claudeCode:{usage:e}}}}return{stopReason:a,...n?{userMessageId:n}:{}}}catch(n){let r=n instanceof Error&&(n.name===`AbortError`||/abort|cancelled|interrupt/i.test(n.message));if(t.cancelled||r)return{stopReason:`cancelled`};throw n instanceof Error&&(n.message.includes(`terminated`)||n.message.includes(`process exited`))?(await this.teardownSession(e.sessionId),Error(`The Claude Agent process exited unexpectedly. Please start a new session.`)):n}finally{let e=ua(t);e?(t.promptRunning=!0,e.resolve(!1)):t.promptRunning=!1}}async function pa(e){let t=this.sessions.get(e.sessionId);if(!t)throw Error(`Session not found`);if(typeof e.value!=`string`)throw Error(`Invalid value for config option ${e.configId}: ${String(e.value)}`);let n=t.configOptions.find(t=>t.id===e.configId);if(!n)throw Error(`Unknown config option: ${e.configId}`);if(n.type===`select`){let t=$i(n.options);if(!t.includes(e.value))throw Error(`Invalid value '${e.value}' for config option ${e.configId}; must be one of: ${t.join(`, `)}`)}let r=e.value;return e.configId===`mode`?(this.applySessionMode(e.sessionId,r),await Q(this).sessionUpdate({sessionId:e.sessionId,update:{sessionUpdate:`current_mode_update`,currentModeId:r}})):e.configId===`model`&&t.queryEngine.setModel(r),ea(this,t,e.configId,r),t.configOptions=t.configOptions.map(t=>t.id===e.configId&&typeof t.currentValue==`string`?{...t,currentValue:r}:t),{configOptions:t.configOptions}}async function ma(e,t,n){let r=e.sessions.get(t);if(!r)return;let i=r.toolUseCache;if(i.__sessionInfoTitleSent)return;i.__sessionInfoTitleSent=!0;let a=Ti(n).slice(0,100);try{await Q(e).sessionUpdate({sessionId:t,update:{sessionUpdate:`session_info_update`,...a?{title:a}:{},updatedAt:new Date().toISOString()}})}catch(e){console.error(`[ACP] Failed to send session_info_update:`,e)}}Object.assign(Z.prototype,{prompt:fa,setSessionConfigOption:pa}),ue(),ye();function ha(e,t){let n=we.toWeb(e);return hi(Te.toWeb(t),n)}async function ga(){de(),ve();let e=ha(process.stdin,process.stdout),t,n=new _i(e=>(t=new Z(e),t),e);console.log=console.error,console.info=console.error,console.warn=console.error,console.debug=console.error;async function r(){for(let[e]of t.sessions)try{await t.unstable_closeSession({sessionId:e})}catch{}process.exit(0)}n.closed.then(r).catch(r),process.on(`SIGTERM`,r),process.on(`SIGINT`,r),process.on(`unhandledRejection`,(e,t)=>{console.error(`Unhandled Rejection at:`,t,`reason:`,e)}),process.stdin.resume()}export{ga as runAcpAgent};
@@ -0,0 +1 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./memoize-BK3gG5ob.js";import{l as r,o as i}from"./envUtils-BDhHQY0-.js";import{n as a,t as o}from"./defineProperty-C-QyHrDq.js";import{E as s,O as c,S as l,i as u,l as d,n as f,s as p,v as m}from"./esm-lWlUmoUA.js";import{C as h,D as g,E as _,I as v,O as y,S as ee,V as te,_ as ne,a as b,d as re,k as ie,l as ae,n as oe,p as se,s as ce,t as le,w as ue,x as de,y as x}from"./esm-Cb-L4oAk.js";import{a as S,r as fe,t as pe}from"./esm-Bx6rTxIs.js";import{C as me,R as he,Wt as ge,pt as _e,tt as ve}from"./state-BemZdQIl.js";import{C as ye,R as be,i as xe,x as Se}from"./debug-BecbSVoN.js";import{Gt as Ce,Jt as we,Kt as C,Yt as Te}from"./settings-D4CpDv2y.js";import{d as Ee,m as De}from"./git-DBlOv64X.js";import{r as Oe,t as ke}from"./execFileNoThrow-DHyW8FMX.js";import{a as Ae,n as je,o as Me,r as Ne}from"./platform-B0uTQc9P.js";import{An as Pe,Bt as Fe,Ft as Ie,Gt as Le,_ as Re,jn as ze,u as Be}from"./model-Bgh_r4lg.js";import{i as Ve,t as He}from"./genericProcessUtils-B2HcDYhg.js";import{arch as Ue,hostname as We,platform as Ge,release as Ke}from"os";import{extname as qe}from"path";import{stat as Je}from"fs/promises";import{inspect as Ye}from"util";import*as Xe from"process";import{AsyncLocalStorage as Ze}from"async_hooks";function Qe(){return process.platform===`linux`&&r(process.env.CLAUDE_CODE_BUBBLEWRAP)}function $e(){return process.platform===`linux`?w??!1:!1}async function et(){if(T!==void 0)return T;if(process.platform===`darwin`)return T=null,null;try{let e=await He(process.pid,10);for(let t of e){let e=t.toLowerCase();for(let t of Ce)if(e.includes(t))return T=t,t}}catch{}return T=null,null}async function tt(){return process.env.TERMINAL_EMULATOR===`JetBrains-JediTerm`&&C.platform!==`darwin`?await et()||`pycharm`:C.terminal}function nt(){return process.env.TERMINAL_EMULATOR===`JetBrains-JediTerm`&&C.platform!==`darwin`?T===void 0?`pycharm`:T||`pycharm`:C.terminal}async function rt(){process.env.TERMINAL_EMULATOR===`JetBrains-JediTerm`&&await et()}var it,w,T,E,at=e((()=>{n(),Te(),i(),Oe(),Ve(),it=t(async()=>{if(process.platform!==`linux`)return!1;let{code:e}=await ke(`test`,[`-f`,`/.dockerenv`]);return e===0}),w=null,process.platform===`linux`&&Je(`/lib/libc.musl-${process.arch===`x64`?`x86_64`:`aarch64`}.so.1`).then(()=>{w=!0},()=>{w=!1}),E={...C,terminal:nt(),getIsDocker:it,getIsBubblewrapSandbox:Qe,isMuslEnvironment:$e,getTerminalWithJetBrainsDetectionAsync:tt,initJetBrainsDetection:rt}}));function ot(e){return st?.has(e)??!1}var st,ct=e((()=>{xe(),be()}));function D(){return O.getStore()}function lt(e,t){return O.run(e,t)}function ut(e){return e?.agentType===`subagent`}function dt(){let e=D();if(!(!ut(e)||!e.subagentName))return e.isBuiltIn?e.subagentName:`user-defined`}function ft(){let e=D();if(!(!e?.invokingRequestId||e.invocationEmitted))return e.invocationEmitted=!0,{invokingRequestId:e.invokingRequestId,invocationKind:e.invocationKind}}var O,pt=e((()=>{O=new Ze}));function mt(e){return e.startsWith(`mcp__`)?`mcp_tool`:e}function ht(){return r(process.env.OTEL_LOG_TOOL_DETAILS)}function gt(e,t){return!!(process.env.CLAUDE_CODE_ENTRYPOINT===`local-agent`||e===`claudeai-proxy`||t&&ot(t))}function _t(e,t,n){let r=vt(e);return!r||!Et.has(r.serverName)&&!gt(t,n)?{}:{mcpServerName:r.serverName,mcpToolName:r.mcpToolName}}function vt(e){if(!e.startsWith(`mcp__`))return;let t=e.split(`__`);if(t.length<3)return;let n=t[1],r=t.slice(2).join(`__`);if(!(!n||!r))return{serverName:n,mcpToolName:r}}function yt(e,t){if(e===`Skill`&&typeof t==`object`&&t&&`skill`in t&&typeof t.skill==`string`)return t.skill}function k(e,t=0){if(typeof e==`string`)return e.length>Dt?`${e.slice(0,Ot)}…[${e.length} chars]`:e;if(typeof e==`number`||typeof e==`boolean`||e==null)return e;if(t>=kt)return`<nested>`;if(Array.isArray(e)){let n=e.slice(0,M).map(e=>k(e,t+1));return e.length>M&&n.push(`…[${e.length} items]`),n}if(typeof e==`object`){let n=Object.entries(e).filter(([e])=>!e.startsWith(`_`)),r=n.slice(0,M).map(([e,n])=>[e,k(n,t+1)]);return n.length>M&&r.push([`…`,`${n.length} keys`]),Object.fromEntries(r)}return String(e)}function bt(e){if(!ht())return;let t=ye(k(e));return t.length>j&&(t=t.slice(0,j)+`…[truncated]`),t}function A(e){let t=qe(e).toLowerCase();if(!t||t===`.`)return;let n=t.slice(1);return n.length>At?`other`:n}function xt(e,t){if(!e.includes(`.`)&&!t)return;let n,r=new Set;if(t){let e=A(t);e&&(r.add(e),n=e)}for(let t of e.split(Mt)){if(!t)continue;let e=t.split(Nt);if(e.length<2)continue;let i=e[0],a=i.lastIndexOf(`/`),o=a>=0?i.slice(a+1):i;if(jt.has(o))for(let t=1;t<e.length;t++){let i=e[t];if(i.charCodeAt(0)===45)continue;let a=A(i);a&&!r.has(a)&&(r.add(a),n=n?n+`,`+a:a)}}if(n)return n}function St(){let e=D();if(e)return{agentId:e.agentId,parentSessionId:e.parentSessionId,agentType:e.agentType};let t=process.env.CLAUDE_CODE_AGENT_ID,n=process.env.CLAUDE_CODE_PARENT_SESSION_ID,r=t?`standalone`:void 0;if(t||r||n)return{...t?{agentId:t}:{},...r?{agentType:r}:{},...n?{parentSessionId:n}:{}};let i=ve();return i?{parentSessionId:i}:{}}function Ct(){try{let e=process.memoryUsage(),t=process.cpuUsage(),n=Date.now(),r;if(N&&P){let e=n-P;e>0&&(r=(t.user-N.user+(t.system-N.system))/(e*1e3)*100)}return N=t,P=n,{uptime:process.uptime(),rss:e.rss,heapTotal:e.heapTotal,heapUsed:e.heapUsed,external:e.external,arrayBuffers:e.arrayBuffers,constrainedMemory:process.constrainedMemory(),cpuUsage:t,cpuPercent:r}}catch{return}}async function wt(e={}){let t=e.model?String(e.model):Be(),n=typeof e.betas==`string`?e.betas:Pe(t).join(`,`),[r,i]=await Promise.all([Ft(),Ee()]),a=Ct();return{model:t,sessionId:_e(),userType:process.env.USER_TYPE||``,...n.length>0?{betas:n}:{},envContext:r,...process.env.CLAUDE_CODE_ENTRYPOINT&&{entrypoint:process.env.CLAUDE_CODE_ENTRYPOINT},...process.env.CLAUDE_AGENT_SDK_VERSION&&{agentSdkVersion:process.env.CLAUDE_AGENT_SDK_VERSION},isInteractive:String(he()),clientType:me(),...a&&{processMetrics:a},sweBenchRunId:process.env.SWE_BENCH_RUN_ID||``,sweBenchInstanceId:process.env.SWE_BENCH_INSTANCE_ID||``,sweBenchTaskId:process.env.SWE_BENCH_TASK_ID||``,...St(),...Ie()&&{subscriptionType:Ie()},...i&&{rh:i}}}function Tt(e,t,n={}){let{envContext:r,processMetrics:i,rh:a,skillMode:o,observerMode:s,...c}=e,l={platform:r.platform,platform_raw:r.platformRaw,arch:r.arch,node_version:r.nodeVersion,terminal:r.terminal||`unknown`,package_managers:r.packageManagers,runtimes:r.runtimes,is_running_with_bun:r.isRunningWithBun,is_ci:r.isCi,is_claubbit:r.isClaubbit,is_claude_code_remote:r.isClaudeCodeRemote,is_local_agent_mode:r.isLocalAgentMode,is_conductor:r.isConductor,is_github_action:r.isGithubAction,is_claude_code_action:r.isClaudeCodeAction,is_claude_ai_auth:r.isClaudeAiAuth,version:r.version,build_time:r.buildTime,deployment_environment:r.deploymentEnvironment};r.remoteEnvironmentType&&(l.remote_environment_type=r.remoteEnvironmentType),r.claudeCodeContainerId&&(l.claude_code_container_id=r.claudeCodeContainerId),r.claudeCodeRemoteSessionId&&(l.claude_code_remote_session_id=r.claudeCodeRemoteSessionId),r.tags&&(l.tags=r.tags.split(`,`).map(e=>e.trim()).filter(Boolean)),r.githubEventName&&(l.github_event_name=r.githubEventName),r.githubActionsRunnerEnvironment&&(l.github_actions_runner_environment=r.githubActionsRunnerEnvironment),r.githubActionsRunnerOs&&(l.github_actions_runner_os=r.githubActionsRunnerOs),r.githubActionRef&&(l.github_action_ref=r.githubActionRef),r.wslVersion&&(l.wsl_version=r.wslVersion),r.linuxDistroId&&(l.linux_distro_id=r.linuxDistroId),r.linuxDistroVersion&&(l.linux_distro_version=r.linuxDistroVersion),r.linuxKernel&&(l.linux_kernel=r.linuxKernel),r.vcs&&(l.vcs=r.vcs),r.versionBase&&(l.version_base=r.versionBase);let u={session_id:c.sessionId,model:c.model,user_type:c.userType,is_interactive:c.isInteractive===`true`,client_type:c.clientType};if(c.betas&&(u.betas=c.betas),c.entrypoint&&(u.entrypoint=c.entrypoint),c.agentSdkVersion&&(u.agent_sdk_version=c.agentSdkVersion),c.sweBenchRunId&&(u.swe_bench_run_id=c.sweBenchRunId),c.sweBenchInstanceId&&(u.swe_bench_instance_id=c.sweBenchInstanceId),c.sweBenchTaskId&&(u.swe_bench_task_id=c.sweBenchTaskId),c.agentId&&(u.agent_id=c.agentId),c.parentSessionId&&(u.parent_session_id=c.parentSessionId),c.agentType&&(u.agent_type=c.agentType),t.githubActionsMetadata){let e=t.githubActionsMetadata;l.github_actions_metadata={actor_id:e.actorId,repository_id:e.repositoryId,repository_owner_id:e.repositoryOwnerId}}let d;return(t.accountUuid||t.organizationUuid)&&(d={account_uuid:t.accountUuid,organization_uuid:t.organizationUuid}),{env:l,...i&&{process:Buffer.from(ye(i)).toString(`base64`)},...d&&{auth:d},core:u,additional:{...a&&{rh:a},...o&&{skill_mode:o},...s&&{observer_mode:s},...n}}}var Et,Dt,Ot,j,M,kt,At,jt,Mt,Nt,Pt,Ft,N,P,It=e((()=>{n(),Te(),at(),ze(),Re(),ge(),i(),ct(),Fe(),De(),Me(),pt(),Se(),Et=new Set,Dt=512,Ot=128,j=4*1024,M=20,kt=2,At=10,jt=new Set([`rm`,`mv`,`cp`,`touch`,`mkdir`,`chmod`,`chown`,`cat`,`head`,`tail`,`sort`,`stat`,`diff`,`wc`,`grep`,`rg`,`sed`]),Mt=/\s*(?:&&|\|\||[;|])\s*/,Nt=/\s+/,Pt=t(()=>{let e=`0.0.11`.match(/^\d+\.\d+\.\d+(?:-[a-z]+)?/);return e?e[0]:void 0}),Ft=t(async()=>{let[e,t,n,i]=await Promise.all([C.getPackageManagers(),C.getRuntimes(),Ne(),je()]);return{platform:we(),platformRaw:process.env.CLAUDE_CODE_HOST_PLATFORM||process.platform,arch:C.arch,nodeVersion:C.nodeVersion,terminal:E.terminal,packageManagers:e.join(`,`),runtimes:t.join(`,`),isRunningWithBun:C.isRunningWithBun(),isCi:r(process.env.CI),isClaubbit:r(process.env.CLAUBBIT),isClaudeCodeRemote:r(process.env.CLAUDE_CODE_REMOTE),isLocalAgentMode:process.env.CLAUDE_CODE_ENTRYPOINT===`local-agent`,isConductor:C.isConductor(),...process.env.CLAUDE_CODE_REMOTE_ENVIRONMENT_TYPE&&{remoteEnvironmentType:process.env.CLAUDE_CODE_REMOTE_ENVIRONMENT_TYPE},...process.env.CLAUDE_CODE_CONTAINER_ID&&{claudeCodeContainerId:process.env.CLAUDE_CODE_CONTAINER_ID},...process.env.CLAUDE_CODE_REMOTE_SESSION_ID&&{claudeCodeRemoteSessionId:process.env.CLAUDE_CODE_REMOTE_SESSION_ID},...process.env.CLAUDE_CODE_TAGS&&{tags:process.env.CLAUDE_CODE_TAGS},isGithubAction:r(process.env.GITHUB_ACTIONS),isClaudeCodeAction:r(process.env.CLAUDE_CODE_ACTION),isClaudeAiAuth:Le(),version:`0.0.11`,versionBase:Pt(),buildTime:`2026-08-13T03:55:30.763Z`,deploymentEnvironment:C.detectDeploymentEnvironment(),...r(process.env.GITHUB_ACTIONS)&&{githubEventName:process.env.GITHUB_EVENT_NAME,githubActionsRunnerEnvironment:process.env.RUNNER_ENVIRONMENT,githubActionsRunnerOs:process.env.RUNNER_OS,githubActionRef:process.env.GITHUB_ACTION_PATH?.includes(`claude-code-action/`)?process.env.GITHUB_ACTION_PATH.split(`claude-code-action/`)[1]:void 0},...Ae()&&{wslVersion:Ae()},...n??{},...i.length>0?{vcs:i.join(`,`)}:{}}}),N=null,P=null}));function Lt(e){return e.setValue(zt,!0)}function Rt(e){return e.getValue(zt)===!0}var zt,Bt=e((()=>{f(),zt=c(`OpenTelemetry SDK Context Key SUPPRESS_TRACING`)}));function Vt(e){let t={};if(typeof e!=`object`||!e)return t;for(let n in e){if(!Object.prototype.hasOwnProperty.call(e,n))continue;if(!Ht(n)){p.warn(`Invalid attribute key: ${n}`);continue}let r=e[n];if(!Ut(r)){p.warn(`Invalid attribute value set for key: ${n}`);continue}Array.isArray(r)?t[n]=r.slice():t[n]=r}return t}function Ht(e){return typeof e==`string`&&e!==``}function Ut(e){return e==null?!0:Array.isArray(e)?Wt(e):Gt(typeof e)}function Wt(e){let t;for(let n of e){if(n==null)continue;let e=typeof n;if(e!==t){if(!t){if(Gt(e)){t=e;continue}return!1}return!1}}return!0}function Gt(e){switch(e){case`number`:case`boolean`:case`string`:return!0}return!1}var Kt=e((()=>{f()}));function qt(){return e=>{p.error(Jt(e))}}function Jt(e){return typeof e==`string`?e:JSON.stringify(Yt(e))}function Yt(e){let t={},n=e;for(;n!==null;)Object.getOwnPropertyNames(n).forEach(e=>{if(t[e])return;let r=n[e];r&&(t[e]=String(r))}),n=Object.getPrototypeOf(n);return t}var Xt=e((()=>{f()}));function Zt(e){try{Qt(e)}catch{}}var Qt,$t=e((()=>{Xt(),Qt=qt()}));function en(e){let t=process.env[e];if(t==null||t.trim()===``)return;let n=Number(t);if(isNaN(n)){p.warn(`Unknown value ${Ye(t)} for ${e}, expected a number, using defaults`);return}return n}function F(e){let t=process.env[e];if(!(t==null||t.trim()===``))return t}var tn=e((()=>{f()})),nn,rn=e((()=>{nn=`2.9.0`})),an,on=e((()=>{an=`process.runtime.name`})),I,sn=e((()=>{rn(),x(),on(),I={[g]:`opentelemetry`,[an]:`node`,[_]:ie,[y]:nn}})),L,cn=e((()=>{tn(),sn(),L=performance})),ln=e((()=>{cn()}));function R(e){let t=e/1e3;return[Math.trunc(t),Math.round(e%1e3*vn)]}function un(e){return gn(R(L.timeOrigin),R(typeof e==`number`?e:L.now()))}function dn(e,t){let n=t[0]-e[0],r=t[1]-e[1];return r<0&&(--n,r+=z),[n,r]}function fn(e){return e[0]*1e6+e[1]/1e3}function pn(e){return e[0]+e[1]/z}function mn(e){return Array.isArray(e)&&e.length===2&&typeof e[0]==`number`&&typeof e[1]==`number`}function hn(e){return mn(e)||typeof e==`number`||e instanceof Date}function gn(e,t){let n=[e[0]+t[0],e[1]+t[1]];return n[1]>=z&&(n[1]-=z,n[0]+=1),n}var _n,vn,z,yn=e((()=>{ln(),_n=9,vn=10**6,z=10**_n})),B,bn=e((()=>{(function(e){e[e.SUCCESS=0]=`SUCCESS`,e[e.FAILED=1]=`FAILED`})(B||(B={}))}));function xn(e){if(!Sn(e)||Cn(e)!==En)return!1;let t=An(e);if(t===null)return!0;let n=U.call(t,`constructor`)&&t.constructor;return typeof n==`function`&&n instanceof n&&V.call(n)===kn}function Sn(e){return typeof e==`object`&&!!e}function Cn(e){return e==null?e===void 0?On:Dn:W&&W in Object(e)?wn(e):Tn(e)}function wn(e){let t=U.call(e,W),n=e[W],r=!1;try{e[W]=void 0,r=!0}catch{}let i=G.call(e);return r&&(t?e[W]=n:delete e[W]),i}function Tn(e){return G.call(e)}var En,Dn,On,V,kn,An,H,U,W,G,jn=e((()=>{En=`[object Object]`,Dn=`[object Null]`,On=`[object Undefined]`,V=Function.prototype.toString,kn=V.call(Object),An=Object.getPrototypeOf,H=Object.prototype,U=H.hasOwnProperty,W=Symbol?Symbol.toStringTag:void 0,G=H.toString}));function Mn(...e){let t=e.shift(),n=new WeakMap;for(;e.length>0;)t=Nn(t,e.shift(),0,n);return t}function K(e){return q(e)?e.slice():e}function Nn(e,t,n=0,r){let i;if(!(n>Ln)){if(n++,Y(e)||Y(t)||Fn(t))i=K(t);else if(q(e)){if(i=e.slice(),q(t))for(let e=0,n=t.length;e<n;e++)i.push(K(t[e]));else if(J(t)){let e=Object.keys(t);for(let n=0,r=e.length;n<r;n++){let r=e[n];r===`__proto__`||r===`constructor`||r===`prototype`||(i[r]=K(t[r]))}}}else if(J(e))if(J(t)){if(!In(e,t))return t;i=Object.assign({},e);let a=Object.keys(t);for(let o=0,s=a.length;o<s;o++){let s=a[o];if(s===`__proto__`||s===`constructor`||s===`prototype`)continue;let c=t[s];if(Y(c))c===void 0?delete i[s]:i[s]=c;else{let a=i[s],o=c;if(Pn(e,s,r)||Pn(t,s,r))delete i[s];else{if(J(a)&&J(o)){let n=r.get(a)||[],i=r.get(o)||[];n.push({obj:e,key:s}),i.push({obj:t,key:s}),r.set(a,n),r.set(o,i)}i[s]=Nn(i[s],c,n,r)}}}}else i=t;return i}}function Pn(e,t,n){let r=n.get(e[t])||[];for(let n=0,i=r.length;n<i;n++){let i=r[n];if(i.key===t&&i.obj===e)return!0}return!1}function q(e){return Array.isArray(e)}function Fn(e){return typeof e==`function`}function J(e){return!Y(e)&&!q(e)&&!Fn(e)&&typeof e==`object`}function Y(e){return typeof e==`string`||typeof e==`number`||typeof e==`boolean`||e===void 0||e instanceof Date||e instanceof RegExp||e===null}function In(e,t){return!(!xn(e)||!xn(t))}var Ln,Rn=e((()=>{jn(),Ln=20})),zn,Bn=e((()=>{a(),zn=class{constructor(){o(this,`_promise`,void 0),o(this,`_resolve`,void 0),o(this,`_reject`,void 0),this._promise=new Promise((e,t)=>{this._resolve=e,this._reject=t})}get promise(){return this._promise}resolve(e){this._resolve(e)}reject(e){this._reject(e)}}})),Vn,Hn=e((()=>{Bn(),a(),Vn=class{constructor(e,t){o(this,`_isCalled`,!1),o(this,`_deferred`,new zn),o(this,`_callback`,void 0),o(this,`_that`,void 0),this._callback=e,this._that=t}get isCalled(){return this._isCalled}get promise(){return this._deferred.promise}call(...e){if(!this._isCalled){this._isCalled=!0;try{Promise.resolve(this._callback.call(this._that,...e)).then(e=>this._deferred.resolve(e),e=>this._deferred.reject(e))}catch(e){this._deferred.reject(e)}}return this._deferred.promise}}}));function Un(e,t){return new Promise(n=>{d.with(Lt(d.active()),()=>{e.export(t,n)})})}var Wn=e((()=>{f(),Bt()})),Gn,X=e((()=>{Bt(),Kt(),$t(),Xt(),yn(),bn(),ln(),Rn(),Hn(),Wn(),Gn={_export:Un}}));function Kn(){if(Z===void 0)try{let e=globalThis.process.argv0;Z=e?`unknown_service:${e}`:`unknown_service`}catch{Z=`unknown_service`}return Z}var Z,qn=e((()=>{})),Q,Jn=e((()=>{Q=e=>typeof e==`object`&&!!e&&typeof e.then==`function`}));function Yn(e,t){return er.FromAttributeList(Object.entries(e),t)}function Xn(){return Yn({[ue]:Kn(),[_]:I[_],[g]:I[g],[y]:I[y]})}function Zn(e){return e.map(([e,t])=>Q(t)?[e,t.catch(t=>{p.debug(`promise rejection for resource attribute: %s - %s`,e,t)})]:[e,t])}function Qn(e){if(typeof e==`string`||e===void 0)return e;p.warn(`Schema URL must be string or undefined, got %s. Schema URL will be ignored.`,e)}function $n(e,t){let n=e?.schemaUrl,r=t?.schemaUrl,i=n===void 0||n===``,a=r===void 0||r===``;if(i)return r;if(a||n===r)return n;p.warn(`Schema URL merge conflict: old resource has "%s", updating resource has "%s". Resulting resource will have undefined Schema URL.`,n,r)}var er,tr=e((()=>{f(),X(),x(),qn(),Jn(),a(),er=class e{static FromAttributeList(t,n){let r=new e({},n);return r._rawAttributes=Zn(t),r._asyncAttributesPending=t.filter(([e,t])=>Q(t)).length>0,r}constructor(e,t){o(this,`_rawAttributes`,void 0),o(this,`_asyncAttributesPending`,!1),o(this,`_schemaUrl`,void 0),o(this,`_memoizedAttributes`,void 0);let n=e.attributes??{};this._rawAttributes=Object.entries(n).map(([e,t])=>(Q(t)&&(this._asyncAttributesPending=!0),[e,t])),this._rawAttributes=Zn(this._rawAttributes),this._schemaUrl=Qn(t?.schemaUrl)}get asyncAttributesPending(){return this._asyncAttributesPending}async waitForAsyncAttributes(){if(this.asyncAttributesPending){for(let e=0;e<this._rawAttributes.length;e++){let[t,n]=this._rawAttributes[e];this._rawAttributes[e]=[t,Q(n)?await n:n]}this._asyncAttributesPending=!1}}get attributes(){if(this.asyncAttributesPending&&p.error(`Accessing resource attributes before async attributes settled`),this._memoizedAttributes)return this._memoizedAttributes;let e={};for(let[t,n]of this._rawAttributes){if(Q(n)){p.debug(`Unsettled resource attribute ${t} skipped`);continue}n!=null&&(e[t]??(e[t]=n))}return this._asyncAttributesPending||(this._memoizedAttributes=e),e}getRawAttributes(){return this._rawAttributes}get schemaUrl(){return this._schemaUrl}merge(t){if(t==null)return this;let n=$n(this,t),r=n?{schemaUrl:n}:void 0;return e.FromAttributeList([...t.getRawAttributes(),...this.getRawAttributes()],r)}}})),nr,rr,ir=e((()=>{f(),x(),X(),a(),nr=class{constructor(){o(this,`_MAX_LENGTH`,255),o(this,`_COMMA_SEPARATOR`,`,`),o(this,`_LABEL_KEY_VALUE_SPLITTER`,`=`)}detect(e){let t={},n=F(`OTEL_RESOURCE_ATTRIBUTES`),r=F(`OTEL_SERVICE_NAME`);if(n)try{let e=this._parseResourceAttributes(n);Object.assign(t,e)}catch(e){p.debug(`EnvDetector failed: ${e instanceof Error?e.message:e}`)}return r&&(t[ue]=r),{attributes:t}}_parseResourceAttributes(e){if(!e)return{};let t={},n=e.split(this._COMMA_SEPARATOR).filter(e=>e.trim()!==``);for(let e of n){let n=e.split(this._LABEL_KEY_VALUE_SPLITTER);if(n.length!==2)throw Error(`Invalid format for OTEL_RESOURCE_ATTRIBUTES: "${e}". Expected format: key=value. The ',' and '=' characters must be percent-encoded in keys and values.`);let[r,i]=n,a=r.trim(),o=i.trim();if(a.length===0)throw Error(`Invalid OTEL_RESOURCE_ATTRIBUTES: empty attribute key in "${e}".`);let s,c;try{s=decodeURIComponent(a),c=decodeURIComponent(o)}catch(t){throw Error(`Failed to percent-decode OTEL_RESOURCE_ATTRIBUTES entry "${e}": ${t instanceof Error?t.message:t}`,{cause:t})}if(s.length>this._MAX_LENGTH)throw Error(`Attribute key exceeds the maximum length of ${this._MAX_LENGTH} characters: "${s}".`);if(c.length>this._MAX_LENGTH)throw Error(`Attribute value exceeds the maximum length of ${this._MAX_LENGTH} characters for key "${s}".`);t[s]=c}return t}},rr=new nr})),ar,or,sr,cr,lr,ur=e((()=>{ar=`host.arch`,or=`host.id`,sr=`host.name`,cr=`os.type`,lr=`os.version`}));async function dr(){if(!$)switch(Xe.platform){case`darwin`:$=(await import(`./getMachineId-darwin-CsRhaP3y.js`)).getMachineId;break;case`linux`:$=(await import(`./getMachineId-linux-Bd7UBNRQ.js`)).getMachineId;break;case`freebsd`:$=(await import(`./getMachineId-bsd-Cut1kHoA.js`)).getMachineId;break;case`win32`:$=(await import(`./getMachineId-win-DamF2CH_.js`)).getMachineId;break;default:$=(await import(`./getMachineId-unsupported-vFGP8E_8.js`)).getMachineId;break}return $()}var $,fr=e((()=>{})),pr,mr,hr=e((()=>{pr=e=>{switch(e){case`arm`:return`arm32`;case`ppc`:return`ppc32`;case`x64`:return`amd64`;default:return e}},mr=e=>{switch(e){case`sunos`:return`solaris`;case`win32`:return`windows`;default:return e}}})),gr,_r,vr=e((()=>{ur(),fr(),hr(),gr=class{detect(e){return{attributes:{[sr]:We(),[ar]:pr(Ue()),[or]:dr()}}}},_r=new gr})),yr,br,xr=e((()=>{ur(),hr(),yr=class{detect(e){return{attributes:{[cr]:mr(Ge()),[lr]:Ke()}}}},br=new yr})),Sr=e((()=>{vr(),xr(),ur()})),Cr=e((()=>{Sr()})),wr=e((()=>{ir(),Cr()})),Tr=e((()=>{tr(),wr(),qn()}));function Er(e){return Dr(e,new WeakSet)}function Dr(e,t){if(e==null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`||e instanceof Uint8Array)return!0;if(typeof e==`object`){if(t.has(e))return!1;if(t.add(e),Array.isArray(e))return e.every(e=>Dr(e,t));let n=e;return n.constructor!==Object&&n.constructor!==void 0?!1:Object.values(n).every(e=>Dr(e,t))}return!1}var Or=e((()=>{})),kr,Ar=e((()=>{f(),b(),x(),Or(),a(),kr=class{set severityText(e){this._isLogRecordReadonly()||(this._severityText=e)}get severityText(){return this._severityText}set severityNumber(e){this._isLogRecordReadonly()||(this._severityNumber=e)}get severityNumber(){return this._severityNumber}set body(e){this._isLogRecordReadonly()||(this._body=e)}get body(){return this._body}get eventName(){return this._eventName}set eventName(e){this._isLogRecordReadonly()||(this._eventName=e)}get droppedAttributesCount(){return this._droppedAttributesCount}constructor(e,t,n){o(this,`hrTime`,void 0),o(this,`hrTimeObserved`,void 0),o(this,`spanContext`,void 0),o(this,`resource`,void 0),o(this,`instrumentationScope`,void 0),o(this,`attributes`,{}),o(this,`_severityText`,void 0),o(this,`_severityNumber`,void 0),o(this,`_body`,void 0),o(this,`_eventName`,void 0),o(this,`_attributesCount`,0),o(this,`_droppedAttributesCount`,0),o(this,`_isReadonly`,!1),o(this,`_logRecordLimits`,void 0);let{timestamp:r,observedTimestamp:i,eventName:a,severityNumber:s,severityText:c,body:l,attributes:d={},exception:f,context:p}=n,h=Date.now();if(this.hrTime=ne(r??h),this.hrTimeObserved=ne(i??h),p){let e=u.getSpanContext(p);e&&m(e)&&(this.spanContext=e)}this.severityNumber=s,this.severityText=c,this.body=l,this.resource=e.resource,this.instrumentationScope=t,this._logRecordLimits=e.logRecordLimits,this._eventName=a,this.setAttributes(d),f!=null&&this._setException(f)}setAttribute(e,t){if(this._isLogRecordReadonly())return this;if(e.length===0)return p.warn(`Invalid attribute key: ${e}`),this;if(!Er(t))return p.warn(`Invalid attribute value set for key: ${e}`),this;let n=!Object.prototype.hasOwnProperty.call(this.attributes,e);return n&&this._attributesCount>=this._logRecordLimits.attributeCountLimit?(this._droppedAttributesCount++,this._droppedAttributesCount===1&&p.warn(`Dropping extra attributes.`),this):(this.attributes[e]=this._truncateToSize(t),n&&this._attributesCount++,this)}setAttributes(e){for(let[t,n]of Object.entries(e))this.setAttribute(t,n);return this}setBody(e){return this.body=e,this}setEventName(e){return this.eventName=e,this}setSeverityNumber(e){return this.severityNumber=e,this}setSeverityText(e){return this.severityText=e,this}_makeReadonly(){this._isReadonly=!0}_truncateToSize(e){let t=this._logRecordLimits.attributeValueLengthLimit;if(t<=0)return p.warn(`Attribute value limit must be positive, got ${t}`),e;if(e==null)return e;if(typeof e==`string`)return this._truncateToLimitUtil(e,t);if(e instanceof Uint8Array)return e;if(Array.isArray(e))return e.map(e=>this._truncateToSize(e));if(typeof e==`object`){let t={};for(let[n,r]of Object.entries(e))t[n]=this._truncateToSize(r);return t}return e}_setException(e){let t=!1;if(typeof e==`string`||typeof e==`number`)Object.hasOwn(this.attributes,`exception.message`)||this.setAttribute(de,String(e)),t=!0;else if(e&&typeof e==`object`){let n=e;n.code?(Object.hasOwn(this.attributes,`exception.type`)||this.setAttribute(h,n.code.toString()),t=!0):n.name&&(Object.hasOwn(this.attributes,`exception.type`)||this.setAttribute(h,n.name),t=!0),n.message&&(Object.hasOwn(this.attributes,`exception.message`)||this.setAttribute(de,n.message),t=!0),n.stack&&(Object.hasOwn(this.attributes,`exception.stacktrace`)||this.setAttribute(ee,n.stack),t=!0)}t||p.warn(`Failed to record an exception ${e}`)}_truncateToLimitUtil(e,t){return e.length<=t?e:e.substring(0,t)}_isLogRecordReadonly(){return this._isReadonly&&p.warn(`Can not execute the operation on emitted log record`),this._isReadonly}}})),jr,Mr=e((()=>{pe(),f(),Ar(),a(),jr=class{constructor(e,t){o(this,`instrumentationScope`,void 0),o(this,`_sharedState`,void 0),o(this,`_loggerConfig`,void 0),this.instrumentationScope=e,this._sharedState=t,this._loggerConfig=this._sharedState.getLoggerConfig(this.instrumentationScope)}emit(e){let t=this._loggerConfig,n=e.context||d.active(),r=e.severityNumber??S.UNSPECIFIED;if(r!==S.UNSPECIFIED&&r<t.minimumSeverity)return;if(t.traceBased){let e=u.getSpanContext(n);if(e&&m(e)&&(e.traceFlags&l.SAMPLED)!==l.SAMPLED)return}let i=new kr(this._sharedState,this.instrumentationScope,{context:n,...e});this._sharedState.loggerMetrics.emitLog(),this._sharedState.activeProcessor.onEmit(i,n),i._makeReadonly()}enabled(e){let t=this._loggerConfig;if(t.disabled)return!1;let n=e?.severityNumber;if(typeof n==`number`&&n!==S.UNSPECIFIED&&n<t.minimumSeverity)return!1;let r=e?.context||d.active();if(t.traceBased){let e=u.getSpanContext(r);if(e&&m(e)&&(e.traceFlags&l.SAMPLED)!==l.SAMPLED)return!1}let i={context:r,instrumentationScope:this.instrumentationScope,severityNumber:e?.severityNumber,eventName:e?.eventName};for(let e of this._sharedState.processors)if(!e.enabled||e.enabled(i))return!0;return!1}}})),Nr,Pr=e((()=>{Nr=class{forceFlush(){return Promise.resolve()}onEmit(e,t){}shutdown(){return Promise.resolve()}enabled(e){return!1}}})),Fr,Ir=e((()=>{b(),a(),Fr=class{constructor(e,t){o(this,`processors`,void 0),o(this,`forceFlushTimeoutMillis`,void 0),this.processors=e,this.forceFlushTimeoutMillis=t}async forceFlush(){let e=this.forceFlushTimeoutMillis;await Promise.all(this.processors.map(t=>ae(t.forceFlush(),e)))}onEmit(e,t){this.processors.forEach(n=>n.onEmit(e,t))}async shutdown(){await Promise.all(this.processors.map(e=>e.shutdown()))}enabled(e){for(let t of this.processors)if(!t.enabled||t.enabled(e))return!0;return!1}}}));function Lr(e){return`${e.name}@${e.version||``}:${e.schemaUrl||``}`}var Rr=e((()=>{})),zr,Br=e((()=>{zr=`otel.sdk.log.created`})),Vr,Hr=e((()=>{Br(),a(),Vr=class{constructor(e){o(this,`createdLogs`,void 0),this.createdLogs=e.createCounter(zr,{unit:`{log_record}`,description:`The number of logs submitted to enabled SDK Loggers.`})}emitLog(){this.createdLogs.add(1)}}})),Ur,Wr=e((()=>{Ur=`0.215.0`})),Gr,Kr,qr,Jr=e((()=>{f(),pe(),Pr(),Ir(),Rr(),Hr(),Wr(),a(),Gr={disabled:!1,minimumSeverity:S.UNSPECIFIED,traceBased:!1},Kr=()=>({...Gr}),qr=class{constructor(e,t,n,r,i,a){o(this,`loggers`,new Map),o(this,`activeProcessor`,void 0),o(this,`registeredLogRecordProcessors`,[]),o(this,`resource`,void 0),o(this,`forceFlushTimeoutMillis`,void 0),o(this,`logRecordLimits`,void 0),o(this,`processors`,void 0),o(this,`loggerMetrics`,void 0),o(this,`_loggerConfigurator`,void 0),o(this,`_loggerConfigs`,new Map),this.resource=e,this.forceFlushTimeoutMillis=t,this.logRecordLimits=n,this.processors=r,r.length>0?(this.registeredLogRecordProcessors=r,this.activeProcessor=new Fr(this.registeredLogRecordProcessors,this.forceFlushTimeoutMillis)):this.activeProcessor=new Nr,this._loggerConfigurator=i??Kr;let c=a?a.getMeter(`@opentelemetry/sdk-logs`,Ur):s();this.loggerMetrics=new Vr(c)}getLoggerConfig(e){let t=Lr(e),n=this._loggerConfigs.get(t);return n||(n=this._loggerConfigurator(e),this._loggerConfigs.set(t,n),n)}}})),Yr,Xr=e((()=>{f(),pe(),le(),b(),Mr(),Jr(),a(),Yr=class{constructor(e={}){o(this,`_shutdownOnce`,void 0),o(this,`_sharedState`,void 0);let t={resource:e.resource??oe(),forceFlushTimeoutMillis:e.forceFlushTimeoutMillis??3e4,logRecordLimits:{attributeCountLimit:e.logRecordLimits?.attributeCountLimit??128,attributeValueLengthLimit:e.logRecordLimits?.attributeValueLengthLimit??1/0},loggerConfigurator:e.loggerConfigurator??Kr,processors:e.processors??[],meterProvider:e.meterProvider};this._sharedState=new qr(t.resource,t.forceFlushTimeoutMillis,t.logRecordLimits,t.processors,t.loggerConfigurator,t.meterProvider),this._shutdownOnce=new ce(this._shutdown,this)}getLogger(e,t,n){if(this._shutdownOnce.isCalled)return p.warn(`A shutdown LoggerProvider cannot provide a Logger`),fe;e||p.warn(`Logger requested without instrumentation scope name.`);let r=e||`unknown`,i=`${r}@${t||``}:${n?.schemaUrl||``}`;return this._sharedState.loggers.has(i)||this._sharedState.loggers.set(i,new jr({name:r,version:t,schemaUrl:n?.schemaUrl},this._sharedState)),this._sharedState.loggers.get(i)}forceFlush(){return this._shutdownOnce.isCalled?(p.warn(`invalid attempt to force flush after LoggerProvider shutdown`),this._shutdownOnce.promise):this._sharedState.activeProcessor.forceFlush()}shutdown(){return this._shutdownOnce.isCalled?(p.warn(`shutdown may only be called once per LoggerProvider`),this._shutdownOnce.promise):this._shutdownOnce.call()}_shutdown(){return this._sharedState.activeProcessor.shutdown()}}})),Zr,Qr=e((()=>{b(),Zr=class{export(e,t){this._sendLogRecords(e,t)}async forceFlush(){}async shutdown(){}_exportInfo(e){return{resource:{attributes:e.resource.attributes},instrumentationScope:e.instrumentationScope,timestamp:se(e.hrTime),traceId:e.spanContext?.traceId,spanId:e.spanContext?.spanId,traceFlags:e.spanContext?.traceFlags,severityText:e.severityText,severityNumber:e.severityNumber,eventName:e.eventName,body:e.body,attributes:e.attributes}}_sendLogRecords(e,t){for(let t of e)console.dir(this._exportInfo(t),{depth:3});t?.({code:re.SUCCESS})}}}));async function $r(e){let t=[];for(let n=0,r=e.length;n<r;n++){let r=e[n];r.resource.asyncAttributesPending&&r.resource.waitForAsyncAttributes&&t.push(r.resource.waitForAsyncAttributes())}t!=null&&t.length>0&&await Promise.all(t)}var ei,ti,ni=e((()=>{f(),b(),a(),ei=class{constructor(e,t,n){o(this,`_exportCompleted`,void 0),o(this,`_exportScheduledPromise`,void 0),o(this,`_exportScheduledResolve`,void 0),this._exportScheduledPromise=new Promise(e=>{this._exportScheduledResolve=e}),this._exportCompleted=this._executeExport(e,t,n)}get exportCompleted(){return this._exportCompleted}get exportScheduled(){return this._exportScheduledPromise}async _executeExport(e,t,n){try{await $r(t),await d.with(te(d.active()),async()=>this._exportWithTimeout(e,t,n))}catch(e){v(e),this._exportScheduledResolve()}}async _exportWithTimeout(e,t,n){return new Promise((r,i)=>{let a=setTimeout(()=>{i(Error(`Timeout`))},n);e.export(t,e=>{clearTimeout(a),e.code===re.SUCCESS?r():i(e.error??Error(`BatchLogRecordProcessor: log record export failed`))}),this._exportScheduledResolve()})}},ti=class{constructor(e,t){o(this,`_maxExportBatchSize`,void 0),o(this,`_maxQueueSize`,void 0),o(this,`_scheduledDelayMillis`,void 0),o(this,`_exportTimeoutMillis`,void 0),o(this,`_exporter`,void 0),o(this,`_currentExport`,null),o(this,`_finishedLogRecords`,[]),o(this,`_timer`,void 0),o(this,`_shutdownOnce`,void 0),o(this,`_flushing`,!1),this._exporter=e,this._maxExportBatchSize=t?.maxExportBatchSize??512,this._maxQueueSize=t?.maxQueueSize??2048,this._scheduledDelayMillis=t?.scheduledDelayMillis??5e3,this._exportTimeoutMillis=t?.exportTimeoutMillis??3e4,this._shutdownOnce=new ce(this._shutdown,this),this._maxExportBatchSize>this._maxQueueSize&&(p.warn(`BatchLogRecordProcessor: maxExportBatchSize must be smaller or equal to maxQueueSize, setting maxExportBatchSize to match maxQueueSize`),this._maxExportBatchSize=this._maxQueueSize)}onEmit(e){this._shutdownOnce.isCalled||this._addToBuffer(e)}forceFlush(){return this._shutdownOnce.isCalled?this._shutdownOnce.promise:this._flushAll()}_addToBuffer(e){this._finishedLogRecords.length>=this._maxQueueSize||(this._finishedLogRecords.push(e),this._maybeStartTimer())}shutdown(){return this._shutdownOnce.call()}async _shutdown(){this.onShutdown(),await this._flushAll(),await this._exporter.shutdown()}async _flushAll(){if(this._flushing)return;this._flushing=!0;let e=this._finishedLogRecords;for(this._finishedLogRecords=[],this._clearTimer(),this._currentExport!==null&&(await this._exporter.forceFlush(),await this._currentExport.exportCompleted,this._currentExport=null);e.length>0;){let t;e.length<=this._maxExportBatchSize?(t=e,e=[]):t=e.splice(0,this._maxExportBatchSize);let n=new ei(this._exporter,t,this._exportTimeoutMillis);this._currentExport=n;try{await n.exportScheduled,await this._exporter.forceFlush(),await n.exportCompleted}catch(e){v(e)}finally{this._currentExport=null}}this._flushing=!1,this._maybeStartTimer()}_extractBatch(){if(this._finishedLogRecords.length===0)return null;if(this._finishedLogRecords.length<=this._maxExportBatchSize){let e=this._finishedLogRecords;return this._finishedLogRecords=[],e}else return this._finishedLogRecords.splice(0,this._maxExportBatchSize)}_exportOneBatch(){this._clearTimer();let e=this._extractBatch();if(e===null)return;let t=new ei(this._exporter,e,this._exportTimeoutMillis);this._currentExport=t,t.exportCompleted.then(()=>{this._currentExport=null,this._maybeStartTimer()}).catch(e=>{this._currentExport=null,v(e),this._maybeStartTimer()})}_maybeStartTimer(){if(!this._shutdownOnce.isCalled&&!this._flushing&&this._finishedLogRecords.length!==0&&this._currentExport===null){if(this._finishedLogRecords.length>=this._maxExportBatchSize){this._exportOneBatch();return}this._timer===void 0&&(this._timer=setTimeout(()=>{this._timer=void 0,this._exportOneBatch()},this._scheduledDelayMillis),typeof this._timer!=`number`&&this._timer.unref())}}_clearTimer(){this._timer!==void 0&&(clearTimeout(this._timer),this._timer=void 0)}}})),ri,ii=e((()=>{ni(),ri=class extends ti{onShutdown(){}}})),ai=e((()=>{ii()})),oi=e((()=>{ai()})),si=e((()=>{Xr(),Qr(),oi()}));export{xt as $,pn as A,Zt as B,Mn as C,un as D,gn as E,cn as F,Bt as G,Kt as H,L as I,vt as J,Rt as K,en as L,hn as M,mn as N,dn as O,R as P,A as Q,F as R,Rn as S,bn as T,Ut as U,$t as V,Vt as W,bt as X,yt as Y,wt as Z,Yn as _,Qr as a,ft as at,Vn as b,Tr as c,pt as ct,_r as d,rt as dt,It as et,vr as f,at as ft,tr as g,Xn as h,Zr as i,Tt as it,yn as j,fn as k,xr as l,lt,ir as m,ri as n,_t as nt,Yr as o,D as ot,rr as p,Lt as q,ii as r,mt as rt,Xr as s,dt as st,si as t,ht as tt,br as u,E as ut,X as v,B as w,Hn as x,Gn as y,tn as z};