@readmagic/workmate 0.0.3 → 0.0.4

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 (322) hide show
  1. package/dist/chunks/{AddWorkspaceDirectory-mANiG0xj.js → AddWorkspaceDirectory-BTC7FPqM.js} +1 -1
  2. package/dist/chunks/{App-aUVaOLeo.js → App-DOm71vtY.js} +1 -1
  3. package/dist/chunks/{ApproveApiKey-36iUE5CW.js → ApproveApiKey-9YQzwrrC.js} +1 -1
  4. package/dist/chunks/ApproveApiKey-LPrZMlgU.js +1 -0
  5. package/dist/chunks/{AssistantSessionChooser-BLcvdkgb.js → AssistantSessionChooser-CnYfFWrx.js} +1 -1
  6. package/dist/chunks/{BackgroundTasksDialog-DyjVt81B.js → BackgroundTasksDialog-D_UHm7xo.js} +1 -1
  7. package/dist/chunks/{BypassPermissionsModeDialog-CTlpvTuz.js → BypassPermissionsModeDialog-DAq-qbqC.js} +1 -1
  8. package/dist/chunks/ClaudeMdExternalIncludesDialog--w2zWWEn.js +1 -0
  9. package/dist/chunks/{ClaudeMdExternalIncludesDialog-5pipE8m8.js → ClaudeMdExternalIncludesDialog-CyvidoR3.js} +1 -1
  10. package/dist/chunks/ConsoleOAuthFlow-BXdC6j3_.js +1 -0
  11. package/dist/chunks/{DesktopHandoff-Blg1TVut.js → DesktopHandoff-gRvy-WlW.js} +1 -1
  12. package/dist/chunks/{DiffDialog-CUEpuocY.js → DiffDialog-CdfVTgOx.js} +1 -1
  13. package/dist/chunks/Doctor-BuiYwjAS.js +1 -0
  14. package/dist/chunks/{Doctor-DlE1Mbb9.js → Doctor-DKlHJBXq.js} +1 -1
  15. package/dist/chunks/{ExitFlow-DCIhnP5h.js → ExitFlow-rExuBL3w.js} +1 -1
  16. package/dist/chunks/{Feedback-CDTqPqsM.js → Feedback-gGpjUC_F.js} +1 -1
  17. package/dist/chunks/{Grove-D9lSG_Lh.js → Grove-CD769Wvw.js} +1 -1
  18. package/dist/chunks/Grove-ENfM8hC6.js +1 -0
  19. package/dist/chunks/{HybridTransport-8j0AviF6.js → HybridTransport-kN1jmg26.js} +1 -1
  20. package/dist/chunks/{InvalidConfigDialog-I3t-0nU3.js → InvalidConfigDialog-BpJub73a.js} +1 -1
  21. package/dist/chunks/{InvalidSettingsDialog-BnthOxGT.js → InvalidSettingsDialog-DzOp3Ihx.js} +1 -1
  22. package/dist/chunks/{MCPConnectionManager-zdocEDgk.js → MCPConnectionManager-CaBvO7NB.js} +1 -1
  23. package/dist/chunks/{McpParsingWarnings-D0XvLirX.js → McpParsingWarnings-Cc6FWyU4.js} +1 -1
  24. package/dist/chunks/{MessageSelector-BBhCstBa.js → MessageSelector-DOB1S2-O.js} +1 -1
  25. package/dist/chunks/{Messages-Dv2VrytX.js → Messages-Clihwd2F.js} +2 -2
  26. package/dist/chunks/{Onboarding-B1WRpoBI.js → Onboarding-D00lTweB.js} +1 -1
  27. package/dist/chunks/{OverageCreditUpsell-BSmgq089.js → OverageCreditUpsell-B-Bf_-UX.js} +1 -1
  28. package/dist/chunks/{PluginSettings-DN9rpwc_.js → PluginSettings-DUxj_oAg.js} +1 -1
  29. package/dist/chunks/{PromptInputFooterSuggestions-3rjz6zhK.js → PromptInputFooterSuggestions-MwS_cExV.js} +1 -1
  30. package/dist/chunks/{PromptInputHelpMenu-DgDJHZqC.js → PromptInputHelpMenu-V2dEpzhC.js} +1 -1
  31. package/dist/chunks/{QueryEngine-BnaHDZVZ.js → QueryEngine-BLcPQYq_.js} +1 -1
  32. package/dist/chunks/{REPL-CA8FEO7J.js → REPL-B_E07dnf.js} +6 -6
  33. package/dist/chunks/REPL-BhURgntS.js +1 -0
  34. package/dist/chunks/{RemoteCallout-BFzCx_Pn.js → RemoteCallout-ChCjmgw1.js} +1 -1
  35. package/dist/chunks/{RemoteSessionManager-BhUrtejX.js → RemoteSessionManager-B43isWQs.js} +1 -1
  36. package/dist/chunks/{ResumeConversation-BseKUFRI.js → ResumeConversation-DaQ9n8_C.js} +1 -1
  37. package/dist/chunks/{SSETransport-DGIytG74.js → SSETransport-h43pQVlJ.js} +1 -1
  38. package/dist/chunks/SearchExtraToolsTool-DSq7beKs.js +1 -0
  39. package/dist/chunks/{Settings-BvhG1XoW.js → Settings-CNsaWv8g.js} +2 -2
  40. package/dist/chunks/{TeleportProgress-Bens06DU.js → TeleportProgress-QtJrXSCX.js} +1 -1
  41. package/dist/chunks/{TeleportRepoMismatchDialog-BtLBCZUe.js → TeleportRepoMismatchDialog-D-HVj-A6.js} +1 -1
  42. package/dist/chunks/{TeleportResumeWrapper-t50LfWyN.js → TeleportResumeWrapper-C6sbzJsJ.js} +1 -1
  43. package/dist/chunks/{ThemePicker-BTfuZZ7E.js → ThemePicker-CqPCp5Hs.js} +1 -1
  44. package/dist/chunks/{TrustDialog-CgE_pYUK.js → TrustDialog-CeVwxDlZ.js} +1 -1
  45. package/dist/chunks/{WelcomeV2-C93xQYAF.js → WelcomeV2-DNiXQ5ES.js} +1 -1
  46. package/dist/chunks/{add-dir-C3IhJYVH.js → add-dir-V3xjklnJ.js} +1 -1
  47. package/dist/chunks/{agentDisplay-Cju-aXCx.js → agentDisplay-BuiwcrQi.js} +1 -1
  48. package/dist/chunks/{agents-Bhg0CtXR.js → agents-D7um1IXM.js} +1 -1
  49. package/dist/chunks/{agents-Du3FQ82k.js → agents-ZY6IaVE7.js} +1 -1
  50. package/dist/chunks/{allErrors-DJYCAtab.js → allErrors-CHVdQ3fT.js} +1 -1
  51. package/dist/chunks/{ant-CVvy4SuO.js → ant-D66LZCap.js} +1 -1
  52. package/dist/chunks/{api-gJBnC8z3.js → api-C-rOQY-l.js} +1 -1
  53. package/dist/chunks/api-Dmn7DUgU.js +1 -0
  54. package/dist/chunks/{assistant-C_SkUDk_.js → assistant-CYF7ch7C.js} +1 -1
  55. package/dist/chunks/auth-C4Rvit2q.js +1 -0
  56. package/dist/chunks/auth-Cj7EX1eG.js +1 -0
  57. package/dist/chunks/{auth-CgEABs3i.js → auth-DAxGNCIR.js} +1 -1
  58. package/dist/chunks/{autoMode-CZyb-mMY.js → autoMode-TysBQkU_.js} +1 -1
  59. package/dist/chunks/{autonomy-DJZ25xZp.js → autonomy-CNEbT-t_.js} +1 -1
  60. package/dist/chunks/{autonomy-BpINX4jw.js → autonomy-k3QPea5z.js} +1 -1
  61. package/dist/chunks/{autonomyPanel-ssoiIOx5.js → autonomyPanel-DiztRblF.js} +1 -1
  62. package/dist/chunks/{backgroundHousekeeping-BHncba6e.js → backgroundHousekeeping-C9m4tiFi.js} +2 -2
  63. package/dist/chunks/backgroundHousekeeping-DQjzXBe0.js +1 -0
  64. package/dist/chunks/{branch-BXo5z2al.js → branch-_NBgDfrK.js} +1 -1
  65. package/dist/chunks/{bridge-CbKc1HeD.js → bridge-DpmFl8p8.js} +2 -2
  66. package/dist/chunks/{bridgeConfig-DbqUHe0H.js → bridgeConfig-DMBOO3gW.js} +1 -1
  67. package/dist/chunks/bridgeConfig-DsI5d0s7.js +1 -0
  68. package/dist/chunks/bridgeEnabled-DZzlF2d8.js +1 -0
  69. package/dist/chunks/{bridgeEnabled-CM3SaumJ.js → bridgeEnabled-FjPuA7zx.js} +1 -1
  70. package/dist/chunks/{bridgeMain-CzhBVCsN.js → bridgeMain-BppY0KW3.js} +6 -6
  71. package/dist/chunks/bridgeMain-BrY4tkF6.js +1 -0
  72. package/dist/chunks/{bridgeMessaging-lfa_v3oi.js → bridgeMessaging-N5zlzCCr.js} +1 -1
  73. package/dist/chunks/{btw-Cp0whJaJ.js → btw-BFRje_Zi.js} +1 -1
  74. package/dist/chunks/caches-BBLH8G1I.js +1 -0
  75. package/dist/chunks/{caches-CmW7idg5.js → caches-CcfPJ4_A.js} +2 -2
  76. package/dist/chunks/{ccrClient-BPXmxWHw.js → ccrClient-q2JCVCU2.js} +1 -1
  77. package/dist/chunks/{clear-DjGPxX7T.js → clear-CxY7W5Wt.js} +1 -1
  78. package/dist/chunks/client-CtVu3BLD.js +1 -0
  79. package/dist/chunks/{color-DYYBN52b.js → color-DOWhfjnA.js} +1 -1
  80. package/dist/chunks/commands-BWw1sQeH.js +1 -0
  81. package/dist/chunks/{commitAttribution-Bmzgtqc6.js → commitAttribution-CLbEIaRJ.js} +1 -1
  82. package/dist/chunks/commitAttribution-DIT_s0vY.js +1 -0
  83. package/dist/chunks/{compact-D6xqZN4Q.js → compact-CaOnQVkH.js} +1 -1
  84. package/dist/chunks/config-DmPGzNmi.js +1 -0
  85. package/dist/chunks/{config-huQaTcNb.js → config-HHTwEsWp.js} +1 -1
  86. package/dist/chunks/{context-Bh_iUj76.js → context-B2OvKo2t.js} +1 -1
  87. package/dist/chunks/context-noninteractive-BilCSCV1.js +1 -0
  88. package/dist/chunks/{context-noninteractive-Cb3EM2Oz.js → context-noninteractive-BuGxX3YL.js} +1 -1
  89. package/dist/chunks/conversation-BWXf3un9.js +1 -0
  90. package/dist/chunks/{conversation-CvCQta8e.js → conversation-awh8AwwL.js} +1 -1
  91. package/dist/chunks/{createSSHSession-B0s839mX.js → createSSHSession-C-c7I5iJ.js} +1 -1
  92. package/dist/chunks/{createSession-VMTMXOHu.js → createSession-D_fIDqgc.js} +1 -1
  93. package/dist/chunks/createSession-Hvpx3Le7.js +1 -0
  94. package/dist/chunks/{crossProjectResume-DGpgCUfk.js → crossProjectResume-_XjvSXA3.js} +1 -1
  95. package/dist/chunks/{datadog-D9rlcN12.js → datadog-Ed8emSFA.js} +1 -1
  96. package/dist/chunks/{desktop-DidI-4N5.js → desktop-D_ofPlyi.js} +1 -1
  97. package/dist/chunks/{diff-CZg5qL2n.js → diff-CUAgBDu1.js} +1 -1
  98. package/dist/chunks/doctor-CkdQ7Fv7.js +1 -0
  99. package/dist/chunks/{effort-BcvNemuq.js → effort-DCgooYMY.js} +1 -1
  100. package/dist/chunks/{entry-dA1UCfC0.js → entry-Bh0gPOAo.js} +1 -1
  101. package/dist/chunks/{envLessBridgeConfig-BFjJ8Kt4.js → envLessBridgeConfig-DJHZAlU-.js} +1 -1
  102. package/dist/chunks/envLessBridgeConfig-sxodu0xO.js +1 -0
  103. package/dist/chunks/{esm-DjGYYlQe.js → esm-B62dCLgf.js} +1 -1
  104. package/dist/chunks/{exit-COMnVxzw.js → exit-CFJR3NfE.js} +1 -1
  105. package/dist/chunks/{extra-usage-BTv_OwGN.js → extra-usage-CjaHpu8y.js} +1 -1
  106. package/dist/chunks/extra-usage-D1Y-3OWQ.js +1 -0
  107. package/dist/chunks/{extra-usage-core-RZMzaH0L.js → extra-usage-core-B6ga8Rni.js} +1 -1
  108. package/dist/chunks/{extra-usage-noninteractive-BB-BQ3kh.js → extra-usage-noninteractive-Dc9AndId.js} +1 -1
  109. package/dist/chunks/{extraUsage-CTn9FWSk.js → extraUsage-2DwLEr26.js} +1 -1
  110. package/dist/chunks/extractMemories-C3qrwpu2.js +1 -0
  111. package/dist/chunks/{fast-CNXgsvnE.js → fast-CW_NsL0x.js} +1 -1
  112. package/dist/chunks/fast-D3CPmUX4.js +1 -0
  113. package/dist/chunks/{feedback-DeJ2gvw2.js → feedback-BpRorTAC.js} +1 -1
  114. package/dist/chunks/{firstPartyEventLogger-CQdJn3LV.js → firstPartyEventLogger-CuUiNdj8.js} +2 -2
  115. package/dist/chunks/firstPartyEventLogger-DPUQnc6J.js +1 -0
  116. package/dist/chunks/{flushGate-CJ73xcaK.js → flushGate-BltVae97.js} +1 -1
  117. package/dist/chunks/{gemini-Cn9bMXwP.js → gemini-YyIxfveQ.js} +1 -1
  118. package/dist/chunks/{generateRecap-BO9kzRon.js → generateRecap-tx4wLIkI.js} +1 -1
  119. package/dist/chunks/{generateSessionName-CGpL6ATy.js → generateSessionName-BkDigIN8.js} +1 -1
  120. package/dist/chunks/{goal-C8Qzl7_i.js → goal-DZrD4puM.js} +1 -1
  121. package/dist/chunks/{grok-CDT9P_BL.js → grok-BZf7W_hL.js} +1 -1
  122. package/dist/chunks/{grove-BGXzEyH9.js → grove-CFBPplP6.js} +1 -1
  123. package/dist/chunks/{heapdump-CFHvdSZv.js → heapdump-DWc3Z2NO.js} +1 -1
  124. package/dist/chunks/{help-DUZ7Y7Em.js → help-pap9jNUJ.js} +1 -1
  125. package/dist/chunks/{hooks-RHwUCXcT.js → hooks-Bmat0L6A.js} +1 -1
  126. package/dist/chunks/hooks-cCAzfabs.js +1 -0
  127. package/dist/chunks/inboundAttachments-DZgSqDwY.js +1 -0
  128. package/dist/chunks/{inboundAttachments-Cfl4_n0S.js → inboundAttachments-DkfNHtF9.js} +1 -1
  129. package/dist/chunks/{initReplBridge-GH3-LHF4.js → initReplBridge-myzllvlk.js} +1 -1
  130. package/dist/chunks/{install-OkuNmjmB.js → install-D4jmHjmk.js} +1 -1
  131. package/dist/chunks/{instrumentation-hrXeo-G4.js → instrumentation-Nqgm1SMw.js} +3 -3
  132. package/dist/chunks/{job-DjmIpwJl.js → job-CT9bcgPb.js} +1 -1
  133. package/dist/chunks/{keybindings-B8U17bhs.js → keybindings-DETOn3qJ.js} +1 -1
  134. package/dist/chunks/{launchAgentsPlatform-DnxH2SAn.js → launchAgentsPlatform-CuRQgd2Q.js} +1 -1
  135. package/dist/chunks/{launchLocalMemory-CgXtGng1.js → launchLocalMemory-CRMqifzn.js} +1 -1
  136. package/dist/chunks/{launchLocalVault-Bs6Km3Ua.js → launchLocalVault-DlKX_oDE.js} +1 -1
  137. package/dist/chunks/{launchMemoryStores-DxVAIJuB.js → launchMemoryStores-CN0ecWpP.js} +1 -1
  138. package/dist/chunks/{launchOnboarding-Cn0t_o2k.js → launchOnboarding-DTdUA_wE.js} +1 -1
  139. package/dist/chunks/{launchSchedule-Chwr3Nzd.js → launchSchedule-psiSLmTA.js} +1 -1
  140. package/dist/chunks/{launchSkillStore-6zxJfWVU.js → launchSkillStore-CQQ00Ads.js} +1 -1
  141. package/dist/chunks/{launchTeleport-Ba_Hj13c.js → launchTeleport-CXFRPVMR.js} +1 -1
  142. package/dist/chunks/{launchVault-hGVrHy33.js → launchVault-Dn6jq0Rc.js} +1 -1
  143. package/dist/chunks/{loadAgentsDir-DrDu5yYy.js → loadAgentsDir-BURvZNN6.js} +38 -38
  144. package/dist/chunks/loadAgentsDir-Db9UTm45.js +1 -0
  145. package/dist/chunks/{loadPluginHooks-s7bvGtns.js → loadPluginHooks-C9A9oS-w.js} +1 -1
  146. package/dist/chunks/{localSearch-_bQhk9W6.js → localSearch-D2Rs8wQP.js} +1 -1
  147. package/dist/chunks/localSearch-hBh1ATr2.js +1 -0
  148. package/dist/chunks/{logoV2Utils-CoC4nheD.js → logoV2Utils-DN9nzdX-.js} +1 -1
  149. package/dist/chunks/{magicDocs-kMjYpjCA.js → magicDocs-DIeTcwAA.js} +1 -1
  150. package/dist/chunks/{main-C_rVSWfm.js → main-CI54PZrG.js} +14 -14
  151. package/dist/chunks/{mappers-D0CNXG32.js → mappers-Q_Z3Kjo-.js} +1 -1
  152. package/dist/chunks/{mcp-1ZuFesM9.js → mcp-CtbhGaLC.js} +1 -1
  153. package/dist/chunks/{mcp-CKvGBEjz.js → mcp-DMacvhqZ.js} +1 -1
  154. package/dist/chunks/{mcp-DtxIl6aN.js → mcp-RvwPC7FB.js} +2 -2
  155. package/dist/chunks/{memory-DE2jtkd_.js → memory-BPN8gW7n.js} +1 -1
  156. package/dist/chunks/{mode-B4WIxCMW.js → mode-Jl_Boaym.js} +1 -1
  157. package/dist/chunks/{model-fi472PRc.js → model-BIVmcl_N.js} +1 -1
  158. package/dist/chunks/{model-j9GNZDFr.js → model-CWBwPvTH.js} +1 -1
  159. package/dist/chunks/model-DlVpqR0P.js +1 -0
  160. package/dist/chunks/{nativeInstaller-DktvrWRd.js → nativeInstaller-8arnRiUO.js} +1 -1
  161. package/dist/chunks/{onChangeAppState-CGVeNkt7.js → onChangeAppState-DBantDJ6.js} +1 -1
  162. package/dist/chunks/{openai-BSVjSJiF.js → openai-yin1iDG8.js} +1 -1
  163. package/dist/chunks/{overageCreditGrant-BVxlYgeU.js → overageCreditGrant-CN_sVURL.js} +1 -1
  164. package/dist/chunks/{panelCall-Cp6fpQeL.js → panelCall-CPKC6VR5.js} +1 -1
  165. package/dist/chunks/{partition-RjCtgt9J.js → partition-CW0BJ881.js} +1 -1
  166. package/dist/chunks/{passes-ByTLy6pj.js → passes-DOm9ukdK.js} +1 -1
  167. package/dist/chunks/{permissions-B3df_htx.js → permissions-CxDJ__l6.js} +1 -1
  168. package/dist/chunks/{pidLock-CdNZ0Wfg.js → pidLock-C69HNTTb.js} +2 -2
  169. package/dist/chunks/{plan-BxTA-b4l.js → plan-B0rEs32a.js} +1 -1
  170. package/dist/chunks/{plugin-DOpl5e1t.js → plugin-BSEMgcGu.js} +1 -1
  171. package/dist/chunks/{pluginAutoupdate-L09CQ-ph.js → pluginAutoupdate-CTByPD8J.js} +1 -1
  172. package/dist/chunks/{pluginBlocklist-B32eWmzn.js → pluginBlocklist-mogKaK0p.js} +1 -1
  173. package/dist/chunks/{pluginCliCommands-CDMWnO3d.js → pluginCliCommands-DQQ7C7kk.js} +1 -1
  174. package/dist/chunks/{pluginFlagging-3FQGvIfq.js → pluginFlagging-mHNff1t9.js} +1 -1
  175. package/dist/chunks/{pluginOperations-ClzXYNQe.js → pluginOperations-JEedVzfS.js} +1 -1
  176. package/dist/chunks/pluginStartupCheck-D7ts2V3p.js +1 -0
  177. package/dist/chunks/{pluginStartupCheck-BNd2QNzZ.js → pluginStartupCheck-RscVZDi4.js} +1 -1
  178. package/dist/chunks/{plugins-CcDG95Bs.js → plugins-Cr03lISA.js} +1 -1
  179. package/dist/chunks/policyLimits-DWtLyJ4n.js +1 -0
  180. package/dist/chunks/{print-Cc_QOSPF.js → print-CZUmAzmt.js} +4 -4
  181. package/dist/chunks/{privacy-settings-ChNsgGUs.js → privacy-settings-CwJ1H8Ua.js} +1 -1
  182. package/dist/chunks/{processBashCommand-Bx6_oZoE.js → processBashCommand-aKNneP2u.js} +1 -1
  183. package/dist/chunks/{processSlashCommand-AltWgIFt.js → processSlashCommand-BcPnWNxZ.js} +1 -1
  184. package/dist/chunks/prompt-CIyhCdkE.js +1 -0
  185. package/dist/chunks/{prompt-C0nU0VK3.js → prompt-DNDgGM9q.js} +1 -1
  186. package/dist/chunks/prompt-DRhjinu2.js +1 -0
  187. package/dist/chunks/{promptEditor-Cumef6hJ.js → promptEditor-DMJyosKj.js} +1 -1
  188. package/dist/chunks/{rate-limit-options-VL7S3SCx.js → rate-limit-options--Y3oF1g0.js} +1 -1
  189. package/dist/chunks/{rcDebugLog-2-1XSyFV.js → rcDebugLog-DoL1FpGJ.js} +1 -1
  190. package/dist/chunks/{reconciler-DHRE_gV2.js → reconciler-CJcSh6xo.js} +1 -1
  191. package/dist/chunks/{referral-DrebVwqx.js → referral-UKJv23_5.js} +1 -1
  192. package/dist/chunks/{refresh-pFezssA8.js → refresh-ul_i5R1a.js} +1 -1
  193. package/dist/chunks/{release-notes-D7vrFNXp.js → release-notes-CGv_6MMt.js} +1 -1
  194. package/dist/chunks/{releaseNotes-CDx2P0fb.js → releaseNotes-BKZNuDLD.js} +1 -1
  195. package/dist/chunks/{reload-plugins-CltHfg-l.js → reload-plugins-2W11dpLQ.js} +1 -1
  196. package/dist/chunks/{remote-env-SvvSuP0J.js → remote-env-D9xsoBfx.js} +1 -1
  197. package/dist/chunks/{remoteBridgeCore-BOeljn2c.js → remoteBridgeCore-asY9JAXU.js} +1 -1
  198. package/dist/chunks/{remoteManagedSettings-CaY_ZH8r.js → remoteManagedSettings-Bxo3bv1U.js} +1 -1
  199. package/dist/chunks/{rename-CbqrCCBO.js → rename-CHsHMWpO.js} +1 -1
  200. package/dist/chunks/{resume-DockJaY9.js → resume-NduOaghx.js} +1 -1
  201. package/dist/chunks/{runtimeObserver-XufSllVw.js → runtimeObserver-BXbjibFk.js} +2 -2
  202. package/dist/chunks/{runtimeObserver-DSUuYKfs.js → runtimeObserver-Bo80nWQf.js} +1 -1
  203. package/dist/chunks/sandbox-adapter-DDfVl_2V.js +1 -0
  204. package/dist/chunks/{sandbox-toggle-CZI5fuK3.js → sandbox-toggle-C-WCDRN4.js} +1 -1
  205. package/dist/chunks/searchExtraTools-BHWzsbNO.js +1 -0
  206. package/dist/chunks/{session-B-Z3DU9o.js → session-pDd13-wE.js} +1 -1
  207. package/dist/chunks/{sessionDiscovery-C3pMZkBM.js → sessionDiscovery-CSUnpsCy.js} +1 -1
  208. package/dist/chunks/sessionFileAccessHooks-BZvxeufx.js +1 -0
  209. package/dist/chunks/{sessionMemory-CqRpgwtU.js → sessionMemory-CAmpw2yb.js} +1 -1
  210. package/dist/chunks/sessionMemory-DT0IkiA1.js +1 -0
  211. package/dist/chunks/sessionMemoryUtils-B4kGNH4j.js +1 -0
  212. package/dist/chunks/{sessionObserver-B_09FQKV.js → sessionObserver-Ur7PqKl_.js} +1 -1
  213. package/dist/chunks/sessionObserver-oIkwTidC.js +1 -0
  214. package/dist/chunks/sessionStorage-DqARUj0K.js +1 -0
  215. package/dist/chunks/{sessionTitle-CmLWNFuX.js → sessionTitle-pWMaI79N.js} +1 -1
  216. package/dist/chunks/{sessionTracing-lArOaj9u.js → sessionTracing-CCPRzOvy.js} +1 -1
  217. package/dist/chunks/{settingsSync-BlDk6rsM.js → settingsSync-D_4P3Esd.js} +1 -1
  218. package/dist/chunks/{setup-DdbmxSZh.js → setup-JHvhWKh9.js} +2 -2
  219. package/dist/chunks/{shadowedRuleDetection-E2wF1UjU.js → shadowedRuleDetection-Chi3afMR.js} +1 -1
  220. package/dist/chunks/{sideQuestion-BjHCLSR9.js → sideQuestion-D03MXdE2.js} +1 -1
  221. package/dist/chunks/{sinks-Cb--pqr-.js → sinks-B4_pw0Gb.js} +2 -2
  222. package/dist/chunks/sinks-Cro1Y8C2.js +1 -0
  223. package/dist/chunks/{skill-learning-B0dyBT1_.js → skill-learning-7ZQF5JvA.js} +1 -1
  224. package/dist/chunks/{skillChangeDetector-DQof8SUY.js → skillChangeDetector-uCaYrerZ.js} +1 -1
  225. package/dist/chunks/{skillGapStore-D2fqmnKx.js → skillGapStore-BND2Lq0Z.js} +1 -1
  226. package/dist/chunks/{skillGapStore-75ZYlfwi.js → skillGapStore-z3LP64O-.js} +2 -2
  227. package/dist/chunks/{skillGenerator-CwXUfM4Y.js → skillGenerator-DaNb-yKH.js} +2 -2
  228. package/dist/chunks/skillLearning-GZxYPlyl.js +1 -0
  229. package/dist/chunks/{skillLearning-CB-5fdMl.js → skillLearning-rMX1bSBa.js} +1 -1
  230. package/dist/chunks/{skillPanel-Bum7xpgo.js → skillPanel-q7GPSQ6_.js} +3 -3
  231. package/dist/chunks/{skillSearchPanel-LSPwZIOw.js → skillSearchPanel-oj8gy1ZL.js} +2 -2
  232. package/dist/chunks/{skills-G8WBeffd.js → skills-QqbeFP0s.js} +1 -1
  233. package/dist/chunks/{status-i5beKggW.js → status-BEIsLmfj.js} +1 -1
  234. package/dist/chunks/{status-ClSsvm1N.js → status-DW3Z_7xa.js} +1 -1
  235. package/dist/chunks/{statusNoticeHelpers-BK-54uGY.js → statusNoticeHelpers-CaHS8xig.js} +1 -1
  236. package/dist/chunks/{tag-DYYq4H_i.js → tag-CRg93Die.js} +1 -1
  237. package/dist/chunks/{tasks-BySzm_YJ.js → tasks-BEohK1ij.js} +1 -1
  238. package/dist/chunks/{teleport-dxtBcM01.js → teleport-4Srg5vcP.js} +1 -1
  239. package/dist/chunks/{templateJobs-CT5VxeRr.js → templateJobs-DYP1fjYU.js} +1 -1
  240. package/dist/chunks/{theme-CVTVsRwt.js → theme-kNL4kl_3.js} +1 -1
  241. package/dist/chunks/{thinkback-CXsRbDYN.js → thinkback-gV-sKkMM.js} +1 -1
  242. package/dist/chunks/thinkback-hc5eJ9ul.js +1 -0
  243. package/dist/chunks/{thinkback-play-BhfCaIye.js → thinkback-play-BpWMqbgJ.js} +1 -1
  244. package/dist/chunks/{toolEventObserver-DdhPsAs1.js → toolEventObserver-C98uraqD.js} +1 -1
  245. package/dist/chunks/{toolEventObserver--4fqXxQZ.js → toolEventObserver-ar5NDa0M.js} +1 -1
  246. package/dist/chunks/{toolPool-DvHECcbN.js → toolPool-CNYKDRq5.js} +1 -1
  247. package/dist/chunks/trustedDevice-0dehm9qz.js +1 -0
  248. package/dist/chunks/{trustedDevice-DvpN4J1F.js → trustedDevice-BBKUhCCL.js} +1 -1
  249. package/dist/chunks/{ultrareviewCommand-i3PfFKly.js → ultrareviewCommand-yXlFsMnv.js} +1 -1
  250. package/dist/chunks/{undercover-Q24TWRw0.js → undercover-BTIRVF1t.js} +1 -1
  251. package/dist/chunks/undercover-CG_269xD.js +1 -0
  252. package/dist/chunks/{updateCCB-CEXA6dax.js → updateCCB-B2xAJ4Nr.js} +1 -1
  253. package/dist/chunks/upgrade-J7lKLkD2.js +1 -0
  254. package/dist/chunks/{upgrade-7OrBbrzS.js → upgrade-yNl7EO4e.js} +1 -1
  255. package/dist/chunks/{upload-B-lNHpWe.js → upload-BWVIHmMB.js} +1 -1
  256. package/dist/chunks/{usage-CZdPfUqP.js → usage-B2PbCUMi.js} +1 -1
  257. package/dist/chunks/usage-Ck8Cu45g.js +1 -0
  258. package/dist/chunks/{useExitOnCtrlCDWithKeybindings-CzFtdlnD.js → useExitOnCtrlCDWithKeybindings-CV4GZ-sq.js} +1 -1
  259. package/dist/chunks/useMainLoopModel-CO4yBjRM.js +1 -0
  260. package/dist/chunks/{useManagePlugins-BkK1zydO.js → useManagePlugins-BzFKIDrD.js} +1 -1
  261. package/dist/chunks/{useMergedTools-DMGRA1ga.js → useMergedTools-CRLWSGDl.js} +1 -1
  262. package/dist/chunks/{useSearchInput-D5VU9IDU.js → useSearchInput-BzGq4t7t.js} +1 -1
  263. package/dist/chunks/{useSettingsErrors-B5PSF1va.js → useSettingsErrors-CSemUjj1.js} +1 -1
  264. package/dist/chunks/{util-CNa1ib_4.js → util-BnReK81E.js} +1 -1
  265. package/dist/chunks/{validatePlugin-Dw-RGCrm.js → validatePlugin-D6sPqea1.js} +1 -1
  266. package/dist/chunks/{workerRegistry-B2QD2sKq.js → workerRegistry-CUXbNyL9.js} +1 -1
  267. package/dist/chunks/worktree-89ttIVxH.js +1 -0
  268. package/dist/cli.js +1 -1
  269. package/package.json +2 -6
  270. package/dist/chunks/ApproveApiKey-DPdcp1CQ.js +0 -1
  271. package/dist/chunks/ClaudeMdExternalIncludesDialog-Dn7Le--z.js +0 -1
  272. package/dist/chunks/ConsoleOAuthFlow-BDr1Vx5K.js +0 -1
  273. package/dist/chunks/Doctor-B540I-gq.js +0 -1
  274. package/dist/chunks/Grove-DLYXL8hv.js +0 -1
  275. package/dist/chunks/REPL-B3RbzeV7.js +0 -1
  276. package/dist/chunks/SearchExtraToolsTool-h6OunbMd.js +0 -1
  277. package/dist/chunks/api-CI8HXREw.js +0 -1
  278. package/dist/chunks/auth-B9V3i5oZ.js +0 -1
  279. package/dist/chunks/auth-fSFfSKy_.js +0 -1
  280. package/dist/chunks/backgroundHousekeeping-QK8iEXoI.js +0 -1
  281. package/dist/chunks/bridgeConfig-CLHy-BiF.js +0 -1
  282. package/dist/chunks/bridgeEnabled-BWSUZ7Xg.js +0 -1
  283. package/dist/chunks/bridgeMain-BESKzpm0.js +0 -1
  284. package/dist/chunks/caches-CpqTC0Lb.js +0 -1
  285. package/dist/chunks/client-DPUvQ6Rf.js +0 -1
  286. package/dist/chunks/commands-D7l3P1k9.js +0 -1
  287. package/dist/chunks/commitAttribution-B7NUPJ8E.js +0 -1
  288. package/dist/chunks/config-qLaiAn7z.js +0 -1
  289. package/dist/chunks/context-noninteractive-CNot6jbs.js +0 -1
  290. package/dist/chunks/conversation-CSpwF3Ha.js +0 -1
  291. package/dist/chunks/createSession-GNSNbUbN.js +0 -1
  292. package/dist/chunks/doctor-CKUXGCri.js +0 -1
  293. package/dist/chunks/envLessBridgeConfig-bei51W3H.js +0 -1
  294. package/dist/chunks/extra-usage-By33zGLT.js +0 -1
  295. package/dist/chunks/extractMemories-CXGZGe0h.js +0 -1
  296. package/dist/chunks/fast-BXzdzzXU.js +0 -1
  297. package/dist/chunks/firstPartyEventLogger-CdLshdJY.js +0 -1
  298. package/dist/chunks/hooks-fZ1r0jUF.js +0 -1
  299. package/dist/chunks/inboundAttachments-YMxf4fmR.js +0 -1
  300. package/dist/chunks/loadAgentsDir-BHOyHxwz.js +0 -1
  301. package/dist/chunks/localSearch-CebU5BA9.js +0 -1
  302. package/dist/chunks/model-C4RHNhDQ.js +0 -1
  303. package/dist/chunks/pluginStartupCheck-RiZxW-WU.js +0 -1
  304. package/dist/chunks/policyLimits-Bwi9VqDF.js +0 -1
  305. package/dist/chunks/prompt-CYx145pp.js +0 -1
  306. package/dist/chunks/prompt-DH3lKFag.js +0 -1
  307. package/dist/chunks/sandbox-adapter-CEZnHq0U.js +0 -1
  308. package/dist/chunks/searchExtraTools-iQfI39wB.js +0 -1
  309. package/dist/chunks/sessionFileAccessHooks-DyrZmoA7.js +0 -1
  310. package/dist/chunks/sessionMemory-D_HQmhj7.js +0 -1
  311. package/dist/chunks/sessionMemoryUtils-CZOIKrn0.js +0 -1
  312. package/dist/chunks/sessionObserver-B400YG3s.js +0 -1
  313. package/dist/chunks/sessionStorage-DRnvtrpU.js +0 -1
  314. package/dist/chunks/sinks-DbwDBd-E.js +0 -1
  315. package/dist/chunks/skillLearning-CSY5R5Jn.js +0 -1
  316. package/dist/chunks/thinkback-B-GpXG9U.js +0 -1
  317. package/dist/chunks/trustedDevice-e6iF1X7C.js +0 -1
  318. package/dist/chunks/undercover-CPvoDtJ1.js +0 -1
  319. package/dist/chunks/upgrade-uR7SIVtx.js +0 -1
  320. package/dist/chunks/usage-7jOeIVv9.js +0 -1
  321. package/dist/chunks/useMainLoopModel-DegH12LZ.js +0 -1
  322. package/dist/chunks/worktree-D38cJ23W.js +0 -1
@@ -1,4 +1,4 @@
1
- import{a as e}from"./rolldown-runtime-DaDcL9Zw.js";import{c as t,l as n,o as r,s as i}from"./envUtils-DSxRz_kt.js";import{n as a,t as o}from"./defineProperty-C-QyHrDq.js";import{M as s,P as c,Tn as l,Un as u,Wn as d,Z as f,en as p,ht as m,ir as h,kn as g,ln as _,tn as ee,vr as v}from"./state-ix0xIunV.js";import{$C as te,$w as y,$y as b,AT as ne,Al as x,Ar as S,B_ as C,Bb as w,C as T,CO as re,CT as ie,Cb as E,Cn as D,D as ae,E as oe,FD as O,FO as se,FT as ce,Fc as k,G as le,GO as ue,GT as de,G_ as fe,HC as pe,H_ as me,Hv as he,Hw as ge,ID as A,Ic as _e,Is as ve,KC as ye,K_ as be,Ks as j,Ku as xe,Ky as Se,LC as Ce,Ls as we,MD as Te,MO as Ee,MT as De,M_ as M,Md as Oe,Nc as ke,Ob as N,Oi as Ae,P as je,PO as Me,Pc as Ne,QS as Pe,Qi as Fe,Qw as Ie,Qy as Le,RC as Re,RO as ze,RT as Be,Sb as Ve,TD as He,TT as Ue,UC as P,UO as F,Ua as We,Us as Ge,Ut as Ke,Uw as qe,Uy as Je,Va as I,Vb as Ye,Vi as Xe,Vs as L,W as R,WT as Ze,Wi as Qe,Wv as $e,X_ as et,Xu as tt,Xw as nt,Xy as rt,Yw as z,ZS as it,Zw as at,Zy as B,_D as ot,_c as st,_g as ct,_i as lt,_w as ut,aT as dt,ag as ft,as as pt,aw as mt,ay as ht,b as gt,bD as _t,bb as vt,bc as yt,ca as bt,cf as xt,cg as St,cr as Ct,cs as wt,cu as Tt,dC as V,dT as Et,dg as Dt,dw as Ot,dy as kt,eT as At,ei as jt,f as Mt,fC as Nt,fc as Pt,fi as Ft,fs as It,fw as Lt,fy as Rt,gc as zt,gi as Bt,go as Vt,gw as Ht,hc as Ut,hg as Wt,hw as Gt,iT as Kt,i_ as qt,ig as Jt,ir as Yt,iw as Xt,jD as Zt,jT as Qt,jd as $t,jr as en,k_ as tn,kb as nn,ki as rn,kl as an,kr as on,lf as sn,lx as cn,mc as ln,mg as un,ms as dn,nT as fn,ng as pn,o as mn,oT as hn,o_ as gn,os as _n,pC as vn,pc as yn,pg as bn,pi as xn,pw as Sn,px as Cn,qC as wn,qi as Tn,qu as En,qy as Dn,rT as On,r_ as kn,s as An,su as jn,tT as Mn,tw as Nn,uC as Pn,uu as Fn,vc as In,vg as Ln,wD as Rn,wT as zn,wb as Bn,wn as Vn,x as Hn,xc as Un,y_ as Wn,yc as Gn,yn as Kn,z_ as qn,zo as Jn}from"./loadAgentsDir-DrDu5yYy.js";import{n as Yn,t as Xn}from"./cwd-CYmmnQVS.js";import{C as Zn,F as H,S as Qn,W as $n,a as er,d as tr,l as U,nt as nr,o as rr,p as ir,rt as ar,w as W,z as or}from"./debug-BrXObCdR.js";import{St as sr,Y as cr,_n as lr,ct as ur,d as dr,f as fr,g as pr,ht as mr,ot as G,yn as hr}from"./settings-DfWP5y6X.js";import{L as gr,P as _r}from"./config-DiT2Z8dY.js";import{i as vr,n as yr,o as K}from"./process-gEbdy6uY.js";import{M as br,N as xr,j as Sr}from"./git-Do0wJvux.js";import{U as Cr,Y as wr,c as Tr,i as Er,o as Dr,s as q}from"./log-BMCygSzM.js";import{i as Or,n as kr}from"./path-D5U-tm91.js";import{s as Ar,u as jr}from"./types-C-MRCL8J.js";import{n as Mr,r as J}from"./analytics-BotDBGh0.js";import{C as Nr,Er as Pr,Mn as Fr,Nn as Ir,Tr as Lr,Vt as Rr,X as zr,_ as Br,at as Vr,cr as Hr,di as Ur,fi as Wr,it as Gr,li as Kr,mi as qr,nt as Jr,o as Yr,sr as Xr,tt as Zr,u as Qr,vn as $r,x as ei,xt as ti,yn as ni}from"./model-fi472PRc.js";import{Dt as ri,En as ii,Ot as ai,Tn as oi,Zt as si,an as ci,dt as li,ut as ui}from"./prompt-C0nU0VK3.js";import{c as di,s as fi}from"./pluginFlagging-3FQGvIfq.js";import{a as pi,o as mi,s as hi}from"./fileStateCache-DDW5toIs.js";import{A as gi,C as _i,D as vi,N as yi,O as bi,P as xi,_ as Si,d as Ci,g as wi,h as Ti,lt as Ei,m as Di,u as Oi,v as ki,y as Ai}from"./rcDebugLog-2-1XSyFV.js";import{c as ji,l as Mi}from"./commitAttribution-Bmzgtqc6.js";import{t as Ni}from"./pollConfig-DH2oCtFS.js";import{r as Pi}from"./inboundAttachments-Cfl4_n0S.js";import{i as Fi,n as Ii,s as Li}from"./mappers-D0CNXG32.js";import{n as Ri,r as zi}from"./sessionTitle-CmLWNFuX.js";import{n as Bi,t as Vi}from"./ccrClient-BPXmxWHw.js";import{n as Hi,t as Ui}from"./HybridTransport-8j0AviF6.js";import{n as Wi,t as Gi}from"./SSETransport-DGIytG74.js";import{a as Ki,n as qi,o as Ji}from"./grove-BGXzEyH9.js";import{o as Yi}from"./remoteManagedSettings-CaY_ZH8r.js";import{i as Xi,r as Zi}from"./auth-CgEABs3i.js";import{t as Qi}from"./pluginBlocklist-B32eWmzn.js";import{t as $i}from"./onChangeAppState-CGVeNkt7.js";import{t as ea}from"./settingsSync-BlDk6rsM.js";import{a as ta,c as na,n as ra,o as ia,r as aa,s as oa}from"./reconciler-DHRE_gV2.js";import{n as sa,t as ca}from"./toolPool-DvHECcbN.js";import{n as la,r as ua}from"./QueryEngine-BnaHDZVZ.js";import{n as da,r as fa}from"./sideQuestion-BjHCLSR9.js";import{n as pa,r as ma}from"./context-noninteractive-Cb3EM2Oz.js";import{a as ha,o as ga,t as _a}from"./skillChangeDetector-DQof8SUY.js";import{n as va,t as ya}from"./refresh-pFezssA8.js";import{dirname as ba,join as xa}from"path";import{PassThrough as Sa}from"stream";import{randomUUID as Y}from"crypto";import{readFile as Ca,stat as wa}from"fs/promises";import{URL as Ta}from"url";import{cwd as X}from"process";a(),p(),Yn(),nr(),or(),Qn(),ir(),yr(),er(),Sr(),wr(),Dr(),Or(),lr(),Ar(),pr(),qr(),Ur(),Pr(),Fr(),$r(),Rr(),Br(),oi(),ci(),y(),yi(),P(),Nt(),bi(),kt(),Ci(),_n(),Jn(),Fe(),en(),ea(),r(),Wi();function Ea(e,t={},r,i){if(n(process.env.CLAUDE_CODE_USE_CCR_V2)){let n=new Ta(e.href);return n.protocol===`wss:`?n.protocol=`https:`:n.protocol===`ws:`&&(n.protocol=`http:`),n.pathname=n.pathname.replace(/\/$/,``)+`/worker/events/stream`,new Gi(n,t,r,i)}if(e.protocol===`ws:`||e.protocol===`wss:`)return n(process.env.CLAUDE_CODE_POST_FOR_SESSION_INGRESS_V2)?new Ui(e,t,r,i):new Hi(e,t,r,i);throw Error(`Unsupported protocol: ${e.protocol}`)}r(),Wi();var Da=class extends ta{constructor(e,t,r){let i=new Sa({encoding:`utf8`});super(i,r),o(this,`url`,void 0),o(this,`transport`,void 0),o(this,`inputStream`,void 0),o(this,`isBridge`,!1),o(this,`isDebug`,!1),o(this,`ccrClient`,null),o(this,`keepAliveTimer`,null),this.inputStream=i,this.url=new Ta(e);let a={},s=vi();s?a.Authorization=`Bearer ${s}`:U(`[remote-io] No session ingress token available`,{level:`error`});let c=process.env.CLAUDE_CODE_ENVIRONMENT_RUNNER_VERSION;c&&(a[`x-environment-runner-version`]=c);let l=()=>{let e={},t=vi();t&&(e.Authorization=`Bearer ${t}`);let n=process.env.CLAUDE_CODE_ENVIRONMENT_RUNNER_VERSION;return n&&(e[`x-environment-runner-version`]=n),e};if(this.transport=Ea(this.url,a,m(),l),this.isBridge=process.env.CLAUDE_CODE_ENVIRONMENT_KIND===`bridge`,this.isDebug=rr(),this.transport.setOnData(e=>{this.inputStream.write(e),this.isBridge&&this.isDebug&&K(e.endsWith(`
1
+ import{a as e}from"./rolldown-runtime-DaDcL9Zw.js";import{c as t,l as n,o as r,s as i}from"./envUtils-DSxRz_kt.js";import{n as a,t as o}from"./defineProperty-C-QyHrDq.js";import{M as s,P as c,Tn as l,Un as u,Wn as d,Z as f,en as p,ht as m,ir as h,kn as g,ln as _,tn as ee,vr as v}from"./state-ix0xIunV.js";import{$C as te,$w as y,$y as b,AT as ne,Al as x,Ar as S,B_ as C,Bb as w,C as T,CO as re,CT as ie,Cb as E,Cn as D,D as ae,E as oe,FD as O,FO as se,FT as ce,Fc as k,G as le,GO as ue,GT as de,G_ as fe,HC as pe,H_ as me,Hv as he,Hw as ge,ID as A,Ic as _e,Is as ve,KC as ye,K_ as be,Ks as j,Ku as xe,Ky as Se,LC as Ce,Ls as we,MD as Te,MO as Ee,MT as De,M_ as M,Md as Oe,Nc as ke,Ob as N,Oi as Ae,P as je,PO as Me,Pc as Ne,QS as Pe,Qi as Fe,Qw as Ie,Qy as Le,RC as Re,RO as ze,RT as Be,Sb as Ve,TD as He,TT as Ue,UC as P,UO as F,Ua as We,Us as Ge,Ut as Ke,Uw as qe,Uy as Je,Va as I,Vb as Ye,Vi as Xe,Vs as L,W as R,WT as Ze,Wi as Qe,Wv as $e,X_ as et,Xu as tt,Xw as nt,Xy as rt,Yw as z,ZS as it,Zw as at,Zy as B,_D as ot,_c as st,_g as ct,_i as lt,_w as ut,aT as dt,ag as ft,as as pt,aw as mt,ay as ht,b as gt,bD as _t,bb as vt,bc as yt,ca as bt,cf as xt,cg as St,cr as Ct,cs as wt,cu as Tt,dC as V,dT as Et,dg as Dt,dw as Ot,dy as kt,eT as At,ei as jt,f as Mt,fC as Nt,fc as Pt,fi as Ft,fs as It,fw as Lt,fy as Rt,gc as zt,gi as Bt,go as Vt,gw as Ht,hc as Ut,hg as Wt,hw as Gt,iT as Kt,i_ as qt,ig as Jt,ir as Yt,iw as Xt,jD as Zt,jT as Qt,jd as $t,jr as en,k_ as tn,kb as nn,ki as rn,kl as an,kr as on,lf as sn,lx as cn,mc as ln,mg as un,ms as dn,nT as fn,ng as pn,o as mn,oT as hn,o_ as gn,os as _n,pC as vn,pc as yn,pg as bn,pi as xn,pw as Sn,px as Cn,qC as wn,qi as Tn,qu as En,qy as Dn,rT as On,r_ as kn,s as An,su as jn,tT as Mn,tw as Nn,uC as Pn,uu as Fn,vc as In,vg as Ln,wD as Rn,wT as zn,wb as Bn,wn as Vn,x as Hn,xc as Un,y_ as Wn,yc as Gn,yn as Kn,z_ as qn,zo as Jn}from"./loadAgentsDir-BURvZNN6.js";import{n as Yn,t as Xn}from"./cwd-CYmmnQVS.js";import{C as Zn,F as H,S as Qn,W as $n,a as er,d as tr,l as U,nt as nr,o as rr,p as ir,rt as ar,w as W,z as or}from"./debug-BrXObCdR.js";import{St as sr,Y as cr,_n as lr,ct as ur,d as dr,f as fr,g as pr,ht as mr,ot as G,yn as hr}from"./settings-DfWP5y6X.js";import{L as gr,P as _r}from"./config-DiT2Z8dY.js";import{i as vr,n as yr,o as K}from"./process-gEbdy6uY.js";import{M as br,N as xr,j as Sr}from"./git-Do0wJvux.js";import{U as Cr,Y as wr,c as Tr,i as Er,o as Dr,s as q}from"./log-BMCygSzM.js";import{i as Or,n as kr}from"./path-D5U-tm91.js";import{s as Ar,u as jr}from"./types-C-MRCL8J.js";import{n as Mr,r as J}from"./analytics-BotDBGh0.js";import{C as Nr,Er as Pr,Mn as Fr,Nn as Ir,Tr as Lr,Vt as Rr,X as zr,_ as Br,at as Vr,cr as Hr,di as Ur,fi as Wr,it as Gr,li as Kr,mi as qr,nt as Jr,o as Yr,sr as Xr,tt as Zr,u as Qr,vn as $r,x as ei,xt as ti,yn as ni}from"./model-BIVmcl_N.js";import{Dt as ri,En as ii,Ot as ai,Tn as oi,Zt as si,an as ci,dt as li,ut as ui}from"./prompt-DNDgGM9q.js";import{c as di,s as fi}from"./pluginFlagging-mHNff1t9.js";import{a as pi,o as mi,s as hi}from"./fileStateCache-DDW5toIs.js";import{A as gi,C as _i,D as vi,N as yi,O as bi,P as xi,_ as Si,d as Ci,g as wi,h as Ti,lt as Ei,m as Di,u as Oi,v as ki,y as Ai}from"./rcDebugLog-DoL1FpGJ.js";import{c as ji,l as Mi}from"./commitAttribution-CLbEIaRJ.js";import{t as Ni}from"./pollConfig-DH2oCtFS.js";import{r as Pi}from"./inboundAttachments-DkfNHtF9.js";import{i as Fi,n as Ii,s as Li}from"./mappers-Q_Z3Kjo-.js";import{n as Ri,r as zi}from"./sessionTitle-pWMaI79N.js";import{n as Bi,t as Vi}from"./ccrClient-q2JCVCU2.js";import{n as Hi,t as Ui}from"./HybridTransport-kN1jmg26.js";import{n as Wi,t as Gi}from"./SSETransport-h43pQVlJ.js";import{a as Ki,n as qi,o as Ji}from"./grove-CFBPplP6.js";import{o as Yi}from"./remoteManagedSettings-Bxo3bv1U.js";import{i as Xi,r as Zi}from"./auth-DAxGNCIR.js";import{t as Qi}from"./pluginBlocklist-mogKaK0p.js";import{t as $i}from"./onChangeAppState-DBantDJ6.js";import{t as ea}from"./settingsSync-D_4P3Esd.js";import{a as ta,c as na,n as ra,o as ia,r as aa,s as oa}from"./reconciler-CJcSh6xo.js";import{n as sa,t as ca}from"./toolPool-CNYKDRq5.js";import{n as la,r as ua}from"./QueryEngine-BLcPQYq_.js";import{n as da,r as fa}from"./sideQuestion-D03MXdE2.js";import{n as pa,r as ma}from"./context-noninteractive-BuGxX3YL.js";import{a as ha,o as ga,t as _a}from"./skillChangeDetector-uCaYrerZ.js";import{n as va,t as ya}from"./refresh-ul_i5R1a.js";import{dirname as ba,join as xa}from"path";import{PassThrough as Sa}from"stream";import{randomUUID as Y}from"crypto";import{readFile as Ca,stat as wa}from"fs/promises";import{URL as Ta}from"url";import{cwd as X}from"process";a(),p(),Yn(),nr(),or(),Qn(),ir(),yr(),er(),Sr(),wr(),Dr(),Or(),lr(),Ar(),pr(),qr(),Ur(),Pr(),Fr(),$r(),Rr(),Br(),oi(),ci(),y(),yi(),P(),Nt(),bi(),kt(),Ci(),_n(),Jn(),Fe(),en(),ea(),r(),Wi();function Ea(e,t={},r,i){if(n(process.env.CLAUDE_CODE_USE_CCR_V2)){let n=new Ta(e.href);return n.protocol===`wss:`?n.protocol=`https:`:n.protocol===`ws:`&&(n.protocol=`http:`),n.pathname=n.pathname.replace(/\/$/,``)+`/worker/events/stream`,new Gi(n,t,r,i)}if(e.protocol===`ws:`||e.protocol===`wss:`)return n(process.env.CLAUDE_CODE_POST_FOR_SESSION_INGRESS_V2)?new Ui(e,t,r,i):new Hi(e,t,r,i);throw Error(`Unsupported protocol: ${e.protocol}`)}r(),Wi();var Da=class extends ta{constructor(e,t,r){let i=new Sa({encoding:`utf8`});super(i,r),o(this,`url`,void 0),o(this,`transport`,void 0),o(this,`inputStream`,void 0),o(this,`isBridge`,!1),o(this,`isDebug`,!1),o(this,`ccrClient`,null),o(this,`keepAliveTimer`,null),this.inputStream=i,this.url=new Ta(e);let a={},s=vi();s?a.Authorization=`Bearer ${s}`:U(`[remote-io] No session ingress token available`,{level:`error`});let c=process.env.CLAUDE_CODE_ENVIRONMENT_RUNNER_VERSION;c&&(a[`x-environment-runner-version`]=c);let l=()=>{let e={},t=vi();t&&(e.Authorization=`Bearer ${t}`);let n=process.env.CLAUDE_CODE_ENVIRONMENT_RUNNER_VERSION;return n&&(e[`x-environment-runner-version`]=n),e};if(this.transport=Ea(this.url,a,m(),l),this.isBridge=process.env.CLAUDE_CODE_ENVIRONMENT_KIND===`bridge`,this.isDebug=rr(),this.transport.setOnData(e=>{this.inputStream.write(e),this.isBridge&&this.isDebug&&K(e.endsWith(`
2
2
  `)?e:e+`
3
3
  `)}),this.transport.setOnClose(()=>{this.inputStream.end()}),n(process.env.CLAUDE_CODE_USE_CCR_V2)){if(!(this.transport instanceof Gi))throw Error(`CCR v2 requires SSETransport; check getTransportForUrl`);this.ccrClient=new Vi(this.transport,this.url);let e=this.ccrClient.initialize();this.restoredWorkerState=e.catch(()=>null),e.catch(e=>{br(`error`,`cli_worker_lifecycle_init_failed`,{reason:e instanceof Bi?e.reason:`unknown`}),q(Error(`CCRClient initialization failed: ${H(e)}`)),Pn(1,`other`)}),ar(async()=>this.ccrClient?.close()),rn((e,t,n)=>this.ccrClient.writeInternalEvent(e,t,n)),Ae(()=>this.ccrClient.readInternalEvents(),()=>this.ccrClient.readSubagentInternalEvents());let t={started:`processing`,completed:`processed`};Mn((e,n)=>{this.ccrClient?.reportDelivery(e,t[n])}),ki((e,t)=>{this.ccrClient?.reportState(e,t)}),Si(e=>{this.ccrClient?.reportMetadata(e)},{replayCurrent:!0})}this.transport.connect();let u=Ni().session_keepalive_interval_v2_ms;if(this.isBridge&&u>0&&(this.keepAliveTimer=setInterval(()=>{U(`[remote-io] keep_alive sent`),this.write({type:`keep_alive`}).catch(e=>{U(`[remote-io] keep_alive write failed: ${H(e)}`)})},u),this.keepAliveTimer.unref?.()),ar(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)&&K(ia(e)+`
@@ -16,8 +16,8 @@ import{a as e}from"./rolldown-runtime-DaDcL9Zw.js";import{c as t,l as n,o as r,s
16
16
  `);break;case`stream-json`:break;default:if(!C||C.type!==`result`)throw Error(`No messages returned`);switch(C.subtype){case`success`:K(C.result.endsWith(`
17
17
  `)?C.result:C.result+`
18
18
  `);break;case`error_during_execution`:K(`Execution error`);break;case`error_max_turns`:K(`Error: Reached max turns (${c.maxTurns}).\nTip: Increase the limit with --max-turns or continue in a new session.`);break;case`error_max_budget_usd`:K(`Error: Exceeded USD budget ($${c.maxBudgetUsd}).\nTip: Increase the limit with --max-budget-usd or start a new session to continue.`);break;case`error_max_structured_output_retries`:K(`Error: Failed to provide valid structured output after maximum retries.
19
- Tip: Simplify your schema or check if the output format matches the expected structure.`)}}if(Ie(),gr())try{let{drainPendingExtraction:e}=await import(`./extractMemories-CXGZGe0h.js`);await e()}catch{}V(C?.type===`result`&&C?.is_error?1:0)}function Ja(e,r,a,o,d,f,p,g,_,ee,v,y){let b=!1,x,S=!1,w=null,T,E=e.outbound;process.on(`SIGINT`,()=>{br(`info`,`shutdown_signal`,{signal:`SIGINT`}),T&&!T.signal.aborted&&T.abort(),Pn(0)}),ar(async()=>{let t={};for(let e of ye(g()))Ye(e)&&(t[e.type]=(t[e.type]??0)+1);br(`info`,`run_state_at_shutdown`,{run_active:b,run_phase:x,worker_status:Oi(),internal_events_pending:e.internalEventsPending,bg_tasks:t})}),wi(e=>{(e==="default"||e===`acceptEdits`||e===`bypassPermissions`||e===`plan`||e===`auto`||e===`dontAsk`)&&E.enqueue({type:`system`,subtype:`status`,status:null,permissionMode:e,uuid:Y(),session_id:m()})});let D={abortController:null,inflightPromise:null,lastEmitted:null,pendingSuggestion:null,pendingLastEmittedEntry:null},ae;v.enableAuthStatus&&(ae=Lr.getInstance().subscribe(e=>{E.enqueue({type:`auth_status`,isAuthenticating:e.isAuthenticating,output:e.output,error:e.error,uuid:Y(),session_id:m()})}));let oe=e=>{let t=Li(e);t&&E.enqueue({type:`rate_limit_event`,rate_limit_info:t,uuid:Y(),session_id:m()})};de.add(oe);let O=d,k=te(d,X(),100),le=pi(100),fe=process.env.CLAUDE_CODE_RESUME_INTERRUPTED_TURN;y&&y.kind!==`none`&&fe&&(U(`[print.ts] Auto-resuming interrupted turn (kind: ${y.kind})`),to(O,y.message),Ue({mode:`prompt`,value:y.message.message.content,uuid:Y()}));let pe=$t().map(e=>{let t=e.value===null?`default`:e.value,n=t==="default"?Yr():Nr(t),r=Me(n),i=ue(n),a=Vr(e.value),o=Ir(n);return{name:t,value:t,displayName:e.label,description:e.description,...r&&{supportsEffort:!0,supportedEffortLevels:se(n)?[...re]:re.filter(e=>e!==`max`)},...i&&{supportsAdaptiveThinking:!0},...a&&{supportsFastMode:!0},...o&&{supportsAutoMode:!0}}}),_e=v.userSpecifiedModel;function ve(e,t){let n=Vt(e,ei(t));O.push(...n);for(let e of n)typeof e.message.content==`string`&&e.message.content.includes(`<local-command-stdout>`)&&E.enqueue({type:`user`,content:e.message.content,message:e.message,session_id:m(),parent_tool_use_id:null,uuid:e.uuid,timestamp:e.timestamp,isReplay:!0})}let j=[],Se=[],we=new Set;function Ee(t){for(let n of t){if(n.type!==`connected`||we.has(n.name)||n.config.type===`sdk`)continue;let t=n.name;try{n.client.setRequestHandler(he,async(n,r)=>{Tr(t,`Elicitation request received in print mode: ${W(n)}`);let i=n.params.mode===`url`?`url`:`form`;J(`tengu_mcp_elicitation_shown`,{mode:i});let a=await ct(t,n.params,r.signal);if(a)return Tr(t,`Elicitation resolved by hook: ${W(a)}`),J(`tengu_mcp_elicitation_response`,{mode:i,action:a.action}),a;let o=`url`in n.params?n.params.url:void 0,s=`requestedSchema`in n.params?n.params.requestedSchema:void 0,c=`elicitationId`in n.params?n.params.elicitationId:void 0,l=await e.handleElicitation(t,n.params.message,s,r.signal,i,o,c),u=await Ln(t,l,r.signal,i,c);return J(`tengu_mcp_elicitation_response`,{mode:i,action:u.action}),u}),n.client.setNotificationHandler($e,e=>{let{elicitationId:n}=e.params;Tr(t,`Elicitation completion notification: ${n}`),Ke({message:`MCP server "${t}" confirmed elicitation ${n} complete`,notificationType:`elicitation_complete`}),E.enqueue({type:`system`,subtype:`elicitation_complete`,mcp_server_name:t,elicitation_id:n,uuid:Y(),session_id:m()})}),we.add(t)}catch{}}}async function De(){let t=new Set(Object.keys(p)),n=new Set(j.map(e=>e.name)),r=Array.from(t).some(e=>!n.has(e)),i=Array.from(n).some(e=>!t.has(e)),a=j.some(e=>e.type===`pending`),o=j.some(e=>e.type===`failed`);if(r||i||a||o){for(let e of j)t.has(e.name)||e.type===`connected`&&await e.cleanup();let r=await un(p,(t,n)=>e.sendMcpMessage(t,n));j=r.clients,Se=r.tools;let i=hr([...n,...t]);_(e=>({...e,mcp:{...e.mcp,tools:[...e.mcp.tools.filter(e=>!i.some(t=>e.name.startsWith(G(t)))),...Se]}})),ut(j)}}De();let M={clients:[],tools:[],configs:{}},Oe=e=>{let t=xe(e.toolPermissionContext,e.mcp.tools),n=Te(sa([...o,...Se,...M.tools],t,e.toolPermissionContext.mode),`name`);v.permissionPromptToolName&&(n=n.filter(e=>!ii(e,v.permissionPromptToolName)));let r=c();if(r&&!v.jsonSchema){let e=ui(r);`tool`in e&&(n=[...n,e.tool])}return n},N=null,Ae=0;function je(){if(!N)return;let e=Math.min(Ae,O.length),t=O.slice(e).filter(e=>e.type===`user`||e.type===`assistant`);Ae=O.length,t.length>0&&N.writeMessages(t)}let Ne=Promise.resolve({response:{added:[],removed:[],errors:{}},sdkServersChanged:!1});function Pe(e){let t=async()=>{let t=new Set(j.map(e=>e.name)),n=await oo(e,{configs:p,clients:j,tools:Se},M,_);for(let e of Object.keys(p))delete p[e];if(Object.assign(p,n.newSdkState.configs),j=n.newSdkState.clients,Se=n.newSdkState.tools,M=n.newDynamicState,n.sdkServersChanged){let e=new Set(j.map(e=>e.name)),n=hr([...t,...e]);_(e=>({...e,mcp:{...e.mcp,tools:[...e.mcp.tools.filter(e=>!n.some(t=>e.name.startsWith(G(t)))),...Se]}}))}return{response:n.response,sdkServersChanged:n.sdkServersChanged}};return Ne=Ne.then(t,t),Ne}function Fe(){let e=g(),t=e.mcp.clients,n=Te([...e.mcp.tools,...M.tools],`name`),r=new Set([...t.map(e=>e.name),...j.map(e=>e.name)]);return[...t,...j,...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`?tn(n,e.name).map(e=>({name:e.mcpInfo?.toolName??e.name,annotations:{readOnly:e.isReadOnly({})||void 0,destructive:e.isDestructive?.({})||void 0,openWorld:e.isOpenWorld?.({})||void 0}})):void 0;return{name:e.name,status:e.type,serverInfo:e.type===`connected`?e.serverInfo:void 0,error:e.type===`failed`?e.error:void 0,config:t,scope:e.config.scope,tools:r}})}async function Le(){try{await Promise.all([Promise.resolve(),xr(`headless_managed_settings_wait`,()=>Yi())]),await za()&&await Ge()}catch(e){q(e)}}let Re=null;i()||(n(process.env.CLAUDE_CODE_SYNC_PLUGIN_INSTALL)?Re=Le():Le());let Ve=Ma(()=>!b),P=a,F=ee;async function We(){let{agentDefinitions:e}=await va(_);P=await Tn(X());let t=F.filter(e=>e.source===`flagSettings`);F=[...e.allAgents,...t]}async function Ge(){let{servers:e}=await C(),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(p))n.type===`sdk`&&!(e in t)&&(t[e]=n);let{response:n,sdkServersChanged:r}=await Pe(t);r&&De(),U(`Headless MCP refresh: added=${n.added.length}, removed=${n.removed.length}`)}let qe=_a.subscribe(()=>{Xe(),Tn(X()).then(e=>{P=e})}),Je=()=>{setTimeout(()=>{!$?.isProactiveActive()||$.isProactivePaused()||S||(async()=>{let e=await hn({basePrompt:`<${Cr}>${new Date().toLocaleTimeString()}</${Cr}>`,currentDir:X(),shouldCreate:()=>!S});if(S){await fn({commands:e});return}for(let t of e)Ue({...t,uuid:Y()});I()})().catch(e=>{q(e),U(`[Proactive] failed to create headless tick: ${e}`,{level:`error`})})},0)};Be(()=>{T&&ne(`now`).length>0&&T.abort(`interrupt`)});let I=async()=>{if(b)return;if(b=!0,x=void 0,Ti(`running`),Ve.stop(),z(`run_entry`),await De(),z(`after_updateSdkMcp`),Re){let e=parseInt(process.env.CLAUDE_CODE_SYNC_PLUGIN_INSTALL_TIMEOUT_MS||``,10);if(e>0){let t=ni(e).then(()=>`timeout`);await Promise.race([Re,t])===`timeout`&&(q(Error(`CLAUDE_CODE_SYNC_PLUGIN_INSTALL: plugin installation timed out after ${e}ms`)),J(`tengu_sync_plugin_install_timeout`,{timeout_ms:e}))}else await Re;Re=null,await We();let{setupPluginHookHotReload:t}=await import(`./loadPluginHooks-s7bvGtns.js`);t()}let n=e=>e.agentId===void 0;try{let r,i=!1,a=async()=>{for(;r=ie(n);){if(r.mode!==`prompt`&&r.mode!==`orphaned-permission`&&r.mode!==`task-notification`)throw Error(`only prompt commands are supported in streaming mode`);let i=[r];if(r.mode===`prompt`)for(;Ka(r,ce(n));)i.push(ie(n));let a=await On(i);if(i=a.attachmentCommands,i.length===0)continue;r=i[0],r.mode===`prompt`&&i.length>1&&(r={...r,value:Ga(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&&E.enqueue({type:`user`,content:e.value,message:{role:`user`,content:e.value},session_id:m(),parent_tool_use_id:null,uuid:e.uuid,isReplay:!0});let s=g(),l=[...s.mcp.clients,...j,...M.clients];Ee(l);let u=Oe(s);for(let e of o)At(e,`started`);if(r.mode===`task-notification`){let e=typeof r.value==`string`?r.value:``,t=e.match(/<task-id>([^<]+)<\/task-id>/),n=e.match(/<tool-use-id>([^<]+)<\/tool-use-id>/),i=e.match(/<output-file>([^<]+)<\/output-file>/),a=e.match(/<status>([^<]+)<\/status>/),o=e.match(/<summary>([^<]+)<\/summary>/),s=e=>e===`completed`||e===`failed`||e===`stopped`||e===`killed`,c=a?.[1],l=s(c)?c===`killed`?`stopped`:c:`completed`,u=e.match(/<usage>([\s\S]*?)<\/usage>/)?.[1]??``,d=u.match(/<total_tokens>(\d+)<\/total_tokens>/),f=u.match(/<tool_uses>(\d+)<\/tool_uses>/),p=u.match(/<duration_ms>(\d+)<\/duration_ms>/);a&&E.enqueue({type:`system`,subtype:`task_notification`,task_id:t?.[1]??``,tool_use_id:n?.[1],status:l,output_file:i?.[1]??``,summary:o?.[1]??``,usage:d&&f?{total_tokens:parseInt(d[1],10),tool_uses:parseInt(f[1],10),duration_ms:p?parseInt(p[1],10):0}:void 0,session_id:m(),uuid:Y()})}let d=r.value,p=a.claimedCommands;if(e instanceof Da&&r.mode===`prompt`&&J(`tengu_bridge_message_received`,{is_repl:!1}),D.abortController?.abort(),D.abortController=null,D.pendingSuggestion=null,D.pendingLastEmittedEntry=null,D.lastEmitted&&r.mode===`prompt`){let e=typeof d==`string`?d:d.find(e=>e.type===`text`)?.text;typeof e==`string`&&Lt(D.lastEmitted.text,e,D.lastEmitted.emittedAt,D.lastEmitted.promptId,D.lastEmitted.generationRequestId),D.lastEmitted=null}T=ge(),z(`before_ask`),Fn();let h=r,ee=!1;try{if(await Hr(h.workload??v.workload,async()=>{for await(let t of la({commands:Te([...P,...s.mcp.commands],`name`),prompt:d,promptUuid:h.uuid,isMeta:h.isMeta,cwd:X(),tools:u,verbose:v.verbose,mcpClients:l,thinkingConfig:v.thinkingConfig,maxTurns:v.maxTurns,maxBudgetUsd:v.maxBudgetUsd,taskBudget:v.taskBudget,canUseTool:f,userSpecifiedModel:_e,fallbackModel:v.fallbackModel,jsonSchema:c()??v.jsonSchema,mutableMessages:O,getReadFileCache:()=>le.size===0?k:hi(k,le),setReadFileCache:e=>{k=e;for(let[e,t]of le.entries()){let n=k.get(e);(!n||t.timestamp>n.timestamp)&&k.set(e,t)}le.clear()},customSystemPrompt:v.systemPrompt,appendSystemPrompt:v.appendSystemPrompt,getAppState:g,setAppState:_,abortController:T,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:F,orphanedPermission:h.orphanedPermission,setSDKStatus:e=>{E.enqueue({type:`system`,subtype:`status`,status:e,session_id:m(),uuid:Y()})}}))if(je(),t.type===`result`){ee=!!t.is_error;for(let e of gi())E.enqueue(e);ye(g()).some(e=>(e.type===`local_agent`||e.type===`local_workflow`)&&Ye(e))?w=t:(w=null,E.enqueue(t))}else{for(let e of gi())E.enqueue(e);E.enqueue(t)}}),ee)await Kt({commands:p,outcome:{type:`failed`,message:`ask() returned an error result`},currentDir:X(),priority:`later`,workload:h.workload??v.workload});else{let e=await Kt({commands:p,outcome:{type:`completed`},currentDir:X(),priority:`later`,workload:h.workload??v.workload});for(let t of e)Ue({...t,uuid:Y()})}}catch(e){throw await Kt({commands:p,outcome:{type:`failed`,error:e},currentDir:X(),priority:`later`,workload:h.workload??v.workload}),e}for(let e of o)At(e,`completed`);if(je(),N?.sendResult(),v.promptSuggestions&&!t(process.env.CLAUDE_CODE_ENABLE_PROMPT_SUGGESTION)){D.abortController?.abort();let e=new AbortController;D.abortController=e;let t=an();if(!t)Sn(`sdk_no_params`,void 0,void 0,`sdk`);else{let n={promise:null};n.promise=(async()=>{try{let n=await Gt(e,O,g,t,`sdk`);if(!n||e.signal.aborted)return;let r={type:`prompt_suggestion`,suggestion:n.suggestion,uuid:Y(),session_id:m()},i={text:n.suggestion,emittedAt:Date.now(),promptId:n.promptId,generationRequestId:n.generationRequestId};w?(D.pendingSuggestion=r,D.pendingLastEmittedEntry={text:i.text,promptId:i.promptId,generationRequestId:i.generationRequestId}):(D.lastEmitted=i,E.enqueue(r))}catch(e){if(e instanceof Error&&(e.name===`AbortError`||e.name===`APIUserAbortError`)){Sn(`aborted`,void 0,void 0,`sdk`);return}q($n(e))}finally{D.inflightPromise===n.promise&&(D.inflightPromise=null)}})(),D.inflightPromise=n.promise}}Ie(),Tt(),nt()}};do{for(let e of gi())E.enqueue(e);x=`draining_commands`,await a(),i=!1;{let e=ye(g()).some(e=>Ye(e)),t=ce(n)!==void 0;(e||t)&&(i=!0,t||(x=`waiting_for_agents`,await ni(100)))}}while(i);w&&(E.enqueue(w),w=null,D.pendingSuggestion&&(E.enqueue(D.pendingSuggestion),D.pendingLastEmittedEntry&&(D.lastEmitted={...D.pendingLastEmittedEntry,emittedAt:Date.now()},D.pendingLastEmittedEntry=null),D.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:m(),total_cost_usd:0,usage:Ei,modelUsage:{},permission_denials:[],uuid:Y(),errors:[H(t),...Er().map(e=>e.error)]})}catch{}D.abortController?.abort(),V(1);return}finally{if(x=`finally_flush`,await e.flushInternalEvents(),x=`finally_post_flush`,!vn()){Ti(`idle`);for(let e of gi())E.enqueue(e)}b=!1,Ve.start()}if($?.isProactiveActive()&&!$.isProactivePaused()&&ce(n)===void 0&&!S){Je();return}if(ce(n)!==void 0){I();return}S&&(D.inflightPromise&&await Promise.race([D.inflightPromise,ni(5e3)]),D.abortController?.abort(),D.abortController=null,await ke(),qe(),ae?.(),de.delete(oe),E.done())},L=function(e,t){E.enqueue({type:`control_response`,response:{subtype:`success`,request_id:e.request_id,response:t}})},R=function(e,t){E.enqueue({type:`control_response`,response:{subtype:`error`,request_id:e.request_id,error:t}})},Ze=new Set;e.setUnexpectedResponseCallback(async e=>{await io({message:e,setAppState:_,handledToolUseIds:Ze,onEnqueued:()=>{I()}})});let tt=new Map,rt=new Map,it=new Set,at=new Map,B=null;return(async()=>{let t=!1;br(`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`&&At(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}})),T&&T.abort(),D.abortController?.abort(),D.abortController=null,D.lastEmitted=null,D.pendingSuggestion=null,L(i);else if(o.subtype===`end_session`){U(`[print.ts] end_session received, reason=${o.reason??`unspecified`}`),T&&T.abort(),D.abortController?.abort(),D.abortController=null,D.lastEmitted=null,D.pendingSuggestion=null,L(i);break}else if(i.request.subtype===`initialize`){if(i.request.sdkMcpServers&&i.request.sdkMcpServers.length>0)for(let e of i.request.sdkMcpServers)p[e]={type:`sdk`,name:e};await Za(i.request,i.request_id,t,E,a,pe,e,!!v.enableAuthStatus,v,ee,g),i.request.promptSuggestions&&_(e=>e.promptSuggestionEnabled?e:{...e,promptSuggestionEnabled:!0}),i.request.agentProgressSummaries&&h(!0),t=!0,Qt()&&I()}else if(i.request.subtype===`set_permission_mode`){let e=i.request;_(t=>({...t,toolPermissionContext:$a(e,i.request_id,t.toolPermissionContext,E),isUltraplanMode:e.ultraplan??t.isUltraplanMode}))}else if(i.request.subtype===`set_model`){let e=i.request.model??`default`,t=e==="default"?Yr():e;_e=t,u(t),Di({model:t}),ve(e,t),L(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},L(i);else if(i.request.subtype===`mcp_status`)L(i,{mcpServers:Fe()});else if(i.request.subtype===`get_context_usage`)try{let e=g(),t=await pa({messages:O,getAppState:g,options:{mainLoopModel:Qr(),tools:Oe(e),agentDefinitions:e.agentDefinitions,customSystemPrompt:v.systemPrompt,appendSystemPrompt:v.appendSystemPrompt}});L(i,{...t})}catch(e){R(i,H(e))}else if(i.request.subtype===`mcp_message`){let e=i.request,t=j.find(t=>t.name===e.server_name);t&&t.type===`connected`&&t.client?.transport?.onmessage&&t.client.transport.onmessage(e.message),L(i)}else if(i.request.subtype===`rewind_files`){let e=g(),t=await Qa(i.request.user_message_id,e,_,i.request.dry_run??!1);t.canRewind||i.request.dry_run?L(i,t):R(i,t.error??`Unexpected error`)}else if(i.request.subtype===`cancel_async_message`){let e=i.request.message_uuid,t=zn(t=>t.uuid===e);L(i,{cancelled:t.length>0})}else if(i.request.subtype===`seed_read_state`){try{let e=kr(i.request.path),t=Math.floor((await wa(e)).mtimeMs);if(t<=i.request.mtime){let n=await Ca(e,`utf-8`),r=(n.charCodeAt(0)===65279?n.slice(1):n).replaceAll(`\r
19
+ Tip: Simplify your schema or check if the output format matches the expected structure.`)}}if(Ie(),gr())try{let{drainPendingExtraction:e}=await import(`./extractMemories-C3qrwpu2.js`);await e()}catch{}V(C?.type===`result`&&C?.is_error?1:0)}function Ja(e,r,a,o,d,f,p,g,_,ee,v,y){let b=!1,x,S=!1,w=null,T,E=e.outbound;process.on(`SIGINT`,()=>{br(`info`,`shutdown_signal`,{signal:`SIGINT`}),T&&!T.signal.aborted&&T.abort(),Pn(0)}),ar(async()=>{let t={};for(let e of ye(g()))Ye(e)&&(t[e.type]=(t[e.type]??0)+1);br(`info`,`run_state_at_shutdown`,{run_active:b,run_phase:x,worker_status:Oi(),internal_events_pending:e.internalEventsPending,bg_tasks:t})}),wi(e=>{(e==="default"||e===`acceptEdits`||e===`bypassPermissions`||e===`plan`||e===`auto`||e===`dontAsk`)&&E.enqueue({type:`system`,subtype:`status`,status:null,permissionMode:e,uuid:Y(),session_id:m()})});let D={abortController:null,inflightPromise:null,lastEmitted:null,pendingSuggestion:null,pendingLastEmittedEntry:null},ae;v.enableAuthStatus&&(ae=Lr.getInstance().subscribe(e=>{E.enqueue({type:`auth_status`,isAuthenticating:e.isAuthenticating,output:e.output,error:e.error,uuid:Y(),session_id:m()})}));let oe=e=>{let t=Li(e);t&&E.enqueue({type:`rate_limit_event`,rate_limit_info:t,uuid:Y(),session_id:m()})};de.add(oe);let O=d,k=te(d,X(),100),le=pi(100),fe=process.env.CLAUDE_CODE_RESUME_INTERRUPTED_TURN;y&&y.kind!==`none`&&fe&&(U(`[print.ts] Auto-resuming interrupted turn (kind: ${y.kind})`),to(O,y.message),Ue({mode:`prompt`,value:y.message.message.content,uuid:Y()}));let pe=$t().map(e=>{let t=e.value===null?`default`:e.value,n=t==="default"?Yr():Nr(t),r=Me(n),i=ue(n),a=Vr(e.value),o=Ir(n);return{name:t,value:t,displayName:e.label,description:e.description,...r&&{supportsEffort:!0,supportedEffortLevels:se(n)?[...re]:re.filter(e=>e!==`max`)},...i&&{supportsAdaptiveThinking:!0},...a&&{supportsFastMode:!0},...o&&{supportsAutoMode:!0}}}),_e=v.userSpecifiedModel;function ve(e,t){let n=Vt(e,ei(t));O.push(...n);for(let e of n)typeof e.message.content==`string`&&e.message.content.includes(`<local-command-stdout>`)&&E.enqueue({type:`user`,content:e.message.content,message:e.message,session_id:m(),parent_tool_use_id:null,uuid:e.uuid,timestamp:e.timestamp,isReplay:!0})}let j=[],Se=[],we=new Set;function Ee(t){for(let n of t){if(n.type!==`connected`||we.has(n.name)||n.config.type===`sdk`)continue;let t=n.name;try{n.client.setRequestHandler(he,async(n,r)=>{Tr(t,`Elicitation request received in print mode: ${W(n)}`);let i=n.params.mode===`url`?`url`:`form`;J(`tengu_mcp_elicitation_shown`,{mode:i});let a=await ct(t,n.params,r.signal);if(a)return Tr(t,`Elicitation resolved by hook: ${W(a)}`),J(`tengu_mcp_elicitation_response`,{mode:i,action:a.action}),a;let o=`url`in n.params?n.params.url:void 0,s=`requestedSchema`in n.params?n.params.requestedSchema:void 0,c=`elicitationId`in n.params?n.params.elicitationId:void 0,l=await e.handleElicitation(t,n.params.message,s,r.signal,i,o,c),u=await Ln(t,l,r.signal,i,c);return J(`tengu_mcp_elicitation_response`,{mode:i,action:u.action}),u}),n.client.setNotificationHandler($e,e=>{let{elicitationId:n}=e.params;Tr(t,`Elicitation completion notification: ${n}`),Ke({message:`MCP server "${t}" confirmed elicitation ${n} complete`,notificationType:`elicitation_complete`}),E.enqueue({type:`system`,subtype:`elicitation_complete`,mcp_server_name:t,elicitation_id:n,uuid:Y(),session_id:m()})}),we.add(t)}catch{}}}async function De(){let t=new Set(Object.keys(p)),n=new Set(j.map(e=>e.name)),r=Array.from(t).some(e=>!n.has(e)),i=Array.from(n).some(e=>!t.has(e)),a=j.some(e=>e.type===`pending`),o=j.some(e=>e.type===`failed`);if(r||i||a||o){for(let e of j)t.has(e.name)||e.type===`connected`&&await e.cleanup();let r=await un(p,(t,n)=>e.sendMcpMessage(t,n));j=r.clients,Se=r.tools;let i=hr([...n,...t]);_(e=>({...e,mcp:{...e.mcp,tools:[...e.mcp.tools.filter(e=>!i.some(t=>e.name.startsWith(G(t)))),...Se]}})),ut(j)}}De();let M={clients:[],tools:[],configs:{}},Oe=e=>{let t=xe(e.toolPermissionContext,e.mcp.tools),n=Te(sa([...o,...Se,...M.tools],t,e.toolPermissionContext.mode),`name`);v.permissionPromptToolName&&(n=n.filter(e=>!ii(e,v.permissionPromptToolName)));let r=c();if(r&&!v.jsonSchema){let e=ui(r);`tool`in e&&(n=[...n,e.tool])}return n},N=null,Ae=0;function je(){if(!N)return;let e=Math.min(Ae,O.length),t=O.slice(e).filter(e=>e.type===`user`||e.type===`assistant`);Ae=O.length,t.length>0&&N.writeMessages(t)}let Ne=Promise.resolve({response:{added:[],removed:[],errors:{}},sdkServersChanged:!1});function Pe(e){let t=async()=>{let t=new Set(j.map(e=>e.name)),n=await oo(e,{configs:p,clients:j,tools:Se},M,_);for(let e of Object.keys(p))delete p[e];if(Object.assign(p,n.newSdkState.configs),j=n.newSdkState.clients,Se=n.newSdkState.tools,M=n.newDynamicState,n.sdkServersChanged){let e=new Set(j.map(e=>e.name)),n=hr([...t,...e]);_(e=>({...e,mcp:{...e.mcp,tools:[...e.mcp.tools.filter(e=>!n.some(t=>e.name.startsWith(G(t)))),...Se]}}))}return{response:n.response,sdkServersChanged:n.sdkServersChanged}};return Ne=Ne.then(t,t),Ne}function Fe(){let e=g(),t=e.mcp.clients,n=Te([...e.mcp.tools,...M.tools],`name`),r=new Set([...t.map(e=>e.name),...j.map(e=>e.name)]);return[...t,...j,...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`?tn(n,e.name).map(e=>({name:e.mcpInfo?.toolName??e.name,annotations:{readOnly:e.isReadOnly({})||void 0,destructive:e.isDestructive?.({})||void 0,openWorld:e.isOpenWorld?.({})||void 0}})):void 0;return{name:e.name,status:e.type,serverInfo:e.type===`connected`?e.serverInfo:void 0,error:e.type===`failed`?e.error:void 0,config:t,scope:e.config.scope,tools:r}})}async function Le(){try{await Promise.all([Promise.resolve(),xr(`headless_managed_settings_wait`,()=>Yi())]),await za()&&await Ge()}catch(e){q(e)}}let Re=null;i()||(n(process.env.CLAUDE_CODE_SYNC_PLUGIN_INSTALL)?Re=Le():Le());let Ve=Ma(()=>!b),P=a,F=ee;async function We(){let{agentDefinitions:e}=await va(_);P=await Tn(X());let t=F.filter(e=>e.source===`flagSettings`);F=[...e.allAgents,...t]}async function Ge(){let{servers:e}=await C(),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(p))n.type===`sdk`&&!(e in t)&&(t[e]=n);let{response:n,sdkServersChanged:r}=await Pe(t);r&&De(),U(`Headless MCP refresh: added=${n.added.length}, removed=${n.removed.length}`)}let qe=_a.subscribe(()=>{Xe(),Tn(X()).then(e=>{P=e})}),Je=()=>{setTimeout(()=>{!$?.isProactiveActive()||$.isProactivePaused()||S||(async()=>{let e=await hn({basePrompt:`<${Cr}>${new Date().toLocaleTimeString()}</${Cr}>`,currentDir:X(),shouldCreate:()=>!S});if(S){await fn({commands:e});return}for(let t of e)Ue({...t,uuid:Y()});I()})().catch(e=>{q(e),U(`[Proactive] failed to create headless tick: ${e}`,{level:`error`})})},0)};Be(()=>{T&&ne(`now`).length>0&&T.abort(`interrupt`)});let I=async()=>{if(b)return;if(b=!0,x=void 0,Ti(`running`),Ve.stop(),z(`run_entry`),await De(),z(`after_updateSdkMcp`),Re){let e=parseInt(process.env.CLAUDE_CODE_SYNC_PLUGIN_INSTALL_TIMEOUT_MS||``,10);if(e>0){let t=ni(e).then(()=>`timeout`);await Promise.race([Re,t])===`timeout`&&(q(Error(`CLAUDE_CODE_SYNC_PLUGIN_INSTALL: plugin installation timed out after ${e}ms`)),J(`tengu_sync_plugin_install_timeout`,{timeout_ms:e}))}else await Re;Re=null,await We();let{setupPluginHookHotReload:t}=await import(`./loadPluginHooks-C9A9oS-w.js`);t()}let n=e=>e.agentId===void 0;try{let r,i=!1,a=async()=>{for(;r=ie(n);){if(r.mode!==`prompt`&&r.mode!==`orphaned-permission`&&r.mode!==`task-notification`)throw Error(`only prompt commands are supported in streaming mode`);let i=[r];if(r.mode===`prompt`)for(;Ka(r,ce(n));)i.push(ie(n));let a=await On(i);if(i=a.attachmentCommands,i.length===0)continue;r=i[0],r.mode===`prompt`&&i.length>1&&(r={...r,value:Ga(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&&E.enqueue({type:`user`,content:e.value,message:{role:`user`,content:e.value},session_id:m(),parent_tool_use_id:null,uuid:e.uuid,isReplay:!0});let s=g(),l=[...s.mcp.clients,...j,...M.clients];Ee(l);let u=Oe(s);for(let e of o)At(e,`started`);if(r.mode===`task-notification`){let e=typeof r.value==`string`?r.value:``,t=e.match(/<task-id>([^<]+)<\/task-id>/),n=e.match(/<tool-use-id>([^<]+)<\/tool-use-id>/),i=e.match(/<output-file>([^<]+)<\/output-file>/),a=e.match(/<status>([^<]+)<\/status>/),o=e.match(/<summary>([^<]+)<\/summary>/),s=e=>e===`completed`||e===`failed`||e===`stopped`||e===`killed`,c=a?.[1],l=s(c)?c===`killed`?`stopped`:c:`completed`,u=e.match(/<usage>([\s\S]*?)<\/usage>/)?.[1]??``,d=u.match(/<total_tokens>(\d+)<\/total_tokens>/),f=u.match(/<tool_uses>(\d+)<\/tool_uses>/),p=u.match(/<duration_ms>(\d+)<\/duration_ms>/);a&&E.enqueue({type:`system`,subtype:`task_notification`,task_id:t?.[1]??``,tool_use_id:n?.[1],status:l,output_file:i?.[1]??``,summary:o?.[1]??``,usage:d&&f?{total_tokens:parseInt(d[1],10),tool_uses:parseInt(f[1],10),duration_ms:p?parseInt(p[1],10):0}:void 0,session_id:m(),uuid:Y()})}let d=r.value,p=a.claimedCommands;if(e instanceof Da&&r.mode===`prompt`&&J(`tengu_bridge_message_received`,{is_repl:!1}),D.abortController?.abort(),D.abortController=null,D.pendingSuggestion=null,D.pendingLastEmittedEntry=null,D.lastEmitted&&r.mode===`prompt`){let e=typeof d==`string`?d:d.find(e=>e.type===`text`)?.text;typeof e==`string`&&Lt(D.lastEmitted.text,e,D.lastEmitted.emittedAt,D.lastEmitted.promptId,D.lastEmitted.generationRequestId),D.lastEmitted=null}T=ge(),z(`before_ask`),Fn();let h=r,ee=!1;try{if(await Hr(h.workload??v.workload,async()=>{for await(let t of la({commands:Te([...P,...s.mcp.commands],`name`),prompt:d,promptUuid:h.uuid,isMeta:h.isMeta,cwd:X(),tools:u,verbose:v.verbose,mcpClients:l,thinkingConfig:v.thinkingConfig,maxTurns:v.maxTurns,maxBudgetUsd:v.maxBudgetUsd,taskBudget:v.taskBudget,canUseTool:f,userSpecifiedModel:_e,fallbackModel:v.fallbackModel,jsonSchema:c()??v.jsonSchema,mutableMessages:O,getReadFileCache:()=>le.size===0?k:hi(k,le),setReadFileCache:e=>{k=e;for(let[e,t]of le.entries()){let n=k.get(e);(!n||t.timestamp>n.timestamp)&&k.set(e,t)}le.clear()},customSystemPrompt:v.systemPrompt,appendSystemPrompt:v.appendSystemPrompt,getAppState:g,setAppState:_,abortController:T,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:F,orphanedPermission:h.orphanedPermission,setSDKStatus:e=>{E.enqueue({type:`system`,subtype:`status`,status:e,session_id:m(),uuid:Y()})}}))if(je(),t.type===`result`){ee=!!t.is_error;for(let e of gi())E.enqueue(e);ye(g()).some(e=>(e.type===`local_agent`||e.type===`local_workflow`)&&Ye(e))?w=t:(w=null,E.enqueue(t))}else{for(let e of gi())E.enqueue(e);E.enqueue(t)}}),ee)await Kt({commands:p,outcome:{type:`failed`,message:`ask() returned an error result`},currentDir:X(),priority:`later`,workload:h.workload??v.workload});else{let e=await Kt({commands:p,outcome:{type:`completed`},currentDir:X(),priority:`later`,workload:h.workload??v.workload});for(let t of e)Ue({...t,uuid:Y()})}}catch(e){throw await Kt({commands:p,outcome:{type:`failed`,error:e},currentDir:X(),priority:`later`,workload:h.workload??v.workload}),e}for(let e of o)At(e,`completed`);if(je(),N?.sendResult(),v.promptSuggestions&&!t(process.env.CLAUDE_CODE_ENABLE_PROMPT_SUGGESTION)){D.abortController?.abort();let e=new AbortController;D.abortController=e;let t=an();if(!t)Sn(`sdk_no_params`,void 0,void 0,`sdk`);else{let n={promise:null};n.promise=(async()=>{try{let n=await Gt(e,O,g,t,`sdk`);if(!n||e.signal.aborted)return;let r={type:`prompt_suggestion`,suggestion:n.suggestion,uuid:Y(),session_id:m()},i={text:n.suggestion,emittedAt:Date.now(),promptId:n.promptId,generationRequestId:n.generationRequestId};w?(D.pendingSuggestion=r,D.pendingLastEmittedEntry={text:i.text,promptId:i.promptId,generationRequestId:i.generationRequestId}):(D.lastEmitted=i,E.enqueue(r))}catch(e){if(e instanceof Error&&(e.name===`AbortError`||e.name===`APIUserAbortError`)){Sn(`aborted`,void 0,void 0,`sdk`);return}q($n(e))}finally{D.inflightPromise===n.promise&&(D.inflightPromise=null)}})(),D.inflightPromise=n.promise}}Ie(),Tt(),nt()}};do{for(let e of gi())E.enqueue(e);x=`draining_commands`,await a(),i=!1;{let e=ye(g()).some(e=>Ye(e)),t=ce(n)!==void 0;(e||t)&&(i=!0,t||(x=`waiting_for_agents`,await ni(100)))}}while(i);w&&(E.enqueue(w),w=null,D.pendingSuggestion&&(E.enqueue(D.pendingSuggestion),D.pendingLastEmittedEntry&&(D.lastEmitted={...D.pendingLastEmittedEntry,emittedAt:Date.now()},D.pendingLastEmittedEntry=null),D.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:m(),total_cost_usd:0,usage:Ei,modelUsage:{},permission_denials:[],uuid:Y(),errors:[H(t),...Er().map(e=>e.error)]})}catch{}D.abortController?.abort(),V(1);return}finally{if(x=`finally_flush`,await e.flushInternalEvents(),x=`finally_post_flush`,!vn()){Ti(`idle`);for(let e of gi())E.enqueue(e)}b=!1,Ve.start()}if($?.isProactiveActive()&&!$.isProactivePaused()&&ce(n)===void 0&&!S){Je();return}if(ce(n)!==void 0){I();return}S&&(D.inflightPromise&&await Promise.race([D.inflightPromise,ni(5e3)]),D.abortController?.abort(),D.abortController=null,await ke(),qe(),ae?.(),de.delete(oe),E.done())},L=function(e,t){E.enqueue({type:`control_response`,response:{subtype:`success`,request_id:e.request_id,response:t}})},R=function(e,t){E.enqueue({type:`control_response`,response:{subtype:`error`,request_id:e.request_id,error:t}})},Ze=new Set;e.setUnexpectedResponseCallback(async e=>{await io({message:e,setAppState:_,handledToolUseIds:Ze,onEnqueued:()=>{I()}})});let tt=new Map,rt=new Map,it=new Set,at=new Map,B=null;return(async()=>{let t=!1;br(`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`&&At(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}})),T&&T.abort(),D.abortController?.abort(),D.abortController=null,D.lastEmitted=null,D.pendingSuggestion=null,L(i);else if(o.subtype===`end_session`){U(`[print.ts] end_session received, reason=${o.reason??`unspecified`}`),T&&T.abort(),D.abortController?.abort(),D.abortController=null,D.lastEmitted=null,D.pendingSuggestion=null,L(i);break}else if(i.request.subtype===`initialize`){if(i.request.sdkMcpServers&&i.request.sdkMcpServers.length>0)for(let e of i.request.sdkMcpServers)p[e]={type:`sdk`,name:e};await Za(i.request,i.request_id,t,E,a,pe,e,!!v.enableAuthStatus,v,ee,g),i.request.promptSuggestions&&_(e=>e.promptSuggestionEnabled?e:{...e,promptSuggestionEnabled:!0}),i.request.agentProgressSummaries&&h(!0),t=!0,Qt()&&I()}else if(i.request.subtype===`set_permission_mode`){let e=i.request;_(t=>({...t,toolPermissionContext:$a(e,i.request_id,t.toolPermissionContext,E),isUltraplanMode:e.ultraplan??t.isUltraplanMode}))}else if(i.request.subtype===`set_model`){let e=i.request.model??`default`,t=e==="default"?Yr():e;_e=t,u(t),Di({model:t}),ve(e,t),L(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},L(i);else if(i.request.subtype===`mcp_status`)L(i,{mcpServers:Fe()});else if(i.request.subtype===`get_context_usage`)try{let e=g(),t=await pa({messages:O,getAppState:g,options:{mainLoopModel:Qr(),tools:Oe(e),agentDefinitions:e.agentDefinitions,customSystemPrompt:v.systemPrompt,appendSystemPrompt:v.appendSystemPrompt}});L(i,{...t})}catch(e){R(i,H(e))}else if(i.request.subtype===`mcp_message`){let e=i.request,t=j.find(t=>t.name===e.server_name);t&&t.type===`connected`&&t.client?.transport?.onmessage&&t.client.transport.onmessage(e.message),L(i)}else if(i.request.subtype===`rewind_files`){let e=g(),t=await Qa(i.request.user_message_id,e,_,i.request.dry_run??!1);t.canRewind||i.request.dry_run?L(i,t):R(i,t.error??`Unexpected error`)}else if(i.request.subtype===`cancel_async_message`){let e=i.request.message_uuid,t=zn(t=>t.uuid===e);L(i,{cancelled:t.length>0})}else if(i.request.subtype===`seed_read_state`){try{let e=kr(i.request.path),t=Math.floor((await wa(e)).mtimeMs);if(t<=i.request.mtime){let n=await Ca(e,`utf-8`),r=(n.charCodeAt(0)===65279?n.slice(1):n).replaceAll(`\r
20
20
  `,`
21
- `);le.set(e,{content:r,timestamp:t,offset:void 0,limit:void 0})}}catch{}L(i)}else if(i.request.subtype===`mcp_set_servers`){let{response:e,sdkServersChanged:t}=await Pe(i.request.servers);L(i,e),t&&De()}else if(i.request.subtype===`reload_plugins`)try{let e=await va(_),t=F.filter(e=>e.source===`flagSettings`);F=[...e.agentDefinitions.allAgents,...t];let n=[],[r,a,o]=await Promise.allSettled([Tn(X()),Ge(),dn()]);r.status===`fulfilled`?P=r.value:q(r.reason),a.status===`rejected`&&q(a.reason),o.status===`fulfilled`?n=o.value.enabled.map(e=>({name:e.name,path:e.path,source:e.source})):q(o.reason),L(i,{commands:P.filter(e=>e.userInvocable!==!1).map(e=>({name:bt(e),description:Qe(e),argumentHint:e.argumentHint||``})),agents:F.map(e=>({name:e.agentType,description:e.whenToUse,model:e.model===`inherit`?void 0:e.model})),plugins:n,mcpServers:Fe(),error_count:e.error_count})}catch(e){R(i,H(e))}else if(i.request.subtype===`mcp_reconnect`){let e=g(),{serverName:t}=i.request;we.delete(t);let n=me(t)??r.find(e=>e.name===t)?.config??j.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)R(i,`Server not found: ${t}`);else{let e=await bn(t,n),r=G(t);if(_(n=>({...n,mcp:{...n.mcp,clients:n.mcp.clients.map(n=>n.name===t?e.client:n),tools:[...A(n.mcp.tools,e=>e.name?.startsWith(r)),...e.tools],commands:[...A(n.mcp.commands,e=>Wn(e,t)),...e.commands],resources:e.resources&&e.resources.length>0?{...n.mcp.resources,[t]:e.resources}:di(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`)Ee([e.client]),L(i);else{let t=e.client.type===`failed`?e.client.error??`Connection failed`:`Server status: ${e.client.type}`;R(i,t)}}}else if(i.request.subtype===`mcp_toggle`){let e=g(),{serverName:t,enabled:n}=i.request;we.delete(t);let a=me(t)??r.find(e=>e.name===t)?.config??j.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)R(i,`Server not found: ${t}`);else if(n){et(t,!0);let e=await bn(t,a),n=G(t);if(_(r=>({...r,mcp:{...r.mcp,clients:r.mcp.clients.map(n=>n.name===t?e.client:n),tools:[...A(r.mcp.tools,e=>e.name?.startsWith(n)),...e.tools],commands:[...A(r.mcp.commands,e=>Wn(e,t)),...e.commands],resources:e.resources&&e.resources.length>0?{...r.mcp.resources,[t]:e.resources}:di(r.mcp.resources,t)}})),e.client.type===`connected`)Ee([e.client]),L(i);else{let t=e.client.type===`failed`?e.client.error??`Connection failed`:`Server status: ${e.client.type}`;R(i,t)}}else{et(t,!1);let n=[...r,...j,...M.clients,...e.mcp.clients].find(e=>e.name===t);n&&n.type===`connected`&&await Jt(t,a);let o=G(t);_(e=>({...e,mcp:{...e.mcp,clients:e.mcp.clients.map(e=>e.name===t?{name:t,type:`disabled`,config:a}:e),tools:A(e.mcp.tools,e=>e.name?.startsWith(o)),commands:A(e.mcp.commands,e=>Wn(e,t)),resources:di(e.mcp.resources,t)}})),L(i)}}else if(o.subtype===`mcp_authenticate`){let e=o.serverName,t=g(),n=me(e)??r.find(t=>t.name===e)?.config??t.mcp.clients.find(t=>t.name===e)?.config??null;if(!n)R(i,`Server not found: ${e}`);else if(n.type!==`sse`&&n.type!==`http`)R(i,`Server type "${n.type}" does not support OAuth authentication`);else try{tt.get(e)?.abort();let t=new AbortController;tt.set(e,t);let r,a=new Promise(e=>{r=e}),o=qt(e,n,e=>r(e),t.signal,{skipBrowserOpen:!0,onWaitingForCallback:t=>{rt.set(e,t)}}),s=await Promise.race([a,o.then(()=>null)]);s?L(i,{authUrl:s,requiresUserAction:!0}):L(i,{requiresUserAction:!1}),at.set(e,o),o.then(async()=>{if(be(e)||it.has(e))return;let t=await bn(e,n),r=G(e);_(n=>({...n,mcp:{...n.mcp,clients:n.mcp.clients.map(n=>n.name===e?t.client:n),tools:[...A(n.mcp.tools,e=>e.name?.startsWith(r)),...t.tools],commands:[...A(n.mcp.commands,t=>Wn(t,e)),...t.commands],resources:t.resources&&t.resources.length>0?{...n.mcp.resources,[e]:t.resources}:di(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=>{U(`MCP OAuth failed for ${e}: ${t}`,{level:`error`})}).finally(()=>{tt.get(e)===t&&(tt.delete(e),rt.delete(e),it.delete(e),at.delete(e))})}catch(e){R(i,H(e))}}else if(o.subtype===`mcp_oauth_callback_url`){let e=o.serverName,t=o.callbackUrl,n=rt.get(e);if(n){let r=!1;try{let e=new URL(t);r=e.searchParams.has(`code`)||e.searchParams.has(`error`)}catch{}if(!r)R(i,`Invalid callback URL: missing authorization code. Please paste the full redirect URL including the code parameter.`);else{it.add(e),n(t);let r=at.get(e);if(r)try{await r,L(i)}catch(e){R(i,e instanceof Error?e.message:`OAuth authentication failed`)}else L(i)}}else R(i,`No active OAuth flow for server: ${e}`)}else if(o.subtype===`claude_authenticate`){let e=o.loginWithClaudeAi;B?.service.cleanup(),J(`tengu_oauth_flow_start`,{loginWithClaudeAi:e??!0});let t=new Xi,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 Zi(t),J(`tengu_oauth_success`,{loginWithClaudeAi:e??!0})}).finally(()=>{t.cleanup(),B?.service===t&&(B=null)});B={service:t,flow:a},a.catch(e=>U(`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`)})]);L(i,{manualUrl:e,automaticUrl:t})}catch(e){R(i,H(e))}}else if(o.subtype===`claude_oauth_callback`||o.subtype===`claude_oauth_wait_for_completion`)if(!B)R(i,`No active claude_authenticate flow`);else{o.subtype===`claude_oauth_callback`&&B.service.handleManualAuthCodeInput({authorizationCode:o.authorizationCode,state:o.state});let{flow:e}=B;e.then(()=>{let e=ti();L(i,{account:{email:e?.email,organization:e?.organization,subscriptionType:e?.subscription,tokenSource:e?.tokenSource,apiKeySource:e?.apiKeySource,apiProvider:Wr()}})},e=>R(i,H(e)))}else if(o.subtype===`mcp_clear_auth`){let e=o.serverName,t=g(),n=me(e)??r.find(t=>t.name===e)?.config??t.mcp.clients.find(t=>t.name===e)?.config??null;if(!n)R(i,`Server not found: ${e}`);else if(n.type!==`sse`&&n.type!==`http`)R(i,`Cannot clear auth for server type "${n.type}"`);else{await gn(e,n);let t=await bn(e,n),r=G(e);_(n=>({...n,mcp:{...n.mcp,clients:n.mcp.clients.map(n=>n.name===e?t.client:n),tools:[...A(n.mcp.tools,e=>e.name?.startsWith(r)),...t.tools],commands:[...A(n.mcp.commands,t=>Wn(t,e)),...t.commands],resources:t.resources&&t.resources.length>0?{...n.mcp.resources,[e]:t.resources}:di(n.mcp.resources,e)}})),L(i,{})}}else if(i.request.subtype===`apply_flag_settings`){let e=Qr(),t=s()??{},n=i.request.settings,r={...t,...n};for(let e of Object.keys(r))r[e]===null&&delete r[e];l(r),He.notifyChange(`flagSettings`),`model`in n&&(n.model==null?u(void 0):u(String(n.model)));let a=Qr();if(a!==e){_e=a;let e=n.model?String(n.model):`default`;Di({model:a}),ve(e,a)}L(i)}else if(i.request.subtype===`get_settings`){let e=g(),t=Qr(),n=Me(t)?ze(t,e.effortValue):void 0;L(i,{...dr(),applied:{model:t,effort:typeof n==`string`?n:null}})}else if(i.request.subtype===`stop_task`){let{task_id:e}=i.request;try{await sn(e,{getAppState:g,setAppState:_}),L(i,{})}catch(e){R(i,H(e))}}else if(o.subtype===`generate_session_title`){let e=o.description,t=o.persist,n=(T&&!T.signal.aborted?T:ge()).signal;(async()=>{try{let r=await Ri(e,n);if(r&&t)try{lt(m(),r)}catch(e){q(e)}L(i,{title:r})}catch(e){R(i,H(e))}})()}else if(o.subtype===`side_question`){let e=o.question;(async()=>{try{let t=an(),n=t?{...t,toolUseContext:{...t.toolUseContext,abortController:ge()}}:await ua({tools:Oe(g()),commands:P,mcpClients:[...g().mcp.clients,...j,...M.clients],messages:O,readFileState:k,getAppState:g,setAppState:_,customSystemPrompt:v.systemPrompt,appendSystemPrompt:v.appendSystemPrompt,thinkingConfig:v.thinkingConfig,agents:F}),r=await fa({question:e,cacheSafeParams:n});L(i,{response:r.response})}catch(e){R(i,H(e))}})()}else if(i.request.subtype===`set_proactive`)i.request.enabled?$.isProactiveActive()||($.activateProactive(`command`),Je()):$.deactivateProactive(),L(i);else if(o.subtype===`remote_control`)if(o.enabled)if(N)L(i,{session_url:Ce(N.bridgeSessionId,N.sessionIngressUrl),connect_url:cn(N.environmentId,N.sessionIngressUrl),environment_id:N.environmentId});else{let t;try{let{initReplBridge:n}=await import(`./initReplBridge-GH3-LHF4.js`),r=await n({onInboundMessage(e){let t=aa(e);if(!t)return;let{content:n,uuid:r}=t;Ue({value:n,mode:`prompt`,uuid:r,skipSlashCommands:!0}),I()},onPermissionResponse(t){e.injectControlResponse(t)},onInterrupt(){T?.abort()},onSetModel(e){let t=e==="default"?Yr():e;_e=t,u(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),U(`[bridge:sdk] State change: ${e}${n?` — ${n}`:``}`),E.enqueue({type:`system`,subtype:`bridge_state`,state:e,detail:n,uuid:Y(),session_id:m()})},initialMessages:O.length>0?O:void 0});r?(N=r,Ae=O.length,e.setOnControlRequestSent(e=>{r.sendControlRequest(e)}),e.setOnControlRequestResolved(e=>{r.sendControlCancelRequest(e)}),L(i,{session_url:Ce(r.bridgeSessionId,r.sessionIngressUrl),connect_url:cn(r.environmentId,r.sessionIngressUrl),environment_id:r.environmentId})):R(i,t??`Remote Control initialization failed`)}catch(e){R(i,H(e))}}else N&&(e.setOnControlRequestSent(void 0),e.setOnControlRequestResolved(void 0),await N.teardown(),N=null),L(i);else R(i,`Unsupported control request subtype: ${i.request.subtype}`);continue}else if(n.type===`control_response`){v.replayUserMessages&&E.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=Fi([n]);O.push(...e),n.type===`assistant`&&v.replayUserMessages&&E.enqueue(n);continue}if(n.type!==`user`)continue;let o=n;if(t=!0,o.uuid){let e=m(),t=await Yt(e,o.uuid);if(t||Va.has(o.uuid)){U(`Skipping duplicate user message: ${o.uuid}`),v.replayUserMessages&&(U(`Sending acknowledgment for duplicate user message: ${o.uuid}`),E.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&&At(o.uuid,`completed`);continue}Ua(o.uuid)}Ue({mode:`prompt`,value:await Pi(o,o.message.content),uuid:o.uuid,priority:o.priority}),_(e=>({...e,attribution:ji(e.attribution,e=>{jt(e).catch(e=>{U(`Attribution: Failed to save snapshot: ${e}`)})})})),I()}S=!0,b||(D.inflightPromise&&await Promise.race([D.inflightPromise,ni(5e3)]),D.abortController?.abort(),D.abortController=null,await ke(),qe(),ae?.(),de.delete(oe),E.done())})(),E}function Ya(e){let t=async(n,r,i,a,o,s)=>{let c=s??await R(n,r,i,a,o);if(c.behavior===`allow`||c.behavior===`deny`)return c;let{signal:l,cleanup:u}=D(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 na(oa().parse(jr(h.content[0].text)),e,r,i)};return t}function Xa(e,t,n,r){if(e===`stdio`)return t.createCanUseTool(r);if(!e)return async(e,t,n,r,i,a)=>a??await R(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=>ii(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`),V(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`),V(1),Error(t)}i=Ya(r)}return i(t,r,a,o,s,c)}}async function Za(e,t,n,r,i,a,o,s,c,l,p){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=Mt(e.agents,`flagSettings`);l.push(...t)}if(c.agent){let e=f()===c.agent,t=l.find(e=>e.agentType===c.agent);if(t&&!e){if(d(t.agentType),!c.systemPrompt&&!An(t)){let e=t.getSystemPrompt();e&&(c.systemPrompt=e)}!c.userSpecifiedModel&&t.model&&t.model!==`inherit`&&u(Nr(t.model)),t.initialPrompt&&o.prependUserMessage(t.initialPrompt)}else t?.initialPrompt&&o.prependUserMessage(t.initialPrompt)}let h=fr()?.outputStyle||`default`,ee=await pt(Xn()),v=ti();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}});_(t)}e.jsonSchema&&g(e.jsonSchema);let te={commands:i.filter(e=>e.userInvocable!==!1).map(e=>({name:bt(e),description:Qe(e),argumentHint:e.argumentHint||``})),agents:l.map(e=>({name:e.agentType,description:e.whenToUse,model:e.model===`inherit`?void 0:e.model})),output_style:h,available_output_styles:Object.keys(ee),models:a,account:{email:v?.email,organization:v?.organization,subscriptionType:v?.subscription,tokenSource:v?.tokenSource,apiKeySource:v?.apiKeySource,apiProvider:Wr()},pid:process.pid};if(Gr()&&Jr()){let e=p();te.fast_mode_state=zr(c.userSpecifiedModel??null,e.fastMode)}if(r.enqueue({type:`control_response`,response:{subtype:`success`,request_id:t,response:te}}),s){let e=Lr.getInstance().getStatus();e&&r.enqueue({type:`auth_status`,isAuthenticating:e.isAuthenticating,output:e.output,error:e.error,uuid:Y(),session_id:m()})}}async function Qa(e,t,n,r){if(!E())return{canRewind:!1,error:`File rewinding is not enabled.`,filesChanged:[]};if(!Ve(t.fileHistory,e))return{canRewind:!1,error:`No file checkpoint found for this message.`,filesChanged:[]};if(r){let n=await Bn(t.fileHistory,e);return{canRewind:!0,filesChanged:n?.filesChanged??[],insertions:n?.insertions,deletions:n?.deletions}}try{await N(e=>n(t=>({...t,fileHistory:e(t.fileHistory)})),e)}catch(e){return{canRewind:!1,error:`Failed to rewind: ${H(e)}`,filesChanged:[]}}return{canRewind:!0,filesChanged:[]}}function $a(e,t,n,r){if(e.mode===`bypassPermissions`){if(ae())return r.enqueue({type:`control_response`,response:{subtype:`error`,request_id:t,error:`Cannot set permission mode to bypassPermissions because it is disabled by settings or configuration`}}),n;if(!n.isBypassPermissionsModeAvailable)return r.enqueue({type:`control_response`,response:{subtype:`error`,request_id:t,error:`Cannot set permission mode to bypassPermissions because the session was not launched with --dangerously-skip-permissions`}}),n}if(e.mode===`auto`&&!oe()){let e=Hn();return r.enqueue({type:`control_response`,response:{subtype:`error`,request_id:t,error:e?`Cannot set permission mode to auto: ${gt(e)}`:`Cannot set permission mode to auto`}}),n}return r.enqueue({type:`control_response`,response:{subtype:`success`,request_id:t,response:{mode:e.mode}}}),{...je(n.mode,e.mode,n),mode:e.mode}}function eo(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:m(),total_cost_usd:0,usage:Ei,modelUsage:{},permission_denials:[],uuid:Y(),errors:[e]};process.stdout.write(W(t)+`
21
+ `);le.set(e,{content:r,timestamp:t,offset:void 0,limit:void 0})}}catch{}L(i)}else if(i.request.subtype===`mcp_set_servers`){let{response:e,sdkServersChanged:t}=await Pe(i.request.servers);L(i,e),t&&De()}else if(i.request.subtype===`reload_plugins`)try{let e=await va(_),t=F.filter(e=>e.source===`flagSettings`);F=[...e.agentDefinitions.allAgents,...t];let n=[],[r,a,o]=await Promise.allSettled([Tn(X()),Ge(),dn()]);r.status===`fulfilled`?P=r.value:q(r.reason),a.status===`rejected`&&q(a.reason),o.status===`fulfilled`?n=o.value.enabled.map(e=>({name:e.name,path:e.path,source:e.source})):q(o.reason),L(i,{commands:P.filter(e=>e.userInvocable!==!1).map(e=>({name:bt(e),description:Qe(e),argumentHint:e.argumentHint||``})),agents:F.map(e=>({name:e.agentType,description:e.whenToUse,model:e.model===`inherit`?void 0:e.model})),plugins:n,mcpServers:Fe(),error_count:e.error_count})}catch(e){R(i,H(e))}else if(i.request.subtype===`mcp_reconnect`){let e=g(),{serverName:t}=i.request;we.delete(t);let n=me(t)??r.find(e=>e.name===t)?.config??j.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)R(i,`Server not found: ${t}`);else{let e=await bn(t,n),r=G(t);if(_(n=>({...n,mcp:{...n.mcp,clients:n.mcp.clients.map(n=>n.name===t?e.client:n),tools:[...A(n.mcp.tools,e=>e.name?.startsWith(r)),...e.tools],commands:[...A(n.mcp.commands,e=>Wn(e,t)),...e.commands],resources:e.resources&&e.resources.length>0?{...n.mcp.resources,[t]:e.resources}:di(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`)Ee([e.client]),L(i);else{let t=e.client.type===`failed`?e.client.error??`Connection failed`:`Server status: ${e.client.type}`;R(i,t)}}}else if(i.request.subtype===`mcp_toggle`){let e=g(),{serverName:t,enabled:n}=i.request;we.delete(t);let a=me(t)??r.find(e=>e.name===t)?.config??j.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)R(i,`Server not found: ${t}`);else if(n){et(t,!0);let e=await bn(t,a),n=G(t);if(_(r=>({...r,mcp:{...r.mcp,clients:r.mcp.clients.map(n=>n.name===t?e.client:n),tools:[...A(r.mcp.tools,e=>e.name?.startsWith(n)),...e.tools],commands:[...A(r.mcp.commands,e=>Wn(e,t)),...e.commands],resources:e.resources&&e.resources.length>0?{...r.mcp.resources,[t]:e.resources}:di(r.mcp.resources,t)}})),e.client.type===`connected`)Ee([e.client]),L(i);else{let t=e.client.type===`failed`?e.client.error??`Connection failed`:`Server status: ${e.client.type}`;R(i,t)}}else{et(t,!1);let n=[...r,...j,...M.clients,...e.mcp.clients].find(e=>e.name===t);n&&n.type===`connected`&&await Jt(t,a);let o=G(t);_(e=>({...e,mcp:{...e.mcp,clients:e.mcp.clients.map(e=>e.name===t?{name:t,type:`disabled`,config:a}:e),tools:A(e.mcp.tools,e=>e.name?.startsWith(o)),commands:A(e.mcp.commands,e=>Wn(e,t)),resources:di(e.mcp.resources,t)}})),L(i)}}else if(o.subtype===`mcp_authenticate`){let e=o.serverName,t=g(),n=me(e)??r.find(t=>t.name===e)?.config??t.mcp.clients.find(t=>t.name===e)?.config??null;if(!n)R(i,`Server not found: ${e}`);else if(n.type!==`sse`&&n.type!==`http`)R(i,`Server type "${n.type}" does not support OAuth authentication`);else try{tt.get(e)?.abort();let t=new AbortController;tt.set(e,t);let r,a=new Promise(e=>{r=e}),o=qt(e,n,e=>r(e),t.signal,{skipBrowserOpen:!0,onWaitingForCallback:t=>{rt.set(e,t)}}),s=await Promise.race([a,o.then(()=>null)]);s?L(i,{authUrl:s,requiresUserAction:!0}):L(i,{requiresUserAction:!1}),at.set(e,o),o.then(async()=>{if(be(e)||it.has(e))return;let t=await bn(e,n),r=G(e);_(n=>({...n,mcp:{...n.mcp,clients:n.mcp.clients.map(n=>n.name===e?t.client:n),tools:[...A(n.mcp.tools,e=>e.name?.startsWith(r)),...t.tools],commands:[...A(n.mcp.commands,t=>Wn(t,e)),...t.commands],resources:t.resources&&t.resources.length>0?{...n.mcp.resources,[e]:t.resources}:di(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=>{U(`MCP OAuth failed for ${e}: ${t}`,{level:`error`})}).finally(()=>{tt.get(e)===t&&(tt.delete(e),rt.delete(e),it.delete(e),at.delete(e))})}catch(e){R(i,H(e))}}else if(o.subtype===`mcp_oauth_callback_url`){let e=o.serverName,t=o.callbackUrl,n=rt.get(e);if(n){let r=!1;try{let e=new URL(t);r=e.searchParams.has(`code`)||e.searchParams.has(`error`)}catch{}if(!r)R(i,`Invalid callback URL: missing authorization code. Please paste the full redirect URL including the code parameter.`);else{it.add(e),n(t);let r=at.get(e);if(r)try{await r,L(i)}catch(e){R(i,e instanceof Error?e.message:`OAuth authentication failed`)}else L(i)}}else R(i,`No active OAuth flow for server: ${e}`)}else if(o.subtype===`claude_authenticate`){let e=o.loginWithClaudeAi;B?.service.cleanup(),J(`tengu_oauth_flow_start`,{loginWithClaudeAi:e??!0});let t=new Xi,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 Zi(t),J(`tengu_oauth_success`,{loginWithClaudeAi:e??!0})}).finally(()=>{t.cleanup(),B?.service===t&&(B=null)});B={service:t,flow:a},a.catch(e=>U(`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`)})]);L(i,{manualUrl:e,automaticUrl:t})}catch(e){R(i,H(e))}}else if(o.subtype===`claude_oauth_callback`||o.subtype===`claude_oauth_wait_for_completion`)if(!B)R(i,`No active claude_authenticate flow`);else{o.subtype===`claude_oauth_callback`&&B.service.handleManualAuthCodeInput({authorizationCode:o.authorizationCode,state:o.state});let{flow:e}=B;e.then(()=>{let e=ti();L(i,{account:{email:e?.email,organization:e?.organization,subscriptionType:e?.subscription,tokenSource:e?.tokenSource,apiKeySource:e?.apiKeySource,apiProvider:Wr()}})},e=>R(i,H(e)))}else if(o.subtype===`mcp_clear_auth`){let e=o.serverName,t=g(),n=me(e)??r.find(t=>t.name===e)?.config??t.mcp.clients.find(t=>t.name===e)?.config??null;if(!n)R(i,`Server not found: ${e}`);else if(n.type!==`sse`&&n.type!==`http`)R(i,`Cannot clear auth for server type "${n.type}"`);else{await gn(e,n);let t=await bn(e,n),r=G(e);_(n=>({...n,mcp:{...n.mcp,clients:n.mcp.clients.map(n=>n.name===e?t.client:n),tools:[...A(n.mcp.tools,e=>e.name?.startsWith(r)),...t.tools],commands:[...A(n.mcp.commands,t=>Wn(t,e)),...t.commands],resources:t.resources&&t.resources.length>0?{...n.mcp.resources,[e]:t.resources}:di(n.mcp.resources,e)}})),L(i,{})}}else if(i.request.subtype===`apply_flag_settings`){let e=Qr(),t=s()??{},n=i.request.settings,r={...t,...n};for(let e of Object.keys(r))r[e]===null&&delete r[e];l(r),He.notifyChange(`flagSettings`),`model`in n&&(n.model==null?u(void 0):u(String(n.model)));let a=Qr();if(a!==e){_e=a;let e=n.model?String(n.model):`default`;Di({model:a}),ve(e,a)}L(i)}else if(i.request.subtype===`get_settings`){let e=g(),t=Qr(),n=Me(t)?ze(t,e.effortValue):void 0;L(i,{...dr(),applied:{model:t,effort:typeof n==`string`?n:null}})}else if(i.request.subtype===`stop_task`){let{task_id:e}=i.request;try{await sn(e,{getAppState:g,setAppState:_}),L(i,{})}catch(e){R(i,H(e))}}else if(o.subtype===`generate_session_title`){let e=o.description,t=o.persist,n=(T&&!T.signal.aborted?T:ge()).signal;(async()=>{try{let r=await Ri(e,n);if(r&&t)try{lt(m(),r)}catch(e){q(e)}L(i,{title:r})}catch(e){R(i,H(e))}})()}else if(o.subtype===`side_question`){let e=o.question;(async()=>{try{let t=an(),n=t?{...t,toolUseContext:{...t.toolUseContext,abortController:ge()}}:await ua({tools:Oe(g()),commands:P,mcpClients:[...g().mcp.clients,...j,...M.clients],messages:O,readFileState:k,getAppState:g,setAppState:_,customSystemPrompt:v.systemPrompt,appendSystemPrompt:v.appendSystemPrompt,thinkingConfig:v.thinkingConfig,agents:F}),r=await fa({question:e,cacheSafeParams:n});L(i,{response:r.response})}catch(e){R(i,H(e))}})()}else if(i.request.subtype===`set_proactive`)i.request.enabled?$.isProactiveActive()||($.activateProactive(`command`),Je()):$.deactivateProactive(),L(i);else if(o.subtype===`remote_control`)if(o.enabled)if(N)L(i,{session_url:Ce(N.bridgeSessionId,N.sessionIngressUrl),connect_url:cn(N.environmentId,N.sessionIngressUrl),environment_id:N.environmentId});else{let t;try{let{initReplBridge:n}=await import(`./initReplBridge-myzllvlk.js`),r=await n({onInboundMessage(e){let t=aa(e);if(!t)return;let{content:n,uuid:r}=t;Ue({value:n,mode:`prompt`,uuid:r,skipSlashCommands:!0}),I()},onPermissionResponse(t){e.injectControlResponse(t)},onInterrupt(){T?.abort()},onSetModel(e){let t=e==="default"?Yr():e;_e=t,u(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),U(`[bridge:sdk] State change: ${e}${n?` — ${n}`:``}`),E.enqueue({type:`system`,subtype:`bridge_state`,state:e,detail:n,uuid:Y(),session_id:m()})},initialMessages:O.length>0?O:void 0});r?(N=r,Ae=O.length,e.setOnControlRequestSent(e=>{r.sendControlRequest(e)}),e.setOnControlRequestResolved(e=>{r.sendControlCancelRequest(e)}),L(i,{session_url:Ce(r.bridgeSessionId,r.sessionIngressUrl),connect_url:cn(r.environmentId,r.sessionIngressUrl),environment_id:r.environmentId})):R(i,t??`Remote Control initialization failed`)}catch(e){R(i,H(e))}}else N&&(e.setOnControlRequestSent(void 0),e.setOnControlRequestResolved(void 0),await N.teardown(),N=null),L(i);else R(i,`Unsupported control request subtype: ${i.request.subtype}`);continue}else if(n.type===`control_response`){v.replayUserMessages&&E.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=Fi([n]);O.push(...e),n.type===`assistant`&&v.replayUserMessages&&E.enqueue(n);continue}if(n.type!==`user`)continue;let o=n;if(t=!0,o.uuid){let e=m(),t=await Yt(e,o.uuid);if(t||Va.has(o.uuid)){U(`Skipping duplicate user message: ${o.uuid}`),v.replayUserMessages&&(U(`Sending acknowledgment for duplicate user message: ${o.uuid}`),E.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&&At(o.uuid,`completed`);continue}Ua(o.uuid)}Ue({mode:`prompt`,value:await Pi(o,o.message.content),uuid:o.uuid,priority:o.priority}),_(e=>({...e,attribution:ji(e.attribution,e=>{jt(e).catch(e=>{U(`Attribution: Failed to save snapshot: ${e}`)})})})),I()}S=!0,b||(D.inflightPromise&&await Promise.race([D.inflightPromise,ni(5e3)]),D.abortController?.abort(),D.abortController=null,await ke(),qe(),ae?.(),de.delete(oe),E.done())})(),E}function Ya(e){let t=async(n,r,i,a,o,s)=>{let c=s??await R(n,r,i,a,o);if(c.behavior===`allow`||c.behavior===`deny`)return c;let{signal:l,cleanup:u}=D(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 na(oa().parse(jr(h.content[0].text)),e,r,i)};return t}function Xa(e,t,n,r){if(e===`stdio`)return t.createCanUseTool(r);if(!e)return async(e,t,n,r,i,a)=>a??await R(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=>ii(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`),V(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`),V(1),Error(t)}i=Ya(r)}return i(t,r,a,o,s,c)}}async function Za(e,t,n,r,i,a,o,s,c,l,p){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=Mt(e.agents,`flagSettings`);l.push(...t)}if(c.agent){let e=f()===c.agent,t=l.find(e=>e.agentType===c.agent);if(t&&!e){if(d(t.agentType),!c.systemPrompt&&!An(t)){let e=t.getSystemPrompt();e&&(c.systemPrompt=e)}!c.userSpecifiedModel&&t.model&&t.model!==`inherit`&&u(Nr(t.model)),t.initialPrompt&&o.prependUserMessage(t.initialPrompt)}else t?.initialPrompt&&o.prependUserMessage(t.initialPrompt)}let h=fr()?.outputStyle||`default`,ee=await pt(Xn()),v=ti();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}});_(t)}e.jsonSchema&&g(e.jsonSchema);let te={commands:i.filter(e=>e.userInvocable!==!1).map(e=>({name:bt(e),description:Qe(e),argumentHint:e.argumentHint||``})),agents:l.map(e=>({name:e.agentType,description:e.whenToUse,model:e.model===`inherit`?void 0:e.model})),output_style:h,available_output_styles:Object.keys(ee),models:a,account:{email:v?.email,organization:v?.organization,subscriptionType:v?.subscription,tokenSource:v?.tokenSource,apiKeySource:v?.apiKeySource,apiProvider:Wr()},pid:process.pid};if(Gr()&&Jr()){let e=p();te.fast_mode_state=zr(c.userSpecifiedModel??null,e.fastMode)}if(r.enqueue({type:`control_response`,response:{subtype:`success`,request_id:t,response:te}}),s){let e=Lr.getInstance().getStatus();e&&r.enqueue({type:`auth_status`,isAuthenticating:e.isAuthenticating,output:e.output,error:e.error,uuid:Y(),session_id:m()})}}async function Qa(e,t,n,r){if(!E())return{canRewind:!1,error:`File rewinding is not enabled.`,filesChanged:[]};if(!Ve(t.fileHistory,e))return{canRewind:!1,error:`No file checkpoint found for this message.`,filesChanged:[]};if(r){let n=await Bn(t.fileHistory,e);return{canRewind:!0,filesChanged:n?.filesChanged??[],insertions:n?.insertions,deletions:n?.deletions}}try{await N(e=>n(t=>({...t,fileHistory:e(t.fileHistory)})),e)}catch(e){return{canRewind:!1,error:`Failed to rewind: ${H(e)}`,filesChanged:[]}}return{canRewind:!0,filesChanged:[]}}function $a(e,t,n,r){if(e.mode===`bypassPermissions`){if(ae())return r.enqueue({type:`control_response`,response:{subtype:`error`,request_id:t,error:`Cannot set permission mode to bypassPermissions because it is disabled by settings or configuration`}}),n;if(!n.isBypassPermissionsModeAvailable)return r.enqueue({type:`control_response`,response:{subtype:`error`,request_id:t,error:`Cannot set permission mode to bypassPermissions because the session was not launched with --dangerously-skip-permissions`}}),n}if(e.mode===`auto`&&!oe()){let e=Hn();return r.enqueue({type:`control_response`,response:{subtype:`error`,request_id:t,error:e?`Cannot set permission mode to auto: ${gt(e)}`:`Cannot set permission mode to auto`}}),n}return r.enqueue({type:`control_response`,response:{subtype:`success`,request_id:t,response:{mode:e.mode}}}),{...je(n.mode,e.mode,n),mode:e.mode}}function eo(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:m(),total_cost_usd:0,usage:Ei,modelUsage:{},permission_denials:[],uuid:Y(),errors:[e]};process.stdout.write(W(t)+`
22
22
  `)}else process.stderr.write(e+`
23
- `)}function to(e,t){let n=e.findIndex(e=>e.uuid===t.uuid);n!==-1&&e.splice(n,2)}async function no(e,t){let r=!ee();if(t.continue)try{J(`tengu_continue_print`,{});let n=await Dn(void 0,void 0);if(n)return t.forkSession||n.sessionId&&(v(pe(n.sessionId),n.fullPath?ba(n.fullPath):null),r&&await Ft()),ga(n,e),xn(t.forkSession?{...n,worktreeSession:void 0}:n),{messages:n.messages,turnInterruptionState:n.turnInterruptionState,agentSetting:n.agentSetting}}catch(e){return q(e),V(1),{messages:[]}}if(t.teleport)try{if(!We(`allow_remote_sessions`))throw Error(`Remote sessions are disabled by your organization's policy.`);if(J(`tengu_teleport_print`,{}),typeof t.teleport!=`string`)throw Error(`No session ID provided for teleport`);let{checkOutTeleportedSessionBranch:e,processMessagesForTeleportResume:n,teleportResumeCodeSession:r,validateGitState:i}=await import(`./teleport-dxtBcM01.js`);await i();let a=await r(t.teleport),{branchError:o}=await e(a.branch);return{messages:n(a.log,o)}}catch(e){return q(e),V(1),{messages:[]}}if(t.resume)try{J(`tengu_resume_print`,{});let i=Na(typeof t.resume==`string`?t.resume:``);if(!i){let e=`Error: --resume requires a valid session ID when used with --print. Usage: claude -p --resume <session-id>`;return typeof t.resume==`string`&&(e+=`. Session IDs must be in UUID format (e.g., 550e8400-e29b-41d4-a716-446655440000). Provided value "${t.resume}" is not a valid UUID`),eo(e,t.outputFormat),V(1),{messages:[]}}if(n(process.env.CLAUDE_CODE_USE_CCR_V2)){let[,n]=await Promise.all([on(i.sessionId),t.restoredWorkerState]);n&&(e($i(n)),typeof n.model==`string`&&u(n.model))}else i.isUrl&&i.ingressUrl&&n(process.env.ENABLE_SESSION_PERSISTENCE)&&await S(i.sessionId,i.ingressUrl);let a=await Dn(i.sessionId,i.jsonlFile||void 0);if(!a||a.messages.length===0)return i.isUrl||n(process.env.CLAUDE_CODE_USE_CCR_V2)?{messages:await(t.sessionStartHooksPromise??B(`startup`))}:(eo(`No conversation found with session ID: ${i.sessionId}`,t.outputFormat),V(1),{messages:[]});if(t.resumeSessionAt){let e=a.messages.findIndex(e=>e.uuid===t.resumeSessionAt);if(e<0)return eo(`No message found with message.uuid of: ${t.resumeSessionAt}`,t.outputFormat),V(1),{messages:[]};a.messages=e>=0?a.messages.slice(0,e+1):[]}return!t.forkSession&&a.sessionId&&(v(pe(a.sessionId),a.fullPath?ba(a.fullPath):null),r&&await Ft()),ga(a,e),xn(t.forkSession?{...a,worktreeSession:void 0}:a),{messages:a.messages,turnInterruptionState:a.turnInterruptionState,agentSetting:a.agentSetting}}catch(e){return q(e),eo(e instanceof Error?`Failed to resume session: ${e.message}`:`Failed to resume session with --print mode`,t.outputFormat),V(1),{messages:[]}}return{messages:await(t.sessionStartHooksPromise??B(`startup`))}}function ro(e,t){let n;return n=typeof e==`string`?e.trim()===``?Xt([]):Xt([W({type:`user`,content:e,uuid:``,session_id:``,message:{role:`user`,content:e},parent_tool_use_id:null})]):e,t.sdkUrl?new Da(t.sdkUrl,n,t.replayUserMessages):new ta(n,t.replayUserMessages)}async function io({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(U(`handleOrphanedPermissionResponse: received orphaned control_response for toolUseID=${t} request_id=${i.request_id}`),r.has(t))return U(`handleOrphanedPermissionResponse: skipping duplicate orphaned permission for toolUseID=${t} (already handled)`),!1;let a=await Ct(t);return a?(r.add(t),U(`handleOrphanedPermissionResponse: enqueuing orphaned permission for toolUseID=${t} messageID=${a.message.id}`),Ue({mode:`orphaned-permission`,value:[],orphanedPermission:{permissionResult:e,assistantMessage:a}}),n?.(),!0):(U(`handleOrphanedPermissionResponse: no unresolved tool_use found for toolUseID=${t} (already resolved in transcript)`),!1)}return!1}function ao(e){return{...e,scope:`dynamic`}}async function oo(e,t,n,r){let{allowed:i,blocked:a}=qn(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 so(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 so(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||!pn(r,ao(i))}),c=[],l=[],u={},d=[...t.clients],f=[...t.tools];for(let e of[...a,...s]){let n=d.find(t=>t.name===e),r=t.configs[e];if(n&&r){if(n.type===`connected`)try{await n.cleanup()}catch(e){q(e)}await Jt(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=ao(n);if(n.type===`sdk`){l.push(t);continue}try{let e=await ft(t,r);if(d.push(e),e.type===`connected`){let t=await St(e);f.push(...t)}else e.type===`failed`&&(u[t]=e.error||`Connection failed`);l.push(t)}catch(e){let n=$n(e);u[t]=n.message,q(n)}}let p={};for(let t of i){let n=e[t];n&&(p[t]=ao(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{qa as runHeadless};
23
+ `)}function to(e,t){let n=e.findIndex(e=>e.uuid===t.uuid);n!==-1&&e.splice(n,2)}async function no(e,t){let r=!ee();if(t.continue)try{J(`tengu_continue_print`,{});let n=await Dn(void 0,void 0);if(n)return t.forkSession||n.sessionId&&(v(pe(n.sessionId),n.fullPath?ba(n.fullPath):null),r&&await Ft()),ga(n,e),xn(t.forkSession?{...n,worktreeSession:void 0}:n),{messages:n.messages,turnInterruptionState:n.turnInterruptionState,agentSetting:n.agentSetting}}catch(e){return q(e),V(1),{messages:[]}}if(t.teleport)try{if(!We(`allow_remote_sessions`))throw Error(`Remote sessions are disabled by your organization's policy.`);if(J(`tengu_teleport_print`,{}),typeof t.teleport!=`string`)throw Error(`No session ID provided for teleport`);let{checkOutTeleportedSessionBranch:e,processMessagesForTeleportResume:n,teleportResumeCodeSession:r,validateGitState:i}=await import(`./teleport-4Srg5vcP.js`);await i();let a=await r(t.teleport),{branchError:o}=await e(a.branch);return{messages:n(a.log,o)}}catch(e){return q(e),V(1),{messages:[]}}if(t.resume)try{J(`tengu_resume_print`,{});let i=Na(typeof t.resume==`string`?t.resume:``);if(!i){let e=`Error: --resume requires a valid session ID when used with --print. Usage: claude -p --resume <session-id>`;return typeof t.resume==`string`&&(e+=`. Session IDs must be in UUID format (e.g., 550e8400-e29b-41d4-a716-446655440000). Provided value "${t.resume}" is not a valid UUID`),eo(e,t.outputFormat),V(1),{messages:[]}}if(n(process.env.CLAUDE_CODE_USE_CCR_V2)){let[,n]=await Promise.all([on(i.sessionId),t.restoredWorkerState]);n&&(e($i(n)),typeof n.model==`string`&&u(n.model))}else i.isUrl&&i.ingressUrl&&n(process.env.ENABLE_SESSION_PERSISTENCE)&&await S(i.sessionId,i.ingressUrl);let a=await Dn(i.sessionId,i.jsonlFile||void 0);if(!a||a.messages.length===0)return i.isUrl||n(process.env.CLAUDE_CODE_USE_CCR_V2)?{messages:await(t.sessionStartHooksPromise??B(`startup`))}:(eo(`No conversation found with session ID: ${i.sessionId}`,t.outputFormat),V(1),{messages:[]});if(t.resumeSessionAt){let e=a.messages.findIndex(e=>e.uuid===t.resumeSessionAt);if(e<0)return eo(`No message found with message.uuid of: ${t.resumeSessionAt}`,t.outputFormat),V(1),{messages:[]};a.messages=e>=0?a.messages.slice(0,e+1):[]}return!t.forkSession&&a.sessionId&&(v(pe(a.sessionId),a.fullPath?ba(a.fullPath):null),r&&await Ft()),ga(a,e),xn(t.forkSession?{...a,worktreeSession:void 0}:a),{messages:a.messages,turnInterruptionState:a.turnInterruptionState,agentSetting:a.agentSetting}}catch(e){return q(e),eo(e instanceof Error?`Failed to resume session: ${e.message}`:`Failed to resume session with --print mode`,t.outputFormat),V(1),{messages:[]}}return{messages:await(t.sessionStartHooksPromise??B(`startup`))}}function ro(e,t){let n;return n=typeof e==`string`?e.trim()===``?Xt([]):Xt([W({type:`user`,content:e,uuid:``,session_id:``,message:{role:`user`,content:e},parent_tool_use_id:null})]):e,t.sdkUrl?new Da(t.sdkUrl,n,t.replayUserMessages):new ta(n,t.replayUserMessages)}async function io({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(U(`handleOrphanedPermissionResponse: received orphaned control_response for toolUseID=${t} request_id=${i.request_id}`),r.has(t))return U(`handleOrphanedPermissionResponse: skipping duplicate orphaned permission for toolUseID=${t} (already handled)`),!1;let a=await Ct(t);return a?(r.add(t),U(`handleOrphanedPermissionResponse: enqueuing orphaned permission for toolUseID=${t} messageID=${a.message.id}`),Ue({mode:`orphaned-permission`,value:[],orphanedPermission:{permissionResult:e,assistantMessage:a}}),n?.(),!0):(U(`handleOrphanedPermissionResponse: no unresolved tool_use found for toolUseID=${t} (already resolved in transcript)`),!1)}return!1}function ao(e){return{...e,scope:`dynamic`}}async function oo(e,t,n,r){let{allowed:i,blocked:a}=qn(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 so(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 so(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||!pn(r,ao(i))}),c=[],l=[],u={},d=[...t.clients],f=[...t.tools];for(let e of[...a,...s]){let n=d.find(t=>t.name===e),r=t.configs[e];if(n&&r){if(n.type===`connected`)try{await n.cleanup()}catch(e){q(e)}await Jt(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=ao(n);if(n.type===`sdk`){l.push(t);continue}try{let e=await ft(t,r);if(d.push(e),e.type===`connected`){let t=await St(e);f.push(...t)}else e.type===`failed`&&(u[t]=e.error||`Connection failed`);l.push(t)}catch(e){let n=$n(e);u[t]=n.message,q(n)}}let p={};for(let t of i){let n=e[t];n&&(p[t]=ao(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{qa as runHeadless};
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{fi as t}from"./src-CDCSSo0U2.js";import{t as n}from"./jsx-runtime-Bb4Xn-E0.js";import{n as r,r as i}from"./analytics-BotDBGh0.js";import{a,i as o,o as s,r as c}from"./grove-BGXzEyH9.js";import{n as l,r as u,t as d}from"./Grove-D9lSG_Lh.js";async function f(e){if(!await s())return e(m),null;let[t,n]=await Promise.all([o(),c()]);if(!t.success)return e(m),null;let r=t.data,a=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 o();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:a?.domain_excluded,onDone:f})}var p,m;e((()=>{t(),u(),r(),a(),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"./rolldown-runtime-DaDcL9Zw.js";import{fi as t}from"./src-CDCSSo0U2.js";import{t as n}from"./jsx-runtime-Bb4Xn-E0.js";import{n as r,r as i}from"./analytics-BotDBGh0.js";import{a,i as o,o as s,r as c}from"./grove-CFBPplP6.js";import{n as l,r as u,t as d}from"./Grove-CD769Wvw.js";async function f(e){if(!await s())return e(m),null;let[t,n]=await Promise.all([o(),c()]);if(!t.success)return e(m),null;let r=t.data,a=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 o();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:a?.domain_excluded,onDone:f})}var p,m;e((()=>{t(),u(),r(),a(),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"./rolldown-runtime-DaDcL9Zw.js";import{I as t,fi as n,t as r}from"./src-CDCSSo0U2.js";import{t as i}from"./jsx-runtime-Bb4Xn-E0.js";import{Ap as a,GC as o,Hp as s,Jg as c,Jm as l,So as u,Vp as d,WC as f,Yg as p,Ym as m,Yo as h,_u as g,kp as _,vo as v,vu as y,xo as b,zo as x}from"./loadAgentsDir-DrDu5yYy.js";import{F as S,j as C,z as w}from"./debug-BrXObCdR.js";import{g as T,n as E}from"./settings-DfWP5y6X.js";import{n as D,r as O}from"./analytics-BotDBGh0.js";import{Ot as k,kt as A}from"./prompt-C0nU0VK3.js";import{randomUUID as j}from"crypto";n(),r(),y(),m(),s();var M=i();function N({input:e,progress:n,verbose:r}){return(0,M.jsxs)(t,{flexDirection:`column`,marginTop:1,children:[(0,M.jsx)(l,{addMargin:!1,param:{text:`<bash-input>${e}</bash-input>`,type:`text`}}),n?(0,M.jsx)(d,{fullOutput:n.fullOutput,output:n.output,elapsedTimeSeconds:n.elapsedTimeSeconds,totalLines:n.totalLines,verbose:r}):g.renderToolUseProgressMessage?.([],{verbose:r,tools:[],terminalSize:void 0})]})}w(),D(),c(),x(),T();function P(){return E().defaultShell??`bash`}y(),k(),o();async function F(t,n,r,i,o){let s=A()&&P()===`powershell`;O(`tengu_input_bash`,{powershell:s});let c=u({content:h({inputString:`<bash-input>${t}</bash-input>`,precedingInputBlocks:n})}),l;o({jsx:(0,M.jsx)(N,{input:t,progress:null,verbose:i.options.verbose}),shouldHidePromptInput:!1});try{let n={...i,setToolJSX:e=>{l=e?.jsx}},d=e=>{o({jsx:(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(N,{input:t,progress:e.data,verbose:i.options.verbose}),l]}),shouldHidePromptInput:!1,showSpinner:!1})},m=null;s&&(m=(a(),e(_)).PowerShellTool);let h=m??g,y=(m?await m.call({command:t,dangerouslyDisableSandbox:!0},n,void 0,void 0,d):await g.call({command:t,dangerouslyDisableSandbox:!0},n,void 0,void 0,d)).data;if(!y)throw Error(`No result received from shell command`);let b=y.stderr,x=await p(h,{...y,stderr:``},j()),S=typeof x.content==`string`?x.content:f(y.stdout);return{messages:[v(),c,...r,u({content:`<bash-stdout>${S}</bash-stdout><bash-stderr>${f(b)}</bash-stderr>`})],shouldQuery:!1}}catch(e){return e instanceof C?e.interrupted?{messages:[v(),c,b({toolUse:!1}),...r],shouldQuery:!1}:{messages:[v(),c,...r,u({content:`<bash-stdout>${f(e.stdout)}</bash-stdout><bash-stderr>${f(e.stderr)}</bash-stderr>`})],shouldQuery:!1}:{messages:[v(),c,...r,u({content:`<bash-stderr>Command failed: ${f(S(e))}</bash-stderr>`})],shouldQuery:!1}}finally{o(null)}}export{F as processBashCommand};
1
+ import{a as e}from"./rolldown-runtime-DaDcL9Zw.js";import{I as t,fi as n,t as r}from"./src-CDCSSo0U2.js";import{t as i}from"./jsx-runtime-Bb4Xn-E0.js";import{Ap as a,GC as o,Hp as s,Jg as c,Jm as l,So as u,Vp as d,WC as f,Yg as p,Ym as m,Yo as h,_u as g,kp as _,vo as v,vu as y,xo as b,zo as x}from"./loadAgentsDir-BURvZNN6.js";import{F as S,j as C,z as w}from"./debug-BrXObCdR.js";import{g as T,n as E}from"./settings-DfWP5y6X.js";import{n as D,r as O}from"./analytics-BotDBGh0.js";import{Ot as k,kt as A}from"./prompt-DNDgGM9q.js";import{randomUUID as j}from"crypto";n(),r(),y(),m(),s();var M=i();function N({input:e,progress:n,verbose:r}){return(0,M.jsxs)(t,{flexDirection:`column`,marginTop:1,children:[(0,M.jsx)(l,{addMargin:!1,param:{text:`<bash-input>${e}</bash-input>`,type:`text`}}),n?(0,M.jsx)(d,{fullOutput:n.fullOutput,output:n.output,elapsedTimeSeconds:n.elapsedTimeSeconds,totalLines:n.totalLines,verbose:r}):g.renderToolUseProgressMessage?.([],{verbose:r,tools:[],terminalSize:void 0})]})}w(),D(),c(),x(),T();function P(){return E().defaultShell??`bash`}y(),k(),o();async function F(t,n,r,i,o){let s=A()&&P()===`powershell`;O(`tengu_input_bash`,{powershell:s});let c=u({content:h({inputString:`<bash-input>${t}</bash-input>`,precedingInputBlocks:n})}),l;o({jsx:(0,M.jsx)(N,{input:t,progress:null,verbose:i.options.verbose}),shouldHidePromptInput:!1});try{let n={...i,setToolJSX:e=>{l=e?.jsx}},d=e=>{o({jsx:(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(N,{input:t,progress:e.data,verbose:i.options.verbose}),l]}),shouldHidePromptInput:!1,showSpinner:!1})},m=null;s&&(m=(a(),e(_)).PowerShellTool);let h=m??g,y=(m?await m.call({command:t,dangerouslyDisableSandbox:!0},n,void 0,void 0,d):await g.call({command:t,dangerouslyDisableSandbox:!0},n,void 0,void 0,d)).data;if(!y)throw Error(`No result received from shell command`);let b=y.stderr,x=await p(h,{...y,stderr:``},j()),S=typeof x.content==`string`?x.content:f(y.stdout);return{messages:[v(),c,...r,u({content:`<bash-stdout>${S}</bash-stdout><bash-stderr>${f(b)}</bash-stderr>`})],shouldQuery:!1}}catch(e){return e instanceof C?e.interrupted?{messages:[v(),c,b({toolUse:!1}),...r],shouldQuery:!1}:{messages:[v(),c,...r,u({content:`<bash-stdout>${f(e.stdout)}</bash-stdout><bash-stderr>${f(e.stderr)}</bash-stderr>`})],shouldQuery:!1}:{messages:[v(),c,...r,u({content:`<bash-stderr>Command failed: ${f(S(e))}</bash-stderr>`})],shouldQuery:!1}}finally{o(null)}}export{F as processBashCommand};
@@ -1,4 +1,4 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{en as t,ht as n,nr as r,t as i}from"./state-ix0xIunV.js";import{Al as a,Bo as o,C as s,Dc as c,ET as l,Ec as u,Eo as d,G as f,Gh as p,Gw as m,Hw as h,Jd as g,KE as _,Kh as v,Ki as y,Kw as b,Kx as x,MT as S,Ol as C,Qi as w,SE as T,Sl as E,So as D,TE as O,TT as k,Th as A,Ui as ee,Uw as te,W as ne,WE as re,Wh as ie,Wo as ae,Yd as oe,Yo as j,Zi as se,aO as M,aw as ce,bl as le,cT as ue,ca as N,dT as de,dy as fe,gy as P,hO as pe,ho as F,hy as me,iC as he,iO as I,jl as L,k as R,kc as ge,mO as _e,my as ve,nC as ye,ow as be,qo as xe,qx as Se,rC as Ce,rO as we,sT as Te,uy as Ee,vo as z,wh as De,xo as Oe,yo as ke,yy as Ae,zi as je,zo as Me}from"./loadAgentsDir-DrDu5yYy.js";import{A as B,D as Ne,a as V,d as Pe,l as H,p as Fe,z as Ie}from"./debug-BrXObCdR.js";import{Mt as Le,jt as Re}from"./settings-DfWP5y6X.js";import{T as U,Y as ze,o as Be,s as W,w as G}from"./log-BMCygSzM.js";import{f as Ve,l as He}from"./file-DcZWPH2V.js";import{n as Ue,r as K}from"./analytics-BotDBGh0.js";import{or as We,sr as Ge,vn as Ke,yn as qe}from"./model-fi472PRc.js";import{ct as Je,ot as Ye}from"./esm-DjGYYlQe.js";import{E as Xe,T as Ze,w as Qe}from"./sessionTracing-lArOaj9u.js";import{n as $e,t as et}from"./slashCommandParsing-RQb_7Xzt.js";import{randomUUID as q}from"crypto";function tt(e,t,n,r,i){let a=0;for(let o of Re){let s=n[o];if(s)for(let n of s)for(let s of n.hooks){let c=s.once?()=>{H(`Removing one-shot hook for event ${o} in skill '${r}'`),v(e,t,o,s)}:void 0;ie(e,t,o,n.matcher||``,s,c,i),a++}}a>0&&H(`Registered ${a} hooks from skill '${r}'`)}var nt=e((()=>{Le(),V(),p()}));function J(){return!1}function rt(){if(!J())throw Error(`ToolUseContext.options.allowBackgroundForkedSlashCommands is test-only and cannot be enabled outside NODE_ENV=test.`)}async function it(e,t,n,r,i,a,o){let s=Ee(),c=e.pluginInfo?M(e.pluginInfo.repository).marketplace:void 0;K(`tengu_slash_command_forked`,{command_name:e.name,invocation_trigger:`user-slash`,...e.pluginInfo&&{_PROTO_plugin_name:e.pluginInfo.pluginManifest.name,...c&&{_PROTO_marketplace_name:c},...P(e.pluginInfo)}});let{skillContent:u,modifiedGetAppState:d,baseAgent:f,promptMessages:p}=await L(e,t,n),g=e.effort===void 0?f:{...f,effort:e.effort};H(`Executing forked slash command /${e.name} with agent ${g.agentType}`);let _=await n.getAppState();n.options.allowBackgroundForkedSlashCommands===!0&&rt();let v=!1;if(_.kairosEnabled&&(v=!0),v){let t=h(),r=N(e),i=We(),c=e=>l({value:e,mode:`prompt`,priority:`later`,isMeta:!0,skipSlashCommands:!0,workload:i}),u=async()=>{if(!o?.runId)return;let e=await Te({runId:o.runId,rootDir:o.rootDir,priority:`later`,workload:i});for(let t of e)k(t)},f=async e=>{o?.runId&&await ue({runId:o.runId,rootDir:o.rootDir,error:e instanceof Error?e.message:String(e)})};return(async()=>{let i=Date.now()+$;for(;Date.now()<i&&n.getAppState().mcp.clients.some(e=>e.type===`pending`);)await qe(Q);let o=n.options.refreshTools?.()??n.options.tools,l=[];for await(let r of A({agentDefinition:g,promptMessages:p,toolUseContext:{...n,getAppState:d,abortController:t},canUseTool:a,isAsync:!0,querySource:`agent:custom`,model:e.model,availableTools:o,override:{agentId:s}}))l.push(r);let f=C(l,`Command completed`);H(`Background forked command /${r} completed (agent ${s})`),c(`<scheduled-task-result command="/${r}">\n${f}\n</scheduled-task-result>`);try{await u()}catch(e){W(e)}})().catch(async e=>{W(e),c(`<scheduled-task-result command="/${r}" status="failed">\n${e instanceof Error?e.message:String(e)}\n</scheduled-task-result>`),await f(e)}),{messages:[],shouldQuery:!1,command:e,deferAutonomyCompletion:!!o?.runId}}let y=[],b=[],x=`forked-command-${e.name}`,S=0,w=e=>(S++,{type:`progress`,data:{message:e,type:`agent_progress`,prompt:u,agentId:s},parentToolUseID:x,toolUseID:`${x}-${S}`,timestamp:new Date().toISOString(),uuid:q()}),E=()=>{i({jsx:oe(b,{tools:n.options.tools,verbose:!1}),shouldHidePromptInput:!1,shouldContinueAnimation:!0,showSpinner:!0})};E();try{for await(let t of A({agentDefinition:g,promptMessages:p,toolUseContext:{...n,getAppState:d},canUseTool:a,isAsync:!1,querySource:`agent:custom`,model:e.model,availableTools:n.options.tools})){y.push(t);let e=xe([t]);if(t.type===`assistant`){let r=T(t);r>0&&n.setResponseLength(e=>e+r);let i=e[0];i&&i.type===`assistant`&&(b.push(w(t)),E())}if(t.type===`user`){let t=e[0];t&&t.type===`user`&&(b.push(w(t)),E())}}}finally{i(null)}let O=C(y,`Command completed`);return H(`Forked slash command /${e.name} completed with agent ${s}`),process.env.USER_TYPE===`ant`&&(O=`[ANT-ONLY] API calls: ${He(m(s))}\n${O}`),{messages:[D({content:j({inputString:`/${N(e)} ${t}`.trim(),precedingInputBlocks:r})}),D({content:`<local-command-stdout>\n${O}\n</local-command-stdout>`})],shouldQuery:!1,command:e,resultText:O}}function at(e){return!/[^a-zA-Z0-9:\-_]/.test(e)}async function ot(e,t,n,i,a,s,c,l,u,d){let f=$e(e);if(!f){K(`tengu_input_slash_missing`,{});let e="Commands are in the form `/command [args]`";return{messages:[z(),...i,D({content:j({inputString:e,precedingInputBlocks:t})})],shouldQuery:!1,resultText:e}}let{commandName:p,args:m,isMcp:h}=f,g=h?`mcp`:je().has(p)?p:`custom`;if(!se(p,a.options.commands)){let n=!1;try{await Pe().stat(`/${p}`),n=!0}catch{}if(at(p)&&!n){K(`tengu_input_slash_invalid`,{input:p});let e=`Unknown skill: ${p}`;return{messages:[z(),...i,D({content:j({inputString:e,precedingInputBlocks:t})}),...m?[ke(`Args from unknown skill: ${m}`,`warning`)]:[]],shouldQuery:!1,resultText:e}}let a=q();return r(a),K(`tengu_input_prompt`,{}),Ze(`user_prompt`,{prompt_length:String(e.length),prompt:Xe(e),"prompt.id":a}),{messages:[D({content:j({inputString:e,precedingInputBlocks:t}),uuid:c}),...i],shouldQuery:!0}}let{messages:_,shouldQuery:v,allowedTools:y,model:b,effort:x,command:S,resultText:C,nextInput:w,submitNextInput:T,deferAutonomyCompletion:E}=await st(p,m,s,a,t,n,l,u,c,d);if(_.length===0){let e={input:g};if(S.type===`prompt`&&S.pluginInfo){let{pluginManifest:t,repository:n}=S.pluginInfo,{marketplace:r}=M(n),i=I(r);e._PROTO_plugin_name=t.name,r&&(e._PROTO_marketplace_name=r),e.plugin_repository=i?n:`third-party`,e.plugin_name=i?t.name:`third-party`,i&&t.version&&(e.plugin_version=t.version),Object.assign(e,P(S.pluginInfo))}return K(`tengu_input_command`,{...e,invocation_trigger:`user-slash`,...process.env.USER_TYPE===`ant`&&{skill_name:p,...S.type===`prompt`&&{skill_source:S.source},...S.loadedFrom&&{skill_loaded_from:S.loadedFrom},...S.kind&&{skill_kind:S.kind}}}),{messages:[],shouldQuery:!1,model:b,nextInput:w,submitNextInput:T,deferAutonomyCompletion:E}}if(_.length===2&&_[1].type===`user`&&typeof _[1].message.content==`string`&&_[1].message.content.startsWith(`Unknown command:`))return e.startsWith(`/var`)||e.startsWith(`/tmp`)||e.startsWith(`/private`)||K(`tengu_input_slash_invalid`,{input:p}),{messages:[z(),..._],shouldQuery:v,allowedTools:y,model:b};let O={input:g};if(S.type===`prompt`&&S.pluginInfo){let{pluginManifest:e,repository:t}=S.pluginInfo,{marketplace:n}=M(t),r=I(n);O._PROTO_plugin_name=e.name,n&&(O._PROTO_marketplace_name=n),O.plugin_repository=r?t:`third-party`,O.plugin_name=r?e.name:`third-party`,r&&e.version&&(O.plugin_version=e.version),Object.assign(O,P(S.pluginInfo))}K(`tengu_input_command`,{...O,invocation_trigger:`user-slash`,...process.env.USER_TYPE===`ant`&&{skill_name:p,...S.type===`prompt`&&{skill_source:S.source},...S.loadedFrom&&{skill_loaded_from:S.loadedFrom},...S.kind&&{skill_kind:S.kind}}});let k=_.length>0&&_[0]&&o(_[0]);return{messages:v||_.every(ae)||k?_:[z(),..._],shouldQuery:v,allowedTools:y,model:b,effort:x,resultText:C,nextInput:w,submitNextInput:T,deferAutonomyCompletion:E}}async function st(e,t,n,r,i,a,o,s,c,l){let u=y(e,r.options.commands);if(u.type===`prompt`&&u.userInvocable!==!1&&me(e),u.userInvocable===!1)return{messages:[D({content:j({inputString:`/${e}`,precedingInputBlocks:i})}),D({content:`This skill can only be invoked by Claude, not directly by users. Ask Claude to use the "${e}" skill for you.`})],shouldQuery:!1,command:u};try{switch(u.type){case`local-jsx`:return new Promise(e=>{let a=!1,o=(n,r)=>{if(a=!0,r?.display===`skip`){e({messages:[],shouldQuery:!1,command:u,nextInput:r?.nextInput,submitNextInput:r?.submitNextInput});return}let o=(r?.metaMessages??[]).map(e=>D({content:e,isMeta:!0})),s=Se()&&typeof n==`string`&&n.endsWith(` dismissed`),c=r?.displayArgs??t;e({messages:r?.display===`system`?s?o:[F(Y(u,c)),F(`<local-command-stdout>${n}</local-command-stdout>`),...o]:[D({content:j({inputString:Y(u,c),precedingInputBlocks:i})}),D(n?{content:`<local-command-stdout>${n}</local-command-stdout>`}:{content:`<local-command-stdout>${_e}</local-command-stdout>`}),...o],shouldQuery:r?.shouldQuery??!1,command:u,nextInput:r?.nextInput,submitNextInput:r?.submitNextInput})};u.load().then(e=>e.call(o,{...r,canUseTool:s},t)).then(t=>{if(t!=null){if(r.options.isNonInteractiveSession){e({messages:[],shouldQuery:!1,command:u});return}a||n({jsx:t,shouldHidePromptInput:!0,showSpinner:!1,isLocalJSXCommand:!0,isImmediate:u.immediate===!0})}}).catch(t=>{W(t),!a&&(a=!0,n({jsx:null,shouldHidePromptInput:!1,clearLocalJSX:!0}),e({messages:[],shouldQuery:!1,command:u}))})});case`local`:{let e=D({content:j({inputString:Y(u,u.isSensitive&&t.trim()?`***`:t),precedingInputBlocks:i})});try{let n=z(),i=await(await u.load()).call(t,r);if(i.type===`skip`)return{messages:[],shouldQuery:!1,command:u};if(i.type===`compact`){let t=[n,e,...i.displayText?[D({content:`<local-command-stdout>${i.displayText}</local-command-stdout>`,timestamp:new Date(Date.now()+100).toISOString()})]:[]],r={...i.compactionResult,messagesToKeep:[...i.compactionResult.messagesToKeep??[],...t]};return _(),{messages:le(r),shouldQuery:!1,command:u}}return{messages:[e,F(`<local-command-stdout>${i.value}</local-command-stdout>`)],shouldQuery:!1,command:u,resultText:i.value}}catch(t){return W(t),{messages:[e,F(`<local-command-stderr>${String(t)}</local-command-stderr>`)],shouldQuery:!1,command:u}}}case`prompt`:try{return u.context===`fork`?await it(u,t,r,i,n,s??ne,l):await Z(u,t,r,i,a,c)}catch(e){return e instanceof Ne?{messages:[D({content:j({inputString:Y(u,t),precedingInputBlocks:i})}),Oe({toolUse:!1})],shouldQuery:!1,command:u}:{messages:[D({content:j({inputString:Y(u,t),precedingInputBlocks:i})}),D({content:`<local-command-stderr>${String(e)}</local-command-stderr>`})],shouldQuery:!1,command:u}}}}catch(e){if(e instanceof B)return{messages:[D({content:j({inputString:e.message,precedingInputBlocks:i})})],shouldQuery:!1,command:u};throw e}}function Y(e,t){return d(N(e),t)}function X(e,t=`loading`){return[`<${G}>${e}</${G}>`,`<${U}>${e}</${U}>`,`<skill-format>true</skill-format>`].join(`
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{en as t,ht as n,nr as r,t as i}from"./state-ix0xIunV.js";import{Al as a,Bo as o,C as s,Dc as c,ET as l,Ec as u,Eo as d,G as f,Gh as p,Gw as m,Hw as h,Jd as g,KE as _,Kh as v,Ki as y,Kw as b,Kx as x,MT as S,Ol as C,Qi as w,SE as T,Sl as E,So as D,TE as O,TT as k,Th as A,Ui as ee,Uw as te,W as ne,WE as re,Wh as ie,Wo as ae,Yd as oe,Yo as j,Zi as se,aO as M,aw as ce,bl as le,cT as ue,ca as N,dT as de,dy as fe,gy as P,hO as pe,ho as F,hy as me,iC as he,iO as I,jl as L,k as R,kc as ge,mO as _e,my as ve,nC as ye,ow as be,qo as xe,qx as Se,rC as Ce,rO as we,sT as Te,uy as Ee,vo as z,wh as De,xo as Oe,yo as ke,yy as Ae,zi as je,zo as Me}from"./loadAgentsDir-BURvZNN6.js";import{A as B,D as Ne,a as V,d as Pe,l as H,p as Fe,z as Ie}from"./debug-BrXObCdR.js";import{Mt as Le,jt as Re}from"./settings-DfWP5y6X.js";import{T as U,Y as ze,o as Be,s as W,w as G}from"./log-BMCygSzM.js";import{f as Ve,l as He}from"./file-DcZWPH2V.js";import{n as Ue,r as K}from"./analytics-BotDBGh0.js";import{or as We,sr as Ge,vn as Ke,yn as qe}from"./model-BIVmcl_N.js";import{ct as Je,ot as Ye}from"./esm-B62dCLgf.js";import{E as Xe,T as Ze,w as Qe}from"./sessionTracing-CCPRzOvy.js";import{n as $e,t as et}from"./slashCommandParsing-RQb_7Xzt.js";import{randomUUID as q}from"crypto";function tt(e,t,n,r,i){let a=0;for(let o of Re){let s=n[o];if(s)for(let n of s)for(let s of n.hooks){let c=s.once?()=>{H(`Removing one-shot hook for event ${o} in skill '${r}'`),v(e,t,o,s)}:void 0;ie(e,t,o,n.matcher||``,s,c,i),a++}}a>0&&H(`Registered ${a} hooks from skill '${r}'`)}var nt=e((()=>{Le(),V(),p()}));function J(){return!1}function rt(){if(!J())throw Error(`ToolUseContext.options.allowBackgroundForkedSlashCommands is test-only and cannot be enabled outside NODE_ENV=test.`)}async function it(e,t,n,r,i,a,o){let s=Ee(),c=e.pluginInfo?M(e.pluginInfo.repository).marketplace:void 0;K(`tengu_slash_command_forked`,{command_name:e.name,invocation_trigger:`user-slash`,...e.pluginInfo&&{_PROTO_plugin_name:e.pluginInfo.pluginManifest.name,...c&&{_PROTO_marketplace_name:c},...P(e.pluginInfo)}});let{skillContent:u,modifiedGetAppState:d,baseAgent:f,promptMessages:p}=await L(e,t,n),g=e.effort===void 0?f:{...f,effort:e.effort};H(`Executing forked slash command /${e.name} with agent ${g.agentType}`);let _=await n.getAppState();n.options.allowBackgroundForkedSlashCommands===!0&&rt();let v=!1;if(_.kairosEnabled&&(v=!0),v){let t=h(),r=N(e),i=We(),c=e=>l({value:e,mode:`prompt`,priority:`later`,isMeta:!0,skipSlashCommands:!0,workload:i}),u=async()=>{if(!o?.runId)return;let e=await Te({runId:o.runId,rootDir:o.rootDir,priority:`later`,workload:i});for(let t of e)k(t)},f=async e=>{o?.runId&&await ue({runId:o.runId,rootDir:o.rootDir,error:e instanceof Error?e.message:String(e)})};return(async()=>{let i=Date.now()+$;for(;Date.now()<i&&n.getAppState().mcp.clients.some(e=>e.type===`pending`);)await qe(Q);let o=n.options.refreshTools?.()??n.options.tools,l=[];for await(let r of A({agentDefinition:g,promptMessages:p,toolUseContext:{...n,getAppState:d,abortController:t},canUseTool:a,isAsync:!0,querySource:`agent:custom`,model:e.model,availableTools:o,override:{agentId:s}}))l.push(r);let f=C(l,`Command completed`);H(`Background forked command /${r} completed (agent ${s})`),c(`<scheduled-task-result command="/${r}">\n${f}\n</scheduled-task-result>`);try{await u()}catch(e){W(e)}})().catch(async e=>{W(e),c(`<scheduled-task-result command="/${r}" status="failed">\n${e instanceof Error?e.message:String(e)}\n</scheduled-task-result>`),await f(e)}),{messages:[],shouldQuery:!1,command:e,deferAutonomyCompletion:!!o?.runId}}let y=[],b=[],x=`forked-command-${e.name}`,S=0,w=e=>(S++,{type:`progress`,data:{message:e,type:`agent_progress`,prompt:u,agentId:s},parentToolUseID:x,toolUseID:`${x}-${S}`,timestamp:new Date().toISOString(),uuid:q()}),E=()=>{i({jsx:oe(b,{tools:n.options.tools,verbose:!1}),shouldHidePromptInput:!1,shouldContinueAnimation:!0,showSpinner:!0})};E();try{for await(let t of A({agentDefinition:g,promptMessages:p,toolUseContext:{...n,getAppState:d},canUseTool:a,isAsync:!1,querySource:`agent:custom`,model:e.model,availableTools:n.options.tools})){y.push(t);let e=xe([t]);if(t.type===`assistant`){let r=T(t);r>0&&n.setResponseLength(e=>e+r);let i=e[0];i&&i.type===`assistant`&&(b.push(w(t)),E())}if(t.type===`user`){let t=e[0];t&&t.type===`user`&&(b.push(w(t)),E())}}}finally{i(null)}let O=C(y,`Command completed`);return H(`Forked slash command /${e.name} completed with agent ${s}`),process.env.USER_TYPE===`ant`&&(O=`[ANT-ONLY] API calls: ${He(m(s))}\n${O}`),{messages:[D({content:j({inputString:`/${N(e)} ${t}`.trim(),precedingInputBlocks:r})}),D({content:`<local-command-stdout>\n${O}\n</local-command-stdout>`})],shouldQuery:!1,command:e,resultText:O}}function at(e){return!/[^a-zA-Z0-9:\-_]/.test(e)}async function ot(e,t,n,i,a,s,c,l,u,d){let f=$e(e);if(!f){K(`tengu_input_slash_missing`,{});let e="Commands are in the form `/command [args]`";return{messages:[z(),...i,D({content:j({inputString:e,precedingInputBlocks:t})})],shouldQuery:!1,resultText:e}}let{commandName:p,args:m,isMcp:h}=f,g=h?`mcp`:je().has(p)?p:`custom`;if(!se(p,a.options.commands)){let n=!1;try{await Pe().stat(`/${p}`),n=!0}catch{}if(at(p)&&!n){K(`tengu_input_slash_invalid`,{input:p});let e=`Unknown skill: ${p}`;return{messages:[z(),...i,D({content:j({inputString:e,precedingInputBlocks:t})}),...m?[ke(`Args from unknown skill: ${m}`,`warning`)]:[]],shouldQuery:!1,resultText:e}}let a=q();return r(a),K(`tengu_input_prompt`,{}),Ze(`user_prompt`,{prompt_length:String(e.length),prompt:Xe(e),"prompt.id":a}),{messages:[D({content:j({inputString:e,precedingInputBlocks:t}),uuid:c}),...i],shouldQuery:!0}}let{messages:_,shouldQuery:v,allowedTools:y,model:b,effort:x,command:S,resultText:C,nextInput:w,submitNextInput:T,deferAutonomyCompletion:E}=await st(p,m,s,a,t,n,l,u,c,d);if(_.length===0){let e={input:g};if(S.type===`prompt`&&S.pluginInfo){let{pluginManifest:t,repository:n}=S.pluginInfo,{marketplace:r}=M(n),i=I(r);e._PROTO_plugin_name=t.name,r&&(e._PROTO_marketplace_name=r),e.plugin_repository=i?n:`third-party`,e.plugin_name=i?t.name:`third-party`,i&&t.version&&(e.plugin_version=t.version),Object.assign(e,P(S.pluginInfo))}return K(`tengu_input_command`,{...e,invocation_trigger:`user-slash`,...process.env.USER_TYPE===`ant`&&{skill_name:p,...S.type===`prompt`&&{skill_source:S.source},...S.loadedFrom&&{skill_loaded_from:S.loadedFrom},...S.kind&&{skill_kind:S.kind}}}),{messages:[],shouldQuery:!1,model:b,nextInput:w,submitNextInput:T,deferAutonomyCompletion:E}}if(_.length===2&&_[1].type===`user`&&typeof _[1].message.content==`string`&&_[1].message.content.startsWith(`Unknown command:`))return e.startsWith(`/var`)||e.startsWith(`/tmp`)||e.startsWith(`/private`)||K(`tengu_input_slash_invalid`,{input:p}),{messages:[z(),..._],shouldQuery:v,allowedTools:y,model:b};let O={input:g};if(S.type===`prompt`&&S.pluginInfo){let{pluginManifest:e,repository:t}=S.pluginInfo,{marketplace:n}=M(t),r=I(n);O._PROTO_plugin_name=e.name,n&&(O._PROTO_marketplace_name=n),O.plugin_repository=r?t:`third-party`,O.plugin_name=r?e.name:`third-party`,r&&e.version&&(O.plugin_version=e.version),Object.assign(O,P(S.pluginInfo))}K(`tengu_input_command`,{...O,invocation_trigger:`user-slash`,...process.env.USER_TYPE===`ant`&&{skill_name:p,...S.type===`prompt`&&{skill_source:S.source},...S.loadedFrom&&{skill_loaded_from:S.loadedFrom},...S.kind&&{skill_kind:S.kind}}});let k=_.length>0&&_[0]&&o(_[0]);return{messages:v||_.every(ae)||k?_:[z(),..._],shouldQuery:v,allowedTools:y,model:b,effort:x,resultText:C,nextInput:w,submitNextInput:T,deferAutonomyCompletion:E}}async function st(e,t,n,r,i,a,o,s,c,l){let u=y(e,r.options.commands);if(u.type===`prompt`&&u.userInvocable!==!1&&me(e),u.userInvocable===!1)return{messages:[D({content:j({inputString:`/${e}`,precedingInputBlocks:i})}),D({content:`This skill can only be invoked by Claude, not directly by users. Ask Claude to use the "${e}" skill for you.`})],shouldQuery:!1,command:u};try{switch(u.type){case`local-jsx`:return new Promise(e=>{let a=!1,o=(n,r)=>{if(a=!0,r?.display===`skip`){e({messages:[],shouldQuery:!1,command:u,nextInput:r?.nextInput,submitNextInput:r?.submitNextInput});return}let o=(r?.metaMessages??[]).map(e=>D({content:e,isMeta:!0})),s=Se()&&typeof n==`string`&&n.endsWith(` dismissed`),c=r?.displayArgs??t;e({messages:r?.display===`system`?s?o:[F(Y(u,c)),F(`<local-command-stdout>${n}</local-command-stdout>`),...o]:[D({content:j({inputString:Y(u,c),precedingInputBlocks:i})}),D(n?{content:`<local-command-stdout>${n}</local-command-stdout>`}:{content:`<local-command-stdout>${_e}</local-command-stdout>`}),...o],shouldQuery:r?.shouldQuery??!1,command:u,nextInput:r?.nextInput,submitNextInput:r?.submitNextInput})};u.load().then(e=>e.call(o,{...r,canUseTool:s},t)).then(t=>{if(t!=null){if(r.options.isNonInteractiveSession){e({messages:[],shouldQuery:!1,command:u});return}a||n({jsx:t,shouldHidePromptInput:!0,showSpinner:!1,isLocalJSXCommand:!0,isImmediate:u.immediate===!0})}}).catch(t=>{W(t),!a&&(a=!0,n({jsx:null,shouldHidePromptInput:!1,clearLocalJSX:!0}),e({messages:[],shouldQuery:!1,command:u}))})});case`local`:{let e=D({content:j({inputString:Y(u,u.isSensitive&&t.trim()?`***`:t),precedingInputBlocks:i})});try{let n=z(),i=await(await u.load()).call(t,r);if(i.type===`skip`)return{messages:[],shouldQuery:!1,command:u};if(i.type===`compact`){let t=[n,e,...i.displayText?[D({content:`<local-command-stdout>${i.displayText}</local-command-stdout>`,timestamp:new Date(Date.now()+100).toISOString()})]:[]],r={...i.compactionResult,messagesToKeep:[...i.compactionResult.messagesToKeep??[],...t]};return _(),{messages:le(r),shouldQuery:!1,command:u}}return{messages:[e,F(`<local-command-stdout>${i.value}</local-command-stdout>`)],shouldQuery:!1,command:u,resultText:i.value}}catch(t){return W(t),{messages:[e,F(`<local-command-stderr>${String(t)}</local-command-stderr>`)],shouldQuery:!1,command:u}}}case`prompt`:try{return u.context===`fork`?await it(u,t,r,i,n,s??ne,l):await Z(u,t,r,i,a,c)}catch(e){return e instanceof Ne?{messages:[D({content:j({inputString:Y(u,t),precedingInputBlocks:i})}),Oe({toolUse:!1})],shouldQuery:!1,command:u}:{messages:[D({content:j({inputString:Y(u,t),precedingInputBlocks:i})}),D({content:`<local-command-stderr>${String(e)}</local-command-stderr>`})],shouldQuery:!1,command:u}}}}catch(e){if(e instanceof B)return{messages:[D({content:j({inputString:e.message,precedingInputBlocks:i})})],shouldQuery:!1,command:u};throw e}}function Y(e,t){return d(N(e),t)}function X(e,t=`loading`){return[`<${G}>${e}</${G}>`,`<${U}>${e}</${U}>`,`<skill-format>true</skill-format>`].join(`
2
2
  `)}function ct(e,t){return[`<${G}>${e}</${G}>`,`<${U}>/${e}</${U}>`,t?`<command-args>${t}</command-args>`:null].filter(Boolean).join(`
3
3
  `)}function lt(e,t){return e.userInvocable===!1&&(e.loadedFrom===`skills`||e.loadedFrom===`plugin`||e.loadedFrom===`mcp`)?X(e.name,e.progressMessage):ct(e.name,t)}async function ut(e,t,n,r,i=[]){let a=ee(e,n);if(!a)throw new B(`Unknown command: ${e}`);if(a.type!==`prompt`)throw Error(`Unexpected ${a.type} command. Expected 'prompt' command. Use /${e} directly in the main conversation.`);return Z(a,t,r,[],i)}async function Z(e,t,r,a=[],o=[],s){let l=await e.getPromptForCommand(t,r),d=!Ce(`hooks`)||he(e.source);if(e.hooks&&d){let t=n();tt(r.setAppState,t,e.hooks,e.name,e.type===`prompt`?e.skillRoot:void 0)}let f=e.source?`${e.source}:${e.name}`:e.name,p=l.filter(e=>e.type===`text`).map(e=>e.text).join(`
4
4
 
@@ -0,0 +1 @@
1
+ import{i as e,r as t}from"./prompt-DNDgGM9q.js";t();export{e as isDeferredTool};
@@ -1,4 +1,4 @@
1
- import{a as e,n as t,o as n,r,t as i}from"./rolldown-runtime-DaDcL9Zw.js";import{c as a,l as o,o as s}from"./envUtils-DSxRz_kt.js";import{n as c,t as l}from"./defineProperty-C-QyHrDq.js";import{E as u,M as d,P as f,T as p,n as m,r as h,t as g}from"./lazySchema-DcIJE_0i.js";import{M as _,S as v,w as y,z as b}from"./debug-BrXObCdR.js";import{J as x,Q as S,X as C,Y as w,Z as T,nt as E}from"./settings-DfWP5y6X.js";import{U as D,Y as O}from"./log-BMCygSzM.js";import{i as k,o as A}from"./platform-BrYefG_2.js";import{_ as ee,u as j}from"./model-fi472PRc.js";import{join as M,parse as N,resolve as P,sep as F}from"node:path";import{createHash as I}from"node:crypto";import{appendFile as te,mkdir as ne,readFile as L,readdir as re,rm as ie,writeFile as ae}from"node:fs/promises";function oe(e){return e.filter(e=>e.data?.type!==`hook_progress`)}function se(e,t){return e.name===t||(e.aliases?.includes(t)??!1)}function ce(e,t){return e.find(e=>se(e,t))}function le(e){return{...de,userFacingName:()=>e.name,...e}}var ue,de,fe=t((()=>{ue=()=>({mode:`default`,additionalWorkingDirectories:new Map,alwaysAllowRules:{},alwaysDenyRules:{},alwaysAskRules:{},isBypassPermissionsModeAvailable:!0}),de={isEnabled:()=>!0,isConcurrencySafe:e=>!1,isReadOnly:e=>!1,isDestructive:e=>!1,checkPermissions:(e,t)=>Promise.resolve({behavior:`allow`,updatedInput:e}),toAutoClassifierInput:e=>``,userFacingName:e=>``}})),R,pe=t((()=>{R=`Bash`}));function me(){return`A powerful search tool built on ripgrep
1
+ import{a as e,n as t,o as n,r,t as i}from"./rolldown-runtime-DaDcL9Zw.js";import{c as a,l as o,o as s}from"./envUtils-DSxRz_kt.js";import{n as c,t as l}from"./defineProperty-C-QyHrDq.js";import{E as u,M as d,P as f,T as p,n as m,r as h,t as g}from"./lazySchema-DcIJE_0i.js";import{M as _,S as v,w as y,z as b}from"./debug-BrXObCdR.js";import{J as x,Q as S,X as C,Y as w,Z as T,nt as E}from"./settings-DfWP5y6X.js";import{U as D,Y as O}from"./log-BMCygSzM.js";import{i as k,o as A}from"./platform-BrYefG_2.js";import{_ as ee,u as j}from"./model-BIVmcl_N.js";import{join as M,parse as N,resolve as P,sep as F}from"node:path";import{createHash as I}from"node:crypto";import{appendFile as te,mkdir as ne,readFile as L,readdir as re,rm as ie,writeFile as ae}from"node:fs/promises";function oe(e){return e.filter(e=>e.data?.type!==`hook_progress`)}function se(e,t){return e.name===t||(e.aliases?.includes(t)??!1)}function ce(e,t){return e.find(e=>se(e,t))}function le(e){return{...de,userFacingName:()=>e.name,...e}}var ue,de,fe=t((()=>{ue=()=>({mode:`default`,additionalWorkingDirectories:new Map,alwaysAllowRules:{},alwaysDenyRules:{},alwaysAskRules:{},isBypassPermissionsModeAvailable:!0}),de={isEnabled:()=>!0,isConcurrencySafe:e=>!1,isReadOnly:e=>!1,isDestructive:e=>!1,checkPermissions:(e,t)=>Promise.resolve({behavior:`allow`,updatedInput:e}),toAutoClassifierInput:e=>``,userFacingName:e=>``}})),R,pe=t((()=>{R=`Bash`}));function me(){return`A powerful search tool built on ripgrep
2
2
 
3
3
  Usage:
4
4
  - ALWAYS use ${z} for search tasks. NEVER invoke \`grep\` or \`rg\` as a ${R} command. The ${z} tool has been optimized for correct permissions and access.
@@ -0,0 +1 @@
1
+ import{iD as e,uD as t}from"./loadAgentsDir-BURvZNN6.js";t();export{e as clearPromptCache};
@@ -1,4 +1,4 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./memoize-BK3gG5ob.js";import{Rn as r,t as i}from"./src-CDCSSo0U2.js";import{By as a,Lg as o,Og as s,Vy as c,dS as l,lS as u,mS as d,pS as f}from"./loadAgentsDir-DrDu5yYy.js";import{E as p,S as m,a as h,d as g,l as _,p as v}from"./debug-BrXObCdR.js";import{n as y,t as b}from"./execSyncWrapper-CCMQShK-.js";import{r as x,t as S}from"./which-CKQnSouy.js";import{basename as C}from"path";import{spawn as w,spawnSync as T}from"child_process";function E(e){return!!x(e)}function D(e){let t=C(e.split(` `)[0]??``);return A.find(e=>t.includes(e))}function O(e,t,n){return n?M.has(e)?[`-g`,`${t}:${n}`]:e===`subl`?[`${t}:${n}`]:[t]:[t]}function k(e,t){let n=N();if(!n)return!1;let i=n.split(` `),a=i[0]??n,o=i.slice(1),s=D(n);if(s){let r=O(s,e,t),i={detached:!0,stdio:`ignore`},c;return c=process.platform===`win32`?w(`${n} ${r.map(e=>`"${e}"`).join(` `)}`,{...i,shell:!0}):w(a,[...o,...r],i),c.on(`error`,e=>_(`editor spawn failed: ${e}`,{level:`error`})),c.unref(),!0}let c=r.get(process.stdout);if(!c)return!1;let l=t&&j.test(C(a));c.enterAlternateScreen();try{let r={stdio:`inherit`},i;return i=process.platform===`win32`?T(`${n} ${l?`+${t} `:``}"${e}"`,{...r,shell:!0}):T(a,[...o,...l?[`+${t}`,e]:[e]],r),i.error?(_(`editor spawn failed: ${i.error}`,{level:`error`}),!1):!0}finally{c.exitAlternateScreen()}}var A,j,M,N,P=e((()=>{n(),i(),h(),S(),A=[`code`,`cursor`,`windsurf`,`codium`,`subl`,`atom`,`gedit`,`notepad++`,`notepad`],j=/\b(vi|vim|nvim|nano|emacs|pico|micro|helix|hx)\b/,M=new Set([`code`,`cursor`,`windsurf`,`codium`]),N=t(()=>process.env.VISUAL?.trim()?process.env.VISUAL.trim():process.env.EDITOR?.trim()?process.env.EDITOR.trim():process.platform===`win32`?`start /wait notepad`:[`code`,`vi`,`nano`].find(e=>E(e)))}));function F(e){return D(e)!==void 0}function I(e){let t=g(),n=r.get(process.stdout);if(!n)throw Error(`Ink instance not found - cannot pause rendering`);let i=N();if(!i)return{content:null};try{t.statSync(e)}catch{return{content:null}}let a=!F(i);a?n.enterAlternateScreen():(n.pause(),n.suspendStdin());try{return b(`${z[i]??i} "${e}"`,{stdio:`inherit`}),{content:t.readFileSync(e,{encoding:`utf-8`})}}catch(e){if(typeof e==`object`&&e&&`status`in e&&typeof e.status==`number`){let t=e.status;if(t!==0)return{content:null,error:`${o(i)} exited with code ${t}`}}return{content:null}}finally{a?n.exitAlternateScreen():(n.resumeStdin(),n.resume())}}function L(e,t,n){let r=e;for(let[e,t]of Object.entries(n))if(t.type===`text`){let n=parseInt(e,10),i=t.content,a=r.indexOf(i);if(a!==-1){let e=l(n,f(i));r=r.slice(0,a)+e+r.slice(a+i.length)}}return r}function R(e,t){let n=g(),r=a();try{p(r,t?u(e,t):e,{encoding:`utf-8`,flush:!0});let n=I(r);if(n.content===null)return n;let i=n.content;return i.endsWith(`
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./memoize-BK3gG5ob.js";import{Rn as r,t as i}from"./src-CDCSSo0U2.js";import{By as a,Lg as o,Og as s,Vy as c,dS as l,lS as u,mS as d,pS as f}from"./loadAgentsDir-BURvZNN6.js";import{E as p,S as m,a as h,d as g,l as _,p as v}from"./debug-BrXObCdR.js";import{n as y,t as b}from"./execSyncWrapper-CCMQShK-.js";import{r as x,t as S}from"./which-CKQnSouy.js";import{basename as C}from"path";import{spawn as w,spawnSync as T}from"child_process";function E(e){return!!x(e)}function D(e){let t=C(e.split(` `)[0]??``);return A.find(e=>t.includes(e))}function O(e,t,n){return n?M.has(e)?[`-g`,`${t}:${n}`]:e===`subl`?[`${t}:${n}`]:[t]:[t]}function k(e,t){let n=N();if(!n)return!1;let i=n.split(` `),a=i[0]??n,o=i.slice(1),s=D(n);if(s){let r=O(s,e,t),i={detached:!0,stdio:`ignore`},c;return c=process.platform===`win32`?w(`${n} ${r.map(e=>`"${e}"`).join(` `)}`,{...i,shell:!0}):w(a,[...o,...r],i),c.on(`error`,e=>_(`editor spawn failed: ${e}`,{level:`error`})),c.unref(),!0}let c=r.get(process.stdout);if(!c)return!1;let l=t&&j.test(C(a));c.enterAlternateScreen();try{let r={stdio:`inherit`},i;return i=process.platform===`win32`?T(`${n} ${l?`+${t} `:``}"${e}"`,{...r,shell:!0}):T(a,[...o,...l?[`+${t}`,e]:[e]],r),i.error?(_(`editor spawn failed: ${i.error}`,{level:`error`}),!1):!0}finally{c.exitAlternateScreen()}}var A,j,M,N,P=e((()=>{n(),i(),h(),S(),A=[`code`,`cursor`,`windsurf`,`codium`,`subl`,`atom`,`gedit`,`notepad++`,`notepad`],j=/\b(vi|vim|nvim|nano|emacs|pico|micro|helix|hx)\b/,M=new Set([`code`,`cursor`,`windsurf`,`codium`]),N=t(()=>process.env.VISUAL?.trim()?process.env.VISUAL.trim():process.env.EDITOR?.trim()?process.env.EDITOR.trim():process.platform===`win32`?`start /wait notepad`:[`code`,`vi`,`nano`].find(e=>E(e)))}));function F(e){return D(e)!==void 0}function I(e){let t=g(),n=r.get(process.stdout);if(!n)throw Error(`Ink instance not found - cannot pause rendering`);let i=N();if(!i)return{content:null};try{t.statSync(e)}catch{return{content:null}}let a=!F(i);a?n.enterAlternateScreen():(n.pause(),n.suspendStdin());try{return b(`${z[i]??i} "${e}"`,{stdio:`inherit`}),{content:t.readFileSync(e,{encoding:`utf-8`})}}catch(e){if(typeof e==`object`&&e&&`status`in e&&typeof e.status==`number`){let t=e.status;if(t!==0)return{content:null,error:`${o(i)} exited with code ${t}`}}return{content:null}}finally{a?n.exitAlternateScreen():(n.resumeStdin(),n.resume())}}function L(e,t,n){let r=e;for(let[e,t]of Object.entries(n))if(t.type===`text`){let n=parseInt(e,10),i=t.content,a=r.indexOf(i);if(a!==-1){let e=l(n,f(i));r=r.slice(0,a)+e+r.slice(a+i.length)}}return r}function R(e,t){let n=g(),r=a();try{p(r,t?u(e,t):e,{encoding:`utf-8`,flush:!0});let n=I(r);if(n.content===null)return n;let i=n.content;return i.endsWith(`
2
2
  `)&&!i.endsWith(`
3
3
 
4
4
  `)&&(i=i.slice(0,-1)),t&&(i=L(i,e,t)),{content:i}}finally{try{n.unlinkSync(r)}catch{}}}var z,B=e((()=>{d(),i(),P(),y(),v(),s(),m(),c(),z={code:`code -w`,subl:`subl --wait`}}));export{P as a,N as i,R as n,k as o,B as r,I as t};
@@ -1 +1 @@
1
- import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{fi as n,t as r,y as i}from"./src-CDCSSo0U2.js";import{t as a}from"./jsx-runtime-Bb4Xn-E0.js";import{_x as o,ah as s,da as c,fa as l,ih as u,oh as d,rh as f,vx as p}from"./loadAgentsDir-DrDu5yYy.js";import{n as m,r as h}from"./analytics-BotDBGh0.js";import{It as g,Mt as _,Pt as v,Vt as y,ci as b,oi as x}from"./model-fi472PRc.js";import{n as S,t as C}from"./extra-usage-BTv_OwGN.js";import{n as w,t as T}from"./upgrade-7OrBbrzS.js";function E({onDone:e,context:t}){let[n,r]=(0,O.useState)(null),a=u(),c=g(),d=v(),f=_()?.hasExtraUsageEnabled===!0,p=c===`max`&&d===`default_claude_max_20x`,m=c===`team`||c===`enterprise`,y=(0,O.useMemo)(()=>{let e=[];if(s.isEnabled()){let t=x(),n=m&&!t,r=a.overageDisabledReason===`out_of_credits`||a.overageDisabledReason===`org_level_disabled_until`||a.overageDisabledReason===`org_service_zero_credit_limit`;if(!(n&&r)){let t=a.overageStatus===`rejected`||a.overageStatus===`allowed_warning`,r;r=n?t?`Request more`:`Request extra usage`:f?`Add funds to continue with extra usage`:`Switch to extra usage`,e.push({label:r,value:`extra-usage`})}}return!p&&!m&&l.isEnabled()&&e.push({label:`Upgrade your plan`,value:`upgrade`}),[{label:`Stop and wait for limit to reset`,value:`cancel`},...e]},[!1,p,m,f,a.overageStatus,a.overageDisabledReason]);function b(){h(`tengu_rate_limit_options_menu_cancel`,{}),e(void 0,{display:`skip`})}function S(n){n===`upgrade`?(h(`tengu_rate_limit_options_menu_select_upgrade`,{}),T(e,t).then(e=>{e&&r(e)})):n===`extra-usage`?(h(`tengu_rate_limit_options_menu_select_extra_usage`,{}),C(e,t).then(e=>{e&&r(e)})):n===`cancel`&&b()}return n||(0,k.jsx)(i,{title:`What do you want to do?`,onCancel:b,color:`suggestion`,children:(0,k.jsx)(o,{options:y,onChange:S,visibleOptionCount:y.length})})}async function D(e,t){return(0,k.jsx)(E,{onDone:e,context:t})}var O,k;e((()=>{O=t(n(),1),p(),r(),m(),f(),y(),b(),S(),d(),c(),w(),k=a()}))();export{D as call};
1
+ import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{fi as n,t as r,y as i}from"./src-CDCSSo0U2.js";import{t as a}from"./jsx-runtime-Bb4Xn-E0.js";import{_x as o,ah as s,da as c,fa as l,ih as u,oh as d,rh as f,vx as p}from"./loadAgentsDir-BURvZNN6.js";import{n as m,r as h}from"./analytics-BotDBGh0.js";import{It as g,Mt as _,Pt as v,Vt as y,ci as b,oi as x}from"./model-BIVmcl_N.js";import{n as S,t as C}from"./extra-usage-CjaHpu8y.js";import{n as w,t as T}from"./upgrade-yNl7EO4e.js";function E({onDone:e,context:t}){let[n,r]=(0,O.useState)(null),a=u(),c=g(),d=v(),f=_()?.hasExtraUsageEnabled===!0,p=c===`max`&&d===`default_claude_max_20x`,m=c===`team`||c===`enterprise`,y=(0,O.useMemo)(()=>{let e=[];if(s.isEnabled()){let t=x(),n=m&&!t,r=a.overageDisabledReason===`out_of_credits`||a.overageDisabledReason===`org_level_disabled_until`||a.overageDisabledReason===`org_service_zero_credit_limit`;if(!(n&&r)){let t=a.overageStatus===`rejected`||a.overageStatus===`allowed_warning`,r;r=n?t?`Request more`:`Request extra usage`:f?`Add funds to continue with extra usage`:`Switch to extra usage`,e.push({label:r,value:`extra-usage`})}}return!p&&!m&&l.isEnabled()&&e.push({label:`Upgrade your plan`,value:`upgrade`}),[{label:`Stop and wait for limit to reset`,value:`cancel`},...e]},[!1,p,m,f,a.overageStatus,a.overageDisabledReason]);function b(){h(`tengu_rate_limit_options_menu_cancel`,{}),e(void 0,{display:`skip`})}function S(n){n===`upgrade`?(h(`tengu_rate_limit_options_menu_select_upgrade`,{}),T(e,t).then(e=>{e&&r(e)})):n===`extra-usage`?(h(`tengu_rate_limit_options_menu_select_extra_usage`,{}),C(e,t).then(e=>{e&&r(e)})):n===`cancel`&&b()}return n||(0,k.jsx)(i,{title:`What do you want to do?`,onCancel:b,color:`suggestion`,children:(0,k.jsx)(o,{options:y,onChange:S,visibleOptionCount:y.length})})}async function D(e,t){return(0,k.jsx)(E,{onDone:e,context:t})}var O,k;e((()=>{O=t(n(),1),p(),r(),m(),f(),y(),b(),S(),d(),c(),w(),k=a()}))();export{D as call};
@@ -1,4 +1,4 @@
1
- import{n as e,r as t}from"./rolldown-runtime-DaDcL9Zw.js";import{l as n,o as r}from"./envUtils-DSxRz_kt.js";import{en as i,gt as a,ht as o,sr as s,z as c}from"./state-ix0xIunV.js";import{F as l,a as u,d,l as f,nt as p,p as m,rt as h,z as g}from"./debug-BrXObCdR.js";import{M as _,j as ee}from"./git-Do0wJvux.js";import{Fr as te,Ir as ne,Nr as v,Pr as re}from"./model-fi472PRc.js";import{join as ie}from"node:path";import{appendFileSync as ae,existsSync as oe,mkdirSync as se}from"node:fs";import{homedir as ce}from"node:os";import{randomUUID as y}from"crypto";var le=e((()=>{})),ue,de=e((()=>{ue={input_tokens:0,cache_creation_input_tokens:0,cache_read_input_tokens:0,output_tokens:0,server_tool_use:{web_search_requests:0,web_fetch_requests:0},service_tier:`standard`,cache_creation:{ephemeral_1h_input_tokens:0,ephemeral_5m_input_tokens:0},inference_geo:``,iterations:[],speed:`standard`}})),fe=e((()=>{}));function pe(e){return e}var me=e((()=>{})),he=e((()=>{le(),de(),fe(),me()}));function ge(e){return/haiku/i.test(e)?`haiku`:/opus/i.test(e)?`opus`:/sonnet/i.test(e)?`sonnet`:null}function _e(e){if(process.env.OPENAI_MODEL)return process.env.OPENAI_MODEL;let t=e.replace(/\[1m\]$/,``),n=ge(t);if(n){let e=`OPENAI_DEFAULT_${n.toUpperCase()}_MODEL`,t=process.env[e];if(t)return t;let r=`ANTHROPIC_DEFAULT_${n.toUpperCase()}_MODEL`,i=process.env[r];if(i)return i}return ve[t]??t}var ve,ye=e((()=>{ve={"claude-sonnet-4-20250514":`gpt-4o`,"claude-sonnet-4-5-20250929":`gpt-4o`,"claude-sonnet-4-6":`gpt-4o`,"claude-opus-4-20250514":`o3`,"claude-opus-4-1-20250805":`o3`,"claude-opus-4-5-20251101":`o3`,"claude-opus-4-6":`o3`,"claude-haiku-4-5-20251001":`gpt-4o-mini`,"claude-3-5-haiku-20241022":`gpt-4o-mini`,"claude-3-7-sonnet-20250219":`gpt-4o`,"claude-3-5-sonnet-20241022":`gpt-4o`}}));function be(e){return/haiku/i.test(e)?`haiku`:/opus/i.test(e)?`opus`:/sonnet/i.test(e)?`sonnet`:null}function xe(){let e=process.env.GROK_MODEL_MAP;if(!e)return null;try{let t=JSON.parse(e);if(t&&typeof t==`object`&&!Array.isArray(t))return t}catch{}return null}function Se(e){if(process.env.GROK_MODEL)return process.env.GROK_MODEL;let t=e.replace(/\[1m\]$/,``),n=be(t),r=xe();if(r&&n&&r[n])return r[n];if(n){let e=`GROK_DEFAULT_${n.toUpperCase()}_MODEL`,t=process.env[e];if(t)return t;let r=`ANTHROPIC_DEFAULT_${n.toUpperCase()}_MODEL`,i=process.env[r];if(i)return i}return b[t]?b[t]:n&&x[n]?x[n]:t}var b,x,Ce=e((()=>{b={"claude-sonnet-4-20250514":`grok-3-mini-fast`,"claude-sonnet-4-5-20250929":`grok-3-mini-fast`,"claude-sonnet-4-6":`grok-3-mini-fast`,"claude-opus-4-20250514":`grok-4.20-reasoning`,"claude-opus-4-1-20250805":`grok-4.20-reasoning`,"claude-opus-4-5-20251101":`grok-4.20-reasoning`,"claude-opus-4-6":`grok-4.20-reasoning`,"claude-haiku-4-5-20251001":`grok-3-mini-fast`,"claude-3-5-haiku-20241022":`grok-3-mini-fast`,"claude-3-7-sonnet-20250219":`grok-3-mini-fast`,"claude-3-5-sonnet-20241022":`grok-3-mini-fast`},x={opus:`grok-4.20-reasoning`,sonnet:`grok-3-mini-fast`,haiku:`grok-3-mini-fast`}}));function we(e){return/haiku/i.test(e)?`haiku`:/opus/i.test(e)?`opus`:/sonnet/i.test(e)?`sonnet`:null}function Te(e){if(process.env.GEMINI_MODEL)return process.env.GEMINI_MODEL;let t=e.replace(/\[1m\]$/i,``),n=we(t);if(!n)return t;let r=`GEMINI_DEFAULT_${n.toUpperCase()}_MODEL`,i=process.env[r];if(i)return i;let a=`ANTHROPIC_DEFAULT_${n.toUpperCase()}_MODEL`,o=process.env[a];if(o)return o;throw Error(`Gemini provider requires GEMINI_MODEL or ${r} (or ${a} for backward compatibility) to be configured.`)}var Ee=e((()=>{})),S,C=e((()=>{S=`_geminiThoughtSignature`}));function w(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}function De(e,t){let n=[],r=new Map;for(let t of e){if(t.type===`assistant`){let e=je(t);e.parts.length>0&&n.push(e);let i=t.message.content;if(Array.isArray(i))for(let e of i)typeof e!=`string`&&e.type===`tool_use`&&r.set(e.id,e.name);continue}if(t.type===`user`){let e=ke(t,r);e.parts.length>0&&n.push(e)}}let i=Oe(t);return{contents:n,...i?{systemInstruction:{parts:[{text:i}]}}:{}}}function Oe(e){return!e||e.length===0?``:e.filter(Boolean).join(`
1
+ import{n as e,r as t}from"./rolldown-runtime-DaDcL9Zw.js";import{l as n,o as r}from"./envUtils-DSxRz_kt.js";import{en as i,gt as a,ht as o,sr as s,z as c}from"./state-ix0xIunV.js";import{F as l,a as u,d,l as f,nt as p,p as m,rt as h,z as g}from"./debug-BrXObCdR.js";import{M as _,j as ee}from"./git-Do0wJvux.js";import{Fr as te,Ir as ne,Nr as v,Pr as re}from"./model-BIVmcl_N.js";import{join as ie}from"node:path";import{appendFileSync as ae,existsSync as oe,mkdirSync as se}from"node:fs";import{homedir as ce}from"node:os";import{randomUUID as y}from"crypto";var le=e((()=>{})),ue,de=e((()=>{ue={input_tokens:0,cache_creation_input_tokens:0,cache_read_input_tokens:0,output_tokens:0,server_tool_use:{web_search_requests:0,web_fetch_requests:0},service_tier:`standard`,cache_creation:{ephemeral_1h_input_tokens:0,ephemeral_5m_input_tokens:0},inference_geo:``,iterations:[],speed:`standard`}})),fe=e((()=>{}));function pe(e){return e}var me=e((()=>{})),he=e((()=>{le(),de(),fe(),me()}));function ge(e){return/haiku/i.test(e)?`haiku`:/opus/i.test(e)?`opus`:/sonnet/i.test(e)?`sonnet`:null}function _e(e){if(process.env.OPENAI_MODEL)return process.env.OPENAI_MODEL;let t=e.replace(/\[1m\]$/,``),n=ge(t);if(n){let e=`OPENAI_DEFAULT_${n.toUpperCase()}_MODEL`,t=process.env[e];if(t)return t;let r=`ANTHROPIC_DEFAULT_${n.toUpperCase()}_MODEL`,i=process.env[r];if(i)return i}return ve[t]??t}var ve,ye=e((()=>{ve={"claude-sonnet-4-20250514":`gpt-4o`,"claude-sonnet-4-5-20250929":`gpt-4o`,"claude-sonnet-4-6":`gpt-4o`,"claude-opus-4-20250514":`o3`,"claude-opus-4-1-20250805":`o3`,"claude-opus-4-5-20251101":`o3`,"claude-opus-4-6":`o3`,"claude-haiku-4-5-20251001":`gpt-4o-mini`,"claude-3-5-haiku-20241022":`gpt-4o-mini`,"claude-3-7-sonnet-20250219":`gpt-4o`,"claude-3-5-sonnet-20241022":`gpt-4o`}}));function be(e){return/haiku/i.test(e)?`haiku`:/opus/i.test(e)?`opus`:/sonnet/i.test(e)?`sonnet`:null}function xe(){let e=process.env.GROK_MODEL_MAP;if(!e)return null;try{let t=JSON.parse(e);if(t&&typeof t==`object`&&!Array.isArray(t))return t}catch{}return null}function Se(e){if(process.env.GROK_MODEL)return process.env.GROK_MODEL;let t=e.replace(/\[1m\]$/,``),n=be(t),r=xe();if(r&&n&&r[n])return r[n];if(n){let e=`GROK_DEFAULT_${n.toUpperCase()}_MODEL`,t=process.env[e];if(t)return t;let r=`ANTHROPIC_DEFAULT_${n.toUpperCase()}_MODEL`,i=process.env[r];if(i)return i}return b[t]?b[t]:n&&x[n]?x[n]:t}var b,x,Ce=e((()=>{b={"claude-sonnet-4-20250514":`grok-3-mini-fast`,"claude-sonnet-4-5-20250929":`grok-3-mini-fast`,"claude-sonnet-4-6":`grok-3-mini-fast`,"claude-opus-4-20250514":`grok-4.20-reasoning`,"claude-opus-4-1-20250805":`grok-4.20-reasoning`,"claude-opus-4-5-20251101":`grok-4.20-reasoning`,"claude-opus-4-6":`grok-4.20-reasoning`,"claude-haiku-4-5-20251001":`grok-3-mini-fast`,"claude-3-5-haiku-20241022":`grok-3-mini-fast`,"claude-3-7-sonnet-20250219":`grok-3-mini-fast`,"claude-3-5-sonnet-20241022":`grok-3-mini-fast`},x={opus:`grok-4.20-reasoning`,sonnet:`grok-3-mini-fast`,haiku:`grok-3-mini-fast`}}));function we(e){return/haiku/i.test(e)?`haiku`:/opus/i.test(e)?`opus`:/sonnet/i.test(e)?`sonnet`:null}function Te(e){if(process.env.GEMINI_MODEL)return process.env.GEMINI_MODEL;let t=e.replace(/\[1m\]$/i,``),n=we(t);if(!n)return t;let r=`GEMINI_DEFAULT_${n.toUpperCase()}_MODEL`,i=process.env[r];if(i)return i;let a=`ANTHROPIC_DEFAULT_${n.toUpperCase()}_MODEL`,o=process.env[a];if(o)return o;throw Error(`Gemini provider requires GEMINI_MODEL or ${r} (or ${a} for backward compatibility) to be configured.`)}var Ee=e((()=>{})),S,C=e((()=>{S=`_geminiThoughtSignature`}));function w(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}function De(e,t){let n=[],r=new Map;for(let t of e){if(t.type===`assistant`){let e=je(t);e.parts.length>0&&n.push(e);let i=t.message.content;if(Array.isArray(i))for(let e of i)typeof e!=`string`&&e.type===`tool_use`&&r.set(e.id,e.name);continue}if(t.type===`user`){let e=ke(t,r);e.parts.length>0&&n.push(e)}}let i=Oe(t);return{contents:n,...i?{systemInstruction:{parts:[{text:i}]}}:{}}}function Oe(e){return!e||e.length===0?``:e.filter(Boolean).join(`
2
2
 
3
3
  `)}function ke(e,t){let n=e.message.content;return typeof n==`string`?{role:`user`,parts:T(n)}:Array.isArray(n)?{role:`user`,parts:n.flatMap(e=>Ae(e,t))}:{role:`user`,parts:[]}}function Ae(e,t){if(typeof e==`string`)return T(e);if(e.type===`text`)return T(e.text);if(e.type===`tool_result`){let n=e;return[{functionResponse:{name:t.get(n.tool_use_id)??n.tool_use_id,response:Pe(n)}}]}if(e.type===`image`){let t=e.source;if(t?.type===`base64`&&typeof t.data==`string`)return[{inlineData:{mimeType:t.media_type||`image/png`,data:t.data}}];if(t?.type===`url`&&typeof t.url==`string`)return T(`[image: ${t.url}]`)}return[]}function je(e){let t=e.message.content;if(typeof t==`string`)return{role:`model`,parts:T(t)};if(!Array.isArray(t))return{role:`model`,parts:[]};let n=[];for(let e of t){if(typeof e==`string`){n.push(...T(e));continue}if(e.type===`text`){n.push(...T(e.text,E(e)));continue}if(e.type===`thinking`){let t=Me(e.thinking,e.signature);t&&n.push(t);continue}if(e.type===`tool_use`){let t=e;n.push({functionCall:{name:t.name,args:Ne(t.input)},...E(e)&&{thoughtSignature:E(e)}})}}return{role:`model`,parts:n}}function T(e,t){return typeof e!=`string`||e.length===0?[]:[{text:e,...t&&{thoughtSignature:t}}]}function Me(e,t){if(!(typeof e!=`string`||e.length===0))return{text:e,thought:!0,...t&&{thoughtSignature:t}}}function Ne(e){if(typeof e==`string`){let t=w(e);return t&&typeof t==`object`&&!Array.isArray(t)?t:t===null?{}:{value:t}}return e&&typeof e==`object`&&!Array.isArray(e)?e:e===void 0?{}:{value:e}}function Pe(e){let t=Fe(e.content);return t&&typeof t==`object`&&!Array.isArray(t)?e.is_error?{...t,is_error:!0}:t:{result:t,...e.is_error?{is_error:!0}:{}}}function Fe(e){if(typeof e==`string`)return w(e)??e;if(Array.isArray(e)){let t=e.map(e=>typeof e==`string`?e:e&&typeof e==`object`&&`text`in e&&typeof e.text==`string`?e.text:``).filter(Boolean).join(`
4
4
  `);return w(t)??t}return e??``}function E(e){let t=e[S];return typeof t==`string`&&t.length>0?t:void 0}var Ie=e((()=>{C()}));function Le(e){if(typeof e==`string`)return O.has(e)?e:void 0;if(Array.isArray(e)){let t=e.filter(e=>typeof e==`string`&&O.has(e)),n=Array.from(new Set(t));return n.length===0?void 0:n.length===1?n[0]:n}}function Re(e){if(e===null)return`null`;if(Array.isArray(e))return`array`;if(typeof e==`string`)return`string`;if(typeof e==`boolean`)return`boolean`;if(typeof e==`number`)return Number.isInteger(e)?`integer`:`number`;if(typeof e==`object`)return`object`}function ze(e){let t=e.map(Re).filter(e=>e!==void 0),n=Array.from(new Set(t));if(n.length!==0)return n.length===1?n[0]:n}function Be(e){return e===void 0?[`null`]:Array.isArray(e)?e.includes(`null`)?e:[...e,`null`]:e===`null`?e:[e,`null`]}function Ve(e){if(!e||typeof e!=`object`||Array.isArray(e))return;let t=Object.entries(e).map(([e,t])=>[e,D(t)]).filter(([,e])=>Object.keys(e).length>0);if(t.length!==0)return Object.fromEntries(t)}function He(e){if(!Array.isArray(e))return;let t=e.map(e=>D(e)).filter(e=>Object.keys(e).length>0);return t.length>0?t:void 0}function D(e){if(!e||typeof e!=`object`||Array.isArray(e))return{};let t=e,n={},r=Le(t.type);t.const===void 0?Array.isArray(t.enum)&&t.enum.length>0&&(n.enum=t.enum,r=r??ze(t.enum)):(n.enum=[t.const],r=r??Re(t.const)),r||(t.properties&&typeof t.properties==`object`?r=`object`:(t.items!==void 0||t.prefixItems!==void 0)&&(r=`array`)),t.nullable===!0&&(r=Be(r)),r&&(n.type=r),typeof t.title==`string`&&(n.title=t.title),typeof t.description==`string`&&(n.description=t.description),typeof t.format==`string`&&(n.format=t.format),typeof t.pattern==`string`&&(n.pattern=t.pattern),typeof t.minimum==`number`?n.minimum=t.minimum:typeof t.exclusiveMinimum==`number`&&(n.minimum=t.exclusiveMinimum),typeof t.maximum==`number`?n.maximum=t.maximum:typeof t.exclusiveMaximum==`number`&&(n.maximum=t.exclusiveMaximum),typeof t.minItems==`number`&&(n.minItems=t.minItems),typeof t.maxItems==`number`&&(n.maxItems=t.maxItems),typeof t.minLength==`number`&&(n.minLength=t.minLength),typeof t.maxLength==`number`&&(n.maxLength=t.maxLength),typeof t.minProperties==`number`&&(n.minProperties=t.minProperties),typeof t.maxProperties==`number`&&(n.maxProperties=t.maxProperties);let i=Ve(t.properties);if(i&&(n.properties=i,n.propertyOrdering=Object.keys(i)),Array.isArray(t.required)){let e=t.required.filter(e=>typeof e==`string`);e.length>0&&(n.required=e)}if(typeof t.additionalProperties==`boolean`)n.additionalProperties=t.additionalProperties;else{let e=D(t.additionalProperties);Object.keys(e).length>0&&(n.additionalProperties=e)}let a=D(t.items);Object.keys(a).length>0&&(n.items=a);let o=He(t.prefixItems);o&&(n.prefixItems=o);let s=He(t.anyOf??t.oneOf);return s&&(n.anyOf=s),n}function Ue(e){let t=D(e);return Object.keys(t).length>0?t:{type:`object`,properties:{}}}function We(e){let t=e.filter(e=>{let t=e.type;return e.type===`custom`||!(`type`in e)||t!==`server`}).map(e=>{let t=e;return{name:t.name||``,description:t.description||``,parametersJsonSchema:Ue(t.input_schema??{type:`object`,properties:{}})}});return t.length>0?[{functionDeclarations:t}]:[]}function Ge(e){if(!e||typeof e!=`object`)return;let t=e;switch(t.type){case`auto`:return{mode:`AUTO`};case`any`:return{mode:`ANY`};case`tool`:return{mode:`ANY`,allowedFunctionNames:typeof t.name==`string`?[t.name]:void 0};default:return}}var O,Ke=e((()=>{O=new Set([`string`,`number`,`integer`,`boolean`,`object`,`array`,`null`])}));async function*qe(e,t){let n=`msg_${y().replace(/-/g,``).slice(0,24)}`,r=!1,i=!1,a=0,o=null,s=!1,c,l=0,u=0,d=0;for await(let i of e){let e=i.usageMetadata;e&&(l=e.promptTokenCount??l,u=(e.candidatesTokenCount??0)+(e.thoughtsTokenCount??0),d=e.cachedContentTokenCount??d),r||(r=!0,yield{type:`message_start`,message:{id:n,type:`message`,role:`assistant`,content:[],model:t,stop_reason:null,stop_sequence:null,usage:{input_tokens:l,output_tokens:0,cache_creation_input_tokens:0,cache_read_input_tokens:d}}});let f=i.candidates?.[0],p=f?.content?.parts??[];for(let e of p){if(e.functionCall){o&&(yield{type:`content_block_stop`,index:o.index},o=null),s=!0;let t=a++;yield{type:`content_block_start`,index:t,content_block:{type:`tool_use`,id:`toolu_${y().replace(/-/g,``).slice(0,24)}`,name:e.functionCall.name||``,input:{}}},e.thoughtSignature&&(yield{type:`content_block_delta`,index:t,delta:{type:`signature_delta`,signature:e.thoughtSignature}}),e.functionCall.args&&Object.keys(e.functionCall.args).length>0&&(yield{type:`content_block_delta`,index:t,delta:{type:`input_json_delta`,partial_json:JSON.stringify(e.functionCall.args)}}),yield{type:`content_block_stop`,index:t};continue}let t=Je(e);if(t){(!o||o.type!==t)&&(o&&(yield{type:`content_block_stop`,index:o.index}),o={index:a++,type:t},yield{type:`content_block_start`,index:o.index,content_block:t===`thinking`?{type:`thinking`,thinking:``,signature:``}:{type:`text`,text:``}}),e.text&&(yield{type:`content_block_delta`,index:o.index,delta:t===`thinking`?{type:`thinking_delta`,thinking:e.text}:{type:`text_delta`,text:e.text}}),e.thoughtSignature&&(yield{type:`content_block_delta`,index:o.index,delta:{type:`signature_delta`,signature:e.thoughtSignature}});continue}e.thoughtSignature&&o&&(yield{type:`content_block_delta`,index:o.index,delta:{type:`signature_delta`,signature:e.thoughtSignature}})}f?.finishReason&&(c=f.finishReason)}r&&(o&&(yield{type:`content_block_stop`,index:o.index}),i||(yield{type:`message_delta`,delta:{stop_reason:Ye(c,s),stop_sequence:null},usage:{input_tokens:l,output_tokens:u,cache_creation_input_tokens:0,cache_read_input_tokens:d}},yield{type:`message_stop`},i=!0))}function Je(e){return typeof e.text==`string`?e.thought?`thinking`:`text`:null}function Ye(e,t){switch(e){case`MAX_TOKENS`:return`max_tokens`;default:return t?`tool_use`:`end_turn`}}var Xe=e((()=>{}));function k(e){if(!e||typeof e!=`object`)return null;let t=e,n=0;for(;t&&n<5;){if(t instanceof Error&&`code`in t&&typeof t.code==`string`){let e=t.code,n=nt.has(e);return{code:e,message:t.message,isSSLError:n}}if(t instanceof Error&&`cause`in t&&t.cause!==t)t=t.cause,n++;else break}return null}function Ze(e){let t=k(e);return t?.isSSLError?`SSL certificate error (${t.code}). If you are behind a corporate proxy or TLS-intercepting firewall, set NODE_EXTRA_CA_CERTS to your CA bundle path, or ask IT to allowlist *.anthropic.com. Run /doctor for details.`:null}function A(e){if(e.includes(`<!DOCTYPE html`)||e.includes(`<html`)){let t=e.match(/<title>([^<]+)<\/title>/);return t&&t[1]?t[1].trim():``}return e}function Qe(e){let t=e.message;return t?A(t):``}function $e(e){return typeof e==`object`&&!!e&&`error`in e&&typeof e.error==`object`&&e.error!==null}function et(e){if(!$e(e))return null;let t=e.error,n=t?.error?.message;if(typeof n==`string`&&n.length>0){let e=A(n);if(e.length>0)return e}let r=t?.message;if(typeof r==`string`&&r.length>0){let e=A(r);if(e.length>0)return e}return null}function tt(e){let t=k(e);if(t){let{code:e,isSSLError:n}=t;if(e===`ETIMEDOUT`)return`Request timed out. Check your internet connection and proxy settings`;if(n)switch(e){case`UNABLE_TO_VERIFY_LEAF_SIGNATURE`:case`UNABLE_TO_GET_ISSUER_CERT`:case`UNABLE_TO_GET_ISSUER_CERT_LOCALLY`:return`Unable to connect to API: SSL certificate verification failed. Check your proxy or corporate SSL certificates`;case`CERT_HAS_EXPIRED`:return`Unable to connect to API: SSL certificate has expired`;case`CERT_REVOKED`:return`Unable to connect to API: SSL certificate has been revoked`;case`DEPTH_ZERO_SELF_SIGNED_CERT`:case`SELF_SIGNED_CERT_IN_CHAIN`:return`Unable to connect to API: Self-signed certificate detected. Check your proxy or corporate SSL certificates`;case`ERR_TLS_CERT_ALTNAME_INVALID`:case`HOSTNAME_MISMATCH`:return`Unable to connect to API: SSL certificate hostname mismatch`;case`CERT_NOT_YET_VALID`:return`Unable to connect to API: SSL certificate is not yet valid`;default:return`Unable to connect to API: SSL error (${e})`}}if(e.message===`Connection error.`)return t?.code?`Unable to connect to API (${t.code})`:`Unable to connect to API. Check your internet connection`;if(!e.message)return et(e)??`API error (status ${e.status??`unknown`})`;let n=Qe(e);return n!==e.message&&n.length>0?n:e.message}var nt,rt=e((()=>{nt=new Set([`UNABLE_TO_VERIFY_LEAF_SIGNATURE`,`UNABLE_TO_GET_ISSUER_CERT`,`UNABLE_TO_GET_ISSUER_CERT_LOCALLY`,`CERT_SIGNATURE_FAILURE`,`CERT_NOT_YET_VALID`,`CERT_HAS_EXPIRED`,`CERT_REVOKED`,`CERT_REJECTED`,`CERT_UNTRUSTED`,`DEPTH_ZERO_SELF_SIGNED_CERT`,`SELF_SIGNED_CERT_IN_CHAIN`,`CERT_CHAIN_TOO_LONG`,`PATH_LENGTH_EXCEEDED`,`ERR_TLS_CERT_ALTNAME_INVALID`,`HOSTNAME_MISMATCH`,`ERR_TLS_HANDSHAKE_TIMEOUT`,`ERR_SSL_WRONG_VERSION_NUMBER`,`ERR_SSL_DECRYPTION_FAILED_OR_BAD_RECORD_MAC`])}));function it(e,t,n){let r=[],i=at(t);i&&r.push({role:`system`,content:i});for(let t of e)switch(t.type){case`user`:r.push(...ot(t));break;case`assistant`:r.push(...ct(t));break;default:break}return r}function at(e){return!e||e.length===0?``:e.filter(Boolean).join(`