@readmagic/workmate 0.0.9 → 0.0.11

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 (445) hide show
  1. package/dist/chunks/{AddWorkspaceDirectory-qFZy3FOD.js → AddWorkspaceDirectory-ag2JTpmU.js} +1 -1
  2. package/dist/chunks/{App-DW4elk6E.js → App-BuKmqFPm.js} +1 -1
  3. package/dist/chunks/ApproveApiKey-CIWOi_7v.js +1 -0
  4. package/dist/chunks/ApproveApiKey-M6U-NafA.js +1 -0
  5. package/dist/chunks/BackgroundTasksDialog-Pnpl3Ixx.js +2 -0
  6. package/dist/chunks/{BypassPermissionsModeDialog-BuRFF1fQ.js → BypassPermissionsModeDialog-B05t83wa.js} +1 -1
  7. package/dist/chunks/{ClaudeMdExternalIncludesDialog-CDrArsSX.js → ClaudeMdExternalIncludesDialog-CSywJdVL.js} +1 -1
  8. package/dist/chunks/ClaudeMdExternalIncludesDialog-D-w166RC.js +1 -0
  9. package/dist/chunks/ConsoleOAuthFlow-CV6PcJOP.js +1 -0
  10. package/dist/chunks/{DiffDialog-BIcwpgSr.js → DiffDialog-DUbFrzKu.js} +3 -3
  11. package/dist/chunks/Doctor-BcnUfJ4I.js +1 -0
  12. package/dist/chunks/Doctor-Dz4TuYas.js +3 -0
  13. package/dist/chunks/ExitFlow-BwyAtIHx.js +2 -0
  14. package/dist/chunks/{Grove-BmirUB6V.js → Grove-BDoVj02t.js} +2 -2
  15. package/dist/chunks/{HybridTransport-BVmSUHf0.js → HybridTransport-C_U0IJfz.js} +4 -4
  16. package/dist/chunks/{InvalidConfigDialog-WRywkKeS.js → InvalidConfigDialog-bih293Xt.js} +1 -1
  17. package/dist/chunks/{InvalidSettingsDialog-C4n3A72C.js → InvalidSettingsDialog-Br8kQOHz.js} +1 -1
  18. package/dist/chunks/MCPConnectionManager-B9n4SXN4.js +1 -0
  19. package/dist/chunks/MCPToolListView-DJ06N1DG.js +1 -0
  20. package/dist/chunks/{McpParsingWarnings-CH4yyMAL.js → McpParsingWarnings-COa71S9q.js} +1 -1
  21. package/dist/chunks/MessageSelector-o4ULADFg.js +3 -0
  22. package/dist/chunks/Messages-qqwHuAW5.js +11 -0
  23. package/dist/chunks/{Onboarding-BboWs1pp.js → Onboarding-BzuQjney.js} +1 -1
  24. package/dist/chunks/{PromptInputFooterSuggestions-BpC9COmh.js → PromptInputFooterSuggestions-to5eYBvI.js} +1 -1
  25. package/dist/chunks/PromptInputHelpMenu-CfMFx-TF.js +1 -0
  26. package/dist/chunks/QueryEngine-Dt0BKUeF.js +1 -0
  27. package/dist/chunks/REPL-CUbEDqEl.js +133 -0
  28. package/dist/chunks/REPL-DMaKNhTa.js +1 -0
  29. package/dist/chunks/RemoteSessionManager-Bf44A0Ol.js +2 -0
  30. package/dist/chunks/ResumeConversation-Ctw5Q1g9.js +1 -0
  31. package/dist/chunks/{SSETransport-1KBBUikF.js → SSETransport-DN4tCDEh.js} +3 -3
  32. package/dist/chunks/SearchExtraToolsTool-C80OdtPZ.js +1 -0
  33. package/dist/chunks/Settings-DfdcmvOV.js +2 -0
  34. package/dist/chunks/{TeleportProgress-BmgPAZAi.js → TeleportProgress-C2LQVLav.js} +1 -1
  35. package/dist/chunks/{TeleportRepoMismatchDialog-sgxNOeM_.js → TeleportRepoMismatchDialog-BZL8Zblz.js} +1 -1
  36. package/dist/chunks/{TeleportResumeWrapper-GptvrUdv.js → TeleportResumeWrapper-wPiIs8xg.js} +1 -1
  37. package/dist/chunks/{ThemePicker-gAMqqD1P.js → ThemePicker-BT_NaRQC.js} +1 -1
  38. package/dist/chunks/{TrustDialog-CWt-4Evl.js → TrustDialog-ACaJ_m7A.js} +1 -1
  39. package/dist/chunks/{ValidationErrorsList-De3kzHtz.js → ValidationErrorsList-C-hWdy_8.js} +1 -1
  40. package/dist/chunks/WelcomeV2-ZQRKlcT4.js +1 -0
  41. package/dist/chunks/add-dir-SAKTkw0S.js +1 -0
  42. package/dist/chunks/{agentDisplay-5gnCQwUY.js → agentDisplay-CuSHqgZc.js} +1 -1
  43. package/dist/chunks/{agents-Bz1MLp4A.js → agents-CMC0iQP4.js} +1 -1
  44. package/dist/chunks/agents-ZgRKpjHv.js +103 -0
  45. package/dist/chunks/allErrors-_cOQksHC.js +1 -0
  46. package/dist/chunks/{api-DzccRM_z.js → api-BbJfMXRS.js} +1 -1
  47. package/dist/chunks/api-DS1MiW01.js +1 -0
  48. package/dist/chunks/{auth-Cjnyy10u.js → auth-7mJGtlZp.js} +2 -2
  49. package/dist/chunks/auth-DGZzCbU0.js +1 -0
  50. package/dist/chunks/auth-DN1MUpB8.js +1 -0
  51. package/dist/chunks/{autoMode-CQ5nqP9c.js → autoMode-CBtY7ACs.js} +6 -6
  52. package/dist/chunks/autonomy-DuQmYhq6.js +15 -0
  53. package/dist/chunks/{autonomy-CPUCe-YU.js → autonomy-lJV7yWUl.js} +1 -1
  54. package/dist/chunks/autonomyPanel-DAQm6lDz.js +1 -0
  55. package/dist/chunks/backgroundHousekeeping-BTy71bcY.js +1 -0
  56. package/dist/chunks/backgroundHousekeeping-Cc7Ag7JG.js +17 -0
  57. package/dist/chunks/{banner-BJZNMppT.js → banner-1Wyeyawe.js} +1 -1
  58. package/dist/chunks/{bg-w3Vlsm3Y.js → bg-CJ0YWFli.js} +2 -2
  59. package/dist/chunks/bg-CeUrRz_7.js +1 -0
  60. package/dist/chunks/branch-k3kirqbA.js +3 -0
  61. package/dist/chunks/{break-cache-DXV0brco.js → break-cache-CAoZ9b72.js} +2 -2
  62. package/dist/chunks/bridgeConfig-CzRUPn-D.js +1 -0
  63. package/dist/chunks/{bridgeConfig-vORehbGG.js → bridgeConfig-UgaUfuP6.js} +1 -1
  64. package/dist/chunks/bridgeMessaging-Ci5H68MX.js +1 -0
  65. package/dist/chunks/{bridgePointer-D4W9GpWw.js → bridgePointer-BL8-lGvN.js} +1 -1
  66. package/dist/chunks/bridgeStatusUtil-C36w15ge.js +1 -0
  67. package/dist/chunks/{btw-DDUC_t0w.js → btw-nVoVuIae.js} +1 -1
  68. package/dist/chunks/caches-B8sM3Zys.js +1 -0
  69. package/dist/chunks/caches-Bp9MZ7IE.js +1 -0
  70. package/dist/chunks/{capacityWake-L7b1mMft.js → capacityWake-BOySRJUJ.js} +1 -1
  71. package/dist/chunks/ccrClient-Br4LAofR.js +1 -0
  72. package/dist/chunks/{claudeDesktop-CAmnheYx.js → claudeDesktop-Bgds1-YT.js} +1 -1
  73. package/dist/chunks/{clear-DdWexxbM.js → clear-C4Vtnbye.js} +1 -1
  74. package/dist/chunks/{cliLaunch-BWWOgBFh.js → cliLaunch-BTpfAGGI.js} +1 -1
  75. package/dist/chunks/{client-CoXtVRzi.js → client-B9404qIP.js} +1 -1
  76. package/dist/chunks/client-BCAbKdNz.js +1 -0
  77. package/dist/chunks/client-CJE6gEvU.js +1 -0
  78. package/dist/chunks/commands-DL-BzoMQ.js +1 -0
  79. package/dist/chunks/compact-Cx7BPXLU.js +2 -0
  80. package/dist/chunks/config-S5OW4Xqr.js +1 -0
  81. package/dist/chunks/config-aRiTrtCv.js +3 -0
  82. package/dist/chunks/{config-CVvUNkj2.js → config-kB2eazPX.js} +1 -1
  83. package/dist/chunks/{context-BWcfhhDj.js → context-BN7DEjoH.js} +1 -1
  84. package/dist/chunks/{context-noninteractive-c7jGVWHQ.js → context-noninteractive-D91W2B8e.js} +5 -5
  85. package/dist/chunks/context-noninteractive-DPacEFJ1.js +1 -0
  86. package/dist/chunks/conversation-D5Nbu9eT.js +1 -0
  87. package/dist/chunks/conversation-hcUx9e-C.js +1 -0
  88. package/dist/chunks/{createSSHSession-DP7B8yvb.js → createSSHSession-DecOR6M5.js} +6 -6
  89. package/dist/chunks/createSession-D27zvmOs.js +1 -0
  90. package/dist/chunks/createSession-DRqkLZWt.js +1 -0
  91. package/dist/chunks/crossProjectResume-Bw3U0Ty6.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-bm551AVV.js +1 -0
  95. package/dist/chunks/debug-BecbSVoN.js +39 -0
  96. package/dist/chunks/{debugUtils-CezNYZ-4.js → debugUtils-CmJfIUxW.js} +1 -1
  97. package/dist/chunks/{detached-CkPpYMJj.js → detached-CIyF0M5O.js} +1 -1
  98. package/dist/chunks/detectRepository-C15umvKN.js +1 -0
  99. package/dist/chunks/detectRepository-DDfLfKcM.js +1 -0
  100. package/dist/chunks/{diff-DHzz9WAp.js → diff-DeK4bwjw.js} +1 -1
  101. package/dist/chunks/{directoryCompletion-D5AvL7TF.js → directoryCompletion-BJCu19HJ.js} +1 -1
  102. package/dist/chunks/doctor-BJORBomU.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-mdegyj8z.js +14 -0
  106. package/dist/chunks/esm-Ka3lhafK.js +1 -0
  107. package/dist/chunks/{execFileNoThrow-5SylUnAI.js → execFileNoThrow-DHyW8FMX.js} +2 -2
  108. package/dist/chunks/execSyncWrapper-CDzB0BM1.js +1 -0
  109. package/dist/chunks/exit-CF3KBl-S.js +1 -0
  110. package/dist/chunks/{extraUsage-Dt5mw35U.js → extraUsage-BrKbpBK-.js} +1 -1
  111. package/dist/chunks/extractMemories-4lBn134y.js +1 -0
  112. package/dist/chunks/fast-0Vi354KI.js +1 -0
  113. package/dist/chunks/{fast-ClYQcEv5.js → fast-DWn40OcQ.js} +1 -1
  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-C7Pwq2yj.js} +3 -3
  117. package/dist/chunks/firstPartyEventLogger-BHjBQH0J.js +5 -0
  118. package/dist/chunks/firstPartyEventLogger-BNBnLYPK.js +1 -0
  119. package/dist/chunks/flushGate-DdJjxCes.js +1 -0
  120. package/dist/chunks/{gemini-fZ0VPU2A.js → gemini-DHv2iVfy.js} +1 -1
  121. package/dist/chunks/generateSessionName-DhS_6oHd.js +1 -0
  122. package/dist/chunks/{genericProcessUtils-BmDSLcMf.js → genericProcessUtils-B2HcDYhg.js} +1 -1
  123. package/dist/chunks/git-DBlOv64X.js +6 -0
  124. package/dist/chunks/git-DF4RFFaT.js +1 -0
  125. package/dist/chunks/githubRepoPathMapping-CK56bUDe.js +1 -0
  126. package/dist/chunks/{goal-IasZVqKh.js → goal-BZG4gtnb.js} +3 -3
  127. package/dist/chunks/{grok-Dk3LyzMa.js → grok-BS57ZhyW.js} +1 -1
  128. package/dist/chunks/{grove-BE4fQ6tG.js → grove-_zlQ83yR.js} +2 -2
  129. package/dist/chunks/help-C_2tdXHC.js +1 -0
  130. package/dist/chunks/{hooks-BrKy5XWQ.js → hooks-C7Bn7MBe.js} +2 -2
  131. package/dist/chunks/hooks-DT80Arzc.js +1 -0
  132. package/dist/chunks/initReplBridge-NkZRcM77.js +1 -0
  133. package/dist/chunks/{install-CVGZ55wV.js → install-Du-DSVzj.js} +1 -1
  134. package/dist/chunks/{instrumentation-BmWotlxR.js → instrumentation-DMs3b82f.js} +5 -5
  135. package/dist/chunks/intl-D2kgJmX7.js +1 -0
  136. package/dist/chunks/{job-DEXxW_Zo.js → job-rbX1VZmp.js} +1 -1
  137. package/dist/chunks/jwtUtils-OzxN2zts.js +1 -0
  138. package/dist/chunks/keybindings-CwdC_8S0.js +2 -0
  139. package/dist/chunks/{launchLocalMemory-CLSSVFoj.js → launchLocalMemory-BLRCK1_o.js} +2 -2
  140. package/dist/chunks/{launchOnboarding-BkJfKviO.js → launchOnboarding-Al_X75Vz.js} +1 -1
  141. package/dist/chunks/{loadAgentsDir-CKSb56Gp.js → loadAgentsDir-BL93ulMm.js} +2197 -2332
  142. package/dist/chunks/loadAgentsDir-eVKq8efm.js +1 -0
  143. package/dist/chunks/loadPluginHooks-B0au35a4.js +1 -0
  144. package/dist/chunks/{localSearch-CPOnyi8I.js → localSearch-C5ipegd9.js} +1 -1
  145. package/dist/chunks/localSearch-CZlFfR_X.js +1 -0
  146. package/dist/chunks/log-Dauqle-Z.js +1 -0
  147. package/dist/chunks/{logoV2Utils-we1sfJvf.js → logoV2Utils-CkvOihX7.js} +1 -1
  148. package/dist/chunks/{magicDocs-DmKlTQvK.js → magicDocs-DLav5QK0.js} +3 -3
  149. package/dist/chunks/main-CVNWNAoh.js +513 -0
  150. package/dist/chunks/{main-ClXu1ilx.js → main-LMyE3jXY.js} +4 -4
  151. package/dist/chunks/managedEnv-CYepSnm8.js +1 -0
  152. package/dist/chunks/{managedEnv-Cl7YbYzf.js → managedEnv-DJSCuqCb.js} +1 -1
  153. package/dist/chunks/{mappers-xQC-Z4-h.js → mappers-DQxMcezy.js} +1 -1
  154. package/dist/chunks/mcp-BAbbEaBA.js +1 -0
  155. package/dist/chunks/mcp-Ct4Sum6A.js +6 -0
  156. package/dist/chunks/mcp-D5HkCqUh.js +2 -0
  157. package/dist/chunks/{memoize-FJv2HV1u.js → memoize-FeyE7JEh.js} +1 -1
  158. package/dist/chunks/memory-COa7aUbx.js +1 -0
  159. package/dist/chunks/{mode-lYTs0XHs.js → mode-Bl2RZC8M.js} +2 -2
  160. package/dist/chunks/model-B7rtZ7KV.js +1 -0
  161. package/dist/chunks/model-Bgh_r4lg.js +1 -0
  162. package/dist/chunks/model-DiuEAv6h.js +1 -0
  163. package/dist/chunks/{modelOptions-efCGKnXT.js → modelOptions-BtEZe5BB.js} +1 -1
  164. package/dist/chunks/nativeInstaller-BEwayifa.js +1 -0
  165. package/dist/chunks/omit--yH_T4rf.js +1 -0
  166. package/dist/chunks/onChangeAppState-ZdwI7boX.js +1 -0
  167. package/dist/chunks/{openai-DJLYqiRl.js → openai-DWs4D-nQ.js} +3 -3
  168. package/dist/chunks/panel-CoNfXy3K.js +1 -0
  169. package/dist/chunks/{parser-BdCj2GrE.js → parser-BH4u7QiV.js} +1 -1
  170. package/dist/chunks/parser-BMIaRErw.js +1 -0
  171. package/dist/chunks/partition-DLcW5Oo_.js +1 -0
  172. package/dist/chunks/permissions-CaucYK3s.js +3 -0
  173. package/dist/chunks/pidLock-DgOBc1Xo.js +3 -0
  174. package/dist/chunks/{plan-BeoIjNPv.js → plan-BNYDTnQd.js} +1 -1
  175. package/dist/chunks/{platform-D6IMiyqT.js → platform-B0uTQc9P.js} +1 -1
  176. package/dist/chunks/plugin-BN-of1_H.js +17 -0
  177. package/dist/chunks/pluginAutoupdate-BBU9Jn4p.js +1 -0
  178. package/dist/chunks/pluginBlocklist-DXQlbG0P.js +1 -0
  179. package/dist/chunks/pluginCliCommands-CfdVNs8D.js +1 -0
  180. package/dist/chunks/pluginFlagging-DcJ_FQuv.js +1 -0
  181. package/dist/chunks/pluginOperations-DnhzFbYI.js +2 -0
  182. package/dist/chunks/pluginStartupCheck-CKBFaMFr.js +1 -0
  183. package/dist/chunks/pluginStartupCheck-CpNB4jxG.js +1 -0
  184. package/dist/chunks/{plugins-pmipe7kE.js → plugins-CBW7kPyp.js} +4 -4
  185. package/dist/chunks/{poorMode-BxsyllUK.js → poorMode-B_xEvuEV.js} +1 -1
  186. package/dist/chunks/poorMode-yH1o41cQ.js +1 -0
  187. package/dist/chunks/print-BZOx09SU.js +26 -0
  188. package/dist/chunks/processBashCommand-dcCNCiBp.js +1 -0
  189. package/dist/chunks/processSlashCommand-YDiM63Qr.js +5 -0
  190. package/dist/chunks/prompt-CXGy0llt.js +1 -0
  191. package/dist/chunks/prompt-DovNDmcx.js +1 -0
  192. package/dist/chunks/{prompt-CybUvG8G.js → prompt-Dx7IWhBt.js} +34 -34
  193. package/dist/chunks/{promptEditor-0Ug93P2I.js → promptEditor-WCkmpejM.js} +2 -2
  194. package/dist/chunks/{protocolHandler-ClfbHTjI.js → protocolHandler-BiVWrpHi.js} +4 -4
  195. package/dist/chunks/{proxy-Blq4W6Ox.js → proxy-CVn7o19p.js} +3 -3
  196. package/dist/chunks/reconciler-C2Nd_e4n.js +1 -0
  197. package/dist/chunks/refresh-B84H2Ezd.js +1 -0
  198. package/dist/chunks/{registerProtocol-3_ozAuDK.js → registerProtocol-E0Iu5hEx.js} +2 -2
  199. package/dist/chunks/{reload-plugins-Dn1ibOiI.js → reload-plugins-D-3AUT9g.js} +1 -1
  200. package/dist/chunks/{remoteBridgeCore-Dpg6Se9C.js → remoteBridgeCore-CV6we3ZA.js} +1 -1
  201. package/dist/chunks/remoteManagedSettings-D26Q09-7.js +1 -0
  202. package/dist/chunks/rename-CSavuBIE.js +1 -0
  203. package/dist/chunks/{renderOptions-CLcco6fc.js → renderOptions-DDLbSMQU.js} +1 -1
  204. package/dist/chunks/resume-CROylN3J.js +2 -0
  205. package/dist/chunks/ripgrep-2M1GkXqJ.js +1 -0
  206. package/dist/chunks/{ripgrep-DkL2S7-I.js → ripgrep-C1ydIMzT.js} +5 -5
  207. package/dist/chunks/{runtimeObserver-DonWCJOx.js → runtimeObserver-L7pSIWBT.js} +4 -4
  208. package/dist/chunks/{runtimeObserver-B0xfyLiA.js → runtimeObserver-OU8KrZQG.js} +1 -1
  209. package/dist/chunks/sandbox-adapter-6UwMLh6e.js +1 -0
  210. package/dist/chunks/{sandbox-toggle-CSdnHWp-.js → sandbox-toggle-YrQNWGsr.js} +1 -1
  211. package/dist/chunks/searchExtraTools-Bdv5HJ74.js +1 -0
  212. package/dist/chunks/{session-BbQlh2S5.js → session-DUYsfPy_.js} +2 -2
  213. package/dist/chunks/sessionFileAccessHooks-Czen7Ejz.js +1 -0
  214. package/dist/chunks/sessionObserver-B0zucj_c.js +1 -0
  215. package/dist/chunks/{sessionObserver-XV6N0XER.js → sessionObserver-Dv3Ba8eA.js} +2 -2
  216. package/dist/chunks/sessionState-D-SaBzWD.js +11 -0
  217. package/dist/chunks/sessionStorage-BM1x51Z7.js +1 -0
  218. package/dist/chunks/{sessionTitle-E1FvsKM9.js → sessionTitle-uCuYaNif.js} +2 -2
  219. package/dist/chunks/{sessionTracing-ClGQ08jM.js → sessionTracing-Bqb3vJTt.js} +3 -3
  220. package/dist/chunks/settings-BG15IFYx.js +1 -0
  221. package/dist/chunks/settings-D4CpDv2y.js +20 -0
  222. package/dist/chunks/settingsSync-BSrpnyqo.js +1 -0
  223. package/dist/chunks/setup-C62oq4AZ.js +3 -0
  224. package/dist/chunks/{shadowedRuleDetection-B9iSx6mB.js → shadowedRuleDetection-BzAZ57p2.js} +1 -1
  225. package/dist/chunks/{shellQuote-Bth6IZgX.js → shellQuote-DS6WrivY.js} +2 -2
  226. package/dist/chunks/{sideQuestion-D2dPToW8.js → sideQuestion-CvMBBjI8.js} +3 -3
  227. package/dist/chunks/sinks-WJ7nzLQs.js +1 -0
  228. package/dist/chunks/sinks-f7qYjbKJ.js +2 -0
  229. package/dist/chunks/skillChangeDetector-U5kRU5nd.js +1 -0
  230. package/dist/chunks/{skillGapStore-DylpOKJ6.js → skillGapStore-CqaT8c0C.js} +2 -2
  231. package/dist/chunks/{skillLifecycle-GK-8eyyn.js → skillLifecycle-CnR8IqJM.js} +2 -2
  232. package/dist/chunks/skillSearchPanel-D9qrOXpI.js +21 -0
  233. package/dist/chunks/{skills-t6krW8GZ.js → skills-BgcFh0vy.js} +1 -1
  234. package/dist/chunks/startupProfiler-B4HBBbHN.js +1 -0
  235. package/dist/chunks/{startupProfiler-jeId9f2i.js → startupProfiler-CmH_aVy2.js} +3 -3
  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-B8uQ-UDi.js} +1 -1
  239. package/dist/chunks/{status-BtsnKNVY.js → status-BekdWoIj.js} +1 -1
  240. package/dist/chunks/{status-nZQEar7T.js → status-D6KlRJmR.js} +2 -2
  241. package/dist/chunks/statusNoticeHelpers-BMM8_uJ1.js +1 -0
  242. package/dist/chunks/{stringUtils-CbS6OkmE.js → stringUtils-C8PaYpQF.js} +1 -1
  243. package/dist/chunks/switcher-Ck9CrXrr.js +1 -0
  244. package/dist/chunks/{switcher-77h2J5HC.js → switcher-DnAhkyIn.js} +1 -1
  245. package/dist/chunks/syncCache-ClP9aBqK.js +1 -0
  246. package/dist/chunks/{tasks-BNrdmF9p.js → tasks-Dmh6qikm.js} +1 -1
  247. package/dist/chunks/teleport-DH3IuAUQ.js +1 -0
  248. package/dist/chunks/{templateJobs-Dkv4I9c1.js → templateJobs-CxqU-s5i.js} +1 -1
  249. package/dist/chunks/{terminalSetup-DQopnSPR.js → terminalSetup-BKGcmlWp.js} +1 -1
  250. package/dist/chunks/{terminalSetup-DTGm1Eo2.js → terminalSetup-Cy19F1Js.js} +4 -4
  251. package/dist/chunks/{theme-BjpBVRf5.js → theme-U7lMFHQ0.js} +1 -1
  252. package/dist/chunks/{tmux-CMRiI6CD.js → tmux-D5EvHWi3.js} +1 -1
  253. package/dist/chunks/{toolEventObserver-D-sNBvOe.js → toolEventObserver-D9qjoVl5.js} +1 -1
  254. package/dist/chunks/toolPool-69mfSPAs.js +1 -0
  255. package/dist/chunks/trustedDevice-B6AKlsl_.js +1 -0
  256. package/dist/chunks/trustedDevice-DL0pWP4_.js +1 -0
  257. package/dist/chunks/{types-DWRxAH0E.js → types-DafcFtmb.js} +2 -2
  258. package/dist/chunks/udsClient-CWnfsgFP.js +1 -0
  259. package/dist/chunks/updateCCB-C6XftzIG.js +11 -0
  260. package/dist/chunks/{upstreamproxy-DDVMwoRi.js → upstreamproxy-CXmjxHpl.js} +2 -2
  261. package/dist/chunks/{useExitOnCtrlCDWithKeybindings-D2FvHieH.js → useExitOnCtrlCDWithKeybindings-DEEJhm_W.js} +1 -1
  262. package/dist/chunks/useMainLoopModel-6w7mhwhU.js +1 -0
  263. package/dist/chunks/useManagePlugins-CjnsO-Of.js +1 -0
  264. package/dist/chunks/{useMergedTools-B-Z9XQ6U.js → useMergedTools-DbhqKk1-.js} +1 -1
  265. package/dist/chunks/{useSearchInput-C6d6nt9S.js → useSearchInput-gUDbkLaC.js} +1 -1
  266. package/dist/chunks/useSettingsErrors-CgPad-H0.js +1 -0
  267. package/dist/chunks/{userAgent-Ng_TTjWr.js → userAgent-CU7Ndh79.js} +1 -1
  268. package/dist/chunks/util-B4oMhJKh.js +1 -0
  269. package/dist/chunks/validatePlugin-y_O_tCEL.js +1 -0
  270. package/dist/chunks/{vim-3mUqsEJm.js → vim-w37BfGZ5.js} +1 -1
  271. package/dist/chunks/{which-DznMOwny.js → which-BRWBO7Gu.js} +1 -1
  272. package/dist/chunks/windowsPaths-BY-IVNwQ.js +1 -0
  273. package/dist/chunks/windowsPaths-DtWHLjmE.js +1 -0
  274. package/dist/chunks/{workSecret-DtiFreRl.js → workSecret-BEhXgH2M.js} +1 -1
  275. package/dist/chunks/workerRegistry-Bq9bS5pw.js +6 -0
  276. package/dist/chunks/worktree-4SUJ4dtz.js +1 -0
  277. package/dist/cli.js +1 -1
  278. package/package.json +2 -3
  279. package/dist/chunks/ApproveApiKey-D05WywHU.js +0 -1
  280. package/dist/chunks/ApproveApiKey-DHAbdwkC.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/autonomyPanel-Ccr9ilei.js +0 -1
  309. package/dist/chunks/backgroundHousekeeping--cs5crp7.js +0 -17
  310. package/dist/chunks/backgroundHousekeeping-CcbHitKC.js +0 -1
  311. package/dist/chunks/bg-DWloqGwk.js +0 -1
  312. package/dist/chunks/branch-CG0AKS1J.js +0 -3
  313. package/dist/chunks/bridgeConfig-Dmc1ZDev.js +0 -1
  314. package/dist/chunks/bridgeMessaging-DlczTV9X.js +0 -1
  315. package/dist/chunks/caches-1IFb6_M_.js +0 -1
  316. package/dist/chunks/caches-CB8MHqy2.js +0 -1
  317. package/dist/chunks/ccrClient-CG6HTv_n.js +0 -1
  318. package/dist/chunks/client-Crrwkw7g.js +0 -1
  319. package/dist/chunks/client-D8hKghba.js +0 -1
  320. package/dist/chunks/color-Cuq0c6xy.js +0 -1
  321. package/dist/chunks/commands-D3sESsTp.js +0 -1
  322. package/dist/chunks/compact-DIpwuBDq.js +0 -2
  323. package/dist/chunks/config-D4G8_MqJ.js +0 -3
  324. package/dist/chunks/config-q9D4hFiK.js +0 -1
  325. package/dist/chunks/context-noninteractive-Bwt9A3XD.js +0 -1
  326. package/dist/chunks/conversation-Bjo_8kia.js +0 -1
  327. package/dist/chunks/conversation-DrHZIQX2.js +0 -1
  328. package/dist/chunks/createSession-CPo6GBSb.js +0 -1
  329. package/dist/chunks/createSession-DnykRoia.js +0 -1
  330. package/dist/chunks/crossProjectResume-D2A-qjgP.js +0 -40
  331. package/dist/chunks/cwd--q1ONL7P.js +0 -1
  332. package/dist/chunks/cwd-L4wygFqJ.js +0 -1
  333. package/dist/chunks/daemon-D2vFIVOz.js +0 -2
  334. package/dist/chunks/datadog-DrmHyl3_.js +0 -1
  335. package/dist/chunks/debug-BdqxZ7rV.js +0 -39
  336. package/dist/chunks/detectRepository-DA1Q_Skc.js +0 -1
  337. package/dist/chunks/detectRepository-DvxoaPlk.js +0 -1
  338. package/dist/chunks/doctor-PWqB46xd.js +0 -1
  339. package/dist/chunks/earlyInput-xcoTbKQn.js +0 -1
  340. package/dist/chunks/entry-4JtoJONR.js +0 -14
  341. package/dist/chunks/esm-DcIr7tVd.js +0 -1
  342. package/dist/chunks/execSyncWrapper-DKuxVTaf.js +0 -1
  343. package/dist/chunks/exit-OW9g7b9A.js +0 -1
  344. package/dist/chunks/extractMemories-1VlmCGwa.js +0 -1
  345. package/dist/chunks/fast-CrvLdpy3.js +0 -1
  346. package/dist/chunks/featureCheck-CrJeuheQ.js +0 -1
  347. package/dist/chunks/featureCheck-HslM03dr.js +0 -1
  348. package/dist/chunks/firstPartyEventLogger-BBXEQUf0.js +0 -1
  349. package/dist/chunks/firstPartyEventLogger-DhEPWcit.js +0 -5
  350. package/dist/chunks/flushGate-ch-Tvwjj.js +0 -1
  351. package/dist/chunks/generateRecap-BIBVlB__.js +0 -1
  352. package/dist/chunks/generateSessionName-nZj_VvKZ.js +0 -1
  353. package/dist/chunks/git-B9uvt96d.js +0 -6
  354. package/dist/chunks/git-BfS5Hk4S.js +0 -1
  355. package/dist/chunks/githubRepoPathMapping-Cqx3pSfc.js +0 -1
  356. package/dist/chunks/help-D2-v9Ug9.js +0 -1
  357. package/dist/chunks/hooks-DGd02IKF.js +0 -1
  358. package/dist/chunks/initReplBridge-RhCAlmHE.js +0 -1
  359. package/dist/chunks/intl-cKc-V6Mq.js +0 -1
  360. package/dist/chunks/jwtUtils-C9sdGhvT.js +0 -1
  361. package/dist/chunks/keybindings-BRdSOSUD.js +0 -2
  362. package/dist/chunks/language-C0cIpKE2.js +0 -1
  363. package/dist/chunks/language-CxThoWRC.js +0 -1
  364. package/dist/chunks/loadAgentsDir-8UprzS4w.js +0 -1
  365. package/dist/chunks/loadPluginHooks-LbaURHVH.js +0 -1
  366. package/dist/chunks/localSearch-DNjbr4S9.js +0 -1
  367. package/dist/chunks/log-CTFl4qpD.js +0 -1
  368. package/dist/chunks/main-BIiwW4mM.js +0 -605
  369. package/dist/chunks/managedEnv-CpiiQx_v.js +0 -1
  370. package/dist/chunks/mcp-B_m1XBDt.js +0 -6
  371. package/dist/chunks/mcp-BiyfH9Sd.js +0 -1
  372. package/dist/chunks/mcp-BjlaPUWX.js +0 -2
  373. package/dist/chunks/memory-LN8f_p2b.js +0 -1
  374. package/dist/chunks/model-C2e73CJD.js +0 -1
  375. package/dist/chunks/model-CvmS-Esk.js +0 -1
  376. package/dist/chunks/model-DJ8mFfuR.js +0 -1
  377. package/dist/chunks/nativeInstaller-DQIFwdat.js +0 -1
  378. package/dist/chunks/omit-CLPZGevl.js +0 -1
  379. package/dist/chunks/onChangeAppState-DhBO34OK.js +0 -1
  380. package/dist/chunks/panel-q0_iT9cg.js +0 -1
  381. package/dist/chunks/panelCall-sum-3zvi.js +0 -1
  382. package/dist/chunks/parser-BcdhBGx0.js +0 -1
  383. package/dist/chunks/partition-CpfoVrg1.js +0 -1
  384. package/dist/chunks/permissions-DTb9wkAP.js +0 -3
  385. package/dist/chunks/pidLock-BR5M6RQw.js +0 -3
  386. package/dist/chunks/pipeTransport-B3TIkTAp.js +0 -1
  387. package/dist/chunks/plugin-D_dHjTud.js +0 -17
  388. package/dist/chunks/pluginAutoupdate-BHKlOOXI.js +0 -1
  389. package/dist/chunks/pluginBlocklist-D93Hd1GF.js +0 -1
  390. package/dist/chunks/pluginCliCommands-vv0wNt4O.js +0 -1
  391. package/dist/chunks/pluginFlagging-CxuRF2Vc.js +0 -1
  392. package/dist/chunks/pluginOperations-BTq4AjYB.js +0 -2
  393. package/dist/chunks/pluginStartupCheck-B6leNWq9.js +0 -1
  394. package/dist/chunks/pluginStartupCheck-DBOCHUHQ.js +0 -1
  395. package/dist/chunks/poorMode-iV1NwC5L.js +0 -1
  396. package/dist/chunks/print-CAUvczBM.js +0 -23
  397. package/dist/chunks/processBashCommand-CdeQg_c6.js +0 -1
  398. package/dist/chunks/processSlashCommand-CbkshIC6.js +0 -5
  399. package/dist/chunks/prompt-RBn4JdEg.js +0 -1
  400. package/dist/chunks/prompt-Rb8zXlDo.js +0 -1
  401. package/dist/chunks/reconciler-Drq3HSkj.js +0 -4
  402. package/dist/chunks/refresh-D8TLHO_T.js +0 -1
  403. package/dist/chunks/remoteManagedSettings-CCrq-qL-.js +0 -1
  404. package/dist/chunks/rename-CKsSc7Z3.js +0 -1
  405. package/dist/chunks/replBridgeHandle-DNC797_T.js +0 -1
  406. package/dist/chunks/resume-B1a5gLVR.js +0 -2
  407. package/dist/chunks/ripgrep-BisRODQ2.js +0 -1
  408. package/dist/chunks/sandbox-adapter-BnBOSkKJ.js +0 -1
  409. package/dist/chunks/searchExtraTools-DbgfnQkH.js +0 -1
  410. package/dist/chunks/sessionFileAccessHooks-Xfr1NiXG.js +0 -1
  411. package/dist/chunks/sessionMemory-7UOFdp29.js +0 -1
  412. package/dist/chunks/sessionMemory-fAzgAS7Q.js +0 -1
  413. package/dist/chunks/sessionMemoryUtils-DVjFw5Bd.js +0 -1
  414. package/dist/chunks/sessionObserver-Cl26OdaW.js +0 -1
  415. package/dist/chunks/sessionState-BvECKycx.js +0 -11
  416. package/dist/chunks/sessionStorage-DSj9yZkl.js +0 -1
  417. package/dist/chunks/settings-B-R9ZJNY.js +0 -1
  418. package/dist/chunks/settings-Xbq6AaD-.js +0 -20
  419. package/dist/chunks/settingsSync-NCN0a4sc.js +0 -1
  420. package/dist/chunks/setup-uZ0dSekt.js +0 -3
  421. package/dist/chunks/sinks-C7q46rvE.js +0 -2
  422. package/dist/chunks/sinks-D3bXeHlQ.js +0 -1
  423. package/dist/chunks/skillChangeDetector-C1EJ7rUL.js +0 -1
  424. package/dist/chunks/skillSearchPanel-mpaC62y4.js +0 -21
  425. package/dist/chunks/startupProfiler-BaiXZ9tr.js +0 -1
  426. package/dist/chunks/state-B4HwLt8i.js +0 -1
  427. package/dist/chunks/state-Bs5xweDL.js +0 -1
  428. package/dist/chunks/statusNoticeHelpers-DMqRGFOh.js +0 -1
  429. package/dist/chunks/switcher-B2CYzCC_.js +0 -1
  430. package/dist/chunks/syncCache-By_-buUC.js +0 -1
  431. package/dist/chunks/teleport-mdnhIZBj.js +0 -1
  432. package/dist/chunks/toolPool-Di30gn_Y.js +0 -1
  433. package/dist/chunks/trustedDevice-CupLMpO8.js +0 -1
  434. package/dist/chunks/trustedDevice-j1u2TG5U.js +0 -1
  435. package/dist/chunks/udsClient-Cm3HqYUu.js +0 -1
  436. package/dist/chunks/updateCCB-BlUAU2Vp.js +0 -11
  437. package/dist/chunks/useMainLoopModel-ylPQNj7Z.js +0 -1
  438. package/dist/chunks/useManagePlugins-BbWJNLe8.js +0 -1
  439. package/dist/chunks/useSettingsErrors-DKh4rkGi.js +0 -1
  440. package/dist/chunks/util-D-X8i5Z2.js +0 -1
  441. package/dist/chunks/validatePlugin-DSw08u76.js +0 -1
  442. package/dist/chunks/windowsPaths-1mgenSWa.js +0 -1
  443. package/dist/chunks/windowsPaths-BVztIhXM.js +0 -1
  444. package/dist/chunks/workerRegistry-DdOYjLm3.js +0 -6
  445. package/dist/chunks/worktree-BX1ULzrw.js +0 -1
@@ -1,14 +0,0 @@
1
- import{n as e,t}from"./defineProperty-C-QyHrDq.js";import{Ar as n,Au as r,Ji as i,Nf as a,Pf as o,U as s,Ui as c,Ux as l,W as u,dc as d,dl as f,fc as p,fl as m,hr as h,i as g,ku as _,o as ee,zx as te}from"./loadAgentsDir-CKSb56Gp.js";import{A as v,C as y,M as b,O as x,P as S,b as C,j as w,l as ne,m as T,p as E,v as D,w as O}from"./external-CEp-aPkt.js";import{r as re}from"./lazySchema-B4D4qJVE.js";import{Hn as ie,Kt as k,br as ae,gt as oe,lr as A,tt as se,yr as ce}from"./state-Bs5xweDL.js";import{f as le,g as ue}from"./settings-Xbq6AaD-.js";import{h as de,r as fe}from"./config-D4G8_MqJ.js";import{l as pe,p as me,r as he}from"./sessionStoragePortable-JZnGwqUM.js";import{_ as ge,u as _e}from"./model-C2e73CJD.js";import{bn as ve,yn as ye}from"./prompt-CybUvG8G.js";import{n as be,r as xe}from"./managedEnv-Cl7YbYzf.js";import{t as Se}from"./QueryEngine-J6ElcO16.js";import{n as Ce,t as we}from"./modelOptions-efCGKnXT.js";import{dirname as Te}from"node:path";import{randomUUID as j}from"node:crypto";import{Readable as Ee,Writable as De}from"node:stream";import{unlink as Oe}from"node:fs/promises";import*as M from"node:path/posix";import{isAbsolute as ke,resolve as Ae}from"node:path/posix";re();var N={authenticate:`authenticate`,document_did_change:`document/didChange`,document_did_close:`document/didClose`,document_did_focus:`document/didFocus`,document_did_open:`document/didOpen`,document_did_save:`document/didSave`,initialize:`initialize`,logout:`logout`,nes_accept:`nes/accept`,nes_close:`nes/close`,nes_reject:`nes/reject`,nes_start:`nes/start`,nes_suggest:`nes/suggest`,session_cancel:`session/cancel`,session_close:`session/close`,session_fork:`session/fork`,session_list:`session/list`,session_load:`session/load`,session_new:`session/new`,session_prompt:`session/prompt`,session_resume:`session/resume`,session_set_config_option:`session/set_config_option`,session_set_mode:`session/set_mode`,session_set_model:`session/set_model`},P={elicitation_complete:`elicitation/complete`,elicitation_create:`elicitation/create`,fs_read_text_file:`fs/read_text_file`,fs_write_text_file:`fs/write_text_file`,session_request_permission:`session/request_permission`,session_update:`session/update`,terminal_create:`terminal/create`,terminal_kill:`terminal/kill`,terminal_output:`terminal/output`,terminal_release:`terminal/release`,terminal_wait_for_exit:`terminal/wait_for_exit`},je=O({_meta:x(v(),b()).nullish(),terminal:T().optional().default(!1)}),Me=O({_meta:x(v(),b()).nullish(),label:v().nullish(),name:v(),optional:T().optional().default(!1),secret:T().optional().default(!0)}),Ne=O({_meta:x(v(),b()).nullish(),description:v().nullish(),id:v(),name:v()}),Pe=O({_meta:x(v(),b()).nullish(),description:v().nullish(),id:v(),link:v().nullish(),name:v(),vars:E(Me)}),Fe=O({_meta:x(v(),b()).nullish(),args:E(v()).optional(),description:v().nullish(),env:x(v(),v()).optional(),id:v(),name:v()}),Ie=w([Pe.and(O({type:C(`env_var`)})),Fe.and(O({type:C(`terminal`)})),Ne]),Le=O({_meta:x(v(),b()).nullish(),methodId:v()}),Re=O({_meta:x(v(),b()).nullish()}),ze=O({_meta:x(v(),b()).nullish(),blob:v(),mimeType:v().nullish(),uri:v()}),Be=O({default:T().nullish(),description:v().nullish(),title:v().nullish()}),Ve=O({_meta:x(v(),b()).nullish()}),He=O({_meta:x(v(),b()).nullish()}),Ue=O({amount:y(),currency:v()}),We=O({_meta:x(v(),b()).nullish(),terminalId:v()}),Ge=O({_meta:x(v(),b()).nullish(),newText:v(),oldText:v().nullish(),path:v()}),Ke=w([v(),y(),y(),T(),E(v())]),qe=D(w([O({content:x(v(),Ke).nullish()}).and(O({action:C(`accept`)})),O({action:C(`decline`)}),O({action:C(`cancel`)})]),O({_meta:x(v(),b()).nullish()})),Je=O({_meta:x(v(),b()).nullish()}),Ye=v(),Xe=O({_meta:x(v(),b()).nullish(),elicitationId:Ye}),Ze=C(`object`),Qe=C(`string`),$e=O({_meta:x(v(),b()).nullish()}),et=O({_meta:x(v(),b()).nullish(),form:Je.nullish(),url:$e.nullish()}),tt=O({const:v(),title:v()}),nt=O({_meta:x(v(),b()).nullish(),name:v(),value:v()}),rt=O({code:w([C(-32700),C(-32600),C(-32601),C(-32602),C(-32603),C(-32800),C(-32e3),C(-32002),C(-32042),y().int().min(-2147483648,{message:`Invalid value: Expected int32 to be >= -2147483648`}).max(2147483647,{message:`Invalid value: Expected int32 to be <= 2147483647`})]),data:b().optional(),message:v()}),it=b(),at=b(),ot=b(),st=O({_meta:x(v(),b()).nullish(),readTextFile:T().optional().default(!1),writeTextFile:T().optional().default(!1)}),ct=O({_meta:x(v(),b()).nullish(),name:v(),value:v()}),lt=O({_meta:x(v(),b()).nullish(),name:v(),title:v().nullish(),version:v()}),ut=O({default:y().nullish(),description:v().nullish(),maximum:y().nullish(),minimum:y().nullish(),title:v().nullish()}),dt=O({_meta:x(v(),b()).nullish()}),ft=O({_meta:x(v(),b()).nullish(),additionalDirectories:E(v()).optional(),cursor:v().nullish(),cwd:v().nullish()}),pt=O({_meta:x(v(),b()).nullish()}),mt=O({_meta:x(v(),b()).nullish(),logout:pt.nullish()}),ht=O({_meta:x(v(),b()).nullish()}),gt=O({_meta:x(v(),b()).nullish()}),_t=O({_meta:x(v(),b()).nullish(),http:T().optional().default(!1),sse:T().optional().default(!1)}),vt=O({_meta:x(v(),b()).nullish(),headers:E(ct),name:v(),url:v()}),yt=O({_meta:x(v(),b()).nullish(),headers:E(ct),name:v(),url:v()}),bt=O({_meta:x(v(),b()).nullish(),args:E(v()),command:v(),env:E(nt),name:v()}),F=w([vt.and(O({type:C(`http`)})),yt.and(O({type:C(`sse`)})),bt]),xt=v(),St=O({_meta:x(v(),b()).nullish(),description:v().nullish(),modelId:xt,name:v()}),Ct=w([C(`error`),C(`warning`),C(`information`),C(`hint`)]),wt=O({_meta:x(v(),b()).nullish()}),Tt=O({_meta:x(v(),b()).nullish()}),Et=O({_meta:x(v(),b()).nullish()}),Dt=O({_meta:x(v(),b()).nullish()}),Ot=O({_meta:x(v(),b()).nullish()}),kt=O({_meta:x(v(),b()).nullish(),maxCount:y().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish()}),At=O({diff:v(),uri:v()}),jt=O({endLine:y().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}),startLine:y().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}),text:v()}),Mt=O({_meta:x(v(),b()).nullish()}),Nt=O({_meta:x(v(),b()).nullish()}),Pt=O({languageId:v(),text:v(),uri:v()}),Ft=O({_meta:x(v(),b()).nullish(),maxCount:y().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish()}),It=w([C(`rejected`),C(`ignored`),C(`replaced`),C(`cancelled`)]),Lt=O({excerpts:E(jt),uri:v()}),Rt=O({_meta:x(v(),b()).nullish()}),zt=O({_meta:x(v(),b()).nullish()}),Bt=O({name:v(),owner:v(),remoteUrl:v()}),Vt=O({_meta:x(v(),b()).nullish()}),Ht=O({_meta:x(v(),b()).nullish(),jump:Mt.nullish(),rename:zt.nullish(),searchAndReplace:Vt.nullish()}),Ut=O({id:v(),isRegex:T().nullish(),replace:v(),search:v(),uri:v()}),Wt=w([C(`automatic`),C(`diagnostic`),C(`manual`)]),Gt=O({_meta:x(v(),b()).nullish(),maxCount:y().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish()}),Kt=O({_meta:x(v(),b()).nullish(),diagnostics:wt.nullish(),editHistory:kt.nullish(),openFiles:Nt.nullish(),recentFiles:Ft.nullish(),relatedSnippets:Rt.nullish(),userActions:Gt.nullish()}),qt=O({_meta:x(v(),b()).nullish(),additionalDirectories:E(v()).optional(),cwd:v(),mcpServers:E(F)}),Jt=O({default:y().nullish(),description:v().nullish(),maximum:y().nullish(),minimum:y().nullish(),title:v().nullish()}),Yt=v(),Xt=w([C(`allow_once`),C(`allow_always`),C(`reject_once`),C(`reject_always`)]),Zt=O({_meta:x(v(),b()).nullish(),kind:Xt,name:v(),optionId:Yt}),Qt=w([C(`high`),C(`medium`),C(`low`)]),$t=w([C(`pending`),C(`in_progress`),C(`completed`)]),en=O({_meta:x(v(),b()).nullish(),content:v(),priority:Qt,status:$t}),tn=O({_meta:x(v(),b()).nullish(),entries:E(en)}),I=O({character:y().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}),line:y().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`})}),nn=O({id:v(),position:I,uri:v()}),rn=O({id:v(),newName:v(),position:I,uri:v()}),an=O({action:v(),position:I,timestampMs:y(),uri:v()}),on=w([C(`utf-16`),C(`utf-32`),C(`utf-8`)]),sn=O({_meta:x(v(),b()).nullish(),auth:je.optional().default({terminal:!1}),elicitation:et.nullish(),fs:st.optional().default({readTextFile:!1,writeTextFile:!1}),nes:Ht.nullish(),positionEncodings:E(on).optional(),terminal:T().optional().default(!1)}),cn=O({_meta:x(v(),b()).nullish(),audio:T().optional().default(!1),embeddedContext:T().optional().default(!1),image:T().optional().default(!1)}),ln=y().int().gte(0).lte(65535),un=O({_meta:x(v(),b()).nullish(),clientCapabilities:sn.optional().default({auth:{terminal:!1},fs:{readTextFile:!1,writeTextFile:!1},terminal:!1}),clientInfo:lt.nullish(),protocolVersion:ln}),L=O({end:I,start:I}),dn=O({message:v(),range:L,severity:Ct,uri:v()}),fn=O({languageId:v(),lastFocusedMs:y().nullish(),uri:v(),visibleRange:L.nullish()}),pn=O({_meta:x(v(),b()).nullish(),diagnostics:E(dn).nullish(),editHistory:E(At).nullish(),openFiles:E(fn).nullish(),recentFiles:E(Pt).nullish(),relatedSnippets:E(Lt).nullish(),userActions:E(an).nullish()}),mn=O({newText:v(),range:L}),hn=w([O({cursorPosition:I.nullish(),edits:E(mn),id:v(),uri:v()}).and(O({kind:C(`edit`)})),nn.and(O({kind:C(`jump`)})),rn.and(O({kind:C(`rename`)})),Ut.and(O({kind:C(`searchAndReplace`)}))]),gn=O({_meta:x(v(),b()).nullish(),content:v()}),_n=O({_meta:x(v(),b()).nullish()}),R=w([y(),v()]).nullable();O({_meta:x(v(),b()).nullish(),requestId:R});var vn=O({requestId:R}),yn=ne([`assistant`,`user`]),z=O({_meta:x(v(),b()).nullish(),audience:E(yn).nullish(),lastModified:v().nullish(),priority:y().nullish()}),bn=O({_meta:x(v(),b()).nullish(),annotations:z.nullish(),data:v(),mimeType:v()}),xn=O({_meta:x(v(),b()).nullish(),annotations:z.nullish(),data:v(),mimeType:v(),uri:v().nullish()}),Sn=O({_meta:x(v(),b()).nullish(),annotations:z.nullish(),description:v().nullish(),mimeType:v().nullish(),name:v(),size:y().nullish(),title:v().nullish(),uri:v()}),Cn=O({_meta:x(v(),b()).nullish(),optionId:Yt}),wn=w([O({outcome:C(`cancelled`)}),Cn.and(O({outcome:C(`selected`)}))]),Tn=O({_meta:x(v(),b()).nullish(),outcome:wn}),En=O({_meta:x(v(),b()).nullish()}),Dn=O({_meta:x(v(),b()).nullish()}),On=O({currentValue:T()}),kn=v(),An=v(),jn=w([C(`mode`),C(`model`),C(`thought_level`),v()]),Mn=v(),Nn=O({_meta:x(v(),b()).nullish(),description:v().nullish(),name:v(),value:Mn}),Pn=O({_meta:x(v(),b()).nullish(),group:kn,name:v(),options:E(Nn)}),B=D(w([O({currentValue:Mn,options:w([E(Nn),E(Pn)])}).and(O({type:C(`select`)})),On.and(O({type:C(`boolean`)}))]),O({_meta:x(v(),b()).nullish(),category:jn.nullish(),description:v().nullish(),id:An,name:v()})),Fn=O({_meta:x(v(),b()).nullish(),configOptions:E(B)}),In=O({_meta:x(v(),b()).nullish()}),V=v(),Ln=O({_meta:x(v(),b()).nullish(),id:v(),sessionId:V}),Rn=O({_meta:x(v(),b()).nullish(),sessionId:V}),zn=O({_meta:x(v(),b()).nullish(),sessionId:V}),Bn=O({_meta:x(v(),b()).nullish(),sessionId:V}),Vn=O({_meta:x(v(),b()).nullish(),args:E(v()).optional(),command:v(),cwd:v().nullish(),env:E(nt).optional(),outputByteLimit:y().nullish(),sessionId:V}),Hn=O({_meta:x(v(),b()).nullish(),sessionId:V,uri:v()}),Un=O({_meta:x(v(),b()).nullish(),position:I,sessionId:V,uri:v(),version:y(),visibleRange:L}),Wn=O({_meta:x(v(),b()).nullish(),languageId:v(),sessionId:V,text:v(),uri:v(),version:y()}),Gn=O({_meta:x(v(),b()).nullish(),sessionId:V,uri:v()}),Kn=O({_meta:x(v(),b()).nullish(),additionalDirectories:E(v()).optional(),cwd:v(),mcpServers:E(F).optional(),sessionId:V}),qn=O({_meta:x(v(),b()).nullish(),sessionId:V,terminalId:v()}),Jn=O({_meta:x(v(),b()).nullish(),additionalDirectories:E(v()).optional(),cwd:v(),mcpServers:E(F),sessionId:V}),Yn=O({_meta:x(v(),b()).nullish(),limit:y().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),line:y().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),path:v(),sessionId:V}),Xn=O({_meta:x(v(),b()).nullish(),id:v(),reason:It.nullish(),sessionId:V}),Zn=O({_meta:x(v(),b()).nullish(),sessionId:V,terminalId:v()}),Qn=O({_meta:x(v(),b()).nullish(),additionalDirectories:E(v()).optional(),cwd:v(),mcpServers:E(F).optional(),sessionId:V}),$n=O({_meta:x(v(),b()).nullish(),additionalDirectories:E(v()).optional(),cwd:v(),sessionId:V,title:v().nullish(),updatedAt:v().nullish()}),er=O({_meta:x(v(),b()).nullish(),nextCursor:v().nullish(),sessions:E($n)}),tr=O({_meta:x(v(),b()).nullish(),title:v().nullish(),updatedAt:v().nullish()}),nr=O({_meta:x(v(),b()).nullish()}),H=v(),rr=O({_meta:x(v(),b()).nullish(),currentModeId:H}),ir=O({_meta:x(v(),b()).nullish(),description:v().nullish(),id:H,name:v()}),U=O({_meta:x(v(),b()).nullish(),availableModes:E(ir),currentModeId:H}),W=O({_meta:x(v(),b()).nullish(),availableModels:E(St),currentModelId:xt}),ar=O({_meta:x(v(),b()).nullish(),configOptions:E(B).nullish(),models:W.nullish(),modes:U.nullish(),sessionId:V}),or=O({_meta:x(v(),b()).nullish(),configOptions:E(B).nullish(),models:W.nullish(),modes:U.nullish()}),sr=O({_meta:x(v(),b()).nullish(),configOptions:E(B).nullish(),models:W.nullish(),modes:U.nullish(),sessionId:V}),cr=O({_meta:x(v(),b()).nullish(),configOptions:E(B).nullish(),models:W.nullish(),modes:U.nullish()}),lr=O({_meta:x(v(),b()).nullish()}),ur=O({_meta:x(v(),b()).nullish(),additionalDirectories:En.nullish(),close:Dn.nullish(),fork:In.nullish(),list:nr.nullish(),resume:lr.nullish()}),dr=D(w([O({type:C(`boolean`),value:T()}),O({value:Mn})]),O({_meta:x(v(),b()).nullish(),configId:An,sessionId:V})),fr=O({_meta:x(v(),b()).nullish(),configOptions:E(B)}),pr=O({_meta:x(v(),b()).nullish(),modeId:H,sessionId:V}),mr=O({_meta:x(v(),b()).nullish()}),hr=O({_meta:x(v(),b()).nullish(),modelId:xt,sessionId:V}),gr=O({_meta:x(v(),b()).nullish()}),_r=O({_meta:x(v(),b()).nullish(),sessionId:V}),vr=w([C(`end_turn`),C(`max_tokens`),C(`max_turn_requests`),C(`refusal`),C(`cancelled`)]),yr=w([C(`email`),C(`uri`),C(`date`),C(`date-time`)]),br=O({default:v().nullish(),description:v().nullish(),enum:E(v()).nullish(),format:yr.nullish(),maxLength:y().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),minLength:y().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),oneOf:E(tt).nullish(),pattern:v().nullish(),title:v().nullish()}),xr=O({_meta:x(v(),b()).nullish(),context:pn.nullish(),position:I,selection:L.nullish(),sessionId:V,triggerKind:Wt,uri:v(),version:y()}),Sr=O({_meta:x(v(),b()).nullish(),suggestions:E(hn)}),Cr=O({_meta:x(v(),b()).nullish(),terminalId:v()}),wr=O({_meta:x(v(),b()).nullish(),exitCode:y().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),signal:v().nullish()}),Tr=O({_meta:x(v(),b()).nullish(),sessionId:V,terminalId:v()}),Er=O({_meta:x(v(),b()).nullish(),exitStatus:wr.nullish(),output:v(),truncated:T()}),Dr=O({_meta:x(v(),b()).nullish(),annotations:z.nullish(),text:v()}),Or=O({range:L.nullish(),text:v()}),kr=O({_meta:x(v(),b()).nullish(),contentChanges:E(Or),sessionId:V,uri:v(),version:y()});O({method:v(),params:w([Rn,Wn,kr,Hn,Gn,Un,Ln,Xn,it]).nullish()});var Ar=w([C(`full`),C(`incremental`)]),jr=O({_meta:x(v(),b()).nullish(),syncKind:Ar}),Mr=O({_meta:x(v(),b()).nullish(),didChange:jr.nullish(),didClose:Tt.nullish(),didFocus:Et.nullish(),didOpen:Dt.nullish(),didSave:Ot.nullish()}),Nr=O({_meta:x(v(),b()).nullish(),document:Mr.nullish()}),Pr=O({_meta:x(v(),b()).nullish(),context:Kt.nullish(),events:Nr.nullish()}),Fr=O({_meta:x(v(),b()).nullish(),auth:mt.optional().default({}),loadSession:T().optional().default(!1),mcpCapabilities:_t.optional().default({http:!1,sse:!1}),nes:Pr.nullish(),positionEncoding:on.nullish(),promptCapabilities:cn.optional().default({audio:!1,embeddedContext:!1,image:!1}),sessionCapabilities:ur.optional().default({})}),Ir=O({_meta:x(v(),b()).nullish(),agentCapabilities:Fr.optional().default({auth:{},loadSession:!1,mcpCapabilities:{http:!1,sse:!1},promptCapabilities:{audio:!1,embeddedContext:!1,image:!1},sessionCapabilities:{}}),agentInfo:lt.nullish(),authMethods:E(Ie).optional().default([]),protocolVersion:ln}),Lr=w([O({_meta:x(v(),b()).nullish(),mimeType:v().nullish(),text:v(),uri:v()}),ze]),Rr=O({_meta:x(v(),b()).nullish(),annotations:z.nullish(),resource:Lr}),zr=w([Dr.and(O({type:C(`text`)})),xn.and(O({type:C(`image`)})),bn.and(O({type:C(`audio`)})),Sn.and(O({type:C(`resource_link`)})),Rr.and(O({type:C(`resource`)}))]),Br=O({_meta:x(v(),b()).nullish(),content:zr}),G=O({_meta:x(v(),b()).nullish(),content:zr,messageId:v().nullish()}),Vr=O({_meta:x(v(),b()).nullish(),messageId:v().nullish(),prompt:E(zr),sessionId:V}),Hr=O({anyOf:E(tt)}),Ur=w([Br.and(O({type:C(`content`)})),Ge.and(O({type:C(`diff`)})),Cr.and(O({type:C(`terminal`)}))]),Wr=v(),Gr=O({sessionId:V,toolCallId:Wr.nullish()}),Kr=D(w([Gr,vn]),O({elicitationId:Ye,url:v().url()})),qr=O({_meta:x(v(),b()).nullish(),line:y().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),path:v()}),Jr=w([C(`pending`),C(`in_progress`),C(`completed`),C(`failed`)]),Yr=w([C(`read`),C(`edit`),C(`delete`),C(`move`),C(`search`),C(`execute`),C(`think`),C(`fetch`),C(`switch_mode`),C(`other`)]),Xr=O({_meta:x(v(),b()).nullish(),content:E(Ur).optional(),kind:Yr.optional(),locations:E(qr).optional(),rawInput:b().optional(),rawOutput:b().optional(),status:Jr.optional(),title:v(),toolCallId:Wr}),Zr=O({_meta:x(v(),b()).nullish(),content:E(Ur).nullish(),kind:Yr.nullish(),locations:E(qr).nullish(),rawInput:b().optional(),rawOutput:b().optional(),status:Jr.nullish(),title:v().nullish(),toolCallId:Wr}),Qr=O({_meta:x(v(),b()).nullish(),options:E(Zt),sessionId:V,toolCall:Zr}),$r=O({_meta:x(v(),b()).nullish(),hint:v()}),ei=O({_meta:x(v(),b()).nullish(),description:v(),input:$r.nullish(),name:v()}),ti=O({_meta:x(v(),b()).nullish(),availableCommands:E(ei)}),ni=w([O({enum:E(v()),type:Qe}),Hr]),ri=O({default:E(v()).nullish(),description:v().nullish(),items:ni,maxItems:y().nullish(),minItems:y().nullish(),title:v().nullish()}),ii=w([br.and(O({type:C(`string`)})),Jt.and(O({type:C(`number`)})),ut.and(O({type:C(`integer`)})),Be.and(O({type:C(`boolean`)})),ri.and(O({type:C(`array`)}))]),ai=O({description:v().nullish(),properties:x(v(),ii).optional().default({}),required:E(v()).nullish(),title:v().nullish(),type:Ze.optional().default(`object`)}),oi=D(w([D(w([Gr,vn]),O({requestedSchema:ai})).and(O({mode:C(`form`)})),Kr.and(O({mode:C(`url`)}))]),O({_meta:x(v(),b()).nullish(),message:v()})),si=O({cachedReadTokens:y().nullish(),cachedWriteTokens:y().nullish(),inputTokens:y(),outputTokens:y(),thoughtTokens:y().nullish(),totalTokens:y()});w([O({id:R,result:w([Ir,Re,gt,sr,or,er,ar,cr,He,mr,fr,O({_meta:x(v(),b()).nullish(),stopReason:vr,usage:si.nullish(),userMessageId:v().nullish()}),gr,_r,Sr,Ve,ot])}),O({error:rt,id:R})]);var ci=O({_meta:x(v(),b()).nullish(),cost:Ue.nullish(),size:y(),used:y()}),li=w([G.and(O({sessionUpdate:C(`user_message_chunk`)})),G.and(O({sessionUpdate:C(`agent_message_chunk`)})),G.and(O({sessionUpdate:C(`agent_thought_chunk`)})),Xr.and(O({sessionUpdate:C(`tool_call`)})),Zr.and(O({sessionUpdate:C(`tool_call_update`)})),tn.and(O({sessionUpdate:C(`plan`)})),ti.and(O({sessionUpdate:C(`available_commands_update`)})),rr.and(O({sessionUpdate:C(`current_mode_update`)})),Fn.and(O({sessionUpdate:C(`config_option_update`)})),tr.and(O({sessionUpdate:C(`session_info_update`)})),ci.and(O({sessionUpdate:C(`usage_update`)}))]),ui=O({_meta:x(v(),b()).nullish(),sessionId:V,update:li});O({method:v(),params:w([ui,Xe,it]).nullish()});var di=O({_meta:x(v(),b()).nullish(),sessionId:V,terminalId:v()}),fi=O({_meta:x(v(),b()).nullish(),exitCode:y().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),signal:v().nullish()}),pi=O({name:v(),uri:v()}),mi=O({_meta:x(v(),b()).nullish(),repository:Bt.nullish(),workspaceFolders:E(pi).nullish(),workspaceUri:v().nullish()});O({id:R,method:v(),params:w([un,Le,ht,qt,Jn,ft,Kn,Qn,Bn,pr,dr,Vr,hr,mi,xr,zn,at]).nullish()});var hi=O({_meta:x(v(),b()).nullish(),content:v(),path:v(),sessionId:V});O({id:R,method:v(),params:w([hi,Yn,Qr,Vn,Tr,Zn,di,qn,oi,at]).nullish()}),w([O({id:R,result:w([O({_meta:x(v(),b()).nullish()}),gn,Tn,We,Er,_n,fi,dt,qe,ot])}),O({error:rt,id:R})]),e();function gi(e,t){let n=new TextEncoder,r=new TextDecoder;return{readable:new ReadableStream({async start(e){let n=``,i=t.getReader();try{for(;;){let{value:t,done:a}=await i.read();if(a){n+=r.decode();break}if(!t)continue;n+=r.decode(t,{stream:!0});let o=n.split(`
2
- `);n=o.pop()||``;for(let t of o){let n=t.trim();if(n)try{let t=JSON.parse(n);e.enqueue(t)}catch(e){console.error(`Failed to parse JSON message:`,n,e)}}}let t=n.trim();if(t)try{let n=JSON.parse(t);e.enqueue(n)}catch(e){console.error(`Failed to parse JSON message:`,t,e)}}catch(t){e.error(t);return}finally{i.releaseLock()}e.close()}}),writable:new WritableStream({async write(t){let r=JSON.stringify(t)+`
3
- `,i=e.getWriter();try{await i.write(n.encode(r))}finally{i.releaseLock()}}})}}re();var _i,vi=class{constructor(e,n){t(this,`connection`,void 0);let r=e(this),i=async(e,t)=>{switch(e){case N.initialize:{let e=un.parse(t);return r.initialize(e)}case N.session_new:{let e=qt.parse(t);return r.newSession(e)}case N.session_load:{if(!r.loadSession)throw K.methodNotFound(e);let n=Jn.parse(t);return r.loadSession(n)}case N.session_list:{if(!r.listSessions)throw K.methodNotFound(e);let n=ft.parse(t);return r.listSessions(n)}case N.session_fork:{if(!r.unstable_forkSession)throw K.methodNotFound(e);let n=Kn.parse(t);return r.unstable_forkSession(n)}case N.session_resume:{if(!r.unstable_resumeSession)throw K.methodNotFound(e);let n=Qn.parse(t);return r.unstable_resumeSession(n)}case N.session_close:{if(!r.unstable_closeSession)throw K.methodNotFound(e);let n=Bn.parse(t);return r.unstable_closeSession(n)}case N.session_set_mode:{if(!r.setSessionMode)throw K.methodNotFound(e);let n=pr.parse(t);return await r.setSessionMode(n)??{}}case N.authenticate:{let e=Le.parse(t);return await r.authenticate(e)??{}}case N.logout:{if(!r.unstable_logout)throw K.methodNotFound(e);let n=ht.parse(t);return await r.unstable_logout(n)??{}}case N.session_prompt:{let e=Vr.parse(t);return r.prompt(e)}case N.session_set_model:{if(!r.unstable_setSessionModel)throw K.methodNotFound(e);let n=hr.parse(t);return await r.unstable_setSessionModel(n)??{}}case N.session_set_config_option:{if(!r.setSessionConfigOption)throw K.methodNotFound(e);let n=dr.parse(t);return r.setSessionConfigOption(n)}case N.nes_start:{if(!r.unstable_startNes)throw K.methodNotFound(e);let n=mi.parse(t);return r.unstable_startNes(n)}case N.nes_suggest:{if(!r.unstable_suggestNes)throw K.methodNotFound(e);let n=xr.parse(t);return r.unstable_suggestNes(n)}case N.nes_close:{if(!r.unstable_closeNes)throw K.methodNotFound(e);let n=zn.parse(t);return await r.unstable_closeNes(n)??{}}default:if(r.extMethod)return r.extMethod(e,t);throw K.methodNotFound(e)}},a=async(e,t)=>{switch(e){case N.session_cancel:{let e=Rn.parse(t);return r.cancel(e)}case N.document_did_open:{if(!r.unstable_didOpenDocument)return;let e=Wn.parse(t);return r.unstable_didOpenDocument(e)}case N.document_did_change:{if(!r.unstable_didChangeDocument)return;let e=kr.parse(t);return r.unstable_didChangeDocument(e)}case N.document_did_close:{if(!r.unstable_didCloseDocument)return;let e=Hn.parse(t);return r.unstable_didCloseDocument(e)}case N.document_did_save:{if(!r.unstable_didSaveDocument)return;let e=Gn.parse(t);return r.unstable_didSaveDocument(e)}case N.document_did_focus:{if(!r.unstable_didFocusDocument)return;let e=Un.parse(t);return r.unstable_didFocusDocument(e)}case N.nes_accept:{if(!r.unstable_acceptNes)return;let e=Ln.parse(t);return r.unstable_acceptNes(e)}case N.nes_reject:{if(!r.unstable_rejectNes)return;let e=Xn.parse(t);return r.unstable_rejectNes(e)}default:if(r.extNotification)return r.extNotification(e,t);throw K.methodNotFound(e)}};this.connection=new bi(i,a,n)}async sessionUpdate(e){return await this.connection.sendNotification(P.session_update,e)}async requestPermission(e){return await this.connection.sendRequest(P.session_request_permission,e)}async readTextFile(e){return await this.connection.sendRequest(P.fs_read_text_file,e)}async writeTextFile(e){return await this.connection.sendRequest(P.fs_write_text_file,e)??{}}async createTerminal(e){return new yi((await this.connection.sendRequest(P.terminal_create,e)).terminalId,e.sessionId,this.connection)}async unstable_createElicitation(e){return await this.connection.sendRequest(P.elicitation_create,e)}async unstable_completeElicitation(e){return await this.connection.sendNotification(P.elicitation_complete,e)}async extMethod(e,t){return await this.connection.sendRequest(e,t)}async extNotification(e,t){return await this.connection.sendNotification(e,t)}get signal(){return this.connection.signal}get closed(){return this.connection.closed}};_i=Symbol.asyncDispose;var yi=class{constructor(e,n,r){t(this,`id`,void 0),t(this,`sessionId`,void 0),t(this,`connection`,void 0),this.id=e,this.sessionId=n,this.connection=r}async currentOutput(){return await this.connection.sendRequest(P.terminal_output,{sessionId:this.sessionId,terminalId:this.id})}async waitForExit(){return await this.connection.sendRequest(P.terminal_wait_for_exit,{sessionId:this.sessionId,terminalId:this.id})}async kill(){return await this.connection.sendRequest(P.terminal_kill,{sessionId:this.sessionId,terminalId:this.id})??{}}async release(){return await this.connection.sendRequest(P.terminal_release,{sessionId:this.sessionId,terminalId:this.id})??{}}async[_i](){await this.release()}},bi=class{constructor(e,n,r){t(this,`pendingResponses`,new Map),t(this,`nextRequestId`,0),t(this,`requestHandler`,void 0),t(this,`notificationHandler`,void 0),t(this,`stream`,void 0),t(this,`writeQueue`,Promise.resolve()),t(this,`abortController`,new AbortController),t(this,`closedPromise`,void 0),this.requestHandler=e,this.notificationHandler=n,this.stream=r,this.closedPromise=new Promise(e=>{this.abortController.signal.addEventListener(`abort`,()=>e())}),this.receive()}get signal(){return this.abortController.signal}get closed(){return this.closedPromise}async receive(){let e;try{let e=this.stream.readable.getReader();try{for(;!this.abortController.signal.aborted;){let{value:t,done:n}=await e.read();if(n)break;if(t)try{this.processMessage(t)}catch(e){console.error(`Unexpected error during message processing:`,t,e),`id`in t&&t.id!==void 0&&this.sendMessage({jsonrpc:`2.0`,id:t.id,error:{code:-32700,message:`Parse error`}})}}}finally{e.releaseLock()}}catch(t){e=t}finally{this.close(e)}}close(e){if(this.abortController.signal.aborted)return;let t=e??Error(`ACP connection closed`);for(let e of this.pendingResponses.values())e.reject(t);this.pendingResponses.clear(),this.abortController.abort(t)}async processMessage(e){if(`method`in e&&`id`in e){let t=await this.tryCallRequestHandler(e.method,e.params);`error`in t&&console.error(`Error handling request`,e,t.error),await this.sendMessage({jsonrpc:`2.0`,id:e.id,...t})}else if(`method`in e){let t=await this.tryCallNotificationHandler(e.method,e.params);`error`in t&&console.error(`Error handling notification`,e,t.error)}else`id`in e?this.handleResponse(e):console.error(`Invalid message`,{message:e})}async tryCallRequestHandler(e,t){try{return{result:await this.requestHandler(e,t)??null}}catch(e){if(e instanceof K)return e.toResult();if(e instanceof S)return K.invalidParams(e.format()).toResult();let t;(e instanceof Error||typeof e==`object`&&e&&`message`in e&&typeof e.message==`string`)&&(t=e.message);try{return K.internalError(t?JSON.parse(t):{}).toResult()}catch{return K.internalError({details:t}).toResult()}}}async tryCallNotificationHandler(e,t){try{return await this.notificationHandler(e,t),{result:null}}catch(e){if(e instanceof K)return e.toResult();if(e instanceof S)return K.invalidParams(e.format()).toResult();let t;(e instanceof Error||typeof e==`object`&&e&&`message`in e&&typeof e.message==`string`)&&(t=e.message);try{return K.internalError(t?JSON.parse(t):{}).toResult()}catch{return K.internalError({details:t}).toResult()}}}handleResponse(e){let t=this.pendingResponses.get(e.id);if(t){if(`result`in e)t.resolve(e.result);else if(`error`in e){let{code:n,message:r,data:i}=e.error;t.reject(new K(n,r,i))}this.pendingResponses.delete(e.id)}else console.error(`Got response to unknown request`,e.id)}sendRequest(e,t){this.throwIfClosed();let n=this.nextRequestId++,r=new Promise((e,t)=>{this.pendingResponses.set(n,{resolve:e,reject:t})});return r.catch(()=>{}),this.sendMessage({jsonrpc:`2.0`,id:n,method:e,params:t}),r}async sendNotification(e,t){this.throwIfClosed(),await this.sendMessage({jsonrpc:`2.0`,method:e,params:t})}throwIfClosed(){if(this.abortController.signal.aborted)throw this.abortController.signal.reason??Error(`ACP connection closed`)}async sendMessage(e){return this.writeQueue=this.writeQueue.then(async()=>{let t=this.stream.writable.getWriter();try{await t.write(e)}finally{t.releaseLock()}}).catch(e=>{this.close(e)}),this.writeQueue}},K=class e extends Error{constructor(e,n,r){super(n),t(this,`code`,void 0),t(this,`data`,void 0),this.code=e,this.name=`RequestError`,this.data=r}static parseError(t,n){return new e(-32700,`Parse error${n?`: ${n}`:``}`,t)}static invalidRequest(t,n){return new e(-32600,`Invalid request${n?`: ${n}`:``}`,t)}static methodNotFound(t){return new e(-32601,`"Method not found": ${t}`,{method:t})}static invalidParams(t,n){return new e(-32602,`Invalid params${n?`: ${n}`:``}`,t)}static internalError(t,n){return new e(-32603,`Internal error${n?`: ${n}`:``}`,t)}static authRequired(t,n){return new e(-32e3,`Authentication required${n?`: ${n}`:``}`,t)}static resourceNotFound(t){return new e(-32002,`Resource not found${t?`: ${t}`:``}`,t&&{uri:t})}toResult(){return{error:{code:this.code,message:this.message,data:this.data}}}toErrorResponse(){return{code:this.code,message:this.message,data:this.data}}};ce(),k(),ue(),ve(),de(),l(),m(),p(),i(),u(),ee(),xe();function q(e,t){if(e)return t?ke(e)?e:Ae(t,e):e}var xi=!(typeof process.geteuid==`function`?process.geteuid()===0:typeof process.getuid==`function`&&process.getuid()===0)||!!process.env.IS_SANDBOX,Si={auto:`auto`,default:`default`,acceptedits:`acceptEdits`,dontask:`dontAsk`,plan:`plan`,bypasspermissions:`bypassPermissions`,bypass:`bypassPermissions`};function Ci(e,t=`permissions.defaultMode`){if(e===void 0)return`default`;if(typeof e!=`string`)throw Error(`Invalid ${t}: expected a string.`);let n=e.trim().toLowerCase();if(n===``)throw Error(`Invalid ${t}: expected a non-empty string.`);let r=Si[n];if(!r)throw Error(`Invalid ${t}: ${e}.`);if(r===`bypassPermissions`&&!xi)throw Error(`Invalid ${t}: bypassPermissions is not available when running as root.`);return r}function wi(e){let t=[...e.mcpServers??[]].sort((e,t)=>e.name.localeCompare(t.name));return JSON.stringify({cwd:e.cwd,mcpServers:t})}var Ti=256;function Ei(e){let t=e.replace(/[\r\n]+/g,` `).replace(/\s+/g,` `).trim();return t.length<=Ti?t:t.slice(0,Ti-1)+`…`}function J(e,t){if(!t)return e;let n=M.resolve(t),r=M.resolve(e);return r.startsWith(n+M.sep)||r===n?M.relative(n,r):e}function Di(e){let t="```";for(let n of e.matchAll(/^```+/gm)??[])for(;n[0].length>=t.length;)t+="`";return t+`
4
- `+e+(e.endsWith(`
5
- `)?``:`
6
- `)+t}function Y(e,t=!1,n){let r=e.name,i=e.input;switch(r){case`Agent`:case`Task`:{let e=i?.description??`Task`,t=i?.prompt;return{title:e,kind:`think`,content:t?[{type:`content`,content:{type:`text`,text:t}}]:[]}}case`Bash`:{let e=i?.command??`Terminal`,t=i?.description;return{title:e,kind:`execute`,content:t?[{type:`content`,content:{type:`text`,text:t}}]:[]}}case`Read`:{let e=i?.file_path,t=e??`File`,r=i?.offset,a=i?.limit,o=``;a&&a>0?o=` (${r??1} - ${(r??1)+a-1})`:r&&(o=` (from line ${r})`);let s=t?J(t,n):`File`,c=q(e,n);return{title:`Read ${s}${o}`,kind:`read`,locations:c?[{path:c,line:r??1}]:[],content:[]}}case`Write`:{let e=i?.file_path??``,t=i?.content??``,r=e?J(e,n):void 0,a=q(e,n);return{title:r?`Write ${r}`:`Write`,kind:`edit`,content:a?[{type:`diff`,path:a,oldText:null,newText:t}]:[{type:`content`,content:{type:`text`,text:t}}],locations:a?[{path:a}]:[]}}case`Edit`:{let e=i?.file_path??``,t=i?.old_string??``,r=i?.new_string??``,a=e?J(e,n):void 0,o=q(e,n);return{title:a?`Edit ${a}`:`Edit`,kind:`edit`,content:o?[{type:`diff`,path:o,oldText:t||null,newText:r}]:[],locations:o?[{path:o}]:[]}}case`Glob`:{let e=i?.path??``,t=i?.pattern??``,r=q(e,n),a=`Find`;return e&&(a+=` \`${e}\``),t&&(a+=` \`${t}\``),{title:a,kind:`search`,content:[],locations:r?[{path:r}]:[]}}case`Grep`:{let e=i?.pattern??``,t=i?.path??``,n=`grep`;return i?.[`-i`]&&(n+=` -i`),i?.[`-n`]&&(n+=` -n`),i?.[`-A`]!==void 0&&(n+=` -A ${i[`-A`]}`),i?.[`-B`]!==void 0&&(n+=` -B ${i[`-B`]}`),i?.[`-C`]!==void 0&&(n+=` -C ${i[`-C`]}`),i?.output_mode===`files_with_matches`?n+=` -l`:i?.output_mode===`count`&&(n+=` -c`),i?.head_limit!==void 0&&(n+=` | head -${i.head_limit}`),i?.glob&&(n+=` --include="${i.glob}"`),i?.type&&(n+=` --type=${i.type}`),i?.multiline&&(n+=` -P`),e&&(n+=` "${e}"`),t&&(n+=` ${t}`),{title:n,kind:`search`,content:[]}}case`TodoWrite`:{let e=i?.todos;return{title:Array.isArray(e)?`Update TODOs: ${e.map(e=>e.content).join(`, `)}`:`Update TODOs`,kind:`think`,content:[]}}case`ExitPlanMode`:{let e=i?.plan;return{title:`Ready to code?`,kind:`switch_mode`,content:e?[{type:`content`,content:{type:`text`,text:e}}]:[]}}default:return{title:r||`Unknown Tool`,kind:`other`,content:[]}}}function Oi(e,t){return Array.isArray(e)&&e.length>0?{content:e.map(e=>({type:`content`,content:ki(e,t)}))}:typeof e==`string`&&e.length>0?{content:[{type:`content`,content:{type:`text`,text:t?`\`\`\`\n${e}\n\`\`\``:e}}]}:{}}function ki(e,t){let n=e=>({type:`text`,text:t?`\`\`\`\n${e}\n\`\`\``:e});switch(e.type){case`text`:{let n=e.text;return{type:`text`,text:t?`\`\`\`\n${n}\n\`\`\``:n}}case`image`:{let t=e.source;return t?.type===`base64`?{type:`image`,data:t.data,mimeType:t.media_type}:n(t?.type===`url`?`[image: ${t.url}]`:`[image: file reference]`)}case`resource_link`:{let t=e.uri;return{type:`resource_link`,uri:t,name:e.name??t,mimeType:e.mimeType}}case`resource`:{let t=e.resource;return{type:`resource`,resource:{uri:t?.uri??``,mimeType:t?.mimeType,...typeof t?.text==`string`?{text:t.text}:{},...typeof t?.blob==`string`?{blob:t.blob}:{}}}}case`tool_reference`:return n(`Tool: ${e.tool_name}`);case`tool_search_tool_search_result`:{let t=e.tool_references;return n(`Tools found: ${t?.map(e=>e.tool_name).join(`, `)||`none`}`)}case`tool_search_tool_result_error`:return n(`Error: ${e.error_code}${e.error_message?` - ${e.error_message}`:``}`);case`web_fetch_result`:return n(`Fetched: ${e.url}`);case`web_fetch_tool_result_error`:return n(`Error: ${e.error_code}`);case`code_execution_result`:case`bash_code_execution_result`:return n(`Output: ${e.stdout||e.stderr||``}`);case`code_execution_tool_result_error`:case`bash_code_execution_tool_result_error`:return n(`Error: ${e.error_code}`);case`text_editor_code_execution_view_result`:return n(e.content);case`text_editor_code_execution_create_result`:return n(e.is_file_update?`File updated`:`File created`);case`text_editor_code_execution_str_replace_result`:{let t=e.lines;return n(t?.join(`
7
- `)||``)}case`text_editor_code_execution_tool_result_error`:return n(`Error: ${e.error_code}${e.error_message?` - ${e.error_message}`:``}`);default:try{return{type:`text`,text:JSON.stringify(e)}}catch{return{type:`text`,text:`[content]`}}}}function Ai(e,t,n=!1){if(!t)return{};let r=e.is_error===!0,i=e.content;if(r&&i)return Oi(i,!0);switch(t.name){case`Read`:return typeof i==`string`&&i.length>0?{content:[{type:`content`,content:{type:`text`,text:Di(i)}}]}:Array.isArray(i)&&i.length>0?{content:i.map(e=>({type:`content`,content:e.type===`text`?{type:`text`,text:Di(e.text)}:ki(e,!1)}))}:{};case`Bash`:{let e=``;if(i&&typeof i==`object`&&!Array.isArray(i)&&i.type===`bash_code_execution_result`){let t=i;e=[t.stdout,t.stderr].filter(Boolean).join(`
8
- `)}else typeof i==`string`?e=i:Array.isArray(i)&&i.length>0&&(e=i.map(e=>e.type===`text`?e.text:``).join(`
9
- `));return e.trim()?{content:[{type:`content`,content:{type:`text`,text:`\`\`\`console\n${e.trimEnd()}\n\`\`\``}}]}:{}}case`Edit`:case`Write`:return{};case`ExitPlanMode`:return{title:`Exited Plan Mode`};default:return Oi(i??``,r)}}function ji(e){return e===`in_progress`?`in_progress`:e===`completed`?`completed`:`pending`}function X(e,t,n,r,i,a,o){let s=[];for(let i of e){let e=i.type,a=null;switch(e){case`text`:case`text_delta`:{let e=i.text??``;a={sessionUpdate:t===`assistant`?`agent_message_chunk`:`user_message_chunk`,...o?.messageId?{messageId:o.messageId}:{},content:{type:`text`,text:e}};break}case`thinking`:case`thinking_delta`:{let e=i.thinking??``;a={sessionUpdate:`agent_thought_chunk`,...o?.messageId?{messageId:o.messageId}:{},content:{type:`text`,text:e}};break}case`image`:{let e=i.source;e?.type===`base64`&&(a={sessionUpdate:t===`assistant`?`agent_message_chunk`:`user_message_chunk`,...o?.messageId?{messageId:o.messageId}:{},content:{type:`image`,data:e.data,mimeType:e.media_type}});break}case`tool_use`:case`server_tool_use`:case`mcp_tool_use`:{let t=i.id??``,n=i.name??`unknown`,s=i.input,c=t in r;if(r[t]={type:e,id:t,name:n,input:s},n===`TodoWrite`){let e=s?.todos;Array.isArray(e)&&(a={sessionUpdate:`plan`,entries:e.map(e=>({content:e.content,status:ji(e.status),priority:`medium`}))})}else{let e=s?{...s}:{};a=c?{_meta:{claudeCode:{toolName:n}},toolCallId:t,sessionUpdate:`tool_call_update`,status:`in_progress`,rawInput:e,...Y({name:n,id:t,input:s??{}},!1,o?.cwd)}:{_meta:{claudeCode:{toolName:n}},toolCallId:t,sessionUpdate:`tool_call`,rawInput:e,status:`pending`,...Y({name:n,id:t,input:s??{}},!1,o?.cwd)}}break}case`tool_result`:case`mcp_tool_result`:{let e=i.tool_use_id??``,t=r[e];if(!t)break;if(t.name!==`TodoWrite`){let n=Ai(i,{name:t.name,id:t.id},!1);a={_meta:{claudeCode:{toolName:t.name}},toolCallId:e,sessionUpdate:`tool_call_update`,status:i.is_error===!0?`failed`:`completed`,rawOutput:i.content,...n}}break}case`redacted_thinking`:case`input_json_delta`:case`citations_delta`:case`signature_delta`:case`container_upload`:case`compaction`:case`compaction_delta`:break}if(a){if(o?.parentToolUseId){let e=a._meta;a._meta={...e,claudeCode:{...e?.claudeCode??{},parentToolUseId:o.parentToolUseId}}}s.push({sessionId:n,update:a})}}return s}function Mi(e,t,n,r,i){let a=e.message;if(!a)return[];let o=a.content;if(!o)return[];if(typeof o==`string`)return[{sessionId:t,update:{sessionUpdate:`agent_message_chunk`,...i?.messageId?{messageId:i.messageId}:{},content:{type:`text`,text:o}}}];let s=i?.streamingActive?o.filter(e=>e.type!==`text`&&e.type!==`thinking`):o;return s.length===0?[]:X(s,`assistant`,t,n,r,void 0,i)}function Ni(e,t,n,r,i){let a=e.event;if(!a)return[];switch(a.type){case`content_block_start`:{let o=a.content_block;return o?X([o],`assistant`,t,n,r,void 0,{clientCapabilities:i?.clientCapabilities,parentToolUseId:e.parent_tool_use_id,cwd:i?.cwd,messageId:i?.messageId}):[]}case`content_block_delta`:{let o=a.delta;return o?X([o],`assistant`,t,n,r,void 0,{clientCapabilities:i?.clientCapabilities,parentToolUseId:e.parent_tool_use_id,cwd:i?.cwd,messageId:i?.messageId}):[]}case`message_start`:case`message_delta`:case`message_stop`:case`content_block_stop`:return[];default:return[]}}function Pi(e,t){let n=0,r=Math.min(e.length,t.length);for(;n<r&&e[n]===t[n];)n++;return n}function Fi(e,t){let n=null,r=0;for(let i of Object.keys(e)){let e=Pi(i,t);e>r&&(r=e,n=i)}return n?e[n]??null:null}var Ii=console;function Li(e,t){if(t.aborted)return Promise.resolve({done:!0,value:void 0});let n,r=new Promise(e=>{n=()=>e({done:!0,value:void 0}),t.addEventListener(`abort`,n,{once:!0})});return Promise.race([e.next(),r]).finally(()=>{n&&t.removeEventListener(`abort`,n)})}async function Ri(e,t,n,r,i,a,o,s){let c=`end_turn`,l={inputTokens:0,outputTokens:0,cachedReadTokens:0,cachedWriteTokens:0},u=null,d=null,f=2e5,p=!1,m=null;try{for(;!r.aborted;){let s=await Li(t,r);if(s.done||r.aborted)break;let h=s.value;if(h==null)continue;let g=h;switch(g.type){case`system`:g.subtype===`compact_boundary`&&(u=0,await n.sessionUpdate({sessionId:e,update:{sessionUpdate:`agent_message_chunk`,content:{type:`text`,text:`
10
-
11
- Compacting completed.`}}}));break;case`result`:{let t=g.usage;t&&(l.inputTokens+=t.input_tokens??0,l.outputTokens+=t.output_tokens??0,l.cachedReadTokens+=t.cache_read_input_tokens??0,l.cachedWriteTokens+=t.cache_creation_input_tokens??0);let i=g.modelUsage;if(i&&d){let e=Fi(i,d);e?.contextWindow&&(f=e.contextWindow)}u!==null&&await n.sessionUpdate({sessionId:e,update:{sessionUpdate:`usage_update`,used:u,size:f}});let a=g.subtype,o=g.is_error;if(r.aborted){c=`cancelled`;break}switch(a){case`success`:{let e=g.stop_reason;c=e===`max_tokens`?`max_tokens`:e===`refusal`?`refusal`:`end_turn`,o&&(c=`end_turn`);break}case`error_during_execution`:c=g.stop_reason===`max_tokens`?`max_tokens`:`end_turn`;break;case`error_max_budget_usd`:case`error_max_turns`:case`error_max_structured_output_retries`:c=`max_turn_requests`;break}break}case`stream_event`:{let t=g.parent_tool_use_id;t===null&&m===null&&(m=j());let r=Ni(g,e,i,n,{clientCapabilities:a,cwd:o,messageId:t===null?m??void 0:void 0});for(let e of r)await n.sessionUpdate(e);p=!0;break}case`assistant`:{let t=g.message,r=g.parent_tool_use_id;if(t?.usage&&r===null){let e=t.usage;u=(typeof e.input_tokens==`number`?e.input_tokens:0)+(typeof e.output_tokens==`number`?e.output_tokens:0)+(typeof e.cache_read_input_tokens==`number`?e.cache_read_input_tokens:0)+(typeof e.cache_creation_input_tokens==`number`?e.cache_creation_input_tokens:0)}r===null&&t?.model&&t.model!==`<synthetic>`&&(d=t.model);let s;r===null&&(m===null&&(m=j()),s=m);let c=Mi(g,e,i,n,{clientCapabilities:a,cwd:o,parentToolUseId:r,streamingActive:p,messageId:s});for(let e of c)await n.sessionUpdate(e);r===null&&(m=null);break}case`user`:break;case`progress`:{let t=g.data;if(!t)break;let r=t.type;if(r===`agent_progress`||r===`skill_progress`){let r=t.message;if(r){let t=r.content;if(t)for(let r of t)r.type===`text`&&await n.sessionUpdate({sessionId:e,update:{sessionUpdate:`agent_message_chunk`,content:{type:`text`,text:r.text}}})}}break}case`tool_use_summary`:break;case`attachment`:break;case`compact_boundary`:u=0,await n.sessionUpdate({sessionId:e,update:{sessionUpdate:`agent_message_chunk`,content:{type:`text`,text:`
12
-
13
- Compacting completed.`}}});break;default:Ii.debug(`Ignoring unknown SDK message type`);break}}if(r.aborted||s?.())return{stopReason:`cancelled`,usage:l}}catch(e){if(r.aborted)return{stopReason:`cancelled`,usage:l};throw e}return{stopReason:c,usage:l}}async function zi(e,t,n,r,i,a){for(let o of t){let t=o;if(t.type!==`user`&&t.type!==`assistant`){Ii.debug(`Ignoring unknown SDK message type`);continue}if(t.isMeta===!0)continue;let s=t.message?.content;if(!s)continue;let c=t.type===`assistant`?`assistant`:`user`;if(typeof s==`string`){if(!s.trim())continue;let t=j();await n.sessionUpdate({sessionId:e,update:{sessionUpdate:c===`assistant`?`agent_message_chunk`:`user_message_chunk`,...t?{messageId:t}:{},content:{type:`text`,text:s}}});continue}if(Array.isArray(s)){let t=X(s,c,e,r,n,void 0,{clientCapabilities:i,cwd:a,messageId:j()});for(let e of t)await n.sessionUpdate(e)}}}function Bi(e,t,n,r,i,a,o,c){return async(n,l,u,d,f,p)=>{let m=Hi(r);if(n.name===`ExitPlanMode`)return Vi(e,t,f,l,m,i,a,o,c);if(p!==void 0)return p;try{let e=await s(n,l,u,d,f);if(e.behavior===`allow`||e.behavior===`deny`)return e}catch(e){return console.error(`[ACP Permissions] Pipeline error:`,e),{behavior:`deny`,message:`Permission pipeline failed`,decisionReason:{type:`other`,reason:`Permission pipeline failed`},toolUseID:f}}let h=Y({name:n.name,id:f,input:l},m,i),g={toolCallId:f,title:h.title,kind:h.kind,status:`pending`,rawInput:l},_=[{kind:`allow_always`,name:`Always Allow`,optionId:`allow_always`},{kind:`allow_once`,name:`Allow`,optionId:`allow`},{kind:`reject_once`,name:`Reject`,optionId:`reject`},{kind:`reject_always`,name:`Always Reject`,optionId:`reject_always`}];try{let n=await e.requestPermission({sessionId:t,toolCall:g,options:_});if(n.outcome.outcome===`cancelled`)return c?.(),{behavior:`deny`,message:`Permission request cancelled by client`,decisionReason:{type:`mode`,mode:`default`},toolUseID:f};if(n.outcome.outcome===`selected`&&`optionId`in n.outcome&&n.outcome.optionId!==void 0){let e=n.outcome.optionId;if(e===`allow`||e===`allow_always`)return{behavior:`allow`,updatedInput:l}}return{behavior:`deny`,message:`Permission denied by client`,decisionReason:{type:`mode`,mode:`default`}}}catch(e){return console.error(`[ACP Permissions] Client request error:`,e),{behavior:`deny`,message:`Permission request failed`,decisionReason:{type:`mode`,mode:`default`}}}}}async function Vi(e,t,n,r,i,a,o,s,c){let l=[{kind:`allow_always`,name:`Yes, and use "auto" mode`,optionId:`auto`},{kind:`allow_always`,name:`Yes, and auto-accept edits`,optionId:`acceptEdits`},{kind:`allow_once`,name:`Yes, and manually approve edits`,optionId:`default`},{kind:`reject_once`,name:`No, keep planning`,optionId:`plan`}];s?.()===!0&&l.unshift({kind:`allow_always`,name:`Yes, and bypass permissions`,optionId:`bypassPermissions`});let u=Y({name:`ExitPlanMode`,id:n,input:r},i,a),d={toolCallId:n,title:u.title,kind:u.kind,status:`pending`,rawInput:r},f=await e.requestPermission({sessionId:t,toolCall:d,options:l});if(f.outcome.outcome===`cancelled`)return c?.(),{behavior:`deny`,message:`Tool use aborted`,decisionReason:{type:`mode`,mode:`default`}};if(f.outcome.outcome===`selected`&&`optionId`in f.outcome&&f.outcome.optionId!==void 0){let n=f.outcome.optionId;if(l.some(e=>e.optionId===n)&&(n==="default"||n===`acceptEdits`||n===`auto`||n===`bypassPermissions`))return o?.(n),await e.sessionUpdate({sessionId:t,update:{sessionUpdate:`current_mode_update`,currentModeId:n}}),{behavior:`allow`,updatedInput:r}}return{behavior:`deny`,message:`User rejected request to exit plan mode.`,decisionReason:{type:`mode`,mode:`plan`}}}function Hi(e){if(!e)return!1;if(e.terminal===!0)return!0;let t=e._meta;return!t||typeof t!=`object`?!1:t.terminal_output===!0}ge(),Ce(),a(),pe(),e(),r(),n();var Z=class{constructor(e){t(this,`conn`,void 0),t(this,`sessions`,new Map),t(this,`clientCapabilities`,void 0),this.conn=e}async initialize(e){return this.clientCapabilities=e.clientCapabilities,{protocolVersion:1,authMethods:[],agentInfo:{name:`claude-code`,title:`Work Mate`,version:typeof globalThis.MACRO==`object`&&globalThis.MACRO!==null?String(globalThis.MACRO.VERSION??`0.0.0`):`0.0.0`},agentCapabilities:{_meta:{claudeCode:{promptQueueing:!0,forkSession:!0}},promptCapabilities:{image:!1,embeddedContext:!0},mcpCapabilities:{http:!0,sse:!0},loadSession:!0,sessionCapabilities:{list:{},resume:{},close:{},delete:{}}}}}async authenticate(e){return{}}async newSession(e){let t=await this.createSession(e);return this.scheduleAvailableCommandsUpdate(t.sessionId),t}async unstable_resumeSession(e){let t=await this.getOrCreateSession({...e,replay:!1});return this.scheduleAvailableCommandsUpdate(t.sessionId),t}async loadSession(e){let t=await this.getOrCreateSession(e);return this.scheduleAvailableCommandsUpdate(t.sessionId),t}async listSessions(e){if(e.cursor!==void 0&&e.cursor!==null)throw Error(`Pagination cursor not supported: listSessions returns all results in a single page.`);let t=e.cwd||se(),n=await he(t),r=await o({dir:t}),i=[];for(let e of r){if(!e.cwd||await he(e.cwd)!==n)continue;let t=Ei(e.summary??``);i.push({sessionId:e.sessionId,cwd:e.cwd,...t?{title:t}:{},updatedAt:new Date(e.lastModified).toISOString()})}return{sessions:i}}async unstable_forkSession(e){let{initialMessages:t}=await Ui(e.sessionId),n=await this.createSession({cwd:e.cwd,mcpServers:e.mcpServers??[],_meta:e._meta},{initialMessages:t});return this.scheduleAvailableCommandsUpdate(n.sessionId),n}async unstable_closeSession(e){if(!this.sessions.get(e.sessionId))throw Error(`Session not found`);return await this.teardownSession(e.sessionId),{}}async unstable_deleteSession(e){let t=await me(e.sessionId);if(t)try{await Oe(t.filePath)}catch(e){if(e.code!==`ENOENT`)throw e}return this.sessions.has(e.sessionId)&&await this.teardownSession(e.sessionId),{}}async extMethod(e,t){if(e===`session/delete`){let e=t.sessionId;if(typeof e!=`string`||e.length===0)throw Error(`session/delete requires a non-empty sessionId`);return this.unstable_deleteSession({sessionId:e})}throw K.methodNotFound(e)}async cancel(e){let t=this.sessions.get(e.sessionId);if(t){t.cancelled=!0,t.cancelGeneration+=1;for(let[,e]of t.pendingMessages)e.resolve(!0);t.pendingMessages.clear(),t.pendingQueue=[],t.pendingQueueHead=0,t.queryEngine.interrupt()}}async setSessionMode(e){if(!this.sessions.get(e.sessionId))throw Error(`Session not found`);return this.applySessionMode(e.sessionId,e.modeId),await this.conn.sessionUpdate({sessionId:e.sessionId,update:{sessionUpdate:`current_mode_update`,currentModeId:e.modeId}}),await this.updateConfigOption(e.sessionId,`mode`,e.modeId),{}}async unstable_setSessionModel(e){let t=this.sessions.get(e.sessionId);if(!t)throw Error(`Session not found`);return t.queryEngine.setModel(e.modelId),await this.updateConfigOption(e.sessionId,`model`,e.modelId),{}}async sendAvailableCommandsUpdate(e){let t=this.sessions.get(e);if(!t)return;let n=t.commands.filter(e=>e.type===`prompt`&&!e.isHidden&&e.userInvocable!==!1).map(e=>({name:e.name,description:e.description,input:e.argumentHint?{hint:e.argumentHint}:void 0}));await this.conn.sessionUpdate({sessionId:e,update:{sessionUpdate:`available_commands_update`,availableCommands:n}})}scheduleAvailableCommandsUpdate(e){setTimeout(()=>{this.sendAvailableCommandsUpdate(e).catch(e=>{console.error(`[ACP] Failed to send available commands update:`,e)})},0)}};async function Ui(e){let t;try{let n=await h(e);n&&n.messages.length>0&&(t=_(n.messages))}catch(e){console.error(`[ACP] fork source load failed:`,e)}return{initialMessages:t}}var Wi=[`auto`,`default`,`acceptEdits`,`bypassPermissions`,`dontAsk`,`plan`];function Gi(e){return Wi.includes(e)}function Ki(e,t,n){if(t){let t=qi(e,`_meta.permissionMode`);if(t===`bypassPermissions`&&!Xi())throw Error(`Mode not available: bypassPermissions cannot run as root (start the agent as a non-root user, or set IS_SANDBOX=1).`);return t}return Ji(n)??`default`}function qi(e,t){if(e==null)throw Error(`Invalid ${t}: expected a string.`);return Ci(e,t)}function Ji(e){if(e!=null)try{return Ci(e,`permissions.defaultMode`)}catch(e){let t=e instanceof Error?e.message:String(e);console.error(`[ACP] Invalid permissions.defaultMode, using default:`,t);return}}function Yi(e,t){return!!e&&Object.hasOwn(e,t)}function Xi(){return Zi()}function Zi(){return process.env.IS_SANDBOX?!0:typeof process.geteuid==`function`?process.geteuid()!==0:typeof process.getuid!=`function`||process.getuid()!==0}function Qi(e,t){return[{id:`mode`,name:`Mode`,description:`Session permission mode`,category:`mode`,type:`select`,currentValue:e.currentModeId,options:e.availableModes.map(e=>({value:e.id,name:e.name,description:e.description}))},{id:`model`,name:`Model`,description:`AI model to use`,category:`model`,type:`select`,currentValue:t.currentModelId,options:t.availableModels.map(e=>({value:e.modelId,name:e.name,description:e.description??void 0}))}]}function $i(e){let t=[];if(!Array.isArray(e))return t;for(let n of e){if(typeof n!=`object`||!n)continue;let e=n;if(Array.isArray(e.options))for(let n of e.options)n&&typeof n==`object`&&typeof n.value==`string`&&t.push(n.value);else typeof n.value==`string`&&t.push(n.value)}return t}function Q(e){return e.conn}function $(e){return e.clientCapabilities}function ea(e,t,n,r){n===`mode`?t.modes={...t.modes,currentModeId:r}:n===`model`&&(t.models={...t.models,currentModelId:r})}k();function ta(){return le().permissions?.defaultMode}async function na(e,t={}){fe();let n=t.sessionId??j(),r=e.cwd;A(n,oe()),ie(r);let i=process.cwd(),a=!1;try{process.chdir(r),a=!0}catch{}ae(),be();try{let i=ye(),a=f(i),o=e._meta,s=Yi(o,`permissionMode`),l=Ki(s?o?.permissionMode:void 0,s,ta()),u=$(this),p=this.conn,m=Bi(p,n,()=>this.sessions.get(n)?.modes.currentModeId??`default`,u,r,e=>{this.applySessionMode(n,e)},()=>this.sessions.get(n)?.appState.toolPermissionContext.isBypassPermissionsModeAvailable??!1),h=Xi(),_={...d(),toolPermissionContext:{...i,mode:l,isBypassPermissionsModeAvailable:h}},[ee,v]=await Promise.all([c(r),g(r)]);_.agentDefinitions=v;let y=new Se({cwd:r,tools:a,commands:ee,mcpClients:[],agents:v.activeAgents,canUseTool:m,getAppState:()=>_,setAppState:e=>{let t=e(_);Object.assign(_,t)},readFileCache:new te(500,50*1024*1024),includePartialMessages:!0,replayUserMessages:!0,initialMessages:t.initialMessages}),b={currentModeId:l,availableModes:[{id:`default`,name:`Default`,description:`Standard behavior, prompts for dangerous operations`},{id:`acceptEdits`,name:`Accept Edits`,description:`Auto-accept file edit operations`},{id:`plan`,name:`Plan Mode`,description:`Planning mode, no actual tool execution`},{id:`auto`,name:`Auto`,description:`Use a model classifier to approve/deny permission prompts.`},...h?[{id:`bypassPermissions`,name:`Bypass Permissions`,description:`Skip all permission checks`}]:[],{id:`dontAsk`,name:`Don't Ask`,description:`Don't prompt for permissions, deny if not pre-approved`}]},x=we(),S=_e(),C={availableModels:x.map(e=>({modelId:String(e.value??``),name:e.label??String(e.value??``),description:e.description??void 0})),currentModelId:S};y.setModel(S);let w=Qi(b,C),ne={queryEngine:y,cancelled:!1,cancelGeneration:0,cwd:r,modes:b,models:C,configOptions:w,promptRunning:!1,pendingMessages:new Map,pendingQueue:[],pendingQueueHead:0,toolUseCache:{},clientCapabilities:u,appState:_,commands:ee,sessionFingerprint:wi({cwd:r,mcpServers:e.mcpServers})};return this.sessions.set(n,ne),{sessionId:n,modes:b,models:C,configOptions:w}}finally{a&&process.chdir(i)}}Object.assign(Z.prototype,{createSession:na}),r(),n(),k(),pe();async function ra(e){let t=e.replay!==!1,n=this.sessions.get(e.sessionId);if(n){if(wi({cwd:e.cwd,mcpServers:e.mcpServers})===n.sessionFingerprint){let r=await me(e.sessionId,e.cwd);return A(e.sessionId,r?Te(r.filePath):null),ie(e.cwd),t&&await this.replaySessionHistory(e),{sessionId:e.sessionId,modes:n.modes,models:n.models,configOptions:n.configOptions}}await this.teardownSession(e.sessionId)}let r=await me(e.sessionId,e.cwd),i=r?Te(r.filePath):null;A(e.sessionId,i),ie(e.cwd);let a;if(r)try{let t=await h(e.sessionId);t&&t.messages.length>0&&(a=_(t.messages))}catch(e){console.error(`[ACP] Failed to load session history:`,e)}let o=await this.createSession({cwd:e.cwd,mcpServers:e.mcpServers??[],_meta:e._meta},{sessionId:e.sessionId,initialMessages:a});if(t&&a&&a.length>0){let t=this.sessions.get(e.sessionId);t&&await zi(e.sessionId,a,Q(this),t.toolUseCache,$(this),t.cwd)}return{sessionId:o.sessionId,modes:o.modes,models:o.models,configOptions:o.configOptions}}async function ia(e){this.sessions.get(e)&&(await this.cancel({sessionId:e}),this.sessions.delete(e))}async function aa(e){try{let t=await h(e.sessionId);if(!t||t.messages.length===0)return;let n=_(t.messages);if(n.length===0)return;let r=this.sessions.get(e.sessionId);if(!r)return;await zi(e.sessionId,n,Q(this),r.toolUseCache,$(this),r.cwd)}catch(e){console.error(`[ACP] Failed to replay session history:`,e)}}function oa(e,t){if(!Gi(t))throw Error(`Invalid mode: ${t}`);let n=this.sessions.get(e);if(n){if(t===`bypassPermissions`&&!n.appState.toolPermissionContext.isBypassPermissionsModeAvailable||!n.modes.availableModes.some(e=>e.id===t))throw Error(`Mode not available: ${t}`);n.modes={...n.modes,currentModeId:t},n.appState.toolPermissionContext={...n.appState.toolPermissionContext,mode:t}}}async function sa(e,t,n){let r=this.sessions.get(e);r&&(ea(this,r,t,n),r.configOptions=r.configOptions.map(e=>e.id===t&&typeof e.currentValue==`string`?{...e,currentValue:n}:e),await Q(this).sessionUpdate({sessionId:e,update:{sessionUpdate:`config_option_update`,configOptions:r.configOptions}}))}Object.assign(Z.prototype,{getOrCreateSession:ra,teardownSession:ia,replaySessionHistory:aa,applySessionMode:oa,updateConfigOption:sa});function ca(e){if(!e||e.length===0)return``;let t=[];for(let n of e){let e=n;if(e.type===`text`)t.push(String(e.text??``));else if(e.type===`resource_link`){let n=typeof e.name==`string`?e.name:void 0,r=typeof e.uri==`string`?e.uri:void 0;t.push(la(n,r))}else if(e.type===`resource`){let n=e.resource;if(n&&typeof n.text==`string`)t.push(n.text);else if(n&&typeof n.blob==`string`){let e=typeof n.mimeType==`string`?n.mimeType:`application/octet-stream`,r=typeof n.uri==`string`?n.uri:`(unknown uri)`;t.push(`Embedded resource: ${r} (${e}, base64 blob, ${n.blob.length} chars)`)}}}return t.filter(e=>e.length>0).join(`
14
- `)}function la(e,t){let n=[];return e&&e.length>0&&n.push(`name=${e}`),t&&t.length>0&&n.push(`uri=${t}`),n.length>0?`Resource link: ${n.join(`, `)}`:`Resource link`}function ua(e){for(;e.pendingQueueHead<e.pendingQueue.length;){let t=e.pendingQueue[e.pendingQueueHead++];if(!t)continue;let n=e.pendingMessages.get(t);if(n)return e.pendingMessages.delete(t),da(e),n}da(e)}function da(e){if(e.pendingQueueHead!==0){if(e.pendingQueueHead>=e.pendingQueue.length){e.pendingQueue=[],e.pendingQueueHead=0;return}e.pendingQueueHead>1024&&e.pendingQueueHead*2>e.pendingQueue.length&&(e.pendingQueue=e.pendingQueue.slice(e.pendingQueueHead),e.pendingQueueHead=0)}}k();async function fa(e){let t=this.sessions.get(e.sessionId);if(!t)throw Error(`Session ${e.sessionId} not found`);let n=e.messageId??void 0,r=ca(e.prompt);if(!r.trim())throw Error(`Prompt content is empty`);let i=t.cancelGeneration;if(t.promptRunning){let e=j();if(await new Promise(n=>{t.pendingQueue.push(e),t.pendingMessages.set(e,{resolve:n})}))return{stopReason:`cancelled`}}if(t.cancelGeneration!==i)return{stopReason:`cancelled`};t.cancelled=!1,t.promptRunning=!0;try{t.queryEngine.resetAbortController(),A(e.sessionId,oe());let i=t.queryEngine.submitMessage(r),{stopReason:a,usage:o}=await Ri(e.sessionId,i,Q(this),t.queryEngine.getAbortSignal(),t.toolUseCache,$(this),t.cwd,()=>t.cancelled);if(t.cancelled)return{stopReason:`cancelled`};if(await ma(this,e.sessionId,r),o){let e={inputTokens:o.inputTokens,outputTokens:o.outputTokens,cachedReadTokens:o.cachedReadTokens,cachedWriteTokens:o.cachedWriteTokens,thoughtTokens:0,totalTokens:o.inputTokens+o.outputTokens+o.cachedReadTokens+o.cachedWriteTokens+0};return{stopReason:a,usage:e,...n?{userMessageId:n}:{},_meta:{claudeCode:{usage:e}}}}return{stopReason:a,...n?{userMessageId:n}:{}}}catch(n){let r=n instanceof Error&&(n.name===`AbortError`||/abort|cancelled|interrupt/i.test(n.message));if(t.cancelled||r)return{stopReason:`cancelled`};throw n instanceof Error&&(n.message.includes(`terminated`)||n.message.includes(`process exited`))?(await this.teardownSession(e.sessionId),Error(`The Claude Agent process exited unexpectedly. Please start a new session.`)):n}finally{let e=ua(t);e?(t.promptRunning=!0,e.resolve(!1)):t.promptRunning=!1}}async function pa(e){let t=this.sessions.get(e.sessionId);if(!t)throw Error(`Session not found`);if(typeof e.value!=`string`)throw Error(`Invalid value for config option ${e.configId}: ${String(e.value)}`);let n=t.configOptions.find(t=>t.id===e.configId);if(!n)throw Error(`Unknown config option: ${e.configId}`);if(n.type===`select`){let t=$i(n.options);if(!t.includes(e.value))throw Error(`Invalid value '${e.value}' for config option ${e.configId}; must be one of: ${t.join(`, `)}`)}let r=e.value;return e.configId===`mode`?(this.applySessionMode(e.sessionId,r),await Q(this).sessionUpdate({sessionId:e.sessionId,update:{sessionUpdate:`current_mode_update`,currentModeId:r}})):e.configId===`model`&&t.queryEngine.setModel(r),ea(this,t,e.configId,r),t.configOptions=t.configOptions.map(t=>t.id===e.configId&&typeof t.currentValue==`string`?{...t,currentValue:r}:t),{configOptions:t.configOptions}}async function ma(e,t,n){let r=e.sessions.get(t);if(!r)return;let i=r.toolUseCache;if(i.__sessionInfoTitleSent)return;i.__sessionInfoTitleSent=!0;let a=Ei(n).slice(0,100);try{await Q(e).sessionUpdate({sessionId:t,update:{sessionUpdate:`session_info_update`,...a?{title:a}:{},updatedAt:new Date().toISOString()}})}catch(e){console.error(`[ACP] Failed to send session_info_update:`,e)}}Object.assign(Z.prototype,{prompt:fa,setSessionConfigOption:pa}),de(),xe();function ha(e,t){let n=Ee.toWeb(e);return gi(De.toWeb(t),n)}async function ga(){fe(),be();let e=ha(process.stdin,process.stdout),t,n=new vi(e=>(t=new Z(e),t),e);console.log=console.error,console.info=console.error,console.warn=console.error,console.debug=console.error;async function r(){for(let[e]of t.sessions)try{await t.unstable_closeSession({sessionId:e})}catch{}process.exit(0)}n.closed.then(r).catch(r),process.on(`SIGTERM`,r),process.on(`SIGINT`,r),process.on(`unhandledRejection`,(e,t)=>{console.error(`Unhandled Rejection at:`,t,`reason:`,e)}),process.stdin.resume()}export{ga as runAcpAgent};
@@ -1 +0,0 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./memoize-BK3gG5ob.js";import{l as r,o as i}from"./envUtils-BDhHQY0-.js";import{n as a,t as o}from"./defineProperty-C-QyHrDq.js";import{E as s,O as c,S as l,i as u,l as d,n as f,s as p,v as m}from"./esm-lWlUmoUA.js";import{C as h,D as g,E as _,I as v,O as y,S as ee,V as te,_ as ne,a as b,d as re,k as ie,l as ae,n as oe,p as se,s as ce,t as le,w as ue,x as de,y as x}from"./esm-Cb-L4oAk.js";import{a as S,r as fe,t as pe}from"./esm-Bx6rTxIs.js";import{C as me,Kt as he,R as ge,mt as _e,nt as ve}from"./state-Bs5xweDL.js";import{S as ye,a as be,w as xe,z as Se}from"./debug-BdqxZ7rV.js";import{Gt as C,Jt as Ce,Wt as we,qt as Te}from"./settings-Xbq6AaD-.js";import{d as Ee,m as De}from"./git-B9uvt96d.js";import{r as Oe,t as ke}from"./execFileNoThrow-5SylUnAI.js";import{a as Ae,n as je,o as Me,r as Ne}from"./platform-D6IMiyqT.js";import{An as Pe,Bt as Fe,Ft as Ie,Gt as Le,_ as Re,jn as ze,u as Be}from"./model-C2e73CJD.js";import{i as Ve,t as He}from"./genericProcessUtils-BmDSLcMf.js";import{arch as Ue,hostname as We,platform as Ge,release as Ke}from"os";import{extname as qe}from"path";import{stat as Je}from"fs/promises";import{inspect as Ye}from"util";import*as Xe from"process";import{AsyncLocalStorage as Ze}from"async_hooks";function Qe(){return process.platform===`linux`&&r(process.env.CLAUDE_CODE_BUBBLEWRAP)}function $e(){return process.platform===`linux`?w??!1:!1}async function et(){if(T!==void 0)return T;if(process.platform===`darwin`)return T=null,null;try{let e=await He(process.pid,10);for(let t of e){let e=t.toLowerCase();for(let t of we)if(e.includes(t))return T=t,t}}catch{}return T=null,null}async function tt(){return process.env.TERMINAL_EMULATOR===`JetBrains-JediTerm`&&C.platform!==`darwin`?await et()||`pycharm`:C.terminal}function nt(){return process.env.TERMINAL_EMULATOR===`JetBrains-JediTerm`&&C.platform!==`darwin`?T===void 0?`pycharm`:T||`pycharm`:C.terminal}async function rt(){process.env.TERMINAL_EMULATOR===`JetBrains-JediTerm`&&await et()}var it,w,T,E,at=e((()=>{n(),Ce(),i(),Oe(),Ve(),it=t(async()=>{if(process.platform!==`linux`)return!1;let{code:e}=await ke(`test`,[`-f`,`/.dockerenv`]);return e===0}),w=null,process.platform===`linux`&&Je(`/lib/libc.musl-${process.arch===`x64`?`x86_64`:`aarch64`}.so.1`).then(()=>{w=!0},()=>{w=!1}),E={...C,terminal:nt(),getIsDocker:it,getIsBubblewrapSandbox:Qe,isMuslEnvironment:$e,getTerminalWithJetBrainsDetectionAsync:tt,initJetBrainsDetection:rt}}));function ot(e){return st?.has(e)??!1}var st,ct=e((()=>{be(),Se()}));function D(){return O.getStore()}function lt(e,t){return O.run(e,t)}function ut(e){return e?.agentType===`subagent`}function dt(){let e=D();if(!(!ut(e)||!e.subagentName))return e.isBuiltIn?e.subagentName:`user-defined`}function ft(){let e=D();if(!(!e?.invokingRequestId||e.invocationEmitted))return e.invocationEmitted=!0,{invokingRequestId:e.invokingRequestId,invocationKind:e.invocationKind}}var O,pt=e((()=>{O=new Ze}));function mt(e){return e.startsWith(`mcp__`)?`mcp_tool`:e}function ht(){return r(process.env.OTEL_LOG_TOOL_DETAILS)}function gt(e,t){return!!(process.env.CLAUDE_CODE_ENTRYPOINT===`local-agent`||e===`claudeai-proxy`||t&&ot(t))}function _t(e,t,n){let r=vt(e);return!r||!Et.has(r.serverName)&&!gt(t,n)?{}:{mcpServerName:r.serverName,mcpToolName:r.mcpToolName}}function vt(e){if(!e.startsWith(`mcp__`))return;let t=e.split(`__`);if(t.length<3)return;let n=t[1],r=t.slice(2).join(`__`);if(!(!n||!r))return{serverName:n,mcpToolName:r}}function yt(e,t){if(e===`Skill`&&typeof t==`object`&&t&&`skill`in t&&typeof t.skill==`string`)return t.skill}function k(e,t=0){if(typeof e==`string`)return e.length>Dt?`${e.slice(0,Ot)}…[${e.length} chars]`:e;if(typeof e==`number`||typeof e==`boolean`||e==null)return e;if(t>=kt)return`<nested>`;if(Array.isArray(e)){let n=e.slice(0,M).map(e=>k(e,t+1));return e.length>M&&n.push(`…[${e.length} items]`),n}if(typeof e==`object`){let n=Object.entries(e).filter(([e])=>!e.startsWith(`_`)),r=n.slice(0,M).map(([e,n])=>[e,k(n,t+1)]);return n.length>M&&r.push([`…`,`${n.length} keys`]),Object.fromEntries(r)}return String(e)}function bt(e){if(!ht())return;let t=xe(k(e));return t.length>j&&(t=t.slice(0,j)+`…[truncated]`),t}function A(e){let t=qe(e).toLowerCase();if(!t||t===`.`)return;let n=t.slice(1);return n.length>At?`other`:n}function xt(e,t){if(!e.includes(`.`)&&!t)return;let n,r=new Set;if(t){let e=A(t);e&&(r.add(e),n=e)}for(let t of e.split(Mt)){if(!t)continue;let e=t.split(Nt);if(e.length<2)continue;let i=e[0],a=i.lastIndexOf(`/`),o=a>=0?i.slice(a+1):i;if(jt.has(o))for(let t=1;t<e.length;t++){let i=e[t];if(i.charCodeAt(0)===45)continue;let a=A(i);a&&!r.has(a)&&(r.add(a),n=n?n+`,`+a:a)}}if(n)return n}function St(){let e=D();if(e)return{agentId:e.agentId,parentSessionId:e.parentSessionId,agentType:e.agentType};let t=process.env.CLAUDE_CODE_AGENT_ID,n=process.env.CLAUDE_CODE_PARENT_SESSION_ID,r=t?`standalone`:void 0;if(t||r||n)return{...t?{agentId:t}:{},...r?{agentType:r}:{},...n?{parentSessionId:n}:{}};let i=ve();return i?{parentSessionId:i}:{}}function Ct(){try{let e=process.memoryUsage(),t=process.cpuUsage(),n=Date.now(),r;if(N&&P){let e=n-P;e>0&&(r=(t.user-N.user+(t.system-N.system))/(e*1e3)*100)}return N=t,P=n,{uptime:process.uptime(),rss:e.rss,heapTotal:e.heapTotal,heapUsed:e.heapUsed,external:e.external,arrayBuffers:e.arrayBuffers,constrainedMemory:process.constrainedMemory(),cpuUsage:t,cpuPercent:r}}catch{return}}async function wt(e={}){let t=e.model?String(e.model):Be(),n=typeof e.betas==`string`?e.betas:Pe(t).join(`,`),[r,i]=await Promise.all([Ft(),Ee()]),a=Ct();return{model:t,sessionId:_e(),userType:process.env.USER_TYPE||``,...n.length>0?{betas:n}:{},envContext:r,...process.env.CLAUDE_CODE_ENTRYPOINT&&{entrypoint:process.env.CLAUDE_CODE_ENTRYPOINT},...process.env.CLAUDE_AGENT_SDK_VERSION&&{agentSdkVersion:process.env.CLAUDE_AGENT_SDK_VERSION},isInteractive:String(ge()),clientType:me(),...a&&{processMetrics:a},sweBenchRunId:process.env.SWE_BENCH_RUN_ID||``,sweBenchInstanceId:process.env.SWE_BENCH_INSTANCE_ID||``,sweBenchTaskId:process.env.SWE_BENCH_TASK_ID||``,...St(),...Ie()&&{subscriptionType:Ie()},...i&&{rh:i}}}function Tt(e,t,n={}){let{envContext:r,processMetrics:i,rh:a,kairosActive:o,skillMode:s,observerMode:c,...l}=e,u={platform:r.platform,platform_raw:r.platformRaw,arch:r.arch,node_version:r.nodeVersion,terminal:r.terminal||`unknown`,package_managers:r.packageManagers,runtimes:r.runtimes,is_running_with_bun:r.isRunningWithBun,is_ci:r.isCi,is_claubbit:r.isClaubbit,is_claude_code_remote:r.isClaudeCodeRemote,is_local_agent_mode:r.isLocalAgentMode,is_conductor:r.isConductor,is_github_action:r.isGithubAction,is_claude_code_action:r.isClaudeCodeAction,is_claude_ai_auth:r.isClaudeAiAuth,version:r.version,build_time:r.buildTime,deployment_environment:r.deploymentEnvironment};r.remoteEnvironmentType&&(u.remote_environment_type=r.remoteEnvironmentType),r.claudeCodeContainerId&&(u.claude_code_container_id=r.claudeCodeContainerId),r.claudeCodeRemoteSessionId&&(u.claude_code_remote_session_id=r.claudeCodeRemoteSessionId),r.tags&&(u.tags=r.tags.split(`,`).map(e=>e.trim()).filter(Boolean)),r.githubEventName&&(u.github_event_name=r.githubEventName),r.githubActionsRunnerEnvironment&&(u.github_actions_runner_environment=r.githubActionsRunnerEnvironment),r.githubActionsRunnerOs&&(u.github_actions_runner_os=r.githubActionsRunnerOs),r.githubActionRef&&(u.github_action_ref=r.githubActionRef),r.wslVersion&&(u.wsl_version=r.wslVersion),r.linuxDistroId&&(u.linux_distro_id=r.linuxDistroId),r.linuxDistroVersion&&(u.linux_distro_version=r.linuxDistroVersion),r.linuxKernel&&(u.linux_kernel=r.linuxKernel),r.vcs&&(u.vcs=r.vcs),r.versionBase&&(u.version_base=r.versionBase);let d={session_id:l.sessionId,model:l.model,user_type:l.userType,is_interactive:l.isInteractive===`true`,client_type:l.clientType};if(l.betas&&(d.betas=l.betas),l.entrypoint&&(d.entrypoint=l.entrypoint),l.agentSdkVersion&&(d.agent_sdk_version=l.agentSdkVersion),l.sweBenchRunId&&(d.swe_bench_run_id=l.sweBenchRunId),l.sweBenchInstanceId&&(d.swe_bench_instance_id=l.sweBenchInstanceId),l.sweBenchTaskId&&(d.swe_bench_task_id=l.sweBenchTaskId),l.agentId&&(d.agent_id=l.agentId),l.parentSessionId&&(d.parent_session_id=l.parentSessionId),l.agentType&&(d.agent_type=l.agentType),t.githubActionsMetadata){let e=t.githubActionsMetadata;u.github_actions_metadata={actor_id:e.actorId,repository_id:e.repositoryId,repository_owner_id:e.repositoryOwnerId}}let f;return(t.accountUuid||t.organizationUuid)&&(f={account_uuid:t.accountUuid,organization_uuid:t.organizationUuid}),{env:u,...i&&{process:Buffer.from(xe(i)).toString(`base64`)},...f&&{auth:f},core:d,additional:{...a&&{rh:a},...o&&{is_assistant_mode:!0},...s&&{skill_mode:s},...c&&{observer_mode:c},...n}}}var Et,Dt,Ot,j,M,kt,At,jt,Mt,Nt,Pt,Ft,N,P,It=e((()=>{n(),Ce(),at(),ze(),Re(),he(),i(),ct(),Fe(),De(),Me(),pt(),ye(),Et=new Set,Dt=512,Ot=128,j=4*1024,M=20,kt=2,At=10,jt=new Set([`rm`,`mv`,`cp`,`touch`,`mkdir`,`chmod`,`chown`,`cat`,`head`,`tail`,`sort`,`stat`,`diff`,`wc`,`grep`,`rg`,`sed`]),Mt=/\s*(?:&&|\|\||[;|])\s*/,Nt=/\s+/,Pt=t(()=>{let e=`0.0.9`.match(/^\d+\.\d+\.\d+(?:-[a-z]+)?/);return e?e[0]:void 0}),Ft=t(async()=>{let[e,t,n,i]=await Promise.all([C.getPackageManagers(),C.getRuntimes(),Ne(),je()]);return{platform:Te(),platformRaw:process.env.CLAUDE_CODE_HOST_PLATFORM||process.platform,arch:C.arch,nodeVersion:C.nodeVersion,terminal:E.terminal,packageManagers:e.join(`,`),runtimes:t.join(`,`),isRunningWithBun:C.isRunningWithBun(),isCi:r(process.env.CI),isClaubbit:r(process.env.CLAUBBIT),isClaudeCodeRemote:r(process.env.CLAUDE_CODE_REMOTE),isLocalAgentMode:process.env.CLAUDE_CODE_ENTRYPOINT===`local-agent`,isConductor:C.isConductor(),...process.env.CLAUDE_CODE_REMOTE_ENVIRONMENT_TYPE&&{remoteEnvironmentType:process.env.CLAUDE_CODE_REMOTE_ENVIRONMENT_TYPE},...process.env.CLAUDE_CODE_CONTAINER_ID&&{claudeCodeContainerId:process.env.CLAUDE_CODE_CONTAINER_ID},...process.env.CLAUDE_CODE_REMOTE_SESSION_ID&&{claudeCodeRemoteSessionId:process.env.CLAUDE_CODE_REMOTE_SESSION_ID},...process.env.CLAUDE_CODE_TAGS&&{tags:process.env.CLAUDE_CODE_TAGS},isGithubAction:r(process.env.GITHUB_ACTIONS),isClaudeCodeAction:r(process.env.CLAUDE_CODE_ACTION),isClaudeAiAuth:Le(),version:`0.0.9`,versionBase:Pt(),buildTime:`2026-08-12T05:56:45.170Z`,deploymentEnvironment:C.detectDeploymentEnvironment(),...r(process.env.GITHUB_ACTIONS)&&{githubEventName:process.env.GITHUB_EVENT_NAME,githubActionsRunnerEnvironment:process.env.RUNNER_ENVIRONMENT,githubActionsRunnerOs:process.env.RUNNER_OS,githubActionRef:process.env.GITHUB_ACTION_PATH?.includes(`claude-code-action/`)?process.env.GITHUB_ACTION_PATH.split(`claude-code-action/`)[1]:void 0},...Ae()&&{wslVersion:Ae()},...n??{},...i.length>0?{vcs:i.join(`,`)}:{}}}),N=null,P=null}));function Lt(e){return e.setValue(zt,!0)}function Rt(e){return e.getValue(zt)===!0}var zt,Bt=e((()=>{f(),zt=c(`OpenTelemetry SDK Context Key SUPPRESS_TRACING`)}));function Vt(e){let t={};if(typeof e!=`object`||!e)return t;for(let n in e){if(!Object.prototype.hasOwnProperty.call(e,n))continue;if(!Ht(n)){p.warn(`Invalid attribute key: ${n}`);continue}let r=e[n];if(!Ut(r)){p.warn(`Invalid attribute value set for key: ${n}`);continue}Array.isArray(r)?t[n]=r.slice():t[n]=r}return t}function Ht(e){return typeof e==`string`&&e!==``}function Ut(e){return e==null?!0:Array.isArray(e)?Wt(e):Gt(typeof e)}function Wt(e){let t;for(let n of e){if(n==null)continue;let e=typeof n;if(e!==t){if(!t){if(Gt(e)){t=e;continue}return!1}return!1}}return!0}function Gt(e){switch(e){case`number`:case`boolean`:case`string`:return!0}return!1}var Kt=e((()=>{f()}));function qt(){return e=>{p.error(Jt(e))}}function Jt(e){return typeof e==`string`?e:JSON.stringify(Yt(e))}function Yt(e){let t={},n=e;for(;n!==null;)Object.getOwnPropertyNames(n).forEach(e=>{if(t[e])return;let r=n[e];r&&(t[e]=String(r))}),n=Object.getPrototypeOf(n);return t}var Xt=e((()=>{f()}));function Zt(e){try{Qt(e)}catch{}}var Qt,$t=e((()=>{Xt(),Qt=qt()}));function en(e){let t=process.env[e];if(t==null||t.trim()===``)return;let n=Number(t);if(isNaN(n)){p.warn(`Unknown value ${Ye(t)} for ${e}, expected a number, using defaults`);return}return n}function F(e){let t=process.env[e];if(!(t==null||t.trim()===``))return t}var tn=e((()=>{f()})),nn,rn=e((()=>{nn=`2.9.0`})),an,on=e((()=>{an=`process.runtime.name`})),I,sn=e((()=>{rn(),x(),on(),I={[g]:`opentelemetry`,[an]:`node`,[_]:ie,[y]:nn}})),L,cn=e((()=>{tn(),sn(),L=performance})),ln=e((()=>{cn()}));function R(e){let t=e/1e3;return[Math.trunc(t),Math.round(e%1e3*vn)]}function un(e){return gn(R(L.timeOrigin),R(typeof e==`number`?e:L.now()))}function dn(e,t){let n=t[0]-e[0],r=t[1]-e[1];return r<0&&(--n,r+=z),[n,r]}function fn(e){return e[0]*1e6+e[1]/1e3}function pn(e){return e[0]+e[1]/z}function mn(e){return Array.isArray(e)&&e.length===2&&typeof e[0]==`number`&&typeof e[1]==`number`}function hn(e){return mn(e)||typeof e==`number`||e instanceof Date}function gn(e,t){let n=[e[0]+t[0],e[1]+t[1]];return n[1]>=z&&(n[1]-=z,n[0]+=1),n}var _n,vn,z,yn=e((()=>{ln(),_n=9,vn=10**6,z=10**_n})),B,bn=e((()=>{(function(e){e[e.SUCCESS=0]=`SUCCESS`,e[e.FAILED=1]=`FAILED`})(B||(B={}))}));function xn(e){if(!Sn(e)||Cn(e)!==En)return!1;let t=An(e);if(t===null)return!0;let n=U.call(t,`constructor`)&&t.constructor;return typeof n==`function`&&n instanceof n&&V.call(n)===kn}function Sn(e){return typeof e==`object`&&!!e}function Cn(e){return e==null?e===void 0?On:Dn:W&&W in Object(e)?wn(e):Tn(e)}function wn(e){let t=U.call(e,W),n=e[W],r=!1;try{e[W]=void 0,r=!0}catch{}let i=G.call(e);return r&&(t?e[W]=n:delete e[W]),i}function Tn(e){return G.call(e)}var En,Dn,On,V,kn,An,H,U,W,G,jn=e((()=>{En=`[object Object]`,Dn=`[object Null]`,On=`[object Undefined]`,V=Function.prototype.toString,kn=V.call(Object),An=Object.getPrototypeOf,H=Object.prototype,U=H.hasOwnProperty,W=Symbol?Symbol.toStringTag:void 0,G=H.toString}));function Mn(...e){let t=e.shift(),n=new WeakMap;for(;e.length>0;)t=Nn(t,e.shift(),0,n);return t}function K(e){return q(e)?e.slice():e}function Nn(e,t,n=0,r){let i;if(!(n>Ln)){if(n++,Y(e)||Y(t)||Fn(t))i=K(t);else if(q(e)){if(i=e.slice(),q(t))for(let e=0,n=t.length;e<n;e++)i.push(K(t[e]));else if(J(t)){let e=Object.keys(t);for(let n=0,r=e.length;n<r;n++){let r=e[n];r===`__proto__`||r===`constructor`||r===`prototype`||(i[r]=K(t[r]))}}}else if(J(e))if(J(t)){if(!In(e,t))return t;i=Object.assign({},e);let a=Object.keys(t);for(let o=0,s=a.length;o<s;o++){let s=a[o];if(s===`__proto__`||s===`constructor`||s===`prototype`)continue;let c=t[s];if(Y(c))c===void 0?delete i[s]:i[s]=c;else{let a=i[s],o=c;if(Pn(e,s,r)||Pn(t,s,r))delete i[s];else{if(J(a)&&J(o)){let n=r.get(a)||[],i=r.get(o)||[];n.push({obj:e,key:s}),i.push({obj:t,key:s}),r.set(a,n),r.set(o,i)}i[s]=Nn(i[s],c,n,r)}}}}else i=t;return i}}function Pn(e,t,n){let r=n.get(e[t])||[];for(let n=0,i=r.length;n<i;n++){let i=r[n];if(i.key===t&&i.obj===e)return!0}return!1}function q(e){return Array.isArray(e)}function Fn(e){return typeof e==`function`}function J(e){return!Y(e)&&!q(e)&&!Fn(e)&&typeof e==`object`}function Y(e){return typeof e==`string`||typeof e==`number`||typeof e==`boolean`||e===void 0||e instanceof Date||e instanceof RegExp||e===null}function In(e,t){return!(!xn(e)||!xn(t))}var Ln,Rn=e((()=>{jn(),Ln=20})),zn,Bn=e((()=>{a(),zn=class{constructor(){o(this,`_promise`,void 0),o(this,`_resolve`,void 0),o(this,`_reject`,void 0),this._promise=new Promise((e,t)=>{this._resolve=e,this._reject=t})}get promise(){return this._promise}resolve(e){this._resolve(e)}reject(e){this._reject(e)}}})),Vn,Hn=e((()=>{Bn(),a(),Vn=class{constructor(e,t){o(this,`_isCalled`,!1),o(this,`_deferred`,new zn),o(this,`_callback`,void 0),o(this,`_that`,void 0),this._callback=e,this._that=t}get isCalled(){return this._isCalled}get promise(){return this._deferred.promise}call(...e){if(!this._isCalled){this._isCalled=!0;try{Promise.resolve(this._callback.call(this._that,...e)).then(e=>this._deferred.resolve(e),e=>this._deferred.reject(e))}catch(e){this._deferred.reject(e)}}return this._deferred.promise}}}));function Un(e,t){return new Promise(n=>{d.with(Lt(d.active()),()=>{e.export(t,n)})})}var Wn=e((()=>{f(),Bt()})),Gn,X=e((()=>{Bt(),Kt(),$t(),Xt(),yn(),bn(),ln(),Rn(),Hn(),Wn(),Gn={_export:Un}}));function Kn(){if(Z===void 0)try{let e=globalThis.process.argv0;Z=e?`unknown_service:${e}`:`unknown_service`}catch{Z=`unknown_service`}return Z}var Z,qn=e((()=>{})),Q,Jn=e((()=>{Q=e=>typeof e==`object`&&!!e&&typeof e.then==`function`}));function Yn(e,t){return er.FromAttributeList(Object.entries(e),t)}function Xn(){return Yn({[ue]:Kn(),[_]:I[_],[g]:I[g],[y]:I[y]})}function Zn(e){return e.map(([e,t])=>Q(t)?[e,t.catch(t=>{p.debug(`promise rejection for resource attribute: %s - %s`,e,t)})]:[e,t])}function Qn(e){if(typeof e==`string`||e===void 0)return e;p.warn(`Schema URL must be string or undefined, got %s. Schema URL will be ignored.`,e)}function $n(e,t){let n=e?.schemaUrl,r=t?.schemaUrl,i=n===void 0||n===``,a=r===void 0||r===``;if(i)return r;if(a||n===r)return n;p.warn(`Schema URL merge conflict: old resource has "%s", updating resource has "%s". Resulting resource will have undefined Schema URL.`,n,r)}var er,tr=e((()=>{f(),X(),x(),qn(),Jn(),a(),er=class e{static FromAttributeList(t,n){let r=new e({},n);return r._rawAttributes=Zn(t),r._asyncAttributesPending=t.filter(([e,t])=>Q(t)).length>0,r}constructor(e,t){o(this,`_rawAttributes`,void 0),o(this,`_asyncAttributesPending`,!1),o(this,`_schemaUrl`,void 0),o(this,`_memoizedAttributes`,void 0);let n=e.attributes??{};this._rawAttributes=Object.entries(n).map(([e,t])=>(Q(t)&&(this._asyncAttributesPending=!0),[e,t])),this._rawAttributes=Zn(this._rawAttributes),this._schemaUrl=Qn(t?.schemaUrl)}get asyncAttributesPending(){return this._asyncAttributesPending}async waitForAsyncAttributes(){if(this.asyncAttributesPending){for(let e=0;e<this._rawAttributes.length;e++){let[t,n]=this._rawAttributes[e];this._rawAttributes[e]=[t,Q(n)?await n:n]}this._asyncAttributesPending=!1}}get attributes(){if(this.asyncAttributesPending&&p.error(`Accessing resource attributes before async attributes settled`),this._memoizedAttributes)return this._memoizedAttributes;let e={};for(let[t,n]of this._rawAttributes){if(Q(n)){p.debug(`Unsettled resource attribute ${t} skipped`);continue}n!=null&&(e[t]??(e[t]=n))}return this._asyncAttributesPending||(this._memoizedAttributes=e),e}getRawAttributes(){return this._rawAttributes}get schemaUrl(){return this._schemaUrl}merge(t){if(t==null)return this;let n=$n(this,t),r=n?{schemaUrl:n}:void 0;return e.FromAttributeList([...t.getRawAttributes(),...this.getRawAttributes()],r)}}})),nr,rr,ir=e((()=>{f(),x(),X(),a(),nr=class{constructor(){o(this,`_MAX_LENGTH`,255),o(this,`_COMMA_SEPARATOR`,`,`),o(this,`_LABEL_KEY_VALUE_SPLITTER`,`=`)}detect(e){let t={},n=F(`OTEL_RESOURCE_ATTRIBUTES`),r=F(`OTEL_SERVICE_NAME`);if(n)try{let e=this._parseResourceAttributes(n);Object.assign(t,e)}catch(e){p.debug(`EnvDetector failed: ${e instanceof Error?e.message:e}`)}return r&&(t[ue]=r),{attributes:t}}_parseResourceAttributes(e){if(!e)return{};let t={},n=e.split(this._COMMA_SEPARATOR).filter(e=>e.trim()!==``);for(let e of n){let n=e.split(this._LABEL_KEY_VALUE_SPLITTER);if(n.length!==2)throw Error(`Invalid format for OTEL_RESOURCE_ATTRIBUTES: "${e}". Expected format: key=value. The ',' and '=' characters must be percent-encoded in keys and values.`);let[r,i]=n,a=r.trim(),o=i.trim();if(a.length===0)throw Error(`Invalid OTEL_RESOURCE_ATTRIBUTES: empty attribute key in "${e}".`);let s,c;try{s=decodeURIComponent(a),c=decodeURIComponent(o)}catch(t){throw Error(`Failed to percent-decode OTEL_RESOURCE_ATTRIBUTES entry "${e}": ${t instanceof Error?t.message:t}`,{cause:t})}if(s.length>this._MAX_LENGTH)throw Error(`Attribute key exceeds the maximum length of ${this._MAX_LENGTH} characters: "${s}".`);if(c.length>this._MAX_LENGTH)throw Error(`Attribute value exceeds the maximum length of ${this._MAX_LENGTH} characters for key "${s}".`);t[s]=c}return t}},rr=new nr})),ar,or,sr,cr,lr,ur=e((()=>{ar=`host.arch`,or=`host.id`,sr=`host.name`,cr=`os.type`,lr=`os.version`}));async function dr(){if(!$)switch(Xe.platform){case`darwin`:$=(await import(`./getMachineId-darwin-CsRhaP3y.js`)).getMachineId;break;case`linux`:$=(await import(`./getMachineId-linux-Bd7UBNRQ.js`)).getMachineId;break;case`freebsd`:$=(await import(`./getMachineId-bsd-Cut1kHoA.js`)).getMachineId;break;case`win32`:$=(await import(`./getMachineId-win-DamF2CH_.js`)).getMachineId;break;default:$=(await import(`./getMachineId-unsupported-vFGP8E_8.js`)).getMachineId;break}return $()}var $,fr=e((()=>{})),pr,mr,hr=e((()=>{pr=e=>{switch(e){case`arm`:return`arm32`;case`ppc`:return`ppc32`;case`x64`:return`amd64`;default:return e}},mr=e=>{switch(e){case`sunos`:return`solaris`;case`win32`:return`windows`;default:return e}}})),gr,_r,vr=e((()=>{ur(),fr(),hr(),gr=class{detect(e){return{attributes:{[sr]:We(),[ar]:pr(Ue()),[or]:dr()}}}},_r=new gr})),yr,br,xr=e((()=>{ur(),hr(),yr=class{detect(e){return{attributes:{[cr]:mr(Ge()),[lr]:Ke()}}}},br=new yr})),Sr=e((()=>{vr(),xr(),ur()})),Cr=e((()=>{Sr()})),wr=e((()=>{ir(),Cr()})),Tr=e((()=>{tr(),wr(),qn()}));function Er(e){return Dr(e,new WeakSet)}function Dr(e,t){if(e==null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`||e instanceof Uint8Array)return!0;if(typeof e==`object`){if(t.has(e))return!1;if(t.add(e),Array.isArray(e))return e.every(e=>Dr(e,t));let n=e;return n.constructor!==Object&&n.constructor!==void 0?!1:Object.values(n).every(e=>Dr(e,t))}return!1}var Or=e((()=>{})),kr,Ar=e((()=>{f(),b(),x(),Or(),a(),kr=class{set severityText(e){this._isLogRecordReadonly()||(this._severityText=e)}get severityText(){return this._severityText}set severityNumber(e){this._isLogRecordReadonly()||(this._severityNumber=e)}get severityNumber(){return this._severityNumber}set body(e){this._isLogRecordReadonly()||(this._body=e)}get body(){return this._body}get eventName(){return this._eventName}set eventName(e){this._isLogRecordReadonly()||(this._eventName=e)}get droppedAttributesCount(){return this._droppedAttributesCount}constructor(e,t,n){o(this,`hrTime`,void 0),o(this,`hrTimeObserved`,void 0),o(this,`spanContext`,void 0),o(this,`resource`,void 0),o(this,`instrumentationScope`,void 0),o(this,`attributes`,{}),o(this,`_severityText`,void 0),o(this,`_severityNumber`,void 0),o(this,`_body`,void 0),o(this,`_eventName`,void 0),o(this,`_attributesCount`,0),o(this,`_droppedAttributesCount`,0),o(this,`_isReadonly`,!1),o(this,`_logRecordLimits`,void 0);let{timestamp:r,observedTimestamp:i,eventName:a,severityNumber:s,severityText:c,body:l,attributes:d={},exception:f,context:p}=n,h=Date.now();if(this.hrTime=ne(r??h),this.hrTimeObserved=ne(i??h),p){let e=u.getSpanContext(p);e&&m(e)&&(this.spanContext=e)}this.severityNumber=s,this.severityText=c,this.body=l,this.resource=e.resource,this.instrumentationScope=t,this._logRecordLimits=e.logRecordLimits,this._eventName=a,this.setAttributes(d),f!=null&&this._setException(f)}setAttribute(e,t){if(this._isLogRecordReadonly())return this;if(e.length===0)return p.warn(`Invalid attribute key: ${e}`),this;if(!Er(t))return p.warn(`Invalid attribute value set for key: ${e}`),this;let n=!Object.prototype.hasOwnProperty.call(this.attributes,e);return n&&this._attributesCount>=this._logRecordLimits.attributeCountLimit?(this._droppedAttributesCount++,this._droppedAttributesCount===1&&p.warn(`Dropping extra attributes.`),this):(this.attributes[e]=this._truncateToSize(t),n&&this._attributesCount++,this)}setAttributes(e){for(let[t,n]of Object.entries(e))this.setAttribute(t,n);return this}setBody(e){return this.body=e,this}setEventName(e){return this.eventName=e,this}setSeverityNumber(e){return this.severityNumber=e,this}setSeverityText(e){return this.severityText=e,this}_makeReadonly(){this._isReadonly=!0}_truncateToSize(e){let t=this._logRecordLimits.attributeValueLengthLimit;if(t<=0)return p.warn(`Attribute value limit must be positive, got ${t}`),e;if(e==null)return e;if(typeof e==`string`)return this._truncateToLimitUtil(e,t);if(e instanceof Uint8Array)return e;if(Array.isArray(e))return e.map(e=>this._truncateToSize(e));if(typeof e==`object`){let t={};for(let[n,r]of Object.entries(e))t[n]=this._truncateToSize(r);return t}return e}_setException(e){let t=!1;if(typeof e==`string`||typeof e==`number`)Object.hasOwn(this.attributes,`exception.message`)||this.setAttribute(de,String(e)),t=!0;else if(e&&typeof e==`object`){let n=e;n.code?(Object.hasOwn(this.attributes,`exception.type`)||this.setAttribute(h,n.code.toString()),t=!0):n.name&&(Object.hasOwn(this.attributes,`exception.type`)||this.setAttribute(h,n.name),t=!0),n.message&&(Object.hasOwn(this.attributes,`exception.message`)||this.setAttribute(de,n.message),t=!0),n.stack&&(Object.hasOwn(this.attributes,`exception.stacktrace`)||this.setAttribute(ee,n.stack),t=!0)}t||p.warn(`Failed to record an exception ${e}`)}_truncateToLimitUtil(e,t){return e.length<=t?e:e.substring(0,t)}_isLogRecordReadonly(){return this._isReadonly&&p.warn(`Can not execute the operation on emitted log record`),this._isReadonly}}})),jr,Mr=e((()=>{pe(),f(),Ar(),a(),jr=class{constructor(e,t){o(this,`instrumentationScope`,void 0),o(this,`_sharedState`,void 0),o(this,`_loggerConfig`,void 0),this.instrumentationScope=e,this._sharedState=t,this._loggerConfig=this._sharedState.getLoggerConfig(this.instrumentationScope)}emit(e){let t=this._loggerConfig,n=e.context||d.active(),r=e.severityNumber??S.UNSPECIFIED;if(r!==S.UNSPECIFIED&&r<t.minimumSeverity)return;if(t.traceBased){let e=u.getSpanContext(n);if(e&&m(e)&&(e.traceFlags&l.SAMPLED)!==l.SAMPLED)return}let i=new kr(this._sharedState,this.instrumentationScope,{context:n,...e});this._sharedState.loggerMetrics.emitLog(),this._sharedState.activeProcessor.onEmit(i,n),i._makeReadonly()}enabled(e){let t=this._loggerConfig;if(t.disabled)return!1;let n=e?.severityNumber;if(typeof n==`number`&&n!==S.UNSPECIFIED&&n<t.minimumSeverity)return!1;let r=e?.context||d.active();if(t.traceBased){let e=u.getSpanContext(r);if(e&&m(e)&&(e.traceFlags&l.SAMPLED)!==l.SAMPLED)return!1}let i={context:r,instrumentationScope:this.instrumentationScope,severityNumber:e?.severityNumber,eventName:e?.eventName};for(let e of this._sharedState.processors)if(!e.enabled||e.enabled(i))return!0;return!1}}})),Nr,Pr=e((()=>{Nr=class{forceFlush(){return Promise.resolve()}onEmit(e,t){}shutdown(){return Promise.resolve()}enabled(e){return!1}}})),Fr,Ir=e((()=>{b(),a(),Fr=class{constructor(e,t){o(this,`processors`,void 0),o(this,`forceFlushTimeoutMillis`,void 0),this.processors=e,this.forceFlushTimeoutMillis=t}async forceFlush(){let e=this.forceFlushTimeoutMillis;await Promise.all(this.processors.map(t=>ae(t.forceFlush(),e)))}onEmit(e,t){this.processors.forEach(n=>n.onEmit(e,t))}async shutdown(){await Promise.all(this.processors.map(e=>e.shutdown()))}enabled(e){for(let t of this.processors)if(!t.enabled||t.enabled(e))return!0;return!1}}}));function Lr(e){return`${e.name}@${e.version||``}:${e.schemaUrl||``}`}var Rr=e((()=>{})),zr,Br=e((()=>{zr=`otel.sdk.log.created`})),Vr,Hr=e((()=>{Br(),a(),Vr=class{constructor(e){o(this,`createdLogs`,void 0),this.createdLogs=e.createCounter(zr,{unit:`{log_record}`,description:`The number of logs submitted to enabled SDK Loggers.`})}emitLog(){this.createdLogs.add(1)}}})),Ur,Wr=e((()=>{Ur=`0.215.0`})),Gr,Kr,qr,Jr=e((()=>{f(),pe(),Pr(),Ir(),Rr(),Hr(),Wr(),a(),Gr={disabled:!1,minimumSeverity:S.UNSPECIFIED,traceBased:!1},Kr=()=>({...Gr}),qr=class{constructor(e,t,n,r,i,a){o(this,`loggers`,new Map),o(this,`activeProcessor`,void 0),o(this,`registeredLogRecordProcessors`,[]),o(this,`resource`,void 0),o(this,`forceFlushTimeoutMillis`,void 0),o(this,`logRecordLimits`,void 0),o(this,`processors`,void 0),o(this,`loggerMetrics`,void 0),o(this,`_loggerConfigurator`,void 0),o(this,`_loggerConfigs`,new Map),this.resource=e,this.forceFlushTimeoutMillis=t,this.logRecordLimits=n,this.processors=r,r.length>0?(this.registeredLogRecordProcessors=r,this.activeProcessor=new Fr(this.registeredLogRecordProcessors,this.forceFlushTimeoutMillis)):this.activeProcessor=new Nr,this._loggerConfigurator=i??Kr;let c=a?a.getMeter(`@opentelemetry/sdk-logs`,Ur):s();this.loggerMetrics=new Vr(c)}getLoggerConfig(e){let t=Lr(e),n=this._loggerConfigs.get(t);return n||(n=this._loggerConfigurator(e),this._loggerConfigs.set(t,n),n)}}})),Yr,Xr=e((()=>{f(),pe(),le(),b(),Mr(),Jr(),a(),Yr=class{constructor(e={}){o(this,`_shutdownOnce`,void 0),o(this,`_sharedState`,void 0);let t={resource:e.resource??oe(),forceFlushTimeoutMillis:e.forceFlushTimeoutMillis??3e4,logRecordLimits:{attributeCountLimit:e.logRecordLimits?.attributeCountLimit??128,attributeValueLengthLimit:e.logRecordLimits?.attributeValueLengthLimit??1/0},loggerConfigurator:e.loggerConfigurator??Kr,processors:e.processors??[],meterProvider:e.meterProvider};this._sharedState=new qr(t.resource,t.forceFlushTimeoutMillis,t.logRecordLimits,t.processors,t.loggerConfigurator,t.meterProvider),this._shutdownOnce=new ce(this._shutdown,this)}getLogger(e,t,n){if(this._shutdownOnce.isCalled)return p.warn(`A shutdown LoggerProvider cannot provide a Logger`),fe;e||p.warn(`Logger requested without instrumentation scope name.`);let r=e||`unknown`,i=`${r}@${t||``}:${n?.schemaUrl||``}`;return this._sharedState.loggers.has(i)||this._sharedState.loggers.set(i,new jr({name:r,version:t,schemaUrl:n?.schemaUrl},this._sharedState)),this._sharedState.loggers.get(i)}forceFlush(){return this._shutdownOnce.isCalled?(p.warn(`invalid attempt to force flush after LoggerProvider shutdown`),this._shutdownOnce.promise):this._sharedState.activeProcessor.forceFlush()}shutdown(){return this._shutdownOnce.isCalled?(p.warn(`shutdown may only be called once per LoggerProvider`),this._shutdownOnce.promise):this._shutdownOnce.call()}_shutdown(){return this._sharedState.activeProcessor.shutdown()}}})),Zr,Qr=e((()=>{b(),Zr=class{export(e,t){this._sendLogRecords(e,t)}async forceFlush(){}async shutdown(){}_exportInfo(e){return{resource:{attributes:e.resource.attributes},instrumentationScope:e.instrumentationScope,timestamp:se(e.hrTime),traceId:e.spanContext?.traceId,spanId:e.spanContext?.spanId,traceFlags:e.spanContext?.traceFlags,severityText:e.severityText,severityNumber:e.severityNumber,eventName:e.eventName,body:e.body,attributes:e.attributes}}_sendLogRecords(e,t){for(let t of e)console.dir(this._exportInfo(t),{depth:3});t?.({code:re.SUCCESS})}}}));async function $r(e){let t=[];for(let n=0,r=e.length;n<r;n++){let r=e[n];r.resource.asyncAttributesPending&&r.resource.waitForAsyncAttributes&&t.push(r.resource.waitForAsyncAttributes())}t!=null&&t.length>0&&await Promise.all(t)}var ei,ti,ni=e((()=>{f(),b(),a(),ei=class{constructor(e,t,n){o(this,`_exportCompleted`,void 0),o(this,`_exportScheduledPromise`,void 0),o(this,`_exportScheduledResolve`,void 0),this._exportScheduledPromise=new Promise(e=>{this._exportScheduledResolve=e}),this._exportCompleted=this._executeExport(e,t,n)}get exportCompleted(){return this._exportCompleted}get exportScheduled(){return this._exportScheduledPromise}async _executeExport(e,t,n){try{await $r(t),await d.with(te(d.active()),async()=>this._exportWithTimeout(e,t,n))}catch(e){v(e),this._exportScheduledResolve()}}async _exportWithTimeout(e,t,n){return new Promise((r,i)=>{let a=setTimeout(()=>{i(Error(`Timeout`))},n);e.export(t,e=>{clearTimeout(a),e.code===re.SUCCESS?r():i(e.error??Error(`BatchLogRecordProcessor: log record export failed`))}),this._exportScheduledResolve()})}},ti=class{constructor(e,t){o(this,`_maxExportBatchSize`,void 0),o(this,`_maxQueueSize`,void 0),o(this,`_scheduledDelayMillis`,void 0),o(this,`_exportTimeoutMillis`,void 0),o(this,`_exporter`,void 0),o(this,`_currentExport`,null),o(this,`_finishedLogRecords`,[]),o(this,`_timer`,void 0),o(this,`_shutdownOnce`,void 0),o(this,`_flushing`,!1),this._exporter=e,this._maxExportBatchSize=t?.maxExportBatchSize??512,this._maxQueueSize=t?.maxQueueSize??2048,this._scheduledDelayMillis=t?.scheduledDelayMillis??5e3,this._exportTimeoutMillis=t?.exportTimeoutMillis??3e4,this._shutdownOnce=new ce(this._shutdown,this),this._maxExportBatchSize>this._maxQueueSize&&(p.warn(`BatchLogRecordProcessor: maxExportBatchSize must be smaller or equal to maxQueueSize, setting maxExportBatchSize to match maxQueueSize`),this._maxExportBatchSize=this._maxQueueSize)}onEmit(e){this._shutdownOnce.isCalled||this._addToBuffer(e)}forceFlush(){return this._shutdownOnce.isCalled?this._shutdownOnce.promise:this._flushAll()}_addToBuffer(e){this._finishedLogRecords.length>=this._maxQueueSize||(this._finishedLogRecords.push(e),this._maybeStartTimer())}shutdown(){return this._shutdownOnce.call()}async _shutdown(){this.onShutdown(),await this._flushAll(),await this._exporter.shutdown()}async _flushAll(){if(this._flushing)return;this._flushing=!0;let e=this._finishedLogRecords;for(this._finishedLogRecords=[],this._clearTimer(),this._currentExport!==null&&(await this._exporter.forceFlush(),await this._currentExport.exportCompleted,this._currentExport=null);e.length>0;){let t;e.length<=this._maxExportBatchSize?(t=e,e=[]):t=e.splice(0,this._maxExportBatchSize);let n=new ei(this._exporter,t,this._exportTimeoutMillis);this._currentExport=n;try{await n.exportScheduled,await this._exporter.forceFlush(),await n.exportCompleted}catch(e){v(e)}finally{this._currentExport=null}}this._flushing=!1,this._maybeStartTimer()}_extractBatch(){if(this._finishedLogRecords.length===0)return null;if(this._finishedLogRecords.length<=this._maxExportBatchSize){let e=this._finishedLogRecords;return this._finishedLogRecords=[],e}else return this._finishedLogRecords.splice(0,this._maxExportBatchSize)}_exportOneBatch(){this._clearTimer();let e=this._extractBatch();if(e===null)return;let t=new ei(this._exporter,e,this._exportTimeoutMillis);this._currentExport=t,t.exportCompleted.then(()=>{this._currentExport=null,this._maybeStartTimer()}).catch(e=>{this._currentExport=null,v(e),this._maybeStartTimer()})}_maybeStartTimer(){if(!this._shutdownOnce.isCalled&&!this._flushing&&this._finishedLogRecords.length!==0&&this._currentExport===null){if(this._finishedLogRecords.length>=this._maxExportBatchSize){this._exportOneBatch();return}this._timer===void 0&&(this._timer=setTimeout(()=>{this._timer=void 0,this._exportOneBatch()},this._scheduledDelayMillis),typeof this._timer!=`number`&&this._timer.unref())}}_clearTimer(){this._timer!==void 0&&(clearTimeout(this._timer),this._timer=void 0)}}})),ri,ii=e((()=>{ni(),ri=class extends ti{onShutdown(){}}})),ai=e((()=>{ii()})),oi=e((()=>{ai()})),si=e((()=>{Xr(),Qr(),oi()}));export{xt as $,pn as A,Zt as B,Mn as C,un as D,gn as E,cn as F,Bt as G,Kt as H,L as I,vt as J,Rt as K,en as L,hn as M,mn as N,dn as O,R as P,A as Q,F as R,Rn as S,bn as T,Ut as U,$t as V,Vt as W,bt as X,yt as Y,wt as Z,Yn as _,Qr as a,ft as at,Vn as b,Tr as c,pt as ct,_r as d,rt as dt,It as et,vr as f,at as ft,tr as g,Xn as h,Zr as i,Tt as it,yn as j,fn as k,xr as l,lt,ir as m,ri as n,_t as nt,Yr as o,D as ot,rr as p,Lt as q,ii as r,mt as rt,Xr as s,dt as st,si as t,ht as tt,br as u,E as ut,X as v,B as w,Hn as x,Gn as y,tn as z};
@@ -1 +0,0 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{S as t,T as n}from"./debug-BdqxZ7rV.js";import{execSync as r}from"child_process";function i(e,t){return n`execSync: ${e.slice(0,100)}`,r(e,t)}var a=e((()=>{t()}));export{a as n,i as t};
@@ -1 +0,0 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{Ac as t,SE as n,St as r,Tt as i,ff as a,kc as o,uf as s,xE as c}from"./loadAgentsDir-CKSb56Gp.js";import{fi as l}from"./src-P_wYS_NJ2.js";import{t as u}from"./jsx-runtime-Bb4Xn-E0.js";import{n as d,t as f}from"./ExitFlow-CoWHhKHJ.js";import{spawnSync as p}from"child_process";function m(){return n(_)??`Goodbye!`}async function h(e){if(t())return e(),p(`tmux`,[`detach-client`],{stdio:`ignore`}),null;let n=r()!==null;return n?(0,g.jsx)(f,{showWorktree:n,onDone:e,onCancel:()=>e()}):(e(m()),await s(0,`prompt_input_exit`),null)}var g,_;e((()=>{c(),l(),d(),o(),a(),i(),g=u(),_=[`Goodbye!`,`See ya!`,`Bye!`,`Catch you later!`]}))();export{h as call};
@@ -1 +0,0 @@
1
- import{Jc as e,Xc as t,Yc as n,qc as r}from"./loadAgentsDir-CKSb56Gp.js";t();export{r as drainPendingExtraction,e as executeExtractMemories,n as initExtractMemories};
@@ -1 +0,0 @@
1
- import{n as e,r as t,t as n}from"./fast-ClYQcEv5.js";t();export{n as FastModePicker,e as call};
@@ -1 +0,0 @@
1
- import{n as e,r as t,t as n}from"./featureCheck-HslM03dr.js";n();export{e as isSkillLearningCompiledIn,t as isSkillLearningEnabled};
@@ -1 +0,0 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";function t(){return!1}function n(){return process.env.SKILL_LEARNING_ENABLED===`1`||process.env.FEATURE_SKILL_LEARNING===`1`}var r=e((()=>{}));export{t as n,n as r,r as t};
@@ -1 +0,0 @@
1
- import{n as e,r as t}from"./firstPartyEventLogger-DhEPWcit.js";e();export{t as initialize1PEventLogging};
@@ -1,5 +0,0 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./memoize-BK3gG5ob.js";import{l as r,n as i,o as a}from"./envUtils-BDhHQY0-.js";import{n as o,t as s}from"./defineProperty-C-QyHrDq.js";import{T as c,w as l,y as u}from"./esm-Cb-L4oAk.js";import{n as d,t as f}from"./axios-DaWTGg7G.js";import{Kt as p,mt as m,z as ee}from"./state-Bs5xweDL.js";import{n as te,t as ne}from"./cwd-L4wygFqJ.js";import{F as re,H as ie,S as ae,W as oe,w as h,z as se}from"./debug-BdqxZ7rV.js";import{Jt as ce,qt as le}from"./settings-Xbq6AaD-.js";import{c as ue,d as g,h as _,n as de}from"./config-D4G8_MqJ.js";import{c as fe,o as pe}from"./execFileNoThrow-5SylUnAI.js";import{d as me,o as he,p as v,s as y}from"./log-CTFl4qpD.js";import{a as ge,i as _e,o as ve}from"./platform-D6IMiyqT.js";import{l as ye,s as be}from"./types-DWRxAH0E.js";import{i as xe,n as Se}from"./analytics-DJobLaWP.js";import{n as Ce,r as b}from"./startupProfiler-jeId9f2i.js";import{$n as we,Bt as x,Fr as Te,Ft as Ee,Gt as De,Ir as Oe,Nt as ke,Ot as Ae,_n as je,jt as S,nr as Me,vn as Ne,zt as Pe}from"./model-C2e73CJD.js";import{n as Fe,t as Ie}from"./userAgent-Ng_TTjWr.js";import{Z as Le,_ as Re,c as ze,et as C,it as Be,n as Ve,o as He,t as Ue,v as We,w}from"./esm-DcIr7tVd.js";import*as T from"path";import{randomUUID as E}from"crypto";import{appendFile as Ge,mkdir as D,readdir as Ke,unlink as O,writeFile as qe}from"fs/promises";function k(){return r(process.env.CLAUDE_CODE_USE_BEDROCK)||r(process.env.CLAUDE_CODE_USE_VERTEX)||r(process.env.CLAUDE_CODE_USE_FOUNDRY)||v()}function Je(){return v()}var A=e((()=>{a(),me()}));async function Ye(){j===null&&!M&&(M=Qe(),j=await M,M=null,N.cache.clear?.())}function Xe(){j=null,M=null,N.cache.clear?.(),P.cache.clear?.()}function Ze(){if(j!==null)return j;let e=S();if(e?.emailAddress)return e.emailAddress}async function Qe(){let e=S();if(e?.emailAddress)return e.emailAddress}var j,M,N,P,F=e((()=>{fe(),n(),p(),x(),_(),te(),ce(),a(),j=null,M=null,N=t(e=>{let t=g(),n=ue(),i,a,o;if(e&&(i=Ee()??void 0,a=ke()??void 0,i&&n.claudeCodeFirstTokenDate)){let e=new Date(n.claudeCodeFirstTokenDate).getTime();isNaN(e)||(o=e)}let s=S(),c=s?.organizationUuid,l=s?.accountUuid;return{deviceId:t,sessionId:m(),email:Ze(),appVersion:`0.0.9`,platform:le(),organizationUuid:c,accountUuid:l,userType:process.env.USER_TYPE,subscriptionType:i,rateLimitTier:a,firstTokenTime:o,...r(process.env.GITHUB_ACTIONS)&&{githubActionsMetadata:{actor:process.env.GITHUB_ACTOR,actorId:process.env.GITHUB_ACTOR_ID,repository:process.env.GITHUB_REPOSITORY,repositoryId:process.env.GITHUB_REPOSITORY_ID,repositoryOwner:process.env.GITHUB_REPOSITORY_OWNER,repositoryOwnerId:process.env.GITHUB_REPOSITORY_OWNER_ID}}}}),P=t(async()=>{let e=await pe(`git config --get user.email`,{shell:!0,reject:!1,cwd:ne()});return e.exitCode===0&&e.stdout?e.stdout.trim():void 0})}));function $e(){return{seconds:0,nanos:0}}function I(e){return e!=null}var L,et=e((()=>{L={fromJSON(e){return{seconds:I(e.seconds)?globalThis.Number(e.seconds):0,nanos:I(e.nanos)?globalThis.Number(e.nanos):0}},toJSON(e){let t={};return e.seconds!==void 0&&(t.seconds=Math.round(e.seconds)),e.nanos!==void 0&&(t.nanos=Math.round(e.nanos)),t},create(e){return L.fromPartial(e??{})},fromPartial(e){let t=$e();return t.seconds=e.seconds??0,t.nanos=e.nanos??0,t}}}));function tt(){return{account_id:0,organization_uuid:``,account_uuid:``}}function R(e){return e!=null}var z,nt=e((()=>{z={fromJSON(e){return{account_id:R(e.account_id)?globalThis.Number(e.account_id):0,organization_uuid:R(e.organization_uuid)?globalThis.String(e.organization_uuid):``,account_uuid:R(e.account_uuid)?globalThis.String(e.account_uuid):``}},toJSON(e){let t={};return e.account_id!==void 0&&(t.account_id=Math.round(e.account_id)),e.organization_uuid!==void 0&&(t.organization_uuid=e.organization_uuid),e.account_uuid!==void 0&&(t.account_uuid=e.account_uuid),t},create(e){return z.fromPartial(e??{})},fromPartial(e){let t=tt();return t.account_id=e.account_id??0,t.organization_uuid=e.organization_uuid??``,t.account_uuid=e.account_uuid??``,t}}}));function rt(){return{actor_id:``,repository_id:``,repository_owner_id:``}}function it(){return{platform:``,node_version:``,terminal:``,package_managers:``,runtimes:``,is_running_with_bun:!1,is_ci:!1,is_claubbit:!1,is_github_action:!1,is_claude_code_action:!1,is_claude_ai_auth:!1,version:``,github_event_name:``,github_actions_runner_environment:``,github_actions_runner_os:``,github_action_ref:``,wsl_version:``,github_actions_metadata:void 0,arch:``,is_claude_code_remote:!1,remote_environment_type:``,claude_code_container_id:``,claude_code_remote_session_id:``,tags:[],deployment_environment:``,is_conductor:!1,version_base:``,coworker_type:``,build_time:``,is_local_agent_mode:!1,linux_distro_id:``,linux_distro_version:``,linux_kernel:``,vcs:``,platform_raw:``}}function at(){return{slack_team_id:``,is_enterprise_install:!1,trigger:``,creation_method:``}}function ot(){return{event_name:``,client_timestamp:void 0,model:``,session_id:``,user_type:``,betas:``,env:void 0,entrypoint:``,agent_sdk_version:``,is_interactive:!1,client_type:``,process:``,additional_metadata:``,auth:void 0,server_timestamp:void 0,event_id:``,device_id:``,swe_bench_run_id:``,swe_bench_instance_id:``,swe_bench_task_id:``,email:``,agent_id:``,parent_session_id:``,agent_type:``,slack:void 0,team_name:``,skill_name:``,plugin_name:``,marketplace_name:``}}function st(e){let t=(e.seconds||0)*1e3;return t+=(e.nanos||0)/1e6,new globalThis.Date(t)}function B(e){return e instanceof globalThis.Date?e:typeof e==`string`?new globalThis.Date(e):st(L.fromJSON(e))}function V(e){return e!=null}var H,U,W,G,ct=e((()=>{et(),nt(),H={fromJSON(e){return{actor_id:V(e.actor_id)?globalThis.String(e.actor_id):``,repository_id:V(e.repository_id)?globalThis.String(e.repository_id):``,repository_owner_id:V(e.repository_owner_id)?globalThis.String(e.repository_owner_id):``}},toJSON(e){let t={};return e.actor_id!==void 0&&(t.actor_id=e.actor_id),e.repository_id!==void 0&&(t.repository_id=e.repository_id),e.repository_owner_id!==void 0&&(t.repository_owner_id=e.repository_owner_id),t},create(e){return H.fromPartial(e??{})},fromPartial(e){let t=rt();return t.actor_id=e.actor_id??``,t.repository_id=e.repository_id??``,t.repository_owner_id=e.repository_owner_id??``,t}},U={fromJSON(e){return{platform:V(e.platform)?globalThis.String(e.platform):``,node_version:V(e.node_version)?globalThis.String(e.node_version):``,terminal:V(e.terminal)?globalThis.String(e.terminal):``,package_managers:V(e.package_managers)?globalThis.String(e.package_managers):``,runtimes:V(e.runtimes)?globalThis.String(e.runtimes):``,is_running_with_bun:V(e.is_running_with_bun)?globalThis.Boolean(e.is_running_with_bun):!1,is_ci:V(e.is_ci)?globalThis.Boolean(e.is_ci):!1,is_claubbit:V(e.is_claubbit)?globalThis.Boolean(e.is_claubbit):!1,is_github_action:V(e.is_github_action)?globalThis.Boolean(e.is_github_action):!1,is_claude_code_action:V(e.is_claude_code_action)?globalThis.Boolean(e.is_claude_code_action):!1,is_claude_ai_auth:V(e.is_claude_ai_auth)?globalThis.Boolean(e.is_claude_ai_auth):!1,version:V(e.version)?globalThis.String(e.version):``,github_event_name:V(e.github_event_name)?globalThis.String(e.github_event_name):``,github_actions_runner_environment:V(e.github_actions_runner_environment)?globalThis.String(e.github_actions_runner_environment):``,github_actions_runner_os:V(e.github_actions_runner_os)?globalThis.String(e.github_actions_runner_os):``,github_action_ref:V(e.github_action_ref)?globalThis.String(e.github_action_ref):``,wsl_version:V(e.wsl_version)?globalThis.String(e.wsl_version):``,github_actions_metadata:V(e.github_actions_metadata)?H.fromJSON(e.github_actions_metadata):void 0,arch:V(e.arch)?globalThis.String(e.arch):``,is_claude_code_remote:V(e.is_claude_code_remote)?globalThis.Boolean(e.is_claude_code_remote):!1,remote_environment_type:V(e.remote_environment_type)?globalThis.String(e.remote_environment_type):``,claude_code_container_id:V(e.claude_code_container_id)?globalThis.String(e.claude_code_container_id):``,claude_code_remote_session_id:V(e.claude_code_remote_session_id)?globalThis.String(e.claude_code_remote_session_id):``,tags:globalThis.Array.isArray(e?.tags)?e.tags.map(e=>globalThis.String(e)):[],deployment_environment:V(e.deployment_environment)?globalThis.String(e.deployment_environment):``,is_conductor:V(e.is_conductor)?globalThis.Boolean(e.is_conductor):!1,version_base:V(e.version_base)?globalThis.String(e.version_base):``,coworker_type:V(e.coworker_type)?globalThis.String(e.coworker_type):``,build_time:V(e.build_time)?globalThis.String(e.build_time):``,is_local_agent_mode:V(e.is_local_agent_mode)?globalThis.Boolean(e.is_local_agent_mode):!1,linux_distro_id:V(e.linux_distro_id)?globalThis.String(e.linux_distro_id):``,linux_distro_version:V(e.linux_distro_version)?globalThis.String(e.linux_distro_version):``,linux_kernel:V(e.linux_kernel)?globalThis.String(e.linux_kernel):``,vcs:V(e.vcs)?globalThis.String(e.vcs):``,platform_raw:V(e.platform_raw)?globalThis.String(e.platform_raw):``}},toJSON(e){let t={};return e.platform!==void 0&&(t.platform=e.platform),e.node_version!==void 0&&(t.node_version=e.node_version),e.terminal!==void 0&&(t.terminal=e.terminal),e.package_managers!==void 0&&(t.package_managers=e.package_managers),e.runtimes!==void 0&&(t.runtimes=e.runtimes),e.is_running_with_bun!==void 0&&(t.is_running_with_bun=e.is_running_with_bun),e.is_ci!==void 0&&(t.is_ci=e.is_ci),e.is_claubbit!==void 0&&(t.is_claubbit=e.is_claubbit),e.is_github_action!==void 0&&(t.is_github_action=e.is_github_action),e.is_claude_code_action!==void 0&&(t.is_claude_code_action=e.is_claude_code_action),e.is_claude_ai_auth!==void 0&&(t.is_claude_ai_auth=e.is_claude_ai_auth),e.version!==void 0&&(t.version=e.version),e.github_event_name!==void 0&&(t.github_event_name=e.github_event_name),e.github_actions_runner_environment!==void 0&&(t.github_actions_runner_environment=e.github_actions_runner_environment),e.github_actions_runner_os!==void 0&&(t.github_actions_runner_os=e.github_actions_runner_os),e.github_action_ref!==void 0&&(t.github_action_ref=e.github_action_ref),e.wsl_version!==void 0&&(t.wsl_version=e.wsl_version),e.github_actions_metadata!==void 0&&(t.github_actions_metadata=H.toJSON(e.github_actions_metadata)),e.arch!==void 0&&(t.arch=e.arch),e.is_claude_code_remote!==void 0&&(t.is_claude_code_remote=e.is_claude_code_remote),e.remote_environment_type!==void 0&&(t.remote_environment_type=e.remote_environment_type),e.claude_code_container_id!==void 0&&(t.claude_code_container_id=e.claude_code_container_id),e.claude_code_remote_session_id!==void 0&&(t.claude_code_remote_session_id=e.claude_code_remote_session_id),e.tags?.length&&(t.tags=e.tags),e.deployment_environment!==void 0&&(t.deployment_environment=e.deployment_environment),e.is_conductor!==void 0&&(t.is_conductor=e.is_conductor),e.version_base!==void 0&&(t.version_base=e.version_base),e.coworker_type!==void 0&&(t.coworker_type=e.coworker_type),e.build_time!==void 0&&(t.build_time=e.build_time),e.is_local_agent_mode!==void 0&&(t.is_local_agent_mode=e.is_local_agent_mode),e.linux_distro_id!==void 0&&(t.linux_distro_id=e.linux_distro_id),e.linux_distro_version!==void 0&&(t.linux_distro_version=e.linux_distro_version),e.linux_kernel!==void 0&&(t.linux_kernel=e.linux_kernel),e.vcs!==void 0&&(t.vcs=e.vcs),e.platform_raw!==void 0&&(t.platform_raw=e.platform_raw),t},create(e){return U.fromPartial(e??{})},fromPartial(e){let t=it();return t.platform=e.platform??``,t.node_version=e.node_version??``,t.terminal=e.terminal??``,t.package_managers=e.package_managers??``,t.runtimes=e.runtimes??``,t.is_running_with_bun=e.is_running_with_bun??!1,t.is_ci=e.is_ci??!1,t.is_claubbit=e.is_claubbit??!1,t.is_github_action=e.is_github_action??!1,t.is_claude_code_action=e.is_claude_code_action??!1,t.is_claude_ai_auth=e.is_claude_ai_auth??!1,t.version=e.version??``,t.github_event_name=e.github_event_name??``,t.github_actions_runner_environment=e.github_actions_runner_environment??``,t.github_actions_runner_os=e.github_actions_runner_os??``,t.github_action_ref=e.github_action_ref??``,t.wsl_version=e.wsl_version??``,t.github_actions_metadata=e.github_actions_metadata!==void 0&&e.github_actions_metadata!==null?H.fromPartial(e.github_actions_metadata):void 0,t.arch=e.arch??``,t.is_claude_code_remote=e.is_claude_code_remote??!1,t.remote_environment_type=e.remote_environment_type??``,t.claude_code_container_id=e.claude_code_container_id??``,t.claude_code_remote_session_id=e.claude_code_remote_session_id??``,t.tags=e.tags?.map(e=>e)||[],t.deployment_environment=e.deployment_environment??``,t.is_conductor=e.is_conductor??!1,t.version_base=e.version_base??``,t.coworker_type=e.coworker_type??``,t.build_time=e.build_time??``,t.is_local_agent_mode=e.is_local_agent_mode??!1,t.linux_distro_id=e.linux_distro_id??``,t.linux_distro_version=e.linux_distro_version??``,t.linux_kernel=e.linux_kernel??``,t.vcs=e.vcs??``,t.platform_raw=e.platform_raw??``,t}},W={fromJSON(e){return{slack_team_id:V(e.slack_team_id)?globalThis.String(e.slack_team_id):``,is_enterprise_install:V(e.is_enterprise_install)?globalThis.Boolean(e.is_enterprise_install):!1,trigger:V(e.trigger)?globalThis.String(e.trigger):``,creation_method:V(e.creation_method)?globalThis.String(e.creation_method):``}},toJSON(e){let t={};return e.slack_team_id!==void 0&&(t.slack_team_id=e.slack_team_id),e.is_enterprise_install!==void 0&&(t.is_enterprise_install=e.is_enterprise_install),e.trigger!==void 0&&(t.trigger=e.trigger),e.creation_method!==void 0&&(t.creation_method=e.creation_method),t},create(e){return W.fromPartial(e??{})},fromPartial(e){let t=at();return t.slack_team_id=e.slack_team_id??``,t.is_enterprise_install=e.is_enterprise_install??!1,t.trigger=e.trigger??``,t.creation_method=e.creation_method??``,t}},G={fromJSON(e){return{event_name:V(e.event_name)?globalThis.String(e.event_name):``,client_timestamp:V(e.client_timestamp)?B(e.client_timestamp):void 0,model:V(e.model)?globalThis.String(e.model):``,session_id:V(e.session_id)?globalThis.String(e.session_id):``,user_type:V(e.user_type)?globalThis.String(e.user_type):``,betas:V(e.betas)?globalThis.String(e.betas):``,env:V(e.env)?U.fromJSON(e.env):void 0,entrypoint:V(e.entrypoint)?globalThis.String(e.entrypoint):``,agent_sdk_version:V(e.agent_sdk_version)?globalThis.String(e.agent_sdk_version):``,is_interactive:V(e.is_interactive)?globalThis.Boolean(e.is_interactive):!1,client_type:V(e.client_type)?globalThis.String(e.client_type):``,process:V(e.process)?globalThis.String(e.process):``,additional_metadata:V(e.additional_metadata)?globalThis.String(e.additional_metadata):``,auth:V(e.auth)?z.fromJSON(e.auth):void 0,server_timestamp:V(e.server_timestamp)?B(e.server_timestamp):void 0,event_id:V(e.event_id)?globalThis.String(e.event_id):``,device_id:V(e.device_id)?globalThis.String(e.device_id):``,swe_bench_run_id:V(e.swe_bench_run_id)?globalThis.String(e.swe_bench_run_id):``,swe_bench_instance_id:V(e.swe_bench_instance_id)?globalThis.String(e.swe_bench_instance_id):``,swe_bench_task_id:V(e.swe_bench_task_id)?globalThis.String(e.swe_bench_task_id):``,email:V(e.email)?globalThis.String(e.email):``,agent_id:V(e.agent_id)?globalThis.String(e.agent_id):``,parent_session_id:V(e.parent_session_id)?globalThis.String(e.parent_session_id):``,agent_type:V(e.agent_type)?globalThis.String(e.agent_type):``,slack:V(e.slack)?W.fromJSON(e.slack):void 0,team_name:V(e.team_name)?globalThis.String(e.team_name):``,skill_name:V(e.skill_name)?globalThis.String(e.skill_name):``,plugin_name:V(e.plugin_name)?globalThis.String(e.plugin_name):``,marketplace_name:V(e.marketplace_name)?globalThis.String(e.marketplace_name):``}},toJSON(e){let t={};return e.event_name!==void 0&&(t.event_name=e.event_name),e.client_timestamp!==void 0&&(t.client_timestamp=e.client_timestamp.toISOString()),e.model!==void 0&&(t.model=e.model),e.session_id!==void 0&&(t.session_id=e.session_id),e.user_type!==void 0&&(t.user_type=e.user_type),e.betas!==void 0&&(t.betas=e.betas),e.env!==void 0&&(t.env=U.toJSON(e.env)),e.entrypoint!==void 0&&(t.entrypoint=e.entrypoint),e.agent_sdk_version!==void 0&&(t.agent_sdk_version=e.agent_sdk_version),e.is_interactive!==void 0&&(t.is_interactive=e.is_interactive),e.client_type!==void 0&&(t.client_type=e.client_type),e.process!==void 0&&(t.process=e.process),e.additional_metadata!==void 0&&(t.additional_metadata=e.additional_metadata),e.auth!==void 0&&(t.auth=z.toJSON(e.auth)),e.server_timestamp!==void 0&&(t.server_timestamp=e.server_timestamp.toISOString()),e.event_id!==void 0&&(t.event_id=e.event_id),e.device_id!==void 0&&(t.device_id=e.device_id),e.swe_bench_run_id!==void 0&&(t.swe_bench_run_id=e.swe_bench_run_id),e.swe_bench_instance_id!==void 0&&(t.swe_bench_instance_id=e.swe_bench_instance_id),e.swe_bench_task_id!==void 0&&(t.swe_bench_task_id=e.swe_bench_task_id),e.email!==void 0&&(t.email=e.email),e.agent_id!==void 0&&(t.agent_id=e.agent_id),e.parent_session_id!==void 0&&(t.parent_session_id=e.parent_session_id),e.agent_type!==void 0&&(t.agent_type=e.agent_type),e.slack!==void 0&&(t.slack=W.toJSON(e.slack)),e.team_name!==void 0&&(t.team_name=e.team_name),e.skill_name!==void 0&&(t.skill_name=e.skill_name),e.plugin_name!==void 0&&(t.plugin_name=e.plugin_name),e.marketplace_name!==void 0&&(t.marketplace_name=e.marketplace_name),t},create(e){return G.fromPartial(e??{})},fromPartial(e){let t=ot();return t.event_name=e.event_name??``,t.client_timestamp=e.client_timestamp??void 0,t.model=e.model??``,t.session_id=e.session_id??``,t.user_type=e.user_type??``,t.betas=e.betas??``,t.env=e.env!==void 0&&e.env!==null?U.fromPartial(e.env):void 0,t.entrypoint=e.entrypoint??``,t.agent_sdk_version=e.agent_sdk_version??``,t.is_interactive=e.is_interactive??!1,t.client_type=e.client_type??``,t.process=e.process??``,t.additional_metadata=e.additional_metadata??``,t.auth=e.auth!==void 0&&e.auth!==null?z.fromPartial(e.auth):void 0,t.server_timestamp=e.server_timestamp??void 0,t.event_id=e.event_id??``,t.device_id=e.device_id??``,t.swe_bench_run_id=e.swe_bench_run_id??``,t.swe_bench_instance_id=e.swe_bench_instance_id??``,t.swe_bench_task_id=e.swe_bench_task_id??``,t.email=e.email??``,t.agent_id=e.agent_id??``,t.parent_session_id=e.parent_session_id??``,t.agent_type=e.agent_type??``,t.slack=e.slack!==void 0&&e.slack!==null?W.fromPartial(e.slack):void 0,t.team_name=e.team_name??``,t.skill_name=e.skill_name??``,t.plugin_name=e.plugin_name??``,t.marketplace_name=e.marketplace_name??``,t}}}));function K(){return T.join(i(),`telemetry`)}function lt(e){if(!d.isAxiosError(e))return re(e);let t=[],n=e.response?.headers?.[`request-id`];return n&&t.push(`request-id=${n}`),e.response?.status&&t.push(`status=${e.response.status}`),e.code&&t.push(`code=${e.code}`),e.message&&t.push(e.message),t.join(`, `)}var q,J,Y,ut=e((()=>{We(),f(),p(),ct(),x(),_(),a(),se(),Me(),be(),he(),je(),ae(),Fe(),Te(),Se(),C(),o(),q=E(),J=`1p_failed_events.`,Y=class{constructor(e={}){s(this,`endpoint`,void 0),s(this,`timeout`,void 0),s(this,`maxBatchSize`,void 0),s(this,`skipAuth`,void 0),s(this,`batchDelayMs`,void 0),s(this,`baseBackoffDelayMs`,void 0),s(this,`maxBackoffDelayMs`,void 0),s(this,`maxAttempts`,void 0),s(this,`isKilled`,void 0),s(this,`pendingExports`,[]),s(this,`isShutdown`,!1),s(this,`schedule`,void 0),s(this,`cancelBackoff`,null),s(this,`attempts`,0),s(this,`isRetrying`,!1),s(this,`lastExportErrorContext`,void 0);let t=e.baseUrl||(process.env.ANTHROPIC_BASE_URL===`https://api-staging.anthropic.com`?`https://api-staging.anthropic.com`:`https://api.anthropic.com`);this.endpoint=`${t}${e.path||`/api/event_logging/batch`}`,this.timeout=e.timeout||1e4,this.maxBatchSize=e.maxBatchSize||200,this.skipAuth=e.skipAuth??!1,this.batchDelayMs=e.batchDelayMs||100,this.baseBackoffDelayMs=e.baseBackoffDelayMs||500,this.maxBackoffDelayMs=e.maxBackoffDelayMs||3e4,this.maxAttempts=e.maxAttempts??8,this.isKilled=e.isKilled??(()=>!1),this.schedule=e.schedule??((e,t)=>{let n=setTimeout(e,t);return()=>clearTimeout(n)}),this.retryPreviousBatches()}async getQueuedEventCount(){return(await this.loadEventsFromCurrentBatch()).length}getCurrentBatchFilePath(){return T.join(K(),`${J}${m()}.${q}.json`)}async loadEventsFromFile(e){try{return await ye(e)}catch{return[]}}async loadEventsFromCurrentBatch(){return this.loadEventsFromFile(this.getCurrentBatchFilePath())}async saveEventsToFile(e,t){try{if(t.length===0)try{await O(e)}catch{}else await D(K(),{recursive:!0}),await qe(e,t.map(e=>h(e)).join(`
2
- `)+`
3
- `,`utf8`)}catch(e){y(e)}}async appendEventsToFile(e,t){if(t.length!==0)try{await D(K(),{recursive:!0}),await Ge(e,t.map(e=>h(e)).join(`
4
- `)+`
5
- `,`utf8`)}catch(e){y(e)}}async deleteFile(e){try{await O(e)}catch{}}async retryPreviousBatches(){try{let e=`${J}${m()}.`,t;try{t=(await Ke(K())).filter(t=>t.startsWith(e)&&t.endsWith(`.json`)).filter(e=>!e.includes(q))}catch(e){if(ie(e))return;throw e}for(let e of t){let t=T.join(K(),e);this.retryFileInBackground(t)}}catch(e){y(e)}}async retryFileInBackground(e){if(this.attempts>=this.maxAttempts){await this.deleteFile(e);return}let t=await this.loadEventsFromFile(e);if(t.length===0){await this.deleteFile(e);return}let n=await this.sendEventsInBatches(t);n.length===0?await this.deleteFile(e):await this.saveEventsToFile(e,n)}async export(e,t){if(this.isShutdown){t({code:w.FAILED,error:Error(`Exporter has been shutdown`)});return}let n=this.doExport(e,t);this.pendingExports.push(n),n.finally(()=>{let e=this.pendingExports.indexOf(n);e>-1&&this.pendingExports.splice(e,1)})}async doExport(e,t){try{let n=e.filter(e=>e.instrumentationScope?.name===`com.anthropic.claude_code.events`);if(n.length===0){t({code:w.SUCCESS});return}let r=this.transformLogsToEvents(n).events;if(r.length===0){t({code:w.SUCCESS});return}if(this.attempts>=this.maxAttempts){t({code:w.FAILED,error:Error(`Dropped ${r.length} events: max attempts (${this.maxAttempts}) reached`)});return}let i=await this.sendEventsInBatches(r);if(this.attempts++,i.length>0){await this.queueFailedEvents(i),this.scheduleBackoffRetry();let e=this.lastExportErrorContext?` (${this.lastExportErrorContext})`:``;t({code:w.FAILED,error:Error(`Failed to export ${i.length} events${e}`)});return}this.resetBackoff(),await this.getQueuedEventCount()>0&&!this.isRetrying&&this.retryFailedEvents(),t({code:w.SUCCESS})}catch(e){y(e),t({code:w.FAILED,error:oe(e)})}}async sendEventsInBatches(e){let t=[];for(let n=0;n<e.length;n+=this.maxBatchSize)t.push(e.slice(n,n+this.maxBatchSize));let n=[],r;for(let e=0;e<t.length;e++){let i=t[e];try{await this.sendBatchWithRetry({events:i})}catch(i){r=lt(i);for(let r=e;r<t.length;r++)n.push(...t[r]);break}e<t.length-1&&this.batchDelayMs>0&&await Ne(this.batchDelayMs)}return n.length>0&&r&&(this.lastExportErrorContext=r),n}async queueFailedEvents(e){let t=this.getCurrentBatchFilePath();await this.appendEventsToFile(t,e);let n=this.lastExportErrorContext?` (${this.lastExportErrorContext})`:``,r=`1P event logging: ${e.length} events failed to export${n}`;y(Error(r))}scheduleBackoffRetry(){if(this.cancelBackoff||this.isRetrying||this.isShutdown)return;let e=Math.min(this.baseBackoffDelayMs*this.attempts*this.attempts,this.maxBackoffDelayMs);this.cancelBackoff=this.schedule(async()=>{this.cancelBackoff=null,await this.retryFailedEvents()},e)}async retryFailedEvents(){let e=this.getCurrentBatchFilePath();for(;!this.isShutdown;){let t=await this.loadEventsFromFile(e);if(t.length===0)break;if(this.attempts>=this.maxAttempts){await this.deleteFile(e),this.resetBackoff();return}this.isRetrying=!0,await this.deleteFile(e);let n=await this.sendEventsInBatches(t);if(this.attempts++,this.isRetrying=!1,n.length>0){await this.saveEventsToFile(e,n),this.scheduleBackoffRetry();return}this.resetBackoff()}}resetBackoff(){this.attempts=0,this.cancelBackoff&&(this.cancelBackoff(),this.cancelBackoff=null)}async sendBatchWithRetry(e){if(this.isKilled())throw Error(`firstParty sink killswitch active`);let t={"Content-Type":`application/json`,"User-Agent":Ie(),"x-service-name":`claude-code`},n=de()||ee(),r=this.skipAuth||!n;if(!r&&De()){let e=Ae();Pe()?e&&Oe(e.expiresAt)&&(r=!0):r=!0}let i=r?{headers:{},error:`trust not established or Oauth token expired`}:we(),a=!i.error,o=a?{...t,...i.headers}:t;try{let t=await d.post(this.endpoint,e,{timeout:this.timeout,headers:o});this.logSuccess(e.events.length,a,t.data);return}catch(n){if(a&&d.isAxiosError(n)&&n.response?.status===401){let n=await d.post(this.endpoint,e,{timeout:this.timeout,headers:t});this.logSuccess(e.events.length,!1,n.data);return}throw n}}logSuccess(e,t,n){}hrTimeToDate(e){let[t,n]=e;return new Date(t*1e3+n/1e6)}transformLogsToEvents(e){let t=[];for(let n of e){let e=n.attributes||{},r=e.event_name||n.body||`unknown`,i=e.core_metadata,a=e.user_metadata,o=e.event_metadata||{};if(!i){t.push({event_type:`ClaudeCodeInternalEvent`,event_data:G.toJSON({event_id:e.event_id,event_name:r,client_timestamp:this.hrTimeToDate(n.hrTime),session_id:m(),additional_metadata:Buffer.from(h({transform_error:`core_metadata attribute is missing`})).toString(`base64`)})});continue}let s=Be(i,a,o),{_PROTO_skill_name:c,_PROTO_plugin_name:l,_PROTO_marketplace_name:u,...d}=s.additional,f=xe(d);t.push({event_type:`ClaudeCodeInternalEvent`,event_data:G.toJSON({event_id:e.event_id,event_name:r,client_timestamp:this.hrTimeToDate(n.hrTime),device_id:e.user_id,email:a?.email,auth:s.auth,...s.core,env:s.env,process:s.process,skill_name:typeof c==`string`?c:void 0,plugin_name:typeof l==`string`?l:void 0,marketplace_name:typeof u==`string`?u:void 0,additional_metadata:Object.keys(f).length>0?Buffer.from(h(f)).toString(`base64`):void 0})})}return{events:t}}async shutdown(){this.isShutdown=!0,this.resetBackoff(),await this.forceFlush()}async forceFlush(){await Promise.all(this.pendingExports)}}}));function X(e){return!1}var dt=e((()=>{}));function ft(){return{}}function pt(e){let t=ft()[e];if(!t)return null;let n=t.sample_rate;return typeof n!=`number`||n<0||n>1||n>=1?null:n<=0?0:Math.random()<n?n:0}async function mt(){if($)try{await $.shutdown()}catch{}}function Z(){return!k()}async function ht(e,t,n={}){try{let r=await Le({model:n.model,betas:n.betas}),i={event_name:t,event_id:E(),core_metadata:r,user_metadata:N(!0),event_metadata:n},a=g();a&&(i.user_id=a),e.emit({body:t,attributes:i})}catch{}}function gt(e,t={}){Z()&&(!Q||X(`firstParty`)||ht(Q,e,t))}function _t(){if(b(`1p_event_logging_start`),!Z())return;b(`1p_event_after_config`);let e=parseInt(process.env.OTEL_LOGS_EXPORT_INTERVAL||vt.toString(),10),t=yt,n=bt,r=_e(),i={[l]:`claude-code`,[c]:`0.0.9`};if(r===`wsl`){let e=ge();e&&(i[`wsl.version`]=e)}$=new He({resource:Re(i),processors:[new Ve(new Y({maxBatchSize:t,isKilled:()=>X(`firstParty`)}),{scheduledDelayMillis:e,maxExportBatchSize:t,maxQueueSize:n})]}),Q=$.getLogger(`com.anthropic.claude_code.events`,`0.0.9`)}var vt,yt,bt,Q,$,xt=e((()=>{ze(),Ue(),u(),_(),ve(),Ce(),F(),A(),ut(),C(),dt(),vt=1e4,yt=200,bt=8192,Q=null,$=null}));export{gt as a,P as c,Xe as d,A as f,Z as i,Ye as l,Je as m,xt as n,pt as o,k as p,_t as r,mt as s,ft as t,F as u};
@@ -1 +0,0 @@
1
- import{n as e,t}from"./defineProperty-C-QyHrDq.js";import{A as n,C as r,m as i,w as a}from"./external-CEp-aPkt.js";import{n as o,r as s,t as c}from"./lazySchema-B4D4qJVE.js";import{F as l,a as u,l as d,z as f}from"./debug-BdqxZ7rV.js";import{B as p,I as m,L as h,V as g,d as _}from"./sessionState-BvECKycx.js";import{i as v}from"./workSecret-DtiFreRl.js";import{t as y}from"./ccrClient-CG6HTv_n.js";import{n as b,t as x}from"./SSETransport-1KBBUikF.js";s(),c(),p(),_();var S={init_retry_max_attempts:3,init_retry_base_delay_ms:500,init_retry_jitter_fraction:.25,init_retry_max_delay_ms:4e3,http_timeout_ms:1e4,uuid_dedup_buffer_size:2e3,heartbeat_interval_ms:2e4,heartbeat_jitter_fraction:.1,token_refresh_buffer_ms:3e5,teardown_archive_timeout_ms:1500,connect_timeout_ms:15e3,min_version:`0.0.0`,should_show_app_upgrade_message:!1},C=o(()=>a({init_retry_max_attempts:r().int().min(1).max(10).default(3),init_retry_base_delay_ms:r().int().min(100).default(500),init_retry_jitter_fraction:r().min(0).max(1).default(.25),init_retry_max_delay_ms:r().int().min(500).default(4e3),http_timeout_ms:r().int().min(2e3).default(1e4),uuid_dedup_buffer_size:r().int().min(100).max(5e4).default(2e3),heartbeat_interval_ms:r().int().min(5e3).max(3e4).default(2e4),heartbeat_jitter_fraction:r().min(0).max(.5).default(.1),token_refresh_buffer_ms:r().int().min(3e4).max(18e5).default(3e5),teardown_archive_timeout_ms:r().int().min(500).max(2e3).default(1500),connect_timeout_ms:r().int().min(5e3).max(6e4).default(15e3),min_version:n().refine(e=>{try{return g(e,`0.0.0`),!0}catch{return!1}}).default(`0.0.0`),should_show_app_upgrade_message:i().default(!1)}));async function w(){let e=S,t=C().safeParse(e);return t.success?t.data:S}async function T(){let e=await w();return e.min_version&&g(`0.0.9`,e.min_version)?`Your version of Work Mate (0.0.9) is too old for Remote Control.\nVersion ${e.min_version} or higher is required. Run \`claude update\` to update.`:null}b(),u(),f(),m();function E(e){return{write:t=>e.write(t),writeBatch:t=>e.writeBatch(t),close:()=>e.close(),isConnectedStatus:()=>e.isConnectedStatus(),getStateLabel:()=>e.getStateLabel(),setOnData:t=>e.setOnData(t),setOnClose:t=>e.setOnClose(t),setOnConnect:t=>e.setOnConnect(t),connect:()=>void e.connect(),getLastSequenceNum:()=>0,get droppedBatchCount(){return e.droppedBatchCount},reportState:()=>{},reportMetadata:()=>{},reportDelivery:()=>{},flush:()=>Promise.resolve()}}async function D(e){let{sessionUrl:t,ingressToken:n,sessionId:r,initialSequenceNum:i,getAuthToken:a}=e,o;a?o=()=>{let e=a();return e?{Authorization:`Bearer ${e}`}:{}}:h(n);let s=e.epoch??await v(t,n);d(`[bridge:repl] CCR v2: worker sessionId=${r} epoch=${s}${e.epoch===void 0?` (via registerWorker)`:` (from /bridge)`}`);let c=new URL(t);c.pathname=c.pathname.replace(/\/$/,``)+`/worker/events/stream`;let u=new x(c,{},r,void 0,i,o),f,p=new y(u,new URL(t),{getAuthHeaders:o,heartbeatIntervalMs:e.heartbeatIntervalMs,heartbeatJitterFraction:e.heartbeatJitterFraction,onEpochMismatch:()=>{d(`[bridge:repl] CCR v2: epoch superseded (409) — closing for poll-loop recovery`);try{p.close(),u.close(),f?.(4090)}catch(e){d(`[bridge:repl] CCR v2: error during epoch-mismatch cleanup: ${l(e)}`,{level:`error`})}throw Error(`epoch superseded`)}});u.setOnEvent(e=>{p.reportDelivery(e.event_id,`received`),p.reportDelivery(e.event_id,`processed`)});let m,g=!1,_=!1;return{write(e){return p.writeEvent(e)},async writeBatch(e){for(let t of e){if(_)break;await p.writeEvent(t)}},close(){_=!0,p.close(),u.close()},isConnectedStatus(){return g},getStateLabel(){return u.isClosedStatus()?`closed`:u.isConnectedStatus()?g?`connected`:`init`:`connecting`},setOnData(e){u.setOnData(e)},setOnClose(e){f=e,u.setOnClose(t=>{p.close(),e(t??4092)})},setOnConnect(e){m=e},getLastSequenceNum(){return u.getLastSequenceNum()},droppedBatchCount:0,reportState(e){p.reportState(e)},reportMetadata(e){p.reportMetadata(e)},reportDelivery(e,t){p.reportDelivery(e,t)},flush(){return p.flush()},connect(){e.outboundOnly||u.connect(),p.initialize(s).then(()=>{g=!0,d(`[bridge:repl] v2 transport ready for writes (epoch=${s}, sse=${u.isConnectedStatus()?`open`:`opening`})`),m?.()},e=>{d(`[bridge:repl] CCR v2 initialize failed: ${l(e)}`,{level:`error`}),p.close(),u.close(),f?.(4091)})}}}e();var O=class{constructor(){t(this,`_active`,!1),t(this,`_pending`,[])}get active(){return this._active}get pendingCount(){return this._pending.length}start(){this._active=!0}end(){return this._active=!1,this._pending.splice(0)}enqueue(...e){return this._active?(this._pending.push(...e),!0):!1}drop(){this._active=!1;let e=this._pending.length;return this._pending.length=0,e}deactivate(){this._active=!1}};export{w as a,T as i,E as n,D as r,O as t};
@@ -1 +0,0 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{Cc as t,Ia as n,Qa as r,Sc as i,Tc as a,Va as o}from"./loadAgentsDir-CKSb56Gp.js";import{G as s,Q as c,a as l,l as u}from"./debug-BdqxZ7rV.js";async function d(){try{let{getResolvedLanguage:e}=await import(`./language-C0cIpKE2.js`);return e()===`zh`?m:p}catch{return p}}async function f(e){let t=i();if(!t)return u(`[recap] no CacheSafeParams saved, skipping`),{kind:`no-turn`};let r=new AbortController;e.addEventListener(`abort`,()=>r.abort(),{once:!0});try{let{messages:i}=await a({promptMessages:[n({content:await d()})],cacheSafeParams:t,canUseTool:async()=>({behavior:`deny`,message:`Recap cannot use tools`,decisionReason:{type:`other`,reason:`away_summary`}}),overrides:{abortController:r},querySource:`away_summary`,forkLabel:`away_summary`,maxTurns:1,skipCacheWrite:!0,skipTranscript:!0});if(e.aborted)return{kind:`aborted`};let s=i.find(e=>e.type===`assistant`&&e.isApiErrorMessage);if(s)return{kind:`api-error`,text:o(s)??``};let c=i.filter(e=>e.type===`assistant`&&!e.isApiErrorMessage).pop();if(!c)return{kind:`failed`};let l=o(c);return!l||l.trim().length===0?{kind:`failed`}:{kind:`ok`,text:l.trim()}}catch(t){return t instanceof c||e.aborted||r.signal.aborted?{kind:`aborted`}:(u(`[recap] generation failed: ${t}`),{kind:`failed`})}}var p,m;e((()=>{s(),l(),t(),r(),p=`The user stepped away and is coming back. Recap in under 40 words, 1-2 plain sentences, no markdown. Lead with the overall goal and current task, then the one next action. Skip root-cause narrative, fix internals, secondary to-dos, and em-dash tangents.`,m=`用户离开后回来了。用中文写 1-2 句话,不超过 60 字,无 markdown。先说明高层目标和当前任务,再说明下一步操作。跳过根因分析和次要待办。`}))();export{f as generateRecap};
@@ -1 +0,0 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{$ as t,Qa as n,et as r,za as i,zg as a}from"./loadAgentsDir-CKSb56Gp.js";import{F as o,a as s,l as c,z as l}from"./debug-BdqxZ7rV.js";import{s as u,u as d}from"./types-DWRxAH0E.js";import{gt as f}from"./sessionState-BvECKycx.js";import{r as p,t as m}from"./sessionTitle-E1FvsKM9.js";async function h(e,t){let n=m(e);if(!n)return null;try{let e=await r({systemPrompt:f([`Generate a short kebab-case name (2-4 words) that captures the main topic of this conversation. Use lowercase words separated by hyphens. Examples: "fix-login-bug", "add-auth-feature", "refactor-api-client", "debug-test-failures". Return JSON with a "name" field.`]),userPrompt:n,outputFormat:{type:`json_schema`,schema:{type:`object`,properties:{name:{type:`string`}},required:[`name`],additionalProperties:!1}},signal:t,options:{querySource:`rename_generate_name`,agents:[],isNonInteractiveSession:!1,hasAppendSystemPrompt:!1,mcpTools:[]}}),a=d(Array.isArray(e.message.content)?i(e.message.content):e.message.content);return a&&typeof a==`object`&&`name`in a&&typeof a.name==`string`?a.name:null}catch(e){return c(`generateSessionName failed: ${o(e)}`,{level:`error`}),null}}var g=e((()=>{t(),s(),l(),u(),n(),p(),a()}));export{g as n,h as t};
@@ -1,6 +0,0 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./memoize-BK3gG5ob.js";import{n as r,t as i}from"./defineProperty-C-QyHrDq.js";import{Kt as a,dr as o}from"./state-Bs5xweDL.js";import{n as s,t as c}from"./cwd-L4wygFqJ.js";import{S as ee,a as te,d as l,nt as ne,p as u,rt as re,w as ie}from"./debug-BdqxZ7rV.js";import{r as ae,t as d}from"./execFileNoThrow-5SylUnAI.js";import{o as oe}from"./log-CTFl4qpD.js";import{n as f,t as se}from"./memoize-FJv2HV1u.js";import{r as ce,t as le}from"./which-DznMOwny.js";import{basename as ue,dirname as p,join as m,resolve as h,sep as g}from"path";import{readFileSync as _,realpathSync as v,statSync as y,unwatchFile as b,watchFile as de}from"fs";import{createHash as fe}from"crypto";import{readFile as x,readdir as pe,stat as me}from"fs/promises";function S(e,t,n){let r=he();if(!r)return;let i={timestamp:new Date().toISOString(),level:e,event:t,data:n??{}},a=l(),o=ie(i)+`
2
- `;try{a.appendFileSync(r,o)}catch{try{a.mkdirSync(p(r)),a.appendFileSync(r,o)}catch{}}}function he(){return process.env.CLAUDE_CODE_DIAGNOSTICS_FILE}async function ge(e,t,n){let r=Date.now();S(`info`,`${e}_started`);try{let i=await t(),a=n?n(i):{};return S(`info`,`${e}_completed`,{duration_ms:Date.now()-r,...a}),i}catch(t){throw S(`error`,`${e}_failed`,{duration_ms:Date.now()-r}),t}}var C=e((()=>{u(),ee()}));async function w(e,t,n,r){try{return _e(await x(m(e,`config`),`utf-8`),t,n,r)}catch{return null}}function _e(e,t,n,r){let i=e.split(`
3
- `),a=t.toLowerCase(),o=r.toLowerCase(),s=!1;for(let e of i){let t=e.trim();if(t.length===0||t[0]===`#`||t[0]===`;`)continue;if(t[0]===`[`){s=xe(t,a,n);continue}if(!s)continue;let r=ve(t);if(r&&r.key.toLowerCase()===o)return r.value}return null}function ve(e){let t=0;for(;t<e.length&&Se(e[t]);)t++;if(t===0)return null;let n=e.slice(0,t);for(;t<e.length&&(e[t]===` `||e[t]===` `);)t++;if(t>=e.length||e[t]!==`=`)return null;for(t++;t<e.length&&(e[t]===` `||e[t]===` `);)t++;return{key:n,value:ye(e,t)}}function ye(e,t){let n=``,r=!1,i=t;for(;i<e.length;){let t=e[i];if(!r&&(t===`#`||t===`;`))break;if(t===`"`){r=!r,i++;continue}if(t===`\\`&&i+1<e.length){let t=e[i+1];if(r){switch(t){case`n`:n+=`
4
- `;break;case`t`:n+=` `;break;case`b`:n+=`\b`;break;case`"`:n+=`"`;break;case`\\`:n+=`\\`;break;default:n+=t;break}i+=2;continue}if(t===`\\`){n+=`\\`,i+=2;continue}}n+=t,i++}return r||(n=be(n)),n}function be(e){let t=e.length;for(;t>0&&(e[t-1]===` `||e[t-1]===` `);)t--;return e.slice(0,t)}function xe(e,t,n){let r=1;for(;r<e.length&&e[r]!==`]`&&e[r]!==` `&&e[r]!==` `&&e[r]!==`"`;)r++;if(e.slice(1,r).toLowerCase()!==t)return!1;if(n===null)return r<e.length&&e[r]===`]`;for(;r<e.length&&(e[r]===` `||e[r]===` `);)r++;if(r>=e.length||e[r]!==`"`)return!1;r++;let i=``;for(;r<e.length&&e[r]!==`"`;){if(e[r]===`\\`&&r+1<e.length){let t=e[r+1];if(t===`\\`||t===`"`){i+=t,r+=2;continue}i+=t,r+=2;continue}i+=e[r],r++}return r>=e.length||e[r]!==`"`||(r++,r>=e.length||e[r]!==`]`)?!1:i===n}function Se(e){return e>=`a`&&e<=`z`||e>=`A`&&e<=`Z`||e>=`0`&&e<=`9`||e===`-`}var T=e((()=>{}));function Ce(){N.clear()}async function E(e){let t=h(e??c()),n=N.get(t);if(n!==void 0)return n;let r=V(t);if(!r)return N.set(t,null),null;let i=m(r,`.git`);try{if((await me(i)).isFile()){let e=(await x(i,`utf-8`)).trim();if(e.startsWith(`gitdir:`)){let n=h(r,e.slice(7).trim());return N.set(t,n),n}}return N.set(t,i),i}catch{return N.set(t,null),null}}function D(e){return!(!e||e.startsWith(`-`)||e.startsWith(`/`)||e.includes(`..`)||e.split(`/`).some(e=>e===`.`||e===``)||!/^[a-zA-Z0-9/._+@-]+$/.test(e))}function O(e){return/^[0-9a-f]{40}$/.test(e)||/^[0-9a-f]{64}$/.test(e)}async function k(e){try{let t=(await x(m(e,`HEAD`),`utf-8`)).trim();if(t.startsWith(`ref:`)){let n=t.slice(4).trim();if(n.startsWith(`refs/heads/`)){let e=n.slice(11);return D(e)?{type:`branch`,name:e}:null}if(!D(n))return null;let r=await A(e,n);return r?{type:`detached`,sha:r}:{type:`detached`,sha:``}}return O(t)?{type:`detached`,sha:t}:null}catch{return null}}async function A(e,t){let n=await j(e,t);if(n)return n;let r=await M(e);return r&&r!==e?j(r,t):null}async function j(e,t){try{let n=(await x(m(e,t),`utf-8`)).trim();if(n.startsWith(`ref:`)){let t=n.slice(4).trim();return D(t)?A(e,t):null}return O(n)?n:null}catch{}try{let n=await x(m(e,`packed-refs`),`utf-8`);for(let e of n.split(`
5
- `)){if(e.startsWith(`#`)||e.startsWith(`^`))continue;let n=e.indexOf(` `);if(n!==-1&&e.slice(n+1)===t){let t=e.slice(0,n);return O(t)?t:null}}}catch{}return null}async function M(e){try{return h(e,(await x(m(e,`commondir`),`utf-8`)).trim())}catch{return null}}async function we(e,t,n){try{let r=(await x(m(e,t),`utf-8`)).trim();if(r.startsWith(`ref:`)){let e=r.slice(4).trim();if(e.startsWith(n)){let t=e.slice(n.length);return D(t)?t:null}}}catch{}return null}async function Te(){let e=await E();if(!e)return`HEAD`;let t=await k(e);return t&&t.type===`branch`?t.name:`HEAD`}async function Ee(){let e=await E();if(!e)return null;let t=await w(e,`remote`,`origin`,`url`);if(t)return t;let n=await M(e);return n&&n!==e?w(n,`remote`,`origin`,`url`):null}async function De(){let e=await E();if(!e)return`main`;let t=await M(e)??e,n=await we(t,`refs/remotes/origin/HEAD`,`refs/remotes/origin/`);if(n)return n;for(let e of[`main`,`master`])if(await A(t,`refs/remotes/origin/${e}`))return e;return`main`}function Oe(){return I.get(`branch`,Te)}function ke(){return I.get(`remoteUrl`,Ee)}function Ae(){return I.get(`defaultBranch`,De)}async function je(e){let t=await E(e);if(!t)return null;let n=await k(t);return n?n.type===`branch`?A(t,`refs/heads/${n.name}`):n.sha:null}async function Me(e){let t;try{let n=(await x(m(e,`.git`),`utf-8`)).trim();if(!n.startsWith(`gitdir:`))return null;t=h(e,n.slice(7).trim())}catch{return null}let n=await k(t);return n?n.type===`branch`?A(t,`refs/heads/${n.name}`):n.sha:null}async function Ne(e){let t=await E(e);if(!t)return null;let n=await w(t,`remote`,`origin`,`url`);if(n)return n;let r=await M(t);return r&&r!==t?w(r,`remote`,`origin`,`url`):null}async function Pe(){try{let e=await E();return e?(await pe(m(await M(e)??e,`worktrees`))).length+1:0}catch{return 1}}var N,P,F,I,L=e((()=>{a(),ne(),s(),$(),T(),r(),N=new Map,P=1e3,F=class{constructor(){i(this,`gitDir`,null),i(this,`commonDir`,null),i(this,`initialized`,!1),i(this,`initPromise`,null),i(this,`watchedPaths`,[]),i(this,`branchRefPath`,null),i(this,`cache`,new Map)}async ensureStarted(){if(!this.initialized)return this.initPromise||(this.initPromise=this.start()),this.initPromise}async start(){this.gitDir=await E(),this.initialized=!0,this.gitDir&&(this.commonDir=await M(this.gitDir),this.watchPath(m(this.gitDir,`HEAD`),()=>{this.onHeadChanged()}),this.watchPath(m(this.commonDir??this.gitDir,`config`),()=>{this.invalidate()}),await this.watchCurrentBranchRef(),re(async()=>{this.stopWatching()}))}watchPath(e,t){this.watchedPaths.push(e),de(e,{interval:P},t)}async watchCurrentBranchRef(){if(!this.gitDir)return;let e=await k(this.gitDir),t=this.commonDir??this.gitDir,n=e?.type===`branch`?m(t,`refs`,`heads`,e.name):null;n!==this.branchRefPath&&(this.branchRefPath&&(b(this.branchRefPath),this.watchedPaths=this.watchedPaths.filter(e=>e!==this.branchRefPath)),this.branchRefPath=n,n&&this.watchPath(n,()=>{this.invalidate()}))}async onHeadChanged(){this.invalidate(),await o(),await this.watchCurrentBranchRef()}invalidate(){for(let e of this.cache.values())e.dirty=!0}stopWatching(){for(let e of this.watchedPaths)b(e);this.watchedPaths=[],this.branchRefPath=null}async get(e,t){await this.ensureStarted();let n=this.cache.get(e);if(n&&!n.dirty)return n.value;n&&(n.dirty=!1);let r=await t(),i=this.cache.get(e);return i&&!i.dirty&&(i.value=r),i||this.cache.set(e,{value:r,dirty:!1,compute:t}),r}reset(){this.stopWatching(),this.cache.clear(),this.initialized=!1,this.initPromise=null,this.gitDir=null,this.commonDir=null}},I=new F}));function Fe(){function e(e){let t=B(e);return t===z?null:t}return e.cache=B.cache,e}function Ie(){function e(e){let t=V(e);return t?H(t):null}return e.cache=H.cache,e}function Le(e){return E(e)}function R(e){let t=e.trim();if(!t)return null;let n=t.match(/^git@([^:]+):(.+?)(?:\.git)?$/);if(n&&n[1]&&n[2])return`${n[1]}/${n[2]}`.toLowerCase();let r=t.match(/^(?:https?|ssh):\/\/(?:[^@]+@)?([^/]+)\/(.+?)(?:\.git)?$/);if(r&&r[1]&&r[2]){let e=r[1],t=r[2];if(ze(e)&&t.startsWith(`git/`)){let e=t.slice(4),n=e.split(`/`);return n.length>=3&&n[0].includes(`.`)?e.toLowerCase():`github.com/${e}`.toLowerCase()}return`${e}/${t}`.toLowerCase()}return null}async function Re(){let e=await Y();if(!e)return null;let t=R(e);return t?fe(`sha256`).update(t).digest(`hex`).substring(0,16):null}function ze(e){let t=e.split(`:`)[0]??``;return t===`localhost`||/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(t)}function Be(){let e=l(),t=c(),n=m(t,`.git`);try{let t=e.statSync(n);if(t.isFile())return!1;if(t.isDirectory()){let t=m(n,`HEAD`);try{if(e.statSync(t).isFile())return!1}catch{}}}catch{}try{if(e.statSync(m(t,`HEAD`)).isFile())return!0}catch{}try{if(e.statSync(m(t,`objects`)).isDirectory())return!0}catch{}try{if(e.statSync(m(t,`refs`)).isDirectory())return!0}catch{}return!1}var z,B,V,H,U,W,G,K,q,J,Y,X,Z,Q,Ve,$=e((()=>{n(),s(),te(),C(),ae(),u(),L(),oe(),se(),le(),z=Symbol(`git-root-not-found`),B=f(e=>{let t=Date.now();S(`info`,`find_git_root_started`);let n=h(e),r=n.substring(0,n.indexOf(g)+1)||g,i=0;for(;n!==r;){try{let e=m(n,`.git`);i++;let r=y(e);if(r.isDirectory()||r.isFile())return S(`info`,`find_git_root_completed`,{duration_ms:Date.now()-t,stat_count:i,found:!0}),n.normalize(`NFC`)}catch{}let e=p(n);if(e===n)break;n=e}try{let e=m(r,`.git`);i++;let n=y(e);if(n.isDirectory()||n.isFile())return S(`info`,`find_git_root_completed`,{duration_ms:Date.now()-t,stat_count:i,found:!0}),r.normalize(`NFC`)}catch{}return S(`info`,`find_git_root_completed`,{duration_ms:Date.now()-t,stat_count:i,found:!1}),z},e=>e,50),V=Fe(),H=f(e=>{try{let t=_(m(e,`.git`),`utf-8`).trim();if(!t.startsWith(`gitdir:`))return e;let n=h(e,t.slice(7).trim()),r=h(n,_(m(n,`commondir`),`utf-8`).trim());return h(p(n))!==m(r,`worktrees`)||v(_(m(n,`gitdir`),`utf-8`).trim())!==m(v(e),`.git`)?e:ue(r)===`.git`?p(r).normalize(`NFC`):r.normalize(`NFC`)}catch{return e}},e=>e,50),U=Ie(),W=t(()=>ce(`git`)||`git`),G=t(async()=>{let e=Date.now();S(`info`,`is_git_check_started`);let t=V(c())!==null;return S(`info`,`is_git_check_completed`,{duration_ms:Date.now()-e,is_git:t}),t}),K=async e=>V(e)!==null,q=async()=>Oe(),J=async()=>Ae(),Y=async()=>ke(),X=async e=>{let t=[`--no-optional-locks`,`status`,`--porcelain`];e?.ignoreUntracked&&t.push(`-uno`);let{stdout:n}=await d(W(),t,{preserveOutputOnError:!1});return n.trim().length===0},Z=async()=>{let{stdout:e}=await d(W(),[`--no-optional-locks`,`status`,`--porcelain`],{preserveOutputOnError:!1}),t=[],n=[];return e.trim().split(`
6
- `).filter(e=>e.length>0).forEach(e=>{let r=e.substring(0,2),i=e.substring(2).trim();r===`??`?n.push(i):i&&t.push(i)}),{tracked:t,untracked:n}},Q=async()=>Pe(),Ve=async e=>{try{let t=e||`Work Mate auto-stash - ${new Date().toISOString()}`,{untracked:n}=await Z();if(n.length>0){let{code:e}=await d(W(),[`add`,...n],{preserveOutputOnError:!1});if(e!==0)return!1}let{code:r}=await d(W(),[`stash`,`push`,`--message`,t],{preserveOutputOnError:!1});return r===0}catch{return!1}}}));export{ge as A,Me as C,w as D,T as E,C as O,L as S,A as T,Ve as _,J as a,je as b,X as c,Re as d,Q as f,R as g,Be as h,q as i,S as k,G as l,$ as m,U as n,Z as o,W as p,V as r,Le as s,K as t,Y as u,Ce as v,E as w,Ne as x,M as y};
@@ -1 +0,0 @@
1
- import{a as e,i as t,m as n,r,u as i}from"./git-B9uvt96d.js";n();export{r as findGitRoot,t as getBranch,e as getDefaultBranch,i as getRemoteUrl};
@@ -1 +0,0 @@
1
- import{Kt as e,tt as t}from"./state-Bs5xweDL.js";import{a as n,l as r}from"./debug-BdqxZ7rV.js";import{Cn as i,On as a}from"./settings-Xbq6AaD-.js";import{c as o,h as s,y as c}from"./config-D4G8_MqJ.js";import{S as l,m as u,r as d,x as f}from"./git-B9uvt96d.js";import{a as p,i as m,n as h}from"./detectRepository-DvxoaPlk.js";import{realpath as g}from"fs/promises";e(),s(),n(),m(),i(),l(),u();async function _(){try{let e=await h();if(!e){r(`Not in a GitHub repository, skipping path mapping update`);return}let n=t(),i=d(n)??n,a;try{a=(await g(i)).normalize(`NFC`)}catch{a=i}let s=e.toLowerCase(),l=o().githubRepoPaths?.[s]??[];if(l[0]===a){r(`Path ${a} already tracked for repo ${s}`);return}let u=l.filter(e=>e!==a),f=[a,...u];c(e=>({...e,githubRepoPaths:{...e.githubRepoPaths,[s]:f}})),r(`Added ${a} to tracked paths for repo ${s}`)}catch(e){r(`Error updating repo path mapping: ${e}`)}}function v(e){let t=o(),n=e.toLowerCase();return t.githubRepoPaths?.[n]??[]}async function y(e){let t=await Promise.all(e.map(a));return e.filter((e,n)=>t[n])}async function b(e,t){try{let n=await f(e);if(!n)return!1;let r=p(n);return r?r.toLowerCase()===t.toLowerCase():!1}catch{return!1}}function x(e,t){let n=o(),i=e.toLowerCase(),a=n.githubRepoPaths?.[i]??[],s=a.filter(e=>e!==t);if(s.length===a.length)return;let l={...n.githubRepoPaths};s.length===0?delete l[i]:l[i]=s,c(e=>({...e,githubRepoPaths:l})),r(`Removed ${t} from tracked paths for repo ${i}`)}export{b as a,_ as i,v as n,x as r,y as t};
@@ -1 +0,0 @@
1
- import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{Dw as n,Ew as r,Ii as i,Ji as a,Ow as o,Vi as s,dd as c,fd as l,pw as u}from"./loadAgentsDir-CKSb56Gp.js";import{I as d,Lt as f,P as p,Wt as m,a as h,fi as g,n as _,ot as v,r as y,t as b,x}from"./src-P_wYS_NJ2.js";import{t as S}from"./jsx-runtime-Bb4Xn-E0.js";import{b as C,y as w}from"./startupProfiler-jeId9f2i.js";import{n as T,t as E}from"./useExitOnCtrlCDWithKeybindings-D2FvHieH.js";import{n as D,r as O}from"./modalContext-CUThy6Ph.js";import{n as k,t as A}from"./PromptInputHelpMenu-BvcAzbSi.js";function j({commands:e,maxHeight:t,columns:n,title:r,onCancel:i,emptyMessage:a}){let{headerFocused:o,focusHeader:l}=h(),u=Math.max(1,n-10),f=Math.max(1,Math.floor((t-10)/2)),m=(0,M.useMemo)(()=>{let t=new Set;return e.filter(e=>t.has(e.name)?!1:(t.add(e.name),!0)).sort((e,t)=>e.name.localeCompare(t.name)).map(e=>({label:`/${e.name}`,value:e.name,description:C(s(e),u,!0)}))},[e,u]);return(0,N.jsx)(d,{flexDirection:`column`,paddingY:1,children:e.length===0&&a?(0,N.jsx)(p,{dimColor:!0,children:a}):(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(p,{children:r}),(0,N.jsx)(d,{marginTop:1,children:(0,N.jsx)(c,{options:m,visibleOptionCount:f,onCancel:i,disableSelection:!0,hideIndexes:!0,layout:`compact-vertical`,onUpFromFirstItem:l,isDisabled:o})})]})})}var M,N,P=e((()=>{g(),M=t(g(),1),a(),w(),b(),l(),N=S()}));function F(){return(0,I.jsxs)(d,{flexDirection:`column`,paddingY:1,gap:1,children:[(0,I.jsxs)(d,{flexDirection:`column`,gap:1,children:[(0,I.jsx)(p,{bold:!0,children:`Getting started`}),(0,I.jsxs)(d,{flexDirection:`column`,children:[(0,I.jsxs)(p,{children:[(0,I.jsx)(p,{bold:!0,children:`1. `}),(0,I.jsx)(p,{children:`Ask a question or describe a task — Claude will explore your code and respond.`})]}),(0,I.jsxs)(p,{children:[(0,I.jsx)(p,{bold:!0,children:`2. `}),(0,I.jsx)(p,{children:`When Claude wants to edit files or run commands, you review and approve each action.`})]}),(0,I.jsxs)(p,{children:[(0,I.jsx)(p,{bold:!0,children:`3. `}),(0,I.jsx)(p,{children:`Type `}),(0,I.jsx)(p,{bold:!0,children:`/commit`}),(0,I.jsx)(p,{children:` to commit changes, `}),(0,I.jsx)(p,{bold:!0,children:`/help`}),(0,I.jsx)(p,{children:` for commands, or `}),(0,I.jsx)(p,{bold:!0,children:`?`}),(0,I.jsx)(p,{children:` for shortcuts.`})]})]})]}),(0,I.jsxs)(d,{flexDirection:`column`,children:[(0,I.jsx)(d,{children:(0,I.jsx)(p,{bold:!0,children:`Shortcuts`})}),(0,I.jsx)(A,{gap:2,fixedWidth:!0})]})]})}var I,L=e((()=>{g(),b(),k(),I=S()}));function R({onClose:e,commands:t}){let{rows:n,columns:r}=v(),a=Math.floor(n/2),s=O(),c=()=>e(`Help dialog dismissed`,{display:`system`});m(`help:dismiss`,c,{context:`Help`});let l=T(c),u=o(`help:dismiss`,`Help`,`esc`),h=i(),g=t.filter(e=>h.has(e.name)&&!e.isHidden),b=t.filter(e=>!h.has(e.name)&&!e.isHidden),S=[(0,z.jsx)(_,{title:`general`,children:(0,z.jsx)(F,{})},`general`)];return S.push((0,z.jsx)(_,{title:`commands`,children:(0,z.jsx)(j,{commands:g,maxHeight:a,columns:r,title:`Browse default commands:`,onCancel:c})},`commands`)),S.push((0,z.jsx)(_,{title:`custom-commands`,children:(0,z.jsx)(j,{commands:b,maxHeight:a,columns:r,title:`Browse custom commands:`,emptyMessage:`No custom commands found`,onCancel:c})},`custom`)),(0,z.jsx)(d,{flexDirection:`column`,height:s?void 0:a,children:(0,z.jsxs)(x,{color:`professionalBlue`,children:[(0,z.jsx)(y,{title:`Work Mate v0.0.9`,color:`professionalBlue`,defaultTab:`general`,children:S}),(0,z.jsx)(d,{marginTop:1,children:(0,z.jsxs)(p,{children:[`For more help: `,(0,z.jsx)(f,{url:`https://code.claude.com/docs/en/overview`})]})}),(0,z.jsx)(d,{marginTop:1,children:(0,z.jsx)(p,{dimColor:!0,children:l.pending?(0,z.jsxs)(z.Fragment,{children:[`Press `,l.keyName,` again to exit`]}):(0,z.jsxs)(p,{italic:!0,children:[u,` to cancel`]})})})]})})}var z,B=e((()=>{g(),E(),n(),a(),D(),u(),b(),r(),P(),L(),z=S()})),V,H;e((()=>{B(),V=S(),H=async(e,{options:{commands:t}})=>(0,V.jsx)(R,{commands:t,onClose:e})}))();export{H as call};
@@ -1 +0,0 @@
1
- import{Xt as e,_n as t,un as n,vn as r}from"./loadAgentsDir-CKSb56Gp.js";r();export{e as executeSessionEndHooks,n as getSessionEndHookTimeoutMs,t as hasWorktreeCreateHook};
@@ -1 +0,0 @@
1
- import{l as e,o as t,u as n}from"./envUtils-BDhHQY0-.js";import{Ar as r,Cf as i,Df as a,Ha as o,LT as s,Nc as c,Qa as l,RT as u,Wa as d,kc as f,no as p,pr as m,xf as h}from"./loadAgentsDir-CKSb56Gp.js";import{Kt as g,mt as _,tt as v}from"./state-Bs5xweDL.js";import{F as y,a as b,l as x,nt as S,rt as ee,z as C}from"./debug-BdqxZ7rV.js";import{c as te,h as ne,y as re}from"./config-D4G8_MqJ.js";import{O as w,i as ie,k as T,m as E,u as D}from"./git-B9uvt96d.js";import{g as O,m as k}from"./log-CTFl4qpD.js";import{n as A,r as j}from"./analytics-DJobLaWP.js";import{Bt as ae,Fr as M,It as N,Ot as oe,Pr as se,_n as P,mt as F,vn as I}from"./model-C2e73CJD.js";import{a as ce,i as le,r as L,t as R}from"./sessionIdCompat-DMayYBrf.js";import{I as ue,L as de,c as fe,d as pe,h as z,m as me,n as B,p as he,u as V}from"./sessionState-BvECKycx.js";import{a as H,i as U,n as W,o as G,t as K}from"./bridgeConfig-vORehbGG.js";import{a as ge,o as q,r as _e,s as J}from"./debugUtils-CezNYZ-4.js";import{a as Y,i as ve,n as X,t as Z}from"./createSession-CPo6GBSb.js";import{n as ye,o as be}from"./mappers-xQC-Z4-h.js";import{n as xe,r as Se,t as Q}from"./sessionTitle-E1FvsKM9.js";import{i as Ce,n as we,r as Te,t as Ee}from"./flushGate-ch-Tvwjj.js";import{n as De,t as Oe}from"./pollConfig-BgpfHQPJ.js";import{n as ke,t as Ae}from"./rcDebugLog-CARUIORE.js";import{a as je,i as Me,n as $,o as Ne,r as Pe,t as Fe}from"./capacityWake-L7b1mMft.js";import{a as Ie,i as Le,n as Re,o as ze,r as Be,t as Ve}from"./bridgeMessaging-DlczTV9X.js";import{a as He,n as Ue,r as We,t as Ge}from"./workSecret-DtiFreRl.js";import{i as Ke}from"./trustedDevice-j1u2TG5U.js";import{t as qe}from"./HybridTransport-BVmSUHf0.js";import{hostname as Je}from"os";import{randomUUID as Ye}from"crypto";g(),k(),E(),ne(),M(),ae(),u(),h(),H(),pe(),l(),r(),ve(),ye(),Se(),b(),Ae(),w(),A(),S(),R(),f(),ue(),B(),t(),q(),C(),P();var Xe=2e3,Ze=6e4,Qe=900*1e3,$e=0;async function et(t){let{dir:r,machineName:i,branch:a,gitRepoUrl:o,title:s,baseUrl:l,sessionIngressUrl:u,workerType:d,getAccessToken:f,createSession:p,archiveSession:m,getCurrentTitle:h=()=>s,toSDKMessages:g=()=>{throw Error(`BridgeCoreParams.toSDKMessages not provided. Pass it if you use writeMessages() or initialMessages — daemon callers that only use writeSdkMessages() never hit this path.`)},onAuth401:_,getPollIntervalConfig:v=()=>De,initialHistoryCap:b=200,initialMessages:S,previouslyFlushedUUIDs:C,onInboundMessage:te,onPermissionResponse:ne,onInterrupt:re,onSetModel:w,onSetMaxThinkingTokens:ie,onSetPermissionMode:E,onStateChange:D,onUserMessage:O,perpetual:k,initialSSESequenceNum:A=0}=t,ae=++$e,{writeBridgePointer:M,clearBridgePointer:N,readBridgePointer:oe}=await import(`./bridgePointer-D4W9GpWw.js`),se=k?await oe(r):null,P=se?.source===`repl`?se:null;x(`[bridge:repl] initBridgeCore #${ae} starting (initialMessages=${S?.length??0}${P?` perpetual prior=env:${P.environmentId}`:``})`);let F=Pe({baseUrl:l,getAccessToken:f,runnerVersion:`0.0.9`,onDebug:x,onAuth401:_,getTrustedDeviceToken:Ke}),I={dir:r,machineName:i,branch:a,gitRepoUrl:o,maxSessions:1,spawnMode:`single-session`,verbose:!1,sandbox:!1,bridgeId:Ye(),workerType:d,environmentId:Ye(),reuseEnvironmentId:P?.environmentId,apiBaseUrl:l,sessionIngressUrl:u},L,R;try{let e=await F.registerBridgeEnvironment(I);L=e.environment_id,R=e.environment_secret}catch(e){return J(`registration_failed`,`[bridge:repl] Environment registration failed: ${y(e)}`),P&&await N(r),D?.(`failed`,y(e)),null}x(`[bridge:repl] Environment registered: ${L}`),T(`info`,`bridge_repl_env_registered`),j(`tengu_bridge_repl_env_registered`,{});async function ue(e,t){if(L!==e)return x(`[bridge:repl] Env mismatch (requested ${e}, got ${L}) — cannot reconnect in place`),!1;let n=ce(t),r=n===t?[t]:[t,n];for(let e of r)try{return await F.reconnectSession(L,e),x(`[bridge:repl] Reconnected session ${e} in place on env ${L}`),!0}catch(t){x(`[bridge:repl] reconnectSession(${e}) failed: ${y(t)}`)}return x(`[bridge:repl] reconnectSession exhausted — falling through to fresh session`),!1}let pe=P?await ue(P.environmentId,P.sessionId):!1;P&&!pe&&await N(r);let z;if(pe&&P){if(z=P.sessionId,x(`[bridge:repl] Perpetual session reused: ${z}`),S&&C)for(let e of S)C.add(e.uuid)}else{let e=await p({environmentId:L,title:s,gitRepoUrl:o,branch:a,signal:AbortSignal.timeout(15e3)});if(!e)return x(`[bridge:repl] Session creation failed, deregistering environment`),j(`tengu_bridge_repl_session_failed`,{}),await F.deregisterEnvironment(L).catch(()=>{}),D?.(`failed`,`Session creation failed`),null;z=e,x(`[bridge:repl] Session created: ${z}`)}await M(r,{sessionId:z,environmentId:L,source:`repl`}),T(`info`,`bridge_repl_session_created`),j(`tengu_bridge_repl_started`,{has_initial_messages:!!(S&&S.length>0),inProtectedNamespace:n()});let me=new Set;if(S)for(let e of S)me.add(e.uuid);let B=new Ve(2e3);for(let e of me)B.add(e);let he=new Ve(2e3),V=new AbortController,H=null;fe(e=>{V.signal.aborted||H?.reportMetadata(e)},{replayCurrent:!0});let U=0,W=pe?A:0,G=null,K=null,ge=Fe(V.signal),q=ge.wake,_e=ge.signal,Y=new Ee,ve=!O,X=0,Z=null;async function ye(){if(Z)return Z;Z=be();try{return await Z}finally{Z=null}}async function be(){if(X++,ke(`doReconnect: attempt=${X}/3 envId=${L} sessionId=${z} workId=${G}`),U++,x(`[bridge:repl] Reconnecting after env lost (attempt ${X}/3)`),X>3)return x(`[bridge:repl] Environment reconnect limit reached (3), giving up`),!1;if(H){let e=H.getLastSequenceNum();e>W&&(W=e),H.close(),H=null}if(q(),Y.drop(),G){let e=G;if(await F.stopWork(L,e,!1).catch(()=>{}),G!==e)return x(`[bridge:repl] Poll loop recovered during stopWork await — deferring to it`),X=0,!0;G=null,K=null}if(V.signal.aborted)return x(`[bridge:repl] Reconnect aborted by teardown`),!1;let e=L;I.reuseEnvironmentId=e;try{let e=await F.registerBridgeEnvironment(I);L=e.environment_id,R=e.environment_secret}catch(e){return I.reuseEnvironmentId=void 0,x(`[bridge:repl] Environment re-registration failed: ${y(e)}`),!1}if(I.reuseEnvironmentId=void 0,x(`[bridge:repl] Re-registered: requested=${e} got=${L}`),V.signal.aborted)return x(`[bridge:repl] Reconnect aborted after env registration, cleaning up`),await F.deregisterEnvironment(L).catch(()=>{}),!1;if(H!==null)return x(`[bridge:repl] Poll loop recovered during registerBridgeEnvironment await — deferring to it`),X=0,!0;if(await ue(e,z))return j(`tengu_bridge_repl_reconnected_in_place`,{}),X=0,!0;if(L!==e&&j(`tengu_bridge_repl_env_expired_fresh_session`,{}),await m(z),V.signal.aborted)return x(`[bridge:repl] Reconnect aborted after archive, cleaning up`),await F.deregisterEnvironment(L).catch(()=>{}),!1;let t=h(),n=await p({environmentId:L,title:t,gitRepoUrl:o,branch:a,signal:AbortSignal.timeout(15e3)});return n?V.signal.aborted?(x(`[bridge:repl] Reconnect aborted after session creation, cleaning up`),await m(n),!1):(z=n,c(le(n)).catch(()=>{}),W=0,he.clear(),ve=!O,x(`[bridge:repl] Re-created session: ${z}`),await M(r,{sessionId:z,environmentId:L,source:`repl`}),C?.clear(),X=0,!0):(x(`[bridge:repl] Session creation failed during reconnection`),!1)}function xe(){return f()}function Se(){let e=Y.end();if(e.length===0)return;if(!H){x(`[bridge:repl] Cannot drain ${e.length} pending message(s): no transport`);return}for(let t of e)B.add(t.uuid);let t=g(e).map(e=>({...e,session_id:z}));x(`[bridge:repl] Drained ${e.length} pending message(s) after flush`),H.writeBatch(t)}let Q=null;function Ce(){Q?.()}function Oe(e){if(ke(`handleTransportPermanentClose: code=${e} transport=${H?`exists`:`null`} pollAborted=${V.signal.aborted}`),x(`[bridge:repl] Transport permanently closed: code=${e}`),j(`tengu_bridge_repl_ws_closed`,{code:e}),H){let e=H.getLastSequenceNum();e>W&&(W=e),H=null}q();let t=Y.drop();if(t>0&&x(`[bridge:repl] Dropping ${t} pending message(s) on transport close (code=${e})`,{level:`warn`}),e===1e3){D?.(`failed`,`session ended`),V.abort(),Ce();return}D?.(`reconnecting`,`Remote Control connection lost (code ${e})`),x(`[bridge:repl] Transport reconnect budget exhausted (code=${e}), attempting env reconnect`),ye().then(t=>{t||V.signal.aborted||(x(`[bridge:repl] reconnectEnvironmentWithSession resolved false — tearing down`),j(`tengu_bridge_repl_reconnect_failed`,{close_code:e}),D?.(`failed`,`reconnection failed`),Ce())})}tt({api:F,getCredentials:()=>({environmentId:L,environmentSecret:R}),signal:V.signal,getPollIntervalConfig:v,onStateChange:D,getWsState:()=>H?.getStateLabel()??`null`,isAtCapacity:()=>H!==null,capacitySignal:_e,onFatalError:Ce,getHeartbeatInfo:()=>!G||!K?null:{environmentId:L,workId:G,sessionToken:K},onHeartbeatFatal:e=>{if(x(`[bridge:repl] heartbeatWork fatal (status=${e.status}) — tearing down work item for fast re-dispatch`),H){let e=H.getLastSequenceNum();e>W&&(W=e),H.close(),H=null}Y.drop(),G&&F.stopWork(L,G,!1).catch(e=>{x(`[bridge:repl] stopWork after heartbeat fatal: ${y(e)}`)}),G=null,K=null,q(),D?.(`reconnecting`,`Work item lease expired, fetching fresh token`)},async onEnvironmentLost(){return await ye()?{environmentId:L,environmentSecret:R}:null},onWorkReceived:(t,n,i,a)=>{if(H?.isConnectedStatus()&&x(`[bridge:repl] Work received while transport connected, replacing with fresh token (workId=${i})`),x(`[bridge:repl] Work received: workId=${i} workSessionId=${t} currentSessionId=${z} match=${He(t,z)}`),M(r,{sessionId:z,environmentId:L,source:`repl`}),!He(t,z)){x(`[bridge:repl] Rejecting foreign session: expected=${z} got=${t}`);return}G=i,K=n;let o=a||e(process.env.CLAUDE_BRIDGE_USE_CCR_V2),s;if(!o){if(s=xe(),!s){x(`[bridge:repl] No OAuth token available for session ingress, skipping work`);return}de(s)}if(j(`tengu_bridge_repl_work_received`,{}),H){let e=H;H=null;let t=e.getLastSequenceNum();t>W&&(W=t),e.close()}Y.deactivate();let c=e=>Le(e,{transport:H,sessionId:z,onInterrupt:re,onSetModel:w,onSetMaxThinkingTokens:ie,onSetPermissionMode:E}),d=!1,f=e=>{H=e,e.setOnConnect(()=>{if(H===e){if(x(`[bridge:repl] Ingress transport connected`),j(`tengu_bridge_repl_ws_connected`,{}),!o){let e=xe();e&&de(e)}if($=!1,!d&&S&&S.length>0){d=!0;let t=b,n=S.filter(e=>Ie(e)&&!C?.has(e.uuid)),r=t>0&&n.length>t?n.slice(-t):n;r.length<n.length&&(x(`[bridge:repl] Capped initial flush: ${n.length} -> ${r.length} (cap=${t})`),j(`tengu_bridge_repl_history_capped`,{eligible_count:n.length,capped_count:r.length}));let i=g(r);if(i.length>0){x(`[bridge:repl] Flushing ${i.length} initial message(s) via transport`);let t=i.map(e=>({...e,session_id:z})),n=e.droppedBatchCount;e.writeBatch(t).then(()=>{if(e.droppedBatchCount>n){x(`[bridge:repl] Initial flush dropped ${e.droppedBatchCount-n} batch(es) — not marking ${i.length} UUID(s) as flushed`);return}if(C)for(let e of i)e.uuid&&C.add(e.uuid)}).catch(e=>x(`[bridge:repl] Initial flush failed: ${e}`)).finally(()=>{H===e&&(Se(),D?.(`connected`))})}else Se(),D?.(`connected`)}else Y.active||D?.(`connected`)}}),e.setOnData(e=>{try{let t=JSON.parse(e);ke(`ingress: type=${t.type}${t.type===`control_request`?` subtype=${t.request?.subtype} request_id=${t.request_id}`:``}${t.type===`control_response`?` subtype=${t.response?.subtype} request_id=${t.response?.request_id}`:``}${t.type===`user`?` uuid=${t.uuid}`:``}${t.type===`keep_alive`?``:` len=${e.length}`}`)}catch{ke(`ingress (non-JSON): ${String(e).slice(0,200)}`)}Be(e,B,he,te,ne,c)}),e.setOnClose(t=>{H===e&&(ke(`transport onClose: code=${t} connected=${e.isConnectedStatus()} state=${e.getStateLabel()} seq=${e.getLastSequenceNum()}`),Oe(t))}),!d&&S&&S.length>0&&Y.start(),e.connect()};if(U++,o){let e=Ge(l,t),r=U;x(`[bridge:repl] CCR v2: sessionUrl=${e} session=${t} gen=${r}`),Te({sessionUrl:e,ingressToken:n,sessionId:t,initialSequenceNum:W}).then(e=>{if(V.signal.aborted){e.close();return}if(r!==U){x(`[bridge:repl] CCR v2: discarding stale handshake gen=${r} current=${U}`),e.close();return}f(e)},e=>{x(`[bridge:repl] CCR v2: createV2ReplTransport failed: ${y(e)}`,{level:`error`}),j(`tengu_bridge_repl_ccr_v2_init_failed`,{}),r===U&&(G&&(F.stopWork(L,G,!1).catch(e=>{x(`[bridge:repl] stopWork after v2 init failure: ${y(e)}`)}),G=null,K=null),q())})}else{let e=Ue(u,t);x(`[bridge:repl] Ingress URL: ${e}`),x(`[bridge:repl] Creating HybridTransport: session=${t}`);let n=s??``;f(we(new qe(new URL(e),{Authorization:`Bearer ${n}`,"anthropic-version":`2023-06-01`},t,()=>({Authorization:`Bearer ${xe()??n}`,"anthropic-version":`2023-06-01`}),{maxConsecutiveFailures:50,isBridge:!0,onBatchDropped:()=>{D?.(`reconnecting`,`Lost sync with Remote Control — events could not be delivered`),q()}})))}}});let Ae=k?setInterval(()=>{Z||M(r,{sessionId:z,environmentId:L,source:`repl`})},60*6e4):null;Ae?.unref?.();let je=v().session_keepalive_interval_v2_ms,Me=je>0?setInterval(()=>{H&&(x(`[bridge:repl] keep_alive sent`),H.write({type:`keep_alive`}).catch(e=>{x(`[bridge:repl] keep_alive write failed: ${y(e)}`)}))},je):null;Me?.unref?.();let $=!1;Q=async()=>{if($){x(`[bridge:repl] Teardown already in progress, skipping duplicate call env=${L} session=${z}`);return}$=!0;let e=Date.now();if(x(`[bridge:repl] Teardown starting: env=${L} session=${z} workId=${G??`none`} transportState=${H?.getStateLabel()??`null`}`),Ae!==null&&clearInterval(Ae),Me!==null&&clearInterval(Me),V.abort(),x(`[bridge:repl] Teardown: poll loop aborted`),H){let e=H.getLastSequenceNum();e>W&&(W=e)}if(k){H=null,Y.drop(),await M(r,{sessionId:z,environmentId:L,source:`repl`}),x(`[bridge:repl] Teardown (perpetual): leaving env=${L} session=${z} alive on server, duration=${Date.now()-e}ms`);return}let t=H;if(H=null,Y.drop(),t){let e={...ze(z),session_id:z};t.write(e)}let n=G?F.stopWork(L,G,!0).then(()=>{x(`[bridge:repl] Teardown: stopWork completed`)}).catch(e=>{x(`[bridge:repl] Teardown stopWork failed: ${y(e)}`)}):Promise.resolve();await Promise.all([n,m(z)]),t?.close(),x(`[bridge:repl] Teardown: transport closed`),await F.deregisterEnvironment(L).catch(e=>{x(`[bridge:repl] Teardown deregister failed: ${y(e)}`)}),await N(r),x(`[bridge:repl] Teardown complete: env=${L} duration=${Date.now()-e}ms`)};let Ne=ee(()=>Q?.());return x(`[bridge:repl] Ready: env=${L} session=${z}`),D?.(`ready`),{get bridgeSessionId(){return z},get environmentId(){return L},getSSESequenceNum(){let e=H?.getLastSequenceNum()??0;return Math.max(W,e)},sessionIngressUrl:u,writeMessages(e){let t=e.filter(e=>Ie(e)&&!me.has(e.uuid)&&!B.has(e.uuid));if(t.length===0)return;if(!ve)for(let e of t){let t=Re(e);if(t!==void 0&&O?.(t,z)){ve=!0;break}}if(Y.enqueue(...t)){x(`[bridge:repl] Queued ${t.length} message(s) during initial flush`);return}if(!H){let e=t.map(e=>e.type).join(`,`);x(`[bridge:repl] Transport not configured, dropping ${t.length} message(s) [${e}] for session=${z}`,{level:`warn`});return}for(let e of t)B.add(e.uuid);x(`[bridge:repl] Sending ${t.length} message(s) via transport`);let n=g(t).map(e=>({...e,session_id:z}));H.writeBatch(n)},writeSdkMessages(e){let t=e.filter(e=>!e.uuid||!B.has(e.uuid));if(t.length===0)return;if(!H){x(`[bridge:repl] Transport not configured, dropping ${t.length} SDK message(s) for session=${z}`,{level:`warn`});return}for(let e of t)e.uuid&&B.add(e.uuid);let n=t.map(e=>({...e,session_id:z}));H.writeBatch(n)},sendControlRequest(e){if(!H){x(`[bridge:repl] Transport not configured, skipping control_request`);return}let t={...e,session_id:z};H.write(t),x(`[bridge:repl] Sent control_request request_id=${e.request_id}`)},sendControlResponse(e){if(!H){x(`[bridge:repl] Transport not configured, skipping control_response`);return}let t={...e,session_id:z};H.write(t),x(`[bridge:repl] Sent control_response`)},sendControlCancelRequest(e){if(!H){x(`[bridge:repl] Transport not configured, skipping control_cancel_request`);return}let t={type:`control_cancel_request`,request_id:e,session_id:z};H.write(t),x(`[bridge:repl] Sent control_cancel_request request_id=${e}`)},sendResult(){if(!H){x(`[bridge:repl] sendResult: skipping, transport not configured session=${z}`);return}H.reportState(`idle`);let e={...ze(z),session_id:z};H.write(e),x(`[bridge:repl] Sent result for session=${z}`)},async teardown(){Ne(),await Q?.(),x(`[bridge:repl] Torn down`),j(`tengu_bridge_repl_teardown`,{})}}}async function tt({api:e,getCredentials:t,signal:n,onStateChange:r,onWorkReceived:i,onEnvironmentLost:a,getWsState:o,isAtCapacity:s,capacitySignal:c,onFatalError:l,getPollIntervalConfig:u=()=>De,getHeartbeatInfo:d,onHeartbeatFatal:f}){x(`[bridge:repl] Starting work poll loop for env=${t().environmentId}`);let p=0,m=null,h=null,g=0,_=!1;for(;!n.aborted;){let{environmentId:v,environmentSecret:b}=t(),S=u();try{let t=await e.pollForWork(v,b,n,S.reclaim_older_than_ms);if(g=0,p>0&&(x(`[bridge:repl] Poll recovered after ${p} consecutive error(s)`),p=0,m=null,h=null,r?.(`ready`)),!t){let t=_;if(_=!1,s?.()&&c&&!t){let t=S.poll_interval_ms_at_capacity;if(S.non_exclusive_heartbeat_interval_ms>0&&d){j(`tengu_bridge_heartbeat_mode_entered`,{heartbeat_interval_ms:S.non_exclusive_heartbeat_interval_ms});let r=t>0?Date.now()+t:null,i=!1,a=0;for(;!n.aborted&&s()&&(r===null||Date.now()<r);){let t=u();if(t.non_exclusive_heartbeat_interval_ms<=0)break;let n=d();if(!n)break;let r=c();try{await e.heartbeatWork(n.environmentId,n.workId,n.sessionToken)}catch(e){if(x(`[bridge:repl:heartbeat] Failed: ${y(e)}`),e instanceof $){r.cleanup(),j(`tengu_bridge_heartbeat_error`,{status:e.status,error_type:e.status===401||e.status===403?`auth_failed`:`fatal`}),f?(f(e),x(`[bridge:repl:heartbeat] Fatal (status=${e.status}), work state cleared — fast-polling for re-dispatch`)):i=!0;break}}a++,await I(t.non_exclusive_heartbeat_interval_ms,r.signal),r.cleanup()}let o=i?`error`:n.aborted?`shutdown`:s()?r!==null&&Date.now()>=r?`poll_due`:`config_disabled`:`capacity_changed`;if(j(`tengu_bridge_heartbeat_mode_exited`,{reason:o,heartbeat_cycles:a}),!i){o===`poll_due`&&x(`[bridge:repl] Heartbeat poll_due after ${a} cycles — falling through to pollForWork`);continue}}let r=t>0?t:S.non_exclusive_heartbeat_interval_ms;if(r>0){let e=c(),t=Date.now();await I(r,e.signal),e.cleanup();let n=Date.now()-t-r;n>6e4&&(x(`[bridge:repl] At-capacity sleep overran by ${Math.round(n/1e3)}s — process suspension detected, forcing one fast-poll cycle`),j(`tengu_bridge_repl_suspension_detected`,{overrun_ms:n}),_=!0)}}else await I(S.poll_interval_ms_not_at_capacity,n);continue}let a;try{a=We(t.secret)}catch(n){x(`[bridge:repl] Failed to decode work secret: ${y(n)}`),j(`tengu_bridge_repl_work_secret_failed`,{}),await e.stopWork(v,t.id,!1).catch(()=>{});continue}x(`[bridge:repl] Acknowledging workId=${t.id}`);try{await e.acknowledgeWork(v,t.id,a.session_ingress_token)}catch(e){x(`[bridge:repl] Acknowledge failed workId=${t.id}: ${y(e)}`)}if(t.data.type===`healthcheck`){x(`[bridge:repl] Healthcheck received`);continue}if(t.data.type===`session`){let e=t.data.id;try{Ne(e,`session_id`)}catch{x(`[bridge:repl] Invalid session_id in work: ${e}`);continue}i(e,a.session_ingress_token,t.id,a.use_code_sessions===!0),x(`[bridge:repl] Work accepted, continuing poll loop`)}}catch(i){if(n.aborted)break;if(i instanceof $&&i.status===404&&a){let e=t().environmentId;if(v!==e){x(`[bridge:repl] Stale poll error for old env=${v}, current env=${e} — skipping onEnvironmentLost`),p=0,m=null;continue}if(g++,x(`[bridge:repl] Environment deleted, attempting re-registration (attempt ${g}/3)`),j(`tengu_bridge_repl_env_lost`,{attempt:g}),g>3){x(`[bridge:repl] Environment re-registration limit reached (3), giving up`),r?.(`failed`,`Environment deleted and re-registration limit reached`),l?.();break}r?.(`reconnecting`,`environment lost, recreating session`);let i=await a();if(n.aborted)break;if(i){p=0,m=null,r?.(`ready`),x(`[bridge:repl] Re-registered environment: ${i.environmentId}`);continue}r?.(`failed`,`Environment deleted and re-registration failed`),l?.();break}if(i instanceof $){let e=Me(i.errorType),t=je(i);x(`[bridge:repl] Fatal poll error: ${i.message} (status=${i.status}, type=${i.errorType??`unknown`})${t?` (suppressed)`:``}`),j(`tengu_bridge_repl_fatal_error`,{status:i.status,error_type:i.errorType}),T(e?`info`:`error`,`bridge_repl_fatal_error`,{status:i.status,error_type:i.errorType}),t||r?.(`failed`,e?`session expired · /remote-control to reconnect`:i.message),l?.();break}let s=Date.now();h!==null&&s-h>6e4*2&&(x(`[bridge:repl] Detected system sleep (${Math.round((s-h)/1e3)}s gap), resetting poll error budget`),T(`info`,`bridge_repl_poll_sleep_detected`,{gapMs:s-h}),p=0,m=null),h=s,p++,m===null&&(m=s);let c=s-m,f=ge(i),_=_e(i),y=o?.()??`unknown`;if(x(`[bridge:repl] Poll error (attempt ${p}, elapsed ${Math.round(c/1e3)}s, ws=${y}): ${_}`),j(`tengu_bridge_repl_poll_error`,{status:f,consecutiveErrors:p,elapsedMs:c}),p===1&&r?.(`reconnecting`,_),c>=9e5){x(`[bridge:repl] Poll failures exceeded ${Qe/1e3}s (${p} errors), giving up`),T(`info`,`bridge_repl_poll_give_up`),j(`tengu_bridge_repl_poll_give_up`,{consecutiveErrors:p,elapsedMs:c,lastStatus:f}),r?.(`failed`,`connection to server lost`);break}let b=Math.min(Xe*2**(p-1),Ze);if(u().non_exclusive_heartbeat_interval_ms>0){let t=d?.();if(t)try{await e.heartbeatWork(t.environmentId,t.workId,t.sessionToken)}catch{}}await I(b,n)}}x(`[bridge:repl] Work poll loop ended (aborted=${n.aborted}) env=${t().environmentId}`)}b(),C(),q(),R();async function nt(e){let{onInboundMessage:t,onPermissionResponse:n,onInterrupt:r,onSetModel:c,onSetMaxThinkingTokens:l,onSetPermissionMode:u,onStateChange:f,initialMessages:h,getMessages:g,previouslyFlushedUUIDs:b,initialName:S,perpetual:ee,outboundOnly:C,tags:ne}=e??{};if(L(me),!await he())return J(`not_enabled`,`[bridge:repl] Skipping: bridge not enabled`),null;if(!K())return J(`no_oauth`,`[bridge:repl] Skipping: no OAuth tokens`),f?.(`failed`,`authentication required`),null;if(await a(),!i(`allow_remote_control`))return J(`policy_denied`,`[bridge:repl] Skipping: allow_remote_control policy not allowed`),f?.(`failed`,`disabled by your organization's policy`),null;if(!U()){let e=te();if(e.bridgeOauthDeadExpiresAt!=null&&(e.bridgeOauthDeadFailCount??0)>=3&&oe()?.expiresAt===e.bridgeOauthDeadExpiresAt)return x(`[bridge:repl] Skipping: cross-process backoff (dead token seen ${e.bridgeOauthDeadFailCount} times)`),null;await F();let t=oe();if(t&&t.expiresAt!==null&&t.expiresAt<=Date.now()){J(`oauth_expired_unrefreshable`,`[bridge:repl] Skipping: OAuth token expired and refresh failed (re-login required)`),f?.(`failed`,`authentication required`);let e=t.expiresAt;return re(t=>({...t,bridgeOauthDeadExpiresAt:e,bridgeOauthDeadFailCount:t.bridgeOauthDeadExpiresAt===e?(t.bridgeOauthDeadFailCount??0)+1:1})),null}}let w=W(),T=`remote-control-${s()}`,E=!1,O=!1;if(S)T=S,E=!0,O=!0;else{let e=_(),t=e?m(e):void 0;if(t)T=t,E=!0,O=!0;else if(h&&h.length>0)for(let e=h.length-1;e>=0;e--){let t=h[e];if(t.type!==`user`||t.isMeta||t.toolUseResult||t.isCompactSummary||t.origin&&t.origin.kind!==`human`||p(t))continue;let n=o(t.message.content);if(!n)continue;let r=it(n);if(r){T=r,E=!0;break}}}let k=0,A,j=0,ae=(e,t,n)=>{E=!0,T=e,x(`[bridge:repl] derived title from message ${n}: ${e}`),Y(t,e,{baseUrl:w,getAccessToken:K}).catch(()=>{})},M=(e,t)=>{let n=++j,r=k;xe(e,AbortSignal.timeout(15e3)).then(e=>{e&&n===j&&A===t&&!m(_())&&ae(e,t,r)})},P=(e,t)=>{if(O||m(_()))return!0;if(A!==void 0&&A!==t&&(k=0),A=t,k++,k===1&&!E){let n=it(e);n&&ae(n,t,k),M(e,t)}else if(k===3){let n=g?.(),r=n?Q(d(n)):e;M(r,t)}return k>=3},I=G()?`self-hosted`:await se();if(!I)return J(`no_org_uuid`,`[bridge:repl] Skipping: no org UUID`),f?.(`failed`,`/login`),null;if(z()&&!ee){let e=await Ce();if(e)return J(`version_too_old`,`[bridge:repl] Skipping: ${e}`,!0),f?.(`failed`,"run `claude update` to upgrade"),null;x(`[bridge:repl] Using env-less bridge path (tengu_bridge_repl_v2)`);let{initEnvLessBridgeCore:i}=await import(`./remoteBridgeCore-Dpg6Se9C.js`);return i({baseUrl:w,orgUUID:I,title:T,getAccessToken:K,onAuth401:N,toSDKMessages:be,initialHistoryCap:200,initialMessages:h,onInboundMessage:t,onUserMessage:P,onPermissionResponse:n,onInterrupt:r,onSetModel:c,onSetMaxThinkingTokens:l,onSetPermissionMode:u,onStateChange:f,outboundOnly:C,tags:ne})}let ce=V();if(ce)return J(`version_too_old`,`[bridge:repl] Skipping: ${ce}`),f?.(`failed`,"run `claude update` to upgrade"),null;let le=await ie(),R=await D(),ue=process.env.CLAUDE_BRIDGE_SESSION_INGRESS_URL||w;return et({dir:v(),machineName:Je(),branch:le,gitRepoUrl:R,title:T,baseUrl:w,sessionIngressUrl:ue,workerType:`claude_code`,getAccessToken:K,createSession:e=>X({...e,events:[],baseUrl:w,getAccessToken:K}),archiveSession:e=>Z(e,{baseUrl:w,getAccessToken:K,timeoutMs:1500}).catch(e=>{x(`[bridge:repl] archiveBridgeSession threw: ${y(e)}`,{level:`error`})}),getCurrentTitle:()=>m(_())??T,onUserMessage:P,toSDKMessages:be,onAuth401:N,getPollIntervalConfig:Oe,initialHistoryCap:200,initialMessages:h,previouslyFlushedUUIDs:b,onInboundMessage:t,onPermissionResponse:n,onInterrupt:r,onSetModel:c,onSetMaxThinkingTokens:l,onSetPermissionMode:u,onStateChange:f,perpetual:ee})}var rt=50;function it(e){let t=O(e),n=(/^(.*?[.!?])\s/.exec(t)?.[1]??t).replace(/\s+/g,` `).trim();if(n)return n.length>rt?n.slice(0,rt-1)+`…`:n}export{nt as initReplBridge};
@@ -1 +0,0 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";function t(){return c||(c=new Intl.Segmenter(void 0,{granularity:`grapheme`})),c}function n(e){return e?t().segment(e)[Symbol.iterator]().next().value?.segment??``:``}function r(e){if(!e)return``;let n=``;for(let{segment:r}of t().segment(e))n=r;return n}function i(){return l||(l=new Intl.Segmenter(void 0,{granularity:`word`})),l}function a(e,t){let n=`${e}:${t}`,r=u.get(n);return r||(r=new Intl.RelativeTimeFormat(`en`,{style:e,numeric:t}),u.set(n,r)),r}function o(){return d||(d=Intl.DateTimeFormat().resolvedOptions().timeZone),d}function s(){if(f===null)try{let e=Intl.DateTimeFormat().resolvedOptions().locale;f=new Intl.Locale(e).language}catch{f=void 0}return f}var c,l,u,d,f,p=e((()=>{c=null,l=null,u=new Map,d=null,f=null}));export{o as a,r as c,s as i,t as n,i as o,a as r,p as s,n as t};
@@ -1 +0,0 @@
1
- import{C as e,F as t,S as n,a as r,l as i,z as a}from"./debug-BdqxZ7rV.js";import{O as o,k as s}from"./git-B9uvt96d.js";import{n as c,r as l}from"./analytics-DJobLaWP.js";c(),r(),o(),a(),n();function u(e){if(e<6e4)return`${Math.round(e/1e3)}s`;let t=Math.floor(e/6e4),n=Math.round(e%6e4/1e3);return n>0?`${t}m ${n}s`:`${t}m`}function d(t){let n=(t.startsWith(`sk-ant-si-`)?t.slice(10):t).split(`.`);if(n.length!==3||!n[1])return null;try{return e(Buffer.from(n[1],`base64url`).toString(`utf8`))}catch{return null}}function f(e){let t=d(e);return typeof t==`object`&&t&&`exp`in t&&typeof t.exp==`number`?t.exp:null}var p=300*1e3,m=1800*1e3,h=3,g=6e4;function _({getAccessToken:e,onRefresh:n,label:r,refreshBufferMs:a=p}){let o=new Map,c=new Map,d=new Map;function _(e){let t=(d.get(e)??0)+1;return d.set(e,t),t}function v(e,t){let n=f(t);if(!n){i(`[${r}:token] Could not decode JWT expiry for sessionId=${e}, token prefix=${t.slice(0,15)}…, keeping existing timer`);return}let s=o.get(e);s&&clearTimeout(s);let c=_(e),l=new Date(n*1e3).toISOString(),d=n*1e3-Date.now()-a;if(d<=0){i(`[${r}:token] Token for sessionId=${e} expires=${l} (past or within buffer), refreshing immediately`),b(e,c);return}i(`[${r}:token] Scheduled token refresh for sessionId=${e} in ${u(d)} (expires=${l}, buffer=${a/1e3}s)`);let p=setTimeout(b,d,e,c);o.set(e,p)}function y(e,t){let n=o.get(e);n&&clearTimeout(n);let s=_(e),c=Math.max(t*1e3-a,3e4);i(`[${r}:token] Scheduled token refresh for sessionId=${e} in ${u(c)} (expires_in=${t}s, buffer=${a/1e3}s)`);let l=setTimeout(b,c,e,s);o.set(e,l)}async function b(a,f){let p;try{p=await e()}catch(e){i(`[${r}:token] getAccessToken threw for sessionId=${a}: ${t(e)}`,{level:`error`})}if(d.get(a)!==f){i(`[${r}:token] doRefresh for sessionId=${a} stale (gen ${f} vs ${d.get(a)}), skipping`);return}if(!p){let e=(c.get(a)??0)+1;if(c.set(a,e),i(`[${r}:token] No OAuth token available for refresh, sessionId=${a} (failure ${e}/${h})`,{level:`error`}),s(`error`,`bridge_token_refresh_no_oauth`),e<h){let e=setTimeout(b,g,a,f);o.set(a,e)}return}c.delete(a),i(`[${r}:token] Refreshing token for sessionId=${a}: new token prefix=${p.slice(0,15)}…`),l(`tengu_bridge_token_refreshed`,{}),n(a,p);let _=setTimeout(b,m,a,f);o.set(a,_),i(`[${r}:token] Scheduled follow-up refresh for sessionId=${a} in ${u(m)}`)}function x(e){_(e);let t=o.get(e);t&&(clearTimeout(t),o.delete(e)),c.delete(e)}function S(){for(let e of d.keys())_(e);for(let e of o.values())clearTimeout(e);o.clear(),c.clear()}return{schedule:v,scheduleFromExpiresIn:y,cancel:x,cancelAll:S}}export{f as n,_ as t};
@@ -1,2 +0,0 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{Bw as t,Fw as n,Hw as r,Nw as i,Pw as a,Rw as o,Uw as s,Vw as c}from"./loadAgentsDir-CKSb56Gp.js";import{I as l,S as u,w as d,z as f}from"./debug-BdqxZ7rV.js";import{r as p,t as m}from"./promptEditor-0Ug93P2I.js";import{dirname as h}from"path";import{mkdir as g,writeFile as _}from"fs/promises";function v(e){let t=new Set(o.map(e=>c(e.key)));return e.map(e=>{let n={};for(let[r,i]of Object.entries(e.bindings))t.has(c(r))||(n[r]=i);return{context:e.context,bindings:n}}).filter(e=>Object.keys(e.bindings).length>0)}function y(){return d({$schema:`https://www.schemastore.org/claude-code-keybindings.json`,$docs:`https://code.claude.com/docs/en/keybindings`,bindings:v(r)},null,2)+`
2
- `}var b=e((()=>{u(),s(),t()}));async function x(){if(!n())return{type:`text`,value:`Keybinding customization is not enabled. This feature is currently in preview.`};let e=i(),t=!1;await g(h(e),{recursive:!0});try{await _(e,y(),{encoding:`utf-8`,flag:`wx`})}catch(e){if(l(e)===`EEXIST`)t=!0;else throw e}let r=await m(e);return r.error?{type:`text`,value:`${t?`Opened`:`Created`} ${e}. Could not open in editor: ${r.error}`}:{type:`text`,value:t?`Opened ${e} in your editor.`:`Created ${e} with template. Opened in your editor.`}}e((()=>{a(),b(),f(),p()}))();export{x as call};
@@ -1 +0,0 @@
1
- import{n as e,t}from"./language-CxThoWRC.js";e();export{t as getResolvedLanguage};
@@ -1 +0,0 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{c as t,h as n}from"./config-D4G8_MqJ.js";import{i as r,s as i}from"./intl-cKc-V6Mq.js";function a(){let e=t().preferredLanguage??`auto`;return e===`en`||e===`zh`?e:r()===`zh`?`zh`:`en`}var o=e((()=>{n(),i()}));export{o as n,a as t};
@@ -1 +0,0 @@
1
- import{o as e,t}from"./loadAgentsDir-CKSb56Gp.js";e();export{t as clearAgentDefinitionsCache};
@@ -1 +0,0 @@
1
- import{gg as e,mg as t,pg as n}from"./loadAgentsDir-CKSb56Gp.js";n();export{t as loadPluginHooks,e as setupPluginHookHotReload};
@@ -1 +0,0 @@
1
- import{a as e,c as t,o as n,t as r}from"./localSearch-CPOnyi8I.js";n();export{r as clearSkillIndexCache,e as getSkillIndex,t as searchSkills};
@@ -1 +0,0 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./memoize-BK3gG5ob.js";import{l as r,o as i}from"./envUtils-BDhHQY0-.js";import{Dn as ee,En as te,Kt as ne}from"./state-Bs5xweDL.js";import{S as re,U as ie,W as ae,d as a,p as oe,z as se}from"./debug-BdqxZ7rV.js";import{i as ce,t as le}from"./hash-Tu-My5Vp.js";import{join as o}from"path";import s from"node:process";import c from"node:path";import l from"node:os";import"fs/promises";var u,d,ue,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,O,k,A,j,M,N,de,P,F,I=e((()=>{u=`command-name`,d=`command-message`,ue=`command-args`,f=`bash-input`,p=`bash-stdout`,m=`bash-stderr`,h=`local-command-stdout`,g=`local-command-stderr`,_=`local-command-caveat`,v=[f,p,m,h,g,_],y=`tick`,b=`task-notification`,x=`task-id`,S=`tool-use-id`,C=`task-type`,w=`output-file`,T=`status`,E=`summary`,D=`worktree`,O=`worktreePath`,k=`worktreeBranch`,A=`remote-review`,j=`remote-review-progress`,M=`cross-session-message`,N=`fork-boilerplate`,de=`Your directive: `,P=[`help`,`-h`,`--help`],F=[`list`,`show`,`display`,`current`,`view`,`get`,`check`,`describe`,`print`,`version`,`about`,`status`,`?`]}));function fe(e){if(typeof e!=`string`)return!1;let t=e.trim();return t!==``&&t!==`.`&&t!==`..`&&!e.includes(`/`)&&!e.includes(`\\`)&&!e.includes(`\0`)}function L(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);if(!fe(e))throw Error(`Unsafe filename: ${JSON.stringify(e)}`)}var pe=e((()=>{Object.freeze([``,` `,`.`,`..`,` .`,`. `,` ..`,`.. `,`../`,`../foo`,`foo/../bar`,`foo/bar`,`foo\\bar`,`foo\0bar`])}));function me(e,{suffix:t=`nodejs`}={}){return L(e),t&&(e+=`-${t}`),L(e),s.platform===`darwin`?V(e):s.platform===`win32`?H(e):U(e)}var R,z,B,V,H,U,he=e((()=>{pe(),R=l.homedir(),z=l.tmpdir(),{env:B}=s,V=e=>{let t=c.join(R,`Library`);return{data:c.join(t,`Application Support`,e),config:c.join(t,`Preferences`,e),cache:c.join(t,`Caches`,e),log:c.join(t,`Logs`,e),temp:c.join(z,e)}},H=e=>{let t=B.APPDATA||c.join(R,`AppData`,`Roaming`),n=B.LOCALAPPDATA||c.join(R,`AppData`,`Local`);return{data:c.join(n,e,`Data`),config:c.join(t,e,`Config`),cache:c.join(n,e,`Cache`),log:c.join(n,e,`Log`),temp:c.join(z,e)}},U=e=>{let t=c.basename(R);return{data:c.join(B.XDG_DATA_HOME||c.join(R,`.local`,`share`),e),config:c.join(B.XDG_CONFIG_HOME||c.join(R,`.config`),e),cache:c.join(B.XDG_CACHE_HOME||c.join(R,`.cache`),e),log:c.join(B.XDG_STATE_HOME||c.join(R,`.local`,`state`),e),temp:c.join(z,t,e)}}}));function W(e){let t=e.replace(/[^a-zA-Z0-9]/g,`-`);return t.length<=q?t:`${t.slice(0,q)}-${Math.abs(le(e)).toString(36)}`}function G(e){return W(e)}var K,q,J,ge=e((()=>{he(),oe(),ce(),K=me(`claude-cli`),q=200,J={baseLogs:()=>o(K.cache,G(a().cwd())),errors:()=>o(K.cache,G(a().cwd()),`errors`),messages:()=>o(K.cache,G(a().cwd()),`messages`),mcpLogs:e=>o(K.cache,G(a().cwd()),`mcp-logs-${W(e)}`)}}));function _e(e){return e.replace(Y,``).trim()||e}function ve(e){return e.replace(Y,``).trim()}function ye(e){return e.replace(be,``).trim()}var Y,be,xe=e((()=>{Y=/<([a-z][\w-]*)(?:\s[^>]*)?>[\s\S]*?<\/\1>\n?/g,be=/<(ide_opened_file|ide_selection)(?:\s[^>]*)?>[\s\S]*?<\/\1>\n?/g}));function Se(){return process.env.CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC?`essential-traffic`:process.env.DISABLE_TELEMETRY?`no-telemetry`:`default`}function Ce(){return Se()===`essential-traffic`}function we(){return Se()!=="default"}function Te(){return process.env.CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC?`CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC`:null}var Ee=e((()=>{}));function De(e,t){let n=e.firstPrompt?.startsWith(`<${y}>`),r=e.firstPrompt?ve(e.firstPrompt):``,i=r&&!n;return _e(e.agentName||e.customTitle||e.summary||(i?r:void 0)||t||(n?`Autonomous session`:void 0)||(e.sessionId?e.sessionId.slice(0,8):``)||``).trim()}function Oe(e){return e.toISOString().replace(/[:.]/g,`-`)}function ke(e){Z.length>=X&&Z.shift(),Z.push(e)}function Ae(e){if($===null&&($=e,Q.length>0)){let e=[...Q];Q.length=0;for(let t of e)switch(t.type){case`error`:$.logError(t.error);break;case`mcpError`:$.logMCPError(t.serverName,t.error);break;case`mcpDebug`:$.logMCPDebug(t.serverName,t.message);break}}}function je(e){let t=ae(e);try{if(r(process.env.CLAUDE_CODE_USE_BEDROCK)||r(process.env.CLAUDE_CODE_USE_VERTEX)||r(process.env.CLAUDE_CODE_USE_FOUNDRY)||process.env.DISABLE_ERROR_REPORTING||Ce())return;if(ke({error:ie(t),timestamp:new Date().toISOString()}),$===null){Q.push({type:`error`,error:t});return}$.logError(t)}catch{}}function Me(){return[...Z]}function Ne(e,t){try{if($===null){Q.push({type:`mcpError`,serverName:e,error:t});return}$.logMCPError(e,t)}catch{}}function Pe(e,t){try{if($===null){Q.push({type:`mcpDebug`,serverName:e,message:t});return}$.logMCPDebug(e,t)}catch{}}function Fe(e,t){if(!t||!t.startsWith(`repl_main_thread`))return;let{messages:n,...r}=e;te(r),ee(null)}var X,Z,Q,$,Ie=e((()=>{n(),ne(),I(),ge(),xe(),i(),se(),Ee(),re(),X=100,Z=[],Q=[],$=null,t(()=>process.argv.includes(`--hard-fail`))}));export{de as A,b as B,ue as C,F as D,P as E,j as F,k as G,v as H,A as I,I as J,O as K,T as L,g as M,h as N,M as O,w as P,E as R,p as S,u as T,y as U,C as V,S as W,ye as _,De as a,f as b,Pe as c,Ee as d,Ce as f,ve as g,_e as h,Me as i,_ as j,N as k,Ne as l,xe as m,Fe as n,Ie as o,we as p,D as q,Oe as r,je as s,Ae as t,Te as u,J as v,d as w,m as x,ge as y,x as z};