claude-code-best 2.8.1 → 2.8.2

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 (396) hide show
  1. package/dist/chunks/{AddWorkspaceDirectory-CNyPaerF.js → AddWorkspaceDirectory-BCCbaWoh.js} +1 -1
  2. package/dist/chunks/{App-hiKxO6UA.js → App-BIAYUFvT.js} +1 -1
  3. package/dist/chunks/{ApproveApiKey-Cd43j9Wa.js → ApproveApiKey-DRARgWX3.js} +1 -1
  4. package/dist/chunks/ApproveApiKey-Do-Qth0X.js +1 -0
  5. package/dist/chunks/{AssistantSessionChooser-C8OxwSGM.js → AssistantSessionChooser-eUrEGDlX.js} +1 -1
  6. package/dist/chunks/{BackgroundTasksDialog-VKhuyQLe.js → BackgroundTasksDialog-DSeAqhMC.js} +1 -1
  7. package/dist/chunks/{BypassPermissionsModeDialog-Ddjzluka.js → BypassPermissionsModeDialog-8z7R5EpU.js} +1 -1
  8. package/dist/chunks/{ClaudeInChromeOnboarding-BhvrEJlm.js → ClaudeInChromeOnboarding-B7mDm5Hb.js} +1 -1
  9. package/dist/chunks/{ClaudeMdExternalIncludesDialog-DoNd72PS.js → ClaudeMdExternalIncludesDialog-DE9dpWtg.js} +1 -1
  10. package/dist/chunks/ClaudeMdExternalIncludesDialog-DTZS-dek.js +1 -0
  11. package/dist/chunks/ConsoleOAuthFlow-UcQCmIWd.js +1 -0
  12. package/dist/chunks/{DesktopHandoff-DVUOZjb0.js → DesktopHandoff-Ce0nE7D6.js} +1 -1
  13. package/dist/chunks/{DevChannelsDialog-DJbRHAIy.js → DevChannelsDialog-mt0lA5wR.js} +1 -1
  14. package/dist/chunks/{DiffDialog-D0RK4t-9.js → DiffDialog-BfSnz8L-.js} +1 -1
  15. package/dist/chunks/{Doctor-0Nv3L1Oy.js → Doctor-BOVjkAKn.js} +1 -1
  16. package/dist/chunks/Doctor-osWC5WVY.js +1 -0
  17. package/dist/chunks/{ExitFlow-BPbtGcEg.js → ExitFlow-C3BGvwv-.js} +1 -1
  18. package/dist/chunks/{Feedback-BSagYjmf.js → Feedback-BtZb1A8b.js} +1 -1
  19. package/dist/chunks/Grove-DyC_Wrfx.js +1 -0
  20. package/dist/chunks/{Grove-BrP9JNpK.js → Grove-HpMLktXp.js} +1 -1
  21. package/dist/chunks/{HybridTransport-DLaxmXCR.js → HybridTransport-COk7jAC7.js} +1 -1
  22. package/dist/chunks/{ITermBackend-tXN55G2D.js → ITermBackend-BlwyeN8U.js} +1 -1
  23. package/dist/chunks/{InvalidConfigDialog-BzFQdfwu.js → InvalidConfigDialog-QVIRDXwA.js} +1 -1
  24. package/dist/chunks/{InvalidSettingsDialog-KFg61s41.js → InvalidSettingsDialog-CZRZm0oa.js} +1 -1
  25. package/dist/chunks/{MCPConnectionManager-N-oJu3qn.js → MCPConnectionManager-2Fulnp8q.js} +1 -1
  26. package/dist/chunks/{McpParsingWarnings-DsHSSgsx.js → McpParsingWarnings-DWMO0bV6.js} +1 -1
  27. package/dist/chunks/{MessageSelector-D10JMnsc.js → MessageSelector-B4jJQ-KQ.js} +1 -1
  28. package/dist/chunks/{Messages-CQdQJ2AA.js → Messages-ltcn1Qkf.js} +2 -2
  29. package/dist/chunks/{Onboarding-DBJX6Cnf.js → Onboarding-CHcND5Tt.js} +1 -1
  30. package/dist/chunks/{OverageCreditUpsell-B4beCEX2.js → OverageCreditUpsell-CMBqZrnz.js} +1 -1
  31. package/dist/chunks/{PluginSettings-BBrFCSpQ.js → PluginSettings-DIS_qrVA.js} +1 -1
  32. package/dist/chunks/{PromptInputHelpMenu-Bjjr3tYl.js → PromptInputHelpMenu-CAwbW7z2.js} +1 -1
  33. package/dist/chunks/{QueryEngine-BSk8-8vB.js → QueryEngine-BQs519Rb.js} +1 -1
  34. package/dist/chunks/REPL-DJh_wVWI.js +1 -0
  35. package/dist/chunks/{REPL-CXcCBQuz.js → REPL-Dx3SPe95.js} +6 -6
  36. package/dist/chunks/{RemoteCallout-CuxqarhC.js → RemoteCallout-CwI1mLQ9.js} +1 -1
  37. package/dist/chunks/{RemoteSessionManager-BhPF41Wn.js → RemoteSessionManager-BXMBhfQD.js} +1 -1
  38. package/dist/chunks/{ResumeConversation-hmIOkZ2U.js → ResumeConversation-BK7L_YBI.js} +1 -1
  39. package/dist/chunks/{SSETransport-8yaTbdSK.js → SSETransport-Co-0nMlR.js} +1 -1
  40. package/dist/chunks/SearchExtraToolsTool-DVi-ggud.js +1 -0
  41. package/dist/chunks/SentryErrorBoundary-DLML64E_.js +1 -0
  42. package/dist/chunks/{SentryErrorBoundary-ydwbrVTx.js → SentryErrorBoundary-kEgE7qeH.js} +1 -1
  43. package/dist/chunks/{Settings-BSbzT25q.js → Settings-DOve7mW1.js} +2 -2
  44. package/dist/chunks/{TeleportProgress-CNcl_DxR.js → TeleportProgress--n-u7MYY.js} +1 -1
  45. package/dist/chunks/{TeleportRepoMismatchDialog-DJc8_mjE.js → TeleportRepoMismatchDialog-CzQzdYb2.js} +1 -1
  46. package/dist/chunks/{TeleportResumeWrapper-Cw438s-J.js → TeleportResumeWrapper-CtANoO1Z.js} +1 -1
  47. package/dist/chunks/{ThemePicker-8X6yAwuQ.js → ThemePicker-kBt6obJb.js} +1 -1
  48. package/dist/chunks/{TmuxBackend-CqAnVFoI.js → TmuxBackend-Q5xdOkW4.js} +1 -1
  49. package/dist/chunks/{TrustDialog-Ch1FJzxi.js → TrustDialog-CoCFqyRD.js} +1 -1
  50. package/dist/chunks/{ValidationErrorsList-sgfvJPWZ.js → ValidationErrorsList-CL42YlaS.js} +1 -1
  51. package/dist/chunks/{WelcomeV2-Bu8l3w90.js → WelcomeV2-B0d9sH1c.js} +1 -1
  52. package/dist/chunks/{WindowsTerminalBackend-Bvq7nHOp.js → WindowsTerminalBackend-CLSeqqHh.js} +1 -1
  53. package/dist/chunks/{add-dir-DqrRNnxe.js → add-dir-IrADCHV-.js} +1 -1
  54. package/dist/chunks/{agentDisplay-DcxzWi1v.js → agentDisplay-BUXpQhYh.js} +1 -1
  55. package/dist/chunks/{agents-QqLm1wcM.js → agents-BqQtaTaM.js} +1 -1
  56. package/dist/chunks/{agents-Do1ynqiW.js → agents-Cx0f6suK.js} +1 -1
  57. package/dist/chunks/{ant-D5gD6O-r.js → ant-BUkS8Em4.js} +1 -1
  58. package/dist/chunks/api-CoBZPEi-.js +1 -0
  59. package/dist/chunks/{api-hcsOinLV.js → api-Cy1N7XAQ.js} +1 -1
  60. package/dist/chunks/assistant-B2_c5C4T.js +1 -0
  61. package/dist/chunks/{assistant-DkECAILU.js → assistant-BGzd9a5x.js} +1 -1
  62. package/dist/chunks/{assistant-CemNvrYr.js → assistant-C3dP-BSJ.js} +1 -1
  63. package/dist/chunks/auth-CRVuUNwf.js +1 -0
  64. package/dist/chunks/{auth-Dm8aWPRh.js → auth-DVtMm7Hj.js} +1 -1
  65. package/dist/chunks/{autoMode-dygqoN_C.js → autoMode-ThlM20qr.js} +1 -1
  66. package/dist/chunks/{autonomy-BdxnxJnk.js → autonomy-B637YdCF.js} +1 -1
  67. package/dist/chunks/{autonomy-DPeEmb00.js → autonomy-B_vxYZbV.js} +1 -1
  68. package/dist/chunks/{autonomyPanel-Bocl2taZ.js → autonomyPanel-BM2VhTsn.js} +1 -1
  69. package/dist/chunks/backgroundHousekeeping-BWAfdRVf.js +1 -0
  70. package/dist/chunks/{backgroundHousekeeping-zf-tDimg.js → backgroundHousekeeping-Cll7XHG1.js} +2 -2
  71. package/dist/chunks/{branch-DwdVgun5.js → branch-BlH5WYNu.js} +1 -1
  72. package/dist/chunks/{bridge-DkkMogD_.js → bridge-QRFJRzVG.js} +2 -2
  73. package/dist/chunks/{bridgeConfig-l6Ldi_hk.js → bridgeConfig-Di9LziJ3.js} +1 -1
  74. package/dist/chunks/bridgeConfig-pVTHa_ED.js +1 -0
  75. package/dist/chunks/bridgeEnabled-c_BeJX3S.js +1 -0
  76. package/dist/chunks/{bridgeEnabled-DYclTb9d.js → bridgeEnabled-z1fPRzzV.js} +1 -1
  77. package/dist/chunks/bridgeMain-CHk_DCxy.js +1 -0
  78. package/dist/chunks/{bridgeMain-Ct5oDosG.js → bridgeMain-DVoobI7G.js} +6 -6
  79. package/dist/chunks/{bridgeMessaging-CYe1Cixl.js → bridgeMessaging-BG8fNZac.js} +1 -1
  80. package/dist/chunks/{btw-CyOlY5R-.js → btw-DpeWZQbf.js} +1 -1
  81. package/dist/chunks/{buddy-q-utA1_5.js → buddy-Bni2g0Km.js} +1 -1
  82. package/dist/chunks/{bypassPermissionsKillswitch-CTrRxzdz.js → bypassPermissionsKillswitch-7e56Rquc.js} +1 -1
  83. package/dist/chunks/caches-3byHT6VF.js +1 -0
  84. package/dist/chunks/{caches-Bz4yVQyE.js → caches-CzEBsMvP.js} +2 -2
  85. package/dist/chunks/{ccrClient-DXiEw9xU.js → ccrClient-iR6zwGb1.js} +1 -1
  86. package/dist/chunks/changeDetector-Cg75mKOu.js +1 -0
  87. package/dist/chunks/channelNotification-BSmZprUZ.js +1 -0
  88. package/dist/chunks/{channelNotification-CLPdvxGZ.js → channelNotification-CSmLgwtO.js} +1 -1
  89. package/dist/chunks/{chrome-DxbhLWDW.js → chrome-BO1vbvZ0.js} +1 -1
  90. package/dist/chunks/clear-CTOCrXv_.js +1 -0
  91. package/dist/chunks/client-BgdjJNnC.js +1 -0
  92. package/dist/chunks/{color-DiLtK8_L.js → color-BP4FmcMn.js} +1 -1
  93. package/dist/chunks/commands-CkfOhzGE.js +1 -0
  94. package/dist/chunks/commitAttribution-DKvggTZx.js +1 -0
  95. package/dist/chunks/{commitAttribution-CJXF8wMs.js → commitAttribution-Djh1ZpYH.js} +1 -1
  96. package/dist/chunks/{compact-C6xm1N5a.js → compact-BtAvCkY0.js} +1 -1
  97. package/dist/chunks/{companion-rXSt0nmz.js → companion-C-jfFhlz.js} +1 -1
  98. package/dist/chunks/{config-CzC08IjE.js → config-CloXpblh.js} +1 -1
  99. package/dist/chunks/{config-BE3jrcr-.js → config-DwsIX0hc.js} +1 -1
  100. package/dist/chunks/{context-BHE99SMA.js → context-DdwMoH4j.js} +1 -1
  101. package/dist/chunks/{context-noninteractive-BZQIUH_y.js → context-noninteractive-BWbEqad6.js} +1 -1
  102. package/dist/chunks/context-noninteractive-DNOyQYnM.js +1 -0
  103. package/dist/chunks/{conversation-CBPRFDod.js → conversation-DR4MFYYi.js} +1 -1
  104. package/dist/chunks/conversation-DVhyJA1O.js +1 -0
  105. package/dist/chunks/{copy-TgphIVzy.js → copy-tl-41wwU.js} +1 -1
  106. package/dist/chunks/{createSSHSession-CSKEZ4ic.js → createSSHSession-B_IyqOll.js} +1 -1
  107. package/dist/chunks/createSession-CIM50iEU.js +1 -0
  108. package/dist/chunks/{createSession-Ce218tQj.js → createSession-Csaqw8kb.js} +1 -1
  109. package/dist/chunks/{cronJitterConfig-CnKed5Gi.js → cronJitterConfig-2sHTXBLu.js} +1 -1
  110. package/dist/chunks/{crossProjectResume-BFlsTYOq.js → crossProjectResume-C1I0X__e.js} +1 -1
  111. package/dist/chunks/{datadog-D5jSRybW.js → datadog-BzkFYNcv.js} +1 -1
  112. package/dist/chunks/datadog-vQKKqB6Z.js +1 -0
  113. package/dist/chunks/{desktop-cjA0tGOa.js → desktop-oTXppB2O.js} +1 -1
  114. package/dist/chunks/{diff-DMd61IjE.js → diff-B23DUoT8.js} +1 -1
  115. package/dist/chunks/{doctor-ueUYyjyL.js → doctor-o2MJvjAE.js} +1 -1
  116. package/dist/chunks/{effort-B9IvAstG.js → effort-B1X_S_oa.js} +1 -1
  117. package/dist/chunks/{entry-Bq_KRMWs.js → entry-BAXMpXJ0.js} +5 -5
  118. package/dist/chunks/envLessBridgeConfig-Dj0umjOo.js +1 -0
  119. package/dist/chunks/{envLessBridgeConfig-CpjlwmvF.js → envLessBridgeConfig-YNTOVEqU.js} +1 -1
  120. package/dist/chunks/{exit-DtjFIrvJ.js → exit-CwGJifQF.js} +1 -1
  121. package/dist/chunks/{export-CP638-TO.js → export-CqbYdFmJ.js} +1 -1
  122. package/dist/chunks/{exportRenderer-B5emJDvn.js → exportRenderer-DP_z8YD1.js} +1 -1
  123. package/dist/chunks/extra-usage-1FUBiJOE.js +1 -0
  124. package/dist/chunks/{extra-usage-DIm8nrKj.js → extra-usage-BQ5Z1wJb.js} +1 -1
  125. package/dist/chunks/{extra-usage-core-DERKSEe1.js → extra-usage-core-B1oJoxYa.js} +1 -1
  126. package/dist/chunks/{extra-usage-noninteractive-Dq5dog_-.js → extra-usage-noninteractive-BV_6cpdd.js} +1 -1
  127. package/dist/chunks/{extraUsage-BMvDY0Sk.js → extraUsage-Ca_6qcke.js} +1 -1
  128. package/dist/chunks/extractMemories-B-yrLjpP.js +1 -0
  129. package/dist/chunks/{fast-BP2t1xDM.js → fast-BJMGfO_S.js} +1 -1
  130. package/dist/chunks/fast-CFtN26up.js +1 -0
  131. package/dist/chunks/{feedback-C-mR6zJr.js → feedback-O0Gushxg.js} +1 -1
  132. package/dist/chunks/{firstPartyEventLogger-sMmHdYjg.js → firstPartyEventLogger-0s2WJ6SR.js} +1 -1
  133. package/dist/chunks/{flushGate-C18XwNsa.js → flushGate-CLjpgnG6.js} +1 -1
  134. package/dist/chunks/gates-4fq2Ws2D.js +1 -0
  135. package/dist/chunks/{gates-Be5r2kKS.js → gates-C5y8P5t9.js} +1 -1
  136. package/dist/chunks/{gemini-BberPcp1.js → gemini-D6lfJRGH.js} +1 -1
  137. package/dist/chunks/{generateRecap-B76UcVUS.js → generateRecap-AYujRzfu.js} +1 -1
  138. package/dist/chunks/{generateSessionName-BwtXd8TC.js → generateSessionName-CXg1uVLN.js} +1 -1
  139. package/dist/chunks/{githubRepoPathMapping-5IlVgR2l.js → githubRepoPathMapping-CdjkMIX3.js} +1 -1
  140. package/dist/chunks/{goal-DQ0jNcLO.js → goal-BGr-SlcA.js} +1 -1
  141. package/dist/chunks/{grok-Dh_thT2_.js → grok-DxyRt4Jq.js} +1 -1
  142. package/dist/chunks/{growthbook-4ADV3CAt.js → growthbook-D93ZmHUL.js} +1 -1
  143. package/dist/chunks/{heapdump-Dwqmh4SX.js → heapdump-DZz5qnZg.js} +1 -1
  144. package/dist/chunks/{help-Bznaywoi.js → help-C8HhaC70.js} +1 -1
  145. package/dist/chunks/hooks-CmW7bdtz.js +1 -0
  146. package/dist/chunks/{hooks-F-82cg6M.js → hooks-De2yBPig.js} +1 -1
  147. package/dist/chunks/{hostAdapter-DpfLr3hX.js → hostAdapter-CZdJUeS1.js} +1 -1
  148. package/dist/chunks/{ide-BfAKWufQ.js → ide-GnSLasRI.js} +1 -1
  149. package/dist/chunks/{inboundAttachments-CFV_eqMu.js → inboundAttachments-C8y3D5mp.js} +1 -1
  150. package/dist/chunks/inboundAttachments-DZiITyN8.js +1 -0
  151. package/dist/chunks/{initReplBridge-DV9KhSic.js → initReplBridge-YGXqLbNZ.js} +1 -1
  152. package/dist/chunks/{insights-BNsCwNYa.js → insights-23tyPxXV.js} +1 -1
  153. package/dist/chunks/{install-Bszzs98N.js → install-BXi4d63r.js} +1 -1
  154. package/dist/chunks/{install-github-app-DVxGR2rp.js → install-github-app-D2X7BgzJ.js} +1 -1
  155. package/dist/chunks/{install-slack-app-CjlRL19o.js → install-slack-app-_J1t0kSP.js} +1 -1
  156. package/dist/chunks/{instrumentation-BOYPOtyu.js → instrumentation-C9WDRy-K.js} +3 -3
  157. package/dist/chunks/{job-BvD5_lGz.js → job-DXX7dNN_.js} +1 -1
  158. package/dist/chunks/{keybindings-RPmPPGhp.js → keybindings-CChhkkE0.js} +1 -1
  159. package/dist/chunks/{lang-9VNaOJMz.js → lang-COIVItM_.js} +1 -1
  160. package/dist/chunks/language-CiMwEWO-.js +1 -0
  161. package/dist/chunks/{language-Ct5Nkqm6.js → language-DzWvcLCu.js} +1 -1
  162. package/dist/chunks/{launchAgentsPlatform-CnoxFIXV.js → launchAgentsPlatform-Du_WvKeU.js} +1 -1
  163. package/dist/chunks/{launchAutofixPr-ChaDUtvx.js → launchAutofixPr-CypNniKH.js} +1 -1
  164. package/dist/chunks/{launchLocalMemory-MwZfEJxz.js → launchLocalMemory-GkqB_Gcr.js} +1 -1
  165. package/dist/chunks/{launchLocalVault-B6Ib5WXx.js → launchLocalVault-CBihJDzq.js} +1 -1
  166. package/dist/chunks/{launchMemoryStores-D6xyGwQ1.js → launchMemoryStores-BkK0wwq0.js} +1 -1
  167. package/dist/chunks/{launchOnboarding-BtdAOO3p.js → launchOnboarding-BubTG5vY.js} +1 -1
  168. package/dist/chunks/{launchSchedule-XVljzNKg.js → launchSchedule-CkV6Ai-0.js} +1 -1
  169. package/dist/chunks/{launchSkillStore-QT8Qcc5N.js → launchSkillStore-DIrFg_WZ.js} +1 -1
  170. package/dist/chunks/{launchTeleport-DwxPesKQ.js → launchTeleport-DFrgN9sU.js} +1 -1
  171. package/dist/chunks/{launchVault-Dbti6pph.js → launchVault-CIiNsg91.js} +1 -1
  172. package/dist/chunks/loadAgentsDir-CjhNkoq0.js +1 -0
  173. package/dist/chunks/{loadAgentsDir-BYWykYwn.js → loadAgentsDir-DC4jN6-f.js} +53 -53
  174. package/dist/chunks/{loadPluginHooks-2U3UO__Q.js → loadPluginHooks-DukITDP2.js} +1 -1
  175. package/dist/chunks/{localSearch-eWjZxMc8.js → localSearch-But4wyLg.js} +1 -1
  176. package/dist/chunks/localSearch-D8FFon8N.js +1 -0
  177. package/dist/chunks/login-B3TV33p4.js +1 -0
  178. package/dist/chunks/{login-D1aQCqp0.js → login-ajsn1Sg7.js} +1 -1
  179. package/dist/chunks/{logoV2Utils-CPNvLtol.js → logoV2Utils-CpeUvaOM.js} +1 -1
  180. package/dist/chunks/logout-BqbTEPv9.js +1 -0
  181. package/dist/chunks/{magicDocs-DAvjAbAJ.js → magicDocs-TF6U6QoB.js} +1 -1
  182. package/dist/chunks/{main-BKlQiSuc.js → main-bjQRqaUr.js} +15 -15
  183. package/dist/chunks/mappers-Bg-xtimK.js +1 -0
  184. package/dist/chunks/{mcp-Cmw8ecKk.js → mcp-DtHGTZUo.js} +1 -1
  185. package/dist/chunks/{mcp-C3jlClk0.js → mcp-Vj0ijoSq.js} +2 -2
  186. package/dist/chunks/{mcp-ya96irNP.js → mcp-i8lqdWTr.js} +1 -1
  187. package/dist/chunks/{mcpServer-B1q9blAc.js → mcpServer-CuqaXxiJ.js} +1 -1
  188. package/dist/chunks/{mcpServer-BJB5g6j2.js → mcpServer-Dr9UfcEd.js} +1 -1
  189. package/dist/chunks/{memory-CxiukAGg.js → memory-DVJxsbcO.js} +1 -1
  190. package/dist/chunks/{mode-DqAJ2y6R.js → mode-C9yWWppB.js} +1 -1
  191. package/dist/chunks/model-BYSyXf9-.js +1 -0
  192. package/dist/chunks/{model-C8TW-qjl.js → model-Dq-13vaB.js} +1 -1
  193. package/dist/chunks/{onChangeAppState-BG1pF7ht.js → onChangeAppState-Cc4zOnqx.js} +1 -1
  194. package/dist/chunks/{openai-CHoRhRtf.js → openai-DMCGGZts.js} +1 -1
  195. package/dist/chunks/{overageCreditGrant-DYMg1lV4.js → overageCreditGrant-CzkWDmsQ.js} +1 -1
  196. package/dist/chunks/{panelCall-SYrmrKt9.js → panelCall-D36EWzwF.js} +1 -1
  197. package/dist/chunks/{passes-CSV-SZJc.js → passes-CPAwB9_F.js} +1 -1
  198. package/dist/chunks/{paths-BZjPDxMm.js → paths-CEAy4QCs.js} +2 -2
  199. package/dist/chunks/{permissions-DBddT2NP.js → permissions-B39hfy0O.js} +1 -1
  200. package/dist/chunks/{pipeTransport-uK7GxbSG.js → pipeTransport-7auNUakO.js} +1 -1
  201. package/dist/chunks/{plan-DEbo-Adi.js → plan-pCEs76NM.js} +1 -1
  202. package/dist/chunks/{plugin-Cops24hg.js → plugin-BSC-7wQh.js} +1 -1
  203. package/dist/chunks/{pluginAutoupdate-Bg7JMOHN.js → pluginAutoupdate-Cre72Rtf.js} +1 -1
  204. package/dist/chunks/{pluginBlocklist-DEM_RWc2.js → pluginBlocklist-D2Cj4TR2.js} +1 -1
  205. package/dist/chunks/{pluginCliCommands-DyYEg7Cv.js → pluginCliCommands-CTxmCPph.js} +1 -1
  206. package/dist/chunks/{pluginFlagging-DwChUZMJ.js → pluginFlagging-C5EGcjZe.js} +1 -1
  207. package/dist/chunks/{pluginOperations-COyT4tHs.js → pluginOperations-DDI1CG0K.js} +1 -1
  208. package/dist/chunks/{pluginStartupCheck-DCxJJkYs.js → pluginStartupCheck-B3QqfRt6.js} +1 -1
  209. package/dist/chunks/pluginStartupCheck-DYC8CWxw.js +1 -0
  210. package/dist/chunks/{plugins-BanQjHmw.js → plugins-Bz7JxD43.js} +1 -1
  211. package/dist/chunks/policyLimits-C-oHygGe.js +1 -0
  212. package/dist/chunks/{pollConfig-DBNHhvHf.js → pollConfig-CyO4Ycwc.js} +1 -1
  213. package/dist/chunks/{poor-aPQce502.js → poor-eRoBwI0Z.js} +1 -1
  214. package/dist/chunks/{poorMode-CFRuV-nB.js → poorMode-BdNsLBQ-.js} +1 -1
  215. package/dist/chunks/poorMode-D2-4vRxb.js +1 -0
  216. package/dist/chunks/{print-Cf2tY__0.js → print-Ogibzjap.js} +4 -4
  217. package/dist/chunks/{privacy-settings-CYkM3Aem.js → privacy-settings-Dd7PtKbY.js} +1 -1
  218. package/dist/chunks/{processBashCommand-BLSC8o8M.js → processBashCommand-BjdUo_Na.js} +1 -1
  219. package/dist/chunks/{processSlashCommand-Ch9B-6nh.js → processSlashCommand-tetvMLMl.js} +1 -1
  220. package/dist/chunks/prompt-BHI7PZe4.js +227 -0
  221. package/dist/chunks/prompt-DZ1EAUlC.js +1 -0
  222. package/dist/chunks/prompt-DeRHlPn1.js +1 -0
  223. package/dist/chunks/{promptEditor-U03qQWbq.js → promptEditor-DoJ-xPi4.js} +1 -1
  224. package/dist/chunks/{protocolHandler-3yBj9w5N.js → protocolHandler-Dgzu5UWb.js} +1 -1
  225. package/dist/chunks/{rate-limit-options-D-xl_9PO.js → rate-limit-options-B6QH2-xn.js} +1 -1
  226. package/dist/chunks/{rcDebugLog-ClX1msJX.js → rcDebugLog-C0Bam8V9.js} +1 -1
  227. package/dist/chunks/{referral-qe-yqXJE.js → referral-B10JtHMk.js} +1 -1
  228. package/dist/chunks/{refresh-CO_P3WKA.js → refresh-DmEsCaJ0.js} +1 -1
  229. package/dist/chunks/{registerProtocol-CClQph00.js → registerProtocol-CQjmvg7a.js} +1 -1
  230. package/dist/chunks/{registry-C0zdU2Hb.js → registry-CLaXh4Gk.js} +1 -1
  231. package/dist/chunks/{release-notes-CyZHxWTF.js → release-notes-dxng0ob_.js} +1 -1
  232. package/dist/chunks/{releaseNotes-BtxL5R5Q.js → releaseNotes-CS5L5W0H.js} +2 -2
  233. package/dist/chunks/{reload-plugins-B0eR8JHH.js → reload-plugins-CgzAjBDp.js} +1 -1
  234. package/dist/chunks/{remote-env-B_sIjY87.js → remote-env-BasfU8Ra.js} +1 -1
  235. package/dist/chunks/{remoteBridgeCore-C3WRaLpU.js → remoteBridgeCore-IJI5koHz.js} +1 -1
  236. package/dist/chunks/{remoteControlServer-BOj9qmgH.js → remoteControlServer-BBCt7ySV.js} +1 -1
  237. package/dist/chunks/{rename-BFAC3WLD.js → rename-eEdSZsJ2.js} +1 -1
  238. package/dist/chunks/{resume-CpivBr9S.js → resume-DjnfattK.js} +1 -1
  239. package/dist/chunks/{runtimeObserver-sOnfVR7t.js → runtimeObserver-ByTBtmBf.js} +2 -2
  240. package/dist/chunks/{runtimeObserver-C2_7Vsnd.js → runtimeObserver-COpkJmg-.js} +1 -1
  241. package/dist/chunks/sandbox-adapter-DagBhoTC.js +1 -0
  242. package/dist/chunks/{sandbox-toggle-Bv68-Ca7.js → sandbox-toggle-CQohaYND.js} +1 -1
  243. package/dist/chunks/searchExtraTools-kk-wV-cC.js +1 -0
  244. package/dist/chunks/{sentry-BBCn6RGP.js → sentry-C0bQlih_.js} +1 -1
  245. package/dist/chunks/{session-DfvxYP8o.js → session-Dx_ODOHl.js} +1 -1
  246. package/dist/chunks/{sessionDiscovery-CyuRBTAm.js → sessionDiscovery-DAqs0Ra6.js} +1 -1
  247. package/dist/chunks/sessionFileAccessHooks-C-Ic-0Ry.js +1 -0
  248. package/dist/chunks/sessionMemory-BMtFup-Y.js +1 -0
  249. package/dist/chunks/{sessionMemory-kYQnpcyG.js → sessionMemory-Bq3ECr1S.js} +1 -1
  250. package/dist/chunks/sessionMemoryUtils-BU7N_IQG.js +1 -0
  251. package/dist/chunks/sessionObserver-BwAfzGUg.js +1 -0
  252. package/dist/chunks/{sessionObserver-CTkIYplM.js → sessionObserver-rd6RRTzc.js} +1 -1
  253. package/dist/chunks/sessionStorage-X2u45U9z.js +1 -0
  254. package/dist/chunks/{sessionTitle-ePQRpeV2.js → sessionTitle-1k_2BhFL.js} +1 -1
  255. package/dist/chunks/{sessionTracing-81-RIJBo.js → sessionTracing-DNSDPYdR.js} +1 -1
  256. package/dist/chunks/{settingsSync-DEFWnE1o.js → settingsSync-3xG2A_wN.js} +1 -1
  257. package/dist/chunks/{setup-BJSk1czd.js → setup-C2V4elOv.js} +2 -2
  258. package/dist/chunks/{setup-2611vmGJ.js → setup-CY808VaY.js} +1 -1
  259. package/dist/chunks/{setup-CTfYsKsz.js → setup-Hlga8GJ_.js} +1 -1
  260. package/dist/chunks/{shadowedRuleDetection-CGD7Nx03.js → shadowedRuleDetection-BdBNo5eP.js} +1 -1
  261. package/dist/chunks/{sideQuestion-BcP9Mm-5.js → sideQuestion-DWOCUKMh.js} +1 -1
  262. package/dist/chunks/{sink-D_t1TIt9.js → sink-DCh0VJ4g.js} +1 -1
  263. package/dist/chunks/sink-nZmawD5W.js +1 -0
  264. package/dist/chunks/sinks-BTZnXPr_.js +1 -0
  265. package/dist/chunks/{sinks-DXsozhmS.js → sinks-_9T2oPB_.js} +2 -2
  266. package/dist/chunks/{skill-learning-CZm2iMik.js → skill-learning-CzZFGFZO.js} +1 -1
  267. package/dist/chunks/{skillChangeDetector-1aFn40GC.js → skillChangeDetector-345QNWDp.js} +1 -1
  268. package/dist/chunks/{skillGapStore-cWo6Ra90.js → skillGapStore-Bz_qbwI1.js} +2 -2
  269. package/dist/chunks/{skillGapStore-DzHv8v-D.js → skillGapStore-DJm3SULe.js} +1 -1
  270. package/dist/chunks/{skillGenerator-D_W1IeP3.js → skillGenerator-BcNv-VZ5.js} +2 -2
  271. package/dist/chunks/skillLearning-BJAfTX2G.js +1 -0
  272. package/dist/chunks/skillLearning-DPhuKS4j.js +1 -0
  273. package/dist/chunks/{skillPanel-ChmOZu4F.js → skillPanel-Q85P-Gg4.js} +3 -3
  274. package/dist/chunks/{skillSearchPanel-CVx2b4Pr.js → skillSearchPanel-CMCQDAcX.js} +2 -2
  275. package/dist/chunks/{skills-CWX1SydA.js → skills-D3eUg3HG.js} +1 -1
  276. package/dist/chunks/{sprites-BuvEFwW6.js → sprites-ChoMSqpa.js} +1 -1
  277. package/dist/chunks/{stats-wjMQA-CA.js → stats-DdhEa_6-.js} +1 -1
  278. package/dist/chunks/{status-CyU7IQhO.js → status-CX7Kgn21.js} +1 -1
  279. package/dist/chunks/{statusNoticeHelpers-JNibsI_v.js → statusNoticeHelpers-AibXOONm.js} +1 -1
  280. package/dist/chunks/{tag-opEEZI5B.js → tag-BJ_u3aJm.js} +1 -1
  281. package/dist/chunks/{tasks-CCtnU5u1.js → tasks-DeEWOchP.js} +1 -1
  282. package/dist/chunks/teamHelpers-CxoQp7OY.js +1 -0
  283. package/dist/chunks/{teamHelpers-BJJs8taN.js → teamHelpers-WmWa_h3B.js} +1 -1
  284. package/dist/chunks/{teammateModeSnapshot-CLiiOCkO.js → teammateModeSnapshot-DZ6ulELC.js} +1 -1
  285. package/dist/chunks/teammateModeSnapshot-KWxn1jxl.js +1 -0
  286. package/dist/chunks/{teleport-ClxQigSQ.js → teleport-CuDXJj_f.js} +1 -1
  287. package/dist/chunks/{templateJobs-C6D7GC-Q.js → templateJobs-nFBp68za.js} +1 -1
  288. package/dist/chunks/{terminalSetup-B3bN4Cj8.js → terminalSetup-BORjK3qH.js} +1 -1
  289. package/dist/chunks/{terminalSetup-2ioFcRAA.js → terminalSetup-DULcnnWe.js} +1 -1
  290. package/dist/chunks/{theme-Dgq_Og2P.js → theme-Bf2QD0ja.js} +1 -1
  291. package/dist/chunks/thinkback-C1nnGg5r.js +1 -0
  292. package/dist/chunks/{thinkback-C43WBHis.js → thinkback-DZEhr3Ii.js} +1 -1
  293. package/dist/chunks/{thinkback-play-D2_n_aoQ.js → thinkback-play-BtEBESXM.js} +1 -1
  294. package/dist/chunks/{toolEventObserver-BG_3sGCL.js → toolEventObserver-CNZy5TpN.js} +1 -1
  295. package/dist/chunks/{toolEventObserver-B7EA-nNa.js → toolEventObserver-DMdrez6V.js} +1 -1
  296. package/dist/chunks/toolPool-DDj2TbY6.js +1 -0
  297. package/dist/chunks/{toolPool-HYKCHxDA.js → toolPool-DHQyHmDY.js} +1 -1
  298. package/dist/chunks/{trustedDevice-DeNxe6bl.js → trustedDevice-DWb5CPB_.js} +1 -1
  299. package/dist/chunks/{trustedDevice-S34i6Jc9.js → trustedDevice-Dw2crViN.js} +1 -1
  300. package/dist/chunks/{ultrareviewCommand-C45bmZqN.js → ultrareviewCommand-BfN25zni.js} +1 -1
  301. package/dist/chunks/undercover-DSp7SB7e.js +1 -0
  302. package/dist/chunks/{undercover-DoUSM8d6.js → undercover-rcR56jZx.js} +1 -1
  303. package/dist/chunks/{updateCCB-BuAm25MX.js → updateCCB-DlTAqQJq.js} +1 -1
  304. package/dist/chunks/{upgrade-BDKg286g.js → upgrade-ClLcX7zy.js} +1 -1
  305. package/dist/chunks/upgrade-kf1QWUo7.js +1 -0
  306. package/dist/chunks/{upload-CMptZXZs.js → upload-BqEzK59v.js} +1 -1
  307. package/dist/chunks/{usage-Bw_LK9YI.js → usage-BgKDh8pQ.js} +1 -1
  308. package/dist/chunks/{usage-DEWsKPXj.js → usage-DW-akzSR.js} +1 -1
  309. package/dist/chunks/{useMainLoopModel-D0PmGDuy.js → useMainLoopModel-BTpZ8k3k.js} +1 -1
  310. package/dist/chunks/{useManagePlugins-B-ejJsXy.js → useManagePlugins-z0qezP5r.js} +1 -1
  311. package/dist/chunks/{useMergedTools-B6x9qtfj.js → useMergedTools-B78rAreW.js} +1 -1
  312. package/dist/chunks/{useSearchInput-BpMLsxaS.js → useSearchInput-CwxF3CHN.js} +1 -1
  313. package/dist/chunks/{useSettingsErrors-DUe4k_RK.js → useSettingsErrors-CjDaon07.js} +1 -1
  314. package/dist/chunks/{useVoice-C3ryR2HE.js → useVoice-X5WSnyed.js} +1 -1
  315. package/dist/chunks/{util-DWl5gjmI.js → util-CP-_gsEO.js} +1 -1
  316. package/dist/chunks/utils-CULcnflj.js +1 -0
  317. package/dist/chunks/{validatePlugin-8EMSASvV.js → validatePlugin-DUuaprqR.js} +1 -1
  318. package/dist/chunks/{vim-CaZ20SrQ.js → vim-BfmsdxOa.js} +1 -1
  319. package/dist/chunks/{voice-BrnKguEV.js → voice-B3GIfFlB.js} +1 -1
  320. package/dist/chunks/voiceModeEnabled-BrA5ZhH4.js +1 -0
  321. package/dist/chunks/{voiceModeEnabled-3eg8vSqy.js → voiceModeEnabled-C1Q9j5q6.js} +1 -1
  322. package/dist/chunks/{voiceStreamSTT-D7jWIYwz.js → voiceStreamSTT-BguyxdrW.js} +1 -1
  323. package/dist/chunks/voiceStreamSTT-Dmp7Vm1S.js +1 -0
  324. package/dist/chunks/{web-tools-BT3TbzG5.js → web-tools-qf_VwWRn.js} +1 -1
  325. package/dist/chunks/{workerRegistry-C_i5wwjL.js → workerRegistry-SbiLJIsG.js} +1 -1
  326. package/dist/chunks/worktree-Djga1wtm.js +1 -0
  327. package/dist/chunks/{xml-DOXio8vw.js → xml-D7-jJqSA.js} +1 -1
  328. package/dist/cli.js +1 -1
  329. package/package.json +1 -1
  330. package/dist/chunks/ApproveApiKey-DUoUTxFp.js +0 -1
  331. package/dist/chunks/ClaudeMdExternalIncludesDialog-COO2W0ij.js +0 -1
  332. package/dist/chunks/ConsoleOAuthFlow-CPWq7O57.js +0 -1
  333. package/dist/chunks/Doctor-Ba9zhV0V.js +0 -1
  334. package/dist/chunks/Grove-DyvIToPa.js +0 -1
  335. package/dist/chunks/REPL-D-akKdFc.js +0 -1
  336. package/dist/chunks/SearchExtraToolsTool-wDSdfnRo.js +0 -1
  337. package/dist/chunks/SentryErrorBoundary-Duyg6HeT.js +0 -1
  338. package/dist/chunks/api-VMfJpk1G.js +0 -1
  339. package/dist/chunks/assistant-D7D1sqTB.js +0 -1
  340. package/dist/chunks/auth-CGdLe3rq.js +0 -1
  341. package/dist/chunks/backgroundHousekeeping-4H6yTjsj.js +0 -1
  342. package/dist/chunks/bridgeConfig-CTJBoASk.js +0 -1
  343. package/dist/chunks/bridgeEnabled-SMuWz3Is.js +0 -1
  344. package/dist/chunks/bridgeMain-UqwOi37W.js +0 -1
  345. package/dist/chunks/caches-DKMoKTAZ.js +0 -1
  346. package/dist/chunks/changeDetector--KPj2maX.js +0 -1
  347. package/dist/chunks/channelNotification-fJgjqRMx.js +0 -1
  348. package/dist/chunks/clear-CYVCwiwu.js +0 -1
  349. package/dist/chunks/client-DvWRsIpi.js +0 -1
  350. package/dist/chunks/commands-BT2_ICaW.js +0 -1
  351. package/dist/chunks/commitAttribution-Bpbro1a4.js +0 -1
  352. package/dist/chunks/context-noninteractive-BQDOgVUW.js +0 -1
  353. package/dist/chunks/conversation-Bt6QdGd-.js +0 -1
  354. package/dist/chunks/createSession-BaHXBnfG.js +0 -1
  355. package/dist/chunks/datadog-DgYqUGa-.js +0 -1
  356. package/dist/chunks/envLessBridgeConfig-D_GCqhTu.js +0 -1
  357. package/dist/chunks/extra-usage-C4dUWLhg.js +0 -1
  358. package/dist/chunks/extractMemories-DS7XXeEo.js +0 -1
  359. package/dist/chunks/fast-D1xIHYaN.js +0 -1
  360. package/dist/chunks/gates-CUAwAhPL.js +0 -1
  361. package/dist/chunks/hooks-DynUngv2.js +0 -1
  362. package/dist/chunks/inboundAttachments-Cug-8Xdy.js +0 -1
  363. package/dist/chunks/language-CjFs6_la.js +0 -1
  364. package/dist/chunks/loadAgentsDir-tPgCg0WD.js +0 -1
  365. package/dist/chunks/localSearch-CxwxzM8W.js +0 -1
  366. package/dist/chunks/login-CVVFklZw.js +0 -1
  367. package/dist/chunks/logout-BYsszpXx.js +0 -1
  368. package/dist/chunks/mappers-BBkM1aA5.js +0 -1
  369. package/dist/chunks/model-VB4ItNVB.js +0 -1
  370. package/dist/chunks/pluginStartupCheck-DjfIaOch.js +0 -1
  371. package/dist/chunks/policyLimits-D-Y_soHx.js +0 -1
  372. package/dist/chunks/poorMode-DQagHYWe.js +0 -1
  373. package/dist/chunks/prompt-BGNhFY1n.js +0 -227
  374. package/dist/chunks/prompt-CrNwH5kr.js +0 -1
  375. package/dist/chunks/prompt-dH0MMivt.js +0 -1
  376. package/dist/chunks/sandbox-adapter-jX_WzvnK.js +0 -1
  377. package/dist/chunks/searchExtraTools-xPuOKDpi.js +0 -1
  378. package/dist/chunks/sessionFileAccessHooks-DiKsr7H7.js +0 -1
  379. package/dist/chunks/sessionMemory-C34-eFnJ.js +0 -1
  380. package/dist/chunks/sessionMemoryUtils-CcJcgftx.js +0 -1
  381. package/dist/chunks/sessionObserver-B73s6yu8.js +0 -1
  382. package/dist/chunks/sessionStorage-BHi7PKs-.js +0 -1
  383. package/dist/chunks/sink-i8NmYch9.js +0 -1
  384. package/dist/chunks/sinks-3w0mLszx.js +0 -1
  385. package/dist/chunks/skillLearning-Bddmbx8E.js +0 -1
  386. package/dist/chunks/skillLearning-C-uI_jZB.js +0 -1
  387. package/dist/chunks/teamHelpers-D41zdxpl.js +0 -1
  388. package/dist/chunks/teammateModeSnapshot-q-bARbLL.js +0 -1
  389. package/dist/chunks/thinkback-BE8NNmAo.js +0 -1
  390. package/dist/chunks/toolPool-BLshLuvo.js +0 -1
  391. package/dist/chunks/undercover-B4sdXe12.js +0 -1
  392. package/dist/chunks/upgrade-BiWGhm2d.js +0 -1
  393. package/dist/chunks/utils-DP3EtI6F.js +0 -1
  394. package/dist/chunks/voiceModeEnabled-B1ARFTcz.js +0 -1
  395. package/dist/chunks/voiceStreamSTT-CONK4g-B.js +0 -1
  396. package/dist/chunks/worktree-CFNQKVGn.js +0 -1
@@ -1 +1 @@
1
- import{n as e,o as t}from"./chunk-DR8-3Aex.js";import{Ct as n,F as r,Rn as i,Tt as a,W as o,b as s,t as c,x as l}from"./src-Di342QoJ.js";import{t as u}from"./jsx-runtime-D-D469L8.js";import{Cc as d,Ps as f,yc as p}from"./paths-BZjPDxMm.js";import{U as m,z as h}from"./debug-otxXY3j-.js";import{$D as g,Hk as _,Ll as v,Po as y,Rl as b,Uk as x,Uo as S,Wk as C,ck as w,d_ as T,dt as E,eO as D,ft as O,mb as k,p_ as A,pb as j}from"./loadAgentsDir-BYWykYwn.js";import{X as M}from"./rcDebugLog-ClX1msJX.js";import{t as N}from"./useTerminalSize-Du-EamDN.js";import{n as P,r as F}from"./sideQuestion-BcP9Mm-5.js";import{i as I,n as L}from"./modalContext-CuTwi_eD.js";function R({question:e,context:t,onDone:n}){let[i,c]=(0,H.useState)(null),[u,d]=(0,H.useState)(null),[f,p]=(0,H.useState)(0),m=(0,H.useRef)(null),{rows:_}=I(r());a(()=>p(e=>e+1),i||u?null:80);function v(e){if(e.key===`escape`||e.key===`return`||e.key===` `||e.ctrl&&(e.key===`c`||e.key===`d`)){e.preventDefault(),n(void 0,{display:`skip`});return}(e.key===`up`||e.ctrl&&e.key===`p`)&&(e.preventDefault(),m.current?.scrollBy(-K)),(e.key===`down`||e.ctrl&&e.key===`n`)&&(e.preventDefault(),m.current?.scrollBy(K))}(0,H.useEffect)(()=>{let n=g();async function r(){try{let r=await F({question:e,cacheSafeParams:await B(t)});n.signal.aborted||(r.response?c(r.response):d(`No response received`))}catch(e){n.signal.aborted||d(h(e)||`Failed to get response`)}}return r(),()=>{n.abort()}},[e,t]);let y=Math.max(5,_-W-G);return(0,U.jsxs)(l,{flexDirection:`column`,paddingLeft:2,marginTop:1,tabIndex:0,autoFocus:!0,onKeyDown:v,children:[(0,U.jsxs)(l,{children:[(0,U.jsxs)(s,{color:`warning`,bold:!0,children:[`/btw`,` `]}),(0,U.jsx)(s,{dimColor:!0,children:e})]}),(0,U.jsx)(l,{marginTop:1,marginLeft:2,maxHeight:y,children:(0,U.jsx)(o,{ref:m,flexDirection:`column`,flexGrow:1,children:u?(0,U.jsx)(s,{color:`error`,children:u}):i?(0,U.jsx)(T,{children:i}):(0,U.jsxs)(l,{children:[(0,U.jsx)(j,{frame:f,messageColor:`warning`}),(0,U.jsx)(s,{color:`warning`,children:`Answering...`})]})})}),(i||u)&&(0,U.jsx)(l,{marginTop:1,children:(0,U.jsxs)(s,{dimColor:!0,children:[`↑`,`/`,`↓`,` to scroll · Space, Enter, or Escape to dismiss`]})})]})}function z(e){let t=e.at(-1);return t?.type===`assistant`&&t.message.stop_reason===null?e.slice(0,-1):e}async function B(e){let t=y(z(e.messages)),n=v();if(n)return{systemPrompt:n.systemPrompt,userContext:n.userContext,systemContext:n.systemContext,toolUseContext:e,forkContextMessages:t};let[r,i,a]=await Promise.all([E(e.options.tools,e.options.mainLoopModel,[],e.options.mcpClients),x(),_()]);return{systemPrompt:M(r),userContext:i,systemContext:a,toolUseContext:e,forkContextMessages:t}}async function V(e,t,n){let r=n?.trim();return r?(d(e=>({...e,btwUseCount:e.btwUseCount+1})),(0,U.jsx)(R,{question:r,context:t,onDone:e})):(e(`Usage: /btw <your question>`,{display:`system`}),null)}var H,U,W,G,K;e((()=>{i(),H=t(i(),1),n(),A(),k(),f(),O(),L(),C(),N(),c(),D(),p(),m(),b(),S(),P(),w(),U=u(),W=5,G=6,K=3}))();export{V as call};
1
+ import{n as e,o as t}from"./chunk-DR8-3Aex.js";import{Ct as n,F as r,Rn as i,Tt as a,W as o,b as s,t as c,x as l}from"./src-Di342QoJ.js";import{t as u}from"./jsx-runtime-D-D469L8.js";import{Cc as d,Ps as f,yc as p}from"./paths-CEAy4QCs.js";import{U as m,z as h}from"./debug-otxXY3j-.js";import{$D as g,Hk as _,Ll as v,Po as y,Rl as b,Uk as x,Uo as S,Wk as C,ck as w,d_ as T,dt as E,eO as D,ft as O,mb as k,p_ as A,pb as j}from"./loadAgentsDir-DC4jN6-f.js";import{X as M}from"./rcDebugLog-C0Bam8V9.js";import{t as N}from"./useTerminalSize-Du-EamDN.js";import{n as P,r as F}from"./sideQuestion-DWOCUKMh.js";import{i as I,n as L}from"./modalContext-CuTwi_eD.js";function R({question:e,context:t,onDone:n}){let[i,c]=(0,H.useState)(null),[u,d]=(0,H.useState)(null),[f,p]=(0,H.useState)(0),m=(0,H.useRef)(null),{rows:_}=I(r());a(()=>p(e=>e+1),i||u?null:80);function v(e){if(e.key===`escape`||e.key===`return`||e.key===` `||e.ctrl&&(e.key===`c`||e.key===`d`)){e.preventDefault(),n(void 0,{display:`skip`});return}(e.key===`up`||e.ctrl&&e.key===`p`)&&(e.preventDefault(),m.current?.scrollBy(-K)),(e.key===`down`||e.ctrl&&e.key===`n`)&&(e.preventDefault(),m.current?.scrollBy(K))}(0,H.useEffect)(()=>{let n=g();async function r(){try{let r=await F({question:e,cacheSafeParams:await B(t)});n.signal.aborted||(r.response?c(r.response):d(`No response received`))}catch(e){n.signal.aborted||d(h(e)||`Failed to get response`)}}return r(),()=>{n.abort()}},[e,t]);let y=Math.max(5,_-W-G);return(0,U.jsxs)(l,{flexDirection:`column`,paddingLeft:2,marginTop:1,tabIndex:0,autoFocus:!0,onKeyDown:v,children:[(0,U.jsxs)(l,{children:[(0,U.jsxs)(s,{color:`warning`,bold:!0,children:[`/btw`,` `]}),(0,U.jsx)(s,{dimColor:!0,children:e})]}),(0,U.jsx)(l,{marginTop:1,marginLeft:2,maxHeight:y,children:(0,U.jsx)(o,{ref:m,flexDirection:`column`,flexGrow:1,children:u?(0,U.jsx)(s,{color:`error`,children:u}):i?(0,U.jsx)(T,{children:i}):(0,U.jsxs)(l,{children:[(0,U.jsx)(j,{frame:f,messageColor:`warning`}),(0,U.jsx)(s,{color:`warning`,children:`Answering...`})]})})}),(i||u)&&(0,U.jsx)(l,{marginTop:1,children:(0,U.jsxs)(s,{dimColor:!0,children:[`↑`,`/`,`↓`,` to scroll · Space, Enter, or Escape to dismiss`]})})]})}function z(e){let t=e.at(-1);return t?.type===`assistant`&&t.message.stop_reason===null?e.slice(0,-1):e}async function B(e){let t=y(z(e.messages)),n=v();if(n)return{systemPrompt:n.systemPrompt,userContext:n.userContext,systemContext:n.systemContext,toolUseContext:e,forkContextMessages:t};let[r,i,a]=await Promise.all([E(e.options.tools,e.options.mainLoopModel,[],e.options.mcpClients),x(),_()]);return{systemPrompt:M(r),userContext:i,systemContext:a,toolUseContext:e,forkContextMessages:t}}async function V(e,t,n){let r=n?.trim();return r?(d(e=>({...e,btwUseCount:e.btwUseCount+1})),(0,U.jsx)(R,{question:r,context:t,onDone:e})):(e(`Usage: /btw <your question>`,{display:`system`}),null)}var H,U,W,G,K;e((()=>{i(),H=t(i(),1),n(),A(),k(),f(),O(),L(),C(),N(),c(),D(),p(),m(),b(),S(),P(),w(),U=u(),W=5,G=6,K=3}))();export{V as call};
@@ -1,3 +1,3 @@
1
- import{n as e,o as t}from"./chunk-DR8-3Aex.js";import{Rn as n,b as r,t as i,x as a,xt as o}from"./src-Di342QoJ.js";import{t as s}from"./jsx-runtime-D-D469L8.js";import{Cc as c,Jt as l,St as u,dc as d,on as f,wt as p,yc as m}from"./paths-BZjPDxMm.js";import{l as h,u as g}from"./oauth-CdZEzMww.js";import{a as _,i as v,n as y,o as b,r as x,s as S,t as C,v as w}from"./companion-rXSt0nmz.js";import{r as T,t as E}from"./sprites-BuvEFwW6.js";function D({name:e,value:t}){let n=Math.round(Math.max(0,Math.min(100,t))/10),i=`█`.repeat(n)+`░`.repeat(10-n);return(0,k.jsxs)(r,{children:[e.padEnd(10),` `,i,` `,String(t).padStart(3)]})}function O({companion:e,lastReaction:t,onDone:n}){let i=_[e.rarity],s=b[e.rarity],c=T(e,0);return o(()=>{n?.(void 0,{display:`skip`})},{isActive:n!==void 0}),(0,k.jsxs)(a,{flexDirection:`column`,borderStyle:`round`,borderColor:i,paddingX:j,paddingY:1,width:A,flexShrink:0,children:[(0,k.jsxs)(a,{justifyContent:`space-between`,children:[(0,k.jsxs)(r,{bold:!0,color:i,children:[s,` `,e.rarity.toUpperCase()]}),(0,k.jsx)(r,{color:i,children:e.species.toUpperCase()})]}),e.shiny&&(0,k.jsxs)(r,{color:`warning`,bold:!0,children:[`✨`,` SHINY `,`✨`]}),(0,k.jsx)(a,{flexDirection:`column`,marginY:1,children:c.map((e,t)=>(0,k.jsx)(r,{color:i,children:e},t))}),(0,k.jsx)(r,{bold:!0,children:e.name}),(0,k.jsx)(a,{marginY:1,children:(0,k.jsxs)(r,{dimColor:!0,italic:!0,children:[`"`,e.personality,`"`]})}),(0,k.jsx)(a,{flexDirection:`column`,children:S.map(t=>(0,k.jsx)(D,{name:t,value:e.stats[t]??0},t))}),t&&(0,k.jsxs)(a,{flexDirection:`column`,marginTop:1,children:[(0,k.jsx)(r,{dimColor:!0,children:`last said`}),(0,k.jsx)(a,{borderStyle:`round`,borderColor:`inactive`,paddingX:1,children:(0,k.jsx)(r,{dimColor:!0,italic:!0,children:t})})]})]})}var k,A,j,M=e((()=>{i(),E(),w(),k=s(),A=40,j=2}));function N(e,t){let n=y();if(!n||d().companionMuted)return;let r=P(e,n.name),i=Date.now();if(!r&&i-R<z)return;let a=I(e);a.trim()&&(R=i,L(n,a,r).then(e=>{e&&(B.push(e),B.length>V&&B.shift(),t(e))}).catch(()=>{}))}function P(e,t){let n=RegExp(`\\b${F(t)}\\b`,`i`);for(let t=e.length-1;t>=Math.max(0,e.length-3);t--){let r=e[t];if(r?.type!==`user`)continue;let i=r.message?.content;if(typeof i==`string`&&n.test(i))return!0}return!1}function F(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function I(e){return e.slice(-12).filter(e=>e.type===`user`||e.type===`assistant`).map(e=>{let t=e.type===`user`?`user`:`claude`,n=e.message?.content;return`${t}: ${typeof n==`string`?n.slice(0,300):Array.isArray(n)?n.filter(e=>e?.type===`text`).map(e=>e.text).join(` `).slice(0,300):``}`}).join(`
1
+ import{n as e,o as t}from"./chunk-DR8-3Aex.js";import{Rn as n,b as r,t as i,x as a,xt as o}from"./src-Di342QoJ.js";import{t as s}from"./jsx-runtime-D-D469L8.js";import{Cc as c,Jt as l,St as u,dc as d,on as f,wt as p,yc as m}from"./paths-CEAy4QCs.js";import{l as h,u as g}from"./oauth-CdZEzMww.js";import{a as _,i as v,n as y,o as b,r as x,s as S,t as C,v as w}from"./companion-C-jfFhlz.js";import{r as T,t as E}from"./sprites-ChoMSqpa.js";function D({name:e,value:t}){let n=Math.round(Math.max(0,Math.min(100,t))/10),i=`█`.repeat(n)+`░`.repeat(10-n);return(0,k.jsxs)(r,{children:[e.padEnd(10),` `,i,` `,String(t).padStart(3)]})}function O({companion:e,lastReaction:t,onDone:n}){let i=_[e.rarity],s=b[e.rarity],c=T(e,0);return o(()=>{n?.(void 0,{display:`skip`})},{isActive:n!==void 0}),(0,k.jsxs)(a,{flexDirection:`column`,borderStyle:`round`,borderColor:i,paddingX:j,paddingY:1,width:A,flexShrink:0,children:[(0,k.jsxs)(a,{justifyContent:`space-between`,children:[(0,k.jsxs)(r,{bold:!0,color:i,children:[s,` `,e.rarity.toUpperCase()]}),(0,k.jsx)(r,{color:i,children:e.species.toUpperCase()})]}),e.shiny&&(0,k.jsxs)(r,{color:`warning`,bold:!0,children:[`✨`,` SHINY `,`✨`]}),(0,k.jsx)(a,{flexDirection:`column`,marginY:1,children:c.map((e,t)=>(0,k.jsx)(r,{color:i,children:e},t))}),(0,k.jsx)(r,{bold:!0,children:e.name}),(0,k.jsx)(a,{marginY:1,children:(0,k.jsxs)(r,{dimColor:!0,italic:!0,children:[`"`,e.personality,`"`]})}),(0,k.jsx)(a,{flexDirection:`column`,children:S.map(t=>(0,k.jsx)(D,{name:t,value:e.stats[t]??0},t))}),t&&(0,k.jsxs)(a,{flexDirection:`column`,marginTop:1,children:[(0,k.jsx)(r,{dimColor:!0,children:`last said`}),(0,k.jsx)(a,{borderStyle:`round`,borderColor:`inactive`,paddingX:1,children:(0,k.jsx)(r,{dimColor:!0,italic:!0,children:t})})]})]})}var k,A,j,M=e((()=>{i(),E(),w(),k=s(),A=40,j=2}));function N(e,t){let n=y();if(!n||d().companionMuted)return;let r=P(e,n.name),i=Date.now();if(!r&&i-R<z)return;let a=I(e);a.trim()&&(R=i,L(n,a,r).then(e=>{e&&(B.push(e),B.length>V&&B.shift(),t(e))}).catch(()=>{}))}function P(e,t){let n=RegExp(`\\b${F(t)}\\b`,`i`);for(let t=e.length-1;t>=Math.max(0,e.length-3);t--){let r=e[t];if(r?.type!==`user`)continue;let i=r.message?.content;if(typeof i==`string`&&n.test(i))return!0}return!1}function F(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function I(e){return e.slice(-12).filter(e=>e.type===`user`||e.type===`assistant`).map(e=>{let t=e.type===`user`?`user`:`claude`,n=e.message?.content;return`${t}: ${typeof n==`string`?n.slice(0,300):Array.isArray(n)?n.filter(e=>e?.type===`text`).map(e=>e.text).join(` `).slice(0,300):``}`}).join(`
2
2
  `).slice(0,5e3)}async function L(e,t,n){let r=l();if(!r?.accessToken)return null;let i=d().oauthAccount?.organizationUuid;if(!i)return null;let a=`${h().BASE_API_URL}/api/organizations/${i}/claude_code/buddy_react`,o=await fetch(a,{method:`POST`,headers:{Authorization:`Bearer ${r.accessToken}`,"Content-Type":`application/json`,"User-Agent":u()},body:JSON.stringify({name:e.name.slice(0,32),personality:e.personality.slice(0,200),species:e.species,rarity:e.rarity,stats:e.stats,transcript:t,reason:n?`addressed`:`turn`,recent:B.map(e=>e.slice(0,200)),addressed:n}),signal:AbortSignal.timeout(1e4)});if(!o.ok)return null;try{return(await o.json()).reaction?.trim()||null}catch{return null}}var R,z,B,V,H=e((()=>{x(),m(),f(),g(),p(),R=0,z=45e3,B=[],V=8}));function U(e){return e.charAt(0).toUpperCase()+e.slice(1)}async function W(e,t,n){let r=n?.trim().toLowerCase()??``,i=t.setAppState;if(r===`off`)return c(e=>({...e,companionMuted:!0})),e(`companion muted`,{display:`system`}),null;if(r===`on`)return c(e=>({...e,companionMuted:!1})),e(`companion unmuted`,{display:`system`}),null;if(r===`pet`){let n=y();return n?(c(e=>({...e,companionMuted:!1})),i?.(e=>({...e,companionPetAt:Date.now()})),N(t.messages??[],e=>i?.(t=>t.companionReaction===e?t:{...t,companionReaction:e})),e(`petted ${n.name}`,{display:`system`}),null):(e(`no companion yet · run /buddy first`,{display:`system`}),null)}let a=y();if(a&&d().companionMuted&&c(e=>({...e,companionMuted:!1})),a){let n=t.getAppState?.()?.companionReaction;return G.createElement(O,{companion:a,lastReaction:n,onDone:e})}let o=C(),s=v(o),l=K[s.bones.species]??`Buddy`,u=q[s.bones.species]??`Mysterious and code-savvy.`,f={name:l,personality:u,seed:o,hatchedAt:Date.now()};c(e=>({...e,companion:f}));let p=b[s.bones.rarity],m=T(s.bones,0),h=s.bones.shiny?` ✨ Shiny!`:``;return e([`A wild companion appeared!`,``,...m,``,`${l} the ${U(s.bones.species)}${h}`,`Rarity: ${p} (${s.bones.rarity})`,`"${u}"`,``,`Your companion will now appear beside your input box!`,`Say its name to get its take · /buddy pet · /buddy off`].join(`
3
3
  `),{display:`system`}),null}var G,K,q;e((()=>{G=t(n(),1),x(),w(),E(),M(),m(),H(),K={duck:`Waddles`,goose:`Goosberry`,blob:`Gooey`,cat:`Whiskers`,dragon:`Ember`,octopus:`Inky`,owl:`Hoots`,penguin:`Waddleford`,turtle:`Shelly`,snail:`Trailblazer`,ghost:`Casper`,axolotl:`Axie`,capybara:`Chill`,cactus:`Spike`,robot:`Byte`,rabbit:`Flops`,mushroom:`Spore`,chonk:`Chonk`},q={duck:`Quirky and easily amused. Leaves rubber duck debugging tips everywhere.`,goose:`Assertive and honks at bad code. Takes no prisoners in code reviews.`,blob:`Adaptable and goes with the flow. Sometimes splits into two when confused.`,cat:`Independent and judgmental. Watches you type with mild disdain.`,dragon:`Fiery and passionate about architecture. Hoards good variable names.`,octopus:`Multitasker extraordinaire. Wraps tentacles around every problem at once.`,owl:`Wise but verbose. Always says "let me think about that" for exactly 3 seconds.`,penguin:`Cool under pressure. Slides gracefully through merge conflicts.`,turtle:`Patient and thorough. Believes slow and steady wins the deploy.`,snail:`Methodical and leaves a trail of useful comments. Never rushes.`,ghost:`Ethereal and appears at the worst possible moments with spooky insights.`,axolotl:`Regenerative and cheerful. Recovers from any bug with a smile.`,capybara:`Zen master. Remains calm while everything around is on fire.`,cactus:`Prickly on the outside but full of good intentions. Thrives on neglect.`,robot:`Efficient and literal. Processes feedback in binary.`,rabbit:`Energetic and hops between tasks. Finishes before you start.`,mushroom:`Quietly insightful. Grows on you over time.`,chonk:`Big, warm, and takes up the whole couch. Prioritizes comfort over elegance.`}}))();export{W as call};
@@ -1 +1 @@
1
- import{n as e,o as t}from"./chunk-DR8-3Aex.js";import{Rn as n}from"./src-Di342QoJ.js";import{W as r,cn as i}from"./state-sIHsFpDu.js";import{J as a,U as o}from"./debug-otxXY3j-.js";import{o as s,s as c}from"./log-DSV4Ht5l.js";import{L as l,dC as u,fC as d,lC as f,uC as p,w as m}from"./loadAgentsDir-BYWykYwn.js";async function h(e,t,n){{if(y)return;y=!0;let{updateContext:r,notification:i}=await l(e,n);t(e=>{let t=r(e.toolPermissionContext),n=t===e.toolPermissionContext?e:{...e,toolPermissionContext:t};return i?{...n,notifications:{...n.notifications,queue:[...n.notifications.queue,{key:`auto-mode-gate-notification`,text:i,color:`warning`,priority:`high`}]}}:n})}}function g(){y=!1}function _(){let e=p(e=>e.mainLoopModel),t=p(e=>e.mainLoopModelForSession),n=p(e=>e.fastMode),i=d(),o=u(),s=(0,v.useRef)(!0);(0,v.useEffect)(()=>{r()||(s.current?s.current=!1:g(),h(o.getState().toolPermissionContext,i,n).catch(e=>{c(Error(`Auto mode gate check failed`,{cause:a(e)}))}))},[e,t,n])}var v,y,b=e((()=>{v=t(n(),1),o(),s(),i(),f(),m(),y=!1}));export{_ as i,b as n,g as r,h as t};
1
+ import{n as e,o as t}from"./chunk-DR8-3Aex.js";import{Rn as n}from"./src-Di342QoJ.js";import{W as r,cn as i}from"./state-sIHsFpDu.js";import{J as a,U as o}from"./debug-otxXY3j-.js";import{o as s,s as c}from"./log-DSV4Ht5l.js";import{L as l,dC as u,fC as d,lC as f,uC as p,w as m}from"./loadAgentsDir-DC4jN6-f.js";async function h(e,t,n){{if(y)return;y=!0;let{updateContext:r,notification:i}=await l(e,n);t(e=>{let t=r(e.toolPermissionContext),n=t===e.toolPermissionContext?e:{...e,toolPermissionContext:t};return i?{...n,notifications:{...n.notifications,queue:[...n.notifications.queue,{key:`auto-mode-gate-notification`,text:i,color:`warning`,priority:`high`}]}}:n})}}function g(){y=!1}function _(){let e=p(e=>e.mainLoopModel),t=p(e=>e.mainLoopModelForSession),n=p(e=>e.fastMode),i=d(),o=u(),s=(0,v.useRef)(!0);(0,v.useEffect)(()=>{r()||(s.current?s.current=!1:g(),h(o.getState().toolPermissionContext,i,n).catch(e=>{c(Error(`Auto mode gate check failed`,{cause:a(e)}))}))},[e,t,n])}var v,y,b=e((()=>{v=t(n(),1),o(),s(),i(),f(),m(),y=!1}));export{_ as i,b as n,g as r,h as t};
@@ -0,0 +1 @@
1
+ import{n as e,t}from"./caches-CzEBsMvP.js";e();export{t as clearSessionCaches};
@@ -1,3 +1,3 @@
1
- import{n as e,o as t}from"./chunk-DR8-3Aex.js";import{n,t as r}from"./defineProperty-80gRi2ZW.js";import{p as i}from"./zod-DT6hytkp.js";import{Fr as a,Pr as o,Zn as s,cn as c,u as l}from"./state-sIHsFpDu.js";import{Ka as u,dc as d,oo as f,yc as p}from"./paths-BZjPDxMm.js";import{U as m,_ as h,h as g,l as _,p as v,z as y}from"./debug-otxXY3j-.js";import{n as b,r as x}from"./analytics-DqMQntaB.js";import{n as S,t as C}from"./cwd--iizewsn.js";import{E as ee,S as te,_ as ne,r as re,v as ie}from"./git-C0IuvuIy.js";import{o as ae,s as w}from"./log-DSV4Ht5l.js";import{i as oe,n as se}from"./path-BE28AJwZ.js";import{n as T,r as ce}from"./execFileNoThrow-azCkYhmF.js";import{$d as le,$k as ue,AC as de,Cl as fe,Cn as pe,Fc as me,Gi as he,Gk as ge,Gm as _e,Hk as ve,Ic as ye,Kh as be,Lt as xe,My as Se,Ny as Ce,Q as we,Qk as Te,Uk as Ee,Ut as De,Vk as Oe,Wk as ke,X as Ae,Xd as je,Ym as Me,_ as Ne,dA as Pe,gh as Fe,hh as Ie,jC as Le,m as Re,na as ze,pA as Be,qh as Ve,rO as He,tO as Ue,v as We,xl as Ge}from"./loadAgentsDir-BYWykYwn.js";import{nn as Ke,tn as qe}from"./prompt-BGNhFY1n.js";import{a as Je,s as Ye}from"./ripgrep-Bzwdi5-K.js";import{a as Xe,t as Ze}from"./detectRepository-2ICvGD0U.js";import{r as Qe,t as $e}from"./magicDocs-DAvjAbAJ.js";import*as E from"path";import{statSync as et}from"fs";function D(e,t,n){if(t===0)return n?M:0;let r=e.charCodeAt(t-1);return tt(r)?A:nt(r)&&rt(e.charCodeAt(t))?at:0}function tt(e){return e===47||e===92||e===45||e===95||e===46||e===32}function nt(e){return e>=97&&e<=122}function rt(e){return e>=65&&e<=90}function O(){return new Promise(e=>setImmediate(e))}function it(e,t){let n=new Set;for(let r of e){let e=r.length;for(let t=0;t<r.length;t++){let n=r.charCodeAt(t);if(n===47||n===92){e=t;break}}let i=r.slice(0,e);if(i.length>0&&(n.add(i),n.size>=t))break}let r=Array.from(n);return r.sort((e,t)=>{let n=e.length-t.length;return n===0?e<t?-1:+(e>t):n}),r.slice(0,t).map(e=>({path:e,score:0}))}var k,A,at,j,M,ot,st,ct,N,P,lt,ut=e((()=>{n(),k=16,A=8,at=6,j=4,M=8,ot=3,st=1,ct=100,N=64,P=new Int32Array(N),lt=class{constructor(){r(this,`paths`,[]),r(this,`lowerPaths`,[]),r(this,`charBits`,new Int32Array),r(this,`pathLens`,new Uint16Array),r(this,`topLevelCache`,null),r(this,`readyCount`,0)}loadFromFileList(e){let t=new Set,n=[];for(let r of e)r.length>0&&!t.has(r)&&(t.add(r),n.push(r));this.buildIndex(n)}loadFromFileListAsync(e){let t=()=>{};return{queryable:new Promise(e=>{t=e}),done:this.buildAsync(e,t)}}async buildAsync(e,t){let n=new Set,r=[],i=performance.now();for(let t=0;t<e.length;t++){let a=e[t];a.length>0&&!n.has(a)&&(n.add(a),r.push(a)),(t&255)==255&&performance.now()-i>4&&(await O(),i=performance.now())}this.resetArrays(r),i=performance.now();let a=!0;for(let e=0;e<r.length;e++)this.indexPath(e),(e&255)==255&&performance.now()-i>4&&(this.readyCount=e+1,a&&(t(),a=!1),await O(),i=performance.now());this.readyCount=r.length,t()}buildIndex(e){this.resetArrays(e);for(let t=0;t<e.length;t++)this.indexPath(t);this.readyCount=e.length}resetArrays(e){let t=e.length;this.paths=e,this.lowerPaths=Array(t),this.charBits=new Int32Array(t),this.pathLens=new Uint16Array(t),this.readyCount=0,this.topLevelCache=it(e,ct)}indexPath(e){let t=this.paths[e].toLowerCase();this.lowerPaths[e]=t;let n=t.length;this.pathLens[e]=n;let r=0;for(let e=0;e<n;e++){let n=t.charCodeAt(e);n>=97&&n<=122&&(r|=1<<n-97)}this.charBits[e]=r}search(e,t){if(t<=0)return[];if(e.length===0)return this.topLevelCache?this.topLevelCache.slice(0,t):[];let n=e!==e.toLowerCase(),r=n?e:e.toLowerCase(),i=Math.min(r.length,N),a=Array(i),o=0;for(let e=0;e<i;e++){let t=r.charAt(e);a[e]=t;let n=t.charCodeAt(0);n>=97&&n<=122&&(o|=1<<n-97)}let s=i*(k+A)+M+32,c=[],l=-1/0,{paths:u,lowerPaths:d,charBits:f,pathLens:p,readyCount:m}=this;for(let e=0;e<m;e++){if((f[e]&o)!==o)continue;let r=n?u[e]:d[e],m=a[0],h=0,g=[],_=r.indexOf(m);if(_===-1)continue;g[h++]=_;for(let e=_+1;e<r.length;e++){if(r.charCodeAt(e)!==m.charCodeAt(0))continue;let t=r.charCodeAt(e-1);(t===47||t===92||t===45||t===95||t===46||t===32)&&(g[h++]=e)}let v=u[e],y=p[e],b=Math.max(0,32-(y>>2)),x=-1/0;for(let e=0;e<h;e++){P[0]=g[e];let n=0,o=0,u=P[0],d=!0;for(let e=1;e<i;e++){let t=r.indexOf(a[e],u+1);if(t===-1){d=!1;break}P[e]=t;let i=t-u-1;i===0?o+=j:n+=ot+i*st,u=t}if(!d||c.length===t&&s+o-n+b<=l)continue;let f=i*k+o-n;f+=D(v,P[0],!0);for(let e=1;e<i;e++)f+=D(v,P[e],!1);f+=b,f>x&&(x=f)}if(x===-1/0)continue;let S=x;if(c.length<t)c.push({path:v,fuzzScore:S}),c.length===t&&(c.sort((e,t)=>e.fuzzScore-t.fuzzScore),l=c[0].fuzzScore);else if(S>l){let e=0,t=c.length;for(;e<t;){let n=e+t>>1;c[n].fuzzScore<S?e=n+1:t=n}c.splice(e,0,{path:v,fuzzScore:S}),c.shift(),l=c[0].fuzzScore}}c.sort((e,t)=>t.fuzzScore-e.fuzzScore);let h=c.length,g=Math.max(h,1),_=Array(h);for(let e=0;e<h;e++){let t=c[e].path,n=e/g;_[e]={path:t,score:t.includes(`test`)?Math.min(n*1.05,1):n}}return _}}}));function F(){return R||(R=new lt),R}function dt(){R=null,z=null,V++,H=null,U=[],W=[],G=[],B.clear(),K=null,q=null,J=0,Y=null,X=null,Z=null}function ft(e){let t=e.length,n=Math.max(1,Math.floor(t/500)),r=-2128831035;for(let i=0;i<t;i+=n){let t=e[i];for(let e=0;e<t.length;e++)r=(r^t.charCodeAt(e))*16777619|0;r=r*16777619|0}if(t>0){let n=e[t-1];for(let e=0;e<n.length;e++)r=(r^n.charCodeAt(e))*16777619|0}return`${t}:${(r>>>0).toString(16)}`}function pt(){let e=re(C());if(!e)return null;try{return et(E.join(e,`.git`,`index`)).mtimeMs}catch{return null}}function mt(e,t,n){return n===t?e:e.map(e=>{let r=E.join(t,e);return E.relative(n,r)})}async function ht(e){if(e.length===0||!R||U.length===0)return;let t=await vt(e),n=[...U,...W,...G,...e,...t],r=ft(n);if(r===Z){v(`[FileIndex] skipped index rebuild — merged paths unchanged`);return}await R.loadFromFileListAsync(n).done,Z=r,v(`[FileIndex] rebuilt index with ${U.length} tracked + ${e.length} untracked files`)}async function gt(e,t){let n=`${e}:${t}`;if(q===n)return K;let r=g(),i=[`.ignore`,`.rgignore`],a=[...new Set([e,t])],o=(0,kt.default)(),s=!1,c=a.flatMap(e=>i.map(t=>E.join(e,t))),l=await Promise.all(c.map(e=>r.readFile(e,{encoding:`utf8`}).catch(()=>null)));for(let[e,t]of l.entries())t!==null&&(o.add(t),s=!0,v(`[FileIndex] loaded ignore patterns from ${c[e]}`));let u=s?o:null;return K=u,q=n,u}async function _t(e,t){let n=Date.now();v(`[FileIndex] getFilesUsingGit called`);let r=C(),i=re(r);if(!i)return v(`[FileIndex] not a git repo, returning null`),null;try{let a=Date.now(),o=await T(ne(),[`-c`,`core.quotepath=false`,`ls-files`,`--recurse-submodules`],{timeout:5e3,abortSignal:e,cwd:i});if(v(`[FileIndex] git ls-files (tracked) took ${Date.now()-a}ms`),o.code!==0)return v(`[FileIndex] git ls-files failed (code=${o.code}, stderr=${o.stderr}), falling back to ripgrep`),null;let s=mt(o.stdout.trim().split(`
1
+ import{n as e,o as t}from"./chunk-DR8-3Aex.js";import{n,t as r}from"./defineProperty-80gRi2ZW.js";import{p as i}from"./zod-DT6hytkp.js";import{Fr as a,Pr as o,Zn as s,cn as c,u as l}from"./state-sIHsFpDu.js";import{Ka as u,dc as d,oo as f,yc as p}from"./paths-CEAy4QCs.js";import{U as m,_ as h,h as g,l as _,p as v,z as y}from"./debug-otxXY3j-.js";import{n as b,r as x}from"./analytics-DqMQntaB.js";import{n as S,t as C}from"./cwd--iizewsn.js";import{E as ee,S as te,_ as ne,r as re,v as ie}from"./git-C0IuvuIy.js";import{o as ae,s as w}from"./log-DSV4Ht5l.js";import{i as oe,n as se}from"./path-BE28AJwZ.js";import{n as T,r as ce}from"./execFileNoThrow-azCkYhmF.js";import{$d as le,$k as ue,AC as de,Cl as fe,Cn as pe,Fc as me,Gi as he,Gk as ge,Gm as _e,Hk as ve,Ic as ye,Kh as be,Lt as xe,My as Se,Ny as Ce,Q as we,Qk as Te,Uk as Ee,Ut as De,Vk as Oe,Wk as ke,X as Ae,Xd as je,Ym as Me,_ as Ne,dA as Pe,gh as Fe,hh as Ie,jC as Le,m as Re,na as ze,pA as Be,qh as Ve,rO as He,tO as Ue,v as We,xl as Ge}from"./loadAgentsDir-DC4jN6-f.js";import{nn as Ke,tn as qe}from"./prompt-BHI7PZe4.js";import{a as Je,s as Ye}from"./ripgrep-Bzwdi5-K.js";import{a as Xe,t as Ze}from"./detectRepository-2ICvGD0U.js";import{r as Qe,t as $e}from"./magicDocs-TF6U6QoB.js";import*as E from"path";import{statSync as et}from"fs";function D(e,t,n){if(t===0)return n?M:0;let r=e.charCodeAt(t-1);return tt(r)?A:nt(r)&&rt(e.charCodeAt(t))?at:0}function tt(e){return e===47||e===92||e===45||e===95||e===46||e===32}function nt(e){return e>=97&&e<=122}function rt(e){return e>=65&&e<=90}function O(){return new Promise(e=>setImmediate(e))}function it(e,t){let n=new Set;for(let r of e){let e=r.length;for(let t=0;t<r.length;t++){let n=r.charCodeAt(t);if(n===47||n===92){e=t;break}}let i=r.slice(0,e);if(i.length>0&&(n.add(i),n.size>=t))break}let r=Array.from(n);return r.sort((e,t)=>{let n=e.length-t.length;return n===0?e<t?-1:+(e>t):n}),r.slice(0,t).map(e=>({path:e,score:0}))}var k,A,at,j,M,ot,st,ct,N,P,lt,ut=e((()=>{n(),k=16,A=8,at=6,j=4,M=8,ot=3,st=1,ct=100,N=64,P=new Int32Array(N),lt=class{constructor(){r(this,`paths`,[]),r(this,`lowerPaths`,[]),r(this,`charBits`,new Int32Array),r(this,`pathLens`,new Uint16Array),r(this,`topLevelCache`,null),r(this,`readyCount`,0)}loadFromFileList(e){let t=new Set,n=[];for(let r of e)r.length>0&&!t.has(r)&&(t.add(r),n.push(r));this.buildIndex(n)}loadFromFileListAsync(e){let t=()=>{};return{queryable:new Promise(e=>{t=e}),done:this.buildAsync(e,t)}}async buildAsync(e,t){let n=new Set,r=[],i=performance.now();for(let t=0;t<e.length;t++){let a=e[t];a.length>0&&!n.has(a)&&(n.add(a),r.push(a)),(t&255)==255&&performance.now()-i>4&&(await O(),i=performance.now())}this.resetArrays(r),i=performance.now();let a=!0;for(let e=0;e<r.length;e++)this.indexPath(e),(e&255)==255&&performance.now()-i>4&&(this.readyCount=e+1,a&&(t(),a=!1),await O(),i=performance.now());this.readyCount=r.length,t()}buildIndex(e){this.resetArrays(e);for(let t=0;t<e.length;t++)this.indexPath(t);this.readyCount=e.length}resetArrays(e){let t=e.length;this.paths=e,this.lowerPaths=Array(t),this.charBits=new Int32Array(t),this.pathLens=new Uint16Array(t),this.readyCount=0,this.topLevelCache=it(e,ct)}indexPath(e){let t=this.paths[e].toLowerCase();this.lowerPaths[e]=t;let n=t.length;this.pathLens[e]=n;let r=0;for(let e=0;e<n;e++){let n=t.charCodeAt(e);n>=97&&n<=122&&(r|=1<<n-97)}this.charBits[e]=r}search(e,t){if(t<=0)return[];if(e.length===0)return this.topLevelCache?this.topLevelCache.slice(0,t):[];let n=e!==e.toLowerCase(),r=n?e:e.toLowerCase(),i=Math.min(r.length,N),a=Array(i),o=0;for(let e=0;e<i;e++){let t=r.charAt(e);a[e]=t;let n=t.charCodeAt(0);n>=97&&n<=122&&(o|=1<<n-97)}let s=i*(k+A)+M+32,c=[],l=-1/0,{paths:u,lowerPaths:d,charBits:f,pathLens:p,readyCount:m}=this;for(let e=0;e<m;e++){if((f[e]&o)!==o)continue;let r=n?u[e]:d[e],m=a[0],h=0,g=[],_=r.indexOf(m);if(_===-1)continue;g[h++]=_;for(let e=_+1;e<r.length;e++){if(r.charCodeAt(e)!==m.charCodeAt(0))continue;let t=r.charCodeAt(e-1);(t===47||t===92||t===45||t===95||t===46||t===32)&&(g[h++]=e)}let v=u[e],y=p[e],b=Math.max(0,32-(y>>2)),x=-1/0;for(let e=0;e<h;e++){P[0]=g[e];let n=0,o=0,u=P[0],d=!0;for(let e=1;e<i;e++){let t=r.indexOf(a[e],u+1);if(t===-1){d=!1;break}P[e]=t;let i=t-u-1;i===0?o+=j:n+=ot+i*st,u=t}if(!d||c.length===t&&s+o-n+b<=l)continue;let f=i*k+o-n;f+=D(v,P[0],!0);for(let e=1;e<i;e++)f+=D(v,P[e],!1);f+=b,f>x&&(x=f)}if(x===-1/0)continue;let S=x;if(c.length<t)c.push({path:v,fuzzScore:S}),c.length===t&&(c.sort((e,t)=>e.fuzzScore-t.fuzzScore),l=c[0].fuzzScore);else if(S>l){let e=0,t=c.length;for(;e<t;){let n=e+t>>1;c[n].fuzzScore<S?e=n+1:t=n}c.splice(e,0,{path:v,fuzzScore:S}),c.shift(),l=c[0].fuzzScore}}c.sort((e,t)=>t.fuzzScore-e.fuzzScore);let h=c.length,g=Math.max(h,1),_=Array(h);for(let e=0;e<h;e++){let t=c[e].path,n=e/g;_[e]={path:t,score:t.includes(`test`)?Math.min(n*1.05,1):n}}return _}}}));function F(){return R||(R=new lt),R}function dt(){R=null,z=null,V++,H=null,U=[],W=[],G=[],B.clear(),K=null,q=null,J=0,Y=null,X=null,Z=null}function ft(e){let t=e.length,n=Math.max(1,Math.floor(t/500)),r=-2128831035;for(let i=0;i<t;i+=n){let t=e[i];for(let e=0;e<t.length;e++)r=(r^t.charCodeAt(e))*16777619|0;r=r*16777619|0}if(t>0){let n=e[t-1];for(let e=0;e<n.length;e++)r=(r^n.charCodeAt(e))*16777619|0}return`${t}:${(r>>>0).toString(16)}`}function pt(){let e=re(C());if(!e)return null;try{return et(E.join(e,`.git`,`index`)).mtimeMs}catch{return null}}function mt(e,t,n){return n===t?e:e.map(e=>{let r=E.join(t,e);return E.relative(n,r)})}async function ht(e){if(e.length===0||!R||U.length===0)return;let t=await vt(e),n=[...U,...W,...G,...e,...t],r=ft(n);if(r===Z){v(`[FileIndex] skipped index rebuild — merged paths unchanged`);return}await R.loadFromFileListAsync(n).done,Z=r,v(`[FileIndex] rebuilt index with ${U.length} tracked + ${e.length} untracked files`)}async function gt(e,t){let n=`${e}:${t}`;if(q===n)return K;let r=g(),i=[`.ignore`,`.rgignore`],a=[...new Set([e,t])],o=(0,kt.default)(),s=!1,c=a.flatMap(e=>i.map(t=>E.join(e,t))),l=await Promise.all(c.map(e=>r.readFile(e,{encoding:`utf8`}).catch(()=>null)));for(let[e,t]of l.entries())t!==null&&(o.add(t),s=!0,v(`[FileIndex] loaded ignore patterns from ${c[e]}`));let u=s?o:null;return K=u,q=n,u}async function _t(e,t){let n=Date.now();v(`[FileIndex] getFilesUsingGit called`);let r=C(),i=re(r);if(!i)return v(`[FileIndex] not a git repo, returning null`),null;try{let a=Date.now(),o=await T(ne(),[`-c`,`core.quotepath=false`,`ls-files`,`--recurse-submodules`],{timeout:5e3,abortSignal:e,cwd:i});if(v(`[FileIndex] git ls-files (tracked) took ${Date.now()-a}ms`),o.code!==0)return v(`[FileIndex] git ls-files failed (code=${o.code}, stderr=${o.stderr}), falling back to ripgrep`),null;let s=mt(o.stdout.trim().split(`
2
2
  `).filter(Boolean),i,r),c=await gt(i,r);if(c){let e=s.length;s=c.filter(s),v(`[FileIndex] applied ignore patterns: ${e} -> ${s.length} files`)}U=s;let l=Date.now()-n;if(v(`[FileIndex] git ls-files: ${s.length} tracked files in ${l}ms`),x(`tengu_file_suggestions_git_ls_files`,{file_count:s.length,tracked_count:s.length,untracked_count:0,duration_ms:l}),!H){let e=t?[`-c`,`core.quotepath=false`,`ls-files`,`--others`,`--exclude-standard`]:[`-c`,`core.quotepath=false`,`ls-files`,`--others`],n=V;H=T(ne(),e,{timeout:1e4,cwd:i}).then(async e=>{if(n===V&&e.code===0){let t=mt(e.stdout.trim().split(`
3
- `).filter(Boolean),i,r),n=await gt(i,r);if(n&&t.length>0){let e=t.length;t=n.filter(t),v(`[FileIndex] applied ignore patterns to untracked: ${e} -> ${t.length} files`)}v(`[FileIndex] background untracked fetch: ${t.length} files`),ht(t)}}).catch(e=>{v(`[FileIndex] background untracked fetch failed: ${e}`)}).finally(()=>{H=null})}return s}catch(e){return v(`[FileIndex] git ls-files error: ${y(e)}`),null}}async function vt(e){let t=new Set,n=performance.now();for(let r=0;r<e.length;r++)yt(e,r,r+1,t),(r&255)==255&&performance.now()-n>4&&(await O(),n=performance.now());return[...t].map(e=>e+E.sep)}function yt(e,t,n,r){for(let i=t;i<n;i++){let t=E.dirname(e[i]);for(;t!==`.`&&!r.has(t);){let e=E.dirname(t);if(e===t)break;r.add(t),t=e}}}async function bt(e){return(await Promise.all(Re.map(t=>We(t,e)))).flatMap(e=>e.map(e=>e.filePath))}async function xt(e,t){v(`[FileIndex] getProjectFiles called, respectGitignore=${t}`);let n=await _t(e,t);if(n!==null)return v(`[FileIndex] using git ls-files result (${n.length} files)`),n;v(`[FileIndex] git ls-files returned null, falling back to ripgrep`);let r=Date.now(),i=[`--files`,`--follow`,`--hidden`,`--glob`,`!.git/`,`--glob`,`!.svn/`,`--glob`,`!.hg/`,`--glob`,`!.bzr/`,`--glob`,`!.jj/`,`--glob`,`!.sl/`];t||i.push(`--no-ignore-vcs`);let a=(await Ye(i,`.`,e)).map(e=>E.relative(C(),e)),o=Date.now()-r;return v(`[FileIndex] ripgrep: ${a.length} files in ${o}ms`),x(`tengu_file_suggestions_ripgrep`,{file_count:a.length,duration_ms:o}),a}async function St(){let e=AbortSignal.timeout(1e4),t=F();try{let n=u(),r=d(),i=n.respectGitignore??r.respectGitignore??!0,a=C(),[o,s]=await Promise.all([xt(e,i),bt(a)]);W=s;let c=[...o,...s],l=await vt(c);G=l;let f=[...l,...c],p=ft(f);p===X?v(`[FileIndex] skipped index rebuild — tracked paths unchanged`):(await t.loadFromFileListAsync(f).done,X=p,Z=null)}catch(e){w(e)}return t}function Ct(e,t){let n=Math.min(e.length,t.length),r=0;for(;r<n&&e[r]===t[r];)r++;return e.substring(0,r)}function wt(e){if(e.length===0)return``;let t=e.map(e=>e.displayText),n=t[0];for(let e=1;e<t.length;e++){let r=t[e];if(n=Ct(n,r),n===``)return``}return n}function I(e,t){return{id:`file-${e}`,displayText:e,metadata:t===void 0?void 0:{score:t}}}function Tt(e,t){return e.search(t,Q).map(e=>I(e.path,e.score))}function L(){if(z)return;let e=pt();if(R&&!(e!==null&&e!==Y)&&Date.now()-J<jt)return;let t=V,n=Date.now();F(),z=St().then(r=>t===V?(z=null,B.emit(),Y=e,J=Date.now(),v(`[FileIndex] cache refresh completed in ${Date.now()-n}ms`),r):r).catch(e=>(v(`[FileIndex] Cache refresh failed: ${y(e)}`),w(e),t===V&&(z=null),F()))}async function Et(){let e=g(),t=C();try{return(await e.readdir(t)).map(e=>{let n=E.join(t,e.name),r=E.relative(t,n);return e.isDirectory()?r+E.sep:r})}catch(e){return w(e),[]}}async function Dt(e,t=!1){if(!e&&!t)return[];if(u().fileSuggestion?.type===`command`)return(await De({...xe(),query:e})).slice(0,Q).map(I);if(e===``||e===`.`||e===`./`){let e=await Et();return L(),e.slice(0,Q).map(I)}let n=Date.now();try{let t=z!==null;L();let r=e,i=`.`+E.sep;e.startsWith(i)&&(r=e.substring(2)),r.startsWith(`~`)&&(r=se(r));let a=R?Tt(R,r):[],o=Date.now()-n;return v(`[FileIndex] generateFileSuggestions: ${a.length} results in ${o}ms (${t?`partial`:`full`} index)`),x(`tengu_file_suggestions_query`,{duration_ms:o,cache_hit:!t,result_count:a.length,query_length:e.length}),a}catch(e){return w(e),[]}}function Ot(e,t,n,r,i,a){let o=typeof e==`string`?e:e.displayText;i(t.substring(0,r)+o+t.substring(r+n.length)),a(r+o.length)}var kt,R,z,B,At,V,H,U,W,G,K,q,J,Y,X,Z,Q,jt,$=e((()=>{kt=t(i(),1),Ne(),ut(),b(),p(),S(),_(),m(),ce(),h(),ie(),pe(),ae(),oe(),Je(),f(),a(),R=null,z=null,B=o(),At=B.subscribe,V=0,H=null,U=[],W=[],G=[],K=null,q=null,J=0,Y=null,X=null,Z=null,Q=15,jt=5e3}));function Mt(e=new Set){let t=e.size>0;Ee.cache.clear?.(),ve.cache.clear?.(),Oe.cache.clear?.(),qe.cache.clear?.(),dt(),he(),t||Be(),ge(null),s(null),fe(),ye(),ue(`session_start`),de(),Se(),t||je(),process.env.USER_TYPE===`ant`&&import(`./TungstenTool-B40YHYXC.js`).then(({clearSessionsWithTungstenUsage:e,resetInitializationState:t})=>{e(),t()}),import(`./attributionHooks-COqmxGy1.js`).then(({clearAttributionCaches:e})=>e()),Ze(),Ae(),t||Ue(),l(e),te(),_e(),Ve(),$e(),Ie(),import(`./utils-DP3EtI6F.js`).then(({clearWebFetchCache:e})=>e()),import(`./SearchExtraToolsTool-wDSdfnRo.js`).then(({clearSearchExtraToolsDescriptionCache:e})=>e()),import(`./loadAgentsDir-tPgCg0WD.js`).then(({clearAgentDefinitionsCache:e})=>e()),import(`./prompt-CrNwH5kr.js`).then(({clearPromptCache:e})=>e())}var Nt=e((()=>{c(),ze(),Ke(),ke(),$(),le(),He(),Pe(),Ce(),Ge(),be(),Qe(),Me(),me(),we(),Te(),Xe(),ee(),Le(),Fe()}));export{Dt as a,L as c,wt as i,Nt as n,$ as o,Ot as r,At as s,Mt as t};
3
+ `).filter(Boolean),i,r),n=await gt(i,r);if(n&&t.length>0){let e=t.length;t=n.filter(t),v(`[FileIndex] applied ignore patterns to untracked: ${e} -> ${t.length} files`)}v(`[FileIndex] background untracked fetch: ${t.length} files`),ht(t)}}).catch(e=>{v(`[FileIndex] background untracked fetch failed: ${e}`)}).finally(()=>{H=null})}return s}catch(e){return v(`[FileIndex] git ls-files error: ${y(e)}`),null}}async function vt(e){let t=new Set,n=performance.now();for(let r=0;r<e.length;r++)yt(e,r,r+1,t),(r&255)==255&&performance.now()-n>4&&(await O(),n=performance.now());return[...t].map(e=>e+E.sep)}function yt(e,t,n,r){for(let i=t;i<n;i++){let t=E.dirname(e[i]);for(;t!==`.`&&!r.has(t);){let e=E.dirname(t);if(e===t)break;r.add(t),t=e}}}async function bt(e){return(await Promise.all(Re.map(t=>We(t,e)))).flatMap(e=>e.map(e=>e.filePath))}async function xt(e,t){v(`[FileIndex] getProjectFiles called, respectGitignore=${t}`);let n=await _t(e,t);if(n!==null)return v(`[FileIndex] using git ls-files result (${n.length} files)`),n;v(`[FileIndex] git ls-files returned null, falling back to ripgrep`);let r=Date.now(),i=[`--files`,`--follow`,`--hidden`,`--glob`,`!.git/`,`--glob`,`!.svn/`,`--glob`,`!.hg/`,`--glob`,`!.bzr/`,`--glob`,`!.jj/`,`--glob`,`!.sl/`];t||i.push(`--no-ignore-vcs`);let a=(await Ye(i,`.`,e)).map(e=>E.relative(C(),e)),o=Date.now()-r;return v(`[FileIndex] ripgrep: ${a.length} files in ${o}ms`),x(`tengu_file_suggestions_ripgrep`,{file_count:a.length,duration_ms:o}),a}async function St(){let e=AbortSignal.timeout(1e4),t=F();try{let n=u(),r=d(),i=n.respectGitignore??r.respectGitignore??!0,a=C(),[o,s]=await Promise.all([xt(e,i),bt(a)]);W=s;let c=[...o,...s],l=await vt(c);G=l;let f=[...l,...c],p=ft(f);p===X?v(`[FileIndex] skipped index rebuild — tracked paths unchanged`):(await t.loadFromFileListAsync(f).done,X=p,Z=null)}catch(e){w(e)}return t}function Ct(e,t){let n=Math.min(e.length,t.length),r=0;for(;r<n&&e[r]===t[r];)r++;return e.substring(0,r)}function wt(e){if(e.length===0)return``;let t=e.map(e=>e.displayText),n=t[0];for(let e=1;e<t.length;e++){let r=t[e];if(n=Ct(n,r),n===``)return``}return n}function I(e,t){return{id:`file-${e}`,displayText:e,metadata:t===void 0?void 0:{score:t}}}function Tt(e,t){return e.search(t,Q).map(e=>I(e.path,e.score))}function L(){if(z)return;let e=pt();if(R&&!(e!==null&&e!==Y)&&Date.now()-J<jt)return;let t=V,n=Date.now();F(),z=St().then(r=>t===V?(z=null,B.emit(),Y=e,J=Date.now(),v(`[FileIndex] cache refresh completed in ${Date.now()-n}ms`),r):r).catch(e=>(v(`[FileIndex] Cache refresh failed: ${y(e)}`),w(e),t===V&&(z=null),F()))}async function Et(){let e=g(),t=C();try{return(await e.readdir(t)).map(e=>{let n=E.join(t,e.name),r=E.relative(t,n);return e.isDirectory()?r+E.sep:r})}catch(e){return w(e),[]}}async function Dt(e,t=!1){if(!e&&!t)return[];if(u().fileSuggestion?.type===`command`)return(await De({...xe(),query:e})).slice(0,Q).map(I);if(e===``||e===`.`||e===`./`){let e=await Et();return L(),e.slice(0,Q).map(I)}let n=Date.now();try{let t=z!==null;L();let r=e,i=`.`+E.sep;e.startsWith(i)&&(r=e.substring(2)),r.startsWith(`~`)&&(r=se(r));let a=R?Tt(R,r):[],o=Date.now()-n;return v(`[FileIndex] generateFileSuggestions: ${a.length} results in ${o}ms (${t?`partial`:`full`} index)`),x(`tengu_file_suggestions_query`,{duration_ms:o,cache_hit:!t,result_count:a.length,query_length:e.length}),a}catch(e){return w(e),[]}}function Ot(e,t,n,r,i,a){let o=typeof e==`string`?e:e.displayText;i(t.substring(0,r)+o+t.substring(r+n.length)),a(r+o.length)}var kt,R,z,B,At,V,H,U,W,G,K,q,J,Y,X,Z,Q,jt,$=e((()=>{kt=t(i(),1),Ne(),ut(),b(),p(),S(),_(),m(),ce(),h(),ie(),pe(),ae(),oe(),Je(),f(),a(),R=null,z=null,B=o(),At=B.subscribe,V=0,H=null,U=[],W=[],G=[],K=null,q=null,J=0,Y=null,X=null,Z=null,Q=15,jt=5e3}));function Mt(e=new Set){let t=e.size>0;Ee.cache.clear?.(),ve.cache.clear?.(),Oe.cache.clear?.(),qe.cache.clear?.(),dt(),he(),t||Be(),ge(null),s(null),fe(),ye(),ue(`session_start`),de(),Se(),t||je(),process.env.USER_TYPE===`ant`&&import(`./TungstenTool-B40YHYXC.js`).then(({clearSessionsWithTungstenUsage:e,resetInitializationState:t})=>{e(),t()}),import(`./attributionHooks-COqmxGy1.js`).then(({clearAttributionCaches:e})=>e()),Ze(),Ae(),t||Ue(),l(e),te(),_e(),Ve(),$e(),Ie(),import(`./utils-CULcnflj.js`).then(({clearWebFetchCache:e})=>e()),import(`./SearchExtraToolsTool-DVi-ggud.js`).then(({clearSearchExtraToolsDescriptionCache:e})=>e()),import(`./loadAgentsDir-CjhNkoq0.js`).then(({clearAgentDefinitionsCache:e})=>e()),import(`./prompt-DZ1EAUlC.js`).then(({clearPromptCache:e})=>e())}var Nt=e((()=>{c(),ze(),Ke(),ke(),$(),le(),He(),Pe(),Ce(),Ge(),be(),Qe(),Me(),me(),we(),Te(),Xe(),ee(),Le(),Fe()}));export{Dt as a,L as c,wt as i,Nt as n,$ as o,Ot as r,At as s,Mt as t};
@@ -1 +1 @@
1
- import{n as e,t}from"./defineProperty-80gRi2ZW.js";import{At as n,jt as r}from"./paths-BZjPDxMm.js";import{B as i,E as a,O as o,U as s,l as c,p as l,z as u}from"./debug-otxXY3j-.js";import{F as d,P as f}from"./git-C0IuvuIy.js";import{r as p,u as m}from"./proxy-CF7ZDxaW.js";import{n as h,t as g}from"./sleep-C6koP5Ka.js";import{D as _,E as v,O as y,a as b,l as x,r as S}from"./rcDebugLog-ClX1msJX.js";import{n as C}from"./jwtUtils-BQXXBwqW.js";import{randomUUID as w}from"crypto";s(),c(),f(),m(),g(),r(),y(),S(),a(),e();var T=class extends Error{constructor(e,t){super(e),this.retryAfterMs=t}},E=class{constructor(e){t(this,`pending`,[]),t(this,`pendingAtClose`,0),t(this,`draining`,!1),t(this,`closed`,!1),t(this,`backpressureResolvers`,[]),t(this,`sleepResolve`,null),t(this,`flushResolvers`,[]),t(this,`droppedBatches`,0),t(this,`config`,void 0),this.config=e}get droppedBatchCount(){return this.droppedBatches}get pendingCount(){return this.closed?this.pendingAtClose:this.pending.length}async enqueue(e){if(this.closed)return;let t=Array.isArray(e)?e:[e];if(t.length!==0){for(;this.pending.length+t.length>this.config.maxQueueSize&&!this.closed;)await new Promise(e=>{this.backpressureResolvers.push(e)});this.closed||(this.pending.push(...t),this.drain())}}flush(){return this.pending.length===0&&!this.draining?Promise.resolve():(this.drain(),new Promise(e=>{this.flushResolvers.push(e)}))}close(){if(!this.closed){this.closed=!0,this.pendingAtClose=this.pending.length,this.pending=[],this.sleepResolve?.(),this.sleepResolve=null;for(let e of this.backpressureResolvers)e();this.backpressureResolvers=[];for(let e of this.flushResolvers)e();this.flushResolvers=[]}}async drain(){if(this.draining||this.closed)return;this.draining=!0;let e=0;try{for(;this.pending.length>0&&!this.closed;){let t=this.takeBatch();if(t.length!==0){try{await this.config.send(t),e=0}catch(n){if(e++,this.config.maxConsecutiveFailures!==void 0&&e>=this.config.maxConsecutiveFailures){this.droppedBatches++,this.config.onBatchDropped?.(t.length,e),e=0,this.releaseBackpressure();continue}this.pending=t.concat(this.pending);let r=n instanceof T?n.retryAfterMs:void 0;await this.sleep(this.retryDelay(e,r));continue}this.releaseBackpressure()}}}finally{if(this.draining=!1,this.pending.length===0){for(let e of this.flushResolvers)e();this.flushResolvers=[]}}}takeBatch(){let{maxBatchSize:e,maxBatchBytes:t}=this.config;if(t===void 0)return this.pending.splice(0,e);let n=0,r=0;for(;r<this.pending.length&&r<e;){let e;try{e=Buffer.byteLength(o(this.pending[r]))}catch{this.pending.splice(r,1);continue}if(r>0&&n+e>t)break;n+=e,r++}return this.pending.splice(0,r)}retryDelay(e,t){let n=Math.random()*this.config.jitterMs;return t===void 0?Math.min(this.config.baseDelayMs*2**(e-1),this.config.maxDelayMs)+n:Math.max(this.config.baseDelayMs,Math.min(t,this.config.maxDelayMs))+n}releaseBackpressure(){let e=this.backpressureResolvers;this.backpressureResolvers=[];for(let t of e)t()}sleep(e){return new Promise(t=>{this.sleepResolve=t,setTimeout((e,t)=>{e.sleepResolve=null,t()},e,this,t)})}};e();var D=class{constructor(e){t(this,`inflight`,null),t(this,`pending`,null),t(this,`closed`,!1),t(this,`config`,void 0),this.config=e}enqueue(e){this.closed||(this.pending=this.pending?O(this.pending,e):e,this.drain())}close(){this.closed=!0,this.pending=null}async drain(){if(this.inflight||this.closed||!this.pending)return;let e=this.pending;this.pending=null,this.inflight=this.sendWithRetry(e).then(()=>{this.inflight=null,this.pending&&!this.closed&&this.drain()})}async sendWithRetry(e){let t=e,n=0;for(;!this.closed;){if(await this.config.send(t))return;n++,await h(this.retryDelay(n)),this.pending&&!this.closed&&(t=O(t,this.pending),this.pending=null)}}retryDelay(e){return Math.min(this.config.baseDelayMs*2**(e-1),this.config.maxDelayMs)+Math.random()*this.config.jitterMs}};function O(e,t){let n={...e};for(let[e,r]of Object.entries(t))(e===`external_metadata`||e===`internal_metadata`)&&n[e]&&typeof n[e]==`object`&&typeof r==`object`&&r?n[e]={...n[e],...r}:n[e]=r;return n}g(),e();var k=2e4,A=100;function j(){return!0}var M=class extends Error{constructor(e){super(`CCRClient init failed: ${e}`),this.reason=e}},N=10;function P(){return{byMessage:new Map,scopeToMessage:new Map}}function F(e){return`${e.session_id}:${e.parent_tool_use_id??``}`}function I(e,t){let n=[],r=new Map;for(let i of e){let e=i.event;switch(e.type){case`message_start`:{let r=e.message.id,a=t.scopeToMessage.get(F(i));a&&t.byMessage.delete(a),t.scopeToMessage.set(F(i),r),t.byMessage.set(r,[]),n.push(i);break}case`content_block_delta`:{let a=e.delta;if(a.type!==`text_delta`){n.push(i);break}let o=t.scopeToMessage.get(F(i)),s=o?t.byMessage.get(o):void 0;if(!s){n.push(i);break}let c=e.index,l=s[c]??(s[c]=[]);l.push(a.text);let u=r.get(l);if(u){u.event.delta={type:`text_delta`,text:l.join(``)};break}let d={type:`stream_event`,uuid:i.uuid,session_id:i.session_id,parent_tool_use_id:i.parent_tool_use_id,event:{type:`content_block_delta`,index:c,delta:{type:`text_delta`,text:l.join(``)}}};r.set(l,d),n.push(d);break}default:n.push(i)}}return n}function L(e,t){e.byMessage.delete(t.message.id);let n=F(t);e.scopeToMessage.get(n)===t.message.id&&e.scopeToMessage.delete(n)}var R=class{constructor(e,n,r){if(t(this,`workerEpoch`,0),t(this,`heartbeatIntervalMs`,void 0),t(this,`heartbeatJitterFraction`,void 0),t(this,`heartbeatTimer`,null),t(this,`heartbeatInFlight`,!1),t(this,`closed`,!1),t(this,`consecutiveAuthFailures`,0),t(this,`currentState`,null),t(this,`sessionBaseUrl`,void 0),t(this,`sessionId`,void 0),t(this,`http`,p({keepAlive:!0})),t(this,`streamEventBuffer`,[]),t(this,`streamEventTimer`,null),t(this,`streamTextAccumulator`,P()),t(this,`workerState`,void 0),t(this,`eventUploader`,void 0),t(this,`internalEventUploader`,void 0),t(this,`deliveryUploader`,void 0),t(this,`onEpochMismatch`,void 0),t(this,`getAuthHeaders`,void 0),this.onEpochMismatch=r?.onEpochMismatch??(()=>{process.exit(1)}),this.heartbeatIntervalMs=r?.heartbeatIntervalMs??k,this.heartbeatJitterFraction=r?.heartbeatJitterFraction??0,this.getAuthHeaders=r?.getAuthHeaders??v,n.protocol!==`http:`&&n.protocol!==`https:`)throw Error(`CCRClient: Expected http(s) URL, got ${n.protocol}`);let i=n.pathname.replace(/\/$/,``);this.sessionBaseUrl=`${n.protocol}//${n.host}${i}`,this.sessionId=i.split(`/`).pop()||``,this.workerState=new D({send:e=>this.request(`put`,`/worker`,{worker_epoch:this.workerEpoch,...e},`PUT worker`).then(e=>e.ok),baseDelayMs:500,maxDelayMs:3e4,jitterMs:500}),this.eventUploader=new E({maxBatchSize:100,maxBatchBytes:10*1024*1024,maxQueueSize:1e5,send:async e=>{let t=await this.request(`post`,`/worker/events`,{worker_epoch:this.workerEpoch,events:e},`client events`);if(!t.ok)throw new T(`client event POST failed`,t.retryAfterMs)},baseDelayMs:500,maxDelayMs:3e4,jitterMs:500}),this.internalEventUploader=new E({maxBatchSize:100,maxBatchBytes:10*1024*1024,maxQueueSize:200,send:async e=>{let t=await this.request(`post`,`/worker/internal-events`,{worker_epoch:this.workerEpoch,events:e},`internal events`);if(!t.ok)throw new T(`internal event POST failed`,t.retryAfterMs)},baseDelayMs:500,maxDelayMs:3e4,jitterMs:500}),this.deliveryUploader=new E({maxBatchSize:64,maxQueueSize:64,send:async e=>{let t=await this.request(`post`,`/worker/events/delivery`,{worker_epoch:this.workerEpoch,updates:e.map(e=>({event_id:e.eventId,status:e.status}))},`delivery batch`);if(!t.ok)throw new T(`delivery POST failed`,t.retryAfterMs)},baseDelayMs:500,maxDelayMs:3e4,jitterMs:500}),e.setOnEvent(e=>{this.reportDelivery(e.event_id,`received`)})}async initialize(e){let t=Date.now();if(Object.keys(this.getAuthHeaders()).length===0)throw new M(`no_auth_headers`);if(e===void 0){let t=process.env.CLAUDE_CODE_WORKER_EPOCH;e=t?parseInt(t,10):NaN}if(isNaN(e))throw new M(`missing_epoch`);this.workerEpoch=e;let n=this.getWorkerState();if(!(await this.request(`put`,`/worker`,{worker_status:`idle`,worker_epoch:this.workerEpoch,external_metadata:{pending_action:null,task_summary:null,automation_state:null}},`PUT worker (init)`)).ok)throw new M(`worker_register_failed`);this.currentState=`idle`,this.startHeartbeat(),b(()=>{this.writeEvent({type:`keep_alive`})}),l(`CCRClient: initialized, epoch=${this.workerEpoch}`),d(`info`,`cli_worker_lifecycle_initialized`,{epoch:this.workerEpoch,duration_ms:Date.now()-t});let{metadata:r,durationMs:i}=await n;return this.closed||d(`info`,`cli_worker_state_restored`,{duration_ms:i,had_state:r!==null}),r}async getWorkerState(){let e=Date.now(),t=this.getAuthHeaders();return Object.keys(t).length===0?{metadata:null,durationMs:0}:{metadata:(await this.getWithRetry(`${this.sessionBaseUrl}/worker`,t,`worker_state`))?.worker?.external_metadata??null,durationMs:Date.now()-e}}async request(e,t,r,a,{timeout:o=1e4}={}){let s=this.getAuthHeaders();if(Object.keys(s).length===0)return{ok:!1};try{let i=await this.http[e](`${this.sessionBaseUrl}${t}`,r,{headers:{...s,"Content-Type":`application/json`,"anthropic-version":`2023-06-01`,"User-Agent":n()},validateStatus:j,timeout:o});if(i.status>=200&&i.status<300)return this.consecutiveAuthFailures=0,{ok:!0};if(i.status===409&&this.handleEpochMismatch(),i.status===401||i.status===403){let e=_(),t=e?C(e):null;t!==null&&t*1e3<Date.now()&&(l(`CCRClient: session_token expired (exp=${new Date(t*1e3).toISOString()}) — no refresh was delivered, exiting`,{level:`error`}),d(`error`,`cli_worker_token_expired_no_refresh`),this.onEpochMismatch()),this.consecutiveAuthFailures++,this.consecutiveAuthFailures>=N&&(l(`CCRClient: ${this.consecutiveAuthFailures} consecutive auth failures with a valid-looking token — server-side auth unrecoverable, exiting`,{level:`error`}),d(`error`,`cli_worker_auth_failures_exhausted`),this.onEpochMismatch())}if(l(`CCRClient: ${a} returned ${i.status}`,{level:`warn`}),d(`warn`,`cli_worker_request_failed`,{method:e,path:t,status:i.status}),i.status===429){let e=i.headers?.[`retry-after`],t=typeof e==`string`?parseInt(e,10):NaN;if(!isNaN(t)&&t>=0)return{ok:!1,retryAfterMs:t*1e3}}return{ok:!1}}catch(n){return l(`CCRClient: ${a} failed: ${u(n)}`,{level:`warn`}),d(`warn`,`cli_worker_request_error`,{method:e,path:t,error_code:i(n)}),{ok:!1}}}reportState(e,t){e===this.currentState&&!t||(this.currentState=e,this.workerState.enqueue({worker_status:e,requires_action_details:t?{tool_name:t.tool_name,action_description:t.action_description,request_id:t.request_id}:null}))}reportMetadata(e){this.workerState.enqueue({external_metadata:e})}handleEpochMismatch(){l(`CCRClient: Epoch mismatch (409), shutting down`,{level:`error`}),d(`error`,`cli_worker_epoch_mismatch`),this.onEpochMismatch()}startHeartbeat(){this.stopHeartbeat();let e=()=>{let e=this.heartbeatIntervalMs*this.heartbeatJitterFraction*(2*Math.random()-1);this.heartbeatTimer=setTimeout(t,this.heartbeatIntervalMs+e)},t=()=>{this.sendHeartbeat(),this.heartbeatTimer!==null&&e()};e()}stopHeartbeat(){this.heartbeatTimer&&(clearTimeout(this.heartbeatTimer),this.heartbeatTimer=null)}async sendHeartbeat(){if(!this.heartbeatInFlight){this.heartbeatInFlight=!0;try{(await this.request(`post`,`/worker/heartbeat`,{session_id:this.sessionId,worker_epoch:this.workerEpoch},`Heartbeat`,{timeout:5e3})).ok&&l(`CCRClient: Heartbeat sent`)}finally{this.heartbeatInFlight=!1}}}async writeEvent(e){if(e.type===`stream_event`){this.streamEventBuffer.push(e),this.streamEventTimer||(this.streamEventTimer=setTimeout(()=>void this.flushStreamEventBuffer(),A));return}await this.flushStreamEventBuffer(),e.type===`assistant`&&L(this.streamTextAccumulator,e),await this.eventUploader.enqueue(this.toClientEvent(e))}toClientEvent(e){let t=e;return{payload:{...t,uuid:typeof t.uuid==`string`?t.uuid:w()}}}async flushStreamEventBuffer(){if(this.streamEventTimer&&(clearTimeout(this.streamEventTimer),this.streamEventTimer=null),this.streamEventBuffer.length===0)return;let e=this.streamEventBuffer;this.streamEventBuffer=[];let t=I(e,this.streamTextAccumulator);await this.eventUploader.enqueue(t.map(e=>({payload:e,ephemeral:!0})))}async writeInternalEvent(e,t,{isCompaction:n=!1,agentId:r}={}){let i={payload:{type:e,...t,uuid:typeof t.uuid==`string`?t.uuid:w()},...n&&{is_compaction:!0},...r&&{agent_id:r}};await this.internalEventUploader.enqueue(i)}flushInternalEvents(){return this.internalEventUploader.flush()}async flush(){return await this.flushStreamEventBuffer(),this.eventUploader.flush()}async readInternalEvents(){return this.paginatedGet(`/worker/internal-events`,{},`internal_events`)}async readSubagentInternalEvents(){return this.paginatedGet(`/worker/internal-events`,{subagents:`true`},`subagent_events`)}async paginatedGet(e,t,n){let r=this.getAuthHeaders();if(Object.keys(r).length===0)return null;let i=[],a;do{let o=new URL(`${this.sessionBaseUrl}${e}`);for(let[e,n]of Object.entries(t))o.searchParams.set(e,n);a&&o.searchParams.set(`cursor`,a);let s=await this.getWithRetry(o.toString(),r,n);if(!s)return null;i.push(...s.data??[]),a=s.next_cursor}while(a);return l(`CCRClient: Read ${i.length} internal events from ${e}${t.subagents?` (subagents)`:``}`),i}async getWithRetry(e,t,r){for(let r=1;r<=10;r++){let i;try{i=await this.http.get(e,{headers:{...t,"anthropic-version":`2023-06-01`,"User-Agent":n()},validateStatus:j,timeout:3e4})}catch(t){l(`CCRClient: GET ${e} failed (attempt ${r}/10): ${u(t)}`,{level:`warn`}),r<10&&await h(Math.min(500*2**(r-1),3e4)+Math.random()*500);continue}if(i.status>=200&&i.status<300)return i.data;i.status===409&&this.handleEpochMismatch(),l(`CCRClient: GET ${e} returned ${i.status} (attempt ${r}/10)`,{level:`warn`}),r<10&&await h(Math.min(500*2**(r-1),3e4)+Math.random()*500)}return l(`CCRClient: GET retries exhausted`,{level:`error`}),d(`error`,`cli_worker_get_retries_exhausted`,{context:r}),null}reportDelivery(e,t){this.deliveryUploader.enqueue({eventId:e,status:t})}getWorkerEpoch(){return this.workerEpoch}get internalEventsPending(){return this.internalEventUploader.pendingCount}close(){this.closed=!0,this.stopHeartbeat(),x(),this.streamEventTimer&&(clearTimeout(this.streamEventTimer),this.streamEventTimer=null),this.streamEventBuffer=[],this.streamTextAccumulator.byMessage.clear(),this.streamTextAccumulator.scopeToMessage.clear(),this.workerState.close(),this.eventUploader.close(),this.internalEventUploader.close(),this.deliveryUploader.close()}};export{M as n,E as r,R as t};
1
+ import{n as e,t}from"./defineProperty-80gRi2ZW.js";import{At as n,jt as r}from"./paths-CEAy4QCs.js";import{B as i,E as a,O as o,U as s,l as c,p as l,z as u}from"./debug-otxXY3j-.js";import{F as d,P as f}from"./git-C0IuvuIy.js";import{r as p,u as m}from"./proxy-CF7ZDxaW.js";import{n as h,t as g}from"./sleep-C6koP5Ka.js";import{D as _,E as v,O as y,a as b,l as x,r as S}from"./rcDebugLog-C0Bam8V9.js";import{n as C}from"./jwtUtils-BQXXBwqW.js";import{randomUUID as w}from"crypto";s(),c(),f(),m(),g(),r(),y(),S(),a(),e();var T=class extends Error{constructor(e,t){super(e),this.retryAfterMs=t}},E=class{constructor(e){t(this,`pending`,[]),t(this,`pendingAtClose`,0),t(this,`draining`,!1),t(this,`closed`,!1),t(this,`backpressureResolvers`,[]),t(this,`sleepResolve`,null),t(this,`flushResolvers`,[]),t(this,`droppedBatches`,0),t(this,`config`,void 0),this.config=e}get droppedBatchCount(){return this.droppedBatches}get pendingCount(){return this.closed?this.pendingAtClose:this.pending.length}async enqueue(e){if(this.closed)return;let t=Array.isArray(e)?e:[e];if(t.length!==0){for(;this.pending.length+t.length>this.config.maxQueueSize&&!this.closed;)await new Promise(e=>{this.backpressureResolvers.push(e)});this.closed||(this.pending.push(...t),this.drain())}}flush(){return this.pending.length===0&&!this.draining?Promise.resolve():(this.drain(),new Promise(e=>{this.flushResolvers.push(e)}))}close(){if(!this.closed){this.closed=!0,this.pendingAtClose=this.pending.length,this.pending=[],this.sleepResolve?.(),this.sleepResolve=null;for(let e of this.backpressureResolvers)e();this.backpressureResolvers=[];for(let e of this.flushResolvers)e();this.flushResolvers=[]}}async drain(){if(this.draining||this.closed)return;this.draining=!0;let e=0;try{for(;this.pending.length>0&&!this.closed;){let t=this.takeBatch();if(t.length!==0){try{await this.config.send(t),e=0}catch(n){if(e++,this.config.maxConsecutiveFailures!==void 0&&e>=this.config.maxConsecutiveFailures){this.droppedBatches++,this.config.onBatchDropped?.(t.length,e),e=0,this.releaseBackpressure();continue}this.pending=t.concat(this.pending);let r=n instanceof T?n.retryAfterMs:void 0;await this.sleep(this.retryDelay(e,r));continue}this.releaseBackpressure()}}}finally{if(this.draining=!1,this.pending.length===0){for(let e of this.flushResolvers)e();this.flushResolvers=[]}}}takeBatch(){let{maxBatchSize:e,maxBatchBytes:t}=this.config;if(t===void 0)return this.pending.splice(0,e);let n=0,r=0;for(;r<this.pending.length&&r<e;){let e;try{e=Buffer.byteLength(o(this.pending[r]))}catch{this.pending.splice(r,1);continue}if(r>0&&n+e>t)break;n+=e,r++}return this.pending.splice(0,r)}retryDelay(e,t){let n=Math.random()*this.config.jitterMs;return t===void 0?Math.min(this.config.baseDelayMs*2**(e-1),this.config.maxDelayMs)+n:Math.max(this.config.baseDelayMs,Math.min(t,this.config.maxDelayMs))+n}releaseBackpressure(){let e=this.backpressureResolvers;this.backpressureResolvers=[];for(let t of e)t()}sleep(e){return new Promise(t=>{this.sleepResolve=t,setTimeout((e,t)=>{e.sleepResolve=null,t()},e,this,t)})}};e();var D=class{constructor(e){t(this,`inflight`,null),t(this,`pending`,null),t(this,`closed`,!1),t(this,`config`,void 0),this.config=e}enqueue(e){this.closed||(this.pending=this.pending?O(this.pending,e):e,this.drain())}close(){this.closed=!0,this.pending=null}async drain(){if(this.inflight||this.closed||!this.pending)return;let e=this.pending;this.pending=null,this.inflight=this.sendWithRetry(e).then(()=>{this.inflight=null,this.pending&&!this.closed&&this.drain()})}async sendWithRetry(e){let t=e,n=0;for(;!this.closed;){if(await this.config.send(t))return;n++,await h(this.retryDelay(n)),this.pending&&!this.closed&&(t=O(t,this.pending),this.pending=null)}}retryDelay(e){return Math.min(this.config.baseDelayMs*2**(e-1),this.config.maxDelayMs)+Math.random()*this.config.jitterMs}};function O(e,t){let n={...e};for(let[e,r]of Object.entries(t))(e===`external_metadata`||e===`internal_metadata`)&&n[e]&&typeof n[e]==`object`&&typeof r==`object`&&r?n[e]={...n[e],...r}:n[e]=r;return n}g(),e();var k=2e4,A=100;function j(){return!0}var M=class extends Error{constructor(e){super(`CCRClient init failed: ${e}`),this.reason=e}},N=10;function P(){return{byMessage:new Map,scopeToMessage:new Map}}function F(e){return`${e.session_id}:${e.parent_tool_use_id??``}`}function I(e,t){let n=[],r=new Map;for(let i of e){let e=i.event;switch(e.type){case`message_start`:{let r=e.message.id,a=t.scopeToMessage.get(F(i));a&&t.byMessage.delete(a),t.scopeToMessage.set(F(i),r),t.byMessage.set(r,[]),n.push(i);break}case`content_block_delta`:{let a=e.delta;if(a.type!==`text_delta`){n.push(i);break}let o=t.scopeToMessage.get(F(i)),s=o?t.byMessage.get(o):void 0;if(!s){n.push(i);break}let c=e.index,l=s[c]??(s[c]=[]);l.push(a.text);let u=r.get(l);if(u){u.event.delta={type:`text_delta`,text:l.join(``)};break}let d={type:`stream_event`,uuid:i.uuid,session_id:i.session_id,parent_tool_use_id:i.parent_tool_use_id,event:{type:`content_block_delta`,index:c,delta:{type:`text_delta`,text:l.join(``)}}};r.set(l,d),n.push(d);break}default:n.push(i)}}return n}function L(e,t){e.byMessage.delete(t.message.id);let n=F(t);e.scopeToMessage.get(n)===t.message.id&&e.scopeToMessage.delete(n)}var R=class{constructor(e,n,r){if(t(this,`workerEpoch`,0),t(this,`heartbeatIntervalMs`,void 0),t(this,`heartbeatJitterFraction`,void 0),t(this,`heartbeatTimer`,null),t(this,`heartbeatInFlight`,!1),t(this,`closed`,!1),t(this,`consecutiveAuthFailures`,0),t(this,`currentState`,null),t(this,`sessionBaseUrl`,void 0),t(this,`sessionId`,void 0),t(this,`http`,p({keepAlive:!0})),t(this,`streamEventBuffer`,[]),t(this,`streamEventTimer`,null),t(this,`streamTextAccumulator`,P()),t(this,`workerState`,void 0),t(this,`eventUploader`,void 0),t(this,`internalEventUploader`,void 0),t(this,`deliveryUploader`,void 0),t(this,`onEpochMismatch`,void 0),t(this,`getAuthHeaders`,void 0),this.onEpochMismatch=r?.onEpochMismatch??(()=>{process.exit(1)}),this.heartbeatIntervalMs=r?.heartbeatIntervalMs??k,this.heartbeatJitterFraction=r?.heartbeatJitterFraction??0,this.getAuthHeaders=r?.getAuthHeaders??v,n.protocol!==`http:`&&n.protocol!==`https:`)throw Error(`CCRClient: Expected http(s) URL, got ${n.protocol}`);let i=n.pathname.replace(/\/$/,``);this.sessionBaseUrl=`${n.protocol}//${n.host}${i}`,this.sessionId=i.split(`/`).pop()||``,this.workerState=new D({send:e=>this.request(`put`,`/worker`,{worker_epoch:this.workerEpoch,...e},`PUT worker`).then(e=>e.ok),baseDelayMs:500,maxDelayMs:3e4,jitterMs:500}),this.eventUploader=new E({maxBatchSize:100,maxBatchBytes:10*1024*1024,maxQueueSize:1e5,send:async e=>{let t=await this.request(`post`,`/worker/events`,{worker_epoch:this.workerEpoch,events:e},`client events`);if(!t.ok)throw new T(`client event POST failed`,t.retryAfterMs)},baseDelayMs:500,maxDelayMs:3e4,jitterMs:500}),this.internalEventUploader=new E({maxBatchSize:100,maxBatchBytes:10*1024*1024,maxQueueSize:200,send:async e=>{let t=await this.request(`post`,`/worker/internal-events`,{worker_epoch:this.workerEpoch,events:e},`internal events`);if(!t.ok)throw new T(`internal event POST failed`,t.retryAfterMs)},baseDelayMs:500,maxDelayMs:3e4,jitterMs:500}),this.deliveryUploader=new E({maxBatchSize:64,maxQueueSize:64,send:async e=>{let t=await this.request(`post`,`/worker/events/delivery`,{worker_epoch:this.workerEpoch,updates:e.map(e=>({event_id:e.eventId,status:e.status}))},`delivery batch`);if(!t.ok)throw new T(`delivery POST failed`,t.retryAfterMs)},baseDelayMs:500,maxDelayMs:3e4,jitterMs:500}),e.setOnEvent(e=>{this.reportDelivery(e.event_id,`received`)})}async initialize(e){let t=Date.now();if(Object.keys(this.getAuthHeaders()).length===0)throw new M(`no_auth_headers`);if(e===void 0){let t=process.env.CLAUDE_CODE_WORKER_EPOCH;e=t?parseInt(t,10):NaN}if(isNaN(e))throw new M(`missing_epoch`);this.workerEpoch=e;let n=this.getWorkerState();if(!(await this.request(`put`,`/worker`,{worker_status:`idle`,worker_epoch:this.workerEpoch,external_metadata:{pending_action:null,task_summary:null,automation_state:null}},`PUT worker (init)`)).ok)throw new M(`worker_register_failed`);this.currentState=`idle`,this.startHeartbeat(),b(()=>{this.writeEvent({type:`keep_alive`})}),l(`CCRClient: initialized, epoch=${this.workerEpoch}`),d(`info`,`cli_worker_lifecycle_initialized`,{epoch:this.workerEpoch,duration_ms:Date.now()-t});let{metadata:r,durationMs:i}=await n;return this.closed||d(`info`,`cli_worker_state_restored`,{duration_ms:i,had_state:r!==null}),r}async getWorkerState(){let e=Date.now(),t=this.getAuthHeaders();return Object.keys(t).length===0?{metadata:null,durationMs:0}:{metadata:(await this.getWithRetry(`${this.sessionBaseUrl}/worker`,t,`worker_state`))?.worker?.external_metadata??null,durationMs:Date.now()-e}}async request(e,t,r,a,{timeout:o=1e4}={}){let s=this.getAuthHeaders();if(Object.keys(s).length===0)return{ok:!1};try{let i=await this.http[e](`${this.sessionBaseUrl}${t}`,r,{headers:{...s,"Content-Type":`application/json`,"anthropic-version":`2023-06-01`,"User-Agent":n()},validateStatus:j,timeout:o});if(i.status>=200&&i.status<300)return this.consecutiveAuthFailures=0,{ok:!0};if(i.status===409&&this.handleEpochMismatch(),i.status===401||i.status===403){let e=_(),t=e?C(e):null;t!==null&&t*1e3<Date.now()&&(l(`CCRClient: session_token expired (exp=${new Date(t*1e3).toISOString()}) — no refresh was delivered, exiting`,{level:`error`}),d(`error`,`cli_worker_token_expired_no_refresh`),this.onEpochMismatch()),this.consecutiveAuthFailures++,this.consecutiveAuthFailures>=N&&(l(`CCRClient: ${this.consecutiveAuthFailures} consecutive auth failures with a valid-looking token — server-side auth unrecoverable, exiting`,{level:`error`}),d(`error`,`cli_worker_auth_failures_exhausted`),this.onEpochMismatch())}if(l(`CCRClient: ${a} returned ${i.status}`,{level:`warn`}),d(`warn`,`cli_worker_request_failed`,{method:e,path:t,status:i.status}),i.status===429){let e=i.headers?.[`retry-after`],t=typeof e==`string`?parseInt(e,10):NaN;if(!isNaN(t)&&t>=0)return{ok:!1,retryAfterMs:t*1e3}}return{ok:!1}}catch(n){return l(`CCRClient: ${a} failed: ${u(n)}`,{level:`warn`}),d(`warn`,`cli_worker_request_error`,{method:e,path:t,error_code:i(n)}),{ok:!1}}}reportState(e,t){e===this.currentState&&!t||(this.currentState=e,this.workerState.enqueue({worker_status:e,requires_action_details:t?{tool_name:t.tool_name,action_description:t.action_description,request_id:t.request_id}:null}))}reportMetadata(e){this.workerState.enqueue({external_metadata:e})}handleEpochMismatch(){l(`CCRClient: Epoch mismatch (409), shutting down`,{level:`error`}),d(`error`,`cli_worker_epoch_mismatch`),this.onEpochMismatch()}startHeartbeat(){this.stopHeartbeat();let e=()=>{let e=this.heartbeatIntervalMs*this.heartbeatJitterFraction*(2*Math.random()-1);this.heartbeatTimer=setTimeout(t,this.heartbeatIntervalMs+e)},t=()=>{this.sendHeartbeat(),this.heartbeatTimer!==null&&e()};e()}stopHeartbeat(){this.heartbeatTimer&&(clearTimeout(this.heartbeatTimer),this.heartbeatTimer=null)}async sendHeartbeat(){if(!this.heartbeatInFlight){this.heartbeatInFlight=!0;try{(await this.request(`post`,`/worker/heartbeat`,{session_id:this.sessionId,worker_epoch:this.workerEpoch},`Heartbeat`,{timeout:5e3})).ok&&l(`CCRClient: Heartbeat sent`)}finally{this.heartbeatInFlight=!1}}}async writeEvent(e){if(e.type===`stream_event`){this.streamEventBuffer.push(e),this.streamEventTimer||(this.streamEventTimer=setTimeout(()=>void this.flushStreamEventBuffer(),A));return}await this.flushStreamEventBuffer(),e.type===`assistant`&&L(this.streamTextAccumulator,e),await this.eventUploader.enqueue(this.toClientEvent(e))}toClientEvent(e){let t=e;return{payload:{...t,uuid:typeof t.uuid==`string`?t.uuid:w()}}}async flushStreamEventBuffer(){if(this.streamEventTimer&&(clearTimeout(this.streamEventTimer),this.streamEventTimer=null),this.streamEventBuffer.length===0)return;let e=this.streamEventBuffer;this.streamEventBuffer=[];let t=I(e,this.streamTextAccumulator);await this.eventUploader.enqueue(t.map(e=>({payload:e,ephemeral:!0})))}async writeInternalEvent(e,t,{isCompaction:n=!1,agentId:r}={}){let i={payload:{type:e,...t,uuid:typeof t.uuid==`string`?t.uuid:w()},...n&&{is_compaction:!0},...r&&{agent_id:r}};await this.internalEventUploader.enqueue(i)}flushInternalEvents(){return this.internalEventUploader.flush()}async flush(){return await this.flushStreamEventBuffer(),this.eventUploader.flush()}async readInternalEvents(){return this.paginatedGet(`/worker/internal-events`,{},`internal_events`)}async readSubagentInternalEvents(){return this.paginatedGet(`/worker/internal-events`,{subagents:`true`},`subagent_events`)}async paginatedGet(e,t,n){let r=this.getAuthHeaders();if(Object.keys(r).length===0)return null;let i=[],a;do{let o=new URL(`${this.sessionBaseUrl}${e}`);for(let[e,n]of Object.entries(t))o.searchParams.set(e,n);a&&o.searchParams.set(`cursor`,a);let s=await this.getWithRetry(o.toString(),r,n);if(!s)return null;i.push(...s.data??[]),a=s.next_cursor}while(a);return l(`CCRClient: Read ${i.length} internal events from ${e}${t.subagents?` (subagents)`:``}`),i}async getWithRetry(e,t,r){for(let r=1;r<=10;r++){let i;try{i=await this.http.get(e,{headers:{...t,"anthropic-version":`2023-06-01`,"User-Agent":n()},validateStatus:j,timeout:3e4})}catch(t){l(`CCRClient: GET ${e} failed (attempt ${r}/10): ${u(t)}`,{level:`warn`}),r<10&&await h(Math.min(500*2**(r-1),3e4)+Math.random()*500);continue}if(i.status>=200&&i.status<300)return i.data;i.status===409&&this.handleEpochMismatch(),l(`CCRClient: GET ${e} returned ${i.status} (attempt ${r}/10)`,{level:`warn`}),r<10&&await h(Math.min(500*2**(r-1),3e4)+Math.random()*500)}return l(`CCRClient: GET retries exhausted`,{level:`error`}),d(`error`,`cli_worker_get_retries_exhausted`,{context:r}),null}reportDelivery(e,t){this.deliveryUploader.enqueue({eventId:e,status:t})}getWorkerEpoch(){return this.workerEpoch}get internalEventsPending(){return this.internalEventUploader.pendingCount}close(){this.closed=!0,this.stopHeartbeat(),x(),this.streamEventTimer&&(clearTimeout(this.streamEventTimer),this.streamEventTimer=null),this.streamEventBuffer=[],this.streamTextAccumulator.byMessage.clear(),this.streamTextAccumulator.scopeToMessage.clear(),this.workerState.close(),this.eventUploader.close(),this.internalEventUploader.close(),this.deliveryUploader.close()}};export{M as n,E as r,R as t};
@@ -0,0 +1 @@
1
+ import{BA as e,WA as t}from"./loadAgentsDir-DC4jN6-f.js";e();export{t as settingsChangeDetector};
@@ -0,0 +1 @@
1
+ import{a as e,c as t}from"./channelNotification-CSmLgwtO.js";t();export{e as ChannelPermissionRequestNotificationSchema};
@@ -1 +1 @@
1
- import{n as e}from"./chunk-DR8-3Aex.js";import{Ln as t,Mn as n,Tt as r,un as i,vt as a,wn as o}from"./schemas-BGAvj1T4.js";import{t as s}from"./v4-f1i_CNUT.js";import{cn as c,y as l}from"./state-sIHsFpDu.js";import{S as u,_ as d}from"./paths-BZjPDxMm.js";import{E as f,et as p}from"./log-DSV4Ht5l.js";import{n as m,t as h}from"./lazySchema-B0QShMaQ.js";import{i as g,n as _,o as v,p as y,r as b}from"./xml-DOXio8vw.js";function x(){let e=d(`tengu_harbor_ledger`,[]),t=w().safeParse(e);return t.success?t.data:[]}function S(){return!0}function C(e){if(!e)return!1;let{name:t,marketplace:n}=v(e);return n?n===`builtin`&&t===`weixin`?!0:x().some(e=>e.plugin===t&&e.marketplace===n):!1}var w,T=e((()=>{s(),y(),h(),g(),u(),w=m(()=>r(o({marketplace:t(),plugin:t()})))}));function E(e,t,n){let r=Object.entries(n??{}).filter(([e])=>P.test(e)).map(([e,t])=>` ${e}="${_(t)}"`).join(``);return`<${f} source="${_(e)}"${r}>\n${t}\n</${f}>`}function D(e,t){let n=e.split(`:`);return t.find(t=>t.kind===`server`?e===t.name:n[0]===`plugin`&&n[1]===t.name)}function O(e,t,n){if(!t?.experimental?.[`claude/channel`])return{action:`skip`,kind:`capability`,reason:`server did not declare claude/channel capability`};let r=D(e,l());if(!r)return{action:`skip`,kind:`session`,reason:`server ${e} not in --channels list for this session`};if(r.kind===`plugin`){let e=n?v(n).marketplace:void 0;if(e!==r.marketplace)return{action:`skip`,kind:`marketplace`,reason:`you asked for plugin:${r.name}@${r.marketplace} but the installed ${r.name} plugin is from ${e??`an unknown source`}`}}return{action:`register`}}var k,A,j,M,N,P,F=e((()=>{s(),c(),p(),h(),g(),b(),T(),k=m(()=>o({method:i(`notifications/claude/channel`),params:o({content:t(),meta:n(t(),t()).optional()})})),A=`notifications/claude/channel/permission`,j=m(()=>o({method:i(A),params:o({request_id:t(),behavior:a([`allow`,`deny`])})})),M=`notifications/claude/channel/permission_request`,N=m(()=>o({method:i(M),params:o({request_id:t(),tool_name:t(),description:t(),input_preview:t(),channel_context:o({source_server:t().optional(),chat_id:t().optional()}).optional()})})),P=/^[a-zA-Z_][a-zA-Z0-9_]*$/}));export{N as a,F as c,C as d,S as f,j as i,E as l,M as n,D as o,k as r,O as s,A as t,T as u};
1
+ import{n as e}from"./chunk-DR8-3Aex.js";import{Ln as t,Mn as n,Tt as r,un as i,vt as a,wn as o}from"./schemas-BGAvj1T4.js";import{t as s}from"./v4-f1i_CNUT.js";import{cn as c,y as l}from"./state-sIHsFpDu.js";import{S as u,_ as d}from"./paths-CEAy4QCs.js";import{E as f,et as p}from"./log-DSV4Ht5l.js";import{n as m,t as h}from"./lazySchema-B0QShMaQ.js";import{i as g,n as _,o as v,p as y,r as b}from"./xml-D7-jJqSA.js";function x(){let e=d(`tengu_harbor_ledger`,[]),t=w().safeParse(e);return t.success?t.data:[]}function S(){return!0}function C(e){if(!e)return!1;let{name:t,marketplace:n}=v(e);return n?n===`builtin`&&t===`weixin`?!0:x().some(e=>e.plugin===t&&e.marketplace===n):!1}var w,T=e((()=>{s(),y(),h(),g(),u(),w=m(()=>r(o({marketplace:t(),plugin:t()})))}));function E(e,t,n){let r=Object.entries(n??{}).filter(([e])=>P.test(e)).map(([e,t])=>` ${e}="${_(t)}"`).join(``);return`<${f} source="${_(e)}"${r}>\n${t}\n</${f}>`}function D(e,t){let n=e.split(`:`);return t.find(t=>t.kind===`server`?e===t.name:n[0]===`plugin`&&n[1]===t.name)}function O(e,t,n){if(!t?.experimental?.[`claude/channel`])return{action:`skip`,kind:`capability`,reason:`server did not declare claude/channel capability`};let r=D(e,l());if(!r)return{action:`skip`,kind:`session`,reason:`server ${e} not in --channels list for this session`};if(r.kind===`plugin`){let e=n?v(n).marketplace:void 0;if(e!==r.marketplace)return{action:`skip`,kind:`marketplace`,reason:`you asked for plugin:${r.name}@${r.marketplace} but the installed ${r.name} plugin is from ${e??`an unknown source`}`}}return{action:`register`}}var k,A,j,M,N,P,F=e((()=>{s(),c(),p(),h(),g(),b(),T(),k=m(()=>o({method:i(`notifications/claude/channel`),params:o({content:t(),meta:n(t(),t()).optional()})})),A=`notifications/claude/channel/permission`,j=m(()=>o({method:i(A),params:o({request_id:t(),behavior:a([`allow`,`deny`])})})),M=`notifications/claude/channel/permission_request`,N=m(()=>o({method:i(M),params:o({request_id:t(),tool_name:t(),description:t(),input_preview:t(),channel_context:o({source_server:t().optional(),chat_id:t().optional()}).optional()})})),P=/^[a-zA-Z_][a-zA-Z0-9_]*$/}));export{N as a,F as c,C as d,S as f,j as i,E as l,M as n,D as o,k as r,O as s,A as t,T as u};
@@ -1 +1 @@
1
- import{n as e,o as t}from"./chunk-DR8-3Aex.js";import{f as n,s as r}from"./envUtils-BWeoiL4Y.js";import{Rn as i,b as a,f as o,t as s,x as c}from"./src-Di342QoJ.js";import{t as l}from"./jsx-runtime-D-D469L8.js";import{Cc as u,dc as d,dn as f,on as p,yc as m}from"./paths-BZjPDxMm.js";import{a as h,n as g}from"./env-C2A9gV_G.js";import{aS as _,lC as v,oS as y,uC as b}from"./loadAgentsDir-BYWykYwn.js";import{n as x,t as S}from"./browser-Bt-ckCaU.js";import{c as C,d as w,t as T}from"./common-Da57Qwms.js";import{n as E,t as D}from"./setup-CTfYsKsz.js";function O({onDone:e,isExtensionInstalled:t,configEnabled:r,isClaudeAISubscriber:i,isWSL:s}){let l=b(e=>e.mcp.clients),[d,f]=(0,k.useState)(0),[p,m]=(0,k.useState)(r??!1),[h,g]=(0,k.useState)(!1),[v,y]=(0,k.useState)(t),S=process.env.USER_TYPE===`ant`&&n(),C=l.find(e=>e.name===T)?.type===`connected`;function D(e){S?x(e):w(e)}function O(e){switch(e){case`install-extension`:f(e=>e+1),g(!0),D(j);break;case`reconnect`:f(e=>e+1),E().then(e=>{y(e),e&&g(!1)}),D(N);break;case`manage-permissions`:f(e=>e+1),D(M);break;case`toggle-default`:{let e=!p;u(t=>({...t,claudeInChromeDefaultEnabled:e})),m(e);break}}}let P=[],F=v?``:` (requires extension)`;!v&&!S&&P.push({label:`Install Chrome extension`,value:`install-extension`}),P.push({label:(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(a,{children:`Manage permissions`}),(0,A.jsx)(a,{dimColor:!0,children:F})]}),value:`manage-permissions`},{label:(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(a,{children:`Reconnect extension`}),(0,A.jsx)(a,{dimColor:!0,children:F})]}),value:`reconnect`},{label:`Enabled by default: ${p?`Yes`:`No`}`,value:`toggle-default`});let I=s||process.env.USER_TYPE!==`ant`&&!i;return(0,A.jsx)(o,{title:`Claude in Chrome (Beta)`,onCancel:()=>e(),color:`chromeYellow`,children:(0,A.jsxs)(c,{flexDirection:`column`,gap:1,children:[(0,A.jsx)(a,{children:`Claude in Chrome works with the Chrome extension to let you control your browser directly from Claude Code. Navigate websites, fill forms, capture screenshots, record GIFs, and debug with console logs and network requests.`}),s&&(0,A.jsx)(a,{color:`error`,children:`Claude in Chrome is not supported in WSL at this time.`}),process.env.USER_TYPE!==`ant`&&!i&&(0,A.jsx)(a,{color:`error`,children:`Claude in Chrome requires a claude.ai subscription.`}),!I&&(0,A.jsxs)(A.Fragment,{children:[!S&&(0,A.jsxs)(c,{flexDirection:`column`,children:[(0,A.jsxs)(a,{children:[`Status: `,C?(0,A.jsx)(a,{color:`success`,children:`Enabled`}):(0,A.jsx)(a,{color:`inactive`,children:`Disabled`})]}),(0,A.jsxs)(a,{children:[`Extension:`,` `,v?(0,A.jsx)(a,{color:`success`,children:`Installed`}):(0,A.jsx)(a,{color:`warning`,children:`Not detected`})]})]}),(0,A.jsx)(_,{options:P,onChange:O,hideIndexes:!0},d),h&&(0,A.jsxs)(a,{color:`warning`,children:[`Once installed, select `,`"Reconnect extension"`,` to connect.`]}),(0,A.jsxs)(a,{children:[(0,A.jsx)(a,{dimColor:!0,children:`Usage: `}),(0,A.jsx)(a,{children:`claude --chrome`}),(0,A.jsx)(a,{dimColor:!0,children:` or `}),(0,A.jsx)(a,{children:`claude --no-chrome`})]}),(0,A.jsx)(a,{dimColor:!0,children:`Site-level permissions are inherited from the Chrome extension. Manage permissions in the Chrome extension settings to control which sites Claude can browse, click, and type on.`})]}),(0,A.jsx)(a,{dimColor:!0,children:`Learn more: https://code.claude.com/docs/en/chrome`})]})})}var k,A,j,M,N,P;e((()=>{k=t(i(),1),y(),s(),v(),p(),S(),C(),D(),m(),h(),r(),A=l(),j=`https://claude.ai/chrome`,M=`https://clau.de/chrome/permissions`,N=`https://clau.de/chrome/reconnect`,P=async function(e){let t=await E(),n=d(),r=f(),i=g.isWslEnvironment();return(0,A.jsx)(O,{onDone:e,isExtensionInstalled:t,configEnabled:n.claudeInChromeDefaultEnabled,isClaudeAISubscriber:r,isWSL:i})}}))();export{P as call};
1
+ import{n as e,o as t}from"./chunk-DR8-3Aex.js";import{f as n,s as r}from"./envUtils-BWeoiL4Y.js";import{Rn as i,b as a,f as o,t as s,x as c}from"./src-Di342QoJ.js";import{t as l}from"./jsx-runtime-D-D469L8.js";import{Cc as u,dc as d,dn as f,on as p,yc as m}from"./paths-CEAy4QCs.js";import{a as h,n as g}from"./env-C2A9gV_G.js";import{aS as _,lC as v,oS as y,uC as b}from"./loadAgentsDir-DC4jN6-f.js";import{n as x,t as S}from"./browser-Bt-ckCaU.js";import{c as C,d as w,t as T}from"./common-Da57Qwms.js";import{n as E,t as D}from"./setup-Hlga8GJ_.js";function O({onDone:e,isExtensionInstalled:t,configEnabled:r,isClaudeAISubscriber:i,isWSL:s}){let l=b(e=>e.mcp.clients),[d,f]=(0,k.useState)(0),[p,m]=(0,k.useState)(r??!1),[h,g]=(0,k.useState)(!1),[v,y]=(0,k.useState)(t),S=process.env.USER_TYPE===`ant`&&n(),C=l.find(e=>e.name===T)?.type===`connected`;function D(e){S?x(e):w(e)}function O(e){switch(e){case`install-extension`:f(e=>e+1),g(!0),D(j);break;case`reconnect`:f(e=>e+1),E().then(e=>{y(e),e&&g(!1)}),D(N);break;case`manage-permissions`:f(e=>e+1),D(M);break;case`toggle-default`:{let e=!p;u(t=>({...t,claudeInChromeDefaultEnabled:e})),m(e);break}}}let P=[],F=v?``:` (requires extension)`;!v&&!S&&P.push({label:`Install Chrome extension`,value:`install-extension`}),P.push({label:(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(a,{children:`Manage permissions`}),(0,A.jsx)(a,{dimColor:!0,children:F})]}),value:`manage-permissions`},{label:(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(a,{children:`Reconnect extension`}),(0,A.jsx)(a,{dimColor:!0,children:F})]}),value:`reconnect`},{label:`Enabled by default: ${p?`Yes`:`No`}`,value:`toggle-default`});let I=s||process.env.USER_TYPE!==`ant`&&!i;return(0,A.jsx)(o,{title:`Claude in Chrome (Beta)`,onCancel:()=>e(),color:`chromeYellow`,children:(0,A.jsxs)(c,{flexDirection:`column`,gap:1,children:[(0,A.jsx)(a,{children:`Claude in Chrome works with the Chrome extension to let you control your browser directly from Claude Code. Navigate websites, fill forms, capture screenshots, record GIFs, and debug with console logs and network requests.`}),s&&(0,A.jsx)(a,{color:`error`,children:`Claude in Chrome is not supported in WSL at this time.`}),process.env.USER_TYPE!==`ant`&&!i&&(0,A.jsx)(a,{color:`error`,children:`Claude in Chrome requires a claude.ai subscription.`}),!I&&(0,A.jsxs)(A.Fragment,{children:[!S&&(0,A.jsxs)(c,{flexDirection:`column`,children:[(0,A.jsxs)(a,{children:[`Status: `,C?(0,A.jsx)(a,{color:`success`,children:`Enabled`}):(0,A.jsx)(a,{color:`inactive`,children:`Disabled`})]}),(0,A.jsxs)(a,{children:[`Extension:`,` `,v?(0,A.jsx)(a,{color:`success`,children:`Installed`}):(0,A.jsx)(a,{color:`warning`,children:`Not detected`})]})]}),(0,A.jsx)(_,{options:P,onChange:O,hideIndexes:!0},d),h&&(0,A.jsxs)(a,{color:`warning`,children:[`Once installed, select `,`"Reconnect extension"`,` to connect.`]}),(0,A.jsxs)(a,{children:[(0,A.jsx)(a,{dimColor:!0,children:`Usage: `}),(0,A.jsx)(a,{children:`claude --chrome`}),(0,A.jsx)(a,{dimColor:!0,children:` or `}),(0,A.jsx)(a,{children:`claude --no-chrome`})]}),(0,A.jsx)(a,{dimColor:!0,children:`Site-level permissions are inherited from the Chrome extension. Manage permissions in the Chrome extension settings to control which sites Claude can browse, click, and type on.`})]}),(0,A.jsx)(a,{dimColor:!0,children:`Learn more: https://code.claude.com/docs/en/chrome`})]})})}var k,A,j,M,N,P;e((()=>{k=t(i(),1),y(),s(),v(),p(),S(),C(),D(),m(),h(),r(),A=l(),j=`https://claude.ai/chrome`,M=`https://clau.de/chrome/permissions`,N=`https://clau.de/chrome/reconnect`,P=async function(e){let t=await E(),n=d(),r=f(),i=g.isWslEnvironment();return(0,A.jsx)(O,{onDone:e,isExtensionInstalled:t,configEnabled:n.claudeInChromeDefaultEnabled,isClaudeAISubscriber:r,isWSL:i})}}))();export{P as call};
@@ -0,0 +1 @@
1
+ import{n as e}from"./chunk-DR8-3Aex.js";import{n as t,t as n}from"./conversation-DR4MFYYi.js";var r;e((()=>{t(),r=async(e,t)=>(await n(t),{type:`text`,value:``})}))();export{r as call};
@@ -0,0 +1 @@
1
+ import{la as e,ua as t}from"./paths-CEAy4QCs.js";t();export{e as getOrganizationUUID};
@@ -1 +1 @@
1
- import{n as e}from"./chunk-DR8-3Aex.js";import{Ct as t,cn as n}from"./state-sIHsFpDu.js";import{f as r,l as i}from"./teammate-CbskW5G9.js";import{Ar as a,Cb as o,Eb as s,Fr as c,vi as l}from"./loadAgentsDir-BYWykYwn.js";async function u(e,n,i){if(r())return e(`Cannot set color: This session is a swarm teammate. Teammate colors are assigned by the team leader.`,{display:`system`}),null;if(!i||i.trim()===``)return e(`Please provide a color. Available colors: ${o.join(`, `)}, default`,{display:`system`}),null;let s=i.trim().toLowerCase();return d.includes(s)?(await l(t(),`default`,a()),n.setAppState(e=>({...e,standaloneAgentContext:{...e.standaloneAgentContext,name:e.standaloneAgentContext?.name??``,color:void 0}})),e(`Session color reset to default`,{display:`system`}),null):o.includes(s)?(await l(t(),s,a()),n.setAppState(e=>({...e,standaloneAgentContext:{...e.standaloneAgentContext,name:e.standaloneAgentContext?.name??``,color:s}})),e(`Session color set to: ${s}`,{display:`system`}),null):(e(`Invalid color "${s}". Available colors: ${o.join(`, `)}, default`,{display:`system`}),null)}var d;e((()=>{n(),s(),c(),i(),d=[`default`,`reset`,`none`,`gray`,`grey`]}))();export{u as call};
1
+ import{n as e}from"./chunk-DR8-3Aex.js";import{Ct as t,cn as n}from"./state-sIHsFpDu.js";import{f as r,l as i}from"./teammate-CbskW5G9.js";import{Ar as a,Cb as o,Eb as s,Fr as c,vi as l}from"./loadAgentsDir-DC4jN6-f.js";async function u(e,n,i){if(r())return e(`Cannot set color: This session is a swarm teammate. Teammate colors are assigned by the team leader.`,{display:`system`}),null;if(!i||i.trim()===``)return e(`Please provide a color. Available colors: ${o.join(`, `)}, default`,{display:`system`}),null;let s=i.trim().toLowerCase();return d.includes(s)?(await l(t(),`default`,a()),n.setAppState(e=>({...e,standaloneAgentContext:{...e.standaloneAgentContext,name:e.standaloneAgentContext?.name??``,color:void 0}})),e(`Session color reset to default`,{display:`system`}),null):o.includes(s)?(await l(t(),s,a()),n.setAppState(e=>({...e,standaloneAgentContext:{...e.standaloneAgentContext,name:e.standaloneAgentContext?.name??``,color:s}})),e(`Session color set to: ${s}`,{display:`system`}),null):(e(`Invalid color "${s}". Available colors: ${o.join(`, `)}, default`,{display:`system`}),null)}var d;e((()=>{n(),s(),c(),i(),d=[`default`,`reset`,`none`,`gray`,`grey`]}))();export{u as call};
@@ -0,0 +1 @@
1
+ import{Gi as e,Zi as t,na as n}from"./loadAgentsDir-DC4jN6-f.js";n();export{e as clearCommandsCache,t as getCommands};
@@ -0,0 +1 @@
1
+ import{d as e,l as t}from"./commitAttribution-Djh1ZpYH.js";t();export{e as isInternalModelRepo};
@@ -1,2 +1,2 @@
1
- import{n as e}from"./chunk-DR8-3Aex.js";import{Ct as t,cn as n,ot as r}from"./state-sIHsFpDu.js";import{Pr as i,nc as a,rc as o}from"./paths-BZjPDxMm.js";import{_ as s,l as c}from"./debug-otxXY3j-.js";import{n as l,t as u}from"./cwd--iizewsn.js";import{E as d,T as f,_ as p,r as m,v as h}from"./git-C0IuvuIy.js";import{o as g}from"./log-DSV4Ht5l.js";import{n as _,r as v}from"./execFileNoThrow-azCkYhmF.js";import{basename as y,extname as b,join as x,posix as S,sep as C}from"path";import{randomUUID as w}from"crypto";import{stat as T}from"fs/promises";function E(e){let t=S.sep+e.split(C).join(S.sep).replace(/^\/+/,``),n=y(e).toLowerCase(),r=b(e).toLowerCase();if(D.has(n)||O.has(r))return!0;let i=n.split(`.`);if(i.length>2){let e=`.`+i.slice(-2).join(`.`);if(O.has(e))return!0}for(let e of k)if(t.includes(e))return!0;for(let e of A)if(e.test(n))return!0;return!1}var D,O,k,A,j=e((()=>{D=new Set([`package-lock.json`,`yarn.lock`,`pnpm-lock.yaml`,`bun.lockb`,`bun.lock`,`composer.lock`,`gemfile.lock`,`cargo.lock`,`poetry.lock`,`pipfile.lock`,`shrinkwrap.json`,`npm-shrinkwrap.json`]),O=new Set([`.lock`,`.min.js`,`.min.css`,`.min.html`,`.bundle.js`,`.bundle.css`,`.generated.ts`,`.generated.js`,`.d.ts`]),k=[`/dist/`,`/build/`,`/out/`,`/output/`,`/node_modules/`,`/vendor/`,`/vendored/`,`/third_party/`,`/third-party/`,`/external/`,`/.next/`,`/.nuxt/`,`/.svelte-kit/`,`/coverage/`,`/__pycache__/`,`/.tox/`,`/venv/`,`/.venv/`,`/target/release/`,`/target/debug/`],A=[/^.*\.min\.[a-z]+$/i,/^.*-min\.[a-z]+$/i,/^.*\.bundle\.[a-z]+$/i,/^.*\.generated\.[a-z]+$/i,/^.*\.gen\.[a-z]+$/i,/^.*\.auto\.[a-z]+$/i,/^.*_generated\.[a-z]+$/i,/^.*_gen\.[a-z]+$/i,/^.*\.pb\.(go|js|ts|py|rb)$/i,/^.*_pb2?\.py$/i,/^.*\.pb\.h$/i,/^.*\.grpc\.[a-z]+$/i,/^.*\.swagger\.[a-z]+$/i,/^.*\.openapi\.[a-z]+$/i]}));function M(){return m(u())??r()}function N(){return W}function P(){return process.env.CLAUDE_CODE_ENTRYPOINT??`cli`}function F(){return{fileStates:new Map,sessionBaselines:new Map,surface:P(),startingHeadSha:null,promptCount:0,promptCountAtLastCommit:0,permissionPromptCount:0,permissionPromptCountAtLastCommit:0,escapeCount:0,escapeCountAtLastCommit:0}}async function I(e,n){let r=M(),i=t(),a={},o=[],s=new Set,c={},l=0,u=0,d=new Map,f=new Map;for(let t of e){s.add(t.surface);let e=t.sessionBaselines instanceof Map?t.sessionBaselines:new Map(Object.entries(t.sessionBaselines??{}));for(let[t,n]of e)f.has(t)||f.set(t,n);let n=t.fileStates instanceof Map?t.fileStates:new Map(Object.entries(t.fileStates??{}));for(let[e,t]of n){let n=d.get(e);n?d.set(e,{...t,claudeContribution:n.claudeContribution+t.claudeContribution}):d.set(e,t)}}let p=await Promise.all(n.map(async t=>{if(E(t))return{type:`generated`,file:t};let n=x(r,t),i=d.get(t),a=f.get(t),o=e[0].surface,s=0,c=0;if(await R(t))if(i)s=i.claudeContribution,c=0;else{let e=await L(t);c=e>0?e:100}else try{let e=await T(n);if(i)s=i.claudeContribution,c=0;else if(a){let n=await L(t);c=n>0?n:e.size}else c=e.size}catch{return null}s=Math.max(0,s),c=Math.max(0,c);let l=s+c,u=l>0?Math.round(s/l*100):0;return{type:`file`,file:t,claudeChars:s,humanChars:c,percent:u,surface:o}}));for(let e of p)if(e){if(e.type===`generated`){o.push(e.file);continue}a[e.file]={claudeChars:e.claudeChars,humanChars:e.humanChars,percent:e.percent,surface:e.surface},l+=e.claudeChars,u+=e.humanChars,c[e.surface]=(c[e.surface]??0)+e.claudeChars}let m=l+u,h=m>0?Math.round(l/m*100):0,g={};for(let[e,t]of Object.entries(c))g[e]={claudeChars:t,percent:m>0?Math.round(t/m*100):0};return{version:1,summary:{claudePercent:h,claudeChars:l,humanChars:u,surfaces:Array.from(s)},files:a,surfaceBreakdown:g,excludedGenerated:o,sessions:[i]}}async function L(e){let t=M();try{let n=await _(p(),[`diff`,`--cached`,`--stat`,`--`,e],{cwd:t,timeout:5e3});if(n.code!==0||!n.stdout)return 0;let r=n.stdout.split(`
1
+ import{n as e}from"./chunk-DR8-3Aex.js";import{Ct as t,cn as n,ot as r}from"./state-sIHsFpDu.js";import{Pr as i,nc as a,rc as o}from"./paths-CEAy4QCs.js";import{_ as s,l as c}from"./debug-otxXY3j-.js";import{n as l,t as u}from"./cwd--iizewsn.js";import{E as d,T as f,_ as p,r as m,v as h}from"./git-C0IuvuIy.js";import{o as g}from"./log-DSV4Ht5l.js";import{n as _,r as v}from"./execFileNoThrow-azCkYhmF.js";import{basename as y,extname as b,join as x,posix as S,sep as C}from"path";import{randomUUID as w}from"crypto";import{stat as T}from"fs/promises";function E(e){let t=S.sep+e.split(C).join(S.sep).replace(/^\/+/,``),n=y(e).toLowerCase(),r=b(e).toLowerCase();if(D.has(n)||O.has(r))return!0;let i=n.split(`.`);if(i.length>2){let e=`.`+i.slice(-2).join(`.`);if(O.has(e))return!0}for(let e of k)if(t.includes(e))return!0;for(let e of A)if(e.test(n))return!0;return!1}var D,O,k,A,j=e((()=>{D=new Set([`package-lock.json`,`yarn.lock`,`pnpm-lock.yaml`,`bun.lockb`,`bun.lock`,`composer.lock`,`gemfile.lock`,`cargo.lock`,`poetry.lock`,`pipfile.lock`,`shrinkwrap.json`,`npm-shrinkwrap.json`]),O=new Set([`.lock`,`.min.js`,`.min.css`,`.min.html`,`.bundle.js`,`.bundle.css`,`.generated.ts`,`.generated.js`,`.d.ts`]),k=[`/dist/`,`/build/`,`/out/`,`/output/`,`/node_modules/`,`/vendor/`,`/vendored/`,`/third_party/`,`/third-party/`,`/external/`,`/.next/`,`/.nuxt/`,`/.svelte-kit/`,`/coverage/`,`/__pycache__/`,`/.tox/`,`/venv/`,`/.venv/`,`/target/release/`,`/target/debug/`],A=[/^.*\.min\.[a-z]+$/i,/^.*-min\.[a-z]+$/i,/^.*\.bundle\.[a-z]+$/i,/^.*\.generated\.[a-z]+$/i,/^.*\.gen\.[a-z]+$/i,/^.*\.auto\.[a-z]+$/i,/^.*_generated\.[a-z]+$/i,/^.*_gen\.[a-z]+$/i,/^.*\.pb\.(go|js|ts|py|rb)$/i,/^.*_pb2?\.py$/i,/^.*\.pb\.h$/i,/^.*\.grpc\.[a-z]+$/i,/^.*\.swagger\.[a-z]+$/i,/^.*\.openapi\.[a-z]+$/i]}));function M(){return m(u())??r()}function N(){return W}function P(){return process.env.CLAUDE_CODE_ENTRYPOINT??`cli`}function F(){return{fileStates:new Map,sessionBaselines:new Map,surface:P(),startingHeadSha:null,promptCount:0,promptCountAtLastCommit:0,permissionPromptCount:0,permissionPromptCountAtLastCommit:0,escapeCount:0,escapeCountAtLastCommit:0}}async function I(e,n){let r=M(),i=t(),a={},o=[],s=new Set,c={},l=0,u=0,d=new Map,f=new Map;for(let t of e){s.add(t.surface);let e=t.sessionBaselines instanceof Map?t.sessionBaselines:new Map(Object.entries(t.sessionBaselines??{}));for(let[t,n]of e)f.has(t)||f.set(t,n);let n=t.fileStates instanceof Map?t.fileStates:new Map(Object.entries(t.fileStates??{}));for(let[e,t]of n){let n=d.get(e);n?d.set(e,{...t,claudeContribution:n.claudeContribution+t.claudeContribution}):d.set(e,t)}}let p=await Promise.all(n.map(async t=>{if(E(t))return{type:`generated`,file:t};let n=x(r,t),i=d.get(t),a=f.get(t),o=e[0].surface,s=0,c=0;if(await R(t))if(i)s=i.claudeContribution,c=0;else{let e=await L(t);c=e>0?e:100}else try{let e=await T(n);if(i)s=i.claudeContribution,c=0;else if(a){let n=await L(t);c=n>0?n:e.size}else c=e.size}catch{return null}s=Math.max(0,s),c=Math.max(0,c);let l=s+c,u=l>0?Math.round(s/l*100):0;return{type:`file`,file:t,claudeChars:s,humanChars:c,percent:u,surface:o}}));for(let e of p)if(e){if(e.type===`generated`){o.push(e.file);continue}a[e.file]={claudeChars:e.claudeChars,humanChars:e.humanChars,percent:e.percent,surface:e.surface},l+=e.claudeChars,u+=e.humanChars,c[e.surface]=(c[e.surface]??0)+e.claudeChars}let m=l+u,h=m>0?Math.round(l/m*100):0,g={};for(let[e,t]of Object.entries(c))g[e]={claudeChars:t,percent:m>0?Math.round(t/m*100):0};return{version:1,summary:{claudePercent:h,claudeChars:l,humanChars:u,surfaces:Array.from(s)},files:a,surfaceBreakdown:g,excludedGenerated:o,sessions:[i]}}async function L(e){let t=M();try{let n=await _(p(),[`diff`,`--cached`,`--stat`,`--`,e],{cwd:t,timeout:5e3});if(n.code!==0||!n.stdout)return 0;let r=n.stdout.split(`
2
2
  `).filter(Boolean),i=0;for(let e of r)if(e.includes(`file changed`)||e.includes(`files changed`)){let t=e.match(/(\d+) insertions?/),n=e.match(/(\d+) deletions?/),r=t?parseInt(t[1],10):0,a=n?parseInt(n[1],10):0;i+=(r+a)*40}return i}catch{return 0}}async function R(e){let t=M();try{let n=await _(p(),[`diff`,`--cached`,`--name-status`,`--`,e],{cwd:t,timeout:5e3});if(n.code===0&&n.stdout)return n.stdout.trim().startsWith(`D `)}catch{}return!1}function z(e,t){let n={};for(let[t,r]of e.fileStates)n[t]=r;return{type:`attribution-snapshot`,messageId:t,surface:e.surface,fileStates:n,promptCount:e.promptCount,promptCountAtLastCommit:e.promptCountAtLastCommit,permissionPromptCount:e.permissionPromptCount,permissionPromptCountAtLastCommit:e.permissionPromptCountAtLastCommit,escapeCount:e.escapeCount,escapeCountAtLastCommit:e.escapeCountAtLastCommit}}function B(e){let t=F(),n=e[e.length-1];if(!n)return t;t.surface=n.surface;for(let[e,r]of Object.entries(n.fileStates))t.fileStates.set(e,r);return t.promptCount=n.promptCount??0,t.promptCountAtLastCommit=n.promptCountAtLastCommit??0,t.permissionPromptCount=n.permissionPromptCount??0,t.permissionPromptCountAtLastCommit=n.permissionPromptCountAtLastCommit??0,t.escapeCount=n.escapeCount??0,t.escapeCountAtLastCommit=n.escapeCountAtLastCommit??0,t}function V(e,t){t(B(e))}function H(e,t){let n={...e,promptCount:e.promptCount+1};return t(z(n,w())),n}var U,W,G,K=e((()=>{n(),l(),c(),v(),s(),j(),d(),h(),g(),i(),a(),U=`github.com:anthropics/claude-cli-internal,github.com/anthropics/claude-cli-internal,github.com:anthropics/anthropic,github.com/anthropics/anthropic,github.com:anthropics/apps,github.com/anthropics/apps,github.com:anthropics/casino,github.com/anthropics/casino,github.com:anthropics/dbt,github.com/anthropics/dbt,github.com:anthropics/dotfiles,github.com/anthropics/dotfiles,github.com:anthropics/terraform-config,github.com/anthropics/terraform-config,github.com:anthropics/hex-export,github.com/anthropics/hex-export,github.com:anthropics/feedback-v2,github.com/anthropics/feedback-v2,github.com:anthropics/labs,github.com/anthropics/labs,github.com:anthropics/argo-rollouts,github.com/anthropics/argo-rollouts,github.com:anthropics/starling-configs,github.com/anthropics/starling-configs,github.com:anthropics/ts-tools,github.com/anthropics/ts-tools,github.com:anthropics/ts-capsules,github.com/anthropics/ts-capsules,github.com:anthropics/feldspar-testing,github.com/anthropics/feldspar-testing,github.com:anthropics/trellis,github.com/anthropics/trellis,github.com:anthropics/claude-for-hiring,github.com/anthropics/claude-for-hiring,github.com:anthropics/forge-web,github.com/anthropics/forge-web,github.com:anthropics/infra-manifests,github.com/anthropics/infra-manifests,github.com:anthropics/mycro_manifests,github.com/anthropics/mycro_manifests,github.com:anthropics/mycro_configs,github.com/anthropics/mycro_configs,github.com:anthropics/mobile-apps,github.com/anthropics/mobile-apps`.split(`,`),W=null,G=o(async()=>{if(W!==null)return W===`internal`;let e=await f(M());if(!e)return W=`none`,!1;let t=U.some(t=>e.includes(t));return W=t?`internal`:`external`,t})}));export{P as a,H as c,G as d,B as f,M as i,K as l,I as n,L as o,z as p,F as r,N as s,V as t,R as u};
@@ -1,3 +1,3 @@
1
- import{n as e}from"./chunk-DR8-3Aex.js";import{In as t,Ln as n}from"./src-Di342QoJ.js";import{cn as r,dn as i}from"./state-sIHsFpDu.js";import{H as a,U as o}from"./debug-otxXY3j-.js";import{o as s,s as c}from"./log-DSV4Ht5l.js";import{AT as l,Al as u,Cl as d,Cn as f,El as p,Hk as m,Ol as h,Po as g,Tk as _,Tl as v,Uk as y,Uo as b,Wk as x,Zt as S,__ as C,_l as w,cA as T,dA as E,dd as D,dt as O,fA as k,fd as A,ft as j,g_ as M,hl as N,iA as P,jT as F,jk as I,kl as L,rA as R,sA as z,wl as B,xl as V}from"./loadAgentsDir-BYWykYwn.js";async function H(e,t,n,r){t.onCompactProgress?.({type:`hooks_start`,hookType:`pre_compact`}),t.setSDKStatus?.(`compacting`);try{let[i,a]=await Promise.all([S({trigger:`manual`,customInstructions:n||null},t.abortController.signal),W(t,e)]),o=u(n,i.newCustomInstructions);t.setStreamMode?.(`requesting`),t.setResponseLength?.(()=>0),t.onCompactProgress?.({type:`compact_start`});let s=await r.reactiveCompactOnPromptTooLong(e,a,{customInstructions:o,trigger:`manual`});if(!s.ok)switch(s.reason){case`too_few_groups`:throw Error(v);case`aborted`:throw Error(p);case`exhausted`:case`error`:case`media_unstrippable`:throw Error(B)}I(void 0),d(),T(),y.cache.clear?.();let c=[i.userDisplayMessage,s.result.userDisplayMessage].filter(Boolean).join(`
1
+ import{n as e}from"./chunk-DR8-3Aex.js";import{In as t,Ln as n}from"./src-Di342QoJ.js";import{cn as r,dn as i}from"./state-sIHsFpDu.js";import{H as a,U as o}from"./debug-otxXY3j-.js";import{o as s,s as c}from"./log-DSV4Ht5l.js";import{AT as l,Al as u,Cl as d,Cn as f,El as p,Hk as m,Ol as h,Po as g,Tk as _,Tl as v,Uk as y,Uo as b,Wk as x,Zt as S,__ as C,_l as w,cA as T,dA as E,dd as D,dt as O,fA as k,fd as A,ft as j,g_ as M,hl as N,iA as P,jT as F,jk as I,kl as L,rA as R,sA as z,wl as B,xl as V}from"./loadAgentsDir-DC4jN6-f.js";async function H(e,t,n,r){t.onCompactProgress?.({type:`hooks_start`,hookType:`pre_compact`}),t.setSDKStatus?.(`compacting`);try{let[i,a]=await Promise.all([S({trigger:`manual`,customInstructions:n||null},t.abortController.signal),W(t,e)]),o=u(n,i.newCustomInstructions);t.setStreamMode?.(`requesting`),t.setResponseLength?.(()=>0),t.onCompactProgress?.({type:`compact_start`});let s=await r.reactiveCompactOnPromptTooLong(e,a,{customInstructions:o,trigger:`manual`});if(!s.ok)switch(s.reason){case`too_few_groups`:throw Error(v);case`aborted`:throw Error(p);case`exhausted`:case`error`:case`media_unstrippable`:throw Error(B)}I(void 0),d(),T(),y.cache.clear?.();let c=[i.userDisplayMessage,s.result.userDisplayMessage].filter(Boolean).join(`
2
2
  `)||void 0;return{type:`compact`,compactionResult:{...s.result,userDisplayMessage:c},displayText:U(t,c)}}finally{t.setStreamMode?.(`requesting`),t.setResponseLength?.(()=>0),t.onCompactProgress?.({type:`compact_end`}),t.setSDKStatus?.(``)}}function U(e,n){let r=M(`tip`),i=l(`app:toggleTranscript`,`Global`,`ctrl+o`),a=[...e.options.verbose?[]:[`(${i} to see full summary)`],...n?[n]:[],...r?[r]:[]];return t.dim(`Compacted `+a.join(`
3
3
  `))}async function W(e,t){let n=e.getAppState(),r=await O(e.options.tools,e.options.mainLoopModel,Array.from(n.toolPermissionContext.additionalWorkingDirectories.keys()),e.options.mcpClients),i=D({mainThreadAgentDefinition:void 0,toolUseContext:e,customSystemPrompt:e.options.customSystemPrompt,defaultSystemPrompt:r,appendSystemPrompt:e.options.appendSystemPrompt}),[a,o]=await Promise.all([y(),m()]);return{systemPrompt:i,userContext:a,systemContext:o,toolUseContext:e,forkContextMessages:t}}var G,K;e((()=>{n(),r(),j(),x(),F(),E(),L(),z(),R(),V(),N(),_(),o(),f(),s(),b(),C(),A(),G=null,K=async(e,t)=>{let{abortController:n}=t,{messages:r}=t;if(r=g(r),r.length===0)throw Error(`No messages to compact`);let o=e.trim();try{if(!o){let e=await w(r,t.agentId);if(e)return y.cache.clear?.(),d(),k(t.options.querySource??`compact`,t.agentId),i(),T(),{type:`compact`,compactionResult:e,displayText:U(t)}}if(G?.isReactiveOnlyMode())return await H(r,t,o,G);let e=(await P(r,t)).messages,n=await h(e,t,await W(t,e),!1,o,!1);return I(void 0),T(),y.cache.clear?.(),d(),{type:`compact`,compactionResult:n,displayText:U(t,n.userDisplayMessage)}}catch(e){throw n.signal.aborted?Error(`Compaction canceled.`):a(e,`Not enough messages to compact. Send a few more messages first, then try again.`)?Error(v):a(e,`Compaction interrupted · This may be due to network issues — please try again.`)?Error(B):(c(e),Error(`Error during compaction: ${e}`))}}}))();export{K as call};
@@ -1 +1 @@
1
- import{n as e}from"./chunk-DR8-3Aex.js";import{dc as t,yc as n}from"./paths-BZjPDxMm.js";var r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,O,k,A=e((()=>{r=[`common`,`uncommon`,`rare`,`epic`,`legendary`],i=String.fromCharCode,a=i(100,117,99,107),o=i(103,111,111,115,101),s=i(98,108,111,98),c=i(99,97,116),l=i(100,114,97,103,111,110),u=i(111,99,116,111,112,117,115),d=i(111,119,108),f=i(112,101,110,103,117,105,110),p=i(116,117,114,116,108,101),m=i(115,110,97,105,108),h=i(103,104,111,115,116),g=i(97,120,111,108,111,116,108),_=i(99,97,112,121,98,97,114,97),v=i(99,97,99,116,117,115),y=i(114,111,98,111,116),b=i(114,97,98,98,105,116),x=i(109,117,115,104,114,111,111,109),S=i(99,104,111,110,107),C=[a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S],w=[`·`,`✦`,`×`,`◉`,`@`,`°`],T=[`none`,`crown`,`tophat`,`propeller`,`halo`,`wizard`,`beanie`,`tinyduck`],E=[`DEBUGGING`,`PATIENCE`,`CHAOS`,`WISDOM`,`SNARK`],D={common:60,uncommon:25,rare:10,epic:4,legendary:1},O={common:`★`,uncommon:`★★`,rare:`★★★`,epic:`★★★★`,legendary:`★★★★★`},k={common:`inactive`,uncommon:`success`,rare:`permission`,epic:`autoAccept`,legendary:`warning`}}));function j(e){let t=e>>>0;return function(){t|=0,t=t+1831565813|0;let e=Math.imul(t^t>>>15,1|t);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/4294967296}}function M(e){if(typeof Bun<`u`)return Number(BigInt(Bun.hash(e))&4294967295n);let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0}function N(e,t){return t[Math.floor(e()*t.length)]}function P(e){let t=Object.values(D).reduce((e,t)=>e+t,0),n=e()*t;for(let e of r)if(n-=D[e],n<0)return e;return`common`}function F(e,t){let n=U[t],r=N(e,E),i=N(e,E);for(;i===r;)i=N(e,E);let a={};for(let t of E)t===r?a[t]=Math.min(100,n+50+Math.floor(e()*30)):t===i?a[t]=Math.max(1,n-10+Math.floor(e()*15)):a[t]=n+Math.floor(e()*40);return a}function I(e){let t=P(e);return{bones:{rarity:t,species:N(e,C),eye:N(e,w),hat:t===`common`?`none`:N(e,T),shiny:e()<.01,stats:F(e,t)},inspirationSeed:Math.floor(e()*1e9)}}function L(e){return I(j(M(e)))}function R(){return`rehatch-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function z(){let e=t();return e.oauthAccount?.accountUuid??e.userID??`anon`}function B(e,t){return RegExp(`(^|${W})${t}($|${W})`).test(e)}function V(e){if(e.seed)return{};let t=`${e.name} ${e.personality}`.toLowerCase(),n={},i=C.find(e=>B(t,e)),a=r.find(e=>B(t,e));return i&&(n.species=i),a&&(n.rarity=a),n}function H(){let e=t().companion;if(!e)return;let{bones:n}=L(e.seed??z()),r=V(e);return{...e,...n,...r}}var U,W,G=e((()=>{n(),A(),U={common:5,uncommon:15,rare:25,epic:35,legendary:50},W=`[^a-z0-9]+`}));export{b as C,p as E,f as S,m as T,o as _,k as a,u as b,g as c,_ as d,c as f,h as g,a as h,L as i,s as l,l as m,H as n,O as o,S as p,G as r,E as s,R as t,v as u,A as v,y as w,d as x,x as y};
1
+ import{n as e}from"./chunk-DR8-3Aex.js";import{dc as t,yc as n}from"./paths-CEAy4QCs.js";var r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,O,k,A=e((()=>{r=[`common`,`uncommon`,`rare`,`epic`,`legendary`],i=String.fromCharCode,a=i(100,117,99,107),o=i(103,111,111,115,101),s=i(98,108,111,98),c=i(99,97,116),l=i(100,114,97,103,111,110),u=i(111,99,116,111,112,117,115),d=i(111,119,108),f=i(112,101,110,103,117,105,110),p=i(116,117,114,116,108,101),m=i(115,110,97,105,108),h=i(103,104,111,115,116),g=i(97,120,111,108,111,116,108),_=i(99,97,112,121,98,97,114,97),v=i(99,97,99,116,117,115),y=i(114,111,98,111,116),b=i(114,97,98,98,105,116),x=i(109,117,115,104,114,111,111,109),S=i(99,104,111,110,107),C=[a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S],w=[`·`,`✦`,`×`,`◉`,`@`,`°`],T=[`none`,`crown`,`tophat`,`propeller`,`halo`,`wizard`,`beanie`,`tinyduck`],E=[`DEBUGGING`,`PATIENCE`,`CHAOS`,`WISDOM`,`SNARK`],D={common:60,uncommon:25,rare:10,epic:4,legendary:1},O={common:`★`,uncommon:`★★`,rare:`★★★`,epic:`★★★★`,legendary:`★★★★★`},k={common:`inactive`,uncommon:`success`,rare:`permission`,epic:`autoAccept`,legendary:`warning`}}));function j(e){let t=e>>>0;return function(){t|=0,t=t+1831565813|0;let e=Math.imul(t^t>>>15,1|t);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/4294967296}}function M(e){if(typeof Bun<`u`)return Number(BigInt(Bun.hash(e))&4294967295n);let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0}function N(e,t){return t[Math.floor(e()*t.length)]}function P(e){let t=Object.values(D).reduce((e,t)=>e+t,0),n=e()*t;for(let e of r)if(n-=D[e],n<0)return e;return`common`}function F(e,t){let n=U[t],r=N(e,E),i=N(e,E);for(;i===r;)i=N(e,E);let a={};for(let t of E)t===r?a[t]=Math.min(100,n+50+Math.floor(e()*30)):t===i?a[t]=Math.max(1,n-10+Math.floor(e()*15)):a[t]=n+Math.floor(e()*40);return a}function I(e){let t=P(e);return{bones:{rarity:t,species:N(e,C),eye:N(e,w),hat:t===`common`?`none`:N(e,T),shiny:e()<.01,stats:F(e,t)},inspirationSeed:Math.floor(e()*1e9)}}function L(e){return I(j(M(e)))}function R(){return`rehatch-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function z(){let e=t();return e.oauthAccount?.accountUuid??e.userID??`anon`}function B(e,t){return RegExp(`(^|${W})${t}($|${W})`).test(e)}function V(e){if(e.seed)return{};let t=`${e.name} ${e.personality}`.toLowerCase(),n={},i=C.find(e=>B(t,e)),a=r.find(e=>B(t,e));return i&&(n.species=i),a&&(n.rarity=a),n}function H(){let e=t().companion;if(!e)return;let{bones:n}=L(e.seed??z()),r=V(e);return{...e,...n,...r}}var U,W,G=e((()=>{n(),A(),U={common:5,uncommon:15,rare:25,epic:35,legendary:50},W=`[^a-z0-9]+`}));export{b as C,p as E,f as S,m as T,o as _,k as a,u as b,g as c,_ as d,c as f,h as g,a as h,L as i,s as l,l as m,H as n,O as o,S as p,G as r,E as s,R as t,v as u,A as v,y as w,d as x,x as y};
@@ -1 +1 @@
1
- import{Cc as e,Sc as t,ac as n,dc as r,lc as i,oc as a,yc as o}from"./paths-BZjPDxMm.js";o();export{n as checkHasTrustDialogAccepted,a as enableConfigs,i as getCurrentProjectConfig,r as getGlobalConfig,t as saveCurrentProjectConfig,e as saveGlobalConfig};
1
+ import{Cc as e,Sc as t,ac as n,dc as r,lc as i,oc as a,yc as o}from"./paths-CEAy4QCs.js";o();export{n as checkHasTrustDialogAccepted,a as enableConfigs,i as getCurrentProjectConfig,r as getGlobalConfig,t as saveCurrentProjectConfig,e as saveGlobalConfig};
@@ -1 +1 @@
1
- import{n as e}from"./chunk-DR8-3Aex.js";import{t}from"./jsx-runtime-D-D469L8.js";import{n,t as r}from"./Settings-BSbzT25q.js";var i,a;e((()=>{n(),i=t(),a=async(e,t)=>(0,i.jsx)(r,{onClose:e,context:t,defaultTab:`Config`})}))();export{a as call};
1
+ import{n as e}from"./chunk-DR8-3Aex.js";import{t}from"./jsx-runtime-D-D469L8.js";import{n,t as r}from"./Settings-DOve7mW1.js";var i,a;e((()=>{n(),i=t(),a=async(e,t)=>(0,i.jsx)(r,{onClose:e,context:t,defaultTab:`Config`})}))();export{a as call};
@@ -1 +1 @@
1
- import{n as e}from"./chunk-DR8-3Aex.js";import{n as t,t as n}from"./figures-gfT9mM8P.js";import{Rn as r,b as i,o as a,t as o,x as s}from"./src-Di342QoJ.js";import{t as c}from"./jsx-runtime-D-D469L8.js";import{Bc as l,Gs as u,Uc as d,Ws as f}from"./paths-BZjPDxMm.js";import{b as p,y as m}from"./startupProfiler-CBcN1Chw.js";import{Po as h,Uo as g,dl as _,iA as v,ll as y,rA as b}from"./loadAgentsDir-BYWykYwn.js";import{En as x,Gn as S,Kn as C,Mn as w,Un as T,hn as E,mn as D,qn as O}from"./prompt-BGNhFY1n.js";import{n as k,t as A}from"./staticRender-DKFIRhkH.js";function ee(e){let t=[];return j(e,t),M(e,t),P(e,t),F(e,t),I(e,t),t.sort((e,t)=>e.severity===t.severity?(t.savingsTokens??0)-(e.savingsTokens??0):e.severity===`warning`?-1:1),t}function j(e,t){e.percentage>=B&&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 M(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<L||r<R)continue;let a=N(n.name,r,i);a&&t.push(a)}}function N(e,t,n){let r=m(t);switch(e){case C: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 T: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)};case D:return{severity:`info`,title:`WebFetch results using ${r} tokens (${n.toFixed(0)}%)`,detail:`Web page content can be very large. Consider extracting only the specific information needed.`,savingsTokens:Math.floor(t*.4)};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 P(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>=L&&r>=R||a>=z&&n.resultTokens>=R&&t.push({severity:`info`,title:`File reads using ${m(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 F(e,t){let n=e.memoryFiles.reduce((e,t)=>e+t.tokens,0),r=n/e.rawMaxTokens*100;if(r>=V&&n>=H){let i=[...e.memoryFiles].sort((e,t)=>t.tokens-e.tokens).slice(0,3).map(e=>`${l(e.path)} (${m(e.tokens)})`).join(`, `);t.push({severity:`info`,title:`Memory files using ${m(n)} tokens (${r.toFixed(0)}%)`,detail:`Largest: ${i}. Use /memory to review and prune stale entries.`,savingsTokens:Math.floor(n*.3)})}}function I(e,t){!e.isAutoCompactEnabled&&e.percentage>=50&&e.percentage<B&&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 L,R,z,B,V,H,U=e((()=>{O(),w(),S(),E(),d(),p(),L=15,R=1e4,z=5,B=80,V=5,H=5e3}));function W({suggestions:e}){return e.length===0?null:(0,G.jsxs)(s,{flexDirection:`column`,marginTop:1,children:[(0,G.jsx)(i,{bold:!0,children:`Suggestions`}),e.map((e,t)=>(0,G.jsxs)(s,{flexDirection:`column`,marginTop:t===0?0:1,children:[(0,G.jsxs)(s,{children:[(0,G.jsx)(a,{status:e.severity,withSpace:!0}),(0,G.jsx)(i,{bold:!0,children:e.title}),e.savingsTokens?(0,G.jsxs)(i,{dimColor:!0,children:[` `,n.arrowRight,` save ~`,m(e.savingsTokens)]}):null]}),(0,G.jsx)(s,{marginLeft:2,children:(0,G.jsx)(i,{dimColor:!0,children:e.detail})})]},t))]})}var G,K=e((()=>{t(),r(),o(),p(),G=c()}));function q(){return null}function J(e){let t=new Map;for(let n of e){let e=f(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 Q){let r=t.get(e);r&&n.set(e,r)}return n}function Y({data:e}){let{categories:t,totalTokens:n,rawMaxTokens:r,percentage:a,gridRows:o,model:c,memoryFiles:u,mcpTools:d,deferredBuiltinTools:f=[],systemTools:p,systemPromptSections:h,agents:g,skills:_,messageBreakdown:v,cacheHitRate:y,cacheThreshold:b}=e,x=t.filter(e=>e.tokens>0&&e.name!==`Free space`&&e.name!==Z&&!e.isDeferred),S=t.some(e=>e.isDeferred&&e.name.includes(`MCP`)),C=f.length>0,w=t.find(e=>e.name===Z);return(0,X.jsxs)(s,{flexDirection:`column`,paddingLeft:1,children:[(0,X.jsx)(i,{bold:!0,children:`Context Usage`}),(0,X.jsxs)(s,{flexDirection:`row`,gap:2,children:[(0,X.jsx)(s,{flexDirection:`column`,flexShrink:0,children:o.map((e,t)=>(0,X.jsx)(s,{flexDirection:`row`,marginLeft:-1,children:e.map((e,t)=>e.categoryName===`Free space`?(0,X.jsx)(i,{dimColor:!0,children:`⛶ `},t):e.categoryName===Z?(0,X.jsx)(i,{color:e.color,children:`⛝ `},t):(0,X.jsx)(i,{color:e.color,children:e.squareFullness>=.7?`⛁ `:`⛀ `},t))},t))}),(0,X.jsxs)(s,{flexDirection:`column`,gap:0,flexShrink:0,children:[(0,X.jsxs)(i,{dimColor:!0,children:[c,` · `,m(n),`/`,m(r),` tokens (`,a,`%)`]}),(0,X.jsx)(q,{}),y!==void 0&&b!==void 0&&(0,X.jsxs)(i,{color:y<b?`warning`:void 0,children:[`Cache hit rate: `,y.toFixed(0),`%`,y<b?` (below ${b}% threshold)`:``]}),(0,X.jsx)(i,{children:` `}),(0,X.jsx)(i,{dimColor:!0,italic:!0,children:`Estimated usage by category`}),x.map((e,t)=>{let n=m(e.tokens),a=e.isDeferred?`N/A`:`${(e.tokens/r*100).toFixed(1)}%`,o=e.name===Z,c=e.name,l=e.isDeferred?` `:o?`⛝`:`⛁`;return(0,X.jsxs)(s,{children:[(0,X.jsx)(i,{color:e.color,children:l}),(0,X.jsxs)(i,{children:[` `,c,`: `]}),(0,X.jsxs)(i,{dimColor:!0,children:[n,` tokens (`,a,`)`]})]},t)}),(t.find(e=>e.name===`Free space`)?.tokens??0)>0&&(0,X.jsxs)(s,{children:[(0,X.jsx)(i,{dimColor:!0,children:`⛶`}),(0,X.jsx)(i,{children:` Free space: `}),(0,X.jsxs)(i,{dimColor:!0,children:[m(t.find(e=>e.name===`Free space`)?.tokens||0),` (`,((t.find(e=>e.name===`Free space`)?.tokens||0)/r*100).toFixed(1),`%)`]})]}),w&&w.tokens>0&&(0,X.jsxs)(s,{children:[(0,X.jsx)(i,{color:w.color,children:`⛝`}),(0,X.jsxs)(i,{dimColor:!0,children:[` `,w.name,`: `]}),(0,X.jsxs)(i,{dimColor:!0,children:[m(w.tokens),` tokens (`,(w.tokens/r*100).toFixed(1),`%)`]})]})]})]}),(0,X.jsxs)(s,{flexDirection:`column`,marginLeft:-1,children:[d.length>0&&(0,X.jsxs)(s,{flexDirection:`column`,marginTop:1,children:[(0,X.jsxs)(s,{children:[(0,X.jsx)(i,{bold:!0,children:`MCP tools`}),(0,X.jsxs)(i,{dimColor:!0,children:[` · /mcp`,S?` (loaded on-demand)`:``]})]}),d.some(e=>e.isLoaded)&&(0,X.jsxs)(s,{flexDirection:`column`,marginTop:1,children:[(0,X.jsx)(i,{dimColor:!0,children:`Loaded`}),d.filter(e=>e.isLoaded).map((e,t)=>(0,X.jsxs)(s,{children:[(0,X.jsxs)(i,{children:[`└ `,e.name,`: `]}),(0,X.jsxs)(i,{dimColor:!0,children:[m(e.tokens),` tokens`]})]},t))]}),S&&d.some(e=>!e.isLoaded)&&(0,X.jsxs)(s,{flexDirection:`column`,marginTop:1,children:[(0,X.jsx)(i,{dimColor:!0,children:`Available`}),d.filter(e=>!e.isLoaded).map((e,t)=>(0,X.jsx)(s,{children:(0,X.jsxs)(i,{dimColor:!0,children:[`└ `,e.name]})},t))]}),!S&&d.map((e,t)=>(0,X.jsxs)(s,{children:[(0,X.jsxs)(i,{children:[`└ `,e.name,`: `]}),(0,X.jsxs)(i,{dimColor:!0,children:[m(e.tokens),` tokens`]})]},t))]}),(p&&p.length>0||C)&&process.env.USER_TYPE===`ant`&&(0,X.jsxs)(s,{flexDirection:`column`,marginTop:1,children:[(0,X.jsxs)(s,{children:[(0,X.jsx)(i,{bold:!0,children:`[ANT-ONLY] System tools`}),C&&(0,X.jsx)(i,{dimColor:!0,children:` (some loaded on-demand)`})]}),(0,X.jsxs)(s,{flexDirection:`column`,marginTop:1,children:[(0,X.jsx)(i,{dimColor:!0,children:`Loaded`}),p?.map((e,t)=>(0,X.jsxs)(s,{children:[(0,X.jsxs)(i,{children:[`└ `,e.name,`: `]}),(0,X.jsxs)(i,{dimColor:!0,children:[m(e.tokens),` tokens`]})]},`sys-${t}`)),f.filter(e=>e.isLoaded).map((e,t)=>(0,X.jsxs)(s,{children:[(0,X.jsxs)(i,{children:[`└ `,e.name,`: `]}),(0,X.jsxs)(i,{dimColor:!0,children:[m(e.tokens),` tokens`]})]},`def-${t}`))]}),C&&f.some(e=>!e.isLoaded)&&(0,X.jsxs)(s,{flexDirection:`column`,marginTop:1,children:[(0,X.jsx)(i,{dimColor:!0,children:`Available`}),f.filter(e=>!e.isLoaded).map((e,t)=>(0,X.jsx)(s,{children:(0,X.jsxs)(i,{dimColor:!0,children:[`└ `,e.name]})},t))]})]}),h&&h.length>0&&process.env.USER_TYPE===`ant`&&(0,X.jsxs)(s,{flexDirection:`column`,marginTop:1,children:[(0,X.jsx)(i,{bold:!0,children:`[ANT-ONLY] System prompt sections`}),h.map((e,t)=>(0,X.jsxs)(s,{children:[(0,X.jsxs)(i,{children:[`└ `,e.name,`: `]}),(0,X.jsxs)(i,{dimColor:!0,children:[m(e.tokens),` tokens`]})]},t))]}),g.length>0&&(0,X.jsxs)(s,{flexDirection:`column`,marginTop:1,children:[(0,X.jsxs)(s,{children:[(0,X.jsx)(i,{bold:!0,children:`Custom agents`}),(0,X.jsx)(i,{dimColor:!0,children:` · /agents`})]}),Array.from(J(g).entries()).map(([e,t])=>(0,X.jsxs)(s,{flexDirection:`column`,marginTop:1,children:[(0,X.jsx)(i,{dimColor:!0,children:e}),t.map((e,t)=>(0,X.jsxs)(s,{children:[(0,X.jsxs)(i,{children:[`└ `,e.agentType,`: `]}),(0,X.jsxs)(i,{dimColor:!0,children:[m(e.tokens),` tokens`]})]},t))]},e))]}),u.length>0&&(0,X.jsxs)(s,{flexDirection:`column`,marginTop:1,children:[(0,X.jsxs)(s,{children:[(0,X.jsx)(i,{bold:!0,children:`Memory files`}),(0,X.jsx)(i,{dimColor:!0,children:` · /memory`})]}),u.map((e,t)=>(0,X.jsxs)(s,{children:[(0,X.jsxs)(i,{children:[`└ `,l(e.path),`: `]}),(0,X.jsxs)(i,{dimColor:!0,children:[m(e.tokens),` tokens`]})]},t))]}),_&&_.tokens>0&&(0,X.jsxs)(s,{flexDirection:`column`,marginTop:1,children:[(0,X.jsxs)(s,{children:[(0,X.jsx)(i,{bold:!0,children:`Skills`}),(0,X.jsx)(i,{dimColor:!0,children:` · /skills`})]}),Array.from(J(_.skillFrontmatter).entries()).map(([e,t])=>(0,X.jsxs)(s,{flexDirection:`column`,marginTop:1,children:[(0,X.jsx)(i,{dimColor:!0,children:e}),t.map((e,t)=>(0,X.jsxs)(s,{children:[(0,X.jsxs)(i,{children:[`└ `,e.name,`: `]}),(0,X.jsxs)(i,{dimColor:!0,children:[m(e.tokens),` tokens`]})]},t))]},e))]}),v&&process.env.USER_TYPE===`ant`&&(0,X.jsxs)(s,{flexDirection:`column`,marginTop:1,children:[(0,X.jsx)(i,{bold:!0,children:`[ANT-ONLY] Message breakdown`}),(0,X.jsxs)(s,{flexDirection:`column`,marginLeft:1,children:[(0,X.jsxs)(s,{children:[(0,X.jsx)(i,{children:`Tool calls: `}),(0,X.jsxs)(i,{dimColor:!0,children:[m(v.toolCallTokens),` tokens`]})]}),(0,X.jsxs)(s,{children:[(0,X.jsx)(i,{children:`Tool results: `}),(0,X.jsxs)(i,{dimColor:!0,children:[m(v.toolResultTokens),` tokens`]})]}),(0,X.jsxs)(s,{children:[(0,X.jsx)(i,{children:`Attachments: `}),(0,X.jsxs)(i,{dimColor:!0,children:[m(v.attachmentTokens),` tokens`]})]}),(0,X.jsxs)(s,{children:[(0,X.jsx)(i,{children:`Assistant messages (non-tool): `}),(0,X.jsxs)(i,{dimColor:!0,children:[m(v.assistantMessageTokens),` tokens`]})]}),(0,X.jsxs)(s,{children:[(0,X.jsx)(i,{children:`User messages (non-tool-result): `}),(0,X.jsxs)(i,{dimColor:!0,children:[m(v.userMessageTokens),` tokens`]})]})]}),v.toolCallsByType.length>0&&(0,X.jsxs)(s,{flexDirection:`column`,marginTop:1,children:[(0,X.jsx)(i,{bold:!0,children:`[ANT-ONLY] Top tools`}),v.toolCallsByType.slice(0,5).map((e,t)=>(0,X.jsxs)(s,{marginLeft:1,children:[(0,X.jsxs)(i,{children:[`└ `,e.name,`: `]}),(0,X.jsxs)(i,{dimColor:!0,children:[`calls `,m(e.callTokens),`, results `,m(e.resultTokens)]})]},t))]}),v.attachmentsByType.length>0&&(0,X.jsxs)(s,{flexDirection:`column`,marginTop:1,children:[(0,X.jsx)(i,{bold:!0,children:`[ANT-ONLY] Top attachments`}),v.attachmentsByType.slice(0,5).map((e,t)=>(0,X.jsxs)(s,{marginLeft:1,children:[(0,X.jsxs)(i,{children:[`└ `,e.name,`: `]}),(0,X.jsxs)(i,{dimColor:!0,children:[m(e.tokens),` tokens`]})]},t))]})]})]}),(0,X.jsx)(W,{suggestions:ee(e)})]})}var X,Z,Q,te=e((()=>{r(),o(),U(),d(),p(),u(),K(),X=c(),Z=`Autocompact buffer`,Q=[`Project`,`User`,`Managed`,`Plugin`,`Built-in`]}));function ne(e){return h(e)}async function re(e,t){let{messages:n,getAppState:r,options:{mainLoopModel:i,tools:a}}=t,o=ne(n),{messages:s}=await v(o),c=process.stdout.columns||80,l=r();return e(await k((0,$.jsx)(Y,{data:await y(s,i,async()=>l.toolPermissionContext,a,l.agentDefinitions,c,t,void 0,o)}))),null}var $;e((()=>{r(),te(),b(),_(),g(),A(),$=c()}))();export{re as call};
1
+ import{n as e}from"./chunk-DR8-3Aex.js";import{n as t,t as n}from"./figures-gfT9mM8P.js";import{Rn as r,b as i,o as a,t as o,x as s}from"./src-Di342QoJ.js";import{t as c}from"./jsx-runtime-D-D469L8.js";import{Bc as l,Gs as u,Uc as d,Ws as f}from"./paths-CEAy4QCs.js";import{b as p,y as m}from"./startupProfiler-CBcN1Chw.js";import{Po as h,Uo as g,dl as _,iA as v,ll as y,rA as b}from"./loadAgentsDir-DC4jN6-f.js";import{En as x,Gn as S,Kn as C,Mn as w,Un as T,hn as E,mn as D,qn as O}from"./prompt-BHI7PZe4.js";import{n as k,t as A}from"./staticRender-DKFIRhkH.js";function ee(e){let t=[];return j(e,t),M(e,t),P(e,t),F(e,t),I(e,t),t.sort((e,t)=>e.severity===t.severity?(t.savingsTokens??0)-(e.savingsTokens??0):e.severity===`warning`?-1:1),t}function j(e,t){e.percentage>=B&&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 M(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<L||r<R)continue;let a=N(n.name,r,i);a&&t.push(a)}}function N(e,t,n){let r=m(t);switch(e){case C: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 T: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)};case D:return{severity:`info`,title:`WebFetch results using ${r} tokens (${n.toFixed(0)}%)`,detail:`Web page content can be very large. Consider extracting only the specific information needed.`,savingsTokens:Math.floor(t*.4)};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 P(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>=L&&r>=R||a>=z&&n.resultTokens>=R&&t.push({severity:`info`,title:`File reads using ${m(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 F(e,t){let n=e.memoryFiles.reduce((e,t)=>e+t.tokens,0),r=n/e.rawMaxTokens*100;if(r>=V&&n>=H){let i=[...e.memoryFiles].sort((e,t)=>t.tokens-e.tokens).slice(0,3).map(e=>`${l(e.path)} (${m(e.tokens)})`).join(`, `);t.push({severity:`info`,title:`Memory files using ${m(n)} tokens (${r.toFixed(0)}%)`,detail:`Largest: ${i}. Use /memory to review and prune stale entries.`,savingsTokens:Math.floor(n*.3)})}}function I(e,t){!e.isAutoCompactEnabled&&e.percentage>=50&&e.percentage<B&&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 L,R,z,B,V,H,U=e((()=>{O(),w(),S(),E(),d(),p(),L=15,R=1e4,z=5,B=80,V=5,H=5e3}));function W({suggestions:e}){return e.length===0?null:(0,G.jsxs)(s,{flexDirection:`column`,marginTop:1,children:[(0,G.jsx)(i,{bold:!0,children:`Suggestions`}),e.map((e,t)=>(0,G.jsxs)(s,{flexDirection:`column`,marginTop:t===0?0:1,children:[(0,G.jsxs)(s,{children:[(0,G.jsx)(a,{status:e.severity,withSpace:!0}),(0,G.jsx)(i,{bold:!0,children:e.title}),e.savingsTokens?(0,G.jsxs)(i,{dimColor:!0,children:[` `,n.arrowRight,` save ~`,m(e.savingsTokens)]}):null]}),(0,G.jsx)(s,{marginLeft:2,children:(0,G.jsx)(i,{dimColor:!0,children:e.detail})})]},t))]})}var G,K=e((()=>{t(),r(),o(),p(),G=c()}));function q(){return null}function J(e){let t=new Map;for(let n of e){let e=f(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 Q){let r=t.get(e);r&&n.set(e,r)}return n}function Y({data:e}){let{categories:t,totalTokens:n,rawMaxTokens:r,percentage:a,gridRows:o,model:c,memoryFiles:u,mcpTools:d,deferredBuiltinTools:f=[],systemTools:p,systemPromptSections:h,agents:g,skills:_,messageBreakdown:v,cacheHitRate:y,cacheThreshold:b}=e,x=t.filter(e=>e.tokens>0&&e.name!==`Free space`&&e.name!==Z&&!e.isDeferred),S=t.some(e=>e.isDeferred&&e.name.includes(`MCP`)),C=f.length>0,w=t.find(e=>e.name===Z);return(0,X.jsxs)(s,{flexDirection:`column`,paddingLeft:1,children:[(0,X.jsx)(i,{bold:!0,children:`Context Usage`}),(0,X.jsxs)(s,{flexDirection:`row`,gap:2,children:[(0,X.jsx)(s,{flexDirection:`column`,flexShrink:0,children:o.map((e,t)=>(0,X.jsx)(s,{flexDirection:`row`,marginLeft:-1,children:e.map((e,t)=>e.categoryName===`Free space`?(0,X.jsx)(i,{dimColor:!0,children:`⛶ `},t):e.categoryName===Z?(0,X.jsx)(i,{color:e.color,children:`⛝ `},t):(0,X.jsx)(i,{color:e.color,children:e.squareFullness>=.7?`⛁ `:`⛀ `},t))},t))}),(0,X.jsxs)(s,{flexDirection:`column`,gap:0,flexShrink:0,children:[(0,X.jsxs)(i,{dimColor:!0,children:[c,` · `,m(n),`/`,m(r),` tokens (`,a,`%)`]}),(0,X.jsx)(q,{}),y!==void 0&&b!==void 0&&(0,X.jsxs)(i,{color:y<b?`warning`:void 0,children:[`Cache hit rate: `,y.toFixed(0),`%`,y<b?` (below ${b}% threshold)`:``]}),(0,X.jsx)(i,{children:` `}),(0,X.jsx)(i,{dimColor:!0,italic:!0,children:`Estimated usage by category`}),x.map((e,t)=>{let n=m(e.tokens),a=e.isDeferred?`N/A`:`${(e.tokens/r*100).toFixed(1)}%`,o=e.name===Z,c=e.name,l=e.isDeferred?` `:o?`⛝`:`⛁`;return(0,X.jsxs)(s,{children:[(0,X.jsx)(i,{color:e.color,children:l}),(0,X.jsxs)(i,{children:[` `,c,`: `]}),(0,X.jsxs)(i,{dimColor:!0,children:[n,` tokens (`,a,`)`]})]},t)}),(t.find(e=>e.name===`Free space`)?.tokens??0)>0&&(0,X.jsxs)(s,{children:[(0,X.jsx)(i,{dimColor:!0,children:`⛶`}),(0,X.jsx)(i,{children:` Free space: `}),(0,X.jsxs)(i,{dimColor:!0,children:[m(t.find(e=>e.name===`Free space`)?.tokens||0),` (`,((t.find(e=>e.name===`Free space`)?.tokens||0)/r*100).toFixed(1),`%)`]})]}),w&&w.tokens>0&&(0,X.jsxs)(s,{children:[(0,X.jsx)(i,{color:w.color,children:`⛝`}),(0,X.jsxs)(i,{dimColor:!0,children:[` `,w.name,`: `]}),(0,X.jsxs)(i,{dimColor:!0,children:[m(w.tokens),` tokens (`,(w.tokens/r*100).toFixed(1),`%)`]})]})]})]}),(0,X.jsxs)(s,{flexDirection:`column`,marginLeft:-1,children:[d.length>0&&(0,X.jsxs)(s,{flexDirection:`column`,marginTop:1,children:[(0,X.jsxs)(s,{children:[(0,X.jsx)(i,{bold:!0,children:`MCP tools`}),(0,X.jsxs)(i,{dimColor:!0,children:[` · /mcp`,S?` (loaded on-demand)`:``]})]}),d.some(e=>e.isLoaded)&&(0,X.jsxs)(s,{flexDirection:`column`,marginTop:1,children:[(0,X.jsx)(i,{dimColor:!0,children:`Loaded`}),d.filter(e=>e.isLoaded).map((e,t)=>(0,X.jsxs)(s,{children:[(0,X.jsxs)(i,{children:[`└ `,e.name,`: `]}),(0,X.jsxs)(i,{dimColor:!0,children:[m(e.tokens),` tokens`]})]},t))]}),S&&d.some(e=>!e.isLoaded)&&(0,X.jsxs)(s,{flexDirection:`column`,marginTop:1,children:[(0,X.jsx)(i,{dimColor:!0,children:`Available`}),d.filter(e=>!e.isLoaded).map((e,t)=>(0,X.jsx)(s,{children:(0,X.jsxs)(i,{dimColor:!0,children:[`└ `,e.name]})},t))]}),!S&&d.map((e,t)=>(0,X.jsxs)(s,{children:[(0,X.jsxs)(i,{children:[`└ `,e.name,`: `]}),(0,X.jsxs)(i,{dimColor:!0,children:[m(e.tokens),` tokens`]})]},t))]}),(p&&p.length>0||C)&&process.env.USER_TYPE===`ant`&&(0,X.jsxs)(s,{flexDirection:`column`,marginTop:1,children:[(0,X.jsxs)(s,{children:[(0,X.jsx)(i,{bold:!0,children:`[ANT-ONLY] System tools`}),C&&(0,X.jsx)(i,{dimColor:!0,children:` (some loaded on-demand)`})]}),(0,X.jsxs)(s,{flexDirection:`column`,marginTop:1,children:[(0,X.jsx)(i,{dimColor:!0,children:`Loaded`}),p?.map((e,t)=>(0,X.jsxs)(s,{children:[(0,X.jsxs)(i,{children:[`└ `,e.name,`: `]}),(0,X.jsxs)(i,{dimColor:!0,children:[m(e.tokens),` tokens`]})]},`sys-${t}`)),f.filter(e=>e.isLoaded).map((e,t)=>(0,X.jsxs)(s,{children:[(0,X.jsxs)(i,{children:[`└ `,e.name,`: `]}),(0,X.jsxs)(i,{dimColor:!0,children:[m(e.tokens),` tokens`]})]},`def-${t}`))]}),C&&f.some(e=>!e.isLoaded)&&(0,X.jsxs)(s,{flexDirection:`column`,marginTop:1,children:[(0,X.jsx)(i,{dimColor:!0,children:`Available`}),f.filter(e=>!e.isLoaded).map((e,t)=>(0,X.jsx)(s,{children:(0,X.jsxs)(i,{dimColor:!0,children:[`└ `,e.name]})},t))]})]}),h&&h.length>0&&process.env.USER_TYPE===`ant`&&(0,X.jsxs)(s,{flexDirection:`column`,marginTop:1,children:[(0,X.jsx)(i,{bold:!0,children:`[ANT-ONLY] System prompt sections`}),h.map((e,t)=>(0,X.jsxs)(s,{children:[(0,X.jsxs)(i,{children:[`└ `,e.name,`: `]}),(0,X.jsxs)(i,{dimColor:!0,children:[m(e.tokens),` tokens`]})]},t))]}),g.length>0&&(0,X.jsxs)(s,{flexDirection:`column`,marginTop:1,children:[(0,X.jsxs)(s,{children:[(0,X.jsx)(i,{bold:!0,children:`Custom agents`}),(0,X.jsx)(i,{dimColor:!0,children:` · /agents`})]}),Array.from(J(g).entries()).map(([e,t])=>(0,X.jsxs)(s,{flexDirection:`column`,marginTop:1,children:[(0,X.jsx)(i,{dimColor:!0,children:e}),t.map((e,t)=>(0,X.jsxs)(s,{children:[(0,X.jsxs)(i,{children:[`└ `,e.agentType,`: `]}),(0,X.jsxs)(i,{dimColor:!0,children:[m(e.tokens),` tokens`]})]},t))]},e))]}),u.length>0&&(0,X.jsxs)(s,{flexDirection:`column`,marginTop:1,children:[(0,X.jsxs)(s,{children:[(0,X.jsx)(i,{bold:!0,children:`Memory files`}),(0,X.jsx)(i,{dimColor:!0,children:` · /memory`})]}),u.map((e,t)=>(0,X.jsxs)(s,{children:[(0,X.jsxs)(i,{children:[`└ `,l(e.path),`: `]}),(0,X.jsxs)(i,{dimColor:!0,children:[m(e.tokens),` tokens`]})]},t))]}),_&&_.tokens>0&&(0,X.jsxs)(s,{flexDirection:`column`,marginTop:1,children:[(0,X.jsxs)(s,{children:[(0,X.jsx)(i,{bold:!0,children:`Skills`}),(0,X.jsx)(i,{dimColor:!0,children:` · /skills`})]}),Array.from(J(_.skillFrontmatter).entries()).map(([e,t])=>(0,X.jsxs)(s,{flexDirection:`column`,marginTop:1,children:[(0,X.jsx)(i,{dimColor:!0,children:e}),t.map((e,t)=>(0,X.jsxs)(s,{children:[(0,X.jsxs)(i,{children:[`└ `,e.name,`: `]}),(0,X.jsxs)(i,{dimColor:!0,children:[m(e.tokens),` tokens`]})]},t))]},e))]}),v&&process.env.USER_TYPE===`ant`&&(0,X.jsxs)(s,{flexDirection:`column`,marginTop:1,children:[(0,X.jsx)(i,{bold:!0,children:`[ANT-ONLY] Message breakdown`}),(0,X.jsxs)(s,{flexDirection:`column`,marginLeft:1,children:[(0,X.jsxs)(s,{children:[(0,X.jsx)(i,{children:`Tool calls: `}),(0,X.jsxs)(i,{dimColor:!0,children:[m(v.toolCallTokens),` tokens`]})]}),(0,X.jsxs)(s,{children:[(0,X.jsx)(i,{children:`Tool results: `}),(0,X.jsxs)(i,{dimColor:!0,children:[m(v.toolResultTokens),` tokens`]})]}),(0,X.jsxs)(s,{children:[(0,X.jsx)(i,{children:`Attachments: `}),(0,X.jsxs)(i,{dimColor:!0,children:[m(v.attachmentTokens),` tokens`]})]}),(0,X.jsxs)(s,{children:[(0,X.jsx)(i,{children:`Assistant messages (non-tool): `}),(0,X.jsxs)(i,{dimColor:!0,children:[m(v.assistantMessageTokens),` tokens`]})]}),(0,X.jsxs)(s,{children:[(0,X.jsx)(i,{children:`User messages (non-tool-result): `}),(0,X.jsxs)(i,{dimColor:!0,children:[m(v.userMessageTokens),` tokens`]})]})]}),v.toolCallsByType.length>0&&(0,X.jsxs)(s,{flexDirection:`column`,marginTop:1,children:[(0,X.jsx)(i,{bold:!0,children:`[ANT-ONLY] Top tools`}),v.toolCallsByType.slice(0,5).map((e,t)=>(0,X.jsxs)(s,{marginLeft:1,children:[(0,X.jsxs)(i,{children:[`└ `,e.name,`: `]}),(0,X.jsxs)(i,{dimColor:!0,children:[`calls `,m(e.callTokens),`, results `,m(e.resultTokens)]})]},t))]}),v.attachmentsByType.length>0&&(0,X.jsxs)(s,{flexDirection:`column`,marginTop:1,children:[(0,X.jsx)(i,{bold:!0,children:`[ANT-ONLY] Top attachments`}),v.attachmentsByType.slice(0,5).map((e,t)=>(0,X.jsxs)(s,{marginLeft:1,children:[(0,X.jsxs)(i,{children:[`└ `,e.name,`: `]}),(0,X.jsxs)(i,{dimColor:!0,children:[m(e.tokens),` tokens`]})]},t))]})]})]}),(0,X.jsx)(W,{suggestions:ee(e)})]})}var X,Z,Q,te=e((()=>{r(),o(),U(),d(),p(),u(),K(),X=c(),Z=`Autocompact buffer`,Q=[`Project`,`User`,`Managed`,`Plugin`,`Built-in`]}));function ne(e){return h(e)}async function re(e,t){let{messages:n,getAppState:r,options:{mainLoopModel:i,tools:a}}=t,o=ne(n),{messages:s}=await v(o),c=process.stdout.columns||80,l=r();return e(await k((0,$.jsx)(Y,{data:await y(s,i,async()=>l.toolPermissionContext,a,l.agentDefinitions,c,t,void 0,o)}))),null}var $;e((()=>{r(),te(),b(),_(),g(),A(),$=c()}))();export{re as call};
@@ -1,4 +1,4 @@
1
- import{n as e}from"./chunk-DR8-3Aex.js";import{Gs as t,Ws as n}from"./paths-BZjPDxMm.js";import{b as r,y as i}from"./startupProfiler-CBcN1Chw.js";import{Po as a,Uo as o,dl as s,iA as c,ll as l,rA as u}from"./loadAgentsDir-BYWykYwn.js";async function d(e){let{messages:t,getAppState:n,options:{mainLoopModel:r,tools:i,agentDefinitions:o,customSystemPrompt:s,appendSystemPrompt:u}}=e,d=a(t),{messages:f}=await c(d),p=n();return l(f,r,async()=>p.toolPermissionContext,i,o,void 0,{options:{customSystemPrompt:s,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:r,rawMaxTokens:a,percentage:o,model:s,memoryFiles:c,mcpTools:l,agents:u,skills:d,messageBreakdown:f,systemTools:p,systemPromptSections:m}=e,h=`## Context Usage
1
+ import{n as e}from"./chunk-DR8-3Aex.js";import{Gs as t,Ws as n}from"./paths-CEAy4QCs.js";import{b as r,y as i}from"./startupProfiler-CBcN1Chw.js";import{Po as a,Uo as o,dl as s,iA as c,ll as l,rA as u}from"./loadAgentsDir-DC4jN6-f.js";async function d(e){let{messages:t,getAppState:n,options:{mainLoopModel:r,tools:i,agentDefinitions:o,customSystemPrompt:s,appendSystemPrompt:u}}=e,d=a(t),{messages:f}=await c(d),p=n();return l(f,r,async()=>p.toolPermissionContext,i,o,void 0,{options:{customSystemPrompt:s,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:r,rawMaxTokens:a,percentage:o,model:s,memoryFiles:c,mcpTools:l,agents:u,skills:d,messageBreakdown:f,systemTools:p,systemPromptSections:m}=e,h=`## Context Usage
2
2
 
3
3
  `;h+=`**Model:** ${s} \n`,h+=`**Tokens:** ${i(r)} / ${i(a)} (${o}%)\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
@@ -0,0 +1 @@
1
+ import{n as e,r as t,t as n}from"./context-noninteractive-BWbEqad6.js";t();export{n as call,e as collectContextData};
@@ -1 +1 @@
1
- import{a as e,n as t}from"./chunk-DR8-3Aex.js";import{Ct as n,Jn as r,Xn as i,Z as a,cn as o,gn as s,ot as c,qn as l,yn as u}from"./state-sIHsFpDu.js";import{n as d,r as f}from"./analytics-DqMQntaB.js";import{o as p,s as m}from"./log-DSV4Ht5l.js";import{$t as h,$v as g,Ai as ee,Au as _,Cn as v,Di as y,Fn as b,Fr as x,GE as S,In as C,Nn as w,Ob as T,Ot as E,Qv as D,RE as O,Tt as k,_r as A,cv as j,dy as M,gd as N,gi as P,hd as F,ju as I,kb as L,mh as R,mn as z,ph as B,qE as V,sr as H,sv as U,vy as W,zE as G}from"./loadAgentsDir-BYWykYwn.js";import{C as K,y as q}from"./rcDebugLog-ClX1msJX.js";import{l as J,r as Y}from"./commitAttribution-CJXF8wMs.js";import{n as X,t as Z}from"./caches-Bz4yVQyE.js";import{randomUUID as Q}from"crypto";function $(){let e=F();if(!e)return;e.markTranscriptReset?.();let t={type:`status`,subtype:`status`,status:`conversation_cleared`,message:`conversation_cleared`,uuid:Q()};e.writeSdkMessages([t])}async function te({setMessages:t,readFileState:o,discoveredSkillNames:d,loadedNestedMemoryPaths:p,getAppState:_,setAppState:v,setConversationId:C}){let T=z();await h(`clear`,{getAppState:_,setAppState:v,signal:AbortSignal.timeout(T),timeoutMs:T});let E=a();E&&f(`tengu_cache_eviction_hint`,{scope:`conversation_clear`,last_request_id:E});let D=new Set,N=[],F=e=>`isBackgrounded`in e&&e.isBackgrounded===!1;if(_)for(let e of Object.values(_().tasks))F(e)||(I(e)?(D.add(e.agentId),N.push(e)):L(e)&&D.add(e.identity.agentId));t(()=>[]),$();{let{setContextBlocked:t}=(q(),e(K));t(!1)}C&&C(Q()),Z(D),l(null),r(null),i(null),u(),R(c()),o.clear(),d?.clear(),p?.clear(),v&&v(e=>{let t={};for(let[n,r]of Object.entries(e.tasks)){if(!F(r)){t[n]=r;continue}try{r.status===`running`&&(j(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){m(e)}w(n)}return{...e,tasks:t,attribution:Y(),standaloneAgentContext:void 0,fileHistory:{snapshots:[],trackedFiles:new Set,snapshotSequence:0},mcp:{clients:[],tools:[],commands:[],resources:{},pluginReconnectKey:e.mcp.pluginReconnectKey}}}),M(),H(),s({setCurrentAsParent:!0}),process.env.USER_TYPE===`ant`&&process.env.CLAUDE_CODE_SESSION_ID&&(process.env.CLAUDE_CODE_SESSION_ID=n()),await P();for(let e of N)e.status===`running`&&b(e.id,A(S(e.agentId)));{let{saveMode:t}=(x(),e(ee)),{isCoordinatorMode:n}=(G(),e(O));t(n()?`coordinator`:`normal`)}let B=k();B&&y(B);let V=await g(`clear`);V.length>0&&t(()=>V)}var ne=t((()=>{N(),o(),d(),T(),_(),U(),V(),J(),v(),p(),W(),B(),D(),x(),C(),E(),X()}));export{ne as n,te as t};
1
+ import{a as e,n as t}from"./chunk-DR8-3Aex.js";import{Ct as n,Jn as r,Xn as i,Z as a,cn as o,gn as s,ot as c,qn as l,yn as u}from"./state-sIHsFpDu.js";import{n as d,r as f}from"./analytics-DqMQntaB.js";import{o as p,s as m}from"./log-DSV4Ht5l.js";import{$t as h,$v as g,Ai as ee,Au as _,Cn as v,Di as y,Fn as b,Fr as x,GE as S,In as C,Nn as w,Ob as T,Ot as E,Qv as D,RE as O,Tt as k,_r as A,cv as j,dy as M,gd as N,gi as P,hd as F,ju as I,kb as L,mh as R,mn as z,ph as B,qE as V,sr as H,sv as U,vy as W,zE as G}from"./loadAgentsDir-DC4jN6-f.js";import{C as K,y as q}from"./rcDebugLog-C0Bam8V9.js";import{l as J,r as Y}from"./commitAttribution-Djh1ZpYH.js";import{n as X,t as Z}from"./caches-CzEBsMvP.js";import{randomUUID as Q}from"crypto";function $(){let e=F();if(!e)return;e.markTranscriptReset?.();let t={type:`status`,subtype:`status`,status:`conversation_cleared`,message:`conversation_cleared`,uuid:Q()};e.writeSdkMessages([t])}async function te({setMessages:t,readFileState:o,discoveredSkillNames:d,loadedNestedMemoryPaths:p,getAppState:_,setAppState:v,setConversationId:C}){let T=z();await h(`clear`,{getAppState:_,setAppState:v,signal:AbortSignal.timeout(T),timeoutMs:T});let E=a();E&&f(`tengu_cache_eviction_hint`,{scope:`conversation_clear`,last_request_id:E});let D=new Set,N=[],F=e=>`isBackgrounded`in e&&e.isBackgrounded===!1;if(_)for(let e of Object.values(_().tasks))F(e)||(I(e)?(D.add(e.agentId),N.push(e)):L(e)&&D.add(e.identity.agentId));t(()=>[]),$();{let{setContextBlocked:t}=(q(),e(K));t(!1)}C&&C(Q()),Z(D),l(null),r(null),i(null),u(),R(c()),o.clear(),d?.clear(),p?.clear(),v&&v(e=>{let t={};for(let[n,r]of Object.entries(e.tasks)){if(!F(r)){t[n]=r;continue}try{r.status===`running`&&(j(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){m(e)}w(n)}return{...e,tasks:t,attribution:Y(),standaloneAgentContext:void 0,fileHistory:{snapshots:[],trackedFiles:new Set,snapshotSequence:0},mcp:{clients:[],tools:[],commands:[],resources:{},pluginReconnectKey:e.mcp.pluginReconnectKey}}}),M(),H(),s({setCurrentAsParent:!0}),process.env.USER_TYPE===`ant`&&process.env.CLAUDE_CODE_SESSION_ID&&(process.env.CLAUDE_CODE_SESSION_ID=n()),await P();for(let e of N)e.status===`running`&&b(e.id,A(S(e.agentId)));{let{saveMode:t}=(x(),e(ee)),{isCoordinatorMode:n}=(G(),e(O));t(n()?`coordinator`:`normal`)}let B=k();B&&y(B);let V=await g(`clear`);V.length>0&&t(()=>V)}var ne=t((()=>{N(),o(),d(),T(),_(),U(),V(),J(),v(),p(),W(),B(),D(),x(),C(),E(),X()}));export{ne as n,te as t};
@@ -0,0 +1 @@
1
+ import{n as e,t}from"./conversation-DR4MFYYi.js";e();export{t as clearConversation};
@@ -1,4 +1,4 @@
1
- import{n as e,o as t}from"./chunk-DR8-3Aex.js";import{Cn as n,Rn as r,b as i,g as a,h as o,p as s,t as c,tn as l,x as u}from"./src-Di342QoJ.js";import{t as d}from"./jsx-runtime-D-D469L8.js";import{Cc as f,dc as p,yc as m}from"./paths-BZjPDxMm.js";import{n as h,r as g}from"./analytics-DqMQntaB.js";import{o as _,r as v}from"./stringUtils-KZoO4GUd.js";import{Uo as y,aS as b,ko as x,nA as S,ns as C,oS as w,tA as T}from"./loadAgentsDir-BYWykYwn.js";import{tmpdir as E}from"os";import{join as D}from"path";import{mkdir as O,writeFile as k}from"fs/promises";function A(e){let t=T.lexer(C(e)),n=[];for(let e of t)if(e.type===`code`){let t=e;n.push({code:t.text,lang:t.lang})}return n}function j(e){let t=[];for(let n=e.length-1;n>=0&&t.length<V;n--){let r=e[n];if(r?.type!==`assistant`||r.isApiErrorMessage)continue;let i=r.message.content;if(!Array.isArray(i))continue;let a=x(i,`
1
+ import{n as e,o as t}from"./chunk-DR8-3Aex.js";import{Cn as n,Rn as r,b as i,g as a,h as o,p as s,t as c,tn as l,x as u}from"./src-Di342QoJ.js";import{t as d}from"./jsx-runtime-D-D469L8.js";import{Cc as f,dc as p,yc as m}from"./paths-CEAy4QCs.js";import{n as h,r as g}from"./analytics-DqMQntaB.js";import{o as _,r as v}from"./stringUtils-KZoO4GUd.js";import{Uo as y,aS as b,ko as x,nA as S,ns as C,oS as w,tA as T}from"./loadAgentsDir-DC4jN6-f.js";import{tmpdir as E}from"os";import{join as D}from"path";import{mkdir as O,writeFile as k}from"fs/promises";function A(e){let t=T.lexer(C(e)),n=[];for(let e of t)if(e.type===`code`){let t=e;n.push({code:t.text,lang:t.lang})}return n}function j(e){let t=[];for(let n=e.length-1;n>=0&&t.length<V;n--){let r=e[n];if(r?.type!==`assistant`||r.isApiErrorMessage)continue;let i=r.message.content;if(!Array.isArray(i))continue;let a=x(i,`
2
2
 
3
3
  `);a&&t.push(a)}return t}function M(e){if(e){let t=e.replace(/[^a-zA-Z0-9]/g,``);if(t&&t!==`plaintext`)return`.${t}`}return`.txt`}async function N(e,t){let n=D(z,t);return await O(z,{recursive:!0}),await k(n,e,`utf-8`),n}async function P(e,t){let n=await l(e);n&&process.stdout.write(n);let r=v(e,`
4
4
  `)+1,i=e.length;try{return`Copied to clipboard (${i} characters, ${r} lines)\nAlso written to ${await N(e,t)}`}catch{return`Copied to clipboard (${i} characters, ${r} lines)`}}function F(e,t){let r=e.split(`
@@ -1,4 +1,4 @@
1
- import{n as e,t}from"./defineProperty-80gRi2ZW.js";import{Jt as n,on as r}from"./paths-BZjPDxMm.js";import{D as i,E as a,O as o,l as s,p as c}from"./debug-otxXY3j-.js";import{l,u}from"./oauth-CdZEzMww.js";import{i as d,t as f}from"./cliLaunch-Citfs01Q.js";import{resolve as p}from"path";import{existsSync as m,unlinkSync as h}from"fs";import{randomUUID as g}from"crypto";s(),a(),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-80gRi2ZW.js";import{Jt as n,on as r}from"./paths-CEAy4QCs.js";import{D as i,E as a,O as o,l as s,p as c}from"./debug-otxXY3j-.js";import{l,u}from"./oauth-CdZEzMww.js";import{i as d,t as f}from"./cliLaunch-Citfs01Q.js";import{resolve as p}from"path";import{existsSync as m,unlinkSync as h}from"fs";import{randomUUID as g}from"crypto";s(),a(),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{this.proc=await e(),this.reconnectAttempt=0,this.connected=!0,this.startReadLoop(),this.monitorExit(),this.options.onConnected();return}catch(e){c(`[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=i(e)}catch{return}if(!_(t))return;let n=t;if(n.type===`control_request`){let e=n;e.request.subtype===`can_use_tool`?this.options.onPermissionRequest(e.request,e.request_id):(c(`[SSH] Unsupported control request subtype: ${e.request.subtype}`),this.sendErrorResponse(e.request_id,`Unsupported control request subtype: ${e.request.subtype}`));return}n.type!==`control_response`&&n.type!==`keep_alive`&&n.type!==`control_cancel_request`&&n.type!==`streamlined_text`&&n.type!==`streamlined_tool_use_summary`&&!(n.type===`system`&&n.subtype===`post_turn_summary`)&&this.options.onMessage(n)}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}};r(),u(),s();var S=process.platform===`win32`;function C(){let e=process.env.ANTHROPIC_API_KEY;if(e)return{"x-api-key":e};let t=n();return t?.accessToken?{Authorization:`Bearer ${t.accessToken}`}:{}}function w(){return process.env.ANTHROPIC_BASE_URL||l().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}`,a=C();if(Object.keys(a).length===0)return new Response(JSON.stringify({error:`No API credentials available on local machine`}),{status:401,headers:{"content-type":`application/json`}});let o=new Headers(e.headers);for(let[e,t]of Object.entries(a))o.set(e,t);o.delete(`host`),o.delete(`x-auth-nonce`),c(`[SSHAuthProxy] ${e.method} ${r.pathname} -> ${i}`);try{let t=await fetch(i,{method:e.method,headers:o,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 c(`[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 c(`[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 c(`[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}}}s();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(),a=await new Response(n.stderr).text();if(r!==0)throw new A(`SSH probe failed: ${a.trim()||`exit code ${r}`}`);let o=i.split(`
4
4
  `).map(e=>e.trim()).filter(Boolean);c(`[SSHProbe] raw lines: ${JSON.stringify(o)}`);let s=o.findIndex(e=>/^(Linux|Darwin)\s/.test(e));if(s===-1)throw new A(`Could not detect remote platform (uname output missing)`);let l=s>=2&&o[s-2]||null,u=s>=1&&o[s-1]||null,d=u&&/^\d+\.\d+/.test(u)?u:null,f=l!==null&&l.startsWith(`/`),p=o[s+1]||`/`,[m,h]=o[s].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}}s();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:a}=e;if(n!==`linux`&&n!==`darwin`)throw Error(`Remote platform "${n}" is not supported. Only linux and darwin are supported.`);c(`[SSHDeploy] deploying to ${t} (${n}/${r}, v${i})`);let o=L();c(`[SSHDeploy] local binary: ${o}`),a?.(`Creating remote directory...`);let s=await I(t,`mkdir -p ${N}`);if(s.exitCode!==0)throw Error(`Failed to create remote directory: ${s.stderr}`);a?.(`Uploading binary...`);let l=`${N}/${P}`,u=Bun.spawn([`scp`,`-o`,`ConnectTimeout=10`,o,`${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()}`);a?.(`Installing wrapper script...`);let m=await I(t,[`cat > ${N}/${F} << 'WRAPPER'`,`#!/bin/sh`,`exec bun ${N}/${P} "$@"`,`WRAPPER`,`chmod +x ${N}/${F}`].join(`
@@ -0,0 +1 @@
1
+ import{a as e,i as t,n,r}from"./createSession-Csaqw8kb.js";t();export{n as createBridgeSession,r as getBridgeSession,e as updateBridgeSessionTitle};
@@ -1 +1 @@
1
- import{n as e}from"./chunk-DR8-3Aex.js";import{U as t,l as n,p as r,z as i}from"./debug-otxXY3j-.js";import{c as a,d as o,i as s,o as c}from"./debugUtils-l8nsUZ6R.js";async function l({environmentId:e,title:t,events:n,gitRepoUrl:a,branch:o,signal:c,baseUrl:l,getAccessToken:u,permissionMode:d}){let{getClaudeAIOAuthTokens:f}=await import(`./auth-Dm8aWPRh.js`),{getOrganizationUUID:p}=await import(`./client-DvWRsIpi.js`),{getOauthConfig:m}=await import(`./oauth-CmensepG.js`),{getOAuthHeaders:h}=await import(`./api-VMfJpk1G.js`),{parseGitHubRepository:g}=await import(`./detectRepository-BLwSmun2.js`),{getDefaultBranch:_}=await import(`./git-hSvFiuiG.js`),{getMainLoopModel:v}=await import(`./model-VB4ItNVB.js`),{default:y}=await import(`./axios-DLnc2dVy.js`),{isSelfHostedBridge:b}=await import(`./bridgeConfig-CTJBoASk.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-BLwSmun2.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={...t!==void 0&&{title:t},events:n,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: ${i(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,t){let{getClaudeAIOAuthTokens:n}=await import(`./auth-Dm8aWPRh.js`),{getOrganizationUUID:a}=await import(`./client-DvWRsIpi.js`),{getOauthConfig:o}=await import(`./oauth-CmensepG.js`),{getOAuthHeaders:c}=await import(`./api-VMfJpk1G.js`),{default:l}=await import(`./axios-DLnc2dVy.js`),{isSelfHostedBridge:u}=await import(`./bridgeConfig-CTJBoASk.js`),d=t?.getAccessToken?.()??n()?.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=`${t?.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: ${i(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-Dm8aWPRh.js`),{getOrganizationUUID:i}=await import(`./client-DvWRsIpi.js`),{getOauthConfig:a}=await import(`./oauth-CmensepG.js`),{getOAuthHeaders:o}=await import(`./api-VMfJpk1G.js`),{default:c}=await import(`./axios-DLnc2dVy.js`),{isSelfHostedBridge:l}=await import(`./bridgeConfig-CTJBoASk.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,t,n){let{getClaudeAIOAuthTokens:a}=await import(`./auth-Dm8aWPRh.js`),{getOrganizationUUID:c}=await import(`./client-DvWRsIpi.js`),{getOauthConfig:l}=await import(`./oauth-CmensepG.js`),{getOAuthHeaders:u}=await import(`./api-VMfJpk1G.js`),{default:d}=await import(`./axios-DLnc2dVy.js`),{isSelfHostedBridge:f}=await import(`./bridgeConfig-CTJBoASk.js`),p=n?.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),_=`${n?.baseUrl??l().BASE_API_URL}/v1/sessions/${g}`;r(`[bridge] Updating session title: ${g} → ${t}`);try{let e=await d.patch(_,{title:t},{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: ${i(e)}`)}}var p=e((()=>{n(),t(),c(),a()}));export{f as a,p as i,l as n,u as r,d as t};
1
+ import{n as e}from"./chunk-DR8-3Aex.js";import{U as t,l as n,p as r,z as i}from"./debug-otxXY3j-.js";import{c as a,d as o,i as s,o as c}from"./debugUtils-l8nsUZ6R.js";async function l({environmentId:e,title:t,events:n,gitRepoUrl:a,branch:o,signal:c,baseUrl:l,getAccessToken:u,permissionMode:d}){let{getClaudeAIOAuthTokens:f}=await import(`./auth-DVtMm7Hj.js`),{getOrganizationUUID:p}=await import(`./client-BgdjJNnC.js`),{getOauthConfig:m}=await import(`./oauth-CmensepG.js`),{getOAuthHeaders:h}=await import(`./api-CoBZPEi-.js`),{parseGitHubRepository:g}=await import(`./detectRepository-BLwSmun2.js`),{getDefaultBranch:_}=await import(`./git-hSvFiuiG.js`),{getMainLoopModel:v}=await import(`./model-BYSyXf9-.js`),{default:y}=await import(`./axios-DLnc2dVy.js`),{isSelfHostedBridge:b}=await import(`./bridgeConfig-pVTHa_ED.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-BLwSmun2.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={...t!==void 0&&{title:t},events:n,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: ${i(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,t){let{getClaudeAIOAuthTokens:n}=await import(`./auth-DVtMm7Hj.js`),{getOrganizationUUID:a}=await import(`./client-BgdjJNnC.js`),{getOauthConfig:o}=await import(`./oauth-CmensepG.js`),{getOAuthHeaders:c}=await import(`./api-CoBZPEi-.js`),{default:l}=await import(`./axios-DLnc2dVy.js`),{isSelfHostedBridge:u}=await import(`./bridgeConfig-pVTHa_ED.js`),d=t?.getAccessToken?.()??n()?.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=`${t?.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: ${i(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-DVtMm7Hj.js`),{getOrganizationUUID:i}=await import(`./client-BgdjJNnC.js`),{getOauthConfig:a}=await import(`./oauth-CmensepG.js`),{getOAuthHeaders:o}=await import(`./api-CoBZPEi-.js`),{default:c}=await import(`./axios-DLnc2dVy.js`),{isSelfHostedBridge:l}=await import(`./bridgeConfig-pVTHa_ED.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,t,n){let{getClaudeAIOAuthTokens:a}=await import(`./auth-DVtMm7Hj.js`),{getOrganizationUUID:c}=await import(`./client-BgdjJNnC.js`),{getOauthConfig:l}=await import(`./oauth-CmensepG.js`),{getOAuthHeaders:u}=await import(`./api-CoBZPEi-.js`),{default:d}=await import(`./axios-DLnc2dVy.js`),{isSelfHostedBridge:f}=await import(`./bridgeConfig-pVTHa_ED.js`),p=n?.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),_=`${n?.baseUrl??l().BASE_API_URL}/v1/sessions/${g}`;r(`[bridge] Updating session title: ${g} → ${t}`);try{let e=await d.patch(_,{title:t},{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: ${i(e)}`)}}var p=e((()=>{n(),t(),c(),a()}));export{f as a,p as i,l as n,u as r,d as t};