@readmagic/workmate 0.0.9 → 0.0.10

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 (427) hide show
  1. package/dist/chunks/{AddWorkspaceDirectory-qFZy3FOD.js → AddWorkspaceDirectory-Vmmm7p1c.js} +1 -1
  2. package/dist/chunks/App-C2yQjBgY.js +1 -0
  3. package/dist/chunks/ApproveApiKey-CKbv5C1x.js +1 -0
  4. package/dist/chunks/{ApproveApiKey-DHAbdwkC.js → ApproveApiKey-MscC-ssL.js} +1 -1
  5. package/dist/chunks/BackgroundTasksDialog-CL5NWsFL.js +2 -0
  6. package/dist/chunks/{BypassPermissionsModeDialog-BuRFF1fQ.js → BypassPermissionsModeDialog-CLSACUmo.js} +1 -1
  7. package/dist/chunks/{ClaudeMdExternalIncludesDialog-CDrArsSX.js → ClaudeMdExternalIncludesDialog-BqNxQOXJ.js} +1 -1
  8. package/dist/chunks/ClaudeMdExternalIncludesDialog-C0-psohX.js +1 -0
  9. package/dist/chunks/ConsoleOAuthFlow-4mOvEer_.js +1 -0
  10. package/dist/chunks/{DiffDialog-BIcwpgSr.js → DiffDialog-9AYwtupw.js} +3 -3
  11. package/dist/chunks/Doctor-DmgAwce2.js +1 -0
  12. package/dist/chunks/Doctor-jEs9chPk.js +3 -0
  13. package/dist/chunks/ExitFlow-DVKxFdpX.js +2 -0
  14. package/dist/chunks/{Grove-BmirUB6V.js → Grove-B9-hhkZA.js} +1 -1
  15. package/dist/chunks/{HybridTransport-BVmSUHf0.js → HybridTransport-MxJ_W_np.js} +3 -3
  16. package/dist/chunks/{InvalidConfigDialog-WRywkKeS.js → InvalidConfigDialog-o9DF1REI.js} +1 -1
  17. package/dist/chunks/{InvalidSettingsDialog-C4n3A72C.js → InvalidSettingsDialog-YyQcHocx.js} +1 -1
  18. package/dist/chunks/MCPConnectionManager-CUTuaa8T.js +1 -0
  19. package/dist/chunks/MCPToolListView-CvqB4nCw.js +1 -0
  20. package/dist/chunks/{McpParsingWarnings-CH4yyMAL.js → McpParsingWarnings-BCpfHaBK.js} +1 -1
  21. package/dist/chunks/MessageSelector-BLzw172f.js +3 -0
  22. package/dist/chunks/Messages-4K5sLmNh.js +11 -0
  23. package/dist/chunks/{Onboarding-BboWs1pp.js → Onboarding-ClwHS5rh.js} +1 -1
  24. package/dist/chunks/{PromptInputFooterSuggestions-BpC9COmh.js → PromptInputFooterSuggestions-BSA9NrZc.js} +1 -1
  25. package/dist/chunks/PromptInputHelpMenu-Bb4KdIX_.js +1 -0
  26. package/dist/chunks/QueryEngine-DPHLSsax.js +1 -0
  27. package/dist/chunks/REPL-Bf46iQCN.js +1 -0
  28. package/dist/chunks/REPL-DIaAo9M9.js +133 -0
  29. package/dist/chunks/RemoteSessionManager-CS6mywIn.js +2 -0
  30. package/dist/chunks/ResumeConversation-Br2KsBoe.js +1 -0
  31. package/dist/chunks/{SSETransport-1KBBUikF.js → SSETransport-CoxQ8YpH.js} +1 -1
  32. package/dist/chunks/SearchExtraToolsTool-i_YO3QvV.js +1 -0
  33. package/dist/chunks/Settings-BMXysXIx.js +2 -0
  34. package/dist/chunks/{TeleportProgress-BmgPAZAi.js → TeleportProgress-Doucj-50.js} +1 -1
  35. package/dist/chunks/{TeleportRepoMismatchDialog-sgxNOeM_.js → TeleportRepoMismatchDialog-B5I73j7Y.js} +1 -1
  36. package/dist/chunks/{TeleportResumeWrapper-GptvrUdv.js → TeleportResumeWrapper-D6kpr2c6.js} +1 -1
  37. package/dist/chunks/{ThemePicker-gAMqqD1P.js → ThemePicker-DrC8tlp0.js} +1 -1
  38. package/dist/chunks/{TrustDialog-CWt-4Evl.js → TrustDialog-Fk4m_Sy4.js} +1 -1
  39. package/dist/chunks/{ValidationErrorsList-De3kzHtz.js → ValidationErrorsList-D_OUa4RT.js} +1 -1
  40. package/dist/chunks/WelcomeV2-DvfQHnZY.js +1 -0
  41. package/dist/chunks/add-dir-CZ6Clvq8.js +1 -0
  42. package/dist/chunks/{agentDisplay-5gnCQwUY.js → agentDisplay-B755vMZE.js} +1 -1
  43. package/dist/chunks/{agents-Bz1MLp4A.js → agents-CIvP8l0s.js} +1 -1
  44. package/dist/chunks/agents-DHnNg4h6.js +103 -0
  45. package/dist/chunks/allErrors-CU89tF-z.js +1 -0
  46. package/dist/chunks/api-BSeE6MwB.js +1 -0
  47. package/dist/chunks/{api-DzccRM_z.js → api-nSHc_GIQ.js} +1 -1
  48. package/dist/chunks/{auth-Cjnyy10u.js → auth-5QB6tsfB.js} +1 -1
  49. package/dist/chunks/auth-BIGJth5U.js +1 -0
  50. package/dist/chunks/auth-CDQMhIZP.js +1 -0
  51. package/dist/chunks/{autoMode-CQ5nqP9c.js → autoMode-BnUiK9Cu.js} +5 -5
  52. package/dist/chunks/{autonomy-CPUCe-YU.js → autonomy-C1aSgWPQ.js} +1 -1
  53. package/dist/chunks/autonomy-Src6sKCp.js +15 -0
  54. package/dist/chunks/{autonomyPanel-Ccr9ilei.js → autonomyPanel-DnHpuiy4.js} +1 -1
  55. package/dist/chunks/backgroundHousekeeping-B-cw0UcS.js +17 -0
  56. package/dist/chunks/backgroundHousekeeping-BS_8z3_x.js +1 -0
  57. package/dist/chunks/{banner-BJZNMppT.js → banner-D0P7wXdw.js} +1 -1
  58. package/dist/chunks/bg-50rllUNh.js +1 -0
  59. package/dist/chunks/{bg-w3Vlsm3Y.js → bg-DAPORXF3.js} +2 -2
  60. package/dist/chunks/{branch-CG0AKS1J.js → branch-DFWa4Oxo.js} +2 -2
  61. package/dist/chunks/{break-cache-DXV0brco.js → break-cache-Chj9i9MP.js} +2 -2
  62. package/dist/chunks/{bridgeConfig-vORehbGG.js → bridgeConfig-Bb6URf4Q.js} +1 -1
  63. package/dist/chunks/bridgeConfig-BeqChxJC.js +1 -0
  64. package/dist/chunks/bridgeMessaging-C3huGcR3.js +1 -0
  65. package/dist/chunks/{bridgePointer-D4W9GpWw.js → bridgePointer-DLYyvRKb.js} +1 -1
  66. package/dist/chunks/bridgeStatusUtil-DFMftajD.js +1 -0
  67. package/dist/chunks/{btw-DDUC_t0w.js → btw-DSK9R2C8.js} +1 -1
  68. package/dist/chunks/caches-BTQAW9zc.js +1 -0
  69. package/dist/chunks/caches-BVtSCnV1.js +1 -0
  70. package/dist/chunks/{capacityWake-L7b1mMft.js → capacityWake-amzeeBz0.js} +1 -1
  71. package/dist/chunks/{ccrClient-CG6HTv_n.js → ccrClient-Bu7Tf1Z5.js} +1 -1
  72. package/dist/chunks/{claudeDesktop-CAmnheYx.js → claudeDesktop-CsJfF1b-.js} +1 -1
  73. package/dist/chunks/{clear-DdWexxbM.js → clear-ClFDpWVJ.js} +1 -1
  74. package/dist/chunks/{cliLaunch-BWWOgBFh.js → cliLaunch-BWcoyZDP.js} +1 -1
  75. package/dist/chunks/client-BWQ4-rN7.js +1 -0
  76. package/dist/chunks/{client-CoXtVRzi.js → client-DFlE4fYh.js} +1 -1
  77. package/dist/chunks/client-c-3-PW1F.js +1 -0
  78. package/dist/chunks/commands-Bi7k3Wg-.js +1 -0
  79. package/dist/chunks/compact-J-h0Yf4b.js +2 -0
  80. package/dist/chunks/{config-CVvUNkj2.js → config-CVHMRMwd.js} +1 -1
  81. package/dist/chunks/config-Do1870_d.js +3 -0
  82. package/dist/chunks/config-yyFe87vW.js +1 -0
  83. package/dist/chunks/context-Tb1Ca2Q-.js +1 -0
  84. package/dist/chunks/{context-noninteractive-c7jGVWHQ.js → context-noninteractive-D5iQhasu.js} +2 -2
  85. package/dist/chunks/context-noninteractive-soPYKAc9.js +1 -0
  86. package/dist/chunks/conversation-CSEtUxOY.js +1 -0
  87. package/dist/chunks/conversation-Dk1WDQuN.js +1 -0
  88. package/dist/chunks/{createSSHSession-DP7B8yvb.js → createSSHSession-CJtzNQdZ.js} +1 -1
  89. package/dist/chunks/{createSession-CPo6GBSb.js → createSession-DkT1GL8y.js} +1 -1
  90. package/dist/chunks/createSession-eE8mswkv.js +1 -0
  91. package/dist/chunks/crossProjectResume-04n3Ppy9.js +40 -0
  92. package/dist/chunks/cwd-Cfdf7z7s.js +1 -0
  93. package/dist/chunks/cwd-ClLru_7T.js +1 -0
  94. package/dist/chunks/datadog-DjeJThpV.js +1 -0
  95. package/dist/chunks/{debug-BdqxZ7rV.js → debug-RAynG_nM.js} +1 -1
  96. package/dist/chunks/{debugUtils-CezNYZ-4.js → debugUtils-DX0KAXNK.js} +1 -1
  97. package/dist/chunks/{detached-CkPpYMJj.js → detached-X_yjYR7x.js} +1 -1
  98. package/dist/chunks/{detectRepository-DvxoaPlk.js → detectRepository-DgpNd87p.js} +1 -1
  99. package/dist/chunks/detectRepository-ctF9KDbb.js +1 -0
  100. package/dist/chunks/{diff-DHzz9WAp.js → diff-jEJJe58I.js} +1 -1
  101. package/dist/chunks/{directoryCompletion-D5AvL7TF.js → directoryCompletion-BbXR2bfy.js} +1 -1
  102. package/dist/chunks/doctor-B-Wag4C1.js +1 -0
  103. package/dist/chunks/earlyInput-BEjRkAtH.js +1 -0
  104. package/dist/chunks/{earlyInput-BTC_Wucv.js → earlyInput-IghoCjG5.js} +1 -1
  105. package/dist/chunks/entry-oIqjxIjQ.js +14 -0
  106. package/dist/chunks/esm-Cf4nSRjF.js +1 -0
  107. package/dist/chunks/{execFileNoThrow-5SylUnAI.js → execFileNoThrow-Dwu6psHW.js} +1 -1
  108. package/dist/chunks/{execSyncWrapper-DKuxVTaf.js → execSyncWrapper-BTZJjCuv.js} +1 -1
  109. package/dist/chunks/exit-BtW7LfRX.js +1 -0
  110. package/dist/chunks/{extraUsage-Dt5mw35U.js → extraUsage-Mi66JwFZ.js} +1 -1
  111. package/dist/chunks/extractMemories-CUrdiNcr.js +1 -0
  112. package/dist/chunks/{fast-ClYQcEv5.js → fast-BU4iUZ8E.js} +1 -1
  113. package/dist/chunks/fast-C60p6AqJ.js +1 -0
  114. package/dist/chunks/featureCheck-D6FjD-nt.js +1 -0
  115. package/dist/chunks/featureCheck-JOur3pHb.js +1 -0
  116. package/dist/chunks/{fileSuggestions-fNxREjpe.js → fileSuggestions-BMfQIDdW.js} +1 -1
  117. package/dist/chunks/firstPartyEventLogger-B3cXgR67.js +5 -0
  118. package/dist/chunks/firstPartyEventLogger-BfCYN7lt.js +1 -0
  119. package/dist/chunks/flushGate-DgSDVGKZ.js +1 -0
  120. package/dist/chunks/gemini-BwvSxGgn.js +1 -0
  121. package/dist/chunks/{generateSessionName-nZj_VvKZ.js → generateSessionName-DlrdedOk.js} +1 -1
  122. package/dist/chunks/{genericProcessUtils-BmDSLcMf.js → genericProcessUtils-CmsUPyRz.js} +1 -1
  123. package/dist/chunks/{git-B9uvt96d.js → git-2c7WlGDL.js} +1 -1
  124. package/dist/chunks/git-XtKbtJMc.js +1 -0
  125. package/dist/chunks/{githubRepoPathMapping-Cqx3pSfc.js → githubRepoPathMapping-DbWG4hFQ.js} +1 -1
  126. package/dist/chunks/goal-ZmSRBx4q.js +3 -0
  127. package/dist/chunks/{grok-Dk3LyzMa.js → grok-BXMvezWb.js} +1 -1
  128. package/dist/chunks/{grove-BE4fQ6tG.js → grove-CeOjTaY6.js} +1 -1
  129. package/dist/chunks/help-5DNZO6_H.js +1 -0
  130. package/dist/chunks/{hooks-BrKy5XWQ.js → hooks-C637tFtd.js} +2 -2
  131. package/dist/chunks/hooks-DWg07LmS.js +1 -0
  132. package/dist/chunks/initReplBridge-D1h10vQ9.js +1 -0
  133. package/dist/chunks/{install-CVGZ55wV.js → install-C-6ItpH0.js} +1 -1
  134. package/dist/chunks/{instrumentation-BmWotlxR.js → instrumentation-DaiPDUst.js} +4 -4
  135. package/dist/chunks/intl-D2kgJmX7.js +1 -0
  136. package/dist/chunks/{job-DEXxW_Zo.js → job-BeYzQUiR.js} +1 -1
  137. package/dist/chunks/{jwtUtils-C9sdGhvT.js → jwtUtils-CUPXdX3W.js} +1 -1
  138. package/dist/chunks/keybindings-DgIPdBy9.js +2 -0
  139. package/dist/chunks/{launchLocalMemory-CLSSVFoj.js → launchLocalMemory-CE4J98xO.js} +2 -2
  140. package/dist/chunks/{launchOnboarding-BkJfKviO.js → launchOnboarding-BfTdC6vp.js} +1 -1
  141. package/dist/chunks/{loadAgentsDir-CKSb56Gp.js → loadAgentsDir-C7lOqvfh.js} +2194 -2329
  142. package/dist/chunks/loadAgentsDir-zikjxLvn.js +1 -0
  143. package/dist/chunks/loadPluginHooks-Cp8MSwAc.js +1 -0
  144. package/dist/chunks/{localSearch-CPOnyi8I.js → localSearch-BKrznW5x.js} +1 -1
  145. package/dist/chunks/localSearch-ZFyFy5FN.js +1 -0
  146. package/dist/chunks/log-CezCRpAN.js +1 -0
  147. package/dist/chunks/{logoV2Utils-we1sfJvf.js → logoV2Utils-BkQfyQ1-.js} +1 -1
  148. package/dist/chunks/{magicDocs-DmKlTQvK.js → magicDocs-BpVcON9o.js} +2 -2
  149. package/dist/chunks/{main-BIiwW4mM.js → main-9r5gLzUW.js} +55 -55
  150. package/dist/chunks/{main-ClXu1ilx.js → main-CvOv59-7.js} +4 -4
  151. package/dist/chunks/managedEnv-B61yLpwp.js +1 -0
  152. package/dist/chunks/{managedEnv-Cl7YbYzf.js → managedEnv-DhWRJ5DK.js} +1 -1
  153. package/dist/chunks/{mappers-xQC-Z4-h.js → mappers-bOab8ipV.js} +1 -1
  154. package/dist/chunks/mcp-BckPBjaM.js +6 -0
  155. package/dist/chunks/mcp-CS1DA3JL.js +1 -0
  156. package/dist/chunks/mcp-VcGPYCkW.js +2 -0
  157. package/dist/chunks/{memoize-FJv2HV1u.js → memoize-DsqYrbeR.js} +1 -1
  158. package/dist/chunks/memory-C5ohwh-T.js +1 -0
  159. package/dist/chunks/{mode-lYTs0XHs.js → mode-DlKnUM8l.js} +2 -2
  160. package/dist/chunks/model-BGu1AGq0.js +1 -0
  161. package/dist/chunks/model-BsZ4sP_H.js +1 -0
  162. package/dist/chunks/model-D19IIcll.js +1 -0
  163. package/dist/chunks/{modelOptions-efCGKnXT.js → modelOptions-CxP067Qv.js} +1 -1
  164. package/dist/chunks/nativeInstaller-QB8cEJ18.js +1 -0
  165. package/dist/chunks/omit-DDUIPHnl.js +1 -0
  166. package/dist/chunks/onChangeAppState-RBl6H7ho.js +1 -0
  167. package/dist/chunks/{openai-DJLYqiRl.js → openai-B9C2XN5Q.js} +3 -3
  168. package/dist/chunks/{panel-q0_iT9cg.js → panel-KW-wmEvU.js} +1 -1
  169. package/dist/chunks/{parser-BdCj2GrE.js → parser-BwPXQomy.js} +1 -1
  170. package/dist/chunks/parser-xSBaQRLH.js +1 -0
  171. package/dist/chunks/partition-D-UhsUCx.js +1 -0
  172. package/dist/chunks/permissions-BoLXYN1j.js +3 -0
  173. package/dist/chunks/{pidLock-BR5M6RQw.js → pidLock-nJHbufJN.js} +2 -2
  174. package/dist/chunks/plan-CyU2zrCK.js +1 -0
  175. package/dist/chunks/{platform-D6IMiyqT.js → platform-BMPbglug.js} +1 -1
  176. package/dist/chunks/plugin-C6-GQke5.js +17 -0
  177. package/dist/chunks/pluginAutoupdate-SlRFJlTT.js +1 -0
  178. package/dist/chunks/pluginBlocklist-n6Imlh3y.js +1 -0
  179. package/dist/chunks/pluginCliCommands-Bd96zSOQ.js +1 -0
  180. package/dist/chunks/{pluginFlagging-CxuRF2Vc.js → pluginFlagging-DZaYzecY.js} +1 -1
  181. package/dist/chunks/pluginOperations-D90IRawu.js +2 -0
  182. package/dist/chunks/pluginStartupCheck-Bxkxpm4k.js +1 -0
  183. package/dist/chunks/{pluginStartupCheck-B6leNWq9.js → pluginStartupCheck-CB2q2dLv.js} +1 -1
  184. package/dist/chunks/plugins-B9eSjLSA.js +4 -0
  185. package/dist/chunks/poorMode-BAnubpn1.js +1 -0
  186. package/dist/chunks/{poorMode-BxsyllUK.js → poorMode-DEwQOAJt.js} +1 -1
  187. package/dist/chunks/print-eCRv_Li-.js +26 -0
  188. package/dist/chunks/processBashCommand-B5F2Cl7K.js +1 -0
  189. package/dist/chunks/processSlashCommand-BC_D3cH5.js +5 -0
  190. package/dist/chunks/prompt-C1JPqinc.js +1 -0
  191. package/dist/chunks/prompt-DZhBz_Vu.js +1 -0
  192. package/dist/chunks/{prompt-CybUvG8G.js → prompt-M2lu8_Oa.js} +34 -34
  193. package/dist/chunks/{promptEditor-0Ug93P2I.js → promptEditor-DhcZY-iu.js} +2 -2
  194. package/dist/chunks/{protocolHandler-ClfbHTjI.js → protocolHandler-CkFaJKKo.js} +1 -1
  195. package/dist/chunks/{proxy-Blq4W6Ox.js → proxy-CuMaO_YV.js} +1 -1
  196. package/dist/chunks/reconciler-B4GDm_iC.js +1 -0
  197. package/dist/chunks/refresh-DBVizOzg.js +1 -0
  198. package/dist/chunks/{registerProtocol-3_ozAuDK.js → registerProtocol-CsNYRZKr.js} +1 -1
  199. package/dist/chunks/{reload-plugins-Dn1ibOiI.js → reload-plugins-B7JAE3b4.js} +1 -1
  200. package/dist/chunks/{remoteBridgeCore-Dpg6Se9C.js → remoteBridgeCore-CFLJhsB6.js} +1 -1
  201. package/dist/chunks/{remoteManagedSettings-CCrq-qL-.js → remoteManagedSettings-xh_MViZH.js} +1 -1
  202. package/dist/chunks/rename-BCp2Vtqu.js +1 -0
  203. package/dist/chunks/{renderOptions-CLcco6fc.js → renderOptions-Q5oCLFIC.js} +1 -1
  204. package/dist/chunks/resume-DVCSzKvv.js +2 -0
  205. package/dist/chunks/{ripgrep-DkL2S7-I.js → ripgrep-DvOOsDMv.js} +1 -1
  206. package/dist/chunks/ripgrep-e-iewvTf.js +1 -0
  207. package/dist/chunks/{runtimeObserver-DonWCJOx.js → runtimeObserver-CS_3BDNo.js} +4 -4
  208. package/dist/chunks/{runtimeObserver-B0xfyLiA.js → runtimeObserver-DYUva6g-.js} +1 -1
  209. package/dist/chunks/sandbox-adapter-BFZFHplu.js +1 -0
  210. package/dist/chunks/{sandbox-toggle-CSdnHWp-.js → sandbox-toggle--zNSKce_.js} +1 -1
  211. package/dist/chunks/searchExtraTools-ui5y2VSE.js +1 -0
  212. package/dist/chunks/{session-BbQlh2S5.js → session-CO3gEqQP.js} +2 -2
  213. package/dist/chunks/sessionFileAccessHooks-CZvCqQJ6.js +1 -0
  214. package/dist/chunks/sessionObserver-Ba7um95p.js +1 -0
  215. package/dist/chunks/{sessionObserver-XV6N0XER.js → sessionObserver-YkRHC-Aa.js} +1 -1
  216. package/dist/chunks/sessionState-Bifmu95-.js +11 -0
  217. package/dist/chunks/sessionStorage-CedwLLQs.js +1 -0
  218. package/dist/chunks/{sessionTitle-E1FvsKM9.js → sessionTitle-COBSgSXS.js} +2 -2
  219. package/dist/chunks/{sessionTracing-ClGQ08jM.js → sessionTracing-BrNx1k2V.js} +2 -2
  220. package/dist/chunks/settings-DkDH7WQT.js +1 -0
  221. package/dist/chunks/{settings-Xbq6AaD-.js → settings-DnptdP79.js} +5 -5
  222. package/dist/chunks/settingsSync-PmU7SmkU.js +1 -0
  223. package/dist/chunks/setup-BEsBuzsk.js +3 -0
  224. package/dist/chunks/{shadowedRuleDetection-B9iSx6mB.js → shadowedRuleDetection-DEaw-X5j.js} +1 -1
  225. package/dist/chunks/{shellQuote-Bth6IZgX.js → shellQuote-BYeOv3Ip.js} +1 -1
  226. package/dist/chunks/{sideQuestion-D2dPToW8.js → sideQuestion-D0OKljee.js} +3 -3
  227. package/dist/chunks/sinks-BJHgxz6Y.js +1 -0
  228. package/dist/chunks/sinks-D5-yhcgU.js +2 -0
  229. package/dist/chunks/skillChangeDetector-Dd0WPdkO.js +1 -0
  230. package/dist/chunks/{skillGapStore-DylpOKJ6.js → skillGapStore-N_kmvXML.js} +2 -2
  231. package/dist/chunks/{skillLifecycle-GK-8eyyn.js → skillLifecycle-C4F5RXuh.js} +2 -2
  232. package/dist/chunks/{skillSearchPanel-mpaC62y4.js → skillSearchPanel-CftorvAM.js} +3 -3
  233. package/dist/chunks/{skills-t6krW8GZ.js → skills-C4CTRN9o.js} +1 -1
  234. package/dist/chunks/startupProfiler-D4FBdEQr.js +1 -0
  235. package/dist/chunks/{startupProfiler-jeId9f2i.js → startupProfiler-L_UWZ03w.js} +2 -2
  236. package/dist/chunks/state-BemZdQIl.js +1 -0
  237. package/dist/chunks/state-D_lk6z-C.js +1 -0
  238. package/dist/chunks/{stats-BJBhl-Lc.js → stats-IzV0_vEc.js} +1 -1
  239. package/dist/chunks/{status-BtsnKNVY.js → status-CeVP_uDT.js} +1 -1
  240. package/dist/chunks/status-Dzuw3hBv.js +2 -0
  241. package/dist/chunks/statusNoticeHelpers-Bb9gxdSt.js +1 -0
  242. package/dist/chunks/{stringUtils-CbS6OkmE.js → stringUtils-C84IJ91d.js} +1 -1
  243. package/dist/chunks/switcher-4KzBvuKH.js +1 -0
  244. package/dist/chunks/{switcher-77h2J5HC.js → switcher-CCs9xl1z.js} +1 -1
  245. package/dist/chunks/{syncCache-By_-buUC.js → syncCache-CBRiRU5x.js} +1 -1
  246. package/dist/chunks/{tasks-BNrdmF9p.js → tasks-DZDhgx0w.js} +1 -1
  247. package/dist/chunks/teleport-Bw0jSxe9.js +1 -0
  248. package/dist/chunks/{templateJobs-Dkv4I9c1.js → templateJobs-CrNPEKkh.js} +1 -1
  249. package/dist/chunks/{terminalSetup-DQopnSPR.js → terminalSetup-CBqcwQll.js} +1 -1
  250. package/dist/chunks/{terminalSetup-DTGm1Eo2.js → terminalSetup-D-N8YPiQ.js} +1 -1
  251. package/dist/chunks/{theme-BjpBVRf5.js → theme-Dazsirbw.js} +1 -1
  252. package/dist/chunks/{tmux-CMRiI6CD.js → tmux-DewYVEBm.js} +1 -1
  253. package/dist/chunks/{toolEventObserver-D-sNBvOe.js → toolEventObserver-lnHJ9fLQ.js} +1 -1
  254. package/dist/chunks/toolPool-CkXFlqsn.js +1 -0
  255. package/dist/chunks/{trustedDevice-j1u2TG5U.js → trustedDevice-CFf5yaG-.js} +1 -1
  256. package/dist/chunks/trustedDevice-CuwSv8dG.js +1 -0
  257. package/dist/chunks/{types-DWRxAH0E.js → types-3j8PS-Du.js} +1 -1
  258. package/dist/chunks/{udsClient-Cm3HqYUu.js → udsClient-e9dIkwVA.js} +1 -1
  259. package/dist/chunks/{updateCCB-BlUAU2Vp.js → updateCCB-BPe9_FW6.js} +1 -1
  260. package/dist/chunks/{upstreamproxy-DDVMwoRi.js → upstreamproxy-DF00RzGG.js} +1 -1
  261. package/dist/chunks/{useExitOnCtrlCDWithKeybindings-D2FvHieH.js → useExitOnCtrlCDWithKeybindings-ChqBs9Lr.js} +1 -1
  262. package/dist/chunks/useMainLoopModel-2-eujv0n.js +1 -0
  263. package/dist/chunks/useManagePlugins-CYBIkaB1.js +1 -0
  264. package/dist/chunks/{useMergedTools-B-Z9XQ6U.js → useMergedTools-Dk5cPqLc.js} +1 -1
  265. package/dist/chunks/{useSearchInput-C6d6nt9S.js → useSearchInput-C7Y1I9P9.js} +1 -1
  266. package/dist/chunks/useSettingsErrors-DAEO7AyB.js +1 -0
  267. package/dist/chunks/{userAgent-Ng_TTjWr.js → userAgent-CIq27vUR.js} +1 -1
  268. package/dist/chunks/util-VO98TdOz.js +1 -0
  269. package/dist/chunks/validatePlugin-Kk6pxnO2.js +1 -0
  270. package/dist/chunks/{vim-3mUqsEJm.js → vim-EYQn94Kx.js} +1 -1
  271. package/dist/chunks/{which-DznMOwny.js → which-DzFN5TNM.js} +1 -1
  272. package/dist/chunks/{windowsPaths-BVztIhXM.js → windowsPaths-BU3yQWTB.js} +1 -1
  273. package/dist/chunks/windowsPaths-DgZ3YY4a.js +1 -0
  274. package/dist/chunks/{workSecret-DtiFreRl.js → workSecret-DUqdPy44.js} +1 -1
  275. package/dist/chunks/workerRegistry-C07BcZIw.js +6 -0
  276. package/dist/chunks/worktree-dFUkhVE_.js +1 -0
  277. package/dist/cli.js +1 -1
  278. package/package.json +1 -1
  279. package/dist/chunks/App-DW4elk6E.js +0 -1
  280. package/dist/chunks/ApproveApiKey-D05WywHU.js +0 -1
  281. package/dist/chunks/BackgroundTasksDialog-QgFwoaaC.js +0 -2
  282. package/dist/chunks/ClaudeMdExternalIncludesDialog-DpecRCAt.js +0 -1
  283. package/dist/chunks/ConsoleOAuthFlow-D1MYL1dJ.js +0 -1
  284. package/dist/chunks/Doctor-D160J8Ad.js +0 -3
  285. package/dist/chunks/Doctor-VhJi2cmL.js +0 -1
  286. package/dist/chunks/ExitFlow-CoWHhKHJ.js +0 -2
  287. package/dist/chunks/MCPConnectionManager-DPFe4hPh.js +0 -1
  288. package/dist/chunks/MCPToolListView-BPmE0C2o.js +0 -1
  289. package/dist/chunks/MessageSelector-kOn2GaU-.js +0 -3
  290. package/dist/chunks/Messages-4EnHFeh1.js +0 -11
  291. package/dist/chunks/PromptInputHelpMenu-BvcAzbSi.js +0 -1
  292. package/dist/chunks/QueryEngine-J6ElcO16.js +0 -1
  293. package/dist/chunks/REPL-DBjbAJsm.js +0 -133
  294. package/dist/chunks/REPL-oBemMXvp.js +0 -1
  295. package/dist/chunks/RemoteSessionManager-CoIyFKKa.js +0 -2
  296. package/dist/chunks/ResumeConversation-wBG8OD9P.js +0 -1
  297. package/dist/chunks/SearchExtraToolsTool-BugrzImr.js +0 -1
  298. package/dist/chunks/Settings-DptKuJE7.js +0 -2
  299. package/dist/chunks/WelcomeV2-BWF-cJOu.js +0 -1
  300. package/dist/chunks/add-dir-DBVT1cEK.js +0 -1
  301. package/dist/chunks/agents-CnwTOlqO.js +0 -103
  302. package/dist/chunks/allErrors-DYw_q14e.js +0 -1
  303. package/dist/chunks/api-DXDXTFGa.js +0 -1
  304. package/dist/chunks/attributionTrailer-oKKrF3z8.js +0 -1
  305. package/dist/chunks/auth-CnLb6RWc.js +0 -1
  306. package/dist/chunks/auth-D-SGHS0K.js +0 -1
  307. package/dist/chunks/autonomy-dSJl0hN1.js +0 -15
  308. package/dist/chunks/backgroundHousekeeping--cs5crp7.js +0 -17
  309. package/dist/chunks/backgroundHousekeeping-CcbHitKC.js +0 -1
  310. package/dist/chunks/bg-DWloqGwk.js +0 -1
  311. package/dist/chunks/bridgeConfig-Dmc1ZDev.js +0 -1
  312. package/dist/chunks/bridgeMessaging-DlczTV9X.js +0 -1
  313. package/dist/chunks/caches-1IFb6_M_.js +0 -1
  314. package/dist/chunks/caches-CB8MHqy2.js +0 -1
  315. package/dist/chunks/client-Crrwkw7g.js +0 -1
  316. package/dist/chunks/client-D8hKghba.js +0 -1
  317. package/dist/chunks/color-Cuq0c6xy.js +0 -1
  318. package/dist/chunks/commands-D3sESsTp.js +0 -1
  319. package/dist/chunks/compact-DIpwuBDq.js +0 -2
  320. package/dist/chunks/config-D4G8_MqJ.js +0 -3
  321. package/dist/chunks/config-q9D4hFiK.js +0 -1
  322. package/dist/chunks/context-BWcfhhDj.js +0 -1
  323. package/dist/chunks/context-noninteractive-Bwt9A3XD.js +0 -1
  324. package/dist/chunks/conversation-Bjo_8kia.js +0 -1
  325. package/dist/chunks/conversation-DrHZIQX2.js +0 -1
  326. package/dist/chunks/createSession-DnykRoia.js +0 -1
  327. package/dist/chunks/crossProjectResume-D2A-qjgP.js +0 -40
  328. package/dist/chunks/cwd--q1ONL7P.js +0 -1
  329. package/dist/chunks/cwd-L4wygFqJ.js +0 -1
  330. package/dist/chunks/daemon-D2vFIVOz.js +0 -2
  331. package/dist/chunks/datadog-DrmHyl3_.js +0 -1
  332. package/dist/chunks/detectRepository-DA1Q_Skc.js +0 -1
  333. package/dist/chunks/doctor-PWqB46xd.js +0 -1
  334. package/dist/chunks/earlyInput-xcoTbKQn.js +0 -1
  335. package/dist/chunks/entry-4JtoJONR.js +0 -14
  336. package/dist/chunks/esm-DcIr7tVd.js +0 -1
  337. package/dist/chunks/exit-OW9g7b9A.js +0 -1
  338. package/dist/chunks/extractMemories-1VlmCGwa.js +0 -1
  339. package/dist/chunks/fast-CrvLdpy3.js +0 -1
  340. package/dist/chunks/featureCheck-CrJeuheQ.js +0 -1
  341. package/dist/chunks/featureCheck-HslM03dr.js +0 -1
  342. package/dist/chunks/firstPartyEventLogger-BBXEQUf0.js +0 -1
  343. package/dist/chunks/firstPartyEventLogger-DhEPWcit.js +0 -5
  344. package/dist/chunks/flushGate-ch-Tvwjj.js +0 -1
  345. package/dist/chunks/gemini-fZ0VPU2A.js +0 -1
  346. package/dist/chunks/generateRecap-BIBVlB__.js +0 -1
  347. package/dist/chunks/git-BfS5Hk4S.js +0 -1
  348. package/dist/chunks/goal-IasZVqKh.js +0 -3
  349. package/dist/chunks/help-D2-v9Ug9.js +0 -1
  350. package/dist/chunks/hooks-DGd02IKF.js +0 -1
  351. package/dist/chunks/initReplBridge-RhCAlmHE.js +0 -1
  352. package/dist/chunks/intl-cKc-V6Mq.js +0 -1
  353. package/dist/chunks/keybindings-BRdSOSUD.js +0 -2
  354. package/dist/chunks/language-C0cIpKE2.js +0 -1
  355. package/dist/chunks/language-CxThoWRC.js +0 -1
  356. package/dist/chunks/loadAgentsDir-8UprzS4w.js +0 -1
  357. package/dist/chunks/loadPluginHooks-LbaURHVH.js +0 -1
  358. package/dist/chunks/localSearch-DNjbr4S9.js +0 -1
  359. package/dist/chunks/log-CTFl4qpD.js +0 -1
  360. package/dist/chunks/managedEnv-CpiiQx_v.js +0 -1
  361. package/dist/chunks/mcp-B_m1XBDt.js +0 -6
  362. package/dist/chunks/mcp-BiyfH9Sd.js +0 -1
  363. package/dist/chunks/mcp-BjlaPUWX.js +0 -2
  364. package/dist/chunks/memory-LN8f_p2b.js +0 -1
  365. package/dist/chunks/model-C2e73CJD.js +0 -1
  366. package/dist/chunks/model-CvmS-Esk.js +0 -1
  367. package/dist/chunks/model-DJ8mFfuR.js +0 -1
  368. package/dist/chunks/nativeInstaller-DQIFwdat.js +0 -1
  369. package/dist/chunks/omit-CLPZGevl.js +0 -1
  370. package/dist/chunks/onChangeAppState-DhBO34OK.js +0 -1
  371. package/dist/chunks/panelCall-sum-3zvi.js +0 -1
  372. package/dist/chunks/parser-BcdhBGx0.js +0 -1
  373. package/dist/chunks/partition-CpfoVrg1.js +0 -1
  374. package/dist/chunks/permissions-DTb9wkAP.js +0 -3
  375. package/dist/chunks/pipeTransport-B3TIkTAp.js +0 -1
  376. package/dist/chunks/plan-BeoIjNPv.js +0 -1
  377. package/dist/chunks/plugin-D_dHjTud.js +0 -17
  378. package/dist/chunks/pluginAutoupdate-BHKlOOXI.js +0 -1
  379. package/dist/chunks/pluginBlocklist-D93Hd1GF.js +0 -1
  380. package/dist/chunks/pluginCliCommands-vv0wNt4O.js +0 -1
  381. package/dist/chunks/pluginOperations-BTq4AjYB.js +0 -2
  382. package/dist/chunks/pluginStartupCheck-DBOCHUHQ.js +0 -1
  383. package/dist/chunks/plugins-pmipe7kE.js +0 -4
  384. package/dist/chunks/poorMode-iV1NwC5L.js +0 -1
  385. package/dist/chunks/print-CAUvczBM.js +0 -23
  386. package/dist/chunks/processBashCommand-CdeQg_c6.js +0 -1
  387. package/dist/chunks/processSlashCommand-CbkshIC6.js +0 -5
  388. package/dist/chunks/prompt-RBn4JdEg.js +0 -1
  389. package/dist/chunks/prompt-Rb8zXlDo.js +0 -1
  390. package/dist/chunks/reconciler-Drq3HSkj.js +0 -4
  391. package/dist/chunks/refresh-D8TLHO_T.js +0 -1
  392. package/dist/chunks/rename-CKsSc7Z3.js +0 -1
  393. package/dist/chunks/replBridgeHandle-DNC797_T.js +0 -1
  394. package/dist/chunks/resume-B1a5gLVR.js +0 -2
  395. package/dist/chunks/ripgrep-BisRODQ2.js +0 -1
  396. package/dist/chunks/sandbox-adapter-BnBOSkKJ.js +0 -1
  397. package/dist/chunks/searchExtraTools-DbgfnQkH.js +0 -1
  398. package/dist/chunks/sessionFileAccessHooks-Xfr1NiXG.js +0 -1
  399. package/dist/chunks/sessionMemory-7UOFdp29.js +0 -1
  400. package/dist/chunks/sessionMemory-fAzgAS7Q.js +0 -1
  401. package/dist/chunks/sessionMemoryUtils-DVjFw5Bd.js +0 -1
  402. package/dist/chunks/sessionObserver-Cl26OdaW.js +0 -1
  403. package/dist/chunks/sessionState-BvECKycx.js +0 -11
  404. package/dist/chunks/sessionStorage-DSj9yZkl.js +0 -1
  405. package/dist/chunks/settings-B-R9ZJNY.js +0 -1
  406. package/dist/chunks/settingsSync-NCN0a4sc.js +0 -1
  407. package/dist/chunks/setup-uZ0dSekt.js +0 -3
  408. package/dist/chunks/sinks-C7q46rvE.js +0 -2
  409. package/dist/chunks/sinks-D3bXeHlQ.js +0 -1
  410. package/dist/chunks/skillChangeDetector-C1EJ7rUL.js +0 -1
  411. package/dist/chunks/startupProfiler-BaiXZ9tr.js +0 -1
  412. package/dist/chunks/state-B4HwLt8i.js +0 -1
  413. package/dist/chunks/state-Bs5xweDL.js +0 -1
  414. package/dist/chunks/status-nZQEar7T.js +0 -2
  415. package/dist/chunks/statusNoticeHelpers-DMqRGFOh.js +0 -1
  416. package/dist/chunks/switcher-B2CYzCC_.js +0 -1
  417. package/dist/chunks/teleport-mdnhIZBj.js +0 -1
  418. package/dist/chunks/toolPool-Di30gn_Y.js +0 -1
  419. package/dist/chunks/trustedDevice-CupLMpO8.js +0 -1
  420. package/dist/chunks/useMainLoopModel-ylPQNj7Z.js +0 -1
  421. package/dist/chunks/useManagePlugins-BbWJNLe8.js +0 -1
  422. package/dist/chunks/useSettingsErrors-DKh4rkGi.js +0 -1
  423. package/dist/chunks/util-D-X8i5Z2.js +0 -1
  424. package/dist/chunks/validatePlugin-DSw08u76.js +0 -1
  425. package/dist/chunks/windowsPaths-1mgenSWa.js +0 -1
  426. package/dist/chunks/workerRegistry-DdOYjLm3.js +0 -6
  427. package/dist/chunks/worktree-BX1ULzrw.js +0 -1
@@ -1,4 +1,4 @@
1
- import{d as e,o as t}from"./envUtils-BDhHQY0-.js";import{n,t as r}from"./defineProperty-C-QyHrDq.js";import{n as i,t as a}from"./axios-DaWTGg7G.js";import{aw as o,bf as s,iw as c,xf as l}from"./loadAgentsDir-CKSb56Gp.js";import{F as u,S as ee,a as te,l as d,w as ne,z as re}from"./debug-BdqxZ7rV.js";import{g as f,n as p}from"./settings-Xbq6AaD-.js";import{c as m,h,y as g}from"./config-D4G8_MqJ.js";import{o as _,s as v}from"./log-CTFl4qpD.js";import{n as y,r as b}from"./analytics-DJobLaWP.js";import{l as x,u as S}from"./oauth-C9VBDB0Y.js";import{$n as ie,Ar as ae,Br as C,Bt as w,Cn as oe,Dt as se,En as ce,Fr as T,Ft as E,Lr as D,Mr as O,Nr as k,Ot as A,Sn as j,St as M,Ur as N,Vr as P,Wr as F,ai as I,fn as L,gn as R,jn as z,jr as B,jt as V,kr as H,mn as U,nn as W,nr as G,pn as K,si as le,un as ue,yt as de,zr as fe}from"./model-C2e73CJD.js";import{n as pe,t as me}from"./userAgent-Ng_TTjWr.js";import{$ as q,U as he}from"./sessionState-BvECKycx.js";import{d as ge,u as _e}from"./firstPartyEventLogger-DhEPWcit.js";import{n as ve}from"./trustedDevice-j1u2TG5U.js";import{i as ye,r as be}from"./grove-BE4fQ6tG.js";import{t as xe}from"./remoteManagedSettings-CCrq-qL-.js";import{d as Se,n as Ce,t as we}from"./status-nZQEar7T.js";import{createHash as Te,randomBytes as J}from"crypto";import{createServer as Ee}from"http";l(),w(),z(),h(),oe(),R(),_e();async function Y(){A.cache?.clear?.(),ve(),ce(),U(),ge(),be.cache?.clear?.(),ye.cache?.clear?.(),await xe(),await s()}async function De({clearOnboarding:e=!1}){let{flushTelemetry:t}=await import(`./instrumentation-BmWotlxR.js`);await t(),await ue(),j().delete(),await Y(),g(t=>{let n={...t};return e&&(n.hasCompletedOnboarding=!1,n.subscriptionNoticeCount=0,n.hasAvailableSubscription=!1,n.customApiKeyResponses?.approved&&(n.customApiKeyResponses={...n.customApiKeyResponses,approved:[]})),n.oauthAccount=void 0,n})}t(),n(),re(),ee(),te(),y(),f(),le(),F(),T(),he(),a(),S(),h(),G(),_(),pe();async function Oe(){try{if(m().claudeCodeFirstTokenDate!==void 0)return;let e=ie();if(e.error){v(Error(`Failed to get auth headers: ${e.error}`));return}let t=`${x().BASE_API_URL}/api/organization/claude_code_first_token_date`,n=(await i.get(t,{headers:{...e.headers,"User-Agent":me()},timeout:1e4})).data?.first_token_date??null;if(n!==null){let e=new Date(n).getTime();if(isNaN(e)){v(Error(`Received invalid first_token_date from API: ${n}`));return}}g(e=>({...e,claudeCodeFirstTokenDate:n}))}catch(e){v(e)}}c(),S(),_();var ke=class{constructor(e=`/callback`){r(this,`localServer`,void 0),r(this,`port`,0),r(this,`promiseResolver`,null),r(this,`promiseRejecter`,null),r(this,`expectedState`,null),r(this,`pendingResponse`,null),r(this,`callbackPath`,void 0),this.localServer=Ee(),this.callbackPath=e}async start(e){return new Promise((t,n)=>{this.localServer.once(`error`,e=>{n(Error(`Failed to start OAuth callback server: ${e.message}`))}),this.localServer.listen(e??0,`localhost`,()=>{let e=this.localServer.address();this.port=e.port,t(this.port)})})}getPort(){return this.port}hasPendingResponse(){return this.pendingResponse!==null}async waitForAuthorization(e,t){return new Promise((n,r)=>{this.promiseResolver=n,this.promiseRejecter=r,this.expectedState=e,this.startLocalListener(t)})}handleSuccessRedirect(e,t){if(!this.pendingResponse)return;if(t){t(this.pendingResponse,e),this.pendingResponse=null,b(`tengu_oauth_automatic_redirect`,{custom_handler:!0});return}let n=C(e)?x().CLAUDEAI_SUCCESS_URL:x().CONSOLE_SUCCESS_URL;this.pendingResponse.writeHead(302,{Location:n}),this.pendingResponse.end(),this.pendingResponse=null,b(`tengu_oauth_automatic_redirect`,{})}handleErrorRedirect(){if(!this.pendingResponse)return;let e=x().CLAUDEAI_SUCCESS_URL;this.pendingResponse.writeHead(302,{Location:e}),this.pendingResponse.end(),this.pendingResponse=null,b(`tengu_oauth_automatic_redirect_error`,{})}startLocalListener(e){this.localServer.on(`request`,this.handleRedirect.bind(this)),this.localServer.on(`error`,this.handleError.bind(this)),e()}handleRedirect(e,t){let n=new URL(e.url||``,`http://${e.headers.host||`localhost`}`);if(n.pathname!==this.callbackPath){t.writeHead(404),t.end();return}let r=n.searchParams.get(`code`)??void 0,i=n.searchParams.get(`state`)??void 0;this.validateAndRespond(r,i,t)}validateAndRespond(e,t,n){if(!e){n.writeHead(400),n.end(`Authorization code not found`),this.reject(Error(`No authorization code received`));return}if(t!==this.expectedState){n.writeHead(400),n.end(`Invalid state parameter`),this.reject(Error(`Invalid state parameter`));return}this.pendingResponse=n,this.resolve(e)}handleError(e){v(e),this.close(),this.reject(e)}resolve(e){this.promiseResolver&&(this.promiseResolver(e),this.promiseResolver=null,this.promiseRejecter=null)}reject(e){this.promiseRejecter&&(this.promiseRejecter(e),this.promiseResolver=null,this.promiseRejecter=null)}close(){this.pendingResponse&&this.handleErrorRedirect(),this.localServer&&(this.localServer.removeAllListeners(),this.localServer.close())}};function X(e){return e.toString(`base64`).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=/g,``)}function Z(){return X(J(32))}function Ae(e){let t=Te(`sha256`);return t.update(e),X(t.digest())}function je(){return X(J(32))}y(),T(),n();var Q=class{constructor(){r(this,`codeVerifier`,void 0),r(this,`authCodeListener`,null),r(this,`port`,null),r(this,`manualAuthCodeResolver`,null),this.codeVerifier=Z()}async startOAuthFlow(e,t){this.authCodeListener=new ke,this.port=await this.authCodeListener.start();let n=Ae(this.codeVerifier),r=je(),i={codeChallenge:n,state:r,port:this.port,loginWithClaudeAi:t?.loginWithClaudeAi,inferenceOnly:t?.inferenceOnly,orgUUID:t?.orgUUID,loginHint:t?.loginHint,loginMethod:t?.loginMethod},a=H({...i,isManual:!0}),s=H({...i,isManual:!1}),c=await this.waitForAuthorizationCode(r,async()=>{t?.skipBrowserOpen?await e(a,s):(await e(a),await o(s))}),l=this.authCodeListener?.hasPendingResponse()??!1;b(`tengu_oauth_auth_code_received`,{automatic:l});try{let e=await B(c,r,this.codeVerifier,this.port,!l,t?.expiresIn),n=await k(e.access_token);if(l){let t=D(e.scope);this.authCodeListener?.handleSuccessRedirect(t)}return this.formatTokens(e,n.subscriptionType,n.rateLimitTier,n.rawProfile)}catch(e){throw l&&this.authCodeListener?.handleErrorRedirect(),e}finally{this.authCodeListener?.close()}}async waitForAuthorizationCode(e,t){return new Promise((n,r)=>{this.manualAuthCodeResolver=n,this.authCodeListener?.waitForAuthorization(e,t).then(e=>{this.manualAuthCodeResolver=null,n(e)}).catch(e=>{this.manualAuthCodeResolver=null,r(e)})})}handleManualAuthCodeInput(e){this.manualAuthCodeResolver&&(this.manualAuthCodeResolver(e.authorizationCode),this.manualAuthCodeResolver=null,this.authCodeListener?.close())}formatTokens(e,t,n,r){return{accessToken:e.access_token,refreshToken:e.refresh_token,expiresAt:Date.now()+e.expires_in*1e3,scopes:D(e.scope),subscriptionType:t,rateLimitTier:n,profile:r,tokenAccount:e.account?{uuid:e.account.uuid,emailAddress:e.account.email_address,organizationUuid:e.organization?.uuid}:void 0}}cleanup(){this.authCodeListener?.close(),this.manualAuthCodeResolver=null}};y(),T(),w(),h(),_(),Se();async function $(e){await De({clearOnboarding:!1});let t=e.profile??await N(e.accessToken);t?P({accountUuid:t.account.uuid,emailAddress:t.account.email,organizationUuid:t.organization.uuid,displayName:t.account.display_name||void 0,hasExtraUsageEnabled:t.organization.has_extra_usage_enabled??void 0,billingType:t.organization.billing_type??void 0,subscriptionCreatedAt:t.organization.subscription_created_at??void 0,accountCreatedAt:t.account.created_at}):e.tokenAccount&&P({accountUuid:e.tokenAccount.uuid,emailAddress:e.tokenAccount.emailAddress,organizationUuid:e.tokenAccount.organizationUuid});let n=L(e);if(de(),n.warning&&b(`tengu_oauth_storage_warning`,{warning:n.warning}),await O(e.accessToken).catch(e=>d(String(e),{level:`error`})),C(e.scopes))await Oe().catch(e=>d(String(e),{level:`error`}));else if(!await ae(e.accessToken))throw Error(`Unable to create API key. The server accepted the request but did not return a key.`);await Y()}async function Me({email:e,sso:t,console:n,claudeai:r}){n&&r&&(process.stderr.write(`Error: --console and --claudeai cannot be used together.
1
+ import{d as e,o as t}from"./envUtils-BDhHQY0-.js";import{n,t as r}from"./defineProperty-C-QyHrDq.js";import{n as i,t as a}from"./axios-DaWTGg7G.js";import{LS as o,RS as s,df as c,ff as l}from"./loadAgentsDir-C7lOqvfh.js";import{F as u,S as ee,a as te,l as d,w as ne,z as re}from"./debug-RAynG_nM.js";import{g as f,n as p}from"./settings-DnptdP79.js";import{c as m,h,y as g}from"./config-Do1870_d.js";import{o as _,s as v}from"./log-CezCRpAN.js";import{n as y,r as b}from"./analytics-DJobLaWP.js";import{l as x,u as S}from"./oauth-C9VBDB0Y.js";import{$n as ie,Ar as ae,Br as C,Bt as w,Cn as oe,Dt as se,En as ce,Fr as T,Ft as E,Lr as D,Mr as O,Nr as k,Ot as A,Sn as j,St as M,Ur as N,Vr as P,Wr as F,ai as I,fn as L,gn as R,jn as z,jr as B,jt as V,kr as H,mn as U,nn as W,nr as G,pn as K,si as le,un as ue,yt as de,zr as fe}from"./model-BsZ4sP_H.js";import{n as pe,t as me}from"./userAgent-CIq27vUR.js";import{H as q,M as he}from"./sessionState-Bifmu95-.js";import{d as ge,u as _e}from"./firstPartyEventLogger-B3cXgR67.js";import{n as ve}from"./trustedDevice-CFf5yaG-.js";import{i as ye,r as be}from"./grove-CeOjTaY6.js";import{t as xe}from"./remoteManagedSettings-xh_MViZH.js";import{d as Se,n as Ce,t as we}from"./status-Dzuw3hBv.js";import{createHash as Te,randomBytes as J}from"crypto";import{createServer as Ee}from"http";l(),w(),z(),h(),oe(),R(),_e();async function Y(){A.cache?.clear?.(),ve(),ce(),U(),ge(),be.cache?.clear?.(),ye.cache?.clear?.(),await xe(),await c()}async function De({clearOnboarding:e=!1}){let{flushTelemetry:t}=await import(`./instrumentation-DaiPDUst.js`);await t(),await ue(),j().delete(),await Y(),g(t=>{let n={...t};return e&&(n.hasCompletedOnboarding=!1,n.subscriptionNoticeCount=0,n.hasAvailableSubscription=!1,n.customApiKeyResponses?.approved&&(n.customApiKeyResponses={...n.customApiKeyResponses,approved:[]})),n.oauthAccount=void 0,n})}t(),n(),re(),ee(),te(),y(),f(),le(),F(),T(),he(),a(),S(),h(),G(),_(),pe();async function Oe(){try{if(m().claudeCodeFirstTokenDate!==void 0)return;let e=ie();if(e.error){v(Error(`Failed to get auth headers: ${e.error}`));return}let t=`${x().BASE_API_URL}/api/organization/claude_code_first_token_date`,n=(await i.get(t,{headers:{...e.headers,"User-Agent":me()},timeout:1e4})).data?.first_token_date??null;if(n!==null){let e=new Date(n).getTime();if(isNaN(e)){v(Error(`Received invalid first_token_date from API: ${n}`));return}}g(e=>({...e,claudeCodeFirstTokenDate:n}))}catch(e){v(e)}}o(),S(),_();var ke=class{constructor(e=`/callback`){r(this,`localServer`,void 0),r(this,`port`,0),r(this,`promiseResolver`,null),r(this,`promiseRejecter`,null),r(this,`expectedState`,null),r(this,`pendingResponse`,null),r(this,`callbackPath`,void 0),this.localServer=Ee(),this.callbackPath=e}async start(e){return new Promise((t,n)=>{this.localServer.once(`error`,e=>{n(Error(`Failed to start OAuth callback server: ${e.message}`))}),this.localServer.listen(e??0,`localhost`,()=>{let e=this.localServer.address();this.port=e.port,t(this.port)})})}getPort(){return this.port}hasPendingResponse(){return this.pendingResponse!==null}async waitForAuthorization(e,t){return new Promise((n,r)=>{this.promiseResolver=n,this.promiseRejecter=r,this.expectedState=e,this.startLocalListener(t)})}handleSuccessRedirect(e,t){if(!this.pendingResponse)return;if(t){t(this.pendingResponse,e),this.pendingResponse=null,b(`tengu_oauth_automatic_redirect`,{custom_handler:!0});return}let n=C(e)?x().CLAUDEAI_SUCCESS_URL:x().CONSOLE_SUCCESS_URL;this.pendingResponse.writeHead(302,{Location:n}),this.pendingResponse.end(),this.pendingResponse=null,b(`tengu_oauth_automatic_redirect`,{})}handleErrorRedirect(){if(!this.pendingResponse)return;let e=x().CLAUDEAI_SUCCESS_URL;this.pendingResponse.writeHead(302,{Location:e}),this.pendingResponse.end(),this.pendingResponse=null,b(`tengu_oauth_automatic_redirect_error`,{})}startLocalListener(e){this.localServer.on(`request`,this.handleRedirect.bind(this)),this.localServer.on(`error`,this.handleError.bind(this)),e()}handleRedirect(e,t){let n=new URL(e.url||``,`http://${e.headers.host||`localhost`}`);if(n.pathname!==this.callbackPath){t.writeHead(404),t.end();return}let r=n.searchParams.get(`code`)??void 0,i=n.searchParams.get(`state`)??void 0;this.validateAndRespond(r,i,t)}validateAndRespond(e,t,n){if(!e){n.writeHead(400),n.end(`Authorization code not found`),this.reject(Error(`No authorization code received`));return}if(t!==this.expectedState){n.writeHead(400),n.end(`Invalid state parameter`),this.reject(Error(`Invalid state parameter`));return}this.pendingResponse=n,this.resolve(e)}handleError(e){v(e),this.close(),this.reject(e)}resolve(e){this.promiseResolver&&(this.promiseResolver(e),this.promiseResolver=null,this.promiseRejecter=null)}reject(e){this.promiseRejecter&&(this.promiseRejecter(e),this.promiseResolver=null,this.promiseRejecter=null)}close(){this.pendingResponse&&this.handleErrorRedirect(),this.localServer&&(this.localServer.removeAllListeners(),this.localServer.close())}};function X(e){return e.toString(`base64`).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=/g,``)}function Z(){return X(J(32))}function Ae(e){let t=Te(`sha256`);return t.update(e),X(t.digest())}function je(){return X(J(32))}y(),T(),n();var Q=class{constructor(){r(this,`codeVerifier`,void 0),r(this,`authCodeListener`,null),r(this,`port`,null),r(this,`manualAuthCodeResolver`,null),this.codeVerifier=Z()}async startOAuthFlow(e,t){this.authCodeListener=new ke,this.port=await this.authCodeListener.start();let n=Ae(this.codeVerifier),r=je(),i={codeChallenge:n,state:r,port:this.port,loginWithClaudeAi:t?.loginWithClaudeAi,inferenceOnly:t?.inferenceOnly,orgUUID:t?.orgUUID,loginHint:t?.loginHint,loginMethod:t?.loginMethod},a=H({...i,isManual:!0}),o=H({...i,isManual:!1}),c=await this.waitForAuthorizationCode(r,async()=>{t?.skipBrowserOpen?await e(a,o):(await e(a),await s(o))}),l=this.authCodeListener?.hasPendingResponse()??!1;b(`tengu_oauth_auth_code_received`,{automatic:l});try{let e=await B(c,r,this.codeVerifier,this.port,!l,t?.expiresIn),n=await k(e.access_token);if(l){let t=D(e.scope);this.authCodeListener?.handleSuccessRedirect(t)}return this.formatTokens(e,n.subscriptionType,n.rateLimitTier,n.rawProfile)}catch(e){throw l&&this.authCodeListener?.handleErrorRedirect(),e}finally{this.authCodeListener?.close()}}async waitForAuthorizationCode(e,t){return new Promise((n,r)=>{this.manualAuthCodeResolver=n,this.authCodeListener?.waitForAuthorization(e,t).then(e=>{this.manualAuthCodeResolver=null,n(e)}).catch(e=>{this.manualAuthCodeResolver=null,r(e)})})}handleManualAuthCodeInput(e){this.manualAuthCodeResolver&&(this.manualAuthCodeResolver(e.authorizationCode),this.manualAuthCodeResolver=null,this.authCodeListener?.close())}formatTokens(e,t,n,r){return{accessToken:e.access_token,refreshToken:e.refresh_token,expiresAt:Date.now()+e.expires_in*1e3,scopes:D(e.scope),subscriptionType:t,rateLimitTier:n,profile:r,tokenAccount:e.account?{uuid:e.account.uuid,emailAddress:e.account.email_address,organizationUuid:e.organization?.uuid}:void 0}}cleanup(){this.authCodeListener?.close(),this.manualAuthCodeResolver=null}};y(),T(),w(),h(),_(),Se();async function $(e){await De({clearOnboarding:!1});let t=e.profile??await N(e.accessToken);t?P({accountUuid:t.account.uuid,emailAddress:t.account.email,organizationUuid:t.organization.uuid,displayName:t.account.display_name||void 0,hasExtraUsageEnabled:t.organization.has_extra_usage_enabled??void 0,billingType:t.organization.billing_type??void 0,subscriptionCreatedAt:t.organization.subscription_created_at??void 0,accountCreatedAt:t.account.created_at}):e.tokenAccount&&P({accountUuid:e.tokenAccount.uuid,emailAddress:e.tokenAccount.emailAddress,organizationUuid:e.tokenAccount.organizationUuid});let n=L(e);if(de(),n.warning&&b(`tengu_oauth_storage_warning`,{warning:n.warning}),await O(e.accessToken).catch(e=>d(String(e),{level:`error`})),C(e.scopes))await Oe().catch(e=>d(String(e),{level:`error`}));else if(!await ae(e.accessToken))throw Error(`Unable to create API key. The server accepted the request but did not return a key.`);await Y()}async function Me({email:e,sso:t,console:n,claudeai:r}){n&&r&&(process.stderr.write(`Error: --console and --claudeai cannot be used together.
2
2
  `),process.exit(1));let i=p(),a=i.forceLoginMethod?i.forceLoginMethod===`claudeai`:!n,o=i.forceLoginOrgUUID,s=process.env.CLAUDE_CODE_OAUTH_REFRESH_TOKEN;if(s){let e=process.env.CLAUDE_CODE_OAUTH_SCOPES;e||(process.stderr.write(`CLAUDE_CODE_OAUTH_SCOPES is required when using CLAUDE_CODE_OAUTH_REFRESH_TOKEN.
3
3
  Set it to the space-separated scopes the refresh token was issued with
4
4
  (e.g. "user:inference" or "user:profile user:inference user:sessions:claude_code user:mcp_servers").
@@ -0,0 +1 @@
1
+ import{Bt as e,It as t,Ot as n,mt as r,yt as i}from"./model-BsZ4sP_H.js";e();export{r as checkAndRefreshOAuthTokenIfNeeded,i as clearOAuthTokenCache,n as getClaudeAIOAuthTokens,t as handleOAuth401Error};
@@ -0,0 +1 @@
1
+ import{n as e,t}from"./auth-5QB6tsfB.js";export{t as authLogin,e as authStatus};
@@ -1,5 +1,5 @@
1
- import{Bm as e,Im as t,Lm as n,Rm as r,zm as i}from"./loadAgentsDir-CKSb56Gp.js";import{F as a,S as o,w as s,z as c}from"./debug-BdqxZ7rV.js";import{g as l,t as u}from"./settings-Xbq6AaD-.js";import{C as d,_ as f,h as p,u as m}from"./model-C2e73CJD.js";import{n as h,t as g}from"./poorMode-BxsyllUK.js";c(),f(),r(),l(),g(),i(),o();function _(e){process.stdout.write(s(e,null,2)+`
2
- `)}function v(){_(n())}function y(){let e=u(),t=n();_({allow:e?.allow?.length?e.allow:t.allow,soft_deny:e?.soft_deny?.length?e.soft_deny:t.soft_deny,environment:e?.environment?.length?e.environment:t.environment})}var b=`You are an expert reviewer of auto mode classifier rules for Work Mate.
1
+ import{$p as e,DT as t,ET as n,em as r,tm as i}from"./loadAgentsDir-C7lOqvfh.js";import{F as a,S as o,w as s,z as c}from"./debug-RAynG_nM.js";import{g as l,t as u}from"./settings-DnptdP79.js";import{C as d,_ as f,h as p,u as m}from"./model-BsZ4sP_H.js";import{n as h,t as g}from"./poorMode-DEwQOAJt.js";c(),f(),i(),l(),g(),n(),o();function _(e){process.stdout.write(s(e,null,2)+`
2
+ `)}function v(){_(r())}function y(){let e=u(),t=r();_({allow:e?.allow?.length?e.allow:t.allow,soft_deny:e?.soft_deny?.length?e.soft_deny:t.soft_deny,environment:e?.environment?.length?e.environment:t.environment})}var b=`You are an expert reviewer of auto mode classifier rules for Work Mate.
3
3
 
4
4
  Work Mate has an "auto mode" that uses an AI classifier to decide whether tool calls should be auto-approved or require user confirmation. Users can write custom rules in three categories:
5
5
 
@@ -15,13 +15,13 @@ For each rule, evaluate:
15
15
  3. **Conflicts**: Do any of the rules conflict with each other?
16
16
  4. **Actionability**: Is the rule specific enough for the classifier to act on?
17
17
 
18
- Be concise and constructive. Only comment on rules that could be improved. If all rules look good, say so.`;async function x(r){let i=u();if(!((i?.allow?.length??0)>0||(i?.soft_deny?.length??0)>0||(i?.environment?.length??0)>0)){process.stdout.write(`No custom auto mode rules found.
18
+ Be concise and constructive. Only comment on rules that could be improved. If all rules look good, say so.`;async function x(n){let i=u();if(!((i?.allow?.length??0)>0||(i?.soft_deny?.length??0)>0||(i?.environment?.length??0)>0)){process.stdout.write(`No custom auto mode rules found.
19
19
 
20
20
  Add rules to your settings file under autoMode.{allow, soft_deny, environment}.
21
21
  Run \`claude auto-mode defaults\` to see the default rules for reference.
22
- `);return}let o=r.model?d(r.model):h()?p():m(),s=n(),c=t(),l=S(`allow`,i?.allow??[],s.allow)+S(`soft_deny`,i?.soft_deny??[],s.soft_deny)+S(`environment`,i?.environment??[],s.environment);process.stdout.write(`Analyzing your auto mode rules…
22
+ `);return}let o=n.model?d(n.model):h()?p():m(),s=r(),c=e(),l=S(`allow`,i?.allow??[],s.allow)+S(`soft_deny`,i?.soft_deny??[],s.soft_deny)+S(`environment`,i?.environment??[],s.environment);process.stdout.write(`Analyzing your auto mode rules…
23
23
 
24
- `);let f;try{f=await e({querySource:`auto_mode_critique`,model:o,system:b,skipSystemPromptPrefix:!0,max_tokens:4096,messages:[{role:`user`,content:`Here is the full classifier system prompt that the auto mode classifier receives:
24
+ `);let f;try{f=await t({querySource:`auto_mode_critique`,model:o,system:b,skipSystemPromptPrefix:!0,max_tokens:4096,messages:[{role:`user`,content:`Here is the full classifier system prompt that the auto mode classifier receives:
25
25
 
26
26
  <classifier_system_prompt>
27
27
  `+c+`
@@ -1 +1 @@
1
- import{a as e,c as t,i as n,m as r,n as i,o as a,r as o,t as s}from"./autonomy-dSJl0hN1.js";r();export{s as autonomyFlowCancelHandler,i as autonomyFlowHandler,o as autonomyFlowResumeHandler,n as autonomyFlowsHandler,e as autonomyRunsHandler,a as autonomyStatusHandler,t as getAutonomyCommandText};
1
+ import{a as e,c as t,i as n,m as r,n as i,o as a,r as o,t as s}from"./autonomy-Src6sKCp.js";r();export{s as autonomyFlowCancelHandler,i as autonomyFlowHandler,o as autonomyFlowResumeHandler,n as autonomyFlowsHandler,e as autonomyRunsHandler,a as autonomyStatusHandler,t as getAutonomyCommandText};
@@ -0,0 +1,15 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,o as n}from"./envUtils-BDhHQY0-.js";import{Bm as r,C as i,E as a,El as ee,Gm as o,Hm as te,Im as s,Iy as ne,Jm as re,Km as c,Lm as l,Rm as u,Tl as d,Ty as f,Um as p,Vm as m,Wm as h,jy as g,qm as _,wl as ie,x as ae,zm as v}from"./loadAgentsDir-C7lOqvfh.js";import{Wt as oe,it as se}from"./state-BemZdQIl.js";import{o as ce}from"./log-CezCRpAN.js";import{s as le,u as ue}from"./types-3j8PS-Du.js";import{a as y,n as b,o as x,t as S}from"./bridgeConfig-Bb6URf4Q.js";import{i as C,o as w}from"./bg-DAPORXF3.js";import{n as T,t as E}from"./state-BAGmpVBn.js";import{join as D}from"path";import"crypto";import{readFile as O,readdir as k}from"fs/promises";import"net";import"events";function A(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function j(e){return typeof e==`string`&&B.includes(e)}function M(e){return typeof e==`string`&&V.includes(e)}function N(e){return!A(e)||typeof e.name!=`string`||!M(e.status)?null:{name:e.name,...typeof e.prompt==`string`?{prompt:e.prompt}:{},status:e.status,...typeof e.startedAt==`number`?{startedAt:e.startedAt}:{},...typeof e.completedAt==`number`?{completedAt:e.completedAt}:{}}}function P(e){if(!A(e)||typeof e.runId!=`string`||typeof e.workflow!=`string`||!j(e.status)||typeof e.createdAt!=`number`||typeof e.updatedAt!=`number`||typeof e.currentStepIndex!=`number`||!Array.isArray(e.steps))return null;let t=e.steps.map(N).filter(e=>e!==null);return t.length===e.steps.length?{runId:e.runId,workflow:e.workflow,...typeof e.args==`string`?{args:e.args}:{},status:e.status,createdAt:e.createdAt,updatedAt:e.updatedAt,currentStepIndex:e.currentStepIndex,steps:t}:null}async function F(e,t){try{return P(ue(await O(D(e,R,`${t}.json`),`utf-8`),!1))}catch{return null}}async function I(e=se()){let t;try{t=await k(D(e,R))}catch{return[]}let n=t.filter(e=>e.endsWith(`.json`));return(await Promise.all(n.slice(0,z).map(t=>F(e,t.slice(0,-5))))).filter(e=>e!==null).sort((e,t)=>t.updatedAt-e.updatedAt)}function L(e){if(e.length===0)return[`Workflow runs: 0`,` none`].join(`
2
+ `);let t=e.filter(e=>e.status===`running`).length,n=e.filter(e=>e.status===`completed`).length,r=e.filter(e=>e.status===`cancelled`).length,i=[`Workflow runs: ${e.length}`,` Running: ${t}`,` Completed: ${n}`,` Cancelled: ${r}`];for(let t of e.slice(0,10)){let e=t.steps[t.currentStepIndex];i.push(` ${t.runId}: ${t.workflow}: ${t.status} step=${e?.name??`none`} updated=${new Date(t.updatedAt).toLocaleString()}`)}return e.length>10&&i.push(` ... ${e.length-10} more workflow run(s)`),i.join(`
3
+ `)}var R,z,B,V,H=e((()=>{oe(),le(),R=D(`.claude`,`workflow-runs`),z=200,B=[`running`,`completed`,`cancelled`],V=[`pending`,`running`,`completed`,`cancelled`]}));function U(){return D(t(),`pipes`)}var de=e((()=>{n(),ce()}));function fe(){return D(U(),`registry.json`)}async function pe(){try{let e=await O(fe(),`utf8`),t=JSON.parse(e);return t.version===1?t:{...W}}catch{return{...W}}}var W,me=e((()=>{de(),W={version:1,mainMachineId:null,main:null,subs:[]}}));async function he(){return ge(await pe())}function ge(e){let t=[`Pipe registry: ${+!!e.main} main, ${e.subs.length} sub(s)`];e.mainMachineId&&t.push(` main_machine=${e.mainMachineId.slice(0,8)}...`),e.main&&t.push(` [main] ${e.main.pipeName} pid=${e.main.pid} host=${e.main.hostname} tcp=${e.main.tcpPort??`none`}`);for(let n of e.subs.slice(0,10))t.push(` [sub-${n.subIndex}] ${n.pipeName} pid=${n.pid} host=${n.hostname} bound=${n.boundToMain??`none`} tcp=${n.tcpPort??`none`}`);return!e.main&&e.subs.length===0&&t.push(` none`),e.subs.length>10&&t.push(` ... ${e.subs.length-10} more sub pipe(s)`),t.join(`
4
+ `)}var _e=e((()=>{me()}));function ve(){try{let e=x(),t=S();return[`Remote Control: ${e?`self-hosted`:`official`}`,` base_url=${b()}`,` token=${t?`present`:`missing`}`,` entitlement=checked at remote-control startup`].join(`
5
+ `)}catch(e){return[`Remote Control: unknown`,` reason=${e instanceof Error?e.message:String(e)}`].join(`
6
+ `)}}var ye=e((()=>{y()}));async function be(){let e=T(),t=await w(),n=[`Daemon: ${e.status}${e.state?` pid=${e.state.pid} workers=${e.state.workerKinds.join(`,`)}`:``}`,`Background sessions: ${t.length}`];for(let e of t.slice(0,8))n.push(` pid=${e.pid} kind=${e.kind} status=${e.status??`unknown`} cwd=${e.cwd}`);return t.length>8&&n.push(` ... ${t.length-8} more session(s)`),n.join(`
7
+ `)}function xe(){let e=!1,t=null;try{e=a(),t=ae()}catch(e){return[`Auto mode: unknown`,` reason=${e instanceof Error?e.message:String(e)}`].join(`
8
+ `)}return[`Auto mode: ${e?`available`:`unavailable`}`,` reason=${t??`none`}`].join(`
9
+ `)}async function G({runs:e,flows:t,nowMs:n=Date.now()}){return Promise.all([Promise.resolve({id:`auto-mode`,title:`Auto Mode`,content:xe()}),Promise.resolve({id:`runs`,title:`Runs`,content:l(e)}),Promise.resolve({id:`flows`,title:`Flows`,content:h(t)}),I().then(e=>({id:`workflow-runs`,title:`Workflow Runs`,content:L(e)})),he().then(e=>({id:`pipes`,title:`Pipes`,content:e})),be().then(e=>({id:`runtime`,title:`Runtime`,content:e})),Promise.resolve({id:`remote-control`,title:`Remote Control`,content:ve()}),ee().then(e=>({id:`remote-trigger`,title:`RemoteTrigger`,content:ie(e)}))])}async function Se(e){return(await G(e)).map((e,t)=>[t===0?`# Autonomy Deep Status`:`## ${e.title}`,e.content].join(`
10
+ `)).join(`
11
+
12
+ `)}var Ce=e((()=>{E(),C(),c(),u(),i(),d(),H(),_e(),ye()}));function we(e){let[t=`status`,n,r]=e.trim().split(/\s+/,3);return t===``||t===`status`?{type:`status`,deep:n===`--deep`}:t===`runs`?{type:`runs`,limit:n}:t===`flows`?{type:`flows`,limit:n}:t===`flow`?n===`cancel`?r?{type:`flow-cancel`,flowId:r}:{type:`usage`}:n===`resume`?r?{type:`flow-resume`,flowId:r}:{type:`usage`}:n?{type:`flow-detail`,flowId:n}:{type:`usage`}:{type:`usage`}}var K,Te=e((()=>{K=`Usage: /autonomy [status [--deep]|runs [limit]|flows [limit]|flow <id>|flow cancel <id>|flow resume <id>]`}));function q(e){let t=typeof e==`number`?e:Number.parseInt(e??``,10);return!Number.isFinite(t)||t<=0?10:Math.min(t,50)}async function J(e){let t=e?.rootDir,[n,r]=await Promise.all([v(t),_(t)]);return e?.deep?Se({runs:n,flows:r}):[l(n),h(r)].join(`
13
+ `)}async function Ee(e,t){let[n,r]=await Promise.all([v(t?.rootDir),_(t?.rootDir)]),i=(await G({runs:n,flows:r})).find(t=>t.id===e);return i?[`# ${i.title}`,i.content].join(`
14
+ `):`Autonomy deep status section not found: ${e}`}async function De(e){process.stdout.write(`${await J(e)}\n`)}async function Y(e,t){return s(await v(t?.rootDir),q(e))}async function Oe(e){process.stdout.write(`${await Y(e)}\n`)}async function X(e,t){return p(await _(t?.rootDir),q(e))}async function ke(e){process.stdout.write(`${await X(e)}\n`)}async function Z(e,t){return te(await o(e,t?.rootDir))}async function Ae(e){process.stdout.write(`${await Z(e)}\n`)}async function Q(e,t){let n=await re({flowId:e,rootDir:t?.rootDir});if(!n)return`Autonomy flow not found.`;if(!n.accepted)return`Autonomy flow ${e} is already terminal (${n.flow.status}).`;let i=0;if(t?.removeQueuedInMemory){let n=ne(t=>t.autonomy?.flowId===e);i=n.length;for(let e of n)e.autonomy?.runId&&await r(e.autonomy.runId,t?.rootDir)}else{for(let e of n.queuedRunIds)await r(e,t?.rootDir);i=n.queuedRunIds.length}return n.flow.status===`running`?`Cancellation requested for flow ${e}. The current step is still running, and no new steps will be started.`:`Cancelled flow ${e}. Removed ${i} queued step(s).`}async function je(e){process.stdout.write(`${await Q(e)}\n`)}async function $(e,t){let n=await m({flowId:e,rootDir:t?.rootDir,currentDir:t?.currentDir});if(!n)return`Autonomy flow is not waiting or was not found.`;if(t?.enqueueInMemory)return f(n),`Queued the next managed step for flow ${e}.`;let r=n.autonomy?.runId??`unknown`;return[`Prepared the next managed step for flow ${e}.`,`Run ID: ${r}`,``,`Prompt:`,typeof n.value==`string`?n.value:String(n.value)].join(`
15
+ `)}async function Me(e){process.stdout.write(`${await $(e)}\n`)}async function Ne(e,t){let n=we(e);switch(n.type){case`status`:return J({deep:n.deep});case`runs`:return Y(n.limit);case`flows`:return X(n.limit);case`flow-detail`:return Z(n.flowId);case`flow-cancel`:return Q(n.flowId,{removeQueuedInMemory:t?.removeQueuedInMemory});case`flow-resume`:return $(n.flowId,{enqueueInMemory:t?.enqueueInMemory});case`usage`:return K}}var Pe=e((()=>{c(),u(),Ce(),Te(),g()}));export{Oe as a,Ne as c,X as d,Y as f,$ as g,q as h,ke as i,Ee as l,Pe as m,Ae as n,De as o,J as p,Me as r,Q as s,je as t,Z as u};
@@ -1 +1 @@
1
- import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{Nh as n,Ph as r,hd as i,vd as a}from"./loadAgentsDir-CKSb56Gp.js";import{I as o,P as s,fi as c,hn as l,t as u,y as d}from"./src-P_wYS_NJ2.js";import{t as f}from"./jsx-runtime-Bb4Xn-E0.js";import{c as p,l as m,m as h,p as g}from"./autonomy-dSJl0hN1.js";function _(){return S}function v({onDone:e}){a(`autonomy-panel`);let[t,n]=(0,b.useState)(0),[i,c]=(0,b.useState)([]);(0,b.useEffect)(()=>{let e=!1;return r().then(t=>{e||c(t.slice(0,5))}),()=>{e=!0}},[]);let u=(0,b.useMemo)(()=>{let e=[{label:`Overview`,description:`Show run and flow counts plus the latest automatic activity`,run:()=>g()},{label:`Full deep status`,description:`Print every local autonomy surface in one diagnostic report`,run:()=>g({deep:!0})},{label:`Auto mode`,description:`Check whether auto permission mode is available and why`,run:()=>m(`auto-mode`)},{label:`Runs summary`,description:`Show queued/running/completed/failed run totals and latest run`,run:()=>m(`runs`)},{label:`Recent runs`,description:`List recent autonomy run IDs, triggers, statuses, and prompts`,run:()=>p(`runs 10`)},{label:`Flows summary`,description:`Show managed flow totals across queued/running/waiting states`,run:()=>m(`flows`)},{label:`Recent flows`,description:`List recent managed flow IDs, status, current step, and goal`,run:()=>p(`flows 10`)},{label:`Workflow runs`,description:`Show persisted WorkflowTool runs and their current workflow step`,run:()=>m(`workflow-runs`)},{label:`Pipes`,description:`Show UDS/named-pipe and LAN registry for terminal messaging`,run:()=>m(`pipes`)},{label:`Runtime`,description:`Show daemon state and live background or interactive sessions`,run:()=>m(`runtime`)},{label:`Remote Control`,description:`Show bridge mode, base URL, token presence, and entitlement note`,run:()=>m(`remote-control`)},{label:`RemoteTrigger`,description:`Show recent remote trigger audit records, failures, and latest call`,run:()=>m(`remote-trigger`)}],t=i.flatMap(e=>{let t=e.flowId.slice(0,8),n=[{label:`Flow ${t}`,description:`${e.status}: ${e.goal}`,run:()=>p(`flow ${e.flowId}`)}];return e.status===`waiting`&&n.push({label:`Resume ${t}`,description:e.currentStep?`Resume waiting step: ${e.currentStep}`:`Resume waiting flow`,run:()=>p(`flow resume ${e.flowId}`,{enqueueInMemory:!0})}),(e.status===`queued`||e.status===`running`||e.status===`waiting`||e.status===`blocked`)&&n.push({label:`Cancel ${t}`,description:`Cancel ${e.status} flow`,run:()=>p(`flow cancel ${e.flowId}`,{removeQueuedInMemory:!0})}),n});return[...e,...t]},[i]),f=()=>{let n=u[t];n&&n.run().then(t=>{e(t,{display:`system`})})};return l((e,t)=>{if(t.upArrow){n(e=>Math.max(0,e-1));return}if(t.downArrow){n(e=>Math.min(u.length-1,e+1));return}t.return&&f()}),(0,x.jsx)(d,{title:`Autonomy`,subtitle:`${u.length} actions`,onCancel:()=>e(`Autonomy panel dismissed`,{display:`system`}),color:`background`,hideInputGuide:!0,children:(0,x.jsxs)(o,{flexDirection:`column`,children:[u.map((e,n)=>(0,x.jsxs)(o,{flexDirection:`row`,children:[(0,x.jsx)(s,{children:`${n===t?`›`:` `} ${e.label}`.padEnd(C)}),(0,x.jsx)(s,{dimColor:!0,children:e.description})]},`${e.label}-${n}`)),(0,x.jsx)(o,{marginTop:1,children:(0,x.jsx)(s,{dimColor:!0,children:`↑/↓ select · Enter run · Esc close`})})]})})}async function y(e,t,n){let r=n?.trim()??``;return r?(e(await p(r,{enqueueInMemory:!0,removeQueuedInMemory:!0}),{display:`system`}),null):(0,x.jsx)(v,{onDone:e})}var b,x,S,C;e((()=>{b=t(c(),1),u(),i(),h(),n(),x=f(),S=14,C=24}))();export{y as call,_ as getAutonomyPanelBaseActionCountForTests};
1
+ import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{Km as n,ld as r,od as i,qm as a}from"./loadAgentsDir-C7lOqvfh.js";import{I as o,P as s,fi as c,hn as l,t as u,y as d}from"./src-P_wYS_NJ2.js";import{t as f}from"./jsx-runtime-Bb4Xn-E0.js";import{c as p,l as m,m as h,p as g}from"./autonomy-Src6sKCp.js";function _(){return S}function v({onDone:e}){r(`autonomy-panel`);let[t,n]=(0,b.useState)(0),[i,c]=(0,b.useState)([]);(0,b.useEffect)(()=>{let e=!1;return a().then(t=>{e||c(t.slice(0,5))}),()=>{e=!0}},[]);let u=(0,b.useMemo)(()=>{let e=[{label:`Overview`,description:`Show run and flow counts plus the latest automatic activity`,run:()=>g()},{label:`Full deep status`,description:`Print every local autonomy surface in one diagnostic report`,run:()=>g({deep:!0})},{label:`Auto mode`,description:`Check whether auto permission mode is available and why`,run:()=>m(`auto-mode`)},{label:`Runs summary`,description:`Show queued/running/completed/failed run totals and latest run`,run:()=>m(`runs`)},{label:`Recent runs`,description:`List recent autonomy run IDs, triggers, statuses, and prompts`,run:()=>p(`runs 10`)},{label:`Flows summary`,description:`Show managed flow totals across queued/running/waiting states`,run:()=>m(`flows`)},{label:`Recent flows`,description:`List recent managed flow IDs, status, current step, and goal`,run:()=>p(`flows 10`)},{label:`Workflow runs`,description:`Show persisted WorkflowTool runs and their current workflow step`,run:()=>m(`workflow-runs`)},{label:`Pipes`,description:`Show UDS/named-pipe and LAN registry for terminal messaging`,run:()=>m(`pipes`)},{label:`Runtime`,description:`Show daemon state and live background or interactive sessions`,run:()=>m(`runtime`)},{label:`Remote Control`,description:`Show bridge mode, base URL, token presence, and entitlement note`,run:()=>m(`remote-control`)},{label:`RemoteTrigger`,description:`Show recent remote trigger audit records, failures, and latest call`,run:()=>m(`remote-trigger`)}],t=i.flatMap(e=>{let t=e.flowId.slice(0,8),n=[{label:`Flow ${t}`,description:`${e.status}: ${e.goal}`,run:()=>p(`flow ${e.flowId}`)}];return e.status===`waiting`&&n.push({label:`Resume ${t}`,description:e.currentStep?`Resume waiting step: ${e.currentStep}`:`Resume waiting flow`,run:()=>p(`flow resume ${e.flowId}`,{enqueueInMemory:!0})}),(e.status===`queued`||e.status===`running`||e.status===`waiting`||e.status===`blocked`)&&n.push({label:`Cancel ${t}`,description:`Cancel ${e.status} flow`,run:()=>p(`flow cancel ${e.flowId}`,{removeQueuedInMemory:!0})}),n});return[...e,...t]},[i]),f=()=>{let n=u[t];n&&n.run().then(t=>{e(t,{display:`system`})})};return l((e,t)=>{if(t.upArrow){n(e=>Math.max(0,e-1));return}if(t.downArrow){n(e=>Math.min(u.length-1,e+1));return}t.return&&f()}),(0,x.jsx)(d,{title:`Autonomy`,subtitle:`${u.length} actions`,onCancel:()=>e(`Autonomy panel dismissed`,{display:`system`}),color:`background`,hideInputGuide:!0,children:(0,x.jsxs)(o,{flexDirection:`column`,children:[u.map((e,n)=>(0,x.jsxs)(o,{flexDirection:`row`,children:[(0,x.jsx)(s,{children:`${n===t?`›`:` `} ${e.label}`.padEnd(C)}),(0,x.jsx)(s,{dimColor:!0,children:e.description})]},`${e.label}-${n}`)),(0,x.jsx)(o,{marginTop:1,children:(0,x.jsx)(s,{dimColor:!0,children:`↑/↓ select · Enter run · Esc close`})})]})})}async function y(e,t,n){let r=n?.trim()??``;return r?(e(await p(r,{enqueueInMemory:!0,removeQueuedInMemory:!0}),{display:`system`}),null):(0,x.jsx)(v,{onDone:e})}var b,x,S,C;e((()=>{b=t(c(),1),u(),i(),h(),n(),x=f(),S=14,C=24}))();export{y as call,_ as getAutonomyPanelBaseActionCountForTests};
@@ -0,0 +1,17 @@
1
+ import{a as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,o as n}from"./envUtils-BDhHQY0-.js";import{$ as r,Ba as i,Cr as a,Da as o,Nc as s,Oa as ee,Pc as c,Ta as te,Tt as l,Ud as u,Wd as ne,_x as re,aw as d,bm as f,fr as p,lp as m,mt as h,rw as g,sp as ie,tt as ae,vx as oe,yv as _}from"./loadAgentsDir-C7lOqvfh.js";import{R as v,W as y,Wt as b}from"./state-BemZdQIl.js";import{n as x,t as S}from"./cwd-Cfdf7z7s.js";import{S as C,W as w,a as T,d as E,l as D,p as O,z as k}from"./debug-RAynG_nM.js";import{f as A,g as j,y as M}from"./settings-DnptdP79.js";import{S as N}from"./config-Do1870_d.js";import{o as P,s as F,v as I,y as L}from"./log-CezCRpAN.js";import{n as R,r as z}from"./analytics-DJobLaWP.js";import{_ as B,h as V}from"./model-BsZ4sP_H.js";import{bn as H,yn as U}from"./prompt-M2lu8_Oa.js";import{at as W}from"./sessionState-Bifmu95-.js";import{i as se,t as G}from"./nativeInstaller-QB8cEJ18.js";import{n as K,t as ce}from"./allErrors-CU89tF-z.js";import{r as le}from"./magicDocs-BpVcON9o.js";import{n as ue,t as de}from"./pluginAutoupdate-SlRFJlTT.js";import{n as fe,r as pe}from"./registerProtocol-CsNYRZKr.js";import"os";import{join as q}from"path";import"crypto";n(),b(),x(),C(),O(),T(),L(),j(),H(),B(),c(),a(),le(),r(),P(),k(),i(),_(),r(),oe(),k(),P(),i(),_(),f();async function me(e,t){if(!e)return;let{join:n}=await import(`path`),r=await import(`fs/promises`),i=n(S(),`.claude`,`skills`,e,`SKILL.md`),a;try{a=await r.readFile(i,`utf-8`)}catch{F(Error(`Failed to read skill file for improvement: ${i}`));return}let s=t.map(e=>`- ${e.section}: ${e.change}`).join(`
2
+ `),c=V(),l=await ae({messages:[te({content:`You are editing a skill definition file. Apply the following improvements to the skill.
3
+
4
+ <current_skill_file>
5
+ ${a}
6
+ </current_skill_file>
7
+
8
+ <improvements>
9
+ ${s}
10
+ </improvements>
11
+
12
+ Rules:
13
+ - Integrate the improvements naturally into the existing structure
14
+ - Preserve frontmatter (--- block) exactly as-is
15
+ - Preserve the overall format and style
16
+ - Do not remove existing content unless an improvement explicitly replaces it
17
+ - Output the complete updated file inside <updated_file> tags`})],systemPrompt:W([`You edit skill definition files to incorporate user preferences. Output only the updated file content.`]),thinkingConfig:{type:`disabled`},tools:[],signal:re().signal,options:{getToolPermissionContext:async()=>U(),model:c,toolChoice:void 0,isNonInteractiveSession:!1,hasAppendSystemPrompt:!1,temperatureOverride:0,agents:[],querySource:`skill_improvement_apply`,mcpTools:[]}}),u=o(ee(Array.isArray(l.message.content)?l.message.content:[]).trim(),`updated_file`);if(!u){F(Error(`Skill improvement apply: no updated_file tag in response`));return}try{await r.writeFile(i,u,`utf-8`)}catch(e){F(w(e))}}R(),m(),N(),P(),G(),ne(),K(),d(),l();var he=30;function J(){let e=((A()||{}).cleanupPeriodDays??he)*24*60*60*1e3;return new Date(Date.now()-e)}function ge(e,t){return{messages:e.messages+t.messages,errors:e.errors+t.errors}}function _e(e){let t=e.split(`.`)[0].replace(/T(\d{2})-(\d{2})-(\d{2})-(\d{3})Z/,`T$1:$2:$3.$4Z`);return new Date(t)}async function Y(e,t,n){let r={messages:0,errors:0};try{let i=await E().readdir(e);for(let a of i)try{_e(a.name)<t&&(await E().unlink(q(e,a.name)),n?r.messages++:r.errors++)}catch(e){F(e)}}catch(e){e instanceof Error&&`code`in e&&e.code!==`ENOENT`&&F(e)}return r}async function ve(){let e=E(),t=J(),n=I.errors(),r=I.baseLogs(),i=await Y(n,t,!1);try{let n;try{n=await e.readdir(r)}catch{return i}let a=n.filter(e=>e.isDirectory()&&e.name.startsWith(`mcp-logs-`)).map(e=>q(r,e.name));for(let n of a)i=ge(i,await Y(n,t,!0)),await Z(n,e)}catch(e){e instanceof Error&&`code`in e&&e.code!==`ENOENT`&&F(e)}return i}async function X(e,t,n){return(await n.stat(e)).mtime<t?(await n.unlink(e),!0):!1}async function Z(e,t){try{await t.rmdir(e)}catch{}}async function ye(){let e=J(),t={messages:0,errors:0},n=p(),r=E(),i;try{i=await r.readdir(n)}catch{return t}for(let a of i){if(!a.isDirectory())continue;let i=q(n,a.name),o;try{o=await r.readdir(i)}catch{t.errors++;continue}for(let n of o)if(n.isFile()){if(!n.name.endsWith(`.jsonl`)&&!n.name.endsWith(`.cast`))continue;try{await X(q(i,n.name),e,r)&&t.messages++}catch{t.errors++}}else if(n.isDirectory()){let a=q(i,n.name),o=q(a,g),s;try{s=await r.readdir(o)}catch{await Z(a,r);continue}for(let n of s)if(n.isFile())try{await X(q(o,n.name),e,r)&&t.messages++}catch{t.errors++}else if(n.isDirectory()){let i=q(o,n.name),a;try{a=await r.readdir(i)}catch{continue}for(let n of a)if(n.isFile())try{await X(q(i,n.name),e,r)&&t.messages++}catch{t.errors++}await Z(i,r)}await Z(o,r),await Z(a,r)}await Z(i,r)}return t}async function be(e,t,n=!0){let r=J(),i={messages:0,errors:0},a=E(),o;try{o=await a.readdir(e)}catch{return i}for(let n of o)if(!(!n.isFile()||!n.name.endsWith(t)))try{await X(q(e,n.name),r,a)&&i.messages++}catch{i.errors++}return n&&await Z(e,a),i}function xe(){return be(q(t(),`plans`),`.md`)}async function Se(){let e=J(),n={messages:0,errors:0},r=E();try{let i=q(t(),`file-history`),a;try{a=await r.readdir(i)}catch{return n}let o=a.filter(e=>e.isDirectory()).map(e=>q(i,e.name));await Promise.all(o.map(async t=>{try{(await r.stat(t)).mtime<e&&(await r.rm(t,{recursive:!0,force:!0}),n.messages++)}catch{n.errors++}})),await Z(i,r)}catch(e){F(e)}return n}async function Ce(){let e=J(),n={messages:0,errors:0},r=E();try{let i=q(t(),`session-env`),a;try{a=await r.readdir(i)}catch{return n}let o=a.filter(e=>e.isDirectory()).map(e=>q(i,e.name));for(let t of o)try{(await r.stat(t)).mtime<e&&(await r.rm(t,{recursive:!0,force:!0}),n.messages++)}catch{n.errors++}await Z(i,r)}catch(e){F(e)}return n}async function we(){let e=J(),n={messages:0,errors:0},r=E(),i=q(t(),`debug`),a;try{a=await r.readdir(i)}catch{return n}for(let t of a)if(!(!t.isFile()||!t.name.endsWith(`.txt`)||t.name===`latest`))try{await X(q(i,t.name),e,r)&&n.messages++}catch{n.errors++}return n}async function Q(){let{errors:e}=ce();if(e.length>0&&M(`cleanupPeriodDays`)){D(`Skipping cleanup: settings have validation errors but cleanupPeriodDays was explicitly set. Fix settings errors to enable cleanup.`);return}await ve(),await ye(),await xe(),await Se(),await Ce(),await we(),await ie(),await u(J());let t=await h(J());t>0&&z(`tengu_worktree_cleanup`,{removed:t})}b(),G(),ue();var Te=(fe(),e(pe)),$=600*1e3;function Ee(){import(`./extractMemories-CUrdiNcr.js`).then(({initExtractMemories:e})=>{e()}).catch(()=>{}),s(),de(),v()&&Te.ensureDeepLinkProtocolRegistered();let e=!0;async function t(){if(v()&&y()>Date.now()-1e3*60){setTimeout(t,$).unref();return}if(e&&(e=!1,await Q()),v()&&y()>Date.now()-1e3*60){setTimeout(t,$).unref();return}await se()}setTimeout(t,$).unref()}export{me as n,Ee as t};
@@ -0,0 +1 @@
1
+ import{t as e}from"./backgroundHousekeeping-B-cw0UcS.js";export{e as startBackgroundHousekeeping};
@@ -1,2 +1,2 @@
1
- import{S as e,m as t,s as n,y as r}from"./git-B9uvt96d.js";import{f as i,m as a,v as o}from"./startupProfiler-jeId9f2i.js";import{homedir as s}from"os";import{join as c,sep as l}from"path";import{stat as u}from"fs/promises";o(),e(),t();var d=10080*60*1e3,f=1e3;function p(e){let t=[`This session was opened by an external deep link in ${g(e.cwd)}`];if(e.repo){let n=e.lastFetch?a(e.lastFetch):`never`,r=!e.lastFetch||Date.now()-e.lastFetch.getTime()>d;t.push(`Resolved ${e.repo} from local clones · last fetched ${n}${r?` — CLAUDE.md may be stale`:``}`)}return e.prefillLength&&t.push(e.prefillLength>f?`The prompt below (${i(e.prefillLength)} chars) was supplied by the link — scroll to review the entire prompt before pressing Enter.`:`The prompt below was supplied by the link — review carefully before pressing Enter.`),t.join(`
1
+ import{S as e,m as t,s as n,y as r}from"./git-2c7WlGDL.js";import{f as i,m as a,v as o}from"./startupProfiler-L_UWZ03w.js";import{homedir as s}from"os";import{join as c,sep as l}from"path";import{stat as u}from"fs/promises";o(),e(),t();var d=10080*60*1e3,f=1e3;function p(e){let t=[`This session was opened by an external deep link in ${g(e.cwd)}`];if(e.repo){let n=e.lastFetch?a(e.lastFetch):`never`,r=!e.lastFetch||Date.now()-e.lastFetch.getTime()>d;t.push(`Resolved ${e.repo} from local clones · last fetched ${n}${r?` — CLAUDE.md may be stale`:``}`)}return e.prefillLength&&t.push(e.prefillLength>f?`The prompt below (${i(e.prefillLength)} chars) was supplied by the link — scroll to review the entire prompt before pressing Enter.`:`The prompt below was supplied by the link — review carefully before pressing Enter.`),t.join(`
2
2
  `)}async function m(e){let t=await n(e);if(!t)return;let i=await r(t),[a,o]=await Promise.all([h(c(t,`FETCH_HEAD`)),i?h(c(i,`FETCH_HEAD`)):Promise.resolve(void 0)]);return a&&o?a>o?a:o:a??o}async function h(e){try{let{mtime:t}=await u(e);return t}catch{return}}function g(e){let t=s();return e===t?`~`:e.startsWith(t+l)?`~`+e.slice(t.length):e}export{m as n,p as t};
@@ -0,0 +1 @@
1
+ import{a as e,c as t,i as n,r,s as i,t as a}from"./bg-DAPORXF3.js";n();export{a as attachHandler,r as handleBgStart,e as killHandler,i as logsHandler,t as psHandler};
@@ -1,5 +1,5 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,o as n}from"./envUtils-BDhHQY0-.js";import{C as r,S as i}from"./debug-BdqxZ7rV.js";import{a,i as o}from"./genericProcessUtils-BmDSLcMf.js";import{join as s}from"path";import{randomUUID as c}from"crypto";import{readFile as l,readdir as u,unlink as d}from"fs/promises";async function f(){if(process.platform===`win32`){let{DetachedEngine:e}=await import(`./detached-CkPpYMJj.js`);return new e}let{TmuxEngine:e}=await import(`./tmux-CMRiI6CD.js`),t=new e;if(await t.available())return t;let{DetachedEngine:n}=await import(`./detached-CkPpYMJj.js`);return new n}var p=e((()=>{}));function m(){return s(t(),`sessions`)}async function h(){let e=m(),t;try{t=await u(e)}catch{return[]}let n=[];for(let i of t)if(/^\d+\.json$/.test(i)){if(!a(parseInt(i.slice(0,-5),10))){d(s(e,i)).catch(()=>{});continue}try{let t=r(await l(s(e,i),`utf-8`));n.push(t)}catch{}}return n}function g(e,t){let n=parseInt(t,10);return e.find(e=>e.sessionId===t||e.pid===n||e.name&&e.name===t)}function _(e){return new Date(e).toLocaleString()}function v(e){return e.engine?e.engine:e.tmuxSessionName?`tmux`:`detached`}async function y(e){let t=await h();if(t.length===0){console.log(`No active sessions.`);return}console.log(`${t.length} active session${t.length>1?`s`:``}:\n`);for(let e of t){let t=v(e),n=[` PID: ${e.pid}`,` Kind: ${e.kind}`,` Engine: ${t}`,` Session: ${e.sessionId}`,` CWD: ${e.cwd}`];e.name&&n.push(` Name: ${e.name}`),e.startedAt&&n.push(` Started: ${_(e.startedAt)}`),e.status&&n.push(` Status: ${e.status}`),e.waitingFor&&n.push(` Waiting for: ${e.waitingFor}`),e.bridgeSessionId&&n.push(` Bridge: ${e.bridgeSessionId}`),e.tmuxSessionName&&n.push(` Tmux: ${e.tmuxSessionName}`),e.logPath&&n.push(` Log: ${e.logPath}`),console.log(n.join(`
2
- `)),console.log()}}async function b(e){let t=await h();if(!e){if(t.length===0){console.log(`No active sessions.`);return}if(t.length===1)e=t[0].sessionId;else{console.log(`Multiple sessions active. Specify one:`);for(let e of t){let t=e.name?`${e.name} (${e.sessionId})`:e.sessionId;console.log(` ${t} PID=${e.pid}`)}return}}let n=g(t,e);if(!n){console.error(`Session not found: ${e}`),process.exitCode=1;return}if(!n.logPath){console.log(`No log path recorded for session ${n.sessionId}`);return}try{let e=await l(n.logPath,`utf-8`);process.stdout.write(e)}catch(e){console.error(`Failed to read log file: ${n.logPath}`),console.error(e instanceof Error?e.message:String(e)),process.exitCode=1}}async function x(e){let t=await h();if(!e){let n=t.filter(e=>e.tmuxSessionName||e.engine===`detached`);if(n.length===0){console.log("No background sessions to attach to. Start one with `claude daemon bg`.");return}if(n.length===1)e=n[0].sessionId;else{console.log(`Multiple background sessions. Specify one:`);for(let e of n){let t=e.name?`${e.name} (${e.sessionId})`:e.sessionId,n=v(e);console.log(` ${t} PID=${e.pid} engine=${n}`)}return}}let n=g(t,e);if(!n){console.error(`Session not found: ${e}`),process.exitCode=1;return}let r=v(n);try{if(r===`tmux`){let{TmuxEngine:e}=await import(`./tmux-CMRiI6CD.js`),t=new e;if(!await t.available()){console.error(`tmux is no longer available. Cannot attach to tmux session.`),process.exitCode=1;return}await t.attach(n)}else{let{DetachedEngine:e}=await import(`./detached-CkPpYMJj.js`);await new e().attach(n)}}catch(e){console.error(e instanceof Error?e.message:String(e)),process.exitCode=1}}async function S(e){let t=await h();if(!e){if(t.length===0){console.log(`No active sessions to kill.`);return}console.log(`Specify a session to kill:`);for(let e of t){let t=e.name?`${e.name} (${e.sessionId})`:e.sessionId;console.log(` ${t} PID=${e.pid}`)}return}let n=g(t,e);if(!n){console.error(`Session not found: ${e}`),process.exitCode=1;return}console.log(`Killing session ${n.sessionId} (PID: ${n.pid})...`);try{process.kill(n.pid,`SIGTERM`)}catch{console.log(`Session already exited.`);return}if(await new Promise(e=>setTimeout(e,2e3)),a(n.pid))try{process.kill(n.pid,`SIGKILL`),console.log(`Session force-killed.`)}catch{console.log(`Session exited during grace period.`)}else console.log(`Session stopped.`);d(s(m(),`${n.pid}.json`)).catch(()=>{})}async function C(e){let n=await f(),r=e.filter(e=>e!==`--bg`&&e!==`--background`);if(!n.supportsInteractiveInput&&!r.some(e=>e===`-p`||e===`--print`||e===`--pipe`)){console.error(`Error: Background sessions with detached engine require -p/--print flag.
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,o as n}from"./envUtils-BDhHQY0-.js";import{C as r,S as i}from"./debug-RAynG_nM.js";import{a,i as o}from"./genericProcessUtils-CmsUPyRz.js";import{join as s}from"path";import{randomUUID as c}from"crypto";import{readFile as l,readdir as u,unlink as d}from"fs/promises";async function f(){if(process.platform===`win32`){let{DetachedEngine:e}=await import(`./detached-X_yjYR7x.js`);return new e}let{TmuxEngine:e}=await import(`./tmux-DewYVEBm.js`),t=new e;if(await t.available())return t;let{DetachedEngine:n}=await import(`./detached-X_yjYR7x.js`);return new n}var p=e((()=>{}));function m(){return s(t(),`sessions`)}async function h(){let e=m(),t;try{t=await u(e)}catch{return[]}let n=[];for(let i of t)if(/^\d+\.json$/.test(i)){if(!a(parseInt(i.slice(0,-5),10))){d(s(e,i)).catch(()=>{});continue}try{let t=r(await l(s(e,i),`utf-8`));n.push(t)}catch{}}return n}function g(e,t){let n=parseInt(t,10);return e.find(e=>e.sessionId===t||e.pid===n||e.name&&e.name===t)}function _(e){return new Date(e).toLocaleString()}function v(e){return e.engine?e.engine:e.tmuxSessionName?`tmux`:`detached`}async function y(e){let t=await h();if(t.length===0){console.log(`No active sessions.`);return}console.log(`${t.length} active session${t.length>1?`s`:``}:\n`);for(let e of t){let t=v(e),n=[` PID: ${e.pid}`,` Kind: ${e.kind}`,` Engine: ${t}`,` Session: ${e.sessionId}`,` CWD: ${e.cwd}`];e.name&&n.push(` Name: ${e.name}`),e.startedAt&&n.push(` Started: ${_(e.startedAt)}`),e.status&&n.push(` Status: ${e.status}`),e.waitingFor&&n.push(` Waiting for: ${e.waitingFor}`),e.bridgeSessionId&&n.push(` Bridge: ${e.bridgeSessionId}`),e.tmuxSessionName&&n.push(` Tmux: ${e.tmuxSessionName}`),e.logPath&&n.push(` Log: ${e.logPath}`),console.log(n.join(`
2
+ `)),console.log()}}async function b(e){let t=await h();if(!e){if(t.length===0){console.log(`No active sessions.`);return}if(t.length===1)e=t[0].sessionId;else{console.log(`Multiple sessions active. Specify one:`);for(let e of t){let t=e.name?`${e.name} (${e.sessionId})`:e.sessionId;console.log(` ${t} PID=${e.pid}`)}return}}let n=g(t,e);if(!n){console.error(`Session not found: ${e}`),process.exitCode=1;return}if(!n.logPath){console.log(`No log path recorded for session ${n.sessionId}`);return}try{let e=await l(n.logPath,`utf-8`);process.stdout.write(e)}catch(e){console.error(`Failed to read log file: ${n.logPath}`),console.error(e instanceof Error?e.message:String(e)),process.exitCode=1}}async function x(e){let t=await h();if(!e){let n=t.filter(e=>e.tmuxSessionName||e.engine===`detached`);if(n.length===0){console.log("No background sessions to attach to. Start one with `claude daemon bg`.");return}if(n.length===1)e=n[0].sessionId;else{console.log(`Multiple background sessions. Specify one:`);for(let e of n){let t=e.name?`${e.name} (${e.sessionId})`:e.sessionId,n=v(e);console.log(` ${t} PID=${e.pid} engine=${n}`)}return}}let n=g(t,e);if(!n){console.error(`Session not found: ${e}`),process.exitCode=1;return}let r=v(n);try{if(r===`tmux`){let{TmuxEngine:e}=await import(`./tmux-DewYVEBm.js`),t=new e;if(!await t.available()){console.error(`tmux is no longer available. Cannot attach to tmux session.`),process.exitCode=1;return}await t.attach(n)}else{let{DetachedEngine:e}=await import(`./detached-X_yjYR7x.js`);await new e().attach(n)}}catch(e){console.error(e instanceof Error?e.message:String(e)),process.exitCode=1}}async function S(e){let t=await h();if(!e){if(t.length===0){console.log(`No active sessions to kill.`);return}console.log(`Specify a session to kill:`);for(let e of t){let t=e.name?`${e.name} (${e.sessionId})`:e.sessionId;console.log(` ${t} PID=${e.pid}`)}return}let n=g(t,e);if(!n){console.error(`Session not found: ${e}`),process.exitCode=1;return}console.log(`Killing session ${n.sessionId} (PID: ${n.pid})...`);try{process.kill(n.pid,`SIGTERM`)}catch{console.log(`Session already exited.`);return}if(await new Promise(e=>setTimeout(e,2e3)),a(n.pid))try{process.kill(n.pid,`SIGKILL`),console.log(`Session force-killed.`)}catch{console.log(`Session exited during grace period.`)}else console.log(`Session stopped.`);d(s(m(),`${n.pid}.json`)).catch(()=>{})}async function C(e){let n=await f(),r=e.filter(e=>e!==`--bg`&&e!==`--background`);if(!n.supportsInteractiveInput&&!r.some(e=>e===`-p`||e===`--print`||e===`--pipe`)){console.error(`Error: Background sessions with detached engine require -p/--print flag.
3
3
  The detached engine has no terminal for interactive input.
4
4
 
5
5
  Usage:
@@ -1,3 +1,3 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{Ar as t,Ci as n,Er as r,Ir as i,Tr as a,_i as o,vr as s}from"./loadAgentsDir-CKSb56Gp.js";import{Kt as c,mt as l,tt as u}from"./state-Bs5xweDL.js";import{S as d,w as f}from"./debug-BdqxZ7rV.js";import{c as p,s as m}from"./types-DWRxAH0E.js";import{n as h,r as g}from"./analytics-DJobLaWP.js";import{i as _,o as v}from"./stringUtils-CbS6OkmE.js";import{randomUUID as y}from"crypto";import{mkdir as b,readFile as x,writeFile as S}from"fs/promises";function C(e){let t=e?.message?.content;if(!t)return`Branched conversation`;let n=typeof t==`string`?t:t.find(e=>e.type===`text`)?.text;return n&&n.replace(/\s+/g,` `).trim().slice(0,100)||`Branched conversation`}async function w(e){let t=y(),n=l(),o=s(u()),c=r(t),d=a();await b(o,{recursive:!0,mode:448});let m;try{m=await x(d)}catch{throw Error(`No conversation to branch`)}if(m.length===0)throw Error(`No conversation to branch`);let h=p(m),g=h.filter(e=>i(e)&&!e.isSidechain),_=h.filter(e=>e.type===`content-replacement`&&e.sessionId===n).flatMap(e=>e.replacements);if(g.length===0)throw Error(`No messages to branch`);let v=null,C=[],w=[];for(let e of g){let r={...e,sessionId:t,parentUuid:v,isSidechain:!1,forkedFrom:{sessionId:n,messageUuid:e.uuid}},i={...e,sessionId:t};w.push(i),C.push(f(r)),e.type!==`progress`&&(v=e.uuid)}if(_.length>0){let e={type:`content-replacement`,sessionId:t,replacements:_};C.push(f(e))}return await S(c,C.join(`
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{Cr as t,dr as n,hi as r,kr as i,li as a,vr as o,yr as s}from"./loadAgentsDir-C7lOqvfh.js";import{Wt as c,et as l,pt as u}from"./state-BemZdQIl.js";import{S as d,w as f}from"./debug-RAynG_nM.js";import{c as p,s as m}from"./types-3j8PS-Du.js";import{n as h,r as g}from"./analytics-DJobLaWP.js";import{i as _,o as v}from"./stringUtils-C84IJ91d.js";import{randomUUID as y}from"crypto";import{mkdir as b,readFile as x,writeFile as S}from"fs/promises";function C(e){let t=e?.message?.content;if(!t)return`Branched conversation`;let n=typeof t==`string`?t:t.find(e=>e.type===`text`)?.text;return n&&n.replace(/\s+/g,` `).trim().slice(0,100)||`Branched conversation`}async function w(e){let t=y(),r=u(),a=n(l()),c=s(t),d=o();await b(a,{recursive:!0,mode:448});let m;try{m=await x(d)}catch{throw Error(`No conversation to branch`)}if(m.length===0)throw Error(`No conversation to branch`);let h=p(m),g=h.filter(e=>i(e)&&!e.isSidechain),_=h.filter(e=>e.type===`content-replacement`&&e.sessionId===r).flatMap(e=>e.replacements);if(g.length===0)throw Error(`No messages to branch`);let v=null,C=[],w=[];for(let e of g){let n={...e,sessionId:t,parentUuid:v,isSidechain:!1,forkedFrom:{sessionId:r,messageUuid:e.uuid}},i={...e,sessionId:t};w.push(i),C.push(f(n)),e.type!==`progress`&&(v=e.uuid)}if(_.length>0){let e={type:`content-replacement`,sessionId:t,replacements:_};C.push(f(e))}return await S(c,C.join(`
2
2
  `)+`
3
- `,{encoding:`utf8`,mode:384}),{sessionId:t,title:e,forkPath:c,serializedMessages:w,contentReplacementRecords:_}}async function T(e){let t=`${e} (Branch)`;if((await n(t,{exact:!0})).length===0)return t;let r=await n(`${e} (Branch`),i=new Set([1]),a=RegExp(`^${_(e)} \\(Branch(?: (\\d+))?\\)$`);for(let e of r){let t=e.customTitle?.match(a);t&&(t[1]?i.add(parseInt(t[1],10)):i.add(1))}let o=2;for(;i.has(o);)o++;return`${e} (Branch ${o})`}async function E(e,t,n){let r=n?.trim()||void 0,i=l();try{let{sessionId:n,title:a,forkPath:s,serializedMessages:c,contentReplacementRecords:l}=await w(r),u=new Date,d=C(c.find(e=>e.type===`user`)),f=await T(a??d);await o(n,f,s),g(`tengu_conversation_forked`,{message_count:c.length,has_custom_title:!!a});let p={date:u.toISOString().split(`T`)[0],messages:c,fullPath:s,value:u.getTime(),created:u,modified:u,firstPrompt:d,messageCount:c.length,isSidechain:!1,sessionId:n,customTitle:f,contentReplacements:l},m=a?` "${a}"`:``,h=`Branched conversation${m}. You are now in the branch.${`\nTo resume the original: claude -r ${i}`}`;return t.resume?(await t.resume(n,p,`fork`),e(h,{display:`system`})):e(`Branched conversation${m}. Resume with: /resume ${n}`),null}catch(t){return e(`Failed to branch conversation: ${t instanceof Error?t.message:`Unknown error occurred`}`),null}}e((()=>{c(),h(),m(),t(),d(),v()}))();export{E as call,C as deriveFirstPrompt};
3
+ `,{encoding:`utf8`,mode:384}),{sessionId:t,title:e,forkPath:c,serializedMessages:w,contentReplacementRecords:_}}async function T(e){let t=`${e} (Branch)`;if((await r(t,{exact:!0})).length===0)return t;let n=await r(`${e} (Branch`),i=new Set([1]),a=RegExp(`^${_(e)} \\(Branch(?: (\\d+))?\\)$`);for(let e of n){let t=e.customTitle?.match(a);t&&(t[1]?i.add(parseInt(t[1],10)):i.add(1))}let o=2;for(;i.has(o);)o++;return`${e} (Branch ${o})`}async function E(e,t,n){let r=n?.trim()||void 0,i=u();try{let{sessionId:n,title:o,forkPath:s,serializedMessages:c,contentReplacementRecords:l}=await w(r),u=new Date,d=C(c.find(e=>e.type===`user`)),f=await T(o??d);await a(n,f,s),g(`tengu_conversation_forked`,{message_count:c.length,has_custom_title:!!o});let p={date:u.toISOString().split(`T`)[0],messages:c,fullPath:s,value:u.getTime(),created:u,modified:u,firstPrompt:d,messageCount:c.length,isSidechain:!1,sessionId:n,customTitle:f,contentReplacements:l},m=o?` "${o}"`:``,h=`Branched conversation${m}. You are now in the branch.${`\nTo resume the original: claude -r ${i}`}`;return t.resume?(await t.resume(n,p,`fork`),e(h,{display:`system`})):e(`Branched conversation${m}. Resume with: /resume ${n}`),null}catch(t){return e(`Failed to branch conversation: ${t instanceof Error?t.message:`Unknown error occurred`}`),null}}e((()=>{c(),h(),m(),t(),d(),v()}))();export{E as call,C as deriveFirstPrompt};
@@ -1,8 +1,8 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,o as n}from"./envUtils-BDhHQY0-.js";import{Kt as r,z as i}from"./state-Bs5xweDL.js";import{join as a}from"node:path";import{appendFileSync as o,existsSync as s,mkdirSync as c,readFileSync as l,unlinkSync as u,writeFileSync as d}from"node:fs";function f(){return a(t(),`.next-request-no-cache`)}function p(){return a(t(),`.break-cache-always`)}function m(){return a(t(),`break-cache-events.jsonl`)}function h(){try{let e=l(m(),`utf8`).trim().split(`
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,o as n}from"./envUtils-BDhHQY0-.js";import{Wt as r,z as i}from"./state-BemZdQIl.js";import{join as a}from"node:path";import{appendFileSync as o,existsSync as s,mkdirSync as c,readFileSync as l,unlinkSync as u,writeFileSync as d}from"node:fs";function f(){return a(t(),`.next-request-no-cache`)}function p(){return a(t(),`.break-cache-always`)}function m(){return a(t(),`break-cache-events.jsonl`)}function h(){try{let e=l(m(),`utf8`).trim().split(`
2
2
  `).filter(Boolean).map(e=>{try{return JSON.parse(e)}catch{return null}}).filter(e=>e!==null),t=e.filter(e=>e.kind===`once`),n=e[e.length-1],r=e.filter(e=>e.kind===`always_on`||e.kind===`always_off`),i=r[r.length-1];return{totalBreaks:t.length,lastBreakAt:n?.at??null,alwaysModeEnabled:i?.kind===`always_on`}}catch{return{totalBreaks:0,lastBreakAt:null,alwaysModeEnabled:!1}}}function g(e){let n=m();c(t(),{recursive:!0});let r={at:new Date().toISOString(),kind:e};o(n,JSON.stringify(r)+`
3
3
  `,`utf8`)}function _(){g(`once`)}async function v(e){let t=e.trim().toLowerCase(),n=f(),r=p();if(t===`status`){let e=h(),t=s(n),i=s(r);return{type:`text`,value:[`## Break-Cache Status`,``,` Once marker: ${t?`ACTIVE (next call will bust cache)`:`not set`}`,` Always mode: ${i?`ON (every call busts cache)`:`off`}`,``,`## Stats`,` total_breaks: ${e.totalBreaks}`,` last_break_at: ${e.lastBreakAt??`never`}`].join(`
4
4
  `)}}if(t===`off`){let e=!1;return s(n)&&(u(n),e=!0),s(r)&&(u(r),e=!0),g(`always_off`),{type:`text`,value:e?`Break-cache disabled. Removed once marker and/or always flag.`:`Break-cache was not active.`}}if(t===`--clear`)return s(n)?(u(n),{type:`text`,value:`Cache-break marker cleared.\n \`${n}\``}):{type:`text`,value:`No cache-break marker was set.`};if(t===`always`)return d(r,new Date().toISOString(),`utf8`),g(`always_on`),{type:`text`,value:[`## Always-on cache break enabled`,``,`Flag written: \`${r}\``,``,`Every API call will now append a random nonce to the system prompt,`,`permanently preventing prompt-cache hits for this session.`,``,"To disable: `/break-cache off`"].join(`
5
5
  `)};if(t===``||t===`once`){let e=new Date().toISOString();d(n,e,`utf8`),_();let t=h();return{type:`text`,value:[`## Cache break scheduled`,``,`Marker written: \`${n}\``,`Timestamp: ${e}`,``,`The next API call will append a random nonce to the system prompt,`,`causing a cache miss. The marker is removed automatically after use.`,``,"To cancel before the next call: `/break-cache --clear`","For every call: `/break-cache always`",``,`Total breaks this session: ${t.totalBreaks}`,``,`_How it works: The prompt cache keys on the system-prompt prefix hash._`,`_A unique nonce invalidates the hash, forcing a fresh compute._`].join(`
6
6
  `)}}return{type:`text`,value:[`Unknown scope: "${t}"`,``,y].join(`
7
7
  `)}}var y,b,x,S=e((()=>{r(),n(),y=[`Usage: /break-cache [scope]`,``,` (no args) Schedule a one-time cache break for the next API call`,` once Same as no args`,` always Enable persistent cache-break mode (every request)`,` off Disable always mode and clear any pending marker`,` --clear Clear the pending once marker (cancel before next call)`,` status Show current break-cache status and stats`,``,`How it works:`,` The prompt cache keys on the system-prompt prefix hash.`,` A unique nonce invalidates the hash, forcing a fresh compute.`,` This is useful when you want to ensure a clean context window.`].join(`
8
- `),b={type:`local-jsx`,name:`break-cache`,description:`Manage prompt-cache breaking. Open actions or run: once, status, always, off`,isHidden:!1,isEnabled:()=>!i(),argumentHint:`[once|status|always|off|--clear]`,load:()=>import(`./panel-q0_iT9cg.js`)},x={type:`local`,name:`break-cache`,description:`Force the next (or all) API call(s) to miss prompt cache. Scopes: once, status, always, off`,isHidden:!1,isEnabled:()=>i(),supportsNonInteractive:!0,load:async()=>({call:v})}}));export{f as a,p as i,x as n,S as o,v as r,b as t};
8
+ `),b={type:`local-jsx`,name:`break-cache`,description:`Manage prompt-cache breaking. Open actions or run: once, status, always, off`,isHidden:!1,isEnabled:()=>!i(),argumentHint:`[once|status|always|off|--clear]`,load:()=>import(`./panel-KW-wmEvU.js`)},x={type:`local`,name:`break-cache`,description:`Force the next (or all) API call(s) to miss prompt cache. Scopes: once, status, always, off`,isHidden:!1,isEnabled:()=>i(),supportsNonInteractive:!0,load:async()=>({call:v})}}));export{f as a,p as i,x as n,S as o,v as r,b as t};
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{l as t,u as n}from"./oauth-C9VBDB0Y.js";import{Bt as r,Ot as i}from"./model-C2e73CJD.js";function a(){return process.env.CLAUDE_BRIDGE_OAUTH_TOKEN||void 0}function o(){return process.env.CLAUDE_BRIDGE_BASE_URL||void 0}function s(){return a()??i()?.accessToken}function c(){return o()??t().BASE_API_URL}function l(){return!!o()}var u=e((()=>{n(),r()}));export{u as a,a as i,c as n,l as o,o as r,s as t};
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{l as t,u as n}from"./oauth-C9VBDB0Y.js";import{Bt as r,Ot as i}from"./model-BsZ4sP_H.js";function a(){return process.env.CLAUDE_BRIDGE_OAUTH_TOKEN||void 0}function o(){return process.env.CLAUDE_BRIDGE_BASE_URL||void 0}function s(){return a()??i()?.accessToken}function c(){return o()??t().BASE_API_URL}function l(){return!!o()}var u=e((()=>{n(),r()}));export{u as a,a as i,c as n,l as o,o as r,s as t};
@@ -0,0 +1 @@
1
+ import{a as e,n as t,o as n,t as r}from"./bridgeConfig-Bb6URf4Q.js";e();export{r as getBridgeAccessToken,t as getBridgeBaseUrl,n as isSelfHostedBridge};
@@ -0,0 +1 @@
1
+ import{o as e}from"./envUtils-BDhHQY0-.js";import{n as t,t as n}from"./defineProperty-C-QyHrDq.js";import{C as r,F as i,S as a,a as o,l as s,z as c}from"./debug-RAynG_nM.js";import{B as l,F as u,H as d,I as f,O as p,b as m,g as h,m as g,q as _}from"./log-CezCRpAN.js";import{n as v,r as y}from"./analytics-DJobLaWP.js";import{M as b,st as x}from"./sessionState-Bifmu95-.js";import{n as S,t as C}from"./rcDebugLog-CARUIORE.js";import{t as w}from"./controlMessageCompat-IFu4Gc1y.js";import{randomUUID as T}from"crypto";e();async function E(){return!1}function D(){return!1}function O(){return!0}function k(){return null}v(),b(),o(),C(),g(),c(),a(),_(),t();function A(e){return typeof e==`object`&&!!e&&`type`in e&&typeof e.type==`string`}function j(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`control_response`&&`response`in e}function M(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`control_request`&&`request_id`in e&&`request`in e}function N(e){return(e.type===`user`||e.type===`assistant`)&&e.isVirtual?!1:e.type===`user`||e.type===`assistant`||e.type===`system`&&e.subtype===`local_command`}function P(e){if(e.type!==`user`||e.isMeta||e.toolUseResult||e.isCompactSummary||e.origin&&e.origin.kind!==`human`)return;let t=e.message.content,n;if(typeof t==`string`)n=t;else for(let e of t??[])if(e.type===`text`){n=e.text;break}if(n)return h(n)||void 0}var F=`system-reminder`,I=/\s*<([a-z][\w-]*)(?:\s[^>]*)?>[\s\S]*?<\/\1>\s*/gy,L=new Set([m,p,u,f,l,d]);function R(e){let t=e.message?.content;return typeof t==`string`?t:Array.isArray(t)?t.filter(e=>!!e&&typeof e==`object`&&e.type===`text`&&typeof e.text==`string`).map(e=>e.text).join(``):``}function z(e){let t=e.trim();if(!t)return null;I.lastIndex=0;let n=[];for(;I.lastIndex<t.length;){let e=I.exec(t);if(!e)return null;n.push(e[1])}return n.length>0?n:null}function B(e){if(e.type!==`user`||e.isVisibleInTranscriptOnly)return!1;if(e.toolUseResult!==void 0||!e.isMeta)return!0;let t=z(R(e));return!t||t.some(e=>e!==`local-command-caveat`&&e!==F&&L.has(e))}function V(e){return e.some(B)}function H(e,t,n,a,o,c){try{let i=w(r(e));if(j(i)){s(`[bridge:repl] Ingress message type=control_response`),o?.(i);return}if(M(i)){s(`[bridge:repl] Inbound control_request subtype=${i.request.subtype}`),c?.(i);return}if(!A(i))return;let l=`uuid`in i&&typeof i.uuid==`string`?i.uuid:void 0;if(l&&t.has(l)){s(`[bridge:repl] Ignoring echo: type=${i.type} uuid=${l}`);return}if(l&&n.has(l)){s(`[bridge:repl] Ignoring re-delivered inbound: type=${i.type} uuid=${l}`);return}s(`[bridge:repl] Ingress message type=${i.type}${l?` uuid=${l}`:``}`),i.type===`user`?(l&&n.add(l),y(`tengu_bridge_message_received`,{is_repl:!0}),a?.(i)):s(`[bridge:repl] Ignoring non-user inbound message: type=${i.type}`)}catch(e){s(`[bridge:repl] Failed to parse ingress message: ${i(e)}`)}}var U=`This session is outbound-only. Enable Remote Control locally to allow inbound control.`;function W(e,t){let{transport:n,sessionId:r,outboundOnly:i,onInterrupt:a,onSetModel:o,onSetMaxThinkingTokens:c,onSetPermissionMode:l}=t;if(!n){s(`[bridge:repl] Cannot respond to control_request: transport not configured`);return}let u,d=e.request;if(i&&d.subtype!==`initialize`){u={type:`control_response`,response:{subtype:`error`,request_id:e.request_id,error:U}};let t={...u,session_id:r};n.write(t),s(`[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`:o?.(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}`),s(`[bridge:repl] Sent control_response for ${d.subtype} request_id=${e.request_id} result=${u.response.subtype}`)}function G(e){return{type:`result_success`,subtype:`success`,duration_ms:0,duration_api_ms:0,is_error:!1,num_turns:0,result:``,stop_reason:null,total_cost_usd:0,usage:{...x},modelUsage:{},permission_denials:[],session_id:e,uuid:T()}}var K=class{constructor(e){n(this,`capacity`,void 0),n(this,`ring`,void 0),n(this,`set`,new Set),n(this,`writeIdx`,0),this.capacity=e,this.ring=Array(e)}add(e){if(this.set.has(e))return;let t=this.ring[this.writeIdx];t!==void 0&&this.set.delete(t),this.ring[this.writeIdx]=e,this.set.add(e),this.writeIdx=(this.writeIdx+1)%this.capacity}has(e){return this.set.has(e)}clear(){this.set.clear(),this.ring.fill(void 0),this.writeIdx=0}};export{N as a,V as c,O as d,D as f,W as i,k as l,P as n,G as o,H as r,B as s,K as t,E as u};
@@ -1 +1 @@
1
- import{A as e,l as t,w as n}from"./external-CEp-aPkt.js";import{n as r,r as i,t as a}from"./lazySchema-B4D4qJVE.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-BdqxZ7rV.js";import{_ as p,c as m,l as h,m as g}from"./sessionStoragePortable-JZnGwqUM.js";import{dirname as _,join as v}from"path";import{mkdir as y,readFile as b,stat as x,unlink as S,writeFile as C}from"fs/promises";i(),l(),f(),p(),a(),h(),s();var w=r(()=>n({sessionId:e(),environmentId:e(),source:t([`standalone`,`repl`])}));function T(e){return v(m(),g(e),`bridge-pointer.json`)}async function E(e,t){let n=T(e);try{await y(_(n),{recursive:!0}),await C(n,d(t),`utf8`),u(`[bridge:pointer] wrote ${n}`)}catch(e){u(`[bridge:pointer] write failed: ${e}`,{level:`warn`})}}async function D(e){let t=T(e),n,r;try{r=(await x(t)).mtimeMs,n=await b(t,`utf8`)}catch{return null}let i=w().safeParse(k(n));if(!i.success)return u(`[bridge:pointer] invalid schema, clearing: ${t}`),await O(e),null;let a=Math.max(0,Date.now()-r);return a>144e5?(u(`[bridge:pointer] stale (>4h mtime), clearing: ${t}`),await O(e),null):{...i.data,ageMs:a}}async function O(e){let t=T(e);try{await S(t),u(`[bridge:pointer] cleared ${t}`)}catch(e){c(e)||u(`[bridge:pointer] clear failed: ${e}`,{level:`warn`})}}function k(e){try{return o(e)}catch{return null}}export{O as clearBridgePointer,D as readBridgePointer,E as writeBridgePointer};
1
+ import{A as e,l as t,w as n}from"./external-CEp-aPkt.js";import{n as r,r as i,t as a}from"./lazySchema-B4D4qJVE.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-RAynG_nM.js";import{_ as p,c as m,l as h,m as g}from"./sessionStoragePortable-JZnGwqUM.js";import{dirname as _,join as v}from"path";import{mkdir as y,readFile as b,stat as x,unlink as S,writeFile as C}from"fs/promises";i(),l(),f(),p(),a(),h(),s();var w=r(()=>n({sessionId:e(),environmentId:e(),source:t([`standalone`,`repl`])}));function T(e){return v(m(),g(e),`bridge-pointer.json`)}async function E(e,t){let n=T(e);try{await y(_(n),{recursive:!0}),await C(n,d(t),`utf8`),u(`[bridge:pointer] wrote ${n}`)}catch(e){u(`[bridge:pointer] write failed: ${e}`,{level:`warn`})}}async function D(e){let t=T(e),n,r;try{r=(await x(t)).mtimeMs,n=await b(t,`utf8`)}catch{return null}let i=w().safeParse(k(n));if(!i.success)return u(`[bridge:pointer] invalid schema, clearing: ${t}`),await O(e),null;let a=Math.max(0,Date.now()-r);return a>144e5?(u(`[bridge:pointer] stale (>4h mtime), clearing: ${t}`),await O(e),null):{...i.data,ageMs:a}}async function O(e){let t=T(e);try{await S(t),u(`[bridge:pointer] cleared ${t}`)}catch(e){c(e)||u(`[bridge:pointer] clear failed: ${e}`,{level:`warn`})}}function k(e){try{return o(e)}catch{return null}}export{O as clearBridgePointer,D as readBridgePointer,E as writeBridgePointer};
@@ -0,0 +1 @@
1
+ import{HS as e,WS as t}from"./loadAgentsDir-C7lOqvfh.js";import{t as n}from"./src-P_wYS_NJ2.js";import{v as r}from"./startupProfiler-L_UWZ03w.js";import{a as i,n as a,o}from"./bridgeConfig-Bb6URf4Q.js";t(),i(),n(),r();function s(t,n){return`${o()?a():e(void 0,n)}/code?bridge=${t}`}function c({error:e,connected:t,sessionActive:n,reconnecting:r}){return e?{label:`Remote Control failed`,color:`error`}:r?{label:`Remote Control reconnecting`,color:`warning`}:n||t?{label:`Remote Control active`,color:`success`}:{label:`Remote Control connecting…`,color:`warning`}}function l(e){return`Code everywhere with the Claude app or ${e}`}function u(e){return`Continue coding in the Claude app or ${e}`}var d=`Something went wrong, please try again`;export{c as a,l as i,u as n,s as r,d as t};
@@ -1 +1 @@
1
- import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{AS as n,Cc as r,Cy as i,Gu as a,Qa as o,Sc as s,Ty as c,Wa as l,Wu as u,ct as d,fm as f,kS as p,lt as m,mm as h,pw as g,wy as _,zg as v}from"./loadAgentsDir-CKSb56Gp.js";import{I as y,P as b,bn as x,fi as S,ot as C,t as w,vn as T,xt as E}from"./src-P_wYS_NJ2.js";import{t as D}from"./jsx-runtime-Bb4Xn-E0.js";import{F as O,z as k}from"./debug-BdqxZ7rV.js";import{Ut as A}from"./settings-Xbq6AaD-.js";import{h as j,y as M}from"./config-D4G8_MqJ.js";import{gt as N}from"./sessionState-BvECKycx.js";import{n as P,r as F}from"./sideQuestion-D2dPToW8.js";import{i as I,n as L}from"./modalContext-CUThy6Ph.js";function R({question:e,context:t,onDone:n}){let[r,i]=(0,H.useState)(null),[a,o]=(0,H.useState)(null),[s,c]=(0,H.useState)(0),l=(0,H.useRef)(null),{rows:d}=I(C());x(()=>c(e=>e+1),r||a?null:80);function m(e){if(e.key===`escape`||e.key===`return`||e.key===` `||e.ctrl&&(e.key===`c`||e.key===`d`)){e.preventDefault(),n(void 0,{display:`skip`});return}(e.key===`up`||e.ctrl&&e.key===`p`)&&(e.preventDefault(),l.current?.scrollBy(-3)),(e.key===`down`||e.ctrl&&e.key===`n`)&&(e.preventDefault(),l.current?.scrollBy(K))}(0,H.useEffect)(()=>{let n=p();async function r(){try{let r=await F({question:e,cacheSafeParams:await B(t)});n.signal.aborted||(r.response?i(r.response):o(`No response received`))}catch(e){n.signal.aborted||o(O(e)||`Failed to get response`)}}return r(),()=>{n.abort()}},[e,t]);let h=Math.max(5,d-W-G);return(0,U.jsxs)(y,{flexDirection:`column`,paddingLeft:2,marginTop:1,tabIndex:0,autoFocus:!0,onKeyDown:m,children:[(0,U.jsxs)(y,{children:[(0,U.jsxs)(b,{color:`warning`,bold:!0,children:[`/btw`,` `]}),(0,U.jsx)(b,{dimColor:!0,children:e})]}),(0,U.jsx)(y,{marginTop:1,marginLeft:2,maxHeight:h,children:(0,U.jsx)(E,{ref:l,flexDirection:`column`,flexGrow:1,children:a?(0,U.jsx)(b,{color:`error`,children:a}):r?(0,U.jsx)(f,{children:r}):(0,U.jsxs)(y,{children:[(0,U.jsx)(u,{frame:s,messageColor:`warning`}),(0,U.jsx)(b,{color:`warning`,children:`Answering...`})]})})}),(r||a)&&(0,U.jsx)(y,{marginTop:1,children:(0,U.jsxs)(b,{dimColor:!0,children:[`↑`,`/`,`↓`,` to scroll · Space, Enter, or Escape to dismiss`]})})]})}function z(e){let t=e.at(-1);return t?.type===`assistant`&&t.message.stop_reason===null?e.slice(0,-1):e}async function B(e){let t=l(z(e.messages)),n=s();if(n)return{systemPrompt:n.systemPrompt,userContext:n.userContext,systemContext:n.systemContext,toolUseContext:e,forkContextMessages:t};let[r,a,o]=await Promise.all([d(e.options.tools,e.options.mainLoopModel,[],e.options.mcpClients),_(),i()]);return{systemPrompt:N(r),userContext:a,systemContext:o,toolUseContext:e,forkContextMessages:t}}async function V(e,t,n){let r=n?.trim();return r?(M(e=>({...e,btwUseCount:e.btwUseCount+1})),(0,U.jsx)(R,{question:r,context:t,onDone:e})):(e(`Usage: /btw <your question>`,{display:`system`}),null)}var H,U,W,G,K;e((()=>{S(),H=t(S(),1),T(),h(),a(),A(),m(),L(),c(),g(),w(),n(),j(),k(),r(),o(),P(),v(),U=D(),W=5,G=6,K=3}))();export{V as call};
1
+ import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{$C as n,Ba as r,Cv as i,Hu as a,Ma as o,Np as s,Sv as c,Vu as l,_x as u,ct as d,jp as f,lt as p,mc as m,pc as h,vx as g,xv as _,yv as v}from"./loadAgentsDir-C7lOqvfh.js";import{I as y,P as b,bn as x,fi as S,ot as C,t as w,vn as T,xt as E}from"./src-P_wYS_NJ2.js";import{t as D}from"./jsx-runtime-Bb4Xn-E0.js";import{F as O,z as k}from"./debug-RAynG_nM.js";import{Ut as A}from"./settings-DnptdP79.js";import{h as j,y as M}from"./config-Do1870_d.js";import{at as N}from"./sessionState-Bifmu95-.js";import{n as P,r as F}from"./sideQuestion-D0OKljee.js";import{i as I,n as L}from"./modalContext-CUThy6Ph.js";function R({question:e,context:t,onDone:n}){let[r,i]=(0,H.useState)(null),[a,o]=(0,H.useState)(null),[s,c]=(0,H.useState)(0),d=(0,H.useRef)(null),{rows:p}=I(C());x(()=>c(e=>e+1),r||a?null:80);function m(e){if(e.key===`escape`||e.key===`return`||e.key===` `||e.ctrl&&(e.key===`c`||e.key===`d`)){e.preventDefault(),n(void 0,{display:`skip`});return}(e.key===`up`||e.ctrl&&e.key===`p`)&&(e.preventDefault(),d.current?.scrollBy(-3)),(e.key===`down`||e.ctrl&&e.key===`n`)&&(e.preventDefault(),d.current?.scrollBy(K))}(0,H.useEffect)(()=>{let n=u();async function r(){try{let r=await F({question:e,cacheSafeParams:await B(t)});n.signal.aborted||(r.response?i(r.response):o(`No response received`))}catch(e){n.signal.aborted||o(O(e)||`Failed to get response`)}}return r(),()=>{n.abort()}},[e,t]);let h=Math.max(5,p-W-G);return(0,U.jsxs)(y,{flexDirection:`column`,paddingLeft:2,marginTop:1,tabIndex:0,autoFocus:!0,onKeyDown:m,children:[(0,U.jsxs)(y,{children:[(0,U.jsxs)(b,{color:`warning`,bold:!0,children:[`/btw`,` `]}),(0,U.jsx)(b,{dimColor:!0,children:e})]}),(0,U.jsx)(y,{marginTop:1,marginLeft:2,maxHeight:h,children:(0,U.jsx)(E,{ref:d,flexDirection:`column`,flexGrow:1,children:a?(0,U.jsx)(b,{color:`error`,children:a}):r?(0,U.jsx)(f,{children:r}):(0,U.jsxs)(y,{children:[(0,U.jsx)(l,{frame:s,messageColor:`warning`}),(0,U.jsx)(b,{color:`warning`,children:`Answering...`})]})})}),(r||a)&&(0,U.jsx)(y,{marginTop:1,children:(0,U.jsxs)(b,{dimColor:!0,children:[`↑`,`/`,`↓`,` to scroll · Space, Enter, or Escape to dismiss`]})})]})}function z(e){let t=e.at(-1);return t?.type===`assistant`&&t.message.stop_reason===null?e.slice(0,-1):e}async function B(e){let t=o(z(e.messages)),n=h();if(n)return{systemPrompt:n.systemPrompt,userContext:n.userContext,systemContext:n.systemContext,toolUseContext:e,forkContextMessages:t};let[r,i,a]=await Promise.all([d(e.options.tools,e.options.mainLoopModel,[],e.options.mcpClients),c(),_()]);return{systemPrompt:N(r),userContext:i,systemContext:a,toolUseContext:e,forkContextMessages:t}}async function V(e,t,n){let r=n?.trim();return r?(M(e=>({...e,btwUseCount:e.btwUseCount+1})),(0,U.jsx)(R,{question:r,context:t,onDone:e})):(e(`Usage: /btw <your question>`,{display:`system`}),null)}var H,U,W,G,K;e((()=>{S(),H=t(S(),1),T(),s(),a(),A(),p(),L(),i(),n(),w(),g(),j(),k(),m(),r(),P(),v(),U=D(),W=5,G=6,K=3}))();export{V as call};
@@ -0,0 +1 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{$i as t,Ai as n,Au as r,Bi as i,Cv as a,Ev as o,J as s,Jv as c,Kh as l,Ms as u,Ns as d,Sv as f,Tb as p,Tv as m,X as h,Xv as g,Yi as _,bv as v,cp as y,hm as b,hw as x,ih as S,ju as C,lp as w,mw as T,oh as E,qh as D,wb as O,wv as k,xv as A}from"./loadAgentsDir-C7lOqvfh.js";import{On as j,Wt as M,l as N}from"./state-BemZdQIl.js";import{S as P,v as F}from"./git-2c7WlGDL.js";import{i as I,t as L}from"./detectRepository-DgpNd87p.js";import{a as R,n as z}from"./fileSuggestions-BMfQIDdW.js";import{r as B,t as V}from"./magicDocs-BpVcON9o.js";function H(e=new Set){let t=e.size>0;f.cache.clear?.(),A.cache.clear?.(),v.cache.clear?.(),m.cache.clear?.(),z(),n(),t||g(),k(null),j(null),E(),d(),p(`session_start`),y(),r(),import(`./attributionHooks-CUAoGkU6.js`).then(({clearAttributionCaches:e})=>e()),L(),s(),N(e),F(),_(),D(),V(),T(),import(`./SearchExtraToolsTool-i_YO3QvV.js`).then(({clearSearchExtraToolsDescriptionCache:e})=>e()),import(`./loadAgentsDir-zikjxLvn.js`).then(({clearAgentDefinitionsCache:e})=>e()),import(`./prompt-DZhBz_Vu.js`).then(({clearPromptCache:e})=>e())}var U=e((()=>{M(),i(),o(),a(),R(),b(),c(),C(),S(),l(),B(),t(),u(),h(),O(),I(),P(),w(),x()}));export{U as n,H as t};
@@ -0,0 +1 @@
1
+ import{n as e,t}from"./caches-BTQAW9zc.js";e();export{t as clearSessionCaches};
@@ -1,3 +1,3 @@
1
- import{n as e,t}from"./defineProperty-C-QyHrDq.js";import{n,t as r}from"./axios-DaWTGg7G.js";import{i,o as a,t as o}from"./debugUtils-CezNYZ-4.js";import{n as s,t as c}from"./rcDebugLog-CARUIORE.js";r(),a(),c();var l=1440*60*1e3,u=`Remote Control requires authentication.`,d=`Error: You must be logged in to use Remote Control.
1
+ import{n as e,t}from"./defineProperty-C-QyHrDq.js";import{n,t as r}from"./axios-DaWTGg7G.js";import{i,o as a,t as o}from"./debugUtils-DX0KAXNK.js";import{n as s,t as c}from"./rcDebugLog-CARUIORE.js";r(),a(),c();var l=1440*60*1e3,u=`Remote Control requires authentication.`,d=`Error: You must be logged in to use Remote Control.
2
2
 
3
3
  Remote Control requires authentication.`;e();var f=`environments-2025-11-01`,p=/^[a-zA-Z0-9_-]+$/;function m(e,t){if(!e||!p.test(e))throw Error(`Invalid ${t}: contains unsafe characters`);return e}var h=class extends Error{constructor(e,n,r){super(e),t(this,`status`,void 0),t(this,`errorType`,void 0),this.name=`BridgeFatalError`,this.status=n,this.errorType=r}};function g(e){function t(t){e.onDebug?.(t)}let r=0;function i(t){let n={Authorization:`Bearer ${t}`,"Content-Type":`application/json`,"anthropic-version":`2023-06-01`,"anthropic-beta":f,"x-environment-runner-version":e.runnerVersion},r=e.getTrustedDeviceToken?.();return r&&(n[`X-Trusted-Device-Token`]=r),n}function a(){let t=e.getAccessToken();if(!t)throw Error(u);return t}async function c(n,r){let i=a(),o=await n(i);if(o.status!==401)return o;if(!e.onAuth401)return t(`[bridge:api] ${r}: 401 received, no refresh handler`),o;if(t(`[bridge:api] ${r}: 401 received, attempting token refresh`),await e.onAuth401(i)){t(`[bridge:api] ${r}: Token refreshed, retrying request`);let e=await n(a());if(e.status!==401)return e;t(`[bridge:api] ${r}: Retry after refresh also got 401`)}else t(`[bridge:api] ${r}: Token refresh failed`);return o}return{async registerBridgeEnvironment(r){t(`[bridge:api] POST /v1/environments/bridge bridgeId=${r.bridgeId}`);let a=await c(t=>n.post(`${e.baseUrl}/v1/environments/bridge`,{machine_name:r.machineName,directory:r.dir,branch:r.branch,git_repo_url:r.gitRepoUrl,max_sessions:r.maxSessions,metadata:{worker_type:r.workerType},...r.reuseEnvironmentId&&{environment_id:r.reuseEnvironmentId}},{headers:i(t),timeout:15e3,validateStatus:e=>e<500}),`Registration`);return _(a.status,a.data,`Registration`),t(`[bridge:api] POST /v1/environments/bridge -> ${a.status} environment_id=${a.data.environment_id}`),t(`[bridge:api] >>> ${o({machine_name:r.machineName,directory:r.dir,branch:r.branch,git_repo_url:r.gitRepoUrl,max_sessions:r.maxSessions,metadata:{worker_type:r.workerType}})}`),t(`[bridge:api] <<< ${o(a.data)}`),a.data},async pollForWork(a,c,l,u){m(a,`environmentId`);let d=r;r=0;let f=await n.get(`${e.baseUrl}/v1/environments/${a}/work/poll`,{headers:i(c),params:u===void 0?void 0:{reclaim_older_than_ms:u},timeout:1e4,signal:l,validateStatus:e=>e<500});return _(f.status,f.data,`Poll`),s(`poll response: status=${f.status} hasData=${!!f.data} url=${e.baseUrl}`),f.data?(t(`[bridge:api] GET .../work/poll -> ${f.status} workId=${f.data.id} type=${f.data.data?.type}${f.data.data?.id?` sessionId=${f.data.data.id}`:``}`),t(`[bridge:api] <<< ${o(f.data)}`),f.data):(r=d+1,(r===1||r%100==0)&&t(`[bridge:api] GET .../work/poll -> ${f.status} (no work, ${r} consecutive empty polls)`),null)},async acknowledgeWork(r,a,o){m(r,`environmentId`),m(a,`workId`),t(`[bridge:api] POST .../work/${a}/ack`);let s=await n.post(`${e.baseUrl}/v1/environments/${r}/work/${a}/ack`,{},{headers:i(o),timeout:1e4,validateStatus:e=>e<500});_(s.status,s.data,`Acknowledge`),t(`[bridge:api] POST .../work/${a}/ack -> ${s.status}`)},async stopWork(r,a,o){m(r,`environmentId`),m(a,`workId`),t(`[bridge:api] POST .../work/${a}/stop force=${o}`);let s=await c(t=>n.post(`${e.baseUrl}/v1/environments/${r}/work/${a}/stop`,{force:o},{headers:i(t),timeout:1e4,validateStatus:e=>e<500}),`StopWork`);_(s.status,s.data,`StopWork`),t(`[bridge:api] POST .../work/${a}/stop -> ${s.status}`)},async deregisterEnvironment(r){m(r,`environmentId`),t(`[bridge:api] DELETE /v1/environments/bridge/${r}`);let a=await c(t=>n.delete(`${e.baseUrl}/v1/environments/bridge/${r}`,{headers:i(t),timeout:1e4,validateStatus:e=>e<500}),`Deregister`);_(a.status,a.data,`Deregister`),t(`[bridge:api] DELETE /v1/environments/bridge/${r} -> ${a.status}`)},async archiveSession(r){m(r,`sessionId`),t(`[bridge:api] POST /v1/sessions/${r}/archive`);let a=await c(t=>n.post(`${e.baseUrl}/v1/sessions/${r}/archive`,{},{headers:i(t),timeout:1e4,validateStatus:e=>e<500}),`ArchiveSession`);if(a.status===409){t(`[bridge:api] POST /v1/sessions/${r}/archive -> 409 (already archived)`);return}_(a.status,a.data,`ArchiveSession`),t(`[bridge:api] POST /v1/sessions/${r}/archive -> ${a.status}`)},async reconnectSession(r,a){m(r,`environmentId`),m(a,`sessionId`),t(`[bridge:api] POST /v1/environments/${r}/bridge/reconnect session_id=${a}`);let o=await c(t=>n.post(`${e.baseUrl}/v1/environments/${r}/bridge/reconnect`,{session_id:a},{headers:i(t),timeout:1e4,validateStatus:e=>e<500}),`ReconnectSession`);_(o.status,o.data,`ReconnectSession`),t(`[bridge:api] POST .../bridge/reconnect -> ${o.status}`)},async heartbeatWork(r,a,o){m(r,`environmentId`),m(a,`workId`),t(`[bridge:api] POST .../work/${a}/heartbeat`);let s=await n.post(`${e.baseUrl}/v1/environments/${r}/work/${a}/heartbeat`,{},{headers:i(o),timeout:1e4,validateStatus:e=>e<500});return _(s.status,s.data,`Heartbeat`),t(`[bridge:api] POST .../work/${a}/heartbeat -> ${s.status} lease_extended=${s.data.lease_extended} state=${s.data.state}`),s.data},async sendPermissionResponseEvent(r,a,s){m(r,`sessionId`),t(`[bridge:api] POST /v1/sessions/${r}/events type=${a.type}`);let c=await n.post(`${e.baseUrl}/v1/sessions/${r}/events`,{events:[a]},{headers:i(s),timeout:1e4,validateStatus:e=>e<500});_(c.status,c.data,`SendPermissionResponseEvent`),t(`[bridge:api] POST /v1/sessions/${r}/events -> ${c.status}`),t(`[bridge:api] >>> ${o({events:[a]})}`),t(`[bridge:api] <<< ${o(c.data)}`)}}}function _(e,t,n){if(e===200||e===204)return;let r=i(t),a=b(t);switch(e){case 401:throw new h(`${n}: Authentication failed (401)${r?`: ${r}`:``}. ${u}`,401,a);case 403:throw new h(v(a)?"Remote Control session has expired. Please restart with `claude remote-control` or /remote-control.":`${n}: Access denied (403)${r?`: ${r}`:``}. Check your organization permissions.`,403,a);case 404:throw new h(r??`${n}: Not found (404). Remote Control may not be available for this organization.`,404,a);case 410:throw new h(r??"Remote Control session has expired. Please restart with `claude remote-control` or /remote-control.",410,a??`environment_expired`);case 429:throw Error(`${n}: Rate limited (429). Polling too frequently.`);default:throw Error(`${n}: Failed with status ${e}${r?`: ${r}`:``}`)}}function v(e){return e?e.includes(`expired`)||e.includes(`lifetime`):!1}function y(e){return e.status===403?e.message.includes(`external_poll_sessions`)||e.message.includes(`environments:manage`):!1}function b(e){if(e&&typeof e==`object`&&`error`in e&&e.error&&typeof e.error==`object`&&`type`in e.error&&typeof e.error.type==`string`)return e.error.type}function x(e){let t=new AbortController;function n(){t.abort(),t=new AbortController}function r(){let n=new AbortController,r=()=>n.abort();if(e.aborted||t.signal.aborted)return n.abort(),{signal:n.signal,cleanup:()=>{}};e.addEventListener(`abort`,r,{once:!0});let i=t.signal;return i.addEventListener(`abort`,r,{once:!0}),{signal:n.signal,cleanup:()=>{e.removeEventListener(`abort`,r),i.removeEventListener(`abort`,r)}}}return{signal:r,wake:n}}export{y as a,l as c,v as i,h as n,m as o,g as r,d as s,x as t};
@@ -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-BdqxZ7rV.js";import{O as l,k as u}from"./git-B9uvt96d.js";import{_n as d,vn as f}from"./model-C2e73CJD.js";import{l as p,r as m}from"./proxy-Blq4W6Ox.js";import{n as h,t as g}from"./userAgent-Ng_TTjWr.js";import{F as _,I as v,P as y,S as b,g as x,v as S}from"./sessionState-BvECKycx.js";import{n as C}from"./jwtUtils-C9sdGhvT.js";import{randomUUID as w}from"crypto";c(),a(),l(),p(),h(),d(),v(),x(),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 f(this.retryDelay(n)),this.pending&&!this.closed&&(t=O(t,this.pending),this.pending=null)}}retryDelay(e){return Math.min(this.config.baseDelayMs*2**(e-1),this.config.maxDelayMs)+Math.random()*this.config.jitterMs}};function O(e,t){let n={...e};for(let[e,r]of Object.entries(t))(e===`external_metadata`||e===`internal_metadata`)&&n[e]&&typeof n[e]==`object`&&typeof r==`object`&&r?n[e]={...n[e],...r}:n[e]=r;return n}d(),e();var k=2e4,A=100;function j(){return!0}var M=class extends Error{constructor(e){super(`CCRClient init failed: ${e}`),t(this,`reason`,void 0),this.reason=e}},N=10;function P(){return{byMessage:new Map,scopeToMessage:new Map}}function F(e){return`${e.session_id}:${e.parent_tool_use_id??``}`}function I(e,t){let n=[],r=new Map;for(let i of e){let e=i.event;switch(e.type){case`message_start`:{let r=e.message.id,a=t.scopeToMessage.get(F(i));a&&t.byMessage.delete(a),t.scopeToMessage.set(F(i),r),t.byMessage.set(r,[]),n.push(i);break}case`content_block_delta`:{let a=e.delta;if(a.type!==`text_delta`){n.push(i);break}let o=t.scopeToMessage.get(F(i)),s=o?t.byMessage.get(o):void 0;if(!s){n.push(i);break}let c=e.index,l=s[c]??(s[c]=[]);l.push(a.text);let u=r.get(l);if(u){u.event.delta={type:`text_delta`,text:l.join(``)};break}let d={type:`stream_event`,uuid:i.uuid,session_id:i.session_id,parent_tool_use_id:i.parent_tool_use_id,event:{type:`content_block_delta`,index:c,delta:{type:`text_delta`,text:l.join(``)}}};r.set(l,d),n.push(d);break}default:n.push(i)}}return n}function L(e,t){e.byMessage.delete(t.message.id);let n=F(t);e.scopeToMessage.get(n)===t.message.id&&e.scopeToMessage.delete(n)}var R=class{constructor(e,n,r){if(t(this,`workerEpoch`,0),t(this,`heartbeatIntervalMs`,void 0),t(this,`heartbeatJitterFraction`,void 0),t(this,`heartbeatTimer`,null),t(this,`heartbeatInFlight`,!1),t(this,`closed`,!1),t(this,`consecutiveAuthFailures`,0),t(this,`currentState`,null),t(this,`sessionBaseUrl`,void 0),t(this,`sessionId`,void 0),t(this,`http`,m({keepAlive:!0})),t(this,`streamEventBuffer`,[]),t(this,`streamEventTimer`,null),t(this,`streamTextAccumulator`,P()),t(this,`workerState`,void 0),t(this,`eventUploader`,void 0),t(this,`internalEventUploader`,void 0),t(this,`deliveryUploader`,void 0),t(this,`onEpochMismatch`,void 0),t(this,`getAuthHeaders`,void 0),this.onEpochMismatch=r?.onEpochMismatch??(()=>{process.exit(1)}),this.heartbeatIntervalMs=r?.heartbeatIntervalMs??k,this.heartbeatJitterFraction=r?.heartbeatJitterFraction??0,this.getAuthHeaders=r?.getAuthHeaders??y,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(),S(()=>{this.writeEvent({type:`keep_alive`})}),o(`CCRClient: initialized, epoch=${this.workerEpoch}`),u(`info`,`cli_worker_lifecycle_initialized`,{epoch:this.workerEpoch,duration_ms:Date.now()-t});let{metadata:r,durationMs:i}=await n;return this.closed||u(`info`,`cli_worker_state_restored`,{duration_ms:i,had_state:r!==null}),r}async getWorkerState(){let e=Date.now(),t=this.getAuthHeaders();return Object.keys(t).length===0?{metadata:null,durationMs:0}:{metadata:(await this.getWithRetry(`${this.sessionBaseUrl}/worker`,t,`worker_state`))?.worker?.external_metadata??null,durationMs:Date.now()-e}}async request(e,t,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":g()},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`}),u(`error`,`cli_worker_token_expired_no_refresh`),this.onEpochMismatch()),this.consecutiveAuthFailures++,this.consecutiveAuthFailures>=N&&(o(`CCRClient: ${this.consecutiveAuthFailures} consecutive auth failures with a valid-looking token — server-side auth unrecoverable, exiting`,{level:`error`}),u(`error`,`cli_worker_auth_failures_exhausted`),this.onEpochMismatch())}if(o(`CCRClient: ${a} returned ${n.status}`,{level:`warn`}),u(`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`}),u(`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`}),u(`error`,`cli_worker_epoch_mismatch`),this.onEpochMismatch()}startHeartbeat(){this.stopHeartbeat();let e=()=>{let e=this.heartbeatIntervalMs*this.heartbeatJitterFraction*(2*Math.random()-1);this.heartbeatTimer=setTimeout(t,this.heartbeatIntervalMs+e)},t=()=>{this.sendHeartbeat(),this.heartbeatTimer!==null&&e()};e()}stopHeartbeat(){this.heartbeatTimer&&(clearTimeout(this.heartbeatTimer),this.heartbeatTimer=null)}async sendHeartbeat(){if(!this.heartbeatInFlight){this.heartbeatInFlight=!0;try{(await this.request(`post`,`/worker/heartbeat`,{session_id:this.sessionId,worker_epoch:this.workerEpoch},`Heartbeat`,{timeout:5e3})).ok&&o(`CCRClient: Heartbeat sent`)}finally{this.heartbeatInFlight=!1}}}async writeEvent(e){if(e.type===`stream_event`){this.streamEventBuffer.push(e),this.streamEventTimer||(this.streamEventTimer=setTimeout(()=>void this.flushStreamEventBuffer(),A));return}await this.flushStreamEventBuffer(),e.type===`assistant`&&L(this.streamTextAccumulator,e),await this.eventUploader.enqueue(this.toClientEvent(e))}toClientEvent(e){let t=e;return{payload:{...t,uuid:typeof t.uuid==`string`?t.uuid:w()}}}async flushStreamEventBuffer(){if(this.streamEventTimer&&(clearTimeout(this.streamEventTimer),this.streamEventTimer=null),this.streamEventBuffer.length===0)return;let e=this.streamEventBuffer;this.streamEventBuffer=[];let t=I(e,this.streamTextAccumulator);await this.eventUploader.enqueue(t.map(e=>({payload:e,ephemeral:!0})))}async writeInternalEvent(e,t,{isCompaction:n=!1,agentId:r}={}){let i={payload:{type:e,...t,uuid:typeof t.uuid==`string`?t.uuid:w()},...n&&{is_compaction:!0},...r&&{agent_id:r}};await this.internalEventUploader.enqueue(i)}flushInternalEvents(){return this.internalEventUploader.flush()}async flush(){return await this.flushStreamEventBuffer(),this.eventUploader.flush()}async readInternalEvents(){return this.paginatedGet(`/worker/internal-events`,{},`internal_events`)}async readSubagentInternalEvents(){return this.paginatedGet(`/worker/internal-events`,{subagents:`true`},`subagent_events`)}async paginatedGet(e,t,n){let r=this.getAuthHeaders();if(Object.keys(r).length===0)return null;let i=[],a;do{let o=new URL(`${this.sessionBaseUrl}${e}`);for(let[e,n]of Object.entries(t))o.searchParams.set(e,n);a&&o.searchParams.set(`cursor`,a);let s=await this.getWithRetry(o.toString(),r,n);if(!s)return null;i.push(...s.data??[]),a=s.next_cursor}while(a);return o(`CCRClient: Read ${i.length} internal events from ${e}${t.subagents?` (subagents)`:``}`),i}async getWithRetry(e,t,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":g()},validateStatus:j,timeout:3e4})}catch(t){o(`CCRClient: GET ${e} failed (attempt ${r}/10): ${n(t)}`,{level:`warn`}),r<10&&await f(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 f(Math.min(500*2**(r-1),3e4)+Math.random()*500)}return o(`CCRClient: GET retries exhausted`,{level:`error`}),u(`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(),b(),this.streamEventTimer&&(clearTimeout(this.streamEventTimer),this.streamEventTimer=null),this.streamEventBuffer=[],this.streamTextAccumulator.byMessage.clear(),this.streamTextAccumulator.scopeToMessage.clear(),this.workerState.close(),this.eventUploader.close(),this.internalEventUploader.close(),this.deliveryUploader.close()}};export{M as n,E as r,R as t};
1
+ import{n as e,t}from"./defineProperty-C-QyHrDq.js";import{F as n,I as r,S as i,a,l as o,w as s,z as c}from"./debug-RAynG_nM.js";import{O as l,k as u}from"./git-2c7WlGDL.js";import{_n as d,vn as f}from"./model-BsZ4sP_H.js";import{l as p,r as m}from"./proxy-CuMaO_YV.js";import{n as h,t as g}from"./userAgent-CIq27vUR.js";import{A as _,O as v,f as y,g as b,k as x,u as S}from"./sessionState-Bifmu95-.js";import{n as C}from"./jwtUtils-CUPXdX3W.js";import{randomUUID as w}from"crypto";c(),a(),l(),p(),h(),d(),_(),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 f(this.retryDelay(n)),this.pending&&!this.closed&&(t=O(t,this.pending),this.pending=null)}}retryDelay(e){return Math.min(this.config.baseDelayMs*2**(e-1),this.config.maxDelayMs)+Math.random()*this.config.jitterMs}};function O(e,t){let n={...e};for(let[e,r]of Object.entries(t))(e===`external_metadata`||e===`internal_metadata`)&&n[e]&&typeof n[e]==`object`&&typeof r==`object`&&r?n[e]={...n[e],...r}:n[e]=r;return n}d(),e();var k=2e4,A=100;function j(){return!0}var M=class extends Error{constructor(e){super(`CCRClient init failed: ${e}`),t(this,`reason`,void 0),this.reason=e}},N=10;function P(){return{byMessage:new Map,scopeToMessage:new Map}}function F(e){return`${e.session_id}:${e.parent_tool_use_id??``}`}function I(e,t){let n=[],r=new Map;for(let i of e){let e=i.event;switch(e.type){case`message_start`:{let r=e.message.id,a=t.scopeToMessage.get(F(i));a&&t.byMessage.delete(a),t.scopeToMessage.set(F(i),r),t.byMessage.set(r,[]),n.push(i);break}case`content_block_delta`:{let a=e.delta;if(a.type!==`text_delta`){n.push(i);break}let o=t.scopeToMessage.get(F(i)),s=o?t.byMessage.get(o):void 0;if(!s){n.push(i);break}let c=e.index,l=s[c]??(s[c]=[]);l.push(a.text);let u=r.get(l);if(u){u.event.delta={type:`text_delta`,text:l.join(``)};break}let d={type:`stream_event`,uuid:i.uuid,session_id:i.session_id,parent_tool_use_id:i.parent_tool_use_id,event:{type:`content_block_delta`,index:c,delta:{type:`text_delta`,text:l.join(``)}}};r.set(l,d),n.push(d);break}default:n.push(i)}}return n}function L(e,t){e.byMessage.delete(t.message.id);let n=F(t);e.scopeToMessage.get(n)===t.message.id&&e.scopeToMessage.delete(n)}var R=class{constructor(e,n,r){if(t(this,`workerEpoch`,0),t(this,`heartbeatIntervalMs`,void 0),t(this,`heartbeatJitterFraction`,void 0),t(this,`heartbeatTimer`,null),t(this,`heartbeatInFlight`,!1),t(this,`closed`,!1),t(this,`consecutiveAuthFailures`,0),t(this,`currentState`,null),t(this,`sessionBaseUrl`,void 0),t(this,`sessionId`,void 0),t(this,`http`,m({keepAlive:!0})),t(this,`streamEventBuffer`,[]),t(this,`streamEventTimer`,null),t(this,`streamTextAccumulator`,P()),t(this,`workerState`,void 0),t(this,`eventUploader`,void 0),t(this,`internalEventUploader`,void 0),t(this,`deliveryUploader`,void 0),t(this,`onEpochMismatch`,void 0),t(this,`getAuthHeaders`,void 0),this.onEpochMismatch=r?.onEpochMismatch??(()=>{process.exit(1)}),this.heartbeatIntervalMs=r?.heartbeatIntervalMs??k,this.heartbeatJitterFraction=r?.heartbeatJitterFraction??0,this.getAuthHeaders=r?.getAuthHeaders??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(),y(()=>{this.writeEvent({type:`keep_alive`})}),o(`CCRClient: initialized, epoch=${this.workerEpoch}`),u(`info`,`cli_worker_lifecycle_initialized`,{epoch:this.workerEpoch,duration_ms:Date.now()-t});let{metadata:r,durationMs:i}=await n;return this.closed||u(`info`,`cli_worker_state_restored`,{duration_ms:i,had_state:r!==null}),r}async getWorkerState(){let e=Date.now(),t=this.getAuthHeaders();return Object.keys(t).length===0?{metadata:null,durationMs:0}:{metadata:(await this.getWithRetry(`${this.sessionBaseUrl}/worker`,t,`worker_state`))?.worker?.external_metadata??null,durationMs:Date.now()-e}}async request(e,t,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":g()},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=x(),t=e?C(e):null;t!==null&&t*1e3<Date.now()&&(o(`CCRClient: session_token expired (exp=${new Date(t*1e3).toISOString()}) — no refresh was delivered, exiting`,{level:`error`}),u(`error`,`cli_worker_token_expired_no_refresh`),this.onEpochMismatch()),this.consecutiveAuthFailures++,this.consecutiveAuthFailures>=N&&(o(`CCRClient: ${this.consecutiveAuthFailures} consecutive auth failures with a valid-looking token — server-side auth unrecoverable, exiting`,{level:`error`}),u(`error`,`cli_worker_auth_failures_exhausted`),this.onEpochMismatch())}if(o(`CCRClient: ${a} returned ${n.status}`,{level:`warn`}),u(`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`}),u(`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`}),u(`error`,`cli_worker_epoch_mismatch`),this.onEpochMismatch()}startHeartbeat(){this.stopHeartbeat();let e=()=>{let e=this.heartbeatIntervalMs*this.heartbeatJitterFraction*(2*Math.random()-1);this.heartbeatTimer=setTimeout(t,this.heartbeatIntervalMs+e)},t=()=>{this.sendHeartbeat(),this.heartbeatTimer!==null&&e()};e()}stopHeartbeat(){this.heartbeatTimer&&(clearTimeout(this.heartbeatTimer),this.heartbeatTimer=null)}async sendHeartbeat(){if(!this.heartbeatInFlight){this.heartbeatInFlight=!0;try{(await this.request(`post`,`/worker/heartbeat`,{session_id:this.sessionId,worker_epoch:this.workerEpoch},`Heartbeat`,{timeout:5e3})).ok&&o(`CCRClient: Heartbeat sent`)}finally{this.heartbeatInFlight=!1}}}async writeEvent(e){if(e.type===`stream_event`){this.streamEventBuffer.push(e),this.streamEventTimer||(this.streamEventTimer=setTimeout(()=>void this.flushStreamEventBuffer(),A));return}await this.flushStreamEventBuffer(),e.type===`assistant`&&L(this.streamTextAccumulator,e),await this.eventUploader.enqueue(this.toClientEvent(e))}toClientEvent(e){let t=e;return{payload:{...t,uuid:typeof t.uuid==`string`?t.uuid:w()}}}async flushStreamEventBuffer(){if(this.streamEventTimer&&(clearTimeout(this.streamEventTimer),this.streamEventTimer=null),this.streamEventBuffer.length===0)return;let e=this.streamEventBuffer;this.streamEventBuffer=[];let t=I(e,this.streamTextAccumulator);await this.eventUploader.enqueue(t.map(e=>({payload:e,ephemeral:!0})))}async writeInternalEvent(e,t,{isCompaction:n=!1,agentId:r}={}){let i={payload:{type:e,...t,uuid:typeof t.uuid==`string`?t.uuid:w()},...n&&{is_compaction:!0},...r&&{agent_id:r}};await this.internalEventUploader.enqueue(i)}flushInternalEvents(){return this.internalEventUploader.flush()}async flush(){return await this.flushStreamEventBuffer(),this.eventUploader.flush()}async readInternalEvents(){return this.paginatedGet(`/worker/internal-events`,{},`internal_events`)}async readSubagentInternalEvents(){return this.paginatedGet(`/worker/internal-events`,{subagents:`true`},`subagent_events`)}async paginatedGet(e,t,n){let r=this.getAuthHeaders();if(Object.keys(r).length===0)return null;let i=[],a;do{let o=new URL(`${this.sessionBaseUrl}${e}`);for(let[e,n]of Object.entries(t))o.searchParams.set(e,n);a&&o.searchParams.set(`cursor`,a);let s=await this.getWithRetry(o.toString(),r,n);if(!s)return null;i.push(...s.data??[]),a=s.next_cursor}while(a);return o(`CCRClient: Read ${i.length} internal events from ${e}${t.subagents?` (subagents)`:``}`),i}async getWithRetry(e,t,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":g()},validateStatus:j,timeout:3e4})}catch(t){o(`CCRClient: GET ${e} failed (attempt ${r}/10): ${n(t)}`,{level:`warn`}),r<10&&await f(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 f(Math.min(500*2**(r-1),3e4)+Math.random()*500)}return o(`CCRClient: GET retries exhausted`,{level:`error`}),u(`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(),b(),this.streamEventTimer&&(clearTimeout(this.streamEventTimer),this.streamEventTimer=null),this.streamEventBuffer=[],this.streamTextAccumulator.byMessage.clear(),this.streamTextAccumulator.scopeToMessage.clear(),this.workerState.close(),this.eventUploader.close(),this.internalEventUploader.close(),this.deliveryUploader.close()}};export{M as n,E as r,R as t};
@@ -1 +1 @@
1
- import{I as e,z as t}from"./debug-BdqxZ7rV.js";import{o as n,s as r}from"./log-CTFl4qpD.js";import{i,o as a,t as o}from"./platform-D6IMiyqT.js";import{a as s,i as c,s as l,u}from"./types-DWRxAH0E.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-RAynG_nM.js";import{o as n,s as r}from"./log-CezCRpAN.js";import{i,o as a,t as o}from"./platform-BMPbglug.js";import{a as s,i as c,s as l,u}from"./types-3j8PS-Du.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-DrHZIQX2.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-Dk1WDQuN.js";var r;e((()=>{t(),r=async(e,t)=>(await n(t),{type:`text`,value:``})}))();export{r as call};
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./bundledMode--fG1S62b.js";import{i as r,r as i}from"./shellQuote-Bth6IZgX.js";import{spawn as a}from"child_process";function o(e){let n=[];for(let r=0;r<e.length;r++){let i=e[r];if(i===`-d`||i.startsWith(`-d `)||i.startsWith(`-d `)){n.push(i),i===`-d`&&r+1<e.length&&n.push(e[++r]);continue}if(i.startsWith(`-d`)&&i.includes(`:`)){n.push(i);continue}if(i===`--feature`){n.push(i),r+1<e.length&&n.push(e[++r]);continue}if(/^--inspect(-brk)?(=|$)/.test(i)){n.push(i);continue}if(i.startsWith(`--`)&&!i.includes(`=`)&&r+1<e.length){if(t())continue;n.push(i),n.push(e[++r]);continue}i.startsWith(`-`)&&!t()&&n.push(i)}return n}function s(e,n){let r=n?.env??process.env,i=t()||!p?[...f,...e]:[...f,p,...e],a={...r};return h&&(process.env.CLAUDE_CODE_GIT_BASH_PATH&&!a.CLAUDE_CODE_GIT_BASH_PATH&&(a.CLAUDE_CODE_GIT_BASH_PATH=process.env.CLAUDE_CODE_GIT_BASH_PATH),process.env.SHELL&&!a.SHELL&&(a.SHELL=process.env.SHELL)),{execPath:m,args:i,env:a,windowsHide:h}}function c(e,t){return a(e.execPath,e.args,{...t,env:{...e.env,...t.env},windowsHide:e.windowsHide})}function l(e){return r([e.execPath,...e.args])}function u(){return f}function d(){return p}var f,p,m,h,g=e((()=>{n(),i(),f=Object.freeze(o(process.execArgv)),p=process.argv[1],m=process.execPath,h=process.platform===`win32`}));export{l as a,g as i,u as n,c as o,d as r,s as t};
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./bundledMode--fG1S62b.js";import{i as r,r as i}from"./shellQuote-BYeOv3Ip.js";import{spawn as a}from"child_process";function o(e){let n=[];for(let r=0;r<e.length;r++){let i=e[r];if(i===`-d`||i.startsWith(`-d `)||i.startsWith(`-d `)){n.push(i),i===`-d`&&r+1<e.length&&n.push(e[++r]);continue}if(i.startsWith(`-d`)&&i.includes(`:`)){n.push(i);continue}if(i===`--feature`){n.push(i),r+1<e.length&&n.push(e[++r]);continue}if(/^--inspect(-brk)?(=|$)/.test(i)){n.push(i);continue}if(i.startsWith(`--`)&&!i.includes(`=`)&&r+1<e.length){if(t())continue;n.push(i),n.push(e[++r]);continue}i.startsWith(`-`)&&!t()&&n.push(i)}return n}function s(e,n){let r=n?.env??process.env,i=t()||!p?[...f,...e]:[...f,p,...e],a={...r};return h&&(process.env.CLAUDE_CODE_GIT_BASH_PATH&&!a.CLAUDE_CODE_GIT_BASH_PATH&&(a.CLAUDE_CODE_GIT_BASH_PATH=process.env.CLAUDE_CODE_GIT_BASH_PATH),process.env.SHELL&&!a.SHELL&&(a.SHELL=process.env.SHELL)),{execPath:m,args:i,env:a,windowsHide:h}}function c(e,t){return a(e.execPath,e.args,{...t,env:{...e.env,...t.env},windowsHide:e.windowsHide})}function l(e){return r([e.execPath,...e.args])}function u(){return f}function d(){return p}var f,p,m,h,g=e((()=>{n(),i(),f=Object.freeze(o(process.execArgv)),p=process.argv[1],m=process.execPath,h=process.platform===`win32`}));export{l as a,g as i,u as n,c as o,d as r,s as t};
@@ -0,0 +1 @@
1
+ import{Fr as e,Pr as t}from"./model-BsZ4sP_H.js";e();export{t as getOrganizationUUID};
@@ -1,4 +1,4 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{a as t,l as n}from"./proxy-Blq4W6Ox.js";import{r,t as i}from"./store-Z8rTjDHe.js";function a(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n}function o(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)}var s=e((()=>{})),c,l=e((()=>{c=function(){let{crypto:e}=globalThis;if(e?.randomUUID)return c=e.randomUUID.bind(e),e.randomUUID();let t=new Uint8Array(1),n=e?()=>e.getRandomValues(t)[0]:()=>Math.random()*255&255;return`10000000-1000-4000-8000-100000000000`.replace(/[018]/g,e=>(e^n()&15>>e/4).toString(16))}}));function u(e){return typeof e==`object`&&!!e&&(`name`in e&&e.name===`AbortError`||`message`in e&&String(e.message).includes(`FetchRequestCanceledException`))}var d,f=e((()=>{d=e=>{if(e instanceof Error)return e;if(typeof e==`object`&&e){try{if(Object.prototype.toString.call(e)===`[object Error]`){let t=Error(e.message,e.cause?{cause:e.cause}:{});return e.stack&&(t.stack=e.stack),e.cause&&!t.cause&&(t.cause=e.cause),e.name&&(t.name=e.name),t}}catch{}try{return Error(JSON.stringify(e))}catch{}}return Error(e)}})),p,m,h,g,ee,_,v,y,te,ne,re,ie,ae,oe,se,ce,le,ue,de=e((()=>{f(),p=class extends Error{},m=class e extends p{constructor(t,n,r,i){super(`${e.makeMessage(t,n,r)}`),this.status=t,this.headers=i,this.requestID=i?.get(`x-request-id`),this.error=n;let a=n;this.code=a?.code,this.param=a?.param,this.type=a?.type}static makeMessage(e,t,n){let r=t?.message?typeof t.message==`string`?t.message:JSON.stringify(t.message):t?JSON.stringify(t):n;return e&&r?`${e} ${r}`:e?`${e} status code (no body)`:r||`(no status code or body)`}static generate(t,n,r,i){if(!t||!i)return new g({message:r,cause:d(n)});let a=n?.error;return t===400?new _(t,a,r,i):t===401?new v(t,a,r,i):t===403?new y(t,a,r,i):t===404?new te(t,a,r,i):t===409?new ne(t,a,r,i):t===422?new re(t,a,r,i):t===429?new ie(t,a,r,i):t>=500?new ae(t,a,r,i):new e(t,a,r,i)}},h=class extends m{constructor({message:e}={}){super(void 0,void 0,e||`Request was aborted.`,void 0)}},g=class extends m{constructor({message:e,cause:t}){super(void 0,void 0,e||`Connection error.`,void 0),t&&(this.cause=t)}},ee=class extends g{constructor({message:e}={}){super({message:e??`Request timed out.`})}},_=class extends m{},v=class extends m{},y=class extends m{},te=class extends m{},ne=class extends m{},re=class extends m{},ie=class extends m{},ae=class extends m{},oe=class extends p{constructor(){super(`Could not parse response content as the length limit was reached`)}},se=class extends p{constructor(){super(`Could not parse response content as the request was rejected by the content filter`)}},ce=class extends Error{constructor(e){super(e)}},le=class extends m{constructor(e,t,n){let r=`OAuth2 authentication error`,i;if(t&&typeof t==`object`){let e=t;i=e.error;let n=e.error_description;n&&typeof n==`string`?r=n:i&&(r=i)}super(e,t,r,n),this.error_code=i}},ue=class extends p{constructor(e,t,n){super(e),this.provider=t,this.cause=n}}}));function fe(e){return typeof e==`object`?e??{}:{}}function pe(e){if(!e)return!0;for(let t in e)return!1;return!0}function me(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function he(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var ge,_e,b,ve,ye,be,xe=e((()=>{de(),ge=/^[a-z][a-z0-9+.-]*:/i,_e=e=>ge.test(e),b=e=>(b=Array.isArray,b(e)),ve=b,ye=(e,t)=>{if(typeof t!=`number`||!Number.isInteger(t))throw new p(`${e} must be an integer`);if(t<0)throw new p(`${e} must be a positive integer`);return t},be=e=>{try{return JSON.parse(e)}catch{return}}})),Se,Ce=e((()=>{Se=e=>new Promise(t=>setTimeout(t,e))})),we,Te=e((()=>{we=`6.46.0`}));function Ee(){return typeof Deno<`u`&&Deno.build!=null?`deno`:typeof EdgeRuntime<`u`?`edge`:Object.prototype.toString.call(globalThis.process===void 0?0:globalThis.process)===`[object process]`?`node`:`unknown`}function De(){if(typeof navigator>`u`||!navigator)return null;for(let{key:e,pattern:t}of[{key:`edge`,pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`ie`,pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`ie`,pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`chrome`,pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`firefox`,pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`safari`,pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}]){let n=t.exec(navigator.userAgent);if(n)return{browser:e,version:`${n[1]||0}.${n[2]||0}.${n[3]||0}`}}return null}var Oe,ke,Ae,je,Me,Ne,Pe=e((()=>{Te(),Oe=()=>typeof window<`u`&&window.document!==void 0&&typeof navigator<`u`,ke=()=>{let e=Ee();if(e===`deno`)return{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":we,"X-Stainless-OS":je(Deno.build.os),"X-Stainless-Arch":Ae(Deno.build.arch),"X-Stainless-Runtime":`deno`,"X-Stainless-Runtime-Version":typeof Deno.version==`string`?Deno.version:Deno.version?.deno??`unknown`};if(typeof EdgeRuntime<`u`)return{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":we,"X-Stainless-OS":`Unknown`,"X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":`edge`,"X-Stainless-Runtime-Version":globalThis.process.version};if(e===`node`)return{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":we,"X-Stainless-OS":je(globalThis.process.platform??`unknown`),"X-Stainless-Arch":Ae(globalThis.process.arch??`unknown`),"X-Stainless-Runtime":`node`,"X-Stainless-Runtime-Version":globalThis.process.version??`unknown`};let t=De();return t?{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":we,"X-Stainless-OS":`Unknown`,"X-Stainless-Arch":`unknown`,"X-Stainless-Runtime":`browser:${t.browser}`,"X-Stainless-Runtime-Version":t.version}:{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":we,"X-Stainless-OS":`Unknown`,"X-Stainless-Arch":`unknown`,"X-Stainless-Runtime":`unknown`,"X-Stainless-Runtime-Version":`unknown`}},Ae=e=>e===`x32`?`x32`:e===`x86_64`||e===`x64`?`x64`:e===`arm`?`arm`:e===`aarch64`||e===`arm64`?`arm64`:e?`other:${e}`:`unknown`,je=e=>(e=e.toLowerCase(),e.includes(`ios`)?`iOS`:e===`android`?`Android`:e===`darwin`?`MacOS`:e===`win32`?`Windows`:e===`freebsd`?`FreeBSD`:e===`openbsd`?`OpenBSD`:e===`linux`?`Linux`:e?`Other:${e}`:`Unknown`),Ne=()=>Me??(Me=ke())}));function Fe(){if(typeof fetch<`u`)return fetch;throw Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new OpenAI({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function Ie(...e){let t=globalThis.ReadableStream;if(t===void 0)throw Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new t(...e)}function Le(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator]();return Ie({start(){},async pull(e){let{done:n,value:r}=await t.next();n?e.close():e.enqueue(r)},async cancel(){await t.return?.()}})}function Re(e){if(e[Symbol.asyncIterator])return e;let t=e.getReader();return{async next(){try{let e=await t.read();return e?.done&&t.releaseLock(),e}catch(e){throw t.releaseLock(),e}},async return(){let e=t.cancel();return t.releaseLock(),await e,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function ze(e){if(typeof e!=`object`||!e)return;if(e[Symbol.asyncIterator]){await e[Symbol.asyncIterator]().return?.();return}let t=e.getReader(),n=t.cancel();t.releaseLock(),await n}var Be=e((()=>{})),Ve,He=e((()=>{Ve=({headers:e,body:t})=>({bodyHeaders:{"content-type":`application/json`},body:JSON.stringify(t)})})),Ue,We,Ge,Ke=e((()=>{Ue=`RFC3986`,We=e=>String(e),Ge={RFC1738:e=>String(e).replace(/%20/g,`+`),RFC3986:We}}));function qe(e){return!e||typeof e!=`object`?!1:!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))}function Je(e,t){if(b(e)){let n=[];for(let r=0;r<e.length;r+=1)n.push(t(e[r]));return n}return t(e)}var Ye,x,Xe,Ze,Qe=e((()=>{Ke(),xe(),Ye=(e,t)=>(Ye=Object.hasOwn??Function.prototype.call.bind(Object.prototype.hasOwnProperty),Ye(e,t)),x=(()=>{let e=[];for(let t=0;t<256;++t)e.push(`%`+((t<16?`0`:``)+t.toString(16)).toUpperCase());return e})(),Xe=1024,Ze=(e,t,n,r,i)=>{if(e.length===0)return e;let a=e;if(typeof e==`symbol`?a=Symbol.prototype.toString.call(e):typeof e!=`string`&&(a=String(e)),n===`iso-8859-1`)return escape(a).replace(/%u[0-9a-f]{4}/gi,function(e){return`%26%23`+parseInt(e.slice(2),16)+`%3B`});let o=``;for(let e=0;e<a.length;e+=Xe){let t=a.length>=Xe?a.slice(e,e+Xe):a,n=[];for(let e=0;e<t.length;++e){let r=t.charCodeAt(e);if(r===45||r===46||r===95||r===126||r>=48&&r<=57||r>=65&&r<=90||r>=97&&r<=122||i===`RFC1738`&&(r===40||r===41)){n[n.length]=t.charAt(e);continue}if(r<128){n[n.length]=x[r];continue}if(r<2048){n[n.length]=x[192|r>>6]+x[128|r&63];continue}if(r<55296||r>=57344){n[n.length]=x[224|r>>12]+x[128|r>>6&63]+x[128|r&63];continue}e+=1,r=65536+((r&1023)<<10|t.charCodeAt(e)&1023),n[n.length]=x[240|r>>18]+x[128|r>>12&63]+x[128|r>>6&63]+x[128|r&63]}o+=n.join(``)}return o}}));function $e(e){return typeof e==`string`||typeof e==`number`||typeof e==`boolean`||typeof e==`symbol`||typeof e==`bigint`}function et(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,ee){let _=e,v=ee,y=0,te=!1;for(;(v=v.get(ot))!==void 0&&!te;){let t=v.get(e);if(y+=1,t!==void 0){if(t===y)throw RangeError(`Cyclic object value`);te=!0}v.get(ot)===void 0&&(y=0)}if(typeof l==`function`?_=l(t,_):_ instanceof Date?_=f?.(_):n===`comma`&&b(_)&&(_=Je(_,function(e){return e instanceof Date?f?.(e):e})),_===null){if(a)return c&&!h?c(t,S.encoder,g,`key`,p):t;_=``}if($e(_)||qe(_)){if(c){let e=h?t:c(t,S.encoder,g,`key`,p);return[m?.(e)+`=`+m?.(c(_,S.encoder,g,`value`,p))]}return[m?.(t)+`=`+m?.(String(_))]}let ne=[];if(_===void 0)return ne;let re;if(n===`comma`&&b(_))h&&c&&(_=Je(_,c)),re=[{value:_.length>0?_.join(`,`)||null:void 0}];else if(b(l))re=l;else{let e=Object.keys(_);re=u?e.sort(u):e}let ie=s?String(t).replace(/\./g,`%2E`):String(t),ae=r&&b(_)&&_.length===1?ie+`[]`:ie;if(i&&b(_)&&_.length===0)return ae+`[]`;for(let t=0;t<re.length;++t){let v=re[t],te=typeof v==`object`&&v.value!==void 0?v.value:_[v];if(o&&te===null)continue;let ie=d&&s?v.replace(/\./g,`%2E`):v,oe=b(_)?typeof n==`function`?n(ae,ie):ae:ae+(d?`.`+ie:`[`+ie+`]`);ee.set(e,y);let se=new WeakMap;se.set(ot,ee),it(ne,et(te,oe,n,r,i,a,o,s,n===`comma`&&h&&b(_)?null:c,l,u,d,f,p,m,h,g,se))}return ne}function tt(e=S){if(e.allowEmptyArrays!==void 0&&typeof e.allowEmptyArrays!=`boolean`)throw TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(e.encodeDotInKeys!==void 0&&typeof e.encodeDotInKeys!=`boolean`)throw TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(e.encoder!==null&&e.encoder!==void 0&&typeof e.encoder!=`function`)throw TypeError(`Encoder has to be a function.`);let t=e.charset||S.charset;if(e.charset!==void 0&&e.charset!==`utf-8`&&e.charset!==`iso-8859-1`)throw TypeError(`The charset option must be either utf-8, iso-8859-1, or undefined`);let n=Ue;if(e.format!==void 0){if(!Ye(Ge,e.format))throw TypeError(`Unknown format option provided.`);n=e.format}let r=Ge[n],i=S.filter;(typeof e.filter==`function`||b(e.filter))&&(i=e.filter);let a;if(a=e.arrayFormat&&e.arrayFormat in rt?e.arrayFormat:`indices`in e?e.indices?`indices`:`repeat`:S.arrayFormat,`commaRoundTrip`in e&&typeof e.commaRoundTrip!=`boolean`)throw TypeError("`commaRoundTrip` must be a boolean, or absent");let o=e.allowDots===void 0?e.encodeDotInKeys?!0:S.allowDots:!!e.allowDots;return{addQueryPrefix:typeof e.addQueryPrefix==`boolean`?e.addQueryPrefix:S.addQueryPrefix,allowDots:o,allowEmptyArrays:typeof e.allowEmptyArrays==`boolean`?!!e.allowEmptyArrays:S.allowEmptyArrays,arrayFormat:a,charset:t,charsetSentinel:typeof e.charsetSentinel==`boolean`?e.charsetSentinel:S.charsetSentinel,commaRoundTrip:!!e.commaRoundTrip,delimiter:e.delimiter===void 0?S.delimiter:e.delimiter,encode:typeof e.encode==`boolean`?e.encode:S.encode,encodeDotInKeys:typeof e.encodeDotInKeys==`boolean`?e.encodeDotInKeys:S.encodeDotInKeys,encoder:typeof e.encoder==`function`?e.encoder:S.encoder,encodeValuesOnly:typeof e.encodeValuesOnly==`boolean`?e.encodeValuesOnly:S.encodeValuesOnly,filter:i,format:n,formatter:r,serializeDate:typeof e.serializeDate==`function`?e.serializeDate:S.serializeDate,skipNulls:typeof e.skipNulls==`boolean`?e.skipNulls:S.skipNulls,sort:typeof e.sort==`function`?e.sort:null,strictNullHandling:typeof e.strictNullHandling==`boolean`?e.strictNullHandling:S.strictNullHandling}}function nt(e,t={}){let n=e,r=tt(t),i,a;typeof r.filter==`function`?(a=r.filter,n=a(``,n)):b(r.filter)&&(a=r.filter,i=a);let o=[];if(typeof n!=`object`||!n)return``;let s=rt[r.arrayFormat],c=s===`comma`&&r.commaRoundTrip;i||(i=Object.keys(n)),r.sort&&i.sort(r.sort);let l=new WeakMap;for(let e=0;e<i.length;++e){let t=i[e];r.skipNulls&&n[t]===null||it(o,et(n[t],t,s,c,r.allowEmptyArrays,r.strictNullHandling,r.skipNulls,r.encodeDotInKeys,r.encode?r.encoder:null,r.filter,r.sort,r.allowDots,r.serializeDate,r.format,r.formatter,r.encodeValuesOnly,r.charset,l))}let u=o.join(r.delimiter),d=r.addQueryPrefix===!0?`?`:``;return r.charsetSentinel&&(r.charset===`iso-8859-1`?d+=`utf8=%26%2310003%3B&`:d+=`utf8=%E2%9C%93&`),u.length>0?d+u:``}var rt,it,at,S,ot,st=e((()=>{Qe(),Ke(),xe(),rt={brackets(e){return String(e)+`[]`},comma:`comma`,indices(e,t){return String(e)+`[`+t+`]`},repeat(e){return String(e)}},it=function(e,t){Array.prototype.push.apply(e,b(t)?t:[t])},S={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:`indices`,charset:`utf-8`,charsetSentinel:!1,delimiter:`&`,encode:!0,encodeDotInKeys:!1,encoder:Ze,encodeValuesOnly:!1,format:Ue,formatter:We,indices:!1,serializeDate(e){return(at??(at=Function.prototype.call.bind(Date.prototype.toISOString)))(e)},skipNulls:!1,strictNullHandling:!1},ot={}}));function ct(e){return nt(e,{arrayFormat:`brackets`})}var lt=e((()=>{st()}));function ut(e){let t=0;for(let n of e)t+=n.length;let n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}function dt(e){let t;return(pt??(t=new globalThis.TextEncoder,pt=t.encode.bind(t)))(e)}function ft(e){let t;return(mt??(t=new globalThis.TextDecoder,mt=t.decode.bind(t)))(e)}var pt,mt,ht=e((()=>{}));function gt(e,t){for(let n=t??0;n<e.length;n++){if(e[n]===10)return{preceding:n,index:n+1,carriage:!1};if(e[n]===13)return{preceding:n,index:n+1,carriage:!0}}return null}function _t(e){for(let t=0;t<e.length-1;t++){if(e[t]===10&&e[t+1]===10||e[t]===13&&e[t+1]===13)return t+2;if(e[t]===13&&e[t+1]===10&&t+3<e.length&&e[t+2]===13&&e[t+3]===10)return t+4}return-1}var C,w,vt,yt=e((()=>{s(),ht(),vt=class{constructor(){C.set(this,void 0),w.set(this,void 0),a(this,C,new Uint8Array,`f`),a(this,w,null,`f`)}decode(e){if(e==null)return[];let t=e instanceof ArrayBuffer?new Uint8Array(e):typeof e==`string`?dt(e):e;a(this,C,ut([o(this,C,`f`),t]),`f`);let n=[],r;for(;(r=gt(o(this,C,`f`),o(this,w,`f`)))!=null;){if(r.carriage&&o(this,w,`f`)==null){a(this,w,r.index,`f`);continue}if(o(this,w,`f`)!=null&&(r.index!==o(this,w,`f`)+1||r.carriage)){n.push(ft(o(this,C,`f`).subarray(0,o(this,w,`f`)-1))),a(this,C,o(this,C,`f`).subarray(o(this,w,`f`)),`f`),a(this,w,null,`f`);continue}let e=o(this,w,`f`)===null?r.preceding:r.preceding-1,t=ft(o(this,C,`f`).subarray(0,e));n.push(t),a(this,C,o(this,C,`f`).subarray(r.index),`f`),a(this,w,null,`f`)}return n}flush(){return o(this,C,`f`).length?this.decode(`
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{a as t,l as n}from"./proxy-CuMaO_YV.js";import{r,t as i}from"./store-Z8rTjDHe.js";function a(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n}function o(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)}var s=e((()=>{})),c,l=e((()=>{c=function(){let{crypto:e}=globalThis;if(e?.randomUUID)return c=e.randomUUID.bind(e),e.randomUUID();let t=new Uint8Array(1),n=e?()=>e.getRandomValues(t)[0]:()=>Math.random()*255&255;return`10000000-1000-4000-8000-100000000000`.replace(/[018]/g,e=>(e^n()&15>>e/4).toString(16))}}));function u(e){return typeof e==`object`&&!!e&&(`name`in e&&e.name===`AbortError`||`message`in e&&String(e.message).includes(`FetchRequestCanceledException`))}var d,f=e((()=>{d=e=>{if(e instanceof Error)return e;if(typeof e==`object`&&e){try{if(Object.prototype.toString.call(e)===`[object Error]`){let t=Error(e.message,e.cause?{cause:e.cause}:{});return e.stack&&(t.stack=e.stack),e.cause&&!t.cause&&(t.cause=e.cause),e.name&&(t.name=e.name),t}}catch{}try{return Error(JSON.stringify(e))}catch{}}return Error(e)}})),p,m,h,g,ee,_,v,y,te,ne,re,ie,ae,oe,se,ce,le,ue,de=e((()=>{f(),p=class extends Error{},m=class e extends p{constructor(t,n,r,i){super(`${e.makeMessage(t,n,r)}`),this.status=t,this.headers=i,this.requestID=i?.get(`x-request-id`),this.error=n;let a=n;this.code=a?.code,this.param=a?.param,this.type=a?.type}static makeMessage(e,t,n){let r=t?.message?typeof t.message==`string`?t.message:JSON.stringify(t.message):t?JSON.stringify(t):n;return e&&r?`${e} ${r}`:e?`${e} status code (no body)`:r||`(no status code or body)`}static generate(t,n,r,i){if(!t||!i)return new g({message:r,cause:d(n)});let a=n?.error;return t===400?new _(t,a,r,i):t===401?new v(t,a,r,i):t===403?new y(t,a,r,i):t===404?new te(t,a,r,i):t===409?new ne(t,a,r,i):t===422?new re(t,a,r,i):t===429?new ie(t,a,r,i):t>=500?new ae(t,a,r,i):new e(t,a,r,i)}},h=class extends m{constructor({message:e}={}){super(void 0,void 0,e||`Request was aborted.`,void 0)}},g=class extends m{constructor({message:e,cause:t}){super(void 0,void 0,e||`Connection error.`,void 0),t&&(this.cause=t)}},ee=class extends g{constructor({message:e}={}){super({message:e??`Request timed out.`})}},_=class extends m{},v=class extends m{},y=class extends m{},te=class extends m{},ne=class extends m{},re=class extends m{},ie=class extends m{},ae=class extends m{},oe=class extends p{constructor(){super(`Could not parse response content as the length limit was reached`)}},se=class extends p{constructor(){super(`Could not parse response content as the request was rejected by the content filter`)}},ce=class extends Error{constructor(e){super(e)}},le=class extends m{constructor(e,t,n){let r=`OAuth2 authentication error`,i;if(t&&typeof t==`object`){let e=t;i=e.error;let n=e.error_description;n&&typeof n==`string`?r=n:i&&(r=i)}super(e,t,r,n),this.error_code=i}},ue=class extends p{constructor(e,t,n){super(e),this.provider=t,this.cause=n}}}));function fe(e){return typeof e==`object`?e??{}:{}}function pe(e){if(!e)return!0;for(let t in e)return!1;return!0}function me(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function he(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var ge,_e,b,ve,ye,be,xe=e((()=>{de(),ge=/^[a-z][a-z0-9+.-]*:/i,_e=e=>ge.test(e),b=e=>(b=Array.isArray,b(e)),ve=b,ye=(e,t)=>{if(typeof t!=`number`||!Number.isInteger(t))throw new p(`${e} must be an integer`);if(t<0)throw new p(`${e} must be a positive integer`);return t},be=e=>{try{return JSON.parse(e)}catch{return}}})),Se,Ce=e((()=>{Se=e=>new Promise(t=>setTimeout(t,e))})),we,Te=e((()=>{we=`6.46.0`}));function Ee(){return typeof Deno<`u`&&Deno.build!=null?`deno`:typeof EdgeRuntime<`u`?`edge`:Object.prototype.toString.call(globalThis.process===void 0?0:globalThis.process)===`[object process]`?`node`:`unknown`}function De(){if(typeof navigator>`u`||!navigator)return null;for(let{key:e,pattern:t}of[{key:`edge`,pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`ie`,pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`ie`,pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`chrome`,pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`firefox`,pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`safari`,pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}]){let n=t.exec(navigator.userAgent);if(n)return{browser:e,version:`${n[1]||0}.${n[2]||0}.${n[3]||0}`}}return null}var Oe,ke,Ae,je,Me,Ne,Pe=e((()=>{Te(),Oe=()=>typeof window<`u`&&window.document!==void 0&&typeof navigator<`u`,ke=()=>{let e=Ee();if(e===`deno`)return{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":we,"X-Stainless-OS":je(Deno.build.os),"X-Stainless-Arch":Ae(Deno.build.arch),"X-Stainless-Runtime":`deno`,"X-Stainless-Runtime-Version":typeof Deno.version==`string`?Deno.version:Deno.version?.deno??`unknown`};if(typeof EdgeRuntime<`u`)return{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":we,"X-Stainless-OS":`Unknown`,"X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":`edge`,"X-Stainless-Runtime-Version":globalThis.process.version};if(e===`node`)return{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":we,"X-Stainless-OS":je(globalThis.process.platform??`unknown`),"X-Stainless-Arch":Ae(globalThis.process.arch??`unknown`),"X-Stainless-Runtime":`node`,"X-Stainless-Runtime-Version":globalThis.process.version??`unknown`};let t=De();return t?{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":we,"X-Stainless-OS":`Unknown`,"X-Stainless-Arch":`unknown`,"X-Stainless-Runtime":`browser:${t.browser}`,"X-Stainless-Runtime-Version":t.version}:{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":we,"X-Stainless-OS":`Unknown`,"X-Stainless-Arch":`unknown`,"X-Stainless-Runtime":`unknown`,"X-Stainless-Runtime-Version":`unknown`}},Ae=e=>e===`x32`?`x32`:e===`x86_64`||e===`x64`?`x64`:e===`arm`?`arm`:e===`aarch64`||e===`arm64`?`arm64`:e?`other:${e}`:`unknown`,je=e=>(e=e.toLowerCase(),e.includes(`ios`)?`iOS`:e===`android`?`Android`:e===`darwin`?`MacOS`:e===`win32`?`Windows`:e===`freebsd`?`FreeBSD`:e===`openbsd`?`OpenBSD`:e===`linux`?`Linux`:e?`Other:${e}`:`Unknown`),Ne=()=>Me??(Me=ke())}));function Fe(){if(typeof fetch<`u`)return fetch;throw Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new OpenAI({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function Ie(...e){let t=globalThis.ReadableStream;if(t===void 0)throw Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new t(...e)}function Le(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator]();return Ie({start(){},async pull(e){let{done:n,value:r}=await t.next();n?e.close():e.enqueue(r)},async cancel(){await t.return?.()}})}function Re(e){if(e[Symbol.asyncIterator])return e;let t=e.getReader();return{async next(){try{let e=await t.read();return e?.done&&t.releaseLock(),e}catch(e){throw t.releaseLock(),e}},async return(){let e=t.cancel();return t.releaseLock(),await e,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function ze(e){if(typeof e!=`object`||!e)return;if(e[Symbol.asyncIterator]){await e[Symbol.asyncIterator]().return?.();return}let t=e.getReader(),n=t.cancel();t.releaseLock(),await n}var Be=e((()=>{})),Ve,He=e((()=>{Ve=({headers:e,body:t})=>({bodyHeaders:{"content-type":`application/json`},body:JSON.stringify(t)})})),Ue,We,Ge,Ke=e((()=>{Ue=`RFC3986`,We=e=>String(e),Ge={RFC1738:e=>String(e).replace(/%20/g,`+`),RFC3986:We}}));function qe(e){return!e||typeof e!=`object`?!1:!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))}function Je(e,t){if(b(e)){let n=[];for(let r=0;r<e.length;r+=1)n.push(t(e[r]));return n}return t(e)}var Ye,x,Xe,Ze,Qe=e((()=>{Ke(),xe(),Ye=(e,t)=>(Ye=Object.hasOwn??Function.prototype.call.bind(Object.prototype.hasOwnProperty),Ye(e,t)),x=(()=>{let e=[];for(let t=0;t<256;++t)e.push(`%`+((t<16?`0`:``)+t.toString(16)).toUpperCase());return e})(),Xe=1024,Ze=(e,t,n,r,i)=>{if(e.length===0)return e;let a=e;if(typeof e==`symbol`?a=Symbol.prototype.toString.call(e):typeof e!=`string`&&(a=String(e)),n===`iso-8859-1`)return escape(a).replace(/%u[0-9a-f]{4}/gi,function(e){return`%26%23`+parseInt(e.slice(2),16)+`%3B`});let o=``;for(let e=0;e<a.length;e+=Xe){let t=a.length>=Xe?a.slice(e,e+Xe):a,n=[];for(let e=0;e<t.length;++e){let r=t.charCodeAt(e);if(r===45||r===46||r===95||r===126||r>=48&&r<=57||r>=65&&r<=90||r>=97&&r<=122||i===`RFC1738`&&(r===40||r===41)){n[n.length]=t.charAt(e);continue}if(r<128){n[n.length]=x[r];continue}if(r<2048){n[n.length]=x[192|r>>6]+x[128|r&63];continue}if(r<55296||r>=57344){n[n.length]=x[224|r>>12]+x[128|r>>6&63]+x[128|r&63];continue}e+=1,r=65536+((r&1023)<<10|t.charCodeAt(e)&1023),n[n.length]=x[240|r>>18]+x[128|r>>12&63]+x[128|r>>6&63]+x[128|r&63]}o+=n.join(``)}return o}}));function $e(e){return typeof e==`string`||typeof e==`number`||typeof e==`boolean`||typeof e==`symbol`||typeof e==`bigint`}function et(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,ee){let _=e,v=ee,y=0,te=!1;for(;(v=v.get(ot))!==void 0&&!te;){let t=v.get(e);if(y+=1,t!==void 0){if(t===y)throw RangeError(`Cyclic object value`);te=!0}v.get(ot)===void 0&&(y=0)}if(typeof l==`function`?_=l(t,_):_ instanceof Date?_=f?.(_):n===`comma`&&b(_)&&(_=Je(_,function(e){return e instanceof Date?f?.(e):e})),_===null){if(a)return c&&!h?c(t,S.encoder,g,`key`,p):t;_=``}if($e(_)||qe(_)){if(c){let e=h?t:c(t,S.encoder,g,`key`,p);return[m?.(e)+`=`+m?.(c(_,S.encoder,g,`value`,p))]}return[m?.(t)+`=`+m?.(String(_))]}let ne=[];if(_===void 0)return ne;let re;if(n===`comma`&&b(_))h&&c&&(_=Je(_,c)),re=[{value:_.length>0?_.join(`,`)||null:void 0}];else if(b(l))re=l;else{let e=Object.keys(_);re=u?e.sort(u):e}let ie=s?String(t).replace(/\./g,`%2E`):String(t),ae=r&&b(_)&&_.length===1?ie+`[]`:ie;if(i&&b(_)&&_.length===0)return ae+`[]`;for(let t=0;t<re.length;++t){let v=re[t],te=typeof v==`object`&&v.value!==void 0?v.value:_[v];if(o&&te===null)continue;let ie=d&&s?v.replace(/\./g,`%2E`):v,oe=b(_)?typeof n==`function`?n(ae,ie):ae:ae+(d?`.`+ie:`[`+ie+`]`);ee.set(e,y);let se=new WeakMap;se.set(ot,ee),it(ne,et(te,oe,n,r,i,a,o,s,n===`comma`&&h&&b(_)?null:c,l,u,d,f,p,m,h,g,se))}return ne}function tt(e=S){if(e.allowEmptyArrays!==void 0&&typeof e.allowEmptyArrays!=`boolean`)throw TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(e.encodeDotInKeys!==void 0&&typeof e.encodeDotInKeys!=`boolean`)throw TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(e.encoder!==null&&e.encoder!==void 0&&typeof e.encoder!=`function`)throw TypeError(`Encoder has to be a function.`);let t=e.charset||S.charset;if(e.charset!==void 0&&e.charset!==`utf-8`&&e.charset!==`iso-8859-1`)throw TypeError(`The charset option must be either utf-8, iso-8859-1, or undefined`);let n=Ue;if(e.format!==void 0){if(!Ye(Ge,e.format))throw TypeError(`Unknown format option provided.`);n=e.format}let r=Ge[n],i=S.filter;(typeof e.filter==`function`||b(e.filter))&&(i=e.filter);let a;if(a=e.arrayFormat&&e.arrayFormat in rt?e.arrayFormat:`indices`in e?e.indices?`indices`:`repeat`:S.arrayFormat,`commaRoundTrip`in e&&typeof e.commaRoundTrip!=`boolean`)throw TypeError("`commaRoundTrip` must be a boolean, or absent");let o=e.allowDots===void 0?e.encodeDotInKeys?!0:S.allowDots:!!e.allowDots;return{addQueryPrefix:typeof e.addQueryPrefix==`boolean`?e.addQueryPrefix:S.addQueryPrefix,allowDots:o,allowEmptyArrays:typeof e.allowEmptyArrays==`boolean`?!!e.allowEmptyArrays:S.allowEmptyArrays,arrayFormat:a,charset:t,charsetSentinel:typeof e.charsetSentinel==`boolean`?e.charsetSentinel:S.charsetSentinel,commaRoundTrip:!!e.commaRoundTrip,delimiter:e.delimiter===void 0?S.delimiter:e.delimiter,encode:typeof e.encode==`boolean`?e.encode:S.encode,encodeDotInKeys:typeof e.encodeDotInKeys==`boolean`?e.encodeDotInKeys:S.encodeDotInKeys,encoder:typeof e.encoder==`function`?e.encoder:S.encoder,encodeValuesOnly:typeof e.encodeValuesOnly==`boolean`?e.encodeValuesOnly:S.encodeValuesOnly,filter:i,format:n,formatter:r,serializeDate:typeof e.serializeDate==`function`?e.serializeDate:S.serializeDate,skipNulls:typeof e.skipNulls==`boolean`?e.skipNulls:S.skipNulls,sort:typeof e.sort==`function`?e.sort:null,strictNullHandling:typeof e.strictNullHandling==`boolean`?e.strictNullHandling:S.strictNullHandling}}function nt(e,t={}){let n=e,r=tt(t),i,a;typeof r.filter==`function`?(a=r.filter,n=a(``,n)):b(r.filter)&&(a=r.filter,i=a);let o=[];if(typeof n!=`object`||!n)return``;let s=rt[r.arrayFormat],c=s===`comma`&&r.commaRoundTrip;i||(i=Object.keys(n)),r.sort&&i.sort(r.sort);let l=new WeakMap;for(let e=0;e<i.length;++e){let t=i[e];r.skipNulls&&n[t]===null||it(o,et(n[t],t,s,c,r.allowEmptyArrays,r.strictNullHandling,r.skipNulls,r.encodeDotInKeys,r.encode?r.encoder:null,r.filter,r.sort,r.allowDots,r.serializeDate,r.format,r.formatter,r.encodeValuesOnly,r.charset,l))}let u=o.join(r.delimiter),d=r.addQueryPrefix===!0?`?`:``;return r.charsetSentinel&&(r.charset===`iso-8859-1`?d+=`utf8=%26%2310003%3B&`:d+=`utf8=%E2%9C%93&`),u.length>0?d+u:``}var rt,it,at,S,ot,st=e((()=>{Qe(),Ke(),xe(),rt={brackets(e){return String(e)+`[]`},comma:`comma`,indices(e,t){return String(e)+`[`+t+`]`},repeat(e){return String(e)}},it=function(e,t){Array.prototype.push.apply(e,b(t)?t:[t])},S={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:`indices`,charset:`utf-8`,charsetSentinel:!1,delimiter:`&`,encode:!0,encodeDotInKeys:!1,encoder:Ze,encodeValuesOnly:!1,format:Ue,formatter:We,indices:!1,serializeDate(e){return(at??(at=Function.prototype.call.bind(Date.prototype.toISOString)))(e)},skipNulls:!1,strictNullHandling:!1},ot={}}));function ct(e){return nt(e,{arrayFormat:`brackets`})}var lt=e((()=>{st()}));function ut(e){let t=0;for(let n of e)t+=n.length;let n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}function dt(e){let t;return(pt??(t=new globalThis.TextEncoder,pt=t.encode.bind(t)))(e)}function ft(e){let t;return(mt??(t=new globalThis.TextDecoder,mt=t.decode.bind(t)))(e)}var pt,mt,ht=e((()=>{}));function gt(e,t){for(let n=t??0;n<e.length;n++){if(e[n]===10)return{preceding:n,index:n+1,carriage:!1};if(e[n]===13)return{preceding:n,index:n+1,carriage:!0}}return null}function _t(e){for(let t=0;t<e.length-1;t++){if(e[t]===10&&e[t+1]===10||e[t]===13&&e[t+1]===13)return t+2;if(e[t]===13&&e[t+1]===10&&t+3<e.length&&e[t+2]===13&&e[t+3]===10)return t+4}return-1}var C,w,vt,yt=e((()=>{s(),ht(),vt=class{constructor(){C.set(this,void 0),w.set(this,void 0),a(this,C,new Uint8Array,`f`),a(this,w,null,`f`)}decode(e){if(e==null)return[];let t=e instanceof ArrayBuffer?new Uint8Array(e):typeof e==`string`?dt(e):e;a(this,C,ut([o(this,C,`f`),t]),`f`);let n=[],r;for(;(r=gt(o(this,C,`f`),o(this,w,`f`)))!=null;){if(r.carriage&&o(this,w,`f`)==null){a(this,w,r.index,`f`);continue}if(o(this,w,`f`)!=null&&(r.index!==o(this,w,`f`)+1||r.carriage)){n.push(ft(o(this,C,`f`).subarray(0,o(this,w,`f`)-1))),a(this,C,o(this,C,`f`).subarray(o(this,w,`f`)),`f`),a(this,w,null,`f`);continue}let e=o(this,w,`f`)===null?r.preceding:r.preceding-1,t=ft(o(this,C,`f`).subarray(0,e));n.push(t),a(this,C,o(this,C,`f`).subarray(r.index),`f`),a(this,w,null,`f`)}return n}flush(){return o(this,C,`f`).length?this.decode(`
2
2
  `):[]}},C=new WeakMap,w=new WeakMap,vt.NEWLINE_CHARS=new Set([`
3
3
  `,`\r`]),vt.NEWLINE_REGEXP=/\r\n|[\n\r]/g}));function bt(){}function xt(e,t,n){return!t||St[e]>St[n]?bt:t[e].bind(t)}function T(e){let t=e.logger,n=e.logLevel??`off`;if(!t)return wt;let r=Tt.get(t);if(r&&r[0]===n)return r[1];let i={error:xt(`error`,t,n),warn:xt(`warn`,t,n),info:xt(`info`,t,n),debug:xt(`debug`,t,n)};return Tt.set(t,[n,i]),i}var St,Ct,wt,Tt,Et,Dt=e((()=>{xe(),St={off:0,error:200,warn:300,info:400,debug:500},Ct=(e,t,n)=>{if(e){if(me(St,e))return e;T(n).warn(`${t} was set to ${JSON.stringify(e)}, expected one of ${JSON.stringify(Object.keys(St))}`)}},wt={error:bt,warn:bt,info:bt,debug:bt},Tt=new WeakMap,Et=e=>(e.options&&(e.options={...e.options},delete e.options.headers),e.headers&&(e.headers=Object.fromEntries((e.headers instanceof Headers?[...e.headers]:Object.entries(e.headers)).map(([e,t])=>[e,e.toLowerCase()===`authorization`||e.toLowerCase()===`api-key`||e.toLowerCase()===`x-api-key`||e.toLowerCase()===`x-amz-security-token`||e.toLowerCase()===`cookie`||e.toLowerCase()===`set-cookie`?`***`:t]))),`retryOfRequestLogID`in e&&(e.retryOfRequestLogID&&(e.retryOf=e.retryOfRequestLogID),delete e.retryOfRequestLogID),e)}));async function*Ot(e,t){if(!e.body)throw t.abort(),globalThis.navigator!==void 0&&globalThis.navigator.product===`ReactNative`?new p(`The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api`):new p(`Attempted to iterate over a response with no body`);let n=new Nt,r=new vt,i=Re(e.body);for await(let e of kt(i))for(let t of r.decode(e)){let e=n.decode(t);e&&(yield e)}for(let e of r.flush()){let t=n.decode(e);t&&(yield t)}}async function*kt(e){let t=new Uint8Array;for await(let n of e){if(n==null)continue;let e=n instanceof ArrayBuffer?new Uint8Array(n):typeof n==`string`?dt(n):n,r=new Uint8Array(t.length+e.length);r.set(t),r.set(e,t.length),t=r;let i;for(;(i=_t(t))!==-1;)yield t.slice(0,i),t=t.slice(i)}t.length>0&&(yield t)}function At(e,t){let n=e.indexOf(t);return n===-1?[e,``,``]:[e.substring(0,n),t,e.substring(n+t.length)]}var jt,Mt,Nt,Pt=e((()=>{s(),de(),Be(),yt(),f(),ht(),Dt(),Mt=class e{constructor(e,t,n){this.iterator=e,jt.set(this,void 0),this.controller=t,a(this,jt,n,`f`)}static fromSSEResponse(t,n,r,i){let a=!1,o=r?T(r):console;async function*s(){if(a)throw new p("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");a=!0;let e=!1;try{for await(let r of Ot(t,n))if(!e){if(r.data.startsWith(`[DONE]`)){e=!0;continue}if(r.event===null||!r.event.startsWith(`thread.`)){let e;try{e=JSON.parse(r.data)}catch(e){throw o.error(`Could not parse message into JSON:`,r.data),o.error(`From chunk:`,r.raw),e}if(e&&e.error)throw new m(void 0,e.error,void 0,t.headers);yield i?{event:r.event,data:e}:e}else{let e;try{e=JSON.parse(r.data)}catch(e){throw console.error(`Could not parse message into JSON:`,r.data),console.error(`From chunk:`,r.raw),e}if(r.event==`error`)throw new m(void 0,e.error,e.message,void 0);yield{event:r.event,data:e}}}e=!0}catch(e){if(u(e))return;throw e}finally{e||n.abort()}}return new e(s,n,r)}static fromReadableStream(t,n,r){let i=!1;async function*a(){let e=new vt,n=Re(t);for await(let t of n)for(let n of e.decode(t))yield n;for(let t of e.flush())yield t}async function*o(){if(i)throw new p("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");i=!0;let e=!1;try{for await(let t of a())e||t&&(yield JSON.parse(t));e=!0}catch(e){if(u(e))return;throw e}finally{e||n.abort()}}return new e(o,n,r)}[(jt=new WeakMap,Symbol.asyncIterator)](){return this.iterator()}tee(){let t=[],n=[],r=this.iterator(),i=e=>({next:()=>{if(e.length===0){let e=r.next();t.push(e),n.push(e)}return e.shift()}});return[new e(()=>i(t),this.controller,o(this,jt,`f`)),new e(()=>i(n),this.controller,o(this,jt,`f`))]}toReadableStream(){let e=this,t;return Ie({async start(){t=e[Symbol.asyncIterator]()},async pull(e){try{let{value:n,done:r}=await t.next();if(r)return e.close();let i=dt(JSON.stringify(n)+`
4
4
  `);e.enqueue(i)}catch(t){e.error(t)}},async cancel(){await t.return?.()}})}},Nt=class{constructor(){this.event=null,this.data=[],this.chunks=[]}decode(e){if(e.endsWith(`\r`)&&(e=e.substring(0,e.length-1)),!e){if(!this.event&&!this.data.length)return null;let e={event:this.event,data:this.data.join(`
@@ -0,0 +1 @@
1
+ import{r as e,t}from"./client-DFlE4fYh.js";e();export{t as clearOpenAIClientCache};
@@ -0,0 +1 @@
1
+ import{Ai as e,Bi as t,Fi as n}from"./loadAgentsDir-C7lOqvfh.js";t();export{e as clearCommandsCache,n as getCommands};
@@ -0,0 +1,2 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{Ba as t,Bv as n,Cv as r,Dp as i,Dv as a,Ep as o,I_ as s,Jv as c,Kv as l,L_ as u,Ma as d,Mv as f,N_ as p,Ov as m,P_ as h,QC as g,Qm as _,Sv as v,Yv as y,ZC as b,_v as x,ct as S,eh as C,ih as w,jv as T,lt as E,oh as D,vn as O,vv as k,xv as A}from"./loadAgentsDir-C7lOqvfh.js";import{di as j,ui as M}from"./src-P_wYS_NJ2.js";import{Wt as N,qt as P}from"./state-BemZdQIl.js";import{R as F,z as I}from"./debug-RAynG_nM.js";import{o as L,s as R}from"./log-CezCRpAN.js";function z(e,t){let n=o(`tip`),r=b(`app:toggleTranscript`,`Global`,`ctrl+o`),i=[...e.options.verbose?[]:[`(${r} to see full summary)`],...t?[t]:[],...n?[n]:[]];return M.dim(`Compacted `+i.join(`
2
+ `))}async function B(e,t){let n=e.getAppState(),r=await S(e.options.tools,e.options.mainLoopModel,Array.from(n.toolPermissionContext.additionalWorkingDirectories.keys()),e.options.mcpClients),i=x({mainThreadAgentDefinition:void 0,toolUseContext:e,customSystemPrompt:e.options.customSystemPrompt,defaultSystemPrompt:r,appendSystemPrompt:e.options.appendSystemPrompt}),[a,o]=await Promise.all([v(),A()]);return{systemPrompt:i,userContext:a,systemContext:o,toolUseContext:e,forkContextMessages:t}}var V;e((()=>{j(),N(),E(),r(),g(),c(),u(),T(),a(),w(),_(),n(),I(),O(),L(),t(),i(),k(),V=async(e,t)=>{let{abortController:n}=t,{messages:r}=t;if(r=d(r),r.length===0)throw Error(`No messages to compact`);let i=e.trim();try{if(!i){let e=await C(r,t.agentId);if(e)return v.cache.clear?.(),D(),y(t.options.querySource??`compact`,t.agentId),P(),f(),{type:`compact`,compactionResult:e,displayText:z(t)}}let e=(await m(r,t)).messages,n=await s(e,t,await B(t,e),!1,i,!1);return l(void 0),f(),v.cache.clear?.(),D(),{type:`compact`,compactionResult:n,displayText:z(t,n.userDisplayMessage)}}catch(e){throw n.signal.aborted?Error(`Compaction canceled.`):F(e,`Not enough messages to compact. Send a few more messages first, then try again.`)?Error(h):F(e,`Compaction interrupted · This may be due to network issues — please try again.`)?Error(p):(R(e),Error(`Error during compaction: ${e}`))}}}))();export{V as call};