claude-code-best 2.6.8 → 2.6.9

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 (400) hide show
  1. package/dist/chunks/{AddWorkspaceDirectory-YmrkKVv2.js → AddWorkspaceDirectory-_RSNUS7K.js} +1 -1
  2. package/dist/chunks/{App-IAjCdPUn.js → App-4VqMMjIu.js} +1 -1
  3. package/dist/chunks/{ApproveApiKey-DhsT69v7.js → ApproveApiKey-B7oSxzWc.js} +1 -1
  4. package/dist/chunks/ApproveApiKey-Bmcop2Do.js +1 -0
  5. package/dist/chunks/{AssistantSessionChooser-DCUVNGfn.js → AssistantSessionChooser-Lf5l_1Dh.js} +1 -1
  6. package/dist/chunks/{BackgroundTasksDialog-Di_gH2TW.js → BackgroundTasksDialog-Ckgmqm6u.js} +1 -1
  7. package/dist/chunks/{BypassPermissionsModeDialog-BeZqE75e.js → BypassPermissionsModeDialog-DNqPpiPC.js} +1 -1
  8. package/dist/chunks/{ClaudeInChromeOnboarding-CZHktpPE.js → ClaudeInChromeOnboarding-BODZ64gw.js} +1 -1
  9. package/dist/chunks/{ClaudeMdExternalIncludesDialog-Dofr1TYr.js → ClaudeMdExternalIncludesDialog-DLI6ey3G.js} +1 -1
  10. package/dist/chunks/ClaudeMdExternalIncludesDialog-DO61Zz-S.js +1 -0
  11. package/dist/chunks/ConsoleOAuthFlow-FSHC5mxO.js +1 -0
  12. package/dist/chunks/{DesktopHandoff-C8_CDNft.js → DesktopHandoff--xyI5kTQ.js} +1 -1
  13. package/dist/chunks/{DevChannelsDialog-DkGWCFpL.js → DevChannelsDialog-DJ4mHsA_.js} +1 -1
  14. package/dist/chunks/{DiffDialog-93P95op8.js → DiffDialog-CVWUlOjm.js} +1 -1
  15. package/dist/chunks/{Doctor-Zd0UaR5d.js → Doctor-DVoFX-9y.js} +1 -1
  16. package/dist/chunks/Doctor-Dcntgp5Z.js +1 -0
  17. package/dist/chunks/{ExitFlow-4edARxmd.js → ExitFlow-BKzQPr75.js} +1 -1
  18. package/dist/chunks/{Feedback-CZY-BikO.js → Feedback-hFZwDSRp.js} +1 -1
  19. package/dist/chunks/Grove-Cmcsx2UE.js +1 -0
  20. package/dist/chunks/{Grove-TYf1glGP.js → Grove-G0DtwY22.js} +1 -1
  21. package/dist/chunks/{HybridTransport-BNexuwcN.js → HybridTransport-xN03sWrt.js} +1 -1
  22. package/dist/chunks/{ITermBackend-DuomVpsD.js → ITermBackend-DzN3ZWds.js} +1 -1
  23. package/dist/chunks/{InvalidConfigDialog-Byury3Zx.js → InvalidConfigDialog-Iy4Su1Lm.js} +1 -1
  24. package/dist/chunks/{InvalidSettingsDialog-B8_0AvWo.js → InvalidSettingsDialog-dx4y_nY-.js} +1 -1
  25. package/dist/chunks/{MCPConnectionManager-xL_wQCda.js → MCPConnectionManager-kVO-4BcA.js} +1 -1
  26. package/dist/chunks/{McpParsingWarnings-C6u4RM2a.js → McpParsingWarnings-D420-W8M.js} +1 -1
  27. package/dist/chunks/{MessageSelector-DAyH1noQ.js → MessageSelector-CDVC2CAj.js} +1 -1
  28. package/dist/chunks/{Messages-QH8_sB13.js → Messages-C5gVVVmY.js} +2 -2
  29. package/dist/chunks/{Onboarding-XWhelEBr.js → Onboarding-BkidUre_.js} +1 -1
  30. package/dist/chunks/{OverageCreditUpsell-BvPz1jLU.js → OverageCreditUpsell-DoRUucoN.js} +1 -1
  31. package/dist/chunks/{PluginSettings-D1YHfrE1.js → PluginSettings-DhpNtjTm.js} +1 -1
  32. package/dist/chunks/{PromptInputFooterSuggestions-rqUoa9Ch.js → PromptInputFooterSuggestions-BnpXzkW9.js} +1 -1
  33. package/dist/chunks/{PromptInputHelpMenu-OTViHSR0.js → PromptInputHelpMenu-DKbiO4C0.js} +1 -1
  34. package/dist/chunks/{QueryEngine-DigBggXq.js → QueryEngine-J15EOjWx.js} +1 -1
  35. package/dist/chunks/REPL-Dk3Ics9i.js +1 -0
  36. package/dist/chunks/{REPL-D2p-vgct.js → REPL-nrJ13J1o.js} +6 -6
  37. package/dist/chunks/{RemoteCallout-CCIWIrd-.js → RemoteCallout-DGXIcTKv.js} +1 -1
  38. package/dist/chunks/{RemoteSessionManager-Dx81p5dH.js → RemoteSessionManager-3KsuTCZM.js} +1 -1
  39. package/dist/chunks/{ResumeConversation-73r3Zh5P.js → ResumeConversation-kS7lkjJm.js} +1 -1
  40. package/dist/chunks/{SSETransport-C9hd2v-w.js → SSETransport-Cy1rXP6E.js} +1 -1
  41. package/dist/chunks/SearchExtraToolsTool-C998WSxs.js +1 -0
  42. package/dist/chunks/SentryErrorBoundary-BJLT-ebr.js +1 -0
  43. package/dist/chunks/{SentryErrorBoundary-z8tMb-zO.js → SentryErrorBoundary-B_6MfzRa.js} +1 -1
  44. package/dist/chunks/{Settings-D9qdaMe5.js → Settings-DBopjMkN.js} +2 -2
  45. package/dist/chunks/{TeleportProgress-CPXN7u3Z.js → TeleportProgress-CQUN_zoe.js} +1 -1
  46. package/dist/chunks/{TeleportRepoMismatchDialog-CiyXjTxq.js → TeleportRepoMismatchDialog-CPquWrd-.js} +1 -1
  47. package/dist/chunks/{TeleportResumeWrapper-Dao8ktHk.js → TeleportResumeWrapper-NIFNCHIO.js} +1 -1
  48. package/dist/chunks/{ThemePicker-CFYFNnPp.js → ThemePicker-DnK0DStD.js} +1 -1
  49. package/dist/chunks/{TmuxBackend-B5DBBugq.js → TmuxBackend-C00k5RF9.js} +1 -1
  50. package/dist/chunks/{TrustDialog-DtIXHMR_.js → TrustDialog-CUnvtDeS.js} +1 -1
  51. package/dist/chunks/{ValidationErrorsList-BK0wOS55.js → ValidationErrorsList-CJbO1qub.js} +1 -1
  52. package/dist/chunks/{WelcomeV2-BjUbi9vp.js → WelcomeV2-BBFGft_e.js} +1 -1
  53. package/dist/chunks/{WindowsTerminalBackend-DFLLlAOp.js → WindowsTerminalBackend-DSsgxuNK.js} +1 -1
  54. package/dist/chunks/{add-dir-JoVgNFOk.js → add-dir-BPqd010H.js} +1 -1
  55. package/dist/chunks/{agentDisplay-B3RjWR-3.js → agentDisplay-C0B1b_90.js} +1 -1
  56. package/dist/chunks/{agents-UqS5PhD2.js → agents-CYs7WGHP.js} +1 -1
  57. package/dist/chunks/{agents-BUyLUAIu.js → agents-DMzVeRly.js} +1 -1
  58. package/dist/chunks/{ant-Bq1wIvnP.js → ant-BO0Hmoii.js} +1 -1
  59. package/dist/chunks/api-B2HW-oZI.js +1 -0
  60. package/dist/chunks/{api-O4eHGLTY.js → api-DLLVkmRJ.js} +1 -1
  61. package/dist/chunks/asciicast-C3nf97NR.js +1 -0
  62. package/dist/chunks/{asciicast-o5Zg4dJt.js → asciicast-DIsaWcsJ.js} +1 -1
  63. package/dist/chunks/assistant-BmM44yln.js +1 -0
  64. package/dist/chunks/{assistant-CMIbt3Ir.js → assistant-CHp4-EaF.js} +1 -1
  65. package/dist/chunks/{assistant-D5Tg_1ry.js → assistant-_dIpsqHM.js} +1 -1
  66. package/dist/chunks/{auth-D3SKo0wT.js → auth-DelyQc8g.js} +1 -1
  67. package/dist/chunks/auth-ndSNSeqS.js +1 -0
  68. package/dist/chunks/{autoMode-BIVJlkBM.js → autoMode-D3-o7xPK.js} +1 -1
  69. package/dist/chunks/{autonomy-Mi7Fkq1J.js → autonomy-CzSRoxjl.js} +1 -1
  70. package/dist/chunks/{autonomy-BYi6z9LD.js → autonomy-tTAucjip.js} +1 -1
  71. package/dist/chunks/{autonomyPanel-D_GsUMOf.js → autonomyPanel-DcK8N52K.js} +1 -1
  72. package/dist/chunks/{backgroundHousekeeping-BG_UYxFF.js → backgroundHousekeeping-Bbkz61_-.js} +2 -2
  73. package/dist/chunks/backgroundHousekeeping-DVo3ndZr.js +1 -0
  74. package/dist/chunks/{branch-BC-K45fw.js → branch-ZJF4xAh9.js} +1 -1
  75. package/dist/chunks/{bridge-DBteRzgS.js → bridge-C6gSt_32.js} +2 -2
  76. package/dist/chunks/{bridgeConfig-C_GoD1k5.js → bridgeConfig-DXUNQp2l.js} +1 -1
  77. package/dist/chunks/bridgeConfig-ZcbBdhji.js +1 -0
  78. package/dist/chunks/bridgeEnabled-D5qCI5v2.js +1 -0
  79. package/dist/chunks/{bridgeEnabled-cSK8a7tN.js → bridgeEnabled-G6vxQV-7.js} +1 -1
  80. package/dist/chunks/bridgeMain-B4Zv8UOe.js +1 -0
  81. package/dist/chunks/{bridgeMain-QbfEOTqV.js → bridgeMain-DlnIQOtX.js} +6 -6
  82. package/dist/chunks/{bridgeMessaging-CqXQzew4.js → bridgeMessaging-mek-AaFi.js} +1 -1
  83. package/dist/chunks/{bridgePointer-FvAMj3re.js → bridgePointer-B2FPGDWR.js} +1 -1
  84. package/dist/chunks/{btw-DBtPlEWc.js → btw-Cz2lyle-.js} +1 -1
  85. package/dist/chunks/{buddy-BYwTgNnf.js → buddy-BMqKttFw.js} +1 -1
  86. package/dist/chunks/{bypassPermissionsKillswitch-DkYLp9m0.js → bypassPermissionsKillswitch-BxvX48jr.js} +1 -1
  87. package/dist/chunks/caches-D_W3nCFE.js +1 -0
  88. package/dist/chunks/{caches-DGW9ovtw.js → caches-wtRUk5y5.js} +2 -2
  89. package/dist/chunks/{ccrClient-B9pi3b8Y.js → ccrClient-BOrmrmgF.js} +1 -1
  90. package/dist/chunks/changeDetector-CUsHUdul.js +1 -0
  91. package/dist/chunks/channelNotification-CLVU5AuO.js +1 -0
  92. package/dist/chunks/{channelNotification-n7Avue-9.js → channelNotification-D8do6HUN.js} +1 -1
  93. package/dist/chunks/{chrome-BwZPfW9Z.js → chrome-JF2BXNK6.js} +1 -1
  94. package/dist/chunks/clear-BP-G1JWa.js +1 -0
  95. package/dist/chunks/client-BHfY6SC5.js +1 -0
  96. package/dist/chunks/{color-BsBrog6H.js → color-oh8CGhkI.js} +1 -1
  97. package/dist/chunks/commands-E0eNJ_XZ.js +1 -0
  98. package/dist/chunks/commitAttribution-B4DOgUS7.js +1 -0
  99. package/dist/chunks/{commitAttribution-q7SEukgl.js → commitAttribution-CUdm_sRl.js} +1 -1
  100. package/dist/chunks/{compact-DiY1w7pT.js → compact-R6vMbGQQ.js} +1 -1
  101. package/dist/chunks/{companion-D18UNnC7.js → companion-ClxqTyG9.js} +1 -1
  102. package/dist/chunks/{config-D3QKcEKz.js → config-BQ-MayP6.js} +1 -1
  103. package/dist/chunks/{config-CSHnElBp.js → config-CPK9PlWS.js} +1 -1
  104. package/dist/chunks/{context-DnyYrN2X.js → context-CWfsKYEB.js} +1 -1
  105. package/dist/chunks/{context-noninteractive-CFlod2Eg.js → context-noninteractive-BJ4hE3MX.js} +1 -1
  106. package/dist/chunks/context-noninteractive-D1Kxn5e0.js +1 -0
  107. package/dist/chunks/conversation-C23rDJe3.js +1 -0
  108. package/dist/chunks/{conversation-CRoOMglD.js → conversation-DizpkPtq.js} +1 -1
  109. package/dist/chunks/{copy-CHGX-YpC.js → copy-BuPCS2HG.js} +1 -1
  110. package/dist/chunks/{createSSHSession-Bf-8h3Sw.js → createSSHSession-Di9Je4Th.js} +1 -1
  111. package/dist/chunks/createSession-Bsa0VJKS.js +1 -0
  112. package/dist/chunks/{createSession-rRZIkjl3.js → createSession-D6v0lBtG.js} +1 -1
  113. package/dist/chunks/{cronJitterConfig-DmBBJDTf.js → cronJitterConfig-By18m-PD.js} +1 -1
  114. package/dist/chunks/{crossProjectResume-BQxLBpDD.js → crossProjectResume-C4YT2T6P.js} +1 -1
  115. package/dist/chunks/{datadog-Bb65d6yd.js → datadog-BFSdlK6C.js} +1 -1
  116. package/dist/chunks/datadog-MUvg76p3.js +1 -0
  117. package/dist/chunks/{desktop-DiCA6RUU.js → desktop-Bd-JHrBo.js} +1 -1
  118. package/dist/chunks/{diff-BvLQ-t8P.js → diff-DGmINgOc.js} +1 -1
  119. package/dist/chunks/{directoryCompletion-DP_4B1GL.js → directoryCompletion-D7EGwonO.js} +1 -1
  120. package/dist/chunks/{doctor-bmTXLycZ.js → doctor-DQ42RQPx.js} +1 -1
  121. package/dist/chunks/{effort-CSTwkB2B.js → effort-E6XjzPYR.js} +1 -1
  122. package/dist/chunks/entry-Di8oWZUk.js +14 -0
  123. package/dist/chunks/{envLessBridgeConfig-DJJKeDBT.js → envLessBridgeConfig-BNvozi46.js} +1 -1
  124. package/dist/chunks/envLessBridgeConfig-CUTBQKDY.js +1 -0
  125. package/dist/chunks/{exit-eirVuF-n.js → exit-CVlpMwCq.js} +1 -1
  126. package/dist/chunks/{export-CcJD8r8U.js → export-CXcPQd0T.js} +1 -1
  127. package/dist/chunks/{exportRenderer-DtezFcml.js → exportRenderer-B9WXgMV2.js} +1 -1
  128. package/dist/chunks/{extra-usage-CBcgeIcJ.js → extra-usage-B2KmuAZe.js} +1 -1
  129. package/dist/chunks/extra-usage-DVtAa1zD.js +1 -0
  130. package/dist/chunks/{extra-usage-core-DWM0Q56J.js → extra-usage-core-B20tawuN.js} +1 -1
  131. package/dist/chunks/{extra-usage-noninteractive-BvJEi4WX.js → extra-usage-noninteractive-DZRe98BZ.js} +1 -1
  132. package/dist/chunks/{extraUsage-CWde-Mi0.js → extraUsage-CxqJdnGC.js} +1 -1
  133. package/dist/chunks/extractMemories-8uB606Y0.js +1 -0
  134. package/dist/chunks/{fast-DQyJ7c7s.js → fast-CPmJ2bp3.js} +1 -1
  135. package/dist/chunks/fast-DTGg3pRh.js +1 -0
  136. package/dist/chunks/{feedback-BzBBKT2y.js → feedback-4GY3ahvw.js} +1 -1
  137. package/dist/chunks/{firstPartyEventLogger-BOHIpp-w.js → firstPartyEventLogger-CISUrAsf.js} +1 -1
  138. package/dist/chunks/{flushGate-DeCDhkKp.js → flushGate-Dr8sMjB7.js} +1 -1
  139. package/dist/chunks/gates-BbF5S-Dy.js +1 -0
  140. package/dist/chunks/{gates-CAVdjC23.js → gates-DI4pxvrD.js} +1 -1
  141. package/dist/chunks/{gemini-CFrOUVS4.js → gemini-Dcfosr2Z.js} +1 -1
  142. package/dist/chunks/{generateRecap-Bcp5DiiO.js → generateRecap-CH_fgtxk.js} +1 -1
  143. package/dist/chunks/{generateSessionName-DeFGkHct.js → generateSessionName-DO0R__8w.js} +1 -1
  144. package/dist/chunks/{githubRepoPathMapping-B07Wb07_.js → githubRepoPathMapping-D5I8CVDz.js} +1 -1
  145. package/dist/chunks/{grok-DtidcVWD.js → grok-X0FzcE6Y.js} +1 -1
  146. package/dist/chunks/{growthbook-gLwBDK-r.js → growthbook-DZPT2JzB.js} +1 -1
  147. package/dist/chunks/{heapdump-BxQYlnPR.js → heapdump-Cq6i0wJH.js} +1 -1
  148. package/dist/chunks/{help-Bi0sABuv.js → help-B8ddA-Ec.js} +1 -1
  149. package/dist/chunks/{hooks-Cc_DxF9N.js → hooks-CvFNccdv.js} +1 -1
  150. package/dist/chunks/hooks-gwB4Eotj.js +1 -0
  151. package/dist/chunks/{hostAdapter-D9_d4gU0.js → hostAdapter-D3s4JFk-.js} +1 -1
  152. package/dist/chunks/{ide-3wDIOoZF.js → ide-CzxV5_D7.js} +1 -1
  153. package/dist/chunks/{inboundAttachments-DPMETKd6.js → inboundAttachments-B3ZTyNKF.js} +1 -1
  154. package/dist/chunks/inboundAttachments-DxrrrqBW.js +1 -0
  155. package/dist/chunks/{initReplBridge-BWP41EGm.js → initReplBridge-DWpGy3aE.js} +1 -1
  156. package/dist/chunks/{insights-w7qM4YyA.js → insights-DiWlKgVQ.js} +1 -1
  157. package/dist/chunks/{install-N2FgArWv.js → install-BFpg1zm1.js} +1 -1
  158. package/dist/chunks/{install-github-app-By39Zi78.js → install-github-app-BUCGGSw0.js} +1 -1
  159. package/dist/chunks/{install-slack-app-CVwZphU-.js → install-slack-app-D5JDqzbs.js} +1 -1
  160. package/dist/chunks/{instrumentation-BkLEupDC.js → instrumentation--BToLJT9.js} +3 -3
  161. package/dist/chunks/{job-CgBE27O7.js → job-mUyxSEc2.js} +1 -1
  162. package/dist/chunks/{keybindings-DHXJzU3E.js → keybindings-D4DbE4G0.js} +1 -1
  163. package/dist/chunks/{lang-DLneRt1b.js → lang-cMcnaxAR.js} +1 -1
  164. package/dist/chunks/language-DC6bsdvI.js +1 -0
  165. package/dist/chunks/{language-BVAzlrRz.js → language-sTn9sA3E.js} +1 -1
  166. package/dist/chunks/{launchAgentsPlatform-CtfK0qPa.js → launchAgentsPlatform-CAfyCAsQ.js} +1 -1
  167. package/dist/chunks/{launchAutofixPr-CQBv0rQ0.js → launchAutofixPr-CSMamZS6.js} +1 -1
  168. package/dist/chunks/{launchLocalMemory-BNE09TKr.js → launchLocalMemory-nYAwNsNT.js} +1 -1
  169. package/dist/chunks/{launchLocalVault-Dw_NJUnd.js → launchLocalVault-yPp8S-tG.js} +1 -1
  170. package/dist/chunks/{launchMemoryStores-CRRB6Z5A.js → launchMemoryStores-Dk3SXucB.js} +1 -1
  171. package/dist/chunks/{launchOnboarding-nMAF5iv7.js → launchOnboarding-BoqmHyRx.js} +1 -1
  172. package/dist/chunks/{launchSchedule-Akq1AmK8.js → launchSchedule-C2HBjD6C.js} +1 -1
  173. package/dist/chunks/{launchSkillStore-Zwtasj13.js → launchSkillStore-B5Yjvi-k.js} +1 -1
  174. package/dist/chunks/{launchTeleport-BzlIYyll.js → launchTeleport-BayvAnwh.js} +1 -1
  175. package/dist/chunks/{launchVault-BevXlxJB.js → launchVault-BszsgPbZ.js} +1 -1
  176. package/dist/chunks/loadAgentsDir-6_9ZFegv.js +1 -0
  177. package/dist/chunks/{loadAgentsDir-DF6FgRn-.js → loadAgentsDir-Cl2w3uvH.js} +53 -53
  178. package/dist/chunks/{loadPluginHooks-DBHkyJaj.js → loadPluginHooks-YHtjByxm.js} +1 -1
  179. package/dist/chunks/{localSearch-v4itMlCM.js → localSearch-CpeqVibs.js} +1 -1
  180. package/dist/chunks/localSearch-DbEm6f3k.js +1 -0
  181. package/dist/chunks/login-D2x89UCR.js +1 -0
  182. package/dist/chunks/{login-CKodBzyZ.js → login-TVtq34WQ.js} +1 -1
  183. package/dist/chunks/{logoV2Utils-VebeEs7Y.js → logoV2Utils-DwaRnvOY.js} +1 -1
  184. package/dist/chunks/logout-BBPihkXp.js +1 -0
  185. package/dist/chunks/{magicDocs-uX5n3NKh.js → magicDocs-_yNWB88A.js} +1 -1
  186. package/dist/chunks/{main-Cd_i0ZPo.js → main-gTbhsbIs.js} +15 -15
  187. package/dist/chunks/{mappers-CPL2ni36.js → mappers-COd8OOml.js} +1 -1
  188. package/dist/chunks/{mcp-Dhp1SaId.js → mcp-CChzTC5v.js} +2 -2
  189. package/dist/chunks/{mcp-Ci_TbB5m.js → mcp-D-0wE0nJ.js} +1 -1
  190. package/dist/chunks/{mcp-DeWOD4B4.js → mcp-DoraEndj.js} +1 -1
  191. package/dist/chunks/{mcpServer-CPJo2eKm.js → mcpServer-CpBN77YB.js} +1 -1
  192. package/dist/chunks/{mcpServer-CTuPkyD6.js → mcpServer-Wd9rZG_E.js} +1 -1
  193. package/dist/chunks/{memory-enMuKEnU.js → memory-I21QZZ9h.js} +1 -1
  194. package/dist/chunks/{model-4f3U2YMu.js → model-BrHh21Db.js} +1 -1
  195. package/dist/chunks/model-C6_WjCy0.js +1 -0
  196. package/dist/chunks/{onChangeAppState-DxTGoS7j.js → onChangeAppState-Cn_HSmmQ.js} +1 -1
  197. package/dist/chunks/{openai-CwG_KpH1.js → openai-BD2V4lHN.js} +1 -1
  198. package/dist/chunks/{overageCreditGrant-CCkJVN9k.js → overageCreditGrant-B47t5a73.js} +1 -1
  199. package/dist/chunks/{passes-O0VEQz1a.js → passes-DAOPYX0C.js} +1 -1
  200. package/dist/chunks/{path-C4kbwvSH.js → path-B3lx7yHn.js} +1 -1
  201. package/dist/chunks/{paths-o5iA-EnQ.js → paths-q1-Ni8Oh.js} +3 -3
  202. package/dist/chunks/{permissions-BtYQvivG.js → permissions-BmxTU-Pk.js} +1 -1
  203. package/dist/chunks/{pipeTransport-BEfqa7Uh.js → pipeTransport-DnHE3axn.js} +1 -1
  204. package/dist/chunks/{plan-Jw4GjVL0.js → plan-4dmnQ9bv.js} +1 -1
  205. package/dist/chunks/{plugin-DZq0voFR.js → plugin-CG7lJIpf.js} +1 -1
  206. package/dist/chunks/{pluginAutoupdate-D19vNoOp.js → pluginAutoupdate-CPLuidh-.js} +1 -1
  207. package/dist/chunks/{pluginBlocklist-DeX8I4dK.js → pluginBlocklist-BHxIUqu4.js} +1 -1
  208. package/dist/chunks/{pluginCliCommands-CMgqxOaT.js → pluginCliCommands-BcDIvxR3.js} +1 -1
  209. package/dist/chunks/{pluginFlagging-DFLE5fkh.js → pluginFlagging-Dh6rYOvj.js} +1 -1
  210. package/dist/chunks/{pluginOperations-BTz69m3_.js → pluginOperations-fdLcp72i.js} +1 -1
  211. package/dist/chunks/{pluginStartupCheck-CWWKwD5F.js → pluginStartupCheck-Dy7EckW4.js} +1 -1
  212. package/dist/chunks/pluginStartupCheck-fyqW-stg.js +1 -0
  213. package/dist/chunks/{plugins-BPUnAc0r.js → plugins-C3-iYKTp.js} +1 -1
  214. package/dist/chunks/policyLimits-DUGrXcje.js +1 -0
  215. package/dist/chunks/{pollConfig-DyHumJli.js → pollConfig-BGXMaSla.js} +1 -1
  216. package/dist/chunks/{poor-CHHZIPDW.js → poor-CxAil0Mi.js} +1 -1
  217. package/dist/chunks/poorMode-BkPHRLuG.js +1 -0
  218. package/dist/chunks/{poorMode-7N6J6YN2.js → poorMode-DFcYVnMT.js} +1 -1
  219. package/dist/chunks/{print-QCXJDmz0.js → print-Cog1o-Tw.js} +4 -4
  220. package/dist/chunks/{privacy-settings-DR0_P3JF.js → privacy-settings-D6g7p6sB.js} +1 -1
  221. package/dist/chunks/{processBashCommand-CkqKsBSD.js → processBashCommand-DqgujTR4.js} +1 -1
  222. package/dist/chunks/{processSlashCommand-DIk_hLHW.js → processSlashCommand-DUPS9Xx3.js} +1 -1
  223. package/dist/chunks/prompt-B-8CD-W_.js +1 -0
  224. package/dist/chunks/{prompt-DiHksuOs.js → prompt-BmOnuQfF.js} +1 -1
  225. package/dist/chunks/prompt-Da3gIGA8.js +1 -0
  226. package/dist/chunks/{promptEditor-B3S5E5Q7.js → promptEditor-ClGwMkWl.js} +1 -1
  227. package/dist/chunks/{protocolHandler-D1XT2l3j.js → protocolHandler--b0d38gF.js} +1 -1
  228. package/dist/chunks/{rate-limit-options-DHh1ksB5.js → rate-limit-options-DD2ZRREl.js} +1 -1
  229. package/dist/chunks/{rcDebugLog-BNojB_eB.js → rcDebugLog-fhwD4wm-.js} +1 -1
  230. package/dist/chunks/{referral-BADm5sBf.js → referral-rRvT6UDX.js} +1 -1
  231. package/dist/chunks/{refresh-D48fjYJ4.js → refresh-C7S_6LOQ.js} +1 -1
  232. package/dist/chunks/{registerProtocol-Dzmi6VC4.js → registerProtocol-Bu_tz5Au.js} +1 -1
  233. package/dist/chunks/{registry-CEu_N3dS.js → registry-Bk0vdx_8.js} +1 -1
  234. package/dist/chunks/{release-notes-Dr61jYDO.js → release-notes-BShc_V-B.js} +1 -1
  235. package/dist/chunks/{releaseNotes-5SV7C5aV.js → releaseNotes-D3wZdQVZ.js} +2 -2
  236. package/dist/chunks/{reload-plugins-BxuE-21F.js → reload-plugins-CpytFAAC.js} +1 -1
  237. package/dist/chunks/{remote-env-BaQjT5em.js → remote-env-B9Of1v31.js} +1 -1
  238. package/dist/chunks/{remoteBridgeCore-B8MjcW6f.js → remoteBridgeCore-BXp6nJ8q.js} +1 -1
  239. package/dist/chunks/{remoteControlServer-BvoNcg9D.js → remoteControlServer-BvlTaHu4.js} +1 -1
  240. package/dist/chunks/{rename-B3q0tgmd.js → rename-DhTddAd7.js} +1 -1
  241. package/dist/chunks/{resume-BSGOqus7.js → resume-DwVeFqnc.js} +1 -1
  242. package/dist/chunks/{runtimeObserver-Bb6wSUMJ.js → runtimeObserver-BtgDP8Gz.js} +1 -1
  243. package/dist/chunks/{runtimeObserver-BbwUiToa.js → runtimeObserver-dtT0QHYO.js} +2 -2
  244. package/dist/chunks/sandbox-adapter-Cm8kCM_U.js +1 -0
  245. package/dist/chunks/{sandbox-toggle-L7YPKXba.js → sandbox-toggle-CG2vZNAb.js} +1 -1
  246. package/dist/chunks/searchExtraTools-D-RZ9DId.js +1 -0
  247. package/dist/chunks/{sentry-DG3ru8XE.js → sentry-DFk8bzvt.js} +1 -1
  248. package/dist/chunks/{session-B5wA2K9M.js → session-DifFcUdR.js} +1 -1
  249. package/dist/chunks/{sessionDiscovery-DijWFNjj.js → sessionDiscovery-CRbLIQv1.js} +1 -1
  250. package/dist/chunks/sessionFileAccessHooks-Bixkjai4.js +1 -0
  251. package/dist/chunks/{sessionMemory-CeWjRuFL.js → sessionMemory-BdptRKL8.js} +1 -1
  252. package/dist/chunks/sessionMemory-T1K_mJRE.js +1 -0
  253. package/dist/chunks/sessionMemoryUtils-q3xRtP-z.js +1 -0
  254. package/dist/chunks/{sessionObserver-CsDT2GnB.js → sessionObserver-D3vw6SJ_.js} +1 -1
  255. package/dist/chunks/sessionObserver-i_3day_6.js +1 -0
  256. package/dist/chunks/sessionStorage-CusaYoh0.js +1 -0
  257. package/dist/chunks/sessionStoragePortable-DJZ_6cL8.js +3 -0
  258. package/dist/chunks/{sessionTitle-CxmvZO71.js → sessionTitle-DnvlYJ-c.js} +1 -1
  259. package/dist/chunks/{sessionTracing-Cy5dAplG.js → sessionTracing-BkzKJi0v.js} +1 -1
  260. package/dist/chunks/{settingsSync-54E8xV8N.js → settingsSync-CHZVpM34.js} +1 -1
  261. package/dist/chunks/{setup-GJtdESQj.js → setup-BfecYO-n.js} +1 -1
  262. package/dist/chunks/{setup-B5CMpp0c.js → setup-BpwYOhci.js} +2 -2
  263. package/dist/chunks/{setup-KWELOokh.js → setup-GxlEx1KG.js} +1 -1
  264. package/dist/chunks/{shadowedRuleDetection-C4NGjljb.js → shadowedRuleDetection-FNzEipG0.js} +1 -1
  265. package/dist/chunks/{sideQuestion-DBrzdgkl.js → sideQuestion-Bfa0SZn5.js} +1 -1
  266. package/dist/chunks/sink-BSwQ045N.js +1 -0
  267. package/dist/chunks/{sink-BKc24wdw.js → sink-DpAjuilF.js} +1 -1
  268. package/dist/chunks/{sinks-BTS1DWM4.js → sinks-C37Xl5c3.js} +2 -2
  269. package/dist/chunks/sinks-DHHmQJi-.js +1 -0
  270. package/dist/chunks/{skill-learning-C5NrosiL.js → skill-learning-BSeEbCnP.js} +1 -1
  271. package/dist/chunks/{skillChangeDetector-NJrEtU47.js → skillChangeDetector-BEDBRGbY.js} +1 -1
  272. package/dist/chunks/{skillGapStore-D1rkePoo.js → skillGapStore-B4GmZRJ0.js} +2 -2
  273. package/dist/chunks/{skillGapStore-uXpRqLGG.js → skillGapStore-BCO6YB3H.js} +1 -1
  274. package/dist/chunks/{skillGenerator-Deog7yBO.js → skillGenerator-QgDWAvzK.js} +2 -2
  275. package/dist/chunks/skillLearning-CFYgFRPE.js +1 -0
  276. package/dist/chunks/skillLearning-en7AuVDZ.js +1 -0
  277. package/dist/chunks/{skillPanel-Bx63GX9w.js → skillPanel-srZjMIbC.js} +3 -3
  278. package/dist/chunks/{skillSearchPanel-CM5EZGkH.js → skillSearchPanel-DTvHcwNK.js} +2 -2
  279. package/dist/chunks/{skills-JvC7Ms0P.js → skills-BlVUkWg4.js} +1 -1
  280. package/dist/chunks/{sprites-YBiqlYch.js → sprites-QO9r_mXk.js} +1 -1
  281. package/dist/chunks/{stats-BJMKNvVK.js → stats-DdXM-u7l.js} +1 -1
  282. package/dist/chunks/{status-DAJ28yxZ.js → status-BIZWtZqI.js} +1 -1
  283. package/dist/chunks/{statusNoticeHelpers-B7nbsqLz.js → statusNoticeHelpers-9sIAjiE6.js} +1 -1
  284. package/dist/chunks/{tag-B4y7cBqH.js → tag-DDJ8pAsl.js} +1 -1
  285. package/dist/chunks/{tasks-CSye58Ap.js → tasks-DYt6udr3.js} +1 -1
  286. package/dist/chunks/{teamHelpers-BFZ4eVwW.js → teamHelpers-BJuKEuyS.js} +1 -1
  287. package/dist/chunks/teamHelpers-Cw5dPQor.js +1 -0
  288. package/dist/chunks/teammateModeSnapshot-BXC7ssXX.js +1 -0
  289. package/dist/chunks/{teammateModeSnapshot-DXc2vyo2.js → teammateModeSnapshot-Zp1weNIZ.js} +1 -1
  290. package/dist/chunks/{teleport-NN6zSxxe.js → teleport-DkoFG3EI.js} +1 -1
  291. package/dist/chunks/{templateJobs-DAVqqU0g.js → templateJobs-V2-TVeGE.js} +1 -1
  292. package/dist/chunks/{terminalSetup-DqL65XR2.js → terminalSetup-DMUDhXur.js} +1 -1
  293. package/dist/chunks/{terminalSetup-jZKBoPTc.js → terminalSetup-l0Vv_v1c.js} +1 -1
  294. package/dist/chunks/{theme-DPv2L3ut.js → theme-Dm1yCDce.js} +1 -1
  295. package/dist/chunks/thinkback-D1mk7cq1.js +1 -0
  296. package/dist/chunks/{thinkback-tcfR5Uod.js → thinkback-DQAZE5SA.js} +1 -1
  297. package/dist/chunks/{thinkback-play-D_uOESmO.js → thinkback-play-BJcGmc9X.js} +1 -1
  298. package/dist/chunks/{toolEventObserver-D6ZTtdh_.js → toolEventObserver-BgkqkNwy.js} +1 -1
  299. package/dist/chunks/{toolEventObserver-CtApZXry.js → toolEventObserver-C-BImvCz.js} +1 -1
  300. package/dist/chunks/toolPool-DNH5H4Jg.js +1 -0
  301. package/dist/chunks/{toolPool-DFpa-yul.js → toolPool-DYvz_Mjt.js} +1 -1
  302. package/dist/chunks/{trustedDevice-DsgCQRsJ.js → trustedDevice-BDrK9AQ6.js} +1 -1
  303. package/dist/chunks/{trustedDevice-Bxn7WW5C.js → trustedDevice-CXsk3eij.js} +1 -1
  304. package/dist/chunks/{ultrareviewCommand-BfuSrdXz.js → ultrareviewCommand-Bc8hMzHz.js} +1 -1
  305. package/dist/chunks/undercover-DUrQYxYo.js +1 -0
  306. package/dist/chunks/{undercover-CM8zTx5g.js → undercover-kRoI_nlN.js} +1 -1
  307. package/dist/chunks/{updateCCB-DTArxdyR.js → updateCCB-BPGNN7VA.js} +1 -1
  308. package/dist/chunks/upgrade-BTI562Ce.js +1 -0
  309. package/dist/chunks/{upgrade-CEd1Jxw_.js → upgrade-DmEGLk6v.js} +1 -1
  310. package/dist/chunks/{upload-DNo3bZLc.js → upload-49qk5TBL.js} +1 -1
  311. package/dist/chunks/{usage-X4-qec8g.js → usage-DhJDFJVx.js} +1 -1
  312. package/dist/chunks/{usage-DEwRsc7E.js → usage-sYgTL8wR.js} +1 -1
  313. package/dist/chunks/{useMainLoopModel-2A9HV1H3.js → useMainLoopModel-CJaR_qEJ.js} +1 -1
  314. package/dist/chunks/{useManagePlugins-D9MBag8O.js → useManagePlugins-B1FpmxFo.js} +1 -1
  315. package/dist/chunks/{useMergedTools-DCYrP_YE.js → useMergedTools-eMPZ95TX.js} +1 -1
  316. package/dist/chunks/{useSearchInput-CepwLBvi.js → useSearchInput-CR-b0Qi6.js} +1 -1
  317. package/dist/chunks/{useSettingsErrors-C8ffWXbY.js → useSettingsErrors-p-PFBeaC.js} +1 -1
  318. package/dist/chunks/{useVoice-vHZVaTAN.js → useVoice-D3PqTfCK.js} +1 -1
  319. package/dist/chunks/{util-B13MVSse.js → util-BZ2fS3PR.js} +1 -1
  320. package/dist/chunks/utils-hhztcb0b.js +1 -0
  321. package/dist/chunks/{validatePlugin-Cf_toBOJ.js → validatePlugin-QtcXXmZu.js} +1 -1
  322. package/dist/chunks/{vim-6p7eiRPG.js → vim-LmepJftY.js} +1 -1
  323. package/dist/chunks/{voice-Bvc_BxoI.js → voice-CNRTt4gH.js} +1 -1
  324. package/dist/chunks/voiceModeEnabled-B57V7REx.js +1 -0
  325. package/dist/chunks/{voiceModeEnabled-BPbOh6jd.js → voiceModeEnabled-wWM929QG.js} +1 -1
  326. package/dist/chunks/{voiceStreamSTT-CzCUhap3.js → voiceStreamSTT-CnK9GN6Q.js} +1 -1
  327. package/dist/chunks/voiceStreamSTT-Dp-1uSjP.js +1 -0
  328. package/dist/chunks/{workerRegistry-DCtC-WN3.js → workerRegistry-CrIpKIZe.js} +1 -1
  329. package/dist/chunks/worktree-YbEK6b36.js +1 -0
  330. package/dist/chunks/{xml-CqxiCY4v.js → xml-CMdTGiv6.js} +1 -1
  331. package/dist/cli.js +1 -1
  332. package/package.json +1 -1
  333. package/dist/chunks/ApproveApiKey-CAvlRKLr.js +0 -1
  334. package/dist/chunks/ClaudeMdExternalIncludesDialog-DrkzPawC.js +0 -1
  335. package/dist/chunks/ConsoleOAuthFlow-CtqOQRDT.js +0 -1
  336. package/dist/chunks/Doctor-CheDaF3O.js +0 -1
  337. package/dist/chunks/Grove-CbcR0CsI.js +0 -1
  338. package/dist/chunks/REPL-Cxh0Qnnt.js +0 -1
  339. package/dist/chunks/SearchExtraToolsTool-BNpA8JzR.js +0 -1
  340. package/dist/chunks/SentryErrorBoundary-BFwcMSIK.js +0 -1
  341. package/dist/chunks/api-kAjsowcb.js +0 -1
  342. package/dist/chunks/asciicast-aoKFhc7C.js +0 -1
  343. package/dist/chunks/assistant-nOCkNa3_.js +0 -1
  344. package/dist/chunks/auth-CDOk9J9A.js +0 -1
  345. package/dist/chunks/backgroundHousekeeping-wHy1eAso.js +0 -1
  346. package/dist/chunks/bridgeConfig-V_pmBzSH.js +0 -1
  347. package/dist/chunks/bridgeEnabled-BxtxHb8R.js +0 -1
  348. package/dist/chunks/bridgeMain-CMNptMs4.js +0 -1
  349. package/dist/chunks/caches-B-GiT9hm.js +0 -1
  350. package/dist/chunks/changeDetector-S1Jti1bW.js +0 -1
  351. package/dist/chunks/channelNotification-Bx6dpA7I.js +0 -1
  352. package/dist/chunks/clear-BXv0Sq3m.js +0 -1
  353. package/dist/chunks/client-DNQukPEE.js +0 -1
  354. package/dist/chunks/commands-BK3ugb0u.js +0 -1
  355. package/dist/chunks/commitAttribution-CtQYmnw-.js +0 -1
  356. package/dist/chunks/context-noninteractive-0YpW67KZ.js +0 -1
  357. package/dist/chunks/conversation-DCG0fiGV.js +0 -1
  358. package/dist/chunks/createSession-BYf27ahD.js +0 -1
  359. package/dist/chunks/datadog-NnzM1Mu3.js +0 -1
  360. package/dist/chunks/entry-BUwwv2dM.js +0 -14
  361. package/dist/chunks/envLessBridgeConfig-Dq02Vvx1.js +0 -1
  362. package/dist/chunks/extra-usage-DhB0NElh.js +0 -1
  363. package/dist/chunks/extractMemories-wcRNh_jz.js +0 -1
  364. package/dist/chunks/fast-ukzN3wl2.js +0 -1
  365. package/dist/chunks/gates-CB_pFChT.js +0 -1
  366. package/dist/chunks/hooks-BTBhK9sh.js +0 -1
  367. package/dist/chunks/inboundAttachments-DBaPmCTv.js +0 -1
  368. package/dist/chunks/language-ZBygqv6V.js +0 -1
  369. package/dist/chunks/loadAgentsDir-OIIKHPq9.js +0 -1
  370. package/dist/chunks/localSearch-DslXIfeC.js +0 -1
  371. package/dist/chunks/login-CTIVwgFU.js +0 -1
  372. package/dist/chunks/logout-B3MyP8fk.js +0 -1
  373. package/dist/chunks/model-BsHyPvD0.js +0 -1
  374. package/dist/chunks/pluginStartupCheck-Non969kz.js +0 -1
  375. package/dist/chunks/policyLimits-D6dpS-CU.js +0 -1
  376. package/dist/chunks/poorMode-DX4EXe0o.js +0 -1
  377. package/dist/chunks/prompt-2ia5b-QO.js +0 -1
  378. package/dist/chunks/prompt-CNtVpGdl.js +0 -1
  379. package/dist/chunks/sandbox-adapter-Cr6f6gjf.js +0 -1
  380. package/dist/chunks/searchExtraTools-DRVIhwVJ.js +0 -1
  381. package/dist/chunks/sessionFileAccessHooks-DnbPctQc.js +0 -1
  382. package/dist/chunks/sessionMemory-BOT9f5f0.js +0 -1
  383. package/dist/chunks/sessionMemoryUtils-B47JMJa2.js +0 -1
  384. package/dist/chunks/sessionObserver-BNZflr2e.js +0 -1
  385. package/dist/chunks/sessionStorage-BUuPrnU0.js +0 -1
  386. package/dist/chunks/sessionStoragePortable-BI9q2WcJ.js +0 -3
  387. package/dist/chunks/sink-DG0SNHP7.js +0 -1
  388. package/dist/chunks/sinks-Cbp-8X1S.js +0 -1
  389. package/dist/chunks/skillLearning-BHjRTDJw.js +0 -1
  390. package/dist/chunks/skillLearning-By7jxHSI.js +0 -1
  391. package/dist/chunks/teamHelpers-CKBoDEPj.js +0 -1
  392. package/dist/chunks/teammateModeSnapshot-BfOLEMKn.js +0 -1
  393. package/dist/chunks/thinkback-B0OSwcPG.js +0 -1
  394. package/dist/chunks/toolPool-DqemSx_r.js +0 -1
  395. package/dist/chunks/undercover-B-R6dhHB.js +0 -1
  396. package/dist/chunks/upgrade-CCrHxXrm.js +0 -1
  397. package/dist/chunks/utils-C-vk0zpl.js +0 -1
  398. package/dist/chunks/voiceModeEnabled-JSBux8GA.js +0 -1
  399. package/dist/chunks/voiceStreamSTT-D9ER6Ml3.js +0 -1
  400. package/dist/chunks/worktree-Dv0mPuy_.js +0 -1
@@ -1,3 +1,3 @@
1
- import{n as e,o as t}from"./chunk-DR8-3Aex.js";import{n,t as r}from"./figures-gfT9mM8P.js";import{F as i,In as a,J as o,Ln as s,Rn as c,Ut as l,_ as u,a as d,b as f,f as p,i as m,n as h,o as g,p as ee,r as te,t as _,tt as ne,x as v,xt as y}from"./src-Di342QoJ.js";import{t as b}from"./jsx-runtime-D-D469L8.js";import{cn as re,ot as x}from"./state-sIHsFpDu.js";import{Bo as S,Po as C,Ro as w,Vo as T,Xa as E,Xs as D,jo as O,nc as k,oo as A}from"./paths-o5iA-EnQ.js";import{E as j,w as M}from"./debug-UI3T040K.js";import{BS as ie,Bx as ae,H as oe,K as se,LS as N,Lo as ce,Nx as P,Px as F,RS as le,U as ue,Uw as I,V as de,W as fe,dD as pe,hp as me,hu as L,mo as he,mp as R,mu as z,oD as B,q as ge,sA as _e,uA as ve,uD as V,zx as ye}from"./loadAgentsDir-DF6FgRn-.js";import{t as be}from"./useKeybinding-FsOnjW6T.js";import{l as xe,u as Se}from"./referral-BADm5sBf.js";import{n as Ce,t as we}from"./AddWorkspaceDirectory-YmrkKVv2.js";import{t as Te}from"./SearchBox-DfOmUoaI.js";import{n as Ee,t as De}from"./useSearchInput-CepwLBvi.js";import{n as H,t as Oe}from"./shadowedRuleDetection-C4NGjljb.js";import{n as ke,t as Ae}from"./autoModeDenials-Cp6VFdsm.js";function je({ruleValue:e}){switch(e.toolName){case z.name:return e.ruleContent?e.ruleContent.endsWith(`:*`)?(0,U.jsxs)(f,{dimColor:!0,children:[`Any Bash command starting with `,(0,U.jsx)(f,{bold:!0,children:e.ruleContent.slice(0,-2)})]}):(0,U.jsxs)(f,{dimColor:!0,children:[`The Bash command `,(0,U.jsx)(f,{bold:!0,children:e.ruleContent})]}):(0,U.jsx)(f,{dimColor:!0,children:`Any Bash command`});default:return e.ruleContent?null:(0,U.jsxs)(f,{dimColor:!0,children:[`Any use of the `,(0,U.jsx)(f,{bold:!0,children:e.toolName}),` tool`]})}}var U,Me=e((()=>{c(),_(),L(),U=b()}));function Ne(e){switch(e){case`localSettings`:return{label:`Project settings (local)`,description:`Saved in ${E(`localSettings`)}`,value:e};case`projectSettings`:return{label:`Project settings`,description:`Checked in at ${E(`projectSettings`)}`,value:e};case`userSettings`:return{label:`User settings`,description:`Saved in at ~/.claude/settings.json`,value:e}}}function Pe({onAddRules:e,onCancel:t,ruleValues:n,ruleBehavior:r,initialContext:i,setToolPermissionContext:a}){let o=D.map(Ne),s=(0,Fe.useCallback)(o=>{if(o===`cancel`){t();return}else if(D.includes(o)){let t=o,s=B(i,{type:`addRules`,rules:n,behavior:r,destination:t});pe({type:`addRules`,rules:n,behavior:r,destination:t}),a(s);let c=n.map(e=>({ruleValue:e,ruleBehavior:r,source:t})),l=Oe(s,{sandboxAutoAllowEnabled:_e.isSandboxingEnabled()&&_e.isAutoAllowBashIfSandboxedEnabled()}).filter(e=>n.some(t=>t.toolName===e.rule.ruleValue.toolName&&t.ruleContent===e.rule.ruleValue.ruleContent));e(c,l.length>0?l:void 0)}},[e,t,n,r,i,a]);return(0,W.jsxs)(p,{title:`Add ${r} permission ${C(n.length,`rule`)}`,onCancel:t,color:`permission`,children:[(0,W.jsx)(v,{flexDirection:`column`,paddingX:2,children:n.map(e=>(0,W.jsxs)(v,{flexDirection:`column`,children:[(0,W.jsx)(f,{bold:!0,children:T(e)}),(0,W.jsx)(je,{ruleValue:e})]},T(e)))}),(0,W.jsxs)(v,{flexDirection:`column`,marginY:1,children:[(0,W.jsx)(f,{children:n.length===1?`Where should this rule be saved?`:`Where should these rules be saved?`}),(0,W.jsx)(P,{options:o,onChange:s})]})]})}var Fe,W,Ie=e((()=>{c(),Fe=t(c(),1),F(),_(),V(),w(),H(),ve(),k(),A(),O(),Me(),W=b()}));function Le({onCancel:e,onSubmit:t,ruleBehavior:n}){let[a,s]=(0,Re.useState)(``),[c,l]=(0,Re.useState)(0),u=Se();ne(`confirm:no`,e,{context:`Settings`});let{columns:d}=i(),p=d-6;return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(v,{flexDirection:`column`,gap:1,borderStyle:`round`,paddingLeft:1,paddingRight:1,borderColor:`permission`,children:[(0,G.jsxs)(f,{bold:!0,color:`permission`,children:[`Add `,n,` permission rule`]}),(0,G.jsxs)(v,{flexDirection:`column`,children:[(0,G.jsxs)(f,{children:[`Permission rules are a tool name, optionally followed by a specifier in parentheses.`,(0,G.jsx)(o,{}),`e.g., `,(0,G.jsx)(f,{bold:!0,children:T({toolName:R.name})}),(0,G.jsx)(f,{bold:!1,children:` or `}),(0,G.jsx)(f,{bold:!0,children:T({toolName:z.name,ruleContent:`ls:*`})})]}),(0,G.jsx)(v,{borderDimColor:!0,borderStyle:`round`,marginY:1,paddingLeft:1,children:(0,G.jsx)(ye,{showCursor:!0,value:a,onChange:s,onSubmit:e=>{let r=e.trim();r.length!==0&&t(S(r),n)},placeholder:`Enter permission rule${r.ellipsis}`,columns:p,cursorOffset:c,onChangeCursorOffset:l})})]})]}),(0,G.jsx)(v,{marginLeft:3,children:u.pending?(0,G.jsxs)(f,{dimColor:!0,children:[`Press `,u.keyName,` again to exit`]}):(0,G.jsx)(f,{dimColor:!0,children:`Enter to submit · Esc to cancel`})})]})}var Re,G,ze=e((()=>{n(),c(),Re=t(c(),1),ae(),xe(),I(),_(),be(),L(),me(),w(),G=b()}));function Be({onHeaderFocusChange:e,onStateChange:t}){let{headerFocused:n,focusHeader:r}=m();(0,K.useEffect)(()=>{e?.(n)},[n,e]);let[i]=(0,K.useState)(()=>Ae()),[a,o]=(0,K.useState)(()=>new Set),[s,c]=(0,K.useState)(()=>new Set),[l,u]=(0,K.useState)(0);(0,K.useEffect)(()=>{t({approved:a,retry:s,denials:i})},[a,s,i,t]);let d=(0,K.useCallback)(e=>{let t=Number(e);o(e=>{let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n})},[]),p=(0,K.useCallback)(e=>{u(Number(e))},[]);if(y((e,t)=>{e===`r`&&(c(e=>{let t=new Set(e);return t.has(l)?t.delete(l):t.add(l),t}),o(e=>{if(e.has(l))return e;let t=new Set(e);return t.add(l),t}))},{isActive:i.length>0}),i.length===0)return(0,q.jsx)(f,{dimColor:!0,children:`No recent denials. Commands denied by the auto mode classifier will appear here.`});let h=i.map((e,t)=>{let n=a.has(t),r=s.has(t)?` (retry)`:``;return{label:(0,q.jsxs)(f,{children:[(0,q.jsx)(g,{status:n?`success`:`error`,withSpace:!0}),e.display,(0,q.jsx)(f,{dimColor:!0,children:r})]}),value:String(t)}});return(0,q.jsxs)(v,{flexDirection:`column`,children:[(0,q.jsx)(f,{children:`Commands recently denied by the auto mode classifier.`}),(0,q.jsx)(v,{marginTop:1,children:(0,q.jsx)(P,{options:h,onChange:d,onFocus:p,visibleOptionCount:Math.min(10,h.length),isDisabled:n,onUpFromFirstItem:r})})]})}var K,q,Ve=e((()=>{c(),K=t(c(),1),_(),ke(),F(),q=b()}));function He({directoryPath:e,onRemove:t,onCancel:n,permissionContext:r,setPermissionContext:i}){let a=(0,J.useCallback)(()=>{i(B(r,{type:`removeDirectories`,directories:[e],destination:`session`})),t()},[e,r,i,t]),o=(0,J.useCallback)(e=>{e===`yes`?a():n()},[a,n]);return(0,Y.jsxs)(p,{title:`Remove directory from workspace?`,onCancel:n,color:`error`,children:[(0,Y.jsx)(v,{marginX:2,flexDirection:`column`,children:(0,Y.jsx)(f,{bold:!0,children:e})}),(0,Y.jsx)(f,{children:`Claude Code will no longer have access to files in this directory.`}),(0,Y.jsx)(P,{onChange:o,onCancel:n,options:[{label:`Yes`,value:`yes`},{label:`No`,value:`no`}]})]})}var J,Y,Ue=e((()=>{c(),J=t(c(),1),F(),_(),V(),Y=b()}));function We({onExit:e,toolPermissionContext:t,onRequestAddDirectory:n,onRequestRemoveDirectory:i,onHeaderFocusChange:a}){let{headerFocused:o,focusHeader:s}=m();(0,X.useEffect)(()=>{a?.(o)},[o,a]);let c=Ge.useMemo(()=>Array.from(t.additionalWorkingDirectories.keys()).map(e=>({path:e,isCurrent:!1,isDeletable:!0})),[t.additionalWorkingDirectories]),l=(0,X.useCallback)(e=>{if(e===`add-directory`){n();return}let t=c.find(t=>t.path===e);t&&t.isDeletable&&i(t.path)},[c,n,i]),u=(0,X.useCallback)(()=>e(`Workspace dialog dismissed`,{display:`system`}),[e]),d=Ge.useMemo(()=>{let e=c.map(e=>({label:e.path,value:e.path}));return e.push({label:`Add directory${r.ellipsis}`,value:`add-directory`}),e},[c]);return(0,Z.jsxs)(v,{flexDirection:`column`,marginBottom:1,children:[(0,Z.jsxs)(v,{flexDirection:`row`,marginTop:1,marginLeft:2,gap:1,children:[(0,Z.jsx)(f,{children:`- ${x()}`}),(0,Z.jsx)(f,{dimColor:!0,children:`(Original working directory)`})]}),(0,Z.jsx)(P,{options:d,onChange:l,onCancel:u,visibleOptionCount:Math.min(10,d.length),onUpFromFirstItem:s,isDisabled:o})]})}var Ge,X,Z,Ke=e((()=>{n(),Ge=t(c(),1),X=t(c(),1),re(),F(),_(),Z=b()}));function qe({rule:e}){return(0,$.jsx)(f,{dimColor:!0,children:`From ${ge(e.source)}`})}function Je(e){switch(e){case`allow`:return`allowed`;case`deny`:return`denied`;case`ask`:return`ask`}}function Ye({rule:e,onDelete:t,onCancel:n}){let r=Se();ne(`confirm:no`,n,{context:`Confirmation`});let i=(0,$.jsxs)(v,{flexDirection:`column`,marginX:2,children:[(0,$.jsx)(f,{bold:!0,children:T(e.ruleValue)}),(0,$.jsx)(je,{ruleValue:e.ruleValue}),(0,$.jsx)(qe,{rule:e})]}),a=(0,$.jsx)(v,{marginLeft:3,children:r.pending?(0,$.jsxs)(f,{dimColor:!0,children:[`Press `,r.keyName,` again to exit`]}):(0,$.jsx)(f,{dimColor:!0,children:`Esc to cancel`})});return e.source===`policySettings`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(v,{flexDirection:`column`,gap:1,borderStyle:`round`,paddingLeft:1,paddingRight:1,borderColor:`permission`,children:[(0,$.jsx)(f,{bold:!0,color:`permission`,children:`Rule details`}),i,(0,$.jsxs)(f,{italic:!0,children:[`This rule is configured by managed settings and cannot be modified.`,`
1
+ import{n as e,o as t}from"./chunk-DR8-3Aex.js";import{n,t as r}from"./figures-gfT9mM8P.js";import{F as i,In as a,J as o,Ln as s,Rn as c,Ut as l,_ as u,a as d,b as f,f as p,i as m,n as h,o as g,p as ee,r as te,t as _,tt as ne,x as v,xt as y}from"./src-Di342QoJ.js";import{t as b}from"./jsx-runtime-D-D469L8.js";import{cn as re,ot as x}from"./state-sIHsFpDu.js";import{Bo as S,Po as C,Ro as w,Vo as T,Xa as E,Xs as D,jo as O,nc as k,oo as A}from"./paths-q1-Ni8Oh.js";import{E as j,w as M}from"./debug-UI3T040K.js";import{BS as ie,Bx as ae,H as oe,K as se,LS as N,Lo as ce,Nx as P,Px as F,RS as le,U as ue,Uw as I,V as de,W as fe,dD as pe,hp as me,hu as L,mo as he,mp as R,mu as z,oD as B,q as ge,sA as _e,uA as ve,uD as V,zx as ye}from"./loadAgentsDir-Cl2w3uvH.js";import{t as be}from"./useKeybinding-FsOnjW6T.js";import{l as xe,u as Se}from"./referral-rRvT6UDX.js";import{n as Ce,t as we}from"./AddWorkspaceDirectory-_RSNUS7K.js";import{t as Te}from"./SearchBox-DfOmUoaI.js";import{n as Ee,t as De}from"./useSearchInput-CR-b0Qi6.js";import{n as H,t as Oe}from"./shadowedRuleDetection-FNzEipG0.js";import{n as ke,t as Ae}from"./autoModeDenials-Cp6VFdsm.js";function je({ruleValue:e}){switch(e.toolName){case z.name:return e.ruleContent?e.ruleContent.endsWith(`:*`)?(0,U.jsxs)(f,{dimColor:!0,children:[`Any Bash command starting with `,(0,U.jsx)(f,{bold:!0,children:e.ruleContent.slice(0,-2)})]}):(0,U.jsxs)(f,{dimColor:!0,children:[`The Bash command `,(0,U.jsx)(f,{bold:!0,children:e.ruleContent})]}):(0,U.jsx)(f,{dimColor:!0,children:`Any Bash command`});default:return e.ruleContent?null:(0,U.jsxs)(f,{dimColor:!0,children:[`Any use of the `,(0,U.jsx)(f,{bold:!0,children:e.toolName}),` tool`]})}}var U,Me=e((()=>{c(),_(),L(),U=b()}));function Ne(e){switch(e){case`localSettings`:return{label:`Project settings (local)`,description:`Saved in ${E(`localSettings`)}`,value:e};case`projectSettings`:return{label:`Project settings`,description:`Checked in at ${E(`projectSettings`)}`,value:e};case`userSettings`:return{label:`User settings`,description:`Saved in at ~/.claude/settings.json`,value:e}}}function Pe({onAddRules:e,onCancel:t,ruleValues:n,ruleBehavior:r,initialContext:i,setToolPermissionContext:a}){let o=D.map(Ne),s=(0,Fe.useCallback)(o=>{if(o===`cancel`){t();return}else if(D.includes(o)){let t=o,s=B(i,{type:`addRules`,rules:n,behavior:r,destination:t});pe({type:`addRules`,rules:n,behavior:r,destination:t}),a(s);let c=n.map(e=>({ruleValue:e,ruleBehavior:r,source:t})),l=Oe(s,{sandboxAutoAllowEnabled:_e.isSandboxingEnabled()&&_e.isAutoAllowBashIfSandboxedEnabled()}).filter(e=>n.some(t=>t.toolName===e.rule.ruleValue.toolName&&t.ruleContent===e.rule.ruleValue.ruleContent));e(c,l.length>0?l:void 0)}},[e,t,n,r,i,a]);return(0,W.jsxs)(p,{title:`Add ${r} permission ${C(n.length,`rule`)}`,onCancel:t,color:`permission`,children:[(0,W.jsx)(v,{flexDirection:`column`,paddingX:2,children:n.map(e=>(0,W.jsxs)(v,{flexDirection:`column`,children:[(0,W.jsx)(f,{bold:!0,children:T(e)}),(0,W.jsx)(je,{ruleValue:e})]},T(e)))}),(0,W.jsxs)(v,{flexDirection:`column`,marginY:1,children:[(0,W.jsx)(f,{children:n.length===1?`Where should this rule be saved?`:`Where should these rules be saved?`}),(0,W.jsx)(P,{options:o,onChange:s})]})]})}var Fe,W,Ie=e((()=>{c(),Fe=t(c(),1),F(),_(),V(),w(),H(),ve(),k(),A(),O(),Me(),W=b()}));function Le({onCancel:e,onSubmit:t,ruleBehavior:n}){let[a,s]=(0,Re.useState)(``),[c,l]=(0,Re.useState)(0),u=Se();ne(`confirm:no`,e,{context:`Settings`});let{columns:d}=i(),p=d-6;return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(v,{flexDirection:`column`,gap:1,borderStyle:`round`,paddingLeft:1,paddingRight:1,borderColor:`permission`,children:[(0,G.jsxs)(f,{bold:!0,color:`permission`,children:[`Add `,n,` permission rule`]}),(0,G.jsxs)(v,{flexDirection:`column`,children:[(0,G.jsxs)(f,{children:[`Permission rules are a tool name, optionally followed by a specifier in parentheses.`,(0,G.jsx)(o,{}),`e.g., `,(0,G.jsx)(f,{bold:!0,children:T({toolName:R.name})}),(0,G.jsx)(f,{bold:!1,children:` or `}),(0,G.jsx)(f,{bold:!0,children:T({toolName:z.name,ruleContent:`ls:*`})})]}),(0,G.jsx)(v,{borderDimColor:!0,borderStyle:`round`,marginY:1,paddingLeft:1,children:(0,G.jsx)(ye,{showCursor:!0,value:a,onChange:s,onSubmit:e=>{let r=e.trim();r.length!==0&&t(S(r),n)},placeholder:`Enter permission rule${r.ellipsis}`,columns:p,cursorOffset:c,onChangeCursorOffset:l})})]})]}),(0,G.jsx)(v,{marginLeft:3,children:u.pending?(0,G.jsxs)(f,{dimColor:!0,children:[`Press `,u.keyName,` again to exit`]}):(0,G.jsx)(f,{dimColor:!0,children:`Enter to submit · Esc to cancel`})})]})}var Re,G,ze=e((()=>{n(),c(),Re=t(c(),1),ae(),xe(),I(),_(),be(),L(),me(),w(),G=b()}));function Be({onHeaderFocusChange:e,onStateChange:t}){let{headerFocused:n,focusHeader:r}=m();(0,K.useEffect)(()=>{e?.(n)},[n,e]);let[i]=(0,K.useState)(()=>Ae()),[a,o]=(0,K.useState)(()=>new Set),[s,c]=(0,K.useState)(()=>new Set),[l,u]=(0,K.useState)(0);(0,K.useEffect)(()=>{t({approved:a,retry:s,denials:i})},[a,s,i,t]);let d=(0,K.useCallback)(e=>{let t=Number(e);o(e=>{let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n})},[]),p=(0,K.useCallback)(e=>{u(Number(e))},[]);if(y((e,t)=>{e===`r`&&(c(e=>{let t=new Set(e);return t.has(l)?t.delete(l):t.add(l),t}),o(e=>{if(e.has(l))return e;let t=new Set(e);return t.add(l),t}))},{isActive:i.length>0}),i.length===0)return(0,q.jsx)(f,{dimColor:!0,children:`No recent denials. Commands denied by the auto mode classifier will appear here.`});let h=i.map((e,t)=>{let n=a.has(t),r=s.has(t)?` (retry)`:``;return{label:(0,q.jsxs)(f,{children:[(0,q.jsx)(g,{status:n?`success`:`error`,withSpace:!0}),e.display,(0,q.jsx)(f,{dimColor:!0,children:r})]}),value:String(t)}});return(0,q.jsxs)(v,{flexDirection:`column`,children:[(0,q.jsx)(f,{children:`Commands recently denied by the auto mode classifier.`}),(0,q.jsx)(v,{marginTop:1,children:(0,q.jsx)(P,{options:h,onChange:d,onFocus:p,visibleOptionCount:Math.min(10,h.length),isDisabled:n,onUpFromFirstItem:r})})]})}var K,q,Ve=e((()=>{c(),K=t(c(),1),_(),ke(),F(),q=b()}));function He({directoryPath:e,onRemove:t,onCancel:n,permissionContext:r,setPermissionContext:i}){let a=(0,J.useCallback)(()=>{i(B(r,{type:`removeDirectories`,directories:[e],destination:`session`})),t()},[e,r,i,t]),o=(0,J.useCallback)(e=>{e===`yes`?a():n()},[a,n]);return(0,Y.jsxs)(p,{title:`Remove directory from workspace?`,onCancel:n,color:`error`,children:[(0,Y.jsx)(v,{marginX:2,flexDirection:`column`,children:(0,Y.jsx)(f,{bold:!0,children:e})}),(0,Y.jsx)(f,{children:`Claude Code will no longer have access to files in this directory.`}),(0,Y.jsx)(P,{onChange:o,onCancel:n,options:[{label:`Yes`,value:`yes`},{label:`No`,value:`no`}]})]})}var J,Y,Ue=e((()=>{c(),J=t(c(),1),F(),_(),V(),Y=b()}));function We({onExit:e,toolPermissionContext:t,onRequestAddDirectory:n,onRequestRemoveDirectory:i,onHeaderFocusChange:a}){let{headerFocused:o,focusHeader:s}=m();(0,X.useEffect)(()=>{a?.(o)},[o,a]);let c=Ge.useMemo(()=>Array.from(t.additionalWorkingDirectories.keys()).map(e=>({path:e,isCurrent:!1,isDeletable:!0})),[t.additionalWorkingDirectories]),l=(0,X.useCallback)(e=>{if(e===`add-directory`){n();return}let t=c.find(t=>t.path===e);t&&t.isDeletable&&i(t.path)},[c,n,i]),u=(0,X.useCallback)(()=>e(`Workspace dialog dismissed`,{display:`system`}),[e]),d=Ge.useMemo(()=>{let e=c.map(e=>({label:e.path,value:e.path}));return e.push({label:`Add directory${r.ellipsis}`,value:`add-directory`}),e},[c]);return(0,Z.jsxs)(v,{flexDirection:`column`,marginBottom:1,children:[(0,Z.jsxs)(v,{flexDirection:`row`,marginTop:1,marginLeft:2,gap:1,children:[(0,Z.jsx)(f,{children:`- ${x()}`}),(0,Z.jsx)(f,{dimColor:!0,children:`(Original working directory)`})]}),(0,Z.jsx)(P,{options:d,onChange:l,onCancel:u,visibleOptionCount:Math.min(10,d.length),onUpFromFirstItem:s,isDisabled:o})]})}var Ge,X,Z,Ke=e((()=>{n(),Ge=t(c(),1),X=t(c(),1),re(),F(),_(),Z=b()}));function qe({rule:e}){return(0,$.jsx)(f,{dimColor:!0,children:`From ${ge(e.source)}`})}function Je(e){switch(e){case`allow`:return`allowed`;case`deny`:return`denied`;case`ask`:return`ask`}}function Ye({rule:e,onDelete:t,onCancel:n}){let r=Se();ne(`confirm:no`,n,{context:`Confirmation`});let i=(0,$.jsxs)(v,{flexDirection:`column`,marginX:2,children:[(0,$.jsx)(f,{bold:!0,children:T(e.ruleValue)}),(0,$.jsx)(je,{ruleValue:e.ruleValue}),(0,$.jsx)(qe,{rule:e})]}),a=(0,$.jsx)(v,{marginLeft:3,children:r.pending?(0,$.jsxs)(f,{dimColor:!0,children:[`Press `,r.keyName,` again to exit`]}):(0,$.jsx)(f,{dimColor:!0,children:`Esc to cancel`})});return e.source===`policySettings`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(v,{flexDirection:`column`,gap:1,borderStyle:`round`,paddingLeft:1,paddingRight:1,borderColor:`permission`,children:[(0,$.jsx)(f,{bold:!0,color:`permission`,children:`Rule details`}),i,(0,$.jsxs)(f,{italic:!0,children:[`This rule is configured by managed settings and cannot be modified.`,`
2
2
  `,`Contact your system administrator for more information.`]})]}),a]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(v,{flexDirection:`column`,gap:1,borderStyle:`round`,paddingLeft:1,paddingRight:1,borderColor:`error`,children:[(0,$.jsxs)(f,{bold:!0,color:`error`,children:[`Delete `,Je(e.ruleBehavior),` tool?`]}),i,(0,$.jsx)(f,{children:`Are you sure you want to delete this permission rule?`}),(0,$.jsx)(P,{onChange:e=>e===`yes`?t():n(),onCancel:n,options:[{label:`Yes`,value:`yes`},{label:`No`,value:`no`}]})]}),a]})}function Xe(e){let{options:t,searchQuery:n,isSearchMode:r,isFocused:i,onSelect:a,onCancel:o,lastFocusedRuleKey:s,cursorOffset:c,onHeaderFocusChange:l}=e,f=d(),{headerFocused:p,focusHeader:h,blurHeader:g}=m();return(0,Q.useEffect)(()=>{r&&p&&g()},[r,p,g]),(0,Q.useEffect)(()=>{l?.(p)},[p,l]),(0,$.jsxs)(v,{flexDirection:`column`,children:[(0,$.jsx)(v,{marginBottom:1,flexDirection:`column`,children:(0,$.jsx)(u,{query:n,isFocused:r&&!p,isTerminalFocused:i,width:f,cursorOffset:c})}),(0,$.jsx)(P,{options:t,onChange:a,onCancel:o,visibleOptionCount:Math.min(10,t.length),isDisabled:r||p,defaultFocusValue:s,onUpFromFirstItem:h})]})}function Ze({tab:e,getRulesOptions:t,handleToolSelect:n,...r}){return(0,$.jsxs)(v,{flexDirection:`column`,flexShrink:e===`allow`?0:void 0,children:[(0,$.jsx)(f,{children:{allow:`Claude Code won't ask before using allowed tools.`,ask:`Claude Code will always ask for confirmation before using these tools.`,deny:`Claude Code will always reject requests to use denied tools.`}[e]}),(0,$.jsx)(Xe,{options:t(e,r.searchQuery).options,onSelect:t=>n(t,e),...r})]})}function Qe({onExit:e,initialTab:t,onRetryDenials:n}){let i=Ae().length>0,o=t??(i?`recent`:`allow`),[s,c]=(0,Q.useState)([]),u=le(e=>e.toolPermissionContext),d=ie(),p=l(),m=(0,Q.useRef)({approved:new Set,retry:new Set,denials:[]}),g=(0,Q.useCallback)(e=>{m.current=e},[]),[_,y]=(0,Q.useState)(),[b,re]=(0,Q.useState)(),[x,S]=(0,Q.useState)(null),[C,w]=(0,Q.useState)(null),[E,D]=(0,Q.useState)(!1),[O,k]=(0,Q.useState)(null),[A,M]=(0,Q.useState)(!1),[ae,se]=(0,Q.useState)(!0),N=(0,Q.useCallback)(e=>{se(e)},[]),ce=(0,Q.useMemo)(()=>{let e=new Map;return oe(u).forEach(t=>{e.set(j(t),t)}),e},[u]),P=(0,Q.useMemo)(()=>{let e=new Map;return fe(u).forEach(t=>{e.set(j(t),t)}),e},[u]),F=(0,Q.useMemo)(()=>{let e=new Map;return ue(u).forEach(t=>{e.set(j(t),t)}),e},[u]),I=(0,Q.useCallback)((e,t=``)=>{let n=(()=>{switch(e){case`allow`:return ce;case`deny`:return P;case`ask`:return F;case`workspace`:case`recent`:return new Map}})(),i=[];e!==`workspace`&&e!==`recent`&&!t&&i.push({label:`Add a new rule${r.ellipsis}`,value:`add-new-rule`});let a=Array.from(n.keys()).sort((e,t)=>{let r=n.get(e),i=n.get(t);if(r&&i){let e=T(r.ruleValue).toLowerCase(),t=T(i.ruleValue).toLowerCase();return e.localeCompare(t)}return 0}),o=t.toLowerCase();for(let e of a){let r=n.get(e);if(r){let n=T(r.ruleValue);if(t&&!n.toLowerCase().includes(o))continue;i.push({label:n,value:e})}}return{options:i,rulesByKey:n}},[ce,P,F]),me=Se(),L=!_&&!x&&!C&&!E&&!O,{query:he,setQuery:R,cursorOffset:z}=Ee({isActive:L&&A,onExit:()=>{M(!1)}}),ge=(0,Q.useCallback)(e=>{L&&(A||e.ctrl||e.meta||(e.key===`/`?(e.preventDefault(),M(!0),R(``)):e.key.length===1&&e.key!==`j`&&e.key!==`k`&&e.key!==`m`&&e.key!==`i`&&e.key!==`r`&&e.key!==` `&&(e.preventDefault(),M(!0),R(e.key))))},[L,A,R]),_e=(0,Q.useCallback)((e,t)=>{let{rulesByKey:n}=I(t);if(e===`add-new-rule`){S(t);return}else{y(n.get(e));return}},[I]),ve=(0,Q.useCallback)(()=>{S(null)},[]),V=(0,Q.useCallback)((e,t)=>{w({ruleValue:e,ruleBehavior:t}),S(null)},[]),ye=(0,Q.useCallback)((e,t)=>{w(null);for(let t of e)c(e=>[...e,`Added ${t.ruleBehavior} rule ${a.bold(T(t.ruleValue))}`]);if(t&&t.length>0)for(let e of t){let t=e.shadowType===`deny`?`blocked`:`shadowed`;c(n=>[...n,a.yellow(`${r.warning} Warning: ${T(e.rule.ruleValue)} is ${t}`),a.dim(` ${e.reason}`),a.dim(` Fix: ${e.fix}`)])}},[]),be=(0,Q.useCallback)(()=>{w(null)},[]),xe=(0,Q.useCallback)(()=>D(!0),[]),Ce=(0,Q.useCallback)(e=>k(e),[]),Te=(0,Q.useCallback)(()=>{let t=m.current,r=e=>Array.from(e).map(e=>t.denials[e]).filter(e=>e!==void 0),i=r(t.retry);if(i.length>0){let t=i.map(e=>e.display);n?.(t),e(void 0,{shouldQuery:!0,metaMessages:[`Permission granted for: ${t.join(`, `)}. You may now retry ${t.length===1?`this command`:`these commands`} if you would like.`]});return}let o=r(t.approved);o.length>0||s.length>0?e([...o.length>0?[`Approved ${o.map(e=>a.bold(e.display)).join(`, `)}`]:[],...s].join(`
3
3
  `)):e(`Permissions dialog dismissed`,{display:`system`})},[s,e,n]);ne(`confirm:no`,Te,{context:`Settings`,isActive:L&&!A});let De=()=>{if(!_)return;let{options:e}=I(_.ruleBehavior),t=j(_),n=e.filter(e=>e.value!==`add-new-rule`).map(e=>e.value),r=n.indexOf(t),i;r!==-1&&(r<n.length-1?i=n[r+1]:r>0&&(i=n[r-1])),re(i),de({rule:_,initialContext:u,setToolPermissionContext(e){d(t=>({...t,toolPermissionContext:e}))}}),c(e=>[...e,`Deleted ${_.ruleBehavior} rule ${a.bold(T(_.ruleValue))}`]),y(void 0)};if(_)return(0,$.jsx)(Ye,{rule:_,onDelete:De,onCancel:()=>y(void 0)});if(x&&x!==`workspace`&&x!==`recent`)return(0,$.jsx)(Le,{onCancel:ve,onSubmit:V,ruleBehavior:x});if(C)return(0,$.jsx)(Pe,{onAddRules:ye,onCancel:be,ruleValues:[C.ruleValue],ruleBehavior:C.ruleBehavior,initialContext:u,setToolPermissionContext:e=>{d(t=>({...t,toolPermissionContext:e}))}});if(E)return(0,$.jsx)(we,{onAddDirectory:(e,t)=>{let n={type:`addDirectories`,directories:[e],destination:t?`localSettings`:`session`},r=B(u,n);d(e=>({...e,toolPermissionContext:r})),t&&pe(n),c(n=>[...n,`Added directory ${a.bold(e)} to workspace${t?` and saved to local settings`:` for this session`}`]),D(!1)},onCancel:()=>D(!1),permissionContext:u});if(O)return(0,$.jsx)(He,{directoryPath:O,onRemove:()=>{c(e=>[...e,`Removed directory ${a.bold(O)} from workspace`]),k(null)},onCancel:()=>k(null),permissionContext:u,setPermissionContext:e=>{d(t=>({...t,toolPermissionContext:e}))}});let H={searchQuery:he,isSearchMode:A,isFocused:p,onCancel:Te,lastFocusedRuleKey:b,cursorOffset:z,getRulesOptions:I,handleToolSelect:_e,onHeaderFocusChange:N};return(0,$.jsx)(v,{flexDirection:`column`,onKeyDown:ge,children:(0,$.jsxs)(ee,{color:`permission`,children:[(0,$.jsxs)(te,{title:`Permissions:`,color:`permission`,defaultTab:o,hidden:!!_||!!x||!!C||E||!!O,initialHeaderFocused:!i,navFromContent:!A,children:[(0,$.jsx)(h,{id:`recent`,title:`Recently denied`,children:(0,$.jsx)(Be,{onHeaderFocusChange:N,onStateChange:g})}),(0,$.jsx)(h,{id:`allow`,title:`Allow`,children:(0,$.jsx)(Ze,{tab:`allow`,...H})}),(0,$.jsx)(h,{id:`ask`,title:`Ask`,children:(0,$.jsx)(Ze,{tab:`ask`,...H})}),(0,$.jsx)(h,{id:`deny`,title:`Deny`,children:(0,$.jsx)(Ze,{tab:`deny`,...H})}),(0,$.jsx)(h,{id:`workspace`,title:`Workspace`,children:(0,$.jsxs)(v,{flexDirection:`column`,children:[(0,$.jsx)(f,{children:`Claude Code can read files in the workspace, and make edits when auto-accept edits is on.`}),(0,$.jsx)(We,{onExit:e,toolPermissionContext:u,onRequestAddDirectory:xe,onRequestRemoveDirectory:Ce,onHeaderFocusChange:N})]})})]}),(0,$.jsx)(v,{marginTop:1,paddingLeft:1,children:(0,$.jsx)(f,{dimColor:!0,children:me.pending?(0,$.jsxs)($.Fragment,{children:[`Press `,me.keyName,` again to exit`]}):ae?(0,$.jsx)($.Fragment,{children:`←/→ tab switch · ↓ return · Esc cancel`}):A?(0,$.jsx)($.Fragment,{children:`Type to filter · Enter/↓ select · ↑ tabs · Esc clear`}):i&&o===`recent`?(0,$.jsx)($.Fragment,{children:`Enter approve · r retry · ↑↓ navigate · ←/→ switch · Esc cancel`}):(0,$.jsx)($.Fragment,{children:`↑↓ navigate · Enter select · Type to search · ←/→ switch · Esc cancel`})})})]})})}var Q,$,$e=e((()=>{s(),n(),c(),Q=t(c(),1),N(),V(),F(),xe(),De(),_(),be(),ke(),w(),se(),M(),Te(),Ie(),Ce(),Me(),ze(),Ve(),Ue(),Ke(),$=b()})),et,tt;e((()=>{$e(),ce(),et=b(),tt=async(e,t)=>(0,et.jsx)(Qe,{onExit:e,onRetryDenials:e=>{t.setMessages(t=>[...t,he(e)])}})}))();export{tt as call};
@@ -1 +1 @@
1
- import{n as e}from"./chunk-DR8-3Aex.js";import{n as t,s as n}from"./envUtils-BWeoiL4Y.js";import{o as r}from"./log-CzsijfHZ.js";import{a as i,o as a}from"./teamHelpers-BFZ4eVwW.js";import{join as o}from"path";import"fs/promises";import"net";import"events";function s(e){let t=a(e);if(!t)return[];let n=new Set(t.hiddenPaneIds??[]),r=[];for(let e of t.members){if(e.name===`team-lead`)continue;let t=e.isActive===!1?`idle`:`running`;r.push({name:e.name,agentId:e.agentId,agentType:e.agentType,model:e.model,prompt:e.prompt,status:t,color:e.color,tmuxPaneId:e.tmuxPaneId,cwd:e.cwd,worktreePath:e.worktreePath,isHidden:n.has(e.tmuxPaneId),backendType:e.backendType,mode:e.mode})}return r}var c=e((()=>{i()}));function l(){return o(t(),`pipes`)}function u(e){return e?.pipeIpc??d}var d,f=e((()=>{n(),r(),d={role:`main`,subIndex:null,displayRole:`main`,serverName:null,attachedBy:null,localIp:null,hostname:null,machineId:null,mac:null,statusVisible:!1,selectorOpen:!1,selectedPipes:[],routeMode:`selected`,slaves:{},discoveredPipes:[]}}));export{c as a,s as i,l as n,f as r,u as t};
1
+ import{n as e}from"./chunk-DR8-3Aex.js";import{n as t,s as n}from"./envUtils-BWeoiL4Y.js";import{o as r}from"./log-CzsijfHZ.js";import{a as i,o as a}from"./teamHelpers-BJuKEuyS.js";import{join as o}from"path";import"fs/promises";import"net";import"events";function s(e){let t=a(e);if(!t)return[];let n=new Set(t.hiddenPaneIds??[]),r=[];for(let e of t.members){if(e.name===`team-lead`)continue;let t=e.isActive===!1?`idle`:`running`;r.push({name:e.name,agentId:e.agentId,agentType:e.agentType,model:e.model,prompt:e.prompt,status:t,color:e.color,tmuxPaneId:e.tmuxPaneId,cwd:e.cwd,worktreePath:e.worktreePath,isHidden:n.has(e.tmuxPaneId),backendType:e.backendType,mode:e.mode})}return r}var c=e((()=>{i()}));function l(){return o(t(),`pipes`)}function u(e){return e?.pipeIpc??d}var d,f=e((()=>{n(),r(),d={role:`main`,subIndex:null,displayRole:`main`,serverName:null,attachedBy:null,localIp:null,hostname:null,machineId:null,mac:null,statusVisible:!1,selectorOpen:!1,selectedPipes:[],routeMode:`selected`,slaves:{},discoveredPipes:[]}}));export{c as a,s as i,l as n,f as r,u as t};
@@ -1 +1 @@
1
- import{n as e}from"./chunk-DR8-3Aex.js";import{Rn as t,b as n,t as r,x as i}from"./src-Di342QoJ.js";import{t as a}from"./jsx-runtime-D-D469L8.js";import{cn as o,rn as s}from"./state-sIHsFpDu.js";import{Gv as c,Jv as l,Wv as u,ix as d,j as f,oD as p,px as m,uD as h,w as g}from"./loadAgentsDir-DF6FgRn-.js";import{a as _,i as v,r as y,t as b}from"./promptEditor-B3S5E5Q7.js";import{r as x,t as S}from"./staticRender-Br64h1E1.js";function C({planContent:e,planPath:t,editorName:r}){return(0,T.jsxs)(i,{flexDirection:`column`,children:[(0,T.jsx)(n,{bold:!0,children:`Current Plan`}),(0,T.jsx)(n,{dimColor:!0,children:t}),(0,T.jsx)(i,{marginTop:1,children:(0,T.jsx)(n,{children:e})}),r&&(0,T.jsxs)(i,{marginTop:1,children:[(0,T.jsx)(n,{dimColor:!0,children:`"/plan open"`}),(0,T.jsx)(n,{dimColor:!0,children:` to edit this plan in `}),(0,T.jsx)(n,{bold:!0,dimColor:!0,children:r})]})]})}async function w(e,t,n){let{getAppState:r,setAppState:i}=t,a=r().toolPermissionContext.mode;if(a!==`plan`){s(a,`plan`),i(e=>({...e,toolPermissionContext:p(f(e.toolPermissionContext),{type:`setMode`,mode:`plan`,destination:`session`})}));let t=n.trim();return t&&t!==`open`?e(`Enabled plan mode`,{shouldQuery:!0}):e(`Enabled plan mode`),null}let o=u(),l=c();if(!o)return e(`Already in plan mode. No plan written yet.`),null;if(n.trim().split(/\s+/)[0]===`open`){let t=await b(l);return t.error?e(`Failed to open plan in editor: ${t.error}`):e(`Opened plan in editor: ${l}`),null}let d=v();return e(await x((0,T.jsx)(C,{planContent:o,planPath:l,editorName:d?m(d):void 0}))),null}var T;e((()=>{t(),o(),r(),_(),d(),h(),g(),l(),y(),S(),T=a()}))();export{w as call};
1
+ import{n as e}from"./chunk-DR8-3Aex.js";import{Rn as t,b as n,t as r,x as i}from"./src-Di342QoJ.js";import{t as a}from"./jsx-runtime-D-D469L8.js";import{cn as o,rn as s}from"./state-sIHsFpDu.js";import{Gv as c,Jv as l,Wv as u,ix as d,j as f,oD as p,px as m,uD as h,w as g}from"./loadAgentsDir-Cl2w3uvH.js";import{a as _,i as v,r as y,t as b}from"./promptEditor-ClGwMkWl.js";import{r as x,t as S}from"./staticRender-Br64h1E1.js";function C({planContent:e,planPath:t,editorName:r}){return(0,T.jsxs)(i,{flexDirection:`column`,children:[(0,T.jsx)(n,{bold:!0,children:`Current Plan`}),(0,T.jsx)(n,{dimColor:!0,children:t}),(0,T.jsx)(i,{marginTop:1,children:(0,T.jsx)(n,{children:e})}),r&&(0,T.jsxs)(i,{marginTop:1,children:[(0,T.jsx)(n,{dimColor:!0,children:`"/plan open"`}),(0,T.jsx)(n,{dimColor:!0,children:` to edit this plan in `}),(0,T.jsx)(n,{bold:!0,dimColor:!0,children:r})]})]})}async function w(e,t,n){let{getAppState:r,setAppState:i}=t,a=r().toolPermissionContext.mode;if(a!==`plan`){s(a,`plan`),i(e=>({...e,toolPermissionContext:p(f(e.toolPermissionContext),{type:`setMode`,mode:`plan`,destination:`session`})}));let t=n.trim();return t&&t!==`open`?e(`Enabled plan mode`,{shouldQuery:!0}):e(`Enabled plan mode`),null}let o=u(),l=c();if(!o)return e(`Already in plan mode. No plan written yet.`),null;if(n.trim().split(/\s+/)[0]===`open`){let t=await b(l);return t.error?e(`Failed to open plan in editor: ${t.error}`):e(`Opened plan in editor: ${l}`),null}let d=v();return e(await x((0,T.jsx)(C,{planContent:o,planPath:l,editorName:d?m(d):void 0}))),null}var T;e((()=>{t(),o(),r(),_(),d(),h(),g(),l(),y(),S(),T=a()}))();export{w as call};
@@ -1 +1 @@
1
- import{n as e}from"./chunk-DR8-3Aex.js";import{Rn as t}from"./src-Di342QoJ.js";import{t as n}from"./jsx-runtime-D-D469L8.js";import{n as r,t as i}from"./PluginSettings-D1YHfrE1.js";async function a(e,t,n){return(0,o.jsx)(i,{onComplete:e,args:n})}var o;e((()=>{t(),r(),o=n()}))();export{a as call};
1
+ import{n as e}from"./chunk-DR8-3Aex.js";import{Rn as t}from"./src-Di342QoJ.js";import{t as n}from"./jsx-runtime-D-D469L8.js";import{n as r,t as i}from"./PluginSettings-DhpNtjTm.js";async function a(e,t,n){return(0,o.jsx)(i,{onComplete:e,args:n})}var o;e((()=>{t(),r(),o=n()}))();export{a as call};
@@ -1 +1 @@
1
- import{n as e}from"./chunk-DR8-3Aex.js";import{Ac as t,Fc as n,ws as r,xs as i}from"./paths-o5iA-EnQ.js";import{L as a,V as o,d as s,s as c}from"./debug-UI3T040K.js";import{o as l,s as u}from"./log-CzsijfHZ.js";import{Es as d,Gs as f,Hs as p,Ls as m,Os as h,Vs as g,js as _}from"./loadAgentsDir-DF6FgRn-.js";import{i as v,o as y}from"./xml-CqxiCY4v.js";import{f as b,s as x}from"./pluginOperations-BTz69m3_.js";function S(e){return O=e,k!==null&&k.length>0&&(e(k),k=null),()=>{O=null}}async function C(){let e=await p(),t=m(),n=new Set;for(let[i,a]of Object.entries(e)){let e=t[i]?.autoUpdate;(e===void 0?r(i,a):e)&&n.add(i.toLowerCase())}return n}async function w(e,t){let n=!1;for(let{scope:r}of t)try{let t=await b(e,r);t.success&&!t.alreadyUpToDate?(n=!0,s(`Plugin autoupdate: updated ${e} from ${t.oldVersion} to ${t.newVersion}`)):t.alreadyUpToDate||s(`Plugin autoupdate: failed to update ${e}: ${t.message}`,{level:`warn`})}catch(t){s(`Plugin autoupdate: error updating ${e}: ${a(t)}`,{level:`warn`})}return n?e:null}async function T(e){let t=_(),n=Object.keys(t.plugins);return n.length===0?[]:(await Promise.allSettled(n.map(async n=>{let{marketplace:r}=y(n);if(!r||!e.has(r.toLowerCase()))return null;let i=t.plugins[n];if(!i||i.length===0)return null;let a=i.filter(h);return a.length===0?null:w(n,a)}))).filter(e=>e.status===`fulfilled`&&e.value!==null).map(e=>e.value)}async function E(e){return T(e)}function D(){(async()=>{if(n()){s(`Plugin autoupdate: skipped (auto-updater disabled)`);return}try{let e=await C();if(e.size===0)return;let t=(await Promise.allSettled(Array.from(e).map(async e=>{try{await f(e,void 0,{disableCredentialHelper:!0})}catch(t){s(`Plugin autoupdate: failed to refresh marketplace ${e}: ${a(t)}`,{level:`warn`})}}))).filter(e=>e.status===`rejected`);t.length>0&&s(`Plugin autoupdate: ${t.length} marketplace refresh(es) failed`,{level:`warn`}),s(`Plugin autoupdate: checking installed plugins`);let n=await E(e);n.length>0&&(O?O(n):k=n)}catch(e){u(e)}})()}var O,k,A=e((()=>{x(),t(),c(),o(),l(),d(),g(),v(),i(),O=null,k=null}));export{T as i,A as n,S as r,D as t};
1
+ import{n as e}from"./chunk-DR8-3Aex.js";import{Ac as t,Fc as n,ws as r,xs as i}from"./paths-q1-Ni8Oh.js";import{L as a,V as o,d as s,s as c}from"./debug-UI3T040K.js";import{o as l,s as u}from"./log-CzsijfHZ.js";import{Es as d,Gs as f,Hs as p,Ls as m,Os as h,Vs as g,js as _}from"./loadAgentsDir-Cl2w3uvH.js";import{i as v,o as y}from"./xml-CMdTGiv6.js";import{f as b,s as x}from"./pluginOperations-fdLcp72i.js";function S(e){return O=e,k!==null&&k.length>0&&(e(k),k=null),()=>{O=null}}async function C(){let e=await p(),t=m(),n=new Set;for(let[i,a]of Object.entries(e)){let e=t[i]?.autoUpdate;(e===void 0?r(i,a):e)&&n.add(i.toLowerCase())}return n}async function w(e,t){let n=!1;for(let{scope:r}of t)try{let t=await b(e,r);t.success&&!t.alreadyUpToDate?(n=!0,s(`Plugin autoupdate: updated ${e} from ${t.oldVersion} to ${t.newVersion}`)):t.alreadyUpToDate||s(`Plugin autoupdate: failed to update ${e}: ${t.message}`,{level:`warn`})}catch(t){s(`Plugin autoupdate: error updating ${e}: ${a(t)}`,{level:`warn`})}return n?e:null}async function T(e){let t=_(),n=Object.keys(t.plugins);return n.length===0?[]:(await Promise.allSettled(n.map(async n=>{let{marketplace:r}=y(n);if(!r||!e.has(r.toLowerCase()))return null;let i=t.plugins[n];if(!i||i.length===0)return null;let a=i.filter(h);return a.length===0?null:w(n,a)}))).filter(e=>e.status===`fulfilled`&&e.value!==null).map(e=>e.value)}async function E(e){return T(e)}function D(){(async()=>{if(n()){s(`Plugin autoupdate: skipped (auto-updater disabled)`);return}try{let e=await C();if(e.size===0)return;let t=(await Promise.allSettled(Array.from(e).map(async e=>{try{await f(e,void 0,{disableCredentialHelper:!0})}catch(t){s(`Plugin autoupdate: failed to refresh marketplace ${e}: ${a(t)}`,{level:`warn`})}}))).filter(e=>e.status===`rejected`);t.length>0&&s(`Plugin autoupdate: ${t.length} marketplace refresh(es) failed`,{level:`warn`}),s(`Plugin autoupdate: checking installed plugins`);let n=await E(e);n.length>0&&(O?O(n):k=n)}catch(e){u(e)}})()}var O,k,A=e((()=>{x(),t(),c(),o(),l(),d(),g(),v(),i(),O=null,k=null}));export{T as i,A as n,S as r,D as t};
@@ -1 +1 @@
1
- import{L as e,V as t,d as n,s as r}from"./debug-UI3T040K.js";import{Es as i,Ms as a,Rs as o,Us as s,Vs as c}from"./loadAgentsDir-DF6FgRn-.js";import{d as l,s as u}from"./pluginOperations-BTz69m3_.js";import{i as d,n as f,r as p,t as m}from"./pluginFlagging-DFLE5fkh.js";u(),r(),t(),i(),c(),p();function h(e,t,n){let r=new Set(t.plugins.map(e=>e.name)),i=`@${n}`,a=[];for(let t of Object.keys(e.plugins)){if(!t.endsWith(i))continue;let e=t.slice(0,-i.length);r.has(e)||a.push(t)}return a}async function g(){await d();let t=a(),r=f(),i=await s(),c=[];for(let a of Object.keys(i))try{let i=await o(a);if(!i.forceRemoveDeletedPlugins)continue;let s=h(t,i,a);for(let i of s){if(i in r)continue;let a=t.plugins[i]??[];if(a.some(e=>e.scope===`user`||e.scope===`project`||e.scope===`local`)){for(let t of a){let{scope:r}=t;if(!(r!==`user`&&r!==`project`&&r!==`local`))try{await l(i,r)}catch(t){n(`Failed to auto-uninstall delisted plugin ${i} from ${r}: ${e(t)}`,{level:`error`})}}await m(i),c.push(i)}}}catch(t){n(`Failed to check for delisted plugins in "${a}": ${e(t)}`,{level:`warn`})}return c}export{g as t};
1
+ import{L as e,V as t,d as n,s as r}from"./debug-UI3T040K.js";import{Es as i,Ms as a,Rs as o,Us as s,Vs as c}from"./loadAgentsDir-Cl2w3uvH.js";import{d as l,s as u}from"./pluginOperations-fdLcp72i.js";import{i as d,n as f,r as p,t as m}from"./pluginFlagging-Dh6rYOvj.js";u(),r(),t(),i(),c(),p();function h(e,t,n){let r=new Set(t.plugins.map(e=>e.name)),i=`@${n}`,a=[];for(let t of Object.keys(e.plugins)){if(!t.endsWith(i))continue;let e=t.slice(0,-i.length);r.has(e)||a.push(t)}return a}async function g(){await d();let t=a(),r=f(),i=await s(),c=[];for(let a of Object.keys(i))try{let i=await o(a);if(!i.forceRemoveDeletedPlugins)continue;let s=h(t,i,a);for(let i of s){if(i in r)continue;let a=t.plugins[i]??[];if(a.some(e=>e.scope===`user`||e.scope===`project`||e.scope===`local`)){for(let t of a){let{scope:r}=t;if(!(r!==`user`&&r!==`project`&&r!==`local`))try{await l(i,r)}catch(t){n(`Failed to auto-uninstall delisted plugin ${i} from ${r}: ${e(t)}`,{level:`error`})}}await m(i),c.push(i)}}}catch(t){n(`Failed to check for delisted plugins in "${a}": ${e(t)}`,{level:`warn`})}return c}export{g as t};
@@ -1 +1 @@
1
- import{n as e,t}from"./figures-gfT9mM8P.js";import{L as n,V as r}from"./debug-UI3T040K.js";import{n as i,r as a}from"./analytics-DqMQntaB.js";import{n as o,o as s}from"./process-DMKLUQIO.js";import{o as c,s as l}from"./log-CzsijfHZ.js";import{$T as u,J_ as d,K_ as f,Ts as p,ZT as m,q_ as h,ws as g}from"./loadAgentsDir-DF6FgRn-.js";import{i as _,o as v}from"./xml-CqxiCY4v.js";import{a as y,c as b,d as x,f as S,i as C,r as w,s as T}from"./pluginOperations-BTz69m3_.js";e(),r(),u(),c(),p(),_(),o(),d(),i(),T();function E(e,r,i){l(e);let o=i?`${r} plugin "${i}"`:r===`disable-all`?`disable all plugins`:`${r} plugins`;console.error(`${t.cross} Failed to ${o}: ${n(e)}`);let s=i?(()=>{let{name:e,marketplace:t}=v(i);return{_PROTO_plugin_name:e,...t&&{_PROTO_marketplace_name:t},...f(e,t,g())}})():{};a(`tengu_plugin_command_failed`,{command:r,error_category:h(e),...s}),process.exit(1)}async function D(e,n=`user`){try{console.log(`Installing plugin "${e}"...`);let r=await b(e,n);if(!r.success)throw Error(r.message);console.log(`${t.tick} ${r.message}`);let{name:i,marketplace:o}=v(r.pluginId||e);a(`tengu_plugin_installed_cli`,{_PROTO_plugin_name:i,...o&&{_PROTO_marketplace_name:o},scope:r.scope||n,install_source:`cli-explicit`,...f(i,o,g())}),process.exit(0)}catch(t){E(t,`install`,e)}}async function O(e,n=`user`,r=!1){try{let i=await x(e,n,!r);if(!i.success)throw Error(i.message);console.log(`${t.tick} ${i.message}`);let{name:o,marketplace:s}=v(i.pluginId||e);a(`tengu_plugin_uninstalled_cli`,{_PROTO_plugin_name:o,...s&&{_PROTO_marketplace_name:s},scope:i.scope||n,...f(o,s,g())}),process.exit(0)}catch(t){E(t,`uninstall`,e)}}async function k(e,n){try{let r=await y(e,n);if(!r.success)throw Error(r.message);console.log(`${t.tick} ${r.message}`);let{name:i,marketplace:o}=v(r.pluginId||e);a(`tengu_plugin_enabled_cli`,{_PROTO_plugin_name:i,...o&&{_PROTO_marketplace_name:o},scope:r.scope,...f(i,o,g())}),process.exit(0)}catch(t){E(t,`enable`,e)}}async function A(e,n){try{let r=await C(e,n);if(!r.success)throw Error(r.message);console.log(`${t.tick} ${r.message}`);let{name:i,marketplace:o}=v(r.pluginId||e);a(`tengu_plugin_disabled_cli`,{_PROTO_plugin_name:i,...o&&{_PROTO_marketplace_name:o},scope:r.scope,...f(i,o,g())}),process.exit(0)}catch(t){E(t,`disable`,e)}}async function j(){try{let e=await w();if(!e.success)throw Error(e.message);console.log(`${t.tick} ${e.message}`),a(`tengu_plugin_disabled_all_cli`,{}),process.exit(0)}catch(e){E(e,`disable-all`)}}async function M(e,n){try{s(`Checking for updates for plugin "${e}" at ${n} scope…\n`);let r=await S(e,n);if(!r.success)throw Error(r.message);if(s(`${t.tick} ${r.message}\n`),!r.alreadyUpToDate){let{name:t,marketplace:n}=v(r.pluginId||e);a(`tengu_plugin_updated_cli`,{_PROTO_plugin_name:t,...n&&{_PROTO_marketplace_name:n},old_version:r.oldVersion||`unknown`,new_version:r.newVersion||`unknown`,...f(t,n,g())})}await m(0)}catch(t){E(t,`update`,e)}}export{O as a,D as i,A as n,M as o,k as r,j as t};
1
+ import{n as e,t}from"./figures-gfT9mM8P.js";import{L as n,V as r}from"./debug-UI3T040K.js";import{n as i,r as a}from"./analytics-DqMQntaB.js";import{n as o,o as s}from"./process-DMKLUQIO.js";import{o as c,s as l}from"./log-CzsijfHZ.js";import{$T as u,J_ as d,K_ as f,Ts as p,ZT as m,q_ as h,ws as g}from"./loadAgentsDir-Cl2w3uvH.js";import{i as _,o as v}from"./xml-CMdTGiv6.js";import{a as y,c as b,d as x,f as S,i as C,r as w,s as T}from"./pluginOperations-fdLcp72i.js";e(),r(),u(),c(),p(),_(),o(),d(),i(),T();function E(e,r,i){l(e);let o=i?`${r} plugin "${i}"`:r===`disable-all`?`disable all plugins`:`${r} plugins`;console.error(`${t.cross} Failed to ${o}: ${n(e)}`);let s=i?(()=>{let{name:e,marketplace:t}=v(i);return{_PROTO_plugin_name:e,...t&&{_PROTO_marketplace_name:t},...f(e,t,g())}})():{};a(`tengu_plugin_command_failed`,{command:r,error_category:h(e),...s}),process.exit(1)}async function D(e,n=`user`){try{console.log(`Installing plugin "${e}"...`);let r=await b(e,n);if(!r.success)throw Error(r.message);console.log(`${t.tick} ${r.message}`);let{name:i,marketplace:o}=v(r.pluginId||e);a(`tengu_plugin_installed_cli`,{_PROTO_plugin_name:i,...o&&{_PROTO_marketplace_name:o},scope:r.scope||n,install_source:`cli-explicit`,...f(i,o,g())}),process.exit(0)}catch(t){E(t,`install`,e)}}async function O(e,n=`user`,r=!1){try{let i=await x(e,n,!r);if(!i.success)throw Error(i.message);console.log(`${t.tick} ${i.message}`);let{name:o,marketplace:s}=v(i.pluginId||e);a(`tengu_plugin_uninstalled_cli`,{_PROTO_plugin_name:o,...s&&{_PROTO_marketplace_name:s},scope:i.scope||n,...f(o,s,g())}),process.exit(0)}catch(t){E(t,`uninstall`,e)}}async function k(e,n){try{let r=await y(e,n);if(!r.success)throw Error(r.message);console.log(`${t.tick} ${r.message}`);let{name:i,marketplace:o}=v(r.pluginId||e);a(`tengu_plugin_enabled_cli`,{_PROTO_plugin_name:i,...o&&{_PROTO_marketplace_name:o},scope:r.scope,...f(i,o,g())}),process.exit(0)}catch(t){E(t,`enable`,e)}}async function A(e,n){try{let r=await C(e,n);if(!r.success)throw Error(r.message);console.log(`${t.tick} ${r.message}`);let{name:i,marketplace:o}=v(r.pluginId||e);a(`tengu_plugin_disabled_cli`,{_PROTO_plugin_name:i,...o&&{_PROTO_marketplace_name:o},scope:r.scope,...f(i,o,g())}),process.exit(0)}catch(t){E(t,`disable`,e)}}async function j(){try{let e=await w();if(!e.success)throw Error(e.message);console.log(`${t.tick} ${e.message}`),a(`tengu_plugin_disabled_all_cli`,{}),process.exit(0)}catch(e){E(e,`disable-all`)}}async function M(e,n){try{s(`Checking for updates for plugin "${e}" at ${n} scope…\n`);let r=await S(e,n);if(!r.success)throw Error(r.message);if(s(`${t.tick} ${r.message}\n`),!r.alreadyUpToDate){let{name:t,marketplace:n}=v(r.pluginId||e);a(`tengu_plugin_updated_cli`,{_PROTO_plugin_name:t,...n&&{_PROTO_marketplace_name:n},old_version:r.oldVersion||`unknown`,new_version:r.newVersion||`unknown`,...f(t,n,g())})}await m(0)}catch(t){E(t,`update`,e)}}export{O as a,D as i,A as n,M as o,k as r,j as t};
@@ -1 +1 @@
1
- import{n as e}from"./chunk-DR8-3Aex.js";import{E as t,T as n,d as r,h as i,p as a,s as o,w as s}from"./debug-UI3T040K.js";import{o as c,s as l}from"./log-CzsijfHZ.js";import{aA as u,iA as d}from"./loadAgentsDir-DF6FgRn-.js";import{join as f}from"path";import{randomBytes as p}from"crypto";import{readFile as m,rename as h,unlink as g,writeFile as _}from"fs/promises";function v(){return f(d(),D)}function y(e){let t=n(e);if(typeof t!=`object`||!t||!(`plugins`in t)||typeof t.plugins!=`object`||t.plugins===null)return{};let r=t.plugins,i={};for(let[e,t]of Object.entries(r))if(t&&typeof t==`object`&&`flaggedAt`in t&&typeof t.flaggedAt==`string`){let n={flaggedAt:t.flaggedAt};`seenAt`in t&&typeof t.seenAt==`string`&&(n.seenAt=t.seenAt),i[e]=n}return i}async function b(){try{return y(await m(v(),{encoding:`utf-8`}))}catch{return{}}}async function x(e){let n=v(),r=`${n}.${p(8).toString(`hex`)}.tmp`;try{await a().mkdir(d()),await _(r,t({plugins:e},null,2),{encoding:`utf-8`,mode:384}),await h(r,n),k=e}catch(e){l(e);try{await g(r)}catch{}}}async function S(){let e=await b(),t=Date.now(),n=!1;for(let[r,i]of Object.entries(e))i.seenAt&&t-new Date(i.seenAt).getTime()>=O&&(delete e[r],n=!0);k=e,n&&await x(e)}function C(){return k??{}}async function w(e){k===null&&(k=await b()),await x({...k,[e]:{flaggedAt:new Date().toISOString()}}),r(`Flagged plugin: ${e}`)}async function T(e){k===null&&(k=await b());let t=new Date().toISOString(),n=!1,r={...k};for(let i of e){let e=r[i];e&&!e.seenAt&&(r[i]={...e,seenAt:t},n=!0)}n&&await x(r)}async function E(e){if(k===null&&(k=await b()),!(e in k))return;let{[e]:t,...n}=k;k=n,await x(n)}var D,O,k,A=e((()=>{o(),i(),c(),s(),u(),D=`flagged-plugins.json`,O=2880*60*1e3,k=null}));export{T as a,S as i,C as n,E as o,A as r,w as t};
1
+ import{n as e}from"./chunk-DR8-3Aex.js";import{E as t,T as n,d as r,h as i,p as a,s as o,w as s}from"./debug-UI3T040K.js";import{o as c,s as l}from"./log-CzsijfHZ.js";import{aA as u,iA as d}from"./loadAgentsDir-Cl2w3uvH.js";import{join as f}from"path";import{randomBytes as p}from"crypto";import{readFile as m,rename as h,unlink as g,writeFile as _}from"fs/promises";function v(){return f(d(),D)}function y(e){let t=n(e);if(typeof t!=`object`||!t||!(`plugins`in t)||typeof t.plugins!=`object`||t.plugins===null)return{};let r=t.plugins,i={};for(let[e,t]of Object.entries(r))if(t&&typeof t==`object`&&`flaggedAt`in t&&typeof t.flaggedAt==`string`){let n={flaggedAt:t.flaggedAt};`seenAt`in t&&typeof t.seenAt==`string`&&(n.seenAt=t.seenAt),i[e]=n}return i}async function b(){try{return y(await m(v(),{encoding:`utf-8`}))}catch{return{}}}async function x(e){let n=v(),r=`${n}.${p(8).toString(`hex`)}.tmp`;try{await a().mkdir(d()),await _(r,t({plugins:e},null,2),{encoding:`utf-8`,mode:384}),await h(r,n),k=e}catch(e){l(e);try{await g(r)}catch{}}}async function S(){let e=await b(),t=Date.now(),n=!1;for(let[r,i]of Object.entries(e))i.seenAt&&t-new Date(i.seenAt).getTime()>=O&&(delete e[r],n=!0);k=e,n&&await x(e)}function C(){return k??{}}async function w(e){k===null&&(k=await b()),await x({...k,[e]:{flaggedAt:new Date().toISOString()}}),r(`Flagged plugin: ${e}`)}async function T(e){k===null&&(k=await b());let t=new Date().toISOString(),n=!1,r={...k};for(let i of e){let e=r[i];e&&!e.seenAt&&(r[i]={...e,seenAt:t},n=!0)}n&&await x(r)}async function E(e){if(k===null&&(k=await b()),!(e in k))return;let{[e]:t,...n}=k;k=n,await x(n)}var D,O,k,A=e((()=>{o(),i(),c(),s(),u(),D=`flagged-plugins.json`,O=2880*60*1e3,k=null}));export{T as a,S as i,C as n,E as o,A as r,w as t};
@@ -1,2 +1,2 @@
1
- import{n as e}from"./chunk-DR8-3Aex.js";import{cn as t,ot as n}from"./state-sIHsFpDu.js";import{Po as r,Qa as i,jo as a,lo as o,oo as s}from"./paths-o5iA-EnQ.js";import{K as c,U as l,V as u,h as d,p as f}from"./debug-UI3T040K.js";import{o as p,s as m}from"./log-CzsijfHZ.js";import{Bs as h,Cs as g,Es as _,FA as v,Hs as y,IA as b,Ms as x,Ns as ee,Nw as S,PA as C,Ps as w,Rs as T,Ss as E,Vs as te,_s as ne,aA as D,bs as O,dc as k,ds as A,fs as re,hs as ie,js as j,jw as ae,lc as M,ls as oe,nh as se,ps as N,rh as ce,ss as P,tA as F,uc as I,us as L,vs as R}from"./loadAgentsDir-DF6FgRn-.js";import{i as z,m as B,o as V,p as H,s as U}from"./xml-CqxiCY4v.js";import{n as W,t as G}from"./pluginStartupCheck-CWWKwD5F.js";import{dirname as le,join as K}from"path";function q(e){if(!Q.includes(e))throw Error(`Invalid scope "${e}". Must be one of: ${Q.join(`, `)}`)}function ue(e){return Q.includes(e)}function J(e){return e===`project`||e===`local`?n():void 0}function de(e){return i(`projectSettings`)?.enabledPlugins?.[e]===!0}function fe(e){let t=e.includes(`@`);for(let n of[`local`,`project`,`user`]){let r=i(U(n))?.enabledPlugins;if(r){for(let i of Object.keys(r))if(t?i===e:i.startsWith(`${e}@`))return{pluginId:i,scope:n}}}return null}function pe(e,t){let{name:n,marketplace:r}=V(e);return t.find(t=>t.name===e||t.name===n?!0:r&&t.source?t.name===n&&t.source.includes(`@${r}`):!1)}function me(e){let{name:t}=V(e),n=x();if(n.plugins[e]?.length)return{pluginId:e,pluginName:t};let r=Object.keys(n.plugins).find(e=>{let{name:r}=V(e);return r===t&&(n.plugins[e]?.length??0)>0});return r?{pluginId:r,pluginName:t}:null}function Y(e){let t=x().plugins[e];if(!t||t.length===0)return{scope:`user`};let r=n(),i=t.find(e=>e.scope===`local`&&e.projectPath===r);if(i)return{scope:i.scope,projectPath:i.projectPath};let a=t.find(e=>e.scope===`project`&&e.projectPath===r);if(a)return{scope:a.scope,projectPath:a.projectPath};let o=t.find(e=>e.scope===`user`);return o?{scope:o.scope}:{scope:t[0].scope,projectPath:t[0].projectPath}}async function he(e,t=`user`){q(t);let{name:n,marketplace:r}=V(e),i,a,o;if(r){let t=await h(e);t&&(i=t.entry,a=r,o=t.marketplaceInstallLocation)}else{let e=await y();for(let[t,r]of Object.entries(e))try{let e=(await T(t)).plugins.find(e=>e.name===n);if(e){i=e,a=t,o=r.installLocation;break}}catch(e){m(c(e))}}if(!i||!a)return{success:!1,message:`Plugin "${n}" not found in ${r?`marketplace "${r}"`:`any configured marketplace`}`};let s=i,l=`${s.name}@${a}`,u=await O({pluginId:l,entry:s,scope:t,marketplaceInstallLocation:o});if(!u.ok){let e=u;switch(e.reason){case`local-source-no-location`:return{success:!1,message:`Cannot install local plugin "${e.pluginName}" without marketplace install location`};case`settings-write-failed`:return{success:!1,message:`Failed to update settings: ${e.message}`};case`resolution-failed`:return{success:!1,message:ne(e.resolution)};case`blocked-by-policy`:return{success:!1,message:`Plugin "${e.pluginName}" is blocked by your organization's policy and cannot be installed`};case`dependency-blocked-by-policy`:return{success:!1,message:`Plugin "${e.pluginName}" depends on "${e.blockedDependency}", which is blocked by your organization's policy`}}}return{success:!0,message:`Successfully installed plugin: ${l} (scope: ${t})${u.depNote}`,pluginId:l,pluginName:s.name,scope:t}}async function ge(e,t=`user`,n=!0){q(t);let{enabled:r,disabled:a}=await N(),s=[...r,...a],c=pe(e,s),l=U(t),u=i(l),d,f;if(c)d=Object.keys(u?.enabledPlugins??{}).find(t=>t===e||t===c.name||t.startsWith(`${c.name}@`))??(e.includes(`@`)?e:c.name),f=c.name;else{let t=me(e);if(!t)return{success:!1,message:`Plugin "${e}" not found in installed plugins`};d=t.pluginId,f=t.pluginName}let p=J(t),m=x().plugins[d],h=m?.find(e=>e.scope===t&&e.projectPath===p);if(!h){let{scope:n}=Y(d);return n!==t&&m&&m.length>0?n===`project`?{success:!1,message:`Plugin "${e}" is enabled at project scope (.claude/settings.json, shared with your team). To disable just for you: claude plugin disable ${e} --scope local`}:{success:!1,message:`Plugin "${e}" is installed in ${n} scope, not ${t}. Use --scope ${n} to uninstall.`}:{success:!1,message:`Plugin "${e}" is not installed in ${t} scope. Use --scope to specify the correct scope.`}}let g=h.installPath,_={...u?.enabledPlugins};_[d]=void 0,o(l,{enabledPlugins:_}),M(),ee(d,t,p);let y=x().plugins[d],b=!y||y.length===0;b&&g&&await k(g),b&&(ae(d),n&&await F(d));let S=C(d,s),w=v(S);return{success:!0,message:`Successfully uninstalled plugin: ${f} (scope: ${t})${w}`,pluginId:d,pluginName:f,scope:t,reverseDependents:S.length>0?S:void 0}}async function X(e,t,n){let r=t?`enable`:`disable`;if(B(e)){let{error:n}=o(`userSettings`,{enabledPlugins:{...i(`userSettings`)?.enabledPlugins,[e]:t}});if(n)return{success:!1,message:`Failed to ${r} built-in plugin: ${n.message}`};M();let{name:a}=V(e);return{success:!0,message:`Successfully ${r}d built-in plugin: ${a}`,pluginId:e,pluginName:a,scope:`user`}}n&&q(n);let a,s,c=fe(e);if(n)if(s=n,c)a=c.pluginId;else if(e.includes(`@`))a=e;else return{success:!1,message:`Plugin "${e}" not found in settings. Use plugin@marketplace format.`};else if(c)a=c.pluginId,s=c.scope;else if(e.includes(`@`))a=e,s=`user`;else return{success:!1,message:`Plugin "${e}" not found in any editable settings scope. Use plugin@marketplace format.`};if(t&&ce(a))return{success:!1,message:`Plugin "${a}" is blocked by your organization's policy and cannot be enabled`};let l=U(s),u=i(l)?.enabledPlugins?.[a],d={user:0,project:1,local:2},f=n&&c&&d[n]>d[c.scope];if(n&&u===void 0&&c&&c.scope!==n&&!f)return{success:!1,message:`Plugin "${e}" is installed at ${c.scope} scope, not ${n}. Use --scope ${c.scope} or omit --scope to auto-detect.`};if(t===(n&&!f?u===!0:G().has(a)))return{success:!1,message:`Plugin "${e}" is already ${t?`enabled`:`disabled`}${n?` at ${n} scope`:``}`};let p;if(!t){let{enabled:e,disabled:t}=await N(),n=C(a,[...e,...t]);n.length>0&&(p=n)}let{error:m}=o(l,{enabledPlugins:{...i(l)?.enabledPlugins,[a]:t}});if(m)return{success:!1,message:`Failed to ${r} plugin: ${m.message}`};M();let{name:h}=V(a),g=v(p);return{success:!0,message:`Successfully ${r}d plugin: ${h} (scope: ${s})${g}`,pluginId:a,pluginName:h,scope:s,reverseDependents:p}}async function _e(e,t){return X(e,!0,t)}async function ve(e,t){return X(e,!1,t)}async function Z(){let e=G();if(e.size===0)return{success:!0,message:`No enabled plugins to disable`};let t=[],n=[];for(let[r]of e){let e=await X(r,!1);e.success?t.push(r):n.push(`${r}: ${e.message}`)}return n.length>0?{success:!1,message:`Disabled ${t.length} ${r(t.length,`plugin`)}, ${n.length} failed:\n${n.join(`
1
+ import{n as e}from"./chunk-DR8-3Aex.js";import{cn as t,ot as n}from"./state-sIHsFpDu.js";import{Po as r,Qa as i,jo as a,lo as o,oo as s}from"./paths-q1-Ni8Oh.js";import{K as c,U as l,V as u,h as d,p as f}from"./debug-UI3T040K.js";import{o as p,s as m}from"./log-CzsijfHZ.js";import{Bs as h,Cs as g,Es as _,FA as v,Hs as y,IA as b,Ms as x,Ns as ee,Nw as S,PA as C,Ps as w,Rs as T,Ss as E,Vs as te,_s as ne,aA as D,bs as O,dc as k,ds as A,fs as re,hs as ie,js as j,jw as ae,lc as M,ls as oe,nh as se,ps as N,rh as ce,ss as P,tA as F,uc as I,us as L,vs as R}from"./loadAgentsDir-Cl2w3uvH.js";import{i as z,m as B,o as V,p as H,s as U}from"./xml-CMdTGiv6.js";import{n as W,t as G}from"./pluginStartupCheck-Dy7EckW4.js";import{dirname as le,join as K}from"path";function q(e){if(!Q.includes(e))throw Error(`Invalid scope "${e}". Must be one of: ${Q.join(`, `)}`)}function ue(e){return Q.includes(e)}function J(e){return e===`project`||e===`local`?n():void 0}function de(e){return i(`projectSettings`)?.enabledPlugins?.[e]===!0}function fe(e){let t=e.includes(`@`);for(let n of[`local`,`project`,`user`]){let r=i(U(n))?.enabledPlugins;if(r){for(let i of Object.keys(r))if(t?i===e:i.startsWith(`${e}@`))return{pluginId:i,scope:n}}}return null}function pe(e,t){let{name:n,marketplace:r}=V(e);return t.find(t=>t.name===e||t.name===n?!0:r&&t.source?t.name===n&&t.source.includes(`@${r}`):!1)}function me(e){let{name:t}=V(e),n=x();if(n.plugins[e]?.length)return{pluginId:e,pluginName:t};let r=Object.keys(n.plugins).find(e=>{let{name:r}=V(e);return r===t&&(n.plugins[e]?.length??0)>0});return r?{pluginId:r,pluginName:t}:null}function Y(e){let t=x().plugins[e];if(!t||t.length===0)return{scope:`user`};let r=n(),i=t.find(e=>e.scope===`local`&&e.projectPath===r);if(i)return{scope:i.scope,projectPath:i.projectPath};let a=t.find(e=>e.scope===`project`&&e.projectPath===r);if(a)return{scope:a.scope,projectPath:a.projectPath};let o=t.find(e=>e.scope===`user`);return o?{scope:o.scope}:{scope:t[0].scope,projectPath:t[0].projectPath}}async function he(e,t=`user`){q(t);let{name:n,marketplace:r}=V(e),i,a,o;if(r){let t=await h(e);t&&(i=t.entry,a=r,o=t.marketplaceInstallLocation)}else{let e=await y();for(let[t,r]of Object.entries(e))try{let e=(await T(t)).plugins.find(e=>e.name===n);if(e){i=e,a=t,o=r.installLocation;break}}catch(e){m(c(e))}}if(!i||!a)return{success:!1,message:`Plugin "${n}" not found in ${r?`marketplace "${r}"`:`any configured marketplace`}`};let s=i,l=`${s.name}@${a}`,u=await O({pluginId:l,entry:s,scope:t,marketplaceInstallLocation:o});if(!u.ok){let e=u;switch(e.reason){case`local-source-no-location`:return{success:!1,message:`Cannot install local plugin "${e.pluginName}" without marketplace install location`};case`settings-write-failed`:return{success:!1,message:`Failed to update settings: ${e.message}`};case`resolution-failed`:return{success:!1,message:ne(e.resolution)};case`blocked-by-policy`:return{success:!1,message:`Plugin "${e.pluginName}" is blocked by your organization's policy and cannot be installed`};case`dependency-blocked-by-policy`:return{success:!1,message:`Plugin "${e.pluginName}" depends on "${e.blockedDependency}", which is blocked by your organization's policy`}}}return{success:!0,message:`Successfully installed plugin: ${l} (scope: ${t})${u.depNote}`,pluginId:l,pluginName:s.name,scope:t}}async function ge(e,t=`user`,n=!0){q(t);let{enabled:r,disabled:a}=await N(),s=[...r,...a],c=pe(e,s),l=U(t),u=i(l),d,f;if(c)d=Object.keys(u?.enabledPlugins??{}).find(t=>t===e||t===c.name||t.startsWith(`${c.name}@`))??(e.includes(`@`)?e:c.name),f=c.name;else{let t=me(e);if(!t)return{success:!1,message:`Plugin "${e}" not found in installed plugins`};d=t.pluginId,f=t.pluginName}let p=J(t),m=x().plugins[d],h=m?.find(e=>e.scope===t&&e.projectPath===p);if(!h){let{scope:n}=Y(d);return n!==t&&m&&m.length>0?n===`project`?{success:!1,message:`Plugin "${e}" is enabled at project scope (.claude/settings.json, shared with your team). To disable just for you: claude plugin disable ${e} --scope local`}:{success:!1,message:`Plugin "${e}" is installed in ${n} scope, not ${t}. Use --scope ${n} to uninstall.`}:{success:!1,message:`Plugin "${e}" is not installed in ${t} scope. Use --scope to specify the correct scope.`}}let g=h.installPath,_={...u?.enabledPlugins};_[d]=void 0,o(l,{enabledPlugins:_}),M(),ee(d,t,p);let y=x().plugins[d],b=!y||y.length===0;b&&g&&await k(g),b&&(ae(d),n&&await F(d));let S=C(d,s),w=v(S);return{success:!0,message:`Successfully uninstalled plugin: ${f} (scope: ${t})${w}`,pluginId:d,pluginName:f,scope:t,reverseDependents:S.length>0?S:void 0}}async function X(e,t,n){let r=t?`enable`:`disable`;if(B(e)){let{error:n}=o(`userSettings`,{enabledPlugins:{...i(`userSettings`)?.enabledPlugins,[e]:t}});if(n)return{success:!1,message:`Failed to ${r} built-in plugin: ${n.message}`};M();let{name:a}=V(e);return{success:!0,message:`Successfully ${r}d built-in plugin: ${a}`,pluginId:e,pluginName:a,scope:`user`}}n&&q(n);let a,s,c=fe(e);if(n)if(s=n,c)a=c.pluginId;else if(e.includes(`@`))a=e;else return{success:!1,message:`Plugin "${e}" not found in settings. Use plugin@marketplace format.`};else if(c)a=c.pluginId,s=c.scope;else if(e.includes(`@`))a=e,s=`user`;else return{success:!1,message:`Plugin "${e}" not found in any editable settings scope. Use plugin@marketplace format.`};if(t&&ce(a))return{success:!1,message:`Plugin "${a}" is blocked by your organization's policy and cannot be enabled`};let l=U(s),u=i(l)?.enabledPlugins?.[a],d={user:0,project:1,local:2},f=n&&c&&d[n]>d[c.scope];if(n&&u===void 0&&c&&c.scope!==n&&!f)return{success:!1,message:`Plugin "${e}" is installed at ${c.scope} scope, not ${n}. Use --scope ${c.scope} or omit --scope to auto-detect.`};if(t===(n&&!f?u===!0:G().has(a)))return{success:!1,message:`Plugin "${e}" is already ${t?`enabled`:`disabled`}${n?` at ${n} scope`:``}`};let p;if(!t){let{enabled:e,disabled:t}=await N(),n=C(a,[...e,...t]);n.length>0&&(p=n)}let{error:m}=o(l,{enabledPlugins:{...i(l)?.enabledPlugins,[a]:t}});if(m)return{success:!1,message:`Failed to ${r} plugin: ${m.message}`};M();let{name:h}=V(a),g=v(p);return{success:!0,message:`Successfully ${r}d plugin: ${h} (scope: ${s})${g}`,pluginId:a,pluginName:h,scope:s,reverseDependents:p}}async function _e(e,t){return X(e,!0,t)}async function ve(e,t){return X(e,!1,t)}async function Z(){let e=G();if(e.size===0)return{success:!0,message:`No enabled plugins to disable`};let t=[],n=[];for(let[r]of e){let e=await X(r,!1);e.success?t.push(r):n.push(`${r}: ${e.message}`)}return n.length>0?{success:!1,message:`Disabled ${t.length} ${r(t.length,`plugin`)}, ${n.length} failed:\n${n.join(`
2
2
  `)}`}:{success:!0,message:`Disabled ${t.length} ${r(t.length,`plugin`)}`}}async function ye(e,t){let{name:n,marketplace:r}=V(e),i=r?`${n}@${r}`:e,a=await h(e);if(!a)return{success:!1,message:`Plugin "${n}" not found`,pluginId:i,scope:t};let{entry:o,marketplaceInstallLocation:s}=a,c=j().plugins[i];if(!c||c.length===0)return{success:!1,message:`Plugin "${n}" is not installed`,pluginId:i,scope:t};let l=J(t),u=c.find(e=>e.scope===t&&e.projectPath===l);return u?be({pluginId:i,pluginName:n,entry:o,marketplaceInstallLocation:s,installation:u,scope:t,projectPath:l}):{success:!1,message:`Plugin "${n}" is not installed at scope ${l?`${t} (${l})`:t}`,pluginId:i,scope:t}}async function be({pluginId:e,pluginName:t,entry:n,marketplaceInstallLocation:r,installation:i,scope:a,projectPath:o}){let s=f(),c=i.version,u,d,p=!1,m;if(typeof n.source!=`string`){let t=await P(n.source,{manifest:{name:n.name}});u=t.path,p=!0,m=t.gitCommitSha,d=await E(e,n.source,t.manifest,t.path,n.version,t.gitCommitSha)}else{let t;try{t=await s.stat(r)}catch(t){if(l(t))return{success:!1,message:`Marketplace directory not found at ${r}`,pluginId:e,scope:a};throw t}u=K(t.isDirectory()?r:le(r),n.source);try{await s.stat(u)}catch(t){if(l(t))return{success:!1,message:`Plugin source not found at ${u}`,pluginId:e,scope:a};throw t}let i,o=K(u,`.claude-plugin`,`plugin.json`);try{i=await ie(o,n.name,n.source)}catch{}d=await E(e,n.source,i,u,n.version)}try{let r=L(e,d),s=A(e,d);if(i.version===d||i.installPath===r||i.installPath===s)return{success:!0,message:`${t} is already at the latest version (${d}).`,pluginId:e,newVersion:d,oldVersion:c,alreadyUpToDate:!0,scope:a};r=await oe(u,e,d,n);let l=i.installPath;if(w(e,a,o,r,d,m),l&&l!==r){let e=j();Object.values(e.plugins).some(e=>e.some(e=>e.installPath===l))||await k(l)}let f=o?`${a} (${o})`:a;return{success:!0,message:`Plugin "${t}" updated from ${c||`unknown`} to ${d} for scope ${f}. Restart to apply changes.`,pluginId:e,newVersion:d,oldVersion:c,scope:a}}finally{p&&u!==L(e,d)&&await s.rm(u,{recursive:!0,force:!0})}}var Q,$,xe=e((()=>{t(),H(),u(),d(),p(),I(),b(),_(),te(),D(),z(),R(),re(),S(),se(),W(),g(),s(),a(),Q=[`user`,`project`,`local`],$=[`user`,`project`,`local`,`managed`]}));export{_e as a,he as c,ge as d,ye as f,ve as i,ue as l,$ as n,Y as o,Z as r,xe as s,Q as t,de as u};
@@ -1 +1 @@
1
- import{n as e}from"./chunk-DR8-3Aex.js";import{Cs as t,Qa as n,lo as r,oo as i,xs as a}from"./paths-o5iA-EnQ.js";import{d as o,s}from"./debug-UI3T040K.js";import{n as c,t as l}from"./cwd--iizewsn.js";import{o as u,s as d}from"./log-CzsijfHZ.js";import{Bs as f,Es as p,LA as m,RA as h,Vs as g,gs as _,vs as v,xs as y}from"./loadAgentsDir-DF6FgRn-.js";import{i as b,s as x}from"./xml-CqxiCY4v.js";import{join as S}from"path";function C(){let e=new Map,t=m();for(let[n,r]of Object.entries(t))n.includes(`@`)&&(r===!0?e.set(n,`flag`):r===!1&&e.delete(n));for(let{scope:r,source:i}of[{scope:`managed`,source:`policySettings`},{scope:`user`,source:`userSettings`},{scope:`project`,source:`projectSettings`},{scope:`local`,source:`localSettings`},{scope:`flag`,source:`flagSettings`}]){let a=n(i);if(a?.enabledPlugins)for(let[n,s]of Object.entries(a.enabledPlugins))n.includes(`@`)&&(n in t&&t[n]!==s&&o(`Plugin ${n} from --add-dir (${t[n]}) overridden by ${i} (${s})`),s===!0?e.set(n,r):s===!1&&e.delete(n))}return o(`Found ${e.size} enabled plugins with scopes: ${Array.from(e.entries()).map(([e,t])=>`${e}(${t})`).join(`, `)}`),e}async function w(e,i,a=`user`){let o=a===`user`?void 0:l(),s=x(a),c=n(s),u={...c?.enabledPlugins},p=[],m=[];for(let n=0;n<e.length;n++){let r=e[n];if(r){i&&i(r,n+1,e.length);try{let e=await f(r);if(!e){m.push({name:r,error:`Plugin not found in any marketplace`});continue}let{entry:n,marketplaceInstallLocation:i}=e;t(n.source)?y({pluginId:r,installPath:S(i,n.source),version:n.version},a,o):await _(r,n,a,o),u[r]=!0,p.push(r)}catch(e){let t=e instanceof Error?e.message:String(e);m.push({name:r,error:t}),d(e)}}}return r(s,{...c,enabledPlugins:u}),{installed:p,failed:m}}var T=e((()=>{c(),s(),u(),i(),h(),p(),g(),b(),v(),a()}));export{T as n,w as r,C as t};
1
+ import{n as e}from"./chunk-DR8-3Aex.js";import{Cs as t,Qa as n,lo as r,oo as i,xs as a}from"./paths-q1-Ni8Oh.js";import{d as o,s}from"./debug-UI3T040K.js";import{n as c,t as l}from"./cwd--iizewsn.js";import{o as u,s as d}from"./log-CzsijfHZ.js";import{Bs as f,Es as p,LA as m,RA as h,Vs as g,gs as _,vs as v,xs as y}from"./loadAgentsDir-Cl2w3uvH.js";import{i as b,s as x}from"./xml-CMdTGiv6.js";import{join as S}from"path";function C(){let e=new Map,t=m();for(let[n,r]of Object.entries(t))n.includes(`@`)&&(r===!0?e.set(n,`flag`):r===!1&&e.delete(n));for(let{scope:r,source:i}of[{scope:`managed`,source:`policySettings`},{scope:`user`,source:`userSettings`},{scope:`project`,source:`projectSettings`},{scope:`local`,source:`localSettings`},{scope:`flag`,source:`flagSettings`}]){let a=n(i);if(a?.enabledPlugins)for(let[n,s]of Object.entries(a.enabledPlugins))n.includes(`@`)&&(n in t&&t[n]!==s&&o(`Plugin ${n} from --add-dir (${t[n]}) overridden by ${i} (${s})`),s===!0?e.set(n,r):s===!1&&e.delete(n))}return o(`Found ${e.size} enabled plugins with scopes: ${Array.from(e.entries()).map(([e,t])=>`${e}(${t})`).join(`, `)}`),e}async function w(e,i,a=`user`){let o=a===`user`?void 0:l(),s=x(a),c=n(s),u={...c?.enabledPlugins},p=[],m=[];for(let n=0;n<e.length;n++){let r=e[n];if(r){i&&i(r,n+1,e.length);try{let e=await f(r);if(!e){m.push({name:r,error:`Plugin not found in any marketplace`});continue}let{entry:n,marketplaceInstallLocation:i}=e;t(n.source)?y({pluginId:r,installPath:S(i,n.source),version:n.version},a,o):await _(r,n,a,o),u[r]=!0,p.push(r)}catch(e){let t=e instanceof Error?e.message:String(e);m.push({name:r,error:t}),d(e)}}}return r(s,{...c,enabledPlugins:u}),{installed:p,failed:m}}var T=e((()=>{c(),s(),u(),i(),h(),p(),g(),b(),v(),a()}));export{T as n,w as r,C as t};
@@ -0,0 +1 @@
1
+ import{n as e,t}from"./pluginStartupCheck-Dy7EckW4.js";e();export{t as getPluginEditableScopes};
@@ -1,4 +1,4 @@
1
- import{n as e,t}from"./figures-gfT9mM8P.js";import{Or as n,cn as r}from"./state-sIHsFpDu.js";import{Po as i,jo as a}from"./paths-o5iA-EnQ.js";import{E as o,L as s,V as c,w as l}from"./debug-UI3T040K.js";import{n as u,r as d}from"./analytics-DqMQntaB.js";import{o as f,s as p}from"./log-CzsijfHZ.js";import{$s as m,As as h,Aw as g,BA as _,Es as v,Fs as y,Gs as b,Hs as x,Ms as S,Vs as C,Ws as w,Ys as T,ac as ee,fs as te,kw as ne,lc as E,ps as D,qs as O,sc as k,uc as A,zA as j}from"./loadAgentsDir-DF6FgRn-.js";import{i as M,o as N,s as P}from"./xml-CqxiCY4v.js";import{n as F,t as I}from"./exit-_obETqBv.js";import{n as L,t as R}from"./pluginOperations-BTz69m3_.js";import{a as z,i as B,n as V,o as H,r as U,t as W}from"./pluginCliCommands-CMgqxOaT.js";import{a as re,c as G,i as K,n as q,r as J,s as Y,t as X}from"./validatePlugin-Cf_toBOJ.js";import{basename as ie,dirname as Z}from"path";e(),r(),u(),_(),c(),f(),A(),G(),v(),ee(),C(),ne(),K(),M(),te(),X(),l(),a();function Q(e,n){p(e),I(`${t.cross} Failed to ${n}: ${s(e)}`)}function $(e){e.errors.length>0&&(console.log(`${t.cross} Found ${e.errors.length} ${i(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} ${i(e.warnings.length,`warning`)}:\n`),e.warnings.forEach(e=>{console.log(` ${t.pointer} ${e.path}: ${e.message}`)}),console.log(``))}async function ae(e,r){r.cowork&&n(!0);try{let n=await q(e);console.log(`Validating ${n.fileType} manifest: ${n.filePath}\n`),$(n);let r=[];if(n.fileType===`plugin`){let e=Z(n.filePath);if(ie(e)===`.claude-plugin`){r=await J(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){p(e),console.error(`${t.cross} Unexpected error during validation: ${s(e)}`),process.exit(2)}}async function oe(e){e.cowork&&n(!0),d(`tengu_plugin_list_command`,{});let r=S(),{getPluginEditableScopes:i}=await import(`./pluginStartupCheck-Non969kz.js`),a=i(),s=Object.keys(r.plugins),{enabled:c,disabled:l,errors:u}=await D(),f=[...c,...l],p=f.filter(e=>e.source.endsWith(`@inline`)),_=u.filter(e=>e.source.endsWith(`@inline`)||e.source.startsWith(`inline[`));if(e.json){let t=new Map(f.map(e=>[e.source,e])),n=[];for(let e of s.sort()){let i=r.plugins[e];if(!i||i.length===0)continue;let o=N(e).name,s=u.filter(t=>t.source===e||`plugin`in t&&t.plugin===o).map(j);for(let r of i){let i=t.get(e),o;if(i){let e=i.mcpServers||await g(i);e&&Object.keys(e).length>0&&(o=e)}n.push({id:e,version:r.version||`unknown`,scope:r.scope,enabled:a.has(e),installPath:r.installPath,installedAt:r.installedAt,lastUpdated:r.lastUpdated,projectPath:r.projectPath,mcpServers:o,errors:s.length>0?s:void 0})}}for(let e of p){let t=e.mcpServers||await g(e),r=_.filter(t=>t.source===e.source||`plugin`in t&&t.plugin===e.name).map(j);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 _.filter(e=>e.source.startsWith(`inline[`)))n.push({id:e.source,version:`unknown`,scope:`session`,enabled:!1,installPath:`path`in e?e.path:``,errors:[j(e)]});if(e.available){let e=[];try{let[t,n]=await Promise.all([x(),Y()]),{marketplaces:r}=await k(t);for(let{name:t,data:i}of r)if(i)for(let r of i.plugins){let i=m(r.name,t);h(i)||e.push({pluginId:i,name:r.name,description:r.description,marketplaceName:t,version:r.version,source:r.source,installCount:n?.get(i)})}}catch{}F(o({installed:n,available:e},null,2))}else F(o(n,null,2))}s.length===0&&p.length===0&&_.length===0&&F("No plugins installed. Use `claude plugin install` to install a plugin."),s.length>0&&console.log(`Installed plugins:
1
+ import{n as e,t}from"./figures-gfT9mM8P.js";import{Or as n,cn as r}from"./state-sIHsFpDu.js";import{Po as i,jo as a}from"./paths-q1-Ni8Oh.js";import{E as o,L as s,V as c,w as l}from"./debug-UI3T040K.js";import{n as u,r as d}from"./analytics-DqMQntaB.js";import{o as f,s as p}from"./log-CzsijfHZ.js";import{$s as m,As as h,Aw as g,BA as _,Es as v,Fs as y,Gs as b,Hs as x,Ms as S,Vs as C,Ws as w,Ys as T,ac as ee,fs as te,kw as ne,lc as E,ps as D,qs as O,sc as k,uc as A,zA as j}from"./loadAgentsDir-Cl2w3uvH.js";import{i as M,o as N,s as P}from"./xml-CMdTGiv6.js";import{n as F,t as I}from"./exit-_obETqBv.js";import{n as L,t as R}from"./pluginOperations-fdLcp72i.js";import{a as z,i as B,n as V,o as H,r as U,t as W}from"./pluginCliCommands-BcDIvxR3.js";import{a as re,c as G,i as K,n as q,r as J,s as Y,t as X}from"./validatePlugin-QtcXXmZu.js";import{basename as ie,dirname as Z}from"path";e(),r(),u(),_(),c(),f(),A(),G(),v(),ee(),C(),ne(),K(),M(),te(),X(),l(),a();function Q(e,n){p(e),I(`${t.cross} Failed to ${n}: ${s(e)}`)}function $(e){e.errors.length>0&&(console.log(`${t.cross} Found ${e.errors.length} ${i(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} ${i(e.warnings.length,`warning`)}:\n`),e.warnings.forEach(e=>{console.log(` ${t.pointer} ${e.path}: ${e.message}`)}),console.log(``))}async function ae(e,r){r.cowork&&n(!0);try{let n=await q(e);console.log(`Validating ${n.fileType} manifest: ${n.filePath}\n`),$(n);let r=[];if(n.fileType===`plugin`){let e=Z(n.filePath);if(ie(e)===`.claude-plugin`){r=await J(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){p(e),console.error(`${t.cross} Unexpected error during validation: ${s(e)}`),process.exit(2)}}async function oe(e){e.cowork&&n(!0),d(`tengu_plugin_list_command`,{});let r=S(),{getPluginEditableScopes:i}=await import(`./pluginStartupCheck-fyqW-stg.js`),a=i(),s=Object.keys(r.plugins),{enabled:c,disabled:l,errors:u}=await D(),f=[...c,...l],p=f.filter(e=>e.source.endsWith(`@inline`)),_=u.filter(e=>e.source.endsWith(`@inline`)||e.source.startsWith(`inline[`));if(e.json){let t=new Map(f.map(e=>[e.source,e])),n=[];for(let e of s.sort()){let i=r.plugins[e];if(!i||i.length===0)continue;let o=N(e).name,s=u.filter(t=>t.source===e||`plugin`in t&&t.plugin===o).map(j);for(let r of i){let i=t.get(e),o;if(i){let e=i.mcpServers||await g(i);e&&Object.keys(e).length>0&&(o=e)}n.push({id:e,version:r.version||`unknown`,scope:r.scope,enabled:a.has(e),installPath:r.installPath,installedAt:r.installedAt,lastUpdated:r.lastUpdated,projectPath:r.projectPath,mcpServers:o,errors:s.length>0?s:void 0})}}for(let e of p){let t=e.mcpServers||await g(e),r=_.filter(t=>t.source===e.source||`plugin`in t&&t.plugin===e.name).map(j);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 _.filter(e=>e.source.startsWith(`inline[`)))n.push({id:e.source,version:`unknown`,scope:`session`,enabled:!1,installPath:`path`in e?e.path:``,errors:[j(e)]});if(e.available){let e=[];try{let[t,n]=await Promise.all([x(),Y()]),{marketplaces:r}=await k(t);for(let{name:t,data:i}of r)if(i)for(let r of i.plugins){let i=m(r.name,t);h(i)||e.push({pluginId:i,name:r.name,description:r.description,marketplaceName:t,version:r.version,source:r.source,installCount:n?.get(i)})}}catch{}F(o({installed:n,available:e},null,2))}else F(o(n,null,2))}s.length===0&&p.length===0&&_.length===0&&F("No plugins installed. Use `claude plugin install` to install a plugin."),s.length>0&&console.log(`Installed plugins:
2
2
  `);for(let e of s.sort()){let n=r.plugins[e];if(!n||n.length===0)continue;let i=N(e).name,o=u.filter(t=>t.source===e||`plugin`in t&&t.plugin===i);for(let r of n){let n=a.has(e),i=o.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 o)console.log(` Error: ${j(e)}`);console.log(``)}}if(p.length>0||_.length>0){console.log(`Session-only plugins (--plugin-dir):
3
3
  `);for(let e of p){let n=_.filter(t=>t.source===e.source||`plugin`in t&&t.plugin===e.name),r=n.length>0?`${t.cross} loaded with errors`:`${t.tick} loaded`;console.log(` ${t.pointer} ${e.source}`),console.log(` Version: ${e.manifest.version??`unknown`}`),console.log(` Path: ${e.path}`),console.log(` Status: ${r}`);for(let e of n)console.log(` Error: ${j(e)}`);console.log(``)}for(let e of _.filter(e=>e.source.startsWith(`inline[`)))console.log(` ${t.pointer} ${e.source}: ${t.cross} ${j(e)}\n`)}F()}async function se(e,r){r.cowork&&n(!0);try{let n=await re(e);n||I(`${t.cross} Invalid marketplace source format. Try: owner/repo, https://..., or ./path`),`error`in n&&I(`${t.cross} ${n.error}`);let i=r.scope??`user`;i!==`user`&&i!==`project`&&i!==`local`&&I(`${t.cross} Invalid scope '${i}'. Use: user, project, or local`);let a=P(i),o=n;r.sparse&&r.sparse.length>0&&(o.source===`github`||o.source===`git`?o={...o,sparsePaths:r.sparse}:I(`${t.cross} --sparse is only supported for github and git marketplace sources (got: ${o.source})`)),console.log(`Adding marketplace...`);let{name:s,alreadyMaterialized:c,resolvedSource:l}=await y(o,e=>{console.log(e)});T(s,{source:l},a),E();let u=o.source;o.source===`github`&&(u=o.repo),d(`tengu_marketplace_added`,{source_type:u}),F(c?`${t.tick} Marketplace '${s}' already on disk — declared in ${i} settings`:`${t.tick} Successfully added marketplace: ${s} (declared in ${i} settings)`)}catch(e){Q(e,`add marketplace`)}}async function ce(e){e.cowork&&n(!0);try{let n=await x(),r=Object.keys(n);e.json&&F(o(r.sort().map(e=>{let t=n[e],r=t?.source;return{name:e,source:r?.source,...r?.source===`github`&&{repo:r.repo},...r?.source===`git`&&{url:r.url},...r?.source===`url`&&{url:r.url},...r?.source===`directory`&&{path:r.path},...r?.source===`file`&&{path:r.path},installLocation:t?.installLocation}}),null,2)),r.length===0&&F(`No marketplaces configured`),console.log(`Configured marketplaces:
4
4
  `),r.forEach(e=>{let r=n[e];if(console.log(` ${t.pointer} ${e}`),r?.source){let e=r.source;e.source===`github`?console.log(` Source: GitHub (${e.repo})`):e.source===`git`?console.log(` Source: Git (${e.url})`):e.source===`url`?console.log(` Source: URL (${e.url})`):e.source===`directory`?console.log(` Source: Directory (${e.path})`):e.source===`file`&&console.log(` Source: File (${e.path})`)}console.log(``)}),F()}catch(e){Q(e,`list marketplaces`)}}async function le(e,r){r.cowork&&n(!0);try{await O(e),E(),d(`tengu_marketplace_removed`,{marketplace_name:e}),F(`${t.tick} Successfully removed marketplace: ${e}`)}catch(e){Q(e,`remove marketplace`)}}async function ue(e,r){r.cowork&&n(!0);try{if(e)console.log(`Updating marketplace: ${e}...`),await b(e,e=>{console.log(e)}),E(),d(`tengu_marketplace_updated`,{marketplace_name:e}),F(`${t.tick} Successfully updated marketplace: ${e}`);else{let e=await x(),n=Object.keys(e);n.length===0&&F(`No marketplaces configured`),console.log(`Updating ${n.length} marketplace(s)...`),await w(),E(),d(`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 de(e,t){t.cowork&&n(!0);let r=t.scope||`user`;t.cowork&&r!==`user`&&I(`--cowork can only be used with user scope`),R.includes(r)||I(`Invalid scope: ${r}. Must be one of: ${R.join(`, `)}.`);let{name:i,marketplace:a}=N(e);d(`tengu_plugin_install_command`,{_PROTO_plugin_name:i,...a&&{_PROTO_marketplace_name:a},scope:r}),await B(e,r)}async function fe(e,t){t.cowork&&n(!0);let r=t.scope||`user`;t.cowork&&r!==`user`&&I(`--cowork can only be used with user scope`),R.includes(r)||I(`Invalid scope: ${r}. Must be one of: ${R.join(`, `)}.`);let{name:i,marketplace:a}=N(e);d(`tengu_plugin_uninstall_command`,{_PROTO_plugin_name:i,...a&&{_PROTO_marketplace_name:a},scope:r}),await z(e,r,t.keepData)}async function pe(e,t){t.cowork&&n(!0);let r;t.scope&&(R.includes(t.scope)||I(`Invalid scope "${t.scope}". Valid scopes: ${R.join(`, `)}`),r=t.scope),t.cowork&&r!==void 0&&r!==`user`&&I(`--cowork can only be used with user scope`),t.cowork&&r===void 0&&(r=`user`);let{name:i,marketplace:a}=N(e);d(`tengu_plugin_enable_command`,{_PROTO_plugin_name:i,...a&&{_PROTO_marketplace_name:a},scope:r??`auto`}),await U(e,r)}async function me(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&&n(!0),t.all){t.scope&&I(`Cannot use --scope with --all`),d(`tengu_plugin_disable_command`,{}),await W();return}let r;t.scope&&(R.includes(t.scope)||I(`Invalid scope "${t.scope}". Valid scopes: ${R.join(`, `)}`),r=t.scope),t.cowork&&r!==void 0&&r!==`user`&&I(`--cowork can only be used with user scope`),t.cowork&&r===void 0&&(r=`user`);let{name:i,marketplace:a}=N(e);d(`tengu_plugin_disable_command`,{_PROTO_plugin_name:i,...a&&{_PROTO_marketplace_name:a},scope:r??`auto`}),await V(e,r)}async function he(e,t){t.cowork&&n(!0);let{name:r,marketplace:i}=N(e);d(`tengu_plugin_update_command`,{_PROTO_plugin_name:r,...i&&{_PROTO_marketplace_name:i}});let a=`user`;t.scope&&(L.includes(t.scope)||I(`Invalid scope "${t.scope}". Valid scopes: ${L.join(`, `)}`),a=t.scope),t.cowork&&a!==`user`&&I(`--cowork can only be used with user scope`),await H(e,a)}export{se as marketplaceAddHandler,ce as marketplaceListHandler,le as marketplaceRemoveHandler,ue as marketplaceUpdateHandler,me as pluginDisableHandler,pe as pluginEnableHandler,de as pluginInstallHandler,oe as pluginListHandler,fe as pluginUninstallHandler,he as pluginUpdateHandler,ae as pluginValidateHandler};
@@ -0,0 +1 @@
1
+ import{Ba as e,Ka as t,Ra as n}from"./loadAgentsDir-Cl2w3uvH.js";n();export{e as isPolicyAllowed,t as waitForPolicyLimitsToLoad};
@@ -1 +1 @@
1
- import{Cn as e,wn as t}from"./schemas-BGAvj1T4.js";import{t as n}from"./v4-f1i_CNUT.js";import{S as r,v as i}from"./paths-o5iA-EnQ.js";import{n as a,t as o}from"./lazySchema-2sOku3cX.js";n(),o(),r();var s=2e3,c=6e5,l={poll_interval_ms_not_at_capacity:s,poll_interval_ms_at_capacity:c,non_exclusive_heartbeat_interval_ms:0,multisession_poll_interval_ms_not_at_capacity:s,multisession_poll_interval_ms_partial_capacity:s,multisession_poll_interval_ms_at_capacity:c,reclaim_older_than_ms:5e3,session_keepalive_interval_v2_ms:12e4},u={message:`must be 0 (disabled) or ≥100ms`},d=a(()=>t({poll_interval_ms_not_at_capacity:e().int().min(100),poll_interval_ms_at_capacity:e().int().refine(e=>e===0||e>=100,u),non_exclusive_heartbeat_interval_ms:e().int().min(0).default(0),multisession_poll_interval_ms_not_at_capacity:e().int().min(100).default(l.multisession_poll_interval_ms_not_at_capacity),multisession_poll_interval_ms_partial_capacity:e().int().min(100).default(l.multisession_poll_interval_ms_partial_capacity),multisession_poll_interval_ms_at_capacity:e().int().refine(e=>e===0||e>=100,u).default(l.multisession_poll_interval_ms_at_capacity),reclaim_older_than_ms:e().int().min(1).default(5e3),session_keepalive_interval_v2_ms:e().int().min(0).default(12e4)}).refine(e=>e.non_exclusive_heartbeat_interval_ms>0||e.poll_interval_ms_at_capacity>0,{message:`at-capacity liveness requires non_exclusive_heartbeat_interval_ms > 0 or poll_interval_ms_at_capacity > 0`}).refine(e=>e.non_exclusive_heartbeat_interval_ms>0||e.multisession_poll_interval_ms_at_capacity>0,{message:`at-capacity liveness requires non_exclusive_heartbeat_interval_ms > 0 or multisession_poll_interval_ms_at_capacity > 0`}));function f(){let e=i(`tengu_bridge_poll_interval_config`,l,300*1e3),t=d().safeParse(e);return t.success?t.data:l}export{l as n,f as t};
1
+ import{Cn as e,wn as t}from"./schemas-BGAvj1T4.js";import{t as n}from"./v4-f1i_CNUT.js";import{S as r,v as i}from"./paths-q1-Ni8Oh.js";import{n as a,t as o}from"./lazySchema-2sOku3cX.js";n(),o(),r();var s=2e3,c=6e5,l={poll_interval_ms_not_at_capacity:s,poll_interval_ms_at_capacity:c,non_exclusive_heartbeat_interval_ms:0,multisession_poll_interval_ms_not_at_capacity:s,multisession_poll_interval_ms_partial_capacity:s,multisession_poll_interval_ms_at_capacity:c,reclaim_older_than_ms:5e3,session_keepalive_interval_v2_ms:12e4},u={message:`must be 0 (disabled) or ≥100ms`},d=a(()=>t({poll_interval_ms_not_at_capacity:e().int().min(100),poll_interval_ms_at_capacity:e().int().refine(e=>e===0||e>=100,u),non_exclusive_heartbeat_interval_ms:e().int().min(0).default(0),multisession_poll_interval_ms_not_at_capacity:e().int().min(100).default(l.multisession_poll_interval_ms_not_at_capacity),multisession_poll_interval_ms_partial_capacity:e().int().min(100).default(l.multisession_poll_interval_ms_partial_capacity),multisession_poll_interval_ms_at_capacity:e().int().refine(e=>e===0||e>=100,u).default(l.multisession_poll_interval_ms_at_capacity),reclaim_older_than_ms:e().int().min(1).default(5e3),session_keepalive_interval_v2_ms:e().int().min(0).default(12e4)}).refine(e=>e.non_exclusive_heartbeat_interval_ms>0||e.poll_interval_ms_at_capacity>0,{message:`at-capacity liveness requires non_exclusive_heartbeat_interval_ms > 0 or poll_interval_ms_at_capacity > 0`}).refine(e=>e.non_exclusive_heartbeat_interval_ms>0||e.multisession_poll_interval_ms_at_capacity>0,{message:`at-capacity liveness requires non_exclusive_heartbeat_interval_ms > 0 or multisession_poll_interval_ms_at_capacity > 0`}));function f(){let e=i(`tengu_bridge_poll_interval_config`,l,300*1e3),t=d().safeParse(e);return t.success?t.data:l}export{l as n,f as t};
@@ -1 +1 @@
1
- import{n as e}from"./chunk-DR8-3Aex.js";import{i as t,n,t as r}from"./poorMode-7N6J6YN2.js";var i;e((()=>{r(),i=async(e,r)=>{let i=!n();return t(i),i?r.setAppState(e=>({...e,promptSuggestionEnabled:!1})):r.setAppState(e=>({...e,promptSuggestionEnabled:!0})),{type:`text`,value:`Poor mode ${i?`ON`:`OFF`} — ${i?`extract_memories and prompt_suggestion are disabled`:`extract_memories and prompt_suggestion are restored`}`}}}))();export{i as call};
1
+ import{n as e}from"./chunk-DR8-3Aex.js";import{i as t,n,t as r}from"./poorMode-DFcYVnMT.js";var i;e((()=>{r(),i=async(e,r)=>{let i=!n();return t(i),i?r.setAppState(e=>({...e,promptSuggestionEnabled:!1})):r.setAppState(e=>({...e,promptSuggestionEnabled:!0})),{type:`text`,value:`Poor mode ${i?`ON`:`OFF`} — ${i?`extract_memories and prompt_suggestion are disabled`:`extract_memories and prompt_suggestion are restored`}`}}}))();export{i as call};
@@ -0,0 +1 @@
1
+ import{n as e,t}from"./poorMode-DFcYVnMT.js";t();export{e as isPoorModeActive};
@@ -1 +1 @@
1
- import{n as e,r as t}from"./chunk-DR8-3Aex.js";import{Ka as n,lo as r,oo as i}from"./paths-o5iA-EnQ.js";var a=t({isPoorModeActive:()=>o,setPoorMode:()=>s});function o(){return c===null&&(c=n().poorMode===!0),c}function s(e){c=e,r(`userSettings`,{poorMode:e||void 0})}var c,l=e((()=>{i(),c=null}));export{s as i,o as n,a as r,l as t};
1
+ import{n as e,r as t}from"./chunk-DR8-3Aex.js";import{Ka as n,lo as r,oo as i}from"./paths-q1-Ni8Oh.js";var a=t({isPoorModeActive:()=>o,setPoorMode:()=>s});function o(){return c===null&&(c=n().poorMode===!0),c}function s(e){c=e,r(`userSettings`,{poorMode:e||void 0})}var c,l=e((()=>{i(),c=null}));export{s as i,o as n,a as r,l as t};
@@ -1,4 +1,4 @@
1
- import{a as e}from"./chunk-DR8-3Aex.js";import{c as t,l as n,s as r,u as i}from"./envUtils-BWeoiL4Y.js";import{n as a,t as o}from"./defineProperty-80gRi2ZW.js";import{B as s,b as c,v as l}from"./server-DzOdtq8A.js";import{Ct as u,F as d,In as f,R as p,Tn as m,Vn as h,_n as g,_r as ee,cn as _,jr as te,ln as v,nr as ne,tr as re,tt as y,y as b}from"./state-sIHsFpDu.js";import{Aa as x,Br as S,Bt as ie,C as ae,Cr as oe,Dr as se,El as C,Et as ce,Fa as le,Ki as ue,Ma as w,Ml as de,Na as fe,Ot as T,Pr as E,Rr as pe,S as me,Si as he,Tl as ge,Xn as _e,Xo as D,Yn as O,_ as ve,a as ye,bl as be,c as xe,jl as Se,kt as Ce,ls as we,ms as Te,no as k,on as A,oo as Ee,pi as De,qi as Oe,ss as j,to as ke,vi as M,xi as Ae,xs as N,yi as je,yl as Me}from"./paths-o5iA-EnQ.js";import{E as P,K as Ne,L as F,T as Pe,V as Fe,X as Ie,Y as Le,c as Re,d as I,h as ze,p as Be,s as L,w as R}from"./debug-UI3T040K.js";import{n as Ve,r as z}from"./analytics-DqMQntaB.js";import{n as He,t as Ue}from"./cwd--iizewsn.js";import{i as We,n as B,o as V}from"./process-DMKLUQIO.js";import{F as Ge,I as Ke,P as H}from"./git-CN3qtTb_.js";import{J as qe,K as Je,c as Ye,et as U,i as Xe,o as Ze,s as W}from"./log-CzsijfHZ.js";import{i as Qe,n as $e}from"./path-C4kbwvSH.js";import{s as et,u as tt}from"./types-Csi32ZXh.js";import{C as nt,c as rt,d as it,l as at,m as ot,s as st,x as G}from"./teammate-DMYOtLTK.js";import{n as ct,t as lt}from"./sleep-8Eb9j_Ly.js";import{$C as ut,$D as dt,$E as ft,$T as pt,$r as mt,AC as ht,Ar as gt,Av as _t,BD as vt,B_ as yt,Ba as bt,Cb as xt,Cn as St,Cx as Ct,D as wt,DC as Tt,DO as Et,Di as Dt,Ei as Ot,Ex as kt,F as At,FD as K,Fc as jt,G as Mt,GD as Nt,GE as Pt,Gi as Ft,HD as It,HS as Lt,HT as Rt,Hi as zt,ID as Bt,Ic as Vt,Is as Ht,JA as Ut,JD as Wt,JT as Gt,K as Kt,Ks as qt,LD as Jt,LT as Yt,Lo as Xt,Ls as Zt,Ly as Qt,Ml as $t,Mx as en,NE as tn,NO as nn,Nc as rn,O as an,OC as on,OD as sn,OT as cn,Of as ln,Or as un,Ov as dn,PO as fn,Pc as pn,QE as mn,QT as q,Qv as hn,RD as gn,Ra as _n,Ry as vn,S as yn,SA as bn,SE as xn,Sx as Sn,TE as Cn,Tv as wn,UC as Tn,UD as En,Uh as Dn,Us as On,Uu as kn,VD as An,VS as jn,V_ as Mn,Vs as Nn,Vt as Pn,WD as Fn,WE as In,WT as Ln,Wu as Rn,Xi as zn,ZE as Bn,ZT as Vn,Zh as Hn,_c as Un,aj as Wn,as as Gn,au as Kn,bO as qn,bc as Jn,bw as Yn,bx as Xn,cs as Zn,dE as Qn,db as $n,di as er,eE as tr,eg as nr,ey as rr,fC as ir,fE as ar,fO as or,fc as sr,fi as cr,fs as lr,fw as ur,gc as dr,gi as fr,gj as pr,gw as mr,hb as hr,hc as gr,hi as _r,hw as vr,ip as yr,ir as br,jE as xr,jl as Sr,jv as Cr,jx as wr,kD as Tr,kT as Er,kf as Dr,kr as Or,kv as kr,kx as Ar,la as jr,lj as Mr,lr as Nr,lw as Pr,mE as Fr,mO as J,mc as Ir,mj as Lr,ms as Rr,nD as zr,nO as Br,nu as Vr,nw as Hr,ny as Ur,o as Wr,oj as Gr,os as Kr,oy as qr,p as Jr,pC as Yr,pE as Xr,pO as Zr,pc as Qr,po as $r,qD as ei,qT as ti,qu as ni,rD as ri,rj as ii,rp as ai,ru as oi,s as si,sA as ci,sy as li,tD as ui,tg as di,ty as fi,u as pi,uA as mi,uC as hi,uw as gi,vA as _i,vc as vi,vi as yi,w as bi,wE as xi,wO as Si,wb as Ci,wn as wi,wv as Ti,x as Ei,xE as Di,xO as Oi,xc as ki,xv as Ai,yO as ji,yc as Mi,yn as Ni,zD as Pi,zi as Fi}from"./loadAgentsDir-DF6FgRn-.js";import{F as Ii,Hn as Li,Ht as Ri,M as zi,Nt as Bi,Pt as Vi,Vn as Hi,_t as Ui,pn as Wi,vt as Gi,xn as Ki}from"./prompt-DiHksuOs.js";import{i as qi,o as Ji}from"./xml-CqxiCY4v.js";import{a as Yi,o as Xi,s as Zi}from"./fileStateCache-C7-TxF8G.js";import{A as Qi,C as $i,D as ea,N as ta,O as na,P as ra,Z as ia,_ as aa,d as oa,g as sa,h as ca,m as la,u as ua,v as da,y as fa}from"./rcDebugLog-BNojB_eB.js";import{c as pa,l as ma}from"./commitAttribution-q7SEukgl.js";import{P as ha,V as ga,a as _a,d as va}from"./teamHelpers-BFZ4eVwW.js";import{t as ya}from"./pollConfig-DyHumJli.js";import{r as ba}from"./inboundAttachments-DPMETKd6.js";import{i as xa,n as Sa,s as Ca}from"./mappers-CPL2ni36.js";import{n as wa,r as Ta}from"./sessionTitle-CxmvZO71.js";import{n as Ea,t as Da}from"./ccrClient-B9pi3b8Y.js";import{n as Oa,t as ka}from"./HybridTransport-BNexuwcN.js";import{n as Aa,t as ja}from"./SSETransport-C9hd2v-w.js";import{t as Ma}from"./pluginBlocklist-DeX8I4dK.js";import{c as Na,d as Pa,f as Fa,l as Ia,o as La,r as Ra,s as za,u as Ba}from"./channelNotification-n7Avue-9.js";import{t as Va}from"./onChangeAppState-DxTGoS7j.js";import{t as Ha}from"./settingsSync-54E8xV8N.js";import{a as Ua,c as Wa,d as Ga,f as Ka,l as qa,m as Ja,o as Ya,p as Xa,r as Za,t as Qa}from"./cronJitterConfig-DmBBJDTf.js";import{i as $a,n as eo}from"./toolPool-DFpa-yul.js";import{n as to,r as no}from"./QueryEngine-DigBggXq.js";import{n as ro,r as io}from"./sideQuestion-DBrzdgkl.js";import{n as ao,r as oo}from"./context-noninteractive-CFlod2Eg.js";import{a as so,o as co,t as lo}from"./skillChangeDetector-NJrEtU47.js";import{n as uo,t as fo}from"./refresh-D48fjYJ4.js";import{dirname as po,join as mo}from"path";import{PassThrough as ho}from"stream";import{randomUUID as Y}from"crypto";import{readFile as go,stat as _o}from"fs/promises";import{URL as vo}from"url";import{cwd as X}from"process";a(),_(),He(),Le(),Fe(),R(),ze(),B(),L(),H(),U(),Ze(),Qe(),et(),G(),N(),Ee(),le(),w(),Oe(),E(),O(),lt(),A(),at(),me(),ye(),Hi(),Ki(),_i(),mi(),Oi(),Pi(),Tr(),Pt(),ta(),xn(),ha(),pt(),Yt(),na(),yt(),oa(),jt(),pn(),Kr(),Xt(),zn(),gt(),wi(),Ni(),Ha(),r(),Aa();function yo(e,t={},n,r){if(i(process.env.CLAUDE_CODE_USE_CCR_V2)){let i=new vo(e.href);return i.protocol===`wss:`?i.protocol=`https:`:i.protocol===`ws:`&&(i.protocol=`http:`),i.pathname=i.pathname.replace(/\/$/,``)+`/worker/events/stream`,new ja(i,t,n,r)}if(e.protocol===`ws:`||e.protocol===`wss:`)return i(process.env.CLAUDE_CODE_POST_FOR_SESSION_INGRESS_V2)?new ka(e,t,n,r):new Oa(e,t,n,r);throw Error(`Unsupported protocol: ${e.protocol}`)}r(),Aa();var bo=class extends Ga{constructor(e,t,n){let r=new ho({encoding:`utf8`});super(r,n),o(this,`url`,void 0),o(this,`transport`,void 0),o(this,`inputStream`,void 0),o(this,`isBridge`,!1),o(this,`isDebug`,!1),o(this,`ccrClient`,null),o(this,`keepAliveTimer`,null),this.inputStream=r,this.url=new vo(e);let a={},s=ea();s?a.Authorization=`Bearer ${s}`:I(`[remote-io] No session ingress token available`,{level:`error`});let c=process.env.CLAUDE_CODE_ENVIRONMENT_RUNNER_VERSION;if(c&&(a[`x-environment-runner-version`]=c),this.transport=yo(this.url,a,u(),()=>{let e={},t=ea();t&&(e.Authorization=`Bearer ${t}`);let n=process.env.CLAUDE_CODE_ENVIRONMENT_RUNNER_VERSION;return n&&(e[`x-environment-runner-version`]=n),e}),this.isBridge=process.env.CLAUDE_CODE_ENVIRONMENT_KIND===`bridge`,this.isDebug=Re(),this.transport.setOnData(e=>{this.inputStream.write(e),this.isBridge&&this.isDebug&&V(e.endsWith(`
1
+ import{a as e}from"./chunk-DR8-3Aex.js";import{c as t,l as n,s as r,u as i}from"./envUtils-BWeoiL4Y.js";import{n as a,t as o}from"./defineProperty-80gRi2ZW.js";import{B as s,b as c,v as l}from"./server-DzOdtq8A.js";import{Ct as u,F as d,In as f,R as p,Tn as m,Vn as h,_n as g,_r as ee,cn as _,jr as te,ln as v,nr as ne,tr as re,tt as y,y as b}from"./state-sIHsFpDu.js";import{Aa as x,Br as S,Bt as ie,C as ae,Cr as oe,Dr as se,El as C,Et as ce,Fa as le,Ki as ue,Ma as w,Ml as de,Na as fe,Ot as T,Pr as E,Rr as pe,S as me,Si as he,Tl as ge,Xn as _e,Xo as D,Yn as O,_ as ve,a as ye,bl as be,c as xe,jl as Se,kt as Ce,ls as we,ms as Te,no as k,on as A,oo as Ee,pi as De,qi as Oe,ss as j,to as ke,vi as M,xi as Ae,xs as N,yi as je,yl as Me}from"./paths-q1-Ni8Oh.js";import{E as P,K as Ne,L as F,T as Pe,V as Fe,X as Ie,Y as Le,c as Re,d as I,h as ze,p as Be,s as L,w as R}from"./debug-UI3T040K.js";import{n as Ve,r as z}from"./analytics-DqMQntaB.js";import{n as He,t as Ue}from"./cwd--iizewsn.js";import{i as We,n as B,o as V}from"./process-DMKLUQIO.js";import{F as Ge,I as Ke,P as H}from"./git-CN3qtTb_.js";import{J as qe,K as Je,c as Ye,et as U,i as Xe,o as Ze,s as W}from"./log-CzsijfHZ.js";import{i as Qe,n as $e}from"./path-B3lx7yHn.js";import{s as et,u as tt}from"./types-Csi32ZXh.js";import{C as nt,c as rt,d as it,l as at,m as ot,s as st,x as G}from"./teammate-DMYOtLTK.js";import{n as ct,t as lt}from"./sleep-8Eb9j_Ly.js";import{$C as ut,$D as dt,$E as ft,$T as pt,$r as mt,AC as ht,Ar as gt,Av as _t,BD as vt,B_ as yt,Ba as bt,Cb as xt,Cn as St,Cx as Ct,D as wt,DC as Tt,DO as Et,Di as Dt,Ei as Ot,Ex as kt,F as At,FD as K,Fc as jt,G as Mt,GD as Nt,GE as Pt,Gi as Ft,HD as It,HS as Lt,HT as Rt,Hi as zt,ID as Bt,Ic as Vt,Is as Ht,JA as Ut,JD as Wt,JT as Gt,K as Kt,Ks as qt,LD as Jt,LT as Yt,Lo as Xt,Ls as Zt,Ly as Qt,Ml as $t,Mx as en,NE as tn,NO as nn,Nc as rn,O as an,OC as on,OD as sn,OT as cn,Of as ln,Or as un,Ov as dn,PO as fn,Pc as pn,QE as mn,QT as q,Qv as hn,RD as gn,Ra as _n,Ry as vn,S as yn,SA as bn,SE as xn,Sx as Sn,TE as Cn,Tv as wn,UC as Tn,UD as En,Uh as Dn,Us as On,Uu as kn,VD as An,VS as jn,V_ as Mn,Vs as Nn,Vt as Pn,WD as Fn,WE as In,WT as Ln,Wu as Rn,Xi as zn,ZE as Bn,ZT as Vn,Zh as Hn,_c as Un,aj as Wn,as as Gn,au as Kn,bO as qn,bc as Jn,bw as Yn,bx as Xn,cs as Zn,dE as Qn,db as $n,di as er,eE as tr,eg as nr,ey as rr,fC as ir,fE as ar,fO as or,fc as sr,fi as cr,fs as lr,fw as ur,gc as dr,gi as fr,gj as pr,gw as mr,hb as hr,hc as gr,hi as _r,hw as vr,ip as yr,ir as br,jE as xr,jl as Sr,jv as Cr,jx as wr,kD as Tr,kT as Er,kf as Dr,kr as Or,kv as kr,kx as Ar,la as jr,lj as Mr,lr as Nr,lw as Pr,mE as Fr,mO as J,mc as Ir,mj as Lr,ms as Rr,nD as zr,nO as Br,nu as Vr,nw as Hr,ny as Ur,o as Wr,oj as Gr,os as Kr,oy as qr,p as Jr,pC as Yr,pE as Xr,pO as Zr,pc as Qr,po as $r,qD as ei,qT as ti,qu as ni,rD as ri,rj as ii,rp as ai,ru as oi,s as si,sA as ci,sy as li,tD as ui,tg as di,ty as fi,u as pi,uA as mi,uC as hi,uw as gi,vA as _i,vc as vi,vi as yi,w as bi,wE as xi,wO as Si,wb as Ci,wn as wi,wv as Ti,x as Ei,xE as Di,xO as Oi,xc as ki,xv as Ai,yO as ji,yc as Mi,yn as Ni,zD as Pi,zi as Fi}from"./loadAgentsDir-Cl2w3uvH.js";import{F as Ii,Hn as Li,Ht as Ri,M as zi,Nt as Bi,Pt as Vi,Vn as Hi,_t as Ui,pn as Wi,vt as Gi,xn as Ki}from"./prompt-BmOnuQfF.js";import{i as qi,o as Ji}from"./xml-CMdTGiv6.js";import{a as Yi,o as Xi,s as Zi}from"./fileStateCache-C7-TxF8G.js";import{A as Qi,C as $i,D as ea,N as ta,O as na,P as ra,Z as ia,_ as aa,d as oa,g as sa,h as ca,m as la,u as ua,v as da,y as fa}from"./rcDebugLog-fhwD4wm-.js";import{c as pa,l as ma}from"./commitAttribution-CUdm_sRl.js";import{P as ha,V as ga,a as _a,d as va}from"./teamHelpers-BJuKEuyS.js";import{t as ya}from"./pollConfig-BGXMaSla.js";import{r as ba}from"./inboundAttachments-B3ZTyNKF.js";import{i as xa,n as Sa,s as Ca}from"./mappers-COd8OOml.js";import{n as wa,r as Ta}from"./sessionTitle-DnvlYJ-c.js";import{n as Ea,t as Da}from"./ccrClient-BOrmrmgF.js";import{n as Oa,t as ka}from"./HybridTransport-xN03sWrt.js";import{n as Aa,t as ja}from"./SSETransport-Cy1rXP6E.js";import{t as Ma}from"./pluginBlocklist-BHxIUqu4.js";import{c as Na,d as Pa,f as Fa,l as Ia,o as La,r as Ra,s as za,u as Ba}from"./channelNotification-D8do6HUN.js";import{t as Va}from"./onChangeAppState-Cn_HSmmQ.js";import{t as Ha}from"./settingsSync-CHZVpM34.js";import{a as Ua,c as Wa,d as Ga,f as Ka,l as qa,m as Ja,o as Ya,p as Xa,r as Za,t as Qa}from"./cronJitterConfig-By18m-PD.js";import{i as $a,n as eo}from"./toolPool-DYvz_Mjt.js";import{n as to,r as no}from"./QueryEngine-J15EOjWx.js";import{n as ro,r as io}from"./sideQuestion-Bfa0SZn5.js";import{n as ao,r as oo}from"./context-noninteractive-BJ4hE3MX.js";import{a as so,o as co,t as lo}from"./skillChangeDetector-BEDBRGbY.js";import{n as uo,t as fo}from"./refresh-C7S_6LOQ.js";import{dirname as po,join as mo}from"path";import{PassThrough as ho}from"stream";import{randomUUID as Y}from"crypto";import{readFile as go,stat as _o}from"fs/promises";import{URL as vo}from"url";import{cwd as X}from"process";a(),_(),He(),Le(),Fe(),R(),ze(),B(),L(),H(),U(),Ze(),Qe(),et(),G(),N(),Ee(),le(),w(),Oe(),E(),O(),lt(),A(),at(),me(),ye(),Hi(),Ki(),_i(),mi(),Oi(),Pi(),Tr(),Pt(),ta(),xn(),ha(),pt(),Yt(),na(),yt(),oa(),jt(),pn(),Kr(),Xt(),zn(),gt(),wi(),Ni(),Ha(),r(),Aa();function yo(e,t={},n,r){if(i(process.env.CLAUDE_CODE_USE_CCR_V2)){let i=new vo(e.href);return i.protocol===`wss:`?i.protocol=`https:`:i.protocol===`ws:`&&(i.protocol=`http:`),i.pathname=i.pathname.replace(/\/$/,``)+`/worker/events/stream`,new ja(i,t,n,r)}if(e.protocol===`ws:`||e.protocol===`wss:`)return i(process.env.CLAUDE_CODE_POST_FOR_SESSION_INGRESS_V2)?new ka(e,t,n,r):new Oa(e,t,n,r);throw Error(`Unsupported protocol: ${e.protocol}`)}r(),Aa();var bo=class extends Ga{constructor(e,t,n){let r=new ho({encoding:`utf8`});super(r,n),o(this,`url`,void 0),o(this,`transport`,void 0),o(this,`inputStream`,void 0),o(this,`isBridge`,!1),o(this,`isDebug`,!1),o(this,`ccrClient`,null),o(this,`keepAliveTimer`,null),this.inputStream=r,this.url=new vo(e);let a={},s=ea();s?a.Authorization=`Bearer ${s}`:I(`[remote-io] No session ingress token available`,{level:`error`});let c=process.env.CLAUDE_CODE_ENVIRONMENT_RUNNER_VERSION;if(c&&(a[`x-environment-runner-version`]=c),this.transport=yo(this.url,a,u(),()=>{let e={},t=ea();t&&(e.Authorization=`Bearer ${t}`);let n=process.env.CLAUDE_CODE_ENVIRONMENT_RUNNER_VERSION;return n&&(e[`x-environment-runner-version`]=n),e}),this.isBridge=process.env.CLAUDE_CODE_ENVIRONMENT_KIND===`bridge`,this.isDebug=Re(),this.transport.setOnData(e=>{this.inputStream.write(e),this.isBridge&&this.isDebug&&V(e.endsWith(`
2
2
  `)?e:e+`
3
3
  `)}),this.transport.setOnClose(()=>{this.inputStream.end()}),i(process.env.CLAUDE_CODE_USE_CCR_V2)){if(!(this.transport instanceof ja))throw Error(`CCR v2 requires SSETransport; check getTransportForUrl`);this.ccrClient=new Da(this.transport,this.url);let e=this.ccrClient.initialize();this.restoredWorkerState=e.catch(()=>null),e.catch(e=>{Ge(`error`,`cli_worker_lifecycle_init_failed`,{reason:e instanceof Ea?e.reason:`unknown`}),W(Error(`CCRClient initialization failed: ${F(e)}`)),Vn(1,`other`)}),Ie(async()=>this.ccrClient?.close()),Dt((e,t,n)=>this.ccrClient.writeInternalEvent(e,t,n)),Ot(()=>this.ccrClient.readInternalEvents(),()=>this.ccrClient.readSubagentInternalEvents());let t={started:`processing`,completed:`processed`};An((e,n)=>{this.ccrClient?.reportDelivery(e,t[n])}),da((e,t)=>{this.ccrClient?.reportState(e,t)}),aa(e=>{this.ccrClient?.reportMetadata(e)},{replayCurrent:!0})}this.transport.connect();let l=ya().session_keepalive_interval_v2_ms;if(this.isBridge&&l>0&&(this.keepAliveTimer=setInterval(()=>{I(`[remote-io] keep_alive sent`),this.write({type:`keep_alive`}).catch(e=>{I(`[remote-io] keep_alive write failed: ${F(e)}`)})},l),this.keepAliveTimer.unref?.()),Ie(async()=>this.close()),t){let e=this.inputStream;(async()=>{for await(let n of t)e.write(String(n).replace(/\n$/,``)+`
4
4
  `)})()}}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)&&V(Ka(e)+`
@@ -28,12 +28,12 @@ Shut down your team and prepare your final response for the user.`,Ro=1e4,zo=new
28
28
  `);break;case`stream-json`:break;default:if(!S||S.type!==`result`)throw Error(`No messages returned`);switch(S.subtype){case`success`:V(S.result.endsWith(`
29
29
  `)?S.result:S.result+`
30
30
  `);break;case`error_during_execution`:V(`Execution error`);break;case`error_max_turns`:V(`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`:V(`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`:V(`Error: Failed to provide valid structured output after maximum retries.
31
- Tip: Simplify your schema or check if the output format matches the expected structure.`)}}if(gn(),xe())try{let{drainPendingExtraction:e}=await import(`./extractMemories-wcRNh_jz.js`);await e()}catch{}q(S?.type===`result`&&S?.is_error?1:0)}function Ko(e,r,a,o,s,m,h,g,_,te,v,ne){let y=!1,b,x=!1,ae=!1,le=null,w,T=e.outbound;process.on(`SIGINT`,()=>{Ge(`info`,`shutdown_signal`,{signal:`SIGINT`}),w&&!w.signal.aborted&&w.abort(),Vn(0)}),Ie(async()=>{let t={};for(let e of xi(g()))vn(e)&&(t[e.type]=(t[e.type]??0)+1);Ge(`info`,`run_state_at_shutdown`,{run_active:y,run_phase:b,worker_status:ua(),internal_events_pending:e.internalEventsPending,bg_tasks:t})}),sa(e=>{(e===`default`||e===`acceptEdits`||e===`bypassPermissions`||e===`plan`||e===`auto`||e===`dontAsk`)&&T.enqueue({type:`system`,subtype:`status`,status:null,permissionMode:e,uuid:Y(),session_id:u()})});let E={abortController:null,inflightPromise:null,lastEmitted:null,pendingSuggestion:null,pendingLastEmittedEntry:null},me;v.enableAuthStatus&&(me=ue.getInstance().subscribe(e=>{T.enqueue({type:`auth_status`,isAuthenticating:e.isAuthenticating,output:e.output,error:e.error,uuid:Y(),session_id:u()})}));let ge=e=>{let t=Ca(e);t&&T.enqueue({type:`rate_limit_event`,rate_limit_info:t,uuid:Y(),session_id:u()})};fn.add(ge);let D=s,O=xr(s,X(),100),ye=Yi(100),xe=process.env.CLAUDE_CODE_RESUME_INTERRUPTED_TURN;ne&&ne.kind!==`none`&&xe&&(I(`[print.ts] Auto-resuming interrupted turn (kind: ${ne.kind})`),ts(D,ne.message),J({mode:`prompt`,value:ne.message.message.content,uuid:Y()}));let Se=ln().map(e=>{let t=e.value===null?`default`:e.value,n=t===`default`?oe():S(t),r=Wn(n),i=pr(n),a=he(e.value),o=_e(n);return{name:t,value:t,displayName:e.label,description:e.description,...r&&{supportsEffort:!0,supportedEffortLevels:Gr(n)?[...Ut]:Ut.filter(e=>e!==`max`)},...i&&{supportsAdaptiveThinking:!0},...a&&{supportsFastMode:!0},...o&&{supportsAutoMode:!0}}}),we=v.userSpecifiedModel;function Te(e,t){let n=$r(e,pe(t));D.push(...n);for(let e of n)typeof e.message.content==`string`&&e.message.content.includes(`<local-command-stdout>`)&&T.enqueue({type:`user`,content:e.message.content,message:e.message,session_id:u(),parent_tool_use_id:null,uuid:e.uuid,timestamp:e.timestamp,isReplay:!0})}let k=[],A=[],Ee=new Set;function De(t){for(let n of t){if(n.type!==`connected`||Ee.has(n.name)||n.config.type===`sdk`)continue;let t=n.name;try{n.client.setRequestHandler(l,async(n,r)=>{Ye(t,`Elicitation request received in print mode: ${P(n)}`);let i=n.params.mode===`url`?`url`:`form`;z(`tengu_mcp_elicitation_shown`,{mode:i});let a=await ir(t,n.params,r.signal);if(a)return Ye(t,`Elicitation resolved by hook: ${P(a)}`),z(`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 Yr(t,await e.handleElicitation(t,n.params.message,s,r.signal,i,o,c),r.signal,i,c);return z(`tengu_mcp_elicitation_response`,{mode:i,action:l.action}),l}),n.client.setNotificationHandler(c,e=>{let{elicitationId:n}=e.params;Ye(t,`Elicitation completion notification: ${n}`),Pn({message:`MCP server "${t}" confirmed elicitation ${n} complete`,notificationType:`elicitation_complete`}),T.enqueue({type:`system`,subtype:`elicitation_complete`,mcp_server_name:t,elicitation_id:n,uuid:Y(),session_id:u()})}),Ee.add(t)}catch{}}}async function Oe(){let t=new Set(Object.keys(h)),n=new Set(k.map(e=>e.name)),r=Array.from(t).some(e=>!n.has(e)),i=Array.from(n).some(e=>!t.has(e)),a=k.some(e=>e.type===`pending`),o=k.some(e=>e.type===`failed`);if(r||i||a||o){for(let e of k)t.has(e.name)||e.type===`connected`&&await e.cleanup();let r=await en(h,(t,n)=>e.sendMcpMessage(t,n));k=r.clients,A=r.tools;let i=nt([...n,...t]);_(e=>({...e,mcp:{...e.mcp,tools:[...e.mcp.tools.filter(e=>!i.some(t=>e.name.startsWith(j(t)))),...A]}})),ri(k)}}Oe();let M={clients:[],tools:[],configs:{}},Ae=e=>{let t=kn(e.toolPermissionContext,e.mcp.tools),n=be($a([...o,...A,...M.tools],t,e.toolPermissionContext.mode),`name`);v.permissionPromptToolName&&(n=n.filter(e=>!Li(e,v.permissionPromptToolName)));let r=p();if(r&&!v.jsonSchema){let e=Ui(r);`tool`in e&&(n=[...n,e.tool])}return n},N=null,je=0;function Me(){if(!N)return;let e=Math.min(je,D.length),t=D.slice(e).filter(e=>e.type===`user`||e.type===`assistant`);je=D.length,t.length>0&&N.writeMessages(t)}let Pe=Promise.resolve({response:{added:[],removed:[],errors:{}},sdkServersChanged:!1});function Fe(e){let t=async()=>{let t=new Set(k.map(e=>e.name)),n=await os(e,{configs:h,clients:k,tools:A},M,_);for(let e of Object.keys(h))delete h[e];if(Object.assign(h,n.newSdkState.configs),k=n.newSdkState.clients,A=n.newSdkState.tools,M=n.newDynamicState,n.sdkServersChanged){let e=new Set(k.map(e=>e.name)),n=nt([...t,...e]);_(e=>({...e,mcp:{...e.mcp,tools:[...e.mcp.tools.filter(e=>!n.some(t=>e.name.startsWith(j(t)))),...A]}}))}return{response:n.response,sdkServersChanged:n.sdkServersChanged}};return Pe=Pe.then(t,t),Pe}function Le(){let e=g(),t=e.mcp.clients,n=be([...e.mcp.tools,...M.tools],`name`),r=new Set([...t.map(e=>e.name),...k.map(e=>e.name)]);return[...t,...k,...M.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`?ut(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,i;if(e.type===`connected`&&e.capabilities.experimental){let t={...e.capabilities.experimental};t[`claude/channel`]&&(!Fa()||!Pa(e.config.pluginSource))&&delete t[`claude/channel`],Object.keys(t).length>0&&(i={experimental:t})}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,capabilities:i}})}async function Re(){try{await Promise.all([Promise.resolve(),Ke(`headless_managed_settings_wait`,()=>Rt())]),await No()&&await He()}catch(e){W(e)}}let ze=null;t()||(i(process.env.CLAUDE_CODE_SYNC_PLUGIN_INSTALL)?ze=Re():Re());let Be=Eo(()=>!y),L=a,R=te;async function Ve(){let{agentDefinitions:e}=await uo(_);L=await Ft(X());let t=R.filter(e=>e.source===`flagSettings`);R=[...e.allAgents,...t]}async function He(){let{servers:e}=await gi(),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(h))n.type===`sdk`&&!(e in t)&&(t[e]=n);let{response:n,sdkServersChanged:r}=await Fe(t);r&&Oe(),I(`Headless MCP refresh: added=${n.added.length}, removed=${n.removed.length}`)}let Ue=lo.subscribe(()=>{Fi(),Ft(X()).then(e=>{L=e})}),We=()=>{setTimeout(()=>{!$?.isProactiveActive()||$.isProactivePaused()||x||(async()=>{let e=await Wt({basePrompt:`<${qe}>${new Date().toLocaleTimeString()}</${qe}>`,currentDir:X(),shouldCreate:()=>!x});if(x){await It({commands:e});return}for(let t of e)J({...t,uuid:Y()});B()})().catch(e=>{W(e),I(`[Proactive] failed to create headless tick: ${e}`,{level:`error`})})},0)};Et(()=>{w&&ji(`now`).length>0&&w.abort(`interrupt`)});let B=async()=>{if(y)return;if(y=!0,b=void 0,ca(`running`),Be.stop(),K(`run_entry`),await Oe(),K(`after_updateSdkMcp`),ze){let e=parseInt(process.env.CLAUDE_CODE_SYNC_PLUGIN_INSTALL_TIMEOUT_MS||``,10);if(e>0){let t=ct(e).then(()=>`timeout`);await Promise.race([ze,t])===`timeout`&&(W(Error(`CLAUDE_CODE_SYNC_PLUGIN_INSTALL: plugin installation timed out after ${e}ms`)),z(`tengu_sync_plugin_install_timeout`,{timeout_ms:e}))}else await ze;ze=null,await Ve();let{setupPluginHookHotReload:t}=await import(`./loadPluginHooks-DBHkyJaj.js`);t()}let t=e=>e.agentId===void 0;try{let r,i=!1,a=async()=>{for(;r=or(t);){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(;Wo(r,Si(t));)i.push(or(t));let a=await En(i);if(i=a.attachmentCommands,i.length===0)continue;r=i[0],r.mode===`prompt`&&i.length>1&&(r={...r,value:Uo(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(v.replayUserMessages&&i.length>1)for(let e of i)e.uuid&&e.uuid!==r.uuid&&T.enqueue({type:`user`,content:e.value,message:{role:`user`,content:e.value},session_id:u(),parent_tool_use_id:null,uuid:e.uuid,isReplay:!0});let s=g(),c=[...s.mcp.clients,...k,...M.clients];De(c);for(let e of c)$o(e);let l=Ae(s);for(let e of o)vt(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`,d=e.match(/<usage>([\s\S]*?)<\/usage>/)?.[1]??``,f=d.match(/<total_tokens>(\d+)<\/total_tokens>/),p=d.match(/<tool_uses>(\d+)<\/tool_uses>/),m=d.match(/<duration_ms>(\d+)<\/duration_ms>/);a&&T.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:f&&p?{total_tokens:parseInt(f[1],10),tool_uses:parseInt(p[1],10),duration_ms:m?parseInt(m[1],10):0}:void 0,session_id:u(),uuid:Y()})}let d=r.value,f=a.claimedCommands;if(e instanceof bo&&r.mode===`prompt`&&z(`tengu_bridge_message_received`,{is_repl:!1}),E.abortController?.abort(),E.abortController=null,E.pendingSuggestion=null,E.pendingLastEmittedEntry=null,E.lastEmitted&&r.mode===`prompt`){let e=typeof d==`string`?d:d.find(e=>e.type===`text`)?.text;typeof e==`string`&&mn(E.lastEmitted.text,e,E.lastEmitted.emittedAt,E.lastEmitted.promptId,E.lastEmitted.generationRequestId),E.lastEmitted=null}w=sn(),K(`before_ask`),Kn();let h=r,ee=!1;try{if(await Ce(h.workload??v.workload,async()=>{for await(let t of to({commands:be([...L,...s.mcp.commands],`name`),prompt:d,promptUuid:h.uuid,isMeta:h.isMeta,cwd:X(),tools:l,verbose:v.verbose,mcpClients:c,thinkingConfig:v.thinkingConfig,maxTurns:v.maxTurns,maxBudgetUsd:v.maxBudgetUsd,taskBudget:v.taskBudget,canUseTool:m,userSpecifiedModel:we,fallbackModel:v.fallbackModel,jsonSchema:p()??v.jsonSchema,mutableMessages:D,getReadFileCache:()=>ye.size===0?O:Zi(O,ye),setReadFileCache:e=>{O=e;for(let[e,t]of ye.entries()){let n=O.get(e);(!n||t.timestamp>n.timestamp)&&O.set(e,t)}ye.clear()},customSystemPrompt:v.systemPrompt,appendSystemPrompt:v.appendSystemPrompt,getAppState:g,setAppState:_,abortController:w,replayUserMessages:v.replayUserMessages,includePartialMessages:v.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:R,orphanedPermission:h.orphanedPermission,setSDKStatus:e=>{T.enqueue({type:`system`,subtype:`status`,status:e,session_id:u(),uuid:Y()})}}))if(Me(),t.type===`result`){ee=!!t.is_error;for(let e of Qi())T.enqueue(e);xi(g()).some(e=>(e.type===`local_agent`||e.type===`local_workflow`)&&vn(e))?le=t:(le=null,T.enqueue(t))}else{for(let e of Qi())T.enqueue(e);T.enqueue(t)}}),ee)await Fn({commands:f,outcome:{type:`failed`,message:`ask() returned an error result`},currentDir:X(),priority:`later`,workload:h.workload??v.workload});else{let e=await Fn({commands:f,outcome:{type:`completed`},currentDir:X(),priority:`later`,workload:h.workload??v.workload});for(let t of e)J({...t,uuid:Y()})}}catch(e){throw await Fn({commands:f,outcome:{type:`failed`,error:e},currentDir:X(),priority:`later`,workload:h.workload??v.workload}),e}for(let e of o)vt(e,`completed`);if(Me(),N?.sendResult(),v.promptSuggestions&&!n(process.env.CLAUDE_CODE_ENABLE_PROMPT_SUGGESTION)){E.abortController?.abort();let e=new AbortController;E.abortController=e;let t=Sr();if(!t)ft(`sdk_no_params`,void 0,void 0,`sdk`);else{let n={promise:null};n.promise=(async()=>{try{let n=await ui(e,D,g,t,`sdk`);if(!n||e.signal.aborted)return;let r={type:`prompt_suggestion`,suggestion:n.suggestion,uuid:Y(),session_id:u()},i={text:n.suggestion,emittedAt:Date.now(),promptId:n.promptId,generationRequestId:n.generationRequestId};le?(E.pendingSuggestion=r,E.pendingLastEmittedEntry={text:i.text,promptId:i.promptId,generationRequestId:i.generationRequestId}):(E.lastEmitted=i,T.enqueue(r))}catch(e){if(e instanceof Error&&(e.name===`AbortError`||e.name===`APIUserAbortError`)){ft(`aborted`,void 0,void 0,`sdk`);return}W(Ne(e))}finally{E.inflightPromise===n.promise&&(E.inflightPromise=null)}})(),E.inflightPromise=n.promise}}gn(),oi(),Bt()}};do{for(let e of Qi())T.enqueue(e);b=`draining_commands`,await a(),i=!1;{let e=xi(g()).some(e=>vn(e)&&e.type!==`in_process_teammate`),n=Si(t)!==void 0;(e||n)&&(i=!0,n||(b=`waiting_for_agents`,await ct(100)))}}while(i);le&&(T.enqueue(le),le=null,E.pendingSuggestion&&(T.enqueue(E.pendingSuggestion),E.pendingLastEmittedEntry&&(E.lastEmitted={...E.pendingLastEmittedEntry,emittedAt:Date.now()},E.pendingLastEmittedEntry=null),E.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:u(),total_cost_usd:0,usage:ia,modelUsage:{},permission_denials:[],uuid:Y(),errors:[F(t),...Xe().map(e=>e.error)]})}catch{}E.abortController?.abort(),q(1);return}finally{if(b=`finally_flush`,await e.flushInternalEvents(),b=`finally_post_flush`,!tr()){ca(`idle`);for(let e of Qi())T.enqueue(e)}y=!1,Be.start()}if($?.isProactiveActive()&&!$.isProactivePaused()&&Si(t)===void 0&&!x){We();return}if(Si(t)!==void 0){B();return}{let e=g().teamContext;if(e&&it(e)){let e=`team-lead`;for(;;){let t=g();if(!(st(t)||t.teamContext&&Object.keys(t.teamContext.teammates).length>0)){I(`[print.ts] No more active teammates, stopping poll`);break}let n=await di(e,t.teamContext?.teamName);if(n.length>0){I(`[print.ts] Team-lead found ${n.length} unread messages`),await nr(e,t.teamContext?.teamName);let r=t.teamContext?.teamName;for(let e of n){let n=Hn(e.text);if(n&&r){let e=n.from;I(`[print.ts] Processing shutdown_approved from ${e}`);let i=t.teamContext?.teammates?Object.entries(t.teamContext.teammates).find(([,t])=>t.name===e)?.[0]:void 0;i&&(va(r,{agentId:i,name:e}),I(`[print.ts] Removed ${e} from team file`),await ga(r,i,e,`shutdown`),_(e=>{if(!e.teamContext?.teammates||!(i in e.teamContext.teammates))return e;let{[i]:t,...n}=e.teamContext.teammates;return{...e,teamContext:{...e.teamContext,teammates:n}}}))}}J({mode:`prompt`,value:n.map(e=>`<${Je} teammate_id="${e.from}"${e.color?` color="${e.color}"`:``}>\n${e.text}\n</${Je}>`).join(`
31
+ Tip: Simplify your schema or check if the output format matches the expected structure.`)}}if(gn(),xe())try{let{drainPendingExtraction:e}=await import(`./extractMemories-8uB606Y0.js`);await e()}catch{}q(S?.type===`result`&&S?.is_error?1:0)}function Ko(e,r,a,o,s,m,h,g,_,te,v,ne){let y=!1,b,x=!1,ae=!1,le=null,w,T=e.outbound;process.on(`SIGINT`,()=>{Ge(`info`,`shutdown_signal`,{signal:`SIGINT`}),w&&!w.signal.aborted&&w.abort(),Vn(0)}),Ie(async()=>{let t={};for(let e of xi(g()))vn(e)&&(t[e.type]=(t[e.type]??0)+1);Ge(`info`,`run_state_at_shutdown`,{run_active:y,run_phase:b,worker_status:ua(),internal_events_pending:e.internalEventsPending,bg_tasks:t})}),sa(e=>{(e===`default`||e===`acceptEdits`||e===`bypassPermissions`||e===`plan`||e===`auto`||e===`dontAsk`)&&T.enqueue({type:`system`,subtype:`status`,status:null,permissionMode:e,uuid:Y(),session_id:u()})});let E={abortController:null,inflightPromise:null,lastEmitted:null,pendingSuggestion:null,pendingLastEmittedEntry:null},me;v.enableAuthStatus&&(me=ue.getInstance().subscribe(e=>{T.enqueue({type:`auth_status`,isAuthenticating:e.isAuthenticating,output:e.output,error:e.error,uuid:Y(),session_id:u()})}));let ge=e=>{let t=Ca(e);t&&T.enqueue({type:`rate_limit_event`,rate_limit_info:t,uuid:Y(),session_id:u()})};fn.add(ge);let D=s,O=xr(s,X(),100),ye=Yi(100),xe=process.env.CLAUDE_CODE_RESUME_INTERRUPTED_TURN;ne&&ne.kind!==`none`&&xe&&(I(`[print.ts] Auto-resuming interrupted turn (kind: ${ne.kind})`),ts(D,ne.message),J({mode:`prompt`,value:ne.message.message.content,uuid:Y()}));let Se=ln().map(e=>{let t=e.value===null?`default`:e.value,n=t===`default`?oe():S(t),r=Wn(n),i=pr(n),a=he(e.value),o=_e(n);return{name:t,value:t,displayName:e.label,description:e.description,...r&&{supportsEffort:!0,supportedEffortLevels:Gr(n)?[...Ut]:Ut.filter(e=>e!==`max`)},...i&&{supportsAdaptiveThinking:!0},...a&&{supportsFastMode:!0},...o&&{supportsAutoMode:!0}}}),we=v.userSpecifiedModel;function Te(e,t){let n=$r(e,pe(t));D.push(...n);for(let e of n)typeof e.message.content==`string`&&e.message.content.includes(`<local-command-stdout>`)&&T.enqueue({type:`user`,content:e.message.content,message:e.message,session_id:u(),parent_tool_use_id:null,uuid:e.uuid,timestamp:e.timestamp,isReplay:!0})}let k=[],A=[],Ee=new Set;function De(t){for(let n of t){if(n.type!==`connected`||Ee.has(n.name)||n.config.type===`sdk`)continue;let t=n.name;try{n.client.setRequestHandler(l,async(n,r)=>{Ye(t,`Elicitation request received in print mode: ${P(n)}`);let i=n.params.mode===`url`?`url`:`form`;z(`tengu_mcp_elicitation_shown`,{mode:i});let a=await ir(t,n.params,r.signal);if(a)return Ye(t,`Elicitation resolved by hook: ${P(a)}`),z(`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 Yr(t,await e.handleElicitation(t,n.params.message,s,r.signal,i,o,c),r.signal,i,c);return z(`tengu_mcp_elicitation_response`,{mode:i,action:l.action}),l}),n.client.setNotificationHandler(c,e=>{let{elicitationId:n}=e.params;Ye(t,`Elicitation completion notification: ${n}`),Pn({message:`MCP server "${t}" confirmed elicitation ${n} complete`,notificationType:`elicitation_complete`}),T.enqueue({type:`system`,subtype:`elicitation_complete`,mcp_server_name:t,elicitation_id:n,uuid:Y(),session_id:u()})}),Ee.add(t)}catch{}}}async function Oe(){let t=new Set(Object.keys(h)),n=new Set(k.map(e=>e.name)),r=Array.from(t).some(e=>!n.has(e)),i=Array.from(n).some(e=>!t.has(e)),a=k.some(e=>e.type===`pending`),o=k.some(e=>e.type===`failed`);if(r||i||a||o){for(let e of k)t.has(e.name)||e.type===`connected`&&await e.cleanup();let r=await en(h,(t,n)=>e.sendMcpMessage(t,n));k=r.clients,A=r.tools;let i=nt([...n,...t]);_(e=>({...e,mcp:{...e.mcp,tools:[...e.mcp.tools.filter(e=>!i.some(t=>e.name.startsWith(j(t)))),...A]}})),ri(k)}}Oe();let M={clients:[],tools:[],configs:{}},Ae=e=>{let t=kn(e.toolPermissionContext,e.mcp.tools),n=be($a([...o,...A,...M.tools],t,e.toolPermissionContext.mode),`name`);v.permissionPromptToolName&&(n=n.filter(e=>!Li(e,v.permissionPromptToolName)));let r=p();if(r&&!v.jsonSchema){let e=Ui(r);`tool`in e&&(n=[...n,e.tool])}return n},N=null,je=0;function Me(){if(!N)return;let e=Math.min(je,D.length),t=D.slice(e).filter(e=>e.type===`user`||e.type===`assistant`);je=D.length,t.length>0&&N.writeMessages(t)}let Pe=Promise.resolve({response:{added:[],removed:[],errors:{}},sdkServersChanged:!1});function Fe(e){let t=async()=>{let t=new Set(k.map(e=>e.name)),n=await os(e,{configs:h,clients:k,tools:A},M,_);for(let e of Object.keys(h))delete h[e];if(Object.assign(h,n.newSdkState.configs),k=n.newSdkState.clients,A=n.newSdkState.tools,M=n.newDynamicState,n.sdkServersChanged){let e=new Set(k.map(e=>e.name)),n=nt([...t,...e]);_(e=>({...e,mcp:{...e.mcp,tools:[...e.mcp.tools.filter(e=>!n.some(t=>e.name.startsWith(j(t)))),...A]}}))}return{response:n.response,sdkServersChanged:n.sdkServersChanged}};return Pe=Pe.then(t,t),Pe}function Le(){let e=g(),t=e.mcp.clients,n=be([...e.mcp.tools,...M.tools],`name`),r=new Set([...t.map(e=>e.name),...k.map(e=>e.name)]);return[...t,...k,...M.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`?ut(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,i;if(e.type===`connected`&&e.capabilities.experimental){let t={...e.capabilities.experimental};t[`claude/channel`]&&(!Fa()||!Pa(e.config.pluginSource))&&delete t[`claude/channel`],Object.keys(t).length>0&&(i={experimental:t})}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,capabilities:i}})}async function Re(){try{await Promise.all([Promise.resolve(),Ke(`headless_managed_settings_wait`,()=>Rt())]),await No()&&await He()}catch(e){W(e)}}let ze=null;t()||(i(process.env.CLAUDE_CODE_SYNC_PLUGIN_INSTALL)?ze=Re():Re());let Be=Eo(()=>!y),L=a,R=te;async function Ve(){let{agentDefinitions:e}=await uo(_);L=await Ft(X());let t=R.filter(e=>e.source===`flagSettings`);R=[...e.allAgents,...t]}async function He(){let{servers:e}=await gi(),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(h))n.type===`sdk`&&!(e in t)&&(t[e]=n);let{response:n,sdkServersChanged:r}=await Fe(t);r&&Oe(),I(`Headless MCP refresh: added=${n.added.length}, removed=${n.removed.length}`)}let Ue=lo.subscribe(()=>{Fi(),Ft(X()).then(e=>{L=e})}),We=()=>{setTimeout(()=>{!$?.isProactiveActive()||$.isProactivePaused()||x||(async()=>{let e=await Wt({basePrompt:`<${qe}>${new Date().toLocaleTimeString()}</${qe}>`,currentDir:X(),shouldCreate:()=>!x});if(x){await It({commands:e});return}for(let t of e)J({...t,uuid:Y()});B()})().catch(e=>{W(e),I(`[Proactive] failed to create headless tick: ${e}`,{level:`error`})})},0)};Et(()=>{w&&ji(`now`).length>0&&w.abort(`interrupt`)});let B=async()=>{if(y)return;if(y=!0,b=void 0,ca(`running`),Be.stop(),K(`run_entry`),await Oe(),K(`after_updateSdkMcp`),ze){let e=parseInt(process.env.CLAUDE_CODE_SYNC_PLUGIN_INSTALL_TIMEOUT_MS||``,10);if(e>0){let t=ct(e).then(()=>`timeout`);await Promise.race([ze,t])===`timeout`&&(W(Error(`CLAUDE_CODE_SYNC_PLUGIN_INSTALL: plugin installation timed out after ${e}ms`)),z(`tengu_sync_plugin_install_timeout`,{timeout_ms:e}))}else await ze;ze=null,await Ve();let{setupPluginHookHotReload:t}=await import(`./loadPluginHooks-YHtjByxm.js`);t()}let t=e=>e.agentId===void 0;try{let r,i=!1,a=async()=>{for(;r=or(t);){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(;Wo(r,Si(t));)i.push(or(t));let a=await En(i);if(i=a.attachmentCommands,i.length===0)continue;r=i[0],r.mode===`prompt`&&i.length>1&&(r={...r,value:Uo(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(v.replayUserMessages&&i.length>1)for(let e of i)e.uuid&&e.uuid!==r.uuid&&T.enqueue({type:`user`,content:e.value,message:{role:`user`,content:e.value},session_id:u(),parent_tool_use_id:null,uuid:e.uuid,isReplay:!0});let s=g(),c=[...s.mcp.clients,...k,...M.clients];De(c);for(let e of c)$o(e);let l=Ae(s);for(let e of o)vt(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`,d=e.match(/<usage>([\s\S]*?)<\/usage>/)?.[1]??``,f=d.match(/<total_tokens>(\d+)<\/total_tokens>/),p=d.match(/<tool_uses>(\d+)<\/tool_uses>/),m=d.match(/<duration_ms>(\d+)<\/duration_ms>/);a&&T.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:f&&p?{total_tokens:parseInt(f[1],10),tool_uses:parseInt(p[1],10),duration_ms:m?parseInt(m[1],10):0}:void 0,session_id:u(),uuid:Y()})}let d=r.value,f=a.claimedCommands;if(e instanceof bo&&r.mode===`prompt`&&z(`tengu_bridge_message_received`,{is_repl:!1}),E.abortController?.abort(),E.abortController=null,E.pendingSuggestion=null,E.pendingLastEmittedEntry=null,E.lastEmitted&&r.mode===`prompt`){let e=typeof d==`string`?d:d.find(e=>e.type===`text`)?.text;typeof e==`string`&&mn(E.lastEmitted.text,e,E.lastEmitted.emittedAt,E.lastEmitted.promptId,E.lastEmitted.generationRequestId),E.lastEmitted=null}w=sn(),K(`before_ask`),Kn();let h=r,ee=!1;try{if(await Ce(h.workload??v.workload,async()=>{for await(let t of to({commands:be([...L,...s.mcp.commands],`name`),prompt:d,promptUuid:h.uuid,isMeta:h.isMeta,cwd:X(),tools:l,verbose:v.verbose,mcpClients:c,thinkingConfig:v.thinkingConfig,maxTurns:v.maxTurns,maxBudgetUsd:v.maxBudgetUsd,taskBudget:v.taskBudget,canUseTool:m,userSpecifiedModel:we,fallbackModel:v.fallbackModel,jsonSchema:p()??v.jsonSchema,mutableMessages:D,getReadFileCache:()=>ye.size===0?O:Zi(O,ye),setReadFileCache:e=>{O=e;for(let[e,t]of ye.entries()){let n=O.get(e);(!n||t.timestamp>n.timestamp)&&O.set(e,t)}ye.clear()},customSystemPrompt:v.systemPrompt,appendSystemPrompt:v.appendSystemPrompt,getAppState:g,setAppState:_,abortController:w,replayUserMessages:v.replayUserMessages,includePartialMessages:v.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:R,orphanedPermission:h.orphanedPermission,setSDKStatus:e=>{T.enqueue({type:`system`,subtype:`status`,status:e,session_id:u(),uuid:Y()})}}))if(Me(),t.type===`result`){ee=!!t.is_error;for(let e of Qi())T.enqueue(e);xi(g()).some(e=>(e.type===`local_agent`||e.type===`local_workflow`)&&vn(e))?le=t:(le=null,T.enqueue(t))}else{for(let e of Qi())T.enqueue(e);T.enqueue(t)}}),ee)await Fn({commands:f,outcome:{type:`failed`,message:`ask() returned an error result`},currentDir:X(),priority:`later`,workload:h.workload??v.workload});else{let e=await Fn({commands:f,outcome:{type:`completed`},currentDir:X(),priority:`later`,workload:h.workload??v.workload});for(let t of e)J({...t,uuid:Y()})}}catch(e){throw await Fn({commands:f,outcome:{type:`failed`,error:e},currentDir:X(),priority:`later`,workload:h.workload??v.workload}),e}for(let e of o)vt(e,`completed`);if(Me(),N?.sendResult(),v.promptSuggestions&&!n(process.env.CLAUDE_CODE_ENABLE_PROMPT_SUGGESTION)){E.abortController?.abort();let e=new AbortController;E.abortController=e;let t=Sr();if(!t)ft(`sdk_no_params`,void 0,void 0,`sdk`);else{let n={promise:null};n.promise=(async()=>{try{let n=await ui(e,D,g,t,`sdk`);if(!n||e.signal.aborted)return;let r={type:`prompt_suggestion`,suggestion:n.suggestion,uuid:Y(),session_id:u()},i={text:n.suggestion,emittedAt:Date.now(),promptId:n.promptId,generationRequestId:n.generationRequestId};le?(E.pendingSuggestion=r,E.pendingLastEmittedEntry={text:i.text,promptId:i.promptId,generationRequestId:i.generationRequestId}):(E.lastEmitted=i,T.enqueue(r))}catch(e){if(e instanceof Error&&(e.name===`AbortError`||e.name===`APIUserAbortError`)){ft(`aborted`,void 0,void 0,`sdk`);return}W(Ne(e))}finally{E.inflightPromise===n.promise&&(E.inflightPromise=null)}})(),E.inflightPromise=n.promise}}gn(),oi(),Bt()}};do{for(let e of Qi())T.enqueue(e);b=`draining_commands`,await a(),i=!1;{let e=xi(g()).some(e=>vn(e)&&e.type!==`in_process_teammate`),n=Si(t)!==void 0;(e||n)&&(i=!0,n||(b=`waiting_for_agents`,await ct(100)))}}while(i);le&&(T.enqueue(le),le=null,E.pendingSuggestion&&(T.enqueue(E.pendingSuggestion),E.pendingLastEmittedEntry&&(E.lastEmitted={...E.pendingLastEmittedEntry,emittedAt:Date.now()},E.pendingLastEmittedEntry=null),E.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:u(),total_cost_usd:0,usage:ia,modelUsage:{},permission_denials:[],uuid:Y(),errors:[F(t),...Xe().map(e=>e.error)]})}catch{}E.abortController?.abort(),q(1);return}finally{if(b=`finally_flush`,await e.flushInternalEvents(),b=`finally_post_flush`,!tr()){ca(`idle`);for(let e of Qi())T.enqueue(e)}y=!1,Be.start()}if($?.isProactiveActive()&&!$.isProactivePaused()&&Si(t)===void 0&&!x){We();return}if(Si(t)!==void 0){B();return}{let e=g().teamContext;if(e&&it(e)){let e=`team-lead`;for(;;){let t=g();if(!(st(t)||t.teamContext&&Object.keys(t.teamContext.teammates).length>0)){I(`[print.ts] No more active teammates, stopping poll`);break}let n=await di(e,t.teamContext?.teamName);if(n.length>0){I(`[print.ts] Team-lead found ${n.length} unread messages`),await nr(e,t.teamContext?.teamName);let r=t.teamContext?.teamName;for(let e of n){let n=Hn(e.text);if(n&&r){let e=n.from;I(`[print.ts] Processing shutdown_approved from ${e}`);let i=t.teamContext?.teammates?Object.entries(t.teamContext.teammates).find(([,t])=>t.name===e)?.[0]:void 0;i&&(va(r,{agentId:i,name:e}),I(`[print.ts] Removed ${e} from team file`),await ga(r,i,e,`shutdown`),_(e=>{if(!e.teamContext?.teammates||!(i in e.teamContext.teammates))return e;let{[i]:t,...n}=e.teamContext.teammates;return{...e,teamContext:{...e.teamContext,teammates:n}}}))}}J({mode:`prompt`,value:n.map(e=>`<${Je} teammate_id="${e.from}"${e.color?` color="${e.color}"`:``}>\n${e.text}\n</${Je}>`).join(`
32
32
 
33
33
  `),uuid:Y()}),B();return}if(x&&!ae){ae=!0,I(`[print.ts] Input closed with active teammates, injecting shutdown prompt`),J({mode:`prompt`,value:Lo,uuid:Y()}),B();return}await ct(500)}}}x&&(await(async()=>{let e=g();rt(e)&&await ot(_,e);let t=g(),n=t.teamContext;return n&&Object.keys(n.teammates).length>0||st(t)})()?(J({mode:`prompt`,value:Lo,uuid:Y()}),B()):(E.inflightPromise&&await Promise.race([E.inflightPromise,ct(5e3)]),E.abortController?.abort(),E.abortController=null,await rn(),Ue(),me?.(),fn.delete(ge),T.done()))},V=null;if(Io.isKairosCronEnabled()){let e=e=>{x||(async()=>{let t=await ei({basePrompt:e.basePrompt,trigger:`scheduled-task`,currentDir:X(),sourceId:e.sourceId,sourceLabel:e.sourceLabel,workload:ce,shouldCreate:()=>!x});if(t){if(x){await It({commands:[t]});return}await e.onSuccess(t)}})().catch(t=>{W(t),I(`[ScheduledTasks] failed to enqueue headless task${e.logSuffix}: ${t}`,{level:`error`})})},t=e=>{J({...e,uuid:Y()}),B()};V=Po.createCronScheduler({onFire:n=>{e({basePrompt:n,sourceId:n,sourceLabel:n,logSuffix:``,onSuccess:t})},onFireTask:n=>{if(n.agentId){e({basePrompt:n.prompt,sourceId:n.id,sourceLabel:n.prompt,logSuffix:` ${n.id}`,onSuccess:async e=>{await Br(e.autonomy.runId,`No teammate runtime available for scheduled task owner ${n.agentId} in headless mode.`,e.autonomy.rootDir)}});return}e({basePrompt:n.prompt,sourceId:n.id,sourceLabel:n.prompt,logSuffix:` ${n.id}`,onSuccess:t})},isLoading:()=>y||x,getJitterConfig:Fo?.getCronJitterConfig,isKilled:()=>!Io?.isKairosCronEnabled()}),V.start()}let H=function(e,t){T.enqueue({type:`control_response`,response:{subtype:`success`,request_id:e.request_id,response:t}})},U=function(e,t){T.enqueue({type:`control_response`,response:{subtype:`error`,request_id:e.request_id,error:t}})},Ze=new Set;e.setUnexpectedResponseCallback(async e=>{await is({message:e,setAppState:_,handledToolUseIds:Ze,onEnqueued:()=>{B()}})});let Qe=new Map,et=new Map,tt=new Set,at=new Map,G=null;return(async()=>{let t=!1;Ge(`info`,`cli_message_loop_started`);for await(let n of e.structuredInput){let i=`uuid`in n?n.uuid:void 0;if(i&&n.type!==`user`&&n.type!==`control_response`&&vt(i,`completed`),n.type===`control_request`){let i=n,o=i.request;if(i.request.subtype===`interrupt`)_(e=>({...e,attribution:{...e.attribution,escapeCount:e.attribution.escapeCount+1}})),w&&w.abort(),E.abortController?.abort(),E.abortController=null,E.lastEmitted=null,E.pendingSuggestion=null,H(i);else if(o.subtype===`end_session`){I(`[print.ts] end_session received, reason=${o.reason??`unspecified`}`),w&&w.abort(),E.abortController?.abort(),E.abortController=null,E.lastEmitted=null,E.pendingSuggestion=null,H(i);break}else if(i.request.subtype===`initialize`){if(i.request.sdkMcpServers&&i.request.sdkMcpServers.length>0)for(let e of i.request.sdkMcpServers)h[e]={type:`sdk`,name:e};await Yo(i.request,i.request_id,t,T,a,Se,e,!!v.enableAuthStatus,v,te,g),i.request.promptSuggestions&&_(e=>e.promptSuggestionEnabled?e:{...e,promptSuggestionEnabled:!0}),i.request.agentProgressSummaries&&ve(`tengu_slate_prism`,!0)&&ee(!0),t=!0,qn()&&B()}else if(i.request.subtype===`set_permission_mode`){let e=i.request;_(t=>({...t,toolPermissionContext:Zo(e,i.request_id,t.toolPermissionContext,T),isUltraplanMode:e.ultraplan??t.isUltraplanMode}))}else if(i.request.subtype===`set_model`){let e=i.request.model??`default`,t=e===`default`?oe():e;we=t,re(t),la({model:t}),Te(e,t),H(i)}else if(i.request.subtype===`set_max_thinking_tokens`)i.request.max_thinking_tokens===null?v.thinkingConfig=void 0:i.request.max_thinking_tokens===0?v.thinkingConfig={type:`disabled`}:v.thinkingConfig={type:`enabled`,budgetTokens:i.request.max_thinking_tokens},H(i);else if(i.request.subtype===`mcp_status`)H(i,{mcpServers:Le()});else if(i.request.subtype===`get_context_usage`)try{let e=g();H(i,{...await ao({messages:D,getAppState:g,options:{mainLoopModel:se(),tools:Ae(e),agentDefinitions:e.agentDefinitions,customSystemPrompt:v.systemPrompt,appendSystemPrompt:v.appendSystemPrompt}})})}catch(e){U(i,F(e))}else if(i.request.subtype===`mcp_message`){let e=i.request,t=k.find(t=>t.name===e.server_name);t&&t.type===`connected`&&t.client?.transport?.onmessage&&t.client.transport.onmessage(e.message),H(i)}else if(i.request.subtype===`rewind_files`){let e=g(),t=await Xo(i.request.user_message_id,e,_,i.request.dry_run??!1);t.canRewind||i.request.dry_run?H(i,t):U(i,t.error??`Unexpected error`)}else if(i.request.subtype===`cancel_async_message`){let e=i.request.message_uuid;H(i,{cancelled:Zr(t=>t.uuid===e).length>0})}else if(i.request.subtype===`seed_read_state`){try{let e=$e(i.request.path),t=Math.floor((await _o(e)).mtimeMs);if(t<=i.request.mtime){let n=await go(e,`utf-8`),r=(n.charCodeAt(0)===65279?n.slice(1):n).replaceAll(`\r
34
34
  `,`
35
- `);ye.set(e,{content:r,timestamp:t,offset:void 0,limit:void 0})}}catch{}H(i)}else if(i.request.subtype===`mcp_set_servers`){let{response:e,sdkServersChanged:t}=await Fe(i.request.servers);H(i,e),t&&Oe()}else if(i.request.subtype===`reload_plugins`)try{let e=await uo(_),t=R.filter(e=>e.source===`flagSettings`);R=[...e.agentDefinitions.allAgents,...t];let n=[],[r,a,o]=await Promise.allSettled([Ft(X()),He(),Rr()]);r.status===`fulfilled`?L=r.value:W(r.reason),a.status===`rejected`&&W(a.reason),o.status===`fulfilled`?n=o.value.enabled.map(e=>({name:e.name,path:e.path,source:e.source})):W(o.reason),H(i,{commands:L.filter(e=>e.userInvocable!==!1).map(e=>({name:jr(e),description:zt(e),argumentHint:e.argumentHint||``})),agents:R.map(e=>({name:e.agentType,description:e.whenToUse,model:e.model===`inherit`?void 0:e.model})),plugins:n,mcpServers:Le(),error_count:e.error_count})}catch(e){U(i,F(e))}else if(i.request.subtype===`mcp_reconnect`){let e=g(),{serverName:t}=i.request;Ee.delete(t);let n=ur(t)??r.find(e=>e.name===t)?.config??k.find(e=>e.name===t)?.config??M.clients.find(e=>e.name===t)?.config??e.mcp.clients.find(e=>e.name===t)?.config??null;if(!n)U(i,`Server not found: ${t}`);else{let e=await wr(t,n),r=j(t);_(n=>({...n,mcp:{...n.mcp,clients:n.mcp.clients.map(n=>n.name===t?e.client:n),tools:[...C(n.mcp.tools,e=>e.name?.startsWith(r)),...e.tools],commands:[...C(n.mcp.commands,e=>Tn(e,t)),...e.commands],resources:e.resources&&e.resources.length>0?{...n.mcp.resources,[t]:e.resources}:de(n.mcp.resources,t)}})),M={...M,clients:[...M.clients.filter(e=>e.name!==t),e.client],tools:[...M.tools.filter(e=>!e.name?.startsWith(r)),...e.tools]},e.client.type===`connected`?(De([e.client]),$o(e.client),H(i)):U(i,e.client.type===`failed`?e.client.error??`Connection failed`:`Server status: ${e.client.type}`)}}else if(i.request.subtype===`mcp_toggle`){let e=g(),{serverName:t,enabled:n}=i.request;Ee.delete(t);let a=ur(t)??r.find(e=>e.name===t)?.config??k.find(e=>e.name===t)?.config??M.clients.find(e=>e.name===t)?.config??e.mcp.clients.find(e=>e.name===t)?.config??null;if(!a)U(i,`Server not found: ${t}`);else if(n){Yn(t,!0);let e=await wr(t,a),n=j(t);_(r=>({...r,mcp:{...r.mcp,clients:r.mcp.clients.map(n=>n.name===t?e.client:n),tools:[...C(r.mcp.tools,e=>e.name?.startsWith(n)),...e.tools],commands:[...C(r.mcp.commands,e=>Tn(e,t)),...e.commands],resources:e.resources&&e.resources.length>0?{...r.mcp.resources,[t]:e.resources}:de(r.mcp.resources,t)}})),e.client.type===`connected`?(De([e.client]),$o(e.client),H(i)):U(i,e.client.type===`failed`?e.client.error??`Connection failed`:`Server status: ${e.client.type}`)}else{Yn(t,!1);let n=[...r,...k,...M.clients,...e.mcp.clients].find(e=>e.name===t);n&&n.type===`connected`&&await Sn(t,a);let o=j(t);_(e=>({...e,mcp:{...e.mcp,clients:e.mcp.clients.map(e=>e.name===t?{name:t,type:`disabled`,config:a}:e),tools:C(e.mcp.tools,e=>e.name?.startsWith(o)),commands:C(e.mcp.commands,e=>Tn(e,t)),resources:de(e.mcp.resources,t)}})),H(i)}}else if(o.subtype===`channel_enable`){let e=g();Qo(i.request_id,o.serverName,[...e.mcp.clients,...k,...M.clients],T)}else if(o.subtype===`mcp_authenticate`){let e=o.serverName,t=g(),n=ur(e)??r.find(t=>t.name===e)?.config??t.mcp.clients.find(t=>t.name===e)?.config??null;if(!n)U(i,`Server not found: ${e}`);else if(n.type!==`sse`&&n.type!==`http`)U(i,`Server type "${n.type}" does not support OAuth authentication`);else try{Qe.get(e)?.abort();let t=new AbortController;Qe.set(e,t);let r,a=new Promise(e=>{r=e}),o=on(e,n,e=>r(e),t.signal,{skipBrowserOpen:!0,onWaitingForCallback:t=>{et.set(e,t)}}),s=await Promise.race([a,o.then(()=>null)]);s?H(i,{authUrl:s,requiresUserAction:!0}):H(i,{requiresUserAction:!1}),at.set(e,o),o.then(async()=>{if(mr(e)||tt.has(e))return;let t=await wr(e,n),r=j(e);_(n=>({...n,mcp:{...n.mcp,clients:n.mcp.clients.map(n=>n.name===e?t.client:n),tools:[...C(n.mcp.tools,e=>e.name?.startsWith(r)),...t.tools],commands:[...C(n.mcp.commands,t=>Tn(t,e)),...t.commands],resources:t.resources&&t.resources.length>0?{...n.mcp.resources,[e]:t.resources}:de(n.mcp.resources,e)}})),M={...M,clients:[...M.clients.filter(t=>t.name!==e),t.client],tools:[...M.tools.filter(e=>!e.name?.startsWith(r)),...t.tools]}}).catch(t=>{I(`MCP OAuth failed for ${e}: ${t}`,{level:`error`})}).finally(()=>{Qe.get(e)===t&&(Qe.delete(e),et.delete(e),tt.delete(e),at.delete(e))})}catch(e){U(i,F(e))}}else if(o.subtype===`mcp_oauth_callback_url`){let e=o.serverName,t=o.callbackUrl,n=et.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)U(i,`Invalid callback URL: missing authorization code. Please paste the full redirect URL including the code parameter.`);else{tt.add(e),n(t);let r=at.get(e);if(r)try{await r,H(i)}catch(e){U(i,e instanceof Error?e.message:`OAuth authentication failed`)}else H(i)}}else U(i,`No active OAuth flow for server: ${e}`)}else if(o.subtype===`claude_authenticate`){let e=o.loginWithClaudeAi;G?.service.cleanup(),z(`tengu_oauth_flow_start`,{loginWithClaudeAi:e??!0});let t=new cn,n,r=new Promise(e=>{n=e}),a=t.startOAuthFlow(async(e,t)=>{n({manualUrl:e,automaticUrl:t})},{loginWithClaudeAi:e??!0,skipBrowserOpen:!0}).then(async t=>{await Ci(t),z(`tengu_oauth_success`,{loginWithClaudeAi:e??!0})}).finally(()=>{t.cleanup(),G?.service===t&&(G=null)});G={service:t,flow:a},a.catch(e=>I(`claude_authenticate flow ended: ${e}`,{level:`info`}));try{let{manualUrl:e,automaticUrl:t}=await Promise.race([r,a.then(()=>{throw Error(`OAuth flow completed without producing auth URLs`)})]);H(i,{manualUrl:e,automaticUrl:t})}catch(e){U(i,F(e))}}else if(o.subtype===`claude_oauth_callback`||o.subtype===`claude_oauth_wait_for_completion`)if(!G)U(i,`No active claude_authenticate flow`);else{o.subtype===`claude_oauth_callback`&&G.service.handleManualAuthCodeInput({authorizationCode:o.authorizationCode,state:o.state});let{flow:e}=G;e.then(()=>{let e=ie();H(i,{account:{email:e?.email,organization:e?.organization,subscriptionType:e?.subscription,tokenSource:e?.tokenSource,apiKeySource:e?.apiKeySource,apiProvider:fe()}})},e=>U(i,F(e)))}else if(o.subtype===`mcp_clear_auth`){let e=o.serverName,t=g(),n=ur(e)??r.find(t=>t.name===e)?.config??t.mcp.clients.find(t=>t.name===e)?.config??null;if(!n)U(i,`Server not found: ${e}`);else if(n.type!==`sse`&&n.type!==`http`)U(i,`Cannot clear auth for server type "${n.type}"`);else{await ht(e,n);let t=await wr(e,n),r=j(e);_(n=>({...n,mcp:{...n.mcp,clients:n.mcp.clients.map(n=>n.name===e?t.client:n),tools:[...C(n.mcp.tools,e=>e.name?.startsWith(r)),...t.tools],commands:[...C(n.mcp.commands,t=>Tn(t,e)),...t.commands],resources:t.resources&&t.resources.length>0?{...n.mcp.resources,[e]:t.resources}:de(n.mcp.resources,e)}})),H(i,{})}}else if(i.request.subtype===`apply_flag_settings`){let e=se(),t=d()??{},n=i.request.settings,r={...t,...n};for(let e of Object.keys(r))r[e]===null&&delete r[e];f(r),bn.notifyChange(`flagSettings`),`model`in n&&(n.model==null?re(void 0):re(String(n.model)));let a=se();if(a!==e){we=a;let e=n.model?String(n.model):`default`;la({model:a}),Te(e,a)}H(i)}else if(i.request.subtype===`get_settings`){let e=g(),t=se(),n=Wn(t)?Mr(t,e.effortValue):void 0;H(i,{...ke(),applied:{model:t,effort:typeof n==`string`?n:null}})}else if(i.request.subtype===`stop_task`){let{task_id:e}=i.request;try{await yr(e,{getAppState:g,setAppState:_}),H(i,{})}catch(e){U(i,F(e))}}else if(o.subtype===`generate_session_title`){let e=o.description,t=o.persist,n=(w&&!w.signal.aborted?w:sn()).signal;(async()=>{try{let r=await wa(e,n);if(r&&t)try{fr(u(),r)}catch(e){W(e)}H(i,{title:r})}catch(e){U(i,F(e))}})()}else if(o.subtype===`side_question`){let e=o.question;(async()=>{try{let t=Sr();H(i,{response:(await io({question:e,cacheSafeParams:t?{...t,toolUseContext:{...t.toolUseContext,abortController:sn()}}:await no({tools:Ae(g()),commands:L,mcpClients:[...g().mcp.clients,...k,...M.clients],messages:D,readFileState:O,getAppState:g,setAppState:_,customSystemPrompt:v.systemPrompt,appendSystemPrompt:v.appendSystemPrompt,thinkingConfig:v.thinkingConfig,agents:R})})).response})}catch(e){U(i,F(e))}})()}else if(i.request.subtype===`set_proactive`)i.request.enabled?$.isProactiveActive()||($.activateProactive(`command`),We()):$.deactivateProactive(),H(i);else if(o.subtype===`remote_control`)if(o.enabled)if(N)H(i,{session_url:Qn(N.bridgeSessionId,N.sessionIngressUrl),connect_url:$n(N.environmentId,N.sessionIngressUrl),environment_id:N.environmentId});else{let t;try{let{initReplBridge:n}=await import(`./initReplBridge-BWP41EGm.js`),r=await n({onInboundMessage(e){let t=qa(e);if(!t)return;let{content:n,uuid:r}=t;J({value:n,mode:`prompt`,uuid:r,skipSlashCommands:!0}),B()},onPermissionResponse(t){e.injectControlResponse(t)},onInterrupt(){w?.abort()},onSetModel(e){let t=e===`default`?oe():e;we=t,re(t)},onSetMaxThinkingTokens(e){e===null?v.thinkingConfig=void 0:e===0?v.thinkingConfig={type:`disabled`}:v.thinkingConfig={type:`enabled`,budgetTokens:e}},onStateChange(e,n){e===`failed`&&(t=n),I(`[bridge:sdk] State change: ${e}${n?` — ${n}`:``}`),T.enqueue({type:`system`,subtype:`bridge_state`,state:e,detail:n,uuid:Y(),session_id:u()})},initialMessages:D.length>0?D:void 0});r?(N=r,je=D.length,e.setOnControlRequestSent(e=>{r.sendControlRequest(e)}),e.setOnControlRequestResolved(e=>{r.sendControlCancelRequest(e)}),H(i,{session_url:Qn(r.bridgeSessionId,r.sessionIngressUrl),connect_url:$n(r.environmentId,r.sessionIngressUrl),environment_id:r.environmentId})):U(i,t??`Remote Control initialization failed`)}catch(e){U(i,F(e))}}else N&&(e.setOnControlRequestSent(void 0),e.setOnControlRequestResolved(void 0),await N.teardown(),N=null),H(i);else U(i,`Unsupported control request subtype: ${i.request.subtype}`);continue}else if(n.type===`control_response`){v.replayUserMessages&&T.enqueue(n);continue}else if(n.type===`keep_alive`)continue;else if(n.type===`update_environment_variables`)continue;else if(n.type===`assistant`||n.type===`system`){let e=xa([n]);D.push(...e),n.type===`assistant`&&v.replayUserMessages&&T.enqueue(n);continue}if(n.type!==`user`)continue;let o=n;if(t=!0,o.uuid){let e=u(),t=await br(e,o.uuid);if(t||zo.has(o.uuid)){I(`Skipping duplicate user message: ${o.uuid}`),v.replayUserMessages&&(I(`Sending acknowledgment for duplicate user message: ${o.uuid}`),T.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&&vt(o.uuid,`completed`);continue}Vo(o.uuid)}J({mode:`prompt`,value:await ba(o,o.message.content),uuid:o.uuid,priority:o.priority}),_(e=>({...e,attribution:pa(e.attribution,e=>{mt(e).catch(e=>{I(`Attribution: Failed to save snapshot: ${e}`)})})})),B()}x=!0,V?.stop(),y||(E.inflightPromise&&await Promise.race([E.inflightPromise,ct(5e3)]),E.abortController?.abort(),E.abortController=null,await rn(),Ue(),me?.(),fn.delete(ge),T.done())})(),T}function qo(e){let t=async(n,r,i,a,o,s)=>{let c=s??await Mt(n,r,i,a,o);if(c.behavior===`allow`||c.behavior===`deny`)return c;let{signal:l,cleanup:u}=St(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 Ja(Xa().parse(tt(h.content[0].text)),e,r,i)};return t}function Jo(e,t,n,r){if(e===`stdio`)return t.createCanUseTool(r);if(!e)return async(e,t,n,r,i,a)=>a??await Mt(e,t,n,r,i);let i=null;return async(t,r,a,o,s,c)=>{if(!i){let t=n(),r=t.find(t=>Li(t,e));if(!r){let n=`Error: MCP tool ${e} (passed via --permission-prompt-tool) not found. Available MCP tools: ${t.map(e=>e.name).join(`, `)||`none`}`;throw process.stderr.write(`${n}\n`),q(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`),q(1),Error(t)}i=qo(r)}return i(t,r,a,o,s,c)}}async function Yo(e,t,n,r,i,a,o,s,c,l,d){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=Jr(e.agents,`flagSettings`);l.push(...t)}if(c.agent){let e=y()===c.agent,t=l.find(e=>e.agentType===c.agent);if(t&&!e){if(ne(t.agentType),!c.systemPrompt&&!si(t)){let e=t.getSystemPrompt();e&&(c.systemPrompt=e)}!c.userSpecifiedModel&&t.model&&t.model!==`inherit`&&re(S(t.model)),t.initialPrompt&&o.prependUserMessage(t.initialPrompt)}else t?.initialPrompt&&o.prependUserMessage(t.initialPrompt)}let f=k()?.outputStyle||`default`,p=await Gn(Ue()),m=ie();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}});g(t)}e.jsonSchema&&h(e.jsonSchema);let ee={commands:i.filter(e=>e.userInvocable!==!1).map(e=>({name:jr(e),description:zt(e),argumentHint:e.argumentHint||``})),agents:l.map(e=>({name:e.agentType,description:e.whenToUse,model:e.model===`inherit`?void 0:e.model})),output_style:f,available_output_styles:Object.keys(p),models:a,account:{email:m?.email,organization:m?.organization,subscriptionType:m?.subscription,tokenSource:m?.tokenSource,apiKeySource:m?.apiKeySource,apiProvider:fe()},pid:process.pid};if(Ae()&&je()){let e=d();ee.fast_mode_state=De(c.userSpecifiedModel??null,e.fastMode)}if(r.enqueue({type:`control_response`,response:{subtype:`success`,request_id:t,response:ee}}),s){let e=ue.getInstance().getStatus();e&&r.enqueue({type:`auth_status`,isAuthenticating:e.isAuthenticating,output:e.output,error:e.error,uuid:Y(),session_id:u()})}}async function Xo(e,t,n,r){if(!fi())return{canRewind:!1,error:`File rewinding is not enabled.`,filesChanged:[]};if(!rr(t.fileHistory,e))return{canRewind:!1,error:`No file checkpoint found for this message.`,filesChanged:[]};if(r){let n=await Ur(t.fileHistory,e);return{canRewind:!0,filesChanged:n?.filesChanged??[],insertions:n?.insertions,deletions:n?.deletions}}try{await qr(e=>n(t=>({...t,fileHistory:e(t.fileHistory)})),e)}catch(e){return{canRewind:!1,error:`Failed to rewind: ${F(e)}`,filesChanged:[]}}return{canRewind:!0,filesChanged:[]}}function Zo(e,t,n,r){if(e.mode===`bypassPermissions`){if(an())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`&&!wt()){let e=yn();return r.enqueue({type:`control_response`,response:{subtype:`error`,request_id:t,error:e?`Cannot set permission mode to auto: ${Ei(e)}`:`Cannot set permission mode to auto`}}),n}return r.enqueue({type:`control_response`,response:{subtype:`success`,request_id:t,response:{mode:e.mode}}}),{...At(n.mode,e.mode,n),mode:e.mode}}function Qo(e,t,n,r){let i=t=>r.enqueue({type:`control_response`,response:{subtype:`error`,request_id:e,error:t}}),a=n.find(e=>e.name===t&&e.type===`connected`);if(!a||a.type!==`connected`)return i(`server ${t} is not connected`);let o=a.config.pluginSource,s=o?Ji(o):void 0;if(!s?.marketplace)return i(`server ${t} is not plugin-sourced; channel_enable requires a marketplace plugin`);let c={kind:`plugin`,name:s.name,marketplace:s.marketplace},l=b(),u=l.some(e=>e.kind===`plugin`&&e.name===c.name&&e.marketplace===c.marketplace);u||m([...l,c]);let d=za(t,a.capabilities,o);if(d.action===`skip`)return u||m(l),i(d.reason);let f=`${c.name}@${c.marketplace}`;Ye(t,`Channel notifications registered`),z(`tengu_mcp_channel_enable`,{plugin:f}),a.client.setNotificationHandler(Ra(),async e=>{let{content:n,meta:r}=e.params;Ye(t,`notifications/claude/channel: ${n.slice(0,80)}`),z(`tengu_mcp_channel_message`,{content_length:n.length,meta_key_count:Object.keys(r??{}).length,entry_kind:`plugin`,is_dev:!1,plugin:f}),J({mode:`prompt`,value:Ia(t,n,r),priority:`next`,isMeta:!0,origin:{kind:`channel`,server:t},skipSlashCommands:!0})}),r.enqueue({type:`control_response`,response:{subtype:`success`,request_id:e,response:void 0}})}function $o(e){if(e.type!==`connected`||za(e.name,e.capabilities,e.config.pluginSource).action!==`register`)return;let t=La(e.name,b()),n=t?.kind===`plugin`?`${t.name}@${t.marketplace}`:void 0;Ye(e.name,`Channel notifications re-registered after reconnect`),e.client.setNotificationHandler(Ra(),async r=>{let{content:i,meta:a}=r.params;Ye(e.name,`notifications/claude/channel: ${i.slice(0,80)}`),z(`tengu_mcp_channel_message`,{content_length:i.length,meta_key_count:Object.keys(a??{}).length,entry_kind:t?.kind,is_dev:t?.dev??!1,plugin:n}),J({mode:`prompt`,value:Ia(e.name,i,a),priority:`next`,isMeta:!0,origin:{kind:`channel`,server:e.name},skipSlashCommands:!0})})}function es(e,t){if(t===`stream-json`){let t={type:`result`,subtype:`error_during_execution`,duration_ms:0,duration_api_ms:0,is_error:!0,num_turns:0,stop_reason:null,session_id:u(),total_cost_usd:0,usage:ia,modelUsage:{},permission_denials:[],uuid:Y(),errors:[e]};process.stdout.write(P(t)+`
35
+ `);ye.set(e,{content:r,timestamp:t,offset:void 0,limit:void 0})}}catch{}H(i)}else if(i.request.subtype===`mcp_set_servers`){let{response:e,sdkServersChanged:t}=await Fe(i.request.servers);H(i,e),t&&Oe()}else if(i.request.subtype===`reload_plugins`)try{let e=await uo(_),t=R.filter(e=>e.source===`flagSettings`);R=[...e.agentDefinitions.allAgents,...t];let n=[],[r,a,o]=await Promise.allSettled([Ft(X()),He(),Rr()]);r.status===`fulfilled`?L=r.value:W(r.reason),a.status===`rejected`&&W(a.reason),o.status===`fulfilled`?n=o.value.enabled.map(e=>({name:e.name,path:e.path,source:e.source})):W(o.reason),H(i,{commands:L.filter(e=>e.userInvocable!==!1).map(e=>({name:jr(e),description:zt(e),argumentHint:e.argumentHint||``})),agents:R.map(e=>({name:e.agentType,description:e.whenToUse,model:e.model===`inherit`?void 0:e.model})),plugins:n,mcpServers:Le(),error_count:e.error_count})}catch(e){U(i,F(e))}else if(i.request.subtype===`mcp_reconnect`){let e=g(),{serverName:t}=i.request;Ee.delete(t);let n=ur(t)??r.find(e=>e.name===t)?.config??k.find(e=>e.name===t)?.config??M.clients.find(e=>e.name===t)?.config??e.mcp.clients.find(e=>e.name===t)?.config??null;if(!n)U(i,`Server not found: ${t}`);else{let e=await wr(t,n),r=j(t);_(n=>({...n,mcp:{...n.mcp,clients:n.mcp.clients.map(n=>n.name===t?e.client:n),tools:[...C(n.mcp.tools,e=>e.name?.startsWith(r)),...e.tools],commands:[...C(n.mcp.commands,e=>Tn(e,t)),...e.commands],resources:e.resources&&e.resources.length>0?{...n.mcp.resources,[t]:e.resources}:de(n.mcp.resources,t)}})),M={...M,clients:[...M.clients.filter(e=>e.name!==t),e.client],tools:[...M.tools.filter(e=>!e.name?.startsWith(r)),...e.tools]},e.client.type===`connected`?(De([e.client]),$o(e.client),H(i)):U(i,e.client.type===`failed`?e.client.error??`Connection failed`:`Server status: ${e.client.type}`)}}else if(i.request.subtype===`mcp_toggle`){let e=g(),{serverName:t,enabled:n}=i.request;Ee.delete(t);let a=ur(t)??r.find(e=>e.name===t)?.config??k.find(e=>e.name===t)?.config??M.clients.find(e=>e.name===t)?.config??e.mcp.clients.find(e=>e.name===t)?.config??null;if(!a)U(i,`Server not found: ${t}`);else if(n){Yn(t,!0);let e=await wr(t,a),n=j(t);_(r=>({...r,mcp:{...r.mcp,clients:r.mcp.clients.map(n=>n.name===t?e.client:n),tools:[...C(r.mcp.tools,e=>e.name?.startsWith(n)),...e.tools],commands:[...C(r.mcp.commands,e=>Tn(e,t)),...e.commands],resources:e.resources&&e.resources.length>0?{...r.mcp.resources,[t]:e.resources}:de(r.mcp.resources,t)}})),e.client.type===`connected`?(De([e.client]),$o(e.client),H(i)):U(i,e.client.type===`failed`?e.client.error??`Connection failed`:`Server status: ${e.client.type}`)}else{Yn(t,!1);let n=[...r,...k,...M.clients,...e.mcp.clients].find(e=>e.name===t);n&&n.type===`connected`&&await Sn(t,a);let o=j(t);_(e=>({...e,mcp:{...e.mcp,clients:e.mcp.clients.map(e=>e.name===t?{name:t,type:`disabled`,config:a}:e),tools:C(e.mcp.tools,e=>e.name?.startsWith(o)),commands:C(e.mcp.commands,e=>Tn(e,t)),resources:de(e.mcp.resources,t)}})),H(i)}}else if(o.subtype===`channel_enable`){let e=g();Qo(i.request_id,o.serverName,[...e.mcp.clients,...k,...M.clients],T)}else if(o.subtype===`mcp_authenticate`){let e=o.serverName,t=g(),n=ur(e)??r.find(t=>t.name===e)?.config??t.mcp.clients.find(t=>t.name===e)?.config??null;if(!n)U(i,`Server not found: ${e}`);else if(n.type!==`sse`&&n.type!==`http`)U(i,`Server type "${n.type}" does not support OAuth authentication`);else try{Qe.get(e)?.abort();let t=new AbortController;Qe.set(e,t);let r,a=new Promise(e=>{r=e}),o=on(e,n,e=>r(e),t.signal,{skipBrowserOpen:!0,onWaitingForCallback:t=>{et.set(e,t)}}),s=await Promise.race([a,o.then(()=>null)]);s?H(i,{authUrl:s,requiresUserAction:!0}):H(i,{requiresUserAction:!1}),at.set(e,o),o.then(async()=>{if(mr(e)||tt.has(e))return;let t=await wr(e,n),r=j(e);_(n=>({...n,mcp:{...n.mcp,clients:n.mcp.clients.map(n=>n.name===e?t.client:n),tools:[...C(n.mcp.tools,e=>e.name?.startsWith(r)),...t.tools],commands:[...C(n.mcp.commands,t=>Tn(t,e)),...t.commands],resources:t.resources&&t.resources.length>0?{...n.mcp.resources,[e]:t.resources}:de(n.mcp.resources,e)}})),M={...M,clients:[...M.clients.filter(t=>t.name!==e),t.client],tools:[...M.tools.filter(e=>!e.name?.startsWith(r)),...t.tools]}}).catch(t=>{I(`MCP OAuth failed for ${e}: ${t}`,{level:`error`})}).finally(()=>{Qe.get(e)===t&&(Qe.delete(e),et.delete(e),tt.delete(e),at.delete(e))})}catch(e){U(i,F(e))}}else if(o.subtype===`mcp_oauth_callback_url`){let e=o.serverName,t=o.callbackUrl,n=et.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)U(i,`Invalid callback URL: missing authorization code. Please paste the full redirect URL including the code parameter.`);else{tt.add(e),n(t);let r=at.get(e);if(r)try{await r,H(i)}catch(e){U(i,e instanceof Error?e.message:`OAuth authentication failed`)}else H(i)}}else U(i,`No active OAuth flow for server: ${e}`)}else if(o.subtype===`claude_authenticate`){let e=o.loginWithClaudeAi;G?.service.cleanup(),z(`tengu_oauth_flow_start`,{loginWithClaudeAi:e??!0});let t=new cn,n,r=new Promise(e=>{n=e}),a=t.startOAuthFlow(async(e,t)=>{n({manualUrl:e,automaticUrl:t})},{loginWithClaudeAi:e??!0,skipBrowserOpen:!0}).then(async t=>{await Ci(t),z(`tengu_oauth_success`,{loginWithClaudeAi:e??!0})}).finally(()=>{t.cleanup(),G?.service===t&&(G=null)});G={service:t,flow:a},a.catch(e=>I(`claude_authenticate flow ended: ${e}`,{level:`info`}));try{let{manualUrl:e,automaticUrl:t}=await Promise.race([r,a.then(()=>{throw Error(`OAuth flow completed without producing auth URLs`)})]);H(i,{manualUrl:e,automaticUrl:t})}catch(e){U(i,F(e))}}else if(o.subtype===`claude_oauth_callback`||o.subtype===`claude_oauth_wait_for_completion`)if(!G)U(i,`No active claude_authenticate flow`);else{o.subtype===`claude_oauth_callback`&&G.service.handleManualAuthCodeInput({authorizationCode:o.authorizationCode,state:o.state});let{flow:e}=G;e.then(()=>{let e=ie();H(i,{account:{email:e?.email,organization:e?.organization,subscriptionType:e?.subscription,tokenSource:e?.tokenSource,apiKeySource:e?.apiKeySource,apiProvider:fe()}})},e=>U(i,F(e)))}else if(o.subtype===`mcp_clear_auth`){let e=o.serverName,t=g(),n=ur(e)??r.find(t=>t.name===e)?.config??t.mcp.clients.find(t=>t.name===e)?.config??null;if(!n)U(i,`Server not found: ${e}`);else if(n.type!==`sse`&&n.type!==`http`)U(i,`Cannot clear auth for server type "${n.type}"`);else{await ht(e,n);let t=await wr(e,n),r=j(e);_(n=>({...n,mcp:{...n.mcp,clients:n.mcp.clients.map(n=>n.name===e?t.client:n),tools:[...C(n.mcp.tools,e=>e.name?.startsWith(r)),...t.tools],commands:[...C(n.mcp.commands,t=>Tn(t,e)),...t.commands],resources:t.resources&&t.resources.length>0?{...n.mcp.resources,[e]:t.resources}:de(n.mcp.resources,e)}})),H(i,{})}}else if(i.request.subtype===`apply_flag_settings`){let e=se(),t=d()??{},n=i.request.settings,r={...t,...n};for(let e of Object.keys(r))r[e]===null&&delete r[e];f(r),bn.notifyChange(`flagSettings`),`model`in n&&(n.model==null?re(void 0):re(String(n.model)));let a=se();if(a!==e){we=a;let e=n.model?String(n.model):`default`;la({model:a}),Te(e,a)}H(i)}else if(i.request.subtype===`get_settings`){let e=g(),t=se(),n=Wn(t)?Mr(t,e.effortValue):void 0;H(i,{...ke(),applied:{model:t,effort:typeof n==`string`?n:null}})}else if(i.request.subtype===`stop_task`){let{task_id:e}=i.request;try{await yr(e,{getAppState:g,setAppState:_}),H(i,{})}catch(e){U(i,F(e))}}else if(o.subtype===`generate_session_title`){let e=o.description,t=o.persist,n=(w&&!w.signal.aborted?w:sn()).signal;(async()=>{try{let r=await wa(e,n);if(r&&t)try{fr(u(),r)}catch(e){W(e)}H(i,{title:r})}catch(e){U(i,F(e))}})()}else if(o.subtype===`side_question`){let e=o.question;(async()=>{try{let t=Sr();H(i,{response:(await io({question:e,cacheSafeParams:t?{...t,toolUseContext:{...t.toolUseContext,abortController:sn()}}:await no({tools:Ae(g()),commands:L,mcpClients:[...g().mcp.clients,...k,...M.clients],messages:D,readFileState:O,getAppState:g,setAppState:_,customSystemPrompt:v.systemPrompt,appendSystemPrompt:v.appendSystemPrompt,thinkingConfig:v.thinkingConfig,agents:R})})).response})}catch(e){U(i,F(e))}})()}else if(i.request.subtype===`set_proactive`)i.request.enabled?$.isProactiveActive()||($.activateProactive(`command`),We()):$.deactivateProactive(),H(i);else if(o.subtype===`remote_control`)if(o.enabled)if(N)H(i,{session_url:Qn(N.bridgeSessionId,N.sessionIngressUrl),connect_url:$n(N.environmentId,N.sessionIngressUrl),environment_id:N.environmentId});else{let t;try{let{initReplBridge:n}=await import(`./initReplBridge-DWpGy3aE.js`),r=await n({onInboundMessage(e){let t=qa(e);if(!t)return;let{content:n,uuid:r}=t;J({value:n,mode:`prompt`,uuid:r,skipSlashCommands:!0}),B()},onPermissionResponse(t){e.injectControlResponse(t)},onInterrupt(){w?.abort()},onSetModel(e){let t=e===`default`?oe():e;we=t,re(t)},onSetMaxThinkingTokens(e){e===null?v.thinkingConfig=void 0:e===0?v.thinkingConfig={type:`disabled`}:v.thinkingConfig={type:`enabled`,budgetTokens:e}},onStateChange(e,n){e===`failed`&&(t=n),I(`[bridge:sdk] State change: ${e}${n?` — ${n}`:``}`),T.enqueue({type:`system`,subtype:`bridge_state`,state:e,detail:n,uuid:Y(),session_id:u()})},initialMessages:D.length>0?D:void 0});r?(N=r,je=D.length,e.setOnControlRequestSent(e=>{r.sendControlRequest(e)}),e.setOnControlRequestResolved(e=>{r.sendControlCancelRequest(e)}),H(i,{session_url:Qn(r.bridgeSessionId,r.sessionIngressUrl),connect_url:$n(r.environmentId,r.sessionIngressUrl),environment_id:r.environmentId})):U(i,t??`Remote Control initialization failed`)}catch(e){U(i,F(e))}}else N&&(e.setOnControlRequestSent(void 0),e.setOnControlRequestResolved(void 0),await N.teardown(),N=null),H(i);else U(i,`Unsupported control request subtype: ${i.request.subtype}`);continue}else if(n.type===`control_response`){v.replayUserMessages&&T.enqueue(n);continue}else if(n.type===`keep_alive`)continue;else if(n.type===`update_environment_variables`)continue;else if(n.type===`assistant`||n.type===`system`){let e=xa([n]);D.push(...e),n.type===`assistant`&&v.replayUserMessages&&T.enqueue(n);continue}if(n.type!==`user`)continue;let o=n;if(t=!0,o.uuid){let e=u(),t=await br(e,o.uuid);if(t||zo.has(o.uuid)){I(`Skipping duplicate user message: ${o.uuid}`),v.replayUserMessages&&(I(`Sending acknowledgment for duplicate user message: ${o.uuid}`),T.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&&vt(o.uuid,`completed`);continue}Vo(o.uuid)}J({mode:`prompt`,value:await ba(o,o.message.content),uuid:o.uuid,priority:o.priority}),_(e=>({...e,attribution:pa(e.attribution,e=>{mt(e).catch(e=>{I(`Attribution: Failed to save snapshot: ${e}`)})})})),B()}x=!0,V?.stop(),y||(E.inflightPromise&&await Promise.race([E.inflightPromise,ct(5e3)]),E.abortController?.abort(),E.abortController=null,await rn(),Ue(),me?.(),fn.delete(ge),T.done())})(),T}function qo(e){let t=async(n,r,i,a,o,s)=>{let c=s??await Mt(n,r,i,a,o);if(c.behavior===`allow`||c.behavior===`deny`)return c;let{signal:l,cleanup:u}=St(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 Ja(Xa().parse(tt(h.content[0].text)),e,r,i)};return t}function Jo(e,t,n,r){if(e===`stdio`)return t.createCanUseTool(r);if(!e)return async(e,t,n,r,i,a)=>a??await Mt(e,t,n,r,i);let i=null;return async(t,r,a,o,s,c)=>{if(!i){let t=n(),r=t.find(t=>Li(t,e));if(!r){let n=`Error: MCP tool ${e} (passed via --permission-prompt-tool) not found. Available MCP tools: ${t.map(e=>e.name).join(`, `)||`none`}`;throw process.stderr.write(`${n}\n`),q(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`),q(1),Error(t)}i=qo(r)}return i(t,r,a,o,s,c)}}async function Yo(e,t,n,r,i,a,o,s,c,l,d){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=Jr(e.agents,`flagSettings`);l.push(...t)}if(c.agent){let e=y()===c.agent,t=l.find(e=>e.agentType===c.agent);if(t&&!e){if(ne(t.agentType),!c.systemPrompt&&!si(t)){let e=t.getSystemPrompt();e&&(c.systemPrompt=e)}!c.userSpecifiedModel&&t.model&&t.model!==`inherit`&&re(S(t.model)),t.initialPrompt&&o.prependUserMessage(t.initialPrompt)}else t?.initialPrompt&&o.prependUserMessage(t.initialPrompt)}let f=k()?.outputStyle||`default`,p=await Gn(Ue()),m=ie();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}});g(t)}e.jsonSchema&&h(e.jsonSchema);let ee={commands:i.filter(e=>e.userInvocable!==!1).map(e=>({name:jr(e),description:zt(e),argumentHint:e.argumentHint||``})),agents:l.map(e=>({name:e.agentType,description:e.whenToUse,model:e.model===`inherit`?void 0:e.model})),output_style:f,available_output_styles:Object.keys(p),models:a,account:{email:m?.email,organization:m?.organization,subscriptionType:m?.subscription,tokenSource:m?.tokenSource,apiKeySource:m?.apiKeySource,apiProvider:fe()},pid:process.pid};if(Ae()&&je()){let e=d();ee.fast_mode_state=De(c.userSpecifiedModel??null,e.fastMode)}if(r.enqueue({type:`control_response`,response:{subtype:`success`,request_id:t,response:ee}}),s){let e=ue.getInstance().getStatus();e&&r.enqueue({type:`auth_status`,isAuthenticating:e.isAuthenticating,output:e.output,error:e.error,uuid:Y(),session_id:u()})}}async function Xo(e,t,n,r){if(!fi())return{canRewind:!1,error:`File rewinding is not enabled.`,filesChanged:[]};if(!rr(t.fileHistory,e))return{canRewind:!1,error:`No file checkpoint found for this message.`,filesChanged:[]};if(r){let n=await Ur(t.fileHistory,e);return{canRewind:!0,filesChanged:n?.filesChanged??[],insertions:n?.insertions,deletions:n?.deletions}}try{await qr(e=>n(t=>({...t,fileHistory:e(t.fileHistory)})),e)}catch(e){return{canRewind:!1,error:`Failed to rewind: ${F(e)}`,filesChanged:[]}}return{canRewind:!0,filesChanged:[]}}function Zo(e,t,n,r){if(e.mode===`bypassPermissions`){if(an())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`&&!wt()){let e=yn();return r.enqueue({type:`control_response`,response:{subtype:`error`,request_id:t,error:e?`Cannot set permission mode to auto: ${Ei(e)}`:`Cannot set permission mode to auto`}}),n}return r.enqueue({type:`control_response`,response:{subtype:`success`,request_id:t,response:{mode:e.mode}}}),{...At(n.mode,e.mode,n),mode:e.mode}}function Qo(e,t,n,r){let i=t=>r.enqueue({type:`control_response`,response:{subtype:`error`,request_id:e,error:t}}),a=n.find(e=>e.name===t&&e.type===`connected`);if(!a||a.type!==`connected`)return i(`server ${t} is not connected`);let o=a.config.pluginSource,s=o?Ji(o):void 0;if(!s?.marketplace)return i(`server ${t} is not plugin-sourced; channel_enable requires a marketplace plugin`);let c={kind:`plugin`,name:s.name,marketplace:s.marketplace},l=b(),u=l.some(e=>e.kind===`plugin`&&e.name===c.name&&e.marketplace===c.marketplace);u||m([...l,c]);let d=za(t,a.capabilities,o);if(d.action===`skip`)return u||m(l),i(d.reason);let f=`${c.name}@${c.marketplace}`;Ye(t,`Channel notifications registered`),z(`tengu_mcp_channel_enable`,{plugin:f}),a.client.setNotificationHandler(Ra(),async e=>{let{content:n,meta:r}=e.params;Ye(t,`notifications/claude/channel: ${n.slice(0,80)}`),z(`tengu_mcp_channel_message`,{content_length:n.length,meta_key_count:Object.keys(r??{}).length,entry_kind:`plugin`,is_dev:!1,plugin:f}),J({mode:`prompt`,value:Ia(t,n,r),priority:`next`,isMeta:!0,origin:{kind:`channel`,server:t},skipSlashCommands:!0})}),r.enqueue({type:`control_response`,response:{subtype:`success`,request_id:e,response:void 0}})}function $o(e){if(e.type!==`connected`||za(e.name,e.capabilities,e.config.pluginSource).action!==`register`)return;let t=La(e.name,b()),n=t?.kind===`plugin`?`${t.name}@${t.marketplace}`:void 0;Ye(e.name,`Channel notifications re-registered after reconnect`),e.client.setNotificationHandler(Ra(),async r=>{let{content:i,meta:a}=r.params;Ye(e.name,`notifications/claude/channel: ${i.slice(0,80)}`),z(`tengu_mcp_channel_message`,{content_length:i.length,meta_key_count:Object.keys(a??{}).length,entry_kind:t?.kind,is_dev:t?.dev??!1,plugin:n}),J({mode:`prompt`,value:Ia(e.name,i,a),priority:`next`,isMeta:!0,origin:{kind:`channel`,server:e.name},skipSlashCommands:!0})})}function es(e,t){if(t===`stream-json`){let t={type:`result`,subtype:`error_during_execution`,duration_ms:0,duration_api_ms:0,is_error:!0,num_turns:0,stop_reason:null,session_id:u(),total_cost_usd:0,usage:ia,modelUsage:{},permission_denials:[],uuid:Y(),errors:[e]};process.stdout.write(P(t)+`
36
36
  `)}else process.stderr.write(e+`
37
37
  `)}function ts(e,t){let n=e.findIndex(e=>e.uuid===t.uuid);n!==-1&&e.splice(n,2)}async function ns(t,n){let r=!v();if(n.continue)try{z(`tengu_continue_print`,{});let i=await wn(void 0,void 0);if(i){if(Q){let n=Q.matchSessionMode(i.mode);if(n){process.stderr.write(n+`
38
- `);let{getAgentDefinitionsWithOverrides:r,getActiveAgentsFromList:i}=(Wr(),e(pi));r.cache.clear?.();let a=await r(Ue());t(e=>({...e,agentDefinitions:{...a,allAgents:a.allAgents,activeAgents:i(a.allAgents)}}))}}return n.forkSession||i.sessionId&&(te(Di(i.sessionId),i.fullPath?po(i.fullPath):null),r&&await er()),co(i,t),cr(n.forkSession?{...i,worktreeSession:void 0}:i),Q&&yi(Q.isCoordinatorMode()?`coordinator`:`normal`),{messages:i.messages,turnInterruptionState:i.turnInterruptionState,agentSetting:i.agentSetting}}}catch(e){return W(e),q(1),{messages:[]}}if(n.teleport)try{if(!bt(`allow_remote_sessions`))throw Error(`Remote sessions are disabled by your organization's policy.`);if(z(`tengu_teleport_print`,{}),typeof n.teleport!=`string`)throw Error(`No session ID provided for teleport`);let{checkOutTeleportedSessionBranch:e,processMessagesForTeleportResume:t,teleportResumeCodeSession:r,validateGitState:i}=await import(`./teleport-NN6zSxxe.js`);await i();let a=await r(n.teleport),{branchError:o}=await e(a.branch);return{messages:t(a.log,o)}}catch(e){return W(e),q(1),{messages:[]}}if(n.resume)try{z(`tengu_resume_print`,{});let a=Do(typeof n.resume==`string`?n.resume:``);if(!a){let e=`Error: --resume requires a valid session ID when used with --print. Usage: claude -p --resume <session-id>`;return typeof n.resume==`string`&&(e+=`. Session IDs must be in UUID format (e.g., 550e8400-e29b-41d4-a716-446655440000). Provided value "${n.resume}" is not a valid UUID`),es(e,n.outputFormat),q(1),{messages:[]}}if(i(process.env.CLAUDE_CODE_USE_CCR_V2)){let[,e]=await Promise.all([un(a.sessionId),n.restoredWorkerState]);e&&(t(Va(e)),typeof e.model==`string`&&re(e.model))}else a.isUrl&&a.ingressUrl&&i(process.env.ENABLE_SESSION_PERSISTENCE)&&await Or(a.sessionId,a.ingressUrl);let o=await wn(a.sessionId,a.jsonlFile||void 0);if(!o||o.messages.length===0)return a.isUrl||i(process.env.CLAUDE_CODE_USE_CCR_V2)?{messages:await(n.sessionStartHooksPromise??kr(`startup`))}:(es(`No conversation found with session ID: ${a.sessionId}`,n.outputFormat),q(1),{messages:[]});if(n.resumeSessionAt){let e=o.messages.findIndex(e=>e.uuid===n.resumeSessionAt);if(e<0)return es(`No message found with message.uuid of: ${n.resumeSessionAt}`,n.outputFormat),q(1),{messages:[]};o.messages=e>=0?o.messages.slice(0,e+1):[]}if(Q){let n=Q.matchSessionMode(o.mode);if(n){process.stderr.write(n+`
38
+ `);let{getAgentDefinitionsWithOverrides:r,getActiveAgentsFromList:i}=(Wr(),e(pi));r.cache.clear?.();let a=await r(Ue());t(e=>({...e,agentDefinitions:{...a,allAgents:a.allAgents,activeAgents:i(a.allAgents)}}))}}return n.forkSession||i.sessionId&&(te(Di(i.sessionId),i.fullPath?po(i.fullPath):null),r&&await er()),co(i,t),cr(n.forkSession?{...i,worktreeSession:void 0}:i),Q&&yi(Q.isCoordinatorMode()?`coordinator`:`normal`),{messages:i.messages,turnInterruptionState:i.turnInterruptionState,agentSetting:i.agentSetting}}}catch(e){return W(e),q(1),{messages:[]}}if(n.teleport)try{if(!bt(`allow_remote_sessions`))throw Error(`Remote sessions are disabled by your organization's policy.`);if(z(`tengu_teleport_print`,{}),typeof n.teleport!=`string`)throw Error(`No session ID provided for teleport`);let{checkOutTeleportedSessionBranch:e,processMessagesForTeleportResume:t,teleportResumeCodeSession:r,validateGitState:i}=await import(`./teleport-DkoFG3EI.js`);await i();let a=await r(n.teleport),{branchError:o}=await e(a.branch);return{messages:t(a.log,o)}}catch(e){return W(e),q(1),{messages:[]}}if(n.resume)try{z(`tengu_resume_print`,{});let a=Do(typeof n.resume==`string`?n.resume:``);if(!a){let e=`Error: --resume requires a valid session ID when used with --print. Usage: claude -p --resume <session-id>`;return typeof n.resume==`string`&&(e+=`. Session IDs must be in UUID format (e.g., 550e8400-e29b-41d4-a716-446655440000). Provided value "${n.resume}" is not a valid UUID`),es(e,n.outputFormat),q(1),{messages:[]}}if(i(process.env.CLAUDE_CODE_USE_CCR_V2)){let[,e]=await Promise.all([un(a.sessionId),n.restoredWorkerState]);e&&(t(Va(e)),typeof e.model==`string`&&re(e.model))}else a.isUrl&&a.ingressUrl&&i(process.env.ENABLE_SESSION_PERSISTENCE)&&await Or(a.sessionId,a.ingressUrl);let o=await wn(a.sessionId,a.jsonlFile||void 0);if(!o||o.messages.length===0)return a.isUrl||i(process.env.CLAUDE_CODE_USE_CCR_V2)?{messages:await(n.sessionStartHooksPromise??kr(`startup`))}:(es(`No conversation found with session ID: ${a.sessionId}`,n.outputFormat),q(1),{messages:[]});if(n.resumeSessionAt){let e=o.messages.findIndex(e=>e.uuid===n.resumeSessionAt);if(e<0)return es(`No message found with message.uuid of: ${n.resumeSessionAt}`,n.outputFormat),q(1),{messages:[]};o.messages=e>=0?o.messages.slice(0,e+1):[]}if(Q){let n=Q.matchSessionMode(o.mode);if(n){process.stderr.write(n+`
39
39
  `);let{getAgentDefinitionsWithOverrides:r,getActiveAgentsFromList:i}=(Wr(),e(pi));r.cache.clear?.();let a=await r(Ue());t(e=>({...e,agentDefinitions:{...a,allAgents:a.allAgents,activeAgents:i(a.allAgents)}}))}}return!n.forkSession&&o.sessionId&&(te(Di(o.sessionId),o.fullPath?po(o.fullPath):null),r&&await er()),co(o,t),cr(n.forkSession?{...o,worktreeSession:void 0}:o),Q&&yi(Q.isCoordinatorMode()?`coordinator`:`normal`),{messages:o.messages,turnInterruptionState:o.turnInterruptionState,agentSetting:o.agentSetting}}catch(e){return W(e),es(e instanceof Error?`Failed to resume session: ${e.message}`:`Failed to resume session with --print mode`,n.outputFormat),q(1),{messages:[]}}return{messages:await(n.sessionStartHooksPromise??kr(`startup`))}}function rs(e,t){let n;return n=typeof e==`string`?e.trim()===``?In([]):In([P({type:`user`,content:e,uuid:``,session_id:``,message:{role:`user`,content:e},parent_tool_use_id:null})]):e,t.sdkUrl?new bo(t.sdkUrl,n,t.replayUserMessages):new Ga(n,t.replayUserMessages)}async function is({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(I(`handleOrphanedPermissionResponse: received orphaned control_response for toolUseID=${t} request_id=${i.request_id}`),r.has(t))return I(`handleOrphanedPermissionResponse: skipping duplicate orphaned permission for toolUseID=${t} (already handled)`),!1;let a=await Nr(t);return a?(r.add(t),I(`handleOrphanedPermissionResponse: enqueuing orphaned permission for toolUseID=${t} messageID=${a.message.id}`),J({mode:`orphaned-permission`,value:[],orphanedPermission:{permissionResult:e,assistantMessage:a}}),n?.(),!0):(I(`handleOrphanedPermissionResponse: no unresolved tool_use found for toolUseID=${t} (already resolved in transcript)`),!1)}return!1}function as(e){return{...e,scope:`dynamic`}}async function os(e,t,n,r){let{allowed:i,blocked:a}=Pr(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 ss(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 ss(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?!0:!Xn(r,as(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){W(e)}await Sn(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=as(n);if(n.type===`sdk`){l.push(t);continue}try{let e=await Ct(t,r);if(d.push(e),e.type===`connected`){let t=await kt(e);f.push(...t)}else e.type===`failed`&&(u[t]=e.error||`Connection failed`);l.push(t)}catch(e){let n=Ne(e);u[t]=n.message,W(n)}}let p={};for(let t of i){let n=e[t];n&&(p[t]=as(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{Go as runHeadless};
@@ -1 +1 @@
1
- import{n as e}from"./chunk-DR8-3Aex.js";import{Rn as t}from"./src-Di342QoJ.js";import{t as n}from"./jsx-runtime-D-D469L8.js";import{n as r,r as i}from"./analytics-DqMQntaB.js";import{GT as a,JT as o,KT as s,qT as c}from"./loadAgentsDir-DF6FgRn-.js";import{n as l,r as u,t as d}from"./Grove-TYf1glGP.js";async function f(e){if(!await o())return e(m),null;let[t,n]=await Promise.all([s(),a()]);if(!t.success)return e(m),null;let r=t.data,c=n.success?n.data:null;async function u(t){if(t===`escape`||t===`defer`){e(`Privacy settings dialog dismissed`,{display:`system`});return}await f()}async function f(){let t=await s();if(!t.success){e(`Unable to retrieve updated privacy settings`,{display:`system`});return}let n=t.data;e(`"Help improve Claude" set to ${n.grove_enabled?`true`:`false`}.`),r.grove_enabled!==null&&r.grove_enabled!==n.grove_enabled&&i(`tengu_grove_policy_toggled`,{state:n.grove_enabled,location:`settings`})}return r.grove_enabled===null?(0,p.jsx)(d,{showIfAlreadyViewed:!0,onDone:u,location:`settings`}):(0,p.jsx)(l,{settings:r,domainExcluded:c?.domain_excluded,onDone:f})}var p,m;e((()=>{t(),u(),r(),c(),p=n(),m=`Review and manage your privacy settings at https://claude.ai/settings/data-privacy-controls`}))();export{f as call};
1
+ import{n as e}from"./chunk-DR8-3Aex.js";import{Rn as t}from"./src-Di342QoJ.js";import{t as n}from"./jsx-runtime-D-D469L8.js";import{n as r,r as i}from"./analytics-DqMQntaB.js";import{GT as a,JT as o,KT as s,qT as c}from"./loadAgentsDir-Cl2w3uvH.js";import{n as l,r as u,t as d}from"./Grove-G0DtwY22.js";async function f(e){if(!await o())return e(m),null;let[t,n]=await Promise.all([s(),a()]);if(!t.success)return e(m),null;let r=t.data,c=n.success?n.data:null;async function u(t){if(t===`escape`||t===`defer`){e(`Privacy settings dialog dismissed`,{display:`system`});return}await f()}async function f(){let t=await s();if(!t.success){e(`Unable to retrieve updated privacy settings`,{display:`system`});return}let n=t.data;e(`"Help improve Claude" set to ${n.grove_enabled?`true`:`false`}.`),r.grove_enabled!==null&&r.grove_enabled!==n.grove_enabled&&i(`tengu_grove_policy_toggled`,{state:n.grove_enabled,location:`settings`})}return r.grove_enabled===null?(0,p.jsx)(d,{showIfAlreadyViewed:!0,onDone:u,location:`settings`}):(0,p.jsx)(l,{settings:r,domainExcluded:c?.domain_excluded,onDone:f})}var p,m;e((()=>{t(),u(),r(),c(),p=n(),m=`Review and manage your privacy settings at https://claude.ai/settings/data-privacy-controls`}))();export{f as call};
@@ -1 +1 @@
1
- import{a as e}from"./chunk-DR8-3Aex.js";import{Rn as t,t as n,x as r}from"./src-Di342QoJ.js";import{t as i}from"./jsx-runtime-D-D469L8.js";import{Ka as a,oo as o}from"./paths-o5iA-EnQ.js";import{L as s,N as c,V as l}from"./debug-UI3T040K.js";import{n as u,r as d}from"./analytics-DqMQntaB.js";import{Dg as f,Dm as p,Eg as m,Em as h,Lo as g,Rm as _,bo as v,go as y,hu as b,mu as x,qo as S,vC as C,yC as w,yo as T,zm as E}from"./loadAgentsDir-DF6FgRn-.js";import{Ft as D,Pt as O}from"./prompt-DiHksuOs.js";import{r as k,t as A}from"./xml-CqxiCY4v.js";import{randomUUID as j}from"crypto";t(),n(),b(),f(),E();var M=i();function N({input:e,progress:t,verbose:n}){return(0,M.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,M.jsx)(m,{addMargin:!1,param:{text:`<bash-input>${e}</bash-input>`,type:`text`}}),t?(0,M.jsx)(_,{fullOutput:t.fullOutput,output:t.output,elapsedTimeSeconds:t.elapsedTimeSeconds,totalLines:t.totalLines,verbose:n}):x.renderToolUseProgressMessage?.([],{verbose:n,tools:[],terminalSize:void 0})]})}u(),l(),C(),g(),o();function P(){return a().defaultShell??`bash`}b(),O(),k();async function F(t,n,r,i,a){let o=D()&&P()===`powershell`;d(`tengu_input_bash`,{powershell:o});let l=v({content:S({inputString:`<bash-input>${t}</bash-input>`,precedingInputBlocks:n})}),u;a({jsx:(0,M.jsx)(N,{input:t,progress:null,verbose:i.options.verbose}),shouldHidePromptInput:!1});try{let n={...i,setToolJSX:e=>{u=e?.jsx}},s=e=>{a({jsx:(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(N,{input:t,progress:e.data,verbose:i.options.verbose}),u]}),shouldHidePromptInput:!1,showSpinner:!1})},c=null;o&&(c=(p(),e(h)).PowerShellTool);let d=c??x,f=(c?await c.call({command:t,dangerouslyDisableSandbox:!0},n,void 0,void 0,s):await x.call({command:t,dangerouslyDisableSandbox:!0},n,void 0,void 0,s)).data;if(!f)throw Error(`No result received from shell command`);let m=f.stderr,g=await w(d,{...f,stderr:``},j()),_=typeof g.content==`string`?g.content:A(f.stdout);return{messages:[y(),l,...r,v({content:`<bash-stdout>${_}</bash-stdout><bash-stderr>${A(m)}</bash-stderr>`})],shouldQuery:!1}}catch(e){return e instanceof c?e.interrupted?{messages:[y(),l,T({toolUse:!1}),...r],shouldQuery:!1}:{messages:[y(),l,...r,v({content:`<bash-stdout>${A(e.stdout)}</bash-stdout><bash-stderr>${A(e.stderr)}</bash-stderr>`})],shouldQuery:!1}:{messages:[y(),l,...r,v({content:`<bash-stderr>Command failed: ${A(s(e))}</bash-stderr>`})],shouldQuery:!1}}finally{a(null)}}export{F as processBashCommand};
1
+ import{a as e}from"./chunk-DR8-3Aex.js";import{Rn as t,t as n,x as r}from"./src-Di342QoJ.js";import{t as i}from"./jsx-runtime-D-D469L8.js";import{Ka as a,oo as o}from"./paths-q1-Ni8Oh.js";import{L as s,N as c,V as l}from"./debug-UI3T040K.js";import{n as u,r as d}from"./analytics-DqMQntaB.js";import{Dg as f,Dm as p,Eg as m,Em as h,Lo as g,Rm as _,bo as v,go as y,hu as b,mu as x,qo as S,vC as C,yC as w,yo as T,zm as E}from"./loadAgentsDir-Cl2w3uvH.js";import{Ft as D,Pt as O}from"./prompt-BmOnuQfF.js";import{r as k,t as A}from"./xml-CMdTGiv6.js";import{randomUUID as j}from"crypto";t(),n(),b(),f(),E();var M=i();function N({input:e,progress:t,verbose:n}){return(0,M.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,M.jsx)(m,{addMargin:!1,param:{text:`<bash-input>${e}</bash-input>`,type:`text`}}),t?(0,M.jsx)(_,{fullOutput:t.fullOutput,output:t.output,elapsedTimeSeconds:t.elapsedTimeSeconds,totalLines:t.totalLines,verbose:n}):x.renderToolUseProgressMessage?.([],{verbose:n,tools:[],terminalSize:void 0})]})}u(),l(),C(),g(),o();function P(){return a().defaultShell??`bash`}b(),O(),k();async function F(t,n,r,i,a){let o=D()&&P()===`powershell`;d(`tengu_input_bash`,{powershell:o});let l=v({content:S({inputString:`<bash-input>${t}</bash-input>`,precedingInputBlocks:n})}),u;a({jsx:(0,M.jsx)(N,{input:t,progress:null,verbose:i.options.verbose}),shouldHidePromptInput:!1});try{let n={...i,setToolJSX:e=>{u=e?.jsx}},s=e=>{a({jsx:(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(N,{input:t,progress:e.data,verbose:i.options.verbose}),u]}),shouldHidePromptInput:!1,showSpinner:!1})},c=null;o&&(c=(p(),e(h)).PowerShellTool);let d=c??x,f=(c?await c.call({command:t,dangerouslyDisableSandbox:!0},n,void 0,void 0,s):await x.call({command:t,dangerouslyDisableSandbox:!0},n,void 0,void 0,s)).data;if(!f)throw Error(`No result received from shell command`);let m=f.stderr,g=await w(d,{...f,stderr:``},j()),_=typeof g.content==`string`?g.content:A(f.stdout);return{messages:[y(),l,...r,v({content:`<bash-stdout>${_}</bash-stdout><bash-stderr>${A(m)}</bash-stderr>`})],shouldQuery:!1}}catch(e){return e instanceof c?e.interrupted?{messages:[y(),l,T({toolUse:!1}),...r],shouldQuery:!1}:{messages:[y(),l,...r,v({content:`<bash-stdout>${A(e.stdout)}</bash-stdout><bash-stderr>${A(e.stderr)}</bash-stderr>`})],shouldQuery:!1}:{messages:[y(),l,...r,v({content:`<bash-stderr>Command failed: ${A(s(e))}</bash-stderr>`})],shouldQuery:!1}}finally{a(null)}}export{F as processBashCommand};