claude-code-zanii 2.8.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/README.md +146 -0
- package/dist/chunks/AddWorkspaceDirectory-y_rd6sRl.js +1 -0
- package/dist/chunks/App-DgWSavG1.js +1 -0
- package/dist/chunks/ApproveApiKey-CJKWha-a.js +1 -0
- package/dist/chunks/ApproveApiKey-DTs2ExZH.js +1 -0
- package/dist/chunks/AssistantSessionChooser-BAhVk4id.js +1 -0
- package/dist/chunks/BackgroundTasksDialog-XU_JPh7R.js +2 -0
- package/dist/chunks/BypassPermissionsModeDialog-DV0Pi7ys.js +1 -0
- package/dist/chunks/ClaudeInChromeOnboarding-6erm_8Fn.js +1 -0
- package/dist/chunks/ClaudeMdExternalIncludesDialog-CjBvzB5s.js +1 -0
- package/dist/chunks/ClaudeMdExternalIncludesDialog-ts0XnWwl.js +1 -0
- package/dist/chunks/ConsoleOAuthFlow-DySPdSqQ.js +1 -0
- package/dist/chunks/CustomSelect-DqZxzBZP.js +1 -0
- package/dist/chunks/DesktopHandoff-5c90JK88.js +1 -0
- package/dist/chunks/DevChannelsDialog-DCMderzu.js +1 -0
- package/dist/chunks/Dialog-Dgg8bqcG.js +1 -0
- package/dist/chunks/DiffDialog-BU765aqh.js +6 -0
- package/dist/chunks/Doctor-B73iDB-d.js +3 -0
- package/dist/chunks/Doctor-CLZDdNRo.js +1 -0
- package/dist/chunks/ExitFlow-DBqn2mUf.js +2 -0
- package/dist/chunks/Feedback-D-JHabwi.js +2 -0
- package/dist/chunks/Grove-D-uQNMMo.js +11 -0
- package/dist/chunks/HybridTransport-B-G4QJcy.js +4 -0
- package/dist/chunks/ITermBackend-KP1vKsRN.js +1 -0
- package/dist/chunks/InProcessTransport-ByBEKxrQ.js +1 -0
- package/dist/chunks/InvalidConfigDialog-CMqiZ5nG.js +1 -0
- package/dist/chunks/InvalidSettingsDialog-CjPCKzVZ.js +1 -0
- package/dist/chunks/ListItem-B6MyhHvM.js +1 -0
- package/dist/chunks/MCPConnectionManager-BJ8PcYPe.js +1 -0
- package/dist/chunks/Message-DNxJ_tMS.js +1 -0
- package/dist/chunks/MessageSelector-D79Ug71B.js +3 -0
- package/dist/chunks/Messages-CtIbkB2M.js +11 -0
- package/dist/chunks/Onboarding-DVrgKrI9.js +1 -0
- package/dist/chunks/OverageCreditUpsell-D_td1ss4.js +1 -0
- package/dist/chunks/PermissionDialog-BCS22yEO.js +1 -0
- package/dist/chunks/PermissionDialog-C5O1fL53.js +1 -0
- package/dist/chunks/PermissionRequestTitle-CtlbBU9t.js +1 -0
- package/dist/chunks/PluginSettings-OPrg-_3N.js +17 -0
- package/dist/chunks/PressEnterToContinue-DmzxIgbZ.js +1 -0
- package/dist/chunks/PromptInputFooterSuggestions-CcsKj5DK.js +1 -0
- package/dist/chunks/PromptInputHelpMenu-JedFdsxU.js +1 -0
- package/dist/chunks/REPL-ByhyIRnf.js +1 -0
- package/dist/chunks/REPL-Clve-8zC.js +157 -0
- package/dist/chunks/RemoteCallout-BZcabEKb.js +1 -0
- package/dist/chunks/RemoteSessionManager-C2PIFDHt.js +1 -0
- package/dist/chunks/ResumeConversation-D3ZRTFcF.js +1 -0
- package/dist/chunks/SSETransport-DmZWnH0k.js +4 -0
- package/dist/chunks/SearchBox-DQg2Ph0V.js +1 -0
- package/dist/chunks/SearchExtraToolsTool-CLO4nt6N.js +1 -0
- package/dist/chunks/SentryErrorBoundary-BVfBaOOU.js +2 -0
- package/dist/chunks/SentryErrorBoundary-DIaVFad-.js +1 -0
- package/dist/chunks/Settings-rOCxQdS8.js +2 -0
- package/dist/chunks/TeleportProgress-CP8IY6bz.js +1 -0
- package/dist/chunks/TeleportRepoMismatchDialog-DMmHgBqo.js +1 -0
- package/dist/chunks/TeleportResumeWrapper-D5wEAW1-.js +1 -0
- package/dist/chunks/ThemePicker-Bgr7yOQB.js +1 -0
- package/dist/chunks/TmuxBackend-BzbtUtP1.js +9 -0
- package/dist/chunks/TrustDialog-BI5U3BQ0.js +1 -0
- package/dist/chunks/TungstenTool-CiQclNwj.js +1 -0
- package/dist/chunks/TungstenTool-kMqy-ifa.js +1 -0
- package/dist/chunks/ValidationErrorsList-DprGtB2w.js +2 -0
- package/dist/chunks/WelcomeV2-C4vfBnIy.js +1 -0
- package/dist/chunks/WindowsTerminalBackend-BSoezOCE.js +2 -0
- package/dist/chunks/add-dir-DpOmv6kv.js +1 -0
- package/dist/chunks/agentDisplay-DuYEwOwO.js +1 -0
- package/dist/chunks/agents-BlurXZrF.js +2 -0
- package/dist/chunks/agents-DhZf7ftU.js +103 -0
- package/dist/chunks/ajv-CDrSAj3O.js +8 -0
- package/dist/chunks/analytics-i6X1et4O.js +1 -0
- package/dist/chunks/ant-D9hd_iYy.js +1 -0
- package/dist/chunks/api-CoaOHwDQ.js +4 -0
- package/dist/chunks/api-DvyGR-L7.js +1 -0
- package/dist/chunks/api-YHYC4Zdk.js +1 -0
- package/dist/chunks/artifacts-BMAYdaqh.js +1 -0
- package/dist/chunks/asciicast-DpHRoebc.js +1 -0
- package/dist/chunks/asciicast-HG1EoAQe.js +4 -0
- package/dist/chunks/assistant-D4-qcNT1.js +1 -0
- package/dist/chunks/assistant-DO2ZmZn1.js +1 -0
- package/dist/chunks/assistant-Dd86NmJM.js +1 -0
- package/dist/chunks/attributionHooks-BUmHrLhB.js +1 -0
- package/dist/chunks/attributionTrailer-r2Pbpu2N.js +1 -0
- package/dist/chunks/auth-CF3BGNYT.js +1 -0
- package/dist/chunks/auth-DwWwG43F.js +1 -0
- package/dist/chunks/auth-V_Xk2iea.js +1 -0
- package/dist/chunks/autoMode-DUksX5_i.js +45 -0
- package/dist/chunks/autoModeDenials-0CPO-Jbu.js +1 -0
- package/dist/chunks/autonomy-C5mNhAdz.js +21 -0
- package/dist/chunks/autonomy-CLt1dWaC.js +1 -0
- package/dist/chunks/autonomyPanel-rioFnrQO.js +1 -0
- package/dist/chunks/axios-DPuSPBlH.js +1 -0
- package/dist/chunks/axios-Zh7qGPze.js +12 -0
- package/dist/chunks/backgroundHousekeeping-BGtfqu-J.js +1 -0
- package/dist/chunks/backgroundHousekeeping-BqKZEvy0.js +17 -0
- package/dist/chunks/banner-BGLr3KYQ.js +2 -0
- package/dist/chunks/base64-js-B1tFNiG0.js +1 -0
- package/dist/chunks/bedrockClient-BFzWuhQK.js +15 -0
- package/dist/chunks/bg-B-YgGwLj.js +9 -0
- package/dist/chunks/bg-IU4gG3jc.js +1 -0
- package/dist/chunks/branch-BWY5W7hf.js +3 -0
- package/dist/chunks/break-cache-CY-O23fJ.js +8 -0
- package/dist/chunks/bridge-CqWd70vK.js +2 -0
- package/dist/chunks/bridgeConfig-CWO8AmCY.js +1 -0
- package/dist/chunks/bridgeConfig-D38y9eXn.js +1 -0
- package/dist/chunks/bridgeConfig-EwUq__ct.js +1 -0
- package/dist/chunks/bridgeConfig-GYR-LUiu.js +1 -0
- package/dist/chunks/bridgeEnabled-DKqmLnKO.js +1 -0
- package/dist/chunks/bridgeEnabled-DZIGDtfY.js +1 -0
- package/dist/chunks/bridgeMain-CXVks2ND.js +1 -0
- package/dist/chunks/bridgeMain-D4nsECwJ.js +68 -0
- package/dist/chunks/bridgeMessaging-BUOZU_ba.js +1 -0
- package/dist/chunks/bridgePointer-BpzIEsD_.js +1 -0
- package/dist/chunks/browser-D1vC3BNd.js +1 -0
- package/dist/chunks/btw-CVXJwoXo.js +1 -0
- package/dist/chunks/buddy-BLcvL8lP.js +3 -0
- package/dist/chunks/bundledMode-DQNSSQbt.js +1 -0
- package/dist/chunks/caches-BrfvzKn5.js +1 -0
- package/dist/chunks/caches-CkSv3MfC.js +3 -0
- package/dist/chunks/capacityWake-BWCSatN6.js +1 -0
- package/dist/chunks/changeDetector-DEZU6tum.js +1 -0
- package/dist/chunks/changeDetector-Df7c6U3d.js +1 -0
- package/dist/chunks/channelAllowlist-BApjAS0V.js +1 -0
- package/dist/chunks/channelNotification-BjWwF85R.js +1 -0
- package/dist/chunks/channelNotification-D01YVwNj.js +1 -0
- package/dist/chunks/chokidar-DPwMBcWI.js +1 -0
- package/dist/chunks/chokidar-DkDXNCTz.js +1 -0
- package/dist/chunks/chrome-D7coxEOI.js +1 -0
- package/dist/chunks/chromeNativeHost-CPj9M_4-.js +1 -0
- package/dist/chunks/chunk-DR8-3Aex.js +1 -0
- package/dist/chunks/classPrivateFieldSet2-DZkxcFPS.js +1 -0
- package/dist/chunks/claudeAiLimitsHook-ATshVrOH.js +1 -0
- package/dist/chunks/claudeDesktop-PVa9tWsM.js +1 -0
- package/dist/chunks/cleanup-C-PGmKpV.js +1 -0
- package/dist/chunks/clear-CxGE9Ntr.js +1 -0
- package/dist/chunks/cliLaunch-CMXoY_LO.js +1 -0
- package/dist/chunks/client-BWED8Tbu.js +35 -0
- package/dist/chunks/client-CinDjeSq.js +7 -0
- package/dist/chunks/client-CpXGg9e0.js +1 -0
- package/dist/chunks/color-B3w_VQTn.js +1 -0
- package/dist/chunks/color-convert-BQZnVz_5.js +1 -0
- package/dist/chunks/commands-DFp48zwy.js +1 -0
- package/dist/chunks/commitAttribution-B0cXmbvv.js +2 -0
- package/dist/chunks/commitAttribution-DRSKRoH6.js +1 -0
- package/dist/chunks/common-BX7bn3hg.js +1 -0
- package/dist/chunks/common-Ce3LanTX.js +1 -0
- package/dist/chunks/common-DdLQuE2_.js +1 -0
- package/dist/chunks/common-HfKcqOYK.js +1 -0
- package/dist/chunks/compact-C8ljGMdo.js +3 -0
- package/dist/chunks/companion-mD1jw6xX.js +1 -0
- package/dist/chunks/completionCache-BqQXVTa9.js +1 -0
- package/dist/chunks/completionCache-BtP4vfAi.js +4 -0
- package/dist/chunks/computerUseLock-ADE_PhIK.js +1 -0
- package/dist/chunks/config-CmyaIIOY.js +1 -0
- package/dist/chunks/config-Rl1Y_Dtq.js +1 -0
- package/dist/chunks/connectHeadless-MFABhXpz.js +1 -0
- package/dist/chunks/constants-BM62Vf_X.js +1 -0
- package/dist/chunks/constants-BfXy-5cI.js +1 -0
- package/dist/chunks/context-BeiZkUNq.js +1 -0
- package/dist/chunks/context-noninteractive-CRdF3iv8.js +54 -0
- package/dist/chunks/controlMessageCompat-591iGHUK.js +1 -0
- package/dist/chunks/conversation-BoguXZEI.js +1 -0
- package/dist/chunks/conversation-yhs7tT-g.js +1 -0
- package/dist/chunks/copy-BpeUcqku.js +7 -0
- package/dist/chunks/createSSHSession-B3JOB4TE.js +6 -0
- package/dist/chunks/createSession-BJSnFBGt.js +1 -0
- package/dist/chunks/createSession-CnRHI3RU.js +1 -0
- package/dist/chunks/cron-iqTFGIos.js +1 -0
- package/dist/chunks/cronScheduler-zRXhgEEU.js +6 -0
- package/dist/chunks/cronTasks-CMJldfoP.js +2 -0
- package/dist/chunks/crossProjectResume-DxO6TX30.js +40 -0
- package/dist/chunks/cwd-B2guYBbl.js +1 -0
- package/dist/chunks/cwd-B5bbyUwz.js +1 -0
- package/dist/chunks/cwd-BXiaJzLh.js +1 -0
- package/dist/chunks/daemon-B3v4OoOu.js +2 -0
- package/dist/chunks/dangerousBackend-OmCzoW35.js +1 -0
- package/dist/chunks/datadog-3-Vvz0yz.js +1 -0
- package/dist/chunks/datadog-BQlp3bTs.js +1 -0
- package/dist/chunks/debug-BDBIipC1.js +2 -0
- package/dist/chunks/debug-C7tW7DFW.js +1 -0
- package/dist/chunks/debug-CjIaNjpK.js +5 -0
- package/dist/chunks/debugUtils-Dsg-UHeg.js +1 -0
- package/dist/chunks/defineProperty-CaCI0a5T.js +1 -0
- package/dist/chunks/desktop-C_SS0068.js +1 -0
- package/dist/chunks/detached-B7RNZeyl.js +5 -0
- package/dist/chunks/detect-libc-DFFGDzPC.js +1 -0
- package/dist/chunks/detectRepository-BnTCJAXR.js +1 -0
- package/dist/chunks/detectRepository-Gobn9eFt.js +1 -0
- package/dist/chunks/detection-CN_uLGU2.js +1 -0
- package/dist/chunks/detection-DW6grIlc.js +1 -0
- package/dist/chunks/diff-B8YmRG5T.js +1 -0
- package/dist/chunks/directoryCompletion-J560aATd.js +1 -0
- package/dist/chunks/dist-B1wOprSs.js +29 -0
- package/dist/chunks/dist-DZQOarNX.js +5 -0
- package/dist/chunks/dist-HZfkKiUF.js +20 -0
- package/dist/chunks/dist-es-4xyrZoNc2.js +1 -0
- package/dist/chunks/dist-es-6kjvVbJd.js +1 -0
- package/dist/chunks/dist-es-BJldFHbt.js +3 -0
- package/dist/chunks/dist-es-BM013UFT.js +1 -0
- package/dist/chunks/dist-es-BPPewn1A.js +1 -0
- package/dist/chunks/dist-es-BZGG3Hnm.js +1 -0
- package/dist/chunks/dist-es-BZjJL64k2.js +1 -0
- package/dist/chunks/dist-es-BctcPxLN.js +1 -0
- package/dist/chunks/dist-es-Bf2jR30y.js +1 -0
- package/dist/chunks/dist-es-BgLoR-hQ.js +1 -0
- package/dist/chunks/dist-es-BismPcTW.js +1 -0
- package/dist/chunks/dist-es-BrPzXmSP.js +1 -0
- package/dist/chunks/dist-es-Bu21Wvhs.js +1 -0
- package/dist/chunks/dist-es-BuWNNAXW.js +1 -0
- package/dist/chunks/dist-es-Bz11sFiK2.js +1 -0
- package/dist/chunks/dist-es-C5VplyPL2.js +5 -0
- package/dist/chunks/dist-es-C66BuLgn.js +1 -0
- package/dist/chunks/dist-es-CCIzgNln2.js +1 -0
- package/dist/chunks/dist-es-CLyx7Kge2.js +1 -0
- package/dist/chunks/dist-es-CUbatGdn.js +1 -0
- package/dist/chunks/dist-es-CYe_-TbD.js +1 -0
- package/dist/chunks/dist-es-C_IHUdzL.js +1 -0
- package/dist/chunks/dist-es-Ci_rKlMr.js +1 -0
- package/dist/chunks/dist-es-ClDZBAj7.js +1 -0
- package/dist/chunks/dist-es-Cp--qjOi.js +1 -0
- package/dist/chunks/dist-es-CzE4kW1L.js +9 -0
- package/dist/chunks/dist-es-DUg5w7-v.js +1 -0
- package/dist/chunks/dist-es-Dl0ZRczY.js +1 -0
- package/dist/chunks/dist-es-Do_155z5.js +1 -0
- package/dist/chunks/dist-es-DxIM0jd82.js +1 -0
- package/dist/chunks/dist-es-Fav2oBDs.js +1 -0
- package/dist/chunks/dist-es-TZjwPaGn.js +1 -0
- package/dist/chunks/dist-es-W22ud2el2.js +1 -0
- package/dist/chunks/dist-es-aU8-02YH.js +1 -0
- package/dist/chunks/dist-es-b3yZSGx82.js +1 -0
- package/dist/chunks/dist-es-dIP5JtXz.js +5 -0
- package/dist/chunks/dist-es-mQ4HvnYs2.js +1 -0
- package/dist/chunks/distRoot-CJaacAHy.js +1 -0
- package/dist/chunks/doctor-DLZPF4iY.js +1 -0
- package/dist/chunks/earlyInput-BTI1CSNt.js +2 -0
- package/dist/chunks/earlyInput-BwGtzhhP.js +1 -0
- package/dist/chunks/effort-BaHvpBWr.js +9 -0
- package/dist/chunks/entry-_e-lyRwv.js +14 -0
- package/dist/chunks/env-CesrOJJq.js +1 -0
- package/dist/chunks/envLessBridgeConfig-4oys0_9A.js +1 -0
- package/dist/chunks/envLessBridgeConfig-DJ1Sts3F.js +1 -0
- package/dist/chunks/envUtils-CFG7IQID.js +1 -0
- package/dist/chunks/errorLogSink-Ti4Suoz6.js +2 -0
- package/dist/chunks/escHotkey-CVn_80xM.js +259 -0
- package/dist/chunks/esm-BFnjHW38.js +1 -0
- package/dist/chunks/esm-BQg_LX3V.js +1 -0
- package/dist/chunks/esm-BtC6CMmM.js +1 -0
- package/dist/chunks/esm-BwzC0MQp.js +1 -0
- package/dist/chunks/esm-CFybeQ_Q.js +1 -0
- package/dist/chunks/esm-CK-5CT5X.js +1 -0
- package/dist/chunks/esm-CL1OwlZB.js +1 -0
- package/dist/chunks/esm-CMzgSTAl.js +1 -0
- package/dist/chunks/esm-CPE_H2Lx.js +1 -0
- package/dist/chunks/esm-CcWquv5a.js +10 -0
- package/dist/chunks/esm-CeNEpRZt.js +1 -0
- package/dist/chunks/esm-D7hykoRB.js +1 -0
- package/dist/chunks/esm-DUtcefEV.js +1 -0
- package/dist/chunks/esm-DhrUwJBp.js +1 -0
- package/dist/chunks/esm-Duu1fRQ8.js +1 -0
- package/dist/chunks/esm-Ght2BaU2.js +1 -0
- package/dist/chunks/esm-Q6Yz2GMx.js +56 -0
- package/dist/chunks/esm-WONEiurY.js +13 -0
- package/dist/chunks/event-streams-BumpU1aB.js +1 -0
- package/dist/chunks/eventLoopStallDetector-DxyFdg1h.js +1 -0
- package/dist/chunks/execAsync-ChKxDZ8C.js +1 -0
- package/dist/chunks/execFileNoThrow-DdmR1mBS.js +1 -0
- package/dist/chunks/execSyncWrapper-Ch4TNj8u.js +1 -0
- package/dist/chunks/execa-BMaINL7N.js +34 -0
- package/dist/chunks/executor-C7INr19-.js +1 -0
- package/dist/chunks/executor-Dnf3YYma.js +1604 -0
- package/dist/chunks/exit-BakzsOD0.js +1 -0
- package/dist/chunks/exit-CiDn2tN9.js +2 -0
- package/dist/chunks/export-b-6pqMqz.js +2 -0
- package/dist/chunks/exportRenderer-RxtEIyTm.js +1 -0
- package/dist/chunks/extra-usage-7EPJNjNW.js +1 -0
- package/dist/chunks/extra-usage-ChvuewCq.js +1 -0
- package/dist/chunks/extra-usage-core-BVhLtoDF.js +1 -0
- package/dist/chunks/extra-usage-noninteractive-_Njh6q-q.js +1 -0
- package/dist/chunks/extraUsage-qOBMQB6g.js +1 -0
- package/dist/chunks/extractMemories-CRBVNiG1.js +1 -0
- package/dist/chunks/fast-C4uw_g7o.js +1 -0
- package/dist/chunks/fast-CEaIzaPl.js +1 -0
- package/dist/chunks/featureCheck-B1GSTyhh.js +1 -0
- package/dist/chunks/featureCheck-DKigAPal.js +1 -0
- package/dist/chunks/feedback-Bf3TjjuD.js +1 -0
- package/dist/chunks/figures-fES5sASd.js +1 -0
- package/dist/chunks/fileStateCache-DAsLEZau.js +1 -0
- package/dist/chunks/files-B-m_4X8b.js +2 -0
- package/dist/chunks/findExecutable-D8vJrFnO.js +1 -0
- package/dist/chunks/firstPartyEventLogger-BtrGagNa.js +1 -0
- package/dist/chunks/flushGate-2zqab-Pp.js +1 -0
- package/dist/chunks/foundry-sdk-CtX8C0x3.js +1 -0
- package/dist/chunks/fpsMetrics-ts_jaF3g.js +1 -0
- package/dist/chunks/fuse-ivQ_eRwF.js +1 -0
- package/dist/chunks/gates-CmKoQ0O-.js +1 -0
- package/dist/chunks/gates-_wbPDQ3M.js +1 -0
- package/dist/chunks/gemini-DRx495gn.js +3 -0
- package/dist/chunks/generateRecap-Cv8gd_QF.js +1 -0
- package/dist/chunks/generateSessionName-Dpjg-u_x.js +1 -0
- package/dist/chunks/genericProcessUtils-BFJMxLqn.js +23 -0
- package/dist/chunks/getMachineId-bsd-C9pL9Ajr.js +1 -0
- package/dist/chunks/getMachineId-darwin-Ma4F9rJg.js +2 -0
- package/dist/chunks/getMachineId-linux-C0lXMqsj.js +1 -0
- package/dist/chunks/getMachineId-unsupported-ByHQTXat.js +1 -0
- package/dist/chunks/getMachineId-win-DZsXZmTz.js +1 -0
- package/dist/chunks/git-Bj8Ow4pJ.js +6 -0
- package/dist/chunks/git-Q_b4oZ17.js +1 -0
- package/dist/chunks/githubRepoPathMapping-DGivBX9h.js +1 -0
- package/dist/chunks/goal-BrHEJv8o.js +3 -0
- package/dist/chunks/goalStorage-CsuPOQbk.js +1 -0
- package/dist/chunks/graceful-fs-BuPWC-vB.js +2 -0
- package/dist/chunks/grok-CDkDDaY_.js +1 -0
- package/dist/chunks/growthbook-D3_Cr9n-.js +1 -0
- package/dist/chunks/growthbook-p4aJ_UMv.js +32 -0
- package/dist/chunks/hash-KW-tVnPp.js +1 -0
- package/dist/chunks/heapdump-CloylIZ9.js +5 -0
- package/dist/chunks/help-DpSJlHIc.js +1 -0
- package/dist/chunks/hooks-2pogt8nv.js +79 -0
- package/dist/chunks/hooks-BBODdwnE.js +1 -0
- package/dist/chunks/hostAdapter-B5KTUqhv.js +1 -0
- package/dist/chunks/hostGuard-DyWr2TwE.js +1 -0
- package/dist/chunks/httpAuthSchemes-CgPbtGos.js +13 -0
- package/dist/chunks/ide-CJEcfBZq.js +2 -0
- package/dist/chunks/inboundAttachments-RNpYpRTO.js +1 -0
- package/dist/chunks/index.min-DCDiLq-j.js +1 -0
- package/dist/chunks/initReplBridge-D2E6IM2B.js +1 -0
- package/dist/chunks/initReplBridge-p2uwDBPx.js +1 -0
- package/dist/chunks/insights-DnpZScKs.js +822 -0
- package/dist/chunks/install-D_vTxUlG.js +1 -0
- package/dist/chunks/install-github-app-BK8A7g3i.js +147 -0
- package/dist/chunks/install-slack-app-C47R9VoI.js +1 -0
- package/dist/chunks/instinctParser-DxKdI3JC.js +1 -0
- package/dist/chunks/instrumentation-DkdAJFrZ.js +12 -0
- package/dist/chunks/intl-Pse97ORk.js +1 -0
- package/dist/chunks/isObject-DaxDnPKm.js +1 -0
- package/dist/chunks/isSymbol-D7QeUnS5.js +1 -0
- package/dist/chunks/job-opl00C4l.js +2 -0
- package/dist/chunks/json-bigint-BRRVs1dv.js +8 -0
- package/dist/chunks/jsx-runtime-BTgGEFjL.js +1 -0
- package/dist/chunks/jws-B_ieuaZg.js +3 -0
- package/dist/chunks/jwtUtils-D-tJzoJY.js +1 -0
- package/dist/chunks/keybindings-mRf9VSe8.js +2 -0
- package/dist/chunks/lang-eH4EJErj.js +1 -0
- package/dist/chunks/language-DD9ar6RA.js +1 -0
- package/dist/chunks/language-EZLNdETg.js +1 -0
- package/dist/chunks/launchAgentsPlatform-Cq0_7-IM.js +1 -0
- package/dist/chunks/launchAutofixPr-Bw7aUHUs.js +18 -0
- package/dist/chunks/launchCommand-Bk1Fn-qZ.js +1 -0
- package/dist/chunks/launchLocalMemory-CLBCUgwd.js +3 -0
- package/dist/chunks/launchLocalVault-BfWJWrBg.js +3 -0
- package/dist/chunks/launchMemoryStores-DdnSVSDZ.js +1 -0
- package/dist/chunks/launchOnboarding-ziCEX3GI.js +8 -0
- package/dist/chunks/launchSchedule-G_c7sgmy.js +1 -0
- package/dist/chunks/launchSkillStore-Z1Kd7nCg.js +1 -0
- package/dist/chunks/launchTeleport-Dp9AFbPx.js +3 -0
- package/dist/chunks/launchVault-hwK-Ljek.js +1 -0
- package/dist/chunks/lazySchema-2sOku3cX.js +1 -0
- package/dist/chunks/lib-BHRYgENJ.js +8 -0
- package/dist/chunks/lib-DRyNc7xD.js +2 -0
- package/dist/chunks/lib-Ddq71jM5.js +14 -0
- package/dist/chunks/loadAgentsDir-Bz0FfcVt.js +5620 -0
- package/dist/chunks/loadAgentsDir-CLM0ws7u.js +1 -0
- package/dist/chunks/loadPluginHooks-B5SIS2uo.js +1 -0
- package/dist/chunks/loadSso-RY87rrJO.js +1 -0
- package/dist/chunks/localSearch-BLF6PSv2.js +1 -0
- package/dist/chunks/localSearch-CTycGe3E.js +1 -0
- package/dist/chunks/localSearch-inDahM8I.js +1 -0
- package/dist/chunks/lockfile--gk1HDM6.js +1 -0
- package/dist/chunks/log-B-Nj3Yed.js +1 -0
- package/dist/chunks/log-DVv8YiNo.js +1 -0
- package/dist/chunks/login-BeLvLowc.js +1 -0
- package/dist/chunks/login-DUUOeNoz.js +1 -0
- package/dist/chunks/logoV2Utils-D5SpeZ3C.js +1 -0
- package/dist/chunks/logout-C2QuTBdS.js +1 -0
- package/dist/chunks/magicDocs-CUXKi-Wv.js +57 -0
- package/dist/chunks/main-CFhpWtpC.js +1420 -0
- package/dist/chunks/main-sboa5RKc.js +31 -0
- package/dist/chunks/mappers-DLkk0PZz.js +1 -0
- package/dist/chunks/mcp-C2f6IgAp.js +2 -0
- package/dist/chunks/mcp-Djui9m3_.js +6 -0
- package/dist/chunks/mcp-DvTSxrJ4.js +1 -0
- package/dist/chunks/mcpServer-DMA0bdFC.js +1 -0
- package/dist/chunks/mcpServer-DxEHfW2v.js +1 -0
- package/dist/chunks/memoize-Bg2dXTzV.js +1 -0
- package/dist/chunks/memoize-DNnuA2aU.js +1 -0
- package/dist/chunks/memory-B9io9Zcv.js +1 -0
- package/dist/chunks/mobile-CPnnvkQV.js +2 -0
- package/dist/chunks/modalContext-B1b0Gsro.js +1 -0
- package/dist/chunks/mode-BDgwh_Xb.js +2 -0
- package/dist/chunks/model-B6cpEh-s.js +1 -0
- package/dist/chunks/model-BcunOCC9.js +1 -0
- package/dist/chunks/modelOptions-CHUHQ9WG.js +1 -0
- package/dist/chunks/normalization-cjPqid31.js +1 -0
- package/dist/chunks/oauth-CnBLewrU.js +1 -0
- package/dist/chunks/oauth-DMPGYAoZ.js +1 -0
- package/dist/chunks/observationStore-DVBxrSdI.js +4 -0
- package/dist/chunks/onChangeAppState-M61XDN6V.js +1 -0
- package/dist/chunks/open-CsUNPSNx.js +1 -0
- package/dist/chunks/openai-BHvlYW3m.js +2 -0
- package/dist/chunks/output-style-BtKuBrs4.js +1 -0
- package/dist/chunks/outputStyles-hHuIBkRB.js +84 -0
- package/dist/chunks/overageCreditGrant-BLFT-rF3.js +1 -0
- package/dist/chunks/p-map-C-WNcN6g.js +1 -0
- package/dist/chunks/p-map-CQ2NythB.js +1 -0
- package/dist/chunks/package-9IAs5Qf0.js +1 -0
- package/dist/chunks/panel-27xLZI7c.js +1 -0
- package/dist/chunks/panel-NoDfShEZ.js +1 -0
- package/dist/chunks/panelCall-CEOWVNCM.js +1 -0
- package/dist/chunks/parseConnectUrl-CxU4IX9o.js +1 -0
- package/dist/chunks/parser-DGlAnaNj.js +1 -0
- package/dist/chunks/parser-DGoLe2RS.js +1 -0
- package/dist/chunks/passes-CExcqu66.js +1 -0
- package/dist/chunks/path-uaxlnhva.js +1 -0
- package/dist/chunks/permissions-B3PceQul.js +1 -0
- package/dist/chunks/permissions-DezIL2xF.js +3 -0
- package/dist/chunks/permissions-DnpI8Whh.js +1 -0
- package/dist/chunks/pipeTransport-CB_Wq_Kx.js +1 -0
- package/dist/chunks/plan-cfZBclh9.js +1 -0
- package/dist/chunks/platform-BXz_rgpy.js +2 -0
- package/dist/chunks/plist-DLGDWBD6.js +6 -0
- package/dist/chunks/plugin-CuhENLRs.js +1 -0
- package/dist/chunks/pluginAutoupdate-wTeOXfQe.js +1 -0
- package/dist/chunks/pluginBlocklist-D6pkKfXr.js +1 -0
- package/dist/chunks/pluginCliCommands-DqxdCwsq.js +1 -0
- package/dist/chunks/pluginFlagging-CjH48f-K.js +1 -0
- package/dist/chunks/pluginOperations-DMFYB3pK.js +2 -0
- package/dist/chunks/pluginStartupCheck-BW3_KfZz.js +1 -0
- package/dist/chunks/pluginStartupCheck-Cj2BMjVw.js +1 -0
- package/dist/chunks/plugins-CarsG2v8.js +4 -0
- package/dist/chunks/policyLimits-DFn1vHkN.js +1 -0
- package/dist/chunks/pollConfig-C8nODJY1.js +1 -0
- package/dist/chunks/poller-DXZJ-dUP.js +1 -0
- package/dist/chunks/poor-C7GQ4a5X.js +1 -0
- package/dist/chunks/poorMode-CBe0rfxB.js +1 -0
- package/dist/chunks/poorMode-CbZTudtw.js +1 -0
- package/dist/chunks/postCommitAttribution--vvAWIqD.js +1 -0
- package/dist/chunks/print-CwwtGSbK.js +114 -0
- package/dist/chunks/privacy-settings-Bz8cAVp5.js +11 -0
- package/dist/chunks/privacyLevel-CRCHhztk.js +1 -0
- package/dist/chunks/process-CnhUplBr.js +1 -0
- package/dist/chunks/process-X4vCP9x0.js +1 -0
- package/dist/chunks/processBashCommand-NL0YEUqW.js +3 -0
- package/dist/chunks/processSlashCommand-FPMWElsI.js +6 -0
- package/dist/chunks/processSlashCommand-_oJs6_w8.js +6 -0
- package/dist/chunks/processUserInput-QAJK0XSn.js +1 -0
- package/dist/chunks/projectContext-B21hXj9q.js +1 -0
- package/dist/chunks/projectContext-DbTQHQS3.js +1 -0
- package/dist/chunks/prompt-C6eleu4x.js +1 -0
- package/dist/chunks/prompt-CUdoQXyN.js +1 -0
- package/dist/chunks/prompt-CsBCtw4l.js +228 -0
- package/dist/chunks/prompt-hnIDYhP4.js +54 -0
- package/dist/chunks/promptEditor-CrlVcc17.js +4 -0
- package/dist/chunks/protectedNamespace-Cn4901XG.js +1 -0
- package/dist/chunks/protocolHandler-DM_w7sJ5.js +13 -0
- package/dist/chunks/protocols-CpoQzjyI.js +7 -0
- package/dist/chunks/proxy-9WvtUy8E.js +99 -0
- package/dist/chunks/rate-limit-options-BehQ3MoX.js +1 -0
- package/dist/chunks/rcDebugLog-BbHlIxCm.js +11 -0
- package/dist/chunks/referral-BfAZEIZL.js +1 -0
- package/dist/chunks/refresh-Bl3Miver.js +1 -0
- package/dist/chunks/registerProtocol-BHZ3vZED.js +36 -0
- package/dist/chunks/registerSkillHooks-BR7v5qDA.js +1 -0
- package/dist/chunks/registry-C2igpRd-.js +1 -0
- package/dist/chunks/release-notes-C_Cou6ye.js +4 -0
- package/dist/chunks/releaseNotes-DveQShyB.js +2 -0
- package/dist/chunks/reload-plugins-D-pAUoB5.js +1 -0
- package/dist/chunks/remote-env-C_dBgbgo.js +1 -0
- package/dist/chunks/remoteBridgeCore-BxWhTy1u.js +1 -0
- package/dist/chunks/remoteControlServer-D3OjUlB-.js +3 -0
- package/dist/chunks/rename-f3m0ETSt.js +1 -0
- package/dist/chunks/renderOptions-QZLxGnh_.js +1 -0
- package/dist/chunks/replBridge-qeVmCJOb.js +1 -0
- package/dist/chunks/resume-CM_8p9Iu.js +2 -0
- package/dist/chunks/rewind-0cB7o6fx.js +1 -0
- package/dist/chunks/ripgrep-BEWqxrpl.js +5 -0
- package/dist/chunks/ripgrep-G82m12Ng.js +1 -0
- package/dist/chunks/rollback-CVo2gqgR.js +11 -0
- package/dist/chunks/runtimeObserver-1EdvvoYw.js +1 -0
- package/dist/chunks/runtimeObserver-CX6vepq9.js +10 -0
- package/dist/chunks/sandbox-adapter-DzHfW2tH.js +1 -0
- package/dist/chunks/sandbox-toggle-N6KgmH2T.js +1 -0
- package/dist/chunks/sanitization-CIBpY9KT.js +1 -0
- package/dist/chunks/satisfies-B7ZvBUQP.js +1 -0
- package/dist/chunks/schemas-Bwt-7U5W.js +40 -0
- package/dist/chunks/sdk-Drp69kIx.js +1 -0
- package/dist/chunks/sdkHeapDumpMonitor-B9GVkISU.js +1 -0
- package/dist/chunks/searchExtraTools-BphNJsl8.js +1 -0
- package/dist/chunks/semver-BsItM2Z4.js +1 -0
- package/dist/chunks/semver-D3lOjiBN.js +1 -0
- package/dist/chunks/sentry-ySzRCXGd.js +1 -0
- package/dist/chunks/server-C8nMDji6.js +1 -0
- package/dist/chunks/server-XZG51Slr.js +1 -0
- package/dist/chunks/serverBanner-D68EBGzH.js +1 -0
- package/dist/chunks/serverLog-hv2hc5US.js +1 -0
- package/dist/chunks/session-CVoGFb8a.js +2 -0
- package/dist/chunks/sessionDataUploader-BaD1Q7v3.js +1 -0
- package/dist/chunks/sessionDiscovery-D7g66TX6.js +1 -0
- package/dist/chunks/sessionFileAccessHooks-9lPjspRX.js +1 -0
- package/dist/chunks/sessionManager-BhOjMNAP.js +1 -0
- package/dist/chunks/sessionMemory-BA6cdxqP.js +1 -0
- package/dist/chunks/sessionMemory-CtEhIRGF.js +1 -0
- package/dist/chunks/sessionMemoryUtils-D_B92ypa.js +1 -0
- package/dist/chunks/sessionObserver-CESI-uVZ.js +1 -0
- package/dist/chunks/sessionObserver-SpE_eglb.js +20 -0
- package/dist/chunks/sessionRestore-DqsqYK4K.js +1 -0
- package/dist/chunks/sessionState-Dgky34M4.js +1 -0
- package/dist/chunks/sessionStorage-DJb5HKhQ.js +1 -0
- package/dist/chunks/sessionStorage-DSMfHTcg.js +1 -0
- package/dist/chunks/sessionStoragePortable-DyM_hZnp.js +3 -0
- package/dist/chunks/sessionTitle-Bzxk_EW9.js +14 -0
- package/dist/chunks/sessionTracing-DR8O0686.js +12 -0
- package/dist/chunks/setup-BHNS9sBS.js +9 -0
- package/dist/chunks/setup-BafJxZ0F.js +4 -0
- package/dist/chunks/setup-MLNNYLi6.js +1 -0
- package/dist/chunks/shadowedRuleDetection-Ch9gTxfD.js +1 -0
- package/dist/chunks/shellQuote-3s6tV-hK.js +1 -0
- package/dist/chunks/sideQuestion-BBn6XIOD.js +20 -0
- package/dist/chunks/signal-BTxmab6r.js +1 -0
- package/dist/chunks/signin-ChbUAEGq.js +1 -0
- package/dist/chunks/sink-B1qICbRh.js +1 -0
- package/dist/chunks/sink-yBIcxQf1.js +1 -0
- package/dist/chunks/sinks-C7weduDR.js +1 -0
- package/dist/chunks/skill-learning-08nEdOJ2.js +5 -0
- package/dist/chunks/skillGapStore-CuvWGqFb.js +5 -0
- package/dist/chunks/skillGapStore-DmMuDXKO.js +1 -0
- package/dist/chunks/skillGenerator-mEMjcmmm.js +8 -0
- package/dist/chunks/skillLearning-B3a-8Ys3.js +1 -0
- package/dist/chunks/skillLearning-q5T6o0mH.js +1 -0
- package/dist/chunks/skillPanel-BuUMhONI.js +28 -0
- package/dist/chunks/skillSearchPanel-BUEv7Sm9.js +21 -0
- package/dist/chunks/skillUsageTracking-BBTiWOKB.js +1 -0
- package/dist/chunks/skills-DvQuQfDW.js +1 -0
- package/dist/chunks/slashCommandParsing-BkTC3GRb.js +1 -0
- package/dist/chunks/sleep-CC8jykQd.js +1 -0
- package/dist/chunks/slowOperations-niPqC54V.js +1 -0
- package/dist/chunks/sprites-C5X62Vyh.js +1 -0
- package/dist/chunks/src-58uAJYF_.js +6 -0
- package/dist/chunks/src-7Y8fx6gl.js +2 -0
- package/dist/chunks/src-BuserDTl.js +1 -0
- package/dist/chunks/src-CMY4XoRy.js +1 -0
- package/dist/chunks/src-CfeAM1FB.js +1 -0
- package/dist/chunks/src-CxT2FDXy.js +1 -0
- package/dist/chunks/src-CyQf7rVu.js +26 -0
- package/dist/chunks/src-DJLbU8sT.js +1 -0
- package/dist/chunks/src-DJQlyVK6.js +5 -0
- package/dist/chunks/src-DNHWYkls.js +53 -0
- package/dist/chunks/src-DU_g0n_Q.js +1 -0
- package/dist/chunks/src-DhqzQjMg.js +19 -0
- package/dist/chunks/src-Duzv1Znh.js +1 -0
- package/dist/chunks/src-OBx6GAig.js +1 -0
- package/dist/chunks/src-WjnK2Dbo.js +1 -0
- package/dist/chunks/src-hjAMxWFj.js +7 -0
- package/dist/chunks/src-lLwoqdC0.js +9 -0
- package/dist/chunks/src-yRsWbJp_.js +2 -0
- package/dist/chunks/sso-oidc-yfC-A2A2.js +1 -0
- package/dist/chunks/startupProfiler-4P7GdVw6.js +3 -0
- package/dist/chunks/startupProfiler-CipS0otN.js +1 -0
- package/dist/chunks/state-9wSimHaL.js +1 -0
- package/dist/chunks/state-BQkyHx88.js +1 -0
- package/dist/chunks/state-CEAUTY3A.js +1 -0
- package/dist/chunks/state-CUZTq6r0.js +1 -0
- package/dist/chunks/state-U0HNbTx8.js +1 -0
- package/dist/chunks/staticRender-BB3CisKd.js +1 -0
- package/dist/chunks/stats-Dyi2U_mq.js +1 -0
- package/dist/chunks/status-CSL-GMou.js +1 -0
- package/dist/chunks/statusNoticeHelpers-BaXE951d.js +1 -0
- package/dist/chunks/stdio-BuUJYJFs.js +3 -0
- package/dist/chunks/stdio-iX0TTmbp.js +1 -0
- package/dist/chunks/stickers-2CRSckfH.js +1 -0
- package/dist/chunks/store-DdfsZvtr.js +1 -0
- package/dist/chunks/stringUtils-U7kMYMJq.js +4 -0
- package/dist/chunks/sts-CJmdeT7s.js +1 -0
- package/dist/chunks/subprocessEnv-DKTILev5.js +1 -0
- package/dist/chunks/subprocessEnv-WjRguKWf.js +1 -0
- package/dist/chunks/supports-color-DaytqqjM.js +1 -0
- package/dist/chunks/systemPromptSections-BnrxBWdc.js +1 -0
- package/dist/chunks/systemPromptSections-Dk6azdAb.js +1 -0
- package/dist/chunks/systemTheme-C1GNqIfy.js +1 -0
- package/dist/chunks/tag-C4cH016L.js +11 -0
- package/dist/chunks/tasks-CEdUW3RQ.js +1 -0
- package/dist/chunks/teamHelpers-CTA_CtTT.js +1 -0
- package/dist/chunks/teamHelpers-D65qZInv.js +1 -0
- package/dist/chunks/teammate-C-FiRloZ.js +1 -0
- package/dist/chunks/teammateModeSnapshot-DWRG5-Us.js +1 -0
- package/dist/chunks/teammateModeSnapshot-DtgsNj1G.js +1 -0
- package/dist/chunks/teleport-C_UgMy0V.js +1 -0
- package/dist/chunks/templateJobs-CMbS0tuk.js +12 -0
- package/dist/chunks/terminalSetup--jwGVap8.js +33 -0
- package/dist/chunks/terminalSetup-zID-wokH.js +1 -0
- package/dist/chunks/theme-C6XwTpVy.js +1 -0
- package/dist/chunks/thinkback-CVLnmLAT.js +1 -0
- package/dist/chunks/thinkback-MeOOO7gf.js +1 -0
- package/dist/chunks/thinkback-play-D7G260F4.js +1 -0
- package/dist/chunks/tmux-DtYJuTWh.js +1 -0
- package/dist/chunks/toolEventObserver-BtC9xDYY.js +1 -0
- package/dist/chunks/toolEventObserver-MfsHAt8h.js +1 -0
- package/dist/chunks/toolPool-CEi_2xIH.js +1 -0
- package/dist/chunks/toolPool-CdYJcCnc.js +1 -0
- package/dist/chunks/trustedDevice-CjQTGAa4.js +1 -0
- package/dist/chunks/trustedDevice-DADcxAAs.js +1 -0
- package/dist/chunks/tui-B8Ijq4Pk.js +6 -0
- package/dist/chunks/turndown.es-T-Xe93nc.js +69 -0
- package/dist/chunks/types-BVelRhgb.js +17 -0
- package/dist/chunks/types-Bqp3meR4.js +1 -0
- package/dist/chunks/types-CNmINIu3.js +1 -0
- package/dist/chunks/types-DgzOOCDl.js +3 -0
- package/dist/chunks/udsClient-ClY_0CKr.js +1 -0
- package/dist/chunks/ultrareviewCommand-CqvHj9Io.js +3 -0
- package/dist/chunks/undercover-CVCVOSrs.js +1 -0
- package/dist/chunks/undercover-CbxiJO2b.js +31 -0
- package/dist/chunks/up-CBJhVVbd.js +12 -0
- package/dist/chunks/updateCCB-DPPpquAw.js +11 -0
- package/dist/chunks/upgrade-DaaHOvft.js +1 -0
- package/dist/chunks/upgrade-k7ZvAWZ0.js +1 -0
- package/dist/chunks/upload-CEDxwMa1.js +1 -0
- package/dist/chunks/upstreamproxy-BtGJ2LRi.js +11 -0
- package/dist/chunks/usage-CsUSu4fb.js +1 -0
- package/dist/chunks/usage-oABvixCs.js +1 -0
- package/dist/chunks/useExitOnCtrlCDWithKeybindings-CBce_-hb.js +1 -0
- package/dist/chunks/useExitOnCtrlCDWithKeybindings-CLYjTZXb.js +1 -0
- package/dist/chunks/useKeybinding-DAQL_dB_.js +1 -0
- package/dist/chunks/useMainLoopModel-QC_H3esG.js +1 -0
- package/dist/chunks/useManageMCPConnections-bf-VfJGD.js +1 -0
- package/dist/chunks/useManagePlugins-CXdYUpit.js +1 -0
- package/dist/chunks/useMergedTools-DERzhQOJ.js +1 -0
- package/dist/chunks/useSearchInput-nqhdILI2.js +1 -0
- package/dist/chunks/useTerminalSize-DzV4aaTi.js +1 -0
- package/dist/chunks/useVoice-CO69xtWC.js +1 -0
- package/dist/chunks/util-C8wqPqv0.js +1 -0
- package/dist/chunks/utils-CDFsSXHr.js +1 -0
- package/dist/chunks/utils-ZO5TryVH.js +1 -0
- package/dist/chunks/v4-DLhvDPkt.js +1 -0
- package/dist/chunks/validatePlugin-C4cd71Yz.js +1 -0
- package/dist/chunks/vertex-sdk-CC3U26o7.js +9 -0
- package/dist/chunks/vim-BNiQx5Vf.js +1 -0
- package/dist/chunks/voice-BCbnJzYL.js +8 -0
- package/dist/chunks/voice-BJyz9KZO.js +8 -0
- package/dist/chunks/voice-CP2ULpju.js +2 -0
- package/dist/chunks/voiceModeEnabled-C-pa8B3Q.js +1 -0
- package/dist/chunks/voiceModeEnabled-CMtRN2pa.js +1 -0
- package/dist/chunks/voiceStreamSTT-31b2u0rj.js +1 -0
- package/dist/chunks/voiceStreamSTT-Fkhm6Ftg.js +1 -0
- package/dist/chunks/voiceStreamSTT-sI-hg-aP.js +1 -0
- package/dist/chunks/web-tools-CLmlPgLk.js +1 -0
- package/dist/chunks/which-C0ex-06E.js +1 -0
- package/dist/chunks/windowsPaths-C5TNvKYu.js +1 -0
- package/dist/chunks/windowsPaths-Kue_7s52.js +1 -0
- package/dist/chunks/workSecret-Dh5Ayceu.js +1 -0
- package/dist/chunks/workerRegistry-B5iWYqpK.js +1 -0
- package/dist/chunks/worktree-BypJA0GB.js +1 -0
- package/dist/chunks/worktreeModeEnabled-DPTdK3JV.js +1 -0
- package/dist/chunks/worktreeModeEnabled-Dtrcn7eD.js +1 -0
- package/dist/chunks/wrapper-BDPb4PTV.js +6 -0
- package/dist/chunks/wrapper-DRTs77RK.js +1 -0
- package/dist/chunks/xdg-BaVL-FHd.js +1 -0
- package/dist/chunks/xml-E8VMPwdJ.js +1 -0
- package/dist/chunks/zod-B_P2Eo_D.js +1 -0
- package/dist/cli-bun.js +2 -0
- package/dist/cli-node.js +2 -0
- package/dist/cli.js +2 -0
- package/dist/vendor/audio-capture/arm64-darwin/audio-capture.node +0 -0
- package/dist/vendor/audio-capture/arm64-linux/audio-capture.node +0 -0
- package/dist/vendor/audio-capture/arm64-win32/audio-capture.node +0 -0
- package/dist/vendor/audio-capture/x64-darwin/audio-capture.node +0 -0
- package/dist/vendor/audio-capture/x64-linux/audio-capture.node +0 -0
- package/dist/vendor/audio-capture/x64-win32/audio-capture.node +0 -0
- package/dist/vendor/ripgrep/x64-win32/rg.exe +0 -0
- package/package.json +233 -0
- package/scripts/postinstall.cjs +389 -0
- package/scripts/run-parallel.mjs +10 -0
- package/scripts/setup-chrome-mcp.mjs +70 -0
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import{a as e}from"./chunk-DR8-3Aex.js";import{n as t,t as n}from"./memoize-DNnuA2aU.js";import{c as r,l as i,n as a,s as o,u as s}from"./envUtils-CFG7IQID.js";import{n as c,t as l}from"./defineProperty-CaCI0a5T.js";import{n as u,t as d}from"./axios-Zh7qGPze.js";import{Ln as f,Mn as p,Tt as m,un as h,vt as g,wn as _,wt as ee}from"./schemas-Bwt-7U5W.js";import{B as v,b as te,v as ne}from"./server-XZG51Slr.js";import{t as y}from"./v4-DLhvDPkt.js";import{Tn as b,t as x,wn as re}from"./src-DNHWYkls.js";import{Ht as S,N as C,U as w,W as T,Y as E,at as D,m as ie,mt as ae,t as O,vt as k}from"./state-CUZTq6r0.js";import{$t as oe,$u as se,Ao as ce,As as le,At as A,Au as ue,Bu as j,C as de,D as fe,Ds as M,E as pe,Ei as me,Eo as he,Es as ge,F as _e,Fu as ve,Ga as N,Gs as P,Hl as ye,Ht as be,Hu as F,It as xe,Jr as I,Ka as Se,Kc as L,Ku as R,Ms as Ce,Mt as z,Nt as we,Oc as Te,Oi as Ee,Oo as De,Or as Oe,Ot as ke,Ou as Ae,Pt as je,Pu as Me,Ql as Ne,Qu as Pe,Rt as Fe,Si as Ie,So as Le,T as Re,Tc as ze,Ut as Be,Uu as Ve,Vr as He,Vt as Ue,Vu as B,Wt as We,Xl as Ge,Yi as Ke,_s as qe,ar as Je,au as Ye,du as Xe,ea as Ze,ei as Qe,el as $e,gl as et,h as tt,hn as nt,jt as rt,ki as it,l as at,lc as ot,ln as st,ls as ct,m as lt,nt as ut,pl as dt,qu as ft,sr as pt,wc as mt,wi as ht,wo as gt,xn as _t,xs as vt}from"./growthbook-p4aJ_UMv.js";import{$ as yt,D as bt,E as xt,J as St,K as Ct,O as wt,Q as Tt,U as Et,_ as Dt,h as Ot,l as V,p as H,u as kt,z as U}from"./debug-CjIaNjpK.js";import{n as At,t as jt}from"./cwd-B2guYBbl.js";import{$ as Mt,J as Nt,K as Pt,L as Ft,Q as It,R as Lt,U as Rt,V as zt,f as Bt,j as W,p as Vt,pt as Ht,s as Ut,ut as Wt,y as Gt}from"./state-BQkyHx88.js";import{i as Kt,n as qt}from"./process-CnhUplBr.js";import{M as Jt,N as Yt,j as Xt,v as Zt}from"./git-Bj8Ow4pJ.js";import{G as Qt,_ as $t}from"./privacyLevel-CRCHhztk.js";import{i as en,l as tn,o as G,s as nn}from"./log-DVv8YiNo.js";import{i as rn,n as an}from"./path-uaxlnhva.js";import{s as on,u as sn}from"./types-BVelRhgb.js";import{D as cn,O as ln,b as un,c as dn,d as fn,l as pn,m as mn,s as hn,x as gn}from"./teammate-C-FiRloZ.js";import{d as _n,f as K}from"./stringUtils-U7kMYMJq.js";import{n as vn,r as yn}from"./analytics-i6X1et4O.js";import{y as bn}from"./startupProfiler-4P7GdVw6.js";import{n as xn,t as Sn}from"./lazySchema-2sOku3cX.js";import{l as Cn,u as wn}from"./oauth-DMPGYAoZ.js";import{i as Tn,r as En}from"./permissions-DnpI8Whh.js";import{n as Dn,t as On}from"./sleep-CC8jykQd.js";import{a as kn,i as An}from"./genericProcessUtils-BFJMxLqn.js";import{i as jn,n as Mn,r as q,t as Nn}from"./log-B-Nj3Yed.js";import{$E as Pn,$F as Fn,$I as In,$a as Ln,$b as Rn,$i as zn,$v as Bn,AA as Vn,Ao as Hn,At as Un,Au as Wn,BA as Gn,BF as Kn,Bk as qn,CA as Jn,CC as Yn,CS as Xn,Cb as Zn,Ch as Qn,Cl as $n,Cn as er,Cv as tr,DF as nr,DM as rr,DS as ir,Dn as ar,Do as or,Dv as sr,EA as cr,EM as lr,EP as ur,Ef as dr,Ek as fr,Em as pr,En as mr,Eo as hr,Ev as gr,FM as _r,Fc as vr,Fm as yr,Ft as br,Fu as xr,Fv as Sr,Fy as Cr,G as wr,GC as Tr,GM as Er,GN as Dr,Gd as Or,Gh as kr,Gk as Ar,Gm as jr,Gt as Mr,HM as Nr,HS as Pr,Hc as Fr,Hh as Ir,Hk as J,Hv as Lr,Hx as Rr,I as zr,ID as Br,IM as Vr,Ic as Hr,Ik as Ur,Im as Wr,Iv as Gr,Iy as Kr,JM as qr,Ja as Jr,Jd as Yr,Jj as Xr,Jo as Zr,KC as Qr,KF as $r,KM as ei,KN as ti,Kh as ni,Kj as ri,Kk as ii,Km as ai,Lc as oi,Li as si,Lk as ci,Ln as li,Lt as ui,Ly as di,M as fi,M_ as pi,Mm as mi,Mo as hi,Mv as gi,N_ as _i,Nf as vi,Nm as yi,No as bi,Nr as xi,Ns as Si,Nu as Ci,Nv as wi,O as Ti,Of as Ei,Oi as Di,Om as Oi,Oo as ki,Ov as Ai,Pc as ji,Pf as Mi,Pi as Ni,Pk as Pi,Pm as Fi,Pr as Ii,Pu as Li,QE as Ri,Qb as zi,Qi as Bi,Qn as Vi,RA as Hi,RC as Ui,RM as Wi,Rk as Gi,Rr as Ki,Ry as qi,SA as Ji,SC as Yi,SF as Xi,SM as Zi,SP as Qi,Sh as $i,Sm as Y,Sv as ea,TA as ta,TM as na,TP as ra,Tf as ia,Tk as aa,Tm as oa,To as sa,Tv as ca,U as la,UA as ua,UC as da,UM as fa,Ud as pa,Uh as ma,Uk as ha,Uv as ga,VA as _a,VF as va,VM as ya,VS as ba,Vc as xa,Vd as Sa,Vh as Ca,Vk as wa,Vv as Ta,Vx as Ea,WA as Da,WC as Oa,WF as ka,WM as Aa,Wd as ja,Wh as Ma,Wk as Na,Wt as Pa,X as Fa,XC as Ia,Xm as La,Xr as Ra,Xv as za,YM as Ba,Ya as Va,Yd as Ha,Yv as Ua,Z as Wa,ZC as Ga,Zc as Ka,Zm as qa,Zo as Ja,Zr as Ya,_ as Xa,_C as Za,_L as Qa,_S as $a,_c as eo,_h as to,_i as no,_k as ro,_u as io,aO as ao,ak as oo,al as so,ar as co,aw as lo,ay as uo,bC as fo,bI as po,bP as mo,bS as ho,ba as go,bh as _o,bm as vo,br as yo,bv as bo,cA as xo,cL as So,ch as Co,ck as wo,cw as To,dA as Eo,dL as Do,dM as Oo,dN as ko,dm as Ao,dp as jo,du as Mo,dw as No,eD as Po,eI as Fo,eL as Io,eP as Lo,ew as Ro,ex as zo,ey as Bo,fL as Vo,fM as Ho,fS as Uo,fk as Wo,fp as Go,fr as Ko,fs as qo,fu as Jo,fv as Yo,fx as Xo,gk as Zo,gp as Qo,gu as $o,gx as es,hL as ts,hk as ns,hp as rs,hx as is,iI as as,iP as os,iT as ss,ik as cs,io as ls,iw as us,ix as ds,iy as fs,jF as ps,jc as ms,jm as hs,jo as gs,jt as _s,ju as vs,jv as ys,kA as bs,kM as xs,ko as Ss,kv as Cs,lL as ws,lM as Ts,lc as Es,ld as Ds,lh as Os,lk as ks,lv as As,ly as js,mA as Ms,ma as Ns,mc as Ps,mk as Fs,mu as Is,nM as Ls,nS as Rs,nk as zs,o as Bs,oI as Vs,oO as Hs,ok as Us,ow as Ws,oy as Gs,p as Ks,pA as qs,pM as Js,pS as Ys,pk as Xs,ps as Zs,pu as Qs,qM as $s,qN as ec,rM as tc,rP as nc,rT as rc,ra as ic,rk as ac,rl as oc,rw as sc,s as cc,sA as lc,sd as uc,sk as dc,to as fc,u as pc,uA as mc,uL as hc,uM as gc,uh as _c,uk as vc,um as yc,un as bc,uu as xc,uv as Sc,uy as Cc,v as wc,vC as Tc,vP as Ec,vS as Dc,va as Oc,vi as kc,vl as Ac,w as jc,wA as Mc,wS as Nc,wb as Pc,wl as Fc,wm as Ic,wo as Lc,wr as Rc,wv as zc,xC as Bc,xM as Vc,xc as Hc,xh as Uc,xl as Wc,xm as Gc,xv as Kc,yA as qc,yh as Jc,ys as Yc,yv as Xc,zA as Zc,zM as Qc,zi as $c,zk as el,zn as tl,zy as nl}from"./loadAgentsDir-Bz0FfcVt.js";import{o as X,r as rl}from"./debug-BDBIipC1.js";import{r as il,t as al}from"./slowOperations-niPqC54V.js";import{At as ol,Dt as sl,Et as cl,Gn as ll,Ln as ul,Nt as dl,Ot as fl,P as pl,Rt as ml,Tt as hl,j as gl,jt as _l,mn as vl,nn as yl,pn as bl,tr as xl}from"./prompt-CsBCtw4l.js";import{i as Sl,n as Cl,o as wl,p as Tl,r as El}from"./xml-E8VMPwdJ.js";import{c as Dl,l as Ol}from"./debugUtils-Dsg-UHeg.js";import{H as kl,M as Al,S as jl,T as Ml,U as Nl,r as Pl,s as Fl,v as Il,w as Ll,x as Rl,y as zl}from"./rcDebugLog-BbHlIxCm.js";import{I as Bl,O as Vl,a as Hl,d as Ul}from"./teamHelpers-CTA_CtTT.js";import{a as Wl,i as Gl,o as Kl}from"./fileStateCache-DAsLEZau.js";import{n as ql,t as Jl}from"./cwd-BXiaJzLh.js";import{n as Yl,t as Xl}from"./browser-D1vC3BNd.js";import{a as Zl,n as Ql,o as $l,t as eu}from"./bridgeConfig-GYR-LUiu.js";import{t as tu}from"./pollConfig-C8nODJY1.js";import{a as nu,n as ru,r as iu}from"./mappers-DLkk0PZz.js";import{t as au}from"./controlMessageCompat-591iGHUK.js";import{n as ou,r as su,t as cu}from"./SSETransport-DmZWnH0k.js";import{n as lu,t as uu}from"./HybridTransport-B-G4QJcy.js";import{a as du,i as fu,o as pu}from"./sessionState-Dgky34M4.js";import{t as mu}from"./pluginBlocklist-D6pkKfXr.js";import{t as hu}from"./channelAllowlist-BApjAS0V.js";import{a as gu,s as _u,t as vu}from"./utils-ZO5TryVH.js";import{n as yu,r as bu}from"./outputStyles-hHuIBkRB.js";import{n as xu,t as Su}from"./systemTheme-C1GNqIfy.js";import{t as Cu}from"./types-Bqp3meR4.js";import{n as wu,t as Tu}from"./refresh-Bl3Miver.js";import{i as Eu}from"./goalStorage-CsuPOQbk.js";import{c as Du,i as Ou,n as ku,r as Au,s as ju}from"./sessionRestore-DqsqYK4K.js";import{a as Mu,o as Nu,t as Pu}from"./processUserInput-QAJK0XSn.js";import{d as Fu,f as Iu,g as Lu,h as Ru,i as zu,l as Bu,m as Vu,n as Hu,o as Uu,p as Wu,r as Gu,s as Ku}from"./cronScheduler-zRXhgEEU.js";import{n as qu,r as Ju,t as Yu}from"./MessageSelector-D79Ug71B.js";import{n as Xu,o as Zu}from"./changeDetector-Df7c6U3d.js";import{basename as Qu,dirname as $u,join as ed,relative as td,resolve as Z}from"path";import{PassThrough as nd}from"stream";import{randomUUID as Q}from"crypto";import{mkdir as rd,readFile as id,stat as ad,writeFile as od}from"fs/promises";import{URL as sd}from"url";import{setMaxListeners as cd}from"events";import{cwd as ld}from"process";import{AsyncLocalStorage as ud}from"async_hooks";S(),wn(),ut(),Lo(),qe(),Xt(),Et(),Zt(),ce(),P(),lt(),Bi(),Cu(),n(),o(),c(),y(),x(),Pe(),Me(),At(),Ft(),Dt(),qt(),Qt(),G(),rn(),Ae(),ln(),_n(),Ne(),on(),bn(),ye(),Sn(),Tn(),dt(),$e(),M(),De(),gt(),gn(),Ze(),me(),I(),Oe(),pn(),pt(),nt(),Mn(),We(),xe(),pe(),rl(),ts(),ws(),In(),ll(),ul(),Tl(),Ml(),Fo(),$r(),va(),Vl(),ps(),nr(),yl(),al(),ra(),mo(),nc(),Kl(),ko(),tc(),ql(),Ll(),Ms(),Eo(),ro(),ao(),Ri(),Hl(),us(),fo(),ba(),Rr(),ds(),Ua(),Ta(),gi(),Cs(),gr(),Kc(),Xc(),Wc(),Ka(),ic(),$c(),yo(),mr(),bc(),Fa(),la(),Bs(),wn(),ut(),V(),Et(),po(),ot(),xt(),Bi(),fr(),Xe(),aa();var dd=null;async function fd(){dd&&await dd}zl(),ml(),Da(),Pi(),Oo(),xt(),Ha();var pd=`SandboxNetworkAccess`;function md(e){if(e){if(e.type===`classifier`)return e.reason;switch(e.type){case`rule`:case`mode`:case`subcommandResults`:case`permissionPromptTool`:return;case`hook`:case`asyncAgent`:case`sandboxOverride`:case`workingDir`:case`safetyCheck`:case`other`:return e.reason}}}function hd(e,t,n,r){let i;try{i=e.getActivityDescription?.(t)??e.getToolUseSummary?.(t)??e.userFacingName(t)}catch{i=e.name}return{tool_name:e.name,action_description:i,tool_use_id:n,request_id:r,input:t}}var gd=1e3,_d=class{constructor(e,t){l(this,`structuredInput`,void 0),l(this,`pendingRequests`,new Map),l(this,`restoredWorkerState`,Promise.resolve(null)),l(this,`inputClosed`,!1),l(this,`unexpectedResponseCallback`,void 0),l(this,`resolvedToolUseIds`,new Set),l(this,`prependedLines`,[]),l(this,`onControlRequestSent`,void 0),l(this,`onControlRequestResolved`,void 0),l(this,`outbound`,new Yr),this.input=e,this.replayUserMessages=t,this.input=e,this.structuredInput=this.read()}trackResolvedToolUseId(e){let t=e.request;if(t.subtype===`can_use_tool`&&(this.resolvedToolUseIds.add(t.tool_use_id),this.resolvedToolUseIds.size>gd)){let e=this.resolvedToolUseIds.values().next().value;e!==void 0&&this.resolvedToolUseIds.delete(e)}}flushInternalEvents(){return Promise.resolve()}get internalEventsPending(){return 0}prependUserMessage(e){this.prependedLines.push(il({type:`user`,content:e,uuid:``,session_id:``,message:{role:`user`,content:e},parent_tool_use_id:null})+`
|
|
2
|
+
`)}async*read(){let e=``,t=async function*(){for(;;){this.prependedLines.length>0&&(e=this.prependedLines.join(``)+e,this.prependedLines=[]);let t=e.indexOf(`
|
|
3
|
+
`);if(t===-1)break;let n=e.slice(0,t);e=e.slice(t+1);let r=await this.processLine(n);r&&(Lr(`info`,`cli_stdin_message_parsed`,{type:r.type}),yield r)}}.bind(this);yield*t();for await(let n of this.input)e+=n,yield*t();if(e){let t=await this.processLine(e);t&&(yield t)}this.inputClosed=!0;for(let e of this.pendingRequests.values())e.reject(Error(`Tool permission stream closed before response received`))}getPendingPermissionRequests(){return Array.from(this.pendingRequests.values()).map(e=>e.request).filter(e=>e.request.subtype===`can_use_tool`)}setUnexpectedResponseCallback(e){this.unexpectedResponseCallback=e}injectControlResponse(e){let t=e.response,n=t?.request_id;if(!n)return;let r=this.pendingRequests.get(n);if(r)if(this.trackResolvedToolUseId(r.request),this.pendingRequests.delete(n),this.write({type:`control_cancel_request`,request_id:n}),t.subtype===`error`)r.reject(Error(t.error));else{let e=t.response;if(r.schema)try{r.resolve(r.schema.parse(e))}catch(e){r.reject(e)}else r.resolve({})}}setOnControlRequestSent(e){this.onControlRequestSent=e}setOnControlRequestResolved(e){this.onControlRequestResolved=e}async processLine(e){if(e)try{let t=au(bt(e));if(t.type===`keep_alive`)return;if(t.type===`update_environment_variables`){let e=t.variables??{},n=Object.keys(e);for(let[t,n]of Object.entries(e))process.env[t]=n;X(`[structuredIO] applied update_environment_variables: ${n.join(`, `)}`);return}if(t.type===`control_response`){let e=`uuid`in t&&typeof t.uuid==`string`?t.uuid:void 0;e&&Ho(e,`completed`);let n=t.response,r=this.pendingRequests.get(n.request_id);if(!r){let e=(n.subtype===`success`?n.response:void 0)?.toolUseID;if(typeof e==`string`&&this.resolvedToolUseIds.has(e)){X(`Ignoring duplicate control_response for already-resolved toolUseID=${e} request_id=${n.request_id}`);return}this.unexpectedResponseCallback&&await this.unexpectedResponseCallback(t);return}if(this.trackResolvedToolUseId(r.request),this.pendingRequests.delete(n.request_id),r.request.request.subtype===`can_use_tool`&&this.onControlRequestResolved&&this.onControlRequestResolved(n.request_id),n.subtype===`error`){r.reject(Error(n.error??`Unknown error`));return}let i=n.response;if(r.schema)try{r.resolve(r.schema.parse(i))}catch(e){r.reject(e)}else r.resolve({});return this.replayUserMessages?t:void 0}if(t.type!==`user`&&t.type!==`control_request`&&t.type!==`assistant`&&t.type!==`system`){X(`Ignoring unknown message type: ${t.type}`,{level:`warn`});return}return t.type===`control_request`?(t.request||vd(`Error: Missing request on control_request`),t):(t.type===`assistant`||t.type===`system`||t.message?.role!==`user`&&vd(`Error: Expected message role 'user', got '${t.message?.role}'`),t)}catch(t){console.error(`Error parsing streaming input line: ${e}: ${t}`),process.exit(1)}}async write(e){Gi(Iu(e)+`
|
|
4
|
+
`)}async sendRequest(e,t,n,r=Q()){let i={type:`control_request`,request_id:r,request:e};if(this.inputClosed)throw Error(`Stream closed`);if(n?.aborted)throw Error(`Request aborted`);this.outbound.enqueue(i),e.subtype===`can_use_tool`&&this.onControlRequestSent&&this.onControlRequestSent(i);let a=()=>{this.outbound.enqueue({type:`control_cancel_request`,request_id:r});let e=this.pendingRequests.get(r);e&&(this.trackResolvedToolUseId(e.request),e.reject(new dl))};n&&n.addEventListener(`abort`,a,{once:!0});try{return await new Promise((n,i)=>{this.pendingRequests.set(r,{request:{type:`control_request`,request_id:r,request:e},resolve:e=>{n(e)},reject:i,schema:t})})}finally{n&&n.removeEventListener(`abort`,a),this.pendingRequests.delete(r)}}createCanUseTool(e){return async(t,n,r,i,a,o)=>{let s=o??await ua(t,n,r,i,a);if(s.behavior===`allow`||s.behavior===`deny`)return s;let c=new AbortController,l=r.abortController.signal,u=()=>c.abort();l.addEventListener(`abort`,u,{once:!0});try{let i=yd(t.name,a,n,r,s.suggestions).then(e=>({source:`hook`,decision:e})),o=Q();e?.(hd(t,n,a,o));let l=this.sendRequest({subtype:`can_use_tool`,tool_name:t.name,input:n,permission_suggestions:s.suggestions,blocked_path:s.blockedPath,decision_reason:md(s.decisionReason),tool_use_id:a,agent_id:r.agentId},Wu(),c.signal,o).then(e=>({source:`sdk`,result:e})),u=await Promise.race([i,l]);return u.source===`hook`?u.decision?(l.catch(()=>{}),c.abort(),u.decision):Vu((await l).result,t,n,r):Vu(u.result,t,n,r)}catch(e){return Vu({behavior:`deny`,message:`Tool permission request failed: ${e}`,toolUseID:a},t,n,r)}finally{this.getPendingPermissionRequests().length===0&&fu(`running`),l.removeEventListener(`abort`,u)}}}createHookCallback(e,t){return{type:`callback`,timeout:t,callback:async(t,n,r)=>{try{return await this.sendRequest({subtype:`hook_callback`,callback_id:e,input:t,tool_use_id:n||void 0},Ru(),r)}catch(t){return console.error(`Error in hook callback ${e}:`,t),{}}}}}async handleElicitation(e,t,n,r,i,a,o){try{return await this.sendRequest({subtype:`elicitation`,mcp_server_name:e,message:t,mode:i,url:a,elicitation_id:o,requested_schema:n},Lu(),r)}catch{return{action:`cancel`}}}createSandboxAskCallback(){return async e=>{try{return(await this.sendRequest({subtype:`can_use_tool`,tool_name:pd,input:{host:e.host},tool_use_id:Q(),description:`Allow network connection to ${e.host}?`},Wu())).behavior===`allow`}catch{return!1}}}async sendMcpMessage(e,t){return(await this.sendRequest({subtype:`mcp_message`,server_name:e,message:t},_({mcp_response:ee()}))).mcp_response}};function vd(e){console.error(e),process.exit(1)}async function yd(e,t,n,r,i){let a=r.getAppState().toolPermissionContext.mode,o=ui(e,t,n,r,a,i,r.abortController.signal);for await(let e of o)if(e.permissionRequestResult&&(e.permissionRequestResult.behavior===`allow`||e.permissionRequestResult.behavior===`deny`)){let t=e.permissionRequestResult;if(t.behavior===`allow`){let e=t.updatedInput||n,i=t.updatedPermissions??[];if(i.length>0){Qi(i);let e=Ec(r.getAppState().toolPermissionContext,i);r.setAppState(t=>t.toolPermissionContext===e?t:{...t,toolPermissionContext:e})}return{behavior:`allow`,updatedInput:e,userModified:!1,decisionReason:{type:`hook`,hookName:`PermissionRequest`}}}else return{behavior:`deny`,message:t.message||`Permission denied by PermissionRequest hook`,decisionReason:{type:`hook`,hookName:`PermissionRequest`}}}}function bd(e,t={},n,r){if(s(process.env.CLAUDE_CODE_USE_CCR_V2)){let i=new sd(e.href);return i.protocol===`wss:`?i.protocol=`https:`:i.protocol===`ws:`&&(i.protocol=`http:`),i.pathname=i.pathname.replace(/\/$/,``)+`/worker/events/stream`,new cu(i,t,n,r)}if(e.protocol===`ws:`||e.protocol===`wss:`)return s(process.env.CLAUDE_CODE_POST_FOR_SESSION_INGRESS_V2)?new uu(e,t,n,r):new lu(e,t,n,r);throw Error(`Unsupported protocol: ${e.protocol}`)}S(),Tt(),Oo(),V(),Xt(),o(),Et(),c();var xd=class extends _d{constructor(e,t,n){let r=new nd({encoding:`utf8`});super(r,n),l(this,`url`,void 0),l(this,`transport`,void 0),l(this,`inputStream`,void 0),l(this,`isBridge`,!1),l(this,`isDebug`,!1),l(this,`ccrClient`,null),l(this,`keepAliveTimer`,null),this.inputStream=r,this.url=new sd(e);let i={},a=Il();a?i.Authorization=`Bearer ${a}`:H(`[remote-io] No session ingress token available`,{level:`error`});let o=process.env.CLAUDE_CODE_ENVIRONMENT_RUNNER_VERSION;if(o&&(i[`x-environment-runner-version`]=o),this.transport=bd(this.url,i,D(),()=>{let e={},t=Il();t&&(e.Authorization=`Bearer ${t}`);let n=process.env.CLAUDE_CODE_ENVIRONMENT_RUNNER_VERSION;return n&&(e[`x-environment-runner-version`]=n),e}),this.isBridge=process.env.CLAUDE_CODE_ENVIRONMENT_KIND===`bridge`,this.isDebug=kt(),this.transport.setOnData(e=>{this.inputStream.write(e),this.isBridge&&this.isDebug&&Kt(e.endsWith(`
|
|
5
|
+
`)?e:e+`
|
|
6
|
+
`)}),this.transport.setOnClose(()=>{this.inputStream.end()}),s(process.env.CLAUDE_CODE_USE_CCR_V2)){if(!(this.transport instanceof cu))throw Error(`CCR v2 requires SSETransport; check getTransportForUrl`);this.ccrClient=new ou(this.transport,this.url);let e=this.ccrClient.initialize();this.restoredWorkerState=e.catch(()=>null),e.catch(e=>{Jt(`error`,`cli_worker_lifecycle_init_failed`,{reason:e instanceof su?e.reason:`unknown`}),nn(Error(`CCRClient initialization failed: ${U(e)}`)),ns(1,`other`)}),yt(async()=>this.ccrClient?.close()),kc((e,t,n)=>this.ccrClient.writeInternalEvent(e,t,n)),no(()=>this.ccrClient.readInternalEvents(),()=>this.ccrClient.readSubagentInternalEvents());let t={started:`processing`,completed:`processed`};Js((e,n)=>{this.ccrClient?.reportDelivery(e,t[n])}),pu((e,t)=>{this.ccrClient?.reportState(e,t)}),du(e=>{this.ccrClient?.reportMetadata(e)},{replayCurrent:!0})}this.transport.connect();let c=tu().session_keepalive_interval_v2_ms;if(this.isBridge&&c>0&&(this.keepAliveTimer=setInterval(()=>{H(`[remote-io] keep_alive sent`),this.write({type:`keep_alive`}).catch(e=>{H(`[remote-io] keep_alive write failed: ${U(e)}`)})},c),this.keepAliveTimer.unref?.()),yt(async()=>this.close()),t){let e=this.inputStream;(async()=>{for await(let n of t)e.write(String(n).replace(/\n$/,``)+`
|
|
7
|
+
`)})()}}flushInternalEvents(){return this.ccrClient?.flushInternalEvents()??Promise.resolve()}get internalEventsPending(){return this.ccrClient?.internalEventsPending??0}async write(e){this.ccrClient?await this.ccrClient.writeEvent(e):await this.transport.write(e),this.isBridge&&(e.type===`control_request`||this.isDebug)&&Kt(Iu(e)+`
|
|
8
|
+
`)}close(){this.keepAliveTimer&&(clearInterval(this.keepAliveTimer),this.keepAliveTimer=null),this.transport.close(),this.inputStream.end()}};Ja(),Te(),Bo(),[...Bn],Tt(),V();var Sd=`[stdout-guard]`,Cd=!1,wd=``,Td=null;function Ed(e){if(e.length===0)return!0;try{return JSON.parse(e),!0}catch{return!1}}function Dd(){Cd||(Cd=!0,Td=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`);wd+=r;let i,a=!0;for(;(i=wd.indexOf(`
|
|
9
|
+
`))!==-1;){let e=wd.slice(0,i);wd=wd.slice(i+1),Ed(e)?a=Td(e+`
|
|
10
|
+
`):(process.stderr.write(`${Sd} ${e}\n`),H(`streamJsonStdoutGuard diverted non-JSON stdout line: ${e.slice(0,200)}`))}let o=typeof t==`function`?t:n;return o&&queueMicrotask(()=>o()),a},yt(async()=>{wd.length>0&&(Td&&Ed(wd)?Td(wd+`
|
|
11
|
+
`):process.stderr.write(`${Sd} ${wd}\n`),wd=``),Td&&(process.stdout.write=Td,Td=null),Cd=!1}))}bl(),_l(),ri(),Ei(),F(),xo();var Od=[`subscribe_pr_activity`,`unsubscribe_pr_activity`];function kd(e){return Od.some(t=>e.endsWith(t))}var Ad=(Go(),e(jo));function jd(e){return e.filter(e=>lc.has(e.name)||kd(e.name))}function Md(e,t,n){let[r,i]=Ve(ve([...e,...t],`name`),Hs),a=(e,t)=>e.name.localeCompare(t.name),o=[...i.sort(a),...r.sort(a)];return Ad&&Ad.isCoordinatorMode()?jd(o):o}pr();var Nd=null;function Pd(e,t){Nd?.(e,t)}yi(),S(),ut(),qe(),Et(),G(),Si();function Fd(e){return t=>({...t,...typeof e.permission_mode==`string`?{toolPermissionContext:{...t.toolPermissionContext,mode:et(e.permission_mode)}}:{},...typeof e.is_ultraplan_mode==`boolean`?{isUltraplanMode:e.is_ultraplan_mode}:{}})}S(),No(),G(),Tr(),yo();var Id=(mt(),e(ze)).BRIEF_TOOL_NAME,Ld=(mt(),e(ze)).LEGACY_BRIEF_TOOL_NAME,Rd=(da(),e(Oa)).SEND_USER_FILE_TOOL_NAME;function zd(e){if(e.type!==`attachment`)return e;let t=e.attachment;if(t.type===`new_file`)return{...e,attachment:{...t,type:`file`,displayPath:td(Jl(),t.filename)}};if(t.type===`new_directory`)return{...e,attachment:{...t,type:`directory`,displayPath:td(Jl(),t.path)}};if(!(`displayPath`in t)){let n=`filename`in t?t.filename:`path`in t?t.path:`skillDir`in t?t.skillDir:void 0;if(n)return{...e,attachment:{...t,displayPath:td(Jl(),n)}}}return e}function Bd(e){try{let t=e.map(zd),n=new Set(En);for(let e of t)e.type===`user`&&e.permissionMode!==void 0&&!n.has(e.permissionMode)&&(e.permissionMode=void 0);let r=oi(vr(Hr(t))),i=Vd(r),a;if(i.kind===`interrupted_turn`){let[e]=so([ms({content:`Continue from where you left off.`,isMeta:!0})]);r.push(e),a={kind:`interrupted_prompt`,message:e}}else a=i;let o=r.findLastIndex(e=>e.type!==`system`&&e.type!==`progress`);return o!==-1&&r[o].type===`user`&&r.splice(o+1,0,Hc({content:Es})),{messages:r,turnInterruptionState:a}}catch(e){throw nn(e),e}}function Vd(e){if(e.length===0)return{kind:`none`};let t=e.findLastIndex(e=>e.type!==`system`&&e.type!==`progress`&&!(e.type===`assistant`&&e.isApiErrorMessage)),n=t===-1?void 0:e[t];return!n||n.type===`assistant`?{kind:`none`}:n.type===`user`?n.isMeta||n.isCompactSummary?{kind:`none`}:oc(n)?Hd(n,e,t)?{kind:`none`}:{kind:`interrupted_turn`}:{kind:`interrupted_prompt`,message:n}:n.type===`attachment`?{kind:`interrupted_turn`}:{kind:`none`}}function Hd(e,t,n){let r=e.message.content;if(!Array.isArray(r))return!1;let i=r[0];if(i?.type!==`tool_result`)return!1;let a=i.tool_use_id;for(let e=n-1;e>=0;e--){let n=t[e];if(n.type!==`assistant`)continue;let r=n.message.content;if(Array.isArray(r)){for(let e of r)if(typeof e!=`string`&&`type`in e&&e.type===`tool_use`&&`id`in e&&e.id===a)return(`name`in e?e.name:void 0)===Id||(`name`in e?e.name:void 0)===Ld||(`name`in e?e.name:void 0)===Rd}}return!1}function Ud(e){for(let t of e)if(t.type===`attachment`){if(t.attachment.type===`invoked_skills`){let e=t.attachment.skills;for(let t of e)t.name&&t.path&&t.content&&O(t.name,t.path,t.content,null)}t.attachment.type===`skill_listing`&&Fc()}Fc(),$n()}async function Wd(e){let{messages:t,leafUuids:n}=await Ki(e),r=null,i=0;for(let e of t.values()){if(e.isSidechain||!n.has(e.uuid))continue;let t=new Date(e.timestamp).getTime();t>i&&(i=t,r=e)}return r?{messages:Ya(li(t,r)),sessionId:r.sessionId}:{messages:[],sessionId:void 0}}async function Gd(e,t){try{let n=null,r=null,i;if(e===void 0){let e=Ii(),t=new Set;try{let{listAllLiveSessions:e}=await import(`./udsClient-ClY_0CKr.js`),n=await e();t=new Set(n.flatMap(e=>e.kind&&e.kind!==`interactive`&&e.sessionId?[e.sessionId]:[]))}catch{}n=(await e).find(e=>{let n=Ko(e);return!n||!t.has(n)})??null}else if(t){let e=await Wd(t);r=e.messages,i=e.sessionId}else typeof e==`string`?(n=await co(e),i=e):n=e;if(!n&&!r)return null;n&&(Rc(n)&&(n=await xi(n)),i||(i=Ko(n)),i&&await Xi(n,mc(i)),lo(n),r=n.messages,tl(r)),Ud(r);let a=Bd(r);r=a.messages;let o=await Qr(`resume`,{sessionId:i});return r.push(...o),{messages:r,turnInterruptionState:a.turnInterruptionState,fileHistorySnapshots:n?.fileHistorySnapshots,attributionSnapshots:n?.attributionSnapshots,contentReplacements:n?.contentReplacements,contextCollapseCommits:n?.contextCollapseCommits,contextCollapseSnapshot:n?.contextCollapseSnapshot,sessionId:i,agentName:n?.agentName,agentColor:n?.agentColor,agentSetting:n?.agentSetting,customTitle:n?.customTitle,tag:n?.tag,mode:n?.mode,worktreeSession:n?.worktreeSession,prNumber:n?.prNumber,prUrl:n?.prUrl,prRepository:n?.prRepository,fullPath:n?.fullPath,goal:n?.goal}}catch(e){throw nn(e),e}}Hi(),Ro(),Ia(),gs(),Ln(),Oc(),y(),S(),Sl(),El(),hu();var Kd=xn(()=>_({method:h(`notifications/claude/channel`),params:_({content:f(),meta:p(f(),f()).optional()})})),qd=`notifications/claude/channel/permission`;xn(()=>_({method:h(qd),params:_({request_id:f(),behavior:g([`allow`,`deny`])})}));var Jd=`notifications/claude/channel/permission_request`;xn(()=>_({method:h(Jd),params:_({request_id:f(),tool_name:f(),description:f(),input_preview:f(),channel_context:_({source_server:f().optional(),chat_id:f().optional()}).optional()})}));var Yd=/^[a-zA-Z_][a-zA-Z0-9_]*$/;function Xd(e,t,n){let r=Object.entries(n??{}).filter(([e])=>Yd.test(e)).map(([e,t])=>` ${e}="${Cl(t)}"`).join(``);return`<${$t} source="${Cl(e)}"${r}>\n${t}\n</${$t}>`}function Zd(e,t){let n=e.split(`:`);return t.find(t=>t.kind===`server`?e===t.name:n[0]===`plugin`&&n[1]===t.name)}function Qd(e,t,n){if(!t?.experimental?.[`claude/channel`])return{action:`skip`,kind:`capability`,reason:`server did not declare claude/channel capability`};let r=Zd(e,ie());if(!r)return{action:`skip`,kind:`session`,reason:`server ${e} not in --channels list for this session`};if(r.kind===`plugin`){let e=n?wl(n).marketplace:void 0;if(e!==r.marketplace)return{action:`skip`,kind:`marketplace`,reason:`you asked for plugin:${r.name}@${r.marketplace} but the installed ${r.name} plugin is from ${e??`an unknown source`}`}}return{action:`register`}}y(),Sn(),Sl(),lt();var $d=xn(()=>m(_({marketplace:f(),plugin:f()})));function ef(){let e=at(`tengu_harbor_ledger`,[]),t=$d().safeParse(e);return t.success?t.data:[]}function tf(){return!0}function nf(e){if(!e)return!1;let{name:t,marketplace:n}=wl(e);return n?n===`builtin`&&t===`weixin`?!0:ef().some(e=>e.plugin===t&&e.marketplace===n):!1}Yi(),Za(),Sc(),re(),Qt(),Rs(),ja(),qe(),o(),No(),gc(),Zn(),G(),Ka(),qo(),yo(),Su(),c(),ru(),Jn();var rf=()=>{try{return qu(),e(Yu)}catch{return null}},af=(Go(),e(jo)).getCoordinatorUserContext,of=class{constructor(e){l(this,`config`,void 0),l(this,`mutableMessages`,void 0),l(this,`abortController`,void 0),l(this,`permissionDenials`,void 0),l(this,`totalUsage`,void 0),l(this,`hasHandledOrphanedPermission`,!1),l(this,`readFileState`,void 0),l(this,`discoveredSkillNames`,new Set),l(this,`loadedNestedMemoryPaths`,new Set),this.config=e,this.mutableMessages=e.initialMessages??[],this.abortController=e.abortController??Ls(),this.permissionDenials=[],this.readFileState=e.readFileCache,this.totalUsage=Nl}async*submitMessage(e,t){let{cwd:n,commands:i,tools:a,mcpClients:o,verbose:c=!1,thinkingConfig:l,maxTurns:u,maxBudgetUsd:d,taskBudget:f,canUseTool:p,customSystemPrompt:m,appendSystemPrompt:h,userSpecifiedModel:g,fallbackModel:_,jsonSchema:ee,getAppState:v,setAppState:te,replayUserMessages:ne=!1,includePartialMessages:y=!1,agents:x=[],setSDKStatus:re,orphanedPermission:S}=this.config;this.discoveredSkillNames.clear(),this.permissionDenials=[],Zs(n);let C=!Lt(),w=Date.now(),E=async(e,t,n,r,i,a)=>{let o=await p(e,t,n,r,i,a);return o.behavior!==`allow`&&this.permissionDenials.push({type:`permission_denial`,tool_name:Nu(e.name),tool_use_id:i,tool_input:t}),o},D=v(),ie=g?Qe(g):He(),O=l||(Qa()===!1?{type:`disabled`}:{type:`adaptive`});Ts(`before_getSystemPrompt`);let oe=typeof m==`string`?m:void 0,{defaultSystemPrompt:ce,userContext:le,systemContext:A}=await Ju({tools:a,mainLoopModel:ie,additionalWorkingDirectories:Array.from(D.toolPermissionContext.additionalWorkingDirectories.keys()),mcpClients:o,customSystemPrompt:oe});Ts(`after_getSystemPrompt`);let ue={...le,...af(o,ar()?er():void 0)},j=oe!==void 0&&ge()?await os():null,de=kl([...oe===void 0?ce:[oe],...j?[j]:[],...h?[h]:[]]),fe=a.some(e=>Io(e,fl));ee&&fe&&Pc(te,W());let M={messages:this.mutableMessages,setMessages:e=>{this.mutableMessages=e(this.mutableMessages)},onChangeAPIKey:()=>{},handleElicitation:this.config.handleElicitation,options:{commands:i,debug:!1,tools:a,verbose:c,mainLoopModel:ie,thinkingConfig:O,mcpClients:o,mcpResources:{},ideInstallationStatus:null,isNonInteractiveSession:!0,customSystemPrompt:m,appendSystemPrompt:h,agentDefinitions:{activeAgents:x,allAgents:[]},theme:xu(ct().theme),maxBudgetUsd:d},getAppState:v,setAppState:te,abortController:this.abortController,readFileState:this.readFileState,nestedMemoryAttachmentTriggers:new Set,loadedNestedMemoryPaths:this.loadedNestedMemoryPaths,dynamicSkillDirTriggers:new Set,discoveredSkillNames:this.discoveredSkillNames,setInProgressToolUseIDs:()=>{},setResponseLength:()=>{},updateFileHistoryState:e=>{te(t=>{let n=e(t.fileHistory);return n===t.fileHistory?t:{...t,fileHistory:n}})},updateAttributionState:e=>{te(t=>{let n=e(t.attribution);return n===t.attribution?t:{...t,attribution:n}})},setSDKStatus:re};if(S&&!this.hasHandledOrphanedPermission){this.hasHandledOrphanedPermission=!0;for await(let e of Ji(S,a,this.mutableMessages,M))yield e}let{messages:pe,shouldQuery:me,allowedTools:he,model:_e,resultText:ve}=await Pu({input:e,mode:`prompt`,setToolJSX:()=>{},context:{...M,messages:this.mutableMessages},messages:this.mutableMessages,uuid:t?.uuid,isMeta:t?.isMeta,querySource:`sdk`});this.mutableMessages.push(...pe);let N=[...this.mutableMessages];if(C&&pe.length>0){let e=Ra(N);r()||(await e,(s(process.env.CLAUDE_CODE_EAGER_FLUSH)||s(process.env.CLAUDE_CODE_IS_COWORK))&&await Vi())}let P=rf(),ye=pe.filter(e=>e.type===`user`&&!e.isMeta&&!e.toolUseResult&&(P?.selectableUserMessagesFilter(e)??!0)||e.type===`system`&&e.subtype===`compact_boundary`),be=ne?ye:[];te(e=>({...e,toolPermissionContext:{...e.toolPermissionContext,alwaysAllowRules:{...e.toolPermissionContext.alwaysAllowRules,command:he}}}));let F=_e??ie;M={messages:N,setMessages:()=>{},onChangeAPIKey:()=>{},handleElicitation:this.config.handleElicitation,options:{commands:i,debug:!1,tools:a,verbose:c,mainLoopModel:F,thinkingConfig:O,mcpClients:o,mcpResources:{},ideInstallationStatus:null,isNonInteractiveSession:!0,customSystemPrompt:m,appendSystemPrompt:h,theme:xu(ct().theme),agentDefinitions:{activeAgents:x,allAgents:[]},maxBudgetUsd:d},getAppState:v,setAppState:te,abortController:this.abortController,readFileState:this.readFileState,nestedMemoryAttachmentTriggers:new Set,loadedNestedMemoryPaths:this.loadedNestedMemoryPaths,dynamicSkillDirTriggers:new Set,discoveredSkillNames:this.discoveredSkillNames,setInProgressToolUseIDs:()=>{},setResponseLength:()=>{},updateFileHistoryState:M.updateFileHistoryState,updateAttributionState:M.updateAttributionState,setSDKStatus:re},Ts(`before_skills_plugins`);let[xe,{enabled:I}]=await Promise.all([si(jt()),go()]);if(Ts(`after_skills_plugins`),yield Mu({tools:a,mcpClients:o,model:F,permissionMode:D.toolPermissionContext.mode,commands:i,agents:x,skills:xe,plugins:I,fastMode:D.fastMode}),Ts(`system_message_yielded`),!me){for(let e of pe)if(e.type===`user`&&typeof e.message.content==`string`&&(e.message.content.includes(`<local-command-stdout>`)||e.message.content.includes(`<local-command-stderr>`)||e.isCompactSummary)&&(yield{type:`user`,message:{...e.message,content:b(e.message.content)},session_id:W(),parent_tool_use_id:null,uuid:e.uuid,timestamp:e.timestamp,isReplay:!e.isCompactSummary,isSynthetic:e.isMeta||e.isVisibleInTranscriptOnly}),e.type===`system`&&e.subtype===`local_command`&&typeof e.content==`string`&&(e.content.includes(`<local-command-stdout>`)||e.content.includes(`<local-command-stderr>`))&&(yield iu(e.content,e.uuid)),e.type===`system`&&e.subtype===`compact_boundary`){let t=e;yield{type:`system`,subtype:`compact_boundary`,session_id:W(),uuid:e.uuid,compact_metadata:nu(t.compactMetadata)}}C&&(await Ra(N),(s(process.env.CLAUDE_CODE_EAGER_FLUSH)||s(process.env.CLAUDE_CODE_IS_COWORK))&&await Vi()),yield{type:`result`,subtype:`success`,is_error:!1,duration_ms:Date.now()-w,duration_api_ms:ae(),num_turns:N.length-1,result:ve??``,stop_reason:null,session_id:W(),total_cost_usd:k(),usage:this.totalUsage,modelUsage:T(),permission_denials:this.permissionDenials,fast_mode_state:Ke(F,D.fastMode),uuid:Q()};return}if(Ws()&&C){let e=rf()?.selectableUserMessagesFilter??(e=>!0);pe.filter(e).forEach(e=>{To(e=>{te(t=>({...t,fileHistory:e(t.fileHistory)}))},e.uuid)})}let Se=Nl,L=1,R=!1,Ce,z=null,we=en().at(-1),Te=ee?eo(this.mutableMessages,fl):0;for await(let e of Or({messages:N,systemPrompt:de,userContext:ue,systemContext:A,canUseTool:E,toolUseContext:M,fallbackModel:_,querySource:`sdk`,maxTurns:u,taskBudget:f})){if(e.type===`assistant`||e.type===`user`||e.type===`system`&&e.subtype===`compact_boundary`){if(C&&e.type===`system`&&e.subtype===`compact_boundary`){let t=e.compactMetadata?.preservedSegment?.tailUuid;if(t){let e=this.mutableMessages.findLastIndex(e=>e.uuid===t);e!==-1&&await Ra(this.mutableMessages.slice(0,e+1))}}if(N.push(e),C&&(e.type===`assistant`?Ra(N):await Ra(N)),!R&&be.length>0){R=!0;for(let e of be)e.type===`user`&&(yield{type:`user`,message:e.message,session_id:W(),parent_tool_use_id:null,uuid:e.uuid,timestamp:e.timestamp,isReplay:!0})}}switch(e.type===`user`&&L++,e.type){case`tombstone`:break;case`assistant`:{let t=e,n=t.message?.stop_reason;n!=null&&(z=n),this.mutableMessages.push(t),yield*ta(t);break}case`progress`:{let t=e;this.mutableMessages.push(t),C&&(N.push(t),Ra(N)),yield*ta(t);break}case`user`:{let t=e;this.mutableMessages.push(t),yield*ta(t);break}case`stream_event`:{let t=e.event;if(t.type===`message_start`){Se=Nl;let e=t.message;Se=Yo(Se,e.usage)}if(t.type===`message_delta`){Se=Yo(Se,t.usage);let e=t.delta;e.stop_reason!=null&&(z=e.stop_reason)}t.type===`message_stop`&&(this.totalUsage=As(this.totalUsage,Se)),y&&(yield{type:`stream_event`,event:t,session_id:W(),parent_tool_use_id:null,uuid:Q()});break}case`attachment`:{let t=e;this.mutableMessages.push(t),C&&(N.push(t),Ra(N));let n=t.attachment;if(n.type===`structured_output`)Ce=n.data;else if(n.type===`max_turns_reached`){C&&(s(process.env.CLAUDE_CODE_EAGER_FLUSH)||s(process.env.CLAUDE_CODE_IS_COWORK))&&await Vi(),yield{type:`result`,subtype:`error_max_turns`,duration_ms:Date.now()-w,duration_api_ms:ae(),is_error:!0,num_turns:n.turnCount,stop_reason:z,session_id:W(),total_cost_usd:k(),usage:this.totalUsage,modelUsage:T(),permission_denials:this.permissionDenials,fast_mode_state:Ke(F,D.fastMode),uuid:Q(),errors:[`Reached maximum number of turns (${n.maxTurns})`]};return}else ne&&n.type===`queued_command`&&(yield{type:`user`,message:{role:`user`,content:n.prompt},session_id:W(),parent_tool_use_id:null,uuid:n.source_uuid||t.uuid,timestamp:t.timestamp,isReplay:!0});break}case`stream_request_start`:break;case`system`:{let t=e,n=this.config.snipReplay?.(t,this.mutableMessages);if(n!==void 0){n.executed&&(this.mutableMessages.length=0,this.mutableMessages.push(...n.messages));break}if(this.mutableMessages.push(t),t.subtype===`compact_boundary`&&t.compactMetadata){let e=t,n=this.mutableMessages.length-1;n>0&&this.mutableMessages.splice(0,n);let r=N.length-1;r>0&&N.splice(0,r),yield{type:`system`,subtype:`compact_boundary`,session_id:W(),uuid:t.uuid,compact_metadata:nu(e.compactMetadata)}}if(t.subtype===`api_error`){let e=t;yield{type:`system`,subtype:`api_retry`,attempt:e.retryAttempt,max_retries:e.maxRetries,retry_delay_ms:e.retryInMs,error_status:e.error.status??null,error:Kn(e.error),session_id:W(),uuid:t.uuid}}break}case`tool_use_summary`:{let t=e;yield{type:`tool_use_summary`,summary:t.summary,preceding_tool_use_ids:t.precedingToolUseIds,session_id:W(),uuid:t.uuid};break}}if(d!==void 0&&k()>=d){C&&(s(process.env.CLAUDE_CODE_EAGER_FLUSH)||s(process.env.CLAUDE_CODE_IS_COWORK))&&await Vi(),yield{type:`result`,subtype:`error_max_budget_usd`,duration_ms:Date.now()-w,duration_api_ms:ae(),is_error:!0,num_turns:L,stop_reason:z,session_id:W(),total_cost_usd:k(),usage:this.totalUsage,modelUsage:T(),permission_denials:this.permissionDenials,fast_mode_state:Ke(F,D.fastMode),uuid:Q(),errors:[`Reached maximum budget ($${d}). Increase the limit with --max-budget-usd or start a new session.`]};return}if(e.type===`user`&&ee){let e=eo(this.mutableMessages,fl)-Te,t=parseInt(process.env.MAX_STRUCTURED_OUTPUT_RETRIES||`5`,10);if(e>=t){C&&(s(process.env.CLAUDE_CODE_EAGER_FLUSH)||s(process.env.CLAUDE_CODE_IS_COWORK))&&await Vi(),yield{type:`result`,subtype:`error_max_structured_output_retries`,duration_ms:Date.now()-w,duration_api_ms:ae(),is_error:!0,num_turns:L,stop_reason:z,session_id:W(),total_cost_usd:k(),usage:this.totalUsage,modelUsage:T(),permission_denials:this.permissionDenials,fast_mode_state:Ke(F,D.fastMode),uuid:Q(),errors:[`Failed to provide valid structured output after ${t} attempts`]};return}}}let Ee=N.findLast(e=>e.type===`assistant`||e.type===`user`),De=Ee?.type??`undefined`,Oe=Ee?.type===`assistant`?se(Ee.message.content)?.type??`none`:`n/a`;if(C&&(s(process.env.CLAUDE_CODE_EAGER_FLUSH)||s(process.env.CLAUDE_CODE_IS_COWORK))&&await Vi(),!Mc(Ee,z)){yield{type:`result`,subtype:`error_during_execution`,duration_ms:Date.now()-w,duration_api_ms:ae(),is_error:!0,num_turns:L,stop_reason:z,session_id:W(),total_cost_usd:k(),usage:this.totalUsage,modelUsage:T(),permission_denials:this.permissionDenials,fast_mode_state:Ke(F,D.fastMode),uuid:Q(),errors:(()=>{let e=en(),t=we?e.lastIndexOf(we)+1:0;return[`[ede_diagnostic] result_type=${De} last_content_type=${Oe} stop_reason=${z}`,...e.slice(t).map(e=>e.error)]})()};return}let ke=``,Ae=!1;if(Ee.type===`assistant`){let e=se(Ee.message.content);e?.type===`text`&&!Ps.has(e.text)&&(ke=e.text),Ae=!!Ee.isApiErrorMessage}yield{type:`result`,subtype:`success`,is_error:Ae,duration_ms:Date.now()-w,duration_api_ms:ae(),num_turns:L,result:ke,stop_reason:z,session_id:W(),total_cost_usd:k(),usage:this.totalUsage,modelUsage:T(),permission_denials:this.permissionDenials,structured_output:Ce,fast_mode_state:Ke(F,D.fastMode),uuid:Q()}}interrupt(){this.abortController.abort()}resetAbortController(){this.abortController=Ls()}getAbortSignal(){return this.abortController.signal}getMessages(){return this.mutableMessages}getReadFileState(){return this.readFileState}getSessionId(){return W()}setModel(e){this.config.userSpecifiedModel=e}};async function*sf({commands:e,prompt:t,promptUuid:n,isMeta:r,cwd:i,tools:a,mcpClients:o,verbose:s=!1,thinkingConfig:c,maxTurns:l,maxBudgetUsd:u,taskBudget:d,canUseTool:f,mutableMessages:p=[],getReadFileCache:m,setReadFileCache:h,customSystemPrompt:g,appendSystemPrompt:_,userSpecifiedModel:ee,fallbackModel:v,jsonSchema:te,getAppState:ne,setAppState:y,abortController:b,replayUserMessages:x=!1,includePartialMessages:re=!1,handleElicitation:S,agents:C=[],setSDKStatus:w,orphanedPermission:T}){let E=new of({cwd:i,tools:a,commands:e,mcpClients:o,agents:C??[],canUseTool:f,getAppState:ne,setAppState:y,initialMessages:p,readFileCache:Gl(m()),customSystemPrompt:g,appendSystemPrompt:_,userSpecifiedModel:ee,fallbackModel:v,thinkingConfig:c,maxTurns:l,maxBudgetUsd:u,taskBudget:d,jsonSchema:te,verbose:s,handleElicitation:S,replayUserMessages:x,includePartialMessages:re,setSDKStatus:w,abortController:b,orphanedPermission:T});try{yield*E.submitMessage(t,{uuid:n,isMeta:r})}finally{h(E.getReadFileState())}}Vn(),Rn(),Ft(),cr(),xl(),ll(),ul(),V(),o(),Et(),Kl(),Ka(),yo();var cf=10;function lf(e){return typeof e==`string`?e:e==null?``:typeof e==`object`?JSON.stringify(e):String(e)}function uf(e,t,n=cf){let r=Wl(n),i=new Map,a=new Map,o=new Map;for(let n of e)if(n.type===`assistant`&&Array.isArray(n.message.content)){for(let e of n.message.content)if(e.type===`tool_use`&&e.name===`Read`){let n=e.input;if(n?.file_path&&n?.offset===void 0&&n?.limit===void 0){let r=an(n.file_path,t);i.set(e.id,r)}}else if(e.type===`tool_use`&&e.name===`Write`){let n=e.input;if(n?.file_path&&n.content!==void 0&&n.content!==null){let r=an(n.file_path,t);a.set(e.id,{filePath:r,content:lf(n.content)})}}else if(e.type===`tool_use`&&e.name===`Edit`){let n=e.input;if(n?.file_path){let r=an(n.file_path,t);o.set(e.id,r)}}}for(let t of e)if(t.type===`user`&&Array.isArray(t.message.content)){for(let e of t.message.content)if(e.type===`tool_result`&&e.tool_use_id){let n=i.get(e.tool_use_id);if(n&&typeof e.content==`string`&&!e.content.startsWith(`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.`)){let i=e.content.replace(/<system-reminder>[\s\S]*?<\/system-reminder>/g,``).split(`
|
|
12
|
+
`).map(Ye).join(`
|
|
13
|
+
`).trim();if(t.timestamp){let e=new Date(t.timestamp).getTime();r.set(n,{content:i,timestamp:e,offset:void 0,limit:void 0})}}let s=a.get(e.tool_use_id);if(s&&t.timestamp){let e=new Date(t.timestamp).getTime();r.set(s.filePath,{content:s.content,timestamp:e,offset:void 0,limit:void 0})}let c=o.get(e.tool_use_id);if(c&&e.is_error!==!0)try{let{content:e}=ue(c);r.set(c,{content:e,timestamp:Ge(c),offset:void 0,limit:void 0})}catch(e){if(!Ct(e))throw e}}}return r}Ui(),At(),Et(),G(),zl(),V(),xt();var df=new Map;async function ff(e,t,n){e.stopProgressInterval();let r=e.shellCommand?.taskOutput,i=r?await r.getStdout():``,a=r?.getStderr()??``;e.shellCommand?.cleanup(),Ea({hookId:e.hookId,hookName:e.hookName,hookEvent:e.hookEvent,output:i+a,stdout:i,stderr:a,exitCode:t,outcome:n})}async function pf(){let e=Array.from(df.values());await Promise.all(e.map(async e=>{if(e.shellCommand?.status===`completed`){let t=await e.shellCommand.result;await ff(e,t.code,t.code===0?`success`:`error`)}else e.shellCommand&&e.shellCommand.status!==`killed`&&e.shellCommand.kill(),await ff(e,1,`cancelled`)})),df.clear()}ha(),V(),ro();function mf(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&&(H(`Exiting after ${n}ms of idle time`),Zo())},n))},stop(){i&&(clearTimeout(i),i=null)}}}R(),j(),Ar();var hf=`https://claude.ai`,gf=`https://claude-ai.staging.ant.dev`,_f=`http://localhost:4000`;function vf(e,t){return e?.includes(`_staging_`)===!0||t?.includes(`staging`)===!0}function yf(e,t){return e?.includes(`_local_`)===!0||t?.includes(`localhost`)===!0}function bf(e,t){if(yf(e,t)){if(t)try{return new URL(t).origin}catch{}return _f}return vf(e,t)?gf:hf}function xf(t,n){let{toCompatSessionId:r}=(Dl(),e(Ol)),i=r(t),a=process.env.CLAUDE_BRIDGE_BASE_URL;return a?`${a.replace(/\/+$/,``)}/code/${i}`:`${bf(i,n)}/code/${i}`}Vs(),Zl();function Sf(e,t){return`${$l()?Ql():as(void 0,t)}/code?bridge=${e}`}function Cf(e){if(e.type!==`user`)return;let t=e.message?.content;if(!t||Array.isArray(t)&&t.length===0)return;let n=`uuid`in e&&typeof e.uuid==`string`?e.uuid:void 0;return{content:Array.isArray(t)?wf(t):t,uuid:n}}function wf(e){return e.some(Tf)?e.map(e=>{if(!Tf(e))return e;let t=e.source,n=typeof t.mediaType==`string`&&t.mediaType?t.mediaType:Fn(e.source.data);return{...e,source:{type:`base64`,media_type:n,data:e.source.data}}}):e}function Tf(e){return e.type!==`image`||e.source?.type!==`base64`?!1:!e.source.media_type}d(),y(),S(),V(),o(),Sn(),Zl();var Ef=3e4;function Df(e){H(`[bridge:inbound-attach] ${e}`)}var Of=xn(()=>_({file_uuid:f(),file_name:f()})),kf=xn(()=>m(Of()));function Af(e){if(typeof e!=`object`||!e||!(`file_attachments`in e))return[];let t=kf().safeParse(e.file_attachments);return t.success?t.data:[]}function jf(e){return Qu(e).replace(/[^a-zA-Z0-9._-]/g,`_`)||`attachment`}function Mf(){return ed(a(),`uploads`,D())}async function Nf(e){let t=eu();if(!t){Df(`skip: no oauth token`);return}let n;try{let r=`${Ql()}/api/oauth/files/${encodeURIComponent(e.file_uuid)}/content`,i=await u.get(r,{headers:{Authorization:`Bearer ${t}`},responseType:`arraybuffer`,timeout:Ef,validateStatus:()=>!0});if(i.status!==200){Df(`fetch ${e.file_uuid} failed: status=${i.status}`);return}n=Buffer.from(i.data)}catch(t){Df(`fetch ${e.file_uuid} threw: ${t}`);return}let r=jf(e.file_name),i=(e.file_uuid.slice(0,8)||Q().slice(0,8)).replace(/[^a-zA-Z0-9_-]/g,`_`),a=Mf(),o=ed(a,`${i}-${r}`);try{await rd(a,{recursive:!0}),await od(o,n)}catch(e){Df(`write ${o} failed: ${e}`);return}return Df(`resolved ${e.file_uuid} → ${o} (${n.length} bytes)`),o}async function Pf(e){if(e.length===0)return``;Df(`resolving ${e.length} attachment(s)`);let t=(await Promise.all(e.map(Nf))).filter(e=>e!==void 0);return t.length===0?``:t.map(e=>`@"${e}"`).join(` `)+` `}function Ff(e,t){if(!t)return e;if(typeof e==`string`)return t+e;let n=e.findLastIndex(e=>e.type===`text`);if(n!==-1){let r=e[n];if(r.type===`text`)return[...e.slice(0,n),{...r,text:t+r.text},...e.slice(n+1)]}return[...e,{type:`text`,text:t.trimEnd()}]}async function If(e,t){let n=Af(e);return n.length===0?t:Ff(t,await Pf(n))}js();var Lf=50;function Rf(e=Lf){let t=new AbortController;return cd(e,t.signal),t}tc();function zf(e,t){let{signalB:n,timeoutMs:r}=t??{},i=Ls();if(e?.aborted||n?.aborted)return i.abort(),{signal:i.signal,cleanup:()=>{}};let a,o=()=>{a!==void 0&&clearTimeout(a),i.abort()};return r!==void 0&&(a=setTimeout(o,r),a.unref?.()),e?.addEventListener(`abort`,o),n?.addEventListener(`abort`,o),{signal:i.signal,cleanup:()=>{a!==void 0&&clearTimeout(a),e?.removeEventListener(`abort`,o),n?.removeEventListener(`abort`,o)}}}y(),S(),vn(),V(),Sn(),Ka(),ko();var Bf=`Generate a concise, sentence-case title (3-7 words) that captures the main topic or goal of this coding session. The title should be clear enough that the user recognizes the session in a list. Use sentence case: capitalize only the first word and proper nouns.
|
|
14
|
+
|
|
15
|
+
Return JSON with a single "title" field.
|
|
16
|
+
|
|
17
|
+
Good examples:
|
|
18
|
+
{"title": "Fix login button on mobile"}
|
|
19
|
+
{"title": "Add OAuth authentication"}
|
|
20
|
+
{"title": "Debug failing CI tests"}
|
|
21
|
+
{"title": "Refactor API client error handling"}
|
|
22
|
+
|
|
23
|
+
Bad (too vague): {"title": "Code changes"}
|
|
24
|
+
Bad (too long): {"title": "Investigate and fix the issue where the login button does not respond on mobile devices"}
|
|
25
|
+
Bad (wrong case): {"title": "Fix Login Button On Mobile"}`,Vf=xn(()=>_({title:f()}));async function Hf(e,t){let n=e.trim();if(!n)return null;try{let e=ji((await Wa({systemPrompt:kl([Bf]),userPrompt:n,outputFormat:{type:`json_schema`,schema:{type:`object`,properties:{title:{type:`string`}},required:[`title`],additionalProperties:!1}},signal:t,options:{querySource:`generate_session_title`,agents:[],isNonInteractiveSession:C(),hasAppendSystemPrompt:!1,mcpTools:[]}})).message.content),r=Vf().safeParse(sn(e)),i=r.success&&r.data.title.trim()||null;return yn(`tengu_session_title_generated`,{success:i!==null}),i}catch(e){return H(`generateSessionTitle failed: ${e}`,{level:`error`}),yn(`tengu_session_title_generated`,{success:!1}),null}}Ao(),ec(),tc(),I(),ko(),ts();async function Uf({tools:e,mainLoopModel:t,additionalWorkingDirectories:n,mcpClients:r,customSystemPrompt:i}){let[a,o,s]=await Promise.all([i===void 0?yc(e,t,n,r):Promise.resolve([]),ti(),i===void 0?Dr():Promise.resolve({})]);return{defaultSystemPrompt:a,userContext:o,systemContext:s}}async function Wf({tools:e,commands:t,mcpClients:n,messages:r,readFileState:i,getAppState:a,setAppState:o,customSystemPrompt:s,appendSystemPrompt:c,thinkingConfig:l,agents:u}){let d=He(),f=a(),{defaultSystemPrompt:p,userContext:m,systemContext:h}=await Uf({tools:e,mainLoopModel:d,additionalWorkingDirectories:Array.from(f.toolPermissionContext.additionalWorkingDirectories.keys()),mcpClients:n,customSystemPrompt:s}),g=kl([...s===void 0?p:[s],...c?[c]:[]]),_=r.at(-1),ee=_?.type===`assistant`&&_.message.stop_reason===null?r.slice(0,-1):r;return{systemPrompt:g,userContext:m,systemContext:h,toolUseContext:{options:{commands:t,debug:!1,mainLoopModel:d,tools:e,verbose:!1,thinkingConfig:l??(Qa()===!1?{type:`disabled`}:{type:`adaptive`}),mcpClients:n,mcpResources:{},isNonInteractiveSession:!0,agentDefinitions:{activeAgents:u,allAgents:[]},customSystemPrompt:s,appendSystemPrompt:c},abortController:Ls(),readFileState:i,getAppState:a,setAppState:o,messages:ee,setInProgressToolUseIDs:()=>{},setResponseLength:()=>{},updateFileHistoryState:()=>{},updateAttributionState:()=>{}},forkContextMessages:ee}}Ml(),Sa(),Ka();async function Gf({question:e,cacheSafeParams:t}){let n=await pa({promptMessages:[ms({content:`<system-reminder>This is a side question from the user. You must answer this question directly in a single response.
|
|
26
|
+
|
|
27
|
+
IMPORTANT CONTEXT:
|
|
28
|
+
- You are a separate, lightweight agent spawned to answer this one question
|
|
29
|
+
- The main agent is NOT interrupted - it continues working independently in the background
|
|
30
|
+
- You share the conversation context but are a completely separate instance
|
|
31
|
+
- Do NOT reference being interrupted or what you were "previously doing" - that framing is incorrect
|
|
32
|
+
|
|
33
|
+
CRITICAL CONSTRAINTS:
|
|
34
|
+
- You have NO tools available - you cannot read files, run commands, search, or take any actions
|
|
35
|
+
- This is a one-off response - there will be no follow-up turns
|
|
36
|
+
- You can ONLY provide information based on what you already know from the conversation context
|
|
37
|
+
- NEVER say things like "Let me try...", "I'll now...", "Let me check...", or promise to take any action
|
|
38
|
+
- If you don't know the answer, say so - do not offer to look it up or investigate
|
|
39
|
+
|
|
40
|
+
Simply answer the question with the information you have.</system-reminder>
|
|
41
|
+
|
|
42
|
+
${e}`})],cacheSafeParams:t,canUseTool:async()=>({behavior:`deny`,message:`Side questions cannot use tools`,decisionReason:{type:`other`,reason:`side_question`}}),querySource:`side_question`,forkLabel:`side_question`,maxTurns:1,skipCacheWrite:!0});return{response:Kf(n.messages),usage:n.totalUsage}}function Kf(e){let t=e.flatMap(e=>e.type===`assistant`?e.message.content:[]);if(t.length>0){let e=ji(t,`
|
|
43
|
+
|
|
44
|
+
`).trim();if(e)return e;let n=t.find(e=>e.type===`tool_use`);if(n)return`(The model tried to call ${`name`in n?n.name:`a tool`} instead of answering directly. Try rephrasing or ask in the main conversation.)`}let n=e.find(e=>e.type===`system`&&`subtype`in e&&e.subtype===`api_error`);return n?`(API error: ${Al(n.error)})`:null}jc(),S(),Wc(),V(),Xt(),o(),bc(),G();var qf;function Jf(){let e=qf;return qf=void 0,e}async function Yf(e,{sessionId:t,agentType:n,model:i,forceSyncExecution:a}={}){if(r())return[];let o=[],s=[],c=[];if(Pn())H(`Skipping plugin hooks - allowManagedHooksOnly is enabled`);else try{await Yt(`load_plugin_hooks`,()=>Ga())}catch(t){let n=t instanceof Error?Error(`Failed to load plugin hooks during ${e}: ${t.message}`):Error(`Failed to load plugin hooks during ${e}: ${String(t)}`);t instanceof Error&&t.stack&&(n.stack=t.stack),nn(n);let r=t instanceof Error?t.message:String(t),i=``;i=r.includes(`Failed to clone`)||r.includes(`network`)||r.includes(`ETIMEDOUT`)||r.includes(`ENOTFOUND`)?`This appears to be a network issue. Check your internet connection and try again.`:r.includes(`Permission denied`)||r.includes(`EACCES`)||r.includes(`EPERM`)?`This appears to be a permissions issue. Check file permissions on ~/.claude/plugins/`:r.includes(`Invalid`)||r.includes(`parse`)||r.includes(`JSON`)||r.includes(`schema`)?`This appears to be a configuration issue. Check your plugin settings in .claude/settings.json`:`Please fix the plugin configuration or remove problematic plugins from your settings.`,H(`Warning: Failed to load plugin hooks. SessionStart hooks from plugins will not execute. Error: ${r}. ${i}`,{level:`warn`})}let l=n??w();for await(let n of Pa(e,t,l,i,void 0,void 0,a))n.message&&o.push(n.message),n.additionalContexts&&n.additionalContexts.length>0&&s.push(...n.additionalContexts),n.initialUserMessage&&(qf=n.initialUserMessage),n.watchPaths&&n.watchPaths.length>0&&c.push(...n.watchPaths);if(c.length>0&&sc(c),s.length>0){let e=Ac({type:`hook_additional_context`,content:s,hookName:`SessionStart`,toolUseID:`SessionStart`,hookEvent:`SessionStart`});o.push(e)}return o}async function Xf(e,{forceSyncExecution:t}={}){if(r())return[];let n=[],i=[];if(Pn())H(`Skipping plugin hooks - allowManagedHooksOnly is enabled`);else try{await Ga()}catch(e){H(`Warning: Failed to load plugin hooks. Setup hooks from plugins will not execute. Error: ${e instanceof Error?e.message:String(e)}`,{level:`warn`})}for await(let r of Mr(e,void 0,void 0,t))r.message&&n.push(r.message),r.additionalContexts&&r.additionalContexts.length>0&&i.push(...r.additionalContexts);if(i.length>0){let e=Ac({type:`hook_additional_context`,content:i,hookName:`Setup`,toolUseID:`Setup`,hookEvent:`Setup`});n.push(e)}return n}Gs(),bu(),Xu(),V(),Ri(),P();function Zf(e,t){let n=Ce();H(`Settings changed from ${e}, updating app state`);let r=ur();Po(),t(e=>{let t=wr(e.toolPermissionContext,r);if(process.env.USER_TYPE===`ant`&&process.env.CLAUDE_CODE_ENTRYPOINT!==`local-agent`){let e=wc(r,[]);e.length>0&&(t=fi(t,e))}t.isBypassPermissionsModeAvailable&&Ti()&&(t=Xa(t)),t=zr(t);let i=e.settings.effortLevel,a=n.effortLevel,o=i!==a;return{...e,settings:n,toolPermissionContext:t,...o&&a!==void 0?{effortValue:a}:{}}})}ma(),S(),o(),Et(),Sa(),G(),Ka(),P(),lt(),vn(),qc();function Qf(){return`user_intent`}function $f(e){return e.promptSuggestionEnabled?e.pendingWorkerRequest||e.pendingSandboxRequest?`pending_permission`:e.elicitation.queue.length>0?`elicitation_active`:e.toolPermissionContext.mode===`plan`?`plan_mode`:process.env.USER_TYPE===`external`&&ka.status!==`allowed`?`rate_limit`:null:`disabled`}async function ep(e,t,n,r,i){if(e.signal.aborted)return $(`aborted`,void 0,void 0,i),null;if(cn(t,e=>e.type===`assistant`)<2)return $(`early_conversation`,void 0,void 0,i),null;let a=xa(t);if(a?.isApiErrorMessage)return $(`last_response_error`,void 0,void 0,i),null;let o=np(a);if(o)return $(o,void 0,void 0,i),null;let s=$f(n());if(s)return $(s,void 0,void 0,i),null;let c=Qf(),{suggestion:l,generationRequestId:u}=await ap(e,c,r);return e.signal.aborted?($(`aborted`,void 0,void 0,i),null):l?op(l,c,i)?null:{suggestion:l,promptId:c,generationRequestId:u}:($(`empty`,void 0,c,i),null)}var tp=1e4;function np(e){if(!e)return null;let t=e.message.usage,n=t.input_tokens??0,r=t.cache_creation_input_tokens??0,i=t.output_tokens??0;return n+r+i>tp?`cache_cold`:null}var rp=`[SUGGESTION MODE: Suggest what the user might naturally type next into Claude Code.]
|
|
45
|
+
|
|
46
|
+
FIRST: Look at the user's recent messages and original request.
|
|
47
|
+
|
|
48
|
+
Your job is to predict what THEY would type - not what you think they should do.
|
|
49
|
+
|
|
50
|
+
THE TEST: Would they think "I was just about to type that"?
|
|
51
|
+
|
|
52
|
+
EXAMPLES:
|
|
53
|
+
User asked "fix the bug and run tests", bug is fixed → "run the tests"
|
|
54
|
+
After code written → "try it out"
|
|
55
|
+
Claude offers options → suggest the one the user would likely pick, based on conversation
|
|
56
|
+
Claude asks to continue → "yes" or "go ahead"
|
|
57
|
+
Task complete, obvious follow-up → "commit this" or "push it"
|
|
58
|
+
After error or misunderstanding → silence (let them assess/correct)
|
|
59
|
+
|
|
60
|
+
Be specific: "run the tests" beats "continue".
|
|
61
|
+
|
|
62
|
+
NEVER SUGGEST:
|
|
63
|
+
- Evaluative ("looks good", "thanks")
|
|
64
|
+
- Questions ("what about...?")
|
|
65
|
+
- Claude-voice ("Let me...", "I'll...", "Here's...")
|
|
66
|
+
- New ideas they didn't ask about
|
|
67
|
+
- Multiple sentences
|
|
68
|
+
|
|
69
|
+
Stay silent if the next step isn't obvious from what the user said.
|
|
70
|
+
|
|
71
|
+
Format: 2-12 words, match the user's style. Or nothing.
|
|
72
|
+
|
|
73
|
+
Reply with ONLY the suggestion, no quotes or explanation.`,ip={user_intent:rp,stated_intent:rp};async function ap(e,t,n){let r=ip[t],i=await pa({promptMessages:[ms({content:r})],cacheSafeParams:n,canUseTool:async()=>({behavior:`deny`,message:`No tools needed for suggestion`,decisionReason:{type:`other`,reason:`suggestion only`}}),querySource:`prompt_suggestion`,forkLabel:`prompt_suggestion`,overrides:{abortController:e},skipTranscript:!0,skipCacheWrite:!0}),a=i.messages.find(e=>e.type===`assistant`),o=a?.type===`assistant`?a.requestId??null:null;for(let e of i.messages){if(e.type!==`assistant`)continue;let t=(Array.isArray(e.message.content)?e.message.content:[]).find(e=>e.type===`text`);if(t?.type===`text`&&typeof t.text==`string`){let e=t.text.trim();if(e)return{suggestion:e,generationRequestId:o}}}return{suggestion:null,generationRequestId:o}}function op(e,t,n){if(!e)return $(`empty`,void 0,t,n),!0;let r=e.toLowerCase(),i=e.trim().split(/\s+/).length,a=[[`done`,()=>r===`done`],[`meta_text`,()=>r===`nothing found`||r===`nothing found.`||r.startsWith(`nothing to suggest`)||r.startsWith(`no suggestion`)||/\bsilence is\b|\bstay(s|ing)? silent\b/.test(r)||/^\W*silence\W*$/.test(r)],[`meta_wrapped`,()=>/^\(.*\)$|^\[.*\]$/.test(e)],[`error_message`,()=>r.startsWith(`api error:`)||r.startsWith(`prompt is too long`)||r.startsWith(`request timed out`)||r.startsWith(`invalid api key`)||r.startsWith(`image was too large`)],[`prefixed_label`,()=>/^\w+:\s/.test(e)],[`too_few_words`,()=>i>=2||e.startsWith(`/`)?!1:!new Set([`yes`,`yeah`,`yep`,`yea`,`yup`,`sure`,`ok`,`okay`,`push`,`commit`,`deploy`,`stop`,`continue`,`check`,`exit`,`quit`,`no`]).has(r)],[`too_many_words`,()=>i>12],[`too_long`,()=>e.length>=100],[`multiple_sentences`,()=>/[.!?]\s+[A-Z]/.test(e)],[`has_formatting`,()=>/[\n*]|\*\*/.test(e)],[`evaluative`,()=>/thanks|thank you|looks good|sounds good|that works|that worked|that's all|nice|great|perfect|makes sense|awesome|excellent/.test(r)],[`claude_voice`,()=>/^(let me|i'll|i've|i'm|i can|i would|i think|i notice|here's|here is|here are|that's|this is|this will|you can|you should|you could|sure,|of course|certainly)/i.test(e)]];for(let[r,i]of a)if(i())return $(r,e,t,n),!0;return!1}function sp(e,t,n,r,i){let a=Math.round(t.length/(e.length||1)*100)/100,o=t===e,s=Math.max(0,Date.now()-n);yn(`tengu_prompt_suggestion`,{source:`sdk`,outcome:o?`accepted`:`ignored`,prompt_id:r,...i&&{generationRequestId:i},...o&&{timeToAcceptMs:s},...!o&&{timeToIgnoreMs:s},similarity:a,...process.env.USER_TYPE===`ant`&&{suggestion:e,userInput:t}})}function $(e,t,n,r){let i=n??Qf();yn(`tengu_prompt_suggestion`,{...r&&{source:r},outcome:`suppressed`,reason:e,prompt_id:i,...process.env.USER_TYPE===`ant`&&t&&{suggestion:t}})}S();var cp=null,lp=null;function up(){return cp!==null&&lp!==D()&&(cp=null,lp=null),cp}Xl(),wo(),Us(),c();var dp=class{constructor(){l(this,`codeVerifier`,void 0),l(this,`authCodeListener`,null),l(this,`port`,null),l(this,`manualAuthCodeResolver`,null),this.codeVerifier=cs()}async startOAuthFlow(e,t){this.authCodeListener=new dc,this.port=await this.authCodeListener.start();let n=ac(this.codeVerifier),r=oo(),i={codeChallenge:n,state:r,port:this.port,loginWithClaudeAi:t?.loginWithClaudeAi,inferenceOnly:t?.inferenceOnly,orgUUID:t?.orgUUID,loginHint:t?.loginHint,loginMethod:t?.loginMethod},a=A({...i,isManual:!0}),o=A({...i,isManual:!1}),s=await this.waitForAuthorizationCode(r,async()=>{t?.skipBrowserOpen?await e(a,o):(await e(a),await Yl(o))}),c=this.authCodeListener?.hasPendingResponse()??!1;K(`tengu_oauth_auth_code_received`,{automatic:c});try{let e=await z(s,r,this.codeVerifier,this.port,!c,t?.expiresIn),n=await je(e.access_token);if(c){let t=Fe(e.scope);this.authCodeListener?.handleSuccessRedirect(t)}return this.formatTokens(e,n.subscriptionType,n.rateLimitTier,n.rawProfile)}catch(e){throw c&&this.authCodeListener?.handleErrorRedirect(),e}finally{this.authCodeListener?.close()}}async waitForAuthorizationCode(e,t){return new Promise((n,r)=>{this.manualAuthCodeResolver=n,this.authCodeListener?.waitForAuthorization(e,t).then(e=>{this.manualAuthCodeResolver=null,n(e)}).catch(e=>{this.manualAuthCodeResolver=null,r(e)})})}handleManualAuthCodeInput(e){this.manualAuthCodeResolver&&(this.manualAuthCodeResolver(e.authorizationCode),this.manualAuthCodeResolver=null,this.authCodeListener?.close())}formatTokens(e,t,n,r){return{accessToken:e.access_token,refreshToken:e.refresh_token,expiresAt:Date.now()+e.expires_in*1e3,scopes:Fe(e.scope),subscriptionType:t,rateLimitTier:n,profile:r,tokenAccount:e.account?{uuid:e.account.uuid,emailAddress:e.account.email_address,organizationUuid:e.organization?.uuid}:void 0}}cleanup(){this.authCodeListener?.close(),this.manualAuthCodeResolver=null}};Xs(),vn(),Ml(),vc(),xe(),zs(),ut(),qe(),V(),o(),Et(),G(),ce(),P(),xt(),Br();async function fp(e){await Fs({clearOnboarding:!1});let t=e.profile??await Be(e.accessToken);t?be({accountUuid:t.account.uuid,emailAddress:t.account.email,organizationUuid:t.organization.uuid,displayName:t.account.display_name||void 0,hasExtraUsageEnabled:t.organization.has_extra_usage_enabled??void 0,billingType:t.organization.billing_type??void 0,subscriptionCreatedAt:t.organization.subscription_created_at??void 0,accountCreatedAt:t.account.created_at}):e.tokenAccount&&be({accountUuid:e.tokenAccount.uuid,emailAddress:e.tokenAccount.emailAddress,organizationUuid:e.tokenAccount.organizationUuid});let n=ke(e);if(_e(),n.warning&&yn(`tengu_oauth_storage_warning`,{warning:n.warning}),await we(e.accessToken).catch(e=>H(String(e),{level:`error`})),Ue(e.scopes))await ks().catch(e=>H(String(e),{level:`error`}));else if(!await rt(e.accessToken))throw Error(`Unable to create API key. The server accepted the request but did not return a key.`);await Wo()}c();var pp=class e{constructor(){l(this,`status`,{isAuthenticating:!1,output:[]}),l(this,`changed`,un()),l(this,`subscribe`,this.changed.subscribe)}static getInstance(){return e.instance||(e.instance=new e),e.instance}getStatus(){return{...this.status,output:[...this.status.output]}}startAuthentication(){this.status={isAuthenticating:!0,output:[]},this.changed.emit(this.getStatus())}addOutput(e){this.status.output.push(e),this.changed.emit(this.getStatus())}setError(e){this.status.error=e,this.changed.emit(this.getStatus())}endAuthentication(e){e?this.status={isAuthenticating:!1,output:[]}:this.status.isAuthenticating=!1,this.changed.emit(this.getStatus())}static reset(){e.instance&&(e.instance.changed.clear(),e.instance=null)}};l(pp,`instance`,null);function mp(e){if(e.toLowerCase().endsWith(`.jsonl`))return{sessionId:Q(),ingressUrl:null,isUrl:!1,jsonlFile:e,isJsonlFile:!0};if(Bc(e))return{sessionId:e,ingressUrl:null,isUrl:!1,jsonlFile:null,isJsonlFile:!1};try{let t=new URL(e);return{sessionId:Q(),ingressUrl:t.href,isUrl:!0,jsonlFile:null,isJsonlFile:!1}}catch{}return null}Xn(),_c(),Ci(),Is(),v(),bc(),G(),xt();async function hp(e,t,n){try{let r=t.mode===`url`?`url`:`form`,i=`url`in t?t.url:void 0,a=`elicitationId`in t?t.elicitationId:void 0,{elicitationResponse:o,blockingError:s}=await Un({serverName:e,message:t.message,requestedSchema:`requestedSchema`in t?t.requestedSchema:void 0,signal:n,mode:r,url:i,elicitationId:a});return s?{action:`decline`}:o?{action:o.action,content:o.content}:void 0}catch(t){tn(e,`Elicitation hook error: ${t}`);return}}async function gp(e,t,n,r,i){try{let{elicitationResultResponse:a,blockingError:o}=await _s({serverName:e,action:t.action,content:t.content,signal:n,mode:r,elicitationId:i});if(o)return br({message:`Elicitation response for server "${e}": decline`,notificationType:`elicitation_response`}),{action:`decline`};let s=a?{action:a.action,content:a.content??t.content}:t;return br({message:`Elicitation response for server "${e}": ${s.action}`,notificationType:`elicitation_response`}),s}catch(n){return tn(e,`ElicitationResult hook error: ${n}`),br({message:`Elicitation response for server "${e}": ${t.action}`,notificationType:`elicitation_response`}),t}}Mi(),vs(),_u(),d(),_n(),rl(),el(),Pi(),wn(),qe(),G(),Se();var _p=1440*60*1e3,vp=t(async()=>{if(qn())return{success:!1};try{return{success:!0,data:(await fe(()=>{let e=de();if(e.error)throw Error(`Failed to get auth headers: ${e.error}`);return u.get(`${Cn().BASE_API_URL}/api/oauth/account/settings`,{headers:{...e.headers,"User-Agent":N()}})})).data}}catch(e){return nn(e),vp.cache.clear?.(),{success:!1}}});async function yp(){try{await fe(()=>{let e=de();if(e.error)throw Error(`Failed to get auth headers: ${e.error}`);return u.post(`${Cn().BASE_API_URL}/api/oauth/account/grove_notice_viewed`,{},{headers:{...e.headers,"User-Agent":N()}})}),vp.cache.clear?.()}catch(e){nn(e)}}async function bp(){if(!_t())return!1;let e=st()?.accountUuid;if(!e)return!1;let t=ct().groveConfigCache?.[e];return t?Date.now()-t.timestamp>_p?(X(`Grove: Cache stale, returning cached data and refreshing in background`),xp(e),t.grove_enabled):(X(`Grove: Using fresh cached config`),t.grove_enabled):(X(`Grove: No cache, fetching config in background (dialog skipped this session)`),xp(e),!1)}async function xp(e){try{let t=await Sp();if(!t.success)return;let n=t.data.grove_enabled,r=ct().groveConfigCache?.[e];if(r?.grove_enabled===n&&Date.now()-r.timestamp<=_p)return;vt(t=>({...t,groveConfigCache:{...t.groveConfigCache,[e]:{grove_enabled:n,timestamp:Date.now()}}}))}catch(e){X(`Grove: Failed to fetch and store config: ${e}`)}}var Sp=t(async()=>{if(qn())return{success:!1};try{let{grove_enabled:e,domain_excluded:t,notice_is_grace_period:n,notice_reminder_frequency:r}=(await fe(()=>{let e=de();if(e.error)throw Error(`Failed to get auth headers: ${e.error}`);return u.get(`${Cn().BASE_API_URL}/api/claude_code_grove`,{headers:{...e.headers,"User-Agent":Re()},timeout:3e3})})).data;return{success:!0,data:{grove_enabled:e,domain_excluded:t??!1,notice_is_grace_period:n??!0,notice_reminder_frequency:r}}}catch(e){return X(`Failed to fetch Grove notice config: ${e}`),{success:!1}}});function Cp(e,t,n){if(!e.success||!t.success)return!1;let r=e.data,i=t.data;if(r.grove_enabled!==null)return!1;if(n||!i.notice_is_grace_period)return!0;let a=i.notice_reminder_frequency;return a!==null&&r.grove_notice_viewed_at?Math.floor((Date.now()-new Date(r.grove_notice_viewed_at).getTime())/(1e3*60*60*24))>=a:r.grove_notice_viewed_at==null}async function wp(){let[e,t]=await Promise.all([vp(),Sp()]);if(Cp(e,t,!1)){let e=t.success?t.data:null;K(`tengu_grove_print_viewed`,{dismissable:e?.notice_is_grace_period}),e===null||e.notice_is_grace_period?(ci(`
|
|
74
|
+
An update to our Consumer Terms and Privacy Policy will take effect on October 8, 2025. Run \`claude\` to review the updated terms.
|
|
75
|
+
|
|
76
|
+
`),await yp()):(ci(`
|
|
77
|
+
[ACTION REQUIRED] An update to our Consumer Terms and Privacy Policy has taken effect on October 8, 2025. You must run \`claude\` to review the updated terms.
|
|
78
|
+
|
|
79
|
+
`),await wa(1))}}Ft(),Ka(),nr();function Tp(e){return e.flatMap(e=>{if(!e)return[];switch(e.type){case`assistant`:return[{type:`assistant`,message:e.message,uuid:e.uuid,requestId:void 0,timestamp:new Date().toISOString()}];case`user`:return[{type:`user`,message:e.message,uuid:e.uuid??Q(),timestamp:e.timestamp??new Date().toISOString(),isMeta:e.isSynthetic}];default:return[]}})}function Ep(e){if(e)return{type:`rate_limit`,status:e.status,...e.resetsAt!==void 0&&{resetsAt:e.resetsAt},...e.rateLimitType!==void 0&&{rateLimitType:e.rateLimitType},...e.utilization!==void 0&&{utilization:e.utilization},...e.overageStatus!==void 0&&{overageStatus:e.overageStatus},...e.overageResetsAt!==void 0&&{overageResetsAt:e.overageResetsAt},...e.overageDisabledReason!==void 0&&{overageDisabledReason:e.overageDisabledReason},...e.isUsingOverage!==void 0&&{isUsingOverage:e.isUsingOverage},...e.surpassedThreshold!==void 0&&{surpassedThreshold:e.surpassedThreshold}}}Ds(),bn(),Ka();async function Dp(e){let{messages:t,getAppState:n,options:{mainLoopModel:r,tools:i,agentDefinitions:a,customSystemPrompt:o,appendSystemPrompt:s}}=e,c=Fr(t),{messages:l}=await Pr(c),u=n();return uc(l,r,async()=>u.toolPermissionContext,i,a,void 0,{options:{customSystemPrompt:o,appendSystemPrompt:s}},void 0,c)}ai();var Op=`cron`,kp=new ud;function Ap(e,t){return kp.run({workload:e},t)}_a(),nl(),Qo(),S(),qr(),At(),Vr(),Nr(),An(),G();var jp=200,Mp=100,Np=!1,Pp=ed(Er,`runs.json`),Fp=`Recovered stale active autonomy run`,Ip=new Set;function Lp(e){let t=e.replace(/\s+/g,` `).trim();return t.length<=240?t:`${t.slice(0,237)}...`}function Rp(e){return{...e}}function zp(e){return e.status===`queued`||e.status===`running`}function Bp(e){let t=e.map(Rp),n=t.filter(zp).length;return!Np&&n>=Mp&&(Np=!0,nn(Error(`autonomy: ${n} active runs exceed warn threshold ${Mp}; check for finalize leaks`))),fa(t,zp,e=>e.createdAt,jp)}function Vp(e){return{...e,runtime:e.runtime===`flow_step`?`flow_step`:`automatic`,currentDir:e.currentDir??e.rootDir,ownerKey:e.ownerKey??`main-thread`}}function Hp(e=E()){return ed(Z(e),Pp)}async function Up(e=E()){try{let t=await Ot().readFile(Hp(e),{encoding:`utf-8`}),n=JSON.parse(t);return Array.isArray(n.runs)?n.runs.filter(e=>!!(e&&typeof e.runId==`string`&&typeof e.trigger==`string`&&typeof e.status==`string`&&typeof e.rootDir==`string`&&typeof e.promptPreview==`string`&&typeof e.createdAt==`number`)).map(Vp).sort((e,t)=>t.createdAt-e.createdAt):[]}catch{return[]}}async function Wp(e,t=E()){let n=Hp(t);await rd($u(n),{recursive:!0}),await od(n,`${JSON.stringify({runs:Bp(e)},null,2)}\n`,`utf-8`)}async function Gp(e,t,n=E()){return Aa(n,async()=>{let r=await Up(n),i=r.findIndex(t=>t.runId===e);if(i===-1)return null;let a=t(Rp(r[i]));if(!a)return null;let o=Rp(a);return r[i]=o,await Wp(r,n),o})}async function Kp(e,t=E()){return(await Up(t)).find(t=>t.runId===e)??null}function qp(e){return e===`queued`||e===`running`}function Jp(e){return typeof e==`number`&&Number.isInteger(e)&&e>0&&e<=4194304}function Yp(e){return!qp(e.status)||e.ownerProcessId===void 0?!1:Jp(e.ownerProcessId)?!kn(e.ownerProcessId):!0}function Xp(e){return`${Fp}: owner process ${e.ownerProcessId} is no longer running.`}function Zp(e,t,n){return{...e,status:`failed`,endedAt:n,error:t}}function Qp(e,t){return Zp(e,Xp(e),t)}async function $p(e,t){e.parentFlowId&&e.parentFlowSyncMode===`managed`&&await Wi({flowId:e.parentFlowId,runId:e.runId,error:e.error??`Autonomy run failed.`,rootDir:t,nowMs:e.endedAt})}function em(e,t){return e.trigger===t.trigger&&e.sourceId===t.sourceId&&(t.ownerKey===void 0||e.ownerKey===t.ownerKey)&&qp(e.status)}async function tm(e){return(await Up(e.rootDir)).some(t=>em(t,e)&&!Yp(t))}function nm(e,t,n){let r=e.nowMs??Date.now();return{runId:Q(),runtime:e.runtime??(e.flow?`flow_step`:`automatic`),trigger:e.trigger,status:`queued`,rootDir:t,currentDir:n,ownerKey:e.flow?.ownerKey??e.ownerKey??`main-thread`,...e.sourceId?{sourceId:e.sourceId}:{},...e.sourceLabel?{sourceLabel:e.sourceLabel}:{},...e.flow?{parentFlowId:e.flow.flowId,parentFlowKey:e.flow.flowKey,parentFlowSyncMode:e.flow.syncMode,flowStepId:e.flow.stepId,flowStepName:e.flow.stepName}:{},promptPreview:Lp(e.prompt),createdAt:r,ownerProcessId:process.pid,ownerSessionId:D()}}async function rm(e,t,n){let r=!1,i=[];return await Aa(t,async()=>{let a=await Up(t),o=e.sourceId;if(n&&o){let n=!1,r=!1;for(let t=0;t<a.length;t++){let s=a[t];if(em(s,{trigger:e.trigger,sourceId:o,ownerKey:e.ownerKey})){if(Yp(s)){let n=Qp(s,e.createdAt);a[t]=n,i.push(n),r=!0;continue}s.ownerProcessId===void 0&&!Ip.has(s.runId)&&(Ip.add(s.runId),nn(Error(`[autonomyRuns] blocked by legacy un-owned active run ${s.runId} (createdAt=${s.createdAt}); cancel manually if this is a stale upgrade artifact`))),n=!0}}if(n){r&&await Wp(a,t);return}}a.unshift(e),await Wp(a,t),r=!0}),{created:r,recoveredStaleRuns:i}}async function im(e,t){if(e.parentFlowId&&e.flowStepId&&e.parentFlowSyncMode===`managed`){let n=(await _r(e.parentFlowId,t))?.stateJson?.steps.findIndex(t=>t.stepId===e.flowStepId)??0;await Qc({flowId:e.parentFlowId,stepId:e.flowStepId,stepIndex:n>=0?n:0,runId:e.runId,rootDir:t,nowMs:e.createdAt})}}async function am(e,t){let n=Z(e.rootDir??E()),r=nm(e,n,Z(e.currentDir??n)),{created:i,recoveredStaleRuns:a}=await rm(r,n,t);for(let e of a)await $p(e,n);return i?(await im(r,n),r):null}function om(e,t){let n=e.stateJson,r=n?.steps[t];if(!n||!r)return e.goal;let i=n.steps.slice(0,t).filter(e=>e.status===`completed`).map(e=>`- ${e.name}`),a=n.steps.slice(t+1).map(e=>`- ${e.name}`);return[`This is step ${t+1}/${n.steps.length} of the managed autonomy flow "${e.goal}".`,`<autonomy_flow>`,`Flow ID: ${e.flowId}`,`Flow source: ${e.sourceLabel??e.sourceId??`automatic`}`,`Current step: ${r.name}`,i.length>0?[`Completed steps:`,...i].join(`
|
|
80
|
+
`):`Completed steps: none`,a.length>0?[`Remaining steps after this one:`,...a].join(`
|
|
81
|
+
`):`Remaining steps after this one: none`,`</autonomy_flow>`,r.prompt].join(`
|
|
82
|
+
|
|
83
|
+
`)}async function sm(e){let t=Z(e.rootDir??E()),n=await _r(e.flowId,t);if(!n||n.status!==`queued`||!n.stateJson)return null;let r=n.stateJson.currentStepIndex,i=n.stateJson.steps[r];if(!i)return null;if(i.status===`queued`&&i.runId){let a=await Kp(i.runId,t);if(a&&a.status===`queued`&&!a.startedAt&&!a.endedAt){let i=await ei({basePrompt:om(n,r),trigger:`managed-flow-step`,rootDir:t,currentDir:e.currentDir??n.currentDir}),o={kind:`autonomy`,trigger:`managed-flow-step`,runId:a.runId,...a.sourceId?{sourceId:a.sourceId}:{}};return{value:i,mode:`prompt`,priority:e.priority??`later`,isMeta:!0,origin:o,workload:e.workload,autonomy:{runId:a.runId,rootDir:a.rootDir,trigger:`managed-flow-step`,sourceId:a.sourceId,sourceLabel:a.sourceLabel,...a.parentFlowId?{flowId:a.parentFlowId}:{},...a.flowStepId?{flowStepId:a.flowStepId}:{},...a.flowStepName?{flowStepName:a.flowStepName}:{}}}}return null}return i.status!==`pending`||i.runId?null:um({basePrompt:om(n,r),trigger:`managed-flow-step`,rootDir:t,currentDir:e.currentDir??n.currentDir,sourceId:n.sourceId??n.flowId,sourceLabel:n.sourceLabel??n.goal,workload:e.workload,priority:e.priority,flow:{flowId:n.flowId,flowKey:n.flowKey,syncMode:`managed`,ownerKey:n.ownerKey,stepId:i.stepId,stepName:i.name}})}async function cm(e){if(e.task.steps.length===0)return null;let t=Z(e.rootDir??E()),n=Z(e.currentDir??jt()),r=await ya({trigger:`proactive-tick`,goal:e.task.prompt,steps:e.task.steps.map(e=>({name:e.name,prompt:e.prompt,...e.waitFor?{waitFor:e.waitFor}:{}})),rootDir:t,currentDir:n,ownerKey:e.ownerKey,sourceId:`heartbeat:${e.task.name}`,sourceLabel:e.task.name});return r?sm({flowId:r.flow.flowId,rootDir:t,currentDir:n,priority:e.priority,workload:e.workload}):null}async function lm(e,t,n,r){let i=r??Date.now(),a=await Gp(e,e=>qp(e.status)?Zp(e,t,i):null,n);return a&&await $p(a,n??a.rootDir),a}async function um(e){let t=Z(e.rootDir??E()),n=Z(e.currentDir??jt()),r=await Ba({basePrompt:e.basePrompt,trigger:e.trigger,rootDir:t,currentDir:n});return e.shouldCreate&&!e.shouldCreate()?null:fm({prepared:r,rootDir:t,currentDir:n,sourceId:e.sourceId,sourceLabel:e.sourceLabel,ownerKey:e.ownerKey,workload:e.workload,priority:e.priority,flow:e.flow})}async function dm(e){let t=Z(e.rootDir??E()),n=Z(e.currentDir??jt());if(await tm({trigger:e.trigger,sourceId:e.sourceId,rootDir:t,ownerKey:e.ownerKey}))return null;let r=await Ba({basePrompt:e.basePrompt,trigger:e.trigger,rootDir:t,currentDir:n});return e.shouldCreate&&!e.shouldCreate()?null:pm({prepared:r,rootDir:t,currentDir:n,sourceId:e.sourceId,sourceLabel:e.sourceLabel,ownerKey:e.ownerKey,workload:e.workload,priority:e.priority})}async function fm(e){let t=await mm(e,!1);if(!t)throw Error(`Autonomy queued prompt was unexpectedly skipped.`);return t}async function pm(e){return mm(e,!0)}async function mm(e,t){let n=Z(e.rootDir??e.prepared.rootDir??E()),r=Z(e.currentDir??e.prepared.currentDir??jt()),i=e.prepared.prompt,a=await am({trigger:e.prepared.trigger,prompt:i,rootDir:n,currentDir:r,sourceId:e.sourceId,sourceLabel:e.sourceLabel,ownerKey:e.ownerKey,flow:e.flow},t&&!!e.sourceId);if(!a)return null;$s(e.prepared);let o={kind:`autonomy`,trigger:e.prepared.trigger,runId:a.runId,...e.sourceId?{sourceId:e.sourceId}:{}};return{value:i,mode:`prompt`,priority:e.priority??`later`,isMeta:!0,origin:o,workload:e.workload,autonomy:{runId:a.runId,rootDir:a.rootDir,trigger:e.prepared.trigger,sourceId:e.sourceId,sourceLabel:e.sourceLabel,...a.parentFlowId?{flowId:a.parentFlowId}:{},...a.flowStepId?{flowStepId:a.flowStepId}:{},...a.flowStepName?{flowStepName:a.flowStepName}:{}}}}async function hm(e){let t=Z(e.rootDir??E()),n=Z(e.currentDir??jt()),r=await Ba({basePrompt:e.basePrompt,trigger:`proactive-tick`,rootDir:t,currentDir:n});if(e.shouldCreate&&!e.shouldCreate())return[];let i=[await fm({prepared:r,rootDir:t,currentDir:n,workload:e.workload,priority:e.priority})];for(let a of r.dueHeartbeatTasks){if(a.steps.length===0)continue;if(e.shouldCreate&&!e.shouldCreate())break;let r=await cm({task:a,rootDir:t,currentDir:n,priority:e.priority,workload:e.workload});r&&i.push(r)}return i}na();function gm(e,t){return e.autonomy?.rootDir??t}function _m(e){return`${e.rootDir??``}\0${e.runId}`}function vm(e,t){let n=new Map;for(let r of e){let e=r.autonomy?.runId;if(!e)continue;let i={runId:e,rootDir:gm(r,t)};n.set(_m(i),i)}return[...n.values()]}function ym(e){return e.mode===`prompt`||e.mode===`task-notification`}function bm(e){let t=new Map;for(let n of e){let e=n.rootDir??``,r=t.get(e);r?r.push(n):t.set(e,[n])}return t}async function xm(e,t){let n=[],r=[],i=vm(e,t),a=new Map;for(let[e,t]of bm(i)){let n=await lr(e||void 0),r=new Set(t.map(e=>e.runId));for(let t of n)r.has(t.runId)&&a.set(_m({runId:t.runId,rootDir:e||void 0}),t)}for(let i of e){let e=i.autonomy?.runId;if(!e){n.push(i);continue}let o=gm(i,t),s=a.get(_m({runId:e,rootDir:o}));s?.status===`queued`&&!s.startedAt&&!s.endedAt?n.push(i):r.push(i)}return{attachmentCommands:n,staleCommands:r}}async function Sm(e,t){let n=await xm(e,t),r=[],i=[],a=new Set,o=vm(n.attachmentCommands.filter(ym),t);for(let e of o)(await xs(e.runId,e.rootDir))?.status===`running`?(r.push(e.runId),i.push(_m(e))):a.add(_m(e));let s=new Set(i),c=[],l=[],u=[...n.staleCommands];for(let e of n.attachmentCommands){let n=e.autonomy?.runId;if(!n){c.push(e);continue}let r=_m({runId:n,rootDir:gm(e,t)});s.has(r)?(c.push(e),l.push(e)):a.has(r)&&u.push(e)}return{attachmentCommands:c,staleCommands:u,claimedRunIds:r,claimedCommands:l}}async function Cm(e){for(let t of vm(e.commands,e.rootDir))await rr(t.runId,t.rootDir)}function wm(e){return typeof e==`string`?e:e instanceof Error?e.message:String(e)}function Tm(e,t=`query failed`){let n=wm(e).toLowerCase();return n.includes(`api_error`)||n.includes(`provider`)||n.includes(`openai`)||n.includes(`gemini`)||n.includes(`grok`)||n.includes(`anthropic`)||n.includes(`bedrock`)||n.includes(`vertex`)?`provider api_error`:t}async function Em(e){let t=[];for(let n of e.commands){let r=n.autonomy;r?.runId&&(e.outcome.type===`completed`?t.push(...await Vc({runId:r.runId,rootDir:r.rootDir,currentDir:e.currentDir,priority:e.priority,workload:n.workload??e.workload})):e.outcome.type===`cancelled`?await rr(r.runId,r.rootDir):await Zi({runId:r.runId,rootDir:r.rootDir,error:e.outcome.message??Tm(e.outcome.error)}))}return t}V(),xt();async function Dm(){try{let e=await id(ki(),`utf-8`),t=L().safeParse(bt(e));return t.success?t.data:(H(`Invalid known_marketplaces.json in zip cache: ${t.error.message}`,{level:`error`}),{})}catch{return{}}}async function Om(e){await Lc(ki(),wt(e,null,2))}async function km(e,t){let n=or();if(!n)return;let r=await Am(t);r!==null&&await Lc(ed(n,hr(e)),r)}async function Am(e){let t=[ed(e,`.claude-plugin`,`marketplace.json`),ed(e,`marketplace.json`),e];for(let e of t)try{return await id(e,`utf-8`)}catch{}return null}async function jm(){let e=await fc();for(let[t,n]of Object.entries(e))if(n.installLocation)try{await km(t,n.installLocation)}catch(e){H(`Failed to save marketplace JSON for ${t}: ${e}`)}await Om({...await Dm(),...e})}vn(),Tt(),V(),Xt(),Dt(),G(),Ln(),Oc(),gs();async function Mm(){let e=bi();H(`installPluginsForHeadless: starting${e?` (zip cache mode)`:``}`);let t=await ls();t&&(Jr(),Ns(`headlessPluginInstall: seed marketplaces registered`)),e&&(await Ot().mkdir(Ss()),await Ot().mkdir(Hn()));let n=Object.keys(Va()).length,r={marketplaces_installed:0,delisted_count:0},i=t;try{if(n===0)H(`installPluginsForHeadless: no marketplaces declared`);else{let t=await Yt(`headless_marketplace_reconcile`,()=>Bu({skip:e?(e,t)=>!hi(t):void 0,onProgress:e=>{e.type===`installed`?H(`installPluginsForHeadless: installed marketplace ${e.name}`):e.type===`failed`&&H(`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&&H(`installPluginsForHeadless: skipped ${t.skipped.length} marketplace(s) unsupported by zip cache: ${t.skipped.join(`, `)}`);let n=t.installed.length+t.updated.length;n>0&&(Jr(),Ns(`headlessPluginInstall: marketplaces reconciled`),i=!0),r.marketplaces_installed=n}e&&await jm();let t=await mu();return r.delisted_count=t.length,t.length>0&&(i=!0),i&&Ns(`headlessPluginInstall: plugins changed`),e&&yt(sa),i}catch(e){return nn(e),!1}finally{yn(`tengu_headless_plugin_install`,r)}}rc(),Tu(),_i(),Uo();var Nm=class extends Error{constructor(e,t){super(e),this.code=t,this.name=`StopTaskError`}};async function Pm(e,t){let{getAppState:n,setAppState:r}=t,i=n().tasks?.[e];if(!i)throw new Nm(`No task found with ID: ${e}`,`not_found`);if(i.status!==`running`)throw new Nm(`Task ${e} is not running (status: ${i.status})`,`not_running`);let a=pi(i.type);if(!a)throw new Nm(`Unsupported task type: ${i.type}`,`unsupported_type`);if(await a.kill(e,r),Ys(i)){let t=!1;r(n=>{let r=n.tasks[e];return!r||r.notified?n:(t=!0,{...n,tasks:{...n.tasks,[e]:{...r,notified:!0}}})}),t&&jl(e,`stopped`,{toolUseId:i.toolUseId,summary:i.description})}let o=Ys(i)?i.command:i.description;return{taskId:e,taskType:i.type,command:o}}Me(),_n(),rl(),Ta(),Pi(),Ml(),ha(),ql(),Da(),sl(),nt(),Ft(),_l(),v(),ic(),xt(),$c(),o(),Oc(),pn(),Ll(),lt(),Et(),On(),M();var Fm=(Go(),e(jo)),Im=(Pl(),e(Fl)),Lm=(Gu(),e(Hu)),Rm=(Uu(),e(zu)),zm=(gl(),e(pl)),Bm=`<system-reminder>
|
|
84
|
+
You are running in non-interactive mode and cannot return a response to the user until your team is shut down.
|
|
85
|
+
|
|
86
|
+
You MUST shut down your team before preparing your final response:
|
|
87
|
+
1. Use requestShutdown to ask each team member to shut down gracefully
|
|
88
|
+
2. Wait for shutdown approvals
|
|
89
|
+
3. Use the cleanup operation to clean up the team
|
|
90
|
+
4. Only then provide your final response to the user
|
|
91
|
+
|
|
92
|
+
The user cannot receive your response until the team is completely shut down.
|
|
93
|
+
</system-reminder>
|
|
94
|
+
|
|
95
|
+
Shut down your team and prepare your final response for the user.`,Vm=1e4,Hm=new Set,Um=[];function Wm(e){if(Hm.has(e))return!1;if(Hm.add(e),Um.push(e),Um.length>Vm){let e=Um.splice(0,Um.length-Vm);for(let t of e)Hm.delete(t)}return!0}function Gm(e){return typeof e==`string`?[{type:`text`,text:e}]:e}function Km(e){return e.length===1?e[0]:e.every(e=>typeof e==`string`)?e.join(`
|
|
96
|
+
`):e.flatMap(Gm)}function qm(e,t){return t!==void 0&&t.mode===`prompt`&&t.workload===e.workload&&t.isMeta===e.isMeta}async function Jm(e,t,n,r,i,a,o,c){if(process.env.USER_TYPE===`ant`&&s(process.env.CLAUDE_CODE_EXIT_AFTER_FIRST_RENDER)&&(process.stderr.write(`\nStartup time: ${Math.round(process.uptime()*1e3)}ms\n`),process.exit(0)),Zu.subscribe(e=>{Zf(e,n),Sr()&&n(e=>{let t=e.settings,n=t.fastMode===!0&&!t.fastModePerSessionOptIn;return{...e,fastMode:n}})}),Im&&!Im.isProactiveActive()&&s(process.env.CLAUDE_CODE_PROACTIVE)&&Im.activateProactive(`command`),typeof Bun<`u`&&setInterval(()=>{process.memoryUsage.rss()>350*1024*1024?Bun.gc(!0):Bun.gc(!1)},1e3).unref(),ca(),zc(`runHeadless_entry`),await bp()&&await wp(),zc(`after_grove_check`),tt(),c.resumeSessionAt&&!c.resume){process.stderr.write(`Error: --resume-session-at requires --resume
|
|
97
|
+
`),J(1);return}if(c.rewindFiles&&!c.resume){process.stderr.write(`Error: --rewind-files requires --resume
|
|
98
|
+
`),J(1);return}if(c.rewindFiles&&e){process.stderr.write(`Error: --rewind-files is a standalone operation and cannot be used with a prompt
|
|
99
|
+
`),J(1);return}let l=oh(e,c);c.outputFormat===`stream-json`&&Dd();let u=Gn.getSandboxUnavailableReason();if(u){if(Gn.isSandboxRequired()){process.stderr.write(`\nError: sandbox required but unavailable: ${u}\n sandbox.failIfUnavailable is set — refusing to start without a working sandbox.\n\n`),J(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(Gn.isSandboxingEnabled())try{await Gn.initialize(l.createSandboxAskCallback())}catch(e){process.stderr.write(`\n❌ Sandbox Error: ${U(e)}\n`),J(1,`other`);return}c.outputFormat===`stream-json`&&c.verbose&&Ou(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:Q(),session_id:W()};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:Q(),session_id:W()};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:Q(),session_id:W()}}})();l.write(t)}),c.setupTrigger&&await Xf(c.setupTrigger),zc(`before_loadInitialMessages`);let d=t(),{messages:f,turnInterruptionState:p,agentSetting:m}=await ah(n,{continue:c.continue,teleport:c.teleport,resume:c.resume,resumeSessionAt:c.resumeSessionAt,forkSession:c.forkSession,outputFormat:c.outputFormat,sessionStartHooksPromise:c.sessionStartHooksPromise,restoredWorkerState:l.restoredWorkerState}),h=Jf();if(h&&l.prependUserMessage(h),!c.agent&&!Gt()&&m){let{agentDefinition:e}=ku(m,void 0,{activeAgents:o,allAgents:o});if(e){if(n(t=>({...t,agent:e.agentType})),!c.systemPrompt&&!cc(e)){let t=e.getSystemPrompt();t&&(c.systemPrompt=t)}Uc(e.agentType)}}if(f.length===0&&process.exitCode!==void 0)return;if(c.rewindFiles){let e=f.find(e=>e.uuid===c.rewindFiles);if(!e||e.type!==`user`){process.stderr.write(`Error: --rewind-files requires a user message UUID, but ${c.rewindFiles} is not a user message in this session\n`),J(1);return}let r=t(),i=await $m(c.rewindFiles,r,n,!1);if(!i.canRewind){process.stderr.write(`Error: ${i.error||`Unexpected error`}\n`),J(1);return}process.stdout.write(`Files rewound to state at message ${c.rewindFiles}\n`),J(0);return}let g=typeof c.resume==`string`&&(!!Tc(c.resume)||c.resume.endsWith(`.jsonl`)),_=!!c.sdkUrl;if(!e&&!g&&!_){process.stderr.write(`Error: Input must be provided either through stdin or as a prompt argument when using --print
|
|
100
|
+
`),J(1);return}if(c.outputFormat===`stream-json`&&!c.verbose){process.stderr.write(`Error: When using --print, --output-format=stream-json requires --verbose
|
|
101
|
+
`),J(1);return}let ee=dr(d.mcp.tools,d.toolPermissionContext),v=[...i,...ee],te=Zm(c.sdkUrl?`stdio`:c.permissionPromptToolName,l,()=>t().mcp.tools,e=>{n(e=>({...e,attribution:{...e.attribution,permissionPromptCount:e.attribution.permissionPromptCount+1}})),yr(`requires_action`,e)});c.permissionPromptToolName&&(v=v.filter(e=>!vl(e,c.permissionPromptToolName))),Ur(),zc(`after_loadInitialMessages`),await he(),zc(`after_modelStrings`);let ne=c.outputFormat===`json`&&c.verbose,y=[],b;zc(`before_runHeadlessStreaming`);for await(let e of Ym(l,d.mcp.clients,[...r,...d.mcp.commands],v,f,te,a,t,n,o,c,p))c.outputFormat===`stream-json`&&c.verbose&&await l.write(e),e.type!==`control_response`&&e.type!==`control_request`&&e.type!==`control_cancel_request`&&!(e.type===`system`&&(e.subtype===`session_state_changed`||e.subtype===`task_notification`||e.subtype===`task_started`||e.subtype===`task_progress`||e.subtype===`post_turn_summary`))&&e.type!==`stream_event`&&e.type!==`keep_alive`&&e.type!==`streamlined_text`&&e.type!==`streamlined_tool_use_summary`&&e.type!==`prompt_suggestion`&&(ne&&y.push(e),b=e);switch(c.outputFormat){case`json`:if(!b||b.type!==`result`)throw Error(`No messages returned`);if(c.verbose){Gi(wt(y)+`
|
|
102
|
+
`);break}Gi(wt(b)+`
|
|
103
|
+
`);break;case`stream-json`:break;default:if(!b||b.type!==`result`)throw Error(`No messages returned`);switch(b.subtype){case`success`:Gi(b.result.endsWith(`
|
|
104
|
+
`)?b.result:b.result+`
|
|
105
|
+
`);break;case`error_during_execution`:Gi(`Execution error`);break;case`error_max_turns`:Gi(`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`:Gi(`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`:Gi(`Error: Failed to provide valid structured output after maximum retries.
|
|
106
|
+
Tip: Simplify your schema or check if the output format matches the expected structure.`)}}if(sr(),le())try{let{drainPendingExtraction:e}=await import(`./extractMemories-CRBVNiG1.js`);await e()}catch{}J(b?.type===`result`&&b?.is_error?1:0)}function Ym(e,t,n,a,o,c,l,u,d,f,p,m){let h=!1,g,_=!1,ee=!1,v=null,y,b=e.outbound;process.on(`SIGINT`,()=>{Lr(`info`,`shutdown_signal`,{signal:`SIGINT`}),y&&!y.signal.aborted&&y.abort(),wa(0)}),Du(async()=>{let t={};for(let e of qs(u()))ss(e)&&(t[e.type]=(t[e.type]??0)+1);Lr(`info`,`run_state_at_shutdown`,{run_active:h,run_phase:g,worker_status:mi(),internal_events_pending:e.internalEventsPending,bg_tasks:t})}),Wr(e=>{(e===`default`||e===`acceptEdits`||e===`bypassPermissions`||e===`plan`||e===`auto`||e===`dontAsk`)&&b.enqueue({type:`system`,subtype:`status`,status:null,permissionMode:e,uuid:Q(),session_id:W()})});let x={abortController:null,inflightPromise:null,lastEmitted:null,pendingSuggestion:null,pendingLastEmittedEntry:null},re;p.enableAuthStatus&&(re=pp.getInstance().subscribe(e=>{b.enqueue({type:`auth_status`,isAuthenticating:e.isAuthenticating,output:e.output,error:e.error,uuid:Q(),session_id:W()})}));let S=e=>{let t=Ep(e);t&&b.enqueue({type:`rate_limit_event`,rate_limit_info:t,uuid:Q(),session_id:W()})};Ku.add(S);let C=o,w=uf(o,ld(),100),T=zi(100),E=process.env.CLAUDE_CODE_RESUME_INTERRUPTED_TURN;m&&m.kind!==`none`&&E&&(X(`[print.ts] Auto-resuming interrupted turn (kind: ${m.kind})`),ih(C,m.message),Y({mode:`prompt`,value:m.message.message.content,uuid:Q()}));let D=jr().map(e=>{let t=e.value===null?`default`:e.value,n=t===`default`?Ie():it(t),r=hc(n),i=bo(n),a=Gr(e.value),o=za(n);return{name:t,value:t,displayName:e.label,description:e.description,...r&&{supportsEffort:!0,supportedEffortLevels:Do(n)?[...So]:So.filter(e=>e!==`max`)},...i&&{supportsAdaptiveThinking:!0},...a&&{supportsFastMode:!0},...o&&{supportsAutoMode:!0}}}),ie=p.userSpecifiedModel;function ae(e,t){let n=zn(e,Ee(t));C.push(...n);for(let e of n)typeof e.message.content==`string`&&e.message.content.includes(`<local-command-stdout>`)&&b.enqueue({type:`user`,content:e.message.content,message:e.message,session_id:W(),parent_tool_use_id:null,uuid:e.uuid,timestamp:e.timestamp,isReplay:!0})}let O=[],k=[],se=new Set;function ce(t){for(let n of t){if(n.type!==`connected`||se.has(n.name)||n.config.type===`sdk`)continue;let t=n.name;try{n.client.setRequestHandler(ne,async(n,r)=>{jn(t,`Elicitation request received in print mode: ${wt(n)}`);let i=n.params.mode===`url`?`url`:`form`;K(`tengu_mcp_elicitation_shown`,{mode:i});let a=await hp(t,n.params,r.signal);if(a)return jn(t,`Elicitation resolved by hook: ${wt(a)}`),K(`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 gp(t,await e.handleElicitation(t,n.params.message,s,r.signal,i,o,c),r.signal,i,c);return K(`tengu_mcp_elicitation_response`,{mode:i,action:l.action}),l}),n.client.setNotificationHandler(te,e=>{let{elicitationId:n}=e.params;jn(t,`Elicitation completion notification: ${n}`),vi({message:`MCP server "${t}" confirmed elicitation ${n} complete`,notificationType:`elicitation_complete`}),b.enqueue({type:`system`,subtype:`elicitation_complete`,mcp_server_name:t,elicitation_id:n,uuid:Q(),session_id:W()})}),se.add(t)}catch{}}}async function le(){let t=new Set(Object.keys(l)),n=new Set(O.map(e=>e.name)),r=Array.from(t).some(e=>!n.has(e)),i=Array.from(n).some(e=>!t.has(e)),a=O.some(e=>e.type===`pending`),o=O.some(e=>e.type===`failed`);if(r||i||a||o){for(let e of O)t.has(e.name)||e.type===`connected`&&await e.cleanup();let r=await io(l,(t,n)=>e.sendMcpMessage(t,n));O=r.clients,k=r.tools;let i=Xr([...n,...t]);d(e=>({...e,mcp:{...e.mcp,tools:[...e.mcp.tools.filter(e=>!i.some(t=>e.name.startsWith(Wn(t)))),...k]}})),Zc(O)}}le();let A={clients:[],tools:[],configs:{}},ue=e=>{let t=ia(e.toolPermissionContext,e.mcp.tools),n=ve(Md([...a,...k,...A.tools],t,e.toolPermissionContext.mode),`name`);p.permissionPromptToolName&&(n=n.filter(e=>!vl(e,p.permissionPromptToolName)));let r=Vt();if(r&&!p.jsonSchema){let e=ol(r);`tool`in e&&(n=[...n,e.tool])}return n},j=null,de=0;function fe(){if(!j)return;let e=Math.min(de,C.length),t=C.slice(e).filter(e=>e.type===`user`||e.type===`assistant`);de=C.length,t.length>0&&j.writeMessages(t)}let M=Promise.resolve({response:{added:[],removed:[],errors:{}},sdkServersChanged:!1});function pe(e){let t=async()=>{let t=new Set(O.map(e=>e.name)),n=await lh(e,{configs:l,clients:O,tools:k},A,d);for(let e of Object.keys(l))delete l[e];if(Object.assign(l,n.newSdkState.configs),O=n.newSdkState.clients,k=n.newSdkState.tools,A=n.newDynamicState,n.sdkServersChanged){let e=new Set(O.map(e=>e.name)),n=Xr([...t,...e]);d(e=>({...e,mcp:{...e.mcp,tools:[...e.mcp.tools.filter(e=>!n.some(t=>e.name.startsWith(Wn(t)))),...k]}}))}return{response:n.response,sdkServersChanged:n.sdkServersChanged}};return M=M.then(t,t),M}function me(){let e=u(),t=e.mcp.clients,n=ve([...e.mcp.tools,...A.tools],`name`),r=new Set([...t.map(e=>e.name),...O.map(e=>e.name)]);return[...t,...O,...A.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`?gu(n,e.name).map(e=>({name:e.mcpInfo?.toolName??e.name,annotations:{readOnly:e.isReadOnly({})||void 0,destructive:e.isDestructive?.({})||void 0,openWorld:e.isOpenWorld?.({})||void 0}})):void 0,i;if(e.type===`connected`&&e.capabilities.experimental){let t={...e.capabilities.experimental};t[`claude/channel`]&&(!tf()||!nf(e.config.pluginSource))&&delete t[`claude/channel`],Object.keys(t).length>0&&(i={experimental:t})}return{name:e.name,status:e.type,serverInfo:e.type===`connected`?e.serverInfo:void 0,error:e.type===`failed`?e.error:void 0,config:t,scope:e.config.scope,tools:r,capabilities:i}})}async function he(){try{await Promise.all([Promise.resolve(),ga(`headless_managed_settings_wait`,()=>fd())]),await Mm()&&await be()}catch(e){q(e)}}let ge=null;r()||(s(process.env.CLAUDE_CODE_SYNC_PLUGIN_INSTALL)?ge=he():he());let _e=mf(()=>!h),N=n,P=f;async function ye(){let{agentDefinitions:e}=await wu(d);N=await Ni(ld());let t=P.filter(e=>e.source===`flagSettings`);P=[...e.allAgents,...t]}async function be(){let{servers:e}=await Dc(),t={};for(let[n,r]of Object.entries(e)){let e=r.type;(e===void 0||e===`stdio`||e===`sse`||e===`http`||e===`sdk`)&&(t[n]=r)}for(let[e,n]of Object.entries(l))n.type===`sdk`&&!(e in t)&&(t[e]=n);let{response:n,sdkServersChanged:r}=await pe(t);r&&le(),X(`Headless MCP refresh: added=${n.added.length}, removed=${n.removed.length}`)}let F=Eu.subscribe(()=>{Di(),Ni(ld()).then(e=>{N=e})}),xe=()=>{setTimeout(()=>{!Im?.isProactiveActive()||Im.isProactivePaused()||_||(async()=>{let e=await hm({basePrompt:`<${cl}>${new Date().toLocaleTimeString()}</${cl}>`,currentDir:ld(),shouldCreate:()=>!_});if(_){await Cm({commands:e});return}for(let t of e)Y({...t,uuid:Q()});I()})().catch(e=>{q(e),X(`[Proactive] failed to create headless tick: ${e}`,{level:`error`})})},0)};hs(()=>{y&&Ic(`now`).length>0&&y.abort(`interrupt`)});let I=async()=>{if(h)return;if(h=!0,g=void 0,yr(`running`),_e.stop(),zc(`run_entry`),await le(),zc(`after_updateSdkMcp`),ge){let e=parseInt(process.env.CLAUDE_CODE_SYNC_PLUGIN_INSTALL_TIMEOUT_MS||``,10);if(e>0){let t=Dn(e).then(()=>`timeout`);await Promise.race([ge,t])===`timeout`&&(q(Error(`CLAUDE_CODE_SYNC_PLUGIN_INSTALL: plugin installation timed out after ${e}ms`)),K(`tengu_sync_plugin_install_timeout`,{timeout_ms:e}))}else await ge;ge=null,await ye();let{setupPluginHookHotReload:t}=await import(`./loadPluginHooks-B5SIS2uo.js`);t()}let t=e=>e.agentId===void 0;try{let n,r=!1,a=async()=>{for(;n=vo(t);){if(n.mode!==`prompt`&&n.mode!==`orphaned-permission`&&n.mode!==`task-notification`)throw Error(`only prompt commands are supported in streaming mode`);let r=[n];if(n.mode===`prompt`)for(;qm(n,Oi(t));)r.push(vo(t));let a=await Sm(r);if(r=a.attachmentCommands,r.length===0)continue;n=r[0],n.mode===`prompt`&&r.length>1&&(n={...n,value:Km(r.map(e=>e.value)),uuid:r.findLast(e=>e.uuid)?.uuid??n.uuid});let o=r.map(e=>e.uuid).filter(e=>e!==void 0);if(p.replayUserMessages&&r.length>1)for(let e of r)e.uuid&&e.uuid!==n.uuid&&b.enqueue({type:`user`,content:e.value,message:{role:`user`,content:e.value},session_id:W(),parent_tool_use_id:null,uuid:e.uuid,isReplay:!0});let s=u(),l=[...s.mcp.clients,...O,...A.clients];ce(l);for(let e of l)nh(e);let f=ue(s);for(let e of o)Pd(e,`started`);if(n.mode===`task-notification`){let e=typeof n.value==`string`?n.value:``,t=e.match(/<task-id>([^<]+)<\/task-id>/),r=e.match(/<tool-use-id>([^<]+)<\/tool-use-id>/),i=e.match(/<output-file>([^<]+)<\/output-file>/),a=e.match(/<status>([^<]+)<\/status>/),o=e.match(/<summary>([^<]+)<\/summary>/),s=e=>e===`completed`||e===`failed`||e===`stopped`||e===`killed`,c=a?.[1],l=s(c)?c===`killed`?`stopped`:c:`completed`,u=e.match(/<usage>([\s\S]*?)<\/usage>/)?.[1]??``,d=u.match(/<total_tokens>(\d+)<\/total_tokens>/),f=u.match(/<tool_uses>(\d+)<\/tool_uses>/),p=u.match(/<duration_ms>(\d+)<\/duration_ms>/);a&&b.enqueue({type:`system`,subtype:`task_notification`,task_id:t?.[1]??``,tool_use_id:r?.[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:W(),uuid:Q()})}let m=n.value,h=a.claimedCommands;if(e instanceof xd&&n.mode===`prompt`&&K(`tengu_bridge_message_received`,{is_repl:!1}),x.abortController?.abort(),x.abortController=null,x.pendingSuggestion=null,x.pendingLastEmittedEntry=null,x.lastEmitted&&n.mode===`prompt`){let e=typeof m==`string`?m:m.find(e=>e.type===`text`)?.text;typeof e==`string`&&sp(x.lastEmitted.text,e,x.lastEmitted.emittedAt,x.lastEmitted.promptId,x.lastEmitted.generationRequestId),x.lastEmitted=null}y=Rf(),zc(`before_ask`),tr();let g=n,_=!1;try{if(await Ap(g.workload??p.workload,async()=>{for await(let t of sf({commands:ve([...N,...s.mcp.commands],`name`),prompt:m,promptUuid:g.uuid,isMeta:g.isMeta,cwd:ld(),tools:f,verbose:p.verbose,mcpClients:l,thinkingConfig:p.thinkingConfig,maxTurns:p.maxTurns,maxBudgetUsd:p.maxBudgetUsd,taskBudget:p.taskBudget,canUseTool:c,userSpecifiedModel:ie,fallbackModel:p.fallbackModel,jsonSchema:Vt()??p.jsonSchema,mutableMessages:C,getReadFileCache:()=>T.size===0?w:zo(w,T),setReadFileCache:e=>{w=e;for(let[e,t]of T.entries()){let n=w.get(e);(!n||t.timestamp>n.timestamp)&&w.set(e,t)}T.clear()},customSystemPrompt:p.systemPrompt,appendSystemPrompt:p.appendSystemPrompt,getAppState:u,setAppState:d,abortController:y,replayUserMessages:p.replayUserMessages,includePartialMessages:p.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:P,orphanedPermission:g.orphanedPermission,setSDKStatus:e=>{b.enqueue({type:`system`,subtype:`status`,status:e,session_id:W(),uuid:Q()})}}))if(fe(),t.type===`result`){_=!!t.is_error;for(let e of Rl())b.enqueue(e);qs(u()).some(e=>(e.type===`local_agent`||e.type===`local_workflow`)&&ss(e))?v=t:(v=null,b.enqueue(t))}else{for(let e of Rl())b.enqueue(e);b.enqueue(t)}}),_)await Em({commands:h,outcome:{type:`failed`,message:`ask() returned an error result`},currentDir:ld(),priority:`later`,workload:g.workload??p.workload});else{let e=await Em({commands:h,outcome:{type:`completed`},currentDir:ld(),priority:`later`,workload:g.workload??p.workload});for(let t of e)Y({...t,uuid:Q()})}}catch(e){throw await Em({commands:h,outcome:{type:`failed`,error:e},currentDir:ld(),priority:`later`,workload:g.workload??p.workload}),e}for(let e of o)Pd(e,`completed`);if(fe(),j?.sendResult(),p.promptSuggestions&&!i(process.env.CLAUDE_CODE_ENABLE_PROMPT_SUGGESTION)){x.abortController?.abort();let e=new AbortController;x.abortController=e;let t=up();if(!t)$(`sdk_no_params`,void 0,void 0,`sdk`);else{let n={promise:null};n.promise=(async()=>{try{let n=await ep(e,C,u,t,`sdk`);if(!n||e.signal.aborted)return;let r={type:`prompt_suggestion`,suggestion:n.suggestion,uuid:Q(),session_id:W()},i={text:n.suggestion,emittedAt:Date.now(),promptId:n.promptId,generationRequestId:n.generationRequestId};v?(x.pendingSuggestion=r,x.pendingLastEmittedEntry={text:i.text,promptId:i.promptId,generationRequestId:i.generationRequestId}):(x.lastEmitted=i,b.enqueue(r))}catch(e){if(e instanceof Error&&(e.name===`AbortError`||e.name===`APIUserAbortError`)){$(`aborted`,void 0,void 0,`sdk`);return}q(St(e))}finally{x.inflightPromise===n.promise&&(x.inflightPromise=null)}})(),x.inflightPromise=n.promise}}sr(),ea(),ca()}};do{for(let e of Rl())b.enqueue(e);g=`draining_commands`,await a(),r=!1;{let e=qs(u()).some(e=>ss(e)&&e.type!==`in_process_teammate`),n=Oi(t)!==void 0;(e||n)&&(r=!0,n||(g=`waiting_for_agents`,await Dn(100)))}}while(r);v&&(b.enqueue(v),v=null,x.pendingSuggestion&&(b.enqueue(x.pendingSuggestion),x.pendingLastEmittedEntry&&(x.lastEmitted={...x.pendingLastEmittedEntry,emittedAt:Date.now()},x.pendingLastEmittedEntry=null),x.pendingSuggestion=null))}catch(t){try{await e.write({type:`result`,subtype:`error_during_execution`,duration_ms:0,duration_api_ms:0,is_error:!0,num_turns:0,stop_reason:null,session_id:W(),total_cost_usd:0,usage:Nl,modelUsage:{},permission_denials:[],uuid:Q(),errors:[U(t),...Nn().map(e=>e.error)]})}catch{}x.abortController?.abort(),J(1);return}finally{if(g=`finally_flush`,await e.flushInternalEvents(),g=`finally_post_flush`,!Na()){yr(`idle`);for(let e of Rl())b.enqueue(e)}h=!1,_e.start()}if(Im?.isProactiveActive()&&!Im.isProactivePaused()&&Oi(t)===void 0&&!_){xe();return}if(Oi(t)!==void 0){I();return}{let e=u().teamContext;if(e&&fn(e)){let e=`team-lead`;for(;;){let t=u();if(!(hn(t)||t.teamContext&&Object.keys(t.teamContext.teammates).length>0)){X(`[print.ts] No more active teammates, stopping poll`);break}let n=await es(e,t.teamContext?.teamName);if(n.length>0){X(`[print.ts] Team-lead found ${n.length} unread messages`),await is(e,t.teamContext?.teamName);let r=t.teamContext?.teamName;for(let e of n){let n=Xo(e.text);if(n&&r){let e=n.from;X(`[print.ts] Processing shutdown_approved from ${e}`);let i=t.teamContext?.teammates?Object.entries(t.teamContext.teammates).find(([,t])=>t.name===e)?.[0]:void 0;i&&(Ul(r,{agentId:i,name:e}),X(`[print.ts] Removed ${e} from team file`),await Bl(r,i,e,`shutdown`),d(e=>{if(!e.teamContext?.teammates||!(i in e.teamContext.teammates))return e;let{[i]:t,...n}=e.teamContext.teammates;return{...e,teamContext:{...e.teamContext,teammates:n}}}))}}Y({mode:`prompt`,value:n.map(e=>`<${hl} teammate_id="${e.from}"${e.color?` color="${e.color}"`:``}>\n${e.text}\n</${hl}>`).join(`
|
|
107
|
+
|
|
108
|
+
`),uuid:Q()}),I();return}if(_&&!ee){ee=!0,X(`[print.ts] Input closed with active teammates, injecting shutdown prompt`),Y({mode:`prompt`,value:Bm,uuid:Q()}),I();return}await Dn(500)}}}_&&(await(async()=>{let e=u();dn(e)&&await mn(d,e);let t=u(),n=t.teamContext;return n&&Object.keys(n.teammates).length>0||hn(t)})()?(Y({mode:`prompt`,value:Bm,uuid:Q()}),I()):(x.inflightPromise&&await Promise.race([x.inflightPromise,Dn(5e3)]),x.abortController?.abort(),x.abortController=null,await pf(),F(),re?.(),Ku.delete(S),b.done()))},Se=null;if(zm.isKairosCronEnabled()){let e=e=>{_||(async()=>{let t=await dm({basePrompt:e.basePrompt,trigger:`scheduled-task`,currentDir:ld(),sourceId:e.sourceId,sourceLabel:e.sourceLabel,workload:Op,shouldCreate:()=>!_});if(t){if(_){await Cm({commands:[t]});return}await e.onSuccess(t)}})().catch(t=>{q(t),X(`[ScheduledTasks] failed to enqueue headless task${e.logSuffix}: ${t}`,{level:`error`})})},t=e=>{Y({...e,uuid:Q()}),I()};Se=Lm.createCronScheduler({onFire:n=>{e({basePrompt:n,sourceId:n,sourceLabel:n,logSuffix:``,onSuccess:t})},onFireTask:n=>{if(n.agentId){e({basePrompt:n.prompt,sourceId:n.id,sourceLabel:n.prompt,logSuffix:` ${n.id}`,onSuccess:async e=>{await lm(e.autonomy.runId,`No teammate runtime available for scheduled task owner ${n.agentId} in headless mode.`,e.autonomy.rootDir)}});return}e({basePrompt:n.prompt,sourceId:n.id,sourceLabel:n.prompt,logSuffix:` ${n.id}`,onSuccess:t})},isLoading:()=>h||_,getJitterConfig:Rm?.getCronJitterConfig,isKilled:()=>!zm?.isKairosCronEnabled()}),Se.start()}let L=function(e,t){b.enqueue({type:`control_response`,response:{subtype:`success`,request_id:e.request_id,response:t}})},R=function(e,t){b.enqueue({type:`control_response`,response:{subtype:`error`,request_id:e.request_id,error:t}})},Ce=new Set;e.setUnexpectedResponseCallback(async e=>{await sh({message:e,setAppState:d,handledToolUseIds:Ce,onEnqueued:()=>{I()}})});let z=new Map,we=new Map,Te=new Set,De=new Map,Oe=null;return(async()=>{let r=!1;Lr(`info`,`cli_message_loop_started`);for await(let i of e.structuredInput){let a=`uuid`in i?i.uuid:void 0;if(a&&i.type!==`user`&&i.type!==`control_response`&&Pd(a,`completed`),i.type===`control_request`){let a=i,o=a.request;if(a.request.subtype===`interrupt`)d(e=>({...e,attribution:{...e.attribution,escapeCount:e.attribution.escapeCount+1}})),y&&y.abort(),x.abortController?.abort(),x.abortController=null,x.lastEmitted=null,x.pendingSuggestion=null,L(a);else if(o.subtype===`end_session`){X(`[print.ts] end_session received, reason=${o.reason??`unspecified`}`),y&&y.abort(),x.abortController?.abort(),x.abortController=null,x.lastEmitted=null,x.pendingSuggestion=null,L(a);break}else if(a.request.subtype===`initialize`){if(a.request.sdkMcpServers&&a.request.sdkMcpServers.length>0)for(let e of a.request.sdkMcpServers)l[e]={type:`sdk`,name:e};await Qm(a.request,a.request_id,r,b,n,D,e,!!p.enableAuthStatus,p,f,u),a.request.promptSuggestions&&d(e=>e.promptSuggestionEnabled?e:{...e,promptSuggestionEnabled:!0}),a.request.agentProgressSummaries&&Je(`tengu_slate_prism`,!0)&&Wt(!0),r=!0,oa()&&I()}else if(a.request.subtype===`set_permission_mode`){let e=a.request;d(t=>({...t,toolPermissionContext:eh(e,a.request_id,t.toolPermissionContext,b),isUltraplanMode:e.ultraplan??t.isUltraplanMode}))}else if(a.request.subtype===`set_model`){let e=a.request.model??`default`,t=e===`default`?Ie():e;ie=t,It(t),Fi({model:t}),ae(e,t),L(a)}else if(a.request.subtype===`set_max_thinking_tokens`)a.request.max_thinking_tokens===null?p.thinkingConfig=void 0:a.request.max_thinking_tokens===0?p.thinkingConfig={type:`disabled`}:p.thinkingConfig={type:`enabled`,budgetTokens:a.request.max_thinking_tokens},L(a);else if(a.request.subtype===`mcp_status`)L(a,{mcpServers:me()});else if(a.request.subtype===`get_context_usage`)try{let e=u();L(a,{...await Dp({messages:C,getAppState:u,options:{mainLoopModel:ht(),tools:ue(e),agentDefinitions:e.agentDefinitions,customSystemPrompt:p.systemPrompt,appendSystemPrompt:p.appendSystemPrompt}})})}catch(e){R(a,U(e))}else if(a.request.subtype===`mcp_message`){let e=a.request,t=O.find(t=>t.name===e.server_name);t&&t.type===`connected`&&t.client?.transport?.onmessage&&t.client.transport.onmessage(e.message),L(a)}else if(a.request.subtype===`rewind_files`){let e=u(),t=await $m(a.request.user_message_id,e,d,a.request.dry_run??!1);t.canRewind||a.request.dry_run?L(a,t):R(a,t.error??`Unexpected error`)}else if(a.request.subtype===`cancel_async_message`){let e=a.request.message_uuid;L(a,{cancelled:Gc(t=>t.uuid===e).length>0})}else if(a.request.subtype===`seed_read_state`){try{let e=bs(a.request.path),t=Math.floor((await ad(e)).mtimeMs);if(t<=a.request.mtime){let n=await id(e,`utf-8`),r=(n.charCodeAt(0)===65279?n.slice(1):n).replaceAll(`\r
|
|
109
|
+
`,`
|
|
110
|
+
`);T.set(e,{content:r,timestamp:t,offset:void 0,limit:void 0})}}catch{}L(a)}else if(a.request.subtype===`mcp_set_servers`){let{response:e,sdkServersChanged:t}=await pe(a.request.servers);L(a,e),t&&le()}else if(a.request.subtype===`reload_plugins`)try{let e=await wu(d),t=P.filter(e=>e.source===`flagSettings`);P=[...e.agentDefinitions.allAgents,...t];let n=[],[r,i,o]=await Promise.allSettled([Ni(ld()),be(),go()]);r.status===`fulfilled`?N=r.value:q(r.reason),i.status===`rejected`&&q(i.reason),o.status===`fulfilled`?n=o.value.enabled.map(e=>({name:e.name,path:e.path,source:e.source})):q(o.reason),L(a,{commands:N.filter(e=>e.userInvocable!==!1).map(e=>({name:Yc(e),description:Zr(e),argumentHint:e.argumentHint||``})),agents:P.map(e=>({name:e.agentType,description:e.whenToUse,model:e.model===`inherit`?void 0:e.model})),plugins:n,mcpServers:me(),error_count:e.error_count})}catch(e){R(a,U(e))}else if(a.request.subtype===`mcp_reconnect`){let e=u(),{serverName:n}=a.request;se.delete(n);let r=ho(n)??t.find(e=>e.name===n)?.config??O.find(e=>e.name===n)?.config??A.clients.find(e=>e.name===n)?.config??e.mcp.clients.find(e=>e.name===n)?.config??null;if(!r)R(a,`Server not found: ${n}`);else{let e=await $o(n,r),t=Wn(n);d(r=>({...r,mcp:{...r.mcp,clients:r.mcp.clients.map(t=>t.name===n?e.client:t),tools:[...B(r.mcp.tools,e=>e.name?.startsWith(t)),...e.tools],commands:[...B(r.mcp.commands,e=>vu(e,n)),...e.commands],resources:e.resources&&e.resources.length>0?{...r.mcp.resources,[n]:e.resources}:ft(r.mcp.resources,n)}})),A={...A,clients:[...A.clients.filter(e=>e.name!==n),e.client],tools:[...A.tools.filter(e=>!e.name?.startsWith(t)),...e.tools]},e.client.type===`connected`?(ce([e.client]),nh(e.client),L(a)):R(a,e.client.type===`failed`?e.client.error??`Connection failed`:`Server status: ${e.client.type}`)}}else if(a.request.subtype===`mcp_toggle`){let e=u(),{serverName:n,enabled:r}=a.request;se.delete(n);let i=ho(n)??t.find(e=>e.name===n)?.config??O.find(e=>e.name===n)?.config??A.clients.find(e=>e.name===n)?.config??e.mcp.clients.find(e=>e.name===n)?.config??null;if(!i)R(a,`Server not found: ${n}`);else if(r){ir(n,!0);let e=await $o(n,i),t=Wn(n);d(r=>({...r,mcp:{...r.mcp,clients:r.mcp.clients.map(t=>t.name===n?e.client:t),tools:[...B(r.mcp.tools,e=>e.name?.startsWith(t)),...e.tools],commands:[...B(r.mcp.commands,e=>vu(e,n)),...e.commands],resources:e.resources&&e.resources.length>0?{...r.mcp.resources,[n]:e.resources}:ft(r.mcp.resources,n)}})),e.client.type===`connected`?(ce([e.client]),nh(e.client),L(a)):R(a,e.client.type===`failed`?e.client.error??`Connection failed`:`Server status: ${e.client.type}`)}else{ir(n,!1);let r=[...t,...O,...A.clients,...e.mcp.clients].find(e=>e.name===n);r&&r.type===`connected`&&await Mo(n,i);let o=Wn(n);d(e=>({...e,mcp:{...e.mcp,clients:e.mcp.clients.map(e=>e.name===n?{name:n,type:`disabled`,config:i}:e),tools:B(e.mcp.tools,e=>e.name?.startsWith(o)),commands:B(e.mcp.commands,e=>vu(e,n)),resources:ft(e.mcp.resources,n)}})),L(a)}}else if(o.subtype===`channel_enable`){let e=u();th(a.request_id,o.serverName,[...e.mcp.clients,...O,...A.clients],b)}else if(o.subtype===`mcp_authenticate`){let e=o.serverName,n=u(),r=ho(e)??t.find(t=>t.name===e)?.config??n.mcp.clients.find(t=>t.name===e)?.config??null;if(!r)R(a,`Server not found: ${e}`);else if(r.type!==`sse`&&r.type!==`http`)R(a,`Server type "${r.type}" does not support OAuth authentication`);else try{z.get(e)?.abort();let t=new AbortController;z.set(e,t);let n,i=new Promise(e=>{n=e}),o=Li(e,r,e=>n(e),t.signal,{skipBrowserOpen:!0,onWaitingForCallback:t=>{we.set(e,t)}}),s=await Promise.race([i,o.then(()=>null)]);s?L(a,{authUrl:s,requiresUserAction:!0}):L(a,{requiresUserAction:!1}),De.set(e,o),o.then(async()=>{if(Nc(e)||Te.has(e))return;let t=await $o(e,r),n=Wn(e);d(r=>({...r,mcp:{...r.mcp,clients:r.mcp.clients.map(n=>n.name===e?t.client:n),tools:[...B(r.mcp.tools,e=>e.name?.startsWith(n)),...t.tools],commands:[...B(r.mcp.commands,t=>vu(t,e)),...t.commands],resources:t.resources&&t.resources.length>0?{...r.mcp.resources,[e]:t.resources}:ft(r.mcp.resources,e)}})),A={...A,clients:[...A.clients.filter(t=>t.name!==e),t.client],tools:[...A.tools.filter(e=>!e.name?.startsWith(n)),...t.tools]}}).catch(t=>{X(`MCP OAuth failed for ${e}: ${t}`,{level:`error`})}).finally(()=>{z.get(e)===t&&(z.delete(e),we.delete(e),Te.delete(e),De.delete(e))})}catch(e){R(a,U(e))}}else if(o.subtype===`mcp_oauth_callback_url`){let e=o.serverName,t=o.callbackUrl,n=we.get(e);if(n){let r=!1;try{let e=new URL(t);r=e.searchParams.has(`code`)||e.searchParams.has(`error`)}catch{}if(!r)R(a,`Invalid callback URL: missing authorization code. Please paste the full redirect URL including the code parameter.`);else{Te.add(e),n(t);let r=De.get(e);if(r)try{await r,L(a)}catch(e){R(a,e instanceof Error?e.message:`OAuth authentication failed`)}else L(a)}}else R(a,`No active OAuth flow for server: ${e}`)}else if(o.subtype===`claude_authenticate`){let e=o.loginWithClaudeAi;Oe?.service.cleanup(),K(`tengu_oauth_flow_start`,{loginWithClaudeAi:e??!0});let t=new dp,n,r=new Promise(e=>{n=e}),i=t.startOAuthFlow(async(e,t)=>{n({manualUrl:e,automaticUrl:t})},{loginWithClaudeAi:e??!0,skipBrowserOpen:!0}).then(async t=>{await fp(t),K(`tengu_oauth_success`,{loginWithClaudeAi:e??!0})}).finally(()=>{t.cleanup(),Oe?.service===t&&(Oe=null)});Oe={service:t,flow:i},i.catch(e=>X(`claude_authenticate flow ended: ${e}`,{level:`info`}));try{let{manualUrl:e,automaticUrl:t}=await Promise.race([r,i.then(()=>{throw Error(`OAuth flow completed without producing auth URLs`)})]);L(a,{manualUrl:e,automaticUrl:t})}catch(e){R(a,U(e))}}else if(o.subtype===`claude_oauth_callback`||o.subtype===`claude_oauth_wait_for_completion`)if(!Oe)R(a,`No active claude_authenticate flow`);else{o.subtype===`claude_oauth_callback`&&Oe.service.handleManualAuthCodeInput({authorizationCode:o.authorizationCode,state:o.state});let{flow:e}=Oe;e.then(()=>{let e=oe();L(a,{account:{email:e?.email,organization:e?.organization,subscriptionType:e?.subscription,tokenSource:e?.tokenSource,apiKeySource:e?.apiKeySource,apiProvider:Le()}})},e=>R(a,U(e)))}else if(o.subtype===`mcp_clear_auth`){let e=o.serverName,n=u(),r=ho(e)??t.find(t=>t.name===e)?.config??n.mcp.clients.find(t=>t.name===e)?.config??null;if(!r)R(a,`Server not found: ${e}`);else if(r.type!==`sse`&&r.type!==`http`)R(a,`Cannot clear auth for server type "${r.type}"`);else{await xr(e,r);let t=await $o(e,r),n=Wn(e);d(r=>({...r,mcp:{...r.mcp,clients:r.mcp.clients.map(n=>n.name===e?t.client:n),tools:[...B(r.mcp.tools,e=>e.name?.startsWith(n)),...t.tools],commands:[...B(r.mcp.commands,t=>vu(t,e)),...t.commands],resources:t.resources&&t.resources.length>0?{...r.mcp.resources,[e]:t.resources}:ft(r.mcp.resources,e)}})),L(a,{})}}else if(a.request.subtype===`apply_flag_settings`){let e=ht(),t=Bt()??{},n=a.request.settings,r={...t,...n};for(let e of Object.keys(r))r[e]===null&&delete r[e];Pt(r),Zu.notifyChange(`flagSettings`),`model`in n&&(n.model==null?It(void 0):It(String(n.model)));let i=ht();if(i!==e){ie=i;let e=n.model?String(n.model):`default`;Fi({model:i}),ae(e,i)}L(a)}else if(a.request.subtype===`get_settings`){let e=u(),t=ht(),n=hc(t)?Vo(t,e.effortValue):void 0;L(a,{...fs(),applied:{model:t,effort:typeof n==`string`?n:null}})}else if(a.request.subtype===`stop_task`){let{task_id:e}=a.request;try{await Pm(e,{getAppState:u,setAppState:d}),L(a,{})}catch(e){R(a,U(e))}}else if(o.subtype===`generate_session_title`){let e=o.description,t=o.persist,n=(y&&!y.signal.aborted?y:Rf()).signal;(async()=>{try{let r=await Hf(e,n);if(r&&t)try{$i(W(),r)}catch(e){q(e)}L(a,{title:r})}catch(e){R(a,U(e))}})()}else if(o.subtype===`side_question`){let e=o.question;(async()=>{try{let t=up();L(a,{response:(await Gf({question:e,cacheSafeParams:t?{...t,toolUseContext:{...t.toolUseContext,abortController:Rf()}}:await Wf({tools:ue(u()),commands:N,mcpClients:[...u().mcp.clients,...O,...A.clients],messages:C,readFileState:w,getAppState:u,setAppState:d,customSystemPrompt:p.systemPrompt,appendSystemPrompt:p.appendSystemPrompt,thinkingConfig:p.thinkingConfig,agents:P})})).response})}catch(e){R(a,U(e))}})()}else if(a.request.subtype===`set_proactive`)a.request.enabled?Im.isProactiveActive()||(Im.activateProactive(`command`),xe()):Im.deactivateProactive(),L(a);else if(o.subtype===`remote_control`)if(o.enabled)if(j)L(a,{session_url:xf(j.bridgeSessionId,j.sessionIngressUrl),connect_url:Sf(j.environmentId,j.sessionIngressUrl),environment_id:j.environmentId});else{let t;try{let{initReplBridge:n}=await import(`./initReplBridge-D2E6IM2B.js`),r=await n({onInboundMessage(e){let t=Cf(e);if(!t)return;let{content:n,uuid:r}=t;Y({value:n,mode:`prompt`,uuid:r,skipSlashCommands:!0}),I()},onPermissionResponse(t){e.injectControlResponse(t)},onInterrupt(){y?.abort()},onSetModel(e){let t=e===`default`?Ie():e;ie=t,It(t)},onSetMaxThinkingTokens(e){e===null?p.thinkingConfig=void 0:e===0?p.thinkingConfig={type:`disabled`}:p.thinkingConfig={type:`enabled`,budgetTokens:e}},onStateChange(e,n){e===`failed`&&(t=n),X(`[bridge:sdk] State change: ${e}${n?` — ${n}`:``}`),b.enqueue({type:`system`,subtype:`bridge_state`,state:e,detail:n,uuid:Q(),session_id:W()})},initialMessages:C.length>0?C:void 0});r?(j=r,de=C.length,e.setOnControlRequestSent(e=>{r.sendControlRequest(e)}),e.setOnControlRequestResolved(e=>{r.sendControlCancelRequest(e)}),L(a,{session_url:xf(r.bridgeSessionId,r.sessionIngressUrl),connect_url:Sf(r.environmentId,r.sessionIngressUrl),environment_id:r.environmentId})):R(a,t??`Remote Control initialization failed`)}catch(e){R(a,U(e))}}else j&&(e.setOnControlRequestSent(void 0),e.setOnControlRequestResolved(void 0),await j.teardown(),j=null),L(a);else R(a,`Unsupported control request subtype: ${a.request.subtype}`);continue}else if(i.type===`control_response`){p.replayUserMessages&&b.enqueue(i);continue}else if(i.type===`keep_alive`)continue;else if(i.type===`update_environment_variables`)continue;else if(i.type===`assistant`||i.type===`system`){let e=Tp([i]);C.push(...e),i.type===`assistant`&&p.replayUserMessages&&b.enqueue(i);continue}if(i.type!==`user`)continue;let o=i;if(r=!0,o.uuid){let e=W(),t=await La(e,o.uuid);if(t||Hm.has(o.uuid)){X(`Skipping duplicate user message: ${o.uuid}`),p.replayUserMessages&&(X(`Sending acknowledgment for duplicate user message: ${o.uuid}`),b.enqueue({type:`user`,content:o.message?.content??``,message:o.message,session_id:e,parent_tool_use_id:null,uuid:o.uuid,timestamp:o.timestamp,isReplay:!0})),t&&Pd(o.uuid,`completed`);continue}Wm(o.uuid)}Y({mode:`prompt`,value:await If(o,o.message.content),uuid:o.uuid,priority:o.priority}),d(e=>({...e,attribution:ju(e.attribution,e=>{to(e).catch(e=>{X(`Attribution: Failed to save snapshot: ${e}`)})})})),I()}_=!0,Se?.stop(),h||(x.inflightPromise&&await Promise.race([x.inflightPromise,Dn(5e3)]),x.abortController?.abort(),x.abortController=null,await pf(),F(),re?.(),Ku.delete(S),b.done())})(),b}function Xm(e){let t=async(n,r,i,a,o,s)=>{let c=s??await ua(n,r,i,a,o);if(c.behavior===`allow`||c.behavior===`deny`)return c;let{signal:l,cleanup:u}=zf(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 Vu(Wu().parse(Cc(h.content[0].text)),e,r,i)};return t}function Zm(e,t,n,r){if(e===`stdio`)return t.createCanUseTool(r);if(!e)return async(e,t,n,r,i,a)=>a??await ua(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=>vl(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`),J(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`),J(1),Error(t)}i=Xm(r)}return i(t,r,a,o,s,c)}}async function Qm(e,t,n,r,i,a,o,s,c,l,u){if(n){r.enqueue({type:`control_response`,response:{subtype:`error`,error:`Already initialized`,request_id:t,pending_permission_requests:o.getPendingPermissionRequests()}});return}if(e.systemPrompt!==void 0&&(c.systemPrompt=e.systemPrompt),e.appendSystemPrompt!==void 0&&(c.appendSystemPrompt=e.appendSystemPrompt),e.promptSuggestions!==void 0&&(c.promptSuggestions=e.promptSuggestions),e.agents){let t=Ks(e.agents,`flagSettings`);l.push(...t)}if(c.agent){let e=Gt()===c.agent,t=l.find(e=>e.agentType===c.agent);if(t&&!e){if(Mt(t.agentType),!c.systemPrompt&&!cc(t)){let e=t.getSystemPrompt();e&&(c.systemPrompt=e)}!c.userSpecifiedModel&&t.model&&t.model!==`inherit`&&It(it(t.model)),t.initialPrompt&&o.prependUserMessage(t.initialPrompt)}else t?.initialPrompt&&o.prependUserMessage(t.initialPrompt)}let d=uo()?.outputStyle||`default`,f=await yu(Jl()),p=oe();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}});zt(t)}e.jsonSchema&&Nt(e.jsonSchema);let m={commands:i.filter(e=>e.userInvocable!==!1).map(e=>({name:Yc(e),description:Zr(e),argumentHint:e.argumentHint||``})),agents:l.map(e=>({name:e.agentType,description:e.whenToUse,model:e.model===`inherit`?void 0:e.model})),output_style:d,available_output_styles:Object.keys(f),models:a,account:{email:p?.email,organization:p?.organization,subscriptionType:p?.subscription,tokenSource:p?.tokenSource,apiKeySource:p?.apiKeySource,apiProvider:Le()},pid:process.pid};if(Sr()&&wi()){let e=u();m.fast_mode_state=ys(c.userSpecifiedModel??null,e.fastMode)}if(r.enqueue({type:`control_response`,response:{subtype:`success`,request_id:t,response:m}}),s){let e=pp.getInstance().getStatus();e&&r.enqueue({type:`auth_status`,isAuthenticating:e.isAuthenticating,output:e.output,error:e.error,uuid:Q(),session_id:W()})}}async function $m(e,t,n,r){if(!Kr())return{canRewind:!1,error:`File rewinding is not enabled.`,filesChanged:[]};if(!Cr(t.fileHistory,e))return{canRewind:!1,error:`No file checkpoint found for this message.`,filesChanged:[]};if(r){let n=await di(t.fileHistory,e);return{canRewind:!0,filesChanged:n?.filesChanged??[],insertions:n?.insertions,deletions:n?.deletions}}try{await qi(e=>n(t=>({...t,fileHistory:e(t.fileHistory)})),e)}catch(e){return{canRewind:!1,error:`Failed to rewind: ${U(e)}`,filesChanged:[]}}return{canRewind:!0,filesChanged:[]}}function eh(e,t,n,r){if(e.mode===`bypassPermissions`){if(kr())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`&&!Ma()){let e=Ir();return r.enqueue({type:`control_response`,response:{subtype:`error`,request_id:t,error:e?`Cannot set permission mode to auto: ${Ca(e)}`:`Cannot set permission mode to auto`}}),n}return r.enqueue({type:`control_response`,response:{subtype:`success`,request_id:t,response:{mode:e.mode}}}),{...ni(n.mode,e.mode,n),mode:e.mode}}function th(e,t,n,r){let i=t=>r.enqueue({type:`control_response`,response:{subtype:`error`,request_id:e,error:t}}),a=n.find(e=>e.name===t&&e.type===`connected`);if(!a||a.type!==`connected`)return i(`server ${t} is not connected`);let o=a.config.pluginSource,s=o?Yn(o):void 0;if(!s?.marketplace)return i(`server ${t} is not plugin-sourced; channel_enable requires a marketplace plugin`);let c={kind:`plugin`,name:s.name,marketplace:s.marketplace},l=Ut(),u=l.some(e=>e.kind===`plugin`&&e.name===c.name&&e.marketplace===c.marketplace);u||Rt([...l,c]);let d=Qd(t,a.capabilities,o);if(d.action===`skip`)return u||Rt(l),i(d.reason);let f=`${c.name}@${c.marketplace}`;jn(t,`Channel notifications registered`),K(`tengu_mcp_channel_enable`,{plugin:f}),a.client.setNotificationHandler(Kd(),async e=>{let{content:n,meta:r}=e.params;jn(t,`notifications/claude/channel: ${n.slice(0,80)}`),K(`tengu_mcp_channel_message`,{content_length:n.length,meta_key_count:Object.keys(r??{}).length,entry_kind:`plugin`,is_dev:!1,plugin:f}),Y({mode:`prompt`,value:Xd(t,n,r),priority:`next`,isMeta:!0,origin:{kind:`channel`,server:t},skipSlashCommands:!0})}),r.enqueue({type:`control_response`,response:{subtype:`success`,request_id:e,response:void 0}})}function nh(e){if(e.type!==`connected`||Qd(e.name,e.capabilities,e.config.pluginSource).action!==`register`)return;let t=Zd(e.name,Ut()),n=t?.kind===`plugin`?`${t.name}@${t.marketplace}`:void 0;jn(e.name,`Channel notifications re-registered after reconnect`),e.client.setNotificationHandler(Kd(),async r=>{let{content:i,meta:a}=r.params;jn(e.name,`notifications/claude/channel: ${i.slice(0,80)}`),K(`tengu_mcp_channel_message`,{content_length:i.length,meta_key_count:Object.keys(a??{}).length,entry_kind:t?.kind,is_dev:t?.dev??!1,plugin:n}),Y({mode:`prompt`,value:Xd(e.name,i,a),priority:`next`,isMeta:!0,origin:{kind:`channel`,server:e.name},skipSlashCommands:!0})})}function rh(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:W(),total_cost_usd:0,usage:Nl,modelUsage:{},permission_denials:[],uuid:Q(),errors:[e]};process.stdout.write(wt(t)+`
|
|
111
|
+
`)}else process.stderr.write(e+`
|
|
112
|
+
`)}function ih(e,t){let n=e.findIndex(e=>e.uuid===t.uuid);n!==-1&&e.splice(n,2)}async function ah(t,n){let r=!Lt();if(n.continue)try{K(`tengu_continue_print`,{});let i=await Gd(void 0,void 0);if(i){if(Fm){let n=Fm.matchSessionMode(i.mode);if(n){process.stderr.write(n+`
|
|
113
|
+
`);let{getAgentDefinitionsWithOverrides:r,getActiveAgentsFromList:i}=(Bs(),e(pc));r.cache.clear?.();let a=await r(Jl());t(e=>({...e,agentDefinitions:{...a,allAgents:a.allAgents,activeAgents:i(a.allAgents)}}))}}return n.forkSession||i.sessionId&&(Ht(rs(i.sessionId),i.fullPath?$u(i.fullPath):null),r&&await Jc()),Au(i,t),_o(n.forkSession?{...i,worktreeSession:void 0}:i),Fm&&Qn(Fm.isCoordinatorMode()?`coordinator`:`normal`),{messages:i.messages,turnInterruptionState:i.turnInterruptionState,agentSetting:i.agentSetting}}}catch(e){return q(e),J(1),{messages:[]}}if(n.teleport)try{if(!ii(`allow_remote_sessions`))throw Error(`Remote sessions are disabled by your organization's policy.`);if(K(`tengu_teleport_print`,{}),typeof n.teleport!=`string`)throw Error(`No session ID provided for teleport`);let{checkOutTeleportedSessionBranch:e,processMessagesForTeleportResume:t,teleportResumeCodeSession:r,validateGitState:i}=await import(`./teleport-C_UgMy0V.js`);await i();let a=await r(n.teleport),{branchError:o}=await e(a.branch);return{messages:t(a.log,o)}}catch(e){return q(e),J(1),{messages:[]}}if(n.resume)try{K(`tengu_resume_print`,{});let i=mp(typeof n.resume==`string`?n.resume:``);if(!i){let e=`Error: --resume requires a valid session ID when used with --print. Usage: claude -p --resume <session-id>`;return typeof n.resume==`string`&&(e+=`. Session IDs must be in UUID format (e.g., 550e8400-e29b-41d4-a716-446655440000). Provided value "${n.resume}" is not a valid UUID`),rh(e,n.outputFormat),J(1),{messages:[]}}if(s(process.env.CLAUDE_CODE_USE_CCR_V2)){let[,e]=await Promise.all([Co(i.sessionId),n.restoredWorkerState]);e&&(t(Fd(e)),typeof e.model==`string`&&It(e.model))}else i.isUrl&&i.ingressUrl&&s(process.env.ENABLE_SESSION_PERSISTENCE)&&await Os(i.sessionId,i.ingressUrl);let a=await Gd(i.sessionId,i.jsonlFile||void 0);if(!a||a.messages.length===0)return i.isUrl||s(process.env.CLAUDE_CODE_USE_CCR_V2)?{messages:await(n.sessionStartHooksPromise??Yf(`startup`))}:(rh(`No conversation found with session ID: ${i.sessionId}`,n.outputFormat),J(1),{messages:[]});if(n.resumeSessionAt){let e=a.messages.findIndex(e=>e.uuid===n.resumeSessionAt);if(e<0)return rh(`No message found with message.uuid of: ${n.resumeSessionAt}`,n.outputFormat),J(1),{messages:[]};a.messages=e>=0?a.messages.slice(0,e+1):[]}if(Fm){let n=Fm.matchSessionMode(a.mode);if(n){process.stderr.write(n+`
|
|
114
|
+
`);let{getAgentDefinitionsWithOverrides:r,getActiveAgentsFromList:i}=(Bs(),e(pc));r.cache.clear?.();let a=await r(Jl());t(e=>({...e,agentDefinitions:{...a,allAgents:a.allAgents,activeAgents:i(a.allAgents)}}))}}return!n.forkSession&&a.sessionId&&(Ht(rs(a.sessionId),a.fullPath?$u(a.fullPath):null),r&&await Jc()),Au(a,t),_o(n.forkSession?{...a,worktreeSession:void 0}:a),Fm&&Qn(Fm.isCoordinatorMode()?`coordinator`:`normal`),{messages:a.messages,turnInterruptionState:a.turnInterruptionState,agentSetting:a.agentSetting}}catch(e){return q(e),rh(e instanceof Error?`Failed to resume session: ${e.message}`:`Failed to resume session with --print mode`,n.outputFormat),J(1),{messages:[]}}return{messages:await(n.sessionStartHooksPromise??Yf(`startup`))}}function oh(e,t){let n;return n=typeof e==`string`?e.trim()===``?Ai([]):Ai([wt({type:`user`,content:e,uuid:``,session_id:``,message:{role:`user`,content:e},parent_tool_use_id:null})]):e,t.sdkUrl?new xd(t.sdkUrl,n,t.replayUserMessages):new Fu(n,t.replayUserMessages)}async function sh({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(X(`handleOrphanedPermissionResponse: received orphaned control_response for toolUseID=${t} request_id=${i.request_id}`),r.has(t))return X(`handleOrphanedPermissionResponse: skipping duplicate orphaned permission for toolUseID=${t} (already handled)`),!1;let a=await qa(t);return a?(r.add(t),X(`handleOrphanedPermissionResponse: enqueuing orphaned permission for toolUseID=${t} messageID=${a.message.id}`),Y({mode:`orphaned-permission`,value:[],orphanedPermission:{permissionResult:e,assistantMessage:a}}),n?.(),!0):(X(`handleOrphanedPermissionResponse: no unresolved tool_use found for toolUseID=${t} (already resolved in transcript)`),!1)}return!1}function ch(e){return{...e,scope:`dynamic`}}async function lh(e,t,n,r){let{allowed:i,blocked:a}=$a(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 uh(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 uh(e,t,n){let r=new Set(Object.keys(t.configs)),i=new Set(Object.keys(e)),a=[...r].filter(e=>!i.has(e)),o=[...i].filter(e=>!r.has(e)),s=[...r].filter(e=>i.has(e)).filter(n=>{let r=t.configs[n],i=e[n];return!r||!i?!0:!xc(r,ch(i))}),c=[],l=[],u={},d=[...t.clients],f=[...t.tools];for(let e of[...a,...s]){let n=d.find(t=>t.name===e),r=t.configs[e];if(n&&r){if(n.type===`connected`)try{await n.cleanup()}catch(e){q(e)}await Mo(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=ch(n);if(n.type===`sdk`){l.push(t);continue}try{let e=await Jo(t,r);if(d.push(e),e.type===`connected`){let t=await Qs(e);f.push(...t)}else e.type===`failed`&&(u[t]=e.error||`Connection failed`);l.push(t)}catch(e){let n=St(e);u[t]=n.message,q(n)}}let p={};for(let t of i){let n=e[t];n&&(p[t]=ch(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{Jm as runHeadless};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import{n as e,o as t}from"./chunk-DR8-3Aex.js";import{Q as n,Rn as r,b as i,f as a,g as o,h as s,t as c,x as l,xt as u}from"./src-DNHWYkls.js";import{t as d}from"./jsx-runtime-BTgGEFjL.js";import{d as f,f as p}from"./stringUtils-U7kMYMJq.js";import{n as m,r as h}from"./analytics-i6X1et4O.js";import{Ak as g,Dk as _,Mk as v,Nk as y,Ok as b,RT as x,jk as S,kk as C,vw as w}from"./loadAgentsDir-Bz0FfcVt.js";function T(){return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(i,{children:[`An update to our Consumer Terms and Privacy Policy will take effect on `,(0,A.jsx)(i,{bold:!0,children:`October 8, 2025`}),`. You can accept the updated terms today.`]}),(0,A.jsxs)(l,{flexDirection:`column`,children:[(0,A.jsx)(i,{children:`What's changing?`}),(0,A.jsx)(l,{paddingLeft:1,children:(0,A.jsxs)(i,{children:[(0,A.jsx)(i,{children:`· `}),(0,A.jsx)(i,{bold:!0,children:`You can help improve Claude `}),(0,A.jsxs)(i,{children:[`— Allow the use of your chats and coding sessions to train and improve Anthropic AI models. Change anytime in your Privacy Settings (`,(0,A.jsx)(n,{url:`https://claude.ai/settings/data-privacy-controls`}),`).`]})]})}),(0,A.jsx)(l,{paddingLeft:1,children:(0,A.jsxs)(i,{children:[(0,A.jsx)(i,{children:`· `}),(0,A.jsx)(i,{bold:!0,children:`Updates to data retention `}),(0,A.jsx)(i,{children:`— To help us improve our AI models and safety protections, we're extending data retention to 5 years.`})]})})]}),(0,A.jsxs)(i,{children:[`Learn more (`,(0,A.jsx)(n,{url:`https://www.anthropic.com/news/updates-to-our-consumer-terms`}),`) or read the updated Consumer Terms (`,(0,A.jsx)(n,{url:`https://anthropic.com/legal/terms`}),`) and Privacy Policy (`,(0,A.jsx)(n,{url:`https://anthropic.com/legal/privacy`}),`)`]})]})}function E(){return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(i,{children:`We've updated our Consumer Terms and Privacy Policy.`}),(0,A.jsxs)(l,{flexDirection:`column`,gap:1,children:[(0,A.jsx)(i,{children:`What's changing?`}),(0,A.jsxs)(l,{flexDirection:`column`,children:[(0,A.jsx)(i,{bold:!0,children:`Help improve Claude`}),(0,A.jsx)(i,{children:`Allow the use of your chats and coding sessions to train and improve Anthropic AI models. You can change this anytime in Privacy Settings`}),(0,A.jsx)(n,{url:`https://claude.ai/settings/data-privacy-controls`})]}),(0,A.jsxs)(l,{flexDirection:`column`,children:[(0,A.jsx)(i,{bold:!0,children:`How this affects data retention`}),(0,A.jsx)(i,{children:`Turning ON the improve Claude setting extends data retention from 30 days to 5 years. Turning it OFF keeps the default 30-day data retention. Delete data anytime.`})]})]}),(0,A.jsxs)(i,{children:[`Learn more (`,(0,A.jsx)(n,{url:`https://www.anthropic.com/news/updates-to-our-consumer-terms`}),`) or read the updated Consumer Terms (`,(0,A.jsx)(n,{url:`https://anthropic.com/legal/terms`}),`) and Privacy Policy (`,(0,A.jsx)(n,{url:`https://anthropic.com/legal/privacy`}),`)`]})]})}function D({showIfAlreadyViewed:e,location:t,onDone:n}){let[r,c]=(0,k.useState)(null),[u,d]=(0,k.useState)(null);if((0,k.useEffect)(()=>{async function r(){let[r,i]=await Promise.all([C(),b()]),a=i.success?i.data:null;d(a);let o=_(r,i,e);if(c(o),!o){n(`skip_rendering`);return}v(),p(`tengu_grove_policy_viewed`,{location:t,dismissable:a?.notice_is_grace_period})}r()},[e,t,n]),r===null||!r)return null;async function f(e){switch(e){case`accept_opt_in`:await y(!0),p(`tengu_grove_policy_submitted`,{state:!0,dismissable:u?.notice_is_grace_period});break;case`accept_opt_out`:await y(!1),p(`tengu_grove_policy_submitted`,{state:!1,dismissable:u?.notice_is_grace_period});break;case`defer`:p(`tengu_grove_policy_dismissed`,{state:!0});break;case`escape`:p(`tengu_grove_policy_escaped`,{});break}n(e)}let m=u?.domain_excluded?[{label:`Accept terms · Help improve Claude: OFF (for emails with your domain)`,value:`accept_opt_out`}]:[{label:`Accept terms · Help improve Claude: ON`,value:`accept_opt_in`},{label:`Accept terms · Help improve Claude: OFF`,value:`accept_opt_out`}];function h(){if(u?.notice_is_grace_period){f(`defer`);return}f(`escape`)}return(0,A.jsxs)(a,{title:`Updates to Consumer Terms and Policies`,color:`professionalBlue`,onCancel:h,inputGuide:e=>e.pending?(0,A.jsxs)(i,{children:[`Press `,e.keyName,` again to exit`]}):(0,A.jsxs)(s,{children:[(0,A.jsx)(o,{shortcut:`Enter`,action:`confirm`}),(0,A.jsx)(o,{shortcut:`Esc`,action:`cancel`})]}),children:[(0,A.jsxs)(l,{flexDirection:`row`,children:[(0,A.jsx)(l,{flexDirection:`column`,gap:1,flexGrow:1,children:u?.notice_is_grace_period?(0,A.jsx)(T,{}):(0,A.jsx)(E,{})}),(0,A.jsx)(l,{flexShrink:0,children:(0,A.jsx)(i,{color:`professionalBlue`,children:j})})]}),(0,A.jsxs)(l,{flexDirection:`column`,gap:1,children:[(0,A.jsxs)(l,{flexDirection:`column`,children:[(0,A.jsx)(i,{bold:!0,children:`Please select how you'd like to continue`}),(0,A.jsx)(i,{children:`Your choice takes effect immediately upon confirmation.`})]}),(0,A.jsx)(x,{options:[...m,...u?.notice_is_grace_period?[{label:`Not now`,value:`defer`}]:[]],onChange:e=>f(e),onCancel:h})]})]})}function O({settings:e,domainExcluded:t,onDone:r}){let[c,d]=(0,k.useState)(e.grove_enabled);k.useEffect(()=>{p(`tengu_grove_privacy_settings_viewed`,{})},[]),u(async(e,n)=>{if(!t&&(n.tab||n.return||e===` `)){let e=!c;d(e),await y(e)}});let f=(0,A.jsx)(i,{color:`error`,children:`false`});return t?f=(0,A.jsx)(i,{color:`error`,children:`false (for emails with your domain)`}):c&&(f=(0,A.jsx)(i,{color:`success`,children:`true`})),(0,A.jsxs)(a,{title:`Data Privacy`,color:`professionalBlue`,onCancel:r,inputGuide:e=>e.pending?(0,A.jsxs)(i,{children:[`Press `,e.keyName,` again to exit`]}):t?(0,A.jsx)(o,{shortcut:`Esc`,action:`cancel`}):(0,A.jsxs)(s,{children:[(0,A.jsx)(o,{shortcut:`Enter/Tab/Space`,action:`toggle`}),(0,A.jsx)(o,{shortcut:`Esc`,action:`cancel`})]}),children:[(0,A.jsxs)(i,{children:[`Review and manage your privacy settings at`,` `,(0,A.jsx)(n,{url:`https://claude.ai/settings/data-privacy-controls`})]}),(0,A.jsxs)(l,{children:[(0,A.jsx)(l,{width:44,children:(0,A.jsx)(i,{bold:!0,children:`Help improve Claude`})}),(0,A.jsx)(l,{children:f})]})]})}var k,A,j,M=e((()=>{k=t(r(),1),f(),c(),g(),w(),A=d(),j=` _____________
|
|
2
|
+
| \\ \\
|
|
3
|
+
| NEW TERMS \\__\\
|
|
4
|
+
| |
|
|
5
|
+
| ---------- |
|
|
6
|
+
| ---------- |
|
|
7
|
+
| ---------- |
|
|
8
|
+
| ---------- |
|
|
9
|
+
| ---------- |
|
|
10
|
+
| |
|
|
11
|
+
|______________|`}));async function N(e){if(!await S())return e(F),null;let[t,n]=await Promise.all([C(),b()]);if(!t.success)return e(F),null;let r=t.data,i=n.success?n.data:null;async function a(t){if(t===`escape`||t===`defer`){e(`Privacy settings dialog dismissed`,{display:`system`});return}await o()}async function o(){let t=await C();if(!t.success){e(`Unable to retrieve updated privacy settings`,{display:`system`});return}let n=t.data;e(`"Help improve Claude" set to ${n.grove_enabled?`true`:`false`}.`),r.grove_enabled!==null&&r.grove_enabled!==n.grove_enabled&&h(`tengu_grove_policy_toggled`,{state:n.grove_enabled,location:`settings`})}return r.grove_enabled===null?(0,P.jsx)(D,{showIfAlreadyViewed:!0,onDone:a,location:`settings`}):(0,P.jsx)(O,{settings:r,domainExcluded:i?.domain_excluded,onDone:o})}var P,F;e((()=>{r(),M(),m(),g(),P=d(),F=`Review and manage your privacy settings at https://claude.ai/settings/data-privacy-controls`}))();export{N as call};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e}from"./chunk-DR8-3Aex.js";import{_ as t,h as n}from"./debug-CjIaNjpK.js";import{i as ee,t as te}from"./hash-KW-tVnPp.js";import{join as r}from"path";import i from"node:process";import a from"node:path";import o from"node:os";var s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,O,k,A,j,M,N,P,F,I,L,R,ne=e((()=>{s=`command-name`,c=`command-message`,l=`command-args`,u=`bash-input`,d=`bash-stdout`,f=`bash-stderr`,p=`local-command-stdout`,m=`local-command-stderr`,h=`local-command-caveat`,g=[u,d,f,p,m,h],_=`tick`,v=`task-notification`,y=`task-id`,b=`tool-use-id`,x=`task-type`,S=`output-file`,C=`status`,w=`summary`,T=`worktree`,E=`worktreePath`,D=`worktreeBranch`,O=`ultraplan`,k=`remote-review`,A=`remote-review-progress`,j=`teammate-message`,M=`channel-message`,N=`channel`,P=`cross-session-message`,F=`fork-boilerplate`,I=`Your directive: `,L=[`help`,`-h`,`--help`],R=[`list`,`show`,`display`,`current`,`view`,`get`,`check`,`describe`,`print`,`version`,`about`,`status`,`?`]}));function re(e){return e.sort((e,t)=>{let n=t.modified.getTime()-e.modified.getTime();return n===0?t.created.getTime()-e.created.getTime():n})}var ie=e((()=>{}));function ae(e){if(typeof e!=`string`)return!1;let t=e.trim();return t!==``&&t!==`.`&&t!==`..`&&!e.includes(`/`)&&!e.includes(`\\`)&&!e.includes(`\0`)}function z(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);if(!ae(e))throw Error(`Unsafe filename: ${JSON.stringify(e)}`)}var oe=e((()=>{Object.freeze([``,` `,`.`,`..`,` .`,`. `,` ..`,`.. `,`../`,`../foo`,`foo/../bar`,`foo/bar`,`foo\\bar`,`foo\0bar`])}));function se(e,{suffix:t=`nodejs`}={}){return z(e),t&&(e+=`-${t}`),z(e),i.platform===`darwin`?U(e):i.platform===`win32`?W(e):G(e)}var B,V,H,U,W,G,ce=e((()=>{oe(),B=o.homedir(),V=o.tmpdir(),{env:H}=i,U=e=>{let t=a.join(B,`Library`);return{data:a.join(t,`Application Support`,e),config:a.join(t,`Preferences`,e),cache:a.join(t,`Caches`,e),log:a.join(t,`Logs`,e),temp:a.join(V,e)}},W=e=>{let t=H.APPDATA||a.join(B,`AppData`,`Roaming`),n=H.LOCALAPPDATA||a.join(B,`AppData`,`Local`);return{data:a.join(n,e,`Data`),config:a.join(t,e,`Config`),cache:a.join(n,e,`Cache`),log:a.join(n,e,`Log`),temp:a.join(V,e)}},G=e=>{let t=a.basename(B);return{data:a.join(H.XDG_DATA_HOME||a.join(B,`.local`,`share`),e),config:a.join(H.XDG_CONFIG_HOME||a.join(B,`.config`),e),cache:a.join(H.XDG_CACHE_HOME||a.join(B,`.cache`),e),log:a.join(H.XDG_STATE_HOME||a.join(B,`.local`,`state`),e),temp:a.join(V,t,e)}}}));function K(e){let t=e.replace(/[^a-zA-Z0-9]/g,`-`);return t.length<=Y?t:`${t.slice(0,Y)}-${Math.abs(te(e)).toString(36)}`}function q(e){return K(e)}var J,Y,X,le=e((()=>{ce(),t(),ee(),J=se(`claude-cli`),Y=200,X={baseLogs:()=>r(J.cache,q(n().cwd())),errors:()=>r(J.cache,q(n().cwd()),`errors`),messages:()=>r(J.cache,q(n().cwd()),`messages`),mcpLogs:e=>r(J.cache,q(n().cwd()),`mcp-logs-${K(e)}`)}}));function ue(e){return e.replace(Z,``).trim()||e}function de(e){return e.replace(Z,``).trim()}function fe(e){return e.replace(Q,``).trim()}var Z,Q,pe=e((()=>{Z=/<([a-z][\w-]*)(?:\s[^>]*)?>[\s\S]*?<\/\1>\n?/g,Q=/<(ide_opened_file|ide_selection)(?:\s[^>]*)?>[\s\S]*?<\/\1>\n?/g}));function $(){return process.env.CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC?`essential-traffic`:process.env.DISABLE_TELEMETRY?`no-telemetry`:`default`}function me(){return $()===`essential-traffic`}function he(){return $()!==`default`}function ge(){return process.env.CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC?`CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC`:null}var _e=e((()=>{}));export{A,b as B,P as C,m as D,h as E,v as F,ne as G,D as H,x as I,j as L,C as M,w as N,p as O,y as P,g as R,R as S,I as T,E as U,O as V,T as W,N as _,pe as a,s as b,fe as c,ie as d,re as f,M as g,d as h,he as i,k as j,S as k,X as l,f as m,_e as n,ue as o,u as p,me as r,de as s,ge as t,le as u,l as v,F as w,L as x,c as y,_ as z};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e}from"./chunk-DR8-3Aex.js";function t(e,t){e.destroyed||e.write(t)}function n(e){t(process.stdout,e)}function r(e){t(process.stderr,e)}function i(e){console.error(e),process.exit(1)}var a=e((()=>{}));export{n as i,a as n,r,i as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,t}from"./process-CnhUplBr.js";e();export{t as exitWithError};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{a as e}from"./chunk-DR8-3Aex.js";import{Rn as t,Tn as n,b as r,t as i,wn as a,x as o}from"./src-DNHWYkls.js";import{t as s}from"./jsx-runtime-BTgGEFjL.js";import{Gs as c,Ms as l}from"./growthbook-p4aJ_UMv.js";import{F as u,U as d,z as f}from"./debug-CjIaNjpK.js";import{i as p,o as m}from"./platform-BXz_rgpy.js";import{n as h,r as g}from"./analytics-i6X1et4O.js";import{u as _,y as v}from"./startupProfiler-4P7GdVw6.js";import{AP as y,Ac as b,Dc as x,HP as S,Hy as C,Kg as w,UP as T,Vy as E,Zc as D,cb as O,db as k,ef as A,jP as j,jc as M,lb as N,qg as P,sl as F,tf as I,ub as L}from"./loadAgentsDir-Bz0FfcVt.js";import{Xt as R,Zt as z}from"./prompt-CsBCtw4l.js";import{r as B,t as V}from"./xml-E8VMPwdJ.js";import{randomUUID as H}from"crypto";P(),I(),D(),t(),a(),i(),v(),T(),k(),N();var U=s();function W({output:e,fullOutput:t,elapsedTimeSeconds:i,totalLines:a,totalBytes:s,timeoutMs:c,verbose:l}){let u=n(t.trim()),d=n(e.trim()).split(`
|
|
2
|
+
`).filter(e=>e),f=l?u:d.slice(-5).join(`
|
|
3
|
+
`);if(!d.length)return(0,U.jsx)(S,{children:(0,U.jsxs)(L,{children:[(0,U.jsx)(r,{dimColor:!0,children:`Running… `}),(0,U.jsx)(O,{elapsedTimeSeconds:i,timeoutMs:c})]})});let p=a?Math.max(0,a-5):0,m=``;return!l&&s&&a?m=`~${a} lines`:!l&&p>0&&(m=`+${p} lines`),(0,U.jsx)(S,{children:(0,U.jsx)(L,{children:(0,U.jsxs)(o,{flexDirection:`column`,children:[(0,U.jsx)(o,{height:l?void 0:Math.min(5,d.length),flexDirection:`column`,overflow:`hidden`,children:(0,U.jsx)(r,{dimColor:!0,children:f})}),(0,U.jsxs)(o,{flexDirection:`row`,gap:1,children:[m?(0,U.jsx)(r,{dimColor:!0,children:m}):null,(0,U.jsx)(O,{elapsedTimeSeconds:i,timeoutMs:c}),s?(0,U.jsx)(r,{dimColor:!0,children:_(s)}):null]})]})})})}i();function G({input:e,progress:t,verbose:n}){return(0,U.jsxs)(o,{flexDirection:`column`,marginTop:1,children:[(0,U.jsx)(w,{addMargin:!1,param:{text:`<bash-input>${e}</bash-input>`,type:`text`}}),t?(0,U.jsx)(W,{fullOutput:t.fullOutput,output:t.output,elapsedTimeSeconds:t.elapsedTimeSeconds,totalLines:t.totalLines,verbose:n}):A.renderToolUseProgressMessage?.([],{verbose:n,tools:[],terminalSize:void 0})]})}d(),h(),c(),m(),R();function K(){let e=l().defaultShell;return e===`bash`||e===`powershell`?e:p()===`windows`&&z()?`powershell`:`bash`}I(),R(),y(),B();async function q(t,n,r,i,a){let o=z()&&K()===`powershell`;g(`tengu_input_bash`,{powershell:o});let s=M({content:F({inputString:`<bash-input>${t}</bash-input>`,precedingInputBlocks:n})}),c;a({jsx:(0,U.jsx)(G,{input:t,progress:null,verbose:i.options.verbose}),shouldHidePromptInput:!1});try{let n={...i,setToolJSX:e=>{c=e?.jsx}},l=e=>{a({jsx:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(G,{input:t,progress:e.data,verbose:i.options.verbose}),c]}),shouldHidePromptInput:!1,showSpinner:!1})},u=null;o&&(u=(C(),e(E)).PowerShellTool);let d=u??A,f=(u?await u.call({command:t,dangerouslyDisableSandbox:!0},n,void 0,void 0,l):await A.call({command:t,dangerouslyDisableSandbox:!0},n,void 0,void 0,l)).data;if(!f)throw Error(`No result received from shell command`);let p=f.stderr,m=await j(d,{...f,stderr:``},H()),h=typeof m.content==`string`?m.content:V(f.stdout);return{messages:[x(),s,...r,M({content:`<bash-stdout>${h}</bash-stdout><bash-stderr>${V(p)}</bash-stderr>`})],shouldQuery:!1}}catch(e){return e instanceof u?e.interrupted?{messages:[x(),s,b({toolUse:!1}),...r],shouldQuery:!1}:{messages:[x(),s,...r,M({content:`<bash-stdout>${V(e.stdout)}</bash-stdout><bash-stderr>${V(e.stderr)}</bash-stderr>`})],shouldQuery:!1}:{messages:[x(),s,...r,M({content:`<bash-stderr>Command failed: ${V(f(e))}</bash-stderr>`})],shouldQuery:!1}}finally{a(null)}}export{q as processBashCommand};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{n as e}from"./chunk-DR8-3Aex.js";import{s as t,u as n}from"./envUtils-CFG7IQID.js";import{Ht as r,at as i,t as a}from"./state-CUZTq6r0.js";import{Er as o,Ql as s,ha as c,wr as l}from"./growthbook-p4aJ_UMv.js";import{P as u,U as d,_ as f,l as p}from"./debug-CjIaNjpK.js";import{L as m}from"./state-BQkyHx88.js";import{G as h,b as g,y as _}from"./privacyLevel-CRCHhztk.js";import{o as v}from"./log-DVv8YiNo.js";import{A as y,DA as b,Fd as x,HI as S,Na as C,OA as w,TM as T,U as E,UI as D,VN as O,VS as k,Vd as A,WI as j,Zc as M,Zo as N,aN as P,eg as F,jc as I,jf as ee,nE as L,oM as R,qo as z,vl as B,w as V,xl as H,yl as U}from"./loadAgentsDir-Bz0FfcVt.js";import{i as W}from"./xml-E8VMPwdJ.js";import{O as G}from"./sessionTracing-DR8O0686.js";import{n as K}from"./skillUsageTracking-BBTiWOKB.js";import{n as q,t as J}from"./registerSkillHooks-BR7v5qDA.js";import"crypto";function Y(e,t=`loading`){return[`<${_}>${e}</${_}>`,`<${g}>${e}</${g}>`,`<skill-format>true</skill-format>`].join(`
|
|
2
|
+
`)}function X(e,t){return[`<${_}>${e}</${_}>`,`<${g}>/${e}</${g}>`,t?`<command-args>${t}</command-args>`:null].filter(Boolean).join(`
|
|
3
|
+
`)}function Z(e,t){return e.userInvocable===!1&&(e.loadedFrom===`skills`||e.loadedFrom===`plugin`||e.loadedFrom===`mcp`)?Y(e.name,e.progressMessage):X(e.name,t)}async function Q(e,t,n,r,i=[]){let a=z(e,n);if(!a)throw new u(`Unknown command: ${e}`);if(a.type!==`prompt`)throw Error(`Unexpected ${a.type} command. Expected 'prompt' command. Use /${e} directly in the main conversation.`);return $(a,t,r,[],i)}async function $(e,t,r,o=[],s=[],c){if(n(process.env.CLAUDE_CODE_COORDINATOR_MODE)&&!r.agentId){let n=Z(e,t),r=[`Skill "/${e.name}" is available for workers.`];e.description&&r.push(`Description: ${e.description}`),e.whenToUse&&r.push(`When to use: ${e.whenToUse}`);let i=e.allowedTools??[];i.length>0&&r.push(`This skill grants workers additional tool permissions: ${i.join(`, `)}`),r.push(`\nInstruct a worker to use this skill by including "Use the /${e.name} skill" in your Agent prompt. The worker has access to the Skill tool and will receive the skill's content and permissions when it invokes it.`);let a=[{type:`text`,text:r.join(`
|
|
4
|
+
`)}];return{messages:[I({content:n,uuid:c}),I({content:a,isMeta:!0})],shouldQuery:!0,model:e.model,effort:e.effort,command:e}}let u=await e.getPromptForCommand(t,r),d=!D(`hooks`)||j(e.source);if(e.hooks&&d){let t=i();q(r.setAppState,t,e.hooks,e.name,e.type===`prompt`?e.skillRoot:void 0)}let f=e.source?`${e.source}:${e.name}`:e.name,p=u.filter(e=>e.type===`text`).map(e=>e.text).join(`
|
|
5
|
+
|
|
6
|
+
`);a(e.name,f,p,l()?.agentId??null);let m=Z(e,t),h=y(e.allowedTools??[]),g=s.length>0||o.length>0?[...s,...o,...u]:u,_=await w(U(u.filter(e=>e.type===`text`).map(e=>e.text).join(` `),r,null,[],r.messages,`repl_main_thread`,{skipSkillDiscovery:!0}));return{messages:[I({content:m,uuid:c}),I({content:g,isMeta:!0}),..._,B({type:`command_permissions`,allowedTools:h,model:e.model})],shouldQuery:!0,allowedTools:h,model:e.model,effort:e.effort,command:e}}e((()=>{m(),N(),r(),h(),R(),x(),k(),ee(),F(),o(),H(),p(),t(),d(),s(),A(),f(),L(),b(),J(),v(),P(),M(),V(),E(),W(),S(),K(),G(),C(),O(),T(),c()}))();export{Y as formatSkillLoadingMetadata,Q as processPromptSlashCommand};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{s as e,u as t}from"./envUtils-CFG7IQID.js";import{Ht as n,at as r,t as i}from"./state-CUZTq6r0.js";import{Er as a,Ql as o,Yl as s,ha as c,ma as l,wr as u}from"./growthbook-p4aJ_UMv.js";import{P as d,U as f,_ as p,h as m,j as h,l as g,p as _}from"./debug-CjIaNjpK.js";import{L as v,ct as y}from"./state-BQkyHx88.js";import{G as b,b as x,y as S}from"./privacyLevel-CRCHhztk.js";import{o as C,s as w}from"./log-DVv8YiNo.js";import{n as T,r as E}from"./analytics-i6X1et4O.js";import{n as D,t as O}from"./sleep-CC8jykQd.js";import{$M as k,A as ee,Aa as A,Ac as te,Bd as j,DA as ne,Dc as M,Fd as re,H as ie,HI as ae,Hd as oe,Ko as se,Mf as N,Na as ce,Nd as le,OA as ue,Oc as P,Qc as F,RN as I,Rc as L,SM as R,TM as z,U as B,UI as V,US as H,VN as U,VS as de,Vd as fe,WI as pe,Xo as me,Yo as he,Zc as ge,Zo as _e,aM as ve,aN as ye,al as be,bC as xe,eN as Se,eg as Ce,iE as we,jc as W,jf as Te,nE as Ee,nM as De,nl as Oe,oM as ke,rM as Ae,sl as G,tg as je,vl as Me,w as Ne,wc as K,xM as Pe,xl as Fe,yC as Ie,yl as Le,ys as q}from"./loadAgentsDir-Bz0FfcVt.js";import{a as J,i as Re,o as Y}from"./xml-E8VMPwdJ.js";import{A as ze,O as Be,k as Ve}from"./sessionTracing-DR8O0686.js";import{n as He,r as Ue}from"./skillUsageTracking-BBTiWOKB.js";import{n as We,t as Ge}from"./slashCommandParsing-BkTC3GRb.js";import{i as Ke,n as qe,r as Je,t as Ye}from"./registerSkillHooks-BR7v5qDA.js";import{randomUUID as X}from"crypto";v(),_e(),Ke(),n(),b(),T(),ke(),re(),de(),Te(),Ce(),Ae(),a(),Fe(),g(),e(),f(),o(),fe(),p(),Ee(),ne(),Ye(),C(),ye(),ge(),Ne(),B(),Re(),ae(),Ge(),O(),He(),Be(),ce(),U(),xe(),z(),c();var Xe=200,Z=1e4;function Ze(){return!1}function Qe(){if(!Ze())throw Error(`ToolUseContext.options.allowBackgroundForkedSlashCommands is test-only and cannot be enabled outside NODE_ENV=test.`)}async function $e(e,t,n,r,i,a,o){let c=Ie(),u=e.pluginInfo?Y(e.pluginInfo.repository).marketplace:void 0;E(`tengu_slash_command_forked`,{command_name:e.name,invocation_trigger:`user-slash`,...e.pluginInfo&&{_PROTO_plugin_name:e.pluginInfo.pluginManifest.name,...u&&{_PROTO_marketplace_name:u},...A(e.pluginInfo)}});let{skillContent:d,modifiedGetAppState:f,baseAgent:p,promptMessages:m}=await oe(e,t,n),h=e.effort===void 0?p:{...p,effort:e.effort};_(`Executing forked slash command /${e.name} with agent ${h.agentType}`);let g=await n.getAppState();n.options.allowBackgroundForkedSlashCommands===!0&&Qe();let v=!1;if(g.kairosEnabled&&(v=!0),v){let t=De(),r=q(e),i=l(),s=e=>Se({value:e,mode:`prompt`,priority:`later`,isMeta:!0,skipSlashCommands:!0,workload:i}),u=async()=>{if(!o?.runId)return;let e=await Pe({runId:o.runId,rootDir:o.rootDir,priority:`later`,workload:i});for(let t of e)k(t)},d=async e=>{o?.runId&&await R({runId:o.runId,rootDir:o.rootDir,error:e instanceof Error?e.message:String(e)})};return(async()=>{let i=Date.now()+Z;for(;Date.now()<i&&n.getAppState().mcp.clients.some(e=>e.type===`pending`);)await D(Xe);let o=n.options.refreshTools?.()??n.options.tools,l=[];for await(let r of N({agentDefinition:h,promptMessages:m,toolUseContext:{...n,getAppState:f,abortController:t},canUseTool:a,isAsync:!0,querySource:`agent:custom`,model:e.model,availableTools:o,override:{agentId:c}}))l.push(r);let d=j(l,`Command completed`);_(`Background forked command /${r} completed (agent ${c})`),s(`<scheduled-task-result command="/${r}">\n${d}\n</scheduled-task-result>`);try{await u()}catch(e){w(e)}})().catch(async e=>{w(e),s(`<scheduled-task-result command="/${r}" status="failed">\n${e instanceof Error?e.message:String(e)}\n</scheduled-task-result>`),await d(e)}),{messages:[],shouldQuery:!1,command:e,deferAutonomyCompletion:!!o?.runId}}let y=[],b=[],x=`forked-command-${e.name}`,S=0,C=e=>(S++,{type:`progress`,data:{message:e,type:`agent_progress`,prompt:d,agentId:c},parentToolUseID:x,toolUseID:`${x}-${S}`,timestamp:new Date().toISOString(),uuid:X()}),T=()=>{i({jsx:je(b,{tools:n.options.tools,verbose:!1}),shouldHidePromptInput:!1,shouldContinueAnimation:!0,showSpinner:!0})};T();try{for await(let t of N({agentDefinition:h,promptMessages:m,toolUseContext:{...n,getAppState:f},canUseTool:a,isAsync:!1,querySource:`agent:custom`,model:e.model,availableTools:n.options.tools})){y.push(t);let e=be([t]);if(t.type===`assistant`){let r=I(t);r>0&&n.setResponseLength(e=>e+r);let i=e[0];i&&i.type===`assistant`&&(b.push(C(t)),T())}if(t.type===`user`){let t=e[0];t&&t.type===`user`&&(b.push(C(t)),T())}}}finally{i(null)}let O=j(y,`Command completed`);return _(`Forked slash command /${e.name} completed with agent ${c}`),process.env.USER_TYPE===`ant`&&(O=`[ANT-ONLY] API calls: ${s(ve(c))}\n${O}`),{messages:[W({content:G({inputString:`/${q(e)} ${t}`.trim(),precedingInputBlocks:r})}),W({content:`<local-command-stdout>\n${O}\n</local-command-stdout>`})],shouldQuery:!1,command:e,resultText:O}}function et(e){return!/[^a-zA-Z0-9:\-_]/.test(e)}async function tt(e,t,n,r,i,a,o,s,c,l){let u=We(e);if(!u){E(`tengu_input_slash_missing`,{});let e="Commands are in the form `/command [args]`";return{messages:[M(),...r,W({content:G({inputString:e,precedingInputBlocks:t})})],shouldQuery:!1,resultText:e}}let{commandName:d,args:f,isMcp:p}=u,h=p?`mcp`:se().has(d)?d:`custom`;if(!me(d,i.options.commands)){let n=!1;try{await m().stat(`/${d}`),n=!0}catch{}if(et(d)&&!n){E(`tengu_input_slash_invalid`,{input:d});let e=`Unknown skill: ${d}`;return{messages:[M(),...r,W({content:G({inputString:e,precedingInputBlocks:t})}),...f?[P(`Args from unknown skill: ${f}`,`warning`)]:[]],shouldQuery:!1,resultText:e}}let i=X();return y(i),E(`tengu_input_prompt`,{}),Ve(`user_prompt`,{prompt_length:String(e.length),prompt:ze(e),"prompt.id":i}),{messages:[W({content:G({inputString:e,precedingInputBlocks:t}),uuid:o}),...r],shouldQuery:!0}}let{messages:g,shouldQuery:_,allowedTools:v,model:b,effort:x,command:S,resultText:C,nextInput:w,submitNextInput:T,deferAutonomyCompletion:D}=await nt(d,f,a,i,t,n,s,c,o,l);if(g.length===0){let e={input:h};if(S.type===`prompt`&&S.pluginInfo){let{pluginManifest:t,repository:n}=S.pluginInfo,{marketplace:r}=Y(n),i=J(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,A(S.pluginInfo))}return E(`tengu_input_command`,{...e,invocation_trigger:`user-slash`,...process.env.USER_TYPE===`ant`&&{skill_name:d,...S.type===`prompt`&&{skill_source:S.source},...S.loadedFrom&&{skill_loaded_from:S.loadedFrom},...S.kind&&{skill_kind:S.kind}}}),{messages:[],shouldQuery:!1,model:b,nextInput:w,submitNextInput:T,deferAutonomyCompletion:D}}if(g.length===2&&g[1].type===`user`&&typeof g[1].message.content==`string`&&g[1].message.content.startsWith(`Unknown command:`))return e.startsWith(`/var`)||e.startsWith(`/tmp`)||e.startsWith(`/private`)||E(`tengu_input_slash_invalid`,{input:d}),{messages:[M(),...g],shouldQuery:_,allowedTools:v,model:b};let O={input:h};if(S.type===`prompt`&&S.pluginInfo){let{pluginManifest:e,repository:t}=S.pluginInfo,{marketplace:n}=Y(t),r=J(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,A(S.pluginInfo))}E(`tengu_input_command`,{...O,invocation_trigger:`user-slash`,...process.env.USER_TYPE===`ant`&&{skill_name:d,...S.type===`prompt`&&{skill_source:S.source},...S.loadedFrom&&{skill_loaded_from:S.loadedFrom},...S.kind&&{skill_kind:S.kind}}});let k=g.length>0&&g[0]&&F(g[0]);return{messages:_||g.every(Oe)||k?g:[M(),...g],shouldQuery:_,allowedTools:v,model:b,effort:x,resultText:C,nextInput:w,submitNextInput:T,deferAutonomyCompletion:D}}async function nt(e,t,n,r,i,a,o,s,c,l){let u=he(e,r.options.commands);if(u.type===`prompt`&&u.userInvocable!==!1&&Ue(e),u.userInvocable===!1)return{messages:[W({content:G({inputString:`/${e}`,precedingInputBlocks:i})}),W({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=>W({content:e,isMeta:!0})),s=we()&&typeof n==`string`&&n.endsWith(` dismissed`),c=r?.displayArgs??t;e({messages:r?.display===`system`?s?o:[K(Q(u,c)),K(`<local-command-stdout>${n}</local-command-stdout>`),...o]:[W({content:G({inputString:Q(u,c),precedingInputBlocks:i})}),W(n?{content:`<local-command-stdout>${n}</local-command-stdout>`}:{content:`<local-command-stdout>${Je}</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=W({content:G({inputString:Q(u,u.isSensitive&&t.trim()?`***`:t),precedingInputBlocks:i})});try{let n=M(),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?[W({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 H(),{messages:le(r),shouldQuery:!1,command:u}}return{messages:[e,K(`<local-command-stdout>${i.value}</local-command-stdout>`)],shouldQuery:!1,command:u,resultText:i.value}}catch(t){return w(t),{messages:[e,K(`<local-command-stderr>${String(t)}</local-command-stderr>`)],shouldQuery:!1,command:u}}}case`prompt`:try{return u.context===`fork`?await $e(u,t,r,i,n,s??ie,l):await at(u,t,r,i,a,c)}catch(e){return e instanceof h?{messages:[W({content:G({inputString:Q(u,t),precedingInputBlocks:i})}),te({toolUse:!1})],shouldQuery:!1,command:u}:{messages:[W({content:G({inputString:Q(u,t),precedingInputBlocks:i})}),W({content:`<local-command-stderr>${String(e)}</local-command-stderr>`})],shouldQuery:!1,command:u}}}}catch(e){if(e instanceof d)return{messages:[W({content:G({inputString:e.message,precedingInputBlocks:i})})],shouldQuery:!1,command:u};throw e}}function Q(e,t){return L(q(e),t)}function rt(e,t=`loading`){return[`<${S}>${e}</${S}>`,`<${x}>${e}</${x}>`,`<skill-format>true</skill-format>`].join(`
|
|
2
|
+
`)}function it(e,t){return[`<${S}>${e}</${S}>`,`<${x}>/${e}</${x}>`,t?`<command-args>${t}</command-args>`:null].filter(Boolean).join(`
|
|
3
|
+
`)}function $(e,t){return e.userInvocable===!1&&(e.loadedFrom===`skills`||e.loadedFrom===`plugin`||e.loadedFrom===`mcp`)?rt(e.name,e.progressMessage):it(e.name,t)}async function at(e,n,a,o=[],s=[],c){if(t(process.env.CLAUDE_CODE_COORDINATOR_MODE)&&!a.agentId){let t=$(e,n),r=[`Skill "/${e.name}" is available for workers.`];e.description&&r.push(`Description: ${e.description}`),e.whenToUse&&r.push(`When to use: ${e.whenToUse}`);let i=e.allowedTools??[];i.length>0&&r.push(`This skill grants workers additional tool permissions: ${i.join(`, `)}`),r.push(`\nInstruct a worker to use this skill by including "Use the /${e.name} skill" in your Agent prompt. The worker has access to the Skill tool and will receive the skill's content and permissions when it invokes it.`);let a=[{type:`text`,text:r.join(`
|
|
4
|
+
`)}];return{messages:[W({content:t,uuid:c}),W({content:a,isMeta:!0})],shouldQuery:!0,model:e.model,effort:e.effort,command:e}}let l=await e.getPromptForCommand(n,a),d=!V(`hooks`)||pe(e.source);if(e.hooks&&d){let t=r();qe(a.setAppState,t,e.hooks,e.name,e.type===`prompt`?e.skillRoot:void 0)}let f=e.source?`${e.source}:${e.name}`:e.name,p=l.filter(e=>e.type===`text`).map(e=>e.text).join(`
|
|
5
|
+
|
|
6
|
+
`);i(e.name,f,p,u()?.agentId??null);let m=$(e,n),h=ee(e.allowedTools??[]),g=s.length>0||o.length>0?[...s,...o,...l]:l,_=await ue(Le(l.filter(e=>e.type===`text`).map(e=>e.text).join(` `),a,null,[],a.messages,`repl_main_thread`,{skipSkillDiscovery:!0}));return{messages:[W({content:m,uuid:c}),W({content:g,isMeta:!0}),..._,Me({type:`command_permissions`,allowedTools:h,model:e.model})],shouldQuery:!0,allowedTools:h,model:e.model,effort:e.effort,command:e}}export{tt as processSlashCommand};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Fc as e,Gs as t,Mc as n,R as r,Vs as i,Yi as a,ea as o,nt as s}from"./growthbook-p4aJ_UMv.js";import{n as c,t as l}from"./cwd-B2guYBbl.js";import{A as u,L as d,ct as f,j as p}from"./state-BQkyHx88.js";import{d as m,f as h}from"./stringUtils-U7kMYMJq.js";import{n as g,r as _}from"./analytics-i6X1et4O.js";import{Ai as v,DA as y,Mi as b,OA as x,Oc as S,QF as C,Zc as w,Zt as T,eI as E,fC as D,gD as O,jc as k,mD as A,on as j,ra as M,tI as N,ta as P,uC as F,un as I,vl as L,wc as R,xl as z,yl as ee,ys as te,zi as ne}from"./loadAgentsDir-Bz0FfcVt.js";import{A as re,O as ie,k as ae,s as oe,u as se}from"./sessionTracing-DR8O0686.js";import{r as B}from"./outputStyles-hHuIBkRB.js";import{n as V,t as H}from"./slashCommandParsing-BkTC3GRb.js";import{randomUUID as U}from"crypto";d(),B(),e(),s(),c(),o(),t();function W(e){return e===`Agent`?n:e}function G(e){let t=i()?.outputStyle??`default`,n={type:`system`,subtype:`init`,cwd:l(),session_id:p(),tools:e.tools.map(e=>W(e.name)),mcp_servers:e.mcpClients.map(e=>({name:e.name,status:e.type})),model:e.model,permissionMode:e.permissionMode,slash_commands:e.commands.filter(e=>e.userInvocable!==!1).map(e=>e.name),apiKeySource:r().source,betas:u(),claude_code_version:`2.8.4`,output_style:t,agents:e.agents.map(e=>e.agentType),skills:e.skills.filter(e=>e.userInvocable!==!1).map(e=>e.name),plugins:e.plugins.map(e=>({name:e.name,path:e.path,source:e.source})),uuid:U()};return n.fast_mode_state=a(e.model,e.fastMode),n}m(),g(),E(),ie(),y(),A(),F(),oe(),z(),w(),M(),ne(),I();var K={"`":"`",'"':`"`,"<":`>`,"{":`}`,"[":`]`,"(":`)`,"'":`'`};function q(e,t){if(!new RegExp(t,`i`).test(e)||e.startsWith(`/`))return[];let n=[],r=null,i=0,a=e=>!!e&&/[\p{L}\p{N}_]/u.test(e);for(let t=0;t<e.length;t++){let o=e[t];if(r){if(r===`[`&&o===`[`){i=t;continue}if(o!==K[r]||r===`'`&&a(e[t+1]))continue;n.push({start:i,end:t+1}),r=null}else (o===`<`&&t+1<e.length&&/[a-zA-Z/]/.test(e[t+1])||o===`'`&&!a(e[t-1])||o!==`<`&&o!==`'`&&o in K)&&(r=o,i=t)}let o=[],s=RegExp(`\\b${t}\\b`,`gi`),c=e.matchAll(s);for(let t of c){if(t.index===void 0)continue;let r=t.index,i=r+t[0].length;if(n.some(e=>r>=e.start&&r<e.end))continue;let s=e[r-1],c=e[i];s===`/`||s===`\\`||s===`-`||c===`/`||c===`\\`||c===`-`||c===`?`||c===`.`&&a(e[i+1])||o.push({word:t[0],start:r,end:i})}return o}function J(e){return q(e,`ultraplan`)}function ce(e){return q(e,`ultrareview`)}function Y(e){return J(e).length>0}function le(e){let[t]=J(e);if(!t)return e;let n=e.slice(0,t.start),r=e.slice(t.end);return(n+r).trim()?n+t.word.slice(5)+r:``}function X(e){return e.type===`image`&&e.content.length>0}H();function ue(e){let t=e.toLowerCase();return/\b(wtf|wth|ffs|omfg|shit(ty|tiest)?|dumbass|horrible|awful|piss(ed|ing)? off|piece of (shit|crap|junk)|what the (fuck|hell)|fucking? (broken|useless|terrible|awful|horrible)|fuck you|screw (this|you)|so frustrating|this sucks|damn it)\b/.test(t)}function de(e){let t=e.toLowerCase().trim();return t===`continue`?!0:/\b(keep going|go on)\b/.test(t)}d();function fe(e,t,n,r,i,a,o){let s=U();f(s);let c=typeof e==`string`?e:e.find(e=>e.type===`text`)?.text||``;se(c);let l=typeof e==`string`?e:e.findLast(e=>e.type===`text`)?.text||``;return l&&ae(`user_prompt`,{prompt_length:String(l.length),prompt:re(l),"prompt.id":s}),_(`tengu_input_prompt`,{is_negative:ue(c),is_keep_going:de(c)}),t.length>0?{messages:[k({content:[...typeof e==`string`?e.trim()?[{type:`text`,text:e}]:[]:e,...t],uuid:i,imagePasteIds:n.length>0?n:void 0,permissionMode:a,isMeta:o||void 0}),...r],shouldQuery:!0}:{messages:[k({content:e,uuid:i,permissionMode:a,isMeta:o||void 0}),...r],shouldQuery:!0}}w();async function pe({input:e,preExpansionInput:t,mode:n,setToolJSX:r,context:i,pastedContents:a,ideSelection:o,messages:s,setUserInputOnProcessing:c,uuid:l,isAlreadyProcessing:u,querySource:d,canUseTool:f,skipSlashCommands:p,bridgeOrigin:m,isMeta:h,skipAttachments:g,autonomy:_}){let v=typeof e==`string`?e:null,y=v?.startsWith(`/`)&&!p;n===`prompt`&&v!==null&&!h&&!y&&c?.(v),D(`query_process_user_input_base_start`);let b=i.getAppState(),x=await me(e,n,r,i,a,o,s,l,u,d,f,b.toolPermissionContext.mode,p,m,h,g,t,_);if(D(`query_process_user_input_base_end`),!x.shouldQuery)return x;D(`query_hooks_start`);let C=P(e)||``;for await(let t of T(C,b.toolPermissionContext.mode,i,i.requestPrompt))if(t.message?.type!==`progress`){if(t.blockingError)return{messages:[S(`${j(t.blockingError)}\n\nOriginal prompt: ${e}`,`warning`)],shouldQuery:!1,allowedTools:x.allowedTools};if(t.preventContinuation){let e=t.stopReason?`Operation stopped by hook: ${t.stopReason}`:`Operation stopped by hook`;return x.messages.push(k({content:e})),x.shouldQuery=!1,x}if(t.additionalContexts&&t.additionalContexts.length>0&&x.messages.push(L({type:`hook_additional_context`,content:t.additionalContexts.map(Q),hookName:`UserPromptSubmit`,toolUseID:`hook-${U()}`,hookEvent:`UserPromptSubmit`})),t.message)switch(t.message.attachment.type){case`hook_success`:if(!t.message.attachment.content)break;x.messages.push({...t.message,attachment:{...t.message.attachment,content:Q(t.message.attachment.content)}});break;default:x.messages.push(t.message);break}}return D(`query_hooks_end`),x}var Z=1e4;function Q(e){return e.length>Z?`${e.substring(0,Z)}… [output truncated - exceeded ${Z} characters]`:e}async function me(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,g,_,y){let S=null,w=[],T=[],E=e;if(typeof e==`string`)S=e;else if(e.length>0){D(`query_image_processing_start`);let t=[];for(let n of e)if(n.type===`image`){let e=await N(n);if(e.dimensions){let t=C(e.dimensions);t&&T.push(t)}t.push(e.block)}else t.push(n);E=t,D(`query_image_processing_end`);let n=t[t.length-1];n?.type===`text`?(S=n.text,w=t.slice(0,-1)):w=t}if(S===null&&t!==`prompt`)throw Error(`Mode: ${t} requires a string input.`);let A=i?Object.values(i).filter(X):[],j=A.map(e=>e.id),M=i?await O(i):new Map;D(`query_pasted_image_processing_start`);let P=await Promise.all(A.map(async e=>{let t={type:`image`,source:{type:`base64`,media_type:e.mediaType||`image/png`,data:e.content}};return h(`tengu_pasted_image_resize_attempt`,{original_size_bytes:e.content.length}),{resized:await N(t),originalDimensions:e.dimensions,sourcePath:e.sourcePath??M.get(e.id)}})),F=[];for(let{resized:e,originalDimensions:t,sourcePath:n}of P){if(e.dimensions){let t=C(e.dimensions,n);t&&T.push(t)}else if(t){let e=C(t,n);e&&T.push(e)}else n&&T.push(`[Image source: ${n}]`);F.push(e.block)}D(`query_pasted_image_processing_end`);let I=f;if(p&&S!==null&&S.startsWith(`/`)){let e=V(S),t=e?v(e.commandName,r.options.commands):void 0;if(t){let n=b(t,e?.args??``);if(n.ok)I=!1;else{let e=n.reason??`/${te(t)} isn't available over Remote Control.`;return{messages:[k({content:S,uuid:s}),R(`<local-command-stdout>${e}</local-command-stdout>`)],shouldQuery:!1,resultText:e}}}}if(t===`prompt`&&!r.options.isNonInteractiveSession&&S!==null&&!I&&!S.startsWith(`/`)&&!r.getAppState().ultraplanSessionUrl&&!r.getAppState().ultraplanLaunching&&Y(_??S)){h(`tengu_ultraplan_keyword`,{});let e=le(S).trim(),{processSlashCommand:t}=await import(`./processSlashCommand-_oJs6_w8.js`);return $(await t(`/ultraplan ${e}`,w,F,[],r,n,s,c,u,y),T)}let L=!g&&S!==null&&(t!==`prompt`||I||!S.startsWith(`/`));D(`query_attachment_loading_start`);let z=L?await x(ee(S,r,a??null,[],o,l)):[];if(D(`query_attachment_loading_end`),S!==null&&t===`bash`){let{processBashCommand:e}=await import(`./processBashCommand-NL0YEUqW.js`);return $(await e(S,w,z,r,n),T)}if(S!==null&&!I&&S.startsWith(`/`)){let{processSlashCommand:e}=await import(`./processSlashCommand-_oJs6_w8.js`);return $(await e(S,w,F,z,r,n,s,c,u,y),T)}if(S!==null&&t===`prompt`){let e=S.trim(),t=z.find(e=>e.attachment.type===`agent_mention`);if(t){let n=`@agent-${t.attachment.agentType}`,r=e===n;h(`tengu_subagent_at_mention`,{is_subagent_only:r,is_prefix:e.startsWith(n)&&!r})}}return $(fe(E,F,j,z,s,d,m),T)}function $(e,t){return t.length>0&&e.messages.push(k({content:t.map(e=>({type:`text`,text:e})),isMeta:!0})),e}export{G as a,ce as i,X as n,W as o,J as r,pe as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e}from"./chunk-DR8-3Aex.js";import{n as t,s as n}from"./envUtils-CFG7IQID.js";import{basename as r,join as i,resolve as a}from"path";import{existsSync as o,mkdirSync as s,readFileSync as c,realpathSync as l,writeFileSync as u}from"fs";import{createHash as d}from"crypto";import{execFileSync as f}from"child_process";function p(){return i(t(),`skill-learning`)}function m(){return i(p(),`projects.json`)}function h(e){return e===j?i(p(),`global`):i(p(),`projects`,e)}function g(e){return i(h(e),`project.json`)}function _(e,t){if(F.has(e)&&F.delete(e),F.set(e,t),F.size>N){let e=F.size-P,t=F.keys();for(let n=0;n<e;n++){let e=t.next();if(e.done)break;F.delete(e.value)}}}function v(e=process.cwd()){let t=F.get(e);if(t){F.delete(e),F.set(e,t);let n=Date.now();return n-L>I&&(L=n,S(t)),t}let n=b(e);return _(e,n),S(n),L=Date.now(),n}function y(){let e=C(m());return Object.values(e.projects).sort((e,t)=>e.projectName.localeCompare(t.projectName))}function b(e){let t=process.env.CLAUDE_PROJECT_DIR?.trim();if(t){let n=E(t);return x({source:`claude_project_dir`,scope:`project`,cwd:e,projectRoot:n,identity:`claude-project-dir:${n}`,projectName:r(n)||`project`})}let n=T([`remote`,`get-url`,`origin`],e);if(n){let t=T([`rev-parse`,`--show-toplevel`],e),r=D(n);return x({source:`git_remote`,scope:`project`,cwd:e,projectRoot:E(t||e),gitRemote:r,identity:`git-remote:${r}`,projectName:O(r)})}let i=T([`rev-parse`,`--show-toplevel`],e);if(i){let t=E(i);return x({source:`git_root`,scope:`project`,cwd:e,projectRoot:t,identity:`git-root:${t}`,projectName:r(t)||`project`})}return x({source:`global`,scope:`global`,cwd:e,projectRoot:void 0,identity:`global`,projectName:M})}function x(e){let t=e.scope===`global`?j:k(e.identity);return{projectId:t,projectName:e.projectName,scope:e.scope,source:e.source,cwd:E(e.cwd),projectRoot:e.projectRoot,gitRemote:e.gitRemote,storageDir:h(t)}}function S(e){let t=new Date().toISOString(),n=m(),r=C(n),i=r.projects[e.projectId],a={...e,firstSeenAt:i?.firstSeenAt??t,lastSeenAt:t};r.projects[e.projectId]=a,r.updatedAt=t,s(e.storageDir,{recursive:!0}),s(p(),{recursive:!0}),w(n,r),w(g(e.projectId),a)}function C(e){if(!o(e))return{version:A,updatedAt:new Date(0).toISOString(),projects:{}};try{let t=JSON.parse(c(e,`utf8`));if(t.version===A&&typeof t.projects==`object`&&t.projects)return{version:A,updatedAt:typeof t.updatedAt==`string`?t.updatedAt:new Date(0).toISOString(),projects:t.projects}}catch{}return{version:A,updatedAt:new Date(0).toISOString(),projects:{}}}function w(e,t){u(e,`${JSON.stringify(t,null,2)}\n`,`utf8`)}function T(e,t){try{return f(`git`,[`-C`,t,...e],{encoding:`utf8`,stdio:[`ignore`,`pipe`,`ignore`]}).trim()||null}catch{return null}}function E(e){let t=a(e);try{return l.native(t).normalize(`NFC`)}catch{return t.normalize(`NFC`)}}function D(e){let t=e.trim().replace(/\\/g,`/`);return t=t.replace(/\.git$/i,``),t=t.replace(/\/+$/g,``),t.toLowerCase()}function O(e){return e.match(/[:/]([^/:]+?)(?:\.git)?$/)?.[1]||`project`}function k(e){return`project-${d(`sha256`).update(e).digest(`hex`).slice(0,16)}`}var A,j,M,N,P,F,I,L,R=e((()=>{n(),A=1,j=`global`,M=`Global`,N=32,P=24,F=new Map,I=300*1e3,L=0}));export{R as a,p as i,h as n,y as o,m as r,v as s,g as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e,i as t,n,o as r,r as i,s as a,t as o}from"./projectContext-B21hXj9q.js";e();export{o as getProjectContextPath,n as getProjectStorageDir,i as getProjectsRegistryPath,t as getSkillLearningRootDir,r as listKnownProjects,a as resolveProjectContext};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as e,r as t}from"./prompt-CsBCtw4l.js";t();export{e as isDeferredTool};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Go as e,zo as t}from"./loadAgentsDir-Bz0FfcVt.js";e();export{t as clearPromptCache};
|