@readmagic/workmate 0.0.10 → 0.0.12

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 (437) hide show
  1. package/dist/chunks/{AddWorkspaceDirectory-Vmmm7p1c.js → AddWorkspaceDirectory-CtRxzRny.js} +1 -1
  2. package/dist/chunks/AgentsMdExternalIncludesDialog-_bI4jo_P.js +1 -0
  3. package/dist/chunks/AgentsMdExternalIncludesDialog-_yJJ0wqu.js +1 -0
  4. package/dist/chunks/App-DoAZ7CYS.js +1 -0
  5. package/dist/chunks/ApproveApiKey-C8LwmDM2.js +1 -0
  6. package/dist/chunks/ApproveApiKey-DQP3qmb0.js +1 -0
  7. package/dist/chunks/BackgroundTasksDialog-CDA2noEk.js +2 -0
  8. package/dist/chunks/{BypassPermissionsModeDialog-CLSACUmo.js → BypassPermissionsModeDialog-COI_V57z.js} +1 -1
  9. package/dist/chunks/ConsoleOAuthFlow-Dn8fO-o_.js +1 -0
  10. package/dist/chunks/{DiffDialog-9AYwtupw.js → DiffDialog-CRWtQ1R5.js} +3 -3
  11. package/dist/chunks/Doctor-CZ513Df9.js +3 -0
  12. package/dist/chunks/Doctor-CzPvNZzF.js +1 -0
  13. package/dist/chunks/ExitFlow-BFeftDv0.js +2 -0
  14. package/dist/chunks/{Grove-B9-hhkZA.js → Grove-DRZrhbF0.js} +2 -2
  15. package/dist/chunks/{HybridTransport-MxJ_W_np.js → HybridTransport-BadJQe6u.js} +4 -4
  16. package/dist/chunks/InvalidConfigDialog-DQaT6aen.js +1 -0
  17. package/dist/chunks/{InvalidSettingsDialog-YyQcHocx.js → InvalidSettingsDialog-ISzcIGPU.js} +1 -1
  18. package/dist/chunks/MCPConnectionManager-BpjC7CEo.js +1 -0
  19. package/dist/chunks/MCPToolListView-Rb1Q--jG.js +1 -0
  20. package/dist/chunks/{McpParsingWarnings-BCpfHaBK.js → McpParsingWarnings-xv0RZCSL.js} +1 -1
  21. package/dist/chunks/MessageSelector-BHB55sZb.js +3 -0
  22. package/dist/chunks/Messages-CPX-nIdA.js +11 -0
  23. package/dist/chunks/Onboarding-CymgipoF.js +1 -0
  24. package/dist/chunks/{PromptInputFooterSuggestions-BSA9NrZc.js → PromptInputFooterSuggestions-8-awCxOn.js} +1 -1
  25. package/dist/chunks/PromptInputHelpMenu-BP3UgCdi.js +1 -0
  26. package/dist/chunks/QueryEngine-HkswHUNv.js +1 -0
  27. package/dist/chunks/REPL-CZfg65kg.js +133 -0
  28. package/dist/chunks/REPL-eZsYNBfl.js +1 -0
  29. package/dist/chunks/RemoteSessionManager-B4jqKVd3.js +2 -0
  30. package/dist/chunks/ResumeConversation-B03XN_SP.js +1 -0
  31. package/dist/chunks/{SSETransport-CoxQ8YpH.js → SSETransport-je346ofV.js} +3 -3
  32. package/dist/chunks/SearchExtraToolsTool-C85Sanww.js +1 -0
  33. package/dist/chunks/Settings-C8GKWod1.js +2 -0
  34. package/dist/chunks/{TeleportProgress-Doucj-50.js → TeleportProgress-zmdAsogZ.js} +1 -1
  35. package/dist/chunks/{TeleportRepoMismatchDialog-B5I73j7Y.js → TeleportRepoMismatchDialog-CG32I4cO.js} +1 -1
  36. package/dist/chunks/{TeleportResumeWrapper-D6kpr2c6.js → TeleportResumeWrapper-2Yjr74Lq.js} +1 -1
  37. package/dist/chunks/{ThemePicker-DrC8tlp0.js → ThemePicker-p7_hHk1V.js} +1 -1
  38. package/dist/chunks/TrustDialog-BVcny9vs.js +1 -0
  39. package/dist/chunks/{ValidationErrorsList-D_OUa4RT.js → ValidationErrorsList-DSSUWdgd.js} +1 -1
  40. package/dist/chunks/{WelcomeV2-DvfQHnZY.js → WelcomeV2-BnSYhyfu.js} +1 -1
  41. package/dist/chunks/add-dir-Bd7pilVx.js +1 -0
  42. package/dist/chunks/{agentDisplay-B755vMZE.js → agentDisplay-CfMLGPGH.js} +1 -1
  43. package/dist/chunks/{agents-CIvP8l0s.js → agents-BT82hwBN.js} +1 -1
  44. package/dist/chunks/agents-qR6r94-F.js +103 -0
  45. package/dist/chunks/allErrors-CS77lRvU.js +1 -0
  46. package/dist/chunks/api-C4VflFau.js +1 -0
  47. package/dist/chunks/{api-nSHc_GIQ.js → api-DAubp5q9.js} +1 -1
  48. package/dist/chunks/auth-CNCehj7y.js +1 -0
  49. package/dist/chunks/auth-DrD9DW6X.js +1 -0
  50. package/dist/chunks/{auth-5QB6tsfB.js → auth-yDsvFcM7.js} +2 -2
  51. package/dist/chunks/{autoMode-BnUiK9Cu.js → autoMode-C2lnBot9.js} +6 -6
  52. package/dist/chunks/backgroundHousekeeping-DbpTGbwl.js +1 -0
  53. package/dist/chunks/backgroundHousekeeping-SpTxViUq.js +17 -0
  54. package/dist/chunks/{banner-D0P7wXdw.js → banner-BcAM7iSx.js} +1 -1
  55. package/dist/chunks/bg-Ci7pG4eo.js +9 -0
  56. package/dist/chunks/{branch-DFWa4Oxo.js → branch-DJiMa8td.js} +2 -2
  57. package/dist/chunks/{break-cache-Chj9i9MP.js → break-cache-4rlQORVk.js} +2 -2
  58. package/dist/chunks/{bridgeConfig-Bb6URf4Q.js → bridgeConfig-BB6Hgali.js} +1 -1
  59. package/dist/chunks/bridgeConfig-Ccm79Jze.js +1 -0
  60. package/dist/chunks/{bridgeMessaging-C3huGcR3.js → bridgeMessaging-C9D0Lly2.js} +1 -1
  61. package/dist/chunks/{bridgePointer-DLYyvRKb.js → bridgePointer-DHWK3LEe.js} +1 -1
  62. package/dist/chunks/{bridgeStatusUtil-DFMftajD.js → bridgeStatusUtil-D8UbcVrZ.js} +1 -1
  63. package/dist/chunks/{btw-DSK9R2C8.js → btw-BO2B23f-.js} +1 -1
  64. package/dist/chunks/caches-BQmbXerw.js +1 -0
  65. package/dist/chunks/caches-Dtjmjm6G.js +1 -0
  66. package/dist/chunks/{capacityWake-amzeeBz0.js → capacityWake-ByL6fM6I.js} +1 -1
  67. package/dist/chunks/ccrClient-BG9HU_fW.js +1 -0
  68. package/dist/chunks/{claudeDesktop-CsJfF1b-.js → claudeDesktop-Ct_hyICL.js} +1 -1
  69. package/dist/chunks/{clear-ClFDpWVJ.js → clear-B4XN2fib.js} +1 -1
  70. package/dist/chunks/cliLaunch-OPOtzhvA.js +1 -0
  71. package/dist/chunks/client-7lIxWcaM.js +1 -0
  72. package/dist/chunks/client-B-2ccQZk.js +1 -0
  73. package/dist/chunks/{client-DFlE4fYh.js → client-BMA05FW8.js} +1 -1
  74. package/dist/chunks/commands-D_-v6_A0.js +1 -0
  75. package/dist/chunks/compact-kM0ETtB2.js +2 -0
  76. package/dist/chunks/config-9rLTDOYW.js +3 -0
  77. package/dist/chunks/config-Crf6Mzu3.js +1 -0
  78. package/dist/chunks/{config-CVHMRMwd.js → config-DMKtiMzJ.js} +1 -1
  79. package/dist/chunks/context-BY5oO5is.js +1 -0
  80. package/dist/chunks/{context-noninteractive-D5iQhasu.js → context-noninteractive-mAQt1p9l.js} +5 -5
  81. package/dist/chunks/context-noninteractive-tc4KTYfI.js +1 -0
  82. package/dist/chunks/conversation-CFIn-KsW.js +1 -0
  83. package/dist/chunks/conversation-DPI7VKBL.js +1 -0
  84. package/dist/chunks/createSSHSession-DjLSGm-0.js +6 -0
  85. package/dist/chunks/createSession-CftIZ3aq.js +1 -0
  86. package/dist/chunks/createSession-CjdLcRec.js +1 -0
  87. package/dist/chunks/crossProjectResume-BJqXBzkf.js +40 -0
  88. package/dist/chunks/{cwd-Cfdf7z7s.js → cwd-Besi3Os3.js} +1 -1
  89. package/dist/chunks/cwd-DpqwaYHw.js +1 -0
  90. package/dist/chunks/datadog-BGati3aQ.js +1 -0
  91. package/dist/chunks/debug-Dr1SjdXn.js +39 -0
  92. package/dist/chunks/{debugUtils-DX0KAXNK.js → debugUtils-cK-iOsEV.js} +1 -1
  93. package/dist/chunks/detached-CqfQYVOi.js +5 -0
  94. package/dist/chunks/detectRepository-BsKZDRoI.js +1 -0
  95. package/dist/chunks/detectRepository-CMEkS5_2.js +1 -0
  96. package/dist/chunks/{diff-jEJJe58I.js → diff-1HsxKGBh.js} +1 -1
  97. package/dist/chunks/{directoryCompletion-BbXR2bfy.js → directoryCompletion-ByBTSuLu.js} +1 -1
  98. package/dist/chunks/doctor-CJfvt9zR.js +1 -0
  99. package/dist/chunks/entry-CrZCZQQC.js +14 -0
  100. package/dist/chunks/{envUtils-BDhHQY0-.js → envUtils-DcaKZlRU.js} +1 -1
  101. package/dist/chunks/{esm-Cf4nSRjF.js → esm-BkOWaWVb.js} +1 -1
  102. package/dist/chunks/{execFileNoThrow-Dwu6psHW.js → execFileNoThrow-mXq4K0rl.js} +2 -2
  103. package/dist/chunks/execSyncWrapper-Ne33rRiD.js +1 -0
  104. package/dist/chunks/exit-B8MA4Ltm.js +1 -0
  105. package/dist/chunks/{extraUsage-Mi66JwFZ.js → extraUsage-0pUcYexI.js} +1 -1
  106. package/dist/chunks/extractMemories-DqhN0lba.js +1 -0
  107. package/dist/chunks/fast-DT5WDe3L.js +1 -0
  108. package/dist/chunks/{fast-BU4iUZ8E.js → fast-VOu2FUlV.js} +1 -1
  109. package/dist/chunks/{fileSuggestions-BMfQIDdW.js → fileSuggestions-Be-pyLLq.js} +3 -3
  110. package/dist/chunks/firstPartyEventLogger-B8RVGBQB.js +1 -0
  111. package/dist/chunks/{firstPartyEventLogger-B3cXgR67.js → firstPartyEventLogger-aFhcruXA.js} +2 -2
  112. package/dist/chunks/{flushGate-DgSDVGKZ.js → flushGate-BUSrMj_6.js} +1 -1
  113. package/dist/chunks/gemini-DB4M-MYv.js +1 -0
  114. package/dist/chunks/generateSessionName-DhCypqJ_.js +1 -0
  115. package/dist/chunks/{genericProcessUtils-CmsUPyRz.js → genericProcessUtils-Dc1pfb7J.js} +1 -1
  116. package/dist/chunks/git-Bs1vtuvX.js +1 -0
  117. package/dist/chunks/git-CoQQ6YEf.js +6 -0
  118. package/dist/chunks/githubRepoPathMapping-CmpEaQoo.js +1 -0
  119. package/dist/chunks/goal-TxXtfkQ6.js +3 -0
  120. package/dist/chunks/{grok-BXMvezWb.js → grok-D2a_J5wE.js} +1 -1
  121. package/dist/chunks/{grove-CeOjTaY6.js → grove-BnzBbGsX.js} +1 -1
  122. package/dist/chunks/{help-5DNZO6_H.js → help-C5ankDi4.js} +1 -1
  123. package/dist/chunks/{hooks-C637tFtd.js → hooks-BZS105Rd.js} +3 -3
  124. package/dist/chunks/hooks-D-twhU_z.js +1 -0
  125. package/dist/chunks/{initReplBridge-D1h10vQ9.js → initReplBridge-DL4klK0C.js} +1 -1
  126. package/dist/chunks/{install-C-6ItpH0.js → install-NZvHd_40.js} +1 -1
  127. package/dist/chunks/{instrumentation-DaiPDUst.js → instrumentation-CjBlVlFq.js} +5 -5
  128. package/dist/chunks/{job-BeYzQUiR.js → job-D502Zf8J.js} +1 -1
  129. package/dist/chunks/jwtUtils-FQWtM6iM.js +1 -0
  130. package/dist/chunks/keybindings-D9Boc8FD.js +2 -0
  131. package/dist/chunks/{launchLocalMemory-CE4J98xO.js → launchLocalMemory-DxC3LojF.js} +2 -2
  132. package/dist/chunks/{launchOnboarding-BfTdC6vp.js → launchOnboarding-BLp5k_H4.js} +1 -1
  133. package/dist/chunks/{loadAgentsDir-C7lOqvfh.js → loadAgentsDir-BXtV2jiO.js} +563 -570
  134. package/dist/chunks/loadAgentsDir-BjsAQWqt.js +1 -0
  135. package/dist/chunks/loadPluginHooks-Dt3XQ-3N.js +1 -0
  136. package/dist/chunks/{localSearch-BKrznW5x.js → localSearch-CeP4ef0a.js} +1 -1
  137. package/dist/chunks/localSearch-Cz8Ot7k2.js +1 -0
  138. package/dist/chunks/{log-CezCRpAN.js → log-27kCA_9u.js} +1 -1
  139. package/dist/chunks/{logoV2Utils-BkQfyQ1-.js → logoV2Utils-CEnU8qad.js} +1 -1
  140. package/dist/chunks/{magicDocs-BpVcON9o.js → magicDocs-YtfrqVC6.js} +4 -4
  141. package/dist/chunks/main-CGLCy2pM.js +31 -0
  142. package/dist/chunks/main-CkjTzYj1.js +513 -0
  143. package/dist/chunks/{managedEnv-DhWRJ5DK.js → managedEnv-B-BNY0xC.js} +1 -1
  144. package/dist/chunks/managedEnv-K9Si1UuL.js +1 -0
  145. package/dist/chunks/{mappers-bOab8ipV.js → mappers-IuJeXgvr.js} +1 -1
  146. package/dist/chunks/mcp-DMBoeQzm.js +6 -0
  147. package/dist/chunks/mcp-TMOPfLcW.js +1 -0
  148. package/dist/chunks/mcp-x5rgv-uv.js +2 -0
  149. package/dist/chunks/{memoize-DsqYrbeR.js → memoize-Co4vS6UF.js} +1 -1
  150. package/dist/chunks/memory-DDUoR63T.js +1 -0
  151. package/dist/chunks/{mode-DlKnUM8l.js → mode-GzBwK--u.js} +2 -2
  152. package/dist/chunks/model-BydaMaPr.js +1 -0
  153. package/dist/chunks/model-CDnVaVDR.js +1 -0
  154. package/dist/chunks/model-CIvbC7rW.js +1 -0
  155. package/dist/chunks/{modelOptions-CxP067Qv.js → modelOptions-ut0xePEe.js} +1 -1
  156. package/dist/chunks/nativeInstaller-fgCMR_c0.js +1 -0
  157. package/dist/chunks/oauth-D38aRTUb.js +1 -0
  158. package/dist/chunks/oauth-U649LV5H.js +1 -0
  159. package/dist/chunks/{observationStore-BpjlK0pG.js → observationStore-D0rm3GhP.js} +1 -1
  160. package/dist/chunks/omit-D4Udf-p-.js +1 -0
  161. package/dist/chunks/onChangeAppState-WbvtqDtk.js +1 -0
  162. package/dist/chunks/{openai-B9C2XN5Q.js → openai-DaVFXyBB.js} +3 -3
  163. package/dist/chunks/panel-CoF2a-h4.js +1 -0
  164. package/dist/chunks/parser-B2PlJg4C.js +1 -0
  165. package/dist/chunks/{parser-BwPXQomy.js → parser-CUUiH40T.js} +1 -1
  166. package/dist/chunks/{partition-D-UhsUCx.js → partition-CzW_31Y1.js} +1 -1
  167. package/dist/chunks/permissions-BT3lxYBM.js +3 -0
  168. package/dist/chunks/pidLock-d1VPd6CG.js +3 -0
  169. package/dist/chunks/{plan-CyU2zrCK.js → plan-M9DG3AqN.js} +1 -1
  170. package/dist/chunks/{platform-BMPbglug.js → platform-Dg1c9F_1.js} +1 -1
  171. package/dist/chunks/plugin-BiNHuq3h.js +17 -0
  172. package/dist/chunks/pluginAutoupdate-B5lel6s5.js +1 -0
  173. package/dist/chunks/pluginBlocklist-CNGmIlwU.js +1 -0
  174. package/dist/chunks/pluginCliCommands-WLOEhb2M.js +1 -0
  175. package/dist/chunks/pluginFlagging-CXSSOj4J.js +1 -0
  176. package/dist/chunks/pluginOperations-BFbty6WT.js +2 -0
  177. package/dist/chunks/pluginStartupCheck-BEd0VeQC.js +1 -0
  178. package/dist/chunks/pluginStartupCheck-Bcdxg484.js +1 -0
  179. package/dist/chunks/plugins-BMZ3aYKP.js +4 -0
  180. package/dist/chunks/poorMode-Djw0P9Gu.js +1 -0
  181. package/dist/chunks/{poorMode-DEwQOAJt.js → poorMode-DxgO_bUb.js} +1 -1
  182. package/dist/chunks/print-DmoLcwVq.js +26 -0
  183. package/dist/chunks/processBashCommand-B-VqME9O.js +1 -0
  184. package/dist/chunks/processSlashCommand-D6zEooTy.js +5 -0
  185. package/dist/chunks/{projectContext-CIxul6vA.js → projectContext-BN2ZWzOG.js} +1 -1
  186. package/dist/chunks/{projectContext-RUMJB798.js → projectContext-Bw3o5BrN.js} +1 -1
  187. package/dist/chunks/prompt-C3RRe4kW.js +1 -0
  188. package/dist/chunks/{prompt-M2lu8_Oa.js → prompt-CRc2QEZ5.js} +5 -5
  189. package/dist/chunks/prompt-EtAanewG.js +1 -0
  190. package/dist/chunks/{promptEditor-DhcZY-iu.js → promptEditor-Bo1d8ZLq.js} +2 -2
  191. package/dist/chunks/{protocolHandler-CkFaJKKo.js → protocolHandler-B83fCYI4.js} +4 -4
  192. package/dist/chunks/{proxy-CuMaO_YV.js → proxy-BEKNaTXI.js} +3 -3
  193. package/dist/chunks/rcDebugLog-DSchf3Hs.js +1 -0
  194. package/dist/chunks/reconciler-BGav_ezX.js +1 -0
  195. package/dist/chunks/refresh-DumNiLvM.js +1 -0
  196. package/dist/chunks/{registerProtocol-CsNYRZKr.js → registerProtocol-DduKPsn_.js} +2 -2
  197. package/dist/chunks/{reload-plugins-B7JAE3b4.js → reload-plugins-DNEgQ5vo.js} +1 -1
  198. package/dist/chunks/{remoteBridgeCore-CFLJhsB6.js → remoteBridgeCore-BGOqHADF.js} +1 -1
  199. package/dist/chunks/remoteManagedSettings-26nhzuca.js +1 -0
  200. package/dist/chunks/{rename-BCp2Vtqu.js → rename-BPknfVGF.js} +1 -1
  201. package/dist/chunks/{renderOptions-Q5oCLFIC.js → renderOptions-45A-EdsK.js} +1 -1
  202. package/dist/chunks/resume-DGz04xDh.js +2 -0
  203. package/dist/chunks/ripgrep-BLQnqPnE.js +1 -0
  204. package/dist/chunks/{ripgrep-DvOOsDMv.js → ripgrep-DQ_ILUJV.js} +5 -5
  205. package/dist/chunks/{runtimeObserver-CS_3BDNo.js → runtimeObserver-BZrF3GnQ.js} +4 -4
  206. package/dist/chunks/{runtimeObserver-DYUva6g-.js → runtimeObserver-CBV-7-w7.js} +1 -1
  207. package/dist/chunks/sandbox-adapter-DUqeqkQD.js +1 -0
  208. package/dist/chunks/sandbox-toggle-D61gVqcT.js +1 -0
  209. package/dist/chunks/searchExtraTools-CgsV6kb1.js +1 -0
  210. package/dist/chunks/{session-CO3gEqQP.js → session-Dy-_R7KP.js} +2 -2
  211. package/dist/chunks/sessionFileAccessHooks-BJlrZaRD.js +1 -0
  212. package/dist/chunks/sessionObserver-BGYoLRGx.js +1 -0
  213. package/dist/chunks/{sessionObserver-YkRHC-Aa.js → sessionObserver-CyLpHSkw.js} +1 -1
  214. package/dist/chunks/{sessionState-Bifmu95-.js → sessionState-DSWN4tMV.js} +2 -2
  215. package/dist/chunks/sessionStorage-zJ1esSCE.js +1 -0
  216. package/dist/chunks/{sessionStoragePortable-JZnGwqUM.js → sessionStoragePortable-BhkGMZWp.js} +1 -1
  217. package/dist/chunks/{sessionTitle-COBSgSXS.js → sessionTitle-L5tyJgdU.js} +2 -2
  218. package/dist/chunks/{sessionTracing-BrNx1k2V.js → sessionTracing-DpHGGIZm.js} +3 -3
  219. package/dist/chunks/settings-3ionQKNv.js +1 -0
  220. package/dist/chunks/settings-DiBMs2gM.js +20 -0
  221. package/dist/chunks/settingsSync-dBqlrbcU.js +1 -0
  222. package/dist/chunks/setup-zf3v3ICe.js +3 -0
  223. package/dist/chunks/{shadowedRuleDetection-DEaw-X5j.js → shadowedRuleDetection-DZ0AA2Rw.js} +1 -1
  224. package/dist/chunks/{shellQuote-BYeOv3Ip.js → shellQuote-C_I6DHLV.js} +2 -2
  225. package/dist/chunks/{sideQuestion-D0OKljee.js → sideQuestion-BYT8FdPF.js} +2 -2
  226. package/dist/chunks/sinks-DppGvgz1.js +1 -0
  227. package/dist/chunks/sinks-mFsijQ_S.js +2 -0
  228. package/dist/chunks/skillChangeDetector-D-iq09Xs.js +1 -0
  229. package/dist/chunks/{skillGapStore-N_kmvXML.js → skillGapStore-DQXHqoP7.js} +2 -2
  230. package/dist/chunks/{skillLifecycle-C4F5RXuh.js → skillLifecycle-BG_RnGSh.js} +2 -2
  231. package/dist/chunks/skillSearchPanel-DxYP4Q6R.js +21 -0
  232. package/dist/chunks/skills-BD-2ofXA.js +1 -0
  233. package/dist/chunks/startupProfiler-CUlV07MD.js +1 -0
  234. package/dist/chunks/{startupProfiler-L_UWZ03w.js → startupProfiler-Dc5r6LgE.js} +2 -2
  235. package/dist/chunks/{state-BemZdQIl.js → state-BPFYBqm1.js} +1 -1
  236. package/dist/chunks/state-CsdHk8n-.js +1 -0
  237. package/dist/chunks/{stats-IzV0_vEc.js → stats-BkadEKa-.js} +1 -1
  238. package/dist/chunks/status-BmHu-c7I.js +2 -0
  239. package/dist/chunks/{status-CeVP_uDT.js → status-CrmnCDIE.js} +1 -1
  240. package/dist/chunks/{statusNoticeHelpers-Bb9gxdSt.js → statusNoticeHelpers-DakAVtQO.js} +1 -1
  241. package/dist/chunks/{stringUtils-C84IJ91d.js → stringUtils-Df-Lnjxd.js} +1 -1
  242. package/dist/chunks/{subprocessEnv-Ci8VV_bi.js → subprocessEnv-CNBOhlDV.js} +1 -1
  243. package/dist/chunks/subprocessEnv-DtBCqQIo.js +1 -0
  244. package/dist/chunks/switcher-Dm646gO5.js +1 -0
  245. package/dist/chunks/switcher-sYTxnJQA.js +1 -0
  246. package/dist/chunks/syncCache-BofuFJEe.js +1 -0
  247. package/dist/chunks/{tasks-DZDhgx0w.js → tasks-NpI1iEem.js} +1 -1
  248. package/dist/chunks/teleport-Bs3kEipi.js +1 -0
  249. package/dist/chunks/{templateJobs-CrNPEKkh.js → templateJobs-C94jEE6O.js} +2 -2
  250. package/dist/chunks/{terminalSetup-CBqcwQll.js → terminalSetup-CbXKCpWM.js} +1 -1
  251. package/dist/chunks/{terminalSetup-D-N8YPiQ.js → terminalSetup-fwhFTxGi.js} +4 -4
  252. package/dist/chunks/{theme-Dazsirbw.js → theme-CEi3b_8f.js} +1 -1
  253. package/dist/chunks/tmux-d3cNCIZA.js +1 -0
  254. package/dist/chunks/{toolEventObserver-lnHJ9fLQ.js → toolEventObserver-DlL9CHmI.js} +1 -1
  255. package/dist/chunks/toolPool-DIT_uhtD.js +1 -0
  256. package/dist/chunks/trustedDevice-BokywSKL.js +1 -0
  257. package/dist/chunks/trustedDevice-Bzz03jCy.js +1 -0
  258. package/dist/chunks/{types-3j8PS-Du.js → types-BJ7qTz75.js} +2 -2
  259. package/dist/chunks/udsClient-CF8BmZgN.js +1 -0
  260. package/dist/chunks/{updateCCB-BPe9_FW6.js → updateCCB-CzBxsuJe.js} +1 -1
  261. package/dist/chunks/{upstreamproxy-DF00RzGG.js → upstreamproxy-BuBFDFAD.js} +2 -2
  262. package/dist/chunks/{useExitOnCtrlCDWithKeybindings-ChqBs9Lr.js → useExitOnCtrlCDWithKeybindings-BHQfwlAl.js} +1 -1
  263. package/dist/chunks/useMainLoopModel-BkyIIW9t.js +1 -0
  264. package/dist/chunks/useManagePlugins-BWROoGDs.js +1 -0
  265. package/dist/chunks/{useMergedTools-Dk5cPqLc.js → useMergedTools-CHxnwR7R.js} +1 -1
  266. package/dist/chunks/{useSearchInput-C7Y1I9P9.js → useSearchInput-q2CFPU4W.js} +1 -1
  267. package/dist/chunks/{useSettingsErrors-DAEO7AyB.js → useSettingsErrors-CPVQbsqq.js} +1 -1
  268. package/dist/chunks/{userAgent-CIq27vUR.js → userAgent-B7WkjI6I.js} +1 -1
  269. package/dist/chunks/util-BfqXOA-P.js +1 -0
  270. package/dist/chunks/{validatePlugin-Kk6pxnO2.js → validatePlugin-jrcrYEIu.js} +1 -1
  271. package/dist/chunks/{vim-EYQn94Kx.js → vim-C4Hs5U2h.js} +1 -1
  272. package/dist/chunks/{which-DzFN5TNM.js → which-mplwBbc0.js} +1 -1
  273. package/dist/chunks/windowsPaths-B8p9tFRF.js +1 -0
  274. package/dist/chunks/windowsPaths-C7Mdo9aU.js +1 -0
  275. package/dist/chunks/{workSecret-DUqdPy44.js → workSecret-XLodD7tw.js} +1 -1
  276. package/dist/chunks/workerRegistry-Cfo7bKlm.js +6 -0
  277. package/dist/chunks/worktree-D0k_pCEz.js +1 -0
  278. package/dist/cli.js +1 -1
  279. package/package.json +2 -3
  280. package/dist/chunks/App-C2yQjBgY.js +0 -1
  281. package/dist/chunks/ApproveApiKey-CKbv5C1x.js +0 -1
  282. package/dist/chunks/ApproveApiKey-MscC-ssL.js +0 -1
  283. package/dist/chunks/BackgroundTasksDialog-CL5NWsFL.js +0 -2
  284. package/dist/chunks/ClaudeMdExternalIncludesDialog-BqNxQOXJ.js +0 -1
  285. package/dist/chunks/ClaudeMdExternalIncludesDialog-C0-psohX.js +0 -1
  286. package/dist/chunks/ConsoleOAuthFlow-4mOvEer_.js +0 -1
  287. package/dist/chunks/Doctor-DmgAwce2.js +0 -1
  288. package/dist/chunks/Doctor-jEs9chPk.js +0 -3
  289. package/dist/chunks/ExitFlow-DVKxFdpX.js +0 -2
  290. package/dist/chunks/InvalidConfigDialog-o9DF1REI.js +0 -1
  291. package/dist/chunks/MCPConnectionManager-CUTuaa8T.js +0 -1
  292. package/dist/chunks/MCPToolListView-CvqB4nCw.js +0 -1
  293. package/dist/chunks/MessageSelector-BLzw172f.js +0 -3
  294. package/dist/chunks/Messages-4K5sLmNh.js +0 -11
  295. package/dist/chunks/Onboarding-ClwHS5rh.js +0 -1
  296. package/dist/chunks/PromptInputHelpMenu-Bb4KdIX_.js +0 -1
  297. package/dist/chunks/QueryEngine-DPHLSsax.js +0 -1
  298. package/dist/chunks/REPL-Bf46iQCN.js +0 -1
  299. package/dist/chunks/REPL-DIaAo9M9.js +0 -133
  300. package/dist/chunks/RemoteSessionManager-CS6mywIn.js +0 -2
  301. package/dist/chunks/ResumeConversation-Br2KsBoe.js +0 -1
  302. package/dist/chunks/SearchExtraToolsTool-i_YO3QvV.js +0 -1
  303. package/dist/chunks/Settings-BMXysXIx.js +0 -2
  304. package/dist/chunks/TrustDialog-Fk4m_Sy4.js +0 -1
  305. package/dist/chunks/add-dir-CZ6Clvq8.js +0 -1
  306. package/dist/chunks/agents-DHnNg4h6.js +0 -103
  307. package/dist/chunks/allErrors-CU89tF-z.js +0 -1
  308. package/dist/chunks/api-BSeE6MwB.js +0 -1
  309. package/dist/chunks/auth-BIGJth5U.js +0 -1
  310. package/dist/chunks/auth-CDQMhIZP.js +0 -1
  311. package/dist/chunks/autonomy-C1aSgWPQ.js +0 -1
  312. package/dist/chunks/autonomy-Src6sKCp.js +0 -15
  313. package/dist/chunks/autonomyPanel-DnHpuiy4.js +0 -1
  314. package/dist/chunks/backgroundHousekeeping-B-cw0UcS.js +0 -17
  315. package/dist/chunks/backgroundHousekeeping-BS_8z3_x.js +0 -1
  316. package/dist/chunks/bg-50rllUNh.js +0 -1
  317. package/dist/chunks/bg-DAPORXF3.js +0 -9
  318. package/dist/chunks/bridgeConfig-BeqChxJC.js +0 -1
  319. package/dist/chunks/caches-BTQAW9zc.js +0 -1
  320. package/dist/chunks/caches-BVtSCnV1.js +0 -1
  321. package/dist/chunks/ccrClient-Bu7Tf1Z5.js +0 -1
  322. package/dist/chunks/cliLaunch-BWcoyZDP.js +0 -1
  323. package/dist/chunks/client-BWQ4-rN7.js +0 -1
  324. package/dist/chunks/client-c-3-PW1F.js +0 -1
  325. package/dist/chunks/commands-Bi7k3Wg-.js +0 -1
  326. package/dist/chunks/compact-J-h0Yf4b.js +0 -2
  327. package/dist/chunks/config-Do1870_d.js +0 -3
  328. package/dist/chunks/config-yyFe87vW.js +0 -1
  329. package/dist/chunks/context-Tb1Ca2Q-.js +0 -1
  330. package/dist/chunks/context-noninteractive-soPYKAc9.js +0 -1
  331. package/dist/chunks/conversation-CSEtUxOY.js +0 -1
  332. package/dist/chunks/conversation-Dk1WDQuN.js +0 -1
  333. package/dist/chunks/createSSHSession-CJtzNQdZ.js +0 -6
  334. package/dist/chunks/createSession-DkT1GL8y.js +0 -1
  335. package/dist/chunks/createSession-eE8mswkv.js +0 -1
  336. package/dist/chunks/crossProjectResume-04n3Ppy9.js +0 -40
  337. package/dist/chunks/cwd-ClLru_7T.js +0 -1
  338. package/dist/chunks/datadog-DjeJThpV.js +0 -1
  339. package/dist/chunks/debug-RAynG_nM.js +0 -39
  340. package/dist/chunks/detached-X_yjYR7x.js +0 -5
  341. package/dist/chunks/detectRepository-DgpNd87p.js +0 -1
  342. package/dist/chunks/detectRepository-ctF9KDbb.js +0 -1
  343. package/dist/chunks/doctor-B-Wag4C1.js +0 -1
  344. package/dist/chunks/entry-oIqjxIjQ.js +0 -14
  345. package/dist/chunks/execSyncWrapper-BTZJjCuv.js +0 -1
  346. package/dist/chunks/exit-BtW7LfRX.js +0 -1
  347. package/dist/chunks/extractMemories-CUrdiNcr.js +0 -1
  348. package/dist/chunks/fast-C60p6AqJ.js +0 -1
  349. package/dist/chunks/firstPartyEventLogger-BfCYN7lt.js +0 -1
  350. package/dist/chunks/gemini-BwvSxGgn.js +0 -1
  351. package/dist/chunks/generateSessionName-DlrdedOk.js +0 -1
  352. package/dist/chunks/git-2c7WlGDL.js +0 -6
  353. package/dist/chunks/git-XtKbtJMc.js +0 -1
  354. package/dist/chunks/githubRepoPathMapping-DbWG4hFQ.js +0 -1
  355. package/dist/chunks/goal-ZmSRBx4q.js +0 -3
  356. package/dist/chunks/hooks-DWg07LmS.js +0 -1
  357. package/dist/chunks/jwtUtils-CUPXdX3W.js +0 -1
  358. package/dist/chunks/keybindings-DgIPdBy9.js +0 -2
  359. package/dist/chunks/loadAgentsDir-zikjxLvn.js +0 -1
  360. package/dist/chunks/loadPluginHooks-Cp8MSwAc.js +0 -1
  361. package/dist/chunks/localSearch-ZFyFy5FN.js +0 -1
  362. package/dist/chunks/main-9r5gLzUW.js +0 -605
  363. package/dist/chunks/main-CvOv59-7.js +0 -31
  364. package/dist/chunks/managedEnv-B61yLpwp.js +0 -1
  365. package/dist/chunks/mcp-BckPBjaM.js +0 -6
  366. package/dist/chunks/mcp-CS1DA3JL.js +0 -1
  367. package/dist/chunks/mcp-VcGPYCkW.js +0 -2
  368. package/dist/chunks/memory-C5ohwh-T.js +0 -1
  369. package/dist/chunks/model-BGu1AGq0.js +0 -1
  370. package/dist/chunks/model-BsZ4sP_H.js +0 -1
  371. package/dist/chunks/model-D19IIcll.js +0 -1
  372. package/dist/chunks/nativeInstaller-QB8cEJ18.js +0 -1
  373. package/dist/chunks/oauth-BN2I0_jl.js +0 -1
  374. package/dist/chunks/oauth-C9VBDB0Y.js +0 -1
  375. package/dist/chunks/omit-DDUIPHnl.js +0 -1
  376. package/dist/chunks/onChangeAppState-RBl6H7ho.js +0 -1
  377. package/dist/chunks/panel-KW-wmEvU.js +0 -1
  378. package/dist/chunks/parser-xSBaQRLH.js +0 -1
  379. package/dist/chunks/permissions-BoLXYN1j.js +0 -3
  380. package/dist/chunks/pidLock-nJHbufJN.js +0 -3
  381. package/dist/chunks/plugin-C6-GQke5.js +0 -17
  382. package/dist/chunks/pluginAutoupdate-SlRFJlTT.js +0 -1
  383. package/dist/chunks/pluginBlocklist-n6Imlh3y.js +0 -1
  384. package/dist/chunks/pluginCliCommands-Bd96zSOQ.js +0 -1
  385. package/dist/chunks/pluginFlagging-DZaYzecY.js +0 -1
  386. package/dist/chunks/pluginOperations-D90IRawu.js +0 -2
  387. package/dist/chunks/pluginStartupCheck-Bxkxpm4k.js +0 -1
  388. package/dist/chunks/pluginStartupCheck-CB2q2dLv.js +0 -1
  389. package/dist/chunks/plugins-B9eSjLSA.js +0 -4
  390. package/dist/chunks/poorMode-BAnubpn1.js +0 -1
  391. package/dist/chunks/print-eCRv_Li-.js +0 -26
  392. package/dist/chunks/processBashCommand-B5F2Cl7K.js +0 -1
  393. package/dist/chunks/processSlashCommand-BC_D3cH5.js +0 -5
  394. package/dist/chunks/prompt-C1JPqinc.js +0 -1
  395. package/dist/chunks/prompt-DZhBz_Vu.js +0 -1
  396. package/dist/chunks/rcDebugLog-CARUIORE.js +0 -1
  397. package/dist/chunks/reconciler-B4GDm_iC.js +0 -1
  398. package/dist/chunks/refresh-DBVizOzg.js +0 -1
  399. package/dist/chunks/remoteManagedSettings-xh_MViZH.js +0 -1
  400. package/dist/chunks/resume-DVCSzKvv.js +0 -2
  401. package/dist/chunks/ripgrep-e-iewvTf.js +0 -1
  402. package/dist/chunks/sandbox-adapter-BFZFHplu.js +0 -1
  403. package/dist/chunks/sandbox-toggle--zNSKce_.js +0 -1
  404. package/dist/chunks/searchExtraTools-ui5y2VSE.js +0 -1
  405. package/dist/chunks/sessionFileAccessHooks-CZvCqQJ6.js +0 -1
  406. package/dist/chunks/sessionObserver-Ba7um95p.js +0 -1
  407. package/dist/chunks/sessionStorage-CedwLLQs.js +0 -1
  408. package/dist/chunks/settings-DkDH7WQT.js +0 -1
  409. package/dist/chunks/settings-DnptdP79.js +0 -20
  410. package/dist/chunks/settingsSync-PmU7SmkU.js +0 -1
  411. package/dist/chunks/setup-BEsBuzsk.js +0 -3
  412. package/dist/chunks/sinks-BJHgxz6Y.js +0 -1
  413. package/dist/chunks/sinks-D5-yhcgU.js +0 -2
  414. package/dist/chunks/skillChangeDetector-Dd0WPdkO.js +0 -1
  415. package/dist/chunks/skillSearchPanel-CftorvAM.js +0 -21
  416. package/dist/chunks/skills-C4CTRN9o.js +0 -1
  417. package/dist/chunks/startupProfiler-D4FBdEQr.js +0 -1
  418. package/dist/chunks/state-BAGmpVBn.js +0 -1
  419. package/dist/chunks/state-D_lk6z-C.js +0 -1
  420. package/dist/chunks/status-Dzuw3hBv.js +0 -2
  421. package/dist/chunks/subprocessEnv-CZkA9Cdp.js +0 -1
  422. package/dist/chunks/switcher-4KzBvuKH.js +0 -1
  423. package/dist/chunks/switcher-CCs9xl1z.js +0 -1
  424. package/dist/chunks/syncCache-CBRiRU5x.js +0 -1
  425. package/dist/chunks/teleport-Bw0jSxe9.js +0 -1
  426. package/dist/chunks/tmux-DewYVEBm.js +0 -1
  427. package/dist/chunks/toolPool-CkXFlqsn.js +0 -1
  428. package/dist/chunks/trustedDevice-CFf5yaG-.js +0 -1
  429. package/dist/chunks/trustedDevice-CuwSv8dG.js +0 -1
  430. package/dist/chunks/udsClient-e9dIkwVA.js +0 -1
  431. package/dist/chunks/useMainLoopModel-2-eujv0n.js +0 -1
  432. package/dist/chunks/useManagePlugins-CYBIkaB1.js +0 -1
  433. package/dist/chunks/util-VO98TdOz.js +0 -1
  434. package/dist/chunks/windowsPaths-BU3yQWTB.js +0 -1
  435. package/dist/chunks/windowsPaths-DgZ3YY4a.js +0 -1
  436. package/dist/chunks/workerRegistry-C07BcZIw.js +0 -6
  437. package/dist/chunks/worktree-dFUkhVE_.js +0 -1
@@ -0,0 +1,4 @@
1
+ import{n as e,t}from"./figures-5ThXQEtq.js";import{Ao as n,Bo as r,Go as i,Ho as a,Jw as o,No as s,Oo as c,Uo as l,Xw as u,Zo as d,Zw as f,as as p,cS as m,cs as h,do as g,fo as _,iT as v,lS as y,qo as b,rT as x,rs as S,ss as C,wo as w,zo as ee}from"./loadAgentsDir-BXtV2jiO.js";import{Wt as T,ir as E}from"./state-BPFYBqm1.js";import{C as D,P as O,R as te,x as k}from"./debug-Dr1SjdXn.js";import{o as A,s as j}from"./log-27kCA_9u.js";import{n as ne,r as M}from"./analytics-DJobLaWP.js";import{l as N,o as P}from"./stringUtils-Df-Lnjxd.js";import{n as F,t as I}from"./exit-BOhGfSlm.js";import{n as L,s as R,t as z}from"./pluginOperations-BFbty6WT.js";import{a as B,i as V,n as H,o as U,r as W,t as G}from"./pluginCliCommands-WLOEhb2M.js";import{a as K,c as re,i as q,n as J,r as Y,s as X,t as ie}from"./validatePlugin-jrcrYEIu.js";import{basename as ae,dirname as Z}from"path";e(),T(),ne(),R(),v(),te(),A(),h(),re(),w(),S(),ee(),m(),q(),o(),g(),ie(),k(),P();function Q(e,n){j(e),I(`${t.cross} Failed to ${n}: ${O(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&&E(!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){j(e),console.error(`${t.cross} Unexpected error during validation: ${O(e)}`),process.exit(2)}}async function se(e){e.cowork&&E(!0),M(`tengu_plugin_list_command`,{});let i=n(),{getPluginEditableScopes:a}=await import(`./pluginStartupCheck-Bcdxg484.js`),o=a(),s=Object.keys(i.plugins),{enabled:l,disabled:f,errors:m}=await _(),h=[...l,...f],g=h.filter(e=>e.source.endsWith(`@inline`)),v=m.filter(e=>e.source.endsWith(`@inline`)||e.source.startsWith(`inline[`));if(e.json){let t=new Map(h.map(e=>[e.source,e])),n=[];for(let e of s.sort()){let r=i.plugins[e];if(!r||r.length===0)continue;let a=u(e).name,s=m.filter(t=>t.source===e||`plugin`in t&&t.plugin===a).map(x);for(let i of r){let r=t.get(e),a;if(r){let e=r.mcpServers||await y(r);e&&Object.keys(e).length>0&&(a=e)}n.push({id:e,version:i.version||`unknown`,scope:i.scope,enabled:o.has(e),installPath:i.installPath,installedAt:i.installedAt,lastUpdated:i.lastUpdated,projectPath:i.projectPath,mcpServers:a,errors:s.length>0?s:void 0})}}for(let e of g){let t=e.mcpServers||await y(e),r=v.filter(t=>t.source===e.source||`plugin`in t&&t.plugin===e.name).map(x);n.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:r.length>0?r:void 0})}for(let e of v.filter(e=>e.source.startsWith(`inline[`)))n.push({id:e.source,version:`unknown`,scope:`session`,enabled:!1,installPath:`path`in e?e.path:``,errors:[x(e)]});if(e.available){let e=[];try{let[t,n]=await Promise.all([r(),X()]),{marketplaces:i}=await p(t);for(let{name:t,data:r}of i)if(r)for(let i of r.plugins){let r=d(i.name,t);c(r)||e.push({pluginId:r,name:i.name,description:i.description,marketplaceName:t,version:i.version,source:i.source,installCount:n?.get(r)})}}catch{}F(D({installed:n,available:e},null,2))}else F(D(n,null,2))}s.length===0&&g.length===0&&v.length===0&&F("No plugins installed. Use `claude plugin install` to install a plugin."),s.length>0&&console.log(`Installed plugins:
2
+ `);for(let e of s.sort()){let n=i.plugins[e];if(!n||n.length===0)continue;let r=u(e).name,a=m.filter(t=>t.source===e||`plugin`in t&&t.plugin===r);for(let r of n){let n=o.has(e),i=a.length>0?`${t.cross} failed to load`:n?`${t.tick} enabled`:`${t.cross} disabled`,s=r.version||`unknown`,c=r.scope;console.log(` ${t.pointer} ${e}`),console.log(` Version: ${s}`),console.log(` Scope: ${c}`),console.log(` Status: ${i}`);for(let e of a)console.log(` Error: ${x(e)}`);console.log(``)}}if(g.length>0||v.length>0){console.log(`Session-only plugins (--plugin-dir):
3
+ `);for(let e of g){let n=v.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: ${x(e)}`);console.log(``)}for(let e of v.filter(e=>e.source.startsWith(`inline[`)))console.log(` ${t.pointer} ${e.source}: ${t.cross} ${x(e)}\n`)}F()}async function ce(e,n){n.cowork&&E(!0);try{let r=await K(e);r||I(`${t.cross} Invalid marketplace source format. Try: owner/repo, https://..., or ./path`),`error`in r&&I(`${t.cross} ${r.error}`);let i=n.scope??`user`;i!==`user`&&i!==`project`&&i!==`local`&&I(`${t.cross} Invalid scope '${i}'. Use: user, project, or local`);let a=f(i),o=r;n.sparse&&n.sparse.length>0&&(o.source===`github`||o.source===`git`?o={...o,sparsePaths:n.sparse}:I(`${t.cross} --sparse is only supported for github and git marketplace sources (got: ${o.source})`)),console.log(`Adding marketplace...`);let{name:c,alreadyMaterialized:l,resolvedSource:u}=await s(o,e=>{console.log(e)});b(c,{source:u},a),C();let d=o.source;o.source===`github`&&(d=o.repo),M(`tengu_marketplace_added`,{source_type:d}),F(l?`${t.tick} Marketplace '${c}' already on disk — declared in ${i} settings`:`${t.tick} Successfully added marketplace: ${c} (declared in ${i} settings)`)}catch(e){Q(e,`add marketplace`)}}async function le(e){e.cowork&&E(!0);try{let n=await r(),i=Object.keys(n);e.json&&F(D(i.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)),i.length===0&&F(`No marketplaces configured`),console.log(`Configured marketplaces:
4
+ `),i.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&&E(!0);try{await i(e),C(),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&&E(!0);try{if(e)console.log(`Updating marketplace: ${e}...`),await l(e,e=>{console.log(e)}),C(),M(`tengu_marketplace_updated`,{marketplace_name:e}),F(`${t.tick} Successfully updated marketplace: ${e}`);else{let e=await r(),n=Object.keys(e);n.length===0&&F(`No marketplaces configured`),console.log(`Updating ${n.length} marketplace(s)...`),await a(),C(),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&&E(!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}=u(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&&E(!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}=u(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&&E(!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}=u(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&&E(!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}=u(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&&E(!0);let{name:n,marketplace:r}=u(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-DxgO_bUb.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-DnptdP79.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-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};
@@ -0,0 +1,26 @@
1
+ import{a as e}from"./rolldown-runtime-DaDcL9Zw.js";import{c as t,i as n,l as r,o as i,s as a}from"./envUtils-DcaKZlRU.js";import{n as o,t as s}from"./defineProperty-C-QyHrDq.js";import{n as c,t as l}from"./axios-DaWTGg7G.js";import{$b as u,$d as d,$g as f,$l as p,Ag as m,Ai as h,Ba as g,Bb as _,Bf as ee,Bi as v,C as te,CT as ne,Cg as re,Cm as y,Cn as b,Cr as x,Cu as ie,D as ae,DS as S,DT as oe,D_ as se,Dm as ce,Dn as le,E as ue,ES as de,E_ as fe,Em as pe,En as C,Fi as me,Fo as he,Fs as ge,Fx as _e,Gc as ve,Gx as ye,Hc as w,Hi as be,Ht as xe,IT as Se,Is as T,Jb as Ce,Jc as we,Js as Te,Jv as Ee,KS as De,Kb as Oe,Kc as ke,Kg as Ae,Kr as je,Kx as Me,LT as E,Lb as Ne,Ls as Pe,MT as Fe,N as Ie,NT as Le,Nh as Re,Ni as ze,OT as Be,Om as Ve,Ph as He,Po as Ue,Ps as We,Qb as Ge,Qc as Ke,Qd as qe,Ql as Je,Qx as Ye,Rx as Xe,Sm as Ze,Sn as Qe,Sr as $e,T_ as D,Tg as O,Tm as et,Tn as tt,Tx as nt,U as rt,Ub as it,Uc as at,Vf as ot,Vo as st,W as ct,WS as lt,Wo as ut,Wt as dt,Xb as ft,Xc as pt,Xd as mt,Xg as ht,Xs as gt,Yb as _t,Yc as vt,Yv as yt,Zc as bt,Zd as k,Zg as xt,Zn as St,Zx as Ct,_m as wt,_s as Tt,_w as Et,_y as Dt,ac as Ot,ai as kt,ao as At,ay as jt,b as Mt,bT as Nt,bi as Pt,bm as Ft,bu as It,by as Lt,ci as Rt,dc as zt,dg as Bt,do as Vt,dp as Ht,ds as Ut,ex as Wt,f as Gt,fc as Kt,fs as qt,fx as Jt,fy as Yt,gs as Xt,hb as Zt,hs as Qt,ic as $t,ii as en,im as tn,io as nn,jm as rn,kg as an,lf as on,lx as sn,mb as cn,ms as ln,my as un,nS as dn,ny as fn,o as pn,oy as mn,pb as hn,po as gn,pp as _n,ps as vn,py as yn,qg as bn,qx as xn,r_ as Sn,rc as Cn,rm as wn,ry as Tn,s as En,sC as Dn,sc as On,sf as kn,si as An,so as jn,sy as Mn,t_ as Nn,tl as Pn,tr as Fn,tx as In,ug as Ln,us as Rn,ux as zn,vm as Bn,vn as Vn,vs as Hn,vw as Un,w_ as Wn,wg as Gn,wm as Kn,wn as qn,wu as Jn,x as Yn,xE as Xn,xm as Zn,xr as Qn,ya as $n,yi as er,ym as tr,ys as nr,zb as rr,zo as ir}from"./loadAgentsDir-BXtV2jiO.js";import{A,C as j,M,O as N,b as P,f as ar,g as or,j as F,l as I,m as L,p as R,u as sr,w as z,y as cr}from"./external-CEp-aPkt.js";import{i as B,n as V,r as lr,t as ur}from"./lazySchema-B4D4qJVE.js";import{$t as dr,Gt as fr,M as pr,Mn as mr,Nn as hr,P as gr,Wt as _r,Y as vr,hn as yr,or as br,pt as H,qn as xr,yn as Sr}from"./state-BPFYBqm1.js";import{n as Cr,t as wr}from"./cwd-Besi3Os3.js";import{C as U,E as Tr,P as W,R as Er,S as Dr,U as Or,a as kr,c as G,f as Ar,i as jr,nt as Mr,tt as Nr,u as Pr,x as Fr}from"./debug-Dr1SjdXn.js";import{Bn as Ir,G as Lr,Rn as Rr,cr as zr,d as Br,dt as Vr,f as Hr,g as Ur,it as Wr,nt as Gr,or as Kr,vt as qr}from"./settings-DiBMs2gM.js";import{F as Jr,M as Yr}from"./config-9rLTDOYW.js";import{i as Xr,n as Zr,o as K}from"./process-gEbdy6uY.js";import{A as Qr,O as $r,k as ei}from"./git-CoQQ6YEf.js";import{H as ti,c as ni,i as ri,o as ii,q as ai,s as q}from"./log-27kCA_9u.js";import{s as oi,u as si}from"./types-BJ7qTz75.js";import{n as ci,r as J}from"./analytics-DJobLaWP.js";import{Bt as li,C as ui,Gr as di,Mn as fi,Y as pi,_ as mi,_n as hi,_r as gi,ai as _i,bt as vi,et as yi,ii as bi,it as xi,jn as Si,o as Ci,qr as wi,ri as Ti,rt as Ei,si as Di,tt as Oi,u as ki,vn as Ai,vr as ji,x as Mi}from"./model-CDnVaVDR.js";import{at as Ni,bn as Pi,bt as Fi,ot as Ii,rn as Li,vt as Ri,xn as zi,yt as Bi}from"./prompt-CRc2QEZ5.js";import{A as Vi,D as Hi,M as Ui,_ as Wi,a as Gi,c as Ki,k as qi,l as Ji,n as Yi,o as Xi,s as Zi,st as Qi,t as $i,w as ea,x as ta}from"./sessionState-DSWN4tMV.js";import{n as na,t as ra}from"./omit-D4Udf-p-.js";import{a as ia,n as aa,t as oa}from"./bridgeConfig-BB6Hgali.js";import{i as sa,n as ca,s as la}from"./mappers-IuJeXgvr.js";import{n as ua,r as da}from"./sessionTitle-L5tyJgdU.js";import{t as fa}from"./pollConfig-BgpfHQPJ.js";import{t as pa}from"./controlMessageCompat-IFu4Gc1y.js";import{n as ma,t as ha}from"./ccrClient-BG9HU_fW.js";import{n as ga,t as _a}from"./HybridTransport-BadJQe6u.js";import{n as va,t as ya}from"./SSETransport-je346ofV.js";import{a as ba,n as xa}from"./grove-BnzBbGsX.js";import{o as Sa}from"./remoteManagedSettings-26nhzuca.js";import{i as Ca,r as wa}from"./auth-yDsvFcM7.js";import{t as Ta}from"./pluginBlocklist-CNGmIlwU.js";import{t as Ea}from"./onChangeAppState-WbvtqDtk.js";import{t as Da}from"./settingsSync-dBqlrbcU.js";import{n as Oa,t as ka}from"./toolPool-DIT_uhtD.js";import{n as Aa,r as ja}from"./QueryEngine-HkswHUNv.js";import{r as Ma}from"./bridgeStatusUtil-D8UbcVrZ.js";import{n as Na,r as Pa}from"./sideQuestion-BYT8FdPF.js";import{n as Fa,r as Ia}from"./context-noninteractive-mAQt1p9l.js";import{n as La,t as Ra}from"./modelOptions-ut0xePEe.js";import{a as za,o as Ba,t as Va}from"./skillChangeDetector-D-iq09Xs.js";import{n as Ha}from"./reconciler-BGav_ezX.js";import{n as Ua,t as Wa}from"./refresh-DumNiLvM.js";import{basename as Ga,dirname as Ka,join as qa}from"path";import{PassThrough as Ja}from"stream";import{randomUUID as Y}from"crypto";import{mkdir as Ya,readFile as Xa,stat as Za,writeFile as Qa}from"fs/promises";import{URL as $a}from"url";import{cwd as eo}from"process";i(),o(),l(),_r(),Nr(),Er(),Fr(),Ar(),Zr(),jr(),$r(),ai(),ii(),Rr(),oi(),Ur(),Di(),wi(),ji(),Si(),hi(),li(),mi(),Da(),lr(),ur();var to=V(()=>z({inputTokens:j(),outputTokens:j(),cacheReadInputTokens:j(),cacheCreationInputTokens:j(),webSearchRequests:j(),costUSD:j(),contextWindow:j(),maxOutputTokens:j()})),no=V(()=>P(`json_schema`));V(()=>z({type:no()}));var ro=V(()=>z({type:P(`json_schema`),schema:N(A(),M())}));V(()=>ro());var io=V(()=>I([`user`,`project`,`org`,`temporary`,`oauth`]));V(()=>I([`local`,`user`,`project`]).describe(`Config scope for settings.`)),V(()=>P(`context-1m-2025-08-07`));var ao=V(()=>z({type:P(`adaptive`)}).describe(`Claude decides when and how much to think (Opus 4.6+).`)),oo=V(()=>z({type:P(`enabled`),budgetTokens:j().optional()}).describe(`Fixed thinking token budget (older models)`)),so=V(()=>z({type:P(`disabled`)}).describe(`No extended thinking`));V(()=>F([ao(),oo(),so()]).describe(`Controls Claude's thinking/reasoning behavior. When set, takes precedence over the deprecated maxThinkingTokens.`));var co=V(()=>z({type:P(`stdio`).optional(),command:A(),args:R(A()).optional(),env:N(A(),A()).optional()})),lo=V(()=>z({type:P(`sse`),url:A(),headers:N(A(),A()).optional()})),uo=V(()=>z({type:P(`http`),url:A(),headers:N(A(),A()).optional()})),fo=V(()=>z({type:P(`sdk`),name:A()})),po=V(()=>F([co(),lo(),uo(),fo()])),mo=V(()=>z({type:P(`claudeai-proxy`),url:A(),id:A()})),ho=V(()=>F([po(),mo()])),go=V(()=>z({name:A().describe(`Server name as configured`),status:I([`connected`,`failed`,`needs-auth`,`pending`,`disabled`]).describe(`Current connection status`),serverInfo:z({name:A(),version:A()}).optional().describe(`Server information (available when connected)`),error:A().optional().describe(`Error message (available when status is 'failed')`),config:ho().optional().describe(`Server configuration (includes URL for HTTP/SSE servers)`),scope:A().optional().describe(`Configuration scope (e.g., project, user, local, claudeai, managed)`),tools:R(z({name:A(),description:A().optional(),annotations:z({readOnly:L().optional(),destructive:L().optional(),openWorld:L().optional()}).optional()})).optional().describe(`Tools provided by this server (available when connected)`),capabilities:z({experimental:N(A(),M()).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.`));V(()=>z({added:R(A()).describe(`Names of servers that were added`),removed:R(A()).describe(`Names of servers that were removed`),errors:N(A(),A()).describe(`Map of server names to error messages for servers that failed to connect`)}).describe(`Result of a setMcpServers operation.`));var _o=V(()=>I([`userSettings`,`projectSettings`,`localSettings`,`session`,`cliArg`])),vo=V(()=>I([`allow`,`deny`,`ask`])),yo=V(()=>z({toolName:A(),ruleContent:A().optional()})),bo=V(()=>or(`type`,[z({type:P(`addRules`),rules:R(yo()),behavior:vo(),destination:_o()}),z({type:P(`replaceRules`),rules:R(yo()),behavior:vo(),destination:_o()}),z({type:P(`removeRules`),rules:R(yo()),behavior:vo(),destination:_o()}),z({type:P(`setMode`),mode:cr(()=>So()),destination:_o()}),z({type:P(`addDirectories`),directories:R(A()),destination:_o()}),z({type:P(`removeDirectories`),directories:R(A()),destination:_o()})])),xo=V(()=>I([`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).`));V(()=>F([z({behavior:P(`allow`),updatedInput:N(A(),M()).optional(),updatedPermissions:R(bo()).optional(),toolUseID:A().optional(),decisionClassification:xo().optional()}),z({behavior:P(`deny`),message:A(),interrupt:L().optional(),toolUseID:A().optional(),decisionClassification:xo().optional()})]));var So=V(()=>I([`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).`)),Co=`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(`.`),wo=V(()=>I(Co)),X=V(()=>z({session_id:A(),transcript_path:A(),cwd:A(),permission_mode:A().optional(),agent_id:A().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:A().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).`)})),To=V(()=>X().and(z({hook_event_name:P(`PreToolUse`),tool_name:A(),tool_input:M(),tool_use_id:A()}))),Eo=V(()=>X().and(z({hook_event_name:P(`PermissionRequest`),tool_name:A(),tool_input:M(),permission_suggestions:R(bo()).optional()}))),Do=V(()=>X().and(z({hook_event_name:P(`PostToolUse`),tool_name:A(),tool_input:M(),tool_response:M(),tool_use_id:A()}))),Oo=V(()=>X().and(z({hook_event_name:P(`PostToolUseFailure`),tool_name:A(),tool_input:M(),tool_use_id:A(),error:A(),is_interrupt:L().optional()}))),ko=V(()=>X().and(z({hook_event_name:P(`PermissionDenied`),tool_name:A(),tool_input:M(),tool_use_id:A(),reason:A()}))),Ao=V(()=>X().and(z({hook_event_name:P(`Notification`),message:A(),title:A().optional(),notification_type:A()}))),jo=V(()=>X().and(z({hook_event_name:P(`UserPromptSubmit`),prompt:A()}))),Mo=V(()=>X().and(z({hook_event_name:P(`SessionStart`),source:I([`startup`,`resume`,`clear`,`compact`]),agent_type:A().optional(),model:A().optional()}))),No=V(()=>X().and(z({hook_event_name:P(`Setup`),trigger:I([`init`,`maintenance`])}))),Po=V(()=>X().and(z({hook_event_name:P(`Stop`),stop_hook_active:L(),last_assistant_message:A().optional().describe(`Text content of the last assistant message before stopping. Avoids the need to read and parse the transcript file.`)}))),Fo=V(()=>X().and(z({hook_event_name:P(`StopFailure`),error:Ms(),error_details:A().optional(),last_assistant_message:A().optional()}))),Io=V(()=>X().and(z({hook_event_name:P(`SubagentStart`),agent_id:A(),agent_type:A()}))),Lo=V(()=>X().and(z({hook_event_name:P(`SubagentStop`),stop_hook_active:L(),agent_id:A(),agent_transcript_path:A(),agent_type:A(),last_assistant_message:A().optional().describe(`Text content of the last assistant message before stopping. Avoids the need to read and parse the transcript file.`)}))),Ro=V(()=>X().and(z({hook_event_name:P(`PreCompact`),trigger:I([`manual`,`auto`]),custom_instructions:A().nullable()}))),zo=V(()=>X().and(z({hook_event_name:P(`PostCompact`),trigger:I([`manual`,`auto`]),compact_summary:A().describe(`The conversation summary produced by compaction`)}))),Bo=V(()=>X().and(z({hook_event_name:P(`TeammateIdle`),teammate_name:A(),team_name:A()}))),Vo=V(()=>X().and(z({hook_event_name:P(`TaskCreated`),task_id:A(),task_subject:A(),task_description:A().optional(),teammate_name:A().optional(),team_name:A().optional()}))),Ho=V(()=>X().and(z({hook_event_name:P(`TaskCompleted`),task_id:A(),task_subject:A(),task_description:A().optional(),teammate_name:A().optional(),team_name:A().optional()}))),Uo=V(()=>X().and(z({hook_event_name:P(`Elicitation`),mcp_server_name:A(),message:A(),mode:I([`form`,`url`]).optional(),url:A().optional(),elicitation_id:A().optional(),requested_schema:N(A(),M()).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.`)),Wo=V(()=>X().and(z({hook_event_name:P(`ElicitationResult`),mcp_server_name:A(),elicitation_id:A().optional(),mode:I([`form`,`url`]).optional(),action:I([`accept`,`decline`,`cancel`]),content:N(A(),M()).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.`)),Go=[`user_settings`,`project_settings`,`local_settings`,`policy_settings`,`skills`],Ko=V(()=>X().and(z({hook_event_name:P(`ConfigChange`),source:I(Go),file_path:A().optional()}))),qo=[`session_start`,`nested_traversal`,`path_glob_match`,`include`,`compact`],Jo=[`User`,`Project`,`Local`,`Managed`],Yo=V(()=>X().and(z({hook_event_name:P(`InstructionsLoaded`),file_path:A(),memory_type:I(Jo),load_reason:I(qo),globs:R(A()).optional(),trigger_file_path:A().optional(),parent_file_path:A().optional()}))),Xo=V(()=>X().and(z({hook_event_name:P(`WorktreeCreate`),name:A()}))),Zo=V(()=>X().and(z({hook_event_name:P(`WorktreeRemove`),worktree_path:A()}))),Qo=V(()=>X().and(z({hook_event_name:P(`CwdChanged`),old_cwd:A(),new_cwd:A()}))),$o=V(()=>X().and(z({hook_event_name:P(`FileChanged`),file_path:A(),event:I([`change`,`add`,`unlink`])}))),es=[`clear`,`resume`,`logout`,`prompt_input_exit`,`other`,`bypass_permissions_disabled`],ts=V(()=>I(es)),ns=V(()=>X().and(z({hook_event_name:P(`SessionEnd`),reason:ts()}))),rs=V(()=>F([To(),Do(),Oo(),ko(),Ao(),jo(),Mo(),ns(),Po(),Fo(),Io(),Lo(),Ro(),zo(),Eo(),No(),Bo(),Vo(),Ho(),Uo(),Wo(),Ko(),Yo(),Xo(),Zo(),Qo(),$o()])),is=V(()=>z({async:P(!0),asyncTimeout:j().optional()})),as=V(()=>z({hookEventName:P(`PreToolUse`),permissionDecision:vo().optional(),permissionDecisionReason:A().optional(),updatedInput:N(A(),M()).optional(),additionalContext:A().optional()})),os=V(()=>z({hookEventName:P(`UserPromptSubmit`),additionalContext:A().optional()})),ss=V(()=>z({hookEventName:P(`SessionStart`),additionalContext:A().optional(),initialUserMessage:A().optional(),watchPaths:R(A()).optional()})),cs=V(()=>z({hookEventName:P(`Setup`),additionalContext:A().optional()})),ls=V(()=>z({hookEventName:P(`SubagentStart`),additionalContext:A().optional()})),us=V(()=>z({hookEventName:P(`PostToolUse`),additionalContext:A().optional(),updatedMCPToolOutput:M().optional()})),ds=V(()=>z({hookEventName:P(`PostToolUseFailure`),additionalContext:A().optional()})),fs=V(()=>z({hookEventName:P(`PermissionDenied`),retry:L().optional()})),ps=V(()=>z({hookEventName:P(`Notification`),additionalContext:A().optional()})),ms=V(()=>z({hookEventName:P(`PermissionRequest`),decision:F([z({behavior:P(`allow`),updatedInput:N(A(),M()).optional(),updatedPermissions:R(bo()).optional()}),z({behavior:P(`deny`),message:A().optional(),interrupt:L().optional()})])})),hs=V(()=>z({hookEventName:P(`CwdChanged`),watchPaths:R(A()).optional()})),gs=V(()=>z({hookEventName:P(`FileChanged`),watchPaths:R(A()).optional()})),_s=V(()=>z({continue:L().optional(),suppressOutput:L().optional(),stopReason:A().optional(),decision:I([`approve`,`block`]).optional(),systemMessage:A().optional(),reason:A().optional(),hookSpecificOutput:F([as(),os(),ss(),cs(),ls(),us(),ds(),fs(),ps(),ms(),vs(),ys(),hs(),gs(),bs()]).optional()})),vs=V(()=>z({hookEventName:P(`Elicitation`),action:I([`accept`,`decline`,`cancel`]).optional(),content:N(A(),M()).optional()}).describe(`Hook-specific output for the Elicitation event. Return this to programmatically accept or decline an MCP elicitation request.`)),ys=V(()=>z({hookEventName:P(`ElicitationResult`),action:I([`accept`,`decline`,`cancel`]).optional(),content:N(A(),M()).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.`)),bs=V(()=>z({hookEventName:P(`WorktreeCreate`),worktreePath:A()}).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.`));V(()=>F([is(),_s()]));var xs=V(()=>z({key:A().describe(`Unique key for this option, returned in the response`),label:A().describe(`Display text for this option`),description:A().optional().describe(`Optional description shown below the label`)}));V(()=>z({prompt:A().describe(`Request ID. Presence of this key marks the line as a prompt request.`),message:A().describe(`The prompt message to display to the user`),options:R(xs()).describe(`Available options for the user to choose from`)})),V(()=>z({prompt_response:A().describe(`The request ID from the corresponding prompt request`),selected:A().describe(`The key of the selected option`)}));var Ss=V(()=>z({name:A().describe(`Skill name (without the leading slash)`),description:A().describe(`Description of what the skill does`),argumentHint:A().describe(`Hint for skill arguments (e.g., "<file>")`)}).describe(`Information about an available skill (invoked via /command syntax).`)),Cs=V(()=>z({name:A().describe(`Agent type identifier (e.g., "Explore")`),description:A().describe(`Description of when to use this agent`),model:A().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.`)),ws=V(()=>z({value:A().describe(`Model identifier to use in API calls`),displayName:A().describe(`Human-readable display name`),description:A().describe(`Description of the model's capabilities`),supportsAdaptiveThinking:L().optional().describe(`Whether this model supports adaptive thinking (Claude decides when and how much to think)`),supportsFastMode:L().optional().describe(`Whether this model supports fast mode`),supportsAutoMode:L().optional().describe(`Whether this model supports auto mode`)}).describe(`Information about an available model.`)),Ts=V(()=>z({email:A().optional(),organization:A().optional(),subscriptionType:A().optional(),tokenSource:A().optional(),apiKeySource:A().optional(),apiProvider:I([`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.`)),Es=V(()=>F([A(),N(A(),po())])),Ds=V(()=>z({description:A().describe(`Natural language description of when to use this agent`),tools:R(A()).optional().describe(`Array of allowed tool names. If omitted, inherits all tools from parent`),disallowedTools:R(A()).optional().describe(`Array of tool names to explicitly disallow for this agent`),prompt:A().describe(`The agent's system prompt`),model:A().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:R(Es()).optional(),criticalSystemReminder_EXPERIMENTAL:A().optional().describe(`Experimental: Critical reminder added to system prompt`),skills:R(A()).optional().describe(`Array of skill names to preload into the agent context`),initialPrompt:A().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:j().int().positive().optional().describe(`Maximum number of agentic turns (API round-trips) before stopping`),background:L().optional().describe(`Run this agent as a background task (non-blocking, fire-and-forget) when invoked`),memory:I([`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:So().optional().describe(`Permission mode controlling how tool executions are handled`)}).describe(`Definition for a custom subagent that can be invoked via the Agent tool.`));V(()=>I([`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).`)),V(()=>z({type:P(`local`).describe(`Plugin type. Currently only 'local' is supported`),path:A().describe(`Absolute or relative path to the plugin directory`)}).describe(`Configuration for loading a plugin.`)),V(()=>z({canRewind:L(),error:A().optional(),filesChanged:R(A()).optional(),insertions:j().optional(),deletions:j().optional()}).describe(`Result of a rewindFiles operation.`));var Os=V(()=>M()),ks=V(()=>M()),As=V(()=>M()),Z=V(()=>A()),js=V(()=>M()),Ms=V(()=>I([`authentication_failed`,`billing_error`,`rate_limit`,`invalid_request`,`server_error`,`unknown`,`max_output_tokens`])),Ns=V(()=>F([P(`compacting`),sr()])),Ps=V(()=>z({type:P(`user`),message:Os(),parent_tool_use_id:A().nullable(),isSynthetic:L().optional(),tool_use_result:M().optional(),priority:I([`now`,`next`,`later`]).optional(),timestamp:A().optional().describe(`ISO timestamp when the message was created on the originating process. Older emitters omit it; consumers should fall back to receive time.`)})),Fs=V(()=>Ps().extend({uuid:Z().optional(),session_id:A().optional()})),Is=V(()=>Ps().extend({uuid:Z(),session_id:A(),isReplay:P(!0)})),Ls=V(()=>z({status:I([`allowed`,`allowed_warning`,`rejected`]),resetsAt:j().optional(),rateLimitType:I([`five_hour`,`seven_day`,`seven_day_opus`,`seven_day_sonnet`,`overage`]).optional(),utilization:j().optional(),overageStatus:I([`allowed`,`allowed_warning`,`rejected`]).optional(),overageResetsAt:j().optional(),overageDisabledReason:I([`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:L().optional(),surpassedThreshold:j().optional()}).describe(`Rate limit information for claude.ai subscription users.`)),Rs=V(()=>z({type:P(`assistant`),message:ks(),parent_tool_use_id:A().nullable(),error:Ms().optional(),uuid:Z(),session_id:A()})),zs=V(()=>z({type:P(`rate_limit_event`),rate_limit_info:Ls(),uuid:Z(),session_id:A()}).describe(`Rate limit event emitted when rate limit info changes.`)),Bs=V(()=>z({type:P(`streamlined_text`),text:A().describe(`Text content preserved from the assistant message`),session_id:A(),uuid:Z()}).describe(`@internal Streamlined text message - replaces SDKAssistantMessage in streamlined output. Text content preserved, thinking and tool_use blocks removed.`)),Vs=V(()=>z({type:P(`streamlined_tool_use_summary`),tool_summary:A().describe(`Summary of tool calls (e.g., "Read 2 files, wrote 1 file")`),session_id:A(),uuid:Z()}).describe(`@internal Streamlined tool use summary - replaces tool_use blocks in streamlined output with a cumulative summary string.`)),Hs=V(()=>z({tool_name:A(),tool_use_id:A(),tool_input:N(A(),M())})),Us=V(()=>z({type:P(`result`),subtype:P(`success`),duration_ms:j(),duration_api_ms:j(),is_error:L(),num_turns:j(),result:A(),stop_reason:A().nullable(),total_cost_usd:j(),usage:js(),modelUsage:N(A(),to()),permission_denials:R(Hs()),structured_output:M().optional(),fast_mode_state:pc().optional(),uuid:Z(),session_id:A()})),Ws=V(()=>z({type:P(`result`),subtype:I([`error_during_execution`,`error_max_turns`,`error_max_budget_usd`,`error_max_structured_output_retries`]),duration_ms:j(),duration_api_ms:j(),is_error:L(),num_turns:j(),stop_reason:A().nullable(),total_cost_usd:j(),usage:js(),modelUsage:N(A(),to()),permission_denials:R(Hs()),errors:R(A()),fast_mode_state:pc().optional(),uuid:Z(),session_id:A()})),Gs=V(()=>F([Us(),Ws()])),Ks=V(()=>z({type:P(`system`),subtype:P(`init`),agents:R(A()).optional(),apiKeySource:io(),betas:R(A()).optional(),claude_code_version:A(),cwd:A(),tools:R(A()),mcp_servers:R(z({name:A(),status:A()})),model:A(),permissionMode:So(),slash_commands:R(A()),output_style:A(),skills:R(A()),plugins:R(z({name:A(),path:A(),source:A().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:pc().optional(),uuid:Z(),session_id:A()})),qs=V(()=>z({type:P(`stream_event`),event:As(),parent_tool_use_id:A().nullable(),uuid:Z(),session_id:A()})),Js=V(()=>z({type:P(`system`),subtype:P(`compact_boundary`),compact_metadata:z({trigger:I([`manual`,`auto`]),pre_tokens:j(),preserved_segment:z({head_uuid:Z(),anchor_uuid:Z(),tail_uuid:Z()}).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:Z(),session_id:A()})),Ys=V(()=>z({type:P(`system`),subtype:P(`status`),status:Ns(),permissionMode:So().optional(),uuid:Z(),session_id:A()})),Xs=V(()=>z({type:P(`system`),subtype:P(`post_turn_summary`),summarizes_uuid:A(),status_category:I([`blocked`,`waiting`,`completed`,`review_ready`,`failed`]),status_detail:A(),is_noteworthy:L(),title:A(),description:A(),recent_action:A(),needs_action:A(),artifact_urls:R(A()),uuid:Z(),session_id:A()}).describe(`@internal Background post-turn summary emitted after each assistant turn. summarizes_uuid points to the assistant message this summarizes.`)),Zs=V(()=>z({type:P(`system`),subtype:P(`api_retry`),attempt:j(),max_retries:j(),retry_delay_ms:j(),error_status:j().nullable(),error:Ms(),uuid:Z(),session_id:A()}).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.`)),Qs=V(()=>z({type:P(`system`),subtype:P(`local_command_output`),content:A(),uuid:Z(),session_id:A()}).describe(`Output from a local slash command (e.g. /voice, /cost). Displayed as assistant-style text in the transcript.`)),$s=V(()=>z({type:P(`system`),subtype:P(`hook_started`),hook_id:A(),hook_name:A(),hook_event:A(),uuid:Z(),session_id:A()})),ec=V(()=>z({type:P(`system`),subtype:P(`hook_progress`),hook_id:A(),hook_name:A(),hook_event:A(),stdout:A(),stderr:A(),output:A(),uuid:Z(),session_id:A()})),tc=V(()=>z({type:P(`system`),subtype:P(`hook_response`),hook_id:A(),hook_name:A(),hook_event:A(),output:A(),stdout:A(),stderr:A(),exit_code:j().optional(),outcome:I([`success`,`error`,`cancelled`]),uuid:Z(),session_id:A()})),nc=V(()=>z({type:P(`tool_progress`),tool_use_id:A(),tool_name:A(),parent_tool_use_id:A().nullable(),elapsed_time_seconds:j(),task_id:A().optional(),uuid:Z(),session_id:A()})),rc=V(()=>z({type:P(`auth_status`),isAuthenticating:L(),output:R(A()),error:A().optional(),uuid:Z(),session_id:A()})),ic=V(()=>z({type:P(`system`),subtype:P(`files_persisted`),files:R(z({filename:A(),file_id:A()})),failed:R(z({filename:A(),error:A()})),processed_at:A(),uuid:Z(),session_id:A()})),ac=V(()=>z({type:P(`system`),subtype:P(`task_notification`),task_id:A(),tool_use_id:A().optional(),status:I([`completed`,`failed`,`stopped`]),output_file:A(),summary:A(),usage:z({total_tokens:j(),tool_uses:j(),duration_ms:j()}).optional(),uuid:Z(),session_id:A()})),oc=V(()=>z({type:P(`system`),subtype:P(`task_started`),task_id:A(),tool_use_id:A().optional(),description:A(),task_type:A().optional(),workflow_name:A().optional().describe(`meta.name from the workflow script (e.g. 'spec'). Only set when task_type is 'local_workflow'.`),prompt:A().optional(),uuid:Z(),session_id:A()})),sc=V(()=>z({type:P(`system`),subtype:P(`session_state_changed`),state:I([`idle`,`running`,`requires_action`]),uuid:Z(),session_id:A()}).describe(`Mirrors notifySessionStateChanged. 'idle' fires after heldBackResult flushes and the bg-agent do-while exits — authoritative turn-over signal.`)),cc=V(()=>z({type:P(`system`),subtype:P(`task_progress`),task_id:A(),tool_use_id:A().optional(),description:A(),usage:z({total_tokens:j(),tool_uses:j(),duration_ms:j()}),last_tool_name:A().optional(),summary:A().optional(),uuid:Z(),session_id:A()})),lc=V(()=>z({type:P(`tool_use_summary`),summary:A(),preceding_tool_use_ids:R(A()),uuid:Z(),session_id:A()})),uc=V(()=>z({type:P(`system`),subtype:P(`elicitation_complete`),mcp_server_name:A(),elicitation_id:A(),uuid:Z(),session_id:A()}).describe(`Emitted when an MCP server confirms that a URL-mode elicitation is complete.`)),dc=V(()=>z({type:P(`prompt_suggestion`),suggestion:A(),uuid:Z(),session_id:A()}).describe(`Predicted next user prompt, emitted after each turn when promptSuggestions is enabled.`));V(()=>z({sessionId:A().describe(`Unique session identifier (UUID).`),summary:A().describe(`Display title for the session: custom title, auto-generated summary, or first prompt.`),lastModified:j().describe(`Last modified time in milliseconds since epoch.`),fileSize:j().optional().describe(`File size in bytes. Only populated for local JSONL storage.`),customTitle:A().optional().describe(`User-set session title via /rename.`),firstPrompt:A().optional().describe(`First meaningful user prompt in the session.`),gitBranch:A().optional().describe(`Git branch at the end of the session.`),cwd:A().optional().describe(`Working directory for the session.`),tag:A().optional().describe(`User-set session tag.`),createdAt:j().optional().describe(`Creation time in milliseconds since epoch, extracted from the first entry's timestamp.`)}).describe(`Session metadata returned by listSessions and getSessionInfo.`));var fc=V(()=>F([Rs(),Fs(),Is(),Gs(),Ks(),qs(),Js(),Ys(),Zs(),Qs(),$s(),ec(),tc(),nc(),rc(),ac(),oc(),cc(),sc(),ic(),lc(),zs(),uc(),dc()])),pc=V(()=>I([`off`,`cooldown`,`on`]).describe(`Fast mode state: off, in cooldown after rate limit, or actively enabled.`));lr(),ur();var mc=V(()=>M()),hc=V(()=>z({matcher:A().optional(),hookCallbackIds:R(A()),timeout:j().optional()}).describe(`Configuration for matching and routing hook callbacks.`)),gc=V(()=>z({subtype:P(`initialize`),hooks:N(wo(),R(hc())).optional(),sdkMcpServers:R(A()).optional(),jsonSchema:N(A(),M()).optional(),systemPrompt:A().optional(),appendSystemPrompt:A().optional(),agents:N(A(),Ds()).optional(),promptSuggestions:L().optional(),agentProgressSummaries:L().optional()}).describe(`Initializes the SDK session with hooks, MCP servers, and agent configuration.`));V(()=>z({commands:R(Ss()),agents:R(Cs()),output_style:A(),available_output_styles:R(A()),models:R(ws()),account:Ts(),pid:j().optional().describe(`@internal CLI process PID for tmux socket isolation`),fast_mode_state:pc().optional()}).describe(`Response from session initialization with available commands, models, and account info.`));var _c=V(()=>z({subtype:P(`interrupt`)}).describe(`Interrupts the currently running conversation turn.`)),vc=V(()=>z({subtype:P(`can_use_tool`),tool_name:A(),input:N(A(),M()),permission_suggestions:R(bo()).optional(),blocked_path:A().optional(),decision_reason:A().optional(),title:A().optional(),display_name:A().optional(),tool_use_id:A(),agent_id:A().optional(),description:A().optional()}).describe(`Requests permission to use a tool with the given input.`)),yc=V(()=>z({subtype:P(`set_permission_mode`),mode:So()}).describe(`Sets the permission mode for tool execution handling.`)),bc=V(()=>z({subtype:P(`set_model`),model:A().optional()}).describe(`Sets the model to use for subsequent conversation turns.`)),xc=V(()=>z({subtype:P(`set_max_thinking_tokens`),max_thinking_tokens:j().nullable()}).describe(`Sets the maximum number of thinking tokens for extended thinking.`)),Sc=V(()=>z({subtype:P(`mcp_status`)}).describe(`Requests the current status of all MCP server connections.`));V(()=>z({mcpServers:R(go())}).describe(`Response containing the current status of all MCP server connections.`));var Cc=V(()=>z({subtype:P(`get_context_usage`)}).describe(`Requests a breakdown of current context window usage by category.`)),wc=V(()=>z({name:A(),tokens:j(),color:A(),isDeferred:L().optional()})),Tc=V(()=>z({color:A(),isFilled:L(),categoryName:A(),tokens:j(),percentage:j(),squareFullness:j()}));V(()=>z({categories:R(wc()),totalTokens:j(),maxTokens:j(),rawMaxTokens:j(),percentage:j(),gridRows:R(R(Tc())),model:A(),memoryFiles:R(z({path:A(),type:A(),tokens:j()})),mcpTools:R(z({name:A(),serverName:A(),tokens:j(),isLoaded:L().optional()})),deferredBuiltinTools:R(z({name:A(),tokens:j(),isLoaded:L()})).optional(),systemTools:R(z({name:A(),tokens:j()})).optional(),systemPromptSections:R(z({name:A(),tokens:j()})).optional(),agents:R(z({agentType:A(),source:A(),tokens:j()})),slashCommands:z({totalCommands:j(),includedCommands:j(),tokens:j()}).optional(),skills:z({totalSkills:j(),includedSkills:j(),tokens:j(),skillFrontmatter:R(z({name:A(),source:A(),tokens:j()}))}).optional(),autoCompactThreshold:j().optional(),isAutoCompactEnabled:L(),messageBreakdown:z({toolCallTokens:j(),toolResultTokens:j(),attachmentTokens:j(),assistantMessageTokens:j(),userMessageTokens:j(),toolCallsByType:R(z({name:A(),callTokens:j(),resultTokens:j()})),attachmentsByType:R(z({name:A(),tokens:j()}))}).optional(),apiUsage:z({input_tokens:j(),output_tokens:j(),cache_creation_input_tokens:j(),cache_read_input_tokens:j()}).nullable()}).describe(`Breakdown of current context window usage by category (system prompt, tools, messages, etc.).`));var Ec=V(()=>z({subtype:P(`rewind_files`),user_message_id:A(),dry_run:L().optional()}).describe(`Rewinds file changes made since a specific user message.`));V(()=>z({canRewind:L(),error:A().optional(),filesChanged:R(A()).optional(),insertions:j().optional(),deletions:j().optional()}).describe(`Result of a rewindFiles operation.`));var Dc=V(()=>z({subtype:P(`cancel_async_message`),message_uuid:A()}).describe(`Drops a pending async user message from the command queue by uuid. No-op if already dequeued for execution.`));V(()=>z({cancelled:L()}).describe(`Result of a cancel_async_message operation. cancelled=false means the message was not in the queue (already dequeued or never enqueued).`));var Oc=V(()=>z({subtype:P(`seed_read_state`),path:A(),mtime:j()}).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.`)),kc=V(()=>z({subtype:P(`hook_callback`),callback_id:A(),input:rs(),tool_use_id:A().optional()}).describe(`Delivers a hook callback with its input data.`)),Ac=V(()=>z({subtype:P(`mcp_message`),server_name:A(),message:mc()}).describe(`Sends a JSON-RPC message to a specific MCP server.`)),jc=V(()=>z({subtype:P(`mcp_set_servers`),servers:N(A(),po())}).describe(`Replaces the set of dynamically managed MCP servers.`));V(()=>z({added:R(A()),removed:R(A()),errors:N(A(),A())}).describe(`Result of replacing the set of dynamically managed MCP servers.`));var Mc=V(()=>z({subtype:P(`reload_plugins`)}).describe(`Reloads plugins from disk and returns the refreshed session components.`));V(()=>z({commands:R(Ss()),agents:R(Cs()),plugins:R(z({name:A(),path:A(),source:A().optional()})),mcpServers:R(go()),error_count:j()}).describe(`Refreshed commands, agents, plugins, and MCP server status after reload.`));var Nc=V(()=>z({subtype:P(`mcp_reconnect`),serverName:A()}).describe(`Reconnects a disconnected or failed MCP server.`)),Pc=V(()=>z({subtype:P(`mcp_toggle`),serverName:A(),enabled:L()}).describe(`Enables or disables an MCP server.`)),Fc=V(()=>z({subtype:P(`stop_task`),task_id:A()}).describe(`Stops a running task.`)),Ic=V(()=>z({subtype:P(`apply_flag_settings`),settings:N(A(),M())}).describe(`Merges the provided settings into the flag settings layer, updating the active configuration.`)),Lc=V(()=>z({subtype:P(`get_settings`)}).describe(`Returns the effective merged settings and the raw per-source settings.`));V(()=>z({effective:N(A(),M()),sources:R(z({source:I([`userSettings`,`projectSettings`,`localSettings`,`flagSettings`,`policySettings`]),settings:N(A(),M())})).describe(`Ordered low-to-high priority — later entries override earlier ones.`),applied:z({model:A()}).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 Rc=V(()=>z({subtype:P(`elicitation`),mcp_server_name:A(),message:A(),mode:I([`form`,`url`]).optional(),url:A().optional(),elicitation_id:A().optional(),requested_schema:N(A(),M()).optional()}).describe(`Requests the SDK consumer to handle an MCP elicitation (user input request).`)),zc=V(()=>z({action:I([`accept`,`decline`,`cancel`]),content:N(A(),M()).optional()}).describe(`Response from the SDK consumer for an elicitation request.`)),Bc=V(()=>F([_c(),vc(),gc(),yc(),bc(),xc(),Sc(),Cc(),kc(),Ac(),Ec(),Dc(),Oc(),jc(),Mc(),Nc(),Pc(),Fc(),Ic(),Lc(),Rc()])),Vc=V(()=>z({type:P(`control_request`),request_id:A(),request:Bc()})),Hc=V(()=>z({subtype:P(`success`),request_id:A(),response:N(A(),M()).optional()})),Uc=V(()=>z({subtype:P(`error`),request_id:A(),error:A(),pending_permission_requests:R(cr(()=>Vc())).optional()})),Wc=V(()=>z({type:P(`control_response`),response:F([Hc(),Uc()])})),Gc=V(()=>z({type:P(`control_cancel_request`),request_id:A()}).describe(`Cancels a currently open control request.`)),Kc=V(()=>z({type:P(`keep_alive`)}).describe(`Keep-alive message to maintain WebSocket connection.`)),qc=V(()=>z({type:P(`update_environment_variables`),variables:N(A(),A())}).describe(`Updates environment variables at runtime.`));V(()=>F([fc(),Bs(),Vs(),Xs(),Wc(),Vc(),Gc(),Kc()])),V(()=>F([Fs(),Vc(),Wc(),Kc(),qc()])),tt(),lr(),ur(),Nn(),C(),V(()=>B.object({tool_name:B.string().describe(`The name of the tool requesting permission`),input:B.record(B.string(),B.unknown()).describe(`The input for the tool`),tool_use_id:B.string().optional().describe(`The unique tool use request ID`)}));var Jc=V(()=>B.enum([`user_temporary`,`user_permanent`,`user_reject`]).optional().catch(void 0)),Yc=V(()=>B.object({behavior:B.literal(`allow`),updatedInput:B.record(B.string(),B.unknown()),updatedPermissions:B.array(le()).optional().catch(e=>{G(`Malformed updatedPermissions from SDK host ignored: ${e.error.issues[0]?.message??`unknown`}`,{level:`warn`})}),toolUseID:B.string().optional(),decisionClassification:Jc()})),Xc=V(()=>B.object({behavior:B.literal(`deny`),message:B.string(),interrupt:B.boolean().optional(),toolUseID:B.string().optional(),decisionClassification:Jc()})),Zc=V(()=>B.union([Yc(),Xc()]));function Qc(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:f(e.toolPermissionContext,t)})),Sn(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}}Cr(),zr(),qr(),Wr(),Pi(),Li(),oe(),ne(),In(),un(),Hi(),bn(),Zn(),wn(),qe(),Yi(),pt(),at(),T(),ge(),At(),g(),v(),x(),b(),Vn(),ct();var $c=/\u2028|\u2029/g;function el(e){return e.replace($c,e=>e===`\u2028`?`\\u2028`:`\\u2029`)}function tl(e){return el(U(e))}jr(),Fr(),lr(),Nn();var nl=`SandboxNetworkAccess`;function rl(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 il(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 al=1e3,ol=class{constructor(e,t){s(this,`input`,void 0),s(this,`replayUserMessages`,void 0),s(this,`structuredInput`,void 0),s(this,`pendingRequests`,new Map),s(this,`restoredWorkerState`,Promise.resolve(null)),s(this,`inputClosed`,!1),s(this,`unexpectedResponseCallback`,void 0),s(this,`resolvedToolUseIds`,new Set),s(this,`prependedLines`,[]),s(this,`onControlRequestSent`,void 0),s(this,`onControlRequestResolved`,void 0),s(this,`outbound`,new vt),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>al)){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(U({type:`user`,content:e,uuid:``,session_id:``,message:{role:`user`,content:e},parent_tool_use_id:null})+`
2
+ `)}async*read(){let e=``,t=async function*(){for(;;){this.prependedLines.length>0&&(e=this.prependedLines.join(``)+e,this.prependedLines=[]);let t=e.indexOf(`
3
+ `);if(t===-1)break;let n=e.slice(0,t);e=e.slice(t+1);let r=await this.processLine(n);r&&(ei(`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=pa(Dr(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&&Ze(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||sl(`Error: Missing request on control_request`),t):(t.type===`assistant`||t.type===`system`||t.message?.role!==`user`&&sl(`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(tl(e)+`
4
+ `)}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 Tr))};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 rt(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=cl(t.name,a,n,r,s.suggestions).then(e=>({source:`hook`,decision:e})),o=Y();e?.(il(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:rl(s.decisionReason),tool_use_id:a,agent_id:r.agentId},Zc(),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):Qc((await l).result,t,n,r):Qc(u.result,t,n,r)}catch(e){return Qc({behavior:`deny`,message:`Tool permission request failed: ${e}`,toolUseID:a},t,n,r)}finally{this.getPendingPermissionRequests().length===0&&Xi(`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},qn(),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},zc(),r)}catch{return{action:`cancel`}}}createSandboxAskCallback(){return async e=>{try{return(await this.sendRequest({subtype:`can_use_tool`,tool_name:nl,input:{host:e.host},tool_use_id:Y(),description:`Allow network connection to ${e.host}?`},Zc())).behavior===`allow`}catch{return!1}}}async sendMcpMessage(e,t){return(await this.sendRequest({subtype:`mcp_message`,server_name:e,message:t},z({mcp_response:ar()}))).mcp_response}};function sl(e){console.error(e),process.exit(1)}async function cl(e,t,n,r,i){let a=r.getAppState().toolPermissionContext.mode,o=dt(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){Sn(i);let e=f(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`}}}}Vi(),va();function ll(e,t={},n,i){if(r(process.env.CLAUDE_CODE_USE_CCR_V2)){let r=new $a(e.href);return r.protocol===`wss:`?r.protocol=`https:`:r.protocol===`ws:`&&(r.protocol=`http:`),r.pathname=r.pathname.replace(/\/$/,``)+`/worker/events/stream`,new ya(r,t,n,i)}if(e.protocol===`ws:`||e.protocol===`wss:`)return r(process.env.CLAUDE_CODE_POST_FOR_SESSION_INGRESS_V2)?new _a(e,t,n,i):new ga(e,t,n,i);throw Error(`Unsupported protocol: ${e.protocol}`)}Zn(),jr(),$r(),i(),Er(),Zr(),Yi(),va(),o();var ul=class extends ol{constructor(e,t,n){let i=new Ja({encoding:`utf8`});super(i,n),s(this,`url`,void 0),s(this,`transport`,void 0),s(this,`inputStream`,void 0),s(this,`isBridge`,!1),s(this,`isDebug`,!1),s(this,`ccrClient`,null),s(this,`keepAliveTimer`,null),this.inputStream=i,this.url=new $a(e);let a={},o=qi();o?a.Authorization=`Bearer ${o}`: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=qi();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=ll(this.url,a,H(),l),this.isBridge=process.env.CLAUDE_CODE_ENVIRONMENT_KIND===`bridge`,this.isDebug=kr(),this.transport.setOnData(e=>{this.inputStream.write(e),this.isBridge&&this.isDebug&&K(e.endsWith(`
5
+ `)?e:e+`
6
+ `)}),this.transport.setOnClose(()=>{this.inputStream.end()}),r(process.env.CLAUDE_CODE_USE_CCR_V2)){if(!(this.transport instanceof ya))throw Error(`CCR v2 requires SSETransport; check getTransportForUrl`);this.ccrClient=new ha(this.transport,this.url);let e=this.ccrClient.initialize();this.restoredWorkerState=e.catch(()=>null),e.catch(e=>{ei(`error`,`cli_worker_lifecycle_init_failed`,{reason:e instanceof ma?e.reason:`unknown`}),q(Error(`CCRClient initialization failed: ${W(e)}`)),mt(1,`other`)}),Mr(async()=>this.ccrClient?.close()),Pt((e,t,n)=>this.ccrClient.writeInternalEvent(e,t,n)),er(()=>this.ccrClient.readInternalEvents(),()=>this.ccrClient.readSubagentInternalEvents());let t={started:`processing`,completed:`processed`};y((e,n)=>{this.ccrClient?.reportDelivery(e,t[n])}),Ji((e,t)=>{this.ccrClient?.reportState(e,t)}),Ki(e=>{this.ccrClient?.reportMetadata(e)},{replayCurrent:!0})}this.transport.connect();let u=fa().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?.()),Mr(async()=>this.close()),t){let e=this.inputStream;(async()=>{for await(let n of t)e.write(String(n).replace(/\n$/,``)+`
7
+ `)})()}}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(tl(e)+`
8
+ `)}close(){this.keepAliveTimer&&(clearInterval(this.keepAliveTimer),this.keepAliveTimer=null),this.transport.close(),this.inputStream.end()}};Ri(),Lr(),Fi(),[...Bi],Nr(),jr();var dl=`[stdout-guard]`,fl=!1,Q=``,pl=null;function ml(e){if(e.length===0)return!0;try{return JSON.parse(e),!0}catch{return!1}}function hl(){fl||(fl=!0,pl=process.stdout.write.bind(process.stdout),process.stdout.write=function(e,t,n){let r=typeof e==`string`?e:Buffer.from(e).toString(`utf-8`);Q+=r;let i,a=!0;for(;(i=Q.indexOf(`
9
+ `))!==-1;){let e=Q.slice(0,i);Q=Q.slice(i+1),ml(e)?a=pl(e+`
10
+ `):(process.stderr.write(`${dl} ${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},Mr(async()=>{Q.length>0&&(pl&&ml(Q)?pl(Q+`
11
+ `):process.stderr.write(`${dl} ${Q}\n`),Q=``),pl&&(process.stdout.write=pl,pl=null),fl=!1}))}Yr(),Fe(),Ui(),Ct(),Xe(),cn(),Ii(),Wn(),ht(),m(),ie(),Pn(),gt(),Tt(),ir(),Vt(),pn(),ka(),It(),Er(),ii(),Vi(),Xn(),jr(),qe();function gl(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`),k())},n))},stop(){i&&(clearTimeout(i),i=null)}}}ra(),Se(),S(),kn(),Un();function _l(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)?vl(t):t,uuid:n}}function vl(e){return e.some(yl)?e.map(e=>{if(!yl(e))return e;let t=e.source,n=typeof t.mediaType==`string`&&t.mediaType?t.mediaType:Et(e.source.data);return{...e,source:{type:`base64`,media_type:n,data:e.source.data}}}):e}function yl(e){return e.type!==`image`||e.source?.type!==`base64`?!1:!e.source.media_type}lr(),_r(),jr(),i(),ur(),ia();var bl=3e4;function xl(e){G(`[bridge:inbound-attach] ${e}`)}var Sl=V(()=>z({file_uuid:A(),file_name:A()})),Cl=V(()=>R(Sl()));function wl(e){if(typeof e!=`object`||!e||!(`file_attachments`in e))return[];let t=Cl().safeParse(e.file_attachments);return t.success?t.data:[]}function Tl(e){return Ga(e).replace(/[^a-zA-Z0-9._-]/g,`_`)||`attachment`}function El(){return qa(n(),`uploads`,H())}async function Dl(e){let t=oa();if(!t){xl(`skip: no oauth token`);return}let n;try{let r=`${aa()}/api/oauth/files/${encodeURIComponent(e.file_uuid)}/content`,i=await c.get(r,{headers:{Authorization:`Bearer ${t}`},responseType:`arraybuffer`,timeout:bl,validateStatus:()=>!0});if(i.status!==200){xl(`fetch ${e.file_uuid} failed: status=${i.status}`);return}n=Buffer.from(i.data)}catch(t){xl(`fetch ${e.file_uuid} threw: ${t}`);return}let r=Tl(e.file_name),i=(e.file_uuid.slice(0,8)||Y().slice(0,8)).replace(/[^a-zA-Z0-9_-]/g,`_`),a=El(),o=qa(a,`${i}-${r}`);try{await Ya(a,{recursive:!0}),await Qa(o,n)}catch(e){xl(`write ${o} failed: ${e}`);return}return xl(`resolved ${e.file_uuid} → ${o} (${n.length} bytes)`),o}async function Ol(e){if(e.length===0)return``;xl(`resolving ${e.length} attachment(s)`);let t=(await Promise.all(e.map(Dl))).filter(e=>e!==void 0);return t.length===0?``:t.map(e=>`@"${e}"`).join(` `)+` `}function kl(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 Al(e,t){let n=wl(e);return n.length===0?t:kl(t,await Ol(n))}yi(),Ee(),Bt(),Kt(),Cn(),te(),da(),Na();function jl(e){if(e.toLowerCase().endsWith(`.jsonl`))return{sessionId:Y(),ingressUrl:null,isUrl:!1,jsonlFile:e,isJsonlFile:!0};if(tn(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}Ti(),Dn(),sn(),ft(),Oe(),He(),rn(),ce(),tr(),Ht(),ve(),ca(),Ia(),La(),jr(),Fr();async function Ml(){try{let e=await Xa(ln(),`utf-8`),t=Vr().safeParse(Dr(e));return t.success?t.data:(G(`Invalid known_marketplaces.json in zip cache: ${t.error.message}`,{level:`error`}),{})}catch{return{}}}async function Nl(e){await Rn(ln(),U(e,null,2))}async function Pl(e,t){let n=vn();if(!n)return;let r=await Fl(t);r!==null&&await Rn(qa(n,qt(e)),r)}async function Fl(e){let t=[qa(e,`.claude-plugin`,`marketplace.json`),qa(e,`marketplace.json`),e];for(let e of t)try{return await Xa(e,`utf-8`)}catch{}return null}async function Il(){let e=await st();for(let[t,n]of Object.entries(e))if(n.installLocation)try{await Pl(t,n.installLocation)}catch(e){G(`Failed to save marketplace JSON for ${t}: ${e}`)}await Nl({...await Ml(),...e})}ci(),Nr(),jr(),$r(),ii(),ir(),Tt();async function Ll(){let e=nr();G(`installPluginsForHeadless: starting${e?` (zip cache mode)`:``}`);let t=await ut();t&&(Ue(),jn(`headlessPluginInstall: seed marketplaces registered`)),e&&(await Pr().mkdir(Qt()),await Pr().mkdir(Xt()));let n=Object.keys(he()).length,r={marketplaces_installed:0,delisted_count:0},i=t;try{if(n===0)G(`installPluginsForHeadless: no marketplaces declared`);else{let t=await Qr(`headless_marketplace_reconcile`,()=>Ha({skip:e?(e,t)=>!Hn(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&&(Ue(),jn(`headlessPluginInstall: marketplaces reconciled`),i=!0),r.marketplaces_installed=n}e&&await Il();let t=await Ta();return r.delisted_count=t.length,t.length>0&&(i=!0),i&&jn(`headlessPluginInstall: plugins changed`),e&&Mr(Ut),i}catch(e){return q(e),!1}finally{J(`tengu_headless_plugin_install`,r)}}ci(),jr(),$r(),Zn(),Yi(),ii(),Zr(),wn(),qe(),Nr(),Cr(),ct(),_r(),x(),Vn(),g(),Fr(),i(),Wa(),Vt(),Tn(),ee(),Je(),Er();var $=(Wi(),e(ta)),Rl=1e4,zl=new Set,Bl=[];function Vl(e){if(zl.has(e))return!1;if(zl.add(e),Bl.push(e),Bl.length>Rl){let e=Bl.splice(0,Bl.length-Rl);for(let t of e)zl.delete(t)}return!0}function Hl(e){return typeof e==`string`?[{type:`text`,text:e}]:e}function Ul(e){return e.length===1?e[0]:e.every(e=>typeof e==`string`)?e.join(`
12
+ `):e.flatMap(Hl)}function Wl(e,t){return t!==void 0&&t.mode===`prompt`&&t.workload===e.workload&&t.isMeta===e.isMeta}async function Gl(e,t,n,i,a,o,s,c){if(Be.subscribe(e=>{Ln(e,n),Ei()&&n(e=>{let t=e.settings,n=t.fastMode===!0&&!t.fastModePerSessionOptIn;return{...e,fastMode:n}})}),$&&!$.isProactiveActive()&&r(process.env.CLAUDE_CODE_PROACTIVE)&&$.activateProactive(`command`),typeof Bun<`u`&&setInterval(()=>{process.memoryUsage.rss()>350*1024*1024?Bun.gc(!0):Bun.gc(!1)},1e3).unref(),Bn(),wt(`runHeadless_entry`),await ba()&&await xa(),wt(`after_grove_check`),c.resumeSessionAt&&!c.resume){process.stderr.write(`Error: --resume-session-at requires --resume
13
+ `),k(1);return}if(c.rewindFiles&&!c.resume){process.stderr.write(`Error: --rewind-files requires --resume
14
+ `),k(1);return}if(c.rewindFiles&&e){process.stderr.write(`Error: --rewind-files is a standalone operation and cannot be used with a prompt
15
+ `),k(1);return}let l=tu(e,c);c.outputFormat===`stream-json`&&hl();let u=Nt.getSandboxUnavailableReason();if(u){if(Nt.isSandboxRequired()){process.stderr.write(`\nError: sandbox required but unavailable: ${u}\n sandbox.failIfUnavailable is set — refusing to start without a working sandbox.\n\n`),k(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(Nt.isSandboxingEnabled())try{await Nt.initialize(l.createSandboxAskCallback())}catch(e){process.stderr.write(`\n❌ Sandbox Error: ${W(e)}\n`),k(1,`other`);return}c.outputFormat===`stream-json`&&c.verbose&&Pe(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:H()};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:H()};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:H()}}})();l.write(t)}),c.setupTrigger&&await fe(c.setupTrigger),wt(`before_loadInitialMessages`);let d=t(),{messages:f,turnInterruptionState:p,agentSetting:m}=await eu(n,{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=se();if(h&&l.prependUserMessage(h),!c.agent&&!vr()&&m){let{agentDefinition:e}=za(m,void 0,{activeAgents:s,allAgents:s});if(e){if(n(t=>({...t,agent:e.agentType})),!c.systemPrompt&&!En(e)){let t=e.getSystemPrompt();t&&(c.systemPrompt=t)}An(e.agentType)}}if(f.length===0&&process.exitCode!==void 0)return;if(c.rewindFiles){let e=f.find(e=>e.uuid===c.rewindFiles);if(!e||e.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`),k(1);return}let r=t(),i=await Xl(c.rewindFiles,r,n,!1);if(!i.canRewind){process.stderr.write(`Error: ${i.error||`Unexpected error`}\n`),k(1);return}process.stdout.write(`Files rewound to state at message ${c.rewindFiles}\n`),k(0);return}let g=typeof c.resume==`string`&&(!!tn(c.resume)||c.resume.endsWith(`.jsonl`)),_=!!c.sdkUrl;if(!e&&!g&&!_){process.stderr.write(`Error: Input must be provided either through stdin or as a prompt argument when using --print
16
+ `),k(1);return}if(c.outputFormat===`stream-json`&&!c.verbose){process.stderr.write(`Error: When using --print, --output-format=stream-json requires --verbose
17
+ `),k(1);return}let ee=Ke(d.mcp.tools,d.toolPermissionContext),v=[...a,...ee],te=Jl(c.sdkUrl?`stdio`:c.permissionPromptToolName,l,()=>t().mcp.tools,e=>{n(e=>({...e,attribution:{...e.attribution,permissionPromptCount:e.attribution.permissionPromptCount+1}})),Xi(`requires_action`,e)});c.permissionPromptToolName&&(v=v.filter(e=>!zi(e,c.permissionPromptToolName))),Xr(),wt(`after_loadInitialMessages`),await di(),wt(`after_modelStrings`);let ne=c.outputFormat===`json`&&c.verbose,re=[],y;wt(`before_runHeadlessStreaming`);for await(let e of Kl(l,d.mcp.clients,[...i,...d.mcp.commands],v,f,te,o,t,n,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`&&(ne&&re.push(e),y=e);switch(c.outputFormat){case`json`:if(!y||y.type!==`result`)throw Error(`No messages returned`);if(c.verbose){K(U(re)+`
18
+ `);break}K(U(y)+`
19
+ `);break;case`stream-json`:break;default:if(!y||y.type!==`result`)throw Error(`No messages returned`);switch(y.subtype){case`success`:K(y.result.endsWith(`
20
+ `)?y.result:y.result+`
21
+ `);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.
22
+ Tip: Simplify your schema or check if the output format matches the expected structure.`)}}if(Ft(),Jr())try{let{drainPendingExtraction:e}=await import(`./extractMemories-DqhN0lba.js`);await e()}catch{}k(y?.type===`result`&&y?.is_error?1:0)}function Kl(e,n,i,o,s,c,l,f,m,g,_,ee){let v=!1,te,ne=!1,re=null,y,b=e.outbound;process.on(`SIGINT`,()=>{ei(`info`,`shutdown_signal`,{signal:`SIGINT`}),y&&!y.signal.aborted&&y.abort(),mt(0)}),Mr(async()=>{let t={};for(let e of fn(f()))ot(e)&&(t[e.type]=(t[e.type]??0)+1);ei(`info`,`run_state_at_shutdown`,{run_active:v,run_phase:te,worker_status:$i(),internal_events_pending:e.internalEventsPending,bg_tasks:t})}),Zi(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:H()})});let x={abortController:null,inflightPromise:null,lastEmitted:null,pendingSuggestion:null,pendingLastEmittedEntry:null},ie;_.enableAuthStatus&&(ie=gi.getInstance().subscribe(e=>{b.enqueue({type:`auth_status`,isAuthenticating:e.isAuthenticating,output:e.output,error:e.error,uuid:Y(),session_id:H()})}));let ae=e=>{let t=la(e);t&&b.enqueue({type:`rate_limit_event`,rate_limit_info:t,uuid:Y(),session_id:H()})};yt.add(ae);let S=s,oe=Te(s,eo(),100),se=hn(100),ce=process.env.CLAUDE_CODE_RESUME_INTERRUPTED_TURN;ee&&ee.kind!==`none`&&ce&&(G(`[print.ts] Auto-resuming interrupted turn (kind: ${ee.kind})`),$l(S,ee.message),Mn({mode:`prompt`,value:ee.message.message.content,uuid:Y()}));let le=Ra().map(e=>{let t=e.value===null?`default`:e.value,n=t==="default"?Ci():ui(t),r=_n(n),i=xi(e.value),a=fi(n);return{name:t,value:t,displayName:e.label,description:e.description,...r&&{supportsAdaptiveThinking:!0},...i&&{supportsFastMode:!0},...a&&{supportsAutoMode:!0}}}),ue=_.userSpecifiedModel;function fe(e,t){let n=$n(e,Mi(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:H(),parent_tool_use_id:null,uuid:e.uuid,timestamp:e.timestamp,isReplay:!0})}let C=[],he=[],ge=new Set;function ve(t){for(let n of t){if(n.type!==`connected`||ge.has(n.name)||n.config.type===`sdk`)continue;let t=n.name;try{n.client.setRequestHandler(lt,async(n,r)=>{ni(t,`Elicitation request received in print mode: ${U(n)}`);let i=n.params.mode===`url`?`url`:`form`;J(`tengu_mcp_elicitation_shown`,{mode:i});let a=await Ge(t,n.params,r.signal);if(a)return ni(t,`Elicitation resolved by hook: ${U(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 e.handleElicitation(t,n.params.message,s,r.signal,i,o,c),d=await u(t,l,r.signal,i,c);return J(`tengu_mcp_elicitation_response`,{mode:i,action:d.action}),d}),n.client.setNotificationHandler(De,e=>{let{elicitationId:n}=e.params;ni(t,`Elicitation completion notification: ${n}`),xe({message:`MCP server "${t}" confirmed elicitation ${n} complete`,notificationType:`elicitation_complete`}),b.enqueue({type:`system`,subtype:`elicitation_complete`,mcp_server_name:t,elicitation_id:n,uuid:Y(),session_id:H()})}),ge.add(t)}catch{}}}async function ye(){let t=new Set(Object.keys(l)),n=new Set(C.map(e=>e.name)),r=Array.from(t).some(e=>!n.has(e)),i=Array.from(n).some(e=>!t.has(e)),a=C.some(e=>e.type===`pending`),o=C.some(e=>e.type===`failed`);if(r||i||a||o){for(let e of C)t.has(e.name)||e.type===`connected`&&await e.cleanup();let r=await _t(l,(t,n)=>e.sendMcpMessage(t,n));C=r.clients,he=r.tools;let i=Ir([...n,...t]);m(e=>({...e,mcp:{...e.mcp,tools:[...e.mcp.tools.filter(e=>!i.some(t=>e.name.startsWith(Gr(t)))),...he]}})),xt(C)}}ye();let w={clients:[],tools:[],configs:{}},Se=e=>{let t=bt(e.toolPermissionContext,e.mcp.tools),n=Le(Oa([...o,...he,...w.tools],t,e.toolPermissionContext.mode),`name`);_.permissionPromptToolName&&(n=n.filter(e=>!zi(e,_.permissionPromptToolName)));let r=gr();if(r&&!_.jsonSchema){let e=Ni(r);`tool`in e&&(n=[...n,e.tool])}return n},T=null,Ee=0;function Oe(){if(!T)return;let e=Math.min(Ee,S.length),t=S.slice(e).filter(e=>e.type===`user`||e.type===`assistant`);Ee=S.length,t.length>0&&T.writeMessages(t)}let Ae=Promise.resolve({response:{added:[],removed:[],errors:{}},sdkServersChanged:!1});function Ne(e){let t=async()=>{let t=new Set(C.map(e=>e.name)),n=await iu(e,{configs:l,clients:C,tools:he},w,m);for(let e of Object.keys(l))delete l[e];if(Object.assign(l,n.newSdkState.configs),C=n.newSdkState.clients,he=n.newSdkState.tools,w=n.newDynamicState,n.sdkServersChanged){let e=new Set(C.map(e=>e.name)),n=Ir([...t,...e]);m(e=>({...e,mcp:{...e.mcp,tools:[...e.mcp.tools.filter(e=>!n.some(t=>e.name.startsWith(Gr(t)))),...he]}}))}return{response:n.response,sdkServersChanged:n.sdkServersChanged}};return Ae=Ae.then(t,t),Ae}function Pe(){let e=f(),t=e.mcp.clients,n=Le([...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`?_e(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 Fe(){try{await Promise.all([Promise.resolve(),Qr(`headless_managed_settings_wait`,()=>Sa())]),await Ll()&&await Je()}catch(e){q(e)}}let Ie=null;a()||(r(process.env.CLAUDE_CODE_SYNC_PLUGIN_INSTALL)?Ie=Fe():Fe());let He=gl(()=>!v),Ue=i,Ke=g;async function qe(){let{agentDefinitions:e}=await Ua(m);Ue=await me(eo());let t=Ke.filter(e=>e.source===`flagSettings`);Ke=[...e.allAgents,...t]}async function Je(){let{servers:e}=await Me(),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 Ne(t);r&&ye(),G(`Headless MCP refresh: added=${n.added.length}, removed=${n.removed.length}`)}let Xe=Va.subscribe(()=>{h(),me(eo()).then(e=>{Ue=e})}),Qe=()=>{setTimeout(()=>{!$?.isProactiveActive()||$.isProactivePaused()||ne||(async()=>{let e=await Ve({basePrompt:`<${ti}>${new Date().toLocaleTimeString()}</${ti}>`,currentDir:eo(),shouldCreate:()=>!ne});if(ne){await Kn({commands:e});return}for(let t of e)Mn({...t,uuid:Y()});$e()})().catch(e=>{q(e),G(`[Proactive] failed to create headless tick: ${e}`,{level:`error`})})},0)};Lt(()=>{y&&Yt(`now`).length>0&&y.abort(`interrupt`)});let $e=async()=>{if(v)return;if(v=!0,te=void 0,Xi(`running`),He.stop(),wt(`run_entry`),await ye(),wt(`after_updateSdkMcp`),Ie){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([Ie,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 Ie;Ie=null,await qe();let{setupPluginHookHotReload:t}=await import(`./loadPluginHooks-Dt3XQ-3N.js`);t()}let n=e=>e.agentId===void 0;try{let r,i=!1,a=async()=>{for(;r=jt(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(;Wl(r,Dt(n));)i.push(jt(n));let a=await et(i);if(i=a.attachmentCommands,i.length===0)continue;r=i[0],r.mode===`prompt`&&i.length>1&&(r={...r,value:Ul(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(_.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:H(),parent_tool_use_id:null,uuid:e.uuid,isReplay:!0});let s=f(),l=[...s.mcp.clients,...C,...w.clients];ve(l);let u=Se(s);for(let e of o)Ze(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:H(),uuid:Y()})}let d=r.value,p=a.claimedCommands;if(e instanceof ul&&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 d==`string`?d:d.find(e=>e.type===`text`)?.text;typeof e==`string`&&$t(x.lastEmitted.text,e,x.lastEmitted.emittedAt,x.lastEmitted.promptId,x.lastEmitted.generationRequestId),x.lastEmitted=null}y=Wt(),wt(`before_ask`),we();let h=r,g=!1;try{if(await bi(h.workload??_.workload,async()=>{for await(let t of Aa({commands:Le([...Ue,...s.mcp.commands],`name`),prompt:d,promptUuid:h.uuid,isMeta:h.isMeta,cwd:eo(),tools:u,verbose:_.verbose,mcpClients:l,thinkingConfig:_.thinkingConfig,maxTurns:_.maxTurns,maxBudgetUsd:_.maxBudgetUsd,taskBudget:_.taskBudget,canUseTool:c,userSpecifiedModel:ue,fallbackModel:_.fallbackModel,jsonSchema:gr()??_.jsonSchema,mutableMessages:S,getReadFileCache:()=>se.size===0?oe:Zt(oe,se),setReadFileCache:e=>{oe=e;for(let[e,t]of se.entries()){let n=oe.get(e);(!n||t.timestamp>n.timestamp)&&oe.set(e,t)}se.clear()},customSystemPrompt:_.systemPrompt,appendSystemPrompt:_.appendSystemPrompt,getAppState:f,setAppState:m,abortController:y,replayUserMessages:_.replayUserMessages,includePartialMessages:_.includePartialMessages,handleElicitation:(t,n,r)=>e.handleElicitation(t,n.message,void 0,r,n.mode,n.url,`elicitationId`in n?n.elicitationId:void 0),agents:Ke,orphanedPermission:h.orphanedPermission,setSDKStatus:e=>{b.enqueue({type:`system`,subtype:`status`,status:e,session_id:H(),uuid:Y()})}}))if(Oe(),t.type===`result`){g=!!t.is_error;for(let e of ea())b.enqueue(e);fn(f()).some(e=>(e.type===`local_agent`||e.type===`local_workflow`)&&ot(e))?re=t:(re=null,b.enqueue(t))}else{for(let e of ea())b.enqueue(e);b.enqueue(t)}}),g)await pe({commands:p,outcome:{type:`failed`,message:`ask() returned an error result`},currentDir:eo(),priority:`later`,workload:h.workload??_.workload});else{let e=await pe({commands:p,outcome:{type:`completed`},currentDir:eo(),priority:`later`,workload:h.workload??_.workload});for(let t of e)Mn({...t,uuid:Y()})}}catch(e){throw await pe({commands:p,outcome:{type:`failed`,error:e},currentDir:eo(),priority:`later`,workload:h.workload??_.workload}),e}for(let e of o)Ze(e,`completed`);if(Oe(),T?.sendResult(),_.promptSuggestions&&!t(process.env.CLAUDE_CODE_ENABLE_PROMPT_SUGGESTION)){x.abortController?.abort();let e=new AbortController;x.abortController=e;let t=zt();if(!t)Ot(`sdk_no_params`,void 0,void 0,`sdk`);else{let n={promise:null};n.promise=(async()=>{try{let n=await On(e,S,f,t,`sdk`);if(!n||e.signal.aborted)return;let r={type:`prompt_suggestion`,suggestion:n.suggestion,uuid:Y(),session_id:H()},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`)){Ot(`aborted`,void 0,void 0,`sdk`);return}q(Or(e))}finally{x.inflightPromise===n.promise&&(x.inflightPromise=null)}})(),x.inflightPromise=n.promise}}Ft(),ke(),Bn()}};do{for(let e of ea())b.enqueue(e);te=`draining_commands`,await a(),i=!1;{let e=fn(f()).some(e=>ot(e)),t=Dt(n)!==void 0;(e||t)&&(i=!0,t||(te=`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(t){try{await e.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:H(),total_cost_usd:0,usage:Qi,modelUsage:{},permission_denials:[],uuid:Y(),errors:[W(t),...ri().map(e=>e.error)]})}catch{}x.abortController?.abort(),k(1);return}finally{if(te=`finally_flush`,await e.flushInternalEvents(),te=`finally_post_flush`,!d()){Xi(`idle`);for(let e of ea())b.enqueue(e)}v=!1,He.start()}if($?.isProactiveActive()&&!$.isProactivePaused()&&Dt(n)===void 0&&!ne){Qe();return}if(Dt(n)!==void 0){$e();return}ne&&(x.inflightPromise&&await Promise.race([x.inflightPromise,Ai(5e3)]),x.abortController?.abort(),x.abortController=null,await We(),Xe(),ie?.(),yt.delete(ae),b.done())},D=function(e,t){b.enqueue({type:`control_response`,response:{subtype:`success`,request_id:e.request_id,response:t}})},O=function(e,t){b.enqueue({type:`control_response`,response:{subtype:`error`,request_id:e.request_id,error:t}})},tt=new Set;e.setUnexpectedResponseCallback(async e=>{await nu({message:e,setAppState:m,handledToolUseIds:tt,onEnqueued:()=>{$e()}})});let rt=new Map,it=new Map,at=new Set,st=new Map,ct=null;return(async()=>{let t=!1;ei(`info`,`cli_message_loop_started`);for await(let r of e.structuredInput){let a=`uuid`in r?r.uuid:void 0;if(a&&r.type!==`user`&&r.type!==`control_response`&&Ze(a,`completed`),r.type===`control_request`){let a=r,o=a.request;if(a.request.subtype===`interrupt`)m(e=>({...e,attribution:{...e.attribution,escapeCount:e.attribution.escapeCount+1}})),y&&y.abort(),x.abortController?.abort(),x.abortController=null,x.lastEmitted=null,x.pendingSuggestion=null,D(a);else if(o.subtype===`end_session`){G(`[print.ts] end_session received, reason=${o.reason??`unspecified`}`),y&&y.abort(),x.abortController?.abort(),x.abortController=null,x.lastEmitted=null,x.pendingSuggestion=null,D(a);break}else if(a.request.subtype===`initialize`){if(a.request.sdkMcpServers&&a.request.sdkMcpServers.length>0)for(let e of a.request.sdkMcpServers)l[e]={type:`sdk`,name:e};await Yl(a.request,a.request_id,t,b,i,le,e,!!_.enableAuthStatus,_,g,f),a.request.promptSuggestions&&m(e=>e.promptSuggestionEnabled?e:{...e,promptSuggestionEnabled:!0}),a.request.agentProgressSummaries&&xr(!0),t=!0,yn()&&$e()}else if(a.request.subtype===`set_permission_mode`){let e=a.request;m(t=>({...t,toolPermissionContext:Zl(e,a.request_id,t.toolPermissionContext,b)}))}else if(a.request.subtype===`set_model`){let e=a.request.model??`default`,t=e==="default"?Ci():e;ue=t,mr(t),Gi({model:t}),fe(e,t),D(a)}else if(a.request.subtype===`set_max_thinking_tokens`)a.request.max_thinking_tokens===null?_.thinkingConfig=void 0:a.request.max_thinking_tokens===0?_.thinkingConfig={type:`disabled`}:_.thinkingConfig={type:`enabled`,budgetTokens:a.request.max_thinking_tokens},D(a);else if(a.request.subtype===`mcp_status`)D(a,{mcpServers:Pe()});else if(a.request.subtype===`get_context_usage`)try{let e=f(),t=await Fa({messages:S,getAppState:f,options:{mainLoopModel:ki(),tools:Se(e),agentDefinitions:e.agentDefinitions,customSystemPrompt:_.systemPrompt,appendSystemPrompt:_.appendSystemPrompt}});D(a,{...t})}catch(e){O(a,W(e))}else if(a.request.subtype===`mcp_message`){let e=a.request,t=C.find(t=>t.name===e.server_name);t&&t.type===`connected`&&t.client?.transport?.onmessage&&t.client.transport.onmessage(e.message),D(a)}else if(a.request.subtype===`rewind_files`){let e=f(),t=await Xl(a.request.user_message_id,e,m,a.request.dry_run??!1);t.canRewind||a.request.dry_run?D(a,t):O(a,t.error??`Unexpected error`)}else if(a.request.subtype===`cancel_async_message`){let e=a.request.message_uuid,t=mn(t=>t.uuid===e);D(a,{cancelled:t.length>0})}else if(a.request.subtype===`seed_read_state`){try{let e=Kr(a.request.path),t=Math.floor((await Za(e)).mtimeMs);if(t<=a.request.mtime){let n=await Xa(e,`utf-8`),r=(n.charCodeAt(0)===65279?n.slice(1):n).replaceAll(`\r
23
+ `,`
24
+ `);se.set(e,{content:r,timestamp:t,offset:void 0,limit:void 0})}}catch{}D(a)}else if(a.request.subtype===`mcp_set_servers`){let{response:e,sdkServersChanged:t}=await Ne(a.request.servers);D(a,e),t&&ye()}else if(a.request.subtype===`reload_plugins`)try{let e=await Ua(m),t=Ke.filter(e=>e.source===`flagSettings`);Ke=[...e.agentDefinitions.allAgents,...t];let n=[],[r,i,o]=await Promise.allSettled([me(eo()),Je(),gn()]);r.status===`fulfilled`?Ue=r.value:q(r.reason),i.status===`rejected`&&q(i.reason),o.status===`fulfilled`?n=o.value.enabled.map(e=>({name:e.name,path:e.path,source:e.source})):q(o.reason),D(a,{commands:Ue.filter(e=>e.userInvocable!==!1).map(e=>({name:be(e),description:ze(e),argumentHint:e.argumentHint||``})),agents:Ke.map(e=>({name:e.agentType,description:e.whenToUse,model:e.model===`inherit`?void 0:e.model})),plugins:n,mcpServers:Pe(),error_count:e.error_count})}catch(e){O(a,W(e))}else if(a.request.subtype===`mcp_reconnect`){let e=f(),{serverName:t}=a.request;ge.delete(t);let r=xn(t)??n.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(!r)O(a,`Server not found: ${t}`);else{let e=await Ce(t,r),n=Gr(t);if(m(r=>({...r,mcp:{...r.mcp,clients:r.mcp.clients.map(n=>n.name===t?e.client:n),tools:[...E(r.mcp.tools,e=>e.name?.startsWith(n)),...e.tools],commands:[...E(r.mcp.commands,e=>nt(e,t)),...e.commands],resources:e.resources&&e.resources.length>0?{...r.mcp.resources,[t]:e.resources}:na(r.mcp.resources,t)}})),w={...w,clients:[...w.clients.filter(e=>e.name!==t),e.client],tools:[...w.tools.filter(e=>!e.name?.startsWith(n)),...e.tools]},e.client.type===`connected`)ve([e.client]),D(a);else{let t=e.client.type===`failed`?e.client.error??`Connection failed`:`Server status: ${e.client.type}`;O(a,t)}}}else if(a.request.subtype===`mcp_toggle`){let e=f(),{serverName:t,enabled:r}=a.request;ge.delete(t);let i=xn(t)??n.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(!i)O(a,`Server not found: ${t}`);else if(r){dn(t,!0);let e=await Ce(t,i),n=Gr(t);if(m(r=>({...r,mcp:{...r.mcp,clients:r.mcp.clients.map(n=>n.name===t?e.client:n),tools:[...E(r.mcp.tools,e=>e.name?.startsWith(n)),...e.tools],commands:[...E(r.mcp.commands,e=>nt(e,t)),...e.commands],resources:e.resources&&e.resources.length>0?{...r.mcp.resources,[t]:e.resources}:na(r.mcp.resources,t)}})),e.client.type===`connected`)ve([e.client]),D(a);else{let t=e.client.type===`failed`?e.client.error??`Connection failed`:`Server status: ${e.client.type}`;O(a,t)}}else{dn(t,!1);let r=[...n,...C,...w.clients,...e.mcp.clients].find(e=>e.name===t);r&&r.type===`connected`&&await rr(t,i);let o=Gr(t);m(e=>({...e,mcp:{...e.mcp,clients:e.mcp.clients.map(e=>e.name===t?{name:t,type:`disabled`,config:i}:e),tools:E(e.mcp.tools,e=>e.name?.startsWith(o)),commands:E(e.mcp.commands,e=>nt(e,t)),resources:na(e.mcp.resources,t)}})),D(a)}}else if(o.subtype===`mcp_authenticate`){let e=o.serverName,t=f(),r=xn(e)??n.find(t=>t.name===e)?.config??t.mcp.clients.find(t=>t.name===e)?.config??null;if(!r)O(a,`Server not found: ${e}`);else if(r.type!==`sse`&&r.type!==`http`)O(a,`Server type "${r.type}" does not support OAuth authentication`);else try{rt.get(e)?.abort();let t=new AbortController;rt.set(e,t);let n,i=new Promise(e=>{n=e}),o=zn(e,r,e=>n(e),t.signal,{skipBrowserOpen:!0,onWaitingForCallback:t=>{it.set(e,t)}}),s=await Promise.race([i,o.then(()=>null)]);s?D(a,{authUrl:s,requiresUserAction:!0}):D(a,{requiresUserAction:!1}),st.set(e,o),o.then(async()=>{if(Ye(e)||at.has(e))return;let t=await Ce(e,r),n=Gr(e);m(r=>({...r,mcp:{...r.mcp,clients:r.mcp.clients.map(n=>n.name===e?t.client:n),tools:[...E(r.mcp.tools,e=>e.name?.startsWith(n)),...t.tools],commands:[...E(r.mcp.commands,t=>nt(t,e)),...t.commands],resources:t.resources&&t.resources.length>0?{...r.mcp.resources,[e]:t.resources}:na(r.mcp.resources,e)}})),w={...w,clients:[...w.clients.filter(t=>t.name!==e),t.client],tools:[...w.tools.filter(e=>!e.name?.startsWith(n)),...t.tools]}}).catch(t=>{G(`MCP OAuth failed for ${e}: ${t}`,{level:`error`})}).finally(()=>{rt.get(e)===t&&(rt.delete(e),it.delete(e),at.delete(e),st.delete(e))})}catch(e){O(a,W(e))}}else if(o.subtype===`mcp_oauth_callback_url`){let e=o.serverName,t=o.callbackUrl,n=it.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)O(a,`Invalid callback URL: missing authorization code. Please paste the full redirect URL including the code parameter.`);else{at.add(e),n(t);let r=st.get(e);if(r)try{await r,D(a)}catch(e){O(a,e instanceof Error?e.message:`OAuth authentication failed`)}else D(a)}}else O(a,`No active OAuth flow for server: ${e}`)}else if(o.subtype===`claude_authenticate`){let e=o.loginWithClaudeAi;ct?.service.cleanup(),J(`tengu_oauth_flow_start`,{loginWithClaudeAi:e??!0});let t=new Ca,n,r=new Promise(e=>{n=e}),i=t.startOAuthFlow(async(e,t)=>{n({manualUrl:e,automaticUrl:t})},{loginWithClaudeAi:e??!0,skipBrowserOpen:!0}).then(async t=>{await wa(t),J(`tengu_oauth_success`,{loginWithClaudeAi:e??!0})}).finally(()=>{t.cleanup(),ct?.service===t&&(ct=null)});ct={service:t,flow:i},i.catch(e=>G(`claude_authenticate flow ended: ${e}`,{level:`info`}));try{let{manualUrl:e,automaticUrl:t}=await Promise.race([r,i.then(()=>{throw Error(`OAuth flow completed without producing auth URLs`)})]);D(a,{manualUrl:e,automaticUrl:t})}catch(e){O(a,W(e))}}else if(o.subtype===`claude_oauth_callback`||o.subtype===`claude_oauth_wait_for_completion`)if(!ct)O(a,`No active claude_authenticate flow`);else{o.subtype===`claude_oauth_callback`&&ct.service.handleManualAuthCodeInput({authorizationCode:o.authorizationCode,state:o.state});let{flow:e}=ct;e.then(()=>{let e=vi();D(a,{account:{email:e?.email,organization:e?.organization,subscriptionType:e?.subscription,tokenSource:e?.tokenSource,apiKeySource:e?.apiKeySource,apiProvider:_i()}})},e=>O(a,W(e)))}else if(o.subtype===`mcp_clear_auth`){let e=o.serverName,t=f(),r=xn(e)??n.find(t=>t.name===e)?.config??t.mcp.clients.find(t=>t.name===e)?.config??null;if(!r)O(a,`Server not found: ${e}`);else if(r.type!==`sse`&&r.type!==`http`)O(a,`Cannot clear auth for server type "${r.type}"`);else{await Jt(e,r);let t=await Ce(e,r),n=Gr(e);m(r=>({...r,mcp:{...r.mcp,clients:r.mcp.clients.map(n=>n.name===e?t.client:n),tools:[...E(r.mcp.tools,e=>e.name?.startsWith(n)),...t.tools],commands:[...E(r.mcp.commands,t=>nt(t,e)),...t.commands],resources:t.resources&&t.resources.length>0?{...r.mcp.resources,[e]:t.resources}:na(r.mcp.resources,e)}})),D(a,{})}}else if(a.request.subtype===`apply_flag_settings`){let e=ki(),t=pr()??{},n=a.request.settings,r={...t,...n};for(let e of Object.keys(r))r[e]===null&&delete r[e];yr(r),Be.notifyChange(`flagSettings`),`model`in n&&(n.model==null?mr(void 0):mr(String(n.model)));let i=ki();if(i!==e){ue=i;let e=n.model?String(n.model):`default`;Gi({model:i}),fe(e,i)}D(a)}else if(a.request.subtype===`get_settings`){let e=ki();D(a,{...Br(),applied:{model:e}})}else if(a.request.subtype===`stop_task`){let{task_id:e}=a.request;try{await p(e,{getAppState:f,setAppState:m}),D(a,{})}catch(e){O(a,W(e))}}else if(o.subtype===`generate_session_title`){let e=o.description,t=o.persist,n=(y&&!y.signal.aborted?y:Wt()).signal;(async()=>{try{let r=await ua(e,n);if(r&&t)try{Rt(H(),r)}catch(e){q(e)}D(a,{title:r})}catch(e){O(a,W(e))}})()}else if(o.subtype===`side_question`){let e=o.question;(async()=>{try{let t=zt(),n=t?{...t,toolUseContext:{...t.toolUseContext,abortController:Wt()}}:await ja({tools:Se(f()),commands:Ue,mcpClients:[...f().mcp.clients,...C,...w.clients],messages:S,readFileState:oe,getAppState:f,setAppState:m,customSystemPrompt:_.systemPrompt,appendSystemPrompt:_.appendSystemPrompt,thinkingConfig:_.thinkingConfig,agents:Ke}),r=await Pa({question:e,cacheSafeParams:n});D(a,{response:r.response})}catch(e){O(a,W(e))}})()}else if(a.request.subtype===`set_proactive`)a.request.enabled?$.isProactiveActive()||($.activateProactive(`command`),Qe()):$.deactivateProactive(),D(a);else if(o.subtype===`remote_control`)if(o.enabled)if(T)D(a,{session_url:de(T.bridgeSessionId,T.sessionIngressUrl),connect_url:Ma(T.environmentId,T.sessionIngressUrl),environment_id:T.environmentId});else{let t;try{let{initReplBridge:n}=await import(`./initReplBridge-DL4klK0C.js`),r=await n({onInboundMessage(e){let t=_l(e);if(!t)return;let{content:n,uuid:r}=t;Mn({value:n,mode:`prompt`,uuid:r,skipSlashCommands:!0}),$e()},onPermissionResponse(t){e.injectControlResponse(t)},onInterrupt(){y?.abort()},onSetModel(e){let t=e==="default"?Ci():e;ue=t,mr(t)},onSetMaxThinkingTokens(e){e===null?_.thinkingConfig=void 0:e===0?_.thinkingConfig={type:`disabled`}:_.thinkingConfig={type:`enabled`,budgetTokens:e}},onStateChange(e,n){e===`failed`&&(t=n),G(`[bridge:sdk] State change: ${e}${n?` — ${n}`:``}`),b.enqueue({type:`system`,subtype:`bridge_state`,state:e,detail:n,uuid:Y(),session_id:H()})},initialMessages:S.length>0?S:void 0});r?(T=r,Ee=S.length,e.setOnControlRequestSent(e=>{r.sendControlRequest(e)}),e.setOnControlRequestResolved(e=>{r.sendControlCancelRequest(e)}),D(a,{session_url:de(r.bridgeSessionId,r.sessionIngressUrl),connect_url:Ma(r.environmentId,r.sessionIngressUrl),environment_id:r.environmentId})):O(a,t??`Remote Control initialization failed`)}catch(e){O(a,W(e))}}else T&&(e.setOnControlRequestSent(void 0),e.setOnControlRequestResolved(void 0),await T.teardown(),T=null),D(a);else O(a,`Unsupported control request subtype: ${a.request.subtype}`);continue}else if(r.type===`control_response`){_.replayUserMessages&&b.enqueue(r);continue}else if(r.type===`keep_alive`)continue;else if(r.type===`update_environment_variables`)continue;else if(r.type===`assistant`||r.type===`system`){let e=sa([r]);S.push(...e),r.type===`assistant`&&_.replayUserMessages&&b.enqueue(r);continue}if(r.type!==`user`)continue;let o=r;if(t=!0,o.uuid){let e=H(),t=await St(e,o.uuid);if(t||zl.has(o.uuid)){G(`Skipping duplicate user message: ${o.uuid}`),_.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&&Ze(o.uuid,`completed`);continue}Vl(o.uuid)}Mn({mode:`prompt`,value:await Al(o,o.message.content),uuid:o.uuid,priority:o.priority}),m(e=>({...e,attribution:Re(e.attribution,e=>{je(e).catch(e=>{G(`Attribution: Failed to save snapshot: ${e}`)})})})),$e()}ne=!0,v||(x.inflightPromise&&await Promise.race([x.inflightPromise,Ai(5e3)]),x.abortController?.abort(),x.abortController=null,await We(),Xe(),ie?.(),yt.delete(ae),b.done())})(),b}function ql(e){let t=async(n,r,i,a,o,s)=>{let c=s??await rt(n,r,i,a,o);if(c.behavior===`allow`||c.behavior===`deny`)return c;let{signal:l,cleanup:u}=Qe(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,h=e.mapToolResultToToolResultBlockParam(m.data,`1`);if(!h.content||!Array.isArray(h.content)||!h.content[0]||h.content[0].type!==`text`||typeof h.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 Qc(Zc().parse(si(h.content[0].text)),e,r,i)};return t}function Jl(e,t,n,r){if(e===`stdio`)return t.createCanUseTool(r);if(!e)return async(e,t,n,r,i,a)=>a??await rt(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=>zi(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`),k(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`),k(1),Error(t)}i=ql(r)}return i(t,r,a,o,s,c)}}async function Yl(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=Gt(e.agents,`flagSettings`);l.push(...t)}if(c.agent){let e=vr()===c.agent,t=l.find(e=>e.agentType===c.agent);if(t&&!e){if(hr(t.agentType),!c.systemPrompt&&!En(t)){let e=t.getSystemPrompt();e&&(c.systemPrompt=e)}!c.userSpecifiedModel&&t.model&&t.model!==`inherit`&&mr(ui(t.model)),t.initialPrompt&&o.prependUserMessage(t.initialPrompt)}else t?.initialPrompt&&o.prependUserMessage(t.initialPrompt)}let d=Hr()?.outputStyle||`default`,f=await nn(wr()),p=vi();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}});dr(t)}e.jsonSchema&&Sr(e.jsonSchema);let m={commands:i.filter(e=>e.userInvocable!==!1).map(e=>({name:be(e),description:ze(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:p?.email,organization:p?.organization,subscriptionType:p?.subscription,tokenSource:p?.tokenSource,apiKeySource:p?.apiKeySource,apiProvider:_i()},pid:process.pid};if(Ei()&&Oi()){let e=u();m.fast_mode_state=pi(c.userSpecifiedModel??null,e.fastMode)}if(r.enqueue({type:`control_response`,response:{subtype:`success`,request_id:t,response:m}}),s){let e=gi.getInstance().getStatus();e&&r.enqueue({type:`auth_status`,isAuthenticating:e.isAuthenticating,output:e.output,error:e.error,uuid:Y(),session_id:H()})}}async function Xl(e,t,n,r){if(!Gn())return{canRewind:!1,error:`File rewinding is not enabled.`,filesChanged:[]};if(!re(t.fileHistory,e))return{canRewind:!1,error:`No file checkpoint found for this message.`,filesChanged:[]};if(r){let n=await O(t.fileHistory,e);return{canRewind:!0,filesChanged:n?.filesChanged??[],insertions:n?.insertions,deletions:n?.deletions}}try{await an(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 Zl(e,t,n,r){if(e.mode===`bypassPermissions`){if(ae())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`&&!ue()){let e=Yn();return r.enqueue({type:`control_response`,response:{subtype:`error`,request_id:t,error:e?`Cannot set permission mode to auto: ${Mt(e)}`:`Cannot set permission mode to auto`}}),n}return r.enqueue({type:`control_response`,response:{subtype:`success`,request_id:t,response:{mode:e.mode}}}),{...Ie(n.mode,e.mode,n),mode:e.mode}}function Ql(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:H(),total_cost_usd:0,usage:Qi,modelUsage:{},permission_denials:[],uuid:Y(),errors:[e]};process.stdout.write(U(t)+`
25
+ `)}else process.stderr.write(e+`
26
+ `)}function $l(e,t){let n=e.findIndex(e=>e.uuid===t.uuid);n!==-1&&e.splice(n,2)}async function eu(e,t){let n=!fr();if(t.continue)try{J(`tengu_continue_print`,{});let r=await Jn(void 0,void 0);if(r)return t.forkSession||r.sessionId&&(br(Ae(r.sessionId),r.fullPath?Ka(r.fullPath):null),n&&await en()),Ba(r,e),kt(t.forkSession?{...r,worktreeSession:void 0}:r),{messages:r.messages,turnInterruptionState:r.turnInterruptionState,agentSetting:r.agentSetting}}catch(e){return q(e),k(1),{messages:[]}}if(t.teleport)try{if(!on(`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-Bs3kEipi.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),k(1),{messages:[]}}if(t.resume)try{J(`tengu_resume_print`,{});let i=jl(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`),Ql(e,t.outputFormat),k(1),{messages:[]}}if(r(process.env.CLAUDE_CODE_USE_CCR_V2)){let[,n]=await Promise.all([Qn(i.sessionId),t.restoredWorkerState]);n&&(e(Ea(n)),typeof n.model==`string`&&mr(n.model))}else i.isUrl&&i.ingressUrl&&r(process.env.ENABLE_SESSION_PERSISTENCE)&&await $e(i.sessionId,i.ingressUrl);let a=await Jn(i.sessionId,i.jsonlFile||void 0);if(!a||a.messages.length===0)return i.isUrl||r(process.env.CLAUDE_CODE_USE_CCR_V2)?{messages:await(t.sessionStartHooksPromise??D(`startup`))}:(Ql(`No conversation found with session ID: ${i.sessionId}`,t.outputFormat),k(1),{messages:[]});if(t.resumeSessionAt){let e=a.messages.findIndex(e=>e.uuid===t.resumeSessionAt);if(e<0)return Ql(`No message found with message.uuid of: ${t.resumeSessionAt}`,t.outputFormat),k(1),{messages:[]};a.messages=e>=0?a.messages.slice(0,e+1):[]}return!t.forkSession&&a.sessionId&&(br(Ae(a.sessionId),a.fullPath?Ka(a.fullPath):null),n&&await en()),Ba(a,e),kt(t.forkSession?{...a,worktreeSession:void 0}:a),{messages:a.messages,turnInterruptionState:a.turnInterruptionState,agentSetting:a.agentSetting}}catch(e){return q(e),Ql(e instanceof Error?`Failed to resume session: ${e.message}`:`Failed to resume session with --print mode`,t.outputFormat),k(1),{messages:[]}}return{messages:await(t.sessionStartHooksPromise??D(`startup`))}}function tu(e,t){let n;return n=typeof e==`string`?e.trim()===``?w([]):w([U({type:`user`,content:e,uuid:``,session_id:``,message:{role:`user`,content:e},parent_tool_use_id:null})]):e,t.sdkUrl?new ul(t.sdkUrl,n,t.replayUserMessages):new ol(n,t.replayUserMessages)}async function nu({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 Fn(t);return a?(r.add(t),G(`handleOrphanedPermissionResponse: enqueuing orphaned permission for toolUseID=${t} messageID=${a.message.id}`),Mn({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 ru(e){return{...e,scope:`dynamic`}}async function iu(e,t,n,r){let{allowed:i,blocked:a}=ye(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},m=[...t.clients],h=[...t.tools];for(let e of l)if(!u.has(e)){let t=m.find(t=>t.name===e);t&&t.type===`connected`&&await t.cleanup(),m=m.filter(t=>t.name!==e);let n=`mcp__${e}__`;h=h.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`}};m=[...m,n],d.push(e)}let g=await au(c,n,r);return{response:{added:[...d,...g.response.added],removed:[...f,...g.response.removed],errors:{...o,...g.response.errors}},newSdkState:{configs:p,clients:m,tools:h},newDynamicState:g.newState,sdkServersChanged:d.length>0||f.length>0}}async function au(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||!Ne(r,ru(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 rr(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=ru(n);if(n.type===`sdk`){l.push(t);continue}try{let e=await _(t,r);if(d.push(e),e.type===`connected`){let t=await it(e);f.push(...t)}else e.type===`failed`&&(u[t]=e.error||`Connection failed`);l.push(t)}catch(e){let n=Or(e);u[t]=n.message,q(n)}}let p={};for(let t of i){let n=e[t];n&&(p[t]=ru(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{Gl as runHeadless};
@@ -0,0 +1 @@
1
+ import{a as e}from"./rolldown-runtime-DaDcL9Zw.js";import{$m as t,Ba as n,HC as r,Jg as i,Qm as a,Ta as o,UC as s,Xa as c,Yg as l,Zm as u,_p as d,eh as f,il as p,rl as m,vp as h,wa as g,xa as _}from"./loadAgentsDir-BXtV2jiO.js";import{I as v,fi as y,t as b}from"./src-P_wYS_NJ2.js";import{t as x}from"./jsx-runtime-Bb4Xn-E0.js";import{A as S,P as C,R as w}from"./debug-Dr1SjdXn.js";import{g as T,n as E}from"./settings-DiBMs2gM.js";import{n as D,r as O}from"./analytics-DJobLaWP.js";import{bt as k,xt as A}from"./prompt-CRc2QEZ5.js";import{randomUUID as j}from"crypto";y(),b(),a(),h(),f();var M=x();function N({input:e,progress:n,verbose:r}){return(0,M.jsxs)(v,{flexDirection:`column`,marginTop:1,children:[(0,M.jsx)(d,{addMargin:!1,param:{text:`<bash-input>${e}</bash-input>`,type:`text`}}),n?(0,M.jsx)(t,{fullOutput:n.fullOutput,output:n.output,elapsedTimeSeconds:n.elapsedTimeSeconds,totalLines:n.totalLines,verbose:r}):u.renderToolUseProgressMessage?.([],{verbose:r,tools:[],terminalSize:void 0})]})}w(),D(),r(),n(),T();function P(){return E().defaultShell??`bash`}a(),k(),l();async function F(t,n,r,a,l){let d=A()&&P()===`powershell`;O(`tengu_input_bash`,{powershell:d});let f=o({content:c({inputString:`<bash-input>${t}</bash-input>`,precedingInputBlocks:n})}),h;l({jsx:(0,M.jsx)(N,{input:t,progress:null,verbose:a.options.verbose}),shouldHidePromptInput:!1});try{let n={...a,setToolJSX:e=>{h=e?.jsx}},c=e=>{l({jsx:(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(N,{input:t,progress:e.data,verbose:a.options.verbose}),h]}),shouldHidePromptInput:!1,showSpinner:!1})},g=null;d&&(g=(p(),e(m)).PowerShellTool);let v=g??u,y=(g?await g.call({command:t,dangerouslyDisableSandbox:!0},n,void 0,void 0,c):await u.call({command:t,dangerouslyDisableSandbox:!0},n,void 0,void 0,c)).data;if(!y)throw Error(`No result received from shell command`);let b=y.stderr,x=await s(v,{...y,stderr:``},j()),S=typeof x.content==`string`?x.content:i(y.stdout);return{messages:[_(),f,...r,o({content:`<bash-stdout>${S}</bash-stdout><bash-stderr>${i(b)}</bash-stderr>`})],shouldQuery:!1}}catch(e){return e instanceof S?e.interrupted?{messages:[_(),f,g({toolUse:!1}),...r],shouldQuery:!1}:{messages:[_(),f,...r,o({content:`<bash-stdout>${i(e.stdout)}</bash-stdout><bash-stderr>${i(e.stderr)}</bash-stderr>`})],shouldQuery:!1}:{messages:[_(),f,...r,o({content:`<bash-stderr>Command failed: ${i(C(e))}</bash-stderr>`})],shouldQuery:!1}}finally{l(null)}}export{F as processBashCommand};
@@ -0,0 +1,5 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{$h as t,Am as n,As as r,Ba as i,Bi as a,C as o,Ds as s,Ef as c,Fp as l,Fv as u,Ga as d,Hi as f,Ip as p,Ja as m,Jw as h,Lp as g,Mf as _,Mi as v,Nf as y,Np as b,Oi as x,Os as S,Pi as C,Pp as w,Rv as T,Sa as E,Ta as D,Tf as O,U as k,Uc as A,Va as ee,W as te,Wc as ne,Xa as j,Xw as M,Yw as N,aT as re,aw as ie,b_ as ae,cy as oe,eg as se,ex as ce,fc as le,fv as ue,jm as de,k as fe,ka as pe,kf as me,km as he,my as ge,nm as _e,oT as P,ow as F,pc as I,rm as ve,sw as ye,sy as be,tx as xe,uc as L,uv as Se,v_ as Ce,va as R,wa as we,wf as Te,xa as z,zi as Ee}from"./loadAgentsDir-BXtV2jiO.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-Dr1SjdXn.js";import{Dt as Fe,Ot as Ie}from"./settings-DiBMs2gM.js";import{T as U,o as Le,q as Re,s as W,w as G}from"./log-27kCA_9u.js";import{n as ze,r as K}from"./analytics-DJobLaWP.js";import{_n as Be,ni as Ve,ri as He,vn as Ue}from"./model-CDnVaVDR.js";import{ct as We,ot as Ge}from"./esm-BkOWaWVb.js";import{E as Ke,T as qe,w as Je}from"./sessionTracing-DpHGGIZm.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}'`),g(e,t,o,s)}:void 0;l(e,t,o,n.matcher||``,s,c,i),a++}}a>0&&B(`Registered ${a} hooks from skill '${r}'`)}var Xe=e((()=>{Fe(),V(),p()}));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+=` (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,a,o,s){let l=_e(),d=e.pluginInfo?M(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,...d&&{_PROTO_marketplace_name:d},...c(e.pluginInfo)}});let{skillContent:p,modifiedGetAppState:h,baseAgent:g,promptMessages:_}=await I(e,t,r);B(`Executing forked slash command /${e.name} with agent ${g.agentType}`);let v=r.options.allowBackgroundForkedSlashCommands===!0;if(v&&J(),v){let t=ce(),i=f(e),a=Ve(),c=e=>oe({value:e,mode:`prompt`,priority:`later`,isMeta:!0,skipSlashCommands:!0,workload:a}),u=async()=>{if(!s?.runId)return;let e=await he({runId:s.runId,rootDir:s.rootDir,priority:`later`,workload:a});for(let t of e)be(t)},d=async e=>{s?.runId&&await n({runId:s.runId,rootDir:s.rootDir,error:e instanceof Error?e.message:String(e)})};return(async()=>{let n=Date.now()+$;for(;Date.now()<n&&r.getAppState().mcp.clients.some(e=>e.type===`pending`);)await Ue(Q);let a=r.options.refreshTools?.()??r.options.tools,s=[];for await(let n of w({agentDefinition:g,promptMessages:_,toolUseContext:{...r,getAppState:h,abortController:t},canUseTool:o,isAsync:!0,querySource:`agent:custom`,model:e.model,availableTools:a,override:{agentId:l}}))s.push(n);let d=L(s,`Command completed`);B(`Background forked command /${i} completed (agent ${l})`),c(`<scheduled-task-result command="/${i}">\n${d}\n</scheduled-task-result>`);try{await u()}catch(e){W(e)}})().catch(async e=>{W(e),c(`<scheduled-task-result command="/${i}" status="failed">\n${e instanceof Error?e.message:String(e)}\n</scheduled-task-result>`),await d(e)}),{messages:[],shouldQuery:!1,command:e,deferAutonomyCompletion:!!s?.runId}}let b=[],x=[],S=`forked-command-${e.name}`,C=0,T=e=>(C++,{type:`progress`,data:{message:e,type:`agent_progress`,prompt:p,agentId:l},parentToolUseID:S,toolUseID:`${S}-${C}`,timestamp:new Date().toISOString(),uuid:q()}),E=()=>{a({jsx:y(x,{tools:r.options.tools,verbose:!1}),shouldHidePromptInput:!1,shouldContinueAnimation:!0,showSpinner:!0})};E();try{for await(let t of w({agentDefinition:g,promptMessages:_,toolUseContext:{...r,getAppState:h},canUseTool:o,isAsync:!1,querySource:`agent:custom`,model:e.model,availableTools:r.options.tools})){b.push(t);let e=m([t]);if(t.type===`assistant`){let n=u(t);n>0&&r.setResponseLength(e=>e+n);let i=e[0];i&&i.type===`assistant`&&(x.push(T(t)),E())}if(t.type===`user`){let t=e[0];t&&t.type===`user`&&(x.push(T(t)),E())}}}finally{a(null)}let O=L(b,`Command completed`);return B(`Forked slash command /${e.name} completed with agent ${l}`),{messages:[D({content:j({inputString:`/${f(e)} ${t}`.trim(),precedingInputBlocks:i})}),D({content:`<local-command-stdout>\n${O}\n</local-command-stdout>`})],shouldQuery:!1,command:e,resultText:O}}function tt(e){return!/[^a-zA-Z0-9:\-_]/.test(e)}async function nt(e,t,n,r,i,a,o,s,l,u){let f=Ze(e);if(!f){K(`tengu_input_slash_missing`,{});let e="Commands are in the form `/command [args]`";return{messages:[z(),...r,D({content:j({inputString:e,precedingInputBlocks:t})})],shouldQuery:!1,resultText:e}}let{commandName:p,args:m,isMcp:h}=f,g=h?`mcp`:x().has(p)?p:`custom`;if(!Ee(p,i.options.commands)){let n=!1;try{await Pe().stat(`/${p}`),n=!0}catch{}if(tt(p)&&!n){K(`tengu_input_slash_invalid`,{input:p});let e=`Unknown skill: ${p}`;return{messages:[z(),...r,D({content:j({inputString:e,precedingInputBlocks:t})}),...m?[E(`Args from unknown skill: ${m}`,`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:[D({content:j({inputString:e,precedingInputBlocks:t}),uuid:o}),...r],shouldQuery:!0}}let{messages:_,shouldQuery:v,allowedTools:y,model:b,command:S,resultText:C,nextInput:w,submitNextInput:T,deferAutonomyCompletion:O}=await rt(p,m,a,i,t,n,s,l,o,u);if(_.length===0){let e={input:g};if(S.type===`prompt`&&S.pluginInfo){let{pluginManifest:t,repository:n}=S.pluginInfo,{marketplace:r}=M(n),i=N(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,c(S.pluginInfo))}return K(`tengu_input_command`,{...e,invocation_trigger:`user-slash`}),{messages:[],shouldQuery:!1,model:b,nextInput:w,submitNextInput:T,deferAutonomyCompletion:O}}if(_.length===2&&_[1].type===`user`&&typeof _[1].message.content==`string`&&_[1].message.content.startsWith(`Unknown command:`))return e.startsWith(`/var`)||e.startsWith(`/tmp`)||e.startsWith(`/private`)||K(`tengu_input_slash_invalid`,{input:p}),{messages:[z(),..._],shouldQuery:v,allowedTools:y,model:b};let k={input:g};if(S.type===`prompt`&&S.pluginInfo){let{pluginManifest:e,repository:t}=S.pluginInfo,{marketplace:n}=M(t),r=N(n);k._PROTO_plugin_name=e.name,n&&(k._PROTO_marketplace_name=n),k.plugin_repository=r?t:`third-party`,k.plugin_name=r?e.name:`third-party`,r&&e.version&&(k.plugin_version=e.version),Object.assign(k,c(S.pluginInfo))}K(`tengu_input_command`,{...k,invocation_trigger:`user-slash`});let A=_.length>0&&_[0]&&ee(_[0]);return{messages:v||_.every(d)||A?_:[z(),..._],shouldQuery:v,allowedTools:y,model:b,resultText:C,nextInput:w,submitNextInput:T,deferAutonomyCompletion:O}}async function rt(e,t,n,r,i,a,o,s,c,l){let u=C(e,r.options.commands);if(u.type===`prompt`&&u.userInvocable!==!1&&O(e),u.userInvocable===!1)return{messages:[D({content:j({inputString:`/${e}`,precedingInputBlocks:i})}),D({content:`This skill can only be invoked by Claude, not directly by users. Ask Claude to use the "${e}" skill for you.`})],shouldQuery:!1,command:u};try{switch(u.type){case`local-jsx`:return new Promise(e=>{let a=!1,o=(n,r)=>{if(a=!0,r?.display===`skip`){e({messages:[],shouldQuery:!1,command:u,nextInput:r?.nextInput,submitNextInput:r?.submitNextInput});return}let o=(r?.metaMessages??[]).map(e=>D({content:e,isMeta:!0})),s=se()&&typeof n==`string`&&n.endsWith(` dismissed`),c=r?.displayArgs??t;e({messages:r?.display===`system`?s?o:[R(Y(u,c)),R(`<local-command-stdout>${n}</local-command-stdout>`),...o]:[D({content:j({inputString:Y(u,c),precedingInputBlocks:i})}),D(n?{content:`<local-command-stdout>${n}</local-command-stdout>`}:{content:`<local-command-stdout>${re}</local-command-stdout>`}),...o],shouldQuery:r?.shouldQuery??!1,command:u,nextInput:r?.nextInput,submitNextInput:r?.submitNextInput})};u.load().then(e=>e.call(o,{...r,canUseTool:s},t)).then(t=>{if(t!=null){if(r.options.isNonInteractiveSession){e({messages:[],shouldQuery:!1,command:u});return}a||n({jsx:t,shouldHidePromptInput:!0,showSpinner:!1,isLocalJSXCommand:!0,isImmediate:u.immediate===!0})}}).catch(t=>{W(t),!a&&(a=!0,n({jsx:null,shouldHidePromptInput:!1,clearLocalJSX:!0}),e({messages:[],shouldQuery:!1,command:u}))})});case`local`:{let e=D({content:j({inputString:Y(u,u.isSensitive&&t.trim()?`***`:t),precedingInputBlocks:i})});try{let n=z(),i=await(await u.load()).call(t,r);if(i.type===`skip`)return{messages:[],shouldQuery:!1,command:u};if(i.type===`compact`){let t=[n,e,...i.displayText?[D({content:`<local-command-stdout>${i.displayText}</local-command-stdout>`,timestamp:new Date(Date.now()+100).toISOString()})]:[]],r={...i.compactionResult,messagesToKeep:[...i.compactionResult.messagesToKeep??[],...t]};return ue(),{messages:Ce(r),shouldQuery:!1,command:u}}return{messages:[e,R(`<local-command-stdout>${i.value}</local-command-stdout>`)],shouldQuery:!1,command:u,resultText:i.value}}catch(t){return W(t),{messages:[e,R(`<local-command-stderr>${String(t)}</local-command-stderr>`)],shouldQuery:!1,command:u}}}case`prompt`:try{return u.context===`fork`?await et(u,t,r,i,n,s??k,l):await Z(u,t,r,i,a,c)}catch(e){return e instanceof je?{messages:[D({content:j({inputString:Y(u,t),precedingInputBlocks:i})}),we({toolUse:!1})],shouldQuery:!1,command:u}:{messages:[D({content:j({inputString:Y(u,t),precedingInputBlocks:i})}),D({content:`<local-command-stderr>${String(e)}</local-command-stderr>`})],shouldQuery:!1,command:u}}}}catch(e){if(e instanceof H)return{messages:[D({content:j({inputString:e.message,precedingInputBlocks:i})})],shouldQuery:!1,command:u};throw e}}function Y(e,t){return pe(f(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=v(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),c=!F(`hooks`)||ye(e.source);if(e.hooks&&c){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),f=fe(e.allowedTools??[]),p=i.length>0||r.length>0?[...i,...r,...o]:o,m=await ne(S(o.filter(e=>e.type===`text`).map(e=>e.text).join(` `),n,null,[],n.messages,`repl_main_thread`,{skipSkillDiscovery:!0}));return{messages:[D({content:d,uuid:a}),D({content:p,isMeta:!0}),...m,s({type:`command_permissions`,allowedTools:f,model:e.model})],shouldQuery:!0,allowedTools:f,model:e.model,command:e}}var Q,$;e((()=>{Oe(),a(),P(),Re(),ze(),ae(),Se(),b(),_(),xe(),We(),r(),V(),Me(),le(),Ne(),t(),A(),Xe(),Le(),ge(),i(),o(),te(),h(),ie(),Qe(),Be(),Te(),Je(),me(),T(),ve(),de(),He(),Q=200,$=1e4}))();export{X as formatSkillLoadingMetadata,ot as processPromptSlashCommand,nt as processSlashCommand};
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,o as n}from"./envUtils-BDhHQY0-.js";import{basename as r,join as i,resolve as a}from"path";import{existsSync as o,mkdirSync as s,readFileSync as c,realpathSync as l,writeFileSync as u}from"fs";import{createHash as d}from"crypto";import{execFileSync as f}from"child_process";function p(){return i(t(),`skill-learning`)}function m(){return i(p(),`projects.json`)}function h(e){return e===j?i(p(),`global`):i(p(),`projects`,e)}function g(e){return i(h(e),`project.json`)}function _(e,t){if(F.has(e)&&F.delete(e),F.set(e,t),F.size>N){let e=F.size-P,t=F.keys();for(let n=0;n<e;n++){let e=t.next();if(e.done)break;F.delete(e.value)}}}function v(e=process.cwd()){let t=F.get(e);if(t){F.delete(e),F.set(e,t);let n=Date.now();return n-L>I&&(L=n,S(t)),t}let n=b(e);return _(e,n),S(n),L=Date.now(),n}function y(){let e=C(m());return Object.values(e.projects).sort((e,t)=>e.projectName.localeCompare(t.projectName))}function b(e){let t=process.env.CLAUDE_PROJECT_DIR?.trim();if(t){let n=E(t);return x({source:`claude_project_dir`,scope:`project`,cwd:e,projectRoot:n,identity:`claude-project-dir:${n}`,projectName:r(n)||`project`})}let n=T([`remote`,`get-url`,`origin`],e);if(n){let t=T([`rev-parse`,`--show-toplevel`],e),r=D(n);return x({source:`git_remote`,scope:`project`,cwd:e,projectRoot:E(t||e),gitRemote:r,identity:`git-remote:${r}`,projectName:O(r)})}let i=T([`rev-parse`,`--show-toplevel`],e);if(i){let t=E(i);return x({source:`git_root`,scope:`project`,cwd:e,projectRoot:t,identity:`git-root:${t}`,projectName:r(t)||`project`})}return x({source:`global`,scope:`global`,cwd:e,projectRoot:void 0,identity:`global`,projectName:M})}function x(e){let t=e.scope===`global`?j:k(e.identity);return{projectId:t,projectName:e.projectName,scope:e.scope,source:e.source,cwd:E(e.cwd),projectRoot:e.projectRoot,gitRemote:e.gitRemote,storageDir:h(t)}}function S(e){let t=new Date().toISOString(),n=m(),r=C(n),i=r.projects[e.projectId],a={...e,firstSeenAt:i?.firstSeenAt??t,lastSeenAt:t};r.projects[e.projectId]=a,r.updatedAt=t,s(e.storageDir,{recursive:!0}),s(p(),{recursive:!0}),w(n,r),w(g(e.projectId),a)}function C(e){if(!o(e))return{version:A,updatedAt:new Date(0).toISOString(),projects:{}};try{let t=JSON.parse(c(e,`utf8`));if(t.version===A&&typeof t.projects==`object`&&t.projects)return{version:A,updatedAt:typeof t.updatedAt==`string`?t.updatedAt:new Date(0).toISOString(),projects:t.projects}}catch{}return{version:A,updatedAt:new Date(0).toISOString(),projects:{}}}function w(e,t){u(e,`${JSON.stringify(t,null,2)}\n`,`utf8`)}function T(e,t){try{return f(`git`,[`-C`,t,...e],{encoding:`utf8`,stdio:[`ignore`,`pipe`,`ignore`]}).trim()||null}catch{return null}}function E(e){let t=a(e);try{return l.native(t).normalize(`NFC`)}catch{return t.normalize(`NFC`)}}function D(e){let t=e.trim().replace(/\\/g,`/`);return t=t.replace(/\.git$/i,``),t=t.replace(/\/+$/g,``),t.toLowerCase()}function O(e){return e.match(/[:/]([^/:]+?)(?:\.git)?$/)?.[1]||`project`}function k(e){return`project-${d(`sha256`).update(e).digest(`hex`).slice(0,16)}`}var A,j,M,N,P,F,I,L,R=e((()=>{n(),A=1,j=`global`,M=`Global`,N=32,P=24,F=new Map,I=300*1e3,L=0}));export{R as a,p as i,h as n,y as o,m as r,v as s,g as t};
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{i as t,o as n}from"./envUtils-DcaKZlRU.js";import{basename as r,join as i,resolve as a}from"path";import{existsSync as o,mkdirSync as s,readFileSync as c,realpathSync as l,writeFileSync as u}from"fs";import{createHash as d}from"crypto";import{execFileSync as f}from"child_process";function p(){return i(t(),`skill-learning`)}function m(){return i(p(),`projects.json`)}function h(e){return e===j?i(p(),`global`):i(p(),`projects`,e)}function g(e){return i(h(e),`project.json`)}function _(e,t){if(F.has(e)&&F.delete(e),F.set(e,t),F.size>N){let e=F.size-P,t=F.keys();for(let n=0;n<e;n++){let e=t.next();if(e.done)break;F.delete(e.value)}}}function v(e=process.cwd()){let t=F.get(e);if(t){F.delete(e),F.set(e,t);let n=Date.now();return n-L>I&&(L=n,S(t)),t}let n=b(e);return _(e,n),S(n),L=Date.now(),n}function y(){let e=C(m());return Object.values(e.projects).sort((e,t)=>e.projectName.localeCompare(t.projectName))}function b(e){let t=process.env.CLAUDE_PROJECT_DIR?.trim();if(t){let n=E(t);return x({source:`claude_project_dir`,scope:`project`,cwd:e,projectRoot:n,identity:`claude-project-dir:${n}`,projectName:r(n)||`project`})}let n=T([`remote`,`get-url`,`origin`],e);if(n){let t=T([`rev-parse`,`--show-toplevel`],e),r=D(n);return x({source:`git_remote`,scope:`project`,cwd:e,projectRoot:E(t||e),gitRemote:r,identity:`git-remote:${r}`,projectName:O(r)})}let i=T([`rev-parse`,`--show-toplevel`],e);if(i){let t=E(i);return x({source:`git_root`,scope:`project`,cwd:e,projectRoot:t,identity:`git-root:${t}`,projectName:r(t)||`project`})}return x({source:`global`,scope:`global`,cwd:e,projectRoot:void 0,identity:`global`,projectName:M})}function x(e){let t=e.scope===`global`?j:k(e.identity);return{projectId:t,projectName:e.projectName,scope:e.scope,source:e.source,cwd:E(e.cwd),projectRoot:e.projectRoot,gitRemote:e.gitRemote,storageDir:h(t)}}function S(e){let t=new Date().toISOString(),n=m(),r=C(n),i=r.projects[e.projectId],a={...e,firstSeenAt:i?.firstSeenAt??t,lastSeenAt:t};r.projects[e.projectId]=a,r.updatedAt=t,s(e.storageDir,{recursive:!0}),s(p(),{recursive:!0}),w(n,r),w(g(e.projectId),a)}function C(e){if(!o(e))return{version:A,updatedAt:new Date(0).toISOString(),projects:{}};try{let t=JSON.parse(c(e,`utf8`));if(t.version===A&&typeof t.projects==`object`&&t.projects)return{version:A,updatedAt:typeof t.updatedAt==`string`?t.updatedAt:new Date(0).toISOString(),projects:t.projects}}catch{}return{version:A,updatedAt:new Date(0).toISOString(),projects:{}}}function w(e,t){u(e,`${JSON.stringify(t,null,2)}\n`,`utf8`)}function T(e,t){try{return f(`git`,[`-C`,t,...e],{encoding:`utf8`,stdio:[`ignore`,`pipe`,`ignore`]}).trim()||null}catch{return null}}function E(e){let t=a(e);try{return l.native(t).normalize(`NFC`)}catch{return t.normalize(`NFC`)}}function D(e){let t=e.trim().replace(/\\/g,`/`);return t=t.replace(/\.git$/i,``),t=t.replace(/\/+$/g,``),t.toLowerCase()}function O(e){return e.match(/[:/]([^/:]+?)(?:\.git)?$/)?.[1]||`project`}function k(e){return`project-${d(`sha256`).update(e).digest(`hex`).slice(0,16)}`}var A,j,M,N,P,F,I,L,R=e((()=>{n(),A=1,j=`global`,M=`Global`,N=32,P=24,F=new Map,I=300*1e3,L=0}));export{R as a,p as i,h as n,y as o,m as r,v as s,g as t};
@@ -1 +1 @@
1
- import{a as e,i as t,n,o as r,r as i,s as a,t as o}from"./projectContext-CIxul6vA.js";e();export{o as getProjectContextPath,n as getProjectStorageDir,i as getProjectsRegistryPath,t as getSkillLearningRootDir,r as listKnownProjects,a as resolveProjectContext};
1
+ import{a as e,i as t,n,o as r,r as i,s as a,t as o}from"./projectContext-BN2ZWzOG.js";e();export{o as getProjectContextPath,n as getProjectStorageDir,i as getProjectsRegistryPath,t as getSkillLearningRootDir,r as listKnownProjects,a as resolveProjectContext};
@@ -0,0 +1 @@
1
+ import{Cw as e,kw as t}from"./loadAgentsDir-BXtV2jiO.js";t();export{e as clearPromptCache};
@@ -1,4 +1,4 @@
1
- import{a as e,n as t,o as n,r,t as i}from"./rolldown-runtime-DaDcL9Zw.js";import{l as a,o}from"./envUtils-BDhHQY0-.js";import{n as s,t as c}from"./defineProperty-C-QyHrDq.js";import{A as l,C as u,M as d,w as f}from"./external-CEp-aPkt.js";import{n as p,r as m,t as h}from"./lazySchema-B4D4qJVE.js";import{M as g,S as _,w as v,z as y}from"./debug-RAynG_nM.js";import{G as b,J as x,K as S,Q as C,W as w,q as T}from"./settings-DnptdP79.js";import{H as E,q as D}from"./log-CezCRpAN.js";import{i as O,o as k}from"./platform-BMPbglug.js";import{_ as A,u as j}from"./model-BsZ4sP_H.js";import{join as M,parse as N,resolve as P,sep as ee}from"node:path";import{createHash as F}from"node:crypto";import{appendFile as I,mkdir as te,readFile as L,readdir as ne,rm as re,writeFile as ie}from"node:fs/promises";function ae(e){return e.filter(e=>e.data?.type!==`hook_progress`)}function oe(e,t){return e.name===t||(e.aliases?.includes(t)??!1)}function se(e,t){return e.find(e=>oe(e,t))}function ce(e){return{...ue,userFacingName:()=>e.name,...e}}var le,ue,de=t((()=>{le=()=>({mode:`default`,additionalWorkingDirectories:new Map,alwaysAllowRules:{},alwaysDenyRules:{},alwaysAskRules:{},isBypassPermissionsModeAvailable:!0}),ue={isEnabled:()=>!0,isConcurrencySafe:e=>!1,isReadOnly:e=>!1,isDestructive:e=>!1,checkPermissions:(e,t)=>Promise.resolve({behavior:`allow`,updatedInput:e}),toAutoClassifierInput:e=>``,userFacingName:e=>``}})),fe,pe,me,he,ge=t((()=>{fe=`Edit`,pe=`/.claude/**`,me=`~/.claude/**`,he=`File has been unexpectedly modified. Read it again before attempting to write it.`}));function _e(e){let t=e.trim();if(!t)return null;if(t.endsWith(`-`)){let e=parseInt(t.slice(0,-1),10);return isNaN(e)||e<1?null:{firstPage:e,lastPage:1/0}}let n=t.indexOf(`-`);if(n===-1){let e=parseInt(t,10);return isNaN(e)||e<1?null:{firstPage:e,lastPage:e}}let r=parseInt(t.slice(0,n),10),i=parseInt(t.slice(n+1),10);return isNaN(r)||isNaN(i)||r<1||i<1||i<r?null:{firstPage:r,lastPage:i}}function ve(){return!j().toLowerCase().includes(`claude-3-haiku`)}function ye(e){let t=e.startsWith(`.`)?e.slice(1):e;return be.has(t.toLowerCase())}var be,xe=t((()=>{A(),be=new Set([`pdf`])})),R,Se=t((()=>{R=`Bash`}));function Ce(e,t,n){return`Reads a file from the local filesystem. You can access any file directly by using this tool.
1
+ import{a as e,n as t,o as n,r,t as i}from"./rolldown-runtime-DaDcL9Zw.js";import{l as a,o}from"./envUtils-DcaKZlRU.js";import{n as s,t as c}from"./defineProperty-C-QyHrDq.js";import{A as l,C as u,M as d,w as f}from"./external-CEp-aPkt.js";import{n as p,r as m,t as h}from"./lazySchema-B4D4qJVE.js";import{C as g,R as _,j as v,x as y}from"./debug-Dr1SjdXn.js";import{G as b,J as x,K as S,Q as C,W as w,q as T}from"./settings-DiBMs2gM.js";import{H as E,q as D}from"./log-27kCA_9u.js";import{i as O,o as k}from"./platform-Dg1c9F_1.js";import{_ as A,u as j}from"./model-CDnVaVDR.js";import{join as M,parse as N,resolve as P,sep as ee}from"node:path";import{createHash as F}from"node:crypto";import{appendFile as I,mkdir as te,readFile as L,readdir as ne,rm as re,writeFile as ie}from"node:fs/promises";function ae(e){return e.filter(e=>e.data?.type!==`hook_progress`)}function oe(e,t){return e.name===t||(e.aliases?.includes(t)??!1)}function se(e,t){return e.find(e=>oe(e,t))}function ce(e){return{...ue,userFacingName:()=>e.name,...e}}var le,ue,de=t((()=>{le=()=>({mode:`default`,additionalWorkingDirectories:new Map,alwaysAllowRules:{},alwaysDenyRules:{},alwaysAskRules:{},isBypassPermissionsModeAvailable:!0}),ue={isEnabled:()=>!0,isConcurrencySafe:e=>!1,isReadOnly:e=>!1,isDestructive:e=>!1,checkPermissions:(e,t)=>Promise.resolve({behavior:`allow`,updatedInput:e}),toAutoClassifierInput:e=>``,userFacingName:e=>``}})),fe,pe,me,he,ge=t((()=>{fe=`Edit`,pe=`/.workmate/**`,me=`~/.workmate/**`,he=`File has been unexpectedly modified. Read it again before attempting to write it.`}));function _e(e){let t=e.trim();if(!t)return null;if(t.endsWith(`-`)){let e=parseInt(t.slice(0,-1),10);return isNaN(e)||e<1?null:{firstPage:e,lastPage:1/0}}let n=t.indexOf(`-`);if(n===-1){let e=parseInt(t,10);return isNaN(e)||e<1?null:{firstPage:e,lastPage:e}}let r=parseInt(t.slice(0,n),10),i=parseInt(t.slice(n+1),10);return isNaN(r)||isNaN(i)||r<1||i<1||i<r?null:{firstPage:r,lastPage:i}}function ve(){return!j().toLowerCase().includes(`claude-3-haiku`)}function ye(e){let t=e.startsWith(`.`)?e.slice(1):e;return be.has(t.toLowerCase())}var be,xe=t((()=>{A(),be=new Set([`pdf`])})),R,Se=t((()=>{R=`Bash`}));function Ce(e,t,n){return`Reads a file from the local filesystem. You can access any file directly by using this tool.
2
2
  Assume this tool is able to read all files on the machine. If the User provides a path to a file assume that path is valid. It is okay to read a file that does not exist; an error will be returned.
3
3
 
4
4
  Usage:
@@ -67,7 +67,7 @@ Usage:
67
67
  - This tool will overwrite the existing file if there is one at the provided path.${An()}
68
68
  - Prefer the Edit tool for modifying existing files \u2014 it only sends the diff. Only use this tool to create new files or for complete rewrites.
69
69
  - NEVER create documentation files (*.md) or README files unless explicitly requested by the User.
70
- - Only use emojis if the user explicitly requests it. Avoid writing emojis to files unless asked.`}var Mn,Nn=t((()=>{Ae(),Mn=`Write`})),Pn,Fn=t((()=>{Pn=`NotebookEdit`})),In,Ln=t((()=>{In=`TaskGet`})),Rn,zn=t((()=>{Rn=`TaskList`})),Bn,Vn=t((()=>{Bn=`SearchExtraTools`}));function Hn(e){return e.isNonInteractiveSession}function Un(e){let t=Yn.get(e);if(t)return t;let n=Wn(e);return Yn.set(e,n),n}function Wn(e){try{let t=new Gn.Ajv({allErrors:!0});if(!t.validateSchema(e))return{error:t.errorsText(t.errors)};let n=t.compile(e);return{tool:{...Jn,inputJSONSchema:e,async call(e){if(!n(e)){let e=n.errors?.map(e=>`${e.instancePath||`root`}: ${e.message}`).join(`, `);throw new g(`Output does not match required schema: ${e}`,`StructuredOutput schema mismatch: ${(e??``).slice(0,150)}`)}return{data:`Structured output provided successfully`,structured_output:e}}}}}catch(e){return{error:e instanceof Error?e.message:String(e)}}}var Gn,Kn,qn,K,Jn,Yn,Xn=t((()=>{Gn=n(fn(),1),m(),de(),y(),h(),_(),Kn=p(()=>f({}).passthrough()),qn=p(()=>l().describe(`Structured output tool result`)),K=`StructuredOutput`,Jn=ce({isMcp:!1,isEnabled(){return!0},isConcurrencySafe(){return!0},isReadOnly(){return!0},isOpenWorld(){return!1},name:K,searchHint:`return the final response as structured JSON`,maxResultSizeChars:1e5,async description(){return`Return structured output in the requested format`},async prompt(){return`Use this tool to return your final response in the requested structured format. You MUST call this tool exactly once at the end of your response to provide the structured output.`},get inputSchema(){return Kn()},get outputSchema(){return qn()},async call(e){return{data:`Structured output provided successfully`,structured_output:e}},async checkPermissions(e){return{behavior:`allow`,updatedInput:e}},renderToolUseMessage(e){let t=Object.keys(e);return t.length===0?null:t.length<=3?t.map(t=>`${t}: ${v(e[t])}`).join(`, `):`${t.length} fields: ${t.slice(0,3).join(`, `)}…`},renderToolUseRejectedMessage(){return`Structured output rejected`},renderToolUseErrorMessage(){return`Structured output error`},renderToolUseProgressMessage(){return null},renderToolResultMessage(e){return e},mapToolResultToToolResultBlockParam(e,t){return{tool_use_id:t,type:`tool_result`,content:e}}}),Yn=new WeakMap})),Zn,Qn,$n,er=t((()=>{D(),Zn=`Sleep`,Qn=`Wait for a specified duration`,$n=`Wait for a specified duration. The user can interrupt the sleep at any time.
70
+ - Only use emojis if the user explicitly requests it. Avoid writing emojis to files unless asked.`}var Mn,Nn=t((()=>{Ae(),Mn=`Write`})),Pn,Fn=t((()=>{Pn=`NotebookEdit`})),In,Ln=t((()=>{In=`TaskGet`})),Rn,zn=t((()=>{Rn=`TaskList`})),Bn,Vn=t((()=>{Bn=`SearchExtraTools`}));function Hn(e){return e.isNonInteractiveSession}function Un(e){let t=Yn.get(e);if(t)return t;let n=Wn(e);return Yn.set(e,n),n}function Wn(e){try{let t=new Gn.Ajv({allErrors:!0});if(!t.validateSchema(e))return{error:t.errorsText(t.errors)};let n=t.compile(e);return{tool:{...Jn,inputJSONSchema:e,async call(e){if(!n(e)){let e=n.errors?.map(e=>`${e.instancePath||`root`}: ${e.message}`).join(`, `);throw new v(`Output does not match required schema: ${e}`,`StructuredOutput schema mismatch: ${(e??``).slice(0,150)}`)}return{data:`Structured output provided successfully`,structured_output:e}}}}}catch(e){return{error:e instanceof Error?e.message:String(e)}}}var Gn,Kn,qn,K,Jn,Yn,Xn=t((()=>{Gn=n(fn(),1),m(),de(),_(),h(),y(),Kn=p(()=>f({}).passthrough()),qn=p(()=>l().describe(`Structured output tool result`)),K=`StructuredOutput`,Jn=ce({isMcp:!1,isEnabled(){return!0},isConcurrencySafe(){return!0},isReadOnly(){return!0},isOpenWorld(){return!1},name:K,searchHint:`return the final response as structured JSON`,maxResultSizeChars:1e5,async description(){return`Return structured output in the requested format`},async prompt(){return`Use this tool to return your final response in the requested structured format. You MUST call this tool exactly once at the end of your response to provide the structured output.`},get inputSchema(){return Kn()},get outputSchema(){return qn()},async call(e){return{data:`Structured output provided successfully`,structured_output:e}},async checkPermissions(e){return{behavior:`allow`,updatedInput:e}},renderToolUseMessage(e){let t=Object.keys(e);return t.length===0?null:t.length<=3?t.map(t=>`${t}: ${g(e[t])}`).join(`, `):`${t.length} fields: ${t.slice(0,3).join(`, `)}…`},renderToolUseRejectedMessage(){return`Structured output rejected`},renderToolUseErrorMessage(){return`Structured output error`},renderToolUseProgressMessage(){return null},renderToolResultMessage(e){return e},mapToolResultToToolResultBlockParam(e,t){return{tool_use_id:t,type:`tool_result`,content:e}}}),Yn=new WeakMap})),Zn,Qn,$n,er=t((()=>{D(),Zn=`Sleep`,Qn=`Wait for a specified duration`,$n=`Wait for a specified duration. The user can interrupt the sleep at any time.
71
71
 
72
72
  Use this when the user tells you to sleep or rest, when you have nothing to do, or when you're waiting for something.
73
73
 
@@ -95,12 +95,12 @@ All operations require:
95
95
  - line: The line number (1-based, as shown in editors)
96
96
  - character: The character offset (1-based, as shown in editors)
97
97
 
98
- Note: LSP servers must be configured for the file type. If no server is available, an error will be returned.`})),rr,ir=t((()=>{rr=`VerifyPlanExecution`})),ar,or=t((()=>{ar=`ExecuteExtraTool`})),sr,cr=t((()=>{sr=`EnterWorktree`})),lr,ur=t((()=>{lr=`ExitWorktree`})),dr=t((()=>{})),q,J,fr,pr,mr,hr,Y=t((()=>{q=`Workflow`,J=`.claude/workflows`,fr=`.claude/workflow-runs`,pr=[`.ts`,`.js`,`.mjs`],mr=1e3,hr=4096}));function gr(e){return{[yr]:e}}function _r(e){return typeof e==`object`&&!!e&&yr in e}function vr(e){return e[yr]}var yr,br=t((()=>{yr=Symbol(`workflow.hostHandle`)}));function xr(e,t){return e.kind===`agentType`?t.agentType===e.agentType:e.kind===`model`?typeof t.model==`string`&&t.model.startsWith(e.pattern):e.match(t)}var Sr,Cr,wr=t((()=>{s(),Sr=class extends Error{constructor(e){super(e),this.name=`AdapterNotFoundError`}},Cr=class{constructor(){c(this,`adapters`,new Map),c(this,`rules`,[]),c(this,`defaultId`,null)}register(e){return this.adapters.set(e.id,e),this}default(e){return this.defaultId=e,this}route(e){return this.rules.push(e),this}has(e){return this.adapters.has(e)}get(e){return this.adapters.get(e)}resolve(e){for(let t of this.rules)if(xr(t,e)){let e=this.adapters.get(t.adapter);if(e)return e}if(this.defaultId){let e=this.adapters.get(this.defaultId);if(e)return e}throw new Sr(`No adapter matched (rules=${this.rules.length}, default=${this.defaultId??`none`})`)}async initializeAll(){for(let e of this.adapters.values())await e.initialize?.()}async disposeAll(){for(let e of this.adapters.values())await e.dispose?.()}}}));function Tr(){return 3}function Er(e){return e===void 0||Number.isNaN(e)?3:Math.max(1,Math.min(Math.trunc(e),16))}var Dr,Or=t((()=>{Y(),s(),Dr=class{constructor(e){c(this,`available`,void 0),c(this,`waiters`,[]),this.available=Math.max(1,Math.floor(e))}async acquire(e){if(e?.aborted)throw Error(`Semaphore.acquire aborted (signal already aborted)`);return this.available>0?(--this.available,()=>this.release()):new Promise((t,n)=>{let r=()=>{let e=this.waiters.indexOf(i);e>=0&&this.waiters.splice(e,1),n(Error(`Semaphore.acquire aborted`))},i={wake:()=>{e?.removeEventListener(`abort`,r),t(()=>this.release())},cleanup:()=>e?.removeEventListener(`abort`,r)};e?.addEventListener(`abort`,r,{once:!0}),this.waiters.push(i)})}release(){let e=this.waiters.shift();e?e.wake():this.available+=1}}}));function kr(e){let t=Pr.exec(e);if(!t)return{meta:null,body:e};let n=t.index+t[0].length;for(;n<e.length&&/\s/.test(e[n]);)n++;if(e[n]!==`{`)throw new Z("meta must be an object literal `{ ... }`");let r=0,i=n,a=null;for(;n<e.length;n++){let t=e[n];if(a){if(t===`\\`){n++;continue}t===a&&(a=null);continue}if(t===`"`||t===`'`||t==="`"){a=t;continue}if(t===`{`)r++;else if(t===`}`&&(r--,r===0)){n++;break}}if(r!==0)throw new Z(`meta literal braces are not closed`);let o=e.slice(i,n),s;try{s=Function(`return (${o})`)()}catch(e){throw new Z(`meta must be a plain literal (no variable/function calls/interpolation): ${e.message}`)}return{meta:Ar(s),body:e.slice(0,t.index)+e.slice(n).replace(/^[ \t]*;[ \t]*\n/,`
98
+ Note: LSP servers must be configured for the file type. If no server is available, an error will be returned.`})),rr,ir=t((()=>{rr=`VerifyPlanExecution`})),ar,or=t((()=>{ar=`ExecuteExtraTool`})),sr,cr=t((()=>{sr=`EnterWorktree`})),lr,ur=t((()=>{lr=`ExitWorktree`})),dr=t((()=>{})),q,J,fr,pr,mr,hr,Y=t((()=>{q=`Workflow`,J=`.workmate/workflows`,fr=`.workmate/workflow-runs`,pr=[`.ts`,`.js`,`.mjs`],mr=1e3,hr=4096}));function gr(e){return{[yr]:e}}function _r(e){return typeof e==`object`&&!!e&&yr in e}function vr(e){return e[yr]}var yr,br=t((()=>{yr=Symbol(`workflow.hostHandle`)}));function xr(e,t){return e.kind===`agentType`?t.agentType===e.agentType:e.kind===`model`?typeof t.model==`string`&&t.model.startsWith(e.pattern):e.match(t)}var Sr,Cr,wr=t((()=>{s(),Sr=class extends Error{constructor(e){super(e),this.name=`AdapterNotFoundError`}},Cr=class{constructor(){c(this,`adapters`,new Map),c(this,`rules`,[]),c(this,`defaultId`,null)}register(e){return this.adapters.set(e.id,e),this}default(e){return this.defaultId=e,this}route(e){return this.rules.push(e),this}has(e){return this.adapters.has(e)}get(e){return this.adapters.get(e)}resolve(e){for(let t of this.rules)if(xr(t,e)){let e=this.adapters.get(t.adapter);if(e)return e}if(this.defaultId){let e=this.adapters.get(this.defaultId);if(e)return e}throw new Sr(`No adapter matched (rules=${this.rules.length}, default=${this.defaultId??`none`})`)}async initializeAll(){for(let e of this.adapters.values())await e.initialize?.()}async disposeAll(){for(let e of this.adapters.values())await e.dispose?.()}}}));function Tr(){return 3}function Er(e){return e===void 0||Number.isNaN(e)?3:Math.max(1,Math.min(Math.trunc(e),16))}var Dr,Or=t((()=>{Y(),s(),Dr=class{constructor(e){c(this,`available`,void 0),c(this,`waiters`,[]),this.available=Math.max(1,Math.floor(e))}async acquire(e){if(e?.aborted)throw Error(`Semaphore.acquire aborted (signal already aborted)`);return this.available>0?(--this.available,()=>this.release()):new Promise((t,n)=>{let r=()=>{let e=this.waiters.indexOf(i);e>=0&&this.waiters.splice(e,1),n(Error(`Semaphore.acquire aborted`))},i={wake:()=>{e?.removeEventListener(`abort`,r),t(()=>this.release())},cleanup:()=>e?.removeEventListener(`abort`,r)};e?.addEventListener(`abort`,r,{once:!0}),this.waiters.push(i)})}release(){let e=this.waiters.shift();e?e.wake():this.available+=1}}}));function kr(e){let t=Pr.exec(e);if(!t)return{meta:null,body:e};let n=t.index+t[0].length;for(;n<e.length&&/\s/.test(e[n]);)n++;if(e[n]!==`{`)throw new Z("meta must be an object literal `{ ... }`");let r=0,i=n,a=null;for(;n<e.length;n++){let t=e[n];if(a){if(t===`\\`){n++;continue}t===a&&(a=null);continue}if(t===`"`||t===`'`||t==="`"){a=t;continue}if(t===`{`)r++;else if(t===`}`&&(r--,r===0)){n++;break}}if(r!==0)throw new Z(`meta literal braces are not closed`);let o=e.slice(i,n),s;try{s=Function(`return (${o})`)()}catch(e){throw new Z(`meta must be a plain literal (no variable/function calls/interpolation): ${e.message}`)}return{meta:Ar(s),body:e.slice(0,t.index)+e.slice(n).replace(/^[ \t]*;[ \t]*\n/,`
99
99
  `)}}function Ar(e){if(typeof e!=`object`||!e||Array.isArray(e))throw new Z(`meta must be an object`);let t=e;if(typeof t.name!=`string`||typeof t.description!=`string`)throw new Z(`meta must include string name and description`);return t}function jr(){let e=function(...e){if(e.length===0)throw new Fr(`Date.now()/new Date()`);return new Date(...e)};return e.now=()=>{throw new Fr(`Date.now()`)},e.parse=Date.parse,e.UTC=Date.UTC,e}function Mr(){return new Proxy(Math,{get(e,t,n){return t===`random`?()=>{throw new Fr(`Math.random()`)}:Reflect.get(e,t,n)}})}function Nr(e){if(/^\s*import\b/m.test(e))throw new Z(`workflow scripts are the body of new AsyncFunction (not ESM modules); import is not supported. agent / parallel / pipeline / phase / log / workflow / args / budget are injected as parameters — use them directly.`);if(/\bimport\s*\(/m.test(e))throw new Z(`dynamic import(...) is forbidden in workflow scripts: it bypasses the Date/Math sandbox and breaks resume determinism. The sandbox does not guarantee security (same trust level as the LLM), but explicit escapes are prohibited. Inject external dependencies via args.`);if(/^\s*export\b/m.test(e))throw new Z(`workflow scripts allow only one export const meta = {...} (already extracted by the engine). Remove other export / export default statements; use top-level return for the result.`)}function X(e){let{meta:t,body:n}=kr(e);Nr(n);let r;try{r=new Ir(`agent`,`parallel`,`pipeline`,`phase`,`log`,`workflow`,`args`,`budget`,`Date`,`Math`,n)}catch(e){throw new Z(`Script syntax error: ${e.message}`)}let i=jr(),a=Mr();return{meta:t,async execute(e,t,n){return r(e.agent,e.parallel,e.pipeline,e.phase,e.log,e.workflow,t,n,i,a)}}}var Z,Pr,Fr,Ir,Lr=t((()=>{Z=class extends Error{constructor(e){super(e),this.name=`ScriptError`}},Pr=/export\s+const\s+meta\s*=\s*/,Fr=class extends Error{constructor(e){super(`${e} is not available in workflow scripts (would break resume determinism). Pass timestamps/random seeds via args.`),this.name=`NonDeterministicError`}},Ir=Object.getPrototypeOf(async function(){}).constructor}));function Rr(e){let{label:t,phase:n,...r}=e,i=Object.keys(r).sort(),a={};for(let e of i)a[e]=r[e];return JSON.stringify(a)}function zr(e,t){return F(`sha256`).update(e+`
100
100
  `+Rr(t)).digest(`hex`)}function Br(e){let t=t=>M(e,t,`journal.jsonl`);return{async read(e){try{return(await L(t(e),`utf-8`)).split(`
101
101
  `).filter(e=>e.trim().length>0).map(e=>JSON.parse(e)).sort((e,t)=>(e.seq??0)-(t.seq??0))}catch{return[]}},async append(n,r){await te(M(e,n),{recursive:!0}),await I(t(n),JSON.stringify(r)+`
102
- `,`utf-8`)},async truncate(t){await re(M(e,t),{recursive:!0,force:!0})}}}var Vr=t((()=>{})),Hr,Ur,Wr=t((()=>{s(),Hr=class extends Error{constructor(){super(`workflow token budget exhausted (budget.total reached the cap)`),this.name=`BudgetExhaustedError`}},Ur=class{constructor(e){c(this,`total`,void 0),c(this,`spentTokens`,0),this.total=e}spent(){return this.spentTokens}remaining(){return this.total==null?1/0:Math.max(0,this.total-this.spentTokens)}addOutputTokens(e){e>0&&(this.spentTokens+=e)}assertCanSpend(){if(this.total!=null&&this.spentTokens>=this.total)throw new Hr}}}));function Gr(e,t){let n=qr.get(t);n||(n=new Kr.Ajv({allErrors:!0,strict:!1}).compile(t),qr.set(t,n));let r=n(e);return{valid:r,errors:r?[]:(n.errors??[]).map(e=>e.message??`validation error`)}}var Kr,qr,Jr=t((()=>{Kr=n(fn(),1),qr=new WeakMap}));function Yr(e,t){let n=P(e),r=P(n,t);return r===n||r.startsWith(n+ee)}function Xr(e){return typeof e!=`string`||e.length===0||e.includes(`/`)||e.includes(`\\`)||e.includes(`\0`)||e===`.`||e===`..`?null:e}var Zr=t((()=>{}));function Qr(e){return pr.includes(e.toLowerCase())}async function $r(e,t){for(let n of pr){let r=P(e,t+n);if(!Yr(e,r))return null;try{return{path:r,content:await L(r,`utf-8`)}}catch{}}return null}async function ei(e){let t;try{t=await ne(e)}catch{return[]}return t.filter(e=>Qr(N(e).ext)).map(e=>N(e).name).sort()}var ti=t((()=>{Y(),Zr()})),Q,$,ni=t((()=>{Q=class extends Error{constructor(e){super(e),this.name=`WorkflowError`}},$=class extends Error{constructor(){super(`workflow has been aborted`),this.name=`WorkflowAbortedError`}}}));function ri(e,t){return{semaphore:new Dr(Er(t)),budget:new Ur(e),agentCountBox:{value:0},agentIdSeq:{value:0},depth:0}}function ii(e){let t=ri(e.budgetTotal,e.maxConcurrency);return{ports:e.ports,host:e.host,signal:e.signal,runId:e.runId,workflowName:e.workflowName,cwd:e.cwd,resources:t,journal:e.journal?[...e.journal]:[],journalIndex:0,journalInvalidated:!1,currentPhase:null}}var ai=t((()=>{Wr(),Or()}));function oi(e,t){let n=t=>{e.ports.progressEmitter.emit({runId:e.runId,...t})};return{agent:async(t,r={})=>{let i=e.resources;if(i.agentCountBox.value>=1e3)throw new Q(`workflow exceeds total agent cap (${mr})`);let a=i.agentIdSeq.value++,o={prompt:t,...r},s=zr(t,o),c=r.label,l=r.phase??e.currentPhase??void 0;if(!e.journalInvalidated&&e.journalIndex<e.journal.length){let t=e.journal[e.journalIndex];if(t.key===s)return e.journalIndex++,n({type:`agent_done`,agentId:a,label:c,phase:l,result:t.result}),si(t.result);e.journalInvalidated=!0,e.journal=e.journal.slice(0,e.journalIndex),await e.ports.journalStore.truncate(e.runId)}let u;try{u=await e.resources.semaphore.acquire(e.signal)}catch{throw new $}try{if(e.signal.aborted)throw new $;if(i.budget.assertCanSpend(),e.ports.taskRegistrar.pendingAction(e.runId)?.kind===`skip`)return n({type:`agent_done`,agentId:a,label:c,phase:l,result:{kind:`skipped`}}),null;e.resources.agentCountBox.value++,n({type:`agent_started`,agentId:a,label:c,phase:l});let t=e.ports.agentAdapterRegistry,r=t?{host:e.host,signal:e.signal,runId:e.runId,agentId:a,onProgress:e=>{n({type:`agent_progress`,agentId:a,label:c,phase:l,...e})},...e.ports.taskRegistrar.registerAgentAbort?{registerAgentAbort:(t,n)=>{e.ports.taskRegistrar.registerAgentAbort?.(e.runId,t,n)}}:{},...e.ports.taskRegistrar.unregisterAgentAbort?{unregisterAgentAbort:t=>{e.ports.taskRegistrar.unregisterAgentAbort?.(e.runId,t)}}:{}}:null,u=t?t.resolve(o):null,d=()=>u?u.run(o,r):e.ports.agentRunner.runAgentToResult(o,e.host),f;try{if(f=await d(),f.kind===`dead`){let t=typeof f.detail==`string`?f.detail:``;e.ports.logger.warn?.(`agent "${c??`#${a}`}" returned dead`+(f.reason?` (${f.reason})`:``)+(t?`: ${t.slice(0,150)}`:``)+`; retrying once`),f=await d()}}catch(t){if(t instanceof $)throw t;let n=t instanceof Error?t.message:String(t);e.ports.logger.warn?.(`agent "${c??`#${a}`}" threw (${n}); retrying once`);try{f=await d()}catch(e){if(e instanceof $)throw e;f={kind:`dead`,reason:`runagent-threw`,detail:e instanceof Error?e.message:String(e)}}}f.kind===`ok`&&e.resources.budget.addOutputTokens(f.usage.outputTokens),n({type:`agent_done`,agentId:a,label:c,phase:l,result:f});let p={key:s,seq:a,result:f};return e.journal.push(p),e.journalIndex++,await e.ports.journalStore.append(e.runId,p),si(f)}finally{u()}},parallel:async t=>{if(t.length>4096)throw new Q(`parallel exceeds the per-call items cap (${hr})`);return Promise.all(t.map(async(t,n)=>{try{return await t()}catch(t){return e.ports.logger.warn?.(`parallel thunk #${n} failed: ${t.message}`),null}}))},pipeline:async(t,...n)=>{if(t.length>4096)throw new Q(`pipeline exceeds the per-call items cap (${hr})`);return Promise.all(t.map(async(t,r)=>{try{let e=t;for(let i of n)e=await i(e,t,r);return e}catch(t){return e.ports.logger.warn?.(`pipeline item #${r} failed: ${t.message}`),null}}))},phase:t=>{e.currentPhase&&n({type:`phase_done`,phase:e.currentPhase}),e.currentPhase=t,n({type:`phase_started`,phase:t})},log:e=>{n({type:`log`,message:e})},workflow:async(n,r)=>{if(e.resources.depth>=1)throw new Q(`workflow() nesting allows only one level`);return t({...typeof n==`string`?{name:n}:{scriptPath:n.scriptPath},args:r})}}}function si(e){return e.kind===`ok`?e.output:null}var ci=t((()=>{Y(),ni(),Vr()}));async function li(e){let{ports:t}=e,n;try{n=X(e.script)}catch(n){let r=n.message;return t.progressEmitter.emit({type:`run_done`,runId:e.runId,status:`failed`,error:r}),{status:`failed`,error:r}}let r=e.workflowName??n.meta?.name??`workflow`,i=[],a=!1;e.resume&&!e.scriptChanged?i=await t.journalStore.read(e.runId):e.scriptChanged&&(await t.journalStore.truncate(e.runId),a=!0);let o=ii({ports:t,host:e.host,signal:e.signal,runId:e.runId,workflowName:r,cwd:e.cwd,budgetTotal:e.budgetTotal,maxConcurrency:e.maxConcurrency,journal:i});a&&(o.journalInvalidated=!0),t.progressEmitter.emit({type:`run_started`,runId:e.runId,workflowName:r,meta:n.meta});let s=async t=>{let n=await ui(t,e.cwd),r;try{r=X(n)}catch(e){throw new Q(`Sub-workflow script error: ${e.message}`)}let i=o.resources.depth;o.resources.depth+=1;try{let e=oi(o,s);return await r.execute(e,t.args,o.resources.budget)}finally{o.resources.depth=i}},c=oi(o,s),l=()=>{o.currentPhase&&t.progressEmitter.emit({type:`phase_done`,runId:e.runId,phase:o.currentPhase})},u;try{u={status:`completed`,returnValue:await n.execute(c,e.args,o.resources.budget)}}catch(e){u=e instanceof $?{status:`killed`}:{status:`failed`,error:e.message}}return l(),t.progressEmitter.emit({type:`run_done`,runId:e.runId,...u}),u}async function ui(e,t){if(e.script)return e.script;if(e.scriptPath)return await L(e.scriptPath,`utf-8`);if(e.name){let n=await $r(M(t,J),e.name);if(!n)throw new Q(`Sub-workflow "${e.name}" not found`);return n.content}throw new Q(`workflow() requires name or scriptPath`)}var di=t((()=>{Y(),ai(),ni(),ci(),ti(),Lr()}));function fi(e){return{emit:e}}function pi(){let e=[];return{emitter:{emit:t=>void e.push(t)},events:e}}var mi=t((()=>{})),hi,gi=t((()=>{m(),hi=f({script:l().optional().describe(`Self-contained workflow script source (inline)`),name:l().optional().describe(`Named workflow, resolved to .claude/workflows/<name>.ts|js|mjs`),scriptPath:l().optional().describe(`Absolute path to an existing script file`),args:d().optional().describe(`The args global variable passed through to the script. Pass a real JSON value (object/array/string), not a JSON string.`),resumeFromRunId:l().optional().describe(`Resume the specified run, replaying the journal`),description:l().optional().describe(`A short description of this invocation (3-5 words)`),title:l().optional().describe(`Progress viewer title`),maxConcurrency:u().int().min(1).max(16).optional().describe(`Concurrency cap for agent(). Defaults to 3 (max 16). When the workflow contains heavy parallel/pipeline fan-out, you may confirm the desired concurrency with the user via AskUserQuestion before launching.`)})}));async function _i(e,t,n){let r=M(n,fr,t);await te(r,{recursive:!0});let i=M(r,`script.js`);return await ie(i,e,`utf-8`),i}var vi=t((()=>{Y()}));function yi(e){return{name:q,inputSchema:hi,isEnabled:()=>!0,isReadOnly:()=>!1,async description(){return`Execute a workflow script that orchestrates multiple subagents to complete a task`},async prompt(){return wi},renderToolUseMessage(e){return e.resumeFromRunId?`Workflow resume: ${e.resumeFromRunId}`:`Workflow: ${e.name??e.scriptPath??(e.script?`inline`:`unknown`)}`},async call(t,n,r,i){let a=e.hostFactory({context:n,canUseTool:r,parentMessage:i}),o,s;try{let e=await Ci(t,a.cwd);o=e.script,s=e.workflowFile}catch(e){return{data:{output:`Error: ${e.message}`}}}try{X(o)}catch(e){return{data:{output:`Error: script validation failed: ${e.message}`}}}let c=t.name??t.title??`workflow`,{runId:l,signal:u}=e.taskRegistrar.register({workflowName:c,...s?{workflowFile:s}:{},...t.description?{summary:t.description}:{},...a.toolUseId?{toolUseId:a.toolUseId}:{},...t.resumeFromRunId?{runId:t.resumeFromRunId}:{}},a.handle);if(!s&&t.script)try{s=await _i(t.script,l,a.cwd)}catch(t){e.logger.warn?.(`inline script persist failed: ${t.message}`)}li({script:o,...t.args===void 0?{}:{args:Si(t.args)},runId:l,workflowName:c,ports:e,host:a.handle,signal:u,cwd:a.cwd,budgetTotal:a.budgetTotal,...t.maxConcurrency===void 0?{}:{maxConcurrency:t.maxConcurrency},...t.resumeFromRunId?{resume:!0}:{}}).then(t=>bi(e,t,l)).catch(t=>e.taskRegistrar.fail(l,t.message));let d=s??`<inline run ${l}>`;return{data:{output:[`Workflow started (running in the background).`,`run_id: ${l}`,`workflow: ${c}`,`script: ${d}`,``,`You will be notified on completion. Use /workflows to view live progress.`].join(`
103
- `)}}},mapToolResultToToolResultBlockParam(e,t){return{tool_use_id:t,type:`tool_result`,content:[{type:`text`,text:e.output}]}}}}function bi(e,t,n){if(t.status===`completed`){let r=t.returnValue==null?`(no return value)`:xi(t.returnValue);e.taskRegistrar.complete(n,r)}else t.status===`failed`?e.taskRegistrar.fail(n,t.error??`workflow failed`):e.taskRegistrar.kill(n)}function xi(e){if(typeof e==`string`)return e.slice(0,500);try{return JSON.stringify(e).slice(0,500)}catch{return String(e)}}function Si(e){if(typeof e!=`string`)return e;try{let t=JSON.parse(e);return typeof t==`object`&&t?t:e}catch{return e}}async function Ci(e,t){if(e.script)return{script:e.script};if(e.scriptPath){let n=P(t,e.scriptPath);if(!Yr(t,n))throw Error(`scriptPath "${e.scriptPath}" is out of bounds (after resolve, ${n} is not within cwd ${t})`);return{script:await L(n,`utf-8`),workflowFile:n}}if(e.name){if(Xr(e.name)===null)throw Error(`Named workflow name "${e.name}" is invalid (contains path separators or is . / ..)`);let n=await $r(M(t,J),e.name);if(!n)throw Error(`Named workflow "${e.name}" not found (looked in ${J}/)`);return{script:n.content,workflowFile:n.path}}throw Error(`One of script, name, or scriptPath must be provided`)}var wi,Ti=t((()=>{Y(),ti(),di(),Lr(),Zr(),gi(),vi(),wi='Use the Workflow tool to execute a workflow script that orchestrates multiple subagents deterministically. The script runs in the background; you receive a run_id immediately and are notified on completion.\n\nProvide the script inline via "script", or reference a named workflow via "name" (resolved from .claude/workflows/), or an existing file via "scriptPath". Pass "args" as a real JSON value (object/array/string), not a stringified string.\n\nUse "resumeFromRunId" to resume a prior run — completed agent() calls replay from the journal instantly.\n\nConcurrency: default is 3 (hard ceiling 16). OMIT maxConcurrency to use 3. To set maxConcurrency to ANY value other than 3, you MUST first ask the user via AskUserQuestion — propose 3 / 6 / 9 (or other tiers matching the fan-out width) with 3 marked "(Recommended)". The ONLY exception: the user has ALREADY specified a concurrency number in this session ("use 6", "maxConcurrency 9") — then honor it without re-asking. Never silently raise concurrency above 3 just because the workflow fans out; 3 is the recommended default.\n\nScript execution model (common pitfalls — getting these wrong is the #1 cause of script errors): the script is the body of `new AsyncFunction` — NOT an ESM module, and TypeScript is NOT transpiled. Therefore:\n- Do NOT use `import` — `agent`, `parallel`, `pipeline`, `phase`, `log`, `workflow`, `args`, and `budget` are injected as parameters; reference them directly.\n- Do NOT use TS type annotations, `interface`, `enum`, `as`, or generics — the engine does not transpile, so even a .ts file with type syntax fails to parse.\n- Keep EXACTLY ONE `export const meta = {...}` (plain literal) and remove every other `export` / `export default`.\n- Return the result with a top-level `return`.\nPrefer .js / .mjs. See /ultracode for the full playbook and quality patterns.'})),Ei=r({AdapterNotFoundError:()=>Sr,AgentAdapterRegistry:()=>Cr,Budget:()=>Ur,BudgetExhaustedError:()=>Hr,DEFAULT_MAX_CONCURRENCY:()=>3,MAX_CONCURRENCY_CAP:()=>16,MAX_ITEMS_PER_CALL:()=>hr,MAX_TOTAL_AGENTS:()=>mr,ScriptError:()=>Z,Semaphore:()=>Dr,WORKFLOW_DIR_NAME:()=>J,WORKFLOW_RUNS_DIR:()=>fr,WORKFLOW_SCRIPT_EXTENSIONS:()=>pr,WORKFLOW_TOOL_NAME:()=>q,WorkflowAbortedError:()=>$,WorkflowError:()=>Q,agentCallKey:()=>zr,clampMaxConcurrency:()=>Er,createBufferingEmitter:()=>pi,createEngineContext:()=>ii,createFileJournalStore:()=>Br,createHostHandle:()=>gr,createProgressEmitter:()=>fi,createSharedResources:()=>ri,createWorkflowTool:()=>yi,extractMeta:()=>kr,isHostHandle:()=>_r,listNamedWorkflows:()=>ei,makeHooks:()=>oi,maxConcurrency:()=>Tr,parseScript:()=>X,persistInlineScript:()=>_i,resolveNamedWorkflow:()=>$r,runWorkflow:()=>li,unwrapHostHandle:()=>vr,validateAgainstSchema:()=>Gr,workflowInputSchema:()=>hi}),Di=t((()=>{dr(),Y(),br(),wr(),Or(),Lr(),Vr(),Wr(),Jr(),ti(),ni(),ai(),ci(),di(),mi(),Ti(),gi(),vi()})),Oi,ki,Ai,ji,Mi,Ni,Pi=t((()=>{Oi=`LocalMemoryRecall`,ki=100*1024,Ai=2*1024,ji=50*1024,Mi=4*1024,Ni=8*1024})),Fi,Ii,Li,Ri,zi=t((()=>{T(),Me(),_n(),C(),Sn(),b(),Ae(),Pe(),wn(),hn(),kn(),ge(),Nn(),Fn(),Be(),Ie(),Ln(),zn(),Re(),Vn(),Xn(),er(),nr(),ir(),or(),cr(),ur(),Di(),Pi(),Fi=new Set([S,je,gn,x,vn,w,q,Oi]),Ii=new Set([...Fi]),Li=new Set([z,Ne,G,pn,...On,fe,Mn,Pn,ze,K,Bn,ar,sr,lr]),Ri=new Set([...On,z,fe,Mn,pn,G,Pn,x,vn,S,w,Fe,In,Rn,Le,Ne,gn,je,rr,`LSP`,ze,q,Zn,Bn,ar,K])}));function Bi(){return`Deferred tools appear by name in <available-deferred-tools> messages.`}function Vi(e){return!(e.alwaysLoad===!0||Ri.has(e.name))}function Hi(e){return e.name}function Ui(){return Wi+Bi()+Gi}var Wi,Gi,Ki=t((()=>{zi(),Vn(),Wi=`Search for deferred tools by name or keyword. LOW PRIORITY — only use this tool when no core tool can accomplish the task. Core tools (Read, Edit, Write, Bash, Glob, Grep, Agent, WebFetch, WebSearch, Skill) are always available and should be used directly. This tool is for discovering additional capabilities like MCP tools, worktree management, agent teams (TeamCreate, TeamDelete, SendMessage), etc.
102
+ `,`utf-8`)},async truncate(t){await re(M(e,t),{recursive:!0,force:!0})}}}var Vr=t((()=>{})),Hr,Ur,Wr=t((()=>{s(),Hr=class extends Error{constructor(){super(`workflow token budget exhausted (budget.total reached the cap)`),this.name=`BudgetExhaustedError`}},Ur=class{constructor(e){c(this,`total`,void 0),c(this,`spentTokens`,0),this.total=e}spent(){return this.spentTokens}remaining(){return this.total==null?1/0:Math.max(0,this.total-this.spentTokens)}addOutputTokens(e){e>0&&(this.spentTokens+=e)}assertCanSpend(){if(this.total!=null&&this.spentTokens>=this.total)throw new Hr}}}));function Gr(e,t){let n=qr.get(t);n||(n=new Kr.Ajv({allErrors:!0,strict:!1}).compile(t),qr.set(t,n));let r=n(e);return{valid:r,errors:r?[]:(n.errors??[]).map(e=>e.message??`validation error`)}}var Kr,qr,Jr=t((()=>{Kr=n(fn(),1),qr=new WeakMap}));function Yr(e,t){let n=P(e),r=P(n,t);return r===n||r.startsWith(n+ee)}function Xr(e){return typeof e!=`string`||e.length===0||e.includes(`/`)||e.includes(`\\`)||e.includes(`\0`)||e===`.`||e===`..`?null:e}var Zr=t((()=>{}));function Qr(e){return pr.includes(e.toLowerCase())}async function $r(e,t){for(let n of pr){let r=P(e,t+n);if(!Yr(e,r))return null;try{return{path:r,content:await L(r,`utf-8`)}}catch{}}return null}async function ei(e){let t;try{t=await ne(e)}catch{return[]}return t.filter(e=>Qr(N(e).ext)).map(e=>N(e).name).sort()}var ti=t((()=>{Y(),Zr()})),Q,$,ni=t((()=>{Q=class extends Error{constructor(e){super(e),this.name=`WorkflowError`}},$=class extends Error{constructor(){super(`workflow has been aborted`),this.name=`WorkflowAbortedError`}}}));function ri(e,t){return{semaphore:new Dr(Er(t)),budget:new Ur(e),agentCountBox:{value:0},agentIdSeq:{value:0},depth:0}}function ii(e){let t=ri(e.budgetTotal,e.maxConcurrency);return{ports:e.ports,host:e.host,signal:e.signal,runId:e.runId,workflowName:e.workflowName,cwd:e.cwd,resources:t,journal:e.journal?[...e.journal]:[],journalIndex:0,journalInvalidated:!1,currentPhase:null}}var ai=t((()=>{Wr(),Or()}));function oi(e,t){let n=t=>{e.ports.progressEmitter.emit({runId:e.runId,...t})};return{agent:async(t,r={})=>{let i=e.resources;if(i.agentCountBox.value>=1e3)throw new Q(`workflow exceeds total agent cap (${mr})`);let a=i.agentIdSeq.value++,o={prompt:t,...r},s=zr(t,o),c=r.label,l=r.phase??e.currentPhase??void 0;if(!e.journalInvalidated&&e.journalIndex<e.journal.length){let t=e.journal[e.journalIndex];if(t.key===s)return e.journalIndex++,n({type:`agent_done`,agentId:a,label:c,phase:l,result:t.result}),si(t.result);e.journalInvalidated=!0,e.journal=e.journal.slice(0,e.journalIndex),await e.ports.journalStore.truncate(e.runId)}let u;try{u=await e.resources.semaphore.acquire(e.signal)}catch{throw new $}try{if(e.signal.aborted)throw new $;if(i.budget.assertCanSpend(),e.ports.taskRegistrar.pendingAction(e.runId)?.kind===`skip`)return n({type:`agent_done`,agentId:a,label:c,phase:l,result:{kind:`skipped`}}),null;e.resources.agentCountBox.value++,n({type:`agent_started`,agentId:a,label:c,phase:l});let t=e.ports.agentAdapterRegistry,r=t?{host:e.host,signal:e.signal,runId:e.runId,agentId:a,onProgress:e=>{n({type:`agent_progress`,agentId:a,label:c,phase:l,...e})},...e.ports.taskRegistrar.registerAgentAbort?{registerAgentAbort:(t,n)=>{e.ports.taskRegistrar.registerAgentAbort?.(e.runId,t,n)}}:{},...e.ports.taskRegistrar.unregisterAgentAbort?{unregisterAgentAbort:t=>{e.ports.taskRegistrar.unregisterAgentAbort?.(e.runId,t)}}:{}}:null,u=t?t.resolve(o):null,d=()=>u?u.run(o,r):e.ports.agentRunner.runAgentToResult(o,e.host),f;try{if(f=await d(),f.kind===`dead`){let t=typeof f.detail==`string`?f.detail:``;e.ports.logger.warn?.(`agent "${c??`#${a}`}" returned dead`+(f.reason?` (${f.reason})`:``)+(t?`: ${t.slice(0,150)}`:``)+`; retrying once`),f=await d()}}catch(t){if(t instanceof $)throw t;let n=t instanceof Error?t.message:String(t);e.ports.logger.warn?.(`agent "${c??`#${a}`}" threw (${n}); retrying once`);try{f=await d()}catch(e){if(e instanceof $)throw e;f={kind:`dead`,reason:`runagent-threw`,detail:e instanceof Error?e.message:String(e)}}}f.kind===`ok`&&e.resources.budget.addOutputTokens(f.usage.outputTokens),n({type:`agent_done`,agentId:a,label:c,phase:l,result:f});let p={key:s,seq:a,result:f};return e.journal.push(p),e.journalIndex++,await e.ports.journalStore.append(e.runId,p),si(f)}finally{u()}},parallel:async t=>{if(t.length>4096)throw new Q(`parallel exceeds the per-call items cap (${hr})`);return Promise.all(t.map(async(t,n)=>{try{return await t()}catch(t){return e.ports.logger.warn?.(`parallel thunk #${n} failed: ${t.message}`),null}}))},pipeline:async(t,...n)=>{if(t.length>4096)throw new Q(`pipeline exceeds the per-call items cap (${hr})`);return Promise.all(t.map(async(t,r)=>{try{let e=t;for(let i of n)e=await i(e,t,r);return e}catch(t){return e.ports.logger.warn?.(`pipeline item #${r} failed: ${t.message}`),null}}))},phase:t=>{e.currentPhase&&n({type:`phase_done`,phase:e.currentPhase}),e.currentPhase=t,n({type:`phase_started`,phase:t})},log:e=>{n({type:`log`,message:e})},workflow:async(n,r)=>{if(e.resources.depth>=1)throw new Q(`workflow() nesting allows only one level`);return t({...typeof n==`string`?{name:n}:{scriptPath:n.scriptPath},args:r})}}}function si(e){return e.kind===`ok`?e.output:null}var ci=t((()=>{Y(),ni(),Vr()}));async function li(e){let{ports:t}=e,n;try{n=X(e.script)}catch(n){let r=n.message;return t.progressEmitter.emit({type:`run_done`,runId:e.runId,status:`failed`,error:r}),{status:`failed`,error:r}}let r=e.workflowName??n.meta?.name??`workflow`,i=[],a=!1;e.resume&&!e.scriptChanged?i=await t.journalStore.read(e.runId):e.scriptChanged&&(await t.journalStore.truncate(e.runId),a=!0);let o=ii({ports:t,host:e.host,signal:e.signal,runId:e.runId,workflowName:r,cwd:e.cwd,budgetTotal:e.budgetTotal,maxConcurrency:e.maxConcurrency,journal:i});a&&(o.journalInvalidated=!0),t.progressEmitter.emit({type:`run_started`,runId:e.runId,workflowName:r,meta:n.meta});let s=async t=>{let n=await ui(t,e.cwd),r;try{r=X(n)}catch(e){throw new Q(`Sub-workflow script error: ${e.message}`)}let i=o.resources.depth;o.resources.depth+=1;try{let e=oi(o,s);return await r.execute(e,t.args,o.resources.budget)}finally{o.resources.depth=i}},c=oi(o,s),l=()=>{o.currentPhase&&t.progressEmitter.emit({type:`phase_done`,runId:e.runId,phase:o.currentPhase})},u;try{u={status:`completed`,returnValue:await n.execute(c,e.args,o.resources.budget)}}catch(e){u=e instanceof $?{status:`killed`}:{status:`failed`,error:e.message}}return l(),t.progressEmitter.emit({type:`run_done`,runId:e.runId,...u}),u}async function ui(e,t){if(e.script)return e.script;if(e.scriptPath)return await L(e.scriptPath,`utf-8`);if(e.name){let n=await $r(M(t,J),e.name);if(!n)throw new Q(`Sub-workflow "${e.name}" not found`);return n.content}throw new Q(`workflow() requires name or scriptPath`)}var di=t((()=>{Y(),ai(),ni(),ci(),ti(),Lr()}));function fi(e){return{emit:e}}function pi(){let e=[];return{emitter:{emit:t=>void e.push(t)},events:e}}var mi=t((()=>{})),hi,gi=t((()=>{m(),hi=f({script:l().optional().describe(`Self-contained workflow script source (inline)`),name:l().optional().describe(`Named workflow, resolved to .workmate/workflows/<name>.ts|js|mjs`),scriptPath:l().optional().describe(`Absolute path to an existing script file`),args:d().optional().describe(`The args global variable passed through to the script. Pass a real JSON value (object/array/string), not a JSON string.`),resumeFromRunId:l().optional().describe(`Resume the specified run, replaying the journal`),description:l().optional().describe(`A short description of this invocation (3-5 words)`),title:l().optional().describe(`Progress viewer title`),maxConcurrency:u().int().min(1).max(16).optional().describe(`Concurrency cap for agent(). Defaults to 3 (max 16). When the workflow contains heavy parallel/pipeline fan-out, you may confirm the desired concurrency with the user via AskUserQuestion before launching.`)})}));async function _i(e,t,n){let r=M(n,fr,t);await te(r,{recursive:!0});let i=M(r,`script.js`);return await ie(i,e,`utf-8`),i}var vi=t((()=>{Y()}));function yi(e){return{name:q,inputSchema:hi,isEnabled:()=>!0,isReadOnly:()=>!1,async description(){return`Execute a workflow script that orchestrates multiple subagents to complete a task`},async prompt(){return wi},renderToolUseMessage(e){return e.resumeFromRunId?`Workflow resume: ${e.resumeFromRunId}`:`Workflow: ${e.name??e.scriptPath??(e.script?`inline`:`unknown`)}`},async call(t,n,r,i){let a=e.hostFactory({context:n,canUseTool:r,parentMessage:i}),o,s;try{let e=await Ci(t,a.cwd);o=e.script,s=e.workflowFile}catch(e){return{data:{output:`Error: ${e.message}`}}}try{X(o)}catch(e){return{data:{output:`Error: script validation failed: ${e.message}`}}}let c=t.name??t.title??`workflow`,{runId:l,signal:u}=e.taskRegistrar.register({workflowName:c,...s?{workflowFile:s}:{},...t.description?{summary:t.description}:{},...a.toolUseId?{toolUseId:a.toolUseId}:{},...t.resumeFromRunId?{runId:t.resumeFromRunId}:{}},a.handle);if(!s&&t.script)try{s=await _i(t.script,l,a.cwd)}catch(t){e.logger.warn?.(`inline script persist failed: ${t.message}`)}li({script:o,...t.args===void 0?{}:{args:Si(t.args)},runId:l,workflowName:c,ports:e,host:a.handle,signal:u,cwd:a.cwd,budgetTotal:a.budgetTotal,...t.maxConcurrency===void 0?{}:{maxConcurrency:t.maxConcurrency},...t.resumeFromRunId?{resume:!0}:{}}).then(t=>bi(e,t,l)).catch(t=>e.taskRegistrar.fail(l,t.message));let d=s??`<inline run ${l}>`;return{data:{output:[`Workflow started (running in the background).`,`run_id: ${l}`,`workflow: ${c}`,`script: ${d}`,``,`You will be notified on completion. Use /workflows to view live progress.`].join(`
103
+ `)}}},mapToolResultToToolResultBlockParam(e,t){return{tool_use_id:t,type:`tool_result`,content:[{type:`text`,text:e.output}]}}}}function bi(e,t,n){if(t.status===`completed`){let r=t.returnValue==null?`(no return value)`:xi(t.returnValue);e.taskRegistrar.complete(n,r)}else t.status===`failed`?e.taskRegistrar.fail(n,t.error??`workflow failed`):e.taskRegistrar.kill(n)}function xi(e){if(typeof e==`string`)return e.slice(0,500);try{return JSON.stringify(e).slice(0,500)}catch{return String(e)}}function Si(e){if(typeof e!=`string`)return e;try{let t=JSON.parse(e);return typeof t==`object`&&t?t:e}catch{return e}}async function Ci(e,t){if(e.script)return{script:e.script};if(e.scriptPath){let n=P(t,e.scriptPath);if(!Yr(t,n))throw Error(`scriptPath "${e.scriptPath}" is out of bounds (after resolve, ${n} is not within cwd ${t})`);return{script:await L(n,`utf-8`),workflowFile:n}}if(e.name){if(Xr(e.name)===null)throw Error(`Named workflow name "${e.name}" is invalid (contains path separators or is . / ..)`);let n=await $r(M(t,J),e.name);if(!n)throw Error(`Named workflow "${e.name}" not found (looked in ${J}/)`);return{script:n.content,workflowFile:n.path}}throw Error(`One of script, name, or scriptPath must be provided`)}var wi,Ti=t((()=>{Y(),ti(),di(),Lr(),Zr(),gi(),vi(),wi='Use the Workflow tool to execute a workflow script that orchestrates multiple subagents deterministically. The script runs in the background; you receive a run_id immediately and are notified on completion.\n\nProvide the script inline via "script", or reference a named workflow via "name" (resolved from .workmate/workflows/), or an existing file via "scriptPath". Pass "args" as a real JSON value (object/array/string), not a stringified string.\n\nUse "resumeFromRunId" to resume a prior run — completed agent() calls replay from the journal instantly.\n\nConcurrency: default is 3 (hard ceiling 16). OMIT maxConcurrency to use 3. To set maxConcurrency to ANY value other than 3, you MUST first ask the user via AskUserQuestion — propose 3 / 6 / 9 (or other tiers matching the fan-out width) with 3 marked "(Recommended)". The ONLY exception: the user has ALREADY specified a concurrency number in this session ("use 6", "maxConcurrency 9") — then honor it without re-asking. Never silently raise concurrency above 3 just because the workflow fans out; 3 is the recommended default.\n\nScript execution model (common pitfalls — getting these wrong is the #1 cause of script errors): the script is the body of `new AsyncFunction` — NOT an ESM module, and TypeScript is NOT transpiled. Therefore:\n- Do NOT use `import` — `agent`, `parallel`, `pipeline`, `phase`, `log`, `workflow`, `args`, and `budget` are injected as parameters; reference them directly.\n- Do NOT use TS type annotations, `interface`, `enum`, `as`, or generics — the engine does not transpile, so even a .ts file with type syntax fails to parse.\n- Keep EXACTLY ONE `export const meta = {...}` (plain literal) and remove every other `export` / `export default`.\n- Return the result with a top-level `return`.\nPrefer .js / .mjs. See /ultracode for the full playbook and quality patterns.'})),Ei=r({AdapterNotFoundError:()=>Sr,AgentAdapterRegistry:()=>Cr,Budget:()=>Ur,BudgetExhaustedError:()=>Hr,DEFAULT_MAX_CONCURRENCY:()=>3,MAX_CONCURRENCY_CAP:()=>16,MAX_ITEMS_PER_CALL:()=>hr,MAX_TOTAL_AGENTS:()=>mr,ScriptError:()=>Z,Semaphore:()=>Dr,WORKFLOW_DIR_NAME:()=>J,WORKFLOW_RUNS_DIR:()=>fr,WORKFLOW_SCRIPT_EXTENSIONS:()=>pr,WORKFLOW_TOOL_NAME:()=>q,WorkflowAbortedError:()=>$,WorkflowError:()=>Q,agentCallKey:()=>zr,clampMaxConcurrency:()=>Er,createBufferingEmitter:()=>pi,createEngineContext:()=>ii,createFileJournalStore:()=>Br,createHostHandle:()=>gr,createProgressEmitter:()=>fi,createSharedResources:()=>ri,createWorkflowTool:()=>yi,extractMeta:()=>kr,isHostHandle:()=>_r,listNamedWorkflows:()=>ei,makeHooks:()=>oi,maxConcurrency:()=>Tr,parseScript:()=>X,persistInlineScript:()=>_i,resolveNamedWorkflow:()=>$r,runWorkflow:()=>li,unwrapHostHandle:()=>vr,validateAgainstSchema:()=>Gr,workflowInputSchema:()=>hi}),Di=t((()=>{dr(),Y(),br(),wr(),Or(),Lr(),Vr(),Wr(),Jr(),ti(),ni(),ai(),ci(),di(),mi(),Ti(),gi(),vi()})),Oi,ki,Ai,ji,Mi,Ni,Pi=t((()=>{Oi=`LocalMemoryRecall`,ki=100*1024,Ai=2*1024,ji=50*1024,Mi=4*1024,Ni=8*1024})),Fi,Ii,Li,Ri,zi=t((()=>{T(),Me(),_n(),C(),Sn(),b(),Ae(),Pe(),wn(),hn(),kn(),ge(),Nn(),Fn(),Be(),Ie(),Ln(),zn(),Re(),Vn(),Xn(),er(),nr(),ir(),or(),cr(),ur(),Di(),Pi(),Fi=new Set([S,je,gn,x,vn,w,q,Oi]),Ii=new Set([...Fi]),Li=new Set([z,Ne,G,pn,...On,fe,Mn,Pn,ze,K,Bn,ar,sr,lr]),Ri=new Set([...On,z,fe,Mn,pn,G,Pn,x,vn,S,w,Fe,In,Rn,Le,Ne,gn,je,rr,`LSP`,ze,q,Zn,Bn,ar,K])}));function Bi(){return`Deferred tools appear by name in <available-deferred-tools> messages.`}function Vi(e){return!(e.alwaysLoad===!0||Ri.has(e.name))}function Hi(e){return e.name}function Ui(){return Wi+Bi()+Gi}var Wi,Gi,Ki=t((()=>{zi(),Vn(),Wi=`Search for deferred tools by name or keyword. LOW PRIORITY — only use this tool when no core tool can accomplish the task. Core tools (Read, Edit, Write, Bash, Glob, Grep, Agent, WebFetch, WebSearch, Skill) are always available and should be used directly. This tool is for discovering additional capabilities like MCP tools, worktree management, agent teams (TeamCreate, TeamDelete, SendMessage), etc.
104
104
 
105
105
  `,Gi=` Returns matching tool names.
106
106
 
@@ -0,0 +1 @@
1
+ import{i as e,r as t}from"./prompt-CRc2QEZ5.js";t();export{e as isDeferredTool};
@@ -1,4 +1,4 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./memoize-BK3gG5ob.js";import{Cu as r,Id as i,Pd as a,Rd as o,Su as s,Vb as c,Yb as l,zd as u}from"./loadAgentsDir-C7lOqvfh.js";import{Rn as d,t as f}from"./src-P_wYS_NJ2.js";import{E as p,S as m,a as h,d as g,l as _,p as v}from"./debug-RAynG_nM.js";import{n as y,t as b}from"./execSyncWrapper-BTZJjCuv.js";import{r as x,t as S}from"./which-DzFN5TNM.js";import{basename as C}from"path";import{spawn as w,spawnSync as T}from"child_process";function E(e){return!!x(e)}function D(e){let t=C(e.split(` `)[0]??``);return A.find(e=>t.includes(e))}function O(e,t,n){return n?M.has(e)?[`-g`,`${t}:${n}`]:e===`subl`?[`${t}:${n}`]:[t]:[t]}function k(e,t){let n=N();if(!n)return!1;let r=n.split(` `),i=r[0]??n,a=r.slice(1),o=D(n);if(o){let r=O(o,e,t),s={detached:!0,stdio:`ignore`},c;return c=process.platform===`win32`?w(`${n} ${r.map(e=>`"${e}"`).join(` `)}`,{...s,shell:!0}):w(i,[...a,...r],s),c.on(`error`,e=>_(`editor spawn failed: ${e}`,{level:`error`})),c.unref(),!0}let s=d.get(process.stdout);if(!s)return!1;let c=t&&j.test(C(i));s.enterAlternateScreen();try{let r={stdio:`inherit`},o;return o=process.platform===`win32`?T(`${n} ${c?`+${t} `:``}"${e}"`,{...r,shell:!0}):T(i,[...a,...c?[`+${t}`,e]:[e]],r),o.error?(_(`editor spawn failed: ${o.error}`,{level:`error`}),!1):!0}finally{s.exitAlternateScreen()}}var A,j,M,N,P=e((()=>{n(),f(),h(),S(),A=[`code`,`cursor`,`windsurf`,`codium`,`subl`,`atom`,`gedit`,`notepad++`,`notepad`],j=/\b(vi|vim|nvim|nano|emacs|pico|micro|helix|hx)\b/,M=new Set([`code`,`cursor`,`windsurf`,`codium`]),N=t(()=>process.env.VISUAL?.trim()?process.env.VISUAL.trim():process.env.EDITOR?.trim()?process.env.EDITOR.trim():process.platform===`win32`?`start /wait notepad`:[`code`,`vi`,`nano`].find(e=>E(e)))}));function F(e){return D(e)!==void 0}function I(e){let t=g(),n=d.get(process.stdout);if(!n)throw Error(`Ink instance not found - cannot pause rendering`);let r=N();if(!r)return{content:null};try{t.statSync(e)}catch{return{content:null}}let i=!F(r);i?n.enterAlternateScreen():(n.pause(),n.suspendStdin());try{return b(`${z[r]??r} "${e}"`,{stdio:`inherit`}),{content:t.readFileSync(e,{encoding:`utf-8`})}}catch(e){if(typeof e==`object`&&e&&`status`in e&&typeof e.status==`number`){let t=e.status;if(t!==0)return{content:null,error:`${l(r)} exited with code ${t}`}}return{content:null}}finally{i?n.exitAlternateScreen():(n.resumeStdin(),n.resume())}}function L(e,t,n){let r=e;for(let[e,t]of Object.entries(n))if(t.type===`text`){let n=parseInt(e,10),a=t.content,s=r.indexOf(a);if(s!==-1){let e=i(n,o(a));r=r.slice(0,s)+e+r.slice(s+a.length)}}return r}function R(e,t){let n=g(),r=s();try{p(r,t?a(e,t):e,{encoding:`utf-8`,flush:!0});let n=I(r);if(n.content===null)return n;let i=n.content;return i.endsWith(`
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./memoize-BK3gG5ob.js";import{Mb as r,Nd as i,Pd as a,_u as o,jd as s,kd as c,vu as l,wb as u}from"./loadAgentsDir-BXtV2jiO.js";import{Rn as d,t as f}from"./src-P_wYS_NJ2.js";import{T as p,c as m,f as h,i as g,u as _,x as v}from"./debug-Dr1SjdXn.js";import{n as y,t as b}from"./execSyncWrapper-Ne33rRiD.js";import{r as x,t as S}from"./which-mplwBbc0.js";import{basename as C}from"path";import{spawn as w,spawnSync as T}from"child_process";function E(e){return!!x(e)}function D(e){let t=C(e.split(` `)[0]??``);return A.find(e=>t.includes(e))}function O(e,t,n){return n?M.has(e)?[`-g`,`${t}:${n}`]:e===`subl`?[`${t}:${n}`]:[t]:[t]}function k(e,t){let n=N();if(!n)return!1;let r=n.split(` `),i=r[0]??n,a=r.slice(1),o=D(n);if(o){let r=O(o,e,t),s={detached:!0,stdio:`ignore`},c;return c=process.platform===`win32`?w(`${n} ${r.map(e=>`"${e}"`).join(` `)}`,{...s,shell:!0}):w(i,[...a,...r],s),c.on(`error`,e=>m(`editor spawn failed: ${e}`,{level:`error`})),c.unref(),!0}let s=d.get(process.stdout);if(!s)return!1;let c=t&&j.test(C(i));s.enterAlternateScreen();try{let r={stdio:`inherit`},o;return o=process.platform===`win32`?T(`${n} ${c?`+${t} `:``}"${e}"`,{...r,shell:!0}):T(i,[...a,...c?[`+${t}`,e]:[e]],r),o.error?(m(`editor spawn failed: ${o.error}`,{level:`error`}),!1):!0}finally{s.exitAlternateScreen()}}var A,j,M,N,P=e((()=>{n(),f(),g(),S(),A=[`code`,`cursor`,`windsurf`,`codium`,`subl`,`atom`,`gedit`,`notepad++`,`notepad`],j=/\b(vi|vim|nvim|nano|emacs|pico|micro|helix|hx)\b/,M=new Set([`code`,`cursor`,`windsurf`,`codium`]),N=t(()=>process.env.VISUAL?.trim()?process.env.VISUAL.trim():process.env.EDITOR?.trim()?process.env.EDITOR.trim():process.platform===`win32`?`start /wait notepad`:[`code`,`vi`,`nano`].find(e=>E(e)))}));function F(e){return D(e)!==void 0}function I(e){let t=_(),n=d.get(process.stdout);if(!n)throw Error(`Ink instance not found - cannot pause rendering`);let i=N();if(!i)return{content:null};try{t.statSync(e)}catch{return{content:null}}let a=!F(i);a?n.enterAlternateScreen():(n.pause(),n.suspendStdin());try{return b(`${z[i]??i} "${e}"`,{stdio:`inherit`}),{content:t.readFileSync(e,{encoding:`utf-8`})}}catch(e){if(typeof e==`object`&&e&&`status`in e&&typeof e.status==`number`){let t=e.status;if(t!==0)return{content:null,error:`${r(i)} exited with code ${t}`}}return{content:null}}finally{a?n.exitAlternateScreen():(n.resumeStdin(),n.resume())}}function L(e,t,n){let r=e;for(let[e,t]of Object.entries(n))if(t.type===`text`){let n=parseInt(e,10),a=t.content,o=r.indexOf(a);if(o!==-1){let e=s(n,i(a));r=r.slice(0,o)+e+r.slice(o+a.length)}}return r}function R(e,t){let n=_(),r=o();try{p(r,t?c(e,t):e,{encoding:`utf-8`,flush:!0});let n=I(r);if(n.content===null)return n;let i=n.content;return i.endsWith(`
2
2
  `)&&!i.endsWith(`
3
3
 
4
- `)&&(i=i.slice(0,-1)),t&&(i=L(i,e,t)),{content:i}}finally{try{n.unlinkSync(r)}catch{}}}var z,B=e((()=>{u(),f(),P(),y(),v(),c(),m(),r(),z={code:`code -w`,subl:`subl --wait`}}));export{P as a,N as i,R as n,k as o,B as r,I as t};
4
+ `)&&(i=i.slice(0,-1)),t&&(i=L(i,e,t)),{content:i}}finally{try{n.unlinkSync(r)}catch{}}}var z,B=e((()=>{a(),f(),P(),y(),h(),u(),v(),l(),z={code:`code -w`,subl:`subl --wait`}}));export{P as a,N as i,R as n,k as o,B as r,I as t};