@readmagic/workmate 0.0.13 → 0.0.15

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 (435) hide show
  1. package/dist/chunks/AddWorkspaceDirectory-DcVnvL_u.js +1 -0
  2. package/dist/chunks/AgentsMdExternalIncludesDialog-0Qdg3Rh7.js +1 -0
  3. package/dist/chunks/{AgentsMdExternalIncludesDialog-CH9x1Ngp.js → AgentsMdExternalIncludesDialog-D6DopTxc.js} +1 -1
  4. package/dist/chunks/App-BoI5EJry.js +1 -0
  5. package/dist/chunks/ApproveApiKey-BjlQDcMx.js +1 -0
  6. package/dist/chunks/ApproveApiKey-PWFcscjY.js +1 -0
  7. package/dist/chunks/BackgroundTasksDialog-ClSMkcGp.js +2 -0
  8. package/dist/chunks/BypassPermissionsModeDialog-KCZv-PXl.js +1 -0
  9. package/dist/chunks/DiffDialog-BGBkuVIn.js +6 -0
  10. package/dist/chunks/Doctor-CI04juFO.js +3 -0
  11. package/dist/chunks/Doctor-DCrqcW68.js +1 -0
  12. package/dist/chunks/ExitFlow-qrCDVA9i.js +2 -0
  13. package/dist/chunks/Grove-B-M3DWD3.js +11 -0
  14. package/dist/chunks/{HybridTransport-BQNLZNa_.js → HybridTransport-n5jji6SI.js} +2 -4
  15. package/dist/chunks/InvalidConfigDialog-By-j6fHE.js +1 -0
  16. package/dist/chunks/InvalidSettingsDialog-C_reeMzL.js +1 -0
  17. package/dist/chunks/MCPConnectionManager-BNG7iSlw.js +1 -0
  18. package/dist/chunks/MCPToolListView-jw0tITfc.js +1 -0
  19. package/dist/chunks/{McpParsingWarnings-CUx2zexI.js → McpParsingWarnings-BeZ3Bn8N.js} +1 -1
  20. package/dist/chunks/MessageSelector-Ci6N-gCw.js +3 -0
  21. package/dist/chunks/Messages-D6CRTH2m.js +10 -0
  22. package/dist/chunks/{Onboarding-t-P6Q5O6.js → Onboarding-DDkVEq-G.js} +1 -1
  23. package/dist/chunks/PermissionDialog-BPhvs5xH.js +1 -0
  24. package/dist/chunks/PressEnterToContinue-Dwoh6CaW.js +1 -0
  25. package/dist/chunks/{PromptInputFooterSuggestions-R12fbdmp.js → PromptInputFooterSuggestions-BlhZuQ5F.js} +1 -1
  26. package/dist/chunks/PromptInputHelpMenu-kKyPIMau.js +1 -0
  27. package/dist/chunks/QueryEngine-DXpS0Ytq.js +1 -0
  28. package/dist/chunks/REPL-D1BCm7cR.js +128 -0
  29. package/dist/chunks/REPL-JQgCrSEv.js +1 -0
  30. package/dist/chunks/RemoteSessionManager-mWVrdNfS.js +2 -0
  31. package/dist/chunks/ResumeConversation-BzTn_1jS.js +1 -0
  32. package/dist/chunks/SSETransport-D86IVNn1.js +2 -0
  33. package/dist/chunks/{SearchBox-C9vUA4IM.js → SearchBox-CwwV0W-w.js} +1 -1
  34. package/dist/chunks/SearchExtraToolsTool-BXIja1MR.js +1 -0
  35. package/dist/chunks/Settings-D_i8HzEW.js +2 -0
  36. package/dist/chunks/{TeleportProgress-3hmIApkj.js → TeleportProgress-CW8mLRy2.js} +1 -1
  37. package/dist/chunks/{TeleportRepoMismatchDialog-BA1a66RK.js → TeleportRepoMismatchDialog-DZD32R-l.js} +1 -1
  38. package/dist/chunks/TeleportResumeWrapper-BhuUE1aq.js +1 -0
  39. package/dist/chunks/ThemePicker-ByQZgIbH.js +1 -0
  40. package/dist/chunks/{TrustDialog-Dpk03V1Y.js → TrustDialog-BzwibD_8.js} +1 -1
  41. package/dist/chunks/ValidationErrorsList-Cuq6W2yc.js +2 -0
  42. package/dist/chunks/add-dir-BQ-ljgk6.js +1 -0
  43. package/dist/chunks/{agentDisplay-D7bdOOG7.js → agentDisplay-tRprY4gB.js} +1 -1
  44. package/dist/chunks/agents-DMyQUXwl.js +101 -0
  45. package/dist/chunks/{agents-22wiC58F.js → agents-Dq4BCf0H.js} +1 -1
  46. package/dist/chunks/allErrors-CQWZ6BPw.js +1 -0
  47. package/dist/chunks/{api-f3GN2I_J.js → api-ClAyS7cQ.js} +1 -1
  48. package/dist/chunks/api-CpD5jeKe.js +1 -0
  49. package/dist/chunks/attributionHooks-C0aXyx9L.js +1 -0
  50. package/dist/chunks/{auth-Czy7GoRh.js → auth-CWAvPfX7.js} +7 -12
  51. package/dist/chunks/auth-DG5bkWDc.js +1 -0
  52. package/dist/chunks/auth-DuHfQBuH.js +1 -0
  53. package/dist/chunks/backgroundHousekeeping-kf_v7Vfr.js +1 -0
  54. package/dist/chunks/backgroundHousekeeping-rzQFJiND.js +17 -0
  55. package/dist/chunks/{banner-BcAM7iSx.js → banner-HfMnBd03.js} +2 -2
  56. package/dist/chunks/{bg-Ci7pG4eo.js → bg-DltfF1_K.js} +2 -2
  57. package/dist/chunks/branch-BWbCrXBJ.js +2 -0
  58. package/dist/chunks/{break-cache-4rlQORVk.js → break-cache-Cd1yQ-0h.js} +2 -3
  59. package/dist/chunks/bridgeConfig-CABsoOum.js +1 -0
  60. package/dist/chunks/{bridgeConfig-B80T_lw7.js → bridgeConfig-CPHAyzdg.js} +1 -1
  61. package/dist/chunks/{bridgeMessaging-DyvHd16Z.js → bridgeMessaging-vR7uQXB9.js} +1 -1
  62. package/dist/chunks/{bridgePointer-DHWK3LEe.js → bridgePointer-CiHy2tTN.js} +1 -1
  63. package/dist/chunks/bridgeStatusUtil-CHTx7XwJ.js +1 -0
  64. package/dist/chunks/btw-IGcgP-Qq.js +1 -0
  65. package/dist/chunks/caches-Dj1YhqrG.js +1 -0
  66. package/dist/chunks/caches-FP8mGB4k.js +1 -0
  67. package/dist/chunks/{capacityWake-ByL6fM6I.js → capacityWake-LRiPhPeM.js} +1 -1
  68. package/dist/chunks/{ccrClient-BALhzhPF.js → ccrClient--8aPutWE.js} +1 -1
  69. package/dist/chunks/claudeDesktop-CB3UCt7U.js +1 -0
  70. package/dist/chunks/{clear-B_yVyJXP.js → clear-CF-FZwpe.js} +1 -1
  71. package/dist/chunks/{cliLaunch-OPOtzhvA.js → cliLaunch-xIVvtPZy.js} +1 -1
  72. package/dist/chunks/{client-BMA05FW8.js → client-B7WkO81L.js} +1 -1
  73. package/dist/chunks/client-BCzhAEd0.js +1 -0
  74. package/dist/chunks/client-BU7upHOb.js +1 -0
  75. package/dist/chunks/commands-Cr1p7OPH.js +1 -0
  76. package/dist/chunks/compact-BrJGpEFZ.js +2 -0
  77. package/dist/chunks/{config-9rLTDOYW.js → config-BSkuQZNf.js} +1 -1
  78. package/dist/chunks/config-BohF3_IV.js +1 -0
  79. package/dist/chunks/{config-DMKtiMzJ.js → config-D78R57VA.js} +1 -1
  80. package/dist/chunks/context-DADnwl4t.js +1 -0
  81. package/dist/chunks/context-noninteractive-BAbzwNxu.js +1 -0
  82. package/dist/chunks/{context-noninteractive-CHzerxnH.js → context-noninteractive-kACWzgS1.js} +2 -2
  83. package/dist/chunks/conversation-C8w1DtXk.js +1 -0
  84. package/dist/chunks/conversation-Ds7zRD0x.js +1 -0
  85. package/dist/chunks/{createSSHSession-XkHMiGRN.js → createSSHSession-B71Plec6.js} +3 -4
  86. package/dist/chunks/{createSession-BNGm9fL4.js → createSession-BJeDECzt.js} +1 -1
  87. package/dist/chunks/createSession-Bozo4Bu8.js +1 -0
  88. package/dist/chunks/crossProjectResume-B1I6YzXr.js +40 -0
  89. package/dist/chunks/{datadog-3WUWcCFn.js → datadog-C9uqPA6N.js} +1 -1
  90. package/dist/chunks/{debug-Dr1SjdXn.js → debug-BQj6h99Q.js} +1 -1
  91. package/dist/chunks/debugUtils-B86DM1Sp.js +1 -0
  92. package/dist/chunks/{detached-CqfQYVOi.js → detached--wGwkuHX.js} +1 -2
  93. package/dist/chunks/{detectRepository-CMEkS5_2.js → detectRepository-Qy3zKoyn.js} +1 -1
  94. package/dist/chunks/detectRepository-tRUoPOKy.js +1 -0
  95. package/dist/chunks/{diff-CKlLimGq.js → diff-CzChvQyK.js} +1 -1
  96. package/dist/chunks/directoryCompletion-i2oWpaUe.js +1 -0
  97. package/dist/chunks/doctor-DdvdGkNX.js +1 -0
  98. package/dist/chunks/{entry-DCbq734V.js → entry-BoL8sy1Y.js} +5 -6
  99. package/dist/chunks/esm-DtcV71xh.js +1 -0
  100. package/dist/chunks/{execFileNoThrow-mXq4K0rl.js → execFileNoThrow-DYm1GeGn.js} +1 -1
  101. package/dist/chunks/{execSyncWrapper-Ne33rRiD.js → execSyncWrapper-CqvQqke-.js} +1 -1
  102. package/dist/chunks/exit-Af27f74w.js +1 -0
  103. package/dist/chunks/exit-s9XGerrH.js +1 -0
  104. package/dist/chunks/{extraUsage-C86bZVgt.js → extraUsage-DsFwXMAj.js} +1 -1
  105. package/dist/chunks/extractMemories-B1KbTMY0.js +1 -0
  106. package/dist/chunks/fast-BGU8p2uY.js +1 -0
  107. package/dist/chunks/fast-CuUjONVV.js +1 -0
  108. package/dist/chunks/{fileSuggestions-BalHmi1-.js → fileSuggestions-DU7gmksK.js} +2 -2
  109. package/dist/chunks/{firstPartyEventLogger-1RTgXHSz.js → firstPartyEventLogger-7pAyUdbp.js} +3 -5
  110. package/dist/chunks/firstPartyEventLogger-sMeCTEUW.js +1 -0
  111. package/dist/chunks/flushGate-4DfYr-Ru.js +1 -0
  112. package/dist/chunks/{fpsMetrics-DffAomdg.js → fpsMetrics-Dk_pnSHJ.js} +1 -1
  113. package/dist/chunks/gemini-Cll4fVQn.js +1 -0
  114. package/dist/chunks/generateSessionName-BgGMwpps.js +1 -0
  115. package/dist/chunks/{genericProcessUtils-Dc1pfb7J.js → genericProcessUtils-Bbcbi11g.js} +1 -1
  116. package/dist/chunks/git-BaSq69E7.js +1 -0
  117. package/dist/chunks/{git-CoQQ6YEf.js → git-DplvjXEY.js} +2 -3
  118. package/dist/chunks/{githubRepoPathMapping-CmpEaQoo.js → githubRepoPathMapping-Px3_GeD1.js} +1 -1
  119. package/dist/chunks/goal-D4E2WQVn.js +3 -0
  120. package/dist/chunks/grok-HF1PHxXb.js +1 -0
  121. package/dist/chunks/{grove-b9gGKgu4.js → grove-Bck1zFaD.js} +2 -2
  122. package/dist/chunks/help-DJp61Job.js +1 -0
  123. package/dist/chunks/{hooks-C-QMGvCg.js → hooks-CJ17byYD.js} +7 -7
  124. package/dist/chunks/hooks-CjR3Eq0Z.js +1 -0
  125. package/dist/chunks/initReplBridge-D09JEKHt.js +1 -0
  126. package/dist/chunks/install-Dd5fw0cA.js +1 -0
  127. package/dist/chunks/{instrumentation-DQ705pC7.js → instrumentation-jsPu6qqs.js} +4 -4
  128. package/dist/chunks/{job-BaMT6Lb2.js → job-BHhkQbvu.js} +1 -1
  129. package/dist/chunks/{jwtUtils-FQWtM6iM.js → jwtUtils-YCoZL0FW.js} +1 -1
  130. package/dist/chunks/keybindings-Ch5lzNB8.js +1 -0
  131. package/dist/chunks/{launchLocalMemory-CtZrkmaw.js → launchLocalMemory-DsaijVcO.js} +2 -2
  132. package/dist/chunks/launchOnboarding-DHOylaqn.js +8 -0
  133. package/dist/chunks/loadAgentsDir-8FioUEwX.js +1 -0
  134. package/dist/chunks/{loadAgentsDir-mcRW90aq.js → loadAgentsDir-CwEfQDOw.js} +661 -698
  135. package/dist/chunks/loadPluginHooks-C-Yk5KlI.js +1 -0
  136. package/dist/chunks/localSearch-BEnlgSB7.js +1 -0
  137. package/dist/chunks/localSearch-LcgRjjl3.js +1 -0
  138. package/dist/chunks/{log-27kCA_9u.js → log-BlJ7CcKG.js} +1 -1
  139. package/dist/chunks/{logoV2Utils--8OUQQPd.js → logoV2Utils-DG9GwFjl.js} +1 -1
  140. package/dist/chunks/{magicDocs-26J_l1De.js → magicDocs-qGHR3Cqh.js} +2 -2
  141. package/dist/chunks/main-CBVQ8bRm.js +356 -0
  142. package/dist/chunks/{main-CGLCy2pM.js → main-Zh18lf2J.js} +2 -2
  143. package/dist/chunks/{managedEnv-Ds6MlFQE.js → managedEnv-3MbOWrVs.js} +1 -1
  144. package/dist/chunks/managedEnv-B4YV3A_y.js +1 -0
  145. package/dist/chunks/{mappers-DwZw084m.js → mappers-CdY45PDA.js} +1 -1
  146. package/dist/chunks/mcp-BA8XQ6h1.js +1 -0
  147. package/dist/chunks/mcp-DI8pGrqi.js +2 -0
  148. package/dist/chunks/mcp-DvY_FibT.js +6 -0
  149. package/dist/chunks/{memoize-Co4vS6UF.js → memoize-_2f7NWDv.js} +1 -1
  150. package/dist/chunks/memory-C2U7CCmM.js +1 -0
  151. package/dist/chunks/{modalContext-CUThy6Ph.js → modalContext-wY9CeN4G.js} +1 -1
  152. package/dist/chunks/{mode-B80CHkqo.js → mode-ByV6NqmB.js} +2 -2
  153. package/dist/chunks/model-C73ETGu9.js +1 -0
  154. package/dist/chunks/model-CVG_RRTy.js +1 -0
  155. package/dist/chunks/model-CeG-iOKF.js +1 -0
  156. package/dist/chunks/modelOptions-A5jrCUBp.js +1 -0
  157. package/dist/chunks/nativeInstaller-CXFD8LDV.js +1 -0
  158. package/dist/chunks/{omit-KEhe84f4.js → omit-B65XeX8r.js} +1 -1
  159. package/dist/chunks/{onChangeAppState-Dq1tIEJI.js → onChangeAppState-EtUxsgYz.js} +1 -1
  160. package/dist/chunks/openai-Dx5mvMjY.js +10 -0
  161. package/dist/chunks/{panel-CoF2a-h4.js → panel-Bg_0PHE6.js} +1 -1
  162. package/dist/chunks/{parser-CUUiH40T.js → parser-a2S_eFyE.js} +1 -1
  163. package/dist/chunks/parser-x-w3ikxt.js +1 -0
  164. package/dist/chunks/{partition-DeT341qu.js → partition-8vZDG3rY.js} +1 -1
  165. package/dist/chunks/permissions-CJUBfBTr.js +3 -0
  166. package/dist/chunks/pidLock-tjm2n1Nd.js +3 -0
  167. package/dist/chunks/plan-eFur8bdH.js +1 -0
  168. package/dist/chunks/{platform-Dg1c9F_1.js → platform-DVeTi9mp.js} +2 -2
  169. package/dist/chunks/plugin-fYLRLdOY.js +17 -0
  170. package/dist/chunks/pluginAutoupdate-B4w7SSYc.js +1 -0
  171. package/dist/chunks/{pluginBlocklist-BfoLN9a-.js → pluginBlocklist-CMwb7gmY.js} +1 -1
  172. package/dist/chunks/{pluginCliCommands-Bc2Iybhz.js → pluginCliCommands-3YCj7Y3Q.js} +1 -1
  173. package/dist/chunks/{pluginFlagging-Cr0d0hBA.js → pluginFlagging-srvq9H7p.js} +1 -1
  174. package/dist/chunks/pluginOperations-C7BCR7pw.js +2 -0
  175. package/dist/chunks/{pluginStartupCheck-DiCDQQlr.js → pluginStartupCheck-BLc0U7W7.js} +1 -1
  176. package/dist/chunks/pluginStartupCheck-nzVDPI1k.js +1 -0
  177. package/dist/chunks/plugins-CPtmmDDi.js +4 -0
  178. package/dist/chunks/poorMode-DD88nPJ4.js +1 -0
  179. package/dist/chunks/{poorMode-DxgO_bUb.js → poorMode-wm2WkPF0.js} +1 -1
  180. package/dist/chunks/print-BCud0ukQ.js +14 -0
  181. package/dist/chunks/processBashCommand-C9-FonuX.js +1 -0
  182. package/dist/chunks/processSlashCommand-Bi8_1MRC.js +5 -0
  183. package/dist/chunks/{prompt-DIlq8NTy.js → prompt-Bm2EEG4F.js} +21 -23
  184. package/dist/chunks/prompt-CX_v9F3s.js +1 -0
  185. package/dist/chunks/prompt-V0WQJrkO2.js +1 -0
  186. package/dist/chunks/{promptEditor-BILqOGl1.js → promptEditor-DQ9fpdQD.js} +3 -3
  187. package/dist/chunks/protocolHandler--eQQuSyx.js +13 -0
  188. package/dist/chunks/{proxy-BEKNaTXI.js → proxy-C0j74LqT.js} +1 -1
  189. package/dist/chunks/reconciler-DgQ4y1Vn.js +1 -0
  190. package/dist/chunks/refresh-CayVRWUY.js +1 -0
  191. package/dist/chunks/registerProtocol-DrWIX3Lb.js +1 -0
  192. package/dist/chunks/{reload-plugins-CGb0HTsH.js → reload-plugins-6xcH3dLg.js} +1 -1
  193. package/dist/chunks/{remoteBridgeCore-BmteXmI9.js → remoteBridgeCore-BnZYGaMH.js} +1 -1
  194. package/dist/chunks/{remoteManagedSettings-CwDGxL5p.js → remoteManagedSettings-CfFmrRze.js} +1 -1
  195. package/dist/chunks/rename-mDtCTbnD.js +1 -0
  196. package/dist/chunks/{renderOptions-45A-EdsK.js → renderOptions-CkqTbz6d.js} +1 -1
  197. package/dist/chunks/resume-DRvz4QFs.js +2 -0
  198. package/dist/chunks/ripgrep-Di-2j8Ws.js +1 -0
  199. package/dist/chunks/{ripgrep-DQ_ILUJV.js → ripgrep-DsLUmulz.js} +2 -2
  200. package/dist/chunks/{runtimeObserver-CtNY8Al2.js → runtimeObserver-Ba6SM-sI.js} +1 -1
  201. package/dist/chunks/{runtimeObserver-4ZqaCXYy.js → runtimeObserver-Dt5sGJVb.js} +4 -4
  202. package/dist/chunks/sandbox-adapter-Cmrd6tBj.js +1 -0
  203. package/dist/chunks/sandbox-toggle-DKcw3SbO.js +1 -0
  204. package/dist/chunks/searchExtraTools-DIgC0CFB.js +1 -0
  205. package/dist/chunks/{session-wb6X4Wrq.js → session-COVyD8UU.js} +2 -2
  206. package/dist/chunks/sessionFileAccessHooks-yAPDTrbm.js +1 -0
  207. package/dist/chunks/{sessionIdCompat-DMayYBrf.js → sessionIdCompat-Dgp6PW_1.js} +1 -1
  208. package/dist/chunks/sessionObserver-BizdPx8P.js +1 -0
  209. package/dist/chunks/{sessionObserver-BJQ5hwjU.js → sessionObserver-iAgSetlC.js} +2 -2
  210. package/dist/chunks/sessionState-zhvcDpb2.js +11 -0
  211. package/dist/chunks/sessionStorage-LMY409Ji.js +1 -0
  212. package/dist/chunks/sessionStoragePortable-x0Yn02-G.js +3 -0
  213. package/dist/chunks/{sessionTitle-Cbzrb9jT.js → sessionTitle-QPRly1tZ.js} +2 -2
  214. package/dist/chunks/{sessionTracing-CEsm8pZL.js → sessionTracing-C4uqAdud.js} +2 -2
  215. package/dist/chunks/settings-BgHApyGL.js +1 -0
  216. package/dist/chunks/settings-CvhsRFaT.js +19 -0
  217. package/dist/chunks/settingsSync-BGo6dHJo.js +1 -0
  218. package/dist/chunks/setup-Bjw5VS6x.js +3 -0
  219. package/dist/chunks/{shadowedRuleDetection-D5X5fhzj.js → shadowedRuleDetection-CzRAzcC1.js} +1 -1
  220. package/dist/chunks/{shellQuote-C_I6DHLV.js → shellQuote-D3Ocv_U-.js} +1 -1
  221. package/dist/chunks/{sideQuestion-BHRtwhyj.js → sideQuestion-oIYrx5ar.js} +3 -3
  222. package/dist/chunks/sinks-Bje3hCkR.js +1 -0
  223. package/dist/chunks/sinks-FaljTZ-c.js +1 -0
  224. package/dist/chunks/skillChangeDetector-v6mAYzXX.js +1 -0
  225. package/dist/chunks/{skillGapStore-BjQSSz2E.js → skillGapStore-CJjt3IW7.js} +2 -2
  226. package/dist/chunks/{skillLifecycle-Sp8strFv.js → skillLifecycle-BsgH84vl.js} +2 -2
  227. package/dist/chunks/{skillSearchPanel-3sYRez_Q.js → skillSearchPanel-CneXymsb.js} +4 -4
  228. package/dist/chunks/skills-DZRBy7vT.js +1 -0
  229. package/dist/chunks/{src-r6ZFgWPx2.js → src-D3yIF9I42.js} +1 -1
  230. package/dist/chunks/src-DL3w8VPk2.js +51 -0
  231. package/dist/chunks/{startupProfiler-Dc5r6LgE.js → startupProfiler-2sjXZkIP.js} +1 -1
  232. package/dist/chunks/startupProfiler-B2fyaBEa.js +1 -0
  233. package/dist/chunks/{staticRender-DrU6eWoq.js → staticRender-D9AbnQFr.js} +1 -1
  234. package/dist/chunks/{stats-BkadEKa-.js → stats-Dq-5qizS.js} +1 -1
  235. package/dist/chunks/status-BP_R8051.js +2 -0
  236. package/dist/chunks/status-CZYD3NGb.js +1 -0
  237. package/dist/chunks/statusNoticeHelpers-ODrnrLAZ.js +1 -0
  238. package/dist/chunks/{stringUtils-Df-Lnjxd.js → stringUtils-BjnclTLB.js} +3 -3
  239. package/dist/chunks/{switcher-uoQMHmEZ.js → switcher-BkGOeIzI.js} +1 -1
  240. package/dist/chunks/switcher-DwKN9daN.js +1 -0
  241. package/dist/chunks/{syncCache-BooMjgU6.js → syncCache-CpmpvjfC.js} +1 -1
  242. package/dist/chunks/tasks-CIUuwrX4.js +1 -0
  243. package/dist/chunks/teleport-IzyDplC7.js +1 -0
  244. package/dist/chunks/{templateJobs-BYYfF4m5.js → templateJobs-De57J461.js} +1 -3
  245. package/dist/chunks/{terminalSetup-CbXKCpWM.js → terminalSetup-DDvQ0K5e.js} +1 -1
  246. package/dist/chunks/terminalSetup-JJiXmszo.js +32 -0
  247. package/dist/chunks/theme-Nwii7354.js +1 -0
  248. package/dist/chunks/{tmux-d3cNCIZA.js → tmux-g0cQ0Buz.js} +1 -1
  249. package/dist/chunks/{toolEventObserver-BFEl47bq.js → toolEventObserver-Cq-uBb0-.js} +1 -1
  250. package/dist/chunks/toolPool-BBU4ll_p.js +1 -0
  251. package/dist/chunks/trustedDevice-BKzkA7fq.js +1 -0
  252. package/dist/chunks/{trustedDevice-BLiKbGpG.js → trustedDevice-DWZxDUxS.js} +1 -1
  253. package/dist/chunks/{types-BJ7qTz75.js → types-BomO8WUz.js} +1 -1
  254. package/dist/chunks/{udsClient-CF8BmZgN.js → udsClient-DSvRPCvR.js} +1 -1
  255. package/dist/chunks/upstreamproxy-DYoLvdM9.js +10 -0
  256. package/dist/chunks/useExitOnCtrlCDWithKeybindings-D48aDPG9.js +1 -0
  257. package/dist/chunks/useMainLoopModel-89eUU13X.js +1 -0
  258. package/dist/chunks/useManagePlugins-EqoQELMT.js +1 -0
  259. package/dist/chunks/useMergedTools-BJ4L9QSK.js +1 -0
  260. package/dist/chunks/{useSearchInput-KFKh2ozY.js → useSearchInput-DkVER3cm.js} +1 -1
  261. package/dist/chunks/useSettingsErrors-D3MlQ1GF.js +1 -0
  262. package/dist/chunks/{userAgent-DUrr02yh.js → userAgent-aoe_xVAb.js} +1 -1
  263. package/dist/chunks/util-g-5UX5gH.js +1 -0
  264. package/dist/chunks/validatePlugin-CSE8zjZn.js +1 -0
  265. package/dist/chunks/{vim-C4Hs5U2h.js → vim-s-wmybpU.js} +1 -1
  266. package/dist/chunks/{which-mplwBbc0.js → which-BR8YVCCW.js} +1 -1
  267. package/dist/chunks/{windowsPaths-C7Mdo9aU.js → windowsPaths-BmXyrasP.js} +1 -1
  268. package/dist/chunks/windowsPaths-BybjGW7e.js +1 -0
  269. package/dist/chunks/{workSecret-XLodD7tw.js → workSecret-BUd8cQ6-.js} +1 -1
  270. package/dist/chunks/workerRegistry-DGwy0YHB.js +2 -0
  271. package/dist/chunks/worktree-jjuORs7p.js +1 -0
  272. package/dist/cli.js +1 -1
  273. package/package.json +1 -1
  274. package/dist/chunks/AddWorkspaceDirectory-BzNj9rS6.js +0 -1
  275. package/dist/chunks/AgentsMdExternalIncludesDialog-CDZPR488.js +0 -1
  276. package/dist/chunks/App-D-bYAYAl.js +0 -1
  277. package/dist/chunks/ApproveApiKey-BEGV9Zj9.js +0 -1
  278. package/dist/chunks/ApproveApiKey-CjacpIqq.js +0 -1
  279. package/dist/chunks/BackgroundTasksDialog-A9hw_SV0.js +0 -2
  280. package/dist/chunks/BypassPermissionsModeDialog-B0BizN_J.js +0 -1
  281. package/dist/chunks/DiffDialog-mQ-5_TSv.js +0 -6
  282. package/dist/chunks/Doctor-BC6IuQhd.js +0 -3
  283. package/dist/chunks/Doctor-i_5_AQd-.js +0 -1
  284. package/dist/chunks/ExitFlow-Bu2cVGpC.js +0 -2
  285. package/dist/chunks/Grove-D0nn8zOV.js +0 -11
  286. package/dist/chunks/InvalidConfigDialog-C5CIiSIE.js +0 -1
  287. package/dist/chunks/InvalidSettingsDialog-Dq7hKXcO.js +0 -1
  288. package/dist/chunks/MCPConnectionManager-aDDsYkGM.js +0 -1
  289. package/dist/chunks/MCPToolListView-Cr0MDkzT.js +0 -1
  290. package/dist/chunks/MessageSelector-DwGOWKKL.js +0 -3
  291. package/dist/chunks/Messages-C1jh4ixt.js +0 -11
  292. package/dist/chunks/PermissionDialog-Cb3z8OUP.js +0 -1
  293. package/dist/chunks/PressEnterToContinue-Dq0Imo9c.js +0 -1
  294. package/dist/chunks/PromptInputHelpMenu-BgADIzRj.js +0 -1
  295. package/dist/chunks/QueryEngine-HlLQJmsd.js +0 -1
  296. package/dist/chunks/REPL-Rs_JQkDc.js +0 -1
  297. package/dist/chunks/REPL-VKAmKkII.js +0 -133
  298. package/dist/chunks/RemoteSessionManager-BbgXeM-t.js +0 -2
  299. package/dist/chunks/ResumeConversation-66zbx12g.js +0 -1
  300. package/dist/chunks/SSETransport-BBQkdn4e.js +0 -4
  301. package/dist/chunks/SearchExtraToolsTool-Bq87I_vu.js +0 -1
  302. package/dist/chunks/Settings-BKdLcyXe.js +0 -2
  303. package/dist/chunks/TeleportResumeWrapper-BT4O-Wsi.js +0 -1
  304. package/dist/chunks/ThemePicker-DUlhcoso.js +0 -1
  305. package/dist/chunks/ValidationErrorsList-DSSUWdgd.js +0 -2
  306. package/dist/chunks/add-dir-BUr0z-VU.js +0 -1
  307. package/dist/chunks/agents-8ELI8RJo.js +0 -103
  308. package/dist/chunks/allErrors-C1eMbHSv.js +0 -1
  309. package/dist/chunks/api-DgjIFdMn.js +0 -1
  310. package/dist/chunks/attributionHooks-CUAoGkU6.js +0 -1
  311. package/dist/chunks/auth-B73a4Cob.js +0 -1
  312. package/dist/chunks/auth-D_0waidQ.js +0 -1
  313. package/dist/chunks/autoModeDenials-BxNzGJdR.js +0 -1
  314. package/dist/chunks/backgroundHousekeeping-C_ArdTFX.js +0 -17
  315. package/dist/chunks/backgroundHousekeeping-YJhvZ0dh.js +0 -1
  316. package/dist/chunks/branch-bb4-bErF.js +0 -3
  317. package/dist/chunks/bridgeConfig-DywkIo_k.js +0 -1
  318. package/dist/chunks/bridgeStatusUtil-DStiD05t.js +0 -1
  319. package/dist/chunks/btw-BRmV51bR.js +0 -1
  320. package/dist/chunks/caches-C5DIVdvI.js +0 -1
  321. package/dist/chunks/caches-zDZEgNKq.js +0 -1
  322. package/dist/chunks/claudeDesktop-Ct_hyICL.js +0 -1
  323. package/dist/chunks/client-7lIxWcaM.js +0 -1
  324. package/dist/chunks/client-DVg8PpFX.js +0 -1
  325. package/dist/chunks/commands-ByFXqW43.js +0 -1
  326. package/dist/chunks/compact-BUShp2eQ.js +0 -2
  327. package/dist/chunks/config-BwHNU_pI.js +0 -1
  328. package/dist/chunks/context-6Pk3iVhh.js +0 -1
  329. package/dist/chunks/context-noninteractive-DFwRQyFE.js +0 -1
  330. package/dist/chunks/conversation-5zb5XkSA.js +0 -1
  331. package/dist/chunks/conversation-JP2ZXrwu.js +0 -1
  332. package/dist/chunks/createSession-VTqzWAu6.js +0 -1
  333. package/dist/chunks/crossProjectResume-DxgQVYSi.js +0 -40
  334. package/dist/chunks/debugUtils-cK-iOsEV.js +0 -1
  335. package/dist/chunks/detectRepository-BsKZDRoI.js +0 -1
  336. package/dist/chunks/directoryCompletion-ByBTSuLu.js +0 -1
  337. package/dist/chunks/doctor-Bvx0u0sO.js +0 -1
  338. package/dist/chunks/esm-CtQkOk5D.js +0 -1
  339. package/dist/chunks/exit-BOhGfSlm.js +0 -2
  340. package/dist/chunks/exit-DTsz5Lcb.js +0 -1
  341. package/dist/chunks/extractMemories-6OnMgL2S.js +0 -1
  342. package/dist/chunks/fast-B2ziqJEA.js +0 -1
  343. package/dist/chunks/fast-BkhjaTkZ.js +0 -1
  344. package/dist/chunks/firstPartyEventLogger-CXMzhLrF.js +0 -1
  345. package/dist/chunks/flushGate-DWL05x7v.js +0 -1
  346. package/dist/chunks/gemini-BLpLJyli.js +0 -1
  347. package/dist/chunks/generateSessionName-CdbMksHi.js +0 -1
  348. package/dist/chunks/git-Bs1vtuvX.js +0 -1
  349. package/dist/chunks/goal-V3qix-i1.js +0 -3
  350. package/dist/chunks/grok-BLLATotv.js +0 -1
  351. package/dist/chunks/help-BR7UEr5R.js +0 -1
  352. package/dist/chunks/hooks-D6wtd0Qq.js +0 -1
  353. package/dist/chunks/initReplBridge-DyScxedy.js +0 -1
  354. package/dist/chunks/install-DGH_bjUh.js +0 -1
  355. package/dist/chunks/keybindings-CG292HS1.js +0 -2
  356. package/dist/chunks/launchOnboarding-CyOtdZkT.js +0 -8
  357. package/dist/chunks/loadAgentsDir-4UC4yLg1.js +0 -1
  358. package/dist/chunks/loadPluginHooks-CWI0RMUx.js +0 -1
  359. package/dist/chunks/localSearch-CCCDKpYx.js +0 -1
  360. package/dist/chunks/localSearch-D4hVR7-d.js +0 -1
  361. package/dist/chunks/main-DUjtDK1Q.js +0 -513
  362. package/dist/chunks/managedEnv-BuCurT_S.js +0 -1
  363. package/dist/chunks/mcp-CEKR7PjL.js +0 -6
  364. package/dist/chunks/mcp-DCAf2hHD.js +0 -1
  365. package/dist/chunks/mcp-mCuc8dNe.js +0 -2
  366. package/dist/chunks/memory-B5SkpC7u.js +0 -1
  367. package/dist/chunks/model-BqaneI4D.js +0 -1
  368. package/dist/chunks/model-C29_32BD.js +0 -1
  369. package/dist/chunks/model-NG8fvuT2.js +0 -1
  370. package/dist/chunks/modelOptions-CiZgZxZC.js +0 -1
  371. package/dist/chunks/nativeInstaller-DqbEfGSX.js +0 -1
  372. package/dist/chunks/openai-BvnsYTpQ.js +0 -10
  373. package/dist/chunks/parser-B2PlJg4C.js +0 -1
  374. package/dist/chunks/permissions-BPpeHxpk.js +0 -3
  375. package/dist/chunks/pidLock-DQGDoFQP.js +0 -3
  376. package/dist/chunks/plan-BRiC5ujG.js +0 -1
  377. package/dist/chunks/plugin-Dcg_GGR9.js +0 -17
  378. package/dist/chunks/pluginAutoupdate-ByH9IPC9.js +0 -1
  379. package/dist/chunks/pluginOperations-CKNyYjS-.js +0 -2
  380. package/dist/chunks/pluginStartupCheck-B48_cGgo.js +0 -1
  381. package/dist/chunks/plugins-BP_36tOl.js +0 -4
  382. package/dist/chunks/poorMode-Djw0P9Gu.js +0 -1
  383. package/dist/chunks/print-2uavraPq.js +0 -26
  384. package/dist/chunks/processBashCommand-g3sAMpHt.js +0 -1
  385. package/dist/chunks/processSlashCommand-tIbeCrv5.js +0 -5
  386. package/dist/chunks/prompt-DLv-Cd67.js +0 -1
  387. package/dist/chunks/prompt-DV5tCLRh.js +0 -1
  388. package/dist/chunks/protocolHandler-B83fCYI4.js +0 -13
  389. package/dist/chunks/reconciler-CDq6XgAS.js +0 -1
  390. package/dist/chunks/refresh-ysrhoWCo.js +0 -1
  391. package/dist/chunks/registerProtocol-DduKPsn_.js +0 -36
  392. package/dist/chunks/rename-1GLIUlYk.js +0 -1
  393. package/dist/chunks/resume-DWtlUiHW.js +0 -2
  394. package/dist/chunks/ripgrep-BLQnqPnE.js +0 -1
  395. package/dist/chunks/sandbox-adapter-BzjRQh_r.js +0 -1
  396. package/dist/chunks/sandbox-toggle-Bz49-F6e.js +0 -1
  397. package/dist/chunks/searchExtraTools-D6vj8qJ-.js +0 -1
  398. package/dist/chunks/sessionFileAccessHooks-Da97UA2n.js +0 -1
  399. package/dist/chunks/sessionObserver-DXO4trhk.js +0 -1
  400. package/dist/chunks/sessionState-Bn3ESS5f.js +0 -11
  401. package/dist/chunks/sessionStorage-DlPVsQn9.js +0 -1
  402. package/dist/chunks/sessionStoragePortable-BhkGMZWp.js +0 -3
  403. package/dist/chunks/settings-3ionQKNv.js +0 -1
  404. package/dist/chunks/settings-DiBMs2gM.js +0 -20
  405. package/dist/chunks/settingsSync-eHaSngKo.js +0 -1
  406. package/dist/chunks/setup-DeyiuGNX.js +0 -3
  407. package/dist/chunks/sinks-Bgy2UNK-.js +0 -2
  408. package/dist/chunks/sinks-CgzLmim2.js +0 -1
  409. package/dist/chunks/skillChangeDetector-BlSP16j6.js +0 -1
  410. package/dist/chunks/skills-CJhWI8t1.js +0 -1
  411. package/dist/chunks/src-P_wYS_NJ2.js +0 -53
  412. package/dist/chunks/startupProfiler-CUlV07MD.js +0 -1
  413. package/dist/chunks/status-CDCurOqs.js +0 -2
  414. package/dist/chunks/status-yoQIQ2Ni.js +0 -1
  415. package/dist/chunks/statusNoticeHelpers-Sl4jjauz.js +0 -1
  416. package/dist/chunks/switcher-C-m6MUwE.js +0 -1
  417. package/dist/chunks/tasks-CHG_6sXQ.js +0 -1
  418. package/dist/chunks/teleport-C9KRE4X8.js +0 -1
  419. package/dist/chunks/terminalSetup-fwhFTxGi.js +0 -33
  420. package/dist/chunks/theme-MvX7hojJ.js +0 -1
  421. package/dist/chunks/toolPool-Cq74Cvjp.js +0 -1
  422. package/dist/chunks/trustedDevice-BGwujSqc.js +0 -1
  423. package/dist/chunks/updateCCB-CfckOy7T.js +0 -11
  424. package/dist/chunks/upstreamproxy-BuBFDFAD.js +0 -11
  425. package/dist/chunks/useExitOnCtrlCDWithKeybindings-CPLBDluY.js +0 -1
  426. package/dist/chunks/useMainLoopModel-C00PbZ1Q.js +0 -1
  427. package/dist/chunks/useManagePlugins-DFaGntzJ.js +0 -1
  428. package/dist/chunks/useMergedTools-DYobZ5N4.js +0 -1
  429. package/dist/chunks/useSettingsErrors-BRgjvaHd.js +0 -1
  430. package/dist/chunks/util-D7uwPgF1.js +0 -1
  431. package/dist/chunks/validatePlugin-VukX52bx.js +0 -1
  432. package/dist/chunks/windowsPaths-B8p9tFRF.js +0 -1
  433. package/dist/chunks/workerRegistry-BA37PVbv.js +0 -6
  434. package/dist/chunks/worktree-Lik8xuKd.js +0 -1
  435. package/dist/chunks/xdg-DcF9ejUM.js +0 -1
@@ -0,0 +1,2 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{Aw as t,Bw as n,Do as r,Eo as i,Fo as a,Fw as o,Io as s,Iw as c,Lo as l,Mw as u,No as d,Nw as f,Oo as p,Vw as m,Yx as h,Zx as g,_o as _,ao as v,as as y,co as b,dg as x,do as S,go as C,hw as ee,is as w,jw as T,ko as E,lo as D,mo as te,oo as O,os as k,po as A,ro as j,so as M,ug as ne,vo as re,xo as ie,yw as ae}from"./loadAgentsDir-CwEfQDOw.js";import{Wt as oe,et as N}from"./state-BPFYBqm1.js";import{B as P,R as se,U as ce,f as F,u as I}from"./debug-BQj6h99Q.js";import{c as L,g as R,x as z}from"./settings-CvhsRFaT.js";import{o as B,s as V}from"./log-BlJ7CcKG.js";import{l as H,o as U}from"./stringUtils-BjnclTLB.js";import{n as W,t as G}from"./pluginStartupCheck-BLc0U7W7.js";import{dirname as le,join as K}from"path";function q(e){if(!Q.includes(e))throw Error(`Invalid scope "${e}". Must be one of: ${Q.join(`, `)}`)}function ue(e){return Q.includes(e)}function J(e){return e===`project`||e===`local`?N():void 0}function de(e){return L(`projectSettings`)?.enabledPlugins?.[e]===!0}function fe(e){let t=e.includes(`@`);for(let n of[`local`,`project`,`user`]){let r=L(c(n))?.enabledPlugins;if(r){for(let i of Object.keys(r))if(t?i===e:i.startsWith(`${e}@`))return{pluginId:i,scope:n}}}return null}function pe(e,t){let{name:n,marketplace:r}=o(e);return t.find(t=>t.name===e||t.name===n?!0:r&&t.source?t.name===n&&t.source.includes(`@${r}`):!1)}function me(e){let{name:t}=o(e),n=r();if(n.plugins[e]?.length)return{pluginId:e,pluginName:t};let i=Object.keys(n.plugins).find(e=>{let{name:r}=o(e);return r===t&&(n.plugins[e]?.length??0)>0});return i?{pluginId:i,pluginName:t}:null}function Y(e){let t=r().plugins[e];if(!t||t.length===0)return{scope:`user`};let n=N(),i=t.find(e=>e.scope===`local`&&e.projectPath===n);if(i)return{scope:i.scope,projectPath:i.projectPath};let a=t.find(e=>e.scope===`project`&&e.projectPath===n);if(a)return{scope:a.scope,projectPath:a.projectPath};let o=t.find(e=>e.scope===`user`);return o?{scope:o.scope}:{scope:t[0].scope,projectPath:t[0].projectPath}}async function he(e,t=`user`){q(t);let{name:n,marketplace:r}=o(e),i,s,c;if(r){let t=await a(e);t&&(i=t.entry,s=r,c=t.marketplaceInstallLocation)}else{let e=await l();for(let[t,r]of Object.entries(e))try{let e=(await d(t)).plugins.find(e=>e.name===n);if(e){i=e,s=t,c=r.installLocation;break}}catch(e){V(ce(e))}}if(!i||!s)return{success:!1,message:`Plugin "${n}" not found in ${r?`marketplace "${r}"`:`any configured marketplace`}`};let u=i,f=`${u.name}@${s}`,p=await C({pluginId:f,entry:u,scope:t,marketplaceInstallLocation:c});if(!p.ok){let e=p;switch(e.reason){case`local-source-no-location`:return{success:!1,message:`Cannot install local plugin "${e.pluginName}" without marketplace install location`};case`settings-write-failed`:return{success:!1,message:`Failed to update settings: ${e.message}`};case`resolution-failed`:return{success:!1,message:A(e.resolution)};case`blocked-by-policy`:return{success:!1,message:`Plugin "${e.pluginName}" is blocked by your organization's policy and cannot be installed`};case`dependency-blocked-by-policy`:return{success:!1,message:`Plugin "${e.pluginName}" depends on "${e.blockedDependency}", which is blocked by your organization's policy`}}}return{success:!0,message:`Successfully installed plugin: ${f} (scope: ${t})${p.depNote}`,pluginId:f,pluginName:u.name,scope:t}}async function ge(e,n=`user`,i=!0){q(n);let{enabled:a,disabled:o}=await D(),s=[...a,...o],l=pe(e,s),u=c(n),d=L(u),f,m;if(l)f=Object.keys(d?.enabledPlugins??{}).find(t=>t===e||t===l.name||t.startsWith(`${l.name}@`))??(e.includes(`@`)?e:l.name),m=l.name;else{let t=me(e);if(!t)return{success:!1,message:`Plugin "${e}" not found in installed plugins`};f=t.pluginId,m=t.pluginName}let g=J(n),_=r().plugins[f],v=_?.find(e=>e.scope===n&&e.projectPath===g);if(!v){let{scope:t}=Y(f);return t!==n&&_&&_.length>0?t===`project`?{success:!1,message:`Plugin "${e}" is enabled at project scope (.workmate/settings.json, shared with your team). To disable just for you: claude plugin disable ${e} --scope local`}:{success:!1,message:`Plugin "${e}" is installed in ${t} scope, not ${n}. Use --scope ${t} to uninstall.`}:{success:!1,message:`Plugin "${e}" is not installed in ${n} scope. Use --scope to specify the correct scope.`}}let y=v.installPath,b={...d?.enabledPlugins};b[f]=void 0,z(u,{enabledPlugins:b}),w(),p(f,n,g);let x=r().plugins[f],S=!x||x.length===0;S&&y&&await k(y),S&&(h(f),i&&await ee(f));let C=t(f,s),E=T(C);return{success:!0,message:`Successfully uninstalled plugin: ${m} (scope: ${n})${E}`,pluginId:f,pluginName:m,scope:n,reverseDependents:C.length>0?C:void 0}}async function X(e,n,r){let i=n?`enable`:`disable`;if(m(e)){let{error:t}=z(`userSettings`,{enabledPlugins:{...L(`userSettings`)?.enabledPlugins,[e]:n}});if(t)return{success:!1,message:`Failed to ${i} built-in plugin: ${t.message}`};w();let{name:r}=o(e);return{success:!0,message:`Successfully ${i}d built-in plugin: ${r}`,pluginId:e,pluginName:r,scope:`user`}}r&&q(r);let a,s,l=fe(e);if(r)if(s=r,l)a=l.pluginId;else if(e.includes(`@`))a=e;else return{success:!1,message:`Plugin "${e}" not found in settings. Use plugin@marketplace format.`};else if(l)a=l.pluginId,s=l.scope;else if(e.includes(`@`))a=e,s=`user`;else return{success:!1,message:`Plugin "${e}" not found in any editable settings scope. Use plugin@marketplace format.`};if(n&&x(a))return{success:!1,message:`Plugin "${a}" is blocked by your organization's policy and cannot be enabled`};let u=c(s),d=L(u)?.enabledPlugins?.[a],f={user:0,project:1,local:2},p=r&&l&&f[r]>f[l.scope];if(r&&d===void 0&&l&&l.scope!==r&&!p)return{success:!1,message:`Plugin "${e}" is installed at ${l.scope} scope, not ${r}. Use --scope ${l.scope} or omit --scope to auto-detect.`};if(n===(r&&!p?d===!0:G().has(a)))return{success:!1,message:`Plugin "${e}" is already ${n?`enabled`:`disabled`}${r?` at ${r} scope`:``}`};let h;if(!n){let{enabled:e,disabled:n}=await D(),r=t(a,[...e,...n]);r.length>0&&(h=r)}let{error:g}=z(u,{enabledPlugins:{...L(u)?.enabledPlugins,[a]:n}});if(g)return{success:!1,message:`Failed to ${i} plugin: ${g.message}`};w();let{name:_}=o(a),v=T(h);return{success:!0,message:`Successfully ${i}d plugin: ${_} (scope: ${s})${v}`,pluginId:a,pluginName:_,scope:s,reverseDependents:h}}async function _e(e,t){return X(e,!0,t)}async function ve(e,t){return X(e,!1,t)}async function Z(){let e=G();if(e.size===0)return{success:!0,message:`No enabled plugins to disable`};let t=[],n=[];for(let[r]of e){let e=await X(r,!1);e.success?t.push(r):n.push(`${r}: ${e.message}`)}return n.length>0?{success:!1,message:`Disabled ${t.length} ${H(t.length,`plugin`)}, ${n.length} failed:\n${n.join(`
2
+ `)}`}:{success:!0,message:`Disabled ${t.length} ${H(t.length,`plugin`)}`}}async function ye(e,t){let{name:n,marketplace:r}=o(e),s=r?`${n}@${r}`:e,c=await a(e);if(!c)return{success:!1,message:`Plugin "${n}" not found`,pluginId:s,scope:t};let{entry:l,marketplaceInstallLocation:u}=c,d=i().plugins[s];if(!d||d.length===0)return{success:!1,message:`Plugin "${n}" is not installed`,pluginId:s,scope:t};let f=J(t),p=d.find(e=>e.scope===t&&e.projectPath===f);return p?be({pluginId:s,pluginName:n,entry:l,marketplaceInstallLocation:u,installation:p,scope:t,projectPath:f}):{success:!1,message:`Plugin "${n}" is not installed at scope ${f?`${t} (${f})`:t}`,pluginId:s,scope:t}}async function be({pluginId:e,pluginName:t,entry:n,marketplaceInstallLocation:r,installation:a,scope:o,projectPath:s}){let c=I(),l=a.version,u,d,f=!1,p;if(typeof n.source!=`string`){let t=await j(n.source,{manifest:{name:n.name}});u=t.path,f=!0,p=t.gitCommitSha,d=await _(e,n.source,t.manifest,t.path,n.version,t.gitCommitSha)}else{let t;try{t=await c.stat(r)}catch(t){if(P(t))return{success:!1,message:`Marketplace directory not found at ${r}`,pluginId:e,scope:o};throw t}u=K(t.isDirectory()?r:le(r),n.source);try{await c.stat(u)}catch(t){if(P(t))return{success:!1,message:`Plugin source not found at ${u}`,pluginId:e,scope:o};throw t}let i,a=K(u,`.claude-plugin`,`plugin.json`);try{i=await S(a,n.name,n.source)}catch{}d=await _(e,n.source,i,u,n.version)}try{let r=O(e,d),c=M(e,d);if(a.version===d||a.installPath===r||a.installPath===c)return{success:!0,message:`${t} is already at the latest version (${d}).`,pluginId:e,newVersion:d,oldVersion:l,alreadyUpToDate:!0,scope:o};r=await v(u,e,d,n);let f=a.installPath;if(E(e,o,s,r,d,p),f&&f!==r){let e=i();Object.values(e.plugins).some(e=>e.some(e=>e.installPath===f))||await k(f)}let m=s?`${o} (${s})`:o;return{success:!0,message:`Plugin "${t}" updated from ${l||`unknown`} to ${d} for scope ${m}. Restart to apply changes.`,pluginId:e,newVersion:d,oldVersion:l,scope:o}}finally{f&&u!==O(e,d)&&await c.rm(u,{recursive:!0,force:!0})}}var Q,$,xe=e((()=>{oe(),n(),se(),F(),B(),y(),u(),ie(),s(),ae(),f(),te(),b(),g(),ne(),W(),re(),R(),U(),Q=[`user`,`project`,`local`],$=[`user`,`project`,`local`,`managed`]}));export{_e as a,he as c,ge as d,ye as f,ve as i,ue as l,$ as n,Y as o,Z as r,xe as s,Q as t,de as u};
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{Co as t,Jw as n,Ro as r,Ww as i,Yw as a,go as o}from"./loadAgentsDir-mcRW90aq.js";import{n as s}from"./cwd-Besi3Os3.js";import{c,i as l}from"./debug-Dr1SjdXn.js";import{c as u,g as d,vt as f}from"./settings-DiBMs2gM.js";import{o as p}from"./log-27kCA_9u.js";import"path";function m(){let e=new Map,t=n();for(let[n,r]of Object.entries(t))n.includes(`@`)&&(r===!0?e.set(n,`flag`):r===!1&&e.delete(n));for(let{scope:n,source:r}of[{scope:`managed`,source:`policySettings`},{scope:`user`,source:`userSettings`},{scope:`project`,source:`projectSettings`},{scope:`local`,source:`localSettings`},{scope:`flag`,source:`flagSettings`}]){let i=u(r);if(i?.enabledPlugins)for(let[a,o]of Object.entries(i.enabledPlugins))a.includes(`@`)&&(a in t&&t[a]!==o&&c(`Plugin ${a} from --add-dir (${t[a]}) overridden by ${r} (${o})`),o===!0?e.set(a,n):o===!1&&e.delete(a))}return c(`Found ${e.size} enabled plugins with scopes: ${Array.from(e.entries()).map(([e,t])=>`${e}(${t})`).join(`, `)}`),e}var h=e((()=>{s(),l(),p(),d(),a(),t(),r(),i(),o(),f()}));export{h as n,m as t};
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{Io as t,Lw as n,Nw as r,Rw as i,mo as a,xo as o}from"./loadAgentsDir-CwEfQDOw.js";import{n as s}from"./cwd-Besi3Os3.js";import{c,i as l}from"./debug-BQj6h99Q.js";import{c as u,g as d,vt as f}from"./settings-CvhsRFaT.js";import{o as p}from"./log-BlJ7CcKG.js";import"path";function m(){let e=new Map,t=n();for(let[n,r]of Object.entries(t))n.includes(`@`)&&(r===!0?e.set(n,`flag`):r===!1&&e.delete(n));for(let{scope:n,source:r}of[{scope:`managed`,source:`policySettings`},{scope:`user`,source:`userSettings`},{scope:`project`,source:`projectSettings`},{scope:`local`,source:`localSettings`},{scope:`flag`,source:`flagSettings`}]){let i=u(r);if(i?.enabledPlugins)for(let[a,o]of Object.entries(i.enabledPlugins))a.includes(`@`)&&(a in t&&t[a]!==o&&c(`Plugin ${a} from --add-dir (${t[a]}) overridden by ${r} (${o})`),o===!0?e.set(a,n):o===!1&&e.delete(a))}return c(`Found ${e.size} enabled plugins with scopes: ${Array.from(e.entries()).map(([e,t])=>`${e}(${t})`).join(`, `)}`),e}var h=e((()=>{s(),l(),p(),d(),i(),o(),t(),r(),a(),f()}));export{h as n,m as t};
@@ -0,0 +1 @@
1
+ import{n as e,t}from"./pluginStartupCheck-BLc0U7W7.js";e();export{t as getPluginEditableScopes};
@@ -0,0 +1,4 @@
1
+ import{n as e,t}from"./figures-5ThXQEtq.js";import{Ao as n,Bo as r,Do as i,Fw as a,Ho as o,Hw as s,Io as c,Iw as l,Jo as u,Jx as d,Lo as f,Nw as p,To as ee,Uw as m,Wo as h,as as g,co as _,es as v,is as y,lo as b,ns as x,qx as S,xo as te,zo as C}from"./loadAgentsDir-CwEfQDOw.js";import{Wt as w,ir as T}from"./state-BPFYBqm1.js";import{C as E,P as D,R as O,x as k}from"./debug-BQj6h99Q.js";import{o as ne,s as A}from"./log-BlJ7CcKG.js";import{n as j,r as M}from"./analytics-DJobLaWP.js";import{l as N,o as P}from"./stringUtils-BjnclTLB.js";import{n as F,t as I}from"./exit-s9XGerrH.js";import{n as L,s as R,t as z}from"./pluginOperations-C7BCR7pw.js";import{a as B,i as V,n as H,o as U,r as W,t as G}from"./pluginCliCommands-3YCj7Y3Q.js";import{a as re,c as K,i as q,n as J,r as Y,s as X,t as ie}from"./validatePlugin-CSE8zjZn.js";import{basename as ae,dirname as Z}from"path";e(),w(),j(),R(),m(),O(),ne(),g(),K(),te(),v(),c(),S(),q(),p(),_(),ie(),k(),P();function Q(e,n){A(e),I(`${t.cross} Failed to ${n}: ${D(e)}`)}function $(e){e.errors.length>0&&(console.log(`${t.cross} Found ${e.errors.length} ${N(e.errors.length,`error`)}:\n`),e.errors.forEach(e=>{console.log(` ${t.pointer} ${e.path}: ${e.message}`)}),console.log(``)),e.warnings.length>0&&(console.log(`${t.warning} Found ${e.warnings.length} ${N(e.warnings.length,`warning`)}:\n`),e.warnings.forEach(e=>{console.log(` ${t.pointer} ${e.path}: ${e.message}`)}),console.log(``))}async function oe(e,n){n.cowork&&T(!0);try{let n=await J(e);console.log(`Validating ${n.fileType} manifest: ${n.filePath}\n`),$(n);let r=[];if(n.fileType===`plugin`){let e=Z(n.filePath);if(ae(e)===`.claude-plugin`){r=await Y(Z(e));for(let e of r)console.log(`Validating ${e.fileType}: ${e.filePath}\n`),$(e)}}let i=n.success&&r.every(e=>e.success),a=n.warnings.length>0||r.some(e=>e.warnings.length>0);i?F(a?`${t.tick} Validation passed with warnings`:`${t.tick} Validation passed`):(console.log(`${t.cross} Validation failed`),process.exit(1))}catch(e){A(e),console.error(`${t.cross} Unexpected error during validation: ${D(e)}`),process.exit(2)}}async function se(e){e.cowork&&T(!0),M(`tengu_plugin_list_command`,{});let n=i(),{getPluginEditableScopes:r}=await import(`./pluginStartupCheck-nzVDPI1k.js`),o=r(),c=Object.keys(n.plugins),{enabled:l,disabled:p,errors:m}=await b(),h=[...l,...p],g=h.filter(e=>e.source.endsWith(`@inline`)),_=m.filter(e=>e.source.endsWith(`@inline`)||e.source.startsWith(`inline[`));if(e.json){let t=new Map(h.map(e=>[e.source,e])),r=[];for(let e of c.sort()){let i=n.plugins[e];if(!i||i.length===0)continue;let c=a(e).name,l=m.filter(t=>t.source===e||`plugin`in t&&t.plugin===c).map(s);for(let n of i){let i=t.get(e),a;if(i){let e=i.mcpServers||await d(i);e&&Object.keys(e).length>0&&(a=e)}r.push({id:e,version:n.version||`unknown`,scope:n.scope,enabled:o.has(e),installPath:n.installPath,installedAt:n.installedAt,lastUpdated:n.lastUpdated,projectPath:n.projectPath,mcpServers:a,errors:l.length>0?l:void 0})}}for(let e of g){let t=e.mcpServers||await d(e),n=_.filter(t=>t.source===e.source||`plugin`in t&&t.plugin===e.name).map(s);r.push({id:e.source,version:e.manifest.version??`unknown`,scope:`session`,enabled:e.enabled!==!1,installPath:e.path,mcpServers:t&&Object.keys(t).length>0?t:void 0,errors:n.length>0?n:void 0})}for(let e of _.filter(e=>e.source.startsWith(`inline[`)))r.push({id:e.source,version:`unknown`,scope:`session`,enabled:!1,installPath:`path`in e?e.path:``,errors:[s(e)]});if(e.available){let e=[];try{let[t,n]=await Promise.all([f(),X()]),{marketplaces:r}=await x(t);for(let{name:t,data:i}of r)if(i)for(let r of i.plugins){let i=u(r.name,t);ee(i)||e.push({pluginId:i,name:r.name,description:r.description,marketplaceName:t,version:r.version,source:r.source,installCount:n?.get(i)})}}catch{}F(E({installed:r,available:e},null,2))}else F(E(r,null,2))}c.length===0&&g.length===0&&_.length===0&&F("No plugins installed. Use `claude plugin install` to install a plugin."),c.length>0&&console.log(`Installed plugins:
2
+ `);for(let e of c.sort()){let r=n.plugins[e];if(!r||r.length===0)continue;let i=a(e).name,c=m.filter(t=>t.source===e||`plugin`in t&&t.plugin===i);for(let n of r){let r=o.has(e),i=c.length>0?`${t.cross} failed to load`:r?`${t.tick} enabled`:`${t.cross} disabled`,a=n.version||`unknown`,l=n.scope;console.log(` ${t.pointer} ${e}`),console.log(` Version: ${a}`),console.log(` Scope: ${l}`),console.log(` Status: ${i}`);for(let e of c)console.log(` Error: ${s(e)}`);console.log(``)}}if(g.length>0||_.length>0){console.log(`Session-only plugins (--plugin-dir):
3
+ `);for(let e of g){let n=_.filter(t=>t.source===e.source||`plugin`in t&&t.plugin===e.name),r=n.length>0?`${t.cross} loaded with errors`:`${t.tick} loaded`;console.log(` ${t.pointer} ${e.source}`),console.log(` Version: ${e.manifest.version??`unknown`}`),console.log(` Path: ${e.path}`),console.log(` Status: ${r}`);for(let e of n)console.log(` Error: ${s(e)}`);console.log(``)}for(let e of _.filter(e=>e.source.startsWith(`inline[`)))console.log(` ${t.pointer} ${e.source}: ${t.cross} ${s(e)}\n`)}F()}async function ce(e,r){r.cowork&&T(!0);try{let i=await re(e);i||I(`${t.cross} Invalid marketplace source format. Try: owner/repo, https://..., or ./path`),`error`in i&&I(`${t.cross} ${i.error}`);let a=r.scope??`user`;a!==`user`&&a!==`project`&&a!==`local`&&I(`${t.cross} Invalid scope '${a}'. Use: user, project, or local`);let o=l(a),s=i;r.sparse&&r.sparse.length>0&&(s.source===`github`||s.source===`git`?s={...s,sparsePaths:r.sparse}:I(`${t.cross} --sparse is only supported for github and git marketplace sources (got: ${s.source})`)),console.log(`Adding marketplace...`);let{name:c,alreadyMaterialized:u,resolvedSource:d}=await n(s,e=>{console.log(e)});h(c,{source:d},o),y();let f=s.source;s.source===`github`&&(f=s.repo),M(`tengu_marketplace_added`,{source_type:f}),F(u?`${t.tick} Marketplace '${c}' already on disk — declared in ${a} settings`:`${t.tick} Successfully added marketplace: ${c} (declared in ${a} settings)`)}catch(e){Q(e,`add marketplace`)}}async function le(e){e.cowork&&T(!0);try{let n=await f(),r=Object.keys(n);e.json&&F(E(r.sort().map(e=>{let t=n[e],r=t?.source;return{name:e,source:r?.source,...r?.source===`github`&&{repo:r.repo},...r?.source===`git`&&{url:r.url},...r?.source===`url`&&{url:r.url},...r?.source===`directory`&&{path:r.path},...r?.source===`file`&&{path:r.path},installLocation:t?.installLocation}}),null,2)),r.length===0&&F(`No marketplaces configured`),console.log(`Configured marketplaces:
4
+ `),r.forEach(e=>{let r=n[e];if(console.log(` ${t.pointer} ${e}`),r?.source){let e=r.source;e.source===`github`?console.log(` Source: GitHub (${e.repo})`):e.source===`git`?console.log(` Source: Git (${e.url})`):e.source===`url`?console.log(` Source: URL (${e.url})`):e.source===`directory`?console.log(` Source: Directory (${e.path})`):e.source===`file`&&console.log(` Source: File (${e.path})`)}console.log(``)}),F()}catch(e){Q(e,`list marketplaces`)}}async function ue(e,n){n.cowork&&T(!0);try{await o(e),y(),M(`tengu_marketplace_removed`,{marketplace_name:e}),F(`${t.tick} Successfully removed marketplace: ${e}`)}catch(e){Q(e,`remove marketplace`)}}async function de(e,n){n.cowork&&T(!0);try{if(e)console.log(`Updating marketplace: ${e}...`),await r(e,e=>{console.log(e)}),y(),M(`tengu_marketplace_updated`,{marketplace_name:e}),F(`${t.tick} Successfully updated marketplace: ${e}`);else{let e=await f(),n=Object.keys(e);n.length===0&&F(`No marketplaces configured`),console.log(`Updating ${n.length} marketplace(s)...`),await C(),y(),M(`tengu_marketplace_updated_all`,{count:n.length}),F(`${t.tick} Successfully updated ${n.length} marketplace(s)`)}}catch(e){Q(e,`update marketplace(s)`)}}async function fe(e,t){t.cowork&&T(!0);let n=t.scope||`user`;t.cowork&&n!==`user`&&I(`--cowork can only be used with user scope`),z.includes(n)||I(`Invalid scope: ${n}. Must be one of: ${z.join(`, `)}.`);let{name:r,marketplace:i}=a(e);M(`tengu_plugin_install_command`,{_PROTO_plugin_name:r,...i&&{_PROTO_marketplace_name:i},scope:n}),await V(e,n)}async function pe(e,t){t.cowork&&T(!0);let n=t.scope||`user`;t.cowork&&n!==`user`&&I(`--cowork can only be used with user scope`),z.includes(n)||I(`Invalid scope: ${n}. Must be one of: ${z.join(`, `)}.`);let{name:r,marketplace:i}=a(e);M(`tengu_plugin_uninstall_command`,{_PROTO_plugin_name:r,...i&&{_PROTO_marketplace_name:i},scope:n}),await B(e,n,t.keepData)}async function me(e,t){t.cowork&&T(!0);let n;t.scope&&(z.includes(t.scope)||I(`Invalid scope "${t.scope}". Valid scopes: ${z.join(`, `)}`),n=t.scope),t.cowork&&n!==void 0&&n!==`user`&&I(`--cowork can only be used with user scope`),t.cowork&&n===void 0&&(n=`user`);let{name:r,marketplace:i}=a(e);M(`tengu_plugin_enable_command`,{_PROTO_plugin_name:r,...i&&{_PROTO_marketplace_name:i},scope:n??`auto`}),await W(e,n)}async function he(e,t){if(t.all&&e&&I(`Cannot use --all with a specific plugin`),!t.all&&!e&&I(`Please specify a plugin name or use --all to disable all plugins`),t.cowork&&T(!0),t.all){t.scope&&I(`Cannot use --scope with --all`),M(`tengu_plugin_disable_command`,{}),await G();return}let n;t.scope&&(z.includes(t.scope)||I(`Invalid scope "${t.scope}". Valid scopes: ${z.join(`, `)}`),n=t.scope),t.cowork&&n!==void 0&&n!==`user`&&I(`--cowork can only be used with user scope`),t.cowork&&n===void 0&&(n=`user`);let{name:r,marketplace:i}=a(e);M(`tengu_plugin_disable_command`,{_PROTO_plugin_name:r,...i&&{_PROTO_marketplace_name:i},scope:n??`auto`}),await H(e,n)}async function ge(e,t){t.cowork&&T(!0);let{name:n,marketplace:r}=a(e);M(`tengu_plugin_update_command`,{_PROTO_plugin_name:n,...r&&{_PROTO_marketplace_name:r}});let i=`user`;t.scope&&(L.includes(t.scope)||I(`Invalid scope "${t.scope}". Valid scopes: ${L.join(`, `)}`),i=t.scope),t.cowork&&i!==`user`&&I(`--cowork can only be used with user scope`),await U(e,i)}export{ce as marketplaceAddHandler,le as marketplaceListHandler,ue as marketplaceRemoveHandler,de as marketplaceUpdateHandler,he as pluginDisableHandler,me as pluginEnableHandler,fe as pluginInstallHandler,se as pluginListHandler,pe as pluginUninstallHandler,ge as pluginUpdateHandler,oe as pluginValidateHandler};
@@ -0,0 +1 @@
1
+ import{n as e,t}from"./poorMode-wm2WkPF0.js";t();export{e as isPoorModeActive};
@@ -1 +1 @@
1
- import{n as e,r as t}from"./rolldown-runtime-DaDcL9Zw.js";import{g as n,n as r,x as i}from"./settings-DiBMs2gM.js";var a=t({isPoorModeActive:()=>o,setPoorMode:()=>s});function o(){return c===null&&(c=r().poorMode===!0),c}function s(e){c=e,i(`userSettings`,{poorMode:e||void 0})}var c,l=e((()=>{n(),c=null}));export{s as i,o as n,a as r,l as t};
1
+ import{n as e,r as t}from"./rolldown-runtime-DaDcL9Zw.js";import{g as n,n as r,x as i}from"./settings-CvhsRFaT.js";var a=t({isPoorModeActive:()=>o,setPoorMode:()=>s});function o(){return c===null&&(c=r().poorMode===!0),c}function s(e){c=e,i(`userSettings`,{poorMode:e||void 0})}var c,l=e((()=>{n(),c=null}));export{s as i,o as n,a as r,l as t};
@@ -0,0 +1,14 @@
1
+ import{c as e,i as t,l as n,o as r,s as i}from"./envUtils-DcaKZlRU.js";import{n as a,t as o}from"./defineProperty-C-QyHrDq.js";import{n as s,t as c}from"./axios-DaWTGg7G.js";import{$d as l,$l as u,$y as d,A as f,Ai as p,Ax as m,B as h,Bb as g,Bc as ee,Bg as _,Bt as te,C as ne,Cn as re,Cx as v,Di as y,Fb as b,Fc as x,Gg as ie,Gs as ae,Gv as oe,Hc as se,If as S,Ig as ce,Io as le,Ix as ue,Jb as de,Jn as fe,Jv as pe,KS as me,Kv as he,La as C,Lb as ge,Lc as _e,Lf as ve,Lg as ye,Li as be,Lv as xe,Lx as Se,Mi as Ce,Mo as w,Ms as we,Mx as Te,Nb as Ee,Ns as T,Ob as De,Pb as Oe,Pc as ke,Ps as Ae,Qd as E,Qn as je,Qy as Me,Rb as Ne,Rc as Pe,Ro as Fe,Rv as Ie,ST as D,Sb as Le,Sn as Re,Tb as ze,Th as Be,Tu as O,Uc as Ve,Ug as He,Ur as Ue,V as We,Vc as Ge,Vg as Ke,Vo as qe,Vt as Je,Vx as Ye,Wc as k,Xp as A,Xv as Xe,Yb as Ze,Yv as Qe,Zb as $e,Zd as et,Zp as tt,_T as nt,__ as rt,_i as it,_m as at,aT as ot,af as st,ai as ct,b as lt,bg as ut,bm as dt,bn as ft,br as pt,bx as mt,cT as ht,cc as gt,co as _t,cs as vt,dS as yt,dm as bt,ds as xt,eb as St,ec as Ct,ef as wt,eg as Tt,eu as Et,f as Dt,fS as Ot,fT as kt,fm as At,fs as jt,g_ as Mt,ga as Nt,gi as Pt,gm as Ft,gs as It,h_ as Lt,hg as Rt,hm as zt,hn as Bt,hs as Vt,ic as Ht,ii as Ut,io as Wt,jS as Gt,jb as Kt,jo as qt,js as Jt,jx as Yt,kS as Xt,lc as Zt,lp as Qt,ls as $t,ly as en,m_ as tn,mg as nn,mm as rn,ms as an,nc as on,ni as sn,no as cn,nw as ln,ny as un,o as dn,oE as fn,oy as pn,pT as mn,pg as hn,pm as gn,ps as _n,qc as vn,qg as yn,qs as bn,rf as xn,rw as Sn,ry as Cn,s as wn,sp as Tn,ss as En,tc as Dn,tg as On,ti as kn,to as An,ty as jn,um as Mn,uo as Nn,us as Pn,ux as Fn,v as In,vT as Ln,vm as Rn,vr as zn,w as Bn,wb as Vn,wh as Hn,wm as Un,wn as Wn,wu as Gn,xT as Kn,xm as qn,xn as Jn,xu as Yn,y as Xn,yg as Zn,ym as Qn,yn as $n,yr as er,zb as tr,zi as nr}from"./loadAgentsDir-CwEfQDOw.js";import{A as j,C as M,M as N,O as P,b as F,f as rr,g as ir,j as I,l as L,m as R,p as z,u as ar,w as B,y as or}from"./external-CEp-aPkt.js";import{i as V,n as H,r as sr,t as cr}from"./lazySchema-B4D4qJVE.js";import{$t as lr,Gt as ur,M as dr,Mn as fr,Nn as pr,P as mr,Wt as hr,Y as gr,hn as _r,or as vr,pt as U,qn as yr,yn as br}from"./state-BPFYBqm1.js";import{n as xr,t as Sr}from"./cwd-Besi3Os3.js";import{C as Cr,E as wr,P as W,R as Tr,S as Er,U as Dr,a as Or,c as G,f as kr,i as Ar,nt as jr,tt as Mr,u as Nr,x as Pr}from"./debug-BQj6h99Q.js";import{Bn as Fr,G as Ir,Rn as Lr,cr as Rr,d as zr,dt as Br,f as Vr,g as Hr,it as Ur,nt as Wr,or as Gr,vt as Kr}from"./settings-CvhsRFaT.js";import{F as qr,M as Jr}from"./config-BSkuQZNf.js";import{i as Yr,n as Xr,o as K}from"./process-gEbdy6uY.js";import{A as Zr,O as Qr,k as $r}from"./git-DplvjXEY.js";import{H as ei,c as ti,i as ni,o as ri,q as ii,s as q}from"./log-BlJ7CcKG.js";import{s as ai,u as oi}from"./types-BomO8WUz.js";import{n as si,r as J}from"./analytics-DJobLaWP.js";import{Bt as ci,C as li,Kr as ui,Mn as di,Wr as fi,Y as pi,_ as mi,_n as hi,_r as gi,bt as _i,et as vi,gr as yi,ii as bi,it as xi,jn as Si,ni as Ci,o as wi,oi as Ti,ri as Ei,rt as Di,tt as Oi,u as ki,vn as Ai,x as ji}from"./model-CeG-iOKF.js";import{_t as Mi,at as Ni,it as Pi,nn as Fi,vt as Ii,xn as Li,yn as Ri,yt as zi}from"./prompt-Bm2EEG4F.js";import{C as Bi,S as Vi,T as Hi,_ as Ui,a as Wi,at as Gi,b as Ki,c as qi,ct as Ji,et as Yi,l as Xi,n as Zi,nt as Qi,o as $i,rt as ea,s as ta,st as na,t as ra}from"./sessionState-zhvcDpb2.js";import{n as ia,t as aa}from"./omit-B65XeX8r.js";import{a as oa,n as sa,t as ca}from"./bridgeConfig-CPHAyzdg.js";import{i as la,n as ua,s as da}from"./mappers-CdY45PDA.js";import{n as fa,r as pa}from"./sessionTitle-QPRly1tZ.js";import{t as ma}from"./pollConfig-BgpfHQPJ.js";import{t as ha}from"./controlMessageCompat-IFu4Gc1y.js";import{n as ga,t as _a}from"./ccrClient--8aPutWE.js";import{n as va,t as ya}from"./HybridTransport-n5jji6SI.js";import{n as ba,t as xa}from"./SSETransport-D86IVNn1.js";import{a as Sa,n as Ca}from"./grove-Bck1zFaD.js";import{o as wa}from"./remoteManagedSettings-CfFmrRze.js";import{i as Ta,r as Ea}from"./auth-CWAvPfX7.js";import{t as Da}from"./pluginBlocklist-CMwb7gmY.js";import{t as Oa}from"./settingsSync-BGo6dHJo.js";import{n as ka,t as Aa}from"./toolPool-BBU4ll_p.js";import{t as ja}from"./onChangeAppState-EtUxsgYz.js";import{n as Ma,r as Na}from"./QueryEngine-DXpS0Ytq.js";import{r as Pa}from"./bridgeStatusUtil-CHTx7XwJ.js";import{n as Fa,r as Ia}from"./sideQuestion-oIYrx5ar.js";import{n as La,r as Ra}from"./context-noninteractive-kACWzgS1.js";import{n as za,t as Ba}from"./modelOptions-A5jrCUBp.js";import{a as Va,o as Ha,t as Ua}from"./skillChangeDetector-v6mAYzXX.js";import{n as Wa}from"./reconciler-DgQ4y1Vn.js";import{n as Ga,t as Ka}from"./refresh-CayVRWUY.js";import{basename as qa,dirname as Ja,join as Ya}from"path";import{PassThrough as Xa}from"stream";import{randomUUID as Y}from"crypto";import{mkdir as Za,readFile as Qa,stat as $a,writeFile as eo}from"fs/promises";import{URL as to}from"url";import{cwd as X}from"process";r(),a(),c(),hr(),Mr(),Tr(),Pr(),kr(),Xr(),Ar(),Qr(),ii(),ri(),Lr(),ai(),Hr(),Ti(),ui(),gi(),Si(),hi(),ci(),mi(),Oa(),sr(),cr();var no=H(()=>B({inputTokens:M(),outputTokens:M(),cacheReadInputTokens:M(),cacheCreationInputTokens:M(),webSearchRequests:M(),costUSD:M(),contextWindow:M(),maxOutputTokens:M()})),ro=H(()=>F(`json_schema`));H(()=>B({type:ro()}));var io=H(()=>B({type:F(`json_schema`),schema:P(j(),N())}));H(()=>io());var ao=H(()=>L([`user`,`project`,`org`,`temporary`,`oauth`]));H(()=>L([`local`,`user`,`project`]).describe(`Config scope for settings.`)),H(()=>F(`context-1m-2025-08-07`));var oo=H(()=>B({type:F(`adaptive`)}).describe(`Work Mate decides when and how much to think (Opus 4.6+).`)),so=H(()=>B({type:F(`enabled`),budgetTokens:M().optional()}).describe(`Fixed thinking token budget (older models)`)),co=H(()=>B({type:F(`disabled`)}).describe(`No extended thinking`));H(()=>I([oo(),so(),co()]).describe(`Controls Work Mate's thinking/reasoning behavior. When set, takes precedence over the deprecated maxThinkingTokens.`));var lo=H(()=>B({type:F(`stdio`).optional(),command:j(),args:z(j()).optional(),env:P(j(),j()).optional()})),uo=H(()=>B({type:F(`sse`),url:j(),headers:P(j(),j()).optional()})),fo=H(()=>B({type:F(`http`),url:j(),headers:P(j(),j()).optional()})),po=H(()=>B({type:F(`sdk`),name:j()})),mo=H(()=>I([lo(),uo(),fo(),po()])),ho=H(()=>B({type:F(`claudeai-proxy`),url:j(),id:j()})),go=H(()=>I([mo(),ho()])),_o=H(()=>B({name:j().describe(`Server name as configured`),status:L([`connected`,`failed`,`needs-auth`,`pending`,`disabled`]).describe(`Current connection status`),serverInfo:B({name:j(),version:j()}).optional().describe(`Server information (available when connected)`),error:j().optional().describe(`Error message (available when status is 'failed')`),config:go().optional().describe(`Server configuration (includes URL for HTTP/SSE servers)`),scope:j().optional().describe(`Configuration scope (e.g., project, user, local, claudeai, managed)`),tools:z(B({name:j(),description:j().optional(),annotations:B({readOnly:R().optional(),destructive:R().optional(),openWorld:R().optional()}).optional()})).optional().describe(`Tools provided by this server (available when connected)`),capabilities:B({experimental:P(j(),N()).optional()}).optional().describe(`@internal Server capabilities (available when connected). experimental['claude/channel'] is only present if the server's plugin is on the approved channels allowlist — use its presence to decide whether to show an Enable-channel prompt.`)}).describe(`Status information for an MCP server connection.`));H(()=>B({added:z(j()).describe(`Names of servers that were added`),removed:z(j()).describe(`Names of servers that were removed`),errors:P(j(),j()).describe(`Map of server names to error messages for servers that failed to connect`)}).describe(`Result of a setMcpServers operation.`));var vo=H(()=>L([`userSettings`,`projectSettings`,`localSettings`,`session`,`cliArg`])),yo=H(()=>L([`allow`,`deny`,`ask`])),bo=H(()=>B({toolName:j(),ruleContent:j().optional()})),xo=H(()=>ir(`type`,[B({type:F(`addRules`),rules:z(bo()),behavior:yo(),destination:vo()}),B({type:F(`replaceRules`),rules:z(bo()),behavior:yo(),destination:vo()}),B({type:F(`removeRules`),rules:z(bo()),behavior:yo(),destination:vo()}),B({type:F(`setMode`),mode:or(()=>Co()),destination:vo()}),B({type:F(`addDirectories`),directories:z(j()),destination:vo()}),B({type:F(`removeDirectories`),directories:z(j()),destination:vo()})])),So=H(()=>L([`user_temporary`,`user_permanent`,`user_reject`]).describe(`Classification of this permission decision for telemetry. SDK hosts that prompt users (desktop apps, IDEs) should set this to reflect what actually happened: user_temporary for allow-once, user_permanent for always-allow (both the click and later cache hits), user_reject for deny. If unset, the CLI infers conservatively (temporary for allow, reject for deny). The vocabulary matches tool_decision OTel events (monitoring-usage docs).`));H(()=>I([B({behavior:F(`allow`),updatedInput:P(j(),N()).optional(),updatedPermissions:z(xo()).optional(),toolUseID:j().optional(),decisionClassification:So().optional()}),B({behavior:F(`deny`),message:j(),interrupt:R().optional(),toolUseID:j().optional(),decisionClassification:So().optional()})]));var Co=H(()=>L([`default`,`acceptEdits`,`bypassPermissions`,`plan`,`dontAsk`,`auto`]).describe(`Permission mode for controlling how tool executions are handled. 'default' - Standard behavior, prompts for dangerous operations. 'acceptEdits' - Auto-accept file edit operations. 'bypassPermissions' - Bypass all permission checks (requires allowDangerouslySkipPermissions). 'plan' - Planning mode, no actual tool execution. 'dontAsk' - Don't prompt for permissions, deny if not pre-approved. 'auto' - Automatic mode (transcript classifier).`)),wo=`PreToolUse.PostToolUse.PostToolUseFailure.Notification.UserPromptSubmit.SessionStart.SessionEnd.Stop.StopFailure.SubagentStart.SubagentStop.PreCompact.PostCompact.PermissionRequest.PermissionDenied.Setup.TeammateIdle.TaskCreated.TaskCompleted.Elicitation.ElicitationResult.ConfigChange.WorktreeCreate.WorktreeRemove.InstructionsLoaded.CwdChanged.FileChanged`.split(`.`),To=H(()=>L(wo)),Z=H(()=>B({session_id:j(),transcript_path:j(),cwd:j(),permission_mode:j().optional(),agent_id:j().optional().describe(`Subagent identifier. Present only when the hook fires from within a subagent (e.g., a tool called by an AgentTool worker). Absent for the main thread, even in --agent sessions. Use this field (not agent_type) to distinguish subagent calls from main-thread calls.`),agent_type:j().optional().describe(`Agent type name (e.g., "general-purpose", "code-reviewer"). Present when the hook fires from within a subagent (alongside agent_id), or on the main thread of a session started with --agent (without agent_id).`)})),Eo=H(()=>Z().and(B({hook_event_name:F(`PreToolUse`),tool_name:j(),tool_input:N(),tool_use_id:j()}))),Do=H(()=>Z().and(B({hook_event_name:F(`PermissionRequest`),tool_name:j(),tool_input:N(),permission_suggestions:z(xo()).optional()}))),Oo=H(()=>Z().and(B({hook_event_name:F(`PostToolUse`),tool_name:j(),tool_input:N(),tool_response:N(),tool_use_id:j()}))),ko=H(()=>Z().and(B({hook_event_name:F(`PostToolUseFailure`),tool_name:j(),tool_input:N(),tool_use_id:j(),error:j(),is_interrupt:R().optional()}))),Ao=H(()=>Z().and(B({hook_event_name:F(`PermissionDenied`),tool_name:j(),tool_input:N(),tool_use_id:j(),reason:j()}))),jo=H(()=>Z().and(B({hook_event_name:F(`Notification`),message:j(),title:j().optional(),notification_type:j()}))),Mo=H(()=>Z().and(B({hook_event_name:F(`UserPromptSubmit`),prompt:j()}))),No=H(()=>Z().and(B({hook_event_name:F(`SessionStart`),source:L([`startup`,`resume`,`clear`,`compact`]),agent_type:j().optional(),model:j().optional()}))),Po=H(()=>Z().and(B({hook_event_name:F(`Setup`),trigger:L([`init`,`maintenance`])}))),Fo=H(()=>Z().and(B({hook_event_name:F(`Stop`),stop_hook_active:R(),last_assistant_message:j().optional().describe(`Text content of the last assistant message before stopping. Avoids the need to read and parse the transcript file.`)}))),Io=H(()=>Z().and(B({hook_event_name:F(`StopFailure`),error:Ns(),error_details:j().optional(),last_assistant_message:j().optional()}))),Lo=H(()=>Z().and(B({hook_event_name:F(`SubagentStart`),agent_id:j(),agent_type:j()}))),Ro=H(()=>Z().and(B({hook_event_name:F(`SubagentStop`),stop_hook_active:R(),agent_id:j(),agent_transcript_path:j(),agent_type:j(),last_assistant_message:j().optional().describe(`Text content of the last assistant message before stopping. Avoids the need to read and parse the transcript file.`)}))),zo=H(()=>Z().and(B({hook_event_name:F(`PreCompact`),trigger:L([`manual`,`auto`]),custom_instructions:j().nullable()}))),Bo=H(()=>Z().and(B({hook_event_name:F(`PostCompact`),trigger:L([`manual`,`auto`]),compact_summary:j().describe(`The conversation summary produced by compaction`)}))),Vo=H(()=>Z().and(B({hook_event_name:F(`TeammateIdle`),teammate_name:j(),team_name:j()}))),Ho=H(()=>Z().and(B({hook_event_name:F(`TaskCreated`),task_id:j(),task_subject:j(),task_description:j().optional(),teammate_name:j().optional(),team_name:j().optional()}))),Uo=H(()=>Z().and(B({hook_event_name:F(`TaskCompleted`),task_id:j(),task_subject:j(),task_description:j().optional(),teammate_name:j().optional(),team_name:j().optional()}))),Wo=H(()=>Z().and(B({hook_event_name:F(`Elicitation`),mcp_server_name:j(),message:j(),mode:L([`form`,`url`]).optional(),url:j().optional(),elicitation_id:j().optional(),requested_schema:P(j(),N()).optional()})).describe(`Hook input for the Elicitation event. Fired when an MCP server requests user input. Hooks can auto-respond (accept/decline) instead of showing the dialog.`)),Go=H(()=>Z().and(B({hook_event_name:F(`ElicitationResult`),mcp_server_name:j(),elicitation_id:j().optional(),mode:L([`form`,`url`]).optional(),action:L([`accept`,`decline`,`cancel`]),content:P(j(),N()).optional()})).describe(`Hook input for the ElicitationResult event. Fired after the user responds to an MCP elicitation. Hooks can observe or override the response before it is sent to the server.`)),Ko=[`user_settings`,`project_settings`,`local_settings`,`policy_settings`,`skills`],qo=H(()=>Z().and(B({hook_event_name:F(`ConfigChange`),source:L(Ko),file_path:j().optional()}))),Jo=[`session_start`,`nested_traversal`,`path_glob_match`,`include`,`compact`],Yo=[`User`,`Project`,`Local`,`Managed`],Xo=H(()=>Z().and(B({hook_event_name:F(`InstructionsLoaded`),file_path:j(),memory_type:L(Yo),load_reason:L(Jo),globs:z(j()).optional(),trigger_file_path:j().optional(),parent_file_path:j().optional()}))),Zo=H(()=>Z().and(B({hook_event_name:F(`WorktreeCreate`),name:j()}))),Qo=H(()=>Z().and(B({hook_event_name:F(`WorktreeRemove`),worktree_path:j()}))),$o=H(()=>Z().and(B({hook_event_name:F(`CwdChanged`),old_cwd:j(),new_cwd:j()}))),es=H(()=>Z().and(B({hook_event_name:F(`FileChanged`),file_path:j(),event:L([`change`,`add`,`unlink`])}))),ts=[`clear`,`resume`,`logout`,`prompt_input_exit`,`other`,`bypass_permissions_disabled`],ns=H(()=>L(ts)),rs=H(()=>Z().and(B({hook_event_name:F(`SessionEnd`),reason:ns()}))),is=H(()=>I([Eo(),Oo(),ko(),Ao(),jo(),Mo(),No(),rs(),Fo(),Io(),Lo(),Ro(),zo(),Bo(),Do(),Po(),Vo(),Ho(),Uo(),Wo(),Go(),qo(),Xo(),Zo(),Qo(),$o(),es()])),as=H(()=>B({async:F(!0),asyncTimeout:M().optional()})),os=H(()=>B({hookEventName:F(`PreToolUse`),permissionDecision:yo().optional(),permissionDecisionReason:j().optional(),updatedInput:P(j(),N()).optional(),additionalContext:j().optional()})),ss=H(()=>B({hookEventName:F(`UserPromptSubmit`),additionalContext:j().optional()})),cs=H(()=>B({hookEventName:F(`SessionStart`),additionalContext:j().optional(),initialUserMessage:j().optional(),watchPaths:z(j()).optional()})),ls=H(()=>B({hookEventName:F(`Setup`),additionalContext:j().optional()})),us=H(()=>B({hookEventName:F(`SubagentStart`),additionalContext:j().optional()})),ds=H(()=>B({hookEventName:F(`PostToolUse`),additionalContext:j().optional(),updatedMCPToolOutput:N().optional()})),fs=H(()=>B({hookEventName:F(`PostToolUseFailure`),additionalContext:j().optional()})),ps=H(()=>B({hookEventName:F(`PermissionDenied`),retry:R().optional()})),ms=H(()=>B({hookEventName:F(`Notification`),additionalContext:j().optional()})),hs=H(()=>B({hookEventName:F(`PermissionRequest`),decision:I([B({behavior:F(`allow`),updatedInput:P(j(),N()).optional(),updatedPermissions:z(xo()).optional()}),B({behavior:F(`deny`),message:j().optional(),interrupt:R().optional()})])})),gs=H(()=>B({hookEventName:F(`CwdChanged`),watchPaths:z(j()).optional()})),_s=H(()=>B({hookEventName:F(`FileChanged`),watchPaths:z(j()).optional()})),vs=H(()=>B({continue:R().optional(),suppressOutput:R().optional(),stopReason:j().optional(),decision:L([`approve`,`block`]).optional(),systemMessage:j().optional(),reason:j().optional(),hookSpecificOutput:I([os(),ss(),cs(),ls(),us(),ds(),fs(),ps(),ms(),hs(),ys(),bs(),gs(),_s(),xs()]).optional()})),ys=H(()=>B({hookEventName:F(`Elicitation`),action:L([`accept`,`decline`,`cancel`]).optional(),content:P(j(),N()).optional()}).describe(`Hook-specific output for the Elicitation event. Return this to programmatically accept or decline an MCP elicitation request.`)),bs=H(()=>B({hookEventName:F(`ElicitationResult`),action:L([`accept`,`decline`,`cancel`]).optional(),content:P(j(),N()).optional()}).describe(`Hook-specific output for the ElicitationResult event. Return this to override the action or content before the response is sent to the MCP server.`)),xs=H(()=>B({hookEventName:F(`WorktreeCreate`),worktreePath:j()}).describe(`Hook-specific output for the WorktreeCreate event. Provides the absolute path to the created worktree directory. Command hooks print the path on stdout instead.`));H(()=>I([as(),vs()]));var Ss=H(()=>B({key:j().describe(`Unique key for this option, returned in the response`),label:j().describe(`Display text for this option`),description:j().optional().describe(`Optional description shown below the label`)}));H(()=>B({prompt:j().describe(`Request ID. Presence of this key marks the line as a prompt request.`),message:j().describe(`The prompt message to display to the user`),options:z(Ss()).describe(`Available options for the user to choose from`)})),H(()=>B({prompt_response:j().describe(`The request ID from the corresponding prompt request`),selected:j().describe(`The key of the selected option`)}));var Cs=H(()=>B({name:j().describe(`Skill name (without the leading slash)`),description:j().describe(`Description of what the skill does`),argumentHint:j().describe(`Hint for skill arguments (e.g., "<file>")`)}).describe(`Information about an available skill (invoked via /command syntax).`)),ws=H(()=>B({name:j().describe(`Agent type identifier (e.g., "Explore")`),description:j().describe(`Description of when to use this agent`),model:j().optional().describe(`Model alias this agent uses. If omitted, inherits the parent's model`)}).describe(`Information about an available subagent that can be invoked via the Task tool.`)),Ts=H(()=>B({value:j().describe(`Model identifier to use in API calls`),displayName:j().describe(`Human-readable display name`),description:j().describe(`Description of the model's capabilities`),supportsAdaptiveThinking:R().optional().describe(`Whether this model supports adaptive thinking (Work Mate decides when and how much to think)`),supportsFastMode:R().optional().describe(`Whether this model supports fast mode`),supportsAutoMode:R().optional().describe(`Whether this model supports auto mode`)}).describe(`Information about an available model.`)),Es=H(()=>B({email:j().optional(),organization:j().optional(),subscriptionType:j().optional(),tokenSource:j().optional(),apiKeySource:j().optional(),apiProvider:L([`firstParty`,`bedrock`,`vertex`,`foundry`]).optional().describe(`Active API backend. Anthropic OAuth login only applies when "firstParty"; for 3P providers the other fields are absent and auth is external (AWS creds, gcloud ADC, etc.).`)}).describe(`Information about the logged in user's account.`)),Ds=H(()=>I([j(),P(j(),mo())])),Os=H(()=>B({description:j().describe(`Natural language description of when to use this agent`),tools:z(j()).optional().describe(`Array of allowed tool names. If omitted, inherits all tools from parent`),disallowedTools:z(j()).optional().describe(`Array of tool names to explicitly disallow for this agent`),prompt:j().describe(`The agent's system prompt`),model:j().optional().describe(`Model alias (e.g. 'sonnet', 'opus', 'haiku') or full model ID (e.g. 'claude-opus-4-5'). If omitted or 'inherit', uses the main model`),mcpServers:z(Ds()).optional(),criticalSystemReminder_EXPERIMENTAL:j().optional().describe(`Experimental: Critical reminder added to system prompt`),skills:z(j()).optional().describe(`Array of skill names to preload into the agent context`),initialPrompt:j().optional().describe(`Auto-submitted as the first user turn when this agent is the main thread agent. Slash commands are processed. Prepended to any user-provided prompt.`),maxTurns:M().int().positive().optional().describe(`Maximum number of agentic turns (API round-trips) before stopping`),background:R().optional().describe(`Run this agent as a background task (non-blocking, fire-and-forget) when invoked`),memory:L([`user`,`project`,`local`]).optional().describe(`Scope for auto-loading agent memory files. 'user' - ~/.workmate/agent-memory/<agentType>/, 'project' - .workmate/agent-memory/<agentType>/, 'local' - .workmate/agent-memory-local/<agentType>/`),permissionMode:Co().optional().describe(`Permission mode controlling how tool executions are handled`)}).describe(`Definition for a custom subagent that can be invoked via the Agent tool.`));H(()=>L([`user`,`project`,`local`]).describe(`Source for loading filesystem-based settings. 'user' - Global user settings (~/.workmate/settings.json). 'project' - Project settings (.workmate/settings.json). 'local' - Local settings (.workmate/settings.local.json).`)),H(()=>B({type:F(`local`).describe(`Plugin type. Currently only 'local' is supported`),path:j().describe(`Absolute or relative path to the plugin directory`)}).describe(`Configuration for loading a plugin.`)),H(()=>B({canRewind:R(),error:j().optional(),filesChanged:z(j()).optional(),insertions:M().optional(),deletions:M().optional()}).describe(`Result of a rewindFiles operation.`));var ks=H(()=>N()),As=H(()=>N()),js=H(()=>N()),Q=H(()=>j()),Ms=H(()=>N()),Ns=H(()=>L([`authentication_failed`,`billing_error`,`rate_limit`,`invalid_request`,`server_error`,`unknown`,`max_output_tokens`])),Ps=H(()=>I([F(`compacting`),ar()])),Fs=H(()=>B({type:F(`user`),message:ks(),parent_tool_use_id:j().nullable(),isSynthetic:R().optional(),tool_use_result:N().optional(),priority:L([`now`,`next`,`later`]).optional(),timestamp:j().optional().describe(`ISO timestamp when the message was created on the originating process. Older emitters omit it; consumers should fall back to receive time.`)})),Is=H(()=>Fs().extend({uuid:Q().optional(),session_id:j().optional()})),Ls=H(()=>Fs().extend({uuid:Q(),session_id:j(),isReplay:F(!0)})),Rs=H(()=>B({status:L([`allowed`,`allowed_warning`,`rejected`]),resetsAt:M().optional(),rateLimitType:L([`five_hour`,`seven_day`,`seven_day_opus`,`seven_day_sonnet`,`overage`]).optional(),utilization:M().optional(),overageStatus:L([`allowed`,`allowed_warning`,`rejected`]).optional(),overageResetsAt:M().optional(),overageDisabledReason:L([`overage_not_provisioned`,`org_level_disabled`,`org_level_disabled_until`,`out_of_credits`,`seat_tier_level_disabled`,`member_level_disabled`,`seat_tier_zero_credit_limit`,`group_zero_credit_limit`,`member_zero_credit_limit`,`org_service_level_disabled`,`org_service_zero_credit_limit`,`no_limits_configured`,`unknown`]).optional(),isUsingOverage:R().optional(),surpassedThreshold:M().optional()}).describe(`Rate limit information for claude.ai subscription users.`)),zs=H(()=>B({type:F(`assistant`),message:As(),parent_tool_use_id:j().nullable(),error:Ns().optional(),uuid:Q(),session_id:j()})),Bs=H(()=>B({type:F(`rate_limit_event`),rate_limit_info:Rs(),uuid:Q(),session_id:j()}).describe(`Rate limit event emitted when rate limit info changes.`)),Vs=H(()=>B({type:F(`streamlined_text`),text:j().describe(`Text content preserved from the assistant message`),session_id:j(),uuid:Q()}).describe(`@internal Streamlined text message - replaces SDKAssistantMessage in streamlined output. Text content preserved, thinking and tool_use blocks removed.`)),Hs=H(()=>B({type:F(`streamlined_tool_use_summary`),tool_summary:j().describe(`Summary of tool calls (e.g., "Read 2 files, wrote 1 file")`),session_id:j(),uuid:Q()}).describe(`@internal Streamlined tool use summary - replaces tool_use blocks in streamlined output with a cumulative summary string.`)),Us=H(()=>B({tool_name:j(),tool_use_id:j(),tool_input:P(j(),N())})),Ws=H(()=>B({type:F(`result`),subtype:F(`success`),duration_ms:M(),duration_api_ms:M(),is_error:R(),num_turns:M(),result:j(),stop_reason:j().nullable(),total_cost_usd:M(),usage:Ms(),modelUsage:P(j(),no()),permission_denials:z(Us()),structured_output:N().optional(),fast_mode_state:mc().optional(),uuid:Q(),session_id:j()})),Gs=H(()=>B({type:F(`result`),subtype:L([`error_during_execution`,`error_max_turns`,`error_max_budget_usd`,`error_max_structured_output_retries`]),duration_ms:M(),duration_api_ms:M(),is_error:R(),num_turns:M(),stop_reason:j().nullable(),total_cost_usd:M(),usage:Ms(),modelUsage:P(j(),no()),permission_denials:z(Us()),errors:z(j()),fast_mode_state:mc().optional(),uuid:Q(),session_id:j()})),Ks=H(()=>I([Ws(),Gs()])),qs=H(()=>B({type:F(`system`),subtype:F(`init`),agents:z(j()).optional(),apiKeySource:ao(),betas:z(j()).optional(),claude_code_version:j(),cwd:j(),tools:z(j()),mcp_servers:z(B({name:j(),status:j()})),model:j(),permissionMode:Co(),slash_commands:z(j()),output_style:j(),skills:z(j()),plugins:z(B({name:j(),path:j(),source:j().optional().describe(`@internal Plugin source identifier in "name\\@marketplace" format. Sentinels: "name\\@inline" for --plugin-dir, "name\\@builtin" for built-in plugins.`)})),fast_mode_state:mc().optional(),uuid:Q(),session_id:j()})),Js=H(()=>B({type:F(`stream_event`),event:js(),parent_tool_use_id:j().nullable(),uuid:Q(),session_id:j()})),Ys=H(()=>B({type:F(`system`),subtype:F(`compact_boundary`),compact_metadata:B({trigger:L([`manual`,`auto`]),pre_tokens:M(),preserved_segment:B({head_uuid:Q(),anchor_uuid:Q(),tail_uuid:Q()}).optional().describe(`Relink info for messagesToKeep. Loaders splice the preserved segment at anchor_uuid (summary for suffix-preserving, boundary for prefix-preserving partial compact) so resume includes preserved content. Unset when compaction summarizes everything (no messagesToKeep).`)}),uuid:Q(),session_id:j()})),Xs=H(()=>B({type:F(`system`),subtype:F(`status`),status:Ps(),permissionMode:Co().optional(),uuid:Q(),session_id:j()})),Zs=H(()=>B({type:F(`system`),subtype:F(`post_turn_summary`),summarizes_uuid:j(),status_category:L([`blocked`,`waiting`,`completed`,`review_ready`,`failed`]),status_detail:j(),is_noteworthy:R(),title:j(),description:j(),recent_action:j(),needs_action:j(),artifact_urls:z(j()),uuid:Q(),session_id:j()}).describe(`@internal Background post-turn summary emitted after each assistant turn. summarizes_uuid points to the assistant message this summarizes.`)),Qs=H(()=>B({type:F(`system`),subtype:F(`api_retry`),attempt:M(),max_retries:M(),retry_delay_ms:M(),error_status:M().nullable(),error:Ns(),uuid:Q(),session_id:j()}).describe(`Emitted when an API request fails with a retryable error and will be retried after a delay. error_status is null for connection errors (e.g. timeouts) that had no HTTP response.`)),$s=H(()=>B({type:F(`system`),subtype:F(`local_command_output`),content:j(),uuid:Q(),session_id:j()}).describe(`Output from a local slash command (e.g. /voice, /cost). Displayed as assistant-style text in the transcript.`)),ec=H(()=>B({type:F(`system`),subtype:F(`hook_started`),hook_id:j(),hook_name:j(),hook_event:j(),uuid:Q(),session_id:j()})),tc=H(()=>B({type:F(`system`),subtype:F(`hook_progress`),hook_id:j(),hook_name:j(),hook_event:j(),stdout:j(),stderr:j(),output:j(),uuid:Q(),session_id:j()})),nc=H(()=>B({type:F(`system`),subtype:F(`hook_response`),hook_id:j(),hook_name:j(),hook_event:j(),output:j(),stdout:j(),stderr:j(),exit_code:M().optional(),outcome:L([`success`,`error`,`cancelled`]),uuid:Q(),session_id:j()})),rc=H(()=>B({type:F(`tool_progress`),tool_use_id:j(),tool_name:j(),parent_tool_use_id:j().nullable(),elapsed_time_seconds:M(),task_id:j().optional(),uuid:Q(),session_id:j()})),ic=H(()=>B({type:F(`auth_status`),isAuthenticating:R(),output:z(j()),error:j().optional(),uuid:Q(),session_id:j()})),ac=H(()=>B({type:F(`system`),subtype:F(`files_persisted`),files:z(B({filename:j(),file_id:j()})),failed:z(B({filename:j(),error:j()})),processed_at:j(),uuid:Q(),session_id:j()})),oc=H(()=>B({type:F(`system`),subtype:F(`task_notification`),task_id:j(),tool_use_id:j().optional(),status:L([`completed`,`failed`,`stopped`]),output_file:j(),summary:j(),usage:B({total_tokens:M(),tool_uses:M(),duration_ms:M()}).optional(),uuid:Q(),session_id:j()})),sc=H(()=>B({type:F(`system`),subtype:F(`task_started`),task_id:j(),tool_use_id:j().optional(),description:j(),task_type:j().optional(),workflow_name:j().optional().describe(`meta.name from the workflow script (e.g. 'spec'). Only set when task_type is 'local_workflow'.`),prompt:j().optional(),uuid:Q(),session_id:j()})),cc=H(()=>B({type:F(`system`),subtype:F(`session_state_changed`),state:L([`idle`,`running`,`requires_action`]),uuid:Q(),session_id:j()}).describe(`Mirrors notifySessionStateChanged. 'idle' fires after heldBackResult flushes and the bg-agent do-while exits — authoritative turn-over signal.`)),lc=H(()=>B({type:F(`system`),subtype:F(`task_progress`),task_id:j(),tool_use_id:j().optional(),description:j(),usage:B({total_tokens:M(),tool_uses:M(),duration_ms:M()}),last_tool_name:j().optional(),summary:j().optional(),uuid:Q(),session_id:j()})),uc=H(()=>B({type:F(`tool_use_summary`),summary:j(),preceding_tool_use_ids:z(j()),uuid:Q(),session_id:j()})),dc=H(()=>B({type:F(`system`),subtype:F(`elicitation_complete`),mcp_server_name:j(),elicitation_id:j(),uuid:Q(),session_id:j()}).describe(`Emitted when an MCP server confirms that a URL-mode elicitation is complete.`)),fc=H(()=>B({type:F(`prompt_suggestion`),suggestion:j(),uuid:Q(),session_id:j()}).describe(`Predicted next user prompt, emitted after each turn when promptSuggestions is enabled.`));H(()=>B({sessionId:j().describe(`Unique session identifier (UUID).`),summary:j().describe(`Display title for the session: custom title, auto-generated summary, or first prompt.`),lastModified:M().describe(`Last modified time in milliseconds since epoch.`),fileSize:M().optional().describe(`File size in bytes. Only populated for local JSONL storage.`),customTitle:j().optional().describe(`User-set session title via /rename.`),firstPrompt:j().optional().describe(`First meaningful user prompt in the session.`),gitBranch:j().optional().describe(`Git branch at the end of the session.`),cwd:j().optional().describe(`Working directory for the session.`),tag:j().optional().describe(`User-set session tag.`),createdAt:M().optional().describe(`Creation time in milliseconds since epoch, extracted from the first entry's timestamp.`)}).describe(`Session metadata returned by listSessions and getSessionInfo.`));var pc=H(()=>I([zs(),Is(),Ls(),Ks(),qs(),Js(),Ys(),Xs(),Qs(),$s(),ec(),tc(),nc(),rc(),ic(),oc(),sc(),lc(),cc(),ac(),uc(),Bs(),dc(),fc()])),mc=H(()=>L([`off`,`cooldown`,`on`]).describe(`Fast mode state: off, in cooldown after rate limit, or actively enabled.`));sr(),cr();var hc=H(()=>N()),gc=H(()=>B({matcher:j().optional(),hookCallbackIds:z(j()),timeout:M().optional()}).describe(`Configuration for matching and routing hook callbacks.`)),_c=H(()=>B({subtype:F(`initialize`),hooks:P(To(),z(gc())).optional(),sdkMcpServers:z(j()).optional(),jsonSchema:P(j(),N()).optional(),systemPrompt:j().optional(),appendSystemPrompt:j().optional(),agents:P(j(),Os()).optional(),promptSuggestions:R().optional(),agentProgressSummaries:R().optional()}).describe(`Initializes the SDK session with hooks, MCP servers, and agent configuration.`));H(()=>B({commands:z(Cs()),agents:z(ws()),output_style:j(),available_output_styles:z(j()),models:z(Ts()),account:Es(),pid:M().optional().describe(`@internal CLI process PID for tmux socket isolation`),fast_mode_state:mc().optional()}).describe(`Response from session initialization with available commands, models, and account info.`));var vc=H(()=>B({subtype:F(`interrupt`)}).describe(`Interrupts the currently running conversation turn.`)),yc=H(()=>B({subtype:F(`can_use_tool`),tool_name:j(),input:P(j(),N()),permission_suggestions:z(xo()).optional(),blocked_path:j().optional(),decision_reason:j().optional(),title:j().optional(),display_name:j().optional(),tool_use_id:j(),agent_id:j().optional(),description:j().optional()}).describe(`Requests permission to use a tool with the given input.`)),bc=H(()=>B({subtype:F(`set_permission_mode`),mode:Co()}).describe(`Sets the permission mode for tool execution handling.`)),xc=H(()=>B({subtype:F(`set_model`),model:j().optional()}).describe(`Sets the model to use for subsequent conversation turns.`)),Sc=H(()=>B({subtype:F(`set_max_thinking_tokens`),max_thinking_tokens:M().nullable()}).describe(`Sets the maximum number of thinking tokens for extended thinking.`)),Cc=H(()=>B({subtype:F(`mcp_status`)}).describe(`Requests the current status of all MCP server connections.`));H(()=>B({mcpServers:z(_o())}).describe(`Response containing the current status of all MCP server connections.`));var wc=H(()=>B({subtype:F(`get_context_usage`)}).describe(`Requests a breakdown of current context window usage by category.`)),Tc=H(()=>B({name:j(),tokens:M(),color:j(),isDeferred:R().optional()})),Ec=H(()=>B({color:j(),isFilled:R(),categoryName:j(),tokens:M(),percentage:M(),squareFullness:M()}));H(()=>B({categories:z(Tc()),totalTokens:M(),maxTokens:M(),rawMaxTokens:M(),percentage:M(),gridRows:z(z(Ec())),model:j(),memoryFiles:z(B({path:j(),type:j(),tokens:M()})),mcpTools:z(B({name:j(),serverName:j(),tokens:M(),isLoaded:R().optional()})),deferredBuiltinTools:z(B({name:j(),tokens:M(),isLoaded:R()})).optional(),systemTools:z(B({name:j(),tokens:M()})).optional(),systemPromptSections:z(B({name:j(),tokens:M()})).optional(),agents:z(B({agentType:j(),source:j(),tokens:M()})),slashCommands:B({totalCommands:M(),includedCommands:M(),tokens:M()}).optional(),skills:B({totalSkills:M(),includedSkills:M(),tokens:M(),skillFrontmatter:z(B({name:j(),source:j(),tokens:M()}))}).optional(),autoCompactThreshold:M().optional(),isAutoCompactEnabled:R(),messageBreakdown:B({toolCallTokens:M(),toolResultTokens:M(),attachmentTokens:M(),assistantMessageTokens:M(),userMessageTokens:M(),toolCallsByType:z(B({name:j(),callTokens:M(),resultTokens:M()})),attachmentsByType:z(B({name:j(),tokens:M()}))}).optional(),apiUsage:B({input_tokens:M(),output_tokens:M(),cache_creation_input_tokens:M(),cache_read_input_tokens:M()}).nullable()}).describe(`Breakdown of current context window usage by category (system prompt, tools, messages, etc.).`));var Dc=H(()=>B({subtype:F(`rewind_files`),user_message_id:j(),dry_run:R().optional()}).describe(`Rewinds file changes made since a specific user message.`));H(()=>B({canRewind:R(),error:j().optional(),filesChanged:z(j()).optional(),insertions:M().optional(),deletions:M().optional()}).describe(`Result of a rewindFiles operation.`));var Oc=H(()=>B({subtype:F(`cancel_async_message`),message_uuid:j()}).describe(`Drops a pending async user message from the command queue by uuid. No-op if already dequeued for execution.`));H(()=>B({cancelled:R()}).describe(`Result of a cancel_async_message operation. cancelled=false means the message was not in the queue (already dequeued or never enqueued).`));var kc=H(()=>B({subtype:F(`seed_read_state`),path:j(),mtime:M()}).describe(`Seeds the readFileState cache with a path+mtime entry. Use when a prior Read was removed from context (e.g. by snip) so Edit validation would fail despite the client having observed the Read. The mtime lets the CLI detect if the file changed since the seeded Read — same staleness check as the normal path.`)),Ac=H(()=>B({subtype:F(`hook_callback`),callback_id:j(),input:is(),tool_use_id:j().optional()}).describe(`Delivers a hook callback with its input data.`)),jc=H(()=>B({subtype:F(`mcp_message`),server_name:j(),message:hc()}).describe(`Sends a JSON-RPC message to a specific MCP server.`)),Mc=H(()=>B({subtype:F(`mcp_set_servers`),servers:P(j(),mo())}).describe(`Replaces the set of dynamically managed MCP servers.`));H(()=>B({added:z(j()),removed:z(j()),errors:P(j(),j())}).describe(`Result of replacing the set of dynamically managed MCP servers.`));var Nc=H(()=>B({subtype:F(`reload_plugins`)}).describe(`Reloads plugins from disk and returns the refreshed session components.`));H(()=>B({commands:z(Cs()),agents:z(ws()),plugins:z(B({name:j(),path:j(),source:j().optional()})),mcpServers:z(_o()),error_count:M()}).describe(`Refreshed commands, agents, plugins, and MCP server status after reload.`));var Pc=H(()=>B({subtype:F(`mcp_reconnect`),serverName:j()}).describe(`Reconnects a disconnected or failed MCP server.`)),Fc=H(()=>B({subtype:F(`mcp_toggle`),serverName:j(),enabled:R()}).describe(`Enables or disables an MCP server.`)),Ic=H(()=>B({subtype:F(`stop_task`),task_id:j()}).describe(`Stops a running task.`)),Lc=H(()=>B({subtype:F(`apply_flag_settings`),settings:P(j(),N())}).describe(`Merges the provided settings into the flag settings layer, updating the active configuration.`)),Rc=H(()=>B({subtype:F(`get_settings`)}).describe(`Returns the effective merged settings and the raw per-source settings.`));H(()=>B({effective:P(j(),N()),sources:z(B({source:L([`userSettings`,`projectSettings`,`localSettings`,`flagSettings`,`policySettings`]),settings:P(j(),N())})).describe(`Ordered low-to-high priority — later entries override earlier ones.`),applied:B({model:j()}).optional().describe("Runtime-resolved values after env overrides, session state, and model-specific defaults are applied. Unlike `effective` (disk merge), these reflect what will actually be sent to the API.")}).describe(`Effective merged settings plus raw per-source settings in merge order.`));var zc=H(()=>B({subtype:F(`elicitation`),mcp_server_name:j(),message:j(),mode:L([`form`,`url`]).optional(),url:j().optional(),elicitation_id:j().optional(),requested_schema:P(j(),N()).optional()}).describe(`Requests the SDK consumer to handle an MCP elicitation (user input request).`)),Bc=H(()=>B({action:L([`accept`,`decline`,`cancel`]),content:P(j(),N()).optional()}).describe(`Response from the SDK consumer for an elicitation request.`)),Vc=H(()=>I([vc(),yc(),_c(),bc(),xc(),Sc(),Cc(),wc(),Ac(),jc(),Dc(),Oc(),kc(),Mc(),Nc(),Pc(),Fc(),Ic(),Lc(),Rc(),zc()])),Hc=H(()=>B({type:F(`control_request`),request_id:j(),request:Vc()})),Uc=H(()=>B({subtype:F(`success`),request_id:j(),response:P(j(),N()).optional()})),Wc=H(()=>B({subtype:F(`error`),request_id:j(),error:j(),pending_permission_requests:z(or(()=>Hc())).optional()})),Gc=H(()=>B({type:F(`control_response`),response:I([Uc(),Wc()])})),Kc=H(()=>B({type:F(`control_cancel_request`),request_id:j()}).describe(`Cancels a currently open control request.`)),qc=H(()=>B({type:F(`keep_alive`)}).describe(`Keep-alive message to maintain WebSocket connection.`)),Jc=H(()=>B({type:F(`update_environment_variables`),variables:P(j(),j())}).describe(`Updates environment variables at runtime.`));H(()=>I([pc(),Vs(),Hs(),Zs(),Gc(),Hc(),Kc(),qc()])),H(()=>I([Is(),Hc(),Gc(),qc(),Jc()])),Re(),sr(),cr(),ie(),re(),H(()=>V.object({tool_name:V.string().describe(`The name of the tool requesting permission`),input:V.record(V.string(),V.unknown()).describe(`The input for the tool`),tool_use_id:V.string().optional().describe(`The unique tool use request ID`)}));var Yc=H(()=>V.enum([`user_temporary`,`user_permanent`,`user_reject`]).optional().catch(void 0)),Xc=H(()=>V.object({behavior:V.literal(`allow`),updatedInput:V.record(V.string(),V.unknown()),updatedPermissions:V.array(Wn()).optional().catch(e=>{G(`Malformed updatedPermissions from SDK host ignored: ${e.error.issues[0]?.message??`unknown`}`,{level:`warn`})}),toolUseID:V.string().optional(),decisionClassification:Yc()})),Zc=H(()=>V.object({behavior:V.literal(`deny`),message:V.string(),interrupt:V.boolean().optional(),toolUseID:V.string().optional(),decisionClassification:Yc()})),Qc=H(()=>V.union([Xc(),Zc()]));function $c(e,t,n,r){let i={type:`permissionPromptTool`,permissionPromptToolName:t.name,toolResult:e};if(e.behavior===`allow`){let t=e.updatedPermissions;t&&(r.setAppState(e=>({...e,toolPermissionContext:He(e.toolPermissionContext,t)})),yn(t));let a=Object.keys(e.updatedInput).length>0?e.updatedInput:n;return{...e,updatedInput:a,decisionReason:i}}else e.behavior===`deny`&&e.interrupt&&(G(`SDK permission prompt deny+interrupt: tool=${t.name} message=${e.message}`),r.abortController.abort());return{...e,decisionReason:i}}xr(),Rr(),Kr(),Ur(),Ri(),Fi(),Gi(),kt(),ht(),g(),Cn(),Ki(),ye(),rn(),A(),l(),Zi(),se(),x(),T(),we(),cn(),C(),be(),pt(),ft(),Bt(),We();var el=/\u2028|\u2029/g;function tl(e){return e.replace(el,e=>e===`\u2028`?`\\u2028`:`\\u2029`)}function nl(e){return tl(Cr(e))}Ar(),Pr(),sr(),ie();var rl=`SandboxNetworkAccess`;function il(e){if(e){if(e.type===`classifier`)return e.reason;switch(e.type){case`rule`:case`mode`:case`subcommandResults`:case`permissionPromptTool`:return;case`hook`:case`asyncAgent`:case`sandboxOverride`:case`workingDir`:case`safetyCheck`:case`other`:return e.reason}}}function al(e,t,n,r){let i;try{i=e.getActivityDescription?.(t)??e.getToolUseSummary?.(t)??e.userFacingName(t)}catch{i=e.name}return{tool_name:e.name,action_description:i,tool_use_id:n,request_id:r,input:t}}var ol=1e3,sl=class{constructor(e,t){o(this,`input`,void 0),o(this,`replayUserMessages`,void 0),o(this,`structuredInput`,void 0),o(this,`pendingRequests`,new Map),o(this,`restoredWorkerState`,Promise.resolve(null)),o(this,`inputClosed`,!1),o(this,`unexpectedResponseCallback`,void 0),o(this,`resolvedToolUseIds`,new Set),o(this,`prependedLines`,[]),o(this,`onControlRequestSent`,void 0),o(this,`onControlRequestResolved`,void 0),o(this,`outbound`,new Ge),this.input=e,this.replayUserMessages=t,this.input=e,this.structuredInput=this.read()}trackResolvedToolUseId(e){let t=e.request;if(t.subtype===`can_use_tool`&&(this.resolvedToolUseIds.add(t.tool_use_id),this.resolvedToolUseIds.size>ol)){let e=this.resolvedToolUseIds.values().next().value;e!==void 0&&this.resolvedToolUseIds.delete(e)}}flushInternalEvents(){return Promise.resolve()}get internalEventsPending(){return 0}prependUserMessage(e){this.prependedLines.push(`${Cr({type:`user`,content:e,uuid:``,session_id:``,message:{role:`user`,content:e},parent_tool_use_id:null})}\n`)}async*read(){let e=``,t=async function*(){for(;;){this.prependedLines.length>0&&(e=this.prependedLines.join(``)+e,this.prependedLines=[]);let t=e.indexOf(`
2
+ `);if(t===-1)break;let n=e.slice(0,t);e=e.slice(t+1);let r=await this.processLine(n);r&&($r(`info`,`cli_stdin_message_parsed`,{type:r.type}),yield r)}}.bind(this);yield*t();for await(let n of this.input)e+=n,yield*t();if(e){let t=await this.processLine(e);t&&(yield t)}this.inputClosed=!0;for(let e of this.pendingRequests.values())e.reject(Error(`Tool permission stream closed before response received`))}getPendingPermissionRequests(){return Array.from(this.pendingRequests.values()).map(e=>e.request).filter(e=>e.request.subtype===`can_use_tool`)}setUnexpectedResponseCallback(e){this.unexpectedResponseCallback=e}injectControlResponse(e){let t=e.response,n=t?.request_id;if(!n)return;let r=this.pendingRequests.get(n);if(r)if(this.trackResolvedToolUseId(r.request),this.pendingRequests.delete(n),this.write({type:`control_cancel_request`,request_id:n}),t.subtype===`error`)r.reject(Error(t.error));else{let e=t.response;if(r.schema)try{r.resolve(r.schema.parse(e))}catch(e){r.reject(e)}else r.resolve({})}}setOnControlRequestSent(e){this.onControlRequestSent=e}setOnControlRequestResolved(e){this.onControlRequestResolved=e}async processLine(e){if(e)try{let t=ha(Er(e));if(t.type===`keep_alive`)return;if(t.type===`update_environment_variables`){let e=t.variables??{},n=Object.keys(e);for(let[t,n]of Object.entries(e))process.env[t]=n;G(`[structuredIO] applied update_environment_variables: ${n.join(`, `)}`);return}if(t.type===`control_response`){let e=`uuid`in t&&typeof t.uuid==`string`?t.uuid:void 0;e&&zt(e,`completed`);let n=t.response,r=this.pendingRequests.get(n.request_id);if(!r){let e=(n.subtype===`success`?n.response:void 0)?.toolUseID;if(typeof e==`string`&&this.resolvedToolUseIds.has(e)){G(`Ignoring duplicate control_response for already-resolved toolUseID=${e} request_id=${n.request_id}`);return}this.unexpectedResponseCallback&&await this.unexpectedResponseCallback(t);return}if(this.trackResolvedToolUseId(r.request),this.pendingRequests.delete(n.request_id),r.request.request.subtype===`can_use_tool`&&this.onControlRequestResolved&&this.onControlRequestResolved(n.request_id),n.subtype===`error`){r.reject(Error(n.error??`Unknown error`));return}let i=n.response;if(r.schema)try{r.resolve(r.schema.parse(i))}catch(e){r.reject(e)}else r.resolve({});return this.replayUserMessages?t:void 0}if(t.type!==`user`&&t.type!==`control_request`&&t.type!==`assistant`&&t.type!==`system`){G(`Ignoring unknown message type: ${t.type}`,{level:`warn`});return}return t.type===`control_request`?(t.request||cl(`Error: Missing request on control_request`),t):(t.type===`assistant`||t.type===`system`||t.message?.role!==`user`&&cl(`Error: Expected message role 'user', got '${t.message?.role}'`),t)}catch(t){console.error(`Error parsing streaming input line: ${e}: ${t}`),process.exit(1)}}async write(e){K(`${nl(e)}\n`)}async sendRequest(e,t,n,r=Y()){let i={type:`control_request`,request_id:r,request:e};if(this.inputClosed)throw Error(`Stream closed`);if(n?.aborted)throw Error(`Request aborted`);this.outbound.enqueue(i),e.subtype===`can_use_tool`&&this.onControlRequestSent&&this.onControlRequestSent(i);let a=()=>{this.outbound.enqueue({type:`control_cancel_request`,request_id:r});let e=this.pendingRequests.get(r);e&&(this.trackResolvedToolUseId(e.request),e.reject(new wr))};n&&n.addEventListener(`abort`,a,{once:!0});try{return await new Promise((n,i)=>{this.pendingRequests.set(r,{request:{type:`control_request`,request_id:r,request:e},resolve:e=>{n(e)},reject:i,schema:t})})}finally{n&&n.removeEventListener(`abort`,a),this.pendingRequests.delete(r)}}createCanUseTool(e){return async(t,n,r,i,a,o)=>{let s=o??await h(t,n,r,i,a);if(s.behavior===`allow`||s.behavior===`deny`)return s;let c=new AbortController,l=r.abortController.signal,u=()=>c.abort();l.addEventListener(`abort`,u,{once:!0});try{let i=ll(t.name,a,n,r,s.suggestions).then(e=>({source:`hook`,decision:e})),o=Y();e?.(al(t,n,a,o));let l=this.sendRequest({subtype:`can_use_tool`,tool_name:t.name,input:n,permission_suggestions:s.suggestions,blocked_path:s.blockedPath,decision_reason:il(s.decisionReason),tool_use_id:a,agent_id:r.agentId},Qc(),c.signal,o).then(e=>({source:`sdk`,result:e})),u=await Promise.race([i,l]);return u.source===`hook`?u.decision?(l.catch(()=>{}),c.abort(),u.decision):$c((await l).result,t,n,r):$c(u.result,t,n,r)}catch(e){return $c({behavior:`deny`,message:`Tool permission request failed: ${e}`,toolUseID:a},t,n,r)}finally{this.getPendingPermissionRequests().length===0&&$i(`running`),l.removeEventListener(`abort`,u)}}}createHookCallback(e,t){return{type:`callback`,timeout:t,callback:async(t,n,r)=>{try{return await this.sendRequest({subtype:`hook_callback`,callback_id:e,input:t,tool_use_id:n||void 0},Jn(),r)}catch(t){return console.error(`Error in hook callback ${e}:`,t),{}}}}}async handleElicitation(e,t,n,r,i,a,o){try{return await this.sendRequest({subtype:`elicitation`,mcp_server_name:e,message:t,mode:i,url:a,elicitation_id:o,requested_schema:n},Bc(),r)}catch{return{action:`cancel`}}}createSandboxAskCallback(){return async e=>{try{return(await this.sendRequest({subtype:`can_use_tool`,tool_name:rl,input:{host:e.host},tool_use_id:Y(),description:`Allow network connection to ${e.host}?`},Qc())).behavior===`allow`}catch{return!1}}}async sendMcpMessage(e,t){return(await this.sendRequest({subtype:`mcp_message`,server_name:e,message:t},B({mcp_response:rr()}))).mcp_response}};function cl(e){console.error(e),process.exit(1)}async function ll(e,t,n,r,i){let a=r.getAppState().toolPermissionContext.mode,o=Je(e,t,n,r,a,i,r.abortController.signal);for await(let e of o)if(e.permissionRequestResult&&(e.permissionRequestResult.behavior===`allow`||e.permissionRequestResult.behavior===`deny`)){let t=e.permissionRequestResult;if(t.behavior===`allow`){let e=t.updatedInput||n,i=t.updatedPermissions??[];if(i.length>0){yn(i);let e=He(r.getAppState().toolPermissionContext,i);r.setAppState(t=>t.toolPermissionContext===e?t:{...t,toolPermissionContext:e})}return{behavior:`allow`,updatedInput:e,userModified:!1,decisionReason:{type:`hook`,hookName:`PermissionRequest`}}}else return{behavior:`deny`,message:t.message||`Permission denied by PermissionRequest hook`,decisionReason:{type:`hook`,hookName:`PermissionRequest`}}}}Bi(),ba();function ul(e,t={},r,i){if(n(process.env.CLAUDE_CODE_USE_CCR_V2)){let n=new to(e.href);return n.protocol===`wss:`?n.protocol=`https:`:n.protocol===`ws:`&&(n.protocol=`http:`),n.pathname=`${n.pathname.replace(/\/$/,``)}/worker/events/stream`,new xa(n,t,r,i)}if(e.protocol===`ws:`||e.protocol===`wss:`)return n(process.env.CLAUDE_CODE_POST_FOR_SESSION_INGRESS_V2)?new ya(e,t,r,i):new va(e,t,r,i);throw Error(`Unsupported protocol: ${e.protocol}`)}rn(),Ar(),Qr(),r(),Tr(),Xr(),Zi(),ba(),a();var dl=class extends sl{constructor(e,t,r){let i=new Xa({encoding:`utf8`});super(i,r),o(this,`url`,void 0),o(this,`transport`,void 0),o(this,`inputStream`,void 0),o(this,`isBridge`,!1),o(this,`isDebug`,!1),o(this,`ccrClient`,null),o(this,`keepAliveTimer`,null),this.inputStream=i,this.url=new to(e);let a={},s=Vi();s?a.Authorization=`Bearer ${s}`:G(`[remote-io] No session ingress token available`,{level:`error`});let c=process.env.CLAUDE_CODE_ENVIRONMENT_RUNNER_VERSION;c&&(a[`x-environment-runner-version`]=c);let l=()=>{let e={},t=Vi();t&&(e.Authorization=`Bearer ${t}`);let n=process.env.CLAUDE_CODE_ENVIRONMENT_RUNNER_VERSION;return n&&(e[`x-environment-runner-version`]=n),e};if(this.transport=ul(this.url,a,U(),l),this.isBridge=process.env.CLAUDE_CODE_ENVIRONMENT_KIND===`bridge`,this.isDebug=Or(),this.transport.setOnData(e=>{this.inputStream.write(e),this.isBridge&&this.isDebug&&K(e.endsWith(`
3
+ `)?e:`${e}\n`)}),this.transport.setOnClose(()=>{this.inputStream.end()}),n(process.env.CLAUDE_CODE_USE_CCR_V2)){if(!(this.transport instanceof xa))throw Error(`CCR v2 requires SSETransport; check getTransportForUrl`);this.ccrClient=new _a(this.transport,this.url);let e=this.ccrClient.initialize();this.restoredWorkerState=e.catch(()=>null),e.catch(e=>{$r(`error`,`cli_worker_lifecycle_init_failed`,{reason:e instanceof ga?e.reason:`unknown`}),q(Error(`CCRClient initialization failed: ${W(e)}`)),et(1,`other`)}),jr(async()=>this.ccrClient?.close()),it((e,t,n)=>this.ccrClient.writeInternalEvent(e,t,n)),Pt(()=>this.ccrClient.readInternalEvents(),()=>this.ccrClient.readSubagentInternalEvents());let t={started:`processing`,completed:`processed`};Ft((e,n)=>{this.ccrClient?.reportDelivery(e,t[n])}),Xi((e,t)=>{this.ccrClient?.reportState(e,t)}),qi(e=>{this.ccrClient?.reportMetadata(e)},{replayCurrent:!0})}this.transport.connect();let u=ma().session_keepalive_interval_v2_ms;if(this.isBridge&&u>0&&(this.keepAliveTimer=setInterval(()=>{G(`[remote-io] keep_alive sent`),this.write({type:`keep_alive`}).catch(e=>{G(`[remote-io] keep_alive write failed: ${W(e)}`)})},u),this.keepAliveTimer.unref?.()),jr(async()=>this.close()),t){let e=this.inputStream;(async()=>{for await(let n of t)e.write(`${String(n).replace(/\n$/,``)}\n`)})()}}flushInternalEvents(){return this.ccrClient?.flushInternalEvents()??Promise.resolve()}get internalEventsPending(){return this.ccrClient?.internalEventsPending??0}async write(e){this.ccrClient?await this.ccrClient.writeEvent(e):await this.transport.write(e),this.isBridge&&(e.type===`control_request`||this.isDebug)&&K(`${nl(e)}\n`)}close(){this.keepAliveTimer&&(clearInterval(this.keepAliveTimer),this.keepAliveTimer=null),this.transport.close(),this.inputStream.end()}};Mi(),Ir(),zi(),[...Ii],Mr(),Ar();var fl=`[stdout-guard]`,pl=!1,$=``,ml=null;function hl(e){if(e.length===0)return!0;try{return JSON.parse(e),!0}catch{return!1}}function gl(){pl||(pl=!0,ml=process.stdout.write.bind(process.stdout),process.stdout.write=((e,t,n)=>{let r=typeof e==`string`?e:Buffer.from(e).toString(`utf-8`);$+=r;let i,a=!0;for(;(i=$.indexOf(`
4
+ `))!==-1;){let e=$.slice(0,i);$=$.slice(i+1),hl(e)?a=ml(`${e}\n`):(process.stderr.write(`${fl} ${e}\n`),G(`streamJsonStdoutGuard diverted non-JSON stdout line: ${e.slice(0,200)}`))}let o=typeof t==`function`?t:n;return o&&queueMicrotask(()=>o()),a}),jr(async()=>{$.length>0&&(ml&&hl($)?ml(`${$}\n`):process.stderr.write(`${fl} ${$}\n`),$=``),ml&&(process.stdout.write=ml,ml=null),pl=!1}))}Jr(),nt(),Hi(),ue(),v(),d(),Ni(),tn(),_(),ut(),Gn(),vn(),bn(),an(),le(),_t(),dn(),Aa(),Yn(),Tr(),ri(),Bi(),fn(),Ar(),l();function _l(e){let t=process.env.CLAUDE_CODE_EXIT_AFTER_STOP_DELAY,n=t?parseInt(t,10):null,r=n&&!isNaN(n)&&n>0,i=null,a=0;return{start(){i&&(clearTimeout(i),i=null),r&&(a=Date.now(),i=setTimeout(()=>{let t=Date.now()-a;e()&&t>=n&&(G(`Exiting after ${n}ms of idle time`),E())},n))},stop(){i&&(clearTimeout(i),i=null)}}}aa(),Kn(),Ot(),xn(),Sn();function vl(e){if(e.type!==`user`)return;let t=e.message?.content;if(!t||Array.isArray(t)&&t.length===0)return;let n=`uuid`in e&&typeof e.uuid==`string`?e.uuid:void 0;return{content:Array.isArray(t)?yl(t):t,uuid:n}}function yl(e){return e.some(bl)?e.map(e=>{if(!bl(e))return e;let t=e.source,n=typeof t.mediaType==`string`&&t.mediaType?t.mediaType:ln(e.source.data);return{...e,source:{type:`base64`,media_type:n,data:e.source.data}}}):e}function bl(e){return e.type!==`image`||e.source?.type!==`base64`?!1:!e.source.media_type}sr(),hr(),Ar(),r(),cr(),oa();var xl=3e4;function Sl(e){G(`[bridge:inbound-attach] ${e}`)}var Cl=H(()=>B({file_uuid:j(),file_name:j()})),wl=H(()=>z(Cl()));function Tl(e){if(typeof e!=`object`||!e||!(`file_attachments`in e))return[];let t=wl().safeParse(e.file_attachments);return t.success?t.data:[]}function El(e){return qa(e).replace(/[^a-zA-Z0-9._-]/g,`_`)||`attachment`}function Dl(){return Ya(t(),`uploads`,U())}async function Ol(e){let t=ca();if(!t){Sl(`skip: no oauth token`);return}let n;try{let r=`${sa()}/api/oauth/files/${encodeURIComponent(e.file_uuid)}/content`,i=await s.get(r,{headers:{Authorization:`Bearer ${t}`},responseType:`arraybuffer`,timeout:xl,validateStatus:()=>!0});if(i.status!==200){Sl(`fetch ${e.file_uuid} failed: status=${i.status}`);return}n=Buffer.from(i.data)}catch(t){Sl(`fetch ${e.file_uuid} threw: ${t}`);return}let r=El(e.file_name),i=(e.file_uuid.slice(0,8)||Y().slice(0,8)).replace(/[^a-zA-Z0-9_-]/g,`_`),a=Dl(),o=Ya(a,`${i}-${r}`);try{await Za(a,{recursive:!0}),await eo(o,n)}catch(e){Sl(`write ${o} failed: ${e}`);return}return Sl(`resolved ${e.file_uuid} → ${o} (${n.length} bytes)`),o}async function kl(e){if(e.length===0)return``;Sl(`resolving ${e.length} attachment(s)`);let t=(await Promise.all(e.map(Ol))).filter(e=>e!==void 0);return t.length===0?``:`${t.map(e=>`@"${e}"`).join(` `)} `}function Al(e,t){if(!t)return e;if(typeof e==`string`)return t+e;let n=e.findLastIndex(e=>e.type===`text`);if(n!==-1){let r=e[n];if(r.type===`text`)return[...e.slice(0,n),{...r,text:t+r.text},...e.slice(n+1)]}return[...e,{type:`text`,text:t.trimEnd()}]}async function jl(e,t){let n=Tl(e);return n.length===0?t:Al(t,await kl(n))}vi(),xe(),On(),Zt(),Ct(),lt(),pa(),Fa();function Ml(e){if(e.toLowerCase().endsWith(`.jsonl`))return{sessionId:Y(),ingressUrl:null,isUrl:!1,jsonlFile:e,isJsonlFile:!0};if(tt(e))return{sessionId:e,ingressUrl:null,isUrl:!1,jsonlFile:null,isJsonlFile:!1};try{let t=new URL(e);return{sessionId:Y(),ingressUrl:t.href,isUrl:!0,jsonlFile:null,isJsonlFile:!1}}catch{}return null}Ci(),me(),de(),b(),Kt(),Be(),Un(),dt(),At(),Tn(),_e(),ua(),Ra(),za(),Ar(),Pr();async function Nl(){try{let e=await Qa(xt(),`utf-8`),t=Br().safeParse(Er(e));return t.success?t.data:(G(`Invalid known_marketplaces.json in zip cache: ${t.error.message}`,{level:`error`}),{})}catch{return{}}}async function Pl(e){await En(xt(),Cr(e,null,2))}async function Fl(e,t){let n=Pn();if(!n)return;let r=await Il(t);r!==null&&await En(Ya(n,$t(e)),r)}async function Il(e){let t=[Ya(e,`.claude-plugin`,`marketplace.json`),Ya(e,`marketplace.json`),e];for(let e of t)try{return await Qa(e,`utf-8`)}catch{}return null}async function Ll(){let e=await Fe();for(let[t,n]of Object.entries(e))if(n.installLocation)try{await Fl(t,n.installLocation)}catch(e){G(`Failed to save marketplace JSON for ${t}: ${e}`)}await Pl({...await Nl(),...e})}si(),Mr(),Ar(),Qr(),ri(),le(),an();async function Rl(){let e=It();G(`installPluginsForHeadless: starting${e?` (zip cache mode)`:``}`);let t=await qe();t&&(qt(),Wt(`headlessPluginInstall: seed marketplaces registered`)),e&&(await Nr().mkdir(jt()),await Nr().mkdir(_n()));let n=Object.keys(w()).length,r={marketplaces_installed:0,delisted_count:0},i=t;try{if(n===0)G(`installPluginsForHeadless: no marketplaces declared`);else{let t=await Zr(`headless_marketplace_reconcile`,()=>Wa({skip:e?(e,t)=>!Vt(t):void 0,onProgress:e=>{e.type===`installed`?G(`installPluginsForHeadless: installed marketplace ${e.name}`):e.type===`failed`&&G(`installPluginsForHeadless: failed to install marketplace ${e.name}: ${e.error}`)}}),e=>({installed_count:e.installed.length,updated_count:e.updated.length,failed_count:e.failed.length,skipped_count:e.skipped.length}));t.skipped.length>0&&G(`installPluginsForHeadless: skipped ${t.skipped.length} marketplace(s) unsupported by zip cache: ${t.skipped.join(`, `)}`);let n=t.installed.length+t.updated.length;n>0&&(qt(),Wt(`headlessPluginInstall: marketplaces reconciled`),i=!0),r.marketplaces_installed=n}e&&await Ll();let t=await Da();return r.delisted_count=t.length,t.length>0&&(i=!0),i&&Wt(`headlessPluginInstall: plugins changed`),e&&jr(vt),i}catch(e){return q(e),!1}finally{J(`tengu_headless_plugin_install`,r)}}si(),Ar(),Qr(),rn(),Zi(),ri(),Xr(),A(),l(),Mr(),xr(),We(),hr(),pt(),Bt(),C(),Pr(),r(),Ka(),_t(),he(),S(),u(),Tr();var zl=1e4,Bl=new Set,Vl=[];function Hl(e){if(Bl.has(e))return!1;if(Bl.add(e),Vl.push(e),Vl.length>zl){let e=Vl.splice(0,Vl.length-zl);for(let t of e)Bl.delete(t)}return!0}function Ul(e){return typeof e==`string`?[{type:`text`,text:e}]:e}function Wl(e){return e.length===1?e[0]:e.every(e=>typeof e==`string`)?e.join(`
5
+ `):e.flatMap(Ul)}function Gl(e,t){return t!==void 0&&t.mode===`prompt`&&t.workload===e.workload&&t.isMeta===e.isMeta}async function Kl(e,t,r,i,a,o,s,c){if(mn.subscribe(e=>{Tt(e,r),Di()&&r(e=>{let t=e.settings,n=t.fastMode===!0&&!t.fastModePerSessionOptIn;return{...e,fastMode:n}})}),!na()&&n(process.env.CLAUDE_CODE_PROACTIVE)&&Qi(`command`),typeof Bun<`u`&&setInterval(()=>{process.memoryUsage.rss()>350*1024*1024?Bun.gc(!0):Bun.gc(!1)},1e3).unref(),bt(),Mn(`runHeadless_entry`),await Sa()&&await Ca(),Mn(`after_grove_check`),c.resumeSessionAt&&!c.resume){process.stderr.write(`Error: --resume-session-at requires --resume
6
+ `),E(1);return}if(c.rewindFiles&&!c.resume){process.stderr.write(`Error: --rewind-files requires --resume
7
+ `),E(1);return}if(c.rewindFiles&&e){process.stderr.write(`Error: --rewind-files is a standalone operation and cannot be used with a prompt
8
+ `),E(1);return}let l=nu(e,c);c.outputFormat===`stream-json`&&gl();let u=ot.getSandboxUnavailableReason();if(u){if(ot.isSandboxRequired()){process.stderr.write(`\nError: sandbox required but unavailable: ${u}\n sandbox.failIfUnavailable is set — refusing to start without a working sandbox.\n\n`),E(1);return}process.stderr.write(`\n⚠ Sandbox disabled: ${u}\n Commands will run WITHOUT sandboxing. Network and filesystem restrictions will NOT be enforced.\n\n`)}else if(ot.isSandboxingEnabled())try{await ot.initialize(l.createSandboxAskCallback())}catch(e){process.stderr.write(`\n❌ Sandbox Error: ${W(e)}\n`),E(1,`other`);return}c.outputFormat===`stream-json`&&c.verbose&&Ae(e=>{let t=(()=>{switch(e.type){case`started`:return{type:`system`,subtype:`hook_started`,hook_id:e.hookId,hook_name:e.hookName,hook_event:e.hookEvent,uuid:Y(),session_id:U()};case`progress`:return{type:`system`,subtype:`hook_progress`,hook_id:e.hookId,hook_name:e.hookName,hook_event:e.hookEvent,stdout:e.stdout,stderr:e.stderr,output:e.output,uuid:Y(),session_id:U()};case`response`:return{type:`system`,subtype:`hook_response`,hook_id:e.hookId,hook_name:e.hookName,hook_event:e.hookEvent,output:e.output,stdout:e.stdout,stderr:e.stderr,exit_code:e.exitCode,outcome:e.outcome,uuid:Y(),session_id:U()}}})();l.write(t)}),c.setupTrigger&&await Mt(c.setupTrigger),Mn(`before_loadInitialMessages`);let d=t(),{messages:f,turnInterruptionState:p,agentSetting:m}=await tu(r,{continue:c.continue,teleport:c.teleport,resume:c.resume,resumeSessionAt:c.resumeSessionAt,forkSession:c.forkSession,outputFormat:c.outputFormat,sessionStartHooksPromise:c.sessionStartHooksPromise,restoredWorkerState:l.restoredWorkerState}),h=rt();if(h&&l.prependUserMessage(h),!c.agent&&!gr()&&m){let{agentDefinition:e}=Va(m,void 0,{activeAgents:s,allAgents:s});if(e){if(r(t=>({...t,agent:e.agentType})),!c.systemPrompt&&!wn(e)){let t=e.getSystemPrompt();t&&(c.systemPrompt=t)}Ut(e.agentType)}}if(f.length===0&&process.exitCode!==void 0)return;if(c.rewindFiles){if(f.find(e=>e.uuid===c.rewindFiles)?.type!==`user`){process.stderr.write(`Error: --rewind-files requires a user message UUID, but ${c.rewindFiles} is not a user message in this session\n`),E(1);return}let e=t(),n=await Zl(c.rewindFiles,e,r,!1);if(!n.canRewind){process.stderr.write(`Error: ${n.error||`Unexpected error`}\n`),E(1);return}process.stdout.write(`Files rewound to state at message ${c.rewindFiles}\n`),E(0);return}let g=typeof c.resume==`string`&&(!!tt(c.resume)||c.resume.endsWith(`.jsonl`)),ee=!!c.sdkUrl;if(!e&&!g&&!ee){process.stderr.write(`Error: Input must be provided either through stdin or as a prompt argument when using --print
9
+ `),E(1);return}if(c.outputFormat===`stream-json`&&!c.verbose){process.stderr.write(`Error: When using --print, --output-format=stream-json requires --verbose
10
+ `),E(1);return}let _=k(d.mcp.tools,d.toolPermissionContext),te=[...a,..._],ne=Yl(c.sdkUrl?`stdio`:c.permissionPromptToolName,l,()=>t().mcp.tools,e=>{r(e=>({...e,attribution:{...e.attribution,permissionPromptCount:e.attribution.permissionPromptCount+1}})),$i(`requires_action`,e)});c.permissionPromptToolName&&(te=te.filter(e=>!Li(e,c.permissionPromptToolName))),Yr(),Mn(`after_loadInitialMessages`),await fi(),Mn(`after_modelStrings`);let re=c.outputFormat===`json`&&c.verbose,v=[],y;Mn(`before_runHeadlessStreaming`);for await(let e of ql(l,d.mcp.clients,[...i,...d.mcp.commands],te,f,ne,o,t,r,s,c,p))c.outputFormat===`stream-json`&&c.verbose&&await l.write(e),e.type!==`control_response`&&e.type!==`control_request`&&e.type!==`control_cancel_request`&&!(e.type===`system`&&(e.subtype===`session_state_changed`||e.subtype===`task_notification`||e.subtype===`task_started`||e.subtype===`task_progress`||e.subtype===`post_turn_summary`))&&e.type!==`stream_event`&&e.type!==`keep_alive`&&e.type!==`streamlined_text`&&e.type!==`streamlined_tool_use_summary`&&e.type!==`prompt_suggestion`&&(re&&v.push(e),y=e);switch(c.outputFormat){case`json`:if(y?.type!==`result`)throw Error(`No messages returned`);if(c.verbose){K(`${Cr(v)}\n`);break}K(`${Cr(y)}\n`);break;case`stream-json`:break;default:if(y?.type!==`result`)throw Error(`No messages returned`);switch(y.subtype){case`success`:K(y.result.endsWith(`
11
+ `)?y.result:`${y.result}\n`);break;case`error_during_execution`:K(`Execution error`);break;case`error_max_turns`:K(`Error: Reached max turns (${c.maxTurns}).\nTip: Increase the limit with --max-turns or continue in a new session.`);break;case`error_max_budget_usd`:K(`Error: Exceeded USD budget ($${c.maxBudgetUsd}).\nTip: Increase the limit with --max-budget-usd or start a new session to continue.`);break;case`error_max_structured_output_retries`:K(`Error: Failed to provide valid structured output after maximum retries.
12
+ Tip: Simplify your schema or check if the output format matches the expected structure.`)}}if(gn(),qr())try{let{drainPendingExtraction:e}=await import(`./extractMemories-B1KbTMY0.js`);await e()}catch{}E(y?.type===`result`&&y?.is_error?1:0)}function ql(t,r,a,o,s,c,l,u,d,f,m,h){let g=!1,_,ne=!1,re=null,v,b=t.outbound;process.on(`SIGINT`,()=>{$r(`info`,`shutdown_signal`,{signal:`SIGINT`}),v&&!v.signal.aborted&&v.abort(),et(0)}),jr(async()=>{let e={};for(let t of oe(u()))ve(t)&&(e[t.type]=(e[t.type]??0)+1);$r(`info`,`run_state_at_shutdown`,{run_active:g,run_phase:_,worker_status:ra(),internal_events_pending:t.internalEventsPending,bg_tasks:e})}),ta(e=>{(e==="default"||e===`acceptEdits`||e===`bypassPermissions`||e===`plan`||e===`auto`||e===`dontAsk`)&&b.enqueue({type:`system`,subtype:`status`,status:null,permissionMode:e,uuid:Y(),session_id:U()})});let x={abortController:null,inflightPromise:null,lastEmitted:null,pendingSuggestion:null,pendingLastEmittedEntry:null},ie;m.enableAuthStatus&&(ie=yi.getInstance().subscribe(e=>{b.enqueue({type:`auth_status`,isAuthenticating:e.isAuthenticating,output:e.output,error:e.error,uuid:Y(),session_id:U()})}));let se=e=>{let t=da(e);t&&b.enqueue({type:`rate_limit_event`,rate_limit_info:t,uuid:Y(),session_id:U()})};Ie.add(se);let S=s,ce=ae(s,X(),100),le=Me(100),ue=process.env.CLAUDE_CODE_RESUME_INTERRUPTED_TURN;h&&h.kind!==`none`&&ue&&(G(`[print.ts] Auto-resuming interrupted turn (kind: ${h.kind})`),eu(S,h.message),Xe({mode:`prompt`,value:h.message.message.content,uuid:Y()}));let de=Ba().map(e=>{let t=e.value===null?`default`:e.value,n=t==="default"?wi():li(t),r=Qt(n),i=xi(e.value),a=di(n);return{name:t,value:t,displayName:e.label,description:e.description,...r&&{supportsAdaptiveThinking:!0},...i&&{supportsFastMode:!0},...a&&{supportsAutoMode:!0}}}),me=m.userSpecifiedModel;function he(e,t){let n=Nt(e,ji(t));S.push(...n);for(let e of n)typeof e.message.content==`string`&&e.message.content.includes(`<local-command-stdout>`)&&b.enqueue({type:`user`,content:e.message.content,message:e.message,session_id:U(),parent_tool_use_id:null,uuid:e.uuid,timestamp:e.timestamp,isReplay:!0})}let C=[],_e=[],ye=new Set;function be(e){for(let n of e){if(n.type!==`connected`||ye.has(n.name)||n.config.type===`sdk`)continue;let e=n.name;try{n.client.setRequestHandler(Xt,async(n,r)=>{ti(e,`Elicitation request received in print mode: ${Cr(n)}`);let i=n.params.mode===`url`?`url`:`form`;J(`tengu_mcp_elicitation_shown`,{mode:i});let a=await ge(e,n.params,r.signal);if(a)return ti(e,`Elicitation resolved by hook: ${Cr(a)}`),J(`tengu_mcp_elicitation_response`,{mode:i,action:a.action}),a;let o=`url`in n.params?n.params.url:void 0,s=`requestedSchema`in n.params?n.params.requestedSchema:void 0,c=`elicitationId`in n.params?n.params.elicitationId:void 0,l=await t.handleElicitation(e,n.params.message,s,r.signal,i,o,c),u=await Ne(e,l,r.signal,i,c);return J(`tengu_mcp_elicitation_response`,{mode:i,action:u.action}),u}),n.client.setNotificationHandler(Gt,t=>{let{elicitationId:n}=t.params;ti(e,`Elicitation completion notification: ${n}`),te({message:`MCP server "${e}" confirmed elicitation ${n} complete`,notificationType:`elicitation_complete`}),b.enqueue({type:`system`,subtype:`elicitation_complete`,mcp_server_name:e,elicitation_id:n,uuid:Y(),session_id:U()})}),ye.add(e)}catch{}}}async function xe(){let e=new Set(Object.keys(l)),n=new Set(C.map(e=>e.name)),r=Array.from(e).some(e=>!n.has(e)),i=Array.from(n).some(t=>!e.has(t)),a=C.some(e=>e.type===`pending`),o=C.some(e=>e.type===`failed`);if(r||i||a||o){for(let t of C)e.has(t.name)||t.type===`connected`&&await t.cleanup();let r=await Oe(l,(e,n)=>t.sendMcpMessage(e,n));C=r.clients,_e=r.tools;let i=Fr([...n,...e]);d(e=>({...e,mcp:{...e.mcp,tools:[...e.mcp.tools.filter(e=>!i.some(t=>e.name.startsWith(Wr(t)))),..._e]}})),Ke(C)}}xe();let w={clients:[],tools:[],configs:{}},we=e=>{let t=Ve(e.toolPermissionContext,e.mcp.tools),n=Ln(ka([...o,..._e,...w.tools],t,e.toolPermissionContext.mode),`name`);m.permissionPromptToolName&&(n=n.filter(e=>!Li(e,m.permissionPromptToolName)));let r=mr();if(r&&!m.jsonSchema){let e=Pi(r);`tool`in e&&(n=[...n,e.tool])}return n},T=null,De=0;function ke(){if(!T)return;let e=Math.min(De,S.length),t=S.slice(e).filter(e=>e.type===`user`||e.type===`assistant`);De=S.length,t.length>0&&T.writeMessages(t)}let Ae=Promise.resolve({response:{added:[],removed:[],errors:{}},sdkServersChanged:!1});function je(e){let t=async()=>{let t=new Set(C.map(e=>e.name)),n=await au(e,{configs:l,clients:C,tools:_e},w,d);for(let e of Object.keys(l))delete l[e];if(Object.assign(l,n.newSdkState.configs),C=n.newSdkState.clients,_e=n.newSdkState.tools,w=n.newDynamicState,n.sdkServersChanged){let e=new Set(C.map(e=>e.name)),n=Fr([...t,...e]);d(e=>({...e,mcp:{...e.mcp,tools:[...e.mcp.tools.filter(e=>!n.some(t=>e.name.startsWith(Wr(t)))),..._e]}}))}return{response:n.response,sdkServersChanged:n.sdkServersChanged}};return Ae=Ae.then(t,t),Ae}function Fe(){let e=u(),t=e.mcp.clients,n=Ln([...e.mcp.tools,...w.tools],`name`),r=new Set([...t.map(e=>e.name),...C.map(e=>e.name)]);return[...t,...C,...w.clients.filter(e=>!r.has(e.name))].map(e=>{let t;if(e.config.type===`sse`||e.config.type===`http`)t={type:e.config.type,url:e.config.url,headers:e.config.headers,oauth:e.config.oauth};else if(e.config.type===`claudeai-proxy`)t={type:`claudeai-proxy`,url:e.config.url,id:e.config.id};else if(e.config.type===`stdio`||e.config.type===void 0){let n=e.config;t={type:`stdio`,command:n.command,args:n.args}}let r=e.type===`connected`?mt(n,e.name).map(e=>({name:e.mcpInfo?.toolName??e.name,annotations:{readOnly:e.isReadOnly({})||void 0,destructive:e.isDestructive?.({})||void 0,openWorld:e.isOpenWorld?.({})||void 0}})):void 0;return{name:e.name,status:e.type,serverInfo:e.type===`connected`?e.serverInfo:void 0,error:e.type===`failed`?e.error:void 0,config:t,scope:e.config.scope,tools:r}})}async function Le(){try{await Promise.all([Promise.resolve(),Zr(`headless_managed_settings_wait`,()=>wa())]),await Rl()&&await We()}catch(e){q(e)}}let Re=null;i()||(n(process.env.CLAUDE_CODE_SYNC_PLUGIN_INSTALL)?Re=Le():Le());let ze=_l(()=>!g),Be=a,O=f;async function He(){let{agentDefinitions:e}=await Ga(d);Be=await Ce(X());let t=O.filter(e=>e.source===`flagSettings`);O=[...e.allAgents,...t]}async function We(){let{servers:e}=await Yt(),t={};for(let[n,r]of Object.entries(e)){let e=r.type;(e===void 0||e===`stdio`||e===`sse`||e===`http`||e===`sdk`)&&(t[n]=r)}for(let[e,n]of Object.entries(l))n.type===`sdk`&&!(e in t)&&(t[e]=n);let{response:n,sdkServersChanged:r}=await je(t);r&&xe(),G(`Headless MCP refresh: added=${n.added.length}, removed=${n.removed.length}`)}let Ge=Ua.subscribe(()=>{y(),Ce(X()).then(e=>{Be=e})}),qe=()=>{setTimeout(()=>{!na()||Ji()||ne||(async()=>{let e=await qn({basePrompt:`<${ei}>${new Date().toLocaleTimeString()}</${ei}>`,currentDir:X(),shouldCreate:()=>!ne});if(ne){await at({commands:e});return}for(let t of e)Xe({...t,uuid:Y()});Je()})().catch(e=>{q(e),G(`[Proactive] failed to create headless tick: ${e}`,{level:`error`})})},0)};en(()=>{v&&jn(`now`).length>0&&v.abort(`interrupt`)});let Je=async()=>{if(g)return;if(g=!0,_=void 0,$i(`running`),ze.stop(),Mn(`run_entry`),await xe(),Mn(`after_updateSdkMcp`),Re){let e=parseInt(process.env.CLAUDE_CODE_SYNC_PLUGIN_INSTALL_TIMEOUT_MS||``,10);if(e>0){let t=Ai(e).then(()=>`timeout`);await Promise.race([Re,t])===`timeout`&&(q(Error(`CLAUDE_CODE_SYNC_PLUGIN_INSTALL: plugin installation timed out after ${e}ms`)),J(`tengu_sync_plugin_install_timeout`,{timeout_ms:e}))}else await Re;Re=null,await He();let{setupPluginHookHotReload:t}=await import(`./loadPluginHooks-C-Yk5KlI.js`);t()}let n=e=>e.agentId===void 0;try{let r,i=!1,a=async()=>{for(;r=pe(n);){if(r.mode!==`prompt`&&r.mode!==`orphaned-permission`&&r.mode!==`task-notification`)throw Error(`only prompt commands are supported in streaming mode`);let i=[r];if(r.mode===`prompt`)for(;Gl(r,pn(n));)i.push(pe(n));let a=await Rn(i);if(i=a.attachmentCommands,i.length===0)continue;r=i[0],r.mode===`prompt`&&i.length>1&&(r={...r,value:Wl(i.map(e=>e.value)),uuid:i.findLast(e=>e.uuid)?.uuid??r.uuid});let o=i.map(e=>e.uuid).filter(e=>e!==void 0);if(m.replayUserMessages&&i.length>1)for(let e of i)e.uuid&&e.uuid!==r.uuid&&b.enqueue({type:`user`,content:e.value,message:{role:`user`,content:e.value},session_id:U(),parent_tool_use_id:null,uuid:e.uuid,isReplay:!0});let s=u(),l=[...s.mcp.clients,...C,...w.clients];be(l);let f=we(s);for(let e of o)zt(e,`started`);if(r.mode===`task-notification`){let e=typeof r.value==`string`?r.value:``,t=e.match(/<task-id>([^<]+)<\/task-id>/),n=e.match(/<tool-use-id>([^<]+)<\/tool-use-id>/),i=e.match(/<output-file>([^<]+)<\/output-file>/),a=e.match(/<status>([^<]+)<\/status>/),o=e.match(/<summary>([^<]+)<\/summary>/),s=e=>e===`completed`||e===`failed`||e===`stopped`||e===`killed`,c=a?.[1],l=s(c)?c===`killed`?`stopped`:c:`completed`,u=e.match(/<usage>([\s\S]*?)<\/usage>/)?.[1]??``,d=u.match(/<total_tokens>(\d+)<\/total_tokens>/),f=u.match(/<tool_uses>(\d+)<\/tool_uses>/),p=u.match(/<duration_ms>(\d+)<\/duration_ms>/);a&&b.enqueue({type:`system`,subtype:`task_notification`,task_id:t?.[1]??``,tool_use_id:n?.[1],status:l,output_file:i?.[1]??``,summary:o?.[1]??``,usage:d&&f?{total_tokens:parseInt(d[1],10),tool_uses:parseInt(f[1],10),duration_ms:p?parseInt(p[1],10):0}:void 0,session_id:U(),uuid:Y()})}let p=r.value,h=a.claimedCommands;if(t instanceof dl&&r.mode===`prompt`&&J(`tengu_bridge_message_received`,{is_repl:!1}),x.abortController?.abort(),x.abortController=null,x.pendingSuggestion=null,x.pendingLastEmittedEntry=null,x.lastEmitted&&r.mode===`prompt`){let e=typeof p==`string`?p:p.find(e=>e.type===`text`)?.text;typeof e==`string`&&Dn(x.lastEmitted.text,e,x.lastEmitted.emittedAt,x.lastEmitted.promptId,x.lastEmitted.generationRequestId),x.lastEmitted=null}v=tr(),Mn(`before_ask`),ee();let g=r,_=!1;try{if(await Ei(g.workload??m.workload,async()=>{for await(let e of Ma({commands:Ln([...Be,...s.mcp.commands],`name`),prompt:p,promptUuid:g.uuid,isMeta:g.isMeta,cwd:X(),tools:f,verbose:m.verbose,mcpClients:l,thinkingConfig:m.thinkingConfig,maxTurns:m.maxTurns,maxBudgetUsd:m.maxBudgetUsd,taskBudget:m.taskBudget,canUseTool:c,userSpecifiedModel:me,fallbackModel:m.fallbackModel,jsonSchema:mr()??m.jsonSchema,mutableMessages:S,getReadFileCache:()=>le.size===0?ce:St(ce,le),setReadFileCache:e=>{ce=e;for(let[e,t]of le.entries()){let n=ce.get(e);(!n||t.timestamp>n.timestamp)&&ce.set(e,t)}le.clear()},customSystemPrompt:m.systemPrompt,appendSystemPrompt:m.appendSystemPrompt,getAppState:u,setAppState:d,abortController:v,replayUserMessages:m.replayUserMessages,includePartialMessages:m.includePartialMessages,handleElicitation:(e,n,r)=>t.handleElicitation(e,n.message,void 0,r,n.mode,n.url,`elicitationId`in n?n.elicitationId:void 0),agents:O,orphanedPermission:g.orphanedPermission,setSDKStatus:e=>{b.enqueue({type:`system`,subtype:`status`,status:e,session_id:U(),uuid:Y()})}}))if(ke(),e.type===`result`){_=!!e.is_error;for(let e of Ui())b.enqueue(e);oe(u()).some(e=>(e.type===`local_agent`||e.type===`local_workflow`)&&ve(e))?re=e:(re=null,b.enqueue(e))}else{for(let e of Ui())b.enqueue(e);b.enqueue(e)}}),_)await Qn({commands:h,outcome:{type:`failed`,message:`ask() returned an error result`},currentDir:X(),priority:`later`,workload:g.workload??m.workload});else{let e=await Qn({commands:h,outcome:{type:`completed`},currentDir:X(),priority:`later`,workload:g.workload??m.workload});for(let t of e)Xe({...t,uuid:Y()})}}catch(e){throw await Qn({commands:h,outcome:{type:`failed`,error:e},currentDir:X(),priority:`later`,workload:g.workload??m.workload}),e}for(let e of o)zt(e,`completed`);if(ke(),T?.sendResult(),m.promptSuggestions&&!e(process.env.CLAUDE_CODE_ENABLE_PROMPT_SUGGESTION)){x.abortController?.abort();let e=new AbortController;x.abortController=e;let t=gt();if(!t)on(`sdk_no_params`,void 0,void 0,`sdk`);else{let n={promise:null};n.promise=(async()=>{try{let n=await Ht(e,S,u,t,`sdk`);if(!n||e.signal.aborted)return;let r={type:`prompt_suggestion`,suggestion:n.suggestion,uuid:Y(),session_id:U()},i={text:n.suggestion,emittedAt:Date.now(),promptId:n.promptId,generationRequestId:n.generationRequestId};re?(x.pendingSuggestion=r,x.pendingLastEmittedEntry={text:i.text,promptId:i.promptId,generationRequestId:i.generationRequestId}):(x.lastEmitted=i,b.enqueue(r))}catch(e){if(e instanceof Error&&(e.name===`AbortError`||e.name===`APIUserAbortError`)){on(`aborted`,void 0,void 0,`sdk`);return}q(Dr(e))}finally{x.inflightPromise===n.promise&&(x.inflightPromise=null)}})(),x.inflightPromise=n.promise}}gn(),Pe(),bt()}};do{for(let e of Ui())b.enqueue(e);_=`draining_commands`,await a(),i=!1;{let e=oe(u()).some(e=>ve(e)),t=pn(n)!==void 0;(e||t)&&(i=!0,t||(_=`waiting_for_agents`,await Ai(100)))}}while(i);re&&(b.enqueue(re),re=null,x.pendingSuggestion&&(b.enqueue(x.pendingSuggestion),x.pendingLastEmittedEntry&&(x.lastEmitted={...x.pendingLastEmittedEntry,emittedAt:Date.now()},x.pendingLastEmittedEntry=null),x.pendingSuggestion=null))}catch(e){try{await t.write({type:`result`,subtype:`error_during_execution`,duration_ms:0,duration_api_ms:0,is_error:!0,num_turns:0,stop_reason:null,session_id:U(),total_cost_usd:0,usage:Yi,modelUsage:{},permission_denials:[],uuid:Y(),errors:[W(e),...ni().map(e=>e.error)]})}catch{}x.abortController?.abort(),E(1);return}finally{if(_=`finally_flush`,await t.flushInternalEvents(),_=`finally_post_flush`,!wt()){$i(`idle`);for(let e of Ui())b.enqueue(e)}g=!1,ze.start()}if(na()&&!Ji()&&pn(n)===void 0&&!ne){qe();return}if(pn(n)!==void 0){Je();return}ne&&(x.inflightPromise&&await Promise.race([x.inflightPromise,Ai(5e3)]),x.abortController?.abort(),x.abortController=null,await Jt(),Ge(),ie?.(),Ie.delete(se),b.done())},k=(e,t)=>{b.enqueue({type:`control_response`,response:{subtype:`success`,request_id:e.request_id,response:t}})},A=(e,t)=>{b.enqueue({type:`control_response`,response:{subtype:`error`,request_id:e.request_id,error:t}})},tt=new Set;t.setUnexpectedResponseCallback(async e=>{await ru({message:e,setAppState:d,handledToolUseIds:tt,onEnqueued:()=>{Je()}})});let nt=new Map,rt=new Map,it=new Set,ot=new Map,st=null;return(async()=>{let e=!1;$r(`info`,`cli_message_loop_started`);for await(let n of t.structuredInput){let i=`uuid`in n?n.uuid:void 0;if(i&&n.type!==`user`&&n.type!==`control_response`&&zt(i,`completed`),n.type===`control_request`){let i=n,o=i.request;if(i.request.subtype===`interrupt`)d(e=>({...e,attribution:{...e.attribution,escapeCount:e.attribution.escapeCount+1}})),v&&v.abort(),x.abortController?.abort(),x.abortController=null,x.lastEmitted=null,x.pendingSuggestion=null,k(i);else if(o.subtype===`end_session`){G(`[print.ts] end_session received, reason=${o.reason??`unspecified`}`),v&&v.abort(),x.abortController?.abort(),x.abortController=null,x.lastEmitted=null,x.pendingSuggestion=null,k(i);break}else if(i.request.subtype===`initialize`){if(i.request.sdkMcpServers&&i.request.sdkMcpServers.length>0)for(let e of i.request.sdkMcpServers)l[e]={type:`sdk`,name:e};await Xl(i.request,i.request_id,e,b,a,de,t,!!m.enableAuthStatus,m,f,u),i.request.promptSuggestions&&d(e=>e.promptSuggestionEnabled?e:{...e,promptSuggestionEnabled:!0}),i.request.agentProgressSummaries&&yr(!0),e=!0,un()&&Je()}else if(i.request.subtype===`set_permission_mode`){let e=i.request;d(t=>({...t,toolPermissionContext:Ql(e,i.request_id,t.toolPermissionContext,b)}))}else if(i.request.subtype===`set_model`){let e=i.request.model??`default`,t=e==="default"?wi():e;me=t,fr(t),Wi({model:t}),he(e,t),k(i)}else if(i.request.subtype===`set_max_thinking_tokens`)i.request.max_thinking_tokens===null?m.thinkingConfig=void 0:i.request.max_thinking_tokens===0?m.thinkingConfig={type:`disabled`}:m.thinkingConfig={type:`enabled`,budgetTokens:i.request.max_thinking_tokens},k(i);else if(i.request.subtype===`mcp_status`)k(i,{mcpServers:Fe()});else if(i.request.subtype===`get_context_usage`)try{let e=u(),t=await La({messages:S,getAppState:u,options:{mainLoopModel:ki(),tools:we(e),agentDefinitions:e.agentDefinitions,customSystemPrompt:m.systemPrompt,appendSystemPrompt:m.appendSystemPrompt}});k(i,{...t})}catch(e){A(i,W(e))}else if(i.request.subtype===`mcp_message`){let e=i.request,t=C.find(t=>t.name===e.server_name);t&&t.type===`connected`&&t.client?.transport?.onmessage&&t.client.transport.onmessage(e.message),k(i)}else if(i.request.subtype===`rewind_files`){let e=u(),t=await Zl(i.request.user_message_id,e,d,i.request.dry_run??!1);t.canRewind||i.request.dry_run?k(i,t):A(i,t.error??`Unexpected error`)}else if(i.request.subtype===`cancel_async_message`){let e=i.request.message_uuid,t=Qe(t=>t.uuid===e);k(i,{cancelled:t.length>0})}else if(i.request.subtype===`seed_read_state`){try{let e=Gr(i.request.path),t=Math.floor((await $a(e)).mtimeMs);if(t<=i.request.mtime){let n=await Qa(e,`utf-8`),r=(n.charCodeAt(0)===65279?n.slice(1):n).replaceAll(`\r
13
+ `,`
14
+ `);le.set(e,{content:r,timestamp:t,offset:void 0,limit:void 0})}}catch{}k(i)}else if(i.request.subtype===`mcp_set_servers`){let{response:e,sdkServersChanged:t}=await je(i.request.servers);k(i,e),t&&xe()}else if(i.request.subtype===`reload_plugins`)try{let e=await Ga(d),t=O.filter(e=>e.source===`flagSettings`);O=[...e.agentDefinitions.allAgents,...t];let n=[],[r,a,o]=await Promise.allSettled([Ce(X()),We(),Nn()]);r.status===`fulfilled`?Be=r.value:q(r.reason),a.status===`rejected`&&q(a.reason),o.status===`fulfilled`?n=o.value.enabled.map(e=>({name:e.name,path:e.path,source:e.source})):q(o.reason),k(i,{commands:Be.filter(e=>e.userInvocable!==!1).map(e=>({name:nr(e),description:p(e),argumentHint:e.argumentHint||``})),agents:O.map(e=>({name:e.agentType,description:e.whenToUse,model:e.model===`inherit`?void 0:e.model})),plugins:n,mcpServers:Fe(),error_count:e.error_count})}catch(e){A(i,W(e))}else if(i.request.subtype===`mcp_reconnect`){let e=u(),{serverName:t}=i.request;ye.delete(t);let n=Te(t)??r.find(e=>e.name===t)?.config??C.find(e=>e.name===t)?.config??w.clients.find(e=>e.name===t)?.config??e.mcp.clients.find(e=>e.name===t)?.config??null;if(!n)A(i,`Server not found: ${t}`);else{let e=await Ee(t,n),r=Wr(t);if(d(n=>({...n,mcp:{...n.mcp,clients:n.mcp.clients.map(n=>n.name===t?e.client:n),tools:[...D(n.mcp.tools,e=>e.name?.startsWith(r)),...e.tools],commands:[...D(n.mcp.commands,e=>Fn(e,t)),...e.commands],resources:e.resources&&e.resources.length>0?{...n.mcp.resources,[t]:e.resources}:ia(n.mcp.resources,t)}})),w={...w,clients:[...w.clients.filter(e=>e.name!==t),e.client],tools:[...w.tools.filter(e=>!e.name?.startsWith(r)),...e.tools]},e.client.type===`connected`)be([e.client]),k(i);else{let t=e.client.type===`failed`?e.client.error??`Connection failed`:`Server status: ${e.client.type}`;A(i,t)}}}else if(i.request.subtype===`mcp_toggle`){let e=u(),{serverName:t,enabled:n}=i.request;ye.delete(t);let a=Te(t)??r.find(e=>e.name===t)?.config??C.find(e=>e.name===t)?.config??w.clients.find(e=>e.name===t)?.config??e.mcp.clients.find(e=>e.name===t)?.config??null;if(!a)A(i,`Server not found: ${t}`);else if(n){Ye(t,!0);let e=await Ee(t,a),n=Wr(t);if(d(r=>({...r,mcp:{...r.mcp,clients:r.mcp.clients.map(n=>n.name===t?e.client:n),tools:[...D(r.mcp.tools,e=>e.name?.startsWith(n)),...e.tools],commands:[...D(r.mcp.commands,e=>Fn(e,t)),...e.commands],resources:e.resources&&e.resources.length>0?{...r.mcp.resources,[t]:e.resources}:ia(r.mcp.resources,t)}})),e.client.type===`connected`)be([e.client]),k(i);else{let t=e.client.type===`failed`?e.client.error??`Connection failed`:`Server status: ${e.client.type}`;A(i,t)}}else{Ye(t,!1);let n=[...r,...C,...w.clients,...e.mcp.clients].find(e=>e.name===t);n&&n.type===`connected`&&await Vn(t,a);let o=Wr(t);d(e=>({...e,mcp:{...e.mcp,clients:e.mcp.clients.map(e=>e.name===t?{name:t,type:`disabled`,config:a}:e),tools:D(e.mcp.tools,e=>e.name?.startsWith(o)),commands:D(e.mcp.commands,e=>Fn(e,t)),resources:ia(e.mcp.resources,t)}})),k(i)}}else if(o.subtype===`mcp_authenticate`){let e=o.serverName,t=u(),n=Te(e)??r.find(t=>t.name===e)?.config??t.mcp.clients.find(t=>t.name===e)?.config??null;if(!n)A(i,`Server not found: ${e}`);else if(n.type!==`sse`&&n.type!==`http`)A(i,`Server type "${n.type}" does not support OAuth authentication`);else try{nt.get(e)?.abort();let t=new AbortController;nt.set(e,t);let r,a=new Promise(e=>{r=e}),o=Ze(e,n,e=>r(e),t.signal,{skipBrowserOpen:!0,onWaitingForCallback:t=>{rt.set(e,t)}}),s=await Promise.race([a,o.then(()=>null)]);s?k(i,{authUrl:s,requiresUserAction:!0}):k(i,{requiresUserAction:!1}),ot.set(e,o),o.then(async()=>{if(Se(e)||it.has(e))return;let t=await Ee(e,n),r=Wr(e);d(n=>({...n,mcp:{...n.mcp,clients:n.mcp.clients.map(n=>n.name===e?t.client:n),tools:[...D(n.mcp.tools,e=>e.name?.startsWith(r)),...t.tools],commands:[...D(n.mcp.commands,t=>Fn(t,e)),...t.commands],resources:t.resources&&t.resources.length>0?{...n.mcp.resources,[e]:t.resources}:ia(n.mcp.resources,e)}})),w={...w,clients:[...w.clients.filter(t=>t.name!==e),t.client],tools:[...w.tools.filter(e=>!e.name?.startsWith(r)),...t.tools]}}).catch(t=>{G(`MCP OAuth failed for ${e}: ${t}`,{level:`error`})}).finally(()=>{nt.get(e)===t&&(nt.delete(e),rt.delete(e),it.delete(e),ot.delete(e))})}catch(e){A(i,W(e))}}else if(o.subtype===`mcp_oauth_callback_url`){let e=o.serverName,t=o.callbackUrl,n=rt.get(e);if(n){let r=!1;try{let e=new URL(t);r=e.searchParams.has(`code`)||e.searchParams.has(`error`)}catch{}if(!r)A(i,`Invalid callback URL: missing authorization code. Please paste the full redirect URL including the code parameter.`);else{it.add(e),n(t);let r=ot.get(e);if(r)try{await r,k(i)}catch(e){A(i,e instanceof Error?e.message:`OAuth authentication failed`)}else k(i)}}else A(i,`No active OAuth flow for server: ${e}`)}else if(o.subtype===`claude_authenticate`){let e=o.loginWithClaudeAi;st?.service.cleanup(),J(`tengu_oauth_flow_start`,{loginWithClaudeAi:e??!0});let t=new Ta,n,r=new Promise(e=>{n=e}),a=t.startOAuthFlow(async(e,t)=>{n({manualUrl:e,automaticUrl:t})},{loginWithClaudeAi:e??!0,skipBrowserOpen:!0}).then(async t=>{await Ea(t),J(`tengu_oauth_success`,{loginWithClaudeAi:e??!0})}).finally(()=>{t.cleanup(),st?.service===t&&(st=null)});st={service:t,flow:a},a.catch(e=>G(`claude_authenticate flow ended: ${e}`,{level:`info`}));try{let{manualUrl:e,automaticUrl:t}=await Promise.race([r,a.then(()=>{throw Error(`OAuth flow completed without producing auth URLs`)})]);k(i,{manualUrl:e,automaticUrl:t})}catch(e){A(i,W(e))}}else if(o.subtype===`claude_oauth_callback`||o.subtype===`claude_oauth_wait_for_completion`)if(!st)A(i,`No active claude_authenticate flow`);else{o.subtype===`claude_oauth_callback`&&st.service.handleManualAuthCodeInput({authorizationCode:o.authorizationCode,state:o.state});let{flow:e}=st;e.then(()=>{let e=_i();k(i,{account:{email:e?.email,organization:e?.organization,subscriptionType:e?.subscription,tokenSource:e?.tokenSource,apiKeySource:e?.apiKeySource,apiProvider:bi()}})},e=>A(i,W(e)))}else if(o.subtype===`mcp_clear_auth`){let e=o.serverName,t=u(),n=Te(e)??r.find(t=>t.name===e)?.config??t.mcp.clients.find(t=>t.name===e)?.config??null;if(!n)A(i,`Server not found: ${e}`);else if(n.type!==`sse`&&n.type!==`http`)A(i,`Cannot clear auth for server type "${n.type}"`);else{await $e(e,n);let t=await Ee(e,n),r=Wr(e);d(n=>({...n,mcp:{...n.mcp,clients:n.mcp.clients.map(n=>n.name===e?t.client:n),tools:[...D(n.mcp.tools,e=>e.name?.startsWith(r)),...t.tools],commands:[...D(n.mcp.commands,t=>Fn(t,e)),...t.commands],resources:t.resources&&t.resources.length>0?{...n.mcp.resources,[e]:t.resources}:ia(n.mcp.resources,e)}})),k(i,{})}}else if(i.request.subtype===`apply_flag_settings`){let e=ki(),t=dr()??{},n=i.request.settings,r={...t,...n};for(let e of Object.keys(r))r[e]===null&&delete r[e];_r(r),mn.notifyChange(`flagSettings`),`model`in n&&(n.model==null?fr(void 0):fr(String(n.model)));let a=ki();if(a!==e){me=a;let e=n.model?String(n.model):`default`;Wi({model:a}),he(e,a)}k(i)}else if(i.request.subtype===`get_settings`){let e=ki();k(i,{...zr(),applied:{model:e}})}else if(i.request.subtype===`stop_task`){let{task_id:e}=i.request;try{await Et(e,{getAppState:u,setAppState:d}),k(i,{})}catch(e){A(i,W(e))}}else if(o.subtype===`generate_session_title`){let e=o.description,t=o.persist,n=(v&&!v.signal.aborted?v:tr()).signal;(async()=>{try{let r=await fa(e,n);if(r&&t)try{ct(U(),r)}catch(e){q(e)}k(i,{title:r})}catch(e){A(i,W(e))}})()}else if(o.subtype===`side_question`){let e=o.question;(async()=>{try{let t=gt(),n=t?{...t,toolUseContext:{...t.toolUseContext,abortController:tr()}}:await Na({tools:we(u()),commands:Be,mcpClients:[...u().mcp.clients,...C,...w.clients],messages:S,readFileState:ce,getAppState:u,setAppState:d,customSystemPrompt:m.systemPrompt,appendSystemPrompt:m.appendSystemPrompt,thinkingConfig:m.thinkingConfig,agents:O}),r=await Ia({question:e,cacheSafeParams:n});k(i,{response:r.response})}catch(e){A(i,W(e))}})()}else if(i.request.subtype===`set_proactive`)i.request.enabled?na()||(Qi(`command`),qe()):ea(),k(i);else if(o.subtype===`remote_control`)if(o.enabled)if(T)k(i,{session_url:yt(T.bridgeSessionId,T.sessionIngressUrl),connect_url:Pa(T.environmentId,T.sessionIngressUrl),environment_id:T.environmentId});else{let e;try{let{initReplBridge:n}=await import(`./initReplBridge-D09JEKHt.js`),r=await n({onInboundMessage(e){let t=vl(e);if(!t)return;let{content:n,uuid:r}=t;Xe({value:n,mode:`prompt`,uuid:r,skipSlashCommands:!0}),Je()},onPermissionResponse(e){t.injectControlResponse(e)},onInterrupt(){v?.abort()},onSetModel(e){let t=e==="default"?wi():e;me=t,fr(t)},onSetMaxThinkingTokens(e){e===null?m.thinkingConfig=void 0:e===0?m.thinkingConfig={type:`disabled`}:m.thinkingConfig={type:`enabled`,budgetTokens:e}},onStateChange(t,n){t===`failed`&&(e=n),G(`[bridge:sdk] State change: ${t}${n?` — ${n}`:``}`),b.enqueue({type:`system`,subtype:`bridge_state`,state:t,detail:n,uuid:Y(),session_id:U()})},initialMessages:S.length>0?S:void 0});r?(T=r,De=S.length,t.setOnControlRequestSent(e=>{r.sendControlRequest(e)}),t.setOnControlRequestResolved(e=>{r.sendControlCancelRequest(e)}),k(i,{session_url:yt(r.bridgeSessionId,r.sessionIngressUrl),connect_url:Pa(r.environmentId,r.sessionIngressUrl),environment_id:r.environmentId})):A(i,e??`Remote Control initialization failed`)}catch(e){A(i,W(e))}}else T&&(t.setOnControlRequestSent(void 0),t.setOnControlRequestResolved(void 0),await T.teardown(),T=null),k(i);else A(i,`Unsupported control request subtype: ${i.request.subtype}`);continue}else if(n.type===`control_response`){m.replayUserMessages&&b.enqueue(n);continue}else if(n.type===`keep_alive`)continue;else if(n.type===`update_environment_variables`)continue;else if(n.type===`assistant`||n.type===`system`){let e=la([n]);S.push(...e),n.type===`assistant`&&m.replayUserMessages&&b.enqueue(n);continue}if(n.type!==`user`)continue;let o=n;if(e=!0,o.uuid){let e=U(),t=await fe(e,o.uuid);if(t||Bl.has(o.uuid)){G(`Skipping duplicate user message: ${o.uuid}`),m.replayUserMessages&&(G(`Sending acknowledgment for duplicate user message: ${o.uuid}`),b.enqueue({type:`user`,content:o.message?.content??``,message:o.message,session_id:e,parent_tool_use_id:null,uuid:o.uuid,timestamp:o.timestamp,isReplay:!0})),t&&zt(o.uuid,`completed`);continue}Hl(o.uuid)}Xe({mode:`prompt`,value:await jl(o,o.message.content),uuid:o.uuid,priority:o.priority}),d(e=>({...e,attribution:Hn(e.attribution,e=>{Ue(e).catch(e=>{G(`Attribution: Failed to save snapshot: ${e}`)})})})),Je()}ne=!0,g||(x.inflightPromise&&await Promise.race([x.inflightPromise,Ai(5e3)]),x.abortController?.abort(),x.abortController=null,await Jt(),Ge(),ie?.(),Ie.delete(se),b.done())})(),b}function Jl(e){let t=async(n,r,i,a,o,s)=>{let c=s??await h(n,r,i,a,o);if(c.behavior===`allow`||c.behavior===`deny`)return c;let{signal:l,cleanup:u}=$n(i.abortController.signal);if(l.aborted)return u(),{behavior:`deny`,message:`Permission prompt was aborted.`,decisionReason:{type:`permissionPromptTool`,permissionPromptToolName:n.name,toolResult:void 0}};let d=new Promise(e=>{l.addEventListener(`abort`,()=>e(`aborted`),{once:!0})}),f=e.call({tool_name:n.name,input:r,tool_use_id:o},i,t,a),p=await Promise.race([f,d]);if(u(),p===`aborted`||l.aborted)return{behavior:`deny`,message:`Permission prompt was aborted.`,decisionReason:{type:`permissionPromptTool`,permissionPromptToolName:n.name,toolResult:void 0}};let m=p,g=e.mapToolResultToToolResultBlockParam(m.data,`1`);if(!g.content||!Array.isArray(g.content)||!g.content[0]||g.content[0].type!==`text`||typeof g.content[0].text!=`string`)throw Error(`Permission prompt tool returned an invalid result. Expected a single text block param with type="text" and a string text value.`);return $c(Qc().parse(oi(g.content[0].text)),e,r,i)};return t}function Yl(e,t,n,r){if(e===`stdio`)return t.createCanUseTool(r);if(!e)return async(e,t,n,r,i,a)=>a??await h(e,t,n,r,i);let i=null;return async(t,r,a,o,s,c)=>{if(!i){let t=n(),r=t.find(t=>Li(t,e));if(!r){let n=`Error: MCP tool ${e} (passed via --permission-prompt-tool) not found. Available MCP tools: ${t.map(e=>e.name).join(`, `)||`none`}`;throw process.stderr.write(`${n}\n`),E(1),Error(n)}if(!r.inputJSONSchema){let t=`Error: tool ${e} (passed via --permission-prompt-tool) must be an MCP tool`;throw process.stderr.write(`${t}\n`),E(1),Error(t)}i=Jl(r)}return i(t,r,a,o,s,c)}}async function Xl(e,t,n,r,i,a,o,s,c,l,u){if(n){r.enqueue({type:`control_response`,response:{subtype:`error`,error:`Already initialized`,request_id:t,pending_permission_requests:o.getPendingPermissionRequests()}});return}if(e.systemPrompt!==void 0&&(c.systemPrompt=e.systemPrompt),e.appendSystemPrompt!==void 0&&(c.appendSystemPrompt=e.appendSystemPrompt),e.promptSuggestions!==void 0&&(c.promptSuggestions=e.promptSuggestions),e.agents){let t=Dt(e.agents,`flagSettings`);l.push(...t)}if(c.agent){let e=gr()===c.agent,t=l.find(e=>e.agentType===c.agent);if(t&&!e){if(pr(t.agentType),!c.systemPrompt&&!wn(t)){let e=t.getSystemPrompt();e&&(c.systemPrompt=e)}!c.userSpecifiedModel&&t.model&&t.model!==`inherit`&&fr(li(t.model)),t.initialPrompt&&o.prependUserMessage(t.initialPrompt)}else t?.initialPrompt&&o.prependUserMessage(t.initialPrompt)}let d=Vr()?.outputStyle||`default`,f=await An(Sr()),m=_i();if(e.hooks){let t={};for(let[n,r]of Object.entries(e.hooks))t[n]=r.map(e=>{let t=e.hookCallbackIds.map(t=>o.createHookCallback(t,e.timeout));return{matcher:e.matcher,hooks:t}});lr(t)}e.jsonSchema&&br(e.jsonSchema);let h={commands:i.filter(e=>e.userInvocable!==!1).map(e=>({name:nr(e),description:p(e),argumentHint:e.argumentHint||``})),agents:l.map(e=>({name:e.agentType,description:e.whenToUse,model:e.model===`inherit`?void 0:e.model})),output_style:d,available_output_styles:Object.keys(f),models:a,account:{email:m?.email,organization:m?.organization,subscriptionType:m?.subscription,tokenSource:m?.tokenSource,apiKeySource:m?.apiKeySource,apiProvider:bi()},pid:process.pid};if(Di()&&Oi()){let e=u();h.fast_mode_state=pi(c.userSpecifiedModel??null,e.fastMode)}if(r.enqueue({type:`control_response`,response:{subtype:`success`,request_id:t,response:h}}),s){let e=yi.getInstance().getStatus();e&&r.enqueue({type:`auth_status`,isAuthenticating:e.isAuthenticating,output:e.output,error:e.error,uuid:Y(),session_id:U()})}}async function Zl(e,t,n,r){if(!nn())return{canRewind:!1,error:`File rewinding is not enabled.`,filesChanged:[]};if(!hn(t.fileHistory,e))return{canRewind:!1,error:`No file checkpoint found for this message.`,filesChanged:[]};if(r){let n=await Rt(t.fileHistory,e);return{canRewind:!0,filesChanged:n?.filesChanged??[],insertions:n?.insertions,deletions:n?.deletions}}try{await Zn(e=>n(t=>({...t,fileHistory:e(t.fileHistory)})),e)}catch(e){return{canRewind:!1,error:`Failed to rewind: ${W(e)}`,filesChanged:[]}}return{canRewind:!0,filesChanged:[]}}function Ql(e,t,n,r){if(e.mode===`bypassPermissions`){if(Bn())return r.enqueue({type:`control_response`,response:{subtype:`error`,request_id:t,error:`Cannot set permission mode to bypassPermissions because it is disabled by settings or configuration`}}),n;if(!n.isBypassPermissionsModeAvailable)return r.enqueue({type:`control_response`,response:{subtype:`error`,request_id:t,error:`Cannot set permission mode to bypassPermissions because the session was not launched with --dangerously-skip-permissions`}}),n}if(e.mode===`auto`&&!ne()){let e=Xn();return r.enqueue({type:`control_response`,response:{subtype:`error`,request_id:t,error:e?`Cannot set permission mode to auto: ${In(e)}`:`Cannot set permission mode to auto`}}),n}return r.enqueue({type:`control_response`,response:{subtype:`success`,request_id:t,response:{mode:e.mode}}}),{...f(n.mode,e.mode,n),mode:e.mode}}function $l(e,t){if(t===`stream-json`){let t={type:`result`,subtype:`error_during_execution`,duration_ms:0,duration_api_ms:0,is_error:!0,num_turns:0,stop_reason:null,session_id:U(),total_cost_usd:0,usage:Yi,modelUsage:{},permission_denials:[],uuid:Y(),errors:[e]};process.stdout.write(`${Cr(t)}\n`)}else process.stderr.write(`${e}\n`)}function eu(e,t){let n=e.findIndex(e=>e.uuid===t.uuid);n!==-1&&e.splice(n,2)}async function tu(e,t){let r=!ur();if(t.continue)try{J(`tengu_continue_print`,{});let n=await O(void 0,void 0);if(n)return t.forkSession||n.sessionId&&(vr(ce(n.sessionId),n.fullPath?Ja(n.fullPath):null),r&&await kn()),Ha(n,e),sn(t.forkSession?{...n,worktreeSession:void 0}:n),{messages:n.messages,turnInterruptionState:n.turnInterruptionState,agentSetting:n.agentSetting}}catch(e){return q(e),E(1),{messages:[]}}if(t.teleport)try{if(!st(`allow_remote_sessions`))throw Error(`Remote sessions are disabled by your organization's policy.`);if(J(`tengu_teleport_print`,{}),typeof t.teleport!=`string`)throw Error(`No session ID provided for teleport`);let{checkOutTeleportedSessionBranch:e,processMessagesForTeleportResume:n,teleportResumeCodeSession:r,validateGitState:i}=await import(`./teleport-IzyDplC7.js`);await i();let a=await r(t.teleport),{branchError:o}=await e(a.branch);return{messages:n(a.log,o)}}catch(e){return q(e),E(1),{messages:[]}}if(t.resume)try{J(`tengu_resume_print`,{});let i=Ml(typeof t.resume==`string`?t.resume:``);if(!i){let e=`Error: --resume requires a valid session ID when used with --print. Usage: claude -p --resume <session-id>`;return typeof t.resume==`string`&&(e+=`. Session IDs must be in UUID format (e.g., 550e8400-e29b-41d4-a716-446655440000). Provided value "${t.resume}" is not a valid UUID`),$l(e,t.outputFormat),E(1),{messages:[]}}if(n(process.env.CLAUDE_CODE_USE_CCR_V2)){let[,n]=await Promise.all([zn(i.sessionId),t.restoredWorkerState]);n&&(e(ja(n)),typeof n.model==`string`&&fr(n.model))}else i.isUrl&&i.ingressUrl&&n(process.env.ENABLE_SESSION_PERSISTENCE)&&await er(i.sessionId,i.ingressUrl);let a=await O(i.sessionId,i.jsonlFile||void 0);if(!a||a.messages.length===0)return i.isUrl||n(process.env.CLAUDE_CODE_USE_CCR_V2)?{messages:await(t.sessionStartHooksPromise??Lt(`startup`))}:($l(`No conversation found with session ID: ${i.sessionId}`,t.outputFormat),E(1),{messages:[]});if(t.resumeSessionAt){let e=a.messages.findIndex(e=>e.uuid===t.resumeSessionAt);if(e<0)return $l(`No message found with message.uuid of: ${t.resumeSessionAt}`,t.outputFormat),E(1),{messages:[]};a.messages=e>=0?a.messages.slice(0,e+1):[]}return!t.forkSession&&a.sessionId&&(vr(ce(a.sessionId),a.fullPath?Ja(a.fullPath):null),r&&await kn()),Ha(a,e),sn(t.forkSession?{...a,worktreeSession:void 0}:a),{messages:a.messages,turnInterruptionState:a.turnInterruptionState,agentSetting:a.agentSetting}}catch(e){return q(e),$l(e instanceof Error?`Failed to resume session: ${e.message}`:`Failed to resume session with --print mode`,t.outputFormat),E(1),{messages:[]}}return{messages:await(t.sessionStartHooksPromise??Lt(`startup`))}}function nu(e,t){let n;return n=typeof e==`string`?e.trim()===``?ke([]):ke([Cr({type:`user`,content:e,uuid:``,session_id:``,message:{role:`user`,content:e},parent_tool_use_id:null})]):e,t.sdkUrl?new dl(t.sdkUrl,n,t.replayUserMessages):new sl(n,t.replayUserMessages)}async function ru({message:e,setAppState:t,onEnqueued:n,handledToolUseIds:r}){let i=e.response;if(i?.subtype===`success`&&i.response?.toolUseID&&typeof i.response.toolUseID==`string`){let e=i.response,t=e.toolUseID;if(!t)return!1;if(G(`handleOrphanedPermissionResponse: received orphaned control_response for toolUseID=${t} request_id=${i.request_id}`),r.has(t))return G(`handleOrphanedPermissionResponse: skipping duplicate orphaned permission for toolUseID=${t} (already handled)`),!1;let a=await je(t);return a?(r.add(t),G(`handleOrphanedPermissionResponse: enqueuing orphaned permission for toolUseID=${t} messageID=${a.message.id}`),Xe({mode:`orphaned-permission`,value:[],orphanedPermission:{permissionResult:e,assistantMessage:a}}),n?.(),!0):(G(`handleOrphanedPermissionResponse: no unresolved tool_use found for toolUseID=${t} (already resolved in transcript)`),!1)}return!1}function iu(e){return{...e,scope:`dynamic`}}async function au(e,t,n,r){let{allowed:i,blocked:a}=m(e),o={};for(let e of a)o[e]=`Blocked by enterprise policy (allowedMcpServers/deniedMcpServers)`;let s={},c={};for(let[e,t]of Object.entries(i))t.type===`sdk`?s[e]=t:c[e]=t;let l=new Set(Object.keys(t.configs)),u=new Set(Object.keys(s)),d=[],f=[],p={...t.configs},h=[...t.clients],g=[...t.tools];for(let e of l)if(!u.has(e)){let t=h.find(t=>t.name===e);t&&t.type===`connected`&&await t.cleanup(),h=h.filter(t=>t.name!==e);let n=`mcp__${e}__`;g=g.filter(e=>!e.name.startsWith(n)),delete p[e],f.push(e)}for(let[e,t]of Object.entries(s))if(!l.has(e)){p[e]=t;let n={type:`pending`,name:e,config:{...t,scope:`dynamic`}};h=[...h,n],d.push(e)}let ee=await ou(c,n,r);return{response:{added:[...d,...ee.response.added],removed:[...f,...ee.response.removed],errors:{...o,...ee.response.errors}},newSdkState:{configs:p,clients:h,tools:g},newDynamicState:ee.newState,sdkServersChanged:d.length>0||f.length>0}}async function ou(e,t,n){let r=new Set(Object.keys(t.configs)),i=new Set(Object.keys(e)),a=[...r].filter(e=>!i.has(e)),o=[...i].filter(e=>!r.has(e)),s=[...r].filter(e=>i.has(e)).filter(n=>{let r=t.configs[n],i=e[n];return!r||!i||!Le(r,iu(i))}),c=[],l=[],u={},d=[...t.clients],f=[...t.tools];for(let e of[...a,...s]){let n=d.find(t=>t.name===e),r=t.configs[e];if(n&&r){if(n.type===`connected`)try{await n.cleanup()}catch(e){q(e)}await Vn(e,r)}let i=`mcp__${e}__`;f=f.filter(e=>!e.name.startsWith(i)),d=d.filter(t=>t.name!==e),a.includes(e)&&c.push(e)}for(let t of[...o,...s]){let n=e[t];if(!n)continue;let r=iu(n);if(n.type===`sdk`){l.push(t);continue}try{let e=await ze(t,r);if(d.push(e),e.type===`connected`){let t=await De(e);f.push(...t)}else e.type===`failed`&&(u[t]=e.error||`Connection failed`);l.push(t)}catch(e){let n=Dr(e);u[t]=n.message,q(n)}}let p={};for(let t of i){let n=e[t];n&&(p[t]=iu(n))}let m={clients:d,tools:f,configs:p};return n(e=>{let n=new Set([...Object.keys(t.configs),...Object.keys(p)]),r=e.mcp.tools.filter(e=>{for(let t of n)if(e.name.startsWith(`mcp__${t}__`))return!1;return!0}),i=e.mcp.clients.filter(e=>!n.has(e.name));return{...e,mcp:{...e.mcp,tools:[...r,...f],clients:[...i,...d]}}}),{response:{added:l,removed:c,errors:u},newState:m}}export{Kl as runHeadless};
@@ -0,0 +1 @@
1
+ import{a as e}from"./rolldown-runtime-DaDcL9Zw.js";import{DC as t,Gm as n,Km as r,La as i,OC as a,Rg as o,Sa as s,Um as c,Wm as l,Xc as u,Yc as d,mp as f,pp as p,qa as m,va as h,xa as g,zg as _}from"./loadAgentsDir-CwEfQDOw.js";import{I as v,t as y}from"./src-DL3w8VPk2.js";import{t as b}from"./jsx-runtime-Bb4Xn-E0.js";import{A as x,P as S,R as C}from"./debug-BQj6h99Q.js";import{g as w,n as T}from"./settings-CvhsRFaT.js";import{n as E,r as D}from"./analytics-DJobLaWP.js";import{bt as O,yt as k}from"./prompt-Bm2EEG4F.js";import{randomUUID as A}from"crypto";y(),l(),f(),r();var j=b();function M({input:e,progress:t,verbose:r}){return(0,j.jsxs)(v,{flexDirection:`column`,marginTop:1,children:[(0,j.jsx)(p,{addMargin:!1,param:{text:`<bash-input>${e}</bash-input>`,type:`text`}}),t?(0,j.jsx)(n,{fullOutput:t.fullOutput,output:t.output,elapsedTimeSeconds:t.elapsedTimeSeconds,totalLines:t.totalLines,verbose:r}):c.renderToolUseProgressMessage?.([],{verbose:r,tools:[],terminalSize:void 0})]})}C(),E(),t(),i(),w();function N(){return T().defaultShell??`bash`}l(),k(),_();async function P(t,n,r,i,l){let f=O()&&N()===`powershell`;D(`tengu_input_bash`,{powershell:f});let p=s({content:m({inputString:`<bash-input>${t}</bash-input>`,precedingInputBlocks:n})}),_;l({jsx:(0,j.jsx)(M,{input:t,progress:null,verbose:i.options.verbose}),shouldHidePromptInput:!1});try{let n={...i,setToolJSX:e=>{_=e?.jsx}},m=e=>{l({jsx:(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(M,{input:t,progress:e.data,verbose:i.options.verbose}),_]}),shouldHidePromptInput:!1,showSpinner:!1})},g=null;f&&(g=(u(),e(d)).PowerShellTool);let v=g??c,y=(g?await g.call({command:t,dangerouslyDisableSandbox:!0},n,void 0,void 0,m):await c.call({command:t,dangerouslyDisableSandbox:!0},n,void 0,void 0,m)).data;if(!y)throw Error(`No result received from shell command`);let b=y.stderr,x=await a(v,{...y,stderr:``},A()),S=typeof x.content==`string`?x.content:o(y.stdout);return{messages:[h(),p,...r,s({content:`<bash-stdout>${S}</bash-stdout><bash-stderr>${o(b)}</bash-stderr>`})],shouldQuery:!1}}catch(e){return e instanceof x?e.interrupted?{messages:[h(),p,g({toolUse:!1}),...r],shouldQuery:!1}:{messages:[h(),p,...r,s({content:`<bash-stdout>${o(e.stdout)}</bash-stdout><bash-stderr>${o(e.stderr)}</bash-stderr>`})],shouldQuery:!1}:{messages:[h(),p,...r,s({content:`<bash-stderr>Command failed: ${o(S(e))}</bash-stderr>`})],shouldQuery:!1}}finally{l(null)}}export{P as processBashCommand};
@@ -0,0 +1,5 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{$_ as t,Ap as n,B as r,Bb as i,Cm as a,Ds as o,Dv as s,E as c,Ea as l,Fc as u,Fw as d,GC as f,Ga as p,Gw as m,Ha as h,Ic as g,Ii as _,KC as v,La as y,Li as b,Mp as x,Np as S,Nw as C,Of as w,Pw as T,Ra as ee,Sa as E,Sf as D,Sm as O,Tf as k,Ti as A,Ts as j,Uh as M,V as N,WC as te,Wh as ne,Ww as re,Xp as ie,Xv as ae,Yp as oe,Zv as se,b as ce,bf as le,c_ as ue,ha as P,ji as de,jp as fe,kf as pe,ki as me,kp as he,lc as ge,qa as F,ry as I,sc as L,tv as _e,u_ as ve,uc as ye,va as R,wm as be,ws as xe,wv as Se,xa as Ce,xf as we,ya as Te,zb as Ee,zi as z}from"./loadAgentsDir-CwEfQDOw.js";import{Gn as De,Wt as Oe,pt as ke,t as Ae}from"./state-BPFYBqm1.js";import{E as je,R as Me,c as B,f as Ne,i as V,k as H,u as Pe}from"./debug-BQj6h99Q.js";import{Dt as Fe,Ot as Ie}from"./settings-CvhsRFaT.js";import{T as U,o as Le,q as Re,s as W,w as G}from"./log-BlJ7CcKG.js";import{n as ze,r as K}from"./analytics-DJobLaWP.js";import{_n as Be,ni as Ve,ti as He,vn as Ue}from"./model-CeG-iOKF.js";import{ct as We,ot as Ge}from"./esm-DtcV71xh.js";import{E as Ke,T as qe,w as Je}from"./sessionTracing-C4uqAdud.js";import{randomUUID as q}from"crypto";function Ye(e,t,n,r,i){let a=0;for(let o of Ie){let s=n[o];if(s)for(let n of s)for(let s of n.hooks){let c=s.once?()=>{B(`Removing one-shot hook for event ${o} in skill '${r}'`),S(e,t,o,s)}:void 0;fe(e,t,o,n.matcher||``,s,c,i),a++}}a>0&&B(`Registered ${a} hooks from skill '${r}'`)}var Xe=e((()=>{Fe(),V(),x()}));function Ze(e){let t=e.trim();if(!t.startsWith(`/`))return null;let n=t.slice(1).split(` `);if(!n[0])return null;let r=n[0],i=!1,a=1;n.length>1&&n[1]===`(MCP)`&&(r=`${r} (MCP)`,i=!0,a=2);let o=n.slice(a).join(` `);return{commandName:r,args:o,isMcp:i}}var Qe=e((()=>{}));function $e(){return!1}function J(){if(!$e())throw Error(`ToolUseContext.options.allowBackgroundForkedSlashCommands is test-only and cannot be enabled outside NODE_ENV=test.`)}async function et(e,t,r,i,o,s,c){let l=oe(),u=e.pluginInfo?d(e.pluginInfo.repository).marketplace:void 0;K(`tengu_slash_command_forked`,{command_name:e.name,invocation_trigger:`user-slash`,...e.pluginInfo&&{_PROTO_plugin_name:e.pluginInfo.pluginManifest.name,...u&&{_PROTO_marketplace_name:u},...D(e.pluginInfo)}});let{skillContent:f,modifiedGetAppState:m,baseAgent:h,promptMessages:g}=await ye(e,t,r);B(`Executing forked slash command /${e.name} with agent ${h.agentType}`);let _=r.options.allowBackgroundForkedSlashCommands===!0;if(_&&J(),_){let t=Ee(),i=z(e),o=He(),u=e=>se({value:e,mode:`prompt`,priority:`later`,isMeta:!0,skipSlashCommands:!0,workload:o}),d=async()=>{if(!c?.runId)return;let e=await O({runId:c.runId,rootDir:c.rootDir,priority:`later`,workload:o});for(let t of e)ae(t)},f=async e=>{c?.runId&&await a({runId:c.runId,rootDir:c.rootDir,error:e instanceof Error?e.message:String(e)})};return(async()=>{let a=Date.now()+$;for(;Date.now()<a&&r.getAppState().mcp.clients.some(e=>e.type===`pending`);)await Ue(Q);let o=r.options.refreshTools?.()??r.options.tools,c=[];for await(let i of n({agentDefinition:h,promptMessages:g,toolUseContext:{...r,getAppState:m,abortController:t},canUseTool:s,isAsync:!0,querySource:`agent:custom`,model:e.model,availableTools:o,override:{agentId:l}}))c.push(i);let f=L(c,`Command completed`);B(`Background forked command /${i} completed (agent ${l})`),u(`<scheduled-task-result command="/${i}">\n${f}\n</scheduled-task-result>`);try{await d()}catch(e){W(e)}})().catch(async e=>{W(e),u(`<scheduled-task-result command="/${i}" status="failed">\n${e instanceof Error?e.message:String(e)}\n</scheduled-task-result>`),await f(e)}),{messages:[],shouldQuery:!1,command:e,deferAutonomyCompletion:!!c?.runId}}let v=[],y=[],b=`forked-command-${e.name}`,x=0,S=e=>(x++,{type:`progress`,data:{message:e,type:`agent_progress`,prompt:f,agentId:l},parentToolUseID:b,toolUseID:`${b}-${x}`,timestamp:new Date().toISOString(),uuid:q()}),C=()=>{o({jsx:pe(y,{tools:r.options.tools,verbose:!1}),shouldHidePromptInput:!1,shouldContinueAnimation:!0,showSpinner:!0})};C();try{for await(let t of n({agentDefinition:h,promptMessages:g,toolUseContext:{...r,getAppState:m},canUseTool:s,isAsync:!1,querySource:`agent:custom`,model:e.model,availableTools:r.options.tools})){v.push(t);let e=p([t]);if(t.type===`assistant`){let n=Se(t);n>0&&r.setResponseLength(e=>e+n);let i=e[0];i&&i.type===`assistant`&&(y.push(S(t)),C())}if(t.type===`user`){let t=e[0];t&&t.type===`user`&&(y.push(S(t)),C())}}}finally{o(null)}let w=L(v,`Command completed`);return B(`Forked slash command /${e.name} completed with agent ${l}`),{messages:[E({content:F({inputString:`/${z(e)} ${t}`.trim(),precedingInputBlocks:i})}),E({content:`<local-command-stdout>\n${w}\n</local-command-stdout>`})],shouldQuery:!1,command:e,resultText:w}}function tt(e){return!/[^a-zA-Z0-9:\-_]/.test(e)}async function nt(e,t,n,r,i,a,o,s,c,l){let u=Ze(e);if(!u){K(`tengu_input_slash_missing`,{});let e="Commands are in the form `/command [args]`";return{messages:[R(),...r,E({content:F({inputString:e,precedingInputBlocks:t})})],shouldQuery:!1,resultText:e}}let{commandName:f,args:p,isMcp:m}=u,g=m?`mcp`:A().has(f)?f:`custom`;if(!_(f,i.options.commands)){let n=!1;try{await Pe().stat(`/${f}`),n=!0}catch{}if(tt(f)&&!n){K(`tengu_input_slash_invalid`,{input:f});let e=`Unknown skill: ${f}`;return{messages:[R(),...r,E({content:F({inputString:e,precedingInputBlocks:t})}),...p?[Te(`Args from unknown skill: ${p}`,`warning`)]:[]],shouldQuery:!1,resultText:e}}let i=q();return De(i),K(`tengu_input_prompt`,{}),qe(`user_prompt`,{prompt_length:String(e.length),prompt:Ke(e),"prompt.id":i}),{messages:[E({content:F({inputString:e,precedingInputBlocks:t}),uuid:o}),...r],shouldQuery:!0}}let{messages:v,shouldQuery:y,allowedTools:b,model:x,command:S,resultText:C,nextInput:w,submitNextInput:O,deferAutonomyCompletion:k}=await rt(f,p,a,i,t,n,s,c,o,l);if(v.length===0){let e={input:g};if(S.type===`prompt`&&S.pluginInfo){let{pluginManifest:t,repository:n}=S.pluginInfo,{marketplace:r}=d(n),i=T(r);e._PROTO_plugin_name=t.name,r&&(e._PROTO_marketplace_name=r),e.plugin_repository=i?n:`third-party`,e.plugin_name=i?t.name:`third-party`,i&&t.version&&(e.plugin_version=t.version),Object.assign(e,D(S.pluginInfo))}return K(`tengu_input_command`,{...e,invocation_trigger:`user-slash`}),{messages:[],shouldQuery:!1,model:x,nextInput:w,submitNextInput:O,deferAutonomyCompletion:k}}if(v.length===2&&v[1].type===`user`&&typeof v[1].message.content==`string`&&v[1].message.content.startsWith(`Unknown command:`))return e.startsWith(`/var`)||e.startsWith(`/tmp`)||e.startsWith(`/private`)||K(`tengu_input_slash_invalid`,{input:f}),{messages:[R(),...v],shouldQuery:y,allowedTools:b,model:x};let j={input:g};if(S.type===`prompt`&&S.pluginInfo){let{pluginManifest:e,repository:t}=S.pluginInfo,{marketplace:n}=d(t),r=T(n);j._PROTO_plugin_name=e.name,n&&(j._PROTO_marketplace_name=n),j.plugin_repository=r?t:`third-party`,j.plugin_name=r?e.name:`third-party`,r&&e.version&&(j.plugin_version=e.version),Object.assign(j,D(S.pluginInfo))}K(`tengu_input_command`,{...j,invocation_trigger:`user-slash`});let M=v.length>0&&v[0]&&ee(v[0]);return{messages:y||v.every(h)||M?v:[R(),...v],shouldQuery:y,allowedTools:b,model:x,resultText:C,nextInput:w,submitNextInput:O,deferAutonomyCompletion:k}}async function rt(e,t,n,i,a,o,s,c,l,u){let d=de(e,i.options.commands);if(d.type===`prompt`&&d.userInvocable!==!1&&we(e),d.userInvocable===!1)return{messages:[E({content:F({inputString:`/${e}`,precedingInputBlocks:a})}),E({content:`This skill can only be invoked by Work Mate, not directly by users. Ask Work Mate to use the "${e}" skill for you.`})],shouldQuery:!1,command:d};try{switch(d.type){case`local-jsx`:return new Promise(e=>{let r=!1,o=(n,i)=>{if(r=!0,i?.display===`skip`){e({messages:[],shouldQuery:!1,command:d,nextInput:i?.nextInput,submitNextInput:i?.submitNextInput});return}let o=(i?.metaMessages??[]).map(e=>E({content:e,isMeta:!0})),s=ne()&&typeof n==`string`&&n.endsWith(` dismissed`),c=i?.displayArgs??t;e({messages:i?.display===`system`?s?o:[P(Y(d,c)),P(`<local-command-stdout>${n}</local-command-stdout>`),...o]:[E({content:F({inputString:Y(d,c),precedingInputBlocks:a})}),E(n?{content:`<local-command-stdout>${n}</local-command-stdout>`}:{content:`<local-command-stdout>${re}</local-command-stdout>`}),...o],shouldQuery:i?.shouldQuery??!1,command:d,nextInput:i?.nextInput,submitNextInput:i?.submitNextInput})};d.load().then(e=>e.call(o,{...i,canUseTool:c},t)).then(t=>{if(t!=null){if(i.options.isNonInteractiveSession){e({messages:[],shouldQuery:!1,command:d});return}r||n({jsx:t,shouldHidePromptInput:!0,showSpinner:!1,isLocalJSXCommand:!0,isImmediate:d.immediate===!0})}}).catch(t=>{W(t),!r&&(r=!0,n({jsx:null,shouldHidePromptInput:!1,clearLocalJSX:!0}),e({messages:[],shouldQuery:!1,command:d}))})});case`local`:{let e=E({content:F({inputString:Y(d,d.isSensitive&&t.trim()?`***`:t),precedingInputBlocks:a})});try{let n=R(),r=await(await d.load()).call(t,i);if(r.type===`skip`)return{messages:[],shouldQuery:!1,command:d};if(r.type===`compact`){let t=[n,e,...r.displayText?[E({content:`<local-command-stdout>${r.displayText}</local-command-stdout>`,timestamp:new Date(Date.now()+100).toISOString()})]:[]],i={...r.compactionResult,messagesToKeep:[...r.compactionResult.messagesToKeep??[],...t]};return _e(),{messages:ue(i),shouldQuery:!1,command:d}}return{messages:[e,P(`<local-command-stdout>${r.value}</local-command-stdout>`)],shouldQuery:!1,command:d,resultText:r.value}}catch(t){return W(t),{messages:[e,P(`<local-command-stderr>${String(t)}</local-command-stderr>`)],shouldQuery:!1,command:d}}}case`prompt`:try{return d.context===`fork`?await et(d,t,i,a,n,c??r,u):await Z(d,t,i,a,o,l)}catch(e){return e instanceof je?{messages:[E({content:F({inputString:Y(d,t),precedingInputBlocks:a})}),Ce({toolUse:!1})],shouldQuery:!1,command:d}:{messages:[E({content:F({inputString:Y(d,t),precedingInputBlocks:a})}),E({content:`<local-command-stderr>${String(e)}</local-command-stderr>`})],shouldQuery:!1,command:d}}}}catch(e){if(e instanceof H)return{messages:[E({content:F({inputString:e.message,precedingInputBlocks:a})})],shouldQuery:!1,command:d};throw e}}function Y(e,t){return l(z(e),t)}function X(e,t=`loading`){return[`<${G}>${e}</${G}>`,`<${U}>${e}</${U}>`,`<skill-format>true</skill-format>`].join(`
2
+ `)}function it(e,t){return[`<${G}>${e}</${G}>`,`<${U}>/${e}</${U}>`,t?`<command-args>${t}</command-args>`:null].filter(Boolean).join(`
3
+ `)}function at(e,t){return e.userInvocable===!1&&(e.loadedFrom===`skills`||e.loadedFrom===`plugin`||e.loadedFrom===`mcp`)?X(e.name,e.progressMessage):it(e.name,t)}async function ot(e,t,n,r,i=[]){let a=me(e,n);if(!a)throw new H(`Unknown command: ${e}`);if(a.type!==`prompt`)throw Error(`Unexpected ${a.type} command. Expected 'prompt' command. Use /${e} directly in the main conversation.`);return Z(a,t,r,[],i)}async function Z(e,t,n,r=[],i=[],a){let o=await e.getPromptForCommand(t,n),s=!f(`hooks`)||v(e.source);if(e.hooks&&s){let t=ke();Ye(n.setAppState,t,e.hooks,e.name,e.type===`prompt`?e.skillRoot:void 0)}let l=e.source?`${e.source}:${e.name}`:e.name,u=o.filter(e=>e.type===`text`).map(e=>e.text).join(`
4
+
5
+ `);Ae(e.name,l,u,Ge()?.agentId??null);let d=at(e,t),p=c(e.allowedTools??[]),m=i.length>0||r.length>0?[...i,...r,...o]:o,h=await g(j(o.filter(e=>e.type===`text`).map(e=>e.text).join(` `),n,null,[],n.messages,`repl_main_thread`,{skipSkillDiscovery:!0}));return{messages:[E({content:d,uuid:a}),E({content:m,isMeta:!0}),...h,xe({type:`command_permissions`,allowedTools:p,model:e.model})],shouldQuery:!0,allowedTools:p,model:e.model,command:e}}var Q,$;e((()=>{Oe(),b(),m(),Re(),ze(),ve(),t(),he(),w(),i(),We(),o(),V(),Me(),ge(),Ne(),M(),u(),Xe(),Le(),I(),y(),ce(),N(),C(),te(),Qe(),Be(),le(),Je(),k(),s(),ie(),be(),Ve(),Q=200,$=1e4}))();export{X as formatSkillLoadingMetadata,ot as processPromptSlashCommand,nt as processSlashCommand};