@readmagic/workmate 0.0.14 → 0.0.16

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 (312) hide show
  1. package/dist/chunks/AddWorkspaceDirectory-DAtfMH4o.js +1 -0
  2. package/dist/chunks/{AgentsMdExternalIncludesDialog-D58Vn3SK.js → AgentsMdExternalIncludesDialog-BTYgjY5c.js} +1 -1
  3. package/dist/chunks/AgentsMdExternalIncludesDialog-C6VH6JG6.js +1 -0
  4. package/dist/chunks/{App-CeC-2dzL.js → App-HF0bvxi_.js} +1 -1
  5. package/dist/chunks/ApproveApiKey-B7mKgSqY.js +1 -0
  6. package/dist/chunks/{ApproveApiKey-DFpddLyp.js → ApproveApiKey-BBFLw2B7.js} +1 -1
  7. package/dist/chunks/{BackgroundTasksDialog-9ruzl1jm.js → BackgroundTasksDialog-Coc0ecUd.js} +1 -1
  8. package/dist/chunks/BypassPermissionsModeDialog--Gx9ARd4.js +1 -0
  9. package/dist/chunks/{DiffDialog-LTdtTqsC.js → DiffDialog-tlINuFS1.js} +1 -1
  10. package/dist/chunks/Doctor-BJf49FWX.js +1 -0
  11. package/dist/chunks/{Doctor-Yvrzcrvx.js → Doctor-Wh7z6CnF.js} +2 -2
  12. package/dist/chunks/ExitFlow-B1zHTqQt.js +2 -0
  13. package/dist/chunks/Grove-1Kf7xxIV.js +11 -0
  14. package/dist/chunks/{HybridTransport-CEWG9ZRi.js → HybridTransport-DWqWUZCH.js} +1 -1
  15. package/dist/chunks/{InvalidConfigDialog-Ue3kJUPJ.js → InvalidConfigDialog-OZPFQSnC.js} +1 -1
  16. package/dist/chunks/{InvalidSettingsDialog-BO2AOTVf.js → InvalidSettingsDialog-BNCm-eyC.js} +1 -1
  17. package/dist/chunks/MCPConnectionManager-7H84oi5n.js +1 -0
  18. package/dist/chunks/MCPToolListView-CVgtg3Iq.js +1 -0
  19. package/dist/chunks/{McpParsingWarnings-BsCDFWci.js → McpParsingWarnings-CN8f449l.js} +1 -1
  20. package/dist/chunks/{MessageSelector-DY5K0NHd.js → MessageSelector-B9j6zZ5w.js} +1 -1
  21. package/dist/chunks/Messages-yz1m39eI.js +10 -0
  22. package/dist/chunks/{Onboarding-w0-VVsDz.js → Onboarding-bFbgae8m.js} +1 -1
  23. package/dist/chunks/{PromptInputFooterSuggestions-OEXx0Abp.js → PromptInputFooterSuggestions-CE_yVun1.js} +1 -1
  24. package/dist/chunks/PromptInputHelpMenu-TPWuGwAy.js +1 -0
  25. package/dist/chunks/QueryEngine-CRobcENE.js +1 -0
  26. package/dist/chunks/REPL-BhCC0JP6.js +1 -0
  27. package/dist/chunks/REPL-C33mMf_q.js +128 -0
  28. package/dist/chunks/RemoteSessionManager-BjVD918g.js +2 -0
  29. package/dist/chunks/{ResumeConversation-BbNrpSFB.js → ResumeConversation-CXd8d8po.js} +1 -1
  30. package/dist/chunks/{SSETransport-CLiI2qnD.js → SSETransport-BSilVN9e.js} +1 -1
  31. package/dist/chunks/SearchExtraToolsTool-DoiCI2uJ.js +1 -0
  32. package/dist/chunks/Settings-ClcLl0C1.js +2 -0
  33. package/dist/chunks/{TeleportProgress-IB--CbqZ.js → TeleportProgress-DonJUoPc.js} +1 -1
  34. package/dist/chunks/{TeleportRepoMismatchDialog-KjdlS_gA.js → TeleportRepoMismatchDialog-ByOuSVVz.js} +1 -1
  35. package/dist/chunks/TeleportResumeWrapper-BBtELwF1.js +1 -0
  36. package/dist/chunks/{ThemePicker-BrD_T7xF.js → ThemePicker-1QQJFOEv.js} +1 -1
  37. package/dist/chunks/{TrustDialog-L0rvvpit.js → TrustDialog-DwJ9L_u4.js} +1 -1
  38. package/dist/chunks/{ValidationErrorsList-QZvtUrAy.js → ValidationErrorsList-Cuq6W2yc.js} +1 -1
  39. package/dist/chunks/{add-dir-CpWXReCi.js → add-dir-DOKdPFT2.js} +1 -1
  40. package/dist/chunks/{agentDisplay-CrQvGkTT.js → agentDisplay-TX1bh-lX.js} +1 -1
  41. package/dist/chunks/{agents-C99yMsVF.js → agents-C58tRxpi.js} +1 -1
  42. package/dist/chunks/agents-CbRjX9Pj.js +101 -0
  43. package/dist/chunks/{allErrors-uyOMiF9U.js → allErrors-DRiW7i6Y.js} +1 -1
  44. package/dist/chunks/api-C8uOHD-v.js +1 -0
  45. package/dist/chunks/{api-C5I2xwgd.js → api-CazVavfB.js} +1 -1
  46. package/dist/chunks/auth-BL238vgr.js +1 -0
  47. package/dist/chunks/auth-CfrCl9BZ.js +10 -0
  48. package/dist/chunks/auth-D3GkU6d7.js +1 -0
  49. package/dist/chunks/{backgroundHousekeeping-CjD8bACB.js → backgroundHousekeeping-CPLlaWcV.js} +2 -2
  50. package/dist/chunks/backgroundHousekeeping-Du2tN2WE.js +1 -0
  51. package/dist/chunks/{branch-BOWBZo5K.js → branch-pAa0oBaj.js} +1 -1
  52. package/dist/chunks/{bridgeConfig-CgAVrQfz.js → bridgeConfig-DnFfCpGd.js} +1 -1
  53. package/dist/chunks/bridgeConfig-joBqeK0j.js +1 -0
  54. package/dist/chunks/{bridgeMessaging-cOFtbkf_.js → bridgeMessaging-B_hnuUHb.js} +1 -1
  55. package/dist/chunks/bridgeStatusUtil-Dwz4YHNA.js +1 -0
  56. package/dist/chunks/{btw-B0UmiVKl.js → btw-CkVkYeRr.js} +1 -1
  57. package/dist/chunks/{caches-wN3JyvNE.js → caches-BLQUkrIG.js} +1 -1
  58. package/dist/chunks/caches-DsFl83sh.js +1 -0
  59. package/dist/chunks/{ccrClient-wtUIz75R.js → ccrClient-AfdUbWzY.js} +1 -1
  60. package/dist/chunks/claudeDesktop-CB3UCt7U.js +1 -0
  61. package/dist/chunks/{clear-CNzBoL7O.js → clear-Ac3qYi_-.js} +1 -1
  62. package/dist/chunks/client-BX0r6K3I.js +1 -0
  63. package/dist/chunks/client-Bb2eZnuq.js +1 -0
  64. package/dist/chunks/client-DNEVh6Wu.js +1 -0
  65. package/dist/chunks/client-Pap_HyZZ.js +1 -0
  66. package/dist/chunks/client-zhozU2ws.js +1 -0
  67. package/dist/chunks/commands-BKLsl6gK.js +1 -0
  68. package/dist/chunks/{compact-Bj8mdDYN.js → compact-CXuDr5qM.js} +1 -1
  69. package/dist/chunks/{config-BkbL2e5Q.js → config-BSkuQZNf.js} +1 -1
  70. package/dist/chunks/{config-WMxn2jLl.js → config-D78R57VA.js} +1 -1
  71. package/dist/chunks/config-DrY1SvhQ.js +1 -0
  72. package/dist/chunks/{context-DB1Ar85E.js → context-C2plOqH4.js} +1 -1
  73. package/dist/chunks/context-noninteractive-DpVlZ-wP.js +1 -0
  74. package/dist/chunks/{context-noninteractive-CqnJTDcI.js → context-noninteractive-fVQtwEkw.js} +1 -1
  75. package/dist/chunks/conversation-C0yysXds.js +1 -0
  76. package/dist/chunks/{conversation-DOgBzrm0.js → conversation-DQpS6nvg.js} +1 -1
  77. package/dist/chunks/{createSSHSession-Cf2tOgK_.js → createSSHSession-CfyFuJMH.js} +1 -1
  78. package/dist/chunks/createSession-CmBawnsh.js +1 -0
  79. package/dist/chunks/{createSession-DD5YaQKM.js → createSession-qk9C66lK.js} +1 -1
  80. package/dist/chunks/{crossProjectResume-CkiPQYYE.js → crossProjectResume-DY1ZBO5P.js} +1 -1
  81. package/dist/chunks/{datadog-DcLf1QpG.js → datadog-Cr0VKbct.js} +1 -1
  82. package/dist/chunks/{diff-dfXWiuLA.js → diff-BNjcCXDr.js} +1 -1
  83. package/dist/chunks/{directoryCompletion-BtlRKLzw.js → directoryCompletion-i2oWpaUe.js} +1 -1
  84. package/dist/chunks/doctor-BkCtT7H1.js +1 -0
  85. package/dist/chunks/{entry-wISucmYc.js → entry-o9IZPS4g.js} +3 -3
  86. package/dist/chunks/{esm-CrJVXrKW.js → esm-BI3tFLyy.js} +1 -1
  87. package/dist/chunks/exit-Dlyj7nY8.js +1 -0
  88. package/dist/chunks/extraUsage-5Ueiyw6W.js +1 -0
  89. package/dist/chunks/extractMemories-DnTBWFOW.js +1 -0
  90. package/dist/chunks/fast-B3fRp1xO.js +1 -0
  91. package/dist/chunks/fast-ClOKONyD.js +1 -0
  92. package/dist/chunks/fetchModelList-B8KG79EK.js +1 -0
  93. package/dist/chunks/fetchModelList-gh_jFYai.js +1 -0
  94. package/dist/chunks/{fileSuggestions-Dy2BUZzd.js → fileSuggestions-DK7W8kLF.js} +1 -1
  95. package/dist/chunks/{firstPartyEventLogger-D4yuDP-n.js → firstPartyEventLogger-BMnXb9cv.js} +2 -2
  96. package/dist/chunks/firstPartyEventLogger-YYOb8aIo.js +1 -0
  97. package/dist/chunks/{flushGate-B6ecrC4j.js → flushGate-n4kK6H1U.js} +1 -1
  98. package/dist/chunks/{gemini-BC-BxZmj.js → gemini-C8-QHnsC.js} +1 -1
  99. package/dist/chunks/{generateSessionName-JTR8nPYD.js → generateSessionName-C8DnAVaa.js} +1 -1
  100. package/dist/chunks/{githubRepoPathMapping-Bk4FZrng.js → githubRepoPathMapping-Px3_GeD1.js} +1 -1
  101. package/dist/chunks/{goal-B09SOyra.js → goal-DMmzlZOF.js} +1 -1
  102. package/dist/chunks/grok-LLjpAwP_.js +1 -0
  103. package/dist/chunks/{grove-DsAIY-rZ.js → grove-CQBCzeHf.js} +1 -1
  104. package/dist/chunks/help-JH7WzjZP.js +1 -0
  105. package/dist/chunks/hooks-COhKt_pF.js +1 -0
  106. package/dist/chunks/{hooks-BI4NY5IC.js → hooks-DD2jpRfx.js} +7 -7
  107. package/dist/chunks/initReplBridge-BDaN0hpY.js +1 -0
  108. package/dist/chunks/install-CD4or0vj.js +1 -0
  109. package/dist/chunks/{instrumentation-5cSwEKaF.js → instrumentation-n-otwpYf.js} +4 -4
  110. package/dist/chunks/{job-rW1mEYtm.js → job-B-pEWgXI.js} +1 -1
  111. package/dist/chunks/keybindings-qed9q9tx.js +1 -0
  112. package/dist/chunks/{launchLocalMemory-CPucX8Xj.js → launchLocalMemory-cBovdGMT.js} +1 -1
  113. package/dist/chunks/{launchOnboarding--GCJWeeS.js → launchOnboarding-B__wtt7p.js} +1 -1
  114. package/dist/chunks/{loadAgentsDir-JrGMJN05.js → loadAgentsDir-PPiD2Mfq.js} +574 -574
  115. package/dist/chunks/loadAgentsDir-qvqrTVuS.js +1 -0
  116. package/dist/chunks/{loadPluginHooks-C4zrlV0u.js → loadPluginHooks-DUCuU3_8.js} +1 -1
  117. package/dist/chunks/localSearch-CDk_stXJ.js +1 -0
  118. package/dist/chunks/{localSearch-C-stDP9C.js → localSearch-Cvs9WfoX.js} +1 -1
  119. package/dist/chunks/{logoV2Utils-J2Sqfube.js → logoV2Utils-Bkj74dtY.js} +1 -1
  120. package/dist/chunks/{magicDocs-Dpe3YhyL.js → magicDocs-3U6peChg.js} +2 -2
  121. package/dist/chunks/main-DkjxhBIC.js +356 -0
  122. package/dist/chunks/{managedEnv-C8SisyLk.js → managedEnv-BUrzwaD3.js} +1 -1
  123. package/dist/chunks/managedEnv-XOUMOtEF.js +1 -0
  124. package/dist/chunks/{mappers-CMJorgSL.js → mappers-ZGgwqDOK.js} +1 -1
  125. package/dist/chunks/mcp-COZxwgJZ.js +6 -0
  126. package/dist/chunks/{mcp-SuAh71Ht.js → mcp-CdyNeNzh.js} +1 -1
  127. package/dist/chunks/{mcp-_tBxhPV-.js → mcp-CysOyBIn.js} +1 -1
  128. package/dist/chunks/{memory-DK8bOrUr.js → memory-B5h2TTSS.js} +1 -1
  129. package/dist/chunks/{mode-BhfhEpnW.js → mode-D3yY1fdK.js} +1 -1
  130. package/dist/chunks/model-Bz4JHoU0.js +1 -0
  131. package/dist/chunks/model-g6XBcNAG.js +1 -0
  132. package/dist/chunks/model-sviY1inu.js +1 -0
  133. package/dist/chunks/modelOptions-DYQqTLPi.js +1 -0
  134. package/dist/chunks/{nativeInstaller-xxyUjXbl.js → nativeInstaller-N1xiUpCP.js} +1 -1
  135. package/dist/chunks/{omit-od_CYp5o.js → omit-BOILu8jW.js} +1 -1
  136. package/dist/chunks/{onChangeAppState-CqTb0yEa.js → onChangeAppState-COFFZAXb.js} +1 -1
  137. package/dist/chunks/{openai-qW8mATAs.js → openai-BHM5kEFo.js} +2 -2
  138. package/dist/chunks/openai-CR3CcjCE.js +17 -0
  139. package/dist/chunks/{partition-CYoWXLNU.js → partition-C1SFDk_L.js} +1 -1
  140. package/dist/chunks/{permissions--iKUbWBw.js → permissions-uy_NFbfy.js} +3 -3
  141. package/dist/chunks/{pidLock-BR4hzYgp.js → pidLock-DuMVSwnN.js} +2 -2
  142. package/dist/chunks/{plan-DiHCGXhM.js → plan-DF9YSB5M.js} +1 -1
  143. package/dist/chunks/{plugin-BeC4D7XF.js → plugin-GRPzqgTr.js} +1 -1
  144. package/dist/chunks/{pluginAutoupdate-Bj-CrFuO.js → pluginAutoupdate-AMD-FvKB.js} +1 -1
  145. package/dist/chunks/{pluginBlocklist-DzOs-RS1.js → pluginBlocklist-DNxkAxH6.js} +1 -1
  146. package/dist/chunks/{pluginCliCommands-DwIGn58t.js → pluginCliCommands-BFoR1ZXx.js} +1 -1
  147. package/dist/chunks/{pluginFlagging-BzuymJuf.js → pluginFlagging-CW2IZWSI.js} +1 -1
  148. package/dist/chunks/{pluginOperations-CP1v-nu0.js → pluginOperations-DlWE0idP.js} +1 -1
  149. package/dist/chunks/{pluginStartupCheck-BUeBiYVq.js → pluginStartupCheck-AQGV0DCS.js} +1 -1
  150. package/dist/chunks/pluginStartupCheck-DWpquqxx.js +1 -0
  151. package/dist/chunks/{plugins-D1N31THW.js → plugins-CwUSTE4E.js} +1 -1
  152. package/dist/chunks/poorMode-DD88nPJ4.js +1 -0
  153. package/dist/chunks/{poorMode-D4L_-yWS.js → poorMode-wm2WkPF0.js} +1 -1
  154. package/dist/chunks/print-9wR_ijrL.js +14 -0
  155. package/dist/chunks/{processBashCommand-BGCIqxc9.js → processBashCommand-Deqwq1IE.js} +1 -1
  156. package/dist/chunks/{processSlashCommand-qR_j1DE8.js → processSlashCommand-U9LJ4Keq.js} +2 -2
  157. package/dist/chunks/prompt-BBeDQXIs.js +1 -0
  158. package/dist/chunks/{prompt-DnPppVz8.js → prompt-CQmEvnKN.js} +1 -1
  159. package/dist/chunks/prompt-CXhdqgB7.js +1 -0
  160. package/dist/chunks/{promptEditor-Cilc9N3L.js → promptEditor-Bf72KNF-.js} +1 -1
  161. package/dist/chunks/{protocolHandler-DdbiucQa.js → protocolHandler--eQQuSyx.js} +1 -1
  162. package/dist/chunks/{reconciler-Bte4gdP-.js → reconciler-Css9bs07.js} +1 -1
  163. package/dist/chunks/{refresh-MiZ0acBm.js → refresh-B87z39Zs.js} +1 -1
  164. package/dist/chunks/{registerProtocol-Bpte9dly.js → registerProtocol-DrWIX3Lb.js} +1 -1
  165. package/dist/chunks/{reload-plugins-GdqFZblC.js → reload-plugins-BpmUIkfm.js} +1 -1
  166. package/dist/chunks/{remoteBridgeCore-CAl3_H-O.js → remoteBridgeCore-BCLIIygk.js} +1 -1
  167. package/dist/chunks/{remoteManagedSettings-BcLJLEr7.js → remoteManagedSettings-Ahgn2e80.js} +1 -1
  168. package/dist/chunks/{rename-BDo5qIK0.js → rename-BUt3PliQ.js} +1 -1
  169. package/dist/chunks/{resume-Bbweh2hA.js → resume-uZI9p_FE.js} +1 -1
  170. package/dist/chunks/ripgrep-Di-2j8Ws.js +1 -0
  171. package/dist/chunks/{ripgrep-X5m4gJ-3.js → ripgrep-DsLUmulz.js} +1 -1
  172. package/dist/chunks/{runtimeObserver-CxXxUcrm.js → runtimeObserver-AKOWfdZ_.js} +1 -1
  173. package/dist/chunks/{runtimeObserver-Hjbo43xj.js → runtimeObserver-By59MZKJ.js} +2 -2
  174. package/dist/chunks/sandbox-adapter-D4Uho1vF.js +1 -0
  175. package/dist/chunks/sandbox-toggle-BdvylnWS.js +1 -0
  176. package/dist/chunks/searchExtraTools-BHMkqGBf.js +1 -0
  177. package/dist/chunks/{session-CkuTMD_4.js → session-Tm2-rzBY.js} +1 -1
  178. package/dist/chunks/sessionFileAccessHooks-BaWZ8sqn.js +1 -0
  179. package/dist/chunks/{sessionObserver-CvQ6oyoj.js → sessionObserver-BAr8AWeL.js} +1 -1
  180. package/dist/chunks/sessionObserver-KB1UL_n2.js +1 -0
  181. package/dist/chunks/{sessionState-C2REgUrs.js → sessionState-BTFowSpR.js} +2 -2
  182. package/dist/chunks/sessionStorage-D6nlmaI-.js +1 -0
  183. package/dist/chunks/{sessionTitle-2IWcNB8H.js → sessionTitle-SCqmSDYM.js} +1 -1
  184. package/dist/chunks/{sessionTracing-Bm7hQKHA.js → sessionTracing-CvY4udYI.js} +1 -1
  185. package/dist/chunks/settings-BgHApyGL.js +1 -0
  186. package/dist/chunks/{settings-aUygByiZ.js → settings-CvhsRFaT.js} +1 -1
  187. package/dist/chunks/{settingsSync-DgzCU1BZ.js → settingsSync-nxeaGM2-.js} +1 -1
  188. package/dist/chunks/setup-D4FPeBnM.js +3 -0
  189. package/dist/chunks/{shadowedRuleDetection-CWCQ5dZ0.js → shadowedRuleDetection-Co8m1q1D.js} +1 -1
  190. package/dist/chunks/{sideQuestion-BoW-xYkh.js → sideQuestion-4TJYn-Az.js} +1 -1
  191. package/dist/chunks/{sinks-ZHKfs6gv.js → sinks-Bb2i50kz.js} +1 -1
  192. package/dist/chunks/sinks-D1opmy_x.js +1 -0
  193. package/dist/chunks/skillChangeDetector-BU9AFG0i.js +1 -0
  194. package/dist/chunks/{skillGapStore-CCNeSjIb.js → skillGapStore-BcVP3ZUb.js} +2 -2
  195. package/dist/chunks/{skillLifecycle-wU4JDNYQ.js → skillLifecycle-CG2XmS8f.js} +2 -2
  196. package/dist/chunks/{skillSearchPanel-Cxr1QQn4.js → skillSearchPanel-DOJmUBXB.js} +4 -4
  197. package/dist/chunks/{skills-BghnKnNo.js → skills-DIgCWvzX.js} +1 -1
  198. package/dist/chunks/{stats-unp6R0Ah.js → stats-Dq-5qizS.js} +1 -1
  199. package/dist/chunks/status-Ber2xOXc.js +2 -0
  200. package/dist/chunks/status-CVcXPoOZ.js +1 -0
  201. package/dist/chunks/{statusNoticeHelpers-Dm1aiibR.js → statusNoticeHelpers-CYkrPUpN.js} +1 -1
  202. package/dist/chunks/{switcher-BUNSEJ-7.js → switcher-BIP3rbQn.js} +1 -1
  203. package/dist/chunks/switcher-zbG6T9dN.js +1 -0
  204. package/dist/chunks/syncCache-AMQMQ_HR.js +1 -0
  205. package/dist/chunks/{tasks-BjFot03S.js → tasks-BKERIO4G.js} +1 -1
  206. package/dist/chunks/{teleport-Dj2Kvbmx.js → teleport-DOXbf2sQ.js} +1 -1
  207. package/dist/chunks/{templateJobs-CY7GNRo5.js → templateJobs-dg2F45ZJ.js} +1 -1
  208. package/dist/chunks/{terminalSetup-Ty8T8ePM.js → terminalSetup-DDvQ0K5e.js} +1 -1
  209. package/dist/chunks/{terminalSetup-CpMNk6dc.js → terminalSetup-JJiXmszo.js} +1 -1
  210. package/dist/chunks/{theme-c6grxWNn.js → theme-BGxytGjA.js} +1 -1
  211. package/dist/chunks/{toolEventObserver-D7WbjgFR.js → toolEventObserver-CJhg_p3P.js} +1 -1
  212. package/dist/chunks/toolPool-C0d7Bznl.js +1 -0
  213. package/dist/chunks/{trustedDevice-BF78PNK8.js → trustedDevice-BtXHXu-T.js} +1 -1
  214. package/dist/chunks/trustedDevice-hw3iq84W.js +1 -0
  215. package/dist/chunks/{useExitOnCtrlCDWithKeybindings-qLfN0tc-.js → useExitOnCtrlCDWithKeybindings-C9orgrub.js} +1 -1
  216. package/dist/chunks/useMainLoopModel-BigVcn2T.js +1 -0
  217. package/dist/chunks/{useManagePlugins-E0Qzj-ws.js → useManagePlugins-Bt-DYAnX.js} +1 -1
  218. package/dist/chunks/{useMergedTools-B7iYaNwM.js → useMergedTools-CZeQBdky.js} +1 -1
  219. package/dist/chunks/{useSearchInput-CsxiM9i0.js → useSearchInput-DdKrVHJS.js} +1 -1
  220. package/dist/chunks/{useSettingsErrors-DdVTahNa.js → useSettingsErrors-BR9Wws7D.js} +1 -1
  221. package/dist/chunks/{userAgent-BggRZ-ZE.js → userAgent-DUt0q-Vl.js} +1 -1
  222. package/dist/chunks/{util-Xdy1nOjj.js → util-h-Hmdke_.js} +1 -1
  223. package/dist/chunks/validatePlugin-mWVKNtJa.js +1 -0
  224. package/dist/chunks/{vim-cFcxfuac.js → vim-s-wmybpU.js} +1 -1
  225. package/dist/chunks/{workerRegistry-GrD7IAVQ.js → workerRegistry-dlfqtySm.js} +2 -2
  226. package/dist/chunks/worktree-IxcFe7g-.js +1 -0
  227. package/dist/cli.js +1 -1
  228. package/package.json +1 -1
  229. package/dist/chunks/AddWorkspaceDirectory-m2d3nOQJ.js +0 -1
  230. package/dist/chunks/AgentsMdExternalIncludesDialog-BRXGkHO4.js +0 -1
  231. package/dist/chunks/ApproveApiKey-NXTWIAMj.js +0 -1
  232. package/dist/chunks/BypassPermissionsModeDialog-C4QGpcBT.js +0 -1
  233. package/dist/chunks/Doctor-DmiDH-lg.js +0 -1
  234. package/dist/chunks/ExitFlow-DH0L3tyY.js +0 -2
  235. package/dist/chunks/Grove-BhhnrFX9.js +0 -11
  236. package/dist/chunks/MCPConnectionManager-Ciy9y9VV.js +0 -1
  237. package/dist/chunks/MCPToolListView-Ddmu2UcL.js +0 -1
  238. package/dist/chunks/Messages-LD6ZO301.js +0 -10
  239. package/dist/chunks/PromptInputHelpMenu-DyaUsvNx.js +0 -1
  240. package/dist/chunks/QueryEngine-sH-KjJIq.js +0 -1
  241. package/dist/chunks/REPL-BMH_RItw.js +0 -128
  242. package/dist/chunks/REPL-DkPd3vk5.js +0 -1
  243. package/dist/chunks/RemoteSessionManager-DJhrR1dz.js +0 -2
  244. package/dist/chunks/SearchExtraToolsTool-DupzA6Vm.js +0 -1
  245. package/dist/chunks/Settings-B1EI5LOU.js +0 -2
  246. package/dist/chunks/TeleportResumeWrapper-DnHTI39O.js +0 -1
  247. package/dist/chunks/agents-BYQO6DbG.js +0 -101
  248. package/dist/chunks/api-j0iE1mkR.js +0 -1
  249. package/dist/chunks/auth-BYCRa_mb.js +0 -10
  250. package/dist/chunks/auth-C9FUZzpW.js +0 -1
  251. package/dist/chunks/auth-DwPrlTHv.js +0 -1
  252. package/dist/chunks/backgroundHousekeeping-BxcVB3By.js +0 -1
  253. package/dist/chunks/bridgeConfig-Bxs5dqjH.js +0 -1
  254. package/dist/chunks/bridgeStatusUtil-BQF0AJDO.js +0 -1
  255. package/dist/chunks/caches-C9--b9a7.js +0 -1
  256. package/dist/chunks/claudeDesktop-DPIJpc1V.js +0 -1
  257. package/dist/chunks/client-B7WkO81L.js +0 -17
  258. package/dist/chunks/client-BCzhAEd0.js +0 -1
  259. package/dist/chunks/client-Dr9AYB-r.js +0 -1
  260. package/dist/chunks/commands-DTB0Qzd5.js +0 -1
  261. package/dist/chunks/config-B1kYcRIP.js +0 -1
  262. package/dist/chunks/context-noninteractive-Bno2Xsmp.js +0 -1
  263. package/dist/chunks/conversation-hNXWaswI.js +0 -1
  264. package/dist/chunks/createSession-BZx-2UIB.js +0 -1
  265. package/dist/chunks/doctor-aKE2bG5C.js +0 -1
  266. package/dist/chunks/exit-pjN4EJHV.js +0 -1
  267. package/dist/chunks/extraUsage-CwDhpClH.js +0 -1
  268. package/dist/chunks/extractMemories-WmPLOLUT.js +0 -1
  269. package/dist/chunks/fast-BVABmasw.js +0 -1
  270. package/dist/chunks/fast-Cuj3bfFm.js +0 -1
  271. package/dist/chunks/firstPartyEventLogger-CabA8fu0.js +0 -1
  272. package/dist/chunks/grok-BBo3jGfP.js +0 -1
  273. package/dist/chunks/help-CELr6oJZ.js +0 -1
  274. package/dist/chunks/hooks-9rkDD2iw.js +0 -1
  275. package/dist/chunks/initReplBridge-BYrL6ou1.js +0 -1
  276. package/dist/chunks/install-Dn3_M1Ui.js +0 -1
  277. package/dist/chunks/keybindings-B5kUoxvg.js +0 -1
  278. package/dist/chunks/loadAgentsDir-D-a1uUb5.js +0 -1
  279. package/dist/chunks/localSearch-hOERAH9v.js +0 -1
  280. package/dist/chunks/main-C_PDzJdv.js +0 -356
  281. package/dist/chunks/managedEnv-AEhH_HUs.js +0 -1
  282. package/dist/chunks/mcp-B2mJmWKt.js +0 -6
  283. package/dist/chunks/model-BCM7RpVk.js +0 -1
  284. package/dist/chunks/model-BWR43D3c.js +0 -1
  285. package/dist/chunks/model-CmDF8O9G.js +0 -1
  286. package/dist/chunks/modelOptions-DEQat7lU.js +0 -1
  287. package/dist/chunks/pluginStartupCheck-BGN6Je6d.js +0 -1
  288. package/dist/chunks/poorMode-XDBnxTiF.js +0 -1
  289. package/dist/chunks/print-DaJi1wF_.js +0 -14
  290. package/dist/chunks/prompt-B0gADAvI.js +0 -1
  291. package/dist/chunks/prompt-DqyEtC_I2.js +0 -1
  292. package/dist/chunks/ripgrep-DrpZ79Pp.js +0 -1
  293. package/dist/chunks/sandbox-adapter-DQ_fJSIo.js +0 -1
  294. package/dist/chunks/sandbox-toggle-DmNSThQK.js +0 -1
  295. package/dist/chunks/searchExtraTools-C7b2x2p_.js +0 -1
  296. package/dist/chunks/sessionFileAccessHooks-CQvGAbvL.js +0 -1
  297. package/dist/chunks/sessionObserver-BoQY7nOa.js +0 -1
  298. package/dist/chunks/sessionStorage-BeaEgnaa.js +0 -1
  299. package/dist/chunks/settings-Da6ax5aI.js +0 -1
  300. package/dist/chunks/setup-CvaG4nl5.js +0 -3
  301. package/dist/chunks/sinks-B_ehGpvp.js +0 -1
  302. package/dist/chunks/skillChangeDetector-C-HWR_8v.js +0 -1
  303. package/dist/chunks/status-BraYBx4N.js +0 -2
  304. package/dist/chunks/status-DwyWiaVc.js +0 -1
  305. package/dist/chunks/switcher-DDUnWU_4.js +0 -1
  306. package/dist/chunks/syncCache-1s9xV8WV.js +0 -1
  307. package/dist/chunks/toolPool-O5nkEFb1.js +0 -1
  308. package/dist/chunks/trustedDevice-D_z7bAQh.js +0 -1
  309. package/dist/chunks/updateCCB-ts7Joyve.js +0 -5
  310. package/dist/chunks/useMainLoopModel-DkjG_ikT.js +0 -1
  311. package/dist/chunks/validatePlugin-Be5aSSnP.js +0 -1
  312. package/dist/chunks/worktree-V7xiUAtl.js +0 -1
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{P as t,R as n,c as r,i}from"./debug-BQj6h99Q.js";import{i as a,t as o}from"./sessionIdCompat-Dgp6PW_1.js";import{i as s,o as c}from"./debugUtils-B86DM1Sp.js";async function l({environmentId:e,title:n,events:i,gitRepoUrl:a,branch:o,signal:c,baseUrl:l,getAccessToken:u,permissionMode:d}){let{getClaudeAIOAuthTokens:f}=await import(`./auth-DwPrlTHv.js`),{getOrganizationUUID:p}=await import(`./client-Dr9AYB-r.js`),{getOauthConfig:m}=await import(`./oauth-U649LV5H.js`),{getOAuthHeaders:h}=await import(`./api-j0iE1mkR.js`),{parseGitHubRepository:g}=await import(`./detectRepository-tRUoPOKy.js`),{getDefaultBranch:_}=await import(`./git-BaSq69E7.js`),{getMainLoopModel:v}=await import(`./model-BWR43D3c.js`),{default:y}=await import(`./axios-BHBm_hhU.js`),{isSelfHostedBridge:b}=await import(`./bridgeConfig-Bxs5dqjH.js`),x=u?.()??f()?.accessToken;if(!x)return r(`[bridge] No access token for session creation`),null;let S=b()?`self-hosted`:await p();if(!S)return r(`[bridge] No org UUID for session creation`),null;let C=null,w=null;if(a){let{parseGitRemote:e}=await import(`./detectRepository-tRUoPOKy.js`),t=e(a);if(t){let{host:e,owner:n,name:r}=t,i=o||await _()||void 0;C={type:`git_repository`,url:`https://${e}/${n}/${r}`,revision:i},w={type:`git_repository`,git_info:{type:`github`,repo:`${n}/${r}`,branches:[`claude/${o||`task`}`]}}}else{let e=g(a);if(e){let[t,n]=e.split(`/`);if(t&&n){let e=o||await _()||void 0;C={type:`git_repository`,url:`https://github.com/${t}/${n}`,revision:e},w={type:`git_repository`,git_info:{type:`github`,repo:`${t}/${n}`,branches:[`claude/${o||`task`}`]}}}}}}let T={...n!==void 0&&{title:n},events:i,session_context:{sources:C?[C]:[],outcomes:w?[w]:[],model:v()},environment_id:e,source:`remote-control`,...d&&{permission_mode:d}},E={...h(x),"anthropic-beta":`ccr-byoc-2025-07-29`,"x-organization-uuid":S},D=`${l??m().BASE_API_URL}/v1/sessions`,O;try{O=await y.post(D,T,{headers:E,signal:c,validateStatus:e=>e<500})}catch(e){return r(`[bridge] Session creation request failed: ${t(e)}`),null}if(!(O.status===200||O.status===201)){let e=s(O.data);return r(`[bridge] Session creation failed with status ${O.status}${e?`: ${e}`:``}`),null}let k=O.data;return!k||typeof k!=`object`||!(`id`in k)||typeof k.id!=`string`?(r(`[bridge] No session ID in response`),null):k.id}async function u(e,n){let{getClaudeAIOAuthTokens:i}=await import(`./auth-DwPrlTHv.js`),{getOrganizationUUID:a}=await import(`./client-Dr9AYB-r.js`),{getOauthConfig:o}=await import(`./oauth-U649LV5H.js`),{getOAuthHeaders:c}=await import(`./api-j0iE1mkR.js`),{default:l}=await import(`./axios-BHBm_hhU.js`),{isSelfHostedBridge:u}=await import(`./bridgeConfig-Bxs5dqjH.js`),d=n?.getAccessToken?.()??i()?.accessToken;if(!d)return r(`[bridge] No access token for session fetch`),null;let f=u()?`self-hosted`:await a();if(!f)return r(`[bridge] No org UUID for session fetch`),null;let p={...c(d),"anthropic-beta":`ccr-byoc-2025-07-29`,"x-organization-uuid":f},m=`${n?.baseUrl??o().BASE_API_URL}/v1/sessions/${e}`;r(`[bridge] Fetching session ${e}`);let h;try{h=await l.get(m,{headers:p,timeout:1e4,validateStatus:e=>e<500})}catch(e){return r(`[bridge] Session fetch request failed: ${t(e)}`),null}if(h.status!==200){let e=s(h.data);return r(`[bridge] Session fetch failed with status ${h.status}${e?`: ${e}`:``}`),null}return h.data}async function d(e,t){let{getClaudeAIOAuthTokens:n}=await import(`./auth-DwPrlTHv.js`),{getOrganizationUUID:i}=await import(`./client-Dr9AYB-r.js`),{getOauthConfig:a}=await import(`./oauth-U649LV5H.js`),{getOAuthHeaders:o}=await import(`./api-j0iE1mkR.js`),{default:c}=await import(`./axios-BHBm_hhU.js`),{isSelfHostedBridge:l}=await import(`./bridgeConfig-Bxs5dqjH.js`),u=t?.getAccessToken?.()??n()?.accessToken;if(!u){r(`[bridge] No access token for session archive`);return}let d=l()?`self-hosted`:await i();if(!d){r(`[bridge] No org UUID for session archive`);return}let f={...o(u),"anthropic-beta":`ccr-byoc-2025-07-29`,"x-organization-uuid":d},p=`${t?.baseUrl??a().BASE_API_URL}/v1/sessions/${e}/archive`;r(`[bridge] Archiving session ${e}`);let m=await c.post(p,{},{headers:f,timeout:t?.timeoutMs??1e4,validateStatus:e=>e<500});if(m.status===200)r(`[bridge] Session ${e} archived successfully`);else{let e=s(m.data);r(`[bridge] Session archive failed with status ${m.status}${e?`: ${e}`:``}`)}}async function f(e,n,i){let{getClaudeAIOAuthTokens:o}=await import(`./auth-DwPrlTHv.js`),{getOrganizationUUID:c}=await import(`./client-Dr9AYB-r.js`),{getOauthConfig:l}=await import(`./oauth-U649LV5H.js`),{getOAuthHeaders:u}=await import(`./api-j0iE1mkR.js`),{default:d}=await import(`./axios-BHBm_hhU.js`),{isSelfHostedBridge:f}=await import(`./bridgeConfig-Bxs5dqjH.js`),p=i?.getAccessToken?.()??o()?.accessToken;if(!p){r(`[bridge] No access token for session title update`);return}let m=f()?`self-hosted`:await c();if(!m){r(`[bridge] No org UUID for session title update`);return}let h={...u(p),"anthropic-beta":`ccr-byoc-2025-07-29`,"x-organization-uuid":m},g=a(e),_=`${i?.baseUrl??l().BASE_API_URL}/v1/sessions/${g}`;r(`[bridge] Updating session title: ${g} → ${n}`);try{let e=await d.patch(_,{title:n},{headers:h,timeout:1e4,validateStatus:e=>e<500});if(e.status===200)r(`[bridge] Session title updated successfully`);else{let t=s(e.data);r(`[bridge] Session title update failed with status ${e.status}${t?`: ${t}`:``}`)}}catch(e){r(`[bridge] Session title update request failed: ${t(e)}`)}}var p=e((()=>{i(),n(),c(),o()}));export{f as a,p as i,l as n,u as r,d as t};
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{P as t,R as n,c as r,i}from"./debug-BQj6h99Q.js";import{i as a,t as o}from"./sessionIdCompat-Dgp6PW_1.js";import{i as s,o as c}from"./debugUtils-B86DM1Sp.js";async function l({environmentId:e,title:n,events:i,gitRepoUrl:a,branch:o,signal:c,baseUrl:l,getAccessToken:u,permissionMode:d}){let{getClaudeAIOAuthTokens:f}=await import(`./auth-BL238vgr.js`),{getOrganizationUUID:p}=await import(`./client-BX0r6K3I.js`),{getOauthConfig:m}=await import(`./oauth-U649LV5H.js`),{getOAuthHeaders:h}=await import(`./api-C8uOHD-v.js`),{parseGitHubRepository:g}=await import(`./detectRepository-tRUoPOKy.js`),{getDefaultBranch:_}=await import(`./git-BaSq69E7.js`),{getMainLoopModel:v}=await import(`./model-g6XBcNAG.js`),{default:y}=await import(`./axios-BHBm_hhU.js`),{isSelfHostedBridge:b}=await import(`./bridgeConfig-joBqeK0j.js`),x=u?.()??f()?.accessToken;if(!x)return r(`[bridge] No access token for session creation`),null;let S=b()?`self-hosted`:await p();if(!S)return r(`[bridge] No org UUID for session creation`),null;let C=null,w=null;if(a){let{parseGitRemote:e}=await import(`./detectRepository-tRUoPOKy.js`),t=e(a);if(t){let{host:e,owner:n,name:r}=t,i=o||await _()||void 0;C={type:`git_repository`,url:`https://${e}/${n}/${r}`,revision:i},w={type:`git_repository`,git_info:{type:`github`,repo:`${n}/${r}`,branches:[`claude/${o||`task`}`]}}}else{let e=g(a);if(e){let[t,n]=e.split(`/`);if(t&&n){let e=o||await _()||void 0;C={type:`git_repository`,url:`https://github.com/${t}/${n}`,revision:e},w={type:`git_repository`,git_info:{type:`github`,repo:`${t}/${n}`,branches:[`claude/${o||`task`}`]}}}}}}let T={...n!==void 0&&{title:n},events:i,session_context:{sources:C?[C]:[],outcomes:w?[w]:[],model:v()},environment_id:e,source:`remote-control`,...d&&{permission_mode:d}},E={...h(x),"anthropic-beta":`ccr-byoc-2025-07-29`,"x-organization-uuid":S},D=`${l??m().BASE_API_URL}/v1/sessions`,O;try{O=await y.post(D,T,{headers:E,signal:c,validateStatus:e=>e<500})}catch(e){return r(`[bridge] Session creation request failed: ${t(e)}`),null}if(!(O.status===200||O.status===201)){let e=s(O.data);return r(`[bridge] Session creation failed with status ${O.status}${e?`: ${e}`:``}`),null}let k=O.data;return!k||typeof k!=`object`||!(`id`in k)||typeof k.id!=`string`?(r(`[bridge] No session ID in response`),null):k.id}async function u(e,n){let{getClaudeAIOAuthTokens:i}=await import(`./auth-BL238vgr.js`),{getOrganizationUUID:a}=await import(`./client-BX0r6K3I.js`),{getOauthConfig:o}=await import(`./oauth-U649LV5H.js`),{getOAuthHeaders:c}=await import(`./api-C8uOHD-v.js`),{default:l}=await import(`./axios-BHBm_hhU.js`),{isSelfHostedBridge:u}=await import(`./bridgeConfig-joBqeK0j.js`),d=n?.getAccessToken?.()??i()?.accessToken;if(!d)return r(`[bridge] No access token for session fetch`),null;let f=u()?`self-hosted`:await a();if(!f)return r(`[bridge] No org UUID for session fetch`),null;let p={...c(d),"anthropic-beta":`ccr-byoc-2025-07-29`,"x-organization-uuid":f},m=`${n?.baseUrl??o().BASE_API_URL}/v1/sessions/${e}`;r(`[bridge] Fetching session ${e}`);let h;try{h=await l.get(m,{headers:p,timeout:1e4,validateStatus:e=>e<500})}catch(e){return r(`[bridge] Session fetch request failed: ${t(e)}`),null}if(h.status!==200){let e=s(h.data);return r(`[bridge] Session fetch failed with status ${h.status}${e?`: ${e}`:``}`),null}return h.data}async function d(e,t){let{getClaudeAIOAuthTokens:n}=await import(`./auth-BL238vgr.js`),{getOrganizationUUID:i}=await import(`./client-BX0r6K3I.js`),{getOauthConfig:a}=await import(`./oauth-U649LV5H.js`),{getOAuthHeaders:o}=await import(`./api-C8uOHD-v.js`),{default:c}=await import(`./axios-BHBm_hhU.js`),{isSelfHostedBridge:l}=await import(`./bridgeConfig-joBqeK0j.js`),u=t?.getAccessToken?.()??n()?.accessToken;if(!u){r(`[bridge] No access token for session archive`);return}let d=l()?`self-hosted`:await i();if(!d){r(`[bridge] No org UUID for session archive`);return}let f={...o(u),"anthropic-beta":`ccr-byoc-2025-07-29`,"x-organization-uuid":d},p=`${t?.baseUrl??a().BASE_API_URL}/v1/sessions/${e}/archive`;r(`[bridge] Archiving session ${e}`);let m=await c.post(p,{},{headers:f,timeout:t?.timeoutMs??1e4,validateStatus:e=>e<500});if(m.status===200)r(`[bridge] Session ${e} archived successfully`);else{let e=s(m.data);r(`[bridge] Session archive failed with status ${m.status}${e?`: ${e}`:``}`)}}async function f(e,n,i){let{getClaudeAIOAuthTokens:o}=await import(`./auth-BL238vgr.js`),{getOrganizationUUID:c}=await import(`./client-BX0r6K3I.js`),{getOauthConfig:l}=await import(`./oauth-U649LV5H.js`),{getOAuthHeaders:u}=await import(`./api-C8uOHD-v.js`),{default:d}=await import(`./axios-BHBm_hhU.js`),{isSelfHostedBridge:f}=await import(`./bridgeConfig-joBqeK0j.js`),p=i?.getAccessToken?.()??o()?.accessToken;if(!p){r(`[bridge] No access token for session title update`);return}let m=f()?`self-hosted`:await c();if(!m){r(`[bridge] No org UUID for session title update`);return}let h={...u(p),"anthropic-beta":`ccr-byoc-2025-07-29`,"x-organization-uuid":m},g=a(e),_=`${i?.baseUrl??l().BASE_API_URL}/v1/sessions/${g}`;r(`[bridge] Updating session title: ${g} → ${n}`);try{let e=await d.patch(_,{title:n},{headers:h,timeout:1e4,validateStatus:e=>e<500});if(e.status===200)r(`[bridge] Session title updated successfully`);else{let t=s(e.data);r(`[bridge] Session title update failed with status ${e.status}${t?`: ${t}`:``}`)}}catch(e){r(`[bridge] Session title update request failed: ${t(e)}`)}}var p=e((()=>{i(),n(),c(),o()}));export{f as a,p as i,l as n,u as r,d as t};
@@ -1,4 +1,4 @@
1
- import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{$u as n,Ci as r,Dp as i,Gc as a,Hu as o,Jw as s,Mu as c,Nr as l,Op as u,Pu as d,Qu as f,Si as ee,Sr as te,Uu as p,Yw as m,br as h,cd as ne,fr as g,hC as _,ir as v,ld as re,oi as ie,qc as ae,wr as y,xC as oe}from"./loadAgentsDir-JrGMJN05.js";import{C as se,D as b,Gr as x,H as ce,I as S,P as C,T as w,Wt as le,Xn as ue,ai as T,di as E,fi as de,hn as fe,k as pe,oi as me,ot as he,p as D,t as ge}from"./src-DL3w8VPk2.js";import{t as O}from"./jsx-runtime-Bb4Xn-E0.js";import{Wt as _e,et as ve,pt as ye}from"./state-BPFYBqm1.js";import{S as k,c as A,i as be,x as xe}from"./debug-BQj6h99Q.js";import{Ln as j,Rn as Se}from"./settings-aUygByiZ.js";import{i as Ce,m as we}from"./git-DplvjXEY.js";import{a as Te,o as Ee,s as De}from"./log-BlJ7CcKG.js";import{n as Oe,r as M}from"./analytics-DJobLaWP.js";import{C as ke,d as Ae,m as je,v as Me}from"./startupProfiler-2sjXZkIP.js";import{_ as N,h as P}from"./model-CmDF8O9G.js";import{i as Ne,r as Pe}from"./shellQuote-D3Ocv_U-.js";import{n as Fe,t as Ie}from"./useExitOnCtrlCDWithKeybindings-qLfN0tc-.js";import{t as Le}from"./SearchBox-CwwV0W-w.js";import{n as Re,t as ze}from"./useSearchInput-CsxiM9i0.js";import{n as F,t as Be}from"./Messages-LD6ZO301.js";function Ve({log:e,onExit:t,onSelect:n}){let[r,o]=I.useState(null);I.useEffect(()=>{o(null),y(e)&&l(e).then(o)},[e]);let s=y(e)&&r===null,c=r??e,u=g(c)||``,d=a();return le(`confirm:no`,t,{context:`Confirmation`}),le(`confirm:yes`,(0,I.useCallback)(()=>{n(r??e)},[n,r,e]),{context:`Confirmation`}),s?(0,L.jsxs)(S,{flexDirection:`column`,padding:1,children:[(0,L.jsx)(D,{message:`Loading session…`}),(0,L.jsx)(C,{dimColor:!0,children:(0,L.jsx)(w,{children:(0,L.jsx)(i,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})})})]}):(0,L.jsxs)(S,{flexDirection:`column`,children:[(0,L.jsx)(Be,{messages:c.messages,tools:d,commands:[],verbose:!0,toolJSX:null,toolUseConfirmQueue:[],inProgressToolUseIDs:new Set,isMessageSelectorVisible:!1,conversationId:u,screen:`transcript`,streamingToolUses:[],showAllInTranscript:!0,isLoading:!1}),(0,L.jsxs)(S,{flexShrink:0,flexDirection:`column`,borderTopDimColor:!0,borderBottom:!1,borderLeft:!1,borderRight:!1,borderStyle:`single`,paddingLeft:2,children:[(0,L.jsxs)(C,{children:[je(c.modified),` · `,c.messageCount,` messages`,c.gitBranch?` · ${c.gitBranch}`:``]}),(0,L.jsx)(C,{dimColor:!0,children:(0,L.jsxs)(w,{children:[(0,L.jsx)(b,{shortcut:`Enter`,action:`resume`}),(0,L.jsx)(i,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]})})]})]})}var I,L,He=e((()=>{I=t(T(),1),ge(),_(),ae(),Me(),h(),u(),F(),L=O()}));function R(e,t){if(e===B)return 5;let n=x(e),r=t?Math.min(n,t-V-H):n;return Math.max(0,r)+V+H}function Ue(e,t){let n=t-V-H;return x(e)<=n?e:n<=1?e.charAt(0):ke(e,n)}function We({tabs:e,selectedIndex:t,availableWidth:n,showAllProjects:r=!1}){let i=r?`Resume (All Projects)`:`Resume`,a=i.length+1,o=Math.max(Ye,W),s=n-a-o-2,c=Math.max(0,Math.min(t,e.length-1)),l=Math.max(20,Math.floor(s/2)),u=e.map(e=>R(e,l)),d=0,f=e.length;if(u.reduce((e,t,n)=>e+t+ +(n<u.length-1),0)>s){let t=s-Je,n=u[c]??0;for(d=c,f=c+1;d>0||f<e.length;){let r=d>0,i=f<e.length;if(r){let e=(u[d-1]??0)+1;if(n+e<=t){d--,n+=e;continue}}if(i){let e=(u[f]??0)+1;if(n+e<=t){f++,n+=e;continue}}break}}let ee=d,te=e.length-f,p=e.slice(d,f),m=p.map((e,t)=>d+t);return(0,z.jsxs)(S,{flexDirection:`row`,gap:1,children:[(0,z.jsx)(C,{color:`suggestion`,children:i}),ee>0&&(0,z.jsxs)(C,{dimColor:!0,children:[U,ee]}),p.map((e,t)=>{let n=m[t]===c,r=e===B?e:`#${Ue(e,l-V)}`;return(0,z.jsxs)(C,{backgroundColor:n?`suggestion`:void 0,color:n?`inverseText`:void 0,bold:n,children:[` `,r,` `]},e)}),te>0?(0,z.jsxs)(C,{dimColor:!0,children:[Ge,te,Ke]}):(0,z.jsx)(C,{dimColor:!0,children:qe})]})}var z,B,V,H,U,Ge,Ke,qe,Je,Ye,W,G=e((()=>{ge(),Me(),z=O(),B=`All`,V=2,H=1,U=`← `,Ge=`→`,Ke=` (tab to cycle)`,qe=`(tab to cycle)`,Je=5,Ye=18,W=14}));function Xe({nodes:e,onSelect:t,onCancel:n,onFocus:r,focusNodeId:i,visibleOptionCount:a,layout:o=`expanded`,isDisabled:s=!1,hideIndexes:c=!1,isNodeExpanded:l,onExpand:u,onCollapse:d,getParentPrefix:ee,getChildPrefix:te,onUpFromFirstItem:p}){let[m,h]=K.useState(new Set),ne=K.useRef(!1),g=K.useRef(null),_=K.useCallback(e=>l?l(e):m.has(e),[l,m]),v=K.useMemo(()=>{let t=[];function n(e,r,i){let a=!!e.children&&e.children.length>0,o=_(e.id);if(t.push({node:e,depth:r,isExpanded:o,hasChildren:a,parentId:i}),a&&o&&e.children)for(let t of e.children)n(t,r+1,e.id)}for(let t of e)n(t,0);return t},[e,_]),re=K.useCallback(e=>e?`▼ `:`▶ `,[]),ie=K.useCallback(e=>` ▸ `,[]),ae=ee??re,y=te??ie,oe=K.useCallback(e=>{let t=``;return e.hasChildren?t=ae(e.isExpanded):e.depth>0&&(t=y(e.depth)),t+e.node.label},[ae,y]),se=K.useMemo(()=>v.map(e=>({label:oe(e),description:e.node.description,dimDescription:e.node.dimDescription??!0,value:e.node.id})),[v,oe]),b=K.useMemo(()=>{let e=new Map;return v.forEach(t=>e.set(t.node.id,t.node)),e},[v]),x=K.useCallback(e=>v.find(t=>t.node.id===e),[v]),ce=K.useCallback((e,t)=>{x(e)?.hasChildren&&(t?u?u(e):h(t=>new Set(t).add(e)):d?d(e):h(t=>{let n=new Set(t);return n.delete(e),n}))},[x,u,d]);return(0,Ze.jsx)(S,{tabIndex:0,autoFocus:!0,onKeyDown:e=>{if(!i||s)return;let t=x(i);if(t){if(e.key===`right`&&t.hasChildren)e.preventDefault(),ce(i,!0);else if(e.key===`left`){if(t.hasChildren&&t.isExpanded)e.preventDefault(),ce(i,!1);else if(t.parentId!==void 0&&(e.preventDefault(),ne.current=!0,ce(t.parentId,!1),r)){let e=b.get(t.parentId);e&&r(e)}}}},children:(0,Ze.jsx)(f,{options:se,onChange:K.useCallback(e=>{let n=b.get(e);n&&t(n)},[b,t]),onFocus:K.useCallback(e=>{if(ne.current){ne.current=!1;return}if(g.current!==e&&(g.current=e,r)){let t=b.get(e);t&&r(t)}},[r,b]),onCancel:n,defaultFocusValue:i,visibleOptionCount:a,layout:o,isDisabled:s,hideIndexes:c,onUpFromFirstItem:p})})}var K,Ze,Qe=e((()=>{K=t(T(),1),ge(),n(),Ze=O()}));function $e(e,t){return ke(e.replace(/\s+/g,` `).trim(),t)}function et({before:e,match:t,after:n},r){return E.dim(e)+r(t)+E.dim(n)}function tt(e,t,n){let r=e.toLowerCase().indexOf(t.toLowerCase());if(r===-1)return null;let i=r+t.length,a=Math.max(0,r-n),o=Math.min(e.length,i+n),s=e.slice(a,r),c=e.slice(r,i),l=e.slice(i,o);return{before:(a>0?`…`:``)+s.replace(/\s+/g,` `).trimStart(),match:c.trim(),after:l.replace(/\s+/g,` `).trimEnd()+(o<e.length?`…`:``)}}function nt(e,t,n){let{isGroupHeader:r=!1,isChild:i=!1,forkCount:a=0}=n||{},o=r&&a>0?lt:i?ut:0,s=r&&a>0?` (+${a} other ${a===1?`session`:`sessions`})`:``,c=e.isSidechain?` (sidechain)`:``,l=t-o-c.length-s.length;return`${$e(Te(e),l)}${c}${s}`}function rt(e,t){let{isChild:n=!1,showProjectPath:r=!1}=t||{},i=n?` `:``,a=Ae(e),o=r&&e.projectPath?` · ${e.projectPath}`:``;return i+a+o}function it({logs:e,maxHeight:t=1/0,forceWidth:n,onCancel:r,onSelect:a,onLogsChanged:s,onLoadMore:l,initialSearchQuery:u,showAllProjects:d=!1,onToggleAllProjects:p,onAgenticSearch:m}){let h=he(),_=n===void 0?h.columns:n,re=Fe(r),ae=ue(),y=te(),[oe]=ce(),x=o(oe),T=q.useMemo(()=>e=>me(e,x.warning),[x.warning]),[E,de]=q.useState(null),[D,ge]=q.useState(!1),[O,_e]=q.useState(!1),[k,A]=q.useState(!1),be=q.useMemo(()=>ve(),[]),[xe,j]=q.useState(``),[Se,we]=q.useState(0),[Ee,De]=q.useState(new Set),[Oe,ke]=q.useState(null),[je,Me]=q.useState(1),[N,P]=q.useState(`list`),[Ne,Pe]=q.useState(null),Ie=q.useRef(null),[Le,ze]=q.useState(0),[F,Be]=q.useState({status:`idle`}),[I,L]=q.useState(!1),He=q.useRef(null),{query:R,setQuery:Ue,cursorOffset:z}=Re({isActive:N===`search`&&F.status!==`searching`,onExit:()=>{P(`list`),M(`tengu_session_search_toggled`,{enabled:!1})},onExitUp:()=>{P(`list`),M(`tengu_session_search_toggled`,{enabled:!1})},passthroughCtrlKeys:[`n`],initialQuery:u||``}),B=q.useDeferredValue(R),[V,H]=q.useState(``);q.useEffect(()=>{if(!B){H(``);return}let e=setTimeout(H,300,B);return()=>clearTimeout(e)},[B]);let[U,Ge]=q.useState(null),[Ke,qe]=q.useState(!1);q.useEffect(()=>{Ce().then(e=>de(e)),ee(be).then(e=>{A(e.length>1)})},[be]);let Je=q.useMemo(()=>new Map(e.map(e=>[e,ot(e)])),[e]),Ye=q.useMemo(()=>null,[e,Je,!1]),W=q.useMemo(()=>ct(e),[e]),G=W.length>0,K=q.useMemo(()=>G?[`All`,...W]:[],[G,W]),Ze=K.length>0&&Le<K.length?Le:0,Qe=K[Ze],it=Qe===`All`?void 0:Qe,at=+!!G,lt=q.useMemo(()=>{let t=e;return y&&(t=e.filter(e=>{let t=ye(),n=g(e);return!!(t&&n===t||e.customTitle||v(e.messages)||e.firstPrompt||e.customTitle)})),it!==void 0&&(t=t.filter(e=>e.tag===it)),D&&E&&(t=t.filter(e=>e.gitBranch===E)),k&&!O&&(t=t.filter(e=>e.projectPath===be)),t},[e,y,it,D,E,k,O,be]),ut=q.useMemo(()=>{if(!R)return lt;let e=R.toLowerCase();return lt.filter(t=>{let n=Te(t).toLowerCase(),r=(t.gitBranch||``).toLowerCase(),i=(t.tag||``).toLowerCase(),a=t.prNumber?`pr #${t.prNumber} ${t.prRepository||``}`.toLowerCase():``;return n.includes(e)||r.includes(e)||i.includes(e)||a.includes(e)})},[lt,R]);q.useEffect(()=>{},[B,V,!1]),q.useEffect(()=>{Ge(null),qe(!1)},[V,Ye,!1]);let{filteredLogs:Y,snippets:X}=q.useMemo(()=>{let e=new Map,t=ut;if(U&&V&&U.query===V){for(let t of U.results)if(t.searchableText){let n=tt(t.searchableText,V,dt);n&&e.set(t.log,n)}let n=new Set(t.map(e=>e.messages[0]?.uuid)),r=U.results.map(e=>e.log).filter(e=>!n.has(e.messages[0]?.uuid));t=[...t,...r]}return{filteredLogs:t,snippets:e}},[ut,U,V]),Z=q.useMemo(()=>F.status===`results`&&F.results.length>0?F.results:Y,[F,Y]),Q=Math.max(30,_-4),ft=q.useMemo(()=>{if(!y)return[];let e=st(Z);return Array.from(e.entries()).map(([e,t])=>{let n=t[0],r=Z.indexOf(n),i=X.get(n),a=i?et(i,T):null;if(t.length===1){let t=rt(n,{showProjectPath:d});return{id:`log:${e}:0`,value:{log:n,indexInFiltered:r},label:nt(n,Q),description:a?`${t}\n ${a}`:t,dimDescription:!0}}let o=t.length-1,s=t.slice(1).map((t,n)=>{let r=Z.indexOf(t),i=X.get(t),a=i?et(i,T):null,o=rt(t,{isChild:!0,showProjectPath:d});return{id:`log:${e}:${n+1}`,value:{log:t,indexInFiltered:r},label:nt(t,Q,{isChild:!0}),description:a?`${o}\n ${a}`:o,dimDescription:!0}}),c=rt(n,{showProjectPath:d});return{id:`group:${e}`,value:{log:n,indexInFiltered:r},label:nt(n,Q,{isGroupHeader:!0,forkCount:o}),description:a?`${c}\n ${a}`:c,dimDescription:!0,children:s}})},[y,Z,Q,d,X,T]),pt=q.useMemo(()=>y?[]:Z.map((e,t)=>{let n=$e(Te(e)+(e.isSidechain?` (sidechain)`:``),Q),r=Ae(e),i=d&&e.projectPath?` · ${e.projectPath}`:``,a=X.get(e),o=a?et(a,T):null;return{label:n,description:o?`${r}${i}\n ${o}`:r+i,dimDescription:!0,value:t.toString()}}),[y,Z,T,Q,d,X]),$=Oe?.value.log??null,mt=()=>{if(!y||!$)return``;let e=g($);if(!e)return``;let t=Z.filter(t=>g(t)===e);if(!(t.length>1))return``;let n=Ee.has(e);return t.indexOf($)>0||n?`← to collapse`:`→ to expand`},ht=q.useCallback(async()=>{let e=$?g($):void 0;if(!$||!e){P(`list`),j(``);return}xe.trim()&&(await ie(e,xe.trim(),$.fullPath),y&&s&&s()),P(`list`),j(``)},[$,xe,s,y]),gt=q.useCallback(()=>{P(`list`),M(`tengu_session_search_toggled`,{enabled:!1})},[]),_t=q.useCallback(()=>{P(`search`),M(`tengu_session_search_toggled`,{enabled:!0})},[]),vt=q.useCallback(async()=>{if(!R.trim()||!m||!0)return;He.current?.abort();let t=new AbortController;He.current=t,Be({status:`searching`}),M(`tengu_agentic_search_started`,{query_length:R.length});try{let n=await m(R,e,t.signal);if(t.signal.aborted)return;Be({status:`results`,results:n,query:R}),M(`tengu_agentic_search_completed`,{query_length:R.length,results_count:n.length})}catch(e){if(t.signal.aborted)return;Be({status:`error`,message:e instanceof Error?e.message:`Search failed`}),M(`tengu_agentic_search_error`,{query_length:R.length})}},[R,m,!1,e]);q.useEffect(()=>{F.status!==`idle`&&F.status!==`searching`&&(F.status===`results`&&F.query!==R||F.status===`error`)&&Be({status:`idle`})},[R,F]),q.useEffect(()=>()=>{He.current?.abort()},[]);let yt=q.useRef(F.status);q.useEffect(()=>{let e=yt.current;if(yt.current=F.status,e===`searching`&&F.status===`results`){if(y&&ft.length>0)ke(ft[0]);else if(!y&&Z.length>0){let e=Z[0];ke({id:`0`,value:{log:e,indexInFiltered:0},label:``})}}},[F.status,y,ft,Z]);let bt=q.useCallback(e=>{let t=parseInt(e,10),n=Z[t];!n||Ie.current===t.toString()||(Ie.current=t.toString(),ke({id:t.toString(),value:{log:n,indexInFiltered:t},label:``}),Me(t+1))},[Z]),xt=q.useCallback(e=>{ke(e);let t=Z.findIndex(t=>g(t)===g(e.value.log));t>=0&&Me(t+1)},[Z]);le(`confirm:no`,()=>{He.current?.abort(),Be({status:`idle`}),M(`tengu_agentic_search_cancelled`,{})},{context:`Confirmation`,isActive:N!==`preview`&&F.status===`searching`}),le(`confirm:no`,()=>{P(`list`),j(``)},{context:`Settings`,isActive:N===`rename`&&F.status!==`searching`}),le(`confirm:no`,()=>{Ue(``),L(!1),r?.()},{context:`Confirmation`,isActive:N!==`preview`&&N!==`rename`&&N!==`search`&&I&&F.status!==`searching`}),fe((e,t)=>{if(N!==`preview`&&F.status!==`searching`&&N!==`rename`)if(N===`search`)e.toLowerCase()===`n`&&t.ctrl?gt():(t.return||t.downArrow)&&R.trim();else{if(I){if(t.return){vt(),L(!1);return}else if(t.downArrow){L(!1);return}else if(t.upArrow){P(`search`),L(!1);return}}if(G&&t.tab){let e=t.shift?-1:1;ze(t=>{let n=((t<K.length?t:0)+K.length+e)%K.length,r=K[n];return M(`tengu_session_tag_filter_changed`,{is_all:r===`All`,tag_count:W.length}),n});return}let n=!t.ctrl&&!t.meta,r=e.toLowerCase();if(r===`a`&&t.ctrl&&p)p(),M(`tengu_session_all_projects_toggled`,{enabled:!d});else if(r===`b`&&t.ctrl){let e=!D;ge(e),M(`tengu_session_branch_filter_toggled`,{enabled:e})}else if(r===`w`&&t.ctrl&&k){let e=!O;_e(e),M(`tengu_session_worktree_filter_toggled`,{enabled:e})}else r===`/`&&n?(P(`search`),M(`tengu_session_search_toggled`,{enabled:!0})):r===`r`&&t.ctrl&&$?(P(`rename`),j(``),M(`tengu_session_rename_started`,{})):r===`v`&&t.ctrl&&$?(Pe($),P(`preview`),M(`tengu_session_preview_opened`,{messageCount:$.messageCount})):$&&n&&e.length>0&&!/^\s+$/.test(e)&&(P(`search`),Ue(e),M(`tengu_session_search_toggled`,{enabled:!0}))}},{isActive:!0});let St=[];D&&E&&St.push(E),k&&!O&&St.push(`current worktree`);let Ct=8+ +(St.length>0&&N!==`search`)+at,wt=Math.max(1,Math.floor((t-Ct-2)/3));return q.useEffect(()=>{if(!l)return;let e=wt*2;je+e>=Z.length&&l(wt*3)},[je,wt,Z.length,l]),e.length===0?null:N===`preview`&&Ne&&y?(0,J.jsx)(Ve,{log:Ne,onExit:()=>{P(`list`),Pe(null)},onSelect:a}):(0,J.jsxs)(S,{flexDirection:`column`,height:t-1,children:[(0,J.jsx)(S,{flexShrink:0,children:(0,J.jsx)(se,{color:`suggestion`})}),(0,J.jsx)(S,{flexShrink:0,children:(0,J.jsx)(C,{children:` `})}),G?(0,J.jsx)(We,{tabs:K,selectedIndex:Ze,availableWidth:_,showAllProjects:d}):(0,J.jsx)(S,{flexShrink:0,children:(0,J.jsxs)(C,{bold:!0,color:`suggestion`,children:[`Resume Session`,N===`list`&&Z.length>wt&&(0,J.jsxs)(C,{dimColor:!0,children:[` `,`(`,je,` of `,Z.length,`)`]})]})}),(0,J.jsx)(pe,{query:R,isFocused:N===`search`,isTerminalFocused:ae,cursorOffset:z}),St.length>0&&N!==`search`&&(0,J.jsx)(S,{flexShrink:0,paddingLeft:2,children:(0,J.jsx)(C,{dimColor:!0,children:(0,J.jsx)(w,{children:St})})}),(0,J.jsx)(S,{flexShrink:0,children:(0,J.jsx)(C,{children:` `})}),F.status===`searching`&&(0,J.jsxs)(S,{paddingLeft:1,flexShrink:0,children:[(0,J.jsx)(c,{}),(0,J.jsx)(C,{children:` Searching…`})]}),F.status===`results`&&F.results.length>0&&(0,J.jsx)(S,{paddingLeft:1,marginBottom:1,flexShrink:0,children:(0,J.jsx)(C,{dimColor:!0,italic:!0,children:`Claude found these results:`})}),F.status===`results`&&F.results.length===0&&Y.length===0&&(0,J.jsx)(S,{paddingLeft:1,marginBottom:1,flexShrink:0,children:(0,J.jsx)(C,{dimColor:!0,italic:!0,children:`No matching sessions found.`})}),F.status===`error`&&Y.length===0&&(0,J.jsx)(S,{paddingLeft:1,marginBottom:1,flexShrink:0,children:(0,J.jsx)(C,{dimColor:!0,italic:!0,children:`No matching sessions found.`})}),!!R.trim()&&m&&!1,F.status===`searching`?null:N===`rename`&&$?(0,J.jsxs)(S,{paddingLeft:2,flexDirection:`column`,children:[(0,J.jsx)(C,{bold:!0,children:`Rename session:`}),(0,J.jsx)(S,{paddingTop:1,children:(0,J.jsx)(ne,{value:xe,onChange:j,onSubmit:ht,placeholder:Te($,`Enter new session name`),columns:_,cursorOffset:Se,onChangeCursorOffset:we,showCursor:!0})})]}):y?(0,J.jsx)(Xe,{nodes:ft,onSelect:e=>{a(e.value.log)},onFocus:xt,onCancel:r,focusNodeId:Oe?.id,visibleOptionCount:wt,layout:`expanded`,isDisabled:N===`search`||I,hideIndexes:!1,isNodeExpanded:e=>{if(N===`search`||D)return!0;let t=typeof e==`string`&&e.startsWith(`group:`)?e.substring(6):null;return t?Ee.has(t):!1},onExpand:e=>{let t=typeof e==`string`&&e.startsWith(`group:`)?e.substring(6):null;t&&(De(e=>new Set(e).add(t)),M(`tengu_session_group_expanded`,{}))},onCollapse:e=>{let t=typeof e==`string`&&e.startsWith(`group:`)?e.substring(6):null;t&&De(e=>{let n=new Set(e);return n.delete(t),n})},onUpFromFirstItem:_t}):(0,J.jsx)(f,{options:pt,onChange:e=>{let t=Z[parseInt(e,10)];t&&a(t)},visibleOptionCount:wt,onCancel:r,onFocus:bt,defaultFocusValue:Oe?.id.toString(),layout:`expanded`,isDisabled:N===`search`||I,onUpFromFirstItem:_t}),(0,J.jsx)(S,{paddingLeft:2,children:re.pending?(0,J.jsxs)(C,{dimColor:!0,children:[`Press `,re.keyName,` again to exit`]}):N===`rename`?(0,J.jsx)(C,{dimColor:!0,children:(0,J.jsxs)(w,{children:[(0,J.jsx)(b,{shortcut:`Enter`,action:`save`}),(0,J.jsx)(i,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]})}):F.status===`searching`?(0,J.jsx)(C,{dimColor:!0,children:(0,J.jsxs)(w,{children:[(0,J.jsx)(C,{children:`Searching with Claude…`}),(0,J.jsx)(i,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]})}):I?(0,J.jsx)(C,{dimColor:!0,children:(0,J.jsxs)(w,{children:[(0,J.jsx)(b,{shortcut:`Enter`,action:`search`}),(0,J.jsx)(b,{shortcut:`↓`,action:`skip`}),(0,J.jsx)(i,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]})}):N===`search`?(0,J.jsx)(C,{dimColor:!0,children:(0,J.jsxs)(w,{children:[(0,J.jsx)(C,{children:`Type to Search`}),(0,J.jsx)(b,{shortcut:`Enter`,action:`select`}),(0,J.jsx)(i,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`clear`})]})}):(0,J.jsx)(C,{dimColor:!0,children:(0,J.jsxs)(w,{children:[p&&(0,J.jsx)(b,{shortcut:`Ctrl+A`,action:`show ${d?`current dir`:`all projects`}`}),E&&(0,J.jsx)(b,{shortcut:`Ctrl+B`,action:`toggle branch`}),k&&(0,J.jsx)(b,{shortcut:`Ctrl+W`,action:`show ${O?`current worktree`:`all worktrees`}`}),(0,J.jsx)(b,{shortcut:`Ctrl+V`,action:`preview`}),(0,J.jsx)(b,{shortcut:`Ctrl+R`,action:`rename`}),(0,J.jsx)(C,{children:`Type to search`}),(0,J.jsx)(i,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`}),mt()&&(0,J.jsx)(C,{children:mt()})]})})})]})}function at(e){if(e.type!==`user`&&e.type!==`assistant`)return``;let t=`message`in e?e.message?.content:void 0;return t?typeof t==`string`?t:Array.isArray(t)?t.map(e=>typeof e==`string`?e:`text`in e&&typeof e.text==`string`?e.text:``).filter(Boolean).join(` `):``:``}function ot(e){let t=(e.messages.length<=Y?e.messages:[...e.messages.slice(0,X),...e.messages.slice(-1e3)]).map(at).filter(Boolean).join(` `),n=`${[e.customTitle,e.summary,e.firstPrompt,e.gitBranch,e.tag,e.prNumber?`PR #${e.prNumber}`:void 0,e.prRepository].filter(Boolean).join(` `)} ${t}`.trim();return n.length>Z?n.slice(0,Z):n}function st(e){let t=new Map;for(let n of e){let e=g(n);if(e){let r=t.get(e);r?r.push(n):t.set(e,[n])}}return t.forEach(e=>e.sort((e,t)=>new Date(t.modified).getTime()-new Date(e.modified).getTime())),t}function ct(e){let t=new Set;for(let n of e)n.tag&&t.add(n.tag);return Array.from(t).sort((e,t)=>e.localeCompare(t))}var q,J,lt,ut,Y,X,Z,dt,Q=e((()=>{de(),q=t(T(),1),_e(),Ie(),ze(),oe(),ge(),_(),Oe(),Me(),r(),we(),Ee(),h(),p(),u(),n(),Le(),He(),d(),G(),re(),Qe(),J=O(),lt=2,ut=4,Y=2e3,X=1e3,Z=5e4,dt=50}));function ft(e){if(e.type!==`user`&&e.type!==`assistant`)return``;let t=`message`in e?e.message?.content:void 0;return t?typeof t==`string`?t:Array.isArray(t)?t.map(e=>typeof e==`string`?e:`text`in e&&typeof e.text==`string`?e.text:``).filter(Boolean).join(` `):``:``}function pt(e){if(e.length===0)return``;let t=(e.length<=gt?e:[...e.slice(0,gt/2),...e.slice(-100/2)]).map(ft).filter(Boolean).join(` `).replace(/\s+/g,` `).trim();return t.length>ht?`${t.slice(0,ht)}…`:t}function $(e,t){return!!(Te(e).toLowerCase().includes(t)||e.customTitle?.toLowerCase().includes(t)||e.tag?.toLowerCase().includes(t)||e.gitBranch?.toLowerCase().includes(t)||e.summary?.toLowerCase().includes(t)||e.firstPrompt?.toLowerCase().includes(t)||e.messages&&e.messages.length>0&&pt(e.messages).toLowerCase().includes(t))}async function mt(e,t,n){if(!e.trim()||t.length===0)return[];let r=e.toLowerCase(),i=t.filter(e=>$(e,r)),a;if(i.length>=_t)a=i.slice(0,_t);else{let e=t.filter(e=>!$(e,r)),n=_t-i.length;a=[...i,...e.slice(0,n)]}A(`Agentic search: ${a.length}/${t.length} logs, query="${e}", matching: ${i.length}, with messages: ${j(a,e=>e.messages?.length>0)}`);let o=a.map(async e=>{if(y(e))try{return await l(e)}catch(t){return De(t),e}return e}),s=await Promise.all(o);A(`Agentic search: loaded ${j(s,e=>e.messages?.length>0)}/${a.length} logs with transcripts`);let c=`Sessions:
1
+ import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{$u as n,Ci as r,Dp as i,Gc as a,Hu as o,Jw as s,Mu as c,Nr as l,Op as u,Pu as d,Qu as f,Si as ee,Sr as te,Uu as p,Yw as m,br as h,cd as ne,fr as g,hC as _,ir as v,ld as re,oi as ie,qc as ae,wr as y,xC as oe}from"./loadAgentsDir-PPiD2Mfq.js";import{C as se,D as b,Gr as x,H as ce,I as S,P as C,T as w,Wt as le,Xn as ue,ai as T,di as E,fi as de,hn as fe,k as pe,oi as me,ot as he,p as D,t as ge}from"./src-DL3w8VPk2.js";import{t as O}from"./jsx-runtime-Bb4Xn-E0.js";import{Wt as _e,et as ve,pt as ye}from"./state-BPFYBqm1.js";import{S as k,c as A,i as be,x as xe}from"./debug-BQj6h99Q.js";import{Ln as j,Rn as Se}from"./settings-CvhsRFaT.js";import{i as Ce,m as we}from"./git-DplvjXEY.js";import{a as Te,o as Ee,s as De}from"./log-BlJ7CcKG.js";import{n as Oe,r as M}from"./analytics-DJobLaWP.js";import{C as ke,d as Ae,m as je,v as Me}from"./startupProfiler-2sjXZkIP.js";import{_ as N,h as P}from"./model-sviY1inu.js";import{i as Ne,r as Pe}from"./shellQuote-D3Ocv_U-.js";import{n as Fe,t as Ie}from"./useExitOnCtrlCDWithKeybindings-C9orgrub.js";import{t as Le}from"./SearchBox-CwwV0W-w.js";import{n as Re,t as ze}from"./useSearchInput-DdKrVHJS.js";import{n as F,t as Be}from"./Messages-yz1m39eI.js";function Ve({log:e,onExit:t,onSelect:n}){let[r,o]=I.useState(null);I.useEffect(()=>{o(null),y(e)&&l(e).then(o)},[e]);let s=y(e)&&r===null,c=r??e,u=g(c)||``,d=a();return le(`confirm:no`,t,{context:`Confirmation`}),le(`confirm:yes`,(0,I.useCallback)(()=>{n(r??e)},[n,r,e]),{context:`Confirmation`}),s?(0,L.jsxs)(S,{flexDirection:`column`,padding:1,children:[(0,L.jsx)(D,{message:`Loading session…`}),(0,L.jsx)(C,{dimColor:!0,children:(0,L.jsx)(w,{children:(0,L.jsx)(i,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})})})]}):(0,L.jsxs)(S,{flexDirection:`column`,children:[(0,L.jsx)(Be,{messages:c.messages,tools:d,commands:[],verbose:!0,toolJSX:null,toolUseConfirmQueue:[],inProgressToolUseIDs:new Set,isMessageSelectorVisible:!1,conversationId:u,screen:`transcript`,streamingToolUses:[],showAllInTranscript:!0,isLoading:!1}),(0,L.jsxs)(S,{flexShrink:0,flexDirection:`column`,borderTopDimColor:!0,borderBottom:!1,borderLeft:!1,borderRight:!1,borderStyle:`single`,paddingLeft:2,children:[(0,L.jsxs)(C,{children:[je(c.modified),` · `,c.messageCount,` messages`,c.gitBranch?` · ${c.gitBranch}`:``]}),(0,L.jsx)(C,{dimColor:!0,children:(0,L.jsxs)(w,{children:[(0,L.jsx)(b,{shortcut:`Enter`,action:`resume`}),(0,L.jsx)(i,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]})})]})]})}var I,L,He=e((()=>{I=t(T(),1),ge(),_(),ae(),Me(),h(),u(),F(),L=O()}));function R(e,t){if(e===B)return 5;let n=x(e),r=t?Math.min(n,t-V-H):n;return Math.max(0,r)+V+H}function Ue(e,t){let n=t-V-H;return x(e)<=n?e:n<=1?e.charAt(0):ke(e,n)}function We({tabs:e,selectedIndex:t,availableWidth:n,showAllProjects:r=!1}){let i=r?`Resume (All Projects)`:`Resume`,a=i.length+1,o=Math.max(Ye,W),s=n-a-o-2,c=Math.max(0,Math.min(t,e.length-1)),l=Math.max(20,Math.floor(s/2)),u=e.map(e=>R(e,l)),d=0,f=e.length;if(u.reduce((e,t,n)=>e+t+ +(n<u.length-1),0)>s){let t=s-Je,n=u[c]??0;for(d=c,f=c+1;d>0||f<e.length;){let r=d>0,i=f<e.length;if(r){let e=(u[d-1]??0)+1;if(n+e<=t){d--,n+=e;continue}}if(i){let e=(u[f]??0)+1;if(n+e<=t){f++,n+=e;continue}}break}}let ee=d,te=e.length-f,p=e.slice(d,f),m=p.map((e,t)=>d+t);return(0,z.jsxs)(S,{flexDirection:`row`,gap:1,children:[(0,z.jsx)(C,{color:`suggestion`,children:i}),ee>0&&(0,z.jsxs)(C,{dimColor:!0,children:[U,ee]}),p.map((e,t)=>{let n=m[t]===c,r=e===B?e:`#${Ue(e,l-V)}`;return(0,z.jsxs)(C,{backgroundColor:n?`suggestion`:void 0,color:n?`inverseText`:void 0,bold:n,children:[` `,r,` `]},e)}),te>0?(0,z.jsxs)(C,{dimColor:!0,children:[Ge,te,Ke]}):(0,z.jsx)(C,{dimColor:!0,children:qe})]})}var z,B,V,H,U,Ge,Ke,qe,Je,Ye,W,G=e((()=>{ge(),Me(),z=O(),B=`All`,V=2,H=1,U=`← `,Ge=`→`,Ke=` (tab to cycle)`,qe=`(tab to cycle)`,Je=5,Ye=18,W=14}));function Xe({nodes:e,onSelect:t,onCancel:n,onFocus:r,focusNodeId:i,visibleOptionCount:a,layout:o=`expanded`,isDisabled:s=!1,hideIndexes:c=!1,isNodeExpanded:l,onExpand:u,onCollapse:d,getParentPrefix:ee,getChildPrefix:te,onUpFromFirstItem:p}){let[m,h]=K.useState(new Set),ne=K.useRef(!1),g=K.useRef(null),_=K.useCallback(e=>l?l(e):m.has(e),[l,m]),v=K.useMemo(()=>{let t=[];function n(e,r,i){let a=!!e.children&&e.children.length>0,o=_(e.id);if(t.push({node:e,depth:r,isExpanded:o,hasChildren:a,parentId:i}),a&&o&&e.children)for(let t of e.children)n(t,r+1,e.id)}for(let t of e)n(t,0);return t},[e,_]),re=K.useCallback(e=>e?`▼ `:`▶ `,[]),ie=K.useCallback(e=>` ▸ `,[]),ae=ee??re,y=te??ie,oe=K.useCallback(e=>{let t=``;return e.hasChildren?t=ae(e.isExpanded):e.depth>0&&(t=y(e.depth)),t+e.node.label},[ae,y]),se=K.useMemo(()=>v.map(e=>({label:oe(e),description:e.node.description,dimDescription:e.node.dimDescription??!0,value:e.node.id})),[v,oe]),b=K.useMemo(()=>{let e=new Map;return v.forEach(t=>e.set(t.node.id,t.node)),e},[v]),x=K.useCallback(e=>v.find(t=>t.node.id===e),[v]),ce=K.useCallback((e,t)=>{x(e)?.hasChildren&&(t?u?u(e):h(t=>new Set(t).add(e)):d?d(e):h(t=>{let n=new Set(t);return n.delete(e),n}))},[x,u,d]);return(0,Ze.jsx)(S,{tabIndex:0,autoFocus:!0,onKeyDown:e=>{if(!i||s)return;let t=x(i);if(t){if(e.key===`right`&&t.hasChildren)e.preventDefault(),ce(i,!0);else if(e.key===`left`){if(t.hasChildren&&t.isExpanded)e.preventDefault(),ce(i,!1);else if(t.parentId!==void 0&&(e.preventDefault(),ne.current=!0,ce(t.parentId,!1),r)){let e=b.get(t.parentId);e&&r(e)}}}},children:(0,Ze.jsx)(f,{options:se,onChange:K.useCallback(e=>{let n=b.get(e);n&&t(n)},[b,t]),onFocus:K.useCallback(e=>{if(ne.current){ne.current=!1;return}if(g.current!==e&&(g.current=e,r)){let t=b.get(e);t&&r(t)}},[r,b]),onCancel:n,defaultFocusValue:i,visibleOptionCount:a,layout:o,isDisabled:s,hideIndexes:c,onUpFromFirstItem:p})})}var K,Ze,Qe=e((()=>{K=t(T(),1),ge(),n(),Ze=O()}));function $e(e,t){return ke(e.replace(/\s+/g,` `).trim(),t)}function et({before:e,match:t,after:n},r){return E.dim(e)+r(t)+E.dim(n)}function tt(e,t,n){let r=e.toLowerCase().indexOf(t.toLowerCase());if(r===-1)return null;let i=r+t.length,a=Math.max(0,r-n),o=Math.min(e.length,i+n),s=e.slice(a,r),c=e.slice(r,i),l=e.slice(i,o);return{before:(a>0?`…`:``)+s.replace(/\s+/g,` `).trimStart(),match:c.trim(),after:l.replace(/\s+/g,` `).trimEnd()+(o<e.length?`…`:``)}}function nt(e,t,n){let{isGroupHeader:r=!1,isChild:i=!1,forkCount:a=0}=n||{},o=r&&a>0?lt:i?ut:0,s=r&&a>0?` (+${a} other ${a===1?`session`:`sessions`})`:``,c=e.isSidechain?` (sidechain)`:``,l=t-o-c.length-s.length;return`${$e(Te(e),l)}${c}${s}`}function rt(e,t){let{isChild:n=!1,showProjectPath:r=!1}=t||{},i=n?` `:``,a=Ae(e),o=r&&e.projectPath?` · ${e.projectPath}`:``;return i+a+o}function it({logs:e,maxHeight:t=1/0,forceWidth:n,onCancel:r,onSelect:a,onLogsChanged:s,onLoadMore:l,initialSearchQuery:u,showAllProjects:d=!1,onToggleAllProjects:p,onAgenticSearch:m}){let h=he(),_=n===void 0?h.columns:n,re=Fe(r),ae=ue(),y=te(),[oe]=ce(),x=o(oe),T=q.useMemo(()=>e=>me(e,x.warning),[x.warning]),[E,de]=q.useState(null),[D,ge]=q.useState(!1),[O,_e]=q.useState(!1),[k,A]=q.useState(!1),be=q.useMemo(()=>ve(),[]),[xe,j]=q.useState(``),[Se,we]=q.useState(0),[Ee,De]=q.useState(new Set),[Oe,ke]=q.useState(null),[je,Me]=q.useState(1),[N,P]=q.useState(`list`),[Ne,Pe]=q.useState(null),Ie=q.useRef(null),[Le,ze]=q.useState(0),[F,Be]=q.useState({status:`idle`}),[I,L]=q.useState(!1),He=q.useRef(null),{query:R,setQuery:Ue,cursorOffset:z}=Re({isActive:N===`search`&&F.status!==`searching`,onExit:()=>{P(`list`),M(`tengu_session_search_toggled`,{enabled:!1})},onExitUp:()=>{P(`list`),M(`tengu_session_search_toggled`,{enabled:!1})},passthroughCtrlKeys:[`n`],initialQuery:u||``}),B=q.useDeferredValue(R),[V,H]=q.useState(``);q.useEffect(()=>{if(!B){H(``);return}let e=setTimeout(H,300,B);return()=>clearTimeout(e)},[B]);let[U,Ge]=q.useState(null),[Ke,qe]=q.useState(!1);q.useEffect(()=>{Ce().then(e=>de(e)),ee(be).then(e=>{A(e.length>1)})},[be]);let Je=q.useMemo(()=>new Map(e.map(e=>[e,ot(e)])),[e]),Ye=q.useMemo(()=>null,[e,Je,!1]),W=q.useMemo(()=>ct(e),[e]),G=W.length>0,K=q.useMemo(()=>G?[`All`,...W]:[],[G,W]),Ze=K.length>0&&Le<K.length?Le:0,Qe=K[Ze],it=Qe===`All`?void 0:Qe,at=+!!G,lt=q.useMemo(()=>{let t=e;return y&&(t=e.filter(e=>{let t=ye(),n=g(e);return!!(t&&n===t||e.customTitle||v(e.messages)||e.firstPrompt||e.customTitle)})),it!==void 0&&(t=t.filter(e=>e.tag===it)),D&&E&&(t=t.filter(e=>e.gitBranch===E)),k&&!O&&(t=t.filter(e=>e.projectPath===be)),t},[e,y,it,D,E,k,O,be]),ut=q.useMemo(()=>{if(!R)return lt;let e=R.toLowerCase();return lt.filter(t=>{let n=Te(t).toLowerCase(),r=(t.gitBranch||``).toLowerCase(),i=(t.tag||``).toLowerCase(),a=t.prNumber?`pr #${t.prNumber} ${t.prRepository||``}`.toLowerCase():``;return n.includes(e)||r.includes(e)||i.includes(e)||a.includes(e)})},[lt,R]);q.useEffect(()=>{},[B,V,!1]),q.useEffect(()=>{Ge(null),qe(!1)},[V,Ye,!1]);let{filteredLogs:Y,snippets:X}=q.useMemo(()=>{let e=new Map,t=ut;if(U&&V&&U.query===V){for(let t of U.results)if(t.searchableText){let n=tt(t.searchableText,V,dt);n&&e.set(t.log,n)}let n=new Set(t.map(e=>e.messages[0]?.uuid)),r=U.results.map(e=>e.log).filter(e=>!n.has(e.messages[0]?.uuid));t=[...t,...r]}return{filteredLogs:t,snippets:e}},[ut,U,V]),Z=q.useMemo(()=>F.status===`results`&&F.results.length>0?F.results:Y,[F,Y]),Q=Math.max(30,_-4),ft=q.useMemo(()=>{if(!y)return[];let e=st(Z);return Array.from(e.entries()).map(([e,t])=>{let n=t[0],r=Z.indexOf(n),i=X.get(n),a=i?et(i,T):null;if(t.length===1){let t=rt(n,{showProjectPath:d});return{id:`log:${e}:0`,value:{log:n,indexInFiltered:r},label:nt(n,Q),description:a?`${t}\n ${a}`:t,dimDescription:!0}}let o=t.length-1,s=t.slice(1).map((t,n)=>{let r=Z.indexOf(t),i=X.get(t),a=i?et(i,T):null,o=rt(t,{isChild:!0,showProjectPath:d});return{id:`log:${e}:${n+1}`,value:{log:t,indexInFiltered:r},label:nt(t,Q,{isChild:!0}),description:a?`${o}\n ${a}`:o,dimDescription:!0}}),c=rt(n,{showProjectPath:d});return{id:`group:${e}`,value:{log:n,indexInFiltered:r},label:nt(n,Q,{isGroupHeader:!0,forkCount:o}),description:a?`${c}\n ${a}`:c,dimDescription:!0,children:s}})},[y,Z,Q,d,X,T]),pt=q.useMemo(()=>y?[]:Z.map((e,t)=>{let n=$e(Te(e)+(e.isSidechain?` (sidechain)`:``),Q),r=Ae(e),i=d&&e.projectPath?` · ${e.projectPath}`:``,a=X.get(e),o=a?et(a,T):null;return{label:n,description:o?`${r}${i}\n ${o}`:r+i,dimDescription:!0,value:t.toString()}}),[y,Z,T,Q,d,X]),$=Oe?.value.log??null,mt=()=>{if(!y||!$)return``;let e=g($);if(!e)return``;let t=Z.filter(t=>g(t)===e);if(!(t.length>1))return``;let n=Ee.has(e);return t.indexOf($)>0||n?`← to collapse`:`→ to expand`},ht=q.useCallback(async()=>{let e=$?g($):void 0;if(!$||!e){P(`list`),j(``);return}xe.trim()&&(await ie(e,xe.trim(),$.fullPath),y&&s&&s()),P(`list`),j(``)},[$,xe,s,y]),gt=q.useCallback(()=>{P(`list`),M(`tengu_session_search_toggled`,{enabled:!1})},[]),_t=q.useCallback(()=>{P(`search`),M(`tengu_session_search_toggled`,{enabled:!0})},[]),vt=q.useCallback(async()=>{if(!R.trim()||!m||!0)return;He.current?.abort();let t=new AbortController;He.current=t,Be({status:`searching`}),M(`tengu_agentic_search_started`,{query_length:R.length});try{let n=await m(R,e,t.signal);if(t.signal.aborted)return;Be({status:`results`,results:n,query:R}),M(`tengu_agentic_search_completed`,{query_length:R.length,results_count:n.length})}catch(e){if(t.signal.aborted)return;Be({status:`error`,message:e instanceof Error?e.message:`Search failed`}),M(`tengu_agentic_search_error`,{query_length:R.length})}},[R,m,!1,e]);q.useEffect(()=>{F.status!==`idle`&&F.status!==`searching`&&(F.status===`results`&&F.query!==R||F.status===`error`)&&Be({status:`idle`})},[R,F]),q.useEffect(()=>()=>{He.current?.abort()},[]);let yt=q.useRef(F.status);q.useEffect(()=>{let e=yt.current;if(yt.current=F.status,e===`searching`&&F.status===`results`){if(y&&ft.length>0)ke(ft[0]);else if(!y&&Z.length>0){let e=Z[0];ke({id:`0`,value:{log:e,indexInFiltered:0},label:``})}}},[F.status,y,ft,Z]);let bt=q.useCallback(e=>{let t=parseInt(e,10),n=Z[t];!n||Ie.current===t.toString()||(Ie.current=t.toString(),ke({id:t.toString(),value:{log:n,indexInFiltered:t},label:``}),Me(t+1))},[Z]),xt=q.useCallback(e=>{ke(e);let t=Z.findIndex(t=>g(t)===g(e.value.log));t>=0&&Me(t+1)},[Z]);le(`confirm:no`,()=>{He.current?.abort(),Be({status:`idle`}),M(`tengu_agentic_search_cancelled`,{})},{context:`Confirmation`,isActive:N!==`preview`&&F.status===`searching`}),le(`confirm:no`,()=>{P(`list`),j(``)},{context:`Settings`,isActive:N===`rename`&&F.status!==`searching`}),le(`confirm:no`,()=>{Ue(``),L(!1),r?.()},{context:`Confirmation`,isActive:N!==`preview`&&N!==`rename`&&N!==`search`&&I&&F.status!==`searching`}),fe((e,t)=>{if(N!==`preview`&&F.status!==`searching`&&N!==`rename`)if(N===`search`)e.toLowerCase()===`n`&&t.ctrl?gt():(t.return||t.downArrow)&&R.trim();else{if(I){if(t.return){vt(),L(!1);return}else if(t.downArrow){L(!1);return}else if(t.upArrow){P(`search`),L(!1);return}}if(G&&t.tab){let e=t.shift?-1:1;ze(t=>{let n=((t<K.length?t:0)+K.length+e)%K.length,r=K[n];return M(`tengu_session_tag_filter_changed`,{is_all:r===`All`,tag_count:W.length}),n});return}let n=!t.ctrl&&!t.meta,r=e.toLowerCase();if(r===`a`&&t.ctrl&&p)p(),M(`tengu_session_all_projects_toggled`,{enabled:!d});else if(r===`b`&&t.ctrl){let e=!D;ge(e),M(`tengu_session_branch_filter_toggled`,{enabled:e})}else if(r===`w`&&t.ctrl&&k){let e=!O;_e(e),M(`tengu_session_worktree_filter_toggled`,{enabled:e})}else r===`/`&&n?(P(`search`),M(`tengu_session_search_toggled`,{enabled:!0})):r===`r`&&t.ctrl&&$?(P(`rename`),j(``),M(`tengu_session_rename_started`,{})):r===`v`&&t.ctrl&&$?(Pe($),P(`preview`),M(`tengu_session_preview_opened`,{messageCount:$.messageCount})):$&&n&&e.length>0&&!/^\s+$/.test(e)&&(P(`search`),Ue(e),M(`tengu_session_search_toggled`,{enabled:!0}))}},{isActive:!0});let St=[];D&&E&&St.push(E),k&&!O&&St.push(`current worktree`);let Ct=8+ +(St.length>0&&N!==`search`)+at,wt=Math.max(1,Math.floor((t-Ct-2)/3));return q.useEffect(()=>{if(!l)return;let e=wt*2;je+e>=Z.length&&l(wt*3)},[je,wt,Z.length,l]),e.length===0?null:N===`preview`&&Ne&&y?(0,J.jsx)(Ve,{log:Ne,onExit:()=>{P(`list`),Pe(null)},onSelect:a}):(0,J.jsxs)(S,{flexDirection:`column`,height:t-1,children:[(0,J.jsx)(S,{flexShrink:0,children:(0,J.jsx)(se,{color:`suggestion`})}),(0,J.jsx)(S,{flexShrink:0,children:(0,J.jsx)(C,{children:` `})}),G?(0,J.jsx)(We,{tabs:K,selectedIndex:Ze,availableWidth:_,showAllProjects:d}):(0,J.jsx)(S,{flexShrink:0,children:(0,J.jsxs)(C,{bold:!0,color:`suggestion`,children:[`Resume Session`,N===`list`&&Z.length>wt&&(0,J.jsxs)(C,{dimColor:!0,children:[` `,`(`,je,` of `,Z.length,`)`]})]})}),(0,J.jsx)(pe,{query:R,isFocused:N===`search`,isTerminalFocused:ae,cursorOffset:z}),St.length>0&&N!==`search`&&(0,J.jsx)(S,{flexShrink:0,paddingLeft:2,children:(0,J.jsx)(C,{dimColor:!0,children:(0,J.jsx)(w,{children:St})})}),(0,J.jsx)(S,{flexShrink:0,children:(0,J.jsx)(C,{children:` `})}),F.status===`searching`&&(0,J.jsxs)(S,{paddingLeft:1,flexShrink:0,children:[(0,J.jsx)(c,{}),(0,J.jsx)(C,{children:` Searching…`})]}),F.status===`results`&&F.results.length>0&&(0,J.jsx)(S,{paddingLeft:1,marginBottom:1,flexShrink:0,children:(0,J.jsx)(C,{dimColor:!0,italic:!0,children:`Work Mate found these results:`})}),F.status===`results`&&F.results.length===0&&Y.length===0&&(0,J.jsx)(S,{paddingLeft:1,marginBottom:1,flexShrink:0,children:(0,J.jsx)(C,{dimColor:!0,italic:!0,children:`No matching sessions found.`})}),F.status===`error`&&Y.length===0&&(0,J.jsx)(S,{paddingLeft:1,marginBottom:1,flexShrink:0,children:(0,J.jsx)(C,{dimColor:!0,italic:!0,children:`No matching sessions found.`})}),!!R.trim()&&m&&!1,F.status===`searching`?null:N===`rename`&&$?(0,J.jsxs)(S,{paddingLeft:2,flexDirection:`column`,children:[(0,J.jsx)(C,{bold:!0,children:`Rename session:`}),(0,J.jsx)(S,{paddingTop:1,children:(0,J.jsx)(ne,{value:xe,onChange:j,onSubmit:ht,placeholder:Te($,`Enter new session name`),columns:_,cursorOffset:Se,onChangeCursorOffset:we,showCursor:!0})})]}):y?(0,J.jsx)(Xe,{nodes:ft,onSelect:e=>{a(e.value.log)},onFocus:xt,onCancel:r,focusNodeId:Oe?.id,visibleOptionCount:wt,layout:`expanded`,isDisabled:N===`search`||I,hideIndexes:!1,isNodeExpanded:e=>{if(N===`search`||D)return!0;let t=typeof e==`string`&&e.startsWith(`group:`)?e.substring(6):null;return t?Ee.has(t):!1},onExpand:e=>{let t=typeof e==`string`&&e.startsWith(`group:`)?e.substring(6):null;t&&(De(e=>new Set(e).add(t)),M(`tengu_session_group_expanded`,{}))},onCollapse:e=>{let t=typeof e==`string`&&e.startsWith(`group:`)?e.substring(6):null;t&&De(e=>{let n=new Set(e);return n.delete(t),n})},onUpFromFirstItem:_t}):(0,J.jsx)(f,{options:pt,onChange:e=>{let t=Z[parseInt(e,10)];t&&a(t)},visibleOptionCount:wt,onCancel:r,onFocus:bt,defaultFocusValue:Oe?.id.toString(),layout:`expanded`,isDisabled:N===`search`||I,onUpFromFirstItem:_t}),(0,J.jsx)(S,{paddingLeft:2,children:re.pending?(0,J.jsxs)(C,{dimColor:!0,children:[`Press `,re.keyName,` again to exit`]}):N===`rename`?(0,J.jsx)(C,{dimColor:!0,children:(0,J.jsxs)(w,{children:[(0,J.jsx)(b,{shortcut:`Enter`,action:`save`}),(0,J.jsx)(i,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]})}):F.status===`searching`?(0,J.jsx)(C,{dimColor:!0,children:(0,J.jsxs)(w,{children:[(0,J.jsx)(C,{children:`Searching with Work Mate…`}),(0,J.jsx)(i,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]})}):I?(0,J.jsx)(C,{dimColor:!0,children:(0,J.jsxs)(w,{children:[(0,J.jsx)(b,{shortcut:`Enter`,action:`search`}),(0,J.jsx)(b,{shortcut:`↓`,action:`skip`}),(0,J.jsx)(i,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]})}):N===`search`?(0,J.jsx)(C,{dimColor:!0,children:(0,J.jsxs)(w,{children:[(0,J.jsx)(C,{children:`Type to Search`}),(0,J.jsx)(b,{shortcut:`Enter`,action:`select`}),(0,J.jsx)(i,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`clear`})]})}):(0,J.jsx)(C,{dimColor:!0,children:(0,J.jsxs)(w,{children:[p&&(0,J.jsx)(b,{shortcut:`Ctrl+A`,action:`show ${d?`current dir`:`all projects`}`}),E&&(0,J.jsx)(b,{shortcut:`Ctrl+B`,action:`toggle branch`}),k&&(0,J.jsx)(b,{shortcut:`Ctrl+W`,action:`show ${O?`current worktree`:`all worktrees`}`}),(0,J.jsx)(b,{shortcut:`Ctrl+V`,action:`preview`}),(0,J.jsx)(b,{shortcut:`Ctrl+R`,action:`rename`}),(0,J.jsx)(C,{children:`Type to search`}),(0,J.jsx)(i,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`}),mt()&&(0,J.jsx)(C,{children:mt()})]})})})]})}function at(e){if(e.type!==`user`&&e.type!==`assistant`)return``;let t=`message`in e?e.message?.content:void 0;return t?typeof t==`string`?t:Array.isArray(t)?t.map(e=>typeof e==`string`?e:`text`in e&&typeof e.text==`string`?e.text:``).filter(Boolean).join(` `):``:``}function ot(e){let t=(e.messages.length<=Y?e.messages:[...e.messages.slice(0,X),...e.messages.slice(-1e3)]).map(at).filter(Boolean).join(` `),n=`${[e.customTitle,e.summary,e.firstPrompt,e.gitBranch,e.tag,e.prNumber?`PR #${e.prNumber}`:void 0,e.prRepository].filter(Boolean).join(` `)} ${t}`.trim();return n.length>Z?n.slice(0,Z):n}function st(e){let t=new Map;for(let n of e){let e=g(n);if(e){let r=t.get(e);r?r.push(n):t.set(e,[n])}}return t.forEach(e=>e.sort((e,t)=>new Date(t.modified).getTime()-new Date(e.modified).getTime())),t}function ct(e){let t=new Set;for(let n of e)n.tag&&t.add(n.tag);return Array.from(t).sort((e,t)=>e.localeCompare(t))}var q,J,lt,ut,Y,X,Z,dt,Q=e((()=>{de(),q=t(T(),1),_e(),Ie(),ze(),oe(),ge(),_(),Oe(),Me(),r(),we(),Ee(),h(),p(),u(),n(),Le(),He(),d(),G(),re(),Qe(),J=O(),lt=2,ut=4,Y=2e3,X=1e3,Z=5e4,dt=50}));function ft(e){if(e.type!==`user`&&e.type!==`assistant`)return``;let t=`message`in e?e.message?.content:void 0;return t?typeof t==`string`?t:Array.isArray(t)?t.map(e=>typeof e==`string`?e:`text`in e&&typeof e.text==`string`?e.text:``).filter(Boolean).join(` `):``:``}function pt(e){if(e.length===0)return``;let t=(e.length<=gt?e:[...e.slice(0,gt/2),...e.slice(-100/2)]).map(ft).filter(Boolean).join(` `).replace(/\s+/g,` `).trim();return t.length>ht?`${t.slice(0,ht)}…`:t}function $(e,t){return!!(Te(e).toLowerCase().includes(t)||e.customTitle?.toLowerCase().includes(t)||e.tag?.toLowerCase().includes(t)||e.gitBranch?.toLowerCase().includes(t)||e.summary?.toLowerCase().includes(t)||e.firstPrompt?.toLowerCase().includes(t)||e.messages&&e.messages.length>0&&pt(e.messages).toLowerCase().includes(t))}async function mt(e,t,n){if(!e.trim()||t.length===0)return[];let r=e.toLowerCase(),i=t.filter(e=>$(e,r)),a;if(i.length>=_t)a=i.slice(0,_t);else{let e=t.filter(e=>!$(e,r)),n=_t-i.length;a=[...i,...e.slice(0,n)]}A(`Agentic search: ${a.length}/${t.length} logs, query="${e}", matching: ${i.length}, with messages: ${j(a,e=>e.messages?.length>0)}`);let o=a.map(async e=>{if(y(e))try{return await l(e)}catch(t){return De(t),e}return e}),s=await Promise.all(o);A(`Agentic search: loaded ${j(s,e=>e.messages?.length>0)}/${a.length} logs with transcripts`);let c=`Sessions:
2
2
  ${s.map((e,t)=>{let n=[`${t}:`],r=Te(e);if(n.push(r),e.customTitle&&e.customTitle!==r&&n.push(`[custom title: ${e.customTitle}]`),e.tag&&n.push(`[tag: ${e.tag}]`),e.gitBranch&&n.push(`[branch: ${e.gitBranch}]`),e.summary&&n.push(`- Summary: ${e.summary}`),e.firstPrompt&&e.firstPrompt!==`No prompt`&&n.push(`- First message: ${e.firstPrompt.slice(0,300)}`),e.messages&&e.messages.length>0){let t=pt(e.messages);t&&n.push(`- Transcript: ${t}`)}return n.join(` `)}).join(`
3
3
  `)}
4
4
 
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./memoize-BK3gG5ob.js";import{n as r,t as i}from"./axios-DaWTGg7G.js";import{d as a,h as o}from"./config-BkbL2e5Q.js";import{o as s,s as c}from"./log-BlJ7CcKG.js";import{W as l,_ as u,ii as d,oi as f,r as p,z as m}from"./model-CmDF8O9G.js";import{Z as h,et as g}from"./esm-CrJVXrKW.js";import{f as _,p as v}from"./firstPartyEventLogger-D4yuDP-n.js";import{createHash as y}from"crypto";function b(e){return e.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`)}async function x(){if(N.length===0)return;let e=N;N=[];try{await r.post(E,e,{headers:{"Content-Type":`application/json`,"DD-API-KEY":D},timeout:A})}catch(e){c(e)}}function S(){P||(P=setTimeout(()=>{P=null,x()},T()).unref())}async function C(){P&&(clearTimeout(P),P=null),await x()}async function w(e,t){if(d()!==`firstParty`)return;let n=F;if(n===null&&(n=await I()),!(!n||!j.has(e)))try{let{envContext:n,...r}=await h({model:t.model,betas:t.betas}),i={...r,...n,...t,userBucket:R()};if(typeof i.toolName==`string`&&i.toolName.startsWith(`mcp__`)&&(i.toolName=`mcp`),typeof i.model==`string`){let e=p(i.model.replace(/\[1m]$/i,``));i.model=e in m?e:`other`}if(typeof i.version==`string`&&(i.version=i.version.replace(/^(\d+\.\d+\.\d+-dev\.\d{8})\.t\d+\.sha[a-f0-9]+$/,`$1`)),i.status!==void 0&&i.status!==null){let e=String(i.status);i.http_status=e;let t=e.charAt(0);t>=`1`&&t<=`5`&&(i.http_status_range=`${t}xx`),delete i.status}let a=i,o={ddsource:`nodejs`,ddtags:[`event:${e}`,...M.filter(e=>a[e]!==void 0&&a[e]!==null).map(e=>`${b(e)}:${a[e]}`)].join(`,`),message:e,service:`workmate`,hostname:`workmate`,env:process.env.USER_TYPE};for(let[e,t]of Object.entries(i))t!=null&&(o[b(e)]=t);N.push(o),N.length>=k?(P&&(clearTimeout(P),P=null),x()):S()}catch(e){c(e)}}function T(){return parseInt(process.env.CLAUDE_CODE_DATADOG_FLUSH_INTERVAL_MS||``,10)||O}var E,D,O,k,A,j,M,N,P,F,I,L,R,z=e((()=>{i(),n(),o(),s(),u(),f(),l(),_(),g(),E=process.env.DATADOG_LOGS_ENDPOINT??``,D=process.env.DATADOG_API_KEY??``,O=15e3,k=100,A=5e3,j=new Set(`tengu_api_error.tengu_api_success.tengu_cancel.tengu_compact_failed.tengu_exit.tengu_flicker.tengu_init.tengu_model_fallback_triggered.tengu_oauth_error.tengu_oauth_success.tengu_oauth_token_refresh_failure.tengu_oauth_token_refresh_success.tengu_oauth_token_refresh_lock_acquiring.tengu_oauth_token_refresh_lock_acquired.tengu_oauth_token_refresh_starting.tengu_oauth_token_refresh_completed.tengu_oauth_token_refresh_lock_releasing.tengu_oauth_token_refresh_lock_released.tengu_query_error.tengu_session_file_read.tengu_started.tengu_tool_use_error.tengu_tool_use_granted_in_prompt_permanent.tengu_tool_use_granted_in_prompt_temporary.tengu_tool_use_rejected_in_prompt.tengu_tool_use_success.tengu_uncaught_exception.tengu_unhandled_rejection.tengu_voice_recording_started.tengu_voice_toggled.tengu_team_mem_sync_pull.tengu_team_mem_sync_push.tengu_team_mem_sync_started.tengu_team_mem_entries_capped`.split(`.`)),M=[`arch`,`clientType`,`errorType`,`http_status_range`,`http_status`,`model`,`platform`,`provider`,`skillMode`,`subscriptionType`,`toolName`,`userBucket`,`userType`,`version`,`versionBase`],N=[],P=null,F=null,I=t(async()=>{if(v()||!E||!D)return F=!1,!1;try{return F=!0,!0}catch(e){return c(e),F=!1,!1}}),L=30,R=t(()=>{let e=a(),t=y(`sha256`).update(e).digest(`hex`);return parseInt(t.slice(0,8),16)%L})}));export{C as n,w as r,z as t};
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./memoize-BK3gG5ob.js";import{n as r,t as i}from"./axios-DaWTGg7G.js";import{d as a,h as o}from"./config-BSkuQZNf.js";import{o as s,s as c}from"./log-BlJ7CcKG.js";import{$r as l,N as u,R as d,_ as f,r as p,ti as m}from"./model-sviY1inu.js";import{Z as h,et as g}from"./esm-BI3tFLyy.js";import{f as _,p as v}from"./firstPartyEventLogger-BMnXb9cv.js";import{createHash as y}from"crypto";function b(e){return e.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`)}async function x(){if(N.length===0)return;let e=N;N=[];try{await r.post(E,e,{headers:{"Content-Type":`application/json`,"DD-API-KEY":D},timeout:A})}catch(e){c(e)}}function S(){P||(P=setTimeout(()=>{P=null,x()},T()).unref())}async function C(){P&&(clearTimeout(P),P=null),await x()}async function w(e,t){if(l()!==`firstParty`)return;let n=F;if(n===null&&(n=await I()),!(!n||!j.has(e)))try{let{envContext:n,...r}=await h({model:t.model,betas:t.betas}),i={...r,...n,...t,userBucket:R()};if(typeof i.toolName==`string`&&i.toolName.startsWith(`mcp__`)&&(i.toolName=`mcp`),typeof i.model==`string`){let e=p(i.model.replace(/\[1m]$/i,``));i.model=e in u?e:`other`}if(typeof i.version==`string`&&(i.version=i.version.replace(/^(\d+\.\d+\.\d+-dev\.\d{8})\.t\d+\.sha[a-f0-9]+$/,`$1`)),i.status!==void 0&&i.status!==null){let e=String(i.status);i.http_status=e;let t=e.charAt(0);t>=`1`&&t<=`5`&&(i.http_status_range=`${t}xx`),delete i.status}let a=i,o={ddsource:`nodejs`,ddtags:[`event:${e}`,...M.filter(e=>a[e]!==void 0&&a[e]!==null).map(e=>`${b(e)}:${a[e]}`)].join(`,`),message:e,service:`workmate`,hostname:`workmate`,env:process.env.USER_TYPE};for(let[e,t]of Object.entries(i))t!=null&&(o[b(e)]=t);N.push(o),N.length>=k?(P&&(clearTimeout(P),P=null),x()):S()}catch(e){c(e)}}function T(){return parseInt(process.env.CLAUDE_CODE_DATADOG_FLUSH_INTERVAL_MS||``,10)||O}var E,D,O,k,A,j,M,N,P,F,I,L,R,z=e((()=>{i(),n(),o(),s(),f(),m(),d(),_(),g(),E=process.env.DATADOG_LOGS_ENDPOINT??``,D=process.env.DATADOG_API_KEY??``,O=15e3,k=100,A=5e3,j=new Set(`tengu_api_error.tengu_api_success.tengu_cancel.tengu_compact_failed.tengu_exit.tengu_flicker.tengu_init.tengu_model_fallback_triggered.tengu_oauth_error.tengu_oauth_success.tengu_oauth_token_refresh_failure.tengu_oauth_token_refresh_success.tengu_oauth_token_refresh_lock_acquiring.tengu_oauth_token_refresh_lock_acquired.tengu_oauth_token_refresh_starting.tengu_oauth_token_refresh_completed.tengu_oauth_token_refresh_lock_releasing.tengu_oauth_token_refresh_lock_released.tengu_query_error.tengu_session_file_read.tengu_started.tengu_tool_use_error.tengu_tool_use_granted_in_prompt_permanent.tengu_tool_use_granted_in_prompt_temporary.tengu_tool_use_rejected_in_prompt.tengu_tool_use_success.tengu_uncaught_exception.tengu_unhandled_rejection.tengu_voice_recording_started.tengu_voice_toggled.tengu_team_mem_sync_pull.tengu_team_mem_sync_push.tengu_team_mem_sync_started.tengu_team_mem_entries_capped`.split(`.`)),M=[`arch`,`clientType`,`errorType`,`http_status_range`,`http_status`,`model`,`platform`,`provider`,`skillMode`,`subscriptionType`,`toolName`,`userBucket`,`userType`,`version`,`versionBase`],N=[],P=null,F=null,I=t(async()=>{if(v()||!E||!D)return F=!1,!1;try{return F=!0,!0}catch(e){return c(e),F=!1,!1}}),L=30,R=t(()=>{let e=a(),t=y(`sha256`).update(e).digest(`hex`);return parseInt(t.slice(0,8),16)%L})}));export{C as n,w as r,z as t};
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{t}from"./jsx-runtime-Bb4Xn-E0.js";var n,r;e((()=>{n=t(),r=async(e,t)=>{let{DiffDialog:r}=await import(`./DiffDialog-LTdtTqsC.js`);return(0,n.jsx)(r,{messages:t.messages,onDone:e})}}))();export{r as call};
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{t}from"./jsx-runtime-Bb4Xn-E0.js";var n,r;e((()=>{n=t(),r=async(e,t)=>{let{DiffDialog:r}=await import(`./DiffDialog-tlINuFS1.js`);return(0,n.jsx)(r,{messages:t.messages,onDone:e})}}))();export{r as call};
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./cwd-Besi3Os3.js";import{f as r,u as i}from"./debug-BQj6h99Q.js";import{cr as a,or as o}from"./settings-aUygByiZ.js";import{o as s,s as c}from"./log-BlJ7CcKG.js";import{a as l,i as u}from"./memoize-_2f7NWDv.js";import{basename as d,dirname as f,join as p,sep as m}from"path";function h(e,t){if(!e)return{directory:t||n(),prefix:``};let r=o(e,t);return e.endsWith(`/`)||e.endsWith(m)?{directory:r,prefix:``}:{directory:f(r),prefix:d(e)}}async function g(e){let t=C.get(e);if(t)return t;try{let t=(await i().readdir(e)).filter(e=>e.isDirectory()&&!e.name.startsWith(`.`)).map(t=>({name:t.name,path:p(e,t.name),type:`directory`})).slice(0,100);return C.set(e,t),t}catch(e){return c(e),[]}}async function _(e,t={}){let{basePath:r=n(),maxResults:i=10}=t,{directory:a,prefix:o}=h(e,r),s=await g(a),c=o.toLowerCase();return s.filter(e=>e.name.toLowerCase().startsWith(c)).slice(0,i).map(e=>({id:e.path,displayText:`${e.name}/`,description:`directory`,metadata:{type:`directory`}}))}function v(e){return e.startsWith(`~/`)||e.startsWith(`/`)||e.startsWith(`./`)||e.startsWith(`../`)||e===`~`||e===`.`||e===`..`}async function y(e,t=!1){let n=`${e}:${t}`,r=w.get(n);if(r)return r;try{let r=(await i().readdir(e)).filter(e=>t||!e.name.startsWith(`.`)).map(t=>({name:t.name,path:p(e,t.name),type:t.isDirectory()?`directory`:`file`})).sort((e,t)=>e.type===`directory`&&t.type!==`directory`?-1:e.type!==`directory`&&t.type===`directory`?1:e.name.localeCompare(t.name)).slice(0,100);return w.set(n,r),r}catch(e){return c(e),[]}}async function b(e,t={}){let{basePath:r=n(),maxResults:i=10,includeFiles:a=!0,includeHidden:o=!1}=t,{directory:s,prefix:c}=h(e,r),l=await y(s,o),u=c.toLowerCase(),d=l.filter(e=>!a&&e.type===`file`?!1:e.name.toLowerCase().startsWith(u)).slice(0,i),f=e.includes(`/`)||e.includes(m),p=``;if(f){let t=e.lastIndexOf(`/`),n=e.lastIndexOf(m),r=Math.max(t,n);p=e.substring(0,r+1)}return(p.startsWith(`./`)||p.startsWith(`.${m}`))&&(p=p.slice(2)),d.map(e=>{let t=p+e.name;return{id:t,displayText:e.type===`directory`?`${t}/`:t,metadata:{type:e.type}}})}var x,S,C,w,T=e((()=>{l(),t(),r(),s(),a(),x=500,S=300*1e3,C=new u({max:x,ttl:S}),w=new u({max:x,ttl:S})}));export{v as i,b as n,T as r,_ as t};
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./cwd-Besi3Os3.js";import{f as r,u as i}from"./debug-BQj6h99Q.js";import{cr as a,or as o}from"./settings-CvhsRFaT.js";import{o as s,s as c}from"./log-BlJ7CcKG.js";import{a as l,i as u}from"./memoize-_2f7NWDv.js";import{basename as d,dirname as f,join as p,sep as m}from"path";function h(e,t){if(!e)return{directory:t||n(),prefix:``};let r=o(e,t);return e.endsWith(`/`)||e.endsWith(m)?{directory:r,prefix:``}:{directory:f(r),prefix:d(e)}}async function g(e){let t=C.get(e);if(t)return t;try{let t=(await i().readdir(e)).filter(e=>e.isDirectory()&&!e.name.startsWith(`.`)).map(t=>({name:t.name,path:p(e,t.name),type:`directory`})).slice(0,100);return C.set(e,t),t}catch(e){return c(e),[]}}async function _(e,t={}){let{basePath:r=n(),maxResults:i=10}=t,{directory:a,prefix:o}=h(e,r),s=await g(a),c=o.toLowerCase();return s.filter(e=>e.name.toLowerCase().startsWith(c)).slice(0,i).map(e=>({id:e.path,displayText:`${e.name}/`,description:`directory`,metadata:{type:`directory`}}))}function v(e){return e.startsWith(`~/`)||e.startsWith(`/`)||e.startsWith(`./`)||e.startsWith(`../`)||e===`~`||e===`.`||e===`..`}async function y(e,t=!1){let n=`${e}:${t}`,r=w.get(n);if(r)return r;try{let r=(await i().readdir(e)).filter(e=>t||!e.name.startsWith(`.`)).map(t=>({name:t.name,path:p(e,t.name),type:t.isDirectory()?`directory`:`file`})).sort((e,t)=>e.type===`directory`&&t.type!==`directory`?-1:e.type!==`directory`&&t.type===`directory`?1:e.name.localeCompare(t.name)).slice(0,100);return w.set(n,r),r}catch(e){return c(e),[]}}async function b(e,t={}){let{basePath:r=n(),maxResults:i=10,includeFiles:a=!0,includeHidden:o=!1}=t,{directory:s,prefix:c}=h(e,r),l=await y(s,o),u=c.toLowerCase(),d=l.filter(e=>!a&&e.type===`file`?!1:e.name.toLowerCase().startsWith(u)).slice(0,i),f=e.includes(`/`)||e.includes(m),p=``;if(f){let t=e.lastIndexOf(`/`),n=e.lastIndexOf(m),r=Math.max(t,n);p=e.substring(0,r+1)}return(p.startsWith(`./`)||p.startsWith(`.${m}`))&&(p=p.slice(2)),d.map(e=>{let t=p+e.name;return{id:t,displayText:e.type===`directory`?`${t}/`:t,metadata:{type:e.type}}})}var x,S,C,w,T=e((()=>{l(),t(),r(),s(),a(),x=500,S=300*1e3,C=new u({max:x,ttl:S}),w=new u({max:x,ttl:S})}));export{v as i,b as n,T as r,_ as t};
@@ -0,0 +1 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{t}from"./jsx-runtime-Bb4Xn-E0.js";import{n,t as r}from"./Doctor-Wh7z6CnF.js";var i,a;e((()=>{n(),i=t(),a=(e,t,n)=>Promise.resolve((0,i.jsx)(r,{onDone:e}))}))();export{a as call};
@@ -1,4 +1,4 @@
1
- import{n as e,t}from"./defineProperty-C-QyHrDq.js";import{$y as n,B as r,Cu as i,Kc as a,Li as o,Mi as s,Qs as c,V as l,Yy as u,Zs as d,ar as f,br as p,gf as m,hf as h,i as g,o as _,qc as v,wu as y}from"./loadAgentsDir-JrGMJN05.js";import{A as b,C as x,M as S,O as C,P as w,b as T,j as E,l as ee,m as D,p as O,v as k,w as A}from"./external-CEp-aPkt.js";import{r as te}from"./lazySchema-B4D4qJVE.js";import{Bn as ne,Wt as j,_r as re,et as ie,gr as ae,ht as oe,or as M}from"./state-BPFYBqm1.js";import{f as se,g as ce}from"./settings-aUygByiZ.js";import{h as le,r as ue}from"./config-BkbL2e5Q.js";import{l as de,p as fe,r as pe}from"./sessionStoragePortable-x0Yn02-G.js";import{_ as me,u as he}from"./model-CmDF8O9G.js";import{vn as ge,yn as _e}from"./prompt-DnPppVz8.js";import{n as ve,r as ye}from"./managedEnv-C8SisyLk.js";import{t as be}from"./QueryEngine-sH-KjJIq.js";import{n as xe,t as Se}from"./modelOptions-DEQat7lU.js";import{dirname as Ce}from"node:path";import{randomUUID as N}from"node:crypto";import{Readable as we,Writable as Te}from"node:stream";import{unlink as Ee}from"node:fs/promises";import*as P from"node:path/posix";import{isAbsolute as De,resolve as Oe}from"node:path/posix";te();var F={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`},I={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`},ke=A({_meta:C(b(),S()).nullish(),terminal:D().optional().default(!1)}),Ae=A({_meta:C(b(),S()).nullish(),label:b().nullish(),name:b(),optional:D().optional().default(!1),secret:D().optional().default(!0)}),je=A({_meta:C(b(),S()).nullish(),description:b().nullish(),id:b(),name:b()}),Me=A({_meta:C(b(),S()).nullish(),description:b().nullish(),id:b(),link:b().nullish(),name:b(),vars:O(Ae)}),Ne=A({_meta:C(b(),S()).nullish(),args:O(b()).optional(),description:b().nullish(),env:C(b(),b()).optional(),id:b(),name:b()}),Pe=E([Me.and(A({type:T(`env_var`)})),Ne.and(A({type:T(`terminal`)})),je]),Fe=A({_meta:C(b(),S()).nullish(),methodId:b()}),Ie=A({_meta:C(b(),S()).nullish()}),Le=A({_meta:C(b(),S()).nullish(),blob:b(),mimeType:b().nullish(),uri:b()}),Re=A({default:D().nullish(),description:b().nullish(),title:b().nullish()}),ze=A({_meta:C(b(),S()).nullish()}),Be=A({_meta:C(b(),S()).nullish()}),Ve=A({amount:x(),currency:b()}),He=A({_meta:C(b(),S()).nullish(),terminalId:b()}),Ue=A({_meta:C(b(),S()).nullish(),newText:b(),oldText:b().nullish(),path:b()}),We=E([b(),x(),x(),D(),O(b())]),Ge=k(E([A({content:C(b(),We).nullish()}).and(A({action:T(`accept`)})),A({action:T(`decline`)}),A({action:T(`cancel`)})]),A({_meta:C(b(),S()).nullish()})),Ke=A({_meta:C(b(),S()).nullish()}),qe=b(),Je=A({_meta:C(b(),S()).nullish(),elicitationId:qe}),Ye=T(`object`),Xe=T(`string`),Ze=A({_meta:C(b(),S()).nullish()}),Qe=A({_meta:C(b(),S()).nullish(),form:Ke.nullish(),url:Ze.nullish()}),$e=A({const:b(),title:b()}),et=A({_meta:C(b(),S()).nullish(),name:b(),value:b()}),tt=A({code:E([T(-32700),T(-32600),T(-32601),T(-32602),T(-32603),T(-32800),T(-32e3),T(-32002),T(-32042),x().int().min(-2147483648,{message:`Invalid value: Expected int32 to be >= -2147483648`}).max(2147483647,{message:`Invalid value: Expected int32 to be <= 2147483647`})]),data:S().optional(),message:b()}),nt=S(),rt=S(),it=S(),at=A({_meta:C(b(),S()).nullish(),readTextFile:D().optional().default(!1),writeTextFile:D().optional().default(!1)}),ot=A({_meta:C(b(),S()).nullish(),name:b(),value:b()}),st=A({_meta:C(b(),S()).nullish(),name:b(),title:b().nullish(),version:b()}),ct=A({default:x().nullish(),description:b().nullish(),maximum:x().nullish(),minimum:x().nullish(),title:b().nullish()}),lt=A({_meta:C(b(),S()).nullish()}),ut=A({_meta:C(b(),S()).nullish(),additionalDirectories:O(b()).optional(),cursor:b().nullish(),cwd:b().nullish()}),dt=A({_meta:C(b(),S()).nullish()}),ft=A({_meta:C(b(),S()).nullish(),logout:dt.nullish()}),pt=A({_meta:C(b(),S()).nullish()}),mt=A({_meta:C(b(),S()).nullish()}),ht=A({_meta:C(b(),S()).nullish(),http:D().optional().default(!1),sse:D().optional().default(!1)}),gt=A({_meta:C(b(),S()).nullish(),headers:O(ot),name:b(),url:b()}),_t=A({_meta:C(b(),S()).nullish(),headers:O(ot),name:b(),url:b()}),vt=A({_meta:C(b(),S()).nullish(),args:O(b()),command:b(),env:O(et),name:b()}),L=E([gt.and(A({type:T(`http`)})),_t.and(A({type:T(`sse`)})),vt]),yt=b(),bt=A({_meta:C(b(),S()).nullish(),description:b().nullish(),modelId:yt,name:b()}),xt=E([T(`error`),T(`warning`),T(`information`),T(`hint`)]),St=A({_meta:C(b(),S()).nullish()}),Ct=A({_meta:C(b(),S()).nullish()}),wt=A({_meta:C(b(),S()).nullish()}),Tt=A({_meta:C(b(),S()).nullish()}),Et=A({_meta:C(b(),S()).nullish()}),Dt=A({_meta:C(b(),S()).nullish(),maxCount:x().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish()}),Ot=A({diff:b(),uri:b()}),kt=A({endLine:x().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}),startLine:x().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}),text:b()}),At=A({_meta:C(b(),S()).nullish()}),jt=A({_meta:C(b(),S()).nullish()}),Mt=A({languageId:b(),text:b(),uri:b()}),Nt=A({_meta:C(b(),S()).nullish(),maxCount:x().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish()}),Pt=E([T(`rejected`),T(`ignored`),T(`replaced`),T(`cancelled`)]),Ft=A({excerpts:O(kt),uri:b()}),It=A({_meta:C(b(),S()).nullish()}),Lt=A({_meta:C(b(),S()).nullish()}),Rt=A({name:b(),owner:b(),remoteUrl:b()}),zt=A({_meta:C(b(),S()).nullish()}),Bt=A({_meta:C(b(),S()).nullish(),jump:At.nullish(),rename:Lt.nullish(),searchAndReplace:zt.nullish()}),Vt=A({id:b(),isRegex:D().nullish(),replace:b(),search:b(),uri:b()}),Ht=E([T(`automatic`),T(`diagnostic`),T(`manual`)]),Ut=A({_meta:C(b(),S()).nullish(),maxCount:x().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish()}),Wt=A({_meta:C(b(),S()).nullish(),diagnostics:St.nullish(),editHistory:Dt.nullish(),openFiles:jt.nullish(),recentFiles:Nt.nullish(),relatedSnippets:It.nullish(),userActions:Ut.nullish()}),Gt=A({_meta:C(b(),S()).nullish(),additionalDirectories:O(b()).optional(),cwd:b(),mcpServers:O(L)}),Kt=A({default:x().nullish(),description:b().nullish(),maximum:x().nullish(),minimum:x().nullish(),title:b().nullish()}),qt=b(),Jt=E([T(`allow_once`),T(`allow_always`),T(`reject_once`),T(`reject_always`)]),Yt=A({_meta:C(b(),S()).nullish(),kind:Jt,name:b(),optionId:qt}),Xt=E([T(`high`),T(`medium`),T(`low`)]),Zt=E([T(`pending`),T(`in_progress`),T(`completed`)]),Qt=A({_meta:C(b(),S()).nullish(),content:b(),priority:Xt,status:Zt}),$t=A({_meta:C(b(),S()).nullish(),entries:O(Qt)}),R=A({character:x().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}),line:x().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`})}),en=A({id:b(),position:R,uri:b()}),tn=A({id:b(),newName:b(),position:R,uri:b()}),nn=A({action:b(),position:R,timestampMs:x(),uri:b()}),rn=E([T(`utf-16`),T(`utf-32`),T(`utf-8`)]),an=A({_meta:C(b(),S()).nullish(),auth:ke.optional().default({terminal:!1}),elicitation:Qe.nullish(),fs:at.optional().default({readTextFile:!1,writeTextFile:!1}),nes:Bt.nullish(),positionEncodings:O(rn).optional(),terminal:D().optional().default(!1)}),on=A({_meta:C(b(),S()).nullish(),audio:D().optional().default(!1),embeddedContext:D().optional().default(!1),image:D().optional().default(!1)}),sn=x().int().gte(0).lte(65535),cn=A({_meta:C(b(),S()).nullish(),clientCapabilities:an.optional().default({auth:{terminal:!1},fs:{readTextFile:!1,writeTextFile:!1},terminal:!1}),clientInfo:st.nullish(),protocolVersion:sn}),z=A({end:R,start:R}),ln=A({message:b(),range:z,severity:xt,uri:b()}),un=A({languageId:b(),lastFocusedMs:x().nullish(),uri:b(),visibleRange:z.nullish()}),dn=A({_meta:C(b(),S()).nullish(),diagnostics:O(ln).nullish(),editHistory:O(Ot).nullish(),openFiles:O(un).nullish(),recentFiles:O(Mt).nullish(),relatedSnippets:O(Ft).nullish(),userActions:O(nn).nullish()}),fn=A({newText:b(),range:z}),pn=E([A({cursorPosition:R.nullish(),edits:O(fn),id:b(),uri:b()}).and(A({kind:T(`edit`)})),en.and(A({kind:T(`jump`)})),tn.and(A({kind:T(`rename`)})),Vt.and(A({kind:T(`searchAndReplace`)}))]),mn=A({_meta:C(b(),S()).nullish(),content:b()}),hn=A({_meta:C(b(),S()).nullish()}),B=E([x(),b()]).nullable();A({_meta:C(b(),S()).nullish(),requestId:B});var gn=A({requestId:B}),_n=ee([`assistant`,`user`]),V=A({_meta:C(b(),S()).nullish(),audience:O(_n).nullish(),lastModified:b().nullish(),priority:x().nullish()}),vn=A({_meta:C(b(),S()).nullish(),annotations:V.nullish(),data:b(),mimeType:b()}),yn=A({_meta:C(b(),S()).nullish(),annotations:V.nullish(),data:b(),mimeType:b(),uri:b().nullish()}),bn=A({_meta:C(b(),S()).nullish(),annotations:V.nullish(),description:b().nullish(),mimeType:b().nullish(),name:b(),size:x().nullish(),title:b().nullish(),uri:b()}),xn=A({_meta:C(b(),S()).nullish(),optionId:qt}),Sn=E([A({outcome:T(`cancelled`)}),xn.and(A({outcome:T(`selected`)}))]),Cn=A({_meta:C(b(),S()).nullish(),outcome:Sn}),wn=A({_meta:C(b(),S()).nullish()}),Tn=A({_meta:C(b(),S()).nullish()}),En=A({currentValue:D()}),Dn=b(),On=b(),kn=E([T(`mode`),T(`model`),T(`thought_level`),b()]),An=b(),jn=A({_meta:C(b(),S()).nullish(),description:b().nullish(),name:b(),value:An}),Mn=A({_meta:C(b(),S()).nullish(),group:Dn,name:b(),options:O(jn)}),H=k(E([A({currentValue:An,options:E([O(jn),O(Mn)])}).and(A({type:T(`select`)})),En.and(A({type:T(`boolean`)}))]),A({_meta:C(b(),S()).nullish(),category:kn.nullish(),description:b().nullish(),id:On,name:b()})),Nn=A({_meta:C(b(),S()).nullish(),configOptions:O(H)}),Pn=A({_meta:C(b(),S()).nullish()}),U=b(),Fn=A({_meta:C(b(),S()).nullish(),id:b(),sessionId:U}),In=A({_meta:C(b(),S()).nullish(),sessionId:U}),Ln=A({_meta:C(b(),S()).nullish(),sessionId:U}),Rn=A({_meta:C(b(),S()).nullish(),sessionId:U}),zn=A({_meta:C(b(),S()).nullish(),args:O(b()).optional(),command:b(),cwd:b().nullish(),env:O(et).optional(),outputByteLimit:x().nullish(),sessionId:U}),Bn=A({_meta:C(b(),S()).nullish(),sessionId:U,uri:b()}),Vn=A({_meta:C(b(),S()).nullish(),position:R,sessionId:U,uri:b(),version:x(),visibleRange:z}),Hn=A({_meta:C(b(),S()).nullish(),languageId:b(),sessionId:U,text:b(),uri:b(),version:x()}),Un=A({_meta:C(b(),S()).nullish(),sessionId:U,uri:b()}),Wn=A({_meta:C(b(),S()).nullish(),additionalDirectories:O(b()).optional(),cwd:b(),mcpServers:O(L).optional(),sessionId:U}),Gn=A({_meta:C(b(),S()).nullish(),sessionId:U,terminalId:b()}),Kn=A({_meta:C(b(),S()).nullish(),additionalDirectories:O(b()).optional(),cwd:b(),mcpServers:O(L),sessionId:U}),qn=A({_meta:C(b(),S()).nullish(),limit:x().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),line:x().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),path:b(),sessionId:U}),Jn=A({_meta:C(b(),S()).nullish(),id:b(),reason:Pt.nullish(),sessionId:U}),Yn=A({_meta:C(b(),S()).nullish(),sessionId:U,terminalId:b()}),Xn=A({_meta:C(b(),S()).nullish(),additionalDirectories:O(b()).optional(),cwd:b(),mcpServers:O(L).optional(),sessionId:U}),Zn=A({_meta:C(b(),S()).nullish(),additionalDirectories:O(b()).optional(),cwd:b(),sessionId:U,title:b().nullish(),updatedAt:b().nullish()}),Qn=A({_meta:C(b(),S()).nullish(),nextCursor:b().nullish(),sessions:O(Zn)}),$n=A({_meta:C(b(),S()).nullish(),title:b().nullish(),updatedAt:b().nullish()}),er=A({_meta:C(b(),S()).nullish()}),W=b(),tr=A({_meta:C(b(),S()).nullish(),currentModeId:W}),nr=A({_meta:C(b(),S()).nullish(),description:b().nullish(),id:W,name:b()}),G=A({_meta:C(b(),S()).nullish(),availableModes:O(nr),currentModeId:W}),K=A({_meta:C(b(),S()).nullish(),availableModels:O(bt),currentModelId:yt}),rr=A({_meta:C(b(),S()).nullish(),configOptions:O(H).nullish(),models:K.nullish(),modes:G.nullish(),sessionId:U}),ir=A({_meta:C(b(),S()).nullish(),configOptions:O(H).nullish(),models:K.nullish(),modes:G.nullish()}),ar=A({_meta:C(b(),S()).nullish(),configOptions:O(H).nullish(),models:K.nullish(),modes:G.nullish(),sessionId:U}),or=A({_meta:C(b(),S()).nullish(),configOptions:O(H).nullish(),models:K.nullish(),modes:G.nullish()}),sr=A({_meta:C(b(),S()).nullish()}),cr=A({_meta:C(b(),S()).nullish(),additionalDirectories:wn.nullish(),close:Tn.nullish(),fork:Pn.nullish(),list:er.nullish(),resume:sr.nullish()}),lr=k(E([A({type:T(`boolean`),value:D()}),A({value:An})]),A({_meta:C(b(),S()).nullish(),configId:On,sessionId:U})),ur=A({_meta:C(b(),S()).nullish(),configOptions:O(H)}),dr=A({_meta:C(b(),S()).nullish(),modeId:W,sessionId:U}),fr=A({_meta:C(b(),S()).nullish()}),pr=A({_meta:C(b(),S()).nullish(),modelId:yt,sessionId:U}),mr=A({_meta:C(b(),S()).nullish()}),hr=A({_meta:C(b(),S()).nullish(),sessionId:U}),gr=E([T(`end_turn`),T(`max_tokens`),T(`max_turn_requests`),T(`refusal`),T(`cancelled`)]),_r=E([T(`email`),T(`uri`),T(`date`),T(`date-time`)]),vr=A({default:b().nullish(),description:b().nullish(),enum:O(b()).nullish(),format:_r.nullish(),maxLength:x().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),minLength:x().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),oneOf:O($e).nullish(),pattern:b().nullish(),title:b().nullish()}),yr=A({_meta:C(b(),S()).nullish(),context:dn.nullish(),position:R,selection:z.nullish(),sessionId:U,triggerKind:Ht,uri:b(),version:x()}),br=A({_meta:C(b(),S()).nullish(),suggestions:O(pn)}),xr=A({_meta:C(b(),S()).nullish(),terminalId:b()}),Sr=A({_meta:C(b(),S()).nullish(),exitCode:x().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),signal:b().nullish()}),Cr=A({_meta:C(b(),S()).nullish(),sessionId:U,terminalId:b()}),wr=A({_meta:C(b(),S()).nullish(),exitStatus:Sr.nullish(),output:b(),truncated:D()}),Tr=A({_meta:C(b(),S()).nullish(),annotations:V.nullish(),text:b()}),Er=A({range:z.nullish(),text:b()}),Dr=A({_meta:C(b(),S()).nullish(),contentChanges:O(Er),sessionId:U,uri:b(),version:x()});A({method:b(),params:E([In,Hn,Dr,Bn,Un,Vn,Fn,Jn,nt]).nullish()});var Or=E([T(`full`),T(`incremental`)]),kr=A({_meta:C(b(),S()).nullish(),syncKind:Or}),Ar=A({_meta:C(b(),S()).nullish(),didChange:kr.nullish(),didClose:Ct.nullish(),didFocus:wt.nullish(),didOpen:Tt.nullish(),didSave:Et.nullish()}),jr=A({_meta:C(b(),S()).nullish(),document:Ar.nullish()}),Mr=A({_meta:C(b(),S()).nullish(),context:Wt.nullish(),events:jr.nullish()}),Nr=A({_meta:C(b(),S()).nullish(),auth:ft.optional().default({}),loadSession:D().optional().default(!1),mcpCapabilities:ht.optional().default({http:!1,sse:!1}),nes:Mr.nullish(),positionEncoding:rn.nullish(),promptCapabilities:on.optional().default({audio:!1,embeddedContext:!1,image:!1}),sessionCapabilities:cr.optional().default({})}),Pr=A({_meta:C(b(),S()).nullish(),agentCapabilities:Nr.optional().default({auth:{},loadSession:!1,mcpCapabilities:{http:!1,sse:!1},promptCapabilities:{audio:!1,embeddedContext:!1,image:!1},sessionCapabilities:{}}),agentInfo:st.nullish(),authMethods:O(Pe).optional().default([]),protocolVersion:sn}),Fr=E([A({_meta:C(b(),S()).nullish(),mimeType:b().nullish(),text:b(),uri:b()}),Le]),Ir=A({_meta:C(b(),S()).nullish(),annotations:V.nullish(),resource:Fr}),Lr=E([Tr.and(A({type:T(`text`)})),yn.and(A({type:T(`image`)})),vn.and(A({type:T(`audio`)})),bn.and(A({type:T(`resource_link`)})),Ir.and(A({type:T(`resource`)}))]),Rr=A({_meta:C(b(),S()).nullish(),content:Lr}),zr=A({_meta:C(b(),S()).nullish(),content:Lr,messageId:b().nullish()}),Br=A({_meta:C(b(),S()).nullish(),messageId:b().nullish(),prompt:O(Lr),sessionId:U}),Vr=A({anyOf:O($e)}),Hr=E([Rr.and(A({type:T(`content`)})),Ue.and(A({type:T(`diff`)})),xr.and(A({type:T(`terminal`)}))]),Ur=b(),Wr=A({sessionId:U,toolCallId:Ur.nullish()}),Gr=k(E([Wr,gn]),A({elicitationId:qe,url:b().url()})),Kr=A({_meta:C(b(),S()).nullish(),line:x().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),path:b()}),qr=E([T(`pending`),T(`in_progress`),T(`completed`),T(`failed`)]),Jr=E([T(`read`),T(`edit`),T(`delete`),T(`move`),T(`search`),T(`execute`),T(`think`),T(`fetch`),T(`switch_mode`),T(`other`)]),Yr=A({_meta:C(b(),S()).nullish(),content:O(Hr).optional(),kind:Jr.optional(),locations:O(Kr).optional(),rawInput:S().optional(),rawOutput:S().optional(),status:qr.optional(),title:b(),toolCallId:Ur}),Xr=A({_meta:C(b(),S()).nullish(),content:O(Hr).nullish(),kind:Jr.nullish(),locations:O(Kr).nullish(),rawInput:S().optional(),rawOutput:S().optional(),status:qr.nullish(),title:b().nullish(),toolCallId:Ur}),Zr=A({_meta:C(b(),S()).nullish(),options:O(Yt),sessionId:U,toolCall:Xr}),Qr=A({_meta:C(b(),S()).nullish(),hint:b()}),$r=A({_meta:C(b(),S()).nullish(),description:b(),input:Qr.nullish(),name:b()}),ei=A({_meta:C(b(),S()).nullish(),availableCommands:O($r)}),ti=E([A({enum:O(b()),type:Xe}),Vr]),ni=A({default:O(b()).nullish(),description:b().nullish(),items:ti,maxItems:x().nullish(),minItems:x().nullish(),title:b().nullish()}),ri=E([vr.and(A({type:T(`string`)})),Kt.and(A({type:T(`number`)})),ct.and(A({type:T(`integer`)})),Re.and(A({type:T(`boolean`)})),ni.and(A({type:T(`array`)}))]),ii=A({description:b().nullish(),properties:C(b(),ri).optional().default({}),required:O(b()).nullish(),title:b().nullish(),type:Ye.optional().default(`object`)}),ai=k(E([k(E([Wr,gn]),A({requestedSchema:ii})).and(A({mode:T(`form`)})),Gr.and(A({mode:T(`url`)}))]),A({_meta:C(b(),S()).nullish(),message:b()})),oi=A({cachedReadTokens:x().nullish(),cachedWriteTokens:x().nullish(),inputTokens:x(),outputTokens:x(),thoughtTokens:x().nullish(),totalTokens:x()});E([A({id:B,result:E([Pr,Ie,mt,ar,ir,Qn,rr,or,Be,fr,ur,A({_meta:C(b(),S()).nullish(),stopReason:gr,usage:oi.nullish(),userMessageId:b().nullish()}),mr,hr,br,ze,it])}),A({error:tt,id:B})]);var si=A({_meta:C(b(),S()).nullish(),cost:Ve.nullish(),size:x(),used:x()}),ci=E([zr.and(A({sessionUpdate:T(`user_message_chunk`)})),zr.and(A({sessionUpdate:T(`agent_message_chunk`)})),zr.and(A({sessionUpdate:T(`agent_thought_chunk`)})),Yr.and(A({sessionUpdate:T(`tool_call`)})),Xr.and(A({sessionUpdate:T(`tool_call_update`)})),$t.and(A({sessionUpdate:T(`plan`)})),ei.and(A({sessionUpdate:T(`available_commands_update`)})),tr.and(A({sessionUpdate:T(`current_mode_update`)})),Nn.and(A({sessionUpdate:T(`config_option_update`)})),$n.and(A({sessionUpdate:T(`session_info_update`)})),si.and(A({sessionUpdate:T(`usage_update`)}))]),li=A({_meta:C(b(),S()).nullish(),sessionId:U,update:ci});A({method:b(),params:E([li,Je,nt]).nullish()});var ui=A({_meta:C(b(),S()).nullish(),sessionId:U,terminalId:b()}),di=A({_meta:C(b(),S()).nullish(),exitCode:x().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),signal:b().nullish()}),fi=A({name:b(),uri:b()}),pi=A({_meta:C(b(),S()).nullish(),repository:Rt.nullish(),workspaceFolders:O(fi).nullish(),workspaceUri:b().nullish()});A({id:B,method:b(),params:E([cn,Fe,pt,Gt,Kn,ut,Wn,Xn,Rn,dr,lr,Br,pr,pi,yr,Ln,rt]).nullish()});var mi=A({_meta:C(b(),S()).nullish(),content:b(),path:b(),sessionId:U});A({id:B,method:b(),params:E([mi,qn,Zr,zn,Cr,Yn,ui,Gn,ai,rt]).nullish()}),E([A({id:B,result:E([A({_meta:C(b(),S()).nullish()}),mn,Cn,He,wr,hn,di,lt,Ge,it])}),A({error:tt,id:B})]),e();function hi(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(`
1
+ import{n as e,t}from"./defineProperty-C-QyHrDq.js";import{$y as n,B as r,Cu as i,Kc as a,Li as o,Mi as s,Qs as c,V as l,Yy as u,Zs as d,ar as f,br as p,gf as m,hf as h,i as g,o as _,qc as v,wu as y}from"./loadAgentsDir-PPiD2Mfq.js";import{A as b,C as x,M as S,O as C,P as w,b as T,j as E,l as ee,m as D,p as O,v as k,w as A}from"./external-CEp-aPkt.js";import{r as te}from"./lazySchema-B4D4qJVE.js";import{Bn as ne,Wt as j,_r as re,et as ie,gr as ae,ht as oe,or as M}from"./state-BPFYBqm1.js";import{f as se,g as ce}from"./settings-CvhsRFaT.js";import{h as le,r as ue}from"./config-BSkuQZNf.js";import{l as de,p as fe,r as pe}from"./sessionStoragePortable-x0Yn02-G.js";import{_ as me,u as he}from"./model-sviY1inu.js";import{vn as ge,yn as _e}from"./prompt-CQmEvnKN.js";import{n as ve,r as ye}from"./managedEnv-BUrzwaD3.js";import{t as be}from"./QueryEngine-CRobcENE.js";import{n as xe,r as Se}from"./modelOptions-DYQqTLPi.js";import{dirname as Ce}from"node:path";import{randomUUID as N}from"node:crypto";import{Readable as we,Writable as Te}from"node:stream";import{unlink as Ee}from"node:fs/promises";import*as P from"node:path/posix";import{isAbsolute as De,resolve as Oe}from"node:path/posix";te();var F={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`},I={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`},ke=A({_meta:C(b(),S()).nullish(),terminal:D().optional().default(!1)}),Ae=A({_meta:C(b(),S()).nullish(),label:b().nullish(),name:b(),optional:D().optional().default(!1),secret:D().optional().default(!0)}),je=A({_meta:C(b(),S()).nullish(),description:b().nullish(),id:b(),name:b()}),Me=A({_meta:C(b(),S()).nullish(),description:b().nullish(),id:b(),link:b().nullish(),name:b(),vars:O(Ae)}),Ne=A({_meta:C(b(),S()).nullish(),args:O(b()).optional(),description:b().nullish(),env:C(b(),b()).optional(),id:b(),name:b()}),Pe=E([Me.and(A({type:T(`env_var`)})),Ne.and(A({type:T(`terminal`)})),je]),Fe=A({_meta:C(b(),S()).nullish(),methodId:b()}),Ie=A({_meta:C(b(),S()).nullish()}),Le=A({_meta:C(b(),S()).nullish(),blob:b(),mimeType:b().nullish(),uri:b()}),Re=A({default:D().nullish(),description:b().nullish(),title:b().nullish()}),ze=A({_meta:C(b(),S()).nullish()}),Be=A({_meta:C(b(),S()).nullish()}),Ve=A({amount:x(),currency:b()}),He=A({_meta:C(b(),S()).nullish(),terminalId:b()}),Ue=A({_meta:C(b(),S()).nullish(),newText:b(),oldText:b().nullish(),path:b()}),We=E([b(),x(),x(),D(),O(b())]),Ge=k(E([A({content:C(b(),We).nullish()}).and(A({action:T(`accept`)})),A({action:T(`decline`)}),A({action:T(`cancel`)})]),A({_meta:C(b(),S()).nullish()})),Ke=A({_meta:C(b(),S()).nullish()}),qe=b(),Je=A({_meta:C(b(),S()).nullish(),elicitationId:qe}),Ye=T(`object`),Xe=T(`string`),Ze=A({_meta:C(b(),S()).nullish()}),Qe=A({_meta:C(b(),S()).nullish(),form:Ke.nullish(),url:Ze.nullish()}),$e=A({const:b(),title:b()}),et=A({_meta:C(b(),S()).nullish(),name:b(),value:b()}),tt=A({code:E([T(-32700),T(-32600),T(-32601),T(-32602),T(-32603),T(-32800),T(-32e3),T(-32002),T(-32042),x().int().min(-2147483648,{message:`Invalid value: Expected int32 to be >= -2147483648`}).max(2147483647,{message:`Invalid value: Expected int32 to be <= 2147483647`})]),data:S().optional(),message:b()}),nt=S(),rt=S(),it=S(),at=A({_meta:C(b(),S()).nullish(),readTextFile:D().optional().default(!1),writeTextFile:D().optional().default(!1)}),ot=A({_meta:C(b(),S()).nullish(),name:b(),value:b()}),st=A({_meta:C(b(),S()).nullish(),name:b(),title:b().nullish(),version:b()}),ct=A({default:x().nullish(),description:b().nullish(),maximum:x().nullish(),minimum:x().nullish(),title:b().nullish()}),lt=A({_meta:C(b(),S()).nullish()}),ut=A({_meta:C(b(),S()).nullish(),additionalDirectories:O(b()).optional(),cursor:b().nullish(),cwd:b().nullish()}),dt=A({_meta:C(b(),S()).nullish()}),ft=A({_meta:C(b(),S()).nullish(),logout:dt.nullish()}),pt=A({_meta:C(b(),S()).nullish()}),mt=A({_meta:C(b(),S()).nullish()}),ht=A({_meta:C(b(),S()).nullish(),http:D().optional().default(!1),sse:D().optional().default(!1)}),gt=A({_meta:C(b(),S()).nullish(),headers:O(ot),name:b(),url:b()}),_t=A({_meta:C(b(),S()).nullish(),headers:O(ot),name:b(),url:b()}),vt=A({_meta:C(b(),S()).nullish(),args:O(b()),command:b(),env:O(et),name:b()}),L=E([gt.and(A({type:T(`http`)})),_t.and(A({type:T(`sse`)})),vt]),yt=b(),bt=A({_meta:C(b(),S()).nullish(),description:b().nullish(),modelId:yt,name:b()}),xt=E([T(`error`),T(`warning`),T(`information`),T(`hint`)]),St=A({_meta:C(b(),S()).nullish()}),Ct=A({_meta:C(b(),S()).nullish()}),wt=A({_meta:C(b(),S()).nullish()}),Tt=A({_meta:C(b(),S()).nullish()}),Et=A({_meta:C(b(),S()).nullish()}),Dt=A({_meta:C(b(),S()).nullish(),maxCount:x().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish()}),Ot=A({diff:b(),uri:b()}),kt=A({endLine:x().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}),startLine:x().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}),text:b()}),At=A({_meta:C(b(),S()).nullish()}),jt=A({_meta:C(b(),S()).nullish()}),Mt=A({languageId:b(),text:b(),uri:b()}),Nt=A({_meta:C(b(),S()).nullish(),maxCount:x().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish()}),Pt=E([T(`rejected`),T(`ignored`),T(`replaced`),T(`cancelled`)]),Ft=A({excerpts:O(kt),uri:b()}),It=A({_meta:C(b(),S()).nullish()}),Lt=A({_meta:C(b(),S()).nullish()}),Rt=A({name:b(),owner:b(),remoteUrl:b()}),zt=A({_meta:C(b(),S()).nullish()}),Bt=A({_meta:C(b(),S()).nullish(),jump:At.nullish(),rename:Lt.nullish(),searchAndReplace:zt.nullish()}),Vt=A({id:b(),isRegex:D().nullish(),replace:b(),search:b(),uri:b()}),Ht=E([T(`automatic`),T(`diagnostic`),T(`manual`)]),Ut=A({_meta:C(b(),S()).nullish(),maxCount:x().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish()}),Wt=A({_meta:C(b(),S()).nullish(),diagnostics:St.nullish(),editHistory:Dt.nullish(),openFiles:jt.nullish(),recentFiles:Nt.nullish(),relatedSnippets:It.nullish(),userActions:Ut.nullish()}),Gt=A({_meta:C(b(),S()).nullish(),additionalDirectories:O(b()).optional(),cwd:b(),mcpServers:O(L)}),Kt=A({default:x().nullish(),description:b().nullish(),maximum:x().nullish(),minimum:x().nullish(),title:b().nullish()}),qt=b(),Jt=E([T(`allow_once`),T(`allow_always`),T(`reject_once`),T(`reject_always`)]),Yt=A({_meta:C(b(),S()).nullish(),kind:Jt,name:b(),optionId:qt}),Xt=E([T(`high`),T(`medium`),T(`low`)]),Zt=E([T(`pending`),T(`in_progress`),T(`completed`)]),Qt=A({_meta:C(b(),S()).nullish(),content:b(),priority:Xt,status:Zt}),$t=A({_meta:C(b(),S()).nullish(),entries:O(Qt)}),R=A({character:x().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}),line:x().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`})}),en=A({id:b(),position:R,uri:b()}),tn=A({id:b(),newName:b(),position:R,uri:b()}),nn=A({action:b(),position:R,timestampMs:x(),uri:b()}),rn=E([T(`utf-16`),T(`utf-32`),T(`utf-8`)]),an=A({_meta:C(b(),S()).nullish(),auth:ke.optional().default({terminal:!1}),elicitation:Qe.nullish(),fs:at.optional().default({readTextFile:!1,writeTextFile:!1}),nes:Bt.nullish(),positionEncodings:O(rn).optional(),terminal:D().optional().default(!1)}),on=A({_meta:C(b(),S()).nullish(),audio:D().optional().default(!1),embeddedContext:D().optional().default(!1),image:D().optional().default(!1)}),sn=x().int().gte(0).lte(65535),cn=A({_meta:C(b(),S()).nullish(),clientCapabilities:an.optional().default({auth:{terminal:!1},fs:{readTextFile:!1,writeTextFile:!1},terminal:!1}),clientInfo:st.nullish(),protocolVersion:sn}),z=A({end:R,start:R}),ln=A({message:b(),range:z,severity:xt,uri:b()}),un=A({languageId:b(),lastFocusedMs:x().nullish(),uri:b(),visibleRange:z.nullish()}),dn=A({_meta:C(b(),S()).nullish(),diagnostics:O(ln).nullish(),editHistory:O(Ot).nullish(),openFiles:O(un).nullish(),recentFiles:O(Mt).nullish(),relatedSnippets:O(Ft).nullish(),userActions:O(nn).nullish()}),fn=A({newText:b(),range:z}),pn=E([A({cursorPosition:R.nullish(),edits:O(fn),id:b(),uri:b()}).and(A({kind:T(`edit`)})),en.and(A({kind:T(`jump`)})),tn.and(A({kind:T(`rename`)})),Vt.and(A({kind:T(`searchAndReplace`)}))]),mn=A({_meta:C(b(),S()).nullish(),content:b()}),hn=A({_meta:C(b(),S()).nullish()}),B=E([x(),b()]).nullable();A({_meta:C(b(),S()).nullish(),requestId:B});var gn=A({requestId:B}),_n=ee([`assistant`,`user`]),V=A({_meta:C(b(),S()).nullish(),audience:O(_n).nullish(),lastModified:b().nullish(),priority:x().nullish()}),vn=A({_meta:C(b(),S()).nullish(),annotations:V.nullish(),data:b(),mimeType:b()}),yn=A({_meta:C(b(),S()).nullish(),annotations:V.nullish(),data:b(),mimeType:b(),uri:b().nullish()}),bn=A({_meta:C(b(),S()).nullish(),annotations:V.nullish(),description:b().nullish(),mimeType:b().nullish(),name:b(),size:x().nullish(),title:b().nullish(),uri:b()}),xn=A({_meta:C(b(),S()).nullish(),optionId:qt}),Sn=E([A({outcome:T(`cancelled`)}),xn.and(A({outcome:T(`selected`)}))]),Cn=A({_meta:C(b(),S()).nullish(),outcome:Sn}),wn=A({_meta:C(b(),S()).nullish()}),Tn=A({_meta:C(b(),S()).nullish()}),En=A({currentValue:D()}),Dn=b(),On=b(),kn=E([T(`mode`),T(`model`),T(`thought_level`),b()]),An=b(),jn=A({_meta:C(b(),S()).nullish(),description:b().nullish(),name:b(),value:An}),Mn=A({_meta:C(b(),S()).nullish(),group:Dn,name:b(),options:O(jn)}),H=k(E([A({currentValue:An,options:E([O(jn),O(Mn)])}).and(A({type:T(`select`)})),En.and(A({type:T(`boolean`)}))]),A({_meta:C(b(),S()).nullish(),category:kn.nullish(),description:b().nullish(),id:On,name:b()})),Nn=A({_meta:C(b(),S()).nullish(),configOptions:O(H)}),Pn=A({_meta:C(b(),S()).nullish()}),U=b(),Fn=A({_meta:C(b(),S()).nullish(),id:b(),sessionId:U}),In=A({_meta:C(b(),S()).nullish(),sessionId:U}),Ln=A({_meta:C(b(),S()).nullish(),sessionId:U}),Rn=A({_meta:C(b(),S()).nullish(),sessionId:U}),zn=A({_meta:C(b(),S()).nullish(),args:O(b()).optional(),command:b(),cwd:b().nullish(),env:O(et).optional(),outputByteLimit:x().nullish(),sessionId:U}),Bn=A({_meta:C(b(),S()).nullish(),sessionId:U,uri:b()}),Vn=A({_meta:C(b(),S()).nullish(),position:R,sessionId:U,uri:b(),version:x(),visibleRange:z}),Hn=A({_meta:C(b(),S()).nullish(),languageId:b(),sessionId:U,text:b(),uri:b(),version:x()}),Un=A({_meta:C(b(),S()).nullish(),sessionId:U,uri:b()}),Wn=A({_meta:C(b(),S()).nullish(),additionalDirectories:O(b()).optional(),cwd:b(),mcpServers:O(L).optional(),sessionId:U}),Gn=A({_meta:C(b(),S()).nullish(),sessionId:U,terminalId:b()}),Kn=A({_meta:C(b(),S()).nullish(),additionalDirectories:O(b()).optional(),cwd:b(),mcpServers:O(L),sessionId:U}),qn=A({_meta:C(b(),S()).nullish(),limit:x().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),line:x().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),path:b(),sessionId:U}),Jn=A({_meta:C(b(),S()).nullish(),id:b(),reason:Pt.nullish(),sessionId:U}),Yn=A({_meta:C(b(),S()).nullish(),sessionId:U,terminalId:b()}),Xn=A({_meta:C(b(),S()).nullish(),additionalDirectories:O(b()).optional(),cwd:b(),mcpServers:O(L).optional(),sessionId:U}),Zn=A({_meta:C(b(),S()).nullish(),additionalDirectories:O(b()).optional(),cwd:b(),sessionId:U,title:b().nullish(),updatedAt:b().nullish()}),Qn=A({_meta:C(b(),S()).nullish(),nextCursor:b().nullish(),sessions:O(Zn)}),$n=A({_meta:C(b(),S()).nullish(),title:b().nullish(),updatedAt:b().nullish()}),er=A({_meta:C(b(),S()).nullish()}),W=b(),tr=A({_meta:C(b(),S()).nullish(),currentModeId:W}),nr=A({_meta:C(b(),S()).nullish(),description:b().nullish(),id:W,name:b()}),G=A({_meta:C(b(),S()).nullish(),availableModes:O(nr),currentModeId:W}),K=A({_meta:C(b(),S()).nullish(),availableModels:O(bt),currentModelId:yt}),rr=A({_meta:C(b(),S()).nullish(),configOptions:O(H).nullish(),models:K.nullish(),modes:G.nullish(),sessionId:U}),ir=A({_meta:C(b(),S()).nullish(),configOptions:O(H).nullish(),models:K.nullish(),modes:G.nullish()}),ar=A({_meta:C(b(),S()).nullish(),configOptions:O(H).nullish(),models:K.nullish(),modes:G.nullish(),sessionId:U}),or=A({_meta:C(b(),S()).nullish(),configOptions:O(H).nullish(),models:K.nullish(),modes:G.nullish()}),sr=A({_meta:C(b(),S()).nullish()}),cr=A({_meta:C(b(),S()).nullish(),additionalDirectories:wn.nullish(),close:Tn.nullish(),fork:Pn.nullish(),list:er.nullish(),resume:sr.nullish()}),lr=k(E([A({type:T(`boolean`),value:D()}),A({value:An})]),A({_meta:C(b(),S()).nullish(),configId:On,sessionId:U})),ur=A({_meta:C(b(),S()).nullish(),configOptions:O(H)}),dr=A({_meta:C(b(),S()).nullish(),modeId:W,sessionId:U}),fr=A({_meta:C(b(),S()).nullish()}),pr=A({_meta:C(b(),S()).nullish(),modelId:yt,sessionId:U}),mr=A({_meta:C(b(),S()).nullish()}),hr=A({_meta:C(b(),S()).nullish(),sessionId:U}),gr=E([T(`end_turn`),T(`max_tokens`),T(`max_turn_requests`),T(`refusal`),T(`cancelled`)]),_r=E([T(`email`),T(`uri`),T(`date`),T(`date-time`)]),vr=A({default:b().nullish(),description:b().nullish(),enum:O(b()).nullish(),format:_r.nullish(),maxLength:x().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),minLength:x().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),oneOf:O($e).nullish(),pattern:b().nullish(),title:b().nullish()}),yr=A({_meta:C(b(),S()).nullish(),context:dn.nullish(),position:R,selection:z.nullish(),sessionId:U,triggerKind:Ht,uri:b(),version:x()}),br=A({_meta:C(b(),S()).nullish(),suggestions:O(pn)}),xr=A({_meta:C(b(),S()).nullish(),terminalId:b()}),Sr=A({_meta:C(b(),S()).nullish(),exitCode:x().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),signal:b().nullish()}),Cr=A({_meta:C(b(),S()).nullish(),sessionId:U,terminalId:b()}),wr=A({_meta:C(b(),S()).nullish(),exitStatus:Sr.nullish(),output:b(),truncated:D()}),Tr=A({_meta:C(b(),S()).nullish(),annotations:V.nullish(),text:b()}),Er=A({range:z.nullish(),text:b()}),Dr=A({_meta:C(b(),S()).nullish(),contentChanges:O(Er),sessionId:U,uri:b(),version:x()});A({method:b(),params:E([In,Hn,Dr,Bn,Un,Vn,Fn,Jn,nt]).nullish()});var Or=E([T(`full`),T(`incremental`)]),kr=A({_meta:C(b(),S()).nullish(),syncKind:Or}),Ar=A({_meta:C(b(),S()).nullish(),didChange:kr.nullish(),didClose:Ct.nullish(),didFocus:wt.nullish(),didOpen:Tt.nullish(),didSave:Et.nullish()}),jr=A({_meta:C(b(),S()).nullish(),document:Ar.nullish()}),Mr=A({_meta:C(b(),S()).nullish(),context:Wt.nullish(),events:jr.nullish()}),Nr=A({_meta:C(b(),S()).nullish(),auth:ft.optional().default({}),loadSession:D().optional().default(!1),mcpCapabilities:ht.optional().default({http:!1,sse:!1}),nes:Mr.nullish(),positionEncoding:rn.nullish(),promptCapabilities:on.optional().default({audio:!1,embeddedContext:!1,image:!1}),sessionCapabilities:cr.optional().default({})}),Pr=A({_meta:C(b(),S()).nullish(),agentCapabilities:Nr.optional().default({auth:{},loadSession:!1,mcpCapabilities:{http:!1,sse:!1},promptCapabilities:{audio:!1,embeddedContext:!1,image:!1},sessionCapabilities:{}}),agentInfo:st.nullish(),authMethods:O(Pe).optional().default([]),protocolVersion:sn}),Fr=E([A({_meta:C(b(),S()).nullish(),mimeType:b().nullish(),text:b(),uri:b()}),Le]),Ir=A({_meta:C(b(),S()).nullish(),annotations:V.nullish(),resource:Fr}),Lr=E([Tr.and(A({type:T(`text`)})),yn.and(A({type:T(`image`)})),vn.and(A({type:T(`audio`)})),bn.and(A({type:T(`resource_link`)})),Ir.and(A({type:T(`resource`)}))]),Rr=A({_meta:C(b(),S()).nullish(),content:Lr}),zr=A({_meta:C(b(),S()).nullish(),content:Lr,messageId:b().nullish()}),Br=A({_meta:C(b(),S()).nullish(),messageId:b().nullish(),prompt:O(Lr),sessionId:U}),Vr=A({anyOf:O($e)}),Hr=E([Rr.and(A({type:T(`content`)})),Ue.and(A({type:T(`diff`)})),xr.and(A({type:T(`terminal`)}))]),Ur=b(),Wr=A({sessionId:U,toolCallId:Ur.nullish()}),Gr=k(E([Wr,gn]),A({elicitationId:qe,url:b().url()})),Kr=A({_meta:C(b(),S()).nullish(),line:x().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),path:b()}),qr=E([T(`pending`),T(`in_progress`),T(`completed`),T(`failed`)]),Jr=E([T(`read`),T(`edit`),T(`delete`),T(`move`),T(`search`),T(`execute`),T(`think`),T(`fetch`),T(`switch_mode`),T(`other`)]),Yr=A({_meta:C(b(),S()).nullish(),content:O(Hr).optional(),kind:Jr.optional(),locations:O(Kr).optional(),rawInput:S().optional(),rawOutput:S().optional(),status:qr.optional(),title:b(),toolCallId:Ur}),Xr=A({_meta:C(b(),S()).nullish(),content:O(Hr).nullish(),kind:Jr.nullish(),locations:O(Kr).nullish(),rawInput:S().optional(),rawOutput:S().optional(),status:qr.nullish(),title:b().nullish(),toolCallId:Ur}),Zr=A({_meta:C(b(),S()).nullish(),options:O(Yt),sessionId:U,toolCall:Xr}),Qr=A({_meta:C(b(),S()).nullish(),hint:b()}),$r=A({_meta:C(b(),S()).nullish(),description:b(),input:Qr.nullish(),name:b()}),ei=A({_meta:C(b(),S()).nullish(),availableCommands:O($r)}),ti=E([A({enum:O(b()),type:Xe}),Vr]),ni=A({default:O(b()).nullish(),description:b().nullish(),items:ti,maxItems:x().nullish(),minItems:x().nullish(),title:b().nullish()}),ri=E([vr.and(A({type:T(`string`)})),Kt.and(A({type:T(`number`)})),ct.and(A({type:T(`integer`)})),Re.and(A({type:T(`boolean`)})),ni.and(A({type:T(`array`)}))]),ii=A({description:b().nullish(),properties:C(b(),ri).optional().default({}),required:O(b()).nullish(),title:b().nullish(),type:Ye.optional().default(`object`)}),ai=k(E([k(E([Wr,gn]),A({requestedSchema:ii})).and(A({mode:T(`form`)})),Gr.and(A({mode:T(`url`)}))]),A({_meta:C(b(),S()).nullish(),message:b()})),oi=A({cachedReadTokens:x().nullish(),cachedWriteTokens:x().nullish(),inputTokens:x(),outputTokens:x(),thoughtTokens:x().nullish(),totalTokens:x()});E([A({id:B,result:E([Pr,Ie,mt,ar,ir,Qn,rr,or,Be,fr,ur,A({_meta:C(b(),S()).nullish(),stopReason:gr,usage:oi.nullish(),userMessageId:b().nullish()}),mr,hr,br,ze,it])}),A({error:tt,id:B})]);var si=A({_meta:C(b(),S()).nullish(),cost:Ve.nullish(),size:x(),used:x()}),ci=E([zr.and(A({sessionUpdate:T(`user_message_chunk`)})),zr.and(A({sessionUpdate:T(`agent_message_chunk`)})),zr.and(A({sessionUpdate:T(`agent_thought_chunk`)})),Yr.and(A({sessionUpdate:T(`tool_call`)})),Xr.and(A({sessionUpdate:T(`tool_call_update`)})),$t.and(A({sessionUpdate:T(`plan`)})),ei.and(A({sessionUpdate:T(`available_commands_update`)})),tr.and(A({sessionUpdate:T(`current_mode_update`)})),Nn.and(A({sessionUpdate:T(`config_option_update`)})),$n.and(A({sessionUpdate:T(`session_info_update`)})),si.and(A({sessionUpdate:T(`usage_update`)}))]),li=A({_meta:C(b(),S()).nullish(),sessionId:U,update:ci});A({method:b(),params:E([li,Je,nt]).nullish()});var ui=A({_meta:C(b(),S()).nullish(),sessionId:U,terminalId:b()}),di=A({_meta:C(b(),S()).nullish(),exitCode:x().int().gte(0).max(4294967295,{message:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),signal:b().nullish()}),fi=A({name:b(),uri:b()}),pi=A({_meta:C(b(),S()).nullish(),repository:Rt.nullish(),workspaceFolders:O(fi).nullish(),workspaceUri:b().nullish()});A({id:B,method:b(),params:E([cn,Fe,pt,Gt,Kn,ut,Wn,Xn,Rn,dr,lr,Br,pr,pi,yr,Ln,rt]).nullish()});var mi=A({_meta:C(b(),S()).nullish(),content:b(),path:b(),sessionId:U});A({id:B,method:b(),params:E([mi,qn,Zr,zn,Cr,Yn,ui,Gn,ai,rt]).nullish()}),E([A({id:B,result:E([A({_meta:C(b(),S()).nullish()}),mn,Cn,He,wr,hn,di,lt,Ge,it])}),A({error:tt,id:B})]),e();function hi(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
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
3
  `,i=e.getWriter();try{await i.write(n.encode(r))}finally{i.releaseLock()}}})}}te();var gi,_i=class{constructor(e,n){t(this,`connection`,void 0);let r=e(this),i=async(e,t)=>{switch(e){case F.initialize:{let e=cn.parse(t);return r.initialize(e)}case F.session_new:{let e=Gt.parse(t);return r.newSession(e)}case F.session_load:{if(!r.loadSession)throw q.methodNotFound(e);let n=Kn.parse(t);return r.loadSession(n)}case F.session_list:{if(!r.listSessions)throw q.methodNotFound(e);let n=ut.parse(t);return r.listSessions(n)}case F.session_fork:{if(!r.unstable_forkSession)throw q.methodNotFound(e);let n=Wn.parse(t);return r.unstable_forkSession(n)}case F.session_resume:{if(!r.unstable_resumeSession)throw q.methodNotFound(e);let n=Xn.parse(t);return r.unstable_resumeSession(n)}case F.session_close:{if(!r.unstable_closeSession)throw q.methodNotFound(e);let n=Rn.parse(t);return r.unstable_closeSession(n)}case F.session_set_mode:{if(!r.setSessionMode)throw q.methodNotFound(e);let n=dr.parse(t);return await r.setSessionMode(n)??{}}case F.authenticate:{let e=Fe.parse(t);return await r.authenticate(e)??{}}case F.logout:{if(!r.unstable_logout)throw q.methodNotFound(e);let n=pt.parse(t);return await r.unstable_logout(n)??{}}case F.session_prompt:{let e=Br.parse(t);return r.prompt(e)}case F.session_set_model:{if(!r.unstable_setSessionModel)throw q.methodNotFound(e);let n=pr.parse(t);return await r.unstable_setSessionModel(n)??{}}case F.session_set_config_option:{if(!r.setSessionConfigOption)throw q.methodNotFound(e);let n=lr.parse(t);return r.setSessionConfigOption(n)}case F.nes_start:{if(!r.unstable_startNes)throw q.methodNotFound(e);let n=pi.parse(t);return r.unstable_startNes(n)}case F.nes_suggest:{if(!r.unstable_suggestNes)throw q.methodNotFound(e);let n=yr.parse(t);return r.unstable_suggestNes(n)}case F.nes_close:{if(!r.unstable_closeNes)throw q.methodNotFound(e);let n=Ln.parse(t);return await r.unstable_closeNes(n)??{}}default:if(r.extMethod)return r.extMethod(e,t);throw q.methodNotFound(e)}},a=async(e,t)=>{switch(e){case F.session_cancel:{let e=In.parse(t);return r.cancel(e)}case F.document_did_open:{if(!r.unstable_didOpenDocument)return;let e=Hn.parse(t);return r.unstable_didOpenDocument(e)}case F.document_did_change:{if(!r.unstable_didChangeDocument)return;let e=Dr.parse(t);return r.unstable_didChangeDocument(e)}case F.document_did_close:{if(!r.unstable_didCloseDocument)return;let e=Bn.parse(t);return r.unstable_didCloseDocument(e)}case F.document_did_save:{if(!r.unstable_didSaveDocument)return;let e=Un.parse(t);return r.unstable_didSaveDocument(e)}case F.document_did_focus:{if(!r.unstable_didFocusDocument)return;let e=Vn.parse(t);return r.unstable_didFocusDocument(e)}case F.nes_accept:{if(!r.unstable_acceptNes)return;let e=Fn.parse(t);return r.unstable_acceptNes(e)}case F.nes_reject:{if(!r.unstable_rejectNes)return;let e=Jn.parse(t);return r.unstable_rejectNes(e)}default:if(r.extNotification)return r.extNotification(e,t);throw q.methodNotFound(e)}};this.connection=new yi(i,a,n)}async sessionUpdate(e){return await this.connection.sendNotification(I.session_update,e)}async requestPermission(e){return await this.connection.sendRequest(I.session_request_permission,e)}async readTextFile(e){return await this.connection.sendRequest(I.fs_read_text_file,e)}async writeTextFile(e){return await this.connection.sendRequest(I.fs_write_text_file,e)??{}}async createTerminal(e){return new vi((await this.connection.sendRequest(I.terminal_create,e)).terminalId,e.sessionId,this.connection)}async unstable_createElicitation(e){return await this.connection.sendRequest(I.elicitation_create,e)}async unstable_completeElicitation(e){return await this.connection.sendNotification(I.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}};gi=Symbol.asyncDispose;var vi=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(I.terminal_output,{sessionId:this.sessionId,terminalId:this.id})}async waitForExit(){return await this.connection.sendRequest(I.terminal_wait_for_exit,{sessionId:this.sessionId,terminalId:this.id})}async kill(){return await this.connection.sendRequest(I.terminal_kill,{sessionId:this.sessionId,terminalId:this.id})??{}}async release(){return await this.connection.sendRequest(I.terminal_release,{sessionId:this.sessionId,terminalId:this.id})??{}}async[gi](){await this.release()}},yi=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 q)return e.toResult();if(e instanceof w)return q.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 q.internalError(t?JSON.parse(t):{}).toResult()}catch{return q.internalError({details:t}).toResult()}}}async tryCallNotificationHandler(e,t){try{return await this.notificationHandler(e,t),{result:null}}catch(e){if(e instanceof q)return e.toResult();if(e instanceof w)return q.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 q.internalError(t?JSON.parse(t):{}).toResult()}catch{return q.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 q(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}},q=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}}};ae(),j(),ce(),_e(),le(),n(),v(),c(),o(),l(),_(),ye();function J(e,t){if(e)return t?De(e)?e:Oe(t,e):e}var bi=!(typeof process.geteuid==`function`?process.geteuid()===0:typeof process.getuid==`function`&&process.getuid()===0)||!!process.env.IS_SANDBOX,xi={auto:`auto`,default:`default`,acceptedits:`acceptEdits`,dontask:`dontAsk`,plan:`plan`,bypasspermissions:`bypassPermissions`,bypass:`bypassPermissions`};function Si(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=xi[n];if(!r)throw Error(`Invalid ${t}: ${e}.`);if(r===`bypassPermissions`&&!bi)throw Error(`Invalid ${t}: bypassPermissions is not available when running as root.`);return r}function Ci(e){let t=[...e.mcpServers??[]].sort((e,t)=>e.name.localeCompare(t.name));return JSON.stringify({cwd:e.cwd,mcpServers:t})}var wi=256;function Ti(e){let t=e.replace(/[\r\n]+/g,` `).replace(/\s+/g,` `).trim();return t.length<=wi?t:`${t.slice(0,wi-1)}…`}function Ei(e,t){if(!t)return e;let n=P.resolve(t),r=P.resolve(e);return r.startsWith(n+P.sep)||r===n?P.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}\n${e}${e.endsWith(`
4
4
  `)?``:`
@@ -9,5 +9,5 @@ import{n as e,t}from"./defineProperty-C-QyHrDq.js";import{$y as n,B as r,Cu as i
9
9
 
10
10
  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=N());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=N()),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:`
11
11
 
12
- 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=N();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:N()});for(let e of t)await n.sessionUpdate(e)}}}function Bi(e,t,n,i,a,o,s,c){return async(n,l,u,d,f,p)=>{let m=Hi(i);if(n.name===`ExitPlanMode`)return Vi(e,t,f,l,m,a,o,s,c);if(p!==void 0)return p;try{let e=await r(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,a),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}me(),xe(),h(),de(),e(),y(),p();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:`workmate`,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||ie(),n=await pe(t),r=await m({dir:t}),i=[];for(let e of r){if(!e.cwd||await pe(e.cwd)!==n)continue;let t=Ti(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 fe(e.sessionId);if(t)try{await Ee(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 q.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 f(e);n&&n.messages.length>0&&(t=i(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 Si(e,t)}function Ji(e){if(e!=null)try{return Si(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})}j();function ta(){return se().permissions?.defaultMode}async function na(e,t={}){ue();let n=t.sessionId??N(),r=e.cwd;M(n,oe()),ne(r);let i=process.cwd(),o=!1;try{process.chdir(r),o=!0}catch{}re(),ve();try{let i=ge(),o=a(i),c=e._meta,l=Yi(c,`permissionMode`),f=Ki(l?c?.permissionMode:void 0,l,ta()),p=$(this),m=this.conn,h=Bi(m,n,()=>this.sessions.get(n)?.modes.currentModeId??`default`,p,r,e=>{this.applySessionMode(n,e)},()=>this.sessions.get(n)?.appState.toolPermissionContext.isBypassPermissionsModeAvailable??!1),_=Xi(),v={...d(),toolPermissionContext:{...i,mode:f,isBypassPermissionsModeAvailable:_}},[y,b]=await Promise.all([s(r),g(r)]);v.agentDefinitions=b;let x=new be({cwd:r,tools:o,commands:y,mcpClients:[],agents:b.activeAgents,canUseTool:h,getAppState:()=>v,setAppState:e=>{let t=e(v);Object.assign(v,t)},readFileCache:new u(500,50*1024*1024),includePartialMessages:!0,replayUserMessages:!0,initialMessages:t.initialMessages}),S={currentModeId:f,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.`},..._?[{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`}]},C=Se(),w=he(),T={availableModels:C.map(e=>({modelId:String(e.value??``),name:e.label??String(e.value??``),description:e.description??void 0})),currentModelId:w};x.setModel(w);let E=Qi(S,T),ee={queryEngine:x,cancelled:!1,cancelGeneration:0,cwd:r,modes:S,models:T,configOptions:E,promptRunning:!1,pendingMessages:new Map,pendingQueue:[],pendingQueueHead:0,toolUseCache:{},clientCapabilities:p,appState:v,commands:y,sessionFingerprint:Ci({cwd:r,mcpServers:e.mcpServers})};return this.sessions.set(n,ee),{sessionId:n,modes:S,models:T,configOptions:E}}finally{o&&process.chdir(i)}}Object.assign(Z.prototype,{createSession:na}),y(),p(),j(),de();async function ra(e){let t=e.replay!==!1,n=this.sessions.get(e.sessionId);if(n){if(Ci({cwd:e.cwd,mcpServers:e.mcpServers})===n.sessionFingerprint){let r=await fe(e.sessionId,e.cwd);return M(e.sessionId,r?Ce(r.filePath):null),ne(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 fe(e.sessionId,e.cwd),a=r?Ce(r.filePath):null;M(e.sessionId,a),ne(e.cwd);let o;if(r)try{let t=await f(e.sessionId);t&&t.messages.length>0&&(o=i(t.messages))}catch(e){console.error(`[ACP] Failed to load session history:`,e)}let s=await this.createSession({cwd:e.cwd,mcpServers:e.mcpServers??[],_meta:e._meta},{sessionId:e.sessionId,initialMessages:o});if(t&&o&&o.length>0){let t=this.sessions.get(e.sessionId);t&&await zi(e.sessionId,o,Q(this),t.toolUseCache,$(this),t.cwd)}return{sessionId:s.sessionId,modes:s.modes,models:s.models,configOptions:s.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 f(e.sessionId);if(!t||t.messages.length===0)return;let n=i(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(`
13
- `)}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)}}j();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=N();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(),M(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=Ti(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}),le(),ye();function ha(e,t){let n=we.toWeb(e);return hi(Te.toWeb(t),n)}async function ga(){ue(),ve();let e=ha(process.stdin,process.stdout),t,n=new _i(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};
12
+ 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=N();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:N()});for(let e of t)await n.sessionUpdate(e)}}}function Bi(e,t,n,i,a,o,s,c){return async(n,l,u,d,f,p)=>{let m=Hi(i);if(n.name===`ExitPlanMode`)return Vi(e,t,f,l,m,a,o,s,c);if(p!==void 0)return p;try{let e=await r(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,a),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}me(),Se(),h(),de(),e(),y(),p();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:`workmate`,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||ie(),n=await pe(t),r=await m({dir:t}),i=[];for(let e of r){if(!e.cwd||await pe(e.cwd)!==n)continue;let t=Ti(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 fe(e.sessionId);if(t)try{await Ee(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 q.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 f(e);n&&n.messages.length>0&&(t=i(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 Si(e,t)}function Ji(e){if(e!=null)try{return Si(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})}j();function ta(){return se().permissions?.defaultMode}async function na(e,t={}){ue();let n=t.sessionId??N(),r=e.cwd;M(n,oe()),ne(r);let i=process.cwd(),o=!1;try{process.chdir(r),o=!0}catch{}re(),ve();try{let i=ge(),o=a(i),c=e._meta,l=Yi(c,`permissionMode`),f=Ki(l?c?.permissionMode:void 0,l,ta()),p=$(this),m=this.conn,h=Bi(m,n,()=>this.sessions.get(n)?.modes.currentModeId??`default`,p,r,e=>{this.applySessionMode(n,e)},()=>this.sessions.get(n)?.appState.toolPermissionContext.isBypassPermissionsModeAvailable??!1),_=Xi(),v={...d(),toolPermissionContext:{...i,mode:f,isBypassPermissionsModeAvailable:_}},[y,b]=await Promise.all([s(r),g(r)]);v.agentDefinitions=b;let x=new be({cwd:r,tools:o,commands:y,mcpClients:[],agents:b.activeAgents,canUseTool:h,getAppState:()=>v,setAppState:e=>{let t=e(v);Object.assign(v,t)},readFileCache:new u(500,50*1024*1024),includePartialMessages:!0,replayUserMessages:!0,initialMessages:t.initialMessages}),S={currentModeId:f,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.`},..._?[{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`}]},C=xe(),w=he(),T={availableModels:C.map(e=>({modelId:String(e.value??``),name:e.label??String(e.value??``),description:e.description??void 0})),currentModelId:w};x.setModel(w);let E=Qi(S,T),ee={queryEngine:x,cancelled:!1,cancelGeneration:0,cwd:r,modes:S,models:T,configOptions:E,promptRunning:!1,pendingMessages:new Map,pendingQueue:[],pendingQueueHead:0,toolUseCache:{},clientCapabilities:p,appState:v,commands:y,sessionFingerprint:Ci({cwd:r,mcpServers:e.mcpServers})};return this.sessions.set(n,ee),{sessionId:n,modes:S,models:T,configOptions:E}}finally{o&&process.chdir(i)}}Object.assign(Z.prototype,{createSession:na}),y(),p(),j(),de();async function ra(e){let t=e.replay!==!1,n=this.sessions.get(e.sessionId);if(n){if(Ci({cwd:e.cwd,mcpServers:e.mcpServers})===n.sessionFingerprint){let r=await fe(e.sessionId,e.cwd);return M(e.sessionId,r?Ce(r.filePath):null),ne(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 fe(e.sessionId,e.cwd),a=r?Ce(r.filePath):null;M(e.sessionId,a),ne(e.cwd);let o;if(r)try{let t=await f(e.sessionId);t&&t.messages.length>0&&(o=i(t.messages))}catch(e){console.error(`[ACP] Failed to load session history:`,e)}let s=await this.createSession({cwd:e.cwd,mcpServers:e.mcpServers??[],_meta:e._meta},{sessionId:e.sessionId,initialMessages:o});if(t&&o&&o.length>0){let t=this.sessions.get(e.sessionId);t&&await zi(e.sessionId,o,Q(this),t.toolUseCache,$(this),t.cwd)}return{sessionId:s.sessionId,modes:s.modes,models:s.models,configOptions:s.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 f(e.sessionId);if(!t||t.messages.length===0)return;let n=i(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(`
13
+ `)}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)}}j();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=N();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(),M(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 Work Mate 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=Ti(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}),le(),ye();function ha(e,t){let n=we.toWeb(e);return hi(Te.toWeb(t),n)}async function ga(){ue(),ve();let e=ha(process.stdin,process.stdout),t,n=new _i(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 +1 @@
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-DcaKZlRU.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,R as he,Wt as ge,pt as _e,tt as ve}from"./state-BPFYBqm1.js";import{C as ye,R as be,i as xe,x as Se}from"./debug-BQj6h99Q.js";import{Gt as Ce,Kt as C,Yt as we,qt as Te}from"./settings-aUygByiZ.js";import{d as Ee,m as De}from"./git-DplvjXEY.js";import{r as Oe,t as ke}from"./execFileNoThrow-DYm1GeGn.js";import{a as Ae,n as je,o as Me,r as Ne}from"./platform-DVeTi9mp.js";import{An as Pe,Bt as Fe,Ft as Ie,Gt as Le,_ as Re,jn as ze,u as Be}from"./model-CmDF8O9G.js";import{i as Ve,t as He}from"./genericProcessUtils-Bbcbi11g.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 Ce)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(),we(),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((()=>{xe(),be()}));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=ye(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(he()),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,skillMode:o,observerMode:s,...c}=e,l={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&&(l.remote_environment_type=r.remoteEnvironmentType),r.claudeCodeContainerId&&(l.claude_code_container_id=r.claudeCodeContainerId),r.claudeCodeRemoteSessionId&&(l.claude_code_remote_session_id=r.claudeCodeRemoteSessionId),r.tags&&(l.tags=r.tags.split(`,`).map(e=>e.trim()).filter(Boolean)),r.githubEventName&&(l.github_event_name=r.githubEventName),r.githubActionsRunnerEnvironment&&(l.github_actions_runner_environment=r.githubActionsRunnerEnvironment),r.githubActionsRunnerOs&&(l.github_actions_runner_os=r.githubActionsRunnerOs),r.githubActionRef&&(l.github_action_ref=r.githubActionRef),r.wslVersion&&(l.wsl_version=r.wslVersion),r.linuxDistroId&&(l.linux_distro_id=r.linuxDistroId),r.linuxDistroVersion&&(l.linux_distro_version=r.linuxDistroVersion),r.linuxKernel&&(l.linux_kernel=r.linuxKernel),r.vcs&&(l.vcs=r.vcs),r.versionBase&&(l.version_base=r.versionBase);let u={session_id:c.sessionId,model:c.model,user_type:c.userType,is_interactive:c.isInteractive===`true`,client_type:c.clientType};if(c.betas&&(u.betas=c.betas),c.entrypoint&&(u.entrypoint=c.entrypoint),c.agentSdkVersion&&(u.agent_sdk_version=c.agentSdkVersion),c.sweBenchRunId&&(u.swe_bench_run_id=c.sweBenchRunId),c.sweBenchInstanceId&&(u.swe_bench_instance_id=c.sweBenchInstanceId),c.sweBenchTaskId&&(u.swe_bench_task_id=c.sweBenchTaskId),c.agentId&&(u.agent_id=c.agentId),c.parentSessionId&&(u.parent_session_id=c.parentSessionId),c.agentType&&(u.agent_type=c.agentType),t.githubActionsMetadata){let e=t.githubActionsMetadata;l.github_actions_metadata={actor_id:e.actorId,repository_id:e.repositoryId,repository_owner_id:e.repositoryOwnerId}}let d;return(t.accountUuid||t.organizationUuid)&&(d={account_uuid:t.accountUuid,organization_uuid:t.organizationUuid}),{env:l,...i&&{process:Buffer.from(ye(i)).toString(`base64`)},...d&&{auth:d},core:u,additional:{...a&&{rh:a},...o&&{skill_mode:o},...s&&{observer_mode:s},...n}}}var Et,Dt,Ot,j,M,kt,At,jt,Mt,Nt,Pt,Ft,N,P,It=e((()=>{n(),we(),at(),ze(),Re(),ge(),i(),ct(),Fe(),De(),Me(),pt(),Se(),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.14`.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.14`,versionBase:Pt(),buildTime:`2026-08-13T18:38:19.460Z`,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
+ 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-DcaKZlRU.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,R as he,Wt as ge,pt as _e,tt as ve}from"./state-BPFYBqm1.js";import{C as ye,R as be,i as xe,x as Se}from"./debug-BQj6h99Q.js";import{Gt as Ce,Kt as C,Yt as we,qt as Te}from"./settings-CvhsRFaT.js";import{d as Ee,m as De}from"./git-DplvjXEY.js";import{r as Oe,t as ke}from"./execFileNoThrow-DYm1GeGn.js";import{a as Ae,n as je,o as Me,r as Ne}from"./platform-DVeTi9mp.js";import{Pt as Pe,Tn as Fe,_ as Ie,kt as Le,u as Re,wn as ze,zt as Be}from"./model-sviY1inu.js";import{i as Ve,t as He}from"./genericProcessUtils-Bbcbi11g.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 Ce)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(),we(),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((()=>{xe(),be()}));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=ye(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):Re(),n=typeof e.betas==`string`?e.betas:ze(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(he()),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(),...Le()&&{subscriptionType:Le()},...i&&{rh:i}}}function Tt(e,t,n={}){let{envContext:r,processMetrics:i,rh:a,skillMode:o,observerMode:s,...c}=e,l={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&&(l.remote_environment_type=r.remoteEnvironmentType),r.claudeCodeContainerId&&(l.claude_code_container_id=r.claudeCodeContainerId),r.claudeCodeRemoteSessionId&&(l.claude_code_remote_session_id=r.claudeCodeRemoteSessionId),r.tags&&(l.tags=r.tags.split(`,`).map(e=>e.trim()).filter(Boolean)),r.githubEventName&&(l.github_event_name=r.githubEventName),r.githubActionsRunnerEnvironment&&(l.github_actions_runner_environment=r.githubActionsRunnerEnvironment),r.githubActionsRunnerOs&&(l.github_actions_runner_os=r.githubActionsRunnerOs),r.githubActionRef&&(l.github_action_ref=r.githubActionRef),r.wslVersion&&(l.wsl_version=r.wslVersion),r.linuxDistroId&&(l.linux_distro_id=r.linuxDistroId),r.linuxDistroVersion&&(l.linux_distro_version=r.linuxDistroVersion),r.linuxKernel&&(l.linux_kernel=r.linuxKernel),r.vcs&&(l.vcs=r.vcs),r.versionBase&&(l.version_base=r.versionBase);let u={session_id:c.sessionId,model:c.model,user_type:c.userType,is_interactive:c.isInteractive===`true`,client_type:c.clientType};if(c.betas&&(u.betas=c.betas),c.entrypoint&&(u.entrypoint=c.entrypoint),c.agentSdkVersion&&(u.agent_sdk_version=c.agentSdkVersion),c.sweBenchRunId&&(u.swe_bench_run_id=c.sweBenchRunId),c.sweBenchInstanceId&&(u.swe_bench_instance_id=c.sweBenchInstanceId),c.sweBenchTaskId&&(u.swe_bench_task_id=c.sweBenchTaskId),c.agentId&&(u.agent_id=c.agentId),c.parentSessionId&&(u.parent_session_id=c.parentSessionId),c.agentType&&(u.agent_type=c.agentType),t.githubActionsMetadata){let e=t.githubActionsMetadata;l.github_actions_metadata={actor_id:e.actorId,repository_id:e.repositoryId,repository_owner_id:e.repositoryOwnerId}}let d;return(t.accountUuid||t.organizationUuid)&&(d={account_uuid:t.accountUuid,organization_uuid:t.organizationUuid}),{env:l,...i&&{process:Buffer.from(ye(i)).toString(`base64`)},...d&&{auth:d},core:u,additional:{...a&&{rh:a},...o&&{skill_mode:o},...s&&{observer_mode:s},...n}}}var Et,Dt,Ot,j,M,kt,At,jt,Mt,Nt,Pt,Ft,N,P,It=e((()=>{n(),we(),at(),Fe(),Ie(),ge(),i(),ct(),Pe(),De(),Me(),pt(),Se(),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.16`.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:Be(),version:`0.0.16`,versionBase:Pt(),buildTime:`2026-08-14T04:05:02.242Z`,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};
@@ -0,0 +1 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{$d as t,St as n,Zd as r,_T as i,gc as a,hc as o,vT as s,yt as c}from"./loadAgentsDir-PPiD2Mfq.js";import{t as l}from"./jsx-runtime-Bb4Xn-E0.js";import{n as u,t as d}from"./ExitFlow-B1zHTqQt.js";import{spawnSync as f}from"child_process";function p(){return s(g)??`Goodbye!`}async function m(e){if(a())return e(),f(`tmux`,[`detach-client`],{stdio:`ignore`}),null;let t=c()!==null;return t?(0,h.jsx)(d,{showWorktree:t,onDone:e,onCancel:()=>e()}):(e(p()),await r(0,`prompt_input_exit`),null)}var h,g;e((()=>{i(),u(),o(),t(),n(),h=l(),g=[`Goodbye!`,`See ya!`,`Bye!`,`Catch you later!`]}))();export{m as call};