@readmagic/workmate 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/AddWorkspaceDirectory-BSLHrjbt.js +1 -0
- package/dist/chunks/App-DY5O6IKw.js +1 -0
- package/dist/chunks/ApproveApiKey-BEzfC6r3.js +1 -0
- package/dist/chunks/ApproveApiKey-DfAPwDix.js +1 -0
- package/dist/chunks/AssistantSessionChooser-Ce3PraaD.js +1 -0
- package/dist/chunks/BackgroundTasksDialog-Dvhcgahe.js +2 -0
- package/dist/chunks/BypassPermissionsModeDialog-B68V1bCq.js +1 -0
- package/dist/chunks/ClaudeMdExternalIncludesDialog-BV7HHcgL.js +1 -0
- package/dist/chunks/ClaudeMdExternalIncludesDialog-CTWhpIm8.js +1 -0
- package/dist/chunks/ConsoleOAuthFlow-CU5fCPKq.js +1 -0
- package/dist/chunks/DesktopHandoff-BRbU4is4.js +1 -0
- package/dist/chunks/Dialog-vfLXEPed.js +1 -0
- package/dist/chunks/DiffDialog-CBluIK-x.js +6 -0
- package/dist/chunks/Doctor-B0CRtxi2.js +1 -0
- package/dist/chunks/Doctor-WxNv49HC.js +3 -0
- package/dist/chunks/ExitFlow-CRPgptCN.js +2 -0
- package/dist/chunks/Feedback-CEtzaLr3.js +2 -0
- package/dist/chunks/Grove--kttLxvs.js +11 -0
- package/dist/chunks/Grove-CelgLWH4.js +1 -0
- package/dist/chunks/HybridTransport-BgV5_7Az.js +4 -0
- package/dist/chunks/InvalidConfigDialog-DCGwXW_p.js +1 -0
- package/dist/chunks/InvalidSettingsDialog-jTwsdXWr.js +1 -0
- package/dist/chunks/ListItem-vfLXEPed.js +1 -0
- package/dist/chunks/MCPConnectionManager-BX0LMz9J.js +1 -0
- package/dist/chunks/McpParsingWarnings-WQrWJeWP.js +1 -0
- package/dist/chunks/MessageSelector-_UZB8cGb.js +3 -0
- package/dist/chunks/Messages-jCoW_1Rr.js +11 -0
- package/dist/chunks/Onboarding-BoIVNCgc.js +1 -0
- package/dist/chunks/OverageCreditUpsell-1FCN8bH3.js +1 -0
- package/dist/chunks/PermissionDialog-0ya1CU5k.js +1 -0
- package/dist/chunks/PluginSettings-BD9JLV9-.js +17 -0
- package/dist/chunks/PressEnterToContinue-Dl9Hg9Mf.js +1 -0
- package/dist/chunks/PromptInputFooterSuggestions-CrGST0Cq.js +1 -0
- package/dist/chunks/PromptInputHelpMenu-B2TDpbpw.js +1 -0
- package/dist/chunks/QueryEngine-D2HUnwmU.js +1 -0
- package/dist/chunks/REPL-BV4WyYMg.js +142 -0
- package/dist/chunks/REPL-DcpN3MRC.js +1 -0
- package/dist/chunks/RemoteCallout-DS_EV6Fh.js +1 -0
- package/dist/chunks/RemoteSessionManager-Tx1N2uVL.js +2 -0
- package/dist/chunks/ResumeConversation-Cw3vP4G8.js +1 -0
- package/dist/chunks/SSETransport-BXiEBMpb.js +4 -0
- package/dist/chunks/SearchBox-vfLXEPed.js +1 -0
- package/dist/chunks/SearchExtraToolsTool-D3VOFq9R.js +1 -0
- package/dist/chunks/Settings-ns6mRsDc.js +2 -0
- package/dist/chunks/TeleportProgress-CcDzMC5L.js +1 -0
- package/dist/chunks/TeleportRepoMismatchDialog-DZbxl4sD.js +1 -0
- package/dist/chunks/TeleportResumeWrapper-EowJO5nm.js +1 -0
- package/dist/chunks/ThemePicker-BYbChJpu.js +1 -0
- package/dist/chunks/TrustDialog-DA3YTk_k.js +1 -0
- package/dist/chunks/TungstenTool-Cb7gJvq4.js +1 -0
- package/dist/chunks/TungstenTool-CxMQVCuF.js +1 -0
- package/dist/chunks/ValidationErrorsList-Cx-hoRwG.js +2 -0
- package/dist/chunks/WelcomeV2-BTfttGcv.js +1 -0
- package/dist/chunks/add-dir-CWt69NAZ.js +1 -0
- package/dist/chunks/agentDisplay-CQ4mZWFH.js +1 -0
- package/dist/chunks/agents-C6jzKOit.js +2 -0
- package/dist/chunks/agents-D4clhuCl.js +103 -0
- package/dist/chunks/ajv-5vMo9UcX.js +8 -0
- package/dist/chunks/allErrors-HMPqE0jK.js +1 -0
- package/dist/chunks/analytics-BotDBGh0.js +1 -0
- package/dist/chunks/ant-9Z5bppVC.js +1 -0
- package/dist/chunks/api-L2IgleTV.js +1 -0
- package/dist/chunks/api-TgV7fl9V.js +1 -0
- package/dist/chunks/asciicast-DYbkzGCN.js +1 -0
- package/dist/chunks/asciicast-n-BBfgDq.js +4 -0
- package/dist/chunks/assistant-BA9_Mo9U.js +1 -0
- package/dist/chunks/assistant-BiNOSla3.js +1 -0
- package/dist/chunks/assistant-YvbVKjVh.js +1 -0
- package/dist/chunks/attributionHooks-CUAoGkU6.js +1 -0
- package/dist/chunks/attributionTrailer-oKKrF3z8.js +1 -0
- package/dist/chunks/auth-CEig4Gxp.js +1 -0
- package/dist/chunks/auth-CbGDlhyO.js +1 -0
- package/dist/chunks/auth-DHyCIxCk.js +15 -0
- package/dist/chunks/autoMode-Db4QrgFr.js +45 -0
- package/dist/chunks/autoModeDenials-BxNzGJdR.js +1 -0
- package/dist/chunks/autonomy-BkAMA7du.js +1 -0
- package/dist/chunks/autonomy-D4Vy-RPQ.js +15 -0
- package/dist/chunks/autonomyPanel-EjfO8jvg.js +1 -0
- package/dist/chunks/axios-BHBm_hhU.js +1 -0
- package/dist/chunks/axios-DaWTGg7G.js +16 -0
- package/dist/chunks/backgroundHousekeeping-BNEKWHhH.js +1 -0
- package/dist/chunks/backgroundHousekeeping-hDDE8mJC.js +17 -0
- package/dist/chunks/banner-hD6wZygx.js +2 -0
- package/dist/chunks/base64-js-0wLHn8zB.js +1 -0
- package/dist/chunks/bedrockClient-DxE_mHFI.js +15 -0
- package/dist/chunks/bg-BzG63WOm.js +1 -0
- package/dist/chunks/bg-DQ0Q3Qv-.js +9 -0
- package/dist/chunks/branch-CeQ9IyZk.js +3 -0
- package/dist/chunks/break-cache-Bd0clV2N.js +8 -0
- package/dist/chunks/bridge-yerAiaK2.js +2 -0
- package/dist/chunks/bridgeConfig-CCtXe8ak.js +1 -0
- package/dist/chunks/bridgeConfig-D5dB38xD.js +1 -0
- package/dist/chunks/bridgeEnabled--F-6TUi4.js +1 -0
- package/dist/chunks/bridgeEnabled-DKX8-T_H.js +1 -0
- package/dist/chunks/bridgeMain--R1HFbOv.js +68 -0
- package/dist/chunks/bridgeMain-d06JByZn.js +1 -0
- package/dist/chunks/bridgeMessaging-CqbLTDcx.js +1 -0
- package/dist/chunks/bridgePointer-W_jdQ8zf.js +1 -0
- package/dist/chunks/browser-Bd7GeBH1.js +1 -0
- package/dist/chunks/btw-CVGRmL9a.js +1 -0
- package/dist/chunks/bundledMode--fG1S62b.js +1 -0
- package/dist/chunks/caches-BtmAri4e.js +3 -0
- package/dist/chunks/caches-BuTIAOtY.js +1 -0
- package/dist/chunks/capacityWake-CV_x9H8j.js +1 -0
- package/dist/chunks/ccrClient-HqMi5Kfu.js +1 -0
- package/dist/chunks/checksum-DgbnMdM-.js +1 -0
- package/dist/chunks/classPrivateFieldSet2-D4U5K-I3.js +1 -0
- package/dist/chunks/classPrivateMethodInitSpec-BXQD0Vh4.js +1 -0
- package/dist/chunks/claudeDesktop-aUMx06RK.js +1 -0
- package/dist/chunks/clear-C6nRzIQE.js +1 -0
- package/dist/chunks/cliLaunch-2AUoMnqx.js +1 -0
- package/dist/chunks/client-BeET1hnC.js +1 -0
- package/dist/chunks/client-DchQnIJD.js +36 -0
- package/dist/chunks/client-DvAL7lY8.js +8 -0
- package/dist/chunks/color-DXI_4ibU.js +1 -0
- package/dist/chunks/color-convert-p91EwGT7.js +1 -0
- package/dist/chunks/commands-VjcG4qFq.js +1 -0
- package/dist/chunks/commitAttribution-Cm40fdNU.js +2 -0
- package/dist/chunks/commitAttribution-Lb3qUlAR.js +1 -0
- package/dist/chunks/compact-DPTVpJ4D.js +2 -0
- package/dist/chunks/completionCache-BQaLkB4d.js +4 -0
- package/dist/chunks/completionCache-CW8lKIgy.js +1 -0
- package/dist/chunks/config-0cRberzR.js +1 -0
- package/dist/chunks/config-BSXLgwpD.js +1 -0
- package/dist/chunks/config-BrxKpHpR.js +1 -0
- package/dist/chunks/config-C7YHKCPV.js +3 -0
- package/dist/chunks/config-CLmFk-5V.js +1 -0
- package/dist/chunks/connectHeadless-CqRoEtrg.js +1 -0
- package/dist/chunks/context-C_cKrBUn.js +1 -0
- package/dist/chunks/context-noninteractive-DnH6Q9Lu.js +54 -0
- package/dist/chunks/context-noninteractive-rUZ3ydmJ.js +1 -0
- package/dist/chunks/controlMessageCompat-IFu4Gc1y.js +1 -0
- package/dist/chunks/conversation-GJxfkr6M.js +1 -0
- package/dist/chunks/conversation-oK3aFzqO.js +1 -0
- package/dist/chunks/createSSHSession--bWmmIk9.js +6 -0
- package/dist/chunks/createSession-DIr4sUp6.js +1 -0
- package/dist/chunks/createSession-DM4acqaC.js +1 -0
- package/dist/chunks/cron-3LntnnhJ.js +1 -0
- package/dist/chunks/crossProjectResume-DKrtjTpm.js +40 -0
- package/dist/chunks/cwd-BuJhkTrc.js +1 -0
- package/dist/chunks/cwd-D-tY2NKc.js +1 -0
- package/dist/chunks/daemon-B9lBPdBJ.js +2 -0
- package/dist/chunks/dangerousBackend-DwcP0P08.js +1 -0
- package/dist/chunks/datadog-ByS7LGGa.js +1 -0
- package/dist/chunks/datadog-DNCsyfSO.js +1 -0
- package/dist/chunks/debug-DzZUT2Wv.js +1 -0
- package/dist/chunks/debug-IKW-jE7K.js +39 -0
- package/dist/chunks/debugUtils-D2981c0Z.js +1 -0
- package/dist/chunks/defineProperty-C-QyHrDq.js +1 -0
- package/dist/chunks/desktop-B5cvrcOQ.js +1 -0
- package/dist/chunks/detached-rfIUyc-B.js +5 -0
- package/dist/chunks/detect-libc-CxbBtWJu.js +1 -0
- package/dist/chunks/detectRepository-6nw-Aw3v.js +1 -0
- package/dist/chunks/detectRepository-ReZ0Fz8Z.js +1 -0
- package/dist/chunks/diff-cXAp9cNN.js +1 -0
- package/dist/chunks/directoryCompletion-DBM2o5kx.js +1 -0
- package/dist/chunks/dist-CXlEpGqr.js +20 -0
- package/dist/chunks/dist-DESLAofA.js +1 -0
- package/dist/chunks/dist-DIee4wq1.js +29 -0
- package/dist/chunks/dist-Dopnn8wS.js +5 -0
- package/dist/chunks/dist-es-5t7v8oaj.js +1 -0
- package/dist/chunks/dist-es-BF6bR-Ik.js +2 -0
- package/dist/chunks/dist-es-BIjDeceU.js +1 -0
- package/dist/chunks/dist-es-BOPBJQo3.js +1 -0
- package/dist/chunks/dist-es-Bfr4TzQe.js +3 -0
- package/dist/chunks/dist-es-Byxccz_-.js +1 -0
- package/dist/chunks/dist-es-C-OjW2Ao.js +1 -0
- package/dist/chunks/dist-es-C3reqy7X.js +1 -0
- package/dist/chunks/dist-es-C7vygWzp.js +1 -0
- package/dist/chunks/dist-es-CEk66gUu.js +1 -0
- package/dist/chunks/dist-es-CIULjvtA2.js +1 -0
- package/dist/chunks/dist-es-CMtO44xC.js +1 -0
- package/dist/chunks/dist-es-CQMt6zRM.js +1 -0
- package/dist/chunks/dist-es-CYPVg66r.js +9 -0
- package/dist/chunks/dist-es-Cd_AeqMK.js +6 -0
- package/dist/chunks/dist-es-Cgsa8pb82.js +1 -0
- package/dist/chunks/dist-es-Cwru7c2B2.js +1 -0
- package/dist/chunks/dist-es-D1Y8zSMI.js +1 -0
- package/dist/chunks/dist-es-D1wHe_zh.js +1 -0
- package/dist/chunks/dist-es-DKFm0FJ7.js +1 -0
- package/dist/chunks/dist-es-DKIwwJME.js +1 -0
- package/dist/chunks/dist-es-DNFTCbrP.js +1 -0
- package/dist/chunks/dist-es-DXIR5NLi2.js +1 -0
- package/dist/chunks/dist-es-DelBIxNM.js +1 -0
- package/dist/chunks/dist-es-DmdZmEJ-.js +1 -0
- package/dist/chunks/dist-es-Gt_DpXlP.js +1 -0
- package/dist/chunks/dist-es-gUzZ_7Vf.js +1 -0
- package/dist/chunks/dist-es-kj-F5A132.js +1 -0
- package/dist/chunks/dist-es-yHGBqhBe.js +1 -0
- package/dist/chunks/doctor-CTMHXZvQ.js +1 -0
- package/dist/chunks/earlyInput-BTC_Wucv.js +2 -0
- package/dist/chunks/earlyInput-xcoTbKQn.js +1 -0
- package/dist/chunks/effort-Br8KKHdx.js +9 -0
- package/dist/chunks/entry-4lIRMrLI.js +14 -0
- package/dist/chunks/envLessBridgeConfig-CGuIxFzJ.js +1 -0
- package/dist/chunks/envLessBridgeConfig-D_Jg4fJy.js +1 -0
- package/dist/chunks/envUtils-DSxRz_kt.js +1 -0
- package/dist/chunks/esm-BYnFh4pG.js +1 -0
- package/dist/chunks/esm-Bx6rTxIs.js +1 -0
- package/dist/chunks/esm-C367Cyo-.js +1 -0
- package/dist/chunks/esm-C8Zkk1Ux.js +1 -0
- package/dist/chunks/esm-CGx9qY3q.js +56 -0
- package/dist/chunks/esm-CXM9jqO_.js +1 -0
- package/dist/chunks/esm-CXczu_-W.js +1 -0
- package/dist/chunks/esm-CXt5K8Xt.js +1 -0
- package/dist/chunks/esm-Cb-L4oAk.js +1 -0
- package/dist/chunks/esm-D6ZZCdtk.js +1 -0
- package/dist/chunks/esm-DhRjocaU.js +1 -0
- package/dist/chunks/esm-DklLYEuz.js +1 -0
- package/dist/chunks/esm-IYgGg4wR.js +1 -0
- package/dist/chunks/esm-lWlUmoUA.js +1 -0
- package/dist/chunks/esm-lyfry1WB.js +10 -0
- package/dist/chunks/esm-wGnzjq4Z.js +1 -0
- package/dist/chunks/event-streams-C0Zy0Uqv.js +1 -0
- package/dist/chunks/event-streams-DoqJmjFN.js +1 -0
- package/dist/chunks/eventLoopStallDetector-Cg_RXU1q.js +1 -0
- package/dist/chunks/execAsync-Bv2yxuGe.js +1 -0
- package/dist/chunks/execFileNoThrow-COKYqVQj.js +34 -0
- package/dist/chunks/execSyncWrapper-DZJ3tNWF.js +1 -0
- package/dist/chunks/exit-BOhGfSlm.js +2 -0
- package/dist/chunks/exit-Z9oWrqE4.js +1 -0
- package/dist/chunks/extra-usage-BS4aVOt5.js +1 -0
- package/dist/chunks/extra-usage-DtAIhW74.js +1 -0
- package/dist/chunks/extra-usage-core-CdL1ltqq.js +1 -0
- package/dist/chunks/extra-usage-noninteractive-DxxRI0Yx.js +1 -0
- package/dist/chunks/extraUsage-BYZdi44Y.js +1 -0
- package/dist/chunks/extractMemories-C4f9JWuI.js +1 -0
- package/dist/chunks/fast-B0OB4x7K.js +1 -0
- package/dist/chunks/fast-DKqiojzf.js +1 -0
- package/dist/chunks/featureCheck-CrJeuheQ.js +1 -0
- package/dist/chunks/featureCheck-HslM03dr.js +1 -0
- package/dist/chunks/feedback-yB19xph5.js +1 -0
- package/dist/chunks/figures-5ThXQEtq.js +1 -0
- package/dist/chunks/file-D1cN3LMK.js +12 -0
- package/dist/chunks/fileStateCache-DDW5toIs.js +1 -0
- package/dist/chunks/files-DAzGtmzz.js +2 -0
- package/dist/chunks/firstPartyEventLogger-CdUpe6Lh.js +1 -0
- package/dist/chunks/firstPartyEventLogger-hU-LPkje.js +5 -0
- package/dist/chunks/flushGate-ZFr8yv7F.js +1 -0
- package/dist/chunks/foundry-sdk-BdeF2aBu.js +1 -0
- package/dist/chunks/fpsMetrics-Cf_hdtiJ.js +1 -0
- package/dist/chunks/from-CgDRRLiX.js +4 -0
- package/dist/chunks/gemini-DqAv8_GY.js +1 -0
- package/dist/chunks/generateRecap-lO2PDlx8.js +1 -0
- package/dist/chunks/generateSessionName-48veu5dv.js +1 -0
- package/dist/chunks/genericProcessUtils-F1Qcb1sO.js +23 -0
- package/dist/chunks/getMachineId-bsd-Cut1kHoA.js +1 -0
- package/dist/chunks/getMachineId-darwin-CsRhaP3y.js +2 -0
- package/dist/chunks/getMachineId-linux-Bd7UBNRQ.js +1 -0
- package/dist/chunks/getMachineId-unsupported-vFGP8E_8.js +1 -0
- package/dist/chunks/getMachineId-win-DamF2CH_.js +1 -0
- package/dist/chunks/git-BE_FiJZp.js +1 -0
- package/dist/chunks/git-tyaWOgRL.js +6 -0
- package/dist/chunks/githubRepoPathMapping-BlR0BphY.js +1 -0
- package/dist/chunks/goal-Bn8Kz2Dp.js +3 -0
- package/dist/chunks/graceful-fs-DDVg0cja.js +2 -0
- package/dist/chunks/grok-DhnO_KDC.js +1 -0
- package/dist/chunks/grove-DotW04-v.js +7 -0
- package/dist/chunks/hash-Tu-My5Vp.js +1 -0
- package/dist/chunks/heapdump-DkZSKNbp.js +5 -0
- package/dist/chunks/help-DU_BcZtU.js +1 -0
- package/dist/chunks/hooks-BTMWE5Qx.js +79 -0
- package/dist/chunks/hooks-DONAb_nq.js +1 -0
- package/dist/chunks/hostGuard-Dh296c6q.js +1 -0
- package/dist/chunks/inboundAttachments-BcEgi49j.js +1 -0
- package/dist/chunks/inboundAttachments-DVs3_m48.js +1 -0
- package/dist/chunks/index.min-D75yiGLN.js +1 -0
- package/dist/chunks/initReplBridge-D0Xec8S-.js +1 -0
- package/dist/chunks/install-BkfXeXpv.js +1 -0
- package/dist/chunks/instinctParser-Dt-lqnDe.js +1 -0
- package/dist/chunks/instrumentation-H0XRS1yG.js +21 -0
- package/dist/chunks/intl-cKc-V6Mq.js +1 -0
- package/dist/chunks/isObject-C6qM3WEW.js +1 -0
- package/dist/chunks/isSymbol-BO6cdPI7.js +1 -0
- package/dist/chunks/job-DKtLkF8V.js +2 -0
- package/dist/chunks/json-bigint-bonnP-Hz.js +8 -0
- package/dist/chunks/jsx-runtime-Bb4Xn-E0.js +1 -0
- package/dist/chunks/jws-BscXOT9I.js +3 -0
- package/dist/chunks/jwtUtils-C-ojmb8W.js +1 -0
- package/dist/chunks/keybindings-ez51eHHp.js +2 -0
- package/dist/chunks/language-BuRSO2sR.js +1 -0
- package/dist/chunks/language-Da4KNbjm.js +1 -0
- package/dist/chunks/launchAgentsPlatform-BQyPdrHp.js +1 -0
- package/dist/chunks/launchCommand-1qkTCKpf.js +1 -0
- package/dist/chunks/launchLocalMemory-CWHAj7CX.js +3 -0
- package/dist/chunks/launchLocalVault-D8iJdtsP.js +3 -0
- package/dist/chunks/launchMemoryStores-W7jWG2uH.js +1 -0
- package/dist/chunks/launchOnboarding-q__LaLy1.js +8 -0
- package/dist/chunks/launchSchedule-BWi9F5vh.js +1 -0
- package/dist/chunks/launchSkillStore-4wd4MQBc.js +1 -0
- package/dist/chunks/launchTeleport-BlCf2QM_.js +3 -0
- package/dist/chunks/launchVault-C7u7LZV7.js +1 -0
- package/dist/chunks/lazySchema-uxlVVNM1.js +1 -0
- package/dist/chunks/lib-BSzUGQb_.js +2 -0
- package/dist/chunks/lib-BlVGipXx.js +14 -0
- package/dist/chunks/lib-rQZENxQg.js +8 -0
- package/dist/chunks/loadAgentsDir-Dgd-fzNt.js +1 -0
- package/dist/chunks/loadAgentsDir-nzr38hai.js +3990 -0
- package/dist/chunks/loadPluginHooks-z1-zvBLw.js +1 -0
- package/dist/chunks/loadSso-DSxfVpgX.js +1 -0
- package/dist/chunks/localSearch-B-L_ldos.js +1 -0
- package/dist/chunks/localSearch-D-FprOMr.js +1 -0
- package/dist/chunks/lockfile-D5-j7HOZ.js +1 -0
- package/dist/chunks/log-B3eB4EFv.js +1 -0
- package/dist/chunks/logoV2Utils-RQ160dI2.js +1 -0
- package/dist/chunks/magicDocs-BqZ0GewA.js +57 -0
- package/dist/chunks/main-DeFMhaFE.js +31 -0
- package/dist/chunks/main-y7LJ5qUc.js +1243 -0
- package/dist/chunks/mappers-CWykjGfP.js +1 -0
- package/dist/chunks/mcp-CSFPAfaW.js +2 -0
- package/dist/chunks/mcp-DBwT4pa9.js +6 -0
- package/dist/chunks/mcp-DvZTaHZE.js +1 -0
- package/dist/chunks/memoize-BK3gG5ob.js +1 -0
- package/dist/chunks/memoize-BO31Ws9Q.js +1 -0
- package/dist/chunks/memory-DcpPpYN0.js +1 -0
- package/dist/chunks/metadata-BRLJvh61.js +1 -0
- package/dist/chunks/modalContext-DFjKLCB6.js +1 -0
- package/dist/chunks/mode-BkViT_0o.js +2 -0
- package/dist/chunks/model--z4Di9QO.js +1 -0
- package/dist/chunks/model-CZktWw6o.js +1 -0
- package/dist/chunks/model-DfFA3qMO.js +1 -0
- package/dist/chunks/multipart-parser-DDLYsngd.js +2 -0
- package/dist/chunks/nativeInstaller-GcIk7G2Y.js +1 -0
- package/dist/chunks/oauth-BqJqV-2M.js +1 -0
- package/dist/chunks/oauth-C8X_p8Gc.js +1 -0
- package/dist/chunks/observationStore-DzCdXq8U.js +4 -0
- package/dist/chunks/onChangeAppState-DwGVi-BC.js +1 -0
- package/dist/chunks/open-BtQHzzL9.js +1 -0
- package/dist/chunks/openai-B2wxZDQx.js +10 -0
- package/dist/chunks/openaiShared-G2-w4gJt.js +1 -0
- package/dist/chunks/output-style-BM3qAHLA.js +1 -0
- package/dist/chunks/overageCreditGrant-CjK49axw.js +1 -0
- package/dist/chunks/p-map-B1EeBuI8.js +1 -0
- package/dist/chunks/p-map-HKDr3iDo.js +1 -0
- package/dist/chunks/package-BC0bllK8.js +1 -0
- package/dist/chunks/panel-B-nrcHpm.js +1 -0
- package/dist/chunks/panel-R4ue6pSW.js +1 -0
- package/dist/chunks/panelCall-I_fbgub5.js +1 -0
- package/dist/chunks/parseConnectUrl-BiyKR5-x.js +1 -0
- package/dist/chunks/parser-BlM_Fk4J.js +1 -0
- package/dist/chunks/parser-CQrasoUB.js +1 -0
- package/dist/chunks/partition-CxRF7T-f.js +1 -0
- package/dist/chunks/passes-U_h-hNu-.js +1 -0
- package/dist/chunks/path-BCSE0S-c.js +1 -0
- package/dist/chunks/permissions-B8epy16o.js +3 -0
- package/dist/chunks/permissions-CeYKbtSC.js +1 -0
- package/dist/chunks/permissions-Cn_6f8CB.js +1 -0
- package/dist/chunks/pidLock-CBJDnBG_.js +3 -0
- package/dist/chunks/pipeTransport-D3Qx9v1V.js +1 -0
- package/dist/chunks/plan-BAhStVci.js +1 -0
- package/dist/chunks/platform-EtecGacO.js +2 -0
- package/dist/chunks/plist-Bzo2VMe9.js +6 -0
- package/dist/chunks/plugin-D9huNnv6.js +1 -0
- package/dist/chunks/pluginAutoupdate-BfmyxR5g.js +1 -0
- package/dist/chunks/pluginBlocklist-03sZaZa6.js +1 -0
- package/dist/chunks/pluginCliCommands-P2Ndi1r1.js +1 -0
- package/dist/chunks/pluginFlagging-BVy7Xv_0.js +1 -0
- package/dist/chunks/pluginOperations-Cz37qcjF.js +2 -0
- package/dist/chunks/pluginStartupCheck-BqUwHcMD.js +1 -0
- package/dist/chunks/pluginStartupCheck-w24D-wwk.js +1 -0
- package/dist/chunks/plugins-B0hiIN4q.js +4 -0
- package/dist/chunks/policyLimits-Dem-XJ_h.js +1 -0
- package/dist/chunks/pollConfig-C2Ac8WMU.js +1 -0
- package/dist/chunks/poller-CpLBoB-N.js +1 -0
- package/dist/chunks/poor-CfbMKZNJ.js +1 -0
- package/dist/chunks/poorMode-Bsw2V-V_.js +1 -0
- package/dist/chunks/poorMode-jvImnkty.js +1 -0
- package/dist/chunks/postCommitAttribution-DoSP9wZD.js +1 -0
- package/dist/chunks/print-ozjC0Mhg.js +23 -0
- package/dist/chunks/privacy-settings-DeGoBRrZ.js +1 -0
- package/dist/chunks/process-CNfq37LF.js +1 -0
- package/dist/chunks/process-gEbdy6uY.js +1 -0
- package/dist/chunks/processBashCommand-loWZ8MSE.js +1 -0
- package/dist/chunks/processSlashCommand-BdouajZb.js +5 -0
- package/dist/chunks/projectContext-BaDZBAoK.js +1 -0
- package/dist/chunks/projectContext-D9MDwJUF.js +1 -0
- package/dist/chunks/prompt-Bef63FhB.js +132 -0
- package/dist/chunks/prompt-C7wd1H_i.js +1 -0
- package/dist/chunks/prompt-DIoNqZvO.js +1 -0
- package/dist/chunks/promptEditor-foiayhdY.js +4 -0
- package/dist/chunks/protocolHandler-BsiB1oW_.js +13 -0
- package/dist/chunks/protocols-CCsohXid.js +18 -0
- package/dist/chunks/protocols-CnYQjBlj.js +2 -0
- package/dist/chunks/proxy-Cn2YwITp.js +99 -0
- package/dist/chunks/rate-limit-options-DTJPDcTr.js +1 -0
- package/dist/chunks/rcDebugLog-BUuD-X1D.js +11 -0
- package/dist/chunks/reconciler-DqXTmV3J.js +4 -0
- package/dist/chunks/referral-DP_GshTS.js +1 -0
- package/dist/chunks/refresh-CNzXPAFw.js +1 -0
- package/dist/chunks/registerProtocol-CjxlFsKw.js +36 -0
- package/dist/chunks/release-notes-BxgK8zWO.js +4 -0
- package/dist/chunks/releaseNotes-CbSktIJW.js +2 -0
- package/dist/chunks/reload-plugins-CDu6yU5-.js +1 -0
- package/dist/chunks/remote-env-B4HnhISc.js +1 -0
- package/dist/chunks/remoteBridgeCore-D-wG5jau.js +1 -0
- package/dist/chunks/remoteManagedSettings-B7gt0VAX.js +1 -0
- package/dist/chunks/rename-DlbMb24l.js +1 -0
- package/dist/chunks/renderOptions-5kWQpVr2.js +1 -0
- package/dist/chunks/resume-BB5iBogS.js +2 -0
- package/dist/chunks/rewind-D12hCfZD.js +1 -0
- package/dist/chunks/ripgrep-BQgJ02F9.js +1 -0
- package/dist/chunks/ripgrep-BvDwiKJ3.js +5 -0
- package/dist/chunks/rollback-BPWRKlIZ.js +11 -0
- package/dist/chunks/rolldown-runtime-DaDcL9Zw.js +1 -0
- package/dist/chunks/runtimeObserver-BNH2WGE3.js +1 -0
- package/dist/chunks/runtimeObserver-Ci-5gvYg.js +10 -0
- package/dist/chunks/sandbox-adapter-Coe1GDAE.js +1 -0
- package/dist/chunks/sandbox-toggle-B2Yk4y2V.js +1 -0
- package/dist/chunks/sanitization-DV-94a9Z.js +1 -0
- package/dist/chunks/satisfies-DQJHNtpQ.js +1 -0
- package/dist/chunks/sdkHeapDumpMonitor-WdXUV7DV.js +1 -0
- package/dist/chunks/searchExtraTools-BnWZ9roi.js +1 -0
- package/dist/chunks/semver-BMRJYn3q.js +1 -0
- package/dist/chunks/semver-DQo45qGo.js +1 -0
- package/dist/chunks/serde-f76bObzR.js +4 -0
- package/dist/chunks/server-LdbAb0sV.js +1 -0
- package/dist/chunks/serverBanner-BdExKFHT.js +1 -0
- package/dist/chunks/serverLog-BFmvyJ93.js +1 -0
- package/dist/chunks/session-Bmx7L3Mt.js +2 -0
- package/dist/chunks/sessionDataUploader-CaCjwsA2.js +1 -0
- package/dist/chunks/sessionDiscovery-DcEAr5vJ.js +1 -0
- package/dist/chunks/sessionFileAccessHooks-BhdOmW9o.js +1 -0
- package/dist/chunks/sessionManager-CPa049BO.js +1 -0
- package/dist/chunks/sessionMemory-Bsg2unYX.js +1 -0
- package/dist/chunks/sessionMemory-CIbCojm-.js +1 -0
- package/dist/chunks/sessionMemoryUtils-Cjb57wtC.js +1 -0
- package/dist/chunks/sessionObserver-CRU1qWnP.js +1 -0
- package/dist/chunks/sessionObserver-DQwHsDrM.js +20 -0
- package/dist/chunks/sessionStorage-BxDN8qRc.js +1 -0
- package/dist/chunks/sessionStoragePortable-Cx6JQ5Ye.js +3 -0
- package/dist/chunks/sessionTitle-B8jcexkQ.js +14 -0
- package/dist/chunks/sessionTracing-BuLsL6qA.js +11 -0
- package/dist/chunks/settings-5PQdphqC.js +19 -0
- package/dist/chunks/settingsSync-BDeuErb5.js +1 -0
- package/dist/chunks/setup-BKEnSLR9.js +3 -0
- package/dist/chunks/shadowedRuleDetection-7Z8ezTKF.js +1 -0
- package/dist/chunks/shellQuote-fB02N16J.js +4 -0
- package/dist/chunks/sideQuestion-CYdNATPW.js +20 -0
- package/dist/chunks/signin-CPaEtsnK.js +1 -0
- package/dist/chunks/sink-DjKoYMsA.js +1 -0
- package/dist/chunks/sink-iYxWapbU.js +1 -0
- package/dist/chunks/sinks-GryGVRT8.js +2 -0
- package/dist/chunks/sinks-jfaIjsRJ.js +1 -0
- package/dist/chunks/skill-learning-E8tQed-Q.js +5 -0
- package/dist/chunks/skillChangeDetector-A8SAuyo9.js +1 -0
- package/dist/chunks/skillGapStore-B5rl12bV.js +1 -0
- package/dist/chunks/skillGapStore-CjJrxxjk.js +5 -0
- package/dist/chunks/skillGenerator-BDR_z3-X.js +8 -0
- package/dist/chunks/skillLearning-BQtfFE0g.js +1 -0
- package/dist/chunks/skillLearning-C8ihdryM.js +1 -0
- package/dist/chunks/skillPanel-yR8Oi-mO.js +28 -0
- package/dist/chunks/skillSearchPanel-DUQQUCUS.js +21 -0
- package/dist/chunks/skills-NAZQ3j-t.js +1 -0
- package/dist/chunks/slashCommandParsing-RQb_7Xzt.js +1 -0
- package/dist/chunks/src-CDCSSo0U2.js +53 -0
- package/dist/chunks/src-CHw1lvBc.js +3 -0
- package/dist/chunks/src-CST_jFnT.js +1 -0
- package/dist/chunks/src-CgZmCiiH.js +2 -0
- package/dist/chunks/src-CiJCsqUl.js +9 -0
- package/dist/chunks/src-D06Xyj4g.js +2 -0
- package/dist/chunks/src-DCUgdrYl.js +5 -0
- package/dist/chunks/src-DLz3FZm1.js +1 -0
- package/dist/chunks/src-DPUAq5Ty.js +1 -0
- package/dist/chunks/src-DQOX_xI1.js +1 -0
- package/dist/chunks/src-Dt5IJd3C.js +1 -0
- package/dist/chunks/src-Dvp6-vB7.js +19 -0
- package/dist/chunks/src-PM8NIIu_.js +1 -0
- package/dist/chunks/src-l6_O0K-a.js +1 -0
- package/dist/chunks/src-xRRBgNzF.js +25 -0
- package/dist/chunks/sso-oidc-DFJ7SBvI.js +1 -0
- package/dist/chunks/startupProfiler-B0m6crkd.js +1 -0
- package/dist/chunks/startupProfiler-DxRQteII.js +3 -0
- package/dist/chunks/state-4KQ3kaqz.js +1 -0
- package/dist/chunks/state-53JDbNQM.js +1 -0
- package/dist/chunks/state-Cn_m2NOf.js +1 -0
- package/dist/chunks/staticRender-BIxpgNUq.js +1 -0
- package/dist/chunks/stats-h4yu84Q-.js +1 -0
- package/dist/chunks/status-BbdeubJG.js +1 -0
- package/dist/chunks/status-is_Bg_IB.js +2 -0
- package/dist/chunks/statusNoticeHelpers-CQ7CUugR.js +1 -0
- package/dist/chunks/stdio-4S7b8Uhx.js +1 -0
- package/dist/chunks/stdio-W_Kokrkh.js +3 -0
- package/dist/chunks/stickers-qJoNhPk4.js +1 -0
- package/dist/chunks/store-Z8rTjDHe.js +1 -0
- package/dist/chunks/stringUtils-CvXbHQRH.js +4 -0
- package/dist/chunks/sts-C2Gf2WYN.js +1 -0
- package/dist/chunks/subprocessEnv-BSQSomcK.js +1 -0
- package/dist/chunks/subprocessEnv-vrwzMgKn.js +1 -0
- package/dist/chunks/supports-color-uJ1LqA-P.js +1 -0
- package/dist/chunks/systemPromptSections-CgpggIYX.js +1 -0
- package/dist/chunks/systemPromptSections-IePG5K8r.js +1 -0
- package/dist/chunks/systemTheme-Ceakddth.js +1 -0
- package/dist/chunks/tag-i3HZ4lhj.js +11 -0
- package/dist/chunks/tasks-HzsYNTZ1.js +1 -0
- package/dist/chunks/teleport-hN3cAbYC.js +1 -0
- package/dist/chunks/templateJobs-CIv_ysje.js +12 -0
- package/dist/chunks/terminalSetup-C0PF87iu.js +33 -0
- package/dist/chunks/terminalSetup-CxniwSF-.js +1 -0
- package/dist/chunks/theme-BKIHX_Dx.js +1 -0
- package/dist/chunks/thinkback-BA4cMz4D.js +1 -0
- package/dist/chunks/thinkback-mT-8FIT-.js +1 -0
- package/dist/chunks/thinkback-play-Cfk49mvF.js +1 -0
- package/dist/chunks/tmux-CbsW-VDJ.js +1 -0
- package/dist/chunks/toolEventObserver-8FQtxeVv.js +1 -0
- package/dist/chunks/toolEventObserver-B1xvyKdE.js +1 -0
- package/dist/chunks/toolPool-CHVDZqh7.js +1 -0
- package/dist/chunks/trustedDevice-BYCh1ff7.js +1 -0
- package/dist/chunks/trustedDevice-DnIWErCt.js +1 -0
- package/dist/chunks/tui-fTa_pzdA.js +6 -0
- package/dist/chunks/types-BUyOCzUt.js +1 -0
- package/dist/chunks/types-Czs-_G1S.js +3 -0
- package/dist/chunks/types-a7X-tJpJ.js +17 -0
- package/dist/chunks/udsClient-Cg9bBD0p.js +1 -0
- package/dist/chunks/ultrareviewCommand-DCFRZsKp.js +3 -0
- package/dist/chunks/undercover-B-kKUWtK.js +1 -0
- package/dist/chunks/undercover-CsLPQb-a.js +31 -0
- package/dist/chunks/up-dO5BcPaq.js +12 -0
- package/dist/chunks/updateCCB-CfUnkOLT.js +11 -0
- package/dist/chunks/upgrade-CngUwvY4.js +1 -0
- package/dist/chunks/upgrade-kpttjebY.js +1 -0
- package/dist/chunks/upload-DDhQqV8n.js +1 -0
- package/dist/chunks/upstreamproxy-CvcjNY7J.js +11 -0
- package/dist/chunks/usage-CJ5w0907.js +1 -0
- package/dist/chunks/usage-eZRwLa77.js +1 -0
- package/dist/chunks/useExitOnCtrlCDWithKeybindings-yAroCqu4.js +1 -0
- package/dist/chunks/useMainLoopModel-BNFW-g8E.js +1 -0
- package/dist/chunks/useManagePlugins-CTtPaQRP.js +1 -0
- package/dist/chunks/useMergedTools-CZJffsmf.js +1 -0
- package/dist/chunks/useSearchInput-C-CqUK6w.js +1 -0
- package/dist/chunks/useSettingsErrors-BWlJCgYF.js +1 -0
- package/dist/chunks/util-DJV0joAW.js +1 -0
- package/dist/chunks/v4-jw6qOKwQ.js +65 -0
- package/dist/chunks/validatePlugin-CRmpIGLV.js +1 -0
- package/dist/chunks/vertex-sdk-DjXcZ2J7.js +9 -0
- package/dist/chunks/vim-n8-UT5w-.js +1 -0
- package/dist/chunks/which-BBCjXfI2.js +1 -0
- package/dist/chunks/windowsPaths-D6T_3XaU.js +1 -0
- package/dist/chunks/windowsPaths-DUKTzBck.js +1 -0
- package/dist/chunks/workSecret-C_lv0dRh.js +1 -0
- package/dist/chunks/workerRegistry-BdHi7_sN.js +1 -0
- package/dist/chunks/worktree-YDeHMlHZ.js +1 -0
- package/dist/chunks/worktreeModeEnabled-BFOYTTTr.js +1 -0
- package/dist/chunks/worktreeModeEnabled-D68iEHpC.js +1 -0
- package/dist/chunks/wrapper-K8ZapJVu.js +6 -0
- package/dist/chunks/xdg-DcF9ejUM.js +1 -0
- package/dist/chunks/zod-CuNujUwx.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/ripgrep/x64-linux/rg +0 -0
- package/package.json +218 -0
- package/scripts/postinstall.cjs +389 -0
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{n as e,t}from"./figures-5ThXQEtq.js";import{en as n,hr as r}from"./state-4KQ3kaqz.js";import{$s as i,AD as a,As as o,Es as s,Fs as c,Gs as l,Hs as u,Ms as d,SD as f,Vs as p,Ws as m,Ys as h,ac as g,fs as ee,kD as _,lc as v,nv as y,ps as b,qs as x,rv as S,sc as C,uc as te,xD as w,yD as T}from"./loadAgentsDir-nzr38hai.js";import{E,O as D,U as O,z as k}from"./debug-IKW-jE7K.js";import{o as ne,s as A}from"./log-B3eB4EFv.js";import{n as re,r as j}from"./analytics-BotDBGh0.js";import{l as M,o as N}from"./stringUtils-CvXbHQRH.js";import{n as P,t as F}from"./exit-BOhGfSlm.js";import{n as I,s as L,t as R}from"./pluginOperations-Cz37qcjF.js";import{a as z,i as B,n as V,o as H,r as U,t as W}from"./pluginCliCommands-P2Ndi1r1.js";import{a as G,c as ie,i as K,n as q,r as J,s as Y,t as ae}from"./validatePlugin-CRmpIGLV.js";import{basename as oe,dirname as X}from"path";e(),n(),re(),L(),a(),O(),ne(),te(),ie(),s(),g(),p(),y(),K(),T(),ee(),ae(),E(),N();function Z(e,n){A(e),F(`${t.cross} Failed to ${n}: ${k(e)}`)}function Q(e){e.errors.length>0&&(console.log(`${t.cross} Found ${e.errors.length} ${M(e.errors.length,`error`)}:\n`),e.errors.forEach(e=>{console.log(` ${t.pointer} ${e.path}: ${e.message}`)}),console.log(``)),e.warnings.length>0&&(console.log(`${t.warning} Found ${e.warnings.length} ${M(e.warnings.length,`warning`)}:\n`),e.warnings.forEach(e=>{console.log(` ${t.pointer} ${e.path}: ${e.message}`)}),console.log(``))}async function se(e,n){n.cowork&&r(!0);try{let n=await q(e);console.log(`Validating ${n.fileType} manifest: ${n.filePath}\n`),Q(n);let r=[];if(n.fileType===`plugin`){let e=X(n.filePath);if(oe(e)===`.claude-plugin`){r=await J(X(e));for(let e of r)console.log(`Validating ${e.fileType}: ${e.filePath}\n`),Q(e)}}let i=n.success&&r.every(e=>e.success),a=n.warnings.length>0||r.some(e=>e.warnings.length>0);i?P(a?`${t.tick} Validation passed with warnings`:`${t.tick} Validation passed`):(console.log(`${t.cross} Validation failed`),process.exit(1))}catch(e){A(e),console.error(`${t.cross} Unexpected error during validation: ${k(e)}`),process.exit(2)}}async function $(e){e.cowork&&r(!0),j(`tengu_plugin_list_command`,{});let n=d(),{getPluginEditableScopes:a}=await import(`./pluginStartupCheck-BqUwHcMD.js`),s=a(),c=Object.keys(n.plugins),{enabled:l,disabled:f,errors:p}=await b(),m=[...l,...f],h=m.filter(e=>e.source.endsWith(`@inline`)),g=p.filter(e=>e.source.endsWith(`@inline`)||e.source.startsWith(`inline[`));if(e.json){let t=new Map(m.map(e=>[e.source,e])),r=[];for(let e of c.sort()){let i=n.plugins[e];if(!i||i.length===0)continue;let a=w(e).name,o=p.filter(t=>t.source===e||`plugin`in t&&t.plugin===a).map(_);for(let n of i){let i=t.get(e),a;if(i){let e=i.mcpServers||await S(i);e&&Object.keys(e).length>0&&(a=e)}r.push({id:e,version:n.version||`unknown`,scope:n.scope,enabled:s.has(e),installPath:n.installPath,installedAt:n.installedAt,lastUpdated:n.lastUpdated,projectPath:n.projectPath,mcpServers:a,errors:o.length>0?o:void 0})}}for(let e of h){let t=e.mcpServers||await S(e),n=g.filter(t=>t.source===e.source||`plugin`in t&&t.plugin===e.name).map(_);r.push({id:e.source,version:e.manifest.version??`unknown`,scope:`session`,enabled:e.enabled!==!1,installPath:e.path,mcpServers:t&&Object.keys(t).length>0?t:void 0,errors:n.length>0?n:void 0})}for(let e of g.filter(e=>e.source.startsWith(`inline[`)))r.push({id:e.source,version:`unknown`,scope:`session`,enabled:!1,installPath:`path`in e?e.path:``,errors:[_(e)]});if(e.available){let e=[];try{let[t,n]=await Promise.all([u(),Y()]),{marketplaces:r}=await C(t);for(let{name:t,data:a}of r)if(a)for(let r of a.plugins){let a=i(r.name,t);o(a)||e.push({pluginId:a,name:r.name,description:r.description,marketplaceName:t,version:r.version,source:r.source,installCount:n?.get(a)})}}catch{}P(D({installed:r,available:e},null,2))}else P(D(r,null,2))}c.length===0&&h.length===0&&g.length===0&&P("No plugins installed. Use `claude plugin install` to install a plugin."),c.length>0&&console.log(`Installed plugins:
|
|
2
|
+
`);for(let e of c.sort()){let r=n.plugins[e];if(!r||r.length===0)continue;let i=w(e).name,a=p.filter(t=>t.source===e||`plugin`in t&&t.plugin===i);for(let n of r){let r=s.has(e),i=a.length>0?`${t.cross} failed to load`:r?`${t.tick} enabled`:`${t.cross} disabled`,o=n.version||`unknown`,c=n.scope;console.log(` ${t.pointer} ${e}`),console.log(` Version: ${o}`),console.log(` Scope: ${c}`),console.log(` Status: ${i}`);for(let e of a)console.log(` Error: ${_(e)}`);console.log(``)}}if(h.length>0||g.length>0){console.log(`Session-only plugins (--plugin-dir):
|
|
3
|
+
`);for(let e of h){let n=g.filter(t=>t.source===e.source||`plugin`in t&&t.plugin===e.name),r=n.length>0?`${t.cross} loaded with errors`:`${t.tick} loaded`;console.log(` ${t.pointer} ${e.source}`),console.log(` Version: ${e.manifest.version??`unknown`}`),console.log(` Path: ${e.path}`),console.log(` Status: ${r}`);for(let e of n)console.log(` Error: ${_(e)}`);console.log(``)}for(let e of g.filter(e=>e.source.startsWith(`inline[`)))console.log(` ${t.pointer} ${e.source}: ${t.cross} ${_(e)}\n`)}P()}async function ce(e,n){n.cowork&&r(!0);try{let r=await G(e);r||F(`${t.cross} Invalid marketplace source format. Try: owner/repo, https://..., or ./path`),`error`in r&&F(`${t.cross} ${r.error}`);let i=n.scope??`user`;i!==`user`&&i!==`project`&&i!==`local`&&F(`${t.cross} Invalid scope '${i}'. Use: user, project, or local`);let a=f(i),o=r;n.sparse&&n.sparse.length>0&&(o.source===`github`||o.source===`git`?o={...o,sparsePaths:n.sparse}:F(`${t.cross} --sparse is only supported for github and git marketplace sources (got: ${o.source})`)),console.log(`Adding marketplace...`);let{name:s,alreadyMaterialized:l,resolvedSource:u}=await c(o,e=>{console.log(e)});h(s,{source:u},a),v();let d=o.source;o.source===`github`&&(d=o.repo),j(`tengu_marketplace_added`,{source_type:d}),P(l?`${t.tick} Marketplace '${s}' already on disk — declared in ${i} settings`:`${t.tick} Successfully added marketplace: ${s} (declared in ${i} settings)`)}catch(e){Z(e,`add marketplace`)}}async function le(e){e.cowork&&r(!0);try{let n=await u(),r=Object.keys(n);e.json&&P(D(r.sort().map(e=>{let t=n[e],r=t?.source;return{name:e,source:r?.source,...r?.source===`github`&&{repo:r.repo},...r?.source===`git`&&{url:r.url},...r?.source===`url`&&{url:r.url},...r?.source===`directory`&&{path:r.path},...r?.source===`file`&&{path:r.path},installLocation:t?.installLocation}}),null,2)),r.length===0&&P(`No marketplaces configured`),console.log(`Configured marketplaces:
|
|
4
|
+
`),r.forEach(e=>{let r=n[e];if(console.log(` ${t.pointer} ${e}`),r?.source){let e=r.source;e.source===`github`?console.log(` Source: GitHub (${e.repo})`):e.source===`git`?console.log(` Source: Git (${e.url})`):e.source===`url`?console.log(` Source: URL (${e.url})`):e.source===`directory`?console.log(` Source: Directory (${e.path})`):e.source===`file`&&console.log(` Source: File (${e.path})`)}console.log(``)}),P()}catch(e){Z(e,`list marketplaces`)}}async function ue(e,n){n.cowork&&r(!0);try{await x(e),v(),j(`tengu_marketplace_removed`,{marketplace_name:e}),P(`${t.tick} Successfully removed marketplace: ${e}`)}catch(e){Z(e,`remove marketplace`)}}async function de(e,n){n.cowork&&r(!0);try{if(e)console.log(`Updating marketplace: ${e}...`),await l(e,e=>{console.log(e)}),v(),j(`tengu_marketplace_updated`,{marketplace_name:e}),P(`${t.tick} Successfully updated marketplace: ${e}`);else{let e=await u(),n=Object.keys(e);n.length===0&&P(`No marketplaces configured`),console.log(`Updating ${n.length} marketplace(s)...`),await m(),v(),j(`tengu_marketplace_updated_all`,{count:n.length}),P(`${t.tick} Successfully updated ${n.length} marketplace(s)`)}}catch(e){Z(e,`update marketplace(s)`)}}async function fe(e,t){t.cowork&&r(!0);let n=t.scope||`user`;t.cowork&&n!==`user`&&F(`--cowork can only be used with user scope`),R.includes(n)||F(`Invalid scope: ${n}. Must be one of: ${R.join(`, `)}.`);let{name:i,marketplace:a}=w(e);j(`tengu_plugin_install_command`,{_PROTO_plugin_name:i,...a&&{_PROTO_marketplace_name:a},scope:n}),await B(e,n)}async function pe(e,t){t.cowork&&r(!0);let n=t.scope||`user`;t.cowork&&n!==`user`&&F(`--cowork can only be used with user scope`),R.includes(n)||F(`Invalid scope: ${n}. Must be one of: ${R.join(`, `)}.`);let{name:i,marketplace:a}=w(e);j(`tengu_plugin_uninstall_command`,{_PROTO_plugin_name:i,...a&&{_PROTO_marketplace_name:a},scope:n}),await z(e,n,t.keepData)}async function me(e,t){t.cowork&&r(!0);let n;t.scope&&(R.includes(t.scope)||F(`Invalid scope "${t.scope}". Valid scopes: ${R.join(`, `)}`),n=t.scope),t.cowork&&n!==void 0&&n!==`user`&&F(`--cowork can only be used with user scope`),t.cowork&&n===void 0&&(n=`user`);let{name:i,marketplace:a}=w(e);j(`tengu_plugin_enable_command`,{_PROTO_plugin_name:i,...a&&{_PROTO_marketplace_name:a},scope:n??`auto`}),await U(e,n)}async function he(e,t){if(t.all&&e&&F(`Cannot use --all with a specific plugin`),!t.all&&!e&&F(`Please specify a plugin name or use --all to disable all plugins`),t.cowork&&r(!0),t.all){t.scope&&F(`Cannot use --scope with --all`),j(`tengu_plugin_disable_command`,{}),await W();return}let n;t.scope&&(R.includes(t.scope)||F(`Invalid scope "${t.scope}". Valid scopes: ${R.join(`, `)}`),n=t.scope),t.cowork&&n!==void 0&&n!==`user`&&F(`--cowork can only be used with user scope`),t.cowork&&n===void 0&&(n=`user`);let{name:i,marketplace:a}=w(e);j(`tengu_plugin_disable_command`,{_PROTO_plugin_name:i,...a&&{_PROTO_marketplace_name:a},scope:n??`auto`}),await V(e,n)}async function ge(e,t){t.cowork&&r(!0);let{name:n,marketplace:i}=w(e);j(`tengu_plugin_update_command`,{_PROTO_plugin_name:n,...i&&{_PROTO_marketplace_name:i}});let a=`user`;t.scope&&(I.includes(t.scope)||F(`Invalid scope "${t.scope}". Valid scopes: ${I.join(`, `)}`),a=t.scope),t.cowork&&a!==`user`&&F(`--cowork can only be used with user scope`),await H(e,a)}export{ce as marketplaceAddHandler,le as marketplaceListHandler,ue as marketplaceRemoveHandler,de as marketplaceUpdateHandler,he as pluginDisableHandler,me as pluginEnableHandler,fe as pluginInstallHandler,$ as pluginListHandler,pe as pluginUninstallHandler,ge as pluginUpdateHandler,se as pluginValidateHandler};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Ua as e,Va as t,Ya as n}from"./loadAgentsDir-nzr38hai.js";t();export{e as isPolicyAllowed,n as waitForPolicyLimitsToLoad};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{C as e,t,w as n}from"./v4-jw6qOKwQ.js";import{n as r,t as i}from"./lazySchema-uxlVVNM1.js";t(),i();var a=2e3,o=6e5,s={poll_interval_ms_not_at_capacity:a,poll_interval_ms_at_capacity:o,non_exclusive_heartbeat_interval_ms:0,multisession_poll_interval_ms_not_at_capacity:a,multisession_poll_interval_ms_partial_capacity:a,multisession_poll_interval_ms_at_capacity:o,reclaim_older_than_ms:5e3,session_keepalive_interval_v2_ms:12e4},c={message:`must be 0 (disabled) or ≥100ms`},l=r(()=>n({poll_interval_ms_not_at_capacity:e().int().min(100),poll_interval_ms_at_capacity:e().int().refine(e=>e===0||e>=100,c),non_exclusive_heartbeat_interval_ms:e().int().min(0).default(0),multisession_poll_interval_ms_not_at_capacity:e().int().min(100).default(s.multisession_poll_interval_ms_not_at_capacity),multisession_poll_interval_ms_partial_capacity:e().int().min(100).default(s.multisession_poll_interval_ms_partial_capacity),multisession_poll_interval_ms_at_capacity:e().int().refine(e=>e===0||e>=100,c).default(s.multisession_poll_interval_ms_at_capacity),reclaim_older_than_ms:e().int().min(1).default(5e3),session_keepalive_interval_v2_ms:e().int().min(0).default(12e4)}).refine(e=>e.non_exclusive_heartbeat_interval_ms>0||e.poll_interval_ms_at_capacity>0,{message:`at-capacity liveness requires non_exclusive_heartbeat_interval_ms > 0 or poll_interval_ms_at_capacity > 0`}).refine(e=>e.non_exclusive_heartbeat_interval_ms>0||e.multisession_poll_interval_ms_at_capacity>0,{message:`at-capacity liveness requires non_exclusive_heartbeat_interval_ms > 0 or multisession_poll_interval_ms_at_capacity > 0`}));function u(){let e=s,t=l().safeParse(e);return t.success?t.data:s}export{s as n,u as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,t}from"./store-Z8rTjDHe.js";t();function n(){let e=process.env.OPENAI_BASE_URL;return e&&/\bapi\.deepseek\.com\b/i.test(e)?e.replace(/\/+$/,``):process.env.DEEPSEEK_API_KEY?`https://api.deepseek.com`:null}function r(){return process.env.DEEPSEEK_API_KEY||process.env.OPENAI_API_KEY||null}var i={providerId:`deepseek`,isEnabled(){return n()!==null&&r()!==null},async fetchBalance(e){let t=n(),i=r();if(!t||!i)return null;let a;try{a=await fetch(`${t}/user/balance`,{method:`GET`,headers:{Authorization:`Bearer ${i}`,Accept:`application/json`},signal:e})}catch{return null}if(!a.ok)return null;let o;try{o=await a.json()}catch{return null}let s=o?.balance_infos;if(!Array.isArray(s))return null;let c=s.find(e=>typeof e==`object`&&!!e&&e.currency===`USD`)??s[0]??null;if(!c)return null;let l=typeof c.currency==`string`?c.currency:`USD`,u=c.total_balance,d=typeof u==`number`?u:Number(u);return Number.isFinite(d)?{currency:l,remaining:d,updatedAt:Math.floor(Date.now()/1e3)}:null}};function a(e,t){if(!t)return e;let n=t.split(`.`).filter(Boolean),r=e;for(let e of n){if(r==null)return;if(Array.isArray(r)){let t=Number(e);if(!Number.isFinite(t))return;r=r[t]}else if(typeof r==`object`)r=r[e];else return}return r}var o=/^(10\.|192\.168\.|172\.(1[6-9]|2\d|3[01])\.|169\.254\.|127\.|0\.0\.0\.0|fc|fd|\[::1\]|\[fe80:)/;function s(e){let t=new URL(e);if(t.protocol!==`https:`&&t.protocol!==`http:`)throw Error(`unsupported protocol: ${t.protocol}`);if(t.protocol===`http:`&&![`localhost`,`127.0.0.1`,`[::1]`].includes(t.hostname))throw Error(`http only allowed for localhost, got ${t.hostname}`);if(o.test(t.hostname))throw Error(`private/reserved IP not allowed: ${t.hostname}`);return t}var c={providerId:`generic`,isEnabled(){return!!process.env.CLAUDE_CODE_BALANCE_URL},async fetchBalance(e){let t=process.env.CLAUDE_CODE_BALANCE_URL;if(!t)return null;let n;try{n=s(t)}catch{return null}let r=process.env.CLAUDE_CODE_BALANCE_KEY||process.env.OPENAI_API_KEY||process.env.ANTHROPIC_API_KEY||``,i=process.env.CLAUDE_CODE_BALANCE_JSON_PATH||`balance`,o=process.env.CLAUDE_CODE_BALANCE_CURRENCY||`USD`,c;try{c=await fetch(n.href,{method:`GET`,headers:{Accept:`application/json`,...r?{Authorization:`Bearer ${r}`}:{}},signal:e})}catch{return null}if(!c.ok)return null;let l;try{l=await c.json()}catch{return null}let u=a(l,i),d=typeof u==`number`?u:Number(u);return Number.isFinite(d)?{currency:o,remaining:d,updatedAt:Math.floor(Date.now()/1e3)}:null}},l=10,u=[c,i];function d(){return process.env.CLAUDE_CODE_BALANCE_PROVIDER===`none`?null:u.find(e=>e.isEnabled())??null}function f(){let e=process.env.CLAUDE_CODE_BALANCE_POLL_INTERVAL_MINUTES,t=e?Number(e):l;return!Number.isFinite(t)||t<=0?l*6e4:Math.floor(t*6e4)}var p=null,m=null,h=null,g=1e4;async function _(){if(!h)return;m?.abort(),m=new AbortController;let t=setTimeout(()=>m?.abort(),g);try{let t=await h.fetchBalance(m.signal);e(h.providerId,t)}catch{}finally{clearTimeout(t)}}function v(){p===null&&(h=d(),h&&(_(),p=setInterval(()=>{_()},f()),typeof p.unref==`function`&&p.unref()))}export{v as startBalancePolling};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{i as t,n,t as r}from"./poorMode-Bsw2V-V_.js";var i;e((()=>{r(),i=async(e,r)=>{let i=!n();return t(i),i?r.setAppState(e=>({...e,promptSuggestionEnabled:!1})):r.setAppState(e=>({...e,promptSuggestionEnabled:!0})),{type:`text`,value:`Poor mode ${i?`ON`:`OFF`} — ${i?`extract_memories and prompt_suggestion are disabled`:`extract_memories and prompt_suggestion are restored`}`}}}))();export{i as call};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,r as t}from"./rolldown-runtime-DaDcL9Zw.js";import{g as n,n as r,y as i}from"./settings-5PQdphqC.js";var a=t({isPoorModeActive:()=>o,setPoorMode:()=>s});function o(){return c===null&&(c=r().poorMode===!0),c}function s(e){c=e,i(`userSettings`,{poorMode:e||void 0})}var c,l=e((()=>{n(),c=null}));export{s as i,o as n,a as r,l as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,t}from"./poorMode-Bsw2V-V_.js";t();export{e as isPoorModeActive};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";var t;e((()=>{t=async()=>{}}))();export{t as installPrepareCommitMsgHook};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import{a as e}from"./rolldown-runtime-DaDcL9Zw.js";import{c as t,l as n,o as r,s as i}from"./envUtils-DSxRz_kt.js";import{n as a,t as o}from"./defineProperty-C-QyHrDq.js";import{M as s,P as c,Tn as l,Un as u,Wn as d,Z as f,en as p,ht as m,ir as h,kn as g,ln as _,tn as ee,vr as v}from"./state-4KQ3kaqz.js";import{$S as te,Al as y,Ar as b,BD as ne,BE as x,B_ as S,Bw as re,By as C,C as w,Cn as T,D as E,DC as D,DS as O,Dv as ie,Dw as ae,E as k,ES as oe,Fc as A,G as se,G_ as ce,Gy as le,H_ as ue,IE as de,Ic as fe,Is as j,Iy as M,JE as pe,Jw as me,K_ as he,Ks as ge,Ku as _e,Kw as ve,Ls as ye,MC as N,M_ as be,Md as P,NC as xe,NE as Se,Nc as Ce,OC as we,OS as Te,Oi as Ee,Ov as De,P as Oe,Pc as ke,QD as Ae,QE as F,Qi as je,Ry as Me,Sw as Ne,Tb as Pe,Ua as I,Us as L,Ut as Fe,VE as Ie,Va as Le,Vi as Re,Vs as ze,Vw as Be,W as Ve,Wi as He,Wy as Ue,X_ as We,Xu as R,YD as z,ZD as Ge,ZE as B,Zw as Ke,_C as qe,_c as Je,_g as Ye,_i as Xe,_w as Ze,aC as Qe,ag as $e,as as V,aw as et,ay as tt,b as nt,bC as rt,bc as it,bw as at,cC as ot,cO as st,ca as ct,cf as lt,cg as ut,cr as dt,cs as ft,cu as pt,cy as mt,dg as ht,dw as H,eC as gt,eT as _t,ei as vt,f as yt,fc as bt,fi as xt,fs as St,fw as Ct,fy as wt,gc as Tt,gi as Et,go as Dt,gw as Ot,hC as kt,hc as At,hg as jt,hw as Mt,hy as Nt,iC as Pt,i_ as Ft,ig as It,ir as Lt,iw as Rt,jC as zt,jd as Bt,jr as Vt,kC as Ht,kS as Ut,k_ as Wt,kb as Gt,ki as Kt,kl as qt,kr as Jt,lC as Yt,lf as Xt,ly as Zt,mS as Qt,mc as $t,mg as en,ms as tn,mw as nn,my as rn,nb as an,ng as on,o as sn,oO as cn,oT as ln,o_ as un,os as dn,pS as fn,pc as pn,pg as mn,pi as hn,pw as gn,py as _n,qE as vn,qi as yn,qu as bn,qw as xn,r_ as Sn,rb as Cn,s as wn,sT as Tn,su as En,tO as Dn,uu as On,vc as kn,vg as An,vw as jn,wn as Mn,x as Nn,xC as Pn,xc as Fn,xw as In,y_ as Ln,yc as Rn,yn as zn,yw as Bn,z_ as Vn,zo as Hn,zw as Un,zy as Wn}from"./loadAgentsDir-nzr38hai.js";import{n as Gn,t as Kn}from"./cwd-BuJhkTrc.js";import{D as qn,E as Jn,J as Yn,O as U,U as Xn,_ as Zn,h as Qn,l as $n,ot as er,p as W,st as tr,u as nr,z as G}from"./debug-IKW-jE7K.js";import{St as rr,Y as ir,_n as ar,ct as or,d as sr,f as cr,g as lr,ht as ur,ot as K,yn as dr}from"./settings-5PQdphqC.js";import{L as fr,P as pr}from"./config-C7YHKCPV.js";import{i as mr,n as hr,o as q}from"./process-gEbdy6uY.js";import{M as gr,N as _r,j as vr}from"./git-tyaWOgRL.js";import{U as yr,Y as br,c as xr,i as Sr,o as Cr,s as J}from"./log-B3eB4EFv.js";import{i as wr,n as Tr}from"./path-BCSE0S-c.js";import{s as Er,u as Dr}from"./types-a7X-tJpJ.js";import{n as Or,r as Y}from"./analytics-BotDBGh0.js";import{C as kr,Er as Ar,Mn as jr,Nn as Mr,Tr as Nr,Vt as Pr,X as Fr,_ as Ir,at as Lr,cr as Rr,di as zr,fi as Br,it as Vr,li as Hr,mi as Ur,nt as Wr,o as Gr,sr as Kr,tt as qr,u as Jr,vn as Yr,x as Xr,xt as Zr,yn as Qr}from"./model-DfFA3qMO.js";import{Cn as $r,Et as ei,Tt as ti,Yt as ni,dt as ri,rn as ii,ut as ai,wn as oi}from"./prompt-Bef63FhB.js";import{c as si,s as ci}from"./pluginFlagging-BVy7Xv_0.js";import{a as li,o as ui,s as di}from"./fileStateCache-DDW5toIs.js";import{A as fi,C as pi,D as mi,N as hi,O as gi,P as _i,_ as vi,d as yi,g as bi,h as xi,lt as Si,m as Ci,u as wi,v as Ti,y as Ei}from"./rcDebugLog-BUuD-X1D.js";import{c as Di,l as Oi}from"./commitAttribution-Cm40fdNU.js";import{K as ki,x as Ai,y as ji}from"./stdio-W_Kokrkh.js";import{t as Mi}from"./pollConfig-C2Ac8WMU.js";import{r as Ni}from"./inboundAttachments-DVs3_m48.js";import{i as Pi,n as Fi,s as Ii}from"./mappers-CWykjGfP.js";import{n as Li,r as Ri}from"./sessionTitle-B8jcexkQ.js";import{n as zi,t as Bi}from"./ccrClient-HqMi5Kfu.js";import{n as Vi,t as Hi}from"./HybridTransport-BgV5_7Az.js";import{n as Ui,t as Wi}from"./SSETransport-BXiEBMpb.js";import{a as Gi,n as Ki,o as qi}from"./grove-DotW04-v.js";import{o as Ji}from"./remoteManagedSettings-B7gt0VAX.js";import{i as Yi,r as Xi}from"./auth-DHyCIxCk.js";import{t as Zi}from"./pluginBlocklist-03sZaZa6.js";import{t as Qi}from"./onChangeAppState-DwGVi-BC.js";import{t as $i}from"./settingsSync-BDeuErb5.js";import{a as ea,c as ta,n as na,o as ra,r as ia,s as aa}from"./reconciler-DqXTmV3J.js";import{n as oa,t as sa}from"./toolPool-CHVDZqh7.js";import{n as ca,r as la}from"./QueryEngine-D2HUnwmU.js";import{n as ua,r as da}from"./sideQuestion-CYdNATPW.js";import{n as fa,r as pa}from"./context-noninteractive-DnH6Q9Lu.js";import{a as ma,o as ha,t as ga}from"./skillChangeDetector-A8SAuyo9.js";import{n as _a,t as va}from"./refresh-CNzXPAFw.js";import{dirname as ya,join as ba}from"path";import{PassThrough as xa}from"stream";import{randomUUID as X}from"crypto";import{readFile as Sa,stat as Ca}from"fs/promises";import{URL as wa}from"url";import{cwd as Z}from"process";a(),p(),Gn(),er(),Xn(),Jn(),Zn(),hr(),$n(),vr(),br(),Cr(),wr(),ar(),Er(),lr(),Ur(),zr(),Ar(),jr(),Yr(),Pr(),Ir(),$r(),ii(),Mt(),hi(),Qe(),Te(),gi(),ie(),yi(),dn(),Hn(),je(),Vt(),$i(),r(),Ui();function Ta(e,t={},r,i){if(n(process.env.CLAUDE_CODE_USE_CCR_V2)){let n=new wa(e.href);return n.protocol===`wss:`?n.protocol=`https:`:n.protocol===`ws:`&&(n.protocol=`http:`),n.pathname=n.pathname.replace(/\/$/,``)+`/worker/events/stream`,new Wi(n,t,r,i)}if(e.protocol===`ws:`||e.protocol===`wss:`)return n(process.env.CLAUDE_CODE_POST_FOR_SESSION_INGRESS_V2)?new Hi(e,t,r,i):new Vi(e,t,r,i);throw Error(`Unsupported protocol: ${e.protocol}`)}r(),Ui();var Ea=class extends ea{constructor(e,t,r){let i=new xa({encoding:`utf8`});super(i,r),o(this,`url`,void 0),o(this,`transport`,void 0),o(this,`inputStream`,void 0),o(this,`isBridge`,!1),o(this,`isDebug`,!1),o(this,`ccrClient`,null),o(this,`keepAliveTimer`,null),this.inputStream=i,this.url=new wa(e);let a={},s=mi();s?a.Authorization=`Bearer ${s}`:W(`[remote-io] No session ingress token available`,{level:`error`});let c=process.env.CLAUDE_CODE_ENVIRONMENT_RUNNER_VERSION;c&&(a[`x-environment-runner-version`]=c);let l=()=>{let e={},t=mi();t&&(e.Authorization=`Bearer ${t}`);let n=process.env.CLAUDE_CODE_ENVIRONMENT_RUNNER_VERSION;return n&&(e[`x-environment-runner-version`]=n),e};if(this.transport=Ta(this.url,a,m(),l),this.isBridge=process.env.CLAUDE_CODE_ENVIRONMENT_KIND===`bridge`,this.isDebug=nr(),this.transport.setOnData(e=>{this.inputStream.write(e),this.isBridge&&this.isDebug&&q(e.endsWith(`
|
|
2
|
+
`)?e:e+`
|
|
3
|
+
`)}),this.transport.setOnClose(()=>{this.inputStream.end()}),n(process.env.CLAUDE_CODE_USE_CCR_V2)){if(!(this.transport instanceof Wi))throw Error(`CCR v2 requires SSETransport; check getTransportForUrl`);this.ccrClient=new Bi(this.transport,this.url);let e=this.ccrClient.initialize();this.restoredWorkerState=e.catch(()=>null),e.catch(e=>{gr(`error`,`cli_worker_lifecycle_init_failed`,{reason:e instanceof zi?e.reason:`unknown`}),J(Error(`CCRClient initialization failed: ${G(e)}`)),oe(1,`other`)}),tr(async()=>this.ccrClient?.close()),Kt((e,t,n)=>this.ccrClient.writeInternalEvent(e,t,n)),Ee(()=>this.ccrClient.readInternalEvents(),()=>this.ccrClient.readSubagentInternalEvents());let t={started:`processing`,completed:`processed`};Ze((e,n)=>{this.ccrClient?.reportDelivery(e,t[n])}),Ti((e,t)=>{this.ccrClient?.reportState(e,t)}),vi(e=>{this.ccrClient?.reportMetadata(e)},{replayCurrent:!0})}this.transport.connect();let u=Mi().session_keepalive_interval_v2_ms;if(this.isBridge&&u>0&&(this.keepAliveTimer=setInterval(()=>{W(`[remote-io] keep_alive sent`),this.write({type:`keep_alive`}).catch(e=>{W(`[remote-io] keep_alive write failed: ${G(e)}`)})},u),this.keepAliveTimer.unref?.()),tr(async()=>this.close()),t){let e=this.inputStream;(async()=>{for await(let n of t)e.write(String(n).replace(/\n$/,``)+`
|
|
4
|
+
`)})()}}flushInternalEvents(){return this.ccrClient?.flushInternalEvents()??Promise.resolve()}get internalEventsPending(){return this.ccrClient?.internalEventsPending??0}async write(e){this.ccrClient?await this.ccrClient.writeEvent(e):await this.transport.write(e),this.isBridge&&(e.type===`control_request`||this.isDebug)&&q(ra(e)+`
|
|
5
|
+
`)}close(){this.keepAliveTimer&&(clearInterval(this.keepAliveTimer),this.keepAliveTimer=null),this.transport.close(),this.inputStream.end()}};ni(),ir(),ei(),[...ti],er(),$n();var Da=`[stdout-guard]`,Oa=!1,Q=``,ka=null;function Aa(e){if(e.length===0)return!0;try{return JSON.parse(e),!0}catch{return!1}}function ja(){Oa||(Oa=!0,ka=process.stdout.write.bind(process.stdout),process.stdout.write=function(e,t,n){let r=typeof e==`string`?e:Buffer.from(e).toString(`utf-8`);Q+=r;let i,a=!0;for(;(i=Q.indexOf(`
|
|
6
|
+
`))!==-1;){let e=Q.slice(0,i);Q=Q.slice(i+1),Aa(e)?a=ka(e+`
|
|
7
|
+
`):(process.stderr.write(`${Da} ${e}\n`),W(`streamJsonStdoutGuard diverted non-JSON stdout line: ${e.slice(0,200)}`))}let o=typeof t==`function`?t:n;return o&&queueMicrotask(()=>o()),a},tr(async()=>{Q.length>0&&(ka&&Aa(Q)?ka(Q+`
|
|
8
|
+
`):process.stderr.write(`${Da} ${Q}\n`),Q=``),ka&&(process.stdout.write=ka,ka=null),Oa=!1}))}rr(),or(),pr(),cn(),z(),vn(),x(),de(),ri(),ui(),_i(),me(),et(),N(),Pn(),qe(),le(),wt(),mt(),ce(),be(),R(),A(),ke(),Rn(),ze(),St(),Mn(),zn(),se(),sn(),sa(),tt(),Xn(),Cr(),gi(),M(),$n(),Te();function Ma(e){let t=process.env.CLAUDE_CODE_EXIT_AFTER_STOP_DELAY,n=t?parseInt(t,10):null,r=n&&!isNaN(n)&&n>0,i=null,a=0;return{start(){i&&(clearTimeout(i),i=null),r&&(a=Date.now(),i=setTimeout(()=>{let t=Date.now()-a;e()&&t>=n&&(W(`Exiting after ${n}ms of idle time`),O())},n))},stop(){i&&(clearTimeout(i),i=null)}}}qr(),ci(),B(),ln(),D(),gt(),Qt(),Gt(),y(),Le(),w(),Ri(),ua();function Na(e){if(e.toLowerCase().endsWith(`.jsonl`))return{sessionId:X(),ingressUrl:null,isUrl:!1,jsonlFile:e,isJsonlFile:!0};if(De(e))return{sessionId:e,ingressUrl:null,isUrl:!1,jsonlFile:null,isJsonlFile:!1};try{let t=new URL(e);return{sessionId:X(),ingressUrl:t.href,isUrl:!0,jsonlFile:null,isJsonlFile:!1}}catch{}return null}Kr(),ae(),In(),gn(),Oi(),ki(),Sn(),jt(),ht(),P(),En(),Fi(),Gi(),pa(),$n();async function Pa(){try{let e=await Sa(Tt(),`utf-8`),t=ur().safeParse(qn(e));return t.success?t.data:(W(`Invalid known_marketplaces.json in zip cache: ${t.error.message}`,{level:`error`}),{})}catch{return{}}}async function Fa(e){await bt(Tt(),U(e,null,2))}async function Ia(e,t){let n=At();if(!n)return;let r=await La(t);r!==null&&await bt(ba(n,$t(e)),r)}async function La(e){let t=[ba(e,`.claude-plugin`,`marketplace.json`),ba(e,`marketplace.json`),e];for(let e of t)try{return await Sa(e,`utf-8`)}catch{}return null}async function Ra(){let e=await L();for(let[t,n]of Object.entries(e))if(n.installLocation)try{await Ia(t,n.installLocation)}catch(e){W(`Failed to save marketplace JSON for ${t}: ${e}`)}await Fa({...await Pa(),...e})}Or(),er(),$n(),vr(),Cr(),ze(),Rn();async function za(){let e=Fn();W(`installPluginsForHeadless: starting${e?` (zip cache mode)`:``}`);let t=await ge();t&&(j(),ft(`headlessPluginInstall: seed marketplaces registered`)),e&&(await Qn().mkdir(Je()),await Qn().mkdir(kn()));let n=Object.keys(ye()).length,r={marketplaces_installed:0,delisted_count:0},i=t;try{if(n===0)W(`installPluginsForHeadless: no marketplaces declared`);else{let t=await _r(`headless_marketplace_reconcile`,()=>na({skip:e?(e,t)=>!it(t):void 0,onProgress:e=>{e.type===`installed`?W(`installPluginsForHeadless: installed marketplace ${e.name}`):e.type===`failed`&&W(`installPluginsForHeadless: failed to install marketplace ${e.name}: ${e.error}`)}}),e=>({installed_count:e.installed.length,updated_count:e.updated.length,failed_count:e.failed.length,skipped_count:e.skipped.length}));t.skipped.length>0&&W(`installPluginsForHeadless: skipped ${t.skipped.length} marketplace(s) unsupported by zip cache: ${t.skipped.join(`, `)}`);let n=t.installed.length+t.updated.length;n>0&&(j(),ft(`headlessPluginInstall: marketplaces reconciled`),i=!0),r.marketplaces_installed=n}e&&await Ra();let t=await Zi();return r.delisted_count=t.length,t.length>0&&(i=!0),i&&ft(`headlessPluginInstall: plugins changed`),e&&tr(pn),i}catch(e){return J(e),!1}finally{Y(`tengu_headless_plugin_install`,r)}}Or(),$n(),vr(),Mt(),yi(),Cr(),hr(),ie(),Te(),er(),Gn(),p(),Vt(),Hn(),Jn(),r(),va(),St(),Yt(),an(),lt(),Xn();var $=(Ei(),e(pi)),Ba=1e4,Va=new Set,Ha=[];function Ua(e){if(Va.has(e))return!1;if(Va.add(e),Ha.push(e),Ha.length>Ba){let e=Ha.splice(0,Ha.length-Ba);for(let t of e)Va.delete(t)}return!0}function Wa(e){return typeof e==`string`?[{type:`text`,text:e}]:e}function Ga(e){return e.length===1?e[0]:e.every(e=>typeof e==`string`)?e.join(`
|
|
9
|
+
`):e.flatMap(Wa)}function Ka(e,t){return t!==void 0&&t.mode===`prompt`&&t.workload===e.workload&&t.isMeta===e.isMeta}async function qa(e,t,r,i,a,o,s,c){if(process.env.USER_TYPE===`ant`&&n(process.env.CLAUDE_CODE_EXIT_AFTER_FIRST_RENDER)&&(process.stderr.write(`\nStartup time: ${Math.round(process.uptime()*1e3)}ms\n`),process.exit(0)),Ie.subscribe(e=>{fn(e,r),Vr()&&r(e=>{let t=e.settings,n=t.fastMode===!0&&!t.fastModePerSessionOptIn;return{...e,fastMode:n}})}),$&&!$.isProactiveActive()&&n(process.env.CLAUDE_CODE_PROACTIVE)&&$.activateProactive(`command`),typeof Bun<`u`&&setInterval(()=>{process.memoryUsage.rss()>350*1024*1024?Bun.gc(!0):Bun.gc(!1)},1e3).unref(),Ct(),H(`runHeadless_entry`),await qi()&&await Ki(),H(`after_grove_check`),c.resumeSessionAt&&!c.resume){process.stderr.write(`Error: --resume-session-at requires --resume
|
|
10
|
+
`),O(1);return}if(c.rewindFiles&&!c.resume){process.stderr.write(`Error: --rewind-files requires --resume
|
|
11
|
+
`),O(1);return}if(c.rewindFiles&&e){process.stderr.write(`Error: --rewind-files is a standalone operation and cannot be used with a prompt
|
|
12
|
+
`),O(1);return}let l=ro(e,c);c.outputFormat===`stream-json`&&ja();let u=Se.getSandboxUnavailableReason();if(u){if(Se.isSandboxRequired()){process.stderr.write(`\nError: sandbox required but unavailable: ${u}\n sandbox.failIfUnavailable is set — refusing to start without a working sandbox.\n\n`),O(1);return}process.stderr.write(`\n⚠ Sandbox disabled: ${u}\n Commands will run WITHOUT sandboxing. Network and filesystem restrictions will NOT be enforced.\n\n`)}else if(Se.isSandboxingEnabled())try{await Se.initialize(l.createSandboxAskCallback())}catch(e){process.stderr.write(`\n❌ Sandbox Error: ${G(e)}\n`),O(1,`other`);return}c.outputFormat===`stream-json`&&c.verbose&&fe(e=>{let t=(()=>{switch(e.type){case`started`:return{type:`system`,subtype:`hook_started`,hook_id:e.hookId,hook_name:e.hookName,hook_event:e.hookEvent,uuid:X(),session_id:m()};case`progress`:return{type:`system`,subtype:`hook_progress`,hook_id:e.hookId,hook_name:e.hookName,hook_event:e.hookEvent,stdout:e.stdout,stderr:e.stderr,output:e.output,uuid:X(),session_id:m()};case`response`:return{type:`system`,subtype:`hook_response`,hook_id:e.hookId,hook_name:e.hookName,hook_event:e.hookEvent,output:e.output,stdout:e.stdout,stderr:e.stderr,exit_code:e.exitCode,outcome:e.outcome,uuid:X(),session_id:m()}}})();l.write(t)}),c.setupTrigger&&await rn(c.setupTrigger),H(`before_loadInitialMessages`);let d=t(),{messages:p,turnInterruptionState:h,agentSetting:g}=await no(r,{continue:c.continue,teleport:c.teleport,resume:c.resume,resumeSessionAt:c.resumeSessionAt,forkSession:c.forkSession,outputFormat:c.outputFormat,sessionStartHooksPromise:c.sessionStartHooksPromise,restoredWorkerState:l.restoredWorkerState}),_=Nt();if(_&&l.prependUserMessage(_),!c.agent&&!f()&&g){let{agentDefinition:e}=ma(g,void 0,{activeAgents:s,allAgents:s});if(e){if(r(t=>({...t,agent:e.agentType})),!c.systemPrompt&&!wn(e)){let t=e.getSystemPrompt();t&&(c.systemPrompt=t)}Et(e.agentType)}}if(p.length===0&&process.exitCode!==void 0)return;if(c.rewindFiles){let e=p.find(e=>e.uuid===c.rewindFiles);if(!e||e.type!==`user`){process.stderr.write(`Error: --rewind-files requires a user message UUID, but ${c.rewindFiles} is not a user message in this session\n`),O(1);return}let n=t(),i=await Qa(c.rewindFiles,n,r,!1);if(!i.canRewind){process.stderr.write(`Error: ${i.error||`Unexpected error`}\n`),O(1);return}process.stdout.write(`Files rewound to state at message ${c.rewindFiles}\n`),O(0);return}let ee=typeof c.resume==`string`&&(!!De(c.resume)||c.resume.endsWith(`.jsonl`)),v=!!c.sdkUrl;if(!e&&!ee&&!v){process.stderr.write(`Error: Input must be provided either through stdin or as a prompt argument when using --print
|
|
13
|
+
`),O(1);return}if(c.outputFormat===`stream-json`&&!c.verbose){process.stderr.write(`Error: When using --print, --output-format=stream-json requires --verbose
|
|
14
|
+
`),O(1);return}let te=bn(d.mcp.tools,d.toolPermissionContext),y=[...a,...te],b=Xa(c.sdkUrl?`stdio`:c.permissionPromptToolName,l,()=>t().mcp.tools,e=>{r(e=>({...e,attribution:{...e.attribution,permissionPromptCount:e.attribution.permissionPromptCount+1}})),xi(`requires_action`,e)});c.permissionPromptToolName&&(y=y.filter(e=>!oi(e,c.permissionPromptToolName))),mr(),H(`after_loadInitialMessages`),await Hr(),H(`after_modelStrings`);let ne=c.outputFormat===`json`&&c.verbose,x=[],S;H(`before_runHeadlessStreaming`);for await(let e of Ja(l,d.mcp.clients,[...i,...d.mcp.commands],y,p,b,o,t,r,s,c,h))c.outputFormat===`stream-json`&&c.verbose&&await l.write(e),e.type!==`control_response`&&e.type!==`control_request`&&e.type!==`control_cancel_request`&&!(e.type===`system`&&(e.subtype===`session_state_changed`||e.subtype===`task_notification`||e.subtype===`task_started`||e.subtype===`task_progress`||e.subtype===`post_turn_summary`))&&e.type!==`stream_event`&&e.type!==`keep_alive`&&e.type!==`streamlined_text`&&e.type!==`streamlined_tool_use_summary`&&e.type!==`prompt_suggestion`&&(ne&&x.push(e),S=e);switch(c.outputFormat){case`json`:if(!S||S.type!==`result`)throw Error(`No messages returned`);if(c.verbose){q(U(x)+`
|
|
15
|
+
`);break}q(U(S)+`
|
|
16
|
+
`);break;case`stream-json`:break;default:if(!S||S.type!==`result`)throw Error(`No messages returned`);switch(S.subtype){case`success`:q(S.result.endsWith(`
|
|
17
|
+
`)?S.result:S.result+`
|
|
18
|
+
`);break;case`error_during_execution`:q(`Execution error`);break;case`error_max_turns`:q(`Error: Reached max turns (${c.maxTurns}).\nTip: Increase the limit with --max-turns or continue in a new session.`);break;case`error_max_budget_usd`:q(`Error: Exceeded USD budget ($${c.maxBudgetUsd}).\nTip: Increase the limit with --max-budget-usd or start a new session to continue.`);break;case`error_max_structured_output_retries`:q(`Error: Failed to provide valid structured output after maximum retries.
|
|
19
|
+
Tip: Simplify your schema or check if the output format matches the expected structure.`)}}if(nn(),fr())try{let{drainPendingExtraction:e}=await import(`./extractMemories-C4f9JWuI.js`);await e()}catch{}O(S?.type===`result`&&S?.is_error?1:0)}function Ja(e,r,a,o,d,f,p,g,_,ee,v,y){let b=!1,x,C=!1,w=null,T,E=e.outbound;process.on(`SIGINT`,()=>{gr(`info`,`shutdown_signal`,{signal:`SIGINT`}),T&&!T.signal.aborted&&T.abort(),oe(0)}),tr(async()=>{let t={};for(let e of ot(g()))Cn(e)&&(t[e.type]=(t[e.type]??0)+1);gr(`info`,`run_state_at_shutdown`,{run_active:b,run_phase:x,worker_status:wi(),internal_events_pending:e.internalEventsPending,bg_tasks:t})}),bi(e=>{(e==="default"||e===`acceptEdits`||e===`bypassPermissions`||e===`plan`||e===`auto`||e===`dontAsk`)&&E.enqueue({type:`system`,subtype:`status`,status:null,permissionMode:e,uuid:X(),session_id:m()})});let D={abortController:null,inflightPromise:null,lastEmitted:null,pendingSuggestion:null,pendingLastEmittedEntry:null},ie;v.enableAuthStatus&&(ie=Nr.getInstance().subscribe(e=>{E.enqueue({type:`auth_status`,isAuthenticating:e.isAuthenticating,output:e.output,error:e.error,uuid:X(),session_id:m()})}));let ae=e=>{let t=Ii(e);t&&E.enqueue({type:`rate_limit_event`,rate_limit_info:t,uuid:X(),session_id:m()})};Tn.add(ae);let k=d,A=kt(d,Z(),100),se=li(100),ce=process.env.CLAUDE_CODE_RESUME_INTERRUPTED_TURN;y&&y.kind!==`none`&&ce&&(W(`[print.ts] Auto-resuming interrupted turn (kind: ${y.kind})`),to(k,y.message),Be({mode:`prompt`,value:y.message.message.content,uuid:X()}));let le=Bt().map(e=>{let t=e.value===null?`default`:e.value,n=t==="default"?Gr():kr(t),r=Ge(n),i=st(n),a=Lr(e.value),o=Mr(n);return{name:t,value:t,displayName:e.label,description:e.description,...r&&{supportsEffort:!0,supportedEffortLevels:Ae(n)?[...ne]:ne.filter(e=>e!==`max`)},...i&&{supportsAdaptiveThinking:!0},...a&&{supportsFastMode:!0},...o&&{supportsAutoMode:!0}}}),de=v.userSpecifiedModel;function fe(e,t){let n=Dt(e,Xr(t));k.push(...n);for(let e of n)typeof e.message.content==`string`&&e.message.content.includes(`<local-command-stdout>`)&&E.enqueue({type:`user`,content:e.message.content,message:e.message,session_id:m(),parent_tool_use_id:null,uuid:e.uuid,timestamp:e.timestamp,isReplay:!0})}let j=[],M=[],me=new Set;function ge(t){for(let n of t){if(n.type!==`connected`||me.has(n.name)||n.config.type===`sdk`)continue;let t=n.name;try{n.client.setRequestHandler(ji,async(n,r)=>{xr(t,`Elicitation request received in print mode: ${U(n)}`);let i=n.params.mode===`url`?`url`:`form`;Y(`tengu_mcp_elicitation_shown`,{mode:i});let a=await Ye(t,n.params,r.signal);if(a)return xr(t,`Elicitation resolved by hook: ${U(a)}`),Y(`tengu_mcp_elicitation_response`,{mode:i,action:a.action}),a;let o=`url`in n.params?n.params.url:void 0,s=`requestedSchema`in n.params?n.params.requestedSchema:void 0,c=`elicitationId`in n.params?n.params.elicitationId:void 0,l=await e.handleElicitation(t,n.params.message,s,r.signal,i,o,c),u=await An(t,l,r.signal,i,c);return Y(`tengu_mcp_elicitation_response`,{mode:i,action:u.action}),u}),n.client.setNotificationHandler(Ai,e=>{let{elicitationId:n}=e.params;xr(t,`Elicitation completion notification: ${n}`),Fe({message:`MCP server "${t}" confirmed elicitation ${n} complete`,notificationType:`elicitation_complete`}),E.enqueue({type:`system`,subtype:`elicitation_complete`,mcp_server_name:t,elicitation_id:n,uuid:X(),session_id:m()})}),me.add(t)}catch{}}}async function ye(){let t=new Set(Object.keys(p)),n=new Set(j.map(e=>e.name)),r=Array.from(t).some(e=>!n.has(e)),i=Array.from(n).some(e=>!t.has(e)),a=j.some(e=>e.type===`pending`),o=j.some(e=>e.type===`failed`);if(r||i||a||o){for(let e of j)t.has(e.name)||e.type===`connected`&&await e.cleanup();let r=await en(p,(t,n)=>e.sendMcpMessage(t,n));j=r.clients,M=r.tools;let i=dr([...n,...t]);_(e=>({...e,mcp:{...e.mcp,tools:[...e.mcp.tools.filter(e=>!i.some(t=>e.name.startsWith(K(t)))),...M]}})),xe(j)}}ye();let N={clients:[],tools:[],configs:{}},be=e=>{let t=_e(e.toolPermissionContext,e.mcp.tools),n=pe(oa([...o,...M,...N.tools],t,e.toolPermissionContext.mode),`name`);v.permissionPromptToolName&&(n=n.filter(e=>!oi(e,v.permissionPromptToolName)));let r=c();if(r&&!v.jsonSchema){let e=ai(r);`tool`in e&&(n=[...n,e.tool])}return n},P=null,Se=0;function Te(){if(!P)return;let e=Math.min(Se,k.length),t=k.slice(e).filter(e=>e.type===`user`||e.type===`assistant`);Se=k.length,t.length>0&&P.writeMessages(t)}let Ee=Promise.resolve({response:{added:[],removed:[],errors:{}},sdkServersChanged:!1});function De(e){let t=async()=>{let t=new Set(j.map(e=>e.name)),n=await oo(e,{configs:p,clients:j,tools:M},N,_);for(let e of Object.keys(p))delete p[e];if(Object.assign(p,n.newSdkState.configs),j=n.newSdkState.clients,M=n.newSdkState.tools,N=n.newDynamicState,n.sdkServersChanged){let e=new Set(j.map(e=>e.name)),n=dr([...t,...e]);_(e=>({...e,mcp:{...e.mcp,tools:[...e.mcp.tools.filter(e=>!n.some(t=>e.name.startsWith(K(t)))),...M]}}))}return{response:n.response,sdkServersChanged:n.sdkServersChanged}};return Ee=Ee.then(t,t),Ee}function Oe(){let e=g(),t=e.mcp.clients,n=pe([...e.mcp.tools,...N.tools],`name`),r=new Set([...t.map(e=>e.name),...j.map(e=>e.name)]);return[...t,...j,...N.clients.filter(e=>!r.has(e.name))].map(e=>{let t;if(e.config.type===`sse`||e.config.type===`http`)t={type:e.config.type,url:e.config.url,headers:e.config.headers,oauth:e.config.oauth};else if(e.config.type===`claudeai-proxy`)t={type:`claudeai-proxy`,url:e.config.url,id:e.config.id};else if(e.config.type===`stdio`||e.config.type===void 0){let n=e.config;t={type:`stdio`,command:n.command,args:n.args}}let r=e.type===`connected`?Wt(n,e.name).map(e=>({name:e.mcpInfo?.toolName??e.name,annotations:{readOnly:e.isReadOnly({})||void 0,destructive:e.isDestructive?.({})||void 0,openWorld:e.isOpenWorld?.({})||void 0}})):void 0;return{name:e.name,status:e.type,serverInfo:e.type===`connected`?e.serverInfo:void 0,error:e.type===`failed`?e.error:void 0,config:t,scope:e.config.scope,tools:r}})}async function ke(){try{await Promise.all([Promise.resolve(),_r(`headless_managed_settings_wait`,()=>Ji())]),await za()&&await ze()}catch(e){J(e)}}let je=null;i()||(n(process.env.CLAUDE_CODE_SYNC_PLUGIN_INSTALL)?je=ke():ke());let Me=Ma(()=>!b),I=a,L=ee;async function Le(){let{agentDefinitions:e}=await _a(_);I=await yn(Z());let t=L.filter(e=>e.source===`flagSettings`);L=[...e.allAgents,...t]}async function ze(){let{servers:e}=await S(),t={};for(let[n,r]of Object.entries(e)){let e=r.type;(e===void 0||e===`stdio`||e===`sse`||e===`http`||e===`sdk`)&&(t[n]=r)}for(let[e,n]of Object.entries(p))n.type===`sdk`&&!(e in t)&&(t[e]=n);let{response:n,sdkServersChanged:r}=await De(t);r&&ye(),W(`Headless MCP refresh: added=${n.added.length}, removed=${n.removed.length}`)}let Ve=ga.subscribe(()=>{Re(),yn(Z()).then(e=>{I=e})}),Ue=()=>{setTimeout(()=>{!$?.isProactiveActive()||$.isProactivePaused()||C||(async()=>{let e=await Ne({basePrompt:`<${yr}>${new Date().toLocaleTimeString()}</${yr}>`,currentDir:Z(),shouldCreate:()=>!C});if(C){await jn({commands:e});return}for(let t of e)Be({...t,uuid:X()});R()})().catch(e=>{J(e),W(`[Proactive] failed to create headless tick: ${e}`,{level:`error`})})},0)};_t(()=>{T&&ve(`now`).length>0&&T.abort(`interrupt`)});let R=async()=>{if(b)return;if(b=!0,x=void 0,xi(`running`),Me.stop(),H(`run_entry`),await ye(),H(`after_updateSdkMcp`),je){let e=parseInt(process.env.CLAUDE_CODE_SYNC_PLUGIN_INSTALL_TIMEOUT_MS||``,10);if(e>0){let t=Qr(e).then(()=>`timeout`);await Promise.race([je,t])===`timeout`&&(J(Error(`CLAUDE_CODE_SYNC_PLUGIN_INSTALL: plugin installation timed out after ${e}ms`)),Y(`tengu_sync_plugin_install_timeout`,{timeout_ms:e}))}else await je;je=null,await Le();let{setupPluginHookHotReload:t}=await import(`./loadPluginHooks-z1-zvBLw.js`);t()}let n=e=>e.agentId===void 0;try{let r,i=!1,a=async()=>{for(;r=Un(n);){if(r.mode!==`prompt`&&r.mode!==`orphaned-permission`&&r.mode!==`task-notification`)throw Error(`only prompt commands are supported in streaming mode`);let i=[r];if(r.mode===`prompt`)for(;Ka(r,Ke(n));)i.push(Un(n));let a=await Bn(i);if(i=a.attachmentCommands,i.length===0)continue;r=i[0],r.mode===`prompt`&&i.length>1&&(r={...r,value:Ga(i.map(e=>e.value)),uuid:i.findLast(e=>e.uuid)?.uuid??r.uuid});let o=i.map(e=>e.uuid).filter(e=>e!==void 0);if(v.replayUserMessages&&i.length>1)for(let e of i)e.uuid&&e.uuid!==r.uuid&&E.enqueue({type:`user`,content:e.value,message:{role:`user`,content:e.value},session_id:m(),parent_tool_use_id:null,uuid:e.uuid,isReplay:!0});let s=g(),l=[...s.mcp.clients,...j,...N.clients];ge(l);let u=be(s);for(let e of o)Ot(e,`started`);if(r.mode===`task-notification`){let e=typeof r.value==`string`?r.value:``,t=e.match(/<task-id>([^<]+)<\/task-id>/),n=e.match(/<tool-use-id>([^<]+)<\/tool-use-id>/),i=e.match(/<output-file>([^<]+)<\/output-file>/),a=e.match(/<status>([^<]+)<\/status>/),o=e.match(/<summary>([^<]+)<\/summary>/),s=e=>e===`completed`||e===`failed`||e===`stopped`||e===`killed`,c=a?.[1],l=s(c)?c===`killed`?`stopped`:c:`completed`,u=e.match(/<usage>([\s\S]*?)<\/usage>/)?.[1]??``,d=u.match(/<total_tokens>(\d+)<\/total_tokens>/),f=u.match(/<tool_uses>(\d+)<\/tool_uses>/),p=u.match(/<duration_ms>(\d+)<\/duration_ms>/);a&&E.enqueue({type:`system`,subtype:`task_notification`,task_id:t?.[1]??``,tool_use_id:n?.[1],status:l,output_file:i?.[1]??``,summary:o?.[1]??``,usage:d&&f?{total_tokens:parseInt(d[1],10),tool_uses:parseInt(f[1],10),duration_ms:p?parseInt(p[1],10):0}:void 0,session_id:m(),uuid:X()})}let d=r.value,p=a.claimedCommands;if(e instanceof Ea&&r.mode===`prompt`&&Y(`tengu_bridge_message_received`,{is_repl:!1}),D.abortController?.abort(),D.abortController=null,D.pendingSuggestion=null,D.pendingLastEmittedEntry=null,D.lastEmitted&&r.mode===`prompt`){let e=typeof d==`string`?d:d.find(e=>e.type===`text`)?.text;typeof e==`string`&&we(D.lastEmitted.text,e,D.lastEmitted.emittedAt,D.lastEmitted.promptId,D.lastEmitted.generationRequestId),D.lastEmitted=null}T=Rt(),H(`before_ask`),On();let h=r,ee=!1;try{if(await Rr(h.workload??v.workload,async()=>{for await(let t of ca({commands:pe([...I,...s.mcp.commands],`name`),prompt:d,promptUuid:h.uuid,isMeta:h.isMeta,cwd:Z(),tools:u,verbose:v.verbose,mcpClients:l,thinkingConfig:v.thinkingConfig,maxTurns:v.maxTurns,maxBudgetUsd:v.maxBudgetUsd,taskBudget:v.taskBudget,canUseTool:f,userSpecifiedModel:de,fallbackModel:v.fallbackModel,jsonSchema:c()??v.jsonSchema,mutableMessages:k,getReadFileCache:()=>se.size===0?A:di(A,se),setReadFileCache:e=>{A=e;for(let[e,t]of se.entries()){let n=A.get(e);(!n||t.timestamp>n.timestamp)&&A.set(e,t)}se.clear()},customSystemPrompt:v.systemPrompt,appendSystemPrompt:v.appendSystemPrompt,getAppState:g,setAppState:_,abortController:T,replayUserMessages:v.replayUserMessages,includePartialMessages:v.includePartialMessages,handleElicitation:(t,n,r)=>e.handleElicitation(t,n.message,void 0,r,n.mode,n.url,`elicitationId`in n?n.elicitationId:void 0),agents:L,orphanedPermission:h.orphanedPermission,setSDKStatus:e=>{E.enqueue({type:`system`,subtype:`status`,status:e,session_id:m(),uuid:X()})}}))if(Te(),t.type===`result`){ee=!!t.is_error;for(let e of fi())E.enqueue(e);ot(g()).some(e=>(e.type===`local_agent`||e.type===`local_workflow`)&&Cn(e))?w=t:(w=null,E.enqueue(t))}else{for(let e of fi())E.enqueue(e);E.enqueue(t)}}),ee)await at({commands:p,outcome:{type:`failed`,message:`ask() returned an error result`},currentDir:Z(),priority:`later`,workload:h.workload??v.workload});else{let e=await at({commands:p,outcome:{type:`completed`},currentDir:Z(),priority:`later`,workload:h.workload??v.workload});for(let t of e)Be({...t,uuid:X()})}}catch(e){throw await at({commands:p,outcome:{type:`failed`,error:e},currentDir:Z(),priority:`later`,workload:h.workload??v.workload}),e}for(let e of o)Ot(e,`completed`);if(Te(),P?.sendResult(),v.promptSuggestions&&!t(process.env.CLAUDE_CODE_ENABLE_PROMPT_SUGGESTION)){D.abortController?.abort();let e=new AbortController;D.abortController=e;let t=qt();if(!t)Ht(`sdk_no_params`,void 0,void 0,`sdk`);else{let n={promise:null};n.promise=(async()=>{try{let n=await zt(e,k,g,t,`sdk`);if(!n||e.signal.aborted)return;let r={type:`prompt_suggestion`,suggestion:n.suggestion,uuid:X(),session_id:m()},i={text:n.suggestion,emittedAt:Date.now(),promptId:n.promptId,generationRequestId:n.generationRequestId};w?(D.pendingSuggestion=r,D.pendingLastEmittedEntry={text:i.text,promptId:i.promptId,generationRequestId:i.generationRequestId}):(D.lastEmitted=i,E.enqueue(r))}catch(e){if(e instanceof Error&&(e.name===`AbortError`||e.name===`APIUserAbortError`)){Ht(`aborted`,void 0,void 0,`sdk`);return}J(Yn(e))}finally{D.inflightPromise===n.promise&&(D.inflightPromise=null)}})(),D.inflightPromise=n.promise}}nn(),pt(),Ct()}};do{for(let e of fi())E.enqueue(e);x=`draining_commands`,await a(),i=!1;{let e=ot(g()).some(e=>Cn(e)),t=Ke(n)!==void 0;(e||t)&&(i=!0,t||(x=`waiting_for_agents`,await Qr(100)))}}while(i);w&&(E.enqueue(w),w=null,D.pendingSuggestion&&(E.enqueue(D.pendingSuggestion),D.pendingLastEmittedEntry&&(D.lastEmitted={...D.pendingLastEmittedEntry,emittedAt:Date.now()},D.pendingLastEmittedEntry=null),D.pendingSuggestion=null))}catch(t){try{await e.write({type:`result`,subtype:`error_during_execution`,duration_ms:0,duration_api_ms:0,is_error:!0,num_turns:0,stop_reason:null,session_id:m(),total_cost_usd:0,usage:Si,modelUsage:{},permission_denials:[],uuid:X(),errors:[G(t),...Sr().map(e=>e.error)]})}catch{}D.abortController?.abort(),O(1);return}finally{if(x=`finally_flush`,await e.flushInternalEvents(),x=`finally_post_flush`,!Ut()){xi(`idle`);for(let e of fi())E.enqueue(e)}b=!1,Me.start()}if($?.isProactiveActive()&&!$.isProactivePaused()&&Ke(n)===void 0&&!C){Ue();return}if(Ke(n)!==void 0){R();return}C&&(D.inflightPromise&&await Promise.race([D.inflightPromise,Qr(5e3)]),D.abortController?.abort(),D.abortController=null,await Ce(),Ve(),ie?.(),Tn.delete(ae),E.done())},z=function(e,t){E.enqueue({type:`control_response`,response:{subtype:`success`,request_id:e.request_id,response:t}})},B=function(e,t){E.enqueue({type:`control_response`,response:{subtype:`error`,request_id:e.request_id,error:t}})},qe=new Set;e.setUnexpectedResponseCallback(async e=>{await io({message:e,setAppState:_,handledToolUseIds:qe,onEnqueued:()=>{R()}})});let Je=new Map,Ze=new Map,Qe=new Set,$e=new Map,V=null;return(async()=>{let t=!1;gr(`info`,`cli_message_loop_started`);for await(let n of e.structuredInput){let i=`uuid`in n?n.uuid:void 0;if(i&&n.type!==`user`&&n.type!==`control_response`&&Ot(i,`completed`),n.type===`control_request`){let i=n,o=i.request;if(i.request.subtype===`interrupt`)_(e=>({...e,attribution:{...e.attribution,escapeCount:e.attribution.escapeCount+1}})),T&&T.abort(),D.abortController?.abort(),D.abortController=null,D.lastEmitted=null,D.pendingSuggestion=null,z(i);else if(o.subtype===`end_session`){W(`[print.ts] end_session received, reason=${o.reason??`unspecified`}`),T&&T.abort(),D.abortController?.abort(),D.abortController=null,D.lastEmitted=null,D.pendingSuggestion=null,z(i);break}else if(i.request.subtype===`initialize`){if(i.request.sdkMcpServers&&i.request.sdkMcpServers.length>0)for(let e of i.request.sdkMcpServers)p[e]={type:`sdk`,name:e};await Za(i.request,i.request_id,t,E,a,le,e,!!v.enableAuthStatus,v,ee,g),i.request.promptSuggestions&&_(e=>e.promptSuggestionEnabled?e:{...e,promptSuggestionEnabled:!0}),i.request.agentProgressSummaries&&h(!0),t=!0,xn()&&R()}else if(i.request.subtype===`set_permission_mode`){let e=i.request;_(t=>({...t,toolPermissionContext:$a(e,i.request_id,t.toolPermissionContext,E),isUltraplanMode:e.ultraplan??t.isUltraplanMode}))}else if(i.request.subtype===`set_model`){let e=i.request.model??`default`,t=e==="default"?Gr():e;de=t,u(t),Ci({model:t}),fe(e,t),z(i)}else if(i.request.subtype===`set_max_thinking_tokens`)i.request.max_thinking_tokens===null?v.thinkingConfig=void 0:i.request.max_thinking_tokens===0?v.thinkingConfig={type:`disabled`}:v.thinkingConfig={type:`enabled`,budgetTokens:i.request.max_thinking_tokens},z(i);else if(i.request.subtype===`mcp_status`)z(i,{mcpServers:Oe()});else if(i.request.subtype===`get_context_usage`)try{let e=g(),t=await fa({messages:k,getAppState:g,options:{mainLoopModel:Jr(),tools:be(e),agentDefinitions:e.agentDefinitions,customSystemPrompt:v.systemPrompt,appendSystemPrompt:v.appendSystemPrompt}});z(i,{...t})}catch(e){B(i,G(e))}else if(i.request.subtype===`mcp_message`){let e=i.request,t=j.find(t=>t.name===e.server_name);t&&t.type===`connected`&&t.client?.transport?.onmessage&&t.client.transport.onmessage(e.message),z(i)}else if(i.request.subtype===`rewind_files`){let e=g(),t=await Qa(i.request.user_message_id,e,_,i.request.dry_run??!1);t.canRewind||i.request.dry_run?z(i,t):B(i,t.error??`Unexpected error`)}else if(i.request.subtype===`cancel_async_message`){let e=i.request.message_uuid,t=re(t=>t.uuid===e);z(i,{cancelled:t.length>0})}else if(i.request.subtype===`seed_read_state`){try{let e=Tr(i.request.path),t=Math.floor((await Ca(e)).mtimeMs);if(t<=i.request.mtime){let n=await Sa(e,`utf-8`),r=(n.charCodeAt(0)===65279?n.slice(1):n).replaceAll(`\r
|
|
20
|
+
`,`
|
|
21
|
+
`);se.set(e,{content:r,timestamp:t,offset:void 0,limit:void 0})}}catch{}z(i)}else if(i.request.subtype===`mcp_set_servers`){let{response:e,sdkServersChanged:t}=await De(i.request.servers);z(i,e),t&&ye()}else if(i.request.subtype===`reload_plugins`)try{let e=await _a(_),t=L.filter(e=>e.source===`flagSettings`);L=[...e.agentDefinitions.allAgents,...t];let n=[],[r,a,o]=await Promise.allSettled([yn(Z()),ze(),tn()]);r.status===`fulfilled`?I=r.value:J(r.reason),a.status===`rejected`&&J(a.reason),o.status===`fulfilled`?n=o.value.enabled.map(e=>({name:e.name,path:e.path,source:e.source})):J(o.reason),z(i,{commands:I.filter(e=>e.userInvocable!==!1).map(e=>({name:ct(e),description:He(e),argumentHint:e.argumentHint||``})),agents:L.map(e=>({name:e.agentType,description:e.whenToUse,model:e.model===`inherit`?void 0:e.model})),plugins:n,mcpServers:Oe(),error_count:e.error_count})}catch(e){B(i,G(e))}else if(i.request.subtype===`mcp_reconnect`){let e=g(),{serverName:t}=i.request;me.delete(t);let n=ue(t)??r.find(e=>e.name===t)?.config??j.find(e=>e.name===t)?.config??N.clients.find(e=>e.name===t)?.config??e.mcp.clients.find(e=>e.name===t)?.config??null;if(!n)B(i,`Server not found: ${t}`);else{let e=await mn(t,n),r=K(t);if(_(n=>({...n,mcp:{...n.mcp,clients:n.mcp.clients.map(n=>n.name===t?e.client:n),tools:[...F(n.mcp.tools,e=>e.name?.startsWith(r)),...e.tools],commands:[...F(n.mcp.commands,e=>Ln(e,t)),...e.commands],resources:e.resources&&e.resources.length>0?{...n.mcp.resources,[t]:e.resources}:si(n.mcp.resources,t)}})),N={...N,clients:[...N.clients.filter(e=>e.name!==t),e.client],tools:[...N.tools.filter(e=>!e.name?.startsWith(r)),...e.tools]},e.client.type===`connected`)ge([e.client]),z(i);else{let t=e.client.type===`failed`?e.client.error??`Connection failed`:`Server status: ${e.client.type}`;B(i,t)}}}else if(i.request.subtype===`mcp_toggle`){let e=g(),{serverName:t,enabled:n}=i.request;me.delete(t);let a=ue(t)??r.find(e=>e.name===t)?.config??j.find(e=>e.name===t)?.config??N.clients.find(e=>e.name===t)?.config??e.mcp.clients.find(e=>e.name===t)?.config??null;if(!a)B(i,`Server not found: ${t}`);else if(n){We(t,!0);let e=await mn(t,a),n=K(t);if(_(r=>({...r,mcp:{...r.mcp,clients:r.mcp.clients.map(n=>n.name===t?e.client:n),tools:[...F(r.mcp.tools,e=>e.name?.startsWith(n)),...e.tools],commands:[...F(r.mcp.commands,e=>Ln(e,t)),...e.commands],resources:e.resources&&e.resources.length>0?{...r.mcp.resources,[t]:e.resources}:si(r.mcp.resources,t)}})),e.client.type===`connected`)ge([e.client]),z(i);else{let t=e.client.type===`failed`?e.client.error??`Connection failed`:`Server status: ${e.client.type}`;B(i,t)}}else{We(t,!1);let n=[...r,...j,...N.clients,...e.mcp.clients].find(e=>e.name===t);n&&n.type===`connected`&&await It(t,a);let o=K(t);_(e=>({...e,mcp:{...e.mcp,clients:e.mcp.clients.map(e=>e.name===t?{name:t,type:`disabled`,config:a}:e),tools:F(e.mcp.tools,e=>e.name?.startsWith(o)),commands:F(e.mcp.commands,e=>Ln(e,t)),resources:si(e.mcp.resources,t)}})),z(i)}}else if(o.subtype===`mcp_authenticate`){let e=o.serverName,t=g(),n=ue(e)??r.find(t=>t.name===e)?.config??t.mcp.clients.find(t=>t.name===e)?.config??null;if(!n)B(i,`Server not found: ${e}`);else if(n.type!==`sse`&&n.type!==`http`)B(i,`Server type "${n.type}" does not support OAuth authentication`);else try{Je.get(e)?.abort();let t=new AbortController;Je.set(e,t);let r,a=new Promise(e=>{r=e}),o=Ft(e,n,e=>r(e),t.signal,{skipBrowserOpen:!0,onWaitingForCallback:t=>{Ze.set(e,t)}}),s=await Promise.race([a,o.then(()=>null)]);s?z(i,{authUrl:s,requiresUserAction:!0}):z(i,{requiresUserAction:!1}),$e.set(e,o),o.then(async()=>{if(he(e)||Qe.has(e))return;let t=await mn(e,n),r=K(e);_(n=>({...n,mcp:{...n.mcp,clients:n.mcp.clients.map(n=>n.name===e?t.client:n),tools:[...F(n.mcp.tools,e=>e.name?.startsWith(r)),...t.tools],commands:[...F(n.mcp.commands,t=>Ln(t,e)),...t.commands],resources:t.resources&&t.resources.length>0?{...n.mcp.resources,[e]:t.resources}:si(n.mcp.resources,e)}})),N={...N,clients:[...N.clients.filter(t=>t.name!==e),t.client],tools:[...N.tools.filter(e=>!e.name?.startsWith(r)),...t.tools]}}).catch(t=>{W(`MCP OAuth failed for ${e}: ${t}`,{level:`error`})}).finally(()=>{Je.get(e)===t&&(Je.delete(e),Ze.delete(e),Qe.delete(e),$e.delete(e))})}catch(e){B(i,G(e))}}else if(o.subtype===`mcp_oauth_callback_url`){let e=o.serverName,t=o.callbackUrl,n=Ze.get(e);if(n){let r=!1;try{let e=new URL(t);r=e.searchParams.has(`code`)||e.searchParams.has(`error`)}catch{}if(!r)B(i,`Invalid callback URL: missing authorization code. Please paste the full redirect URL including the code parameter.`);else{Qe.add(e),n(t);let r=$e.get(e);if(r)try{await r,z(i)}catch(e){B(i,e instanceof Error?e.message:`OAuth authentication failed`)}else z(i)}}else B(i,`No active OAuth flow for server: ${e}`)}else if(o.subtype===`claude_authenticate`){let e=o.loginWithClaudeAi;V?.service.cleanup(),Y(`tengu_oauth_flow_start`,{loginWithClaudeAi:e??!0});let t=new Yi,n,r=new Promise(e=>{n=e}),a=t.startOAuthFlow(async(e,t)=>{n({manualUrl:e,automaticUrl:t})},{loginWithClaudeAi:e??!0,skipBrowserOpen:!0}).then(async t=>{await Xi(t),Y(`tengu_oauth_success`,{loginWithClaudeAi:e??!0})}).finally(()=>{t.cleanup(),V?.service===t&&(V=null)});V={service:t,flow:a},a.catch(e=>W(`claude_authenticate flow ended: ${e}`,{level:`info`}));try{let{manualUrl:e,automaticUrl:t}=await Promise.race([r,a.then(()=>{throw Error(`OAuth flow completed without producing auth URLs`)})]);z(i,{manualUrl:e,automaticUrl:t})}catch(e){B(i,G(e))}}else if(o.subtype===`claude_oauth_callback`||o.subtype===`claude_oauth_wait_for_completion`)if(!V)B(i,`No active claude_authenticate flow`);else{o.subtype===`claude_oauth_callback`&&V.service.handleManualAuthCodeInput({authorizationCode:o.authorizationCode,state:o.state});let{flow:e}=V;e.then(()=>{let e=Zr();z(i,{account:{email:e?.email,organization:e?.organization,subscriptionType:e?.subscription,tokenSource:e?.tokenSource,apiKeySource:e?.apiKeySource,apiProvider:Br()}})},e=>B(i,G(e)))}else if(o.subtype===`mcp_clear_auth`){let e=o.serverName,t=g(),n=ue(e)??r.find(t=>t.name===e)?.config??t.mcp.clients.find(t=>t.name===e)?.config??null;if(!n)B(i,`Server not found: ${e}`);else if(n.type!==`sse`&&n.type!==`http`)B(i,`Cannot clear auth for server type "${n.type}"`);else{await un(e,n);let t=await mn(e,n),r=K(e);_(n=>({...n,mcp:{...n.mcp,clients:n.mcp.clients.map(n=>n.name===e?t.client:n),tools:[...F(n.mcp.tools,e=>e.name?.startsWith(r)),...t.tools],commands:[...F(n.mcp.commands,t=>Ln(t,e)),...t.commands],resources:t.resources&&t.resources.length>0?{...n.mcp.resources,[e]:t.resources}:si(n.mcp.resources,e)}})),z(i,{})}}else if(i.request.subtype===`apply_flag_settings`){let e=Jr(),t=s()??{},n=i.request.settings,r={...t,...n};for(let e of Object.keys(r))r[e]===null&&delete r[e];l(r),Ie.notifyChange(`flagSettings`),`model`in n&&(n.model==null?u(void 0):u(String(n.model)));let a=Jr();if(a!==e){de=a;let e=n.model?String(n.model):`default`;Ci({model:a}),fe(e,a)}z(i)}else if(i.request.subtype===`get_settings`){let e=g(),t=Jr(),n=Ge(t)?Dn(t,e.effortValue):void 0;z(i,{...sr(),applied:{model:t,effort:typeof n==`string`?n:null}})}else if(i.request.subtype===`stop_task`){let{task_id:e}=i.request;try{await Xt(e,{getAppState:g,setAppState:_}),z(i,{})}catch(e){B(i,G(e))}}else if(o.subtype===`generate_session_title`){let e=o.description,t=o.persist,n=(T&&!T.signal.aborted?T:Rt()).signal;(async()=>{try{let r=await Li(e,n);if(r&&t)try{Xe(m(),r)}catch(e){J(e)}z(i,{title:r})}catch(e){B(i,G(e))}})()}else if(o.subtype===`side_question`){let e=o.question;(async()=>{try{let t=qt(),n=t?{...t,toolUseContext:{...t.toolUseContext,abortController:Rt()}}:await la({tools:be(g()),commands:I,mcpClients:[...g().mcp.clients,...j,...N.clients],messages:k,readFileState:A,getAppState:g,setAppState:_,customSystemPrompt:v.systemPrompt,appendSystemPrompt:v.appendSystemPrompt,thinkingConfig:v.thinkingConfig,agents:L}),r=await da({question:e,cacheSafeParams:n});z(i,{response:r.response})}catch(e){B(i,G(e))}})()}else if(i.request.subtype===`set_proactive`)i.request.enabled?$.isProactiveActive()||($.activateProactive(`command`),Ue()):$.deactivateProactive(),z(i);else if(o.subtype===`remote_control`)if(o.enabled)if(P)z(i,{session_url:te(P.bridgeSessionId,P.sessionIngressUrl),connect_url:Pe(P.environmentId,P.sessionIngressUrl),environment_id:P.environmentId});else{let t;try{let{initReplBridge:n}=await import(`./initReplBridge-D0Xec8S-.js`),r=await n({onInboundMessage(e){let t=ia(e);if(!t)return;let{content:n,uuid:r}=t;Be({value:n,mode:`prompt`,uuid:r,skipSlashCommands:!0}),R()},onPermissionResponse(t){e.injectControlResponse(t)},onInterrupt(){T?.abort()},onSetModel(e){let t=e==="default"?Gr():e;de=t,u(t)},onSetMaxThinkingTokens(e){e===null?v.thinkingConfig=void 0:e===0?v.thinkingConfig={type:`disabled`}:v.thinkingConfig={type:`enabled`,budgetTokens:e}},onStateChange(e,n){e===`failed`&&(t=n),W(`[bridge:sdk] State change: ${e}${n?` — ${n}`:``}`),E.enqueue({type:`system`,subtype:`bridge_state`,state:e,detail:n,uuid:X(),session_id:m()})},initialMessages:k.length>0?k:void 0});r?(P=r,Se=k.length,e.setOnControlRequestSent(e=>{r.sendControlRequest(e)}),e.setOnControlRequestResolved(e=>{r.sendControlCancelRequest(e)}),z(i,{session_url:te(r.bridgeSessionId,r.sessionIngressUrl),connect_url:Pe(r.environmentId,r.sessionIngressUrl),environment_id:r.environmentId})):B(i,t??`Remote Control initialization failed`)}catch(e){B(i,G(e))}}else P&&(e.setOnControlRequestSent(void 0),e.setOnControlRequestResolved(void 0),await P.teardown(),P=null),z(i);else B(i,`Unsupported control request subtype: ${i.request.subtype}`);continue}else if(n.type===`control_response`){v.replayUserMessages&&E.enqueue(n);continue}else if(n.type===`keep_alive`)continue;else if(n.type===`update_environment_variables`)continue;else if(n.type===`assistant`||n.type===`system`){let e=Pi([n]);k.push(...e),n.type===`assistant`&&v.replayUserMessages&&E.enqueue(n);continue}if(n.type!==`user`)continue;let o=n;if(t=!0,o.uuid){let e=m(),t=await Lt(e,o.uuid);if(t||Va.has(o.uuid)){W(`Skipping duplicate user message: ${o.uuid}`),v.replayUserMessages&&(W(`Sending acknowledgment for duplicate user message: ${o.uuid}`),E.enqueue({type:`user`,content:o.message?.content??``,message:o.message,session_id:e,parent_tool_use_id:null,uuid:o.uuid,timestamp:o.timestamp,isReplay:!0})),t&&Ot(o.uuid,`completed`);continue}Ua(o.uuid)}Be({mode:`prompt`,value:await Ni(o,o.message.content),uuid:o.uuid,priority:o.priority}),_(e=>({...e,attribution:Di(e.attribution,e=>{vt(e).catch(e=>{W(`Attribution: Failed to save snapshot: ${e}`)})})})),R()}C=!0,b||(D.inflightPromise&&await Promise.race([D.inflightPromise,Qr(5e3)]),D.abortController?.abort(),D.abortController=null,await Ce(),Ve(),ie?.(),Tn.delete(ae),E.done())})(),E}function Ya(e){let t=async(n,r,i,a,o,s)=>{let c=s??await Ve(n,r,i,a,o);if(c.behavior===`allow`||c.behavior===`deny`)return c;let{signal:l,cleanup:u}=T(i.abortController.signal);if(l.aborted)return u(),{behavior:`deny`,message:`Permission prompt was aborted.`,decisionReason:{type:`permissionPromptTool`,permissionPromptToolName:n.name,toolResult:void 0}};let d=new Promise(e=>{l.addEventListener(`abort`,()=>e(`aborted`),{once:!0})}),f=e.call({tool_name:n.name,input:r,tool_use_id:o},i,t,a),p=await Promise.race([f,d]);if(u(),p===`aborted`||l.aborted)return{behavior:`deny`,message:`Permission prompt was aborted.`,decisionReason:{type:`permissionPromptTool`,permissionPromptToolName:n.name,toolResult:void 0}};let m=p,h=e.mapToolResultToToolResultBlockParam(m.data,`1`);if(!h.content||!Array.isArray(h.content)||!h.content[0]||h.content[0].type!==`text`||typeof h.content[0].text!=`string`)throw Error(`Permission prompt tool returned an invalid result. Expected a single text block param with type="text" and a string text value.`);return ta(aa().parse(Dr(h.content[0].text)),e,r,i)};return t}function Xa(e,t,n,r){if(e===`stdio`)return t.createCanUseTool(r);if(!e)return async(e,t,n,r,i,a)=>a??await Ve(e,t,n,r,i);let i=null;return async(t,r,a,o,s,c)=>{if(!i){let t=n(),r=t.find(t=>oi(t,e));if(!r){let n=`Error: MCP tool ${e} (passed via --permission-prompt-tool) not found. Available MCP tools: ${t.map(e=>e.name).join(`, `)||`none`}`;throw process.stderr.write(`${n}\n`),O(1),Error(n)}if(!r.inputJSONSchema){let t=`Error: tool ${e} (passed via --permission-prompt-tool) must be an MCP tool`;throw process.stderr.write(`${t}\n`),O(1),Error(t)}i=Ya(r)}return i(t,r,a,o,s,c)}}async function Za(e,t,n,r,i,a,o,s,c,l,p){if(n){r.enqueue({type:`control_response`,response:{subtype:`error`,error:`Already initialized`,request_id:t,pending_permission_requests:o.getPendingPermissionRequests()}});return}if(e.systemPrompt!==void 0&&(c.systemPrompt=e.systemPrompt),e.appendSystemPrompt!==void 0&&(c.appendSystemPrompt=e.appendSystemPrompt),e.promptSuggestions!==void 0&&(c.promptSuggestions=e.promptSuggestions),e.agents){let t=yt(e.agents,`flagSettings`);l.push(...t)}if(c.agent){let e=f()===c.agent,t=l.find(e=>e.agentType===c.agent);if(t&&!e){if(d(t.agentType),!c.systemPrompt&&!wn(t)){let e=t.getSystemPrompt();e&&(c.systemPrompt=e)}!c.userSpecifiedModel&&t.model&&t.model!==`inherit`&&u(kr(t.model)),t.initialPrompt&&o.prependUserMessage(t.initialPrompt)}else t?.initialPrompt&&o.prependUserMessage(t.initialPrompt)}let h=cr()?.outputStyle||`default`,ee=await V(Kn()),v=Zr();if(e.hooks){let t={};for(let[n,r]of Object.entries(e.hooks))t[n]=r.map(e=>{let t=e.hookCallbackIds.map(t=>o.createHookCallback(t,e.timeout));return{matcher:e.matcher,hooks:t}});_(t)}e.jsonSchema&&g(e.jsonSchema);let te={commands:i.filter(e=>e.userInvocable!==!1).map(e=>({name:ct(e),description:He(e),argumentHint:e.argumentHint||``})),agents:l.map(e=>({name:e.agentType,description:e.whenToUse,model:e.model===`inherit`?void 0:e.model})),output_style:h,available_output_styles:Object.keys(ee),models:a,account:{email:v?.email,organization:v?.organization,subscriptionType:v?.subscription,tokenSource:v?.tokenSource,apiKeySource:v?.apiKeySource,apiProvider:Br()},pid:process.pid};if(Vr()&&Wr()){let e=p();te.fast_mode_state=Fr(c.userSpecifiedModel??null,e.fastMode)}if(r.enqueue({type:`control_response`,response:{subtype:`success`,request_id:t,response:te}}),s){let e=Nr.getInstance().getStatus();e&&r.enqueue({type:`auth_status`,isAuthenticating:e.isAuthenticating,output:e.output,error:e.error,uuid:X(),session_id:m()})}}async function Qa(e,t,n,r){if(!Wn())return{canRewind:!1,error:`File rewinding is not enabled.`,filesChanged:[]};if(!Me(t.fileHistory,e))return{canRewind:!1,error:`No file checkpoint found for this message.`,filesChanged:[]};if(r){let n=await C(t.fileHistory,e);return{canRewind:!0,filesChanged:n?.filesChanged??[],insertions:n?.insertions,deletions:n?.deletions}}try{await Ue(e=>n(t=>({...t,fileHistory:e(t.fileHistory)})),e)}catch(e){return{canRewind:!1,error:`Failed to rewind: ${G(e)}`,filesChanged:[]}}return{canRewind:!0,filesChanged:[]}}function $a(e,t,n,r){if(e.mode===`bypassPermissions`){if(E())return r.enqueue({type:`control_response`,response:{subtype:`error`,request_id:t,error:`Cannot set permission mode to bypassPermissions because it is disabled by settings or configuration`}}),n;if(!n.isBypassPermissionsModeAvailable)return r.enqueue({type:`control_response`,response:{subtype:`error`,request_id:t,error:`Cannot set permission mode to bypassPermissions because the session was not launched with --dangerously-skip-permissions`}}),n}if(e.mode===`auto`&&!k()){let e=Nn();return r.enqueue({type:`control_response`,response:{subtype:`error`,request_id:t,error:e?`Cannot set permission mode to auto: ${nt(e)}`:`Cannot set permission mode to auto`}}),n}return r.enqueue({type:`control_response`,response:{subtype:`success`,request_id:t,response:{mode:e.mode}}}),{...Oe(n.mode,e.mode,n),mode:e.mode}}function eo(e,t){if(t===`stream-json`){let t={type:`result`,subtype:`error_during_execution`,duration_ms:0,duration_api_ms:0,is_error:!0,num_turns:0,stop_reason:null,session_id:m(),total_cost_usd:0,usage:Si,modelUsage:{},permission_denials:[],uuid:X(),errors:[e]};process.stdout.write(U(t)+`
|
|
22
|
+
`)}else process.stderr.write(e+`
|
|
23
|
+
`)}function to(e,t){let n=e.findIndex(e=>e.uuid===t.uuid);n!==-1&&e.splice(n,2)}async function no(e,t){let r=!ee();if(t.continue)try{Y(`tengu_continue_print`,{});let n=await Zt(void 0,void 0);if(n)return t.forkSession||n.sessionId&&(v(Pt(n.sessionId),n.fullPath?ya(n.fullPath):null),r&&await xt()),ha(n,e),hn(t.forkSession?{...n,worktreeSession:void 0}:n),{messages:n.messages,turnInterruptionState:n.turnInterruptionState,agentSetting:n.agentSetting}}catch(e){return J(e),O(1),{messages:[]}}if(t.teleport)try{if(!I(`allow_remote_sessions`))throw Error(`Remote sessions are disabled by your organization's policy.`);if(Y(`tengu_teleport_print`,{}),typeof t.teleport!=`string`)throw Error(`No session ID provided for teleport`);let{checkOutTeleportedSessionBranch:e,processMessagesForTeleportResume:n,teleportResumeCodeSession:r,validateGitState:i}=await import(`./teleport-hN3cAbYC.js`);await i();let a=await r(t.teleport),{branchError:o}=await e(a.branch);return{messages:n(a.log,o)}}catch(e){return J(e),O(1),{messages:[]}}if(t.resume)try{Y(`tengu_resume_print`,{});let i=Na(typeof t.resume==`string`?t.resume:``);if(!i){let e=`Error: --resume requires a valid session ID when used with --print. Usage: claude -p --resume <session-id>`;return typeof t.resume==`string`&&(e+=`. Session IDs must be in UUID format (e.g., 550e8400-e29b-41d4-a716-446655440000). Provided value "${t.resume}" is not a valid UUID`),eo(e,t.outputFormat),O(1),{messages:[]}}if(n(process.env.CLAUDE_CODE_USE_CCR_V2)){let[,n]=await Promise.all([Jt(i.sessionId),t.restoredWorkerState]);n&&(e(Qi(n)),typeof n.model==`string`&&u(n.model))}else i.isUrl&&i.ingressUrl&&n(process.env.ENABLE_SESSION_PERSISTENCE)&&await b(i.sessionId,i.ingressUrl);let a=await Zt(i.sessionId,i.jsonlFile||void 0);if(!a||a.messages.length===0)return i.isUrl||n(process.env.CLAUDE_CODE_USE_CCR_V2)?{messages:await(t.sessionStartHooksPromise??_n(`startup`))}:(eo(`No conversation found with session ID: ${i.sessionId}`,t.outputFormat),O(1),{messages:[]});if(t.resumeSessionAt){let e=a.messages.findIndex(e=>e.uuid===t.resumeSessionAt);if(e<0)return eo(`No message found with message.uuid of: ${t.resumeSessionAt}`,t.outputFormat),O(1),{messages:[]};a.messages=e>=0?a.messages.slice(0,e+1):[]}return!t.forkSession&&a.sessionId&&(v(Pt(a.sessionId),a.fullPath?ya(a.fullPath):null),r&&await xt()),ha(a,e),hn(t.forkSession?{...a,worktreeSession:void 0}:a),{messages:a.messages,turnInterruptionState:a.turnInterruptionState,agentSetting:a.agentSetting}}catch(e){return J(e),eo(e instanceof Error?`Failed to resume session: ${e.message}`:`Failed to resume session with --print mode`,t.outputFormat),O(1),{messages:[]}}return{messages:await(t.sessionStartHooksPromise??_n(`startup`))}}function ro(e,t){let n;return n=typeof e==`string`?e.trim()===``?rt([]):rt([U({type:`user`,content:e,uuid:``,session_id:``,message:{role:`user`,content:e},parent_tool_use_id:null})]):e,t.sdkUrl?new Ea(t.sdkUrl,n,t.replayUserMessages):new ea(n,t.replayUserMessages)}async function io({message:e,setAppState:t,onEnqueued:n,handledToolUseIds:r}){let i=e.response;if(i?.subtype===`success`&&i.response?.toolUseID&&typeof i.response.toolUseID==`string`){let e=i.response,t=e.toolUseID;if(!t)return!1;if(W(`handleOrphanedPermissionResponse: received orphaned control_response for toolUseID=${t} request_id=${i.request_id}`),r.has(t))return W(`handleOrphanedPermissionResponse: skipping duplicate orphaned permission for toolUseID=${t} (already handled)`),!1;let a=await dt(t);return a?(r.add(t),W(`handleOrphanedPermissionResponse: enqueuing orphaned permission for toolUseID=${t} messageID=${a.message.id}`),Be({mode:`orphaned-permission`,value:[],orphanedPermission:{permissionResult:e,assistantMessage:a}}),n?.(),!0):(W(`handleOrphanedPermissionResponse: no unresolved tool_use found for toolUseID=${t} (already resolved in transcript)`),!1)}return!1}function ao(e){return{...e,scope:`dynamic`}}async function oo(e,t,n,r){let{allowed:i,blocked:a}=Vn(e),o={};for(let e of a)o[e]=`Blocked by enterprise policy (allowedMcpServers/deniedMcpServers)`;let s={},c={};for(let[e,t]of Object.entries(i))t.type===`sdk`?s[e]=t:c[e]=t;let l=new Set(Object.keys(t.configs)),u=new Set(Object.keys(s)),d=[],f=[],p={...t.configs},m=[...t.clients],h=[...t.tools];for(let e of l)if(!u.has(e)){let t=m.find(t=>t.name===e);t&&t.type===`connected`&&await t.cleanup(),m=m.filter(t=>t.name!==e);let n=`mcp__${e}__`;h=h.filter(e=>!e.name.startsWith(n)),delete p[e],f.push(e)}for(let[e,t]of Object.entries(s))if(!l.has(e)){p[e]=t;let n={type:`pending`,name:e,config:{...t,scope:`dynamic`}};m=[...m,n],d.push(e)}let g=await so(c,n,r);return{response:{added:[...d,...g.response.added],removed:[...f,...g.response.removed],errors:{...o,...g.response.errors}},newSdkState:{configs:p,clients:m,tools:h},newDynamicState:g.newState,sdkServersChanged:d.length>0||f.length>0}}async function so(e,t,n){let r=new Set(Object.keys(t.configs)),i=new Set(Object.keys(e)),a=[...r].filter(e=>!i.has(e)),o=[...i].filter(e=>!r.has(e)),s=[...r].filter(e=>i.has(e)).filter(n=>{let r=t.configs[n],i=e[n];return!r||!i||!on(r,ao(i))}),c=[],l=[],u={},d=[...t.clients],f=[...t.tools];for(let e of[...a,...s]){let n=d.find(t=>t.name===e),r=t.configs[e];if(n&&r){if(n.type===`connected`)try{await n.cleanup()}catch(e){J(e)}await It(e,r)}let i=`mcp__${e}__`;f=f.filter(e=>!e.name.startsWith(i)),d=d.filter(t=>t.name!==e),a.includes(e)&&c.push(e)}for(let t of[...o,...s]){let n=e[t];if(!n)continue;let r=ao(n);if(n.type===`sdk`){l.push(t);continue}try{let e=await $e(t,r);if(d.push(e),e.type===`connected`){let t=await ut(e);f.push(...t)}else e.type===`failed`&&(u[t]=e.error||`Connection failed`);l.push(t)}catch(e){let n=Yn(e);u[t]=n.message,J(n)}}let p={};for(let t of i){let n=e[t];n&&(p[t]=ao(n))}let m={clients:d,tools:f,configs:p};return n(e=>{let n=new Set([...Object.keys(t.configs),...Object.keys(p)]),r=e.mcp.tools.filter(e=>{for(let t of n)if(e.name.startsWith(`mcp__${t}__`))return!1;return!0}),i=e.mcp.clients.filter(e=>!n.has(e.name));return{...e,mcp:{...e.mcp,tools:[...r,...f],clients:[...i,...d]}}}),{response:{added:l,removed:c,errors:u},newState:m}}export{qa as runHeadless};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{fi as t}from"./src-CDCSSo0U2.js";import{t as n}from"./jsx-runtime-Bb4Xn-E0.js";import{n as r,r as i}from"./analytics-BotDBGh0.js";import{a,i as o,o as s,r as c}from"./grove-DotW04-v.js";import{n as l,r as u,t as d}from"./Grove--kttLxvs.js";async function f(e){if(!await s())return e(m),null;let[t,n]=await Promise.all([o(),c()]);if(!t.success)return e(m),null;let r=t.data,a=n.success?n.data:null;async function u(t){if(t===`escape`||t===`defer`){e(`Privacy settings dialog dismissed`,{display:`system`});return}await f()}async function f(){let t=await o();if(!t.success){e(`Unable to retrieve updated privacy settings`,{display:`system`});return}let n=t.data;e(`"Help improve Claude" set to ${n.grove_enabled?`true`:`false`}.`),r.grove_enabled!==null&&r.grove_enabled!==n.grove_enabled&&i(`tengu_grove_policy_toggled`,{state:n.grove_enabled,location:`settings`})}return r.grove_enabled===null?(0,p.jsx)(d,{showIfAlreadyViewed:!0,onDone:u,location:`settings`}):(0,p.jsx)(l,{settings:r,domainExcluded:a?.domain_excluded,onDone:f})}var p,m;e((()=>{t(),u(),r(),a(),p=n(),m=`Review and manage your privacy settings at https://claude.ai/settings/data-privacy-controls`}))();export{f as call};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,t}from"./process-gEbdy6uY.js";e();export{t as exitWithError};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";function t(e){return t=>{t.code===`EPIPE`&&e.destroy()}}function n(){process.stdout.on(`error`,t(process.stdout)),process.stderr.on(`error`,t(process.stderr))}function r(e,t){e.destroyed||e.write(t)}function i(e){r(process.stdout,e)}function a(e){r(process.stderr,e)}function o(e){console.error(e),process.exit(1)}function s(e,t){return new Promise(n=>{let r=t=>{clearTimeout(o),e.off(`end`,i),e.off(`data`,a),n(t)},i=()=>r(!1),a=()=>clearTimeout(o),o=setTimeout(r,t,!0);e.once(`end`,i),e.once(`data`,a)})}var c=e((()=>{}));export{a,n as i,c as n,i as o,s as r,o as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e}from"./rolldown-runtime-DaDcL9Zw.js";import{I as t,fi as n,t as r}from"./src-CDCSSo0U2.js";import{t as i}from"./jsx-runtime-Bb4Xn-E0.js";import{Ap as a,Hp as o,Jg as s,Jm as c,So as l,Vp as u,Yg as d,Ym as f,Yo as p,_u as m,kp as h,oC as g,sC as _,vo as v,vu as y,xo as b,zo as x}from"./loadAgentsDir-nzr38hai.js";import{F as S,U as C,z as w}from"./debug-IKW-jE7K.js";import{g as T,n as E}from"./settings-5PQdphqC.js";import{n as D,r as O}from"./analytics-BotDBGh0.js";import{Dt as k,Et as A}from"./prompt-Bef63FhB.js";import{randomUUID as j}from"crypto";n(),r(),y(),f(),o();var M=i();function N({input:e,progress:n,verbose:r}){return(0,M.jsxs)(t,{flexDirection:`column`,marginTop:1,children:[(0,M.jsx)(c,{addMargin:!1,param:{text:`<bash-input>${e}</bash-input>`,type:`text`}}),n?(0,M.jsx)(u,{fullOutput:n.fullOutput,output:n.output,elapsedTimeSeconds:n.elapsedTimeSeconds,totalLines:n.totalLines,verbose:r}):m.renderToolUseProgressMessage?.([],{verbose:r,tools:[],terminalSize:void 0})]})}C(),D(),s(),x(),T();function P(){return E().defaultShell??`bash`}y(),A(),_();async function F(t,n,r,i,o){let s=k()&&P()===`powershell`;O(`tengu_input_bash`,{powershell:s});let c=l({content:p({inputString:`<bash-input>${t}</bash-input>`,precedingInputBlocks:n})}),u;o({jsx:(0,M.jsx)(N,{input:t,progress:null,verbose:i.options.verbose}),shouldHidePromptInput:!1});try{let n={...i,setToolJSX:e=>{u=e?.jsx}},f=e=>{o({jsx:(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(N,{input:t,progress:e.data,verbose:i.options.verbose}),u]}),shouldHidePromptInput:!1,showSpinner:!1})},p=null;s&&(p=(a(),e(h)).PowerShellTool);let _=p??m,y=(p?await p.call({command:t,dangerouslyDisableSandbox:!0},n,void 0,void 0,f):await m.call({command:t,dangerouslyDisableSandbox:!0},n,void 0,void 0,f)).data;if(!y)throw Error(`No result received from shell command`);let b=y.stderr,x=await d(_,{...y,stderr:``},j()),S=typeof x.content==`string`?x.content:g(y.stdout);return{messages:[v(),c,...r,l({content:`<bash-stdout>${S}</bash-stdout><bash-stderr>${g(b)}</bash-stderr>`})],shouldQuery:!1}}catch(e){return e instanceof S?e.interrupted?{messages:[v(),c,b({toolUse:!1}),...r],shouldQuery:!1}:{messages:[v(),c,...r,l({content:`<bash-stdout>${g(e.stdout)}</bash-stdout><bash-stderr>${g(e.stderr)}</bash-stderr>`})],shouldQuery:!1}:{messages:[v(),c,...r,l({content:`<bash-stderr>Command failed: ${g(w(e))}</bash-stderr>`})],shouldQuery:!1}}finally{o(null)}}export{F as processBashCommand};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{en as t,ht as n,nr as r,t as i}from"./state-4KQ3kaqz.js";import{Al as a,Av as o,Bo as s,C as c,Cw as l,Dc as u,Dv as d,Dw as f,Ec as p,Eo as m,Ev as h,Fv as g,G as _,Gh as v,Hw as y,Jd as b,Jw as x,Kh as S,Ki as C,MD as w,Mv as T,Ol as E,Qi as D,RT as O,SC as k,Sl as ee,So as A,Th as j,Ui as te,VT as ne,Vw as re,W as ie,Wh as ae,Wo as oe,Yd as se,Yo as M,Zi as ce,aw as le,bD as N,bS as ue,bl as de,cE as fe,ca as P,cw as pe,cx as me,ho as F,iw as he,jD as ge,jl as I,jv as L,k as _e,kc as ve,lx as ye,oE as be,qo as xe,sw as Se,vS as Ce,vo as R,wh as we,ww as Te,xC as Ee,xD as z,xo as De,yD as Oe,yS as ke,yo as Ae,zi as je,zo as Me}from"./loadAgentsDir-nzr38hai.js";import{P as B,U as Ne,_ as Pe,h as Fe,j as Ie,l as V,p as H}from"./debug-IKW-jE7K.js";import{Mt as Le,jt as Re}from"./settings-5PQdphqC.js";import{T as U,Y as ze,o as Be,s as W,w as G}from"./log-B3eB4EFv.js";import{f as Ve,l as He}from"./file-D1cN3LMK.js";import{n as Ue,r as K}from"./analytics-BotDBGh0.js";import{or as We,sr as Ge,vn as Ke,yn as qe}from"./model-DfFA3qMO.js";import{h as Je,p as Ye}from"./metadata-BRLJvh61.js";import{E as Xe,T as Ze,w as Qe}from"./sessionTracing-BuLsL6qA.js";import{n as $e,t as et}from"./slashCommandParsing-RQb_7Xzt.js";import{randomUUID as q}from"crypto";function tt(e,t,n,r,i){let a=0;for(let o of Re){let s=n[o];if(s)for(let n of s)for(let s of n.hooks){let c=s.once?()=>{H(`Removing one-shot hook for event ${o} in skill '${r}'`),S(e,t,o,s)}:void 0;ae(e,t,o,n.matcher||``,s,c,i),a++}}a>0&&H(`Registered ${a} hooks from skill '${r}'`)}var nt=e((()=>{Le(),V(),v()}));function J(){return!1}function rt(){if(!J())throw Error(`ToolUseContext.options.allowBackgroundForkedSlashCommands is test-only and cannot be enabled outside NODE_ENV=test.`)}async function it(e,t,n,r,i,a,o){let s=h(),c=e.pluginInfo?z(e.pluginInfo.repository).marketplace:void 0;K(`tengu_slash_command_forked`,{command_name:e.name,invocation_trigger:`user-slash`,...e.pluginInfo&&{_PROTO_plugin_name:e.pluginInfo.pluginManifest.name,...c&&{_PROTO_marketplace_name:c},...T(e.pluginInfo)}});let{skillContent:u,modifiedGetAppState:d,baseAgent:f,promptMessages:p}=await I(e,t,n),m=e.effort===void 0?f:{...f,effort:e.effort};H(`Executing forked slash command /${e.name} with agent ${m.agentType}`);let g=await n.getAppState();n.options.allowBackgroundForkedSlashCommands===!0&&rt();let _=!1;if(g.kairosEnabled&&(_=!0),_){let t=he(),r=P(e),i=We(),c=e=>y({value:e,mode:`prompt`,priority:`later`,isMeta:!0,skipSlashCommands:!0,workload:i}),u=async()=>{if(!o?.runId)return;let e=await l({runId:o.runId,rootDir:o.rootDir,priority:`later`,workload:i});for(let t of e)re(t)},f=async e=>{o?.runId&&await Te({runId:o.runId,rootDir:o.rootDir,error:e instanceof Error?e.message:String(e)})};return(async()=>{let i=Date.now()+$;for(;Date.now()<i&&n.getAppState().mcp.clients.some(e=>e.type===`pending`);)await qe(Q);let o=n.options.refreshTools?.()??n.options.tools,l=[];for await(let r of j({agentDefinition:m,promptMessages:p,toolUseContext:{...n,getAppState:d,abortController:t},canUseTool:a,isAsync:!0,querySource:`agent:custom`,model:e.model,availableTools:o,override:{agentId:s}}))l.push(r);let f=E(l,`Command completed`);H(`Background forked command /${r} completed (agent ${s})`),c(`<scheduled-task-result command="/${r}">\n${f}\n</scheduled-task-result>`);try{await u()}catch(e){W(e)}})().catch(async e=>{W(e),c(`<scheduled-task-result command="/${r}" status="failed">\n${e instanceof Error?e.message:String(e)}\n</scheduled-task-result>`),await f(e)}),{messages:[],shouldQuery:!1,command:e,deferAutonomyCompletion:!!o?.runId}}let v=[],b=[],x=`forked-command-${e.name}`,S=0,C=e=>(S++,{type:`progress`,data:{message:e,type:`agent_progress`,prompt:u,agentId:s},parentToolUseID:x,toolUseID:`${x}-${S}`,timestamp:new Date().toISOString(),uuid:q()}),w=()=>{i({jsx:se(b,{tools:n.options.tools,verbose:!1}),shouldHidePromptInput:!1,shouldContinueAnimation:!0,showSpinner:!0})};w();try{for await(let t of j({agentDefinition:m,promptMessages:p,toolUseContext:{...n,getAppState:d},canUseTool:a,isAsync:!1,querySource:`agent:custom`,model:e.model,availableTools:n.options.tools})){v.push(t);let e=xe([t]);if(t.type===`assistant`){let r=O(t);r>0&&n.setResponseLength(e=>e+r);let i=e[0];i&&i.type===`assistant`&&(b.push(C(t)),w())}if(t.type===`user`){let t=e[0];t&&t.type===`user`&&(b.push(C(t)),w())}}}finally{i(null)}let D=E(v,`Command completed`);return H(`Forked slash command /${e.name} completed with agent ${s}`),process.env.USER_TYPE===`ant`&&(D=`[ANT-ONLY] API calls: ${He(Se(s))}\n${D}`),{messages:[A({content:M({inputString:`/${P(e)} ${t}`.trim(),precedingInputBlocks:r})}),A({content:`<local-command-stdout>\n${D}\n</local-command-stdout>`})],shouldQuery:!1,command:e,resultText:D}}function at(e){return!/[^a-zA-Z0-9:\-_]/.test(e)}async function ot(e,t,n,i,a,o,c,l,u,d){let f=$e(e);if(!f){K(`tengu_input_slash_missing`,{});let e="Commands are in the form `/command [args]`";return{messages:[R(),...i,A({content:M({inputString:e,precedingInputBlocks:t})})],shouldQuery:!1,resultText:e}}let{commandName:p,args:m,isMcp:h}=f,g=h?`mcp`:je().has(p)?p:`custom`;if(!ce(p,a.options.commands)){let n=!1;try{await Fe().stat(`/${p}`),n=!0}catch{}if(at(p)&&!n){K(`tengu_input_slash_invalid`,{input:p});let e=`Unknown skill: ${p}`;return{messages:[R(),...i,A({content:M({inputString:e,precedingInputBlocks:t})}),...m?[Ae(`Args from unknown skill: ${m}`,`warning`)]:[]],shouldQuery:!1,resultText:e}}let a=q();return r(a),K(`tengu_input_prompt`,{}),Ze(`user_prompt`,{prompt_length:String(e.length),prompt:Xe(e),"prompt.id":a}),{messages:[A({content:M({inputString:e,precedingInputBlocks:t}),uuid:c}),...i],shouldQuery:!0}}let{messages:_,shouldQuery:v,allowedTools:y,model:b,effort:x,command:S,resultText:C,nextInput:w,submitNextInput:E,deferAutonomyCompletion:D}=await st(p,m,o,a,t,n,l,u,c,d);if(_.length===0){let e={input:g};if(S.type===`prompt`&&S.pluginInfo){let{pluginManifest:t,repository:n}=S.pluginInfo,{marketplace:r}=z(n),i=N(r);e._PROTO_plugin_name=t.name,r&&(e._PROTO_marketplace_name=r),e.plugin_repository=i?n:`third-party`,e.plugin_name=i?t.name:`third-party`,i&&t.version&&(e.plugin_version=t.version),Object.assign(e,T(S.pluginInfo))}return K(`tengu_input_command`,{...e,invocation_trigger:`user-slash`,...process.env.USER_TYPE===`ant`&&{skill_name:p,...S.type===`prompt`&&{skill_source:S.source},...S.loadedFrom&&{skill_loaded_from:S.loadedFrom},...S.kind&&{skill_kind:S.kind}}}),{messages:[],shouldQuery:!1,model:b,nextInput:w,submitNextInput:E,deferAutonomyCompletion:D}}if(_.length===2&&_[1].type===`user`&&typeof _[1].message.content==`string`&&_[1].message.content.startsWith(`Unknown command:`))return e.startsWith(`/var`)||e.startsWith(`/tmp`)||e.startsWith(`/private`)||K(`tengu_input_slash_invalid`,{input:p}),{messages:[R(),..._],shouldQuery:v,allowedTools:y,model:b};let O={input:g};if(S.type===`prompt`&&S.pluginInfo){let{pluginManifest:e,repository:t}=S.pluginInfo,{marketplace:n}=z(t),r=N(n);O._PROTO_plugin_name=e.name,n&&(O._PROTO_marketplace_name=n),O.plugin_repository=r?t:`third-party`,O.plugin_name=r?e.name:`third-party`,r&&e.version&&(O.plugin_version=e.version),Object.assign(O,T(S.pluginInfo))}K(`tengu_input_command`,{...O,invocation_trigger:`user-slash`,...process.env.USER_TYPE===`ant`&&{skill_name:p,...S.type===`prompt`&&{skill_source:S.source},...S.loadedFrom&&{skill_loaded_from:S.loadedFrom},...S.kind&&{skill_kind:S.kind}}});let k=_.length>0&&_[0]&&s(_[0]);return{messages:v||_.every(oe)||k?_:[R(),..._],shouldQuery:v,allowedTools:y,model:b,effort:x,resultText:C,nextInput:w,submitNextInput:E,deferAutonomyCompletion:D}}async function st(e,t,n,r,i,a,o,s,c,l){let u=C(e,r.options.commands);if(u.type===`prompt`&&u.userInvocable!==!1&&L(e),u.userInvocable===!1)return{messages:[A({content:M({inputString:`/${e}`,precedingInputBlocks:i})}),A({content:`This skill can only be invoked by Claude, not directly by users. Ask Claude to use the "${e}" skill for you.`})],shouldQuery:!1,command:u};try{switch(u.type){case`local-jsx`:return new Promise(e=>{let a=!1,o=(n,r)=>{if(a=!0,r?.display===`skip`){e({messages:[],shouldQuery:!1,command:u,nextInput:r?.nextInput,submitNextInput:r?.submitNextInput});return}let o=(r?.metaMessages??[]).map(e=>A({content:e,isMeta:!0})),s=ye()&&typeof n==`string`&&n.endsWith(` dismissed`),c=r?.displayArgs??t;e({messages:r?.display===`system`?s?o:[F(Y(u,c)),F(`<local-command-stdout>${n}</local-command-stdout>`),...o]:[A({content:M({inputString:Y(u,c),precedingInputBlocks:i})}),A(n?{content:`<local-command-stdout>${n}</local-command-stdout>`}:{content:`<local-command-stdout>${ge}</local-command-stdout>`}),...o],shouldQuery:r?.shouldQuery??!1,command:u,nextInput:r?.nextInput,submitNextInput:r?.submitNextInput})};u.load().then(e=>e.call(o,{...r,canUseTool:s},t)).then(t=>{if(t!=null){if(r.options.isNonInteractiveSession){e({messages:[],shouldQuery:!1,command:u});return}a||n({jsx:t,shouldHidePromptInput:!0,showSpinner:!1,isLocalJSXCommand:!0,isImmediate:u.immediate===!0})}}).catch(t=>{W(t),!a&&(a=!0,n({jsx:null,shouldHidePromptInput:!1,clearLocalJSX:!0}),e({messages:[],shouldQuery:!1,command:u}))})});case`local`:{let e=A({content:M({inputString:Y(u,u.isSensitive&&t.trim()?`***`:t),precedingInputBlocks:i})});try{let n=R(),i=await(await u.load()).call(t,r);if(i.type===`skip`)return{messages:[],shouldQuery:!1,command:u};if(i.type===`compact`){let t=[n,e,...i.displayText?[A({content:`<local-command-stdout>${i.displayText}</local-command-stdout>`,timestamp:new Date(Date.now()+100).toISOString()})]:[]],r={...i.compactionResult,messagesToKeep:[...i.compactionResult.messagesToKeep??[],...t]};return fe(),{messages:de(r),shouldQuery:!1,command:u}}return{messages:[e,F(`<local-command-stdout>${i.value}</local-command-stdout>`)],shouldQuery:!1,command:u,resultText:i.value}}catch(t){return W(t),{messages:[e,F(`<local-command-stderr>${String(t)}</local-command-stderr>`)],shouldQuery:!1,command:u}}}case`prompt`:try{return u.context===`fork`?await it(u,t,r,i,n,s??ie,l):await Z(u,t,r,i,a,c)}catch(e){return e instanceof Ie?{messages:[A({content:M({inputString:Y(u,t),precedingInputBlocks:i})}),De({toolUse:!1})],shouldQuery:!1,command:u}:{messages:[A({content:M({inputString:Y(u,t),precedingInputBlocks:i})}),A({content:`<local-command-stderr>${String(e)}</local-command-stderr>`})],shouldQuery:!1,command:u}}}}catch(e){if(e instanceof B)return{messages:[A({content:M({inputString:e.message,precedingInputBlocks:i})})],shouldQuery:!1,command:u};throw e}}function Y(e,t){return m(P(e),t)}function X(e,t=`loading`){return[`<${G}>${e}</${G}>`,`<${U}>${e}</${U}>`,`<skill-format>true</skill-format>`].join(`
|
|
2
|
+
`)}function ct(e,t){return[`<${G}>${e}</${G}>`,`<${U}>/${e}</${U}>`,t?`<command-args>${t}</command-args>`:null].filter(Boolean).join(`
|
|
3
|
+
`)}function lt(e,t){return e.userInvocable===!1&&(e.loadedFrom===`skills`||e.loadedFrom===`plugin`||e.loadedFrom===`mcp`)?X(e.name,e.progressMessage):ct(e.name,t)}async function ut(e,t,n,r,i=[]){let a=te(e,n);if(!a)throw new B(`Unknown command: ${e}`);if(a.type!==`prompt`)throw Error(`Unexpected ${a.type} command. Expected 'prompt' command. Use /${e} directly in the main conversation.`);return Z(a,t,r,[],i)}async function Z(e,t,r,a=[],o=[],s){let c=await e.getPromptForCommand(t,r),l=!ke(`hooks`)||ue(e.source);if(e.hooks&&l){let t=n();tt(r.setAppState,t,e.hooks,e.name,e.type===`prompt`?e.skillRoot:void 0)}let d=e.source?`${e.source}:${e.name}`:e.name,f=c.filter(e=>e.type===`text`).map(e=>e.text).join(`
|
|
4
|
+
|
|
5
|
+
`);i(e.name,d,f,Ye()?.agentId??null);let m=lt(e,t),h=_e(e.allowedTools??[]),g=o.length>0||a.length>0?[...o,...a,...c]:c,_=await k(u(c.filter(e=>e.type===`text`).map(e=>e.text).join(` `),r,null,[],r.messages,`repl_main_thread`,{skipSkillDiscovery:!0}));return{messages:[A({content:m,uuid:s}),A({content:g,isMeta:!0}),..._,p({type:`command_permissions`,allowedTools:h,model:e.model})],shouldQuery:!0,allowedTools:h,model:e.model,effort:e.effort,command:e}}var Q,$;e((()=>{t(),D(),w(),ze(),Ue(),pe(),ee(),be(),we(),b(),le(),Je(),ve(),V(),Ne(),Ve(),a(),Pe(),me(),Ee(),nt(),Be(),x(),Me(),c(),_(),Oe(),Ce(),et(),Ke(),o(),Qe(),g(),ne(),d(),f(),Ge(),Q=200,$=1e4}))();export{X as formatSkillLoadingMetadata,ut as processPromptSlashCommand,ot as processSlashCommand};
|
|
@@ -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-D9MDwJUF.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{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,o as n}from"./envUtils-DSxRz_kt.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,132 @@
|
|
|
1
|
+
import{n as e,o as t,r as n}from"./rolldown-runtime-DaDcL9Zw.js";import{c as r,l as i,o as a}from"./envUtils-DSxRz_kt.js";import{n as o,t as s}from"./defineProperty-C-QyHrDq.js";import{A as c,C as l,M as u,t as d,w as f}from"./v4-jw6qOKwQ.js";import{E as ee,I as te,O as ne,U as re}from"./debug-IKW-jE7K.js";import{J as ie,Q as ae,X as oe,Y as se,Z as ce,nt as le}from"./settings-5PQdphqC.js";import{U as ue,Y as de}from"./log-B3eB4EFv.js";import{i as fe,o as pe}from"./platform-EtecGacO.js";import{n as me,t as he}from"./lazySchema-uxlVVNM1.js";import{_ as ge,u as _e}from"./model-DfFA3qMO.js";import{t as ve}from"./ajv-5vMo9UcX.js";import{join as p,parse as ye,resolve as m,sep as be}from"node:path";import{createHash as xe}from"node:crypto";import{appendFile as Se,mkdir as Ce,readFile as h,readdir as we,rm as Te,writeFile as Ee}from"node:fs/promises";function De(e){return e.filter(e=>e.data?.type!==`hook_progress`)}function Oe(e,t){return e.name===t||(e.aliases?.includes(t)??!1)}function ke(e,t){return e.find(e=>Oe(e,t))}function Ae(e){return{...Me,userFacingName:()=>e.name,...e}}var je,Me,Ne=e((()=>{je=()=>({mode:`default`,additionalWorkingDirectories:new Map,alwaysAllowRules:{},alwaysDenyRules:{},alwaysAskRules:{},isBypassPermissionsModeAvailable:!0}),Me={isEnabled:()=>!0,isConcurrencySafe:e=>!1,isReadOnly:e=>!1,isDestructive:e=>!1,checkPermissions:(e,t)=>Promise.resolve({behavior:`allow`,updatedInput:e}),toAutoClassifierInput:e=>``,userFacingName:e=>``}})),g,_=e((()=>{g=`Bash`}));function Pe(){return`A powerful search tool built on ripgrep
|
|
2
|
+
|
|
3
|
+
Usage:
|
|
4
|
+
- ALWAYS use ${v} for search tasks. NEVER invoke \`grep\` or \`rg\` as a ${g} command. The ${v} tool has been optimized for correct permissions and access.
|
|
5
|
+
- Supports full regex syntax (e.g., "log.*Error", "function\\s+\\w+")
|
|
6
|
+
- Filter files with glob parameter (e.g., "*.js", "**/*.tsx") or type parameter (e.g., "js", "py", "rust")
|
|
7
|
+
- Output modes: "content" shows matching lines, "files_with_matches" shows only file paths (default), "count" shows match counts
|
|
8
|
+
- Use ${ae} tool for open-ended searches requiring multiple rounds
|
|
9
|
+
- Pattern syntax: Uses ripgrep (not grep) - literal braces need escaping (use \`interface\\{\\}\` to find \`interface{}\` in Go code)
|
|
10
|
+
- Multiline matching: By default patterns match within single lines only. For cross-line patterns like \`struct \\{[\\s\\S]*?field\`, use \`multiline: true\`
|
|
11
|
+
`}var v,Fe=e((()=>{le(),_(),v=`Grep`})),y,Ie,Le,Re,ze=e((()=>{y=`Edit`,Ie=`/.claude/**`,Le=`~/.claude/**`,Re=`File has been unexpectedly modified. Read it again before attempting to write it.`}));function Be(e){let t=e.trim();if(!t)return null;if(t.endsWith(`-`)){let e=parseInt(t.slice(0,-1),10);return isNaN(e)||e<1?null:{firstPage:e,lastPage:1/0}}let n=t.indexOf(`-`);if(n===-1){let e=parseInt(t,10);return isNaN(e)||e<1?null:{firstPage:e,lastPage:e}}let r=parseInt(t.slice(0,n),10),i=parseInt(t.slice(n+1),10);return isNaN(r)||isNaN(i)||r<1||i<1||i<r?null:{firstPage:r,lastPage:i}}function Ve(){return!_e().toLowerCase().includes(`claude-3-haiku`)}function He(e){let t=e.startsWith(`.`)?e.slice(1):e;return Ue.has(t.toLowerCase())}var Ue,We=e((()=>{ge(),Ue=new Set([`pdf`])}));function Ge(e,t,n){return`Reads a file from the local filesystem. You can access any file directly by using this tool.
|
|
12
|
+
Assume this tool is able to read all files on the machine. If the User provides a path to a file assume that path is valid. It is okay to read a file that does not exist; an error will be returned.
|
|
13
|
+
|
|
14
|
+
Usage:
|
|
15
|
+
- The file_path parameter must be an absolute path, not a relative path
|
|
16
|
+
- By default, it reads up to ${x} lines starting from the beginning of the file${t}
|
|
17
|
+
${n}
|
|
18
|
+
${e}
|
|
19
|
+
- This tool allows Claude Code to read images (eg PNG, JPG, etc). When reading an image file the contents are presented visually as Claude Code is a multimodal LLM.${Ve()?`
|
|
20
|
+
- This tool can read PDF files (.pdf). For large PDFs (more than 10 pages), you MUST provide the pages parameter to read specific page ranges (e.g., pages: "1-5"). Reading a large PDF without the pages parameter will fail. Maximum 20 pages per request.`:``}
|
|
21
|
+
- This tool can read Jupyter notebooks (.ipynb files) and returns all cells with their outputs, combining code, text, and visualizations.
|
|
22
|
+
- This tool can only read files, not directories. To read a directory, use an ls command via the ${g} tool.
|
|
23
|
+
- You will regularly be asked to read screenshots. If the user provides a path to a screenshot, ALWAYS use this tool to view the file at the path. This tool will work with all temporary file paths.
|
|
24
|
+
- If you read a file that exists but has empty contents you will receive a system reminder warning in place of file contents.`}var b,Ke,x,qe,Je,Ye,Xe,S=e((()=>{We(),_(),b=`Read`,Ke=`File unchanged since last read. The content from the earlier Read tool_result in this conversation is still current — refer to that instead of re-reading.`,x=2e3,qe=`Read a file from the local filesystem.`,Je=`- Results are returned using cat -n format, with line numbers starting at 1`,Ye=`- You can optionally specify a line offset and limit (especially handy for long files), but it's recommended to read the whole file by not providing these parameters`,Xe=`- When you already know which part of the file you need, only read that part. This can be important for larger files.`}));function Ze(){return`\n- If this is an existing file, you MUST use the ${b} tool first to read the file's contents. This tool will fail if you did not read the file first.`}function Qe(){return`Writes a file to the local filesystem.
|
|
25
|
+
|
|
26
|
+
Usage:
|
|
27
|
+
- This tool will overwrite the existing file if there is one at the provided path.${Ze()}
|
|
28
|
+
- Prefer the Edit tool for modifying existing files \u2014 it only sends the diff. Only use this tool to create new files or for complete rewrites.
|
|
29
|
+
- NEVER create documentation files (*.md) or README files unless explicitly requested by the User.
|
|
30
|
+
- Only use emojis if the user explicitly requests it. Avoid writing emojis to files unless asked.`}var C,$e=e((()=>{S(),C=`Write`})),w,et,tt=e((()=>{w=`Glob`,et=`- Fast file pattern matching tool that works with any codebase size
|
|
31
|
+
- Supports glob patterns like "**/*.js" or "src/**/*.ts"
|
|
32
|
+
- Returns matching file paths sorted by modification time
|
|
33
|
+
- Use this tool when you need to find files by name patterns
|
|
34
|
+
- When you are doing an open ended search that may require multiple rounds of globbing and grepping, use the Agent tool instead`})),T,nt=e((()=>{T=`NotebookEdit`})),E,D,rt=e((()=>{E=`ExitPlanMode`,D=`ExitPlanMode`})),O,it=e((()=>{O=`EnterPlanMode`})),k,at,ot,st,ct=e((()=>{rt(),k=`AskUserQuestion`,at=`Asks the user multiple choice questions to gather information, clarify ambiguity, understand preferences, make decisions or offer them choices.`,ot={markdown:`
|
|
35
|
+
Preview feature:
|
|
36
|
+
Use the optional \`preview\` field on options when presenting concrete artifacts that users need to visually compare:
|
|
37
|
+
- ASCII mockups of UI layouts or components
|
|
38
|
+
- Code snippets showing different implementations
|
|
39
|
+
- Diagram variations
|
|
40
|
+
- Configuration examples
|
|
41
|
+
|
|
42
|
+
Preview content is rendered as markdown in a monospace box. Multi-line text with newlines is supported. When any option has a preview, the UI switches to a side-by-side layout with a vertical option list on the left and preview on the right. Do not use previews for simple preference questions where labels and descriptions suffice. Note: previews are only supported for single-select questions (not multiSelect).
|
|
43
|
+
`,html:`
|
|
44
|
+
Preview feature:
|
|
45
|
+
Use the optional \`preview\` field on options when presenting concrete artifacts that users need to visually compare:
|
|
46
|
+
- HTML mockups of UI layouts or components
|
|
47
|
+
- Formatted code snippets showing different implementations
|
|
48
|
+
- Visual comparisons or diagrams
|
|
49
|
+
|
|
50
|
+
Preview content must be a self-contained HTML fragment (no <html>/<body> wrapper, no <script> or <style> tags — use inline style attributes instead). Do not use previews for simple preference questions where labels and descriptions suffice. Note: previews are only supported for single-select questions (not multiSelect).
|
|
51
|
+
`},st=`Use this tool when you need to ask the user questions during execution. This allows you to:
|
|
52
|
+
1. Gather user preferences or requirements
|
|
53
|
+
2. Clarify ambiguous instructions
|
|
54
|
+
3. Get decisions on implementation choices as you work
|
|
55
|
+
4. Offer choices to the user about what direction to take.
|
|
56
|
+
|
|
57
|
+
Usage notes:
|
|
58
|
+
- Users will always be able to select "Other" to provide custom text input
|
|
59
|
+
- Use multiSelect: true to allow multiple answers to be selected for a question
|
|
60
|
+
- If you recommend a specific option, make that the first option in the list and add "(Recommended)" at the end of the label
|
|
61
|
+
|
|
62
|
+
Plan mode note: In plan mode, use this tool to clarify requirements or choose between approaches BEFORE finalizing your plan. Do NOT use this tool to ask "Is my plan ready?" or "Should I proceed?" - use ${E} for plan approval. IMPORTANT: Do not reference "the plan" in your questions (e.g., "Do you have feedback about the plan?", "Does the plan look good?") because the user cannot see the plan in the UI until you call ${E}. If you need plan approval, use ${E} instead.
|
|
63
|
+
`})),A,lt=e((()=>{A=`TodoWrite`})),ut,dt=e((()=>{ut=`PowerShell`}));function ft(){return fe()===`windows`?process.env.USER_TYPE===`ant`?!r(process.env.CLAUDE_CODE_USE_POWERSHELL_TOOL):i(process.env.CLAUDE_CODE_USE_POWERSHELL_TOOL):!1}var j,pt=e((()=>{_(),dt(),a(),pe(),j=[g,ut]})),M,mt=e((()=>{M=`Skill`})),ht,gt=e((()=>{ht=`TaskCreate`})),_t,vt=e((()=>{_t=`TaskGet`})),yt,bt=e((()=>{yt=`TaskList`})),xt,St=e((()=>{xt=`TaskUpdate`})),N,Ct=e((()=>{N=`SearchExtraTools`}));function wt(e){return e.isNonInteractiveSession}function Tt(e){let t=jt.get(e);if(t)return t;let n=Et(e);return jt.set(e,n),n}function Et(e){try{let t=new Dt.Ajv({allErrors:!0});if(!t.validateSchema(e))return{error:t.errorsText(t.errors)};let n=t.compile(e);return{tool:{...At,inputJSONSchema:e,async call(e){if(!n(e)){let e=n.errors?.map(e=>`${e.instancePath||`root`}: ${e.message}`).join(`, `);throw new te(`Output does not match required schema: ${e}`,`StructuredOutput schema mismatch: ${(e??``).slice(0,150)}`)}return{data:`Structured output provided successfully`,structured_output:e}}}}}catch(e){return{error:e instanceof Error?e.message:String(e)}}}var Dt,Ot,kt,P,At,jt,Mt=e((()=>{Dt=t(ve(),1),d(),Ne(),re(),he(),ee(),Ot=me(()=>f({}).passthrough()),kt=me(()=>c().describe(`Structured output tool result`)),P=`StructuredOutput`,At=Ae({isMcp:!1,isEnabled(){return!0},isConcurrencySafe(){return!0},isReadOnly(){return!0},isOpenWorld(){return!1},name:P,searchHint:`return the final response as structured JSON`,maxResultSizeChars:1e5,async description(){return`Return structured output in the requested format`},async prompt(){return`Use this tool to return your final response in the requested structured format. You MUST call this tool exactly once at the end of your response to provide the structured output.`},get inputSchema(){return Ot()},get outputSchema(){return kt()},async call(e){return{data:`Structured output provided successfully`,structured_output:e}},async checkPermissions(e){return{behavior:`allow`,updatedInput:e}},renderToolUseMessage(e){let t=Object.keys(e);return t.length===0?null:t.length<=3?t.map(t=>`${t}: ${ne(e[t])}`).join(`, `):`${t.length} fields: ${t.slice(0,3).join(`, `)}…`},renderToolUseRejectedMessage(){return`Structured output rejected`},renderToolUseErrorMessage(){return`Structured output error`},renderToolUseProgressMessage(){return null},renderToolResultMessage(e){return e},mapToolResultToToolResultBlockParam(e,t){return{tool_use_id:t,type:`tool_result`,content:e}}}),jt=new WeakMap})),Nt,Pt,Ft,It=e((()=>{de(),Nt=`Sleep`,Pt=`Wait for a specified duration`,Ft=`Wait for a specified duration. The user can interrupt the sleep at any time.
|
|
64
|
+
|
|
65
|
+
Use this when the user tells you to sleep or rest, when you have nothing to do, or when you're waiting for something.
|
|
66
|
+
|
|
67
|
+
You may receive <${ue}> prompts — these are periodic check-ins. Look for useful work to do before sleeping.
|
|
68
|
+
|
|
69
|
+
You can call this concurrently with other tools — it won't interfere with them.
|
|
70
|
+
|
|
71
|
+
Prefer this over \`Bash(sleep ...)\` — it doesn't hold a shell process.
|
|
72
|
+
|
|
73
|
+
Each wake-up costs an API call, but the prompt cache expires after 5 minutes of inactivity — balance accordingly.`})),Lt,Rt=e((()=>{Lt=`Interact with Language Server Protocol (LSP) servers to get code intelligence features.
|
|
74
|
+
|
|
75
|
+
Supported operations:
|
|
76
|
+
- goToDefinition: Find where a symbol is defined
|
|
77
|
+
- findReferences: Find all references to a symbol
|
|
78
|
+
- hover: Get hover information (documentation, type info) for a symbol
|
|
79
|
+
- documentSymbol: Get all symbols (functions, classes, variables) in a document
|
|
80
|
+
- workspaceSymbol: Search for symbols across the entire workspace
|
|
81
|
+
- goToImplementation: Find implementations of an interface or abstract method
|
|
82
|
+
- prepareCallHierarchy: Get call hierarchy item at a position (functions/methods)
|
|
83
|
+
- incomingCalls: Find all functions/methods that call the function at a position
|
|
84
|
+
- outgoingCalls: Find all functions/methods called by the function at a position
|
|
85
|
+
|
|
86
|
+
All operations require:
|
|
87
|
+
- filePath: The file to operate on
|
|
88
|
+
- line: The line number (1-based, as shown in editors)
|
|
89
|
+
- character: The character offset (1-based, as shown in editors)
|
|
90
|
+
|
|
91
|
+
Note: LSP servers must be configured for the file type. If no server is available, an error will be returned.`})),zt=n({VERIFY_PLAN_EXECUTION_TOOL_NAME:()=>F}),F,Bt=e((()=>{F=`VerifyPlanExecution`})),I,Vt=e((()=>{I=`ExecuteExtraTool`})),Ht,Ut=e((()=>{Ht=`EnterWorktree`})),Wt,Gt=e((()=>{Wt=`ExitWorktree`})),Kt=e((()=>{})),L,R,qt,z,Jt,B,V=e((()=>{L=`Workflow`,R=`.claude/workflows`,qt=`.claude/workflow-runs`,z=[`.ts`,`.js`,`.mjs`],Jt=1e3,B=4096}));function Yt(e){return{[H]:e}}function Xt(e){return typeof e==`object`&&!!e&&H in e}function Zt(e){return e[H]}var H,Qt=e((()=>{H=Symbol(`workflow.hostHandle`)}));function $t(e,t){return e.kind===`agentType`?t.agentType===e.agentType:e.kind===`model`?typeof t.model==`string`&&t.model.startsWith(e.pattern):e.match(t)}var en,tn,nn=e((()=>{o(),en=class extends Error{constructor(e){super(e),this.name=`AdapterNotFoundError`}},tn=class{constructor(){s(this,`adapters`,new Map),s(this,`rules`,[]),s(this,`defaultId`,null)}register(e){return this.adapters.set(e.id,e),this}default(e){return this.defaultId=e,this}route(e){return this.rules.push(e),this}has(e){return this.adapters.has(e)}get(e){return this.adapters.get(e)}resolve(e){for(let t of this.rules)if($t(t,e)){let e=this.adapters.get(t.adapter);if(e)return e}if(this.defaultId){let e=this.adapters.get(this.defaultId);if(e)return e}throw new en(`No adapter matched (rules=${this.rules.length}, default=${this.defaultId??`none`})`)}async initializeAll(){for(let e of this.adapters.values())await e.initialize?.()}async disposeAll(){for(let e of this.adapters.values())await e.dispose?.()}}}));function rn(){return 3}function an(e){return e===void 0||Number.isNaN(e)?3:Math.max(1,Math.min(Math.trunc(e),16))}var on,sn=e((()=>{V(),o(),on=class{constructor(e){s(this,`available`,void 0),s(this,`waiters`,[]),this.available=Math.max(1,Math.floor(e))}async acquire(e){if(e?.aborted)throw Error(`Semaphore.acquire aborted (signal already aborted)`);return this.available>0?(--this.available,()=>this.release()):new Promise((t,n)=>{let r=()=>{let e=this.waiters.indexOf(i);e>=0&&this.waiters.splice(e,1),n(Error(`Semaphore.acquire aborted`))},i={wake:()=>{e?.removeEventListener(`abort`,r),t(()=>this.release())},cleanup:()=>e?.removeEventListener(`abort`,r)};e?.addEventListener(`abort`,r,{once:!0}),this.waiters.push(i)})}release(){let e=this.waiters.shift();e?e.wake():this.available+=1}}}));function cn(e){let t=pn.exec(e);if(!t)return{meta:null,body:e};let n=t.index+t[0].length;for(;n<e.length&&/\s/.test(e[n]);)n++;if(e[n]!==`{`)throw new W("meta must be an object literal `{ ... }`");let r=0,i=n,a=null;for(;n<e.length;n++){let t=e[n];if(a){if(t===`\\`){n++;continue}t===a&&(a=null);continue}if(t===`"`||t===`'`||t==="`"){a=t;continue}if(t===`{`)r++;else if(t===`}`&&(r--,r===0)){n++;break}}if(r!==0)throw new W(`meta literal braces are not closed`);let o=e.slice(i,n),s;try{s=Function(`return (${o})`)()}catch(e){throw new W(`meta must be a plain literal (no variable/function calls/interpolation): ${e.message}`)}return{meta:ln(s),body:e.slice(0,t.index)+e.slice(n).replace(/^[ \t]*;[ \t]*\n/,`
|
|
92
|
+
`)}}function ln(e){if(typeof e!=`object`||!e||Array.isArray(e))throw new W(`meta must be an object`);let t=e;if(typeof t.name!=`string`||typeof t.description!=`string`)throw new W(`meta must include string name and description`);return t}function un(){let e=function(...e){if(e.length===0)throw new G(`Date.now()/new Date()`);return new Date(...e)};return e.now=()=>{throw new G(`Date.now()`)},e.parse=Date.parse,e.UTC=Date.UTC,e}function dn(){return new Proxy(Math,{get(e,t,n){return t===`random`?()=>{throw new G(`Math.random()`)}:Reflect.get(e,t,n)}})}function fn(e){if(/^\s*import\b/m.test(e))throw new W(`workflow scripts are the body of new AsyncFunction (not ESM modules); import is not supported. agent / parallel / pipeline / phase / log / workflow / args / budget are injected as parameters — use them directly.`);if(/\bimport\s*\(/m.test(e))throw new W(`dynamic import(...) is forbidden in workflow scripts: it bypasses the Date/Math sandbox and breaks resume determinism. The sandbox does not guarantee security (same trust level as the LLM), but explicit escapes are prohibited. Inject external dependencies via args.`);if(/^\s*export\b/m.test(e))throw new W(`workflow scripts allow only one export const meta = {...} (already extracted by the engine). Remove other export / export default statements; use top-level return for the result.`)}function U(e){let{meta:t,body:n}=cn(e);fn(n);let r;try{r=new mn(`agent`,`parallel`,`pipeline`,`phase`,`log`,`workflow`,`args`,`budget`,`Date`,`Math`,n)}catch(e){throw new W(`Script syntax error: ${e.message}`)}let i=un(),a=dn();return{meta:t,async execute(e,t,n){return r(e.agent,e.parallel,e.pipeline,e.phase,e.log,e.workflow,t,n,i,a)}}}var W,pn,G,mn,K=e((()=>{W=class extends Error{constructor(e){super(e),this.name=`ScriptError`}},pn=/export\s+const\s+meta\s*=\s*/,G=class extends Error{constructor(e){super(`${e} is not available in workflow scripts (would break resume determinism). Pass timestamps/random seeds via args.`),this.name=`NonDeterministicError`}},mn=Object.getPrototypeOf(async function(){}).constructor}));function hn(e){let{label:t,phase:n,...r}=e,i=Object.keys(r).sort(),a={};for(let e of i)a[e]=r[e];return JSON.stringify(a)}function gn(e,t){return xe(`sha256`).update(e+`
|
|
93
|
+
`+hn(t)).digest(`hex`)}function _n(e){let t=t=>p(e,t,`journal.jsonl`);return{async read(e){try{return(await h(t(e),`utf-8`)).split(`
|
|
94
|
+
`).filter(e=>e.trim().length>0).map(e=>JSON.parse(e)).sort((e,t)=>(e.seq??0)-(t.seq??0))}catch{return[]}},async append(n,r){await Ce(p(e,n),{recursive:!0}),await Se(t(n),JSON.stringify(r)+`
|
|
95
|
+
`,`utf-8`)},async truncate(t){await Te(p(e,t),{recursive:!0,force:!0})}}}var vn=e((()=>{})),yn,bn,xn=e((()=>{o(),yn=class extends Error{constructor(){super(`workflow token budget exhausted (budget.total reached the cap)`),this.name=`BudgetExhaustedError`}},bn=class{constructor(e){s(this,`total`,void 0),s(this,`spentTokens`,0),this.total=e}spent(){return this.spentTokens}remaining(){return this.total==null?1/0:Math.max(0,this.total-this.spentTokens)}addOutputTokens(e){e>0&&(this.spentTokens+=e)}assertCanSpend(){if(this.total!=null&&this.spentTokens>=this.total)throw new yn}}}));function Sn(e,t){let n=wn.get(t);n||(n=new Cn.Ajv({allErrors:!0,strict:!1}).compile(t),wn.set(t,n));let r=n(e);return{valid:r,errors:r?[]:(n.errors??[]).map(e=>e.message??`validation error`)}}var Cn,wn,Tn=e((()=>{Cn=t(ve(),1),wn=new WeakMap}));function En(e,t){let n=m(e),r=m(n,t);return r===n||r.startsWith(n+be)}function Dn(e){return typeof e!=`string`||e.length===0||e.includes(`/`)||e.includes(`\\`)||e.includes(`\0`)||e===`.`||e===`..`?null:e}var On=e((()=>{}));function kn(e){return z.includes(e.toLowerCase())}async function q(e,t){for(let n of z){let r=m(e,t+n);if(!En(e,r))return null;try{return{path:r,content:await h(r,`utf-8`)}}catch{}}return null}async function An(e){let t;try{t=await we(e)}catch{return[]}return t.filter(e=>kn(ye(e).ext)).map(e=>ye(e).name).sort()}var J=e((()=>{V(),On()})),Y,X,Z=e((()=>{Y=class extends Error{constructor(e){super(e),this.name=`WorkflowError`}},X=class extends Error{constructor(){super(`workflow has been aborted`),this.name=`WorkflowAbortedError`}}}));function jn(e,t){return{semaphore:new on(an(t)),budget:new bn(e),agentCountBox:{value:0},agentIdSeq:{value:0},depth:0}}function Mn(e){let t=jn(e.budgetTotal,e.maxConcurrency);return{ports:e.ports,host:e.host,signal:e.signal,runId:e.runId,workflowName:e.workflowName,cwd:e.cwd,resources:t,journal:e.journal?[...e.journal]:[],journalIndex:0,journalInvalidated:!1,currentPhase:null}}var Nn=e((()=>{xn(),sn()}));function Pn(e,t){let n=t=>{e.ports.progressEmitter.emit({runId:e.runId,...t})};return{agent:async(t,r={})=>{let i=e.resources;if(i.agentCountBox.value>=1e3)throw new Y(`workflow exceeds total agent cap (${Jt})`);let a=i.agentIdSeq.value++,o={prompt:t,...r},s=gn(t,o),c=r.label,l=r.phase??e.currentPhase??void 0;if(!e.journalInvalidated&&e.journalIndex<e.journal.length){let t=e.journal[e.journalIndex];if(t.key===s)return e.journalIndex++,n({type:`agent_done`,agentId:a,label:c,phase:l,result:t.result}),Fn(t.result);e.journalInvalidated=!0,e.journal=e.journal.slice(0,e.journalIndex),await e.ports.journalStore.truncate(e.runId)}let u;try{u=await e.resources.semaphore.acquire(e.signal)}catch{throw new X}try{if(e.signal.aborted)throw new X;if(i.budget.assertCanSpend(),e.ports.taskRegistrar.pendingAction(e.runId)?.kind===`skip`)return n({type:`agent_done`,agentId:a,label:c,phase:l,result:{kind:`skipped`}}),null;e.resources.agentCountBox.value++,n({type:`agent_started`,agentId:a,label:c,phase:l});let t=e.ports.agentAdapterRegistry,r=t?{host:e.host,signal:e.signal,runId:e.runId,agentId:a,onProgress:e=>{n({type:`agent_progress`,agentId:a,label:c,phase:l,...e})},...e.ports.taskRegistrar.registerAgentAbort?{registerAgentAbort:(t,n)=>{e.ports.taskRegistrar.registerAgentAbort?.(e.runId,t,n)}}:{},...e.ports.taskRegistrar.unregisterAgentAbort?{unregisterAgentAbort:t=>{e.ports.taskRegistrar.unregisterAgentAbort?.(e.runId,t)}}:{}}:null,u=t?t.resolve(o):null,d=()=>u?u.run(o,r):e.ports.agentRunner.runAgentToResult(o,e.host),f;try{if(f=await d(),f.kind===`dead`){let t=typeof f.detail==`string`?f.detail:``;e.ports.logger.warn?.(`agent "${c??`#${a}`}" returned dead`+(f.reason?` (${f.reason})`:``)+(t?`: ${t.slice(0,150)}`:``)+`; retrying once`),f=await d()}}catch(t){if(t instanceof X)throw t;let n=t instanceof Error?t.message:String(t);e.ports.logger.warn?.(`agent "${c??`#${a}`}" threw (${n}); retrying once`);try{f=await d()}catch(e){if(e instanceof X)throw e;f={kind:`dead`,reason:`runagent-threw`,detail:e instanceof Error?e.message:String(e)}}}f.kind===`ok`&&e.resources.budget.addOutputTokens(f.usage.outputTokens),n({type:`agent_done`,agentId:a,label:c,phase:l,result:f});let ee={key:s,seq:a,result:f};return e.journal.push(ee),e.journalIndex++,await e.ports.journalStore.append(e.runId,ee),Fn(f)}finally{u()}},parallel:async t=>{if(t.length>4096)throw new Y(`parallel exceeds the per-call items cap (${B})`);return Promise.all(t.map(async(t,n)=>{try{return await t()}catch(t){return e.ports.logger.warn?.(`parallel thunk #${n} failed: ${t.message}`),null}}))},pipeline:async(t,...n)=>{if(t.length>4096)throw new Y(`pipeline exceeds the per-call items cap (${B})`);return Promise.all(t.map(async(t,r)=>{try{let e=t;for(let i of n)e=await i(e,t,r);return e}catch(t){return e.ports.logger.warn?.(`pipeline item #${r} failed: ${t.message}`),null}}))},phase:t=>{e.currentPhase&&n({type:`phase_done`,phase:e.currentPhase}),e.currentPhase=t,n({type:`phase_started`,phase:t})},log:e=>{n({type:`log`,message:e})},workflow:async(n,r)=>{if(e.resources.depth>=1)throw new Y(`workflow() nesting allows only one level`);return t({...typeof n==`string`?{name:n}:{scriptPath:n.scriptPath},args:r})}}}function Fn(e){return e.kind===`ok`?e.output:null}var In=e((()=>{V(),Z(),vn()}));async function Ln(e){let{ports:t}=e,n;try{n=U(e.script)}catch(n){let r=n.message;return t.progressEmitter.emit({type:`run_done`,runId:e.runId,status:`failed`,error:r}),{status:`failed`,error:r}}let r=e.workflowName??n.meta?.name??`workflow`,i=[],a=!1;e.resume&&!e.scriptChanged?i=await t.journalStore.read(e.runId):e.scriptChanged&&(await t.journalStore.truncate(e.runId),a=!0);let o=Mn({ports:t,host:e.host,signal:e.signal,runId:e.runId,workflowName:r,cwd:e.cwd,budgetTotal:e.budgetTotal,maxConcurrency:e.maxConcurrency,journal:i});a&&(o.journalInvalidated=!0),t.progressEmitter.emit({type:`run_started`,runId:e.runId,workflowName:r,meta:n.meta});let s=async t=>{let n=await Rn(t,e.cwd),r;try{r=U(n)}catch(e){throw new Y(`Sub-workflow script error: ${e.message}`)}let i=o.resources.depth;o.resources.depth+=1;try{let e=Pn(o,s);return await r.execute(e,t.args,o.resources.budget)}finally{o.resources.depth=i}},c=Pn(o,s),l=()=>{o.currentPhase&&t.progressEmitter.emit({type:`phase_done`,runId:e.runId,phase:o.currentPhase})},u;try{u={status:`completed`,returnValue:await n.execute(c,e.args,o.resources.budget)}}catch(e){u=e instanceof X?{status:`killed`}:{status:`failed`,error:e.message}}return l(),t.progressEmitter.emit({type:`run_done`,runId:e.runId,...u}),u}async function Rn(e,t){if(e.script)return e.script;if(e.scriptPath)return await h(e.scriptPath,`utf-8`);if(e.name){let n=await q(p(t,R),e.name);if(!n)throw new Y(`Sub-workflow "${e.name}" not found`);return n.content}throw new Y(`workflow() requires name or scriptPath`)}var zn=e((()=>{V(),Nn(),Z(),In(),J(),K()}));function Bn(e){return{emit:e}}function Vn(){let e=[];return{emitter:{emit:t=>void e.push(t)},events:e}}var Hn=e((()=>{})),Q,$=e((()=>{d(),Q=f({script:c().optional().describe(`Self-contained workflow script source (inline)`),name:c().optional().describe(`Named workflow, resolved to .claude/workflows/<name>.ts|js|mjs`),scriptPath:c().optional().describe(`Absolute path to an existing script file`),args:u().optional().describe(`The args global variable passed through to the script. Pass a real JSON value (object/array/string), not a JSON string.`),resumeFromRunId:c().optional().describe(`Resume the specified run, replaying the journal`),description:c().optional().describe(`A short description of this invocation (3-5 words)`),title:c().optional().describe(`Progress viewer title`),maxConcurrency:l().int().min(1).max(16).optional().describe(`Concurrency cap for agent(). Defaults to 3 (max 16). When the workflow contains heavy parallel/pipeline fan-out, you may confirm the desired concurrency with the user via AskUserQuestion before launching.`)})}));async function Un(e,t,n){let r=p(n,qt,t);await Ce(r,{recursive:!0});let i=p(r,`script.js`);return await Ee(i,e,`utf-8`),i}var Wn=e((()=>{V()}));function Gn(e){return{name:L,inputSchema:Q,isEnabled:()=>!0,isReadOnly:()=>!1,async description(){return`Execute a workflow script that orchestrates multiple subagents to complete a task`},async prompt(){return Xn},renderToolUseMessage(e){return e.resumeFromRunId?`Workflow resume: ${e.resumeFromRunId}`:`Workflow: ${e.name??e.scriptPath??(e.script?`inline`:`unknown`)}`},async call(t,n,r,i){let a=e.hostFactory({context:n,canUseTool:r,parentMessage:i}),o,s;try{let e=await Yn(t,a.cwd);o=e.script,s=e.workflowFile}catch(e){return{data:{output:`Error: ${e.message}`}}}try{U(o)}catch(e){return{data:{output:`Error: script validation failed: ${e.message}`}}}let c=t.name??t.title??`workflow`,{runId:l,signal:u}=e.taskRegistrar.register({workflowName:c,...s?{workflowFile:s}:{},...t.description?{summary:t.description}:{},...a.toolUseId?{toolUseId:a.toolUseId}:{},...t.resumeFromRunId?{runId:t.resumeFromRunId}:{}},a.handle);if(!s&&t.script)try{s=await Un(t.script,l,a.cwd)}catch(t){e.logger.warn?.(`inline script persist failed: ${t.message}`)}Ln({script:o,...t.args===void 0?{}:{args:Jn(t.args)},runId:l,workflowName:c,ports:e,host:a.handle,signal:u,cwd:a.cwd,budgetTotal:a.budgetTotal,...t.maxConcurrency===void 0?{}:{maxConcurrency:t.maxConcurrency},...t.resumeFromRunId?{resume:!0}:{}}).then(t=>Kn(e,t,l)).catch(t=>e.taskRegistrar.fail(l,t.message));let d=s??`<inline run ${l}>`;return{data:{output:[`Workflow started (running in the background).`,`run_id: ${l}`,`workflow: ${c}`,`script: ${d}`,``,`You will be notified on completion. Use /workflows to view live progress.`].join(`
|
|
96
|
+
`)}}},mapToolResultToToolResultBlockParam(e,t){return{tool_use_id:t,type:`tool_result`,content:[{type:`text`,text:e.output}]}}}}function Kn(e,t,n){if(t.status===`completed`){let r=t.returnValue==null?`(no return value)`:qn(t.returnValue);e.taskRegistrar.complete(n,r)}else t.status===`failed`?e.taskRegistrar.fail(n,t.error??`workflow failed`):e.taskRegistrar.kill(n)}function qn(e){if(typeof e==`string`)return e.slice(0,500);try{return JSON.stringify(e).slice(0,500)}catch{return String(e)}}function Jn(e){if(typeof e!=`string`)return e;try{let t=JSON.parse(e);return typeof t==`object`&&t?t:e}catch{return e}}async function Yn(e,t){if(e.script)return{script:e.script};if(e.scriptPath){let n=m(t,e.scriptPath);if(!En(t,n))throw Error(`scriptPath "${e.scriptPath}" is out of bounds (after resolve, ${n} is not within cwd ${t})`);return{script:await h(n,`utf-8`),workflowFile:n}}if(e.name){if(Dn(e.name)===null)throw Error(`Named workflow name "${e.name}" is invalid (contains path separators or is . / ..)`);let n=await q(p(t,R),e.name);if(!n)throw Error(`Named workflow "${e.name}" not found (looked in ${R}/)`);return{script:n.content,workflowFile:n.path}}throw Error(`One of script, name, or scriptPath must be provided`)}var Xn,Zn=e((()=>{V(),J(),zn(),K(),On(),$(),Wn(),Xn='Use the Workflow tool to execute a workflow script that orchestrates multiple subagents deterministically. The script runs in the background; you receive a run_id immediately and are notified on completion.\n\nProvide the script inline via "script", or reference a named workflow via "name" (resolved from .claude/workflows/), or an existing file via "scriptPath". Pass "args" as a real JSON value (object/array/string), not a stringified string.\n\nUse "resumeFromRunId" to resume a prior run — completed agent() calls replay from the journal instantly.\n\nConcurrency: default is 3 (hard ceiling 16). OMIT maxConcurrency to use 3. To set maxConcurrency to ANY value other than 3, you MUST first ask the user via AskUserQuestion — propose 3 / 6 / 9 (or other tiers matching the fan-out width) with 3 marked "(Recommended)". The ONLY exception: the user has ALREADY specified a concurrency number in this session ("use 6", "maxConcurrency 9") — then honor it without re-asking. Never silently raise concurrency above 3 just because the workflow fans out; 3 is the recommended default.\n\nScript execution model (common pitfalls — getting these wrong is the #1 cause of script errors): the script is the body of `new AsyncFunction` — NOT an ESM module, and TypeScript is NOT transpiled. Therefore:\n- Do NOT use `import` — `agent`, `parallel`, `pipeline`, `phase`, `log`, `workflow`, `args`, and `budget` are injected as parameters; reference them directly.\n- Do NOT use TS type annotations, `interface`, `enum`, `as`, or generics — the engine does not transpile, so even a .ts file with type syntax fails to parse.\n- Keep EXACTLY ONE `export const meta = {...}` (plain literal) and remove every other `export` / `export default`.\n- Return the result with a top-level `return`.\nPrefer .js / .mjs. See /ultracode for the full playbook and quality patterns.'})),Qn=n({AdapterNotFoundError:()=>en,AgentAdapterRegistry:()=>tn,Budget:()=>bn,BudgetExhaustedError:()=>yn,DEFAULT_MAX_CONCURRENCY:()=>3,MAX_CONCURRENCY_CAP:()=>16,MAX_ITEMS_PER_CALL:()=>B,MAX_TOTAL_AGENTS:()=>Jt,ScriptError:()=>W,Semaphore:()=>on,WORKFLOW_DIR_NAME:()=>R,WORKFLOW_RUNS_DIR:()=>qt,WORKFLOW_SCRIPT_EXTENSIONS:()=>z,WORKFLOW_TOOL_NAME:()=>L,WorkflowAbortedError:()=>X,WorkflowError:()=>Y,agentCallKey:()=>gn,clampMaxConcurrency:()=>an,createBufferingEmitter:()=>Vn,createEngineContext:()=>Mn,createFileJournalStore:()=>_n,createHostHandle:()=>Yt,createProgressEmitter:()=>Bn,createSharedResources:()=>jn,createWorkflowTool:()=>Gn,extractMeta:()=>cn,isHostHandle:()=>Xt,listNamedWorkflows:()=>An,makeHooks:()=>Pn,maxConcurrency:()=>rn,parseScript:()=>U,persistInlineScript:()=>Un,resolveNamedWorkflow:()=>q,runWorkflow:()=>Ln,unwrapHostHandle:()=>Zt,validateAgainstSchema:()=>Sn,workflowInputSchema:()=>Q}),$n=e((()=>{Kt(),V(),Qt(),nn(),sn(),K(),vn(),xn(),Tn(),J(),Z(),Nn(),In(),zn(),Hn(),Zn(),$(),Wn()})),er,tr,nr,rr,ir,ar,or=e((()=>{er=`LocalMemoryRecall`,tr=100*1024,nr=2*1024,rr=50*1024,ir=4*1024,ar=8*1024})),sr,cr,lr,ur=e((()=>{sr=`VaultHttpFetch`,cr=1048576,lr=3e4})),dr,fr,pr,mr,hr=e((()=>{ce(),rt(),it(),le(),ct(),se(),S(),lt(),Fe(),tt(),pt(),ze(),$e(),nt(),mt(),gt(),vt(),bt(),St(),Ct(),Mt(),It(),Rt(),Bt(),Vt(),Ut(),Gt(),$n(),or(),ur(),dr=new Set([oe,D,O,...process.env.USER_TYPE===`ant`?[]:[ae],k,ie,L,er,sr]),fr=new Set([...dr]),pr=new Set([b,A,v,w,...j,y,C,T,M,P,N,I,Ht,Wt]),mr=new Set([...j,b,y,C,w,v,T,ae,k,oe,ie,ht,_t,yt,xt,A,O,D,F,`LSP`,M,L,Nt,N,I,P])}));function gr(){return process.env.USER_TYPE===`ant`?`Deferred tools appear by name in <system-reminder> messages.`:`Deferred tools appear by name in <available-deferred-tools> messages.`}function _r(e){return!(e.alwaysLoad===!0||mr.has(e.name))}function vr(e){return e.name}function yr(){return br+gr()+xr}var br,xr,Sr=e((()=>{hr(),Ct(),br=`Search for deferred tools by name or keyword. LOW PRIORITY — only use this tool when no core tool can accomplish the task. Core tools (Read, Edit, Write, Bash, Glob, Grep, Agent, WebFetch, WebSearch, Skill) are always available and should be used directly. This tool is for discovering additional capabilities like MCP tools, worktree management, agent teams (TeamCreate, TeamDelete, SendMessage), etc.
|
|
97
|
+
|
|
98
|
+
`,xr=` Returns matching tool names.
|
|
99
|
+
|
|
100
|
+
## Two-step workflow (MUST follow exactly)
|
|
101
|
+
|
|
102
|
+
Deferred tools CANNOT be called directly. You MUST use this two-step pattern:
|
|
103
|
+
|
|
104
|
+
Step 1 — Search: Call this tool (SearchExtraTools) to discover the target tool.
|
|
105
|
+
Input: {"query": "select:TeamCreate"}
|
|
106
|
+
Response: "Found 1 deferred tool(s): TeamCreate. Use ExecuteExtraTool with {"tool_name": "<name>", "params": {...}} to invoke."
|
|
107
|
+
|
|
108
|
+
Step 2 — Execute: Call ExecuteExtraTool to run the discovered tool.
|
|
109
|
+
Input: {"tool_name": "TeamCreate", "params": {"name": "researcher"}}
|
|
110
|
+
Response: the actual tool result.
|
|
111
|
+
|
|
112
|
+
## Example: user asks "create a team"
|
|
113
|
+
|
|
114
|
+
1. SearchExtraTools({"query": "select:TeamCreate"})
|
|
115
|
+
→ Response: Found deferred tool TeamCreate
|
|
116
|
+
2. ExecuteExtraTool({"tool_name": "TeamCreate", "params": {"name": "researcher"}})
|
|
117
|
+
→ Response: Team created successfully
|
|
118
|
+
|
|
119
|
+
If you don't know the exact tool name, use keyword search first:
|
|
120
|
+
1. SearchExtraTools({"query": "team create"})
|
|
121
|
+
→ Response: Found deferred tool(s): TeamCreate
|
|
122
|
+
2. ExecuteExtraTool({"tool_name": "TeamCreate", "params": {...}})
|
|
123
|
+
|
|
124
|
+
## Query forms
|
|
125
|
+
- "select:TeamCreate" — exact tool name (fastest, preferred when you know the name from <available-deferred-tools>)
|
|
126
|
+
- "select:TeamCreate,SendMessage" — comma-separated multi-select
|
|
127
|
+
- "discover:create a team" — returns tool name + description + schema without loading. Use to understand a tool before calling it.
|
|
128
|
+
- "notebook jupyter" — keyword search, up to max_results best matches
|
|
129
|
+
- "+slack send" — require "slack" in the name, rank by remaining terms
|
|
130
|
+
|
|
131
|
+
## Failure policy
|
|
132
|
+
If ExecuteExtraTool fails, do NOT re-search for the same tool — it will loop. Stop and tell the user what failed.`}));export{F as $,Je as $t,X as A,A as At,nn as B,D as Bt,Zn as C,Ne as Cn,M as Ct,Q as D,ft as Dt,$ as E,pt as Et,_n as F,ot as Ft,L as G,w as Gt,Qt as H,T as Ht,vn as I,ct as It,Gt as J,Qe as Jt,V as K,tt as Kt,K as L,O as Lt,J as M,k as Mt,An as N,st as Nt,zn as O,ut as Ot,q as P,at as Pt,Vt as Q,Ke as Qt,U as R,it as Rt,Gn as S,je as Sn,gt as St,Un as T,j as Tt,Zt as U,nt as Ut,Yt as V,rt as Vt,R as W,et as Wt,Ut as X,qe as Xt,Ht as Y,$e as Yt,I as Z,b as Zt,tr as _,g as _n,yt as _t,dr as a,We as an,Nt as at,$n as b,De as bn,vt as bt,hr as c,Be as cn,P as ct,sr as d,Re as dn,Mt as dt,x as en,zt as et,ur as f,Le as fn,wt as ft,er as g,Fe as gn,St as gt,ir as h,Pe as hn,xt as ht,_r as i,Ge as in,Pt as it,Z as j,lt as jt,Ln as k,dt as kt,lr as l,Ie as ln,At as lt,ar as m,v as mn,Ct as mt,yr as n,Xe as nn,Lt as nt,pr as o,He as on,Ft as ot,rr as p,ze as pn,N as pt,Wt as q,C as qt,Sr as r,S as rn,Rt as rt,fr as s,Ve as sn,It as st,vr as t,Ye as tn,Bt as tt,cr as u,y as un,Tt as ut,nr as v,_ as vn,bt as vt,Wn as w,Oe as wn,mt as wt,Qn as x,ke as xn,ht as xt,or as y,Ae as yn,_t as yt,tn as z,E as zt};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as e,r as t}from"./prompt-Bef63FhB.js";t();export{e as isDeferredTool};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{EE as e,bE as t}from"./loadAgentsDir-nzr38hai.js";e();export{t as clearPromptCache};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./memoize-BK3gG5ob.js";import{Rn as r,t as i}from"./src-CDCSSo0U2.js";import{Ax as a,Dx as o,Lg as s,Og as c,Tx as l,kx as u,ny as d,ry as f}from"./loadAgentsDir-nzr38hai.js";import{A as p,E as m,_ as h,h as g,l as _,p as v}from"./debug-IKW-jE7K.js";import{n as y,t as b}from"./execSyncWrapper-DZJ3tNWF.js";import{r as x,t as S}from"./which-BBCjXfI2.js";import{basename as C}from"path";import{spawn as w,spawnSync as T}from"child_process";function E(e){return!!x(e)}function D(e){let t=C(e.split(` `)[0]??``);return A.find(e=>t.includes(e))}function O(e,t,n){return n?M.has(e)?[`-g`,`${t}:${n}`]:e===`subl`?[`${t}:${n}`]:[t]:[t]}function k(e,t){let n=N();if(!n)return!1;let i=n.split(` `),a=i[0]??n,o=i.slice(1),s=D(n);if(s){let r=O(s,e,t),i={detached:!0,stdio:`ignore`},c;return c=process.platform===`win32`?w(`${n} ${r.map(e=>`"${e}"`).join(` `)}`,{...i,shell:!0}):w(a,[...o,...r],i),c.on(`error`,e=>v(`editor spawn failed: ${e}`,{level:`error`})),c.unref(),!0}let c=r.get(process.stdout);if(!c)return!1;let l=t&&j.test(C(a));c.enterAlternateScreen();try{let r={stdio:`inherit`},i;return i=process.platform===`win32`?T(`${n} ${l?`+${t} `:``}"${e}"`,{...r,shell:!0}):T(a,[...o,...l?[`+${t}`,e]:[e]],r),i.error?(v(`editor spawn failed: ${i.error}`,{level:`error`}),!1):!0}finally{c.exitAlternateScreen()}}var A,j,M,N,P=e((()=>{n(),i(),_(),S(),A=[`code`,`cursor`,`windsurf`,`codium`,`subl`,`atom`,`gedit`,`notepad++`,`notepad`],j=/\b(vi|vim|nvim|nano|emacs|pico|micro|helix|hx)\b/,M=new Set([`code`,`cursor`,`windsurf`,`codium`]),N=t(()=>process.env.VISUAL?.trim()?process.env.VISUAL.trim():process.env.EDITOR?.trim()?process.env.EDITOR.trim():process.platform===`win32`?`start /wait notepad`:[`code`,`vi`,`nano`].find(e=>E(e)))}));function F(e){return D(e)!==void 0}function I(e){let t=g(),n=r.get(process.stdout);if(!n)throw Error(`Ink instance not found - cannot pause rendering`);let i=N();if(!i)return{content:null};try{t.statSync(e)}catch{return{content:null}}let a=!F(i);a?n.enterAlternateScreen():(n.pause(),n.suspendStdin());try{return b(`${z[i]??i} "${e}"`,{stdio:`inherit`}),{content:t.readFileSync(e,{encoding:`utf-8`})}}catch(e){if(typeof e==`object`&&e&&`status`in e&&typeof e.status==`number`){let t=e.status;if(t!==0)return{content:null,error:`${s(i)} exited with code ${t}`}}return{content:null}}finally{a?n.exitAlternateScreen():(n.resumeStdin(),n.resume())}}function L(e,t,n){let r=e;for(let[e,t]of Object.entries(n))if(t.type===`text`){let n=parseInt(e,10),i=t.content,a=r.indexOf(i);if(a!==-1){let e=o(n,u(i));r=r.slice(0,a)+e+r.slice(a+i.length)}}return r}function R(e,t){let n=g(),r=d();try{p(r,t?l(e,t):e,{encoding:`utf-8`,flush:!0});let n=I(r);if(n.content===null)return n;let i=n.content;return i.endsWith(`
|
|
2
|
+
`)&&!i.endsWith(`
|
|
3
|
+
|
|
4
|
+
`)&&(i=i.slice(0,-1)),t&&(i=L(i,e,t)),{content:i}}finally{try{n.unlinkSync(r)}catch{}}}var z,B=e((()=>{a(),i(),P(),y(),h(),c(),m(),f(),z={code:`code -w`,subl:`subl --wait`}}));export{P as a,N as i,R as n,k as o,B as r,I as t};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import{E as e,O as t,l as n,p as r}from"./debug-IKW-jE7K.js";import{c as i,g as a}from"./config-C7YHKCPV.js";import{r as o,t as s}from"./execFileNoThrow-COKYqVQj.js";import{n as c,t as l}from"./which-BBCjXfI2.js";import{n as u,t as d}from"./githubRepoPathMapping-BlR0BphY.js";import{n as f}from"./banner-hD6wZygx.js";import{a as p,i as m,n as h}from"./registerProtocol-CjxlFsKw.js";import{homedir as g}from"os";import{basename as _}from"path";import{spawn as v}from"child_process";e(),m(),h(),a(),n(),o(),l();var y=[{name:`iTerm2`,bundleId:`com.googlecode.iterm2`,app:`iTerm`},{name:`Ghostty`,bundleId:`com.mitchellh.ghostty`,app:`Ghostty`},{name:`Kitty`,bundleId:`net.kovidgoyal.kitty`,app:`kitty`},{name:`Alacritty`,bundleId:`org.alacritty`,app:`Alacritty`},{name:`WezTerm`,bundleId:`com.github.wez.wezterm`,app:`WezTerm`},{name:`Terminal.app`,bundleId:`com.apple.Terminal`,app:`Terminal`}],b=[`ghostty`,`kitty`,`alacritty`,`wezterm`,`gnome-terminal`,`konsole`,`xfce4-terminal`,`mate-terminal`,`tilix`,`xterm`];async function x(){let e=i().deepLinkTerminal;if(e){let t=y.find(t=>t.app===e);if(t)return{name:t.name,command:t.app}}let t=process.env.TERM_PROGRAM;if(t){let e=t.replace(/\.app$/i,``).toLowerCase(),n=y.find(t=>t.app.toLowerCase()===e||t.name.toLowerCase()===e);if(n)return{name:n.name,command:n.app}}for(let e of y){let{code:t,stdout:n}=await s(`mdfind`,[`kMDItemCFBundleIdentifier == "${e.bundleId}"`],{timeout:5e3,useCwd:!1});if(t===0&&n.trim().length>0)return{name:e.name,command:e.app}}for(let e of y){let{code:t}=await s(`ls`,[`/Applications/${e.app}.app`],{timeout:1e3,useCwd:!1});if(t===0)return{name:e.name,command:e.app}}return{name:`Terminal.app`,command:`Terminal`}}async function S(){let e=process.env.TERMINAL;if(e){let t=await c(e);if(t)return{name:_(e),command:t}}let t=await c(`x-terminal-emulator`);if(t)return{name:`x-terminal-emulator`,command:t};for(let e of b){let t=await c(e);if(t)return{name:e,command:t}}return null}async function C(){let e=await c(`wt.exe`);if(e)return{name:`Windows Terminal`,command:e};let t=await c(`pwsh.exe`);if(t)return{name:`PowerShell`,command:t};let n=await c(`powershell.exe`);return n?{name:`PowerShell`,command:n}:{name:`Command Prompt`,command:`cmd.exe`}}async function w(){switch(process.platform){case`darwin`:return x();case`linux`:return S();case`win32`:return C();default:return null}}async function T(e,t){let n=await w();if(!n)return r(`No terminal emulator detected`,{level:`error`}),!1;r(`Launching in terminal: ${n.name} (${n.command})`);let i=[`--deep-link-origin`];switch(t.repo&&(i.push(`--deep-link-repo`,t.repo),t.lastFetchMs!==void 0&&i.push(`--deep-link-last-fetch`,String(t.lastFetchMs))),t.query&&i.push(`--prefill`,t.query),process.platform){case`darwin`:return E(n,e,i,t.cwd);case`linux`:return D(n,e,i,t.cwd);case`win32`:return O(n,e,i,t.cwd);default:return!1}}async function E(e,t,n,i){switch(e.command){case`iTerm`:{let{code:e}=await s(`osascript`,[`-e`,`tell application "iTerm"
|
|
2
|
+
if running then
|
|
3
|
+
create window with default profile
|
|
4
|
+
else
|
|
5
|
+
activate
|
|
6
|
+
end if
|
|
7
|
+
tell current session of current window
|
|
8
|
+
write text ${M(A(t,n,i))}
|
|
9
|
+
end tell
|
|
10
|
+
end tell`],{useCwd:!1});if(e===0)return!0;break}case`Terminal`:{let{code:e}=await s(`osascript`,[`-e`,`tell application "Terminal"
|
|
11
|
+
do script ${M(A(t,n,i))}
|
|
12
|
+
activate
|
|
13
|
+
end tell`],{useCwd:!1});return e===0}case`Ghostty`:{let r=[`-na`,e.command,`--args`,`--window-save-state=never`];i&&r.push(`--working-directory=${i}`),r.push(`-e`,t,...n);let{code:a}=await s(`open`,r,{useCwd:!1});if(a===0)return!0;break}case`Alacritty`:{let r=[`-na`,e.command,`--args`];i&&r.push(`--working-directory`,i),r.push(`-e`,t,...n);let{code:a}=await s(`open`,r,{useCwd:!1});if(a===0)return!0;break}case`kitty`:{let r=[`-na`,e.command,`--args`];i&&r.push(`--directory`,i),r.push(t,...n);let{code:a}=await s(`open`,r,{useCwd:!1});if(a===0)return!0;break}case`WezTerm`:{let r=[`-na`,e.command,`--args`,`start`];i&&r.push(`--cwd`,i),r.push(`--`,t,...n);let{code:a}=await s(`open`,r,{useCwd:!1});if(a===0)return!0;break}}return r(`Failed to launch ${e.name}, falling back to Terminal.app`),E({name:`Terminal.app`,command:`Terminal`},t,n,i)}async function D(e,t,n,r){let i,a;switch(e.name){case`gnome-terminal`:i=r?[`--working-directory=${r}`,`--`]:[`--`],i.push(t,...n);break;case`konsole`:i=r?[`--workdir`,r,`-e`]:[`-e`],i.push(t,...n);break;case`kitty`:i=r?[`--directory`,r]:[],i.push(t,...n);break;case`wezterm`:i=r?[`start`,`--cwd`,r,`--`]:[`start`,`--`],i.push(t,...n);break;case`alacritty`:i=r?[`--working-directory`,r,`-e`]:[`-e`],i.push(t,...n);break;case`ghostty`:i=r?[`--working-directory=${r}`,`-e`]:[`-e`],i.push(t,...n);break;case`xfce4-terminal`:case`mate-terminal`:i=r?[`--working-directory=${r}`,`-x`]:[`-x`],i.push(t,...n);break;case`tilix`:i=r?[`--working-directory=${r}`,`-e`]:[`-e`],i.push(t,...n);break;default:i=[`-e`,t,...n],a=r;break}return k(e.command,i,{cwd:a})}async function O(e,t,n,r){let i=[];switch(e.name){case`Windows Terminal`:r&&i.push(`-d`,r),i.push(`--`,t,...n);break;case`PowerShell`:{let e=r?`Set-Location ${N(r)}; `:``;i.push(`-NoExit`,`-Command`,`${e}& ${N(t)} ${n.map(N).join(` `)}`);break}default:{let e=r?`cd /d ${P(r)} && `:``;i.push(`/k`,`${e}${P(t)} ${n.map(e=>P(e)).join(` `)}`);break}}return k(e.command,i,{windowsVerbatimArguments:e.name===`Command Prompt`})}function k(e,t,n={}){return new Promise(i=>{let a=v(e,t,{detached:!0,stdio:`ignore`,cwd:n.cwd,windowsVerbatimArguments:n.windowsVerbatimArguments});a.once(`error`,t=>{r(`Failed to spawn ${e}: ${t.message}`,{level:`error`}),i(!1)}),a.once(`spawn`,()=>{a.unref(),i(!0)})})}function A(e,t,n){return`${n?`cd ${j(n)} && `:``}${[e,...t].map(j).join(` `)}`}function j(e){return`'${e.replace(/'/g,`'\\''`)}'`}function M(e){return`"${e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`)}"`}function N(e){return`'${e.replace(/'/g,`''`)}'`}function P(e){return`"${e.replace(/"/g,``).replace(/%/g,`%%`).replace(/(\\+)$/,`$1$1`)}"`}n();async function F(e){r(`Handling deep link URI: ${e}`);let n;try{n=p(e)}catch(e){let t=e instanceof Error?e.message:String(e);return console.error(`Deep link error: ${t}`),1}r(`Parsed deep link action: ${t(n)}`);let{cwd:i,resolvedRepo:a}=await L(n),o=a?await f(i):void 0;return await T(process.execPath,{query:n.query,cwd:i,repo:a,lastFetchMs:o?.getTime()})?0:(console.error(`Failed to open a terminal. Make sure a supported terminal emulator is installed.`),1)}async function I(){if(process.env.__CFBundleIdentifier!==`com.anthropic.claude-code-url-handler`)return null;try{let{waitForUrlEvent:e}=await import(`./src-DLz3FZm1.js`),t=await e(5e3);return t?await F(t):null}catch{return null}}async function L(e){if(e.cwd)return{cwd:e.cwd};if(e.repo){let t=await d(u(e.repo));if(t[0])return r(`Resolved repo ${e.repo} → ${t[0]}`),{cwd:t[0],resolvedRepo:e.repo};r(`No local clone found for repo ${e.repo}, falling back to home`)}return{cwd:g()}}export{F as handleDeepLinkUri,I as handleUrlSchemeLaunch};
|