@readmagic/workmate 0.0.1 → 0.0.3
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 → AddWorkspaceDirectory-mANiG0xj.js} +1 -1
- package/dist/chunks/{App-DY5O6IKw.js → App-aUVaOLeo.js} +1 -1
- package/dist/chunks/{ApproveApiKey-BEzfC6r3.js → ApproveApiKey-36iUE5CW.js} +1 -1
- package/dist/chunks/ApproveApiKey-DPdcp1CQ.js +1 -0
- package/dist/chunks/{AssistantSessionChooser-Ce3PraaD.js → AssistantSessionChooser-BLcvdkgb.js} +1 -1
- package/dist/chunks/BackgroundTasksDialog-DyjVt81B.js +2 -0
- package/dist/chunks/{BypassPermissionsModeDialog-B68V1bCq.js → BypassPermissionsModeDialog-CTlpvTuz.js} +1 -1
- package/dist/chunks/{ClaudeMdExternalIncludesDialog-CTWhpIm8.js → ClaudeMdExternalIncludesDialog-5pipE8m8.js} +1 -1
- package/dist/chunks/ClaudeMdExternalIncludesDialog-Dn7Le--z.js +1 -0
- package/dist/chunks/ConsoleOAuthFlow-BDr1Vx5K.js +1 -0
- package/dist/chunks/{DesktopHandoff-BRbU4is4.js → DesktopHandoff-Blg1TVut.js} +1 -1
- package/dist/chunks/{DiffDialog-CBluIK-x.js → DiffDialog-CUEpuocY.js} +2 -2
- package/dist/chunks/Doctor-B540I-gq.js +1 -0
- package/dist/chunks/Doctor-DlE1Mbb9.js +3 -0
- package/dist/chunks/ExitFlow-DCIhnP5h.js +2 -0
- package/dist/chunks/Feedback-CDTqPqsM.js +2 -0
- package/dist/chunks/{Grove--kttLxvs.js → Grove-D9lSG_Lh.js} +1 -1
- package/dist/chunks/Grove-DLYXL8hv.js +1 -0
- package/dist/chunks/{HybridTransport-BgV5_7Az.js → HybridTransport-8j0AviF6.js} +4 -4
- package/dist/chunks/{InvalidConfigDialog-DCGwXW_p.js → InvalidConfigDialog-I3t-0nU3.js} +1 -1
- package/dist/chunks/{InvalidSettingsDialog-jTwsdXWr.js → InvalidSettingsDialog-BnthOxGT.js} +1 -1
- package/dist/chunks/MCPConnectionManager-zdocEDgk.js +1 -0
- package/dist/chunks/{McpParsingWarnings-WQrWJeWP.js → McpParsingWarnings-D0XvLirX.js} +1 -1
- package/dist/chunks/MessageSelector-BBhCstBa.js +3 -0
- package/dist/chunks/Messages-Dv2VrytX.js +11 -0
- package/dist/chunks/{Onboarding-BoIVNCgc.js → Onboarding-B1WRpoBI.js} +1 -1
- package/dist/chunks/{OverageCreditUpsell-1FCN8bH3.js → OverageCreditUpsell-BSmgq089.js} +1 -1
- package/dist/chunks/PluginSettings-DN9rpwc_.js +17 -0
- package/dist/chunks/{PromptInputFooterSuggestions-CrGST0Cq.js → PromptInputFooterSuggestions-3rjz6zhK.js} +1 -1
- package/dist/chunks/{PromptInputHelpMenu-B2TDpbpw.js → PromptInputHelpMenu-DgDJHZqC.js} +1 -1
- package/dist/chunks/QueryEngine-BnaHDZVZ.js +1 -0
- package/dist/chunks/REPL-B3RbzeV7.js +1 -0
- package/dist/chunks/{REPL-BV4WyYMg.js → REPL-CA8FEO7J.js} +44 -44
- package/dist/chunks/{RemoteCallout-DS_EV6Fh.js → RemoteCallout-BFzCx_Pn.js} +1 -1
- package/dist/chunks/RemoteSessionManager-BhUrtejX.js +2 -0
- package/dist/chunks/ResumeConversation-BseKUFRI.js +1 -0
- package/dist/chunks/{SSETransport-BXiEBMpb.js → SSETransport-DGIytG74.js} +3 -3
- package/dist/chunks/SearchExtraToolsTool-h6OunbMd.js +1 -0
- package/dist/chunks/Settings-BvhG1XoW.js +2 -0
- package/dist/chunks/{TeleportProgress-CcDzMC5L.js → TeleportProgress-Bens06DU.js} +1 -1
- package/dist/chunks/{TeleportRepoMismatchDialog-DZbxl4sD.js → TeleportRepoMismatchDialog-BtLBCZUe.js} +1 -1
- package/dist/chunks/{TeleportResumeWrapper-EowJO5nm.js → TeleportResumeWrapper-t50LfWyN.js} +1 -1
- package/dist/chunks/{ThemePicker-BYbChJpu.js → ThemePicker-BTfuZZ7E.js} +1 -1
- package/dist/chunks/TrustDialog-CgE_pYUK.js +1 -0
- package/dist/chunks/{ValidationErrorsList-Cx-hoRwG.js → ValidationErrorsList-Bl68E-2-.js} +1 -1
- package/dist/chunks/WelcomeV2-C93xQYAF.js +1 -0
- package/dist/chunks/{add-dir-CWt69NAZ.js → add-dir-C3IhJYVH.js} +1 -1
- package/dist/chunks/{agentDisplay-CQ4mZWFH.js → agentDisplay-Cju-aXCx.js} +1 -1
- package/dist/chunks/{agents-D4clhuCl.js → agents-Bhg0CtXR.js} +7 -7
- package/dist/chunks/{agents-C6jzKOit.js → agents-Du3FQ82k.js} +1 -1
- package/dist/chunks/{allErrors-HMPqE0jK.js → allErrors-DJYCAtab.js} +1 -1
- package/dist/chunks/{ant-9Z5bppVC.js → ant-CVvy4SuO.js} +1 -1
- package/dist/chunks/api-CI8HXREw.js +1 -0
- package/dist/chunks/api-gJBnC8z3.js +1 -0
- package/dist/chunks/asciicast-BsWpcxrc.js +1 -0
- package/dist/chunks/{asciicast-n-BBfgDq.js → asciicast-CbAjUHT_.js} +4 -4
- package/dist/chunks/{assistant-BA9_Mo9U.js → assistant-C83quuNj.js} +1 -1
- package/dist/chunks/{assistant-BiNOSla3.js → assistant-C_SkUDk_.js} +1 -1
- package/dist/chunks/assistant-z2o4-UJe.js +1 -0
- package/dist/chunks/auth-B9V3i5oZ.js +1 -0
- package/dist/chunks/auth-CgEABs3i.js +15 -0
- package/dist/chunks/auth-fSFfSKy_.js +1 -0
- package/dist/chunks/{autoMode-Db4QrgFr.js → autoMode-CZyb-mMY.js} +7 -7
- package/dist/chunks/{autonomy-BkAMA7du.js → autonomy-BpINX4jw.js} +1 -1
- package/dist/chunks/{autonomy-D4Vy-RPQ.js → autonomy-DJZ25xZp.js} +7 -7
- package/dist/chunks/{autonomyPanel-EjfO8jvg.js → autonomyPanel-ssoiIOx5.js} +1 -1
- package/dist/chunks/{backgroundHousekeeping-hDDE8mJC.js → backgroundHousekeeping-BHncba6e.js} +3 -3
- package/dist/chunks/backgroundHousekeeping-QK8iEXoI.js +1 -0
- package/dist/chunks/{banner-hD6wZygx.js → banner-CWkrK10u.js} +1 -1
- package/dist/chunks/bg-B0iMGM9C.js +1 -0
- package/dist/chunks/{bg-DQ0Q3Qv-.js → bg-WnYN5ifx.js} +2 -2
- package/dist/chunks/{branch-CeQ9IyZk.js → branch-BXo5z2al.js} +1 -1
- package/dist/chunks/{break-cache-Bd0clV2N.js → break-cache-BQfgkNAo.js} +2 -2
- package/dist/chunks/{bridge-yerAiaK2.js → bridge-CbKc1HeD.js} +2 -2
- package/dist/chunks/bridgeConfig-CLHy-BiF.js +1 -0
- package/dist/chunks/{bridgeConfig-CCtXe8ak.js → bridgeConfig-DbqUHe0H.js} +1 -1
- package/dist/chunks/bridgeEnabled-BWSUZ7Xg.js +1 -0
- package/dist/chunks/{bridgeEnabled--F-6TUi4.js → bridgeEnabled-CM3SaumJ.js} +1 -1
- package/dist/chunks/bridgeMain-BESKzpm0.js +1 -0
- package/dist/chunks/bridgeMain-CzhBVCsN.js +68 -0
- package/dist/chunks/bridgeMessaging-lfa_v3oi.js +1 -0
- package/dist/chunks/bridgePointer-MqLe5Asm.js +1 -0
- package/dist/chunks/{browser-Bd7GeBH1.js → browser-BmZuQom6.js} +1 -1
- package/dist/chunks/{btw-CVGRmL9a.js → btw-Cp0whJaJ.js} +1 -1
- package/dist/chunks/{caches-BtmAri4e.js → caches-CmW7idg5.js} +2 -2
- package/dist/chunks/caches-CpqTC0Lb.js +1 -0
- package/dist/chunks/ccrClient-BPXmxWHw.js +1 -0
- package/dist/chunks/{claudeDesktop-aUMx06RK.js → claudeDesktop-Cx31Ugjp.js} +1 -1
- package/dist/chunks/{clear-C6nRzIQE.js → clear-DjGPxX7T.js} +1 -1
- package/dist/chunks/{cliLaunch-2AUoMnqx.js → cliLaunch-BkPAatcs.js} +1 -1
- package/dist/chunks/client-DPUvQ6Rf.js +1 -0
- package/dist/chunks/{color-DXI_4ibU.js → color-DYYBN52b.js} +1 -1
- package/dist/chunks/commands-D7l3P1k9.js +1 -0
- package/dist/chunks/commitAttribution-B7NUPJ8E.js +1 -0
- package/dist/chunks/{commitAttribution-Cm40fdNU.js → commitAttribution-Bmzgtqc6.js} +2 -2
- package/dist/chunks/compact-D6xqZN4Q.js +2 -0
- package/dist/chunks/{completionCache-BQaLkB4d.js → completionCache-MN3_MqK8.js} +2 -2
- package/dist/chunks/completionCache-c4aiyZ_f.js +1 -0
- package/dist/chunks/config-DiT2Z8dY.js +3 -0
- package/dist/chunks/config-huQaTcNb.js +1 -0
- package/dist/chunks/config-qLaiAn7z.js +1 -0
- package/dist/chunks/{context-C_cKrBUn.js → context-Bh_iUj76.js} +1 -1
- package/dist/chunks/context-noninteractive-CNot6jbs.js +1 -0
- package/dist/chunks/{context-noninteractive-DnH6Q9Lu.js → context-noninteractive-Cb3EM2Oz.js} +2 -2
- package/dist/chunks/conversation-CSpwF3Ha.js +1 -0
- package/dist/chunks/conversation-CvCQta8e.js +1 -0
- package/dist/chunks/{createSSHSession--bWmmIk9.js → createSSHSession-B0s839mX.js} +5 -5
- package/dist/chunks/createSession-GNSNbUbN.js +1 -0
- package/dist/chunks/{createSession-DIr4sUp6.js → createSession-VMTMXOHu.js} +1 -1
- package/dist/chunks/crossProjectResume-DGpgCUfk.js +40 -0
- package/dist/chunks/cwd--nvsx73T.js +1 -0
- package/dist/chunks/{cwd-BuJhkTrc.js → cwd-CYmmnQVS.js} +1 -1
- package/dist/chunks/{daemon-B9lBPdBJ.js → daemon-YtZbMQtn.js} +1 -1
- package/dist/chunks/datadog-D9rlcN12.js +1 -0
- package/dist/chunks/{debug-IKW-jE7K.js → debug-BrXObCdR.js} +2 -2
- package/dist/chunks/{debugUtils-D2981c0Z.js → debugUtils-NO5KtXqi.js} +1 -1
- package/dist/chunks/{desktop-B5cvrcOQ.js → desktop-DidI-4N5.js} +1 -1
- package/dist/chunks/{detached-rfIUyc-B.js → detached-TYk4hMFj.js} +1 -1
- package/dist/chunks/{detectRepository-ReZ0Fz8Z.js → detectRepository-BPr0VWNO.js} +1 -1
- package/dist/chunks/detectRepository-BTPgN89l.js +1 -0
- package/dist/chunks/{diff-cXAp9cNN.js → diff-CZg5qL2n.js} +1 -1
- package/dist/chunks/{directoryCompletion-DBM2o5kx.js → directoryCompletion-CW2ckkQg.js} +1 -1
- package/dist/chunks/doctor-CKUXGCri.js +1 -0
- package/dist/chunks/{effort-Br8KKHdx.js → effort-BcvNemuq.js} +2 -2
- package/dist/chunks/entry-dA1UCfC0.js +14 -0
- package/dist/chunks/envLessBridgeConfig-BFjJ8Kt4.js +1 -0
- package/dist/chunks/envLessBridgeConfig-bei51W3H.js +1 -0
- package/dist/chunks/esm-DjGYYlQe.js +1 -0
- package/dist/chunks/{execFileNoThrow-COKYqVQj.js → execFileNoThrow-D244NytW.js} +1 -1
- package/dist/chunks/execSyncWrapper-CCMQShK-.js +1 -0
- package/dist/chunks/exit-COMnVxzw.js +1 -0
- package/dist/chunks/extra-usage-BTv_OwGN.js +1 -0
- package/dist/chunks/extra-usage-By33zGLT.js +1 -0
- package/dist/chunks/{extra-usage-core-CdL1ltqq.js → extra-usage-core-RZMzaH0L.js} +1 -1
- package/dist/chunks/{extra-usage-noninteractive-DxxRI0Yx.js → extra-usage-noninteractive-BB-BQ3kh.js} +1 -1
- package/dist/chunks/{extraUsage-BYZdi44Y.js → extraUsage-CTn9FWSk.js} +1 -1
- package/dist/chunks/extractMemories-CXGZGe0h.js +1 -0
- package/dist/chunks/fast-BXzdzzXU.js +1 -0
- package/dist/chunks/{fast-DKqiojzf.js → fast-CNXgsvnE.js} +1 -1
- package/dist/chunks/{feedback-yB19xph5.js → feedback-DeJ2gvw2.js} +1 -1
- package/dist/chunks/{file-D1cN3LMK.js → file-DcZWPH2V.js} +5 -5
- package/dist/chunks/{files-DAzGtmzz.js → files-Cz1-PK3r.js} +1 -1
- package/dist/chunks/firstPartyEventLogger-CQdJn3LV.js +5 -0
- package/dist/chunks/firstPartyEventLogger-CdLshdJY.js +1 -0
- package/dist/chunks/{flushGate-ZFr8yv7F.js → flushGate-CJ73xcaK.js} +1 -1
- package/dist/chunks/gemini-Cn9bMXwP.js +1 -0
- package/dist/chunks/generateRecap-BO9kzRon.js +1 -0
- package/dist/chunks/{generateSessionName-48veu5dv.js → generateSessionName-CGpL6ATy.js} +1 -1
- package/dist/chunks/{genericProcessUtils-F1Qcb1sO.js → genericProcessUtils-CdQTApYX.js} +1 -1
- package/dist/chunks/git-CbcnOf0E.js +1 -0
- package/dist/chunks/git-Do0wJvux.js +6 -0
- package/dist/chunks/{githubRepoPathMapping-BlR0BphY.js → githubRepoPathMapping-C4umZ1oC.js} +1 -1
- package/dist/chunks/{goal-Bn8Kz2Dp.js → goal-C8Qzl7_i.js} +3 -3
- package/dist/chunks/{grok-DhnO_KDC.js → grok-CDT9P_BL.js} +1 -1
- package/dist/chunks/{grove-DotW04-v.js → grove-BGXzEyH9.js} +2 -2
- package/dist/chunks/{heapdump-DkZSKNbp.js → heapdump-CFHvdSZv.js} +5 -5
- package/dist/chunks/{help-DU_BcZtU.js → help-DUZ7Y7Em.js} +1 -1
- package/dist/chunks/{hooks-BTMWE5Qx.js → hooks-RHwUCXcT.js} +2 -2
- package/dist/chunks/hooks-fZ1r0jUF.js +1 -0
- package/dist/chunks/{hostGuard-Dh296c6q.js → hostGuard-C5xydXZI.js} +1 -1
- package/dist/chunks/inboundAttachments-Cfl4_n0S.js +1 -0
- package/dist/chunks/inboundAttachments-YMxf4fmR.js +1 -0
- package/dist/chunks/initReplBridge-GH3-LHF4.js +1 -0
- package/dist/chunks/install-OkuNmjmB.js +1 -0
- package/dist/chunks/{instrumentation-H0XRS1yG.js → instrumentation-hrXeo-G4.js} +6 -6
- package/dist/chunks/{job-DKtLkF8V.js → job-DjmIpwJl.js} +1 -1
- package/dist/chunks/jwtUtils-DE2GPUcx.js +1 -0
- package/dist/chunks/keybindings-B8U17bhs.js +2 -0
- package/dist/chunks/{language-BuRSO2sR.js → language-BA5WprZv.js} +1 -1
- package/dist/chunks/language-BbaOTWm3.js +1 -0
- package/dist/chunks/{launchAgentsPlatform-BQyPdrHp.js → launchAgentsPlatform-DnxH2SAn.js} +1 -1
- package/dist/chunks/{launchLocalMemory-CWHAj7CX.js → launchLocalMemory-CgXtGng1.js} +2 -2
- package/dist/chunks/{launchLocalVault-D8iJdtsP.js → launchLocalVault-Bs6Km3Ua.js} +3 -3
- package/dist/chunks/{launchMemoryStores-W7jWG2uH.js → launchMemoryStores-DxVAIJuB.js} +1 -1
- package/dist/chunks/{launchOnboarding-q__LaLy1.js → launchOnboarding-Cn0t_o2k.js} +1 -1
- package/dist/chunks/{launchSchedule-BWi9F5vh.js → launchSchedule-Chwr3Nzd.js} +1 -1
- package/dist/chunks/{launchSkillStore-4wd4MQBc.js → launchSkillStore-6zxJfWVU.js} +1 -1
- package/dist/chunks/{launchTeleport-BlCf2QM_.js → launchTeleport-Ba_Hj13c.js} +1 -1
- package/dist/chunks/{launchVault-C7u7LZV7.js → launchVault-hGVrHy33.js} +1 -1
- package/dist/chunks/{v4-jw6qOKwQ.js → lazySchema-DcIJE_0i.js} +1 -1
- package/dist/chunks/loadAgentsDir-BHOyHxwz.js +1 -0
- package/dist/chunks/{loadAgentsDir-nzr38hai.js → loadAgentsDir-DrDu5yYy.js} +691 -689
- package/dist/chunks/loadPluginHooks-s7bvGtns.js +1 -0
- package/dist/chunks/localSearch-CebU5BA9.js +1 -0
- package/dist/chunks/{localSearch-B-L_ldos.js → localSearch-_bQhk9W6.js} +1 -1
- package/dist/chunks/{log-B3eB4EFv.js → log-BMCygSzM.js} +1 -1
- package/dist/chunks/{logoV2Utils-RQ160dI2.js → logoV2Utils-CoC4nheD.js} +1 -1
- package/dist/chunks/{magicDocs-BqZ0GewA.js → magicDocs-kMjYpjCA.js} +3 -3
- package/dist/chunks/main-C_rVSWfm.js +859 -0
- package/dist/chunks/{main-DeFMhaFE.js → main-D862LI_d.js} +3 -3
- package/dist/chunks/{mappers-CWykjGfP.js → mappers-D0CNXG32.js} +1 -1
- package/dist/chunks/mcp-1ZuFesM9.js +2 -0
- package/dist/chunks/mcp-CKvGBEjz.js +1 -0
- package/dist/chunks/mcp-DtxIl6aN.js +6 -0
- package/dist/chunks/{memoize-BO31Ws9Q.js → memoize-B0zhbT8Z.js} +1 -1
- package/dist/chunks/{memory-DcpPpYN0.js → memory-DE2jtkd_.js} +1 -1
- package/dist/chunks/{mode-BkViT_0o.js → mode-B4WIxCMW.js} +2 -2
- package/dist/chunks/model-C4RHNhDQ.js +1 -0
- package/dist/chunks/model-fi472PRc.js +1 -0
- package/dist/chunks/{model-CZktWw6o.js → model-j9GNZDFr.js} +1 -1
- package/dist/chunks/nativeInstaller-DktvrWRd.js +1 -0
- package/dist/chunks/{onChangeAppState-DwGVi-BC.js → onChangeAppState-CGVeNkt7.js} +1 -1
- package/dist/chunks/{openai-B2wxZDQx.js → openai-BSVjSJiF.js} +3 -3
- package/dist/chunks/{overageCreditGrant-CjK49axw.js → overageCreditGrant-BVxlYgeU.js} +1 -1
- package/dist/chunks/{panel-R4ue6pSW.js → panel-Be-OxtqL.js} +1 -1
- package/dist/chunks/{panel-B-nrcHpm.js → panel-CrTPqXCv.js} +1 -1
- package/dist/chunks/{panelCall-I_fbgub5.js → panelCall-Cp6fpQeL.js} +1 -1
- package/dist/chunks/parser-Bf6iasPV.js +1 -0
- package/dist/chunks/{parser-CQrasoUB.js → parser-DFwaTGf7.js} +1 -1
- package/dist/chunks/{partition-CxRF7T-f.js → partition-RjCtgt9J.js} +1 -1
- package/dist/chunks/{passes-U_h-hNu-.js → passes-ByTLy6pj.js} +1 -1
- package/dist/chunks/{path-BCSE0S-c.js → path-D5U-tm91.js} +1 -1
- package/dist/chunks/permissions-B3df_htx.js +3 -0
- package/dist/chunks/pidLock-CdNZ0Wfg.js +3 -0
- package/dist/chunks/{pipeTransport-D3Qx9v1V.js → pipeTransport-CqCnc-Ys.js} +1 -1
- package/dist/chunks/{plan-BAhStVci.js → plan-BxTA-b4l.js} +1 -1
- package/dist/chunks/{platform-EtecGacO.js → platform-BrYefG_2.js} +1 -1
- package/dist/chunks/{plugin-D9huNnv6.js → plugin-DOpl5e1t.js} +1 -1
- package/dist/chunks/{pluginAutoupdate-BfmyxR5g.js → pluginAutoupdate-L09CQ-ph.js} +1 -1
- package/dist/chunks/pluginBlocklist-B32eWmzn.js +1 -0
- package/dist/chunks/pluginCliCommands-CDMWnO3d.js +1 -0
- package/dist/chunks/{pluginFlagging-BVy7Xv_0.js → pluginFlagging-3FQGvIfq.js} +1 -1
- package/dist/chunks/pluginOperations-ClzXYNQe.js +2 -0
- package/dist/chunks/{pluginStartupCheck-w24D-wwk.js → pluginStartupCheck-BNd2QNzZ.js} +1 -1
- package/dist/chunks/pluginStartupCheck-RiZxW-WU.js +1 -0
- package/dist/chunks/plugins-CcDG95Bs.js +4 -0
- package/dist/chunks/policyLimits-Bwi9VqDF.js +1 -0
- package/dist/chunks/pollConfig-DH2oCtFS.js +1 -0
- package/dist/chunks/{poor-CfbMKZNJ.js → poor-DekfGNT7.js} +1 -1
- package/dist/chunks/poorMode-AE4WNYZo.js +1 -0
- package/dist/chunks/{poorMode-Bsw2V-V_.js → poorMode-CtcqaiwD.js} +1 -1
- package/dist/chunks/print-Cc_QOSPF.js +23 -0
- package/dist/chunks/{privacy-settings-DeGoBRrZ.js → privacy-settings-ChNsgGUs.js} +1 -1
- package/dist/chunks/processBashCommand-Bx6_oZoE.js +1 -0
- package/dist/chunks/processSlashCommand-AltWgIFt.js +5 -0
- package/dist/chunks/prompt-C0nU0VK3.js +139 -0
- package/dist/chunks/prompt-CYx145pp.js +1 -0
- package/dist/chunks/prompt-DH3lKFag.js +1 -0
- package/dist/chunks/{promptEditor-foiayhdY.js → promptEditor-Cumef6hJ.js} +2 -2
- package/dist/chunks/{protocolHandler-BsiB1oW_.js → protocolHandler-z2zxAtB1.js} +4 -4
- package/dist/chunks/{proxy-Cn2YwITp.js → proxy-CRN7jYIi.js} +3 -3
- package/dist/chunks/{rate-limit-options-DTJPDcTr.js → rate-limit-options-VL7S3SCx.js} +1 -1
- package/dist/chunks/rcDebugLog-2-1XSyFV.js +11 -0
- package/dist/chunks/reconciler-DHRE_gV2.js +4 -0
- package/dist/chunks/{referral-DP_GshTS.js → referral-DrebVwqx.js} +1 -1
- package/dist/chunks/refresh-pFezssA8.js +1 -0
- package/dist/chunks/{registerProtocol-CjxlFsKw.js → registerProtocol-CukLQuxJ.js} +5 -5
- package/dist/chunks/{release-notes-BxgK8zWO.js → release-notes-D7vrFNXp.js} +1 -1
- package/dist/chunks/{releaseNotes-CbSktIJW.js → releaseNotes-CDx2P0fb.js} +2 -2
- package/dist/chunks/{reload-plugins-CDu6yU5-.js → reload-plugins-CltHfg-l.js} +1 -1
- package/dist/chunks/{remote-env-B4HnhISc.js → remote-env-SvvSuP0J.js} +1 -1
- package/dist/chunks/remoteBridgeCore-BOeljn2c.js +1 -0
- package/dist/chunks/remoteManagedSettings-CaY_ZH8r.js +1 -0
- package/dist/chunks/{rename-DlbMb24l.js → rename-CbqrCCBO.js} +1 -1
- package/dist/chunks/{renderOptions-5kWQpVr2.js → renderOptions-BUJB9nAm.js} +1 -1
- package/dist/chunks/{resume-BB5iBogS.js → resume-DockJaY9.js} +2 -2
- package/dist/chunks/{ripgrep-BvDwiKJ3.js → ripgrep-BXmXjAzA.js} +1 -1
- package/dist/chunks/ripgrep-BfIpz5uC.js +1 -0
- package/dist/chunks/{runtimeObserver-BNH2WGE3.js → runtimeObserver-DSUuYKfs.js} +1 -1
- package/dist/chunks/{runtimeObserver-Ci-5gvYg.js → runtimeObserver-XufSllVw.js} +4 -4
- package/dist/chunks/sandbox-adapter-CEZnHq0U.js +1 -0
- package/dist/chunks/{sandbox-toggle-B2Yk4y2V.js → sandbox-toggle-CZI5fuK3.js} +1 -1
- package/dist/chunks/searchExtraTools-iQfI39wB.js +1 -0
- package/dist/chunks/{session-Bmx7L3Mt.js → session-B-Z3DU9o.js} +2 -2
- package/dist/chunks/{sessionDiscovery-DcEAr5vJ.js → sessionDiscovery-C3pMZkBM.js} +1 -1
- package/dist/chunks/sessionFileAccessHooks-DyrZmoA7.js +1 -0
- package/dist/chunks/sessionMemory-CqRpgwtU.js +1 -0
- package/dist/chunks/sessionMemory-D_HQmhj7.js +1 -0
- package/dist/chunks/sessionMemoryUtils-CZOIKrn0.js +1 -0
- package/dist/chunks/sessionObserver-B400YG3s.js +1 -0
- package/dist/chunks/{sessionObserver-DQwHsDrM.js → sessionObserver-B_09FQKV.js} +1 -1
- package/dist/chunks/sessionStorage-DRnvtrpU.js +1 -0
- package/dist/chunks/sessionTitle-CmLWNFuX.js +14 -0
- package/dist/chunks/{sessionTracing-BuLsL6qA.js → sessionTracing-lArOaj9u.js} +3 -3
- package/dist/chunks/settings-DfWP5y6X.js +19 -0
- package/dist/chunks/settingsSync-BlDk6rsM.js +1 -0
- package/dist/chunks/setup-DdbmxSZh.js +3 -0
- package/dist/chunks/{shadowedRuleDetection-7Z8ezTKF.js → shadowedRuleDetection-E2wF1UjU.js} +1 -1
- package/dist/chunks/{shellQuote-fB02N16J.js → shellQuote-DkSy9MYE.js} +1 -1
- package/dist/chunks/{sideQuestion-CYdNATPW.js → sideQuestion-BjHCLSR9.js} +1 -1
- package/dist/chunks/sinks-Cb--pqr-.js +2 -0
- package/dist/chunks/sinks-DbwDBd-E.js +1 -0
- package/dist/chunks/{skill-learning-E8tQed-Q.js → skill-learning-B0dyBT1_.js} +1 -1
- package/dist/chunks/skillChangeDetector-DQof8SUY.js +1 -0
- package/dist/chunks/{skillGapStore-CjJrxxjk.js → skillGapStore-75ZYlfwi.js} +2 -2
- package/dist/chunks/{skillGapStore-B5rl12bV.js → skillGapStore-D2fqmnKx.js} +1 -1
- package/dist/chunks/{skillGenerator-BDR_z3-X.js → skillGenerator-CwXUfM4Y.js} +2 -2
- package/dist/chunks/{skillLearning-BQtfFE0g.js → skillLearning-CB-5fdMl.js} +1 -1
- package/dist/chunks/skillLearning-CSY5R5Jn.js +1 -0
- package/dist/chunks/{skillPanel-yR8Oi-mO.js → skillPanel-Bum7xpgo.js} +3 -3
- package/dist/chunks/{skillSearchPanel-DUQQUCUS.js → skillSearchPanel-LSPwZIOw.js} +6 -6
- package/dist/chunks/{skills-NAZQ3j-t.js → skills-G8WBeffd.js} +1 -1
- package/dist/chunks/startupProfiler-DIWVcO4e.js +1 -0
- package/dist/chunks/{startupProfiler-DxRQteII.js → startupProfiler-xa3NmN7Z.js} +2 -2
- package/dist/chunks/state-BOa-3Av3.js +1 -0
- package/dist/chunks/{state-4KQ3kaqz.js → state-ix0xIunV.js} +1 -1
- package/dist/chunks/{stats-h4yu84Q-.js → stats-DmFubHpI.js} +1 -1
- package/dist/chunks/{status-is_Bg_IB.js → status-ClSsvm1N.js} +2 -2
- package/dist/chunks/{status-BbdeubJG.js → status-i5beKggW.js} +1 -1
- package/dist/chunks/{statusNoticeHelpers-CQ7CUugR.js → statusNoticeHelpers-BK-54uGY.js} +1 -1
- package/dist/chunks/{stickers-qJoNhPk4.js → stickers-D5teCKMN.js} +1 -1
- package/dist/chunks/{stringUtils-CvXbHQRH.js → stringUtils-DGLPkqJ4.js} +1 -1
- package/dist/chunks/systemPromptSections-CR_AoPIX.js +1 -0
- package/dist/chunks/{systemPromptSections-CgpggIYX.js → systemPromptSections-DN0HGVye.js} +1 -1
- package/dist/chunks/{tag-i3HZ4lhj.js → tag-DYYq4H_i.js} +2 -2
- package/dist/chunks/{tasks-HzsYNTZ1.js → tasks-BySzm_YJ.js} +1 -1
- package/dist/chunks/teleport-dxtBcM01.js +1 -0
- package/dist/chunks/{templateJobs-CIv_ysje.js → templateJobs-CT5VxeRr.js} +1 -1
- package/dist/chunks/terminalSetup-BNs9nLbT.js +33 -0
- package/dist/chunks/{terminalSetup-CxniwSF-.js → terminalSetup-RDKg8dVa.js} +1 -1
- package/dist/chunks/{theme-BKIHX_Dx.js → theme-CVTVsRwt.js} +1 -1
- package/dist/chunks/thinkback-B-GpXG9U.js +1 -0
- package/dist/chunks/thinkback-CXsRbDYN.js +1 -0
- package/dist/chunks/thinkback-play-BhfCaIye.js +1 -0
- package/dist/chunks/{tmux-CbsW-VDJ.js → tmux-BY7IdQ1f.js} +1 -1
- package/dist/chunks/{toolEventObserver-B1xvyKdE.js → toolEventObserver--4fqXxQZ.js} +1 -1
- package/dist/chunks/{toolEventObserver-8FQtxeVv.js → toolEventObserver-DdhPsAs1.js} +1 -1
- package/dist/chunks/toolPool-DvHECcbN.js +1 -0
- package/dist/chunks/trustedDevice-DvpN4J1F.js +1 -0
- package/dist/chunks/trustedDevice-e6iF1X7C.js +1 -0
- package/dist/chunks/{tui-fTa_pzdA.js → tui-C2yuCuOU.js} +3 -3
- package/dist/chunks/{types-a7X-tJpJ.js → types-C-MRCL8J.js} +3 -3
- package/dist/chunks/udsClient-BuCtv7dN.js +1 -0
- package/dist/chunks/{ultrareviewCommand-DCFRZsKp.js → ultrareviewCommand-i3PfFKly.js} +2 -2
- package/dist/chunks/undercover-CPvoDtJ1.js +1 -0
- package/dist/chunks/{undercover-CsLPQb-a.js → undercover-Q24TWRw0.js} +3 -3
- package/dist/chunks/{up-dO5BcPaq.js → up-BHkC97_C.js} +1 -1
- package/dist/chunks/updateCCB-CEXA6dax.js +11 -0
- package/dist/chunks/{upgrade-kpttjebY.js → upgrade-7OrBbrzS.js} +1 -1
- package/dist/chunks/upgrade-uR7SIVtx.js +1 -0
- package/dist/chunks/upload-B-lNHpWe.js +1 -0
- package/dist/chunks/{upstreamproxy-CvcjNY7J.js → upstreamproxy-DyR_eXO8.js} +4 -4
- package/dist/chunks/usage-7jOeIVv9.js +1 -0
- package/dist/chunks/{usage-CJ5w0907.js → usage-CZdPfUqP.js} +1 -1
- package/dist/chunks/{useExitOnCtrlCDWithKeybindings-yAroCqu4.js → useExitOnCtrlCDWithKeybindings-CzFtdlnD.js} +1 -1
- package/dist/chunks/useMainLoopModel-DegH12LZ.js +1 -0
- package/dist/chunks/useManagePlugins-BkK1zydO.js +1 -0
- package/dist/chunks/{useMergedTools-CZJffsmf.js → useMergedTools-DMGRA1ga.js} +1 -1
- package/dist/chunks/{useSearchInput-C-CqUK6w.js → useSearchInput-D5VU9IDU.js} +1 -1
- package/dist/chunks/{useSettingsErrors-BWlJCgYF.js → useSettingsErrors-B5PSF1va.js} +1 -1
- package/dist/chunks/{util-DJV0joAW.js → util-CNa1ib_4.js} +1 -1
- package/dist/chunks/validatePlugin-Dw-RGCrm.js +1 -0
- package/dist/chunks/{vim-n8-UT5w-.js → vim-C0KTnJJs.js} +1 -1
- package/dist/chunks/{which-BBCjXfI2.js → which-CKQnSouy.js} +1 -1
- package/dist/chunks/windowsPaths-9pEkw0oV.js +1 -0
- package/dist/chunks/windowsPaths-DtapVxOo.js +1 -0
- package/dist/chunks/{workSecret-C_lv0dRh.js → workSecret-CNWiR2uQ.js} +1 -1
- package/dist/chunks/{workerRegistry-BdHi7_sN.js → workerRegistry-B2QD2sKq.js} +1 -1
- package/dist/chunks/worktree-D38cJ23W.js +1 -0
- package/dist/cli.js +1 -1
- package/package.json +4 -5
- package/dist/chunks/ApproveApiKey-DfAPwDix.js +0 -1
- package/dist/chunks/BackgroundTasksDialog-Dvhcgahe.js +0 -2
- package/dist/chunks/ClaudeMdExternalIncludesDialog-BV7HHcgL.js +0 -1
- package/dist/chunks/ConsoleOAuthFlow-CU5fCPKq.js +0 -1
- package/dist/chunks/Doctor-B0CRtxi2.js +0 -1
- package/dist/chunks/Doctor-WxNv49HC.js +0 -3
- package/dist/chunks/ExitFlow-CRPgptCN.js +0 -2
- package/dist/chunks/Feedback-CEtzaLr3.js +0 -2
- package/dist/chunks/Grove-CelgLWH4.js +0 -1
- package/dist/chunks/MCPConnectionManager-BX0LMz9J.js +0 -1
- package/dist/chunks/MessageSelector-_UZB8cGb.js +0 -3
- package/dist/chunks/Messages-jCoW_1Rr.js +0 -11
- package/dist/chunks/PluginSettings-BD9JLV9-.js +0 -17
- package/dist/chunks/QueryEngine-D2HUnwmU.js +0 -1
- package/dist/chunks/REPL-DcpN3MRC.js +0 -1
- package/dist/chunks/RemoteSessionManager-Tx1N2uVL.js +0 -2
- package/dist/chunks/ResumeConversation-Cw3vP4G8.js +0 -1
- package/dist/chunks/SearchExtraToolsTool-D3VOFq9R.js +0 -1
- package/dist/chunks/Settings-ns6mRsDc.js +0 -2
- package/dist/chunks/TrustDialog-DA3YTk_k.js +0 -1
- package/dist/chunks/WelcomeV2-BTfttGcv.js +0 -1
- package/dist/chunks/ajv-5vMo9UcX.js +0 -8
- package/dist/chunks/api-L2IgleTV.js +0 -1
- package/dist/chunks/api-TgV7fl9V.js +0 -1
- package/dist/chunks/asciicast-DYbkzGCN.js +0 -1
- package/dist/chunks/assistant-YvbVKjVh.js +0 -1
- package/dist/chunks/auth-CEig4Gxp.js +0 -1
- package/dist/chunks/auth-CbGDlhyO.js +0 -1
- package/dist/chunks/auth-DHyCIxCk.js +0 -15
- package/dist/chunks/backgroundHousekeeping-BNEKWHhH.js +0 -1
- package/dist/chunks/bg-BzG63WOm.js +0 -1
- package/dist/chunks/bridgeConfig-D5dB38xD.js +0 -1
- package/dist/chunks/bridgeEnabled-DKX8-T_H.js +0 -1
- package/dist/chunks/bridgeMain--R1HFbOv.js +0 -68
- package/dist/chunks/bridgeMain-d06JByZn.js +0 -1
- package/dist/chunks/bridgeMessaging-CqbLTDcx.js +0 -1
- package/dist/chunks/bridgePointer-W_jdQ8zf.js +0 -1
- package/dist/chunks/caches-BuTIAOtY.js +0 -1
- package/dist/chunks/ccrClient-HqMi5Kfu.js +0 -1
- package/dist/chunks/client-BeET1hnC.js +0 -1
- package/dist/chunks/commands-VjcG4qFq.js +0 -1
- package/dist/chunks/commitAttribution-Lb3qUlAR.js +0 -1
- package/dist/chunks/compact-DPTVpJ4D.js +0 -2
- package/dist/chunks/completionCache-CW8lKIgy.js +0 -1
- package/dist/chunks/config-0cRberzR.js +0 -1
- package/dist/chunks/config-BrxKpHpR.js +0 -1
- package/dist/chunks/config-C7YHKCPV.js +0 -3
- package/dist/chunks/config-CLmFk-5V.js +0 -1
- package/dist/chunks/context-noninteractive-rUZ3ydmJ.js +0 -1
- package/dist/chunks/conversation-GJxfkr6M.js +0 -1
- package/dist/chunks/conversation-oK3aFzqO.js +0 -1
- package/dist/chunks/createSession-DM4acqaC.js +0 -1
- package/dist/chunks/crossProjectResume-DKrtjTpm.js +0 -40
- package/dist/chunks/cwd-D-tY2NKc.js +0 -1
- package/dist/chunks/datadog-ByS7LGGa.js +0 -1
- package/dist/chunks/datadog-DNCsyfSO.js +0 -1
- package/dist/chunks/debug-DzZUT2Wv.js +0 -1
- package/dist/chunks/detectRepository-6nw-Aw3v.js +0 -1
- package/dist/chunks/doctor-CTMHXZvQ.js +0 -1
- package/dist/chunks/entry-4lIRMrLI.js +0 -14
- package/dist/chunks/envLessBridgeConfig-CGuIxFzJ.js +0 -1
- package/dist/chunks/envLessBridgeConfig-D_Jg4fJy.js +0 -1
- package/dist/chunks/esm-C8Zkk1Ux.js +0 -1
- package/dist/chunks/execSyncWrapper-DZJ3tNWF.js +0 -1
- package/dist/chunks/exit-Z9oWrqE4.js +0 -1
- package/dist/chunks/extra-usage-BS4aVOt5.js +0 -1
- package/dist/chunks/extra-usage-DtAIhW74.js +0 -1
- package/dist/chunks/extractMemories-C4f9JWuI.js +0 -1
- package/dist/chunks/fast-B0OB4x7K.js +0 -1
- package/dist/chunks/firstPartyEventLogger-CdUpe6Lh.js +0 -1
- package/dist/chunks/firstPartyEventLogger-hU-LPkje.js +0 -5
- package/dist/chunks/gemini-DqAv8_GY.js +0 -1
- package/dist/chunks/generateRecap-lO2PDlx8.js +0 -1
- package/dist/chunks/git-BE_FiJZp.js +0 -1
- package/dist/chunks/git-tyaWOgRL.js +0 -6
- package/dist/chunks/hooks-DONAb_nq.js +0 -1
- package/dist/chunks/inboundAttachments-BcEgi49j.js +0 -1
- package/dist/chunks/inboundAttachments-DVs3_m48.js +0 -1
- package/dist/chunks/initReplBridge-D0Xec8S-.js +0 -1
- package/dist/chunks/install-BkfXeXpv.js +0 -1
- package/dist/chunks/jwtUtils-C-ojmb8W.js +0 -1
- package/dist/chunks/keybindings-ez51eHHp.js +0 -2
- package/dist/chunks/language-Da4KNbjm.js +0 -1
- package/dist/chunks/lazySchema-uxlVVNM1.js +0 -1
- package/dist/chunks/loadAgentsDir-Dgd-fzNt.js +0 -1
- package/dist/chunks/loadPluginHooks-z1-zvBLw.js +0 -1
- package/dist/chunks/localSearch-D-FprOMr.js +0 -1
- package/dist/chunks/main-y7LJ5qUc.js +0 -1243
- package/dist/chunks/mcp-CSFPAfaW.js +0 -2
- package/dist/chunks/mcp-DBwT4pa9.js +0 -6
- package/dist/chunks/mcp-DvZTaHZE.js +0 -1
- package/dist/chunks/metadata-BRLJvh61.js +0 -1
- package/dist/chunks/model--z4Di9QO.js +0 -1
- package/dist/chunks/model-DfFA3qMO.js +0 -1
- package/dist/chunks/nativeInstaller-GcIk7G2Y.js +0 -1
- package/dist/chunks/parser-BlM_Fk4J.js +0 -1
- package/dist/chunks/permissions-B8epy16o.js +0 -3
- package/dist/chunks/pidLock-CBJDnBG_.js +0 -3
- package/dist/chunks/pluginBlocklist-03sZaZa6.js +0 -1
- package/dist/chunks/pluginCliCommands-P2Ndi1r1.js +0 -1
- package/dist/chunks/pluginOperations-Cz37qcjF.js +0 -2
- package/dist/chunks/pluginStartupCheck-BqUwHcMD.js +0 -1
- package/dist/chunks/plugins-B0hiIN4q.js +0 -4
- package/dist/chunks/policyLimits-Dem-XJ_h.js +0 -1
- package/dist/chunks/pollConfig-C2Ac8WMU.js +0 -1
- package/dist/chunks/poorMode-jvImnkty.js +0 -1
- package/dist/chunks/print-ozjC0Mhg.js +0 -23
- package/dist/chunks/processBashCommand-loWZ8MSE.js +0 -1
- package/dist/chunks/processSlashCommand-BdouajZb.js +0 -5
- package/dist/chunks/prompt-Bef63FhB.js +0 -132
- package/dist/chunks/prompt-C7wd1H_i.js +0 -1
- package/dist/chunks/prompt-DIoNqZvO.js +0 -1
- package/dist/chunks/rcDebugLog-BUuD-X1D.js +0 -11
- package/dist/chunks/reconciler-DqXTmV3J.js +0 -4
- package/dist/chunks/refresh-CNzXPAFw.js +0 -1
- package/dist/chunks/remoteBridgeCore-D-wG5jau.js +0 -1
- package/dist/chunks/remoteManagedSettings-B7gt0VAX.js +0 -1
- package/dist/chunks/ripgrep-BQgJ02F9.js +0 -1
- package/dist/chunks/sandbox-adapter-Coe1GDAE.js +0 -1
- package/dist/chunks/searchExtraTools-BnWZ9roi.js +0 -1
- package/dist/chunks/sessionFileAccessHooks-BhdOmW9o.js +0 -1
- package/dist/chunks/sessionMemory-Bsg2unYX.js +0 -1
- package/dist/chunks/sessionMemory-CIbCojm-.js +0 -1
- package/dist/chunks/sessionMemoryUtils-Cjb57wtC.js +0 -1
- package/dist/chunks/sessionObserver-CRU1qWnP.js +0 -1
- package/dist/chunks/sessionStorage-BxDN8qRc.js +0 -1
- package/dist/chunks/sessionTitle-B8jcexkQ.js +0 -14
- package/dist/chunks/settings-5PQdphqC.js +0 -19
- package/dist/chunks/settingsSync-BDeuErb5.js +0 -1
- package/dist/chunks/setup-BKEnSLR9.js +0 -3
- package/dist/chunks/sink-DjKoYMsA.js +0 -1
- package/dist/chunks/sink-iYxWapbU.js +0 -1
- package/dist/chunks/sinks-GryGVRT8.js +0 -2
- package/dist/chunks/sinks-jfaIjsRJ.js +0 -1
- package/dist/chunks/skillChangeDetector-A8SAuyo9.js +0 -1
- package/dist/chunks/skillLearning-C8ihdryM.js +0 -1
- package/dist/chunks/src-xRRBgNzF.js +0 -25
- package/dist/chunks/startupProfiler-B0m6crkd.js +0 -1
- package/dist/chunks/state-53JDbNQM.js +0 -1
- package/dist/chunks/stdio-4S7b8Uhx.js +0 -1
- package/dist/chunks/stdio-W_Kokrkh.js +0 -3
- package/dist/chunks/systemPromptSections-IePG5K8r.js +0 -1
- package/dist/chunks/teleport-hN3cAbYC.js +0 -1
- package/dist/chunks/terminalSetup-C0PF87iu.js +0 -33
- package/dist/chunks/thinkback-BA4cMz4D.js +0 -1
- package/dist/chunks/thinkback-mT-8FIT-.js +0 -1
- package/dist/chunks/thinkback-play-Cfk49mvF.js +0 -1
- package/dist/chunks/toolPool-CHVDZqh7.js +0 -1
- package/dist/chunks/trustedDevice-BYCh1ff7.js +0 -1
- package/dist/chunks/trustedDevice-DnIWErCt.js +0 -1
- package/dist/chunks/udsClient-Cg9bBD0p.js +0 -1
- package/dist/chunks/undercover-B-kKUWtK.js +0 -1
- package/dist/chunks/updateCCB-CfUnkOLT.js +0 -11
- package/dist/chunks/upgrade-CngUwvY4.js +0 -1
- package/dist/chunks/upload-DDhQqV8n.js +0 -1
- package/dist/chunks/usage-eZRwLa77.js +0 -1
- package/dist/chunks/useMainLoopModel-BNFW-g8E.js +0 -1
- package/dist/chunks/useManagePlugins-CTtPaQRP.js +0 -1
- package/dist/chunks/validatePlugin-CRmpIGLV.js +0 -1
- package/dist/chunks/windowsPaths-D6T_3XaU.js +0 -1
- package/dist/chunks/windowsPaths-DUKTzBck.js +0 -1
- package/dist/chunks/worktree-YDeHMlHZ.js +0 -1
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-DaDcL9Zw.js";import{c as t,l as n,o as r,s as i}from"./envUtils-DSxRz_kt.js";import{n as a,t as o}from"./defineProperty-C-QyHrDq.js";import{M as s,P as c,Tn as l,Un as u,Wn as d,Z as f,en as p,ht as m,ir as h,kn as g,ln as _,tn as ee,vr as v}from"./state-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};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-DaDcL9Zw.js";import{I as t,fi as n,t as r}from"./src-CDCSSo0U2.js";import{t as i}from"./jsx-runtime-Bb4Xn-E0.js";import{Ap as a,Hp as o,Jg as s,Jm as c,So as l,Vp as u,Yg as d,Ym as f,Yo as p,_u as m,kp as h,oC as g,sC as _,vo as v,vu as y,xo as b,zo as x}from"./loadAgentsDir-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};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{en as t,ht as n,nr as r,t as i}from"./state-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};
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
import{n as e,o as t,r as n}from"./rolldown-runtime-DaDcL9Zw.js";import{c as r,l as i,o as a}from"./envUtils-DSxRz_kt.js";import{n as o,t as s}from"./defineProperty-C-QyHrDq.js";import{A as c,C as l,M as u,t as d,w as f}from"./v4-jw6qOKwQ.js";import{E as ee,I as te,O as ne,U as re}from"./debug-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};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e,r as t}from"./prompt-Bef63FhB.js";t();export{e as isDeferredTool};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{EE as e,bE as t}from"./loadAgentsDir-nzr38hai.js";e();export{t as clearPromptCache};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import{n as e,r as t}from"./rolldown-runtime-DaDcL9Zw.js";import{l as n,o as r}from"./envUtils-DSxRz_kt.js";import{en as i,gt as a,ht as o,sr as s,z as c}from"./state-4KQ3kaqz.js";import{U as l,_ as u,h as d,l as f,ot as p,p as m,st as h,z as g}from"./debug-IKW-jE7K.js";import{M as _,j as ee}from"./git-tyaWOgRL.js";import{Fr as te,Ir as ne,Nr as v,Pr as re}from"./model-DfFA3qMO.js";import{join as ie}from"node:path";import{appendFileSync as ae,existsSync as oe,mkdirSync as se}from"node:fs";import{homedir as ce}from"node:os";import{randomUUID as y}from"crypto";var le=e((()=>{})),ue,de=e((()=>{ue={input_tokens:0,cache_creation_input_tokens:0,cache_read_input_tokens:0,output_tokens:0,server_tool_use:{web_search_requests:0,web_fetch_requests:0},service_tier:`standard`,cache_creation:{ephemeral_1h_input_tokens:0,ephemeral_5m_input_tokens:0},inference_geo:``,iterations:[],speed:`standard`}})),fe=e((()=>{}));function pe(e){return e}var me=e((()=>{})),he=e((()=>{le(),de(),fe(),me()}));function ge(e){return/haiku/i.test(e)?`haiku`:/opus/i.test(e)?`opus`:/sonnet/i.test(e)?`sonnet`:null}function _e(e){if(process.env.OPENAI_MODEL)return process.env.OPENAI_MODEL;let t=e.replace(/\[1m\]$/,``),n=ge(t);if(n){let e=`OPENAI_DEFAULT_${n.toUpperCase()}_MODEL`,t=process.env[e];if(t)return t;let r=`ANTHROPIC_DEFAULT_${n.toUpperCase()}_MODEL`,i=process.env[r];if(i)return i}return ve[t]??t}var ve,ye=e((()=>{ve={"claude-sonnet-4-20250514":`gpt-4o`,"claude-sonnet-4-5-20250929":`gpt-4o`,"claude-sonnet-4-6":`gpt-4o`,"claude-opus-4-20250514":`o3`,"claude-opus-4-1-20250805":`o3`,"claude-opus-4-5-20251101":`o3`,"claude-opus-4-6":`o3`,"claude-haiku-4-5-20251001":`gpt-4o-mini`,"claude-3-5-haiku-20241022":`gpt-4o-mini`,"claude-3-7-sonnet-20250219":`gpt-4o`,"claude-3-5-sonnet-20241022":`gpt-4o`}}));function be(e){return/haiku/i.test(e)?`haiku`:/opus/i.test(e)?`opus`:/sonnet/i.test(e)?`sonnet`:null}function xe(){let e=process.env.GROK_MODEL_MAP;if(!e)return null;try{let t=JSON.parse(e);if(t&&typeof t==`object`&&!Array.isArray(t))return t}catch{}return null}function Se(e){if(process.env.GROK_MODEL)return process.env.GROK_MODEL;let t=e.replace(/\[1m\]$/,``),n=be(t),r=xe();if(r&&n&&r[n])return r[n];if(n){let e=`GROK_DEFAULT_${n.toUpperCase()}_MODEL`,t=process.env[e];if(t)return t;let r=`ANTHROPIC_DEFAULT_${n.toUpperCase()}_MODEL`,i=process.env[r];if(i)return i}return b[t]?b[t]:n&&x[n]?x[n]:t}var b,x,Ce=e((()=>{b={"claude-sonnet-4-20250514":`grok-3-mini-fast`,"claude-sonnet-4-5-20250929":`grok-3-mini-fast`,"claude-sonnet-4-6":`grok-3-mini-fast`,"claude-opus-4-20250514":`grok-4.20-reasoning`,"claude-opus-4-1-20250805":`grok-4.20-reasoning`,"claude-opus-4-5-20251101":`grok-4.20-reasoning`,"claude-opus-4-6":`grok-4.20-reasoning`,"claude-haiku-4-5-20251001":`grok-3-mini-fast`,"claude-3-5-haiku-20241022":`grok-3-mini-fast`,"claude-3-7-sonnet-20250219":`grok-3-mini-fast`,"claude-3-5-sonnet-20241022":`grok-3-mini-fast`},x={opus:`grok-4.20-reasoning`,sonnet:`grok-3-mini-fast`,haiku:`grok-3-mini-fast`}}));function we(e){return/haiku/i.test(e)?`haiku`:/opus/i.test(e)?`opus`:/sonnet/i.test(e)?`sonnet`:null}function Te(e){if(process.env.GEMINI_MODEL)return process.env.GEMINI_MODEL;let t=e.replace(/\[1m\]$/i,``),n=we(t);if(!n)return t;let r=`GEMINI_DEFAULT_${n.toUpperCase()}_MODEL`,i=process.env[r];if(i)return i;let a=`ANTHROPIC_DEFAULT_${n.toUpperCase()}_MODEL`,o=process.env[a];if(o)return o;throw Error(`Gemini provider requires GEMINI_MODEL or ${r} (or ${a} for backward compatibility) to be configured.`)}var Ee=e((()=>{})),De,Oe=e((()=>{De=`_geminiThoughtSignature`}));function S(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}function ke(e,t){let n=[],r=new Map;for(let t of e){if(t.type===`assistant`){let e=Ne(t);e.parts.length>0&&n.push(e);let i=t.message.content;if(Array.isArray(i))for(let e of i)typeof e!=`string`&&e.type===`tool_use`&&r.set(e.id,e.name);continue}if(t.type===`user`){let e=je(t,r);e.parts.length>0&&n.push(e)}}let i=Ae(t);return{contents:n,...i?{systemInstruction:{parts:[{text:i}]}}:{}}}function Ae(e){return!e||e.length===0?``:e.filter(Boolean).join(`
|
|
2
|
-
|
|
3
|
-
`)}function je(e,t){let n=e.message.content;return typeof n==`string`?{role:`user`,parts:C(n)}:Array.isArray(n)?{role:`user`,parts:n.flatMap(e=>Me(e,t))}:{role:`user`,parts:[]}}function Me(e,t){if(typeof e==`string`)return C(e);if(e.type===`text`)return C(e.text);if(e.type===`tool_result`){let n=e;return[{functionResponse:{name:t.get(n.tool_use_id)??n.tool_use_id,response:Ie(n)}}]}if(e.type===`image`){let t=e.source;if(t?.type===`base64`&&typeof t.data==`string`)return[{inlineData:{mimeType:t.media_type||`image/png`,data:t.data}}];if(t?.type===`url`&&typeof t.url==`string`)return C(`[image: ${t.url}]`)}return[]}function Ne(e){let t=e.message.content;if(typeof t==`string`)return{role:`model`,parts:C(t)};if(!Array.isArray(t))return{role:`model`,parts:[]};let n=[];for(let e of t){if(typeof e==`string`){n.push(...C(e));continue}if(e.type===`text`){n.push(...C(e.text,w(e)));continue}if(e.type===`thinking`){let t=Pe(e.thinking,e.signature);t&&n.push(t);continue}if(e.type===`tool_use`){let t=e;n.push({functionCall:{name:t.name,args:Fe(t.input)},...w(e)&&{thoughtSignature:w(e)}})}}return{role:`model`,parts:n}}function C(e,t){return typeof e!=`string`||e.length===0?[]:[{text:e,...t&&{thoughtSignature:t}}]}function Pe(e,t){if(!(typeof e!=`string`||e.length===0))return{text:e,thought:!0,...t&&{thoughtSignature:t}}}function Fe(e){if(typeof e==`string`){let t=S(e);return t&&typeof t==`object`&&!Array.isArray(t)?t:t===null?{}:{value:t}}return e&&typeof e==`object`&&!Array.isArray(e)?e:e===void 0?{}:{value:e}}function Ie(e){let t=Le(e.content);return t&&typeof t==`object`&&!Array.isArray(t)?e.is_error?{...t,is_error:!0}:t:{result:t,...e.is_error?{is_error:!0}:{}}}function Le(e){if(typeof e==`string`)return S(e)??e;if(Array.isArray(e)){let t=e.map(e=>typeof e==`string`?e:e&&typeof e==`object`&&`text`in e&&typeof e.text==`string`?e.text:``).filter(Boolean).join(`
|
|
4
|
-
`);return S(t)??t}return e??``}function w(e){let t=e[De];return typeof t==`string`&&t.length>0?t:void 0}var Re=e((()=>{Oe()}));function ze(e){if(typeof e==`string`)return E.has(e)?e:void 0;if(Array.isArray(e)){let t=e.filter(e=>typeof e==`string`&&E.has(e)),n=Array.from(new Set(t));return n.length===0?void 0:n.length===1?n[0]:n}}function Be(e){if(e===null)return`null`;if(Array.isArray(e))return`array`;if(typeof e==`string`)return`string`;if(typeof e==`boolean`)return`boolean`;if(typeof e==`number`)return Number.isInteger(e)?`integer`:`number`;if(typeof e==`object`)return`object`}function Ve(e){let t=e.map(Be).filter(e=>e!==void 0),n=Array.from(new Set(t));if(n.length!==0)return n.length===1?n[0]:n}function He(e){return e===void 0?[`null`]:Array.isArray(e)?e.includes(`null`)?e:[...e,`null`]:e===`null`?e:[e,`null`]}function Ue(e){if(!e||typeof e!=`object`||Array.isArray(e))return;let t=Object.entries(e).map(([e,t])=>[e,T(t)]).filter(([,e])=>Object.keys(e).length>0);if(t.length!==0)return Object.fromEntries(t)}function We(e){if(!Array.isArray(e))return;let t=e.map(e=>T(e)).filter(e=>Object.keys(e).length>0);return t.length>0?t:void 0}function T(e){if(!e||typeof e!=`object`||Array.isArray(e))return{};let t=e,n={},r=ze(t.type);t.const===void 0?Array.isArray(t.enum)&&t.enum.length>0&&(n.enum=t.enum,r=r??Ve(t.enum)):(n.enum=[t.const],r=r??Be(t.const)),r||(t.properties&&typeof t.properties==`object`?r=`object`:(t.items!==void 0||t.prefixItems!==void 0)&&(r=`array`)),t.nullable===!0&&(r=He(r)),r&&(n.type=r),typeof t.title==`string`&&(n.title=t.title),typeof t.description==`string`&&(n.description=t.description),typeof t.format==`string`&&(n.format=t.format),typeof t.pattern==`string`&&(n.pattern=t.pattern),typeof t.minimum==`number`?n.minimum=t.minimum:typeof t.exclusiveMinimum==`number`&&(n.minimum=t.exclusiveMinimum),typeof t.maximum==`number`?n.maximum=t.maximum:typeof t.exclusiveMaximum==`number`&&(n.maximum=t.exclusiveMaximum),typeof t.minItems==`number`&&(n.minItems=t.minItems),typeof t.maxItems==`number`&&(n.maxItems=t.maxItems),typeof t.minLength==`number`&&(n.minLength=t.minLength),typeof t.maxLength==`number`&&(n.maxLength=t.maxLength),typeof t.minProperties==`number`&&(n.minProperties=t.minProperties),typeof t.maxProperties==`number`&&(n.maxProperties=t.maxProperties);let i=Ue(t.properties);if(i&&(n.properties=i,n.propertyOrdering=Object.keys(i)),Array.isArray(t.required)){let e=t.required.filter(e=>typeof e==`string`);e.length>0&&(n.required=e)}if(typeof t.additionalProperties==`boolean`)n.additionalProperties=t.additionalProperties;else{let e=T(t.additionalProperties);Object.keys(e).length>0&&(n.additionalProperties=e)}let a=T(t.items);Object.keys(a).length>0&&(n.items=a);let o=We(t.prefixItems);o&&(n.prefixItems=o);let s=We(t.anyOf??t.oneOf);return s&&(n.anyOf=s),n}function Ge(e){let t=T(e);return Object.keys(t).length>0?t:{type:`object`,properties:{}}}function Ke(e){let t=e.filter(e=>{let t=e.type;return e.type===`custom`||!(`type`in e)||t!==`server`}).map(e=>{let t=e;return{name:t.name||``,description:t.description||``,parametersJsonSchema:Ge(t.input_schema??{type:`object`,properties:{}})}});return t.length>0?[{functionDeclarations:t}]:[]}function qe(e){if(!e||typeof e!=`object`)return;let t=e;switch(t.type){case`auto`:return{mode:`AUTO`};case`any`:return{mode:`ANY`};case`tool`:return{mode:`ANY`,allowedFunctionNames:typeof t.name==`string`?[t.name]:void 0};default:return}}var E,Je=e((()=>{E=new Set([`string`,`number`,`integer`,`boolean`,`object`,`array`,`null`])}));async function*Ye(e,t){let n=`msg_${y().replace(/-/g,``).slice(0,24)}`,r=!1,i=!1,a=0,o=null,s=!1,c,l=0,u=0,d=0;for await(let i of e){let e=i.usageMetadata;e&&(l=e.promptTokenCount??l,u=(e.candidatesTokenCount??0)+(e.thoughtsTokenCount??0),d=e.cachedContentTokenCount??d),r||(r=!0,yield{type:`message_start`,message:{id:n,type:`message`,role:`assistant`,content:[],model:t,stop_reason:null,stop_sequence:null,usage:{input_tokens:l,output_tokens:0,cache_creation_input_tokens:0,cache_read_input_tokens:d}}});let f=i.candidates?.[0],p=f?.content?.parts??[];for(let e of p){if(e.functionCall){o&&(yield{type:`content_block_stop`,index:o.index},o=null),s=!0;let t=a++;yield{type:`content_block_start`,index:t,content_block:{type:`tool_use`,id:`toolu_${y().replace(/-/g,``).slice(0,24)}`,name:e.functionCall.name||``,input:{}}},e.thoughtSignature&&(yield{type:`content_block_delta`,index:t,delta:{type:`signature_delta`,signature:e.thoughtSignature}}),e.functionCall.args&&Object.keys(e.functionCall.args).length>0&&(yield{type:`content_block_delta`,index:t,delta:{type:`input_json_delta`,partial_json:JSON.stringify(e.functionCall.args)}}),yield{type:`content_block_stop`,index:t};continue}let t=Xe(e);if(t){(!o||o.type!==t)&&(o&&(yield{type:`content_block_stop`,index:o.index}),o={index:a++,type:t},yield{type:`content_block_start`,index:o.index,content_block:t===`thinking`?{type:`thinking`,thinking:``,signature:``}:{type:`text`,text:``}}),e.text&&(yield{type:`content_block_delta`,index:o.index,delta:t===`thinking`?{type:`thinking_delta`,thinking:e.text}:{type:`text_delta`,text:e.text}}),e.thoughtSignature&&(yield{type:`content_block_delta`,index:o.index,delta:{type:`signature_delta`,signature:e.thoughtSignature}});continue}e.thoughtSignature&&o&&(yield{type:`content_block_delta`,index:o.index,delta:{type:`signature_delta`,signature:e.thoughtSignature}})}f?.finishReason&&(c=f.finishReason)}r&&(o&&(yield{type:`content_block_stop`,index:o.index}),i||(yield{type:`message_delta`,delta:{stop_reason:Ze(c,s),stop_sequence:null},usage:{input_tokens:l,output_tokens:u,cache_creation_input_tokens:0,cache_read_input_tokens:d}},yield{type:`message_stop`},i=!0))}function Xe(e){return typeof e.text==`string`?e.thought?`thinking`:`text`:null}function Ze(e,t){switch(e){case`MAX_TOKENS`:return`max_tokens`;default:return t?`tool_use`:`end_turn`}}var Qe=e((()=>{}));function D(e){if(!e||typeof e!=`object`)return null;let t=e,n=0;for(;t&&n<5;){if(t instanceof Error&&`code`in t&&typeof t.code==`string`){let e=t.code,n=it.has(e);return{code:e,message:t.message,isSSLError:n}}if(t instanceof Error&&`cause`in t&&t.cause!==t)t=t.cause,n++;else break}return null}function $e(e){let t=D(e);return t?.isSSLError?`SSL certificate error (${t.code}). If you are behind a corporate proxy or TLS-intercepting firewall, set NODE_EXTRA_CA_CERTS to your CA bundle path, or ask IT to allowlist *.anthropic.com. Run /doctor for details.`:null}function O(e){if(e.includes(`<!DOCTYPE html`)||e.includes(`<html`)){let t=e.match(/<title>([^<]+)<\/title>/);return t&&t[1]?t[1].trim():``}return e}function et(e){let t=e.message;return t?O(t):``}function tt(e){return typeof e==`object`&&!!e&&`error`in e&&typeof e.error==`object`&&e.error!==null}function nt(e){if(!tt(e))return null;let t=e.error,n=t?.error?.message;if(typeof n==`string`&&n.length>0){let e=O(n);if(e.length>0)return e}let r=t?.message;if(typeof r==`string`&&r.length>0){let e=O(r);if(e.length>0)return e}return null}function rt(e){let t=D(e);if(t){let{code:e,isSSLError:n}=t;if(e===`ETIMEDOUT`)return`Request timed out. Check your internet connection and proxy settings`;if(n)switch(e){case`UNABLE_TO_VERIFY_LEAF_SIGNATURE`:case`UNABLE_TO_GET_ISSUER_CERT`:case`UNABLE_TO_GET_ISSUER_CERT_LOCALLY`:return`Unable to connect to API: SSL certificate verification failed. Check your proxy or corporate SSL certificates`;case`CERT_HAS_EXPIRED`:return`Unable to connect to API: SSL certificate has expired`;case`CERT_REVOKED`:return`Unable to connect to API: SSL certificate has been revoked`;case`DEPTH_ZERO_SELF_SIGNED_CERT`:case`SELF_SIGNED_CERT_IN_CHAIN`:return`Unable to connect to API: Self-signed certificate detected. Check your proxy or corporate SSL certificates`;case`ERR_TLS_CERT_ALTNAME_INVALID`:case`HOSTNAME_MISMATCH`:return`Unable to connect to API: SSL certificate hostname mismatch`;case`CERT_NOT_YET_VALID`:return`Unable to connect to API: SSL certificate is not yet valid`;default:return`Unable to connect to API: SSL error (${e})`}}if(e.message===`Connection error.`)return t?.code?`Unable to connect to API (${t.code})`:`Unable to connect to API. Check your internet connection`;if(!e.message)return nt(e)??`API error (status ${e.status??`unknown`})`;let n=et(e);return n!==e.message&&n.length>0?n:e.message}var it,at=e((()=>{it=new Set([`UNABLE_TO_VERIFY_LEAF_SIGNATURE`,`UNABLE_TO_GET_ISSUER_CERT`,`UNABLE_TO_GET_ISSUER_CERT_LOCALLY`,`CERT_SIGNATURE_FAILURE`,`CERT_NOT_YET_VALID`,`CERT_HAS_EXPIRED`,`CERT_REVOKED`,`CERT_REJECTED`,`CERT_UNTRUSTED`,`DEPTH_ZERO_SELF_SIGNED_CERT`,`SELF_SIGNED_CERT_IN_CHAIN`,`CERT_CHAIN_TOO_LONG`,`PATH_LENGTH_EXCEEDED`,`ERR_TLS_CERT_ALTNAME_INVALID`,`HOSTNAME_MISMATCH`,`ERR_TLS_HANDSHAKE_TIMEOUT`,`ERR_SSL_WRONG_VERSION_NUMBER`,`ERR_SSL_DECRYPTION_FAILED_OR_BAD_RECORD_MAC`])}));function ot(e,t,n){let r=[],i=st(t);i&&r.push({role:`system`,content:i});for(let t of e)switch(t.type){case`user`:r.push(...ct(t));break;case`assistant`:r.push(...ut(t));break;default:break}return r}function st(e){return!e||e.length===0?``:e.filter(Boolean).join(`
|
|
5
|
-
|
|
6
|
-
`)}function ct(e){let t=[],n=e.message.content;if(typeof n==`string`)t.push({role:`user`,content:n});else if(Array.isArray(n)){let e=[],r=[],i=[];for(let t of n)if(typeof t==`string`)e.push(t);else if(t.type===`text`)e.push(t.text);else if(t.type===`tool_result`)r.push(t);else if(t.type===`image`){let e=dt(t);e&&i.push(e)}for(let e of r)t.push(lt(e));if(i.length>0){let n=[];e.length>0&&n.push({type:`text`,text:e.join(`
|
|
7
|
-
`)}),n.push(...i),t.push({role:`user`,content:n})}else e.length>0&&t.push({role:`user`,content:e.join(`
|
|
8
|
-
`)})}return t}function lt(e){let t;return t=typeof e.content==`string`?e.content:Array.isArray(e.content)?e.content.map(e=>typeof e==`string`?e:`text`in e?e.text:``).filter(Boolean).join(`
|
|
9
|
-
`):``,{role:`tool`,tool_call_id:e.tool_use_id,content:t}}function ut(e){let t=e.message.content;if(typeof t==`string`)return[{role:`assistant`,content:t}];if(!Array.isArray(t))return[{role:`assistant`,content:``}];let n=[],r=[],i=[];for(let e of t)if(typeof e==`string`)n.push(e);else if(e.type===`text`)n.push(e.text);else if(e.type===`tool_use`){let t=e;r.push({id:t.id,type:`function`,function:{name:t.name,arguments:typeof t.input==`string`?t.input:JSON.stringify(t.input)}})}else if(e.type===`thinking`){let t=e.thinking;typeof t==`string`&&i.push(t)}return[{role:`assistant`,content:n.length>0?n.join(`
|
|
10
|
-
`):null,...r.length>0&&{tool_calls:r},...i.length>0&&{reasoning_content:i.join(`
|
|
11
|
-
`)}}]}function dt(e){let t=e.source;return t?t.type===`base64`&&typeof t.data==`string`?{type:`image_url`,image_url:{url:`data:${t.media_type||`image/png`};base64,${t.data}`}}:t.type===`url`&&typeof t.url==`string`?{type:`image_url`,image_url:{url:t.url}}:null:null}var ft=e((()=>{}));function pt(e){return e.filter(e=>{let t=e.type;return e.type===`custom`||!(`type`in e)||t!==`server`}).map(e=>{let t=e,n=t.name||``,r=t.description||``,i=t.input_schema;return{type:`function`,function:{name:n,description:r,parameters:k(i||{type:`object`,properties:{}})}}})}function k(e){if(!e||typeof e!=`object`)return e;let t={...e};`const`in t&&(t.enum=[t.const],delete t.const);for(let e of[`properties`,`definitions`,`$defs`,`patternProperties`]){let n=t[e];if(n&&typeof n==`object`){let r={};for(let[e,t]of Object.entries(n))r[e]=t&&typeof t==`object`?k(t):t;t[e]=r}}for(let e of[`items`,`additionalProperties`,`not`,`if`,`then`,`else`,`contains`,`propertyNames`]){let n=t[e];n&&typeof n==`object`&&!Array.isArray(n)&&(t[e]=k(n))}for(let e of[`anyOf`,`oneOf`,`allOf`]){let n=t[e];Array.isArray(n)&&(t[e]=n.map(e=>e&&typeof e==`object`?k(e):e))}return t}function mt(e){if(!e||typeof e!=`object`)return;let t=e;switch(t.type){case`auto`:return`auto`;case`any`:return`required`;case`tool`:return{type:`function`,function:{name:t.name}};default:return}}var ht=e((()=>{}));async function*gt(e,t){let n=`msg_${y().replace(/-/g,``).slice(0,24)}`,r=!1,i=-1,a=new Map,o=!1,s=!1,c=0,l=0,u=0,d=0,f=new Set,p=null,m=!1;for await(let h of e){let e=h.choices?.[0],g=e?.delta;if(h.usage){c=h.usage.prompt_tokens??c;let e=h.usage.prompt_tokens_details?.cached_tokens??d;l=Math.max(0,c-e),u=h.usage.completion_tokens??u,d=e}if(r||(r=!0,yield{type:`message_start`,message:{id:n,type:`message`,role:`assistant`,content:[],model:t,stop_reason:null,stop_sequence:null,usage:{input_tokens:l,output_tokens:0,cache_creation_input_tokens:0,cache_read_input_tokens:d}}}),!g)continue;let _=g.reasoning_content;if(_!=null&&(o||(i++,o=!0,f.add(i),yield{type:`content_block_start`,index:i,content_block:{type:`thinking`,thinking:``,signature:``}}),_!==``&&(yield{type:`content_block_delta`,index:i,delta:{type:`thinking_delta`,thinking:_}})),g.content!=null&&g.content!==``&&(s||(o&&(yield{type:`content_block_stop`,index:i},f.delete(i),o=!1),i++,s=!0,f.add(i),yield{type:`content_block_start`,index:i,content_block:{type:`text`,text:``}}),yield{type:`content_block_delta`,index:i,delta:{type:`text_delta`,text:g.content}}),g.tool_calls)for(let e of g.tool_calls){let t=e.index;if(!a.has(t)){o&&(yield{type:`content_block_stop`,index:i},f.delete(i),o=!1),s&&(yield{type:`content_block_stop`,index:i},f.delete(i),s=!1),i++;let n=e.id||`toolu_${y().replace(/-/g,``).slice(0,24)}`,r=e.function?.name||``;a.set(t,{contentIndex:i,id:n,name:r,arguments:``}),f.add(i),yield{type:`content_block_start`,index:i,content_block:{type:`tool_use`,id:n,name:r,input:{}}}}let n=e.function?.arguments;n&&(a.get(t).arguments+=n,yield{type:`content_block_delta`,index:a.get(t).contentIndex,delta:{type:`input_json_delta`,partial_json:n}})}if(e?.finish_reason){o&&(yield{type:`content_block_stop`,index:i},f.delete(i),o=!1),s&&(yield{type:`content_block_stop`,index:i},f.delete(i),s=!1);for(let[,e]of a)f.has(e.contentIndex)&&(yield{type:`content_block_stop`,index:e.contentIndex},f.delete(e.contentIndex));p=e.finish_reason,m=a.size>0}}for(let e of f)yield{type:`content_block_stop`,index:e};p!==null&&(yield{type:`message_delta`,delta:{stop_reason:p===`length`?`max_tokens`:m?`tool_use`:_t(p),stop_sequence:null},usage:{input_tokens:l,output_tokens:u,cache_read_input_tokens:d,cache_creation_input_tokens:0}},yield{type:`message_stop`})}function _t(e){switch(e){case`stop`:return`end_turn`;case`tool_calls`:return`tool_use`;case`length`:return`max_tokens`;case`content_filter`:return`end_turn`;default:return`end_turn`}}var vt=e((()=>{})),yt=e((()=>{he(),ye(),Ce(),Ee(),Re(),Je(),Qe(),Oe(),at(),ft(),ht(),vt()}));function A(e){c()&&(j.length>=St&&j.shift(),j.push(e))}function bt(){return j.length===0?[]:j.splice(0).map(e=>({...e,uuid:y(),session_id:o()}))}function xt(e,t,n){A({type:`system`,subtype:`task_notification`,task_id:e,tool_use_id:n?.toolUseId,status:t,output_file:n?.outputFile??``,summary:n?.summary??``,usage:n?.usage})}var St,j,Ct=e((()=>{i(),St=1e3,j=[]}));function wt(){let e=a();if(e!==void 0)return e;let t=process.env.CLAUDE_CODE_WEBSOCKET_AUTH_FILE_DESCRIPTOR;if(!t){let e=ne(process.env.CLAUDE_SESSION_INGRESS_TOKEN_FILE??v,`session ingress token`);return s(e),e}let n=parseInt(t,10);if(Number.isNaN(n))return m(`CLAUDE_CODE_WEBSOCKET_AUTH_FILE_DESCRIPTOR must be a valid file descriptor number, got: ${t}`,{level:`error`}),s(null),null;try{let e=d(),t=process.platform===`darwin`||process.platform===`freebsd`?`/dev/fd/${n}`:`/proc/self/fd/${n}`,r=e.readFileSync(t,{encoding:`utf8`}).trim();return r?(m(`Successfully read token from file descriptor ${n}`),s(r),te(v,r,`session ingress token`),r):(m(`File descriptor contained empty token`,{level:`error`}),s(null),null)}catch(e){m(`Failed to read token from file descriptor ${n}: ${g(e)}`,{level:`error`});let t=ne(process.env.CLAUDE_SESSION_INGRESS_TOKEN_FILE??v,`session ingress token`);return s(t),t}}function Tt(){return process.env.CLAUDE_CODE_SESSION_ACCESS_TOKEN||wt()}function Et(){let e=Tt();if(!e)return{};if(e.startsWith(`sk-ant-sid`)){let t={Cookie:`sessionKey=${e}`},n=process.env.CLAUDE_CODE_ORGANIZATION_UUID;return n&&(t[`X-Organization-Uuid`]=n),t}return{Authorization:`Bearer ${e}`}}function Dt(e){process.env.CLAUDE_CODE_SESSION_ACCESS_TOKEN=e}var Ot=e((()=>{i(),re(),f(),l(),u()})),kt=t({activateProactive:()=>At,deactivateProactive:()=>jt,getActivationSource:()=>zt,getNextTickAt:()=>Rt,isContextBlocked:()=>It,isProactiveActive:()=>N,isProactivePaused:()=>Mt,pauseProactive:()=>Nt,resumeProactive:()=>Pt,setContextBlocked:()=>Ft,setNextTickAt:()=>Lt,shouldTick:()=>Vt,subscribeToProactiveChanges:()=>Bt});function M(){for(let e of z)try{e()}catch{}}function N(){return P}function At(e){P||(P=!0,F=!1,I=!1,R=e,M())}function jt(){P&&(P=!1,F=!1,I=!1,L=null,R=void 0,M())}function Mt(){return F}function Nt(){!P||F||(F=!0,L=null,M())}function Pt(){!P||!F||(F=!1,M())}function Ft(e){I!==e&&(I=e,e&&(L=null),M())}function It(){return I}function Lt(e){L=e,M()}function Rt(){return!P||F||I?null:L}function zt(){return R}function Bt(e){return z.add(e),()=>{z.delete(e)}}function Vt(){return P&&!F&&!I}var P,F,I,L,R,z,Ht=e((()=>{P=!1,F=!1,I=!1,L=null,z=new Set}));function Ut(e){V=e}function Wt(e,t){if(H=e,!e||!t?.replayCurrent)return;let n=Yt();Object.keys(n).length!==0&&e(n)}function Gt(e){U=e}function Kt(e){return!e||e.enabled!==!0?null:{enabled:!0,phase:e.phase===`standby`||e.phase===`sleeping`?e.phase:null,next_tick_at:typeof e.next_tick_at==`number`?e.next_tick_at:null,sleep_until:typeof e.sleep_until==`number`?e.sleep_until:null}}function qt(e){return JSON.stringify(e)}function Jt(e){let t={...K};for(let n of Object.keys(e)){let r=e[n];if(r===void 0){delete t[n];continue}t[n]=r}K=t}function Yt(){let e={...K};return G?e.automation_state={...G}:`automation_state`in K&&(e.automation_state=K.automation_state??null),e}function Xt(){return en}function Zt(e,t){en=e,V?.(e,t),e===`requires_action`&&t?(W=!0,B({pending_action:t})):W&&(W=!1,B({pending_action:null})),e===`idle`&&B({task_summary:null}),e!==`idle`&&Qt(N()?{enabled:!0,phase:null,next_tick_at:null,sleep_until:null}:null),n(process.env.CLAUDE_CODE_EMIT_SESSION_STATE_EVENTS)&&A({type:`system`,subtype:`session_state_changed`,state:e})}function B(e){Jt(e),H?.(e)}function Qt(e){let t=Kt(e);qt(t)!==qt(G)&&(G=t,Jt({automation_state:t}),H?.({automation_state:t}))}function $t(e){U?.(e)}var V,H,U,W,en,G,K,tn=e((()=>{Ht(),r(),Ct(),V=null,H=null,U=null,W=!1,en=`idle`,G=null,K={}}));function nn(){an(),Z=setInterval(()=>{_(`debug`,`session_keepalive_heartbeat`,{refcount:J}),n(process.env.CLAUDE_CODE_REMOTE_SEND_KEEPALIVES)&&q?.()},fn)}function rn(){an(),q!==null&&(Q=setTimeout(()=>{_(`info`,`session_idle_30s`),Q=null},fn))}function an(){Q!==null&&(clearTimeout(Q),Q=null)}function on(e){q=e,J>0&&Z===null&&nn()}function sn(){q=null,Z!==null&&(clearInterval(Z),Z=null),an()}function cn(){n(process.env.CLAUDE_CODE_REMOTE_SEND_KEEPALIVES)&&q?.()}function ln(){return q!==null}function un(e){J++,Y.set(e,(Y.get(e)??0)+1),J===1&&(X=Date.now(),q!==null&&Z===null&&nn()),pn||(pn=!0,h(async()=>{_(`info`,`session_activity_at_shutdown`,{refcount:J,active:Object.fromEntries(Y),oldest_activity_ms:J>0&&X!==null?Date.now()-X:null})}))}function dn(e){J>0&&J--;let t=(Y.get(e)??0)-1;t>0?Y.set(e,t):Y.delete(e),J===0&&Z!==null&&(clearInterval(Z),Z=null,rn())}var fn,q,J,Y,X,Z,Q,pn,mn=e((()=>{p(),ee(),r(),fn=3e4,q=null,J=0,Y=new Map,X=null,Z=null,Q=null,pn=!1}));function hn(){let e=ie(ce(),`.claude`);oe(e)||se(e,{recursive:!0})}function gn(e){try{$||(hn(),ae(_n,`\n===== RC-DEBUG session ${new Date().toISOString()} =====\n`),$=!0);let t=new Date().toISOString().slice(11,23);ae(_n,`[${t}] ${e}\n`)}catch{}}var _n,$,vn=e((()=>{_n=ie(ce(),`.claude`,`rc-debug.log`),$=!1}));export{De as $,bt as A,ot as B,kt as C,Tt as D,Et as E,gt as F,at as G,D as H,vt as I,qe as J,Ye as K,mt as L,A as M,Ct as N,Ot as O,yt as P,Re as Q,pt as R,Mt as S,Vt as T,rt as U,ft as V,$e as W,Je as X,Ke as Y,ke as Z,Wt as _,on as a,ye as at,It as b,dn as c,me as ct,tn as d,Oe as et,Qt as f,Gt as g,Zt as h,ln as i,Se as it,xt as j,Dt as k,sn as l,ue as lt,B as m,gn as n,Te as nt,cn as o,_e as ot,$t as p,Qe as q,mn as r,Ce as rt,un as s,pe as st,vn as t,Ee as tt,Xt as u,de as ut,Ut as v,Lt as w,N as x,Ht as y,ht as z};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{n as e,t}from"./defineProperty-C-QyHrDq.js";import{A as n,C as r,M as i,O as a,b as o,f as s,g as c,j as l,l as u,m as d,n as f,p,t as m,u as ee,w as h,y as g}from"./v4-jw6qOKwQ.js";import{en as te,nt as ne}from"./state-4KQ3kaqz.js";import{BC as _,Dn as re,En as ie,Fs as ae,G as oe,Gt as se,HC as v,Hs as ce,LC as y,Ls as le,On as ue,Tn as de,Vs as fe,W as pe,du as me,fu as he,gw as ge,hw as _e,mT as ve,pT as ye,yn as be}from"./loadAgentsDir-nzr38hai.js";import{D as xe,E as b,O as x,U as S,j as Se,l as C,p as w,z as Ce}from"./debug-IKW-jE7K.js";import{Ct as we,St as Te}from"./settings-5PQdphqC.js";import{n as Ee,o as De}from"./process-gEbdy6uY.js";import{M as Oe,_ as ke,j as Ae,n as je}from"./git-tyaWOgRL.js";import{o as Me,s as T}from"./log-B3eB4EFv.js";import{_ as Ne,f as Pe}from"./file-D1cN3LMK.js";import{n as E,t as D}from"./lazySchema-uxlVVNM1.js";import{dr as Fe,fr as Ie}from"./model-DfFA3qMO.js";import{d as Le,h as Re}from"./rcDebugLog-BUuD-X1D.js";import{t as ze}from"./controlMessageCompat-IFu4Gc1y.js";import{isAbsolute as Be,resolve as Ve}from"path";import{randomUUID as O}from"crypto";m(),D();var k=E(()=>h({inputTokens:r(),outputTokens:r(),cacheReadInputTokens:r(),cacheCreationInputTokens:r(),webSearchRequests:r(),costUSD:r(),contextWindow:r(),maxOutputTokens:r()})),He=E(()=>o(`json_schema`));E(()=>h({type:He()}));var Ue=E(()=>h({type:o(`json_schema`),schema:a(n(),i())}));E(()=>Ue());var We=E(()=>u([`user`,`project`,`org`,`temporary`,`oauth`]));E(()=>u([`local`,`user`,`project`]).describe(`Config scope for settings.`)),E(()=>o(`context-1m-2025-08-07`));var Ge=E(()=>h({type:o(`adaptive`)}).describe(`Claude decides when and how much to think (Opus 4.6+).`)),Ke=E(()=>h({type:o(`enabled`),budgetTokens:r().optional()}).describe(`Fixed thinking token budget (older models)`)),qe=E(()=>h({type:o(`disabled`)}).describe(`No extended thinking`));E(()=>l([Ge(),Ke(),qe()]).describe(`Controls Claude's thinking/reasoning behavior. When set, takes precedence over the deprecated maxThinkingTokens.`));var Je=E(()=>h({type:o(`stdio`).optional(),command:n(),args:p(n()).optional(),env:a(n(),n()).optional()})),Ye=E(()=>h({type:o(`sse`),url:n(),headers:a(n(),n()).optional()})),Xe=E(()=>h({type:o(`http`),url:n(),headers:a(n(),n()).optional()})),Ze=E(()=>h({type:o(`sdk`),name:n()})),A=E(()=>l([Je(),Ye(),Xe(),Ze()])),Qe=E(()=>h({type:o(`claudeai-proxy`),url:n(),id:n()})),$e=E(()=>l([A(),Qe()])),j=E(()=>h({name:n().describe(`Server name as configured`),status:u([`connected`,`failed`,`needs-auth`,`pending`,`disabled`]).describe(`Current connection status`),serverInfo:h({name:n(),version:n()}).optional().describe(`Server information (available when connected)`),error:n().optional().describe(`Error message (available when status is 'failed')`),config:$e().optional().describe(`Server configuration (includes URL for HTTP/SSE servers)`),scope:n().optional().describe(`Configuration scope (e.g., project, user, local, claudeai, managed)`),tools:p(h({name:n(),description:n().optional(),annotations:h({readOnly:d().optional(),destructive:d().optional(),openWorld:d().optional()}).optional()})).optional().describe(`Tools provided by this server (available when connected)`),capabilities:h({experimental:a(n(),i()).optional()}).optional().describe(`@internal Server capabilities (available when connected). experimental['claude/channel'] is only present if the server's plugin is on the approved channels allowlist — use its presence to decide whether to show an Enable-channel prompt.`)}).describe(`Status information for an MCP server connection.`));E(()=>h({added:p(n()).describe(`Names of servers that were added`),removed:p(n()).describe(`Names of servers that were removed`),errors:a(n(),n()).describe(`Map of server names to error messages for servers that failed to connect`)}).describe(`Result of a setMcpServers operation.`));var M=E(()=>u([`userSettings`,`projectSettings`,`localSettings`,`session`,`cliArg`])),N=E(()=>u([`allow`,`deny`,`ask`])),P=E(()=>h({toolName:n(),ruleContent:n().optional()})),F=E(()=>c(`type`,[h({type:o(`addRules`),rules:p(P()),behavior:N(),destination:M()}),h({type:o(`replaceRules`),rules:p(P()),behavior:N(),destination:M()}),h({type:o(`removeRules`),rules:p(P()),behavior:N(),destination:M()}),h({type:o(`setMode`),mode:g(()=>L()),destination:M()}),h({type:o(`addDirectories`),directories:p(n()),destination:M()}),h({type:o(`removeDirectories`),directories:p(n()),destination:M()})])),I=E(()=>u([`user_temporary`,`user_permanent`,`user_reject`]).describe(`Classification of this permission decision for telemetry. SDK hosts that prompt users (desktop apps, IDEs) should set this to reflect what actually happened: user_temporary for allow-once, user_permanent for always-allow (both the click and later cache hits), user_reject for deny. If unset, the CLI infers conservatively (temporary for allow, reject for deny). The vocabulary matches tool_decision OTel events (monitoring-usage docs).`));E(()=>l([h({behavior:o(`allow`),updatedInput:a(n(),i()).optional(),updatedPermissions:p(F()).optional(),toolUseID:n().optional(),decisionClassification:I().optional()}),h({behavior:o(`deny`),message:n(),interrupt:d().optional(),toolUseID:n().optional(),decisionClassification:I().optional()})]));var L=E(()=>u([`default`,`acceptEdits`,`bypassPermissions`,`plan`,`dontAsk`,`auto`]).describe(`Permission mode for controlling how tool executions are handled. 'default' - Standard behavior, prompts for dangerous operations. 'acceptEdits' - Auto-accept file edit operations. 'bypassPermissions' - Bypass all permission checks (requires allowDangerouslySkipPermissions). 'plan' - Planning mode, no actual tool execution. 'dontAsk' - Don't prompt for permissions, deny if not pre-approved. 'auto' - Automatic mode (transcript classifier).`)),et=`PreToolUse.PostToolUse.PostToolUseFailure.Notification.UserPromptSubmit.SessionStart.SessionEnd.Stop.StopFailure.SubagentStart.SubagentStop.PreCompact.PostCompact.PermissionRequest.PermissionDenied.Setup.TeammateIdle.TaskCreated.TaskCompleted.Elicitation.ElicitationResult.ConfigChange.WorktreeCreate.WorktreeRemove.InstructionsLoaded.CwdChanged.FileChanged`.split(`.`),tt=E(()=>u(et)),R=E(()=>h({session_id:n(),transcript_path:n(),cwd:n(),permission_mode:n().optional(),agent_id:n().optional().describe(`Subagent identifier. Present only when the hook fires from within a subagent (e.g., a tool called by an AgentTool worker). Absent for the main thread, even in --agent sessions. Use this field (not agent_type) to distinguish subagent calls from main-thread calls.`),agent_type:n().optional().describe(`Agent type name (e.g., "general-purpose", "code-reviewer"). Present when the hook fires from within a subagent (alongside agent_id), or on the main thread of a session started with --agent (without agent_id).`)})),nt=E(()=>R().and(h({hook_event_name:o(`PreToolUse`),tool_name:n(),tool_input:i(),tool_use_id:n()}))),rt=E(()=>R().and(h({hook_event_name:o(`PermissionRequest`),tool_name:n(),tool_input:i(),permission_suggestions:p(F()).optional()}))),it=E(()=>R().and(h({hook_event_name:o(`PostToolUse`),tool_name:n(),tool_input:i(),tool_response:i(),tool_use_id:n()}))),at=E(()=>R().and(h({hook_event_name:o(`PostToolUseFailure`),tool_name:n(),tool_input:i(),tool_use_id:n(),error:n(),is_interrupt:d().optional()}))),ot=E(()=>R().and(h({hook_event_name:o(`PermissionDenied`),tool_name:n(),tool_input:i(),tool_use_id:n(),reason:n()}))),st=E(()=>R().and(h({hook_event_name:o(`Notification`),message:n(),title:n().optional(),notification_type:n()}))),ct=E(()=>R().and(h({hook_event_name:o(`UserPromptSubmit`),prompt:n()}))),lt=E(()=>R().and(h({hook_event_name:o(`SessionStart`),source:u([`startup`,`resume`,`clear`,`compact`]),agent_type:n().optional(),model:n().optional()}))),ut=E(()=>R().and(h({hook_event_name:o(`Setup`),trigger:u([`init`,`maintenance`])}))),dt=E(()=>R().and(h({hook_event_name:o(`Stop`),stop_hook_active:d(),last_assistant_message:n().optional().describe(`Text content of the last assistant message before stopping. Avoids the need to read and parse the transcript file.`)}))),ft=E(()=>R().and(h({hook_event_name:o(`StopFailure`),error:U(),error_details:n().optional(),last_assistant_message:n().optional()}))),pt=E(()=>R().and(h({hook_event_name:o(`SubagentStart`),agent_id:n(),agent_type:n()}))),mt=E(()=>R().and(h({hook_event_name:o(`SubagentStop`),stop_hook_active:d(),agent_id:n(),agent_transcript_path:n(),agent_type:n(),last_assistant_message:n().optional().describe(`Text content of the last assistant message before stopping. Avoids the need to read and parse the transcript file.`)}))),ht=E(()=>R().and(h({hook_event_name:o(`PreCompact`),trigger:u([`manual`,`auto`]),custom_instructions:n().nullable()}))),gt=E(()=>R().and(h({hook_event_name:o(`PostCompact`),trigger:u([`manual`,`auto`]),compact_summary:n().describe(`The conversation summary produced by compaction`)}))),_t=E(()=>R().and(h({hook_event_name:o(`TeammateIdle`),teammate_name:n(),team_name:n()}))),vt=E(()=>R().and(h({hook_event_name:o(`TaskCreated`),task_id:n(),task_subject:n(),task_description:n().optional(),teammate_name:n().optional(),team_name:n().optional()}))),yt=E(()=>R().and(h({hook_event_name:o(`TaskCompleted`),task_id:n(),task_subject:n(),task_description:n().optional(),teammate_name:n().optional(),team_name:n().optional()}))),bt=E(()=>R().and(h({hook_event_name:o(`Elicitation`),mcp_server_name:n(),message:n(),mode:u([`form`,`url`]).optional(),url:n().optional(),elicitation_id:n().optional(),requested_schema:a(n(),i()).optional()})).describe(`Hook input for the Elicitation event. Fired when an MCP server requests user input. Hooks can auto-respond (accept/decline) instead of showing the dialog.`)),xt=E(()=>R().and(h({hook_event_name:o(`ElicitationResult`),mcp_server_name:n(),elicitation_id:n().optional(),mode:u([`form`,`url`]).optional(),action:u([`accept`,`decline`,`cancel`]),content:a(n(),i()).optional()})).describe(`Hook input for the ElicitationResult event. Fired after the user responds to an MCP elicitation. Hooks can observe or override the response before it is sent to the server.`)),St=[`user_settings`,`project_settings`,`local_settings`,`policy_settings`,`skills`],Ct=E(()=>R().and(h({hook_event_name:o(`ConfigChange`),source:u(St),file_path:n().optional()}))),wt=[`session_start`,`nested_traversal`,`path_glob_match`,`include`,`compact`],Tt=[`User`,`Project`,`Local`,`Managed`],Et=E(()=>R().and(h({hook_event_name:o(`InstructionsLoaded`),file_path:n(),memory_type:u(Tt),load_reason:u(wt),globs:p(n()).optional(),trigger_file_path:n().optional(),parent_file_path:n().optional()}))),Dt=E(()=>R().and(h({hook_event_name:o(`WorktreeCreate`),name:n()}))),Ot=E(()=>R().and(h({hook_event_name:o(`WorktreeRemove`),worktree_path:n()}))),kt=E(()=>R().and(h({hook_event_name:o(`CwdChanged`),old_cwd:n(),new_cwd:n()}))),At=E(()=>R().and(h({hook_event_name:o(`FileChanged`),file_path:n(),event:u([`change`,`add`,`unlink`])}))),jt=[`clear`,`resume`,`logout`,`prompt_input_exit`,`other`,`bypass_permissions_disabled`],Mt=E(()=>u(jt)),Nt=E(()=>R().and(h({hook_event_name:o(`SessionEnd`),reason:Mt()}))),Pt=E(()=>l([nt(),it(),at(),ot(),st(),ct(),lt(),Nt(),dt(),ft(),pt(),mt(),ht(),gt(),rt(),ut(),_t(),vt(),yt(),bt(),xt(),Ct(),Et(),Dt(),Ot(),kt(),At()])),Ft=E(()=>h({async:o(!0),asyncTimeout:r().optional()})),It=E(()=>h({hookEventName:o(`PreToolUse`),permissionDecision:N().optional(),permissionDecisionReason:n().optional(),updatedInput:a(n(),i()).optional(),additionalContext:n().optional()})),Lt=E(()=>h({hookEventName:o(`UserPromptSubmit`),additionalContext:n().optional()})),Rt=E(()=>h({hookEventName:o(`SessionStart`),additionalContext:n().optional(),initialUserMessage:n().optional(),watchPaths:p(n()).optional()})),zt=E(()=>h({hookEventName:o(`Setup`),additionalContext:n().optional()})),Bt=E(()=>h({hookEventName:o(`SubagentStart`),additionalContext:n().optional()})),Vt=E(()=>h({hookEventName:o(`PostToolUse`),additionalContext:n().optional(),updatedMCPToolOutput:i().optional()})),Ht=E(()=>h({hookEventName:o(`PostToolUseFailure`),additionalContext:n().optional()})),Ut=E(()=>h({hookEventName:o(`PermissionDenied`),retry:d().optional()})),Wt=E(()=>h({hookEventName:o(`Notification`),additionalContext:n().optional()})),Gt=E(()=>h({hookEventName:o(`PermissionRequest`),decision:l([h({behavior:o(`allow`),updatedInput:a(n(),i()).optional(),updatedPermissions:p(F()).optional()}),h({behavior:o(`deny`),message:n().optional(),interrupt:d().optional()})])})),Kt=E(()=>h({hookEventName:o(`CwdChanged`),watchPaths:p(n()).optional()})),qt=E(()=>h({hookEventName:o(`FileChanged`),watchPaths:p(n()).optional()})),Jt=E(()=>h({continue:d().optional(),suppressOutput:d().optional(),stopReason:n().optional(),decision:u([`approve`,`block`]).optional(),systemMessage:n().optional(),reason:n().optional(),hookSpecificOutput:l([It(),Lt(),Rt(),zt(),Bt(),Vt(),Ht(),Ut(),Wt(),Gt(),Yt(),Xt(),Kt(),qt(),Zt()]).optional()})),Yt=E(()=>h({hookEventName:o(`Elicitation`),action:u([`accept`,`decline`,`cancel`]).optional(),content:a(n(),i()).optional()}).describe(`Hook-specific output for the Elicitation event. Return this to programmatically accept or decline an MCP elicitation request.`)),Xt=E(()=>h({hookEventName:o(`ElicitationResult`),action:u([`accept`,`decline`,`cancel`]).optional(),content:a(n(),i()).optional()}).describe(`Hook-specific output for the ElicitationResult event. Return this to override the action or content before the response is sent to the MCP server.`)),Zt=E(()=>h({hookEventName:o(`WorktreeCreate`),worktreePath:n()}).describe(`Hook-specific output for the WorktreeCreate event. Provides the absolute path to the created worktree directory. Command hooks print the path on stdout instead.`));E(()=>l([Ft(),Jt()]));var Qt=E(()=>h({key:n().describe(`Unique key for this option, returned in the response`),label:n().describe(`Display text for this option`),description:n().optional().describe(`Optional description shown below the label`)}));E(()=>h({prompt:n().describe(`Request ID. Presence of this key marks the line as a prompt request.`),message:n().describe(`The prompt message to display to the user`),options:p(Qt()).describe(`Available options for the user to choose from`)})),E(()=>h({prompt_response:n().describe(`The request ID from the corresponding prompt request`),selected:n().describe(`The key of the selected option`)}));var z=E(()=>h({name:n().describe(`Skill name (without the leading slash)`),description:n().describe(`Description of what the skill does`),argumentHint:n().describe(`Hint for skill arguments (e.g., "<file>")`)}).describe(`Information about an available skill (invoked via /command syntax).`)),B=E(()=>h({name:n().describe(`Agent type identifier (e.g., "Explore")`),description:n().describe(`Description of when to use this agent`),model:n().optional().describe(`Model alias this agent uses. If omitted, inherits the parent's model`)}).describe(`Information about an available subagent that can be invoked via the Task tool.`)),$t=E(()=>h({value:n().describe(`Model identifier to use in API calls`),displayName:n().describe(`Human-readable display name`),description:n().describe(`Description of the model's capabilities`),supportsEffort:d().optional().describe(`Whether this model supports effort levels`),supportedEffortLevels:p(u([`low`,`medium`,`high`,`xhigh`,`max`])).optional().describe(`Available effort levels for this model`),supportsAdaptiveThinking:d().optional().describe(`Whether this model supports adaptive thinking (Claude decides when and how much to think)`),supportsFastMode:d().optional().describe(`Whether this model supports fast mode`),supportsAutoMode:d().optional().describe(`Whether this model supports auto mode`)}).describe(`Information about an available model.`)),en=E(()=>h({email:n().optional(),organization:n().optional(),subscriptionType:n().optional(),tokenSource:n().optional(),apiKeySource:n().optional(),apiProvider:u([`firstParty`,`bedrock`,`vertex`,`foundry`]).optional().describe(`Active API backend. Anthropic OAuth login only applies when "firstParty"; for 3P providers the other fields are absent and auth is external (AWS creds, gcloud ADC, etc.).`)}).describe(`Information about the logged in user's account.`)),tn=E(()=>l([n(),a(n(),A())])),nn=E(()=>h({description:n().describe(`Natural language description of when to use this agent`),tools:p(n()).optional().describe(`Array of allowed tool names. If omitted, inherits all tools from parent`),disallowedTools:p(n()).optional().describe(`Array of tool names to explicitly disallow for this agent`),prompt:n().describe(`The agent's system prompt`),model:n().optional().describe(`Model alias (e.g. 'sonnet', 'opus', 'haiku') or full model ID (e.g. 'claude-opus-4-5'). If omitted or 'inherit', uses the main model`),mcpServers:p(tn()).optional(),criticalSystemReminder_EXPERIMENTAL:n().optional().describe(`Experimental: Critical reminder added to system prompt`),skills:p(n()).optional().describe(`Array of skill names to preload into the agent context`),initialPrompt:n().optional().describe(`Auto-submitted as the first user turn when this agent is the main thread agent. Slash commands are processed. Prepended to any user-provided prompt.`),maxTurns:r().int().positive().optional().describe(`Maximum number of agentic turns (API round-trips) before stopping`),background:d().optional().describe(`Run this agent as a background task (non-blocking, fire-and-forget) when invoked`),memory:u([`user`,`project`,`local`]).optional().describe(`Scope for auto-loading agent memory files. 'user' - ~/.claude/agent-memory/<agentType>/, 'project' - .claude/agent-memory/<agentType>/, 'local' - .claude/agent-memory-local/<agentType>/`),effort:l([u([`low`,`medium`,`high`,`xhigh`,`max`]),r().int()]).optional().describe(`Reasoning effort level for this agent. Either a named level or an integer`),permissionMode:L().optional().describe(`Permission mode controlling how tool executions are handled`)}).describe(`Definition for a custom subagent that can be invoked via the Agent tool.`));E(()=>u([`user`,`project`,`local`]).describe(`Source for loading filesystem-based settings. 'user' - Global user settings (~/.claude/settings.json). 'project' - Project settings (.claude/settings.json). 'local' - Local settings (.claude/settings.local.json).`)),E(()=>h({type:o(`local`).describe(`Plugin type. Currently only 'local' is supported`),path:n().describe(`Absolute or relative path to the plugin directory`)}).describe(`Configuration for loading a plugin.`)),E(()=>h({canRewind:d(),error:n().optional(),filesChanged:p(n()).optional(),insertions:r().optional(),deletions:r().optional()}).describe(`Result of a rewindFiles operation.`));var rn=E(()=>i()),an=E(()=>i()),on=E(()=>i()),V=E(()=>n()),H=E(()=>i()),U=E(()=>u([`authentication_failed`,`billing_error`,`rate_limit`,`invalid_request`,`server_error`,`unknown`,`max_output_tokens`])),sn=E(()=>l([o(`compacting`),ee()])),W=E(()=>h({type:o(`user`),message:rn(),parent_tool_use_id:n().nullable(),isSynthetic:d().optional(),tool_use_result:i().optional(),priority:u([`now`,`next`,`later`]).optional(),timestamp:n().optional().describe(`ISO timestamp when the message was created on the originating process. Older emitters omit it; consumers should fall back to receive time.`)})),G=E(()=>W().extend({uuid:V().optional(),session_id:n().optional()})),cn=E(()=>W().extend({uuid:V(),session_id:n(),isReplay:o(!0)})),ln=E(()=>h({status:u([`allowed`,`allowed_warning`,`rejected`]),resetsAt:r().optional(),rateLimitType:u([`five_hour`,`seven_day`,`seven_day_opus`,`seven_day_sonnet`,`overage`]).optional(),utilization:r().optional(),overageStatus:u([`allowed`,`allowed_warning`,`rejected`]).optional(),overageResetsAt:r().optional(),overageDisabledReason:u([`overage_not_provisioned`,`org_level_disabled`,`org_level_disabled_until`,`out_of_credits`,`seat_tier_level_disabled`,`member_level_disabled`,`seat_tier_zero_credit_limit`,`group_zero_credit_limit`,`member_zero_credit_limit`,`org_service_level_disabled`,`org_service_zero_credit_limit`,`no_limits_configured`,`unknown`]).optional(),isUsingOverage:d().optional(),surpassedThreshold:r().optional()}).describe(`Rate limit information for claude.ai subscription users.`)),un=E(()=>h({type:o(`assistant`),message:an(),parent_tool_use_id:n().nullable(),error:U().optional(),uuid:V(),session_id:n()})),dn=E(()=>h({type:o(`rate_limit_event`),rate_limit_info:ln(),uuid:V(),session_id:n()}).describe(`Rate limit event emitted when rate limit info changes.`)),fn=E(()=>h({type:o(`streamlined_text`),text:n().describe(`Text content preserved from the assistant message`),session_id:n(),uuid:V()}).describe(`@internal Streamlined text message - replaces SDKAssistantMessage in streamlined output. Text content preserved, thinking and tool_use blocks removed.`)),pn=E(()=>h({type:o(`streamlined_tool_use_summary`),tool_summary:n().describe(`Summary of tool calls (e.g., "Read 2 files, wrote 1 file")`),session_id:n(),uuid:V()}).describe(`@internal Streamlined tool use summary - replaces tool_use blocks in streamlined output with a cumulative summary string.`)),K=E(()=>h({tool_name:n(),tool_use_id:n(),tool_input:a(n(),i())})),mn=E(()=>h({type:o(`result`),subtype:o(`success`),duration_ms:r(),duration_api_ms:r(),is_error:d(),num_turns:r(),result:n(),stop_reason:n().nullable(),total_cost_usd:r(),usage:H(),modelUsage:a(n(),k()),permission_denials:p(K()),structured_output:i().optional(),fast_mode_state:q().optional(),uuid:V(),session_id:n()})),hn=E(()=>h({type:o(`result`),subtype:u([`error_during_execution`,`error_max_turns`,`error_max_budget_usd`,`error_max_structured_output_retries`]),duration_ms:r(),duration_api_ms:r(),is_error:d(),num_turns:r(),stop_reason:n().nullable(),total_cost_usd:r(),usage:H(),modelUsage:a(n(),k()),permission_denials:p(K()),errors:p(n()),fast_mode_state:q().optional(),uuid:V(),session_id:n()})),gn=E(()=>l([mn(),hn()])),_n=E(()=>h({type:o(`system`),subtype:o(`init`),agents:p(n()).optional(),apiKeySource:We(),betas:p(n()).optional(),claude_code_version:n(),cwd:n(),tools:p(n()),mcp_servers:p(h({name:n(),status:n()})),model:n(),permissionMode:L(),slash_commands:p(n()),output_style:n(),skills:p(n()),plugins:p(h({name:n(),path:n(),source:n().optional().describe(`@internal Plugin source identifier in "name\\@marketplace" format. Sentinels: "name\\@inline" for --plugin-dir, "name\\@builtin" for built-in plugins.`)})),fast_mode_state:q().optional(),uuid:V(),session_id:n()})),vn=E(()=>h({type:o(`stream_event`),event:on(),parent_tool_use_id:n().nullable(),uuid:V(),session_id:n()})),yn=E(()=>h({type:o(`system`),subtype:o(`compact_boundary`),compact_metadata:h({trigger:u([`manual`,`auto`]),pre_tokens:r(),preserved_segment:h({head_uuid:V(),anchor_uuid:V(),tail_uuid:V()}).optional().describe(`Relink info for messagesToKeep. Loaders splice the preserved segment at anchor_uuid (summary for suffix-preserving, boundary for prefix-preserving partial compact) so resume includes preserved content. Unset when compaction summarizes everything (no messagesToKeep).`)}),uuid:V(),session_id:n()})),bn=E(()=>h({type:o(`system`),subtype:o(`status`),status:sn(),permissionMode:L().optional(),uuid:V(),session_id:n()})),xn=E(()=>h({type:o(`system`),subtype:o(`post_turn_summary`),summarizes_uuid:n(),status_category:u([`blocked`,`waiting`,`completed`,`review_ready`,`failed`]),status_detail:n(),is_noteworthy:d(),title:n(),description:n(),recent_action:n(),needs_action:n(),artifact_urls:p(n()),uuid:V(),session_id:n()}).describe(`@internal Background post-turn summary emitted after each assistant turn. summarizes_uuid points to the assistant message this summarizes.`)),Sn=E(()=>h({type:o(`system`),subtype:o(`api_retry`),attempt:r(),max_retries:r(),retry_delay_ms:r(),error_status:r().nullable(),error:U(),uuid:V(),session_id:n()}).describe(`Emitted when an API request fails with a retryable error and will be retried after a delay. error_status is null for connection errors (e.g. timeouts) that had no HTTP response.`)),Cn=E(()=>h({type:o(`system`),subtype:o(`local_command_output`),content:n(),uuid:V(),session_id:n()}).describe(`Output from a local slash command (e.g. /voice, /cost). Displayed as assistant-style text in the transcript.`)),wn=E(()=>h({type:o(`system`),subtype:o(`hook_started`),hook_id:n(),hook_name:n(),hook_event:n(),uuid:V(),session_id:n()})),Tn=E(()=>h({type:o(`system`),subtype:o(`hook_progress`),hook_id:n(),hook_name:n(),hook_event:n(),stdout:n(),stderr:n(),output:n(),uuid:V(),session_id:n()})),En=E(()=>h({type:o(`system`),subtype:o(`hook_response`),hook_id:n(),hook_name:n(),hook_event:n(),output:n(),stdout:n(),stderr:n(),exit_code:r().optional(),outcome:u([`success`,`error`,`cancelled`]),uuid:V(),session_id:n()})),Dn=E(()=>h({type:o(`tool_progress`),tool_use_id:n(),tool_name:n(),parent_tool_use_id:n().nullable(),elapsed_time_seconds:r(),task_id:n().optional(),uuid:V(),session_id:n()})),On=E(()=>h({type:o(`auth_status`),isAuthenticating:d(),output:p(n()),error:n().optional(),uuid:V(),session_id:n()})),kn=E(()=>h({type:o(`system`),subtype:o(`files_persisted`),files:p(h({filename:n(),file_id:n()})),failed:p(h({filename:n(),error:n()})),processed_at:n(),uuid:V(),session_id:n()})),An=E(()=>h({type:o(`system`),subtype:o(`task_notification`),task_id:n(),tool_use_id:n().optional(),status:u([`completed`,`failed`,`stopped`]),output_file:n(),summary:n(),usage:h({total_tokens:r(),tool_uses:r(),duration_ms:r()}).optional(),uuid:V(),session_id:n()})),jn=E(()=>h({type:o(`system`),subtype:o(`task_started`),task_id:n(),tool_use_id:n().optional(),description:n(),task_type:n().optional(),workflow_name:n().optional().describe(`meta.name from the workflow script (e.g. 'spec'). Only set when task_type is 'local_workflow'.`),prompt:n().optional(),uuid:V(),session_id:n()})),Mn=E(()=>h({type:o(`system`),subtype:o(`session_state_changed`),state:u([`idle`,`running`,`requires_action`]),uuid:V(),session_id:n()}).describe(`Mirrors notifySessionStateChanged. 'idle' fires after heldBackResult flushes and the bg-agent do-while exits — authoritative turn-over signal.`)),Nn=E(()=>h({type:o(`system`),subtype:o(`task_progress`),task_id:n(),tool_use_id:n().optional(),description:n(),usage:h({total_tokens:r(),tool_uses:r(),duration_ms:r()}),last_tool_name:n().optional(),summary:n().optional(),uuid:V(),session_id:n()})),Pn=E(()=>h({type:o(`tool_use_summary`),summary:n(),preceding_tool_use_ids:p(n()),uuid:V(),session_id:n()})),Fn=E(()=>h({type:o(`system`),subtype:o(`elicitation_complete`),mcp_server_name:n(),elicitation_id:n(),uuid:V(),session_id:n()}).describe(`Emitted when an MCP server confirms that a URL-mode elicitation is complete.`)),In=E(()=>h({type:o(`prompt_suggestion`),suggestion:n(),uuid:V(),session_id:n()}).describe(`Predicted next user prompt, emitted after each turn when promptSuggestions is enabled.`));E(()=>h({sessionId:n().describe(`Unique session identifier (UUID).`),summary:n().describe(`Display title for the session: custom title, auto-generated summary, or first prompt.`),lastModified:r().describe(`Last modified time in milliseconds since epoch.`),fileSize:r().optional().describe(`File size in bytes. Only populated for local JSONL storage.`),customTitle:n().optional().describe(`User-set session title via /rename.`),firstPrompt:n().optional().describe(`First meaningful user prompt in the session.`),gitBranch:n().optional().describe(`Git branch at the end of the session.`),cwd:n().optional().describe(`Working directory for the session.`),tag:n().optional().describe(`User-set session tag.`),createdAt:r().optional().describe(`Creation time in milliseconds since epoch, extracted from the first entry's timestamp.`)}).describe(`Session metadata returned by listSessions and getSessionInfo.`));var Ln=E(()=>l([un(),G(),cn(),gn(),_n(),vn(),yn(),bn(),Sn(),Cn(),wn(),Tn(),En(),Dn(),On(),An(),jn(),Nn(),Mn(),kn(),Pn(),dn(),Fn(),In()])),q=E(()=>u([`off`,`cooldown`,`on`]).describe(`Fast mode state: off, in cooldown after rate limit, or actively enabled.`));m(),D();var Rn=E(()=>i()),zn=E(()=>h({matcher:n().optional(),hookCallbackIds:p(n()),timeout:r().optional()}).describe(`Configuration for matching and routing hook callbacks.`)),Bn=E(()=>h({subtype:o(`initialize`),hooks:a(tt(),p(zn())).optional(),sdkMcpServers:p(n()).optional(),jsonSchema:a(n(),i()).optional(),systemPrompt:n().optional(),appendSystemPrompt:n().optional(),agents:a(n(),nn()).optional(),promptSuggestions:d().optional(),agentProgressSummaries:d().optional()}).describe(`Initializes the SDK session with hooks, MCP servers, and agent configuration.`));E(()=>h({commands:p(z()),agents:p(B()),output_style:n(),available_output_styles:p(n()),models:p($t()),account:en(),pid:r().optional().describe(`@internal CLI process PID for tmux socket isolation`),fast_mode_state:q().optional()}).describe(`Response from session initialization with available commands, models, and account info.`));var Vn=E(()=>h({subtype:o(`interrupt`)}).describe(`Interrupts the currently running conversation turn.`)),Hn=E(()=>h({subtype:o(`can_use_tool`),tool_name:n(),input:a(n(),i()),permission_suggestions:p(F()).optional(),blocked_path:n().optional(),decision_reason:n().optional(),title:n().optional(),display_name:n().optional(),tool_use_id:n(),agent_id:n().optional(),description:n().optional()}).describe(`Requests permission to use a tool with the given input.`)),Un=E(()=>h({subtype:o(`set_permission_mode`),mode:L(),ultraplan:d().optional().describe(`@internal CCR ultraplan session marker.`)}).describe(`Sets the permission mode for tool execution handling.`)),Wn=E(()=>h({subtype:o(`set_model`),model:n().optional()}).describe(`Sets the model to use for subsequent conversation turns.`)),Gn=E(()=>h({subtype:o(`set_max_thinking_tokens`),max_thinking_tokens:r().nullable()}).describe(`Sets the maximum number of thinking tokens for extended thinking.`)),Kn=E(()=>h({subtype:o(`mcp_status`)}).describe(`Requests the current status of all MCP server connections.`));E(()=>h({mcpServers:p(j())}).describe(`Response containing the current status of all MCP server connections.`));var qn=E(()=>h({subtype:o(`get_context_usage`)}).describe(`Requests a breakdown of current context window usage by category.`)),Jn=E(()=>h({name:n(),tokens:r(),color:n(),isDeferred:d().optional()})),Yn=E(()=>h({color:n(),isFilled:d(),categoryName:n(),tokens:r(),percentage:r(),squareFullness:r()}));E(()=>h({categories:p(Jn()),totalTokens:r(),maxTokens:r(),rawMaxTokens:r(),percentage:r(),gridRows:p(p(Yn())),model:n(),memoryFiles:p(h({path:n(),type:n(),tokens:r()})),mcpTools:p(h({name:n(),serverName:n(),tokens:r(),isLoaded:d().optional()})),deferredBuiltinTools:p(h({name:n(),tokens:r(),isLoaded:d()})).optional(),systemTools:p(h({name:n(),tokens:r()})).optional(),systemPromptSections:p(h({name:n(),tokens:r()})).optional(),agents:p(h({agentType:n(),source:n(),tokens:r()})),slashCommands:h({totalCommands:r(),includedCommands:r(),tokens:r()}).optional(),skills:h({totalSkills:r(),includedSkills:r(),tokens:r(),skillFrontmatter:p(h({name:n(),source:n(),tokens:r()}))}).optional(),autoCompactThreshold:r().optional(),isAutoCompactEnabled:d(),messageBreakdown:h({toolCallTokens:r(),toolResultTokens:r(),attachmentTokens:r(),assistantMessageTokens:r(),userMessageTokens:r(),toolCallsByType:p(h({name:n(),callTokens:r(),resultTokens:r()})),attachmentsByType:p(h({name:n(),tokens:r()}))}).optional(),apiUsage:h({input_tokens:r(),output_tokens:r(),cache_creation_input_tokens:r(),cache_read_input_tokens:r()}).nullable()}).describe(`Breakdown of current context window usage by category (system prompt, tools, messages, etc.).`));var Xn=E(()=>h({subtype:o(`rewind_files`),user_message_id:n(),dry_run:d().optional()}).describe(`Rewinds file changes made since a specific user message.`));E(()=>h({canRewind:d(),error:n().optional(),filesChanged:p(n()).optional(),insertions:r().optional(),deletions:r().optional()}).describe(`Result of a rewindFiles operation.`));var Zn=E(()=>h({subtype:o(`cancel_async_message`),message_uuid:n()}).describe(`Drops a pending async user message from the command queue by uuid. No-op if already dequeued for execution.`));E(()=>h({cancelled:d()}).describe(`Result of a cancel_async_message operation. cancelled=false means the message was not in the queue (already dequeued or never enqueued).`));var Qn=E(()=>h({subtype:o(`seed_read_state`),path:n(),mtime:r()}).describe(`Seeds the readFileState cache with a path+mtime entry. Use when a prior Read was removed from context (e.g. by snip) so Edit validation would fail despite the client having observed the Read. The mtime lets the CLI detect if the file changed since the seeded Read — same staleness check as the normal path.`)),$n=E(()=>h({subtype:o(`hook_callback`),callback_id:n(),input:Pt(),tool_use_id:n().optional()}).describe(`Delivers a hook callback with its input data.`)),er=E(()=>h({subtype:o(`mcp_message`),server_name:n(),message:Rn()}).describe(`Sends a JSON-RPC message to a specific MCP server.`)),tr=E(()=>h({subtype:o(`mcp_set_servers`),servers:a(n(),A())}).describe(`Replaces the set of dynamically managed MCP servers.`));E(()=>h({added:p(n()),removed:p(n()),errors:a(n(),n())}).describe(`Result of replacing the set of dynamically managed MCP servers.`));var nr=E(()=>h({subtype:o(`reload_plugins`)}).describe(`Reloads plugins from disk and returns the refreshed session components.`));E(()=>h({commands:p(z()),agents:p(B()),plugins:p(h({name:n(),path:n(),source:n().optional()})),mcpServers:p(j()),error_count:r()}).describe(`Refreshed commands, agents, plugins, and MCP server status after reload.`));var rr=E(()=>h({subtype:o(`mcp_reconnect`),serverName:n()}).describe(`Reconnects a disconnected or failed MCP server.`)),ir=E(()=>h({subtype:o(`mcp_toggle`),serverName:n(),enabled:d()}).describe(`Enables or disables an MCP server.`)),ar=E(()=>h({subtype:o(`stop_task`),task_id:n()}).describe(`Stops a running task.`)),or=E(()=>h({subtype:o(`apply_flag_settings`),settings:a(n(),i())}).describe(`Merges the provided settings into the flag settings layer, updating the active configuration.`)),sr=E(()=>h({subtype:o(`get_settings`)}).describe(`Returns the effective merged settings and the raw per-source settings.`));E(()=>h({effective:a(n(),i()),sources:p(h({source:u([`userSettings`,`projectSettings`,`localSettings`,`flagSettings`,`policySettings`]),settings:a(n(),i())})).describe(`Ordered low-to-high priority — later entries override earlier ones.`),applied:h({model:n(),effort:u([`low`,`medium`,`high`,`xhigh`,`max`]).nullable()}).optional().describe("Runtime-resolved values after env overrides, session state, and model-specific defaults are applied. Unlike `effective` (disk merge), these reflect what will actually be sent to the API.")}).describe(`Effective merged settings plus raw per-source settings in merge order.`));var cr=E(()=>h({subtype:o(`elicitation`),mcp_server_name:n(),message:n(),mode:u([`form`,`url`]).optional(),url:n().optional(),elicitation_id:n().optional(),requested_schema:a(n(),i()).optional()}).describe(`Requests the SDK consumer to handle an MCP elicitation (user input request).`)),lr=E(()=>h({action:u([`accept`,`decline`,`cancel`]),content:a(n(),i()).optional()}).describe(`Response from the SDK consumer for an elicitation request.`)),ur=E(()=>l([Vn(),Hn(),Bn(),Un(),Wn(),Gn(),Kn(),qn(),$n(),er(),Xn(),Zn(),Qn(),tr(),nr(),rr(),ir(),ar(),or(),sr(),cr()])),J=E(()=>h({type:o(`control_request`),request_id:n(),request:ur()})),dr=E(()=>h({subtype:o(`success`),request_id:n(),response:a(n(),i()).optional()})),fr=E(()=>h({subtype:o(`error`),request_id:n(),error:n(),pending_permission_requests:p(g(()=>J())).optional()})),Y=E(()=>h({type:o(`control_response`),response:l([dr(),fr()])})),pr=E(()=>h({type:o(`control_cancel_request`),request_id:n()}).describe(`Cancels a currently open control request.`)),X=E(()=>h({type:o(`keep_alive`)}).describe(`Keep-alive message to maintain WebSocket connection.`)),mr=E(()=>h({type:o(`update_environment_variables`),variables:a(n(),n())}).describe(`Updates environment variables at runtime.`));E(()=>l([Ln(),fn(),pn(),xn(),Y(),J(),pr(),X()])),E(()=>l([G(),J(),Y(),X(),mr()])),e(),te(),S(),b(),Ee(),Ae(),ie(),m(),C(),D(),_(),re(),E(()=>f.object({tool_name:f.string().describe(`The name of the tool requesting permission`),input:f.record(f.string(),f.unknown()).describe(`The input for the tool`),tool_use_id:f.string().optional().describe(`The unique tool use request ID`)}));var Z=E(()=>f.enum([`user_temporary`,`user_permanent`,`user_reject`]).optional().catch(void 0)),hr=E(()=>f.object({behavior:f.literal(`allow`),updatedInput:f.record(f.string(),f.unknown()),updatedPermissions:f.array(ue()).optional().catch(e=>{w(`Malformed updatedPermissions from SDK host ignored: ${e.error.issues[0]?.message??`unknown`}`,{level:`warn`})}),toolUseID:f.string().optional(),decisionClassification:Z()})),gr=E(()=>f.object({behavior:f.literal(`deny`),message:f.string(),interrupt:f.boolean().optional(),toolUseID:f.string().optional(),decisionClassification:Z()})),Q=E(()=>f.union([hr(),gr()]));function $(e,t,n,r){let i={type:`permissionPromptTool`,permissionPromptToolName:t.name,toolResult:e};if(e.behavior===`allow`){let t=e.updatedPermissions;t&&(r.setAppState(e=>({...e,toolPermissionContext:y(e.toolPermissionContext,t)})),v(t));let a=Object.keys(e.updatedInput).length>0?e.updatedInput:n;return{...e,updatedInput:a,decisionReason:i}}else e.behavior===`deny`&&e.interrupt&&(w(`SDK permission prompt deny+interrupt: tool=${t.name} message=${e.message}`),r.abortController.abort());return{...e,decisionReason:i}}Me(),Pe(),Te(),_e(),Le(),he(),be(),oe();var _r=/\u2028|\u2029/g;function vr(e){return e.replace(_r,e=>e===`\u2028`?`\\u2028`:`\\u2029`)}function yr(e){return vr(x(e))}C(),b(),m(),_();var br=`SandboxNetworkAccess`;function xr(e){if(e){if(e.type===`classifier`)return e.reason;switch(e.type){case`rule`:case`mode`:case`subcommandResults`:case`permissionPromptTool`:return;case`hook`:case`asyncAgent`:case`sandboxOverride`:case`workingDir`:case`safetyCheck`:case`other`:return e.reason}}}function Sr(e,t,n,r){let i;try{i=e.getActivityDescription?.(t)??e.getToolUseSummary?.(t)??e.userFacingName(t)}catch{i=e.name}return{tool_name:e.name,action_description:i,tool_use_id:n,request_id:r,input:t}}var Cr=1e3,wr=class{constructor(e,n){t(this,`input`,void 0),t(this,`replayUserMessages`,void 0),t(this,`structuredInput`,void 0),t(this,`pendingRequests`,new Map),t(this,`restoredWorkerState`,Promise.resolve(null)),t(this,`inputClosed`,!1),t(this,`unexpectedResponseCallback`,void 0),t(this,`resolvedToolUseIds`,new Set),t(this,`prependedLines`,[]),t(this,`onControlRequestSent`,void 0),t(this,`onControlRequestResolved`,void 0),t(this,`outbound`,new me),this.input=e,this.replayUserMessages=n,this.input=e,this.structuredInput=this.read()}trackResolvedToolUseId(e){let t=e.request;if(t.subtype===`can_use_tool`&&(this.resolvedToolUseIds.add(t.tool_use_id),this.resolvedToolUseIds.size>Cr)){let e=this.resolvedToolUseIds.values().next().value;e!==void 0&&this.resolvedToolUseIds.delete(e)}}flushInternalEvents(){return Promise.resolve()}get internalEventsPending(){return 0}prependUserMessage(e){this.prependedLines.push(x({type:`user`,content:e,uuid:``,session_id:``,message:{role:`user`,content:e},parent_tool_use_id:null})+`
|
|
2
|
-
`)}async*read(){let e=``,t=async function*(){for(;;){this.prependedLines.length>0&&(e=this.prependedLines.join(``)+e,this.prependedLines=[]);let t=e.indexOf(`
|
|
3
|
-
`);if(t===-1)break;let n=e.slice(0,t);e=e.slice(t+1);let r=await this.processLine(n);r&&(Oe(`info`,`cli_stdin_message_parsed`,{type:r.type}),yield r)}}.bind(this);yield*t();for await(let n of this.input)e+=n,yield*t();if(e){let t=await this.processLine(e);t&&(yield t)}this.inputClosed=!0;for(let e of this.pendingRequests.values())e.reject(Error(`Tool permission stream closed before response received`))}getPendingPermissionRequests(){return Array.from(this.pendingRequests.values()).map(e=>e.request).filter(e=>e.request.subtype===`can_use_tool`)}setUnexpectedResponseCallback(e){this.unexpectedResponseCallback=e}injectControlResponse(e){let t=e.response,n=t?.request_id;if(!n)return;let r=this.pendingRequests.get(n);if(r)if(this.trackResolvedToolUseId(r.request),this.pendingRequests.delete(n),this.write({type:`control_cancel_request`,request_id:n}),t.subtype===`error`)r.reject(Error(t.error));else{let e=t.response;if(r.schema)try{r.resolve(r.schema.parse(e))}catch(e){r.reject(e)}else r.resolve({})}}setOnControlRequestSent(e){this.onControlRequestSent=e}setOnControlRequestResolved(e){this.onControlRequestResolved=e}async processLine(e){if(e)try{let t=ze(xe(e));if(t.type===`keep_alive`)return;if(t.type===`update_environment_variables`){let e=t.variables??{},n=Object.keys(e);for(let[t,n]of Object.entries(e))process.env[t]=n;w(`[structuredIO] applied update_environment_variables: ${n.join(`, `)}`);return}if(t.type===`control_response`){let e=`uuid`in t&&typeof t.uuid==`string`?t.uuid:void 0;e&&ge(e,`completed`);let n=t.response,r=this.pendingRequests.get(n.request_id);if(!r){let e=(n.subtype===`success`?n.response:void 0)?.toolUseID;if(typeof e==`string`&&this.resolvedToolUseIds.has(e)){w(`Ignoring duplicate control_response for already-resolved toolUseID=${e} request_id=${n.request_id}`);return}this.unexpectedResponseCallback&&await this.unexpectedResponseCallback(t);return}if(this.trackResolvedToolUseId(r.request),this.pendingRequests.delete(n.request_id),r.request.request.subtype===`can_use_tool`&&this.onControlRequestResolved&&this.onControlRequestResolved(n.request_id),n.subtype===`error`){r.reject(Error(n.error??`Unknown error`));return}let i=n.response;if(r.schema)try{r.resolve(r.schema.parse(i))}catch(e){r.reject(e)}else r.resolve({});return this.replayUserMessages?t:void 0}if(t.type!==`user`&&t.type!==`control_request`&&t.type!==`assistant`&&t.type!==`system`){w(`Ignoring unknown message type: ${t.type}`,{level:`warn`});return}return t.type===`control_request`?(t.request||Tr(`Error: Missing request on control_request`),t):(t.type===`assistant`||t.type===`system`||t.message?.role!==`user`&&Tr(`Error: Expected message role 'user', got '${t.message?.role}'`),t)}catch(t){console.error(`Error parsing streaming input line: ${e}: ${t}`),process.exit(1)}}async write(e){De(yr(e)+`
|
|
4
|
-
`)}async sendRequest(e,t,n,r=O()){let i={type:`control_request`,request_id:r,request:e};if(this.inputClosed)throw Error(`Stream closed`);if(n?.aborted)throw Error(`Request aborted`);this.outbound.enqueue(i),e.subtype===`can_use_tool`&&this.onControlRequestSent&&this.onControlRequestSent(i);let a=()=>{this.outbound.enqueue({type:`control_cancel_request`,request_id:r});let e=this.pendingRequests.get(r);e&&(this.trackResolvedToolUseId(e.request),e.reject(new Se))};n&&n.addEventListener(`abort`,a,{once:!0});try{return await new Promise((n,i)=>{this.pendingRequests.set(r,{request:{type:`control_request`,request_id:r,request:e},resolve:e=>{n(e)},reject:i,schema:t})})}finally{n&&n.removeEventListener(`abort`,a),this.pendingRequests.delete(r)}}createCanUseTool(e){return async(t,n,r,i,a,o)=>{let s=o??await pe(t,n,r,i,a);if(s.behavior===`allow`||s.behavior===`deny`)return s;let c=new AbortController,l=r.abortController.signal,u=()=>c.abort();l.addEventListener(`abort`,u,{once:!0});try{let i=Er(t.name,a,n,r,s.suggestions).then(e=>({source:`hook`,decision:e})),o=O();e?.(Sr(t,n,a,o));let l=this.sendRequest({subtype:`can_use_tool`,tool_name:t.name,input:n,permission_suggestions:s.suggestions,blocked_path:s.blockedPath,decision_reason:xr(s.decisionReason),tool_use_id:a,agent_id:r.agentId},Q(),c.signal,o).then(e=>({source:`sdk`,result:e})),u=await Promise.race([i,l]);return u.source===`hook`?u.decision?(l.catch(()=>{}),c.abort(),u.decision):$((await l).result,t,n,r):$(u.result,t,n,r)}catch(e){return $({behavior:`deny`,message:`Tool permission request failed: ${e}`,toolUseID:a},t,n,r)}finally{this.getPendingPermissionRequests().length===0&&Re(`running`),l.removeEventListener(`abort`,u)}}}createHookCallback(e,t){return{type:`callback`,timeout:t,callback:async(t,n,r)=>{try{return await this.sendRequest({subtype:`hook_callback`,callback_id:e,input:t,tool_use_id:n||void 0},de(),r)}catch(t){return console.error(`Error in hook callback ${e}:`,t),{}}}}}async handleElicitation(e,t,n,r,i,a,o){try{return await this.sendRequest({subtype:`elicitation`,mcp_server_name:e,message:t,mode:i,url:a,elicitation_id:o,requested_schema:n},lr(),r)}catch{return{action:`cancel`}}}createSandboxAskCallback(){return async e=>{try{return(await this.sendRequest({subtype:`can_use_tool`,tool_name:br,input:{host:e.host},tool_use_id:O(),description:`Allow network connection to ${e.host}?`},Q())).behavior===`allow`}catch{return!1}}}async sendMcpMessage(e,t){return(await this.sendRequest({subtype:`mcp_message`,server_name:e,message:t},h({mcp_response:s()}))).mcp_response}};function Tr(e){console.error(e),process.exit(1)}async function Er(e,t,n,r,i){let a=r.getAppState().toolPermissionContext.mode,o=se(e,t,n,r,a,i,r.abortController.signal);for await(let e of o)if(e.permissionRequestResult&&(e.permissionRequestResult.behavior===`allow`||e.permissionRequestResult.behavior===`deny`)){let t=e.permissionRequestResult;if(t.behavior===`allow`){let e=t.updatedInput||n,i=t.updatedPermissions??[];if(i.length>0){v(i);let e=y(r.getAppState().toolPermissionContext,i);r.setAppState(t=>t.toolPermissionContext===e?t:{...t,toolPermissionContext:e})}return{behavior:`allow`,updatedInput:e,userModified:!1,decisionReason:{type:`hook`,hookName:`PermissionRequest`}}}else return{behavior:`deny`,message:t.message||`Permission denied by PermissionRequest hook`,decisionReason:{type:`hook`,hookName:`PermissionRequest`}}}}ve();function Dr(e){if(e.type!==`user`)return;let t=e.message?.content;if(!t||Array.isArray(t)&&t.length===0)return;let n=`uuid`in e&&typeof e.uuid==`string`?e.uuid:void 0;return{content:Array.isArray(t)?Or(t):t,uuid:n}}function Or(e){return e.some(kr)?e.map(e=>{if(!kr(e))return e;let t=e.source,n=typeof t.mediaType==`string`&&t.mediaType?t.mediaType:ye(e.source.data);return{...e,source:{type:`base64`,media_type:n,data:e.source.data}}}):e}function kr(e){return e.type!==`image`||e.source?.type!==`base64`?!1:!e.source.media_type}Fe(),C(),S(),ke(),fe();function Ar(e,t,n){let r=[],i=[],a=[];for(let[o,s]of Object.entries(e)){let e=t[o],c=Mr(s.source,n?.projectRoot);e?s.sourceIsFallback||Ie(c,e.source)?a.push(o):i.push({name:o,declaredSource:c,materializedSource:e.source}):r.push(o)}return{missing:r,sourceChanged:i,upToDate:a}}async function jr(e){let t=le();if(Object.keys(t).length===0)return{installed:[],updated:[],failed:[],upToDate:[],skipped:[]};let n;try{n=await ce()}catch(e){T(e),n={}}let r=Ar(t,n,{projectRoot:ne()}),i=[...r.missing.map(e=>({name:e,source:Mr(t[e].source),action:`install`})),...r.sourceChanged.map(({name:e,declaredSource:t})=>({name:e,source:t,action:`update`}))],a=[],o=[];for(let t of i){if(e?.skip?.(t.name,t.source)){a.push(t.name);continue}if(t.action===`update`&&we(t.source)&&!await Ne(t.source.path)){w(`[reconcile] '${t.name}' declared path does not exist; keeping materialized entry`),a.push(t.name);continue}o.push(t)}if(o.length===0)return{installed:[],updated:[],failed:[],upToDate:r.upToDate,skipped:a};w(`[reconcile] ${o.length} marketplace(s): ${o.map(e=>`${e.name}(${e.action})`).join(`, `)}`);let s=[],c=[],l=[];for(let t=0;t<o.length;t++){let{name:n,source:r,action:i}=o[t];e?.onProgress?.({type:`installing`,name:n,action:i,index:t+1,total:o.length});try{let t=await ae(r);i===`install`?s.push(n):c.push(n),e?.onProgress?.({type:`installed`,name:n,alreadyMaterialized:t.alreadyMaterialized})}catch(t){let r=Ce(t);l.push({name:n,error:r}),e?.onProgress?.({type:`failed`,name:n,error:r}),T(t)}}return{installed:s,updated:c,failed:l,upToDate:r.upToDate,skipped:a}}function Mr(e,t){if((e.source===`directory`||e.source===`file`)&&!Be(e.path)){let n=t??ne(),r=je(n);return{...e,path:Ve(r??n,e.path)}}return e}export{wr as a,$ as c,br as i,jr as n,yr as o,Dr as r,Q as s,Ar as t};
|