@readmagic/workmate 0.0.2 → 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.
- package/dist/chunks/{AddWorkspaceDirectory-BgNp7glC.js → AddWorkspaceDirectory-BTC7FPqM.js} +1 -1
- package/dist/chunks/{App-Coboqa8H.js → App-DOm71vtY.js} +1 -1
- package/dist/chunks/{ApproveApiKey-CYpBbj0k.js → ApproveApiKey-9YQzwrrC.js} +1 -1
- package/dist/chunks/ApproveApiKey-LPrZMlgU.js +1 -0
- package/dist/chunks/{AssistantSessionChooser-DxKsTdqj.js → AssistantSessionChooser-CnYfFWrx.js} +1 -1
- package/dist/chunks/BackgroundTasksDialog-D_UHm7xo.js +2 -0
- package/dist/chunks/{BypassPermissionsModeDialog-Cx3QGFz-.js → BypassPermissionsModeDialog-DAq-qbqC.js} +1 -1
- package/dist/chunks/ClaudeMdExternalIncludesDialog--w2zWWEn.js +1 -0
- package/dist/chunks/{ClaudeMdExternalIncludesDialog-BAK9fxwg.js → ClaudeMdExternalIncludesDialog-CyvidoR3.js} +1 -1
- package/dist/chunks/ConsoleOAuthFlow-BXdC6j3_.js +1 -0
- package/dist/chunks/{DesktopHandoff-BsHgLlTy.js → DesktopHandoff-gRvy-WlW.js} +1 -1
- package/dist/chunks/{DiffDialog-BgTW2Znv.js → DiffDialog-CdfVTgOx.js} +2 -2
- package/dist/chunks/Doctor-BuiYwjAS.js +1 -0
- package/dist/chunks/Doctor-DKlHJBXq.js +3 -0
- package/dist/chunks/ExitFlow-rExuBL3w.js +2 -0
- package/dist/chunks/Feedback-gGpjUC_F.js +2 -0
- package/dist/chunks/{Grove-Dsi4yU08.js → Grove-CD769Wvw.js} +1 -1
- package/dist/chunks/Grove-ENfM8hC6.js +1 -0
- package/dist/chunks/{HybridTransport-8qA64lCx.js → HybridTransport-kN1jmg26.js} +4 -4
- package/dist/chunks/{InvalidConfigDialog-CAZ1z5WG.js → InvalidConfigDialog-BpJub73a.js} +1 -1
- package/dist/chunks/{InvalidSettingsDialog-D82Qk_MR.js → InvalidSettingsDialog-DzOp3Ihx.js} +1 -1
- package/dist/chunks/MCPConnectionManager-CaBvO7NB.js +1 -0
- package/dist/chunks/{McpParsingWarnings-8ZueNqAd.js → McpParsingWarnings-Cc6FWyU4.js} +1 -1
- package/dist/chunks/MessageSelector-DOB1S2-O.js +3 -0
- package/dist/chunks/Messages-Clihwd2F.js +11 -0
- package/dist/chunks/{Onboarding-CUztnbbv.js → Onboarding-D00lTweB.js} +1 -1
- package/dist/chunks/{OverageCreditUpsell-DSgrZvMv.js → OverageCreditUpsell-B-Bf_-UX.js} +1 -1
- package/dist/chunks/PluginSettings-DUxj_oAg.js +17 -0
- package/dist/chunks/{PromptInputFooterSuggestions-IaihWay3.js → PromptInputFooterSuggestions-MwS_cExV.js} +1 -1
- package/dist/chunks/{PromptInputHelpMenu-okS2rQ4k.js → PromptInputHelpMenu-V2dEpzhC.js} +1 -1
- package/dist/chunks/QueryEngine-BLcPQYq_.js +1 -0
- package/dist/chunks/{REPL-Dto012J0.js → REPL-B_E07dnf.js} +44 -44
- package/dist/chunks/REPL-BhURgntS.js +1 -0
- package/dist/chunks/{RemoteCallout-C_UIYnuT.js → RemoteCallout-ChCjmgw1.js} +1 -1
- package/dist/chunks/{RemoteSessionManager-CuSSHAXN.js → RemoteSessionManager-B43isWQs.js} +2 -2
- package/dist/chunks/ResumeConversation-DaQ9n8_C.js +1 -0
- package/dist/chunks/{SSETransport-Chj_yfPv.js → SSETransport-h43pQVlJ.js} +3 -3
- package/dist/chunks/SearchExtraToolsTool-DSq7beKs.js +1 -0
- package/dist/chunks/Settings-CNsaWv8g.js +2 -0
- package/dist/chunks/{TeleportProgress-DP1a8jit.js → TeleportProgress-QtJrXSCX.js} +1 -1
- package/dist/chunks/{TeleportRepoMismatchDialog-B6sTwXuZ.js → TeleportRepoMismatchDialog-D-HVj-A6.js} +1 -1
- package/dist/chunks/{TeleportResumeWrapper-CKUuRQSG.js → TeleportResumeWrapper-C6sbzJsJ.js} +1 -1
- package/dist/chunks/{ThemePicker-Dyq1YVhb.js → ThemePicker-CqPCp5Hs.js} +1 -1
- package/dist/chunks/TrustDialog-CeVwxDlZ.js +1 -0
- package/dist/chunks/{ValidationErrorsList-DUNh4BNa.js → ValidationErrorsList-Bl68E-2-.js} +1 -1
- package/dist/chunks/{WelcomeV2-TPbOXGrO.js → WelcomeV2-DNiXQ5ES.js} +1 -1
- package/dist/chunks/{add-dir-Bf_5tCeR.js → add-dir-V3xjklnJ.js} +1 -1
- package/dist/chunks/{agentDisplay-CCeYiAta.js → agentDisplay-BuiwcrQi.js} +1 -1
- package/dist/chunks/{agents-Bt72Gz1v.js → agents-D7um1IXM.js} +7 -7
- package/dist/chunks/{agents-T8xHY5Wk.js → agents-ZY6IaVE7.js} +1 -1
- package/dist/chunks/{allErrors-CDWTJcMw.js → allErrors-CHVdQ3fT.js} +1 -1
- package/dist/chunks/{ant-DRF-v5bA.js → ant-D66LZCap.js} +1 -1
- package/dist/chunks/api-C-rOQY-l.js +1 -0
- package/dist/chunks/api-Dmn7DUgU.js +1 -0
- package/dist/chunks/asciicast-BsWpcxrc.js +1 -0
- package/dist/chunks/{asciicast-CQJlNTae.js → asciicast-CbAjUHT_.js} +4 -4
- package/dist/chunks/{assistant-z1ojxEET.js → assistant-CYF7ch7C.js} +1 -1
- package/dist/chunks/auth-C4Rvit2q.js +1 -0
- package/dist/chunks/auth-Cj7EX1eG.js +1 -0
- package/dist/chunks/auth-DAxGNCIR.js +15 -0
- package/dist/chunks/{autoMode-DW_H3i37.js → autoMode-TysBQkU_.js} +5 -5
- package/dist/chunks/{autonomy-OxhciwYa.js → autonomy-CNEbT-t_.js} +7 -7
- package/dist/chunks/{autonomy-46hnmyAi.js → autonomy-k3QPea5z.js} +1 -1
- package/dist/chunks/{autonomyPanel-CTEjq0Bd.js → autonomyPanel-DiztRblF.js} +1 -1
- package/dist/chunks/{backgroundHousekeeping-Cpxq4krt.js → backgroundHousekeeping-C9m4tiFi.js} +3 -3
- package/dist/chunks/backgroundHousekeeping-DQjzXBe0.js +1 -0
- package/dist/chunks/{banner-BVkLvJiB.js → banner-CWkrK10u.js} +1 -1
- package/dist/chunks/bg-B0iMGM9C.js +1 -0
- package/dist/chunks/{bg-zWGqkcST.js → bg-WnYN5ifx.js} +2 -2
- package/dist/chunks/{branch-DJzijRGm.js → branch-_NBgDfrK.js} +1 -1
- package/dist/chunks/{bridge-Dpr2AWpc.js → bridge-DpmFl8p8.js} +2 -2
- package/dist/chunks/{bridgeConfig-DDF3teRE.js → bridgeConfig-DMBOO3gW.js} +1 -1
- package/dist/chunks/bridgeConfig-DsI5d0s7.js +1 -0
- package/dist/chunks/bridgeEnabled-DZzlF2d8.js +1 -0
- package/dist/chunks/{bridgeEnabled-D4JDZd0y.js → bridgeEnabled-FjPuA7zx.js} +1 -1
- package/dist/chunks/bridgeMain-BppY0KW3.js +68 -0
- package/dist/chunks/bridgeMain-BrY4tkF6.js +1 -0
- package/dist/chunks/bridgeMessaging-N5zlzCCr.js +1 -0
- package/dist/chunks/bridgePointer-MqLe5Asm.js +1 -0
- package/dist/chunks/{browser-BKiu1max.js → browser-BmZuQom6.js} +1 -1
- package/dist/chunks/{btw-DG9CCeq4.js → btw-BFRje_Zi.js} +1 -1
- package/dist/chunks/caches-BBLH8G1I.js +1 -0
- package/dist/chunks/{caches-BB5_91gU.js → caches-CcfPJ4_A.js} +2 -2
- package/dist/chunks/ccrClient-q2JCVCU2.js +1 -0
- package/dist/chunks/{claudeDesktop-9xfIgkzE.js → claudeDesktop-Cx31Ugjp.js} +1 -1
- package/dist/chunks/{clear-ueMvDelv.js → clear-CxY7W5Wt.js} +1 -1
- package/dist/chunks/{cliLaunch-BJ9o-rIV.js → cliLaunch-BkPAatcs.js} +1 -1
- package/dist/chunks/client-CtVu3BLD.js +1 -0
- package/dist/chunks/{color-B0-MIfsq.js → color-DOWhfjnA.js} +1 -1
- package/dist/chunks/commands-BWw1sQeH.js +1 -0
- package/dist/chunks/{commitAttribution-DKun9CeU.js → commitAttribution-CLbEIaRJ.js} +2 -2
- package/dist/chunks/commitAttribution-DIT_s0vY.js +1 -0
- package/dist/chunks/compact-CaOnQVkH.js +2 -0
- package/dist/chunks/{completionCache-CdHCuiqq.js → completionCache-MN3_MqK8.js} +2 -2
- package/dist/chunks/completionCache-c4aiyZ_f.js +1 -0
- package/dist/chunks/config-DiT2Z8dY.js +3 -0
- package/dist/chunks/config-DmPGzNmi.js +1 -0
- package/dist/chunks/config-HHTwEsWp.js +1 -0
- package/dist/chunks/{context-DBswG0EY.js → context-B2OvKo2t.js} +1 -1
- package/dist/chunks/context-noninteractive-BilCSCV1.js +1 -0
- package/dist/chunks/{context-noninteractive-CTvyNimw.js → context-noninteractive-BuGxX3YL.js} +2 -2
- package/dist/chunks/conversation-BWXf3un9.js +1 -0
- package/dist/chunks/conversation-awh8AwwL.js +1 -0
- package/dist/chunks/{createSSHSession-BdO35H6o.js → createSSHSession-C-c7I5iJ.js} +5 -5
- package/dist/chunks/{createSession-Br1g8qSD.js → createSession-D_fIDqgc.js} +1 -1
- package/dist/chunks/createSession-Hvpx3Le7.js +1 -0
- package/dist/chunks/crossProjectResume-_XjvSXA3.js +40 -0
- package/dist/chunks/{daemon-BQiSFjc-.js → daemon-YtZbMQtn.js} +1 -1
- package/dist/chunks/datadog-Ed8emSFA.js +1 -0
- package/dist/chunks/{debug-DiuXEmUq.js → debug-BrXObCdR.js} +1 -1
- package/dist/chunks/{debugUtils-3YYWvb3H.js → debugUtils-NO5KtXqi.js} +1 -1
- package/dist/chunks/{desktop-W7SA8BFk.js → desktop-D_ofPlyi.js} +1 -1
- package/dist/chunks/{detached-Cv9gAylK.js → detached-TYk4hMFj.js} +1 -1
- package/dist/chunks/{detectRepository-B1PMTLAU.js → detectRepository-BPr0VWNO.js} +1 -1
- package/dist/chunks/detectRepository-BTPgN89l.js +1 -0
- package/dist/chunks/{diff-CMtRjFUb.js → diff-CUAgBDu1.js} +1 -1
- package/dist/chunks/{directoryCompletion-CeV63gvu.js → directoryCompletion-CW2ckkQg.js} +1 -1
- package/dist/chunks/doctor-CkdQ7Fv7.js +1 -0
- package/dist/chunks/{effort-BAlVDBHq.js → effort-DCgooYMY.js} +2 -2
- package/dist/chunks/{entry-DLqeVq5C.js → entry-Bh0gPOAo.js} +4 -4
- package/dist/chunks/envLessBridgeConfig-DJHZAlU-.js +1 -0
- package/dist/chunks/envLessBridgeConfig-sxodu0xO.js +1 -0
- package/dist/chunks/esm-B62dCLgf.js +1 -0
- package/dist/chunks/{execFileNoThrow-DResQRvR.js → execFileNoThrow-D244NytW.js} +1 -1
- package/dist/chunks/execSyncWrapper-CCMQShK-.js +1 -0
- package/dist/chunks/exit-CFJR3NfE.js +1 -0
- package/dist/chunks/extra-usage-CjaHpu8y.js +1 -0
- package/dist/chunks/extra-usage-D1Y-3OWQ.js +1 -0
- package/dist/chunks/{extra-usage-core-Dh4rVUI-.js → extra-usage-core-B6ga8Rni.js} +1 -1
- package/dist/chunks/{extra-usage-noninteractive-D4Ya5KPm.js → extra-usage-noninteractive-Dc9AndId.js} +1 -1
- package/dist/chunks/{extraUsage-DtWi8E78.js → extraUsage-2DwLEr26.js} +1 -1
- package/dist/chunks/extractMemories-C3qrwpu2.js +1 -0
- package/dist/chunks/{fast-DkUxqWhE.js → fast-CW_NsL0x.js} +1 -1
- package/dist/chunks/fast-D3CPmUX4.js +1 -0
- package/dist/chunks/{feedback-Cn7Sbqxa.js → feedback-BpRorTAC.js} +1 -1
- package/dist/chunks/{file-BZriE-XU.js → file-DcZWPH2V.js} +5 -5
- package/dist/chunks/firstPartyEventLogger-CuUiNdj8.js +5 -0
- package/dist/chunks/firstPartyEventLogger-DPUQnc6J.js +1 -0
- package/dist/chunks/{flushGate-ebqQZF1t.js → flushGate-BltVae97.js} +1 -1
- package/dist/chunks/gemini-YyIxfveQ.js +1 -0
- package/dist/chunks/generateRecap-tx4wLIkI.js +1 -0
- package/dist/chunks/{generateSessionName-DEAw5x_h.js → generateSessionName-BkDigIN8.js} +1 -1
- package/dist/chunks/{genericProcessUtils-DO7Fy0RJ.js → genericProcessUtils-CdQTApYX.js} +1 -1
- package/dist/chunks/git-CbcnOf0E.js +1 -0
- package/dist/chunks/git-Do0wJvux.js +6 -0
- package/dist/chunks/{githubRepoPathMapping-Tt-LdYFZ.js → githubRepoPathMapping-C4umZ1oC.js} +1 -1
- package/dist/chunks/{goal-DCaI1NPN.js → goal-DZrD4puM.js} +3 -3
- package/dist/chunks/{grok-CKlngG3b.js → grok-BZf7W_hL.js} +1 -1
- package/dist/chunks/{grove-DSWe6psK.js → grove-CFBPplP6.js} +2 -2
- package/dist/chunks/{heapdump-OVbV05On.js → heapdump-DWc3Z2NO.js} +5 -5
- package/dist/chunks/{help-CRtX5VX9.js → help-pap9jNUJ.js} +1 -1
- package/dist/chunks/{hooks-tpf90xd5.js → hooks-Bmat0L6A.js} +2 -2
- package/dist/chunks/hooks-cCAzfabs.js +1 -0
- package/dist/chunks/{hostGuard-t7QfbijF.js → hostGuard-C5xydXZI.js} +1 -1
- package/dist/chunks/inboundAttachments-DZgSqDwY.js +1 -0
- package/dist/chunks/inboundAttachments-DkfNHtF9.js +1 -0
- package/dist/chunks/initReplBridge-myzllvlk.js +1 -0
- package/dist/chunks/install-D4jmHjmk.js +1 -0
- package/dist/chunks/{instrumentation--Sx0y1Gk.js → instrumentation-Nqgm1SMw.js} +6 -6
- package/dist/chunks/{job-D7B35Usp.js → job-CT9bcgPb.js} +1 -1
- package/dist/chunks/jwtUtils-DE2GPUcx.js +1 -0
- package/dist/chunks/keybindings-DETOn3qJ.js +2 -0
- package/dist/chunks/{language-8Rnu_qxl.js → language-BA5WprZv.js} +1 -1
- package/dist/chunks/language-BbaOTWm3.js +1 -0
- package/dist/chunks/{launchAgentsPlatform-CNPkOVzu.js → launchAgentsPlatform-CuRQgd2Q.js} +1 -1
- package/dist/chunks/{launchLocalMemory-BxmDhENs.js → launchLocalMemory-CRMqifzn.js} +2 -2
- package/dist/chunks/{launchLocalVault-DQlTGA-g.js → launchLocalVault-DlKX_oDE.js} +3 -3
- package/dist/chunks/{launchMemoryStores-EYAwxI8i.js → launchMemoryStores-CN0ecWpP.js} +1 -1
- package/dist/chunks/{launchOnboarding-CTu5Zf4E.js → launchOnboarding-DTdUA_wE.js} +1 -1
- package/dist/chunks/{launchSchedule-CeHHSvO7.js → launchSchedule-psiSLmTA.js} +1 -1
- package/dist/chunks/{launchSkillStore-Bqh2Fru2.js → launchSkillStore-CQQ00Ads.js} +1 -1
- package/dist/chunks/{launchTeleport-Crc3XVZX.js → launchTeleport-CXFRPVMR.js} +1 -1
- package/dist/chunks/{launchVault-BHLgpth_.js → launchVault-Dn6jq0Rc.js} +1 -1
- package/dist/chunks/{v4-jw6qOKwQ.js → lazySchema-DcIJE_0i.js} +1 -1
- package/dist/chunks/{loadAgentsDir-ZQwvbURI.js → loadAgentsDir-BURvZNN6.js} +685 -683
- package/dist/chunks/loadAgentsDir-Db9UTm45.js +1 -0
- package/dist/chunks/loadPluginHooks-C9A9oS-w.js +1 -0
- package/dist/chunks/{localSearch-H0LchlTi.js → localSearch-D2Rs8wQP.js} +1 -1
- package/dist/chunks/localSearch-hBh1ATr2.js +1 -0
- package/dist/chunks/{log-Duzb4o6h.js → log-BMCygSzM.js} +1 -1
- package/dist/chunks/{logoV2Utils-5lcUu53m.js → logoV2Utils-DN9nzdX-.js} +1 -1
- package/dist/chunks/{magicDocs-D1FIPmYg.js → magicDocs-DIeTcwAA.js} +3 -3
- package/dist/chunks/{main-B8XtFN2P.js → main-CI54PZrG.js} +78 -78
- package/dist/chunks/{main-CR7cXdgy.js → main-D862LI_d.js} +2 -2
- package/dist/chunks/{mappers-DKU4RgE3.js → mappers-Q_Z3Kjo-.js} +1 -1
- package/dist/chunks/mcp-CtbhGaLC.js +2 -0
- package/dist/chunks/mcp-DMacvhqZ.js +1 -0
- package/dist/chunks/mcp-RvwPC7FB.js +6 -0
- package/dist/chunks/{memoize-DgMjqLtn.js → memoize-B0zhbT8Z.js} +1 -1
- package/dist/chunks/{memory-D-Q62bJ7.js → memory-BPN8gW7n.js} +1 -1
- package/dist/chunks/{mode-DFZgqKBd.js → mode-Jl_Boaym.js} +2 -2
- package/dist/chunks/model-BIVmcl_N.js +1 -0
- package/dist/chunks/{model-fDWtIRVr.js → model-CWBwPvTH.js} +1 -1
- package/dist/chunks/model-DlVpqR0P.js +1 -0
- package/dist/chunks/nativeInstaller-8arnRiUO.js +1 -0
- package/dist/chunks/{onChangeAppState-DaQ0R9Tw.js → onChangeAppState-DBantDJ6.js} +1 -1
- package/dist/chunks/{openai-DNS0-ivj.js → openai-yin1iDG8.js} +3 -3
- package/dist/chunks/{overageCreditGrant-qHN3tnp2.js → overageCreditGrant-CN_sVURL.js} +1 -1
- package/dist/chunks/{panelCall-BvKpHquo.js → panelCall-CPKC6VR5.js} +1 -1
- package/dist/chunks/parser-Bf6iasPV.js +1 -0
- package/dist/chunks/{parser-TYEkLFgh.js → parser-DFwaTGf7.js} +1 -1
- package/dist/chunks/{partition-Cv11dD5P.js → partition-CW0BJ881.js} +1 -1
- package/dist/chunks/{passes-DQdM2Ssq.js → passes-DOm9ukdK.js} +1 -1
- package/dist/chunks/{path-Cu_AKqg6.js → path-D5U-tm91.js} +1 -1
- package/dist/chunks/permissions-CxDJ__l6.js +3 -0
- package/dist/chunks/pidLock-C69HNTTb.js +3 -0
- package/dist/chunks/{pipeTransport-7GIO6GCA.js → pipeTransport-CqCnc-Ys.js} +1 -1
- package/dist/chunks/{plan-D8dQDl8W.js → plan-B0rEs32a.js} +1 -1
- package/dist/chunks/{platform-B5dCGT8t.js → platform-BrYefG_2.js} +1 -1
- package/dist/chunks/{plugin-w8MqsKHn.js → plugin-BSEMgcGu.js} +1 -1
- package/dist/chunks/{pluginAutoupdate-7FFHzSRz.js → pluginAutoupdate-CTByPD8J.js} +1 -1
- package/dist/chunks/pluginBlocklist-mogKaK0p.js +1 -0
- package/dist/chunks/pluginCliCommands-DQQ7C7kk.js +1 -0
- package/dist/chunks/{pluginFlagging-_WUQP3Lq.js → pluginFlagging-mHNff1t9.js} +1 -1
- package/dist/chunks/pluginOperations-JEedVzfS.js +2 -0
- package/dist/chunks/pluginStartupCheck-D7ts2V3p.js +1 -0
- package/dist/chunks/{pluginStartupCheck-BelpzwZI.js → pluginStartupCheck-RscVZDi4.js} +1 -1
- package/dist/chunks/plugins-Cr03lISA.js +4 -0
- package/dist/chunks/policyLimits-DWtLyJ4n.js +1 -0
- package/dist/chunks/pollConfig-DH2oCtFS.js +1 -0
- package/dist/chunks/{poor-D3T_8wwf.js → poor-DekfGNT7.js} +1 -1
- package/dist/chunks/poorMode-AE4WNYZo.js +1 -0
- package/dist/chunks/{poorMode-BqyVuBu-.js → poorMode-CtcqaiwD.js} +1 -1
- package/dist/chunks/print-CZUmAzmt.js +23 -0
- package/dist/chunks/{privacy-settings-D5zxu4Aa.js → privacy-settings-CwJ1H8Ua.js} +1 -1
- package/dist/chunks/processBashCommand-aKNneP2u.js +1 -0
- package/dist/chunks/processSlashCommand-BcPnWNxZ.js +5 -0
- package/dist/chunks/prompt-CIyhCdkE.js +1 -0
- package/dist/chunks/prompt-DNDgGM9q.js +139 -0
- package/dist/chunks/prompt-DRhjinu2.js +1 -0
- package/dist/chunks/{promptEditor-D6HzjcMS.js → promptEditor-DMJyosKj.js} +2 -2
- package/dist/chunks/{protocolHandler-BXlx1N7v.js → protocolHandler-z2zxAtB1.js} +4 -4
- package/dist/chunks/{proxy-CHnxhNZI.js → proxy-CRN7jYIi.js} +3 -3
- package/dist/chunks/{rate-limit-options-1hc-RyNR.js → rate-limit-options--Y3oF1g0.js} +1 -1
- package/dist/chunks/rcDebugLog-DoL1FpGJ.js +11 -0
- package/dist/chunks/reconciler-CJcSh6xo.js +4 -0
- package/dist/chunks/{referral-Cu9bEOFE.js → referral-UKJv23_5.js} +1 -1
- package/dist/chunks/{refresh-vJbxW4a1.js → refresh-ul_i5R1a.js} +1 -1
- package/dist/chunks/{registerProtocol-B_XbLDQO.js → registerProtocol-CukLQuxJ.js} +3 -3
- package/dist/chunks/{release-notes-CavWoMQR.js → release-notes-CGv_6MMt.js} +1 -1
- package/dist/chunks/{releaseNotes-Di6OaHF7.js → releaseNotes-BKZNuDLD.js} +2 -2
- package/dist/chunks/{reload-plugins-ofeLn07p.js → reload-plugins-2W11dpLQ.js} +1 -1
- package/dist/chunks/{remote-env-dXzHAuD6.js → remote-env-D9xsoBfx.js} +1 -1
- package/dist/chunks/remoteBridgeCore-asY9JAXU.js +1 -0
- package/dist/chunks/remoteManagedSettings-Bxo3bv1U.js +1 -0
- package/dist/chunks/{rename-CtjP0lop.js → rename-CHsHMWpO.js} +1 -1
- package/dist/chunks/{renderOptions-DOXmueQV.js → renderOptions-BUJB9nAm.js} +1 -1
- package/dist/chunks/{resume-C5h5JvY1.js → resume-NduOaghx.js} +2 -2
- package/dist/chunks/{ripgrep-BN_g-F7X.js → ripgrep-BXmXjAzA.js} +1 -1
- package/dist/chunks/ripgrep-BfIpz5uC.js +1 -0
- package/dist/chunks/{runtimeObserver-B93v1AxE.js → runtimeObserver-BXbjibFk.js} +4 -4
- package/dist/chunks/{runtimeObserver-DOZFrqJu.js → runtimeObserver-Bo80nWQf.js} +1 -1
- package/dist/chunks/sandbox-adapter-DDfVl_2V.js +1 -0
- package/dist/chunks/{sandbox-toggle-TiLGFwaZ.js → sandbox-toggle-C-WCDRN4.js} +1 -1
- package/dist/chunks/searchExtraTools-BHWzsbNO.js +1 -0
- package/dist/chunks/{session-v9tKHhU9.js → session-pDd13-wE.js} +2 -2
- package/dist/chunks/{sessionDiscovery-4byQKOnc.js → sessionDiscovery-CSUnpsCy.js} +1 -1
- package/dist/chunks/sessionFileAccessHooks-BZvxeufx.js +1 -0
- package/dist/chunks/sessionMemory-CAmpw2yb.js +1 -0
- package/dist/chunks/sessionMemory-DT0IkiA1.js +1 -0
- package/dist/chunks/sessionMemoryUtils-B4kGNH4j.js +1 -0
- package/dist/chunks/{sessionObserver-OgY9BUP4.js → sessionObserver-Ur7PqKl_.js} +1 -1
- package/dist/chunks/sessionObserver-oIkwTidC.js +1 -0
- package/dist/chunks/sessionStorage-DqARUj0K.js +1 -0
- package/dist/chunks/sessionTitle-pWMaI79N.js +14 -0
- package/dist/chunks/{sessionTracing-BBxhPccY.js → sessionTracing-CCPRzOvy.js} +3 -3
- package/dist/chunks/settings-DfWP5y6X.js +19 -0
- package/dist/chunks/settingsSync-D_4P3Esd.js +1 -0
- package/dist/chunks/setup-JHvhWKh9.js +3 -0
- package/dist/chunks/{shadowedRuleDetection-DDSOFi1W.js → shadowedRuleDetection-Chi3afMR.js} +1 -1
- package/dist/chunks/{shellQuote-yXoC_y5m.js → shellQuote-DkSy9MYE.js} +1 -1
- package/dist/chunks/{sideQuestion-CAiA6jAf.js → sideQuestion-D03MXdE2.js} +1 -1
- package/dist/chunks/sinks-B4_pw0Gb.js +2 -0
- package/dist/chunks/sinks-Cro1Y8C2.js +1 -0
- package/dist/chunks/{skill-learning-Dx1o4mMo.js → skill-learning-7ZQF5JvA.js} +1 -1
- package/dist/chunks/skillChangeDetector-uCaYrerZ.js +1 -0
- package/dist/chunks/{skillGapStore-BV_6qzxU.js → skillGapStore-BND2Lq0Z.js} +1 -1
- package/dist/chunks/{skillGapStore-Zvqiyxds.js → skillGapStore-z3LP64O-.js} +2 -2
- package/dist/chunks/{skillGenerator-jJQDphQ8.js → skillGenerator-DaNb-yKH.js} +2 -2
- package/dist/chunks/skillLearning-GZxYPlyl.js +1 -0
- package/dist/chunks/{skillLearning-BTT3_yGc.js → skillLearning-rMX1bSBa.js} +1 -1
- package/dist/chunks/{skillPanel-OW2M6SZr.js → skillPanel-q7GPSQ6_.js} +3 -3
- package/dist/chunks/{skillSearchPanel-C0Y56c5N.js → skillSearchPanel-oj8gy1ZL.js} +4 -4
- package/dist/chunks/{skills-BFsyLP33.js → skills-QqbeFP0s.js} +1 -1
- package/dist/chunks/startupProfiler-DIWVcO4e.js +1 -0
- package/dist/chunks/{startupProfiler-BquH_Yqm.js → startupProfiler-xa3NmN7Z.js} +2 -2
- package/dist/chunks/{stats-CrPmPT8f.js → stats-DmFubHpI.js} +1 -1
- package/dist/chunks/{status-BO5J2MAe.js → status-BEIsLmfj.js} +1 -1
- package/dist/chunks/{status-DHJbK4pV.js → status-DW3Z_7xa.js} +2 -2
- package/dist/chunks/{statusNoticeHelpers-CqeUBySi.js → statusNoticeHelpers-CaHS8xig.js} +1 -1
- package/dist/chunks/{stickers-BLFmyHZV.js → stickers-D5teCKMN.js} +1 -1
- package/dist/chunks/{stringUtils-D_g2L6A4.js → stringUtils-DGLPkqJ4.js} +1 -1
- package/dist/chunks/{tag-M2AEtXjW.js → tag-CRg93Die.js} +2 -2
- package/dist/chunks/{tasks-CoOs_Qkj.js → tasks-BEohK1ij.js} +1 -1
- package/dist/chunks/teleport-4Srg5vcP.js +1 -0
- package/dist/chunks/{templateJobs-Cl50Qw0s.js → templateJobs-DYP1fjYU.js} +1 -1
- package/dist/chunks/terminalSetup-BNs9nLbT.js +33 -0
- package/dist/chunks/{terminalSetup-Bdh9K31U.js → terminalSetup-RDKg8dVa.js} +1 -1
- package/dist/chunks/{theme-DgCIr0jU.js → theme-kNL4kl_3.js} +1 -1
- package/dist/chunks/{thinkback-ERCQ86CR.js → thinkback-gV-sKkMM.js} +1 -1
- package/dist/chunks/thinkback-hc5eJ9ul.js +1 -0
- package/dist/chunks/thinkback-play-BpWMqbgJ.js +1 -0
- package/dist/chunks/{tmux-ZZk68JBq.js → tmux-BY7IdQ1f.js} +1 -1
- package/dist/chunks/{toolEventObserver-9-5Ne25Z.js → toolEventObserver-C98uraqD.js} +1 -1
- package/dist/chunks/{toolEventObserver-9XCQXiMx.js → toolEventObserver-ar5NDa0M.js} +1 -1
- package/dist/chunks/toolPool-CNYKDRq5.js +1 -0
- package/dist/chunks/trustedDevice-0dehm9qz.js +1 -0
- package/dist/chunks/trustedDevice-BBKUhCCL.js +1 -0
- package/dist/chunks/{types-Cnorfsss.js → types-C-MRCL8J.js} +3 -3
- package/dist/chunks/udsClient-BuCtv7dN.js +1 -0
- package/dist/chunks/{ultrareviewCommand-BMBHepdu.js → ultrareviewCommand-yXlFsMnv.js} +2 -2
- package/dist/chunks/{undercover-DDgIKbO5.js → undercover-BTIRVF1t.js} +1 -1
- package/dist/chunks/undercover-CG_269xD.js +1 -0
- package/dist/chunks/{up-D6bNw_tT.js → up-BHkC97_C.js} +1 -1
- package/dist/chunks/updateCCB-B2xAJ4Nr.js +11 -0
- package/dist/chunks/upgrade-J7lKLkD2.js +1 -0
- package/dist/chunks/{upgrade-BN20nsCH.js → upgrade-yNl7EO4e.js} +1 -1
- package/dist/chunks/upload-BWVIHmMB.js +1 -0
- package/dist/chunks/{upstreamproxy-os5rw0Vg.js → upstreamproxy-DyR_eXO8.js} +4 -4
- package/dist/chunks/{usage-D_sqm8us.js → usage-B2PbCUMi.js} +1 -1
- package/dist/chunks/usage-Ck8Cu45g.js +1 -0
- package/dist/chunks/{useExitOnCtrlCDWithKeybindings-vzUoPY51.js → useExitOnCtrlCDWithKeybindings-CV4GZ-sq.js} +1 -1
- package/dist/chunks/useMainLoopModel-CO4yBjRM.js +1 -0
- package/dist/chunks/useManagePlugins-BzFKIDrD.js +1 -0
- package/dist/chunks/{useMergedTools-Bb4XbC9d.js → useMergedTools-CRLWSGDl.js} +1 -1
- package/dist/chunks/{useSearchInput-B1UOjxAI.js → useSearchInput-BzGq4t7t.js} +1 -1
- package/dist/chunks/{useSettingsErrors-BLbvu4--.js → useSettingsErrors-CSemUjj1.js} +1 -1
- package/dist/chunks/{util-CxlfALM4.js → util-BnReK81E.js} +1 -1
- package/dist/chunks/validatePlugin-D6sPqea1.js +1 -0
- package/dist/chunks/{vim-DLWBHwVM.js → vim-C0KTnJJs.js} +1 -1
- package/dist/chunks/{which-sEFQXpaX.js → which-CKQnSouy.js} +1 -1
- package/dist/chunks/windowsPaths-9pEkw0oV.js +1 -0
- package/dist/chunks/windowsPaths-DtapVxOo.js +1 -0
- package/dist/chunks/{workSecret-DvniZR71.js → workSecret-CNWiR2uQ.js} +1 -1
- package/dist/chunks/{workerRegistry-CFnGtb3L.js → workerRegistry-CUXbNyL9.js} +1 -1
- package/dist/chunks/worktree-89ttIVxH.js +1 -0
- package/dist/cli.js +1 -1
- package/package.json +5 -10
- package/dist/chunks/ApproveApiKey-CQsQdQBC.js +0 -1
- package/dist/chunks/BackgroundTasksDialog-AiVi-1pI.js +0 -2
- package/dist/chunks/ClaudeMdExternalIncludesDialog-DUu6iRJk.js +0 -1
- package/dist/chunks/ConsoleOAuthFlow-DVTPwR5I.js +0 -1
- package/dist/chunks/Doctor-BXhz8eUa.js +0 -3
- package/dist/chunks/Doctor-D75dsEyb.js +0 -1
- package/dist/chunks/ExitFlow-B1XNACQP.js +0 -2
- package/dist/chunks/Feedback-Cvz80lAn.js +0 -2
- package/dist/chunks/Grove-B7hhBvFw.js +0 -1
- package/dist/chunks/MCPConnectionManager-BLfKm4H2.js +0 -1
- package/dist/chunks/MessageSelector-DmKtBYX9.js +0 -3
- package/dist/chunks/Messages-CaFdI1kk.js +0 -11
- package/dist/chunks/PluginSettings-0FSNch8O.js +0 -17
- package/dist/chunks/QueryEngine-WYDWzQuY.js +0 -1
- package/dist/chunks/REPL-vV_jzAVx.js +0 -1
- package/dist/chunks/ResumeConversation-g_JyOWbl.js +0 -1
- package/dist/chunks/SearchExtraToolsTool-Daedym7_.js +0 -1
- package/dist/chunks/Settings-DUXA-qac.js +0 -2
- package/dist/chunks/TrustDialog-CdZS9t-T.js +0 -1
- package/dist/chunks/ajv-5vMo9UcX.js +0 -8
- package/dist/chunks/api-CLLIHLpn.js +0 -1
- package/dist/chunks/api-DMpNA1s8.js +0 -1
- package/dist/chunks/asciicast-BIr75_x9.js +0 -1
- package/dist/chunks/auth-Ce0jllLf.js +0 -1
- package/dist/chunks/auth-DV3P8Qup.js +0 -1
- package/dist/chunks/auth-DpFfHy1W.js +0 -15
- package/dist/chunks/backgroundHousekeeping-BycL9lOe.js +0 -1
- package/dist/chunks/bg-H849G7Sc.js +0 -1
- package/dist/chunks/bridgeConfig-CcANVX0P.js +0 -1
- package/dist/chunks/bridgeEnabled-Cn-u7P4_.js +0 -1
- package/dist/chunks/bridgeMain-CtgVyLjI.js +0 -68
- package/dist/chunks/bridgeMain-Dh0gWRVo.js +0 -1
- package/dist/chunks/bridgeMessaging-CRG6HqUb.js +0 -1
- package/dist/chunks/bridgePointer-Cug5fQ3e.js +0 -1
- package/dist/chunks/caches-C3NINY3K.js +0 -1
- package/dist/chunks/ccrClient-CRXGlUCe.js +0 -1
- package/dist/chunks/client-AnWHs0gW.js +0 -1
- package/dist/chunks/commands-DsKH3ogN.js +0 -1
- package/dist/chunks/commitAttribution-D7NrwLhc.js +0 -1
- package/dist/chunks/compact-BhWCO-oD.js +0 -2
- package/dist/chunks/completionCache-C9zlWBRz.js +0 -1
- package/dist/chunks/config-662VDD70.js +0 -3
- package/dist/chunks/config-CUN8YbOa.js +0 -1
- package/dist/chunks/config-DklnhNx1.js +0 -1
- package/dist/chunks/config-Wk3svGdH.js +0 -1
- package/dist/chunks/context-noninteractive-C3dICmA9.js +0 -1
- package/dist/chunks/conversation-CooSju3g.js +0 -1
- package/dist/chunks/conversation-DLLIOKYV.js +0 -1
- package/dist/chunks/createSession-CVG8SiEm.js +0 -1
- package/dist/chunks/crossProjectResume-DiKJb83I.js +0 -40
- package/dist/chunks/datadog-BE6D_6m0.js +0 -1
- package/dist/chunks/datadog-C69i7cfI.js +0 -1
- package/dist/chunks/debug-8kgDrUfj.js +0 -1
- package/dist/chunks/detectRepository-_Kj817Vi.js +0 -1
- package/dist/chunks/doctor-DEz8BHAz.js +0 -1
- package/dist/chunks/envLessBridgeConfig-3kCrKZl7.js +0 -1
- package/dist/chunks/envLessBridgeConfig-BfgXw47_.js +0 -1
- package/dist/chunks/esm-C8Zkk1Ux.js +0 -1
- package/dist/chunks/execSyncWrapper-CWxMek26.js +0 -1
- package/dist/chunks/exit-cyepwuyy.js +0 -1
- package/dist/chunks/extra-usage-DlFeNGQD.js +0 -1
- package/dist/chunks/extra-usage-nRFfBiXh.js +0 -1
- package/dist/chunks/extractMemories-BqN8fWZ5.js +0 -1
- package/dist/chunks/fast-NvqW2-t1.js +0 -1
- package/dist/chunks/firstPartyEventLogger-AhXYSrkP.js +0 -1
- package/dist/chunks/firstPartyEventLogger-BQYrBdvD.js +0 -5
- package/dist/chunks/gemini-Sr_00TsL.js +0 -1
- package/dist/chunks/generateRecap-5d4l_ODy.js +0 -1
- package/dist/chunks/git-Cc1jAz6r.js +0 -1
- package/dist/chunks/git-Cgc8X5l2.js +0 -6
- package/dist/chunks/hooks-DvtnNoYE.js +0 -1
- package/dist/chunks/inboundAttachments-BZ6MKpxd.js +0 -1
- package/dist/chunks/inboundAttachments-D5Ux2kCl.js +0 -1
- package/dist/chunks/initReplBridge-CjuO6in6.js +0 -1
- package/dist/chunks/install-DqpM2brU.js +0 -1
- package/dist/chunks/jwtUtils-CqXPjf-a.js +0 -1
- package/dist/chunks/keybindings-JvAmBpLt.js +0 -2
- package/dist/chunks/language-DaxZe0Xw.js +0 -1
- package/dist/chunks/lazySchema-uxlVVNM1.js +0 -1
- package/dist/chunks/loadAgentsDir-D7npVvsj.js +0 -1
- package/dist/chunks/loadPluginHooks-CaKvZVZI.js +0 -1
- package/dist/chunks/localSearch-BU5oulbF.js +0 -1
- package/dist/chunks/mcp-B06Mqsur.js +0 -6
- package/dist/chunks/mcp-C0AjA07u.js +0 -1
- package/dist/chunks/mcp-ghioDl7W.js +0 -2
- package/dist/chunks/metadata-CIx5CsoY.js +0 -1
- package/dist/chunks/model-BgrLt7P7.js +0 -1
- package/dist/chunks/model-aVc5c3Lz.js +0 -1
- package/dist/chunks/nativeInstaller-DKe1pWoL.js +0 -1
- package/dist/chunks/parser-Bj3gOqFv.js +0 -1
- package/dist/chunks/permissions-DB_2mmCl.js +0 -3
- package/dist/chunks/pidLock-DchmaAK6.js +0 -3
- package/dist/chunks/pluginBlocklist-Cw_l-yal.js +0 -1
- package/dist/chunks/pluginCliCommands-BtYWRxhS.js +0 -1
- package/dist/chunks/pluginOperations-BOkST1qE.js +0 -2
- package/dist/chunks/pluginStartupCheck-XBLJZZys.js +0 -1
- package/dist/chunks/plugins-6px6K1fh.js +0 -4
- package/dist/chunks/policyLimits-C07tQ0Wr.js +0 -1
- package/dist/chunks/pollConfig-C2Ac8WMU.js +0 -1
- package/dist/chunks/poorMode-BdBDiOFD.js +0 -1
- package/dist/chunks/print-DcQSuK0v.js +0 -23
- package/dist/chunks/processBashCommand-CEqA4QZi.js +0 -1
- package/dist/chunks/processSlashCommand-DMpFk59M.js +0 -5
- package/dist/chunks/prompt-CKvoqUC3.js +0 -1
- package/dist/chunks/prompt-aXZPR3q8.js +0 -1
- package/dist/chunks/prompt-wys9CwDo.js +0 -132
- package/dist/chunks/rcDebugLog-CivJaJ3V.js +0 -11
- package/dist/chunks/reconciler-BKX4jh34.js +0 -4
- package/dist/chunks/remoteBridgeCore-CmwkjiTK.js +0 -1
- package/dist/chunks/remoteManagedSettings-Co-CxR67.js +0 -1
- package/dist/chunks/ripgrep-hOjrgpMp.js +0 -1
- package/dist/chunks/sandbox-adapter-CO5GuywY.js +0 -1
- package/dist/chunks/searchExtraTools-CXZJU2Kv.js +0 -1
- package/dist/chunks/sessionFileAccessHooks-BUyIQVzL.js +0 -1
- package/dist/chunks/sessionMemory-ZsxCLHYd.js +0 -1
- package/dist/chunks/sessionMemory-e6YpTUhW.js +0 -1
- package/dist/chunks/sessionMemoryUtils-BD_dqyYB.js +0 -1
- package/dist/chunks/sessionObserver-DNItJztR.js +0 -1
- package/dist/chunks/sessionStorage-xvxpRETp.js +0 -1
- package/dist/chunks/sessionTitle-Bph6GO4F.js +0 -14
- package/dist/chunks/settings-BhvhCpVh.js +0 -19
- package/dist/chunks/settingsSync-D2B5K4BT.js +0 -1
- package/dist/chunks/setup-CEnNEK6Z.js +0 -3
- package/dist/chunks/sink-CyKOf5TT.js +0 -1
- package/dist/chunks/sink-DxPJ4khU.js +0 -1
- package/dist/chunks/sinks-BNo3DvxO.js +0 -2
- package/dist/chunks/sinks-CHgtwDha.js +0 -1
- package/dist/chunks/skillChangeDetector-BRBCwQ2w.js +0 -1
- package/dist/chunks/skillLearning-BH7EAU1m.js +0 -1
- package/dist/chunks/src-xRRBgNzF.js +0 -25
- package/dist/chunks/startupProfiler-CYCH-qos.js +0 -1
- package/dist/chunks/stdio-4S7b8Uhx.js +0 -1
- package/dist/chunks/stdio-W_Kokrkh.js +0 -3
- package/dist/chunks/teleport-DjIgQeBB.js +0 -1
- package/dist/chunks/terminalSetup-nvS3KCDG.js +0 -33
- package/dist/chunks/thinkback-BSv_fvbV.js +0 -1
- package/dist/chunks/thinkback-play-DNB0IWYt.js +0 -1
- package/dist/chunks/toolPool-uQKZRMKg.js +0 -1
- package/dist/chunks/trustedDevice-0ej6e3nx.js +0 -1
- package/dist/chunks/trustedDevice-nqhuw4tp.js +0 -1
- package/dist/chunks/udsClient-CiFj4M_h.js +0 -1
- package/dist/chunks/undercover-6UUO38fQ.js +0 -1
- package/dist/chunks/updateCCB-B-OlpLjA.js +0 -11
- package/dist/chunks/upgrade-DYqlCH80.js +0 -1
- package/dist/chunks/upload-BQGByiXE.js +0 -1
- package/dist/chunks/usage-DolSCKGi.js +0 -1
- package/dist/chunks/useMainLoopModel-cZd8EKo5.js +0 -1
- package/dist/chunks/useManagePlugins-DgGZBvXV.js +0 -1
- package/dist/chunks/validatePlugin-n8a4W_jI.js +0 -1
- package/dist/chunks/windowsPaths-BLevJOlm.js +0 -1
- package/dist/chunks/windowsPaths-N_YmYY6k.js +0 -1
- package/dist/chunks/worktree-Dr_WzlXs.js +0 -1
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{en as t,nt as n}from"./state-ix0xIunV.js";import{Bs as r,Cs as i,DD as a,DE as o,ED as s,Es as c,Hs as l,Ms as u,Ns as d,Ps as f,Rs as p,SD as m,Ss as h,Vs as g,_D as _,_s as v,am as y,bs as b,dc as x,ds as S,fs as C,gD as w,hs as T,iv as E,jE as D,js as O,lc as k,ls as ee,om as te,ov as ne,ps as A,ss as j,uc as M,us as N,vD as re,vs as ie,xD as P,yD as ae}from"./loadAgentsDir-ZQwvbURI.js";import{G as F,J as oe,U as se,_ as ce,h as I}from"./debug-DiuXEmUq.js";import{c as L,g as R,y as z}from"./settings-BhvhCpVh.js";import{o as B,s as V}from"./log-Duzb4o6h.js";import{l as H,o as U}from"./stringUtils-D_g2L6A4.js";import{n as W,t as G}from"./pluginStartupCheck-BelpzwZI.js";import{dirname as le,join as K}from"path";function q(e){if(!Q.includes(e))throw Error(`Invalid scope "${e}". Must be one of: ${Q.join(`, `)}`)}function ue(e){return Q.includes(e)}function J(e){return e===`project`||e===`local`?n():void 0}function de(e){return L(`projectSettings`)?.enabledPlugins?.[e]===!0}function fe(e){let t=e.includes(`@`);for(let n of[`local`,`project`,`user`]){let r=L(m(n))?.enabledPlugins;if(r){for(let i of Object.keys(r))if(t?i===e:i.startsWith(`${e}@`))return{pluginId:i,scope:n}}}return null}function pe(e,t){let{name:n,marketplace:r}=P(e);return t.find(t=>t.name===e||t.name===n?!0:r&&t.source?t.name===n&&t.source.includes(`@${r}`):!1)}function me(e){let{name:t}=P(e),n=u();if(n.plugins[e]?.length)return{pluginId:e,pluginName:t};let r=Object.keys(n.plugins).find(e=>{let{name:r}=P(e);return r===t&&(n.plugins[e]?.length??0)>0});return r?{pluginId:r,pluginName:t}:null}function Y(e){let t=u().plugins[e];if(!t||t.length===0)return{scope:`user`};let r=n(),i=t.find(e=>e.scope===`local`&&e.projectPath===r);if(i)return{scope:i.scope,projectPath:i.projectPath};let a=t.find(e=>e.scope===`project`&&e.projectPath===r);if(a)return{scope:a.scope,projectPath:a.projectPath};let o=t.find(e=>e.scope===`user`);return o?{scope:o.scope}:{scope:t[0].scope,projectPath:t[0].projectPath}}async function he(e,t=`user`){q(t);let{name:n,marketplace:i}=P(e),a,o,s;if(i){let t=await r(e);t&&(a=t.entry,o=i,s=t.marketplaceInstallLocation)}else{let e=await l();for(let[t,r]of Object.entries(e))try{let e=(await p(t)).plugins.find(e=>e.name===n);if(e){a=e,o=t,s=r.installLocation;break}}catch(e){V(oe(e))}}if(!a||!o)return{success:!1,message:`Plugin "${n}" not found in ${i?`marketplace "${i}"`:`any configured marketplace`}`};let c=a,u=`${c.name}@${o}`,d=await b({pluginId:u,entry:c,scope:t,marketplaceInstallLocation:s});if(!d.ok){let e=d;switch(e.reason){case`local-source-no-location`:return{success:!1,message:`Cannot install local plugin "${e.pluginName}" without marketplace install location`};case`settings-write-failed`:return{success:!1,message:`Failed to update settings: ${e.message}`};case`resolution-failed`:return{success:!1,message:v(e.resolution)};case`blocked-by-policy`:return{success:!1,message:`Plugin "${e.pluginName}" is blocked by your organization's policy and cannot be installed`};case`dependency-blocked-by-policy`:return{success:!1,message:`Plugin "${e.pluginName}" depends on "${e.blockedDependency}", which is blocked by your organization's policy`}}}return{success:!0,message:`Successfully installed plugin: ${u} (scope: ${t})${d.depNote}`,pluginId:u,pluginName:c.name,scope:t}}async function ge(e,t=`user`,n=!0){q(t);let{enabled:r,disabled:i}=await A(),a=[...r,...i],s=pe(e,a),c=m(t),l=L(c),f,p;if(s)f=Object.keys(l?.enabledPlugins??{}).find(t=>t===e||t===s.name||t.startsWith(`${s.name}@`))??(e.includes(`@`)?e:s.name),p=s.name;else{let t=me(e);if(!t)return{success:!1,message:`Plugin "${e}" not found in installed plugins`};f=t.pluginId,p=t.pluginName}let h=J(t),g=u().plugins[f],v=g?.find(e=>e.scope===t&&e.projectPath===h);if(!v){let{scope:n}=Y(f);return n!==t&&g&&g.length>0?n===`project`?{success:!1,message:`Plugin "${e}" is enabled at project scope (.claude/settings.json, shared with your team). To disable just for you: claude plugin disable ${e} --scope local`}:{success:!1,message:`Plugin "${e}" is installed in ${n} scope, not ${t}. Use --scope ${n} to uninstall.`}:{success:!1,message:`Plugin "${e}" is not installed in ${t} scope. Use --scope to specify the correct scope.`}}let y=v.installPath,b={...l?.enabledPlugins};b[f]=void 0,z(c,{enabledPlugins:b}),k(),d(f,t,h);let S=u().plugins[f],C=!S||S.length===0;C&&y&&await x(y),C&&(E(f),n&&await o(f));let T=w(f,a),D=_(T);return{success:!0,message:`Successfully uninstalled plugin: ${p} (scope: ${t})${D}`,pluginId:f,pluginName:p,scope:t,reverseDependents:T.length>0?T:void 0}}async function X(e,t,n){let r=t?`enable`:`disable`;if(a(e)){let{error:n}=z(`userSettings`,{enabledPlugins:{...L(`userSettings`)?.enabledPlugins,[e]:t}});if(n)return{success:!1,message:`Failed to ${r} built-in plugin: ${n.message}`};k();let{name:i}=P(e);return{success:!0,message:`Successfully ${r}d built-in plugin: ${i}`,pluginId:e,pluginName:i,scope:`user`}}n&&q(n);let i,o,s=fe(e);if(n)if(o=n,s)i=s.pluginId;else if(e.includes(`@`))i=e;else return{success:!1,message:`Plugin "${e}" not found in settings. Use plugin@marketplace format.`};else if(s)i=s.pluginId,o=s.scope;else if(e.includes(`@`))i=e,o=`user`;else return{success:!1,message:`Plugin "${e}" not found in any editable settings scope. Use plugin@marketplace format.`};if(t&&te(i))return{success:!1,message:`Plugin "${i}" is blocked by your organization's policy and cannot be enabled`};let c=m(o),l=L(c)?.enabledPlugins?.[i],u={user:0,project:1,local:2},d=n&&s&&u[n]>u[s.scope];if(n&&l===void 0&&s&&s.scope!==n&&!d)return{success:!1,message:`Plugin "${e}" is installed at ${s.scope} scope, not ${n}. Use --scope ${s.scope} or omit --scope to auto-detect.`};if(t===(n&&!d?l===!0:G().has(i)))return{success:!1,message:`Plugin "${e}" is already ${t?`enabled`:`disabled`}${n?` at ${n} scope`:``}`};let f;if(!t){let{enabled:e,disabled:t}=await A(),n=w(i,[...e,...t]);n.length>0&&(f=n)}let{error:p}=z(c,{enabledPlugins:{...L(c)?.enabledPlugins,[i]:t}});if(p)return{success:!1,message:`Failed to ${r} plugin: ${p.message}`};k();let{name:h}=P(i),g=_(f);return{success:!0,message:`Successfully ${r}d plugin: ${h} (scope: ${o})${g}`,pluginId:i,pluginName:h,scope:o,reverseDependents:f}}async function _e(e,t){return X(e,!0,t)}async function ve(e,t){return X(e,!1,t)}async function Z(){let e=G();if(e.size===0)return{success:!0,message:`No enabled plugins to disable`};let t=[],n=[];for(let[r]of e){let e=await X(r,!1);e.success?t.push(r):n.push(`${r}: ${e.message}`)}return n.length>0?{success:!1,message:`Disabled ${t.length} ${H(t.length,`plugin`)}, ${n.length} failed:\n${n.join(`
|
|
2
|
-
`)}`}:{success:!0,message:`Disabled ${t.length} ${H(t.length,`plugin`)}`}}async function ye(e,t){let{name:n,marketplace:i}=P(e),a=i?`${n}@${i}`:e,o=await r(e);if(!o)return{success:!1,message:`Plugin "${n}" not found`,pluginId:a,scope:t};let{entry:s,marketplaceInstallLocation:c}=o,l=O().plugins[a];if(!l||l.length===0)return{success:!1,message:`Plugin "${n}" is not installed`,pluginId:a,scope:t};let u=J(t),d=l.find(e=>e.scope===t&&e.projectPath===u);return d?be({pluginId:a,pluginName:n,entry:s,marketplaceInstallLocation:c,installation:d,scope:t,projectPath:u}):{success:!1,message:`Plugin "${n}" is not installed at scope ${u?`${t} (${u})`:t}`,pluginId:a,scope:t}}async function be({pluginId:e,pluginName:t,entry:n,marketplaceInstallLocation:r,installation:i,scope:a,projectPath:o}){let s=I(),c=i.version,l,u,d=!1,p;if(typeof n.source!=`string`){let t=await j(n.source,{manifest:{name:n.name}});l=t.path,d=!0,p=t.gitCommitSha,u=await h(e,n.source,t.manifest,t.path,n.version,t.gitCommitSha)}else{let t;try{t=await s.stat(r)}catch(t){if(F(t))return{success:!1,message:`Marketplace directory not found at ${r}`,pluginId:e,scope:a};throw t}l=K(t.isDirectory()?r:le(r),n.source);try{await s.stat(l)}catch(t){if(F(t))return{success:!1,message:`Plugin source not found at ${l}`,pluginId:e,scope:a};throw t}let i,o=K(l,`.claude-plugin`,`plugin.json`);try{i=await T(o,n.name,n.source)}catch{}u=await h(e,n.source,i,l,n.version)}try{let r=N(e,u),s=S(e,u);if(i.version===u||i.installPath===r||i.installPath===s)return{success:!0,message:`${t} is already at the latest version (${u}).`,pluginId:e,newVersion:u,oldVersion:c,alreadyUpToDate:!0,scope:a};r=await ee(l,e,u,n);let d=i.installPath;if(f(e,a,o,r,u,p),d&&d!==r){let e=O();Object.values(e.plugins).some(e=>e.some(e=>e.installPath===d))||await x(d)}let m=o?`${a} (${o})`:a;return{success:!0,message:`Plugin "${t}" updated from ${c||`unknown`} to ${u} for scope ${m}. Restart to apply changes.`,pluginId:e,newVersion:u,oldVersion:c,scope:a}}finally{d&&l!==N(e,u)&&await s.rm(l,{recursive:!0,force:!0})}}var Q,$,xe=e((()=>{t(),s(),se(),ce(),B(),M(),re(),c(),g(),D(),ae(),ie(),C(),ne(),y(),W(),i(),R(),U(),Q=[`user`,`project`,`local`],$=[`user`,`project`,`local`,`managed`]}));export{_e as a,he as c,ge as d,ye as f,ve as i,ue as l,$ as n,Y as o,Z as r,xe as s,Q as t,de as u};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e,t}from"./pluginStartupCheck-BelpzwZI.js";e();export{t as getPluginEditableScopes};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{n as e,t}from"./figures-5ThXQEtq.js";import{en as n,hr as r}from"./state-ix0xIunV.js";import{$s as i,AD as a,As as o,Es as s,Fs as c,Gs as l,Hs as u,Ms as d,SD as f,Vs as p,Ws as m,Ys as h,ac as g,fs as ee,kD as _,lc as v,nv as y,ps as b,qs as x,rv as S,sc as C,uc as te,xD as w,yD as T}from"./loadAgentsDir-ZQwvbURI.js";import{E,O as D,U as O,z as k}from"./debug-DiuXEmUq.js";import{o as ne,s as A}from"./log-Duzb4o6h.js";import{n as re,r as j}from"./analytics-BotDBGh0.js";import{l as M,o as N}from"./stringUtils-D_g2L6A4.js";import{n as P,t as F}from"./exit-BOhGfSlm.js";import{n as I,s as L,t as R}from"./pluginOperations-BOkST1qE.js";import{a as z,i as B,n as V,o as H,r as U,t as W}from"./pluginCliCommands-BtYWRxhS.js";import{a as G,c as ie,i as K,n as q,r as J,s as Y,t as ae}from"./validatePlugin-n8a4W_jI.js";import{basename as oe,dirname as X}from"path";e(),n(),re(),L(),a(),O(),ne(),te(),ie(),s(),g(),p(),y(),K(),T(),ee(),ae(),E(),N();function Z(e,n){A(e),F(`${t.cross} Failed to ${n}: ${k(e)}`)}function Q(e){e.errors.length>0&&(console.log(`${t.cross} Found ${e.errors.length} ${M(e.errors.length,`error`)}:\n`),e.errors.forEach(e=>{console.log(` ${t.pointer} ${e.path}: ${e.message}`)}),console.log(``)),e.warnings.length>0&&(console.log(`${t.warning} Found ${e.warnings.length} ${M(e.warnings.length,`warning`)}:\n`),e.warnings.forEach(e=>{console.log(` ${t.pointer} ${e.path}: ${e.message}`)}),console.log(``))}async function se(e,n){n.cowork&&r(!0);try{let n=await q(e);console.log(`Validating ${n.fileType} manifest: ${n.filePath}\n`),Q(n);let r=[];if(n.fileType===`plugin`){let e=X(n.filePath);if(oe(e)===`.claude-plugin`){r=await J(X(e));for(let e of r)console.log(`Validating ${e.fileType}: ${e.filePath}\n`),Q(e)}}let i=n.success&&r.every(e=>e.success),a=n.warnings.length>0||r.some(e=>e.warnings.length>0);i?P(a?`${t.tick} Validation passed with warnings`:`${t.tick} Validation passed`):(console.log(`${t.cross} Validation failed`),process.exit(1))}catch(e){A(e),console.error(`${t.cross} Unexpected error during validation: ${k(e)}`),process.exit(2)}}async function $(e){e.cowork&&r(!0),j(`tengu_plugin_list_command`,{});let n=d(),{getPluginEditableScopes:a}=await import(`./pluginStartupCheck-XBLJZZys.js`),s=a(),c=Object.keys(n.plugins),{enabled:l,disabled:f,errors:p}=await b(),m=[...l,...f],h=m.filter(e=>e.source.endsWith(`@inline`)),g=p.filter(e=>e.source.endsWith(`@inline`)||e.source.startsWith(`inline[`));if(e.json){let t=new Map(m.map(e=>[e.source,e])),r=[];for(let e of c.sort()){let i=n.plugins[e];if(!i||i.length===0)continue;let a=w(e).name,o=p.filter(t=>t.source===e||`plugin`in t&&t.plugin===a).map(_);for(let n of i){let i=t.get(e),a;if(i){let e=i.mcpServers||await S(i);e&&Object.keys(e).length>0&&(a=e)}r.push({id:e,version:n.version||`unknown`,scope:n.scope,enabled:s.has(e),installPath:n.installPath,installedAt:n.installedAt,lastUpdated:n.lastUpdated,projectPath:n.projectPath,mcpServers:a,errors:o.length>0?o:void 0})}}for(let e of h){let t=e.mcpServers||await S(e),n=g.filter(t=>t.source===e.source||`plugin`in t&&t.plugin===e.name).map(_);r.push({id:e.source,version:e.manifest.version??`unknown`,scope:`session`,enabled:e.enabled!==!1,installPath:e.path,mcpServers:t&&Object.keys(t).length>0?t:void 0,errors:n.length>0?n:void 0})}for(let e of g.filter(e=>e.source.startsWith(`inline[`)))r.push({id:e.source,version:`unknown`,scope:`session`,enabled:!1,installPath:`path`in e?e.path:``,errors:[_(e)]});if(e.available){let e=[];try{let[t,n]=await Promise.all([u(),Y()]),{marketplaces:r}=await C(t);for(let{name:t,data:a}of r)if(a)for(let r of a.plugins){let a=i(r.name,t);o(a)||e.push({pluginId:a,name:r.name,description:r.description,marketplaceName:t,version:r.version,source:r.source,installCount:n?.get(a)})}}catch{}P(D({installed:r,available:e},null,2))}else P(D(r,null,2))}c.length===0&&h.length===0&&g.length===0&&P("No plugins installed. Use `claude plugin install` to install a plugin."),c.length>0&&console.log(`Installed plugins:
|
|
2
|
-
`);for(let e of c.sort()){let r=n.plugins[e];if(!r||r.length===0)continue;let i=w(e).name,a=p.filter(t=>t.source===e||`plugin`in t&&t.plugin===i);for(let n of r){let r=s.has(e),i=a.length>0?`${t.cross} failed to load`:r?`${t.tick} enabled`:`${t.cross} disabled`,o=n.version||`unknown`,c=n.scope;console.log(` ${t.pointer} ${e}`),console.log(` Version: ${o}`),console.log(` Scope: ${c}`),console.log(` Status: ${i}`);for(let e of a)console.log(` Error: ${_(e)}`);console.log(``)}}if(h.length>0||g.length>0){console.log(`Session-only plugins (--plugin-dir):
|
|
3
|
-
`);for(let e of h){let n=g.filter(t=>t.source===e.source||`plugin`in t&&t.plugin===e.name),r=n.length>0?`${t.cross} loaded with errors`:`${t.tick} loaded`;console.log(` ${t.pointer} ${e.source}`),console.log(` Version: ${e.manifest.version??`unknown`}`),console.log(` Path: ${e.path}`),console.log(` Status: ${r}`);for(let e of n)console.log(` Error: ${_(e)}`);console.log(``)}for(let e of g.filter(e=>e.source.startsWith(`inline[`)))console.log(` ${t.pointer} ${e.source}: ${t.cross} ${_(e)}\n`)}P()}async function ce(e,n){n.cowork&&r(!0);try{let r=await G(e);r||F(`${t.cross} Invalid marketplace source format. Try: owner/repo, https://..., or ./path`),`error`in r&&F(`${t.cross} ${r.error}`);let i=n.scope??`user`;i!==`user`&&i!==`project`&&i!==`local`&&F(`${t.cross} Invalid scope '${i}'. Use: user, project, or local`);let a=f(i),o=r;n.sparse&&n.sparse.length>0&&(o.source===`github`||o.source===`git`?o={...o,sparsePaths:n.sparse}:F(`${t.cross} --sparse is only supported for github and git marketplace sources (got: ${o.source})`)),console.log(`Adding marketplace...`);let{name:s,alreadyMaterialized:l,resolvedSource:u}=await c(o,e=>{console.log(e)});h(s,{source:u},a),v();let d=o.source;o.source===`github`&&(d=o.repo),j(`tengu_marketplace_added`,{source_type:d}),P(l?`${t.tick} Marketplace '${s}' already on disk — declared in ${i} settings`:`${t.tick} Successfully added marketplace: ${s} (declared in ${i} settings)`)}catch(e){Z(e,`add marketplace`)}}async function le(e){e.cowork&&r(!0);try{let n=await u(),r=Object.keys(n);e.json&&P(D(r.sort().map(e=>{let t=n[e],r=t?.source;return{name:e,source:r?.source,...r?.source===`github`&&{repo:r.repo},...r?.source===`git`&&{url:r.url},...r?.source===`url`&&{url:r.url},...r?.source===`directory`&&{path:r.path},...r?.source===`file`&&{path:r.path},installLocation:t?.installLocation}}),null,2)),r.length===0&&P(`No marketplaces configured`),console.log(`Configured marketplaces:
|
|
4
|
-
`),r.forEach(e=>{let r=n[e];if(console.log(` ${t.pointer} ${e}`),r?.source){let e=r.source;e.source===`github`?console.log(` Source: GitHub (${e.repo})`):e.source===`git`?console.log(` Source: Git (${e.url})`):e.source===`url`?console.log(` Source: URL (${e.url})`):e.source===`directory`?console.log(` Source: Directory (${e.path})`):e.source===`file`&&console.log(` Source: File (${e.path})`)}console.log(``)}),P()}catch(e){Z(e,`list marketplaces`)}}async function ue(e,n){n.cowork&&r(!0);try{await x(e),v(),j(`tengu_marketplace_removed`,{marketplace_name:e}),P(`${t.tick} Successfully removed marketplace: ${e}`)}catch(e){Z(e,`remove marketplace`)}}async function de(e,n){n.cowork&&r(!0);try{if(e)console.log(`Updating marketplace: ${e}...`),await l(e,e=>{console.log(e)}),v(),j(`tengu_marketplace_updated`,{marketplace_name:e}),P(`${t.tick} Successfully updated marketplace: ${e}`);else{let e=await u(),n=Object.keys(e);n.length===0&&P(`No marketplaces configured`),console.log(`Updating ${n.length} marketplace(s)...`),await m(),v(),j(`tengu_marketplace_updated_all`,{count:n.length}),P(`${t.tick} Successfully updated ${n.length} marketplace(s)`)}}catch(e){Z(e,`update marketplace(s)`)}}async function fe(e,t){t.cowork&&r(!0);let n=t.scope||`user`;t.cowork&&n!==`user`&&F(`--cowork can only be used with user scope`),R.includes(n)||F(`Invalid scope: ${n}. Must be one of: ${R.join(`, `)}.`);let{name:i,marketplace:a}=w(e);j(`tengu_plugin_install_command`,{_PROTO_plugin_name:i,...a&&{_PROTO_marketplace_name:a},scope:n}),await B(e,n)}async function pe(e,t){t.cowork&&r(!0);let n=t.scope||`user`;t.cowork&&n!==`user`&&F(`--cowork can only be used with user scope`),R.includes(n)||F(`Invalid scope: ${n}. Must be one of: ${R.join(`, `)}.`);let{name:i,marketplace:a}=w(e);j(`tengu_plugin_uninstall_command`,{_PROTO_plugin_name:i,...a&&{_PROTO_marketplace_name:a},scope:n}),await z(e,n,t.keepData)}async function me(e,t){t.cowork&&r(!0);let n;t.scope&&(R.includes(t.scope)||F(`Invalid scope "${t.scope}". Valid scopes: ${R.join(`, `)}`),n=t.scope),t.cowork&&n!==void 0&&n!==`user`&&F(`--cowork can only be used with user scope`),t.cowork&&n===void 0&&(n=`user`);let{name:i,marketplace:a}=w(e);j(`tengu_plugin_enable_command`,{_PROTO_plugin_name:i,...a&&{_PROTO_marketplace_name:a},scope:n??`auto`}),await U(e,n)}async function he(e,t){if(t.all&&e&&F(`Cannot use --all with a specific plugin`),!t.all&&!e&&F(`Please specify a plugin name or use --all to disable all plugins`),t.cowork&&r(!0),t.all){t.scope&&F(`Cannot use --scope with --all`),j(`tengu_plugin_disable_command`,{}),await W();return}let n;t.scope&&(R.includes(t.scope)||F(`Invalid scope "${t.scope}". Valid scopes: ${R.join(`, `)}`),n=t.scope),t.cowork&&n!==void 0&&n!==`user`&&F(`--cowork can only be used with user scope`),t.cowork&&n===void 0&&(n=`user`);let{name:i,marketplace:a}=w(e);j(`tengu_plugin_disable_command`,{_PROTO_plugin_name:i,...a&&{_PROTO_marketplace_name:a},scope:n??`auto`}),await V(e,n)}async function ge(e,t){t.cowork&&r(!0);let{name:n,marketplace:i}=w(e);j(`tengu_plugin_update_command`,{_PROTO_plugin_name:n,...i&&{_PROTO_marketplace_name:i}});let a=`user`;t.scope&&(I.includes(t.scope)||F(`Invalid scope "${t.scope}". Valid scopes: ${I.join(`, `)}`),a=t.scope),t.cowork&&a!==`user`&&F(`--cowork can only be used with user scope`),await H(e,a)}export{ce as marketplaceAddHandler,le as marketplaceListHandler,ue as marketplaceRemoveHandler,de as marketplaceUpdateHandler,he as pluginDisableHandler,me as pluginEnableHandler,fe as pluginInstallHandler,$ as pluginListHandler,pe as pluginUninstallHandler,ge as pluginUpdateHandler,se as pluginValidateHandler};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Ua as e,Va as t,Ya as n}from"./loadAgentsDir-ZQwvbURI.js";t();export{e as isPolicyAllowed,n as waitForPolicyLimitsToLoad};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{C as e,t,w as n}from"./v4-jw6qOKwQ.js";import{n as r,t as i}from"./lazySchema-uxlVVNM1.js";t(),i();var a=2e3,o=6e5,s={poll_interval_ms_not_at_capacity:a,poll_interval_ms_at_capacity:o,non_exclusive_heartbeat_interval_ms:0,multisession_poll_interval_ms_not_at_capacity:a,multisession_poll_interval_ms_partial_capacity:a,multisession_poll_interval_ms_at_capacity:o,reclaim_older_than_ms:5e3,session_keepalive_interval_v2_ms:12e4},c={message:`must be 0 (disabled) or ≥100ms`},l=r(()=>n({poll_interval_ms_not_at_capacity:e().int().min(100),poll_interval_ms_at_capacity:e().int().refine(e=>e===0||e>=100,c),non_exclusive_heartbeat_interval_ms:e().int().min(0).default(0),multisession_poll_interval_ms_not_at_capacity:e().int().min(100).default(s.multisession_poll_interval_ms_not_at_capacity),multisession_poll_interval_ms_partial_capacity:e().int().min(100).default(s.multisession_poll_interval_ms_partial_capacity),multisession_poll_interval_ms_at_capacity:e().int().refine(e=>e===0||e>=100,c).default(s.multisession_poll_interval_ms_at_capacity),reclaim_older_than_ms:e().int().min(1).default(5e3),session_keepalive_interval_v2_ms:e().int().min(0).default(12e4)}).refine(e=>e.non_exclusive_heartbeat_interval_ms>0||e.poll_interval_ms_at_capacity>0,{message:`at-capacity liveness requires non_exclusive_heartbeat_interval_ms > 0 or poll_interval_ms_at_capacity > 0`}).refine(e=>e.non_exclusive_heartbeat_interval_ms>0||e.multisession_poll_interval_ms_at_capacity>0,{message:`at-capacity liveness requires non_exclusive_heartbeat_interval_ms > 0 or multisession_poll_interval_ms_at_capacity > 0`}));function u(){let e=s,t=l().safeParse(e);return t.success?t.data:s}export{s as n,u as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e,t}from"./poorMode-BqyVuBu-.js";t();export{e as isPoorModeActive};
|
|
@@ -1,23 +0,0 @@
|
|
|
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{$S as te,Al as y,Ar as b,BD as ne,BE as x,B_ as S,Bw as re,By as C,C as w,Cn as T,D as E,DC as D,DS as O,Dv as ie,Dw as ae,E as k,ES as oe,Fc as A,G as se,G_ as ce,Gy as le,H_ as ue,IE as de,Ic as fe,Is as j,Iy as M,JE as pe,Jw as me,K_ as he,Ks as ge,Ku as _e,Kw as ve,Ls as ye,MC as N,M_ as be,Md as P,NC as xe,NE as Se,Nc as Ce,OC as we,OS as Te,Oi as Ee,Ov as De,P as Oe,Pc as ke,QD as Ae,QE as F,Qi as je,Ry as Me,Sw as Ne,Tb as Pe,Ua as I,Us as L,Ut as Fe,VE as Ie,Va as Le,Vi as Re,Vs as ze,Vw as Be,W as Ve,Wi as He,Wy as Ue,X_ as We,Xu as R,YD as z,ZD as Ge,ZE as B,Zw as Ke,_C as qe,_c as Je,_g as Ye,_i as Xe,_w as Ze,aC as Qe,ag as $e,as as V,aw as et,ay as tt,b as nt,bC as rt,bc as it,bw as at,cC as ot,cO as st,ca as ct,cf as lt,cg as ut,cr as dt,cs as ft,cu as pt,cy as mt,dg as ht,dw as H,eC as gt,eT as _t,ei as vt,f as yt,fc as bt,fi as xt,fs as St,fw as Ct,fy as wt,gc as Tt,gi as Et,go as Dt,gw as Ot,hC as kt,hc as At,hg as jt,hw as Mt,hy as Nt,iC as Pt,i_ as Ft,ig as It,ir as Lt,iw as Rt,jC as zt,jd as Bt,jr as Vt,kC as Ht,kS as Ut,k_ as Wt,kb as Gt,ki as Kt,kl as qt,kr as Jt,lC as Yt,lf as Xt,ly as Zt,mS as Qt,mc as $t,mg as en,ms as tn,mw as nn,my as rn,nb as an,ng as on,o as sn,oO as cn,oT as ln,o_ as un,os as dn,pS as fn,pc as pn,pg as mn,pi as hn,pw as gn,py as _n,qE as vn,qi as yn,qu as bn,qw as xn,r_ as Sn,rb as Cn,s as wn,sT as Tn,su as En,tO as Dn,uu as On,vc as kn,vg as An,vw as jn,wn as Mn,x as Nn,xC as Pn,xc as Fn,xw as In,y_ as Ln,yc as Rn,yn as zn,yw as Bn,z_ as Vn,zo as Hn,zw as Un,zy as Wn}from"./loadAgentsDir-ZQwvbURI.js";import{n as Gn,t as Kn}from"./cwd-CYmmnQVS.js";import{D as qn,E as Jn,J as Yn,O as U,U as Xn,_ as Zn,h as Qn,l as $n,ot as er,p as W,st as tr,u as nr,z as G}from"./debug-DiuXEmUq.js";import{St as rr,Y as ir,_n as ar,ct as or,d as sr,f as cr,g as lr,ht as ur,ot as K,yn as dr}from"./settings-BhvhCpVh.js";import{L as fr,P as pr}from"./config-662VDD70.js";import{i as mr,n as hr,o as q}from"./process-gEbdy6uY.js";import{M as gr,N as _r,j as vr}from"./git-Cgc8X5l2.js";import{U as yr,Y as br,c as xr,i as Sr,o as Cr,s as J}from"./log-Duzb4o6h.js";import{i as wr,n as Tr}from"./path-Cu_AKqg6.js";import{s as Er,u as Dr}from"./types-Cnorfsss.js";import{n as Or,r as Y}from"./analytics-BotDBGh0.js";import{C as kr,Er as Ar,Mn as jr,Nn as Mr,Tr as Nr,Vt as Pr,X as Fr,_ as Ir,at as Lr,cr as Rr,di as zr,fi as Br,it as Vr,li as Hr,mi as Ur,nt as Wr,o as Gr,sr as Kr,tt as qr,u as Jr,vn as Yr,x as Xr,xt as Zr,yn as Qr}from"./model-BgrLt7P7.js";import{Cn as $r,Et as ei,Tt as ti,Yt as ni,dt as ri,rn as ii,ut as ai,wn as oi}from"./prompt-wys9CwDo.js";import{c as si,s as ci}from"./pluginFlagging-_WUQP3Lq.js";import{a as li,o as ui,s as di}from"./fileStateCache-DDW5toIs.js";import{A as fi,C as pi,D as mi,N as hi,O as gi,P as _i,_ as vi,d as yi,g as bi,h as xi,lt as Si,m as Ci,u as wi,v as Ti,y as Ei}from"./rcDebugLog-CivJaJ3V.js";import{c as Di,l as Oi}from"./commitAttribution-DKun9CeU.js";import{K as ki,x as Ai,y as ji}from"./stdio-W_Kokrkh.js";import{t as Mi}from"./pollConfig-C2Ac8WMU.js";import{r as Ni}from"./inboundAttachments-BZ6MKpxd.js";import{i as Pi,n as Fi,s as Ii}from"./mappers-DKU4RgE3.js";import{n as Li,r as Ri}from"./sessionTitle-Bph6GO4F.js";import{n as zi,t as Bi}from"./ccrClient-CRXGlUCe.js";import{n as Vi,t as Hi}from"./HybridTransport-8qA64lCx.js";import{n as Ui,t as Wi}from"./SSETransport-Chj_yfPv.js";import{a as Gi,n as Ki,o as qi}from"./grove-DSWe6psK.js";import{o as Ji}from"./remoteManagedSettings-Co-CxR67.js";import{i as Yi,r as Xi}from"./auth-DpFfHy1W.js";import{t as Zi}from"./pluginBlocklist-Cw_l-yal.js";import{t as Qi}from"./onChangeAppState-DaQ0R9Tw.js";import{t as $i}from"./settingsSync-D2B5K4BT.js";import{a as ea,c as ta,n as na,o as ra,r as ia,s as aa}from"./reconciler-BKX4jh34.js";import{n as oa,t as sa}from"./toolPool-uQKZRMKg.js";import{n as ca,r as la}from"./QueryEngine-WYDWzQuY.js";import{n as ua,r as da}from"./sideQuestion-CAiA6jAf.js";import{n as fa,r as pa}from"./context-noninteractive-CTvyNimw.js";import{a as ma,o as ha,t as ga}from"./skillChangeDetector-BRBCwQ2w.js";import{n as _a,t as va}from"./refresh-vJbxW4a1.js";import{dirname as ya,join as ba}from"path";import{PassThrough as xa}from"stream";import{randomUUID as X}from"crypto";import{readFile as Sa,stat as Ca}from"fs/promises";import{URL as wa}from"url";import{cwd as Z}from"process";a(),p(),Gn(),er(),Xn(),Jn(),Zn(),hr(),$n(),vr(),br(),Cr(),wr(),ar(),Er(),lr(),Ur(),zr(),Ar(),jr(),Yr(),Pr(),Ir(),$r(),ii(),Mt(),hi(),Qe(),Te(),gi(),ie(),yi(),dn(),Hn(),je(),Vt(),$i(),r(),Ui();function Ta(e,t={},r,i){if(n(process.env.CLAUDE_CODE_USE_CCR_V2)){let n=new wa(e.href);return n.protocol===`wss:`?n.protocol=`https:`:n.protocol===`ws:`&&(n.protocol=`http:`),n.pathname=n.pathname.replace(/\/$/,``)+`/worker/events/stream`,new Wi(n,t,r,i)}if(e.protocol===`ws:`||e.protocol===`wss:`)return n(process.env.CLAUDE_CODE_POST_FOR_SESSION_INGRESS_V2)?new Hi(e,t,r,i):new Vi(e,t,r,i);throw Error(`Unsupported protocol: ${e.protocol}`)}r(),Ui();var Ea=class extends ea{constructor(e,t,r){let i=new xa({encoding:`utf8`});super(i,r),o(this,`url`,void 0),o(this,`transport`,void 0),o(this,`inputStream`,void 0),o(this,`isBridge`,!1),o(this,`isDebug`,!1),o(this,`ccrClient`,null),o(this,`keepAliveTimer`,null),this.inputStream=i,this.url=new wa(e);let a={},s=mi();s?a.Authorization=`Bearer ${s}`:W(`[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=mi();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=Ta(this.url,a,m(),l),this.isBridge=process.env.CLAUDE_CODE_ENVIRONMENT_KIND===`bridge`,this.isDebug=nr(),this.transport.setOnData(e=>{this.inputStream.write(e),this.isBridge&&this.isDebug&&q(e.endsWith(`
|
|
2
|
-
`)?e:e+`
|
|
3
|
-
`)}),this.transport.setOnClose(()=>{this.inputStream.end()}),n(process.env.CLAUDE_CODE_USE_CCR_V2)){if(!(this.transport instanceof Wi))throw Error(`CCR v2 requires SSETransport; check getTransportForUrl`);this.ccrClient=new Bi(this.transport,this.url);let e=this.ccrClient.initialize();this.restoredWorkerState=e.catch(()=>null),e.catch(e=>{gr(`error`,`cli_worker_lifecycle_init_failed`,{reason:e instanceof zi?e.reason:`unknown`}),J(Error(`CCRClient initialization failed: ${G(e)}`)),oe(1,`other`)}),tr(async()=>this.ccrClient?.close()),Kt((e,t,n)=>this.ccrClient.writeInternalEvent(e,t,n)),Ee(()=>this.ccrClient.readInternalEvents(),()=>this.ccrClient.readSubagentInternalEvents());let t={started:`processing`,completed:`processed`};Ze((e,n)=>{this.ccrClient?.reportDelivery(e,t[n])}),Ti((e,t)=>{this.ccrClient?.reportState(e,t)}),vi(e=>{this.ccrClient?.reportMetadata(e)},{replayCurrent:!0})}this.transport.connect();let u=Mi().session_keepalive_interval_v2_ms;if(this.isBridge&&u>0&&(this.keepAliveTimer=setInterval(()=>{W(`[remote-io] keep_alive sent`),this.write({type:`keep_alive`}).catch(e=>{W(`[remote-io] keep_alive write failed: ${G(e)}`)})},u),this.keepAliveTimer.unref?.()),tr(async()=>this.close()),t){let e=this.inputStream;(async()=>{for await(let n of t)e.write(String(n).replace(/\n$/,``)+`
|
|
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)&&q(ra(e)+`
|
|
5
|
-
`)}close(){this.keepAliveTimer&&(clearInterval(this.keepAliveTimer),this.keepAliveTimer=null),this.transport.close(),this.inputStream.end()}};ni(),ir(),ei(),[...ti],er(),$n();var Da=`[stdout-guard]`,Oa=!1,Q=``,ka=null;function Aa(e){if(e.length===0)return!0;try{return JSON.parse(e),!0}catch{return!1}}function ja(){Oa||(Oa=!0,ka=process.stdout.write.bind(process.stdout),process.stdout.write=function(e,t,n){let r=typeof e==`string`?e:Buffer.from(e).toString(`utf-8`);Q+=r;let i,a=!0;for(;(i=Q.indexOf(`
|
|
6
|
-
`))!==-1;){let e=Q.slice(0,i);Q=Q.slice(i+1),Aa(e)?a=ka(e+`
|
|
7
|
-
`):(process.stderr.write(`${Da} ${e}\n`),W(`streamJsonStdoutGuard diverted non-JSON stdout line: ${e.slice(0,200)}`))}let o=typeof t==`function`?t:n;return o&&queueMicrotask(()=>o()),a},tr(async()=>{Q.length>0&&(ka&&Aa(Q)?ka(Q+`
|
|
8
|
-
`):process.stderr.write(`${Da} ${Q}\n`),Q=``),ka&&(process.stdout.write=ka,ka=null),Oa=!1}))}rr(),or(),pr(),cn(),z(),vn(),x(),de(),ri(),ui(),_i(),me(),et(),N(),Pn(),qe(),le(),wt(),mt(),ce(),be(),R(),A(),ke(),Rn(),ze(),St(),Mn(),zn(),se(),sn(),sa(),tt(),Xn(),Cr(),gi(),M(),$n(),Te();function Ma(e){let t=process.env.CLAUDE_CODE_EXIT_AFTER_STOP_DELAY,n=t?parseInt(t,10):null,r=n&&!isNaN(n)&&n>0,i=null,a=0;return{start(){i&&(clearTimeout(i),i=null),r&&(a=Date.now(),i=setTimeout(()=>{let t=Date.now()-a;e()&&t>=n&&(W(`Exiting after ${n}ms of idle time`),O())},n))},stop(){i&&(clearTimeout(i),i=null)}}}qr(),ci(),B(),ln(),D(),gt(),Qt(),Gt(),y(),Le(),w(),Ri(),ua();function Na(e){if(e.toLowerCase().endsWith(`.jsonl`))return{sessionId:X(),ingressUrl:null,isUrl:!1,jsonlFile:e,isJsonlFile:!0};if(De(e))return{sessionId:e,ingressUrl:null,isUrl:!1,jsonlFile:null,isJsonlFile:!1};try{let t=new URL(e);return{sessionId:X(),ingressUrl:t.href,isUrl:!0,jsonlFile:null,isJsonlFile:!1}}catch{}return null}Kr(),ae(),In(),gn(),Oi(),ki(),Sn(),jt(),ht(),P(),En(),Fi(),Gi(),pa(),$n();async function Pa(){try{let e=await Sa(Tt(),`utf-8`),t=ur().safeParse(qn(e));return t.success?t.data:(W(`Invalid known_marketplaces.json in zip cache: ${t.error.message}`,{level:`error`}),{})}catch{return{}}}async function Fa(e){await bt(Tt(),U(e,null,2))}async function Ia(e,t){let n=At();if(!n)return;let r=await La(t);r!==null&&await bt(ba(n,$t(e)),r)}async function La(e){let t=[ba(e,`.claude-plugin`,`marketplace.json`),ba(e,`marketplace.json`),e];for(let e of t)try{return await Sa(e,`utf-8`)}catch{}return null}async function Ra(){let e=await L();for(let[t,n]of Object.entries(e))if(n.installLocation)try{await Ia(t,n.installLocation)}catch(e){W(`Failed to save marketplace JSON for ${t}: ${e}`)}await Fa({...await Pa(),...e})}Or(),er(),$n(),vr(),Cr(),ze(),Rn();async function za(){let e=Fn();W(`installPluginsForHeadless: starting${e?` (zip cache mode)`:``}`);let t=await ge();t&&(j(),ft(`headlessPluginInstall: seed marketplaces registered`)),e&&(await Qn().mkdir(Je()),await Qn().mkdir(kn()));let n=Object.keys(ye()).length,r={marketplaces_installed:0,delisted_count:0},i=t;try{if(n===0)W(`installPluginsForHeadless: no marketplaces declared`);else{let t=await _r(`headless_marketplace_reconcile`,()=>na({skip:e?(e,t)=>!it(t):void 0,onProgress:e=>{e.type===`installed`?W(`installPluginsForHeadless: installed marketplace ${e.name}`):e.type===`failed`&&W(`installPluginsForHeadless: failed to install marketplace ${e.name}: ${e.error}`)}}),e=>({installed_count:e.installed.length,updated_count:e.updated.length,failed_count:e.failed.length,skipped_count:e.skipped.length}));t.skipped.length>0&&W(`installPluginsForHeadless: skipped ${t.skipped.length} marketplace(s) unsupported by zip cache: ${t.skipped.join(`, `)}`);let n=t.installed.length+t.updated.length;n>0&&(j(),ft(`headlessPluginInstall: marketplaces reconciled`),i=!0),r.marketplaces_installed=n}e&&await Ra();let t=await Zi();return r.delisted_count=t.length,t.length>0&&(i=!0),i&&ft(`headlessPluginInstall: plugins changed`),e&&tr(pn),i}catch(e){return J(e),!1}finally{Y(`tengu_headless_plugin_install`,r)}}Or(),$n(),vr(),Mt(),yi(),Cr(),hr(),ie(),Te(),er(),Gn(),p(),Vt(),Hn(),Jn(),r(),va(),St(),Yt(),an(),lt(),Xn();var $=(Ei(),e(pi)),Ba=1e4,Va=new Set,Ha=[];function Ua(e){if(Va.has(e))return!1;if(Va.add(e),Ha.push(e),Ha.length>Ba){let e=Ha.splice(0,Ha.length-Ba);for(let t of e)Va.delete(t)}return!0}function Wa(e){return typeof e==`string`?[{type:`text`,text:e}]:e}function Ga(e){return e.length===1?e[0]:e.every(e=>typeof e==`string`)?e.join(`
|
|
9
|
-
`):e.flatMap(Wa)}function Ka(e,t){return t!==void 0&&t.mode===`prompt`&&t.workload===e.workload&&t.isMeta===e.isMeta}async function qa(e,t,r,i,a,o,s,c){if(process.env.USER_TYPE===`ant`&&n(process.env.CLAUDE_CODE_EXIT_AFTER_FIRST_RENDER)&&(process.stderr.write(`\nStartup time: ${Math.round(process.uptime()*1e3)}ms\n`),process.exit(0)),Ie.subscribe(e=>{fn(e,r),Vr()&&r(e=>{let t=e.settings,n=t.fastMode===!0&&!t.fastModePerSessionOptIn;return{...e,fastMode:n}})}),$&&!$.isProactiveActive()&&n(process.env.CLAUDE_CODE_PROACTIVE)&&$.activateProactive(`command`),typeof Bun<`u`&&setInterval(()=>{process.memoryUsage.rss()>350*1024*1024?Bun.gc(!0):Bun.gc(!1)},1e3).unref(),Ct(),H(`runHeadless_entry`),await qi()&&await Ki(),H(`after_grove_check`),c.resumeSessionAt&&!c.resume){process.stderr.write(`Error: --resume-session-at requires --resume
|
|
10
|
-
`),O(1);return}if(c.rewindFiles&&!c.resume){process.stderr.write(`Error: --rewind-files requires --resume
|
|
11
|
-
`),O(1);return}if(c.rewindFiles&&e){process.stderr.write(`Error: --rewind-files is a standalone operation and cannot be used with a prompt
|
|
12
|
-
`),O(1);return}let l=ro(e,c);c.outputFormat===`stream-json`&&ja();let u=Se.getSandboxUnavailableReason();if(u){if(Se.isSandboxRequired()){process.stderr.write(`\nError: sandbox required but unavailable: ${u}\n sandbox.failIfUnavailable is set — refusing to start without a working sandbox.\n\n`),O(1);return}process.stderr.write(`\n⚠ Sandbox disabled: ${u}\n Commands will run WITHOUT sandboxing. Network and filesystem restrictions will NOT be enforced.\n\n`)}else if(Se.isSandboxingEnabled())try{await Se.initialize(l.createSandboxAskCallback())}catch(e){process.stderr.write(`\n❌ Sandbox Error: ${G(e)}\n`),O(1,`other`);return}c.outputFormat===`stream-json`&&c.verbose&&fe(e=>{let t=(()=>{switch(e.type){case`started`:return{type:`system`,subtype:`hook_started`,hook_id:e.hookId,hook_name:e.hookName,hook_event:e.hookEvent,uuid:X(),session_id:m()};case`progress`:return{type:`system`,subtype:`hook_progress`,hook_id:e.hookId,hook_name:e.hookName,hook_event:e.hookEvent,stdout:e.stdout,stderr:e.stderr,output:e.output,uuid:X(),session_id:m()};case`response`:return{type:`system`,subtype:`hook_response`,hook_id:e.hookId,hook_name:e.hookName,hook_event:e.hookEvent,output:e.output,stdout:e.stdout,stderr:e.stderr,exit_code:e.exitCode,outcome:e.outcome,uuid:X(),session_id:m()}}})();l.write(t)}),c.setupTrigger&&await rn(c.setupTrigger),H(`before_loadInitialMessages`);let d=t(),{messages:p,turnInterruptionState:h,agentSetting:g}=await no(r,{continue:c.continue,teleport:c.teleport,resume:c.resume,resumeSessionAt:c.resumeSessionAt,forkSession:c.forkSession,outputFormat:c.outputFormat,sessionStartHooksPromise:c.sessionStartHooksPromise,restoredWorkerState:l.restoredWorkerState}),_=Nt();if(_&&l.prependUserMessage(_),!c.agent&&!f()&&g){let{agentDefinition:e}=ma(g,void 0,{activeAgents:s,allAgents:s});if(e){if(r(t=>({...t,agent:e.agentType})),!c.systemPrompt&&!wn(e)){let t=e.getSystemPrompt();t&&(c.systemPrompt=t)}Et(e.agentType)}}if(p.length===0&&process.exitCode!==void 0)return;if(c.rewindFiles){let e=p.find(e=>e.uuid===c.rewindFiles);if(!e||e.type!==`user`){process.stderr.write(`Error: --rewind-files requires a user message UUID, but ${c.rewindFiles} is not a user message in this session\n`),O(1);return}let n=t(),i=await Qa(c.rewindFiles,n,r,!1);if(!i.canRewind){process.stderr.write(`Error: ${i.error||`Unexpected error`}\n`),O(1);return}process.stdout.write(`Files rewound to state at message ${c.rewindFiles}\n`),O(0);return}let ee=typeof c.resume==`string`&&(!!De(c.resume)||c.resume.endsWith(`.jsonl`)),v=!!c.sdkUrl;if(!e&&!ee&&!v){process.stderr.write(`Error: Input must be provided either through stdin or as a prompt argument when using --print
|
|
13
|
-
`),O(1);return}if(c.outputFormat===`stream-json`&&!c.verbose){process.stderr.write(`Error: When using --print, --output-format=stream-json requires --verbose
|
|
14
|
-
`),O(1);return}let te=bn(d.mcp.tools,d.toolPermissionContext),y=[...a,...te],b=Xa(c.sdkUrl?`stdio`:c.permissionPromptToolName,l,()=>t().mcp.tools,e=>{r(e=>({...e,attribution:{...e.attribution,permissionPromptCount:e.attribution.permissionPromptCount+1}})),xi(`requires_action`,e)});c.permissionPromptToolName&&(y=y.filter(e=>!oi(e,c.permissionPromptToolName))),mr(),H(`after_loadInitialMessages`),await Hr(),H(`after_modelStrings`);let ne=c.outputFormat===`json`&&c.verbose,x=[],S;H(`before_runHeadlessStreaming`);for await(let e of Ja(l,d.mcp.clients,[...i,...d.mcp.commands],y,p,b,o,t,r,s,c,h))c.outputFormat===`stream-json`&&c.verbose&&await l.write(e),e.type!==`control_response`&&e.type!==`control_request`&&e.type!==`control_cancel_request`&&!(e.type===`system`&&(e.subtype===`session_state_changed`||e.subtype===`task_notification`||e.subtype===`task_started`||e.subtype===`task_progress`||e.subtype===`post_turn_summary`))&&e.type!==`stream_event`&&e.type!==`keep_alive`&&e.type!==`streamlined_text`&&e.type!==`streamlined_tool_use_summary`&&e.type!==`prompt_suggestion`&&(ne&&x.push(e),S=e);switch(c.outputFormat){case`json`:if(!S||S.type!==`result`)throw Error(`No messages returned`);if(c.verbose){q(U(x)+`
|
|
15
|
-
`);break}q(U(S)+`
|
|
16
|
-
`);break;case`stream-json`:break;default:if(!S||S.type!==`result`)throw Error(`No messages returned`);switch(S.subtype){case`success`:q(S.result.endsWith(`
|
|
17
|
-
`)?S.result:S.result+`
|
|
18
|
-
`);break;case`error_during_execution`:q(`Execution error`);break;case`error_max_turns`:q(`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`:q(`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`:q(`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(nn(),fr())try{let{drainPendingExtraction:e}=await import(`./extractMemories-BqN8fWZ5.js`);await e()}catch{}O(S?.type===`result`&&S?.is_error?1:0)}function Ja(e,r,a,o,d,f,p,g,_,ee,v,y){let b=!1,x,C=!1,w=null,T,E=e.outbound;process.on(`SIGINT`,()=>{gr(`info`,`shutdown_signal`,{signal:`SIGINT`}),T&&!T.signal.aborted&&T.abort(),oe(0)}),tr(async()=>{let t={};for(let e of ot(g()))Cn(e)&&(t[e.type]=(t[e.type]??0)+1);gr(`info`,`run_state_at_shutdown`,{run_active:b,run_phase:x,worker_status:wi(),internal_events_pending:e.internalEventsPending,bg_tasks:t})}),bi(e=>{(e==="default"||e===`acceptEdits`||e===`bypassPermissions`||e===`plan`||e===`auto`||e===`dontAsk`)&&E.enqueue({type:`system`,subtype:`status`,status:null,permissionMode:e,uuid:X(),session_id:m()})});let D={abortController:null,inflightPromise:null,lastEmitted:null,pendingSuggestion:null,pendingLastEmittedEntry:null},ie;v.enableAuthStatus&&(ie=Nr.getInstance().subscribe(e=>{E.enqueue({type:`auth_status`,isAuthenticating:e.isAuthenticating,output:e.output,error:e.error,uuid:X(),session_id:m()})}));let ae=e=>{let t=Ii(e);t&&E.enqueue({type:`rate_limit_event`,rate_limit_info:t,uuid:X(),session_id:m()})};Tn.add(ae);let k=d,A=kt(d,Z(),100),se=li(100),ce=process.env.CLAUDE_CODE_RESUME_INTERRUPTED_TURN;y&&y.kind!==`none`&&ce&&(W(`[print.ts] Auto-resuming interrupted turn (kind: ${y.kind})`),to(k,y.message),Be({mode:`prompt`,value:y.message.message.content,uuid:X()}));let le=Bt().map(e=>{let t=e.value===null?`default`:e.value,n=t==="default"?Gr():kr(t),r=Ge(n),i=st(n),a=Lr(e.value),o=Mr(n);return{name:t,value:t,displayName:e.label,description:e.description,...r&&{supportsEffort:!0,supportedEffortLevels:Ae(n)?[...ne]:ne.filter(e=>e!==`max`)},...i&&{supportsAdaptiveThinking:!0},...a&&{supportsFastMode:!0},...o&&{supportsAutoMode:!0}}}),de=v.userSpecifiedModel;function fe(e,t){let n=Dt(e,Xr(t));k.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=[],M=[],me=new Set;function ge(t){for(let n of t){if(n.type!==`connected`||me.has(n.name)||n.config.type===`sdk`)continue;let t=n.name;try{n.client.setRequestHandler(ji,async(n,r)=>{xr(t,`Elicitation request received in print mode: ${U(n)}`);let i=n.params.mode===`url`?`url`:`form`;Y(`tengu_mcp_elicitation_shown`,{mode:i});let a=await Ye(t,n.params,r.signal);if(a)return xr(t,`Elicitation resolved by hook: ${U(a)}`),Y(`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 An(t,l,r.signal,i,c);return Y(`tengu_mcp_elicitation_response`,{mode:i,action:u.action}),u}),n.client.setNotificationHandler(Ai,e=>{let{elicitationId:n}=e.params;xr(t,`Elicitation completion notification: ${n}`),Fe({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:X(),session_id:m()})}),me.add(t)}catch{}}}async function ye(){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 en(p,(t,n)=>e.sendMcpMessage(t,n));j=r.clients,M=r.tools;let i=dr([...n,...t]);_(e=>({...e,mcp:{...e.mcp,tools:[...e.mcp.tools.filter(e=>!i.some(t=>e.name.startsWith(K(t)))),...M]}})),xe(j)}}ye();let N={clients:[],tools:[],configs:{}},be=e=>{let t=_e(e.toolPermissionContext,e.mcp.tools),n=pe(oa([...o,...M,...N.tools],t,e.toolPermissionContext.mode),`name`);v.permissionPromptToolName&&(n=n.filter(e=>!oi(e,v.permissionPromptToolName)));let r=c();if(r&&!v.jsonSchema){let e=ai(r);`tool`in e&&(n=[...n,e.tool])}return n},P=null,Se=0;function Te(){if(!P)return;let e=Math.min(Se,k.length),t=k.slice(e).filter(e=>e.type===`user`||e.type===`assistant`);Se=k.length,t.length>0&&P.writeMessages(t)}let Ee=Promise.resolve({response:{added:[],removed:[],errors:{}},sdkServersChanged:!1});function De(e){let t=async()=>{let t=new Set(j.map(e=>e.name)),n=await oo(e,{configs:p,clients:j,tools:M},N,_);for(let e of Object.keys(p))delete p[e];if(Object.assign(p,n.newSdkState.configs),j=n.newSdkState.clients,M=n.newSdkState.tools,N=n.newDynamicState,n.sdkServersChanged){let e=new Set(j.map(e=>e.name)),n=dr([...t,...e]);_(e=>({...e,mcp:{...e.mcp,tools:[...e.mcp.tools.filter(e=>!n.some(t=>e.name.startsWith(K(t)))),...M]}}))}return{response:n.response,sdkServersChanged:n.sdkServersChanged}};return Ee=Ee.then(t,t),Ee}function Oe(){let e=g(),t=e.mcp.clients,n=pe([...e.mcp.tools,...N.tools],`name`),r=new Set([...t.map(e=>e.name),...j.map(e=>e.name)]);return[...t,...j,...N.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`?Wt(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 ke(){try{await Promise.all([Promise.resolve(),_r(`headless_managed_settings_wait`,()=>Ji())]),await za()&&await ze()}catch(e){J(e)}}let je=null;i()||(n(process.env.CLAUDE_CODE_SYNC_PLUGIN_INSTALL)?je=ke():ke());let Me=Ma(()=>!b),I=a,L=ee;async function Le(){let{agentDefinitions:e}=await _a(_);I=await yn(Z());let t=L.filter(e=>e.source===`flagSettings`);L=[...e.allAgents,...t]}async function ze(){let{servers:e}=await S(),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 De(t);r&&ye(),W(`Headless MCP refresh: added=${n.added.length}, removed=${n.removed.length}`)}let Ve=ga.subscribe(()=>{Re(),yn(Z()).then(e=>{I=e})}),Ue=()=>{setTimeout(()=>{!$?.isProactiveActive()||$.isProactivePaused()||C||(async()=>{let e=await Ne({basePrompt:`<${yr}>${new Date().toLocaleTimeString()}</${yr}>`,currentDir:Z(),shouldCreate:()=>!C});if(C){await jn({commands:e});return}for(let t of e)Be({...t,uuid:X()});R()})().catch(e=>{J(e),W(`[Proactive] failed to create headless tick: ${e}`,{level:`error`})})},0)};_t(()=>{T&&ve(`now`).length>0&&T.abort(`interrupt`)});let R=async()=>{if(b)return;if(b=!0,x=void 0,xi(`running`),Me.stop(),H(`run_entry`),await ye(),H(`after_updateSdkMcp`),je){let e=parseInt(process.env.CLAUDE_CODE_SYNC_PLUGIN_INSTALL_TIMEOUT_MS||``,10);if(e>0){let t=Qr(e).then(()=>`timeout`);await Promise.race([je,t])===`timeout`&&(J(Error(`CLAUDE_CODE_SYNC_PLUGIN_INSTALL: plugin installation timed out after ${e}ms`)),Y(`tengu_sync_plugin_install_timeout`,{timeout_ms:e}))}else await je;je=null,await Le();let{setupPluginHookHotReload:t}=await import(`./loadPluginHooks-CaKvZVZI.js`);t()}let n=e=>e.agentId===void 0;try{let r,i=!1,a=async()=>{for(;r=Un(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,Ke(n));)i.push(Un(n));let a=await Bn(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,...N.clients];ge(l);let u=be(s);for(let e of o)Ot(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:X()})}let d=r.value,p=a.claimedCommands;if(e instanceof Ea&&r.mode===`prompt`&&Y(`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`&&we(D.lastEmitted.text,e,D.lastEmitted.emittedAt,D.lastEmitted.promptId,D.lastEmitted.generationRequestId),D.lastEmitted=null}T=Rt(),H(`before_ask`),On();let h=r,ee=!1;try{if(await Rr(h.workload??v.workload,async()=>{for await(let t of ca({commands:pe([...I,...s.mcp.commands],`name`),prompt:d,promptUuid:h.uuid,isMeta:h.isMeta,cwd:Z(),tools:u,verbose:v.verbose,mcpClients:l,thinkingConfig:v.thinkingConfig,maxTurns:v.maxTurns,maxBudgetUsd:v.maxBudgetUsd,taskBudget:v.taskBudget,canUseTool:f,userSpecifiedModel:de,fallbackModel:v.fallbackModel,jsonSchema:c()??v.jsonSchema,mutableMessages:k,getReadFileCache:()=>se.size===0?A:di(A,se),setReadFileCache:e=>{A=e;for(let[e,t]of se.entries()){let n=A.get(e);(!n||t.timestamp>n.timestamp)&&A.set(e,t)}se.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:L,orphanedPermission:h.orphanedPermission,setSDKStatus:e=>{E.enqueue({type:`system`,subtype:`status`,status:e,session_id:m(),uuid:X()})}}))if(Te(),t.type===`result`){ee=!!t.is_error;for(let e of fi())E.enqueue(e);ot(g()).some(e=>(e.type===`local_agent`||e.type===`local_workflow`)&&Cn(e))?w=t:(w=null,E.enqueue(t))}else{for(let e of fi())E.enqueue(e);E.enqueue(t)}}),ee)await at({commands:p,outcome:{type:`failed`,message:`ask() returned an error result`},currentDir:Z(),priority:`later`,workload:h.workload??v.workload});else{let e=await at({commands:p,outcome:{type:`completed`},currentDir:Z(),priority:`later`,workload:h.workload??v.workload});for(let t of e)Be({...t,uuid:X()})}}catch(e){throw await at({commands:p,outcome:{type:`failed`,error:e},currentDir:Z(),priority:`later`,workload:h.workload??v.workload}),e}for(let e of o)Ot(e,`completed`);if(Te(),P?.sendResult(),v.promptSuggestions&&!t(process.env.CLAUDE_CODE_ENABLE_PROMPT_SUGGESTION)){D.abortController?.abort();let e=new AbortController;D.abortController=e;let t=qt();if(!t)Ht(`sdk_no_params`,void 0,void 0,`sdk`);else{let n={promise:null};n.promise=(async()=>{try{let n=await zt(e,k,g,t,`sdk`);if(!n||e.signal.aborted)return;let r={type:`prompt_suggestion`,suggestion:n.suggestion,uuid:X(),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`)){Ht(`aborted`,void 0,void 0,`sdk`);return}J(Yn(e))}finally{D.inflightPromise===n.promise&&(D.inflightPromise=null)}})(),D.inflightPromise=n.promise}}nn(),pt(),Ct()}};do{for(let e of fi())E.enqueue(e);x=`draining_commands`,await a(),i=!1;{let e=ot(g()).some(e=>Cn(e)),t=Ke(n)!==void 0;(e||t)&&(i=!0,t||(x=`waiting_for_agents`,await Qr(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:Si,modelUsage:{},permission_denials:[],uuid:X(),errors:[G(t),...Sr().map(e=>e.error)]})}catch{}D.abortController?.abort(),O(1);return}finally{if(x=`finally_flush`,await e.flushInternalEvents(),x=`finally_post_flush`,!Ut()){xi(`idle`);for(let e of fi())E.enqueue(e)}b=!1,Me.start()}if($?.isProactiveActive()&&!$.isProactivePaused()&&Ke(n)===void 0&&!C){Ue();return}if(Ke(n)!==void 0){R();return}C&&(D.inflightPromise&&await Promise.race([D.inflightPromise,Qr(5e3)]),D.abortController?.abort(),D.abortController=null,await Ce(),Ve(),ie?.(),Tn.delete(ae),E.done())},z=function(e,t){E.enqueue({type:`control_response`,response:{subtype:`success`,request_id:e.request_id,response:t}})},B=function(e,t){E.enqueue({type:`control_response`,response:{subtype:`error`,request_id:e.request_id,error:t}})},qe=new Set;e.setUnexpectedResponseCallback(async e=>{await io({message:e,setAppState:_,handledToolUseIds:qe,onEnqueued:()=>{R()}})});let Je=new Map,Ze=new Map,Qe=new Set,$e=new Map,V=null;return(async()=>{let t=!1;gr(`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`&&Ot(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,z(i);else if(o.subtype===`end_session`){W(`[print.ts] end_session received, reason=${o.reason??`unspecified`}`),T&&T.abort(),D.abortController?.abort(),D.abortController=null,D.lastEmitted=null,D.pendingSuggestion=null,z(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,le,e,!!v.enableAuthStatus,v,ee,g),i.request.promptSuggestions&&_(e=>e.promptSuggestionEnabled?e:{...e,promptSuggestionEnabled:!0}),i.request.agentProgressSummaries&&h(!0),t=!0,xn()&&R()}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"?Gr():e;de=t,u(t),Ci({model:t}),fe(e,t),z(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},z(i);else if(i.request.subtype===`mcp_status`)z(i,{mcpServers:Oe()});else if(i.request.subtype===`get_context_usage`)try{let e=g(),t=await fa({messages:k,getAppState:g,options:{mainLoopModel:Jr(),tools:be(e),agentDefinitions:e.agentDefinitions,customSystemPrompt:v.systemPrompt,appendSystemPrompt:v.appendSystemPrompt}});z(i,{...t})}catch(e){B(i,G(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),z(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?z(i,t):B(i,t.error??`Unexpected error`)}else if(i.request.subtype===`cancel_async_message`){let e=i.request.message_uuid,t=re(t=>t.uuid===e);z(i,{cancelled:t.length>0})}else if(i.request.subtype===`seed_read_state`){try{let e=Tr(i.request.path),t=Math.floor((await Ca(e)).mtimeMs);if(t<=i.request.mtime){let n=await Sa(e,`utf-8`),r=(n.charCodeAt(0)===65279?n.slice(1):n).replaceAll(`\r
|
|
20
|
-
`,`
|
|
21
|
-
`);se.set(e,{content:r,timestamp:t,offset:void 0,limit:void 0})}}catch{}z(i)}else if(i.request.subtype===`mcp_set_servers`){let{response:e,sdkServersChanged:t}=await De(i.request.servers);z(i,e),t&&ye()}else if(i.request.subtype===`reload_plugins`)try{let e=await _a(_),t=L.filter(e=>e.source===`flagSettings`);L=[...e.agentDefinitions.allAgents,...t];let n=[],[r,a,o]=await Promise.allSettled([yn(Z()),ze(),tn()]);r.status===`fulfilled`?I=r.value:J(r.reason),a.status===`rejected`&&J(a.reason),o.status===`fulfilled`?n=o.value.enabled.map(e=>({name:e.name,path:e.path,source:e.source})):J(o.reason),z(i,{commands:I.filter(e=>e.userInvocable!==!1).map(e=>({name:ct(e),description:He(e),argumentHint:e.argumentHint||``})),agents:L.map(e=>({name:e.agentType,description:e.whenToUse,model:e.model===`inherit`?void 0:e.model})),plugins:n,mcpServers:Oe(),error_count:e.error_count})}catch(e){B(i,G(e))}else if(i.request.subtype===`mcp_reconnect`){let e=g(),{serverName:t}=i.request;me.delete(t);let n=ue(t)??r.find(e=>e.name===t)?.config??j.find(e=>e.name===t)?.config??N.clients.find(e=>e.name===t)?.config??e.mcp.clients.find(e=>e.name===t)?.config??null;if(!n)B(i,`Server not found: ${t}`);else{let e=await mn(t,n),r=K(t);if(_(n=>({...n,mcp:{...n.mcp,clients:n.mcp.clients.map(n=>n.name===t?e.client:n),tools:[...F(n.mcp.tools,e=>e.name?.startsWith(r)),...e.tools],commands:[...F(n.mcp.commands,e=>Ln(e,t)),...e.commands],resources:e.resources&&e.resources.length>0?{...n.mcp.resources,[t]:e.resources}:si(n.mcp.resources,t)}})),N={...N,clients:[...N.clients.filter(e=>e.name!==t),e.client],tools:[...N.tools.filter(e=>!e.name?.startsWith(r)),...e.tools]},e.client.type===`connected`)ge([e.client]),z(i);else{let t=e.client.type===`failed`?e.client.error??`Connection failed`:`Server status: ${e.client.type}`;B(i,t)}}}else if(i.request.subtype===`mcp_toggle`){let e=g(),{serverName:t,enabled:n}=i.request;me.delete(t);let a=ue(t)??r.find(e=>e.name===t)?.config??j.find(e=>e.name===t)?.config??N.clients.find(e=>e.name===t)?.config??e.mcp.clients.find(e=>e.name===t)?.config??null;if(!a)B(i,`Server not found: ${t}`);else if(n){We(t,!0);let e=await mn(t,a),n=K(t);if(_(r=>({...r,mcp:{...r.mcp,clients:r.mcp.clients.map(n=>n.name===t?e.client:n),tools:[...F(r.mcp.tools,e=>e.name?.startsWith(n)),...e.tools],commands:[...F(r.mcp.commands,e=>Ln(e,t)),...e.commands],resources:e.resources&&e.resources.length>0?{...r.mcp.resources,[t]:e.resources}:si(r.mcp.resources,t)}})),e.client.type===`connected`)ge([e.client]),z(i);else{let t=e.client.type===`failed`?e.client.error??`Connection failed`:`Server status: ${e.client.type}`;B(i,t)}}else{We(t,!1);let n=[...r,...j,...N.clients,...e.mcp.clients].find(e=>e.name===t);n&&n.type===`connected`&&await It(t,a);let o=K(t);_(e=>({...e,mcp:{...e.mcp,clients:e.mcp.clients.map(e=>e.name===t?{name:t,type:`disabled`,config:a}:e),tools:F(e.mcp.tools,e=>e.name?.startsWith(o)),commands:F(e.mcp.commands,e=>Ln(e,t)),resources:si(e.mcp.resources,t)}})),z(i)}}else if(o.subtype===`mcp_authenticate`){let e=o.serverName,t=g(),n=ue(e)??r.find(t=>t.name===e)?.config??t.mcp.clients.find(t=>t.name===e)?.config??null;if(!n)B(i,`Server not found: ${e}`);else if(n.type!==`sse`&&n.type!==`http`)B(i,`Server type "${n.type}" does not support OAuth authentication`);else try{Je.get(e)?.abort();let t=new AbortController;Je.set(e,t);let r,a=new Promise(e=>{r=e}),o=Ft(e,n,e=>r(e),t.signal,{skipBrowserOpen:!0,onWaitingForCallback:t=>{Ze.set(e,t)}}),s=await Promise.race([a,o.then(()=>null)]);s?z(i,{authUrl:s,requiresUserAction:!0}):z(i,{requiresUserAction:!1}),$e.set(e,o),o.then(async()=>{if(he(e)||Qe.has(e))return;let t=await mn(e,n),r=K(e);_(n=>({...n,mcp:{...n.mcp,clients:n.mcp.clients.map(n=>n.name===e?t.client:n),tools:[...F(n.mcp.tools,e=>e.name?.startsWith(r)),...t.tools],commands:[...F(n.mcp.commands,t=>Ln(t,e)),...t.commands],resources:t.resources&&t.resources.length>0?{...n.mcp.resources,[e]:t.resources}:si(n.mcp.resources,e)}})),N={...N,clients:[...N.clients.filter(t=>t.name!==e),t.client],tools:[...N.tools.filter(e=>!e.name?.startsWith(r)),...t.tools]}}).catch(t=>{W(`MCP OAuth failed for ${e}: ${t}`,{level:`error`})}).finally(()=>{Je.get(e)===t&&(Je.delete(e),Ze.delete(e),Qe.delete(e),$e.delete(e))})}catch(e){B(i,G(e))}}else if(o.subtype===`mcp_oauth_callback_url`){let e=o.serverName,t=o.callbackUrl,n=Ze.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)B(i,`Invalid callback URL: missing authorization code. Please paste the full redirect URL including the code parameter.`);else{Qe.add(e),n(t);let r=$e.get(e);if(r)try{await r,z(i)}catch(e){B(i,e instanceof Error?e.message:`OAuth authentication failed`)}else z(i)}}else B(i,`No active OAuth flow for server: ${e}`)}else if(o.subtype===`claude_authenticate`){let e=o.loginWithClaudeAi;V?.service.cleanup(),Y(`tengu_oauth_flow_start`,{loginWithClaudeAi:e??!0});let t=new Yi,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 Xi(t),Y(`tengu_oauth_success`,{loginWithClaudeAi:e??!0})}).finally(()=>{t.cleanup(),V?.service===t&&(V=null)});V={service:t,flow:a},a.catch(e=>W(`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`)})]);z(i,{manualUrl:e,automaticUrl:t})}catch(e){B(i,G(e))}}else if(o.subtype===`claude_oauth_callback`||o.subtype===`claude_oauth_wait_for_completion`)if(!V)B(i,`No active claude_authenticate flow`);else{o.subtype===`claude_oauth_callback`&&V.service.handleManualAuthCodeInput({authorizationCode:o.authorizationCode,state:o.state});let{flow:e}=V;e.then(()=>{let e=Zr();z(i,{account:{email:e?.email,organization:e?.organization,subscriptionType:e?.subscription,tokenSource:e?.tokenSource,apiKeySource:e?.apiKeySource,apiProvider:Br()}})},e=>B(i,G(e)))}else if(o.subtype===`mcp_clear_auth`){let e=o.serverName,t=g(),n=ue(e)??r.find(t=>t.name===e)?.config??t.mcp.clients.find(t=>t.name===e)?.config??null;if(!n)B(i,`Server not found: ${e}`);else if(n.type!==`sse`&&n.type!==`http`)B(i,`Cannot clear auth for server type "${n.type}"`);else{await un(e,n);let t=await mn(e,n),r=K(e);_(n=>({...n,mcp:{...n.mcp,clients:n.mcp.clients.map(n=>n.name===e?t.client:n),tools:[...F(n.mcp.tools,e=>e.name?.startsWith(r)),...t.tools],commands:[...F(n.mcp.commands,t=>Ln(t,e)),...t.commands],resources:t.resources&&t.resources.length>0?{...n.mcp.resources,[e]:t.resources}:si(n.mcp.resources,e)}})),z(i,{})}}else if(i.request.subtype===`apply_flag_settings`){let e=Jr(),t=s()??{},n=i.request.settings,r={...t,...n};for(let e of Object.keys(r))r[e]===null&&delete r[e];l(r),Ie.notifyChange(`flagSettings`),`model`in n&&(n.model==null?u(void 0):u(String(n.model)));let a=Jr();if(a!==e){de=a;let e=n.model?String(n.model):`default`;Ci({model:a}),fe(e,a)}z(i)}else if(i.request.subtype===`get_settings`){let e=g(),t=Jr(),n=Ge(t)?Dn(t,e.effortValue):void 0;z(i,{...sr(),applied:{model:t,effort:typeof n==`string`?n:null}})}else if(i.request.subtype===`stop_task`){let{task_id:e}=i.request;try{await Xt(e,{getAppState:g,setAppState:_}),z(i,{})}catch(e){B(i,G(e))}}else if(o.subtype===`generate_session_title`){let e=o.description,t=o.persist,n=(T&&!T.signal.aborted?T:Rt()).signal;(async()=>{try{let r=await Li(e,n);if(r&&t)try{Xe(m(),r)}catch(e){J(e)}z(i,{title:r})}catch(e){B(i,G(e))}})()}else if(o.subtype===`side_question`){let e=o.question;(async()=>{try{let t=qt(),n=t?{...t,toolUseContext:{...t.toolUseContext,abortController:Rt()}}:await la({tools:be(g()),commands:I,mcpClients:[...g().mcp.clients,...j,...N.clients],messages:k,readFileState:A,getAppState:g,setAppState:_,customSystemPrompt:v.systemPrompt,appendSystemPrompt:v.appendSystemPrompt,thinkingConfig:v.thinkingConfig,agents:L}),r=await da({question:e,cacheSafeParams:n});z(i,{response:r.response})}catch(e){B(i,G(e))}})()}else if(i.request.subtype===`set_proactive`)i.request.enabled?$.isProactiveActive()||($.activateProactive(`command`),Ue()):$.deactivateProactive(),z(i);else if(o.subtype===`remote_control`)if(o.enabled)if(P)z(i,{session_url:te(P.bridgeSessionId,P.sessionIngressUrl),connect_url:Pe(P.environmentId,P.sessionIngressUrl),environment_id:P.environmentId});else{let t;try{let{initReplBridge:n}=await import(`./initReplBridge-CjuO6in6.js`),r=await n({onInboundMessage(e){let t=ia(e);if(!t)return;let{content:n,uuid:r}=t;Be({value:n,mode:`prompt`,uuid:r,skipSlashCommands:!0}),R()},onPermissionResponse(t){e.injectControlResponse(t)},onInterrupt(){T?.abort()},onSetModel(e){let t=e==="default"?Gr():e;de=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),W(`[bridge:sdk] State change: ${e}${n?` — ${n}`:``}`),E.enqueue({type:`system`,subtype:`bridge_state`,state:e,detail:n,uuid:X(),session_id:m()})},initialMessages:k.length>0?k:void 0});r?(P=r,Se=k.length,e.setOnControlRequestSent(e=>{r.sendControlRequest(e)}),e.setOnControlRequestResolved(e=>{r.sendControlCancelRequest(e)}),z(i,{session_url:te(r.bridgeSessionId,r.sessionIngressUrl),connect_url:Pe(r.environmentId,r.sessionIngressUrl),environment_id:r.environmentId})):B(i,t??`Remote Control initialization failed`)}catch(e){B(i,G(e))}}else P&&(e.setOnControlRequestSent(void 0),e.setOnControlRequestResolved(void 0),await P.teardown(),P=null),z(i);else B(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=Pi([n]);k.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 Lt(e,o.uuid);if(t||Va.has(o.uuid)){W(`Skipping duplicate user message: ${o.uuid}`),v.replayUserMessages&&(W(`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&&Ot(o.uuid,`completed`);continue}Ua(o.uuid)}Be({mode:`prompt`,value:await Ni(o,o.message.content),uuid:o.uuid,priority:o.priority}),_(e=>({...e,attribution:Di(e.attribution,e=>{vt(e).catch(e=>{W(`Attribution: Failed to save snapshot: ${e}`)})})})),R()}C=!0,b||(D.inflightPromise&&await Promise.race([D.inflightPromise,Qr(5e3)]),D.abortController?.abort(),D.abortController=null,await Ce(),Ve(),ie?.(),Tn.delete(ae),E.done())})(),E}function Ya(e){let t=async(n,r,i,a,o,s)=>{let c=s??await Ve(n,r,i,a,o);if(c.behavior===`allow`||c.behavior===`deny`)return c;let{signal:l,cleanup:u}=T(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 ta(aa().parse(Dr(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 Ve(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=>oi(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`),O(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`),O(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=yt(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&&!wn(t)){let e=t.getSystemPrompt();e&&(c.systemPrompt=e)}!c.userSpecifiedModel&&t.model&&t.model!==`inherit`&&u(kr(t.model)),t.initialPrompt&&o.prependUserMessage(t.initialPrompt)}else t?.initialPrompt&&o.prependUserMessage(t.initialPrompt)}let h=cr()?.outputStyle||`default`,ee=await V(Kn()),v=Zr();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:ct(e),description:He(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:Br()},pid:process.pid};if(Vr()&&Wr()){let e=p();te.fast_mode_state=Fr(c.userSpecifiedModel??null,e.fastMode)}if(r.enqueue({type:`control_response`,response:{subtype:`success`,request_id:t,response:te}}),s){let e=Nr.getInstance().getStatus();e&&r.enqueue({type:`auth_status`,isAuthenticating:e.isAuthenticating,output:e.output,error:e.error,uuid:X(),session_id:m()})}}async function Qa(e,t,n,r){if(!Wn())return{canRewind:!1,error:`File rewinding is not enabled.`,filesChanged:[]};if(!Me(t.fileHistory,e))return{canRewind:!1,error:`No file checkpoint found for this message.`,filesChanged:[]};if(r){let n=await C(t.fileHistory,e);return{canRewind:!0,filesChanged:n?.filesChanged??[],insertions:n?.insertions,deletions:n?.deletions}}try{await Ue(e=>n(t=>({...t,fileHistory:e(t.fileHistory)})),e)}catch(e){return{canRewind:!1,error:`Failed to rewind: ${G(e)}`,filesChanged:[]}}return{canRewind:!0,filesChanged:[]}}function $a(e,t,n,r){if(e.mode===`bypassPermissions`){if(E())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`&&!k()){let e=Nn();return r.enqueue({type:`control_response`,response:{subtype:`error`,request_id:t,error:e?`Cannot set permission mode to auto: ${nt(e)}`:`Cannot set permission mode to auto`}}),n}return r.enqueue({type:`control_response`,response:{subtype:`success`,request_id:t,response:{mode:e.mode}}}),{...Oe(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:Si,modelUsage:{},permission_denials:[],uuid:X(),errors:[e]};process.stdout.write(U(t)+`
|
|
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{Y(`tengu_continue_print`,{});let n=await Zt(void 0,void 0);if(n)return t.forkSession||n.sessionId&&(v(Pt(n.sessionId),n.fullPath?ya(n.fullPath):null),r&&await xt()),ha(n,e),hn(t.forkSession?{...n,worktreeSession:void 0}:n),{messages:n.messages,turnInterruptionState:n.turnInterruptionState,agentSetting:n.agentSetting}}catch(e){return J(e),O(1),{messages:[]}}if(t.teleport)try{if(!I(`allow_remote_sessions`))throw Error(`Remote sessions are disabled by your organization's policy.`);if(Y(`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-DjIgQeBB.js`);await i();let a=await r(t.teleport),{branchError:o}=await e(a.branch);return{messages:n(a.log,o)}}catch(e){return J(e),O(1),{messages:[]}}if(t.resume)try{Y(`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),O(1),{messages:[]}}if(n(process.env.CLAUDE_CODE_USE_CCR_V2)){let[,n]=await Promise.all([Jt(i.sessionId),t.restoredWorkerState]);n&&(e(Qi(n)),typeof n.model==`string`&&u(n.model))}else i.isUrl&&i.ingressUrl&&n(process.env.ENABLE_SESSION_PERSISTENCE)&&await b(i.sessionId,i.ingressUrl);let a=await Zt(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??_n(`startup`))}:(eo(`No conversation found with session ID: ${i.sessionId}`,t.outputFormat),O(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),O(1),{messages:[]};a.messages=e>=0?a.messages.slice(0,e+1):[]}return!t.forkSession&&a.sessionId&&(v(Pt(a.sessionId),a.fullPath?ya(a.fullPath):null),r&&await xt()),ha(a,e),hn(t.forkSession?{...a,worktreeSession:void 0}:a),{messages:a.messages,turnInterruptionState:a.turnInterruptionState,agentSetting:a.agentSetting}}catch(e){return J(e),eo(e instanceof Error?`Failed to resume session: ${e.message}`:`Failed to resume session with --print mode`,t.outputFormat),O(1),{messages:[]}}return{messages:await(t.sessionStartHooksPromise??_n(`startup`))}}function ro(e,t){let n;return n=typeof e==`string`?e.trim()===``?rt([]):rt([U({type:`user`,content:e,uuid:``,session_id:``,message:{role:`user`,content:e},parent_tool_use_id:null})]):e,t.sdkUrl?new Ea(t.sdkUrl,n,t.replayUserMessages):new ea(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(W(`handleOrphanedPermissionResponse: received orphaned control_response for toolUseID=${t} request_id=${i.request_id}`),r.has(t))return W(`handleOrphanedPermissionResponse: skipping duplicate orphaned permission for toolUseID=${t} (already handled)`),!1;let a=await dt(t);return a?(r.add(t),W(`handleOrphanedPermissionResponse: enqueuing orphaned permission for toolUseID=${t} messageID=${a.message.id}`),Be({mode:`orphaned-permission`,value:[],orphanedPermission:{permissionResult:e,assistantMessage:a}}),n?.(),!0):(W(`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}=Vn(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||!on(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){J(e)}await It(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 $e(t,r);if(d.push(e),e.type===`connected`){let t=await ut(e);f.push(...t)}else e.type===`failed`&&(u[t]=e.error||`Connection failed`);l.push(t)}catch(e){let n=Yn(e);u[t]=n.message,J(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 +0,0 @@
|
|
|
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,Hp as o,Jg as s,Jm as c,So as l,Vp as u,Yg as d,Ym as f,Yo as p,_u as m,kp as h,oC as g,sC as _,vo as v,vu as y,xo as b,zo as x}from"./loadAgentsDir-ZQwvbURI.js";import{F as S,U as C,z as w}from"./debug-DiuXEmUq.js";import{g as T,n as E}from"./settings-BhvhCpVh.js";import{n as D,r as O}from"./analytics-BotDBGh0.js";import{Dt as k,Et as A}from"./prompt-wys9CwDo.js";import{randomUUID as j}from"crypto";n(),r(),y(),f(),o();var M=i();function N({input:e,progress:n,verbose:r}){return(0,M.jsxs)(t,{flexDirection:`column`,marginTop:1,children:[(0,M.jsx)(c,{addMargin:!1,param:{text:`<bash-input>${e}</bash-input>`,type:`text`}}),n?(0,M.jsx)(u,{fullOutput:n.fullOutput,output:n.output,elapsedTimeSeconds:n.elapsedTimeSeconds,totalLines:n.totalLines,verbose:r}):m.renderToolUseProgressMessage?.([],{verbose:r,tools:[],terminalSize:void 0})]})}C(),D(),s(),x(),T();function P(){return E().defaultShell??`bash`}y(),A(),_();async function F(t,n,r,i,o){let s=k()&&P()===`powershell`;O(`tengu_input_bash`,{powershell:s});let c=l({content:p({inputString:`<bash-input>${t}</bash-input>`,precedingInputBlocks:n})}),u;o({jsx:(0,M.jsx)(N,{input:t,progress:null,verbose:i.options.verbose}),shouldHidePromptInput:!1});try{let n={...i,setToolJSX:e=>{u=e?.jsx}},f=e=>{o({jsx:(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(N,{input:t,progress:e.data,verbose:i.options.verbose}),u]}),shouldHidePromptInput:!1,showSpinner:!1})},p=null;s&&(p=(a(),e(h)).PowerShellTool);let _=p??m,y=(p?await p.call({command:t,dangerouslyDisableSandbox:!0},n,void 0,void 0,f):await m.call({command:t,dangerouslyDisableSandbox:!0},n,void 0,void 0,f)).data;if(!y)throw Error(`No result received from shell command`);let b=y.stderr,x=await d(_,{...y,stderr:``},j()),S=typeof x.content==`string`?x.content:g(y.stdout);return{messages:[v(),c,...r,l({content:`<bash-stdout>${S}</bash-stdout><bash-stderr>${g(b)}</bash-stderr>`})],shouldQuery:!1}}catch(e){return e instanceof S?e.interrupted?{messages:[v(),c,b({toolUse:!1}),...r],shouldQuery:!1}:{messages:[v(),c,...r,l({content:`<bash-stdout>${g(e.stdout)}</bash-stdout><bash-stderr>${g(e.stderr)}</bash-stderr>`})],shouldQuery:!1}:{messages:[v(),c,...r,l({content:`<bash-stderr>Command failed: ${g(w(e))}</bash-stderr>`})],shouldQuery:!1}}finally{o(null)}}export{F as processBashCommand};
|
|
@@ -1,5 +0,0 @@
|
|
|
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,Av as o,Bo as s,C as c,Cw as l,Dc as u,Dv as d,Dw as f,Ec as p,Eo as m,Ev as h,Fv as g,G as _,Gh as v,Hw as y,Jd as b,Jw as x,Kh as S,Ki as C,MD as w,Mv as T,Ol as E,Qi as D,RT as O,SC as k,Sl as ee,So as A,Th as j,Ui as te,VT as ne,Vw as re,W as ie,Wh as ae,Wo as oe,Yd as se,Yo as M,Zi as ce,aw as le,bD as N,bS as ue,bl as de,cE as fe,ca as P,cw as pe,cx as me,ho as F,iw as he,jD as ge,jl as I,jv as L,k as _e,kc as ve,lx as ye,oE as be,qo as xe,sw as Se,vS as Ce,vo as R,wh as we,ww as Te,xC as Ee,xD as z,xo as De,yD as Oe,yS as ke,yo as Ae,zi as je,zo as Me}from"./loadAgentsDir-ZQwvbURI.js";import{P as B,U as Ne,_ as Pe,h as Fe,j as Ie,l as V,p as H}from"./debug-DiuXEmUq.js";import{Mt as Le,jt as Re}from"./settings-BhvhCpVh.js";import{T as U,Y as ze,o as Be,s as W,w as G}from"./log-Duzb4o6h.js";import{f as Ve,l as He}from"./file-BZriE-XU.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-BgrLt7P7.js";import{h as Je,p as Ye}from"./metadata-CIx5CsoY.js";import{E as Xe,T as Ze,w as Qe}from"./sessionTracing-BBxhPccY.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}'`),S(e,t,o,s)}:void 0;ae(e,t,o,n.matcher||``,s,c,i),a++}}a>0&&H(`Registered ${a} hooks from skill '${r}'`)}var nt=e((()=>{Le(),V(),v()}));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=h(),c=e.pluginInfo?z(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},...T(e.pluginInfo)}});let{skillContent:u,modifiedGetAppState:d,baseAgent:f,promptMessages:p}=await I(e,t,n),m=e.effort===void 0?f:{...f,effort:e.effort};H(`Executing forked slash command /${e.name} with agent ${m.agentType}`);let g=await n.getAppState();n.options.allowBackgroundForkedSlashCommands===!0&&rt();let _=!1;if(g.kairosEnabled&&(_=!0),_){let t=he(),r=P(e),i=We(),c=e=>y({value:e,mode:`prompt`,priority:`later`,isMeta:!0,skipSlashCommands:!0,workload:i}),u=async()=>{if(!o?.runId)return;let e=await l({runId:o.runId,rootDir:o.rootDir,priority:`later`,workload:i});for(let t of e)re(t)},f=async e=>{o?.runId&&await Te({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 j({agentDefinition:m,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=E(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 v=[],b=[],x=`forked-command-${e.name}`,S=0,C=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()}),w=()=>{i({jsx:se(b,{tools:n.options.tools,verbose:!1}),shouldHidePromptInput:!1,shouldContinueAnimation:!0,showSpinner:!0})};w();try{for await(let t of j({agentDefinition:m,promptMessages:p,toolUseContext:{...n,getAppState:d},canUseTool:a,isAsync:!1,querySource:`agent:custom`,model:e.model,availableTools:n.options.tools})){v.push(t);let e=xe([t]);if(t.type===`assistant`){let r=O(t);r>0&&n.setResponseLength(e=>e+r);let i=e[0];i&&i.type===`assistant`&&(b.push(C(t)),w())}if(t.type===`user`){let t=e[0];t&&t.type===`user`&&(b.push(C(t)),w())}}}finally{i(null)}let D=E(v,`Command completed`);return H(`Forked slash command /${e.name} completed with agent ${s}`),process.env.USER_TYPE===`ant`&&(D=`[ANT-ONLY] API calls: ${He(Se(s))}\n${D}`),{messages:[A({content:M({inputString:`/${P(e)} ${t}`.trim(),precedingInputBlocks:r})}),A({content:`<local-command-stdout>\n${D}\n</local-command-stdout>`})],shouldQuery:!1,command:e,resultText:D}}function at(e){return!/[^a-zA-Z0-9:\-_]/.test(e)}async function ot(e,t,n,i,a,o,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:[R(),...i,A({content:M({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(!ce(p,a.options.commands)){let n=!1;try{await Fe().stat(`/${p}`),n=!0}catch{}if(at(p)&&!n){K(`tengu_input_slash_invalid`,{input:p});let e=`Unknown skill: ${p}`;return{messages:[R(),...i,A({content:M({inputString:e,precedingInputBlocks:t})}),...m?[Ae(`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:[A({content:M({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:E,deferAutonomyCompletion:D}=await st(p,m,o,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}=z(n),i=N(r);e._PROTO_plugin_name=t.name,r&&(e._PROTO_marketplace_name=r),e.plugin_repository=i?n:`third-party`,e.plugin_name=i?t.name:`third-party`,i&&t.version&&(e.plugin_version=t.version),Object.assign(e,T(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:E,deferAutonomyCompletion:D}}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:[R(),..._],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}=z(t),r=N(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,T(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]&&s(_[0]);return{messages:v||_.every(oe)||k?_:[R(),..._],shouldQuery:v,allowedTools:y,model:b,effort:x,resultText:C,nextInput:w,submitNextInput:E,deferAutonomyCompletion:D}}async function st(e,t,n,r,i,a,o,s,c,l){let u=C(e,r.options.commands);if(u.type===`prompt`&&u.userInvocable!==!1&&L(e),u.userInvocable===!1)return{messages:[A({content:M({inputString:`/${e}`,precedingInputBlocks:i})}),A({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=>A({content:e,isMeta:!0})),s=ye()&&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]:[A({content:M({inputString:Y(u,c),precedingInputBlocks:i})}),A(n?{content:`<local-command-stdout>${n}</local-command-stdout>`}:{content:`<local-command-stdout>${ge}</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=A({content:M({inputString:Y(u,u.isSensitive&&t.trim()?`***`:t),precedingInputBlocks:i})});try{let n=R(),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?[A({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 fe(),{messages:de(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??ie,l):await Z(u,t,r,i,a,c)}catch(e){return e instanceof Ie?{messages:[A({content:M({inputString:Y(u,t),precedingInputBlocks:i})}),De({toolUse:!1})],shouldQuery:!1,command:u}:{messages:[A({content:M({inputString:Y(u,t),precedingInputBlocks:i})}),A({content:`<local-command-stderr>${String(e)}</local-command-stderr>`})],shouldQuery:!1,command:u}}}}catch(e){if(e instanceof B)return{messages:[A({content:M({inputString:e.message,precedingInputBlocks:i})})],shouldQuery:!1,command:u};throw e}}function Y(e,t){return m(P(e),t)}function X(e,t=`loading`){return[`<${G}>${e}</${G}>`,`<${U}>${e}</${U}>`,`<skill-format>true</skill-format>`].join(`
|
|
2
|
-
`)}function ct(e,t){return[`<${G}>${e}</${G}>`,`<${U}>/${e}</${U}>`,t?`<command-args>${t}</command-args>`:null].filter(Boolean).join(`
|
|
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=te(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 c=await e.getPromptForCommand(t,r),l=!ke(`hooks`)||ue(e.source);if(e.hooks&&l){let t=n();tt(r.setAppState,t,e.hooks,e.name,e.type===`prompt`?e.skillRoot:void 0)}let d=e.source?`${e.source}:${e.name}`:e.name,f=c.filter(e=>e.type===`text`).map(e=>e.text).join(`
|
|
4
|
-
|
|
5
|
-
`);i(e.name,d,f,Ye()?.agentId??null);let m=lt(e,t),h=_e(e.allowedTools??[]),g=o.length>0||a.length>0?[...o,...a,...c]:c,_=await k(u(c.filter(e=>e.type===`text`).map(e=>e.text).join(` `),r,null,[],r.messages,`repl_main_thread`,{skipSkillDiscovery:!0}));return{messages:[A({content:m,uuid:s}),A({content:g,isMeta:!0}),..._,p({type:`command_permissions`,allowedTools:h,model:e.model})],shouldQuery:!0,allowedTools:h,model:e.model,effort:e.effort,command:e}}var Q,$;e((()=>{t(),D(),w(),ze(),Ue(),pe(),ee(),be(),we(),b(),le(),Je(),ve(),V(),Ne(),Ve(),a(),Pe(),me(),Ee(),nt(),Be(),x(),Me(),c(),_(),Oe(),Ce(),et(),Ke(),o(),Qe(),g(),ne(),d(),f(),Ge(),Q=200,$=1e4}))();export{X as formatSkillLoadingMetadata,ut as processPromptSlashCommand,ot as processSlashCommand};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e,r as t}from"./prompt-wys9CwDo.js";t();export{e as isDeferredTool};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{EE as e,bE as t}from"./loadAgentsDir-ZQwvbURI.js";e();export{t as clearPromptCache};
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
import{n as e,o as t,r as n}from"./rolldown-runtime-DaDcL9Zw.js";import{c as r,l as i,o as a}from"./envUtils-DSxRz_kt.js";import{n as o,t as s}from"./defineProperty-C-QyHrDq.js";import{A as c,C as l,M as u,t as d,w as f}from"./v4-jw6qOKwQ.js";import{E as ee,I as te,O as ne,U as re}from"./debug-DiuXEmUq.js";import{J as ie,Q as ae,X as oe,Y as se,Z as ce,nt as le}from"./settings-BhvhCpVh.js";import{U as ue,Y as de}from"./log-Duzb4o6h.js";import{i as fe,o as pe}from"./platform-B5dCGT8t.js";import{n as me,t as he}from"./lazySchema-uxlVVNM1.js";import{_ as ge,u as _e}from"./model-BgrLt7P7.js";import{t as ve}from"./ajv-5vMo9UcX.js";import{join as p,parse as ye,resolve as m,sep as be}from"node:path";import{createHash as xe}from"node:crypto";import{appendFile as Se,mkdir as Ce,readFile as h,readdir as we,rm as Te,writeFile as Ee}from"node:fs/promises";function De(e){return e.filter(e=>e.data?.type!==`hook_progress`)}function Oe(e,t){return e.name===t||(e.aliases?.includes(t)??!1)}function ke(e,t){return e.find(e=>Oe(e,t))}function Ae(e){return{...Me,userFacingName:()=>e.name,...e}}var je,Me,Ne=e((()=>{je=()=>({mode:`default`,additionalWorkingDirectories:new Map,alwaysAllowRules:{},alwaysDenyRules:{},alwaysAskRules:{},isBypassPermissionsModeAvailable:!0}),Me={isEnabled:()=>!0,isConcurrencySafe:e=>!1,isReadOnly:e=>!1,isDestructive:e=>!1,checkPermissions:(e,t)=>Promise.resolve({behavior:`allow`,updatedInput:e}),toAutoClassifierInput:e=>``,userFacingName:e=>``}})),g,_=e((()=>{g=`Bash`}));function Pe(){return`A powerful search tool built on ripgrep
|
|
2
|
-
|
|
3
|
-
Usage:
|
|
4
|
-
- ALWAYS use ${v} for search tasks. NEVER invoke \`grep\` or \`rg\` as a ${g} command. The ${v} tool has been optimized for correct permissions and access.
|
|
5
|
-
- Supports full regex syntax (e.g., "log.*Error", "function\\s+\\w+")
|
|
6
|
-
- Filter files with glob parameter (e.g., "*.js", "**/*.tsx") or type parameter (e.g., "js", "py", "rust")
|
|
7
|
-
- Output modes: "content" shows matching lines, "files_with_matches" shows only file paths (default), "count" shows match counts
|
|
8
|
-
- Use ${ae} tool for open-ended searches requiring multiple rounds
|
|
9
|
-
- Pattern syntax: Uses ripgrep (not grep) - literal braces need escaping (use \`interface\\{\\}\` to find \`interface{}\` in Go code)
|
|
10
|
-
- Multiline matching: By default patterns match within single lines only. For cross-line patterns like \`struct \\{[\\s\\S]*?field\`, use \`multiline: true\`
|
|
11
|
-
`}var v,Fe=e((()=>{le(),_(),v=`Grep`})),y,Ie,Le,Re,ze=e((()=>{y=`Edit`,Ie=`/.claude/**`,Le=`~/.claude/**`,Re=`File has been unexpectedly modified. Read it again before attempting to write it.`}));function Be(e){let t=e.trim();if(!t)return null;if(t.endsWith(`-`)){let e=parseInt(t.slice(0,-1),10);return isNaN(e)||e<1?null:{firstPage:e,lastPage:1/0}}let n=t.indexOf(`-`);if(n===-1){let e=parseInt(t,10);return isNaN(e)||e<1?null:{firstPage:e,lastPage:e}}let r=parseInt(t.slice(0,n),10),i=parseInt(t.slice(n+1),10);return isNaN(r)||isNaN(i)||r<1||i<1||i<r?null:{firstPage:r,lastPage:i}}function Ve(){return!_e().toLowerCase().includes(`claude-3-haiku`)}function He(e){let t=e.startsWith(`.`)?e.slice(1):e;return Ue.has(t.toLowerCase())}var Ue,We=e((()=>{ge(),Ue=new Set([`pdf`])}));function Ge(e,t,n){return`Reads a file from the local filesystem. You can access any file directly by using this tool.
|
|
12
|
-
Assume this tool is able to read all files on the machine. If the User provides a path to a file assume that path is valid. It is okay to read a file that does not exist; an error will be returned.
|
|
13
|
-
|
|
14
|
-
Usage:
|
|
15
|
-
- The file_path parameter must be an absolute path, not a relative path
|
|
16
|
-
- By default, it reads up to ${x} lines starting from the beginning of the file${t}
|
|
17
|
-
${n}
|
|
18
|
-
${e}
|
|
19
|
-
- This tool allows Claude Code to read images (eg PNG, JPG, etc). When reading an image file the contents are presented visually as Claude Code is a multimodal LLM.${Ve()?`
|
|
20
|
-
- This tool can read PDF files (.pdf). For large PDFs (more than 10 pages), you MUST provide the pages parameter to read specific page ranges (e.g., pages: "1-5"). Reading a large PDF without the pages parameter will fail. Maximum 20 pages per request.`:``}
|
|
21
|
-
- This tool can read Jupyter notebooks (.ipynb files) and returns all cells with their outputs, combining code, text, and visualizations.
|
|
22
|
-
- This tool can only read files, not directories. To read a directory, use an ls command via the ${g} tool.
|
|
23
|
-
- You will regularly be asked to read screenshots. If the user provides a path to a screenshot, ALWAYS use this tool to view the file at the path. This tool will work with all temporary file paths.
|
|
24
|
-
- If you read a file that exists but has empty contents you will receive a system reminder warning in place of file contents.`}var b,Ke,x,qe,Je,Ye,Xe,S=e((()=>{We(),_(),b=`Read`,Ke=`File unchanged since last read. The content from the earlier Read tool_result in this conversation is still current — refer to that instead of re-reading.`,x=2e3,qe=`Read a file from the local filesystem.`,Je=`- Results are returned using cat -n format, with line numbers starting at 1`,Ye=`- You can optionally specify a line offset and limit (especially handy for long files), but it's recommended to read the whole file by not providing these parameters`,Xe=`- When you already know which part of the file you need, only read that part. This can be important for larger files.`}));function Ze(){return`\n- If this is an existing file, you MUST use the ${b} tool first to read the file's contents. This tool will fail if you did not read the file first.`}function Qe(){return`Writes a file to the local filesystem.
|
|
25
|
-
|
|
26
|
-
Usage:
|
|
27
|
-
- This tool will overwrite the existing file if there is one at the provided path.${Ze()}
|
|
28
|
-
- Prefer the Edit tool for modifying existing files \u2014 it only sends the diff. Only use this tool to create new files or for complete rewrites.
|
|
29
|
-
- NEVER create documentation files (*.md) or README files unless explicitly requested by the User.
|
|
30
|
-
- Only use emojis if the user explicitly requests it. Avoid writing emojis to files unless asked.`}var C,$e=e((()=>{S(),C=`Write`})),w,et,tt=e((()=>{w=`Glob`,et=`- Fast file pattern matching tool that works with any codebase size
|
|
31
|
-
- Supports glob patterns like "**/*.js" or "src/**/*.ts"
|
|
32
|
-
- Returns matching file paths sorted by modification time
|
|
33
|
-
- Use this tool when you need to find files by name patterns
|
|
34
|
-
- When you are doing an open ended search that may require multiple rounds of globbing and grepping, use the Agent tool instead`})),T,nt=e((()=>{T=`NotebookEdit`})),E,D,rt=e((()=>{E=`ExitPlanMode`,D=`ExitPlanMode`})),O,it=e((()=>{O=`EnterPlanMode`})),k,at,ot,st,ct=e((()=>{rt(),k=`AskUserQuestion`,at=`Asks the user multiple choice questions to gather information, clarify ambiguity, understand preferences, make decisions or offer them choices.`,ot={markdown:`
|
|
35
|
-
Preview feature:
|
|
36
|
-
Use the optional \`preview\` field on options when presenting concrete artifacts that users need to visually compare:
|
|
37
|
-
- ASCII mockups of UI layouts or components
|
|
38
|
-
- Code snippets showing different implementations
|
|
39
|
-
- Diagram variations
|
|
40
|
-
- Configuration examples
|
|
41
|
-
|
|
42
|
-
Preview content is rendered as markdown in a monospace box. Multi-line text with newlines is supported. When any option has a preview, the UI switches to a side-by-side layout with a vertical option list on the left and preview on the right. Do not use previews for simple preference questions where labels and descriptions suffice. Note: previews are only supported for single-select questions (not multiSelect).
|
|
43
|
-
`,html:`
|
|
44
|
-
Preview feature:
|
|
45
|
-
Use the optional \`preview\` field on options when presenting concrete artifacts that users need to visually compare:
|
|
46
|
-
- HTML mockups of UI layouts or components
|
|
47
|
-
- Formatted code snippets showing different implementations
|
|
48
|
-
- Visual comparisons or diagrams
|
|
49
|
-
|
|
50
|
-
Preview content must be a self-contained HTML fragment (no <html>/<body> wrapper, no <script> or <style> tags — use inline style attributes instead). Do not use previews for simple preference questions where labels and descriptions suffice. Note: previews are only supported for single-select questions (not multiSelect).
|
|
51
|
-
`},st=`Use this tool when you need to ask the user questions during execution. This allows you to:
|
|
52
|
-
1. Gather user preferences or requirements
|
|
53
|
-
2. Clarify ambiguous instructions
|
|
54
|
-
3. Get decisions on implementation choices as you work
|
|
55
|
-
4. Offer choices to the user about what direction to take.
|
|
56
|
-
|
|
57
|
-
Usage notes:
|
|
58
|
-
- Users will always be able to select "Other" to provide custom text input
|
|
59
|
-
- Use multiSelect: true to allow multiple answers to be selected for a question
|
|
60
|
-
- If you recommend a specific option, make that the first option in the list and add "(Recommended)" at the end of the label
|
|
61
|
-
|
|
62
|
-
Plan mode note: In plan mode, use this tool to clarify requirements or choose between approaches BEFORE finalizing your plan. Do NOT use this tool to ask "Is my plan ready?" or "Should I proceed?" - use ${E} for plan approval. IMPORTANT: Do not reference "the plan" in your questions (e.g., "Do you have feedback about the plan?", "Does the plan look good?") because the user cannot see the plan in the UI until you call ${E}. If you need plan approval, use ${E} instead.
|
|
63
|
-
`})),A,lt=e((()=>{A=`TodoWrite`})),ut,dt=e((()=>{ut=`PowerShell`}));function ft(){return fe()===`windows`?process.env.USER_TYPE===`ant`?!r(process.env.CLAUDE_CODE_USE_POWERSHELL_TOOL):i(process.env.CLAUDE_CODE_USE_POWERSHELL_TOOL):!1}var j,pt=e((()=>{_(),dt(),a(),pe(),j=[g,ut]})),M,mt=e((()=>{M=`Skill`})),ht,gt=e((()=>{ht=`TaskCreate`})),_t,vt=e((()=>{_t=`TaskGet`})),yt,bt=e((()=>{yt=`TaskList`})),xt,St=e((()=>{xt=`TaskUpdate`})),N,Ct=e((()=>{N=`SearchExtraTools`}));function wt(e){return e.isNonInteractiveSession}function Tt(e){let t=jt.get(e);if(t)return t;let n=Et(e);return jt.set(e,n),n}function Et(e){try{let t=new Dt.Ajv({allErrors:!0});if(!t.validateSchema(e))return{error:t.errorsText(t.errors)};let n=t.compile(e);return{tool:{...At,inputJSONSchema:e,async call(e){if(!n(e)){let e=n.errors?.map(e=>`${e.instancePath||`root`}: ${e.message}`).join(`, `);throw new te(`Output does not match required schema: ${e}`,`StructuredOutput schema mismatch: ${(e??``).slice(0,150)}`)}return{data:`Structured output provided successfully`,structured_output:e}}}}}catch(e){return{error:e instanceof Error?e.message:String(e)}}}var Dt,Ot,kt,P,At,jt,Mt=e((()=>{Dt=t(ve(),1),d(),Ne(),re(),he(),ee(),Ot=me(()=>f({}).passthrough()),kt=me(()=>c().describe(`Structured output tool result`)),P=`StructuredOutput`,At=Ae({isMcp:!1,isEnabled(){return!0},isConcurrencySafe(){return!0},isReadOnly(){return!0},isOpenWorld(){return!1},name:P,searchHint:`return the final response as structured JSON`,maxResultSizeChars:1e5,async description(){return`Return structured output in the requested format`},async prompt(){return`Use this tool to return your final response in the requested structured format. You MUST call this tool exactly once at the end of your response to provide the structured output.`},get inputSchema(){return Ot()},get outputSchema(){return kt()},async call(e){return{data:`Structured output provided successfully`,structured_output:e}},async checkPermissions(e){return{behavior:`allow`,updatedInput:e}},renderToolUseMessage(e){let t=Object.keys(e);return t.length===0?null:t.length<=3?t.map(t=>`${t}: ${ne(e[t])}`).join(`, `):`${t.length} fields: ${t.slice(0,3).join(`, `)}…`},renderToolUseRejectedMessage(){return`Structured output rejected`},renderToolUseErrorMessage(){return`Structured output error`},renderToolUseProgressMessage(){return null},renderToolResultMessage(e){return e},mapToolResultToToolResultBlockParam(e,t){return{tool_use_id:t,type:`tool_result`,content:e}}}),jt=new WeakMap})),Nt,Pt,Ft,It=e((()=>{de(),Nt=`Sleep`,Pt=`Wait for a specified duration`,Ft=`Wait for a specified duration. The user can interrupt the sleep at any time.
|
|
64
|
-
|
|
65
|
-
Use this when the user tells you to sleep or rest, when you have nothing to do, or when you're waiting for something.
|
|
66
|
-
|
|
67
|
-
You may receive <${ue}> prompts — these are periodic check-ins. Look for useful work to do before sleeping.
|
|
68
|
-
|
|
69
|
-
You can call this concurrently with other tools — it won't interfere with them.
|
|
70
|
-
|
|
71
|
-
Prefer this over \`Bash(sleep ...)\` — it doesn't hold a shell process.
|
|
72
|
-
|
|
73
|
-
Each wake-up costs an API call, but the prompt cache expires after 5 minutes of inactivity — balance accordingly.`})),Lt,Rt=e((()=>{Lt=`Interact with Language Server Protocol (LSP) servers to get code intelligence features.
|
|
74
|
-
|
|
75
|
-
Supported operations:
|
|
76
|
-
- goToDefinition: Find where a symbol is defined
|
|
77
|
-
- findReferences: Find all references to a symbol
|
|
78
|
-
- hover: Get hover information (documentation, type info) for a symbol
|
|
79
|
-
- documentSymbol: Get all symbols (functions, classes, variables) in a document
|
|
80
|
-
- workspaceSymbol: Search for symbols across the entire workspace
|
|
81
|
-
- goToImplementation: Find implementations of an interface or abstract method
|
|
82
|
-
- prepareCallHierarchy: Get call hierarchy item at a position (functions/methods)
|
|
83
|
-
- incomingCalls: Find all functions/methods that call the function at a position
|
|
84
|
-
- outgoingCalls: Find all functions/methods called by the function at a position
|
|
85
|
-
|
|
86
|
-
All operations require:
|
|
87
|
-
- filePath: The file to operate on
|
|
88
|
-
- line: The line number (1-based, as shown in editors)
|
|
89
|
-
- character: The character offset (1-based, as shown in editors)
|
|
90
|
-
|
|
91
|
-
Note: LSP servers must be configured for the file type. If no server is available, an error will be returned.`})),zt=n({VERIFY_PLAN_EXECUTION_TOOL_NAME:()=>F}),F,Bt=e((()=>{F=`VerifyPlanExecution`})),I,Vt=e((()=>{I=`ExecuteExtraTool`})),Ht,Ut=e((()=>{Ht=`EnterWorktree`})),Wt,Gt=e((()=>{Wt=`ExitWorktree`})),Kt=e((()=>{})),L,R,qt,z,Jt,B,V=e((()=>{L=`Workflow`,R=`.claude/workflows`,qt=`.claude/workflow-runs`,z=[`.ts`,`.js`,`.mjs`],Jt=1e3,B=4096}));function Yt(e){return{[H]:e}}function Xt(e){return typeof e==`object`&&!!e&&H in e}function Zt(e){return e[H]}var H,Qt=e((()=>{H=Symbol(`workflow.hostHandle`)}));function $t(e,t){return e.kind===`agentType`?t.agentType===e.agentType:e.kind===`model`?typeof t.model==`string`&&t.model.startsWith(e.pattern):e.match(t)}var en,tn,nn=e((()=>{o(),en=class extends Error{constructor(e){super(e),this.name=`AdapterNotFoundError`}},tn=class{constructor(){s(this,`adapters`,new Map),s(this,`rules`,[]),s(this,`defaultId`,null)}register(e){return this.adapters.set(e.id,e),this}default(e){return this.defaultId=e,this}route(e){return this.rules.push(e),this}has(e){return this.adapters.has(e)}get(e){return this.adapters.get(e)}resolve(e){for(let t of this.rules)if($t(t,e)){let e=this.adapters.get(t.adapter);if(e)return e}if(this.defaultId){let e=this.adapters.get(this.defaultId);if(e)return e}throw new en(`No adapter matched (rules=${this.rules.length}, default=${this.defaultId??`none`})`)}async initializeAll(){for(let e of this.adapters.values())await e.initialize?.()}async disposeAll(){for(let e of this.adapters.values())await e.dispose?.()}}}));function rn(){return 3}function an(e){return e===void 0||Number.isNaN(e)?3:Math.max(1,Math.min(Math.trunc(e),16))}var on,sn=e((()=>{V(),o(),on=class{constructor(e){s(this,`available`,void 0),s(this,`waiters`,[]),this.available=Math.max(1,Math.floor(e))}async acquire(e){if(e?.aborted)throw Error(`Semaphore.acquire aborted (signal already aborted)`);return this.available>0?(--this.available,()=>this.release()):new Promise((t,n)=>{let r=()=>{let e=this.waiters.indexOf(i);e>=0&&this.waiters.splice(e,1),n(Error(`Semaphore.acquire aborted`))},i={wake:()=>{e?.removeEventListener(`abort`,r),t(()=>this.release())},cleanup:()=>e?.removeEventListener(`abort`,r)};e?.addEventListener(`abort`,r,{once:!0}),this.waiters.push(i)})}release(){let e=this.waiters.shift();e?e.wake():this.available+=1}}}));function cn(e){let t=pn.exec(e);if(!t)return{meta:null,body:e};let n=t.index+t[0].length;for(;n<e.length&&/\s/.test(e[n]);)n++;if(e[n]!==`{`)throw new W("meta must be an object literal `{ ... }`");let r=0,i=n,a=null;for(;n<e.length;n++){let t=e[n];if(a){if(t===`\\`){n++;continue}t===a&&(a=null);continue}if(t===`"`||t===`'`||t==="`"){a=t;continue}if(t===`{`)r++;else if(t===`}`&&(r--,r===0)){n++;break}}if(r!==0)throw new W(`meta literal braces are not closed`);let o=e.slice(i,n),s;try{s=Function(`return (${o})`)()}catch(e){throw new W(`meta must be a plain literal (no variable/function calls/interpolation): ${e.message}`)}return{meta:ln(s),body:e.slice(0,t.index)+e.slice(n).replace(/^[ \t]*;[ \t]*\n/,`
|
|
92
|
-
`)}}function ln(e){if(typeof e!=`object`||!e||Array.isArray(e))throw new W(`meta must be an object`);let t=e;if(typeof t.name!=`string`||typeof t.description!=`string`)throw new W(`meta must include string name and description`);return t}function un(){let e=function(...e){if(e.length===0)throw new G(`Date.now()/new Date()`);return new Date(...e)};return e.now=()=>{throw new G(`Date.now()`)},e.parse=Date.parse,e.UTC=Date.UTC,e}function dn(){return new Proxy(Math,{get(e,t,n){return t===`random`?()=>{throw new G(`Math.random()`)}:Reflect.get(e,t,n)}})}function fn(e){if(/^\s*import\b/m.test(e))throw new W(`workflow scripts are the body of new AsyncFunction (not ESM modules); import is not supported. agent / parallel / pipeline / phase / log / workflow / args / budget are injected as parameters — use them directly.`);if(/\bimport\s*\(/m.test(e))throw new W(`dynamic import(...) is forbidden in workflow scripts: it bypasses the Date/Math sandbox and breaks resume determinism. The sandbox does not guarantee security (same trust level as the LLM), but explicit escapes are prohibited. Inject external dependencies via args.`);if(/^\s*export\b/m.test(e))throw new W(`workflow scripts allow only one export const meta = {...} (already extracted by the engine). Remove other export / export default statements; use top-level return for the result.`)}function U(e){let{meta:t,body:n}=cn(e);fn(n);let r;try{r=new mn(`agent`,`parallel`,`pipeline`,`phase`,`log`,`workflow`,`args`,`budget`,`Date`,`Math`,n)}catch(e){throw new W(`Script syntax error: ${e.message}`)}let i=un(),a=dn();return{meta:t,async execute(e,t,n){return r(e.agent,e.parallel,e.pipeline,e.phase,e.log,e.workflow,t,n,i,a)}}}var W,pn,G,mn,K=e((()=>{W=class extends Error{constructor(e){super(e),this.name=`ScriptError`}},pn=/export\s+const\s+meta\s*=\s*/,G=class extends Error{constructor(e){super(`${e} is not available in workflow scripts (would break resume determinism). Pass timestamps/random seeds via args.`),this.name=`NonDeterministicError`}},mn=Object.getPrototypeOf(async function(){}).constructor}));function hn(e){let{label:t,phase:n,...r}=e,i=Object.keys(r).sort(),a={};for(let e of i)a[e]=r[e];return JSON.stringify(a)}function gn(e,t){return xe(`sha256`).update(e+`
|
|
93
|
-
`+hn(t)).digest(`hex`)}function _n(e){let t=t=>p(e,t,`journal.jsonl`);return{async read(e){try{return(await h(t(e),`utf-8`)).split(`
|
|
94
|
-
`).filter(e=>e.trim().length>0).map(e=>JSON.parse(e)).sort((e,t)=>(e.seq??0)-(t.seq??0))}catch{return[]}},async append(n,r){await Ce(p(e,n),{recursive:!0}),await Se(t(n),JSON.stringify(r)+`
|
|
95
|
-
`,`utf-8`)},async truncate(t){await Te(p(e,t),{recursive:!0,force:!0})}}}var vn=e((()=>{})),yn,bn,xn=e((()=>{o(),yn=class extends Error{constructor(){super(`workflow token budget exhausted (budget.total reached the cap)`),this.name=`BudgetExhaustedError`}},bn=class{constructor(e){s(this,`total`,void 0),s(this,`spentTokens`,0),this.total=e}spent(){return this.spentTokens}remaining(){return this.total==null?1/0:Math.max(0,this.total-this.spentTokens)}addOutputTokens(e){e>0&&(this.spentTokens+=e)}assertCanSpend(){if(this.total!=null&&this.spentTokens>=this.total)throw new yn}}}));function Sn(e,t){let n=wn.get(t);n||(n=new Cn.Ajv({allErrors:!0,strict:!1}).compile(t),wn.set(t,n));let r=n(e);return{valid:r,errors:r?[]:(n.errors??[]).map(e=>e.message??`validation error`)}}var Cn,wn,Tn=e((()=>{Cn=t(ve(),1),wn=new WeakMap}));function En(e,t){let n=m(e),r=m(n,t);return r===n||r.startsWith(n+be)}function Dn(e){return typeof e!=`string`||e.length===0||e.includes(`/`)||e.includes(`\\`)||e.includes(`\0`)||e===`.`||e===`..`?null:e}var On=e((()=>{}));function kn(e){return z.includes(e.toLowerCase())}async function q(e,t){for(let n of z){let r=m(e,t+n);if(!En(e,r))return null;try{return{path:r,content:await h(r,`utf-8`)}}catch{}}return null}async function An(e){let t;try{t=await we(e)}catch{return[]}return t.filter(e=>kn(ye(e).ext)).map(e=>ye(e).name).sort()}var J=e((()=>{V(),On()})),Y,X,Z=e((()=>{Y=class extends Error{constructor(e){super(e),this.name=`WorkflowError`}},X=class extends Error{constructor(){super(`workflow has been aborted`),this.name=`WorkflowAbortedError`}}}));function jn(e,t){return{semaphore:new on(an(t)),budget:new bn(e),agentCountBox:{value:0},agentIdSeq:{value:0},depth:0}}function Mn(e){let t=jn(e.budgetTotal,e.maxConcurrency);return{ports:e.ports,host:e.host,signal:e.signal,runId:e.runId,workflowName:e.workflowName,cwd:e.cwd,resources:t,journal:e.journal?[...e.journal]:[],journalIndex:0,journalInvalidated:!1,currentPhase:null}}var Nn=e((()=>{xn(),sn()}));function Pn(e,t){let n=t=>{e.ports.progressEmitter.emit({runId:e.runId,...t})};return{agent:async(t,r={})=>{let i=e.resources;if(i.agentCountBox.value>=1e3)throw new Y(`workflow exceeds total agent cap (${Jt})`);let a=i.agentIdSeq.value++,o={prompt:t,...r},s=gn(t,o),c=r.label,l=r.phase??e.currentPhase??void 0;if(!e.journalInvalidated&&e.journalIndex<e.journal.length){let t=e.journal[e.journalIndex];if(t.key===s)return e.journalIndex++,n({type:`agent_done`,agentId:a,label:c,phase:l,result:t.result}),Fn(t.result);e.journalInvalidated=!0,e.journal=e.journal.slice(0,e.journalIndex),await e.ports.journalStore.truncate(e.runId)}let u;try{u=await e.resources.semaphore.acquire(e.signal)}catch{throw new X}try{if(e.signal.aborted)throw new X;if(i.budget.assertCanSpend(),e.ports.taskRegistrar.pendingAction(e.runId)?.kind===`skip`)return n({type:`agent_done`,agentId:a,label:c,phase:l,result:{kind:`skipped`}}),null;e.resources.agentCountBox.value++,n({type:`agent_started`,agentId:a,label:c,phase:l});let t=e.ports.agentAdapterRegistry,r=t?{host:e.host,signal:e.signal,runId:e.runId,agentId:a,onProgress:e=>{n({type:`agent_progress`,agentId:a,label:c,phase:l,...e})},...e.ports.taskRegistrar.registerAgentAbort?{registerAgentAbort:(t,n)=>{e.ports.taskRegistrar.registerAgentAbort?.(e.runId,t,n)}}:{},...e.ports.taskRegistrar.unregisterAgentAbort?{unregisterAgentAbort:t=>{e.ports.taskRegistrar.unregisterAgentAbort?.(e.runId,t)}}:{}}:null,u=t?t.resolve(o):null,d=()=>u?u.run(o,r):e.ports.agentRunner.runAgentToResult(o,e.host),f;try{if(f=await d(),f.kind===`dead`){let t=typeof f.detail==`string`?f.detail:``;e.ports.logger.warn?.(`agent "${c??`#${a}`}" returned dead`+(f.reason?` (${f.reason})`:``)+(t?`: ${t.slice(0,150)}`:``)+`; retrying once`),f=await d()}}catch(t){if(t instanceof X)throw t;let n=t instanceof Error?t.message:String(t);e.ports.logger.warn?.(`agent "${c??`#${a}`}" threw (${n}); retrying once`);try{f=await d()}catch(e){if(e instanceof X)throw e;f={kind:`dead`,reason:`runagent-threw`,detail:e instanceof Error?e.message:String(e)}}}f.kind===`ok`&&e.resources.budget.addOutputTokens(f.usage.outputTokens),n({type:`agent_done`,agentId:a,label:c,phase:l,result:f});let ee={key:s,seq:a,result:f};return e.journal.push(ee),e.journalIndex++,await e.ports.journalStore.append(e.runId,ee),Fn(f)}finally{u()}},parallel:async t=>{if(t.length>4096)throw new Y(`parallel exceeds the per-call items cap (${B})`);return Promise.all(t.map(async(t,n)=>{try{return await t()}catch(t){return e.ports.logger.warn?.(`parallel thunk #${n} failed: ${t.message}`),null}}))},pipeline:async(t,...n)=>{if(t.length>4096)throw new Y(`pipeline exceeds the per-call items cap (${B})`);return Promise.all(t.map(async(t,r)=>{try{let e=t;for(let i of n)e=await i(e,t,r);return e}catch(t){return e.ports.logger.warn?.(`pipeline item #${r} failed: ${t.message}`),null}}))},phase:t=>{e.currentPhase&&n({type:`phase_done`,phase:e.currentPhase}),e.currentPhase=t,n({type:`phase_started`,phase:t})},log:e=>{n({type:`log`,message:e})},workflow:async(n,r)=>{if(e.resources.depth>=1)throw new Y(`workflow() nesting allows only one level`);return t({...typeof n==`string`?{name:n}:{scriptPath:n.scriptPath},args:r})}}}function Fn(e){return e.kind===`ok`?e.output:null}var In=e((()=>{V(),Z(),vn()}));async function Ln(e){let{ports:t}=e,n;try{n=U(e.script)}catch(n){let r=n.message;return t.progressEmitter.emit({type:`run_done`,runId:e.runId,status:`failed`,error:r}),{status:`failed`,error:r}}let r=e.workflowName??n.meta?.name??`workflow`,i=[],a=!1;e.resume&&!e.scriptChanged?i=await t.journalStore.read(e.runId):e.scriptChanged&&(await t.journalStore.truncate(e.runId),a=!0);let o=Mn({ports:t,host:e.host,signal:e.signal,runId:e.runId,workflowName:r,cwd:e.cwd,budgetTotal:e.budgetTotal,maxConcurrency:e.maxConcurrency,journal:i});a&&(o.journalInvalidated=!0),t.progressEmitter.emit({type:`run_started`,runId:e.runId,workflowName:r,meta:n.meta});let s=async t=>{let n=await Rn(t,e.cwd),r;try{r=U(n)}catch(e){throw new Y(`Sub-workflow script error: ${e.message}`)}let i=o.resources.depth;o.resources.depth+=1;try{let e=Pn(o,s);return await r.execute(e,t.args,o.resources.budget)}finally{o.resources.depth=i}},c=Pn(o,s),l=()=>{o.currentPhase&&t.progressEmitter.emit({type:`phase_done`,runId:e.runId,phase:o.currentPhase})},u;try{u={status:`completed`,returnValue:await n.execute(c,e.args,o.resources.budget)}}catch(e){u=e instanceof X?{status:`killed`}:{status:`failed`,error:e.message}}return l(),t.progressEmitter.emit({type:`run_done`,runId:e.runId,...u}),u}async function Rn(e,t){if(e.script)return e.script;if(e.scriptPath)return await h(e.scriptPath,`utf-8`);if(e.name){let n=await q(p(t,R),e.name);if(!n)throw new Y(`Sub-workflow "${e.name}" not found`);return n.content}throw new Y(`workflow() requires name or scriptPath`)}var zn=e((()=>{V(),Nn(),Z(),In(),J(),K()}));function Bn(e){return{emit:e}}function Vn(){let e=[];return{emitter:{emit:t=>void e.push(t)},events:e}}var Hn=e((()=>{})),Q,$=e((()=>{d(),Q=f({script:c().optional().describe(`Self-contained workflow script source (inline)`),name:c().optional().describe(`Named workflow, resolved to .claude/workflows/<name>.ts|js|mjs`),scriptPath:c().optional().describe(`Absolute path to an existing script file`),args:u().optional().describe(`The args global variable passed through to the script. Pass a real JSON value (object/array/string), not a JSON string.`),resumeFromRunId:c().optional().describe(`Resume the specified run, replaying the journal`),description:c().optional().describe(`A short description of this invocation (3-5 words)`),title:c().optional().describe(`Progress viewer title`),maxConcurrency:l().int().min(1).max(16).optional().describe(`Concurrency cap for agent(). Defaults to 3 (max 16). When the workflow contains heavy parallel/pipeline fan-out, you may confirm the desired concurrency with the user via AskUserQuestion before launching.`)})}));async function Un(e,t,n){let r=p(n,qt,t);await Ce(r,{recursive:!0});let i=p(r,`script.js`);return await Ee(i,e,`utf-8`),i}var Wn=e((()=>{V()}));function Gn(e){return{name:L,inputSchema:Q,isEnabled:()=>!0,isReadOnly:()=>!1,async description(){return`Execute a workflow script that orchestrates multiple subagents to complete a task`},async prompt(){return Xn},renderToolUseMessage(e){return e.resumeFromRunId?`Workflow resume: ${e.resumeFromRunId}`:`Workflow: ${e.name??e.scriptPath??(e.script?`inline`:`unknown`)}`},async call(t,n,r,i){let a=e.hostFactory({context:n,canUseTool:r,parentMessage:i}),o,s;try{let e=await Yn(t,a.cwd);o=e.script,s=e.workflowFile}catch(e){return{data:{output:`Error: ${e.message}`}}}try{U(o)}catch(e){return{data:{output:`Error: script validation failed: ${e.message}`}}}let c=t.name??t.title??`workflow`,{runId:l,signal:u}=e.taskRegistrar.register({workflowName:c,...s?{workflowFile:s}:{},...t.description?{summary:t.description}:{},...a.toolUseId?{toolUseId:a.toolUseId}:{},...t.resumeFromRunId?{runId:t.resumeFromRunId}:{}},a.handle);if(!s&&t.script)try{s=await Un(t.script,l,a.cwd)}catch(t){e.logger.warn?.(`inline script persist failed: ${t.message}`)}Ln({script:o,...t.args===void 0?{}:{args:Jn(t.args)},runId:l,workflowName:c,ports:e,host:a.handle,signal:u,cwd:a.cwd,budgetTotal:a.budgetTotal,...t.maxConcurrency===void 0?{}:{maxConcurrency:t.maxConcurrency},...t.resumeFromRunId?{resume:!0}:{}}).then(t=>Kn(e,t,l)).catch(t=>e.taskRegistrar.fail(l,t.message));let d=s??`<inline run ${l}>`;return{data:{output:[`Workflow started (running in the background).`,`run_id: ${l}`,`workflow: ${c}`,`script: ${d}`,``,`You will be notified on completion. Use /workflows to view live progress.`].join(`
|
|
96
|
-
`)}}},mapToolResultToToolResultBlockParam(e,t){return{tool_use_id:t,type:`tool_result`,content:[{type:`text`,text:e.output}]}}}}function Kn(e,t,n){if(t.status===`completed`){let r=t.returnValue==null?`(no return value)`:qn(t.returnValue);e.taskRegistrar.complete(n,r)}else t.status===`failed`?e.taskRegistrar.fail(n,t.error??`workflow failed`):e.taskRegistrar.kill(n)}function qn(e){if(typeof e==`string`)return e.slice(0,500);try{return JSON.stringify(e).slice(0,500)}catch{return String(e)}}function Jn(e){if(typeof e!=`string`)return e;try{let t=JSON.parse(e);return typeof t==`object`&&t?t:e}catch{return e}}async function Yn(e,t){if(e.script)return{script:e.script};if(e.scriptPath){let n=m(t,e.scriptPath);if(!En(t,n))throw Error(`scriptPath "${e.scriptPath}" is out of bounds (after resolve, ${n} is not within cwd ${t})`);return{script:await h(n,`utf-8`),workflowFile:n}}if(e.name){if(Dn(e.name)===null)throw Error(`Named workflow name "${e.name}" is invalid (contains path separators or is . / ..)`);let n=await q(p(t,R),e.name);if(!n)throw Error(`Named workflow "${e.name}" not found (looked in ${R}/)`);return{script:n.content,workflowFile:n.path}}throw Error(`One of script, name, or scriptPath must be provided`)}var Xn,Zn=e((()=>{V(),J(),zn(),K(),On(),$(),Wn(),Xn='Use the Workflow tool to execute a workflow script that orchestrates multiple subagents deterministically. The script runs in the background; you receive a run_id immediately and are notified on completion.\n\nProvide the script inline via "script", or reference a named workflow via "name" (resolved from .claude/workflows/), or an existing file via "scriptPath". Pass "args" as a real JSON value (object/array/string), not a stringified string.\n\nUse "resumeFromRunId" to resume a prior run — completed agent() calls replay from the journal instantly.\n\nConcurrency: default is 3 (hard ceiling 16). OMIT maxConcurrency to use 3. To set maxConcurrency to ANY value other than 3, you MUST first ask the user via AskUserQuestion — propose 3 / 6 / 9 (or other tiers matching the fan-out width) with 3 marked "(Recommended)". The ONLY exception: the user has ALREADY specified a concurrency number in this session ("use 6", "maxConcurrency 9") — then honor it without re-asking. Never silently raise concurrency above 3 just because the workflow fans out; 3 is the recommended default.\n\nScript execution model (common pitfalls — getting these wrong is the #1 cause of script errors): the script is the body of `new AsyncFunction` — NOT an ESM module, and TypeScript is NOT transpiled. Therefore:\n- Do NOT use `import` — `agent`, `parallel`, `pipeline`, `phase`, `log`, `workflow`, `args`, and `budget` are injected as parameters; reference them directly.\n- Do NOT use TS type annotations, `interface`, `enum`, `as`, or generics — the engine does not transpile, so even a .ts file with type syntax fails to parse.\n- Keep EXACTLY ONE `export const meta = {...}` (plain literal) and remove every other `export` / `export default`.\n- Return the result with a top-level `return`.\nPrefer .js / .mjs. See /ultracode for the full playbook and quality patterns.'})),Qn=n({AdapterNotFoundError:()=>en,AgentAdapterRegistry:()=>tn,Budget:()=>bn,BudgetExhaustedError:()=>yn,DEFAULT_MAX_CONCURRENCY:()=>3,MAX_CONCURRENCY_CAP:()=>16,MAX_ITEMS_PER_CALL:()=>B,MAX_TOTAL_AGENTS:()=>Jt,ScriptError:()=>W,Semaphore:()=>on,WORKFLOW_DIR_NAME:()=>R,WORKFLOW_RUNS_DIR:()=>qt,WORKFLOW_SCRIPT_EXTENSIONS:()=>z,WORKFLOW_TOOL_NAME:()=>L,WorkflowAbortedError:()=>X,WorkflowError:()=>Y,agentCallKey:()=>gn,clampMaxConcurrency:()=>an,createBufferingEmitter:()=>Vn,createEngineContext:()=>Mn,createFileJournalStore:()=>_n,createHostHandle:()=>Yt,createProgressEmitter:()=>Bn,createSharedResources:()=>jn,createWorkflowTool:()=>Gn,extractMeta:()=>cn,isHostHandle:()=>Xt,listNamedWorkflows:()=>An,makeHooks:()=>Pn,maxConcurrency:()=>rn,parseScript:()=>U,persistInlineScript:()=>Un,resolveNamedWorkflow:()=>q,runWorkflow:()=>Ln,unwrapHostHandle:()=>Zt,validateAgainstSchema:()=>Sn,workflowInputSchema:()=>Q}),$n=e((()=>{Kt(),V(),Qt(),nn(),sn(),K(),vn(),xn(),Tn(),J(),Z(),Nn(),In(),zn(),Hn(),Zn(),$(),Wn()})),er,tr,nr,rr,ir,ar,or=e((()=>{er=`LocalMemoryRecall`,tr=100*1024,nr=2*1024,rr=50*1024,ir=4*1024,ar=8*1024})),sr,cr,lr,ur=e((()=>{sr=`VaultHttpFetch`,cr=1048576,lr=3e4})),dr,fr,pr,mr,hr=e((()=>{ce(),rt(),it(),le(),ct(),se(),S(),lt(),Fe(),tt(),pt(),ze(),$e(),nt(),mt(),gt(),vt(),bt(),St(),Ct(),Mt(),It(),Rt(),Bt(),Vt(),Ut(),Gt(),$n(),or(),ur(),dr=new Set([oe,D,O,...process.env.USER_TYPE===`ant`?[]:[ae],k,ie,L,er,sr]),fr=new Set([...dr]),pr=new Set([b,A,v,w,...j,y,C,T,M,P,N,I,Ht,Wt]),mr=new Set([...j,b,y,C,w,v,T,ae,k,oe,ie,ht,_t,yt,xt,A,O,D,F,`LSP`,M,L,Nt,N,I,P])}));function gr(){return process.env.USER_TYPE===`ant`?`Deferred tools appear by name in <system-reminder> messages.`:`Deferred tools appear by name in <available-deferred-tools> messages.`}function _r(e){return!(e.alwaysLoad===!0||mr.has(e.name))}function vr(e){return e.name}function yr(){return br+gr()+xr}var br,xr,Sr=e((()=>{hr(),Ct(),br=`Search for deferred tools by name or keyword. LOW PRIORITY — only use this tool when no core tool can accomplish the task. Core tools (Read, Edit, Write, Bash, Glob, Grep, Agent, WebFetch, WebSearch, Skill) are always available and should be used directly. This tool is for discovering additional capabilities like MCP tools, worktree management, agent teams (TeamCreate, TeamDelete, SendMessage), etc.
|
|
97
|
-
|
|
98
|
-
`,xr=` Returns matching tool names.
|
|
99
|
-
|
|
100
|
-
## Two-step workflow (MUST follow exactly)
|
|
101
|
-
|
|
102
|
-
Deferred tools CANNOT be called directly. You MUST use this two-step pattern:
|
|
103
|
-
|
|
104
|
-
Step 1 — Search: Call this tool (SearchExtraTools) to discover the target tool.
|
|
105
|
-
Input: {"query": "select:TeamCreate"}
|
|
106
|
-
Response: "Found 1 deferred tool(s): TeamCreate. Use ExecuteExtraTool with {"tool_name": "<name>", "params": {...}} to invoke."
|
|
107
|
-
|
|
108
|
-
Step 2 — Execute: Call ExecuteExtraTool to run the discovered tool.
|
|
109
|
-
Input: {"tool_name": "TeamCreate", "params": {"name": "researcher"}}
|
|
110
|
-
Response: the actual tool result.
|
|
111
|
-
|
|
112
|
-
## Example: user asks "create a team"
|
|
113
|
-
|
|
114
|
-
1. SearchExtraTools({"query": "select:TeamCreate"})
|
|
115
|
-
→ Response: Found deferred tool TeamCreate
|
|
116
|
-
2. ExecuteExtraTool({"tool_name": "TeamCreate", "params": {"name": "researcher"}})
|
|
117
|
-
→ Response: Team created successfully
|
|
118
|
-
|
|
119
|
-
If you don't know the exact tool name, use keyword search first:
|
|
120
|
-
1. SearchExtraTools({"query": "team create"})
|
|
121
|
-
→ Response: Found deferred tool(s): TeamCreate
|
|
122
|
-
2. ExecuteExtraTool({"tool_name": "TeamCreate", "params": {...}})
|
|
123
|
-
|
|
124
|
-
## Query forms
|
|
125
|
-
- "select:TeamCreate" — exact tool name (fastest, preferred when you know the name from <available-deferred-tools>)
|
|
126
|
-
- "select:TeamCreate,SendMessage" — comma-separated multi-select
|
|
127
|
-
- "discover:create a team" — returns tool name + description + schema without loading. Use to understand a tool before calling it.
|
|
128
|
-
- "notebook jupyter" — keyword search, up to max_results best matches
|
|
129
|
-
- "+slack send" — require "slack" in the name, rank by remaining terms
|
|
130
|
-
|
|
131
|
-
## Failure policy
|
|
132
|
-
If ExecuteExtraTool fails, do NOT re-search for the same tool — it will loop. Stop and tell the user what failed.`}));export{F as $,Je as $t,X as A,A as At,nn as B,D as Bt,Zn as C,Ne as Cn,M as Ct,Q as D,ft as Dt,$ as E,pt as Et,_n as F,ot as Ft,L as G,w as Gt,Qt as H,T as Ht,vn as I,ct as It,Gt as J,Qe as Jt,V as K,tt as Kt,K as L,O as Lt,J as M,k as Mt,An as N,st as Nt,zn as O,ut as Ot,q as P,at as Pt,Vt as Q,Ke as Qt,U as R,it as Rt,Gn as S,je as Sn,gt as St,Un as T,j as Tt,Zt as U,nt as Ut,Yt as V,rt as Vt,R as W,et as Wt,Ut as X,qe as Xt,Ht as Y,$e as Yt,I as Z,b as Zt,tr as _,g as _n,yt as _t,dr as a,We as an,Nt as at,$n as b,De as bn,vt as bt,hr as c,Be as cn,P as ct,sr as d,Re as dn,Mt as dt,x as en,zt as et,ur as f,Le as fn,wt as ft,er as g,Fe as gn,St as gt,ir as h,Pe as hn,xt as ht,_r as i,Ge as in,Pt as it,Z as j,lt as jt,Ln as k,dt as kt,lr as l,Ie as ln,At as lt,ar as m,v as mn,Ct as mt,yr as n,Xe as nn,Lt as nt,pr as o,He as on,Ft as ot,rr as p,ze as pn,N as pt,Wt as q,C as qt,Sr as r,S as rn,Rt as rt,fr as s,Ve as sn,It as st,vr as t,Ye as tn,Bt as tt,cr as u,y as un,Tt as ut,nr as v,_ as vn,bt as vt,Wn as w,Oe as wn,mt as wt,Qn as x,ke as xn,ht as xt,or as y,Ae as yn,_t as yt,tn as z,E as zt};
|
|
@@ -1,11 +0,0 @@
|
|
|
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{U as l,_ as u,h as d,l as f,ot as p,p as m,st as h,z as g}from"./debug-DiuXEmUq.js";import{M as _,j as ee}from"./git-Cgc8X5l2.js";import{Fr as te,Ir as ne,Nr as v,Pr as re}from"./model-BgrLt7P7.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((()=>{})),De,Oe=e((()=>{De=`_geminiThoughtSignature`}));function S(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}function ke(e,t){let n=[],r=new Map;for(let t of e){if(t.type===`assistant`){let e=Ne(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=je(t,r);e.parts.length>0&&n.push(e)}}let i=Ae(t);return{contents:n,...i?{systemInstruction:{parts:[{text:i}]}}:{}}}function Ae(e){return!e||e.length===0?``:e.filter(Boolean).join(`
|
|
2
|
-
|
|
3
|
-
`)}function je(e,t){let n=e.message.content;return typeof n==`string`?{role:`user`,parts:C(n)}:Array.isArray(n)?{role:`user`,parts:n.flatMap(e=>Me(e,t))}:{role:`user`,parts:[]}}function Me(e,t){if(typeof e==`string`)return C(e);if(e.type===`text`)return C(e.text);if(e.type===`tool_result`){let n=e;return[{functionResponse:{name:t.get(n.tool_use_id)??n.tool_use_id,response:Ie(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 C(`[image: ${t.url}]`)}return[]}function Ne(e){let t=e.message.content;if(typeof t==`string`)return{role:`model`,parts:C(t)};if(!Array.isArray(t))return{role:`model`,parts:[]};let n=[];for(let e of t){if(typeof e==`string`){n.push(...C(e));continue}if(e.type===`text`){n.push(...C(e.text,w(e)));continue}if(e.type===`thinking`){let t=Pe(e.thinking,e.signature);t&&n.push(t);continue}if(e.type===`tool_use`){let t=e;n.push({functionCall:{name:t.name,args:Fe(t.input)},...w(e)&&{thoughtSignature:w(e)}})}}return{role:`model`,parts:n}}function C(e,t){return typeof e!=`string`||e.length===0?[]:[{text:e,...t&&{thoughtSignature:t}}]}function Pe(e,t){if(!(typeof e!=`string`||e.length===0))return{text:e,thought:!0,...t&&{thoughtSignature:t}}}function Fe(e){if(typeof e==`string`){let t=S(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 Ie(e){let t=Le(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 Le(e){if(typeof e==`string`)return S(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
|
-
`);return S(t)??t}return e??``}function w(e){let t=e[De];return typeof t==`string`&&t.length>0?t:void 0}var Re=e((()=>{Oe()}));function ze(e){if(typeof e==`string`)return E.has(e)?e:void 0;if(Array.isArray(e)){let t=e.filter(e=>typeof e==`string`&&E.has(e)),n=Array.from(new Set(t));return n.length===0?void 0:n.length===1?n[0]:n}}function Be(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 Ve(e){let t=e.map(Be).filter(e=>e!==void 0),n=Array.from(new Set(t));if(n.length!==0)return n.length===1?n[0]:n}function He(e){return e===void 0?[`null`]:Array.isArray(e)?e.includes(`null`)?e:[...e,`null`]:e===`null`?e:[e,`null`]}function Ue(e){if(!e||typeof e!=`object`||Array.isArray(e))return;let t=Object.entries(e).map(([e,t])=>[e,T(t)]).filter(([,e])=>Object.keys(e).length>0);if(t.length!==0)return Object.fromEntries(t)}function We(e){if(!Array.isArray(e))return;let t=e.map(e=>T(e)).filter(e=>Object.keys(e).length>0);return t.length>0?t:void 0}function T(e){if(!e||typeof e!=`object`||Array.isArray(e))return{};let t=e,n={},r=ze(t.type);t.const===void 0?Array.isArray(t.enum)&&t.enum.length>0&&(n.enum=t.enum,r=r??Ve(t.enum)):(n.enum=[t.const],r=r??Be(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=He(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=Ue(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=T(t.additionalProperties);Object.keys(e).length>0&&(n.additionalProperties=e)}let a=T(t.items);Object.keys(a).length>0&&(n.items=a);let o=We(t.prefixItems);o&&(n.prefixItems=o);let s=We(t.anyOf??t.oneOf);return s&&(n.anyOf=s),n}function Ge(e){let t=T(e);return Object.keys(t).length>0?t:{type:`object`,properties:{}}}function Ke(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:Ge(t.input_schema??{type:`object`,properties:{}})}});return t.length>0?[{functionDeclarations:t}]:[]}function qe(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 E,Je=e((()=>{E=new Set([`string`,`number`,`integer`,`boolean`,`object`,`array`,`null`])}));async function*Ye(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=Xe(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:Ze(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 Xe(e){return typeof e.text==`string`?e.thought?`thinking`:`text`:null}function Ze(e,t){switch(e){case`MAX_TOKENS`:return`max_tokens`;default:return t?`tool_use`:`end_turn`}}var Qe=e((()=>{}));function D(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=it.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 $e(e){let t=D(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 O(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 et(e){let t=e.message;return t?O(t):``}function tt(e){return typeof e==`object`&&!!e&&`error`in e&&typeof e.error==`object`&&e.error!==null}function nt(e){if(!tt(e))return null;let t=e.error,n=t?.error?.message;if(typeof n==`string`&&n.length>0){let e=O(n);if(e.length>0)return e}let r=t?.message;if(typeof r==`string`&&r.length>0){let e=O(r);if(e.length>0)return e}return null}function rt(e){let t=D(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 nt(e)??`API error (status ${e.status??`unknown`})`;let n=et(e);return n!==e.message&&n.length>0?n:e.message}var it,at=e((()=>{it=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 ot(e,t,n){let r=[],i=st(t);i&&r.push({role:`system`,content:i});for(let t of e)switch(t.type){case`user`:r.push(...ct(t));break;case`assistant`:r.push(...ut(t));break;default:break}return r}function st(e){return!e||e.length===0?``:e.filter(Boolean).join(`
|
|
5
|
-
|
|
6
|
-
`)}function ct(e){let t=[],n=e.message.content;if(typeof n==`string`)t.push({role:`user`,content:n});else if(Array.isArray(n)){let e=[],r=[],i=[];for(let t of n)if(typeof t==`string`)e.push(t);else if(t.type===`text`)e.push(t.text);else if(t.type===`tool_result`)r.push(t);else if(t.type===`image`){let e=dt(t);e&&i.push(e)}for(let e of r)t.push(lt(e));if(i.length>0){let n=[];e.length>0&&n.push({type:`text`,text:e.join(`
|
|
7
|
-
`)}),n.push(...i),t.push({role:`user`,content:n})}else e.length>0&&t.push({role:`user`,content:e.join(`
|
|
8
|
-
`)})}return t}function lt(e){let t;return t=typeof e.content==`string`?e.content:Array.isArray(e.content)?e.content.map(e=>typeof e==`string`?e:`text`in e?e.text:``).filter(Boolean).join(`
|
|
9
|
-
`):``,{role:`tool`,tool_call_id:e.tool_use_id,content:t}}function ut(e){let t=e.message.content;if(typeof t==`string`)return[{role:`assistant`,content:t}];if(!Array.isArray(t))return[{role:`assistant`,content:``}];let n=[],r=[],i=[];for(let e of t)if(typeof e==`string`)n.push(e);else if(e.type===`text`)n.push(e.text);else if(e.type===`tool_use`){let t=e;r.push({id:t.id,type:`function`,function:{name:t.name,arguments:typeof t.input==`string`?t.input:JSON.stringify(t.input)}})}else if(e.type===`thinking`){let t=e.thinking;typeof t==`string`&&i.push(t)}return[{role:`assistant`,content:n.length>0?n.join(`
|
|
10
|
-
`):null,...r.length>0&&{tool_calls:r},...i.length>0&&{reasoning_content:i.join(`
|
|
11
|
-
`)}}]}function dt(e){let t=e.source;return t?t.type===`base64`&&typeof t.data==`string`?{type:`image_url`,image_url:{url:`data:${t.media_type||`image/png`};base64,${t.data}`}}:t.type===`url`&&typeof t.url==`string`?{type:`image_url`,image_url:{url:t.url}}:null:null}var ft=e((()=>{}));function pt(e){return e.filter(e=>{let t=e.type;return e.type===`custom`||!(`type`in e)||t!==`server`}).map(e=>{let t=e,n=t.name||``,r=t.description||``,i=t.input_schema;return{type:`function`,function:{name:n,description:r,parameters:k(i||{type:`object`,properties:{}})}}})}function k(e){if(!e||typeof e!=`object`)return e;let t={...e};`const`in t&&(t.enum=[t.const],delete t.const);for(let e of[`properties`,`definitions`,`$defs`,`patternProperties`]){let n=t[e];if(n&&typeof n==`object`){let r={};for(let[e,t]of Object.entries(n))r[e]=t&&typeof t==`object`?k(t):t;t[e]=r}}for(let e of[`items`,`additionalProperties`,`not`,`if`,`then`,`else`,`contains`,`propertyNames`]){let n=t[e];n&&typeof n==`object`&&!Array.isArray(n)&&(t[e]=k(n))}for(let e of[`anyOf`,`oneOf`,`allOf`]){let n=t[e];Array.isArray(n)&&(t[e]=n.map(e=>e&&typeof e==`object`?k(e):e))}return t}function mt(e){if(!e||typeof e!=`object`)return;let t=e;switch(t.type){case`auto`:return`auto`;case`any`:return`required`;case`tool`:return{type:`function`,function:{name:t.name}};default:return}}var ht=e((()=>{}));async function*gt(e,t){let n=`msg_${y().replace(/-/g,``).slice(0,24)}`,r=!1,i=-1,a=new Map,o=!1,s=!1,c=0,l=0,u=0,d=0,f=new Set,p=null,m=!1;for await(let h of e){let e=h.choices?.[0],g=e?.delta;if(h.usage){c=h.usage.prompt_tokens??c;let e=h.usage.prompt_tokens_details?.cached_tokens??d;l=Math.max(0,c-e),u=h.usage.completion_tokens??u,d=e}if(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}}}),!g)continue;let _=g.reasoning_content;if(_!=null&&(o||(i++,o=!0,f.add(i),yield{type:`content_block_start`,index:i,content_block:{type:`thinking`,thinking:``,signature:``}}),_!==``&&(yield{type:`content_block_delta`,index:i,delta:{type:`thinking_delta`,thinking:_}})),g.content!=null&&g.content!==``&&(s||(o&&(yield{type:`content_block_stop`,index:i},f.delete(i),o=!1),i++,s=!0,f.add(i),yield{type:`content_block_start`,index:i,content_block:{type:`text`,text:``}}),yield{type:`content_block_delta`,index:i,delta:{type:`text_delta`,text:g.content}}),g.tool_calls)for(let e of g.tool_calls){let t=e.index;if(!a.has(t)){o&&(yield{type:`content_block_stop`,index:i},f.delete(i),o=!1),s&&(yield{type:`content_block_stop`,index:i},f.delete(i),s=!1),i++;let n=e.id||`toolu_${y().replace(/-/g,``).slice(0,24)}`,r=e.function?.name||``;a.set(t,{contentIndex:i,id:n,name:r,arguments:``}),f.add(i),yield{type:`content_block_start`,index:i,content_block:{type:`tool_use`,id:n,name:r,input:{}}}}let n=e.function?.arguments;n&&(a.get(t).arguments+=n,yield{type:`content_block_delta`,index:a.get(t).contentIndex,delta:{type:`input_json_delta`,partial_json:n}})}if(e?.finish_reason){o&&(yield{type:`content_block_stop`,index:i},f.delete(i),o=!1),s&&(yield{type:`content_block_stop`,index:i},f.delete(i),s=!1);for(let[,e]of a)f.has(e.contentIndex)&&(yield{type:`content_block_stop`,index:e.contentIndex},f.delete(e.contentIndex));p=e.finish_reason,m=a.size>0}}for(let e of f)yield{type:`content_block_stop`,index:e};p!==null&&(yield{type:`message_delta`,delta:{stop_reason:p===`length`?`max_tokens`:m?`tool_use`:_t(p),stop_sequence:null},usage:{input_tokens:l,output_tokens:u,cache_read_input_tokens:d,cache_creation_input_tokens:0}},yield{type:`message_stop`})}function _t(e){switch(e){case`stop`:return`end_turn`;case`tool_calls`:return`tool_use`;case`length`:return`max_tokens`;case`content_filter`:return`end_turn`;default:return`end_turn`}}var vt=e((()=>{})),yt=e((()=>{he(),ye(),Ce(),Ee(),Re(),Je(),Qe(),Oe(),at(),ft(),ht(),vt()}));function A(e){c()&&(j.length>=St&&j.shift(),j.push(e))}function bt(){return j.length===0?[]:j.splice(0).map(e=>({...e,uuid:y(),session_id:o()}))}function xt(e,t,n){A({type:`system`,subtype:`task_notification`,task_id:e,tool_use_id:n?.toolUseId,status:t,output_file:n?.outputFile??``,summary:n?.summary??``,usage:n?.usage})}var St,j,Ct=e((()=>{i(),St=1e3,j=[]}));function wt(){let e=a();if(e!==void 0)return e;let t=process.env.CLAUDE_CODE_WEBSOCKET_AUTH_FILE_DESCRIPTOR;if(!t){let e=ne(process.env.CLAUDE_SESSION_INGRESS_TOKEN_FILE??v,`session ingress token`);return s(e),e}let n=parseInt(t,10);if(Number.isNaN(n))return m(`CLAUDE_CODE_WEBSOCKET_AUTH_FILE_DESCRIPTOR must be a valid file descriptor number, got: ${t}`,{level:`error`}),s(null),null;try{let e=d(),t=process.platform===`darwin`||process.platform===`freebsd`?`/dev/fd/${n}`:`/proc/self/fd/${n}`,r=e.readFileSync(t,{encoding:`utf8`}).trim();return r?(m(`Successfully read token from file descriptor ${n}`),s(r),te(v,r,`session ingress token`),r):(m(`File descriptor contained empty token`,{level:`error`}),s(null),null)}catch(e){m(`Failed to read token from file descriptor ${n}: ${g(e)}`,{level:`error`});let t=ne(process.env.CLAUDE_SESSION_INGRESS_TOKEN_FILE??v,`session ingress token`);return s(t),t}}function Tt(){return process.env.CLAUDE_CODE_SESSION_ACCESS_TOKEN||wt()}function Et(){let e=Tt();if(!e)return{};if(e.startsWith(`sk-ant-sid`)){let t={Cookie:`sessionKey=${e}`},n=process.env.CLAUDE_CODE_ORGANIZATION_UUID;return n&&(t[`X-Organization-Uuid`]=n),t}return{Authorization:`Bearer ${e}`}}function Dt(e){process.env.CLAUDE_CODE_SESSION_ACCESS_TOKEN=e}var Ot=e((()=>{i(),re(),f(),l(),u()})),kt=t({activateProactive:()=>At,deactivateProactive:()=>jt,getActivationSource:()=>zt,getNextTickAt:()=>Rt,isContextBlocked:()=>It,isProactiveActive:()=>N,isProactivePaused:()=>Mt,pauseProactive:()=>Nt,resumeProactive:()=>Pt,setContextBlocked:()=>Ft,setNextTickAt:()=>Lt,shouldTick:()=>Vt,subscribeToProactiveChanges:()=>Bt});function M(){for(let e of z)try{e()}catch{}}function N(){return P}function At(e){P||(P=!0,F=!1,I=!1,R=e,M())}function jt(){P&&(P=!1,F=!1,I=!1,L=null,R=void 0,M())}function Mt(){return F}function Nt(){!P||F||(F=!0,L=null,M())}function Pt(){!P||!F||(F=!1,M())}function Ft(e){I!==e&&(I=e,e&&(L=null),M())}function It(){return I}function Lt(e){L=e,M()}function Rt(){return!P||F||I?null:L}function zt(){return R}function Bt(e){return z.add(e),()=>{z.delete(e)}}function Vt(){return P&&!F&&!I}var P,F,I,L,R,z,Ht=e((()=>{P=!1,F=!1,I=!1,L=null,z=new Set}));function Ut(e){V=e}function Wt(e,t){if(H=e,!e||!t?.replayCurrent)return;let n=Yt();Object.keys(n).length!==0&&e(n)}function Gt(e){U=e}function Kt(e){return!e||e.enabled!==!0?null:{enabled:!0,phase:e.phase===`standby`||e.phase===`sleeping`?e.phase:null,next_tick_at:typeof e.next_tick_at==`number`?e.next_tick_at:null,sleep_until:typeof e.sleep_until==`number`?e.sleep_until:null}}function qt(e){return JSON.stringify(e)}function Jt(e){let t={...K};for(let n of Object.keys(e)){let r=e[n];if(r===void 0){delete t[n];continue}t[n]=r}K=t}function Yt(){let e={...K};return G?e.automation_state={...G}:`automation_state`in K&&(e.automation_state=K.automation_state??null),e}function Xt(){return en}function Zt(e,t){en=e,V?.(e,t),e===`requires_action`&&t?(W=!0,B({pending_action:t})):W&&(W=!1,B({pending_action:null})),e===`idle`&&B({task_summary:null}),e!==`idle`&&Qt(N()?{enabled:!0,phase:null,next_tick_at:null,sleep_until:null}:null),n(process.env.CLAUDE_CODE_EMIT_SESSION_STATE_EVENTS)&&A({type:`system`,subtype:`session_state_changed`,state:e})}function B(e){Jt(e),H?.(e)}function Qt(e){let t=Kt(e);qt(t)!==qt(G)&&(G=t,Jt({automation_state:t}),H?.({automation_state:t}))}function $t(e){U?.(e)}var V,H,U,W,en,G,K,tn=e((()=>{Ht(),r(),Ct(),V=null,H=null,U=null,W=!1,en=`idle`,G=null,K={}}));function nn(){an(),Z=setInterval(()=>{_(`debug`,`session_keepalive_heartbeat`,{refcount:J}),n(process.env.CLAUDE_CODE_REMOTE_SEND_KEEPALIVES)&&q?.()},fn)}function rn(){an(),q!==null&&(Q=setTimeout(()=>{_(`info`,`session_idle_30s`),Q=null},fn))}function an(){Q!==null&&(clearTimeout(Q),Q=null)}function on(e){q=e,J>0&&Z===null&&nn()}function sn(){q=null,Z!==null&&(clearInterval(Z),Z=null),an()}function cn(){n(process.env.CLAUDE_CODE_REMOTE_SEND_KEEPALIVES)&&q?.()}function ln(){return q!==null}function un(e){J++,Y.set(e,(Y.get(e)??0)+1),J===1&&(X=Date.now(),q!==null&&Z===null&&nn()),pn||(pn=!0,h(async()=>{_(`info`,`session_activity_at_shutdown`,{refcount:J,active:Object.fromEntries(Y),oldest_activity_ms:J>0&&X!==null?Date.now()-X:null})}))}function dn(e){J>0&&J--;let t=(Y.get(e)??0)-1;t>0?Y.set(e,t):Y.delete(e),J===0&&Z!==null&&(clearInterval(Z),Z=null,rn())}var fn,q,J,Y,X,Z,Q,pn,mn=e((()=>{p(),ee(),r(),fn=3e4,q=null,J=0,Y=new Map,X=null,Z=null,Q=null,pn=!1}));function hn(){let e=ie(ce(),`.claude`);oe(e)||se(e,{recursive:!0})}function gn(e){try{$||(hn(),ae(_n,`\n===== RC-DEBUG session ${new Date().toISOString()} =====\n`),$=!0);let t=new Date().toISOString().slice(11,23);ae(_n,`[${t}] ${e}\n`)}catch{}}var _n,$,vn=e((()=>{_n=ie(ce(),`.claude`,`rc-debug.log`),$=!1}));export{De as $,bt as A,ot as B,kt as C,Tt as D,Et as E,gt as F,at as G,D as H,vt as I,qe as J,Ye as K,mt as L,A as M,Ct as N,Ot as O,yt as P,Re as Q,pt as R,Mt as S,Vt as T,rt as U,ft as V,$e as W,Je as X,Ke as Y,ke as Z,Wt as _,on as a,ye as at,It as b,dn as c,me as ct,tn as d,Oe as et,Qt as f,Gt as g,Zt as h,ln as i,Se as it,xt as j,Dt as k,sn as l,ue as lt,B as m,gn as n,Te as nt,cn as o,_e as ot,$t as p,Qe as q,mn as r,Ce as rt,un as s,pe as st,vn as t,Ee as tt,Xt as u,de as ut,Ut as v,Lt as w,N as x,Ht as y,ht as z};
|