@readmagic/workmate 0.0.25 → 0.0.26

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 (355) hide show
  1. package/dist/chunks/{AddWorkspaceDirectory-Y5S_lMjD.js → AddWorkspaceDirectory-mS8iUoWY.js} +1 -1
  2. package/dist/chunks/{AgentsMdExternalIncludesDialog-DVbU-BaD.js → AgentsMdExternalIncludesDialog-BHBkysy0.js} +1 -1
  3. package/dist/chunks/AgentsMdExternalIncludesDialog-DuStmCjj.js +1 -0
  4. package/dist/chunks/App-D--vtCyq.js +1 -0
  5. package/dist/chunks/BackgroundTasksDialog-mcDuiNGs.js +2 -0
  6. package/dist/chunks/{BypassPermissionsModeDialog-DjqGAL4C.js → BypassPermissionsModeDialog-DyqI98d2.js} +1 -1
  7. package/dist/chunks/CustomSelect-CpMbxYbt.js +1 -0
  8. package/dist/chunks/DiffDialog-BQAU2pJx.js +6 -0
  9. package/dist/chunks/Doctor-BU69VQzw.js +1 -0
  10. package/dist/chunks/Doctor-DJOMbSDE.js +3 -0
  11. package/dist/chunks/{ExitFlow-Dh9QdaYK.js → ExitFlow-xBOnvhiW.js} +2 -2
  12. package/dist/chunks/{InvalidConfigDialog-C9boykQn.js → InvalidConfigDialog-NiuhcaG5.js} +1 -1
  13. package/dist/chunks/{InvalidSettingsDialog-UN5mleCK.js → InvalidSettingsDialog-DrromC1I.js} +1 -1
  14. package/dist/chunks/KeybindingProviderSetup-CSUkJHTT.js +1 -0
  15. package/dist/chunks/MCPConnectionManager-Bn1PDn3R.js +1 -0
  16. package/dist/chunks/MCPToolListView-BRxjOaOL.js +1 -0
  17. package/dist/chunks/{McpParsingWarnings-zkM_lGd0.js → McpParsingWarnings-BYG2yqjO.js} +1 -1
  18. package/dist/chunks/MessageSelector-B7xAQqZI.js +3 -0
  19. package/dist/chunks/Messages-CxMsfjOa.js +10 -0
  20. package/dist/chunks/{Onboarding-BT90cFkn.js → Onboarding-CkATe87e.js} +1 -1
  21. package/dist/chunks/{PermissionDialog-BaibiQae.js → PermissionDialog-tEMMa5-a.js} +1 -1
  22. package/dist/chunks/{PressEnterToContinue-DZc_s_pE.js → PressEnterToContinue-CPOaYnym.js} +1 -1
  23. package/dist/chunks/{PromptInputFooterSuggestions-CCTZYbWI.js → PromptInputFooterSuggestions-CwqAsTI2.js} +1 -1
  24. package/dist/chunks/PromptInputHelpMenu-krq-hiFO.js +1 -0
  25. package/dist/chunks/{ProviderSetup-yIj8YOKF.js → ProviderSetup-J6Ty-Wj8.js} +1 -1
  26. package/dist/chunks/QueryEngine-Mdi_kUaL.js +1 -0
  27. package/dist/chunks/REPL-BgzQtSFF.js +1 -0
  28. package/dist/chunks/REPL-rirm6s_7.js +124 -0
  29. package/dist/chunks/ResumeConversation-Cmsbo5m7.js +1 -0
  30. package/dist/chunks/{SearchBox-C9xxQzh1.js → SearchBox-DQBLKyzJ.js} +1 -1
  31. package/dist/chunks/SearchExtraToolsTool-D1-7C04z.js +1 -0
  32. package/dist/chunks/{SelectMulti-BW7Ffk1G.js → SelectMulti-BpAjjhsn.js} +1 -1
  33. package/dist/chunks/Settings-B6DImvca.js +2 -0
  34. package/dist/chunks/Spinner-DhhSOFcN.js +1 -0
  35. package/dist/chunks/{SpinnerGlyph-CqrOK3Mx.js → SpinnerGlyph-CmVXC-_9.js} +1 -1
  36. package/dist/chunks/{TextInput-Cev5Awdd.js → TextInput-BboKIug2.js} +11 -11
  37. package/dist/chunks/ThemePicker-DTpXbEY0.js +1 -0
  38. package/dist/chunks/{TrustDialog-8Sjmuu0e.js → TrustDialog-CZ8JpySm.js} +1 -1
  39. package/dist/chunks/{ValidationErrorsList-INwwoerV.js → ValidationErrorsList-C_gDQfm1.js} +1 -1
  40. package/dist/chunks/{_baseEach-DrPH_FGo.js → _baseEach-DGbaIpJA.js} +1 -1
  41. package/dist/chunks/_baseSlice-D67_NpZ1.js +1 -0
  42. package/dist/chunks/{add-dir-D3RMaYxy.js → add-dir-B576wzi9.js} +1 -1
  43. package/dist/chunks/{agentDisplay-B3npXoCS.js → agentDisplay-ZuFoBZYu.js} +1 -1
  44. package/dist/chunks/{agents-2mPGmeq6.js → agents-Dy4_hDic.js} +1 -1
  45. package/dist/chunks/agents-HIOBiw4w.js +101 -0
  46. package/dist/chunks/allErrors-CxPNR2WN.js +1 -0
  47. package/dist/chunks/appleTerminalBackup-C9kjzdM9.js +1 -0
  48. package/dist/chunks/{backgroundHousekeeping-BkFxfjOf.js → backgroundHousekeeping-PyLNnGdw.js} +1 -1
  49. package/dist/chunks/backgroundHousekeeping-ZCMPmQuU.js +1 -0
  50. package/dist/chunks/{banner-DHpTmEO7.js → banner-DqFectPg.js} +2 -2
  51. package/dist/chunks/{branch-Be_yDFU8.js → branch-B_BL5N9N.js} +2 -2
  52. package/dist/chunks/{break-cache-UUt6Dkf2.js → break-cache-DL95nKZl.js} +2 -2
  53. package/dist/chunks/{btw-DUml5L1w.js → btw-Y44ctueB.js} +1 -1
  54. package/dist/chunks/bundledMode-BxyD5cqq.js +1 -0
  55. package/dist/chunks/caches-5xZ4dSXt.js +1 -0
  56. package/dist/chunks/caches-Be9saXxV.js +1 -0
  57. package/dist/chunks/{claudeDesktop-mBGFDbI6.js → claudeDesktop-g8eUUY2E.js} +1 -1
  58. package/dist/chunks/{clear-CrGjNe6E.js → clear-DtTkA707.js} +1 -1
  59. package/dist/chunks/{client-BDuhbzLD.js → client-Bw_L3lSc.js} +1 -1
  60. package/dist/chunks/{client-BYFVVMcf.js → client-aJ2Nr_sh.js} +1 -1
  61. package/dist/chunks/client-mnUISv_N.js +1 -0
  62. package/dist/chunks/client-wPqIdEVm.js +1 -0
  63. package/dist/chunks/commands-wfE12a4L.js +1 -0
  64. package/dist/chunks/compact-CvNOtu7J.js +2 -0
  65. package/dist/chunks/config-D3K87Mm1.js +3 -0
  66. package/dist/chunks/config-DTga6Ku8.js +1 -0
  67. package/dist/chunks/config-DtmqWusU.js +1 -0
  68. package/dist/chunks/{context-mV5zjqmc.js → context-Opu4E8dL.js} +1 -1
  69. package/dist/chunks/{context-noninteractive-DvfVvmSE.js → context-noninteractive-B1V2Mp26.js} +5 -5
  70. package/dist/chunks/context-noninteractive-eIlneYiL.js +1 -0
  71. package/dist/chunks/conversation-CG_z7TLE.js +1 -0
  72. package/dist/chunks/conversation-CHesBfFZ.js +1 -0
  73. package/dist/chunks/conversationRecovery-OhitW-7g.js +1 -0
  74. package/dist/chunks/crossProjectResume-mmYx8PrZ.js +40 -0
  75. package/dist/chunks/cwd-BH2f3u0o.js +1 -0
  76. package/dist/chunks/{cwd-BvNt_018.js → cwd-DrEEb4f5.js} +1 -1
  77. package/dist/chunks/{debug-CRnGsZOV.js → debug-kBjDaVkQ.js} +3 -3
  78. package/dist/chunks/{detectRepository-CsJLbVEe.js → detectRepository-M6K2wc7h.js} +1 -1
  79. package/dist/chunks/{diff-DUEoNCnJ.js → diff-Cv7tX2-P.js} +1 -1
  80. package/dist/chunks/{directoryCompletion-Bgi8DBT5.js → directoryCompletion-BHyjyKAM.js} +1 -1
  81. package/dist/chunks/doctor-DeBG5SL5.js +1 -0
  82. package/dist/chunks/{entry-D1iD76SW.js → entry-CbhyIWgj.js} +5 -5
  83. package/dist/chunks/envUtils-DZ_SvEVz.js +1 -0
  84. package/dist/chunks/execFileNoThrow-BfZFnCGa.js +1 -0
  85. package/dist/chunks/execa-CBhG1doD.js +34 -0
  86. package/dist/chunks/exit-OKEV_ddw.js +1 -0
  87. package/dist/chunks/{extraUsage-BtHE-SBX.js → extraUsage-BlRL3yeb.js} +1 -1
  88. package/dist/chunks/extractMemories-jnsv-_n_.js +1 -0
  89. package/dist/chunks/fast-4I_qPJCd.js +1 -0
  90. package/dist/chunks/fast-DiolM1M7.js +1 -0
  91. package/dist/chunks/{fetchModelList-Cjow_QGy.js → fetchModelList-BRFTQim4.js} +1 -1
  92. package/dist/chunks/fetchModelList-qPKAuu4m.js +1 -0
  93. package/dist/chunks/{fileSuggestions-C96V9-Ne.js → fileSuggestions-iWVXvvLB.js} +3 -3
  94. package/dist/chunks/{fpsMetrics-wxj9GAsd.js → fpsMetrics-Ixd0J4CH.js} +1 -1
  95. package/dist/chunks/{gemini-4YGElN3H.js → gemini-BfVyavwQ.js} +2 -2
  96. package/dist/chunks/{generateSessionName-BHIKyXpz.js → generateSessionName-CGaTTXCA.js} +1 -1
  97. package/dist/chunks/genericProcessUtils-CVtQOTO2.js +12 -0
  98. package/dist/chunks/{goal-ePK_jLo3.js → goal-BidR-GFa.js} +1 -1
  99. package/dist/chunks/grok-DLcuI-U7.js +1 -0
  100. package/dist/chunks/{help-B7xRle-V.js → help-CZuvYhXj.js} +1 -1
  101. package/dist/chunks/history-BxPGftQw.js +1 -0
  102. package/dist/chunks/hooks-Bg9WIjZQ.js +1 -0
  103. package/dist/chunks/{hooks-BN5f58HY.js → hooks-ehqfAM5F.js} +2 -2
  104. package/dist/chunks/install-ACGY0vhM.js +1 -0
  105. package/dist/chunks/{instrumentation-Oj5xagJG.js → instrumentation-B9bfF2mA.js} +5 -5
  106. package/dist/chunks/{job-D9ypO0cd.js → job-Coztdn6A.js} +1 -1
  107. package/dist/chunks/keybindings-DwSdLpaE.js +1 -0
  108. package/dist/chunks/{launchLocalMemory-DliLezJw.js → launchLocalMemory-DRzfpIOB.js} +1 -1
  109. package/dist/chunks/{launchOnboarding-A-kk-7ID.js → launchOnboarding-D2zFCJf-.js} +1 -1
  110. package/dist/chunks/{loadAgentsDir-DGozQu_6.js → loadAgentsDir-DR5PVAc3.js} +557 -561
  111. package/dist/chunks/loadAgentsDir-DqAbnpB-.js +1 -0
  112. package/dist/chunks/{loadPluginHooks-BiHPKDaY.js → loadPluginHooks-BiQgGfUJ.js} +1 -1
  113. package/dist/chunks/{loader-CtoR-vO-.js → loader-6MqzNGmV.js} +1 -1
  114. package/dist/chunks/{localSearch-BU02Qsv9.js → localSearch-CzkxDuOR.js} +1 -1
  115. package/dist/chunks/localSearch-DW3JT2MA.js +1 -0
  116. package/dist/chunks/lockfile-D_9vif6E.js +1 -0
  117. package/dist/chunks/{log-DoSpAwRP.js → log-DWZny1vM.js} +1 -1
  118. package/dist/chunks/{logoUtils-DLd6JKqW.js → logoUtils-DR5T0pr3.js} +1 -1
  119. package/dist/chunks/{magicDocs-Bj8LYrN2.js → magicDocs-BwBxjfLo.js} +2 -2
  120. package/dist/chunks/main-Ryi27wYq.js +345 -0
  121. package/dist/chunks/managedEnv-DCEJh3z3.js +1 -0
  122. package/dist/chunks/managedEnv-Do9fgLpk.js +1 -0
  123. package/dist/chunks/managedEnvConstants-CWcT7nYr.js +1 -0
  124. package/dist/chunks/mcp-BCpnF6wD.js +1 -0
  125. package/dist/chunks/mcp-CJ6SDJEK.js +6 -0
  126. package/dist/chunks/mcp-CZBTxbhu.js +2 -0
  127. package/dist/chunks/memory-BQO6Y0ak.js +1 -0
  128. package/dist/chunks/{modalContext-DDZdU1J8.js → modalContext-CBE8xuck.js} +1 -1
  129. package/dist/chunks/{mode-CBKawxnD.js → mode-wq70cR44.js} +1 -1
  130. package/dist/chunks/model-D42epddJ.js +1 -0
  131. package/dist/chunks/{model-DwbqvCY2.js → model-DVk9-2dk.js} +1 -1
  132. package/dist/chunks/{modelOptions-CXBfKFXA.js → modelOptions-beLgXORr.js} +1 -1
  133. package/dist/chunks/nativeInstaller-ChGSz1lb.js +1 -0
  134. package/dist/chunks/{notifications-ql0eSo0Y.js → notifications-dGBuNvFj.js} +1 -1
  135. package/dist/chunks/{onChangeAppState-D85b33R5.js → onChangeAppState-B4K-rSaF.js} +1 -1
  136. package/dist/chunks/openai-DAwnAV9K.js +2 -0
  137. package/dist/chunks/{overlayContext-CLjlCFBl.js → overlayContext-B6i_6y_0.js} +1 -1
  138. package/dist/chunks/{panel-DMZkOEiU.js → panel-C0CF3noE.js} +1 -1
  139. package/dist/chunks/parser-BZt0VFd_.js +1 -0
  140. package/dist/chunks/{parser-UqADrvxF.js → parser-DThLwgdM.js} +1 -1
  141. package/dist/chunks/{partition-CwxTlmMd.js → partition-BRQHofxD.js} +1 -1
  142. package/dist/chunks/{pasteStore-ovtxMVR5.js → pasteStore-BmehVo5j.js} +1 -1
  143. package/dist/chunks/{permissions-CgsvWOk_.js → permissions-DkfWKN-B.js} +3 -3
  144. package/dist/chunks/pidLock-YvAaIrIY.js +3 -0
  145. package/dist/chunks/plan-B6U3ioer.js +1 -0
  146. package/dist/chunks/{platform-DsMIk3eq.js → platform-Vl9IynC3.js} +1 -1
  147. package/dist/chunks/plugin-CTA2_-F7.js +17 -0
  148. package/dist/chunks/{pluginAutoupdate-DQqYDPVg.js → pluginAutoupdate-Dy5W3HWE.js} +1 -1
  149. package/dist/chunks/{pluginBlocklist-BAr9WTup.js → pluginBlocklist-DAoUENwc.js} +1 -1
  150. package/dist/chunks/pluginCliCommands-CaHnj0C_.js +1 -0
  151. package/dist/chunks/{pluginFlagging-BO_3qjfs.js → pluginFlagging-BCj9LJP3.js} +1 -1
  152. package/dist/chunks/pluginOperations-ClXNOOG6.js +2 -0
  153. package/dist/chunks/pluginStartupCheck-CiwMKGjx.js +1 -0
  154. package/dist/chunks/{pluginStartupCheck-BX6cv-vs.js → pluginStartupCheck-U8_xk25t.js} +1 -1
  155. package/dist/chunks/{plugins-9crasx2V.js → plugins-D7zyI9c4.js} +4 -4
  156. package/dist/chunks/{poller-CpLBoB-N.js → poller-BeyVwHAf.js} +1 -1
  157. package/dist/chunks/poorMode-DtzWNhsY.js +1 -0
  158. package/dist/chunks/poorMode-Ocff_UT1.js +1 -0
  159. package/dist/chunks/print-BzljdXem.js +13 -0
  160. package/dist/chunks/processBashCommand-RUkmyAl4.js +1 -0
  161. package/dist/chunks/processSlashCommand-DRLO-jNV.js +5 -0
  162. package/dist/chunks/{projectContext-5fmRr6Sd.js → projectContext-COeHKDrk.js} +1 -1
  163. package/dist/chunks/{projectContext-DhtjLv3k.js → projectContext-QN5U3Ggr.js} +1 -1
  164. package/dist/chunks/{projectOnboardingState--L3BKjOE.js → projectOnboardingState-KqcpRXls.js} +1 -1
  165. package/dist/chunks/{prompt-DzO1um1h.js → prompt-CTByhpUI.js} +20 -20
  166. package/dist/chunks/prompt-DTpfW6yP.js +1 -0
  167. package/dist/chunks/prompt-D__eHY_5.js +1 -0
  168. package/dist/chunks/promptEditor-CpUFgGzc.js +4 -0
  169. package/dist/chunks/{protocolHandler-BWgH1jaF.js → protocolHandler-BQSLVGnG.js} +2 -2
  170. package/dist/chunks/{proxy-BjkGlmBu.js → proxy-BtWuysHM.js} +2 -2
  171. package/dist/chunks/{reconciler-CVMmAaCy.js → reconciler-D6BUq8WB.js} +1 -1
  172. package/dist/chunks/refresh-B4pqFp12.js +1 -0
  173. package/dist/chunks/reject-C6IvUvBt.js +1 -0
  174. package/dist/chunks/{reload-plugins-DeyJTx4s.js → reload-plugins-DXQqk7q6.js} +1 -1
  175. package/dist/chunks/rename-D4XBmTBI.js +1 -0
  176. package/dist/chunks/{renderOptions-DRS2EslG.js → renderOptions-DkP98P_d.js} +1 -1
  177. package/dist/chunks/{resume-N4O5YI-S.js → resume-DzIev0JI.js} +2 -2
  178. package/dist/chunks/ripgrep-CYP26Fhg.js +1 -0
  179. package/dist/chunks/ripgrep-D1f1pbCz.js +5 -0
  180. package/dist/chunks/{runtimeObserver-DMSzdFWt.js → runtimeObserver-BPqlbu0B.js} +4 -4
  181. package/dist/chunks/{runtimeObserver-C0CJvA3q.js → runtimeObserver-BUHs3qjs.js} +1 -1
  182. package/dist/chunks/sandbox-adapter-CumL75tU.js +1 -0
  183. package/dist/chunks/{sandbox-toggle-Tbbaw18C.js → sandbox-toggle-CTtET6Xq.js} +1 -1
  184. package/dist/chunks/searchExtraTools-BMCU2zEf.js +1 -0
  185. package/dist/chunks/{select-Fq6g2Ejk.js → select-FrwoTzuc.js} +1 -1
  186. package/dist/chunks/sessionFileAccessHooks-WO8WTdT9.js +1 -0
  187. package/dist/chunks/{sessionObserver-CRie77tp.js → sessionObserver-B6xzxckA.js} +2 -2
  188. package/dist/chunks/sessionObserver-CBrM4opL.js +1 -0
  189. package/dist/chunks/sessionStorage-C1EAxDWG.js +1 -0
  190. package/dist/chunks/sessionTracing-UFK96PxT.js +11 -0
  191. package/dist/chunks/settings-BK6gCko-.js +1 -0
  192. package/dist/chunks/settings-YIDksG5Z.js +24 -0
  193. package/dist/chunks/setup-BBvZyrfz.js +3 -0
  194. package/dist/chunks/{shadowedRuleDetection-CTnYVrmP.js → shadowedRuleDetection-D6R2OeoH.js} +1 -1
  195. package/dist/chunks/{sideQuestion-Cl8m2qYx.js → sideQuestion-5jcbOMsR.js} +3 -3
  196. package/dist/chunks/{sinks-CiupmfTg.js → sinks-B-kFqjjd.js} +1 -1
  197. package/dist/chunks/sinks-DB_D4lmu.js +1 -0
  198. package/dist/chunks/skillChangeDetector-103-nEle.js +1 -0
  199. package/dist/chunks/{skillGapStore-es3K-aYe.js → skillGapStore-DOz1KCqo.js} +2 -2
  200. package/dist/chunks/{skillLifecycle-BcgoOQBk.js → skillLifecycle-D9NkIwFQ.js} +2 -2
  201. package/dist/chunks/{skillSearchPanel-CuDDb1L-.js → skillSearchPanel-DFiSZaJ4.js} +2 -2
  202. package/dist/chunks/skills-DgeLr52a.js +1 -0
  203. package/dist/chunks/sleep-BbWr_FL1.js +1 -0
  204. package/dist/chunks/{src-9vmGsuSI.js → src-Cy5_qH26.js} +1 -1
  205. package/dist/chunks/{src-DL3w8VPk.js → src-WZ94ZKI3.js} +4 -4
  206. package/dist/chunks/{startupProfiler-DF0AjiDf.js → startupProfiler-DIM_Ihyp.js} +2 -2
  207. package/dist/chunks/startupProfiler-FpGsKWYk.js +1 -0
  208. package/dist/chunks/{state-BQ4BEGin.js → state-CXY-q5gr.js} +1 -1
  209. package/dist/chunks/state-DXt6rahM.js +1 -0
  210. package/dist/chunks/{staticRender-BVWx0IM1.js → staticRender-RHUIg5ln.js} +1 -1
  211. package/dist/chunks/status-CKLecQZV.js +1 -0
  212. package/dist/chunks/{statusNoticeHelpers-BfmIub5L.js → statusNoticeHelpers-DI45AH-c.js} +1 -1
  213. package/dist/chunks/stringUtils-D_xPrwGQ.js +4 -0
  214. package/dist/chunks/switcher-D2Z2ZNQ0.js +1 -0
  215. package/dist/chunks/switcher-DhZCaAun.js +1 -0
  216. package/dist/chunks/{tasks-B6gYXxOx.js → tasks-6suPhqsK.js} +1 -1
  217. package/dist/chunks/{templateJobs-BW6TaqEC.js → templateJobs-BKVEWCsb.js} +1 -1
  218. package/dist/chunks/{terminalSetup-C-g9Xvj3.js → terminalSetup-7PUR4hfo.js} +1 -1
  219. package/dist/chunks/{terminalSetup-BgIXFBpd.js → terminalSetup-Cqy5_PhJ.js} +4 -4
  220. package/dist/chunks/{theme-9AZceq_m.js → theme-B-HG2PUs.js} +1 -1
  221. package/dist/chunks/tipRegistry-BR_lSGRw.js +2 -0
  222. package/dist/chunks/{toolEventObserver-DTuJcREC.js → toolEventObserver-BY3QVnr6.js} +1 -1
  223. package/dist/chunks/toolPool-BcwIF8Q_.js +1 -0
  224. package/dist/chunks/{types-97nL3naE.js → types-CD25a50S.js} +1 -1
  225. package/dist/chunks/udsClient-CCxgLiZy.js +1 -0
  226. package/dist/chunks/urlHandler-BNsQKqba.js +1 -0
  227. package/dist/chunks/{use-select-navigation-BStVRvcX.js → use-select-navigation-CW5alA9r.js} +1 -1
  228. package/dist/chunks/{useDoublePress-C9xxQzh1.js → useDoublePress-DQBLKyzJ.js} +1 -1
  229. package/dist/chunks/{useExitOnCtrlCDWithKeybindings-DWRFdFoU.js → useExitOnCtrlCDWithKeybindings-BgJrnuDl.js} +1 -1
  230. package/dist/chunks/useMainLoopModel-BVgJo4hN.js +1 -0
  231. package/dist/chunks/useManagePlugins-CrWjzESW.js +1 -0
  232. package/dist/chunks/useMergedTools-r6GQq5mI.js +1 -0
  233. package/dist/chunks/{useSearchInput-B_mY9wBq.js → useSearchInput-BITV_Txn.js} +1 -1
  234. package/dist/chunks/{useSettingsErrors-CM7tThcp.js → useSettingsErrors-CO0fTNzn.js} +1 -1
  235. package/dist/chunks/{util-Bb2S6g9N.js → util-_zo3I1y8.js} +1 -1
  236. package/dist/chunks/validatePlugin-DFGdRhA-.js +1 -0
  237. package/dist/chunks/{vim-Dpnhgoz_.js → vim-qgMS88ss.js} +1 -1
  238. package/dist/chunks/worktree-CR_M6Qfy.js +1 -0
  239. package/dist/cli.js +1 -1
  240. package/package.json +1 -1
  241. package/scripts/postinstall.cjs +16 -16
  242. package/dist/chunks/AgentsMdExternalIncludesDialog-Bnb1jWcg.js +0 -1
  243. package/dist/chunks/App-B8q8PV77.js +0 -1
  244. package/dist/chunks/BackgroundTasksDialog-i0TkZgQp.js +0 -2
  245. package/dist/chunks/CustomSelect-BvTftqEH.js +0 -1
  246. package/dist/chunks/DiffDialog-v5r8cBKW.js +0 -6
  247. package/dist/chunks/Doctor-DKpBnbuI.js +0 -1
  248. package/dist/chunks/Doctor-uvO6NM5m.js +0 -3
  249. package/dist/chunks/KeybindingProviderSetup-DsJqfEt-.js +0 -1
  250. package/dist/chunks/MCPConnectionManager-DkZVxLEj.js +0 -1
  251. package/dist/chunks/MCPToolListView-De1W4jpj.js +0 -1
  252. package/dist/chunks/MessageSelector-DW_itlX-.js +0 -3
  253. package/dist/chunks/Messages-BFsCpACq.js +0 -10
  254. package/dist/chunks/PromptInputHelpMenu-Bm5KY0Ma.js +0 -1
  255. package/dist/chunks/QueryEngine-egz5mbaW.js +0 -1
  256. package/dist/chunks/REPL-D27CE4WN.js +0 -124
  257. package/dist/chunks/REPL-e8wAT1wN.js +0 -1
  258. package/dist/chunks/ResumeConversation-CWA27Lke.js +0 -1
  259. package/dist/chunks/SearchExtraToolsTool-BRchtZ9Q.js +0 -1
  260. package/dist/chunks/Settings-axHLvYIy.js +0 -3
  261. package/dist/chunks/Spinner-VjwI7m_g.js +0 -1
  262. package/dist/chunks/ThemePicker-CtQYHmOr.js +0 -1
  263. package/dist/chunks/agents-DEnmg8Xo.js +0 -101
  264. package/dist/chunks/allErrors-C9kx6lnk.js +0 -1
  265. package/dist/chunks/appleTerminalBackup-CT7g8yOs.js +0 -1
  266. package/dist/chunks/backgroundHousekeeping-CvWfd99M.js +0 -1
  267. package/dist/chunks/caches-DWjwe-DN.js +0 -1
  268. package/dist/chunks/caches-VLs1tQkZ.js +0 -1
  269. package/dist/chunks/client-CO_6v4yl.js +0 -1
  270. package/dist/chunks/client-DO-O441l.js +0 -1
  271. package/dist/chunks/commands-Cn1P7Tms.js +0 -1
  272. package/dist/chunks/compact-DGUhdXcc.js +0 -2
  273. package/dist/chunks/config-C7GTF4iI.js +0 -1
  274. package/dist/chunks/config-CWPHVTic.js +0 -3
  275. package/dist/chunks/config-Cox0TM2Z.js +0 -1
  276. package/dist/chunks/context-noninteractive--OuiZUzL.js +0 -1
  277. package/dist/chunks/conversation--y8PD2Lk.js +0 -1
  278. package/dist/chunks/conversation-BIPJEOwO.js +0 -1
  279. package/dist/chunks/conversationRecovery-BBJzrA0g.js +0 -1
  280. package/dist/chunks/crossProjectResume-CwZb3cEU.js +0 -40
  281. package/dist/chunks/cwd-BZMp3CZ8.js +0 -1
  282. package/dist/chunks/doctor-4NiE46ZG.js +0 -1
  283. package/dist/chunks/envUtils-DfkgIdYf.js +0 -1
  284. package/dist/chunks/execFileNoThrow-BgRsj_SW.js +0 -34
  285. package/dist/chunks/exit-CrsQsjbx.js +0 -1
  286. package/dist/chunks/extractMemories-kogJzpit.js +0 -1
  287. package/dist/chunks/fast-CuNVwVTr.js +0 -1
  288. package/dist/chunks/fast-RlFnwGRV.js +0 -1
  289. package/dist/chunks/fetchModelList-uiCPVqbJ.js +0 -1
  290. package/dist/chunks/genericProcessUtils-BNlr-QxM.js +0 -23
  291. package/dist/chunks/grok-DnmklTrm.js +0 -1
  292. package/dist/chunks/history-kOw3CcLT.js +0 -1
  293. package/dist/chunks/hooks-BDY1jMbS.js +0 -1
  294. package/dist/chunks/install-DrMiHa2Q.js +0 -1
  295. package/dist/chunks/keybindings-BRRN_eap.js +0 -1
  296. package/dist/chunks/loadAgentsDir-CJAK4kif.js +0 -1
  297. package/dist/chunks/localSearch-DyaB2Rm-.js +0 -1
  298. package/dist/chunks/main-B_09WbaG.js +0 -345
  299. package/dist/chunks/managedEnv-BJGfe3m7.js +0 -1
  300. package/dist/chunks/managedEnv-CIWJsuty.js +0 -1
  301. package/dist/chunks/managedEnvConstants-BPwL2aWI.js +0 -1
  302. package/dist/chunks/mcp-1nBvcNxw.js +0 -1
  303. package/dist/chunks/mcp-7DXpXMdT.js +0 -2
  304. package/dist/chunks/mcp-kw99WVi2.js +0 -6
  305. package/dist/chunks/memory-CjWvzR_9.js +0 -1
  306. package/dist/chunks/model-DpZaKZMb.js +0 -1
  307. package/dist/chunks/nativeInstaller-SmPeEisk.js +0 -1
  308. package/dist/chunks/openai-D_j7-KW6.js +0 -2
  309. package/dist/chunks/parser-2usBI4G-.js +0 -1
  310. package/dist/chunks/pidLock-B-SW3Nhx.js +0 -3
  311. package/dist/chunks/plan-BJrWtXEh.js +0 -1
  312. package/dist/chunks/plugin-D97VJAxW.js +0 -17
  313. package/dist/chunks/pluginCliCommands-CUGPc853.js +0 -1
  314. package/dist/chunks/pluginOperations-rTrzu6Vg.js +0 -2
  315. package/dist/chunks/pluginStartupCheck-BRHnXlym.js +0 -1
  316. package/dist/chunks/poorMode-BaS0DBUO.js +0 -1
  317. package/dist/chunks/poorMode-DmvzFAz_.js +0 -1
  318. package/dist/chunks/print-Bi3xVdB3.js +0 -13
  319. package/dist/chunks/processBashCommand-BBtnCx-7.js +0 -1
  320. package/dist/chunks/processSlashCommand-jzF0GmLO.js +0 -5
  321. package/dist/chunks/prompt-CmijKW7G.js +0 -1
  322. package/dist/chunks/prompt-DYBx_D0H.js +0 -1
  323. package/dist/chunks/promptEditor-B6S_Rzcu.js +0 -4
  324. package/dist/chunks/refresh-CAGv8BJY.js +0 -1
  325. package/dist/chunks/reject-CEUkoI2G.js +0 -1
  326. package/dist/chunks/rename-DPFis9g_.js +0 -1
  327. package/dist/chunks/ripgrep-3omwGI-l.js +0 -1
  328. package/dist/chunks/ripgrep-CgQrN3XX.js +0 -5
  329. package/dist/chunks/sandbox-adapter-D15jjHJR.js +0 -1
  330. package/dist/chunks/searchExtraTools-BoFc__Eg.js +0 -1
  331. package/dist/chunks/sessionFileAccessHooks-Rgsp4_Ex.js +0 -1
  332. package/dist/chunks/sessionObserver-PcaVCVkX.js +0 -1
  333. package/dist/chunks/sessionStorage-Dkf7FRgA.js +0 -1
  334. package/dist/chunks/sessionTracing-D7rekMdW.js +0 -11
  335. package/dist/chunks/settings-8fwIkMDV.js +0 -1
  336. package/dist/chunks/settings-CodSADx8.js +0 -24
  337. package/dist/chunks/setup-DBiIrXrh.js +0 -3
  338. package/dist/chunks/sinks-DH83d_kd.js +0 -1
  339. package/dist/chunks/skillChangeDetector-BrrZaFkT.js +0 -1
  340. package/dist/chunks/skills-BRtgqnLz.js +0 -1
  341. package/dist/chunks/startupProfiler-D1NRu2nj.js +0 -1
  342. package/dist/chunks/state-D3gvDiu8.js +0 -1
  343. package/dist/chunks/status-WXA16wIM.js +0 -1
  344. package/dist/chunks/stringUtils-Bu_lJH5c.js +0 -4
  345. package/dist/chunks/switcher-5gilU5_R.js +0 -1
  346. package/dist/chunks/switcher-DMfuKuw_.js +0 -1
  347. package/dist/chunks/tipRegistry-DtO1H_Wo.js +0 -2
  348. package/dist/chunks/toolPool-DHS8jWaL.js +0 -1
  349. package/dist/chunks/udsClient-CmYHFiBD.js +0 -1
  350. package/dist/chunks/urlHandler-DLz3FZm1.js +0 -1
  351. package/dist/chunks/useMainLoopModel-DSN5HjV1.js +0 -1
  352. package/dist/chunks/useManagePlugins-ntnOf5OU.js +0 -1
  353. package/dist/chunks/useMergedTools-C5Yns9Ij.js +0 -1
  354. package/dist/chunks/validatePlugin-D8WQ5z4W.js +0 -1
  355. package/dist/chunks/worktree-a5oOPSYl.js +0 -1
@@ -0,0 +1,40 @@
1
+ import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{C as n,D as r,Gr as i,H as a,I as o,P as s,T as c,Wt as l,Xn as u,ai as d,di as f,fi as p,hn as m,k as ee,oi as te,ot as ne,p as h,t as g}from"./src-WZ94ZKI3.js";import{t as _}from"./jsx-runtime-Bb4Xn-E0.js";import{Pt as v,at as re,q as ie}from"./state-CXY-q5gr.js";import{Dc as y,Or as ae,Tb as b,Tc as oe,bi as x,br as S,ei as se,gr as ce,hd as le,lr as C,md as w,sb as ue,tb as T,tr as de,vS as fe,vr as pe,wb as me,yS as he,yi as ge}from"./loadAgentsDir-DR5PVAc3.js";import{S as E,c as D,i as O,x as _e}from"./debug-kBjDaVkQ.js";import{Bn as ve,Dr as ye,Pr as be,zn as k}from"./settings-YIDksG5Z.js";import{a as A,o as xe,s as Se}from"./log-DWZny1vM.js";import{n as Ce}from"./analytics-COpjZpvd.js";import{S as we,_ as j,d as Te,p as Ee}from"./startupProfiler-DIM_Ihyp.js";import{f as De,u as Oe}from"./model-D42epddJ.js";import{n as M,t as ke}from"./TextInput-BboKIug2.js";import{n as Ae,t as N}from"./useExitOnCtrlCDWithKeybindings-BgJrnuDl.js";import{n as je,t as Me}from"./select-FrwoTzuc.js";import{r as Ne,t as Pe}from"./Spinner-DhhSOFcN.js";import{l as Fe,u as Ie}from"./SpinnerGlyph-CmVXC-_9.js";import{t as Le}from"./SearchBox-DQBLKyzJ.js";import{n as Re,t as ze}from"./useSearchInput-BITV_Txn.js";import{n as P,t as F}from"./Messages-CxMsfjOa.js";function Be({log:e,onExit:t,onSelect:n}){let[i,a]=I.useState(null);I.useEffect(()=>{a(null),S(e)&&ae(e).then(a)},[e]);let u=S(e)&&i===null,d=i??e,f=C(d)||``,p=oe();return l(`confirm:no`,t,{context:`Confirmation`}),l(`confirm:yes`,(0,I.useCallback)(()=>{n(i??e)},[n,i,e]),{context:`Confirmation`}),u?(0,L.jsxs)(o,{flexDirection:`column`,padding:1,children:[(0,L.jsx)(h,{message:`Loading session…`}),(0,L.jsx)(s,{dimColor:!0,children:(0,L.jsx)(c,{children:(0,L.jsx)(w,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})})})]}):(0,L.jsxs)(o,{flexDirection:`column`,children:[(0,L.jsx)(F,{messages:d.messages,tools:p,commands:[],verbose:!0,toolJSX:null,toolUseConfirmQueue:[],inProgressToolUseIDs:new Set,isMessageSelectorVisible:!1,conversationId:f,screen:`transcript`,streamingToolUses:[],showAllInTranscript:!0,isLoading:!1}),(0,L.jsxs)(o,{flexShrink:0,flexDirection:`column`,borderTopDimColor:!0,borderBottom:!1,borderLeft:!1,borderRight:!1,borderStyle:`single`,paddingLeft:2,children:[(0,L.jsxs)(s,{children:[Ee(d.modified),` · `,d.messageCount,` messages`,d.gitBranch?` · ${d.gitBranch}`:``]}),(0,L.jsx)(s,{dimColor:!0,children:(0,L.jsxs)(c,{children:[(0,L.jsx)(r,{shortcut:`Enter`,action:`resume`}),(0,L.jsx)(w,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]})})]})]})}var I,L,Ve=e((()=>{I=t(d(),1),g(),T(),y(),j(),ce(),le(),P(),L=_()}));function R(e,t){if(e===B)return 5;let n=i(e),r=t?Math.min(n,t-V-H):n;return Math.max(0,r)+V+H}function He(e,t){let n=t-V-H;return i(e)<=n?e:n<=1?e.charAt(0):we(e,n)}function Ue({tabs:e,selectedIndex:t,availableWidth:n,showAllProjects:r=!1}){let i=r?`Resume (All Projects)`:`Resume`,a=i.length+1,c=Math.max(Je,W),l=n-a-c-2,u=Math.max(0,Math.min(t,e.length-1)),d=Math.max(20,Math.floor(l/2)),f=e.map(e=>R(e,d)),p=0,m=e.length;if(f.reduce((e,t,n)=>e+t+ +(n<f.length-1),0)>l){let t=l-qe,n=f[u]??0;for(p=u,m=u+1;p>0||m<e.length;){let r=p>0,i=m<e.length;if(r){let e=(f[p-1]??0)+1;if(n+e<=t){p--,n+=e;continue}}if(i){let e=(f[m]??0)+1;if(n+e<=t){m++,n+=e;continue}}break}}let ee=p,te=e.length-m,ne=e.slice(p,m),h=ne.map((e,t)=>p+t);return(0,z.jsxs)(o,{flexDirection:`row`,gap:1,children:[(0,z.jsx)(s,{color:`suggestion`,children:i}),ee>0&&(0,z.jsxs)(s,{dimColor:!0,children:[U,ee]}),ne.map((e,t)=>{let n=h[t]===u,r=e===B?e:`#${He(e,d-V)}`;return(0,z.jsxs)(s,{backgroundColor:n?`suggestion`:void 0,color:n?`inverseText`:void 0,bold:n,children:[` `,r,` `]},e)}),te>0?(0,z.jsxs)(s,{dimColor:!0,children:[We,te,Ge]}):(0,z.jsx)(s,{dimColor:!0,children:Ke})]})}var z,B,V,H,U,We,Ge,Ke,qe,Je,W,G=e((()=>{g(),j(),z=_(),B=`All`,V=2,H=1,U=`← `,We=`→`,Ge=` (tab to cycle)`,Ke=`(tab to cycle)`,qe=5,Je=18,W=14}));function Ye({nodes:e,onSelect:t,onCancel:n,onFocus:r,focusNodeId:i,visibleOptionCount:a,layout:s=`expanded`,isDisabled:c=!1,hideIndexes:l=!1,isNodeExpanded:u,onExpand:d,onCollapse:f,getParentPrefix:p,getChildPrefix:m,onUpFromFirstItem:ee}){let[te,ne]=K.useState(new Set),h=K.useRef(!1),g=K.useRef(null),_=K.useCallback(e=>u?u(e):te.has(e),[u,te]),v=K.useMemo(()=>{let t=[];function n(e,r,i){let a=!!e.children&&e.children.length>0,o=_(e.id);if(t.push({node:e,depth:r,isExpanded:o,hasChildren:a,parentId:i}),a&&o&&e.children)for(let t of e.children)n(t,r+1,e.id)}for(let t of e)n(t,0);return t},[e,_]),re=K.useCallback(e=>e?`▼ `:`▶ `,[]),ie=K.useCallback(e=>` ▸ `,[]),y=p??re,ae=m??ie,b=K.useCallback(e=>{let t=``;return e.hasChildren?t=y(e.isExpanded):e.depth>0&&(t=ae(e.depth)),t+e.node.label},[y,ae]),oe=K.useMemo(()=>v.map(e=>({label:b(e),description:e.node.description,dimDescription:e.node.dimDescription??!0,value:e.node.id})),[v,b]),x=K.useMemo(()=>{let e=new Map;return v.forEach(t=>e.set(t.node.id,t.node)),e},[v]),S=K.useCallback(e=>v.find(t=>t.node.id===e),[v]),se=K.useCallback((e,t)=>{S(e)?.hasChildren&&(t?d?d(e):ne(t=>new Set(t).add(e)):f?f(e):ne(t=>{let n=new Set(t);return n.delete(e),n}))},[S,d,f]);return(0,Xe.jsx)(o,{tabIndex:0,autoFocus:!0,onKeyDown:e=>{if(!i||c)return;let t=S(i);if(t){if(e.key===`right`&&t.hasChildren)e.preventDefault(),se(i,!0);else if(e.key===`left`){if(t.hasChildren&&t.isExpanded)e.preventDefault(),se(i,!1);else if(t.parentId!==void 0&&(e.preventDefault(),h.current=!0,se(t.parentId,!1),r)){let e=x.get(t.parentId);e&&r(e)}}}},children:(0,Xe.jsx)(Me,{options:oe,onChange:K.useCallback(e=>{let n=x.get(e);n&&t(n)},[x,t]),onFocus:K.useCallback(e=>{if(h.current){h.current=!1;return}if(g.current!==e&&(g.current=e,r)){let t=x.get(e);t&&r(t)}},[r,x]),onCancel:n,defaultFocusValue:i,visibleOptionCount:a,layout:s,isDisabled:c,hideIndexes:l,onUpFromFirstItem:ee})})}var K,Xe,Ze=e((()=>{K=t(d(),1),g(),je(),Xe=_()}));function Qe(e,t){return we(e.replace(/\s+/g,` `).trim(),t)}function $e({before:e,match:t,after:n},r){return f.dim(e)+r(t)+f.dim(n)}function et(e,t,n){let r=e.toLowerCase().indexOf(t.toLowerCase());if(r===-1)return null;let i=r+t.length,a=Math.max(0,r-n),o=Math.min(e.length,i+n),s=e.slice(a,r),c=e.slice(r,i),l=e.slice(i,o);return{before:(a>0?`…`:``)+s.replace(/\s+/g,` `).trimStart(),match:c.trim(),after:l.replace(/\s+/g,` `).trimEnd()+(o<e.length?`…`:``)}}function tt(e,t,n){let{isGroupHeader:r=!1,isChild:i=!1,forkCount:a=0}=n||{},o=r&&a>0?ct:i?lt:0,s=r&&a>0?` (+${a} other ${a===1?`session`:`sessions`})`:``,c=e.isSidechain?` (sidechain)`:``,l=t-o-c.length-s.length;return`${Qe(A(e),l)}${c}${s}`}function nt(e,t){let{isChild:n=!1,showProjectPath:r=!1}=t||{},i=n?` `:``,a=Te(e),o=r&&e.projectPath?` · ${e.projectPath}`:``;return i+a+o}function rt({logs:e,maxHeight:t=1/0,forceWidth:i,onCancel:d,onSelect:f,onLogsChanged:p,onLoadMore:h,initialSearchQuery:g,showAllProjects:_=!1,onToggleAllProjects:v,onAgenticSearch:y}){let ae=ne(),b=i===void 0?ae.columns:i,oe=Ae(d),x=u(),S=pe(),[ce]=a(),le=Fe(ce),ue=q.useMemo(()=>e=>te(e,le.warning),[le.warning]),[T,fe]=q.useState(null),[me,he]=q.useState(!1),[E,D]=q.useState(!1),[O,_e]=q.useState(!1),ve=q.useMemo(()=>ie(),[]),[be,k]=q.useState(``),[xe,Se]=q.useState(0),[Ce,we]=q.useState(new Set),[j,Ee]=q.useState(null),[De,Oe]=q.useState(1),[M,N]=q.useState(`list`),[je,Ne]=q.useState(null),Ie=q.useRef(null),[Le,ze]=q.useState(0),[P,F]=q.useState({status:`idle`}),[I,L]=q.useState(!1),Ve=q.useRef(null),{query:R,setQuery:He,cursorOffset:z}=Re({isActive:M===`search`&&P.status!==`searching`,onExit:()=>{N(`list`)},onExitUp:()=>{N(`list`)},passthroughCtrlKeys:[`n`],initialQuery:g||``}),B=q.useDeferredValue(R),[V,H]=q.useState(``);q.useEffect(()=>{if(!B){H(``);return}let e=setTimeout(H,300,B);return()=>clearTimeout(e)},[B]);let[U,We]=q.useState(null),[Ge,Ke]=q.useState(!1);q.useEffect(()=>{ye().then(e=>fe(e)),ge(ve).then(e=>{_e(e.length>1)})},[ve]);let qe=q.useMemo(()=>new Map(e.map(e=>[e,at(e)])),[e]),Je=q.useMemo(()=>null,[e,qe,!1]),W=q.useMemo(()=>st(e),[e]),G=W.length>0,K=q.useMemo(()=>G?[`All`,...W]:[],[G,W]),Xe=K.length>0&&Le<K.length?Le:0,Ze=K[Xe],rt=Ze===`All`?void 0:Ze,it=+!!G,ct=q.useMemo(()=>{let t=e;return S&&(t=e.filter(e=>{let t=re(),n=C(e);return!!(t&&n===t||e.customTitle||de(e.messages)||e.firstPrompt||e.customTitle)})),rt!==void 0&&(t=t.filter(e=>e.tag===rt)),me&&T&&(t=t.filter(e=>e.gitBranch===T)),O&&!E&&(t=t.filter(e=>e.projectPath===ve)),t},[e,S,rt,me,T,O,E,ve]),lt=q.useMemo(()=>{if(!R)return ct;let e=R.toLowerCase();return ct.filter(t=>{let n=A(t).toLowerCase(),r=(t.gitBranch||``).toLowerCase(),i=(t.tag||``).toLowerCase(),a=t.prNumber?`pr #${t.prNumber} ${t.prRepository||``}`.toLowerCase():``;return n.includes(e)||r.includes(e)||i.includes(e)||a.includes(e)})},[ct,R]);q.useEffect(()=>{},[B,V,!1]),q.useEffect(()=>{We(null),Ke(!1)},[V,Je,!1]);let{filteredLogs:ut,snippets:Y}=q.useMemo(()=>{let e=new Map,t=lt;if(U&&V&&U.query===V){for(let t of U.results)if(t.searchableText){let n=et(t.searchableText,V,dt);n&&e.set(t.log,n)}let n=new Set(t.map(e=>e.messages[0]?.uuid)),r=U.results.map(e=>e.log).filter(e=>!n.has(e.messages[0]?.uuid));t=[...t,...r]}return{filteredLogs:t,snippets:e}},[lt,U,V]),X=q.useMemo(()=>P.status===`results`&&P.results.length>0?P.results:ut,[P,ut]),Z=Math.max(30,b-4),ft=q.useMemo(()=>{if(!S)return[];let e=ot(X);return Array.from(e.entries()).map(([e,t])=>{let n=t[0],r=X.indexOf(n),i=Y.get(n),a=i?$e(i,ue):null;if(t.length===1){let t=nt(n,{showProjectPath:_});return{id:`log:${e}:0`,value:{log:n,indexInFiltered:r},label:tt(n,Z),description:a?`${t}\n ${a}`:t,dimDescription:!0}}let o=t.length-1,s=t.slice(1).map((t,n)=>{let r=X.indexOf(t),i=Y.get(t),a=i?$e(i,ue):null,o=nt(t,{isChild:!0,showProjectPath:_});return{id:`log:${e}:${n+1}`,value:{log:t,indexInFiltered:r},label:tt(t,Z,{isChild:!0}),description:a?`${o}\n ${a}`:o,dimDescription:!0}}),c=nt(n,{showProjectPath:_});return{id:`group:${e}`,value:{log:n,indexInFiltered:r},label:tt(n,Z,{isGroupHeader:!0,forkCount:o}),description:a?`${c}\n ${a}`:c,dimDescription:!0,children:s}})},[S,X,Z,_,Y,ue]),pt=q.useMemo(()=>S?[]:X.map((e,t)=>{let n=Qe(A(e)+(e.isSidechain?` (sidechain)`:``),Z),r=Te(e),i=_&&e.projectPath?` · ${e.projectPath}`:``,a=Y.get(e),o=a?$e(a,ue):null;return{label:n,description:o?`${r}${i}\n ${o}`:r+i,dimDescription:!0,value:t.toString()}}),[S,X,ue,Z,_,Y]),Q=j?.value.log??null,mt=()=>{if(!S||!Q)return``;let e=C(Q);if(!e)return``;let t=X.filter(t=>C(t)===e);if(!(t.length>1))return``;let n=Ce.has(e);return t.indexOf(Q)>0||n?`← to collapse`:`→ to expand`},ht=q.useCallback(async()=>{let e=Q?C(Q):void 0;if(!Q||!e){N(`list`),k(``);return}be.trim()&&(await se(e,be.trim(),Q.fullPath),S&&p&&p()),N(`list`),k(``)},[Q,be,p,S]),gt=q.useCallback(()=>{N(`list`)},[]),_t=q.useCallback(()=>{N(`search`)},[]),vt=q.useCallback(async()=>{if(!R.trim()||!y||!0)return;Ve.current?.abort();let t=new AbortController;Ve.current=t,F({status:`searching`}),R.length;try{let n=await y(R,e,t.signal);if(t.signal.aborted)return;F({status:`results`,results:n,query:R}),R.length,n.length}catch(e){if(t.signal.aborted)return;F({status:`error`,message:e instanceof Error?e.message:`Search failed`}),R.length}},[R,y,!1,e]);q.useEffect(()=>{P.status!==`idle`&&P.status!==`searching`&&(P.status===`results`&&P.query!==R||P.status===`error`)&&F({status:`idle`})},[R,P]),q.useEffect(()=>()=>{Ve.current?.abort()},[]);let yt=q.useRef(P.status);q.useEffect(()=>{let e=yt.current;if(yt.current=P.status,e===`searching`&&P.status===`results`){if(S&&ft.length>0)Ee(ft[0]);else if(!S&&X.length>0){let e=X[0];Ee({id:`0`,value:{log:e,indexInFiltered:0},label:``})}}},[P.status,S,ft,X]);let bt=q.useCallback(e=>{let t=parseInt(e,10),n=X[t];!n||Ie.current===t.toString()||(Ie.current=t.toString(),Ee({id:t.toString(),value:{log:n,indexInFiltered:t},label:``}),Oe(t+1))},[X]),xt=q.useCallback(e=>{Ee(e);let t=X.findIndex(t=>C(t)===C(e.value.log));t>=0&&Oe(t+1)},[X]);l(`confirm:no`,()=>{Ve.current?.abort(),F({status:`idle`})},{context:`Confirmation`,isActive:M!==`preview`&&P.status===`searching`}),l(`confirm:no`,()=>{N(`list`),k(``)},{context:`Settings`,isActive:M===`rename`&&P.status!==`searching`}),l(`confirm:no`,()=>{He(``),L(!1),d?.()},{context:`Confirmation`,isActive:M!==`preview`&&M!==`rename`&&M!==`search`&&I&&P.status!==`searching`}),m((e,t)=>{if(M!==`preview`&&P.status!==`searching`&&M!==`rename`)if(M===`search`)e.toLowerCase()===`n`&&t.ctrl?gt():(t.return||t.downArrow)&&R.trim();else{if(I){if(t.return){vt(),L(!1);return}else if(t.downArrow){L(!1);return}else if(t.upArrow){N(`search`),L(!1);return}}if(G&&t.tab){let e=t.shift?-1:1;ze(t=>{let n=((t<K.length?t:0)+K.length+e)%K.length;return K[n],W.length,n});return}let n=!t.ctrl&&!t.meta,r=e.toLowerCase();r===`a`&&t.ctrl&&v?v():r===`b`&&t.ctrl?he(!me):r===`w`&&t.ctrl&&O?D(!E):r===`/`&&n?N(`search`):r===`r`&&t.ctrl&&Q?(N(`rename`),k(``)):r===`v`&&t.ctrl&&Q?(Ne(Q),N(`preview`),Q.messageCount):Q&&n&&e.length>0&&!/^\s+$/.test(e)&&(N(`search`),He(e))}},{isActive:!0});let St=[];me&&T&&St.push(T),O&&!E&&St.push(`current worktree`);let Ct=8+ +(St.length>0&&M!==`search`)+it,$=Math.max(1,Math.floor((t-Ct-2)/3));return q.useEffect(()=>{if(!h)return;let e=$*2;De+e>=X.length&&h($*3)},[De,$,X.length,h]),e.length===0?null:M===`preview`&&je&&S?(0,J.jsx)(Be,{log:je,onExit:()=>{N(`list`),Ne(null)},onSelect:f}):(0,J.jsxs)(o,{flexDirection:`column`,height:t-1,children:[(0,J.jsx)(o,{flexShrink:0,children:(0,J.jsx)(n,{color:`suggestion`})}),(0,J.jsx)(o,{flexShrink:0,children:(0,J.jsx)(s,{children:` `})}),G?(0,J.jsx)(Ue,{tabs:K,selectedIndex:Xe,availableWidth:b,showAllProjects:_}):(0,J.jsx)(o,{flexShrink:0,children:(0,J.jsxs)(s,{bold:!0,color:`suggestion`,children:[`Resume Session`,M===`list`&&X.length>$&&(0,J.jsxs)(s,{dimColor:!0,children:[` `,`(`,De,` of `,X.length,`)`]})]})}),(0,J.jsx)(ee,{query:R,isFocused:M===`search`,isTerminalFocused:x,cursorOffset:z}),St.length>0&&M!==`search`&&(0,J.jsx)(o,{flexShrink:0,paddingLeft:2,children:(0,J.jsx)(s,{dimColor:!0,children:(0,J.jsx)(c,{children:St})})}),(0,J.jsx)(o,{flexShrink:0,children:(0,J.jsx)(s,{children:` `})}),P.status===`searching`&&(0,J.jsxs)(o,{paddingLeft:1,flexShrink:0,children:[(0,J.jsx)(Pe,{}),(0,J.jsx)(s,{children:` Searching…`})]}),P.status===`results`&&P.results.length>0&&(0,J.jsx)(o,{paddingLeft:1,marginBottom:1,flexShrink:0,children:(0,J.jsx)(s,{dimColor:!0,italic:!0,children:`Work Mate found these results:`})}),P.status===`results`&&P.results.length===0&&ut.length===0&&(0,J.jsx)(o,{paddingLeft:1,marginBottom:1,flexShrink:0,children:(0,J.jsx)(s,{dimColor:!0,italic:!0,children:`No matching sessions found.`})}),P.status===`error`&&ut.length===0&&(0,J.jsx)(o,{paddingLeft:1,marginBottom:1,flexShrink:0,children:(0,J.jsx)(s,{dimColor:!0,italic:!0,children:`No matching sessions found.`})}),!!R.trim()&&y&&!1,P.status===`searching`?null:M===`rename`&&Q?(0,J.jsxs)(o,{paddingLeft:2,flexDirection:`column`,children:[(0,J.jsx)(s,{bold:!0,children:`Rename session:`}),(0,J.jsx)(o,{paddingTop:1,children:(0,J.jsx)(ke,{value:be,onChange:k,onSubmit:ht,placeholder:A(Q,`Enter new session name`),columns:b,cursorOffset:xe,onChangeCursorOffset:Se,showCursor:!0})})]}):S?(0,J.jsx)(Ye,{nodes:ft,onSelect:e=>{f(e.value.log)},onFocus:xt,onCancel:d,focusNodeId:j?.id,visibleOptionCount:$,layout:`expanded`,isDisabled:M===`search`||I,hideIndexes:!1,isNodeExpanded:e=>{if(M===`search`||me)return!0;let t=typeof e==`string`&&e.startsWith(`group:`)?e.substring(6):null;return t?Ce.has(t):!1},onExpand:e=>{let t=typeof e==`string`&&e.startsWith(`group:`)?e.substring(6):null;t&&we(e=>new Set(e).add(t))},onCollapse:e=>{let t=typeof e==`string`&&e.startsWith(`group:`)?e.substring(6):null;t&&we(e=>{let n=new Set(e);return n.delete(t),n})},onUpFromFirstItem:_t}):(0,J.jsx)(Me,{options:pt,onChange:e=>{let t=X[parseInt(e,10)];t&&f(t)},visibleOptionCount:$,onCancel:d,onFocus:bt,defaultFocusValue:j?.id.toString(),layout:`expanded`,isDisabled:M===`search`||I,onUpFromFirstItem:_t}),(0,J.jsx)(o,{paddingLeft:2,children:oe.pending?(0,J.jsxs)(s,{dimColor:!0,children:[`Press `,oe.keyName,` again to exit`]}):M===`rename`?(0,J.jsx)(s,{dimColor:!0,children:(0,J.jsxs)(c,{children:[(0,J.jsx)(r,{shortcut:`Enter`,action:`save`}),(0,J.jsx)(w,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]})}):P.status===`searching`?(0,J.jsx)(s,{dimColor:!0,children:(0,J.jsxs)(c,{children:[(0,J.jsx)(s,{children:`Searching with Work Mate…`}),(0,J.jsx)(w,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]})}):I?(0,J.jsx)(s,{dimColor:!0,children:(0,J.jsxs)(c,{children:[(0,J.jsx)(r,{shortcut:`Enter`,action:`search`}),(0,J.jsx)(r,{shortcut:`↓`,action:`skip`}),(0,J.jsx)(w,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]})}):M===`search`?(0,J.jsx)(s,{dimColor:!0,children:(0,J.jsxs)(c,{children:[(0,J.jsx)(s,{children:`Type to Search`}),(0,J.jsx)(r,{shortcut:`Enter`,action:`select`}),(0,J.jsx)(w,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`clear`})]})}):(0,J.jsx)(s,{dimColor:!0,children:(0,J.jsxs)(c,{children:[v&&(0,J.jsx)(r,{shortcut:`Ctrl+A`,action:`show ${_?`current dir`:`all projects`}`}),T&&(0,J.jsx)(r,{shortcut:`Ctrl+B`,action:`toggle branch`}),O&&(0,J.jsx)(r,{shortcut:`Ctrl+W`,action:`show ${E?`current worktree`:`all worktrees`}`}),(0,J.jsx)(r,{shortcut:`Ctrl+V`,action:`preview`}),(0,J.jsx)(r,{shortcut:`Ctrl+R`,action:`rename`}),(0,J.jsx)(s,{children:`Type to search`}),(0,J.jsx)(w,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`}),mt()&&(0,J.jsx)(s,{children:mt()})]})})})]})}function it(e){if(e.type!==`user`&&e.type!==`assistant`)return``;let t=`message`in e?e.message?.content:void 0;return t?typeof t==`string`?t:Array.isArray(t)?t.map(e=>typeof e==`string`?e:`text`in e&&typeof e.text==`string`?e.text:``).filter(Boolean).join(` `):``:``}function at(e){let t=(e.messages.length<=ut?e.messages:[...e.messages.slice(0,Y),...e.messages.slice(-1e3)]).map(it).filter(Boolean).join(` `),n=`${[e.customTitle,e.summary,e.firstPrompt,e.gitBranch,e.tag,e.prNumber?`PR #${e.prNumber}`:void 0,e.prRepository].filter(Boolean).join(` `)} ${t}`.trim();return n.length>X?n.slice(0,X):n}function ot(e){let t=new Map;for(let n of e){let e=C(n);if(e){let r=t.get(e);r?r.push(n):t.set(e,[n])}}return t.forEach(e=>e.sort((e,t)=>new Date(t.modified).getTime()-new Date(e.modified).getTime())),t}function st(e){let t=new Set;for(let n of e)n.tag&&t.add(n.tag);return Array.from(t).sort((e,t)=>e.localeCompare(t))}var q,J,ct,lt,ut,Y,X,dt,Z=e((()=>{p(),q=t(d(),1),v(),N(),ze(),ue(),g(),T(),Ce(),j(),x(),be(),xe(),ce(),Ie(),le(),je(),Le(),Ve(),Ne(),G(),M(),Ze(),J=_(),ct=2,lt=4,ut=2e3,Y=1e3,X=5e4,dt=50}));function ft(e){if(e.type!==`user`&&e.type!==`assistant`)return``;let t=`message`in e?e.message?.content:void 0;return t?typeof t==`string`?t:Array.isArray(t)?t.map(e=>typeof e==`string`?e:`text`in e&&typeof e.text==`string`?e.text:``).filter(Boolean).join(` `):``:``}function pt(e){if(e.length===0)return``;let t=(e.length<=gt?e:[...e.slice(0,gt/2),...e.slice(-100/2)]).map(ft).filter(Boolean).join(` `).replace(/\s+/g,` `).trim();return t.length>ht?`${t.slice(0,ht)}…`:t}function Q(e,t){return!!(A(e).toLowerCase().includes(t)||e.customTitle?.toLowerCase().includes(t)||e.tag?.toLowerCase().includes(t)||e.gitBranch?.toLowerCase().includes(t)||e.summary?.toLowerCase().includes(t)||e.firstPrompt?.toLowerCase().includes(t)||e.messages&&e.messages.length>0&&pt(e.messages).toLowerCase().includes(t))}async function mt(e,t,n){if(!e.trim()||t.length===0)return[];let r=e.toLowerCase(),i=t.filter(e=>Q(e,r)),a;if(i.length>=_t)a=i.slice(0,_t);else{let e=t.filter(e=>!Q(e,r)),n=_t-i.length;a=[...i,...e.slice(0,n)]}D(`Agentic search: ${a.length}/${t.length} logs, query="${e}", matching: ${i.length}, with messages: ${k(a,e=>e.messages?.length>0)}`);let o=a.map(async e=>{if(S(e))try{return await ae(e)}catch(t){return Se(t),e}return e}),s=await Promise.all(o);D(`Agentic search: loaded ${k(s,e=>e.messages?.length>0)}/${a.length} logs with transcripts`);let c=`Sessions:
2
+ ${s.map((e,t)=>{let n=[`${t}:`],r=A(e);if(n.push(r),e.customTitle&&e.customTitle!==r&&n.push(`[custom title: ${e.customTitle}]`),e.tag&&n.push(`[tag: ${e.tag}]`),e.gitBranch&&n.push(`[branch: ${e.gitBranch}]`),e.summary&&n.push(`- Summary: ${e.summary}`),e.firstPrompt&&e.firstPrompt!==`No prompt`&&n.push(`- First message: ${e.firstPrompt.slice(0,300)}`),e.messages&&e.messages.length>0){let t=pt(e.messages);t&&n.push(`- Transcript: ${t}`)}return n.join(` `)}).join(`
3
+ `)}
4
+
5
+ Search query: "${e}"
6
+
7
+ Find the sessions that are most relevant to this query.`;D(`Agentic search prompt (first 500 chars): ${c.slice(0,500)}...`);try{let e=Oe();D(`Agentic search using model: ${e}`);let t=(await he({model:e,system:vt,messages:[{role:`user`,content:c}],signal:n,querySource:`session_search`})).content.find(e=>e.type===`text`);if(t?.type!==`text`)return D(`No text content in agentic search response`),[];D(`Agentic search response: ${t.text}`);let r=t.text.match(/\{[\s\S]*\}/);if(!r)return D(`Could not find JSON in agentic search response`),[];let i=(E(r[0]).relevant_indices||[]).filter(e=>e>=0&&e<s.length).map(e=>s[e]);return D(`Agentic search found ${i.length} relevant sessions`),i}catch(e){return Se(e),D(`Agentic search error: ${e}`),[]}}var ht,gt,_t,vt,yt=e((()=>{ve(),O(),xe(),De(),ce(),fe(),_e(),ht=2e3,gt=100,_t=100,vt=`Your goal is to find relevant sessions based on a user's search query.
8
+
9
+ You will be given a list of sessions with their metadata and a search query. Identify which sessions are most relevant to the query.
10
+
11
+ Each session may include:
12
+ - Title (display name or custom title)
13
+ - Tag (user-assigned category, shown as [tag: name] - users tag sessions with /tag command to categorize them)
14
+ - Branch (git branch name, shown as [branch: name])
15
+ - Summary (AI-generated summary)
16
+ - First message (beginning of the conversation)
17
+ - Transcript (excerpt of conversation content)
18
+
19
+ IMPORTANT: Tags are user-assigned labels that indicate the session's topic or category. If the query matches a tag exactly or partially, those sessions should be highly prioritized.
20
+
21
+ For each session, consider (in order of priority):
22
+ 1. Exact tag matches (highest priority - user explicitly categorized this session)
23
+ 2. Partial tag matches or tag-related terms
24
+ 3. Title matches (custom titles or first message content)
25
+ 4. Branch name matches
26
+ 5. Summary and transcript content matches
27
+ 6. Semantic similarity and related concepts
28
+
29
+ CRITICAL: Be VERY inclusive in your matching. Include sessions that:
30
+ - Contain the query term anywhere in any field
31
+ - Are semantically related to the query (e.g., "testing" matches sessions about "tests", "unit tests", "QA", etc.)
32
+ - Discuss topics that could be related to the query
33
+ - Have transcripts that mention the concept even in passing
34
+
35
+ When in doubt, INCLUDE the session. It's better to return too many results than too few. The user can easily scan through results, but missing relevant sessions is frustrating.
36
+
37
+ Return sessions ordered by relevance (most relevant first). If truly no sessions have ANY connection to the query, return an empty array - but this should be rare.
38
+
39
+ Respond with ONLY the JSON object, no markdown formatting:
40
+ {"relevant_indices": [2, 5, 0]}`}));function bt(e,t){let n=ie();if(!t||!e.projectPath||e.projectPath===n)return{isCrossProject:!1};let r=C(e);return{isCrossProject:!0,isSameRepoWorktree:!1,command:`cd ${b([e.projectPath])} && claude --resume ${r}`,projectPath:e.projectPath}}var xt=e((()=>{v(),me(),ce()}));export{rt as a,yt as i,xt as n,Z as o,mt as r,bt as t};
@@ -0,0 +1 @@
1
+ import{n as e,t}from"./cwd-DrEEb4f5.js";e();export{t as getCwd};
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{Pt as t,T as n,q as r}from"./state-BQ4BEGin.js";import{AsyncLocalStorage as i}from"async_hooks";function a(e,t){return c.run(e,t)}function o(){return c.getStore()??n()}function s(){try{return o()}catch{return r()}}var c,l=e((()=>{t(),c=new i}));export{a as i,l as n,o as r,s as t};
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{Pt as t,T as n,q as r}from"./state-CXY-q5gr.js";import{AsyncLocalStorage as i}from"async_hooks";function a(e,t){return c.run(e,t)}function o(){return c.getStore()??n()}function s(){try{return o()}catch{return r()}}var c,l=e((()=>{t(),c=new i}));export{a as i,l as n,o as r,s as t};
@@ -1,4 +1,4 @@
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(`
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-DZ_SvEVz.js";import{n as s,t as c}from"./defineProperty-C-QyHrDq.js";import{Pt as l,at as u}from"./state-CXY-q5gr.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
2
  `):[]}},C=new WeakMap,w=new WeakMap,jt.NEWLINE_CHARS=new Set([`
3
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
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(`
@@ -34,6 +34,6 @@ you can set the \`dangerouslyAllowBrowser\` option to \`true\`, e.g.,
34
34
  new Anthropic({ apiKey, dangerouslyAllowBrowser: true });
35
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
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(`
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.WORKMATE_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
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};
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.WORKMATE_DEBUG_LOGS_DIR?re(process.env.WORKMATE_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.WORKMATE_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-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
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./cwd-DrEEb4f5.js";import{c as r,i}from"./debug-kBjDaVkQ.js";import{Pr as a,jr as o}from"./settings-YIDksG5Z.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-v5r8cBKW.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-BQAU2pJx.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{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};
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{v as t,y as n}from"./types-CD25a50S.js";import{n as r,t as i}from"./cwd-DrEEb4f5.js";import{f as a,u as o}from"./debug-kBjDaVkQ.js";import{Qn as s,er as c}from"./settings-YIDksG5Z.js";import{o as l,s as u}from"./log-DWZny1vM.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-DJOMbSDE.js";var i,a;e((()=>{n(),i=t(),a=(e,t,n)=>Promise.resolve((0,i.jsx)(r,{onDone:e}))}))();export{a as call};
@@ -1,13 +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(`
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-CD25a50S.js";import{$n as h,Hn as g,Pt as _,Qn as ee,Tn as v,ot as y,q as b}from"./state-CXY-q5gr.js";import{B as te,Dc as ne,Di as re,Ds as ie,Ec as ae,Gv as oe,Mi as se,Os as ce,V as le,Vv as ue,Xl as de,Yl as fe,gr as x,i as pe,nr as S,o as me}from"./loadAgentsDir-DR5PVAc3.js";import{ar as he,d as ge,dr as _e,hr as C,m as ve}from"./settings-YIDksG5Z.js";import{d as ye,n as be}from"./config-D3K87Mm1.js";import{f as xe,s as Se}from"./model-D42epddJ.js";import{_n as Ce,vn as we}from"./prompt-CTByhpUI.js";import{t as w}from"./conversationRecovery-OhitW-7g.js";import{t as Te}from"./QueryEngine-Mdi_kUaL.js";import{n as Ee,r as De}from"./modelOptions-beLgXORr.js";import{n as Oe,r as ke}from"./managedEnv-Do9fgLpk.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
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(`
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(),_(),ve(),we(),ye(),oe(),ne(),ce(),se(),le(),me(),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
4
  `)?``:`
5
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
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
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:`
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:{workMate:{toolName:n}},toolCallId:t,sessionUpdate:`tool_call_update`,status:`in_progress`,rawInput:e,...Y({name:n,id:t,input:s??{}},!1,o?.cwd)}:{_meta:{workMate:{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:{workMate:{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,workMate:{...e?.workMate??{},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
9
 
10
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
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};
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(),fe(),_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:{workMate:{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 he(t),r=await de({dir:t}),i=[];for(let e of r){if(!e.cwd||await he(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 ge().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),pe(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 ue(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:{workMate:{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};
@@ -0,0 +1 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./memoize-BK3gG5ob.js";import{homedir as r}from"os";import{join as i}from"path";function a(e){let t=process.env.NODE_OPTIONS;return t?t.split(/\s+/).includes(e):!1}function o(e){if(!e)return!1;if(typeof e==`boolean`)return e;let t=e.toLowerCase().trim();return[`1`,`true`,`yes`,`on`].includes(t)}function s(e){if(e===void 0)return!1;if(typeof e==`boolean`)return!e;if(!e)return!1;let t=e.toLowerCase().trim();return[`0`,`false`,`no`,`off`].includes(t)}function c(){return o(process.env.WORKMATE_SIMPLE)||process.argv.includes(`--bare`)}function l(e){let t={};if(e)for(let n of e){let[e,...r]=n.split(`=`);if(!e||r.length===0)throw Error(`Invalid environment variable format: ${n}, environment variables should be added as: -e KEY1=value1 -e KEY2=value2`);t[e]=r.join(`=`)}return t}function u(){return process.env.AWS_REGION||process.env.AWS_DEFAULT_REGION||`us-east-1`}function d(){return process.env.CLOUD_ML_REGION||`us-east5`}function f(){return o(process.env.CLAUDE_BASH_MAINTAIN_PROJECT_WORKING_DIR)}function p(){return!1}function m(e){if(e){let t=g.find(([t])=>e.startsWith(t));if(t)return process.env[t[1]]||d()}return d()}var h,g,_=e((()=>{n(),h=t(()=>(process.env.WORKMATE_CONFIG_DIR??i(r(),`.workmate`)).normalize(`NFC`),()=>process.env.WORKMATE_CONFIG_DIR),g=[[`claude-haiku-4-5`,`VERTEX_REGION_CLAUDE_HAIKU_4_5`],[`claude-3-5-haiku`,`VERTEX_REGION_CLAUDE_3_5_HAIKU`],[`claude-3-5-sonnet`,`VERTEX_REGION_CLAUDE_3_5_SONNET`],[`claude-3-7-sonnet`,`VERTEX_REGION_CLAUDE_3_7_SONNET`],[`claude-opus-4-1`,`VERTEX_REGION_CLAUDE_4_1_OPUS`],[`claude-opus-4`,`VERTEX_REGION_CLAUDE_4_0_OPUS`],[`claude-sonnet-4-6`,`VERTEX_REGION_CLAUDE_4_6_SONNET`],[`claude-sonnet-4-5`,`VERTEX_REGION_CLAUDE_4_5_SONNET`],[`claude-sonnet-4`,`VERTEX_REGION_CLAUDE_4_0_SONNET`]]}));export{a,s as c,l as d,f,h as i,o as l,d as n,_ as o,m as r,c as s,u as t,p as u};
@@ -0,0 +1 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./cwd-DrEEb4f5.js";import{w as r,x as i}from"./debug-kBjDaVkQ.js";import{n as a,r as o,t as s}from"./execa-CBhG1doD.js";import{o as c,s as l}from"./log-DWZny1vM.js";function u(e,t,i=10*h*m){let o;o=t===void 0?{}:t instanceof AbortSignal?{abortSignal:t,timeout:i}:t;let{abortSignal:s,timeout:c=10*h*m,input:l,stdio:u=[`ignore`,`pipe`,`pipe`]}=o;s?.throwIfAborted(),r`exec: ${e.slice(0,200)}`;try{let t=a(e,{env:process.env,maxBuffer:1e6,timeout:c,cwd:n(),stdio:u,shell:!0,reject:!1,input:l});return t.stdout&&t.stdout.trim()||null}catch{return null}}function d(e,t,r={timeout:10*h*m,preserveOutputOnError:!0,useCwd:!0}){return p(e,t,{abortSignal:r.abortSignal,timeout:r.timeout,preserveOutputOnError:r.preserveOutputOnError,cwd:r.useCwd?n():void 0,env:r.env,stdin:r.stdin,input:r.input})}function f(e,t){return e.shortMessage?e.shortMessage:typeof e.signal==`string`?e.signal:String(t)}function p(e,t,{abortSignal:n,timeout:r=10*h*m,preserveOutputOnError:i=!0,cwd:a,env:o,maxBuffer:c,shell:u,stdin:d,input:p}={timeout:10*h*m,preserveOutputOnError:!0,maxBuffer:1e6}){return new Promise(m=>{s(e,t,{maxBuffer:c,cancelSignal:n,timeout:r,cwd:a,env:o,shell:u,stdin:d,input:p,reject:!1}).then(e=>{if(e.failed)if(i){let t=e.exitCode??1;m({stdout:e.stdout||``,stderr:e.stderr||``,code:t,error:f(e,t)})}else m({stdout:``,stderr:``,code:e.exitCode??1});else m({stdout:e.stdout,stderr:e.stderr,code:0})}).catch(e=>{l(e),m({stdout:``,stderr:``,code:1})})})}var m,h,g=e((()=>{o(),t(),c(),i(),m=1e3,h=60}));export{g as i,p as n,u as r,d as t};