@readmagic/workmate 0.0.24 → 0.0.25

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 (402) hide show
  1. package/dist/chunks/AddWorkspaceDirectory-Y5S_lMjD.js +1 -0
  2. package/dist/chunks/AgentsMdExternalIncludesDialog-Bnb1jWcg.js +1 -0
  3. package/dist/chunks/AgentsMdExternalIncludesDialog-DVbU-BaD.js +1 -0
  4. package/dist/chunks/App-B8q8PV77.js +1 -0
  5. package/dist/chunks/BackgroundTasksDialog-i0TkZgQp.js +2 -0
  6. package/dist/chunks/BypassPermissionsModeDialog-DjqGAL4C.js +1 -0
  7. package/dist/chunks/CustomSelect-BvTftqEH.js +1 -0
  8. package/dist/chunks/DiffDialog-v5r8cBKW.js +6 -0
  9. package/dist/chunks/Doctor-DKpBnbuI.js +1 -0
  10. package/dist/chunks/Doctor-uvO6NM5m.js +3 -0
  11. package/dist/chunks/ExitFlow-Dh9QdaYK.js +2 -0
  12. package/dist/chunks/InvalidConfigDialog-C9boykQn.js +1 -0
  13. package/dist/chunks/{InvalidSettingsDialog-iwh8H52b.js → InvalidSettingsDialog-UN5mleCK.js} +1 -1
  14. package/dist/chunks/KeybindingProviderSetup-DsJqfEt-.js +1 -0
  15. package/dist/chunks/MCPConnectionManager-DkZVxLEj.js +1 -0
  16. package/dist/chunks/MCPToolListView-De1W4jpj.js +1 -0
  17. package/dist/chunks/McpParsingWarnings-zkM_lGd0.js +1 -0
  18. package/dist/chunks/MessageSelector-DW_itlX-.js +3 -0
  19. package/dist/chunks/Messages-BFsCpACq.js +10 -0
  20. package/dist/chunks/Onboarding-BT90cFkn.js +1 -0
  21. package/dist/chunks/PromptInputFooterSuggestions-CCTZYbWI.js +1 -0
  22. package/dist/chunks/PromptInputHelpMenu-Bm5KY0Ma.js +1 -0
  23. package/dist/chunks/{ProviderSetup-BCSPsvfv.js → ProviderSetup-yIj8YOKF.js} +1 -1
  24. package/dist/chunks/QueryEngine-egz5mbaW.js +1 -0
  25. package/dist/chunks/REPL-D27CE4WN.js +124 -0
  26. package/dist/chunks/REPL-e8wAT1wN.js +1 -0
  27. package/dist/chunks/ResumeConversation-CWA27Lke.js +1 -0
  28. package/dist/chunks/SearchExtraToolsTool-BRchtZ9Q.js +1 -0
  29. package/dist/chunks/{SelectMulti-BQRHed-d.js → SelectMulti-BW7Ffk1G.js} +1 -1
  30. package/dist/chunks/Settings-axHLvYIy.js +3 -0
  31. package/dist/chunks/Spinner-VjwI7m_g.js +1 -0
  32. package/dist/chunks/{SpinnerGlyph-CmkRUvHe.js → SpinnerGlyph-CqrOK3Mx.js} +1 -1
  33. package/dist/chunks/TextInput-Cev5Awdd.js +22 -0
  34. package/dist/chunks/ThemePicker-CtQYHmOr.js +1 -0
  35. package/dist/chunks/TrustDialog-8Sjmuu0e.js +1 -0
  36. package/dist/chunks/{ValidationErrorsList-DgNzJQUP.js → ValidationErrorsList-INwwoerV.js} +1 -1
  37. package/dist/chunks/_baseEach-DrPH_FGo.js +1 -0
  38. package/dist/chunks/add-dir-D3RMaYxy.js +1 -0
  39. package/dist/chunks/{agentDisplay-M4pfwbMC.js → agentDisplay-B3npXoCS.js} +1 -1
  40. package/dist/chunks/{agents-DddX7lLX.js → agents-2mPGmeq6.js} +1 -1
  41. package/dist/chunks/agents-DEnmg8Xo.js +101 -0
  42. package/dist/chunks/allErrors-C9kx6lnk.js +1 -0
  43. package/dist/chunks/analytics-COpjZpvd.js +1 -0
  44. package/dist/chunks/{appleTerminalBackup-BArZWB21.js → appleTerminalBackup-CT7g8yOs.js} +1 -1
  45. package/dist/chunks/backgroundHousekeeping-BkFxfjOf.js +1 -0
  46. package/dist/chunks/backgroundHousekeeping-CvWfd99M.js +1 -0
  47. package/dist/chunks/banner-DHpTmEO7.js +2 -0
  48. package/dist/chunks/branch-Be_yDFU8.js +2 -0
  49. package/dist/chunks/{break-cache-BMXqFTeS.js → break-cache-UUt6Dkf2.js} +2 -2
  50. package/dist/chunks/btw-DUml5L1w.js +1 -0
  51. package/dist/chunks/caches-DWjwe-DN.js +1 -0
  52. package/dist/chunks/caches-VLs1tQkZ.js +1 -0
  53. package/dist/chunks/{claudeDesktop-D8ml2767.js → claudeDesktop-mBGFDbI6.js} +1 -1
  54. package/dist/chunks/{clear-B8ZtFPOK.js → clear-CrGjNe6E.js} +1 -1
  55. package/dist/chunks/{client-CpTCeWba.js → client-BDuhbzLD.js} +1 -1
  56. package/dist/chunks/{client-4iqhC8xq.js → client-BYFVVMcf.js} +1 -1
  57. package/dist/chunks/client-CO_6v4yl.js +1 -0
  58. package/dist/chunks/client-DO-O441l.js +1 -0
  59. package/dist/chunks/commands-Cn1P7Tms.js +1 -0
  60. package/dist/chunks/compact-DGUhdXcc.js +2 -0
  61. package/dist/chunks/config-C7GTF4iI.js +1 -0
  62. package/dist/chunks/config-CWPHVTic.js +3 -0
  63. package/dist/chunks/config-Cox0TM2Z.js +1 -0
  64. package/dist/chunks/context-mV5zjqmc.js +1 -0
  65. package/dist/chunks/context-noninteractive--OuiZUzL.js +1 -0
  66. package/dist/chunks/{context-noninteractive-C7wrRZnM.js → context-noninteractive-DvfVvmSE.js} +2 -2
  67. package/dist/chunks/conversation--y8PD2Lk.js +1 -0
  68. package/dist/chunks/conversation-BIPJEOwO.js +1 -0
  69. package/dist/chunks/conversationRecovery-BBJzrA0g.js +1 -0
  70. package/dist/chunks/crossProjectResume-CwZb3cEU.js +40 -0
  71. package/dist/chunks/cwd-BZMp3CZ8.js +1 -0
  72. package/dist/chunks/cwd-BvNt_018.js +1 -0
  73. package/dist/chunks/debug-CRnGsZOV.js +39 -0
  74. package/dist/chunks/{detectRepository-CfX8Lc0A.js → detectRepository-CsJLbVEe.js} +1 -1
  75. package/dist/chunks/{diff-DdpHThJ7.js → diff-DUEoNCnJ.js} +1 -1
  76. package/dist/chunks/{directoryCompletion-D_Rtg-4j.js → directoryCompletion-Bgi8DBT5.js} +1 -1
  77. package/dist/chunks/doctor-4NiE46ZG.js +1 -0
  78. package/dist/chunks/entry-D1iD76SW.js +13 -0
  79. package/dist/chunks/{esm-CGx9qY3q.js → esm-DUH16IqH.js} +1 -1
  80. package/dist/chunks/execAsync-D6SA-YsV.js +1 -0
  81. package/dist/chunks/{execFileNoThrow-BTachNBI.js → execFileNoThrow-BgRsj_SW.js} +3 -3
  82. package/dist/chunks/exit-CrsQsjbx.js +1 -0
  83. package/dist/chunks/extraUsage-BtHE-SBX.js +1 -0
  84. package/dist/chunks/extractMemories-kogJzpit.js +1 -0
  85. package/dist/chunks/fast-CuNVwVTr.js +1 -0
  86. package/dist/chunks/fast-RlFnwGRV.js +1 -0
  87. package/dist/chunks/fetchModelList-Cjow_QGy.js +1 -0
  88. package/dist/chunks/fetchModelList-uiCPVqbJ.js +1 -0
  89. package/dist/chunks/fileSuggestions-C96V9-Ne.js +3 -0
  90. package/dist/chunks/firstPartyEventLogger-CN9UOmEC.js +1 -0
  91. package/dist/chunks/firstPartyEventLogger-RR5rvDtk.js +1 -0
  92. package/dist/chunks/{gemini-C_ApXgwc.js → gemini-4YGElN3H.js} +2 -2
  93. package/dist/chunks/generateSessionName-BHIKyXpz.js +1 -0
  94. package/dist/chunks/{genericProcessUtils-DwQFuna9.js → genericProcessUtils-BNlr-QxM.js} +1 -1
  95. package/dist/chunks/getMachineId-bsd-DTYGimUN.js +1 -0
  96. package/dist/chunks/getMachineId-darwin-DqIFUVvd.js +2 -0
  97. package/dist/chunks/getMachineId-linux-CnCTmdzd.js +1 -0
  98. package/dist/chunks/getMachineId-unsupported-Cx21ssu1.js +1 -0
  99. package/dist/chunks/getMachineId-win-vZhex7KX.js +1 -0
  100. package/dist/chunks/goal-ePK_jLo3.js +3 -0
  101. package/dist/chunks/grok-DnmklTrm.js +1 -0
  102. package/dist/chunks/help-B7xRle-V.js +1 -0
  103. package/dist/chunks/history-kOw3CcLT.js +1 -0
  104. package/dist/chunks/hooks-BDY1jMbS.js +1 -0
  105. package/dist/chunks/{hooks-DR3IYPJ3.js → hooks-BN5f58HY.js} +2 -2
  106. package/dist/chunks/install-DrMiHa2Q.js +1 -0
  107. package/dist/chunks/instrumentation-Oj5xagJG.js +21 -0
  108. package/dist/chunks/{job-YhJQWgE0.js → job-D9ypO0cd.js} +1 -1
  109. package/dist/chunks/keybindings-BRRN_eap.js +1 -0
  110. package/dist/chunks/launchLocalMemory-DliLezJw.js +3 -0
  111. package/dist/chunks/launchOnboarding-A-kk-7ID.js +8 -0
  112. package/dist/chunks/loadAgentsDir-CJAK4kif.js +1 -0
  113. package/dist/chunks/{loadAgentsDir-B0Anodo0.js → loadAgentsDir-DGozQu_6.js} +550 -550
  114. package/dist/chunks/{loadPluginHooks-BSwCtQ6T.js → loadPluginHooks-BiHPKDaY.js} +1 -1
  115. package/dist/chunks/{loader-CICGtLp2.js → loader-CtoR-vO-.js} +1 -1
  116. package/dist/chunks/{localSearch-BxLYi6w_.js → localSearch-BU02Qsv9.js} +1 -1
  117. package/dist/chunks/localSearch-DyaB2Rm-.js +1 -0
  118. package/dist/chunks/{log-D2TIwHBV.js → log-DoSpAwRP.js} +1 -1
  119. package/dist/chunks/logoUtils-DLd6JKqW.js +1 -0
  120. package/dist/chunks/{magicDocs-Bkz7ZcmL.js → magicDocs-Bj8LYrN2.js} +2 -2
  121. package/dist/chunks/main-B_09WbaG.js +345 -0
  122. package/dist/chunks/managedEnv-BJGfe3m7.js +1 -0
  123. package/dist/chunks/{managedEnv-OPlzUPbJ.js → managedEnv-CIWJsuty.js} +1 -1
  124. package/dist/chunks/mcp-1nBvcNxw.js +1 -0
  125. package/dist/chunks/mcp-7DXpXMdT.js +2 -0
  126. package/dist/chunks/mcp-kw99WVi2.js +6 -0
  127. package/dist/chunks/memory-CjWvzR_9.js +1 -0
  128. package/dist/chunks/mode-CBKawxnD.js +2 -0
  129. package/dist/chunks/model-DpZaKZMb.js +1 -0
  130. package/dist/chunks/model-DwbqvCY2.js +1 -0
  131. package/dist/chunks/modelOptions-CXBfKFXA.js +1 -0
  132. package/dist/chunks/nativeInstaller-SmPeEisk.js +1 -0
  133. package/dist/chunks/{notifications-Bc6k-Ozy.js → notifications-ql0eSo0Y.js} +1 -1
  134. package/dist/chunks/onChangeAppState-D85b33R5.js +1 -0
  135. package/dist/chunks/open-Cyrr4E5x.js +1 -0
  136. package/dist/chunks/openai-D_j7-KW6.js +2 -0
  137. package/dist/chunks/overlayContext-CLjlCFBl.js +1 -0
  138. package/dist/chunks/{panel-CVS4SK_E.js → panel-DMZkOEiU.js} +1 -1
  139. package/dist/chunks/parser-2usBI4G-.js +1 -0
  140. package/dist/chunks/{parser-Cg6hSCmn.js → parser-UqADrvxF.js} +1 -1
  141. package/dist/chunks/partition-CwxTlmMd.js +1 -0
  142. package/dist/chunks/{pasteStore-P0zP-ch0.js → pasteStore-ovtxMVR5.js} +1 -1
  143. package/dist/chunks/permissions-CgsvWOk_.js +3 -0
  144. package/dist/chunks/pidLock-B-SW3Nhx.js +3 -0
  145. package/dist/chunks/plan-BJrWtXEh.js +1 -0
  146. package/dist/chunks/platform-DsMIk3eq.js +2 -0
  147. package/dist/chunks/plugin-D97VJAxW.js +17 -0
  148. package/dist/chunks/{pluginAutoupdate-ennb9k8_.js → pluginAutoupdate-DQqYDPVg.js} +1 -1
  149. package/dist/chunks/{pluginBlocklist-9OrNEh--.js → pluginBlocklist-BAr9WTup.js} +1 -1
  150. package/dist/chunks/pluginCliCommands-CUGPc853.js +1 -0
  151. package/dist/chunks/{pluginFlagging-js_-WmYj.js → pluginFlagging-BO_3qjfs.js} +1 -1
  152. package/dist/chunks/pluginOperations-rTrzu6Vg.js +2 -0
  153. package/dist/chunks/pluginStartupCheck-BRHnXlym.js +1 -0
  154. package/dist/chunks/{pluginStartupCheck-SRXOyqr7.js → pluginStartupCheck-BX6cv-vs.js} +1 -1
  155. package/dist/chunks/plugins-9crasx2V.js +4 -0
  156. package/dist/chunks/poorMode-BaS0DBUO.js +1 -0
  157. package/dist/chunks/{poorMode-B0QGV6Ci.js → poorMode-DmvzFAz_.js} +1 -1
  158. package/dist/chunks/print-Bi3xVdB3.js +13 -0
  159. package/dist/chunks/processBashCommand-BBtnCx-7.js +1 -0
  160. package/dist/chunks/processSlashCommand-jzF0GmLO.js +5 -0
  161. package/dist/chunks/{projectOnboardingState-B5YATuc6.js → projectOnboardingState--L3BKjOE.js} +1 -1
  162. package/dist/chunks/prompt-CmijKW7G.js +1 -0
  163. package/dist/chunks/prompt-DYBx_D0H.js +1 -0
  164. package/dist/chunks/{prompt-CJ1l3XXk.js → prompt-DzO1um1h.js} +4 -4
  165. package/dist/chunks/{promptEditor-DoGHJN_W.js → promptEditor-B6S_Rzcu.js} +2 -2
  166. package/dist/chunks/protocolHandler-BWgH1jaF.js +13 -0
  167. package/dist/chunks/{proxy-CDBfZjO7.js → proxy-BjkGlmBu.js} +1 -1
  168. package/dist/chunks/reconciler-CVMmAaCy.js +1 -0
  169. package/dist/chunks/refresh-CAGv8BJY.js +1 -0
  170. package/dist/chunks/reject-CEUkoI2G.js +1 -0
  171. package/dist/chunks/{reload-plugins-CQZFQLWP.js → reload-plugins-DeyJTx4s.js} +1 -1
  172. package/dist/chunks/rename-DPFis9g_.js +1 -0
  173. package/dist/chunks/{renderOptions-DV0dn0IW.js → renderOptions-DRS2EslG.js} +1 -1
  174. package/dist/chunks/resume-N4O5YI-S.js +2 -0
  175. package/dist/chunks/ripgrep-3omwGI-l.js +1 -0
  176. package/dist/chunks/ripgrep-CgQrN3XX.js +5 -0
  177. package/dist/chunks/{runtimeObserver-DEuR8z0f.js → runtimeObserver-C0CJvA3q.js} +1 -1
  178. package/dist/chunks/{runtimeObserver-PJ1o8GRA.js → runtimeObserver-DMSzdFWt.js} +4 -4
  179. package/dist/chunks/sandbox-adapter-D15jjHJR.js +1 -0
  180. package/dist/chunks/sandbox-toggle-Tbbaw18C.js +1 -0
  181. package/dist/chunks/searchExtraTools-BoFc__Eg.js +1 -0
  182. package/dist/chunks/select-Fq6g2Ejk.js +1 -0
  183. package/dist/chunks/sessionFileAccessHooks-Rgsp4_Ex.js +1 -0
  184. package/dist/chunks/{sessionObserver-BtKjvteq.js → sessionObserver-CRie77tp.js} +2 -2
  185. package/dist/chunks/sessionObserver-PcaVCVkX.js +1 -0
  186. package/dist/chunks/sessionStorage-Dkf7FRgA.js +1 -0
  187. package/dist/chunks/sessionTracing-D7rekMdW.js +11 -0
  188. package/dist/chunks/settings-8fwIkMDV.js +1 -0
  189. package/dist/chunks/settings-CodSADx8.js +24 -0
  190. package/dist/chunks/setup-DBiIrXrh.js +3 -0
  191. package/dist/chunks/{shadowedRuleDetection-Bg_aIc5Z.js → shadowedRuleDetection-CTnYVrmP.js} +1 -1
  192. package/dist/chunks/{sideQuestion-D49GsfH7.js → sideQuestion-Cl8m2qYx.js} +3 -3
  193. package/dist/chunks/sinks-CiupmfTg.js +1 -0
  194. package/dist/chunks/sinks-DH83d_kd.js +1 -0
  195. package/dist/chunks/skillChangeDetector-BrrZaFkT.js +1 -0
  196. package/dist/chunks/{skillGapStore-CcFoHNLl.js → skillGapStore-es3K-aYe.js} +2 -2
  197. package/dist/chunks/{skillLifecycle-Bnz_4wE5.js → skillLifecycle-BcgoOQBk.js} +2 -2
  198. package/dist/chunks/{skillSearchPanel-C_5yUhqn.js → skillSearchPanel-CuDDb1L-.js} +4 -4
  199. package/dist/chunks/skills-BRtgqnLz.js +1 -0
  200. package/dist/chunks/{src-CiJCsqUl.js → src-C8gyNm5a.js} +1 -1
  201. package/dist/chunks/src-Db7K3F_i.js +3 -0
  202. package/dist/chunks/startupProfiler-D1NRu2nj.js +1 -0
  203. package/dist/chunks/startupProfiler-DF0AjiDf.js +3 -0
  204. package/dist/chunks/{state-B4jiUise.js → state-BQ4BEGin.js} +1 -1
  205. package/dist/chunks/state-D3gvDiu8.js +1 -0
  206. package/dist/chunks/status-WXA16wIM.js +1 -0
  207. package/dist/chunks/statusNoticeHelpers-BfmIub5L.js +1 -0
  208. package/dist/chunks/{stringUtils-C718f5ey.js → stringUtils-Bu_lJH5c.js} +1 -1
  209. package/dist/chunks/switcher-5gilU5_R.js +1 -0
  210. package/dist/chunks/{switcher-DZwUo5Ed.js → switcher-DMfuKuw_.js} +1 -1
  211. package/dist/chunks/{tasks-DdcUQEeD.js → tasks-B6gYXxOx.js} +1 -1
  212. package/dist/chunks/{templateJobs-C8qsPrLj.js → templateJobs-BW6TaqEC.js} +1 -1
  213. package/dist/chunks/{terminalSetup-B_10N_gE.js → terminalSetup-BgIXFBpd.js} +4 -4
  214. package/dist/chunks/{terminalSetup-qc2PlvOm.js → terminalSetup-C-g9Xvj3.js} +1 -1
  215. package/dist/chunks/{theme-f1h2QI8J.js → theme-9AZceq_m.js} +1 -1
  216. package/dist/chunks/tipRegistry-DtO1H_Wo.js +2 -0
  217. package/dist/chunks/{toolEventObserver-7QP38x4t.js → toolEventObserver-DTuJcREC.js} +1 -1
  218. package/dist/chunks/toolPool-DHS8jWaL.js +1 -0
  219. package/dist/chunks/{types-Dx7P7JLQ.js → types-97nL3naE.js} +16 -16
  220. package/dist/chunks/{udsClient-cQz6nJ_T.js → udsClient-CmYHFiBD.js} +1 -1
  221. package/dist/chunks/{use-select-navigation-hWL5VHnL.js → use-select-navigation-BStVRvcX.js} +1 -1
  222. package/dist/chunks/useExitOnCtrlCDWithKeybindings-DWRFdFoU.js +1 -0
  223. package/dist/chunks/useMainLoopModel-DSN5HjV1.js +1 -0
  224. package/dist/chunks/useManagePlugins-ntnOf5OU.js +1 -0
  225. package/dist/chunks/useMergedTools-C5Yns9Ij.js +1 -0
  226. package/dist/chunks/useSearchInput-B_mY9wBq.js +1 -0
  227. package/dist/chunks/useSettingsErrors-CM7tThcp.js +1 -0
  228. package/dist/chunks/util-Bb2S6g9N.js +1 -0
  229. package/dist/chunks/{validatePlugin-BMSoeb_b.js → validatePlugin-D8WQ5z4W.js} +1 -1
  230. package/dist/chunks/vim-Dpnhgoz_.js +1 -0
  231. package/dist/chunks/worktree-a5oOPSYl.js +1 -0
  232. package/dist/cli.js +1 -1
  233. package/package.json +1 -12
  234. package/dist/chunks/AddWorkspaceDirectory-Ch8IcWXO.js +0 -1
  235. package/dist/chunks/AgentsMdExternalIncludesDialog-Cyia0s4g.js +0 -1
  236. package/dist/chunks/AgentsMdExternalIncludesDialog-LjI_H_Au.js +0 -1
  237. package/dist/chunks/App-BOqh_1tN.js +0 -1
  238. package/dist/chunks/BackgroundTasksDialog-CSEuuoq9.js +0 -2
  239. package/dist/chunks/BypassPermissionsModeDialog-CwfCwUr9.js +0 -1
  240. package/dist/chunks/CustomSelect-wmZ9jz0W.js +0 -1
  241. package/dist/chunks/DiffDialog-BpXIEWiE.js +0 -6
  242. package/dist/chunks/Doctor-CMpr7tdf.js +0 -1
  243. package/dist/chunks/Doctor-DqW6j3_B.js +0 -3
  244. package/dist/chunks/ExitFlow-DacaBTlk.js +0 -2
  245. package/dist/chunks/Grove-CNqYPWI6.js +0 -11
  246. package/dist/chunks/InvalidConfigDialog-0TMJItCC.js +0 -1
  247. package/dist/chunks/KeybindingProviderSetup-D49HHTXD.js +0 -1
  248. package/dist/chunks/MCPConnectionManager-Cie77ZAK.js +0 -1
  249. package/dist/chunks/MCPToolListView-B4ehtkXd.js +0 -1
  250. package/dist/chunks/McpParsingWarnings-Bff66RtJ.js +0 -1
  251. package/dist/chunks/MessageSelector-Dpd6Iywp.js +0 -3
  252. package/dist/chunks/Messages-DN7M3oS_.js +0 -10
  253. package/dist/chunks/Onboarding-CQmE3rUf.js +0 -1
  254. package/dist/chunks/PromptInputFooterSuggestions-HI6HH3TP.js +0 -1
  255. package/dist/chunks/PromptInputHelpMenu-3QNUC2Cg.js +0 -1
  256. package/dist/chunks/QueryEngine-DdLWvJv6.js +0 -1
  257. package/dist/chunks/REPL-BqO9KcK_.js +0 -124
  258. package/dist/chunks/REPL-CmZmypfF.js +0 -1
  259. package/dist/chunks/ResumeConversation-DBqX7gva.js +0 -1
  260. package/dist/chunks/SearchExtraToolsTool-BsSoILFj.js +0 -1
  261. package/dist/chunks/Settings-B-7yBewS.js +0 -3
  262. package/dist/chunks/Spinner-ByQXTvAA.js +0 -1
  263. package/dist/chunks/TextInput-B8ruWRf2.js +0 -22
  264. package/dist/chunks/ThemePicker-BQErFFW1.js +0 -1
  265. package/dist/chunks/TrustDialog-BIhz6AZE.js +0 -1
  266. package/dist/chunks/_baseEach-CsIRoaTH.js +0 -1
  267. package/dist/chunks/add-dir-CrUDs19x.js +0 -1
  268. package/dist/chunks/agents-CGaCQeLw.js +0 -101
  269. package/dist/chunks/allErrors-BF73lon8.js +0 -1
  270. package/dist/chunks/analytics-DJobLaWP.js +0 -1
  271. package/dist/chunks/backgroundHousekeeping-Bq3LMsVR.js +0 -17
  272. package/dist/chunks/backgroundHousekeeping-Cl3Ox7Qh.js +0 -1
  273. package/dist/chunks/banner-Cu2-XUek.js +0 -2
  274. package/dist/chunks/branch-Yg_taNlT.js +0 -2
  275. package/dist/chunks/btw-udbprVvu.js +0 -1
  276. package/dist/chunks/caches-ChjIEcdd.js +0 -1
  277. package/dist/chunks/caches-DLJ6urv-.js +0 -1
  278. package/dist/chunks/client-BiqbIkwr.js +0 -1
  279. package/dist/chunks/client-CZ8nyVh5.js +0 -1
  280. package/dist/chunks/commands-CVCpJo7M.js +0 -1
  281. package/dist/chunks/compact-izk6RKHQ.js +0 -2
  282. package/dist/chunks/config-C-Y2qtB2.js +0 -3
  283. package/dist/chunks/config-CFqpXMFX.js +0 -1
  284. package/dist/chunks/config-DD8fCYXn.js +0 -1
  285. package/dist/chunks/context-BbVm4SWK.js +0 -1
  286. package/dist/chunks/context-noninteractive-x0HAzWhc.js +0 -1
  287. package/dist/chunks/conversation-DouVzO0K.js +0 -1
  288. package/dist/chunks/conversation-DrVkifKy.js +0 -1
  289. package/dist/chunks/conversationRecovery-DliPBo_z.js +0 -1
  290. package/dist/chunks/crossProjectResume-DxMy05_P.js +0 -40
  291. package/dist/chunks/cwd-Dc3NV7s8.js +0 -1
  292. package/dist/chunks/cwd-Pa83R95t.js +0 -1
  293. package/dist/chunks/datadog-Cu3s7P48.js +0 -1
  294. package/dist/chunks/debug-Bglx1aTu.js +0 -39
  295. package/dist/chunks/doctor-D_kV_D_l.js +0 -1
  296. package/dist/chunks/entry-Bxseqbi_.js +0 -13
  297. package/dist/chunks/esm-BXTZz3av.js +0 -1
  298. package/dist/chunks/execAsync-Bv2yxuGe.js +0 -1
  299. package/dist/chunks/exit-C_R_FgzR.js +0 -1
  300. package/dist/chunks/extraUsage-xMuDiNKh.js +0 -1
  301. package/dist/chunks/extractMemories-D4Dl1itt.js +0 -1
  302. package/dist/chunks/fast-DH-C5IZs.js +0 -1
  303. package/dist/chunks/fast-bopOPrtf.js +0 -1
  304. package/dist/chunks/fetchModelList-DC4VQpqa.js +0 -1
  305. package/dist/chunks/fetchModelList-FE8tzTDc.js +0 -1
  306. package/dist/chunks/fileSuggestions-C-9unnoJ.js +0 -3
  307. package/dist/chunks/firstPartyEventLogger-QmjjQmgt.js +0 -3
  308. package/dist/chunks/firstPartyEventLogger-lFeqhtfh.js +0 -1
  309. package/dist/chunks/generateSessionName-CQ03xlYI.js +0 -1
  310. package/dist/chunks/getMachineId-bsd-Cut1kHoA.js +0 -1
  311. package/dist/chunks/getMachineId-darwin-CsRhaP3y.js +0 -2
  312. package/dist/chunks/getMachineId-linux-Bd7UBNRQ.js +0 -1
  313. package/dist/chunks/getMachineId-unsupported-vFGP8E_8.js +0 -1
  314. package/dist/chunks/getMachineId-win-DamF2CH_.js +0 -1
  315. package/dist/chunks/goal-CdL29Y8C.js +0 -3
  316. package/dist/chunks/grok-C6WAslUT.js +0 -1
  317. package/dist/chunks/grove-O6qp7ITR.js +0 -1
  318. package/dist/chunks/help-DxanITNN.js +0 -1
  319. package/dist/chunks/history-BMycjPTT.js +0 -1
  320. package/dist/chunks/hooks-D9ApLkBp.js +0 -1
  321. package/dist/chunks/install-0D9u2dZw.js +0 -1
  322. package/dist/chunks/instrumentation-BFiGwntt.js +0 -21
  323. package/dist/chunks/keybindings-DZrF9iNd.js +0 -1
  324. package/dist/chunks/launchLocalMemory-DhJ56KDc.js +0 -3
  325. package/dist/chunks/launchOnboarding-DmMoZwv5.js +0 -8
  326. package/dist/chunks/loadAgentsDir-BbUR6pqH.js +0 -1
  327. package/dist/chunks/localSearch-zfn7jgrh.js +0 -1
  328. package/dist/chunks/logoUtils-CRxTutvr.js +0 -1
  329. package/dist/chunks/main-9ksgUUY_.js +0 -345
  330. package/dist/chunks/managedEnv-BEqrGqn1.js +0 -1
  331. package/dist/chunks/mcp-ChF12reQ.js +0 -1
  332. package/dist/chunks/mcp-DoEl5uah.js +0 -2
  333. package/dist/chunks/mcp-hp9qqjAy.js +0 -6
  334. package/dist/chunks/memory-Qv-wGNQ5.js +0 -1
  335. package/dist/chunks/mode-bFXPCR2P.js +0 -2
  336. package/dist/chunks/model-6lkW4o2c.js +0 -1
  337. package/dist/chunks/model-BvQFFOf8.js +0 -1
  338. package/dist/chunks/modelOptions-BBvF3wHK.js +0 -1
  339. package/dist/chunks/nativeInstaller-CdjmE9Zy.js +0 -1
  340. package/dist/chunks/onChangeAppState-DLjZ1x95.js +0 -1
  341. package/dist/chunks/open-BtQHzzL9.js +0 -1
  342. package/dist/chunks/openai-D46QvESE.js +0 -2
  343. package/dist/chunks/overlayContext-8--_fbvY.js +0 -1
  344. package/dist/chunks/parser-CG5RuOCK.js +0 -1
  345. package/dist/chunks/partition-DznN4XZH.js +0 -1
  346. package/dist/chunks/permissions-DmGFViHI.js +0 -3
  347. package/dist/chunks/pidLock-Cm4sW35f.js +0 -3
  348. package/dist/chunks/plan-CzGBz_87.js +0 -1
  349. package/dist/chunks/platform-BacQ6ACS.js +0 -2
  350. package/dist/chunks/plugin-CluR79xX.js +0 -17
  351. package/dist/chunks/pluginCliCommands-CJv5uhOG.js +0 -1
  352. package/dist/chunks/pluginOperations-CcUSHAIa.js +0 -2
  353. package/dist/chunks/pluginStartupCheck-CRBUO9gP.js +0 -1
  354. package/dist/chunks/plugins-IwwaCDba.js +0 -4
  355. package/dist/chunks/poorMode-G-pnu6NM.js +0 -1
  356. package/dist/chunks/print-CgszM1ea.js +0 -13
  357. package/dist/chunks/processBashCommand-D098WsqY.js +0 -1
  358. package/dist/chunks/processSlashCommand-DOQFjJ88.js +0 -5
  359. package/dist/chunks/prompt-BKPmDAuL.js +0 -1
  360. package/dist/chunks/prompt-CgOklk7z.js +0 -1
  361. package/dist/chunks/protocolHandler-DjQALaU2.js +0 -13
  362. package/dist/chunks/reconciler-ykkSPR-i.js +0 -1
  363. package/dist/chunks/refresh-Dn_I1R4v.js +0 -1
  364. package/dist/chunks/registerProtocol-CAsDme_E.js +0 -1
  365. package/dist/chunks/reject-DtcCfuZV.js +0 -1
  366. package/dist/chunks/rename-DyEfsZiq.js +0 -1
  367. package/dist/chunks/resume-BcXEDUqZ.js +0 -2
  368. package/dist/chunks/ripgrep-DLs8MraF.js +0 -1
  369. package/dist/chunks/ripgrep-Dl3y5r4m.js +0 -5
  370. package/dist/chunks/sandbox-adapter-DfB9kgQD.js +0 -1
  371. package/dist/chunks/sandbox-toggle-D9GDUsTl.js +0 -1
  372. package/dist/chunks/searchExtraTools-D4gMMQv0.js +0 -1
  373. package/dist/chunks/select-DIxfl_VN.js +0 -1
  374. package/dist/chunks/sessionFileAccessHooks-lbgHnVvi.js +0 -1
  375. package/dist/chunks/sessionObserver-D6qzEdGJ.js +0 -1
  376. package/dist/chunks/sessionStorage-C_7gow_z.js +0 -1
  377. package/dist/chunks/sessionTracing-CtbeAD0s.js +0 -11
  378. package/dist/chunks/settings-B2jvL8Dp.js +0 -24
  379. package/dist/chunks/settings-CisDe8DB.js +0 -1
  380. package/dist/chunks/setup-qecdf-ES.js +0 -3
  381. package/dist/chunks/sinks-C-lP7uyO.js +0 -1
  382. package/dist/chunks/sinks-De-B1lPQ.js +0 -1
  383. package/dist/chunks/skillChangeDetector-DkOJoNhT.js +0 -1
  384. package/dist/chunks/skills-BE5scC-g.js +0 -1
  385. package/dist/chunks/src-CHw1lvBc.js +0 -3
  386. package/dist/chunks/startupProfiler-BH0FoI66.js +0 -1
  387. package/dist/chunks/startupProfiler-CJdr3SxP.js +0 -3
  388. package/dist/chunks/state-BhOKSFi5.js +0 -1
  389. package/dist/chunks/status-Dw09WZLd.js +0 -1
  390. package/dist/chunks/statusNoticeHelpers-BRQpUIlH.js +0 -1
  391. package/dist/chunks/switcher-CgZVah7U.js +0 -1
  392. package/dist/chunks/tipRegistry-B71o4qWr.js +0 -2
  393. package/dist/chunks/toolPool-V-7Yv0GA.js +0 -1
  394. package/dist/chunks/useExitOnCtrlCDWithKeybindings-BKwzUpgb.js +0 -1
  395. package/dist/chunks/useMainLoopModel-DxvV70Ru.js +0 -1
  396. package/dist/chunks/useManagePlugins-BXLXazrR.js +0 -1
  397. package/dist/chunks/useMergedTools-CCgnBJzO.js +0 -1
  398. package/dist/chunks/useSearchInput-CzopttqC.js +0 -1
  399. package/dist/chunks/useSettingsErrors-SFPWfxsA.js +0 -1
  400. package/dist/chunks/util-Cbb3S6SX.js +0 -1
  401. package/dist/chunks/vim-CoRp9lY1.js +0 -1
  402. package/dist/chunks/worktree-Vm-SNY5x.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{i,l as a,o}from"./envUtils-DfkgIdYf.js";import{n as s,t as c}from"./defineProperty-C-QyHrDq.js";import{Pt as l,at as u}from"./state-BQ4BEGin.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?.[1])t.push(`mcp`),t.push(n[1].toLowerCase());else{let n=e.match(/^([^:[]+):/);n?.[1]&&t.push(n[1].trim().toLowerCase())}let r=e.match(/^\[([^\]]+)]/);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?.[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,Fe,Ie,Le,Re,ze,Be,Ve,He,Ue,We,x=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 Fe({message:r,cause:Ne(n)});let a=n,o=a?.error?.type;return t===400?new Le(t,a,r,i,o):t===401?new Re(t,a,r,i,o):t===403?new ze(t,a,r,i,o):t===404?new Be(t,a,r,i,o):t===409?new Ve(t,a,r,i,o):t===422?new He(t,a,r,i,o):t===429?new Ue(t,a,r,i,o):t>=500?new We(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)}},Fe=class extends y{constructor({message:e,cause:t}){super(void 0,void 0,e||`Connection error.`,void 0),t&&(this.cause=t)}},Ie=class extends Fe{constructor({message:e}={}){super({message:e??`Request timed out.`})}},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{},We=class extends y{}}));function Ge(e){return typeof e==`object`?e??{}:{}}function Ke(e){if(!e)return!0;for(let t in e)return!1;return!0}function qe(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var Je,Ye,Xe,Ze,Qe,$e,et=e((()=>{x(),Je=/^[a-z][a-z0-9+.-]*:/i,Ye=e=>Je.test(e),Xe=e=>(Xe=Array.isArray,Xe(e)),Ze=Xe,Qe=(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},$e=e=>{try{return JSON.parse(e)}catch{return}}})),tt,nt=e((()=>{tt=e=>new Promise(t=>setTimeout(t,e))})),S,rt=e((()=>{S=`0.81.0`}));function it(){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 at(){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 ot,st,ct,lt,ut,dt,ft=e((()=>{rt(),ot=()=>typeof window<`u`&&window.document!==void 0&&typeof navigator<`u`,st=()=>{let e=it();if(e===`deno`)return{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":S,"X-Stainless-OS":lt(Deno.build.os),"X-Stainless-Arch":ct(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":S,"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":S,"X-Stainless-OS":lt(globalThis.process.platform??`unknown`),"X-Stainless-Arch":ct(globalThis.process.arch??`unknown`),"X-Stainless-Runtime":`node`,"X-Stainless-Runtime-Version":globalThis.process.version??`unknown`};let t=at();return t?{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":S,"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":S,"X-Stainless-OS":`Unknown`,"X-Stainless-Arch":`unknown`,"X-Stainless-Runtime":`unknown`,"X-Stainless-Runtime-Version":`unknown`}},ct=e=>e===`x32`?`x32`:e===`x86_64`||e===`x64`?`x64`:e===`arm`?`arm`:e===`aarch64`||e===`arm64`?`arm64`:e?`other:${e}`:`unknown`,lt=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`),dt=()=>ut??(ut=st())}));function pt(){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 mt(...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 ht(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator]();return mt({start(){},async pull(e){let{done:n,value:r}=await t.next();n?e.close():e.enqueue(r)},async cancel(){await t.return?.()}})}function gt(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 _t(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 vt=e((()=>{})),yt,bt=e((()=>{yt=({headers:e,body:t})=>({bodyHeaders:{"content-type":`application/json`},body:JSON.stringify(t)})}));function xt(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 St=e((()=>{x()}));function Ct(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 wt(e){let t;return(Et??(t=new globalThis.TextEncoder,Et=t.encode.bind(t)))(e)}function Tt(e){let t;return(Dt??(t=new globalThis.TextDecoder,Dt=t.decode.bind(t)))(e)}var Et,Dt,Ot=e((()=>{}));function kt(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 At(e){for(let t=0;t<e.length-1;t++){if(e[t]===10&&e[t+1]===10||e[t]===13&&e[t+1]===13)return t+2;if(e[t]===13&&e[t+1]===10&&t+3<e.length&&e[t+2]===13&&e[t+3]===10)return t+4}return-1}var C,w,jt,Mt=e((()=>{_(),Ot(),jt=class{constructor(){C.set(this,void 0),w.set(this,void 0),h(this,C,new Uint8Array,`f`),h(this,w,null,`f`)}decode(e){if(e==null)return[];let t=e instanceof ArrayBuffer?new Uint8Array(e):typeof e==`string`?wt(e):e;h(this,C,Ct([g(this,C,`f`),t]),`f`);let n=[],r;for(;(r=kt(g(this,C,`f`),g(this,w,`f`)))!=null;){if(r.carriage&&g(this,w,`f`)==null){h(this,w,r.index,`f`);continue}if(g(this,w,`f`)!=null&&(r.index!==g(this,w,`f`)+1||r.carriage)){n.push(Tt(g(this,C,`f`).subarray(0,g(this,w,`f`)-1))),h(this,C,g(this,C,`f`).subarray(g(this,w,`f`)),`f`),h(this,w,null,`f`);continue}let e=g(this,w,`f`)===null?r.preceding:r.preceding-1,t=Tt(g(this,C,`f`).subarray(0,e));n.push(t),h(this,C,g(this,C,`f`).subarray(r.index),`f`),h(this,w,null,`f`)}return n}flush(){return g(this,C,`f`).length?this.decode(`
2
+ `):[]}},C=new WeakMap,w=new WeakMap,jt.NEWLINE_CHARS=new Set([`
3
+ `,`\r`]),jt.NEWLINE_REGEXP=/\r\n|[\n\r]/g}));function Nt(){}function Pt(e,t,n){return!t||Ft[e]>Ft[n]?Nt:t[e].bind(t)}function T(e){let t=e.logger,n=e.logLevel??`off`;if(!t)return Lt;let r=Rt.get(t);if(r&&r[0]===n)return r[1];let i={error:Pt(`error`,t,n),warn:Pt(`warn`,t,n),info:Pt(`info`,t,n),debug:Pt(`debug`,t,n)};return Rt.set(t,[n,i]),i}var Ft,It,Lt,Rt,E,zt=e((()=>{et(),Ft={off:0,error:200,warn:300,info:400,debug:500},It=(e,t,n)=>{if(e){if(qe(Ft,e))return e;T(n).warn(`${t} was set to ${JSON.stringify(e)}, expected one of ${JSON.stringify(Object.keys(Ft))}`)}},Lt={error:Nt,warn:Nt,info:Nt,debug:Nt},Rt=new WeakMap,E=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*Bt(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 Gt,r=new jt,i=gt(e.body);for await(let e of Vt(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*Vt(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`?wt(n):n,r=new Uint8Array(t.length+e.length);r.set(t),r.set(e,t.length),t=r;let i;for(;(i=At(t))!==-1;)yield t.slice(0,i),t=t.slice(i)}t.length>0&&(yield t)}function Ht(e,t){let n=e.indexOf(t);return n===-1?[e,``,``]:[e.substring(0,n),t,e.substring(n+t.length)]}var Ut,Wt,Gt,Kt=e((()=>{_(),x(),vt(),Mt(),Pe(),et(),Ot(),zt(),Wt=class e{constructor(e,t,n){this.iterator=e,Ut.set(this,void 0),this.controller=t,h(this,Ut,n,`f`)}static fromSSEResponse(t,n,r){let i=!1,a=r?T(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 Bt(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=$e(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 jt,n=gt(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)}[(Ut=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,Ut,`f`)),new e(()=>i(n),this.controller,g(this,Ut,`f`))]}toReadableStream(){let e=this,t;return mt({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=wt(JSON.stringify(n)+`
4
+ `);e.enqueue(i)}catch(t){e.error(t)}},async cancel(){await t.return?.()}})}},Gt=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]=Ht(e,`:`);return r.startsWith(` `)&&(r=r.substring(1)),t===`event`?this.event=r:t===`data`&&this.data.push(r),null}}}));async function qt(e,t){let{response:n,requestLogID:r,retryOfRequestLogID:i,startTime:a}=t,o=await(async()=>{if(t.options.stream)return T(e).debug(`response`,n.status,n.url,n.headers,n.body),t.options.__streamClass?t.options.__streamClass.fromSSEResponse(n,t.controller):Wt.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:Jt(await n.json(),n):await n.text()})();return T(e).debug(`[${r}] response parsed`,E({retryOfRequestLogID:i,url:n.url,status:n.status,body:o,durationMs:Date.now()-a})),o}function Jt(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 Yt=e((()=>{Kt(),zt()})),Xt,Zt,Qt=e((()=>{_(),Yt(),Zt=class e extends Promise{constructor(e,t,n=qt){super(e=>{e(null)}),this.responsePromise=t,this.parseResponse=n,Xt.set(this,void 0),h(this,Xt,e,`f`)}_thenUnwrap(t){return new e(g(this,Xt,`f`),this.responsePromise,async(e,n)=>Jt(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,Xt,`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)}},Xt=new WeakMap})),$t,en,tn,nn,rn,D=e((()=>{_(),x(),Yt(),Qt(),et(),en=class{constructor(e,t,n,r){$t.set(this,void 0),h(this,$t,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,$t,`f`).requestAPIList(this.constructor,e)}async*iterPages(){let e=this;for(yield e;e.hasNextPage();)e=await e.getNextPage(),yield e}async*[($t=new WeakMap,Symbol.asyncIterator)](){for await(let e of this.iterPages())for(let t of e.getPaginatedItems())yield t}},tn=class extends Zt{constructor(e,t,n){super(e,t,async(e,t)=>new n(e,t.response,await qt(e,t),t.options))}async*[Symbol.asyncIterator](){let e=await this;for await(let t of e)yield t}},nn=class extends en{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:{...Ge(this.options.query),before_id:e}}:null}let e=this.last_id;return e?{...this.options,query:{...Ge(this.options.query),after_id:e}}:null}},rn=class extends en{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:{...Ge(this.options.query),page:e}}:null}}}));function O(e,t,n){return sn(),new File(e,t??`unknown_file`,n)}function an(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 on(e){let t=typeof e==`function`?e:e.fetch,n=un.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 un.set(t,r),r}var sn,cn,ln,un,dn,fn,pn,mn=e((()=>{vt(),sn=()=>{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`.":``))}},cn=e=>typeof e==`object`&&!!e&&typeof e[Symbol.asyncIterator]==`function`,ln=async(e,t,n=!0)=>({...e,body:await dn(e.body,t,n)}),un=new WeakMap,dn=async(e,t,n=!0)=>{if(!await on(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])=>pn(r,e,t,n))),r},fn=e=>e instanceof Blob&&`name`in e,pn=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,O([await n.blob()],an(n,r),i))}else if(cn(n))e.append(t,O([await new Response(ht(n)).blob()],an(n,r)));else if(fn(n))e.append(t,O([n],an(n,r),{type:n.type}));else if(Array.isArray(n))await Promise.all(n.map(n=>pn(e,t+`[]`,n,r)));else if(typeof n==`object`)await Promise.all(Object.entries(n).map(([n,i])=>pn(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 hn(e,t,n){if(sn(),e=await e,t||(t=an(e,!0)),yn(e))return e instanceof File&&t==null&&n==null?e:O([await e.arrayBuffer()],t??e.name,{type:e.type,lastModified:e.lastModified,...n});if(bn(e)){let r=await e.blob();return t||(t=new URL(e.url).pathname.split(/[\\/]/).pop()),O(await gn(r),t,n)}let r=await gn(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 O(r,t,n)}async function gn(e){let t=[];if(typeof e==`string`||ArrayBuffer.isView(e)||e instanceof ArrayBuffer)t.push(e);else if(vn(e))t.push(e instanceof Blob?e:await e.arrayBuffer());else if(cn(e))for await(let n of e)t.push(...await gn(n));else{let t=e?.constructor?.name;throw Error(`Unexpected data type: ${typeof e}${t?`; constructor: ${t}`:``}${_n(e)}`)}return t}function _n(e){return typeof e!=`object`||!e?``:`; props: [${Object.getOwnPropertyNames(e).map(e=>`"${e}"`).join(`, `)}]`}var vn,yn,bn,xn=e((()=>{mn(),vn=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`,yn=e=>typeof e==`object`&&!!e&&typeof e.name==`string`&&typeof e.lastModified==`number`&&vn(e),bn=e=>typeof e==`object`&&!!e&&typeof e.url==`string`&&typeof e.blob==`function`})),Sn=e((()=>{xn()})),Cn=e((()=>{})),k,A=e((()=>{k=class{constructor(e){this._client=e}}}));function*wn(e){if(!e)return;if(Tn 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():Ze(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=Ze(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 Tn,j,M=e((()=>{et(),Tn=Symbol.for(`brand.privateNullableHeaders`),j=e=>{let t=new Headers,n=new Set;for(let r of e){let e=new Set;for(let[i,a]of wn(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{[Tn]:!0,values:t,nulls:n}}}));function En(e){return typeof e==`object`&&!!e&&An in e}function Dn(e,t){let n=new Set;if(e)for(let t of e)En(t)&&n.add(t[An]);if(t){for(let e of t)if(En(e)&&n.add(e[An]),Array.isArray(e.content))for(let t of e.content)En(t)&&n.add(t[An])}return Array.from(n)}function On(e,t){let n=Dn(e,t);return n.length===0?{}:{"x-stainless-helper":n.join(`, `)}}function kn(e){return En(e)?{"x-stainless-helper":e[An]}:{}}var An,jn=e((()=>{An=Symbol(`anthropic.sdk.stainlessHelper`)}));function Mn(e){return e.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g,encodeURIComponent)}var Nn,Pn,N,P=e((()=>{x(),Nn=Object.freeze(Object.create(null)),Pn=(e=Mn)=>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??Nn)??Nn)?.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},N=Pn(Mn)})),Fn,In=e((()=>{A(),D(),M(),jn(),mn(),P(),Fn=class extends k{list(e={},t){let{betas:n,...r}=e??{};return this._client.getAPIList(`/v1/files`,nn,{query:r,...t,headers:j([{"anthropic-beta":[...n??[],`files-api-2025-04-14`].toString()},t?.headers])})}delete(e,t={},n){let{betas:r}=t??{};return this._client.delete(N`/v1/files/${e}`,{...n,headers:j([{"anthropic-beta":[...r??[],`files-api-2025-04-14`].toString()},n?.headers])})}download(e,t={},n){let{betas:r}=t??{};return this._client.get(N`/v1/files/${e}/content`,{...n,headers:j([{"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(N`/v1/files/${e}`,{...n,headers:j([{"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`,ln({body:r,...t,headers:j([{"anthropic-beta":[...n??[],`files-api-2025-04-14`].toString()},kn(r.file),t?.headers])},this._client))}}})),Ln,Rn=e((()=>{A(),D(),M(),P(),Ln=class extends k{retrieve(e,t={},n){let{betas:r}=t??{};return this._client.get(N`/v1/models/${e}?beta=true`,{...n,headers:j([{...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`,nn,{query:r,...t,headers:j([{...n?.toString()==null?void 0:{"anthropic-beta":n?.toString()}},t?.headers])})}}})),F=e((()=>{x()})),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((()=>{x()})),Kn,I,qn,Jn,Yn,Xn=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},I=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),I(e);case`number`:let n=t.value[t.value.length-1];if(n===`.`||n===`-`)return e=e.slice(0,e.length-1),I(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),I(e);break;case`delimiter`:return e=e.slice(0,e.length-1),I(e)}return e},qn=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},Jn=e=>{let t=``;return e.map(e=>{switch(e.type){case`string`:t+=`"`+e.value+`"`;break;default:t+=e.value;break}}),t},Yn=e=>JSON.parse(Jn(qn(I(Kn(e)))))})),Zn=e((()=>{Kt()}));function Qn(e){return e.type===`tool_use`||e.type===`server_tool_use`||e.type===`mcp_tool_use`}var L,R,z,$n,er,tr,nr,rr,ir,B,ar,or,sr,V,cr,lr,ur,dr,fr,pr,mr,hr,gr,_r,vr,yr,br=e((()=>{_(),Xn(),F(),Pe(),Zn(),Gn(),vr=`__json_buf`,yr=class e{constructor(e,t){L.add(this),this.messages=[],this.receivedMessages=[],R.set(this,void 0),z.set(this,null),this.controller=new AbortController,$n.set(this,void 0),er.set(this,()=>{}),tr.set(this,()=>{}),nr.set(this,void 0),rr.set(this,()=>{}),ir.set(this,()=>{}),B.set(this,{}),ar.set(this,!1),or.set(this,!1),sr.set(this,!1),V.set(this,!1),cr.set(this,void 0),lr.set(this,void 0),ur.set(this,void 0),pr.set(this,e=>{if(h(this,or,!0,`f`),Me(e)&&(e=new b),e instanceof b)return h(this,sr,!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,$n,new Promise((e,t)=>{h(this,er,e,`f`),h(this,tr,t,`f`)}),`f`),h(this,nr,new Promise((e,t)=>{h(this,rr,e,`f`),h(this,ir,t,`f`)}),`f`),g(this,$n,`f`).catch(()=>{}),g(this,nr,`f`).catch(()=>{}),h(this,z,e,`f`),h(this,ur,t?.logger??console,`f`)}get response(){return g(this,cr,`f`)}get request_id(){return g(this,lr,`f`)}async withResponse(){h(this,V,!0,`f`);let e=await g(this,$n,`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,z,{...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,pr,`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,L,`m`,mr).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,L,`m`,hr).call(this,e);if(i.controller.signal?.aborted)throw new b;g(this,L,`m`,gr).call(this)}finally{r&&i&&r.removeEventListener(`abort`,i)}}_connected(e){this.ended||(h(this,cr,e,`f`),h(this,lr,e?.headers.get(`request-id`),`f`),g(this,er,`f`).call(this,e),this._emit(`connect`))}get ended(){return g(this,ar,`f`)}get errored(){return g(this,or,`f`)}get aborted(){return g(this,sr,`f`)}abort(){this.controller.abort()}on(e,t){return(g(this,B,`f`)[e]||(g(this,B,`f`)[e]=[])).push({listener:t}),this}off(e,t){let n=g(this,B,`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,B,`f`)[e]||(g(this,B,`f`)[e]=[])).push({listener:t,once:!0}),this}emitted(e){return new Promise((t,n)=>{h(this,V,!0,`f`),e!==`error`&&this.once(`error`,n),this.once(e,t)})}async done(){h(this,V,!0,`f`),await g(this,nr,`f`)}get currentMessage(){return g(this,R,`f`)}async finalMessage(){return await this.done(),g(this,L,`m`,dr).call(this)}async finalText(){return await this.done(),g(this,L,`m`,fr).call(this)}_emit(e,...t){if(g(this,ar,`f`))return;e===`end`&&(h(this,ar,!0,`f`),g(this,rr,`f`).call(this));let n=g(this,B,`f`)[e];if(n&&(g(this,B,`f`)[e]=n.filter(e=>!e.once),n.forEach(({listener:e})=>e(...t))),e===`abort`){let e=t[0];!g(this,V,`f`)&&!n?.length&&Promise.reject(e),g(this,tr,`f`).call(this,e),g(this,ir,`f`).call(this,e),this._emit(`end`);return}if(e===`error`){let e=t[0];!g(this,V,`f`)&&!n?.length&&Promise.reject(e),g(this,tr,`f`).call(this,e),g(this,ir,`f`).call(this,e),this._emit(`end`)}}_emitFinal(){this.receivedMessages.at(-1)&&this._emit(`finalMessage`,g(this,L,`m`,dr).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,L,`m`,mr).call(this),this._connected(null);let t=Wt.fromReadableStream(e,this.controller);for await(let e of t)g(this,L,`m`,hr).call(this,e);if(t.controller.signal?.aborted)throw new b;g(this,L,`m`,gr).call(this)}finally{n&&r&&n.removeEventListener(`abort`,r)}}[(R=new WeakMap,z=new WeakMap,$n=new WeakMap,er=new WeakMap,tr=new WeakMap,nr=new WeakMap,rr=new WeakMap,ir=new WeakMap,B=new WeakMap,ar=new WeakMap,or=new WeakMap,sr=new WeakMap,V=new WeakMap,cr=new WeakMap,lr=new WeakMap,ur=new WeakMap,pr=new WeakMap,L=new WeakSet,dr=function(){if(this.receivedMessages.length===0)throw new v(`stream ended without producing a Message with role=assistant`);return this.receivedMessages.at(-1)},fr=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(` `)},mr=function(){this.ended||h(this,R,void 0,`f`)},hr=function(e){if(this.ended)return;let t=g(this,L,`m`,_r).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`:Qn(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,z,`f`),{logger:g(this,ur,`f`)}),!0);break;case`content_block_stop`:this._emit(`contentBlock`,t.content.at(-1));break;case`message_start`:h(this,R,t,`f`);break;case`content_block_start`:case`message_delta`:break}},gr=function(){if(this.ended)throw new v(`stream has ended, this shouldn't happen`);let e=g(this,R,`f`);if(!e)throw new v(`request ended without sending any chunks`);return h(this,R,void 0,`f`),Hn(e,g(this,z,`f`),{logger:g(this,ur,`f`)})},_r=function(e){let t=g(this,R,`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&&Qn(n)){let r=n[vr]||``;r+=e.delta.partial_json;let i={...n};if(Object.defineProperty(i,vr,{value:r,enumerable:!1,writable:!0}),r)try{i.input=Yn(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,pr,`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 Wt(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}}})),xr,Sr=e((()=>{xr=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}}})),Cr,wr=e((()=>{Cr=`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 Tr(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}async function Er(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 xr?e.content:`Error: ${e instanceof Error?e.message:String(e)}`,is_error:!0}}}))}}var Dr,Or,H,U,kr,W,G,K,Ar,jr,Mr,Nr,Pr=e((()=>{_(),Sr(),x(),M(),wr(),jn(),Nr=class{constructor(e,t,n){Dr.add(this),this.client=e,Or.set(this,!1),H.set(this,!1),U.set(this,void 0),kr.set(this,void 0),W.set(this,void 0),G.set(this,void 0),K.set(this,void 0),Ar.set(this,0),h(this,U,{params:{...t,messages:structuredClone(t.messages)}},`f`);let r=[`BetaToolRunner`,...Dn(t.tools,t.messages)].join(`, `);h(this,kr,{...n,headers:j([{"x-stainless-helper":r},n?.headers])},`f`),h(this,K,Tr(),`f`)}async*[(Or=new WeakMap,H=new WeakMap,U=new WeakMap,kr=new WeakMap,W=new WeakMap,G=new WeakMap,K=new WeakMap,Ar=new WeakMap,Dr=new WeakSet,jr=async function(){let e=g(this,U,`f`).params.compactionControl;if(!e||!e.enabled)return!1;let t=0;if(g(this,W,`f`)!==void 0)try{let e=await g(this,W,`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,U,`f`).params.model,i=e.summaryPrompt??Cr,a=g(this,U,`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,U,`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,U,`f`).params.messages=[{role:`user`,content:o.content}],!0},Symbol.asyncIterator)](){var e;if(g(this,Or,`f`))throw new v(`Cannot iterate over a consumed stream`);h(this,Or,!0,`f`),h(this,H,!0,`f`),h(this,G,void 0,`f`);try{for(;;){let t;try{if(g(this,U,`f`).params.max_iterations&&g(this,Ar,`f`)>=g(this,U,`f`).params.max_iterations)break;h(this,H,!1,`f`),h(this,G,void 0,`f`),h(this,Ar,(e=g(this,Ar,`f`),e++,e),`f`),h(this,W,void 0,`f`);let{max_iterations:n,compactionControl:r,...i}=g(this,U,`f`).params;if(i.stream?(t=this.client.beta.messages.stream({...i},g(this,kr,`f`)),h(this,W,t.finalMessage(),`f`),g(this,W,`f`).catch(()=>{}),yield t):(h(this,W,this.client.beta.messages.create({...i,stream:!1},g(this,kr,`f`)),`f`),yield g(this,W,`f`)),!await g(this,Dr,`m`,jr).call(this)){if(!g(this,H,`f`)){let{role:e,content:t}=await g(this,W,`f`);g(this,U,`f`).params.messages.push({role:e,content:t})}let e=await g(this,Dr,`m`,Mr).call(this,g(this,U,`f`).params.messages.at(-1));if(e)g(this,U,`f`).params.messages.push(e);else if(!g(this,H,`f`))break}}finally{t&&t.abort()}}if(!g(this,W,`f`))throw new v(`ToolRunner concluded without a message from the server`);g(this,K,`f`).resolve(await g(this,W,`f`))}catch(e){throw h(this,Or,!1,`f`),g(this,K,`f`).promise.catch(()=>{}),g(this,K,`f`).reject(e),h(this,K,Tr(),`f`),e}}setMessagesParams(e){typeof e==`function`?g(this,U,`f`).params=e(g(this,U,`f`).params):g(this,U,`f`).params=e,h(this,H,!0,`f`),h(this,G,void 0,`f`)}async generateToolResponse(){let e=await g(this,W,`f`)??this.params.messages.at(-1);return e?g(this,Dr,`m`,Mr).call(this,e):null}done(){return g(this,K,`f`).promise}async runUntilDone(){if(!g(this,Or,`f`))for await(let e of this);return this.done()}get params(){return g(this,U,`f`).params}pushMessages(...e){this.setMessagesParams(t=>({...t,messages:[...t.messages,...e]}))}then(e,t){return this.runUntilDone().then(e,t)}},Mr=async function(e){return g(this,G,`f`)===void 0&&h(this,G,Er(g(this,U,`f`).params,e),`f`),g(this,G,`f`)}})),Fr,Ir=e((()=>{x(),vt(),Mt(),Fr=class e{constructor(e,t){this.iterator=e,this.controller=t}async*decoder(){let e=new jt;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(gt(t.body),n)}}})),Lr,Rr=e((()=>{A(),D(),M(),Ir(),F(),P(),Lr=class extends k{create(e,t){let{betas:n,...r}=e;return this._client.post(`/v1/messages/batches?beta=true`,{body:r,...t,headers:j([{"anthropic-beta":[...n??[],`message-batches-2024-09-24`].toString()},t?.headers])})}retrieve(e,t={},n){let{betas:r}=t??{};return this._client.get(N`/v1/messages/batches/${e}?beta=true`,{...n,headers:j([{"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`,nn,{query:r,...t,headers:j([{"anthropic-beta":[...n??[],`message-batches-2024-09-24`].toString()},t?.headers])})}delete(e,t={},n){let{betas:r}=t??{};return this._client.delete(N`/v1/messages/batches/${e}?beta=true`,{...n,headers:j([{"anthropic-beta":[...r??[],`message-batches-2024-09-24`].toString()},n?.headers])})}cancel(e,t={},n){let{betas:r}=t??{};return this._client.post(N`/v1/messages/batches/${e}/cancel?beta=true`,{...n,headers:j([{"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:j([{"anthropic-beta":[...i??[],`message-batches-2024-09-24`].toString(),Accept:`application/binary`},n?.headers]),stream:!0,__binaryResponse:!0})._thenUnwrap((e,t)=>Fr.fromResponse(t.response,t.controller))}}}));function zr(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 Br,Vr,Hr,Ur=e((()=>{F(),A(),Bn(),M(),jn(),Gn(),br(),Pr(),Sr(),Rr(),Br={"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`},Vr=[`claude-opus-4-6`],Hr=class extends k{constructor(){super(...arguments),this.batches=new Lr(this._client)}create(e,t){let n=zr(e),{betas:r,...i}=n;i.model in Br&&console.warn(`The model '${i.model}' is deprecated and will reach end-of-life on ${Br[i.model]}\nPlease migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`),i.model in Vr&&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=On(i.tools,i.messages);return this._client.post(`/v1/messages?beta=true`,{body:i,timeout:a??6e5,...t,headers:j([{...r?.toString()==null?void 0:{"anthropic-beta":r?.toString()}},o,t?.headers]),stream:n.stream??!1})}parse(e,t){return t={...t,headers:j([{"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 yr.createMessage(this,e,t)}countTokens(e,t){let{betas:n,...r}=zr(e);return this._client.post(`/v1/messages/count_tokens?beta=true`,{body:r,...t,headers:j([{"anthropic-beta":[...n??[],`token-counting-2024-11-01`].toString()},t?.headers])})}toolRunner(e,t){return new Nr(this._client,e,t)}},Hr.Batches=Lr,Hr.BetaToolRunner=Nr,Hr.ToolError=xr})),Wr,Gr=e((()=>{A(),D(),M(),mn(),P(),Wr=class extends k{create(e,t={},n){let{betas:r,...i}=t??{};return this._client.post(N`/v1/skills/${e}/versions?beta=true`,ln({body:i,...n,headers:j([{"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(N`/v1/skills/${r}/versions/${e}?beta=true`,{...n,headers:j([{"anthropic-beta":[...i??[],`skills-2025-10-02`].toString()},n?.headers])})}list(e,t={},n){let{betas:r,...i}=t??{};return this._client.getAPIList(N`/v1/skills/${e}/versions?beta=true`,rn,{query:i,...n,headers:j([{"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(N`/v1/skills/${r}/versions/${e}?beta=true`,{...n,headers:j([{"anthropic-beta":[...i??[],`skills-2025-10-02`].toString()},n?.headers])})}}})),Kr,qr=e((()=>{A(),Gr(),D(),M(),mn(),P(),Kr=class extends k{constructor(){super(...arguments),this.versions=new Wr(this._client)}create(e={},t){let{betas:n,...r}=e??{};return this._client.post(`/v1/skills?beta=true`,ln({body:r,...t,headers:j([{"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(N`/v1/skills/${e}?beta=true`,{...n,headers:j([{"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`,rn,{query:r,...t,headers:j([{"anthropic-beta":[...n??[],`skills-2025-10-02`].toString()},t?.headers])})}delete(e,t={},n){let{betas:r}=t??{};return this._client.delete(N`/v1/skills/${e}?beta=true`,{...n,headers:j([{"anthropic-beta":[...r??[],`skills-2025-10-02`].toString()},n?.headers])})}},Kr.Versions=Wr})),q,Jr=e((()=>{A(),In(),Rn(),Ur(),qr(),q=class extends k{constructor(){super(...arguments),this.models=new Ln(this._client),this.messages=new Hr(this._client),this.files=new Fn(this._client),this.skills=new Kr(this._client)}},q.Models=Ln,q.Messages=Hr,q.Files=Fn,q.Skills=Kr})),Yr,Xr=e((()=>{A(),M(),Yr=class extends k{create(e,t){let{betas:n,...r}=e;return this._client.post(`/v1/complete`,{body:r,timeout:this._client._options.timeout??6e5,...t,headers:j([{...n?.toString()==null?void 0:{"anthropic-beta":n?.toString()}},t?.headers]),stream:e.stream??!1})}}}));function Zr(e){return e?.output_config?.format}function Qr(e,t,n){let r=Zr(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}:$r(e,t,n)}function $r(e,t,n){let r=null,i=e.content.map(e=>{if(e.type===`text`){let n=ei(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 ei(e,t){let n=Zr(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 ti=e((()=>{x()}));function ni(e){return e.type===`tool_use`||e.type===`server_tool_use`}var J,Y,ri,ii,ai,oi,si,ci,li,X,ui,di,fi,Z,pi,mi,hi,gi,_i,vi,yi,bi,xi,Si,Ci,wi,Ti=e((()=>{_(),Pe(),F(),Zn(),Xn(),ti(),Ci=`__json_buf`,wi=class e{constructor(e,t){J.add(this),this.messages=[],this.receivedMessages=[],Y.set(this,void 0),ri.set(this,null),this.controller=new AbortController,ii.set(this,void 0),ai.set(this,()=>{}),oi.set(this,()=>{}),si.set(this,void 0),ci.set(this,()=>{}),li.set(this,()=>{}),X.set(this,{}),ui.set(this,!1),di.set(this,!1),fi.set(this,!1),Z.set(this,!1),pi.set(this,void 0),mi.set(this,void 0),hi.set(this,void 0),vi.set(this,e=>{if(h(this,di,!0,`f`),Me(e)&&(e=new b),e instanceof b)return h(this,fi,!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,ii,new Promise((e,t)=>{h(this,ai,e,`f`),h(this,oi,t,`f`)}),`f`),h(this,si,new Promise((e,t)=>{h(this,ci,e,`f`),h(this,li,t,`f`)}),`f`),g(this,ii,`f`).catch(()=>{}),g(this,si,`f`).catch(()=>{}),h(this,ri,e,`f`),h(this,hi,t?.logger??console,`f`)}get response(){return g(this,pi,`f`)}get request_id(){return g(this,mi,`f`)}async withResponse(){h(this,Z,!0,`f`);let e=await g(this,ii,`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,ri,{...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,vi,`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,J,`m`,yi).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,J,`m`,bi).call(this,e);if(i.controller.signal?.aborted)throw new b;g(this,J,`m`,xi).call(this)}finally{r&&i&&r.removeEventListener(`abort`,i)}}_connected(e){this.ended||(h(this,pi,e,`f`),h(this,mi,e?.headers.get(`request-id`),`f`),g(this,ai,`f`).call(this,e),this._emit(`connect`))}get ended(){return g(this,ui,`f`)}get errored(){return g(this,di,`f`)}get aborted(){return g(this,fi,`f`)}abort(){this.controller.abort()}on(e,t){return(g(this,X,`f`)[e]||(g(this,X,`f`)[e]=[])).push({listener:t}),this}off(e,t){let n=g(this,X,`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,X,`f`)[e]||(g(this,X,`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,si,`f`)}get currentMessage(){return g(this,Y,`f`)}async finalMessage(){return await this.done(),g(this,J,`m`,gi).call(this)}async finalText(){return await this.done(),g(this,J,`m`,_i).call(this)}_emit(e,...t){if(g(this,ui,`f`))return;e===`end`&&(h(this,ui,!0,`f`),g(this,ci,`f`).call(this));let n=g(this,X,`f`)[e];if(n&&(g(this,X,`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,oi,`f`).call(this,e),g(this,li,`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,oi,`f`).call(this,e),g(this,li,`f`).call(this,e),this._emit(`end`)}}_emitFinal(){this.receivedMessages.at(-1)&&this._emit(`finalMessage`,g(this,J,`m`,gi).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,J,`m`,yi).call(this),this._connected(null);let t=Wt.fromReadableStream(e,this.controller);for await(let e of t)g(this,J,`m`,bi).call(this,e);if(t.controller.signal?.aborted)throw new b;g(this,J,`m`,xi).call(this)}finally{n&&r&&n.removeEventListener(`abort`,r)}}[(Y=new WeakMap,ri=new WeakMap,ii=new WeakMap,ai=new WeakMap,oi=new WeakMap,si=new WeakMap,ci=new WeakMap,li=new WeakMap,X=new WeakMap,ui=new WeakMap,di=new WeakMap,fi=new WeakMap,Z=new WeakMap,pi=new WeakMap,mi=new WeakMap,hi=new WeakMap,vi=new WeakMap,J=new WeakSet,gi=function(){if(this.receivedMessages.length===0)throw new v(`stream ended without producing a Message with role=assistant`);return this.receivedMessages.at(-1)},_i=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(` `)},yi=function(){this.ended||h(this,Y,void 0,`f`)},bi=function(e){if(this.ended)return;let t=g(this,J,`m`,Si).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`:ni(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(Qr(t,g(this,ri,`f`),{logger:g(this,hi,`f`)}),!0);break;case`content_block_stop`:this._emit(`contentBlock`,t.content.at(-1));break;case`message_start`:h(this,Y,t,`f`);break;case`content_block_start`:case`message_delta`:break}},xi=function(){if(this.ended)throw new v(`stream has ended, this shouldn't happen`);let e=g(this,Y,`f`);if(!e)throw new v(`request ended without sending any chunks`);return h(this,Y,void 0,`f`),Qr(e,g(this,ri,`f`),{logger:g(this,hi,`f`)})},Si=function(e){let t=g(this,Y,`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&&ni(n)){let r=n[Ci]||``;r+=e.delta.partial_json;let i={...n};Object.defineProperty(i,Ci,{value:r,enumerable:!1,writable:!0}),r&&(i.input=Yn(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 Wt(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}}})),Ei,Di=e((()=>{A(),D(),M(),Ir(),F(),P(),Ei=class extends k{create(e,t){return this._client.post(`/v1/messages/batches`,{body:e,...t})}retrieve(e,t){return this._client.get(N`/v1/messages/batches/${e}`,t)}list(e={},t){return this._client.getAPIList(`/v1/messages/batches`,nn,{query:e,...t})}delete(e,t){return this._client.delete(N`/v1/messages/batches/${e}`,t)}cancel(e,t){return this._client.post(N`/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:j([{Accept:`application/binary`},t?.headers]),stream:!0,__binaryResponse:!0})._thenUnwrap((e,t)=>Fr.fromResponse(t.response,t.controller))}}})),Oi,ki,Ai,ji=e((()=>{A(),M(),jn(),Ti(),ti(),Di(),Bn(),Oi=class extends k{constructor(){super(...arguments),this.batches=new Ei(this._client)}create(e,t){e.model in ki&&console.warn(`The model '${e.model}' is deprecated and will reach end-of-life on ${ki[e.model]}\nPlease migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`),e.model in Ai&&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=On(e.tools,e.messages);return this._client.post(`/v1/messages`,{body:e,timeout:n??6e5,...t,headers:j([r,t?.headers]),stream:e.stream??!1})}parse(e,t){return this.create(e,t).then(t=>$r(t,e,{logger:this._client.logger??console}))}stream(e,t){return wi.createMessage(this,e,t,{logger:this._client.logger??console})}countTokens(e,t){return this._client.post(`/v1/messages/count_tokens`,{body:e,...t})}},ki={"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`},Ai=[`claude-opus-4-6`],Oi.Batches=Ei})),Mi,Ni=e((()=>{A(),D(),M(),P(),Mi=class extends k{retrieve(e,t={},n){let{betas:r}=t??{};return this._client.get(N`/v1/models/${e}`,{...n,headers:j([{...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`,nn,{query:r,...t,headers:j([{...n?.toString()==null?void 0:{"anthropic-beta":n?.toString()}},t?.headers])})}}})),Pi=e((()=>{Cn(),Jr(),Xr(),ji(),Ni()})),Fi,Ii=e((()=>{Fi=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()}})),Li,Ri,zi,Bi,Vi,Hi,Q,Ui,Wi=e((()=>{_(),je(),et(),nt(),Pe(),ft(),vt(),bt(),St(),rt(),x(),D(),Sn(),Pi(),Qt(),Xr(),Ni(),Jr(),ji(),M(),Ii(),zt(),Vi=`\\n\\nHuman:`,Hi=`\\n\\nAssistant:`,Q=class{constructor({baseURL:e=Fi(`ANTHROPIC_BASE_URL`),apiKey:t=Fi(`ANTHROPIC_API_KEY`)??null,authToken:n=Fi(`ANTHROPIC_AUTH_TOKEN`)??null,...r}={}){Li.add(this),zi.set(this,void 0);let i={apiKey:t,authToken:n,...r,baseURL:e||`https://api.anthropic.com`};if(!i.dangerouslyAllowBrowser&&ot())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??Ri.DEFAULT_TIMEOUT,this.logger=i.logger??console;let a=`warn`;this.logLevel=a,this.logLevel=It(i.logLevel,`ClientOptions.logLevel`,this)??It(Fi(`ANTHROPIC_LOG`),`process.env['ANTHROPIC_LOG']`,this)??a,this.fetchOptions=i.fetchOptions,this.maxRetries=i.maxRetries??2,this.fetch=i.fetch??pt(),h(this,zi,yt,`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 j([await this.apiKeyAuth(e),await this.bearerAuth(e)])}async apiKeyAuth(e){if(this.apiKey!=null)return j([{"X-Api-Key":this.apiKey}])}async bearerAuth(e){if(this.authToken!=null)return j([{Authorization:`Bearer ${this.authToken}`}])}stringifyQuery(e){return xt(e)}getUserAgent(){return`${this.constructor.name}/JS ${S}`}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,Li,`m`,Bi).call(this)&&n||this.baseURL,i=Ye(e)?new URL(e):new URL(r+(r.endsWith(`/`)&&e.startsWith(`/`)?e.slice(1):e)),a=this.defaultQuery(),o=Object.fromEntries(i.searchParams);return(!Ke(a)||!Ke(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 Zt(this,this.makeRequest(e,t,void 0))}async makeRequest(e,t,n){let r=await e,i=r.maxRetries??this.maxRetries;t??(t=i),await this.prepareOptions(r);let{req:a,url:o,timeout:s}=await this.buildRequest(r,{retryCount:i-t});await this.prepareRequest(a,{url:o,options:r});let c=`log_`+(Math.random()*(1<<24)|0).toString(16).padStart(6,`0`),l=n===void 0?``:`, retryOf: ${n}`,u=Date.now();if(T(this).debug(`[${c}] sending request`,E({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 T(this).info(`[${c}] connection ${i?`timed out`:`failed`} - ${e}`),T(this).debug(`[${c}] connection ${i?`timed out`:`failed`} (${e})`,E({retryOfRequestLogID:n,url:o,durationMs:f-u,message:d.message})),this.retryRequest(r,t,n??c);throw T(this).info(`[${c}] connection ${i?`timed out`:`failed`} - error; no more retries left`),T(this).debug(`[${c}] connection ${i?`timed out`:`failed`} (error; no more retries left)`,E({retryOfRequestLogID:n,url:o,durationMs:f-u,message:d.message})),i?new Ie:new Fe({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 _t(d.body),T(this).info(`${p} - ${e}`),T(this).debug(`[${c}] response error (${e})`,E({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`;T(this).info(`${p} - ${i}`);let a=await d.text().catch(e=>Ne(e).message),o=$e(a),s=o?void 0:a;throw T(this).debug(`[${c}] response error (${i})`,E({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 T(this).info(p),T(this).debug(`[${c}] response start`,E({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 tn(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 tt(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&&Qe(`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=j([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))}:{},...dt(),...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=j([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:ht(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,zi,`f`).call(this,{body:e,headers:n})}},Ri=Q,zi=new WeakMap,Li=new WeakSet,Bi=function(){return this.baseURL!==`https://api.anthropic.com`},Q.Anthropic=Ri,Q.HUMAN_PROMPT=Vi,Q.AI_PROMPT=Hi,Q.DEFAULT_TIMEOUT=6e5,Q.AnthropicError=v,Q.APIError=y,Q.APIConnectionError=Fe,Q.APIConnectionTimeoutError=Ie,Q.APIUserAbortError=b,Q.NotFoundError=Be,Q.ConflictError=Ve,Q.RateLimitError=Ue,Q.BadRequestError=Le,Q.AuthenticationError=Re,Q.InternalServerError=We,Q.PermissionDeniedError=ze,Q.UnprocessableEntityError=He,Q.toFile=hn,Ui=class extends Q{constructor(){super(...arguments),this.completions=new Yr(this),this.messages=new Oi(this),this.models=new Mi(this),this.beta=new q(this)}},Ui.Completions=Yr,Ui.Messages=Oi,Ui.Models=Mi,Ui.Beta=q})),Gi=e((()=>{Wi(),Sn(),Qt(),D(),x()}));function Ki(e){return e instanceof ra||e instanceof b||e instanceof Error&&e.name===`AbortError`}function qi(e,t){return e instanceof Error&&e.message===t}function Ji(e){return e instanceof Error?e:Error(String(e))}function Yi(e){return e instanceof Error?e.message:String(e)}function Xi(e){if(e&&typeof e==`object`&&`code`in e&&typeof e.code==`string`)return e.code}function Zi(e){return Xi(e)===`ENOENT`}function Qi(e){if(e&&typeof e==`object`&&`path`in e&&typeof e.path==`string`)return e.path}function $i(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 ea(e){let t=Xi(e);return t===`ENOENT`||t===`EACCES`||t===`EPERM`||t===`ENOTDIR`||t===`ELOOP`}var ta,na,ra,ia,aa,oa,sa=e((()=>{Gi(),s(),ta=class extends Error{constructor(e){super(e),this.name=this.constructor.name}},na=class extends Error{},ra=class extends Error{constructor(e){super(e),this.name=`AbortError`}},ia=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}},aa=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`}},oa=class extends Error{constructor(e,t){super(e),c(this,`telemetryMessage`,void 0),this.name=`TelemetrySafeError`,this.telemetryMessage=t??e}}}));function ca(){return fa}function la(e,t,n){return $`JSON.stringify(${e})`,JSON.stringify(e,t,n)}function ua(e,t){return $`structuredClone(${e})`,structuredClone(e,t)}function da(e,t,n){if($`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 fa,$,pa,ma=e((()=>{l(),Ja(),(()=>{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})(),fa={[Symbol.dispose](){}},$=ca,pa=(e,t)=>($`JSON.parse(${e})`,t===void 0?JSON.parse(e):JSON.parse(e,t))}));function ha(){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 ga=e((()=>{}));function _a(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 va(e,t,n){let{resolvedPath:r}=_a(e,t);return n.has(r)?!0:(n.add(r),!1)}function ya(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 ba(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=xa();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=ya(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}=_a(r,t);return a&&i!==t&&n.add(i),Array.from(n)}function xa(){return Ea}async function Sa(e,t,n){try{var r=ha();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 Ca(e,t){try{var n=ha();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*wa(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 Ta,Ea,Da=e((()=>{sa(),ma(),ga(),Ta={cwd(){return process.cwd()},existsSync(e){return $`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(Xi(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 $`fs.statSync(${e})`,m.statSync(e)},lstatSync(e){return $`fs.lstatSync(${e})`,m.lstatSync(e)},readFileSync(e,t){return $`fs.readFileSync(${e})`,m.readFileSync(e,{encoding:t.encoding})},readFileBytesSync(e){return $`fs.readFileBytesSync(${e})`,m.readFileSync(e)},readSync(e,t){$`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($`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(Xi(e)!==`EEXIST`)throw e}m.appendFileSync(e,t)},copyFileSync(e,t){$`fs.copyFileSync(${e} → ${t})`,m.copyFileSync(e,t)},unlinkSync(e){$`fs.unlinkSync(${e})`,m.unlinkSync(e)},renameSync(e,t){$`fs.renameSync(${e} → ${t})`,m.renameSync(e,t)},linkSync(e,t){$`fs.linkSync(${e} → ${t})`,m.linkSync(e,t)},symlinkSync(e,t,n){$`fs.symlinkSync(${e} → ${t})`,m.symlinkSync(e,t,n)},readlinkSync(e){return $`fs.readlinkSync(${e})`,m.readlinkSync(e)},realpathSync(e){return $`fs.realpathSync(${e})`,m.realpathSync(e).normalize(`NFC`)},mkdirSync(e,t){$`fs.mkdirSync(${e})`;let n={recursive:!0};t?.mode!==void 0&&(n.mode=t.mode);try{m.mkdirSync(e,n)}catch(e){if(Xi(e)!==`EEXIST`)throw e}},readdirSync(e){return $`fs.readdirSync(${e})`,m.readdirSync(e,{withFileTypes:!0})},readdirStringSync(e){return $`fs.readdirStringSync(${e})`,m.readdirSync(e)},isDirEmptySync(e){return $`fs.isDirEmptySync(${e})`,this.readdirSync(e).length===0},rmdirSync(e){$`fs.rmdirSync(${e})`,m.rmdirSync(e)},rmSync(e,t){$`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()}}},Ea=Ta})),Oa=t({getDebugLogPath:()=>Ia,getHasFormattedOutput:()=>ja,isDebugMode:()=>Ba,isDebugToStdErr:()=>Ha,logAntError:()=>La,logForDebugging:()=>Fa,setHasFormattedOutput:()=>Aa});function ka(e){return!Ba()||typeof process>`u`||process.versions===void 0||process.versions.node===void 0?!1:De(e,Va())}function Aa(e){Wa=e}function ja(){return Wa}async function Ma(e,t,n,r){e&&await le(t,{recursive:!0}).catch(()=>{}),await ce(n,r),qa()}function Na(){}function Pa(){if(!Ga){let e=null;Ga=ye({writeFn:t=>{let n=Ia(),r=te(n),i=e!==r;if(e=r,Ba()){if(i)try{xa().mkdirSync(r)}catch{}try{xa().appendFileSync(n,t)}catch{try{xa().mkdirSync(r),xa().appendFileSync(n,t)}catch{}}qa();return}Ka=Ka.then(Ma.bind(null,i,r,n,t)).catch(Na)},flushIntervalMs:1e3,maxBufferSize:100,immediateMode:Ba()}),xe(async()=>{Ga?.dispose(),await Ka})}return Ga}function Fa(e,{level:t}={level:`debug`}){if(Ra[t]<Ra[za()]||!ka(e))return;Wa&&e.includes(`
39
+ `)&&(e=la(e));let n=`${new Date().toISOString()} [${t.toUpperCase()}] ${e.trim()}\n`;if(Ha()){ee(n);return}Pa().write(n)}function Ia(){return Ua()??(process.env.CLAUDE_CODE_DEBUG_LOGS_DIR?re(process.env.CLAUDE_CODE_DEBUG_LOGS_DIR):null)??ne(i(),`debug`,`${u()}.txt`)}function La(e,t){t instanceof Error&&t.stack&&Fa(`[ANT-ONLY] ${e} stack trace:\n${t.stack}`,{level:`error`})}var Ra,za,Ba,Va,Ha,Ua,Wa,Ga,Ka,qa,Ja=e((()=>{r(),l(),be(),we(),ke(),o(),Da(),d(),ma(),Ra={verbose:0,debug:1,info:2,warn:3,error:4},za=n(()=>{let e=process.env.CLAUDE_CODE_DEBUG_LOG_LEVEL?.toLowerCase().trim();return e&&Object.hasOwn(Ra,e)?e:`debug`}),Ba=n(()=>a(process.env.DEBUG)||a(process.env.DEBUG_SDK)||process.argv.includes(`--debug`)||process.argv.includes(`-d`)||Ha()||process.argv.some(e=>e.startsWith(`--debug=`))||Ua()!==null),Va=n(()=>{let e=process.argv.find(e=>e.startsWith(`--debug=`));return e?Oe(e.substring(8)):null}),Ha=n(()=>process.argv.includes(`--debug-to-stderr`)),Ua=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}),Wa=!1,Ga=null,Ka=Promise.resolve(),qa=n(async()=>{try{let e=Ia(),t=ne(te(e),`latest`);await ve(t).catch(()=>{}),await _e(e,t)}catch{}})}));export{we as $,aa as A,$i as B,la as C,ta as D,ra as E,qi as F,F as G,Gi as H,sa as I,y as J,Fe as K,Ki as L,Yi as M,Xi as N,ia as O,Qi as P,x as Q,Zi as R,pa as S,da as T,Ui as U,Ji as V,Wi as W,Re as X,b as Y,Be as Z,Ca as _,Ba as a,ua as b,Fa as c,ba as d,xe as et,Da as f,_a as g,wa as h,Ja as i,oa as j,na as k,Aa as l,Sa as m,Ia as n,ye as nt,Ha as o,va as p,Ie as q,ja as r,be as rt,La as s,Oa as t,Se as tt,xa as u,ha as v,$ as w,ma as x,ga as y,ea as z};
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./cwd-Pa83R95t.js";import{c as r,i}from"./debug-Bglx1aTu.js";import{Lr as a,Nr as o}from"./settings-B2jvL8Dp.js";function s(){f.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(f.has(e))return f.get(e)??null;try{let t=await o();if(r(`Git remote URL: ${t}`),!t)return r(`No git remote URL found`),f.set(e,null),null;let n=u(t);return r(`Parsed repository: ${n?`${n.host}/${n.owner}/${n.name}`:null} from URL: ${t}`),f.set(e,n),n}catch(t){return r(`Error detecting repository: ${t}`),f.set(e,null),null}}function u(e){let t=e.trim(),n=t.match(/^git@([^:]+):([^/]+)\/([^/]+?)(?:\.git)?$/);if(n?.[1]&&n[2]&&n[3])return d(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 d(n)?{host:e===`https`||e===`http`?t:n,owner:r[3],name:r[4]}:null}return null}function d(e){if(!e.includes(`.`))return!1;let t=e.split(`.`).pop();return t?/^[a-zA-Z]+$/.test(t):!1}var f,p=e((()=>{t(),i(),a(),f=new Map}));export{c as n,p as r,s as t};
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./cwd-BvNt_018.js";import{c as r,i}from"./debug-CRnGsZOV.js";import{Ir as a,Nr as o}from"./settings-CodSADx8.js";function s(){f.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(f.has(e))return f.get(e)??null;try{let t=await o();if(r(`Git remote URL: ${t}`),!t)return r(`No git remote URL found`),f.set(e,null),null;let n=u(t);return r(`Parsed repository: ${n?`${n.host}/${n.owner}/${n.name}`:null} from URL: ${t}`),f.set(e,n),n}catch(t){return r(`Error detecting repository: ${t}`),f.set(e,null),null}}function u(e){let t=e.trim(),n=t.match(/^git@([^:]+):([^/]+)\/([^/]+?)(?:\.git)?$/);if(n?.[1]&&n[2]&&n[3])return d(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 d(n)?{host:e===`https`||e===`http`?t:n,owner:r[3],name:r[4]}:null}return null}function d(e){if(!e.includes(`.`))return!1;let t=e.split(`.`).pop();return t?/^[a-zA-Z]+$/.test(t):!1}var f,p=e((()=>{t(),i(),a(),f=new Map}));export{c as n,p as r,s as t};
@@ -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-BpXIEWiE.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-v5r8cBKW.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{b as t,y as n}from"./types-Dx7P7JLQ.js";import{n as r,t as i}from"./cwd-Pa83R95t.js";import{f as a,u as o}from"./debug-Bglx1aTu.js";import{er as s,nr as c}from"./settings-B2jvL8Dp.js";import{o as l,s as u}from"./log-D2TIwHBV.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||i(),prefix:``};let n=s(e,t);return e.endsWith(`/`)||e.endsWith(m)?{directory:n,prefix:``}:{directory:f(n),prefix:d(e)}}async function g(e){let t=C.get(e);if(t)return t;try{let t=(await o().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 u(e),[]}}async function _(e,t={}){let{basePath:n=i(),maxResults:r=10}=t,{directory:a,prefix:o}=h(e,n),s=await g(a),c=o.toLowerCase();return s.filter(e=>e.name.toLowerCase().startsWith(c)).slice(0,r).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 o().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 u(e),[]}}async function b(e,t={}){let{basePath:n=i(),maxResults:r=10,includeFiles:a=!0,includeHidden:o=!1}=t,{directory:s,prefix:c}=h(e,n),l=await y(s,o),u=c.toLowerCase(),d=l.filter(e=>!a&&e.type===`file`?!1:e.name.toLowerCase().startsWith(u)).slice(0,r),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((()=>{t(),r(),a(),l(),c(),x=500,S=300*1e3,C=new n({max:x,ttl:S}),w=new n({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{v as t,y as n}from"./types-97nL3naE.js";import{n as r,t as i}from"./cwd-BvNt_018.js";import{f as a,u as o}from"./debug-CRnGsZOV.js";import{er as s,nr as c}from"./settings-CodSADx8.js";import{o as l,s as u}from"./log-DoSpAwRP.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||i(),prefix:``};let n=s(e,t);return e.endsWith(`/`)||e.endsWith(m)?{directory:n,prefix:``}:{directory:f(n),prefix:d(e)}}async function g(e){let t=C.get(e);if(t)return t;try{let t=(await o().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 u(e),[]}}async function _(e,t={}){let{basePath:n=i(),maxResults:r=10}=t,{directory:a,prefix:o}=h(e,n),s=await g(a),c=o.toLowerCase();return s.filter(e=>e.name.toLowerCase().startsWith(c)).slice(0,r).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 o().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 u(e),[]}}async function b(e,t={}){let{basePath:n=i(),maxResults:r=10,includeFiles:a=!0,includeHidden:o=!1}=t,{directory:s,prefix:c}=h(e,n),l=await y(s,o),u=c.toLowerCase(),d=l.filter(e=>!a&&e.type===`file`?!1:e.name.toLowerCase().startsWith(u)).slice(0,r),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((()=>{n(),r(),a(),l(),c(),x=500,S=300*1e3,C=new t({max:x,ttl:S}),w=new t({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-uvO6NM5m.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,13 @@
1
+ import{n as e,t}from"./defineProperty-C-QyHrDq.js";import{B as n,J as r,N as i,P as a,Q as o,R as s,U as c,W as l,X as u,Z as d,b as f,et as p,k as m}from"./types-97nL3naE.js";import{$n as h,Hn as g,Pt as _,Qn as ee,Tn as v,ot as y,q as b}from"./state-BQ4BEGin.js";import{B as te,Dc as ne,Di as re,Ds as ie,Ec as ae,Mi as oe,Os as se,Ug as ce,V as le,Xl as ue,Yl as de,gr as x,i as fe,nr as S,o as pe,zg as me}from"./loadAgentsDir-DGozQu_6.js";import{_r as C,d as he,h as ge,pr as _e,sr as ve}from"./settings-CodSADx8.js";import{d as ye,n as be}from"./config-CWPHVTic.js";import{f as xe,s as Se}from"./model-DpZaKZMb.js";import{_n as Ce,vn as we}from"./prompt-DzO1um1h.js";import{t as w}from"./conversationRecovery-BBJzrA0g.js";import{t as Te}from"./QueryEngine-egz5mbaW.js";import{n as Ee,r as De}from"./modelOptions-CXBfKFXA.js";import{n as Oe,r as ke}from"./managedEnv-CIWJsuty.js";import{dirname as Ae}from"node:path";import{randomUUID as T}from"node:crypto";import{Readable as je,Writable as Me}from"node:stream";import{unlink as Ne}from"node:fs/promises";import*as E from"node:path/posix";import{isAbsolute as Pe,resolve as Fe}from"node:path/posix";f();var D={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`},O={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`},Ie=l({_meta:r(u(),o()).nullish(),terminal:a().optional().default(!1)}),Le=l({_meta:r(u(),o()).nullish(),label:u().nullish(),name:u(),optional:a().optional().default(!1),secret:a().optional().default(!0)}),Re=l({_meta:r(u(),o()).nullish(),description:u().nullish(),id:u(),name:u()}),ze=l({_meta:r(u(),o()).nullish(),description:u().nullish(),id:u(),link:u().nullish(),name:u(),vars:i(Le)}),Be=l({_meta:r(u(),o()).nullish(),args:i(u()).optional(),description:u().nullish(),env:r(u(),u()).optional(),id:u(),name:u()}),Ve=d([ze.and(l({type:n(`env_var`)})),Be.and(l({type:n(`terminal`)})),Re]),He=l({_meta:r(u(),o()).nullish(),methodId:u()}),Ue=l({_meta:r(u(),o()).nullish()}),We=l({_meta:r(u(),o()).nullish(),blob:u(),mimeType:u().nullish(),uri:u()}),Ge=l({default:a().nullish(),description:u().nullish(),title:u().nullish()}),Ke=l({_meta:r(u(),o()).nullish()}),qe=l({_meta:r(u(),o()).nullish()}),Je=l({amount:c(),currency:u()}),Ye=l({_meta:r(u(),o()).nullish(),terminalId:u()}),Xe=l({_meta:r(u(),o()).nullish(),newText:u(),oldText:u().nullish(),path:u()}),Ze=d([u(),c(),c(),a(),i(u())]),Qe=s(d([l({content:r(u(),Ze).nullish()}).and(l({action:n(`accept`)})),l({action:n(`decline`)}),l({action:n(`cancel`)})]),l({_meta:r(u(),o()).nullish()})),$e=l({_meta:r(u(),o()).nullish()}),et=u(),tt=l({_meta:r(u(),o()).nullish(),elicitationId:et}),nt=n(`object`),rt=n(`string`),it=l({_meta:r(u(),o()).nullish()}),at=l({_meta:r(u(),o()).nullish(),form:$e.nullish(),url:it.nullish()}),ot=l({const:u(),title:u()}),st=l({_meta:r(u(),o()).nullish(),name:u(),value:u()}),ct=l({code:d([n(-32700),n(-32600),n(-32601),n(-32602),n(-32603),n(-32800),n(-32e3),n(-32002),n(-32042),c().int().min(-2147483648,{message:`Invalid value: Expected int32 to be >= -2147483648`}).max(2147483647,{message:`Invalid value: Expected int32 to be <= 2147483647`})]),data:o().optional(),message:u()}),lt=o(),ut=o(),dt=o(),ft=l({_meta:r(u(),o()).nullish(),readTextFile:a().optional().default(!1),writeTextFile:a().optional().default(!1)}),pt=l({_meta:r(u(),o()).nullish(),name:u(),value:u()}),mt=l({_meta:r(u(),o()).nullish(),name:u(),title:u().nullish(),version:u()}),ht=l({default:c().nullish(),description:u().nullish(),maximum:c().nullish(),minimum:c().nullish(),title:u().nullish()}),gt=l({_meta:r(u(),o()).nullish()}),_t=l({_meta:r(u(),o()).nullish(),additionalDirectories:i(u()).optional(),cursor:u().nullish(),cwd:u().nullish()}),vt=l({_meta:r(u(),o()).nullish()}),yt=l({_meta:r(u(),o()).nullish(),logout:vt.nullish()}),bt=l({_meta:r(u(),o()).nullish()}),xt=l({_meta:r(u(),o()).nullish()}),St=l({_meta:r(u(),o()).nullish(),http:a().optional().default(!1),sse:a().optional().default(!1)}),Ct=l({_meta:r(u(),o()).nullish(),headers:i(pt),name:u(),url:u()}),wt=l({_meta:r(u(),o()).nullish(),headers:i(pt),name:u(),url:u()}),Tt=l({_meta:r(u(),o()).nullish(),args:i(u()),command:u(),env:i(st),name:u()}),k=d([Ct.and(l({type:n(`http`)})),wt.and(l({type:n(`sse`)})),Tt]),A=u(),Et=l({_meta:r(u(),o()).nullish(),description:u().nullish(),modelId:A,name:u()}),Dt=d([n(`error`),n(`warning`),n(`information`),n(`hint`)]),Ot=l({_meta:r(u(),o()).nullish()}),kt=l({_meta:r(u(),o()).nullish()}),At=l({_meta:r(u(),o()).nullish()}),jt=l({_meta:r(u(),o()).nullish()}),Mt=l({_meta:r(u(),o()).nullish()}),Nt=l({_meta:r(u(),o()).nullish(),maxCount:c().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish()}),Pt=l({diff:u(),uri:u()}),Ft=l({endLine:c().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}),startLine:c().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}),text:u()}),It=l({_meta:r(u(),o()).nullish()}),Lt=l({_meta:r(u(),o()).nullish()}),Rt=l({languageId:u(),text:u(),uri:u()}),zt=l({_meta:r(u(),o()).nullish(),maxCount:c().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish()}),Bt=d([n(`rejected`),n(`ignored`),n(`replaced`),n(`cancelled`)]),Vt=l({excerpts:i(Ft),uri:u()}),Ht=l({_meta:r(u(),o()).nullish()}),Ut=l({_meta:r(u(),o()).nullish()}),Wt=l({name:u(),owner:u(),remoteUrl:u()}),Gt=l({_meta:r(u(),o()).nullish()}),Kt=l({_meta:r(u(),o()).nullish(),jump:It.nullish(),rename:Ut.nullish(),searchAndReplace:Gt.nullish()}),qt=l({id:u(),isRegex:a().nullish(),replace:u(),search:u(),uri:u()}),Jt=d([n(`automatic`),n(`diagnostic`),n(`manual`)]),Yt=l({_meta:r(u(),o()).nullish(),maxCount:c().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish()}),Xt=l({_meta:r(u(),o()).nullish(),diagnostics:Ot.nullish(),editHistory:Nt.nullish(),openFiles:Lt.nullish(),recentFiles:zt.nullish(),relatedSnippets:Ht.nullish(),userActions:Yt.nullish()}),Zt=l({_meta:r(u(),o()).nullish(),additionalDirectories:i(u()).optional(),cwd:u(),mcpServers:i(k)}),Qt=l({default:c().nullish(),description:u().nullish(),maximum:c().nullish(),minimum:c().nullish(),title:u().nullish()}),$t=u(),en=d([n(`allow_once`),n(`allow_always`),n(`reject_once`),n(`reject_always`)]),tn=l({_meta:r(u(),o()).nullish(),kind:en,name:u(),optionId:$t}),nn=d([n(`high`),n(`medium`),n(`low`)]),rn=d([n(`pending`),n(`in_progress`),n(`completed`)]),an=l({_meta:r(u(),o()).nullish(),content:u(),priority:nn,status:rn}),on=l({_meta:r(u(),o()).nullish(),entries:i(an)}),j=l({character:c().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}),line:c().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`})}),sn=l({id:u(),position:j,uri:u()}),cn=l({id:u(),newName:u(),position:j,uri:u()}),ln=l({action:u(),position:j,timestampMs:c(),uri:u()}),M=d([n(`utf-16`),n(`utf-32`),n(`utf-8`)]),un=l({_meta:r(u(),o()).nullish(),auth:Ie.optional().default({terminal:!1}),elicitation:at.nullish(),fs:ft.optional().default({readTextFile:!1,writeTextFile:!1}),nes:Kt.nullish(),positionEncodings:i(M).optional(),terminal:a().optional().default(!1)}),dn=l({_meta:r(u(),o()).nullish(),audio:a().optional().default(!1),embeddedContext:a().optional().default(!1),image:a().optional().default(!1)}),fn=c().int().gte(0).lte(65535),pn=l({_meta:r(u(),o()).nullish(),clientCapabilities:un.optional().default({auth:{terminal:!1},fs:{readTextFile:!1,writeTextFile:!1},terminal:!1}),clientInfo:mt.nullish(),protocolVersion:fn}),N=l({end:j,start:j}),mn=l({message:u(),range:N,severity:Dt,uri:u()}),hn=l({languageId:u(),lastFocusedMs:c().nullish(),uri:u(),visibleRange:N.nullish()}),gn=l({_meta:r(u(),o()).nullish(),diagnostics:i(mn).nullish(),editHistory:i(Pt).nullish(),openFiles:i(hn).nullish(),recentFiles:i(Rt).nullish(),relatedSnippets:i(Vt).nullish(),userActions:i(ln).nullish()}),_n=l({newText:u(),range:N}),vn=d([l({cursorPosition:j.nullish(),edits:i(_n),id:u(),uri:u()}).and(l({kind:n(`edit`)})),sn.and(l({kind:n(`jump`)})),cn.and(l({kind:n(`rename`)})),qt.and(l({kind:n(`searchAndReplace`)}))]),yn=l({_meta:r(u(),o()).nullish(),content:u()}),bn=l({_meta:r(u(),o()).nullish()}),P=d([c(),u()]).nullable();l({_meta:r(u(),o()).nullish(),requestId:P});var xn=l({requestId:P}),Sn=m([`assistant`,`user`]),F=l({_meta:r(u(),o()).nullish(),audience:i(Sn).nullish(),lastModified:u().nullish(),priority:c().nullish()}),Cn=l({_meta:r(u(),o()).nullish(),annotations:F.nullish(),data:u(),mimeType:u()}),wn=l({_meta:r(u(),o()).nullish(),annotations:F.nullish(),data:u(),mimeType:u(),uri:u().nullish()}),Tn=l({_meta:r(u(),o()).nullish(),annotations:F.nullish(),description:u().nullish(),mimeType:u().nullish(),name:u(),size:c().nullish(),title:u().nullish(),uri:u()}),En=l({_meta:r(u(),o()).nullish(),optionId:$t}),Dn=d([l({outcome:n(`cancelled`)}),En.and(l({outcome:n(`selected`)}))]),On=l({_meta:r(u(),o()).nullish(),outcome:Dn}),kn=l({_meta:r(u(),o()).nullish()}),An=l({_meta:r(u(),o()).nullish()}),jn=l({currentValue:a()}),Mn=u(),Nn=u(),Pn=d([n(`mode`),n(`model`),n(`thought_level`),u()]),I=u(),Fn=l({_meta:r(u(),o()).nullish(),description:u().nullish(),name:u(),value:I}),In=l({_meta:r(u(),o()).nullish(),group:Mn,name:u(),options:i(Fn)}),L=s(d([l({currentValue:I,options:d([i(Fn),i(In)])}).and(l({type:n(`select`)})),jn.and(l({type:n(`boolean`)}))]),l({_meta:r(u(),o()).nullish(),category:Pn.nullish(),description:u().nullish(),id:Nn,name:u()})),Ln=l({_meta:r(u(),o()).nullish(),configOptions:i(L)}),Rn=l({_meta:r(u(),o()).nullish()}),R=u(),zn=l({_meta:r(u(),o()).nullish(),id:u(),sessionId:R}),Bn=l({_meta:r(u(),o()).nullish(),sessionId:R}),Vn=l({_meta:r(u(),o()).nullish(),sessionId:R}),Hn=l({_meta:r(u(),o()).nullish(),sessionId:R}),Un=l({_meta:r(u(),o()).nullish(),args:i(u()).optional(),command:u(),cwd:u().nullish(),env:i(st).optional(),outputByteLimit:c().nullish(),sessionId:R}),Wn=l({_meta:r(u(),o()).nullish(),sessionId:R,uri:u()}),Gn=l({_meta:r(u(),o()).nullish(),position:j,sessionId:R,uri:u(),version:c(),visibleRange:N}),Kn=l({_meta:r(u(),o()).nullish(),languageId:u(),sessionId:R,text:u(),uri:u(),version:c()}),qn=l({_meta:r(u(),o()).nullish(),sessionId:R,uri:u()}),Jn=l({_meta:r(u(),o()).nullish(),additionalDirectories:i(u()).optional(),cwd:u(),mcpServers:i(k).optional(),sessionId:R}),Yn=l({_meta:r(u(),o()).nullish(),sessionId:R,terminalId:u()}),Xn=l({_meta:r(u(),o()).nullish(),additionalDirectories:i(u()).optional(),cwd:u(),mcpServers:i(k),sessionId:R}),Zn=l({_meta:r(u(),o()).nullish(),limit:c().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),line:c().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),path:u(),sessionId:R}),Qn=l({_meta:r(u(),o()).nullish(),id:u(),reason:Bt.nullish(),sessionId:R}),$n=l({_meta:r(u(),o()).nullish(),sessionId:R,terminalId:u()}),er=l({_meta:r(u(),o()).nullish(),additionalDirectories:i(u()).optional(),cwd:u(),mcpServers:i(k).optional(),sessionId:R}),tr=l({_meta:r(u(),o()).nullish(),additionalDirectories:i(u()).optional(),cwd:u(),sessionId:R,title:u().nullish(),updatedAt:u().nullish()}),nr=l({_meta:r(u(),o()).nullish(),nextCursor:u().nullish(),sessions:i(tr)}),rr=l({_meta:r(u(),o()).nullish(),title:u().nullish(),updatedAt:u().nullish()}),ir=l({_meta:r(u(),o()).nullish()}),z=u(),ar=l({_meta:r(u(),o()).nullish(),currentModeId:z}),or=l({_meta:r(u(),o()).nullish(),description:u().nullish(),id:z,name:u()}),B=l({_meta:r(u(),o()).nullish(),availableModes:i(or),currentModeId:z}),V=l({_meta:r(u(),o()).nullish(),availableModels:i(Et),currentModelId:A}),sr=l({_meta:r(u(),o()).nullish(),configOptions:i(L).nullish(),models:V.nullish(),modes:B.nullish(),sessionId:R}),cr=l({_meta:r(u(),o()).nullish(),configOptions:i(L).nullish(),models:V.nullish(),modes:B.nullish()}),lr=l({_meta:r(u(),o()).nullish(),configOptions:i(L).nullish(),models:V.nullish(),modes:B.nullish(),sessionId:R}),ur=l({_meta:r(u(),o()).nullish(),configOptions:i(L).nullish(),models:V.nullish(),modes:B.nullish()}),dr=l({_meta:r(u(),o()).nullish()}),fr=l({_meta:r(u(),o()).nullish(),additionalDirectories:kn.nullish(),close:An.nullish(),fork:Rn.nullish(),list:ir.nullish(),resume:dr.nullish()}),pr=s(d([l({type:n(`boolean`),value:a()}),l({value:I})]),l({_meta:r(u(),o()).nullish(),configId:Nn,sessionId:R})),mr=l({_meta:r(u(),o()).nullish(),configOptions:i(L)}),hr=l({_meta:r(u(),o()).nullish(),modeId:z,sessionId:R}),gr=l({_meta:r(u(),o()).nullish()}),_r=l({_meta:r(u(),o()).nullish(),modelId:A,sessionId:R}),vr=l({_meta:r(u(),o()).nullish()}),yr=l({_meta:r(u(),o()).nullish(),sessionId:R}),br=d([n(`end_turn`),n(`max_tokens`),n(`max_turn_requests`),n(`refusal`),n(`cancelled`)]),xr=d([n(`email`),n(`uri`),n(`date`),n(`date-time`)]),Sr=l({default:u().nullish(),description:u().nullish(),enum:i(u()).nullish(),format:xr.nullish(),maxLength:c().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),minLength:c().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),oneOf:i(ot).nullish(),pattern:u().nullish(),title:u().nullish()}),Cr=l({_meta:r(u(),o()).nullish(),context:gn.nullish(),position:j,selection:N.nullish(),sessionId:R,triggerKind:Jt,uri:u(),version:c()}),wr=l({_meta:r(u(),o()).nullish(),suggestions:i(vn)}),Tr=l({_meta:r(u(),o()).nullish(),terminalId:u()}),Er=l({_meta:r(u(),o()).nullish(),exitCode:c().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),signal:u().nullish()}),Dr=l({_meta:r(u(),o()).nullish(),sessionId:R,terminalId:u()}),Or=l({_meta:r(u(),o()).nullish(),exitStatus:Er.nullish(),output:u(),truncated:a()}),kr=l({_meta:r(u(),o()).nullish(),annotations:F.nullish(),text:u()}),Ar=l({range:N.nullish(),text:u()}),jr=l({_meta:r(u(),o()).nullish(),contentChanges:i(Ar),sessionId:R,uri:u(),version:c()});l({method:u(),params:d([Bn,Kn,jr,Wn,qn,Gn,zn,Qn,lt]).nullish()});var Mr=d([n(`full`),n(`incremental`)]),Nr=l({_meta:r(u(),o()).nullish(),syncKind:Mr}),Pr=l({_meta:r(u(),o()).nullish(),didChange:Nr.nullish(),didClose:kt.nullish(),didFocus:At.nullish(),didOpen:jt.nullish(),didSave:Mt.nullish()}),Fr=l({_meta:r(u(),o()).nullish(),document:Pr.nullish()}),Ir=l({_meta:r(u(),o()).nullish(),context:Xt.nullish(),events:Fr.nullish()}),Lr=l({_meta:r(u(),o()).nullish(),auth:yt.optional().default({}),loadSession:a().optional().default(!1),mcpCapabilities:St.optional().default({http:!1,sse:!1}),nes:Ir.nullish(),positionEncoding:M.nullish(),promptCapabilities:dn.optional().default({audio:!1,embeddedContext:!1,image:!1}),sessionCapabilities:fr.optional().default({})}),Rr=l({_meta:r(u(),o()).nullish(),agentCapabilities:Lr.optional().default({auth:{},loadSession:!1,mcpCapabilities:{http:!1,sse:!1},promptCapabilities:{audio:!1,embeddedContext:!1,image:!1},sessionCapabilities:{}}),agentInfo:mt.nullish(),authMethods:i(Ve).optional().default([]),protocolVersion:fn}),zr=d([l({_meta:r(u(),o()).nullish(),mimeType:u().nullish(),text:u(),uri:u()}),We]),Br=l({_meta:r(u(),o()).nullish(),annotations:F.nullish(),resource:zr}),H=d([kr.and(l({type:n(`text`)})),wn.and(l({type:n(`image`)})),Cn.and(l({type:n(`audio`)})),Tn.and(l({type:n(`resource_link`)})),Br.and(l({type:n(`resource`)}))]),Vr=l({_meta:r(u(),o()).nullish(),content:H}),U=l({_meta:r(u(),o()).nullish(),content:H,messageId:u().nullish()}),Hr=l({_meta:r(u(),o()).nullish(),messageId:u().nullish(),prompt:i(H),sessionId:R}),Ur=l({anyOf:i(ot)}),Wr=d([Vr.and(l({type:n(`content`)})),Xe.and(l({type:n(`diff`)})),Tr.and(l({type:n(`terminal`)}))]),W=u(),Gr=l({sessionId:R,toolCallId:W.nullish()}),Kr=s(d([Gr,xn]),l({elicitationId:et,url:u().url()})),qr=l({_meta:r(u(),o()).nullish(),line:c().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),path:u()}),Jr=d([n(`pending`),n(`in_progress`),n(`completed`),n(`failed`)]),Yr=d([n(`read`),n(`edit`),n(`delete`),n(`move`),n(`search`),n(`execute`),n(`think`),n(`fetch`),n(`switch_mode`),n(`other`)]),Xr=l({_meta:r(u(),o()).nullish(),content:i(Wr).optional(),kind:Yr.optional(),locations:i(qr).optional(),rawInput:o().optional(),rawOutput:o().optional(),status:Jr.optional(),title:u(),toolCallId:W}),Zr=l({_meta:r(u(),o()).nullish(),content:i(Wr).nullish(),kind:Yr.nullish(),locations:i(qr).nullish(),rawInput:o().optional(),rawOutput:o().optional(),status:Jr.nullish(),title:u().nullish(),toolCallId:W}),Qr=l({_meta:r(u(),o()).nullish(),options:i(tn),sessionId:R,toolCall:Zr}),$r=l({_meta:r(u(),o()).nullish(),hint:u()}),ei=l({_meta:r(u(),o()).nullish(),description:u(),input:$r.nullish(),name:u()}),ti=l({_meta:r(u(),o()).nullish(),availableCommands:i(ei)}),ni=d([l({enum:i(u()),type:rt}),Ur]),ri=l({default:i(u()).nullish(),description:u().nullish(),items:ni,maxItems:c().nullish(),minItems:c().nullish(),title:u().nullish()}),ii=d([Sr.and(l({type:n(`string`)})),Qt.and(l({type:n(`number`)})),ht.and(l({type:n(`integer`)})),Ge.and(l({type:n(`boolean`)})),ri.and(l({type:n(`array`)}))]),ai=l({description:u().nullish(),properties:r(u(),ii).optional().default({}),required:i(u()).nullish(),title:u().nullish(),type:nt.optional().default(`object`)}),oi=s(d([s(d([Gr,xn]),l({requestedSchema:ai})).and(l({mode:n(`form`)})),Kr.and(l({mode:n(`url`)}))]),l({_meta:r(u(),o()).nullish(),message:u()})),si=l({cachedReadTokens:c().nullish(),cachedWriteTokens:c().nullish(),inputTokens:c(),outputTokens:c(),thoughtTokens:c().nullish(),totalTokens:c()});d([l({id:P,result:d([Rr,Ue,xt,lr,cr,nr,sr,ur,qe,gr,mr,l({_meta:r(u(),o()).nullish(),stopReason:br,usage:si.nullish(),userMessageId:u().nullish()}),vr,yr,wr,Ke,dt])}),l({error:ct,id:P})]);var ci=l({_meta:r(u(),o()).nullish(),cost:Je.nullish(),size:c(),used:c()}),li=d([U.and(l({sessionUpdate:n(`user_message_chunk`)})),U.and(l({sessionUpdate:n(`agent_message_chunk`)})),U.and(l({sessionUpdate:n(`agent_thought_chunk`)})),Xr.and(l({sessionUpdate:n(`tool_call`)})),Zr.and(l({sessionUpdate:n(`tool_call_update`)})),on.and(l({sessionUpdate:n(`plan`)})),ti.and(l({sessionUpdate:n(`available_commands_update`)})),ar.and(l({sessionUpdate:n(`current_mode_update`)})),Ln.and(l({sessionUpdate:n(`config_option_update`)})),rr.and(l({sessionUpdate:n(`session_info_update`)})),ci.and(l({sessionUpdate:n(`usage_update`)}))]),ui=l({_meta:r(u(),o()).nullish(),sessionId:R,update:li});l({method:u(),params:d([ui,tt,lt]).nullish()});var di=l({_meta:r(u(),o()).nullish(),sessionId:R,terminalId:u()}),fi=l({_meta:r(u(),o()).nullish(),exitCode:c().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),signal:u().nullish()}),pi=l({name:u(),uri:u()}),mi=l({_meta:r(u(),o()).nullish(),repository:Wt.nullish(),workspaceFolders:i(pi).nullish(),workspaceUri:u().nullish()});l({id:P,method:u(),params:d([pn,He,bt,Zt,Xn,_t,Jn,er,Hn,hr,pr,Hr,_r,mi,Cr,Vn,ut]).nullish()});var hi=l({_meta:r(u(),o()).nullish(),content:u(),path:u(),sessionId:R});l({id:P,method:u(),params:d([hi,Zn,Qr,Un,Dr,$n,di,Yn,oi,ut]).nullish()}),d([l({id:P,result:d([l({_meta:r(u(),o()).nullish()}),yn,On,Ye,Or,bn,fi,gt,Qe,dt])}),l({error:ct,id:P})]),e();function gi(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()}}})}}f();var _i,vi=class{constructor(e,n){t(this,`connection`,void 0);let r=e(this),i=async(e,t)=>{switch(e){case D.initialize:{let e=pn.parse(t);return r.initialize(e)}case D.session_new:{let e=Zt.parse(t);return r.newSession(e)}case D.session_load:{if(!r.loadSession)throw G.methodNotFound(e);let n=Xn.parse(t);return r.loadSession(n)}case D.session_list:{if(!r.listSessions)throw G.methodNotFound(e);let n=_t.parse(t);return r.listSessions(n)}case D.session_fork:{if(!r.unstable_forkSession)throw G.methodNotFound(e);let n=Jn.parse(t);return r.unstable_forkSession(n)}case D.session_resume:{if(!r.unstable_resumeSession)throw G.methodNotFound(e);let n=er.parse(t);return r.unstable_resumeSession(n)}case D.session_close:{if(!r.unstable_closeSession)throw G.methodNotFound(e);let n=Hn.parse(t);return r.unstable_closeSession(n)}case D.session_set_mode:{if(!r.setSessionMode)throw G.methodNotFound(e);let n=hr.parse(t);return await r.setSessionMode(n)??{}}case D.authenticate:{let e=He.parse(t);return await r.authenticate(e)??{}}case D.logout:{if(!r.unstable_logout)throw G.methodNotFound(e);let n=bt.parse(t);return await r.unstable_logout(n)??{}}case D.session_prompt:{let e=Hr.parse(t);return r.prompt(e)}case D.session_set_model:{if(!r.unstable_setSessionModel)throw G.methodNotFound(e);let n=_r.parse(t);return await r.unstable_setSessionModel(n)??{}}case D.session_set_config_option:{if(!r.setSessionConfigOption)throw G.methodNotFound(e);let n=pr.parse(t);return r.setSessionConfigOption(n)}case D.nes_start:{if(!r.unstable_startNes)throw G.methodNotFound(e);let n=mi.parse(t);return r.unstable_startNes(n)}case D.nes_suggest:{if(!r.unstable_suggestNes)throw G.methodNotFound(e);let n=Cr.parse(t);return r.unstable_suggestNes(n)}case D.nes_close:{if(!r.unstable_closeNes)throw G.methodNotFound(e);let n=Vn.parse(t);return await r.unstable_closeNes(n)??{}}default:if(r.extMethod)return r.extMethod(e,t);throw G.methodNotFound(e)}},a=async(e,t)=>{switch(e){case D.session_cancel:{let e=Bn.parse(t);return r.cancel(e)}case D.document_did_open:{if(!r.unstable_didOpenDocument)return;let e=Kn.parse(t);return r.unstable_didOpenDocument(e)}case D.document_did_change:{if(!r.unstable_didChangeDocument)return;let e=jr.parse(t);return r.unstable_didChangeDocument(e)}case D.document_did_close:{if(!r.unstable_didCloseDocument)return;let e=Wn.parse(t);return r.unstable_didCloseDocument(e)}case D.document_did_save:{if(!r.unstable_didSaveDocument)return;let e=qn.parse(t);return r.unstable_didSaveDocument(e)}case D.document_did_focus:{if(!r.unstable_didFocusDocument)return;let e=Gn.parse(t);return r.unstable_didFocusDocument(e)}case D.nes_accept:{if(!r.unstable_acceptNes)return;let e=zn.parse(t);return r.unstable_acceptNes(e)}case D.nes_reject:{if(!r.unstable_rejectNes)return;let e=Qn.parse(t);return r.unstable_rejectNes(e)}default:if(r.extNotification)return r.extNotification(e,t);throw G.methodNotFound(e)}};this.connection=new bi(i,a,n)}async sessionUpdate(e){return await this.connection.sendNotification(O.session_update,e)}async requestPermission(e){return await this.connection.sendRequest(O.session_request_permission,e)}async readTextFile(e){return await this.connection.sendRequest(O.fs_read_text_file,e)}async writeTextFile(e){return await this.connection.sendRequest(O.fs_write_text_file,e)??{}}async createTerminal(e){return new yi((await this.connection.sendRequest(O.terminal_create,e)).terminalId,e.sessionId,this.connection)}async unstable_createElicitation(e){return await this.connection.sendRequest(O.elicitation_create,e)}async unstable_completeElicitation(e){return await this.connection.sendNotification(O.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}};_i=Symbol.asyncDispose;var yi=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(O.terminal_output,{sessionId:this.sessionId,terminalId:this.id})}async waitForExit(){return await this.connection.sendRequest(O.terminal_wait_for_exit,{sessionId:this.sessionId,terminalId:this.id})}async kill(){return await this.connection.sendRequest(O.terminal_kill,{sessionId:this.sessionId,terminalId:this.id})??{}}async release(){return await this.connection.sendRequest(O.terminal_release,{sessionId:this.sessionId,terminalId:this.id})??{}}async[_i](){await this.release()}},bi=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 G)return e.toResult();if(e instanceof p)return G.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 G.internalError(t?JSON.parse(t):{}).toResult()}catch{return G.internalError({details:t}).toResult()}}}async tryCallNotificationHandler(e,t){try{return await this.notificationHandler(e,t),{result:null}}catch(e){if(e instanceof G)return e.toResult();if(e instanceof p)return G.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 G.internalError(t?JSON.parse(t):{}).toResult()}catch{return G.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 G(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}},G=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}}};ee(),_(),ge(),we(),ye(),ce(),ne(),se(),oe(),le(),pe(),ke();function K(e,t){if(e)return t?Pe(e)?e:Fe(t,e):e}var xi=!(typeof process.geteuid==`function`?process.geteuid()===0:typeof process.getuid==`function`&&process.getuid()===0)||!!process.env.IS_SANDBOX,Si={auto:`auto`,default:`default`,acceptedits:`acceptEdits`,dontask:`dontAsk`,plan:`plan`,bypasspermissions:`bypassPermissions`,bypass:`bypassPermissions`};function Ci(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=Si[n];if(!r)throw Error(`Invalid ${t}: ${e}.`);if(r===`bypassPermissions`&&!xi)throw Error(`Invalid ${t}: bypassPermissions is not available when running as root.`);return r}function wi(e){let t=[...e.mcpServers??[]].sort((e,t)=>e.name.localeCompare(t.name));return JSON.stringify({cwd:e.cwd,mcpServers:t})}var Ti=256;function Ei(e){let t=e.replace(/[\r\n]+/g,` `).replace(/\s+/g,` `).trim();return t.length<=Ti?t:`${t.slice(0,Ti-1)}…`}function q(e,t){if(!t)return e;let n=E.resolve(t),r=E.resolve(e);return r.startsWith(n+E.sep)||r===n?E.relative(n,r):e}function J(e){let t="```";for(let n of e.matchAll(/^```+/gm)??[])for(;n[0].length>=t.length;)t+="`";return`${t}\n${e}${e.endsWith(`
4
+ `)?``:`
5
+ `}${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?q(t,n):`File`,c=K(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?q(e,n):void 0,a=K(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?q(e,n):void 0,o=K(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=K(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 Di(e,t){return Array.isArray(e)&&e.length>0?{content:e.map(e=>({type:`content`,content:Oi(e,t)}))}:typeof e==`string`&&e.length>0?{content:[{type:`content`,content:{type:`text`,text:t?`\`\`\`\n${e}\n\`\`\``:e}}]}:{}}function Oi(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(`
6
+ `)||``)}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 ki(e,t,n=!1){if(!t)return{};let r=e.is_error===!0,i=e.content;if(r&&i)return Di(i,!0);switch(t.name){case`Read`:return typeof i==`string`&&i.length>0?{content:[{type:`content`,content:{type:`text`,text:J(i)}}]}:Array.isArray(i)&&i.length>0?{content:i.map(e=>({type:`content`,content:e.type===`text`?{type:`text`,text:J(e.text)}:Oi(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(`
7
+ `)}else typeof i==`string`?e=i:Array.isArray(i)&&i.length>0&&(e=i.map(e=>e.type===`text`?e.text:``).join(`
8
+ `));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 Di(i??``,r)}}function Ai(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:Ai(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=ki(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 ji(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 Mi(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 Ni(e,t){let n=0,r=Math.min(e.length,t.length);for(;n<r&&e[n]===t[n];)n++;return n}function Pi(e,t){let n=null,r=0;for(let i of Object.keys(e)){let e=Ni(i,t);e>r&&(r=e,n=i)}return n?e[n]??null:null}var Fi=console;function Ii(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 Li(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 Ii(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:`
9
+
10
+ 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=Pi(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=T());let r=Mi(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=T()),s=m);let c=ji(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:`
11
+
12
+ Compacting completed.`}}});break;default:Fi.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 Ri(e,t,n,r,i,a){for(let o of t){let t=o;if(t.type!==`user`&&t.type!==`assistant`){Fi.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=T();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:T()});for(let e of t)await n.sessionUpdate(e)}}}function zi(e,t,n,r,i,a,o,s){return async(n,c,l,u,d,f)=>{let p=Vi(r);if(n.name===`ExitPlanMode`)return Bi(e,t,d,c,p,i,a,o,s);if(f!==void 0)return f;try{let e=await te(n,c,l,u,d);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:d}}let m=Y({name:n.name,id:d,input:c},p,i),h={toolCallId:d,title:m.title,kind:m.kind,status:`pending`,rawInput:c},g=[{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:h,options:g});if(n.outcome.outcome===`cancelled`)return s?.(),{behavior:`deny`,message:`Permission request cancelled by client`,decisionReason:{type:`mode`,mode:`default`},toolUseID:d};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 Bi(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 Vi(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}xe(),De(),de(),_e(),e(),x();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:`workmate`,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||b(),n=await ve(t),r=await ue({dir:t}),i=[];for(let e of r){if(!e.cwd||await ve(e.cwd)!==n)continue;let t=Ei(e.summary??``);i.push({sessionId:e.sessionId,cwd:e.cwd,...t?{title:t}:{},updatedAt:new Date(e.lastModified).toISOString()})}return{sessions:i}}async unstable_forkSession(e){let{initialMessages:t}=await Hi(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 C(e.sessionId);if(t)try{await Ne(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 G.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 Hi(e){let t;try{let n=await S(e);n&&n.messages.length>0&&(t=w(n.messages))}catch(e){console.error(`[ACP] fork source load failed:`,e)}return{initialMessages:t}}var Ui=[`auto`,`default`,`acceptEdits`,`bypassPermissions`,`dontAsk`,`plan`];function Wi(e){return Ui.includes(e)}function Gi(e,t,n){if(t){let t=Ki(e,`_meta.permissionMode`);if(t===`bypassPermissions`&&!Yi())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 qi(n)??`default`}function Ki(e,t){if(e==null)throw Error(`Invalid ${t}: expected a string.`);return Ci(e,t)}function qi(e){if(e!=null)try{return Ci(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 Ji(e,t){return!!e&&Object.hasOwn(e,t)}function Yi(){return Xi()}function Xi(){return process.env.IS_SANDBOX?!0:typeof process.geteuid==`function`?process.geteuid()!==0:typeof process.getuid!=`function`||process.getuid()!==0}function Zi(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 Qi(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 $i(e,t,n,r){n===`mode`?t.modes={...t.modes,currentModeId:r}:n===`model`&&(t.models={...t.models,currentModelId:r})}_();function ea(){return he().permissions?.defaultMode}async function ta(e,t={}){be();let n=t.sessionId??T(),r=e.cwd;g(n,y()),v(r);let i=process.cwd(),a=!1;try{process.chdir(r),a=!0}catch{}h(),Oe();try{let i=Ce(),a=ae(i),o=e._meta,s=Ji(o,`permissionMode`),c=Gi(s?o?.permissionMode:void 0,s,ea()),l=$(this),u=this.conn,d=zi(u,n,()=>this.sessions.get(n)?.modes.currentModeId??`default`,l,r,e=>{this.applySessionMode(n,e)},()=>this.sessions.get(n)?.appState.toolPermissionContext.isBypassPermissionsModeAvailable??!1),f=Yi(),p={...ie(),toolPermissionContext:{...i,mode:c,isBypassPermissionsModeAvailable:f}},[m,h]=await Promise.all([re(r),fe(r)]);p.agentDefinitions=h;let g=new Te({cwd:r,tools:a,commands:m,mcpClients:[],agents:h.activeAgents,canUseTool:d,getAppState:()=>p,setAppState:e=>{let t=e(p);Object.assign(p,t)},readFileCache:new me(500,50*1024*1024),includePartialMessages:!0,replayUserMessages:!0,initialMessages:t.initialMessages}),_={currentModeId:c,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.`},...f?[{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`}]},ee=Ee(),v=Se(),y={availableModels:ee.map(e=>({modelId:String(e.value??``),name:e.label??String(e.value??``),description:e.description??void 0})),currentModelId:v};g.setModel(v);let b=Zi(_,y),te={queryEngine:g,cancelled:!1,cancelGeneration:0,cwd:r,modes:_,models:y,configOptions:b,promptRunning:!1,pendingMessages:new Map,pendingQueue:[],pendingQueueHead:0,toolUseCache:{},clientCapabilities:l,appState:p,commands:m,sessionFingerprint:wi({cwd:r,mcpServers:e.mcpServers})};return this.sessions.set(n,te),{sessionId:n,modes:_,models:y,configOptions:b}}finally{a&&process.chdir(i)}}Object.assign(Z.prototype,{createSession:ta}),x(),_(),_e();async function na(e){let t=e.replay!==!1,n=this.sessions.get(e.sessionId);if(n){if(wi({cwd:e.cwd,mcpServers:e.mcpServers})===n.sessionFingerprint){let r=await C(e.sessionId,e.cwd);return g(e.sessionId,r?Ae(r.filePath):null),v(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 C(e.sessionId,e.cwd),i=r?Ae(r.filePath):null;g(e.sessionId,i),v(e.cwd);let a;if(r)try{let t=await S(e.sessionId);t&&t.messages.length>0&&(a=w(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 Ri(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 ra(e){this.sessions.get(e)&&(await this.cancel({sessionId:e}),this.sessions.delete(e))}async function ia(e){try{let t=await S(e.sessionId);if(!t||t.messages.length===0)return;let n=w(t.messages);if(n.length===0)return;let r=this.sessions.get(e.sessionId);if(!r)return;await Ri(e.sessionId,n,Q(this),r.toolUseCache,$(this),r.cwd)}catch(e){console.error(`[ACP] Failed to replay session history:`,e)}}function aa(e,t){if(!Wi(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 oa(e,t,n){let r=this.sessions.get(e);r&&($i(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:na,teardownSession:ra,replaySessionHistory:ia,applySessionMode:aa,updateConfigOption:oa});function sa(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(ca(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(`
13
+ `)}function ca(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 la(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),ua(e),n}ua(e)}function ua(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)}}_();async function da(e){let t=this.sessions.get(e.sessionId);if(!t)throw Error(`Session ${e.sessionId} not found`);let n=e.messageId??void 0,r=sa(e.prompt);if(!r.trim())throw Error(`Prompt content is empty`);let i=t.cancelGeneration;if(t.promptRunning){let e=T();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(),g(e.sessionId,y());let i=t.queryEngine.submitMessage(r),{stopReason:a,usage:o}=await Li(e.sessionId,i,Q(this),t.queryEngine.getAbortSignal(),t.toolUseCache,$(this),t.cwd,()=>t.cancelled);if(t.cancelled)return{stopReason:`cancelled`};if(await pa(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 Work Mate Agent process exited unexpectedly. Please start a new session.`)):n}finally{let e=la(t);e?(t.promptRunning=!0,e.resolve(!1)):t.promptRunning=!1}}async function fa(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=Qi(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),$i(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 pa(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=Ei(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:da,setSessionConfigOption:fa}),ye(),ke();function ma(e,t){let n=je.toWeb(e);return gi(Me.toWeb(t),n)}async function ha(){be(),Oe();let e=ma(process.stdin,process.stdout),t,n=new vi(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{ha as runAcpAgent};