@readmagic/workmate 0.0.19 → 0.0.20

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 (256) hide show
  1. package/dist/chunks/{AddWorkspaceDirectory-9FcHMKgX.js → AddWorkspaceDirectory-BYNvxNrD.js} +1 -1
  2. package/dist/chunks/AgentsMdExternalIncludesDialog-BSSz86ER.js +1 -0
  3. package/dist/chunks/{AgentsMdExternalIncludesDialog-DLnj3JQO.js → AgentsMdExternalIncludesDialog-CMEGV4Md.js} +1 -1
  4. package/dist/chunks/{App-NkBqbDbC.js → App-W_9d1DjK.js} +1 -1
  5. package/dist/chunks/{ApproveApiKey-rgB6AsYD.js → ApproveApiKey-Bf1Rb8Ql.js} +1 -1
  6. package/dist/chunks/ApproveApiKey-wpdvXpFr.js +1 -0
  7. package/dist/chunks/{BackgroundTasksDialog-CcViruUO.js → BackgroundTasksDialog-lGn1Wj1k.js} +1 -1
  8. package/dist/chunks/{BypassPermissionsModeDialog-D254L98G.js → BypassPermissionsModeDialog-CjVjyNf8.js} +1 -1
  9. package/dist/chunks/{DiffDialog-6Srcz3NW.js → DiffDialog-DCpchgp5.js} +1 -1
  10. package/dist/chunks/Doctor-6SjW91rd.js +1 -0
  11. package/dist/chunks/{Doctor-DiNxlXfC.js → Doctor-FPYTivHw.js} +1 -1
  12. package/dist/chunks/{ExitFlow-Bt2De110.js → ExitFlow-Dy8_1D8J.js} +1 -1
  13. package/dist/chunks/{Grove-DC4jyxeB.js → Grove-Dd6rjs5P.js} +1 -1
  14. package/dist/chunks/{HybridTransport-DArmWb1V.js → HybridTransport-CJVkWa2u.js} +1 -1
  15. package/dist/chunks/{InvalidConfigDialog-DFiB0Kzc.js → InvalidConfigDialog-Bisj9ic_.js} +1 -1
  16. package/dist/chunks/{InvalidSettingsDialog-BHNo2__T.js → InvalidSettingsDialog-DyTPNRQR.js} +1 -1
  17. package/dist/chunks/{MCPConnectionManager-CdpO2Tj9.js → MCPConnectionManager-DfyoZaiu.js} +1 -1
  18. package/dist/chunks/{MCPToolListView-Ch4jOk_x.js → MCPToolListView-Dioupv8F.js} +1 -1
  19. package/dist/chunks/{McpParsingWarnings-D4UQ8Q2e.js → McpParsingWarnings-BUlgpZAF.js} +1 -1
  20. package/dist/chunks/{MessageSelector-BgsrdJur.js → MessageSelector-D8fylxPg.js} +1 -1
  21. package/dist/chunks/{Messages-DB1pmDY_.js → Messages-BZDFMYBT.js} +1 -1
  22. package/dist/chunks/{Onboarding-BnjdTwci.js → Onboarding-BKLomZYo.js} +1 -1
  23. package/dist/chunks/{PromptInputFooterSuggestions-Chg9U-BC.js → PromptInputFooterSuggestions-DCum89fF.js} +1 -1
  24. package/dist/chunks/{PromptInputHelpMenu-C0ZSo12s.js → PromptInputHelpMenu-DG2lRqis.js} +1 -1
  25. package/dist/chunks/{QueryEngine-bKlupZpA.js → QueryEngine-CyGHpX7M.js} +1 -1
  26. package/dist/chunks/REPL-BDsz8KIx.js +1 -0
  27. package/dist/chunks/{REPL-Cg8UXYpX.js → REPL-CCBNfZfs.js} +5 -5
  28. package/dist/chunks/{RemoteSessionManager-CRWOHvKf.js → RemoteSessionManager-BfsOv4K6.js} +1 -1
  29. package/dist/chunks/{ResumeConversation-Ld7tYLKO.js → ResumeConversation-pC8NLq0F.js} +1 -1
  30. package/dist/chunks/{SSETransport-pPrlSZNF.js → SSETransport-B3K6eH9I.js} +1 -1
  31. package/dist/chunks/SearchExtraToolsTool-DYoxHo9T.js +1 -0
  32. package/dist/chunks/{Settings-CsOlPcIW.js → Settings-CKaGmKg2.js} +2 -2
  33. package/dist/chunks/{TeleportProgress-Di-PMey7.js → TeleportProgress-CkgSp1cs.js} +1 -1
  34. package/dist/chunks/{TeleportRepoMismatchDialog-CDv1cbo-.js → TeleportRepoMismatchDialog-DdO_rECq.js} +1 -1
  35. package/dist/chunks/{TeleportResumeWrapper-Bmf13tGU.js → TeleportResumeWrapper-BeG4N-2z.js} +1 -1
  36. package/dist/chunks/{ThemePicker-B3AO3_jA.js → ThemePicker-iD9ufy99.js} +1 -1
  37. package/dist/chunks/{TrustDialog-C0aiR_LU.js → TrustDialog-qO5OdQt8.js} +1 -1
  38. package/dist/chunks/{add-dir-w1Ay3861.js → add-dir-C4eSVlZ6.js} +1 -1
  39. package/dist/chunks/{agentDisplay-D01ZlnVX.js → agentDisplay-BM4QG_RX.js} +1 -1
  40. package/dist/chunks/{agents-Bxenhf8S.js → agents-BbDBN5l9.js} +1 -1
  41. package/dist/chunks/{agents-B_hUgPnR.js → agents-D3APE_8d.js} +1 -1
  42. package/dist/chunks/{allErrors-C_iHQOlK.js → allErrors-BkgB7JNK.js} +1 -1
  43. package/dist/chunks/api-BHBK9axp.js +1 -0
  44. package/dist/chunks/{api-C5ULzZny.js → api-DyUWfg3a.js} +1 -1
  45. package/dist/chunks/{auth-DvcZHXGk.js → auth-0rn1U4Eq.js} +1 -1
  46. package/dist/chunks/auth-BEoTPSgC.js +1 -0
  47. package/dist/chunks/auth-BPug7U_u.js +1 -0
  48. package/dist/chunks/backgroundHousekeeping-D7xAhUaE.js +1 -0
  49. package/dist/chunks/{backgroundHousekeeping-BGKR5cdA.js → backgroundHousekeeping-km82qEh0.js} +2 -2
  50. package/dist/chunks/{branch-CqQxCSHG.js → branch-CQ38cx5n.js} +1 -1
  51. package/dist/chunks/{bridgeConfig-MxsnEEPx.js → bridgeConfig-C5L-7KaP.js} +1 -1
  52. package/dist/chunks/bridgeConfig-CJMjDoaP.js +1 -0
  53. package/dist/chunks/{bridgeMessaging-Bx5pkkkx.js → bridgeMessaging-DVC3qj-C.js} +1 -1
  54. package/dist/chunks/{bridgeStatusUtil-B9EcQksI.js → bridgeStatusUtil-Cex6VowM.js} +1 -1
  55. package/dist/chunks/{btw-DeznoRrw.js → btw-_P96ffHR.js} +1 -1
  56. package/dist/chunks/caches-DH-q8Fjf.js +1 -0
  57. package/dist/chunks/caches-Dq0pJFDP.js +1 -0
  58. package/dist/chunks/{ccrClient-CimQTd0b.js → ccrClient-DO563xlf.js} +1 -1
  59. package/dist/chunks/{clear-KvoD-lFN.js → clear-DmqQBNKg.js} +1 -1
  60. package/dist/chunks/client-C19cqYQS.js +1 -0
  61. package/dist/chunks/commands-BkpqHY9F.js +1 -0
  62. package/dist/chunks/{compact-Dgzve3dI.js → compact-DuVIvqMu.js} +1 -1
  63. package/dist/chunks/config-DMP6-Ccr.js +1 -0
  64. package/dist/chunks/{context-Dz-bbYCw.js → context-DjgMzIfe.js} +1 -1
  65. package/dist/chunks/{context-noninteractive-ApbVPU86.js → context-noninteractive-BzDVMnWC.js} +1 -1
  66. package/dist/chunks/context-noninteractive-DV7bIJCm.js +1 -0
  67. package/dist/chunks/{conversation-CJ-d0O-U.js → conversation-BBOE_EoE.js} +1 -1
  68. package/dist/chunks/conversation-WxH5pb2z.js +1 -0
  69. package/dist/chunks/{createSSHSession-DOz_Ox1_.js → createSSHSession-LVGVXHXL.js} +1 -1
  70. package/dist/chunks/createSession-BUzna9-E.js +1 -0
  71. package/dist/chunks/{createSession-yR87Rhiv.js → createSession-Dgwxk1WA.js} +1 -1
  72. package/dist/chunks/{crossProjectResume-DNnZo3gU.js → crossProjectResume-6B2NYy8a.js} +1 -1
  73. package/dist/chunks/{datadog-DBgIEaEd.js → datadog-Bc6wkPne.js} +1 -1
  74. package/dist/chunks/{diff-qOom_T1G.js → diff-DIg66U_d.js} +1 -1
  75. package/dist/chunks/doctor-BhUmhHQU.js +1 -0
  76. package/dist/chunks/{entry-EmOA7oWN.js → entry-B-Y-AYeK.js} +1 -1
  77. package/dist/chunks/{esm-DBMVQDVv.js → esm-CvHtYRrr.js} +1 -1
  78. package/dist/chunks/{exit-DDrAFCzE.js → exit-CW2eqUrR.js} +1 -1
  79. package/dist/chunks/{extraUsage-DylXI7Fc.js → extraUsage-CkTon7ib.js} +1 -1
  80. package/dist/chunks/extractMemories-CfmbvayQ.js +1 -0
  81. package/dist/chunks/fast-ByahC7Gw.js +1 -0
  82. package/dist/chunks/{fast-BCkhj9Dq.js → fast-xtIP4u4y.js} +1 -1
  83. package/dist/chunks/fetchModelList-D9aePIPW.js +1 -0
  84. package/dist/chunks/{fetchModelList-BbjuFHQT.js → fetchModelList-Dy-x4h3G.js} +1 -1
  85. package/dist/chunks/{fileSuggestions-Ct7vKEpR.js → fileSuggestions-CFkJktgc.js} +1 -1
  86. package/dist/chunks/firstPartyEventLogger-Bt9iG9xk.js +1 -0
  87. package/dist/chunks/{firstPartyEventLogger-CxUuXQhL.js → firstPartyEventLogger-DqGSujCz.js} +2 -2
  88. package/dist/chunks/{flushGate-BZe_QwEz.js → flushGate-BjKW7PFC.js} +1 -1
  89. package/dist/chunks/{gemini-8sSwOtEf.js → gemini-NnmxBoEp.js} +1 -1
  90. package/dist/chunks/{generateSessionName-vT1khubt.js → generateSessionName-EpqGW-T2.js} +1 -1
  91. package/dist/chunks/{goal-CznQA1n1.js → goal-DbS8yJfB.js} +1 -1
  92. package/dist/chunks/{grok-cEzUsG-s.js → grok-BxZ4vTDw.js} +1 -1
  93. package/dist/chunks/{grove--HtQL4QZ.js → grove-CYE1Cfcz.js} +1 -1
  94. package/dist/chunks/{help-B6A_kDQA.js → help-DatnwM25.js} +1 -1
  95. package/dist/chunks/{hooks-CN5hLrhi.js → hooks-7iyENdDG.js} +1 -1
  96. package/dist/chunks/hooks-DjbqtbUV.js +1 -0
  97. package/dist/chunks/{initReplBridge-BJhmlcVt.js → initReplBridge-BEZW5PEY.js} +1 -1
  98. package/dist/chunks/{install-DUOtI2Hq.js → install-DJukI-kL.js} +1 -1
  99. package/dist/chunks/{instrumentation-DpgB3GFx.js → instrumentation-2HH15DPu.js} +3 -3
  100. package/dist/chunks/{job-DDoX1iFe.js → job-CXz7SLZp.js} +1 -1
  101. package/dist/chunks/{keybindings-BGTuYfk-.js → keybindings-C9l5il16.js} +1 -1
  102. package/dist/chunks/{launchLocalMemory-CoWeLNeP.js → launchLocalMemory-BfGenqj1.js} +1 -1
  103. package/dist/chunks/{launchOnboarding-CTIBGSLV.js → launchOnboarding-DjMmXeQE.js} +1 -1
  104. package/dist/chunks/{loadAgentsDir-DXOkUcW3.js → loadAgentsDir-DaNpxaO-.js} +587 -612
  105. package/dist/chunks/loadAgentsDir-DcI-8FQF.js +1 -0
  106. package/dist/chunks/{loadPluginHooks-DrNVtTBq.js → loadPluginHooks-CGgpcyEC.js} +1 -1
  107. package/dist/chunks/{localSearch-DnT21UkF.js → localSearch-C2SZ9bGW.js} +1 -1
  108. package/dist/chunks/localSearch-CTTwYTU1.js +1 -0
  109. package/dist/chunks/{logoUtils-YwL3izJt.js → logoUtils-CbIqOFrX.js} +1 -1
  110. package/dist/chunks/{magicDocs-rxv0rR8E.js → magicDocs-CrTwULyJ.js} +1 -1
  111. package/dist/chunks/{main-BOvY4O6D.js → main-bJXadFi0.js} +10 -10
  112. package/dist/chunks/{managedEnv-CpgCYISH.js → managedEnv-CUsdYhAI.js} +1 -1
  113. package/dist/chunks/managedEnv-DXeaUDSK.js +1 -0
  114. package/dist/chunks/{mappers-DYtq2XVS.js → mappers-_B-s9fNz.js} +1 -1
  115. package/dist/chunks/{mcp-BoU3TNFs.js → mcp-BbbYzWpy.js} +2 -2
  116. package/dist/chunks/{mcp-BPvcoKDY.js → mcp-D91sH9a8.js} +1 -1
  117. package/dist/chunks/{mcp-BfqsHRx0.js → mcp-Dx-zgUgu.js} +1 -1
  118. package/dist/chunks/{memory-BPKRdkBb.js → memory-BeL7ui9m.js} +1 -1
  119. package/dist/chunks/{mode-CXpXux2s.js → mode-D695kgLI.js} +1 -1
  120. package/dist/chunks/model-DX0TtzqX.js +1 -0
  121. package/dist/chunks/{model-Cxx3suBa.js → model-Do0f476p.js} +1 -1
  122. package/dist/chunks/{model-CxPYKiW1.js → model-DpcM8dz5.js} +1 -1
  123. package/dist/chunks/{modelOptions-BqBHEyiR.js → modelOptions-B3nis9cC.js} +1 -1
  124. package/dist/chunks/{src-l6_O0K-a.js → modifiersNative-BYHdmWw1.js} +1 -1
  125. package/dist/chunks/modifiersNative-D7nm70eq.js +1 -0
  126. package/dist/chunks/{nativeInstaller-CaXwRpoR.js → nativeInstaller-CymO8TNe.js} +1 -1
  127. package/dist/chunks/{omit-DZUxsClb.js → omit-DO61BHZu.js} +1 -1
  128. package/dist/chunks/{onChangeAppState-qHXqufwy.js → onChangeAppState-vKml_lit.js} +1 -1
  129. package/dist/chunks/{openai-_FQ9EhuR.js → openai-DdupGVdC.js} +1 -1
  130. package/dist/chunks/{partition-BgwHlPsO.js → partition-BivH9MBJ.js} +1 -1
  131. package/dist/chunks/{permissions-Dv5d5Nu3.js → permissions-C9iqR4_N.js} +1 -1
  132. package/dist/chunks/{pidLock-CEhbTkBE.js → pidLock-DiKz5Tza.js} +2 -2
  133. package/dist/chunks/{plan-DVPBW5OS.js → plan-KDN5IGWY.js} +1 -1
  134. package/dist/chunks/{plugin-Bh2eBwLW.js → plugin-D0rzUb8E.js} +1 -1
  135. package/dist/chunks/{pluginAutoupdate-C2YbEHrP.js → pluginAutoupdate-C2xTKLR_.js} +1 -1
  136. package/dist/chunks/{pluginBlocklist-B2NAKaB9.js → pluginBlocklist-xdiUmUpt.js} +1 -1
  137. package/dist/chunks/{pluginCliCommands-Cw5TrYYb.js → pluginCliCommands-CIDDvVN7.js} +1 -1
  138. package/dist/chunks/{pluginFlagging-BDTgCYuC.js → pluginFlagging-DRA0m76J.js} +1 -1
  139. package/dist/chunks/{pluginOperations-BBwGEdfC.js → pluginOperations-BEYsarAn.js} +1 -1
  140. package/dist/chunks/{pluginStartupCheck-DhhMk3dA.js → pluginStartupCheck-BF1N4Lih.js} +1 -1
  141. package/dist/chunks/pluginStartupCheck-DVkI4pqo.js +1 -0
  142. package/dist/chunks/{plugins-r0h93GT_.js → plugins-CWWU4BKs.js} +1 -1
  143. package/dist/chunks/{print-CDzhHi2F.js → print-B5H2xbBS.js} +3 -3
  144. package/dist/chunks/{processBashCommand-DmdCAWOR.js → processBashCommand-EQ9EWaRV.js} +1 -1
  145. package/dist/chunks/{processSlashCommand-B43TkiaI.js → processSlashCommand-C4PKNyFT.js} +1 -1
  146. package/dist/chunks/{prompt-DEioJrx_.js → prompt-8u06WVES.js} +1 -1
  147. package/dist/chunks/prompt-B9sDzLPK.js +1 -0
  148. package/dist/chunks/prompt-WsoTRhoh.js +1 -0
  149. package/dist/chunks/{promptEditor-eJzbtNn4.js → promptEditor-Cr4w-4Bz.js} +1 -1
  150. package/dist/chunks/{protocolHandler-C-CFTcUJ.js → protocolHandler-DzHVaPl3.js} +2 -2
  151. package/dist/chunks/{reconciler-DZP4dJJG.js → reconciler-RIKmaPg7.js} +1 -1
  152. package/dist/chunks/{refresh-vaY-Sr80.js → refresh-CCSCAjgz.js} +1 -1
  153. package/dist/chunks/registerProtocol-C0IlPEoa.js +1 -0
  154. package/dist/chunks/{reload-plugins-m9CzoIxu.js → reload-plugins-DC-tbXVv.js} +1 -1
  155. package/dist/chunks/{remoteBridgeCore-C4vSr1gp.js → remoteBridgeCore-NGTnhQgw.js} +1 -1
  156. package/dist/chunks/{remoteManagedSettings-6RAHPt_g.js → remoteManagedSettings-BoOYHzYP.js} +1 -1
  157. package/dist/chunks/{rename-DmauGVBX.js → rename-DS1AmW-F.js} +1 -1
  158. package/dist/chunks/{resume-ut_pBrLN.js → resume-Cf5PSoPw.js} +1 -1
  159. package/dist/chunks/{runtimeObserver-CSroopId.js → runtimeObserver-DzesbvgI.js} +1 -1
  160. package/dist/chunks/{runtimeObserver-C2vjqtCE.js → runtimeObserver-L6041elO.js} +2 -2
  161. package/dist/chunks/sandbox-adapter-Z4Phj31K.js +1 -0
  162. package/dist/chunks/{sandbox-toggle-BJKd1ZYk.js → sandbox-toggle-COZE8Lo4.js} +1 -1
  163. package/dist/chunks/sanitization-DV-94a9Z.js +1 -0
  164. package/dist/chunks/searchExtraTools-CvkRbL2m.js +1 -0
  165. package/dist/chunks/{session-DTin6hOR.js → session-BvA99K4j.js} +1 -1
  166. package/dist/chunks/sessionFileAccessHooks-6XfAf6ke.js +1 -0
  167. package/dist/chunks/{sessionObserver-iAJLH92a.js → sessionObserver-0D8xFoRK.js} +1 -1
  168. package/dist/chunks/sessionObserver-CRWUBJEY.js +1 -0
  169. package/dist/chunks/{sessionState-DAcub-HK.js → sessionState-CQhbGfmh.js} +1 -1
  170. package/dist/chunks/sessionStorage-DqEuxDlb.js +1 -0
  171. package/dist/chunks/{sessionTracing-Dvi520eN.js → sessionTracing-BoOZsXU2.js} +1 -1
  172. package/dist/chunks/{settingsSync-aHn3p-6J.js → settingsSync-rkWmClKS.js} +1 -1
  173. package/dist/chunks/{setup-CK3ybjjM.js → setup-D8L275fT.js} +2 -2
  174. package/dist/chunks/{shadowedRuleDetection-BL7dEv-u.js → shadowedRuleDetection-Cy9tsuKc.js} +1 -1
  175. package/dist/chunks/{sideQuestion-Ct87yvOR.js → sideQuestion-Ds7Elgs4.js} +1 -1
  176. package/dist/chunks/{sinks-Bmn3li0M.js → sinks-BXX72cbf.js} +1 -1
  177. package/dist/chunks/sinks-DMp6uEzM.js +1 -0
  178. package/dist/chunks/{skillChangeDetector-Bco3UoeW.js → skillChangeDetector-CtithJ4a.js} +1 -1
  179. package/dist/chunks/{skillGapStore-MtlRyYmT.js → skillGapStore-BxCxKPev.js} +2 -2
  180. package/dist/chunks/{skillLifecycle-Drs6gEv9.js → skillLifecycle-CfyNC3sW.js} +2 -2
  181. package/dist/chunks/{skillSearchPanel-DkvmjNaw.js → skillSearchPanel-CMNJFIEC.js} +2 -2
  182. package/dist/chunks/{skills-axToWEo0.js → skills-DXMk-498.js} +1 -1
  183. package/dist/chunks/{status-CGp4uRlH.js → status-CFrLuGbf.js} +1 -1
  184. package/dist/chunks/status-D5OCkMZG.js +1 -0
  185. package/dist/chunks/{statusNoticeHelpers-BrN_2q7H.js → statusNoticeHelpers-CZoOse-_.js} +1 -1
  186. package/dist/chunks/switcher-AiMcRzoi.js +1 -0
  187. package/dist/chunks/{switcher-99gm2vpe.js → switcher-DQF5ZNal.js} +1 -1
  188. package/dist/chunks/{syncCache-B3OVvp8K.js → syncCache-qWJ_VfBo.js} +1 -1
  189. package/dist/chunks/{tasks-t5zT_D32.js → tasks-C8pb6ftc.js} +1 -1
  190. package/dist/chunks/{teleport-CvX_nUjQ.js → teleport-Bi_1VFIZ.js} +1 -1
  191. package/dist/chunks/{templateJobs-Bm8bovHx.js → templateJobs-DJ4dcfcL.js} +1 -1
  192. package/dist/chunks/{theme-DzaSXOpQ.js → theme-CEKOCSLw.js} +1 -1
  193. package/dist/chunks/{toolEventObserver-C_nHI27x.js → toolEventObserver-D2nk8ZbW.js} +1 -1
  194. package/dist/chunks/{toolPool-CgKK0K8f.js → toolPool-Df5iUqJ-.js} +1 -1
  195. package/dist/chunks/{trustedDevice-Bb7O8_tj.js → trustedDevice-CB6rNzl-.js} +1 -1
  196. package/dist/chunks/trustedDevice-DXGePUAC.js +1 -0
  197. package/dist/chunks/{useExitOnCtrlCDWithKeybindings-D0uqGxGw.js → useExitOnCtrlCDWithKeybindings-Bw0mlTT9.js} +1 -1
  198. package/dist/chunks/useMainLoopModel-CIG2cjS2.js +1 -0
  199. package/dist/chunks/{useManagePlugins-ITVFO9dz.js → useManagePlugins-MSHw-qHx.js} +1 -1
  200. package/dist/chunks/{useMergedTools-rQ19rFvH.js → useMergedTools-Bb-INJa2.js} +1 -1
  201. package/dist/chunks/{useSearchInput-CXTa-leH.js → useSearchInput-QL_VtdJD.js} +1 -1
  202. package/dist/chunks/{useSettingsErrors-Xc6RYjYF.js → useSettingsErrors-Dvi6zLCr.js} +1 -1
  203. package/dist/chunks/{userAgent-CJ5Rp9kc.js → userAgent-i-oGzf40.js} +1 -1
  204. package/dist/chunks/{util-CD3ar4of.js → util-CLQvtXuD.js} +1 -1
  205. package/dist/chunks/{validatePlugin-CxrlCKc1.js → validatePlugin-1mTZ3TJR.js} +1 -1
  206. package/dist/chunks/{workerRegistry-BGJtgrko.js → workerRegistry-BjxoZ12l.js} +2 -2
  207. package/dist/chunks/worktree-DpksgxdF.js +1 -0
  208. package/dist/cli.js +1 -1
  209. package/package.json +1 -5
  210. package/dist/chunks/AgentsMdExternalIncludesDialog-Bny8WDwC.js +0 -1
  211. package/dist/chunks/ApproveApiKey-BKzkEkW-.js +0 -1
  212. package/dist/chunks/Doctor-DYEdLRxR.js +0 -1
  213. package/dist/chunks/REPL-yzvMFfaU.js +0 -1
  214. package/dist/chunks/SearchExtraToolsTool-CdgQlm--.js +0 -1
  215. package/dist/chunks/api-CB3e0De0.js +0 -1
  216. package/dist/chunks/attributionHooks-C0aXyx9L.js +0 -1
  217. package/dist/chunks/auth-CsYEYXBO.js +0 -1
  218. package/dist/chunks/auth-CubXYcRl.js +0 -1
  219. package/dist/chunks/backgroundHousekeeping-CykbtljP.js +0 -1
  220. package/dist/chunks/bridgeConfig-Cp2x_wtE.js +0 -1
  221. package/dist/chunks/caches-BiVRgePi.js +0 -1
  222. package/dist/chunks/caches-CGzKSWiP.js +0 -1
  223. package/dist/chunks/client-CmnPWgLq.js +0 -1
  224. package/dist/chunks/commands-CrzVgHxp.js +0 -1
  225. package/dist/chunks/config-Df8jooTW.js +0 -1
  226. package/dist/chunks/context-noninteractive-m4O3VtG7.js +0 -1
  227. package/dist/chunks/conversation-BYBX07j8.js +0 -1
  228. package/dist/chunks/createSession-C_-ZEQT5.js +0 -1
  229. package/dist/chunks/doctor-CflXjqVK.js +0 -1
  230. package/dist/chunks/extractMemories-B_8wZpXA.js +0 -1
  231. package/dist/chunks/fast-4ajfJv-M.js +0 -1
  232. package/dist/chunks/fetchModelList-V8_e2O1N.js +0 -1
  233. package/dist/chunks/firstPartyEventLogger-YQm0DoVu.js +0 -1
  234. package/dist/chunks/hooks-CJY5Vfy6.js +0 -1
  235. package/dist/chunks/loadAgentsDir-Dxz1vp3F.js +0 -1
  236. package/dist/chunks/localSearch-CCs5fOd_.js +0 -1
  237. package/dist/chunks/managedEnv-CrnBYTtQ.js +0 -1
  238. package/dist/chunks/model-aEJ54cMA.js +0 -1
  239. package/dist/chunks/pluginStartupCheck-CHx379_R.js +0 -1
  240. package/dist/chunks/postCommitAttribution-DoSP9wZD.js +0 -1
  241. package/dist/chunks/prompt-C50mDqWv.js +0 -1
  242. package/dist/chunks/prompt-WGH9CcXh.js +0 -1
  243. package/dist/chunks/registerProtocol-Xsq4ldwg.js +0 -1
  244. package/dist/chunks/sandbox-adapter-CL0qdcxn.js +0 -1
  245. package/dist/chunks/searchExtraTools-ByWuNCGo.js +0 -1
  246. package/dist/chunks/sessionFileAccessHooks-DorzHolr.js +0 -1
  247. package/dist/chunks/sessionObserver-Dy6NFlzL.js +0 -1
  248. package/dist/chunks/sessionStorage-DItJMkwx.js +0 -1
  249. package/dist/chunks/sinks-QQ_6Op7q.js +0 -1
  250. package/dist/chunks/src-DPUAq5Ty.js +0 -1
  251. package/dist/chunks/status-3uevwSMo.js +0 -1
  252. package/dist/chunks/switcher-DJDxjLPQ.js +0 -1
  253. package/dist/chunks/trustedDevice-C2gnF9Lc.js +0 -1
  254. package/dist/chunks/useMainLoopModel-BGPOmBkl.js +0 -1
  255. package/dist/chunks/worktree-CanG5GhE.js +0 -1
  256. /package/dist/chunks/{src-DLz3FZm1.js → urlHandler-DLz3FZm1.js} +0 -0
@@ -1 +1 @@
1
- import{o as e}from"./envUtils-DcaKZlRU.js";import{n as t,t as n}from"./defineProperty-C-QyHrDq.js";import{P as r,R as i,S as a,c as o,i as s,x as c}from"./debug-D58GQBDG.js";import{B as l,F as u,H as d,I as f,O as p,b as m,g as h,m as g,q as _}from"./log-CZ7ploQm.js";import{n as v,r as y}from"./analytics-DJobLaWP.js";import{T as b,et as x}from"./sessionState-DAcub-HK.js";import{n as S,t as C}from"./rcDebugLog-DSchf3Hs.js";import{t as w}from"./controlMessageCompat-IFu4Gc1y.js";import{randomUUID as T}from"crypto";e();async function E(){return!1}function D(){return!1}function O(){return!0}function k(){return null}v(),b(),s(),C(),g(),i(),c(),_(),t();function A(e){return typeof e==`object`&&!!e&&`type`in e&&typeof e.type==`string`}function j(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`control_response`&&`response`in e}function M(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`control_request`&&`request_id`in e&&`request`in e}function N(e){return(e.type===`user`||e.type===`assistant`)&&e.isVirtual?!1:e.type===`user`||e.type===`assistant`||e.type===`system`&&e.subtype===`local_command`}function P(e){if(e.type!==`user`||e.isMeta||e.toolUseResult||e.isCompactSummary||e.origin&&e.origin.kind!==`human`)return;let t=e.message.content,n;if(typeof t==`string`)n=t;else for(let e of t??[])if(e.type===`text`){n=e.text;break}if(n)return h(n)||void 0}var F=`system-reminder`,I=/\s*<([a-z][\w-]*)(?:\s[^>]*)?>[\s\S]*?<\/\1>\s*/gy,L=new Set([m,p,u,f,l,d]);function R(e){let t=e.message?.content;return typeof t==`string`?t:Array.isArray(t)?t.filter(e=>!!e&&typeof e==`object`&&e.type===`text`&&typeof e.text==`string`).map(e=>e.text).join(``):``}function z(e){let t=e.trim();if(!t)return null;I.lastIndex=0;let n=[];for(;I.lastIndex<t.length;){let e=I.exec(t);if(!e)return null;n.push(e[1])}return n.length>0?n:null}function B(e){if(e.type!==`user`||e.isVisibleInTranscriptOnly)return!1;if(e.toolUseResult!==void 0||!e.isMeta)return!0;let t=z(R(e));return!t||t.some(e=>e!==`local-command-caveat`&&e!==F&&L.has(e))}function V(e){return e.some(B)}function H(e,t,n,i,s,c){try{let r=w(a(e));if(j(r)){o(`[bridge:repl] Ingress message type=control_response`),s?.(r);return}if(M(r)){o(`[bridge:repl] Inbound control_request subtype=${r.request.subtype}`),c?.(r);return}if(!A(r))return;let l=`uuid`in r&&typeof r.uuid==`string`?r.uuid:void 0;if(l&&t.has(l)){o(`[bridge:repl] Ignoring echo: type=${r.type} uuid=${l}`);return}if(l&&n.has(l)){o(`[bridge:repl] Ignoring re-delivered inbound: type=${r.type} uuid=${l}`);return}o(`[bridge:repl] Ingress message type=${r.type}${l?` uuid=${l}`:``}`),r.type===`user`?(l&&n.add(l),y(`tengu_bridge_message_received`,{is_repl:!0}),i?.(r)):o(`[bridge:repl] Ignoring non-user inbound message: type=${r.type}`)}catch(e){o(`[bridge:repl] Failed to parse ingress message: ${r(e)}`)}}var U=`This session is outbound-only. Enable Remote Control locally to allow inbound control.`;function W(e,t){let{transport:n,sessionId:r,outboundOnly:i,onInterrupt:a,onSetModel:s,onSetMaxThinkingTokens:c,onSetPermissionMode:l}=t;if(!n){o(`[bridge:repl] Cannot respond to control_request: transport not configured`);return}let u,d=e.request;if(i&&d.subtype!==`initialize`){u={type:`control_response`,response:{subtype:`error`,request_id:e.request_id,error:U}};let t={...u,session_id:r};n.write(t),o(`[bridge:repl] Rejected ${d.subtype} (outbound-only) request_id=${e.request_id}`);return}switch(d.subtype){case`initialize`:u={type:`control_response`,response:{subtype:`success`,request_id:e.request_id,response:{commands:[],output_style:`normal`,available_output_styles:[`normal`],models:[],account:{},pid:process.pid}}};break;case`set_model`:s?.(d.model),u={type:`control_response`,response:{subtype:`success`,request_id:e.request_id}};break;case`set_max_thinking_tokens`:c?.(d.max_thinking_tokens??null),u={type:`control_response`,response:{subtype:`success`,request_id:e.request_id}};break;case`set_permission_mode`:{let t=l?.(d.mode)??{ok:!1,error:`set_permission_mode is not supported in this context (onSetPermissionMode callback not registered)`};u=t.ok?{type:`control_response`,response:{subtype:`success`,request_id:e.request_id}}:{type:`control_response`,response:{subtype:`error`,request_id:e.request_id,error:t.error}};break}case`interrupt`:a?.(),u={type:`control_response`,response:{subtype:`success`,request_id:e.request_id}};break;default:u={type:`control_response`,response:{subtype:`error`,request_id:e.request_id,error:`REPL bridge does not handle control_request subtype: ${d.subtype}`}}}let f={...u,session_id:r};n.write(f),S(`control_response: subtype=${d.subtype} request_id=${e.request_id} result=${u.response.subtype}`),o(`[bridge:repl] Sent control_response for ${d.subtype} request_id=${e.request_id} result=${u.response.subtype}`)}function G(e){return{type:`result_success`,subtype:`success`,duration_ms:0,duration_api_ms:0,is_error:!1,num_turns:0,result:``,stop_reason:null,total_cost_usd:0,usage:{...x},modelUsage:{},permission_denials:[],session_id:e,uuid:T()}}var K=class{constructor(e){n(this,`capacity`,void 0),n(this,`ring`,void 0),n(this,`set`,new Set),n(this,`writeIdx`,0),this.capacity=e,this.ring=Array(e)}add(e){if(this.set.has(e))return;let t=this.ring[this.writeIdx];t!==void 0&&this.set.delete(t),this.ring[this.writeIdx]=e,this.set.add(e),this.writeIdx=(this.writeIdx+1)%this.capacity}has(e){return this.set.has(e)}clear(){this.set.clear(),this.ring.fill(void 0),this.writeIdx=0}};export{N as a,V as c,O as d,D as f,W as i,k as l,P as n,G as o,H as r,B as s,K as t,E as u};
1
+ import{o as e}from"./envUtils-DcaKZlRU.js";import{n as t,t as n}from"./defineProperty-C-QyHrDq.js";import{P as r,R as i,S as a,c as o,i as s,x as c}from"./debug-D58GQBDG.js";import{B as l,F as u,H as d,I as f,O as p,b as m,g as h,m as g,q as _}from"./log-CZ7ploQm.js";import{n as v,r as y}from"./analytics-DJobLaWP.js";import{T as b,et as x}from"./sessionState-CQhbGfmh.js";import{n as S,t as C}from"./rcDebugLog-DSchf3Hs.js";import{t as w}from"./controlMessageCompat-IFu4Gc1y.js";import{randomUUID as T}from"crypto";e();async function E(){return!1}function D(){return!1}function O(){return!0}function k(){return null}v(),b(),s(),C(),g(),i(),c(),_(),t();function A(e){return typeof e==`object`&&!!e&&`type`in e&&typeof e.type==`string`}function j(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`control_response`&&`response`in e}function M(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`control_request`&&`request_id`in e&&`request`in e}function N(e){return(e.type===`user`||e.type===`assistant`)&&e.isVirtual?!1:e.type===`user`||e.type===`assistant`||e.type===`system`&&e.subtype===`local_command`}function P(e){if(e.type!==`user`||e.isMeta||e.toolUseResult||e.isCompactSummary||e.origin&&e.origin.kind!==`human`)return;let t=e.message.content,n;if(typeof t==`string`)n=t;else for(let e of t??[])if(e.type===`text`){n=e.text;break}if(n)return h(n)||void 0}var F=`system-reminder`,I=/\s*<([a-z][\w-]*)(?:\s[^>]*)?>[\s\S]*?<\/\1>\s*/gy,L=new Set([m,p,u,f,l,d]);function R(e){let t=e.message?.content;return typeof t==`string`?t:Array.isArray(t)?t.filter(e=>!!e&&typeof e==`object`&&e.type===`text`&&typeof e.text==`string`).map(e=>e.text).join(``):``}function z(e){let t=e.trim();if(!t)return null;I.lastIndex=0;let n=[];for(;I.lastIndex<t.length;){let e=I.exec(t);if(!e)return null;n.push(e[1])}return n.length>0?n:null}function B(e){if(e.type!==`user`||e.isVisibleInTranscriptOnly)return!1;if(e.toolUseResult!==void 0||!e.isMeta)return!0;let t=z(R(e));return!t||t.some(e=>e!==`local-command-caveat`&&e!==F&&L.has(e))}function V(e){return e.some(B)}function H(e,t,n,i,s,c){try{let r=w(a(e));if(j(r)){o(`[bridge:repl] Ingress message type=control_response`),s?.(r);return}if(M(r)){o(`[bridge:repl] Inbound control_request subtype=${r.request.subtype}`),c?.(r);return}if(!A(r))return;let l=`uuid`in r&&typeof r.uuid==`string`?r.uuid:void 0;if(l&&t.has(l)){o(`[bridge:repl] Ignoring echo: type=${r.type} uuid=${l}`);return}if(l&&n.has(l)){o(`[bridge:repl] Ignoring re-delivered inbound: type=${r.type} uuid=${l}`);return}o(`[bridge:repl] Ingress message type=${r.type}${l?` uuid=${l}`:``}`),r.type===`user`?(l&&n.add(l),y(`tengu_bridge_message_received`,{is_repl:!0}),i?.(r)):o(`[bridge:repl] Ignoring non-user inbound message: type=${r.type}`)}catch(e){o(`[bridge:repl] Failed to parse ingress message: ${r(e)}`)}}var U=`This session is outbound-only. Enable Remote Control locally to allow inbound control.`;function W(e,t){let{transport:n,sessionId:r,outboundOnly:i,onInterrupt:a,onSetModel:s,onSetMaxThinkingTokens:c,onSetPermissionMode:l}=t;if(!n){o(`[bridge:repl] Cannot respond to control_request: transport not configured`);return}let u,d=e.request;if(i&&d.subtype!==`initialize`){u={type:`control_response`,response:{subtype:`error`,request_id:e.request_id,error:U}};let t={...u,session_id:r};n.write(t),o(`[bridge:repl] Rejected ${d.subtype} (outbound-only) request_id=${e.request_id}`);return}switch(d.subtype){case`initialize`:u={type:`control_response`,response:{subtype:`success`,request_id:e.request_id,response:{commands:[],output_style:`normal`,available_output_styles:[`normal`],models:[],account:{},pid:process.pid}}};break;case`set_model`:s?.(d.model),u={type:`control_response`,response:{subtype:`success`,request_id:e.request_id}};break;case`set_max_thinking_tokens`:c?.(d.max_thinking_tokens??null),u={type:`control_response`,response:{subtype:`success`,request_id:e.request_id}};break;case`set_permission_mode`:{let t=l?.(d.mode)??{ok:!1,error:`set_permission_mode is not supported in this context (onSetPermissionMode callback not registered)`};u=t.ok?{type:`control_response`,response:{subtype:`success`,request_id:e.request_id}}:{type:`control_response`,response:{subtype:`error`,request_id:e.request_id,error:t.error}};break}case`interrupt`:a?.(),u={type:`control_response`,response:{subtype:`success`,request_id:e.request_id}};break;default:u={type:`control_response`,response:{subtype:`error`,request_id:e.request_id,error:`REPL bridge does not handle control_request subtype: ${d.subtype}`}}}let f={...u,session_id:r};n.write(f),S(`control_response: subtype=${d.subtype} request_id=${e.request_id} result=${u.response.subtype}`),o(`[bridge:repl] Sent control_response for ${d.subtype} request_id=${e.request_id} result=${u.response.subtype}`)}function G(e){return{type:`result_success`,subtype:`success`,duration_ms:0,duration_api_ms:0,is_error:!1,num_turns:0,result:``,stop_reason:null,total_cost_usd:0,usage:{...x},modelUsage:{},permission_denials:[],session_id:e,uuid:T()}}var K=class{constructor(e){n(this,`capacity`,void 0),n(this,`ring`,void 0),n(this,`set`,new Set),n(this,`writeIdx`,0),this.capacity=e,this.ring=Array(e)}add(e){if(this.set.has(e))return;let t=this.ring[this.writeIdx];t!==void 0&&this.set.delete(t),this.ring[this.writeIdx]=e,this.set.add(e),this.writeIdx=(this.writeIdx+1)%this.capacity}has(e){return this.set.has(e)}clear(){this.set.clear(),this.ring.fill(void 0),this.writeIdx=0}};export{N as a,V as c,O as d,D as f,W as i,k as l,P as n,G as o,H as r,B as s,K as t,E as u};
@@ -1 +1 @@
1
- import{aS as e,sS as t}from"./loadAgentsDir-DXOkUcW3.js";import{v as n}from"./startupProfiler-CbzxVmbv.js";import{a as r,n as i,o as a}from"./bridgeConfig-MxsnEEPx.js";t(),r(),n();function o(t,n){return`${a()?i():e(void 0,n)}/code?bridge=${t}`}function s({error:e,connected:t,sessionActive:n,reconnecting:r}){return e?{label:`Remote Control failed`,color:`error`}:r?{label:`Remote Control reconnecting`,color:`warning`}:n||t?{label:`Remote Control active`,color:`success`}:{label:`Remote Control connecting…`,color:`warning`}}function c(e){return`Code everywhere with the Work Mate app or ${e}`}function l(e){return`Continue coding in the Work Mate app or ${e}`}var u=`Something went wrong, please try again`;export{s as a,c as i,l as n,o as r,u as t};
1
+ import{aS as e,sS as t}from"./loadAgentsDir-DaNpxaO-.js";import{v as n}from"./startupProfiler-CbzxVmbv.js";import{a as r,n as i,o as a}from"./bridgeConfig-C5L-7KaP.js";t(),r(),n();function o(t,n){return`${a()?i():e(void 0,n)}/code?bridge=${t}`}function s({error:e,connected:t,sessionActive:n,reconnecting:r}){return e?{label:`Remote Control failed`,color:`error`}:r?{label:`Remote Control reconnecting`,color:`warning`}:n||t?{label:`Remote Control active`,color:`success`}:{label:`Remote Control connecting…`,color:`warning`}}function c(e){return`Code everywhere with the Work Mate app or ${e}`}function l(e){return`Continue coding in the Work Mate app or ${e}`}var u=`Something went wrong, please try again`;export{s as a,c as i,l as n,o as r,u as t};
@@ -1 +1 @@
1
- import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{Fb as n,J_ as r,La as i,Lu as a,Pb as o,Ru as s,Sp as c,Y_ as l,at as u,by as d,cc as f,gC as p,ka as m,lc as h,ot as g,q_ as _,wp as v}from"./loadAgentsDir-DXOkUcW3.js";import{I as y,P as b,ai as x,bn as S,ot as C,t as w,vn as T,xt as E}from"./src-DL3w8VPk2.js";import{t as D}from"./jsx-runtime-Bb4Xn-E0.js";import{P as O,R as k}from"./debug-D58GQBDG.js";import{Ut as A}from"./settings-3xZ0fsvE.js";import{h as j,y as M}from"./config-DRy1I12M.js";import{Q as N}from"./sessionState-DAcub-HK.js";import{n as P,r as F}from"./sideQuestion-Ct87yvOR.js";import{i as I,n as L}from"./modalContext-wY9CeN4G.js";function R({question:e,context:t,onDone:n}){let[r,i]=(0,H.useState)(null),[s,l]=(0,H.useState)(null),[u,d]=(0,H.useState)(0),f=(0,H.useRef)(null),{rows:p}=I(C());S(()=>d(e=>e+1),r||s?null:80);function m(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(),f.current?.scrollBy(-3)),(e.key===`down`||e.ctrl&&e.key===`n`)&&(e.preventDefault(),f.current?.scrollBy(K))}(0,H.useEffect)(()=>{let n=o();async function r(){try{let r=await F({question:e,cacheSafeParams:await B(t)});n.signal.aborted||(r.response?i(r.response):l(`No response received`))}catch(e){n.signal.aborted||l(O(e)||`Failed to get response`)}}return r(),()=>{n.abort()}},[e,t]);let h=Math.max(5,p-W-G);return(0,U.jsxs)(y,{flexDirection:`column`,paddingLeft:2,marginTop:1,tabIndex:0,autoFocus:!0,onKeyDown:m,children:[(0,U.jsxs)(y,{children:[(0,U.jsxs)(b,{color:`warning`,bold:!0,children:[`/btw`,` `]}),(0,U.jsx)(b,{dimColor:!0,children:e})]}),(0,U.jsx)(y,{marginTop:1,marginLeft:2,maxHeight:h,children:(0,U.jsx)(E,{ref:f,flexDirection:`column`,flexGrow:1,children:s?(0,U.jsx)(b,{color:`error`,children:s}):r?(0,U.jsx)(c,{children:r}):(0,U.jsxs)(y,{children:[(0,U.jsx)(a,{frame:u,messageColor:`warning`}),(0,U.jsx)(b,{color:`warning`,children:`Answering...`})]})})}),(r||s)&&(0,U.jsx)(y,{marginTop:1,children:(0,U.jsxs)(b,{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=m(z(e.messages)),n=f();if(n)return{systemPrompt:n.systemPrompt,userContext:n.userContext,systemContext:n.systemContext,toolUseContext:e,forkContextMessages:t};let[i,a,o]=await Promise.all([u(e.options.tools,e.options.mainLoopModel,[],e.options.mcpClients),r(),_()]);return{systemPrompt:N(i),userContext:a,systemContext:o,toolUseContext:e,forkContextMessages:t}}async function V(e,t,n){let r=n?.trim();return r?(M(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((()=>{H=t(x(),1),T(),v(),s(),A(),g(),L(),l(),p(),w(),n(),j(),k(),h(),i(),P(),d(),U=D(),W=5,G=6,K=3}))();export{V as call};
1
+ import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{Fb as n,J_ as r,La as i,Lu as a,Pb as o,Ru as s,Sp as c,Y_ as l,at as u,by as d,cc as f,gC as p,ka as m,lc as h,ot as g,q_ as _,wp as v}from"./loadAgentsDir-DaNpxaO-.js";import{I as y,P as b,ai as x,bn as S,ot as C,t as w,vn as T,xt as E}from"./src-DL3w8VPk2.js";import{t as D}from"./jsx-runtime-Bb4Xn-E0.js";import{P as O,R as k}from"./debug-D58GQBDG.js";import{Ut as A}from"./settings-3xZ0fsvE.js";import{h as j,y as M}from"./config-DRy1I12M.js";import{Q as N}from"./sessionState-CQhbGfmh.js";import{n as P,r as F}from"./sideQuestion-Ds7Elgs4.js";import{i as I,n as L}from"./modalContext-wY9CeN4G.js";function R({question:e,context:t,onDone:n}){let[r,i]=(0,H.useState)(null),[s,l]=(0,H.useState)(null),[u,d]=(0,H.useState)(0),f=(0,H.useRef)(null),{rows:p}=I(C());S(()=>d(e=>e+1),r||s?null:80);function m(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(),f.current?.scrollBy(-3)),(e.key===`down`||e.ctrl&&e.key===`n`)&&(e.preventDefault(),f.current?.scrollBy(K))}(0,H.useEffect)(()=>{let n=o();async function r(){try{let r=await F({question:e,cacheSafeParams:await B(t)});n.signal.aborted||(r.response?i(r.response):l(`No response received`))}catch(e){n.signal.aborted||l(O(e)||`Failed to get response`)}}return r(),()=>{n.abort()}},[e,t]);let h=Math.max(5,p-W-G);return(0,U.jsxs)(y,{flexDirection:`column`,paddingLeft:2,marginTop:1,tabIndex:0,autoFocus:!0,onKeyDown:m,children:[(0,U.jsxs)(y,{children:[(0,U.jsxs)(b,{color:`warning`,bold:!0,children:[`/btw`,` `]}),(0,U.jsx)(b,{dimColor:!0,children:e})]}),(0,U.jsx)(y,{marginTop:1,marginLeft:2,maxHeight:h,children:(0,U.jsx)(E,{ref:f,flexDirection:`column`,flexGrow:1,children:s?(0,U.jsx)(b,{color:`error`,children:s}):r?(0,U.jsx)(c,{children:r}):(0,U.jsxs)(y,{children:[(0,U.jsx)(a,{frame:u,messageColor:`warning`}),(0,U.jsx)(b,{color:`warning`,children:`Answering...`})]})})}),(r||s)&&(0,U.jsx)(y,{marginTop:1,children:(0,U.jsxs)(b,{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=m(z(e.messages)),n=f();if(n)return{systemPrompt:n.systemPrompt,userContext:n.userContext,systemContext:n.systemContext,toolUseContext:e,forkContextMessages:t};let[i,a,o]=await Promise.all([u(e.options.tools,e.options.mainLoopModel,[],e.options.mcpClients),r(),_()]);return{systemPrompt:N(i),userContext:a,systemContext:o,toolUseContext:e,forkContextMessages:t}}async function V(e,t,n){let r=n?.trim();return r?(M(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((()=>{H=t(x(),1),T(),v(),s(),A(),g(),L(),l(),p(),w(),n(),j(),k(),h(),i(),P(),d(),U=D(),W=5,G=6,K=3}))();export{V as call};
@@ -0,0 +1 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{$f as t,Di as n,Ds as r,Du as i,Eu as a,G as o,Im as s,J_ as c,K_ as l,Ki as u,Ky as d,Li as f,MC as p,Os as m,Pm as h,Q_ as g,Sh as _,Sv as v,X_ as y,Xi as b,Y_ as x,Z_ as S,bv as C,ep as w,jC as T,q as E,q_ as D,qy as O,rm as k,xh as A}from"./loadAgentsDir-DaNpxaO-.js";import{Dn as j,Ut as M,l as N}from"./state-D5D6QpTX.js";import{S as P,v as F}from"./git-By_J4XJL.js";import{i as I,t as L}from"./detectRepository-CDOJ-M7h.js";import{a as R,n as z}from"./fileSuggestions-CFkJktgc.js";import{r as B,t as V}from"./magicDocs-CrTwULyJ.js";function H(e=new Set){let r=e.size>0;c.cache.clear?.(),D.cache.clear?.(),l.cache.clear?.(),S.cache.clear?.(),z(),n(),r||v(),y(null),j(null),s(),m(),O(`session_start`),t(),a(),L(),o(),N(e),F(),u(),_(),V(),T(),import(`./SearchExtraToolsTool-DYoxHo9T.js`).then(({clearSearchExtraToolsDescriptionCache:e})=>e()),import(`./loadAgentsDir-DcI-8FQF.js`).then(({clearAgentDefinitionsCache:e})=>e()),import(`./prompt-WsoTRhoh.js`).then(({clearPromptCache:e})=>e())}var U=e((()=>{M(),f(),g(),x(),R(),k(),C(),i(),h(),A(),B(),b(),r(),E(),d(),I(),P(),w(),p()}));export{U as n,H as t};
@@ -0,0 +1 @@
1
+ import{n as e,t}from"./caches-DH-q8Fjf.js";e();export{t as clearSessionCaches};
@@ -1 +1 @@
1
- import{n as e,t}from"./defineProperty-C-QyHrDq.js";import{C as n,F as r,P as i,R as a,c as o,i as s,x as c}from"./debug-D58GQBDG.js";import{O as l,k as u}from"./git-By_J4XJL.js";import{dn as d,fn as f}from"./model-Cxx3suBa.js";import{l as p,r as m}from"./proxy-BhIc7-mj.js";import{n as h,t as g}from"./userAgent-CJ5Rp9kc.js";import{C as _,S as v,f as y,g as b,u as x,x as S}from"./sessionState-DAcub-HK.js";import{n as C}from"./jwtUtils-C_LG1txt.js";import{randomUUID as w}from"crypto";a(),s(),l(),p(),h(),d(),_(),x(),c(),e();var T=class extends Error{constructor(e,n){super(e),t(this,`retryAfterMs`,void 0),this.retryAfterMs=n}},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 r=0,i=0;for(;i<this.pending.length&&i<e;){let e;try{e=Buffer.byteLength(n(this.pending[i]))}catch{this.pending.splice(i,1);continue}if(i>0&&r+e>t)break;r+=e,i++}return this.pending.splice(0,i)}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 f(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}d(),e();var k=2e4,A=100;function j(){return!0}var M=class extends Error{constructor(e){super(`CCRClient init failed: ${e}`),t(this,`reason`,void 0),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`,m({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??S,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(),y(()=>{this.writeEvent({type:`keep_alive`})}),o(`CCRClient: initialized, epoch=${this.workerEpoch}`),u(`info`,`cli_worker_lifecycle_initialized`,{epoch:this.workerEpoch,duration_ms:Date.now()-t});let{metadata:r,durationMs:i}=await n;return this.closed||u(`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,n,a,{timeout:s=1e4}={}){let c=this.getAuthHeaders();if(Object.keys(c).length===0)return{ok:!1};try{let r=await this.http[e](`${this.sessionBaseUrl}${t}`,n,{headers:{...c,"Content-Type":`application/json`,"anthropic-version":`2023-06-01`,"User-Agent":g()},validateStatus:j,timeout:s});if(r.status>=200&&r.status<300)return this.consecutiveAuthFailures=0,{ok:!0};if(r.status===409&&this.handleEpochMismatch(),r.status===401||r.status===403){let e=v(),t=e?C(e):null;t!==null&&t*1e3<Date.now()&&(o(`CCRClient: session_token expired (exp=${new Date(t*1e3).toISOString()}) — no refresh was delivered, exiting`,{level:`error`}),u(`error`,`cli_worker_token_expired_no_refresh`),this.onEpochMismatch()),this.consecutiveAuthFailures++,this.consecutiveAuthFailures>=N&&(o(`CCRClient: ${this.consecutiveAuthFailures} consecutive auth failures with a valid-looking token — server-side auth unrecoverable, exiting`,{level:`error`}),u(`error`,`cli_worker_auth_failures_exhausted`),this.onEpochMismatch())}if(o(`CCRClient: ${a} returned ${r.status}`,{level:`warn`}),u(`warn`,`cli_worker_request_failed`,{method:e,path:t,status:r.status}),r.status===429){let e=r.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 o(`CCRClient: ${a} failed: ${i(n)}`,{level:`warn`}),u(`warn`,`cli_worker_request_error`,{method:e,path:t,error_code:r(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(){o(`CCRClient: Epoch mismatch (409), shutting down`,{level:`error`}),u(`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&&o(`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 o(`CCRClient: Read ${i.length} internal events from ${e}${t.subagents?` (subagents)`:``}`),i}async getWithRetry(e,t,n){for(let n=1;n<=10;n++){let r;try{r=await this.http.get(e,{headers:{...t,"anthropic-version":`2023-06-01`,"User-Agent":g()},validateStatus:j,timeout:3e4})}catch(t){o(`CCRClient: GET ${e} failed (attempt ${n}/10): ${i(t)}`,{level:`warn`}),n<10&&await f(Math.min(500*2**(n-1),3e4)+Math.random()*500);continue}if(r.status>=200&&r.status<300)return r.data;r.status===409&&this.handleEpochMismatch(),o(`CCRClient: GET ${e} returned ${r.status} (attempt ${n}/10)`,{level:`warn`}),n<10&&await f(Math.min(500*2**(n-1),3e4)+Math.random()*500)}return o(`CCRClient: GET retries exhausted`,{level:`error`}),u(`error`,`cli_worker_get_retries_exhausted`,{context:n}),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(),b(),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-C-QyHrDq.js";import{C as n,F as r,P as i,R as a,c as o,i as s,x as c}from"./debug-D58GQBDG.js";import{O as l,k as u}from"./git-By_J4XJL.js";import{dn as d,fn as f}from"./model-Do0f476p.js";import{l as p,r as m}from"./proxy-BhIc7-mj.js";import{n as h,t as g}from"./userAgent-i-oGzf40.js";import{C as _,S as v,f as y,g as b,u as x,x as S}from"./sessionState-CQhbGfmh.js";import{n as C}from"./jwtUtils-C_LG1txt.js";import{randomUUID as w}from"crypto";a(),s(),l(),p(),h(),d(),_(),x(),c(),e();var T=class extends Error{constructor(e,n){super(e),t(this,`retryAfterMs`,void 0),this.retryAfterMs=n}},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 r=0,i=0;for(;i<this.pending.length&&i<e;){let e;try{e=Buffer.byteLength(n(this.pending[i]))}catch{this.pending.splice(i,1);continue}if(i>0&&r+e>t)break;r+=e,i++}return this.pending.splice(0,i)}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 f(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}d(),e();var k=2e4,A=100;function j(){return!0}var M=class extends Error{constructor(e){super(`CCRClient init failed: ${e}`),t(this,`reason`,void 0),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`,m({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??S,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(),y(()=>{this.writeEvent({type:`keep_alive`})}),o(`CCRClient: initialized, epoch=${this.workerEpoch}`),u(`info`,`cli_worker_lifecycle_initialized`,{epoch:this.workerEpoch,duration_ms:Date.now()-t});let{metadata:r,durationMs:i}=await n;return this.closed||u(`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,n,a,{timeout:s=1e4}={}){let c=this.getAuthHeaders();if(Object.keys(c).length===0)return{ok:!1};try{let r=await this.http[e](`${this.sessionBaseUrl}${t}`,n,{headers:{...c,"Content-Type":`application/json`,"anthropic-version":`2023-06-01`,"User-Agent":g()},validateStatus:j,timeout:s});if(r.status>=200&&r.status<300)return this.consecutiveAuthFailures=0,{ok:!0};if(r.status===409&&this.handleEpochMismatch(),r.status===401||r.status===403){let e=v(),t=e?C(e):null;t!==null&&t*1e3<Date.now()&&(o(`CCRClient: session_token expired (exp=${new Date(t*1e3).toISOString()}) — no refresh was delivered, exiting`,{level:`error`}),u(`error`,`cli_worker_token_expired_no_refresh`),this.onEpochMismatch()),this.consecutiveAuthFailures++,this.consecutiveAuthFailures>=N&&(o(`CCRClient: ${this.consecutiveAuthFailures} consecutive auth failures with a valid-looking token — server-side auth unrecoverable, exiting`,{level:`error`}),u(`error`,`cli_worker_auth_failures_exhausted`),this.onEpochMismatch())}if(o(`CCRClient: ${a} returned ${r.status}`,{level:`warn`}),u(`warn`,`cli_worker_request_failed`,{method:e,path:t,status:r.status}),r.status===429){let e=r.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 o(`CCRClient: ${a} failed: ${i(n)}`,{level:`warn`}),u(`warn`,`cli_worker_request_error`,{method:e,path:t,error_code:r(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(){o(`CCRClient: Epoch mismatch (409), shutting down`,{level:`error`}),u(`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&&o(`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 o(`CCRClient: Read ${i.length} internal events from ${e}${t.subagents?` (subagents)`:``}`),i}async getWithRetry(e,t,n){for(let n=1;n<=10;n++){let r;try{r=await this.http.get(e,{headers:{...t,"anthropic-version":`2023-06-01`,"User-Agent":g()},validateStatus:j,timeout:3e4})}catch(t){o(`CCRClient: GET ${e} failed (attempt ${n}/10): ${i(t)}`,{level:`warn`}),n<10&&await f(Math.min(500*2**(n-1),3e4)+Math.random()*500);continue}if(r.status>=200&&r.status<300)return r.data;r.status===409&&this.handleEpochMismatch(),o(`CCRClient: GET ${e} returned ${r.status} (attempt ${n}/10)`,{level:`warn`}),n<10&&await f(Math.min(500*2**(n-1),3e4)+Math.random()*500)}return o(`CCRClient: GET retries exhausted`,{level:`error`}),u(`error`,`cli_worker_get_retries_exhausted`,{context:n}),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(),b(),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 +1 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./conversation-CJ-d0O-U.js";var r;e((()=>{t(),r=async(e,t)=>(await n(t),{type:`text`,value:``})}))();export{r as call};
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./conversation-BBOE_EoE.js";var r;e((()=>{t(),r=async(e,t)=>(await n(t),{type:`text`,value:``})}))();export{r as call};
@@ -0,0 +1 @@
1
+ import{Dr as e,Or as t}from"./model-Do0f476p.js";t();export{e as getOrganizationUUID};
@@ -0,0 +1 @@
1
+ import{Di as e,Li as t,Mi as n}from"./loadAgentsDir-DaNpxaO-.js";t();export{e as clearCommandsCache,n as getCommands};
@@ -1,2 +1,2 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{$_ as t,Am as n,G_ as r,Im as i,J_ as a,La as o,Om as s,Pm as c,W_ as l,Y_ as u,_p as d,at as f,bv as p,ev as m,fv as h,hC as g,hn as _,iv as v,ka as y,l_ as b,mC as x,o_ as S,ot as C,q_ as w,rv as T,s_ as E,u_ as D,vp as O,vv as k,xv as A}from"./loadAgentsDir-DXOkUcW3.js";import{di as j,fi as M}from"./src-DL3w8VPk2.js";import{Kt as N,Ut as P}from"./state-D5D6QpTX.js";import{L as F,R as I}from"./debug-D58GQBDG.js";import{o as L,s as R}from"./log-CZ7ploQm.js";function z(e,t){let n=d(`tip`),r=x(`app:toggleTranscript`,`Global`,`ctrl+o`),i=[...e.options.verbose?[]:[`(${r} to see full summary)`],...t?[t]:[],...n?[n]:[]];return j.dim(`Compacted ${i.join(`
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{$_ as t,Am as n,G_ as r,Im as i,J_ as a,La as o,Om as s,Pm as c,W_ as l,Y_ as u,_p as d,at as f,bv as p,ev as m,fv as h,hC as g,hn as _,iv as v,ka as y,l_ as b,mC as x,o_ as S,ot as C,q_ as w,rv as T,s_ as E,u_ as D,vp as O,vv as k,xv as A}from"./loadAgentsDir-DaNpxaO-.js";import{di as j,fi as M}from"./src-DL3w8VPk2.js";import{Kt as N,Ut as P}from"./state-D5D6QpTX.js";import{L as F,R as I}from"./debug-D58GQBDG.js";import{o as L,s as R}from"./log-CZ7ploQm.js";function z(e,t){let n=d(`tip`),r=x(`app:toggleTranscript`,`Global`,`ctrl+o`),i=[...e.options.verbose?[]:[`(${r} to see full summary)`],...t?[t]:[],...n?[n]:[]];return j.dim(`Compacted ${i.join(`
2
2
  `)}`)}async function B(e,t){let n=e.getAppState(),r=await f(e.options.tools,e.options.mainLoopModel,Array.from(n.toolPermissionContext.additionalWorkingDirectories.keys()),e.options.mcpClients),i=l({mainThreadAgentDefinition:void 0,toolUseContext:e,customSystemPrompt:e.options.customSystemPrompt,defaultSystemPrompt:r,appendSystemPrompt:e.options.appendSystemPrompt}),[o,s]=await Promise.all([a(),w()]);return{systemPrompt:i,userContext:o,systemContext:s,toolUseContext:e,forkContextMessages:t}}var V;e((()=>{M(),P(),C(),u(),g(),p(),D(),T(),t(),c(),s(),h(),I(),_(),L(),o(),O(),r(),V=async(e,t)=>{let{abortController:r}=t,{messages:o}=t;if(o=y(o),o.length===0)throw Error(`No messages to compact`);let s=e.trim();try{if(!s){let e=await n(o,t.agentId);if(e)return a.cache.clear?.(),i(),A(t.options.querySource??`compact`,t.agentId),N(),v(),{type:`compact`,compactionResult:e,displayText:z(t)}}let e=(await m(o,t)).messages,r=await b(e,t,await B(t,e),!1,s,!1);return k(void 0),v(),a.cache.clear?.(),i(),{type:`compact`,compactionResult:r,displayText:z(t,r.userDisplayMessage)}}catch(e){throw r.signal.aborted?Error(`Compaction canceled.`):F(e,`Not enough messages to compact. Send a few more messages first, then try again.`)?Error(E):F(e,`Compaction interrupted · This may be due to network issues — please try again.`)?Error(S):(R(e),Error(`Error during compaction: ${e}`))}}}))();export{V as call};
@@ -0,0 +1 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{t}from"./jsx-runtime-Bb4Xn-E0.js";import{n,t as r}from"./Settings-CKaGmKg2.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"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./figures-5ThXQEtq.js";import{$_ as r,La as i,U_ as a,V_ as o,ev as s,ka as c}from"./loadAgentsDir-DXOkUcW3.js";import{I as l,P as u,s as d,t as f}from"./src-DL3w8VPk2.js";import{t as p}from"./jsx-runtime-Bb4Xn-E0.js";import{Cn as m,bn as h,cn as g,sn as _}from"./settings-3xZ0fsvE.js";import{_ as v,v as y}from"./startupProfiler-CbzxVmbv.js";import{Et as b,Ot as x,Yt as S,in as C,rn as w,tn as T}from"./prompt-DEioJrx_.js";import{n as E,t as D}from"./staticRender-D9AbnQFr.js";function O(e){let t=[];return k(e,t),A(e,t),M(e,t),N(e,t),ee(e,t),t.sort((e,t)=>e.severity===t.severity?(t.savingsTokens??0)-(e.savingsTokens??0):e.severity===`warning`?-1:1),t}function k(e,t){e.percentage>=L&&t.push({severity:`warning`,title:`Context is ${e.percentage}% full`,detail:e.isAutoCompactEnabled?`Autocompact will trigger soon, which discards older messages. Use /compact now to control what gets kept.`:`Autocompact is disabled. Use /compact to free space, or enable autocompact in /config.`})}function A(e,t){if(e.messageBreakdown)for(let n of e.messageBreakdown.toolCallsByType){let r=n.callTokens+n.resultTokens,i=r/e.rawMaxTokens*100;if(i<P||r<F)continue;let a=j(n.name,r,i);a&&t.push(a)}}function j(e,t,n){let r=v(t);switch(e){case w: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 S: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 b:return{severity:`info`,title:`Grep results using ${r} tokens (${n.toFixed(0)}%)`,detail:`Add more specific patterns or use the glob or type parameter to narrow file types. Consider Glob for file discovery instead of Grep.`,savingsTokens:Math.floor(t*.3)};default:return n>=20?{severity:`info`,title:`${e} using ${r} tokens (${n.toFixed(0)}%)`,detail:`This tool is consuming a significant portion of context.`,savingsTokens:Math.floor(t*.2)}:null}}function M(e,t){if(!e.messageBreakdown)return;let n=e.messageBreakdown.toolCallsByType.find(e=>e.name===S);if(!n)return;let r=n.callTokens+n.resultTokens,i=r/e.rawMaxTokens*100,a=n.resultTokens/e.rawMaxTokens*100;i>=P&&r>=F||a>=I&&n.resultTokens>=F&&t.push({severity:`info`,title:`File reads using ${v(n.resultTokens)} tokens (${a.toFixed(0)}%)`,detail:`If you are re-reading files, consider referencing earlier reads. Use offset/limit for large files.`,savingsTokens:Math.floor(n.resultTokens*.3)})}function N(e,t){let n=e.memoryFiles.reduce((e,t)=>e+t.tokens,0),r=n/e.rawMaxTokens*100;if(r>=R&&n>=z){let i=[...e.memoryFiles].sort((e,t)=>t.tokens-e.tokens).slice(0,3).map(e=>`${h(e.path)} (${v(e.tokens)})`).join(`, `);t.push({severity:`info`,title:`Memory files using ${v(n)} tokens (${r.toFixed(0)}%)`,detail:`Largest: ${i}. Use /memory to review and prune stale entries.`,savingsTokens:Math.floor(n*.3)})}}function ee(e,t){!e.isAutoCompactEnabled&&e.percentage>=50&&e.percentage<L&&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 P,F,I,L,R,z,B=e((()=>{C(),T(),x(),m(),y(),P=15,F=1e4,I=5,L=80,R=5,z=5e3}));function V({suggestions:e}){return e.length===0?null:(0,H.jsxs)(l,{flexDirection:`column`,marginTop:1,children:[(0,H.jsx)(u,{bold:!0,children:`Suggestions`}),e.map((e,t)=>(0,H.jsxs)(l,{flexDirection:`column`,marginTop:t===0?0:1,children:[(0,H.jsxs)(l,{children:[(0,H.jsx)(d,{status:e.severity,withSpace:!0}),(0,H.jsx)(u,{bold:!0,children:e.title}),e.savingsTokens?(0,H.jsxs)(u,{dimColor:!0,children:[` `,n.arrowRight,` save ~`,v(e.savingsTokens)]}):null]}),(0,H.jsx)(l,{marginLeft:2,children:(0,H.jsx)(u,{dimColor:!0,children:e.detail})})]},t))]})}var H,U=e((()=>{t(),f(),y(),H=p()}));function W(){return null}function G(e){let t=new Map;for(let n of e){let e=_(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 Y){let r=t.get(e);r&&n.set(e,r)}return n}function K({data:e}){let{categories:t,totalTokens:n,rawMaxTokens:r,percentage:i,gridRows:a,model:o,memoryFiles:s,mcpTools:c,deferredBuiltinTools:d=[],agents:f,skills:p,cacheHitRate:m,cacheThreshold:g}=e,_=t.filter(e=>e.tokens>0&&e.name!==`Free space`&&e.name!==J&&!e.isDeferred),y=t.some(e=>e.isDeferred&&e.name.includes(`MCP`)),b=t.find(e=>e.name===J);return(0,q.jsxs)(l,{flexDirection:`column`,paddingLeft:1,children:[(0,q.jsx)(u,{bold:!0,children:`Context Usage`}),(0,q.jsxs)(l,{flexDirection:`row`,gap:2,children:[(0,q.jsx)(l,{flexDirection:`column`,flexShrink:0,children:a.map((e,t)=>(0,q.jsx)(l,{flexDirection:`row`,marginLeft:-1,children:e.map((e,t)=>e.categoryName===`Free space`?(0,q.jsx)(u,{dimColor:!0,children:`⛶ `},t):e.categoryName===J?(0,q.jsx)(u,{color:e.color,children:`⛝ `},t):(0,q.jsx)(u,{color:e.color,children:e.squareFullness>=.7?`⛁ `:`⛀ `},t))},t))}),(0,q.jsxs)(l,{flexDirection:`column`,gap:0,flexShrink:0,children:[(0,q.jsxs)(u,{dimColor:!0,children:[o,` · `,v(n),`/`,v(r),` tokens (`,i,`%)`]}),(0,q.jsx)(W,{}),m!==void 0&&g!==void 0&&(0,q.jsxs)(u,{color:m<g?`warning`:void 0,children:[`Cache hit rate: `,m.toFixed(0),`%`,m<g?` (below ${g}% threshold)`:``]}),(0,q.jsx)(u,{children:` `}),(0,q.jsx)(u,{dimColor:!0,italic:!0,children:`Estimated usage by category`}),_.map((e,t)=>{let n=v(e.tokens),i=e.isDeferred?`N/A`:`${(e.tokens/r*100).toFixed(1)}%`,a=e.name===J,o=e.name,s=e.isDeferred?` `:a?`⛝`:`⛁`;return(0,q.jsxs)(l,{children:[(0,q.jsx)(u,{color:e.color,children:s}),(0,q.jsxs)(u,{children:[` `,o,`: `]}),(0,q.jsxs)(u,{dimColor:!0,children:[n,` tokens (`,i,`)`]})]},t)}),(t.find(e=>e.name===`Free space`)?.tokens??0)>0&&(0,q.jsxs)(l,{children:[(0,q.jsx)(u,{dimColor:!0,children:`⛶`}),(0,q.jsx)(u,{children:` Free space: `}),(0,q.jsxs)(u,{dimColor:!0,children:[v(t.find(e=>e.name===`Free space`)?.tokens||0),` (`,((t.find(e=>e.name===`Free space`)?.tokens||0)/r*100).toFixed(1),`%)`]})]}),b&&b.tokens>0&&(0,q.jsxs)(l,{children:[(0,q.jsx)(u,{color:b.color,children:`⛝`}),(0,q.jsxs)(u,{dimColor:!0,children:[` `,b.name,`: `]}),(0,q.jsxs)(u,{dimColor:!0,children:[v(b.tokens),` tokens (`,(b.tokens/r*100).toFixed(1),`%)`]})]})]})]}),(0,q.jsxs)(l,{flexDirection:`column`,marginLeft:-1,children:[c.length>0&&(0,q.jsxs)(l,{flexDirection:`column`,marginTop:1,children:[(0,q.jsxs)(l,{children:[(0,q.jsx)(u,{bold:!0,children:`MCP tools`}),(0,q.jsxs)(u,{dimColor:!0,children:[` · /mcp`,y?` (loaded on-demand)`:``]})]}),c.some(e=>e.isLoaded)&&(0,q.jsxs)(l,{flexDirection:`column`,marginTop:1,children:[(0,q.jsx)(u,{dimColor:!0,children:`Loaded`}),c.filter(e=>e.isLoaded).map((e,t)=>(0,q.jsxs)(l,{children:[(0,q.jsxs)(u,{children:[`└ `,e.name,`: `]}),(0,q.jsxs)(u,{dimColor:!0,children:[v(e.tokens),` tokens`]})]},t))]}),y&&c.some(e=>!e.isLoaded)&&(0,q.jsxs)(l,{flexDirection:`column`,marginTop:1,children:[(0,q.jsx)(u,{dimColor:!0,children:`Available`}),c.filter(e=>!e.isLoaded).map((e,t)=>(0,q.jsx)(l,{children:(0,q.jsxs)(u,{dimColor:!0,children:[`└ `,e.name]})},t))]}),!y&&c.map((e,t)=>(0,q.jsxs)(l,{children:[(0,q.jsxs)(u,{children:[`└ `,e.name,`: `]}),(0,q.jsxs)(u,{dimColor:!0,children:[v(e.tokens),` tokens`]})]},t))]}),f.length>0&&(0,q.jsxs)(l,{flexDirection:`column`,marginTop:1,children:[(0,q.jsxs)(l,{children:[(0,q.jsx)(u,{bold:!0,children:`Custom agents`}),(0,q.jsx)(u,{dimColor:!0,children:` · /agents`})]}),Array.from(G(f).entries()).map(([e,t])=>(0,q.jsxs)(l,{flexDirection:`column`,marginTop:1,children:[(0,q.jsx)(u,{dimColor:!0,children:e}),t.map((e,t)=>(0,q.jsxs)(l,{children:[(0,q.jsxs)(u,{children:[`└ `,e.agentType,`: `]}),(0,q.jsxs)(u,{dimColor:!0,children:[v(e.tokens),` tokens`]})]},t))]},e))]}),s.length>0&&(0,q.jsxs)(l,{flexDirection:`column`,marginTop:1,children:[(0,q.jsxs)(l,{children:[(0,q.jsx)(u,{bold:!0,children:`Memory files`}),(0,q.jsx)(u,{dimColor:!0,children:` · /memory`})]}),s.map((e,t)=>(0,q.jsxs)(l,{children:[(0,q.jsxs)(u,{children:[`└ `,h(e.path),`: `]}),(0,q.jsxs)(u,{dimColor:!0,children:[v(e.tokens),` tokens`]})]},t))]}),p&&p.tokens>0&&(0,q.jsxs)(l,{flexDirection:`column`,marginTop:1,children:[(0,q.jsxs)(l,{children:[(0,q.jsx)(u,{bold:!0,children:`Skills`}),(0,q.jsx)(u,{dimColor:!0,children:` · /skills`})]}),Array.from(G(p.skillFrontmatter).entries()).map(([e,t])=>(0,q.jsxs)(l,{flexDirection:`column`,marginTop:1,children:[(0,q.jsx)(u,{dimColor:!0,children:e}),t.map((e,t)=>(0,q.jsxs)(l,{children:[(0,q.jsxs)(u,{children:[`└ `,e.name,`: `]}),(0,q.jsxs)(u,{dimColor:!0,children:[v(e.tokens),` tokens`]})]},t))]},e))]})]}),(0,q.jsx)(V,{suggestions:O(e)})]})}var q,J,Y,X=e((()=>{f(),B(),m(),y(),g(),U(),q=p(),J=`Autocompact buffer`,Y=[`Project`,`User`,`Managed`,`Plugin`,`Built-in`]}));function Z(e){return c(e)}async function Q(e,t){let{messages:n,getAppState:r,options:{mainLoopModel:i,tools:a}}=t,c=Z(n),{messages:l}=await s(c),u=process.stdout.columns||80,d=r();return e(await E((0,$.jsx)(K,{data:await o(l,i,async()=>d.toolPermissionContext,a,d.agentDefinitions,u,t,void 0,c)}))),null}var $;e((()=>{X(),r(),a(),i(),D(),$=p()}))();export{Q as call};
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./figures-5ThXQEtq.js";import{$_ as r,La as i,U_ as a,V_ as o,ev as s,ka as c}from"./loadAgentsDir-DaNpxaO-.js";import{I as l,P as u,s as d,t as f}from"./src-DL3w8VPk2.js";import{t as p}from"./jsx-runtime-Bb4Xn-E0.js";import{Cn as m,bn as h,cn as g,sn as _}from"./settings-3xZ0fsvE.js";import{_ as v,v as y}from"./startupProfiler-CbzxVmbv.js";import{Et as b,Ot as x,Yt as S,in as C,rn as w,tn as T}from"./prompt-8u06WVES.js";import{n as E,t as D}from"./staticRender-D9AbnQFr.js";function O(e){let t=[];return k(e,t),A(e,t),M(e,t),N(e,t),ee(e,t),t.sort((e,t)=>e.severity===t.severity?(t.savingsTokens??0)-(e.savingsTokens??0):e.severity===`warning`?-1:1),t}function k(e,t){e.percentage>=L&&t.push({severity:`warning`,title:`Context is ${e.percentage}% full`,detail:e.isAutoCompactEnabled?`Autocompact will trigger soon, which discards older messages. Use /compact now to control what gets kept.`:`Autocompact is disabled. Use /compact to free space, or enable autocompact in /config.`})}function A(e,t){if(e.messageBreakdown)for(let n of e.messageBreakdown.toolCallsByType){let r=n.callTokens+n.resultTokens,i=r/e.rawMaxTokens*100;if(i<P||r<F)continue;let a=j(n.name,r,i);a&&t.push(a)}}function j(e,t,n){let r=v(t);switch(e){case w: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 S: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 b:return{severity:`info`,title:`Grep results using ${r} tokens (${n.toFixed(0)}%)`,detail:`Add more specific patterns or use the glob or type parameter to narrow file types. Consider Glob for file discovery instead of Grep.`,savingsTokens:Math.floor(t*.3)};default:return n>=20?{severity:`info`,title:`${e} using ${r} tokens (${n.toFixed(0)}%)`,detail:`This tool is consuming a significant portion of context.`,savingsTokens:Math.floor(t*.2)}:null}}function M(e,t){if(!e.messageBreakdown)return;let n=e.messageBreakdown.toolCallsByType.find(e=>e.name===S);if(!n)return;let r=n.callTokens+n.resultTokens,i=r/e.rawMaxTokens*100,a=n.resultTokens/e.rawMaxTokens*100;i>=P&&r>=F||a>=I&&n.resultTokens>=F&&t.push({severity:`info`,title:`File reads using ${v(n.resultTokens)} tokens (${a.toFixed(0)}%)`,detail:`If you are re-reading files, consider referencing earlier reads. Use offset/limit for large files.`,savingsTokens:Math.floor(n.resultTokens*.3)})}function N(e,t){let n=e.memoryFiles.reduce((e,t)=>e+t.tokens,0),r=n/e.rawMaxTokens*100;if(r>=R&&n>=z){let i=[...e.memoryFiles].sort((e,t)=>t.tokens-e.tokens).slice(0,3).map(e=>`${h(e.path)} (${v(e.tokens)})`).join(`, `);t.push({severity:`info`,title:`Memory files using ${v(n)} tokens (${r.toFixed(0)}%)`,detail:`Largest: ${i}. Use /memory to review and prune stale entries.`,savingsTokens:Math.floor(n*.3)})}}function ee(e,t){!e.isAutoCompactEnabled&&e.percentage>=50&&e.percentage<L&&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 P,F,I,L,R,z,B=e((()=>{C(),T(),x(),m(),y(),P=15,F=1e4,I=5,L=80,R=5,z=5e3}));function V({suggestions:e}){return e.length===0?null:(0,H.jsxs)(l,{flexDirection:`column`,marginTop:1,children:[(0,H.jsx)(u,{bold:!0,children:`Suggestions`}),e.map((e,t)=>(0,H.jsxs)(l,{flexDirection:`column`,marginTop:t===0?0:1,children:[(0,H.jsxs)(l,{children:[(0,H.jsx)(d,{status:e.severity,withSpace:!0}),(0,H.jsx)(u,{bold:!0,children:e.title}),e.savingsTokens?(0,H.jsxs)(u,{dimColor:!0,children:[` `,n.arrowRight,` save ~`,v(e.savingsTokens)]}):null]}),(0,H.jsx)(l,{marginLeft:2,children:(0,H.jsx)(u,{dimColor:!0,children:e.detail})})]},t))]})}var H,U=e((()=>{t(),f(),y(),H=p()}));function W(){return null}function G(e){let t=new Map;for(let n of e){let e=_(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 Y){let r=t.get(e);r&&n.set(e,r)}return n}function K({data:e}){let{categories:t,totalTokens:n,rawMaxTokens:r,percentage:i,gridRows:a,model:o,memoryFiles:s,mcpTools:c,deferredBuiltinTools:d=[],agents:f,skills:p,cacheHitRate:m,cacheThreshold:g}=e,_=t.filter(e=>e.tokens>0&&e.name!==`Free space`&&e.name!==J&&!e.isDeferred),y=t.some(e=>e.isDeferred&&e.name.includes(`MCP`)),b=t.find(e=>e.name===J);return(0,q.jsxs)(l,{flexDirection:`column`,paddingLeft:1,children:[(0,q.jsx)(u,{bold:!0,children:`Context Usage`}),(0,q.jsxs)(l,{flexDirection:`row`,gap:2,children:[(0,q.jsx)(l,{flexDirection:`column`,flexShrink:0,children:a.map((e,t)=>(0,q.jsx)(l,{flexDirection:`row`,marginLeft:-1,children:e.map((e,t)=>e.categoryName===`Free space`?(0,q.jsx)(u,{dimColor:!0,children:`⛶ `},t):e.categoryName===J?(0,q.jsx)(u,{color:e.color,children:`⛝ `},t):(0,q.jsx)(u,{color:e.color,children:e.squareFullness>=.7?`⛁ `:`⛀ `},t))},t))}),(0,q.jsxs)(l,{flexDirection:`column`,gap:0,flexShrink:0,children:[(0,q.jsxs)(u,{dimColor:!0,children:[o,` · `,v(n),`/`,v(r),` tokens (`,i,`%)`]}),(0,q.jsx)(W,{}),m!==void 0&&g!==void 0&&(0,q.jsxs)(u,{color:m<g?`warning`:void 0,children:[`Cache hit rate: `,m.toFixed(0),`%`,m<g?` (below ${g}% threshold)`:``]}),(0,q.jsx)(u,{children:` `}),(0,q.jsx)(u,{dimColor:!0,italic:!0,children:`Estimated usage by category`}),_.map((e,t)=>{let n=v(e.tokens),i=e.isDeferred?`N/A`:`${(e.tokens/r*100).toFixed(1)}%`,a=e.name===J,o=e.name,s=e.isDeferred?` `:a?`⛝`:`⛁`;return(0,q.jsxs)(l,{children:[(0,q.jsx)(u,{color:e.color,children:s}),(0,q.jsxs)(u,{children:[` `,o,`: `]}),(0,q.jsxs)(u,{dimColor:!0,children:[n,` tokens (`,i,`)`]})]},t)}),(t.find(e=>e.name===`Free space`)?.tokens??0)>0&&(0,q.jsxs)(l,{children:[(0,q.jsx)(u,{dimColor:!0,children:`⛶`}),(0,q.jsx)(u,{children:` Free space: `}),(0,q.jsxs)(u,{dimColor:!0,children:[v(t.find(e=>e.name===`Free space`)?.tokens||0),` (`,((t.find(e=>e.name===`Free space`)?.tokens||0)/r*100).toFixed(1),`%)`]})]}),b&&b.tokens>0&&(0,q.jsxs)(l,{children:[(0,q.jsx)(u,{color:b.color,children:`⛝`}),(0,q.jsxs)(u,{dimColor:!0,children:[` `,b.name,`: `]}),(0,q.jsxs)(u,{dimColor:!0,children:[v(b.tokens),` tokens (`,(b.tokens/r*100).toFixed(1),`%)`]})]})]})]}),(0,q.jsxs)(l,{flexDirection:`column`,marginLeft:-1,children:[c.length>0&&(0,q.jsxs)(l,{flexDirection:`column`,marginTop:1,children:[(0,q.jsxs)(l,{children:[(0,q.jsx)(u,{bold:!0,children:`MCP tools`}),(0,q.jsxs)(u,{dimColor:!0,children:[` · /mcp`,y?` (loaded on-demand)`:``]})]}),c.some(e=>e.isLoaded)&&(0,q.jsxs)(l,{flexDirection:`column`,marginTop:1,children:[(0,q.jsx)(u,{dimColor:!0,children:`Loaded`}),c.filter(e=>e.isLoaded).map((e,t)=>(0,q.jsxs)(l,{children:[(0,q.jsxs)(u,{children:[`└ `,e.name,`: `]}),(0,q.jsxs)(u,{dimColor:!0,children:[v(e.tokens),` tokens`]})]},t))]}),y&&c.some(e=>!e.isLoaded)&&(0,q.jsxs)(l,{flexDirection:`column`,marginTop:1,children:[(0,q.jsx)(u,{dimColor:!0,children:`Available`}),c.filter(e=>!e.isLoaded).map((e,t)=>(0,q.jsx)(l,{children:(0,q.jsxs)(u,{dimColor:!0,children:[`└ `,e.name]})},t))]}),!y&&c.map((e,t)=>(0,q.jsxs)(l,{children:[(0,q.jsxs)(u,{children:[`└ `,e.name,`: `]}),(0,q.jsxs)(u,{dimColor:!0,children:[v(e.tokens),` tokens`]})]},t))]}),f.length>0&&(0,q.jsxs)(l,{flexDirection:`column`,marginTop:1,children:[(0,q.jsxs)(l,{children:[(0,q.jsx)(u,{bold:!0,children:`Custom agents`}),(0,q.jsx)(u,{dimColor:!0,children:` · /agents`})]}),Array.from(G(f).entries()).map(([e,t])=>(0,q.jsxs)(l,{flexDirection:`column`,marginTop:1,children:[(0,q.jsx)(u,{dimColor:!0,children:e}),t.map((e,t)=>(0,q.jsxs)(l,{children:[(0,q.jsxs)(u,{children:[`└ `,e.agentType,`: `]}),(0,q.jsxs)(u,{dimColor:!0,children:[v(e.tokens),` tokens`]})]},t))]},e))]}),s.length>0&&(0,q.jsxs)(l,{flexDirection:`column`,marginTop:1,children:[(0,q.jsxs)(l,{children:[(0,q.jsx)(u,{bold:!0,children:`Memory files`}),(0,q.jsx)(u,{dimColor:!0,children:` · /memory`})]}),s.map((e,t)=>(0,q.jsxs)(l,{children:[(0,q.jsxs)(u,{children:[`└ `,h(e.path),`: `]}),(0,q.jsxs)(u,{dimColor:!0,children:[v(e.tokens),` tokens`]})]},t))]}),p&&p.tokens>0&&(0,q.jsxs)(l,{flexDirection:`column`,marginTop:1,children:[(0,q.jsxs)(l,{children:[(0,q.jsx)(u,{bold:!0,children:`Skills`}),(0,q.jsx)(u,{dimColor:!0,children:` · /skills`})]}),Array.from(G(p.skillFrontmatter).entries()).map(([e,t])=>(0,q.jsxs)(l,{flexDirection:`column`,marginTop:1,children:[(0,q.jsx)(u,{dimColor:!0,children:e}),t.map((e,t)=>(0,q.jsxs)(l,{children:[(0,q.jsxs)(u,{children:[`└ `,e.name,`: `]}),(0,q.jsxs)(u,{dimColor:!0,children:[v(e.tokens),` tokens`]})]},t))]},e))]})]}),(0,q.jsx)(V,{suggestions:O(e)})]})}var q,J,Y,X=e((()=>{f(),B(),m(),y(),g(),U(),q=p(),J=`Autocompact buffer`,Y=[`Project`,`User`,`Managed`,`Plugin`,`Built-in`]}));function Z(e){return c(e)}async function Q(e,t){let{messages:n,getAppState:r,options:{mainLoopModel:i,tools:a}}=t,c=Z(n),{messages:l}=await s(c),u=process.stdout.columns||80,d=r();return e(await E((0,$.jsx)(K,{data:await o(l,i,async()=>d.toolPermissionContext,a,d.agentDefinitions,u,t,void 0,c)}))),null}var $;e((()=>{X(),r(),a(),i(),D(),$=p()}))();export{Q as call};
@@ -1,4 +1,4 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{$_ as t,La as n,U_ as r,V_ as i,ev as a,ka as o}from"./loadAgentsDir-DXOkUcW3.js";import{cn as s,sn as c}from"./settings-3xZ0fsvE.js";import{_ as l,v as u}from"./startupProfiler-CbzxVmbv.js";async function d(e){let{messages:t,getAppState:n,options:{mainLoopModel:r,tools:s,agentDefinitions:c,customSystemPrompt:l,appendSystemPrompt:u}}=e,d=o(t),{messages:f}=await a(d),p=n();return i(f,r,async()=>p.toolPermissionContext,s,c,void 0,{options:{customSystemPrompt:l,appendSystemPrompt:u}},void 0,d)}async function f(e,t){return{type:`text`,value:p(await d(t))}}function p(e){let{categories:t,totalTokens:n,rawMaxTokens:r,percentage:i,model:a,memoryFiles:o,mcpTools:s,agents:u,skills:d}=e,f=`## Context Usage
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{$_ as t,La as n,U_ as r,V_ as i,ev as a,ka as o}from"./loadAgentsDir-DaNpxaO-.js";import{cn as s,sn as c}from"./settings-3xZ0fsvE.js";import{_ as l,v as u}from"./startupProfiler-CbzxVmbv.js";async function d(e){let{messages:t,getAppState:n,options:{mainLoopModel:r,tools:s,agentDefinitions:c,customSystemPrompt:l,appendSystemPrompt:u}}=e,d=o(t),{messages:f}=await a(d),p=n();return i(f,r,async()=>p.toolPermissionContext,s,c,void 0,{options:{customSystemPrompt:l,appendSystemPrompt:u}},void 0,d)}async function f(e,t){return{type:`text`,value:p(await d(t))}}function p(e){let{categories:t,totalTokens:n,rawMaxTokens:r,percentage:i,model:a,memoryFiles:o,mcpTools:s,agents:u,skills:d}=e,f=`## Context Usage
2
2
 
3
3
  `;f+=`**Model:** ${a} \n`,f+=`**Tokens:** ${l(n)} / ${l(r)} (${i}%)\n`,f+=`
4
4
  `;let p=t.filter(e=>e.tokens>0&&e.name!==`Free space`&&e.name!==`Autocompact buffer`);if(p.length>0){f+=`### Estimated usage by category
@@ -0,0 +1 @@
1
+ import{n as e,r as t,t as n}from"./context-noninteractive-BzDVMnWC.js";t();export{n as call,e as collectContextData};
@@ -1 +1 @@
1
- import{a as e,n as t}from"./rolldown-runtime-DaDcL9Zw.js";import{AC as n,Ch as r,Dn as i,Fg as a,HT as o,Kn as s,Lg as c,Ls as l,Mg as u,On as d,Rs as f,St as p,Th as m,Tn as h,YT as g,br as _,di as v,h_ as y,hc as b,hn as x,jg as S,kC as C,m_ as w,mi as T,qt as E,sn as D,ti as O,tr as k,yt as A}from"./loadAgentsDir-DXOkUcW3.js";import{$ as j,$t as M,Cn as N,En as P,Ut as F,W as I,Zt as L,wn as R}from"./state-D5D6QpTX.js";import{o as z,s as B}from"./log-CZ7ploQm.js";import{n as V,r as H}from"./analytics-DJobLaWP.js";import{at as U,ut as W}from"./sessionState-DAcub-HK.js";import{n as G,t as K}from"./caches-BiVRgePi.js";import{randomUUID as q}from"crypto";function J(){return Y}var Y,X=t((()=>{b(),Y=null}));function Z(){let e=J();if(!e)return;e.markTranscriptReset?.();let t={type:`status`,subtype:`status`,status:`conversation_cleared`,message:`conversation_cleared`,uuid:q()};e.writeSdkMessages([t])}async function Q({setMessages:t,readFileState:c,discoveredSkillNames:l,loadedNestedMemoryPaths:d,getAppState:p,setAppState:m,setConversationId:g}){let b=D();await E(`clear`,{getAppState:p,setAppState:m,signal:AbortSignal.timeout(b),timeoutMs:b});let x=I();x&&H(`tengu_cache_eviction_hint`,{scope:`conversation_clear`,last_request_id:x});let S=new Set,C=[],w=e=>`isBackgrounded`in e&&e.isBackgrounded===!1;if(p)for(let e of Object.values(p().tasks))w(e)||f(e)&&(S.add(e.agentId),C.push(e));t(()=>[]),Z();let{setContextBlocked:F}=(U(),e(W));F(!1),g&&g(q()),K(S),N(null),R(null),P(null),M(),n(j()),c.clear(),l?.clear(),d?.clear(),m&&m(e=>{let t={};for(let[n,r]of Object.entries(e.tasks)){if(!w(r)){t[n]=r;continue}try{r.status===`running`&&(u(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){B(e)}h(n)}return{...e,tasks:t,attribution:r(),standaloneAgentContext:void 0,fileHistory:{snapshots:[],trackedFiles:new Set,snapshotSequence:0},mcp:{clients:[],tools:[],commands:[],resources:{},pluginReconnectKey:e.mcp.pluginReconnectKey}}}),o(),s(),L({setCurrentAsParent:!0}),await O();for(let e of C)e.status===`running`&&i(e.id,k(a(e.agentId)));let{saveMode:z}=(_(),e(T));z(`normal`);let V=A();V&&v(V);let G=await y(`clear`);G.length>0&&t(()=>G)}var $=t((()=>{X(),F(),V(),l(),S(),c(),m(),x(),z(),g(),C(),w(),_(),d(),p(),G()}));export{$ as n,Q as t};
1
+ import{a as e,n as t}from"./rolldown-runtime-DaDcL9Zw.js";import{AC as n,Ch as r,Dn as i,Fg as a,HT as o,Kn as s,Lg as c,Ls as l,Mg as u,On as d,Rs as f,St as p,Th as m,Tn as h,YT as g,br as _,di as v,h_ as y,hc as b,hn as x,jg as S,kC as C,m_ as w,mi as T,qt as E,sn as D,ti as O,tr as k,yt as A}from"./loadAgentsDir-DaNpxaO-.js";import{$ as j,$t as M,Cn as N,En as P,Ut as F,W as I,Zt as L,wn as R}from"./state-D5D6QpTX.js";import{o as z,s as B}from"./log-CZ7ploQm.js";import{n as V,r as H}from"./analytics-DJobLaWP.js";import{at as U,ut as W}from"./sessionState-CQhbGfmh.js";import{n as G,t as K}from"./caches-DH-q8Fjf.js";import{randomUUID as q}from"crypto";function J(){return Y}var Y,X=t((()=>{b(),Y=null}));function Z(){let e=J();if(!e)return;e.markTranscriptReset?.();let t={type:`status`,subtype:`status`,status:`conversation_cleared`,message:`conversation_cleared`,uuid:q()};e.writeSdkMessages([t])}async function Q({setMessages:t,readFileState:c,discoveredSkillNames:l,loadedNestedMemoryPaths:d,getAppState:p,setAppState:m,setConversationId:g}){let b=D();await E(`clear`,{getAppState:p,setAppState:m,signal:AbortSignal.timeout(b),timeoutMs:b});let x=I();x&&H(`tengu_cache_eviction_hint`,{scope:`conversation_clear`,last_request_id:x});let S=new Set,C=[],w=e=>`isBackgrounded`in e&&e.isBackgrounded===!1;if(p)for(let e of Object.values(p().tasks))w(e)||f(e)&&(S.add(e.agentId),C.push(e));t(()=>[]),Z();let{setContextBlocked:F}=(U(),e(W));F(!1),g&&g(q()),K(S),N(null),R(null),P(null),M(),n(j()),c.clear(),l?.clear(),d?.clear(),m&&m(e=>{let t={};for(let[n,r]of Object.entries(e.tasks)){if(!w(r)){t[n]=r;continue}try{r.status===`running`&&(u(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){B(e)}h(n)}return{...e,tasks:t,attribution:r(),standaloneAgentContext:void 0,fileHistory:{snapshots:[],trackedFiles:new Set,snapshotSequence:0},mcp:{clients:[],tools:[],commands:[],resources:{},pluginReconnectKey:e.mcp.pluginReconnectKey}}}),o(),s(),L({setCurrentAsParent:!0}),await O();for(let e of C)e.status===`running`&&i(e.id,k(a(e.agentId)));let{saveMode:z}=(_(),e(T));z(`normal`);let V=A();V&&v(V);let G=await y(`clear`);G.length>0&&t(()=>G)}var $=t((()=>{X(),F(),V(),l(),S(),c(),m(),x(),z(),g(),C(),w(),_(),d(),p(),G()}));export{$ as n,Q as t};
@@ -0,0 +1 @@
1
+ import{n as e,t}from"./conversation-BBOE_EoE.js";e();export{t as clearConversation};
@@ -1,4 +1,4 @@
1
- import{n as e,t}from"./defineProperty-C-QyHrDq.js";import{C as n,S as r,c as i,i as a,x as o}from"./debug-D58GQBDG.js";import{l as s,u as c}from"./oauth-D38aRTUb.js";import{Pt as l,St as u}from"./model-Cxx3suBa.js";import{t as d}from"./cliLaunch-DDtwAolw.js";import{resolve as f}from"path";import{existsSync as p,unlinkSync as m}from"fs";import{randomUUID as h}from"crypto";a(),o(),e();function g(e){return typeof e==`object`&&!!e&&`type`in e&&typeof e.type==`string`}var _=2e3,v=15e3,y=3,b=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??y}connect(){this.connected||(this.readLoopAbort=new AbortController,this.startReadLoop(),this.monitorExit(),this.connected=!0,this.options.onConnected())}async startReadLoop(){let e=this.proc.stdout;if(!e){this.options.onError(Error(`SSH process stdout is not available`));return}let t=e.getReader(),n=new TextDecoder,r=``;try{for(;!this.disconnected;){let{done:e,value:i}=await t.read();if(e)break;r+=n.decode(i,{stream:!0});let a=r.split(`
1
+ import{n as e,t}from"./defineProperty-C-QyHrDq.js";import{C as n,S as r,c as i,i as a,x as o}from"./debug-D58GQBDG.js";import{l as s,u as c}from"./oauth-D38aRTUb.js";import{Pt as l,St as u}from"./model-Do0f476p.js";import{t as d}from"./cliLaunch-DDtwAolw.js";import{resolve as f}from"path";import{existsSync as p,unlinkSync as m}from"fs";import{randomUUID as h}from"crypto";a(),o(),e();function g(e){return typeof e==`object`&&!!e&&`type`in e&&typeof e.type==`string`}var _=2e3,v=15e3,y=3,b=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??y}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(_*2**(this.reconnectAttempt-1),v);if(await new Promise(e=>setTimeout(e,t)),this.userInitiatedDisconnect)return;try{let t=await e();this.proc=t,this.reconnectAttempt=0,this.connected=!0,this.startReadLoop(),this.monitorExit(),this.options.onConnected();return}catch(e){i(`[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=r(e)}catch{return}if(!g(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):(i(`[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}\n`);return t.write(n),t.flush?.(),!0}catch{return!1}}async sendMessage(e){let t=n({type:`user`,message:{role:`user`,content:e},parent_tool_use_id:null,session_id:``});return this.writeToStdin(t)}sendInterrupt(){let e=n({type:`control_request`,request_id:crypto.randomUUID(),request:{subtype:`interrupt`}});this.writeToStdin(e)}respondToPermissionRequest(e,t){let r=n({type:`control_response`,response:{subtype:`success`,request_id:e,response:{behavior:t.behavior,...t.behavior===`allow`?{updatedInput:t.updatedInput}:{message:t.message}}}});this.writeToStdin(r)}sendErrorResponse(e,t){let r=n({type:`control_response`,response:{subtype:`error`,request_id:e,error:t}});this.writeToStdin(r)}disconnect(){if(!this.disconnected){this.userInitiatedDisconnect=!0,this.disconnected=!0,this.connected=!1,this.readLoopAbort?.abort();try{let e=this.proc.stdin;e&&typeof e!=`number`&&e.end?.()}catch{}try{this.proc.kill()}catch{}}}isConnected(){return this.connected&&!this.disconnected}};l(),c(),a();var x=process.platform===`win32`;function S(){let e=process.env.ANTHROPIC_API_KEY;if(e)return{"x-api-key":e};let t=u();return t?.accessToken?{Authorization:`Bearer ${t.accessToken}`}:{}}function C(){return process.env.ANTHROPIC_BASE_URL||s().BASE_API_URL}async function w(e,t){if(t&&e.headers.get(`x-auth-nonce`)!==t)return new Response(`Forbidden`,{status:403});let n=C(),r=new URL(e.url),a=`${n}${r.pathname}${r.search}`,o=S();if(Object.keys(o).length===0)return new Response(JSON.stringify({error:`No API credentials available on local machine`}),{status:401,headers:{"content-type":`application/json`}});let s=new Headers(e.headers);for(let[e,t]of Object.entries(o))s.set(e,t);s.delete(`host`),s.delete(`x-auth-nonce`),i(`[SSHAuthProxy] ${e.method} ${r.pathname} -> ${a}`);try{let t=await fetch(a,{method:e.method,headers:s,body:e.body,duplex:`half`}),n=new Headers(t.headers);return n.delete(`content-encoding`),n.delete(`content-length`),new Response(t.body,{status:t.status,statusText:t.statusText,headers:n})}catch(e){let t=e instanceof Error?e.message:String(e);return i(`[SSHAuthProxy] upstream error: ${t}`),new Response(JSON.stringify({error:`Proxy upstream error: ${t}`}),{status:502,headers:{"content-type":`application/json`}})}}async function T(){let e=h();return x?D(e):E(e)}async function E(e){let t=`/tmp/claude-ssh-auth-${e}.sock`,n=Bun.serve({unix:t,fetch:e=>w(e,null)});return i(`[SSHAuthProxy] listening on unix:${t}`),{proxy:{stop(){n.stop(!0);try{m(t)}catch{}}},localAddress:t,authEnv:{ANTHROPIC_AUTH_SOCKET:t}}}async function D(e){let t=h(),n=Bun.serve({port:0,hostname:`127.0.0.1`,fetch:e=>w(e,t)}),r=n.port;return i(`[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}}}a();var O=15e3,k=class extends Error{constructor(e){super(e),this.name=`SSHProbeError`}};async function A(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 k(`SSH probe timed out after ${O/1e3}s`)),O))]),a=await new Response(n.stdout).text(),o=await new Response(n.stderr).text();if(r!==0)throw new k(`SSH probe failed: ${o.trim()||`exit code ${r}`}`);let s=a.split(`
3
3
  `).map(e=>e.trim()).filter(Boolean);i(`[SSHProbe] raw lines: ${JSON.stringify(s)}`);let c=s.findIndex(e=>/^(Linux|Darwin)\s/.test(e));if(c===-1)throw new k(`Could not detect remote platform (uname output missing)`);let l=c>=2&&s[c-2]||null,u=c>=1&&s[c-1]||null,d=u&&/^\d+\.\d+/.test(u)?u:null,f=l?.startsWith(`/`)??!1,p=s[c+1]||`/`,[m,h]=s[c].split(/\s+/),g=m===`Darwin`?`darwin`:`linux`,_=h===`aarch64`||h===`arm64`?`arm64`:`x64`;return t?.(`Detected ${g}/${_}`),{hasBinary:f&&d!==null,remoteVersion:d,remotePlatform:g,remoteArch:_,defaultCwd:p,binaryPath:f?l:null}}a();var j=6e4,M=`~/.local/bin`,N=`claude-code-cli.js`,P=`claude`;async function F(e,t,n=j){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 I(){let e=f(import.meta.dir,`../..`),t=f(e,`dist/cli.js`);if(p(t))return t;let n=f(e,`src/entrypoints/cli.tsx`);if(p(n))return n;throw Error("Cannot find local CLI binary to deploy. Run `bun run build` first.")}async function L(e){let{host:t,remotePlatform:n,remoteArch:r,localVersion:a,onProgress:o}=e;if(n!==`linux`&&n!==`darwin`)throw Error(`Remote platform "${n}" is not supported. Only linux and darwin are supported.`);i(`[SSHDeploy] deploying to ${t} (${n}/${r}, v${a})`);let s=I();i(`[SSHDeploy] local binary: ${s}`),o?.(`Creating remote directory...`);let c=await F(t,`mkdir -p ${M}`);if(c.exitCode!==0)throw Error(`Failed to create remote directory: ${c.stderr}`);o?.(`Uploading binary...`);let l=`${M}/${N}`,u=Bun.spawn([`scp`,`-o`,`ConnectTimeout=10`,s,`${t}:${l}`],{stdout:`pipe`,stderr:`pipe`}),d=setTimeout(()=>u.kill(),j),f=await new Response(u.stderr).text(),p=await u.exited;if(clearTimeout(d),p!==0)throw Error(`SCP upload failed (exit ${p}): ${f.trim()}`);o?.(`Installing wrapper script...`);let m=await F(t,[`cat > ${M}/${P} << 'WRAPPER'`,`#!/bin/sh`,`exec bun ${M}/${N} "$@"`,`WRAPPER`,`chmod +x ${M}/${P}`].join(`
4
4
  `));if(m.exitCode!==0)throw Error(`Failed to install wrapper script: ${m.stderr}`);o?.(`Verifying installation...`);let h=await F(t,`${M}/${P} --version`);if(h.exitCode!==0)throw Error(`Binary deployed but verification failed (exit ${h.exitCode}): ${h.stderr}`);return i(`[SSHDeploy] deployed successfully, remote version: ${h.stdout}`),o?.(`Deployed v${h.stdout}`),`${M}/${P}`}a(),o();var R=3e4,z=20,B=class extends Error{constructor(e){super(e),this.name=`SSHSessionError`}};async function V(e,t){let{host:n,localVersion:r,extraCliArgs:a,remoteBin:o}=e,s=t?.onProgress,c,l=`/`;if(o){s?.(`Using custom remote binary, skipping probe/deploy…`),c=o,i(`[SSH] custom remoteBin: ${o}`);try{let e=Bun.spawn([`ssh`,`-o`,`BatchMode=yes`,`-o`,`ConnectTimeout=5`,n,`pwd`],{stdin:`ignore`,stdout:`pipe`,stderr:`ignore`});await e.exited;let t=(await new Response(e.stdout).text()).trim();t.startsWith(`/`)&&(l=t)}catch{}}else{let e=await A(n,s);i(`[SSH] probe result: ${JSON.stringify(e)}`),l=e.defaultCwd,c=e.binaryPath??`~/.local/bin/claude`,(!e.hasBinary||e.remoteVersion!==r)&&(s?.(e.hasBinary?`Updating remote binary (${e.remoteVersion} → ${r})…`:`Deploying binary to remote…`),c=await L({host:n,remotePlatform:e.remotePlatform,remoteArch:e.remoteArch,localVersion:r,onProgress:s}))}let{proxy:u,localAddress:d,authEnv:f}=await T();i(`[SSH] auth proxy listening on ${d}`);let p=h().slice(0,8),m=process.platform===`win32`,g=[];for(let[e,t]of Object.entries(f))g.push(`${e}=${t}`);g.push(c,`--output-format`,`stream-json`,`--input-format`,`stream-json`,`--verbose`,`-p`),e.cwd&&g.push(`--cwd`,e.cwd),e.permissionMode&&g.push(`--permission-mode`,e.permissionMode),e.dangerouslySkipPermissions&&g.push(`--dangerously-skip-permissions`),g.push(...a);let _=[`ssh`];if(m){let e=d.split(`:`)[1],t=1e4+Math.floor(Math.random()*5e4);_.push(`-R`,`${t}:127.0.0.1:${e}`);let n=g.findIndex(e=>e.startsWith(`ANTHROPIC_BASE_URL=`));n!==-1&&(g[n]=`ANTHROPIC_BASE_URL=http://127.0.0.1:${t}`)}else{let e=`/tmp/claude-ssh-auth-${p}.sock`;_.push(`-R`,`${e}:${d}`),_.push(`-o`,`StreamLocalBindUnlink=yes`);let t=g.indexOf(`ANTHROPIC_AUTH_SOCKET=${f.ANTHROPIC_AUTH_SOCKET}`);t!==-1&&(g[t]=`ANTHROPIC_AUTH_SOCKET=${e}`)}_.push(n,g.join(` `)),s?.(`Starting remote session…`),i(`[SSH] spawning: ${_.join(` `)}`);let v;try{v=Bun.spawn(_,{stdin:`pipe`,stdout:`pipe`,stderr:`pipe`})}catch(e){throw u.stop(),new B(`Failed to spawn SSH process: ${e instanceof Error?e.message:String(e)}`)}let y=[];W(v,y);let x;if(o){let t=await Promise.race([v.exited.then(e=>e),new Promise(e=>setTimeout(()=>e(null),3e3))]);if(t!==null){u.stop();let e=y.join(``).trim();throw new B(`Remote process exited immediately (code ${t})${e?`: ${e}`:``}`)}x=e.cwd||l||`/`}else try{x=await U(v,e.cwd||l)}catch(e){throw u.stop(),v.kill(),e}i(`[SSH] remote session initialized, remoteCwd=${x}`);let S=v,C=async()=>{i(`[SSH] reconnect: re-spawning SSH process with --continue`);let e=[..._],t=e.length-1,n=e[t];n.includes(`--continue`)||(e[t]=n.replace(/ -p(?:\s|$)/,` -p --continue `));let r=Bun.spawn(e,{stdin:`pipe`,stdout:`pipe`,stderr:`pipe`}),a=[];return W(r,a),await U(r,x),S=r,y.length=0,y.push(...a),r};return{remoteCwd:x,get proc(){return S},proxy:u,createManager(e){return new b(S,{...e,reconnect:C})},getStderrTail(){return y.slice(-20).join(``)}}}async function H(e){let{proxy:t,authEnv:n}=await T(),r=[`--output-format`,`stream-json`,`--input-format`,`stream-json`,`-p`];e.cwd&&r.push(`--cwd`,e.cwd),e.permissionMode&&r.push(`--permission-mode`,e.permissionMode),e.dangerouslySkipPermissions&&r.push(`--dangerously-skip-permissions`);let a=d(r),o;try{o=Bun.spawn([a.execPath,...a.args],{stdin:`pipe`,stdout:`pipe`,stderr:`pipe`,env:{...a.env,...n}})}catch(e){throw t.stop(),new B(`Failed to spawn local CLI process: ${e instanceof Error?e.message:String(e)}`)}i(`[SSH] local session spawned, waiting for init message...`);let s=[];W(o,s);let c;try{c=await U(o,e.cwd)}catch(e){throw t.stop(),o.kill(),e}i(`[SSH] local session initialized, remoteCwd=${c}`);let l=o,u=async()=>{i(`[SSH] local reconnect: re-spawning CLI with --continue`);let e=[...r];e.includes(`--continue`)||e.push(`--continue`);let t=d(e),a=Bun.spawn([t.execPath,...t.args],{stdin:`pipe`,stdout:`pipe`,stderr:`pipe`,env:{...t.env,...n}}),o=[];return W(a,o),await U(a,c),l=a,s.length=0,s.push(...o),a};return{remoteCwd:c,get proc(){return l},proxy:t,createManager(e){return new b(l,{...e,reconnect:u})},getStderrTail(){return s.slice(-20).join(``)}}}async function U(e,t){let n=e.stdout;if(!n)throw new B(`Child process stdout is not readable`);let i=n.getReader(),a=new TextDecoder,o=``,s=Date.now()+R;try{for(;Date.now()<s;){let e=s-Date.now(),n=await Promise.race([i.read(),new Promise((t,n)=>setTimeout(()=>n(new B(`Remote CLI did not initialize within 30 seconds. Check SSH connectivity and remote binary.`)),e))]);if(n.done)throw new B(`Child process exited before sending init message`);o+=a.decode(n.value,{stream:!0});let c=o.split(`
@@ -0,0 +1 @@
1
+ import{a as e,i as t,n,r}from"./createSession-Dgwxk1WA.js";t();export{n as createBridgeSession,r as getBridgeSession,e as updateBridgeSessionTitle};
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{P as t,R as n,c as r,i}from"./debug-D58GQBDG.js";import{i as a,t as o}from"./sessionIdCompat-Dgp6PW_1.js";import{i as s,o as c}from"./debugUtils-DXBRbwCE.js";async function l({environmentId:e,title:n,events:i,gitRepoUrl:a,branch:o,signal:c,baseUrl:l,getAccessToken:u,permissionMode:d}){let{getClaudeAIOAuthTokens:f}=await import(`./auth-CubXYcRl.js`),{getOrganizationUUID:p}=await import(`./client-CmnPWgLq.js`),{getOauthConfig:m}=await import(`./oauth-U649LV5H.js`),{getOAuthHeaders:h}=await import(`./api-CB3e0De0.js`),{parseGitHubRepository:g}=await import(`./detectRepository-Cv9-k6dg.js`),{getDefaultBranch:_}=await import(`./git-zJCasBa6.js`),{getMainLoopModel:v}=await import(`./model-aEJ54cMA.js`),{default:y}=await import(`./axios-BHBm_hhU.js`),{isSelfHostedBridge:b}=await import(`./bridgeConfig-Cp2x_wtE.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-Cv9-k6dg.js`),t=e(a);if(t){let{host:e,owner:n,name:r}=t,i=o||await _()||void 0;C={type:`git_repository`,url:`https://${e}/${n}/${r}`,revision:i},w={type:`git_repository`,git_info:{type:`github`,repo:`${n}/${r}`,branches:[`claude/${o||`task`}`]}}}else{let e=g(a);if(e){let[t,n]=e.split(`/`);if(t&&n){let e=o||await _()||void 0;C={type:`git_repository`,url:`https://github.com/${t}/${n}`,revision:e},w={type:`git_repository`,git_info:{type:`github`,repo:`${t}/${n}`,branches:[`claude/${o||`task`}`]}}}}}}let T={...n!==void 0&&{title:n},events:i,session_context:{sources:C?[C]:[],outcomes:w?[w]:[],model:v()},environment_id:e,source:`remote-control`,...d&&{permission_mode:d}},E={...h(x),"anthropic-beta":`ccr-byoc-2025-07-29`,"x-organization-uuid":S},D=`${l??m().BASE_API_URL}/v1/sessions`,O;try{O=await y.post(D,T,{headers:E,signal:c,validateStatus:e=>e<500})}catch(e){return r(`[bridge] Session creation request failed: ${t(e)}`),null}if(!(O.status===200||O.status===201)){let e=s(O.data);return r(`[bridge] Session creation failed with status ${O.status}${e?`: ${e}`:``}`),null}let k=O.data;return!k||typeof k!=`object`||!(`id`in k)||typeof k.id!=`string`?(r(`[bridge] No session ID in response`),null):k.id}async function u(e,n){let{getClaudeAIOAuthTokens:i}=await import(`./auth-CubXYcRl.js`),{getOrganizationUUID:a}=await import(`./client-CmnPWgLq.js`),{getOauthConfig:o}=await import(`./oauth-U649LV5H.js`),{getOAuthHeaders:c}=await import(`./api-CB3e0De0.js`),{default:l}=await import(`./axios-BHBm_hhU.js`),{isSelfHostedBridge:u}=await import(`./bridgeConfig-Cp2x_wtE.js`),d=n?.getAccessToken?.()??i()?.accessToken;if(!d)return r(`[bridge] No access token for session fetch`),null;let f=u()?`self-hosted`:await a();if(!f)return r(`[bridge] No org UUID for session fetch`),null;let p={...c(d),"anthropic-beta":`ccr-byoc-2025-07-29`,"x-organization-uuid":f},m=`${n?.baseUrl??o().BASE_API_URL}/v1/sessions/${e}`;r(`[bridge] Fetching session ${e}`);let h;try{h=await l.get(m,{headers:p,timeout:1e4,validateStatus:e=>e<500})}catch(e){return r(`[bridge] Session fetch request failed: ${t(e)}`),null}if(h.status!==200){let e=s(h.data);return r(`[bridge] Session fetch failed with status ${h.status}${e?`: ${e}`:``}`),null}return h.data}async function d(e,t){let{getClaudeAIOAuthTokens:n}=await import(`./auth-CubXYcRl.js`),{getOrganizationUUID:i}=await import(`./client-CmnPWgLq.js`),{getOauthConfig:a}=await import(`./oauth-U649LV5H.js`),{getOAuthHeaders:o}=await import(`./api-CB3e0De0.js`),{default:c}=await import(`./axios-BHBm_hhU.js`),{isSelfHostedBridge:l}=await import(`./bridgeConfig-Cp2x_wtE.js`),u=t?.getAccessToken?.()??n()?.accessToken;if(!u){r(`[bridge] No access token for session archive`);return}let d=l()?`self-hosted`:await i();if(!d){r(`[bridge] No org UUID for session archive`);return}let f={...o(u),"anthropic-beta":`ccr-byoc-2025-07-29`,"x-organization-uuid":d},p=`${t?.baseUrl??a().BASE_API_URL}/v1/sessions/${e}/archive`;r(`[bridge] Archiving session ${e}`);let m=await c.post(p,{},{headers:f,timeout:t?.timeoutMs??1e4,validateStatus:e=>e<500});if(m.status===200)r(`[bridge] Session ${e} archived successfully`);else{let e=s(m.data);r(`[bridge] Session archive failed with status ${m.status}${e?`: ${e}`:``}`)}}async function f(e,n,i){let{getClaudeAIOAuthTokens:o}=await import(`./auth-CubXYcRl.js`),{getOrganizationUUID:c}=await import(`./client-CmnPWgLq.js`),{getOauthConfig:l}=await import(`./oauth-U649LV5H.js`),{getOAuthHeaders:u}=await import(`./api-CB3e0De0.js`),{default:d}=await import(`./axios-BHBm_hhU.js`),{isSelfHostedBridge:f}=await import(`./bridgeConfig-Cp2x_wtE.js`),p=i?.getAccessToken?.()??o()?.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=a(e),_=`${i?.baseUrl??l().BASE_API_URL}/v1/sessions/${g}`;r(`[bridge] Updating session title: ${g} → ${n}`);try{let e=await d.patch(_,{title:n},{headers:h,timeout:1e4,validateStatus:e=>e<500});if(e.status===200)r(`[bridge] Session title updated successfully`);else{let t=s(e.data);r(`[bridge] Session title update failed with status ${e.status}${t?`: ${t}`:``}`)}}catch(e){r(`[bridge] Session title update request failed: ${t(e)}`)}}var p=e((()=>{i(),n(),c(),o()}));export{f as a,p as i,l as n,u as r,d as t};
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{P as t,R as n,c as r,i}from"./debug-D58GQBDG.js";import{i as a,t as o}from"./sessionIdCompat-Dgp6PW_1.js";import{i as s,o as c}from"./debugUtils-DXBRbwCE.js";async function l({environmentId:e,title:n,events:i,gitRepoUrl:a,branch:o,signal:c,baseUrl:l,getAccessToken:u,permissionMode:d}){let{getClaudeAIOAuthTokens:f}=await import(`./auth-BEoTPSgC.js`),{getOrganizationUUID:p}=await import(`./client-C19cqYQS.js`),{getOauthConfig:m}=await import(`./oauth-U649LV5H.js`),{getOAuthHeaders:h}=await import(`./api-BHBK9axp.js`),{parseGitHubRepository:g}=await import(`./detectRepository-Cv9-k6dg.js`),{getDefaultBranch:_}=await import(`./git-zJCasBa6.js`),{getMainLoopModel:v}=await import(`./model-DX0TtzqX.js`),{default:y}=await import(`./axios-BHBm_hhU.js`),{isSelfHostedBridge:b}=await import(`./bridgeConfig-CJMjDoaP.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-Cv9-k6dg.js`),t=e(a);if(t){let{host:e,owner:n,name:r}=t,i=o||await _()||void 0;C={type:`git_repository`,url:`https://${e}/${n}/${r}`,revision:i},w={type:`git_repository`,git_info:{type:`github`,repo:`${n}/${r}`,branches:[`claude/${o||`task`}`]}}}else{let e=g(a);if(e){let[t,n]=e.split(`/`);if(t&&n){let e=o||await _()||void 0;C={type:`git_repository`,url:`https://github.com/${t}/${n}`,revision:e},w={type:`git_repository`,git_info:{type:`github`,repo:`${t}/${n}`,branches:[`claude/${o||`task`}`]}}}}}}let T={...n!==void 0&&{title:n},events:i,session_context:{sources:C?[C]:[],outcomes:w?[w]:[],model:v()},environment_id:e,source:`remote-control`,...d&&{permission_mode:d}},E={...h(x),"anthropic-beta":`ccr-byoc-2025-07-29`,"x-organization-uuid":S},D=`${l??m().BASE_API_URL}/v1/sessions`,O;try{O=await y.post(D,T,{headers:E,signal:c,validateStatus:e=>e<500})}catch(e){return r(`[bridge] Session creation request failed: ${t(e)}`),null}if(!(O.status===200||O.status===201)){let e=s(O.data);return r(`[bridge] Session creation failed with status ${O.status}${e?`: ${e}`:``}`),null}let k=O.data;return!k||typeof k!=`object`||!(`id`in k)||typeof k.id!=`string`?(r(`[bridge] No session ID in response`),null):k.id}async function u(e,n){let{getClaudeAIOAuthTokens:i}=await import(`./auth-BEoTPSgC.js`),{getOrganizationUUID:a}=await import(`./client-C19cqYQS.js`),{getOauthConfig:o}=await import(`./oauth-U649LV5H.js`),{getOAuthHeaders:c}=await import(`./api-BHBK9axp.js`),{default:l}=await import(`./axios-BHBm_hhU.js`),{isSelfHostedBridge:u}=await import(`./bridgeConfig-CJMjDoaP.js`),d=n?.getAccessToken?.()??i()?.accessToken;if(!d)return r(`[bridge] No access token for session fetch`),null;let f=u()?`self-hosted`:await a();if(!f)return r(`[bridge] No org UUID for session fetch`),null;let p={...c(d),"anthropic-beta":`ccr-byoc-2025-07-29`,"x-organization-uuid":f},m=`${n?.baseUrl??o().BASE_API_URL}/v1/sessions/${e}`;r(`[bridge] Fetching session ${e}`);let h;try{h=await l.get(m,{headers:p,timeout:1e4,validateStatus:e=>e<500})}catch(e){return r(`[bridge] Session fetch request failed: ${t(e)}`),null}if(h.status!==200){let e=s(h.data);return r(`[bridge] Session fetch failed with status ${h.status}${e?`: ${e}`:``}`),null}return h.data}async function d(e,t){let{getClaudeAIOAuthTokens:n}=await import(`./auth-BEoTPSgC.js`),{getOrganizationUUID:i}=await import(`./client-C19cqYQS.js`),{getOauthConfig:a}=await import(`./oauth-U649LV5H.js`),{getOAuthHeaders:o}=await import(`./api-BHBK9axp.js`),{default:c}=await import(`./axios-BHBm_hhU.js`),{isSelfHostedBridge:l}=await import(`./bridgeConfig-CJMjDoaP.js`),u=t?.getAccessToken?.()??n()?.accessToken;if(!u){r(`[bridge] No access token for session archive`);return}let d=l()?`self-hosted`:await i();if(!d){r(`[bridge] No org UUID for session archive`);return}let f={...o(u),"anthropic-beta":`ccr-byoc-2025-07-29`,"x-organization-uuid":d},p=`${t?.baseUrl??a().BASE_API_URL}/v1/sessions/${e}/archive`;r(`[bridge] Archiving session ${e}`);let m=await c.post(p,{},{headers:f,timeout:t?.timeoutMs??1e4,validateStatus:e=>e<500});if(m.status===200)r(`[bridge] Session ${e} archived successfully`);else{let e=s(m.data);r(`[bridge] Session archive failed with status ${m.status}${e?`: ${e}`:``}`)}}async function f(e,n,i){let{getClaudeAIOAuthTokens:o}=await import(`./auth-BEoTPSgC.js`),{getOrganizationUUID:c}=await import(`./client-C19cqYQS.js`),{getOauthConfig:l}=await import(`./oauth-U649LV5H.js`),{getOAuthHeaders:u}=await import(`./api-BHBK9axp.js`),{default:d}=await import(`./axios-BHBm_hhU.js`),{isSelfHostedBridge:f}=await import(`./bridgeConfig-CJMjDoaP.js`),p=i?.getAccessToken?.()??o()?.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=a(e),_=`${i?.baseUrl??l().BASE_API_URL}/v1/sessions/${g}`;r(`[bridge] Updating session title: ${g} → ${n}`);try{let e=await d.patch(_,{title:n},{headers:h,timeout:1e4,validateStatus:e=>e<500});if(e.status===200)r(`[bridge] Session title updated successfully`);else{let t=s(e.data);r(`[bridge] Session title update failed with status ${e.status}${t?`: ${t}`:``}`)}}catch(e){r(`[bridge] Session title update request failed: ${t(e)}`)}}var p=e((()=>{i(),n(),c(),o()}));export{f as a,p as i,l as n,u as r,d as t};
@@ -1,4 +1,4 @@
1
- import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{$u as n,Ci as r,Dp as i,Gc as a,Hu as o,Mu as s,Nr as c,Op as l,Pu as u,Qu as d,Si as f,Sr as ee,Uu as p,Uw as m,Ww as h,br as g,cd as te,fr as _,gC as v,ir as y,ld as ne,oi as re,qc as ie,uC as b,wr as x}from"./loadAgentsDir-DXOkUcW3.js";import{C as ae,D as S,Gr as C,H as oe,I as w,P as T,T as E,Wt as se,Xn as ce,ai as D,di as O,fi as le,hn as ue,k as de,oi as fe,ot as pe,p as k,t as me}from"./src-DL3w8VPk2.js";import{t as A}from"./jsx-runtime-Bb4Xn-E0.js";import{$ as he,Ut as ge,ft as _e}from"./state-D5D6QpTX.js";import{S as j,c as M,i as ve,x as ye}from"./debug-D58GQBDG.js";import{In as N,Ln as be}from"./settings-3xZ0fsvE.js";import{i as xe,m as Se}from"./git-By_J4XJL.js";import{a as Ce,o as we,s as Te}from"./log-CZ7ploQm.js";import{n as Ee,r as P}from"./analytics-DJobLaWP.js";import{C as De,d as Oe,m as ke,v as Ae}from"./startupProfiler-CbzxVmbv.js";import{_ as F,h as I}from"./model-Cxx3suBa.js";import{i as je,r as Me}from"./shellQuote-Ddgr1vif.js";import{n as Ne,t as Pe}from"./useExitOnCtrlCDWithKeybindings-D0uqGxGw.js";import{t as Fe}from"./SearchBox-CwwV0W-w.js";import{n as Ie,t as Le}from"./useSearchInput-CXTa-leH.js";import{n as L,t as R}from"./Messages-DB1pmDY_.js";function Re({log:e,onExit:t,onSelect:n}){let[r,o]=z.useState(null);z.useEffect(()=>{o(null),x(e)&&c(e).then(o)},[e]);let s=x(e)&&r===null,l=r??e,u=_(l)||``,d=a();return se(`confirm:no`,t,{context:`Confirmation`}),se(`confirm:yes`,(0,z.useCallback)(()=>{n(r??e)},[n,r,e]),{context:`Confirmation`}),s?(0,B.jsxs)(w,{flexDirection:`column`,padding:1,children:[(0,B.jsx)(k,{message:`Loading session…`}),(0,B.jsx)(T,{dimColor:!0,children:(0,B.jsx)(E,{children:(0,B.jsx)(i,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})})})]}):(0,B.jsxs)(w,{flexDirection:`column`,children:[(0,B.jsx)(R,{messages:l.messages,tools:d,commands:[],verbose:!0,toolJSX:null,toolUseConfirmQueue:[],inProgressToolUseIDs:new Set,isMessageSelectorVisible:!1,conversationId:u,screen:`transcript`,streamingToolUses:[],showAllInTranscript:!0,isLoading:!1}),(0,B.jsxs)(w,{flexShrink:0,flexDirection:`column`,borderTopDimColor:!0,borderBottom:!1,borderLeft:!1,borderRight:!1,borderStyle:`single`,paddingLeft:2,children:[(0,B.jsxs)(T,{children:[ke(l.modified),` · `,l.messageCount,` messages`,l.gitBranch?` · ${l.gitBranch}`:``]}),(0,B.jsx)(T,{dimColor:!0,children:(0,B.jsxs)(E,{children:[(0,B.jsx)(S,{shortcut:`Enter`,action:`resume`}),(0,B.jsx)(i,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]})})]})]})}var z,B,ze=e((()=>{z=t(D(),1),me(),b(),ie(),Ae(),g(),l(),L(),B=A()}));function V(e,t){if(e===U)return 5;let n=C(e),r=t?Math.min(n,t-W-G):n;return Math.max(0,r)+W+G}function Be(e,t){let n=t-W-G;return C(e)<=n?e:n<=1?e.charAt(0):De(e,n)}function Ve({tabs:e,selectedIndex:t,availableWidth:n,showAllProjects:r=!1}){let i=r?`Resume (All Projects)`:`Resume`,a=i.length+1,o=Math.max(Ke,qe),s=n-a-o-2,c=Math.max(0,Math.min(t,e.length-1)),l=Math.max(20,Math.floor(s/2)),u=e.map(e=>V(e,l)),d=0,f=e.length;if(u.reduce((e,t,n)=>e+t+ +(n<u.length-1),0)>s){let t=s-Ge,n=u[c]??0;for(d=c,f=c+1;d>0||f<e.length;){let r=d>0,i=f<e.length;if(r){let e=(u[d-1]??0)+1;if(n+e<=t){d--,n+=e;continue}}if(i){let e=(u[f]??0)+1;if(n+e<=t){f++,n+=e;continue}}break}}let ee=d,p=e.length-f,m=e.slice(d,f),h=m.map((e,t)=>d+t);return(0,H.jsxs)(w,{flexDirection:`row`,gap:1,children:[(0,H.jsx)(T,{color:`suggestion`,children:i}),ee>0&&(0,H.jsxs)(T,{dimColor:!0,children:[K,ee]}),m.map((e,t)=>{let n=h[t]===c,r=e===U?e:`#${Be(e,l-W)}`;return(0,H.jsxs)(T,{backgroundColor:n?`suggestion`:void 0,color:n?`inverseText`:void 0,bold:n,children:[` `,r,` `]},e)}),p>0?(0,H.jsxs)(T,{dimColor:!0,children:[He,p,Ue]}):(0,H.jsx)(T,{dimColor:!0,children:We})]})}var H,U,W,G,K,He,Ue,We,Ge,Ke,qe,Je=e((()=>{me(),Ae(),H=A(),U=`All`,W=2,G=1,K=`← `,He=`→`,Ue=` (tab to cycle)`,We=`(tab to cycle)`,Ge=5,Ke=18,qe=14}));function Ye({nodes:e,onSelect:t,onCancel:n,onFocus:r,focusNodeId:i,visibleOptionCount:a,layout:o=`expanded`,isDisabled:s=!1,hideIndexes:c=!1,isNodeExpanded:l,onExpand:u,onCollapse:f,getParentPrefix:ee,getChildPrefix:p,onUpFromFirstItem:m}){let[h,g]=q.useState(new Set),te=q.useRef(!1),_=q.useRef(null),v=q.useCallback(e=>l?l(e):h.has(e),[l,h]),y=q.useMemo(()=>{let t=[];function n(e,r,i){let a=!!e.children&&e.children.length>0,o=v(e.id);if(t.push({node:e,depth:r,isExpanded:o,hasChildren:a,parentId:i}),a&&o&&e.children)for(let t of e.children)n(t,r+1,e.id)}for(let t of e)n(t,0);return t},[e,v]),ne=q.useCallback(e=>e?`▼ `:`▶ `,[]),re=q.useCallback(e=>` ▸ `,[]),ie=ee??ne,b=p??re,x=q.useCallback(e=>{let t=``;return e.hasChildren?t=ie(e.isExpanded):e.depth>0&&(t=b(e.depth)),t+e.node.label},[ie,b]),ae=q.useMemo(()=>y.map(e=>({label:x(e),description:e.node.description,dimDescription:e.node.dimDescription??!0,value:e.node.id})),[y,x]),S=q.useMemo(()=>{let e=new Map;return y.forEach(t=>e.set(t.node.id,t.node)),e},[y]),C=q.useCallback(e=>y.find(t=>t.node.id===e),[y]),oe=q.useCallback((e,t)=>{C(e)?.hasChildren&&(t?u?u(e):g(t=>new Set(t).add(e)):f?f(e):g(t=>{let n=new Set(t);return n.delete(e),n}))},[C,u,f]);return(0,Xe.jsx)(w,{tabIndex:0,autoFocus:!0,onKeyDown:e=>{if(!i||s)return;let t=C(i);if(t){if(e.key===`right`&&t.hasChildren)e.preventDefault(),oe(i,!0);else if(e.key===`left`){if(t.hasChildren&&t.isExpanded)e.preventDefault(),oe(i,!1);else if(t.parentId!==void 0&&(e.preventDefault(),te.current=!0,oe(t.parentId,!1),r)){let e=S.get(t.parentId);e&&r(e)}}}},children:(0,Xe.jsx)(d,{options:ae,onChange:q.useCallback(e=>{let n=S.get(e);n&&t(n)},[S,t]),onFocus:q.useCallback(e=>{if(te.current){te.current=!1;return}if(_.current!==e&&(_.current=e,r)){let t=S.get(e);t&&r(t)}},[r,S]),onCancel:n,defaultFocusValue:i,visibleOptionCount:a,layout:o,isDisabled:s,hideIndexes:c,onUpFromFirstItem:m})})}var q,Xe,Ze=e((()=>{q=t(D(),1),me(),n(),Xe=A()}));function Qe(e,t){return De(e.replace(/\s+/g,` `).trim(),t)}function $e({before:e,match:t,after:n},r){return O.dim(e)+r(t)+O.dim(n)}function et(e,t,n){let r=e.toLowerCase().indexOf(t.toLowerCase());if(r===-1)return null;let i=r+t.length,a=Math.max(0,r-n),o=Math.min(e.length,i+n),s=e.slice(a,r),c=e.slice(r,i),l=e.slice(i,o);return{before:(a>0?`…`:``)+s.replace(/\s+/g,` `).trimStart(),match:c.trim(),after:l.replace(/\s+/g,` `).trimEnd()+(o<e.length?`…`:``)}}function tt(e,t,n){let{isGroupHeader:r=!1,isChild:i=!1,forkCount:a=0}=n||{},o=r&&a>0?ct:i?lt:0,s=r&&a>0?` (+${a} other ${a===1?`session`:`sessions`})`:``,c=e.isSidechain?` (sidechain)`:``,l=t-o-c.length-s.length;return`${Qe(Ce(e),l)}${c}${s}`}function nt(e,t){let{isChild:n=!1,showProjectPath:r=!1}=t||{},i=n?` `:``,a=Oe(e),o=r&&e.projectPath?` · ${e.projectPath}`:``;return i+a+o}function rt({logs:e,maxHeight:t=1/0,forceWidth:n,onCancel:r,onSelect:a,onLogsChanged:c,onLoadMore:l,initialSearchQuery:u,showAllProjects:p=!1,onToggleAllProjects:m,onAgenticSearch:h}){let g=pe(),v=n===void 0?g.columns:n,ne=Ne(r),ie=ce(),b=ee(),[x]=oe(),C=o(x),D=J.useMemo(()=>e=>fe(e,C.warning),[C.warning]),[O,le]=J.useState(null),[k,me]=J.useState(!1),[A,ge]=J.useState(!1),[j,M]=J.useState(!1),ve=J.useMemo(()=>he(),[]),[ye,N]=J.useState(``),[be,Se]=J.useState(0),[we,Te]=J.useState(new Set),[Ee,De]=J.useState(null),[ke,Ae]=J.useState(1),[F,I]=J.useState(`list`),[je,Me]=J.useState(null),Pe=J.useRef(null),[Fe,Le]=J.useState(0),[L,R]=J.useState({status:`idle`}),[z,B]=J.useState(!1),ze=J.useRef(null),{query:V,setQuery:Be,cursorOffset:H}=Ie({isActive:F===`search`&&L.status!==`searching`,onExit:()=>{I(`list`),P(`tengu_session_search_toggled`,{enabled:!1})},onExitUp:()=>{I(`list`),P(`tengu_session_search_toggled`,{enabled:!1})},passthroughCtrlKeys:[`n`],initialQuery:u||``}),U=J.useDeferredValue(V),[W,G]=J.useState(``);J.useEffect(()=>{if(!U){G(``);return}let e=setTimeout(G,300,U);return()=>clearTimeout(e)},[U]);let[K,He]=J.useState(null),[Ue,We]=J.useState(!1);J.useEffect(()=>{xe().then(e=>le(e)),f(ve).then(e=>{M(e.length>1)})},[ve]);let Ge=J.useMemo(()=>new Map(e.map(e=>[e,at(e)])),[e]),Ke=J.useMemo(()=>null,[e,Ge,!1]),qe=J.useMemo(()=>st(e),[e]),Je=qe.length>0,q=J.useMemo(()=>Je?[`All`,...qe]:[],[Je,qe]),Xe=q.length>0&&Fe<q.length?Fe:0,Ze=q[Xe],rt=Ze===`All`?void 0:Ze,it=+!!Je,ct=J.useMemo(()=>{let t=e;return b&&(t=e.filter(e=>{let t=_e(),n=_(e);return!!(t&&n===t||e.customTitle||y(e.messages)||e.firstPrompt||e.customTitle)})),rt!==void 0&&(t=t.filter(e=>e.tag===rt)),k&&O&&(t=t.filter(e=>e.gitBranch===O)),j&&!A&&(t=t.filter(e=>e.projectPath===ve)),t},[e,b,rt,k,O,j,A,ve]),lt=J.useMemo(()=>{if(!V)return ct;let e=V.toLowerCase();return ct.filter(t=>{let n=Ce(t).toLowerCase(),r=(t.gitBranch||``).toLowerCase(),i=(t.tag||``).toLowerCase(),a=t.prNumber?`pr #${t.prNumber} ${t.prRepository||``}`.toLowerCase():``;return n.includes(e)||r.includes(e)||i.includes(e)||a.includes(e)})},[ct,V]);J.useEffect(()=>{},[U,W,!1]),J.useEffect(()=>{He(null),We(!1)},[W,Ke,!1]);let{filteredLogs:ut,snippets:X}=J.useMemo(()=>{let e=new Map,t=lt;if(K&&W&&K.query===W){for(let t of K.results)if(t.searchableText){let n=et(t.searchableText,W,dt);n&&e.set(t.log,n)}let n=new Set(t.map(e=>e.messages[0]?.uuid)),r=K.results.map(e=>e.log).filter(e=>!n.has(e.messages[0]?.uuid));t=[...t,...r]}return{filteredLogs:t,snippets:e}},[lt,K,W]),Z=J.useMemo(()=>L.status===`results`&&L.results.length>0?L.results:ut,[L,ut]),Q=Math.max(30,v-4),ft=J.useMemo(()=>{if(!b)return[];let e=ot(Z);return Array.from(e.entries()).map(([e,t])=>{let n=t[0],r=Z.indexOf(n),i=X.get(n),a=i?$e(i,D):null;if(t.length===1){let t=nt(n,{showProjectPath:p});return{id:`log:${e}:0`,value:{log:n,indexInFiltered:r},label:tt(n,Q),description:a?`${t}\n ${a}`:t,dimDescription:!0}}let o=t.length-1,s=t.slice(1).map((t,n)=>{let r=Z.indexOf(t),i=X.get(t),a=i?$e(i,D):null,o=nt(t,{isChild:!0,showProjectPath:p});return{id:`log:${e}:${n+1}`,value:{log:t,indexInFiltered:r},label:tt(t,Q,{isChild:!0}),description:a?`${o}\n ${a}`:o,dimDescription:!0}}),c=nt(n,{showProjectPath:p});return{id:`group:${e}`,value:{log:n,indexInFiltered:r},label:tt(n,Q,{isGroupHeader:!0,forkCount:o}),description:a?`${c}\n ${a}`:c,dimDescription:!0,children:s}})},[b,Z,Q,p,X,D]),pt=J.useMemo(()=>b?[]:Z.map((e,t)=>{let n=Qe(Ce(e)+(e.isSidechain?` (sidechain)`:``),Q),r=Oe(e),i=p&&e.projectPath?` · ${e.projectPath}`:``,a=X.get(e),o=a?$e(a,D):null;return{label:n,description:o?`${r}${i}\n ${o}`:r+i,dimDescription:!0,value:t.toString()}}),[b,Z,D,Q,p,X]),$=Ee?.value.log??null,mt=()=>{if(!b||!$)return``;let e=_($);if(!e)return``;let t=Z.filter(t=>_(t)===e);if(!(t.length>1))return``;let n=we.has(e);return t.indexOf($)>0||n?`← to collapse`:`→ to expand`},ht=J.useCallback(async()=>{let e=$?_($):void 0;if(!$||!e){I(`list`),N(``);return}ye.trim()&&(await re(e,ye.trim(),$.fullPath),b&&c&&c()),I(`list`),N(``)},[$,ye,c,b]),gt=J.useCallback(()=>{I(`list`),P(`tengu_session_search_toggled`,{enabled:!1})},[]),_t=J.useCallback(()=>{I(`search`),P(`tengu_session_search_toggled`,{enabled:!0})},[]),vt=J.useCallback(async()=>{if(!V.trim()||!h||!0)return;ze.current?.abort();let t=new AbortController;ze.current=t,R({status:`searching`}),P(`tengu_agentic_search_started`,{query_length:V.length});try{let n=await h(V,e,t.signal);if(t.signal.aborted)return;R({status:`results`,results:n,query:V}),P(`tengu_agentic_search_completed`,{query_length:V.length,results_count:n.length})}catch(e){if(t.signal.aborted)return;R({status:`error`,message:e instanceof Error?e.message:`Search failed`}),P(`tengu_agentic_search_error`,{query_length:V.length})}},[V,h,!1,e]);J.useEffect(()=>{L.status!==`idle`&&L.status!==`searching`&&(L.status===`results`&&L.query!==V||L.status===`error`)&&R({status:`idle`})},[V,L]),J.useEffect(()=>()=>{ze.current?.abort()},[]);let yt=J.useRef(L.status);J.useEffect(()=>{let e=yt.current;if(yt.current=L.status,e===`searching`&&L.status===`results`){if(b&&ft.length>0)De(ft[0]);else if(!b&&Z.length>0){let e=Z[0];De({id:`0`,value:{log:e,indexInFiltered:0},label:``})}}},[L.status,b,ft,Z]);let bt=J.useCallback(e=>{let t=parseInt(e,10),n=Z[t];!n||Pe.current===t.toString()||(Pe.current=t.toString(),De({id:t.toString(),value:{log:n,indexInFiltered:t},label:``}),Ae(t+1))},[Z]),xt=J.useCallback(e=>{De(e);let t=Z.findIndex(t=>_(t)===_(e.value.log));t>=0&&Ae(t+1)},[Z]);se(`confirm:no`,()=>{ze.current?.abort(),R({status:`idle`}),P(`tengu_agentic_search_cancelled`,{})},{context:`Confirmation`,isActive:F!==`preview`&&L.status===`searching`}),se(`confirm:no`,()=>{I(`list`),N(``)},{context:`Settings`,isActive:F===`rename`&&L.status!==`searching`}),se(`confirm:no`,()=>{Be(``),B(!1),r?.()},{context:`Confirmation`,isActive:F!==`preview`&&F!==`rename`&&F!==`search`&&z&&L.status!==`searching`}),ue((e,t)=>{if(F!==`preview`&&L.status!==`searching`&&F!==`rename`)if(F===`search`)e.toLowerCase()===`n`&&t.ctrl?gt():(t.return||t.downArrow)&&V.trim();else{if(z){if(t.return){vt(),B(!1);return}else if(t.downArrow){B(!1);return}else if(t.upArrow){I(`search`),B(!1);return}}if(Je&&t.tab){let e=t.shift?-1:1;Le(t=>{let n=((t<q.length?t:0)+q.length+e)%q.length,r=q[n];return P(`tengu_session_tag_filter_changed`,{is_all:r===`All`,tag_count:qe.length}),n});return}let n=!t.ctrl&&!t.meta,r=e.toLowerCase();if(r===`a`&&t.ctrl&&m)m(),P(`tengu_session_all_projects_toggled`,{enabled:!p});else if(r===`b`&&t.ctrl){let e=!k;me(e),P(`tengu_session_branch_filter_toggled`,{enabled:e})}else if(r===`w`&&t.ctrl&&j){let e=!A;ge(e),P(`tengu_session_worktree_filter_toggled`,{enabled:e})}else r===`/`&&n?(I(`search`),P(`tengu_session_search_toggled`,{enabled:!0})):r===`r`&&t.ctrl&&$?(I(`rename`),N(``),P(`tengu_session_rename_started`,{})):r===`v`&&t.ctrl&&$?(Me($),I(`preview`),P(`tengu_session_preview_opened`,{messageCount:$.messageCount})):$&&n&&e.length>0&&!/^\s+$/.test(e)&&(I(`search`),Be(e),P(`tengu_session_search_toggled`,{enabled:!0}))}},{isActive:!0});let St=[];k&&O&&St.push(O),j&&!A&&St.push(`current worktree`);let Ct=8+ +(St.length>0&&F!==`search`)+it,wt=Math.max(1,Math.floor((t-Ct-2)/3));return J.useEffect(()=>{if(!l)return;let e=wt*2;ke+e>=Z.length&&l(wt*3)},[ke,wt,Z.length,l]),e.length===0?null:F===`preview`&&je&&b?(0,Y.jsx)(Re,{log:je,onExit:()=>{I(`list`),Me(null)},onSelect:a}):(0,Y.jsxs)(w,{flexDirection:`column`,height:t-1,children:[(0,Y.jsx)(w,{flexShrink:0,children:(0,Y.jsx)(ae,{color:`suggestion`})}),(0,Y.jsx)(w,{flexShrink:0,children:(0,Y.jsx)(T,{children:` `})}),Je?(0,Y.jsx)(Ve,{tabs:q,selectedIndex:Xe,availableWidth:v,showAllProjects:p}):(0,Y.jsx)(w,{flexShrink:0,children:(0,Y.jsxs)(T,{bold:!0,color:`suggestion`,children:[`Resume Session`,F===`list`&&Z.length>wt&&(0,Y.jsxs)(T,{dimColor:!0,children:[` `,`(`,ke,` of `,Z.length,`)`]})]})}),(0,Y.jsx)(de,{query:V,isFocused:F===`search`,isTerminalFocused:ie,cursorOffset:H}),St.length>0&&F!==`search`&&(0,Y.jsx)(w,{flexShrink:0,paddingLeft:2,children:(0,Y.jsx)(T,{dimColor:!0,children:(0,Y.jsx)(E,{children:St})})}),(0,Y.jsx)(w,{flexShrink:0,children:(0,Y.jsx)(T,{children:` `})}),L.status===`searching`&&(0,Y.jsxs)(w,{paddingLeft:1,flexShrink:0,children:[(0,Y.jsx)(s,{}),(0,Y.jsx)(T,{children:` Searching…`})]}),L.status===`results`&&L.results.length>0&&(0,Y.jsx)(w,{paddingLeft:1,marginBottom:1,flexShrink:0,children:(0,Y.jsx)(T,{dimColor:!0,italic:!0,children:`Work Mate found these results:`})}),L.status===`results`&&L.results.length===0&&ut.length===0&&(0,Y.jsx)(w,{paddingLeft:1,marginBottom:1,flexShrink:0,children:(0,Y.jsx)(T,{dimColor:!0,italic:!0,children:`No matching sessions found.`})}),L.status===`error`&&ut.length===0&&(0,Y.jsx)(w,{paddingLeft:1,marginBottom:1,flexShrink:0,children:(0,Y.jsx)(T,{dimColor:!0,italic:!0,children:`No matching sessions found.`})}),!!V.trim()&&h&&!1,L.status===`searching`?null:F===`rename`&&$?(0,Y.jsxs)(w,{paddingLeft:2,flexDirection:`column`,children:[(0,Y.jsx)(T,{bold:!0,children:`Rename session:`}),(0,Y.jsx)(w,{paddingTop:1,children:(0,Y.jsx)(te,{value:ye,onChange:N,onSubmit:ht,placeholder:Ce($,`Enter new session name`),columns:v,cursorOffset:be,onChangeCursorOffset:Se,showCursor:!0})})]}):b?(0,Y.jsx)(Ye,{nodes:ft,onSelect:e=>{a(e.value.log)},onFocus:xt,onCancel:r,focusNodeId:Ee?.id,visibleOptionCount:wt,layout:`expanded`,isDisabled:F===`search`||z,hideIndexes:!1,isNodeExpanded:e=>{if(F===`search`||k)return!0;let t=typeof e==`string`&&e.startsWith(`group:`)?e.substring(6):null;return t?we.has(t):!1},onExpand:e=>{let t=typeof e==`string`&&e.startsWith(`group:`)?e.substring(6):null;t&&(Te(e=>new Set(e).add(t)),P(`tengu_session_group_expanded`,{}))},onCollapse:e=>{let t=typeof e==`string`&&e.startsWith(`group:`)?e.substring(6):null;t&&Te(e=>{let n=new Set(e);return n.delete(t),n})},onUpFromFirstItem:_t}):(0,Y.jsx)(d,{options:pt,onChange:e=>{let t=Z[parseInt(e,10)];t&&a(t)},visibleOptionCount:wt,onCancel:r,onFocus:bt,defaultFocusValue:Ee?.id.toString(),layout:`expanded`,isDisabled:F===`search`||z,onUpFromFirstItem:_t}),(0,Y.jsx)(w,{paddingLeft:2,children:ne.pending?(0,Y.jsxs)(T,{dimColor:!0,children:[`Press `,ne.keyName,` again to exit`]}):F===`rename`?(0,Y.jsx)(T,{dimColor:!0,children:(0,Y.jsxs)(E,{children:[(0,Y.jsx)(S,{shortcut:`Enter`,action:`save`}),(0,Y.jsx)(i,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]})}):L.status===`searching`?(0,Y.jsx)(T,{dimColor:!0,children:(0,Y.jsxs)(E,{children:[(0,Y.jsx)(T,{children:`Searching with Work Mate…`}),(0,Y.jsx)(i,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]})}):z?(0,Y.jsx)(T,{dimColor:!0,children:(0,Y.jsxs)(E,{children:[(0,Y.jsx)(S,{shortcut:`Enter`,action:`search`}),(0,Y.jsx)(S,{shortcut:`↓`,action:`skip`}),(0,Y.jsx)(i,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]})}):F===`search`?(0,Y.jsx)(T,{dimColor:!0,children:(0,Y.jsxs)(E,{children:[(0,Y.jsx)(T,{children:`Type to Search`}),(0,Y.jsx)(S,{shortcut:`Enter`,action:`select`}),(0,Y.jsx)(i,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`clear`})]})}):(0,Y.jsx)(T,{dimColor:!0,children:(0,Y.jsxs)(E,{children:[m&&(0,Y.jsx)(S,{shortcut:`Ctrl+A`,action:`show ${p?`current dir`:`all projects`}`}),O&&(0,Y.jsx)(S,{shortcut:`Ctrl+B`,action:`toggle branch`}),j&&(0,Y.jsx)(S,{shortcut:`Ctrl+W`,action:`show ${A?`current worktree`:`all worktrees`}`}),(0,Y.jsx)(S,{shortcut:`Ctrl+V`,action:`preview`}),(0,Y.jsx)(S,{shortcut:`Ctrl+R`,action:`rename`}),(0,Y.jsx)(T,{children:`Type to search`}),(0,Y.jsx)(i,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`}),mt()&&(0,Y.jsx)(T,{children:mt()})]})})})]})}function it(e){if(e.type!==`user`&&e.type!==`assistant`)return``;let t=`message`in e?e.message?.content:void 0;return t?typeof t==`string`?t:Array.isArray(t)?t.map(e=>typeof e==`string`?e:`text`in e&&typeof e.text==`string`?e.text:``).filter(Boolean).join(` `):``:``}function at(e){let t=(e.messages.length<=ut?e.messages:[...e.messages.slice(0,X),...e.messages.slice(-1e3)]).map(it).filter(Boolean).join(` `),n=`${[e.customTitle,e.summary,e.firstPrompt,e.gitBranch,e.tag,e.prNumber?`PR #${e.prNumber}`:void 0,e.prRepository].filter(Boolean).join(` `)} ${t}`.trim();return n.length>Z?n.slice(0,Z):n}function ot(e){let t=new Map;for(let n of e){let e=_(n);if(e){let r=t.get(e);r?r.push(n):t.set(e,[n])}}return t.forEach(e=>e.sort((e,t)=>new Date(t.modified).getTime()-new Date(e.modified).getTime())),t}function st(e){let t=new Set;for(let n of e)n.tag&&t.add(n.tag);return Array.from(t).sort((e,t)=>e.localeCompare(t))}var J,Y,ct,lt,ut,X,Z,dt,Q=e((()=>{le(),J=t(D(),1),ge(),Pe(),Le(),v(),me(),b(),Ee(),Ae(),r(),Se(),we(),g(),p(),l(),n(),Fe(),ze(),u(),Je(),ne(),Ze(),Y=A(),ct=2,lt=4,ut=2e3,X=1e3,Z=5e4,dt=50}));function ft(e){if(e.type!==`user`&&e.type!==`assistant`)return``;let t=`message`in e?e.message?.content:void 0;return t?typeof t==`string`?t:Array.isArray(t)?t.map(e=>typeof e==`string`?e:`text`in e&&typeof e.text==`string`?e.text:``).filter(Boolean).join(` `):``:``}function pt(e){if(e.length===0)return``;let t=(e.length<=gt?e:[...e.slice(0,gt/2),...e.slice(-100/2)]).map(ft).filter(Boolean).join(` `).replace(/\s+/g,` `).trim();return t.length>ht?`${t.slice(0,ht)}…`:t}function $(e,t){return!!(Ce(e).toLowerCase().includes(t)||e.customTitle?.toLowerCase().includes(t)||e.tag?.toLowerCase().includes(t)||e.gitBranch?.toLowerCase().includes(t)||e.summary?.toLowerCase().includes(t)||e.firstPrompt?.toLowerCase().includes(t)||e.messages&&e.messages.length>0&&pt(e.messages).toLowerCase().includes(t))}async function mt(e,t,n){if(!e.trim()||t.length===0)return[];let r=e.toLowerCase(),i=t.filter(e=>$(e,r)),a;if(i.length>=_t)a=i.slice(0,_t);else{let e=t.filter(e=>!$(e,r)),n=_t-i.length;a=[...i,...e.slice(0,n)]}M(`Agentic search: ${a.length}/${t.length} logs, query="${e}", matching: ${i.length}, with messages: ${N(a,e=>e.messages?.length>0)}`);let o=a.map(async e=>{if(x(e))try{return await c(e)}catch(t){return Te(t),e}return e}),s=await Promise.all(o);M(`Agentic search: loaded ${N(s,e=>e.messages?.length>0)}/${a.length} logs with transcripts`);let l=`Sessions:
1
+ import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{$u as n,Ci as r,Dp as i,Gc as a,Hu as o,Mu as s,Nr as c,Op as l,Pu as u,Qu as d,Si as f,Sr as ee,Uu as p,Uw as m,Ww as h,br as g,cd as te,fr as _,gC as v,ir as y,ld as ne,oi as re,qc as ie,uC as b,wr as x}from"./loadAgentsDir-DaNpxaO-.js";import{C as ae,D as S,Gr as C,H as oe,I as w,P as T,T as E,Wt as se,Xn as ce,ai as D,di as O,fi as le,hn as ue,k as de,oi as fe,ot as pe,p as k,t as me}from"./src-DL3w8VPk2.js";import{t as A}from"./jsx-runtime-Bb4Xn-E0.js";import{$ as he,Ut as ge,ft as _e}from"./state-D5D6QpTX.js";import{S as j,c as M,i as ve,x as ye}from"./debug-D58GQBDG.js";import{In as N,Ln as be}from"./settings-3xZ0fsvE.js";import{i as xe,m as Se}from"./git-By_J4XJL.js";import{a as Ce,o as we,s as Te}from"./log-CZ7ploQm.js";import{n as Ee,r as P}from"./analytics-DJobLaWP.js";import{C as De,d as Oe,m as ke,v as Ae}from"./startupProfiler-CbzxVmbv.js";import{_ as F,h as I}from"./model-Do0f476p.js";import{i as je,r as Me}from"./shellQuote-Ddgr1vif.js";import{n as Ne,t as Pe}from"./useExitOnCtrlCDWithKeybindings-Bw0mlTT9.js";import{t as Fe}from"./SearchBox-CwwV0W-w.js";import{n as Ie,t as Le}from"./useSearchInput-QL_VtdJD.js";import{n as L,t as R}from"./Messages-BZDFMYBT.js";function Re({log:e,onExit:t,onSelect:n}){let[r,o]=z.useState(null);z.useEffect(()=>{o(null),x(e)&&c(e).then(o)},[e]);let s=x(e)&&r===null,l=r??e,u=_(l)||``,d=a();return se(`confirm:no`,t,{context:`Confirmation`}),se(`confirm:yes`,(0,z.useCallback)(()=>{n(r??e)},[n,r,e]),{context:`Confirmation`}),s?(0,B.jsxs)(w,{flexDirection:`column`,padding:1,children:[(0,B.jsx)(k,{message:`Loading session…`}),(0,B.jsx)(T,{dimColor:!0,children:(0,B.jsx)(E,{children:(0,B.jsx)(i,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})})})]}):(0,B.jsxs)(w,{flexDirection:`column`,children:[(0,B.jsx)(R,{messages:l.messages,tools:d,commands:[],verbose:!0,toolJSX:null,toolUseConfirmQueue:[],inProgressToolUseIDs:new Set,isMessageSelectorVisible:!1,conversationId:u,screen:`transcript`,streamingToolUses:[],showAllInTranscript:!0,isLoading:!1}),(0,B.jsxs)(w,{flexShrink:0,flexDirection:`column`,borderTopDimColor:!0,borderBottom:!1,borderLeft:!1,borderRight:!1,borderStyle:`single`,paddingLeft:2,children:[(0,B.jsxs)(T,{children:[ke(l.modified),` · `,l.messageCount,` messages`,l.gitBranch?` · ${l.gitBranch}`:``]}),(0,B.jsx)(T,{dimColor:!0,children:(0,B.jsxs)(E,{children:[(0,B.jsx)(S,{shortcut:`Enter`,action:`resume`}),(0,B.jsx)(i,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]})})]})]})}var z,B,ze=e((()=>{z=t(D(),1),me(),b(),ie(),Ae(),g(),l(),L(),B=A()}));function V(e,t){if(e===U)return 5;let n=C(e),r=t?Math.min(n,t-W-G):n;return Math.max(0,r)+W+G}function Be(e,t){let n=t-W-G;return C(e)<=n?e:n<=1?e.charAt(0):De(e,n)}function Ve({tabs:e,selectedIndex:t,availableWidth:n,showAllProjects:r=!1}){let i=r?`Resume (All Projects)`:`Resume`,a=i.length+1,o=Math.max(Ke,qe),s=n-a-o-2,c=Math.max(0,Math.min(t,e.length-1)),l=Math.max(20,Math.floor(s/2)),u=e.map(e=>V(e,l)),d=0,f=e.length;if(u.reduce((e,t,n)=>e+t+ +(n<u.length-1),0)>s){let t=s-Ge,n=u[c]??0;for(d=c,f=c+1;d>0||f<e.length;){let r=d>0,i=f<e.length;if(r){let e=(u[d-1]??0)+1;if(n+e<=t){d--,n+=e;continue}}if(i){let e=(u[f]??0)+1;if(n+e<=t){f++,n+=e;continue}}break}}let ee=d,p=e.length-f,m=e.slice(d,f),h=m.map((e,t)=>d+t);return(0,H.jsxs)(w,{flexDirection:`row`,gap:1,children:[(0,H.jsx)(T,{color:`suggestion`,children:i}),ee>0&&(0,H.jsxs)(T,{dimColor:!0,children:[K,ee]}),m.map((e,t)=>{let n=h[t]===c,r=e===U?e:`#${Be(e,l-W)}`;return(0,H.jsxs)(T,{backgroundColor:n?`suggestion`:void 0,color:n?`inverseText`:void 0,bold:n,children:[` `,r,` `]},e)}),p>0?(0,H.jsxs)(T,{dimColor:!0,children:[He,p,Ue]}):(0,H.jsx)(T,{dimColor:!0,children:We})]})}var H,U,W,G,K,He,Ue,We,Ge,Ke,qe,Je=e((()=>{me(),Ae(),H=A(),U=`All`,W=2,G=1,K=`← `,He=`→`,Ue=` (tab to cycle)`,We=`(tab to cycle)`,Ge=5,Ke=18,qe=14}));function Ye({nodes:e,onSelect:t,onCancel:n,onFocus:r,focusNodeId:i,visibleOptionCount:a,layout:o=`expanded`,isDisabled:s=!1,hideIndexes:c=!1,isNodeExpanded:l,onExpand:u,onCollapse:f,getParentPrefix:ee,getChildPrefix:p,onUpFromFirstItem:m}){let[h,g]=q.useState(new Set),te=q.useRef(!1),_=q.useRef(null),v=q.useCallback(e=>l?l(e):h.has(e),[l,h]),y=q.useMemo(()=>{let t=[];function n(e,r,i){let a=!!e.children&&e.children.length>0,o=v(e.id);if(t.push({node:e,depth:r,isExpanded:o,hasChildren:a,parentId:i}),a&&o&&e.children)for(let t of e.children)n(t,r+1,e.id)}for(let t of e)n(t,0);return t},[e,v]),ne=q.useCallback(e=>e?`▼ `:`▶ `,[]),re=q.useCallback(e=>` ▸ `,[]),ie=ee??ne,b=p??re,x=q.useCallback(e=>{let t=``;return e.hasChildren?t=ie(e.isExpanded):e.depth>0&&(t=b(e.depth)),t+e.node.label},[ie,b]),ae=q.useMemo(()=>y.map(e=>({label:x(e),description:e.node.description,dimDescription:e.node.dimDescription??!0,value:e.node.id})),[y,x]),S=q.useMemo(()=>{let e=new Map;return y.forEach(t=>e.set(t.node.id,t.node)),e},[y]),C=q.useCallback(e=>y.find(t=>t.node.id===e),[y]),oe=q.useCallback((e,t)=>{C(e)?.hasChildren&&(t?u?u(e):g(t=>new Set(t).add(e)):f?f(e):g(t=>{let n=new Set(t);return n.delete(e),n}))},[C,u,f]);return(0,Xe.jsx)(w,{tabIndex:0,autoFocus:!0,onKeyDown:e=>{if(!i||s)return;let t=C(i);if(t){if(e.key===`right`&&t.hasChildren)e.preventDefault(),oe(i,!0);else if(e.key===`left`){if(t.hasChildren&&t.isExpanded)e.preventDefault(),oe(i,!1);else if(t.parentId!==void 0&&(e.preventDefault(),te.current=!0,oe(t.parentId,!1),r)){let e=S.get(t.parentId);e&&r(e)}}}},children:(0,Xe.jsx)(d,{options:ae,onChange:q.useCallback(e=>{let n=S.get(e);n&&t(n)},[S,t]),onFocus:q.useCallback(e=>{if(te.current){te.current=!1;return}if(_.current!==e&&(_.current=e,r)){let t=S.get(e);t&&r(t)}},[r,S]),onCancel:n,defaultFocusValue:i,visibleOptionCount:a,layout:o,isDisabled:s,hideIndexes:c,onUpFromFirstItem:m})})}var q,Xe,Ze=e((()=>{q=t(D(),1),me(),n(),Xe=A()}));function Qe(e,t){return De(e.replace(/\s+/g,` `).trim(),t)}function $e({before:e,match:t,after:n},r){return O.dim(e)+r(t)+O.dim(n)}function et(e,t,n){let r=e.toLowerCase().indexOf(t.toLowerCase());if(r===-1)return null;let i=r+t.length,a=Math.max(0,r-n),o=Math.min(e.length,i+n),s=e.slice(a,r),c=e.slice(r,i),l=e.slice(i,o);return{before:(a>0?`…`:``)+s.replace(/\s+/g,` `).trimStart(),match:c.trim(),after:l.replace(/\s+/g,` `).trimEnd()+(o<e.length?`…`:``)}}function tt(e,t,n){let{isGroupHeader:r=!1,isChild:i=!1,forkCount:a=0}=n||{},o=r&&a>0?ct:i?lt:0,s=r&&a>0?` (+${a} other ${a===1?`session`:`sessions`})`:``,c=e.isSidechain?` (sidechain)`:``,l=t-o-c.length-s.length;return`${Qe(Ce(e),l)}${c}${s}`}function nt(e,t){let{isChild:n=!1,showProjectPath:r=!1}=t||{},i=n?` `:``,a=Oe(e),o=r&&e.projectPath?` · ${e.projectPath}`:``;return i+a+o}function rt({logs:e,maxHeight:t=1/0,forceWidth:n,onCancel:r,onSelect:a,onLogsChanged:c,onLoadMore:l,initialSearchQuery:u,showAllProjects:p=!1,onToggleAllProjects:m,onAgenticSearch:h}){let g=pe(),v=n===void 0?g.columns:n,ne=Ne(r),ie=ce(),b=ee(),[x]=oe(),C=o(x),D=J.useMemo(()=>e=>fe(e,C.warning),[C.warning]),[O,le]=J.useState(null),[k,me]=J.useState(!1),[A,ge]=J.useState(!1),[j,M]=J.useState(!1),ve=J.useMemo(()=>he(),[]),[ye,N]=J.useState(``),[be,Se]=J.useState(0),[we,Te]=J.useState(new Set),[Ee,De]=J.useState(null),[ke,Ae]=J.useState(1),[F,I]=J.useState(`list`),[je,Me]=J.useState(null),Pe=J.useRef(null),[Fe,Le]=J.useState(0),[L,R]=J.useState({status:`idle`}),[z,B]=J.useState(!1),ze=J.useRef(null),{query:V,setQuery:Be,cursorOffset:H}=Ie({isActive:F===`search`&&L.status!==`searching`,onExit:()=>{I(`list`),P(`tengu_session_search_toggled`,{enabled:!1})},onExitUp:()=>{I(`list`),P(`tengu_session_search_toggled`,{enabled:!1})},passthroughCtrlKeys:[`n`],initialQuery:u||``}),U=J.useDeferredValue(V),[W,G]=J.useState(``);J.useEffect(()=>{if(!U){G(``);return}let e=setTimeout(G,300,U);return()=>clearTimeout(e)},[U]);let[K,He]=J.useState(null),[Ue,We]=J.useState(!1);J.useEffect(()=>{xe().then(e=>le(e)),f(ve).then(e=>{M(e.length>1)})},[ve]);let Ge=J.useMemo(()=>new Map(e.map(e=>[e,at(e)])),[e]),Ke=J.useMemo(()=>null,[e,Ge,!1]),qe=J.useMemo(()=>st(e),[e]),Je=qe.length>0,q=J.useMemo(()=>Je?[`All`,...qe]:[],[Je,qe]),Xe=q.length>0&&Fe<q.length?Fe:0,Ze=q[Xe],rt=Ze===`All`?void 0:Ze,it=+!!Je,ct=J.useMemo(()=>{let t=e;return b&&(t=e.filter(e=>{let t=_e(),n=_(e);return!!(t&&n===t||e.customTitle||y(e.messages)||e.firstPrompt||e.customTitle)})),rt!==void 0&&(t=t.filter(e=>e.tag===rt)),k&&O&&(t=t.filter(e=>e.gitBranch===O)),j&&!A&&(t=t.filter(e=>e.projectPath===ve)),t},[e,b,rt,k,O,j,A,ve]),lt=J.useMemo(()=>{if(!V)return ct;let e=V.toLowerCase();return ct.filter(t=>{let n=Ce(t).toLowerCase(),r=(t.gitBranch||``).toLowerCase(),i=(t.tag||``).toLowerCase(),a=t.prNumber?`pr #${t.prNumber} ${t.prRepository||``}`.toLowerCase():``;return n.includes(e)||r.includes(e)||i.includes(e)||a.includes(e)})},[ct,V]);J.useEffect(()=>{},[U,W,!1]),J.useEffect(()=>{He(null),We(!1)},[W,Ke,!1]);let{filteredLogs:ut,snippets:X}=J.useMemo(()=>{let e=new Map,t=lt;if(K&&W&&K.query===W){for(let t of K.results)if(t.searchableText){let n=et(t.searchableText,W,dt);n&&e.set(t.log,n)}let n=new Set(t.map(e=>e.messages[0]?.uuid)),r=K.results.map(e=>e.log).filter(e=>!n.has(e.messages[0]?.uuid));t=[...t,...r]}return{filteredLogs:t,snippets:e}},[lt,K,W]),Z=J.useMemo(()=>L.status===`results`&&L.results.length>0?L.results:ut,[L,ut]),Q=Math.max(30,v-4),ft=J.useMemo(()=>{if(!b)return[];let e=ot(Z);return Array.from(e.entries()).map(([e,t])=>{let n=t[0],r=Z.indexOf(n),i=X.get(n),a=i?$e(i,D):null;if(t.length===1){let t=nt(n,{showProjectPath:p});return{id:`log:${e}:0`,value:{log:n,indexInFiltered:r},label:tt(n,Q),description:a?`${t}\n ${a}`:t,dimDescription:!0}}let o=t.length-1,s=t.slice(1).map((t,n)=>{let r=Z.indexOf(t),i=X.get(t),a=i?$e(i,D):null,o=nt(t,{isChild:!0,showProjectPath:p});return{id:`log:${e}:${n+1}`,value:{log:t,indexInFiltered:r},label:tt(t,Q,{isChild:!0}),description:a?`${o}\n ${a}`:o,dimDescription:!0}}),c=nt(n,{showProjectPath:p});return{id:`group:${e}`,value:{log:n,indexInFiltered:r},label:tt(n,Q,{isGroupHeader:!0,forkCount:o}),description:a?`${c}\n ${a}`:c,dimDescription:!0,children:s}})},[b,Z,Q,p,X,D]),pt=J.useMemo(()=>b?[]:Z.map((e,t)=>{let n=Qe(Ce(e)+(e.isSidechain?` (sidechain)`:``),Q),r=Oe(e),i=p&&e.projectPath?` · ${e.projectPath}`:``,a=X.get(e),o=a?$e(a,D):null;return{label:n,description:o?`${r}${i}\n ${o}`:r+i,dimDescription:!0,value:t.toString()}}),[b,Z,D,Q,p,X]),$=Ee?.value.log??null,mt=()=>{if(!b||!$)return``;let e=_($);if(!e)return``;let t=Z.filter(t=>_(t)===e);if(!(t.length>1))return``;let n=we.has(e);return t.indexOf($)>0||n?`← to collapse`:`→ to expand`},ht=J.useCallback(async()=>{let e=$?_($):void 0;if(!$||!e){I(`list`),N(``);return}ye.trim()&&(await re(e,ye.trim(),$.fullPath),b&&c&&c()),I(`list`),N(``)},[$,ye,c,b]),gt=J.useCallback(()=>{I(`list`),P(`tengu_session_search_toggled`,{enabled:!1})},[]),_t=J.useCallback(()=>{I(`search`),P(`tengu_session_search_toggled`,{enabled:!0})},[]),vt=J.useCallback(async()=>{if(!V.trim()||!h||!0)return;ze.current?.abort();let t=new AbortController;ze.current=t,R({status:`searching`}),P(`tengu_agentic_search_started`,{query_length:V.length});try{let n=await h(V,e,t.signal);if(t.signal.aborted)return;R({status:`results`,results:n,query:V}),P(`tengu_agentic_search_completed`,{query_length:V.length,results_count:n.length})}catch(e){if(t.signal.aborted)return;R({status:`error`,message:e instanceof Error?e.message:`Search failed`}),P(`tengu_agentic_search_error`,{query_length:V.length})}},[V,h,!1,e]);J.useEffect(()=>{L.status!==`idle`&&L.status!==`searching`&&(L.status===`results`&&L.query!==V||L.status===`error`)&&R({status:`idle`})},[V,L]),J.useEffect(()=>()=>{ze.current?.abort()},[]);let yt=J.useRef(L.status);J.useEffect(()=>{let e=yt.current;if(yt.current=L.status,e===`searching`&&L.status===`results`){if(b&&ft.length>0)De(ft[0]);else if(!b&&Z.length>0){let e=Z[0];De({id:`0`,value:{log:e,indexInFiltered:0},label:``})}}},[L.status,b,ft,Z]);let bt=J.useCallback(e=>{let t=parseInt(e,10),n=Z[t];!n||Pe.current===t.toString()||(Pe.current=t.toString(),De({id:t.toString(),value:{log:n,indexInFiltered:t},label:``}),Ae(t+1))},[Z]),xt=J.useCallback(e=>{De(e);let t=Z.findIndex(t=>_(t)===_(e.value.log));t>=0&&Ae(t+1)},[Z]);se(`confirm:no`,()=>{ze.current?.abort(),R({status:`idle`}),P(`tengu_agentic_search_cancelled`,{})},{context:`Confirmation`,isActive:F!==`preview`&&L.status===`searching`}),se(`confirm:no`,()=>{I(`list`),N(``)},{context:`Settings`,isActive:F===`rename`&&L.status!==`searching`}),se(`confirm:no`,()=>{Be(``),B(!1),r?.()},{context:`Confirmation`,isActive:F!==`preview`&&F!==`rename`&&F!==`search`&&z&&L.status!==`searching`}),ue((e,t)=>{if(F!==`preview`&&L.status!==`searching`&&F!==`rename`)if(F===`search`)e.toLowerCase()===`n`&&t.ctrl?gt():(t.return||t.downArrow)&&V.trim();else{if(z){if(t.return){vt(),B(!1);return}else if(t.downArrow){B(!1);return}else if(t.upArrow){I(`search`),B(!1);return}}if(Je&&t.tab){let e=t.shift?-1:1;Le(t=>{let n=((t<q.length?t:0)+q.length+e)%q.length,r=q[n];return P(`tengu_session_tag_filter_changed`,{is_all:r===`All`,tag_count:qe.length}),n});return}let n=!t.ctrl&&!t.meta,r=e.toLowerCase();if(r===`a`&&t.ctrl&&m)m(),P(`tengu_session_all_projects_toggled`,{enabled:!p});else if(r===`b`&&t.ctrl){let e=!k;me(e),P(`tengu_session_branch_filter_toggled`,{enabled:e})}else if(r===`w`&&t.ctrl&&j){let e=!A;ge(e),P(`tengu_session_worktree_filter_toggled`,{enabled:e})}else r===`/`&&n?(I(`search`),P(`tengu_session_search_toggled`,{enabled:!0})):r===`r`&&t.ctrl&&$?(I(`rename`),N(``),P(`tengu_session_rename_started`,{})):r===`v`&&t.ctrl&&$?(Me($),I(`preview`),P(`tengu_session_preview_opened`,{messageCount:$.messageCount})):$&&n&&e.length>0&&!/^\s+$/.test(e)&&(I(`search`),Be(e),P(`tengu_session_search_toggled`,{enabled:!0}))}},{isActive:!0});let St=[];k&&O&&St.push(O),j&&!A&&St.push(`current worktree`);let Ct=8+ +(St.length>0&&F!==`search`)+it,wt=Math.max(1,Math.floor((t-Ct-2)/3));return J.useEffect(()=>{if(!l)return;let e=wt*2;ke+e>=Z.length&&l(wt*3)},[ke,wt,Z.length,l]),e.length===0?null:F===`preview`&&je&&b?(0,Y.jsx)(Re,{log:je,onExit:()=>{I(`list`),Me(null)},onSelect:a}):(0,Y.jsxs)(w,{flexDirection:`column`,height:t-1,children:[(0,Y.jsx)(w,{flexShrink:0,children:(0,Y.jsx)(ae,{color:`suggestion`})}),(0,Y.jsx)(w,{flexShrink:0,children:(0,Y.jsx)(T,{children:` `})}),Je?(0,Y.jsx)(Ve,{tabs:q,selectedIndex:Xe,availableWidth:v,showAllProjects:p}):(0,Y.jsx)(w,{flexShrink:0,children:(0,Y.jsxs)(T,{bold:!0,color:`suggestion`,children:[`Resume Session`,F===`list`&&Z.length>wt&&(0,Y.jsxs)(T,{dimColor:!0,children:[` `,`(`,ke,` of `,Z.length,`)`]})]})}),(0,Y.jsx)(de,{query:V,isFocused:F===`search`,isTerminalFocused:ie,cursorOffset:H}),St.length>0&&F!==`search`&&(0,Y.jsx)(w,{flexShrink:0,paddingLeft:2,children:(0,Y.jsx)(T,{dimColor:!0,children:(0,Y.jsx)(E,{children:St})})}),(0,Y.jsx)(w,{flexShrink:0,children:(0,Y.jsx)(T,{children:` `})}),L.status===`searching`&&(0,Y.jsxs)(w,{paddingLeft:1,flexShrink:0,children:[(0,Y.jsx)(s,{}),(0,Y.jsx)(T,{children:` Searching…`})]}),L.status===`results`&&L.results.length>0&&(0,Y.jsx)(w,{paddingLeft:1,marginBottom:1,flexShrink:0,children:(0,Y.jsx)(T,{dimColor:!0,italic:!0,children:`Work Mate found these results:`})}),L.status===`results`&&L.results.length===0&&ut.length===0&&(0,Y.jsx)(w,{paddingLeft:1,marginBottom:1,flexShrink:0,children:(0,Y.jsx)(T,{dimColor:!0,italic:!0,children:`No matching sessions found.`})}),L.status===`error`&&ut.length===0&&(0,Y.jsx)(w,{paddingLeft:1,marginBottom:1,flexShrink:0,children:(0,Y.jsx)(T,{dimColor:!0,italic:!0,children:`No matching sessions found.`})}),!!V.trim()&&h&&!1,L.status===`searching`?null:F===`rename`&&$?(0,Y.jsxs)(w,{paddingLeft:2,flexDirection:`column`,children:[(0,Y.jsx)(T,{bold:!0,children:`Rename session:`}),(0,Y.jsx)(w,{paddingTop:1,children:(0,Y.jsx)(te,{value:ye,onChange:N,onSubmit:ht,placeholder:Ce($,`Enter new session name`),columns:v,cursorOffset:be,onChangeCursorOffset:Se,showCursor:!0})})]}):b?(0,Y.jsx)(Ye,{nodes:ft,onSelect:e=>{a(e.value.log)},onFocus:xt,onCancel:r,focusNodeId:Ee?.id,visibleOptionCount:wt,layout:`expanded`,isDisabled:F===`search`||z,hideIndexes:!1,isNodeExpanded:e=>{if(F===`search`||k)return!0;let t=typeof e==`string`&&e.startsWith(`group:`)?e.substring(6):null;return t?we.has(t):!1},onExpand:e=>{let t=typeof e==`string`&&e.startsWith(`group:`)?e.substring(6):null;t&&(Te(e=>new Set(e).add(t)),P(`tengu_session_group_expanded`,{}))},onCollapse:e=>{let t=typeof e==`string`&&e.startsWith(`group:`)?e.substring(6):null;t&&Te(e=>{let n=new Set(e);return n.delete(t),n})},onUpFromFirstItem:_t}):(0,Y.jsx)(d,{options:pt,onChange:e=>{let t=Z[parseInt(e,10)];t&&a(t)},visibleOptionCount:wt,onCancel:r,onFocus:bt,defaultFocusValue:Ee?.id.toString(),layout:`expanded`,isDisabled:F===`search`||z,onUpFromFirstItem:_t}),(0,Y.jsx)(w,{paddingLeft:2,children:ne.pending?(0,Y.jsxs)(T,{dimColor:!0,children:[`Press `,ne.keyName,` again to exit`]}):F===`rename`?(0,Y.jsx)(T,{dimColor:!0,children:(0,Y.jsxs)(E,{children:[(0,Y.jsx)(S,{shortcut:`Enter`,action:`save`}),(0,Y.jsx)(i,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]})}):L.status===`searching`?(0,Y.jsx)(T,{dimColor:!0,children:(0,Y.jsxs)(E,{children:[(0,Y.jsx)(T,{children:`Searching with Work Mate…`}),(0,Y.jsx)(i,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]})}):z?(0,Y.jsx)(T,{dimColor:!0,children:(0,Y.jsxs)(E,{children:[(0,Y.jsx)(S,{shortcut:`Enter`,action:`search`}),(0,Y.jsx)(S,{shortcut:`↓`,action:`skip`}),(0,Y.jsx)(i,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]})}):F===`search`?(0,Y.jsx)(T,{dimColor:!0,children:(0,Y.jsxs)(E,{children:[(0,Y.jsx)(T,{children:`Type to Search`}),(0,Y.jsx)(S,{shortcut:`Enter`,action:`select`}),(0,Y.jsx)(i,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`clear`})]})}):(0,Y.jsx)(T,{dimColor:!0,children:(0,Y.jsxs)(E,{children:[m&&(0,Y.jsx)(S,{shortcut:`Ctrl+A`,action:`show ${p?`current dir`:`all projects`}`}),O&&(0,Y.jsx)(S,{shortcut:`Ctrl+B`,action:`toggle branch`}),j&&(0,Y.jsx)(S,{shortcut:`Ctrl+W`,action:`show ${A?`current worktree`:`all worktrees`}`}),(0,Y.jsx)(S,{shortcut:`Ctrl+V`,action:`preview`}),(0,Y.jsx)(S,{shortcut:`Ctrl+R`,action:`rename`}),(0,Y.jsx)(T,{children:`Type to search`}),(0,Y.jsx)(i,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`}),mt()&&(0,Y.jsx)(T,{children:mt()})]})})})]})}function it(e){if(e.type!==`user`&&e.type!==`assistant`)return``;let t=`message`in e?e.message?.content:void 0;return t?typeof t==`string`?t:Array.isArray(t)?t.map(e=>typeof e==`string`?e:`text`in e&&typeof e.text==`string`?e.text:``).filter(Boolean).join(` `):``:``}function at(e){let t=(e.messages.length<=ut?e.messages:[...e.messages.slice(0,X),...e.messages.slice(-1e3)]).map(it).filter(Boolean).join(` `),n=`${[e.customTitle,e.summary,e.firstPrompt,e.gitBranch,e.tag,e.prNumber?`PR #${e.prNumber}`:void 0,e.prRepository].filter(Boolean).join(` `)} ${t}`.trim();return n.length>Z?n.slice(0,Z):n}function ot(e){let t=new Map;for(let n of e){let e=_(n);if(e){let r=t.get(e);r?r.push(n):t.set(e,[n])}}return t.forEach(e=>e.sort((e,t)=>new Date(t.modified).getTime()-new Date(e.modified).getTime())),t}function st(e){let t=new Set;for(let n of e)n.tag&&t.add(n.tag);return Array.from(t).sort((e,t)=>e.localeCompare(t))}var J,Y,ct,lt,ut,X,Z,dt,Q=e((()=>{le(),J=t(D(),1),ge(),Pe(),Le(),v(),me(),b(),Ee(),Ae(),r(),Se(),we(),g(),p(),l(),n(),Fe(),ze(),u(),Je(),ne(),Ze(),Y=A(),ct=2,lt=4,ut=2e3,X=1e3,Z=5e4,dt=50}));function ft(e){if(e.type!==`user`&&e.type!==`assistant`)return``;let t=`message`in e?e.message?.content:void 0;return t?typeof t==`string`?t:Array.isArray(t)?t.map(e=>typeof e==`string`?e:`text`in e&&typeof e.text==`string`?e.text:``).filter(Boolean).join(` `):``:``}function pt(e){if(e.length===0)return``;let t=(e.length<=gt?e:[...e.slice(0,gt/2),...e.slice(-100/2)]).map(ft).filter(Boolean).join(` `).replace(/\s+/g,` `).trim();return t.length>ht?`${t.slice(0,ht)}…`:t}function $(e,t){return!!(Ce(e).toLowerCase().includes(t)||e.customTitle?.toLowerCase().includes(t)||e.tag?.toLowerCase().includes(t)||e.gitBranch?.toLowerCase().includes(t)||e.summary?.toLowerCase().includes(t)||e.firstPrompt?.toLowerCase().includes(t)||e.messages&&e.messages.length>0&&pt(e.messages).toLowerCase().includes(t))}async function mt(e,t,n){if(!e.trim()||t.length===0)return[];let r=e.toLowerCase(),i=t.filter(e=>$(e,r)),a;if(i.length>=_t)a=i.slice(0,_t);else{let e=t.filter(e=>!$(e,r)),n=_t-i.length;a=[...i,...e.slice(0,n)]}M(`Agentic search: ${a.length}/${t.length} logs, query="${e}", matching: ${i.length}, with messages: ${N(a,e=>e.messages?.length>0)}`);let o=a.map(async e=>{if(x(e))try{return await c(e)}catch(t){return Te(t),e}return e}),s=await Promise.all(o);M(`Agentic search: loaded ${N(s,e=>e.messages?.length>0)}/${a.length} logs with transcripts`);let l=`Sessions:
2
2
  ${s.map((e,t)=>{let n=[`${t}:`],r=Ce(e);if(n.push(r),e.customTitle&&e.customTitle!==r&&n.push(`[custom title: ${e.customTitle}]`),e.tag&&n.push(`[tag: ${e.tag}]`),e.gitBranch&&n.push(`[branch: ${e.gitBranch}]`),e.summary&&n.push(`- Summary: ${e.summary}`),e.firstPrompt&&e.firstPrompt!==`No prompt`&&n.push(`- First message: ${e.firstPrompt.slice(0,300)}`),e.messages&&e.messages.length>0){let t=pt(e.messages);t&&n.push(`- Transcript: ${t}`)}return n.join(` `)}).join(`
3
3
  `)}
4
4
 
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./memoize-BK3gG5ob.js";import{n as r,t as i}from"./axios-DaWTGg7G.js";import{d as a,h as o}from"./config-DRy1I12M.js";import{o as s,s as c}from"./log-CZ7ploQm.js";import{$r as l,N as u,R as d,_ as f,r as p,ti as m}from"./model-Cxx3suBa.js";import{Z as h,et as g}from"./esm-DBMVQDVv.js";import{f as _,p as v}from"./firstPartyEventLogger-CxUuXQhL.js";import{createHash as y}from"crypto";function b(e){return e.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`)}async function x(){if(N.length===0)return;let e=N;N=[];try{await r.post(E,e,{headers:{"Content-Type":`application/json`,"DD-API-KEY":D},timeout:A})}catch(e){c(e)}}function S(){P||(P=setTimeout(()=>{P=null,x()},T()).unref())}async function C(){P&&(clearTimeout(P),P=null),await x()}async function w(e,t){if(l()!==`firstParty`)return;let n=F;if(n===null&&(n=await I()),!(!n||!j.has(e)))try{let{envContext:n,...r}=await h({model:t.model,betas:t.betas}),i={...r,...n,...t,userBucket:R()};if(typeof i.toolName==`string`&&i.toolName.startsWith(`mcp__`)&&(i.toolName=`mcp`),typeof i.model==`string`){let e=p(i.model.replace(/\[1m]$/i,``));i.model=e in u?e:`other`}if(typeof i.version==`string`&&(i.version=i.version.replace(/^(\d+\.\d+\.\d+-dev\.\d{8})\.t\d+\.sha[a-f0-9]+$/,`$1`)),i.status!==void 0&&i.status!==null){let e=String(i.status);i.http_status=e;let t=e.charAt(0);t>=`1`&&t<=`5`&&(i.http_status_range=`${t}xx`),delete i.status}let a=i,o={ddsource:`nodejs`,ddtags:[`event:${e}`,...M.filter(e=>a[e]!==void 0&&a[e]!==null).map(e=>`${b(e)}:${a[e]}`)].join(`,`),message:e,service:`workmate`,hostname:`workmate`,env:process.env.USER_TYPE};for(let[e,t]of Object.entries(i))t!=null&&(o[b(e)]=t);N.push(o),N.length>=k?(P&&(clearTimeout(P),P=null),x()):S()}catch(e){c(e)}}function T(){return parseInt(process.env.CLAUDE_CODE_DATADOG_FLUSH_INTERVAL_MS||``,10)||O}var E,D,O,k,A,j,M,N,P,F,I,L,R,z=e((()=>{i(),n(),o(),s(),f(),m(),d(),_(),g(),E=process.env.DATADOG_LOGS_ENDPOINT??``,D=process.env.DATADOG_API_KEY??``,O=15e3,k=100,A=5e3,j=new Set(`tengu_api_error.tengu_api_success.tengu_cancel.tengu_compact_failed.tengu_exit.tengu_flicker.tengu_init.tengu_model_fallback_triggered.tengu_oauth_error.tengu_oauth_success.tengu_oauth_token_refresh_failure.tengu_oauth_token_refresh_success.tengu_oauth_token_refresh_lock_acquiring.tengu_oauth_token_refresh_lock_acquired.tengu_oauth_token_refresh_starting.tengu_oauth_token_refresh_completed.tengu_oauth_token_refresh_lock_releasing.tengu_oauth_token_refresh_lock_released.tengu_query_error.tengu_session_file_read.tengu_started.tengu_tool_use_error.tengu_tool_use_granted_in_prompt_permanent.tengu_tool_use_granted_in_prompt_temporary.tengu_tool_use_rejected_in_prompt.tengu_tool_use_success.tengu_uncaught_exception.tengu_unhandled_rejection.tengu_voice_recording_started.tengu_voice_toggled.tengu_team_mem_sync_pull.tengu_team_mem_sync_push.tengu_team_mem_sync_started.tengu_team_mem_entries_capped`.split(`.`)),M=[`arch`,`clientType`,`errorType`,`http_status_range`,`http_status`,`model`,`platform`,`provider`,`skillMode`,`subscriptionType`,`toolName`,`userBucket`,`userType`,`version`,`versionBase`],N=[],P=null,F=null,I=t(async()=>{if(v()||!E||!D)return F=!1,!1;try{return F=!0,!0}catch(e){return c(e),F=!1,!1}}),L=30,R=t(()=>{let e=a(),t=y(`sha256`).update(e).digest(`hex`);return parseInt(t.slice(0,8),16)%L})}));export{C as n,w as r,z as t};
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./memoize-BK3gG5ob.js";import{n as r,t as i}from"./axios-DaWTGg7G.js";import{d as a,h as o}from"./config-DRy1I12M.js";import{o as s,s as c}from"./log-CZ7ploQm.js";import{$r as l,N as u,R as d,_ as f,r as p,ti as m}from"./model-Do0f476p.js";import{Z as h,et as g}from"./esm-CvHtYRrr.js";import{f as _,p as v}from"./firstPartyEventLogger-DqGSujCz.js";import{createHash as y}from"crypto";function b(e){return e.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`)}async function x(){if(N.length===0)return;let e=N;N=[];try{await r.post(E,e,{headers:{"Content-Type":`application/json`,"DD-API-KEY":D},timeout:A})}catch(e){c(e)}}function S(){P||(P=setTimeout(()=>{P=null,x()},T()).unref())}async function C(){P&&(clearTimeout(P),P=null),await x()}async function w(e,t){if(l()!==`firstParty`)return;let n=F;if(n===null&&(n=await I()),!(!n||!j.has(e)))try{let{envContext:n,...r}=await h({model:t.model,betas:t.betas}),i={...r,...n,...t,userBucket:R()};if(typeof i.toolName==`string`&&i.toolName.startsWith(`mcp__`)&&(i.toolName=`mcp`),typeof i.model==`string`){let e=p(i.model.replace(/\[1m]$/i,``));i.model=e in u?e:`other`}if(typeof i.version==`string`&&(i.version=i.version.replace(/^(\d+\.\d+\.\d+-dev\.\d{8})\.t\d+\.sha[a-f0-9]+$/,`$1`)),i.status!==void 0&&i.status!==null){let e=String(i.status);i.http_status=e;let t=e.charAt(0);t>=`1`&&t<=`5`&&(i.http_status_range=`${t}xx`),delete i.status}let a=i,o={ddsource:`nodejs`,ddtags:[`event:${e}`,...M.filter(e=>a[e]!==void 0&&a[e]!==null).map(e=>`${b(e)}:${a[e]}`)].join(`,`),message:e,service:`workmate`,hostname:`workmate`,env:process.env.USER_TYPE};for(let[e,t]of Object.entries(i))t!=null&&(o[b(e)]=t);N.push(o),N.length>=k?(P&&(clearTimeout(P),P=null),x()):S()}catch(e){c(e)}}function T(){return parseInt(process.env.CLAUDE_CODE_DATADOG_FLUSH_INTERVAL_MS||``,10)||O}var E,D,O,k,A,j,M,N,P,F,I,L,R,z=e((()=>{i(),n(),o(),s(),f(),m(),d(),_(),g(),E=process.env.DATADOG_LOGS_ENDPOINT??``,D=process.env.DATADOG_API_KEY??``,O=15e3,k=100,A=5e3,j=new Set(`tengu_api_error.tengu_api_success.tengu_cancel.tengu_compact_failed.tengu_exit.tengu_flicker.tengu_init.tengu_model_fallback_triggered.tengu_oauth_error.tengu_oauth_success.tengu_oauth_token_refresh_failure.tengu_oauth_token_refresh_success.tengu_oauth_token_refresh_lock_acquiring.tengu_oauth_token_refresh_lock_acquired.tengu_oauth_token_refresh_starting.tengu_oauth_token_refresh_completed.tengu_oauth_token_refresh_lock_releasing.tengu_oauth_token_refresh_lock_released.tengu_query_error.tengu_session_file_read.tengu_started.tengu_tool_use_error.tengu_tool_use_granted_in_prompt_permanent.tengu_tool_use_granted_in_prompt_temporary.tengu_tool_use_rejected_in_prompt.tengu_tool_use_success.tengu_uncaught_exception.tengu_unhandled_rejection.tengu_voice_recording_started.tengu_voice_toggled.tengu_team_mem_sync_pull.tengu_team_mem_sync_push.tengu_team_mem_sync_started.tengu_team_mem_entries_capped`.split(`.`)),M=[`arch`,`clientType`,`errorType`,`http_status_range`,`http_status`,`model`,`platform`,`provider`,`skillMode`,`subscriptionType`,`toolName`,`userBucket`,`userType`,`version`,`versionBase`],N=[],P=null,F=null,I=t(async()=>{if(v()||!E||!D)return F=!1,!1;try{return F=!0,!0}catch(e){return c(e),F=!1,!1}}),L=30,R=t(()=>{let e=a(),t=y(`sha256`).update(e).digest(`hex`);return parseInt(t.slice(0,8),16)%L})}));export{C as n,w as r,z as t};
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{t}from"./jsx-runtime-Bb4Xn-E0.js";var n,r;e((()=>{n=t(),r=async(e,t)=>{let{DiffDialog:r}=await import(`./DiffDialog-6Srcz3NW.js`);return(0,n.jsx)(r,{messages:t.messages,onDone:e})}}))();export{r as call};
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{t}from"./jsx-runtime-Bb4Xn-E0.js";var n,r;e((()=>{n=t(),r=async(e,t)=>{let{DiffDialog:r}=await import(`./DiffDialog-DCpchgp5.js`);return(0,n.jsx)(r,{messages:t.messages,onDone:e})}}))();export{r as call};
@@ -0,0 +1 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{t}from"./jsx-runtime-Bb4Xn-E0.js";import{n,t as r}from"./Doctor-FPYTivHw.js";var i,a;e((()=>{n(),i=t(),a=(e,t,n)=>Promise.resolve((0,i.jsx)(r,{onDone:e}))}))();export{a as call};