@readmagic/workmate 0.0.5 → 0.0.7

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 (415) hide show
  1. package/dist/chunks/{AddWorkspaceDirectory-DJRkEz7o.js → AddWorkspaceDirectory-CFrrXnt9.js} +1 -1
  2. package/dist/chunks/{App-iJu5qyiF.js → App-Buad9Llp.js} +1 -1
  3. package/dist/chunks/{ApproveApiKey-CRejTHUw.js → ApproveApiKey-B2HJUD7h.js} +1 -1
  4. package/dist/chunks/ApproveApiKey-BQbHdvc3.js +1 -0
  5. package/dist/chunks/{AssistantSessionChooser-CBLQ1v-J.js → AssistantSessionChooser-4lm4eXQ8.js} +1 -1
  6. package/dist/chunks/BackgroundTasksDialog-D4qA0M5O.js +2 -0
  7. package/dist/chunks/{BypassPermissionsModeDialog-D1FCKVOi.js → BypassPermissionsModeDialog-DllL8dxU.js} +1 -1
  8. package/dist/chunks/ClaudeMdExternalIncludesDialog--ywODh81.js +1 -0
  9. package/dist/chunks/{ClaudeMdExternalIncludesDialog-CI0yF6sZ.js → ClaudeMdExternalIncludesDialog-BZSyRqeq.js} +1 -1
  10. package/dist/chunks/ConsoleOAuthFlow-Wkfw7Ts-.js +1 -0
  11. package/dist/chunks/{DesktopHandoff-D1rrMxeP.js → DesktopHandoff-DaP4Riar.js} +1 -1
  12. package/dist/chunks/{DiffDialog-BKcfKx7O.js → DiffDialog-B7hx8i_Y.js} +2 -2
  13. package/dist/chunks/Doctor-89OgoAUA.js +1 -0
  14. package/dist/chunks/Doctor-CuKJ-nGt.js +3 -0
  15. package/dist/chunks/ExitFlow-DnPydE17.js +2 -0
  16. package/dist/chunks/{Feedback-bEUtrHia.js → Feedback-SmGiR3mf.js} +2 -2
  17. package/dist/chunks/Grove-CjN9DO47.js +11 -0
  18. package/dist/chunks/Grove-Cq88VBmM.js +1 -0
  19. package/dist/chunks/{HybridTransport-9fTBC2Pv.js → HybridTransport-rK83Qijz.js} +1 -1
  20. package/dist/chunks/{InvalidConfigDialog-9M-1nfZ6.js → InvalidConfigDialog-DdO0AxyF.js} +1 -1
  21. package/dist/chunks/{InvalidSettingsDialog-B2F6pryH.js → InvalidSettingsDialog-s1G0DwXF.js} +1 -1
  22. package/dist/chunks/MCPConnectionManager-NRfIjdlj.js +1 -0
  23. package/dist/chunks/{McpParsingWarnings-BPBb7Npe.js → McpParsingWarnings-Du5IxZos.js} +1 -1
  24. package/dist/chunks/MessageSelector-iIroHvXo.js +3 -0
  25. package/dist/chunks/Messages-D4Hm4gaY.js +11 -0
  26. package/dist/chunks/{Onboarding-cHcnsBGp.js → Onboarding-BiZByBK-.js} +1 -1
  27. package/dist/chunks/{OverageCreditUpsell-CWCD_RpM.js → OverageCreditUpsell-BM7szLgm.js} +1 -1
  28. package/dist/chunks/PluginSettings-uY5KTCtK.js +17 -0
  29. package/dist/chunks/{PromptInputFooterSuggestions-D5sAO6y-.js → PromptInputFooterSuggestions-BmsFdOu9.js} +1 -1
  30. package/dist/chunks/{PromptInputHelpMenu-n6hAdsto.js → PromptInputHelpMenu-DX-0wEDo.js} +1 -1
  31. package/dist/chunks/QueryEngine-CGYaShXD.js +1 -0
  32. package/dist/chunks/REPL-CRJB2t2z.js +142 -0
  33. package/dist/chunks/REPL-u4Yq29Du.js +1 -0
  34. package/dist/chunks/{RemoteCallout-CiA4rCEs.js → RemoteCallout-B-tyvQOe.js} +1 -1
  35. package/dist/chunks/{RemoteSessionManager-zdHfmvfj.js → RemoteSessionManager-DCd0O5_l.js} +2 -2
  36. package/dist/chunks/ResumeConversation-DAAXlOCd.js +1 -0
  37. package/dist/chunks/{SSETransport-BPbhCa2f.js → SSETransport-5VK5okFv.js} +1 -1
  38. package/dist/chunks/SearchExtraToolsTool-B-7Bworf.js +1 -0
  39. package/dist/chunks/Settings-CUjWlncb.js +2 -0
  40. package/dist/chunks/{TeleportProgress-DrulEQ7z.js → TeleportProgress-DxN0bQL2.js} +1 -1
  41. package/dist/chunks/{TeleportRepoMismatchDialog-D3FOLr0P.js → TeleportRepoMismatchDialog-A5Ss0kuk.js} +1 -1
  42. package/dist/chunks/{TeleportResumeWrapper-DI5iRFND.js → TeleportResumeWrapper-Bz14mUqR.js} +1 -1
  43. package/dist/chunks/{ThemePicker-CQ7dfFtv.js → ThemePicker-CVSRqTzW.js} +1 -1
  44. package/dist/chunks/TrustDialog-CY8an_Tg.js +1 -0
  45. package/dist/chunks/{ValidationErrorsList-CPYeuppg.js → ValidationErrorsList-BYsDtAvX.js} +1 -1
  46. package/dist/chunks/{WelcomeV2-C-UXdIng.js → WelcomeV2-C1BfrqC5.js} +1 -1
  47. package/dist/chunks/{add-dir-xTz4COgn.js → add-dir-DfLYgwox.js} +1 -1
  48. package/dist/chunks/{agentDisplay-BuSReYxu.js → agentDisplay-CMmHIl86.js} +1 -1
  49. package/dist/chunks/{agents-CiLlKN2I.js → agents-DE_4mAHG.js} +1 -1
  50. package/dist/chunks/agents-DJtPfvnL.js +103 -0
  51. package/dist/chunks/allErrors-CQE2k0zO.js +1 -0
  52. package/dist/chunks/{ant-CBIfqmAb.js → ant-ClQkuQjZ.js} +1 -1
  53. package/dist/chunks/{api-B-5jqiMg.js → api-2cdIPaeq.js} +1 -1
  54. package/dist/chunks/api-CG-lhKe-.js +1 -0
  55. package/dist/chunks/{assistant-XOnU01yl.js → assistant-Bje16tQx.js} +1 -1
  56. package/dist/chunks/auth-DMfEiQrC.js +1 -0
  57. package/dist/chunks/auth-D_cGl8WD.js +1 -0
  58. package/dist/chunks/{auth-DT2yxy94.js → auth-DqcKPbw8.js} +1 -1
  59. package/dist/chunks/{autoMode-CEMflt3g.js → autoMode-ZW70mpr0.js} +5 -5
  60. package/dist/chunks/{autonomy-_N8aDaA8.js → autonomy-CwbWsCnv.js} +1 -1
  61. package/dist/chunks/autonomy-Oui8yK8G.js +15 -0
  62. package/dist/chunks/{autonomyPanel-I4yCy3Fr.js → autonomyPanel-Mq50H7iM.js} +1 -1
  63. package/dist/chunks/backgroundHousekeeping-BpLtI45r.js +1 -0
  64. package/dist/chunks/backgroundHousekeeping-DtJNx4Ja.js +17 -0
  65. package/dist/chunks/{branch-BIX-pyHp.js → branch-DU5O9KZ0.js} +1 -1
  66. package/dist/chunks/{break-cache-BQfgkNAo.js → break-cache-C_p7Kmx2.js} +3 -3
  67. package/dist/chunks/{bridge-CYskzVt8.js → bridge-DNNxtPlz.js} +2 -2
  68. package/dist/chunks/{bridgeConfig-5p_w4s5r.js → bridgeConfig-CE6dMsiJ.js} +1 -1
  69. package/dist/chunks/bridgeConfig-DP9dD1Cv.js +1 -0
  70. package/dist/chunks/{bridgeEnabled-DhFrLTbG.js → bridgeEnabled-Cc0mGlTb.js} +1 -1
  71. package/dist/chunks/bridgeEnabled-D8wP3DWQ.js +1 -0
  72. package/dist/chunks/bridgeMain-CwxMa_pd.js +1 -0
  73. package/dist/chunks/bridgeMain-D11t1BYQ.js +68 -0
  74. package/dist/chunks/{bridgeMessaging-B5Lbzr8e.js → bridgeMessaging-DdvApEqW.js} +1 -1
  75. package/dist/chunks/{bridgePointer-MqLe5Asm.js → bridgePointer-DqHMHa2B.js} +1 -1
  76. package/dist/chunks/{btw-CWWFO7u8.js → btw-CejSEdNl.js} +1 -1
  77. package/dist/chunks/{caches-DPqPIogk.js → caches-5HVQSevy.js} +2 -2
  78. package/dist/chunks/caches-B-nJoHLM.js +1 -0
  79. package/dist/chunks/{ccrClient-CTLnU9Y1.js → ccrClient-BFyfO67b.js} +1 -1
  80. package/dist/chunks/{claudeDesktop-Cx31Ugjp.js → claudeDesktop-Fe-QL-sN.js} +1 -1
  81. package/dist/chunks/{clear-DCAgZwc4.js → clear-D8m2utXW.js} +1 -1
  82. package/dist/chunks/client-C6MbjvOB.js +17 -0
  83. package/dist/chunks/client-DKXCfdde.js +1 -0
  84. package/dist/chunks/client-xxikkAoZ.js +1 -0
  85. package/dist/chunks/{color-CmJGInHL.js → color-DWhgZH7A.js} +1 -1
  86. package/dist/chunks/commands-CxJpmEKF.js +1 -0
  87. package/dist/chunks/commitAttribution-DM6SBMwl.js +1 -0
  88. package/dist/chunks/{commitAttribution-CGZr7XNO.js → commitAttribution-DPnHHKSA.js} +1 -1
  89. package/dist/chunks/compact-CblM7306.js +2 -0
  90. package/dist/chunks/config-BLVBFi5v.js +1 -0
  91. package/dist/chunks/config-CMnqm6Se.js +1 -0
  92. package/dist/chunks/{config-3m_9zSrj.js → config-DRDuVyzE.js} +2 -2
  93. package/dist/chunks/{context-C9V4GF0n.js → context-CdSMMM-0.js} +1 -1
  94. package/dist/chunks/context-noninteractive-CPkf2vB9.js +1 -0
  95. package/dist/chunks/{context-noninteractive-BmC4o5xo.js → context-noninteractive-DNury4JI.js} +5 -5
  96. package/dist/chunks/conversation-DCMw_rsE.js +1 -0
  97. package/dist/chunks/conversation-pUtvc-cE.js +1 -0
  98. package/dist/chunks/{createSSHSession-BL6j0AU5.js → createSSHSession-BOdTAX3N.js} +1 -1
  99. package/dist/chunks/{createSession-D_sgO1Xy.js → createSession-8Ei-Lj7V.js} +1 -1
  100. package/dist/chunks/createSession-CjqxVh_Q.js +1 -0
  101. package/dist/chunks/crossProjectResume-Bj_Pe8oe.js +40 -0
  102. package/dist/chunks/{datadog-UkGdjL8-.js → datadog-DqHxqiwY.js} +1 -1
  103. package/dist/chunks/{desktop-HbYKh-VK.js → desktop-Z5FAfunZ.js} +1 -1
  104. package/dist/chunks/{diff-nTV17iWX.js → diff-CJEKvOA5.js} +1 -1
  105. package/dist/chunks/doctor-BA2ZLDTl.js +1 -0
  106. package/dist/chunks/{entry-CCFI6-gM.js → entry-DE0uMIf0.js} +4 -4
  107. package/dist/chunks/envLessBridgeConfig-B-LKYNvv.js +1 -0
  108. package/dist/chunks/envLessBridgeConfig-DyD9XCda.js +1 -0
  109. package/dist/chunks/{esm-CGoYrggU.js → esm-5w3xFBnt.js} +1 -1
  110. package/dist/chunks/exit-Dt9kHtJO.js +1 -0
  111. package/dist/chunks/{extra-usage-g2Pw4zt_.js → extra-usage-C7E2Z1p1.js} +1 -1
  112. package/dist/chunks/extra-usage-D0Kkjp-2.js +1 -0
  113. package/dist/chunks/{extra-usage-core-DLYHAInT.js → extra-usage-core-DjdaD1qO.js} +1 -1
  114. package/dist/chunks/{extra-usage-noninteractive-D8iszH3c.js → extra-usage-noninteractive-BnD1RhKK.js} +1 -1
  115. package/dist/chunks/{extraUsage-C2Ylufhj.js → extraUsage-CpgRTcMk.js} +1 -1
  116. package/dist/chunks/extractMemories-DhUprYa7.js +1 -0
  117. package/dist/chunks/{fast-Dx2fTmWr.js → fast-C4ZevUNL.js} +1 -1
  118. package/dist/chunks/fast-CChxlAAF.js +1 -0
  119. package/dist/chunks/{feedback-DCQ4pJ3v.js → feedback-BIhBhV6n.js} +1 -1
  120. package/dist/chunks/{firstPartyEventLogger-BNGPPBNP.js → firstPartyEventLogger-BXY1IJ2D.js} +2 -2
  121. package/dist/chunks/firstPartyEventLogger-CnkGSojw.js +1 -0
  122. package/dist/chunks/{flushGate-XaheIZZT.js → flushGate-CgHq81Gw.js} +1 -1
  123. package/dist/chunks/{gemini-BCCLHK3K.js → gemini-C1J-x1g7.js} +1 -1
  124. package/dist/chunks/generateRecap-C0jjCg0Z.js +1 -0
  125. package/dist/chunks/generateSessionName-w0BMtwS7.js +1 -0
  126. package/dist/chunks/{githubRepoPathMapping-B4AM8luI.js → githubRepoPathMapping-8D0kpsif.js} +1 -1
  127. package/dist/chunks/{goal-Bp6fyGqo.js → goal-B4GsR54_.js} +3 -3
  128. package/dist/chunks/grok-ffNyU3Lt.js +1 -0
  129. package/dist/chunks/{grove-DrBVaZSN.js → grove-BQisE2JM.js} +1 -1
  130. package/dist/chunks/{heapdump-JseysNDr.js → heapdump-DiCjAPR3.js} +1 -1
  131. package/dist/chunks/{help-DR9hKneR.js → help-2hn8VK2-.js} +1 -1
  132. package/dist/chunks/hooks-CBmrBO-J.js +1 -0
  133. package/dist/chunks/{hooks-C5n23H1E.js → hooks-CkA9bhHl.js} +2 -2
  134. package/dist/chunks/hostGuard-BHI6Q8Mt.js +1 -0
  135. package/dist/chunks/inboundAttachments-C5K3XPTC.js +1 -0
  136. package/dist/chunks/{inboundAttachments-Cp8XvLMZ.js → inboundAttachments-IH-g95jo.js} +1 -1
  137. package/dist/chunks/initReplBridge-C-P4dgAG.js +1 -0
  138. package/dist/chunks/{install-C7qTB0V5.js → install-Dzlm4u58.js} +1 -1
  139. package/dist/chunks/{instrumentation-CLZttr_u.js → instrumentation-Yt31gxWN.js} +3 -3
  140. package/dist/chunks/{job-BhiazwPH.js → job-BXujwZNa.js} +1 -1
  141. package/dist/chunks/{keybindings-CkL8BzUt.js → keybindings-D8FXoO89.js} +2 -2
  142. package/dist/chunks/language-Baosud0X.js +1 -0
  143. package/dist/chunks/{language-DIw2871r.js → language-Ca4B018X.js} +1 -1
  144. package/dist/chunks/{launchAgentsPlatform-j-mWpwW1.js → launchAgentsPlatform-D6DmNuDt.js} +1 -1
  145. package/dist/chunks/{launchLocalMemory-DmoXp0Xo.js → launchLocalMemory-C0FzUq7x.js} +2 -2
  146. package/dist/chunks/{launchLocalVault-1uKe0HjA.js → launchLocalVault-DkYAre4O.js} +3 -3
  147. package/dist/chunks/{launchMemoryStores-SxDKjHJ3.js → launchMemoryStores-D2rKWAPs.js} +1 -1
  148. package/dist/chunks/{launchOnboarding-CTtpnXcs.js → launchOnboarding-gOVAFEFp.js} +1 -1
  149. package/dist/chunks/{launchSchedule-BDVnGhaL.js → launchSchedule-IZdFstT_.js} +1 -1
  150. package/dist/chunks/{launchSkillStore-SmMLxp4K.js → launchSkillStore-B7LamM1d.js} +1 -1
  151. package/dist/chunks/{launchTeleport-B472ZSGz.js → launchTeleport-C2BQMfYP.js} +3 -3
  152. package/dist/chunks/{launchVault-CsyBgxle.js → launchVault-C60WUcCI.js} +1 -1
  153. package/dist/chunks/{lazySchema-DcIJE_0i.js → lazySchema-DULtBUCI.js} +1 -1
  154. package/dist/chunks/loadAgentsDir-B9c3Emvg.js +1 -0
  155. package/dist/chunks/{loadAgentsDir-Clu7Uk6a.js → loadAgentsDir-x3rlgED4.js} +693 -695
  156. package/dist/chunks/loadPluginHooks-BhNdAjeY.js +1 -0
  157. package/dist/chunks/localSearch-BLCGsdyM.js +1 -0
  158. package/dist/chunks/{localSearch-iA6JTk19.js → localSearch-DtplGF-l.js} +1 -1
  159. package/dist/chunks/{logoV2Utils-YHBJLIrC.js → logoV2Utils-gGK9gErT.js} +1 -1
  160. package/dist/chunks/{magicDocs-Bf1fqnHN.js → magicDocs-qdDB_mKb.js} +2 -2
  161. package/dist/chunks/{main-gtV_TqXP.js → main-OWFSddRx.js} +84 -84
  162. package/dist/chunks/managedEnv-Aq5BXfY7.js +1 -0
  163. package/dist/chunks/managedEnv-BHoeDjpS.js +1 -0
  164. package/dist/chunks/managedEnvConstants-BPwL2aWI.js +1 -0
  165. package/dist/chunks/{mappers-C8lYERPX.js → mappers-04gNXJ3w.js} +1 -1
  166. package/dist/chunks/mcp-BSNdwbxR.js +1 -0
  167. package/dist/chunks/mcp-CMnDNI-4.js +6 -0
  168. package/dist/chunks/mcp-D1yA9E56.js +2 -0
  169. package/dist/chunks/memory-D1zbyjxN.js +1 -0
  170. package/dist/chunks/{mode-DO6g7nkX.js → mode-DY087x_x.js} +2 -2
  171. package/dist/chunks/model-CZViyZnE.js +1 -0
  172. package/dist/chunks/{model-DLXL0CNu.js → model-D0EfJBuw.js} +1 -1
  173. package/dist/chunks/model-DLLkVV6S.js +1 -0
  174. package/dist/chunks/{nativeInstaller-OPuO2sm_.js → nativeInstaller-yj81F75v.js} +1 -1
  175. package/dist/chunks/onChangeAppState-DhGKPG9g.js +1 -0
  176. package/dist/chunks/{openai-HOebt-8k.js → openai-EYRnUsco.js} +3 -3
  177. package/dist/chunks/{overageCreditGrant-Bi1CTBAx.js → overageCreditGrant-Du3dOYVu.js} +1 -1
  178. package/dist/chunks/{panel-CrTPqXCv.js → panel-BSZGX6jN.js} +1 -1
  179. package/dist/chunks/{panelCall-D0eURklm.js → panelCall-dMvRPAGE.js} +1 -1
  180. package/dist/chunks/{partition-C8RSL3SQ.js → partition-C4FWzYVm.js} +1 -1
  181. package/dist/chunks/{passes-BJci5SM_.js → passes-Daz-ARWD.js} +1 -1
  182. package/dist/chunks/permissions-DF8tAmDF.js +3 -0
  183. package/dist/chunks/{pidLock-Bd2e6xuT.js → pidLock-CbC_il6r.js} +2 -2
  184. package/dist/chunks/{plan-D4gMsK7i.js → plan-rsb_83Fo.js} +1 -1
  185. package/dist/chunks/{plugin-CwCo5Kik.js → plugin-Cm31-nej.js} +1 -1
  186. package/dist/chunks/pluginAutoupdate-0k03PVff.js +1 -0
  187. package/dist/chunks/pluginBlocklist-wPFCUPdm.js +1 -0
  188. package/dist/chunks/pluginCliCommands-DhL9LbH0.js +1 -0
  189. package/dist/chunks/{pluginFlagging-DNPBbJZo.js → pluginFlagging-CAdaFV_D.js} +1 -1
  190. package/dist/chunks/pluginOperations-Cs_Z4C6O.js +2 -0
  191. package/dist/chunks/pluginStartupCheck-BRXGKGjG.js +1 -0
  192. package/dist/chunks/pluginStartupCheck-KeU0efTj.js +1 -0
  193. package/dist/chunks/{plugins-CzJIuPfb.js → plugins-CQNKZmjP.js} +4 -4
  194. package/dist/chunks/policyLimits-D2s8M8P2.js +1 -0
  195. package/dist/chunks/{pollConfig-DH2oCtFS.js → pollConfig-2nFzv6Hy.js} +1 -1
  196. package/dist/chunks/{poor-Dha9p9RF.js → poor-DXumVTR4.js} +1 -1
  197. package/dist/chunks/{poorMode-1NLYiS3Y.js → poorMode-CBOtooa0.js} +1 -1
  198. package/dist/chunks/poorMode-yNZL5uYf.js +1 -0
  199. package/dist/chunks/print-uxCF5ka5.js +23 -0
  200. package/dist/chunks/{privacy-settings-6ZWxR4Qt.js → privacy-settings-BncbJCV0.js} +1 -1
  201. package/dist/chunks/processBashCommand-CGdwvPmD.js +1 -0
  202. package/dist/chunks/processSlashCommand-DQarepEb.js +5 -0
  203. package/dist/chunks/prompt-BgOdcHkd.js +1 -0
  204. package/dist/chunks/{prompt-Bg_1U0gO.js → prompt-CE3sFmZV.js} +5 -5
  205. package/dist/chunks/prompt-CLJKFebn.js +1 -0
  206. package/dist/chunks/{promptEditor-BhYDmwdS.js → promptEditor-CyTzyjwG.js} +2 -2
  207. package/dist/chunks/{protocolHandler-Dnb7lITm.js → protocolHandler-JR8pASdH.js} +1 -1
  208. package/dist/chunks/rate-limit-options-C-EqWjeI.js +1 -0
  209. package/dist/chunks/{rcDebugLog-VKwMl0yg.js → rcDebugLog-DBB9r8aw.js} +1 -1
  210. package/dist/chunks/reconciler-CYD_XpG4.js +4 -0
  211. package/dist/chunks/{referral-BlrMpBAV.js → referral-CKmHHxj_.js} +1 -1
  212. package/dist/chunks/refresh-ZqZdmLK5.js +1 -0
  213. package/dist/chunks/{registerProtocol-CuKZAiCc.js → registerProtocol-wZv2uiW_.js} +1 -1
  214. package/dist/chunks/{release-notes-BgP8u7NE.js → release-notes-B5K7wVqZ.js} +1 -1
  215. package/dist/chunks/{releaseNotes-CunqVlbU.js → releaseNotes-B8gbyFFJ.js} +2 -2
  216. package/dist/chunks/{reload-plugins-CD9TzvFm.js → reload-plugins-B9ApSp2m.js} +1 -1
  217. package/dist/chunks/{remote-env-QaP_W_sv.js → remote-env-CAt1dHIS.js} +1 -1
  218. package/dist/chunks/{remoteBridgeCore-9-HVMo63.js → remoteBridgeCore-Bk3UdSLJ.js} +1 -1
  219. package/dist/chunks/remoteManagedSettings-bswzAB6W.js +1 -0
  220. package/dist/chunks/rename-CE_U6KE6.js +1 -0
  221. package/dist/chunks/{resume-D-SpOy_1.js → resume-BicEjsPd.js} +2 -2
  222. package/dist/chunks/{runtimeObserver-Dm3LIUMp.js → runtimeObserver-BrGF5QWX.js} +4 -4
  223. package/dist/chunks/{runtimeObserver-DOEcrylu.js → runtimeObserver-CiwnPFjK.js} +1 -1
  224. package/dist/chunks/sandbox-adapter-BtMiHImm.js +1 -0
  225. package/dist/chunks/{sandbox-toggle-B61AeBor.js → sandbox-toggle-D8eebdyI.js} +1 -1
  226. package/dist/chunks/searchExtraTools-hLLPuh7c.js +1 -0
  227. package/dist/chunks/{session-RwJCIIcs.js → session-BZIlR9Gc.js} +2 -2
  228. package/dist/chunks/{sessionDiscovery-dkFeWcA3.js → sessionDiscovery-DfDqTrF1.js} +1 -1
  229. package/dist/chunks/sessionFileAccessHooks-Bm8wiqwe.js +1 -0
  230. package/dist/chunks/sessionMemory-D37S0-jX.js +1 -0
  231. package/dist/chunks/sessionMemory-DmlAG3jq.js +1 -0
  232. package/dist/chunks/sessionMemoryUtils-6EWDHSGU.js +1 -0
  233. package/dist/chunks/sessionObserver-BUw2rzKl.js +1 -0
  234. package/dist/chunks/{sessionObserver-CSOYgsvH.js → sessionObserver-KgquhGWw.js} +1 -1
  235. package/dist/chunks/sessionStorage-CucBSK5Q.js +1 -0
  236. package/dist/chunks/{sessionTitle-CLOlPZ_M.js → sessionTitle-DAnM73S0.js} +2 -2
  237. package/dist/chunks/{sessionTracing-D8wr9j4X.js → sessionTracing-_Hh5VXxt.js} +1 -1
  238. package/dist/chunks/settings-BeLFUeie.js +19 -0
  239. package/dist/chunks/settings-Cl16Haug.js +1 -0
  240. package/dist/chunks/settingsSync-BNvFYH3c.js +1 -0
  241. package/dist/chunks/setup-D8kXv3ts.js +3 -0
  242. package/dist/chunks/{shadowedRuleDetection-CXsmUY2o.js → shadowedRuleDetection-C6R5zOUe.js} +1 -1
  243. package/dist/chunks/{sideQuestion-CHpOVzY5.js → sideQuestion-hUhxls9r.js} +3 -3
  244. package/dist/chunks/{sinks-1hFrW9HK.js → sinks-BuE17DeZ.js} +2 -2
  245. package/dist/chunks/sinks-FevoYQqP.js +1 -0
  246. package/dist/chunks/{skill-learning-Ck17rwH8.js → skill-learning-CMdxGtxr.js} +1 -1
  247. package/dist/chunks/skillChangeDetector-C65ZLSYV.js +1 -0
  248. package/dist/chunks/{skillGapStore-DyqNKuNy.js → skillGapStore-D18LRJAM.js} +2 -2
  249. package/dist/chunks/{skillGapStore-BJ1h2LVr.js → skillGapStore-Ep62R-2_.js} +1 -1
  250. package/dist/chunks/{skillGenerator-BT8NGzXT.js → skillGenerator-Bc7WwNT8.js} +2 -2
  251. package/dist/chunks/{skillLearning-Cn9Uw0Kd.js → skillLearning-Cs9fJgkV.js} +1 -1
  252. package/dist/chunks/skillLearning-duPZl69A.js +1 -0
  253. package/dist/chunks/{skillPanel-N0GoWjIi.js → skillPanel-Cyzby746.js} +3 -3
  254. package/dist/chunks/{skillSearchPanel-CTwtgTzy.js → skillSearchPanel-Cll9ccA5.js} +4 -4
  255. package/dist/chunks/{skills-Bv3lH-aA.js → skills-BPPeYBy7.js} +1 -1
  256. package/dist/chunks/{stats-C1Ff6w4i.js → stats-CqfF4Axp.js} +1 -1
  257. package/dist/chunks/{status-FD7HVYS7.js → status-CC9Q-2Yn.js} +1 -1
  258. package/dist/chunks/{status-DyXiBa0m.js → status-D4IQpsNK.js} +2 -2
  259. package/dist/chunks/statusNoticeHelpers-CEGvdm5d.js +1 -0
  260. package/dist/chunks/syncCache-CANQZ9mQ.js +1 -0
  261. package/dist/chunks/{tag-RzOSA5T0.js → tag-DDbNqBMu.js} +2 -2
  262. package/dist/chunks/{tasks-eJrOcdhB.js → tasks-CZvWJYGr.js} +1 -1
  263. package/dist/chunks/teleport-Dk5j03Ix.js +1 -0
  264. package/dist/chunks/{templateJobs-BnOBSFtq.js → templateJobs-D1BdhZsv.js} +1 -1
  265. package/dist/chunks/{terminalSetup-D_P5iZmq.js → terminalSetup-3JNy6i_J.js} +5 -5
  266. package/dist/chunks/{terminalSetup-BfvmoJaK.js → terminalSetup-Cn6jeYw1.js} +1 -1
  267. package/dist/chunks/{theme-S0kVMVt4.js → theme-Cg4GNOoQ.js} +1 -1
  268. package/dist/chunks/thinkback-p-vKIRW_.js +1 -0
  269. package/dist/chunks/thinkback-play-DnPTDE8B.js +1 -0
  270. package/dist/chunks/{thinkback-HyW_R_88.js → thinkback-rFA1do6F.js} +1 -1
  271. package/dist/chunks/{toolEventObserver--Z6jENks.js → toolEventObserver-CzsCuUMc.js} +1 -1
  272. package/dist/chunks/{toolEventObserver-BAFzvePj.js → toolEventObserver-SFwURL5F.js} +1 -1
  273. package/dist/chunks/toolPool-BR27AMJO.js +1 -0
  274. package/dist/chunks/trustedDevice-BYt39fui.js +1 -0
  275. package/dist/chunks/{trustedDevice-Dn4rXbxT.js → trustedDevice-CKedohmT.js} +1 -1
  276. package/dist/chunks/{types-C-MRCL8J.js → types-Dut4311z.js} +2 -2
  277. package/dist/chunks/{ultrareviewCommand-mYDTBCFD.js → ultrareviewCommand-C_4OSBTW.js} +2 -2
  278. package/dist/chunks/{undercover-CdapzvNH.js → undercover-D30rKimg.js} +2 -2
  279. package/dist/chunks/undercover-DRSwLozU.js +1 -0
  280. package/dist/chunks/{updateCCB-DPShheOr.js → updateCCB-C2G-U-qA.js} +1 -1
  281. package/dist/chunks/upgrade-Bi-bIz7R.js +1 -0
  282. package/dist/chunks/{upgrade-BOeakAP6.js → upgrade-Chs-OQFd.js} +1 -1
  283. package/dist/chunks/{upload-BXQsDtLW.js → upload-D8FWMSQx.js} +1 -1
  284. package/dist/chunks/{usage-iNQzY960.js → usage-BxVeUt60.js} +1 -1
  285. package/dist/chunks/usage-DUO7Yy1f.js +1 -0
  286. package/dist/chunks/{useExitOnCtrlCDWithKeybindings-CntByfTQ.js → useExitOnCtrlCDWithKeybindings-BwsZ5f0s.js} +1 -1
  287. package/dist/chunks/useMainLoopModel-Gy1Vv4Qr.js +1 -0
  288. package/dist/chunks/useManagePlugins-B11_87VN.js +1 -0
  289. package/dist/chunks/useMergedTools-CR56my9t.js +1 -0
  290. package/dist/chunks/{useSearchInput-H-8hJeFD.js → useSearchInput-C5OzQnX6.js} +1 -1
  291. package/dist/chunks/{useSettingsErrors-BF5i5Xju.js → useSettingsErrors-B9vOZL41.js} +1 -1
  292. package/dist/chunks/{util-CoicMvOv.js → util-8EHwfg4A.js} +1 -1
  293. package/dist/chunks/validatePlugin-6q1qmnAC.js +1 -0
  294. package/dist/chunks/{vim-DdvQlLDm.js → vim-CNDzwoTd.js} +1 -1
  295. package/dist/chunks/{workerRegistry-CzqQwCHC.js → workerRegistry-CvyHvwx-.js} +1 -1
  296. package/dist/chunks/worktree-ogmNCIpz.js +1 -0
  297. package/dist/cli.js +1 -1
  298. package/package.json +1 -1
  299. package/dist/chunks/ApproveApiKey-CKfn7U1R.js +0 -1
  300. package/dist/chunks/BackgroundTasksDialog-CyoLEYWH.js +0 -2
  301. package/dist/chunks/ClaudeMdExternalIncludesDialog-TypH-X8e.js +0 -1
  302. package/dist/chunks/ConsoleOAuthFlow-wGQuFt41.js +0 -1
  303. package/dist/chunks/Doctor-CcJUwSQn.js +0 -1
  304. package/dist/chunks/Doctor-Yco1McrL.js +0 -3
  305. package/dist/chunks/ExitFlow-D3csukbB.js +0 -2
  306. package/dist/chunks/Grove-DPkIjqg8.js +0 -1
  307. package/dist/chunks/Grove-Dsd7F39b.js +0 -11
  308. package/dist/chunks/MCPConnectionManager-MWpKjeZT.js +0 -1
  309. package/dist/chunks/MessageSelector-DsQmqFt2.js +0 -3
  310. package/dist/chunks/Messages-B3sGRx5A.js +0 -11
  311. package/dist/chunks/PluginSettings-B0jbwB2M.js +0 -17
  312. package/dist/chunks/QueryEngine-cwdsr4dr.js +0 -1
  313. package/dist/chunks/REPL-CJzScgbZ.js +0 -142
  314. package/dist/chunks/REPL-DlBJIPCw.js +0 -1
  315. package/dist/chunks/ResumeConversation-Rxwd6HAJ.js +0 -1
  316. package/dist/chunks/SearchExtraToolsTool-VP87ErGx.js +0 -1
  317. package/dist/chunks/Settings-CxI_KHUj.js +0 -2
  318. package/dist/chunks/TrustDialog-CnVKrdxQ.js +0 -1
  319. package/dist/chunks/agents-Du9KYHqN.js +0 -103
  320. package/dist/chunks/allErrors-P3utlEeA.js +0 -1
  321. package/dist/chunks/api-BiwZmmsh.js +0 -1
  322. package/dist/chunks/auth-BQa4kzQo.js +0 -1
  323. package/dist/chunks/auth-UAJhZNmZ.js +0 -1
  324. package/dist/chunks/autonomy-Cg5zweUa.js +0 -15
  325. package/dist/chunks/backgroundHousekeeping-BUUZ7Csq.js +0 -1
  326. package/dist/chunks/backgroundHousekeeping-DhF2lrQ9.js +0 -17
  327. package/dist/chunks/bridgeConfig-DWEqKbXk.js +0 -1
  328. package/dist/chunks/bridgeEnabled-CjVCMwnq.js +0 -1
  329. package/dist/chunks/bridgeMain-6lollTtZ.js +0 -1
  330. package/dist/chunks/bridgeMain-BX2AkLPs.js +0 -68
  331. package/dist/chunks/caches-C46fa77L.js +0 -1
  332. package/dist/chunks/client-Bup0Sgcn.js +0 -1
  333. package/dist/chunks/commands-BdB1eFvP.js +0 -1
  334. package/dist/chunks/commitAttribution-D6J3NuhB.js +0 -1
  335. package/dist/chunks/compact-C6-lMHgn.js +0 -2
  336. package/dist/chunks/config-Bxt1UH1T.js +0 -1
  337. package/dist/chunks/config-CjjXZfNi.js +0 -1
  338. package/dist/chunks/context-noninteractive-DvGo1l7b.js +0 -1
  339. package/dist/chunks/conversation-CH9ouFai.js +0 -1
  340. package/dist/chunks/conversation-CYqqk0o7.js +0 -1
  341. package/dist/chunks/createSession-DUfOAeyE.js +0 -1
  342. package/dist/chunks/crossProjectResume-D5hTOfnE.js +0 -40
  343. package/dist/chunks/doctor-7fgVhEKL.js +0 -1
  344. package/dist/chunks/envLessBridgeConfig-B2HYnEKo.js +0 -1
  345. package/dist/chunks/envLessBridgeConfig-DXd10GXD.js +0 -1
  346. package/dist/chunks/exit-ropaQiOr.js +0 -1
  347. package/dist/chunks/extra-usage-CLhv1Z4g.js +0 -1
  348. package/dist/chunks/extractMemories-B2IAvbXM.js +0 -1
  349. package/dist/chunks/fast-_G6zcFye.js +0 -1
  350. package/dist/chunks/firstPartyEventLogger-C9LzVy6y.js +0 -1
  351. package/dist/chunks/generateRecap-BhvbixY2.js +0 -1
  352. package/dist/chunks/generateSessionName-CN1oh7Fa.js +0 -1
  353. package/dist/chunks/grok-ax26ju8y.js +0 -1
  354. package/dist/chunks/hooks-BUJLxdFJ.js +0 -1
  355. package/dist/chunks/hostGuard-C5xydXZI.js +0 -1
  356. package/dist/chunks/inboundAttachments-C0nMTtCi.js +0 -1
  357. package/dist/chunks/initReplBridge-DJs28ZkI.js +0 -1
  358. package/dist/chunks/language-DfOAuDFc.js +0 -1
  359. package/dist/chunks/loadAgentsDir-DTbJJff-.js +0 -1
  360. package/dist/chunks/loadPluginHooks-Cvd5VdjQ.js +0 -1
  361. package/dist/chunks/localSearch-DKv8PRLD.js +0 -1
  362. package/dist/chunks/mcp-CNuhEGP6.js +0 -6
  363. package/dist/chunks/mcp-Ci0OPVrR.js +0 -1
  364. package/dist/chunks/mcp-CwIYauZl.js +0 -2
  365. package/dist/chunks/memory-DCGqfQ1U.js +0 -1
  366. package/dist/chunks/model-BQF64tZx.js +0 -1
  367. package/dist/chunks/model-DvrvG6BB.js +0 -1
  368. package/dist/chunks/onChangeAppState-CHhRDkM7.js +0 -1
  369. package/dist/chunks/permissions-JU9CGHgI.js +0 -3
  370. package/dist/chunks/pluginAutoupdate-CO-n9bqe.js +0 -1
  371. package/dist/chunks/pluginBlocklist-5qbaTRbV.js +0 -1
  372. package/dist/chunks/pluginCliCommands-I-lsw_us.js +0 -1
  373. package/dist/chunks/pluginOperations-Cz6eQ0Vu.js +0 -2
  374. package/dist/chunks/pluginStartupCheck-CoW7073W.js +0 -1
  375. package/dist/chunks/pluginStartupCheck-DJ9fslCK.js +0 -1
  376. package/dist/chunks/policyLimits-BkjgMQD0.js +0 -1
  377. package/dist/chunks/poorMode-qlxqU8Hm.js +0 -1
  378. package/dist/chunks/print-BL4EUT5Z.js +0 -23
  379. package/dist/chunks/processBashCommand-BZs9wggV.js +0 -1
  380. package/dist/chunks/processSlashCommand-D8lKLNzM.js +0 -5
  381. package/dist/chunks/prompt-CN7gBNKS.js +0 -1
  382. package/dist/chunks/prompt-D-zHhqp8.js +0 -1
  383. package/dist/chunks/rate-limit-options-DVzT3eWH.js +0 -1
  384. package/dist/chunks/reconciler-BdRXZTJf.js +0 -4
  385. package/dist/chunks/refresh-jwqnoK2h.js +0 -1
  386. package/dist/chunks/remoteManagedSettings-jZ6u8ZBT.js +0 -1
  387. package/dist/chunks/rename-29qxHf8W.js +0 -1
  388. package/dist/chunks/sandbox-adapter-LzTcKwBp.js +0 -1
  389. package/dist/chunks/searchExtraTools-CbJJQqzH.js +0 -1
  390. package/dist/chunks/sessionFileAccessHooks-B_nNW0zE.js +0 -1
  391. package/dist/chunks/sessionMemory-C4JAUZ6V.js +0 -1
  392. package/dist/chunks/sessionMemory-btARBn8H.js +0 -1
  393. package/dist/chunks/sessionMemoryUtils-BlqAy8oR.js +0 -1
  394. package/dist/chunks/sessionObserver-DMvWci8-.js +0 -1
  395. package/dist/chunks/sessionStorage-Diyuvt20.js +0 -1
  396. package/dist/chunks/settings-Dlp5JTa_.js +0 -19
  397. package/dist/chunks/settingsSync-QWA0VZSu.js +0 -1
  398. package/dist/chunks/setup-UI9uv2-K.js +0 -3
  399. package/dist/chunks/sinks-CXq8-7Qn.js +0 -1
  400. package/dist/chunks/skillChangeDetector-s0F9Yf9a.js +0 -1
  401. package/dist/chunks/skillLearning-1ZfYIzfL.js +0 -1
  402. package/dist/chunks/statusNoticeHelpers-kTp9Rdk6.js +0 -1
  403. package/dist/chunks/teleport-ABA-hdmP.js +0 -1
  404. package/dist/chunks/thinkback-C6gV2LpU.js +0 -1
  405. package/dist/chunks/thinkback-play-H6md4czq.js +0 -1
  406. package/dist/chunks/toolPool-CR61XXm3.js +0 -1
  407. package/dist/chunks/trustedDevice-DUrFWupL.js +0 -1
  408. package/dist/chunks/undercover-k3JoOKAb.js +0 -1
  409. package/dist/chunks/upgrade-D7iGU0PQ.js +0 -1
  410. package/dist/chunks/usage-DbRdMJog.js +0 -1
  411. package/dist/chunks/useMainLoopModel-DHkRIgNs.js +0 -1
  412. package/dist/chunks/useManagePlugins-B8HD0RUh.js +0 -1
  413. package/dist/chunks/useMergedTools-DfchLQZC.js +0 -1
  414. package/dist/chunks/validatePlugin-z2fcngf8.js +0 -1
  415. package/dist/chunks/worktree-DMhP5T0p.js +0 -1
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./figures-5ThXQEtq.js";import{I as r,P as i,fi as a,s as o,t as s}from"./src-CDCSSo0U2.js";import{t as c}from"./jsx-runtime-Bb4Xn-E0.js";import{Ao as l,KE as u,al as d,qE as f,rl as p,zo as m}from"./loadAgentsDir-Clu7Uk6a.js";import{dn as h,un as g}from"./settings-Dlp5JTa_.js";import{f as _,l as v}from"./file-DcZWPH2V.js";import{b as y,y as b}from"./startupProfiler-xa3NmN7Z.js";import{$t as x,an as S,bn as C,gn as w,vn as T,yn as ee}from"./prompt-Bg_1U0gO.js";import{n as E,t as D}from"./staticRender-BIxpgNUq.js";function O(e){let t=[];return k(e,t),A(e,t),M(e,t),N(e,t),P(e,t),t.sort((e,t)=>e.severity===t.severity?(t.savingsTokens??0)-(e.savingsTokens??0):e.severity===`warning`?-1:1),t}function k(e,t){e.percentage>=R&&t.push({severity:`warning`,title:`Context is ${e.percentage}% full`,detail:e.isAutoCompactEnabled?`Autocompact will trigger soon, which discards older messages. Use /compact now to control what gets kept.`:`Autocompact is disabled. Use /compact to free space, or enable autocompact in /config.`})}function A(e,t){if(e.messageBreakdown)for(let n of e.messageBreakdown.toolCallsByType){let r=n.callTokens+n.resultTokens,i=r/e.rawMaxTokens*100;if(i<F||r<I)continue;let a=j(n.name,r,i);a&&t.push(a)}}function j(e,t,n){let r=b(t);switch(e){case ee:return{severity:`warning`,title:`Bash results using ${r} tokens (${n.toFixed(0)}%)`,detail:`Pipe output through head, tail, or grep to reduce result size. Avoid cat on large files — use Read with offset/limit instead.`,savingsTokens:Math.floor(t*.5)};case x:return{severity:`info`,title:`Read results using ${r} tokens (${n.toFixed(0)}%)`,detail:`Use offset and limit parameters to read only the sections you need. Avoid re-reading entire files when you only need a few lines.`,savingsTokens:Math.floor(t*.3)};case w:return{severity:`info`,title:`Grep results using ${r} tokens (${n.toFixed(0)}%)`,detail:`Add more specific patterns or use the glob or type parameter to narrow file types. Consider Glob for file discovery instead of Grep.`,savingsTokens:Math.floor(t*.3)};default:return n>=20?{severity:`info`,title:`${e} using ${r} tokens (${n.toFixed(0)}%)`,detail:`This tool is consuming a significant portion of context.`,savingsTokens:Math.floor(t*.2)}:null}}function M(e,t){if(!e.messageBreakdown)return;let n=e.messageBreakdown.toolCallsByType.find(e=>e.name===x);if(!n)return;let r=n.callTokens+n.resultTokens,i=r/e.rawMaxTokens*100,a=n.resultTokens/e.rawMaxTokens*100;i>=F&&r>=I||a>=L&&n.resultTokens>=I&&t.push({severity:`info`,title:`File reads using ${b(n.resultTokens)} tokens (${a.toFixed(0)}%)`,detail:`If you are re-reading files, consider referencing earlier reads. Use offset/limit for large files.`,savingsTokens:Math.floor(n.resultTokens*.3)})}function N(e,t){let n=e.memoryFiles.reduce((e,t)=>e+t.tokens,0),r=n/e.rawMaxTokens*100;if(r>=z&&n>=B){let i=[...e.memoryFiles].sort((e,t)=>t.tokens-e.tokens).slice(0,3).map(e=>`${v(e.path)} (${b(e.tokens)})`).join(`, `);t.push({severity:`info`,title:`Memory files using ${b(n)} tokens (${r.toFixed(0)}%)`,detail:`Largest: ${i}. Use /memory to review and prune stale entries.`,savingsTokens:Math.floor(n*.3)})}}function P(e,t){!e.isAutoCompactEnabled&&e.percentage>=50&&e.percentage<R&&t.push({severity:`info`,title:`Autocompact is disabled`,detail:`Without autocompact, you will hit context limits and lose the conversation. Enable it in /config or use /compact manually.`})}var F,I,L,R,z,B,V=e((()=>{C(),S(),T(),_(),y(),F=15,I=1e4,L=5,R=80,z=5,B=5e3}));function H({suggestions:e}){return e.length===0?null:(0,U.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,U.jsx)(i,{bold:!0,children:`Suggestions`}),e.map((e,t)=>(0,U.jsxs)(r,{flexDirection:`column`,marginTop:t===0?0:1,children:[(0,U.jsxs)(r,{children:[(0,U.jsx)(o,{status:e.severity,withSpace:!0}),(0,U.jsx)(i,{bold:!0,children:e.title}),e.savingsTokens?(0,U.jsxs)(i,{dimColor:!0,children:[` `,n.arrowRight,` save ~`,b(e.savingsTokens)]}):null]}),(0,U.jsx)(r,{marginLeft:2,children:(0,U.jsx)(i,{dimColor:!0,children:e.detail})})]},t))]})}var U,W=e((()=>{t(),a(),s(),y(),U=c()}));function G(){return null}function K(e){let t=new Map;for(let n of e){let e=g(n.source),r=t.get(e)||[];r.push(n),t.set(e,r)}for(let[e,n]of t.entries())t.set(e,n.sort((e,t)=>t.tokens-e.tokens));let n=new Map;for(let e of X){let r=t.get(e);r&&n.set(e,r)}return n}function q({data:e}){let{categories:t,totalTokens:n,rawMaxTokens:a,percentage:o,gridRows:s,model:c,memoryFiles:l,mcpTools:u,deferredBuiltinTools:d=[],systemTools:f,systemPromptSections:p,agents:m,skills:h,messageBreakdown:g,cacheHitRate:_,cacheThreshold:y}=e,x=t.filter(e=>e.tokens>0&&e.name!==`Free space`&&e.name!==Y&&!e.isDeferred),S=t.some(e=>e.isDeferred&&e.name.includes(`MCP`)),C=d.length>0,w=t.find(e=>e.name===Y);return(0,J.jsxs)(r,{flexDirection:`column`,paddingLeft:1,children:[(0,J.jsx)(i,{bold:!0,children:`Context Usage`}),(0,J.jsxs)(r,{flexDirection:`row`,gap:2,children:[(0,J.jsx)(r,{flexDirection:`column`,flexShrink:0,children:s.map((e,t)=>(0,J.jsx)(r,{flexDirection:`row`,marginLeft:-1,children:e.map((e,t)=>e.categoryName===`Free space`?(0,J.jsx)(i,{dimColor:!0,children:`⛶ `},t):e.categoryName===Y?(0,J.jsx)(i,{color:e.color,children:`⛝ `},t):(0,J.jsx)(i,{color:e.color,children:e.squareFullness>=.7?`⛁ `:`⛀ `},t))},t))}),(0,J.jsxs)(r,{flexDirection:`column`,gap:0,flexShrink:0,children:[(0,J.jsxs)(i,{dimColor:!0,children:[c,` · `,b(n),`/`,b(a),` tokens (`,o,`%)`]}),(0,J.jsx)(G,{}),_!==void 0&&y!==void 0&&(0,J.jsxs)(i,{color:_<y?`warning`:void 0,children:[`Cache hit rate: `,_.toFixed(0),`%`,_<y?` (below ${y}% threshold)`:``]}),(0,J.jsx)(i,{children:` `}),(0,J.jsx)(i,{dimColor:!0,italic:!0,children:`Estimated usage by category`}),x.map((e,t)=>{let n=b(e.tokens),o=e.isDeferred?`N/A`:`${(e.tokens/a*100).toFixed(1)}%`,s=e.name===Y,c=e.name,l=e.isDeferred?` `:s?`⛝`:`⛁`;return(0,J.jsxs)(r,{children:[(0,J.jsx)(i,{color:e.color,children:l}),(0,J.jsxs)(i,{children:[` `,c,`: `]}),(0,J.jsxs)(i,{dimColor:!0,children:[n,` tokens (`,o,`)`]})]},t)}),(t.find(e=>e.name===`Free space`)?.tokens??0)>0&&(0,J.jsxs)(r,{children:[(0,J.jsx)(i,{dimColor:!0,children:`⛶`}),(0,J.jsx)(i,{children:` Free space: `}),(0,J.jsxs)(i,{dimColor:!0,children:[b(t.find(e=>e.name===`Free space`)?.tokens||0),` (`,((t.find(e=>e.name===`Free space`)?.tokens||0)/a*100).toFixed(1),`%)`]})]}),w&&w.tokens>0&&(0,J.jsxs)(r,{children:[(0,J.jsx)(i,{color:w.color,children:`⛝`}),(0,J.jsxs)(i,{dimColor:!0,children:[` `,w.name,`: `]}),(0,J.jsxs)(i,{dimColor:!0,children:[b(w.tokens),` tokens (`,(w.tokens/a*100).toFixed(1),`%)`]})]})]})]}),(0,J.jsxs)(r,{flexDirection:`column`,marginLeft:-1,children:[u.length>0&&(0,J.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,J.jsxs)(r,{children:[(0,J.jsx)(i,{bold:!0,children:`MCP tools`}),(0,J.jsxs)(i,{dimColor:!0,children:[` · /mcp`,S?` (loaded on-demand)`:``]})]}),u.some(e=>e.isLoaded)&&(0,J.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,J.jsx)(i,{dimColor:!0,children:`Loaded`}),u.filter(e=>e.isLoaded).map((e,t)=>(0,J.jsxs)(r,{children:[(0,J.jsxs)(i,{children:[`└ `,e.name,`: `]}),(0,J.jsxs)(i,{dimColor:!0,children:[b(e.tokens),` tokens`]})]},t))]}),S&&u.some(e=>!e.isLoaded)&&(0,J.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,J.jsx)(i,{dimColor:!0,children:`Available`}),u.filter(e=>!e.isLoaded).map((e,t)=>(0,J.jsx)(r,{children:(0,J.jsxs)(i,{dimColor:!0,children:[`└ `,e.name]})},t))]}),!S&&u.map((e,t)=>(0,J.jsxs)(r,{children:[(0,J.jsxs)(i,{children:[`└ `,e.name,`: `]}),(0,J.jsxs)(i,{dimColor:!0,children:[b(e.tokens),` tokens`]})]},t))]}),(f&&f.length>0||C)&&process.env.USER_TYPE===`ant`&&(0,J.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,J.jsxs)(r,{children:[(0,J.jsx)(i,{bold:!0,children:`[ANT-ONLY] System tools`}),C&&(0,J.jsx)(i,{dimColor:!0,children:` (some loaded on-demand)`})]}),(0,J.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,J.jsx)(i,{dimColor:!0,children:`Loaded`}),f?.map((e,t)=>(0,J.jsxs)(r,{children:[(0,J.jsxs)(i,{children:[`└ `,e.name,`: `]}),(0,J.jsxs)(i,{dimColor:!0,children:[b(e.tokens),` tokens`]})]},`sys-${t}`)),d.filter(e=>e.isLoaded).map((e,t)=>(0,J.jsxs)(r,{children:[(0,J.jsxs)(i,{children:[`└ `,e.name,`: `]}),(0,J.jsxs)(i,{dimColor:!0,children:[b(e.tokens),` tokens`]})]},`def-${t}`))]}),C&&d.some(e=>!e.isLoaded)&&(0,J.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,J.jsx)(i,{dimColor:!0,children:`Available`}),d.filter(e=>!e.isLoaded).map((e,t)=>(0,J.jsx)(r,{children:(0,J.jsxs)(i,{dimColor:!0,children:[`└ `,e.name]})},t))]})]}),p&&p.length>0&&process.env.USER_TYPE===`ant`&&(0,J.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,J.jsx)(i,{bold:!0,children:`[ANT-ONLY] System prompt sections`}),p.map((e,t)=>(0,J.jsxs)(r,{children:[(0,J.jsxs)(i,{children:[`└ `,e.name,`: `]}),(0,J.jsxs)(i,{dimColor:!0,children:[b(e.tokens),` tokens`]})]},t))]}),m.length>0&&(0,J.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,J.jsxs)(r,{children:[(0,J.jsx)(i,{bold:!0,children:`Custom agents`}),(0,J.jsx)(i,{dimColor:!0,children:` · /agents`})]}),Array.from(K(m).entries()).map(([e,t])=>(0,J.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,J.jsx)(i,{dimColor:!0,children:e}),t.map((e,t)=>(0,J.jsxs)(r,{children:[(0,J.jsxs)(i,{children:[`└ `,e.agentType,`: `]}),(0,J.jsxs)(i,{dimColor:!0,children:[b(e.tokens),` tokens`]})]},t))]},e))]}),l.length>0&&(0,J.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,J.jsxs)(r,{children:[(0,J.jsx)(i,{bold:!0,children:`Memory files`}),(0,J.jsx)(i,{dimColor:!0,children:` · /memory`})]}),l.map((e,t)=>(0,J.jsxs)(r,{children:[(0,J.jsxs)(i,{children:[`└ `,v(e.path),`: `]}),(0,J.jsxs)(i,{dimColor:!0,children:[b(e.tokens),` tokens`]})]},t))]}),h&&h.tokens>0&&(0,J.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,J.jsxs)(r,{children:[(0,J.jsx)(i,{bold:!0,children:`Skills`}),(0,J.jsx)(i,{dimColor:!0,children:` · /skills`})]}),Array.from(K(h.skillFrontmatter).entries()).map(([e,t])=>(0,J.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,J.jsx)(i,{dimColor:!0,children:e}),t.map((e,t)=>(0,J.jsxs)(r,{children:[(0,J.jsxs)(i,{children:[`└ `,e.name,`: `]}),(0,J.jsxs)(i,{dimColor:!0,children:[b(e.tokens),` tokens`]})]},t))]},e))]}),g&&process.env.USER_TYPE===`ant`&&(0,J.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,J.jsx)(i,{bold:!0,children:`[ANT-ONLY] Message breakdown`}),(0,J.jsxs)(r,{flexDirection:`column`,marginLeft:1,children:[(0,J.jsxs)(r,{children:[(0,J.jsx)(i,{children:`Tool calls: `}),(0,J.jsxs)(i,{dimColor:!0,children:[b(g.toolCallTokens),` tokens`]})]}),(0,J.jsxs)(r,{children:[(0,J.jsx)(i,{children:`Tool results: `}),(0,J.jsxs)(i,{dimColor:!0,children:[b(g.toolResultTokens),` tokens`]})]}),(0,J.jsxs)(r,{children:[(0,J.jsx)(i,{children:`Attachments: `}),(0,J.jsxs)(i,{dimColor:!0,children:[b(g.attachmentTokens),` tokens`]})]}),(0,J.jsxs)(r,{children:[(0,J.jsx)(i,{children:`Assistant messages (non-tool): `}),(0,J.jsxs)(i,{dimColor:!0,children:[b(g.assistantMessageTokens),` tokens`]})]}),(0,J.jsxs)(r,{children:[(0,J.jsx)(i,{children:`User messages (non-tool-result): `}),(0,J.jsxs)(i,{dimColor:!0,children:[b(g.userMessageTokens),` tokens`]})]})]}),g.toolCallsByType.length>0&&(0,J.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,J.jsx)(i,{bold:!0,children:`[ANT-ONLY] Top tools`}),g.toolCallsByType.slice(0,5).map((e,t)=>(0,J.jsxs)(r,{marginLeft:1,children:[(0,J.jsxs)(i,{children:[`└ `,e.name,`: `]}),(0,J.jsxs)(i,{dimColor:!0,children:[`calls `,b(e.callTokens),`, results `,b(e.resultTokens)]})]},t))]}),g.attachmentsByType.length>0&&(0,J.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,J.jsx)(i,{bold:!0,children:`[ANT-ONLY] Top attachments`}),g.attachmentsByType.slice(0,5).map((e,t)=>(0,J.jsxs)(r,{marginLeft:1,children:[(0,J.jsxs)(i,{children:[`└ `,e.name,`: `]}),(0,J.jsxs)(i,{dimColor:!0,children:[b(e.tokens),` tokens`]})]},t))]})]})]}),(0,J.jsx)(H,{suggestions:O(e)})]})}var J,Y,X,Z=e((()=>{a(),s(),V(),_(),y(),h(),W(),J=c(),Y=`Autocompact buffer`,X=[`Project`,`User`,`Managed`,`Plugin`,`Built-in`]}));function Q(e){return l(e)}async function te(e,t){let{messages:n,getAppState:r,options:{mainLoopModel:i,tools:a}}=t,o=Q(n),{messages:s}=await f(o),c=process.stdout.columns||80,l=r();return e(await E((0,$.jsx)(q,{data:await p(s,i,async()=>l.toolPermissionContext,a,l.agentDefinitions,c,t,void 0,o)}))),null}var $;e((()=>{a(),Z(),u(),d(),m(),D(),$=c()}))();export{te as call};
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./figures-5ThXQEtq.js";import{I as r,P as i,fi as a,s as o,t as s}from"./src-CDCSSo0U2.js";import{t as c}from"./jsx-runtime-Bb4Xn-E0.js";import{Co as l,LE as u,Mo as d,Qc as f,RE as p,Xc as m}from"./loadAgentsDir-x3rlgED4.js";import{fn as h,pn as g}from"./settings-BeLFUeie.js";import{f as _,l as v}from"./file-DcZWPH2V.js";import{b as y,y as b}from"./startupProfiler-xa3NmN7Z.js";import{$t as x,an as S,bn as C,gn as w,vn as T,yn as ee}from"./prompt-CE3sFmZV.js";import{n as E,t as D}from"./staticRender-BIxpgNUq.js";function O(e){let t=[];return k(e,t),A(e,t),M(e,t),N(e,t),P(e,t),t.sort((e,t)=>e.severity===t.severity?(t.savingsTokens??0)-(e.savingsTokens??0):e.severity===`warning`?-1:1),t}function k(e,t){e.percentage>=R&&t.push({severity:`warning`,title:`Context is ${e.percentage}% full`,detail:e.isAutoCompactEnabled?`Autocompact will trigger soon, which discards older messages. Use /compact now to control what gets kept.`:`Autocompact is disabled. Use /compact to free space, or enable autocompact in /config.`})}function A(e,t){if(e.messageBreakdown)for(let n of e.messageBreakdown.toolCallsByType){let r=n.callTokens+n.resultTokens,i=r/e.rawMaxTokens*100;if(i<F||r<I)continue;let a=j(n.name,r,i);a&&t.push(a)}}function j(e,t,n){let r=b(t);switch(e){case ee:return{severity:`warning`,title:`Bash results using ${r} tokens (${n.toFixed(0)}%)`,detail:`Pipe output through head, tail, or grep to reduce result size. Avoid cat on large files — use Read with offset/limit instead.`,savingsTokens:Math.floor(t*.5)};case x:return{severity:`info`,title:`Read results using ${r} tokens (${n.toFixed(0)}%)`,detail:`Use offset and limit parameters to read only the sections you need. Avoid re-reading entire files when you only need a few lines.`,savingsTokens:Math.floor(t*.3)};case w:return{severity:`info`,title:`Grep results using ${r} tokens (${n.toFixed(0)}%)`,detail:`Add more specific patterns or use the glob or type parameter to narrow file types. Consider Glob for file discovery instead of Grep.`,savingsTokens:Math.floor(t*.3)};default:return n>=20?{severity:`info`,title:`${e} using ${r} tokens (${n.toFixed(0)}%)`,detail:`This tool is consuming a significant portion of context.`,savingsTokens:Math.floor(t*.2)}:null}}function M(e,t){if(!e.messageBreakdown)return;let n=e.messageBreakdown.toolCallsByType.find(e=>e.name===x);if(!n)return;let r=n.callTokens+n.resultTokens,i=r/e.rawMaxTokens*100,a=n.resultTokens/e.rawMaxTokens*100;i>=F&&r>=I||a>=L&&n.resultTokens>=I&&t.push({severity:`info`,title:`File reads using ${b(n.resultTokens)} tokens (${a.toFixed(0)}%)`,detail:`If you are re-reading files, consider referencing earlier reads. Use offset/limit for large files.`,savingsTokens:Math.floor(n.resultTokens*.3)})}function N(e,t){let n=e.memoryFiles.reduce((e,t)=>e+t.tokens,0),r=n/e.rawMaxTokens*100;if(r>=z&&n>=B){let i=[...e.memoryFiles].sort((e,t)=>t.tokens-e.tokens).slice(0,3).map(e=>`${v(e.path)} (${b(e.tokens)})`).join(`, `);t.push({severity:`info`,title:`Memory files using ${b(n)} tokens (${r.toFixed(0)}%)`,detail:`Largest: ${i}. Use /memory to review and prune stale entries.`,savingsTokens:Math.floor(n*.3)})}}function P(e,t){!e.isAutoCompactEnabled&&e.percentage>=50&&e.percentage<R&&t.push({severity:`info`,title:`Autocompact is disabled`,detail:`Without autocompact, you will hit context limits and lose the conversation. Enable it in /config or use /compact manually.`})}var F,I,L,R,z,B,V=e((()=>{C(),S(),T(),_(),y(),F=15,I=1e4,L=5,R=80,z=5,B=5e3}));function H({suggestions:e}){return e.length===0?null:(0,U.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,U.jsx)(i,{bold:!0,children:`Suggestions`}),e.map((e,t)=>(0,U.jsxs)(r,{flexDirection:`column`,marginTop:t===0?0:1,children:[(0,U.jsxs)(r,{children:[(0,U.jsx)(o,{status:e.severity,withSpace:!0}),(0,U.jsx)(i,{bold:!0,children:e.title}),e.savingsTokens?(0,U.jsxs)(i,{dimColor:!0,children:[` `,n.arrowRight,` save ~`,b(e.savingsTokens)]}):null]}),(0,U.jsx)(r,{marginLeft:2,children:(0,U.jsx)(i,{dimColor:!0,children:e.detail})})]},t))]})}var U,W=e((()=>{t(),a(),s(),y(),U=c()}));function G(){return null}function K(e){let t=new Map;for(let n of e){let e=h(n.source),r=t.get(e)||[];r.push(n),t.set(e,r)}for(let[e,n]of t.entries())t.set(e,n.sort((e,t)=>t.tokens-e.tokens));let n=new Map;for(let e of X){let r=t.get(e);r&&n.set(e,r)}return n}function q({data:e}){let{categories:t,totalTokens:n,rawMaxTokens:a,percentage:o,gridRows:s,model:c,memoryFiles:l,mcpTools:u,deferredBuiltinTools:d=[],systemTools:f,systemPromptSections:p,agents:m,skills:h,messageBreakdown:g,cacheHitRate:_,cacheThreshold:y}=e,x=t.filter(e=>e.tokens>0&&e.name!==`Free space`&&e.name!==Y&&!e.isDeferred),S=t.some(e=>e.isDeferred&&e.name.includes(`MCP`)),C=d.length>0,w=t.find(e=>e.name===Y);return(0,J.jsxs)(r,{flexDirection:`column`,paddingLeft:1,children:[(0,J.jsx)(i,{bold:!0,children:`Context Usage`}),(0,J.jsxs)(r,{flexDirection:`row`,gap:2,children:[(0,J.jsx)(r,{flexDirection:`column`,flexShrink:0,children:s.map((e,t)=>(0,J.jsx)(r,{flexDirection:`row`,marginLeft:-1,children:e.map((e,t)=>e.categoryName===`Free space`?(0,J.jsx)(i,{dimColor:!0,children:`⛶ `},t):e.categoryName===Y?(0,J.jsx)(i,{color:e.color,children:`⛝ `},t):(0,J.jsx)(i,{color:e.color,children:e.squareFullness>=.7?`⛁ `:`⛀ `},t))},t))}),(0,J.jsxs)(r,{flexDirection:`column`,gap:0,flexShrink:0,children:[(0,J.jsxs)(i,{dimColor:!0,children:[c,` · `,b(n),`/`,b(a),` tokens (`,o,`%)`]}),(0,J.jsx)(G,{}),_!==void 0&&y!==void 0&&(0,J.jsxs)(i,{color:_<y?`warning`:void 0,children:[`Cache hit rate: `,_.toFixed(0),`%`,_<y?` (below ${y}% threshold)`:``]}),(0,J.jsx)(i,{children:` `}),(0,J.jsx)(i,{dimColor:!0,italic:!0,children:`Estimated usage by category`}),x.map((e,t)=>{let n=b(e.tokens),o=e.isDeferred?`N/A`:`${(e.tokens/a*100).toFixed(1)}%`,s=e.name===Y,c=e.name,l=e.isDeferred?` `:s?`⛝`:`⛁`;return(0,J.jsxs)(r,{children:[(0,J.jsx)(i,{color:e.color,children:l}),(0,J.jsxs)(i,{children:[` `,c,`: `]}),(0,J.jsxs)(i,{dimColor:!0,children:[n,` tokens (`,o,`)`]})]},t)}),(t.find(e=>e.name===`Free space`)?.tokens??0)>0&&(0,J.jsxs)(r,{children:[(0,J.jsx)(i,{dimColor:!0,children:`⛶`}),(0,J.jsx)(i,{children:` Free space: `}),(0,J.jsxs)(i,{dimColor:!0,children:[b(t.find(e=>e.name===`Free space`)?.tokens||0),` (`,((t.find(e=>e.name===`Free space`)?.tokens||0)/a*100).toFixed(1),`%)`]})]}),w&&w.tokens>0&&(0,J.jsxs)(r,{children:[(0,J.jsx)(i,{color:w.color,children:`⛝`}),(0,J.jsxs)(i,{dimColor:!0,children:[` `,w.name,`: `]}),(0,J.jsxs)(i,{dimColor:!0,children:[b(w.tokens),` tokens (`,(w.tokens/a*100).toFixed(1),`%)`]})]})]})]}),(0,J.jsxs)(r,{flexDirection:`column`,marginLeft:-1,children:[u.length>0&&(0,J.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,J.jsxs)(r,{children:[(0,J.jsx)(i,{bold:!0,children:`MCP tools`}),(0,J.jsxs)(i,{dimColor:!0,children:[` · /mcp`,S?` (loaded on-demand)`:``]})]}),u.some(e=>e.isLoaded)&&(0,J.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,J.jsx)(i,{dimColor:!0,children:`Loaded`}),u.filter(e=>e.isLoaded).map((e,t)=>(0,J.jsxs)(r,{children:[(0,J.jsxs)(i,{children:[`└ `,e.name,`: `]}),(0,J.jsxs)(i,{dimColor:!0,children:[b(e.tokens),` tokens`]})]},t))]}),S&&u.some(e=>!e.isLoaded)&&(0,J.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,J.jsx)(i,{dimColor:!0,children:`Available`}),u.filter(e=>!e.isLoaded).map((e,t)=>(0,J.jsx)(r,{children:(0,J.jsxs)(i,{dimColor:!0,children:[`└ `,e.name]})},t))]}),!S&&u.map((e,t)=>(0,J.jsxs)(r,{children:[(0,J.jsxs)(i,{children:[`└ `,e.name,`: `]}),(0,J.jsxs)(i,{dimColor:!0,children:[b(e.tokens),` tokens`]})]},t))]}),(f&&f.length>0||C)&&process.env.USER_TYPE===`ant`&&(0,J.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,J.jsxs)(r,{children:[(0,J.jsx)(i,{bold:!0,children:`[ANT-ONLY] System tools`}),C&&(0,J.jsx)(i,{dimColor:!0,children:` (some loaded on-demand)`})]}),(0,J.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,J.jsx)(i,{dimColor:!0,children:`Loaded`}),f?.map((e,t)=>(0,J.jsxs)(r,{children:[(0,J.jsxs)(i,{children:[`└ `,e.name,`: `]}),(0,J.jsxs)(i,{dimColor:!0,children:[b(e.tokens),` tokens`]})]},`sys-${t}`)),d.filter(e=>e.isLoaded).map((e,t)=>(0,J.jsxs)(r,{children:[(0,J.jsxs)(i,{children:[`└ `,e.name,`: `]}),(0,J.jsxs)(i,{dimColor:!0,children:[b(e.tokens),` tokens`]})]},`def-${t}`))]}),C&&d.some(e=>!e.isLoaded)&&(0,J.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,J.jsx)(i,{dimColor:!0,children:`Available`}),d.filter(e=>!e.isLoaded).map((e,t)=>(0,J.jsx)(r,{children:(0,J.jsxs)(i,{dimColor:!0,children:[`└ `,e.name]})},t))]})]}),p&&p.length>0&&process.env.USER_TYPE===`ant`&&(0,J.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,J.jsx)(i,{bold:!0,children:`[ANT-ONLY] System prompt sections`}),p.map((e,t)=>(0,J.jsxs)(r,{children:[(0,J.jsxs)(i,{children:[`└ `,e.name,`: `]}),(0,J.jsxs)(i,{dimColor:!0,children:[b(e.tokens),` tokens`]})]},t))]}),m.length>0&&(0,J.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,J.jsxs)(r,{children:[(0,J.jsx)(i,{bold:!0,children:`Custom agents`}),(0,J.jsx)(i,{dimColor:!0,children:` · /agents`})]}),Array.from(K(m).entries()).map(([e,t])=>(0,J.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,J.jsx)(i,{dimColor:!0,children:e}),t.map((e,t)=>(0,J.jsxs)(r,{children:[(0,J.jsxs)(i,{children:[`└ `,e.agentType,`: `]}),(0,J.jsxs)(i,{dimColor:!0,children:[b(e.tokens),` tokens`]})]},t))]},e))]}),l.length>0&&(0,J.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,J.jsxs)(r,{children:[(0,J.jsx)(i,{bold:!0,children:`Memory files`}),(0,J.jsx)(i,{dimColor:!0,children:` · /memory`})]}),l.map((e,t)=>(0,J.jsxs)(r,{children:[(0,J.jsxs)(i,{children:[`└ `,v(e.path),`: `]}),(0,J.jsxs)(i,{dimColor:!0,children:[b(e.tokens),` tokens`]})]},t))]}),h&&h.tokens>0&&(0,J.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,J.jsxs)(r,{children:[(0,J.jsx)(i,{bold:!0,children:`Skills`}),(0,J.jsx)(i,{dimColor:!0,children:` · /skills`})]}),Array.from(K(h.skillFrontmatter).entries()).map(([e,t])=>(0,J.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,J.jsx)(i,{dimColor:!0,children:e}),t.map((e,t)=>(0,J.jsxs)(r,{children:[(0,J.jsxs)(i,{children:[`└ `,e.name,`: `]}),(0,J.jsxs)(i,{dimColor:!0,children:[b(e.tokens),` tokens`]})]},t))]},e))]}),g&&process.env.USER_TYPE===`ant`&&(0,J.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,J.jsx)(i,{bold:!0,children:`[ANT-ONLY] Message breakdown`}),(0,J.jsxs)(r,{flexDirection:`column`,marginLeft:1,children:[(0,J.jsxs)(r,{children:[(0,J.jsx)(i,{children:`Tool calls: `}),(0,J.jsxs)(i,{dimColor:!0,children:[b(g.toolCallTokens),` tokens`]})]}),(0,J.jsxs)(r,{children:[(0,J.jsx)(i,{children:`Tool results: `}),(0,J.jsxs)(i,{dimColor:!0,children:[b(g.toolResultTokens),` tokens`]})]}),(0,J.jsxs)(r,{children:[(0,J.jsx)(i,{children:`Attachments: `}),(0,J.jsxs)(i,{dimColor:!0,children:[b(g.attachmentTokens),` tokens`]})]}),(0,J.jsxs)(r,{children:[(0,J.jsx)(i,{children:`Assistant messages (non-tool): `}),(0,J.jsxs)(i,{dimColor:!0,children:[b(g.assistantMessageTokens),` tokens`]})]}),(0,J.jsxs)(r,{children:[(0,J.jsx)(i,{children:`User messages (non-tool-result): `}),(0,J.jsxs)(i,{dimColor:!0,children:[b(g.userMessageTokens),` tokens`]})]})]}),g.toolCallsByType.length>0&&(0,J.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,J.jsx)(i,{bold:!0,children:`[ANT-ONLY] Top tools`}),g.toolCallsByType.slice(0,5).map((e,t)=>(0,J.jsxs)(r,{marginLeft:1,children:[(0,J.jsxs)(i,{children:[`└ `,e.name,`: `]}),(0,J.jsxs)(i,{dimColor:!0,children:[`calls `,b(e.callTokens),`, results `,b(e.resultTokens)]})]},t))]}),g.attachmentsByType.length>0&&(0,J.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,J.jsx)(i,{bold:!0,children:`[ANT-ONLY] Top attachments`}),g.attachmentsByType.slice(0,5).map((e,t)=>(0,J.jsxs)(r,{marginLeft:1,children:[(0,J.jsxs)(i,{children:[`└ `,e.name,`: `]}),(0,J.jsxs)(i,{dimColor:!0,children:[b(e.tokens),` tokens`]})]},t))]})]})]}),(0,J.jsx)(H,{suggestions:O(e)})]})}var J,Y,X,Z=e((()=>{a(),s(),V(),_(),y(),g(),W(),J=c(),Y=`Autocompact buffer`,X=[`Project`,`User`,`Managed`,`Plugin`,`Built-in`]}));function Q(e){return l(e)}async function te(e,t){let{messages:n,getAppState:r,options:{mainLoopModel:i,tools:a}}=t,o=Q(n),{messages:s}=await p(o),c=process.stdout.columns||80,l=r();return e(await E((0,$.jsx)(q,{data:await m(s,i,async()=>l.toolPermissionContext,a,l.agentDefinitions,c,t,void 0,o)}))),null}var $;e((()=>{a(),Z(),u(),f(),d(),D(),$=c()}))();export{te as call};
@@ -0,0 +1 @@
1
+ import{n as e,r as t,t as n}from"./context-noninteractive-DNury4JI.js";t();export{n as call,e as collectContextData};
@@ -1,4 +1,4 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{Ao as t,KE as n,al as r,qE as i,rl as a,zo as o}from"./loadAgentsDir-Clu7Uk6a.js";import{dn as s,un as c}from"./settings-Dlp5JTa_.js";import{b as l,y as u}from"./startupProfiler-xa3NmN7Z.js";async function d(e){let{messages:n,getAppState:r,options:{mainLoopModel:o,tools:s,agentDefinitions:c,customSystemPrompt:l,appendSystemPrompt:u}}=e,d=t(n),{messages:f}=await i(d),p=r();return a(f,o,async()=>p.toolPermissionContext,s,c,void 0,{options:{customSystemPrompt:l,appendSystemPrompt:u}},void 0,d)}async function f(e,t){return{type:`text`,value:p(await d(t))}}function p(e){let{categories:t,totalTokens:n,rawMaxTokens:r,percentage:i,model:a,memoryFiles:o,mcpTools:s,agents:l,skills:d,messageBreakdown:f,systemTools:p,systemPromptSections:m}=e,h=`## Context Usage
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{Co as t,LE as n,Mo as r,Qc as i,RE as a,Xc as o}from"./loadAgentsDir-x3rlgED4.js";import{fn as s,pn as c}from"./settings-BeLFUeie.js";import{b as l,y as u}from"./startupProfiler-xa3NmN7Z.js";async function d(e){let{messages:n,getAppState:r,options:{mainLoopModel:i,tools:s,agentDefinitions:c,customSystemPrompt:l,appendSystemPrompt:u}}=e,d=t(n),{messages:f}=await a(d),p=r();return o(f,i,async()=>p.toolPermissionContext,s,c,void 0,{options:{customSystemPrompt:l,appendSystemPrompt:u}},void 0,d)}async function f(e,t){return{type:`text`,value:p(await d(t))}}function p(e){let{categories:t,totalTokens:n,rawMaxTokens:r,percentage:i,model:a,memoryFiles:o,mcpTools:c,agents:l,skills:d,messageBreakdown:f,systemTools:p,systemPromptSections:m}=e,h=`## Context Usage
2
2
 
3
3
  `;h+=`**Model:** ${a} \n`,h+=`**Tokens:** ${u(n)} / ${u(r)} (${i}%)\n`,h+=`
4
4
  `;let g=t.filter(e=>e.tokens>0&&e.name!==`Free space`&&e.name!==`Autocompact buffer`);if(g.length>0){h+=`### Estimated usage by category
@@ -6,11 +6,11 @@ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{Ao as t,KE as n,al as
6
6
  `,h+=`| Category | Tokens | Percentage |
7
7
  `,h+=`|----------|--------|------------|
8
8
  `;for(let e of g){let t=(e.tokens/r*100).toFixed(1);h+=`| ${e.name} | ${u(e.tokens)} | ${t}% |\n`}let e=t.find(e=>e.name===`Free space`);if(e&&e.tokens>0){let t=(e.tokens/r*100).toFixed(1);h+=`| Free space | ${u(e.tokens)} | ${t}% |\n`}let n=t.find(e=>e.name===`Autocompact buffer`);if(n&&n.tokens>0){let e=(n.tokens/r*100).toFixed(1);h+=`| Autocompact buffer | ${u(n.tokens)} | ${e}% |\n`}h+=`
9
- `}if(s.length>0){h+=`### MCP Tools
9
+ `}if(c.length>0){h+=`### MCP Tools
10
10
 
11
11
  `,h+=`| Tool | Server | Tokens |
12
12
  `,h+=`|------|--------|--------|
13
- `;for(let e of s)h+=`| ${e.name} | ${e.serverName} | ${u(e.tokens)} |\n`;h+=`
13
+ `;for(let e of c)h+=`| ${e.name} | ${e.serverName} | ${u(e.tokens)} |\n`;h+=`
14
14
  `}if(p&&p.length>0&&process.env.USER_TYPE===`ant`){h+=`### [ANT-ONLY] System Tools
15
15
 
16
16
  `,h+=`| Tool | Tokens |
@@ -35,7 +35,7 @@ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{Ao as t,KE as n,al as
35
35
 
36
36
  `,h+=`| Skill | Source | Tokens |
37
37
  `,h+=`|-------|--------|--------|
38
- `;for(let e of d.skillFrontmatter)h+=`| ${e.name} | ${c(e.source)} | ${u(e.tokens)} |\n`;h+=`
38
+ `;for(let e of d.skillFrontmatter)h+=`| ${e.name} | ${s(e.source)} | ${u(e.tokens)} |\n`;h+=`
39
39
  `}if(f&&process.env.USER_TYPE===`ant`){if(h+=`### [ANT-ONLY] Message Breakdown
40
40
 
41
41
  `,h+=`| Category | Tokens |
@@ -51,4 +51,4 @@ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{Ao as t,KE as n,al as
51
51
  `,h+=`| Attachment | Tokens |
52
52
  `,h+=`|------------|--------|
53
53
  `;for(let e of f.attachmentsByType)h+=`| ${e.name} | ${u(e.tokens)} |\n`;h+=`
54
- `}}return h}var m=e((()=>{n(),r(),l(),o(),s()}));export{d as n,m as r,f as t};
54
+ `}}return h}var m=e((()=>{n(),i(),l(),r(),c()}));export{d as n,m as r,f as t};
@@ -0,0 +1 @@
1
+ import{a as e,n as t}from"./rolldown-runtime-DaDcL9Zw.js";import{Fn as n,In as r,Rn as i,cn as a,en as o,ht as s,nt as c,q as l,un as u}from"./state-ix0xIunV.js";import{AC as d,Ci as ee,Ct as f,Cu as p,Ei as m,Et as h,Gh as g,Kh as _,Lp as v,Ly as y,Mn as b,Nl as x,OC as te,Rp as S,Ry as C,Xy as w,Zt as T,dn as E,dr as D,fi as O,jn as k,jr as A,kl as j,kn as M,nr as N,rb as P,wu as F,yn as I}from"./loadAgentsDir-x3rlgED4.js";import{o as L,s as ne}from"./log-BMCygSzM.js";import{n as R,r as z}from"./analytics-BotDBGh0.js";import{C as B,y as V}from"./rcDebugLog-DBB9r8aw.js";import{l as H,r as U}from"./commitAttribution-DPnHHKSA.js";import{c as W,d as G}from"./debugUtils-NO5KtXqi.js";import{n as K,t as q}from"./caches-5HVQSevy.js";import{randomUUID as J}from"crypto";function Y(e){Q=e,x(Z()??null).catch(()=>{})}function X(){return Q}function Z(){let e=X();return e?G(e.bridgeSessionId):void 0}var Q,$=t((()=>{j(),W(),Q=null}));function re(){let e=X();if(!e)return;e.markTranscriptReset?.();let t={type:`status`,subtype:`status`,status:`conversation_cleared`,message:`conversation_cleared`,uuid:J()};e.writeSdkMessages([t])}async function ie({setMessages:t,readFileState:o,discoveredSkillNames:d,loadedNestedMemoryPaths:p,getAppState:h,setAppState:g,setConversationId:v}){let y=E();await T(`clear`,{getAppState:h,setAppState:g,signal:AbortSignal.timeout(y),timeoutMs:y});let b=l();b&&z(`tengu_cache_eviction_hint`,{scope:`conversation_clear`,last_request_id:b});let x=new Set,j=[],P=e=>`isBackgrounded`in e&&e.isBackgrounded===!1;if(h)for(let e of Object.values(h().tasks))P(e)||F(e)&&(x.add(e.agentId),j.push(e));t(()=>[]),re();{let{setContextBlocked:t}=(V(),e(B));t(!1)}v&&v(J()),q(x),n(null),r(null),i(null),u(),S(c()),o.clear(),d?.clear(),p?.clear(),g&&g(e=>{let t={};for(let[n,r]of Object.entries(e.tasks)){if(!P(r)){t[n]=r;continue}try{r.status===`running`&&(_(r)&&(r.shellCommand?.kill(),r.shellCommand?.cleanup(),r.cleanupTimeoutId&&clearTimeout(r.cleanupTimeoutId)),`abortController`in r&&r.abortController?.abort(),`unregisterCleanup`in r&&r.unregisterCleanup?.())}catch(e){ne(e)}M(n)}return{...e,tasks:t,attribution:U(),standaloneAgentContext:void 0,fileHistory:{snapshots:[],trackedFiles:new Set,snapshotSequence:0},mcp:{clients:[],tools:[],commands:[],resources:{},pluginReconnectKey:e.mcp.pluginReconnectKey}}}),w(),N(),a({setCurrentAsParent:!0}),process.env.USER_TYPE===`ant`&&process.env.CLAUDE_CODE_SESSION_ID&&(process.env.CLAUDE_CODE_SESSION_ID=s()),await O();for(let e of j)e.status===`running`&&k(e.id,D(te(e.agentId)));let{saveMode:I}=(A(),e(m));I(`normal`);let L=f();L&&ee(L);let R=await C(`clear`);R.length>0&&t(()=>R)}var ae=t((()=>{$(),o(),R(),p(),g(),d(),H(),I(),L(),P(),v(),y(),A(),b(),h(),K()}));export{Y as i,ae as n,$ as r,ie as t};
@@ -0,0 +1 @@
1
+ import{n as e,t}from"./conversation-DCMw_rsE.js";e();export{t as clearConversation};
@@ -1,4 +1,4 @@
1
- import{n as e,t}from"./defineProperty-C-QyHrDq.js";import{C as n,S as r,a as i,l as a,w as o}from"./debug-BrXObCdR.js";import{l as s,u as c}from"./oauth-BqJqV-2M.js";import{Bt as l,Ot as u}from"./model-BQF64tZx.js";import{i as d,t as f}from"./cliLaunch-BkPAatcs.js";import{resolve as p}from"path";import{existsSync as m,unlinkSync as h}from"fs";import{randomUUID as g}from"crypto";i(),r(),e();function _(e){return typeof e==`object`&&!!e&&`type`in e&&typeof e.type==`string`}var v=2e3,y=15e3,b=3,x=class{constructor(e,n){t(this,`proc`,void 0),t(this,`options`,void 0),t(this,`connected`,!1),t(this,`disconnected`,!1),t(this,`readLoopAbort`,null),t(this,`reconnectAttempt`,0),t(this,`maxReconnectAttempts`,void 0),t(this,`userInitiatedDisconnect`,!1),t(this,`reconnecting`,!1),this.proc=e,this.options=n,this.maxReconnectAttempts=n.maxReconnectAttempts??b}connect(){this.connected||(this.readLoopAbort=new AbortController,this.startReadLoop(),this.monitorExit(),this.connected=!0,this.options.onConnected())}async startReadLoop(){let e=this.proc.stdout;if(!e){this.options.onError(Error(`SSH process stdout is not available`));return}let t=e.getReader(),n=new TextDecoder,r=``;try{for(;!this.disconnected;){let{done:e,value:i}=await t.read();if(e)break;r+=n.decode(i,{stream:!0});let a=r.split(`
1
+ import{n as e,t}from"./defineProperty-C-QyHrDq.js";import{C as n,S as r,a as i,l as a,w as o}from"./debug-BrXObCdR.js";import{l as s,u as c}from"./oauth-BqJqV-2M.js";import{Bt as l,Ot as u}from"./model-CZViyZnE.js";import{i as d,t as f}from"./cliLaunch-BkPAatcs.js";import{resolve as p}from"path";import{existsSync as m,unlinkSync as h}from"fs";import{randomUUID as g}from"crypto";i(),r(),e();function _(e){return typeof e==`object`&&!!e&&`type`in e&&typeof e.type==`string`}var v=2e3,y=15e3,b=3,x=class{constructor(e,n){t(this,`proc`,void 0),t(this,`options`,void 0),t(this,`connected`,!1),t(this,`disconnected`,!1),t(this,`readLoopAbort`,null),t(this,`reconnectAttempt`,0),t(this,`maxReconnectAttempts`,void 0),t(this,`userInitiatedDisconnect`,!1),t(this,`reconnecting`,!1),this.proc=e,this.options=n,this.maxReconnectAttempts=n.maxReconnectAttempts??b}connect(){this.connected||(this.readLoopAbort=new AbortController,this.startReadLoop(),this.monitorExit(),this.connected=!0,this.options.onConnected())}async startReadLoop(){let e=this.proc.stdout;if(!e){this.options.onError(Error(`SSH process stdout is not available`));return}let t=e.getReader(),n=new TextDecoder,r=``;try{for(;!this.disconnected;){let{done:e,value:i}=await t.read();if(e)break;r+=n.decode(i,{stream:!0});let a=r.split(`
2
2
  `);r=a.pop()??``;for(let e of a){let t=e.trim();t&&this.processLine(t)}}}catch(e){this.disconnected||this.options.onError(e instanceof Error?e:Error(String(e)))}finally{t.releaseLock(),!this.disconnected&&!this.userInitiatedDisconnect&&this.handleProcessExit()}}monitorExit(){if(this.proc.exitCode!==null){this.userInitiatedDisconnect||this.handleProcessExit();return}this.proc.exited.then(()=>{!this.disconnected&&!this.userInitiatedDisconnect&&this.handleProcessExit()}).catch(()=>{!this.disconnected&&!this.userInitiatedDisconnect&&this.handleProcessExit()})}async handleProcessExit(){if(!(this.disconnected||this.reconnecting)){if(this.connected=!1,!this.options.reconnect){this.disconnected=!0,this.options.onDisconnected();return}if(this.reconnectAttempt>=this.maxReconnectAttempts){this.disconnected=!0,this.options.onDisconnected();return}this.reconnecting=!0;try{await this.attemptReconnect()}finally{this.reconnecting=!1}}}async attemptReconnect(){let e=this.options.reconnect;for(;this.reconnectAttempt<this.maxReconnectAttempts;){this.reconnectAttempt++,this.options.onReconnecting(this.reconnectAttempt,this.maxReconnectAttempts);let t=Math.min(v*2**(this.reconnectAttempt-1),y);if(await new Promise(e=>setTimeout(e,t)),this.userInitiatedDisconnect)return;try{let t=await e();this.proc=t,this.reconnectAttempt=0,this.connected=!0,this.startReadLoop(),this.monitorExit(),this.options.onConnected();return}catch(e){a(`[SSH] reconnect attempt ${this.reconnectAttempt} failed: ${e instanceof Error?e.message:String(e)}`)}}this.disconnected=!0,this.options.onDisconnected()}processLine(e){let t;try{t=n(e)}catch{return}if(!_(t))return;let r=t;if(r.type===`control_request`){let e=r;e.request.subtype===`can_use_tool`?this.options.onPermissionRequest(e.request,e.request_id):(a(`[SSH] Unsupported control request subtype: ${e.request.subtype}`),this.sendErrorResponse(e.request_id,`Unsupported control request subtype: ${e.request.subtype}`));return}r.type!==`control_response`&&r.type!==`keep_alive`&&r.type!==`control_cancel_request`&&r.type!==`streamlined_text`&&r.type!==`streamlined_tool_use_summary`&&!(r.type===`system`&&r.subtype===`post_turn_summary`)&&this.options.onMessage(r)}writeToStdin(e){try{let t=this.proc.stdin;if(!t||typeof t==`number`||this.disconnected)return!1;let n=new TextEncoder().encode(e+`
3
3
  `);return t.write(n),t.flush?.(),!0}catch{return!1}}async sendMessage(e){let t=o({type:`user`,message:{role:`user`,content:e},parent_tool_use_id:null,session_id:``});return this.writeToStdin(t)}sendInterrupt(){let e=o({type:`control_request`,request_id:crypto.randomUUID(),request:{subtype:`interrupt`}});this.writeToStdin(e)}respondToPermissionRequest(e,t){let n=o({type:`control_response`,response:{subtype:`success`,request_id:e,response:{behavior:t.behavior,...t.behavior===`allow`?{updatedInput:t.updatedInput}:{message:t.message}}}});this.writeToStdin(n)}sendErrorResponse(e,t){let n=o({type:`control_response`,response:{subtype:`error`,request_id:e,error:t}});this.writeToStdin(n)}disconnect(){if(!this.disconnected){this.userInitiatedDisconnect=!0,this.disconnected=!0,this.connected=!1,this.readLoopAbort?.abort();try{let e=this.proc.stdin;e&&typeof e!=`number`&&e.end?.()}catch{}try{this.proc.kill()}catch{}}}isConnected(){return this.connected&&!this.disconnected}};l(),c(),i();var S=process.platform===`win32`;function C(){let e=process.env.ANTHROPIC_API_KEY;if(e)return{"x-api-key":e};let t=u();return t?.accessToken?{Authorization:`Bearer ${t.accessToken}`}:{}}function w(){return process.env.ANTHROPIC_BASE_URL||s().BASE_API_URL}async function T(e,t){if(t&&e.headers.get(`x-auth-nonce`)!==t)return new Response(`Forbidden`,{status:403});let n=w(),r=new URL(e.url),i=`${n}${r.pathname}${r.search}`,o=C();if(Object.keys(o).length===0)return new Response(JSON.stringify({error:`No API credentials available on local machine`}),{status:401,headers:{"content-type":`application/json`}});let s=new Headers(e.headers);for(let[e,t]of Object.entries(o))s.set(e,t);s.delete(`host`),s.delete(`x-auth-nonce`),a(`[SSHAuthProxy] ${e.method} ${r.pathname} -> ${i}`);try{let t=await fetch(i,{method:e.method,headers:s,body:e.body,duplex:`half`}),n=new Headers(t.headers);return n.delete(`content-encoding`),n.delete(`content-length`),new Response(t.body,{status:t.status,statusText:t.statusText,headers:n})}catch(e){let t=e instanceof Error?e.message:String(e);return a(`[SSHAuthProxy] upstream error: ${t}`),new Response(JSON.stringify({error:`Proxy upstream error: ${t}`}),{status:502,headers:{"content-type":`application/json`}})}}async function E(){let e=g();return S?O(e):D(e)}async function D(e){let t=`/tmp/claude-ssh-auth-${e}.sock`,n=Bun.serve({unix:t,fetch:e=>T(e,null)});return a(`[SSHAuthProxy] listening on unix:${t}`),{proxy:{stop(){n.stop(!0);try{h(t)}catch{}}},localAddress:t,authEnv:{ANTHROPIC_AUTH_SOCKET:t}}}async function O(e){let t=g(),n=Bun.serve({port:0,hostname:`127.0.0.1`,fetch:e=>T(e,t)}),r=n.port;return a(`[SSHAuthProxy] listening on TCP 127.0.0.1:${r} (nonce-protected)`),{proxy:{stop(){n.stop(!0)}},localAddress:`127.0.0.1:${r}`,authEnv:{ANTHROPIC_BASE_URL:`http://127.0.0.1:${r}`,ANTHROPIC_AUTH_NONCE:t}}}i();var k=15e3,A=class extends Error{constructor(e){super(e),this.name=`SSHProbeError`}};async function j(e,t){t?.(`Probing remote host…`);let n=Bun.spawn([`ssh`,`-o`,`BatchMode=yes`,`-o`,`ConnectTimeout=10`,e,`CLAUDE_BIN=$(test -x "$HOME/.local/bin/claude" && echo "$HOME/.local/bin/claude" || command -v claude 2>/dev/null); echo "$CLAUDE_BIN"; $CLAUDE_BIN --version 2>/dev/null; uname -sm; pwd`],{stdin:`ignore`,stdout:`pipe`,stderr:`pipe`}),r=await Promise.race([n.exited,new Promise((e,t)=>setTimeout(()=>t(new A(`SSH probe timed out after ${k/1e3}s`)),k))]),i=await new Response(n.stdout).text(),o=await new Response(n.stderr).text();if(r!==0)throw new A(`SSH probe failed: ${o.trim()||`exit code ${r}`}`);let s=i.split(`
4
4
  `).map(e=>e.trim()).filter(Boolean);a(`[SSHProbe] raw lines: ${JSON.stringify(s)}`);let c=s.findIndex(e=>/^(Linux|Darwin)\s/.test(e));if(c===-1)throw new A(`Could not detect remote platform (uname output missing)`);let l=c>=2&&s[c-2]||null,u=c>=1&&s[c-1]||null,d=u&&/^\d+\.\d+/.test(u)?u:null,f=l!==null&&l.startsWith(`/`),p=s[c+1]||`/`,[m,h]=s[c].split(/\s+/),g=m===`Darwin`?`darwin`:`linux`,_=h===`aarch64`||h===`arm64`?`arm64`:`x64`;return t?.(`Detected ${g}/${_}`),{hasBinary:f&&d!==null,remoteVersion:d,remotePlatform:g,remoteArch:_,defaultCwd:p,binaryPath:f?l:null}}i();var M=6e4,N=`~/.local/bin`,P=`claude-code-cli.js`,F=`claude`;async function I(e,t,n=M){let r=Bun.spawn([`ssh`,`-o`,`ConnectTimeout=10`,e,t],{stdout:`pipe`,stderr:`pipe`}),i=setTimeout(()=>r.kill(),n);try{let[e,t]=await Promise.all([new Response(r.stdout).text(),new Response(r.stderr).text()]),n=await r.exited;return{stdout:e.trim(),stderr:t.trim(),exitCode:n}}finally{clearTimeout(i)}}function L(){let e=p(import.meta.dir,`../..`),t=p(e,`dist/cli.js`);if(m(t))return t;let n=p(e,`src/entrypoints/cli.tsx`);if(m(n))return n;throw Error("Cannot find local CLI binary to deploy. Run `bun run build` first.")}async function R(e){let{host:t,remotePlatform:n,remoteArch:r,localVersion:i,onProgress:o}=e;if(n!==`linux`&&n!==`darwin`)throw Error(`Remote platform "${n}" is not supported. Only linux and darwin are supported.`);a(`[SSHDeploy] deploying to ${t} (${n}/${r}, v${i})`);let s=L();a(`[SSHDeploy] local binary: ${s}`),o?.(`Creating remote directory...`);let c=await I(t,`mkdir -p ${N}`);if(c.exitCode!==0)throw Error(`Failed to create remote directory: ${c.stderr}`);o?.(`Uploading binary...`);let l=`${N}/${P}`,u=Bun.spawn([`scp`,`-o`,`ConnectTimeout=10`,s,`${t}:${l}`],{stdout:`pipe`,stderr:`pipe`}),d=setTimeout(()=>u.kill(),M),f=await new Response(u.stderr).text(),p=await u.exited;if(clearTimeout(d),p!==0)throw Error(`SCP upload failed (exit ${p}): ${f.trim()}`);o?.(`Installing wrapper script...`);let m=await I(t,[`cat > ${N}/${F} << 'WRAPPER'`,`#!/bin/sh`,`exec bun ${N}/${P} "$@"`,`WRAPPER`,`chmod +x ${N}/${F}`].join(`
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{F as t,a as n,l as r,z as i}from"./debug-BrXObCdR.js";import{c as a,d as o,i as s,o as c}from"./debugUtils-NO5KtXqi.js";async function l({environmentId:e,title:n,events:i,gitRepoUrl:a,branch:o,signal:c,baseUrl:l,getAccessToken:u,permissionMode:d}){let{getClaudeAIOAuthTokens:f}=await import(`./auth-BQa4kzQo.js`),{getOrganizationUUID:p}=await import(`./client-Bup0Sgcn.js`),{getOauthConfig:m}=await import(`./oauth-C8X_p8Gc.js`),{getOAuthHeaders:h}=await import(`./api-BiwZmmsh.js`),{parseGitHubRepository:g}=await import(`./detectRepository-BTPgN89l.js`),{getDefaultBranch:_}=await import(`./git-CbcnOf0E.js`),{getMainLoopModel:v}=await import(`./model-DvrvG6BB.js`),{default:y}=await import(`./axios-BHBm_hhU.js`),{isSelfHostedBridge:b}=await import(`./bridgeConfig-DWEqKbXk.js`),x=u?.()??f()?.accessToken;if(!x)return r(`[bridge] No access token for session creation`),null;let S=b()?`self-hosted`:await p();if(!S)return r(`[bridge] No org UUID for session creation`),null;let C=null,w=null;if(a){let{parseGitRemote:e}=await import(`./detectRepository-BTPgN89l.js`),t=e(a);if(t){let{host:e,owner:n,name:r}=t,i=o||await _()||void 0;C={type:`git_repository`,url:`https://${e}/${n}/${r}`,revision:i},w={type:`git_repository`,git_info:{type:`github`,repo:`${n}/${r}`,branches:[`claude/${o||`task`}`]}}}else{let e=g(a);if(e){let[t,n]=e.split(`/`);if(t&&n){let e=o||await _()||void 0;C={type:`git_repository`,url:`https://github.com/${t}/${n}`,revision:e},w={type:`git_repository`,git_info:{type:`github`,repo:`${t}/${n}`,branches:[`claude/${o||`task`}`]}}}}}}let T={...n!==void 0&&{title:n},events:i,session_context:{sources:C?[C]:[],outcomes:w?[w]:[],model:v()},environment_id:e,source:`remote-control`,...d&&{permission_mode:d}},E={...h(x),"anthropic-beta":`ccr-byoc-2025-07-29`,"x-organization-uuid":S},D=`${l??m().BASE_API_URL}/v1/sessions`,O;try{O=await y.post(D,T,{headers:E,signal:c,validateStatus:e=>e<500})}catch(e){return r(`[bridge] Session creation request failed: ${t(e)}`),null}if(!(O.status===200||O.status===201)){let e=s(O.data);return r(`[bridge] Session creation failed with status ${O.status}${e?`: ${e}`:``}`),null}let k=O.data;return!k||typeof k!=`object`||!(`id`in k)||typeof k.id!=`string`?(r(`[bridge] No session ID in response`),null):k.id}async function u(e,n){let{getClaudeAIOAuthTokens:i}=await import(`./auth-BQa4kzQo.js`),{getOrganizationUUID:a}=await import(`./client-Bup0Sgcn.js`),{getOauthConfig:o}=await import(`./oauth-C8X_p8Gc.js`),{getOAuthHeaders:c}=await import(`./api-BiwZmmsh.js`),{default:l}=await import(`./axios-BHBm_hhU.js`),{isSelfHostedBridge:u}=await import(`./bridgeConfig-DWEqKbXk.js`),d=n?.getAccessToken?.()??i()?.accessToken;if(!d)return r(`[bridge] No access token for session fetch`),null;let f=u()?`self-hosted`:await a();if(!f)return r(`[bridge] No org UUID for session fetch`),null;let p={...c(d),"anthropic-beta":`ccr-byoc-2025-07-29`,"x-organization-uuid":f},m=`${n?.baseUrl??o().BASE_API_URL}/v1/sessions/${e}`;r(`[bridge] Fetching session ${e}`);let h;try{h=await l.get(m,{headers:p,timeout:1e4,validateStatus:e=>e<500})}catch(e){return r(`[bridge] Session fetch request failed: ${t(e)}`),null}if(h.status!==200){let e=s(h.data);return r(`[bridge] Session fetch failed with status ${h.status}${e?`: ${e}`:``}`),null}return h.data}async function d(e,t){let{getClaudeAIOAuthTokens:n}=await import(`./auth-BQa4kzQo.js`),{getOrganizationUUID:i}=await import(`./client-Bup0Sgcn.js`),{getOauthConfig:a}=await import(`./oauth-C8X_p8Gc.js`),{getOAuthHeaders:o}=await import(`./api-BiwZmmsh.js`),{default:c}=await import(`./axios-BHBm_hhU.js`),{isSelfHostedBridge:l}=await import(`./bridgeConfig-DWEqKbXk.js`),u=t?.getAccessToken?.()??n()?.accessToken;if(!u){r(`[bridge] No access token for session archive`);return}let d=l()?`self-hosted`:await i();if(!d){r(`[bridge] No org UUID for session archive`);return}let f={...o(u),"anthropic-beta":`ccr-byoc-2025-07-29`,"x-organization-uuid":d},p=`${t?.baseUrl??a().BASE_API_URL}/v1/sessions/${e}/archive`;r(`[bridge] Archiving session ${e}`);let m=await c.post(p,{},{headers:f,timeout:t?.timeoutMs??1e4,validateStatus:e=>e<500});if(m.status===200)r(`[bridge] Session ${e} archived successfully`);else{let e=s(m.data);r(`[bridge] Session archive failed with status ${m.status}${e?`: ${e}`:``}`)}}async function f(e,n,i){let{getClaudeAIOAuthTokens:a}=await import(`./auth-BQa4kzQo.js`),{getOrganizationUUID:c}=await import(`./client-Bup0Sgcn.js`),{getOauthConfig:l}=await import(`./oauth-C8X_p8Gc.js`),{getOAuthHeaders:u}=await import(`./api-BiwZmmsh.js`),{default:d}=await import(`./axios-BHBm_hhU.js`),{isSelfHostedBridge:f}=await import(`./bridgeConfig-DWEqKbXk.js`),p=i?.getAccessToken?.()??a()?.accessToken;if(!p){r(`[bridge] No access token for session title update`);return}let m=f()?`self-hosted`:await c();if(!m){r(`[bridge] No org UUID for session title update`);return}let h={...u(p),"anthropic-beta":`ccr-byoc-2025-07-29`,"x-organization-uuid":m},g=o(e),_=`${i?.baseUrl??l().BASE_API_URL}/v1/sessions/${g}`;r(`[bridge] Updating session title: ${g} → ${n}`);try{let e=await d.patch(_,{title:n},{headers:h,timeout:1e4,validateStatus:e=>e<500});if(e.status===200)r(`[bridge] Session title updated successfully`);else{let t=s(e.data);r(`[bridge] Session title update failed with status ${e.status}${t?`: ${t}`:``}`)}}catch(e){r(`[bridge] Session title update request failed: ${t(e)}`)}}var p=e((()=>{n(),i(),c(),a()}));export{f as a,p as i,l as n,u as r,d as t};
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{F as t,a as n,l as r,z as i}from"./debug-BrXObCdR.js";import{c as a,d as o,i as s,o as c}from"./debugUtils-NO5KtXqi.js";async function l({environmentId:e,title:n,events:i,gitRepoUrl:a,branch:o,signal:c,baseUrl:l,getAccessToken:u,permissionMode:d}){let{getClaudeAIOAuthTokens:f}=await import(`./auth-D_cGl8WD.js`),{getOrganizationUUID:p}=await import(`./client-DKXCfdde.js`),{getOauthConfig:m}=await import(`./oauth-C8X_p8Gc.js`),{getOAuthHeaders:h}=await import(`./api-CG-lhKe-.js`),{parseGitHubRepository:g}=await import(`./detectRepository-BTPgN89l.js`),{getDefaultBranch:_}=await import(`./git-CbcnOf0E.js`),{getMainLoopModel:v}=await import(`./model-DLLkVV6S.js`),{default:y}=await import(`./axios-BHBm_hhU.js`),{isSelfHostedBridge:b}=await import(`./bridgeConfig-DP9dD1Cv.js`),x=u?.()??f()?.accessToken;if(!x)return r(`[bridge] No access token for session creation`),null;let S=b()?`self-hosted`:await p();if(!S)return r(`[bridge] No org UUID for session creation`),null;let C=null,w=null;if(a){let{parseGitRemote:e}=await import(`./detectRepository-BTPgN89l.js`),t=e(a);if(t){let{host:e,owner:n,name:r}=t,i=o||await _()||void 0;C={type:`git_repository`,url:`https://${e}/${n}/${r}`,revision:i},w={type:`git_repository`,git_info:{type:`github`,repo:`${n}/${r}`,branches:[`claude/${o||`task`}`]}}}else{let e=g(a);if(e){let[t,n]=e.split(`/`);if(t&&n){let e=o||await _()||void 0;C={type:`git_repository`,url:`https://github.com/${t}/${n}`,revision:e},w={type:`git_repository`,git_info:{type:`github`,repo:`${t}/${n}`,branches:[`claude/${o||`task`}`]}}}}}}let T={...n!==void 0&&{title:n},events:i,session_context:{sources:C?[C]:[],outcomes:w?[w]:[],model:v()},environment_id:e,source:`remote-control`,...d&&{permission_mode:d}},E={...h(x),"anthropic-beta":`ccr-byoc-2025-07-29`,"x-organization-uuid":S},D=`${l??m().BASE_API_URL}/v1/sessions`,O;try{O=await y.post(D,T,{headers:E,signal:c,validateStatus:e=>e<500})}catch(e){return r(`[bridge] Session creation request failed: ${t(e)}`),null}if(!(O.status===200||O.status===201)){let e=s(O.data);return r(`[bridge] Session creation failed with status ${O.status}${e?`: ${e}`:``}`),null}let k=O.data;return!k||typeof k!=`object`||!(`id`in k)||typeof k.id!=`string`?(r(`[bridge] No session ID in response`),null):k.id}async function u(e,n){let{getClaudeAIOAuthTokens:i}=await import(`./auth-D_cGl8WD.js`),{getOrganizationUUID:a}=await import(`./client-DKXCfdde.js`),{getOauthConfig:o}=await import(`./oauth-C8X_p8Gc.js`),{getOAuthHeaders:c}=await import(`./api-CG-lhKe-.js`),{default:l}=await import(`./axios-BHBm_hhU.js`),{isSelfHostedBridge:u}=await import(`./bridgeConfig-DP9dD1Cv.js`),d=n?.getAccessToken?.()??i()?.accessToken;if(!d)return r(`[bridge] No access token for session fetch`),null;let f=u()?`self-hosted`:await a();if(!f)return r(`[bridge] No org UUID for session fetch`),null;let p={...c(d),"anthropic-beta":`ccr-byoc-2025-07-29`,"x-organization-uuid":f},m=`${n?.baseUrl??o().BASE_API_URL}/v1/sessions/${e}`;r(`[bridge] Fetching session ${e}`);let h;try{h=await l.get(m,{headers:p,timeout:1e4,validateStatus:e=>e<500})}catch(e){return r(`[bridge] Session fetch request failed: ${t(e)}`),null}if(h.status!==200){let e=s(h.data);return r(`[bridge] Session fetch failed with status ${h.status}${e?`: ${e}`:``}`),null}return h.data}async function d(e,t){let{getClaudeAIOAuthTokens:n}=await import(`./auth-D_cGl8WD.js`),{getOrganizationUUID:i}=await import(`./client-DKXCfdde.js`),{getOauthConfig:a}=await import(`./oauth-C8X_p8Gc.js`),{getOAuthHeaders:o}=await import(`./api-CG-lhKe-.js`),{default:c}=await import(`./axios-BHBm_hhU.js`),{isSelfHostedBridge:l}=await import(`./bridgeConfig-DP9dD1Cv.js`),u=t?.getAccessToken?.()??n()?.accessToken;if(!u){r(`[bridge] No access token for session archive`);return}let d=l()?`self-hosted`:await i();if(!d){r(`[bridge] No org UUID for session archive`);return}let f={...o(u),"anthropic-beta":`ccr-byoc-2025-07-29`,"x-organization-uuid":d},p=`${t?.baseUrl??a().BASE_API_URL}/v1/sessions/${e}/archive`;r(`[bridge] Archiving session ${e}`);let m=await c.post(p,{},{headers:f,timeout:t?.timeoutMs??1e4,validateStatus:e=>e<500});if(m.status===200)r(`[bridge] Session ${e} archived successfully`);else{let e=s(m.data);r(`[bridge] Session archive failed with status ${m.status}${e?`: ${e}`:``}`)}}async function f(e,n,i){let{getClaudeAIOAuthTokens:a}=await import(`./auth-D_cGl8WD.js`),{getOrganizationUUID:c}=await import(`./client-DKXCfdde.js`),{getOauthConfig:l}=await import(`./oauth-C8X_p8Gc.js`),{getOAuthHeaders:u}=await import(`./api-CG-lhKe-.js`),{default:d}=await import(`./axios-BHBm_hhU.js`),{isSelfHostedBridge:f}=await import(`./bridgeConfig-DP9dD1Cv.js`),p=i?.getAccessToken?.()??a()?.accessToken;if(!p){r(`[bridge] No access token for session title update`);return}let m=f()?`self-hosted`:await c();if(!m){r(`[bridge] No org UUID for session title update`);return}let h={...u(p),"anthropic-beta":`ccr-byoc-2025-07-29`,"x-organization-uuid":m},g=o(e),_=`${i?.baseUrl??l().BASE_API_URL}/v1/sessions/${g}`;r(`[bridge] Updating session title: ${g} → ${n}`);try{let e=await d.patch(_,{title:n},{headers:h,timeout:1e4,validateStatus:e=>e<500});if(e.status===200)r(`[bridge] Session title updated successfully`);else{let t=s(e.data);r(`[bridge] Session title update failed with status ${e.status}${t?`: ${t}`:``}`)}}catch(e){r(`[bridge] Session title update request failed: ${t(e)}`)}}var p=e((()=>{n(),i(),c(),a()}));export{f as a,p as i,l as n,u as r,d as t};
@@ -0,0 +1 @@
1
+ import{a as e,i as t,n,r}from"./createSession-8Ei-Lj7V.js";t();export{n as createBridgeSession,r as getBridgeSession,e as updateBridgeSessionTitle};
@@ -0,0 +1,40 @@
1
+ import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{n,t as r}from"./figures-5ThXQEtq.js";import{C as i,D as a,Gr as o,H as s,I as c,P as l,T as u,Wt as d,Xn as f,ai as p,di as m,fi as h,hn as ee,k as te,ot as ne,p as g,t as _,ui as v}from"./src-CDCSSo0U2.js";import{t as y}from"./jsx-runtime-Bb4Xn-E0.js";import{en as b,ht as re,nt as ie}from"./state-ix0xIunV.js";import{Cr as x,Dh as ae,Eb as S,Ex as oe,Fi as se,Fr as C,Ib as ce,Lb as w,Nr as le,Oh as ue,Pi as de,Tx as fe,Uu as pe,Vu as me,Wr as he,XS as T,ax as ge,fx as E,hr as _e,ix as ve,jr as D,px as ye,vi as be,wb as xe}from"./loadAgentsDir-x3rlgED4.js";import{C as Se,S as Ce,a as we,l as O}from"./debug-BrXObCdR.js";import{vn as Te,yn as Ee}from"./settings-BeLFUeie.js";import{_ as k,i as De}from"./git-Do0wJvux.js";import{a as A,o as Oe,s as ke}from"./log-BMCygSzM.js";import{n as Ae,r as j}from"./analytics-BotDBGh0.js";import{T as je,b as M,f as Me,h as Ne}from"./startupProfiler-xa3NmN7Z.js";import{_ as Pe,h as Fe}from"./model-CZViyZnE.js";import{i as N,r as P}from"./shellQuote-DkSy9MYE.js";import{u as Ie}from"./referral-CKmHHxj_.js";import{n as Le,t as Re}from"./useExitOnCtrlCDWithKeybindings-BwsZ5f0s.js";import{t as ze}from"./SearchBox-vfLXEPed.js";import{n as Be,t as Ve}from"./useSearchInput-C5OzQnX6.js";import{d as He,n as F,t as Ue,u as We}from"./Messages-D4Hm4gaY.js";import{sep as I}from"path";function Ge({log:e,onExit:t,onSelect:n}){let[r,i]=L.useState(null);L.useEffect(()=>{i(null),C(e)&&he(e).then(i)},[e]);let o=C(e)&&r===null,s=r??e,f=x(s)||``,p=me();return d(`confirm:no`,t,{context:`Confirmation`}),d(`confirm:yes`,(0,L.useCallback)(()=>{n(r??e)},[n,r,e]),{context:`Confirmation`}),o?(0,R.jsxs)(c,{flexDirection:`column`,padding:1,children:[(0,R.jsx)(g,{message:`Loading session…`}),(0,R.jsx)(l,{dimColor:!0,children:(0,R.jsx)(u,{children:(0,R.jsx)(E,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})})})]}):(0,R.jsxs)(c,{flexDirection:`column`,children:[(0,R.jsx)(Ue,{messages:s.messages,tools:p,commands:[],verbose:!0,toolJSX:null,toolUseConfirmQueue:[],inProgressToolUseIDs:new Set,isMessageSelectorVisible:!1,conversationId:f,screen:`transcript`,streamingToolUses:[],showAllInTranscript:!0,isLoading:!1}),(0,R.jsxs)(c,{flexShrink:0,flexDirection:`column`,borderTopDimColor:!0,borderBottom:!1,borderLeft:!1,borderRight:!1,borderStyle:`single`,paddingLeft:2,children:[(0,R.jsxs)(l,{children:[Ne(s.modified),` · `,s.messageCount,` messages`,s.gitBranch?` · ${s.gitBranch}`:``]}),(0,R.jsx)(l,{dimColor:!0,children:(0,R.jsxs)(u,{children:[(0,R.jsx)(a,{shortcut:`Enter`,action:`resume`}),(0,R.jsx)(E,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]})})]})]})}var L,R,z=e((()=>{L=t(h(),1),_(),Ie(),pe(),M(),D(),ye(),F(),R=y()}));function Ke(e,t){if(e===V)return 5;let n=o(e),r=t?Math.min(n,t-H-U):n;return Math.max(0,r)+H+U}function qe(e,t){let n=t-H-U;return o(e)<=n?e:n<=1?e.charAt(0):je(e,n)}function Je({tabs:e,selectedIndex:t,availableWidth:n,showAllProjects:r=!1}){let i=r?`Resume (All Projects)`:`Resume`,a=i.length+1,o=Math.max(et,W),s=n-a-o-2,u=Math.max(0,Math.min(t,e.length-1)),d=Math.max(20,Math.floor(s/2)),f=e.map(e=>Ke(e,d)),p=0,m=e.length;if(f.reduce((e,t,n)=>e+t+ +(n<f.length-1),0)>s){let t=s-$e,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 h=p,ee=e.length-m,te=e.slice(p,m),ne=te.map((e,t)=>p+t);return(0,B.jsxs)(c,{flexDirection:`row`,gap:1,children:[(0,B.jsx)(l,{color:`suggestion`,children:i}),h>0&&(0,B.jsxs)(l,{dimColor:!0,children:[Ye,h]}),te.map((e,t)=>{let n=ne[t]===u,r=e===V?e:`#${qe(e,d-H)}`;return(0,B.jsxs)(l,{backgroundColor:n?`suggestion`:void 0,color:n?`inverseText`:void 0,bold:n,children:[` `,r,` `]},e)}),ee>0?(0,B.jsxs)(l,{dimColor:!0,children:[Xe,ee,Ze]}):(0,B.jsx)(l,{dimColor:!0,children:Qe})]})}var B,V,H,U,Ye,Xe,Ze,Qe,$e,et,W,G=e((()=>{h(),_(),M(),B=y(),V=`All`,H=2,U=1,Ye=`← `,Xe=`→`,Ze=` (tab to cycle)`,Qe=`(tab to cycle)`,$e=5,et=18,W=14}));function tt({nodes:e,onSelect:t,onCancel:n,onFocus:r,focusNodeId:i,visibleOptionCount:a,layout:o=`expanded`,isDisabled:s=!1,hideIndexes:l=!1,isNodeExpanded:u,onExpand:d,onCollapse:f,getParentPrefix:p,getChildPrefix:m,onUpFromFirstItem:h}){let[ee,te]=K.useState(new Set),ne=K.useRef(!1),g=K.useRef(null),_=K.useCallback(e=>u?u(e):ee.has(e),[u,ee]),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,_]),y=K.useCallback(e=>e?`▼ `:`▶ `,[]),b=K.useCallback(e=>` ▸ `,[]),re=p??y,ie=m??b,x=K.useCallback(e=>{let t=``;return e.hasChildren?t=re(e.isExpanded):e.depth>0&&(t=ie(e.depth)),t+e.node.label},[re,ie]),ae=K.useMemo(()=>v.map(e=>({label:x(e),description:e.node.description,dimDescription:e.node.dimDescription??!0,value:e.node.id})),[v,x]),S=K.useMemo(()=>{let e=new Map;return v.forEach(t=>e.set(t.node.id,t.node)),e},[v]),oe=K.useCallback(e=>v.find(t=>t.node.id===e),[v]),se=K.useCallback((e,t)=>{let n=oe(e);!n||!n.hasChildren||(t?d?d(e):te(t=>new Set(t).add(e)):f?f(e):te(t=>{let n=new Set(t);return n.delete(e),n}))},[oe,d,f]);return(0,nt.jsx)(c,{tabIndex:0,autoFocus:!0,onKeyDown:e=>{if(!i||s)return;let t=oe(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(),ne.current=!0,se(t.parentId,!1),r)){let e=S.get(t.parentId);e&&r(e)}}}},children:(0,nt.jsx)(ve,{options:ae,onChange:K.useCallback(e=>{let n=S.get(e);n&&t(n)},[S,t]),onFocus:K.useCallback(e=>{if(ne.current){ne.current=!1;return}if(g.current!==e&&(g.current=e,r)){let t=S.get(e);t&&r(t)}},[r,S]),onCancel:n,defaultFocusValue:i,visibleOptionCount:a,layout:o,isDisabled:s,hideIndexes:l,onUpFromFirstItem:h})})}var K,nt,rt=e((()=>{K=t(h(),1),_(),ge(),nt=y()}));function it(e,t){return je(e.replace(/\s+/g,` `).trim(),t)}function at({before:e,match:t,after:n},r){return v.dim(e)+r(t)+v.dim(n)}function ot(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 st(e,t,n){let{isGroupHeader:r=!1,isChild:i=!1,forkCount:a=0}=n||{},o=r&&a>0?mt:i?ht:0,s=r&&a>0?` (+${a} other ${a===1?`session`:`sessions`})`:``,c=e.isSidechain?` (sidechain)`:``,l=t-o-c.length-s.length;return`${it(A(e),l)}${c}${s}`}function ct(e,t){let{isChild:n=!1,showProjectPath:r=!1}=t||{},i=n?` `:``,a=Me(e),o=r&&e.projectPath?` · ${e.projectPath}`:``;return i+a+o}function lt({logs:e,maxHeight:t=1/0,forceWidth:n,onCancel:o,onSelect:m,onLogsChanged:h,onLoadMore:g,initialSearchQuery:_,showAllProjects:v=!1,onToggleAllProjects:y,onAgenticSearch:b}){let ae=ne(),S=n===void 0?ae.columns:n,oe=Le(o),se=f(),C=le(),w=process.env.USER_TYPE===`ant`,[ue]=s(),pe=ce(ue),me=q.useMemo(()=>e=>p(e,pe.warning),[pe.warning]),he=process.env.USER_TYPE===`ant`,[T,ge]=q.useState(null),[D,ye]=q.useState(!1),[Se,Ce]=q.useState(!1),[we,O]=q.useState(!1),Te=q.useMemo(()=>ie(),[]),[Ee,k]=q.useState(``),[Oe,ke]=q.useState(0),[Ae,je]=q.useState(new Set),[M,Ne]=q.useState(null),[Pe,Fe]=q.useState(1),[N,P]=q.useState(`list`),[Ie,Re]=q.useState(null),ze=q.useRef(null),[Ve,He]=q.useState(0),[F,Ue]=q.useState({status:`idle`}),[I,L]=q.useState(!1),R=q.useRef(null),{query:z,setQuery:Ke,cursorOffset:qe}=Be({isActive:N===`search`&&F.status!==`searching`,onExit:()=>{P(`list`),j(`tengu_session_search_toggled`,{enabled:!1})},onExitUp:()=>{P(`list`),j(`tengu_session_search_toggled`,{enabled:!1})},passthroughCtrlKeys:[`n`],initialQuery:_||``}),B=q.useDeferredValue(z),[V,H]=q.useState(``);q.useEffect(()=>{if(!B){H(``);return}let e=setTimeout(H,300,B);return()=>clearTimeout(e)},[B]);let[U,Ye]=q.useState(null),[Xe,Ze]=q.useState(!1);q.useEffect(()=>{De().then(e=>ge(e)),de(Te).then(e=>{O(e.length>1)})},[Te]);let Qe=q.useMemo(()=>new Map(e.map(e=>[e,dt(e)])),[e]),$e=q.useMemo(()=>w?new We(e.map(e=>({log:e,searchableText:Qe.get(e)??``})).filter(e=>e.searchableText),{keys:[`searchableText`],threshold:gt,ignoreLocation:!0,includeScore:!0}):null,[e,Qe,w]),et=q.useMemo(()=>pt(e),[e]),W=et.length>0,G=q.useMemo(()=>W?[`All`,...et]:[],[W,et]),K=G.length>0&&Ve<G.length?Ve:0,nt=G[K],rt=nt===`All`?void 0:nt,lt=+!!W,ut=q.useMemo(()=>{let t=e;return C&&(t=e.filter(e=>{let t=re(),n=x(e);return!!(t&&n===t||e.customTitle||_e(e.messages)||e.firstPrompt||e.customTitle)})),rt!==void 0&&(t=t.filter(e=>e.tag===rt)),D&&T&&(t=t.filter(e=>e.gitBranch===T)),we&&!Se&&(t=t.filter(e=>e.projectPath===Te)),t},[e,C,rt,D,T,we,Se,Te]),mt=q.useMemo(()=>{if(!z)return ut;let e=z.toLowerCase();return ut.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)})},[ut,z]);q.useEffect(()=>{w&&B&&B!==V&&Ze(!0)},[B,V,w]),q.useEffect(()=>{if(!w||!V||!$e){Ye(null),Ze(!1);return}let e=setTimeout((e,t,n,r)=>{let i=e.search(t);i.sort((e,t)=>{let n=new Date(e.item.log.modified).getTime(),r=new Date(t.item.log.modified).getTime()-n;return Math.abs(r)>_t?r:(e.score??1)-(t.score??1)}),n({results:i.map(e=>({log:e.item.log,score:e.score,searchableText:e.item.searchableText})),query:t}),r(!1)},0,$e,V,Ye,Ze);return()=>{clearTimeout(e)}},[V,$e,w]);let{filteredLogs:ht,snippets:Y}=q.useMemo(()=>{let e=new Map,t=mt;if(U&&V&&U.query===V){for(let t of U.results)if(t.searchableText){let n=ot(t.searchableText,V,vt);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}},[mt,U,V]),X=q.useMemo(()=>F.status===`results`&&F.results.length>0?F.results:ht,[F,ht]),Z=Math.max(30,S-4),yt=q.useMemo(()=>{if(!C)return[];let e=ft(X);return Array.from(e.entries()).map(([e,t])=>{let n=t[0],r=X.indexOf(n),i=Y.get(n),a=i?at(i,me):null;if(t.length===1){let t=ct(n,{showProjectPath:v});return{id:`log:${e}:0`,value:{log:n,indexInFiltered:r},label:st(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?at(i,me):null,o=ct(t,{isChild:!0,showProjectPath:v});return{id:`log:${e}:${n+1}`,value:{log:t,indexInFiltered:r},label:st(t,Z,{isChild:!0}),description:a?`${o}\n ${a}`:o,dimDescription:!0}}),c=ct(n,{showProjectPath:v});return{id:`group:${e}`,value:{log:n,indexInFiltered:r},label:st(n,Z,{isGroupHeader:!0,forkCount:o}),description:a?`${c}\n ${a}`:c,dimDescription:!0,children:s}})},[C,X,Z,v,Y,me]),bt=q.useMemo(()=>C?[]:X.map((e,t)=>{let n=it(A(e)+(e.isSidechain?` (sidechain)`:``),Z),r=Me(e),i=v&&e.projectPath?` · ${e.projectPath}`:``,a=Y.get(e),o=a?at(a,me):null;return{label:n,description:o?`${r}${i}\n ${o}`:r+i,dimDescription:!0,value:t.toString()}}),[C,X,me,Z,v,Y]),Q=M?.value.log??null,xt=()=>{if(!C||!Q)return``;let e=x(Q);if(!e)return``;let t=X.filter(t=>x(t)===e);if(!(t.length>1))return``;let n=Ae.has(e);return t.indexOf(Q)>0||n?`← to collapse`:`→ to expand`},St=q.useCallback(async()=>{let e=Q?x(Q):void 0;if(!Q||!e){P(`list`),k(``);return}Ee.trim()&&(await be(e,Ee.trim(),Q.fullPath),C&&h&&h()),P(`list`),k(``)},[Q,Ee,h,C]),Ct=q.useCallback(()=>{P(`list`),j(`tengu_session_search_toggled`,{enabled:!1})},[]),wt=q.useCallback(()=>{P(`search`),j(`tengu_session_search_toggled`,{enabled:!0})},[]),Tt=q.useCallback(async()=>{if(!z.trim()||!b||!he)return;R.current?.abort();let t=new AbortController;R.current=t,Ue({status:`searching`}),j(`tengu_agentic_search_started`,{query_length:z.length});try{let n=await b(z,e,t.signal);if(t.signal.aborted)return;Ue({status:`results`,results:n,query:z}),j(`tengu_agentic_search_completed`,{query_length:z.length,results_count:n.length})}catch(e){if(t.signal.aborted)return;Ue({status:`error`,message:e instanceof Error?e.message:`Search failed`}),j(`tengu_agentic_search_error`,{query_length:z.length})}},[z,b,he,e]);q.useEffect(()=>{F.status!==`idle`&&F.status!==`searching`&&(F.status===`results`&&F.query!==z||F.status===`error`)&&Ue({status:`idle`})},[z,F]),q.useEffect(()=>()=>{R.current?.abort()},[]);let Et=q.useRef(F.status);q.useEffect(()=>{let e=Et.current;if(Et.current=F.status,e===`searching`&&F.status===`results`){if(C&&yt.length>0)Ne(yt[0]);else if(!C&&X.length>0){let e=X[0];Ne({id:`0`,value:{log:e,indexInFiltered:0},label:``})}}},[F.status,C,yt,X]);let Dt=q.useCallback(e=>{let t=parseInt(e,10),n=X[t];!n||ze.current===t.toString()||(ze.current=t.toString(),Ne({id:t.toString(),value:{log:n,indexInFiltered:t},label:``}),Fe(t+1))},[X]),Ot=q.useCallback(e=>{Ne(e);let t=X.findIndex(t=>x(t)===x(e.value.log));t>=0&&Fe(t+1)},[X]);d(`confirm:no`,()=>{R.current?.abort(),Ue({status:`idle`}),j(`tengu_agentic_search_cancelled`,{})},{context:`Confirmation`,isActive:N!==`preview`&&F.status===`searching`}),d(`confirm:no`,()=>{P(`list`),k(``)},{context:`Settings`,isActive:N===`rename`&&F.status!==`searching`}),d(`confirm:no`,()=>{Ke(``),L(!1),o?.()},{context:`Confirmation`,isActive:N!==`preview`&&N!==`rename`&&N!==`search`&&I&&F.status!==`searching`}),ee((e,t)=>{if(N!==`preview`&&F.status!==`searching`&&N!==`rename`)if(N===`search`)e.toLowerCase()===`n`&&t.ctrl?Ct():(t.return||t.downArrow)&&z.trim()&&b&&he&&F.status!==`results`&&L(!0);else{if(I){if(t.return){Tt(),L(!1);return}else if(t.downArrow){L(!1);return}else if(t.upArrow){P(`search`),L(!1);return}}if(W&&t.tab){let e=t.shift?-1:1;He(t=>{let n=((t<G.length?t:0)+G.length+e)%G.length,r=G[n];return j(`tengu_session_tag_filter_changed`,{is_all:r===`All`,tag_count:et.length}),n});return}let n=!t.ctrl&&!t.meta,r=e.toLowerCase();if(r===`a`&&t.ctrl&&y)y(),j(`tengu_session_all_projects_toggled`,{enabled:!v});else if(r===`b`&&t.ctrl){let e=!D;ye(e),j(`tengu_session_branch_filter_toggled`,{enabled:e})}else if(r===`w`&&t.ctrl&&we){let e=!Se;Ce(e),j(`tengu_session_worktree_filter_toggled`,{enabled:e})}else r===`/`&&n?(P(`search`),j(`tengu_session_search_toggled`,{enabled:!0})):r===`r`&&t.ctrl&&Q?(P(`rename`),k(``),j(`tengu_session_rename_started`,{})):r===`v`&&t.ctrl&&Q?(Re(Q),P(`preview`),j(`tengu_session_preview_opened`,{messageCount:Q.messageCount})):Q&&n&&e.length>0&&!/^\s+$/.test(e)&&(P(`search`),Ke(e),j(`tengu_session_search_toggled`,{enabled:!0}))}},{isActive:!0});let kt=[];D&&T&&kt.push(T),we&&!Se&&kt.push(`current worktree`);let At=8+ +(kt.length>0&&N!==`search`)+lt,$=Math.max(1,Math.floor((t-At-2)/3));return q.useEffect(()=>{if(!g)return;let e=$*2;Pe+e>=X.length&&g($*3)},[Pe,$,X.length,g]),e.length===0?null:N===`preview`&&Ie&&C?(0,J.jsx)(Ge,{log:Ie,onExit:()=>{P(`list`),Re(null)},onSelect:m}):(0,J.jsxs)(c,{flexDirection:`column`,height:t-1,children:[(0,J.jsx)(c,{flexShrink:0,children:(0,J.jsx)(i,{color:`suggestion`})}),(0,J.jsx)(c,{flexShrink:0,children:(0,J.jsx)(l,{children:` `})}),W?(0,J.jsx)(Je,{tabs:G,selectedIndex:K,availableWidth:S,showAllProjects:v}):(0,J.jsx)(c,{flexShrink:0,children:(0,J.jsxs)(l,{bold:!0,color:`suggestion`,children:[`Resume Session`,N===`list`&&X.length>$&&(0,J.jsxs)(l,{dimColor:!0,children:[` `,`(`,Pe,` of `,X.length,`)`]})]})}),(0,J.jsx)(te,{query:z,isFocused:N===`search`,isTerminalFocused:se,cursorOffset:qe}),kt.length>0&&N!==`search`&&(0,J.jsx)(c,{flexShrink:0,paddingLeft:2,children:(0,J.jsx)(l,{dimColor:!0,children:(0,J.jsx)(u,{children:kt})})}),(0,J.jsx)(c,{flexShrink:0,children:(0,J.jsx)(l,{children:` `})}),F.status===`searching`&&(0,J.jsxs)(c,{paddingLeft:1,flexShrink:0,children:[(0,J.jsx)(xe,{}),(0,J.jsx)(l,{children:` Searching…`})]}),F.status===`results`&&F.results.length>0&&(0,J.jsx)(c,{paddingLeft:1,marginBottom:1,flexShrink:0,children:(0,J.jsx)(l,{dimColor:!0,italic:!0,children:`Claude found these results:`})}),F.status===`results`&&F.results.length===0&&ht.length===0&&(0,J.jsx)(c,{paddingLeft:1,marginBottom:1,flexShrink:0,children:(0,J.jsx)(l,{dimColor:!0,italic:!0,children:`No matching sessions found.`})}),F.status===`error`&&ht.length===0&&(0,J.jsx)(c,{paddingLeft:1,marginBottom:1,flexShrink:0,children:(0,J.jsx)(l,{dimColor:!0,italic:!0,children:`No matching sessions found.`})}),!!z.trim()&&b&&he&&F.status!==`searching`&&F.status!==`results`&&F.status!==`error`&&(0,J.jsxs)(c,{flexShrink:0,flexDirection:`column`,children:[(0,J.jsxs)(c,{flexDirection:`row`,gap:1,children:[(0,J.jsx)(l,{color:I?`suggestion`:void 0,children:I?r.pointer:` `}),(0,J.jsx)(l,{color:I?`suggestion`:void 0,bold:I,children:`Search deeply using Claude →`})]}),(0,J.jsx)(c,{height:1})]}),F.status===`searching`?null:N===`rename`&&Q?(0,J.jsxs)(c,{paddingLeft:2,flexDirection:`column`,children:[(0,J.jsx)(l,{bold:!0,children:`Rename session:`}),(0,J.jsx)(c,{paddingTop:1,children:(0,J.jsx)(fe,{value:Ee,onChange:k,onSubmit:St,placeholder:A(Q,`Enter new session name`),columns:S,cursorOffset:Oe,onChangeCursorOffset:ke,showCursor:!0})})]}):C?(0,J.jsx)(tt,{nodes:yt,onSelect:e=>{m(e.value.log)},onFocus:Ot,onCancel:o,focusNodeId:M?.id,visibleOptionCount:$,layout:`expanded`,isDisabled:N===`search`||I,hideIndexes:!1,isNodeExpanded:e=>{if(N===`search`||D)return!0;let t=typeof e==`string`&&e.startsWith(`group:`)?e.substring(6):null;return t?Ae.has(t):!1},onExpand:e=>{let t=typeof e==`string`&&e.startsWith(`group:`)?e.substring(6):null;t&&(je(e=>new Set(e).add(t)),j(`tengu_session_group_expanded`,{}))},onCollapse:e=>{let t=typeof e==`string`&&e.startsWith(`group:`)?e.substring(6):null;t&&je(e=>{let n=new Set(e);return n.delete(t),n})},onUpFromFirstItem:wt}):(0,J.jsx)(ve,{options:bt,onChange:e=>{let t=X[parseInt(e,10)];t&&m(t)},visibleOptionCount:$,onCancel:o,onFocus:Dt,defaultFocusValue:M?.id.toString(),layout:`expanded`,isDisabled:N===`search`||I,onUpFromFirstItem:wt}),(0,J.jsx)(c,{paddingLeft:2,children:oe.pending?(0,J.jsxs)(l,{dimColor:!0,children:[`Press `,oe.keyName,` again to exit`]}):N===`rename`?(0,J.jsx)(l,{dimColor:!0,children:(0,J.jsxs)(u,{children:[(0,J.jsx)(a,{shortcut:`Enter`,action:`save`}),(0,J.jsx)(E,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]})}):F.status===`searching`?(0,J.jsx)(l,{dimColor:!0,children:(0,J.jsxs)(u,{children:[(0,J.jsx)(l,{children:`Searching with Claude…`}),(0,J.jsx)(E,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]})}):I?(0,J.jsx)(l,{dimColor:!0,children:(0,J.jsxs)(u,{children:[(0,J.jsx)(a,{shortcut:`Enter`,action:`search`}),(0,J.jsx)(a,{shortcut:`↓`,action:`skip`}),(0,J.jsx)(E,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]})}):N===`search`?(0,J.jsx)(l,{dimColor:!0,children:(0,J.jsxs)(u,{children:[(0,J.jsx)(l,{children:Xe&&w?`Searching…`:`Type to Search`}),(0,J.jsx)(a,{shortcut:`Enter`,action:`select`}),(0,J.jsx)(E,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`clear`})]})}):(0,J.jsx)(l,{dimColor:!0,children:(0,J.jsxs)(u,{children:[y&&(0,J.jsx)(a,{shortcut:`Ctrl+A`,action:`show ${v?`current dir`:`all projects`}`}),T&&(0,J.jsx)(a,{shortcut:`Ctrl+B`,action:`toggle branch`}),we&&(0,J.jsx)(a,{shortcut:`Ctrl+W`,action:`show ${Se?`current worktree`:`all worktrees`}`}),(0,J.jsx)(a,{shortcut:`Ctrl+V`,action:`preview`}),(0,J.jsx)(a,{shortcut:`Ctrl+R`,action:`rename`}),(0,J.jsx)(l,{children:`Type to search`}),(0,J.jsx)(E,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`}),xt()&&(0,J.jsx)(l,{children:xt()})]})})})]})}function ut(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 dt(e){let t=(e.messages.length<=Y?e.messages:[...e.messages.slice(0,X),...e.messages.slice(-1e3)]).map(ut).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>Z?n.slice(0,Z):n}function ft(e){let t=new Map;for(let n of e){let e=x(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 pt(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,mt,ht,Y,X,Z,gt,_t,vt,yt=e((()=>{m(),n(),He(),q=t(h(),1),b(),Re(),Ve(),T(),_(),Ie(),Ae(),M(),se(),k(),Oe(),D(),w(),ye(),ge(),ze(),z(),S(),G(),oe(),rt(),J=y(),mt=2,ht=4,Y=2e3,X=1e3,Z=5e4,gt=.3,_t=60*1e3,vt=50}));function bt(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 Q(e){if(e.length===0)return``;let t=(e.length<=wt?e:[...e.slice(0,wt/2),...e.slice(-100/2)]).map(bt).filter(Boolean).join(` `).replace(/\s+/g,` `).trim();return t.length>Ct?t.slice(0,Ct)+`…`:t}function xt(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&&Q(e.messages).toLowerCase().includes(t))}async function St(e,t,n){if(!e.trim()||t.length===0)return[];let r=e.toLowerCase(),i=t.filter(e=>xt(e,r)),a;if(i.length>=Tt)a=i.slice(0,Tt);else{let e=t.filter(e=>!xt(e,r)),n=Tt-i.length;a=[...i,...e.slice(0,n)]}O(`Agentic search: ${a.length}/${t.length} logs, query="${e}", matching: ${i.length}, with messages: ${Te(a,e=>e.messages?.length>0)}`);let o=a.map(async e=>{if(C(e))try{return await he(e)}catch(t){return ke(t),e}return e}),s=await Promise.all(o);O(`Agentic search: loaded ${Te(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=Q(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.`;O(`Agentic search prompt (first 500 chars): ${c.slice(0,500)}...`);try{let e=Fe();O(`Agentic search using model: ${e}`);let t=(await ue({model:e,system:Et,messages:[{role:`user`,content:c}],signal:n,querySource:`session_search`})).content.find(e=>e.type===`text`);if(!t||t.type!==`text`)return O(`No text content in agentic search response`),[];O(`Agentic search response: ${t.text}`);let r=t.text.match(/\{[\s\S]*\}/);if(!r)return O(`Could not find JSON in agentic search response`),[];let i=(Se(r[0]).relevant_indices||[]).filter(e=>e>=0&&e<s.length).map(e=>s[e]);return O(`Agentic search found ${i.length} relevant sessions`),i}catch(e){return ke(e),O(`Agentic search error: ${e}`),[]}}var Ct,wt,Tt,Et,Dt=e((()=>{Ee(),we(),Oe(),Pe(),D(),ae(),Ce(),Ct=2e3,wt=100,Tt=100,Et=`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 Ot(e,t,n){let r=ie();if(!t||!e.projectPath||e.projectPath===r)return{isCrossProject:!1};if(process.env.USER_TYPE!==`ant`){let t=x(e);return{isCrossProject:!0,isSameRepoWorktree:!1,command:`cd ${N([e.projectPath])} && claude --resume ${t}`,projectPath:e.projectPath}}if(n.some(t=>e.projectPath===t||e.projectPath.startsWith(t+I)))return{isCrossProject:!0,isSameRepoWorktree:!0,projectPath:e.projectPath};let i=x(e);return{isCrossProject:!0,isSameRepoWorktree:!1,command:`cd ${N([e.projectPath])} && claude --resume ${i}`,projectPath:e.projectPath}}var kt=e((()=>{b(),P(),D()}));export{lt as a,Dt as i,kt as n,yt as o,St as r,Ot as t};
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./memoize-BK3gG5ob.js";import{n as r,t as i}from"./axios-DaWTGg7G.js";import{f as a,g as o}from"./config-3m_9zSrj.js";import{o as s,s as c}from"./log-BMCygSzM.js";import{Si as l,W as u,_ as d,r as f,wi as p,z as m}from"./model-BQF64tZx.js";import{Z as h,et as g}from"./esm-CGoYrggU.js";import{f as _,p as v}from"./firstPartyEventLogger-BNGPPBNP.js";import{createHash as y}from"crypto";function b(e){return e.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`)}async function x(){if(N.length===0)return;let e=N;N=[];try{await r.post(E,e,{headers:{"Content-Type":`application/json`,"DD-API-KEY":D},timeout:A})}catch(e){c(e)}}function S(){P||(P=setTimeout(()=>{P=null,x()},T()).unref())}async function C(){P&&(clearTimeout(P),P=null),await x()}async function w(e,t){if(l()!==`firstParty`)return;let n=F;if(n===null&&(n=await I()),!(!n||!j.has(e)))try{let{envContext:n,...r}=await h({model:t.model,betas:t.betas}),i={...r,...n,...t,userBucket:R()};if(typeof i.toolName==`string`&&i.toolName.startsWith(`mcp__`)&&(i.toolName=`mcp`),process.env.USER_TYPE!==`ant`&&typeof i.model==`string`){let e=f(i.model.replace(/\[1m]$/i,``));i.model=e in m?e:`other`}if(typeof i.version==`string`&&(i.version=i.version.replace(/^(\d+\.\d+\.\d+-dev\.\d{8})\.t\d+\.sha[a-f0-9]+$/,`$1`)),i.status!==void 0&&i.status!==null){let e=String(i.status);i.http_status=e;let t=e.charAt(0);t>=`1`&&t<=`5`&&(i.http_status_range=`${t}xx`),delete i.status}let a=i,o={ddsource:`nodejs`,ddtags:[`event:${e}`,...M.filter(e=>a[e]!==void 0&&a[e]!==null).map(e=>`${b(e)}:${a[e]}`)].join(`,`),message:e,service:`claude-code`,hostname:`claude-code`,env:process.env.USER_TYPE};for(let[e,t]of Object.entries(i))t!=null&&(o[b(e)]=t);N.push(o),N.length>=k?(P&&(clearTimeout(P),P=null),x()):S()}catch(e){c(e)}}function T(){return parseInt(process.env.CLAUDE_CODE_DATADOG_FLUSH_INTERVAL_MS||``,10)||O}var E,D,O,k,A,j,M,N,P,F,I,L,R,z=e((()=>{i(),n(),o(),s(),d(),p(),u(),_(),g(),E=process.env.DATADOG_LOGS_ENDPOINT??``,D=process.env.DATADOG_API_KEY??``,O=15e3,k=100,A=5e3,j=new Set(`tengu_api_error.tengu_api_success.tengu_brief_mode_enabled.tengu_brief_mode_toggled.tengu_brief_send.tengu_cancel.tengu_compact_failed.tengu_exit.tengu_flicker.tengu_init.tengu_model_fallback_triggered.tengu_oauth_error.tengu_oauth_success.tengu_oauth_token_refresh_failure.tengu_oauth_token_refresh_success.tengu_oauth_token_refresh_lock_acquiring.tengu_oauth_token_refresh_lock_acquired.tengu_oauth_token_refresh_starting.tengu_oauth_token_refresh_completed.tengu_oauth_token_refresh_lock_releasing.tengu_oauth_token_refresh_lock_released.tengu_query_error.tengu_session_file_read.tengu_started.tengu_tool_use_error.tengu_tool_use_granted_in_prompt_permanent.tengu_tool_use_granted_in_prompt_temporary.tengu_tool_use_rejected_in_prompt.tengu_tool_use_success.tengu_uncaught_exception.tengu_unhandled_rejection.tengu_voice_recording_started.tengu_voice_toggled.tengu_team_mem_sync_pull.tengu_team_mem_sync_push.tengu_team_mem_sync_started.tengu_team_mem_entries_capped`.split(`.`)),M=[`arch`,`clientType`,`errorType`,`http_status_range`,`http_status`,`kairosActive`,`model`,`platform`,`provider`,`skillMode`,`subscriptionType`,`toolName`,`userBucket`,`userType`,`version`,`versionBase`],N=[],P=null,F=null,I=t(async()=>{if(v()||!E||!D)return F=!1,!1;try{return F=!0,!0}catch(e){return c(e),F=!1,!1}}),L=30,R=t(()=>{let e=a(),t=y(`sha256`).update(e).digest(`hex`);return parseInt(t.slice(0,8),16)%L})}));export{C as n,w as r,z as t};
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./memoize-BK3gG5ob.js";import{n as r,t as i}from"./axios-DaWTGg7G.js";import{f as a,g as o}from"./config-DRDuVyzE.js";import{o as s,s as c}from"./log-BMCygSzM.js";import{Si as l,W as u,_ as d,r as f,wi as p,z as m}from"./model-CZViyZnE.js";import{Z as h,et as g}from"./esm-5w3xFBnt.js";import{f as _,p as v}from"./firstPartyEventLogger-BXY1IJ2D.js";import{createHash as y}from"crypto";function b(e){return e.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`)}async function x(){if(N.length===0)return;let e=N;N=[];try{await r.post(E,e,{headers:{"Content-Type":`application/json`,"DD-API-KEY":D},timeout:A})}catch(e){c(e)}}function S(){P||(P=setTimeout(()=>{P=null,x()},T()).unref())}async function C(){P&&(clearTimeout(P),P=null),await x()}async function w(e,t){if(l()!==`firstParty`)return;let n=F;if(n===null&&(n=await I()),!(!n||!j.has(e)))try{let{envContext:n,...r}=await h({model:t.model,betas:t.betas}),i={...r,...n,...t,userBucket:R()};if(typeof i.toolName==`string`&&i.toolName.startsWith(`mcp__`)&&(i.toolName=`mcp`),process.env.USER_TYPE!==`ant`&&typeof i.model==`string`){let e=f(i.model.replace(/\[1m]$/i,``));i.model=e in m?e:`other`}if(typeof i.version==`string`&&(i.version=i.version.replace(/^(\d+\.\d+\.\d+-dev\.\d{8})\.t\d+\.sha[a-f0-9]+$/,`$1`)),i.status!==void 0&&i.status!==null){let e=String(i.status);i.http_status=e;let t=e.charAt(0);t>=`1`&&t<=`5`&&(i.http_status_range=`${t}xx`),delete i.status}let a=i,o={ddsource:`nodejs`,ddtags:[`event:${e}`,...M.filter(e=>a[e]!==void 0&&a[e]!==null).map(e=>`${b(e)}:${a[e]}`)].join(`,`),message:e,service:`claude-code`,hostname:`claude-code`,env:process.env.USER_TYPE};for(let[e,t]of Object.entries(i))t!=null&&(o[b(e)]=t);N.push(o),N.length>=k?(P&&(clearTimeout(P),P=null),x()):S()}catch(e){c(e)}}function T(){return parseInt(process.env.CLAUDE_CODE_DATADOG_FLUSH_INTERVAL_MS||``,10)||O}var E,D,O,k,A,j,M,N,P,F,I,L,R,z=e((()=>{i(),n(),o(),s(),d(),p(),u(),_(),g(),E=process.env.DATADOG_LOGS_ENDPOINT??``,D=process.env.DATADOG_API_KEY??``,O=15e3,k=100,A=5e3,j=new Set(`tengu_api_error.tengu_api_success.tengu_brief_mode_enabled.tengu_brief_mode_toggled.tengu_brief_send.tengu_cancel.tengu_compact_failed.tengu_exit.tengu_flicker.tengu_init.tengu_model_fallback_triggered.tengu_oauth_error.tengu_oauth_success.tengu_oauth_token_refresh_failure.tengu_oauth_token_refresh_success.tengu_oauth_token_refresh_lock_acquiring.tengu_oauth_token_refresh_lock_acquired.tengu_oauth_token_refresh_starting.tengu_oauth_token_refresh_completed.tengu_oauth_token_refresh_lock_releasing.tengu_oauth_token_refresh_lock_released.tengu_query_error.tengu_session_file_read.tengu_started.tengu_tool_use_error.tengu_tool_use_granted_in_prompt_permanent.tengu_tool_use_granted_in_prompt_temporary.tengu_tool_use_rejected_in_prompt.tengu_tool_use_success.tengu_uncaught_exception.tengu_unhandled_rejection.tengu_voice_recording_started.tengu_voice_toggled.tengu_team_mem_sync_pull.tengu_team_mem_sync_push.tengu_team_mem_sync_started.tengu_team_mem_entries_capped`.split(`.`)),M=[`arch`,`clientType`,`errorType`,`http_status_range`,`http_status`,`kairosActive`,`model`,`platform`,`provider`,`skillMode`,`subscriptionType`,`toolName`,`userBucket`,`userType`,`version`,`versionBase`],N=[],P=null,F=null,I=t(async()=>{if(v()||!E||!D)return F=!1,!1;try{return F=!0,!0}catch(e){return c(e),F=!1,!1}}),L=30,R=t(()=>{let e=a(),t=y(`sha256`).update(e).digest(`hex`);return parseInt(t.slice(0,8),16)%L})}));export{C as n,w as r,z as t};
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{fi as t}from"./src-CDCSSo0U2.js";import{t as n}from"./jsx-runtime-Bb4Xn-E0.js";import{n as r,t as i}from"./DesktopHandoff-D1rrMxeP.js";async function a(e){return(0,o.jsx)(i,{onDone:e})}var o;e((()=>{t(),r(),o=n()}))();export{a as call};
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{fi as t}from"./src-CDCSSo0U2.js";import{t as n}from"./jsx-runtime-Bb4Xn-E0.js";import{n as r,t as i}from"./DesktopHandoff-DaP4Riar.js";async function a(e){return(0,o.jsx)(i,{onDone:e})}var o;e((()=>{t(),r(),o=n()}))();export{a as call};
@@ -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-BKcfKx7O.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-B7hx8i_Y.js`);return(0,n.jsx)(r,{messages:t.messages,onDone:e})}}))();export{r as call};
@@ -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-CuKJ-nGt.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,6 +1,6 @@
1
- import{n as e,t}from"./defineProperty-C-QyHrDq.js";import{A as n,E as r,I as i,M as a,N as o,P as s,S as c,T as l,b as u,d,g as f,h as p,r as m}from"./lazySchema-DcIJE_0i.js";import{Or as h,Zn as g,_t as _,en as v,kr as y,nt as b,vr as x}from"./state-ix0xIunV.js";import{G as ee,Hy as te,Md as ne,Qi as re,Vy as S,W as ie,Xu as ae,Yu as oe,_f as se,aw as ce,gr as C,i as le,iw as ue,jd as de,jr as fe,o as pe,qi as me,va as he,vf as ge,ya as _e}from"./loadAgentsDir-Clu7Uk6a.js";import{f as ve,g as ye}from"./settings-Dlp5JTa_.js";import{g as be,r as xe}from"./config-3m_9zSrj.js";import{l as w,p as T,r as Se}from"./sessionStoragePortable-Cx6JQ5Ye.js";import{_ as Ce,u as we}from"./model-BQF64tZx.js";import{Tn as Te,wn as Ee}from"./prompt-Bg_1U0gO.js";import{o as De,t as Oe}from"./fileStateCache-DDW5toIs.js";import{t as ke}from"./QueryEngine-cwdsr4dr.js";import{dirname as Ae}from"node:path";import{randomUUID as E}from"node:crypto";import{Readable as je,Writable as Me}from"node:stream";import{unlink as Ne}from"node:fs/promises";import*as D from"node:path/posix";import{isAbsolute as Pe,resolve as Fe}from"node:path/posix";m();var O={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`},k={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=r({_meta:n(a(),s()).nullish(),terminal:f().optional().default(!1)}),Le=r({_meta:n(a(),s()).nullish(),label:a().nullish(),name:a(),optional:f().optional().default(!1),secret:f().optional().default(!0)}),Re=r({_meta:n(a(),s()).nullish(),description:a().nullish(),id:a(),name:a()}),ze=r({_meta:n(a(),s()).nullish(),description:a().nullish(),id:a(),link:a().nullish(),name:a(),vars:p(Le)}),Be=r({_meta:n(a(),s()).nullish(),args:p(a()).optional(),description:a().nullish(),env:n(a(),a()).optional(),id:a(),name:a()}),Ve=o([ze.and(r({type:c(`env_var`)})),Be.and(r({type:c(`terminal`)})),Re]),He=r({_meta:n(a(),s()).nullish(),methodId:a()}),Ue=r({_meta:n(a(),s()).nullish()}),We=r({_meta:n(a(),s()).nullish(),blob:a(),mimeType:a().nullish(),uri:a()}),Ge=r({default:f().nullish(),description:a().nullish(),title:a().nullish()}),Ke=r({_meta:n(a(),s()).nullish()}),qe=r({_meta:n(a(),s()).nullish()}),Je=r({amount:l(),currency:a()}),Ye=r({_meta:n(a(),s()).nullish(),terminalId:a()}),Xe=r({_meta:n(a(),s()).nullish(),newText:a(),oldText:a().nullish(),path:a()}),Ze=o([a(),l(),l(),f(),p(a())]),Qe=u(o([r({content:n(a(),Ze).nullish()}).and(r({action:c(`accept`)})),r({action:c(`decline`)}),r({action:c(`cancel`)})]),r({_meta:n(a(),s()).nullish()})),$e=r({_meta:n(a(),s()).nullish()}),et=a(),tt=r({_meta:n(a(),s()).nullish(),elicitationId:et}),nt=c(`object`),rt=c(`string`),it=r({_meta:n(a(),s()).nullish()}),at=r({_meta:n(a(),s()).nullish(),form:$e.nullish(),url:it.nullish()}),ot=r({const:a(),title:a()}),st=r({_meta:n(a(),s()).nullish(),name:a(),value:a()}),ct=r({code:o([c(-32700),c(-32600),c(-32601),c(-32602),c(-32603),c(-32800),c(-32e3),c(-32002),c(-32042),l().int().min(-2147483648,{message:`Invalid value: Expected int32 to be >= -2147483648`}).max(2147483647,{message:`Invalid value: Expected int32 to be <= 2147483647`})]),data:s().optional(),message:a()}),lt=s(),ut=s(),dt=s(),ft=r({_meta:n(a(),s()).nullish(),readTextFile:f().optional().default(!1),writeTextFile:f().optional().default(!1)}),pt=r({_meta:n(a(),s()).nullish(),name:a(),value:a()}),mt=r({_meta:n(a(),s()).nullish(),name:a(),title:a().nullish(),version:a()}),ht=r({default:l().nullish(),description:a().nullish(),maximum:l().nullish(),minimum:l().nullish(),title:a().nullish()}),gt=r({_meta:n(a(),s()).nullish()}),_t=r({_meta:n(a(),s()).nullish(),additionalDirectories:p(a()).optional(),cursor:a().nullish(),cwd:a().nullish()}),vt=r({_meta:n(a(),s()).nullish()}),yt=r({_meta:n(a(),s()).nullish(),logout:vt.nullish()}),bt=r({_meta:n(a(),s()).nullish()}),xt=r({_meta:n(a(),s()).nullish()}),St=r({_meta:n(a(),s()).nullish(),http:f().optional().default(!1),sse:f().optional().default(!1)}),Ct=r({_meta:n(a(),s()).nullish(),headers:p(pt),name:a(),url:a()}),wt=r({_meta:n(a(),s()).nullish(),headers:p(pt),name:a(),url:a()}),Tt=r({_meta:n(a(),s()).nullish(),args:p(a()),command:a(),env:p(st),name:a()}),A=o([Ct.and(r({type:c(`http`)})),wt.and(r({type:c(`sse`)})),Tt]),j=a(),Et=r({_meta:n(a(),s()).nullish(),description:a().nullish(),modelId:j,name:a()}),Dt=o([c(`error`),c(`warning`),c(`information`),c(`hint`)]),Ot=r({_meta:n(a(),s()).nullish()}),kt=r({_meta:n(a(),s()).nullish()}),At=r({_meta:n(a(),s()).nullish()}),jt=r({_meta:n(a(),s()).nullish()}),Mt=r({_meta:n(a(),s()).nullish()}),Nt=r({_meta:n(a(),s()).nullish(),maxCount:l().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish()}),Pt=r({diff:a(),uri:a()}),Ft=r({endLine:l().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}),startLine:l().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}),text:a()}),It=r({_meta:n(a(),s()).nullish()}),Lt=r({_meta:n(a(),s()).nullish()}),Rt=r({languageId:a(),text:a(),uri:a()}),zt=r({_meta:n(a(),s()).nullish(),maxCount:l().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish()}),Bt=o([c(`rejected`),c(`ignored`),c(`replaced`),c(`cancelled`)]),Vt=r({excerpts:p(Ft),uri:a()}),Ht=r({_meta:n(a(),s()).nullish()}),Ut=r({_meta:n(a(),s()).nullish()}),Wt=r({name:a(),owner:a(),remoteUrl:a()}),Gt=r({_meta:n(a(),s()).nullish()}),Kt=r({_meta:n(a(),s()).nullish(),jump:It.nullish(),rename:Ut.nullish(),searchAndReplace:Gt.nullish()}),qt=r({id:a(),isRegex:f().nullish(),replace:a(),search:a(),uri:a()}),Jt=o([c(`automatic`),c(`diagnostic`),c(`manual`)]),Yt=r({_meta:n(a(),s()).nullish(),maxCount:l().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish()}),Xt=r({_meta:n(a(),s()).nullish(),diagnostics:Ot.nullish(),editHistory:Nt.nullish(),openFiles:Lt.nullish(),recentFiles:zt.nullish(),relatedSnippets:Ht.nullish(),userActions:Yt.nullish()}),Zt=r({_meta:n(a(),s()).nullish(),additionalDirectories:p(a()).optional(),cwd:a(),mcpServers:p(A)}),Qt=r({default:l().nullish(),description:a().nullish(),maximum:l().nullish(),minimum:l().nullish(),title:a().nullish()}),$t=a(),en=o([c(`allow_once`),c(`allow_always`),c(`reject_once`),c(`reject_always`)]),tn=r({_meta:n(a(),s()).nullish(),kind:en,name:a(),optionId:$t}),nn=o([c(`high`),c(`medium`),c(`low`)]),rn=o([c(`pending`),c(`in_progress`),c(`completed`)]),an=r({_meta:n(a(),s()).nullish(),content:a(),priority:nn,status:rn}),on=r({_meta:n(a(),s()).nullish(),entries:p(an)}),M=r({character:l().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}),line:l().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`})}),sn=r({id:a(),position:M,uri:a()}),cn=r({id:a(),newName:a(),position:M,uri:a()}),ln=r({action:a(),position:M,timestampMs:l(),uri:a()}),un=o([c(`utf-16`),c(`utf-32`),c(`utf-8`)]),dn=r({_meta:n(a(),s()).nullish(),auth:Ie.optional().default({terminal:!1}),elicitation:at.nullish(),fs:ft.optional().default({readTextFile:!1,writeTextFile:!1}),nes:Kt.nullish(),positionEncodings:p(un).optional(),terminal:f().optional().default(!1)}),fn=r({_meta:n(a(),s()).nullish(),audio:f().optional().default(!1),embeddedContext:f().optional().default(!1),image:f().optional().default(!1)}),pn=l().int().gte(0).lte(65535),mn=r({_meta:n(a(),s()).nullish(),clientCapabilities:dn.optional().default({auth:{terminal:!1},fs:{readTextFile:!1,writeTextFile:!1},terminal:!1}),clientInfo:mt.nullish(),protocolVersion:pn}),N=r({end:M,start:M}),hn=r({message:a(),range:N,severity:Dt,uri:a()}),gn=r({languageId:a(),lastFocusedMs:l().nullish(),uri:a(),visibleRange:N.nullish()}),_n=r({_meta:n(a(),s()).nullish(),diagnostics:p(hn).nullish(),editHistory:p(Pt).nullish(),openFiles:p(gn).nullish(),recentFiles:p(Rt).nullish(),relatedSnippets:p(Vt).nullish(),userActions:p(ln).nullish()}),vn=r({newText:a(),range:N}),yn=o([r({cursorPosition:M.nullish(),edits:p(vn),id:a(),uri:a()}).and(r({kind:c(`edit`)})),sn.and(r({kind:c(`jump`)})),cn.and(r({kind:c(`rename`)})),qt.and(r({kind:c(`searchAndReplace`)}))]),bn=r({_meta:n(a(),s()).nullish(),content:a()}),xn=r({_meta:n(a(),s()).nullish()}),P=o([l(),a()]).nullable();r({_meta:n(a(),s()).nullish(),requestId:P});var Sn=r({requestId:P}),Cn=d([`assistant`,`user`]),F=r({_meta:n(a(),s()).nullish(),audience:p(Cn).nullish(),lastModified:a().nullish(),priority:l().nullish()}),wn=r({_meta:n(a(),s()).nullish(),annotations:F.nullish(),data:a(),mimeType:a()}),Tn=r({_meta:n(a(),s()).nullish(),annotations:F.nullish(),data:a(),mimeType:a(),uri:a().nullish()}),En=r({_meta:n(a(),s()).nullish(),annotations:F.nullish(),description:a().nullish(),mimeType:a().nullish(),name:a(),size:l().nullish(),title:a().nullish(),uri:a()}),Dn=r({_meta:n(a(),s()).nullish(),optionId:$t}),On=o([r({outcome:c(`cancelled`)}),Dn.and(r({outcome:c(`selected`)}))]),kn=r({_meta:n(a(),s()).nullish(),outcome:On}),An=r({_meta:n(a(),s()).nullish()}),jn=r({_meta:n(a(),s()).nullish()}),Mn=r({currentValue:f()}),Nn=a(),Pn=a(),Fn=o([c(`mode`),c(`model`),c(`thought_level`),a()]),I=a(),In=r({_meta:n(a(),s()).nullish(),description:a().nullish(),name:a(),value:I}),Ln=r({_meta:n(a(),s()).nullish(),group:Nn,name:a(),options:p(In)}),L=u(o([r({currentValue:I,options:o([p(In),p(Ln)])}).and(r({type:c(`select`)})),Mn.and(r({type:c(`boolean`)}))]),r({_meta:n(a(),s()).nullish(),category:Fn.nullish(),description:a().nullish(),id:Pn,name:a()})),Rn=r({_meta:n(a(),s()).nullish(),configOptions:p(L)}),zn=r({_meta:n(a(),s()).nullish()}),R=a(),Bn=r({_meta:n(a(),s()).nullish(),id:a(),sessionId:R}),Vn=r({_meta:n(a(),s()).nullish(),sessionId:R}),Hn=r({_meta:n(a(),s()).nullish(),sessionId:R}),Un=r({_meta:n(a(),s()).nullish(),sessionId:R}),Wn=r({_meta:n(a(),s()).nullish(),args:p(a()).optional(),command:a(),cwd:a().nullish(),env:p(st).optional(),outputByteLimit:l().nullish(),sessionId:R}),Gn=r({_meta:n(a(),s()).nullish(),sessionId:R,uri:a()}),Kn=r({_meta:n(a(),s()).nullish(),position:M,sessionId:R,uri:a(),version:l(),visibleRange:N}),qn=r({_meta:n(a(),s()).nullish(),languageId:a(),sessionId:R,text:a(),uri:a(),version:l()}),Jn=r({_meta:n(a(),s()).nullish(),sessionId:R,uri:a()}),Yn=r({_meta:n(a(),s()).nullish(),additionalDirectories:p(a()).optional(),cwd:a(),mcpServers:p(A).optional(),sessionId:R}),Xn=r({_meta:n(a(),s()).nullish(),sessionId:R,terminalId:a()}),Zn=r({_meta:n(a(),s()).nullish(),additionalDirectories:p(a()).optional(),cwd:a(),mcpServers:p(A),sessionId:R}),Qn=r({_meta:n(a(),s()).nullish(),limit:l().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),line:l().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),path:a(),sessionId:R}),$n=r({_meta:n(a(),s()).nullish(),id:a(),reason:Bt.nullish(),sessionId:R}),er=r({_meta:n(a(),s()).nullish(),sessionId:R,terminalId:a()}),tr=r({_meta:n(a(),s()).nullish(),additionalDirectories:p(a()).optional(),cwd:a(),mcpServers:p(A).optional(),sessionId:R}),nr=r({_meta:n(a(),s()).nullish(),additionalDirectories:p(a()).optional(),cwd:a(),sessionId:R,title:a().nullish(),updatedAt:a().nullish()}),rr=r({_meta:n(a(),s()).nullish(),nextCursor:a().nullish(),sessions:p(nr)}),ir=r({_meta:n(a(),s()).nullish(),title:a().nullish(),updatedAt:a().nullish()}),ar=r({_meta:n(a(),s()).nullish()}),z=a(),or=r({_meta:n(a(),s()).nullish(),currentModeId:z}),sr=r({_meta:n(a(),s()).nullish(),description:a().nullish(),id:z,name:a()}),B=r({_meta:n(a(),s()).nullish(),availableModes:p(sr),currentModeId:z}),V=r({_meta:n(a(),s()).nullish(),availableModels:p(Et),currentModelId:j}),cr=r({_meta:n(a(),s()).nullish(),configOptions:p(L).nullish(),models:V.nullish(),modes:B.nullish(),sessionId:R}),lr=r({_meta:n(a(),s()).nullish(),configOptions:p(L).nullish(),models:V.nullish(),modes:B.nullish()}),ur=r({_meta:n(a(),s()).nullish(),configOptions:p(L).nullish(),models:V.nullish(),modes:B.nullish(),sessionId:R}),dr=r({_meta:n(a(),s()).nullish(),configOptions:p(L).nullish(),models:V.nullish(),modes:B.nullish()}),fr=r({_meta:n(a(),s()).nullish()}),pr=r({_meta:n(a(),s()).nullish(),additionalDirectories:An.nullish(),close:jn.nullish(),fork:zn.nullish(),list:ar.nullish(),resume:fr.nullish()}),mr=u(o([r({type:c(`boolean`),value:f()}),r({value:I})]),r({_meta:n(a(),s()).nullish(),configId:Pn,sessionId:R})),hr=r({_meta:n(a(),s()).nullish(),configOptions:p(L)}),gr=r({_meta:n(a(),s()).nullish(),modeId:z,sessionId:R}),_r=r({_meta:n(a(),s()).nullish()}),vr=r({_meta:n(a(),s()).nullish(),modelId:j,sessionId:R}),yr=r({_meta:n(a(),s()).nullish()}),br=r({_meta:n(a(),s()).nullish(),sessionId:R}),xr=o([c(`end_turn`),c(`max_tokens`),c(`max_turn_requests`),c(`refusal`),c(`cancelled`)]),Sr=o([c(`email`),c(`uri`),c(`date`),c(`date-time`)]),Cr=r({default:a().nullish(),description:a().nullish(),enum:p(a()).nullish(),format:Sr.nullish(),maxLength:l().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),minLength:l().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),oneOf:p(ot).nullish(),pattern:a().nullish(),title:a().nullish()}),wr=r({_meta:n(a(),s()).nullish(),context:_n.nullish(),position:M,selection:N.nullish(),sessionId:R,triggerKind:Jt,uri:a(),version:l()}),Tr=r({_meta:n(a(),s()).nullish(),suggestions:p(yn)}),Er=r({_meta:n(a(),s()).nullish(),terminalId:a()}),Dr=r({_meta:n(a(),s()).nullish(),exitCode:l().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),signal:a().nullish()}),Or=r({_meta:n(a(),s()).nullish(),sessionId:R,terminalId:a()}),kr=r({_meta:n(a(),s()).nullish(),exitStatus:Dr.nullish(),output:a(),truncated:f()}),Ar=r({_meta:n(a(),s()).nullish(),annotations:F.nullish(),text:a()}),jr=r({range:N.nullish(),text:a()}),Mr=r({_meta:n(a(),s()).nullish(),contentChanges:p(jr),sessionId:R,uri:a(),version:l()});r({method:a(),params:o([Vn,qn,Mr,Gn,Jn,Kn,Bn,$n,lt]).nullish()});var Nr=o([c(`full`),c(`incremental`)]),Pr=r({_meta:n(a(),s()).nullish(),syncKind:Nr}),Fr=r({_meta:n(a(),s()).nullish(),didChange:Pr.nullish(),didClose:kt.nullish(),didFocus:At.nullish(),didOpen:jt.nullish(),didSave:Mt.nullish()}),Ir=r({_meta:n(a(),s()).nullish(),document:Fr.nullish()}),Lr=r({_meta:n(a(),s()).nullish(),context:Xt.nullish(),events:Ir.nullish()}),Rr=r({_meta:n(a(),s()).nullish(),auth:yt.optional().default({}),loadSession:f().optional().default(!1),mcpCapabilities:St.optional().default({http:!1,sse:!1}),nes:Lr.nullish(),positionEncoding:un.nullish(),promptCapabilities:fn.optional().default({audio:!1,embeddedContext:!1,image:!1}),sessionCapabilities:pr.optional().default({})}),zr=r({_meta:n(a(),s()).nullish(),agentCapabilities:Rr.optional().default({auth:{},loadSession:!1,mcpCapabilities:{http:!1,sse:!1},promptCapabilities:{audio:!1,embeddedContext:!1,image:!1},sessionCapabilities:{}}),agentInfo:mt.nullish(),authMethods:p(Ve).optional().default([]),protocolVersion:pn}),Br=o([r({_meta:n(a(),s()).nullish(),mimeType:a().nullish(),text:a(),uri:a()}),We]),Vr=r({_meta:n(a(),s()).nullish(),annotations:F.nullish(),resource:Br}),H=o([Ar.and(r({type:c(`text`)})),Tn.and(r({type:c(`image`)})),wn.and(r({type:c(`audio`)})),En.and(r({type:c(`resource_link`)})),Vr.and(r({type:c(`resource`)}))]),Hr=r({_meta:n(a(),s()).nullish(),content:H}),U=r({_meta:n(a(),s()).nullish(),content:H,messageId:a().nullish()}),Ur=r({_meta:n(a(),s()).nullish(),messageId:a().nullish(),prompt:p(H),sessionId:R}),Wr=r({anyOf:p(ot)}),Gr=o([Hr.and(r({type:c(`content`)})),Xe.and(r({type:c(`diff`)})),Er.and(r({type:c(`terminal`)}))]),W=a(),Kr=r({sessionId:R,toolCallId:W.nullish()}),qr=u(o([Kr,Sn]),r({elicitationId:et,url:a().url()})),Jr=r({_meta:n(a(),s()).nullish(),line:l().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),path:a()}),Yr=o([c(`pending`),c(`in_progress`),c(`completed`),c(`failed`)]),Xr=o([c(`read`),c(`edit`),c(`delete`),c(`move`),c(`search`),c(`execute`),c(`think`),c(`fetch`),c(`switch_mode`),c(`other`)]),Zr=r({_meta:n(a(),s()).nullish(),content:p(Gr).optional(),kind:Xr.optional(),locations:p(Jr).optional(),rawInput:s().optional(),rawOutput:s().optional(),status:Yr.optional(),title:a(),toolCallId:W}),Qr=r({_meta:n(a(),s()).nullish(),content:p(Gr).nullish(),kind:Xr.nullish(),locations:p(Jr).nullish(),rawInput:s().optional(),rawOutput:s().optional(),status:Yr.nullish(),title:a().nullish(),toolCallId:W}),$r=r({_meta:n(a(),s()).nullish(),options:p(tn),sessionId:R,toolCall:Qr}),ei=r({_meta:n(a(),s()).nullish(),hint:a()}),ti=r({_meta:n(a(),s()).nullish(),description:a(),input:ei.nullish(),name:a()}),ni=r({_meta:n(a(),s()).nullish(),availableCommands:p(ti)}),ri=o([r({enum:p(a()),type:rt}),Wr]),ii=r({default:p(a()).nullish(),description:a().nullish(),items:ri,maxItems:l().nullish(),minItems:l().nullish(),title:a().nullish()}),ai=o([Cr.and(r({type:c(`string`)})),Qt.and(r({type:c(`number`)})),ht.and(r({type:c(`integer`)})),Ge.and(r({type:c(`boolean`)})),ii.and(r({type:c(`array`)}))]),oi=r({description:a().nullish(),properties:n(a(),ai).optional().default({}),required:p(a()).nullish(),title:a().nullish(),type:nt.optional().default(`object`)}),si=u(o([u(o([Kr,Sn]),r({requestedSchema:oi})).and(r({mode:c(`form`)})),qr.and(r({mode:c(`url`)}))]),r({_meta:n(a(),s()).nullish(),message:a()})),ci=r({cachedReadTokens:l().nullish(),cachedWriteTokens:l().nullish(),inputTokens:l(),outputTokens:l(),thoughtTokens:l().nullish(),totalTokens:l()});o([r({id:P,result:o([zr,Ue,xt,ur,lr,rr,cr,dr,qe,_r,hr,r({_meta:n(a(),s()).nullish(),stopReason:xr,usage:ci.nullish(),userMessageId:a().nullish()}),yr,br,Tr,Ke,dt])}),r({error:ct,id:P})]);var li=r({_meta:n(a(),s()).nullish(),cost:Je.nullish(),size:l(),used:l()}),ui=o([U.and(r({sessionUpdate:c(`user_message_chunk`)})),U.and(r({sessionUpdate:c(`agent_message_chunk`)})),U.and(r({sessionUpdate:c(`agent_thought_chunk`)})),Zr.and(r({sessionUpdate:c(`tool_call`)})),Qr.and(r({sessionUpdate:c(`tool_call_update`)})),on.and(r({sessionUpdate:c(`plan`)})),ni.and(r({sessionUpdate:c(`available_commands_update`)})),or.and(r({sessionUpdate:c(`current_mode_update`)})),Rn.and(r({sessionUpdate:c(`config_option_update`)})),ir.and(r({sessionUpdate:c(`session_info_update`)})),li.and(r({sessionUpdate:c(`usage_update`)}))]),di=r({_meta:n(a(),s()).nullish(),sessionId:R,update:ui});r({method:a(),params:o([di,tt,lt]).nullish()});var fi=r({_meta:n(a(),s()).nullish(),sessionId:R,terminalId:a()}),pi=r({_meta:n(a(),s()).nullish(),exitCode:l().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),signal:a().nullish()}),mi=r({name:a(),uri:a()}),hi=r({_meta:n(a(),s()).nullish(),repository:Wt.nullish(),workspaceFolders:p(mi).nullish(),workspaceUri:a().nullish()});r({id:P,method:a(),params:o([mn,He,bt,Zt,Zn,_t,Yn,tr,Un,gr,mr,Ur,vr,hi,wr,Hn,ut]).nullish()});var gi=r({_meta:n(a(),s()).nullish(),content:a(),path:a(),sessionId:R});r({id:P,method:a(),params:o([gi,Qn,$r,Wn,Or,er,fi,Xn,si,ut]).nullish()}),o([r({id:P,result:o([r({_meta:n(a(),s()).nullish()}),bn,kn,Ye,kr,xn,pi,gt,Qe,dt])}),r({error:ct,id:P})]),e();function _i(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{C as n,D as r,E as i,F as a,L as o,N as s,P as c,_ as l,f as u,g as d,j as f,r as p,x as m}from"./lazySchema-DULtBUCI.js";import{Or as h,Zn as g,_t as _,en as v,kr as y,nt as b,vr as x}from"./state-ix0xIunV.js";import{G as ee,Hu as te,My as S,Ny as ne,Qi as re,Td as ie,Uu as ae,W as oe,XC as se,YC as ce,df as le,gr as C,i as ue,jr as de,o as fe,qi as pe,uf as me,wd as he}from"./loadAgentsDir-x3rlgED4.js";import{f as ge,g as _e}from"./settings-BeLFUeie.js";import{g as ve,r as ye}from"./config-DRDuVyzE.js";import{l as be,p as w,r as T}from"./sessionStoragePortable-Cx6JQ5Ye.js";import{_ as xe,u as Se}from"./model-CZViyZnE.js";import{Tn as Ce,wn as we}from"./prompt-CE3sFmZV.js";import{o as Te,t as Ee}from"./fileStateCache-DDW5toIs.js";import{n as De,r as Oe}from"./managedEnv-Aq5BXfY7.js";import{t as ke}from"./QueryEngine-CGYaShXD.js";import{dirname as Ae}from"node:path";import{randomUUID as E}from"node:crypto";import{Readable as je,Writable as Me}from"node:stream";import{unlink as Ne}from"node:fs/promises";import*as D from"node:path/posix";import{isAbsolute as Pe,resolve as Fe}from"node:path/posix";p();var O={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`},k={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=r({_meta:f(s(),a()).nullish(),terminal:l().optional().default(!1)}),Le=r({_meta:f(s(),a()).nullish(),label:s().nullish(),name:s(),optional:l().optional().default(!1),secret:l().optional().default(!0)}),Re=r({_meta:f(s(),a()).nullish(),description:s().nullish(),id:s(),name:s()}),ze=r({_meta:f(s(),a()).nullish(),description:s().nullish(),id:s(),link:s().nullish(),name:s(),vars:d(Le)}),Be=r({_meta:f(s(),a()).nullish(),args:d(s()).optional(),description:s().nullish(),env:f(s(),s()).optional(),id:s(),name:s()}),Ve=c([ze.and(r({type:n(`env_var`)})),Be.and(r({type:n(`terminal`)})),Re]),He=r({_meta:f(s(),a()).nullish(),methodId:s()}),Ue=r({_meta:f(s(),a()).nullish()}),We=r({_meta:f(s(),a()).nullish(),blob:s(),mimeType:s().nullish(),uri:s()}),Ge=r({default:l().nullish(),description:s().nullish(),title:s().nullish()}),Ke=r({_meta:f(s(),a()).nullish()}),qe=r({_meta:f(s(),a()).nullish()}),Je=r({amount:i(),currency:s()}),Ye=r({_meta:f(s(),a()).nullish(),terminalId:s()}),Xe=r({_meta:f(s(),a()).nullish(),newText:s(),oldText:s().nullish(),path:s()}),Ze=c([s(),i(),i(),l(),d(s())]),Qe=m(c([r({content:f(s(),Ze).nullish()}).and(r({action:n(`accept`)})),r({action:n(`decline`)}),r({action:n(`cancel`)})]),r({_meta:f(s(),a()).nullish()})),$e=r({_meta:f(s(),a()).nullish()}),et=s(),tt=r({_meta:f(s(),a()).nullish(),elicitationId:et}),nt=n(`object`),rt=n(`string`),it=r({_meta:f(s(),a()).nullish()}),at=r({_meta:f(s(),a()).nullish(),form:$e.nullish(),url:it.nullish()}),ot=r({const:s(),title:s()}),st=r({_meta:f(s(),a()).nullish(),name:s(),value:s()}),ct=r({code:c([n(-32700),n(-32600),n(-32601),n(-32602),n(-32603),n(-32800),n(-32e3),n(-32002),n(-32042),i().int().min(-2147483648,{message:`Invalid value: Expected int32 to be >= -2147483648`}).max(2147483647,{message:`Invalid value: Expected int32 to be <= 2147483647`})]),data:a().optional(),message:s()}),lt=a(),ut=a(),dt=a(),ft=r({_meta:f(s(),a()).nullish(),readTextFile:l().optional().default(!1),writeTextFile:l().optional().default(!1)}),pt=r({_meta:f(s(),a()).nullish(),name:s(),value:s()}),mt=r({_meta:f(s(),a()).nullish(),name:s(),title:s().nullish(),version:s()}),ht=r({default:i().nullish(),description:s().nullish(),maximum:i().nullish(),minimum:i().nullish(),title:s().nullish()}),gt=r({_meta:f(s(),a()).nullish()}),_t=r({_meta:f(s(),a()).nullish(),additionalDirectories:d(s()).optional(),cursor:s().nullish(),cwd:s().nullish()}),vt=r({_meta:f(s(),a()).nullish()}),yt=r({_meta:f(s(),a()).nullish(),logout:vt.nullish()}),bt=r({_meta:f(s(),a()).nullish()}),xt=r({_meta:f(s(),a()).nullish()}),St=r({_meta:f(s(),a()).nullish(),http:l().optional().default(!1),sse:l().optional().default(!1)}),Ct=r({_meta:f(s(),a()).nullish(),headers:d(pt),name:s(),url:s()}),wt=r({_meta:f(s(),a()).nullish(),headers:d(pt),name:s(),url:s()}),Tt=r({_meta:f(s(),a()).nullish(),args:d(s()),command:s(),env:d(st),name:s()}),A=c([Ct.and(r({type:n(`http`)})),wt.and(r({type:n(`sse`)})),Tt]),j=s(),Et=r({_meta:f(s(),a()).nullish(),description:s().nullish(),modelId:j,name:s()}),Dt=c([n(`error`),n(`warning`),n(`information`),n(`hint`)]),Ot=r({_meta:f(s(),a()).nullish()}),kt=r({_meta:f(s(),a()).nullish()}),At=r({_meta:f(s(),a()).nullish()}),jt=r({_meta:f(s(),a()).nullish()}),Mt=r({_meta:f(s(),a()).nullish()}),Nt=r({_meta:f(s(),a()).nullish(),maxCount:i().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish()}),Pt=r({diff:s(),uri:s()}),Ft=r({endLine:i().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}),startLine:i().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}),text:s()}),It=r({_meta:f(s(),a()).nullish()}),Lt=r({_meta:f(s(),a()).nullish()}),Rt=r({languageId:s(),text:s(),uri:s()}),zt=r({_meta:f(s(),a()).nullish(),maxCount:i().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish()}),Bt=c([n(`rejected`),n(`ignored`),n(`replaced`),n(`cancelled`)]),Vt=r({excerpts:d(Ft),uri:s()}),Ht=r({_meta:f(s(),a()).nullish()}),Ut=r({_meta:f(s(),a()).nullish()}),Wt=r({name:s(),owner:s(),remoteUrl:s()}),Gt=r({_meta:f(s(),a()).nullish()}),Kt=r({_meta:f(s(),a()).nullish(),jump:It.nullish(),rename:Ut.nullish(),searchAndReplace:Gt.nullish()}),qt=r({id:s(),isRegex:l().nullish(),replace:s(),search:s(),uri:s()}),Jt=c([n(`automatic`),n(`diagnostic`),n(`manual`)]),Yt=r({_meta:f(s(),a()).nullish(),maxCount:i().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish()}),Xt=r({_meta:f(s(),a()).nullish(),diagnostics:Ot.nullish(),editHistory:Nt.nullish(),openFiles:Lt.nullish(),recentFiles:zt.nullish(),relatedSnippets:Ht.nullish(),userActions:Yt.nullish()}),Zt=r({_meta:f(s(),a()).nullish(),additionalDirectories:d(s()).optional(),cwd:s(),mcpServers:d(A)}),Qt=r({default:i().nullish(),description:s().nullish(),maximum:i().nullish(),minimum:i().nullish(),title:s().nullish()}),$t=s(),en=c([n(`allow_once`),n(`allow_always`),n(`reject_once`),n(`reject_always`)]),tn=r({_meta:f(s(),a()).nullish(),kind:en,name:s(),optionId:$t}),nn=c([n(`high`),n(`medium`),n(`low`)]),rn=c([n(`pending`),n(`in_progress`),n(`completed`)]),an=r({_meta:f(s(),a()).nullish(),content:s(),priority:nn,status:rn}),on=r({_meta:f(s(),a()).nullish(),entries:d(an)}),M=r({character:i().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}),line:i().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`})}),sn=r({id:s(),position:M,uri:s()}),cn=r({id:s(),newName:s(),position:M,uri:s()}),ln=r({action:s(),position:M,timestampMs:i(),uri:s()}),un=c([n(`utf-16`),n(`utf-32`),n(`utf-8`)]),dn=r({_meta:f(s(),a()).nullish(),auth:Ie.optional().default({terminal:!1}),elicitation:at.nullish(),fs:ft.optional().default({readTextFile:!1,writeTextFile:!1}),nes:Kt.nullish(),positionEncodings:d(un).optional(),terminal:l().optional().default(!1)}),fn=r({_meta:f(s(),a()).nullish(),audio:l().optional().default(!1),embeddedContext:l().optional().default(!1),image:l().optional().default(!1)}),pn=i().int().gte(0).lte(65535),mn=r({_meta:f(s(),a()).nullish(),clientCapabilities:dn.optional().default({auth:{terminal:!1},fs:{readTextFile:!1,writeTextFile:!1},terminal:!1}),clientInfo:mt.nullish(),protocolVersion:pn}),N=r({end:M,start:M}),hn=r({message:s(),range:N,severity:Dt,uri:s()}),gn=r({languageId:s(),lastFocusedMs:i().nullish(),uri:s(),visibleRange:N.nullish()}),_n=r({_meta:f(s(),a()).nullish(),diagnostics:d(hn).nullish(),editHistory:d(Pt).nullish(),openFiles:d(gn).nullish(),recentFiles:d(Rt).nullish(),relatedSnippets:d(Vt).nullish(),userActions:d(ln).nullish()}),vn=r({newText:s(),range:N}),yn=c([r({cursorPosition:M.nullish(),edits:d(vn),id:s(),uri:s()}).and(r({kind:n(`edit`)})),sn.and(r({kind:n(`jump`)})),cn.and(r({kind:n(`rename`)})),qt.and(r({kind:n(`searchAndReplace`)}))]),bn=r({_meta:f(s(),a()).nullish(),content:s()}),xn=r({_meta:f(s(),a()).nullish()}),P=c([i(),s()]).nullable();r({_meta:f(s(),a()).nullish(),requestId:P});var Sn=r({requestId:P}),Cn=u([`assistant`,`user`]),F=r({_meta:f(s(),a()).nullish(),audience:d(Cn).nullish(),lastModified:s().nullish(),priority:i().nullish()}),wn=r({_meta:f(s(),a()).nullish(),annotations:F.nullish(),data:s(),mimeType:s()}),Tn=r({_meta:f(s(),a()).nullish(),annotations:F.nullish(),data:s(),mimeType:s(),uri:s().nullish()}),En=r({_meta:f(s(),a()).nullish(),annotations:F.nullish(),description:s().nullish(),mimeType:s().nullish(),name:s(),size:i().nullish(),title:s().nullish(),uri:s()}),Dn=r({_meta:f(s(),a()).nullish(),optionId:$t}),On=c([r({outcome:n(`cancelled`)}),Dn.and(r({outcome:n(`selected`)}))]),kn=r({_meta:f(s(),a()).nullish(),outcome:On}),An=r({_meta:f(s(),a()).nullish()}),jn=r({_meta:f(s(),a()).nullish()}),Mn=r({currentValue:l()}),Nn=s(),Pn=s(),Fn=c([n(`mode`),n(`model`),n(`thought_level`),s()]),I=s(),In=r({_meta:f(s(),a()).nullish(),description:s().nullish(),name:s(),value:I}),Ln=r({_meta:f(s(),a()).nullish(),group:Nn,name:s(),options:d(In)}),L=m(c([r({currentValue:I,options:c([d(In),d(Ln)])}).and(r({type:n(`select`)})),Mn.and(r({type:n(`boolean`)}))]),r({_meta:f(s(),a()).nullish(),category:Fn.nullish(),description:s().nullish(),id:Pn,name:s()})),Rn=r({_meta:f(s(),a()).nullish(),configOptions:d(L)}),zn=r({_meta:f(s(),a()).nullish()}),R=s(),Bn=r({_meta:f(s(),a()).nullish(),id:s(),sessionId:R}),Vn=r({_meta:f(s(),a()).nullish(),sessionId:R}),Hn=r({_meta:f(s(),a()).nullish(),sessionId:R}),Un=r({_meta:f(s(),a()).nullish(),sessionId:R}),Wn=r({_meta:f(s(),a()).nullish(),args:d(s()).optional(),command:s(),cwd:s().nullish(),env:d(st).optional(),outputByteLimit:i().nullish(),sessionId:R}),Gn=r({_meta:f(s(),a()).nullish(),sessionId:R,uri:s()}),Kn=r({_meta:f(s(),a()).nullish(),position:M,sessionId:R,uri:s(),version:i(),visibleRange:N}),qn=r({_meta:f(s(),a()).nullish(),languageId:s(),sessionId:R,text:s(),uri:s(),version:i()}),Jn=r({_meta:f(s(),a()).nullish(),sessionId:R,uri:s()}),Yn=r({_meta:f(s(),a()).nullish(),additionalDirectories:d(s()).optional(),cwd:s(),mcpServers:d(A).optional(),sessionId:R}),Xn=r({_meta:f(s(),a()).nullish(),sessionId:R,terminalId:s()}),Zn=r({_meta:f(s(),a()).nullish(),additionalDirectories:d(s()).optional(),cwd:s(),mcpServers:d(A),sessionId:R}),Qn=r({_meta:f(s(),a()).nullish(),limit:i().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),line:i().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),path:s(),sessionId:R}),$n=r({_meta:f(s(),a()).nullish(),id:s(),reason:Bt.nullish(),sessionId:R}),er=r({_meta:f(s(),a()).nullish(),sessionId:R,terminalId:s()}),tr=r({_meta:f(s(),a()).nullish(),additionalDirectories:d(s()).optional(),cwd:s(),mcpServers:d(A).optional(),sessionId:R}),nr=r({_meta:f(s(),a()).nullish(),additionalDirectories:d(s()).optional(),cwd:s(),sessionId:R,title:s().nullish(),updatedAt:s().nullish()}),rr=r({_meta:f(s(),a()).nullish(),nextCursor:s().nullish(),sessions:d(nr)}),ir=r({_meta:f(s(),a()).nullish(),title:s().nullish(),updatedAt:s().nullish()}),ar=r({_meta:f(s(),a()).nullish()}),z=s(),or=r({_meta:f(s(),a()).nullish(),currentModeId:z}),sr=r({_meta:f(s(),a()).nullish(),description:s().nullish(),id:z,name:s()}),B=r({_meta:f(s(),a()).nullish(),availableModes:d(sr),currentModeId:z}),V=r({_meta:f(s(),a()).nullish(),availableModels:d(Et),currentModelId:j}),cr=r({_meta:f(s(),a()).nullish(),configOptions:d(L).nullish(),models:V.nullish(),modes:B.nullish(),sessionId:R}),lr=r({_meta:f(s(),a()).nullish(),configOptions:d(L).nullish(),models:V.nullish(),modes:B.nullish()}),ur=r({_meta:f(s(),a()).nullish(),configOptions:d(L).nullish(),models:V.nullish(),modes:B.nullish(),sessionId:R}),dr=r({_meta:f(s(),a()).nullish(),configOptions:d(L).nullish(),models:V.nullish(),modes:B.nullish()}),fr=r({_meta:f(s(),a()).nullish()}),pr=r({_meta:f(s(),a()).nullish(),additionalDirectories:An.nullish(),close:jn.nullish(),fork:zn.nullish(),list:ar.nullish(),resume:fr.nullish()}),mr=m(c([r({type:n(`boolean`),value:l()}),r({value:I})]),r({_meta:f(s(),a()).nullish(),configId:Pn,sessionId:R})),hr=r({_meta:f(s(),a()).nullish(),configOptions:d(L)}),gr=r({_meta:f(s(),a()).nullish(),modeId:z,sessionId:R}),_r=r({_meta:f(s(),a()).nullish()}),vr=r({_meta:f(s(),a()).nullish(),modelId:j,sessionId:R}),yr=r({_meta:f(s(),a()).nullish()}),br=r({_meta:f(s(),a()).nullish(),sessionId:R}),xr=c([n(`end_turn`),n(`max_tokens`),n(`max_turn_requests`),n(`refusal`),n(`cancelled`)]),Sr=c([n(`email`),n(`uri`),n(`date`),n(`date-time`)]),Cr=r({default:s().nullish(),description:s().nullish(),enum:d(s()).nullish(),format:Sr.nullish(),maxLength:i().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),minLength:i().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),oneOf:d(ot).nullish(),pattern:s().nullish(),title:s().nullish()}),wr=r({_meta:f(s(),a()).nullish(),context:_n.nullish(),position:M,selection:N.nullish(),sessionId:R,triggerKind:Jt,uri:s(),version:i()}),Tr=r({_meta:f(s(),a()).nullish(),suggestions:d(yn)}),Er=r({_meta:f(s(),a()).nullish(),terminalId:s()}),Dr=r({_meta:f(s(),a()).nullish(),exitCode:i().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),signal:s().nullish()}),Or=r({_meta:f(s(),a()).nullish(),sessionId:R,terminalId:s()}),kr=r({_meta:f(s(),a()).nullish(),exitStatus:Dr.nullish(),output:s(),truncated:l()}),Ar=r({_meta:f(s(),a()).nullish(),annotations:F.nullish(),text:s()}),jr=r({range:N.nullish(),text:s()}),Mr=r({_meta:f(s(),a()).nullish(),contentChanges:d(jr),sessionId:R,uri:s(),version:i()});r({method:s(),params:c([Vn,qn,Mr,Gn,Jn,Kn,Bn,$n,lt]).nullish()});var Nr=c([n(`full`),n(`incremental`)]),Pr=r({_meta:f(s(),a()).nullish(),syncKind:Nr}),Fr=r({_meta:f(s(),a()).nullish(),didChange:Pr.nullish(),didClose:kt.nullish(),didFocus:At.nullish(),didOpen:jt.nullish(),didSave:Mt.nullish()}),Ir=r({_meta:f(s(),a()).nullish(),document:Fr.nullish()}),Lr=r({_meta:f(s(),a()).nullish(),context:Xt.nullish(),events:Ir.nullish()}),Rr=r({_meta:f(s(),a()).nullish(),auth:yt.optional().default({}),loadSession:l().optional().default(!1),mcpCapabilities:St.optional().default({http:!1,sse:!1}),nes:Lr.nullish(),positionEncoding:un.nullish(),promptCapabilities:fn.optional().default({audio:!1,embeddedContext:!1,image:!1}),sessionCapabilities:pr.optional().default({})}),zr=r({_meta:f(s(),a()).nullish(),agentCapabilities:Rr.optional().default({auth:{},loadSession:!1,mcpCapabilities:{http:!1,sse:!1},promptCapabilities:{audio:!1,embeddedContext:!1,image:!1},sessionCapabilities:{}}),agentInfo:mt.nullish(),authMethods:d(Ve).optional().default([]),protocolVersion:pn}),Br=c([r({_meta:f(s(),a()).nullish(),mimeType:s().nullish(),text:s(),uri:s()}),We]),Vr=r({_meta:f(s(),a()).nullish(),annotations:F.nullish(),resource:Br}),H=c([Ar.and(r({type:n(`text`)})),Tn.and(r({type:n(`image`)})),wn.and(r({type:n(`audio`)})),En.and(r({type:n(`resource_link`)})),Vr.and(r({type:n(`resource`)}))]),Hr=r({_meta:f(s(),a()).nullish(),content:H}),U=r({_meta:f(s(),a()).nullish(),content:H,messageId:s().nullish()}),Ur=r({_meta:f(s(),a()).nullish(),messageId:s().nullish(),prompt:d(H),sessionId:R}),Wr=r({anyOf:d(ot)}),Gr=c([Hr.and(r({type:n(`content`)})),Xe.and(r({type:n(`diff`)})),Er.and(r({type:n(`terminal`)}))]),W=s(),Kr=r({sessionId:R,toolCallId:W.nullish()}),qr=m(c([Kr,Sn]),r({elicitationId:et,url:s().url()})),Jr=r({_meta:f(s(),a()).nullish(),line:i().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),path:s()}),Yr=c([n(`pending`),n(`in_progress`),n(`completed`),n(`failed`)]),Xr=c([n(`read`),n(`edit`),n(`delete`),n(`move`),n(`search`),n(`execute`),n(`think`),n(`fetch`),n(`switch_mode`),n(`other`)]),Zr=r({_meta:f(s(),a()).nullish(),content:d(Gr).optional(),kind:Xr.optional(),locations:d(Jr).optional(),rawInput:a().optional(),rawOutput:a().optional(),status:Yr.optional(),title:s(),toolCallId:W}),Qr=r({_meta:f(s(),a()).nullish(),content:d(Gr).nullish(),kind:Xr.nullish(),locations:d(Jr).nullish(),rawInput:a().optional(),rawOutput:a().optional(),status:Yr.nullish(),title:s().nullish(),toolCallId:W}),$r=r({_meta:f(s(),a()).nullish(),options:d(tn),sessionId:R,toolCall:Qr}),ei=r({_meta:f(s(),a()).nullish(),hint:s()}),ti=r({_meta:f(s(),a()).nullish(),description:s(),input:ei.nullish(),name:s()}),ni=r({_meta:f(s(),a()).nullish(),availableCommands:d(ti)}),ri=c([r({enum:d(s()),type:rt}),Wr]),ii=r({default:d(s()).nullish(),description:s().nullish(),items:ri,maxItems:i().nullish(),minItems:i().nullish(),title:s().nullish()}),ai=c([Cr.and(r({type:n(`string`)})),Qt.and(r({type:n(`number`)})),ht.and(r({type:n(`integer`)})),Ge.and(r({type:n(`boolean`)})),ii.and(r({type:n(`array`)}))]),oi=r({description:s().nullish(),properties:f(s(),ai).optional().default({}),required:d(s()).nullish(),title:s().nullish(),type:nt.optional().default(`object`)}),si=m(c([m(c([Kr,Sn]),r({requestedSchema:oi})).and(r({mode:n(`form`)})),qr.and(r({mode:n(`url`)}))]),r({_meta:f(s(),a()).nullish(),message:s()})),ci=r({cachedReadTokens:i().nullish(),cachedWriteTokens:i().nullish(),inputTokens:i(),outputTokens:i(),thoughtTokens:i().nullish(),totalTokens:i()});c([r({id:P,result:c([zr,Ue,xt,ur,lr,rr,cr,dr,qe,_r,hr,r({_meta:f(s(),a()).nullish(),stopReason:xr,usage:ci.nullish(),userMessageId:s().nullish()}),yr,br,Tr,Ke,dt])}),r({error:ct,id:P})]);var li=r({_meta:f(s(),a()).nullish(),cost:Je.nullish(),size:i(),used:i()}),ui=c([U.and(r({sessionUpdate:n(`user_message_chunk`)})),U.and(r({sessionUpdate:n(`agent_message_chunk`)})),U.and(r({sessionUpdate:n(`agent_thought_chunk`)})),Zr.and(r({sessionUpdate:n(`tool_call`)})),Qr.and(r({sessionUpdate:n(`tool_call_update`)})),on.and(r({sessionUpdate:n(`plan`)})),ni.and(r({sessionUpdate:n(`available_commands_update`)})),or.and(r({sessionUpdate:n(`current_mode_update`)})),Rn.and(r({sessionUpdate:n(`config_option_update`)})),ir.and(r({sessionUpdate:n(`session_info_update`)})),li.and(r({sessionUpdate:n(`usage_update`)}))]),di=r({_meta:f(s(),a()).nullish(),sessionId:R,update:ui});r({method:s(),params:c([di,tt,lt]).nullish()});var fi=r({_meta:f(s(),a()).nullish(),sessionId:R,terminalId:s()}),pi=r({_meta:f(s(),a()).nullish(),exitCode:i().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),signal:s().nullish()}),mi=r({name:s(),uri:s()}),hi=r({_meta:f(s(),a()).nullish(),repository:Wt.nullish(),workspaceFolders:d(mi).nullish(),workspaceUri:s().nullish()});r({id:P,method:s(),params:c([mn,He,bt,Zt,Zn,_t,Yn,tr,Un,gr,mr,Ur,vr,hi,wr,Hn,ut]).nullish()});var gi=r({_meta:f(s(),a()).nullish(),content:s(),path:s(),sessionId:R});r({id:P,method:s(),params:c([gi,Qn,$r,Wn,Or,er,fi,Xn,si,ut]).nullish()}),c([r({id:P,result:c([r({_meta:f(s(),a()).nullish()}),bn,kn,Ye,kr,xn,pi,gt,Qe,dt])}),r({error:ct,id:P})]),e();function _i(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()}}})}}m();var vi,yi=class{constructor(e,n){t(this,`connection`,void 0);let r=e(this),i=async(e,t)=>{switch(e){case O.initialize:{let e=mn.parse(t);return r.initialize(e)}case O.session_new:{let e=Zt.parse(t);return r.newSession(e)}case O.session_load:{if(!r.loadSession)throw G.methodNotFound(e);let n=Zn.parse(t);return r.loadSession(n)}case O.session_list:{if(!r.listSessions)throw G.methodNotFound(e);let n=_t.parse(t);return r.listSessions(n)}case O.session_fork:{if(!r.unstable_forkSession)throw G.methodNotFound(e);let n=Yn.parse(t);return r.unstable_forkSession(n)}case O.session_resume:{if(!r.unstable_resumeSession)throw G.methodNotFound(e);let n=tr.parse(t);return r.unstable_resumeSession(n)}case O.session_close:{if(!r.unstable_closeSession)throw G.methodNotFound(e);let n=Un.parse(t);return r.unstable_closeSession(n)}case O.session_set_mode:{if(!r.setSessionMode)throw G.methodNotFound(e);let n=gr.parse(t);return await r.setSessionMode(n)??{}}case O.authenticate:{let e=He.parse(t);return await r.authenticate(e)??{}}case O.logout:{if(!r.unstable_logout)throw G.methodNotFound(e);let n=bt.parse(t);return await r.unstable_logout(n)??{}}case O.session_prompt:{let e=Ur.parse(t);return r.prompt(e)}case O.session_set_model:{if(!r.unstable_setSessionModel)throw G.methodNotFound(e);let n=vr.parse(t);return await r.unstable_setSessionModel(n)??{}}case O.session_set_config_option:{if(!r.setSessionConfigOption)throw G.methodNotFound(e);let n=mr.parse(t);return r.setSessionConfigOption(n)}case O.nes_start:{if(!r.unstable_startNes)throw G.methodNotFound(e);let n=hi.parse(t);return r.unstable_startNes(n)}case O.nes_suggest:{if(!r.unstable_suggestNes)throw G.methodNotFound(e);let n=wr.parse(t);return r.unstable_suggestNes(n)}case O.nes_close:{if(!r.unstable_closeNes)throw G.methodNotFound(e);let n=Hn.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 O.session_cancel:{let e=Vn.parse(t);return r.cancel(e)}case O.document_did_open:{if(!r.unstable_didOpenDocument)return;let e=qn.parse(t);return r.unstable_didOpenDocument(e)}case O.document_did_change:{if(!r.unstable_didChangeDocument)return;let e=Mr.parse(t);return r.unstable_didChangeDocument(e)}case O.document_did_close:{if(!r.unstable_didCloseDocument)return;let e=Gn.parse(t);return r.unstable_didCloseDocument(e)}case O.document_did_save:{if(!r.unstable_didSaveDocument)return;let e=Jn.parse(t);return r.unstable_didSaveDocument(e)}case O.document_did_focus:{if(!r.unstable_didFocusDocument)return;let e=Kn.parse(t);return r.unstable_didFocusDocument(e)}case O.nes_accept:{if(!r.unstable_acceptNes)return;let e=Bn.parse(t);return r.unstable_acceptNes(e)}case O.nes_reject:{if(!r.unstable_rejectNes)return;let e=$n.parse(t);return r.unstable_rejectNes(e)}default:if(r.extNotification)return r.extNotification(e,t);throw G.methodNotFound(e)}};this.connection=new xi(i,a,n)}async sessionUpdate(e){return await this.connection.sendNotification(k.session_update,e)}async requestPermission(e){return await this.connection.sendRequest(k.session_request_permission,e)}async readTextFile(e){return await this.connection.sendRequest(k.fs_read_text_file,e)}async writeTextFile(e){return await this.connection.sendRequest(k.fs_write_text_file,e)??{}}async createTerminal(e){return new bi((await this.connection.sendRequest(k.terminal_create,e)).terminalId,e.sessionId,this.connection)}async unstable_createElicitation(e){return await this.connection.sendRequest(k.elicitation_create,e)}async unstable_completeElicitation(e){return await this.connection.sendNotification(k.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}};vi=Symbol.asyncDispose;var bi=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(k.terminal_output,{sessionId:this.sessionId,terminalId:this.id})}async waitForExit(){return await this.connection.sendRequest(k.terminal_wait_for_exit,{sessionId:this.sessionId,terminalId:this.id})}async kill(){return await this.connection.sendRequest(k.terminal_kill,{sessionId:this.sessionId,terminalId:this.id})??{}}async release(){return await this.connection.sendRequest(k.terminal_release,{sessionId:this.sessionId,terminalId:this.id})??{}}async[vi](){await this.release()}},xi=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 i)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 i)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}}};h(),v(),ye(),Te(),be(),De(),ce(),ae(),_e(),re(),ee(),pe();function K(e,t){if(e)return t?Pe(e)?e:Fe(t,e):e}var Si=!(typeof process.geteuid==`function`?process.geteuid()===0:typeof process.getuid==`function`&&process.getuid()===0)||!!process.env.IS_SANDBOX,Ci={auto:`auto`,default:`default`,acceptedits:`acceptEdits`,dontask:`dontAsk`,plan:`plan`,bypasspermissions:`bypassPermissions`,bypass:`bypassPermissions`};function wi(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=Ci[n];if(!r)throw Error(`Invalid ${t}: ${e}.`);if(r===`bypassPermissions`&&!Si)throw Error(`Invalid ${t}: bypassPermissions is not available when running as root.`);return r}function Ti(e){let t=[...e.mcpServers??[]].sort((e,t)=>e.name.localeCompare(t.name));return JSON.stringify({cwd:e.cwd,mcpServers:t})}var Ei=256;function Di(e){let t=e.replace(/[\r\n]+/g,` `).replace(/\s+/g,` `).trim();return t.length<=Ei?t:t.slice(0,Ei-1)+`…`}function q(e,t){if(!t)return e;let n=D.resolve(t),r=D.resolve(e);return r.startsWith(n+D.sep)||r===n?D.relative(n,r):e}function Oi(e){let t="```";for(let n of e.matchAll(/^```+/gm)??[])for(;n[0].length>=t.length;)t+="`";return t+`
3
+ `,i=e.getWriter();try{await i.write(n.encode(r))}finally{i.releaseLock()}}})}}p();var vi,yi=class{constructor(e,n){t(this,`connection`,void 0);let r=e(this),i=async(e,t)=>{switch(e){case O.initialize:{let e=mn.parse(t);return r.initialize(e)}case O.session_new:{let e=Zt.parse(t);return r.newSession(e)}case O.session_load:{if(!r.loadSession)throw G.methodNotFound(e);let n=Zn.parse(t);return r.loadSession(n)}case O.session_list:{if(!r.listSessions)throw G.methodNotFound(e);let n=_t.parse(t);return r.listSessions(n)}case O.session_fork:{if(!r.unstable_forkSession)throw G.methodNotFound(e);let n=Yn.parse(t);return r.unstable_forkSession(n)}case O.session_resume:{if(!r.unstable_resumeSession)throw G.methodNotFound(e);let n=tr.parse(t);return r.unstable_resumeSession(n)}case O.session_close:{if(!r.unstable_closeSession)throw G.methodNotFound(e);let n=Un.parse(t);return r.unstable_closeSession(n)}case O.session_set_mode:{if(!r.setSessionMode)throw G.methodNotFound(e);let n=gr.parse(t);return await r.setSessionMode(n)??{}}case O.authenticate:{let e=He.parse(t);return await r.authenticate(e)??{}}case O.logout:{if(!r.unstable_logout)throw G.methodNotFound(e);let n=bt.parse(t);return await r.unstable_logout(n)??{}}case O.session_prompt:{let e=Ur.parse(t);return r.prompt(e)}case O.session_set_model:{if(!r.unstable_setSessionModel)throw G.methodNotFound(e);let n=vr.parse(t);return await r.unstable_setSessionModel(n)??{}}case O.session_set_config_option:{if(!r.setSessionConfigOption)throw G.methodNotFound(e);let n=mr.parse(t);return r.setSessionConfigOption(n)}case O.nes_start:{if(!r.unstable_startNes)throw G.methodNotFound(e);let n=hi.parse(t);return r.unstable_startNes(n)}case O.nes_suggest:{if(!r.unstable_suggestNes)throw G.methodNotFound(e);let n=wr.parse(t);return r.unstable_suggestNes(n)}case O.nes_close:{if(!r.unstable_closeNes)throw G.methodNotFound(e);let n=Hn.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 O.session_cancel:{let e=Vn.parse(t);return r.cancel(e)}case O.document_did_open:{if(!r.unstable_didOpenDocument)return;let e=qn.parse(t);return r.unstable_didOpenDocument(e)}case O.document_did_change:{if(!r.unstable_didChangeDocument)return;let e=Mr.parse(t);return r.unstable_didChangeDocument(e)}case O.document_did_close:{if(!r.unstable_didCloseDocument)return;let e=Gn.parse(t);return r.unstable_didCloseDocument(e)}case O.document_did_save:{if(!r.unstable_didSaveDocument)return;let e=Jn.parse(t);return r.unstable_didSaveDocument(e)}case O.document_did_focus:{if(!r.unstable_didFocusDocument)return;let e=Kn.parse(t);return r.unstable_didFocusDocument(e)}case O.nes_accept:{if(!r.unstable_acceptNes)return;let e=Bn.parse(t);return r.unstable_acceptNes(e)}case O.nes_reject:{if(!r.unstable_rejectNes)return;let e=$n.parse(t);return r.unstable_rejectNes(e)}default:if(r.extNotification)return r.extNotification(e,t);throw G.methodNotFound(e)}};this.connection=new xi(i,a,n)}async sessionUpdate(e){return await this.connection.sendNotification(k.session_update,e)}async requestPermission(e){return await this.connection.sendRequest(k.session_request_permission,e)}async readTextFile(e){return await this.connection.sendRequest(k.fs_read_text_file,e)}async writeTextFile(e){return await this.connection.sendRequest(k.fs_write_text_file,e)??{}}async createTerminal(e){return new bi((await this.connection.sendRequest(k.terminal_create,e)).terminalId,e.sessionId,this.connection)}async unstable_createElicitation(e){return await this.connection.sendRequest(k.elicitation_create,e)}async unstable_completeElicitation(e){return await this.connection.sendNotification(k.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}};vi=Symbol.asyncDispose;var bi=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(k.terminal_output,{sessionId:this.sessionId,terminalId:this.id})}async waitForExit(){return await this.connection.sendRequest(k.terminal_wait_for_exit,{sessionId:this.sessionId,terminalId:this.id})}async kill(){return await this.connection.sendRequest(k.terminal_kill,{sessionId:this.sessionId,terminalId:this.id})??{}}async release(){return await this.connection.sendRequest(k.terminal_release,{sessionId:this.sessionId,terminalId:this.id})??{}}async[vi](){await this.release()}},xi=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 o)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 o)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}}};h(),v(),_e(),Ce(),ve(),Te(),se(),ae(),re(),ee(),fe(),Oe();function K(e,t){if(e)return t?Pe(e)?e:Fe(t,e):e}var Si=!(typeof process.geteuid==`function`?process.geteuid()===0:typeof process.getuid==`function`&&process.getuid()===0)||!!process.env.IS_SANDBOX,Ci={auto:`auto`,default:`default`,acceptedits:`acceptEdits`,dontask:`dontAsk`,plan:`plan`,bypasspermissions:`bypassPermissions`,bypass:`bypassPermissions`};function wi(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=Ci[n];if(!r)throw Error(`Invalid ${t}: ${e}.`);if(r===`bypassPermissions`&&!Si)throw Error(`Invalid ${t}: bypassPermissions is not available when running as root.`);return r}function Ti(e){let t=[...e.mcpServers??[]].sort((e,t)=>e.name.localeCompare(t.name));return JSON.stringify({cwd:e.cwd,mcpServers:t})}var Ei=256;function Di(e){let t=e.replace(/[\r\n]+/g,` `).replace(/\s+/g,` `).trim();return t.length<=Ei?t:t.slice(0,Ei-1)+`…`}function q(e,t){if(!t)return e;let n=D.resolve(t),r=D.resolve(e);return r.startsWith(n+D.sep)||r===n?D.relative(n,r):e}function Oi(e){let t="```";for(let n of e.matchAll(/^```+/gm)??[])for(;n[0].length>=t.length;)t+="`";return t+`
4
4
  `+e+(e.endsWith(`
5
5
  `)?``:`
6
6
  `)+t}function J(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 ki(e,t){return Array.isArray(e)&&e.length>0?{content:e.map(e=>({type:`content`,content:Ai(e,t)}))}:typeof e==`string`&&e.length>0?{content:[{type:`content`,content:{type:`text`,text:t?`\`\`\`\n${e}\n\`\`\``:e}}]}:{}}function Ai(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(`
@@ -10,5 +10,5 @@ import{n as e,t}from"./defineProperty-C-QyHrDq.js";import{A as n,E as r,I as i,M
10
10
 
11
11
  Compacting completed.`}}}));break;case`result`:{let t=g.usage;t&&(l.inputTokens+=t.input_tokens??0,l.outputTokens+=t.output_tokens??0,l.cachedReadTokens+=t.cache_read_input_tokens??0,l.cachedWriteTokens+=t.cache_creation_input_tokens??0);let i=g.modelUsage;if(i&&d){let e=Ii(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=E());let r=Pi(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=E()),s=m);let c=Ni(g,e,i,n,{clientCapabilities:a,cwd:o,parentToolUseId:r,streamingActive:p,messageId:s});for(let e of c)await n.sessionUpdate(e);r===null&&(m=null);break}case`user`:break;case`progress`:{let t=g.data;if(!t)break;let r=t.type;if(r===`agent_progress`||r===`skill_progress`){let r=t.message;if(r){let t=r.content;if(t)for(let r of t)r.type===`text`&&await n.sessionUpdate({sessionId:e,update:{sessionUpdate:`agent_message_chunk`,content:{type:`text`,text:r.text}}})}}break}case`tool_use_summary`:break;case`attachment`:break;case`compact_boundary`:u=0,await n.sessionUpdate({sessionId:e,update:{sessionUpdate:`agent_message_chunk`,content:{type:`text`,text:`
12
12
 
13
- Compacting completed.`}}});break;default:Li.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 X(e,t,n,r,i,a){for(let o of t){let t=o;if(t.type!==`user`&&t.type!==`assistant`){Li.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=E();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=Y(s,c,e,r,n,void 0,{clientCapabilities:i,cwd:a,messageId:E()});for(let e of t)await n.sessionUpdate(e)}}}function Bi(e,t,n,r,i,a,o,s){return async(n,c,l,u,d,f)=>{let p=Hi(r);if(n.name===`ExitPlanMode`)return Vi(e,t,d,c,p,i,a,o,s);if(f!==void 0)return f;try{let e=await ie(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=J({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 Vi(e,t,n,r,i,a,o,s,c){let l=[{kind:`allow_always`,name:`Yes, and use "auto" mode`,optionId:`auto`},{kind:`allow_always`,name:`Yes, and auto-accept edits`,optionId:`acceptEdits`},{kind:`allow_once`,name:`Yes, and manually approve edits`,optionId:`default`},{kind:`reject_once`,name:`No, keep planning`,optionId:`plan`}];s?.()===!0&&l.unshift({kind:`allow_always`,name:`Yes, and bypass permissions`,optionId:`bypassPermissions`});let u=J({name:`ExitPlanMode`,id:n,input:r},i,a),d={toolCallId:n,title:u.title,kind:u.kind,status:`pending`,rawInput:r},f=await e.requestPermission({sessionId:t,toolCall:d,options:l});if(f.outcome.outcome===`cancelled`)return c?.(),{behavior:`deny`,message:`Tool use aborted`,decisionReason:{type:`mode`,mode:`default`}};if(f.outcome.outcome===`selected`&&`optionId`in f.outcome&&f.outcome.optionId!==void 0){let n=f.outcome.optionId;if(l.some(e=>e.optionId===n)&&(n==="default"||n===`acceptEdits`||n===`auto`||n===`bypassPermissions`))return o?.(n),await e.sessionUpdate({sessionId:t,update:{sessionUpdate:`current_mode_update`,currentModeId:n}}),{behavior:`allow`,updatedInput:r}}return{behavior:`deny`,message:`User rejected request to exit plan mode.`,decisionReason:{type:`mode`,mode:`plan`}}}function Hi(e){if(!e)return!1;if(e.terminal===!0)return!0;let t=e._meta;return!t||typeof t!=`object`?!1:t.terminal_output===!0}Ce(),ne(),se(),w(),e(),te(),fe();var Z=class{constructor(e){t(this,`conn`,void 0),t(this,`sessions`,new Map),t(this,`clientCapabilities`,void 0),this.conn=e}async initialize(e){return this.clientCapabilities=e.clientCapabilities,{protocolVersion:1,authMethods:[],agentInfo:{name:`claude-code`,title:`Work Mate`,version:typeof globalThis.MACRO==`object`&&globalThis.MACRO!==null?String(globalThis.MACRO.VERSION??`0.0.0`):`0.0.0`},agentCapabilities:{_meta:{claudeCode:{promptQueueing:!0,forkSession:!0}},promptCapabilities:{image:!1,embeddedContext:!0},mcpCapabilities:{http:!0,sse:!0},loadSession:!0,sessionCapabilities:{list:{},resume:{},close:{},delete:{}}}}}async authenticate(e){return{}}async newSession(e){let t=await this.createSession(e);return this.scheduleAvailableCommandsUpdate(t.sessionId),t}async unstable_resumeSession(e){let t=await this.getOrCreateSession({...e,replay:!1});return this.scheduleAvailableCommandsUpdate(t.sessionId),t}async loadSession(e){let t=await this.getOrCreateSession(e);return this.scheduleAvailableCommandsUpdate(t.sessionId),t}async listSessions(e){if(e.cursor!==void 0&&e.cursor!==null)throw Error(`Pagination cursor not supported: listSessions returns all results in a single page.`);let t=e.cwd||b(),n=await Se(t),r=await ge({dir:t}),i=[];for(let e of r){if(!e.cwd||await Se(e.cwd)!==n)continue;let t=Di(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 Ui(e.sessionId),n=await this.createSession({cwd:e.cwd,mcpServers:e.mcpServers??[],_meta:e._meta},{initialMessages:t});return this.scheduleAvailableCommandsUpdate(n.sessionId),n}async unstable_closeSession(e){if(!this.sessions.get(e.sessionId))throw Error(`Session not found`);return await this.teardownSession(e.sessionId),{}}async unstable_deleteSession(e){let t=await T(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 Ui(e){let t;try{let n=await C(e);n&&n.messages.length>0&&(t=S(n.messages))}catch(e){console.error(`[ACP] fork source load failed:`,e)}return{initialMessages:t}}var Wi=[`auto`,`default`,`acceptEdits`,`bypassPermissions`,`dontAsk`,`plan`];function Gi(e){return Wi.includes(e)}function Ki(e,t,n){if(t){let t=qi(e,`_meta.permissionMode`);if(t===`bypassPermissions`&&!Xi())throw Error(`Mode not available: bypassPermissions cannot run as root (start the agent as a non-root user, or set IS_SANDBOX=1).`);return t}return Ji(n)??`default`}function qi(e,t){if(e==null)throw Error(`Invalid ${t}: expected a string.`);return wi(e,t)}function Ji(e){if(e!=null)try{return wi(e,`permissions.defaultMode`)}catch(e){let t=e instanceof Error?e.message:String(e);console.error(`[ACP] Invalid permissions.defaultMode, using default:`,t);return}}function Yi(e,t){return!!e&&Object.hasOwn(e,t)}function Xi(){return Zi()}function Zi(){return process.env.IS_SANDBOX?!0:typeof process.geteuid==`function`?process.geteuid()!==0:typeof process.getuid!=`function`||process.getuid()!==0}function Qi(e,t){return[{id:`mode`,name:`Mode`,description:`Session permission mode`,category:`mode`,type:`select`,currentValue:e.currentModeId,options:e.availableModes.map(e=>({value:e.id,name:e.name,description:e.description}))},{id:`model`,name:`Model`,description:`AI model to use`,category:`model`,type:`select`,currentValue:t.currentModelId,options:t.availableModels.map(e=>({value:e.modelId,name:e.name,description:e.description??void 0}))}]}function $i(e){let t=[];if(!Array.isArray(e))return t;for(let n of e){if(typeof n!=`object`||!n)continue;let e=n;if(Array.isArray(e.options))for(let n of e.options)n&&typeof n==`object`&&typeof n.value==`string`&&t.push(n.value);else typeof n.value==`string`&&t.push(n.value)}return t}function Q(e){return e.conn}function $(e){return e.clientCapabilities}function ea(e,t,n,r){n===`mode`?t.modes={...t.modes,currentModeId:r}:n===`model`&&(t.models={...t.models,currentModelId:r})}v();function ta(){return ve().permissions?.defaultMode}async function na(e,t={}){xe();let n=t.sessionId??E(),r=e.cwd;x(n,_()),g(r);let i=process.cwd(),a=!1;try{process.chdir(r),a=!0}catch{}y(),he();try{let i=Ee(),a=oe(i),o=e._meta,s=Yi(o,`permissionMode`),c=Ki(s?o?.permissionMode:void 0,s,ta()),l=$(this),u=this.conn,d=Bi(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=Xi(),p={...ue(),toolPermissionContext:{...i,mode:c,isBypassPermissionsModeAvailable:f}},[m,h]=await Promise.all([me(r),le(r)]);p.agentDefinitions=h;let g=new ke({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 Oe(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`}]},v=de(),y=we(),b={availableModels:v.map(e=>({modelId:String(e.value??``),name:e.label??String(e.value??``),description:e.description??void 0})),currentModelId:y};g.setModel(y);let x=Qi(_,b),ee={queryEngine:g,cancelled:!1,cancelGeneration:0,cwd:r,modes:_,models:b,configOptions:x,promptRunning:!1,pendingMessages:new Map,pendingQueue:[],pendingQueueHead:0,toolUseCache:{},clientCapabilities:l,appState:p,commands:m,sessionFingerprint:Ti({cwd:r,mcpServers:e.mcpServers})};return this.sessions.set(n,ee),{sessionId:n,modes:_,models:b,configOptions:x}}finally{a&&process.chdir(i)}}Object.assign(Z.prototype,{createSession:na}),te(),fe(),v(),w();async function ra(e){let t=e.replay!==!1,n=this.sessions.get(e.sessionId);if(n){if(Ti({cwd:e.cwd,mcpServers:e.mcpServers})===n.sessionFingerprint){let r=await T(e.sessionId,e.cwd);return x(e.sessionId,r?Ae(r.filePath):null),g(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 T(e.sessionId,e.cwd),i=r?Ae(r.filePath):null;x(e.sessionId,i),g(e.cwd);let a;if(r)try{let t=await C(e.sessionId);t&&t.messages.length>0&&(a=S(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 X(e.sessionId,a,Q(this),t.toolUseCache,$(this),t.cwd)}return{sessionId:o.sessionId,modes:o.modes,models:o.models,configOptions:o.configOptions}}async function ia(e){this.sessions.get(e)&&(await this.cancel({sessionId:e}),this.sessions.delete(e))}async function aa(e){try{let t=await C(e.sessionId);if(!t||t.messages.length===0)return;let n=S(t.messages);if(n.length===0)return;let r=this.sessions.get(e.sessionId);if(!r)return;await X(e.sessionId,n,Q(this),r.toolUseCache,$(this),r.cwd)}catch(e){console.error(`[ACP] Failed to replay session history:`,e)}}function oa(e,t){if(!Gi(t))throw Error(`Invalid mode: ${t}`);let n=this.sessions.get(e);if(n){if(t===`bypassPermissions`&&!n.appState.toolPermissionContext.isBypassPermissionsModeAvailable||!n.modes.availableModes.some(e=>e.id===t))throw Error(`Mode not available: ${t}`);n.modes={...n.modes,currentModeId:t},n.appState.toolPermissionContext={...n.appState.toolPermissionContext,mode:t}}}async function sa(e,t,n){let r=this.sessions.get(e);r&&(ea(this,r,t,n),r.configOptions=r.configOptions.map(e=>e.id===t&&typeof e.currentValue==`string`?{...e,currentValue:n}:e),await Q(this).sessionUpdate({sessionId:e,update:{sessionUpdate:`config_option_update`,configOptions:r.configOptions}}))}Object.assign(Z.prototype,{getOrCreateSession:ra,teardownSession:ia,replaySessionHistory:aa,applySessionMode:oa,updateConfigOption:sa});function ca(e){if(!e||e.length===0)return``;let t=[];for(let n of e){let e=n;if(e.type===`text`)t.push(String(e.text??``));else if(e.type===`resource_link`){let n=typeof e.name==`string`?e.name:void 0,r=typeof e.uri==`string`?e.uri:void 0;t.push(la(n,r))}else if(e.type===`resource`){let n=e.resource;if(n&&typeof n.text==`string`)t.push(n.text);else if(n&&typeof n.blob==`string`){let e=typeof n.mimeType==`string`?n.mimeType:`application/octet-stream`,r=typeof n.uri==`string`?n.uri:`(unknown uri)`;t.push(`Embedded resource: ${r} (${e}, base64 blob, ${n.blob.length} chars)`)}}}return t.filter(e=>e.length>0).join(`
14
- `)}function la(e,t){let n=[];return e&&e.length>0&&n.push(`name=${e}`),t&&t.length>0&&n.push(`uri=${t}`),n.length>0?`Resource link: ${n.join(`, `)}`:`Resource link`}function ua(e){for(;e.pendingQueueHead<e.pendingQueue.length;){let t=e.pendingQueue[e.pendingQueueHead++];if(!t)continue;let n=e.pendingMessages.get(t);if(n)return e.pendingMessages.delete(t),da(e),n}da(e)}function da(e){if(e.pendingQueueHead!==0){if(e.pendingQueueHead>=e.pendingQueue.length){e.pendingQueue=[],e.pendingQueueHead=0;return}e.pendingQueueHead>1024&&e.pendingQueueHead*2>e.pendingQueue.length&&(e.pendingQueue=e.pendingQueue.slice(e.pendingQueueHead),e.pendingQueueHead=0)}}v();async function fa(e){let t=this.sessions.get(e.sessionId);if(!t)throw Error(`Session ${e.sessionId} not found`);let n=e.messageId??void 0,r=ca(e.prompt);if(!r.trim())throw Error(`Prompt content is empty`);let i=t.cancelGeneration;if(t.promptRunning){let e=E();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(),x(e.sessionId,_());let i=t.queryEngine.submitMessage(r),{stopReason:a,usage:o}=await zi(e.sessionId,i,Q(this),t.queryEngine.getAbortSignal(),t.toolUseCache,$(this),t.cwd,()=>t.cancelled);if(t.cancelled)return{stopReason:`cancelled`};if(await ma(this,e.sessionId,r),o){let e={inputTokens:o.inputTokens,outputTokens:o.outputTokens,cachedReadTokens:o.cachedReadTokens,cachedWriteTokens:o.cachedWriteTokens,thoughtTokens:0,totalTokens:o.inputTokens+o.outputTokens+o.cachedReadTokens+o.cachedWriteTokens+0};return{stopReason:a,usage:e,...n?{userMessageId:n}:{},_meta:{claudeCode:{usage:e}}}}return{stopReason:a,...n?{userMessageId:n}:{}}}catch(n){let r=n instanceof Error&&(n.name===`AbortError`||/abort|cancelled|interrupt/i.test(n.message));if(t.cancelled||r)return{stopReason:`cancelled`};throw n instanceof Error&&(n.message.includes(`terminated`)||n.message.includes(`process exited`))?(await this.teardownSession(e.sessionId),Error(`The Claude Agent process exited unexpectedly. Please start a new session.`)):n}finally{let e=ua(t);e?(t.promptRunning=!0,e.resolve(!1)):t.promptRunning=!1}}async function pa(e){let t=this.sessions.get(e.sessionId);if(!t)throw Error(`Session not found`);if(typeof e.value!=`string`)throw Error(`Invalid value for config option ${e.configId}: ${String(e.value)}`);let n=t.configOptions.find(t=>t.id===e.configId);if(!n)throw Error(`Unknown config option: ${e.configId}`);if(n.type===`select`){let t=$i(n.options);if(!t.includes(e.value))throw Error(`Invalid value '${e.value}' for config option ${e.configId}; must be one of: ${t.join(`, `)}`)}let r=e.value;return e.configId===`mode`?(this.applySessionMode(e.sessionId,r),await Q(this).sessionUpdate({sessionId:e.sessionId,update:{sessionUpdate:`current_mode_update`,currentModeId:r}})):e.configId===`model`&&t.queryEngine.setModel(r),ea(this,t,e.configId,r),t.configOptions=t.configOptions.map(t=>t.id===e.configId&&typeof t.currentValue==`string`?{...t,currentValue:r}:t),{configOptions:t.configOptions}}async function ma(e,t,n){let r=e.sessions.get(t);if(!r)return;let i=r.toolUseCache;if(i.__sessionInfoTitleSent)return;i.__sessionInfoTitleSent=!0;let a=Di(n).slice(0,100);try{await Q(e).sessionUpdate({sessionId:t,update:{sessionUpdate:`session_info_update`,...a?{title:a}:{},updatedAt:new Date().toISOString()}})}catch(e){console.error(`[ACP] Failed to send session_info_update:`,e)}}Object.assign(Z.prototype,{prompt:fa,setSessionConfigOption:pa}),be(),_e();function ha(e,t){let n=je.toWeb(e);return _i(Me.toWeb(t),n)}async function ga(){xe(),he();let e=ha(process.stdin,process.stdout),t,n=new yi(e=>(t=new Z(e),t),e);console.log=console.error,console.info=console.error,console.warn=console.error,console.debug=console.error;async function r(){for(let[e]of t.sessions)try{await t.unstable_closeSession({sessionId:e})}catch{}process.exit(0)}n.closed.then(r).catch(r),process.on(`SIGTERM`,r),process.on(`SIGINT`,r),process.on(`unhandledRejection`,(e,t)=>{console.error(`Unhandled Rejection at:`,t,`reason:`,e)}),process.stdin.resume()}export{ga as runAcpAgent};
13
+ Compacting completed.`}}});break;default:Li.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 X(e,t,n,r,i,a){for(let o of t){let t=o;if(t.type!==`user`&&t.type!==`assistant`){Li.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=E();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=Y(s,c,e,r,n,void 0,{clientCapabilities:i,cwd:a,messageId:E()});for(let e of t)await n.sessionUpdate(e)}}}function Bi(e,t,n,r,i,a,o,s){return async(n,c,l,u,d,f)=>{let p=Hi(r);if(n.name===`ExitPlanMode`)return Vi(e,t,d,c,p,i,a,o,s);if(f!==void 0)return f;try{let e=await oe(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=J({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 Vi(e,t,n,r,i,a,o,s,c){let l=[{kind:`allow_always`,name:`Yes, and use "auto" mode`,optionId:`auto`},{kind:`allow_always`,name:`Yes, and auto-accept edits`,optionId:`acceptEdits`},{kind:`allow_once`,name:`Yes, and manually approve edits`,optionId:`default`},{kind:`reject_once`,name:`No, keep planning`,optionId:`plan`}];s?.()===!0&&l.unshift({kind:`allow_always`,name:`Yes, and bypass permissions`,optionId:`bypassPermissions`});let u=J({name:`ExitPlanMode`,id:n,input:r},i,a),d={toolCallId:n,title:u.title,kind:u.kind,status:`pending`,rawInput:r},f=await e.requestPermission({sessionId:t,toolCall:d,options:l});if(f.outcome.outcome===`cancelled`)return c?.(),{behavior:`deny`,message:`Tool use aborted`,decisionReason:{type:`mode`,mode:`default`}};if(f.outcome.outcome===`selected`&&`optionId`in f.outcome&&f.outcome.optionId!==void 0){let n=f.outcome.optionId;if(l.some(e=>e.optionId===n)&&(n==="default"||n===`acceptEdits`||n===`auto`||n===`bypassPermissions`))return o?.(n),await e.sessionUpdate({sessionId:t,update:{sessionUpdate:`current_mode_update`,currentModeId:n}}),{behavior:`allow`,updatedInput:r}}return{behavior:`deny`,message:`User rejected request to exit plan mode.`,decisionReason:{type:`mode`,mode:`plan`}}}function Hi(e){if(!e)return!1;if(e.terminal===!0)return!0;let t=e._meta;return!t||typeof t!=`object`?!1:t.terminal_output===!0}xe(),ie(),me(),be(),e(),ne(),de();var Z=class{constructor(e){t(this,`conn`,void 0),t(this,`sessions`,new Map),t(this,`clientCapabilities`,void 0),this.conn=e}async initialize(e){return this.clientCapabilities=e.clientCapabilities,{protocolVersion:1,authMethods:[],agentInfo:{name:`claude-code`,title:`Work Mate`,version:typeof globalThis.MACRO==`object`&&globalThis.MACRO!==null?String(globalThis.MACRO.VERSION??`0.0.0`):`0.0.0`},agentCapabilities:{_meta:{claudeCode:{promptQueueing:!0,forkSession:!0}},promptCapabilities:{image:!1,embeddedContext:!0},mcpCapabilities:{http:!0,sse:!0},loadSession:!0,sessionCapabilities:{list:{},resume:{},close:{},delete:{}}}}}async authenticate(e){return{}}async newSession(e){let t=await this.createSession(e);return this.scheduleAvailableCommandsUpdate(t.sessionId),t}async unstable_resumeSession(e){let t=await this.getOrCreateSession({...e,replay:!1});return this.scheduleAvailableCommandsUpdate(t.sessionId),t}async loadSession(e){let t=await this.getOrCreateSession(e);return this.scheduleAvailableCommandsUpdate(t.sessionId),t}async listSessions(e){if(e.cursor!==void 0&&e.cursor!==null)throw Error(`Pagination cursor not supported: listSessions returns all results in a single page.`);let t=e.cwd||b(),n=await T(t),r=await le({dir:t}),i=[];for(let e of r){if(!e.cwd||await T(e.cwd)!==n)continue;let t=Di(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 Ui(e.sessionId),n=await this.createSession({cwd:e.cwd,mcpServers:e.mcpServers??[],_meta:e._meta},{initialMessages:t});return this.scheduleAvailableCommandsUpdate(n.sessionId),n}async unstable_closeSession(e){if(!this.sessions.get(e.sessionId))throw Error(`Session not found`);return await this.teardownSession(e.sessionId),{}}async unstable_deleteSession(e){let t=await w(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 Ui(e){let t;try{let n=await C(e);n&&n.messages.length>0&&(t=S(n.messages))}catch(e){console.error(`[ACP] fork source load failed:`,e)}return{initialMessages:t}}var Wi=[`auto`,`default`,`acceptEdits`,`bypassPermissions`,`dontAsk`,`plan`];function Gi(e){return Wi.includes(e)}function Ki(e,t,n){if(t){let t=qi(e,`_meta.permissionMode`);if(t===`bypassPermissions`&&!Xi())throw Error(`Mode not available: bypassPermissions cannot run as root (start the agent as a non-root user, or set IS_SANDBOX=1).`);return t}return Ji(n)??`default`}function qi(e,t){if(e==null)throw Error(`Invalid ${t}: expected a string.`);return wi(e,t)}function Ji(e){if(e!=null)try{return wi(e,`permissions.defaultMode`)}catch(e){let t=e instanceof Error?e.message:String(e);console.error(`[ACP] Invalid permissions.defaultMode, using default:`,t);return}}function Yi(e,t){return!!e&&Object.hasOwn(e,t)}function Xi(){return Zi()}function Zi(){return process.env.IS_SANDBOX?!0:typeof process.geteuid==`function`?process.geteuid()!==0:typeof process.getuid!=`function`||process.getuid()!==0}function Qi(e,t){return[{id:`mode`,name:`Mode`,description:`Session permission mode`,category:`mode`,type:`select`,currentValue:e.currentModeId,options:e.availableModes.map(e=>({value:e.id,name:e.name,description:e.description}))},{id:`model`,name:`Model`,description:`AI model to use`,category:`model`,type:`select`,currentValue:t.currentModelId,options:t.availableModels.map(e=>({value:e.modelId,name:e.name,description:e.description??void 0}))}]}function $i(e){let t=[];if(!Array.isArray(e))return t;for(let n of e){if(typeof n!=`object`||!n)continue;let e=n;if(Array.isArray(e.options))for(let n of e.options)n&&typeof n==`object`&&typeof n.value==`string`&&t.push(n.value);else typeof n.value==`string`&&t.push(n.value)}return t}function Q(e){return e.conn}function $(e){return e.clientCapabilities}function ea(e,t,n,r){n===`mode`?t.modes={...t.modes,currentModeId:r}:n===`model`&&(t.models={...t.models,currentModelId:r})}v();function ta(){return ge().permissions?.defaultMode}async function na(e,t={}){ye();let n=t.sessionId??E(),r=e.cwd;x(n,_()),g(r);let i=process.cwd(),a=!1;try{process.chdir(r),a=!0}catch{}y(),De();try{let i=we(),a=te(i),o=e._meta,s=Yi(o,`permissionMode`),c=Ki(s?o?.permissionMode:void 0,s,ta()),l=$(this),u=this.conn,d=Bi(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=Xi(),p={...ce(),toolPermissionContext:{...i,mode:c,isBypassPermissionsModeAvailable:f}},[m,h]=await Promise.all([pe(r),ue(r)]);p.agentDefinitions=h;let g=new ke({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 Ee(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`}]},v=he(),y=Se(),b={availableModels:v.map(e=>({modelId:String(e.value??``),name:e.label??String(e.value??``),description:e.description??void 0})),currentModelId:y};g.setModel(y);let x=Qi(_,b),ee={queryEngine:g,cancelled:!1,cancelGeneration:0,cwd:r,modes:_,models:b,configOptions:x,promptRunning:!1,pendingMessages:new Map,pendingQueue:[],pendingQueueHead:0,toolUseCache:{},clientCapabilities:l,appState:p,commands:m,sessionFingerprint:Ti({cwd:r,mcpServers:e.mcpServers})};return this.sessions.set(n,ee),{sessionId:n,modes:_,models:b,configOptions:x}}finally{a&&process.chdir(i)}}Object.assign(Z.prototype,{createSession:na}),ne(),de(),v(),be();async function ra(e){let t=e.replay!==!1,n=this.sessions.get(e.sessionId);if(n){if(Ti({cwd:e.cwd,mcpServers:e.mcpServers})===n.sessionFingerprint){let r=await w(e.sessionId,e.cwd);return x(e.sessionId,r?Ae(r.filePath):null),g(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 w(e.sessionId,e.cwd),i=r?Ae(r.filePath):null;x(e.sessionId,i),g(e.cwd);let a;if(r)try{let t=await C(e.sessionId);t&&t.messages.length>0&&(a=S(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 X(e.sessionId,a,Q(this),t.toolUseCache,$(this),t.cwd)}return{sessionId:o.sessionId,modes:o.modes,models:o.models,configOptions:o.configOptions}}async function ia(e){this.sessions.get(e)&&(await this.cancel({sessionId:e}),this.sessions.delete(e))}async function aa(e){try{let t=await C(e.sessionId);if(!t||t.messages.length===0)return;let n=S(t.messages);if(n.length===0)return;let r=this.sessions.get(e.sessionId);if(!r)return;await X(e.sessionId,n,Q(this),r.toolUseCache,$(this),r.cwd)}catch(e){console.error(`[ACP] Failed to replay session history:`,e)}}function oa(e,t){if(!Gi(t))throw Error(`Invalid mode: ${t}`);let n=this.sessions.get(e);if(n){if(t===`bypassPermissions`&&!n.appState.toolPermissionContext.isBypassPermissionsModeAvailable||!n.modes.availableModes.some(e=>e.id===t))throw Error(`Mode not available: ${t}`);n.modes={...n.modes,currentModeId:t},n.appState.toolPermissionContext={...n.appState.toolPermissionContext,mode:t}}}async function sa(e,t,n){let r=this.sessions.get(e);r&&(ea(this,r,t,n),r.configOptions=r.configOptions.map(e=>e.id===t&&typeof e.currentValue==`string`?{...e,currentValue:n}:e),await Q(this).sessionUpdate({sessionId:e,update:{sessionUpdate:`config_option_update`,configOptions:r.configOptions}}))}Object.assign(Z.prototype,{getOrCreateSession:ra,teardownSession:ia,replaySessionHistory:aa,applySessionMode:oa,updateConfigOption:sa});function ca(e){if(!e||e.length===0)return``;let t=[];for(let n of e){let e=n;if(e.type===`text`)t.push(String(e.text??``));else if(e.type===`resource_link`){let n=typeof e.name==`string`?e.name:void 0,r=typeof e.uri==`string`?e.uri:void 0;t.push(la(n,r))}else if(e.type===`resource`){let n=e.resource;if(n&&typeof n.text==`string`)t.push(n.text);else if(n&&typeof n.blob==`string`){let e=typeof n.mimeType==`string`?n.mimeType:`application/octet-stream`,r=typeof n.uri==`string`?n.uri:`(unknown uri)`;t.push(`Embedded resource: ${r} (${e}, base64 blob, ${n.blob.length} chars)`)}}}return t.filter(e=>e.length>0).join(`
14
+ `)}function la(e,t){let n=[];return e&&e.length>0&&n.push(`name=${e}`),t&&t.length>0&&n.push(`uri=${t}`),n.length>0?`Resource link: ${n.join(`, `)}`:`Resource link`}function ua(e){for(;e.pendingQueueHead<e.pendingQueue.length;){let t=e.pendingQueue[e.pendingQueueHead++];if(!t)continue;let n=e.pendingMessages.get(t);if(n)return e.pendingMessages.delete(t),da(e),n}da(e)}function da(e){if(e.pendingQueueHead!==0){if(e.pendingQueueHead>=e.pendingQueue.length){e.pendingQueue=[],e.pendingQueueHead=0;return}e.pendingQueueHead>1024&&e.pendingQueueHead*2>e.pendingQueue.length&&(e.pendingQueue=e.pendingQueue.slice(e.pendingQueueHead),e.pendingQueueHead=0)}}v();async function fa(e){let t=this.sessions.get(e.sessionId);if(!t)throw Error(`Session ${e.sessionId} not found`);let n=e.messageId??void 0,r=ca(e.prompt);if(!r.trim())throw Error(`Prompt content is empty`);let i=t.cancelGeneration;if(t.promptRunning){let e=E();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(),x(e.sessionId,_());let i=t.queryEngine.submitMessage(r),{stopReason:a,usage:o}=await zi(e.sessionId,i,Q(this),t.queryEngine.getAbortSignal(),t.toolUseCache,$(this),t.cwd,()=>t.cancelled);if(t.cancelled)return{stopReason:`cancelled`};if(await ma(this,e.sessionId,r),o){let e={inputTokens:o.inputTokens,outputTokens:o.outputTokens,cachedReadTokens:o.cachedReadTokens,cachedWriteTokens:o.cachedWriteTokens,thoughtTokens:0,totalTokens:o.inputTokens+o.outputTokens+o.cachedReadTokens+o.cachedWriteTokens+0};return{stopReason:a,usage:e,...n?{userMessageId:n}:{},_meta:{claudeCode:{usage:e}}}}return{stopReason:a,...n?{userMessageId:n}:{}}}catch(n){let r=n instanceof Error&&(n.name===`AbortError`||/abort|cancelled|interrupt/i.test(n.message));if(t.cancelled||r)return{stopReason:`cancelled`};throw n instanceof Error&&(n.message.includes(`terminated`)||n.message.includes(`process exited`))?(await this.teardownSession(e.sessionId),Error(`The Claude Agent process exited unexpectedly. Please start a new session.`)):n}finally{let e=ua(t);e?(t.promptRunning=!0,e.resolve(!1)):t.promptRunning=!1}}async function pa(e){let t=this.sessions.get(e.sessionId);if(!t)throw Error(`Session not found`);if(typeof e.value!=`string`)throw Error(`Invalid value for config option ${e.configId}: ${String(e.value)}`);let n=t.configOptions.find(t=>t.id===e.configId);if(!n)throw Error(`Unknown config option: ${e.configId}`);if(n.type===`select`){let t=$i(n.options);if(!t.includes(e.value))throw Error(`Invalid value '${e.value}' for config option ${e.configId}; must be one of: ${t.join(`, `)}`)}let r=e.value;return e.configId===`mode`?(this.applySessionMode(e.sessionId,r),await Q(this).sessionUpdate({sessionId:e.sessionId,update:{sessionUpdate:`current_mode_update`,currentModeId:r}})):e.configId===`model`&&t.queryEngine.setModel(r),ea(this,t,e.configId,r),t.configOptions=t.configOptions.map(t=>t.id===e.configId&&typeof t.currentValue==`string`?{...t,currentValue:r}:t),{configOptions:t.configOptions}}async function ma(e,t,n){let r=e.sessions.get(t);if(!r)return;let i=r.toolUseCache;if(i.__sessionInfoTitleSent)return;i.__sessionInfoTitleSent=!0;let a=Di(n).slice(0,100);try{await Q(e).sessionUpdate({sessionId:t,update:{sessionUpdate:`session_info_update`,...a?{title:a}:{},updatedAt:new Date().toISOString()}})}catch(e){console.error(`[ACP] Failed to send session_info_update:`,e)}}Object.assign(Z.prototype,{prompt:fa,setSessionConfigOption:pa}),ve(),Oe();function ha(e,t){let n=je.toWeb(e);return _i(Me.toWeb(t),n)}async function ga(){ye(),De();let e=ha(process.stdin,process.stdout),t,n=new yi(e=>(t=new Z(e),t),e);console.log=console.error,console.info=console.error,console.warn=console.error,console.debug=console.error;async function r(){for(let[e]of t.sessions)try{await t.unstable_closeSession({sessionId:e})}catch{}process.exit(0)}n.closed.then(r).catch(r),process.on(`SIGTERM`,r),process.on(`SIGINT`,r),process.on(`unhandledRejection`,(e,t)=>{console.error(`Unhandled Rejection at:`,t,`reason:`,e)}),process.stdin.resume()}export{ga as runAcpAgent};
@@ -0,0 +1 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{D as t,E as n,N as r,_ as i,n as a,r as o,t as s}from"./lazySchema-DULtBUCI.js";import{i as c,r as l}from"./semver-BMRJYn3q.js";import{r as u,s as d}from"./bridgeEnabled-Cc0mGlTb.js";async function f(){let e=h,t=g().safeParse(e);return t.success?t.data:h}async function p(){let e=await f();return e.min_version&&c(`0.0.7`,e.min_version)?`Your version of Work Mate (0.0.7) is too old for Remote Control.\nVersion ${e.min_version} or higher is required. Run \`claude update\` to update.`:null}async function m(){return d()?(await f()).should_show_app_upgrade_message:!1}var h,g,_=e((()=>{o(),s(),l(),u(),h={init_retry_max_attempts:3,init_retry_base_delay_ms:500,init_retry_jitter_fraction:.25,init_retry_max_delay_ms:4e3,http_timeout_ms:1e4,uuid_dedup_buffer_size:2e3,heartbeat_interval_ms:2e4,heartbeat_jitter_fraction:.1,token_refresh_buffer_ms:3e5,teardown_archive_timeout_ms:1500,connect_timeout_ms:15e3,min_version:`0.0.0`,should_show_app_upgrade_message:!1},g=a(()=>t({init_retry_max_attempts:n().int().min(1).max(10).default(3),init_retry_base_delay_ms:n().int().min(100).default(500),init_retry_jitter_fraction:n().min(0).max(1).default(.25),init_retry_max_delay_ms:n().int().min(500).default(4e3),http_timeout_ms:n().int().min(2e3).default(1e4),uuid_dedup_buffer_size:n().int().min(100).max(5e4).default(2e3),heartbeat_interval_ms:n().int().min(5e3).max(3e4).default(2e4),heartbeat_jitter_fraction:n().min(0).max(.5).default(.1),token_refresh_buffer_ms:n().int().min(3e4).max(18e5).default(3e5),teardown_archive_timeout_ms:n().int().min(500).max(2e3).default(1500),connect_timeout_ms:n().int().min(5e3).max(6e4).default(15e3),min_version:r().refine(e=>{try{return c(e,`0.0.0`),!0}catch{return!1}}).default(`0.0.0`),should_show_app_upgrade_message:i().default(!1)}))}));export{m as a,_ as i,p as n,f as r,h as t};
@@ -0,0 +1 @@
1
+ import{a as e,i as t}from"./envLessBridgeConfig-B-LKYNvv.js";t();export{e as shouldShowAppUpgradeMessage};