@readmagic/workmate 0.0.6 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (409) hide show
  1. package/dist/chunks/{AddWorkspaceDirectory-ClHi-Dr6.js → AddWorkspaceDirectory-CFrrXnt9.js} +1 -1
  2. package/dist/chunks/{App-BP06lHmf.js → App-Buad9Llp.js} +1 -1
  3. package/dist/chunks/{ApproveApiKey-Bsy8kr2a.js → ApproveApiKey-B2HJUD7h.js} +1 -1
  4. package/dist/chunks/ApproveApiKey-BQbHdvc3.js +1 -0
  5. package/dist/chunks/{AssistantSessionChooser-CcocKoTJ.js → AssistantSessionChooser-4lm4eXQ8.js} +1 -1
  6. package/dist/chunks/BackgroundTasksDialog-D4qA0M5O.js +2 -0
  7. package/dist/chunks/{BypassPermissionsModeDialog-BKj_3Idm.js → BypassPermissionsModeDialog-DllL8dxU.js} +1 -1
  8. package/dist/chunks/ClaudeMdExternalIncludesDialog--ywODh81.js +1 -0
  9. package/dist/chunks/{ClaudeMdExternalIncludesDialog-BD-7yAZh.js → ClaudeMdExternalIncludesDialog-BZSyRqeq.js} +1 -1
  10. package/dist/chunks/ConsoleOAuthFlow-Wkfw7Ts-.js +1 -0
  11. package/dist/chunks/{DesktopHandoff-BmPmCfT3.js → DesktopHandoff-DaP4Riar.js} +1 -1
  12. package/dist/chunks/{DiffDialog-C4XSSjvV.js → DiffDialog-B7hx8i_Y.js} +2 -2
  13. package/dist/chunks/Doctor-89OgoAUA.js +1 -0
  14. package/dist/chunks/Doctor-CuKJ-nGt.js +3 -0
  15. package/dist/chunks/ExitFlow-DnPydE17.js +2 -0
  16. package/dist/chunks/{Feedback-BaYA8-SU.js → Feedback-SmGiR3mf.js} +2 -2
  17. package/dist/chunks/{Grove-BJziCbZH.js → Grove-CjN9DO47.js} +1 -1
  18. package/dist/chunks/Grove-Cq88VBmM.js +1 -0
  19. package/dist/chunks/{HybridTransport-B8V6O6rM.js → HybridTransport-rK83Qijz.js} +1 -1
  20. package/dist/chunks/{InvalidConfigDialog-CHzBSJDf.js → InvalidConfigDialog-DdO0AxyF.js} +1 -1
  21. package/dist/chunks/{InvalidSettingsDialog-BKenH3bD.js → InvalidSettingsDialog-s1G0DwXF.js} +1 -1
  22. package/dist/chunks/MCPConnectionManager-NRfIjdlj.js +1 -0
  23. package/dist/chunks/{McpParsingWarnings-Bj2-YL8o.js → McpParsingWarnings-Du5IxZos.js} +1 -1
  24. package/dist/chunks/MessageSelector-iIroHvXo.js +3 -0
  25. package/dist/chunks/Messages-D4Hm4gaY.js +11 -0
  26. package/dist/chunks/{Onboarding-BrAJp0aL.js → Onboarding-BiZByBK-.js} +1 -1
  27. package/dist/chunks/{OverageCreditUpsell-Ds1cB7RC.js → OverageCreditUpsell-BM7szLgm.js} +1 -1
  28. package/dist/chunks/PluginSettings-uY5KTCtK.js +17 -0
  29. package/dist/chunks/{PromptInputFooterSuggestions-egs9VvUs.js → PromptInputFooterSuggestions-BmsFdOu9.js} +1 -1
  30. package/dist/chunks/{PromptInputHelpMenu-SieM5NoY.js → PromptInputHelpMenu-DX-0wEDo.js} +1 -1
  31. package/dist/chunks/QueryEngine-CGYaShXD.js +1 -0
  32. package/dist/chunks/REPL-CRJB2t2z.js +142 -0
  33. package/dist/chunks/REPL-u4Yq29Du.js +1 -0
  34. package/dist/chunks/{RemoteCallout-Cs-ro8_i.js → RemoteCallout-B-tyvQOe.js} +1 -1
  35. package/dist/chunks/{RemoteSessionManager-B740Dp6m.js → RemoteSessionManager-DCd0O5_l.js} +2 -2
  36. package/dist/chunks/ResumeConversation-DAAXlOCd.js +1 -0
  37. package/dist/chunks/{SSETransport-DtpMDekF.js → SSETransport-5VK5okFv.js} +1 -1
  38. package/dist/chunks/SearchExtraToolsTool-B-7Bworf.js +1 -0
  39. package/dist/chunks/Settings-CUjWlncb.js +2 -0
  40. package/dist/chunks/{TeleportProgress-rYaHIEfe.js → TeleportProgress-DxN0bQL2.js} +1 -1
  41. package/dist/chunks/{TeleportRepoMismatchDialog-DY97YZMB.js → TeleportRepoMismatchDialog-A5Ss0kuk.js} +1 -1
  42. package/dist/chunks/{TeleportResumeWrapper-jaQzyTCh.js → TeleportResumeWrapper-Bz14mUqR.js} +1 -1
  43. package/dist/chunks/{ThemePicker-BViWzLp3.js → ThemePicker-CVSRqTzW.js} +1 -1
  44. package/dist/chunks/TrustDialog-CY8an_Tg.js +1 -0
  45. package/dist/chunks/{ValidationErrorsList-B8pRiGuy.js → ValidationErrorsList-BYsDtAvX.js} +1 -1
  46. package/dist/chunks/{WelcomeV2-DqnbSdIu.js → WelcomeV2-C1BfrqC5.js} +1 -1
  47. package/dist/chunks/{add-dir-C2Hu3oE4.js → add-dir-DfLYgwox.js} +1 -1
  48. package/dist/chunks/{agentDisplay-XoDJhr03.js → agentDisplay-CMmHIl86.js} +1 -1
  49. package/dist/chunks/{agents-C4QXeHIJ.js → agents-DE_4mAHG.js} +1 -1
  50. package/dist/chunks/agents-DJtPfvnL.js +103 -0
  51. package/dist/chunks/allErrors-CQE2k0zO.js +1 -0
  52. package/dist/chunks/{ant-B6k6cBts.js → ant-ClQkuQjZ.js} +1 -1
  53. package/dist/chunks/{api-gqTA-D7n.js → api-2cdIPaeq.js} +1 -1
  54. package/dist/chunks/api-CG-lhKe-.js +1 -0
  55. package/dist/chunks/{assistant-DJ9hd4uC.js → assistant-Bje16tQx.js} +1 -1
  56. package/dist/chunks/auth-DMfEiQrC.js +1 -0
  57. package/dist/chunks/auth-D_cGl8WD.js +1 -0
  58. package/dist/chunks/{auth-BnSrKyJe.js → auth-DqcKPbw8.js} +1 -1
  59. package/dist/chunks/{autoMode-BNukrVAB.js → autoMode-ZW70mpr0.js} +5 -5
  60. package/dist/chunks/{autonomy-BEmI7WVW.js → autonomy-CwbWsCnv.js} +1 -1
  61. package/dist/chunks/autonomy-Oui8yK8G.js +15 -0
  62. package/dist/chunks/{autonomyPanel-fhge09AG.js → autonomyPanel-Mq50H7iM.js} +1 -1
  63. package/dist/chunks/backgroundHousekeeping-BpLtI45r.js +1 -0
  64. package/dist/chunks/backgroundHousekeeping-DtJNx4Ja.js +17 -0
  65. package/dist/chunks/{branch-Bpe-gocq.js → branch-DU5O9KZ0.js} +1 -1
  66. package/dist/chunks/{bridge-D12Shbkj.js → bridge-DNNxtPlz.js} +2 -2
  67. package/dist/chunks/{bridgeConfig-BhxRF2vm.js → bridgeConfig-CE6dMsiJ.js} +1 -1
  68. package/dist/chunks/bridgeConfig-DP9dD1Cv.js +1 -0
  69. package/dist/chunks/{bridgeEnabled-SbB-6zdY.js → bridgeEnabled-Cc0mGlTb.js} +1 -1
  70. package/dist/chunks/bridgeEnabled-D8wP3DWQ.js +1 -0
  71. package/dist/chunks/bridgeMain-CwxMa_pd.js +1 -0
  72. package/dist/chunks/bridgeMain-D11t1BYQ.js +68 -0
  73. package/dist/chunks/{bridgeMessaging-DHc5dOhB.js → bridgeMessaging-DdvApEqW.js} +1 -1
  74. package/dist/chunks/{bridgePointer-MqLe5Asm.js → bridgePointer-DqHMHa2B.js} +1 -1
  75. package/dist/chunks/{btw-D9hMM5d2.js → btw-CejSEdNl.js} +1 -1
  76. package/dist/chunks/{caches-UeVVM3T0.js → caches-5HVQSevy.js} +2 -2
  77. package/dist/chunks/caches-B-nJoHLM.js +1 -0
  78. package/dist/chunks/{ccrClient-Iza0L8Zw.js → ccrClient-BFyfO67b.js} +1 -1
  79. package/dist/chunks/{claudeDesktop-Cx31Ugjp.js → claudeDesktop-Fe-QL-sN.js} +1 -1
  80. package/dist/chunks/{clear-B4d38ssF.js → clear-D8m2utXW.js} +1 -1
  81. package/dist/chunks/client-C6MbjvOB.js +17 -0
  82. package/dist/chunks/client-DKXCfdde.js +1 -0
  83. package/dist/chunks/client-xxikkAoZ.js +1 -0
  84. package/dist/chunks/{color-D8VOyoYl.js → color-DWhgZH7A.js} +1 -1
  85. package/dist/chunks/commands-CxJpmEKF.js +1 -0
  86. package/dist/chunks/commitAttribution-DM6SBMwl.js +1 -0
  87. package/dist/chunks/{commitAttribution-ChAgixdj.js → commitAttribution-DPnHHKSA.js} +1 -1
  88. package/dist/chunks/compact-CblM7306.js +2 -0
  89. package/dist/chunks/config-BLVBFi5v.js +1 -0
  90. package/dist/chunks/config-CMnqm6Se.js +1 -0
  91. package/dist/chunks/{config-DmomySWC.js → config-DRDuVyzE.js} +2 -2
  92. package/dist/chunks/{context-Cl6BJ2vm.js → context-CdSMMM-0.js} +1 -1
  93. package/dist/chunks/context-noninteractive-CPkf2vB9.js +1 -0
  94. package/dist/chunks/{context-noninteractive-9hELVC29.js → context-noninteractive-DNury4JI.js} +5 -5
  95. package/dist/chunks/conversation-DCMw_rsE.js +1 -0
  96. package/dist/chunks/conversation-pUtvc-cE.js +1 -0
  97. package/dist/chunks/{createSSHSession-BM-5pbv6.js → createSSHSession-BOdTAX3N.js} +1 -1
  98. package/dist/chunks/{createSession-Cvl1Q50F.js → createSession-8Ei-Lj7V.js} +1 -1
  99. package/dist/chunks/createSession-CjqxVh_Q.js +1 -0
  100. package/dist/chunks/crossProjectResume-Bj_Pe8oe.js +40 -0
  101. package/dist/chunks/{datadog-CpqEQbHa.js → datadog-DqHxqiwY.js} +1 -1
  102. package/dist/chunks/{desktop-B_L6T6jI.js → desktop-Z5FAfunZ.js} +1 -1
  103. package/dist/chunks/{diff-CVzOodeg.js → diff-CJEKvOA5.js} +1 -1
  104. package/dist/chunks/doctor-BA2ZLDTl.js +1 -0
  105. package/dist/chunks/{entry-DHVYCR26.js → entry-DE0uMIf0.js} +4 -4
  106. package/dist/chunks/envLessBridgeConfig-B-LKYNvv.js +1 -0
  107. package/dist/chunks/envLessBridgeConfig-DyD9XCda.js +1 -0
  108. package/dist/chunks/{esm-D5q6s4l8.js → esm-5w3xFBnt.js} +1 -1
  109. package/dist/chunks/exit-Dt9kHtJO.js +1 -0
  110. package/dist/chunks/{extra-usage-zDHVtWKZ.js → extra-usage-C7E2Z1p1.js} +1 -1
  111. package/dist/chunks/extra-usage-D0Kkjp-2.js +1 -0
  112. package/dist/chunks/{extra-usage-core-BFOolqoi.js → extra-usage-core-DjdaD1qO.js} +1 -1
  113. package/dist/chunks/{extra-usage-noninteractive-cUGZy0en.js → extra-usage-noninteractive-BnD1RhKK.js} +1 -1
  114. package/dist/chunks/{extraUsage-Dq66zzqR.js → extraUsage-CpgRTcMk.js} +1 -1
  115. package/dist/chunks/extractMemories-DhUprYa7.js +1 -0
  116. package/dist/chunks/{fast-MS7WZpD8.js → fast-C4ZevUNL.js} +1 -1
  117. package/dist/chunks/fast-CChxlAAF.js +1 -0
  118. package/dist/chunks/{feedback-Fw4m28ZC.js → feedback-BIhBhV6n.js} +1 -1
  119. package/dist/chunks/{firstPartyEventLogger-CoSUd0a1.js → firstPartyEventLogger-BXY1IJ2D.js} +2 -2
  120. package/dist/chunks/firstPartyEventLogger-CnkGSojw.js +1 -0
  121. package/dist/chunks/{flushGate-De-yppeo.js → flushGate-CgHq81Gw.js} +1 -1
  122. package/dist/chunks/{gemini-BPziscyN.js → gemini-C1J-x1g7.js} +1 -1
  123. package/dist/chunks/generateRecap-C0jjCg0Z.js +1 -0
  124. package/dist/chunks/generateSessionName-w0BMtwS7.js +1 -0
  125. package/dist/chunks/{githubRepoPathMapping-qAoiyj6P.js → githubRepoPathMapping-8D0kpsif.js} +1 -1
  126. package/dist/chunks/{goal-CFx4eRkf.js → goal-B4GsR54_.js} +3 -3
  127. package/dist/chunks/grok-ffNyU3Lt.js +1 -0
  128. package/dist/chunks/{grove-CpqjcGCb.js → grove-BQisE2JM.js} +1 -1
  129. package/dist/chunks/{heapdump-C4kPlqGt.js → heapdump-DiCjAPR3.js} +1 -1
  130. package/dist/chunks/{help-B1h-faJ3.js → help-2hn8VK2-.js} +1 -1
  131. package/dist/chunks/hooks-CBmrBO-J.js +1 -0
  132. package/dist/chunks/{hooks-X6J03MnA.js → hooks-CkA9bhHl.js} +2 -2
  133. package/dist/chunks/inboundAttachments-C5K3XPTC.js +1 -0
  134. package/dist/chunks/{inboundAttachments-CUJE3KaU.js → inboundAttachments-IH-g95jo.js} +1 -1
  135. package/dist/chunks/initReplBridge-C-P4dgAG.js +1 -0
  136. package/dist/chunks/{install-D5YORIJL.js → install-Dzlm4u58.js} +1 -1
  137. package/dist/chunks/{instrumentation-Bw3CxPQf.js → instrumentation-Yt31gxWN.js} +3 -3
  138. package/dist/chunks/{job-DOWtcltx.js → job-BXujwZNa.js} +1 -1
  139. package/dist/chunks/{keybindings-BLw5J-Zj.js → keybindings-D8FXoO89.js} +2 -2
  140. package/dist/chunks/language-Baosud0X.js +1 -0
  141. package/dist/chunks/{language-C6Fq-XOZ.js → language-Ca4B018X.js} +1 -1
  142. package/dist/chunks/{launchAgentsPlatform-jWWf-Lk9.js → launchAgentsPlatform-D6DmNuDt.js} +1 -1
  143. package/dist/chunks/{launchLocalMemory-kHeD0I0y.js → launchLocalMemory-C0FzUq7x.js} +2 -2
  144. package/dist/chunks/{launchLocalVault-DLqkOjmb.js → launchLocalVault-DkYAre4O.js} +3 -3
  145. package/dist/chunks/{launchMemoryStores-Ct7AVXrO.js → launchMemoryStores-D2rKWAPs.js} +1 -1
  146. package/dist/chunks/{launchOnboarding-Cc6WwPX9.js → launchOnboarding-gOVAFEFp.js} +1 -1
  147. package/dist/chunks/{launchSchedule-ZyvuvjgU.js → launchSchedule-IZdFstT_.js} +1 -1
  148. package/dist/chunks/{launchSkillStore-BejQnLog.js → launchSkillStore-B7LamM1d.js} +1 -1
  149. package/dist/chunks/{launchTeleport-8CuYUfIR.js → launchTeleport-C2BQMfYP.js} +3 -3
  150. package/dist/chunks/{launchVault-DIvIOuPh.js → launchVault-C60WUcCI.js} +1 -1
  151. package/dist/chunks/{lazySchema-DcIJE_0i.js → lazySchema-DULtBUCI.js} +1 -1
  152. package/dist/chunks/loadAgentsDir-B9c3Emvg.js +1 -0
  153. package/dist/chunks/{loadAgentsDir-D206qwP3.js → loadAgentsDir-x3rlgED4.js} +690 -692
  154. package/dist/chunks/loadPluginHooks-BhNdAjeY.js +1 -0
  155. package/dist/chunks/localSearch-BLCGsdyM.js +1 -0
  156. package/dist/chunks/{localSearch-CzrbOklu.js → localSearch-DtplGF-l.js} +1 -1
  157. package/dist/chunks/{logoV2Utils-8M56V7oN.js → logoV2Utils-gGK9gErT.js} +1 -1
  158. package/dist/chunks/{magicDocs-DWjL2k7P.js → magicDocs-qdDB_mKb.js} +2 -2
  159. package/dist/chunks/{main-BohPzJFF.js → main-OWFSddRx.js} +82 -82
  160. package/dist/chunks/managedEnv-Aq5BXfY7.js +1 -0
  161. package/dist/chunks/managedEnv-BHoeDjpS.js +1 -0
  162. package/dist/chunks/managedEnvConstants-BPwL2aWI.js +1 -0
  163. package/dist/chunks/{mappers-BDMZFgKx.js → mappers-04gNXJ3w.js} +1 -1
  164. package/dist/chunks/mcp-BSNdwbxR.js +1 -0
  165. package/dist/chunks/mcp-CMnDNI-4.js +6 -0
  166. package/dist/chunks/mcp-D1yA9E56.js +2 -0
  167. package/dist/chunks/memory-D1zbyjxN.js +1 -0
  168. package/dist/chunks/{mode-CUkHFkju.js → mode-DY087x_x.js} +2 -2
  169. package/dist/chunks/{model-CKkOnnnx.js → model-CZViyZnE.js} +1 -1
  170. package/dist/chunks/{model-BY3auM2c.js → model-D0EfJBuw.js} +1 -1
  171. package/dist/chunks/model-DLLkVV6S.js +1 -0
  172. package/dist/chunks/{nativeInstaller-CA5d6_G7.js → nativeInstaller-yj81F75v.js} +1 -1
  173. package/dist/chunks/onChangeAppState-DhGKPG9g.js +1 -0
  174. package/dist/chunks/{openai-Cbomn0Ws.js → openai-EYRnUsco.js} +3 -3
  175. package/dist/chunks/{overageCreditGrant-DsUrmeBh.js → overageCreditGrant-Du3dOYVu.js} +1 -1
  176. package/dist/chunks/{panelCall-BsVoL1uF.js → panelCall-dMvRPAGE.js} +1 -1
  177. package/dist/chunks/{partition-BAakXjvj.js → partition-C4FWzYVm.js} +1 -1
  178. package/dist/chunks/{passes-CLRt7Cvm.js → passes-Daz-ARWD.js} +1 -1
  179. package/dist/chunks/permissions-DF8tAmDF.js +3 -0
  180. package/dist/chunks/{pidLock-D5rUnDB-.js → pidLock-CbC_il6r.js} +2 -2
  181. package/dist/chunks/{plan-SYZ4DXR8.js → plan-rsb_83Fo.js} +1 -1
  182. package/dist/chunks/{plugin-Bfjzhmrk.js → plugin-Cm31-nej.js} +1 -1
  183. package/dist/chunks/pluginAutoupdate-0k03PVff.js +1 -0
  184. package/dist/chunks/pluginBlocklist-wPFCUPdm.js +1 -0
  185. package/dist/chunks/pluginCliCommands-DhL9LbH0.js +1 -0
  186. package/dist/chunks/{pluginFlagging-D9HKAGBC.js → pluginFlagging-CAdaFV_D.js} +1 -1
  187. package/dist/chunks/pluginOperations-Cs_Z4C6O.js +2 -0
  188. package/dist/chunks/pluginStartupCheck-BRXGKGjG.js +1 -0
  189. package/dist/chunks/pluginStartupCheck-KeU0efTj.js +1 -0
  190. package/dist/chunks/{plugins-Dn6ceWrT.js → plugins-CQNKZmjP.js} +4 -4
  191. package/dist/chunks/policyLimits-D2s8M8P2.js +1 -0
  192. package/dist/chunks/{pollConfig-DH2oCtFS.js → pollConfig-2nFzv6Hy.js} +1 -1
  193. package/dist/chunks/{poor-j-y-bv8o.js → poor-DXumVTR4.js} +1 -1
  194. package/dist/chunks/{poorMode-DhzFKpPl.js → poorMode-CBOtooa0.js} +1 -1
  195. package/dist/chunks/poorMode-yNZL5uYf.js +1 -0
  196. package/dist/chunks/print-uxCF5ka5.js +23 -0
  197. package/dist/chunks/{privacy-settings-DHMJREbb.js → privacy-settings-BncbJCV0.js} +1 -1
  198. package/dist/chunks/processBashCommand-CGdwvPmD.js +1 -0
  199. package/dist/chunks/processSlashCommand-DQarepEb.js +5 -0
  200. package/dist/chunks/prompt-BgOdcHkd.js +1 -0
  201. package/dist/chunks/{prompt-BNHtszmZ.js → prompt-CE3sFmZV.js} +5 -5
  202. package/dist/chunks/prompt-CLJKFebn.js +1 -0
  203. package/dist/chunks/{promptEditor-DeMrXUir.js → promptEditor-CyTzyjwG.js} +2 -2
  204. package/dist/chunks/{protocolHandler-BHxBy84Z.js → protocolHandler-JR8pASdH.js} +1 -1
  205. package/dist/chunks/rate-limit-options-C-EqWjeI.js +1 -0
  206. package/dist/chunks/{rcDebugLog-CUy1_F23.js → rcDebugLog-DBB9r8aw.js} +1 -1
  207. package/dist/chunks/reconciler-CYD_XpG4.js +4 -0
  208. package/dist/chunks/{referral-CUaIo_vT.js → referral-CKmHHxj_.js} +1 -1
  209. package/dist/chunks/refresh-ZqZdmLK5.js +1 -0
  210. package/dist/chunks/{registerProtocol-B7Fzdofu.js → registerProtocol-wZv2uiW_.js} +1 -1
  211. package/dist/chunks/{release-notes-fbfv2DC0.js → release-notes-B5K7wVqZ.js} +1 -1
  212. package/dist/chunks/{releaseNotes-CxAHFLPl.js → releaseNotes-B8gbyFFJ.js} +2 -2
  213. package/dist/chunks/{reload-plugins-B9IT9CFA.js → reload-plugins-B9ApSp2m.js} +1 -1
  214. package/dist/chunks/{remote-env-BOklGlll.js → remote-env-CAt1dHIS.js} +1 -1
  215. package/dist/chunks/{remoteBridgeCore-j0bG1zjv.js → remoteBridgeCore-Bk3UdSLJ.js} +1 -1
  216. package/dist/chunks/remoteManagedSettings-bswzAB6W.js +1 -0
  217. package/dist/chunks/rename-CE_U6KE6.js +1 -0
  218. package/dist/chunks/{resume-y7MCTZHJ.js → resume-BicEjsPd.js} +2 -2
  219. package/dist/chunks/{runtimeObserver-CyzLASla.js → runtimeObserver-BrGF5QWX.js} +4 -4
  220. package/dist/chunks/{runtimeObserver-BZcJ1FbH.js → runtimeObserver-CiwnPFjK.js} +1 -1
  221. package/dist/chunks/sandbox-adapter-BtMiHImm.js +1 -0
  222. package/dist/chunks/{sandbox-toggle-CWpBO228.js → sandbox-toggle-D8eebdyI.js} +1 -1
  223. package/dist/chunks/searchExtraTools-hLLPuh7c.js +1 -0
  224. package/dist/chunks/{session-DL4cA_8l.js → session-BZIlR9Gc.js} +2 -2
  225. package/dist/chunks/{sessionDiscovery-DAfNKqp1.js → sessionDiscovery-DfDqTrF1.js} +1 -1
  226. package/dist/chunks/sessionFileAccessHooks-Bm8wiqwe.js +1 -0
  227. package/dist/chunks/sessionMemory-D37S0-jX.js +1 -0
  228. package/dist/chunks/sessionMemory-DmlAG3jq.js +1 -0
  229. package/dist/chunks/sessionMemoryUtils-6EWDHSGU.js +1 -0
  230. package/dist/chunks/sessionObserver-BUw2rzKl.js +1 -0
  231. package/dist/chunks/{sessionObserver-ShbCwJ8x.js → sessionObserver-KgquhGWw.js} +1 -1
  232. package/dist/chunks/sessionStorage-CucBSK5Q.js +1 -0
  233. package/dist/chunks/{sessionTitle-coed9IuJ.js → sessionTitle-DAnM73S0.js} +2 -2
  234. package/dist/chunks/{sessionTracing-D9rUyiq0.js → sessionTracing-_Hh5VXxt.js} +1 -1
  235. package/dist/chunks/settings-BeLFUeie.js +19 -0
  236. package/dist/chunks/settings-Cl16Haug.js +1 -0
  237. package/dist/chunks/settingsSync-BNvFYH3c.js +1 -0
  238. package/dist/chunks/setup-D8kXv3ts.js +3 -0
  239. package/dist/chunks/{shadowedRuleDetection-D1wsAdpp.js → shadowedRuleDetection-C6R5zOUe.js} +1 -1
  240. package/dist/chunks/{sideQuestion-wSi38p81.js → sideQuestion-hUhxls9r.js} +3 -3
  241. package/dist/chunks/{sinks-C_Dl1p4K.js → sinks-BuE17DeZ.js} +2 -2
  242. package/dist/chunks/sinks-FevoYQqP.js +1 -0
  243. package/dist/chunks/{skill-learning-B5tmc7EX.js → skill-learning-CMdxGtxr.js} +1 -1
  244. package/dist/chunks/skillChangeDetector-C65ZLSYV.js +1 -0
  245. package/dist/chunks/{skillGapStore-Df5BWAk5.js → skillGapStore-D18LRJAM.js} +2 -2
  246. package/dist/chunks/{skillGapStore-D-kQKVDZ.js → skillGapStore-Ep62R-2_.js} +1 -1
  247. package/dist/chunks/{skillGenerator-DbcdpAkw.js → skillGenerator-Bc7WwNT8.js} +2 -2
  248. package/dist/chunks/{skillLearning-ClRiDcJH.js → skillLearning-Cs9fJgkV.js} +1 -1
  249. package/dist/chunks/skillLearning-duPZl69A.js +1 -0
  250. package/dist/chunks/{skillPanel-LBd4E-MM.js → skillPanel-Cyzby746.js} +3 -3
  251. package/dist/chunks/{skillSearchPanel-CErRnUwo.js → skillSearchPanel-Cll9ccA5.js} +4 -4
  252. package/dist/chunks/{skills-CBKhfg_a.js → skills-BPPeYBy7.js} +1 -1
  253. package/dist/chunks/{stats-BY4dskVg.js → stats-CqfF4Axp.js} +1 -1
  254. package/dist/chunks/{status-DU-B4SMW.js → status-CC9Q-2Yn.js} +1 -1
  255. package/dist/chunks/{status-BnJIXtKl.js → status-D4IQpsNK.js} +2 -2
  256. package/dist/chunks/statusNoticeHelpers-CEGvdm5d.js +1 -0
  257. package/dist/chunks/syncCache-CANQZ9mQ.js +1 -0
  258. package/dist/chunks/{tag-B-wVW9Aj.js → tag-DDbNqBMu.js} +2 -2
  259. package/dist/chunks/{tasks-CBVL005y.js → tasks-CZvWJYGr.js} +1 -1
  260. package/dist/chunks/teleport-Dk5j03Ix.js +1 -0
  261. package/dist/chunks/{templateJobs-D6998LcG.js → templateJobs-D1BdhZsv.js} +1 -1
  262. package/dist/chunks/{terminalSetup-CuV-qU6v.js → terminalSetup-3JNy6i_J.js} +5 -5
  263. package/dist/chunks/{terminalSetup-0SBdyKF5.js → terminalSetup-Cn6jeYw1.js} +1 -1
  264. package/dist/chunks/{theme-p0AooruD.js → theme-Cg4GNOoQ.js} +1 -1
  265. package/dist/chunks/thinkback-p-vKIRW_.js +1 -0
  266. package/dist/chunks/thinkback-play-DnPTDE8B.js +1 -0
  267. package/dist/chunks/{thinkback-DI2NpvG-.js → thinkback-rFA1do6F.js} +1 -1
  268. package/dist/chunks/{toolEventObserver-DlH73w-S.js → toolEventObserver-CzsCuUMc.js} +1 -1
  269. package/dist/chunks/{toolEventObserver-DTccwC3c.js → toolEventObserver-SFwURL5F.js} +1 -1
  270. package/dist/chunks/toolPool-BR27AMJO.js +1 -0
  271. package/dist/chunks/trustedDevice-BYt39fui.js +1 -0
  272. package/dist/chunks/{trustedDevice-BTYoQCkC.js → trustedDevice-CKedohmT.js} +1 -1
  273. package/dist/chunks/{types-C-MRCL8J.js → types-Dut4311z.js} +2 -2
  274. package/dist/chunks/{ultrareviewCommand-BDFUS3hf.js → ultrareviewCommand-C_4OSBTW.js} +2 -2
  275. package/dist/chunks/{undercover-vuTpCnQJ.js → undercover-D30rKimg.js} +1 -1
  276. package/dist/chunks/undercover-DRSwLozU.js +1 -0
  277. package/dist/chunks/{updateCCB-DFL5Wt_I.js → updateCCB-C2G-U-qA.js} +1 -1
  278. package/dist/chunks/upgrade-Bi-bIz7R.js +1 -0
  279. package/dist/chunks/{upgrade-D5qwcaWQ.js → upgrade-Chs-OQFd.js} +1 -1
  280. package/dist/chunks/{upload-B_yADHX9.js → upload-D8FWMSQx.js} +1 -1
  281. package/dist/chunks/{usage-C0SnnC-i.js → usage-BxVeUt60.js} +1 -1
  282. package/dist/chunks/usage-DUO7Yy1f.js +1 -0
  283. package/dist/chunks/{useExitOnCtrlCDWithKeybindings-DKIqRraH.js → useExitOnCtrlCDWithKeybindings-BwsZ5f0s.js} +1 -1
  284. package/dist/chunks/useMainLoopModel-Gy1Vv4Qr.js +1 -0
  285. package/dist/chunks/useManagePlugins-B11_87VN.js +1 -0
  286. package/dist/chunks/useMergedTools-CR56my9t.js +1 -0
  287. package/dist/chunks/{useSearchInput-D1Vr2Js1.js → useSearchInput-C5OzQnX6.js} +1 -1
  288. package/dist/chunks/{useSettingsErrors-B7BXHchG.js → useSettingsErrors-B9vOZL41.js} +1 -1
  289. package/dist/chunks/{util-BaDs-wL5.js → util-8EHwfg4A.js} +1 -1
  290. package/dist/chunks/validatePlugin-6q1qmnAC.js +1 -0
  291. package/dist/chunks/{vim-C-icQDz1.js → vim-CNDzwoTd.js} +1 -1
  292. package/dist/chunks/{workerRegistry-ChqPPIaO.js → workerRegistry-CvyHvwx-.js} +1 -1
  293. package/dist/chunks/worktree-ogmNCIpz.js +1 -0
  294. package/dist/cli.js +1 -1
  295. package/package.json +1 -1
  296. package/dist/chunks/ApproveApiKey-a2ZonQ3n.js +0 -1
  297. package/dist/chunks/BackgroundTasksDialog-DNeBhGCf.js +0 -2
  298. package/dist/chunks/ClaudeMdExternalIncludesDialog-DFivNFuo.js +0 -1
  299. package/dist/chunks/ConsoleOAuthFlow-CS3zjEPF.js +0 -1
  300. package/dist/chunks/Doctor-BhD-ZzZm.js +0 -1
  301. package/dist/chunks/Doctor-DEQe2q16.js +0 -3
  302. package/dist/chunks/ExitFlow-BttnAv-O.js +0 -2
  303. package/dist/chunks/Grove-sWm-oLBf.js +0 -1
  304. package/dist/chunks/MCPConnectionManager-CNh9dNlk.js +0 -1
  305. package/dist/chunks/MessageSelector-DdR6wJhh.js +0 -3
  306. package/dist/chunks/Messages-Ch6cboMV.js +0 -11
  307. package/dist/chunks/PluginSettings-CGqEzejq.js +0 -17
  308. package/dist/chunks/QueryEngine-CZZMl3PB.js +0 -1
  309. package/dist/chunks/REPL-CG2N7E4Q.js +0 -142
  310. package/dist/chunks/REPL-DvA910N_.js +0 -1
  311. package/dist/chunks/ResumeConversation-DzV2zmuX.js +0 -1
  312. package/dist/chunks/SearchExtraToolsTool-C4uO-Zx3.js +0 -1
  313. package/dist/chunks/Settings-XKw6FI_m.js +0 -2
  314. package/dist/chunks/TrustDialog-DGJ_BisZ.js +0 -1
  315. package/dist/chunks/agents-BIHTGDYh.js +0 -103
  316. package/dist/chunks/allErrors-1896uQA1.js +0 -1
  317. package/dist/chunks/api-BsFW57_Q.js +0 -1
  318. package/dist/chunks/auth-8Vd3_U8t.js +0 -1
  319. package/dist/chunks/auth-DRTjfnGy.js +0 -1
  320. package/dist/chunks/autonomy-DGcy5Rml.js +0 -15
  321. package/dist/chunks/backgroundHousekeeping-3i_d_WW5.js +0 -1
  322. package/dist/chunks/backgroundHousekeeping-BVMf_Tjn.js +0 -17
  323. package/dist/chunks/bridgeConfig-CqIQ_rvD.js +0 -1
  324. package/dist/chunks/bridgeEnabled-D0XC5kNh.js +0 -1
  325. package/dist/chunks/bridgeMain-DHUpZFgL.js +0 -68
  326. package/dist/chunks/bridgeMain-DUbQjgCp.js +0 -1
  327. package/dist/chunks/caches-CWzT7e6Y.js +0 -1
  328. package/dist/chunks/client-BzKQTXzF.js +0 -1
  329. package/dist/chunks/commands-DDamMmo4.js +0 -1
  330. package/dist/chunks/commitAttribution-CgohL8vD.js +0 -1
  331. package/dist/chunks/compact-IFHwxjZ9.js +0 -2
  332. package/dist/chunks/config-DY5-_kk_.js +0 -1
  333. package/dist/chunks/config-WxgxrQoP.js +0 -1
  334. package/dist/chunks/context-noninteractive-Beij5MfU.js +0 -1
  335. package/dist/chunks/conversation-BBB91hEw.js +0 -1
  336. package/dist/chunks/conversation-BWVTM40Y.js +0 -1
  337. package/dist/chunks/createSession-CoQtL5Rj.js +0 -1
  338. package/dist/chunks/crossProjectResume-BasMLl2n.js +0 -40
  339. package/dist/chunks/doctor-1L0TFuGw.js +0 -1
  340. package/dist/chunks/envLessBridgeConfig-CN0_44-p.js +0 -1
  341. package/dist/chunks/envLessBridgeConfig-Ck2-KMq0.js +0 -1
  342. package/dist/chunks/exit-Bm1S_f3i.js +0 -1
  343. package/dist/chunks/extra-usage-UHAWtypK.js +0 -1
  344. package/dist/chunks/extractMemories-BcaklA33.js +0 -1
  345. package/dist/chunks/fast-DALAHO3d.js +0 -1
  346. package/dist/chunks/firstPartyEventLogger-CS9jVz6D.js +0 -1
  347. package/dist/chunks/generateRecap-jGDLI_wU.js +0 -1
  348. package/dist/chunks/generateSessionName-hDJ6HBJ1.js +0 -1
  349. package/dist/chunks/grok-Byblph7F.js +0 -1
  350. package/dist/chunks/hooks-DPLIIpAD.js +0 -1
  351. package/dist/chunks/inboundAttachments-BekVc0W-.js +0 -1
  352. package/dist/chunks/initReplBridge-JQ-afRx9.js +0 -1
  353. package/dist/chunks/language-Cqw5gYJR.js +0 -1
  354. package/dist/chunks/loadAgentsDir-TZjwTqdr.js +0 -1
  355. package/dist/chunks/loadPluginHooks-Ddhsyn0_.js +0 -1
  356. package/dist/chunks/localSearch-DrOAL6f4.js +0 -1
  357. package/dist/chunks/mcp-Bt1ITh-Z.js +0 -1
  358. package/dist/chunks/mcp-CwJ-AIpt.js +0 -6
  359. package/dist/chunks/mcp-W0LFoyFR.js +0 -2
  360. package/dist/chunks/memory-3wV7m7UU.js +0 -1
  361. package/dist/chunks/model-DRXcJyU9.js +0 -1
  362. package/dist/chunks/onChangeAppState-DBmy2Ow_.js +0 -1
  363. package/dist/chunks/permissions-BVSFuwNP.js +0 -3
  364. package/dist/chunks/pluginAutoupdate-reO2PgtQ.js +0 -1
  365. package/dist/chunks/pluginBlocklist-C3H2afWG.js +0 -1
  366. package/dist/chunks/pluginCliCommands-lqdxdkQp.js +0 -1
  367. package/dist/chunks/pluginOperations-EN3EKLux.js +0 -2
  368. package/dist/chunks/pluginStartupCheck-BY73BMT2.js +0 -1
  369. package/dist/chunks/pluginStartupCheck-CwWOlveD.js +0 -1
  370. package/dist/chunks/policyLimits-CkTI5KEt.js +0 -1
  371. package/dist/chunks/poorMode-V11s-3cf.js +0 -1
  372. package/dist/chunks/print-Db_VXmfO.js +0 -23
  373. package/dist/chunks/processBashCommand-BcM_fhV9.js +0 -1
  374. package/dist/chunks/processSlashCommand-DEVo3GPX.js +0 -5
  375. package/dist/chunks/prompt-CrX31AGm.js +0 -1
  376. package/dist/chunks/prompt-IAvMxKDl.js +0 -1
  377. package/dist/chunks/rate-limit-options-DIudL9fb.js +0 -1
  378. package/dist/chunks/reconciler-BXpPyfSY.js +0 -4
  379. package/dist/chunks/refresh-CuaVBIQ0.js +0 -1
  380. package/dist/chunks/remoteManagedSettings-Cq994lyc.js +0 -1
  381. package/dist/chunks/rename-Iev7wQsI.js +0 -1
  382. package/dist/chunks/sandbox-adapter-Cu1FYrkh.js +0 -1
  383. package/dist/chunks/searchExtraTools-BUOUds7p.js +0 -1
  384. package/dist/chunks/sessionFileAccessHooks-2cgIIxPk.js +0 -1
  385. package/dist/chunks/sessionMemory-BS8_TbKj.js +0 -1
  386. package/dist/chunks/sessionMemory-D5fSHXvZ.js +0 -1
  387. package/dist/chunks/sessionMemoryUtils-BWUztNh6.js +0 -1
  388. package/dist/chunks/sessionObserver-ChfQtK2m.js +0 -1
  389. package/dist/chunks/sessionStorage-Cf5wmnyB.js +0 -1
  390. package/dist/chunks/settings-BovzmwMP.js +0 -19
  391. package/dist/chunks/settingsSync-PqU9XGJq.js +0 -1
  392. package/dist/chunks/setup-B_FOvNpp.js +0 -3
  393. package/dist/chunks/sinks-BpcRrN_T.js +0 -1
  394. package/dist/chunks/skillChangeDetector-DNqohXxz.js +0 -1
  395. package/dist/chunks/skillLearning-C5cXZE6_.js +0 -1
  396. package/dist/chunks/statusNoticeHelpers-CzTuGNuC.js +0 -1
  397. package/dist/chunks/teleport-dtqQXM4x.js +0 -1
  398. package/dist/chunks/thinkback-Catprqs_.js +0 -1
  399. package/dist/chunks/thinkback-play-CqrIRx2o.js +0 -1
  400. package/dist/chunks/toolPool-B64V-jmK.js +0 -1
  401. package/dist/chunks/trustedDevice-CiwjT_Y6.js +0 -1
  402. package/dist/chunks/undercover-XYapZ_SS.js +0 -1
  403. package/dist/chunks/upgrade-DIg3j929.js +0 -1
  404. package/dist/chunks/usage-CYJKE8N6.js +0 -1
  405. package/dist/chunks/useMainLoopModel-XetDUXd-.js +0 -1
  406. package/dist/chunks/useManagePlugins-B2KhKiu5.js +0 -1
  407. package/dist/chunks/useMergedTools-CKvwz_Zt.js +0 -1
  408. package/dist/chunks/validatePlugin-DtiYlXby.js +0 -1
  409. package/dist/chunks/worktree-DAn8ooa1.js +0 -1
@@ -0,0 +1,68 @@
1
+ import{l as e,o as t,u as n}from"./envUtils-DSxRz_kt.js";import{Gr as r,di as i,t as a,ui as o}from"./src-CDCSSo0U2.js";import{Ca as s,Da as c,Ea as l,Et as u,Oa as d,Qb as f,TC as p,Ta as m,Xb as h,Yb as g,Zb as _,ex as v,jt as ee,nx as te,qb as y,tx as b,vt as x,wC as S,wa as C}from"./loadAgentsDir-x3rlgED4.js";import{C as w,F as T,S as E,a as D,l as O,w as k,z as A}from"./debug-BrXObCdR.js";import{Jt as j,Kt as M,qt as N}from"./settings-BeLFUeie.js";import{M as P,j as F}from"./git-Do0wJvux.js";import{o as I,s as L}from"./log-BMCygSzM.js";import{i as R,n as z,r as B}from"./analytics-BotDBGh0.js";import{T as V,b as H,u as U}from"./startupProfiler-xa3NmN7Z.js";import{_n as W,vn as G}from"./model-CZViyZnE.js";import{n as K,t as q}from"./rcDebugLog-DBB9r8aw.js";import{c as J,d as ne,f as re,n as Y,o as X,r as ie}from"./debugUtils-NO5KtXqi.js";import{n as ae,s as oe}from"./firstPartyEventLogger-BXY1IJ2D.js";import{n as se,t as ce}from"./datadog-DqHxqiwY.js";import{a as le,t as ue}from"./types-Bh9S_JG5.js";import{i as de,n as Z,r as Q}from"./cliLaunch-BkPAatcs.js";import{t as $}from"./lib-BlVGipXx.js";import{t as fe}from"./capacityWake-CV_x9H8j.js";import{t as pe}from"./jwtUtils-DE2GPUcx.js";import{t as me}from"./pollConfig-2nFzv6Hy.js";import{i as he}from"./trustedDevice-CKedohmT.js";import{a as ge,i as _e,n as ve,r as ye,t as be}from"./workSecret-CNWiR2uQ.js";import{hostname as xe,tmpdir as Se}from"os";import{basename as Ce,dirname as we,join as Te,resolve as Ee}from"path";import{createWriteStream as De}from"fs";import{randomUUID as Oe}from"crypto";import{spawn as ke}from"child_process";import{createInterface as Ae}from"readline";t(),A(),E(),F(),I(),z(),H(),W(),p(),ce(),ae(),X(),q(),le(),m(),u(),de(),i();var je=$();j(),a(),D(),v();var Me={type:`utf8`,errorCorrectionLevel:`L`,small:!0};async function Ne(e){return(await(0,je.toString)(e,Me)).split(`
2
+ `).filter(e=>e.length>0)}function Pe(e){let t=e.write??(e=>process.stdout.write(e)),n=e.verbose,i=0,a=`idle`,s=`Ready`,c=``,l=``,u=``,d=``,p=``,m=``,v=null,ee=[],x=!1,S=null,C=0,w=0,T=1,E=null,D=`single-session`,k=new Map,A=null,j=0;function P(e){let t=process.stdout.columns||80,n=0;for(let i of e.split(`
3
+ `)){if(i.length===0){n++;continue}let e=r(i);n+=Math.max(1,Math.ceil(e/t))}return e.endsWith(`
4
+ `)&&n--,n}function F(e){t(e),i+=P(e)}function I(){i<=0||(O(`[bridge:ui] clearStatusLines count=${i}`),t(`\x1b[${i}A`),t(`\x1B[J`),i=0)}function L(e){I(),t(e)}function R(e){Ne(e).then(e=>{ee=e,W()}).catch(e=>{O(`QR code generation failed: ${e}`,{level:`error`})})}function z(){I();let e=N[j%N.length],t=``;c&&(t+=o.dim(` · `)+o.dim(c)),l&&(t+=o.dim(` · `)+o.dim(l)),F(`${o.yellow(e)} ${o.yellow(`Connecting`)}${t}\n`)}function B(){H(),z(),A=setInterval(()=>{j++,z()},150)}function H(){A&&(clearInterval(A),A=null)}function W(){if(a===`reconnecting`||a===`failed`)return;I();let e=a===`idle`;if(x)for(let e of ee)F(`${o.dim(e)}\n`);let t=M,n=e?o.green:o.cyan,r=(e?o.green:o.cyan)(s),i=``;if(c&&(i+=o.dim(` · `)+o.dim(c)),l&&D!==`worktree`&&(i+=o.dim(` · `)+o.dim(l)),process.env.USER_TYPE===`ant`&&u&&F(`${o.yellow(`[ANT-ONLY] Logs:`)} ${o.dim(u)}\n`),F(`${n(t)} ${r}${i}\n`),T>1){let e=D===`worktree`?`New sessions will be created in an isolated worktree`:`New sessions will be created in the current directory`;F(` ${o.dim(`Capacity: ${w}/${T} \u00b7 ${e}`)}\n`);for(let[,e]of k){let t=te(e.title?V(e.title,35):o.dim(`Attached`),e.url),n=e.activity;F(` ${t}${n&&n.type!==`result`&&n.type!==`error`?o.dim(` ${V(n.summary,40)}`):``}
5
+ `)}}if(T===1){let e=D===`single-session`?`Single session · exits when complete`:D===`worktree`?`Capacity: ${w}/1 \u00b7 New sessions will be created in an isolated worktree`:`Capacity: ${w}/1 \u00b7 New sessions will be created in the current directory`;F(` ${o.dim(e)}\n`)}T===1&&!e&&S&&Date.now()-C<3e4&&F(` ${o.dim(V(S,60))}\n`);let p=v??d;if(p){F(`
6
+ `);let t=e?f(p):g(p),n=x?o.dim.italic(`space to hide QR code`):o.dim.italic(`space to show QR code`),r=E?o.dim.italic(` · w to toggle spawn mode`):``;F(`${o.dim(t)}\n`),F(`${n}${r}\n`)}}return{printBanner(e,r){p=e.sessionIngressUrl,m=r,d=h(r,p),R(d),n&&t(o.dim(`Remote Control`)+` v0.0.7
7
+ `),n&&(e.spawnMode!==`single-session`&&(t(o.dim(`Spawn mode: `)+`${e.spawnMode}\n`),t(o.dim(`Max concurrent sessions: `)+`${e.maxSessions}\n`)),t(o.dim(`Environment ID: `)+`${r}\n`)),e.sandbox&&t(o.dim(`Sandbox: `)+`${o.green(`Enabled`)}\n`),t(`
8
+ `),B()},logSessionStart(e,t){if(n){let n=V(t,80);L(o.dim(`[${b()}]`)+` Session started: ${o.white(`"${n}"`)} (${o.dim(e)})\n`)}},logSessionComplete(e,t){L(o.dim(`[${b()}]`)+` Session ${o.green(`completed`)} (${U(t)}) ${o.dim(e)}\n`)},logSessionFailed(e,t){L(o.dim(`[${b()}]`)+` Session ${o.red(`failed`)}: ${t} ${o.dim(e)}\n`)},logStatus(e){L(o.dim(`[${b()}]`)+` ${e}\n`)},logVerbose(e){n&&L(o.dim(`[${b()}] ${e}`)+`
9
+ `)},logError(e){L(o.red(`[${b()}] Error: ${e}`)+`
10
+ `)},logReconnected(e){L(o.dim(`[${b()}]`)+` ${o.green(`Reconnected`)} after ${U(e)}\n`)},setRepoInfo(e,t){c=e,l=t},setDebugLogPath(e){u=e},updateIdleStatus(){H(),a=`idle`,s=`Ready`,S=null,C=0,v=null,R(d),W()},setAttached(e){H(),a=`attached`,s=`Connected`,S=null,C=0,T<=1&&(v=_(e,m,p),R(v)),W()},updateReconnectingStatus(e,t){if(H(),I(),a=`reconnecting`,x)for(let e of ee)F(`${o.dim(e)}\n`);let n=N[j%N.length];j++,F(`${o.yellow(n)} ${o.yellow(`Reconnecting`)} ${o.dim(`·`)} ${o.dim(`retrying in ${e}`)} ${o.dim(`·`)} ${o.dim(`disconnected ${t}`)}\n`)},updateFailedStatus(e){H(),I(),a=`failed`;let t=``;c&&(t+=o.dim(` · `)+o.dim(c)),l&&(t+=o.dim(` · `)+o.dim(l)),F(`${o.red(`×`)} ${o.red(`Remote Control Failed`)}${t}\n`),F(`${o.dim(y)}\n`),e&&F(`${o.red(e)}\n`)},updateSessionStatus(e,t,n,r){n.type===`tool_start`&&(S=n.summary,C=Date.now()),W()},clearStatus(){H(),I()},toggleQr(){x=!x,W()},updateSessionCount(e,t,n){w===e&&T===t&&D===n||(w=e,T=t,D=n)},setSpawnModeDisplay(e){E!==e&&(E=e,e&&(D=e))},addSession(e,t){k.set(e,{url:t})},updateSessionActivity(e,t){let n=k.get(e);n&&(n.activity=t)},setSessionTitle(e,t){let n=k.get(e);n&&(n.title=t,!(a===`reconnecting`||a===`failed`)&&(T===1&&(a=`titled`,s=V(t,40)),W()))},removeSession(e){k.delete(e)},refreshDisplay(){a===`reconnecting`||a===`failed`||W()}}}J();var Fe=10,Ie=10;function Le(e){return e.replace(/[^a-zA-Z0-9_-]/g,`_`)}var Re={Read:`Reading`,Write:`Writing`,Edit:`Editing`,MultiEdit:`Editing`,Bash:`Running`,Glob:`Searching`,Grep:`Searching`,WebFetch:`Fetching`,WebSearch:`Searching`,Task:`Running task`,FileReadTool:`Reading`,FileWriteTool:`Writing`,FileEditTool:`Editing`,GlobTool:`Searching`,GrepTool:`Searching`,BashTool:`Running`,NotebookEditTool:`Editing notebook`,LSP:`LSP`};function ze(e,t){let n=Re[e]??e,r=t.file_path??t.filePath??t.pattern??t.command?.slice(0,60)??t.url??t.query??``;return r?`${n} ${r}`:n}function Be(e,t,n){let r;try{r=w(e)}catch{return[]}if(!r||typeof r!=`object`)return[];let i=r,a=[],o=Date.now();switch(i.type){case`assistant`:{let e=i.message;if(!e)break;let r=e.content;if(!Array.isArray(r))break;for(let e of r){if(!e||typeof e!=`object`)continue;let r=e;if(r.type===`tool_use`){let e=r.name??`Tool`,i=r.input??{},s=ze(e,i);a.push({type:`tool_start`,summary:s,timestamp:o}),n(`[bridge:activity] sessionId=${t} tool_use name=${e} ${He(i)}`)}else if(r.type===`text`){let e=r.text??``;e.length>0&&(a.push({type:`text`,summary:e.slice(0,80),timestamp:o}),n(`[bridge:activity] sessionId=${t} text "${e.slice(0,100)}"`))}}break}case`result`:{let e=i.subtype;if(e===`success`)a.push({type:`result`,summary:`Session completed`,timestamp:o}),n(`[bridge:activity] sessionId=${t} result subtype=success`);else if(e){let r=i.errors?.[0]??`Error: ${e}`;a.push({type:`error`,summary:r,timestamp:o}),n(`[bridge:activity] sessionId=${t} result subtype=${e} error="${r}"`)}else n(`[bridge:activity] sessionId=${t} result subtype=undefined`);break}default:break}return a}function Ve(e){if(e.parent_tool_use_id!=null||e.isSynthetic||e.isReplay)return;let t=e.message?.content,n;if(typeof t==`string`)n=t;else if(Array.isArray(t)){for(let e of t)if(e&&typeof e==`object`&&e.type===`text`){n=e.text;break}}return n=n?.trim(),n||void 0}function He(e){let t=[];for(let[n,r]of Object.entries(e))if(typeof r==`string`&&t.push(`${n}="${r.slice(0,100)}"`),t.length>=3)break;return t.join(` `)}function Ue(e){return{spawn(t,n){let r=Le(t.sessionId),i;if(e.debugFile){let t=e.debugFile.lastIndexOf(`.`);i=t>0?`${e.debugFile.slice(0,t)}-${r}${e.debugFile.slice(t)}`:`${e.debugFile}-${r}`}else(e.verbose||process.env.USER_TYPE===`ant`)&&(i=Te(Se(),`claude`,`bridge-session-${r}.log`));let a=null,o;e.debugFile&&(o=Te(we(e.debugFile),`bridge-transcript-${r}.jsonl`),a=De(o,{flags:`a`}),a.on(`error`,t=>{e.onDebug(`[bridge:session] Transcript write error: ${t.message}`),a=null}),e.onDebug(`[bridge:session] Transcript log: ${o}`));let s=[...e.scriptArgs,`--print`,`--sdk-url`,t.sdkUrl,`--session-id`,t.sessionId,`--input-format`,`stream-json`,`--output-format`,`stream-json`,`--replay-user-messages`,...e.verbose?[`--verbose`]:[],...i?[`--debug-file`,i]:[],...e.permissionMode?[`--permission-mode`,e.permissionMode]:[]],c={...e.env,CLAUDE_CODE_OAUTH_TOKEN:void 0,CLAUDE_CODE_ENVIRONMENT_KIND:`bridge`,...e.sandbox&&{CLAUDE_CODE_FORCE_SANDBOX:`1`},CLAUDE_CODE_SESSION_ACCESS_TOKEN:t.accessToken,CLAUDE_CODE_POST_FOR_SESSION_INGRESS_V2:`1`,...t.useCcrV2&&{CLAUDE_CODE_USE_CCR_V2:`1`,CLAUDE_CODE_WORKER_EPOCH:String(t.workerEpoch)}};e.onDebug(`[bridge:session] Spawning sessionId=${t.sessionId} sdkUrl=${t.sdkUrl} accessToken=${t.accessToken?`present`:`MISSING`}`),e.onDebug(`[bridge:session] Child args: ${s.join(` `)}`),i&&e.onDebug(`[bridge:session] Debug log: ${i}`);let l=ke(e.execPath,s,{cwd:n,stdio:[`pipe`,`pipe`,`pipe`],env:c,windowsHide:!0});e.onDebug(`[bridge:session] sessionId=${t.sessionId} pid=${l.pid}`);let u=[],d=null,f=[],p=!1,m=!1;l.stderr&&Ae({input:l.stderr}).on(`line`,t=>{e.verbose&&process.stderr.write(t+`
11
+ `),f.length>=Ie&&f.shift(),f.push(t)}),l.stdout&&Ae({input:l.stdout}).on(`line`,n=>{a&&a.write(n+`
12
+ `),e.onDebug(`[bridge:ws] sessionId=${t.sessionId} <<< ${Y(n)}`),e.verbose&&process.stderr.write(n+`
13
+ `);let r=Be(n,t.sessionId,e.onDebug);for(let n of r)u.length>=Fe&&u.shift(),u.push(n),d=n,e.onActivity?.(t.sessionId,n);{let r;try{r=w(n)}catch{}if(r&&typeof r==`object`){let n=r;if(n.type===`control_request`)n.request?.subtype===`can_use_tool`&&e.onPermissionRequest&&e.onPermissionRequest(t.sessionId,r,t.accessToken);else if(n.type===`user`&&!m&&t.onFirstUserMessage){let e=Ve(n);e&&(m=!0,t.onFirstUserMessage(e))}}}});let h=new Promise(n=>{l.on(`close`,(r,i)=>{a&&(a.end(),a=null),i===`SIGTERM`||i===`SIGINT`?(e.onDebug(`[bridge:session] sessionId=${t.sessionId} interrupted signal=${i} pid=${l.pid}`),n(`interrupted`)):r===0?(e.onDebug(`[bridge:session] sessionId=${t.sessionId} completed exit_code=0 pid=${l.pid}`),n(`completed`)):(e.onDebug(`[bridge:session] sessionId=${t.sessionId} failed exit_code=${r} pid=${l.pid}`),n(`failed`))}),l.on(`error`,r=>{e.onDebug(`[bridge:session] sessionId=${t.sessionId} spawn error: ${r.message}`),n(`failed`)})}),g={sessionId:t.sessionId,done:h,activities:u,accessToken:t.accessToken,lastStderr:f,get currentActivity(){return d},kill(){l.killed||(e.onDebug(`[bridge:session] Sending SIGTERM to sessionId=${t.sessionId} pid=${l.pid}`),process.platform===`win32`?l.kill():l.kill(`SIGTERM`))},forceKill(){!p&&l.pid&&(p=!0,e.onDebug(`[bridge:session] Sending SIGKILL to sessionId=${t.sessionId} pid=${l.pid}`),process.platform===`win32`?l.kill():l.kill(`SIGKILL`))},writeStdin(n){l.stdin&&!l.stdin.destroyed&&(e.onDebug(`[bridge:ws] sessionId=${t.sessionId} >>> ${Y(n)}`),l.stdin.write(n))},updateAccessToken(n){g.accessToken=n,g.writeStdin(k({type:`update_environment_variables`,variables:{CLAUDE_CODE_SESSION_ACCESS_TOKEN:n}})+`
14
+ `),e.onDebug(`[bridge:session] Sent token refresh via stdin for sessionId=${t.sessionId}`)}};return g}}}D(),v(),X();var We={connInitialMs:2e3,connCapMs:12e4,connGiveUpMs:6e5,generalInitialMs:500,generalCapMs:3e4,generalGiveUpMs:6e5},Ge=1e3,Ke=32;async function qe(){return!1}function Je(e){return e.connCapMs*2}function Ye(){let e=[...Z()],t=Q();return t&&e.push(t),e}function Xe(e,t,n){try{return e.spawn(t,n)}catch(e){let t=T(e);return L(Error(`Session spawn failed: ${t}`)),t}}async function Ze(t,r,i,a,o,u,f,p=We,m,h){let g=new AbortController;f.aborted?g.abort():f.addEventListener(`abort`,()=>g.abort(),{once:!0});let _=g.signal,v=new Map,te=new Map,y=new Map,b=new Map,C=new Map,w=new Map,E=new Set,D=new Map,k=new Set,A=new Set,j=fe(_);async function M(){K(`heartbeat: checking ${v.size} active session(s)`);let e=!1,t=!1,n=[];for(let[i]of v){let o=y.get(i),c=C.get(i);if(!(!o||!c))try{await a.heartbeatWork(r,o,c),e=!0}catch(e){O(`[bridge:heartbeat] Failed for sessionId=${i} workId=${o}: ${T(e)}`),e instanceof s&&(B(`tengu_bridge_heartbeat_error`,{status:e.status,error_type:e.status===401||e.status===403?`auth_failed`:`fatal`}),e.status===401||e.status===403?n.push(i):t=!0)}}for(let e of n){u.logVerbose(`Session ${e} token expired — re-queuing via bridge/reconnect`);try{await a.reconnectSession(r,e),O(`[bridge:heartbeat] Re-queued sessionId=${e} via bridge/reconnect`)}catch(t){u.logError(`Failed to refresh session ${e} token: ${T(t)}`),O(`[bridge:heartbeat] reconnectSession(${e}) failed: ${T(t)}`,{level:`error`})}}return t?`fatal`:n.length>0?`auth_failed`:e?`ok`:`failed`}let N=new Set,F=h?pe({getAccessToken:h,onRefresh:(e,t)=>{let n=v.get(e);n&&(N.has(e)?(u.logVerbose(`Refreshing session ${e} token via bridge/reconnect`),a.reconnectSession(r,e).catch(t=>{u.logError(`Failed to refresh session ${e} token: ${T(t)}`),O(`[bridge:token] reconnectSession(${e}) failed: ${T(t)}`,{level:`error`})})):n.updateAccessToken(t))},label:`bridge`}):null,I=Date.now(),R=new Set;function z(e){R.add(e),e.finally(()=>R.delete(e))}let V=0,H=0,W=null,q=null,J=null,re=null,Y=!1;if(O(`[bridge:work] Starting poll loop spawnMode=${t.spawnMode} maxSessions=${t.maxSessions} environmentId=${r}`),P(`info`,`bridge_loop_started`,{max_sessions:t.maxSessions,spawn_mode:t.spawnMode}),process.env.USER_TYPE===`ant`){let e;if(t.debugFile){let n=t.debugFile.lastIndexOf(`.`);e=n>0?`${t.debugFile.slice(0,n)}-*${t.debugFile.slice(n)}`:`${t.debugFile}-*`}else e=Te(Se(),`claude`,`bridge-session-*.log`);u.setDebugLogPath(e)}u.printBanner(t,r),u.updateSessionCount(0,t.maxSessions,t.spawnMode),m&&u.setAttached(m);function X(){u.updateSessionCount(v.size,t.maxSessions,t.spawnMode);for(let[e,t]of v){let n=t.currentActivity;n&&u.updateSessionActivity(b.get(e)??e,n)}if(v.size===0){u.updateIdleStatus();return}let[e,n]=[...v.entries()].pop(),r=te.get(e);if(!r)return;let i=n.currentActivity;if(!i||i.type===`result`||i.type===`error`){t.maxSessions>1&&u.refreshDisplay();return}let a=U(Date.now()-r),o=n.activities.filter(e=>e.type===`tool_start`).slice(-5).map(e=>e.summary);u.updateSessionStatus(e,a,i,o)}function ae(){oe(),X(),re=setInterval(X,Ge)}function oe(){re&&(clearInterval(re),re=null)}function se(e,n,i){return o=>{let s=y.get(e);K(`session done: sessionId=${e} workId=${s??`none`} status=${o} wasTimedOut=${k.has(e)} duration=${Math.round((Date.now()-n)/1e3)}s stderr=${i.lastStderr.length>0?i.lastStderr.join(`\\n`).slice(0,500):`(none)`}`),v.delete(e),te.delete(e),y.delete(e),C.delete(e);let c=b.get(e)??e;b.delete(e),u.removeSession(c),A.delete(c),N.delete(e);let l=w.get(e);l&&(clearTimeout(l),w.delete(e)),F?.cancel(e),j.wake();let d=k.delete(e),f=d&&o===`interrupted`?`failed`:o,m=Date.now()-n;O(`[bridge:session] sessionId=${e} workId=${s??`unknown`} exited status=${f} duration=${U(m)}`),B(`tengu_bridge_session_done`,{status:f,duration_ms:m}),P(`info`,`bridge_session_done`,{status:f,duration_ms:m}),u.clearStatus(),oe();let h=i.lastStderr.length>0?i.lastStderr.join(`
15
+ `):void 0,x;switch(f){case`completed`:u.logSessionComplete(e,m);break;case`failed`:!d&&!_.aborted&&(x=h??`Process exited with error`,u.logSessionFailed(e,x),L(Error(`Bridge session failed: ${x}`)));break;case`interrupted`:u.logVerbose(`Session ${e} interrupted`);break}f!==`interrupted`&&s&&(z(rt(a,r,s,u,p.stopWorkBaseDelayMs)),E.add(s));let S=D.get(e);if(S&&(D.delete(e),z(ee(S.worktreePath,S.worktreeBranch,S.gitRoot,S.hookBased).catch(e=>u.logVerbose(`Failed to remove worktree ${S.worktreePath}: ${T(e)}`)))),f!==`interrupted`&&!_.aborted)if(t.spawnMode!==`single-session`)z(a.archiveSession(c).catch(t=>u.logVerbose(`Failed to archive session ${e}: ${T(t)}`))),O(`[bridge:session] Session ${f}, returning to idle (multi-session mode)`);else{O(`[bridge:session] Session ${f}, aborting poll loop to tear down environment`),g.abort();return}_.aborted||ae()}}for(m||ae();!_.aborted;){let f=me();try{K(`poll: envId=${r} activeSessions=${v.size}`);let s=await a.pollForWork(r,i,_,f.reclaim_older_than_ms);if(W!==null||q!==null){let e=Date.now()-(W??q??Date.now());u.logReconnected(e),O(`[bridge:poll] Reconnected after ${U(e)}`),B(`tengu_bridge_reconnected`,{disconnected_ms:e})}if(V=0,H=0,W=null,q=null,J=null,!s){if(v.size>=t.maxSessions){let e=f.multisession_poll_interval_ms_at_capacity;if(f.non_exclusive_heartbeat_interval_ms>0){B(`tengu_bridge_heartbeat_mode_entered`,{active_sessions:v.size,heartbeat_interval_ms:f.non_exclusive_heartbeat_interval_ms});let n=e>0?Date.now()+e:null,r=`ok`,i=0;for(;!_.aborted&&v.size>=t.maxSessions&&(n===null||Date.now()<n);){let e=me();if(e.non_exclusive_heartbeat_interval_ms<=0)break;let t=j.signal();if(r=await M(),r===`auth_failed`||r===`fatal`){t.cleanup();break}i++,await G(e.non_exclusive_heartbeat_interval_ms,t.signal),t.cleanup()}let a=r===`auth_failed`||r===`fatal`?r:_.aborted?`shutdown`:v.size<t.maxSessions?`capacity_changed`:n!==null&&Date.now()>=n?`poll_due`:`config_disabled`;if(B(`tengu_bridge_heartbeat_mode_exited`,{reason:a,heartbeat_cycles:i,active_sessions:v.size}),a===`poll_due`&&O(`[bridge:poll] Heartbeat poll_due after ${i} cycles — falling through to pollForWork`),r===`auth_failed`||r===`fatal`){let t=j.signal();await G(e>0?e:f.non_exclusive_heartbeat_interval_ms,t.signal),t.cleanup()}}else if(e>0){let t=j.signal();await G(e,t.signal),t.cleanup()}}else await G(v.size>0?f.multisession_poll_interval_ms_partial_capacity:f.multisession_poll_interval_ms_not_at_capacity,_);continue}let c=v.size>=t.maxSessions;if(E.has(s.id)){if(O(`[bridge:work] Skipping already-completed workId=${s.id}`),c){let e=j.signal();f.non_exclusive_heartbeat_interval_ms>0?(await M(),await G(f.non_exclusive_heartbeat_interval_ms,e.signal)):f.multisession_poll_interval_ms_at_capacity>0&&await G(f.multisession_poll_interval_ms_at_capacity,e.signal),e.cleanup()}else await G(1e3,_);continue}let l;try{l=ye(s.secret)}catch(e){let t=T(e);if(u.logError(`Failed to decode work secret for workId=${s.id}: ${t}`),B(`tengu_bridge_work_secret_failed`,{}),E.add(s.id),z(rt(a,r,s.id,u,p.stopWorkBaseDelayMs)),c){let e=j.signal();f.non_exclusive_heartbeat_interval_ms>0?(await M(),await G(f.non_exclusive_heartbeat_interval_ms,e.signal)):f.multisession_poll_interval_ms_at_capacity>0&&await G(f.multisession_poll_interval_ms_at_capacity,e.signal),e.cleanup()}continue}let h=async()=>{O(`[bridge:work] Acknowledging workId=${s.id}`);try{await a.acknowledgeWork(r,s.id,l.session_ingress_token)}catch(e){O(`[bridge:work] Acknowledge failed workId=${s.id}: ${T(e)}`)}},g=s.data.type;switch(s.data.type){case`healthcheck`:await h(),O(`[bridge:work] Healthcheck received`),u.logVerbose(`Healthcheck received`);break;case`session`:{let i=s.data.id;K(`work received: type=session sessionId=${i} workId=${s.id}`);try{d(i,`session_id`)}catch{await h(),u.logError(`Invalid session_id received: ${i}`);break}let c=v.get(i);if(c){c.updateAccessToken(l.session_ingress_token),C.set(i,l.session_ingress_token),y.set(i,s.id),F?.schedule(i,l.session_ingress_token),O(`[bridge:work] Updated access token for existing sessionId=${i} workId=${s.id}`),await h();break}if(v.size>=t.maxSessions){O(`[bridge:work] At capacity (${v.size}/${t.maxSessions}), cannot spawn new session for workId=${s.id}`);break}await h();let f=Date.now(),g,j=!1,M;if(l.use_code_sessions===!0||e(process.env.CLAUDE_BRIDGE_USE_CCR_V2)){g=be(t.apiBaseUrl,i);for(let e=1;e<=2;e++)try{M=await _e(g,l.session_ingress_token),j=!0,O(`[bridge:session] CCR v2: registered worker sessionId=${i} epoch=${M} attempt=${e}`);break}catch(t){let n=T(t);if(e<2){if(O(`[bridge:session] CCR v2: registerWorker attempt ${e} failed, retrying: ${n}`),await G(2e3,_),_.aborted)break;continue}u.logError(`CCR v2 worker registration failed for session ${i}: ${n}`),L(Error(`registerWorker failed: ${n}`)),E.add(s.id),z(rt(a,r,s.id,u,p.stopWorkBaseDelayMs))}if(!j)break}else g=ve(t.sessionIngressUrl,i);let I=t.spawnMode,R=t.dir,V=0;if(I===`worktree`&&(m===void 0||!ge(i,m))){let e=Date.now();try{let t=await x(`bridge-${Le(i)}`);V=Date.now()-e,D.set(i,{worktreePath:t.worktreePath,worktreeBranch:t.worktreeBranch,gitRoot:t.gitRoot,hookBased:t.hookBased}),R=t.worktreePath,O(`[bridge:session] Created worktree for sessionId=${i} at ${t.worktreePath}`)}catch(e){let t=T(e);u.logError(`Failed to create worktree for session ${i}: ${t}`),L(Error(`Worktree creation failed: ${t}`)),E.add(s.id),z(rt(a,r,s.id,u,p.stopWorkBaseDelayMs));break}}O(`[bridge:session] Spawning sessionId=${i} sdkUrl=${g}`);let H=ne(i);K(`spawning session: sessionId=${i} sdkUrl=${g} useCcrV2=${j} workerEpoch=${M} dir=${R} accessToken=${l.session_ingress_token?l.session_ingress_token.slice(0,8)+`...`:`NONE`}`);let U=Xe(o,{sessionId:i,sdkUrl:g,accessToken:l.session_ingress_token,useCcrV2:j,workerEpoch:M,onFirstUserMessage:e=>{if(A.has(H))return;A.add(H);let n=dt(e);u.setSessionTitle(H,n),O(`[bridge:title] derived title for ${H}: ${n}`),import(`./createSession-CjqxVh_Q.js`).then(({updateBridgeSessionTitle:e})=>e(H,n,{baseUrl:t.apiBaseUrl})).catch(e=>O(`[bridge:title] failed to update title for ${H}: ${e}`,{level:`error`}))}},R);if(typeof U==`string`){u.logError(`Failed to spawn session ${i}: ${U}`);let e=D.get(i);e&&(D.delete(i),z(ee(e.worktreePath,e.worktreeBranch,e.gitRoot,e.hookBased).catch(t=>u.logVerbose(`Failed to remove worktree ${e.worktreePath}: ${T(t)}`)))),E.add(s.id),z(rt(a,r,s.id,u,p.stopWorkBaseDelayMs));break}let W=U,q=Date.now()-f;B(`tengu_bridge_session_started`,{active_sessions:v.size,spawn_mode:I,in_worktree:D.has(i),spawn_duration_ms:q,worktree_create_ms:V,inProtectedNamespace:n()}),P(`info`,`bridge_session_started`,{spawn_mode:I,in_worktree:D.has(i),spawn_duration_ms:q,worktree_create_ms:V}),v.set(i,W),y.set(i,s.id),C.set(i,l.session_ingress_token),b.set(i,H);let J=Date.now();te.set(i,J),u.logSessionStart(i,`Session ${i}`);let re=Le(i),Y;if(t.debugFile){let e=t.debugFile.lastIndexOf(`.`);Y=e>0?`${t.debugFile.slice(0,e)}-${re}${t.debugFile.slice(e)}`:`${t.debugFile}-${re}`}else(t.verbose||process.env.USER_TYPE===`ant`)&&(Y=Te(Se(),`claude`,`bridge-session-${re}.log`));Y&&u.logVerbose(`Debug log: ${Y}`),u.addSession(H,S(H,t.sessionIngressUrl)),ae(),u.setAttached(H),ft(H,t.apiBaseUrl).then(e=>{e&&v.has(i)&&(A.add(H),u.setSessionTitle(H,e),O(`[bridge:title] server title for ${H}: ${e}`))}).catch(e=>O(`[bridge:title] failed to fetch title for ${H}: ${e}`,{level:`error`}));let X=t.sessionTimeoutMs??864e5;if(X>0){let e=setTimeout(it,X,i,X,u,k,W);w.set(i,e)}j&&N.add(i),F?.schedule(i,l.session_ingress_token),W.done.then(se(i,J,W));break}default:await h(),O(`[bridge:work] Unknown work type: ${g}, skipping`);break}if(c){let e=j.signal();f.non_exclusive_heartbeat_interval_ms>0?(await M(),await G(f.non_exclusive_heartbeat_interval_ms,e.signal)):f.multisession_poll_interval_ms_at_capacity>0&&await G(f.multisession_poll_interval_ms_at_capacity,e.signal),e.cleanup()}}catch(e){if(_.aborted)break;if(e instanceof s){Y=!0,l(e.errorType)?u.logStatus(e.message):c(e)?O(`[bridge:work] Suppressed 403 error: ${e.message}`):(u.logError(e.message),L(e)),B(`tengu_bridge_fatal_error`,{status:e.status,error_type:e.errorType}),P(l(e.errorType)?`info`:`error`,`bridge_fatal_error`,{status:e.status,error_type:e.errorType});break}let t=ie(e);if(K(`poll error: ${t} isConn=${$e(e)} isServer=${et(e)} activeSessions=${v.size}`),$e(e)||et(e)){let e=Date.now();J!==null&&e-J>Je(p)&&(O(`[bridge:work] Detected system sleep (${Math.round((e-J)/1e3)}s gap), resetting error budget`),P(`info`,`bridge_poll_sleep_detected`,{gapMs:e-J}),W=null,V=0,q=null,H=0),J=e,W||(W=e);let n=e-W;if(n>=p.connGiveUpMs){u.logError(`Server unreachable for ${Math.round(n/6e4)} minutes, giving up.`),B(`tengu_bridge_poll_give_up`,{error_type:`connection`,elapsed_ms:n}),P(`error`,`bridge_poll_give_up`,{error_type:`connection`,elapsed_ms:n}),Y=!0;break}q=null,H=0,V=V?Math.min(V*2,p.connCapMs):p.connInitialMs;let r=tt(V);u.logVerbose(`Connection error, retrying in ${nt(r)} (${Math.round(n/1e3)}s elapsed): ${t}`),u.updateReconnectingStatus(nt(r),U(n)),me().non_exclusive_heartbeat_interval_ms>0&&await M(),await G(r,_)}else{let e=Date.now();J!==null&&e-J>Je(p)&&(O(`[bridge:work] Detected system sleep (${Math.round((e-J)/1e3)}s gap), resetting error budget`),P(`info`,`bridge_poll_sleep_detected`,{gapMs:e-J}),W=null,V=0,q=null,H=0),J=e,q||(q=e);let n=e-q;if(n>=p.generalGiveUpMs){u.logError(`Persistent errors for ${Math.round(n/6e4)} minutes, giving up.`),B(`tengu_bridge_poll_give_up`,{error_type:`general`,elapsed_ms:n}),P(`error`,`bridge_poll_give_up`,{error_type:`general`,elapsed_ms:n}),Y=!0;break}W=null,V=0,H=H?Math.min(H*2,p.generalCapMs):p.generalInitialMs;let r=tt(H);u.logVerbose(`Poll failed, retrying in ${nt(r)} (${Math.round(n/1e3)}s elapsed): ${t}`),u.updateReconnectingStatus(nt(r),U(n)),me().non_exclusive_heartbeat_interval_ms>0&&await M(),await G(r,_)}}}oe(),u.clearStatus();let ce=Date.now()-I;B(`tengu_bridge_shutdown`,{active_sessions:v.size,loop_duration_ms:ce}),P(`info`,`bridge_shutdown`,{active_sessions:v.size,loop_duration_ms:ce});let le=new Set(v.keys());m&&le.add(m);let ue=new Map(b);if(v.size>0){O(`[bridge:shutdown] Shutting down ${v.size} active session(s)`),u.logStatus(`Shutting down ${v.size} active session(s)\u2026`);let e=new Map(y);for(let[e,t]of v.entries())O(`[bridge:shutdown] Sending SIGTERM to sessionId=${e}`),t.kill();let t=new AbortController;await Promise.race([Promise.allSettled([...v.values()].map(e=>e.done)),G(p.shutdownGraceMs??3e4,t.signal)]),t.abort();for(let[e,t]of v.entries())O(`[bridge:shutdown] Force-killing stuck sessionId=${e}`),t.forceKill();for(let e of w.values())clearTimeout(e);if(w.clear(),F?.cancelAll(),D.size>0){let e=[...D.values()];D.clear(),O(`[bridge:shutdown] Cleaning up ${e.length} worktree(s)`),await Promise.allSettled(e.map(e=>ee(e.worktreePath,e.worktreeBranch,e.gitRoot,e.hookBased)))}await Promise.allSettled([...e.entries()].map(([e,t])=>a.stopWork(r,t,!0).catch(n=>u.logVerbose(`Failed to stop work ${t} for session ${e}: ${T(n)}`))))}if(R.size>0&&await Promise.allSettled([...R]),t.spawnMode===`single-session`&&m&&!Y){u.logStatus("Resume this session by running `claude remote-control --continue`"),O(`[bridge:shutdown] Skipping archive+deregister to allow resume of session ${m}`);return}le.size>0&&(O(`[bridge:shutdown] Archiving ${le.size} session(s)`),await Promise.allSettled([...le].map(e=>a.archiveSession(ue.get(e)??ne(e)).catch(t=>u.logVerbose(`Failed to archive session ${e}: ${T(t)}`)))));try{await a.deregisterEnvironment(r),O(`[bridge:shutdown] Environment deregistered, bridge offline`),u.logVerbose(`Environment deregistered.`)}catch(e){u.logVerbose(`Failed to deregister environment: ${T(e)}`)}let{clearBridgePointer:de}=await import(`./bridgePointer-DqHMHa2B.js`);await de(t.dir),u.logVerbose(`Environment offline.`)}var Qe=new Set([`ECONNREFUSED`,`ECONNRESET`,`ETIMEDOUT`,`ENETUNREACH`,`EHOSTUNREACH`]);function $e(e){return!!(e&&typeof e==`object`&&`code`in e&&typeof e.code==`string`&&Qe.has(e.code))}function et(e){return!!e&&typeof e==`object`&&`code`in e&&typeof e.code==`string`&&e.code===`ERR_BAD_RESPONSE`}function tt(e){return Math.max(0,e+e*.25*(2*Math.random()-1))}function nt(e){return e>=1e3?`${(e/1e3).toFixed(1)}s`:`${Math.round(e)}ms`}async function rt(e,t,n,r,i=1e3){for(let a=1;a<=3;a++)try{await e.stopWork(t,n,!1),O(`[bridge:work] stopWork succeeded for workId=${n} on attempt ${a}/3`);return}catch(e){if(e instanceof s){c(e)?O(`[bridge:work] Suppressed stopWork 403 for ${n}: ${e.message}`):r.logError(`Failed to stop work ${n}: ${e.message}`),P(`error`,`bridge_stop_work_failed`,{attempts:a,fatal:!0});return}let t=T(e);if(a<3){let e=tt(i*2**(a-1));r.logVerbose(`Failed to stop work ${n} (attempt ${a}/3), retrying in ${nt(e)}: ${t}`),await G(e)}else r.logError(`Failed to stop work ${n} after 3 attempts: ${t}`),P(`error`,`bridge_stop_work_failed`,{attempts:3})}}function it(e,t,n,r,i){O(`[bridge:session] sessionId=${e} timed out after ${U(t)}`),B(`tengu_bridge_session_timeout`,{timeout_ms:t}),n.logSessionFailed(e,`Session timed out after ${U(t)}`),r.add(e),i.kill()}var at=[`session`,`same-dir`,`worktree`];function ot(e){return e===`session`?`single-session`:e===`same-dir`?`same-dir`:e===`worktree`?`worktree`:`--spawn requires one of: ${at.join(`, `)} (got: ${e??`<missing>`})`}function st(e){let t=e===void 0?NaN:parseInt(e,10);return isNaN(t)||t<1?`--capacity requires a positive integer (got: ${e??`<missing>`})`:t}function ct(e){let t=!1,n=!1,r,i,a,o,s=!1,c,l,u,d,f=!1;for(let m=0;m<e.length;m++){let h=e[m];if(h===`--help`||h===`-h`)s=!0;else if(h===`--verbose`||h===`-v`)t=!0;else if(h===`--sandbox`)n=!0;else if(h===`--no-sandbox`)n=!1;else if(h===`--debug-file`&&m+1<e.length)r=Ee(e[++m]);else if(h.startsWith(`--debug-file=`))r=Ee(h.slice(13));else if(h===`--session-timeout`&&m+1<e.length)i=parseInt(e[++m],10)*1e3;else if(h.startsWith(`--session-timeout=`))i=parseInt(h.slice(18),10)*1e3;else if(h===`--permission-mode`&&m+1<e.length)a=e[++m];else if(h.startsWith(`--permission-mode=`))a=h.slice(18);else if(h===`--name`&&m+1<e.length)o=e[++m];else if(h.startsWith(`--name=`))o=h.slice(7);else if(h===`--session-id`&&m+1<e.length){if(d=e[++m],!d)return p(`--session-id requires a value`)}else if(h.startsWith(`--session-id=`)){if(d=h.slice(13),!d)return p(`--session-id requires a value`)}else if(h===`--continue`||h===`-c`)f=!0;else if(h===`--spawn`||h.startsWith(`--spawn=`)){if(c!==void 0)return p(`--spawn may only be specified once`);let t=ot(h.startsWith(`--spawn=`)?h.slice(8):e[++m]);if(t===`single-session`||t===`same-dir`||t===`worktree`)c=t;else return p(t)}else if(h===`--capacity`||h.startsWith(`--capacity=`)){if(l!==void 0)return p(`--capacity may only be specified once`);let t=st(h.startsWith(`--capacity=`)?h.slice(11):e[++m]);if(typeof t==`number`)l=t;else return p(t)}else if(h===`--create-session-in-dir`)u=!0;else if(h===`--no-create-session-in-dir`)u=!1;else return p(`Unknown argument: ${h}\nRun 'claude remote-control --help' for usage.`)}if(c===`single-session`&&l!==void 0)return p(`--capacity cannot be used with --spawn=session (single-session mode has fixed capacity 1).`);if((d||f)&&(c!==void 0||l!==void 0||u!==void 0))return p(`--session-id and --continue cannot be used with --spawn, --capacity, or --create-session-in-dir.`);if(d&&f)return p(`--session-id and --continue cannot be used together.`);return{verbose:t,sandbox:n,debugFile:r,sessionTimeoutMs:i,permissionMode:a,name:o,spawnMode:c,capacity:l,createSessionInDir:u,sessionId:d,continueSession:f,help:s};function p(e){return{verbose:t,sandbox:n,debugFile:r,sessionTimeoutMs:i,permissionMode:a,name:o,spawnMode:c,capacity:l,createSessionInDir:u,sessionId:d,continueSession:f,help:s,error:e}}}async function lt(){let{EXTERNAL_PERMISSION_MODES:e}=await import(`./permissions-CeYKbtSC.js`),t=e.join(`, `),n=await qe(),r=`
16
+ Remote Control - Connect your local environment to claude.ai/code
17
+
18
+ USAGE
19
+ claude remote-control [options]
20
+ OPTIONS
21
+ --name <name> Name for the session (shown in claude.ai/code)
22
+ -c, --continue Resume the last session in this directory
23
+ --session-id <id> Resume a specific session by ID (cannot be
24
+ used with spawn flags or --continue)
25
+ --permission-mode <mode> Permission mode for spawned sessions
26
+ (${t})
27
+ --debug-file <path> Write debug logs to file
28
+ -v, --verbose Enable verbose output
29
+ -h, --help Show this help
30
+ ${n?` --spawn <mode> Spawn mode: same-dir, worktree, session
31
+ (default: same-dir)
32
+ --capacity <N> Max concurrent sessions in worktree or
33
+ same-dir mode (default: ${Ke})
34
+ --[no-]create-session-in-dir Pre-create a session in the current
35
+ directory; in worktree mode this session
36
+ stays in cwd while on-demand sessions get
37
+ isolated worktrees (default: on)
38
+ `:``}
39
+ DESCRIPTION
40
+ Remote Control allows you to control sessions on your local device from
41
+ claude.ai/code (https://claude.ai/code). Run this command in the
42
+ directory you want to work in, then connect from the Claude app or web.
43
+ ${n?`
44
+ Remote Control runs as a persistent server that accepts multiple concurrent
45
+ sessions in the current directory. One session is pre-created on start so
46
+ you have somewhere to type immediately. Use --spawn=worktree to isolate
47
+ each on-demand session in its own git worktree, or --spawn=session for
48
+ the classic single-session mode (exits when that session ends). Press 'w'
49
+ during runtime to toggle between same-dir and worktree.
50
+ `:``}
51
+ NOTES
52
+ - You must be logged in with a Claude account that has a subscription
53
+ - Run \`claude\` first in the directory to accept the workspace trust dialog
54
+ ${n?` - Worktree mode requires a git repository or WorktreeCreate/WorktreeRemove hooks
55
+ `:``}`;console.log(r)}var ut=80;function dt(e){return V(e.replace(/\s+/g,` `).trim(),ut)}async function ft(e,t){let{getBridgeSession:n}=await import(`./createSession-CjqxVh_Q.js`);return(await n(e,{baseUrl:t}))?.title||void 0}async function pt(e){let t=ct(e);if(t.help){await lt();return}t.error&&(console.error(`Error: ${t.error}`),process.exit(1));let{verbose:n,sandbox:r,debugFile:i,sessionTimeoutMs:a,permissionMode:o,name:c,spawnMode:l,capacity:u,createSessionInDir:f,sessionId:p,continueSession:m}=t,h=p,g,_=l!==void 0||u!==void 0||f!==void 0;if(o!==void 0){let{PERMISSION_MODES:e}=await import(`./permissions-CeYKbtSC.js`),t=e;t.includes(o)||(console.error(`Error: Invalid permission mode '${o}'. Valid modes: ${t.join(`, `)}`),process.exit(1))}let v=Ee(`.`),{enableConfigs:ee,checkHasTrustDialogAccepted:te}=await import(`./config-CMnqm6Se.js`);ee();let{initSinks:y}=await import(`./sinks-FevoYQqP.js`);y();let b=await qe();_&&!b&&(await R(`tengu_bridge_multi_session_denied`,{used_spawn:l!==void 0,used_capacity:u!==void 0,used_create_session_in_dir:f!==void 0}),await Promise.race([Promise.all([oe(),se()]),G(500,void 0,{unref:!0})]).catch(()=>{}),console.error(`Error: Multi-session Remote Control is not enabled for your account yet.`),process.exit(1));let{setOriginalCwd:x,setCwdState:S}=await import(`./state-BOa-3Av3.js`);x(v),S(v),te()||(console.error(`Error: Workspace not trusted. Please run \`claude\` in ${v} first to review and accept the workspace trust dialog.`),process.exit(1));let{clearOAuthTokenCache:w,checkAndRefreshOAuthTokenIfNeeded:E}=await import(`./auth-D_cGl8WD.js`),{getBridgeAccessToken:D,getBridgeBaseUrl:k}=await import(`./bridgeConfig-DP9dD1Cv.js`);D()||(console.error(ue),process.exit(1));let{getGlobalConfig:A,saveGlobalConfig:j,getCurrentProjectConfig:M,saveCurrentProjectConfig:N}=await import(`./config-CMnqm6Se.js`);if(!A().remoteDialogSeen){let e=(await import(`readline`)).createInterface({input:process.stdin,output:process.stdout});console.log(`
56
+ Remote Control lets you access this CLI session from the web (claude.ai/code)
57
+ or the Claude app, so you can pick up where you left off on any device.
58
+
59
+ You can disconnect remote access anytime by running /remote-control again.
60
+ `);let t=await new Promise(t=>{e.question(`Enable Remote Control? (y/n) `,t)});e.close(),j(e=>e.remoteDialogSeen?e:{...e,remoteDialogSeen:!0}),t.toLowerCase()!==`y`&&t.toLowerCase()!==`yes`&&process.exit(0)}if(m){let{readBridgePointerAcrossWorktrees:e}=await import(`./bridgePointer-DqHMHa2B.js`),t=await e(v);t||(console.error("Error: No recent session found in this directory or its worktrees. Run `claude remote-control` to start a new one."),process.exit(1));let{pointer:n,dir:r}=t,i=Math.round(n.ageMs/6e4),a=i<60?`${i}m`:`${Math.round(i/60)}h`,o=r===v?``:` from worktree ${r}`;console.error(`Resuming session ${n.sessionId} (${a} ago)${o}\u2026`),h=n.sessionId,g=r}let F=k();F.startsWith(`http://`)&&!F.includes(`localhost`)&&!F.includes(`127.0.0.1`)&&(console.error(`Error: Remote Control base URL uses HTTP. Only HTTPS or localhost HTTP is allowed.`),process.exit(1));let I=process.env.CLAUDE_BRIDGE_SESSION_INGRESS_URL||F,{getBranch:z,getRemoteUrl:V,findGitRoot:H}=await import(`./git-CbcnOf0E.js`),{hasWorktreeCreateHook:U}=await import(`./hooks-CBmrBO-J.js`),W=U()||H(v)!==null,K=b?M().remoteControlSpawnMode:void 0;if(K===`worktree`&&!W&&(console.error(`Warning: Saved spawn mode is worktree but this directory is not a git repository. Falling back to same-dir.`),K=void 0,N(e=>e.remoteControlSpawnMode===void 0?e:{...e,remoteControlSpawnMode:void 0})),b&&!K&&W&&l===void 0&&!h&&process.stdin.isTTY){let e=(await import(`readline`)).createInterface({input:process.stdin,output:process.stdout});console.log(`
61
+ Claude Remote Control is launching in spawn mode which lets you create new sessions in this project from Work Mate on Web or your Mobile app. Learn more here: https://code.claude.com/docs/en/remote-control
62
+
63
+ Spawn mode for this project:
64
+ [1] same-dir — sessions share the current directory (default)
65
+ [2] worktree — each session gets an isolated git worktree
66
+
67
+ This can be changed later or explicitly set with --spawn=same-dir or --spawn=worktree.
68
+ `);let t=await new Promise(t=>{e.question(`Choose [1/2] (default: 1): `,t)});e.close();let n=t.trim()===`2`?`worktree`:`same-dir`;K=n,B(`tengu_bridge_spawn_mode_chosen`,{spawn_mode:n}),N(e=>e.remoteControlSpawnMode===n?e:{...e,remoteControlSpawnMode:n})}let q,J;h?(J=`single-session`,q=`resume`):l===void 0?K===void 0?(J=b?`same-dir`:`single-session`,q=`gate_default`):(J=K,q=`saved`):(J=l,q=`flag`);let ne=J===`single-session`?1:u??Ke,Y=f??!0;if(!h){let{clearBridgePointer:e}=await import(`./bridgePointer-DqHMHa2B.js`);await e(v)}J===`worktree`&&!W&&(console.error(`Error: Worktree mode requires a git repository or WorktreeCreate hooks configured. Use --spawn=session for single-session mode.`),process.exit(1));let X=await z(),ie=await V(),ae=xe(),ce=Oe(),{handleOAuth401Error:le}=await import(`./auth-D_cGl8WD.js`),de=C({baseUrl:F,getAccessToken:D,runnerVersion:`0.0.7`,onDebug:O,onAuth401:le,getTrustedDeviceToken:he}),Z;if(h){try{d(h,`sessionId`)}catch{console.error(`Error: Invalid session ID "${h}". Session IDs must not contain unsafe characters.`),process.exit(1)}await E(),w();let{getBridgeSession:e}=await import(`./createSession-CjqxVh_Q.js`),t=await e(h,{baseUrl:F,getAccessToken:D});if(!t){if(g){let{clearBridgePointer:e}=await import(`./bridgePointer-DqHMHa2B.js`);await e(g)}console.error(`Error: Session ${h} not found. It may have been archived or expired.`),process.exit(1)}if(!t.environment_id){if(g){let{clearBridgePointer:e}=await import(`./bridgePointer-DqHMHa2B.js`);await e(g)}console.error(`Error: Session ${h} has no environment_id. It may never have been attached to a bridge.`),process.exit(1)}Z=t.environment_id,O(`[bridge:init] Resuming session ${h} on environment ${Z}`)}let Q={dir:v,machineName:ae,branch:X,gitRepoUrl:ie,maxSessions:ne,spawnMode:J,verbose:n,sandbox:r,bridgeId:ce,workerType:`claude_code`,environmentId:Oe(),reuseEnvironmentId:Z,apiBaseUrl:F,sessionIngressUrl:I,debugFile:i,sessionTimeoutMs:a};O(`[bridge:init] bridgeId=${ce}${Z?` reuseEnvironmentId=${Z}`:``} dir=${v} branch=${X} gitRepoUrl=${ie} machine=${ae}`),O(`[bridge:init] apiBaseUrl=${F} sessionIngressUrl=${I}`),O(`[bridge:init] sandbox=${r}${i?` debugFile=${i}`:``}`);let $,fe;try{let e=await de.registerBridgeEnvironment(Q);$=e.environment_id,fe=e.environment_secret}catch(e){B(`tengu_bridge_registration_failed`,{status:e instanceof s?e.status:void 0}),console.error(e instanceof s&&e.status===404?`Remote Control environments are not available for your account.`:`Error: ${T(e)}`),process.exit(1)}let pe;if(h)if(Z&&$!==Z)L(Error(`Bridge resume env mismatch: requested ${Z}, backend returned ${$}. Falling back to fresh session.`)),console.warn(`Warning: Could not resume session ${h} — its environment has expired. Creating a fresh session instead.`);else{let e=re(h),t=e===h?[h]:[h,e],n=!1,r;for(let e of t)try{await de.reconnectSession($,e),O(`[bridge:init] Session ${e} re-queued via bridge/reconnect`),pe=h,n=!0;break}catch(t){r=t,O(`[bridge:init] reconnectSession(${e}) failed: ${T(t)}`)}if(!n){let e=r,t=e instanceof s;if(g&&t){let{clearBridgePointer:e}=await import(`./bridgePointer-DqHMHa2B.js`);await e(g)}console.error(t?`Error: ${T(e)}`:`Error: Failed to reconnect session ${h}: ${T(e)}\nThe session may still be resumable — try running the same command again.`),process.exit(1)}}O(`[bridge:init] Registered, server environmentId=${$}`);let ge=me();B(`tengu_bridge_started`,{max_sessions:Q.maxSessions,has_debug_file:!!Q.debugFile,sandbox:Q.sandbox,verbose:Q.verbose,heartbeat_interval_ms:ge.non_exclusive_heartbeat_interval_ms,spawn_mode:Q.spawnMode,spawn_mode_source:q,multi_session_gate:b,pre_create_session:Y,worktree_available:W}),P(`info`,`bridge_started`,{max_sessions:Q.maxSessions,sandbox:Q.sandbox,spawn_mode:Q.spawnMode});let _e=Ue({execPath:process.execPath,scriptArgs:Ye(),env:process.env,verbose:n,sandbox:r,debugFile:i,permissionMode:o,onDebug:O,onActivity:(e,t)=>{O(`[bridge:activity] sessionId=${e} ${t.type} ${t.summary}`)},onPermissionRequest:(e,t,n)=>{O(`[bridge:perm] sessionId=${e} tool=${t.request.tool_name} request_id=${t.request_id} (not auto-approving)`)}}),ve=Pe({verbose:n}),{parseGitHubRepository:ye}=await import(`./detectRepository-BTPgN89l.js`),be=ie?ye(ie):null,Se=be?be.split(`/`).pop():Ce(v);ve.setRepoInfo(Se,X);let we=J!==`single-session`&&W;we&&ve.setSpawnModeDisplay(J);let Te=e=>{if(e[0]===3||e[0]===4){process.emit(`SIGINT`);return}if(e[0]===32){ve.toggleQr();return}if(e[0]===119){if(!we)return;let e=Q.spawnMode===`same-dir`?`worktree`:`same-dir`;Q.spawnMode=e,B(`tengu_bridge_spawn_mode_toggled`,{spawn_mode:e}),ve.logStatus(e===`worktree`?`Spawn mode: worktree (new sessions get isolated git worktrees)`:`Spawn mode: same-dir (new sessions share the current directory)`),ve.setSpawnModeDisplay(e),ve.refreshDisplay(),N(t=>t.remoteControlSpawnMode===e?t:{...t,remoteControlSpawnMode:e});return}};process.stdin.isTTY&&(process.stdin.setRawMode(!0),process.stdin.resume(),process.stdin.on(`data`,Te));let De=new AbortController,ke=()=>{O(`[bridge:shutdown] SIGINT received, shutting down`),De.abort()},Ae=()=>{O(`[bridge:shutdown] SIGTERM received, shutting down`),De.abort()};process.on(`SIGINT`,ke),process.on(`SIGTERM`,Ae);let je=pe||null;if(Y&&!pe){let{createBridgeSession:e}=await import(`./createSession-CjqxVh_Q.js`);try{je=await e({environmentId:$,title:c,events:[],gitRepoUrl:ie,branch:X,signal:De.signal,baseUrl:F,getAccessToken:D,permissionMode:o}),je&&O(`[bridge:init] Created initial session ${je}`)}catch(e){O(`[bridge:init] Session creation failed (non-fatal): ${T(e)}`)}}let Me=null;if(je&&J===`single-session`){let{writeBridgePointer:e}=await import(`./bridgePointer-DqHMHa2B.js`),t={sessionId:je,environmentId:$,source:`standalone`};await e(Q.dir,t),Me=setInterval(e,3600*1e3,Q.dir,t),Me.unref?.()}try{await Ze(Q,$,fe,de,_e,ve,De.signal,void 0,je??void 0,async()=>(w(),await E(),D()))}finally{Me!==null&&clearInterval(Me),process.off(`SIGINT`,ke),process.off(`SIGTERM`,Ae),process.stdin.off(`data`,Te),process.stdin.isTTY&&process.stdin.setRawMode(!1),process.stdin.pause()}process.exit(0)}var mt=class extends Error{constructor(e){super(e),this.name=`BridgeHeadlessPermanentError`}};async function ht(e,t){let{dir:n,log:r}=e;process.chdir(n);let{setOriginalCwd:i,setCwdState:a}=await import(`./state-BOa-3Av3.js`);i(n),a(n);let{enableConfigs:o,checkHasTrustDialogAccepted:s}=await import(`./config-CMnqm6Se.js`);o();let{initSinks:c}=await import(`./sinks-FevoYQqP.js`);if(c(),!s())throw new mt(`Workspace not trusted: ${n}. Run \`claude\` in that directory first to accept the trust dialog.`);if(!e.getAccessToken())throw Error(ue);let{getBridgeBaseUrl:l}=await import(`./bridgeConfig-DP9dD1Cv.js`),u=l();if(u.startsWith(`http://`)&&!u.includes(`localhost`)&&!u.includes(`127.0.0.1`))throw new mt(`Remote Control base URL uses HTTP. Only HTTPS or localhost HTTP is allowed.`);let d=process.env.CLAUDE_BRIDGE_SESSION_INGRESS_URL||u,{getBranch:f,getRemoteUrl:p,findGitRoot:m}=await import(`./git-CbcnOf0E.js`),{hasWorktreeCreateHook:h}=await import(`./hooks-CBmrBO-J.js`);if(e.spawnMode===`worktree`&&!(h()||m(n)!==null))throw new mt(`Worktree mode requires a git repository or WorktreeCreate hooks. Directory ${n} has neither.`);let g=await f(),_=await p(),v=xe(),ee=Oe(),te={dir:n,machineName:v,branch:g,gitRepoUrl:_,maxSessions:e.capacity,spawnMode:e.spawnMode,verbose:!1,sandbox:e.sandbox,bridgeId:ee,workerType:`claude_code`,environmentId:Oe(),apiBaseUrl:u,sessionIngressUrl:d,sessionTimeoutMs:e.sessionTimeoutMs},y=C({baseUrl:u,getAccessToken:e.getAccessToken,runnerVersion:`0.0.7`,onDebug:r,onAuth401:e.onAuth401,getTrustedDeviceToken:he}),b,x;try{let e=await y.registerBridgeEnvironment(te);b=e.environment_id,x=e.environment_secret}catch(e){throw Error(`Bridge registration failed: ${T(e)}`)}let S=Ue({execPath:process.execPath,scriptArgs:Ye(),env:process.env,verbose:!1,sandbox:e.sandbox,permissionMode:e.permissionMode,onDebug:r}),w=gt(r);w.printBanner(te,b);let E;if(e.createSessionOnStart){let{createBridgeSession:n}=await import(`./createSession-CjqxVh_Q.js`);try{let i=await n({environmentId:b,title:e.name,events:[],gitRepoUrl:_,branch:g,signal:t,baseUrl:u,getAccessToken:e.getAccessToken,permissionMode:e.permissionMode});i&&(E=i,r(`created initial session ${i}`))}catch(e){r(`session pre-creation failed (non-fatal): ${T(e)}`)}}await Ze(te,b,x,y,S,w,t,void 0,E,async()=>e.getAccessToken())}function gt(e){let t=()=>{};return{printBanner:(t,n)=>e(`registered environmentId=${n} dir=${t.dir} spawnMode=${t.spawnMode} capacity=${t.maxSessions}`),logSessionStart:(t,n)=>e(`session start ${t}`),logSessionComplete:(t,n)=>e(`session complete ${t} (${n}ms)`),logSessionFailed:(t,n)=>e(`session failed ${t}: ${n}`),logStatus:e,logVerbose:e,logError:t=>e(`error: ${t}`),logReconnected:t=>e(`reconnected after ${t}ms`),addSession:(t,n)=>e(`session attached ${t}`),removeSession:t=>e(`session detached ${t}`),updateIdleStatus:t,updateReconnectingStatus:t,updateSessionStatus:t,updateSessionActivity:t,updateSessionCount:t,updateFailedStatus:t,setSpawnModeDisplay:t,setRepoInfo:t,setDebugLogPath:t,setAttached:t,setSessionTitle:t,clearStatus:t,toggleQr:t,refreshDisplay:t}}export{ct as a,et as i,pt as n,ht as o,$e as r,Ze as s,mt as t};
@@ -1 +1 @@
1
- import{n as e,t}from"./defineProperty-C-QyHrDq.js";import{C as n,F as r,S as i,a,l as o,z as s}from"./debug-BrXObCdR.js";import{B as c,F as l,G as u,I as d,O as f,U as p,Y as m,b as h,g,m as _}from"./log-BMCygSzM.js";import{n as v,r as y}from"./analytics-BotDBGh0.js";import{P as b,lt as x,n as S,t as C}from"./rcDebugLog-CUy1_F23.js";import{t as w}from"./controlMessageCompat-IFu4Gc1y.js";import{randomUUID as T}from"crypto";v(),b(),a(),C(),_(),s(),i(),m(),e();function E(e){return typeof e==`object`&&!!e&&`type`in e&&typeof e.type==`string`}function D(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`control_response`&&`response`in e}function O(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`control_request`&&`request_id`in e&&`request`in e}function k(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 A(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 g(n)||void 0}var j=`system-reminder`,M=/\s*<([a-z][\w-]*)(?:\s[^>]*)?>[\s\S]*?<\/\1>\s*/gy,N=new Set([h,f,l,d,c,p,u]);function P(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 F(e){let t=e.trim();if(!t)return null;M.lastIndex=0;let n=[];for(;M.lastIndex<t.length;){let e=M.exec(t);if(!e)return null;n.push(e[1])}return n.length>0?n:null}function I(e){if(e.type!==`user`||e.isVisibleInTranscriptOnly)return!1;if(e.toolUseResult!==void 0||!e.isMeta)return!0;let t=F(P(e));return!t||t.some(e=>e!==`local-command-caveat`&&e!==j&&N.has(e))}function L(e){return e.some(I)}function R(e,t,i,a,s,c){try{let r=w(n(e));if(D(r)){o(`[bridge:repl] Ingress message type=control_response`),s?.(r);return}if(O(r)){o(`[bridge:repl] Inbound control_request subtype=${r.request.subtype}`),c?.(r);return}if(!E(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&&i.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&&i.add(l),y(`tengu_bridge_message_received`,{is_repl:!0}),a?.(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 z=`This session is outbound-only. Enable Remote Control locally to allow inbound control.`;function B(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:z}};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 V(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 H=class{constructor(e){t(this,`capacity`,void 0),t(this,`ring`,void 0),t(this,`set`,new Set),t(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{k as a,L as c,B as i,A as n,V as o,R as r,I as s,H as t};
1
+ import{n as e,t}from"./defineProperty-C-QyHrDq.js";import{C as n,F as r,S as i,a,l as o,z as s}from"./debug-BrXObCdR.js";import{B as c,F as l,G as u,I as d,O as f,U as p,Y as m,b as h,g,m as _}from"./log-BMCygSzM.js";import{n as v,r as y}from"./analytics-BotDBGh0.js";import{P as b,lt as x,n as S,t as C}from"./rcDebugLog-DBB9r8aw.js";import{t as w}from"./controlMessageCompat-IFu4Gc1y.js";import{randomUUID as T}from"crypto";v(),b(),a(),C(),_(),s(),i(),m(),e();function E(e){return typeof e==`object`&&!!e&&`type`in e&&typeof e.type==`string`}function D(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`control_response`&&`response`in e}function O(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`control_request`&&`request_id`in e&&`request`in e}function k(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 A(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 g(n)||void 0}var j=`system-reminder`,M=/\s*<([a-z][\w-]*)(?:\s[^>]*)?>[\s\S]*?<\/\1>\s*/gy,N=new Set([h,f,l,d,c,p,u]);function P(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 F(e){let t=e.trim();if(!t)return null;M.lastIndex=0;let n=[];for(;M.lastIndex<t.length;){let e=M.exec(t);if(!e)return null;n.push(e[1])}return n.length>0?n:null}function I(e){if(e.type!==`user`||e.isVisibleInTranscriptOnly)return!1;if(e.toolUseResult!==void 0||!e.isMeta)return!0;let t=F(P(e));return!t||t.some(e=>e!==`local-command-caveat`&&e!==j&&N.has(e))}function L(e){return e.some(I)}function R(e,t,i,a,s,c){try{let r=w(n(e));if(D(r)){o(`[bridge:repl] Ingress message type=control_response`),s?.(r);return}if(O(r)){o(`[bridge:repl] Inbound control_request subtype=${r.request.subtype}`),c?.(r);return}if(!E(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&&i.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&&i.add(l),y(`tengu_bridge_message_received`,{is_repl:!0}),a?.(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 z=`This session is outbound-only. Enable Remote Control locally to allow inbound control.`;function B(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:z}};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 V(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 H=class{constructor(e){t(this,`capacity`,void 0),t(this,`ring`,void 0),t(this,`set`,new Set),t(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{k as a,L as c,B as i,A as n,V as o,R as r,I as s,H as t};
@@ -1 +1 @@
1
- import{E as e,M as t,d as n,n as r,r as i,t as a}from"./lazySchema-DcIJE_0i.js";import{C as o,S as s,V as c,a as l,l as u,w as d,z as f}from"./debug-BrXObCdR.js";import{_ as p,c as m,g as h,l as g,m as _}from"./sessionStoragePortable-Cx6JQ5Ye.js";import{dirname as v,join as y}from"path";import{mkdir as b,readFile as x,stat as S,unlink as C,writeFile as w}from"fs/promises";i(),l(),f(),p(),a(),g(),s();var T=50,E=r(()=>e({sessionId:t(),environmentId:t(),source:n([`standalone`,`repl`])}));function D(e){return y(m(),_(e),`bridge-pointer.json`)}async function O(e,t){let n=D(e);try{await b(v(n),{recursive:!0}),await w(n,d(t),`utf8`),u(`[bridge:pointer] wrote ${n}`)}catch(e){u(`[bridge:pointer] write failed: ${e}`,{level:`warn`})}}async function k(e){let t=D(e),n,r;try{r=(await S(t)).mtimeMs,n=await x(t,`utf8`)}catch{return null}let i=E().safeParse(M(n));if(!i.success)return u(`[bridge:pointer] invalid schema, clearing: ${t}`),await j(e),null;let a=Math.max(0,Date.now()-r);return a>144e5?(u(`[bridge:pointer] stale (>4h mtime), clearing: ${t}`),await j(e),null):{...i.data,ageMs:a}}async function A(e){let t=await k(e);if(t)return{pointer:t,dir:e};let n=await h(e);if(n.length<=1)return null;if(n.length>T)return u(`[bridge:pointer] ${n.length} worktrees exceeds fanout cap ${T}, skipping`),null;let r=_(e),i=n.filter(e=>_(e)!==r),a=await Promise.all(i.map(async e=>{let t=await k(e);return t?{pointer:t,dir:e}:null})),o=null;for(let e of a)e&&(!o||e.pointer.ageMs<o.pointer.ageMs)&&(o=e);return o&&u(`[bridge:pointer] fanout found pointer in worktree ${o.dir} (ageMs=${o.pointer.ageMs})`),o}async function j(e){let t=D(e);try{await C(t),u(`[bridge:pointer] cleared ${t}`)}catch(e){c(e)||u(`[bridge:pointer] clear failed: ${e}`,{level:`warn`})}}function M(e){try{return o(e)}catch{return null}}export{j as clearBridgePointer,k as readBridgePointer,A as readBridgePointerAcrossWorktrees,O as writeBridgePointer};
1
+ import{D as e,N as t,f as n,n as r,r as i,t as a}from"./lazySchema-DULtBUCI.js";import{C as o,S as s,V as c,a as l,l as u,w as d,z as f}from"./debug-BrXObCdR.js";import{_ as p,c as m,g as h,l as g,m as _}from"./sessionStoragePortable-Cx6JQ5Ye.js";import{dirname as v,join as y}from"path";import{mkdir as b,readFile as x,stat as S,unlink as C,writeFile as w}from"fs/promises";i(),l(),f(),p(),a(),g(),s();var T=50,E=r(()=>e({sessionId:t(),environmentId:t(),source:n([`standalone`,`repl`])}));function D(e){return y(m(),_(e),`bridge-pointer.json`)}async function O(e,t){let n=D(e);try{await b(v(n),{recursive:!0}),await w(n,d(t),`utf8`),u(`[bridge:pointer] wrote ${n}`)}catch(e){u(`[bridge:pointer] write failed: ${e}`,{level:`warn`})}}async function k(e){let t=D(e),n,r;try{r=(await S(t)).mtimeMs,n=await x(t,`utf8`)}catch{return null}let i=E().safeParse(M(n));if(!i.success)return u(`[bridge:pointer] invalid schema, clearing: ${t}`),await j(e),null;let a=Math.max(0,Date.now()-r);return a>144e5?(u(`[bridge:pointer] stale (>4h mtime), clearing: ${t}`),await j(e),null):{...i.data,ageMs:a}}async function A(e){let t=await k(e);if(t)return{pointer:t,dir:e};let n=await h(e);if(n.length<=1)return null;if(n.length>T)return u(`[bridge:pointer] ${n.length} worktrees exceeds fanout cap ${T}, skipping`),null;let r=_(e),i=n.filter(e=>_(e)!==r),a=await Promise.all(i.map(async e=>{let t=await k(e);return t?{pointer:t,dir:e}:null})),o=null;for(let e of a)e&&(!o||e.pointer.ageMs<o.pointer.ageMs)&&(o=e);return o&&u(`[bridge:pointer] fanout found pointer in worktree ${o.dir} (ageMs=${o.pointer.ageMs})`),o}async function j(e){let t=D(e);try{await C(t),u(`[bridge:pointer] cleared ${t}`)}catch(e){c(e)||u(`[bridge:pointer] clear failed: ${e}`,{level:`warn`})}}function M(e){try{return o(e)}catch{return null}}export{j as clearBridgePointer,k as readBridgePointer,A as readBridgePointerAcrossWorktrees,O as writeBridgePointer};
@@ -1 +1 @@
1
- import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{I as n,P as r,bn as i,fi as a,ot as o,t as s,vn as c,xt as l}from"./src-CDCSSo0U2.js";import{t as u}from"./jsx-runtime-Bb4Xn-E0.js";import{Al as d,Ao as f,Bb as p,Gw as m,ME as h,NE as g,Vb as _,Ww as v,ZT as y,aC as b,jE as x,kl as S,lh as C,lt as w,sh as T,ut as E,zo as D}from"./loadAgentsDir-D206qwP3.js";import{F as O,z as k}from"./debug-BrXObCdR.js";import{Kt as A}from"./settings-BovzmwMP.js";import{b as j,g as M}from"./config-DmomySWC.js";import{st as N}from"./rcDebugLog-CUy1_F23.js";import{n as P,r as F}from"./sideQuestion-wSi38p81.js";import{i as I,n as L}from"./modalContext-DFjKLCB6.js";function R({question:e,context:t,onDone:a}){let[s,c]=(0,H.useState)(null),[u,d]=(0,H.useState)(null),[f,m]=(0,H.useState)(0),h=(0,H.useRef)(null),{rows:g}=I(o());i(()=>m(e=>e+1),s||u?null:80);function _(e){if(e.key===`escape`||e.key===`return`||e.key===` `||e.ctrl&&(e.key===`c`||e.key===`d`)){e.preventDefault(),a(void 0,{display:`skip`});return}(e.key===`up`||e.ctrl&&e.key===`p`)&&(e.preventDefault(),h.current?.scrollBy(-3)),(e.key===`down`||e.ctrl&&e.key===`n`)&&(e.preventDefault(),h.current?.scrollBy(K))}(0,H.useEffect)(()=>{let n=v();async function r(){try{let r=await F({question:e,cacheSafeParams:await B(t)});n.signal.aborted||(r.response?c(r.response):d(`No response received`))}catch(e){n.signal.aborted||d(O(e)||`Failed to get response`)}}return r(),()=>{n.abort()}},[e,t]);let y=Math.max(5,g-W-G);return(0,U.jsxs)(n,{flexDirection:`column`,paddingLeft:2,marginTop:1,tabIndex:0,autoFocus:!0,onKeyDown:_,children:[(0,U.jsxs)(n,{children:[(0,U.jsxs)(r,{color:`warning`,bold:!0,children:[`/btw`,` `]}),(0,U.jsx)(r,{dimColor:!0,children:e})]}),(0,U.jsx)(n,{marginTop:1,marginLeft:2,maxHeight:y,children:(0,U.jsx)(l,{ref:h,flexDirection:`column`,flexGrow:1,children:u?(0,U.jsx)(r,{color:`error`,children:u}):s?(0,U.jsx)(T,{children:s}):(0,U.jsxs)(n,{children:[(0,U.jsx)(p,{frame:f,messageColor:`warning`}),(0,U.jsx)(r,{color:`warning`,children:`Answering...`})]})})}),(s||u)&&(0,U.jsx)(n,{marginTop:1,children:(0,U.jsxs)(r,{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=f(z(e.messages)),n=S();if(n)return{systemPrompt:n.systemPrompt,userContext:n.userContext,systemContext:n.systemContext,toolUseContext:e,forkContextMessages:t};let[r,i,a]=await Promise.all([w(e.options.tools,e.options.mainLoopModel,[],e.options.mcpClients),h(),x()]);return{systemPrompt:N(r),userContext:i,systemContext:a,toolUseContext:e,forkContextMessages:t}}async function V(e,t,n){let r=n?.trim();return r?(j(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((()=>{a(),H=t(a(),1),c(),C(),_(),A(),E(),L(),g(),b(),s(),m(),M(),k(),d(),D(),P(),y(),U=u(),W=5,G=6,K=3}))();export{V as call};
1
+ import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{I as n,P as r,bn as i,fi as a,ot as o,t as s,vn as c,xt as l}from"./src-CDCSSo0U2.js";import{t as u}from"./jsx-runtime-Bb4Xn-E0.js";import{CE as d,Cl as f,Co as p,Fw as m,HT as h,Iw as g,Mb as _,Mo as v,SE as y,Sl as b,XS as x,eh as S,jb as C,lt as w,nh as T,ut as E,wE as D}from"./loadAgentsDir-x3rlgED4.js";import{F as O,z as k}from"./debug-BrXObCdR.js";import{Jt as A}from"./settings-BeLFUeie.js";import{b as j,g as M}from"./config-DRDuVyzE.js";import{st as N}from"./rcDebugLog-DBB9r8aw.js";import{n as P,r as F}from"./sideQuestion-hUhxls9r.js";import{i as I,n as L}from"./modalContext-DFjKLCB6.js";function R({question:e,context:t,onDone:a}){let[s,c]=(0,H.useState)(null),[u,d]=(0,H.useState)(null),[f,p]=(0,H.useState)(0),h=(0,H.useRef)(null),{rows:g}=I(o());i(()=>p(e=>e+1),s||u?null:80);function _(e){if(e.key===`escape`||e.key===`return`||e.key===` `||e.ctrl&&(e.key===`c`||e.key===`d`)){e.preventDefault(),a(void 0,{display:`skip`});return}(e.key===`up`||e.ctrl&&e.key===`p`)&&(e.preventDefault(),h.current?.scrollBy(-3)),(e.key===`down`||e.ctrl&&e.key===`n`)&&(e.preventDefault(),h.current?.scrollBy(K))}(0,H.useEffect)(()=>{let n=m();async function r(){try{let r=await F({question:e,cacheSafeParams:await B(t)});n.signal.aborted||(r.response?c(r.response):d(`No response received`))}catch(e){n.signal.aborted||d(O(e)||`Failed to get response`)}}return r(),()=>{n.abort()}},[e,t]);let v=Math.max(5,g-W-G);return(0,U.jsxs)(n,{flexDirection:`column`,paddingLeft:2,marginTop:1,tabIndex:0,autoFocus:!0,onKeyDown:_,children:[(0,U.jsxs)(n,{children:[(0,U.jsxs)(r,{color:`warning`,bold:!0,children:[`/btw`,` `]}),(0,U.jsx)(r,{dimColor:!0,children:e})]}),(0,U.jsx)(n,{marginTop:1,marginLeft:2,maxHeight:v,children:(0,U.jsx)(l,{ref:h,flexDirection:`column`,flexGrow:1,children:u?(0,U.jsx)(r,{color:`error`,children:u}):s?(0,U.jsx)(S,{children:s}):(0,U.jsxs)(n,{children:[(0,U.jsx)(C,{frame:f,messageColor:`warning`}),(0,U.jsx)(r,{color:`warning`,children:`Answering...`})]})})}),(s||u)&&(0,U.jsx)(n,{marginTop:1,children:(0,U.jsxs)(r,{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=p(z(e.messages)),n=b();if(n)return{systemPrompt:n.systemPrompt,userContext:n.userContext,systemContext:n.systemContext,toolUseContext:e,forkContextMessages:t};let[r,i,a]=await Promise.all([w(e.options.tools,e.options.mainLoopModel,[],e.options.mcpClients),d(),y()]);return{systemPrompt:N(r),userContext:i,systemContext:a,toolUseContext:e,forkContextMessages:t}}async function V(e,t,n){let r=n?.trim();return r?(j(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((()=>{a(),H=t(a(),1),c(),T(),_(),A(),E(),L(),D(),x(),s(),g(),M(),k(),f(),v(),P(),h(),U=u(),W=5,G=6,K=3}))();export{V as call};
@@ -1,3 +1,3 @@
1
- import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{n,t as r}from"./defineProperty-C-QyHrDq.js";import{m as i}from"./zod-CuNujUwx.js";import{Sr as a,en as o,l as s,xr as c,zn as l}from"./state-ix0xIunV.js";import{AE as u,Ac as d,Cm as f,Db as ee,Eb as p,Ep as m,Ft as h,GE as g,HE as _,Jw as v,Kp as y,Kw as b,ME as x,NE as te,Ox as ne,PE as re,Qi as ie,Sp as ae,VE as oe,Vi as se,Vt as ce,WE as le,Y as ue,Z as de,_ as fe,_l as pe,eD as me,g as he,hl as ge,jE as _e,kc as ve,kx as ye,nD as be,p as xe,qp as Se,wm as Ce,yn as we}from"./loadAgentsDir-D206qwP3.js";import{n as Te,t as S}from"./cwd-CYmmnQVS.js";import{F as Ee,a as De,d as Oe,l as C,p as ke,z as Ae}from"./debug-BrXObCdR.js";import{g as je,n as Me}from"./settings-BovzmwMP.js";import{c as Ne,g as Pe}from"./config-DmomySWC.js";import{T as Fe,_ as Ie,g as Le,r as w,x as Re}from"./git-Do0wJvux.js";import{n as T,r as ze}from"./execFileNoThrow-D244NytW.js";import{o as Be,s as E}from"./log-BMCygSzM.js";import{i as Ve,n as He}from"./path-D5U-tm91.js";import{n as Ue,r as D}from"./analytics-BotDBGh0.js";import{a as We,s as Ge}from"./ripgrep-BXmXjAzA.js";import{i as Ke,t as qe}from"./detectRepository-BPr0VWNO.js";import{r as Je,t as Ye}from"./magicDocs-DWjL2k7P.js";import*as O from"path";import{statSync as Xe}from"fs";function Ze(e,t,n){if(t===0)return n?A:0;let r=e.charCodeAt(t-1);return Qe(r)?rt:$e(r)&&et(e.charCodeAt(t))?it:0}function Qe(e){return e===47||e===92||e===45||e===95||e===46||e===32}function $e(e){return e>=97&&e<=122}function et(e){return e>=65&&e<=90}function k(){return new Promise(e=>setImmediate(e))}function tt(e,t){let n=new Set;for(let r of e){let e=r.length;for(let t=0;t<r.length;t++){let n=r.charCodeAt(t);if(n===47||n===92){e=t;break}}let i=r.slice(0,e);if(i.length>0&&(n.add(i),n.size>=t))break}let r=Array.from(n);return r.sort((e,t)=>{let n=e.length-t.length;return n===0?e<t?-1:+(e>t):n}),r.slice(0,t).map(e=>({path:e,score:0}))}var nt,rt,it,at,A,ot,j,M,N,P,st,ct=e((()=>{n(),nt=16,rt=8,it=6,at=4,A=8,ot=3,j=1,M=100,N=64,P=new Int32Array(N),st=class{constructor(){r(this,`paths`,[]),r(this,`lowerPaths`,[]),r(this,`charBits`,new Int32Array),r(this,`pathLens`,new Uint16Array),r(this,`topLevelCache`,null),r(this,`readyCount`,0)}loadFromFileList(e){let t=new Set,n=[];for(let r of e)r.length>0&&!t.has(r)&&(t.add(r),n.push(r));this.buildIndex(n)}loadFromFileListAsync(e){let t=()=>{};return{queryable:new Promise(e=>{t=e}),done:this.buildAsync(e,t)}}async buildAsync(e,t){let n=new Set,r=[],i=performance.now();for(let t=0;t<e.length;t++){let a=e[t];a.length>0&&!n.has(a)&&(n.add(a),r.push(a)),(t&255)==255&&performance.now()-i>4&&(await k(),i=performance.now())}this.resetArrays(r),i=performance.now();let a=!0;for(let e=0;e<r.length;e++)this.indexPath(e),(e&255)==255&&performance.now()-i>4&&(this.readyCount=e+1,a&&(t(),a=!1),await k(),i=performance.now());this.readyCount=r.length,t()}buildIndex(e){this.resetArrays(e);for(let t=0;t<e.length;t++)this.indexPath(t);this.readyCount=e.length}resetArrays(e){let t=e.length;this.paths=e,this.lowerPaths=Array(t),this.charBits=new Int32Array(t),this.pathLens=new Uint16Array(t),this.readyCount=0,this.topLevelCache=tt(e,M)}indexPath(e){let t=this.paths[e].toLowerCase();this.lowerPaths[e]=t;let n=t.length;this.pathLens[e]=n;let r=0;for(let e=0;e<n;e++){let n=t.charCodeAt(e);n>=97&&n<=122&&(r|=1<<n-97)}this.charBits[e]=r}search(e,t){if(t<=0)return[];if(e.length===0)return this.topLevelCache?this.topLevelCache.slice(0,t):[];let n=e!==e.toLowerCase(),r=n?e:e.toLowerCase(),i=Math.min(r.length,N),a=Array(i),o=0;for(let e=0;e<i;e++){let t=r.charAt(e);a[e]=t;let n=t.charCodeAt(0);n>=97&&n<=122&&(o|=1<<n-97)}let s=i*24+A+32,c=[],l=-1/0,{paths:u,lowerPaths:d,charBits:f,pathLens:ee,readyCount:p}=this;for(let e=0;e<p;e++){if((f[e]&o)!==o)continue;let r=n?u[e]:d[e],p=a[0],m=0,h=[],g=r.indexOf(p);if(g===-1)continue;h[m++]=g;for(let e=g+1;e<r.length;e++){if(r.charCodeAt(e)!==p.charCodeAt(0))continue;let t=r.charCodeAt(e-1);(t===47||t===92||t===45||t===95||t===46||t===32)&&(h[m++]=e)}let _=u[e],v=ee[e],y=Math.max(0,32-(v>>2)),b=-1/0;for(let e=0;e<m;e++){P[0]=h[e];let n=0,o=0,u=P[0],d=!0;for(let e=1;e<i;e++){let t=r.indexOf(a[e],u+1);if(t===-1){d=!1;break}P[e]=t;let i=t-u-1;i===0?o+=at:n+=ot+i*j,u=t}if(!d||c.length===t&&s+o-n+y<=l)continue;let f=i*nt+o-n;f+=Ze(_,P[0],!0);for(let e=1;e<i;e++)f+=Ze(_,P[e],!1);f+=y,f>b&&(b=f)}if(b===-1/0)continue;let x=b;if(c.length<t)c.push({path:_,fuzzScore:x}),c.length===t&&(c.sort((e,t)=>e.fuzzScore-t.fuzzScore),l=c[0].fuzzScore);else if(x>l){let e=0,t=c.length;for(;e<t;){let n=e+t>>1;c[n].fuzzScore<x?e=n+1:t=n}c.splice(e,0,{path:_,fuzzScore:x}),c.shift(),l=c[0].fuzzScore}}c.sort((e,t)=>t.fuzzScore-e.fuzzScore);let m=c.length,h=Math.max(m,1),g=Array(m);for(let e=0;e<m;e++){let t=c[e].path,n=e/h;g[e]={path:t,score:t.includes(`test`)?Math.min(n*1.05,1):n}}return g}}}));function F(){return R||(R=new st),R}function lt(){R=null,z=null,V++,H=null,U=[],W=[],G=[],B.clear(),K=null,q=null,J=0,Y=null,X=null,Z=null}function ut(e){let t=e.length,n=Math.max(1,Math.floor(t/500)),r=-2128831035;for(let i=0;i<t;i+=n){let t=e[i];for(let e=0;e<t.length;e++)r=(r^t.charCodeAt(e))*16777619|0;r=r*16777619|0}if(t>0){let n=e[t-1];for(let e=0;e<n.length;e++)r=(r^n.charCodeAt(e))*16777619|0}return`${t}:${(r>>>0).toString(16)}`}function dt(){let e=w(S());if(!e)return null;try{return Xe(O.join(e,`.git`,`index`)).mtimeMs}catch{return null}}function ft(e,t,n){return n===t?e:e.map(e=>{let r=O.join(t,e);return O.relative(n,r)})}async function pt(e){if(e.length===0||!R||U.length===0)return;let t=await gt(e),n=[...U,...W,...G,...e,...t],r=ut(n);if(r===Z){C(`[FileIndex] skipped index rebuild — merged paths unchanged`);return}await R.loadFromFileListAsync(n).done,Z=r,C(`[FileIndex] rebuilt index with ${U.length} tracked + ${e.length} untracked files`)}async function mt(e,t){let n=`${e}:${t}`;if(q===n)return K;let r=Oe(),i=[`.ignore`,`.rgignore`],a=[...new Set([e,t])],o=(0,Dt.default)(),s=!1,c=a.flatMap(e=>i.map(t=>O.join(e,t))),l=await Promise.all(c.map(e=>r.readFile(e,{encoding:`utf8`}).catch(()=>null)));for(let[e,t]of l.entries())t!==null&&(o.add(t),s=!0,C(`[FileIndex] loaded ignore patterns from ${c[e]}`));let u=s?o:null;return K=u,q=n,u}async function ht(e,t){let n=Date.now();C(`[FileIndex] getFilesUsingGit called`);let r=S(),i=w(r);if(!i)return C(`[FileIndex] not a git repo, returning null`),null;try{let a=Date.now(),o=await T(Le(),[`-c`,`core.quotepath=false`,`ls-files`,`--recurse-submodules`],{timeout:5e3,abortSignal:e,cwd:i});if(C(`[FileIndex] git ls-files (tracked) took ${Date.now()-a}ms`),o.code!==0)return C(`[FileIndex] git ls-files failed (code=${o.code}, stderr=${o.stderr}), falling back to ripgrep`),null;let s=ft(o.stdout.trim().split(`
1
+ import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{n,t as r}from"./defineProperty-C-QyHrDq.js";import{m as i}from"./zod-CuNujUwx.js";import{Sr as a,en as o,l as s,xr as c,zn as l}from"./state-ix0xIunV.js";import{Bp as u,CE as d,Cc as f,FE as ee,Ft as p,GE as m,IE as h,Lw as g,ME as _,NE as v,Qi as y,SE as b,Sc as x,TE as te,Vi as ne,Vt as re,Y as ie,Z as ae,_ as oe,_b as se,_m as ce,bx as le,cl as ue,g as de,gm as fe,hp as pe,p as me,qE as he,ul as ge,vb as _e,wE as ve,xE as ye,yn as be,yp as xe,yx as Se,zp as Ce,zw as we}from"./loadAgentsDir-x3rlgED4.js";import{n as Te,t as S}from"./cwd-CYmmnQVS.js";import{F as Ee,a as De,d as Oe,l as C,p as ke,z as Ae}from"./debug-BrXObCdR.js";import{g as je,n as Me}from"./settings-BeLFUeie.js";import{c as Ne,g as Pe}from"./config-DRDuVyzE.js";import{T as Fe,_ as Ie,g as Le,r as w,x as Re}from"./git-Do0wJvux.js";import{n as T,r as ze}from"./execFileNoThrow-D244NytW.js";import{o as Be,s as E}from"./log-BMCygSzM.js";import{i as Ve,n as He}from"./path-D5U-tm91.js";import{n as Ue,r as D}from"./analytics-BotDBGh0.js";import{a as We,s as Ge}from"./ripgrep-BXmXjAzA.js";import{i as Ke,t as qe}from"./detectRepository-BPr0VWNO.js";import{r as Je,t as Ye}from"./magicDocs-qdDB_mKb.js";import*as O from"path";import{statSync as Xe}from"fs";function Ze(e,t,n){if(t===0)return n?A:0;let r=e.charCodeAt(t-1);return Qe(r)?rt:$e(r)&&et(e.charCodeAt(t))?it:0}function Qe(e){return e===47||e===92||e===45||e===95||e===46||e===32}function $e(e){return e>=97&&e<=122}function et(e){return e>=65&&e<=90}function k(){return new Promise(e=>setImmediate(e))}function tt(e,t){let n=new Set;for(let r of e){let e=r.length;for(let t=0;t<r.length;t++){let n=r.charCodeAt(t);if(n===47||n===92){e=t;break}}let i=r.slice(0,e);if(i.length>0&&(n.add(i),n.size>=t))break}let r=Array.from(n);return r.sort((e,t)=>{let n=e.length-t.length;return n===0?e<t?-1:+(e>t):n}),r.slice(0,t).map(e=>({path:e,score:0}))}var nt,rt,it,at,A,ot,j,M,N,P,st,ct=e((()=>{n(),nt=16,rt=8,it=6,at=4,A=8,ot=3,j=1,M=100,N=64,P=new Int32Array(N),st=class{constructor(){r(this,`paths`,[]),r(this,`lowerPaths`,[]),r(this,`charBits`,new Int32Array),r(this,`pathLens`,new Uint16Array),r(this,`topLevelCache`,null),r(this,`readyCount`,0)}loadFromFileList(e){let t=new Set,n=[];for(let r of e)r.length>0&&!t.has(r)&&(t.add(r),n.push(r));this.buildIndex(n)}loadFromFileListAsync(e){let t=()=>{};return{queryable:new Promise(e=>{t=e}),done:this.buildAsync(e,t)}}async buildAsync(e,t){let n=new Set,r=[],i=performance.now();for(let t=0;t<e.length;t++){let a=e[t];a.length>0&&!n.has(a)&&(n.add(a),r.push(a)),(t&255)==255&&performance.now()-i>4&&(await k(),i=performance.now())}this.resetArrays(r),i=performance.now();let a=!0;for(let e=0;e<r.length;e++)this.indexPath(e),(e&255)==255&&performance.now()-i>4&&(this.readyCount=e+1,a&&(t(),a=!1),await k(),i=performance.now());this.readyCount=r.length,t()}buildIndex(e){this.resetArrays(e);for(let t=0;t<e.length;t++)this.indexPath(t);this.readyCount=e.length}resetArrays(e){let t=e.length;this.paths=e,this.lowerPaths=Array(t),this.charBits=new Int32Array(t),this.pathLens=new Uint16Array(t),this.readyCount=0,this.topLevelCache=tt(e,M)}indexPath(e){let t=this.paths[e].toLowerCase();this.lowerPaths[e]=t;let n=t.length;this.pathLens[e]=n;let r=0;for(let e=0;e<n;e++){let n=t.charCodeAt(e);n>=97&&n<=122&&(r|=1<<n-97)}this.charBits[e]=r}search(e,t){if(t<=0)return[];if(e.length===0)return this.topLevelCache?this.topLevelCache.slice(0,t):[];let n=e!==e.toLowerCase(),r=n?e:e.toLowerCase(),i=Math.min(r.length,N),a=Array(i),o=0;for(let e=0;e<i;e++){let t=r.charAt(e);a[e]=t;let n=t.charCodeAt(0);n>=97&&n<=122&&(o|=1<<n-97)}let s=i*24+A+32,c=[],l=-1/0,{paths:u,lowerPaths:d,charBits:f,pathLens:ee,readyCount:p}=this;for(let e=0;e<p;e++){if((f[e]&o)!==o)continue;let r=n?u[e]:d[e],p=a[0],m=0,h=[],g=r.indexOf(p);if(g===-1)continue;h[m++]=g;for(let e=g+1;e<r.length;e++){if(r.charCodeAt(e)!==p.charCodeAt(0))continue;let t=r.charCodeAt(e-1);(t===47||t===92||t===45||t===95||t===46||t===32)&&(h[m++]=e)}let _=u[e],v=ee[e],y=Math.max(0,32-(v>>2)),b=-1/0;for(let e=0;e<m;e++){P[0]=h[e];let n=0,o=0,u=P[0],d=!0;for(let e=1;e<i;e++){let t=r.indexOf(a[e],u+1);if(t===-1){d=!1;break}P[e]=t;let i=t-u-1;i===0?o+=at:n+=ot+i*j,u=t}if(!d||c.length===t&&s+o-n+y<=l)continue;let f=i*nt+o-n;f+=Ze(_,P[0],!0);for(let e=1;e<i;e++)f+=Ze(_,P[e],!1);f+=y,f>b&&(b=f)}if(b===-1/0)continue;let x=b;if(c.length<t)c.push({path:_,fuzzScore:x}),c.length===t&&(c.sort((e,t)=>e.fuzzScore-t.fuzzScore),l=c[0].fuzzScore);else if(x>l){let e=0,t=c.length;for(;e<t;){let n=e+t>>1;c[n].fuzzScore<x?e=n+1:t=n}c.splice(e,0,{path:_,fuzzScore:x}),c.shift(),l=c[0].fuzzScore}}c.sort((e,t)=>t.fuzzScore-e.fuzzScore);let m=c.length,h=Math.max(m,1),g=Array(m);for(let e=0;e<m;e++){let t=c[e].path,n=e/h;g[e]={path:t,score:t.includes(`test`)?Math.min(n*1.05,1):n}}return g}}}));function F(){return R||(R=new st),R}function lt(){R=null,z=null,V++,H=null,U=[],W=[],G=[],B.clear(),K=null,q=null,J=0,Y=null,X=null,Z=null}function ut(e){let t=e.length,n=Math.max(1,Math.floor(t/500)),r=-2128831035;for(let i=0;i<t;i+=n){let t=e[i];for(let e=0;e<t.length;e++)r=(r^t.charCodeAt(e))*16777619|0;r=r*16777619|0}if(t>0){let n=e[t-1];for(let e=0;e<n.length;e++)r=(r^n.charCodeAt(e))*16777619|0}return`${t}:${(r>>>0).toString(16)}`}function dt(){let e=w(S());if(!e)return null;try{return Xe(O.join(e,`.git`,`index`)).mtimeMs}catch{return null}}function ft(e,t,n){return n===t?e:e.map(e=>{let r=O.join(t,e);return O.relative(n,r)})}async function pt(e){if(e.length===0||!R||U.length===0)return;let t=await gt(e),n=[...U,...W,...G,...e,...t],r=ut(n);if(r===Z){C(`[FileIndex] skipped index rebuild — merged paths unchanged`);return}await R.loadFromFileListAsync(n).done,Z=r,C(`[FileIndex] rebuilt index with ${U.length} tracked + ${e.length} untracked files`)}async function mt(e,t){let n=`${e}:${t}`;if(q===n)return K;let r=Oe(),i=[`.ignore`,`.rgignore`],a=[...new Set([e,t])],o=(0,Dt.default)(),s=!1,c=a.flatMap(e=>i.map(t=>O.join(e,t))),l=await Promise.all(c.map(e=>r.readFile(e,{encoding:`utf8`}).catch(()=>null)));for(let[e,t]of l.entries())t!==null&&(o.add(t),s=!0,C(`[FileIndex] loaded ignore patterns from ${c[e]}`));let u=s?o:null;return K=u,q=n,u}async function ht(e,t){let n=Date.now();C(`[FileIndex] getFilesUsingGit called`);let r=S(),i=w(r);if(!i)return C(`[FileIndex] not a git repo, returning null`),null;try{let a=Date.now(),o=await T(Le(),[`-c`,`core.quotepath=false`,`ls-files`,`--recurse-submodules`],{timeout:5e3,abortSignal:e,cwd:i});if(C(`[FileIndex] git ls-files (tracked) took ${Date.now()-a}ms`),o.code!==0)return C(`[FileIndex] git ls-files failed (code=${o.code}, stderr=${o.stderr}), falling back to ripgrep`),null;let s=ft(o.stdout.trim().split(`
2
2
  `).filter(Boolean),i,r),c=await mt(i,r);if(c){let e=s.length;s=c.filter(s),C(`[FileIndex] applied ignore patterns: ${e} -> ${s.length} files`)}U=s;let l=Date.now()-n;if(C(`[FileIndex] git ls-files: ${s.length} tracked files in ${l}ms`),D(`tengu_file_suggestions_git_ls_files`,{file_count:s.length,tracked_count:s.length,untracked_count:0,duration_ms:l}),!H){let e=t?[`-c`,`core.quotepath=false`,`ls-files`,`--others`,`--exclude-standard`]:[`-c`,`core.quotepath=false`,`ls-files`,`--others`],n=V;H=T(Le(),e,{timeout:1e4,cwd:i}).then(async e=>{if(n===V&&e.code===0){let t=ft(e.stdout.trim().split(`
3
- `).filter(Boolean),i,r),n=await mt(i,r);if(n&&t.length>0){let e=t.length;t=n.filter(t),C(`[FileIndex] applied ignore patterns to untracked: ${e} -> ${t.length} files`)}C(`[FileIndex] background untracked fetch: ${t.length} files`),pt(t)}}).catch(e=>{C(`[FileIndex] background untracked fetch failed: ${e}`)}).finally(()=>{H=null})}return s}catch(e){return C(`[FileIndex] git ls-files error: ${Ee(e)}`),null}}async function gt(e){let t=new Set,n=performance.now();for(let r=0;r<e.length;r++)_t(e,r,r+1,t),(r&255)==255&&performance.now()-n>4&&(await k(),n=performance.now());return[...t].map(e=>e+O.sep)}function _t(e,t,n,r){for(let i=t;i<n;i++){let t=O.dirname(e[i]);for(;t!==`.`&&!r.has(t);){let e=O.dirname(t);if(e===t)break;r.add(t),t=e}}}async function vt(e){return(await Promise.all(xe.map(t=>fe(t,e)))).flatMap(e=>e.map(e=>e.filePath))}async function yt(e,t){C(`[FileIndex] getProjectFiles called, respectGitignore=${t}`);let n=await ht(e,t);if(n!==null)return C(`[FileIndex] using git ls-files result (${n.length} files)`),n;C(`[FileIndex] git ls-files returned null, falling back to ripgrep`);let r=Date.now(),i=[`--files`,`--follow`,`--hidden`,`--glob`,`!.git/`,`--glob`,`!.svn/`,`--glob`,`!.hg/`,`--glob`,`!.bzr/`,`--glob`,`!.jj/`,`--glob`,`!.sl/`];t||i.push(`--no-ignore-vcs`);let a=(await Ge(i,`.`,e)).map(e=>O.relative(S(),e)),o=Date.now()-r;return C(`[FileIndex] ripgrep: ${a.length} files in ${o}ms`),D(`tengu_file_suggestions_ripgrep`,{file_count:a.length,duration_ms:o}),a}async function bt(){let e=AbortSignal.timeout(1e4),t=F();try{let n=Me(),r=Ne(),i=n.respectGitignore??r.respectGitignore??!0,a=S(),[o,s]=await Promise.all([yt(e,i),vt(a)]);W=s;let c=[...o,...s],l=await gt(c);G=l;let u=[...l,...c],d=ut(u);d===X?C(`[FileIndex] skipped index rebuild — tracked paths unchanged`):(await t.loadFromFileListAsync(u).done,X=d,Z=null)}catch(e){E(e)}return t}function xt(e,t){let n=Math.min(e.length,t.length),r=0;for(;r<n&&e[r]===t[r];)r++;return e.substring(0,r)}function St(e){if(e.length===0)return``;let t=e.map(e=>e.displayText),n=t[0];for(let e=1;e<t.length;e++){let r=t[e];if(n=xt(n,r),n===``)return``}return n}function I(e,t){return{id:`file-${e}`,displayText:e,metadata:t===void 0?void 0:{score:t}}}function Ct(e,t){return e.search(t,Q).map(e=>I(e.path,e.score))}function L(){if(z)return;let e=dt();if(R&&!(e!==null&&e!==Y)&&Date.now()-J<kt)return;let t=V,n=Date.now();F(),z=bt().then(r=>t===V?(z=null,B.emit(),Y=e,J=Date.now(),C(`[FileIndex] cache refresh completed in ${Date.now()-n}ms`),r):r).catch(e=>(C(`[FileIndex] Cache refresh failed: ${Ee(e)}`),E(e),t===V&&(z=null),F()))}async function wt(){let e=Oe(),t=S();try{return(await e.readdir(t)).map(e=>{let n=O.join(t,e.name),r=O.relative(t,n);return e.isDirectory()?r+O.sep:r})}catch(e){return E(e),[]}}async function Tt(e,t=!1){if(!e&&!t)return[];if(Me().fileSuggestion?.type===`command`)return(await ce({...h(),query:e})).slice(0,Q).map(I);if(e===``||e===`.`||e===`./`){let e=await wt();return L(),e.slice(0,Q).map(I)}let n=Date.now();try{let t=z!==null;L();let r=e,i=`.`+O.sep;e.startsWith(i)&&(r=e.substring(2)),r.startsWith(`~`)&&(r=He(r));let a=R?Ct(R,r):[],o=Date.now()-n;return C(`[FileIndex] generateFileSuggestions: ${a.length} results in ${o}ms (${t?`partial`:`full`} index)`),D(`tengu_file_suggestions_query`,{duration_ms:o,cache_hit:!t,result_count:a.length,query_length:e.length}),a}catch(e){return E(e),[]}}function Et(e,t,n,r,i,a){let o=typeof e==`string`?e:e.displayText;i(t.substring(0,r)+o+t.substring(r+n.length)),a(r+o.length)}var Dt,R,z,B,Ot,V,H,U,W,G,K,q,J,Y,X,Z,Q,kt,$=e((()=>{Dt=t(i(),1),he(),ct(),Ue(),Pe(),Te(),De(),Ae(),ze(),ke(),Ie(),we(),Be(),Ve(),We(),je(),a(),R=null,z=null,B=c(),Ot=B.subscribe,V=0,H=null,U=[],W=[],G=[],K=null,q=null,J=0,Y=null,X=null,Z=null,Q=15,kt=5e3}));function At(e=new Set){let t=e.size>0;x.cache.clear?.(),_e.cache.clear?.(),u.cache.clear?.(),le.cache.clear?.(),lt(),se(),t||be(),re(null),l(null),pe(),d(),_(`session_start`),ne(),p(),process.env.USER_TYPE===`ant`&&import(`./TungstenTool-Cb7gJvq4.js`).then(({clearSessionsWithTungstenUsage:e,resetInitializationState:t})=>{e(),t()}),import(`./attributionHooks-CUAoGkU6.js`).then(({clearAttributionCaches:e})=>e()),qe(),ue(),t||b(),s(e),Re(),ae(),Ce(),Ye(),y(),import(`./SearchExtraToolsTool-C4uO-Zx3.js`).then(({clearSearchExtraToolsDescriptionCache:e})=>e()),import(`./loadAgentsDir-TZjwTqdr.js`).then(({clearAgentDefinitionsCache:e})=>e()),import(`./prompt-IAvMxKDl.js`).then(({clearPromptCache:e})=>e())}var jt=e((()=>{o(),ie(),g(),te(),$(),v(),me(),ee(),ge(),f(),Je(),m(),ve(),de(),oe(),Ke(),Fe(),ye(),Se()}));export{Tt as a,L as c,St as i,jt as n,$ as o,Et as r,Ot as s,At as t};
3
+ `).filter(Boolean),i,r),n=await mt(i,r);if(n&&t.length>0){let e=t.length;t=n.filter(t),C(`[FileIndex] applied ignore patterns to untracked: ${e} -> ${t.length} files`)}C(`[FileIndex] background untracked fetch: ${t.length} files`),pt(t)}}).catch(e=>{C(`[FileIndex] background untracked fetch failed: ${e}`)}).finally(()=>{H=null})}return s}catch(e){return C(`[FileIndex] git ls-files error: ${Ee(e)}`),null}}async function gt(e){let t=new Set,n=performance.now();for(let r=0;r<e.length;r++)_t(e,r,r+1,t),(r&255)==255&&performance.now()-n>4&&(await k(),n=performance.now());return[...t].map(e=>e+O.sep)}function _t(e,t,n,r){for(let i=t;i<n;i++){let t=O.dirname(e[i]);for(;t!==`.`&&!r.has(t);){let e=O.dirname(t);if(e===t)break;r.add(t),t=e}}}async function vt(e){return(await Promise.all(me.map(t=>oe(t,e)))).flatMap(e=>e.map(e=>e.filePath))}async function yt(e,t){C(`[FileIndex] getProjectFiles called, respectGitignore=${t}`);let n=await ht(e,t);if(n!==null)return C(`[FileIndex] using git ls-files result (${n.length} files)`),n;C(`[FileIndex] git ls-files returned null, falling back to ripgrep`);let r=Date.now(),i=[`--files`,`--follow`,`--hidden`,`--glob`,`!.git/`,`--glob`,`!.svn/`,`--glob`,`!.hg/`,`--glob`,`!.bzr/`,`--glob`,`!.jj/`,`--glob`,`!.sl/`];t||i.push(`--no-ignore-vcs`);let a=(await Ge(i,`.`,e)).map(e=>O.relative(S(),e)),o=Date.now()-r;return C(`[FileIndex] ripgrep: ${a.length} files in ${o}ms`),D(`tengu_file_suggestions_ripgrep`,{file_count:a.length,duration_ms:o}),a}async function bt(){let e=AbortSignal.timeout(1e4),t=F();try{let n=Me(),r=Ne(),i=n.respectGitignore??r.respectGitignore??!0,a=S(),[o,s]=await Promise.all([yt(e,i),vt(a)]);W=s;let c=[...o,...s],l=await gt(c);G=l;let u=[...l,...c],d=ut(u);d===X?C(`[FileIndex] skipped index rebuild — tracked paths unchanged`):(await t.loadFromFileListAsync(u).done,X=d,Z=null)}catch(e){E(e)}return t}function xt(e,t){let n=Math.min(e.length,t.length),r=0;for(;r<n&&e[r]===t[r];)r++;return e.substring(0,r)}function St(e){if(e.length===0)return``;let t=e.map(e=>e.displayText),n=t[0];for(let e=1;e<t.length;e++){let r=t[e];if(n=xt(n,r),n===``)return``}return n}function I(e,t){return{id:`file-${e}`,displayText:e,metadata:t===void 0?void 0:{score:t}}}function Ct(e,t){return e.search(t,Q).map(e=>I(e.path,e.score))}function L(){if(z)return;let e=dt();if(R&&!(e!==null&&e!==Y)&&Date.now()-J<kt)return;let t=V,n=Date.now();F(),z=bt().then(r=>t===V?(z=null,B.emit(),Y=e,J=Date.now(),C(`[FileIndex] cache refresh completed in ${Date.now()-n}ms`),r):r).catch(e=>(C(`[FileIndex] Cache refresh failed: ${Ee(e)}`),E(e),t===V&&(z=null),F()))}async function wt(){let e=Oe(),t=S();try{return(await e.readdir(t)).map(e=>{let n=O.join(t,e.name),r=O.relative(t,n);return e.isDirectory()?r+O.sep:r})}catch(e){return E(e),[]}}async function Tt(e,t=!1){if(!e&&!t)return[];if(Me().fileSuggestion?.type===`command`)return(await re({...p(),query:e})).slice(0,Q).map(I);if(e===``||e===`.`||e===`./`){let e=await wt();return L(),e.slice(0,Q).map(I)}let n=Date.now();try{let t=z!==null;L();let r=e,i=`.`+O.sep;e.startsWith(i)&&(r=e.substring(2)),r.startsWith(`~`)&&(r=He(r));let a=R?Ct(R,r):[],o=Date.now()-n;return C(`[FileIndex] generateFileSuggestions: ${a.length} results in ${o}ms (${t?`partial`:`full`} index)`),D(`tengu_file_suggestions_query`,{duration_ms:o,cache_hit:!t,result_count:a.length,query_length:e.length}),a}catch(e){return E(e),[]}}function Et(e,t,n,r,i,a){let o=typeof e==`string`?e:e.displayText;i(t.substring(0,r)+o+t.substring(r+n.length)),a(r+o.length)}var Dt,R,z,B,Ot,V,H,U,W,G,K,q,J,Y,X,Z,Q,kt,$=e((()=>{Dt=t(i(),1),de(),ct(),Ue(),Pe(),Te(),De(),Ae(),ze(),ke(),Ie(),be(),Be(),Ve(),We(),je(),a(),R=null,z=null,B=c(),Ot=B.subscribe,V=0,H=null,U=[],W=[],G=[],K=null,q=null,J=0,Y=null,X=null,Z=null,Q=15,kt=5e3}));function At(e=new Set){let t=e.size>0;d.cache.clear?.(),b.cache.clear?.(),ye.cache.clear?.(),ee.cache.clear?.(),lt(),ne(),t||he(),te(null),l(null),ge(),f(),v(`session_start`),Se(),se(),process.env.USER_TYPE===`ant`&&import(`./TungstenTool-Cb7gJvq4.js`).then(({clearSessionsWithTungstenUsage:e,resetInitializationState:t})=>{e(),t()}),import(`./attributionHooks-CUAoGkU6.js`).then(({clearAttributionCaches:e})=>e()),qe(),ie(),t||g(),s(e),Re(),pe(),ce(),Ye(),Ce(),import(`./SearchExtraToolsTool-B-7Bworf.js`).then(({clearSearchExtraToolsDescriptionCache:e})=>e()),import(`./loadAgentsDir-B9c3Emvg.js`).then(({clearAgentDefinitionsCache:e})=>e()),import(`./prompt-CLJKFebn.js`).then(({clearPromptCache:e})=>e())}var jt=e((()=>{o(),y(),h(),ve(),$(),we(),m(),_e(),ue(),fe(),Je(),xe(),x(),ae(),_(),Ke(),Fe(),le(),u()}));export{Tt as a,L as c,St as i,jt as n,$ as o,Et as r,Ot as s,At as t};
@@ -0,0 +1 @@
1
+ import{n as e,t}from"./caches-5HVQSevy.js";e();export{t as clearSessionCaches};
@@ -1 +1 @@
1
- import{n as e,t}from"./defineProperty-C-QyHrDq.js";import{F as n,I as r,S as i,a,l as o,w as s,z as c}from"./debug-BrXObCdR.js";import{M as l,j as u}from"./git-Do0wJvux.js";import{_n as d,ar as f,or as p,vn as m}from"./model-CKkOnnnx.js";import{l as h,r as g}from"./proxy-CRN7jYIi.js";import{D as _,E as v,O as y,a as b,l as x,r as S}from"./rcDebugLog-CUy1_F23.js";import{n as C}from"./jwtUtils-DE2GPUcx.js";import{randomUUID as w}from"crypto";c(),a(),u(),h(),p(),d(),y(),S(),i(),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 n=0,r=0;for(;r<this.pending.length&&r<e;){let e;try{e=Buffer.byteLength(s(this.pending[r]))}catch{this.pending.splice(r,1);continue}if(r>0&&n+e>t)break;n+=e,r++}return this.pending.splice(0,r)}retryDelay(e,t){let n=Math.random()*this.config.jitterMs;return t===void 0?Math.min(this.config.baseDelayMs*2**(e-1),this.config.maxDelayMs)+n:Math.max(this.config.baseDelayMs,Math.min(t,this.config.maxDelayMs))+n}releaseBackpressure(){let e=this.backpressureResolvers;this.backpressureResolvers=[];for(let t of e)t()}sleep(e){return new Promise(t=>{this.sleepResolve=t,setTimeout((e,t)=>{e.sleepResolve=null,t()},e,this,t)})}};e();var D=class{constructor(e){t(this,`inflight`,null),t(this,`pending`,null),t(this,`closed`,!1),t(this,`config`,void 0),this.config=e}enqueue(e){this.closed||(this.pending=this.pending?O(this.pending,e):e,this.drain())}close(){this.closed=!0,this.pending=null}async drain(){if(this.inflight||this.closed||!this.pending)return;let e=this.pending;this.pending=null,this.inflight=this.sendWithRetry(e).then(()=>{this.inflight=null,this.pending&&!this.closed&&this.drain()})}async sendWithRetry(e){let t=e,n=0;for(;!this.closed;){if(await this.config.send(t))return;n++,await m(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`,g({keepAlive:!0})),t(this,`streamEventBuffer`,[]),t(this,`streamEventTimer`,null),t(this,`streamTextAccumulator`,P()),t(this,`workerState`,void 0),t(this,`eventUploader`,void 0),t(this,`internalEventUploader`,void 0),t(this,`deliveryUploader`,void 0),t(this,`onEpochMismatch`,void 0),t(this,`getAuthHeaders`,void 0),this.onEpochMismatch=r?.onEpochMismatch??(()=>{process.exit(1)}),this.heartbeatIntervalMs=r?.heartbeatIntervalMs??k,this.heartbeatJitterFraction=r?.heartbeatJitterFraction??0,this.getAuthHeaders=r?.getAuthHeaders??v,n.protocol!==`http:`&&n.protocol!==`https:`)throw Error(`CCRClient: Expected http(s) URL, got ${n.protocol}`);let i=n.pathname.replace(/\/$/,``);this.sessionBaseUrl=`${n.protocol}//${n.host}${i}`,this.sessionId=i.split(`/`).pop()||``,this.workerState=new D({send:e=>this.request(`put`,`/worker`,{worker_epoch:this.workerEpoch,...e},`PUT worker`).then(e=>e.ok),baseDelayMs:500,maxDelayMs:3e4,jitterMs:500}),this.eventUploader=new E({maxBatchSize:100,maxBatchBytes:10*1024*1024,maxQueueSize:1e5,send:async e=>{let t=await this.request(`post`,`/worker/events`,{worker_epoch:this.workerEpoch,events:e},`client events`);if(!t.ok)throw new T(`client event POST failed`,t.retryAfterMs)},baseDelayMs:500,maxDelayMs:3e4,jitterMs:500}),this.internalEventUploader=new E({maxBatchSize:100,maxBatchBytes:10*1024*1024,maxQueueSize:200,send:async e=>{let t=await this.request(`post`,`/worker/internal-events`,{worker_epoch:this.workerEpoch,events:e},`internal events`);if(!t.ok)throw new T(`internal event POST failed`,t.retryAfterMs)},baseDelayMs:500,maxDelayMs:3e4,jitterMs:500}),this.deliveryUploader=new E({maxBatchSize:64,maxQueueSize:64,send:async e=>{let t=await this.request(`post`,`/worker/events/delivery`,{worker_epoch:this.workerEpoch,updates:e.map(e=>({event_id:e.eventId,status:e.status}))},`delivery batch`);if(!t.ok)throw new T(`delivery POST failed`,t.retryAfterMs)},baseDelayMs:500,maxDelayMs:3e4,jitterMs:500}),e.setOnEvent(e=>{this.reportDelivery(e.event_id,`received`)})}async initialize(e){let t=Date.now();if(Object.keys(this.getAuthHeaders()).length===0)throw new M(`no_auth_headers`);if(e===void 0){let t=process.env.CLAUDE_CODE_WORKER_EPOCH;e=t?parseInt(t,10):NaN}if(isNaN(e))throw new M(`missing_epoch`);this.workerEpoch=e;let n=this.getWorkerState();if(!(await this.request(`put`,`/worker`,{worker_status:`idle`,worker_epoch:this.workerEpoch,external_metadata:{pending_action:null,task_summary:null,automation_state:null}},`PUT worker (init)`)).ok)throw new M(`worker_register_failed`);this.currentState=`idle`,this.startHeartbeat(),b(()=>{this.writeEvent({type:`keep_alive`})}),o(`CCRClient: initialized, epoch=${this.workerEpoch}`),l(`info`,`cli_worker_lifecycle_initialized`,{epoch:this.workerEpoch,duration_ms:Date.now()-t});let{metadata:r,durationMs:i}=await n;return this.closed||l(`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,i,a,{timeout:s=1e4}={}){let c=this.getAuthHeaders();if(Object.keys(c).length===0)return{ok:!1};try{let n=await this.http[e](`${this.sessionBaseUrl}${t}`,i,{headers:{...c,"Content-Type":`application/json`,"anthropic-version":`2023-06-01`,"User-Agent":f()},validateStatus:j,timeout:s});if(n.status>=200&&n.status<300)return this.consecutiveAuthFailures=0,{ok:!0};if(n.status===409&&this.handleEpochMismatch(),n.status===401||n.status===403){let e=_(),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`}),l(`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`}),l(`error`,`cli_worker_auth_failures_exhausted`),this.onEpochMismatch())}if(o(`CCRClient: ${a} returned ${n.status}`,{level:`warn`}),l(`warn`,`cli_worker_request_failed`,{method:e,path:t,status:n.status}),n.status===429){let e=n.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(i){return o(`CCRClient: ${a} failed: ${n(i)}`,{level:`warn`}),l(`warn`,`cli_worker_request_error`,{method:e,path:t,error_code:r(i)}),{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`}),l(`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,r){for(let r=1;r<=10;r++){let i;try{i=await this.http.get(e,{headers:{...t,"anthropic-version":`2023-06-01`,"User-Agent":f()},validateStatus:j,timeout:3e4})}catch(t){o(`CCRClient: GET ${e} failed (attempt ${r}/10): ${n(t)}`,{level:`warn`}),r<10&&await m(Math.min(500*2**(r-1),3e4)+Math.random()*500);continue}if(i.status>=200&&i.status<300)return i.data;i.status===409&&this.handleEpochMismatch(),o(`CCRClient: GET ${e} returned ${i.status} (attempt ${r}/10)`,{level:`warn`}),r<10&&await m(Math.min(500*2**(r-1),3e4)+Math.random()*500)}return o(`CCRClient: GET retries exhausted`,{level:`error`}),l(`error`,`cli_worker_get_retries_exhausted`,{context:r}),null}reportDelivery(e,t){this.deliveryUploader.enqueue({eventId:e,status:t})}getWorkerEpoch(){return this.workerEpoch}get internalEventsPending(){return this.internalEventUploader.pendingCount}close(){this.closed=!0,this.stopHeartbeat(),x(),this.streamEventTimer&&(clearTimeout(this.streamEventTimer),this.streamEventTimer=null),this.streamEventBuffer=[],this.streamTextAccumulator.byMessage.clear(),this.streamTextAccumulator.scopeToMessage.clear(),this.workerState.close(),this.eventUploader.close(),this.internalEventUploader.close(),this.deliveryUploader.close()}};export{M as n,E as r,R as t};
1
+ import{n as e,t}from"./defineProperty-C-QyHrDq.js";import{F as n,I as r,S as i,a,l as o,w as s,z as c}from"./debug-BrXObCdR.js";import{M as l,j as u}from"./git-Do0wJvux.js";import{_n as d,ar as f,or as p,vn as m}from"./model-CZViyZnE.js";import{l as h,r as g}from"./proxy-CRN7jYIi.js";import{D as _,E as v,O as y,a as b,l as x,r as S}from"./rcDebugLog-DBB9r8aw.js";import{n as C}from"./jwtUtils-DE2GPUcx.js";import{randomUUID as w}from"crypto";c(),a(),u(),h(),p(),d(),y(),S(),i(),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 n=0,r=0;for(;r<this.pending.length&&r<e;){let e;try{e=Buffer.byteLength(s(this.pending[r]))}catch{this.pending.splice(r,1);continue}if(r>0&&n+e>t)break;n+=e,r++}return this.pending.splice(0,r)}retryDelay(e,t){let n=Math.random()*this.config.jitterMs;return t===void 0?Math.min(this.config.baseDelayMs*2**(e-1),this.config.maxDelayMs)+n:Math.max(this.config.baseDelayMs,Math.min(t,this.config.maxDelayMs))+n}releaseBackpressure(){let e=this.backpressureResolvers;this.backpressureResolvers=[];for(let t of e)t()}sleep(e){return new Promise(t=>{this.sleepResolve=t,setTimeout((e,t)=>{e.sleepResolve=null,t()},e,this,t)})}};e();var D=class{constructor(e){t(this,`inflight`,null),t(this,`pending`,null),t(this,`closed`,!1),t(this,`config`,void 0),this.config=e}enqueue(e){this.closed||(this.pending=this.pending?O(this.pending,e):e,this.drain())}close(){this.closed=!0,this.pending=null}async drain(){if(this.inflight||this.closed||!this.pending)return;let e=this.pending;this.pending=null,this.inflight=this.sendWithRetry(e).then(()=>{this.inflight=null,this.pending&&!this.closed&&this.drain()})}async sendWithRetry(e){let t=e,n=0;for(;!this.closed;){if(await this.config.send(t))return;n++,await m(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`,g({keepAlive:!0})),t(this,`streamEventBuffer`,[]),t(this,`streamEventTimer`,null),t(this,`streamTextAccumulator`,P()),t(this,`workerState`,void 0),t(this,`eventUploader`,void 0),t(this,`internalEventUploader`,void 0),t(this,`deliveryUploader`,void 0),t(this,`onEpochMismatch`,void 0),t(this,`getAuthHeaders`,void 0),this.onEpochMismatch=r?.onEpochMismatch??(()=>{process.exit(1)}),this.heartbeatIntervalMs=r?.heartbeatIntervalMs??k,this.heartbeatJitterFraction=r?.heartbeatJitterFraction??0,this.getAuthHeaders=r?.getAuthHeaders??v,n.protocol!==`http:`&&n.protocol!==`https:`)throw Error(`CCRClient: Expected http(s) URL, got ${n.protocol}`);let i=n.pathname.replace(/\/$/,``);this.sessionBaseUrl=`${n.protocol}//${n.host}${i}`,this.sessionId=i.split(`/`).pop()||``,this.workerState=new D({send:e=>this.request(`put`,`/worker`,{worker_epoch:this.workerEpoch,...e},`PUT worker`).then(e=>e.ok),baseDelayMs:500,maxDelayMs:3e4,jitterMs:500}),this.eventUploader=new E({maxBatchSize:100,maxBatchBytes:10*1024*1024,maxQueueSize:1e5,send:async e=>{let t=await this.request(`post`,`/worker/events`,{worker_epoch:this.workerEpoch,events:e},`client events`);if(!t.ok)throw new T(`client event POST failed`,t.retryAfterMs)},baseDelayMs:500,maxDelayMs:3e4,jitterMs:500}),this.internalEventUploader=new E({maxBatchSize:100,maxBatchBytes:10*1024*1024,maxQueueSize:200,send:async e=>{let t=await this.request(`post`,`/worker/internal-events`,{worker_epoch:this.workerEpoch,events:e},`internal events`);if(!t.ok)throw new T(`internal event POST failed`,t.retryAfterMs)},baseDelayMs:500,maxDelayMs:3e4,jitterMs:500}),this.deliveryUploader=new E({maxBatchSize:64,maxQueueSize:64,send:async e=>{let t=await this.request(`post`,`/worker/events/delivery`,{worker_epoch:this.workerEpoch,updates:e.map(e=>({event_id:e.eventId,status:e.status}))},`delivery batch`);if(!t.ok)throw new T(`delivery POST failed`,t.retryAfterMs)},baseDelayMs:500,maxDelayMs:3e4,jitterMs:500}),e.setOnEvent(e=>{this.reportDelivery(e.event_id,`received`)})}async initialize(e){let t=Date.now();if(Object.keys(this.getAuthHeaders()).length===0)throw new M(`no_auth_headers`);if(e===void 0){let t=process.env.CLAUDE_CODE_WORKER_EPOCH;e=t?parseInt(t,10):NaN}if(isNaN(e))throw new M(`missing_epoch`);this.workerEpoch=e;let n=this.getWorkerState();if(!(await this.request(`put`,`/worker`,{worker_status:`idle`,worker_epoch:this.workerEpoch,external_metadata:{pending_action:null,task_summary:null,automation_state:null}},`PUT worker (init)`)).ok)throw new M(`worker_register_failed`);this.currentState=`idle`,this.startHeartbeat(),b(()=>{this.writeEvent({type:`keep_alive`})}),o(`CCRClient: initialized, epoch=${this.workerEpoch}`),l(`info`,`cli_worker_lifecycle_initialized`,{epoch:this.workerEpoch,duration_ms:Date.now()-t});let{metadata:r,durationMs:i}=await n;return this.closed||l(`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,i,a,{timeout:s=1e4}={}){let c=this.getAuthHeaders();if(Object.keys(c).length===0)return{ok:!1};try{let n=await this.http[e](`${this.sessionBaseUrl}${t}`,i,{headers:{...c,"Content-Type":`application/json`,"anthropic-version":`2023-06-01`,"User-Agent":f()},validateStatus:j,timeout:s});if(n.status>=200&&n.status<300)return this.consecutiveAuthFailures=0,{ok:!0};if(n.status===409&&this.handleEpochMismatch(),n.status===401||n.status===403){let e=_(),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`}),l(`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`}),l(`error`,`cli_worker_auth_failures_exhausted`),this.onEpochMismatch())}if(o(`CCRClient: ${a} returned ${n.status}`,{level:`warn`}),l(`warn`,`cli_worker_request_failed`,{method:e,path:t,status:n.status}),n.status===429){let e=n.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(i){return o(`CCRClient: ${a} failed: ${n(i)}`,{level:`warn`}),l(`warn`,`cli_worker_request_error`,{method:e,path:t,error_code:r(i)}),{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`}),l(`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,r){for(let r=1;r<=10;r++){let i;try{i=await this.http.get(e,{headers:{...t,"anthropic-version":`2023-06-01`,"User-Agent":f()},validateStatus:j,timeout:3e4})}catch(t){o(`CCRClient: GET ${e} failed (attempt ${r}/10): ${n(t)}`,{level:`warn`}),r<10&&await m(Math.min(500*2**(r-1),3e4)+Math.random()*500);continue}if(i.status>=200&&i.status<300)return i.data;i.status===409&&this.handleEpochMismatch(),o(`CCRClient: GET ${e} returned ${i.status} (attempt ${r}/10)`,{level:`warn`}),r<10&&await m(Math.min(500*2**(r-1),3e4)+Math.random()*500)}return o(`CCRClient: GET retries exhausted`,{level:`error`}),l(`error`,`cli_worker_get_retries_exhausted`,{context:r}),null}reportDelivery(e,t){this.deliveryUploader.enqueue({eventId:e,status:t})}getWorkerEpoch(){return this.workerEpoch}get internalEventsPending(){return this.internalEventUploader.pendingCount}close(){this.closed=!0,this.stopHeartbeat(),x(),this.streamEventTimer&&(clearTimeout(this.streamEventTimer),this.streamEventTimer=null),this.streamEventBuffer=[],this.streamTextAccumulator.byMessage.clear(),this.streamTextAccumulator.scopeToMessage.clear(),this.workerState.close(),this.eventUploader.close(),this.internalEventUploader.close(),this.deliveryUploader.close()}};export{M as n,E as r,R as t};
@@ -1 +1 @@
1
- import{I as e,z as t}from"./debug-BrXObCdR.js";import{o as n,s as r}from"./log-BMCygSzM.js";import{i,o as a,t as o}from"./platform-BrYefG_2.js";import{a as s,i as c,s as l,u}from"./types-C-MRCL8J.js";import{homedir as d}from"os";import{join as f}from"path";import{readFile as p,readdir as m,stat as h}from"fs/promises";s(),t(),l(),n(),a();async function g(){let e=i();if(!o.includes(e))throw Error(`Unsupported platform: ${e} - Claude Desktop integration only works on macOS and WSL.`);if(e===`macos`)return f(d(),`Library`,`Application Support`,`Claude`,`claude_desktop_config.json`);let t=process.env.USERPROFILE?process.env.USERPROFILE.replace(/\\/g,`/`):null;if(t){let e=`/mnt/c${t.replace(/^[A-Z]:/,``)}/AppData/Roaming/Claude/claude_desktop_config.json`;try{return await h(e),e}catch{}}try{let e=`/mnt/c/Users`;try{let t=await m(e,{withFileTypes:!0});for(let n of t){if(n.name===`Public`||n.name===`Default`||n.name===`Default User`||n.name===`All Users`)continue;let t=f(e,n.name,`AppData`,`Roaming`,`Claude`,`claude_desktop_config.json`);try{return await h(t),t}catch{}}}catch{}}catch(e){r(e)}throw Error(`Could not find Claude Desktop config file in Windows. Make sure Claude Desktop is installed on Windows.`)}async function _(){if(!o.includes(i()))throw Error(`Unsupported platform - Claude Desktop integration only works on macOS and WSL.`);try{let t=await g(),n;try{n=await p(t,{encoding:`utf8`})}catch(t){if(e(t)===`ENOENT`)return{};throw t}let r=u(n);if(!r||typeof r!=`object`)return{};let i=r.mcpServers;if(!i||typeof i!=`object`)return{};let a={};for(let[e,t]of Object.entries(i)){if(!t||typeof t!=`object`)continue;let n=c().safeParse(t);n.success&&(a[e]=n.data)}return a}catch(e){return r(e),{}}}export{_ as readClaudeDesktopMcpServers};
1
+ import{I as e,z as t}from"./debug-BrXObCdR.js";import{o as n,s as r}from"./log-BMCygSzM.js";import{i,o as a,t as o}from"./platform-BrYefG_2.js";import{a as s,i as c,s as l,u}from"./types-Dut4311z.js";import{homedir as d}from"os";import{join as f}from"path";import{readFile as p,readdir as m,stat as h}from"fs/promises";s(),t(),l(),n(),a();async function g(){let e=i();if(!o.includes(e))throw Error(`Unsupported platform: ${e} - Claude Desktop integration only works on macOS and WSL.`);if(e===`macos`)return f(d(),`Library`,`Application Support`,`Claude`,`claude_desktop_config.json`);let t=process.env.USERPROFILE?process.env.USERPROFILE.replace(/\\/g,`/`):null;if(t){let e=`/mnt/c${t.replace(/^[A-Z]:/,``)}/AppData/Roaming/Claude/claude_desktop_config.json`;try{return await h(e),e}catch{}}try{let e=`/mnt/c/Users`;try{let t=await m(e,{withFileTypes:!0});for(let n of t){if(n.name===`Public`||n.name===`Default`||n.name===`Default User`||n.name===`All Users`)continue;let t=f(e,n.name,`AppData`,`Roaming`,`Claude`,`claude_desktop_config.json`);try{return await h(t),t}catch{}}}catch{}}catch(e){r(e)}throw Error(`Could not find Claude Desktop config file in Windows. Make sure Claude Desktop is installed on Windows.`)}async function _(){if(!o.includes(i()))throw Error(`Unsupported platform - Claude Desktop integration only works on macOS and WSL.`);try{let t=await g(),n;try{n=await p(t,{encoding:`utf8`})}catch(t){if(e(t)===`ENOENT`)return{};throw t}let r=u(n);if(!r||typeof r!=`object`)return{};let i=r.mcpServers;if(!i||typeof i!=`object`)return{};let a={};for(let[e,t]of Object.entries(i)){if(!t||typeof t!=`object`)continue;let n=c().safeParse(t);n.success&&(a[e]=n.data)}return a}catch(e){return r(e),{}}}export{_ as readClaudeDesktopMcpServers};
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./conversation-BWVTM40Y.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-DCMw_rsE.js";var r;e((()=>{t(),r=async(e,t)=>(await n(t),{type:`text`,value:``})}))();export{r as call};