@readmagic/workmate 0.0.1 → 0.0.2
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-BgNp7glC.js} +1 -1
- package/dist/chunks/{App-DY5O6IKw.js → App-Coboqa8H.js} +1 -1
- package/dist/chunks/ApproveApiKey-CQsQdQBC.js +1 -0
- package/dist/chunks/{ApproveApiKey-BEzfC6r3.js → ApproveApiKey-CYpBbj0k.js} +1 -1
- package/dist/chunks/{AssistantSessionChooser-Ce3PraaD.js → AssistantSessionChooser-DxKsTdqj.js} +1 -1
- package/dist/chunks/{BackgroundTasksDialog-Dvhcgahe.js → BackgroundTasksDialog-AiVi-1pI.js} +1 -1
- package/dist/chunks/{BypassPermissionsModeDialog-B68V1bCq.js → BypassPermissionsModeDialog-Cx3QGFz-.js} +1 -1
- package/dist/chunks/{ClaudeMdExternalIncludesDialog-CTWhpIm8.js → ClaudeMdExternalIncludesDialog-BAK9fxwg.js} +1 -1
- package/dist/chunks/ClaudeMdExternalIncludesDialog-DUu6iRJk.js +1 -0
- package/dist/chunks/ConsoleOAuthFlow-DVTPwR5I.js +1 -0
- package/dist/chunks/{DesktopHandoff-BRbU4is4.js → DesktopHandoff-BsHgLlTy.js} +1 -1
- package/dist/chunks/{DiffDialog-CBluIK-x.js → DiffDialog-BgTW2Znv.js} +1 -1
- package/dist/chunks/{Doctor-WxNv49HC.js → Doctor-BXhz8eUa.js} +1 -1
- package/dist/chunks/Doctor-D75dsEyb.js +1 -0
- package/dist/chunks/{ExitFlow-CRPgptCN.js → ExitFlow-B1XNACQP.js} +1 -1
- package/dist/chunks/{Feedback-CEtzaLr3.js → Feedback-Cvz80lAn.js} +1 -1
- package/dist/chunks/Grove-B7hhBvFw.js +1 -0
- package/dist/chunks/{Grove--kttLxvs.js → Grove-Dsi4yU08.js} +1 -1
- package/dist/chunks/{HybridTransport-BgV5_7Az.js → HybridTransport-8qA64lCx.js} +1 -1
- package/dist/chunks/{InvalidConfigDialog-DCGwXW_p.js → InvalidConfigDialog-CAZ1z5WG.js} +1 -1
- package/dist/chunks/{InvalidSettingsDialog-jTwsdXWr.js → InvalidSettingsDialog-D82Qk_MR.js} +1 -1
- package/dist/chunks/{MCPConnectionManager-BX0LMz9J.js → MCPConnectionManager-BLfKm4H2.js} +1 -1
- package/dist/chunks/{McpParsingWarnings-WQrWJeWP.js → McpParsingWarnings-8ZueNqAd.js} +1 -1
- package/dist/chunks/{MessageSelector-_UZB8cGb.js → MessageSelector-DmKtBYX9.js} +1 -1
- package/dist/chunks/Messages-CaFdI1kk.js +11 -0
- package/dist/chunks/{Onboarding-BoIVNCgc.js → Onboarding-CUztnbbv.js} +1 -1
- package/dist/chunks/{OverageCreditUpsell-1FCN8bH3.js → OverageCreditUpsell-DSgrZvMv.js} +1 -1
- package/dist/chunks/{PluginSettings-BD9JLV9-.js → PluginSettings-0FSNch8O.js} +1 -1
- package/dist/chunks/{PromptInputFooterSuggestions-CrGST0Cq.js → PromptInputFooterSuggestions-IaihWay3.js} +1 -1
- package/dist/chunks/{PromptInputHelpMenu-B2TDpbpw.js → PromptInputHelpMenu-okS2rQ4k.js} +1 -1
- package/dist/chunks/{QueryEngine-D2HUnwmU.js → QueryEngine-WYDWzQuY.js} +1 -1
- package/dist/chunks/{REPL-BV4WyYMg.js → REPL-Dto012J0.js} +7 -7
- package/dist/chunks/REPL-vV_jzAVx.js +1 -0
- package/dist/chunks/{RemoteCallout-DS_EV6Fh.js → RemoteCallout-C_UIYnuT.js} +1 -1
- package/dist/chunks/RemoteSessionManager-CuSSHAXN.js +2 -0
- package/dist/chunks/{ResumeConversation-Cw3vP4G8.js → ResumeConversation-g_JyOWbl.js} +1 -1
- package/dist/chunks/{SSETransport-BXiEBMpb.js → SSETransport-Chj_yfPv.js} +1 -1
- package/dist/chunks/SearchExtraToolsTool-Daedym7_.js +1 -0
- package/dist/chunks/{Settings-ns6mRsDc.js → Settings-DUXA-qac.js} +2 -2
- package/dist/chunks/{TeleportProgress-CcDzMC5L.js → TeleportProgress-DP1a8jit.js} +1 -1
- package/dist/chunks/{TeleportRepoMismatchDialog-DZbxl4sD.js → TeleportRepoMismatchDialog-B6sTwXuZ.js} +1 -1
- package/dist/chunks/{TeleportResumeWrapper-EowJO5nm.js → TeleportResumeWrapper-CKUuRQSG.js} +1 -1
- package/dist/chunks/{ThemePicker-BYbChJpu.js → ThemePicker-Dyq1YVhb.js} +1 -1
- package/dist/chunks/{TrustDialog-DA3YTk_k.js → TrustDialog-CdZS9t-T.js} +1 -1
- package/dist/chunks/{ValidationErrorsList-Cx-hoRwG.js → ValidationErrorsList-DUNh4BNa.js} +1 -1
- package/dist/chunks/WelcomeV2-TPbOXGrO.js +1 -0
- package/dist/chunks/{add-dir-CWt69NAZ.js → add-dir-Bf_5tCeR.js} +1 -1
- package/dist/chunks/{agentDisplay-CQ4mZWFH.js → agentDisplay-CCeYiAta.js} +1 -1
- package/dist/chunks/{agents-D4clhuCl.js → agents-Bt72Gz1v.js} +1 -1
- package/dist/chunks/{agents-C6jzKOit.js → agents-T8xHY5Wk.js} +1 -1
- package/dist/chunks/{allErrors-HMPqE0jK.js → allErrors-CDWTJcMw.js} +1 -1
- package/dist/chunks/{ant-9Z5bppVC.js → ant-DRF-v5bA.js} +1 -1
- package/dist/chunks/api-CLLIHLpn.js +1 -0
- package/dist/chunks/api-DMpNA1s8.js +1 -0
- package/dist/chunks/asciicast-BIr75_x9.js +1 -0
- package/dist/chunks/{asciicast-n-BBfgDq.js → asciicast-CQJlNTae.js} +1 -1
- package/dist/chunks/{assistant-BA9_Mo9U.js → assistant-C83quuNj.js} +1 -1
- package/dist/chunks/{assistant-BiNOSla3.js → assistant-z1ojxEET.js} +1 -1
- package/dist/chunks/assistant-z2o4-UJe.js +1 -0
- package/dist/chunks/auth-Ce0jllLf.js +1 -0
- package/dist/chunks/auth-DV3P8Qup.js +1 -0
- package/dist/chunks/{auth-DHyCIxCk.js → auth-DpFfHy1W.js} +1 -1
- package/dist/chunks/{autoMode-Db4QrgFr.js → autoMode-DW_H3i37.js} +3 -3
- package/dist/chunks/{autonomy-BkAMA7du.js → autonomy-46hnmyAi.js} +1 -1
- package/dist/chunks/{autonomy-D4Vy-RPQ.js → autonomy-OxhciwYa.js} +1 -1
- package/dist/chunks/{autonomyPanel-EjfO8jvg.js → autonomyPanel-CTEjq0Bd.js} +1 -1
- package/dist/chunks/backgroundHousekeeping-BycL9lOe.js +1 -0
- package/dist/chunks/{backgroundHousekeeping-hDDE8mJC.js → backgroundHousekeeping-Cpxq4krt.js} +2 -2
- package/dist/chunks/{banner-hD6wZygx.js → banner-BVkLvJiB.js} +1 -1
- package/dist/chunks/bg-H849G7Sc.js +1 -0
- package/dist/chunks/{bg-DQ0Q3Qv-.js → bg-zWGqkcST.js} +2 -2
- package/dist/chunks/{branch-CeQ9IyZk.js → branch-DJzijRGm.js} +1 -1
- package/dist/chunks/{break-cache-Bd0clV2N.js → break-cache-BQfgkNAo.js} +2 -2
- package/dist/chunks/{bridge-yerAiaK2.js → bridge-Dpr2AWpc.js} +2 -2
- package/dist/chunks/bridgeConfig-CcANVX0P.js +1 -0
- package/dist/chunks/{bridgeConfig-CCtXe8ak.js → bridgeConfig-DDF3teRE.js} +1 -1
- package/dist/chunks/bridgeEnabled-Cn-u7P4_.js +1 -0
- package/dist/chunks/{bridgeEnabled--F-6TUi4.js → bridgeEnabled-D4JDZd0y.js} +1 -1
- package/dist/chunks/{bridgeMain--R1HFbOv.js → bridgeMain-CtgVyLjI.js} +7 -7
- package/dist/chunks/bridgeMain-Dh0gWRVo.js +1 -0
- package/dist/chunks/{bridgeMessaging-CqbLTDcx.js → bridgeMessaging-CRG6HqUb.js} +1 -1
- package/dist/chunks/{bridgePointer-W_jdQ8zf.js → bridgePointer-Cug5fQ3e.js} +1 -1
- package/dist/chunks/{browser-Bd7GeBH1.js → browser-BKiu1max.js} +1 -1
- package/dist/chunks/{btw-CVGRmL9a.js → btw-DG9CCeq4.js} +1 -1
- package/dist/chunks/{caches-BtmAri4e.js → caches-BB5_91gU.js} +2 -2
- package/dist/chunks/caches-C3NINY3K.js +1 -0
- package/dist/chunks/{ccrClient-HqMi5Kfu.js → ccrClient-CRXGlUCe.js} +1 -1
- package/dist/chunks/{claudeDesktop-aUMx06RK.js → claudeDesktop-9xfIgkzE.js} +1 -1
- package/dist/chunks/{clear-C6nRzIQE.js → clear-ueMvDelv.js} +1 -1
- package/dist/chunks/{cliLaunch-2AUoMnqx.js → cliLaunch-BJ9o-rIV.js} +1 -1
- package/dist/chunks/client-AnWHs0gW.js +1 -0
- package/dist/chunks/{color-DXI_4ibU.js → color-B0-MIfsq.js} +1 -1
- package/dist/chunks/commands-DsKH3ogN.js +1 -0
- package/dist/chunks/commitAttribution-D7NrwLhc.js +1 -0
- package/dist/chunks/{commitAttribution-Cm40fdNU.js → commitAttribution-DKun9CeU.js} +1 -1
- package/dist/chunks/{compact-DPTVpJ4D.js → compact-BhWCO-oD.js} +1 -1
- package/dist/chunks/completionCache-C9zlWBRz.js +1 -0
- package/dist/chunks/{completionCache-BQaLkB4d.js → completionCache-CdHCuiqq.js} +2 -2
- package/dist/chunks/{config-C7YHKCPV.js → config-662VDD70.js} +1 -1
- package/dist/chunks/config-CUN8YbOa.js +1 -0
- package/dist/chunks/{config-CLmFk-5V.js → config-DklnhNx1.js} +1 -1
- package/dist/chunks/config-Wk3svGdH.js +1 -0
- package/dist/chunks/{context-C_cKrBUn.js → context-DBswG0EY.js} +1 -1
- package/dist/chunks/context-noninteractive-C3dICmA9.js +1 -0
- package/dist/chunks/{context-noninteractive-DnH6Q9Lu.js → context-noninteractive-CTvyNimw.js} +1 -1
- package/dist/chunks/{conversation-GJxfkr6M.js → conversation-CooSju3g.js} +1 -1
- package/dist/chunks/conversation-DLLIOKYV.js +1 -0
- package/dist/chunks/{createSSHSession--bWmmIk9.js → createSSHSession-BdO35H6o.js} +1 -1
- package/dist/chunks/{createSession-DIr4sUp6.js → createSession-Br1g8qSD.js} +1 -1
- package/dist/chunks/createSession-CVG8SiEm.js +1 -0
- package/dist/chunks/{crossProjectResume-DKrtjTpm.js → crossProjectResume-DiKJb83I.js} +1 -1
- 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-BQiSFjc-.js} +1 -1
- package/dist/chunks/{datadog-DNCsyfSO.js → datadog-BE6D_6m0.js} +1 -1
- package/dist/chunks/datadog-C69i7cfI.js +1 -0
- package/dist/chunks/debug-8kgDrUfj.js +1 -0
- package/dist/chunks/{debug-IKW-jE7K.js → debug-DiuXEmUq.js} +1 -1
- package/dist/chunks/{debugUtils-D2981c0Z.js → debugUtils-3YYWvb3H.js} +1 -1
- package/dist/chunks/{desktop-B5cvrcOQ.js → desktop-W7SA8BFk.js} +1 -1
- package/dist/chunks/{detached-rfIUyc-B.js → detached-Cv9gAylK.js} +1 -1
- package/dist/chunks/{detectRepository-ReZ0Fz8Z.js → detectRepository-B1PMTLAU.js} +1 -1
- package/dist/chunks/detectRepository-_Kj817Vi.js +1 -0
- package/dist/chunks/{diff-cXAp9cNN.js → diff-CMtRjFUb.js} +1 -1
- package/dist/chunks/{directoryCompletion-DBM2o5kx.js → directoryCompletion-CeV63gvu.js} +1 -1
- package/dist/chunks/doctor-DEz8BHAz.js +1 -0
- package/dist/chunks/{effort-Br8KKHdx.js → effort-BAlVDBHq.js} +1 -1
- package/dist/chunks/{entry-4lIRMrLI.js → entry-DLqeVq5C.js} +2 -2
- package/dist/chunks/envLessBridgeConfig-3kCrKZl7.js +1 -0
- package/dist/chunks/envLessBridgeConfig-BfgXw47_.js +1 -0
- package/dist/chunks/{execFileNoThrow-COKYqVQj.js → execFileNoThrow-DResQRvR.js} +1 -1
- package/dist/chunks/{execSyncWrapper-DZJ3tNWF.js → execSyncWrapper-CWxMek26.js} +1 -1
- package/dist/chunks/{exit-Z9oWrqE4.js → exit-cyepwuyy.js} +1 -1
- package/dist/chunks/extra-usage-DlFeNGQD.js +1 -0
- package/dist/chunks/{extra-usage-core-CdL1ltqq.js → extra-usage-core-Dh4rVUI-.js} +1 -1
- package/dist/chunks/{extra-usage-DtAIhW74.js → extra-usage-nRFfBiXh.js} +1 -1
- package/dist/chunks/{extra-usage-noninteractive-DxxRI0Yx.js → extra-usage-noninteractive-D4Ya5KPm.js} +1 -1
- package/dist/chunks/{extraUsage-BYZdi44Y.js → extraUsage-DtWi8E78.js} +1 -1
- package/dist/chunks/extractMemories-BqN8fWZ5.js +1 -0
- package/dist/chunks/{fast-DKqiojzf.js → fast-DkUxqWhE.js} +1 -1
- package/dist/chunks/fast-NvqW2-t1.js +1 -0
- package/dist/chunks/{feedback-yB19xph5.js → feedback-Cn7Sbqxa.js} +1 -1
- package/dist/chunks/{file-D1cN3LMK.js → file-BZriE-XU.js} +1 -1
- package/dist/chunks/{files-DAzGtmzz.js → files-Cz1-PK3r.js} +1 -1
- package/dist/chunks/firstPartyEventLogger-AhXYSrkP.js +1 -0
- package/dist/chunks/{firstPartyEventLogger-hU-LPkje.js → firstPartyEventLogger-BQYrBdvD.js} +2 -2
- package/dist/chunks/{flushGate-ZFr8yv7F.js → flushGate-ebqQZF1t.js} +1 -1
- package/dist/chunks/{gemini-DqAv8_GY.js → gemini-Sr_00TsL.js} +1 -1
- package/dist/chunks/{generateRecap-lO2PDlx8.js → generateRecap-5d4l_ODy.js} +1 -1
- package/dist/chunks/{generateSessionName-48veu5dv.js → generateSessionName-DEAw5x_h.js} +1 -1
- package/dist/chunks/{genericProcessUtils-F1Qcb1sO.js → genericProcessUtils-DO7Fy0RJ.js} +1 -1
- package/dist/chunks/git-Cc1jAz6r.js +1 -0
- package/dist/chunks/{git-tyaWOgRL.js → git-Cgc8X5l2.js} +2 -2
- package/dist/chunks/{githubRepoPathMapping-BlR0BphY.js → githubRepoPathMapping-Tt-LdYFZ.js} +1 -1
- package/dist/chunks/{goal-Bn8Kz2Dp.js → goal-DCaI1NPN.js} +1 -1
- package/dist/chunks/{grok-DhnO_KDC.js → grok-CKlngG3b.js} +1 -1
- package/dist/chunks/{grove-DotW04-v.js → grove-DSWe6psK.js} +1 -1
- package/dist/chunks/{heapdump-DkZSKNbp.js → heapdump-OVbV05On.js} +1 -1
- package/dist/chunks/{help-DU_BcZtU.js → help-CRtX5VX9.js} +1 -1
- package/dist/chunks/hooks-DvtnNoYE.js +1 -0
- package/dist/chunks/{hooks-BTMWE5Qx.js → hooks-tpf90xd5.js} +1 -1
- package/dist/chunks/{hostGuard-Dh296c6q.js → hostGuard-t7QfbijF.js} +1 -1
- package/dist/chunks/{inboundAttachments-DVs3_m48.js → inboundAttachments-BZ6MKpxd.js} +1 -1
- package/dist/chunks/inboundAttachments-D5Ux2kCl.js +1 -0
- package/dist/chunks/{initReplBridge-D0Xec8S-.js → initReplBridge-CjuO6in6.js} +1 -1
- package/dist/chunks/{install-BkfXeXpv.js → install-DqpM2brU.js} +1 -1
- package/dist/chunks/{instrumentation-H0XRS1yG.js → instrumentation--Sx0y1Gk.js} +3 -3
- package/dist/chunks/{job-DKtLkF8V.js → job-D7B35Usp.js} +1 -1
- package/dist/chunks/{jwtUtils-C-ojmb8W.js → jwtUtils-CqXPjf-a.js} +1 -1
- package/dist/chunks/{keybindings-ez51eHHp.js → keybindings-JvAmBpLt.js} +1 -1
- package/dist/chunks/{language-BuRSO2sR.js → language-8Rnu_qxl.js} +1 -1
- package/dist/chunks/language-DaxZe0Xw.js +1 -0
- package/dist/chunks/{launchAgentsPlatform-BQyPdrHp.js → launchAgentsPlatform-CNPkOVzu.js} +1 -1
- package/dist/chunks/{launchLocalMemory-CWHAj7CX.js → launchLocalMemory-BxmDhENs.js} +1 -1
- package/dist/chunks/{launchLocalVault-D8iJdtsP.js → launchLocalVault-DQlTGA-g.js} +1 -1
- package/dist/chunks/{launchMemoryStores-W7jWG2uH.js → launchMemoryStores-EYAwxI8i.js} +1 -1
- package/dist/chunks/{launchOnboarding-q__LaLy1.js → launchOnboarding-CTu5Zf4E.js} +1 -1
- package/dist/chunks/{launchSchedule-BWi9F5vh.js → launchSchedule-CeHHSvO7.js} +1 -1
- package/dist/chunks/{launchSkillStore-4wd4MQBc.js → launchSkillStore-Bqh2Fru2.js} +1 -1
- package/dist/chunks/{launchTeleport-BlCf2QM_.js → launchTeleport-Crc3XVZX.js} +1 -1
- package/dist/chunks/{launchVault-C7u7LZV7.js → launchVault-BHLgpth_.js} +1 -1
- package/dist/chunks/loadAgentsDir-D7npVvsj.js +1 -0
- package/dist/chunks/{loadAgentsDir-nzr38hai.js → loadAgentsDir-ZQwvbURI.js} +66 -66
- package/dist/chunks/{loadPluginHooks-z1-zvBLw.js → loadPluginHooks-CaKvZVZI.js} +1 -1
- package/dist/chunks/localSearch-BU5oulbF.js +1 -0
- package/dist/chunks/{localSearch-B-L_ldos.js → localSearch-H0LchlTi.js} +1 -1
- package/dist/chunks/{log-B3eB4EFv.js → log-Duzb4o6h.js} +1 -1
- package/dist/chunks/{logoV2Utils-RQ160dI2.js → logoV2Utils-5lcUu53m.js} +1 -1
- package/dist/chunks/{magicDocs-BqZ0GewA.js → magicDocs-D1FIPmYg.js} +1 -1
- package/dist/chunks/main-B8XtFN2P.js +859 -0
- package/dist/chunks/{main-DeFMhaFE.js → main-CR7cXdgy.js} +3 -3
- package/dist/chunks/{mappers-CWykjGfP.js → mappers-DKU4RgE3.js} +1 -1
- package/dist/chunks/{mcp-DBwT4pa9.js → mcp-B06Mqsur.js} +4 -4
- package/dist/chunks/{mcp-DvZTaHZE.js → mcp-C0AjA07u.js} +1 -1
- package/dist/chunks/{mcp-CSFPAfaW.js → mcp-ghioDl7W.js} +1 -1
- package/dist/chunks/{memoize-BO31Ws9Q.js → memoize-DgMjqLtn.js} +1 -1
- package/dist/chunks/{memory-DcpPpYN0.js → memory-D-Q62bJ7.js} +1 -1
- package/dist/chunks/{metadata-BRLJvh61.js → metadata-CIx5CsoY.js} +1 -1
- package/dist/chunks/{mode-BkViT_0o.js → mode-DFZgqKBd.js} +1 -1
- package/dist/chunks/{model-DfFA3qMO.js → model-BgrLt7P7.js} +1 -1
- package/dist/chunks/model-aVc5c3Lz.js +1 -0
- package/dist/chunks/{model-CZktWw6o.js → model-fDWtIRVr.js} +1 -1
- package/dist/chunks/{nativeInstaller-GcIk7G2Y.js → nativeInstaller-DKe1pWoL.js} +1 -1
- package/dist/chunks/{onChangeAppState-DwGVi-BC.js → onChangeAppState-DaQ0R9Tw.js} +1 -1
- package/dist/chunks/{openai-B2wxZDQx.js → openai-DNS0-ivj.js} +1 -1
- package/dist/chunks/{overageCreditGrant-CjK49axw.js → overageCreditGrant-qHN3tnp2.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-BvKpHquo.js} +1 -1
- package/dist/chunks/parser-Bj3gOqFv.js +1 -0
- package/dist/chunks/{parser-CQrasoUB.js → parser-TYEkLFgh.js} +1 -1
- package/dist/chunks/{partition-CxRF7T-f.js → partition-Cv11dD5P.js} +1 -1
- package/dist/chunks/{passes-U_h-hNu-.js → passes-DQdM2Ssq.js} +1 -1
- package/dist/chunks/{path-BCSE0S-c.js → path-Cu_AKqg6.js} +1 -1
- package/dist/chunks/{permissions-B8epy16o.js → permissions-DB_2mmCl.js} +1 -1
- package/dist/chunks/{pidLock-CBJDnBG_.js → pidLock-DchmaAK6.js} +2 -2
- package/dist/chunks/{pipeTransport-D3Qx9v1V.js → pipeTransport-7GIO6GCA.js} +1 -1
- package/dist/chunks/{plan-BAhStVci.js → plan-D8dQDl8W.js} +1 -1
- package/dist/chunks/{platform-EtecGacO.js → platform-B5dCGT8t.js} +1 -1
- package/dist/chunks/{plugin-D9huNnv6.js → plugin-w8MqsKHn.js} +1 -1
- package/dist/chunks/{pluginAutoupdate-BfmyxR5g.js → pluginAutoupdate-7FFHzSRz.js} +1 -1
- package/dist/chunks/{pluginBlocklist-03sZaZa6.js → pluginBlocklist-Cw_l-yal.js} +1 -1
- package/dist/chunks/{pluginCliCommands-P2Ndi1r1.js → pluginCliCommands-BtYWRxhS.js} +1 -1
- package/dist/chunks/{pluginFlagging-BVy7Xv_0.js → pluginFlagging-_WUQP3Lq.js} +1 -1
- package/dist/chunks/{pluginOperations-Cz37qcjF.js → pluginOperations-BOkST1qE.js} +1 -1
- package/dist/chunks/{pluginStartupCheck-w24D-wwk.js → pluginStartupCheck-BelpzwZI.js} +1 -1
- package/dist/chunks/pluginStartupCheck-XBLJZZys.js +1 -0
- package/dist/chunks/{plugins-B0hiIN4q.js → plugins-6px6K1fh.js} +1 -1
- package/dist/chunks/policyLimits-C07tQ0Wr.js +1 -0
- package/dist/chunks/{poor-CfbMKZNJ.js → poor-D3T_8wwf.js} +1 -1
- package/dist/chunks/poorMode-BdBDiOFD.js +1 -0
- package/dist/chunks/{poorMode-Bsw2V-V_.js → poorMode-BqyVuBu-.js} +1 -1
- package/dist/chunks/{print-ozjC0Mhg.js → print-DcQSuK0v.js} +4 -4
- package/dist/chunks/{privacy-settings-DeGoBRrZ.js → privacy-settings-D5zxu4Aa.js} +1 -1
- package/dist/chunks/{processBashCommand-loWZ8MSE.js → processBashCommand-CEqA4QZi.js} +1 -1
- package/dist/chunks/{processSlashCommand-BdouajZb.js → processSlashCommand-DMpFk59M.js} +1 -1
- package/dist/chunks/prompt-CKvoqUC3.js +1 -0
- package/dist/chunks/prompt-aXZPR3q8.js +1 -0
- package/dist/chunks/{prompt-Bef63FhB.js → prompt-wys9CwDo.js} +1 -1
- package/dist/chunks/{promptEditor-foiayhdY.js → promptEditor-D6HzjcMS.js} +1 -1
- package/dist/chunks/{protocolHandler-BsiB1oW_.js → protocolHandler-BXlx1N7v.js} +1 -1
- package/dist/chunks/{proxy-Cn2YwITp.js → proxy-CHnxhNZI.js} +1 -1
- package/dist/chunks/{rate-limit-options-DTJPDcTr.js → rate-limit-options-1hc-RyNR.js} +1 -1
- package/dist/chunks/{rcDebugLog-BUuD-X1D.js → rcDebugLog-CivJaJ3V.js} +1 -1
- package/dist/chunks/{reconciler-DqXTmV3J.js → reconciler-BKX4jh34.js} +1 -1
- package/dist/chunks/{referral-DP_GshTS.js → referral-Cu9bEOFE.js} +1 -1
- package/dist/chunks/{refresh-CNzXPAFw.js → refresh-vJbxW4a1.js} +1 -1
- package/dist/chunks/{registerProtocol-CjxlFsKw.js → registerProtocol-B_XbLDQO.js} +3 -3
- package/dist/chunks/{release-notes-BxgK8zWO.js → release-notes-CavWoMQR.js} +1 -1
- package/dist/chunks/{releaseNotes-CbSktIJW.js → releaseNotes-Di6OaHF7.js} +2 -2
- package/dist/chunks/{reload-plugins-CDu6yU5-.js → reload-plugins-ofeLn07p.js} +1 -1
- package/dist/chunks/{remote-env-B4HnhISc.js → remote-env-dXzHAuD6.js} +1 -1
- package/dist/chunks/{remoteBridgeCore-D-wG5jau.js → remoteBridgeCore-CmwkjiTK.js} +1 -1
- package/dist/chunks/{remoteManagedSettings-B7gt0VAX.js → remoteManagedSettings-Co-CxR67.js} +1 -1
- package/dist/chunks/{rename-DlbMb24l.js → rename-CtjP0lop.js} +1 -1
- package/dist/chunks/{renderOptions-5kWQpVr2.js → renderOptions-DOXmueQV.js} +1 -1
- package/dist/chunks/{resume-BB5iBogS.js → resume-C5h5JvY1.js} +1 -1
- package/dist/chunks/{ripgrep-BvDwiKJ3.js → ripgrep-BN_g-F7X.js} +1 -1
- package/dist/chunks/ripgrep-hOjrgpMp.js +1 -0
- package/dist/chunks/{runtimeObserver-Ci-5gvYg.js → runtimeObserver-B93v1AxE.js} +2 -2
- package/dist/chunks/{runtimeObserver-BNH2WGE3.js → runtimeObserver-DOZFrqJu.js} +1 -1
- package/dist/chunks/sandbox-adapter-CO5GuywY.js +1 -0
- package/dist/chunks/{sandbox-toggle-B2Yk4y2V.js → sandbox-toggle-TiLGFwaZ.js} +1 -1
- package/dist/chunks/searchExtraTools-CXZJU2Kv.js +1 -0
- package/dist/chunks/{session-Bmx7L3Mt.js → session-v9tKHhU9.js} +1 -1
- package/dist/chunks/{sessionDiscovery-DcEAr5vJ.js → sessionDiscovery-4byQKOnc.js} +1 -1
- package/dist/chunks/sessionFileAccessHooks-BUyIQVzL.js +1 -0
- package/dist/chunks/sessionMemory-ZsxCLHYd.js +1 -0
- package/dist/chunks/{sessionMemory-Bsg2unYX.js → sessionMemory-e6YpTUhW.js} +1 -1
- package/dist/chunks/sessionMemoryUtils-BD_dqyYB.js +1 -0
- package/dist/chunks/sessionObserver-DNItJztR.js +1 -0
- package/dist/chunks/{sessionObserver-DQwHsDrM.js → sessionObserver-OgY9BUP4.js} +1 -1
- package/dist/chunks/sessionStorage-xvxpRETp.js +1 -0
- package/dist/chunks/{sessionTitle-B8jcexkQ.js → sessionTitle-Bph6GO4F.js} +1 -1
- package/dist/chunks/{sessionTracing-BuLsL6qA.js → sessionTracing-BBxhPccY.js} +1 -1
- package/dist/chunks/{settings-5PQdphqC.js → settings-BhvhCpVh.js} +2 -2
- package/dist/chunks/settingsSync-D2B5K4BT.js +1 -0
- package/dist/chunks/{setup-BKEnSLR9.js → setup-CEnNEK6Z.js} +2 -2
- package/dist/chunks/{shadowedRuleDetection-7Z8ezTKF.js → shadowedRuleDetection-DDSOFi1W.js} +1 -1
- package/dist/chunks/{shellQuote-fB02N16J.js → shellQuote-yXoC_y5m.js} +1 -1
- package/dist/chunks/{sideQuestion-CYdNATPW.js → sideQuestion-CAiA6jAf.js} +1 -1
- package/dist/chunks/sink-CyKOf5TT.js +1 -0
- package/dist/chunks/{sink-DjKoYMsA.js → sink-DxPJ4khU.js} +1 -1
- package/dist/chunks/{sinks-GryGVRT8.js → sinks-BNo3DvxO.js} +2 -2
- package/dist/chunks/sinks-CHgtwDha.js +1 -0
- package/dist/chunks/{skill-learning-E8tQed-Q.js → skill-learning-Dx1o4mMo.js} +1 -1
- package/dist/chunks/{skillChangeDetector-A8SAuyo9.js → skillChangeDetector-BRBCwQ2w.js} +1 -1
- package/dist/chunks/{skillGapStore-B5rl12bV.js → skillGapStore-BV_6qzxU.js} +1 -1
- package/dist/chunks/{skillGapStore-CjJrxxjk.js → skillGapStore-Zvqiyxds.js} +2 -2
- package/dist/chunks/{skillGenerator-BDR_z3-X.js → skillGenerator-jJQDphQ8.js} +2 -2
- package/dist/chunks/skillLearning-BH7EAU1m.js +1 -0
- package/dist/chunks/{skillLearning-BQtfFE0g.js → skillLearning-BTT3_yGc.js} +1 -1
- package/dist/chunks/{skillPanel-yR8Oi-mO.js → skillPanel-OW2M6SZr.js} +3 -3
- package/dist/chunks/{skillSearchPanel-DUQQUCUS.js → skillSearchPanel-C0Y56c5N.js} +4 -4
- package/dist/chunks/{skills-NAZQ3j-t.js → skills-BFsyLP33.js} +1 -1
- package/dist/chunks/{startupProfiler-DxRQteII.js → startupProfiler-BquH_Yqm.js} +1 -1
- package/dist/chunks/startupProfiler-CYCH-qos.js +1 -0
- 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-CrPmPT8f.js} +1 -1
- package/dist/chunks/{status-BbdeubJG.js → status-BO5J2MAe.js} +1 -1
- package/dist/chunks/{status-is_Bg_IB.js → status-DHJbK4pV.js} +1 -1
- package/dist/chunks/{statusNoticeHelpers-CQ7CUugR.js → statusNoticeHelpers-CqeUBySi.js} +1 -1
- package/dist/chunks/{stickers-qJoNhPk4.js → stickers-BLFmyHZV.js} +1 -1
- package/dist/chunks/{stringUtils-CvXbHQRH.js → stringUtils-D_g2L6A4.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-M2AEtXjW.js} +1 -1
- package/dist/chunks/{tasks-HzsYNTZ1.js → tasks-CoOs_Qkj.js} +1 -1
- package/dist/chunks/{teleport-hN3cAbYC.js → teleport-DjIgQeBB.js} +1 -1
- package/dist/chunks/{templateJobs-CIv_ysje.js → templateJobs-Cl50Qw0s.js} +1 -1
- package/dist/chunks/{terminalSetup-CxniwSF-.js → terminalSetup-Bdh9K31U.js} +1 -1
- package/dist/chunks/{terminalSetup-C0PF87iu.js → terminalSetup-nvS3KCDG.js} +1 -1
- package/dist/chunks/{theme-BKIHX_Dx.js → theme-DgCIr0jU.js} +1 -1
- package/dist/chunks/thinkback-BSv_fvbV.js +1 -0
- package/dist/chunks/{thinkback-mT-8FIT-.js → thinkback-ERCQ86CR.js} +1 -1
- package/dist/chunks/{thinkback-play-Cfk49mvF.js → thinkback-play-DNB0IWYt.js} +1 -1
- package/dist/chunks/{tmux-CbsW-VDJ.js → tmux-ZZk68JBq.js} +1 -1
- package/dist/chunks/{toolEventObserver-8FQtxeVv.js → toolEventObserver-9-5Ne25Z.js} +1 -1
- package/dist/chunks/{toolEventObserver-B1xvyKdE.js → toolEventObserver-9XCQXiMx.js} +1 -1
- package/dist/chunks/{toolPool-CHVDZqh7.js → toolPool-uQKZRMKg.js} +1 -1
- package/dist/chunks/trustedDevice-0ej6e3nx.js +1 -0
- package/dist/chunks/{trustedDevice-BYCh1ff7.js → trustedDevice-nqhuw4tp.js} +1 -1
- package/dist/chunks/{tui-fTa_pzdA.js → tui-C2yuCuOU.js} +3 -3
- package/dist/chunks/{types-a7X-tJpJ.js → types-Cnorfsss.js} +1 -1
- package/dist/chunks/{udsClient-Cg9bBD0p.js → udsClient-CiFj4M_h.js} +1 -1
- package/dist/chunks/{ultrareviewCommand-DCFRZsKp.js → ultrareviewCommand-BMBHepdu.js} +1 -1
- package/dist/chunks/undercover-6UUO38fQ.js +1 -0
- package/dist/chunks/{undercover-CsLPQb-a.js → undercover-DDgIKbO5.js} +3 -3
- package/dist/chunks/{up-dO5BcPaq.js → up-D6bNw_tT.js} +1 -1
- package/dist/chunks/{updateCCB-CfUnkOLT.js → updateCCB-B-OlpLjA.js} +1 -1
- package/dist/chunks/{upgrade-kpttjebY.js → upgrade-BN20nsCH.js} +1 -1
- package/dist/chunks/upgrade-DYqlCH80.js +1 -0
- package/dist/chunks/{upload-DDhQqV8n.js → upload-BQGByiXE.js} +1 -1
- package/dist/chunks/{upstreamproxy-CvcjNY7J.js → upstreamproxy-os5rw0Vg.js} +1 -1
- package/dist/chunks/{usage-CJ5w0907.js → usage-D_sqm8us.js} +1 -1
- package/dist/chunks/usage-DolSCKGi.js +1 -0
- package/dist/chunks/{useExitOnCtrlCDWithKeybindings-yAroCqu4.js → useExitOnCtrlCDWithKeybindings-vzUoPY51.js} +1 -1
- package/dist/chunks/useMainLoopModel-cZd8EKo5.js +1 -0
- package/dist/chunks/{useManagePlugins-CTtPaQRP.js → useManagePlugins-DgGZBvXV.js} +1 -1
- package/dist/chunks/{useMergedTools-CZJffsmf.js → useMergedTools-Bb4XbC9d.js} +1 -1
- package/dist/chunks/{useSearchInput-C-CqUK6w.js → useSearchInput-B1UOjxAI.js} +1 -1
- package/dist/chunks/{useSettingsErrors-BWlJCgYF.js → useSettingsErrors-BLbvu4--.js} +1 -1
- package/dist/chunks/{util-DJV0joAW.js → util-CxlfALM4.js} +1 -1
- package/dist/chunks/validatePlugin-n8a4W_jI.js +1 -0
- package/dist/chunks/{vim-n8-UT5w-.js → vim-DLWBHwVM.js} +1 -1
- package/dist/chunks/{which-BBCjXfI2.js → which-sEFQXpaX.js} +1 -1
- package/dist/chunks/windowsPaths-BLevJOlm.js +1 -0
- package/dist/chunks/{windowsPaths-D6T_3XaU.js → windowsPaths-N_YmYY6k.js} +1 -1
- package/dist/chunks/{workSecret-C_lv0dRh.js → workSecret-DvniZR71.js} +1 -1
- package/dist/chunks/{workerRegistry-BdHi7_sN.js → workerRegistry-CFnGtb3L.js} +1 -1
- package/dist/chunks/worktree-Dr_WzlXs.js +1 -0
- package/dist/cli.js +1 -1
- package/package.json +1 -1
- package/dist/chunks/ApproveApiKey-DfAPwDix.js +0 -1
- 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/Grove-CelgLWH4.js +0 -1
- package/dist/chunks/Messages-jCoW_1Rr.js +0 -11
- package/dist/chunks/REPL-DcpN3MRC.js +0 -1
- package/dist/chunks/RemoteSessionManager-Tx1N2uVL.js +0 -2
- package/dist/chunks/SearchExtraToolsTool-D3VOFq9R.js +0 -1
- package/dist/chunks/WelcomeV2-BTfttGcv.js +0 -1
- 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/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-d06JByZn.js +0 -1
- package/dist/chunks/caches-BuTIAOtY.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/completionCache-CW8lKIgy.js +0 -1
- package/dist/chunks/config-0cRberzR.js +0 -1
- package/dist/chunks/config-BrxKpHpR.js +0 -1
- package/dist/chunks/context-noninteractive-rUZ3ydmJ.js +0 -1
- package/dist/chunks/conversation-oK3aFzqO.js +0 -1
- package/dist/chunks/createSession-DM4acqaC.js +0 -1
- package/dist/chunks/cwd-D-tY2NKc.js +0 -1
- package/dist/chunks/datadog-ByS7LGGa.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/envLessBridgeConfig-CGuIxFzJ.js +0 -1
- package/dist/chunks/envLessBridgeConfig-D_Jg4fJy.js +0 -1
- package/dist/chunks/extra-usage-BS4aVOt5.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/git-BE_FiJZp.js +0 -1
- package/dist/chunks/hooks-DONAb_nq.js +0 -1
- package/dist/chunks/inboundAttachments-BcEgi49j.js +0 -1
- package/dist/chunks/language-Da4KNbjm.js +0 -1
- package/dist/chunks/loadAgentsDir-Dgd-fzNt.js +0 -1
- package/dist/chunks/localSearch-D-FprOMr.js +0 -1
- package/dist/chunks/main-y7LJ5qUc.js +0 -1243
- package/dist/chunks/model--z4Di9QO.js +0 -1
- package/dist/chunks/parser-BlM_Fk4J.js +0 -1
- package/dist/chunks/pluginStartupCheck-BqUwHcMD.js +0 -1
- package/dist/chunks/policyLimits-Dem-XJ_h.js +0 -1
- package/dist/chunks/poorMode-jvImnkty.js +0 -1
- package/dist/chunks/prompt-C7wd1H_i.js +0 -1
- package/dist/chunks/prompt-DIoNqZvO.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-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/settingsSync-BDeuErb5.js +0 -1
- package/dist/chunks/sink-iYxWapbU.js +0 -1
- package/dist/chunks/sinks-jfaIjsRJ.js +0 -1
- package/dist/chunks/skillLearning-C8ihdryM.js +0 -1
- package/dist/chunks/startupProfiler-B0m6crkd.js +0 -1
- package/dist/chunks/state-53JDbNQM.js +0 -1
- package/dist/chunks/systemPromptSections-IePG5K8r.js +0 -1
- package/dist/chunks/thinkback-BA4cMz4D.js +0 -1
- package/dist/chunks/trustedDevice-DnIWErCt.js +0 -1
- package/dist/chunks/undercover-B-kKUWtK.js +0 -1
- package/dist/chunks/upgrade-CngUwvY4.js +0 -1
- package/dist/chunks/usage-eZRwLa77.js +0 -1
- package/dist/chunks/useMainLoopModel-BNFW-g8E.js +0 -1
- package/dist/chunks/validatePlugin-CRmpIGLV.js +0 -1
- package/dist/chunks/windowsPaths-DUKTzBck.js +0 -1
- package/dist/chunks/worktree-YDeHMlHZ.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as e,n as t,o as n,r}from"./rolldown-runtime-DaDcL9Zw.js";import{c as i,l as a,n as o,o as s}from"./envUtils-DSxRz_kt.js";import{n as c,t as l}from"./defineProperty-C-QyHrDq.js";import{n as u,t as d}from"./figures-5ThXQEtq.js";import{n as f,t as p}from"./axios-DaWTGg7G.js";import{C as m,D as h,Ft as g,Gr as _,Gt as v,H as y,I as b,Kr as x,Kt as S,Lt as C,Mr as w,P as T,Pn as E,Rn as D,T as O,Tt as k,Vn as A,Wt as j,Xn as M,Xt as N,Y as ee,Yt as P,Z as F,Zn as I,_n as te,bn as ne,ct as L,di as R,dr as re,et as ie,fi as z,ft as ae,hn as oe,ir as se,j as ce,lr as le,lt as ue,ot as de,q as fe,qr as pe,t as B,tr as V,ui as H,vn as me,x as he,y as ge,yn as U,yt as _e}from"./src-CDCSSo0U2.js";import{t as ve}from"./jsx-runtime-Bb4Xn-E0.js";import{A as ye,C as be,S as xe,a as Se,b as Ce,l as we,r as Te,t as Ee,w as De}from"./v4-jw6qOKwQ.js";import{At as Oe,B as ke,Bt as Ae,D as je,Dn as Me,H as Ne,Hn as Pe,Ht as Fe,Jn as Ie,K as Le,Mt as Re,Nt as ze,Pt as Be,Rt as Ve,Sr as He,Tt as Ue,Un as We,Ut as Ge,V as Ke,Vt as qe,Wt as Je,Yn as Ye,Yt as Xe,Z as Ze,Zt as Qe,_r as $e,b as et,bn as tt,dn as nt,en as rt,fn as it,ht as at,jt as ot,kt as st,nt as ct,ot as lt,pn as ut,pt as dt,tn as ft,un as pt,vr as mt,xr as ht,yr as gt,yt as _t,z as vt,zt as yt}from"./state-4KQ3kaqz.js";import{$C as bt,$S as xt,$T as St,$_ as Ct,$d as wt,$f as Tt,$m as Et,$w as Dt,Af as Ot,Ah as kt,Ao as At,Ap as jt,As as Mt,Au as Nt,Av as Pt,Ax as Ft,Ay as It,BC as Lt,Bb as Rt,Bc as zt,Bd as Bt,Bf as Vt,Bg as Ht,Bm as Ut,Bn as Wt,Bo as Gt,Bp as Kt,Bs as qt,Bw as Jt,Bx as Yt,C as Xt,CS as Zt,Cf as Qt,Cg as $t,Ci as en,Cl as tn,Cr as nn,Ct as rn,D as an,DC as on,DS as sn,Db as cn,Dg as ln,Du as un,Dw as dn,Dx as fn,Dy as pn,E as mn,EC as hn,ES as gn,Ec as _n,Ef as vn,Em as yn,Eo as bn,Er as xn,Es as Sn,Et as Cn,Eu as wn,Ex as Tn,Ey as En,FC as W,Fb as Dn,Fd as On,Ff as kn,Fh as An,Fm as jn,Fo as Mn,Fp as Nn,Fs as Pn,Ft as Fn,G as In,GC as Ln,GT as Rn,Gb as zn,Gd as Bn,Gf as Vn,Gl as Hn,Gm as Un,Gt as Wn,Gu as Gn,Gv as Kn,Gw as qn,Gx as Jn,Gy as Yn,HC as Xn,HD as Zn,HS as Qn,HT as $n,Hb as er,Hd as tr,Hf as nr,Hl as rr,Hm as ir,Hs as ar,Hv as or,Hw as sr,Hx as cr,Hy as lr,I as ur,IE as dr,Id as fr,If as pr,Il as mr,Im as hr,Io as gr,Ip as _r,Ir as vr,Is as G,Ix as yr,J as br,JC as xr,JD as K,JE as Sr,JS as Cr,Jf as wr,Jg as Tr,Jl as Er,Jn as Dr,Jo as Or,Jr as kr,Js as Ar,Jw as jr,Jy as Mr,KC as Nr,KS as Pr,KT as Fr,Kb as Ir,Kf as Lr,Ki as Rr,Kl as zr,Ks as Br,Ku as Vr,Kx as Hr,LC as Ur,LT as Wr,Lb as Gr,Ld as Kr,Lf as qr,Lg as Jr,Ll as Yr,Lm as Xr,Ln as Zr,Lp as Qr,Ls as $r,Lx as ei,Ly as ti,M as ni,Mb as ri,Mc as ii,Mf as ai,Mp as oi,Mr as si,Mu as ci,Mx as li,My as ui,N as di,NE as fi,Nb as pi,Nd as mi,Nf as hi,Ng as gi,Nl as _i,Np as vi,Nu as yi,Nx as bi,Ny as xi,OS as Si,OT as Ci,Ob as wi,Oc as Ti,Og as Ei,Oo as Di,Op as Oi,Ou as ki,Ox as Ai,Oy as ji,P as Mi,PC as Ni,Pb as Pi,Pd as Fi,Pf as Ii,Pg as Li,Ph as Ri,Pl as zi,Pm as Bi,Pn as Vi,Pp as Hi,Pr as Ui,Pu as Wi,Q as Gi,QC as Ki,QS as qi,Qa as Ji,Qd as Yi,Qf as Xi,Qi as Zi,Qm as Qi,Qn as $i,Qo as ea,Qs as ta,Qu as na,Qw as ra,Qx as ia,Qy as aa,RC as oa,Ra as sa,Rb as ca,Rc as la,Rg as ua,Ri as da,Rm as fa,Rp as pa,Rs as ma,Rw as ha,Rx as ga,Sb as _a,Sf as va,Sg as ya,Sl as ba,So as xa,Sw as Sa,Sy as Ca,TS as wa,Tb as Ta,Tf as Ea,Tm as Da,To as Oa,Tu as ka,Tv as Aa,Tx as ja,UC as Ma,Ua as Na,Ub as Pa,Ud as Fa,Uf as Ia,Ul as La,Um as Ra,Up as za,Ut as Ba,Uu as Va,Uw as Ha,Ux as Ua,Uy as Wa,VD as Ga,VT as Ka,Va as qa,Vb as Ja,Vc as Ya,Vd as Xa,Vf as Za,Vg as Qa,Vi as $a,Vl as eo,Vm as to,Vs as no,Vu as ro,Vw as io,Vx as ao,Vy as oo,W as so,WS as co,Wb as lo,Wd as uo,Wf as fo,Wi as po,Wl as mo,Wm as ho,Wp as go,Wu as _o,Wv as vo,Ww as yo,Wx as bo,Wy as xo,X as So,XC as Co,XS as wo,Xb as To,Xg as Eo,Xm as Do,Xu as Oo,Xw as ko,Xx as Ao,YC as jo,YD as Mo,Yb as No,Yu as Po,Yw as Fo,Yy as Io,Z as Lo,ZC as Ro,ZS as zo,Zg as Bo,Zi as Vo,Zm as Ho,Zs as Uo,Zt as Wo,Zu as Go,Zw as Ko,_C as qo,_b as Jo,_l as Yo,_m as Xo,_p as Zo,_u as Qo,_v as $o,_x as es,aC as ts,aO as ns,aT as rs,aa as is,ab as as,ac as os,af as ss,ao as cs,ap as ls,aw as us,ax as ds,b as fs,bb as ps,bf as ms,bg as hs,bo as gs,bw as _s,cD as vs,cE as ys,cS as bs,cT as xs,ca as Ss,cl as Cs,cm as ws,cp as Ts,cs as Es,cu as Ds,cx as Os,cy as ks,dC as As,dS as js,dT as Ms,db as Ns,dh as Ps,dm as Fs,dn as Is,do as Ls,dx as Rs,eC as zs,eT as Bs,eb as Vs,eh as Hs,ei as Us,en as Ws,ep as Gs,es as Ks,et as qs,ev as Js,ew as Ys,ex as Xs,fC as Zs,fS as Qs,fb as $s,fh as ec,fi as tc,fm as nc,fp as rc,fs as ic,fx as ac,fy as oc,gb as sc,gl as cc,gm as lc,gp as uc,gs as dc,gu as fc,gv as pc,gx as mc,hC as hc,hD as gc,hT as _c,hb as vc,hi as yc,hl as bc,hm as xc,ho as Sc,hp as Cc,hu as wc,hx as Tc,iC as Ec,iO as Dc,ib as Oc,id as kc,if as Ac,ih as jc,im as Mc,io as Nc,ip as Pc,it as Fc,iu as Ic,iw as Lc,ix as Rc,jc as zc,jf as Bc,jg as Vc,jm as Hc,jp as Uc,jr as Wc,ju as Gc,jx as Kc,kC as qc,kb as Jc,kc as Yc,kg as Xc,kh as Zc,km as Qc,ko as $c,kv as el,kx as tl,ky as nl,lC as rl,lD as il,lE as al,lS as q,lT as ol,lh as sl,li as cl,ll,lm as ul,lt as dl,lu as fl,lx as pl,mC as ml,mD as hl,mT as gl,ma as _l,mb as vl,mm as yl,mo as bl,mp as xl,mr as Sl,mu as Cl,mx as wl,nC as Tl,na as El,nb as Dl,nd as Ol,nm as kl,no as Al,nr as jl,nw as Ml,nx as Nl,oC as Pl,oE as Fl,oO as Il,oS as Ll,oT as Rl,oa as zl,oc as Bl,od as Vl,ol as Hl,op as Ul,or as Wl,os as Gl,ox as Kl,pC as ql,pD as Jl,pa as Yl,pb as Xl,ph as Zl,pi as Ql,pm as $l,po as eu,pu as tu,py as nu,q as ru,qE as iu,qS as au,qT as ou,qf as su,qg as cu,qi as lu,ql as uu,qo as du,qv as fu,qw as pu,qx as mu,rC as hu,rO as gu,ra as _u,rb as vu,rd as yu,rg as bu,rh as xu,rm as Su,ro as Cu,rp as wu,rw as Tu,rx as Eu,sC as Du,sD as Ou,sO as ku,sS as Au,sa as ju,sd as Mu,sh as Nu,si as Pu,sl as Fu,sm as Iu,su as Lu,sx as Ru,sy as zu,tC as Bu,tE as Vu,ta as Hu,tb as Uu,tm as Wu,tp as Gu,tt as Ku,tw as qu,tx as Ju,uC as Yu,uE as Xu,uS as J,ua as Zu,uh as Qu,ul as $u,um as ed,uo as td,ur as nd,ut as rd,uu as id,ux as ad,vi as od,vp as sd,vs as cd,vu as ld,vw as ud,wS as dd,wb as fd,wf as pd,wi as md,wu as hd,wx as gd,wy as _d,x as vd,xb as yd,xf as bd,xv as xd,xw as Sd,yf as Cd,yg as wd,yn as Td,yo as Ed,ys as Dd,yv as Od,yw as kd,zC as Ad,zE as jd,zT as Md,za as Nd,zb as Pd,zc as Fd,zf as Id,zg as Ld,zl as Rd,zm as zd,zn as Bd,zo as Vd,zp as Hd,zs as Ud,zw as Wd,zx as Gd,zy as Kd}from"./loadAgentsDir-nzr38hai.js";import{n as qd,t as Jd}from"./cwd-BuJhkTrc.js";import{D as Yd,E as Xd,G as Zd,J as Qd,O as $d,U as ef,Y as tf,_ as nf,h as rf,j as af,l as of,nt as sf,ot as cf,p as Y,st as lf,x as uf,z as df}from"./debug-IKW-jE7K.js";import{B as ff,Bt as pf,Ft as mf,Ht as hf,It as gf,Jt as _f,Kt as vf,L as yf,Pt as bf,St as xf,Ut as Sf,Vt as Cf,Wt as wf,Xt as Tf,Zt as Ef,_n as Df,c as Of,cn as kf,dn as Af,f as jf,ft as Mf,g as Nf,gn as Pf,n as Ff,vn as If,y as Lf}from"./settings-5PQdphqC.js";import{P as Rf,b as zf,c as Bf,g as Vf,l as Hf,n as Uf}from"./config-C7YHKCPV.js";import{M as Wf,_ as Gf,a as Kf,d as qf,i as Jf,j as Yf}from"./git-tyaWOgRL.js";import{r as Xf,t as Zf}from"./execFileNoThrow-COKYqVQj.js";import{B as Qf,L as $f,N as ep,R as tp,U as np,Y as rp,k as ip,o as ap,s as X}from"./log-B3eB4EFv.js";import{n as op,t as sp}from"./memoize-BO31Ws9Q.js";import{n as cp,t as lp}from"./which-BBCjXfI2.js";import{i as up,o as dp}from"./platform-EtecGacO.js";import{i as fp,n as pp,o as mp,r as hp}from"./path-BCSE0S-c.js";import{D as gp,E as _p,T as vp,f as yp,l as bp}from"./file-D1cN3LMK.js";import{s as xp,u as Sp}from"./types-a7X-tJpJ.js";import{n as Cp,r as Z}from"./analytics-BotDBGh0.js";import{c as wp,n as Tp,s as Ep,t as Dp}from"./intl-cKc-V6Mq.js";import{T as Op,b as kp,d as Ap,f as jp,u as Mp,y as Np}from"./startupProfiler-DxRQteII.js";import{n as Pp,t as Fp}from"./lazySchema-uxlVVNM1.js";import{l as Ip,u as Lp}from"./oauth-BqJqV-2M.js";import{n as Rp,t as zp}from"./bundledMode--fG1S62b.js";import{a as Bp,d as Vp,l as Hp,o as Up,r as Wp,s as Gp}from"./stringUtils-CvXbHQRH.js";import{C as Kp,Ct as qp,D as Jp,Dt as Yp,Er as Xp,Hn as Zp,It as Qp,Kt as $p,Qr as em,T as tm,Tr as nm,Ut as rm,Vn as im,Vt as am,Xr as om,Z as sm,Zt as cm,_ as lm,at as um,b as dm,ci as fm,cr as pm,ct as mm,en as hm,er as gm,h as _m,ht as vm,ir as ym,it as bm,jt as xm,lt as Sm,m as Cm,nn as wm,nr as Tm,nt as Em,oi as Dm,ot as Om,qn as km,rt as Am,si as jm,sr as Mm,st as Nm,tt as Pm,u as Fm,wt as Im,x as Lm}from"./model-DfFA3qMO.js";import{Bt as Rm,Cn as zm,Ct as Bm,Ot as Vm,Vt as Hm,_n as Um,fn as Wm,kt as Gm,ln as Km,pn as qm,rn as Jm,st as Ym,un as Xm,vn as Zm,wt as Qm,xn as $m}from"./prompt-Bef63FhB.js";import{s as eh,u as th}from"./metadata-BRLJvh61.js";import{a as nh,i as rh,r as ih}from"./shellQuote-fB02N16J.js";import{a as ah}from"./ripgrep-BvDwiKJ3.js";import{a as oh,o as sh,s as ch}from"./fileStateCache-DDW5toIs.js";import{C as lh,N as uh,S as dh,T as fh,b as ph,d as mh,f as hh,j as gh,st as _h,w as vh,x as yh,y as bh}from"./rcDebugLog-BUuD-X1D.js";import{T as xh,c as Sh,r as Ch,w as wh}from"./sessionTracing-BuLsL6qA.js";import{i as Th,n as Eh,r as Dh}from"./parser-CQrasoUB.js";import{c as Oh,l as kh}from"./commitAttribution-Cm40fdNU.js";import{n as Ah,t as jh}from"./poorMode-Bsw2V-V_.js";import{a as Mh,f as Nh,l as Ph,o as Fh}from"./api-TgV7fl9V.js";import{r as Ih,t as Lh}from"./config-CLmFk-5V.js";import{l as Rh,u as zh}from"./referral-DP_GshTS.js";import{i as Bh,m as Vh,n as Hh,p as Uh}from"./terminalSetup-C0PF87iu.js";import{n as Wh,t as Gh}from"./browser-Bd7GeBH1.js";import{i as Kh,r as qh}from"./bridgeEnabled--F-6TUi4.js";import{n as Jh,r as Yh}from"./undercover-CsLPQb-a.js";import{t as Xh}from"./lib-BlVGipXx.js";import{t as Zh}from"./Dialog-vfLXEPed.js";import{n as Qh,t as $h}from"./mappers-CWykjGfP.js";import{n as eg,r as tg}from"./sessionTitle-B8jcexkQ.js";import{t as ng}from"./bridgeMessaging-CqbLTDcx.js";import{C as rg,S as ig,d as ag,l as og}from"./pidLock-CBJDnBG_.js";import{n as sg,t as cg}from"./nativeInstaller-GcIk7G2Y.js";import{r as lg,t as ug}from"./pipeTransport-D3Qx9v1V.js";import{t as dg}from"./useManagePlugins-CTtPaQRP.js";import{n as fg,t as pg}from"./MCPConnectionManager-BX0LMz9J.js";import{i as mg,n as hg,r as gg,t as _g}from"./reconciler-DqXTmV3J.js";import{n as vg,t as yg}from"./toolPool-CHVDZqh7.js";import{a as bg,c as xg,i as Sg,l as Cg,r as wg,t as Tg,u as Eg}from"./MessageSelector-_UZB8cGb.js";import{n as Dg,t as Og}from"./useExitOnCtrlCDWithKeybindings-yAroCqu4.js";import{n as kg,t as Ag}from"./sideQuestion-CYdNATPW.js";import{a as jg,n as Mg,o as Ng,r as Pg,s as Fg,t as Ig}from"./skillChangeDetector-A8SAuyo9.js";import{n as Lg,t as Rg}from"./refresh-CNzXPAFw.js";import{i as zg,n as Bg,r as Vg,t as Hg}from"./directoryCompletion-DBM2o5kx.js";import{r as Ug,t as Wg}from"./PromptInputFooterSuggestions-CrGST0Cq.js";import{n as Gg,t as Kg}from"./useMergedTools-CZJffsmf.js";import{a as qg,i as Jg,n as Yg,o as Xg,r as Zg,t as Qg}from"./promptEditor-foiayhdY.js";import{n as $g,t as e_}from"./useMainLoopModel-BNFW-g8E.js";import{i as t_,n as n_,r as r_,t as i_}from"./PermissionDialog-0ya1CU5k.js";import{n as a_,t as o_}from"./RemoteCallout-DS_EV6Fh.js";import{a as s_,c as c_,i as l_,o as u_,r as d_,s as f_}from"./caches-BtmAri4e.js";import{i as p_,n as m_,r as h_,t as g_}from"./conversation-GJxfkr6M.js";import{a as __,i as v_,n as y_,o as b_,r as x_,s as S_,t as C_}from"./extraUsage-BYZdi44Y.js";import{n as w_,t as T_}from"./useSearchInput-C-CqUK6w.js";import{n as E_,t as D_}from"./staticRender-BIxpgNUq.js";import{n as O_,t as k_}from"./useSettingsErrors-BWlJCgYF.js";import{n as A_,t as j_}from"./shadowedRuleDetection-7Z8ezTKF.js";import{n as M_,t as N_}from"./ExitFlow-CRPgptCN.js";import{a as P_,i as F_,r as I_,t as L_}from"./fast-DKqiojzf.js";import{n as R_,r as z_}from"./Feedback-CEtzaLr3.js";import{a as B_,i as V_,n as H_,r as U_,t as W_}from"./PromptInputHelpMenu-B2TDpbpw.js";import{n as G_,r as K_}from"./pluginAutoupdate-BfmyxR5g.js";import{n as q_,r as J_}from"./autoModeDenials-BxNzGJdR.js";import{n as Y_,t as X_}from"./generateSessionName-48veu5dv.js";import{a as Z_,c as Q_,d as $_,i as ev,l as tv,n as nv,o as rv,r as iv,s as av,t as ov,u as sv}from"./Messages-jCoW_1Rr.js";import{a as cv,i as lv,n as uv,o as dv,r as fv,t as pv}from"./BackgroundTasksDialog-Dvhcgahe.js";import{n as mv}from"./fpsMetrics-Cf_hdtiJ.js";import{t as hv}from"./earlyInput-BTC_Wucv.js";import{a as gv,c as _v,i as vv,l as yv,o as bv,r as xv,s as Sv,t as Cv}from"./RemoteSessionManager-Tx1N2uVL.js";import{n as wv,t as Tv}from"./backgroundHousekeeping-hDDE8mJC.js";import{n as Ev}from"./language-BuRSO2sR.js";import{homedir as Dv,tmpdir as Ov}from"os";import*as kv from"path";import{basename as Av,dirname as jv,extname as Mv,join as Nv,relative as Pv,sep as Fv}from"path";import{dirname as Iv,join as Lv}from"node:path";import{watch as Rv}from"fs";import{createHash as zv}from"node:crypto";import{randomUUID as Bv}from"crypto";import{readFile as Vv,stat as Hv,writeFile as Uv}from"fs/promises";import{spawn as Wv,spawnSync as Gv}from"child_process";import{mkdir as Kv,readFile as qv,rename as Jv,writeFile as Yv}from"node:fs/promises";s(),c(),p(),R(),me(),u(),B(),Ee(),He(),rt(),qd(),cf(),tf(),ef(),Xd(),nf(),of(),Yf(),rp(),ap(),Xf(),sp(),lp(),Gf(),dp(),fp(),_p(),Df(),Cp(),yp(),xp(),Ep(),kp(),Af(),Fp(),Lp(),zp(),Ef(),vf(),mf(),xf(),yf(),Up(),Nf(),Rf(),Vf(),fm(),em(),Xp(),Mm(),ym(),km(),am(),Pm(),lm(),Il(),Mo(),zm(),Zm(),qm(),Jm(),eh(),gc(),vs(),iu(),ah(),dr(),Hm(),Gm(),Qm(),Ym(),Xu(),Fl(),sh(),Vu(),ou(),Ka(),Ci(),gl(),Ms(),Rl(),jr(),dn(),Sd(),us(),wh(),Dh(),ih(),Ro(),Ln(),Lt(),Ni(),on(),qo(),ql(),uh(),rl(),Du(),ts(),zs(),Cr(),Si(),wa(),zh(),Zt(),Ll(),mu(),Jn(),cr(),Yt(),ga(),Uh(),Bh(),Ft(),wl(),Os(),Rh(),Kl(),Eu(),Ju(),Pa(),er(),Pi(),$s(),Yn(),ui(),Ca(),oc(),Pt(),Gh(),Js(),Tr(),Qa(),Ei(),Et(),to(),Xr(),yn(),Xo(),ul(),kl(),go(),Hd(),Zo(),Ul(),Gu(),qr(),hi(),Bc(),vn(),pd(),bd(),ms(),qh(),Fa(),Xa(),fr(),Fi(),bh(),yu(),Oo(),ro(),Nt(),un(),wn(),ld(),fc(),Sh(),Lu(),Ic(),uu(),mr(),_i(),ba(),bc(),ll(),Fu(),Ya(),la(),zc(),Yc(),os(),ta(),no(),Sn(),cd(),ic(),Gl(),Vd(),qa(),_l(),Zi(),Wc(),Zr(),Td(),qs(),Lo(),ru(),In(),Xt(),t_(),n_(),T_(),R_();var Q=n(z(),1);x(),nv(),zn(),Ao(),q(),D_();var $=ve();function Xv({children:e}){let{bindings:t}=ia(),n=(0,Q.useRef)(null),r=(0,Q.useRef)(new Map),i=(0,Q.useRef)(new Set).current;return(0,$.jsx)(S,{bindings:t,pendingChordRef:n,pendingChord:null,setPendingChord:()=>{},activeContexts:i,registerActiveContext:()=>{},unregisterActiveContext:()=>{},handlerRegistryRef:r,children:e})}function Zv(e){if(!(`message`in e))return 1;let t=e.message.content;return Array.isArray(t)?t.length:1}async function Qv(e,t,n,{columns:r,verbose:i=!1,chunkSize:a=40,onProgress:o}={}){let s=n=>E_((0,$.jsx)(bs,{children:(0,$.jsx)(Xv,{children:(0,$.jsx)(ov,{messages:e,tools:t,commands:[],verbose:i,toolJSX:null,toolUseConfirmQueue:[],inProgressToolUseIDs:new Set,isMessageSelectorVisible:!1,conversationId:`export`,screen:`prompt`,streamingToolUses:[],showAllInTranscript:!0,isLoading:!1,renderRange:n})})}),r),c=a;for(let t of e)c+=Zv(t);for(let e=0;e<c;e+=a){let t=await s([e,e+a]);if(pe(t).trim()===``)break;await n(t),o?.(e+a)}}async function $v(e,t=[],n){let r=[];return await Qv(e,t,e=>void r.push(pe(e)),{columns:n}),r.join(``)}Tu(),xd(),Ps(),sl(),qg(),ri();function ey({onDone:e}){return(0,$.jsxs)(ge,{title:`You've spent $5 on the Anthropic API this session.`,onCancel:e,children:[(0,$.jsxs)(b,{flexDirection:`column`,children:[(0,$.jsx)(T,{children:`Learn more about how to monitor your spending:`}),(0,$.jsx)(C,{url:`https://code.claude.com/docs/en/costs`})]}),(0,$.jsx)(pi,{options:[{value:`ok`,label:`Got it, thanks!`}],onChange:e})]})}B(),ri();function ty({idleMinutes:e,totalInputTokens:t,onDone:n}){return(0,$.jsxs)(ge,{title:`You've been away ${ny(e)} and this conversation is ${Np(t)} tokens.`,onCancel:()=>n(`dismiss`),children:[(0,$.jsx)(b,{flexDirection:`column`,children:(0,$.jsx)(T,{children:`If this is a new task, clearing context will save usage and be faster.`})}),(0,$.jsx)(pi,{options:[{value:`continue`,label:`Continue this conversation`},{value:`clear`,label:`Send message as a new conversation`},{value:`never`,label:`Don't ask me again`}],onChange:e=>n(e)})]})}function ny(e){if(e<1)return`< 1m`;if(e<60)return`${Math.floor(e)}m`;let t=Math.floor(e/60),n=Math.floor(e%60);return n===0?`${t}h`:`${t}h ${n}m`}async function ry(e,t){let n=Bf().preferredNotifChannel;await Ba(e),Z(`tengu_notification_method_used`,{configured_channel:n,method_used:await ay(n,e,t),term:_f.terminal})}var iy=`Claude Code`;async function ay(e,t,n){let r=t.title||iy;try{switch(e){case`auto`:return oy(t,n);case`iterm2`:return n.notifyITerm2(t),`iterm2`;case`iterm2_with_bell`:return n.notifyITerm2(t),n.notifyBell(),`iterm2_with_bell`;case`kitty`:return n.notifyKitty({...t,title:r,id:sy()}),`kitty`;case`ghostty`:return n.notifyGhostty({...t,title:r}),`ghostty`;case`terminal_bell`:return n.notifyBell(),`terminal_bell`;case`notifications_disabled`:return`disabled`;default:return`none`}}catch{return`error`}}async function oy(e,t){let n=e.title||iy;switch(_f.terminal){case`Apple_Terminal`:return await cy()?(t.notifyBell(),`terminal_bell`):`no_method_available`;case`iTerm.app`:return t.notifyITerm2(e),`iterm2`;case`kitty`:return t.notifyKitty({...e,title:n,id:sy()}),`kitty`;case`ghostty`:return t.notifyGhostty({...e,title:n}),`ghostty`;default:return`no_method_available`}}function sy(){return Math.floor(Math.random()*1e4)}async function cy(){try{if(_f.terminal!==`Apple_Terminal`)return!1;let e=(await Zf(`osascript`,[`-e`,`tell application "Terminal" to name of current settings of front window`])).stdout.trim();if(!e)return!1;let t=await Zf(`defaults`,[`export`,`com.apple.Terminal`,`-`]);if(t.code!==0)return!1;let r=(await import(`./plist-Bzo2VMe9.js`).then(e=>n(e.default,1))).parse(t.stdout)?.[`Window Settings`]?.[e];return r?r.Bell===!1:!1}catch(e){return X(e),!1}}var ly=300,uy=240*1e3,dy=null,fy=null,py=0,my=!1;function hy(){py++,py===1&&(by(),vy())}function gy(){py>0&&py--,py===0&&(yy(),xy())}function _y(){py=0,yy(),xy()}function vy(){process.platform===`darwin`&&fy===null&&(fy=setInterval(()=>{py>0&&(Y(`Restarting caffeinate to maintain sleep prevention`),xy(),by())},uy),fy.unref())}function yy(){fy!==null&&(clearInterval(fy),fy=null)}function by(){if(process.platform===`darwin`&&dy===null){my||(my=!0,lf(async()=>{_y()}));try{dy=Wv(`caffeinate`,[`-i`,`-t`,String(ly)],{stdio:`ignore`}),dy.unref();let e=dy;dy.on(`error`,t=>{Y(`caffeinate spawn error: ${t.message}`),dy===e&&(dy=null)}),dy.on(`exit`,()=>{dy===e&&(dy=null)}),Y(`Started caffeinate to prevent sleep`)}catch{dy=null}}}function xy(){if(dy!==null){let e=dy;dy=null;try{e.kill(`SIGKILL`),Y(`Stopped caffeinate, allowing sleep`)}catch{}}}var Sy=class{constructor(){l(this,`_status`,`idle`),l(this,`_generation`,0),l(this,`_changed`,ht()),l(this,`subscribe`,this._changed.subscribe),l(this,`getSnapshot`,()=>this._status!==`idle`)}reserve(){return this._status===`idle`?(this._status=`dispatching`,this._notify(),!0):!1}cancelReservation(){this._status===`dispatching`&&(this._status=`idle`,this._notify())}tryStart(){return this._status===`running`?null:(this._status=`running`,++this._generation,this._notify(),this._generation)}end(e){return this._generation!==e||this._status!==`running`?!1:(this._status=`idle`,this._notify(),!0)}forceEnd(){this._status!==`idle`&&(this._status=`idle`,++this._generation,this._notify())}get isActive(){return this._status!==`idle`}get generation(){return this._generation}_notify(){this._changed.emit()}};function Cy(e,t=!1){let n=(0,Q.useRef)(0),r=(0,Q.useRef)(void 0),i=(0,Q.useRef)(void 0),a=(0,Q.useRef)(0);(0,Q.useEffect)(()=>{if(t)return;let o=e[0]?.uuid,s=n.current,c=i.current===void 0,l=o!==void 0&&!c&&o===i.current&&s<=e.length,u=o!==void 0&&!c&&o===i.current&&s>e.length,d=l?s:0;if(d===e.length)return;let f=d===0?e:e.slice(d),p=l?r.current:void 0,m=++a.current;if(Pu(f,{},p,e).then(e=>{m===a.current&&e&&!l&&(r.current=e)}),l||c||u){let t=$i(f,e).findLast(si);t&&(r.current=t.uuid)}n.current=e.length,i.current=o},[e,t])}function wy(e){return!e||typeof e!=`object`?!1:`behavior`in e&&(e.behavior===`allow`||e.behavior===`deny`)}function Ty(e,t){if(typeof e.message==`string`&&e.message)return e.message;if(typeof t?.message==`string`&&t.message)return t.message;if(typeof e.error==`string`&&e.error)return e.error}function Ey(e){let t=e.response;if(!t||typeof t!=`object`)return null;if(t.subtype===`success`&&`response`in t&&wy(t.response))return t.response;if(t.subtype!==`error`)return null;let n=`response`in t&&wy(t.response)?t.response:void 0,r=Ty(t,n);return n?r?{...n,message:r}:n:r?{behavior:`deny`,message:r}:null}function Dy(t){{let{pauseProactive:t}=(bh(),e(lh));t()}t?.abort()}function Oy(e,t){return e<t}function ky(e,t){return e&&t===0}function Ay({hasHandle:e,isConnected:t,lastWrittenIndex:n,messageCount:r}){return!e||!t||Oy(n,r)}Jc(),h_();function jy(e){return{id:e.id,subject:e.subject,description:e.description,activeForm:e.activeForm,status:e.status,owner:e.owner,blocks:[...e.blocks],blockedBy:[...e.blockedBy]}}function My(e,t){return e.id.localeCompare(t.id)}function Ny(e,t){return{task_list_id:e,tasks:t.filter(e=>!e.metadata?._internal).map(jy).sort(My)}}function Py(e,t){return JSON.stringify(Ny(e,t))}function Fy(e,t){let n=Ny(e,t);return{type:`task_state`,uuid:Bv(),...n}}B(),q(),of();var Iy=50,Ly=5e3,Ry=1e4,zy=3;function By(e,t,n,r,i){let a=(0,Q.useRef)(null),o=(0,Q.useRef)(void 0),s=(0,Q.useRef)(0),c=(0,Q.useRef)(!1),l=(0,Q.useRef)(!1),u=(0,Q.useRef)(new Set),d=(0,Q.useRef)(void 0),f=(0,Q.useRef)(0),p=Qs(),m=(0,Q.useRef)(r);m.current=r;let h=(0,Q.useRef)(i);h.current=i;let g=(0,Q.useRef)(e);g.current=e;let _=js(),{addNotification:v}=Au(),y=J(e=>e.replBridgeEnabled),b=J(e=>e.replBridgeConnected),x=J(e=>e.replBridgeSessionActive),S=J(e=>e.replBridgeOutboundOnly),C=J(e=>e.replBridgeInitialName);return(0,Q.useEffect)(()=>{{if(!y)return;let r=S;function i(e){r||v({key:`bridge-failed`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(T,{color:`error`,children:`Remote Control failed`}),e&&(0,$.jsxs)(T,{dimColor:!0,children:[` · `,e]})]}),priority:`immediate`})}if(f.current>=zy){Y(`[bridge:repl] Hook: ${f.current} consecutive init failures, not retrying this session`);let e=`disabled after repeated failures · restart to retry`;i(e),p(t=>t.replBridgeError===e&&!t.replBridgeEnabled?t:{...t,replBridgeError:e,replBridgeEnabled:!1});return}let m=!1,h=e.length;return(async()=>{try{if(o.current&&(Y(`[bridge:repl] Hook: waiting for previous teardown to complete before re-init`),await o.current,o.current=void 0,Y(`[bridge:repl] Hook: previous teardown complete, proceeding with re-init`)),m)return;let{initReplBridge:v}=await import(`./initReplBridge-D0Xec8S-.js`),{shouldShowAppUpgradeMessage:y}=await import(`./envLessBridgeConfig-CGuIxFzJ.js`),b=!1;{let{isAssistantMode:e}=await import(`./assistant-YvbVKjVh.js`);b=e()}async function x(e){try{let t=gg(e);if(!t)return;let{uuid:n}=t,{resolveAndPrepend:r}=await import(`./inboundAttachments-BcEgi49j.js`),i=t.content,a=await r(e,i);Y(`[bridge:repl] Injecting inbound user message: ${typeof a==`string`?a.slice(0,80):`[${a.length} content blocks]`}${n?` uuid=${n}`:``}`),io({value:a,mode:`prompt`,uuid:n,skipSlashCommands:!0,bridgeOrigin:!0})}catch(e){Y(`[bridge:repl] handleInboundMessage failed: ${e}`,{level:`error`})}}function S(e,n){if(m)return;if(r){Y(`[bridge:repl] Mirror state=${e}${n?` detail=${n}`:``}`),e===`failed`?p(e=>e.replBridgeConnected?{...e,replBridgeConnected:!1}:e):(e===`ready`||e===`connected`)&&p(e=>e.replBridgeConnected?e:{...e,replBridgeConnected:!0});return}let o=a.current;switch(e){case`ready`:p(e=>{let t=o&&o.environmentId!==``?Ta(o.environmentId,o.sessionIngressUrl):e.replBridgeConnectUrl,n=o?xt(o.bridgeSessionId,o.sessionIngressUrl):e.replBridgeSessionUrl,r=o?.environmentId,i=o?.bridgeSessionId;return e.replBridgeConnected&&!e.replBridgeSessionActive&&!e.replBridgeReconnecting&&e.replBridgeConnectUrl===t&&e.replBridgeSessionUrl===n&&e.replBridgeEnvironmentId===r&&e.replBridgeSessionId===i?e:{...e,replBridgeConnected:!0,replBridgeSessionActive:!1,replBridgeReconnecting:!1,replBridgeConnectUrl:t,replBridgeSessionUrl:n,replBridgeEnvironmentId:r,replBridgeSessionId:i,replBridgeError:void 0}});break;case`connected`:{let e=_.getState().replBridgeSessionActive;p(e=>e.replBridgeSessionActive?e:{...e,replBridgeConnected:!0,replBridgeSessionActive:!0,replBridgeReconnecting:!1,replBridgeError:void 0}),e||t(e=>[...e,Ed(`Remote Control 已连接。现在可以使用 PushNotification、SendUserFile、Brief 工具,请使用 SearchExtraTools 搜索发现。`,`info`)]);break}case`reconnecting`:p(e=>e.replBridgeReconnecting?e:{...e,replBridgeReconnecting:!0,replBridgeSessionActive:!1});break;case`failed`:clearTimeout(d.current),i(n),p(e=>({...e,replBridgeError:n,replBridgeReconnecting:!1,replBridgeSessionActive:!1,replBridgeConnected:!1})),d.current=setTimeout(()=>{m||(d.current=void 0,p(e=>e.replBridgeError?{...e,replBridgeEnabled:!1,replBridgeError:void 0}:e))},Ry);break}}let w=new Map;function T(e){let t=e.response?.request_id;if(!t)return;let n=w.get(t);if(!n){Y(`[bridge:repl] No handler for control_response request_id=${t}`);return}let r=Ey(e);if(!r){Y(`[bridge:repl] Ignoring unrecognized control_response request_id=${t}`);return}w.delete(t),n(r)}let E=await v({outboundOnly:r,tags:r?[`ccr-mirror`]:void 0,onInboundMessage:x,onPermissionResponse:T,onInterrupt(){Dy(n.current)},onSetModel(e){let t=e==="default"?null:e??null;We(t),p(e=>e.mainLoopModelForSession===t?e:{...e,mainLoopModelForSession:t})},onSetMaxThinkingTokens(e){let t=e!==null;p(e=>e.thinkingEnabled===t?e:{...e,thinkingEnabled:t})},onSetPermissionMode(e){if(e===`bypassPermissions`){if(an())return{ok:!1,error:`Cannot set permission mode to bypassPermissions because it is disabled by settings or configuration`};if(!_.getState().toolPermissionContext.isBypassPermissionsModeAvailable)return{ok:!1,error:`Cannot set permission mode to bypassPermissions because the session was not launched with --dangerously-skip-permissions`}}if(e===`auto`&&!mn()){let e=vd();return{ok:!1,error:e?`Cannot set permission mode to auto: ${fs(e)}`:`Cannot set permission mode to auto`}}return p(t=>{let n=t.toolPermissionContext.mode;if(n===e)return t;let r=Mi(n,e,t.toolPermissionContext);return{...t,toolPermissionContext:{...r,mode:e}}}),{ok:!0}},onStateChange:S,initialMessages:e.length>0?e:void 0,getMessages:()=>g.current,previouslyFlushedUUIDs:u.current,initialName:C,perpetual:b}),D=E?{...E,markTranscriptReset(){l.current=!0,c.current=!1,s.current=0}}:null;if(m){Y(`[bridge:repl] Hook: init cancelled during flight, tearing down${D?` env=${D.environmentId}`:``}`),D&&D.teardown();return}if(!D){f.current++,Y(`[bridge:repl] Init returned null (precondition or session creation failed); consecutive failures: ${f.current}`),clearTimeout(d.current),p(e=>({...e,replBridgeError:e.replBridgeError??`check debug logs for details`})),d.current=setTimeout(()=>{m||(d.current=void 0,p(e=>e.replBridgeError?{...e,replBridgeEnabled:!1,replBridgeError:void 0}:e))},Ry);return}if(a.current=D,p_(D),f.current=0,s.current=h,r)p(e=>e.replBridgeConnected&&e.replBridgeSessionId===D.bridgeSessionId?e:{...e,replBridgeConnected:!0,replBridgeSessionId:D.bridgeSessionId,replBridgeSessionUrl:void 0,replBridgeConnectUrl:void 0,replBridgeError:void 0}),Y(`[bridge:repl] Mirror initialized, session=${D.bridgeSessionId}`);else{let e={sendRequest(e,t,n,r,i,a,o){D.sendControlRequest({type:`control_request`,request_id:e,request:{subtype:`can_use_tool`,tool_name:t,input:n,tool_use_id:r,description:i,...a?{permission_suggestions:a}:{},...o?{blocked_path:o}:{}}})},sendResponse(e,t){let n={...t};D.sendControlResponse({type:`control_response`,response:{subtype:`success`,request_id:e,response:n}})},cancelRequest(e){D.sendControlCancelRequest(e)},onResponse(e,t){return w.set(e,t),()=>{w.delete(e)}}};p(t=>({...t,replBridgePermissionCallbacks:e}));let n=xt(D.bridgeSessionId,D.sessionIngressUrl),r=D.environmentId===``?void 0:Ta(D.environmentId,D.sessionIngressUrl);p(e=>e.replBridgeConnected&&e.replBridgeSessionUrl===n?e:{...e,replBridgeConnected:!0,replBridgeSessionUrl:n,replBridgeConnectUrl:r??e.replBridgeConnectUrl,replBridgeEnvironmentId:D.environmentId,replBridgeSessionId:D.bridgeSessionId,replBridgeError:void 0});let i=!b&&await y().catch(()=>!1);if(m)return;t(e=>[...e,bl(n,i?`Please upgrade to the latest version of the Claude mobile app to see your Remote Control sessions.`:void 0)]),Y(`[bridge:repl] Hook initialized, session=${D.bridgeSessionId}`)}}catch(e){if(m)return;f.current++;let n=df(e);Y(`[bridge:repl] Init failed: ${n}; consecutive failures: ${f.current}`),clearTimeout(d.current),i(n),p(e=>({...e,replBridgeError:n})),d.current=setTimeout(()=>{m||(d.current=void 0,p(e=>e.replBridgeError?{...e,replBridgeEnabled:!1,replBridgeError:void 0}:e))},Ry),r||t(e=>[...e,Ed(`Remote Control failed to connect: ${n}`,`warning`)])}})(),()=>{m=!0,clearTimeout(d.current),d.current=void 0,a.current&&(Y(`[bridge:repl] Hook cleanup: starting teardown for env=${a.current.environmentId} session=${a.current.bridgeSessionId}`),o.current=a.current.teardown(),a.current=null,p_(null)),p(e=>!e.replBridgeConnected&&!e.replBridgeSessionActive&&!e.replBridgeError?e:{...e,replBridgeConnected:!1,replBridgeSessionActive:!1,replBridgeReconnecting:!1,replBridgeConnectUrl:void 0,replBridgeSessionUrl:void 0,replBridgeEnvironmentId:void 0,replBridgeSessionId:void 0,replBridgeError:void 0,replBridgePermissionCallbacks:void 0}),s.current=0,c.current=!1,l.current=!1}}},[y,S,p,t,v]),(0,Q.useEffect)(()=>{{if(!b)return;let t=a.current;if(!t)return;s.current>e.length&&Y(`[bridge:repl] Compaction detected: lastWrittenIndex=${s.current} > messages.length=${e.length}, clamping`);let n=Math.min(s.current,e.length),r=[];for(let t=n;t<e.length;t++){let n=e[t];n&&(n.type===`user`||n.type===`assistant`||n.type===`system`&&n.subtype===`local_command`)&&r.push(n)}if(s.current=e.length,r.length>0&&(t.writeMessages(r),l.current=!1),c.current&&ky(l.current,e.length)){l.current=!1,c.current=!1,t.sendResult();return}c.current&&!l.current&&(c.current=!1,t.sendResult())}},[e,b]),(0,Q.useEffect)(()=>{{if(!x||S)return;let e=!1,t,n,r=null,i=null,o=null,s=null,c=e=>{if(!(e===i&&r!==null)){r?.close(),r=null,i=e;try{r=Rv(e,u),r.unref()}catch{}}},l=async()=>{let t=a.current;if(!t)return;let n=Pr();c(au(n));try{let r=await wo(n);if(e||a.current!==t)return;let i=Py(n,r);if(i===o&&t===s)return;t.writeSdkMessages([Fy(n,r)]),o=i,s=t}catch(e){Y(`[bridge:repl] Failed to publish task_state: ${df(e)}`,{level:`error`})}},u=()=>{t&&clearTimeout(t),t=setTimeout(()=>{t=void 0,l()},Iy),t.unref?.()};l();let d=zo(u);return n=setInterval(()=>{l()},Ly),n.unref?.(),()=>{e=!0,d(),t&&clearTimeout(t),n&&clearInterval(n),r?.close()}}},[x,S]),{sendBridgeResult:(0,Q.useCallback)(()=>{{let e=a.current;if(!e){c.current=!0;return}if(ky(l.current,g.current.length)){l.current=!1,c.current=!1,e.sendResult();return}if(l.current||Ay({hasHandle:!0,isConnected:b,lastWrittenIndex:s.current,messageCount:g.current.length})){c.current=!0;return}e.sendResult()}},[b])}}yd(),Jo(),Xl(),Dl(),Uu(),Og(),wg(),Cp();var Vy=Pp(()=>De({method:Ce(`log_event`),params:De({eventName:ye(),eventData:De({}).passthrough()})}));function Hy(e){(0,Q.useEffect)(()=>{if(!e.length)return;let t=ya(e);t&&t.client.setNotificationHandler(Vy(),e=>{let{eventName:t,eventData:n}=e.params;Z(`tengu_ide_${t}`,n)})},[e])}rt(),B();var Uy=6e3;function Wy(){return Date.now()-Le()}function Gy(e){return Wy()<e}function Ky(e){return!Gy(e)}function qy(e,t){let n=E();(0,Q.useEffect)(()=>{gt(!0)},[]),(0,Q.useEffect)(()=>{let r=!1,i=setInterval(()=>{Ky(6e3)&&!r&&(r=!0,clearInterval(i),ry({message:e,notificationType:t},n))},Uy);return()=>clearInterval(i)},[e,t,n])}No(),Ho(),_r(),vi(),jt(),Zg(),B(),pc();var Jy={topLeft:`┌`,topRight:`┐`,bottomLeft:`└`,bottomRight:`┘`,horizontal:`─`,vertical:`│`,teeLeft:`├`,teeRight:`┤`};function Yy(e){return ao().syntaxHighlightingDisabled?(0,$.jsx)(Zy,{...e,highlight:null}):(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(Zy,{...e,highlight:null}),children:(0,$.jsx)(Xy,{...e})})}function Xy(e){let t=(0,Q.use)(qu());return(0,$.jsx)(Zy,{...e,highlight:t})}function Zy({content:e,maxLines:t,minHeight:n,minWidth:r=40,maxWidth:i,highlight:a}){let{columns:o}=de(),[s]=y(),c=i??o-4,l=t??20,u=(0,Q.useMemo)(()=>Qu(e,s,a),[e,s,a]).split(`
|
|
1
|
+
import{a as e,n as t,o as n,r}from"./rolldown-runtime-DaDcL9Zw.js";import{c as i,l as a,n as o,o as s}from"./envUtils-DSxRz_kt.js";import{n as c,t as l}from"./defineProperty-C-QyHrDq.js";import{n as u,t as d}from"./figures-5ThXQEtq.js";import{n as f,t as p}from"./axios-DaWTGg7G.js";import{C as m,D as h,Ft as g,Gr as _,Gt as v,H as y,I as b,Kr as x,Kt as S,Lt as C,Mr as w,P as T,Pn as E,Rn as D,T as O,Tt as k,Vn as A,Wt as j,Xn as M,Xt as N,Y as ee,Yt as P,Z as F,Zn as I,_n as te,bn as ne,ct as L,di as R,dr as re,et as ie,fi as z,ft as ae,hn as oe,ir as se,j as ce,lr as le,lt as ue,ot as de,q as fe,qr as pe,t as B,tr as V,ui as H,vn as me,x as he,y as ge,yn as U,yt as _e}from"./src-CDCSSo0U2.js";import{t as ve}from"./jsx-runtime-Bb4Xn-E0.js";import{A as ye,C as be,S as xe,a as Se,b as Ce,l as we,r as Te,t as Ee,w as De}from"./v4-jw6qOKwQ.js";import{At as Oe,B as ke,Bt as Ae,D as je,Dn as Me,H as Ne,Hn as Pe,Ht as Fe,Jn as Ie,K as Le,Mt as Re,Nt as ze,Pt as Be,Rt as Ve,Sr as He,Tt as Ue,Un as We,Ut as Ge,V as Ke,Vt as qe,Wt as Je,Yn as Ye,Yt as Xe,Z as Ze,Zt as Qe,_r as $e,b as et,bn as tt,dn as nt,en as rt,fn as it,ht as at,jt as ot,kt as st,nt as ct,ot as lt,pn as ut,pt as dt,tn as ft,un as pt,vr as mt,xr as ht,yr as gt,yt as _t,z as vt,zt as yt}from"./state-ix0xIunV.js";import{$C as bt,$S as xt,$T as St,$_ as Ct,$d as wt,$f as Tt,$m as Et,$w as Dt,Af as Ot,Ah as kt,Ao as At,Ap as jt,As as Mt,Au as Nt,Av as Pt,Ax as Ft,Ay as It,BC as Lt,Bb as Rt,Bc as zt,Bd as Bt,Bf as Vt,Bg as Ht,Bm as Ut,Bn as Wt,Bo as Gt,Bp as Kt,Bs as qt,Bw as Jt,Bx as Yt,C as Xt,CS as Zt,Cf as Qt,Cg as $t,Ci as en,Cl as tn,Cr as nn,Ct as rn,D as an,DC as on,DS as sn,Db as cn,Dg as ln,Du as un,Dw as dn,Dx as fn,Dy as pn,E as mn,EC as hn,ES as gn,Ec as _n,Ef as vn,Em as yn,Eo as bn,Er as xn,Es as Sn,Et as Cn,Eu as wn,Ex as Tn,Ey as En,FC as W,Fb as Dn,Fd as On,Ff as kn,Fh as An,Fm as jn,Fo as Mn,Fp as Nn,Fs as Pn,Ft as Fn,G as In,GC as Ln,GT as Rn,Gb as zn,Gd as Bn,Gf as Vn,Gl as Hn,Gm as Un,Gt as Wn,Gu as Gn,Gv as Kn,Gw as qn,Gx as Jn,Gy as Yn,HC as Xn,HD as Zn,HS as Qn,HT as $n,Hb as er,Hd as tr,Hf as nr,Hl as rr,Hm as ir,Hs as ar,Hv as or,Hw as sr,Hx as cr,Hy as lr,I as ur,IE as dr,Id as fr,If as pr,Il as mr,Im as hr,Io as gr,Ip as _r,Ir as vr,Is as G,Ix as yr,J as br,JC as xr,JD as K,JE as Sr,JS as Cr,Jf as wr,Jg as Tr,Jl as Er,Jn as Dr,Jo as Or,Jr as kr,Js as Ar,Jw as jr,Jy as Mr,KC as Nr,KS as Pr,KT as Fr,Kb as Ir,Kf as Lr,Ki as Rr,Kl as zr,Ks as Br,Ku as Vr,Kx as Hr,LC as Ur,LT as Wr,Lb as Gr,Ld as Kr,Lf as qr,Lg as Jr,Ll as Yr,Lm as Xr,Ln as Zr,Lp as Qr,Ls as $r,Lx as ei,Ly as ti,M as ni,Mb as ri,Mc as ii,Mf as ai,Mp as oi,Mr as si,Mu as ci,Mx as li,My as ui,N as di,NE as fi,Nb as pi,Nd as mi,Nf as hi,Ng as gi,Nl as _i,Np as vi,Nu as yi,Nx as bi,Ny as xi,OS as Si,OT as Ci,Ob as wi,Oc as Ti,Og as Ei,Oo as Di,Op as Oi,Ou as ki,Ox as Ai,Oy as ji,P as Mi,PC as Ni,Pb as Pi,Pd as Fi,Pf as Ii,Pg as Li,Ph as Ri,Pl as zi,Pm as Bi,Pn as Vi,Pp as Hi,Pr as Ui,Pu as Wi,Q as Gi,QC as Ki,QS as qi,Qa as Ji,Qd as Yi,Qf as Xi,Qi as Zi,Qm as Qi,Qn as $i,Qo as ea,Qs as ta,Qu as na,Qw as ra,Qx as ia,Qy as aa,RC as oa,Ra as sa,Rb as ca,Rc as la,Rg as ua,Ri as da,Rm as fa,Rp as pa,Rs as ma,Rw as ha,Rx as ga,Sb as _a,Sf as va,Sg as ya,Sl as ba,So as xa,Sw as Sa,Sy as Ca,TS as wa,Tb as Ta,Tf as Ea,Tm as Da,To as Oa,Tu as ka,Tv as Aa,Tx as ja,UC as Ma,Ua as Na,Ub as Pa,Ud as Fa,Uf as Ia,Ul as La,Um as Ra,Up as za,Ut as Ba,Uu as Va,Uw as Ha,Ux as Ua,Uy as Wa,VD as Ga,VT as Ka,Va as qa,Vb as Ja,Vc as Ya,Vd as Xa,Vf as Za,Vg as Qa,Vi as $a,Vl as eo,Vm as to,Vs as no,Vu as ro,Vw as io,Vx as ao,Vy as oo,W as so,WS as co,Wb as lo,Wd as uo,Wf as fo,Wi as po,Wl as mo,Wm as ho,Wp as go,Wu as _o,Wv as vo,Ww as yo,Wx as bo,Wy as xo,X as So,XC as Co,XS as wo,Xb as To,Xg as Eo,Xm as Do,Xu as Oo,Xw as ko,Xx as Ao,YC as jo,YD as Mo,Yb as No,Yu as Po,Yw as Fo,Yy as Io,Z as Lo,ZC as Ro,ZS as zo,Zg as Bo,Zi as Vo,Zm as Ho,Zs as Uo,Zt as Wo,Zu as Go,Zw as Ko,_C as qo,_b as Jo,_l as Yo,_m as Xo,_p as Zo,_u as Qo,_v as $o,_x as es,aC as ts,aO as ns,aT as rs,aa as is,ab as as,ac as os,af as ss,ao as cs,ap as ls,aw as us,ax as ds,b as fs,bb as ps,bf as ms,bg as hs,bo as gs,bw as _s,cD as vs,cE as ys,cS as bs,cT as xs,ca as Ss,cl as Cs,cm as ws,cp as Ts,cs as Es,cu as Ds,cx as Os,cy as ks,dC as As,dS as js,dT as Ms,db as Ns,dh as Ps,dm as Fs,dn as Is,do as Ls,dx as Rs,eC as zs,eT as Bs,eb as Vs,eh as Hs,ei as Us,en as Ws,ep as Gs,es as Ks,et as qs,ev as Js,ew as Ys,ex as Xs,fC as Zs,fS as Qs,fb as $s,fh as ec,fi as tc,fm as nc,fp as rc,fs as ic,fx as ac,fy as oc,gb as sc,gl as cc,gm as lc,gp as uc,gs as dc,gu as fc,gv as pc,gx as mc,hC as hc,hD as gc,hT as _c,hb as vc,hi as yc,hl as bc,hm as xc,ho as Sc,hp as Cc,hu as wc,hx as Tc,iC as Ec,iO as Dc,ib as Oc,id as kc,if as Ac,ih as jc,im as Mc,io as Nc,ip as Pc,it as Fc,iu as Ic,iw as Lc,ix as Rc,jc as zc,jf as Bc,jg as Vc,jm as Hc,jp as Uc,jr as Wc,ju as Gc,jx as Kc,kC as qc,kb as Jc,kc as Yc,kg as Xc,kh as Zc,km as Qc,ko as $c,kv as el,kx as tl,ky as nl,lC as rl,lD as il,lE as al,lS as q,lT as ol,lh as sl,li as cl,ll,lm as ul,lt as dl,lu as fl,lx as pl,mC as ml,mD as hl,mT as gl,ma as _l,mb as vl,mm as yl,mo as bl,mp as xl,mr as Sl,mu as Cl,mx as wl,nC as Tl,na as El,nb as Dl,nd as Ol,nm as kl,no as Al,nr as jl,nw as Ml,nx as Nl,oC as Pl,oE as Fl,oO as Il,oS as Ll,oT as Rl,oa as zl,oc as Bl,od as Vl,ol as Hl,op as Ul,or as Wl,os as Gl,ox as Kl,pC as ql,pD as Jl,pa as Yl,pb as Xl,ph as Zl,pi as Ql,pm as $l,po as eu,pu as tu,py as nu,q as ru,qE as iu,qS as au,qT as ou,qf as su,qg as cu,qi as lu,ql as uu,qo as du,qv as fu,qw as pu,qx as mu,rC as hu,rO as gu,ra as _u,rb as vu,rd as yu,rg as bu,rh as xu,rm as Su,ro as Cu,rp as wu,rw as Tu,rx as Eu,sC as Du,sD as Ou,sO as ku,sS as Au,sa as ju,sd as Mu,sh as Nu,si as Pu,sl as Fu,sm as Iu,su as Lu,sx as Ru,sy as zu,tC as Bu,tE as Vu,ta as Hu,tb as Uu,tm as Wu,tp as Gu,tt as Ku,tw as qu,tx as Ju,uC as Yu,uE as Xu,uS as J,ua as Zu,uh as Qu,ul as $u,um as ed,uo as td,ur as nd,ut as rd,uu as id,ux as ad,vi as od,vp as sd,vs as cd,vu as ld,vw as ud,wS as dd,wb as fd,wf as pd,wi as md,wu as hd,wx as gd,wy as _d,x as vd,xb as yd,xf as bd,xv as xd,xw as Sd,yf as Cd,yg as wd,yn as Td,yo as Ed,ys as Dd,yv as Od,yw as kd,zC as Ad,zE as jd,zT as Md,za as Nd,zb as Pd,zc as Fd,zf as Id,zg as Ld,zl as Rd,zm as zd,zn as Bd,zo as Vd,zp as Hd,zs as Ud,zw as Wd,zx as Gd,zy as Kd}from"./loadAgentsDir-ZQwvbURI.js";import{n as qd,t as Jd}from"./cwd-CYmmnQVS.js";import{D as Yd,E as Xd,G as Zd,J as Qd,O as $d,U as ef,Y as tf,_ as nf,h as rf,j as af,l as of,nt as sf,ot as cf,p as Y,st as lf,x as uf,z as df}from"./debug-DiuXEmUq.js";import{B as ff,Bt as pf,Ft as mf,Ht as hf,It as gf,Jt as _f,Kt as vf,L as yf,Pt as bf,St as xf,Ut as Sf,Vt as Cf,Wt as wf,Xt as Tf,Zt as Ef,_n as Df,c as Of,cn as kf,dn as Af,f as jf,ft as Mf,g as Nf,gn as Pf,n as Ff,vn as If,y as Lf}from"./settings-BhvhCpVh.js";import{P as Rf,b as zf,c as Bf,g as Vf,l as Hf,n as Uf}from"./config-662VDD70.js";import{M as Wf,_ as Gf,a as Kf,d as qf,i as Jf,j as Yf}from"./git-Cgc8X5l2.js";import{r as Xf,t as Zf}from"./execFileNoThrow-DResQRvR.js";import{B as Qf,L as $f,N as ep,R as tp,U as np,Y as rp,k as ip,o as ap,s as X}from"./log-Duzb4o6h.js";import{n as op,t as sp}from"./memoize-DgMjqLtn.js";import{n as cp,t as lp}from"./which-sEFQXpaX.js";import{i as up,o as dp}from"./platform-B5dCGT8t.js";import{i as fp,n as pp,o as mp,r as hp}from"./path-Cu_AKqg6.js";import{D as gp,E as _p,T as vp,f as yp,l as bp}from"./file-BZriE-XU.js";import{s as xp,u as Sp}from"./types-Cnorfsss.js";import{n as Cp,r as Z}from"./analytics-BotDBGh0.js";import{c as wp,n as Tp,s as Ep,t as Dp}from"./intl-cKc-V6Mq.js";import{T as Op,b as kp,d as Ap,f as jp,u as Mp,y as Np}from"./startupProfiler-BquH_Yqm.js";import{n as Pp,t as Fp}from"./lazySchema-uxlVVNM1.js";import{l as Ip,u as Lp}from"./oauth-BqJqV-2M.js";import{n as Rp,t as zp}from"./bundledMode--fG1S62b.js";import{a as Bp,d as Vp,l as Hp,o as Up,r as Wp,s as Gp}from"./stringUtils-D_g2L6A4.js";import{C as Kp,Ct as qp,D as Jp,Dt as Yp,Er as Xp,Hn as Zp,It as Qp,Kt as $p,Qr as em,T as tm,Tr as nm,Ut as rm,Vn as im,Vt as am,Xr as om,Z as sm,Zt as cm,_ as lm,at as um,b as dm,ci as fm,cr as pm,ct as mm,en as hm,er as gm,h as _m,ht as vm,ir as ym,it as bm,jt as xm,lt as Sm,m as Cm,nn as wm,nr as Tm,nt as Em,oi as Dm,ot as Om,qn as km,rt as Am,si as jm,sr as Mm,st as Nm,tt as Pm,u as Fm,wt as Im,x as Lm}from"./model-BgrLt7P7.js";import{Bt as Rm,Cn as zm,Ct as Bm,Ot as Vm,Vt as Hm,_n as Um,fn as Wm,kt as Gm,ln as Km,pn as qm,rn as Jm,st as Ym,un as Xm,vn as Zm,wt as Qm,xn as $m}from"./prompt-wys9CwDo.js";import{s as eh,u as th}from"./metadata-CIx5CsoY.js";import{a as nh,i as rh,r as ih}from"./shellQuote-yXoC_y5m.js";import{a as ah}from"./ripgrep-BN_g-F7X.js";import{a as oh,o as sh,s as ch}from"./fileStateCache-DDW5toIs.js";import{C as lh,N as uh,S as dh,T as fh,b as ph,d as mh,f as hh,j as gh,st as _h,w as vh,x as yh,y as bh}from"./rcDebugLog-CivJaJ3V.js";import{T as xh,c as Sh,r as Ch,w as wh}from"./sessionTracing-BBxhPccY.js";import{i as Th,n as Eh,r as Dh}from"./parser-TYEkLFgh.js";import{c as Oh,l as kh}from"./commitAttribution-DKun9CeU.js";import{n as Ah,t as jh}from"./poorMode-BqyVuBu-.js";import{a as Mh,f as Nh,l as Ph,o as Fh}from"./api-CLLIHLpn.js";import{r as Ih,t as Lh}from"./config-DklnhNx1.js";import{l as Rh,u as zh}from"./referral-Cu9bEOFE.js";import{i as Bh,m as Vh,n as Hh,p as Uh}from"./terminalSetup-nvS3KCDG.js";import{n as Wh,t as Gh}from"./browser-BKiu1max.js";import{i as Kh,r as qh}from"./bridgeEnabled-D4JDZd0y.js";import{n as Jh,r as Yh}from"./undercover-DDgIKbO5.js";import{t as Xh}from"./lib-BlVGipXx.js";import{t as Zh}from"./Dialog-vfLXEPed.js";import{n as Qh,t as $h}from"./mappers-DKU4RgE3.js";import{n as eg,r as tg}from"./sessionTitle-Bph6GO4F.js";import{t as ng}from"./bridgeMessaging-CRG6HqUb.js";import{C as rg,S as ig,d as ag,l as og}from"./pidLock-DchmaAK6.js";import{n as sg,t as cg}from"./nativeInstaller-DKe1pWoL.js";import{r as lg,t as ug}from"./pipeTransport-7GIO6GCA.js";import{t as dg}from"./useManagePlugins-DgGZBvXV.js";import{n as fg,t as pg}from"./MCPConnectionManager-BLfKm4H2.js";import{i as mg,n as hg,r as gg,t as _g}from"./reconciler-BKX4jh34.js";import{n as vg,t as yg}from"./toolPool-uQKZRMKg.js";import{a as bg,c as xg,i as Sg,l as Cg,r as wg,t as Tg,u as Eg}from"./MessageSelector-DmKtBYX9.js";import{n as Dg,t as Og}from"./useExitOnCtrlCDWithKeybindings-vzUoPY51.js";import{n as kg,t as Ag}from"./sideQuestion-CAiA6jAf.js";import{a as jg,n as Mg,o as Ng,r as Pg,s as Fg,t as Ig}from"./skillChangeDetector-BRBCwQ2w.js";import{n as Lg,t as Rg}from"./refresh-vJbxW4a1.js";import{i as zg,n as Bg,r as Vg,t as Hg}from"./directoryCompletion-CeV63gvu.js";import{r as Ug,t as Wg}from"./PromptInputFooterSuggestions-IaihWay3.js";import{n as Gg,t as Kg}from"./useMergedTools-Bb4XbC9d.js";import{a as qg,i as Jg,n as Yg,o as Xg,r as Zg,t as Qg}from"./promptEditor-D6HzjcMS.js";import{n as $g,t as e_}from"./useMainLoopModel-cZd8EKo5.js";import{i as t_,n as n_,r as r_,t as i_}from"./PermissionDialog-0ya1CU5k.js";import{n as a_,t as o_}from"./RemoteCallout-C_UIYnuT.js";import{a as s_,c as c_,i as l_,o as u_,r as d_,s as f_}from"./caches-BB5_91gU.js";import{i as p_,n as m_,r as h_,t as g_}from"./conversation-CooSju3g.js";import{a as __,i as v_,n as y_,o as b_,r as x_,s as S_,t as C_}from"./extraUsage-DtWi8E78.js";import{n as w_,t as T_}from"./useSearchInput-B1UOjxAI.js";import{n as E_,t as D_}from"./staticRender-BIxpgNUq.js";import{n as O_,t as k_}from"./useSettingsErrors-BLbvu4--.js";import{n as A_,t as j_}from"./shadowedRuleDetection-DDSOFi1W.js";import{n as M_,t as N_}from"./ExitFlow-B1XNACQP.js";import{a as P_,i as F_,r as I_,t as L_}from"./fast-DkUxqWhE.js";import{n as R_,r as z_}from"./Feedback-Cvz80lAn.js";import{a as B_,i as V_,n as H_,r as U_,t as W_}from"./PromptInputHelpMenu-okS2rQ4k.js";import{n as G_,r as K_}from"./pluginAutoupdate-7FFHzSRz.js";import{n as q_,r as J_}from"./autoModeDenials-BxNzGJdR.js";import{n as Y_,t as X_}from"./generateSessionName-DEAw5x_h.js";import{a as Z_,c as Q_,d as $_,i as ev,l as tv,n as nv,o as rv,r as iv,s as av,t as ov,u as sv}from"./Messages-CaFdI1kk.js";import{a as cv,i as lv,n as uv,o as dv,r as fv,t as pv}from"./BackgroundTasksDialog-AiVi-1pI.js";import{n as mv}from"./fpsMetrics-Cf_hdtiJ.js";import{t as hv}from"./earlyInput-BTC_Wucv.js";import{a as gv,c as _v,i as vv,l as yv,o as bv,r as xv,s as Sv,t as Cv}from"./RemoteSessionManager-CuSSHAXN.js";import{n as wv,t as Tv}from"./backgroundHousekeeping-Cpxq4krt.js";import{n as Ev}from"./language-8Rnu_qxl.js";import{homedir as Dv,tmpdir as Ov}from"os";import*as kv from"path";import{basename as Av,dirname as jv,extname as Mv,join as Nv,relative as Pv,sep as Fv}from"path";import{dirname as Iv,join as Lv}from"node:path";import{watch as Rv}from"fs";import{createHash as zv}from"node:crypto";import{randomUUID as Bv}from"crypto";import{readFile as Vv,stat as Hv,writeFile as Uv}from"fs/promises";import{spawn as Wv,spawnSync as Gv}from"child_process";import{mkdir as Kv,readFile as qv,rename as Jv,writeFile as Yv}from"node:fs/promises";s(),c(),p(),R(),me(),u(),B(),Ee(),He(),rt(),qd(),cf(),tf(),ef(),Xd(),nf(),of(),Yf(),rp(),ap(),Xf(),sp(),lp(),Gf(),dp(),fp(),_p(),Df(),Cp(),yp(),xp(),Ep(),kp(),Af(),Fp(),Lp(),zp(),Ef(),vf(),mf(),xf(),yf(),Up(),Nf(),Rf(),Vf(),fm(),em(),Xp(),Mm(),ym(),km(),am(),Pm(),lm(),Il(),Mo(),zm(),Zm(),qm(),Jm(),eh(),gc(),vs(),iu(),ah(),dr(),Hm(),Gm(),Qm(),Ym(),Xu(),Fl(),sh(),Vu(),ou(),Ka(),Ci(),gl(),Ms(),Rl(),jr(),dn(),Sd(),us(),wh(),Dh(),ih(),Ro(),Ln(),Lt(),Ni(),on(),qo(),ql(),uh(),rl(),Du(),ts(),zs(),Cr(),Si(),wa(),zh(),Zt(),Ll(),mu(),Jn(),cr(),Yt(),ga(),Uh(),Bh(),Ft(),wl(),Os(),Rh(),Kl(),Eu(),Ju(),Pa(),er(),Pi(),$s(),Yn(),ui(),Ca(),oc(),Pt(),Gh(),Js(),Tr(),Qa(),Ei(),Et(),to(),Xr(),yn(),Xo(),ul(),kl(),go(),Hd(),Zo(),Ul(),Gu(),qr(),hi(),Bc(),vn(),pd(),bd(),ms(),qh(),Fa(),Xa(),fr(),Fi(),bh(),yu(),Oo(),ro(),Nt(),un(),wn(),ld(),fc(),Sh(),Lu(),Ic(),uu(),mr(),_i(),ba(),bc(),ll(),Fu(),Ya(),la(),zc(),Yc(),os(),ta(),no(),Sn(),cd(),ic(),Gl(),Vd(),qa(),_l(),Zi(),Wc(),Zr(),Td(),qs(),Lo(),ru(),In(),Xt(),t_(),n_(),T_(),R_();var Q=n(z(),1);x(),nv(),zn(),Ao(),q(),D_();var $=ve();function Xv({children:e}){let{bindings:t}=ia(),n=(0,Q.useRef)(null),r=(0,Q.useRef)(new Map),i=(0,Q.useRef)(new Set).current;return(0,$.jsx)(S,{bindings:t,pendingChordRef:n,pendingChord:null,setPendingChord:()=>{},activeContexts:i,registerActiveContext:()=>{},unregisterActiveContext:()=>{},handlerRegistryRef:r,children:e})}function Zv(e){if(!(`message`in e))return 1;let t=e.message.content;return Array.isArray(t)?t.length:1}async function Qv(e,t,n,{columns:r,verbose:i=!1,chunkSize:a=40,onProgress:o}={}){let s=n=>E_((0,$.jsx)(bs,{children:(0,$.jsx)(Xv,{children:(0,$.jsx)(ov,{messages:e,tools:t,commands:[],verbose:i,toolJSX:null,toolUseConfirmQueue:[],inProgressToolUseIDs:new Set,isMessageSelectorVisible:!1,conversationId:`export`,screen:`prompt`,streamingToolUses:[],showAllInTranscript:!0,isLoading:!1,renderRange:n})})}),r),c=a;for(let t of e)c+=Zv(t);for(let e=0;e<c;e+=a){let t=await s([e,e+a]);if(pe(t).trim()===``)break;await n(t),o?.(e+a)}}async function $v(e,t=[],n){let r=[];return await Qv(e,t,e=>void r.push(pe(e)),{columns:n}),r.join(``)}Tu(),xd(),Ps(),sl(),qg(),ri();function ey({onDone:e}){return(0,$.jsxs)(ge,{title:`You've spent $5 on the Anthropic API this session.`,onCancel:e,children:[(0,$.jsxs)(b,{flexDirection:`column`,children:[(0,$.jsx)(T,{children:`Learn more about how to monitor your spending:`}),(0,$.jsx)(C,{url:`https://code.claude.com/docs/en/costs`})]}),(0,$.jsx)(pi,{options:[{value:`ok`,label:`Got it, thanks!`}],onChange:e})]})}B(),ri();function ty({idleMinutes:e,totalInputTokens:t,onDone:n}){return(0,$.jsxs)(ge,{title:`You've been away ${ny(e)} and this conversation is ${Np(t)} tokens.`,onCancel:()=>n(`dismiss`),children:[(0,$.jsx)(b,{flexDirection:`column`,children:(0,$.jsx)(T,{children:`If this is a new task, clearing context will save usage and be faster.`})}),(0,$.jsx)(pi,{options:[{value:`continue`,label:`Continue this conversation`},{value:`clear`,label:`Send message as a new conversation`},{value:`never`,label:`Don't ask me again`}],onChange:e=>n(e)})]})}function ny(e){if(e<1)return`< 1m`;if(e<60)return`${Math.floor(e)}m`;let t=Math.floor(e/60),n=Math.floor(e%60);return n===0?`${t}h`:`${t}h ${n}m`}async function ry(e,t){let n=Bf().preferredNotifChannel;await Ba(e),Z(`tengu_notification_method_used`,{configured_channel:n,method_used:await ay(n,e,t),term:_f.terminal})}var iy=`Work Mate`;async function ay(e,t,n){let r=t.title||iy;try{switch(e){case`auto`:return oy(t,n);case`iterm2`:return n.notifyITerm2(t),`iterm2`;case`iterm2_with_bell`:return n.notifyITerm2(t),n.notifyBell(),`iterm2_with_bell`;case`kitty`:return n.notifyKitty({...t,title:r,id:sy()}),`kitty`;case`ghostty`:return n.notifyGhostty({...t,title:r}),`ghostty`;case`terminal_bell`:return n.notifyBell(),`terminal_bell`;case`notifications_disabled`:return`disabled`;default:return`none`}}catch{return`error`}}async function oy(e,t){let n=e.title||iy;switch(_f.terminal){case`Apple_Terminal`:return await cy()?(t.notifyBell(),`terminal_bell`):`no_method_available`;case`iTerm.app`:return t.notifyITerm2(e),`iterm2`;case`kitty`:return t.notifyKitty({...e,title:n,id:sy()}),`kitty`;case`ghostty`:return t.notifyGhostty({...e,title:n}),`ghostty`;default:return`no_method_available`}}function sy(){return Math.floor(Math.random()*1e4)}async function cy(){try{if(_f.terminal!==`Apple_Terminal`)return!1;let e=(await Zf(`osascript`,[`-e`,`tell application "Terminal" to name of current settings of front window`])).stdout.trim();if(!e)return!1;let t=await Zf(`defaults`,[`export`,`com.apple.Terminal`,`-`]);if(t.code!==0)return!1;let r=(await import(`./plist-Bzo2VMe9.js`).then(e=>n(e.default,1))).parse(t.stdout)?.[`Window Settings`]?.[e];return r?r.Bell===!1:!1}catch(e){return X(e),!1}}var ly=300,uy=240*1e3,dy=null,fy=null,py=0,my=!1;function hy(){py++,py===1&&(by(),vy())}function gy(){py>0&&py--,py===0&&(yy(),xy())}function _y(){py=0,yy(),xy()}function vy(){process.platform===`darwin`&&fy===null&&(fy=setInterval(()=>{py>0&&(Y(`Restarting caffeinate to maintain sleep prevention`),xy(),by())},uy),fy.unref())}function yy(){fy!==null&&(clearInterval(fy),fy=null)}function by(){if(process.platform===`darwin`&&dy===null){my||(my=!0,lf(async()=>{_y()}));try{dy=Wv(`caffeinate`,[`-i`,`-t`,String(ly)],{stdio:`ignore`}),dy.unref();let e=dy;dy.on(`error`,t=>{Y(`caffeinate spawn error: ${t.message}`),dy===e&&(dy=null)}),dy.on(`exit`,()=>{dy===e&&(dy=null)}),Y(`Started caffeinate to prevent sleep`)}catch{dy=null}}}function xy(){if(dy!==null){let e=dy;dy=null;try{e.kill(`SIGKILL`),Y(`Stopped caffeinate, allowing sleep`)}catch{}}}var Sy=class{constructor(){l(this,`_status`,`idle`),l(this,`_generation`,0),l(this,`_changed`,ht()),l(this,`subscribe`,this._changed.subscribe),l(this,`getSnapshot`,()=>this._status!==`idle`)}reserve(){return this._status===`idle`?(this._status=`dispatching`,this._notify(),!0):!1}cancelReservation(){this._status===`dispatching`&&(this._status=`idle`,this._notify())}tryStart(){return this._status===`running`?null:(this._status=`running`,++this._generation,this._notify(),this._generation)}end(e){return this._generation!==e||this._status!==`running`?!1:(this._status=`idle`,this._notify(),!0)}forceEnd(){this._status!==`idle`&&(this._status=`idle`,++this._generation,this._notify())}get isActive(){return this._status!==`idle`}get generation(){return this._generation}_notify(){this._changed.emit()}};function Cy(e,t=!1){let n=(0,Q.useRef)(0),r=(0,Q.useRef)(void 0),i=(0,Q.useRef)(void 0),a=(0,Q.useRef)(0);(0,Q.useEffect)(()=>{if(t)return;let o=e[0]?.uuid,s=n.current,c=i.current===void 0,l=o!==void 0&&!c&&o===i.current&&s<=e.length,u=o!==void 0&&!c&&o===i.current&&s>e.length,d=l?s:0;if(d===e.length)return;let f=d===0?e:e.slice(d),p=l?r.current:void 0,m=++a.current;if(Pu(f,{},p,e).then(e=>{m===a.current&&e&&!l&&(r.current=e)}),l||c||u){let t=$i(f,e).findLast(si);t&&(r.current=t.uuid)}n.current=e.length,i.current=o},[e,t])}function wy(e){return!e||typeof e!=`object`?!1:`behavior`in e&&(e.behavior===`allow`||e.behavior===`deny`)}function Ty(e,t){if(typeof e.message==`string`&&e.message)return e.message;if(typeof t?.message==`string`&&t.message)return t.message;if(typeof e.error==`string`&&e.error)return e.error}function Ey(e){let t=e.response;if(!t||typeof t!=`object`)return null;if(t.subtype===`success`&&`response`in t&&wy(t.response))return t.response;if(t.subtype!==`error`)return null;let n=`response`in t&&wy(t.response)?t.response:void 0,r=Ty(t,n);return n?r?{...n,message:r}:n:r?{behavior:`deny`,message:r}:null}function Dy(t){{let{pauseProactive:t}=(bh(),e(lh));t()}t?.abort()}function Oy(e,t){return e<t}function ky(e,t){return e&&t===0}function Ay({hasHandle:e,isConnected:t,lastWrittenIndex:n,messageCount:r}){return!e||!t||Oy(n,r)}Jc(),h_();function jy(e){return{id:e.id,subject:e.subject,description:e.description,activeForm:e.activeForm,status:e.status,owner:e.owner,blocks:[...e.blocks],blockedBy:[...e.blockedBy]}}function My(e,t){return e.id.localeCompare(t.id)}function Ny(e,t){return{task_list_id:e,tasks:t.filter(e=>!e.metadata?._internal).map(jy).sort(My)}}function Py(e,t){return JSON.stringify(Ny(e,t))}function Fy(e,t){let n=Ny(e,t);return{type:`task_state`,uuid:Bv(),...n}}B(),q(),of();var Iy=50,Ly=5e3,Ry=1e4,zy=3;function By(e,t,n,r,i){let a=(0,Q.useRef)(null),o=(0,Q.useRef)(void 0),s=(0,Q.useRef)(0),c=(0,Q.useRef)(!1),l=(0,Q.useRef)(!1),u=(0,Q.useRef)(new Set),d=(0,Q.useRef)(void 0),f=(0,Q.useRef)(0),p=Qs(),m=(0,Q.useRef)(r);m.current=r;let h=(0,Q.useRef)(i);h.current=i;let g=(0,Q.useRef)(e);g.current=e;let _=js(),{addNotification:v}=Au(),y=J(e=>e.replBridgeEnabled),b=J(e=>e.replBridgeConnected),x=J(e=>e.replBridgeSessionActive),S=J(e=>e.replBridgeOutboundOnly),C=J(e=>e.replBridgeInitialName);return(0,Q.useEffect)(()=>{{if(!y)return;let r=S;function i(e){r||v({key:`bridge-failed`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(T,{color:`error`,children:`Remote Control failed`}),e&&(0,$.jsxs)(T,{dimColor:!0,children:[` · `,e]})]}),priority:`immediate`})}if(f.current>=zy){Y(`[bridge:repl] Hook: ${f.current} consecutive init failures, not retrying this session`);let e=`disabled after repeated failures · restart to retry`;i(e),p(t=>t.replBridgeError===e&&!t.replBridgeEnabled?t:{...t,replBridgeError:e,replBridgeEnabled:!1});return}let m=!1,h=e.length;return(async()=>{try{if(o.current&&(Y(`[bridge:repl] Hook: waiting for previous teardown to complete before re-init`),await o.current,o.current=void 0,Y(`[bridge:repl] Hook: previous teardown complete, proceeding with re-init`)),m)return;let{initReplBridge:v}=await import(`./initReplBridge-CjuO6in6.js`),{shouldShowAppUpgradeMessage:y}=await import(`./envLessBridgeConfig-BfgXw47_.js`),b=!1;{let{isAssistantMode:e}=await import(`./assistant-z2o4-UJe.js`);b=e()}async function x(e){try{let t=gg(e);if(!t)return;let{uuid:n}=t,{resolveAndPrepend:r}=await import(`./inboundAttachments-D5Ux2kCl.js`),i=t.content,a=await r(e,i);Y(`[bridge:repl] Injecting inbound user message: ${typeof a==`string`?a.slice(0,80):`[${a.length} content blocks]`}${n?` uuid=${n}`:``}`),io({value:a,mode:`prompt`,uuid:n,skipSlashCommands:!0,bridgeOrigin:!0})}catch(e){Y(`[bridge:repl] handleInboundMessage failed: ${e}`,{level:`error`})}}function S(e,n){if(m)return;if(r){Y(`[bridge:repl] Mirror state=${e}${n?` detail=${n}`:``}`),e===`failed`?p(e=>e.replBridgeConnected?{...e,replBridgeConnected:!1}:e):(e===`ready`||e===`connected`)&&p(e=>e.replBridgeConnected?e:{...e,replBridgeConnected:!0});return}let o=a.current;switch(e){case`ready`:p(e=>{let t=o&&o.environmentId!==``?Ta(o.environmentId,o.sessionIngressUrl):e.replBridgeConnectUrl,n=o?xt(o.bridgeSessionId,o.sessionIngressUrl):e.replBridgeSessionUrl,r=o?.environmentId,i=o?.bridgeSessionId;return e.replBridgeConnected&&!e.replBridgeSessionActive&&!e.replBridgeReconnecting&&e.replBridgeConnectUrl===t&&e.replBridgeSessionUrl===n&&e.replBridgeEnvironmentId===r&&e.replBridgeSessionId===i?e:{...e,replBridgeConnected:!0,replBridgeSessionActive:!1,replBridgeReconnecting:!1,replBridgeConnectUrl:t,replBridgeSessionUrl:n,replBridgeEnvironmentId:r,replBridgeSessionId:i,replBridgeError:void 0}});break;case`connected`:{let e=_.getState().replBridgeSessionActive;p(e=>e.replBridgeSessionActive?e:{...e,replBridgeConnected:!0,replBridgeSessionActive:!0,replBridgeReconnecting:!1,replBridgeError:void 0}),e||t(e=>[...e,Ed(`Remote Control 已连接。现在可以使用 PushNotification、SendUserFile、Brief 工具,请使用 SearchExtraTools 搜索发现。`,`info`)]);break}case`reconnecting`:p(e=>e.replBridgeReconnecting?e:{...e,replBridgeReconnecting:!0,replBridgeSessionActive:!1});break;case`failed`:clearTimeout(d.current),i(n),p(e=>({...e,replBridgeError:n,replBridgeReconnecting:!1,replBridgeSessionActive:!1,replBridgeConnected:!1})),d.current=setTimeout(()=>{m||(d.current=void 0,p(e=>e.replBridgeError?{...e,replBridgeEnabled:!1,replBridgeError:void 0}:e))},Ry);break}}let w=new Map;function T(e){let t=e.response?.request_id;if(!t)return;let n=w.get(t);if(!n){Y(`[bridge:repl] No handler for control_response request_id=${t}`);return}let r=Ey(e);if(!r){Y(`[bridge:repl] Ignoring unrecognized control_response request_id=${t}`);return}w.delete(t),n(r)}let E=await v({outboundOnly:r,tags:r?[`ccr-mirror`]:void 0,onInboundMessage:x,onPermissionResponse:T,onInterrupt(){Dy(n.current)},onSetModel(e){let t=e==="default"?null:e??null;We(t),p(e=>e.mainLoopModelForSession===t?e:{...e,mainLoopModelForSession:t})},onSetMaxThinkingTokens(e){let t=e!==null;p(e=>e.thinkingEnabled===t?e:{...e,thinkingEnabled:t})},onSetPermissionMode(e){if(e===`bypassPermissions`){if(an())return{ok:!1,error:`Cannot set permission mode to bypassPermissions because it is disabled by settings or configuration`};if(!_.getState().toolPermissionContext.isBypassPermissionsModeAvailable)return{ok:!1,error:`Cannot set permission mode to bypassPermissions because the session was not launched with --dangerously-skip-permissions`}}if(e===`auto`&&!mn()){let e=vd();return{ok:!1,error:e?`Cannot set permission mode to auto: ${fs(e)}`:`Cannot set permission mode to auto`}}return p(t=>{let n=t.toolPermissionContext.mode;if(n===e)return t;let r=Mi(n,e,t.toolPermissionContext);return{...t,toolPermissionContext:{...r,mode:e}}}),{ok:!0}},onStateChange:S,initialMessages:e.length>0?e:void 0,getMessages:()=>g.current,previouslyFlushedUUIDs:u.current,initialName:C,perpetual:b}),D=E?{...E,markTranscriptReset(){l.current=!0,c.current=!1,s.current=0}}:null;if(m){Y(`[bridge:repl] Hook: init cancelled during flight, tearing down${D?` env=${D.environmentId}`:``}`),D&&D.teardown();return}if(!D){f.current++,Y(`[bridge:repl] Init returned null (precondition or session creation failed); consecutive failures: ${f.current}`),clearTimeout(d.current),p(e=>({...e,replBridgeError:e.replBridgeError??`check debug logs for details`})),d.current=setTimeout(()=>{m||(d.current=void 0,p(e=>e.replBridgeError?{...e,replBridgeEnabled:!1,replBridgeError:void 0}:e))},Ry);return}if(a.current=D,p_(D),f.current=0,s.current=h,r)p(e=>e.replBridgeConnected&&e.replBridgeSessionId===D.bridgeSessionId?e:{...e,replBridgeConnected:!0,replBridgeSessionId:D.bridgeSessionId,replBridgeSessionUrl:void 0,replBridgeConnectUrl:void 0,replBridgeError:void 0}),Y(`[bridge:repl] Mirror initialized, session=${D.bridgeSessionId}`);else{let e={sendRequest(e,t,n,r,i,a,o){D.sendControlRequest({type:`control_request`,request_id:e,request:{subtype:`can_use_tool`,tool_name:t,input:n,tool_use_id:r,description:i,...a?{permission_suggestions:a}:{},...o?{blocked_path:o}:{}}})},sendResponse(e,t){let n={...t};D.sendControlResponse({type:`control_response`,response:{subtype:`success`,request_id:e,response:n}})},cancelRequest(e){D.sendControlCancelRequest(e)},onResponse(e,t){return w.set(e,t),()=>{w.delete(e)}}};p(t=>({...t,replBridgePermissionCallbacks:e}));let n=xt(D.bridgeSessionId,D.sessionIngressUrl),r=D.environmentId===``?void 0:Ta(D.environmentId,D.sessionIngressUrl);p(e=>e.replBridgeConnected&&e.replBridgeSessionUrl===n?e:{...e,replBridgeConnected:!0,replBridgeSessionUrl:n,replBridgeConnectUrl:r??e.replBridgeConnectUrl,replBridgeEnvironmentId:D.environmentId,replBridgeSessionId:D.bridgeSessionId,replBridgeError:void 0});let i=!b&&await y().catch(()=>!1);if(m)return;t(e=>[...e,bl(n,i?`Please upgrade to the latest version of the Claude mobile app to see your Remote Control sessions.`:void 0)]),Y(`[bridge:repl] Hook initialized, session=${D.bridgeSessionId}`)}}catch(e){if(m)return;f.current++;let n=df(e);Y(`[bridge:repl] Init failed: ${n}; consecutive failures: ${f.current}`),clearTimeout(d.current),i(n),p(e=>({...e,replBridgeError:n})),d.current=setTimeout(()=>{m||(d.current=void 0,p(e=>e.replBridgeError?{...e,replBridgeEnabled:!1,replBridgeError:void 0}:e))},Ry),r||t(e=>[...e,Ed(`Remote Control failed to connect: ${n}`,`warning`)])}})(),()=>{m=!0,clearTimeout(d.current),d.current=void 0,a.current&&(Y(`[bridge:repl] Hook cleanup: starting teardown for env=${a.current.environmentId} session=${a.current.bridgeSessionId}`),o.current=a.current.teardown(),a.current=null,p_(null)),p(e=>!e.replBridgeConnected&&!e.replBridgeSessionActive&&!e.replBridgeError?e:{...e,replBridgeConnected:!1,replBridgeSessionActive:!1,replBridgeReconnecting:!1,replBridgeConnectUrl:void 0,replBridgeSessionUrl:void 0,replBridgeEnvironmentId:void 0,replBridgeSessionId:void 0,replBridgeError:void 0,replBridgePermissionCallbacks:void 0}),s.current=0,c.current=!1,l.current=!1}}},[y,S,p,t,v]),(0,Q.useEffect)(()=>{{if(!b)return;let t=a.current;if(!t)return;s.current>e.length&&Y(`[bridge:repl] Compaction detected: lastWrittenIndex=${s.current} > messages.length=${e.length}, clamping`);let n=Math.min(s.current,e.length),r=[];for(let t=n;t<e.length;t++){let n=e[t];n&&(n.type===`user`||n.type===`assistant`||n.type===`system`&&n.subtype===`local_command`)&&r.push(n)}if(s.current=e.length,r.length>0&&(t.writeMessages(r),l.current=!1),c.current&&ky(l.current,e.length)){l.current=!1,c.current=!1,t.sendResult();return}c.current&&!l.current&&(c.current=!1,t.sendResult())}},[e,b]),(0,Q.useEffect)(()=>{{if(!x||S)return;let e=!1,t,n,r=null,i=null,o=null,s=null,c=e=>{if(!(e===i&&r!==null)){r?.close(),r=null,i=e;try{r=Rv(e,u),r.unref()}catch{}}},l=async()=>{let t=a.current;if(!t)return;let n=Pr();c(au(n));try{let r=await wo(n);if(e||a.current!==t)return;let i=Py(n,r);if(i===o&&t===s)return;t.writeSdkMessages([Fy(n,r)]),o=i,s=t}catch(e){Y(`[bridge:repl] Failed to publish task_state: ${df(e)}`,{level:`error`})}},u=()=>{t&&clearTimeout(t),t=setTimeout(()=>{t=void 0,l()},Iy),t.unref?.()};l();let d=zo(u);return n=setInterval(()=>{l()},Ly),n.unref?.(),()=>{e=!0,d(),t&&clearTimeout(t),n&&clearInterval(n),r?.close()}}},[x,S]),{sendBridgeResult:(0,Q.useCallback)(()=>{{let e=a.current;if(!e){c.current=!0;return}if(ky(l.current,g.current.length)){l.current=!1,c.current=!1,e.sendResult();return}if(l.current||Ay({hasHandle:!0,isConnected:b,lastWrittenIndex:s.current,messageCount:g.current.length})){c.current=!0;return}e.sendResult()}},[b])}}yd(),Jo(),Xl(),Dl(),Uu(),Og(),wg(),Cp();var Vy=Pp(()=>De({method:Ce(`log_event`),params:De({eventName:ye(),eventData:De({}).passthrough()})}));function Hy(e){(0,Q.useEffect)(()=>{if(!e.length)return;let t=ya(e);t&&t.client.setNotificationHandler(Vy(),e=>{let{eventName:t,eventData:n}=e.params;Z(`tengu_ide_${t}`,n)})},[e])}rt(),B();var Uy=6e3;function Wy(){return Date.now()-Le()}function Gy(e){return Wy()<e}function Ky(e){return!Gy(e)}function qy(e,t){let n=E();(0,Q.useEffect)(()=>{gt(!0)},[]),(0,Q.useEffect)(()=>{let r=!1,i=setInterval(()=>{Ky(6e3)&&!r&&(r=!0,clearInterval(i),ry({message:e,notificationType:t},n))},Uy);return()=>clearInterval(i)},[e,t,n])}No(),Ho(),_r(),vi(),jt(),Zg(),B(),pc();var Jy={topLeft:`┌`,topRight:`┐`,bottomLeft:`└`,bottomRight:`┘`,horizontal:`─`,vertical:`│`,teeLeft:`├`,teeRight:`┤`};function Yy(e){return ao().syntaxHighlightingDisabled?(0,$.jsx)(Zy,{...e,highlight:null}):(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(Zy,{...e,highlight:null}),children:(0,$.jsx)(Xy,{...e})})}function Xy(e){let t=(0,Q.use)(qu());return(0,$.jsx)(Zy,{...e,highlight:t})}function Zy({content:e,maxLines:t,minHeight:n,minWidth:r=40,maxWidth:i,highlight:a}){let{columns:o}=de(),[s]=y(),c=i??o-4,l=t??20,u=(0,Q.useMemo)(()=>Qu(e,s,a),[e,s,a]).split(`
|
|
2
2
|
`),d=u.length>l,f=d?u.slice(0,l):u,p=Math.max(0,Math.min(n??0,l)-f.length-+!!d),m=p>0?[...f,...Array(p).fill(``)]:f,h=Math.max(r,...m.map(e=>_(e))),v=Math.min(h+4,c),x=v-4,S=`${Jy.topLeft}${Jy.horizontal.repeat(v-2)}${Jy.topRight}`,C=`${Jy.bottomLeft}${Jy.horizontal.repeat(v-2)}${Jy.bottomRight}`,w=d?(()=>{let e=u.length-l,t=`${Jy.horizontal.repeat(3)} \u2702 ${Jy.horizontal.repeat(3)} ${e} lines hidden `,n=_(t),r=Math.max(0,v-2-n);return`${Jy.teeLeft}${t}${Jy.horizontal.repeat(r)}${Jy.teeRight}`})():null;return(0,$.jsxs)(b,{flexDirection:`column`,children:[(0,$.jsx)(T,{dimColor:!0,children:S}),m.map((e,t)=>{let n=_(e)>x?$o(e,0,x):e,r=` `.repeat(Math.max(0,x-_(n)));return(0,$.jsxs)(b,{flexDirection:`row`,children:[(0,$.jsxs)(T,{dimColor:!0,children:[Jy.vertical,` `]}),(0,$.jsx)(g,{children:n}),(0,$.jsxs)(T,{dimColor:!0,children:[r,` `,Jy.vertical]})]},t)}),w&&(0,$.jsx)(T,{color:`warning`,children:w}),(0,$.jsx)(T,{dimColor:!0,children:C})]})}wa(),B(),kp();function Qy({questions:e,currentQuestionIndex:t,answers:n,hideSubmitTab:r=!1}){let{columns:i}=de(),a=(0,Q.useMemo)(()=>{let n=r?``:` ${d.tick} Submit `,a=_(`← `)+_(` →`)+_(n),o=i-a;if(o<=0)return e.map((e,n)=>{let r=e?.header||`Q${n+1}`;return n===t?r.slice(0,3):``});let s=e.map((e,t)=>e?.header||`Q${t+1}`);if(s.map(e=>4+_(e)).reduce((e,t)=>e+t,0)<=o)return s;let c=4+_(s[t]||``),l=Math.min(c,o/2),u=o-l,f=e.length-1,p=Math.max(6,Math.floor(u/Math.max(f,1)));return s.map((e,n)=>n===t?Op(e,l-2-2):Op(e,p-2-2))},[e,t,i,r]),o=e.length===1&&r;return(0,$.jsxs)(b,{flexDirection:`row`,marginBottom:1,children:[!o&&(0,$.jsx)(T,{color:t===0?`inactive`:void 0,children:`← `}),e.map((e,r)=>{let i=r===t,o=e?.question&&n[e.question]?d.checkboxOn:d.checkboxOff,s=a[r]||e?.header||`Q${r+1}`;return(0,$.jsx)(b,{children:i?(0,$.jsxs)(T,{backgroundColor:`permission`,color:`inverseText`,children:[` `,o,` `,s,` `]}):(0,$.jsxs)(T,{children:[` `,o,` `,s,` `]})},e?.question||`question-${r}`)}),!r&&(0,$.jsx)(b,{children:t===e.length?(0,$.jsxs)(T,{backgroundColor:`permission`,color:`inverseText`,children:[` `,d.tick,` Submit`,` `]}):(0,$.jsxs)(T,{children:[` `,d.tick,` Submit `]})},`submit`),!o&&(0,$.jsx)(T,{color:t===e.length?`inactive`:void 0,children:` →`})]})}u(),wa(),B(),q(),Ei();function $y({question:e,questions:t,currentQuestionIndex:n,answers:r,questionStates:i,hideSubmitTab:a=!1,minContentHeight:o,minContentWidth:s,onUpdateQuestionState:c,onAnswer:l,onTextInputFocus:u,onCancel:f,onTabPrev:p,onTabNext:h,onRespondToClaude:g,onFinishPlanInterview:_}){let y=J(e=>e.toolPermissionContext.mode)===`plan`,[x,S]=(0,Q.useState)(!1),[C,w]=(0,Q.useState)(0),[E,D]=(0,Q.useState)(!1),[O,k]=(0,Q.useState)(0),A=Jg(),M=A?Jr(A):null,N=e.question,ee=i[N],P=e.options,[F,I]=(0,Q.useState)(0),te=(0,Q.useRef)(N);if(te.current!==N){te.current=N;let e=ee?.selectedValue,t=e?P.findIndex(t=>t.label===e):-1;I(t>=0?t:0)}let ne=P[F],L=ee?.selectedValue,R=ee?.textInputValue||``,re=(0,Q.useCallback)(e=>{let t=P[e];t&&(I(e),c(N,{selectedValue:t.label},!1),l(N,t.label))},[P,N,c,l]),ie=(0,Q.useCallback)(e=>{if(E)return;let t;t=typeof e==`number`?e:e===`up`?F>0?F-1:F:F<P.length-1?F+1:F,t>=0&&t<P.length&&I(t)},[F,P.length,E]);j(`chat:externalEditor`,async()=>{let e=ee?.textInputValue||``,t=await Yg(e);t.content!==null&&t.content!==e&&c(N,{textInputValue:t.content},!1)},{context:`Chat`,isActive:E&&!!A}),v({"tabs:previous":()=>p?.(),"tabs:next":()=>h?.()},{context:`Tabs`,isActive:!E&&!x});let z=(0,Q.useCallback)(()=>{D(!1),u(!1),L&&l(N,L)},[L,N,l,u]),ae=(0,Q.useCallback)(()=>{S(!0)},[]),oe=(0,Q.useCallback)(()=>{S(!1)},[]),se=(0,Q.useCallback)(e=>{if(x){if(e.key===`up`||e.ctrl&&e.key===`p`){e.preventDefault(),C===0?oe():w(0);return}if(e.key===`down`||e.ctrl&&e.key===`n`){e.preventDefault(),y&&C===0&&w(1);return}if(e.key===`return`){e.preventDefault(),C===0?g():_();return}e.key===`escape`&&(e.preventDefault(),f());return}if(E){e.key===`escape`&&(e.preventDefault(),z());return}if(e.key===`up`||e.ctrl&&e.key===`p`)e.preventDefault(),F>0&&ie(`up`);else if(e.key===`down`||e.ctrl&&e.key===`n`)e.preventDefault(),F===P.length-1?ae():ie(`down`);else if(e.key===`return`)e.preventDefault(),re(F);else if(e.key===`n`&&!e.ctrl&&!e.meta)e.preventDefault(),D(!0),u(!0);else if(e.key===`escape`)e.preventDefault(),f();else if(e.key.length===1&&e.key>=`1`&&e.key<=`9`){e.preventDefault();let t=parseInt(e.key,10)-1;t<P.length&&ie(t)}},[x,C,y,E,F,P.length,oe,ae,ie,re,z,g,_,f,u]),ce=ne?.preview||null,{columns:le}=de(),ue=le-30-4,fe=(0,Q.useMemo)(()=>o?Math.max(1,o-11):void 0,[o]);return(0,$.jsxs)(b,{flexDirection:`column`,marginTop:1,tabIndex:0,autoFocus:!0,onKeyDown:se,children:[(0,$.jsx)(m,{color:`inactive`}),(0,$.jsxs)(b,{flexDirection:`column`,paddingTop:0,children:[(0,$.jsx)(Qy,{questions:t,currentQuestionIndex:n,answers:r,hideSubmitTab:a}),(0,$.jsx)(r_,{title:e.question,color:`text`}),(0,$.jsxs)(b,{flexDirection:`column`,minHeight:o,children:[(0,$.jsxs)(b,{marginTop:1,flexDirection:`row`,gap:4,children:[(0,$.jsx)(b,{flexDirection:`column`,width:30,children:P.map((e,t)=>{let n=F===t,r=L===e.label;return(0,$.jsxs)(b,{flexDirection:`row`,children:[n?(0,$.jsx)(T,{color:`suggestion`,children:d.pointer}):(0,$.jsx)(T,{children:` `}),(0,$.jsxs)(T,{dimColor:!0,children:[` `,t+1,`.`]}),(0,$.jsxs)(T,{color:r?`success`:n?`suggestion`:void 0,bold:n,children:[` `,e.label]}),r&&(0,$.jsxs)(T,{color:`success`,children:[` `,d.tick]})]},e.label)})}),(0,$.jsxs)(b,{flexDirection:`column`,flexGrow:1,children:[(0,$.jsx)(Yy,{content:ce||`No preview available`,maxLines:fe,minWidth:s,maxWidth:ue}),(0,$.jsxs)(b,{marginTop:1,flexDirection:`row`,gap:1,children:[(0,$.jsx)(T,{color:`suggestion`,children:`Notes:`}),E?(0,$.jsx)(Xs,{value:R,placeholder:`Add notes on this design…`,onChange:e=>{c(N,{textInputValue:e},!1)},onSubmit:z,onExit:z,focus:!0,showCursor:!0,columns:60,cursorOffset:O,onChangeCursorOffset:k}):(0,$.jsx)(T,{dimColor:!0,italic:!0,children:R||`press n to add notes`})]})]})]}),(0,$.jsxs)(b,{flexDirection:`column`,marginTop:1,children:[(0,$.jsx)(m,{color:`inactive`}),(0,$.jsxs)(b,{flexDirection:`row`,gap:1,children:[x&&C===0?(0,$.jsx)(T,{color:`suggestion`,children:d.pointer}):(0,$.jsx)(T,{children:` `}),(0,$.jsx)(T,{color:x&&C===0?`suggestion`:void 0,children:`Chat about this`})]}),y&&(0,$.jsxs)(b,{flexDirection:`row`,gap:1,children:[x&&C===1?(0,$.jsx)(T,{color:`suggestion`,children:d.pointer}):(0,$.jsx)(T,{children:` `}),(0,$.jsx)(T,{color:x&&C===1?`suggestion`:void 0,children:`Skip interview and plan immediately`})]})]}),(0,$.jsx)(b,{marginTop:1,children:(0,$.jsxs)(T,{color:`inactive`,dimColor:!0,children:[`Enter to select · `,d.arrowUp,`/`,d.arrowDown,` to navigate · n to add notes`,t.length>1&&(0,$.jsx)($.Fragment,{children:` · Tab to switch questions`}),E&&M&&(0,$.jsxs)($.Fragment,{children:[` · ctrl+g to edit in `,M]}),` · Esc to cancel`]})})]})]})]})}u(),B(),q(),qg(),Ei(),Zg(),ri(),t_();function eb({question:e,questions:t,currentQuestionIndex:n,answers:r,questionStates:i,hideSubmitTab:a=!1,planFilePath:o,minContentHeight:s,minContentWidth:c,onUpdateQuestionState:l,onAnswer:u,onTextInputFocus:f,onCancel:p,onSubmit:h,onTabPrev:g,onTabNext:_,onRespondToClaude:v,onFinishPlanInterview:y,onImagePaste:x,pastedContents:S,onRemoveImage:C}){let w=J(e=>e.toolPermissionContext.mode)===`plan`,[E,D]=(0,Q.useState)(!1),[O,k]=(0,Q.useState)(0),[A,j]=(0,Q.useState)(!1),M=Jg(),N=M?Jr(M):null,ee=(0,Q.useCallback)(e=>{let t=e===`__other__`;j(t),f(t)},[f]),P=(0,Q.useCallback)(()=>{D(!0)},[]),F=(0,Q.useCallback)(()=>{D(!1)},[]),I=(0,Q.useCallback)(e=>{if(E){if(e.key===`up`||e.ctrl&&e.key===`p`){e.preventDefault(),O===0?F():k(0);return}if(e.key===`down`||e.ctrl&&e.key===`n`){e.preventDefault(),w&&O===0&&k(1);return}if(e.key===`return`){e.preventDefault(),O===0?v():y();return}e.key===`escape`&&(e.preventDefault(),p())}},[E,O,w,F,v,y,p]),te=e.options.map(e=>({type:`text`,value:e.label,label:e.label,description:e.description})),ne=e.question,L=i[ne],R=(0,Q.useCallback)(async(t,n)=>{let r=await Yg(t);r.content!==null&&r.content!==t&&(n(r.content),l(ne,{textInputValue:r.content},e.multiSelect??!1))},[ne,l,e.multiSelect]),re={type:`input`,value:`__other__`,label:`Other`,placeholder:e.multiSelect?`Type something`:`Type something.`,initialValue:L?.textInputValue??``,onChange:t=>{l(ne,{textInputValue:t},e.multiSelect??!1)}},ie=[...te,re];return!e.multiSelect&&e.options.some(e=>e.preview)?(0,$.jsx)($y,{question:e,questions:t,currentQuestionIndex:n,answers:r,questionStates:i,hideSubmitTab:a,minContentHeight:s,minContentWidth:c,onUpdateQuestionState:l,onAnswer:u,onTextInputFocus:f,onCancel:p,onTabPrev:g,onTabNext:_,onRespondToClaude:v,onFinishPlanInterview:y}):(0,$.jsxs)(b,{flexDirection:`column`,marginTop:0,tabIndex:0,autoFocus:!0,onKeyDown:I,children:[w&&o&&(0,$.jsxs)(b,{flexDirection:`column`,gap:0,children:[(0,$.jsx)(m,{color:`inactive`}),(0,$.jsxs)(T,{color:`inactive`,children:[`Planning: `,(0,$.jsx)(Do,{filePath:o})]})]}),(0,$.jsx)(b,{marginTop:-1,children:(0,$.jsx)(m,{color:`inactive`})}),(0,$.jsxs)(b,{flexDirection:`column`,paddingTop:0,children:[(0,$.jsx)(Qy,{questions:t,currentQuestionIndex:n,answers:r,hideSubmitTab:a}),(0,$.jsx)(r_,{title:e.question,color:`text`}),(0,$.jsxs)(b,{flexDirection:`column`,minHeight:s,children:[(0,$.jsx)(b,{marginTop:1,children:e.multiSelect?(0,$.jsx)(Dn,{options:ie,defaultValue:i[e.question]?.selectedValue,onChange:e=>{l(ne,{selectedValue:e},!0);let t=e.includes(`__other__`)?i[ne]?.textInputValue:void 0,n=e.filter(e=>e!==`__other__`).concat(t?[t]:[]);u(ne,n,void 0,!1)},onFocus:ee,onCancel:p,submitButtonText:n===t.length-1?`Submit`:`Next`,onSubmit:h,onDownFromLastItem:P,isDisabled:E,onOpenEditor:R,onImagePaste:x,pastedContents:S,onRemoveImage:C},e.question):(0,$.jsx)(pi,{options:ie,defaultValue:i[e.question]?.selectedValue,onChange:e=>{l(ne,{selectedValue:e},!1);let t=e===`__other__`?i[ne]?.textInputValue:void 0;u(ne,e,t)},onFocus:ee,onCancel:p,onDownFromLastItem:P,isDisabled:E,layout:`compact-vertical`,onOpenEditor:R,onImagePaste:x,pastedContents:S,onRemoveImage:C},e.question)}),(0,$.jsxs)(b,{flexDirection:`column`,children:[(0,$.jsx)(m,{color:`inactive`}),(0,$.jsxs)(b,{flexDirection:`row`,gap:1,children:[E&&O===0?(0,$.jsx)(T,{color:`suggestion`,children:d.pointer}):(0,$.jsx)(T,{children:` `}),(0,$.jsxs)(T,{color:E&&O===0?`suggestion`:void 0,children:[ie.length+1,`. Chat about this`]})]}),w&&(0,$.jsxs)(b,{flexDirection:`row`,gap:1,children:[E&&O===1?(0,$.jsx)(T,{color:`suggestion`,children:d.pointer}):(0,$.jsx)(T,{children:` `}),(0,$.jsxs)(T,{color:E&&O===1?`suggestion`:void 0,children:[ie.length+2,`. Skip interview and plan immediately`]})]})]}),(0,$.jsx)(b,{marginTop:1,children:(0,$.jsxs)(T,{color:`inactive`,dimColor:!0,children:[`Enter to select ·`,` `,t.length===1?(0,$.jsxs)($.Fragment,{children:[d.arrowUp,`/`,d.arrowDown,` to navigate`]}):`Tab/Arrow keys to navigate`,A&&N&&(0,$.jsxs)($.Fragment,{children:[` · ctrl+g to edit in `,N]}),` · Esc to cancel`]})})]})]})]})}function tb(e,t){if(!e)return null;if(e.type===`classifier`)return e.classifier===`auto-mode`?{reasonString:`Auto mode classifier requires confirmation for this ${t}.\n${e.reason}`,configString:void 0,themeColor:`error`}:{reasonString:`Classifier ${H.bold(e.classifier)} requires confirmation for this ${t}.\n${e.reason}`,configString:void 0};switch(e.type){case`rule`:return{reasonString:`Permission rule ${H.bold(ff(e.rule.ruleValue))} requires confirmation for this ${t}.`,configString:e.rule.source===`policySettings`?void 0:`/permissions to update rules`};case`hook`:{let n=e.reason?`:\n${e.reason}`:`.`,r=e.hookSource?` ${H.dim(`[${e.hookSource}]`)}`:``;return{reasonString:`Hook ${H.bold(e.hookName)} requires confirmation for this ${t}${n}${r}`,configString:`/hooks to update`}}case`safetyCheck`:case`other`:return{reasonString:e.reason,configString:void 0};case`workingDir`:return{reasonString:e.reason,configString:`/permissions to update rules`};default:return null}}function nb({permissionResult:e,toolType:t}){let n=J(e=>e.toolPermissionContext.mode),r=tb(e?.decisionReason,t);if(!r)return null;let i=r.themeColor??(e?.decisionReason?.type===`hook`&&n===`auto`?`warning`:void 0);return(0,rb.jsxs)(b,{marginBottom:1,flexDirection:`column`,children:[i?(0,rb.jsx)(T,{color:i,children:r.reasonString}):(0,rb.jsx)(T,{children:(0,rb.jsx)(g,{children:r.reasonString})}),r.configString&&(0,rb.jsx)(T,{dimColor:!0,children:r.configString})]})}var rb,ib=t((()=>{z(),B(),q(),rb=ve()}));u(),B(),ri(),t_(),ib();function ab({questions:e,currentQuestionIndex:t,answers:n,allQuestionsAnswered:r,permissionResult:i,minContentHeight:a,onFinalResponse:o}){return(0,$.jsxs)(b,{flexDirection:`column`,marginTop:1,children:[(0,$.jsx)(m,{color:`inactive`}),(0,$.jsxs)(b,{flexDirection:`column`,borderTop:!0,borderColor:`inactive`,paddingTop:0,children:[(0,$.jsx)(Qy,{questions:e,currentQuestionIndex:t,answers:n}),(0,$.jsx)(r_,{title:`Review your answers`,color:`text`}),(0,$.jsxs)(b,{flexDirection:`column`,marginTop:1,minHeight:a,children:[!r&&(0,$.jsx)(b,{marginBottom:1,children:(0,$.jsxs)(T,{color:`warning`,children:[d.warning,` You have not answered all questions`]})}),Object.keys(n).length>0&&(0,$.jsx)(b,{flexDirection:`column`,marginBottom:1,children:e.filter(e=>e?.question&&n[e.question]).map(e=>{let t=n[e?.question];return(0,$.jsxs)(b,{flexDirection:`column`,marginLeft:1,children:[(0,$.jsxs)(T,{children:[d.bullet,` `,e?.question||`Question`]}),(0,$.jsx)(b,{marginLeft:2,children:(0,$.jsxs)(T,{color:`success`,children:[d.arrowRight,` `,t]})})]},e?.question||`answer`)})}),(0,$.jsx)(nb,{permissionResult:i,toolType:`tool`}),(0,$.jsx)(T,{color:`inactive`,children:`Ready to submit your answers?`}),(0,$.jsx)(b,{marginTop:1,children:(0,$.jsx)(pi,{options:[{type:`text`,label:`Submit answers`,value:`submit`},{type:`text`,label:`Cancel`,value:`cancel`}],onChange:e=>o(e),onCancel:()=>o(`cancel`)})})]})]})]})}function ob(e,t){switch(t.type){case`next-question`:return{...e,currentQuestionIndex:e.currentQuestionIndex+1,isInTextInput:!1};case`prev-question`:return{...e,currentQuestionIndex:Math.max(0,e.currentQuestionIndex-1),isInTextInput:!1};case`update-question-state`:{let n=e.questionStates[t.questionText],r={selectedValue:t.updates.selectedValue??n?.selectedValue??(t.isMultiSelect?[]:void 0),textInputValue:t.updates.textInputValue??n?.textInputValue??``};return{...e,questionStates:{...e.questionStates,[t.questionText]:r}}}case`set-answer`:{let n={...e,answers:{...e.answers,[t.questionText]:t.answer}};return t.shouldAdvance?{...n,currentQuestionIndex:n.currentQuestionIndex+1,isInTextInput:!1}:n}case`set-text-input-mode`:return{...e,isInTextInput:t.isInInput}}}var sb={currentQuestionIndex:0,answers:{},questionStates:{},isInTextInput:!1};function cb(){let[e,t]=(0,Q.useReducer)(ob,sb),n=(0,Q.useCallback)(()=>{t({type:`next-question`})},[]),r=(0,Q.useCallback)(()=>{t({type:`prev-question`})},[]),i=(0,Q.useCallback)((e,n,r)=>{t({type:`update-question-state`,questionText:e,updates:n,isMultiSelect:r})},[]),a=(0,Q.useCallback)((e,n,r=!0)=>{t({type:`set-answer`,questionText:e,answer:n,shouldAdvance:r})},[]),o=(0,Q.useCallback)(e=>{t({type:`set-text-input-mode`,isInInput:e})},[]);return{currentQuestionIndex:e.currentQuestionIndex,answers:e.answers,questionStates:e.questionStates,isInTextInput:e.isInTextInput,nextQuestion:n,prevQuestion:r,updateQuestionState:i,setAnswer:a,setTextInputMode:o}}Yt(),wa(),B(),zh(),Cp(),q(),Tu(),ap(),Ps();var lb=12,ub=40,db=15;function fb(e){return ao().syntaxHighlightingDisabled?(0,$.jsx)(mb,{...e,highlight:null}):(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(mb,{...e,highlight:null}),children:(0,$.jsx)(pb,{...e})})}function pb(e){let t=(0,Q.use)(qu());return(0,$.jsx)(mb,{...e,highlight:t})}function mb({toolUseConfirm:e,onDone:t,onReject:n,highlight:r}){let i=(0,Q.useMemo)(()=>Bt.inputSchema.safeParse(e.input),[e.input]),a=i.success&&i.data.questions||[],{rows:o}=de(),[s]=y(),{globalContentHeight:c,globalContentWidth:l}=(0,Q.useMemo)(()=>{let e=0,t=0,n=Math.max(lb,o-db);for(let i of a)if(i.options.some(e=>e.preview)){let a=Math.max(1,n-11),o=0;for(let e of i.options)if(e.preview){let n=Qu(e.preview,s,r).split(`
|
|
3
3
|
`),i=n.length>a,c=i?a:n.length;o=Math.max(o,c+ +!!i+2);for(let e of n)t=Math.max(t,_(e))}let c=o+2,l=i.options.length+2;e=Math.max(e,Math.max(l,c)+7)}else e=Math.max(e,i.options.length+3+7);return{globalContentHeight:Math.min(Math.max(e,lb),n),globalContentWidth:Math.max(t,ub)}},[a,o,s,r]),u=i.success?i.data.metadata?.source:void 0,[d,f]=(0,Q.useState)({}),p=(0,Q.useRef)(0);function m(e,t,n,r,i,a){let o=p.current++,s={id:o,type:`image`,content:t,mediaType:n||`image/png`,filename:r||`Pasted image`,dimensions:i};Ir(s),To(s),f(t=>({...t,[e]:{...t[e]??{},[o]:s}}))}let h=(0,Q.useCallback)((e,t)=>{f(n=>{let r={...n[e]??{}};return delete r[t],{...n,[e]:r}})},[]),g=Object.values(d).flatMap(e=>Object.values(e)).filter(e=>e.type===`image`),b=J(e=>e.toolPermissionContext.mode)===`plan`,x=b?nl():void 0,{currentQuestionIndex:S,answers:C,questionStates:w,isInTextInput:T,nextQuestion:E,prevQuestion:D,updateQuestionState:O,setAnswer:k,setTextInputMode:A}=cb(),j=S<(a?.length||0)?a?.[S]:null,M=S===(a?.length||0),N=a?.every(e=>e?.question&&!!C[e.question])??!1,ee=a.length===1&&!a[0]?.multiSelect,P=(0,Q.useCallback)(()=>{u&&Z(`tengu_ask_user_question_rejected`,{source:u,questionCount:a.length,isInPlanMode:b,interviewPhaseEnabled:b&&Kr()}),t(),n(),e.onReject()},[t,n,e,u,a.length,b]),F=(0,Q.useCallback)(async()=>{let n=`The user wants to clarify these questions.
|
|
4
4
|
This means they may have additional information, context or questions for you.
|
|
@@ -24,7 +24,7 @@ Input:
|
|
|
24
24
|
${o}
|
|
25
25
|
${s?`\nRecent conversation context:\n${s}`:``}
|
|
26
26
|
|
|
27
|
-
Explain this command in context.`,l=await An({model:Ah()?_m():Fm(),system:$b,messages:[{role:`user`,content:c}],tools:[ex],tool_choice:{type:`tool`,name:`explain_command`},signal:i,querySource:`permission_explainer`}),u=Date.now()-a;Y(`Permission explainer: API returned in ${u}ms, stop_reason=${l.stop_reason}`);let d=l.content.find(e=>e.type===`tool_use`);if(d&&d.type===`tool_use`){Y(`Permission explainer: tool input: ${$d(d.input).slice(0,500)}`);let t=tx().safeParse(d.input);if(t.success){let n={riskLevel:t.data.riskLevel,explanation:t.data.explanation,reasoning:t.data.reasoning,risk:t.data.risk};return Z(`tengu_permission_explainer_generated`,{tool_name:th(e),risk_level:Yb[n.riskLevel],latency_ms:u}),Y(`Permission explainer: ${n.riskLevel} risk for ${e} (${u}ms)`),n}}return Z(`tengu_permission_explainer_error`,{tool_name:th(e),error_type:Xb,latency_ms:u}),Y(`Permission explainer: no parsed output in response`),null}catch(t){let n=Date.now()-a;return i.aborted?(Y(`Permission explainer: request aborted for ${e}`),null):(Y(`Permission explainer error: ${df(t)}`),X(t),Z(`tengu_permission_explainer_error`,{tool_name:th(e),error_type:t instanceof Error&&t.name===`AbortError`?Zb:Qb,latency_ms:n}),null)}}B(),zh(),Cp();var ox=`Loading explanation…`;function sx(){let[e,t]=as(`responding`,ox,!1);return(0,$.jsx)(b,{ref:e,children:(0,$.jsx)(T,{children:ox.split(``).map((e,n)=>(0,$.jsx)(Rc,{char:e,index:n,glimmerIndex:t,messageColor:`inactive`,shimmerColor:`text`},n))})})}function cx(e){switch(e){case`LOW`:return`success`;case`MEDIUM`:return`warning`;case`HIGH`:return`error`}}function lx(e){switch(e){case`LOW`:return`Low risk`;case`MEDIUM`:return`Med risk`;case`HIGH`:return`High risk`}}function ux(e){return ax({toolName:e.toolName,toolInput:e.toolInput,toolDescription:e.toolDescription,messages:e.messages,signal:new AbortController().signal}).catch(()=>null)}function dx(e){let t=ix(),[n,r]=(0,Q.useState)(!1),[i,a]=(0,Q.useState)(null);return j(`confirm:toggleExplanation`,()=>{n||(Z(`tengu_permission_explainer_shortcut_used`,{}),i||a(ux(e))),r(e=>!e)},{context:`Confirmation`,isActive:t}),{visible:n,enabled:t,promise:i}}function fx({promise:e}){let t=(0,Q.use)(e);return t?(0,$.jsxs)(b,{flexDirection:`column`,marginTop:1,children:[(0,$.jsx)(T,{children:t.explanation}),(0,$.jsx)(b,{marginTop:1,children:(0,$.jsx)(T,{children:t.reasoning})}),(0,$.jsx)(b,{marginTop:1,children:(0,$.jsxs)(T,{children:[(0,$.jsxs)(T,{color:cx(t.riskLevel),children:[lx(t.riskLevel),`:`]}),(0,$.jsxs)(T,{children:[` `,t.risk]})]})})]}):(0,$.jsx)(b,{marginTop:1,children:(0,$.jsx)(T,{dimColor:!0,children:`Explanation unavailable`})})}function px({visible:e,promise:t}){return!e||!t?null:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(b,{marginTop:1,children:(0,$.jsx)(sx,{})}),children:(0,$.jsx)(fx,{promise:t})})}wa(),B(),ap(),Id(),fo();function mx(e){let[t]=(0,Q.useState)(()=>_x(e.file_path,e.edits));return(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(gx,{placeholder:!0}),children:(0,$.jsx)(hx,{promise:t,file_path:e.file_path})})}function hx({promise:e,file_path:t}){let{patch:n,firstLine:r,fileContent:i}=(0,Q.use)(e),{columns:a}=de();return(0,$.jsx)(gx,{children:(0,$.jsx)(Ia,{hunks:n,dim:!1,width:a,filePath:t,firstLine:r,fileContent:i})})}function gx({children:e,placeholder:t}){return(0,$.jsx)(b,{flexDirection:`column`,children:(0,$.jsx)(b,{borderColor:`subtle`,borderStyle:`dashed`,flexDirection:`column`,borderLeft:!1,borderRight:!1,children:t?(0,$.jsx)(T,{dimColor:!0,children:`…`}):e})})}async function _x(e,t){let n=t.filter(e=>e.old_string!=null&&e.new_string!=null),r=n.length===1?n[0]:void 0;if(r&&r.old_string.length>=8192)return vx(e,[r]);try{let t=await Vt(e);if(t===null)return vx(e,n);try{if(!r||r.old_string===``){let r=await Za(t);return r===null?vx(e,n):{patch:Tt({filePath:e,fileContents:r,edits:n.map(e=>yx(r,e))}),firstLine:Bp(r),fileContent:r}}let i=await nr(t,r.old_string,3);if(i.truncated||i.content===``)return vx(e,[r]);let a=yx(i.content,r);return{patch:Xi(Tt({filePath:e,fileContents:i.content,edits:[a]}),i.lineOffset-1),firstLine:i.lineOffset===1?Bp(i.content):null,fileContent:i.content}}finally{await t.close()}}catch(t){return X(t),vx(e,n)}}function vx(e,t){return{patch:t.flatMap(t=>Tt({filePath:e,fileContents:t.old_string,edits:[t]})),firstLine:null,fileContent:void 0}}function yx(e,t){let n=Ii(e,t.old_string)||t.old_string;return{...t,old_string:n}}Lr(),Cp(),qr(),Vf(),Gu(),ef(),Ei(),ap();function bx({onChange:e,toolUseContext:t,filePath:n,edits:r,editMode:i}){let a=(0,Q.useRef)(!1),[o,s]=(0,Q.useState)(!1),c=(0,Q.useMemo)(()=>Bv().slice(0,6),[]),l=(0,Q.useMemo)(()=>`✻ [Claude Code] ${Av(n)} (${c}) ⧉`,[n,c]),u=ln(t.options.mcpClients)&&Bf().diffTool===`auto`&&!n.endsWith(`.ipynb`),d=$t(t.options.mcpClients)??`IDE`;async function f(){if(u)try{Z(`tengu_ext_will_show_diff`,{});let{oldContent:o,newContent:s}=await Sx(n,r,t,l);if(a.current)return;Z(`tengu_ext_diff_accepted`,{});let c=xx(n,o,s,i);if(c.length===0){Z(`tengu_ext_diff_rejected`,{});let i=ya(t.options.mcpClients);i&&await Cx(l,i),e({type:`reject`},{file_path:n,edits:r});return}e({type:`accept-once`},{file_path:n,edits:c})}catch(e){X(e),s(!0)}}return(0,Q.useEffect)(()=>(f(),()=>{a.current=!0}),[]),{closeTabInIDE(){let e=ya(t.options.mcpClients);return e?Cx(l,e):Promise.resolve()},showingDiffInIDE:u&&!o,ideName:d,hasError:o}}function xx(e,t,n,r){let i=r===`single`,a=Gs({filePath:e,oldContent:t,newContent:n,singleHunk:i});return a.length===0?[]:(i&&a.length>1&&X(Error(`Unexpected number of hunks: ${a.length}. Expected 1 hunk.`)),kn(a))}async function Sx(e,t,n,r){let i=!1,a=pp(e),o=``;try{o=gp(a)}catch(e){if(!Zd(e))throw e}async function s(){if(!i){i=!0;try{await Cx(r,c)}catch(e){X(e)}process.off(`beforeExit`,s),n.abortController.signal.removeEventListener(`abort`,s)}}n.abortController.signal.addEventListener(`abort`,s),process.on(`beforeExit`,s);let c=ya(n.options.mcpClients);try{let{updatedFile:e}=pr({filePath:a,fileContents:o,edits:t});if(!c||c.type!==`connected`)throw Error(`IDE client not available`);let n=a,i=c.config.ideRunningInWindows===!0;up()===`wsl`&&i&&process.env.WSL_DISTRO_NAME&&(n=new Ht(process.env.WSL_DISTRO_NAME).toIDEPath(a));let l=await bu(`openDiff`,{old_file_path:n,new_file_path:n,new_file_contents:e,tab_name:r},c),u=Array.isArray(l)?l:[l];if(Ex(u))return s(),{oldContent:o,newContent:u[1].text};if(wx(u))return s(),{oldContent:o,newContent:e};if(Tx(u))return s(),{oldContent:o,newContent:o};throw Error(`Not accepted`)}catch(e){throw X(e),s(),e}}async function Cx(e,t){try{if(!t||t.type!==`connected`)throw Error(`IDE client not available`);await bu(`close_tab`,{tab_name:e},t)}catch(e){X(e)}}function wx(e){return Array.isArray(e)&&typeof e[0]==`object`&&e[0]!==null&&`type`in e[0]&&e[0].type===`text`&&`text`in e[0]&&e[0].text===`TAB_CLOSED`}function Tx(e){return Array.isArray(e)&&typeof e[0]==`object`&&e[0]!==null&&`type`in e[0]&&e[0].type===`text`&&`text`in e[0]&&e[0].text===`DIFF_REJECTED`}function Ex(e){return Array.isArray(e)&&e[0]?.type===`text`&&e[0].text===`FILE_SAVED`&&typeof e[1].text==`string`}B(),qd(),Ei(),ri();function Dx({onChange:e,options:t,input:n,filePath:r,ideName:i,symlinkTarget:a,rejectFeedback:o,acceptFeedback:s,setFocusedOption:c,onInputModeToggle:l,focusedOption:u,yesInputMode:d,noInputMode:f}){return(0,$.jsx)(he,{color:`permission`,children:(0,$.jsxs)(b,{flexDirection:`column`,gap:1,children:[(0,$.jsxs)(T,{bold:!0,color:`permission`,children:[`Opened changes in `,i,` ⧉`]}),a&&(0,$.jsx)(T,{color:`warning`,children:Pv(Jd(),a).startsWith(`..`)?`This will modify ${a} (outside working directory) via a symlink`:`Symlink target: ${a}`}),Li()&&(0,$.jsx)(T,{dimColor:!0,children:`Save file to continue…`}),(0,$.jsxs)(b,{flexDirection:`column`,children:[(0,$.jsxs)(T,{children:[`Do you want to make this edit to `,(0,$.jsx)(T,{bold:!0,children:Av(r)}),`?`]}),(0,$.jsx)(pi,{options:t,inlineDescriptions:!0,onChange:r=>{let i=t.find(e=>e.value===r);if(i){if(i.option.type===`reject`){let t=o.trim();e(i.option,n,t||void 0);return}if(i.option.type===`accept-once`){let t=s.trim();e(i.option,n,t||void 0);return}e(i.option,n)}},onCancel:()=>e({type:`reject`},n),onFocus:e=>c(e),onInputModeToggle:l})]}),(0,$.jsx)(b,{marginTop:1,children:(0,$.jsxs)(T,{dimColor:!0,children:[`Esc to cancel`,(u===`yes`&&!d||u===`no`&&!f)&&` · Tab to amend`]})})]})})}rt(),B(),fp();function Ox(e){let t=pp(e),n=pp(`${ct()}/.claude`),r=Bd(t),i=Bd(n);return r.startsWith(i+Fv.toLowerCase())||r.startsWith(i+`/`)}function kx(e){let t=pp(e),n=Nv(Dv(),`.claude`),r=Bd(t),i=Bd(n);return r.startsWith(i+Fv.toLowerCase())||r.startsWith(i+`/`)}function Ax({filePath:e,toolPermissionContext:t,operationType:n=`write`,onRejectFeedbackChange:r,onAcceptFeedbackChange:i,yesInputMode:a=!1,noInputMode:o=!1}){let s=[],c=Hr(`chat:cycleMode`,`Chat`,`shift+tab`);a&&i?s.push({type:`input`,label:`Yes`,value:`yes`,placeholder:`and tell Claude what to do next`,onChange:i,allowEmptySubmitToCancel:!0,option:{type:`accept-once`}}):s.push({label:`Yes`,value:`yes`,option:{type:`accept-once`}});let l=Wt(e,t),u=Ox(e),d=kx(e);if((u||d)&&n!==`read`)s.push({label:`Yes, allow edits to .claude/ config for this session`,value:`yes-claude-folder`,option:{type:`accept-session`,scope:d?`global-claude-folder`:`claude-folder`}});else{let t;if(l)t=n===`read`?`Yes, during this session`:(0,$.jsxs)(T,{children:[`Yes, allow all edits during this session `,(0,$.jsxs)(T,{bold:!0,children:[`(`,c,`)`]})]});else{let r=Av(hp(e))||`this directory`;t=n===`read`?(0,$.jsxs)(T,{children:[`Yes, allow reading from `,(0,$.jsxs)(T,{bold:!0,children:[r,`/`]}),` during this session`]}):(0,$.jsxs)(T,{children:[`Yes, allow all edits in `,(0,$.jsxs)(T,{bold:!0,children:[r,`/`]}),` during this session`,` `,(0,$.jsxs)(T,{bold:!0,children:[`(`,c,`)`]})]})}s.push({label:t,value:`yes-session`,option:{type:`accept-session`}})}return o&&r?s.push({type:`input`,label:`No`,value:`no`,placeholder:`and tell Claude what to do differently`,onChange:r,allowEmptySubmitToCancel:!0,option:{type:`reject`}}):s.push({label:`No`,value:`no`,option:{type:`reject`}}),s}Cp(),eh(),Ef(),Zr(),Rb();function jx(e,t,n,r,i){Lb({completion_type:t,event:e,metadata:{language_name:n,message_id:r,platform:_f.platform,hasFeedback:i??!1}})}function Mx(e,t){let{messageId:n,toolUseConfirm:r,onDone:i,completionType:a,languageName:o}=e;jx(`accept`,a,o,n),Z(`tengu_accept_submitted`,{toolName:th(r.tool.name),isMcp:r.tool.isMcp??!1,has_instructions:!!t?.feedback,instructions_length:t?.feedback?.length??0,entered_feedback_mode:t?.enteredFeedbackMode??!1}),i(),r.onAllow(r.input,[],t?.feedback)}function Nx(e,t){let{messageId:n,path:r,toolUseConfirm:i,toolPermissionContext:a,onDone:o,completionType:s,languageName:c,operationType:l}=e;if(jx(`accept`,s,c,n),t?.scope===`claude-folder`||t?.scope===`global-claude-folder`){let e=[{type:`addRules`,rules:[{toolName:Xm,ruleContent:t.scope===`global-claude-folder`?Wm:Km}],behavior:`allow`,destination:`session`}];o(),i.onAllow(i.input,e);return}let u=r?Vi(r,l,a):[];o(),i.onAllow(i.input,u)}function Px(e,t){let{messageId:n,toolUseConfirm:r,onDone:i,onReject:a,completionType:o,languageName:s}=e;jx(`reject`,o,s,n,t?.hasFeedback),Z(`tengu_reject_submitted`,{toolName:th(r.tool.name),isMcp:r.tool.isMcp??!1,has_instructions:!!t?.feedback,instructions_length:t?.feedback?.length??0,entered_feedback_mode:t?.enteredFeedbackMode??!1}),i(),a(),r.onReject(t?.feedback)}var Fx={"accept-once":Mx,"accept-session":Nx,reject:Px};q(),zh(),Cp(),eh();function Ix({filePath:e,completionType:t,languageName:n,toolUseConfirm:r,onDone:i,onReject:a,parseInput:o,operationType:s=`write`}){let c=J(e=>e.toolPermissionContext),[l,u]=(0,Q.useState)(``),[d,f]=(0,Q.useState)(``),[p,m]=(0,Q.useState)(`yes`),[h,g]=(0,Q.useState)(!1),[_,y]=(0,Q.useState)(!1),[b,x]=(0,Q.useState)(!1),[S,C]=(0,Q.useState)(!1),w=(0,Q.useMemo)(()=>Ax({filePath:e,toolPermissionContext:c,operationType:s,onRejectFeedbackChange:f,onAcceptFeedbackChange:u,yesInputMode:h,noInputMode:_}),[e,c,s,h,_]),T=(0,Q.useCallback)((o,l,u)=>{let d={messageId:r.assistantMessage.message.id,path:e,toolUseConfirm:r,toolPermissionContext:c,onDone:i,onReject:a,completionType:t,languageName:n,operationType:s},f=r.onAllow;r.onAllow=(e,t,n)=>{f(l,t,n)};let p=Fx[o.type];p(d,{feedback:u,hasFeedback:!!u,enteredFeedbackMode:o.type===`accept-once`?b:S,scope:o.type===`accept-session`?o.scope:void 0})},[e,t,n,r,c,i,a,s,b,S]);return v({"confirm:cycleMode":(0,Q.useCallback)(()=>{let e=w.find(e=>e.option.type===`accept-session`);if(e){let t=o(r.input);T(e.option,t)}},[w,o,r.input,T])},{context:`Confirmation`}),{options:w,onChange:T,acceptFeedback:l,rejectFeedback:d,focusedOption:p,setFocusedOption:(0,Q.useCallback)(e=>{e!==`yes`&&h&&!l.trim()&&g(!1),e!==`no`&&_&&!d.trim()&&y(!1),m(e)},[h,_,l,d]),handleInputModeToggle:(0,Q.useCallback)(e=>{let t={toolName:th(r.tool.name),isMcp:r.tool.isMcp??!1};e===`yes`?h?(g(!1),Z(`tengu_accept_feedback_mode_collapsed`,t)):(g(!0),x(!0),Z(`tengu_accept_feedback_mode_entered`,t)):e===`no`&&(_?(y(!1),Z(`tengu_reject_feedback_mode_collapsed`,t)):(y(!0),C(!0),Z(`tengu_reject_feedback_mode_entered`,t)))},[h,_,r]),yesInputMode:h,noInputMode:_}}B(),Tu(),qd(),fp(),ri();function Lx({toolUseConfirm:e,toolUseContext:t,onDone:n,onReject:r,title:i,subtitle:a,question:o=`Do you want to proceed?`,content:s,completionType:c=`tool_use_single`,path:l,parseInput:u,operationType:d=`write`,ideDiffSupport:f,languageName:p}){let m=(0,Q.useMemo)(()=>p??(l?Ml(l):`none`),[p,l]);Vb(e,(0,Q.useMemo)(()=>({completion_type:c,language_name:m}),[c,m]));let h=(0,Q.useMemo)(()=>{if(!l||d===`read`)return null;let e=pp(l),{resolvedPath:t,isSymlink:n}=uf(rf(),e);return n?t:null},[l,d]),g=Ix({filePath:l||``,completionType:c,languageName:m,toolUseConfirm:e,onDone:n,onReject:r,parseInput:u,operationType:d}),{options:_,acceptFeedback:v,rejectFeedback:y,setFocusedOption:x,handleInputModeToggle:S,focusedOption:C,yesInputMode:w,noInputMode:E}=g,D=u(e.input),O=(0,Q.useMemo)(()=>f?f.getConfig(u(e.input)):null,[f,e.input]),{closeTabInIDE:k,showingDiffInIDE:A,ideName:j}=bx(O?{onChange:(e,t)=>{let n=f.applyChanges(D,t.edits);g.onChange(e,n)},toolUseContext:t,filePath:O.filePath,edits:(O.edits||[]).map(e=>({old_string:e.old_string,new_string:e.new_string,replace_all:e.replace_all||!1})),editMode:O.editMode||`single`}:{onChange:()=>{},toolUseContext:t,filePath:``,edits:[],editMode:`single`}),M=(e,t)=>{k?.(),g.onChange(e,D,t?.trim())};if(A&&O&&l)return(0,$.jsx)(Dx,{onChange:(e,t,n)=>M(e,n),options:_,filePath:l,input:D,ideName:j,symlinkTarget:h,rejectFeedback:y,acceptFeedback:v,setFocusedOption:x,onInputModeToggle:S,focusedOption:C,yesInputMode:w,noInputMode:E});let N=h!=null&&Pv(Jd(),h).startsWith(`..`);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(i_,{title:i,subtitle:a,innerPaddingX:0,children:[h?(0,$.jsx)(b,{paddingX:1,marginBottom:1,children:(0,$.jsx)(T,{color:`warning`,children:N?`This will modify ${h} (outside working directory) via a symlink`:`Symlink target: ${h}`})}):null,s,(0,$.jsxs)(b,{flexDirection:`column`,paddingX:1,children:[typeof o==`string`?(0,$.jsx)(T,{children:o}):o,(0,$.jsx)(pi,{options:_,inlineDescriptions:!0,onChange:e=>{let t=_.find(t=>t.value===e);if(t){if(t.option.type===`reject`){let e=y.trim();M(t.option,e||void 0);return}if(t.option.type===`accept-once`){let e=v.trim();M(t.option,e||void 0);return}M(t.option)}},onCancel:()=>M({type:`reject`}),onFocus:e=>x(e),onInputModeToggle:S})]})]}),(0,$.jsx)(b,{paddingX:1,marginTop:1,children:(0,$.jsxs)(T,{dimColor:!0,children:[`Esc to reject`,(C===`yes`&&!w||C===`no`&&!E)&&` · Tab to add feedback`]})})]})}qd(),ef(),_p(),nf(),B(),ld();function Rx({sedInfo:e,...t}){let{filePath:n}=e;return(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(zx,{sedInfo:e,contentPromise:(0,Q.useMemo)(()=>(async()=>{let e=vp(n);return{oldContent:(await rf().readFile(n,{encoding:e})).replaceAll(`\r
|
|
27
|
+
Explain this command in context.`,l=await An({model:Ah()?_m():Fm(),system:$b,messages:[{role:`user`,content:c}],tools:[ex],tool_choice:{type:`tool`,name:`explain_command`},signal:i,querySource:`permission_explainer`}),u=Date.now()-a;Y(`Permission explainer: API returned in ${u}ms, stop_reason=${l.stop_reason}`);let d=l.content.find(e=>e.type===`tool_use`);if(d&&d.type===`tool_use`){Y(`Permission explainer: tool input: ${$d(d.input).slice(0,500)}`);let t=tx().safeParse(d.input);if(t.success){let n={riskLevel:t.data.riskLevel,explanation:t.data.explanation,reasoning:t.data.reasoning,risk:t.data.risk};return Z(`tengu_permission_explainer_generated`,{tool_name:th(e),risk_level:Yb[n.riskLevel],latency_ms:u}),Y(`Permission explainer: ${n.riskLevel} risk for ${e} (${u}ms)`),n}}return Z(`tengu_permission_explainer_error`,{tool_name:th(e),error_type:Xb,latency_ms:u}),Y(`Permission explainer: no parsed output in response`),null}catch(t){let n=Date.now()-a;return i.aborted?(Y(`Permission explainer: request aborted for ${e}`),null):(Y(`Permission explainer error: ${df(t)}`),X(t),Z(`tengu_permission_explainer_error`,{tool_name:th(e),error_type:t instanceof Error&&t.name===`AbortError`?Zb:Qb,latency_ms:n}),null)}}B(),zh(),Cp();var ox=`Loading explanation…`;function sx(){let[e,t]=as(`responding`,ox,!1);return(0,$.jsx)(b,{ref:e,children:(0,$.jsx)(T,{children:ox.split(``).map((e,n)=>(0,$.jsx)(Rc,{char:e,index:n,glimmerIndex:t,messageColor:`inactive`,shimmerColor:`text`},n))})})}function cx(e){switch(e){case`LOW`:return`success`;case`MEDIUM`:return`warning`;case`HIGH`:return`error`}}function lx(e){switch(e){case`LOW`:return`Low risk`;case`MEDIUM`:return`Med risk`;case`HIGH`:return`High risk`}}function ux(e){return ax({toolName:e.toolName,toolInput:e.toolInput,toolDescription:e.toolDescription,messages:e.messages,signal:new AbortController().signal}).catch(()=>null)}function dx(e){let t=ix(),[n,r]=(0,Q.useState)(!1),[i,a]=(0,Q.useState)(null);return j(`confirm:toggleExplanation`,()=>{n||(Z(`tengu_permission_explainer_shortcut_used`,{}),i||a(ux(e))),r(e=>!e)},{context:`Confirmation`,isActive:t}),{visible:n,enabled:t,promise:i}}function fx({promise:e}){let t=(0,Q.use)(e);return t?(0,$.jsxs)(b,{flexDirection:`column`,marginTop:1,children:[(0,$.jsx)(T,{children:t.explanation}),(0,$.jsx)(b,{marginTop:1,children:(0,$.jsx)(T,{children:t.reasoning})}),(0,$.jsx)(b,{marginTop:1,children:(0,$.jsxs)(T,{children:[(0,$.jsxs)(T,{color:cx(t.riskLevel),children:[lx(t.riskLevel),`:`]}),(0,$.jsxs)(T,{children:[` `,t.risk]})]})})]}):(0,$.jsx)(b,{marginTop:1,children:(0,$.jsx)(T,{dimColor:!0,children:`Explanation unavailable`})})}function px({visible:e,promise:t}){return!e||!t?null:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(b,{marginTop:1,children:(0,$.jsx)(sx,{})}),children:(0,$.jsx)(fx,{promise:t})})}wa(),B(),ap(),Id(),fo();function mx(e){let[t]=(0,Q.useState)(()=>_x(e.file_path,e.edits));return(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(gx,{placeholder:!0}),children:(0,$.jsx)(hx,{promise:t,file_path:e.file_path})})}function hx({promise:e,file_path:t}){let{patch:n,firstLine:r,fileContent:i}=(0,Q.use)(e),{columns:a}=de();return(0,$.jsx)(gx,{children:(0,$.jsx)(Ia,{hunks:n,dim:!1,width:a,filePath:t,firstLine:r,fileContent:i})})}function gx({children:e,placeholder:t}){return(0,$.jsx)(b,{flexDirection:`column`,children:(0,$.jsx)(b,{borderColor:`subtle`,borderStyle:`dashed`,flexDirection:`column`,borderLeft:!1,borderRight:!1,children:t?(0,$.jsx)(T,{dimColor:!0,children:`…`}):e})})}async function _x(e,t){let n=t.filter(e=>e.old_string!=null&&e.new_string!=null),r=n.length===1?n[0]:void 0;if(r&&r.old_string.length>=8192)return vx(e,[r]);try{let t=await Vt(e);if(t===null)return vx(e,n);try{if(!r||r.old_string===``){let r=await Za(t);return r===null?vx(e,n):{patch:Tt({filePath:e,fileContents:r,edits:n.map(e=>yx(r,e))}),firstLine:Bp(r),fileContent:r}}let i=await nr(t,r.old_string,3);if(i.truncated||i.content===``)return vx(e,[r]);let a=yx(i.content,r);return{patch:Xi(Tt({filePath:e,fileContents:i.content,edits:[a]}),i.lineOffset-1),firstLine:i.lineOffset===1?Bp(i.content):null,fileContent:i.content}}finally{await t.close()}}catch(t){return X(t),vx(e,n)}}function vx(e,t){return{patch:t.flatMap(t=>Tt({filePath:e,fileContents:t.old_string,edits:[t]})),firstLine:null,fileContent:void 0}}function yx(e,t){let n=Ii(e,t.old_string)||t.old_string;return{...t,old_string:n}}Lr(),Cp(),qr(),Vf(),Gu(),ef(),Ei(),ap();function bx({onChange:e,toolUseContext:t,filePath:n,edits:r,editMode:i}){let a=(0,Q.useRef)(!1),[o,s]=(0,Q.useState)(!1),c=(0,Q.useMemo)(()=>Bv().slice(0,6),[]),l=(0,Q.useMemo)(()=>`✻ [Work Mate] ${Av(n)} (${c}) ⧉`,[n,c]),u=ln(t.options.mcpClients)&&Bf().diffTool===`auto`&&!n.endsWith(`.ipynb`),d=$t(t.options.mcpClients)??`IDE`;async function f(){if(u)try{Z(`tengu_ext_will_show_diff`,{});let{oldContent:o,newContent:s}=await Sx(n,r,t,l);if(a.current)return;Z(`tengu_ext_diff_accepted`,{});let c=xx(n,o,s,i);if(c.length===0){Z(`tengu_ext_diff_rejected`,{});let i=ya(t.options.mcpClients);i&&await Cx(l,i),e({type:`reject`},{file_path:n,edits:r});return}e({type:`accept-once`},{file_path:n,edits:c})}catch(e){X(e),s(!0)}}return(0,Q.useEffect)(()=>(f(),()=>{a.current=!0}),[]),{closeTabInIDE(){let e=ya(t.options.mcpClients);return e?Cx(l,e):Promise.resolve()},showingDiffInIDE:u&&!o,ideName:d,hasError:o}}function xx(e,t,n,r){let i=r===`single`,a=Gs({filePath:e,oldContent:t,newContent:n,singleHunk:i});return a.length===0?[]:(i&&a.length>1&&X(Error(`Unexpected number of hunks: ${a.length}. Expected 1 hunk.`)),kn(a))}async function Sx(e,t,n,r){let i=!1,a=pp(e),o=``;try{o=gp(a)}catch(e){if(!Zd(e))throw e}async function s(){if(!i){i=!0;try{await Cx(r,c)}catch(e){X(e)}process.off(`beforeExit`,s),n.abortController.signal.removeEventListener(`abort`,s)}}n.abortController.signal.addEventListener(`abort`,s),process.on(`beforeExit`,s);let c=ya(n.options.mcpClients);try{let{updatedFile:e}=pr({filePath:a,fileContents:o,edits:t});if(!c||c.type!==`connected`)throw Error(`IDE client not available`);let n=a,i=c.config.ideRunningInWindows===!0;up()===`wsl`&&i&&process.env.WSL_DISTRO_NAME&&(n=new Ht(process.env.WSL_DISTRO_NAME).toIDEPath(a));let l=await bu(`openDiff`,{old_file_path:n,new_file_path:n,new_file_contents:e,tab_name:r},c),u=Array.isArray(l)?l:[l];if(Ex(u))return s(),{oldContent:o,newContent:u[1].text};if(wx(u))return s(),{oldContent:o,newContent:e};if(Tx(u))return s(),{oldContent:o,newContent:o};throw Error(`Not accepted`)}catch(e){throw X(e),s(),e}}async function Cx(e,t){try{if(!t||t.type!==`connected`)throw Error(`IDE client not available`);await bu(`close_tab`,{tab_name:e},t)}catch(e){X(e)}}function wx(e){return Array.isArray(e)&&typeof e[0]==`object`&&e[0]!==null&&`type`in e[0]&&e[0].type===`text`&&`text`in e[0]&&e[0].text===`TAB_CLOSED`}function Tx(e){return Array.isArray(e)&&typeof e[0]==`object`&&e[0]!==null&&`type`in e[0]&&e[0].type===`text`&&`text`in e[0]&&e[0].text===`DIFF_REJECTED`}function Ex(e){return Array.isArray(e)&&e[0]?.type===`text`&&e[0].text===`FILE_SAVED`&&typeof e[1].text==`string`}B(),qd(),Ei(),ri();function Dx({onChange:e,options:t,input:n,filePath:r,ideName:i,symlinkTarget:a,rejectFeedback:o,acceptFeedback:s,setFocusedOption:c,onInputModeToggle:l,focusedOption:u,yesInputMode:d,noInputMode:f}){return(0,$.jsx)(he,{color:`permission`,children:(0,$.jsxs)(b,{flexDirection:`column`,gap:1,children:[(0,$.jsxs)(T,{bold:!0,color:`permission`,children:[`Opened changes in `,i,` ⧉`]}),a&&(0,$.jsx)(T,{color:`warning`,children:Pv(Jd(),a).startsWith(`..`)?`This will modify ${a} (outside working directory) via a symlink`:`Symlink target: ${a}`}),Li()&&(0,$.jsx)(T,{dimColor:!0,children:`Save file to continue…`}),(0,$.jsxs)(b,{flexDirection:`column`,children:[(0,$.jsxs)(T,{children:[`Do you want to make this edit to `,(0,$.jsx)(T,{bold:!0,children:Av(r)}),`?`]}),(0,$.jsx)(pi,{options:t,inlineDescriptions:!0,onChange:r=>{let i=t.find(e=>e.value===r);if(i){if(i.option.type===`reject`){let t=o.trim();e(i.option,n,t||void 0);return}if(i.option.type===`accept-once`){let t=s.trim();e(i.option,n,t||void 0);return}e(i.option,n)}},onCancel:()=>e({type:`reject`},n),onFocus:e=>c(e),onInputModeToggle:l})]}),(0,$.jsx)(b,{marginTop:1,children:(0,$.jsxs)(T,{dimColor:!0,children:[`Esc to cancel`,(u===`yes`&&!d||u===`no`&&!f)&&` · Tab to amend`]})})]})})}rt(),B(),fp();function Ox(e){let t=pp(e),n=pp(`${ct()}/.claude`),r=Bd(t),i=Bd(n);return r.startsWith(i+Fv.toLowerCase())||r.startsWith(i+`/`)}function kx(e){let t=pp(e),n=Nv(Dv(),`.claude`),r=Bd(t),i=Bd(n);return r.startsWith(i+Fv.toLowerCase())||r.startsWith(i+`/`)}function Ax({filePath:e,toolPermissionContext:t,operationType:n=`write`,onRejectFeedbackChange:r,onAcceptFeedbackChange:i,yesInputMode:a=!1,noInputMode:o=!1}){let s=[],c=Hr(`chat:cycleMode`,`Chat`,`shift+tab`);a&&i?s.push({type:`input`,label:`Yes`,value:`yes`,placeholder:`and tell Claude what to do next`,onChange:i,allowEmptySubmitToCancel:!0,option:{type:`accept-once`}}):s.push({label:`Yes`,value:`yes`,option:{type:`accept-once`}});let l=Wt(e,t),u=Ox(e),d=kx(e);if((u||d)&&n!==`read`)s.push({label:`Yes, allow edits to .claude/ config for this session`,value:`yes-claude-folder`,option:{type:`accept-session`,scope:d?`global-claude-folder`:`claude-folder`}});else{let t;if(l)t=n===`read`?`Yes, during this session`:(0,$.jsxs)(T,{children:[`Yes, allow all edits during this session `,(0,$.jsxs)(T,{bold:!0,children:[`(`,c,`)`]})]});else{let r=Av(hp(e))||`this directory`;t=n===`read`?(0,$.jsxs)(T,{children:[`Yes, allow reading from `,(0,$.jsxs)(T,{bold:!0,children:[r,`/`]}),` during this session`]}):(0,$.jsxs)(T,{children:[`Yes, allow all edits in `,(0,$.jsxs)(T,{bold:!0,children:[r,`/`]}),` during this session`,` `,(0,$.jsxs)(T,{bold:!0,children:[`(`,c,`)`]})]})}s.push({label:t,value:`yes-session`,option:{type:`accept-session`}})}return o&&r?s.push({type:`input`,label:`No`,value:`no`,placeholder:`and tell Claude what to do differently`,onChange:r,allowEmptySubmitToCancel:!0,option:{type:`reject`}}):s.push({label:`No`,value:`no`,option:{type:`reject`}}),s}Cp(),eh(),Ef(),Zr(),Rb();function jx(e,t,n,r,i){Lb({completion_type:t,event:e,metadata:{language_name:n,message_id:r,platform:_f.platform,hasFeedback:i??!1}})}function Mx(e,t){let{messageId:n,toolUseConfirm:r,onDone:i,completionType:a,languageName:o}=e;jx(`accept`,a,o,n),Z(`tengu_accept_submitted`,{toolName:th(r.tool.name),isMcp:r.tool.isMcp??!1,has_instructions:!!t?.feedback,instructions_length:t?.feedback?.length??0,entered_feedback_mode:t?.enteredFeedbackMode??!1}),i(),r.onAllow(r.input,[],t?.feedback)}function Nx(e,t){let{messageId:n,path:r,toolUseConfirm:i,toolPermissionContext:a,onDone:o,completionType:s,languageName:c,operationType:l}=e;if(jx(`accept`,s,c,n),t?.scope===`claude-folder`||t?.scope===`global-claude-folder`){let e=[{type:`addRules`,rules:[{toolName:Xm,ruleContent:t.scope===`global-claude-folder`?Wm:Km}],behavior:`allow`,destination:`session`}];o(),i.onAllow(i.input,e);return}let u=r?Vi(r,l,a):[];o(),i.onAllow(i.input,u)}function Px(e,t){let{messageId:n,toolUseConfirm:r,onDone:i,onReject:a,completionType:o,languageName:s}=e;jx(`reject`,o,s,n,t?.hasFeedback),Z(`tengu_reject_submitted`,{toolName:th(r.tool.name),isMcp:r.tool.isMcp??!1,has_instructions:!!t?.feedback,instructions_length:t?.feedback?.length??0,entered_feedback_mode:t?.enteredFeedbackMode??!1}),i(),a(),r.onReject(t?.feedback)}var Fx={"accept-once":Mx,"accept-session":Nx,reject:Px};q(),zh(),Cp(),eh();function Ix({filePath:e,completionType:t,languageName:n,toolUseConfirm:r,onDone:i,onReject:a,parseInput:o,operationType:s=`write`}){let c=J(e=>e.toolPermissionContext),[l,u]=(0,Q.useState)(``),[d,f]=(0,Q.useState)(``),[p,m]=(0,Q.useState)(`yes`),[h,g]=(0,Q.useState)(!1),[_,y]=(0,Q.useState)(!1),[b,x]=(0,Q.useState)(!1),[S,C]=(0,Q.useState)(!1),w=(0,Q.useMemo)(()=>Ax({filePath:e,toolPermissionContext:c,operationType:s,onRejectFeedbackChange:f,onAcceptFeedbackChange:u,yesInputMode:h,noInputMode:_}),[e,c,s,h,_]),T=(0,Q.useCallback)((o,l,u)=>{let d={messageId:r.assistantMessage.message.id,path:e,toolUseConfirm:r,toolPermissionContext:c,onDone:i,onReject:a,completionType:t,languageName:n,operationType:s},f=r.onAllow;r.onAllow=(e,t,n)=>{f(l,t,n)};let p=Fx[o.type];p(d,{feedback:u,hasFeedback:!!u,enteredFeedbackMode:o.type===`accept-once`?b:S,scope:o.type===`accept-session`?o.scope:void 0})},[e,t,n,r,c,i,a,s,b,S]);return v({"confirm:cycleMode":(0,Q.useCallback)(()=>{let e=w.find(e=>e.option.type===`accept-session`);if(e){let t=o(r.input);T(e.option,t)}},[w,o,r.input,T])},{context:`Confirmation`}),{options:w,onChange:T,acceptFeedback:l,rejectFeedback:d,focusedOption:p,setFocusedOption:(0,Q.useCallback)(e=>{e!==`yes`&&h&&!l.trim()&&g(!1),e!==`no`&&_&&!d.trim()&&y(!1),m(e)},[h,_,l,d]),handleInputModeToggle:(0,Q.useCallback)(e=>{let t={toolName:th(r.tool.name),isMcp:r.tool.isMcp??!1};e===`yes`?h?(g(!1),Z(`tengu_accept_feedback_mode_collapsed`,t)):(g(!0),x(!0),Z(`tengu_accept_feedback_mode_entered`,t)):e===`no`&&(_?(y(!1),Z(`tengu_reject_feedback_mode_collapsed`,t)):(y(!0),C(!0),Z(`tengu_reject_feedback_mode_entered`,t)))},[h,_,r]),yesInputMode:h,noInputMode:_}}B(),Tu(),qd(),fp(),ri();function Lx({toolUseConfirm:e,toolUseContext:t,onDone:n,onReject:r,title:i,subtitle:a,question:o=`Do you want to proceed?`,content:s,completionType:c=`tool_use_single`,path:l,parseInput:u,operationType:d=`write`,ideDiffSupport:f,languageName:p}){let m=(0,Q.useMemo)(()=>p??(l?Ml(l):`none`),[p,l]);Vb(e,(0,Q.useMemo)(()=>({completion_type:c,language_name:m}),[c,m]));let h=(0,Q.useMemo)(()=>{if(!l||d===`read`)return null;let e=pp(l),{resolvedPath:t,isSymlink:n}=uf(rf(),e);return n?t:null},[l,d]),g=Ix({filePath:l||``,completionType:c,languageName:m,toolUseConfirm:e,onDone:n,onReject:r,parseInput:u,operationType:d}),{options:_,acceptFeedback:v,rejectFeedback:y,setFocusedOption:x,handleInputModeToggle:S,focusedOption:C,yesInputMode:w,noInputMode:E}=g,D=u(e.input),O=(0,Q.useMemo)(()=>f?f.getConfig(u(e.input)):null,[f,e.input]),{closeTabInIDE:k,showingDiffInIDE:A,ideName:j}=bx(O?{onChange:(e,t)=>{let n=f.applyChanges(D,t.edits);g.onChange(e,n)},toolUseContext:t,filePath:O.filePath,edits:(O.edits||[]).map(e=>({old_string:e.old_string,new_string:e.new_string,replace_all:e.replace_all||!1})),editMode:O.editMode||`single`}:{onChange:()=>{},toolUseContext:t,filePath:``,edits:[],editMode:`single`}),M=(e,t)=>{k?.(),g.onChange(e,D,t?.trim())};if(A&&O&&l)return(0,$.jsx)(Dx,{onChange:(e,t,n)=>M(e,n),options:_,filePath:l,input:D,ideName:j,symlinkTarget:h,rejectFeedback:y,acceptFeedback:v,setFocusedOption:x,onInputModeToggle:S,focusedOption:C,yesInputMode:w,noInputMode:E});let N=h!=null&&Pv(Jd(),h).startsWith(`..`);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(i_,{title:i,subtitle:a,innerPaddingX:0,children:[h?(0,$.jsx)(b,{paddingX:1,marginBottom:1,children:(0,$.jsx)(T,{color:`warning`,children:N?`This will modify ${h} (outside working directory) via a symlink`:`Symlink target: ${h}`})}):null,s,(0,$.jsxs)(b,{flexDirection:`column`,paddingX:1,children:[typeof o==`string`?(0,$.jsx)(T,{children:o}):o,(0,$.jsx)(pi,{options:_,inlineDescriptions:!0,onChange:e=>{let t=_.find(t=>t.value===e);if(t){if(t.option.type===`reject`){let e=y.trim();M(t.option,e||void 0);return}if(t.option.type===`accept-once`){let e=v.trim();M(t.option,e||void 0);return}M(t.option)}},onCancel:()=>M({type:`reject`}),onFocus:e=>x(e),onInputModeToggle:S})]})]}),(0,$.jsx)(b,{paddingX:1,marginTop:1,children:(0,$.jsxs)(T,{dimColor:!0,children:[`Esc to reject`,(C===`yes`&&!w||C===`no`&&!E)&&` · Tab to add feedback`]})})]})}qd(),ef(),_p(),nf(),B(),ld();function Rx({sedInfo:e,...t}){let{filePath:n}=e;return(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(zx,{sedInfo:e,contentPromise:(0,Q.useMemo)(()=>(async()=>{let e=vp(n);return{oldContent:(await rf().readFile(n,{encoding:e})).replaceAll(`\r
|
|
28
28
|
`,`
|
|
29
29
|
`),fileExists:!0}})().catch(e=>{if(!Zd(e))throw e;return{oldContent:``,fileExists:!1}}),[n]),...t})})}function zx({sedInfo:e,contentPromise:t,...n}){let{filePath:r}=e,{oldContent:i,fileExists:a}=(0,Q.use)(t),o=(0,Q.useMemo)(()=>pa(i,e),[i,e]),s=(0,Q.useMemo)(()=>i===o?[]:[{old_string:i,new_string:o,replace_all:!1}],[i,o]),c=(0,Q.useMemo)(()=>a?`Pattern did not match any content`:`File does not exist`,[a]);return(0,$.jsx)(Lx,{toolUseConfirm:n.toolUseConfirm,toolUseContext:n.toolUseContext,onDone:n.onDone,onReject:n.onReject,title:`Edit file`,subtitle:Pv(Jd(),r),question:(0,$.jsxs)(T,{children:[`Do you want to make this edit to `,(0,$.jsx)(T,{bold:!0,children:Av(r)}),`?`]}),content:s.length>0?(0,$.jsx)(mx,{file_path:r,edits:s}):(0,$.jsx)(T,{dimColor:!0,children:c}),path:r,completionType:`str_replace_single`,parseInput:e=>({...Qo.inputSchema.parse(e),_simulatedSedEdit:{filePath:r,newContent:o}})})}Ef(),Rb();function Bx(e,{assistantMessage:{message:{id:t}}},n,r){Lb({completion_type:e,event:n,metadata:{language_name:`none`,message_id:t,platform:Tf(),hasFeedback:r??!1}})}Cp(),eh(),q();function Vx({toolUseConfirm:e,onDone:t,onReject:n,explainerVisible:r}){let i=Qs(),[a,o]=(0,Q.useState)(``),[s,c]=(0,Q.useState)(``),[l,u]=(0,Q.useState)(!1),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(`yes`),[h,g]=(0,Q.useState)(!1),[_,v]=(0,Q.useState)(!1);function y(t){e.onUserInteraction();let n={toolName:th(e.tool.name),isMcp:e.tool.isMcp??!1};t===`yes`?l?(u(!1),Z(`tengu_accept_feedback_mode_collapsed`,n)):(u(!0),g(!0),Z(`tengu_accept_feedback_mode_entered`,n)):t===`no`&&(d?(f(!1),Z(`tengu_reject_feedback_mode_collapsed`,n)):(f(!0),v(!0),Z(`tengu_reject_feedback_mode_entered`,n)))}function b(a){let o=a?.trim(),s=!!o;s||(Z(`tengu_permission_request_escape`,{explainer_visible:r}),i(e=>({...e,attribution:{...e.attribution,escapeCount:e.attribution.escapeCount+1}}))),Bx(`tool_use_single`,e,`reject`,s),o?e.onReject(o):e.onReject(),n(),t()}function x(t){t!==p&&e.onUserInteraction(),t!==`yes`&&l&&!s.trim()&&u(!1),t!==`no`&&d&&!a.trim()&&f(!1),m(t)}return{yesInputMode:l,noInputMode:d,yesFeedbackModeEntered:h,noFeedbackModeEntered:_,acceptFeedback:s,rejectFeedback:a,setAcceptFeedback:c,setRejectFeedback:o,focusedOption:p,handleInputModeToggle:y,handleReject:b,handleFocus:x}}rt(),B();function Hx(e){switch(e.length){case 0:return``;case 1:return(0,$.jsx)(T,{bold:!0,children:e[0]});case 2:return(0,$.jsxs)(T,{children:[(0,$.jsx)(T,{bold:!0,children:e[0]}),` and `,(0,$.jsx)(T,{bold:!0,children:e[1]})]});default:return(0,$.jsxs)(T,{children:[(0,$.jsx)(T,{bold:!0,children:e.slice(0,-1).join(`, `)}),`, and `,(0,$.jsx)(T,{bold:!0,children:e.slice(-1)[0]})]})}}function Ux(e){return e.join(`, `).length>50?`similar`:Hx(e)}function Wx(e){if(e.length===0)return``;let t=e.map(e=>Av(e)||e);return t.length===1?(0,$.jsxs)(T,{children:[(0,$.jsx)(T,{bold:!0,children:t[0]}),Fv]}):t.length===2?(0,$.jsxs)(T,{children:[(0,$.jsx)(T,{bold:!0,children:t[0]}),Fv,` and `,(0,$.jsx)(T,{bold:!0,children:t[1]}),Fv]}):(0,$.jsxs)(T,{children:[(0,$.jsx)(T,{bold:!0,children:t[0]}),Fv,`, `,(0,$.jsx)(T,{bold:!0,children:t[1]}),Fv,` and `,e.length-2,` more`]})}function Gx(e,t,n){let r=e.filter(e=>e.type===`addRules`).flatMap(e=>e.rules||[]),i=r.filter(e=>e.toolName===`Read`),a=r.filter(e=>e.toolName===t),o=e.filter(e=>e.type===`addDirectories`).flatMap(e=>e.directories||[]),s=i.map(e=>e.ruleContent?.replace(`/**`,``)||``).filter(e=>e),c=[...new Set(a.flatMap(e=>{if(!e.ruleContent)return[];let t=W(e.ruleContent)??e.ruleContent;return n?n(t):t}))],l=o.length>0,u=s.length>0,d=c.length>0;if(u&&!l&&!d){if(s.length===1){let e=s[0];return(0,$.jsxs)(T,{children:[`Yes, allow reading from `,(0,$.jsx)(T,{bold:!0,children:Av(e)||e}),Fv,` from this project`]})}return(0,$.jsxs)(T,{children:[`Yes, allow reading from `,Wx(s),` from this project`]})}if(l&&!u&&!d){if(o.length===1){let e=o[0];return(0,$.jsxs)(T,{children:[`Yes, and always allow access to `,(0,$.jsx)(T,{bold:!0,children:Av(e)||e}),Fv,` from this project`]})}return(0,$.jsxs)(T,{children:[`Yes, and always allow access to `,Wx(o),` from this project`]})}if(d&&!l&&!u)return(0,$.jsxs)(T,{children:[`Yes, and don't ask again for `,Ux(c),` commands in `,(0,$.jsx)(T,{bold:!0,children:ct()})]});if((l||u)&&!d){let e=[...o,...s];if(l&&u)return(0,$.jsxs)(T,{children:[`Yes, and always allow access to `,Wx(e),` from this project`]})}if((l||u)&&d){let e=[...o,...s];return e.length===1&&c.length===1?(0,$.jsxs)(T,{children:[`Yes, and allow access to `,Wx(e),` and `,Ux(c),` commands`]}):(0,$.jsxs)(T,{children:[`Yes, and allow `,Wx(e),` access and `,Ux(c),` commands`]})}return null}Lo();function Kx(e,t){let n=e.toLowerCase().trimEnd();return t.some(e=>e.toLowerCase().trimEnd()===n)}function qx(e){let{commandWithoutRedirections:t,redirections:n}=So(e);return n.length>0?t:e}function Jx({suggestions:e=[],decisionReason:t,onRejectFeedbackChange:n,onAcceptFeedbackChange:r,onClassifierDescriptionChange:i,classifierDescription:a,initialClassifierDescriptionEmpty:o=!1,existingAllowDescriptions:s=[],yesInputMode:c=!1,noInputMode:l=!1,editablePrefix:u,onEditablePrefixChange:d}){let f=[];if(c?f.push({type:`input`,label:`Yes`,value:`yes`,placeholder:`and tell Claude what to do next`,onChange:r,allowEmptySubmitToCancel:!0}):f.push({label:`Yes`,value:`yes`}),Nr()){let n=e.some(e=>e.type===`addDirectories`||e.type===`addRules`&&e.rules?.some(e=>e.toolName!==`Bash`));if(u!==void 0&&d&&!n&&e.length>0)f.push({type:`input`,label:`Yes, and don’t ask again for`,value:`yes-prefix-edited`,placeholder:`command prefix (e.g., npm run:*)`,initialValue:u,onChange:d,allowEmptySubmitToCancel:!0,showLabelWithValue:!0,labelValueSeparator:`: `,resetCursorOnUpdate:!0});else if(e.length>0){let t=Gx(e,Um,qx);t&&f.push({label:t,value:`yes-apply-suggestions`})}let r=f.some(e=>e.value===`yes-prefix-edited`);process.env.USER_TYPE===`ant`&&!r&&Ki()&&i&&!o&&!Kx(a??``,s)&&t?.type!==`classifier`&&f.push({type:`input`,label:`Yes, and don’t ask again for`,value:`yes-classifier-reviewed`,placeholder:`describe what to allow...`,initialValue:a??``,onChange:i,allowEmptySubmitToCancel:!0,showLabelWithValue:!0,labelValueSeparator:`: `,resetCursorOnUpdate:!0})}return l?f.push({type:`input`,label:`No`,value:`no`,placeholder:`and tell Claude what to do differently`,onChange:n,allowEmptySubmitToCancel:!0}):f.push({label:`No`,value:`no`}),f}B(),zh(),Cp(),eh(),q(),ld(),Hd(),Ro(),Lt(),dr(),ds(),Oc(),n_(),ib();function Yx(e){let{toolUseConfirm:t,toolUseContext:n,onDone:r,onReject:i,verbose:a}=e,{command:o,description:s}=Qo.inputSchema.parse(t.input),c=Kt(o);return c?(0,$.jsx)(Rx,{toolUseConfirm:t,toolUseContext:n,onDone:r,onReject:i,verbose:a,sedInfo:c}):(0,$.jsx)(Xx,{toolUseConfirm:t,toolUseContext:n,onDone:r,onReject:i,verbose:a,command:o,description:s})}function Xx({toolUseConfirm:e,toolUseContext:t,onDone:n,onReject:r,verbose:i,command:a,description:o}){let[s]=y(),c=J(e=>e.toolPermissionContext),l=dx({toolName:e.tool.name,toolInput:e.input,toolDescription:e.description,messages:t.messages}),{yesInputMode:u,noInputMode:d,yesFeedbackModeEntered:f,noFeedbackModeEntered:p,acceptFeedback:m,rejectFeedback:h,setAcceptFeedback:g,setRejectFeedback:_,focusedOption:v,handleInputModeToggle:x,handleReject:S,handleFocus:C}=Vx({toolUseConfirm:e,onDone:n,onReject:r,explainerVisible:l.visible}),[w,E]=(0,Q.useState)(!1),[D,O]=(0,Q.useState)(o||``),[k,A]=(0,Q.useState)(!o?.trim());(0,Q.useEffect)(()=>{if(!Ki())return;let e=new AbortController;return jo(a,o,e.signal).then(t=>{t&&!e.signal.aborted&&(O(t),A(!1))}).catch(()=>{}),()=>e.abort()},[a,o]);let M=e.permissionResult.decisionReason?.type===`subcommandResults`,[N,ee]=(0,Q.useState)(()=>{if(M){let t=oa(`suggestions`in e.permissionResult?e.permissionResult.suggestions:void 0).filter(e=>e.toolName===Qo.name&&e.ruleContent);return t.length===1?t[0].ruleContent:void 0}let t=wc(a);if(t)return`${t}:*`;let n=Cl(a);return n?`${n}:*`:a}),P=(0,Q.useRef)(!1),F=(0,Q.useCallback)(e=>{P.current=!0,ee(e)},[]);(0,Q.useEffect)(()=>{if(M)return;let e=!1;return Fb(a,e=>Qo.isReadOnly({command:e})).then(t=>{e||P.current||t.length>0&&ee(`${t[0]}:*`)}).catch(()=>{}),()=>{e=!0}},[a,M]);let[I]=(0,Q.useState)(!1),{destructiveWarning:te,sandboxingEnabled:ne,isSandboxed:L}=(0,Q.useMemo)(()=>{let t=fi.isSandboxingEnabled();return{destructiveWarning:null,sandboxingEnabled:t,isSandboxed:t&&br(e.input)}},[a,e.input]);Vb(e,(0,Q.useMemo)(()=>({completion_type:`tool_use_single`,language_name:`none`}),[]));let R=(0,Q.useMemo)(()=>Co(c),[c]),re=(0,Q.useMemo)(()=>Jx({suggestions:e.permissionResult.behavior===`ask`?e.permissionResult.suggestions:void 0,decisionReason:e.permissionResult.decisionReason,onRejectFeedbackChange:_,onAcceptFeedbackChange:g,onClassifierDescriptionChange:O,classifierDescription:D,initialClassifierDescriptionEmpty:k,existingAllowDescriptions:R,yesInputMode:u,noInputMode:d,editablePrefix:N,onEditablePrefixChange:F}),[e,D,k,R,u,d,N,F]);j(`permission:toggleDebug`,(0,Q.useCallback)(()=>{E(e=>!e)},[]),{context:`Confirmation`}),j(`confirm:no`,(0,Q.useCallback)(()=>{e.onDismissCheckmark?.()},[e]),{context:`Confirmation`,isActive:!1});function ie(t){Z(`tengu_permission_request_option_selected`,{option_index:{yes:1,"yes-apply-suggestions":2,"yes-prefix-edited":2,no:3}[t],explainer_visible:l.visible});let r=th(e.tool.name);if(t===`yes-prefix-edited`){let t=(N??``).trim();if(Bx(`tool_use_single`,e,`accept`),!t)e.onAllow(e.input,[]);else{let n=[{type:`addRules`,rules:[{toolName:Qo.name,ruleContent:t}],behavior:`allow`,destination:`localSettings`}];e.onAllow(e.input,n)}n();return}switch(t){case`yes`:{let t=m.trim();Bx(`tool_use_single`,e,`accept`),Z(`tengu_accept_submitted`,{toolName:r,isMcp:e.tool.isMcp??!1,has_instructions:!!t,instructions_length:t.length,entered_feedback_mode:f}),e.onAllow(e.input,[],t||void 0),n();break}case`yes-apply-suggestions`:{Bx(`tool_use_single`,e,`accept`);let t=`suggestions`in e.permissionResult&&e.permissionResult.suggestions||[];e.onAllow(e.input,t),n();break}case`no`:{let t=h.trim();Z(`tengu_reject_submitted`,{toolName:r,isMcp:e.tool.isMcp??!1,has_instructions:!!t,instructions_length:t.length,entered_feedback_mode:p}),S(t||void 0);break}}}return(0,$.jsxs)(i_,{title:ne&&!L?`Bash command (unsandboxed)`:`Bash command`,subtitle:void 0,children:[(0,$.jsxs)(b,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsx)(T,{dimColor:l.visible,children:Qo.renderToolUseMessage({command:a,description:o},{theme:s,verbose:!0})}),!l.visible&&(0,$.jsx)(T,{dimColor:!0,children:e.description}),(0,$.jsx)(px,{visible:l.visible,promise:l.promise})]}),w?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Jb,{permissionResult:e.permissionResult,toolName:`Bash`}),t.options.debug&&(0,$.jsx)(b,{justifyContent:`flex-end`,marginTop:1,children:(0,$.jsx)(T,{dimColor:!0,children:`Ctrl-D to hide debug info`})})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(b,{flexDirection:`column`,children:[(0,$.jsx)(nb,{permissionResult:e.permissionResult,toolType:`command`}),te&&(0,$.jsx)(b,{marginBottom:1,children:(0,$.jsx)(T,{color:`warning`,dimColor:!1,children:te})}),(0,$.jsx)(T,{dimColor:!1,children:`Do you want to proceed?`}),(0,$.jsx)(pi,{options:re,isDisabled:!1,inlineDescriptions:!0,onChange:ie,onCancel:()=>S(),onFocus:C,onInputModeToggle:x})]}),(0,$.jsxs)(b,{justifyContent:`space-between`,marginTop:1,children:[(0,$.jsxs)(T,{dimColor:!0,children:[`Esc to reject`,(v===`yes`&&!u||v===`no`&&!d)&&` · Tab to add feedback`,l.enabled&&` · ctrl+e to ${l.visible?`hide`:`explain`}`]}),t.options.debug&&(0,$.jsx)(T,{dimColor:!0,children:`Ctrl+d to show debug info`})]})]})]})}rt(),B(),Cp(),q(),fr(),ri(),n_();function Zx({toolUseConfirm:e,onDone:t,onReject:n}){let r=J(e=>e.toolPermissionContext.mode);function i(i){i===`yes`?(Z(`tengu_plan_enter`,{interviewPhaseEnabled:Kr(),entryMethod:`tool`}),Xe(r,`plan`),t(),e.onAllow({},[{type:`setMode`,mode:`plan`,destination:`session`}])):(t(),n(),e.onReject())}return(0,$.jsx)(i_,{color:`planMode`,title:`Enter plan mode?`,children:(0,$.jsxs)(b,{flexDirection:`column`,marginTop:1,paddingX:1,children:[(0,$.jsx)(T,{children:`Claude wants to enter plan mode to explore and design an implementation approach.`}),(0,$.jsxs)(b,{marginTop:1,flexDirection:`column`,children:[(0,$.jsx)(T,{dimColor:!0,children:`In plan mode, Claude will:`}),(0,$.jsx)(T,{dimColor:!0,children:` · Explore the codebase thoroughly`}),(0,$.jsx)(T,{dimColor:!0,children:` · Identify existing patterns`}),(0,$.jsx)(T,{dimColor:!0,children:` · Design an implementation strategy`}),(0,$.jsx)(T,{dimColor:!0,children:` · Present a plan for your approval`})]}),(0,$.jsx)(b,{marginTop:1,children:(0,$.jsx)(T,{dimColor:!0,children:`No code changes will be made until you approve the plan.`})}),(0,$.jsx)(b,{marginTop:1,children:(0,$.jsx)(pi,{options:[{label:`Yes, enter plan mode`,value:`yes`},{label:`No, start implementing now`,value:`no`}],onChange:i,onCancel:()=>i(`no`)})})]})})}u(),Ll(),Cp(),q(),rt(),Y_(),El(),B(),qg(),Ei(),ap(),jr(),Vd(),lm(),Ro(),mf(),Xt(),fr(),ui(),Zg(),Wc(),ri(),n_(),ib(),gl(),No();var Qx=(Bn(),e(uo));function $x(e,t){let n=[{type:`setMode`,mode:hf(e),destination:`session`}];return Ki()&&t&&t.length>0&&n.push({type:`addRules`,rules:t.map(e=>({toolName:e.tool,ruleContent:xr(e.prompt)})),behavior:`allow`,destination:`session`}),n}function eS(e,t,n){ft()||jf()?.cleanupPeriodDays===0||!n&&Sl(at())||X_([xa({content:e.slice(0,1e3)})],new AbortController().signal).then(async e=>{if(!e||Sl(at()))return;let n=at(),r=xn();await od(n,e,r,`auto`),await yc(n,e,r,`auto`),t(t=>t.standaloneAgentContext?.name===e?t:{...t,standaloneAgentContext:{...t.standaloneAgentContext,name:e}})}).catch(X)}function tS({toolUseConfirm:e,onDone:t,onReject:n,setStickyFooter:r}){let i=J(e=>e.toolPermissionContext),a=Qs(),o=js(),{addNotification:s}=Au(),[c,l]=(0,Q.useState)(``),[u,f]=(0,Q.useState)({}),p=(0,Q.useRef)(0),m=J(e=>e.settings.showClearContextOnPlanAccept)??!1,h=J(e=>e.ultraplanSessionUrl),g=J(e=>e.ultraplanLaunching),_=!h&&!g,v=e.assistantMessage.message.usage,{mode:y,isAutoModeAvailable:x,isBypassPermissionsModeAvailable:S}=i,C=(0,Q.useMemo)(()=>nS({showClearContext:m,showUltraplan:_,usedPercent:m?rS(v,y):null,isAutoModeAvailable:x,isBypassPermissionsModeAvailable:S,onFeedbackChange:l}),[m,_,v,y,x,S]);function w(e,t,n,r,i){let a=p.current++,o={id:a,type:`image`,content:e,mediaType:t||`image/png`,filename:n||`Pasted image`,dimensions:r};Ir(o),To(o),f(e=>({...e,[a]:o}))}let E=(0,Q.useCallback)(e=>{f(t=>{let n={...t};return delete n[e],n})},[]),D=Object.values(u).filter(e=>e.type===`image`),O=D.length>0,k=e.tool.name===Rm,A=k?void 0:e.input.plan,j=k?nl():void 0,M=e.input.allowedPrompts,N=A??ji(),ee=!N||N.trim()===``,[P]=(0,Q.useState)(()=>On()??void 0),[F,I]=(0,Q.useState)(()=>A||(ji()??`No plan found. Please write your plan to the plan file first.`)),[te,ne]=(0,Q.useState)(!1),[L,R]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{if(te){let e=setTimeout(ne,5e3,!1);return()=>clearTimeout(e)}},[te]);let re=e=>{if(e.ctrl&&e.key===`g`){e.preventDefault(),Z(`tengu_plan_external_editor_used`,{}),(async()=>{if(k&&j){let e=await Qg(j);e.error&&s({key:`external-editor-error`,text:e.error,color:`warning`,priority:`high`}),e.content!==null&&(e.content!==F&&R(!0),I(e.content),ne(!0))}else{let e=await Yg(F);e.error&&s({key:`external-editor-error`,text:e.error,color:`warning`,priority:`high`}),e.content!==null&&e.content!==F&&(I(e.content),ne(!0))}})();return}if(e.shift&&e.key===`tab`){e.preventDefault(),ie(m?`yes-accept-edits`:`yes-accept-edits-keep-context`);return}};async function ie(r){let s=c.trim(),l=s||void 0;if(r===`ultraplan`){Z(`tengu_plan_exit`,{planLengthChars:F.length,outcome:`ultraplan`,interviewPhaseEnabled:Kr(),planStructureVariant:P}),t(),n(),e.onReject(`Plan being refined via Ultraplan — please wait for the result.`),_u({blurb:``,seedPlan:F,getAppState:o.getState,setAppState:o.setState,signal:new AbortController().signal}).then(e=>sr({value:e,mode:`task-notification`})).catch(X);return}let u=k&&!L?{}:{plan:F};{let e=(r===`yes-resume-auto-mode`||r===`yes-auto-clear-context`)&&mn(),t=Qx?.isAutoModeActive()??!1;r!==`no`&&!e&&t&&(Qx?.setAutoModeActive(!1),Ie(!0),a(e=>({...e,toolPermissionContext:{...ni(e.toolPermissionContext),prePlanMode:void 0}})))}let d=r===`yes-accept-edits-keep-context`||r===`yes-default-keep-context`||r===`yes-resume-auto-mode`;if(r!==`no`&&eS(F,a,!d),r!==`no`&&!d){let i=`default`;r===`yes-bypass-permissions`?i=`bypassPermissions`:r===`yes-accept-edits`?i=`acceptEdits`:r===`yes-auto-clear-context`&&mn()&&(i=`auto`,Qx?.setAutoModeActive(!0)),Z(`tengu_plan_exit`,{planLengthChars:F.length,outcome:r,clearContext:!0,interviewPhaseEnabled:Kr(),planStructureVariant:P,hasFeedback:!!l});let o=`\n\nIf you need specific details from before exiting plan mode (like exact code snippets, error messages, or content you generated), read the full transcript at: ${xn()}`,s=l?`\n\nUser feedback on this plan: ${l}`:``;a(e=>({...e,initialMessage:{message:{...xa({content:`Implement the following plan:\n\n${F}${o}${s}`}),planContent:F},clearContext:!0,mode:i,allowedPrompts:M}})),Me(!0),Ye(!0),t(),n(),e.onReject();return}if(r===`yes-resume-auto-mode`&&mn()){Z(`tengu_plan_exit`,{planLengthChars:F.length,outcome:r,clearContext:!1,interviewPhaseEnabled:Kr(),planStructureVariant:P,hasFeedback:!!l}),Me(!0),Ye(!0),Qx?.setAutoModeActive(!0),a(e=>({...e,toolPermissionContext:di({...e.toolPermissionContext,mode:`auto`,prePlanMode:void 0})})),t(),e.onAllow(u,[],l);return}let f={"yes-accept-edits-keep-context":i.isBypassPermissionsModeAvailable?`bypassPermissions`:`acceptEdits`,"yes-default-keep-context":`default`,"yes-resume-auto-mode":`default`}[r];if(f){Z(`tengu_plan_exit`,{planLengthChars:F.length,outcome:r,clearContext:!1,interviewPhaseEnabled:Kr(),planStructureVariant:P,hasFeedback:!!l}),Me(!0),Ye(!0),t(),e.onAllow(u,$x(f,M),l);return}let p={"yes-bypass-permissions":`bypassPermissions`,"yes-accept-edits":`acceptEdits`}[r];if(p){Z(`tengu_plan_exit`,{planLengthChars:F.length,outcome:r,interviewPhaseEnabled:Kr(),planStructureVariant:P,hasFeedback:!!l}),Me(!0),Ye(!0),t(),e.onAllow(u,$x(p,M),l);return}if(r===`no`){if(!s&&!O)return;Z(`tengu_plan_exit`,{planLengthChars:F.length,outcome:`no`,interviewPhaseEnabled:Kr(),planStructureVariant:P});let r;O&&(r=await Promise.all(D.map(async e=>(await _c({type:`image`,source:{type:`base64`,media_type:e.mediaType||`image/png`,data:e.content}})).block))),t(),n(),e.onReject(s||(O?`(See attached image)`:void 0),r&&r.length>0?r:void 0)}}let z=Jg(),ae=z?Jr(z):null,oe=(0,Q.useRef)(ie);oe.current=ie;let se=(0,Q.useRef)(void 0);se.current=()=>{Z(`tengu_plan_exit`,{planLengthChars:F.length,outcome:`no`,interviewPhaseEnabled:Kr(),planStructureVariant:P}),t(),n(),e.onReject()};let ce=!ee&&!!r;if((0,Q.useLayoutEffect)(()=>{if(ce)return r((0,$.jsxs)(b,{flexDirection:`column`,borderStyle:`round`,borderColor:`planMode`,borderLeft:!1,borderRight:!1,borderBottom:!1,paddingX:1,children:[(0,$.jsx)(T,{dimColor:!0,children:`Would you like to proceed?`}),(0,$.jsx)(b,{marginTop:1,children:(0,$.jsx)(pi,{options:C,onChange:e=>void oe.current(e),onCancel:()=>se.current?.(),onImagePaste:w,pastedContents:u,onRemoveImage:E})}),ae&&(0,$.jsxs)(b,{flexDirection:`row`,gap:1,marginTop:1,children:[(0,$.jsx)(T,{dimColor:!0,children:`ctrl-g to edit in `}),(0,$.jsx)(T,{bold:!0,dimColor:!0,children:ae}),k&&j&&(0,$.jsxs)(T,{dimColor:!0,children:[` · `,bp(j)]}),te&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(T,{dimColor:!0,children:` · `}),(0,$.jsxs)(T,{color:`success`,children:[d.tick,`Plan saved!`]})]})]})]})),()=>r(null)},[ce,r,C,u,ae,k,j,te]),ee){function r(r){r===`yes`?(Z(`tengu_plan_exit`,{planLengthChars:0,outcome:`yes-default`,interviewPhaseEnabled:Kr(),planStructureVariant:P}),(Qx?.isAutoModeActive()??!1)&&(Qx?.setAutoModeActive(!1),Ie(!0),a(e=>({...e,toolPermissionContext:{...ni(e.toolPermissionContext),prePlanMode:void 0}}))),Me(!0),Ye(!0),t(),e.onAllow({},[{type:`setMode`,mode:`default`,destination:`session`}])):(Z(`tengu_plan_exit`,{planLengthChars:0,outcome:`no`,interviewPhaseEnabled:Kr(),planStructureVariant:P}),t(),n(),e.onReject())}return(0,$.jsx)(i_,{color:`planMode`,title:`Exit plan mode?`,children:(0,$.jsxs)(b,{flexDirection:`column`,paddingX:1,marginTop:1,children:[(0,$.jsx)(T,{children:`Claude wants to exit plan mode`}),(0,$.jsx)(b,{marginTop:1,children:(0,$.jsx)(pi,{options:[{label:`Yes`,value:`yes`},{label:`No`,value:`no`}],onChange:r,onCancel:()=>{Z(`tengu_plan_exit`,{planLengthChars:0,outcome:`no`,interviewPhaseEnabled:Kr(),planStructureVariant:P}),t(),n(),e.onReject()}})})]})})}return(0,$.jsxs)(b,{flexDirection:`column`,tabIndex:0,autoFocus:!0,onKeyDown:re,children:[(0,$.jsx)(i_,{color:`planMode`,title:`Ready to code?`,innerPaddingX:0,children:(0,$.jsxs)(b,{flexDirection:`column`,marginTop:1,children:[(0,$.jsx)(b,{paddingX:1,flexDirection:`column`,children:(0,$.jsx)(T,{children:`Here is Claude's plan:`})}),(0,$.jsx)(b,{borderColor:`subtle`,borderStyle:`dashed`,flexDirection:`column`,borderLeft:!1,borderRight:!1,paddingX:1,marginBottom:1,overflow:`hidden`,children:(0,$.jsx)(Nu,{children:F})}),(0,$.jsxs)(b,{flexDirection:`column`,paddingX:1,children:[(0,$.jsx)(nb,{permissionResult:e.permissionResult,toolType:`tool`}),Ki()&&M&&M.length>0&&(0,$.jsxs)(b,{flexDirection:`column`,marginBottom:1,children:[(0,$.jsx)(T,{bold:!0,children:`Requested permissions:`}),M.map((e,t)=>(0,$.jsxs)(T,{dimColor:!0,children:[` `,`· `,e.tool,`(`,`prompt:`,` `,e.prompt,`)`]},t))]}),!ce&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(T,{dimColor:!0,children:`Claude has written up a plan and is ready to execute. Would you like to proceed?`}),(0,$.jsx)(b,{marginTop:1,children:(0,$.jsx)(pi,{options:C,onChange:ie,onCancel:()=>se.current?.(),onImagePaste:w,pastedContents:u,onRemoveImage:E})})]})]})]})}),!ce&&ae&&(0,$.jsxs)(b,{flexDirection:`row`,gap:1,paddingX:1,marginTop:1,children:[(0,$.jsxs)(b,{children:[(0,$.jsx)(T,{dimColor:!0,children:`ctrl-g to edit in `}),(0,$.jsx)(T,{bold:!0,dimColor:!0,children:ae}),k&&j&&(0,$.jsxs)(T,{dimColor:!0,children:[` · `,bp(j)]})]}),te&&(0,$.jsxs)(b,{children:[(0,$.jsx)(T,{dimColor:!0,children:` · `}),(0,$.jsxs)(T,{color:`success`,children:[d.tick,`Plan saved!`]})]})]})]})}function nS({showClearContext:e,showUltraplan:t,usedPercent:n,isAutoModeAvailable:r,isBypassPermissionsModeAvailable:i,onFeedbackChange:a}){let o=[],s=n===null?``:` (${n}% used)`;return e&&(r?o.push({label:`Yes, clear context${s} and use auto mode`,value:`yes-auto-clear-context`}):i?o.push({label:`Yes, clear context${s} and bypass permissions`,value:`yes-bypass-permissions`}):o.push({label:`Yes, clear context${s} and auto-accept edits`,value:`yes-accept-edits`})),r?o.push({label:`Yes, and use auto mode`,value:`yes-resume-auto-mode`}):i?o.push({label:`Yes, and bypass permissions`,value:`yes-accept-edits-keep-context`}):o.push({label:`Yes, auto-accept edits`,value:`yes-accept-edits-keep-context`}),o.push({label:`Yes, manually approve edits`,value:`yes-default-keep-context`}),t&&o.push({label:`No, refine with Ultraplan on Claude Code on the web`,value:`ultraplan`}),o.push({type:`input`,label:`No, keep planning`,value:`no`,placeholder:`Tell Claude what to change`,description:`shift+tab to approve with this feedback`,onChange:a}),o}function rS(e,t){if(!e)return null;let n=Zp(Cm({permissionMode:t,mainLoopModel:Fm(),exceeds200kTokens:!1}),dt()),{used:r}=im({input_tokens:e.input_tokens,cache_creation_input_tokens:e.cache_creation_input_tokens??0,cache_read_input_tokens:e.cache_read_input_tokens??0},n);return r}function iS({options:e,onSelect:t,onCancel:n,question:r=`Do you want to proceed?`,toolAnalyticsContext:i}){let a=Qs(),[o,s]=(0,aS.useState)(``),[c,l]=(0,aS.useState)(``),[u,d]=(0,aS.useState)(!1),[f,p]=(0,aS.useState)(!1),[m,h]=(0,aS.useState)(null),[g,_]=(0,aS.useState)(!1),[y,x]=(0,aS.useState)(!1),S=e.find(e=>e.value===m)?.feedbackConfig?.type,C=S===`accept`&&!u||S===`reject`&&!f,w=(0,aS.useMemo)(()=>e.map(e=>{let{value:t,label:n,feedbackConfig:r}=e;if(!r)return{label:n,value:t};let{type:i,placeholder:a}=r,o=i===`accept`?u:f,c=i===`accept`?s:l,d=sS[i];return o?{type:`input`,label:n,value:t,placeholder:a??d,onChange:c,allowEmptySubmitToCancel:!0}:{label:n,value:t}}),[e,u,f]),E=(0,aS.useCallback)(t=>{let n=e.find(e=>e.value===t);if(!n?.feedbackConfig)return;let{type:r}=n.feedbackConfig,a={toolName:i?.toolName,isMcp:i?.isMcp??!1};r===`accept`?u?(d(!1),Z(`tengu_accept_feedback_mode_collapsed`,a)):(d(!0),_(!0),Z(`tengu_accept_feedback_mode_entered`,a)):r===`reject`&&(f?(p(!1),Z(`tengu_reject_feedback_mode_collapsed`,a)):(p(!0),x(!0),Z(`tengu_reject_feedback_mode_entered`,a)))},[e,u,f,i]),D=(0,aS.useCallback)(n=>{let r=e.find(e=>e.value===n);if(!r)return;let a;if(r.feedbackConfig){let e=(r.feedbackConfig.type===`accept`?o:c).trim();e&&(a=e);let t={toolName:i?.toolName,isMcp:i?.isMcp??!1,has_instructions:!!e,instructions_length:e?.length??0,entered_feedback_mode:r.feedbackConfig.type===`accept`?g:y};r.feedbackConfig.type===`accept`?Z(`tengu_accept_submitted`,t):r.feedbackConfig.type===`reject`&&Z(`tengu_reject_submitted`,t)}t(n,a)},[e,o,c,t,i,g,y]);v((0,aS.useMemo)(()=>{let t={};for(let n of e)n.keybinding&&(t[n.keybinding]=()=>D(n.value));return t},[e,D]),{context:`Confirmation`});let O=(0,aS.useCallback)(()=>{Z(`tengu_permission_request_escape`,{}),a(e=>({...e,attribution:{...e.attribution,escapeCount:e.attribution.escapeCount+1}})),n?.()},[n,a]);return(0,oS.jsxs)(b,{flexDirection:`column`,children:[typeof r==`string`?(0,oS.jsx)(T,{children:r}):r,(0,oS.jsx)(pi,{options:w,inlineDescriptions:!0,onChange:D,onCancel:O,onFocus:t=>{let n=e.find(e=>e.value===t);n?.feedbackConfig?.type!==`accept`&&u&&!o.trim()&&d(!1),n?.feedbackConfig?.type!==`reject`&&f&&!c.trim()&&p(!1),h(t)},onInputModeToggle:E}),(0,oS.jsx)(b,{marginTop:1,children:(0,oS.jsxs)(T,{dimColor:!0,children:[`Esc to cancel`,C&&` · Tab to amend`]})})]})}var aS,oS,sS,cS=t((()=>{aS=n(z(),1),B(),zh(),Cp(),q(),Pi(),oS=ve(),sS={accept:`tell Claude what to do next`,reject:`tell Claude what to do differently`}}));Fh(),Io(),ks(),fu(),or(),ju(),tg(),rt(),B(),eh(),Ef(),Ln(),Up(),Rb(),n_(),cS(),ib();function lS({toolUseConfirm:e,onDone:t,onReject:n,verbose:r}){let[i]=y(),a=e.tool.userFacingName(e.input),o=a.endsWith(` (MCP)`)?a.slice(0,-6):a;Vb(e,(0,Q.useMemo)(()=>({completion_type:`tool_use_single`,language_name:`none`}),[]));let s=(0,Q.useCallback)((r,i)=>{switch(r){case`yes`:Lb({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id,platform:_f.platform}}),e.onAllow(e.input,[],i),t();break;case`yes-dont-ask-again`:Lb({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id,platform:_f.platform}}),e.onAllow(e.input,[{type:`addRules`,rules:[{toolName:e.tool.name}],behavior:`allow`,destination:`localSettings`}]),t();break;case`no`:Lb({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id,platform:_f.platform}}),e.onReject(i),n(),t();break}},[e,t,n]),c=(0,Q.useCallback)(()=>{Lb({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id,platform:_f.platform}}),e.onReject(),n(),t()},[e,t,n]),l=ct(),u=Nr(),d=(0,Q.useMemo)(()=>{let e=[{label:`Yes`,value:`yes`,feedbackConfig:{type:`accept`}}];return u&&e.push({label:(0,$.jsxs)(T,{children:[`Yes, and don't ask again for `,(0,$.jsx)(T,{bold:!0,children:o}),` commands in`,` `,(0,$.jsx)(T,{bold:!0,children:l})]}),value:`yes-dont-ask-again`}),e.push({label:`No`,value:`no`,feedbackConfig:{type:`reject`}}),e},[o,l,u]),f=(0,Q.useMemo)(()=>({toolName:th(e.tool.name),isMcp:e.tool.isMcp??!1}),[e.tool.name,e.tool.isMcp]);return(0,$.jsxs)(i_,{title:`Tool use`,children:[(0,$.jsxs)(b,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsxs)(T,{children:[o,`(`,e.tool.renderToolUseMessage(e.input,{theme:i,verbose:!0}),`)`,a.endsWith(` (MCP)`)?(0,$.jsx)(T,{dimColor:!0,children:` (MCP)`}):``]}),(0,$.jsx)(T,{dimColor:!0,children:Vp(e.description,3)})]}),(0,$.jsxs)(b,{flexDirection:`column`,children:[(0,$.jsx)(nb,{permissionResult:e.permissionResult,toolType:`tool`}),(0,$.jsx)(iS,{options:d,onSelect:s,onCancel:c,toolAnalyticsContext:f})]})]})}function uS(e,t,n,r){return{filePath:e,edits:[{old_string:t,new_string:n,replace_all:r}],editMode:`single`}}qd(),B();var dS={getConfig:e=>uS(e.file_path,e.old_string,e.new_string,e.replace_all),applyChanges:(e,t)=>{let n=t[0];return n?{...e,old_string:n.old_string,new_string:n.new_string,replace_all:n.replace_all}:e}};function fS(e){let t=e=>ai.inputSchema.parse(e),{file_path:n,old_string:r,new_string:i,replace_all:a}=t(e.toolUseConfirm.input);return(0,$.jsx)(Lx,{toolUseConfirm:e.toolUseConfirm,toolUseContext:e.toolUseContext,onDone:e.onDone,onReject:e.onReject,title:`Edit file`,subtitle:Pv(Jd(),n),question:(0,$.jsxs)(T,{children:[`Do you want to make this edit to `,(0,$.jsx)(T,{bold:!0,children:Av(n)}),`?`]}),content:(0,$.jsx)(mx,{file_path:n,edits:[{old_string:r,new_string:i,replace_all:a||!1}]}),path:n,completionType:`str_replace_single`,parseInput:t,ideDiffSupport:dS})}B();function pS(e){let t=e.tool;if(`getPath`in t&&typeof t.getPath==`function`)try{return t.getPath(e.input)}catch{return null}return null}function mS({toolUseConfirm:e,onDone:t,onReject:n,verbose:r,toolUseContext:i}){let[a]=y(),o=pS(e),s=e.tool.userFacingName(e.input),c=e.tool.isReadOnly(e.input),l=`${c?`Read`:`Edit`} file`;return o?(0,$.jsx)(Lx,{toolUseConfirm:e,toolUseContext:i,onDone:t,onReject:n,title:l,content:(0,$.jsx)(b,{flexDirection:`column`,paddingX:2,paddingY:1,children:(0,$.jsxs)(T,{children:[s,`(`,e.tool.renderToolUseMessage(e.input,{theme:a,verbose:r}),`)`]})}),path:o,parseInput:e=>e,operationType:c?`read`:`write`,completionType:`tool_use_single`}):(0,$.jsx)(lS,{toolUseConfirm:e,toolUseContext:i,onDone:t,onReject:n,verbose:r})}wa(),B(),Gu(),wr();function hS({file_path:e,content:t,fileExists:n,oldContent:r}){let{columns:i}=de(),a=(0,Q.useMemo)(()=>n?Tt({filePath:e,fileContents:r,edits:[{old_string:r,new_string:t,replace_all:!1}]}):null,[n,e,r,t]),o=t.split(`
|
|
30
30
|
`)[0]??null;return(0,$.jsx)(b,{flexDirection:`column`,children:(0,$.jsx)(b,{borderColor:`subtle`,borderStyle:`dashed`,flexDirection:`column`,borderLeft:!1,borderRight:!1,paddingX:1,children:a?If(a.map(t=>(0,$.jsx)(Vn,{patch:t,dim:!1,filePath:e,firstLine:o,fileContent:r,width:i-2},t.newStart)),e=>(0,$.jsx)(k,{fromLeftEdge:!0,children:(0,$.jsx)(T,{dimColor:!0,children:`...`})},`ellipsis-${e}`)):(0,$.jsx)(su,{code:t||`(No content)`,filePath:e})})})}B(),qd(),ef(),_p();var gS={getConfig:e=>{let t;try{t=gp(e.file_path)}catch(e){if(!Zd(e))throw e;t=``}return uS(e.file_path,t,e.content,!1)},applyChanges:(e,t)=>{let n=t[0];return n?{...e,content:n.new_string}:e}};function _S(e){let t=e=>Ot.inputSchema.parse(e),{file_path:n,content:r}=t(e.toolUseConfirm.input),{fileExists:i,oldContent:a}=(0,Q.useMemo)(()=>{try{return{fileExists:!0,oldContent:gp(n)}}catch(e){if(!Zd(e))throw e;return{fileExists:!1,oldContent:``}}},[n]),o=i?`overwrite`:`create`;return(0,$.jsx)(Lx,{toolUseConfirm:e.toolUseConfirm,toolUseContext:e.toolUseContext,onDone:e.onDone,onReject:e.onReject,title:i?`Overwrite file`:`Create file`,subtitle:Pv(Jd(),n),question:(0,$.jsxs)(T,{children:[`Do you want to `,o,` `,(0,$.jsx)(T,{bold:!0,children:Av(n)}),`?`]}),content:(0,$.jsx)(hS,{file_path:n,content:r,fileExists:i,oldContent:a}),path:n,completionType:`write_file_single`,parseInput:t,ideDiffSupport:gS})}B(),Df(),qd(),Gu(),nf(),wr(),Lr();function vS(e){let t=(0,Q.useMemo)(()=>rf().readFile(e.notebook_path,{encoding:`utf-8`}).then(e=>Sp(e)).catch(()=>null),[e.notebook_path]);return(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(yS,{...e,promise:t})})}function yS({notebook_path:e,cell_id:t,new_source:n,cell_type:r,edit_mode:i=`replace`,verbose:a,width:o,promise:s}){let c=(0,Q.use)(s),l=(0,Q.useMemo)(()=>{if(!c||!t)return``;let e=va(t);if(e!==void 0){if(c.cells[e]){let t=c.cells[e].source;return Array.isArray(t)?t.join(``):t}return``}let n=c.cells.find(e=>e.id===t);return n?Array.isArray(n.source)?n.source.join(``):n.source:``},[c,t]),u=(0,Q.useMemo)(()=>!c||i===`insert`||i===`delete`?null:Tt({filePath:e,fileContents:l,edits:[{old_string:l,new_string:n,replace_all:!1}],ignoreWhitespace:!1}),[c,e,l,n,i]),d;switch(i){case`insert`:d=`Insert new cell`;break;case`delete`:d=`Delete cell`;break;default:d=`Replace cell contents`}return(0,$.jsx)(b,{flexDirection:`column`,children:(0,$.jsxs)(b,{borderStyle:`round`,flexDirection:`column`,paddingX:1,children:[(0,$.jsxs)(b,{paddingBottom:1,flexDirection:`column`,children:[(0,$.jsx)(T,{bold:!0,children:a?e:Pv(Jd(),e)}),(0,$.jsxs)(T,{dimColor:!0,children:[d,` for cell `,t,r?` (${r})`:``]})]}),i===`delete`?(0,$.jsx)(b,{flexDirection:`column`,paddingLeft:2,children:(0,$.jsx)(su,{code:l,filePath:e})}):i===`insert`?(0,$.jsx)(b,{flexDirection:`column`,paddingLeft:2,children:(0,$.jsx)(su,{code:n,filePath:r===`markdown`?`file.md`:e})}):u?If(u.map(t=>(0,$.jsx)(Vn,{patch:t,dim:!1,width:o,filePath:e,firstLine:n.split(`
|
|
@@ -68,7 +68,7 @@ Parse the user's input into ISO 8601 format. Return ONLY the formatted string, o
|
|
|
68
68
|
`)&&(a+=`
|
|
69
69
|
`),r.setRegister(a,i),e===`yank`)r.setOffset(t);else if(e===`delete`){let e=r.text.slice(0,t)+r.text.slice(n);r.setText(e);let i=Math.max(0,e.length-(wp(e).length||1));r.setOffset(Math.min(t,i))}else if(e===`change`){let e=r.text.slice(0,t)+r.text.slice(n);r.setText(e),r.enterInsert(t)}}function UT(e,t,n){let r=t===1?n.cursor.startOfLastLine():n.cursor.goToLine(t);if(r.equals(n.cursor))return;let i=BT(n.cursor,r,`G`,e,t);HT(e,i.from,i.to,n,i.linewise),n.recordChange({type:`operator`,op:e,motion:`G`,count:t})}function WT(e,t,n){let r=t===1?n.cursor.startOfFirstLine():n.cursor.goToLine(t);if(r.equals(n.cursor))return;let i=BT(n.cursor,r,`gg`,e,t);HT(e,i.from,i.to,n,i.linewise),n.recordChange({type:`operator`,op:e,motion:`gg`,count:t})}var GT={d:`delete`,c:`change`,y:`yank`};function KT(e){return e in GT}var qT=new Set([`h`,`l`,`j`,`k`,`w`,`b`,`e`,`W`,`B`,`E`,`0`,`^`,`$`]),JT=new Set([`f`,`F`,`t`,`T`]),YT={i:`inner`,a:`around`};function XT(e){return e in YT}var ZT=new Set([`w`,`W`,`"`,`'`,"`",`(`,`)`,`b`,`[`,`]`,`{`,`}`,`B`,`<`,`>`]),QT=1e4;function $T(){return{mode:`INSERT`,insertedText:``}}function eE(){return{lastChange:null,lastFind:null,register:``,registerIsLinewise:!1}}function tE(e,t,n){switch(e.type){case`idle`:return iE(t,n);case`count`:return aE(e,t,n);case`operator`:return oE(e,t,n);case`operatorCount`:return sE(e,t,n);case`operatorFind`:return cE(e,t,n);case`operatorTextObj`:return lE(e,t,n);case`find`:return uE(e,t,n);case`g`:return dE(e,t,n);case`operatorG`:return fE(e,t,n);case`replace`:return pE(e,t,n);case`indent`:return mE(e,t,n)}}function nE(e,t,n){return KT(e)?{next:{type:`operator`,op:GT[e],count:t}}:qT.has(e)?{execute:()=>{let r=yT(e,n.cursor,t);n.setOffset(r.offset)}}:JT.has(e)?{next:{type:`find`,find:e,count:t}}:e===`g`?{next:{type:`g`,count:t}}:e===`r`?{next:{type:`replace`,count:t}}:e===`>`||e===`<`?{next:{type:`indent`,dir:e,count:t}}:e===`~`?{execute:()=>PT(t,n)}:e===`x`?{execute:()=>MT(t,n)}:e===`J`?{execute:()=>FT(t,n)}:e===`p`||e===`P`?{execute:()=>IT(e===`p`,t,n)}:e===`D`?{execute:()=>OT(`delete`,`$`,1,n)}:e===`C`?{execute:()=>OT(`change`,`$`,1,n)}:e===`Y`?{execute:()=>jT(`yank`,t,n)}:e===`G`?{execute:()=>{t===1?n.setOffset(n.cursor.startOfLastLine().offset):n.setOffset(n.cursor.goToLine(t).offset)}}:e===`.`?{execute:()=>n.onDotRepeat?.()}:e===`;`||e===`,`?{execute:()=>hE(e===`,`,t,n)}:e===`u`?{execute:()=>n.onUndo?.()}:e===`i`?{execute:()=>n.enterInsert(n.cursor.offset)}:e===`I`?{execute:()=>n.enterInsert(n.cursor.firstNonBlankInLogicalLine().offset)}:e===`a`?{execute:()=>{let e=n.cursor.isAtEnd()?n.cursor.offset:n.cursor.right().offset;n.enterInsert(e)}}:e===`A`?{execute:()=>n.enterInsert(n.cursor.endOfLogicalLine().offset)}:e===`o`?{execute:()=>RT(`below`,n)}:e===`O`?{execute:()=>RT(`above`,n)}:null}function rE(e,t,n,r){return XT(n)?{next:{type:`operatorTextObj`,op:e,count:t,scope:YT[n]}}:JT.has(n)?{next:{type:`operatorFind`,op:e,count:t,find:n}}:qT.has(n)?{execute:()=>OT(e,n,t,r)}:n===`G`?{execute:()=>UT(e,t,r)}:n===`g`?{next:{type:`operatorG`,op:e,count:t}}:null}function iE(e,t){return/[1-9]/.test(e)?{next:{type:`count`,digits:e}}:e===`0`?{execute:()=>t.setOffset(t.cursor.startOfLogicalLine().offset)}:nE(e,1,t)||{}}function aE(e,t,n){if(/[0-9]/.test(t)){let n=e.digits+t;return{next:{type:`count`,digits:String(Math.min(parseInt(n,10),QT))}}}return nE(t,parseInt(e.digits,10),n)||{next:{type:`idle`}}}function oE(e,t,n){return t===e.op[0]?{execute:()=>jT(e.op,e.count,n)}:/[0-9]/.test(t)?{next:{type:`operatorCount`,op:e.op,count:e.count,digits:t}}:rE(e.op,e.count,t,n)||{next:{type:`idle`}}}function sE(e,t,n){if(/[0-9]/.test(t)){let n=e.digits+t,r=Math.min(parseInt(n,10),QT);return{next:{...e,digits:String(r)}}}let r=parseInt(e.digits,10),i=e.count*r;return rE(e.op,i,t,n)||{next:{type:`idle`}}}function cE(e,t,n){return{execute:()=>kT(e.op,e.find,t,e.count,n)}}function lE(e,t,n){return ZT.has(t)?{execute:()=>AT(e.op,e.scope,t,e.count,n)}:{next:{type:`idle`}}}function uE(e,t,n){return{execute:()=>{let r=n.cursor.findCharacter(t,e.find,e.count);r!==null&&(n.setOffset(r),n.setLastFind(e.find,t))}}}function dE(e,t,n){return t===`j`||t===`k`?{execute:()=>{let r=yT(`g${t}`,n.cursor,e.count);n.setOffset(r.offset)}}:t===`g`?e.count>1?{execute:()=>{let t=n.text.split(`
|
|
70
70
|
`),r=Math.min(e.count-1,t.length-1),i=0;for(let e=0;e<r;e++)i+=(t[e]?.length??0)+1;n.setOffset(i)}}:{execute:()=>n.setOffset(n.cursor.startOfFirstLine().offset)}:{next:{type:`idle`}}}function fE(e,t,n){return t===`j`||t===`k`?{execute:()=>OT(e.op,`g${t}`,e.count,n)}:t===`g`?{execute:()=>WT(e.op,e.count,n)}:{next:{type:`idle`}}}function pE(e,t,n){return t===``?{next:{type:`idle`}}:{execute:()=>NT(t,e.count,n)}}function mE(e,t,n){return t===e.dir?{execute:()=>LT(e.dir,e.count,n)}:{next:{type:`idle`}}}function hE(e,t,n){let r=n.getLastFind();if(!r)return;let i=r.type;e&&(i={f:`F`,F:`f`,t:`T`,T:`t`}[i]);let a=n.cursor.findCharacter(r.char,i,t);a!==null&&n.setOffset(a)}wl(),Ep();function gE(e){let t=Q.useRef($T()),[n,r]=(0,Q.useState)(`INSERT`),i=Q.useRef(eE()),a=Ru({...e,inputFilter:void 0}),{onModeChange:o,inputFilter:s}=e,c=(0,Q.useCallback)(e=>{e!==void 0&&a.setOffset(e),t.current={mode:`INSERT`,insertedText:``},r(`INSERT`),o?.(`INSERT`)},[a,o]),l=(0,Q.useCallback)(()=>{let n=t.current;n.mode===`INSERT`&&n.insertedText&&(i.current.lastChange={type:`insert`,text:n.insertedText});let s=a.offset;s>0&&e.value[s-1]!==`
|
|
71
|
-
`&&a.setOffset(s-1),t.current={mode:`NORMAL`,command:{type:`idle`}},r(`NORMAL`),o?.(`NORMAL`)},[o,a,e.value]);function u(t,n=!1){return{cursor:t,text:e.value,setText:t=>e.onChange(t),setOffset:e=>a.setOffset(e),enterInsert:e=>c(e),getRegister:()=>i.current.register,setRegister:(e,t)=>{i.current.register=e,i.current.registerIsLinewise=t},getLastFind:()=>i.current.lastFind,setLastFind:(e,t)=>{i.current.lastFind={type:e,char:t}},recordChange:n?()=>{}:e=>{i.current.lastChange=e}}}function d(){let t=i.current.lastChange;if(!t)return;let n=ac.fromText(e.value,e.columns,a.offset),r=u(n,!0);switch(t.type){case`insert`:if(t.text){let r=n.insert(t.text);e.onChange(r.text),a.setOffset(r.offset)}break;case`x`:MT(t.count,r);break;case`replace`:NT(t.char,t.count,r);break;case`toggleCase`:PT(t.count,r);break;case`indent`:LT(t.dir,t.count,r);break;case`join`:FT(t.count,r);break;case`openLine`:RT(t.direction,r);break;case`operator`:OT(t.op,t.motion,t.count,r);break;case`operatorFind`:kT(t.op,t.find,t.char,t.count,r);break;case`operatorTextObj`:AT(t.op,t.scope,t.objType,t.count,r);break}}function f(n,r){let i=t.current,o=s?s(n,r):n,c=i.mode===`INSERT`?o:n,f=ac.fromText(e.value,e.columns,a.offset);if(r.ctrl){a.onInput(c,r);return}if(r.escape&&i.mode===`INSERT`){l();return}if(r.escape&&i.mode===`NORMAL`){t.current={mode:`NORMAL`,command:{type:`idle`}};return}if(r.return){a.onInput(c,r);return}if(i.mode===`INSERT`){r.backspace||r.delete?i.insertedText.length>0&&(t.current={mode:`INSERT`,insertedText:i.insertedText.slice(0,-(wp(i.insertedText).length||1))}):t.current={mode:`INSERT`,insertedText:i.insertedText+c},a.onInput(c,r);return}if(i.mode!==`NORMAL`)return;if(i.command.type===`idle`&&(r.upArrow||r.downArrow||r.leftArrow||r.rightArrow)){a.onInput(c,r);return}let p={...u(f,!1),onUndo:e.onUndo,onDotRepeat:d},m=i.command.type===`idle`||i.command.type===`count`||i.command.type===`operator`||i.command.type===`operatorCount`,h=c;r.leftArrow?h=`h`:r.rightArrow?h=`l`:r.upArrow?h=`k`:r.downArrow?h=`j`:m&&r.backspace?h=`h`:m&&i.command.type!==`count`&&r.delete&&(h=`x`);let g=tE(i.command,h,p);g.execute&&g.execute(),t.current.mode===`NORMAL`&&(g.next?t.current={mode:`NORMAL`,command:g.next}:g.execute&&(t.current={mode:`NORMAL`,command:{type:`idle`}})),c===`?`&&i.mode===`NORMAL`&&i.command.type===`idle`&&e.onChange(`?`)}let p=(0,Q.useCallback)(e=>{e===`INSERT`?t.current={mode:`INSERT`,insertedText:``}:t.current={mode:`NORMAL`,command:{type:`idle`}},r(e),o?.(e)},[o]);return{...a,onInput:f,mode:n,setMode:p}}R(),B();function _E(e){let[t]=y(),n=M();Ua(n,!!e.onImagePaste);let r=gE({value:e.value,onChange:e.onChange,onSubmit:e.onSubmit,onExit:e.onExit,onExitMessage:e.onExitMessage,onHistoryReset:e.onHistoryReset,onHistoryUp:e.onHistoryUp,onHistoryDown:e.onHistoryDown,onClearInput:e.onClearInput,focus:e.focus,mask:e.mask,multiline:e.multiline,cursorChar:e.showCursor?` `:``,highlightPastedText:e.highlightPastedText,invert:n?H.inverse:e=>e,themeText:ce(`text`,t),columns:e.columns,maxVisibleLines:e.maxVisibleLines,onImagePaste:e.onImagePaste,disableCursorMovementForUpDownKeys:e.disableCursorMovementForUpDownKeys,disableEscapeDoublePress:e.disableEscapeDoublePress,externalOffset:e.cursorOffset,onOffsetChange:e.onChangeCursorOffset,inputFilter:e.inputFilter,onModeChange:e.onModeChange,onUndo:e.onUndo}),{mode:i,setMode:a}=r;return Q.useEffect(()=>{e.initialMode&&e.initialMode!==i&&a(e.initialMode)},[e.initialMode,i,a]),(0,$.jsx)(b,{flexDirection:`column`,children:(0,$.jsx)(Nl,{inputState:r,terminalFocus:n,highlights:e.highlights,...e})})}kh(),Jh(),Cn(),lg(),U_(),s();function vE(e){if(!e)return null;let t=e.input_tokens+e.cache_creation_input_tokens+e.cache_read_input_tokens;return t===0?null:Math.round(e.cache_read_input_tokens/t*100)}function yE(e){return`${e.input_tokens}|${e.cache_creation_input_tokens}|${e.cache_read_input_tokens}`}function bE(e){let t=zv(`sha256`).update(e).digest(`hex`).slice(0,16);return Lv(o(),`cache-stats`,`${t}.json`)}var xE={version:1,signature:null,lastResetAt:null,lastHitRate:null};function SE(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.version===1&&(t.signature===null||typeof t.signature==`string`)&&(t.lastResetAt===null||typeof t.lastResetAt==`number`)&&(t.lastHitRate===null||typeof t.lastHitRate==`number`)}async function CE(e){try{let t=await qv(e,`utf8`),n=JSON.parse(t);return SE(n)?n:{...xE}}catch{return{...xE}}}async function wE(e,t){await Kv(Iv(e),{recursive:!0});let n=`${e}.${process.pid}.tmp`;try{await Yv(n,JSON.stringify(t),`utf8`),await Jv(n,e)}catch{}}var TE={signature:null,lastResetAt:null,lastHitRate:null},EE=null;async function DE(e){EE=e;let t=await CE(bE(e));TE={signature:t.signature,lastResetAt:t.lastResetAt,lastHitRate:t.lastHitRate}}function OE(e){let t=yE(e),n=vE(e);return t!==TE.signature&&(TE={signature:t,lastResetAt:Date.now(),lastHitRate:n},EE!==null&&wE(bE(EE),{version:1,signature:t,lastResetAt:TE.lastResetAt,lastHitRate:n})),{...TE}}function kE(){return{...TE}}B(),kp(),wa();function AE(e){let t=e-Date.now()/1e3;if(t<=0)return`now`;let n=Math.floor(t/86400),r=Math.floor(t%86400/3600),i=Math.floor(t%3600/60);return n>=1?`${n}d${r}h`:r>=1?`${r}h${i}m`:`${i}m`}function jE(){return(0,$.jsx)(T,{dimColor:!0,children:` │ `})}function ME({modelName:e,contextUsedPct:t,usedTokens:n,contextWindowSize:r,totalCostUsd:i,rateLimits:a}){let{columns:o}=de(),[s,c]=(0,Q.useState)(0);(0,Q.useEffect)(()=>{if(!((a.five_hour?.resets_at??0)||(a.seven_day?.resets_at??0)))return;let e=setInterval(()=>c(e=>e+1),6e4);return()=>clearInterval(e)},[a.five_hour?.resets_at,a.seven_day?.resets_at]);let l=e.split(` `),u=l.length>=2?`${l[0]} ${l[1]}`:e,d=o<60,f=a.five_hour!=null,p=a.seven_day!=null,m=f?Math.round(a.five_hour.utilization*100):0,h=p?Math.round(a.seven_day.utilization*100):0,g=`${Np(n)}/${Np(r)}`;return(0,$.jsxs)(b,{children:[(0,$.jsx)(T,{children:u}),(0,$.jsx)(jE,{}),(0,$.jsx)(T,{dimColor:!0,children:`Context `}),(0,$.jsxs)(T,{children:[t,`%`]}),!d&&(0,$.jsxs)(T,{dimColor:!0,children:[` (`,g,`)`]}),f&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(jE,{}),(0,$.jsx)(T,{dimColor:!0,children:`Session `}),(0,$.jsxs)(T,{children:[m,`%`]}),!d&&a.five_hour.resets_at>0&&(0,$.jsxs)(T,{dimColor:!0,children:[` `,AE(a.five_hour.resets_at)]})]}),p&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(jE,{}),(0,$.jsx)(T,{dimColor:!0,children:`Weekly `}),(0,$.jsxs)(T,{children:[h,`%`]}),!d&&a.seven_day.resets_at>0&&(0,$.jsxs)(T,{dimColor:!0,children:[` `,AE(a.seven_day.resets_at)]})]}),i>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(jE,{}),(0,$.jsx)(T,{children:wu(i)})]})]})}var NE=Q.memo(ME);Cp(),q(),rt(),Ll(),Ul(),e_(),Yt(),B(),Vf(),km(),qd(),of(),Td(),Vd(),lm(),Wc(),Ka(),kp();var PE=3600*1e3;function FE(e){return String(Math.floor(e)).padStart(2,`0`)}function IE(e){if(e<=0)return`exp`;let t=Math.floor(e/6e4),n=Math.floor(e%6e4/1e3);return`${FE(t)}:${FE(n)}`}function LE({messages:e}){let[t,n]=(0,Q.useState)(()=>Date.now()),[r,i]=(0,Q.useState)(!0),a=Md(e),o=(0,Q.useRef)(null);if(a!==null){let e=yE(a);e!==o.current&&(o.current=e,OE(a))}let{lastResetAt:s,lastHitRate:c}=kE(),l=s===null?null:t-s,u=l===null?null:PE-l,d=l===null?null:l/6e4,f=u!==null&&u<=0;(0,Q.useEffect)(()=>{let e=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(e)},[]);let p=d!==null&&d>=55&&!f;(0,Q.useEffect)(()=>{if(!p){i(!0);return}let e=setInterval(()=>i(e=>!e),500);return()=>clearInterval(e)},[p]);let m=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{m.current||(m.current=!0,DE(at()))},[]);let h=a===null?c:vE(a);if(h===null&&s===null)return(0,$.jsx)(T,{dimColor:!0,children:` Cache --% --:--`});let g=u===null?`--:--`:IE(u),_=h===null?`--%`:`${h}%`,v;return v=f||d===null?`inactive`:d<20?`success`:d<40?`warning`:`error`,(0,$.jsxs)(T,{children:[(0,$.jsx)(T,{dimColor:!0,children:` Cache `}),(0,$.jsx)(T,{color:h!==null&&h>=50?`success`:`inactive`,children:_}),(0,$.jsxs)(T,{color:v,dimColor:p&&!r,children:[` `,g]})]})}function RE(){let{getGoal:t,formatGoalStatusLabel:n}=(Zo(),e(Cc)),r=t();if(!r)return null;let i=r.objective.length>30?`${r.objective.slice(0,27)}…`:r.objective,a=r.tokenBudget===null?Np(r.tokensUsed):`${Np(r.tokensUsed)}/${Np(r.tokenBudget)}`,o=n(r.status),s;switch(r.status){case`active`:s=(0,$.jsx)(T,{color:`ansi:green`,children:o});break;case`paused`:case`budget_limited`:case`usage_limited`:s=(0,$.jsx)(T,{color:`ansi:yellow`,children:o});break;case`blocked`:s=(0,$.jsx)(T,{color:`ansi:red`,children:o});break;case`complete`:s=(0,$.jsx)(T,{color:`ansi:cyan`,children:o});break;default:s=(0,$.jsx)(T,{children:o})}return(0,$.jsxs)(T,{children:[s,(0,$.jsx)(T,{dimColor:!0,children:` · `}),(0,$.jsx)(T,{dimColor:!0,children:i}),(0,$.jsx)(T,{dimColor:!0,children:` · `}),(0,$.jsx)(T,{children:a})]})}function zE(e){return Ne()||e?.statusLineEnabled===!1?!1:e?.statusLineEnabled===!0||!!e?.statusLine?.command}function BE(e,t,n,r,i,a,o){let s=Ze(),c=rn(),l=Cm({permissionMode:e,mainLoopModel:a,exceeds200kTokens:t}),u=n?.outputStyle||`default`,d=Md(r),f=Zp(l,dt()),p=im(d,f),m=Sl(at()),h=rs(),g={...h.five_hour&&{five_hour:{used_percentage:h.five_hour.utilization*100,resets_at:h.five_hour.resets_at}},...h.seven_day&&{seven_day:{used_percentage:h.seven_day.utilization*100,resets_at:h.seven_day.resets_at}}};return{...Fn(),...m&&{session_name:m},model:{id:l,display_name:tm(l)},workspace:{current_dir:Jd(),project_dir:ct(),added_dirs:i},version:`0.0.1`,output_style:{name:u},cost:{total_cost_usd:st(),total_duration_ms:Oe(),total_api_duration_ms:Ue(),total_lines_added:Re(),total_lines_removed:ze()},context_window:{total_input_tokens:ot(),total_output_tokens:Be(),context_window_size:f,current_usage:d,used_percentage:p.used,remaining_percentage:p.remaining},exceeds_200k_tokens:t,...(g.five_hour||g.seven_day)&&{rate_limits:g},...B_()&&{vim:{mode:o??`INSERT`}},...s&&{agent:{name:s}},...ke()&&{remote:{session_id:at()}},...c&&{worktree:{name:c.worktreeName,path:c.worktreePath,branch:c.worktreeBranch,original_cwd:c.originalCwd,original_branch:c.originalBranch}}}}function VE(e){return $c(e)?.uuid??null}function HE({messagesRef:e,lastAssistantMessageId:t,vimMode:n}){let r=(0,Q.useRef)(void 0),i=J(e=>e.toolPermissionContext.mode),a=J(e=>e.toolPermissionContext.additionalWorkingDirectories),o=J(e=>e.statusLineText),s=Qs(),c=ao(),{addNotification:l}=Au(),u=$g(),d=(0,Q.useRef)(c);d.current=c;let f=(0,Q.useRef)(n);f.current=n;let p=(0,Q.useRef)(i);p.current=i;let m=(0,Q.useRef)(a);m.current=a;let h=(0,Q.useRef)(u);h.current=u;let _=(0,Q.useRef)({messageId:null,exceeds200kTokens:!1,permissionMode:i,vimMode:n,mainLoopModel:u}),v=(0,Q.useRef)(void 0),y=(0,Q.useRef)(!0),x=(0,Q.useCallback)(async()=>{r.current?.abort();let t=new AbortController;r.current=t;let n=e.current,i=y.current;if(y.current=!1,d.current?.statusLine?.command)try{let e=_.current.exceeds200kTokens,r=VE(n);r!==_.current.messageId&&(e=Wr(n),_.current.messageId=r,_.current.exceeds200kTokens=e);let a=await Ws(BE(p.current,e,d.current,n,Array.from(m.current.keys()),h.current,f.current),t.signal,void 0,i);t.signal.aborted||s(e=>e.statusLineText===a?e:{...e,statusLineText:a})}catch{}},[e,s]),S=(0,Q.useCallback)(()=>{v.current!==void 0&&clearTimeout(v.current),v.current=setTimeout((e,t)=>{e.current=void 0,t()},300,v,x)},[x]);(0,Q.useEffect)(()=>{(t!==_.current.messageId||i!==_.current.permissionMode||n!==_.current.vimMode||u!==_.current.mainLoopModel)&&(_.current.permissionMode=i,_.current.vimMode=n,_.current.mainLoopModel=u,S())},[t,i,n,u,S]);let C=c?.statusLine?.command,w=(0,Q.useRef)(!0);(0,Q.useEffect)(()=>{if(w.current){w.current=!1;return}y.current=!0,x()},[C,x]),(0,Q.useEffect)(()=>{let e=c?.statusLine;e&&(Z(`tengu_status_line_mount`,{command_length:e.command.length,padding:e.padding}),c.disableAllHooks===!0&&Y(`Status line is configured but disableAllHooks is true`,{level:`warn`}),Uf()||(l({key:`statusline-trust-blocked`,text:`statusline skipped · restart to fix`,color:`warning`,priority:`low`}),Y(`Status line command skipped: workspace trust not accepted`,{level:`warn`})))},[]),(0,Q.useEffect)(()=>(x(),()=>{r.current?.abort(),v.current!==void 0&&clearTimeout(v.current)}),[]);let E=c?.statusLine?.padding??0,D=Cm({permissionMode:i,mainLoopModel:u,exceeds200kTokens:_.current.exceeds200kTokens}),O=Zp(D,dt()),k=Md(e.current),A=k?k.input_tokens+k.cache_creation_input_tokens+k.cache_read_input_tokens:0,j=k?Math.round(im(k,O).used??0):0,M=rs(),N={...M.five_hour&&{five_hour:{utilization:M.five_hour.utilization,resets_at:M.five_hour.resets_at}},...M.seven_day&&{seven_day:{utilization:M.seven_day.utilization,resets_at:M.seven_day.resets_at}}},ee=c?.statusLineEnabled===!0,P=!!c?.statusLine?.command;return(0,$.jsxs)(b,{flexDirection:`column`,paddingX:E,children:[ee&&(0,$.jsxs)(b,{gap:2,children:[(0,$.jsx)(NE,{modelName:tm(D),contextUsedPct:j,usedTokens:A,contextWindowSize:O,totalCostUsd:st(),rateLimits:N}),(0,$.jsx)(RE,{}),(0,$.jsx)(LE,{messages:e.current})]}),o?(0,$.jsx)(T,{dimColor:!0,wrap:`truncate`,children:(0,$.jsx)(g,{children:o})}):P&&pl()?(0,$.jsx)(T,{children:` `}):null]})}var UE=(0,Q.memo)(HE);u(),q(),Nt(),jn(),B();function WE({tasksSelected:e,onOpenDialog:t}){let n=J(e=>e.tasks),r=(0,Q.useMemo)(()=>Object.values(n??{}).filter(e=>vu(e)&&!(process.env.USER_TYPE===`ant`&&ci(e))),[n]);return lv(n??{},!1)||r.length===0?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(GE,{selected:e,onClick:t,children:Bi(r)}),hr(r)&&(0,$.jsxs)(T,{dimColor:!0,children:[` · `,d.arrowDown,` to view`]})]})}function GE({selected:e,onClick:t,children:n}){let[r,i]=(0,Q.useState)(!1),a=(0,$.jsx)(T,{color:`background`,inverse:e||r,children:n});return t?(0,$.jsx)(b,{onClick:t,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),children:a}):a}B(),Ju();function KE({value:e,onChange:t,historyFailedMatch:n}){return(0,$.jsxs)(b,{gap:1,children:[(0,$.jsx)(T,{dimColor:!0,children:n?`no matching prompt:`:`search prompts:`}),(0,$.jsx)(Xs,{value:e,onChange:t,cursorOffset:e.length,onChangeCursorOffset:()=>{},columns:_(e)+1,focus:!0,showCursor:!0,multiline:!1,dimColor:!0})]})}Xf(),Gf(),Xd();var qE=5e3;function JE(e,t){if(e)return`draft`;switch(t){case`APPROVED`:return`approved`;case`CHANGES_REQUESTED`:return`changes_requested`;default:return`pending`}}async function YE(){if(!await qf())return null;let[e,t]=await Promise.all([Jf(),Kf()]);if(e===t)return null;let{stdout:n,code:r}=await Zf(`gh`,[`pr`,`view`,`--json`,`number,url,reviewDecision,isDraft,headRefName,state`],{timeout:qE,preserveOutputOnError:!1});if(r!==0||!n.trim())return null;try{let e=Yd(n);return e.headRefName===t||e.headRefName===`main`||e.headRefName===`master`||e.state===`MERGED`||e.state===`CLOSED`?null:{number:e.number,url:e.url,reviewState:JE(e.isDraft,e.reviewDecision)}}catch{return null}}rt();var XE=6e4,ZE=4e3,QE=60*6e4,$E={number:null,url:null,reviewState:null,lastUpdated:0};function eD(e,t=!0){let[n,r]=(0,Q.useState)($E),i=(0,Q.useRef)(null),a=(0,Q.useRef)(!1),o=(0,Q.useRef)(0);return(0,Q.useEffect)(()=>{if(!t||a.current)return;let e=!1,n=-1,s=Date.now();async function c(){if(e)return;let t=Le();if(n!==t)n=t,s=Date.now();else if(Date.now()-s>=QE)return;let l=Date.now(),u=await YE();if(!e){if(o.current=l,r(e=>{let t=u?.number??null,n=u?.reviewState??null;return e.number===t&&e.reviewState===n?e:{number:t,url:u?.url??null,reviewState:n,lastUpdated:Date.now()}}),Date.now()-l>ZE){a.current=!0;return}e||(i.current=setTimeout(c,XE))}}let l=Date.now()-o.current;return l>=XE?c():i.current=setTimeout(c,XE-l),()=>{e=!0,i.current&&(clearTimeout(i.current),i.current=null)}},[e,t]),n}B(),u(),U_(),Pa(),mf(),Dl(),Nt(),Df(),fv(),q(),rt(),wa(),kp(),Os(),Vf(),dp(),zd();var tD=(bh(),e(lh)),nD=e=>()=>{},rD=()=>null,iD=5e3,aD=1e3;function oD(){let[e,t]=(0,Q.useState)(null);return(0,Q.useEffect)(()=>{function e(){let e=process.memoryUsage().rss/(1024*1024),n=e>=1024?`error`:e>=512?`warning`:`normal`,r=Ap(e*1024*1024);t(e=>e?.text===r?e:{text:r,level:n})}e();let n=setInterval(e,iD);return()=>clearInterval(n)},[]),e}function sD(){let e=(0,Q.useSyncExternalStore)(tD?.subscribeToProactiveChanges??nD,tD?.getNextTickAt??rD,rD),[t,n]=(0,Q.useState)(null);return(0,Q.useEffect)(()=>{if(e===null){n(null);return}function t(){let t=Math.max(0,Math.ceil((e-Date.now())/1e3));n(t)}t();let r=setInterval(t,1e3);return()=>clearInterval(r)},[e]),t===null?null:(0,$.jsxs)(T,{dimColor:!0,children:[`waiting `,Mp(t*1e3,{mostSignificantOnly:!0})]})}function cD(){let[t,n]=(0,Q.useState)(0);(0,Q.useEffect)(()=>{let e=setInterval(()=>n(e=>e+1),aD);return()=>clearInterval(e)},[]);let r=(Zo(),e(Cc)),i=r.getGoal();if(!i)return null;let a=r.getActiveElapsedMs(i),o=Math.floor(a/1e3),s=Math.floor(o/3600),c=Math.floor(o%3600/60),l=o%60,u;u=s>=1?`${s}h${c}min`:c>=1?`${c}min`:`${l}s`;let d;switch(i.status){case`active`:d=`ansi:green`;break;case`paused`:case`budget_limited`:case`usage_limited`:d=`ansi:yellow`;break;case`blocked`:d=`ansi:red`;break;case`complete`:d=`ansi:cyan`;break}return(0,$.jsxs)(T,{color:d,children:[`goal (`,u,`)`]})}function lD({exitMessage:e,vimMode:t,mode:n,toolPermissionContext:r,suppressHint:i,isLoading:a,tasksSelected:o,tmuxSelected:s,isPasting:c,isSearching:l,historyQuery:u,setHistoryQuery:d,historyFailedMatch:f,onOpenTasksDialog:p}){if(e.show)return(0,$.jsxs)(T,{dimColor:!0,children:[`Press `,e.key,` again to exit`]},`exit-message`);if(c)return(0,$.jsx)(T,{dimColor:!0,children:`Pasting text…`},`pasting-message`);let m=B_()&&t===`INSERT`&&!l;return(0,$.jsxs)(b,{justifyContent:`flex-start`,gap:1,children:[l&&(0,$.jsx)(KE,{value:u,onChange:d,historyFailedMatch:f}),m?(0,$.jsx)(T,{dimColor:!0,children:`-- INSERT --`},`vim-insert`):null,(0,$.jsx)(uD,{mode:n,toolPermissionContext:r,showHint:!i&&!m,isLoading:a,tasksSelected:o,tmuxSelected:s,onOpenTasksDialog:p})]})}function uD({mode:t,toolPermissionContext:n,showHint:r,isLoading:i,tasksSelected:a,tmuxSelected:o,onOpenTasksDialog:s}){let{columns:c}=de(),l=lo(`chat:cycleMode`,`Chat`,`shift+tab`),u=J(e=>e.tasks),f=js(),[p]=(0,Q.useState)(()=>f.getState().remoteSessionUrl),m=eD(i,fD()),g=J(e=>process.env.USER_TYPE===`ant`&&e.tungstenActiveSession!==void 0),_=(0,Q.useSyncExternalStore)(tD?.subscribeToProactiveChanges??nD,tD?.getNextTickAt??rD,rD),v=L(),y=ue().getState,x=_!==null,S=(0,Q.useMemo)(()=>Pf(Object.values(u),e=>vu(e)&&!(process.env.USER_TYPE===`ant`&&ci(e))),[u]),w=vl(),E=w!==void 0&&w.length>0,D=lo(`chat:cancel`,`Chat`,`esc`).toLowerCase(),k=lo(`app:toggleTodos`,`Global`,`ctrl+t`),A=lo(`chat:killAgents`,`Chat`,`ctrl+x ctrl+k`),j=J(e=>e.notifications.current?.key===`kill-agents-confirm`),M=oD();if(t===`bash`)return(0,$.jsx)(T,{color:`bashBorder`,children:`! for bash mode`});let N=n?.mode,ee=!gf(N),P=S>0,F=+!!ee+ +!!P,I=fD()&&m.number!==null&&m.reviewState!==null&&m.url!==null&&F<2&&(F===0||c>=80),te=F<2,ne=N&&ee&&!ke()?(0,$.jsxs)(T,{color:bf(N),children:[pf(N),` `,Cf(N).toLowerCase(),` on`,te&&(0,$.jsxs)(T,{dimColor:!0,children:[` `,(0,$.jsx)(h,{shortcut:l,action:`cycle`,parens:!0})]})]},`mode`):null,R=[...p?[(0,$.jsx)(C,{url:p,children:(0,$.jsxs)(T,{color:`ide`,children:[d.circleDouble,` remote`]})},`remote`)]:[],...process.env.USER_TYPE===`ant`&&g?[(0,$.jsx)(TungstenPill,{selected:o},`tmux`)]:[],...I?[(0,$.jsx)(fa,{number:m.number,url:m.url,reviewState:m.reviewState},`pr-status`)]:[],...M?[(0,$.jsxs)(T,{dimColor:M.level===`normal`,color:M.level===`error`?`error`:M.level===`warning`?`warning`:void 0,children:[M.text,` · pid:`,process.pid]},`rss`)]:[],...(Zo(),e(Cc)).getGoal()?[(0,$.jsx)(cD,{},`goal-elapsed`)]:[]],re=Object.values(u).some(e=>e.type===`local_agent`&&e.status===`running`),ie=r?dD(i,D,k,A,E,re,j):[];x?R.push((0,$.jsx)(sD,{},`proactive`)):r&&R.push(...ie);let z=P&&!lv(u,!1)?(0,$.jsx)(WE,{tasksSelected:a,onOpenDialog:s}):null;R.length===0&&!z&&!ne&&r&&R.push((0,$.jsx)(T,{dimColor:!0,children:`? for shortcuts`},`shortcuts-hint`));let ae=Bf().copyOnSelect??!0,oe=v&&(!ae||se());if(pl()&&oe){let e=up()===`macos`,t=e&&(y()?.lastPressHadAlt??!1);R.push((0,$.jsx)(T,{dimColor:!0,children:(0,$.jsxs)(O,{children:[!ae&&(0,$.jsx)(h,{shortcut:`ctrl+c`,action:`copy`}),se()&&(t?(0,$.jsx)(T,{children:`set macOptionClickForcesSelection in VS Code settings`}):(0,$.jsx)(h,{shortcut:e?`option+click`:`shift+click`,action:`native select`}))]})},`selection-copy`))}return z&&r&&R.push((0,$.jsx)(T,{dimColor:!0,children:a?(0,$.jsx)(h,{shortcut:`Enter`,action:`view tasks`}):(0,$.jsx)(h,{shortcut:`↓`,action:`manage`})},`manage-tasks`)),R.length===0&&!z&&!ne?pl()?(0,$.jsx)(T,{children:` `}):null:(0,$.jsxs)(b,{height:1,overflow:`hidden`,children:[ne&&(0,$.jsxs)(b,{flexShrink:0,children:[ne,(z||R.length>0)&&(0,$.jsx)(T,{dimColor:!0,children:` · `})]}),z&&(0,$.jsxs)(b,{flexShrink:0,children:[z,R.length>0&&(0,$.jsx)(T,{dimColor:!0,children:` · `})]}),R.length>0&&(0,$.jsx)(T,{wrap:`truncate`,children:(0,$.jsx)(O,{children:R})})]})}function dD(e,t,n,r,i,a,o){let s=i;return[...e?[(0,$.jsx)(T,{dimColor:!0,children:(0,$.jsx)(h,{shortcut:t,action:`interrupt`})},`esc`)]:[],...!e&&a&&!o?[(0,$.jsx)(T,{dimColor:!0,children:(0,$.jsx)(h,{shortcut:r,action:`stop agents`})},`kill-agents`)]:[],...s?[(0,$.jsx)(T,{dimColor:!0,children:(0,$.jsx)(h,{shortcut:n,action:`show tasks`})},`toggle-tasks`)]:[]]}function fD(){return Bf().prStatusFooterEnabled??!0}Jc(),Yt(),wa(),B(),Gr(),q(),Os(),Ug(),H_();function pD({apiKeyStatus:e,debug:t,exitMessage:n,vimMode:r,mode:i,autoUpdaterResult:a,isAutoUpdating:o,verbose:s,onAutoUpdaterResult:c,onChangeIsUpdating:l,suggestions:u,selectedSuggestion:d,maxColumnWidth:f,toolPermissionContext:p,helpOpen:m,suppressHint:h,isLoading:g,tasksSelected:_,bridgeSelected:v,tmuxSelected:y,ideSelection:x,mcpClients:S,isPasting:C=!1,isInputWrapped:w=!1,messages:E,isSearching:D,historyQuery:O,setHistoryQuery:k,historyFailedMatch:A,onOpenTasksDialog:j}){let M=ao(),{columns:N,rows:ee}=de(),P=(0,Q.useRef)(E);P.current=E;let F=(0,Q.useMemo)(()=>VE(E),[E]),I=N<80,te=pl(),ne=te&&ee<24,L=_,R=h||zE(M)||D;return Q_((0,Q.useMemo)(()=>te&&u.length?{suggestions:u,selectedSuggestion:d,maxColumnWidth:f}:null,[te,u,d,f])),u.length&&!te?(0,$.jsx)(b,{paddingX:2,paddingY:0,children:(0,$.jsx)(Wg,{suggestions:u,selectedSuggestion:d,maxColumnWidth:f})}):m?(0,$.jsx)(W_,{dimColor:!0,fixedWidth:!0,paddingX:2}):(0,$.jsx)($.Fragment,{children:(0,$.jsxs)(b,{flexDirection:I?`column`:`row`,justifyContent:I?`flex-start`:`space-between`,paddingX:2,gap:+!I,children:[(0,$.jsxs)(b,{flexDirection:`column`,flexShrink:+!I,children:[i===`prompt`&&!ne&&!n.show&&!C&&zE(M)&&(0,$.jsx)(UE,{messagesRef:P,lastAssistantMessageId:F,vimMode:r}),(0,$.jsx)(gD,{}),(0,$.jsx)(lD,{exitMessage:n,vimMode:r,mode:i,toolPermissionContext:p,suppressHint:R,isLoading:g,tasksSelected:L,tmuxSelected:y,isPasting:C,isSearching:D,historyQuery:O,setHistoryQuery:k,historyFailedMatch:A,onOpenTasksDialog:j})]}),(0,$.jsxs)(b,{flexShrink:1,gap:1,children:[te?null:(0,$.jsx)(OC,{apiKeyStatus:e,autoUpdaterResult:a,debug:t,isAutoUpdating:o,verbose:s,messages:E,onAutoUpdaterResult:c,onChangeIsUpdating:l,ideSelection:x,mcpClients:S,isInputWrapped:w,isNarrow:I}),process.env.USER_TYPE===`ant`&&Yh()&&(0,$.jsx)(T,{dimColor:!0,children:`undercover`}),(0,$.jsx)(hD,{bridgeSelected:v})]})]})})}var mD=(0,Q.memo)(pD);function hD({bridgeSelected:e}){let t=J(e=>e.replBridgeEnabled),n=J(e=>e.replBridgeConnected),r=J(e=>e.replBridgeSessionActive),i=J(e=>e.replBridgeReconnecting),a=J(e=>e.replBridgeExplicit);if(!Kh()||!t)return null;let o=wi({error:void 0,connected:n,sessionActive:r,reconnecting:i});return!a&&o.label!==`Remote Control reconnecting`?null:(0,$.jsxs)(T,{color:e?`background`:o.color,inverse:e,wrap:`truncate`,children:[o.label,e&&(0,$.jsx)(T,{dimColor:!0,children:` · Enter to view`})]})}function gD(){return null}u(),B();function _D({isLoading:e}){return(0,$.jsxs)(T,{color:process.env.USER_TYPE===`ant`?`subtle`:void 0,dimColor:e,children:[d.pointer,`\xA0`]})}function vD({mode:e,isLoading:t}){return(0,$.jsx)(b,{alignItems:`flex-start`,alignSelf:`flex-start`,flexWrap:`nowrap`,justifyContent:`flex-start`,children:e===`bash`?(0,$.jsx)(T,{color:`bashBorder`,dimColor:t,children:`!\xA0`}):(0,$.jsx)(_D,{isLoading:t})})}B(),q(),Un(),jr(),Vd(),Xd(),Hc();var yD=new Set;function bD(e){try{return Yd(e)?.type===`idle_notification`}catch{return!1}}var xD=3;function SD(e){return`<${Qf}>
|
|
71
|
+
`&&a.setOffset(s-1),t.current={mode:`NORMAL`,command:{type:`idle`}},r(`NORMAL`),o?.(`NORMAL`)},[o,a,e.value]);function u(t,n=!1){return{cursor:t,text:e.value,setText:t=>e.onChange(t),setOffset:e=>a.setOffset(e),enterInsert:e=>c(e),getRegister:()=>i.current.register,setRegister:(e,t)=>{i.current.register=e,i.current.registerIsLinewise=t},getLastFind:()=>i.current.lastFind,setLastFind:(e,t)=>{i.current.lastFind={type:e,char:t}},recordChange:n?()=>{}:e=>{i.current.lastChange=e}}}function d(){let t=i.current.lastChange;if(!t)return;let n=ac.fromText(e.value,e.columns,a.offset),r=u(n,!0);switch(t.type){case`insert`:if(t.text){let r=n.insert(t.text);e.onChange(r.text),a.setOffset(r.offset)}break;case`x`:MT(t.count,r);break;case`replace`:NT(t.char,t.count,r);break;case`toggleCase`:PT(t.count,r);break;case`indent`:LT(t.dir,t.count,r);break;case`join`:FT(t.count,r);break;case`openLine`:RT(t.direction,r);break;case`operator`:OT(t.op,t.motion,t.count,r);break;case`operatorFind`:kT(t.op,t.find,t.char,t.count,r);break;case`operatorTextObj`:AT(t.op,t.scope,t.objType,t.count,r);break}}function f(n,r){let i=t.current,o=s?s(n,r):n,c=i.mode===`INSERT`?o:n,f=ac.fromText(e.value,e.columns,a.offset);if(r.ctrl){a.onInput(c,r);return}if(r.escape&&i.mode===`INSERT`){l();return}if(r.escape&&i.mode===`NORMAL`){t.current={mode:`NORMAL`,command:{type:`idle`}};return}if(r.return){a.onInput(c,r);return}if(i.mode===`INSERT`){r.backspace||r.delete?i.insertedText.length>0&&(t.current={mode:`INSERT`,insertedText:i.insertedText.slice(0,-(wp(i.insertedText).length||1))}):t.current={mode:`INSERT`,insertedText:i.insertedText+c},a.onInput(c,r);return}if(i.mode!==`NORMAL`)return;if(i.command.type===`idle`&&(r.upArrow||r.downArrow||r.leftArrow||r.rightArrow)){a.onInput(c,r);return}let p={...u(f,!1),onUndo:e.onUndo,onDotRepeat:d},m=i.command.type===`idle`||i.command.type===`count`||i.command.type===`operator`||i.command.type===`operatorCount`,h=c;r.leftArrow?h=`h`:r.rightArrow?h=`l`:r.upArrow?h=`k`:r.downArrow?h=`j`:m&&r.backspace?h=`h`:m&&i.command.type!==`count`&&r.delete&&(h=`x`);let g=tE(i.command,h,p);g.execute&&g.execute(),t.current.mode===`NORMAL`&&(g.next?t.current={mode:`NORMAL`,command:g.next}:g.execute&&(t.current={mode:`NORMAL`,command:{type:`idle`}})),c===`?`&&i.mode===`NORMAL`&&i.command.type===`idle`&&e.onChange(`?`)}let p=(0,Q.useCallback)(e=>{e===`INSERT`?t.current={mode:`INSERT`,insertedText:``}:t.current={mode:`NORMAL`,command:{type:`idle`}},r(e),o?.(e)},[o]);return{...a,onInput:f,mode:n,setMode:p}}R(),B();function _E(e){let[t]=y(),n=M();Ua(n,!!e.onImagePaste);let r=gE({value:e.value,onChange:e.onChange,onSubmit:e.onSubmit,onExit:e.onExit,onExitMessage:e.onExitMessage,onHistoryReset:e.onHistoryReset,onHistoryUp:e.onHistoryUp,onHistoryDown:e.onHistoryDown,onClearInput:e.onClearInput,focus:e.focus,mask:e.mask,multiline:e.multiline,cursorChar:e.showCursor?` `:``,highlightPastedText:e.highlightPastedText,invert:n?H.inverse:e=>e,themeText:ce(`text`,t),columns:e.columns,maxVisibleLines:e.maxVisibleLines,onImagePaste:e.onImagePaste,disableCursorMovementForUpDownKeys:e.disableCursorMovementForUpDownKeys,disableEscapeDoublePress:e.disableEscapeDoublePress,externalOffset:e.cursorOffset,onOffsetChange:e.onChangeCursorOffset,inputFilter:e.inputFilter,onModeChange:e.onModeChange,onUndo:e.onUndo}),{mode:i,setMode:a}=r;return Q.useEffect(()=>{e.initialMode&&e.initialMode!==i&&a(e.initialMode)},[e.initialMode,i,a]),(0,$.jsx)(b,{flexDirection:`column`,children:(0,$.jsx)(Nl,{inputState:r,terminalFocus:n,highlights:e.highlights,...e})})}kh(),Jh(),Cn(),lg(),U_(),s();function vE(e){if(!e)return null;let t=e.input_tokens+e.cache_creation_input_tokens+e.cache_read_input_tokens;return t===0?null:Math.round(e.cache_read_input_tokens/t*100)}function yE(e){return`${e.input_tokens}|${e.cache_creation_input_tokens}|${e.cache_read_input_tokens}`}function bE(e){let t=zv(`sha256`).update(e).digest(`hex`).slice(0,16);return Lv(o(),`cache-stats`,`${t}.json`)}var xE={version:1,signature:null,lastResetAt:null,lastHitRate:null};function SE(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.version===1&&(t.signature===null||typeof t.signature==`string`)&&(t.lastResetAt===null||typeof t.lastResetAt==`number`)&&(t.lastHitRate===null||typeof t.lastHitRate==`number`)}async function CE(e){try{let t=await qv(e,`utf8`),n=JSON.parse(t);return SE(n)?n:{...xE}}catch{return{...xE}}}async function wE(e,t){await Kv(Iv(e),{recursive:!0});let n=`${e}.${process.pid}.tmp`;try{await Yv(n,JSON.stringify(t),`utf8`),await Jv(n,e)}catch{}}var TE={signature:null,lastResetAt:null,lastHitRate:null},EE=null;async function DE(e){EE=e;let t=await CE(bE(e));TE={signature:t.signature,lastResetAt:t.lastResetAt,lastHitRate:t.lastHitRate}}function OE(e){let t=yE(e),n=vE(e);return t!==TE.signature&&(TE={signature:t,lastResetAt:Date.now(),lastHitRate:n},EE!==null&&wE(bE(EE),{version:1,signature:t,lastResetAt:TE.lastResetAt,lastHitRate:n})),{...TE}}function kE(){return{...TE}}B(),kp(),wa();function AE(e){let t=e-Date.now()/1e3;if(t<=0)return`now`;let n=Math.floor(t/86400),r=Math.floor(t%86400/3600),i=Math.floor(t%3600/60);return n>=1?`${n}d${r}h`:r>=1?`${r}h${i}m`:`${i}m`}function jE(){return(0,$.jsx)(T,{dimColor:!0,children:` │ `})}function ME({modelName:e,contextUsedPct:t,usedTokens:n,contextWindowSize:r,totalCostUsd:i,rateLimits:a}){let{columns:o}=de(),[s,c]=(0,Q.useState)(0);(0,Q.useEffect)(()=>{if(!((a.five_hour?.resets_at??0)||(a.seven_day?.resets_at??0)))return;let e=setInterval(()=>c(e=>e+1),6e4);return()=>clearInterval(e)},[a.five_hour?.resets_at,a.seven_day?.resets_at]);let l=e.split(` `),u=l.length>=2?`${l[0]} ${l[1]}`:e,d=o<60,f=a.five_hour!=null,p=a.seven_day!=null,m=f?Math.round(a.five_hour.utilization*100):0,h=p?Math.round(a.seven_day.utilization*100):0,g=`${Np(n)}/${Np(r)}`;return(0,$.jsxs)(b,{children:[(0,$.jsx)(T,{children:u}),(0,$.jsx)(jE,{}),(0,$.jsx)(T,{dimColor:!0,children:`Context `}),(0,$.jsxs)(T,{children:[t,`%`]}),!d&&(0,$.jsxs)(T,{dimColor:!0,children:[` (`,g,`)`]}),f&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(jE,{}),(0,$.jsx)(T,{dimColor:!0,children:`Session `}),(0,$.jsxs)(T,{children:[m,`%`]}),!d&&a.five_hour.resets_at>0&&(0,$.jsxs)(T,{dimColor:!0,children:[` `,AE(a.five_hour.resets_at)]})]}),p&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(jE,{}),(0,$.jsx)(T,{dimColor:!0,children:`Weekly `}),(0,$.jsxs)(T,{children:[h,`%`]}),!d&&a.seven_day.resets_at>0&&(0,$.jsxs)(T,{dimColor:!0,children:[` `,AE(a.seven_day.resets_at)]})]}),i>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(jE,{}),(0,$.jsx)(T,{children:wu(i)})]})]})}var NE=Q.memo(ME);Cp(),q(),rt(),Ll(),Ul(),e_(),Yt(),B(),Vf(),km(),qd(),of(),Td(),Vd(),lm(),Wc(),Ka(),kp();var PE=3600*1e3;function FE(e){return String(Math.floor(e)).padStart(2,`0`)}function IE(e){if(e<=0)return`exp`;let t=Math.floor(e/6e4),n=Math.floor(e%6e4/1e3);return`${FE(t)}:${FE(n)}`}function LE({messages:e}){let[t,n]=(0,Q.useState)(()=>Date.now()),[r,i]=(0,Q.useState)(!0),a=Md(e),o=(0,Q.useRef)(null);if(a!==null){let e=yE(a);e!==o.current&&(o.current=e,OE(a))}let{lastResetAt:s,lastHitRate:c}=kE(),l=s===null?null:t-s,u=l===null?null:PE-l,d=l===null?null:l/6e4,f=u!==null&&u<=0;(0,Q.useEffect)(()=>{let e=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(e)},[]);let p=d!==null&&d>=55&&!f;(0,Q.useEffect)(()=>{if(!p){i(!0);return}let e=setInterval(()=>i(e=>!e),500);return()=>clearInterval(e)},[p]);let m=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{m.current||(m.current=!0,DE(at()))},[]);let h=a===null?c:vE(a);if(h===null&&s===null)return(0,$.jsx)(T,{dimColor:!0,children:` Cache --% --:--`});let g=u===null?`--:--`:IE(u),_=h===null?`--%`:`${h}%`,v;return v=f||d===null?`inactive`:d<20?`success`:d<40?`warning`:`error`,(0,$.jsxs)(T,{children:[(0,$.jsx)(T,{dimColor:!0,children:` Cache `}),(0,$.jsx)(T,{color:h!==null&&h>=50?`success`:`inactive`,children:_}),(0,$.jsxs)(T,{color:v,dimColor:p&&!r,children:[` `,g]})]})}function RE(){let{getGoal:t,formatGoalStatusLabel:n}=(Zo(),e(Cc)),r=t();if(!r)return null;let i=r.objective.length>30?`${r.objective.slice(0,27)}…`:r.objective,a=r.tokenBudget===null?Np(r.tokensUsed):`${Np(r.tokensUsed)}/${Np(r.tokenBudget)}`,o=n(r.status),s;switch(r.status){case`active`:s=(0,$.jsx)(T,{color:`ansi:green`,children:o});break;case`paused`:case`budget_limited`:case`usage_limited`:s=(0,$.jsx)(T,{color:`ansi:yellow`,children:o});break;case`blocked`:s=(0,$.jsx)(T,{color:`ansi:red`,children:o});break;case`complete`:s=(0,$.jsx)(T,{color:`ansi:cyan`,children:o});break;default:s=(0,$.jsx)(T,{children:o})}return(0,$.jsxs)(T,{children:[s,(0,$.jsx)(T,{dimColor:!0,children:` · `}),(0,$.jsx)(T,{dimColor:!0,children:i}),(0,$.jsx)(T,{dimColor:!0,children:` · `}),(0,$.jsx)(T,{children:a})]})}function zE(e){return Ne()||e?.statusLineEnabled===!1?!1:e?.statusLineEnabled===!0||!!e?.statusLine?.command}function BE(e,t,n,r,i,a,o){let s=Ze(),c=rn(),l=Cm({permissionMode:e,mainLoopModel:a,exceeds200kTokens:t}),u=n?.outputStyle||`default`,d=Md(r),f=Zp(l,dt()),p=im(d,f),m=Sl(at()),h=rs(),g={...h.five_hour&&{five_hour:{used_percentage:h.five_hour.utilization*100,resets_at:h.five_hour.resets_at}},...h.seven_day&&{seven_day:{used_percentage:h.seven_day.utilization*100,resets_at:h.seven_day.resets_at}}};return{...Fn(),...m&&{session_name:m},model:{id:l,display_name:tm(l)},workspace:{current_dir:Jd(),project_dir:ct(),added_dirs:i},version:`0.0.2`,output_style:{name:u},cost:{total_cost_usd:st(),total_duration_ms:Oe(),total_api_duration_ms:Ue(),total_lines_added:Re(),total_lines_removed:ze()},context_window:{total_input_tokens:ot(),total_output_tokens:Be(),context_window_size:f,current_usage:d,used_percentage:p.used,remaining_percentage:p.remaining},exceeds_200k_tokens:t,...(g.five_hour||g.seven_day)&&{rate_limits:g},...B_()&&{vim:{mode:o??`INSERT`}},...s&&{agent:{name:s}},...ke()&&{remote:{session_id:at()}},...c&&{worktree:{name:c.worktreeName,path:c.worktreePath,branch:c.worktreeBranch,original_cwd:c.originalCwd,original_branch:c.originalBranch}}}}function VE(e){return $c(e)?.uuid??null}function HE({messagesRef:e,lastAssistantMessageId:t,vimMode:n}){let r=(0,Q.useRef)(void 0),i=J(e=>e.toolPermissionContext.mode),a=J(e=>e.toolPermissionContext.additionalWorkingDirectories),o=J(e=>e.statusLineText),s=Qs(),c=ao(),{addNotification:l}=Au(),u=$g(),d=(0,Q.useRef)(c);d.current=c;let f=(0,Q.useRef)(n);f.current=n;let p=(0,Q.useRef)(i);p.current=i;let m=(0,Q.useRef)(a);m.current=a;let h=(0,Q.useRef)(u);h.current=u;let _=(0,Q.useRef)({messageId:null,exceeds200kTokens:!1,permissionMode:i,vimMode:n,mainLoopModel:u}),v=(0,Q.useRef)(void 0),y=(0,Q.useRef)(!0),x=(0,Q.useCallback)(async()=>{r.current?.abort();let t=new AbortController;r.current=t;let n=e.current,i=y.current;if(y.current=!1,d.current?.statusLine?.command)try{let e=_.current.exceeds200kTokens,r=VE(n);r!==_.current.messageId&&(e=Wr(n),_.current.messageId=r,_.current.exceeds200kTokens=e);let a=await Ws(BE(p.current,e,d.current,n,Array.from(m.current.keys()),h.current,f.current),t.signal,void 0,i);t.signal.aborted||s(e=>e.statusLineText===a?e:{...e,statusLineText:a})}catch{}},[e,s]),S=(0,Q.useCallback)(()=>{v.current!==void 0&&clearTimeout(v.current),v.current=setTimeout((e,t)=>{e.current=void 0,t()},300,v,x)},[x]);(0,Q.useEffect)(()=>{(t!==_.current.messageId||i!==_.current.permissionMode||n!==_.current.vimMode||u!==_.current.mainLoopModel)&&(_.current.permissionMode=i,_.current.vimMode=n,_.current.mainLoopModel=u,S())},[t,i,n,u,S]);let C=c?.statusLine?.command,w=(0,Q.useRef)(!0);(0,Q.useEffect)(()=>{if(w.current){w.current=!1;return}y.current=!0,x()},[C,x]),(0,Q.useEffect)(()=>{let e=c?.statusLine;e&&(Z(`tengu_status_line_mount`,{command_length:e.command.length,padding:e.padding}),c.disableAllHooks===!0&&Y(`Status line is configured but disableAllHooks is true`,{level:`warn`}),Uf()||(l({key:`statusline-trust-blocked`,text:`statusline skipped · restart to fix`,color:`warning`,priority:`low`}),Y(`Status line command skipped: workspace trust not accepted`,{level:`warn`})))},[]),(0,Q.useEffect)(()=>(x(),()=>{r.current?.abort(),v.current!==void 0&&clearTimeout(v.current)}),[]);let E=c?.statusLine?.padding??0,D=Cm({permissionMode:i,mainLoopModel:u,exceeds200kTokens:_.current.exceeds200kTokens}),O=Zp(D,dt()),k=Md(e.current),A=k?k.input_tokens+k.cache_creation_input_tokens+k.cache_read_input_tokens:0,j=k?Math.round(im(k,O).used??0):0,M=rs(),N={...M.five_hour&&{five_hour:{utilization:M.five_hour.utilization,resets_at:M.five_hour.resets_at}},...M.seven_day&&{seven_day:{utilization:M.seven_day.utilization,resets_at:M.seven_day.resets_at}}},ee=c?.statusLineEnabled===!0,P=!!c?.statusLine?.command;return(0,$.jsxs)(b,{flexDirection:`column`,paddingX:E,children:[ee&&(0,$.jsxs)(b,{gap:2,children:[(0,$.jsx)(NE,{modelName:tm(D),contextUsedPct:j,usedTokens:A,contextWindowSize:O,totalCostUsd:st(),rateLimits:N}),(0,$.jsx)(RE,{}),(0,$.jsx)(LE,{messages:e.current})]}),o?(0,$.jsx)(T,{dimColor:!0,wrap:`truncate`,children:(0,$.jsx)(g,{children:o})}):P&&pl()?(0,$.jsx)(T,{children:` `}):null]})}var UE=(0,Q.memo)(HE);u(),q(),Nt(),jn(),B();function WE({tasksSelected:e,onOpenDialog:t}){let n=J(e=>e.tasks),r=(0,Q.useMemo)(()=>Object.values(n??{}).filter(e=>vu(e)&&!(process.env.USER_TYPE===`ant`&&ci(e))),[n]);return lv(n??{},!1)||r.length===0?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(GE,{selected:e,onClick:t,children:Bi(r)}),hr(r)&&(0,$.jsxs)(T,{dimColor:!0,children:[` · `,d.arrowDown,` to view`]})]})}function GE({selected:e,onClick:t,children:n}){let[r,i]=(0,Q.useState)(!1),a=(0,$.jsx)(T,{color:`background`,inverse:e||r,children:n});return t?(0,$.jsx)(b,{onClick:t,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),children:a}):a}B(),Ju();function KE({value:e,onChange:t,historyFailedMatch:n}){return(0,$.jsxs)(b,{gap:1,children:[(0,$.jsx)(T,{dimColor:!0,children:n?`no matching prompt:`:`search prompts:`}),(0,$.jsx)(Xs,{value:e,onChange:t,cursorOffset:e.length,onChangeCursorOffset:()=>{},columns:_(e)+1,focus:!0,showCursor:!0,multiline:!1,dimColor:!0})]})}Xf(),Gf(),Xd();var qE=5e3;function JE(e,t){if(e)return`draft`;switch(t){case`APPROVED`:return`approved`;case`CHANGES_REQUESTED`:return`changes_requested`;default:return`pending`}}async function YE(){if(!await qf())return null;let[e,t]=await Promise.all([Jf(),Kf()]);if(e===t)return null;let{stdout:n,code:r}=await Zf(`gh`,[`pr`,`view`,`--json`,`number,url,reviewDecision,isDraft,headRefName,state`],{timeout:qE,preserveOutputOnError:!1});if(r!==0||!n.trim())return null;try{let e=Yd(n);return e.headRefName===t||e.headRefName===`main`||e.headRefName===`master`||e.state===`MERGED`||e.state===`CLOSED`?null:{number:e.number,url:e.url,reviewState:JE(e.isDraft,e.reviewDecision)}}catch{return null}}rt();var XE=6e4,ZE=4e3,QE=60*6e4,$E={number:null,url:null,reviewState:null,lastUpdated:0};function eD(e,t=!0){let[n,r]=(0,Q.useState)($E),i=(0,Q.useRef)(null),a=(0,Q.useRef)(!1),o=(0,Q.useRef)(0);return(0,Q.useEffect)(()=>{if(!t||a.current)return;let e=!1,n=-1,s=Date.now();async function c(){if(e)return;let t=Le();if(n!==t)n=t,s=Date.now();else if(Date.now()-s>=QE)return;let l=Date.now(),u=await YE();if(!e){if(o.current=l,r(e=>{let t=u?.number??null,n=u?.reviewState??null;return e.number===t&&e.reviewState===n?e:{number:t,url:u?.url??null,reviewState:n,lastUpdated:Date.now()}}),Date.now()-l>ZE){a.current=!0;return}e||(i.current=setTimeout(c,XE))}}let l=Date.now()-o.current;return l>=XE?c():i.current=setTimeout(c,XE-l),()=>{e=!0,i.current&&(clearTimeout(i.current),i.current=null)}},[e,t]),n}B(),u(),U_(),Pa(),mf(),Dl(),Nt(),Df(),fv(),q(),rt(),wa(),kp(),Os(),Vf(),dp(),zd();var tD=(bh(),e(lh)),nD=e=>()=>{},rD=()=>null,iD=5e3,aD=1e3;function oD(){let[e,t]=(0,Q.useState)(null);return(0,Q.useEffect)(()=>{function e(){let e=process.memoryUsage().rss/(1024*1024),n=e>=1024?`error`:e>=512?`warning`:`normal`,r=Ap(e*1024*1024);t(e=>e?.text===r?e:{text:r,level:n})}e();let n=setInterval(e,iD);return()=>clearInterval(n)},[]),e}function sD(){let e=(0,Q.useSyncExternalStore)(tD?.subscribeToProactiveChanges??nD,tD?.getNextTickAt??rD,rD),[t,n]=(0,Q.useState)(null);return(0,Q.useEffect)(()=>{if(e===null){n(null);return}function t(){let t=Math.max(0,Math.ceil((e-Date.now())/1e3));n(t)}t();let r=setInterval(t,1e3);return()=>clearInterval(r)},[e]),t===null?null:(0,$.jsxs)(T,{dimColor:!0,children:[`waiting `,Mp(t*1e3,{mostSignificantOnly:!0})]})}function cD(){let[t,n]=(0,Q.useState)(0);(0,Q.useEffect)(()=>{let e=setInterval(()=>n(e=>e+1),aD);return()=>clearInterval(e)},[]);let r=(Zo(),e(Cc)),i=r.getGoal();if(!i)return null;let a=r.getActiveElapsedMs(i),o=Math.floor(a/1e3),s=Math.floor(o/3600),c=Math.floor(o%3600/60),l=o%60,u;u=s>=1?`${s}h${c}min`:c>=1?`${c}min`:`${l}s`;let d;switch(i.status){case`active`:d=`ansi:green`;break;case`paused`:case`budget_limited`:case`usage_limited`:d=`ansi:yellow`;break;case`blocked`:d=`ansi:red`;break;case`complete`:d=`ansi:cyan`;break}return(0,$.jsxs)(T,{color:d,children:[`goal (`,u,`)`]})}function lD({exitMessage:e,vimMode:t,mode:n,toolPermissionContext:r,suppressHint:i,isLoading:a,tasksSelected:o,tmuxSelected:s,isPasting:c,isSearching:l,historyQuery:u,setHistoryQuery:d,historyFailedMatch:f,onOpenTasksDialog:p}){if(e.show)return(0,$.jsxs)(T,{dimColor:!0,children:[`Press `,e.key,` again to exit`]},`exit-message`);if(c)return(0,$.jsx)(T,{dimColor:!0,children:`Pasting text…`},`pasting-message`);let m=B_()&&t===`INSERT`&&!l;return(0,$.jsxs)(b,{justifyContent:`flex-start`,gap:1,children:[l&&(0,$.jsx)(KE,{value:u,onChange:d,historyFailedMatch:f}),m?(0,$.jsx)(T,{dimColor:!0,children:`-- INSERT --`},`vim-insert`):null,(0,$.jsx)(uD,{mode:n,toolPermissionContext:r,showHint:!i&&!m,isLoading:a,tasksSelected:o,tmuxSelected:s,onOpenTasksDialog:p})]})}function uD({mode:t,toolPermissionContext:n,showHint:r,isLoading:i,tasksSelected:a,tmuxSelected:o,onOpenTasksDialog:s}){let{columns:c}=de(),l=lo(`chat:cycleMode`,`Chat`,`shift+tab`),u=J(e=>e.tasks),f=js(),[p]=(0,Q.useState)(()=>f.getState().remoteSessionUrl),m=eD(i,fD()),g=J(e=>process.env.USER_TYPE===`ant`&&e.tungstenActiveSession!==void 0),_=(0,Q.useSyncExternalStore)(tD?.subscribeToProactiveChanges??nD,tD?.getNextTickAt??rD,rD),v=L(),y=ue().getState,x=_!==null,S=(0,Q.useMemo)(()=>Pf(Object.values(u),e=>vu(e)&&!(process.env.USER_TYPE===`ant`&&ci(e))),[u]),w=vl(),E=w!==void 0&&w.length>0,D=lo(`chat:cancel`,`Chat`,`esc`).toLowerCase(),k=lo(`app:toggleTodos`,`Global`,`ctrl+t`),A=lo(`chat:killAgents`,`Chat`,`ctrl+x ctrl+k`),j=J(e=>e.notifications.current?.key===`kill-agents-confirm`),M=oD();if(t===`bash`)return(0,$.jsx)(T,{color:`bashBorder`,children:`! for bash mode`});let N=n?.mode,ee=!gf(N),P=S>0,F=+!!ee+ +!!P,I=fD()&&m.number!==null&&m.reviewState!==null&&m.url!==null&&F<2&&(F===0||c>=80),te=F<2,ne=N&&ee&&!ke()?(0,$.jsxs)(T,{color:bf(N),children:[pf(N),` `,Cf(N).toLowerCase(),` on`,te&&(0,$.jsxs)(T,{dimColor:!0,children:[` `,(0,$.jsx)(h,{shortcut:l,action:`cycle`,parens:!0})]})]},`mode`):null,R=[...p?[(0,$.jsx)(C,{url:p,children:(0,$.jsxs)(T,{color:`ide`,children:[d.circleDouble,` remote`]})},`remote`)]:[],...process.env.USER_TYPE===`ant`&&g?[(0,$.jsx)(TungstenPill,{selected:o},`tmux`)]:[],...I?[(0,$.jsx)(fa,{number:m.number,url:m.url,reviewState:m.reviewState},`pr-status`)]:[],...M?[(0,$.jsxs)(T,{dimColor:M.level===`normal`,color:M.level===`error`?`error`:M.level===`warning`?`warning`:void 0,children:[M.text,` · pid:`,process.pid]},`rss`)]:[],...(Zo(),e(Cc)).getGoal()?[(0,$.jsx)(cD,{},`goal-elapsed`)]:[]],re=Object.values(u).some(e=>e.type===`local_agent`&&e.status===`running`),ie=r?dD(i,D,k,A,E,re,j):[];x?R.push((0,$.jsx)(sD,{},`proactive`)):r&&R.push(...ie);let z=P&&!lv(u,!1)?(0,$.jsx)(WE,{tasksSelected:a,onOpenDialog:s}):null;R.length===0&&!z&&!ne&&r&&R.push((0,$.jsx)(T,{dimColor:!0,children:`? for shortcuts`},`shortcuts-hint`));let ae=Bf().copyOnSelect??!0,oe=v&&(!ae||se());if(pl()&&oe){let e=up()===`macos`,t=e&&(y()?.lastPressHadAlt??!1);R.push((0,$.jsx)(T,{dimColor:!0,children:(0,$.jsxs)(O,{children:[!ae&&(0,$.jsx)(h,{shortcut:`ctrl+c`,action:`copy`}),se()&&(t?(0,$.jsx)(T,{children:`set macOptionClickForcesSelection in VS Code settings`}):(0,$.jsx)(h,{shortcut:e?`option+click`:`shift+click`,action:`native select`}))]})},`selection-copy`))}return z&&r&&R.push((0,$.jsx)(T,{dimColor:!0,children:a?(0,$.jsx)(h,{shortcut:`Enter`,action:`view tasks`}):(0,$.jsx)(h,{shortcut:`↓`,action:`manage`})},`manage-tasks`)),R.length===0&&!z&&!ne?pl()?(0,$.jsx)(T,{children:` `}):null:(0,$.jsxs)(b,{height:1,overflow:`hidden`,children:[ne&&(0,$.jsxs)(b,{flexShrink:0,children:[ne,(z||R.length>0)&&(0,$.jsx)(T,{dimColor:!0,children:` · `})]}),z&&(0,$.jsxs)(b,{flexShrink:0,children:[z,R.length>0&&(0,$.jsx)(T,{dimColor:!0,children:` · `})]}),R.length>0&&(0,$.jsx)(T,{wrap:`truncate`,children:(0,$.jsx)(O,{children:R})})]})}function dD(e,t,n,r,i,a,o){let s=i;return[...e?[(0,$.jsx)(T,{dimColor:!0,children:(0,$.jsx)(h,{shortcut:t,action:`interrupt`})},`esc`)]:[],...!e&&a&&!o?[(0,$.jsx)(T,{dimColor:!0,children:(0,$.jsx)(h,{shortcut:r,action:`stop agents`})},`kill-agents`)]:[],...s?[(0,$.jsx)(T,{dimColor:!0,children:(0,$.jsx)(h,{shortcut:n,action:`show tasks`})},`toggle-tasks`)]:[]]}function fD(){return Bf().prStatusFooterEnabled??!0}Jc(),Yt(),wa(),B(),Gr(),q(),Os(),Ug(),H_();function pD({apiKeyStatus:e,debug:t,exitMessage:n,vimMode:r,mode:i,autoUpdaterResult:a,isAutoUpdating:o,verbose:s,onAutoUpdaterResult:c,onChangeIsUpdating:l,suggestions:u,selectedSuggestion:d,maxColumnWidth:f,toolPermissionContext:p,helpOpen:m,suppressHint:h,isLoading:g,tasksSelected:_,bridgeSelected:v,tmuxSelected:y,ideSelection:x,mcpClients:S,isPasting:C=!1,isInputWrapped:w=!1,messages:E,isSearching:D,historyQuery:O,setHistoryQuery:k,historyFailedMatch:A,onOpenTasksDialog:j}){let M=ao(),{columns:N,rows:ee}=de(),P=(0,Q.useRef)(E);P.current=E;let F=(0,Q.useMemo)(()=>VE(E),[E]),I=N<80,te=pl(),ne=te&&ee<24,L=_,R=h||zE(M)||D;return Q_((0,Q.useMemo)(()=>te&&u.length?{suggestions:u,selectedSuggestion:d,maxColumnWidth:f}:null,[te,u,d,f])),u.length&&!te?(0,$.jsx)(b,{paddingX:2,paddingY:0,children:(0,$.jsx)(Wg,{suggestions:u,selectedSuggestion:d,maxColumnWidth:f})}):m?(0,$.jsx)(W_,{dimColor:!0,fixedWidth:!0,paddingX:2}):(0,$.jsx)($.Fragment,{children:(0,$.jsxs)(b,{flexDirection:I?`column`:`row`,justifyContent:I?`flex-start`:`space-between`,paddingX:2,gap:+!I,children:[(0,$.jsxs)(b,{flexDirection:`column`,flexShrink:+!I,children:[i===`prompt`&&!ne&&!n.show&&!C&&zE(M)&&(0,$.jsx)(UE,{messagesRef:P,lastAssistantMessageId:F,vimMode:r}),(0,$.jsx)(gD,{}),(0,$.jsx)(lD,{exitMessage:n,vimMode:r,mode:i,toolPermissionContext:p,suppressHint:R,isLoading:g,tasksSelected:L,tmuxSelected:y,isPasting:C,isSearching:D,historyQuery:O,setHistoryQuery:k,historyFailedMatch:A,onOpenTasksDialog:j})]}),(0,$.jsxs)(b,{flexShrink:1,gap:1,children:[te?null:(0,$.jsx)(OC,{apiKeyStatus:e,autoUpdaterResult:a,debug:t,isAutoUpdating:o,verbose:s,messages:E,onAutoUpdaterResult:c,onChangeIsUpdating:l,ideSelection:x,mcpClients:S,isInputWrapped:w,isNarrow:I}),process.env.USER_TYPE===`ant`&&Yh()&&(0,$.jsx)(T,{dimColor:!0,children:`undercover`}),(0,$.jsx)(hD,{bridgeSelected:v})]})]})})}var mD=(0,Q.memo)(pD);function hD({bridgeSelected:e}){let t=J(e=>e.replBridgeEnabled),n=J(e=>e.replBridgeConnected),r=J(e=>e.replBridgeSessionActive),i=J(e=>e.replBridgeReconnecting),a=J(e=>e.replBridgeExplicit);if(!Kh()||!t)return null;let o=wi({error:void 0,connected:n,sessionActive:r,reconnecting:i});return!a&&o.label!==`Remote Control reconnecting`?null:(0,$.jsxs)(T,{color:e?`background`:o.color,inverse:e,wrap:`truncate`,children:[o.label,e&&(0,$.jsx)(T,{dimColor:!0,children:` · Enter to view`})]})}function gD(){return null}u(),B();function _D({isLoading:e}){return(0,$.jsxs)(T,{color:process.env.USER_TYPE===`ant`?`subtle`:void 0,dimColor:e,children:[d.pointer,`\xA0`]})}function vD({mode:e,isLoading:t}){return(0,$.jsx)(b,{alignItems:`flex-start`,alignSelf:`flex-start`,flexWrap:`nowrap`,justifyContent:`flex-start`,children:e===`bash`?(0,$.jsx)(T,{color:`bashBorder`,dimColor:t,children:`!\xA0`}):(0,$.jsx)(_D,{isLoading:t})})}B(),q(),Un(),jr(),Vd(),Xd(),Hc();var yD=new Set;function bD(e){try{return Yd(e)?.type===`idle_notification`}catch{return!1}}var xD=3;function SD(e){return`<${Qf}>
|
|
72
72
|
<${tp}>+${e} more tasks completed</${tp}>
|
|
73
73
|
<${$f}>completed</${$f}>
|
|
74
74
|
</${Qf}>`}function CD(e){let t=e.filter(e=>typeof e.value!=`string`||!bD(e.value)),n=t.filter(e=>e.mode===`task-notification`),r=t.filter(e=>e.mode!==`task-notification`);if(n.length<=xD)return[...r,...n];let i=n.slice(0,xD-1),a={value:SD(n.length-(xD-1)),mode:`task-notification`};return[...r,...i,a]}function wD(){let e=mC(),t=J(e=>!!e.viewingAgentTaskId),n=J(e=>e.isBriefOnly),r=(0,Q.useMemo)(()=>{if(e.length===0)return null;let t=e.filter(ko);return t.length===0?null:du(CD(t).map(e=>{let t=e.value;return e.mode===`bash`&&typeof t==`string`&&(t=`<bash-input>${t}</bash-input>`),xa({content:t})}))},[e]);return t||r===null?null:(0,$.jsx)(b,{marginTop:1,flexDirection:`column`,children:r.map((e,t)=>(0,$.jsx)(ho,{isFirst:t===0,useBriefLayout:n,children:(0,$.jsx)(Qc,{message:e,lookups:Ji,addMargin:!1,tools:[],commands:[],verbose:!1,inProgressToolUseIDs:yD,progressMessagesForMessage:[],shouldAnimate:!1,shouldShowDot:!1,isTranscriptMode:!1,isStatic:!0})},t))})}var TD=Q.memo(wD);Ra(),u(),B();function ED({hasStash:e}){return e?(0,$.jsx)(b,{paddingLeft:2,children:(0,$.jsxs)(T,{dimColor:!0,children:[d.pointerSmall,` Stashed (auto-restores after submit)`]})}):null}Ft();var DD=1e4,OD=1e3;function kD(e,t){if(e.length<=DD)return{truncatedText:e,placeholderContent:``};let n=Math.floor(OD/2),r=e.slice(0,n),i=e.slice(-500),a=e.slice(n,-500);return{truncatedText:r+AD(t,tl(a))+i,placeholderContent:a}}function AD(e,t){return`[...Truncated text #${e} +${t} lines...]`}function jD(e,t){let n=Object.keys(t).map(Number),r=n.length>0?Math.max(...n)+1:1,{truncatedText:i,placeholderContent:a}=kD(e,r);return a?{newInput:i,newPastedContents:{...t,[r]:{id:r,type:`text`,content:a}}}:{newInput:e,newPastedContents:t}}function MD({input:e,pastedContents:t,onInputChange:n,setCursorOffset:r,setPastedContents:i}){let[a,o]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{if(a||e.length<=1e4)return;let{newInput:s,newPastedContents:c}=jD(e,t);n(s),r(s.length),i(c),o(!0)},[e,a,t,n,i,r]),(0,Q.useEffect)(()=>{e===``&&o(!1)},[e])}q(),Vf(),jr();var ND=(bh(),e(lh)),PD=3;function FD({input:e,submitCount:t}){let n=mC(),r=J(e=>e.promptSuggestionEnabled);return(0,Q.useMemo)(()=>{if(e===``){if(n.some(Fo)&&(Bf().queuedCommandUpHintCount||0)<PD)return`Press up to edit queued messages`;if(t<1&&r&&!ND?.isProactiveActive())return yv()}},[e,n,t,r])}var ID=5e3,LD=!1;function RD(e){let[t,n]=(0,Q.useState)(!1);return(0,Q.useEffect)(()=>{if(LD||!e)return;LD=!0,n(!0);let t=setTimeout(n,ID,!1);return()=>{clearTimeout(t),n(!1)}},[e]),t}R(),Ll(),Cp(),q(),qd(),jr(),x(),Zi(),Gr(),av(),Ft(),e_(),wa(),B(),zn(),mu(),zh(),ql(),Df(),wl(),Vf(),of(),Ef(),ef(),Os(),No(),ap(),lm(),dp(),Zg(),er(),Ju(),fv(),ga(),U_();var zD=5,BD=3;function VD({debug:e,ideSelection:t,toolPermissionContext:n,setToolPermissionContext:r,apiKeyStatus:i,commands:a,agents:o,isLoading:s,verbose:c,messages:l,onAutoUpdaterResult:u,autoUpdaterResult:d,input:f,onInputChange:p,mode:m,onModeChange:h,stashedPrompt:g,setStashedPrompt:_,submitCount:y,onShowMessageSelector:x,onMessageActionsEnter:S,mcpClients:C,pastedContents:w,setPastedContents:E,vimMode:D,setVimMode:O,showBashesDialog:k,setShowBashesDialog:A,onExit:M,getToolUseContext:N,onSubmit:ee,isSearchingHistory:F,setIsSearchingHistory:I,onDismissSideQuestion:te,isSideQuestionVisible:ne,helpOpen:L,setHelpOpen:R,hasSuppressedDialogs:re,isLocalJSXCommandActive:z=!1,insertTextRef:ae}){let se=$g(),ce=ca()||z,[le,ue]=(0,Q.useState)(!1),[fe,B]=(0,Q.useState)({show:!1}),[V,H]=(0,Q.useState)(f.length),me=Q.useRef(f);f!==me.current&&(H(f.length),me.current=f);let he=Q.useCallback(e=>{me.current=e,p(e)},[p]);ae&&(ae.current={cursorOffset:V,insert:e=>{let t=V===f.length&&f.length>0&&!/\s$/.test(f)?` `+e:e,n=f.slice(0,V)+t+f.slice(V);me.current=n,p(n),H(V+t.length)},setInputWithCursor:(e,t)=>{me.current=e,p(e),H(t)}});let ge=js(),U=Qs(),_e=J(e=>e.tasks),ve=J(e=>e.replBridgeConnected),ye=J(e=>e.replBridgeExplicit),be=J(e=>e.replBridgeReconnecting),xe=ve&&(ye||be),Se=J(e=>process.env.USER_TYPE===`ant`&&e.tungstenActiveSession!==void 0),Ce=process.env.USER_TYPE===`ant`&&Se,we=J(e=>!1),Te=mC(),Ee=J(e=>e.promptSuggestion),De=J(e=>e.speculation),Oe=J(e=>e.speculationSessionTimeSavedMs),ke=J(e=>e.isBriefOnly),Ae=J(e=>e.mainLoopModel),je=J(e=>e.mainLoopModelForSession),Me=J(e=>e.thinkingEnabled),Ne=J(e=>bm()?e.fastMode:!1),Pe=J(e=>e.effortValue),Fe=J(e=>e.viewingAgentTaskId);J(e=>e.viewSelectionMode);let{historyQuery:Ie,setHistoryQuery:Le,historyMatch:Re,historyFailedMatch:ze}=LC(e=>{E(e.pastedContents),sn(e.display)},f,he,H,V,h,m,F,I,E,w),Be=(0,Q.useRef)(-1);Be.current===-1&&(Be.current=HD(l));let Ve=(0,Q.useRef)(!1),[He,Ue]=(0,Q.useState)(!1),We=J(e=>e.selectedBgAgentIndex),Ge=(0,Q.useCallback)(e=>U(t=>{let n=typeof e==`function`?e(t.selectedBgAgentIndex):e;return n===t.selectedBgAgentIndex?t:{...t,selectedBgAgentIndex:n}}),[U]),[Ke,qe]=(0,Q.useState)(!1),[Je,Ye]=(0,Q.useState)(!1),[Xe,Ze]=(0,Q.useState)(!1),[Qe,$e]=(0,Q.useState)(!1),[et,tt]=(0,Q.useState)(!1),[nt,rt]=(0,Q.useState)(!1),[it,at]=(0,Q.useState)(!1),[ot,st]=(0,Q.useState)(!1),ct=(0,Q.useMemo)(()=>{let e=f.indexOf(`
|
|
@@ -81,7 +81,7 @@ Parse the user's input into ISO 8601 format. Return ONLY the formatted string, o
|
|
|
81
81
|
Server disconnected.
|
|
82
82
|
`):process.stderr.write(`\nFailed to connect to server at ${e.wsUrl}\n`),c.current=!1,gn(1),n(!1)},onError:e=>{Y(`[useDirectConnect] Error: ${e.message}`)}});return o.current=i,i.connect(),()=>{Y(`[useDirectConnect] Cleanup - disconnecting`),i.disconnect(),o.current=null}},[e,t,n,r]);let u=(0,Q.useCallback)(async e=>{let t=o.current;return t?(n(!0),t.sendMessage(e)):!1},[n]),d=(0,Q.useCallback)(()=>{o.current?.sendInterrupt(),n(!1)},[n]),f=(0,Q.useCallback)(()=>{o.current?.disconnect(),o.current=null,c.current=!1},[]);return(0,Q.useMemo)(()=>({isRemoteMode:a,sendMessage:u,cancelRequest:d,disconnect:f}),[a,u,d,f])}zm(),of(),Si();function cO({session:e,setMessages:t,setIsLoading:n,setToolUseConfirmQueue:r,tools:i}){let a=!!e,o=(0,Q.useRef)(null),s=(0,Q.useRef)(!1),c=(0,Q.useRef)(!1),l=(0,Q.useRef)(i);(0,Q.useEffect)(()=>{l.current=i},[i]),(0,Q.useEffect)(()=>{if(!e)return;s.current=!1,Y(`[useSSHSession] wiring SSH session manager`);let i=e.createManager({onMessage:e=>{if(tO(e)&&n(!1),e.type===`system`&&e.subtype===`init`){if(s.current)return;s.current=!0}let r=eO(e,{convertToolResults:!0});r.type===`message`&&t(e=>[...e,r.message])},onPermissionRequest:(e,t)=>{Y(`[useSSHSession] permission request: ${e.tool_name}`);let a=$m(l.current,e.tool_name)??KD(e.tool_name),o=GD(e,t),s={behavior:`ask`,message:e.description??`${e.tool_name} requires permission`,suggestions:e.permission_suggestions,blockedPath:e.blocked_path},c={assistantMessage:o,tool:a,description:e.description??`${e.tool_name} requires permission`,input:e.input,toolUseContext:{},toolUseID:e.tool_use_id,permissionResult:s,permissionPromptStartTimeMs:Date.now(),onUserInteraction(){},onAbort(){i.respondToPermissionRequest(t,{behavior:`deny`,message:`User aborted`}),r(t=>t.filter(t=>t.toolUseID!==e.tool_use_id))},onAllow(a){i.respondToPermissionRequest(t,{behavior:`allow`,updatedInput:a}),r(t=>t.filter(t=>t.toolUseID!==e.tool_use_id)),n(!0)},onReject(n){i.respondToPermissionRequest(t,{behavior:`deny`,message:n??`User denied permission`}),r(t=>t.filter(t=>t.toolUseID!==e.tool_use_id))},async recheckPermission(){}};r(e=>[...e,c]),n(!1)},onConnected:()=>{Y(`[useSSHSession] connected`),c.current=!0},onReconnecting:(e,r)=>{Y(`[useSSHSession] ssh dropped, reconnecting (${e}/${r})`),c.current=!1,n(!1);let i={type:`system`,subtype:`informational`,content:`SSH connection dropped — reconnecting (attempt ${e}/${r})...`,timestamp:new Date().toISOString(),uuid:Bv(),level:`warning`};t(e=>[...e,i])},onDisconnected:()=>{Y(`[useSSHSession] ssh process exited (giving up)`);let t=e.getStderrTail().trim(),r=c.current,i=e.proc.exitCode;c.current=!1,n(!1);let a=r?`Remote session ended.`:`SSH session failed before connecting.`;t&&(!r||i!==0)&&(a+=`\nRemote stderr (exit ${i??`signal `+e.proc.signalCode}):\n${t}`),gn(1,`other`,{finalMessage:a})},onError:e=>{Y(`[useSSHSession] error: ${e.message}`)}});return o.current=i,i.connect(),()=>{Y(`[useSSHSession] cleanup`),i.disconnect(),e.proxy.stop(),o.current=null}},[e,t,n,r]);let u=(0,Q.useCallback)(async e=>{let t=o.current;return t?(n(!0),t.sendMessage(e)):!1},[n]),d=(0,Q.useCallback)(()=>{o.current?.sendInterrupt(),n(!1)},[n]),f=(0,Q.useCallback)(()=>{o.current?.disconnect(),o.current=null,c.current=!1},[]);return(0,Q.useMemo)(()=>({isRemoteMode:a,sendMessage:u,cancelRequest:d,disconnect:f}),[a,u,d,f])}of(),Fh();async function lO(e){let{accessToken:t,orgUUID:n}=await Ph();return{baseUrl:`${Ip().BASE_API_URL}/v1/sessions/${e}/events`,headers:{...Mh(t),"anthropic-beta":`ccr-byoc-2025-07-29`,"x-organization-uuid":n}}}async function uO(e,t,n){let r=await f.get(e.baseUrl,{headers:e.headers,params:t,timeout:15e3,validateStatus:()=>!0}).catch(()=>null);return!r||r.status!==200?(Y(`[${n}] HTTP ${r?.status??`error`}`),null):{events:Array.isArray(r.data.data)?r.data.data:[],firstId:r.data.first_id,hasMore:r.data.has_more}}async function dO(e,t=100){return uO(e,{limit:t,anchor_to_latest:!0},`fetchLatestEvents`)}async function fO(e,t,n=100){return uO(e,{limit:n,before_id:t},`fetchOlderEvents`)}of();var pO=40,mO=10,hO=`loading older messages…`,gO=`failed to load older messages — scroll up to retry`,_O=`start of session`;function vO(e){let t=[];for(let n of e.events){let e=eO(n,{convertUserTextMessages:!0,convertToolResults:!0});e.type===`message`&&t.push(e.message)}return t}function yO({config:e,setMessages:t,scrollRef:n,onPrepend:r}){let i=e?.viewerOnly===!0,a=(0,Q.useRef)(void 0),o=(0,Q.useRef)(null),s=(0,Q.useRef)(!1),c=(0,Q.useRef)(null),l=(0,Q.useRef)(0),u=(0,Q.useRef)(Bv());function d(e){return{type:`system`,subtype:`informational`,content:e,isMeta:!1,timestamp:new Date().toISOString(),uuid:u.current,level:`info`}}let f=(0,Q.useCallback)((e,r)=>{let i=vO(e);if(a.current=e.hasMore?e.firstId:null,!r){let e=n.current;c.current=e?{beforeHeight:e.getFreshScrollHeight(),count:i.length}:null}let o=e.hasMore?null:d(_O);t(e=>{let t=e[0]?.uuid===u.current?e.slice(1):e;return o?[o,...i,...t]:[...i,...t]}),Y(`[useAssistantHistory] ${r?`initial`:`older`} page: ${i.length} msgs (raw ${e.events.length}), hasMore=${e.hasMore}`)},[t]);(0,Q.useEffect)(()=>{if(!i||!e)return;let t=!1;return(async()=>{let n=await lO(e.sessionId).catch(()=>null);if(!n||t)return;o.current=n;let r=await dO(n);t||!r||(l.current=mO,f(r,!0))})(),()=>{t=!0}},[i]);let p=(0,Q.useCallback)(async()=>{if(!i||s.current)return;let e=a.current,n=o.current;if(!(!e||!n)){s.current=!0,t(e=>{let t=e[0]?.uuid===u.current?e.slice(1):e;return[d(hO),...t]});try{let r=await fO(n,e);if(!r){t(e=>{let t=e[0]?.uuid===u.current?e.slice(1):e;return[d(gO),...t]});return}f(r,!1)}finally{s.current=!1}}},[i,f,t]);return(0,Q.useLayoutEffect)(()=>{let e=c.current;if(e===null)return;c.current=null;let t=n.current;if(!t||t.isSticky())return;let i=t.getFreshScrollHeight()-e.beforeHeight;i>0&&t.scrollBy(i),r?.(e.count,i)}),(0,Q.useEffect)(()=>{if(l.current<=0||!a.current||s.current)return;let e=n.current;if(!e)return;let t=e.getFreshScrollHeight(),r=e.getViewportHeight();Y(`[useAssistantHistory] fill-check: content=${t} viewport=${r} budget=${l.current}`),t<=r?(l.current--,p()):l.current=0}),{maybeLoadOlder:(0,Q.useCallback)(e=>{e.getScrollTop()<pO&&p()},[p])}}Up();var bO=400;function xO({inputValue:e,setInputValue:t,isValidDigit:n,onDigit:r,enabled:i=!0,once:a=!1,debounceMs:o=bO}){let s=(0,Q.useRef)(e),c=(0,Q.useRef)(!1),l=(0,Q.useRef)(null),u=(0,Q.useRef)({setInputValue:t,isValidDigit:n,onDigit:r});u.current={setInputValue:t,isValidDigit:n,onDigit:r},(0,Q.useEffect)(()=>{if(!(!i||a&&c.current)){if(l.current!==null&&(clearTimeout(l.current),l.current=null),e!==s.current){let t=Gp(e.slice(-1));if(u.current.isValidDigit(t)){let n=e.slice(0,-1);l.current=setTimeout((e,t,n,r,i)=>{e.current=null,t.current=!0,n.current.setInputValue(r),n.current.onDigit(i)},o,l,c,u,n,t)}}return()=>{l.current!==null&&(clearTimeout(l.current),l.current=null)}}},[e,i,a,o])}B();var SO=[`0`,`1`,`2`,`3`],CO={0:`dismissed`,1:`bad`,2:`fine`,3:`good`},wO=e=>SO.includes(e),TO=`How is Claude doing this session? (optional)`;function EO({onSelect:e,inputValue:t,setInputValue:n,message:r=TO}){return xO({inputValue:t,setInputValue:n,isValidDigit:wO,onDigit:t=>e(CO[t])}),(0,$.jsxs)(b,{flexDirection:`column`,marginTop:1,children:[(0,$.jsxs)(b,{children:[(0,$.jsx)(T,{color:`ansi:cyan`,children:`● `}),(0,$.jsx)(T,{bold:!0,children:r})]}),(0,$.jsxs)(b,{marginLeft:2,children:[(0,$.jsx)(b,{width:10,children:(0,$.jsxs)(T,{children:[(0,$.jsx)(T,{color:`ansi:cyan`,children:`1`}),`: Bad`]})}),(0,$.jsx)(b,{width:10,children:(0,$.jsxs)(T,{children:[(0,$.jsx)(T,{color:`ansi:cyan`,children:`2`}),`: Fine`]})}),(0,$.jsx)(b,{width:10,children:(0,$.jsxs)(T,{children:[(0,$.jsx)(T,{color:`ansi:cyan`,children:`3`}),`: Good`]})}),(0,$.jsx)(b,{children:(0,$.jsxs)(T,{children:[(0,$.jsx)(T,{color:`ansi:cyan`,children:`0`}),`: Dismiss`]})})]})]})}vf(),B(),Up();function DO({isOpen:e,skillName:t,updates:n,handleSelect:r,inputValue:i,setInputValue:a}){return!e||i&&!wO(i)?null:(0,$.jsx)(AO,{skillName:t,updates:n,onSelect:r,inputValue:i,setInputValue:a})}var OO=[`0`,`1`];function kO(e){return OO.includes(e)}function AO({skillName:e,updates:t,onSelect:n,inputValue:r,setInputValue:i}){let a=(0,Q.useRef)(r);return(0,Q.useEffect)(()=>{if(r!==a.current){let e=Gp(r.slice(-1));kO(e)&&(i(r.slice(0,-1)),n(e===`1`?`good`:`dismissed`))}},[r,n,i]),(0,$.jsxs)(b,{flexDirection:`column`,marginTop:1,children:[(0,$.jsxs)(b,{children:[(0,$.jsxs)(T,{color:`ansi:cyan`,children:[Sf,` `]}),(0,$.jsxs)(T,{bold:!0,children:[`Skill improvement suggested for "`,e,`"`]})]}),(0,$.jsx)(b,{flexDirection:`column`,marginLeft:2,children:t.map((e,t)=>(0,$.jsxs)(T,{dimColor:!0,children:[`∙`,` `,e.change]},t))}),(0,$.jsxs)(b,{marginLeft:2,marginTop:1,children:[(0,$.jsx)(b,{width:12,children:(0,$.jsxs)(T,{children:[(0,$.jsx)(T,{color:`ansi:cyan`,children:`1`}),`: Apply`]})}),(0,$.jsx)(b,{width:14,children:(0,$.jsxs)(T,{children:[(0,$.jsx)(T,{color:`ansi:cyan`,children:`0`}),`: Dismiss`]})})]})]})}Cp(),q(),Vd();function jO(e){let t=J(e=>e.skillImprovement.suggestion),n=Qs(),[r,i]=(0,Q.useState)(!1),a=(0,Q.useRef)(t),o=(0,Q.useRef)(!1);t&&(a.current=t),t&&!r&&(i(!0),o.current||(o.current=!0,Z(`tengu_skill_improvement_survey`,{event_type:`appeared`,_PROTO_skill_name:t.skillName??`unknown`})));let s=(0,Q.useCallback)(t=>{let r=a.current;if(!r)return;let s=t!==`dismissed`;Z(`tengu_skill_improvement_survey`,{event_type:`responded`,response:s?`applied`:`dismissed`,_PROTO_skill_name:r.skillName}),s&&wv(r.skillName,r.updates).then(()=>{e(e=>[...e,Ed(`Skill "${r.skillName}" updated with improvements.`,`suggestion`)])}),i(!1),o.current=!1,n(e=>e.skillImprovement.suggestion?{...e,skillImprovement:{suggestion:null}}:e)},[n,e]);return{isOpen:r,suggestion:a.current,handleSelect:s}}function MO(e){return{onBeforeQuery:async()=>!0,onTurnComplete:async()=>{},render:()=>null}}Gn(),Va(),rd(),Ul();function NO(e){(0,Q.useEffect)(()=>{let t=()=>{jm()&&process.stdout.write(`
|
|
83
83
|
`+Pc()+`
|
|
84
|
-
`),Ts(e?.())};return process.on(`exit`,t),()=>{process.off(`exit`,t)}},[])}s();function PO(){(0,Q.useEffect)(()=>{process.env.USER_TYPE===`ant`&&a(process.env.CLAUDE_CODE_EXIT_AFTER_FIRST_RENDER)&&(process.stderr.write(`\nStartup time: ${Math.round(process.uptime()*1e3)}ms\n`),process.exit(0))},[])}function FO(e,t){let n=(0,Q.useRef)(e??null),r=(0,Q.useRef)(!e);return(0,Q.useEffect)(()=>{let e=n.current;if(!e)return;let i=!1;return e.then(e=>{i||(r.current=!0,n.current=null,e.length>0&&t(t=>[...e,...t]))}),()=>{i=!0}},[t]),(0,Q.useCallback)(async()=>{if(r.current||!n.current)return;let e=await n.current;r.current||(r.current=!0,n.current=null,e.length>0&&t(t=>[...e,...t]))},[t])}rt(),qs(),am();function IO(){let[e,t]=(0,Q.useState)(()=>{if(!rm()||$p())return`valid`;let{key:e,source:t}=qp({skipRetrievingKeyFromApiKeyHelper:!0});return e||t===`apiKeyHelper`?`loading`:`missing`}),[n,r]=(0,Q.useState)(null);return{status:e,reverify:(0,Q.useCallback)(async()=>{if(!rm()||$p()){t(`valid`);return}await Im(vt());let{key:e,source:n}=qp();if(!e){if(n===`apiKeyHelper`){t(`error`),r(Error(`API key helper did not return a valid key`));return}t(`missing`);return}try{let n=await Fc(e,!1)?`valid`:`invalid`;t(n);return}catch(e){r(e),t(`error`);return}},[]),error:n}}rt(),B(),qd(),of(),B(),zh(),Cp(),q();function LO({screen:t,setScreen:n,showAllInTranscript:r,setShowAllInTranscript:i,messageCount:a,onEnterTranscript:o,onExitTranscript:s,virtualScrollActive:c,searchBarOpen:l=!1}){let u=J(e=>e.expandedView),d=Qs(),f=(0,Q.useCallback)(()=>{Z(`tengu_toggle_todos`,{is_expanded:u===`tasks`}),d(e=>({...e,expandedView:e.expandedView===`tasks`?`none`:`tasks`}))},[u,d]),p=J(e=>e.isBriefOnly),m=(0,Q.useCallback)(()=>{{let{isBriefEnabled:n}=(ss(),e(Ac));if(!n()&&p&&t!==`transcript`){d(e=>e.isBriefOnly?{...e,isBriefOnly:!1}:e);return}}let c=t!==`transcript`;Z(`tengu_toggle_transcript`,{is_entering:c,show_all:r,message_count:a}),n(e=>e===`transcript`?`prompt`:`transcript`),i(!1),c&&o&&o(),!c&&s&&s()},[t,n,p,r,i,a,d,o,s]),h=(0,Q.useCallback)(()=>{Z(`tengu_transcript_toggle_show_all`,{is_expanding:!r,message_count:a}),i(e=>!e)},[r,i,a]),g=(0,Q.useCallback)(()=>{Z(`tengu_transcript_exit`,{show_all:r,message_count:a}),n(`prompt`),i(!1),s&&s()},[n,r,i,a,s]),_=(0,Q.useCallback)(()=>{{let{isBriefEnabled:t}=(ss(),e(Ac));if(!t()&&!p)return;let n=!p;Z(`tengu_brief_mode_toggled`,{enabled:n,gated:!1,source:`keybinding`}),d(e=>e.isBriefOnly===n?e:{...e,isBriefOnly:n})}},[p,d]);j(`app:toggleTodos`,f,{context:`Global`}),j(`app:toggleTranscript`,m,{context:`Global`}),j(`app:toggleBrief`,_,{context:`Global`,isActive:!0}),j(`app:toggleTerminal`,(0,Q.useCallback)(()=>{},[]),{context:`Global`}),j(`app:redraw`,(0,Q.useCallback)(()=>{D.get(process.stdout)?.forceRedraw()},[]),{context:`Global`});let v=t===`transcript`;return j(`transcript:toggleShowAll`,h,{context:`Transcript`,isActive:v&&!c}),j(`transcript:exit`,g,{context:`Transcript`,isActive:v&&!l}),null}Gr(),zn(),zh();var RO={setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}};function zO({onSubmit:e,isActive:t=!0}){let n=P(),r=ca(),i=(0,Q.useMemo)(()=>{if(!n)return new Set;let e=new Set;for(let t of n.bindings)t.action?.startsWith(`command:`)&&e.add(t.action);return e},[n]);return v((0,Q.useMemo)(()=>{let t={};for(let n of i){let r=n.slice(8);t[n]=()=>{e(`/${r}`,RO,void 0,{fromKeybinding:!0})}}return t},[i,e]),{context:`Chat`,isActive:t&&!r}),null}Cp(),q(),U_(),Ll(),Gr(),mu(),zh(),Nt(),jr();var BO=3e3;function VO(e){let{setToolUseConfirmQueue:t,onCancel:n,onAgentsKilled:r,isMessageSelectorVisible:i,screen:a,abortSignal:o,popCommandFromQueue:s,vimMode:c,isLocalJSXCommand:l,isSearchingHistory:u,isHelpOpen:d,inputMode:f,inputValue:p,streamMode:m}=e,h=js(),g=Qs(),_=mC().length,{addNotification:v,removeNotification:y}=Au(),b=(0,Q.useRef)(0),x=(0,Q.useCallback)(()=>{let e={source:`escape`,streamMode:m};if(o!==void 0&&!o.aborted){Z(`tengu_cancel`,e),t(()=>[]),n();return}if(pu()&&s){s();return}Z(`tengu_cancel`,e),t(()=>[]),n()},[o,s,t,n,m]),S=Pd(),C=o!==void 0&&!o.aborted,w=_>0,T=f!==void 0&&f!==`prompt`&&!p,E=a!==`transcript`&&!u&&!i&&!l&&!d&&!S&&!(B_()&&c===`INSERT`),D=E&&(C||w)&&!T,O=E&&(C||w);j(`chat:cancel`,x,{context:`Chat`,isActive:D});let k=(0,Q.useCallback)(()=>{let e=h.getState().tasks,t=Object.entries(e).filter(([,e])=>e.type===`local_agent`&&e.status===`running`);if(t.length===0)return!1;yi(e,g);let n=[];for(let[e,r]of t)Wi(e,g),n.push(r.description),gh(e,`stopped`,{toolUseId:r.toolUseId,summary:r.description});return sr({value:n.length===1?`Background agent "${n[0]}" was stopped by the user.`:`${n.length} background agents were stopped by the user: ${n.map(e=>`"${e}"`).join(`, `)}.`,mode:`task-notification`}),r(),!0},[h,g,r]);return j(`app:interrupt`,(0,Q.useCallback)(()=>{(C||w)&&x()},[C,w,x]),{context:`Global`,isActive:O}),j(`chat:killAgents`,(0,Q.useCallback)(()=>{let e=h.getState().tasks;if(!Object.values(e).some(e=>e.type===`local_agent`&&e.status===`running`)){v({key:`kill-agents-none`,text:`No background agents running`,priority:`immediate`,timeoutMs:2e3});return}let t=Date.now();if(t-b.current<=BO){b.current=0,y(`kill-agents-confirm`),Z(`tengu_cancel`,{source:`kill_agents`}),ha(),k();return}b.current=t;let n=Hr(`chat:killAgents`,`Chat`,`ctrl+x ctrl+k`);v({key:`kill-agents-confirm`,text:`Press ${n} again to stop background agents`,priority:`immediate`,timeoutMs:BO})},[h,v,y,k]),{context:`Chat`}),null}B(),q(),Dl();function HO(e){let t=J(e=>e.tasks),n=J(e=>e.pipeIpc),r=Object.values(t).some(vu),i=t=>{if(t.shift&&(t.key===`up`||t.key===`down`)){t.preventDefault(),r?e?.onOpenBackgroundTasks?.():t.key===`down`&&n?.statusVisible&&e?.onTogglePipeSelector&&e.onTogglePipeSelector();return}};return oe((e,t,n)=>{i(new A(n.keypress))}),{handleKeyDown:i}}q_(),ap();async function UO(e){let{ctx:t,updatedInput:n,suggestions:r,permissionMode:i}=e;try{let e=await t.runHooks(i,r,n);if(e)return e}catch(e){e instanceof Error?X(e):X(Error(`Automated permission check failed: ${String(e)}`))}return null}var WO=new Map,GO=null;function KO(){return GO??null}function qO(e,t){let n=KO();if(!n)return null;let r=Bv(),i={requestId:r,toolName:e.tool.name,toolUseID:e.toolUseID,description:e.description,input:e.input,permissionResult:e.permissionResult,permissionPromptStartTimeMs:e.permissionPromptStartTimeMs};return WO.set(r,{onResponse:t}),n({type:`permission_request`,data:JSON.stringify(i)}),r}function JO(e){e&&WO.delete(e)}function YO(e,t){if(!e)return;let n=KO();n&&n({type:`permission_cancel`,data:JSON.stringify({requestId:e,reason:t})})}Cp(),eh(),fc(),of(),Td(),Vd(),Lt(),bt();function XO(e){let t=!1,n=!1;return{resolve(r){n||(n=!0,t=!0,e(r))},isResolved(){return t},claim(){return t?!1:(t=!0,!0)}}}function ZO(e,t,n,r,i,a,o){let s=r.message.id;return Object.freeze({tool:e,input:t,toolUseContext:n,assistantMessage:r,messageId:s,toolUseID:i,logDecision(r,a){Ys({tool:e,input:a?.input??t,toolUseContext:n,messageId:s,toolUseID:i},r,a?.permissionPromptStartTimeMs)},logCancelled(){Z(`tengu_tool_use_cancelled`,{messageID:s,toolName:th(e.name)})},async persistPermissions(e){return e.length===0?!1:(Xn(e),a(Ur(n.getAppState().toolPermissionContext,e)),e.some(e=>Ma(e.destination)))},resolveIfAborted(e){return n.abortController.signal.aborted?(this.logCancelled(),e(this.cancelAndAbort(void 0,!0)),!0):!1},cancelAndAbort(t,r,i){let a=!!n.agentId,o=t?`${a?cs:Cu}${t}`:a?Nc:Al,s=a?o:Ks(o);return(r||!t&&!i?.length&&!a)&&(Y(`Aborting: tool=${e.name} isAbort=${r} hasFeedback=${!!t} isSubagent=${a}`),n.abortController.abort()),{behavior:`ask`,message:s,contentBlocks:i}},async runHooks(r,a,o,s){for await(let c of Wn(e.name,i,t,n,r,a,n.abortController.signal))if(c.permissionRequestResult){let r=c.permissionRequestResult;if(r.behavior===`allow`){let e=r.updatedInput??o??t;return await this.handleHookAllow(e,r.updatedPermissions??[],s)}else if(r.behavior===`deny`)return this.logDecision({decision:`reject`,source:{type:`hook`}},{permissionPromptStartTimeMs:s}),r.interrupt&&(Y(`Hook interrupt: tool=${e.name} hookMessage=${r.message}`),n.abortController.abort()),this.buildDeny(r.message||`Permission denied by hook`,{type:`hook`,hookName:`PermissionRequest`,reason:r.message})}return null},buildAllow(e,t){return{behavior:`allow`,updatedInput:e,userModified:t?.userModified??!1,...t?.decisionReason&&{decisionReason:t.decisionReason},...t?.acceptFeedback&&{acceptFeedback:t.acceptFeedback},...t?.contentBlocks&&t.contentBlocks.length>0&&{contentBlocks:t.contentBlocks}}},buildDeny(e,t){return{behavior:`deny`,message:e,decisionReason:t}},async handleUserAllow(n,r,i,a,o,s){let c=await this.persistPermissions(r);this.logDecision({decision:`accept`,source:{type:`user`,permanent:c}},{input:n,permissionPromptStartTimeMs:a});let l=e.inputsEquivalent?!e.inputsEquivalent(t,n):!1,u=i?.trim();return this.buildAllow(n,{userModified:l,decisionReason:s,acceptFeedback:u||void 0,contentBlocks:o})},async handleHookAllow(e,t,n){let r=await this.persistPermissions(t);return this.logDecision({decision:`accept`,source:{type:`hook`,permanent:r}},{input:e,permissionPromptStartTimeMs:n}),this.buildAllow(e,{decisionReason:{type:`hook`,hookName:`PermissionRequest`}})},pushToQueue(e){o?.push(e)},removeFromQueue(){o?.remove(i)},updateQueueItem(e){o?.update(i,e)}})}function QO(e){return{push(t){e(e=>[...e,t])},remove(t){e(e=>e.filter(e=>e.toolUseID!==t))},update(t,n){e(e=>e.map(e=>e.toolUseID===t?{...e,...n}:e))}}}of(),B(),fc(),Et(),ef();function $O(e,t){let{ctx:n,description:r,result:i,awaitAutomatedChecksBeforeDialog:a,bridgeCallbacks:o}=e,{resolve:s,isResolved:c,claim:l}=XO(t),u,d,f=o?Bv():void 0,p=Date.now(),m=i.updatedInput??n.input,h=null;function g(e){YO(h,e),JO(h),h=null}function _(){JO(h),h=null}let v={assistantMessage:n.assistantMessage,tool:n.tool,description:r,input:m,toolUseContext:n.toolUseContext,toolUseID:n.toolUseID,permissionResult:i,permissionPromptStartTimeMs:p,onUserInteraction(){Date.now()-p<200||Qi(n.toolUseID)},onDismissCheckmark(){u&&(clearTimeout(u),u=void 0,d&&(n.toolUseContext.abortController.signal.removeEventListener(`abort`,d),d=void 0),n.removeFromQueue())},onAbort(){l()&&(g(`Permission request was aborted locally in sub.`),o&&f&&(o.sendResponse(f,{behavior:`deny`,message:`User aborted`}),o.cancelRequest(f)),n.logCancelled(),n.logDecision({decision:`reject`,source:{type:`user_abort`}},{permissionPromptStartTimeMs:p}),s(n.cancelAndAbort(void 0,!0)))},async onAllow(e,t,r,a){l()&&(g(`Permission request was approved locally in sub.`),o&&f&&(o.sendResponse(f,{behavior:`allow`,updatedInput:e,updatedPermissions:t}),o.cancelRequest(f)),s(await n.handleUserAllow(e,t,r,p,a,i.decisionReason)))},onReject(e,t){l()&&(g(`Permission request was rejected locally in sub.`),o&&f&&(o.sendResponse(f,{behavior:`deny`,message:e??`User denied permission`}),o.cancelRequest(f)),n.logDecision({decision:`reject`,source:{type:`user_reject`,hasFeedback:!!e}},{permissionPromptStartTimeMs:p}),s(n.cancelAndAbort(e,void 0,t)))},async recheckPermission(){if(c())return;let e=await so(n.tool,n.input,n.toolUseContext,n.assistantMessage,n.toolUseID);if(e.behavior===`allow`){if(!l())return;g(`Permission request was resolved locally in sub.`),o&&f&&o.cancelRequest(f),n.removeFromQueue(),n.logDecision({decision:`accept`,source:`config`}),s(n.buildAllow(e.updatedInput??n.input))}}};if(n.pushToQueue(v),h=qO(v,e=>{l()&&(_(),Qi(n.toolUseID),n.removeFromQueue(),o&&f&&o.cancelRequest(f),e.behavior===`allow`?(async()=>{e.permissionUpdates?.length&&n.persistPermissions(e.permissionUpdates),n.logDecision({decision:`accept`,source:{type:`user`,permanent:!!e.permissionUpdates?.length}},{permissionPromptStartTimeMs:p}),s(n.buildAllow(e.updatedInput??m,{acceptFeedback:e.feedback,contentBlocks:e.contentBlocks}))})():(n.logDecision({decision:`reject`,source:{type:`user_reject`,hasFeedback:!!e.feedback}},{permissionPromptStartTimeMs:p}),s(n.cancelAndAbort(e.feedback,void 0,e.contentBlocks))))}),o&&f){o.sendRequest(f,n.tool.name,m,n.toolUseID,r,i.suggestions,i.blockedPath);let e=n.toolUseContext.abortController.signal,t=o.onResponse(f,r=>{l()&&(g(`Permission request was resolved by bridge before pipe response.`),e.removeEventListener(`abort`,t),Qi(n.toolUseID),n.removeFromQueue(),r.behavior===`allow`?(r.updatedPermissions?.length&&n.persistPermissions(r.updatedPermissions),n.logDecision({decision:`accept`,source:{type:`user`,permanent:!!r.updatedPermissions?.length}},{permissionPromptStartTimeMs:p}),s(n.buildAllow(r.updatedInput??m))):(n.logDecision({decision:`reject`,source:{type:`user_reject`,hasFeedback:!!r.message}},{permissionPromptStartTimeMs:p}),s(n.cancelAndAbort(r.message))))});e.addEventListener(`abort`,t,{once:!0})}a||(async()=>{if(c())return;let e=n.toolUseContext.getAppState(),t=await n.runHooks(e.toolPermissionContext.mode,i.suggestions,i.updatedInput,p);!t||!l()||(g(`Permission request was resolved by hook before pipe response.`),o&&f&&o.cancelRequest(f),n.removeFromQueue(),s(t))})()}Cp(),eh(),B(),fc(),Et(),of(),ef(),ap(),In(),Xd(),bt();function ek(e,t){return(0,Q.useCallback)(async(n,r,i,a,o,s)=>new Promise(c=>{let l=ZO(n,r,i,a,o,t,QO(e));if(!l.resolveIfAborted(c))return(s===void 0?so(n,r,i,a,o):Promise.resolve(s)).then(async e=>{if(process.env.USER_TYPE===`ant`&&Z(`tengu_internal_tool_permission_decision`,{toolName:th(n.name),behavior:e.behavior,input:$d(r),messageID:l.messageId,isMcp:n.isMcp??!1}),e.behavior===`allow`){if(l.resolveIfAborted(c))return;e.decisionReason?.type===`classifier`&&e.decisionReason.classifier===`auto-mode`&&Hs(o,e.decisionReason.reason),l.logDecision({decision:`accept`,source:`config`}),c(l.buildAllow(e.updatedInput??r,{decisionReason:e.decisionReason}));return}let t=i.getAppState(),a=await n.description(r,{isNonInteractiveSession:i.options.isNonInteractiveSession,toolPermissionContext:t.toolPermissionContext,tools:i.options.tools});if(!l.resolveIfAborted(c))switch(e.behavior){case`deny`:Ys({tool:n,input:r,toolUseContext:i,messageId:l.messageId,toolUseID:o},{decision:`reject`,source:`config`}),e.decisionReason?.type===`classifier`&&e.decisionReason.classifier===`auto-mode`&&(J_({toolName:n.name,display:a,reason:e.decisionReason.reason??``,timestamp:Date.now()}),i.addNotification?.({key:`auto-mode-denied`,priority:`immediate`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(T,{color:`error`,children:[n.userFacingName(r).toLowerCase(),` denied by auto mode`]}),(0,$.jsx)(T,{dimColor:!0,children:` · /permissions`})]})})),c(e);return;case`ask`:if(t.toolPermissionContext.awaitAutomatedChecksBeforeDialog){let n=await UO({ctx:l,updatedInput:e.updatedInput,suggestions:e.suggestions,permissionMode:t.toolPermissionContext.mode});if(n){c(n);return}}if(l.resolveIfAborted(c))return;$O({ctx:l,description:a,result:e,awaitAutomatedChecksBeforeDialog:t.toolPermissionContext.awaitAutomatedChecksBeforeDialog,bridgeCallbacks:t.replBridgePermissionCallbacks},c);return}}).catch(e=>{e instanceof af||e instanceof sf?(Y(`Permission check threw ${e.constructor.name} for tool=${n.name}: ${e.message}`),l.logCancelled(),c(l.cancelAndAbort(void 0,!0))):(X(e),c(l.cancelAndAbort(void 0,!0)))}).finally(()=>{Qi(o)})}),[e,t])}mh(),Cp(),Zi(),Ft(),qd(),of(),Si(),ef(),ap(),jr(),lm();function tk(){sn(0)}async function nk(e){let{helpers:t,queryGuard:n,isExternalLoading:r=!1,commands:i,onInputChange:a,setPastedContents:o,setToolJSX:s,getToolUseContext:c,messages:l,mainLoopModel:u,ideSelection:d,setUserInputOnProcessing:f,setAbortController:p,onQuery:m,setAppState:h,onBeforeQuery:g,canUseTool:_,queuedCommands:v,uuid:y,skipSlashCommands:b,bridgeOrigin:x}=e,{setCursorOffset:S,clearBuffer:C,resetHistory:w}=t;if(v?.length){id(),await rk({queuedCommands:v,messages:l,mainLoopModel:u,ideSelection:d,querySource:e.querySource,commands:i,queryGuard:n,setToolJSX:s,getToolUseContext:c,setUserInputOnProcessing:f,setAbortController:p,onQuery:m,setAppState:h,onBeforeQuery:g,resetHistory:w,canUseTool:_,onInputChange:a});return}let T=e.input??``,E=e.mode??`prompt`,D=e.pastedContents??{},O=new Set(li(T).map(e=>e.id)),k=Object.fromEntries(Object.entries(D).filter(([,e])=>e.type!==`image`||O.has(e.id))),A=Object.values(k).some(Fd);if(T.trim()===``)return;if(!b&&[`exit`,`quit`,`:q`,`:q!`,`:wq`,`:wq!`].includes(T.trim())){i.find(e=>e.name===`exit`)?nk({...e,input:`/exit`}):tk();return}let j=ja(T,k),M=li(T).filter(e=>k[e.id]?.type===`text`),N=M.length;if(Z(`tengu_paste_text`,{pastedTextCount:N,pastedTextBytes:M.reduce((e,t)=>e+(k[t.id]?.content.length??0),0)}),!b&&j.trim().startsWith(`/`)){let t=j.trim(),d=t.indexOf(` `),f=d===-1?t.slice(1):t.slice(1,d),p=d===-1?``:t.slice(d+1).trim(),m=i.find(e=>e.immediate&&Zu(e)&&(e.name===f||e.aliases?.includes(f)||Ss(e)===f));if(m&&m.type===`local-jsx`&&(n.isActive||r)){Z(`tengu_immediate_command_executed`,{commandName:m.name}),a(``),S(0),o({}),C();let t=c(l,[],Lc(),u),n=!1,r=await(await m.load()).call((t,r)=>{n=!0,s({jsx:null,shouldHidePromptInput:!1,clearLocalJSX:!0}),t&&r?.display!==`skip`&&e.addNotification&&e.addNotification({key:`immediate-${m.name}`,text:t,priority:`immediate`}),r?.nextInput&&(r.submitNextInput?io({value:r.nextInput,mode:`prompt`}):a(r.nextInput))},t,p);r&&!n&&s({jsx:r,shouldHidePromptInput:!1,isLocalJSXCommand:!0,isImmediate:!0});return}}if(n.isActive||r){if(E!==`prompt`&&E!==`bash`)return;e.hasInterruptibleToolInProgress&&(Y(`[interrupt] Aborting current turn: streamMode=${e.streamMode}`),Z(`tengu_cancel`,{source:`interrupt_on_submit`,streamMode:e.streamMode}),e.abortController?.abort(`interrupt`)),io({value:j.trim(),preExpansionValue:T.trim(),mode:E,pastedContents:A?k:void 0,skipSlashCommands:b,bridgeOrigin:x,uuid:y}),a(``),S(0),o({}),w(),C();return}id(),await rk({queuedCommands:[{value:j,preExpansionValue:T,mode:E,pastedContents:A?k:void 0,skipSlashCommands:b,bridgeOrigin:x,uuid:y}],messages:l,mainLoopModel:u,ideSelection:d,querySource:e.querySource,commands:i,queryGuard:n,setToolJSX:s,getToolUseContext:c,setUserInputOnProcessing:f,setAbortController:p,onQuery:m,setAppState:h,onBeforeQuery:g,resetHistory:w,canUseTool:_,onInputChange:a})}async function rk(e){let{messages:t,mainLoopModel:n,ideSelection:r,querySource:i,queryGuard:a,setToolJSX:o,getToolUseContext:s,setUserInputOnProcessing:c,setAbortController:l,onQuery:u,setAppState:d,onBeforeQuery:f,resetHistory:p,canUseTool:m,queuedCommands:h}=e,g=Lc();l(g);function _(){return s(t,[],g,n)}try{a.reserve(),fl(`query_process_user_input_start`);let s=[],v=!1,y,b,x,S,C,w=h??[],T=await kd(w);w=T.attachmentCommands;let E=T.claimedCommands;if(w.length===0){l(null);return}let D=w[0]?.workload,O=D!==void 0&&w.every(e=>e.workload===D)?D:void 0,k=new Set,A;try{await pm(O,async()=>{for(let e=0;e<w.length;e++){let n=w[e],a=e===0,l=n.autonomy?.runId,u=await xg({input:n.value,preExpansionInput:n.preExpansionValue,mode:n.mode,setToolJSX:o,context:_(),pastedContents:a?n.pastedContents:void 0,messages:t,setUserInputOnProcessing:a?c:void 0,isAlreadyProcessing:!a,querySource:i,canUseTool:m,uuid:n.uuid,ideSelection:a?r:void 0,skipSlashCommands:n.skipSlashCommands,bridgeOrigin:n.bridgeOrigin,isMeta:n.isMeta,skipAttachments:!a,autonomy:n.autonomy});l&&u.deferAutonomyCompletion&&k.add(l);let d=n.origin??(n.mode===`task-notification`?{kind:`task-notification`}:void 0);if(d)for(let e of u.messages)e.type===`user`&&(e.origin=d);s.push(...u.messages),a&&(v=u.shouldQuery,y=u.allowedTools,b=u.model,x=u.effort,S=u.nextInput,C=u.submitNextInput)}if(fl(`query_process_user_input_end`),Kd()&&(fl(`query_file_history_snapshot_start`),s.filter(bg).forEach(e=>{lr(e=>{d(t=>({...t,fileHistory:e(t.fileHistory)}))},e.uuid)}),fl(`query_file_history_snapshot_end`)),s.length){p(),o({jsx:null,shouldHidePromptInput:!1,clearLocalJSX:!0});let e=w[0],t=e?.mode??`prompt`,r=e&&typeof e.value==`string`?e.value:void 0,i=t===`prompt`;await u(s,g,v,y??[],b?Jp(b,n):n,i?f:void 0,r,x)}else a.cancelReservation(),o({jsx:null,shouldHidePromptInput:!1,clearLocalJSX:!0}),p(),l(null);S&&(C?io({value:S,mode:`prompt`}):e.onInputChange(S))})}catch(e){A=e}if(E.length){let e=E.filter(e=>{let t=e.autonomy?.runId;return!t||!k.has(t)});if(A)try{await _s({commands:e,outcome:{type:`failed`,error:A},currentDir:Jd(),priority:`later`,workload:O})}catch(e){X(Qd(e))}else try{let t=await _s({commands:e,outcome:{type:`completed`},currentDir:Jd(),priority:`later`,workload:O});for(let e of t)io(e)}catch(e){X(Qd(e))}}if(A)throw A}finally{a.cancelReservation(),c(void 0)}}jr();function ik(e){if(typeof e.value==`string`)return e.value.trim().startsWith(`/`)&&(!e.skipSlashCommands||e.bridgeOrigin===!0);for(let t of e.value)if(t.type===`text`)return t.text.trim().startsWith(`/`)&&(!e.skipSlashCommands||e.bridgeOrigin===!0);return!1}function ak({executeInput:e}){let t=e=>e.agentId===void 0,n=Ko(t);if(!n)return{processed:!1};if(ik(n)||n.mode===`bash`)return e([Wd(t)]),{processed:!0};let r=n.mode,i=Jt(e=>t(e)&&!ik(e)&&e.mode===r);return i.length===0?{processed:!1}:(e(i),{processed:!0})}jr();function ok({executeQueuedInput:e,hasActiveLocalJsxUI:t,queryGuard:n}){let r=(0,Q.useSyncExternalStore)(n.subscribe,n.getSnapshot),i=(0,Q.useSyncExternalStore)(Bs,qn);(0,Q.useEffect)(()=>{r||t||i.length!==0&&ak({executeInput:e})},[i,r,e,t,n])}function sk({isLoading:e,onSubmitMessage:t}){let n=dd();(0,Q.useEffect)(()=>{if(e)return;let r=n.poll();r&&t(r.content)},[e,(0,Q.useSyncExternalStore)((0,Q.useMemo)(()=>n.subscribe.bind(n),[n]),(0,Q.useCallback)(()=>n.revision,[n])),n,t])}function ck(e,t){return e&&t&&t.length>0?Sr([...e,...t],`name`):e||[]}function lk(e,t){return(0,Q.useMemo)(()=>ck(e,t),[e,t])}Tl(),yg(),Kg(),iu();function uk(e,t){return(0,Q.useMemo)(()=>t.length>0?Sr([...e,...t],`name`):e,[e,t])}Zi(),ap();function dk(e,t){let n=(0,Q.useCallback)(async()=>{if(e)try{$a(),t(await lu(e))}catch(e){e instanceof Error&&X(e)}},[e,t]);(0,Q.useEffect)(()=>Ig.subscribe(n),[n])}ap(),Ee(),Ei(),Fp();var fk=Pp(()=>De({method:Ce(`selection_changed`),params:De({selection:De({start:De({line:be(),character:be()}),end:De({line:be(),character:be()})}).nullable().optional(),text:ye().optional(),filePath:ye().optional()})}));function pk(e,t){let n=(0,Q.useRef)(!1),r=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{let i=ya(e);if(r.current!==(i??null)&&(n.current=!1,r.current=i||null,t({lineCount:0,lineStart:void 0,text:void 0,filePath:void 0})),n.current||!i)return;let a=e=>{if(e.selection?.start&&e.selection?.end){let{start:n,end:r}=e.selection,i=r.line-n.line+1;r.character===0&&i--,t({lineCount:i,lineStart:n.line,text:e.text,filePath:e.filePath})}};i.client.setNotificationHandler(fk(),e=>{if(r.current===i)try{let t=e.params;t.selection&&t.selection.start&&t.selection.end?a(t):t.text!==void 0&&a({selection:null,text:t.text,filePath:t.filePath})}catch(e){X(e)}}),n.current=!0},[e,t])}Zc(),B(),cv(),q(),kp();function mk({task:e,selected:t}){let n=dv(e.startTime,e.status===`running`),r=e.progress?.tokenCount??0;return(0,$.jsxs)(b,{flexDirection:`row`,width:`100%`,justifyContent:`space-between`,children:[(0,$.jsxs)(b,{flexDirection:`row`,flexShrink:1,children:[(0,$.jsx)(T,{color:e.status===`running`?`success`:void 0,children:t?`● `:`○ `}),(0,$.jsxs)(T,{bold:t,wrap:`truncate-end`,children:[e.agentType,` `,(0,$.jsx)(T,{dimColor:!0,children:e.description})]})]}),(0,$.jsx)(b,{flexShrink:0,children:(0,$.jsxs)(T,{dimColor:!0,children:[n,` · ↓ `,Np(r),` tokens`]})})]})}function hk(e,t){return e?`↑/↓ to select · Enter to view`:t?t.status===`running`?`shift+↓ to manage · x to stop`:`shift+↓ to manage · x to clear`:`shift+↓ to manage background agents`}function gk(){let e=IC(),t=J(e=>e.viewingAgentTaskId),n=J(e=>e.footerSelection),r=J(e=>e.selectedBgAgentIndex);if(e.length===0)return null;let i=n===`bg_agent`,a=i?r===-1?null:e[r]?.agentId??null:t??null,o=i?r===-1:t===void 0,s=t?e.find(e=>e.agentId===t)??null:null;return(0,$.jsxs)(b,{flexDirection:`column`,width:`100%`,children:[(0,$.jsxs)(b,{flexDirection:`row`,width:`100%`,justifyContent:`space-between`,children:[(0,$.jsxs)(T,{bold:o,children:[o?`● `:`○ `,`main`]}),(0,$.jsx)(T,{dimColor:!0,children:hk(i,s)})]}),e.map(e=>(0,$.jsx)(mk,{task:e,selected:e.agentId===a},e.agentId))]})}of(),Cr();var _k=1e3;function vk({taskListId:e,isLoading:t,onSubmitTask:n}){let r=(0,Q.useRef)(null),i=(0,Q.useRef)(null),a=(0,Q.useRef)(t);a.current=t;let o=(0,Q.useRef)(n);o.current=n;let s=e!==void 0,c=e??`tasklist`,l=(0,Q.useRef)(async()=>{});l.current=async()=>{if(!s||a.current)return;let t=await wo(e);if(r.current!==null){let e=t.find(e=>e.id===r.current);if(!e||e.status===`completed`)Y(`[TaskListWatcher] Task #${r.current} is marked complete, ready for next task`),r.current=null;else return}let n=yk(t);if(!n)return;Y(`[TaskListWatcher] Found available task #${n.id}: ${n.subject}`);let i=await Qn(e,n.id,c);if(!i.success){Y(`[TaskListWatcher] Failed to claim task #${n.id}: ${i.reason}`);return}r.current=n.id;let l=bk(n);Y(`[TaskListWatcher] Submitting task #${n.id} as prompt`),o.current(l)||(Y(`[TaskListWatcher] Failed to submit task #${n.id}, releasing claim`),await qi(e,n.id,{owner:void 0}),r.current=null)};let u=(0,Q.useRef)(()=>{});(0,Q.useEffect)(()=>{if(!s)return;co(e);let t=au(e),n=null,r=()=>{i.current&&clearTimeout(i.current),i.current=setTimeout(e=>void e.current(),_k,l)};u.current=r;try{n=Rv(t,r),n.unref(),Y(`[TaskListWatcher] Watching for tasks in ${t}`)}catch(e){Y(`[TaskListWatcher] Failed to watch ${t}: ${e}`)}return r(),()=>{u.current=()=>{},n&&n.close(),i.current&&clearTimeout(i.current)}},[s,e]),(0,Q.useEffect)(()=>{s&&(t||u.current())},[s,t])}function yk(e){let t=new Set(e.filter(e=>e.status!==`completed`).map(e=>e.id));return e.find(e=>e.status!==`pending`||e.owner?!1:e.blockedBy.every(e=>!t.has(e)))}function bk(e){let t=`Complete all open tasks. Start with task #${e.id}: \n\n ${e.subject}`;return e.description&&(t+=`\n\n${e.description}`),t}Vf(),s(),Ei();function xk({autoConnectIdeFlag:e,ideToInstallExtension:t,setDynamicMcpConfig:n,setShowIdeOnboarding:r,setIDEInstallationState:o}){(0,Q.useEffect)(()=>{function s(r){r&&(Bf().autoConnectIde||e||gi()||process.env.CLAUDE_CODE_SSE_PORT||t||a(process.env.CLAUDE_CODE_AUTO_CONNECT_IDE))&&!i(process.env.CLAUDE_CODE_AUTO_CONNECT_IDE)&&n(e=>e?.ide?e:{...e,ide:{type:r.url.startsWith(`ws:`)?`ws-ide`:`sse-ide`,url:r.url,ideName:r.name,authToken:r.authToken,ideRunningInWindows:r.ideRunningInWindows,scope:`dynamic`}})}Xc(s,t,()=>r(!0),e=>o(e))},[e,t,n,r,o])}M_(),Rh(),B(),zh(),Pa(),q(),Vf(),Ef(),s();function Sk({onBackgroundSession:e,isLoading:t}){let n=Qs(),r=js(),[i,o]=(0,Q.useState)(!1),s=ie(o,e,()=>{}),c=(0,Q.useCallback)(()=>{a(process.env.CLAUDE_CODE_DISABLE_BACKGROUND_TASKS)||(ka(r.getState())?(hd(()=>r.getState(),n),Bf().hasUsedBackgroundTask||zf(e=>e.hasUsedBackgroundTask?e:{...e,hasUsedBackgroundTask:!0})):a(`false`)&&t&&s())},[n,r,t,s]),l=J(ka),u=a(`false`);j(`task:background`,c,{context:`Task`,isActive:l||u&&t});let d=lo(`task:background`,`Task`,`ctrl+b`),f=_f.terminal===`tmux`&&d===`ctrl+b`?`ctrl+b ctrl+b`:d;return!t||!i?null:(0,$.jsx)(b,{paddingLeft:2,children:(0,$.jsx)(T,{dimColor:!0,children:(0,$.jsx)(h,{shortcut:f,action:`background`})})})}q();function Ck({setMessages:e,setIsLoading:t,resetLoadingState:n,setAbortController:r,onBackgroundQuery:i}){let a=J(e=>e.foregroundedTaskId),o=J(e=>e.foregroundedTaskId?e.tasks[e.foregroundedTaskId]:void 0),s=Qs(),c=(0,Q.useRef)(0),l=(0,Q.useCallback)(()=>{if(a){s(e=>{let t=e.foregroundedTaskId;if(!t)return e;let n=e.tasks[t];return n?{...e,foregroundedTaskId:void 0,tasks:{...e.tasks,[t]:{...n,isBackgrounded:!0}}}:{...e,foregroundedTaskId:void 0}}),e([]),n(),r(null);return}i()},[a,s,e,n,r,i]);return(0,Q.useEffect)(()=>{if(!a){c.current=0;return}if(!o||o.type!==`local_agent`){s(e=>({...e,foregroundedTaskId:void 0})),n(),c.current=0;return}let i=o.messages??[];if(i.length!==c.current&&(c.current=i.length,e([...i])),o.status===`running`){let e=o.abortController;if(e?.signal.aborted){s(e=>{if(!e.foregroundedTaskId)return e;let t=e.tasks[e.foregroundedTaskId];return t?{...e,foregroundedTaskId:void 0,tasks:{...e.tasks,[e.foregroundedTaskId]:{...t,isBackgrounded:!0}}}:{...e,foregroundedTaskId:void 0}}),n(),r(null),c.current=0;return}t(!0),e&&r(e)}else s(e=>{let t=e.foregroundedTaskId;if(!t)return e;let n=e.tasks[t];return n?{...e,foregroundedTaskId:void 0,tasks:{...e.tasks,[t]:{...n,isBackgrounded:!0}}}:{...e,foregroundedTaskId:void 0}}),n(),r(null),c.current=0},[a,o,s,e,t,n,r]),{handleBackgroundSession:l}}Ld(),B(),am(),Vf(),lm(),Nf(),Pi(),S_(),n_();var wk=3e4;function Tk({model:e,onDone:t}){let n=K(),r=(0,Q.useRef)(t);(0,Q.useEffect)(()=>{r.current=t});let i=(0,Q.useCallback)(()=>{r.current(`dismiss`)},[]);(0,Q.useEffect)(()=>{kk()},[]),(0,Q.useEffect)(()=>{let e=setTimeout(i,wk);return()=>clearTimeout(e)},[i]);let a=Zn(e),o=a?Ga(a):`high`,s=(0,Q.useCallback)(e=>{Lf(`userSettings`,{effortLevel:gu(e===o?void 0:e)}),r.current(e)},[o]),c=[{label:(0,$.jsx)(Dk,{level:`medium`,text:`Medium (recommended)`}),value:`medium`},{label:(0,$.jsx)(Dk,{level:`high`,text:`High`}),value:`high`},{label:(0,$.jsx)(Dk,{level:`low`,text:`Low`}),value:`low`}];return(0,$.jsx)(i_,{title:n.dialogTitle,children:(0,$.jsxs)(b,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsx)(b,{marginBottom:1,flexDirection:`column`,children:(0,$.jsx)(T,{children:n.dialogDescription})}),(0,$.jsx)(b,{marginBottom:1,children:(0,$.jsxs)(T,{dimColor:!0,children:[(0,$.jsx)(Ek,{level:`low`}),` low `,`·`,` `,(0,$.jsx)(Ek,{level:`medium`}),` medium `,`·`,` `,(0,$.jsx)(Ek,{level:`high`}),` high`]})}),(0,$.jsx)(pi,{options:c,onChange:s,onCancel:i})]})})}function Ek({level:e}){return(0,$.jsx)(T,{color:`suggestion`,children:__(e)})}function Dk({level:e,text:t}){return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ek,{level:e}),` `,t]})}function Ok(e){if(!Kp(e).toLowerCase().includes(`opus-4-6`))return!1;let t=Bf();return t.effortCalloutV2Dismissed?!1:t.numStartups<=1?(kk(),!1):hm()?t.effortCalloutDismissed?(kk(),!1):K().enabled:cm()||wm()?K().enabled:(kk(),!1)}function kk(){zf(e=>e.effortCalloutV2Dismissed?e:{...e,effortCalloutV2Dismissed:!0})}fg(),a_();function Ak(e,t){return t}async function jk(e,t,n){try{Y(`Collecting transcript for sharing`,{level:`info`});let r=Or(e),i=await kr(Wl(e)),a;try{let e=xn(),{size:t}=await Hv(e);t<=52428800?a=await Vv(e,`utf-8`):Y(`Skipping raw transcript read: file too large (${t} bytes)`,{level:`warn`})}catch{}let o=z_($d({trigger:t,version:`0.0.1`,platform:process.platform,transcript:r,subagentTranscripts:Object.keys(i).length>0?i:void 0,rawTranscriptJsonl:a}));await vm();let s=gm();if(s.error)return{success:!1};let c={"Content-Type":`application/json`,"User-Agent":Tm(),...s.headers},l=await f.post(`https://api.anthropic.com/api/claude_code_shared_session_transcripts`,{content:o,appearance_id:n},{headers:c,timeout:3e4});if(l.status===200||l.status===201){let e=l.data;return Y(`Transcript shared successfully`,{level:`info`}),{success:!0,transcriptId:e?.transcript_id}}return{success:!1}}catch(e){return Y(df(e),{level:`error`}),{success:!1}}}var Mk=t((()=>{p(),am(),of(),ef(),Vd(),Wc(),Xd()}));Lh(),Mk();function Nk({hideThanksAfterMs:e,onOpen:t,onSelect:n,shouldShowTranscriptPrompt:r,onTranscriptPromptShown:i,onTranscriptSelect:a}){let[o,s]=(0,Q.useState)(`closed`),[c,l]=(0,Q.useState)(null),u=(0,Q.useRef)(Bv()),d=(0,Q.useRef)(null),f=(0,Q.useCallback)(()=>{s(`thanks`),setTimeout((e,t)=>{e(`closed`),t(null)},e,s,l)},[e]),p=(0,Q.useCallback)(()=>{s(`submitted`),setTimeout(s,e,`closed`)},[e]);return{state:o,lastResponse:c,open:(0,Q.useCallback)(()=>{o===`closed`&&(s(`open`),u.current=Bv(),t(u.current))},[o,t]),handleSelect:(0,Q.useCallback)(e=>{if(l(e),d.current=e,n(u.current,e),e===`dismissed`)s(`closed`),l(null);else if(r?.(e))return s(`transcript_prompt`),i?.(u.current,e),!0;else f();return!1},[f,n,r,i]),handleTranscriptSelect:(0,Q.useCallback)(e=>{switch(e){case`yes`:s(`submitting`),(async()=>{try{await a?.(u.current,e,d.current)?p():f()}catch{f()}})();break;case`no`:case`dont_ask_again`:a?.(u.current,e,d.current),f();break}},[f,p,a])}}Cp(),Vf(),s(),Vd(),lm(),Nf();var Pk={minTimeBeforeFeedbackMs:6e5,minTimeBetweenFeedbackMs:36e5,minTimeBetweenGlobalFeedbackMs:1e8,minUserTurnsBeforeFeedback:5,minUserTurnsBetweenFeedback:10,hideThanksAfterMs:3e3,onForModels:[`*`],probability:.005},Fk={probability:0};function Ik(e,t,n,r=`session`,i=!1){let o=(0,Q.useRef)(`unknown`);o.current=$c(e)?.message?.id||`unknown`;let[s,c]=(0,Q.useState)(()=>({timeLastShown:null,submitCountAtLastAppearance:null})),l=Ak(`tengu_feedback_survey_config`,Pk),u=Ak(`tengu_bad_survey_transcript_ask_config`,Fk),d=Ak(`tengu_good_survey_transcript_ask_config`,Fk),f=Ff().feedbackSurveyRate,p=(0,Q.useRef)(Date.now()),m=(0,Q.useRef)(n),h=(0,Q.useRef)(n);h.current=n;let g=(0,Q.useRef)(e);g.current=e;let _=(0,Q.useRef)(!1),v=(0,Q.useRef)(null),y=(0,Q.useCallback)((e,t)=>{c(n=>n.timeLastShown===e&&n.submitCountAtLastAppearance===t?n:{timeLastShown:e,submitCountAtLastAppearance:t}),Bf().feedbackSurveyState?.lastShownTime!==e&&zf(t=>({...t,feedbackSurveyState:{lastShownTime:e}}))},[]),b=(0,Q.useCallback)(e=>{y(Date.now(),h.current),Z(`tengu_feedback_survey_event`,{event_type:`appeared`,appearance_id:e,last_assistant_message_id:o.current,survey_type:r}),xh(`feedback_survey`,{event_type:`appeared`,appearance_id:e,survey_type:r})},[y,r]),x=(0,Q.useCallback)((e,t)=>{y(Date.now(),h.current),Z(`tengu_feedback_survey_event`,{event_type:`responded`,appearance_id:e,response:t,last_assistant_message_id:o.current,survey_type:r}),xh(`feedback_survey`,{event_type:`responded`,appearance_id:e,response:t,survey_type:r})},[y,r]),S=(0,Q.useCallback)(e=>{if(e!==`bad`&&e!==`good`||Bf().transcriptShareDismissed||!Na(`allow_product_feedback`))return!1;let t=e===`bad`?u.probability:d.probability;return Math.random()<=t},[u.probability,d.probability]),C=(0,Q.useCallback)((e,t)=>{let n=t===`good`?`good_feedback_survey`:`bad_feedback_survey`;Z(`tengu_feedback_survey_event`,{event_type:`transcript_prompt_appeared`,appearance_id:e,last_assistant_message_id:o.current,survey_type:r,trigger:n}),xh(`feedback_survey`,{event_type:`transcript_prompt_appeared`,appearance_id:e,survey_type:r})},[r]),w=(0,Q.useCallback)(async(e,t,n)=>{let i=n===`good`?`good_feedback_survey`:`bad_feedback_survey`;if(Z(`tengu_feedback_survey_event`,{event_type:`transcript_share_${t}`,appearance_id:e,last_assistant_message_id:o.current,survey_type:r,trigger:i}),t===`dont_ask_again`&&zf(e=>({...e,transcriptShareDismissed:!0})),t===`yes`){let t=await jk(g.current,i,e);return Z(`tengu_feedback_survey_event`,{event_type:t.success?`transcript_share_submitted`:`transcript_share_failed`,appearance_id:e,trigger:i}),t.success}return!1},[r]),{state:T,lastResponse:E,open:D,handleSelect:O,handleTranscriptSelect:k}=Nk({hideThanksAfterMs:l.hideThanksAfterMs,onOpen:b,onSelect:x,shouldShowTranscriptPrompt:S,onTranscriptPromptShown:C,onTranscriptSelect:w}),A=Fm(),j=(0,Q.useMemo)(()=>l.onForModels.length===0?!1:l.onForModels.includes(`*`)?!0:l.onForModels.includes(A),[l.onForModels,A]),M=(0,Q.useMemo)(()=>{if(T!==`closed`||t||i)return!1;if(process.env.CLAUDE_FORCE_DISPLAY_SURVEY&&!s.timeLastShown)return!0;if(!j||a(process.env.CLAUDE_CODE_DISABLE_FEEDBACK_SURVEY)||Ih()||!Na(`allow_product_feedback`))return!1;if(s.timeLastShown){if(Date.now()-s.timeLastShown<l.minTimeBetweenFeedbackMs||s.submitCountAtLastAppearance!==null&&n<s.submitCountAtLastAppearance+l.minUserTurnsBetweenFeedback)return!1}else if(Date.now()-p.current<l.minTimeBeforeFeedbackMs||n<m.current+l.minUserTurnsBeforeFeedback)return!1;if(v.current!==n&&(v.current=n,_.current=Math.random()<=(f??l.probability)),!_.current)return!1;let e=Bf().feedbackSurveyState;return!(e?.lastShownTime&&Date.now()-e.lastShownTime<l.minTimeBetweenGlobalFeedbackMs)},[T,t,i,j,s.timeLastShown,s.submitCountAtLastAppearance,n,l.minTimeBetweenFeedbackMs,l.minTimeBetweenGlobalFeedbackMs,l.minUserTurnsBetweenFeedback,l.minTimeBeforeFeedbackMs,l.minUserTurnsBeforeFeedback,l.probability,f]);return(0,Q.useEffect)(()=>{M&&D()},[M,D]),{state:T,lastResponse:E,handleSelect:O,handleTranscriptSelect:k}}Lh(),Cp(),qa(),Vf(),s(),Vd(),wh(),Mk();var Lk=3e3,Rk=`tengu_memory_survey_event`,zk=`memory_survey`;function Bk(e,t,n=!1,{enabled:r=!0}={}){let i=(0,Q.useRef)(new Set),a=(0,Q.useRef)(!1),o=(0,Q.useRef)(e);o.current=e;let{state:s,lastResponse:c,open:l,handleSelect:u,handleTranscriptSelect:d}=Nk({hideThanksAfterMs:Lk,onOpen:(0,Q.useCallback)(e=>{Z(Rk,{event_type:`appeared`,appearance_id:e}),xh(`feedback_survey`,{event_type:`appeared`,appearance_id:e,survey_type:`memory`})},[]),onSelect:(0,Q.useCallback)((e,t)=>{Z(Rk,{event_type:`responded`,appearance_id:e,response:t}),xh(`feedback_survey`,{event_type:`responded`,appearance_id:e,response:t,survey_type:`memory`})},[]),shouldShowTranscriptPrompt:(0,Q.useCallback)(e=>!(process.env.USER_TYPE!==`ant`||e!==`bad`&&e!==`good`||Bf().transcriptShareDismissed||!Na(`allow_product_feedback`)),[]),onTranscriptPromptShown:(0,Q.useCallback)(e=>{Z(Rk,{event_type:`transcript_prompt_appeared`,appearance_id:e,trigger:zk}),xh(`feedback_survey`,{event_type:`transcript_prompt_appeared`,appearance_id:e,survey_type:`memory`})},[]),onTranscriptSelect:(0,Q.useCallback)(async(e,t)=>{if(Z(Rk,{event_type:`transcript_share_${t}`,appearance_id:e,trigger:zk}),t===`dont_ask_again`&&zf(e=>({...e,transcriptShareDismissed:!0})),t===`yes`){let t=await jk(o.current,zk,e);return Z(Rk,{event_type:t.success?`transcript_share_submitted`:`transcript_share_failed`,appearance_id:e,trigger:zk}),t.success}return!1},[])});return(0,Q.useEffect)(()=>{if(r&&e.length===0){a.current=!1,i.current.clear();return}},[r,s,t,n,(0,Q.useMemo)(()=>$c(e),[e]),e,l]),{state:s,lastResponse:c,handleSelect:u,handleTranscriptSelect:d}}Lh(),Cp(),s(),Vd(),wh();var Vk=3e3,Hk=.2;function Uk(e,t){let n=e.findIndex(e=>e.uuid===t);if(n===-1)return!1;for(let t=n+1;t<e.length;t++){let n=e[t];if(n&&(n.type===`user`||n.type===`assistant`))return!0}return!1}function Wk(e,t,n=!1,{enabled:r=!0}={}){let[i,o]=(0,Q.useState)(null),s=(0,Q.useRef)(new Set),c=(0,Q.useRef)(null),{state:l,lastResponse:u,open:d,handleSelect:f}=Nk({hideThanksAfterMs:Vk,onOpen:(0,Q.useCallback)(e=>{Z(`tengu_post_compact_survey_event`,{event_type:`appeared`,appearance_id:e,session_memory_compaction_enabled:$u()}),xh(`feedback_survey`,{event_type:`appeared`,appearance_id:e,survey_type:`post_compact`})},[]),onSelect:(0,Q.useCallback)((e,t)=>{Z(`tengu_post_compact_survey_event`,{event_type:`responded`,appearance_id:e,response:t,session_memory_compaction_enabled:$u()}),xh(`feedback_survey`,{event_type:`responded`,appearance_id:e,response:t,survey_type:`post_compact`})},[])});(0,Q.useEffect)(()=>{r&&o(!1)},[r]);let p=(0,Q.useMemo)(()=>new Set(e.filter(e=>Gt(e)).map(e=>e.uuid)),[e]);return(0,Q.useEffect)(()=>{if(!r||l!==`closed`||t||n||i!==!0||Ih()||a(process.env.CLAUDE_CODE_DISABLE_FEEDBACK_SURVEY))return;if(c.current!==null&&Uk(e,c.current)){c.current=null,Math.random()<Hk&&d();return}let o=Array.from(p).filter(e=>!s.current.has(e));o.length>0&&(s.current=new Set(p),c.current=o[o.length-1])},[r,p,l,t,n,i,e,d]),{state:l,lastResponse:u,handleSelect:f}}vf(),B();var Gk=[`1`,`2`,`3`],Kk={1:`yes`,2:`no`,3:`dont_ask_again`},qk=e=>Gk.includes(e);function Jk({onSelect:e,inputValue:t,setInputValue:n}){return xO({inputValue:t,setInputValue:n,isValidDigit:qk,onDigit:t=>e(Kk[t])}),(0,$.jsxs)(b,{flexDirection:`column`,marginTop:1,children:[(0,$.jsxs)(b,{children:[(0,$.jsxs)(T,{color:`ansi:cyan`,children:[Sf,` `]}),(0,$.jsx)(T,{bold:!0,children:`Can Anthropic look at your session transcript to help us improve Claude Code?`})]}),(0,$.jsx)(b,{marginLeft:2,children:(0,$.jsx)(T,{dimColor:!0,children:`Learn more: https://code.claude.com/docs/en/data-usage#session-quality-surveys`})}),(0,$.jsxs)(b,{marginLeft:2,children:[(0,$.jsx)(b,{width:10,children:(0,$.jsxs)(T,{children:[(0,$.jsx)(T,{color:`ansi:cyan`,children:`1`}),`: Yes`]})}),(0,$.jsx)(b,{width:10,children:(0,$.jsxs)(T,{children:[(0,$.jsx)(T,{color:`ansi:cyan`,children:`2`}),`: No`]})}),(0,$.jsx)(b,{children:(0,$.jsxs)(T,{children:[(0,$.jsx)(T,{color:`ansi:cyan`,children:`3`}),`: Don't ask again`]})})]})]})}Cp(),B();function Yk({state:e,lastResponse:t,handleSelect:n,handleTranscriptSelect:r,inputValue:i,setInputValue:a,onRequestFeedback:o,message:s}){return e===`closed`?null:e===`thanks`?(0,$.jsx)(Zk,{lastResponse:t,inputValue:i,setInputValue:a,onRequestFeedback:o}):e===`submitted`?(0,$.jsx)(b,{marginTop:1,children:(0,$.jsxs)(T,{color:`success`,children:[`✓`,` Thanks for sharing your transcript!`]})}):e===`submitting`?(0,$.jsx)(b,{marginTop:1,children:(0,$.jsxs)(T,{dimColor:!0,children:[`Sharing transcript`,`…`]})}):e===`transcript_prompt`?!r||i&&![`1`,`2`,`3`].includes(i)?null:(0,$.jsx)(Jk,{onSelect:r,inputValue:i,setInputValue:a}):i&&!wO(i)?null:(0,$.jsx)(EO,{onSelect:n,inputValue:i,setInputValue:a,message:s})}var Xk=e=>e===`1`;function Zk({lastResponse:e,inputValue:t,setInputValue:n,onRequestFeedback:r}){let i=r&&e===`good`;xO({inputValue:t,setInputValue:n,isValidDigit:Xk,enabled:!!i,once:!0,onDigit:()=>{Z(`tengu_feedback_survey_event`,{event_type:`followup_accepted`,response:e}),r?.()}});let a=process.env.USER_TYPE===`ant`?`/issue`:`/feedback`;return(0,$.jsxs)(b,{marginTop:1,flexDirection:`column`,children:[(0,$.jsx)(T,{color:`success`,children:`Thanks for the feedback!`}),i?(0,$.jsxs)(T,{dimColor:!0,children:[`(Optional) Press [`,(0,$.jsx)(T,{color:`ansi:cyan`,children:`1`}),`] to tell us what went well `,` · `,a]}):e===`bad`?(0,$.jsx)(T,{dimColor:!0,children:`Use /issue to report model behavior issues.`}):(0,$.jsxs)(T,{dimColor:!0,children:[`Use `,a,` to share detailed feedback anytime.`]})]})}ag(),cg(),rt(),Ll(),ap();function Qk(e){let{addNotification:t}=Au(),n=(0,Q.useRef)(!1),r=(0,Q.useRef)(e);r.current=e,(0,Q.useEffect)(()=>{ke()||n.current||(n.current=!0,Promise.resolve().then(()=>r.current()).then(e=>{if(e)for(let n of Array.isArray(e)?e:[e])t(n)}).catch(X))},[t])}function $k(){Qk(async()=>(await sg()).map((e,t)=>{let n=`low`;return e.type===`error`||e.userActionRequired?n=`high`:(e.type===`path`||e.type===`alias`)&&(n=`medium`),{key:`install-message-${t}-${e.type}`,text:e.message,priority:n,color:e.type===`error`?`error`:`warning`}}))}tf(),of(),Vd(),lm(),Ms(),Ev(),qs(),B(),Vd();function eA(e,t,n){(0,Q.useRef)(null),(0,Q.useRef)(null);let r=(0,Q.useRef)(e),i=(0,Q.useRef)(n),a=(0,Q.useRef)(!1),o=(0,Q.useRef)(null);r.current=e,i.current=n,(0,Q.useEffect)(()=>{},[!1,t]),(0,Q.useEffect)(()=>{if(n||!a.current)return;let e=I();e!==`blurred`&&e!==`unknown`||o.current?.()},[n]),(0,Q.useEffect)(()=>{I()},[n,!1])}Cp(),Vf(),of(),s(),ef(),ap();function tA(){return a(process.env.CLAUDE_CODE_DISABLE_OFFICIAL_MARKETPLACE_AUTOINSTALL)}var nA={MAX_ATTEMPTS:10,INITIAL_DELAY_MS:3600*1e3,BACKOFF_MULTIPLIER:2,MAX_DELAY_MS:10080*60*1e3};function rA(e){let t=nA.INITIAL_DELAY_MS*nA.BACKOFF_MULTIPLIER**e;return Math.min(t,nA.MAX_DELAY_MS)}function iA(e){if(!e.officialMarketplaceAutoInstallAttempted)return!0;if(e.officialMarketplaceAutoInstalled)return!1;let t=e.officialMarketplaceAutoInstallFailReason,n=e.officialMarketplaceAutoInstallRetryCount||0,r=e.officialMarketplaceAutoInstallNextRetryTime,i=Date.now();return n>=nA.MAX_ATTEMPTS||t===`policy_blocked`||r&&i<r?!1:t===`unknown`||t===`git_unavailable`||t===`gcs_unavailable`||t===void 0}async function aA(){let e=Bf();if(!iA(e)){let t=e.officialMarketplaceAutoInstallFailReason??`already_attempted`;return Y(`Official marketplace auto-install skipped: ${t}`),{installed:!1,skipped:!0,reason:t}}try{if(tA())return Y(`Official marketplace auto-install disabled via env var, skipping`),zf(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!1,officialMarketplaceAutoInstallFailReason:`policy_blocked`})),Z(`tengu_official_marketplace_auto_install`,{installed:!1,skipped:!0,policy_blocked:!0}),{installed:!1,skipped:!0,reason:`policy_blocked`};if((await ar())[`claude-plugins-official`])return Y(`Official marketplace '${Jl}' already installed, skipping`),zf(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!0})),{installed:!1,skipped:!0,reason:`already_installed`};if(!Bl(hl))return Y(`Official marketplace blocked by enterprise policy, skipping`),zf(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!1,officialMarketplaceAutoInstallFailReason:`policy_blocked`})),Z(`tengu_official_marketplace_auto_install`,{installed:!1,skipped:!0,policy_blocked:!0}),{installed:!1,skipped:!0,reason:`policy_blocked`};let t=Ud(),n=Nv(t,Jl);if(await Uo(n,t)!==null){let e=await ar();return e[Jl]={source:hl,installLocation:n,lastUpdated:new Date().toISOString()},await Ar(e),zf(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!0,officialMarketplaceAutoInstallFailReason:void 0,officialMarketplaceAutoInstallRetryCount:void 0,officialMarketplaceAutoInstallLastAttemptTime:void 0,officialMarketplaceAutoInstallNextRetryTime:void 0})),Z(`tengu_official_marketplace_auto_install`,{installed:!0,skipped:!1,via_gcs:!0}),{installed:!0,skipped:!1}}if(!await Ou()){Y(`Git not available, skipping official marketplace auto-install`);let t=(e.officialMarketplaceAutoInstallRetryCount||0)+1,n=Date.now(),r=n+rA(t),i=!1;try{zf(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!1,officialMarketplaceAutoInstallFailReason:`git_unavailable`,officialMarketplaceAutoInstallRetryCount:t,officialMarketplaceAutoInstallLastAttemptTime:n,officialMarketplaceAutoInstallNextRetryTime:r}))}catch(e){i=!0,X(Qd(e)),Y(`Failed to save marketplace auto-install git_unavailable state: ${e}`,{level:`error`})}return Z(`tengu_official_marketplace_auto_install`,{installed:!1,skipped:!0,git_unavailable:!0,retry_count:t}),{installed:!1,skipped:!0,reason:`git_unavailable`,configSaveFailed:i}}Y(`Attempting to auto-install official marketplace`),await Pn(hl),Y(`Successfully auto-installed official marketplace`);let r=e.officialMarketplaceAutoInstallRetryCount||0;return zf(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!0,officialMarketplaceAutoInstallFailReason:void 0,officialMarketplaceAutoInstallRetryCount:void 0,officialMarketplaceAutoInstallLastAttemptTime:void 0,officialMarketplaceAutoInstallNextRetryTime:void 0})),Z(`tengu_official_marketplace_auto_install`,{installed:!0,skipped:!1,retry_count:r}),{installed:!0,skipped:!1}}catch(t){let n=t instanceof Error?t.message:String(t);if(n.includes(`xcrun: error:`))return il(),Y(`Official marketplace auto-install: git is a non-functional macOS xcrun shim, treating as git_unavailable`),Z(`tengu_official_marketplace_auto_install`,{installed:!1,skipped:!0,git_unavailable:!0,macos_xcrun_shim:!0}),{installed:!1,skipped:!0,reason:`git_unavailable`};Y(`Failed to auto-install official marketplace: ${n}`,{level:`error`}),X(Qd(t));let r=(e.officialMarketplaceAutoInstallRetryCount||0)+1,i=Date.now(),a=i+rA(r),o=!1;try{zf(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!1,officialMarketplaceAutoInstallFailReason:`unknown`,officialMarketplaceAutoInstallRetryCount:r,officialMarketplaceAutoInstallLastAttemptTime:i,officialMarketplaceAutoInstallNextRetryTime:a}))}catch(e){o=!0,X(Qd(e)),Y(`Failed to save marketplace auto-install failure state: ${e}`,{level:`error`})}return Z(`tengu_official_marketplace_auto_install`,{installed:!1,skipped:!0,failed:!0,retry_count:r}),{installed:!1,skipped:!0,reason:`unknown`,configSaveFailed:o}}}B(),of();function oA(){Qk(async()=>{let e=await aA(),t=[];return e.configSaveFailed&&(Y(`Showing marketplace config save failure notification`),t.push({key:`marketplace-config-save-failed`,jsx:(0,$.jsx)(T,{color:`error`,children:`Failed to save marketplace retry info · Check ~/.claude.json permissions`}),priority:`immediate`,timeoutMs:1e4})),e.installed?(Y(`Showing marketplace installation success notification`),t.push({key:`marketplace-installed`,jsx:(0,$.jsx)(T,{color:`success`,children:`✓ Anthropic marketplace installed · /plugin to see available plugins`}),priority:`immediate`,timeoutMs:7e3})):e.skipped&&e.reason===`unknown`&&(Y(`Showing marketplace installation failure notification`),t.push({key:`marketplace-install-failed`,jsx:(0,$.jsx)(T,{color:`warning`,children:`Failed to install Anthropic marketplace · Will retry on next startup`}),priority:`immediate`,timeoutMs:8e3})),t})}Nf(),Cp();function sA(e){if(e.length===0)return;if(e.length===1)return e[0];let t=e.map(e=>({tip:e,sessions:vv(e.id)}));return t.sort((e,t)=>t.sessions-e.sessions),t[0]?.tip}async function cA(e){if(jf().spinnerTipsEnabled===!1)return;let t=await xv(e);if(t.length!==0)return sA(t)}function lA(e){gv(e.id),Z(`tengu_tip_shown`,{tipIdLength:e.id,cooldownSessions:e.cooldownSessions})}ef(),ap(),rt(),q(),Xt();var uA=!1;async function dA(e,t,n){{if(uA)return;uA=!0;let{updateContext:r,notification:i}=await ur(e,n);t(e=>{let t=r(e.toolPermissionContext),n=t===e.toolPermissionContext?e:{...e,toolPermissionContext:t};return i?{...n,notifications:{...n.notifications,queue:[...n.notifications.queue,{key:`auto-mode-gate-notification`,text:i,color:`warning`,priority:`high`}]}}:n})}}function fA(){uA=!1}function pA(){let e=J(e=>e.mainLoopModel),t=J(e=>e.mainLoopModelForSession),n=J(e=>e.fastMode),r=Qs(),i=js(),a=(0,Q.useRef)(!0);(0,Q.useEffect)(()=>{ke()||(a.current?a.current=!1:fA(),dA(i.getState().toolPermissionContext,r,n).catch(e=>{X(Error(`Auto mode gate check failed`,{cause:Qd(e)}))}))},[e,t,n])}Yn();function mA(e,t,n){let r=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{!Kd()||r.current||(r.current=!0,e&&Wa(e,n))},[t,e,n])}B(),dr(),Cp(),Pi(),n_();function hA({hostPattern:{host:e},onUserResponse:t}){function n(n){switch(process.env.USER_TYPE===`ant`&&Z(`tengu_sandbox_network_dialog_result`,{host:e,result:n}),n){case`yes`:t({allow:!0,persistToSettings:!1});break;case`yes-dont-ask-again`:t({allow:!0,persistToSettings:!0});break;case`no`:t({allow:!1,persistToSettings:!1});break}}let r=[{label:`Yes`,value:`yes`},...jd()?[]:[{label:(0,$.jsxs)(T,{children:[`Yes, and don't ask again for `,(0,$.jsx)(T,{bold:!0,children:e})]}),value:`yes-dont-ask-again`}],{label:(0,$.jsxs)(T,{children:[`No, and tell Claude what to do differently `,(0,$.jsx)(T,{bold:!0,children:`(esc)`})]}),value:`no`}];return(0,$.jsx)(i_,{title:`Network request outside of sandbox`,children:(0,$.jsxs)(b,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsxs)(b,{children:[(0,$.jsx)(T,{dimColor:!0,children:`Host:`}),(0,$.jsxs)(T,{children:[` `,e]})]}),(0,$.jsx)(b,{marginTop:1,children:(0,$.jsx)(T,{children:`Do you want to allow this connection?`})}),(0,$.jsx)(b,{children:(0,$.jsx)(pi,{options:r,onChange:n,onCancel:()=>{process.env.USER_TYPE===`ant`&&Z(`tengu_sandbox_network_dialog_result`,{host:e,result:`cancel`}),t({allow:!1,persistToSettings:!1})}})})]})})}B(),dr(),dp();function gA(e){return`${e.getHours()%12||12}:${String(e.getMinutes()).padStart(2,`0`)}:${String(e.getSeconds()).padStart(2,`0`)}${e.getHours()<12?`am`:`pm`}`}function _A(){let[e,t]=(0,Q.useState)([]),[n,r]=(0,Q.useState)(0);return(0,Q.useEffect)(()=>{let e=fi.getSandboxViolationStore();return e.subscribe(n=>{t(n.slice(-10)),r(e.getTotalCount())})},[]),!fi.isSandboxingEnabled()||up()===`linux`||n===0?null:(0,$.jsxs)(b,{flexDirection:`column`,marginTop:1,children:[(0,$.jsx)(b,{marginLeft:0,children:(0,$.jsxs)(T,{color:`permission`,children:[`⧈ Sandbox blocked `,n,` total `,n===1?`operation`:`operations`]})}),e.map((e,t)=>(0,$.jsx)(b,{paddingLeft:2,children:(0,$.jsxs)(T,{dimColor:!0,children:[gA(e.timestamp),e.command?` ${e.command}:`:``,` `,e.line]})},`${e.timestamp.getTime()}-${t}`)),(0,$.jsx)(b,{paddingLeft:2,children:(0,$.jsxs)(T,{dimColor:!0,children:[`… showing last `,Math.min(10,e.length),` of `,n]})})]})}k_(),Ll(),rt(),B();var vA=[];function yA({mcpClients:e=vA}){let{addNotification:t}=Au();(0,Q.useEffect)(()=>{if(ke())return;let n=e.filter(e=>e.type===`failed`&&e.config.type!==`sse-ide`&&e.config.type!==`ws-ide`&&e.config.type!==`claudeai-proxy`),r=e.filter(e=>e.type===`failed`&&e.config.type===`claudeai-proxy`&&Ct(e.name)),i=e.filter(e=>e.type===`needs-auth`&&e.config.type!==`claudeai-proxy`),a=e.filter(e=>e.type===`needs-auth`&&e.config.type===`claudeai-proxy`&&Ct(e.name));n.length===0&&r.length===0&&i.length===0&&a.length===0||(n.length>0&&t({key:`mcp-failed`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(T,{color:`error`,children:[n.length,` MCP `,n.length===1?`server`:`servers`,` failed`]}),(0,$.jsx)(T,{dimColor:!0,children:` · /mcp`})]}),priority:`medium`}),r.length>0&&t({key:`mcp-claudeai-failed`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(T,{color:`error`,children:[r.length,` claude.ai `,r.length===1?`connector`:`connectors`,` `,`unavailable`]}),(0,$.jsx)(T,{dimColor:!0,children:` · /mcp`})]}),priority:`medium`}),i.length>0&&t({key:`mcp-needs-auth`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(T,{color:`warning`,children:[i.length,` MCP `,i.length===1?`server needs`:`servers need`,` `,`auth`]}),(0,$.jsx)(T,{dimColor:!0,children:` · /mcp`})]}),priority:`medium`}),a.length>0&&t({key:`mcp-claudeai-needs-auth`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(T,{color:`warning`,children:[a.length,` claude.ai`,` `,a.length===1?`connector needs`:`connectors need`,` auth`]}),(0,$.jsx)(T,{dimColor:!0,children:` · /mcp`})]}),priority:`medium`}))},[t,e])}B(),Nf(),ri();var bA=`Auto mode lets Claude handle permission prompts automatically — Claude checks each tool call for risky actions and prompt injection before executing. Actions Claude identifies as safe are executed, while actions Claude identifies as risky are blocked and Claude may try a different approach. Ideal for long-running tasks. Sessions are slightly more expensive. Claude can make mistakes that allow harmful commands to run, it's recommended to only use in isolated environments. Shift+Tab to change mode.`;me(),rt(),Ll(),B(),q(),of(),s();var xA=5e3;function SA(){let{addNotification:e}=Au(),t=Qs(),[n,r]=Q.useState(()=>a(`true`)),i=Q.useRef(new Set),o=Q.useCallback((n,r)=>{let a=`${n}:${r}`;if(i.current.has(a))return;i.current.add(a),Y(`LSP error: ${n} - ${r}`),t(e=>{let t=new Set(e.plugins.errors.map(e=>e.type===`generic-error`?`generic-error:${e.source}:${e.error}`:`${e.type}:${e.source}`)),i=`generic-error:${n}:${r}`;return t.has(i)?e:{...e,plugins:{...e.plugins,errors:[...e.plugins.errors,{type:`generic-error`,source:n,error:r}]}}});let o=n.startsWith(`plugin:`)?n.split(`:`)[1]??n:n;e({key:`lsp-error-${n}`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(T,{color:`error`,children:[`LSP for `,o,` failed`]}),(0,$.jsx)(T,{dimColor:!0,children:` · /plugin for details`})]}),priority:`medium`,timeoutMs:8e3})},[e,t]),s=Q.useCallback(()=>{if(ke()||Ke())return;let e=xc();if(e.status===`failed`){o(`lsp-manager`,e.error.message),r(!1);return}if(e.status===`pending`||e.status===`not-started`)return;let t=lc();if(t){let e=t.getAllServers();for(let[t,n]of e)n.state===`error`&&n.lastError&&o(t,n.lastError.message)}},[o]);ne(s,n?xA:null),Q.useEffect(()=>{ke()||!n||s()},[s,n])}of();var CA=new Map;async function wA(e){if(!e||!e.trim())return Y(`[binaryCheck] Empty command provided, returning false`),!1;let t=e.trim(),n=CA.get(t);if(n!==void 0)return Y(`[binaryCheck] Cache hit for '${t}': ${n}`),n;let r=!1;return await cp(t).catch(()=>null)&&(r=!0),CA.set(t,r),Y(`[binaryCheck] Binary '${t}' ${r?`found`:`not found`}`),r}Vf(),of(),no();var TA=5;function EA(e){return Mf.has(e.toLowerCase())}function DA(e){if(!e)return null;if(typeof e==`string`)return Y(`[lspRecommendation] Skipping string path lspServers (not readable from marketplace)`),null;if(Array.isArray(e)){for(let t of e){if(typeof t==`string`)continue;let e=kA(t);if(e)return e}return null}return kA(e)}function OA(e){return typeof e==`object`&&!!e}function kA(e){let t=new Set,n=null;for(let[r,i]of Object.entries(e)){if(!OA(i))continue;!n&&typeof i.command==`string`&&(n=i.command);let e=i.extensionToLanguage;if(OA(e))for(let n of Object.keys(e))t.add(n.toLowerCase())}return!n||t.size===0?null:{extensions:t,command:n}}async function AA(){let e=new Map;try{let t=await ar();for(let n of Object.keys(t))try{let t=await ma(n),r=EA(n);for(let i of t.plugins){if(!i.lspServers)continue;let t=DA(i.lspServers);if(!t)continue;let a=`${i.name}@${n}`;e.set(a,{entry:i,marketplaceName:n,extensions:t.extensions,command:t.command,isOfficial:r})}}catch(e){Y(`[lspRecommendation] Failed to load marketplace ${n}: ${e}`)}}catch(e){Y(`[lspRecommendation] Failed to load marketplaces config: ${e}`)}return e}async function jA(e){if(PA())return Y(`[lspRecommendation] Recommendations are disabled`),[];let t=Mv(e).toLowerCase();if(!t)return Y(`[lspRecommendation] No file extension found`),[];Y(`[lspRecommendation] Looking for LSP plugins for ${t}`);let n=await AA(),r=Bf().lspRecommendationNeverPlugins??[],i=[];for(let[e,a]of n)if(a.extensions.has(t)){if(r.includes(e)){Y(`[lspRecommendation] Skipping ${e} (in never suggest list)`);continue}if(Mt(e)){Y(`[lspRecommendation] Skipping ${e} (already installed)`);continue}i.push({info:a,pluginId:e})}let a=[];for(let{info:e,pluginId:t}of i)await wA(e.command)?(a.push({info:e,pluginId:t}),Y(`[lspRecommendation] Binary '${e.command}' found for ${t}`)):Y(`[lspRecommendation] Skipping ${t} (binary '${e.command}' not found)`);return a.sort((e,t)=>e.info.isOfficial&&!t.info.isOfficial?-1:!e.info.isOfficial&&t.info.isOfficial?1:0),a.map(({info:e,pluginId:t})=>({pluginId:t,pluginName:e.entry.name,marketplaceName:e.marketplaceName,description:e.entry.description,isOfficial:e.isOfficial,extensions:Array.from(e.extensions),command:e.command}))}function MA(e){zf(t=>{let n=t.lspRecommendationNeverPlugins??[];return n.includes(e)?t:{...t,lspRecommendationNeverPlugins:[...n,e]}}),Y(`[lspRecommendation] Added ${e} to never suggest`)}function NA(){zf(e=>{let t=(e.lspRecommendationIgnoredCount??0)+1;return{...e,lspRecommendationIgnoredCount:t}}),Y(`[lspRecommendation] Incremented ignored count`)}function PA(){let e=Bf();return e.lspRecommendationDisabled===!0||(e.lspRecommendationIgnoredCount??0)>=TA}u(),rt(),B(),ap(),no();function FA(){let[e,t]=Q.useState(null),n=Q.useRef(!1),r=Q.useCallback(r=>{ke()||e||n.current||(n.current=!0,r().then(e=>{e&&t(e)}).catch(X).finally(()=>{n.current=!1}))},[e]);return{recommendation:e,clearRecommendation:Q.useCallback(()=>t(null),[]),tryResolve:r}}async function IA(e,t,n,r,i){try{let a=await qt(e);if(!a)throw Error(`Plugin ${e} not found in marketplace`);await i(a),r({key:`${n}-installed`,jsx:(0,$.jsxs)(T,{color:`success`,children:[d.tick,` `,t,` installed · restart to apply`]}),priority:`immediate`,timeoutMs:5e3})}catch(e){X(e),r({key:`${n}-install-failed`,jsx:(0,$.jsxs)(T,{color:`error`,children:[`Failed to install `,t]}),priority:`immediate`,timeoutMs:5e3})}}rt(),Ll(),q(),Vf(),of(),ap(),Nf();var LA=28e3;function RA(){let e=J(e=>e.fileHistory.trackedFiles),{addNotification:t}=Au(),n=Q.useRef(new Set),{recommendation:r,clearRecommendation:i,tryResolve:a}=FA();return Q.useEffect(()=>{a(async()=>{if(Qe())return null;let t=[];for(let r of e)n.current.has(r)||(n.current.add(r),t.push(r));for(let e of t)try{let t=(await jA(e))[0];if(t)return Y(`[useLspPluginRecommendation] Found match: ${t.pluginName} for ${e}`),Pe(!0),{pluginId:t.pluginId,pluginName:t.pluginName,pluginDescription:t.description,fileExtension:Mv(e),shownAt:Date.now()}}catch(e){X(e)}return null})},[e,a]),{recommendation:r,handleResponse:Q.useCallback(e=>{if(!r)return;let{pluginId:n,pluginName:a,shownAt:o}=r;switch(Y(`[useLspPluginRecommendation] User response: ${e} for ${a}`),e){case`yes`:IA(n,a,`lsp-plugin`,t,async e=>{Y(`[useLspPluginRecommendation] Installing plugin: ${n}`);let t=typeof e.entry.source==`string`?Nv(e.marketplaceInstallLocation,e.entry.source):void 0;await dc(n,e.entry,`user`,void 0,t),Lf(`userSettings`,{enabledPlugins:{...Of(`userSettings`)?.enabledPlugins,[n]:!0}}),Y(`[useLspPluginRecommendation] Plugin installed: ${n}`)});break;case`no`:{let e=Date.now()-o;e>=LA&&(Y(`[useLspPluginRecommendation] Timeout detected (${e}ms), incrementing ignored count`),NA());break}case`never`:MA(n);break;case`disable`:zf(e=>e.lspRecommendationDisabled?e:{...e,lspRecommendationDisabled:!0});break}i()},[r,t,i])}}B(),Pi(),n_();var zA=3e4;function BA({pluginName:e,pluginDescription:t,fileExtension:n,onResponse:r}){let i=Q.useRef(r);i.current=r,Q.useEffect(()=>{let e=setTimeout(e=>e.current(`no`),zA,i);return()=>clearTimeout(e)},[]);function a(e){switch(e){case`yes`:r(`yes`);break;case`no`:r(`no`);break;case`never`:r(`never`);break;case`disable`:r(`disable`);break}}return(0,$.jsx)(i_,{title:`LSP Plugin Recommendation`,children:(0,$.jsxs)(b,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsx)(b,{marginBottom:1,children:(0,$.jsx)(T,{dimColor:!0,children:`LSP provides code intelligence like go-to-definition and error checking`})}),(0,$.jsxs)(b,{children:[(0,$.jsx)(T,{dimColor:!0,children:`Plugin:`}),(0,$.jsxs)(T,{children:[` `,e]})]}),t&&(0,$.jsx)(b,{children:(0,$.jsx)(T,{dimColor:!0,children:t})}),(0,$.jsxs)(b,{children:[(0,$.jsx)(T,{dimColor:!0,children:`Triggered by:`}),(0,$.jsxs)(T,{children:[` `,n,` files`]})]}),(0,$.jsx)(b,{marginTop:1,children:(0,$.jsx)(T,{children:`Would you like to install this LSP plugin?`})}),(0,$.jsx)(b,{children:(0,$.jsx)(pi,{options:[{label:(0,$.jsxs)(T,{children:[`Yes, install `,(0,$.jsx)(T,{bold:!0,children:e})]}),value:`yes`},{label:`No, not now`,value:`no`},{label:(0,$.jsxs)(T,{children:[`Never for `,(0,$.jsx)(T,{bold:!0,children:e})]}),value:`never`},{label:`Disable all LSP recommendations`,value:`disable`}],onChange:a,onCancel:()=>r(`no`)})})]})})}Ll(),Cp(),of(),cd();function VA(){let e=Q.useSyncExternalStore(Fs,ws),{addNotification:t}=Au(),{recommendation:n,clearRecommendation:r,tryResolve:i}=FA();return Q.useEffect(()=>{e&&i(async()=>{let t=await Mc(e);return t&&(Y(`[useClaudeCodeHintRecommendation] surfacing ${t.pluginId} from ${t.sourceCommand}`),ed()),ws()===e&&Iu(),t})},[e,i]),{recommendation:n,handleResponse:Q.useCallback(e=>{if(n){switch(Su(n.pluginId),Z(`tengu_plugin_hint_response`,{_PROTO_plugin_name:n.pluginName,_PROTO_marketplace_name:n.marketplaceName,response:e}),e){case`yes`:{let{pluginId:e,pluginName:r,marketplaceName:i}=n;IA(e,r,`hint-plugin`,t,async t=>{let n=await Dd({pluginId:e,entry:t.entry,marketplaceName:i,scope:`user`,trigger:`hint`});if(!n.success)throw Error(n.success?`Unknown error`:n.error)});break}case`disable`:Wu();break;case`no`:break}r()}},[n,t,r])}}B(),Pi(),n_();var HA=3e4;function UA({pluginName:e,pluginDescription:t,marketplaceName:n,sourceCommand:r,onResponse:i}){let a=Q.useRef(i);a.current=i,Q.useEffect(()=>{let e=setTimeout(e=>e.current(`no`),HA,a);return()=>clearTimeout(e)},[]);function o(e){switch(e){case`yes`:i(`yes`);break;case`disable`:i(`disable`);break;default:i(`no`)}}return(0,$.jsx)(i_,{title:`Plugin Recommendation`,children:(0,$.jsxs)(b,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsx)(b,{marginBottom:1,children:(0,$.jsxs)(T,{dimColor:!0,children:[`The `,(0,$.jsx)(T,{bold:!0,children:r}),` command suggests installing a plugin.`]})}),(0,$.jsxs)(b,{children:[(0,$.jsx)(T,{dimColor:!0,children:`Plugin:`}),(0,$.jsxs)(T,{children:[` `,e]})]}),(0,$.jsxs)(b,{children:[(0,$.jsx)(T,{dimColor:!0,children:`Marketplace:`}),(0,$.jsxs)(T,{children:[` `,n]})]}),t&&(0,$.jsx)(b,{children:(0,$.jsx)(T,{dimColor:!0,children:t})}),(0,$.jsx)(b,{marginTop:1,children:(0,$.jsx)(T,{children:`Would you like to install it?`})}),(0,$.jsx)(b,{children:(0,$.jsx)(pi,{options:[{label:(0,$.jsxs)(T,{children:[`Yes, install `,(0,$.jsx)(T,{bold:!0,children:e})]}),value:`yes`},{label:`No`,value:`no`},{label:`No, and don't show plugin installation hints again`,value:`disable`}],onChange:o,onCancel:()=>i(`no`)})})]})})}Pi(),n_();var WA=3e4;function GA({tools:e,onSelect:t,onDismiss:n}){let r=Q.useRef(t),i=Q.useRef(n);r.current=t,i.current=n,Q.useEffect(()=>{let e=setTimeout(e=>e.current(),WA,i);return()=>clearTimeout(e)},[]);let a=e.map(e=>({label:`${e.name} — ${e.description.slice(0,60)} (score: ${e.score.toFixed(2)})`,value:e.name}));return a.push({label:`Dismiss`,value:`__dismiss__`}),(0,$.jsx)(i_,{title:`Tool Recommendation`,children:(0,$.jsx)(pi,{options:a,onChange:e=>{e===`__dismiss__`?i.current():(i.current(),r.current(e))}})})}mo();var KA=.15,qA=3;function JA(){let e=Q.useSyncExternalStore(Hn,La),t=Q.useMemo(()=>e.length===0?[]:e.slice(0,qA).map(e=>({name:e.name,description:e.description.slice(0,60),score:e.score})),[e]);return{tools:t,visible:t.length>0&&(t[0]?.score??0)>=KA,handleSelect:Q.useCallback(e=>{rr()},[]),handleDismiss:Q.useCallback(()=>{rr()},[])}}rt(),Ll(),B(),q(),of(),Up();function YA(){let{addNotification:e}=Au(),t=J(e=>e.plugins.installationStatus),{totalFailed:n,failedMarketplacesCount:r,failedPluginsCount:i}=(0,Q.useMemo)(()=>{if(!t)return{totalFailed:0,failedMarketplacesCount:0,failedPluginsCount:0};let e=t.marketplaces.filter(e=>e.status===`failed`),n=t.plugins.filter(e=>e.status===`failed`);return{totalFailed:e.length+n.length,failedMarketplacesCount:e.length,failedPluginsCount:n.length}},[t]);(0,Q.useEffect)(()=>{if(!ke()){if(!t){Y(`No installation status to monitor`);return}n!==0&&(Y(`Plugin installation status: ${r} failed marketplaces, ${i} failed plugins`),n!==0&&(Y(`Adding notification for ${n} failed installations`),e({key:`plugin-install-failed`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(T,{color:`error`,children:[n,` `,Hp(n,`plugin`),` failed to install`]}),(0,$.jsx)(T,{dimColor:!0,children:` · /plugin for details`})]}),priority:`medium`})))}},[e,n,r,i])}rt(),Ll(),B(),of(),G_();function XA(){let{addNotification:e}=Au(),[t,n]=(0,Q.useState)([]);(0,Q.useEffect)(()=>{if(!ke())return K_(e=>{Y(`Plugin autoupdate notification: ${e.length} plugin(s) updated`),n(e)})},[]),(0,Q.useEffect)(()=>{if(ke()||t.length===0)return;let n=t.map(e=>{let t=e.indexOf(`@`);return t>0?e.substring(0,t):e}),r=n.length<=2?n.join(` and `):`${n.length} plugins`;e({key:`plugin-autoupdate-restart`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(T,{color:`success`,children:[n.length===1?`Plugin`:`Plugins`,` updated: `,r]}),(0,$.jsx)(T,{dimColor:!0,children:` · Run /reload-plugins to apply`})]}),priority:`low`,timeoutMs:1e4}),Y(`Showing plugin autoupdate notification for: ${n.join(`, `)}`)},[t,e])}of(),ap(),no(),Rg(),Cp();function ZA(e,t,n,r){e(e=>({...e,plugins:{...e.plugins,installationStatus:{...e.plugins.installationStatus,marketplaces:e.plugins.installationStatus.marketplaces.map(e=>e.name===t?{...e,status:n,error:r}:e)}}}))}async function QA(e){Y(`performBackgroundPluginInstallations called`);try{let t=_g($r(),await ar().catch(()=>({}))),n=[...t.missing,...t.sourceChanged.map(e=>e.name)];if(e(e=>({...e,plugins:{...e.plugins,installationStatus:{marketplaces:n.map(e=>({name:e,status:`pending`})),plugins:[]}}})),n.length===0)return;Y(`Installing ${n.length} marketplace(s) in background`);let r=await hg({onProgress:t=>{switch(t.type){case`installing`:ZA(e,t.name,`installing`);break;case`installed`:ZA(e,t.name,`installed`);break;case`failed`:ZA(e,t.name,`failed`,t.error);break}}}),i={installed_count:r.installed.length,updated_count:r.updated.length,failed_count:r.failed.length,up_to_date_count:r.upToDate.length};if(Z(`tengu_marketplace_background_install`,i),Wf(`info`,`tengu_marketplace_background_install`,i),r.installed.length>0){G(),Y(`Auto-refreshing plugins after ${r.installed.length} new marketplace(s) installed`);try{await Lg(e)}catch(t){X(t),Y(`Auto-refresh failed, falling back to needsRefresh: ${t}`,{level:`warn`}),Es(`performBackgroundPluginInstallations: auto-refresh failed`),e(e=>e.plugins.needsRefresh?e:{...e,plugins:{...e.plugins,needsRefresh:!0}})}}else r.updated.length>0&&(G(),Es(`performBackgroundPluginInstallations: marketplaces reconciled`),e(e=>e.plugins.needsRefresh?e:{...e,plugins:{...e.plugins,needsRefresh:!0}}))}catch(e){X(e)}}Vf(),of(),no(),ic();async function $A(e){if(Y(`performStartupChecks called`),!Uf()){Y(`Trust not accepted for current directory - skipping plugin installations`);return}try{Y(`Starting background plugin installations`),await Br()&&(G(),Es(`performStartupChecks: seed marketplaces changed`),e(e=>e.plugins.needsRefresh?e:{...e,plugins:{...e.plugins,needsRefresh:!0}})),await QA(e)}catch(e){Y(`Error initiating background plugin installations: ${e}`)}}B();var ej=/https?:\/\/\S+/;function tj(){let[e,t]=(0,Q.useState)(nm.getInstance().getStatus());return(0,Q.useEffect)(()=>nm.getInstance().subscribe(t),[]),!e.isAuthenticating&&!e.error&&e.output.length===0||!e.isAuthenticating&&!e.error?null:(0,$.jsxs)(b,{flexDirection:`column`,borderStyle:`round`,borderColor:`permission`,paddingX:1,marginY:1,children:[(0,$.jsx)(T,{bold:!0,color:`permission`,children:`Cloud Authentication`}),e.output.length>0&&(0,$.jsx)(b,{flexDirection:`column`,marginTop:1,children:e.output.slice(-5).map((e,t)=>{let n=e.match(ej);if(!n)return(0,$.jsx)(T,{dimColor:!0,children:e},t);let r=n[0],i=n.index??0,a=e.slice(0,i),o=e.slice(i+r.length);return(0,$.jsxs)(T,{dimColor:!0,children:[a,(0,$.jsx)(C,{url:r,children:r}),o]},t)})}),e.error&&(0,$.jsx)(b,{marginTop:1,children:(0,$.jsx)(T,{color:`error`,children:e.error})})]})}Ll(),B(),Rl(),xu(),am(),fm(),rt();function nj(e){let{addNotification:t}=Au(),n=jc(),r=(0,Q.useMemo)(()=>xs(n,e),[n,e]),i=(0,Q.useMemo)(()=>ol(n),[n]),a=(0,Q.useRef)(null),o=Qp(),s=Dm(),c=o===`team`||o===`enterprise`,[l,u]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{ke()||(n.isUsingOverage&&!l&&(!c||s)?(t({key:`limit-reached`,text:i,priority:`immediate`}),u(!0)):!n.isUsingOverage&&l&&u(!1))},[n.isUsingOverage,i,l,t,s,c]),(0,Q.useEffect)(()=>{ke()||r&&r!==a.current&&(a.current=r,t({key:`rate-limit-warning`,jsx:(0,$.jsx)(T,{children:(0,$.jsx)(T,{color:`warning`,children:r})}),priority:`high`}))},[r,t])}Ll(),rt();function rj(e){let{addNotification:t}=Au(),n=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{if(ke())return;let r=_v(e);r&&r!==n.current&&(n.current=r,t({key:`model-deprecation-warning`,text:r,color:`warning`,priority:`high`})),r||(n.current=null)},[e,t])}s();var ij=``;function aj(){Qk(async()=>Rp()||a(process.env.DISABLE_INSTALLATION_CHECKS)||await og()===`development`?null:{timeoutMs:15e3,key:`npm-deprecation-warning`,text:ij,color:`warning`,priority:`high`})}Ll(),B(),Vf(),Ei(),rt();var oj=5;function sj({ideSelection:e,mcpClients:t,ideInstallationStatus:n}){let{addNotification:r,removeNotification:i}=Au(),{status:a,ideName:o}=vC(t),s=(0,Q.useRef)(!1),c=n?Vc(n?.ideType):!1,l=n?.error||c,u=a===`connected`&&(e?.filePath||e?.text&&e.lineCount>0),d=a===`connected`&&!u,f=l&&!c&&!d&&!u,p=l&&c&&!d&&!u;(0,Q.useEffect)(()=>{if(ke())return;if(gi()||a!==null||p){i(`ide-status-hint`);return}if(s.current||(Bf().ideHintShownCount??0)>=oj)return;let e=setTimeout((e,t)=>{hs(!0).then(n=>{let r=n[0]?.name;r&&!e.current&&(e.current=!0,zf(e=>({...e,ideHintShownCount:(e.ideHintShownCount??0)+1})),t({key:`ide-status-hint`,jsx:(0,$.jsxs)(T,{dimColor:!0,children:[`/ide for `,(0,$.jsx)(T,{color:`ide`,children:r})]}),priority:`low`}))})},3e3,s,r);return()=>clearTimeout(e)},[r,i,a,p]),(0,Q.useEffect)(()=>{if(!ke()){if(f||p||a!==`disconnected`||!o){i(`ide-status-disconnected`);return}r({key:`ide-status-disconnected`,text:`${o} disconnected`,color:`error`,priority:`medium`})}},[r,i,a,o,f,p]),(0,Q.useEffect)(()=>{if(!ke()){if(!p){i(`ide-status-jetbrains-disconnected`);return}r({key:`ide-status-jetbrains-disconnected`,text:`IDE plugin not connected · /status for info`,priority:`medium`})}},[r,i,p]),(0,Q.useEffect)(()=>{if(!ke()){if(!f){i(`ide-status-install-error`);return}r({key:`ide-status-install-error`,text:`IDE extension install failed (see /status for info)`,color:`error`,priority:`medium`})}},[r,i,f])}Vf();var cj=[e=>{if(uj(e.sonnet45To46MigrationTimestamp))return{key:`sonnet-46-update`,text:`Model updated to Sonnet 4.6`,color:`suggestion`,priority:`high`,timeoutMs:3e3}},e=>{let t=!!e.legacyOpusMigrationTimestamp;if(uj(e.legacyOpusMigrationTimestamp??e.opusProMigrationTimestamp))return{key:`opus-pro-update`,text:t?`Model updated to Opus 4.7 · Set CLAUDE_CODE_DISABLE_LEGACY_MODEL_REMAP=1 to opt out`:`Model updated to Opus 4.7`,color:`suggestion`,priority:`high`,timeoutMs:t?8e3:3e3}}];function lj(){Qk(()=>{let e=Bf(),t=[];for(let n of cj){let r=n(e);r&&t.push(r)}return t.length>0?t:null})}function uj(e){return e!==void 0&&Date.now()-e<3e3}am(),B(),Cp(),Vf();var dj=3;function fj(){Qk(async()=>{if((Bf().subscriptionNoticeCount??0)>=dj)return null;let e=await pj();return e===null?null:(zf(e=>({...e,subscriptionNoticeCount:(e.subscriptionNoticeCount??0)+1})),Z(`tengu_switch_to_subscription_notice_shown`,{}),{key:`switch-to-subscription`,jsx:(0,$.jsxs)(T,{color:`suggestion`,children:[`Use your existing Claude `,e,` plan with Claude Code`,(0,$.jsxs)(T,{color:`text`,dimColor:!0,children:[` `,`· /login to activate`]})]}),priority:`low`})})}async function pj(){if($p())return null;let e=await om();return e?e.account.has_claude_max?`Max`:e.account.has_claude_pro?`Pro`:null:null}Ll(),q(),Pm(),kp(),rt();var mj=`fast-mode-cooldown-started`,hj=`fast-mode-cooldown-expired`,gj=`fast-mode-org-changed`,_j=`fast-mode-overage-rejected`;function vj(){let{addNotification:e}=Au(),t=J(e=>e.fastMode),n=Qs();(0,Q.useEffect)(()=>{if(!ke()&&bm())return Sm(r=>{r?e({key:gj,color:`fastMode`,priority:`immediate`,text:`Fast mode is now available · /fast to turn on`}):t&&(n(e=>({...e,fastMode:!1})),e({key:gj,color:`warning`,priority:`immediate`,text:`Fast mode has been disabled by your organization`}))})},[e,t,n]),(0,Q.useEffect)(()=>{if(!ke()&&bm())return mm(t=>{n(e=>({...e,fastMode:!1})),e({key:_j,color:`warning`,priority:`immediate`,text:t})})},[e,n]),(0,Q.useEffect)(()=>{if(ke()||!t)return;let n=Nm((t,n)=>{let r=yj(n,Mp(t-Date.now(),{hideTrailingZeros:!0}));e({key:mj,invalidates:[hj],text:r,color:`warning`,priority:`immediate`})}),r=Om(()=>{e({key:hj,invalidates:[mj],color:`fastMode`,text:`Fast limit reset · now using fast mode`,priority:`immediate`})});return()=>{n(),r()}},[e,t])}function yj(e,t){switch(e){case`overloaded`:return`Fast mode overloaded and is temporarily unavailable · resets in ${t}`;case`rate_limit`:return`Fast limit reached and temporarily disabled · resets in ${t}`}}B(),zh();function bj({onRun:e,onCancel:t,reason:n}){let r=(0,Q.useRef)(!1);return j(`confirm:no`,t,{context:`Confirmation`}),(0,Q.useEffect)(()=>{r.current||(r.current=!0,e())},[e]),(0,$.jsxs)(b,{flexDirection:`column`,marginTop:1,children:[(0,$.jsx)(b,{children:(0,$.jsx)(T,{bold:!0,children:`Running feedback capture...`})}),(0,$.jsx)(b,{children:(0,$.jsxs)(T,{dimColor:!0,children:[`Press `,(0,$.jsx)(h,{shortcut:`Esc`,action:`cancel`}),` anytime`]})}),(0,$.jsx)(b,{children:(0,$.jsxs)(T,{dimColor:!0,children:[`Reason: `,n]})})]})}function xj(e){if(process.env.USER_TYPE!==`ant`)return!1;switch(e){case`feedback_survey_bad`:return!1;case`feedback_survey_good`:return!1;default:return!1}}function Sj(e){return process.env.USER_TYPE===`ant`&&e===`feedback_survey_good`?`/good-claude`:`/issue`}function Cj(e){switch(e){case`feedback_survey_bad`:return`You responded "Bad" to the feedback survey`;case`feedback_survey_good`:return`You responded "Good" to the feedback survey`;default:return`Unknown reason`}}var wj=()=>null;vf(),B();function Tj(){return process.env.USER_TYPE===`ant`?(0,$.jsxs)(b,{flexDirection:`row`,marginTop:1,width:`100%`,children:[(0,$.jsx)(b,{minWidth:2,children:(0,$.jsx)(T,{color:`warning`,children:`⚑`})}),(0,$.jsxs)(T,{children:[(0,$.jsx)(T,{dimColor:!0,children:`[ANT-ONLY] `}),(0,$.jsx)(T,{color:`warning`,bold:!0,children:`Something off with Claude?`}),(0,$.jsx)(T,{dimColor:!0,children:` /issue to report it`})]})]}):null}Zm(),Vd();var Ej=[/\bcurl\b/,/\bwget\b/,/\bssh\b/,/\bkubectl\b/,/\bsrun\b/,/\bdocker\b/,/\bbq\b/,/\bgsutil\b/,/\bgcloud\b/,/\baws\b/,/\bgit\s+push\b/,/\bgit\s+pull\b/,/\bgit\s+fetch\b/,/\bgh\s+(pr|issue)\b/,/\bnc\b/,/\bncat\b/,/\btelnet\b/,/\bftp\b/],Dj=[/^no[,!]\s/i,/\bthat'?s (wrong|incorrect|not (what|right|correct))\b/i,/\bnot what I (asked|wanted|meant|said)\b/i,/\bI (said|asked|wanted|told you|already said)\b/i,/\bwhy did you\b/i,/\byou should(n'?t| not)? have\b/i,/\byou were supposed to\b/i,/\btry again\b/i,/\b(undo|revert) (that|this|it|what you)\b/i];function Oj(e){for(let t of e){if(t.type!==`assistant`)continue;let e=t.message.content;if(Array.isArray(e))for(let t of e){if(t.type!==`tool_use`||!(`name`in t))continue;let e=t.name;if(e.startsWith(`mcp__`))return!1;if(e===`Bash`){let e=t.input?.command||``;if(Ej.some(t=>t.test(e)))return!1}}}return!0}function kj(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n.type!==`user`)continue;let r=Mn(n);if(r)return Dj.some(e=>e.test(r))}return!1}var Aj=3,jj=1800*1e3;function Mj(e,t){let n=(0,Q.useRef)(0),r=(0,Q.useRef)(-1),i=(0,Q.useMemo)(()=>Oj(e)&&kj(e),[e]);return process.env.USER_TYPE===`ant`?r.current===t?!0:Date.now()-n.current<jj||t<Aj||!i?!1:(n.current=Date.now(),r.current=t,!0):!1}rt(),B();function Nj(){return process.env.USER_TYPE===`ant`}function Pj(){let[e,t]=(0,Q.useState)(_t);return ae(()=>{t(_t())},Nj()?500:null),!Nj()||e.length===0?null:(0,$.jsxs)(T,{wrap:`truncate-end`,color:`warning`,children:[`[ANT-ONLY] slow sync: `,e.slice(-3).map(e=>`${e.operation} (${Math.round(e.durationMs)}ms)`).join(` · `)]})}u(),B(),wa(),Pi(),Zh(),q(),rt(),m_(),Vd(),jr(),qd(),fp(),Wc(),Gr();var Fj=24,Ij=11;function Lj(){return new Date().toISOString().split(`T`)[0]}function Rj({plan:e,sessionId:t,taskId:n,setMessages:r,readFileState:i,memorySelector:a,getAppState:o,setConversationId:s,resultDedupState:c}){Rt(`ultraplan-choice`);let l=Qs(),{rows:u,columns:f}=de(),p=Q.useMemo(()=>Math.min(Fj,Math.max(1,Math.floor(u/2)-Ij)),[u]),m=Q.useMemo(()=>w(e,Math.max(1,f-4),`wrap`).split(`
|
|
84
|
+
`),Ts(e?.())};return process.on(`exit`,t),()=>{process.off(`exit`,t)}},[])}s();function PO(){(0,Q.useEffect)(()=>{process.env.USER_TYPE===`ant`&&a(process.env.CLAUDE_CODE_EXIT_AFTER_FIRST_RENDER)&&(process.stderr.write(`\nStartup time: ${Math.round(process.uptime()*1e3)}ms\n`),process.exit(0))},[])}function FO(e,t){let n=(0,Q.useRef)(e??null),r=(0,Q.useRef)(!e);return(0,Q.useEffect)(()=>{let e=n.current;if(!e)return;let i=!1;return e.then(e=>{i||(r.current=!0,n.current=null,e.length>0&&t(t=>[...e,...t]))}),()=>{i=!0}},[t]),(0,Q.useCallback)(async()=>{if(r.current||!n.current)return;let e=await n.current;r.current||(r.current=!0,n.current=null,e.length>0&&t(t=>[...e,...t]))},[t])}rt(),qs(),am();function IO(){let[e,t]=(0,Q.useState)(()=>{if(!rm()||$p())return`valid`;let{key:e,source:t}=qp({skipRetrievingKeyFromApiKeyHelper:!0});return e||t===`apiKeyHelper`?`loading`:`missing`}),[n,r]=(0,Q.useState)(null);return{status:e,reverify:(0,Q.useCallback)(async()=>{if(!rm()||$p()){t(`valid`);return}await Im(vt());let{key:e,source:n}=qp();if(!e){if(n===`apiKeyHelper`){t(`error`),r(Error(`API key helper did not return a valid key`));return}t(`missing`);return}try{let n=await Fc(e,!1)?`valid`:`invalid`;t(n);return}catch(e){r(e),t(`error`);return}},[]),error:n}}rt(),B(),qd(),of(),B(),zh(),Cp(),q();function LO({screen:t,setScreen:n,showAllInTranscript:r,setShowAllInTranscript:i,messageCount:a,onEnterTranscript:o,onExitTranscript:s,virtualScrollActive:c,searchBarOpen:l=!1}){let u=J(e=>e.expandedView),d=Qs(),f=(0,Q.useCallback)(()=>{Z(`tengu_toggle_todos`,{is_expanded:u===`tasks`}),d(e=>({...e,expandedView:e.expandedView===`tasks`?`none`:`tasks`}))},[u,d]),p=J(e=>e.isBriefOnly),m=(0,Q.useCallback)(()=>{{let{isBriefEnabled:n}=(ss(),e(Ac));if(!n()&&p&&t!==`transcript`){d(e=>e.isBriefOnly?{...e,isBriefOnly:!1}:e);return}}let c=t!==`transcript`;Z(`tengu_toggle_transcript`,{is_entering:c,show_all:r,message_count:a}),n(e=>e===`transcript`?`prompt`:`transcript`),i(!1),c&&o&&o(),!c&&s&&s()},[t,n,p,r,i,a,d,o,s]),h=(0,Q.useCallback)(()=>{Z(`tengu_transcript_toggle_show_all`,{is_expanding:!r,message_count:a}),i(e=>!e)},[r,i,a]),g=(0,Q.useCallback)(()=>{Z(`tengu_transcript_exit`,{show_all:r,message_count:a}),n(`prompt`),i(!1),s&&s()},[n,r,i,a,s]),_=(0,Q.useCallback)(()=>{{let{isBriefEnabled:t}=(ss(),e(Ac));if(!t()&&!p)return;let n=!p;Z(`tengu_brief_mode_toggled`,{enabled:n,gated:!1,source:`keybinding`}),d(e=>e.isBriefOnly===n?e:{...e,isBriefOnly:n})}},[p,d]);j(`app:toggleTodos`,f,{context:`Global`}),j(`app:toggleTranscript`,m,{context:`Global`}),j(`app:toggleBrief`,_,{context:`Global`,isActive:!0}),j(`app:toggleTerminal`,(0,Q.useCallback)(()=>{},[]),{context:`Global`}),j(`app:redraw`,(0,Q.useCallback)(()=>{D.get(process.stdout)?.forceRedraw()},[]),{context:`Global`});let v=t===`transcript`;return j(`transcript:toggleShowAll`,h,{context:`Transcript`,isActive:v&&!c}),j(`transcript:exit`,g,{context:`Transcript`,isActive:v&&!l}),null}Gr(),zn(),zh();var RO={setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}};function zO({onSubmit:e,isActive:t=!0}){let n=P(),r=ca(),i=(0,Q.useMemo)(()=>{if(!n)return new Set;let e=new Set;for(let t of n.bindings)t.action?.startsWith(`command:`)&&e.add(t.action);return e},[n]);return v((0,Q.useMemo)(()=>{let t={};for(let n of i){let r=n.slice(8);t[n]=()=>{e(`/${r}`,RO,void 0,{fromKeybinding:!0})}}return t},[i,e]),{context:`Chat`,isActive:t&&!r}),null}Cp(),q(),U_(),Ll(),Gr(),mu(),zh(),Nt(),jr();var BO=3e3;function VO(e){let{setToolUseConfirmQueue:t,onCancel:n,onAgentsKilled:r,isMessageSelectorVisible:i,screen:a,abortSignal:o,popCommandFromQueue:s,vimMode:c,isLocalJSXCommand:l,isSearchingHistory:u,isHelpOpen:d,inputMode:f,inputValue:p,streamMode:m}=e,h=js(),g=Qs(),_=mC().length,{addNotification:v,removeNotification:y}=Au(),b=(0,Q.useRef)(0),x=(0,Q.useCallback)(()=>{let e={source:`escape`,streamMode:m};if(o!==void 0&&!o.aborted){Z(`tengu_cancel`,e),t(()=>[]),n();return}if(pu()&&s){s();return}Z(`tengu_cancel`,e),t(()=>[]),n()},[o,s,t,n,m]),S=Pd(),C=o!==void 0&&!o.aborted,w=_>0,T=f!==void 0&&f!==`prompt`&&!p,E=a!==`transcript`&&!u&&!i&&!l&&!d&&!S&&!(B_()&&c===`INSERT`),D=E&&(C||w)&&!T,O=E&&(C||w);j(`chat:cancel`,x,{context:`Chat`,isActive:D});let k=(0,Q.useCallback)(()=>{let e=h.getState().tasks,t=Object.entries(e).filter(([,e])=>e.type===`local_agent`&&e.status===`running`);if(t.length===0)return!1;yi(e,g);let n=[];for(let[e,r]of t)Wi(e,g),n.push(r.description),gh(e,`stopped`,{toolUseId:r.toolUseId,summary:r.description});return sr({value:n.length===1?`Background agent "${n[0]}" was stopped by the user.`:`${n.length} background agents were stopped by the user: ${n.map(e=>`"${e}"`).join(`, `)}.`,mode:`task-notification`}),r(),!0},[h,g,r]);return j(`app:interrupt`,(0,Q.useCallback)(()=>{(C||w)&&x()},[C,w,x]),{context:`Global`,isActive:O}),j(`chat:killAgents`,(0,Q.useCallback)(()=>{let e=h.getState().tasks;if(!Object.values(e).some(e=>e.type===`local_agent`&&e.status===`running`)){v({key:`kill-agents-none`,text:`No background agents running`,priority:`immediate`,timeoutMs:2e3});return}let t=Date.now();if(t-b.current<=BO){b.current=0,y(`kill-agents-confirm`),Z(`tengu_cancel`,{source:`kill_agents`}),ha(),k();return}b.current=t;let n=Hr(`chat:killAgents`,`Chat`,`ctrl+x ctrl+k`);v({key:`kill-agents-confirm`,text:`Press ${n} again to stop background agents`,priority:`immediate`,timeoutMs:BO})},[h,v,y,k]),{context:`Chat`}),null}B(),q(),Dl();function HO(e){let t=J(e=>e.tasks),n=J(e=>e.pipeIpc),r=Object.values(t).some(vu),i=t=>{if(t.shift&&(t.key===`up`||t.key===`down`)){t.preventDefault(),r?e?.onOpenBackgroundTasks?.():t.key===`down`&&n?.statusVisible&&e?.onTogglePipeSelector&&e.onTogglePipeSelector();return}};return oe((e,t,n)=>{i(new A(n.keypress))}),{handleKeyDown:i}}q_(),ap();async function UO(e){let{ctx:t,updatedInput:n,suggestions:r,permissionMode:i}=e;try{let e=await t.runHooks(i,r,n);if(e)return e}catch(e){e instanceof Error?X(e):X(Error(`Automated permission check failed: ${String(e)}`))}return null}var WO=new Map,GO=null;function KO(){return GO??null}function qO(e,t){let n=KO();if(!n)return null;let r=Bv(),i={requestId:r,toolName:e.tool.name,toolUseID:e.toolUseID,description:e.description,input:e.input,permissionResult:e.permissionResult,permissionPromptStartTimeMs:e.permissionPromptStartTimeMs};return WO.set(r,{onResponse:t}),n({type:`permission_request`,data:JSON.stringify(i)}),r}function JO(e){e&&WO.delete(e)}function YO(e,t){if(!e)return;let n=KO();n&&n({type:`permission_cancel`,data:JSON.stringify({requestId:e,reason:t})})}Cp(),eh(),fc(),of(),Td(),Vd(),Lt(),bt();function XO(e){let t=!1,n=!1;return{resolve(r){n||(n=!0,t=!0,e(r))},isResolved(){return t},claim(){return t?!1:(t=!0,!0)}}}function ZO(e,t,n,r,i,a,o){let s=r.message.id;return Object.freeze({tool:e,input:t,toolUseContext:n,assistantMessage:r,messageId:s,toolUseID:i,logDecision(r,a){Ys({tool:e,input:a?.input??t,toolUseContext:n,messageId:s,toolUseID:i},r,a?.permissionPromptStartTimeMs)},logCancelled(){Z(`tengu_tool_use_cancelled`,{messageID:s,toolName:th(e.name)})},async persistPermissions(e){return e.length===0?!1:(Xn(e),a(Ur(n.getAppState().toolPermissionContext,e)),e.some(e=>Ma(e.destination)))},resolveIfAborted(e){return n.abortController.signal.aborted?(this.logCancelled(),e(this.cancelAndAbort(void 0,!0)),!0):!1},cancelAndAbort(t,r,i){let a=!!n.agentId,o=t?`${a?cs:Cu}${t}`:a?Nc:Al,s=a?o:Ks(o);return(r||!t&&!i?.length&&!a)&&(Y(`Aborting: tool=${e.name} isAbort=${r} hasFeedback=${!!t} isSubagent=${a}`),n.abortController.abort()),{behavior:`ask`,message:s,contentBlocks:i}},async runHooks(r,a,o,s){for await(let c of Wn(e.name,i,t,n,r,a,n.abortController.signal))if(c.permissionRequestResult){let r=c.permissionRequestResult;if(r.behavior===`allow`){let e=r.updatedInput??o??t;return await this.handleHookAllow(e,r.updatedPermissions??[],s)}else if(r.behavior===`deny`)return this.logDecision({decision:`reject`,source:{type:`hook`}},{permissionPromptStartTimeMs:s}),r.interrupt&&(Y(`Hook interrupt: tool=${e.name} hookMessage=${r.message}`),n.abortController.abort()),this.buildDeny(r.message||`Permission denied by hook`,{type:`hook`,hookName:`PermissionRequest`,reason:r.message})}return null},buildAllow(e,t){return{behavior:`allow`,updatedInput:e,userModified:t?.userModified??!1,...t?.decisionReason&&{decisionReason:t.decisionReason},...t?.acceptFeedback&&{acceptFeedback:t.acceptFeedback},...t?.contentBlocks&&t.contentBlocks.length>0&&{contentBlocks:t.contentBlocks}}},buildDeny(e,t){return{behavior:`deny`,message:e,decisionReason:t}},async handleUserAllow(n,r,i,a,o,s){let c=await this.persistPermissions(r);this.logDecision({decision:`accept`,source:{type:`user`,permanent:c}},{input:n,permissionPromptStartTimeMs:a});let l=e.inputsEquivalent?!e.inputsEquivalent(t,n):!1,u=i?.trim();return this.buildAllow(n,{userModified:l,decisionReason:s,acceptFeedback:u||void 0,contentBlocks:o})},async handleHookAllow(e,t,n){let r=await this.persistPermissions(t);return this.logDecision({decision:`accept`,source:{type:`hook`,permanent:r}},{input:e,permissionPromptStartTimeMs:n}),this.buildAllow(e,{decisionReason:{type:`hook`,hookName:`PermissionRequest`}})},pushToQueue(e){o?.push(e)},removeFromQueue(){o?.remove(i)},updateQueueItem(e){o?.update(i,e)}})}function QO(e){return{push(t){e(e=>[...e,t])},remove(t){e(e=>e.filter(e=>e.toolUseID!==t))},update(t,n){e(e=>e.map(e=>e.toolUseID===t?{...e,...n}:e))}}}of(),B(),fc(),Et(),ef();function $O(e,t){let{ctx:n,description:r,result:i,awaitAutomatedChecksBeforeDialog:a,bridgeCallbacks:o}=e,{resolve:s,isResolved:c,claim:l}=XO(t),u,d,f=o?Bv():void 0,p=Date.now(),m=i.updatedInput??n.input,h=null;function g(e){YO(h,e),JO(h),h=null}function _(){JO(h),h=null}let v={assistantMessage:n.assistantMessage,tool:n.tool,description:r,input:m,toolUseContext:n.toolUseContext,toolUseID:n.toolUseID,permissionResult:i,permissionPromptStartTimeMs:p,onUserInteraction(){Date.now()-p<200||Qi(n.toolUseID)},onDismissCheckmark(){u&&(clearTimeout(u),u=void 0,d&&(n.toolUseContext.abortController.signal.removeEventListener(`abort`,d),d=void 0),n.removeFromQueue())},onAbort(){l()&&(g(`Permission request was aborted locally in sub.`),o&&f&&(o.sendResponse(f,{behavior:`deny`,message:`User aborted`}),o.cancelRequest(f)),n.logCancelled(),n.logDecision({decision:`reject`,source:{type:`user_abort`}},{permissionPromptStartTimeMs:p}),s(n.cancelAndAbort(void 0,!0)))},async onAllow(e,t,r,a){l()&&(g(`Permission request was approved locally in sub.`),o&&f&&(o.sendResponse(f,{behavior:`allow`,updatedInput:e,updatedPermissions:t}),o.cancelRequest(f)),s(await n.handleUserAllow(e,t,r,p,a,i.decisionReason)))},onReject(e,t){l()&&(g(`Permission request was rejected locally in sub.`),o&&f&&(o.sendResponse(f,{behavior:`deny`,message:e??`User denied permission`}),o.cancelRequest(f)),n.logDecision({decision:`reject`,source:{type:`user_reject`,hasFeedback:!!e}},{permissionPromptStartTimeMs:p}),s(n.cancelAndAbort(e,void 0,t)))},async recheckPermission(){if(c())return;let e=await so(n.tool,n.input,n.toolUseContext,n.assistantMessage,n.toolUseID);if(e.behavior===`allow`){if(!l())return;g(`Permission request was resolved locally in sub.`),o&&f&&o.cancelRequest(f),n.removeFromQueue(),n.logDecision({decision:`accept`,source:`config`}),s(n.buildAllow(e.updatedInput??n.input))}}};if(n.pushToQueue(v),h=qO(v,e=>{l()&&(_(),Qi(n.toolUseID),n.removeFromQueue(),o&&f&&o.cancelRequest(f),e.behavior===`allow`?(async()=>{e.permissionUpdates?.length&&n.persistPermissions(e.permissionUpdates),n.logDecision({decision:`accept`,source:{type:`user`,permanent:!!e.permissionUpdates?.length}},{permissionPromptStartTimeMs:p}),s(n.buildAllow(e.updatedInput??m,{acceptFeedback:e.feedback,contentBlocks:e.contentBlocks}))})():(n.logDecision({decision:`reject`,source:{type:`user_reject`,hasFeedback:!!e.feedback}},{permissionPromptStartTimeMs:p}),s(n.cancelAndAbort(e.feedback,void 0,e.contentBlocks))))}),o&&f){o.sendRequest(f,n.tool.name,m,n.toolUseID,r,i.suggestions,i.blockedPath);let e=n.toolUseContext.abortController.signal,t=o.onResponse(f,r=>{l()&&(g(`Permission request was resolved by bridge before pipe response.`),e.removeEventListener(`abort`,t),Qi(n.toolUseID),n.removeFromQueue(),r.behavior===`allow`?(r.updatedPermissions?.length&&n.persistPermissions(r.updatedPermissions),n.logDecision({decision:`accept`,source:{type:`user`,permanent:!!r.updatedPermissions?.length}},{permissionPromptStartTimeMs:p}),s(n.buildAllow(r.updatedInput??m))):(n.logDecision({decision:`reject`,source:{type:`user_reject`,hasFeedback:!!r.message}},{permissionPromptStartTimeMs:p}),s(n.cancelAndAbort(r.message))))});e.addEventListener(`abort`,t,{once:!0})}a||(async()=>{if(c())return;let e=n.toolUseContext.getAppState(),t=await n.runHooks(e.toolPermissionContext.mode,i.suggestions,i.updatedInput,p);!t||!l()||(g(`Permission request was resolved by hook before pipe response.`),o&&f&&o.cancelRequest(f),n.removeFromQueue(),s(t))})()}Cp(),eh(),B(),fc(),Et(),of(),ef(),ap(),In(),Xd(),bt();function ek(e,t){return(0,Q.useCallback)(async(n,r,i,a,o,s)=>new Promise(c=>{let l=ZO(n,r,i,a,o,t,QO(e));if(!l.resolveIfAborted(c))return(s===void 0?so(n,r,i,a,o):Promise.resolve(s)).then(async e=>{if(process.env.USER_TYPE===`ant`&&Z(`tengu_internal_tool_permission_decision`,{toolName:th(n.name),behavior:e.behavior,input:$d(r),messageID:l.messageId,isMcp:n.isMcp??!1}),e.behavior===`allow`){if(l.resolveIfAborted(c))return;e.decisionReason?.type===`classifier`&&e.decisionReason.classifier===`auto-mode`&&Hs(o,e.decisionReason.reason),l.logDecision({decision:`accept`,source:`config`}),c(l.buildAllow(e.updatedInput??r,{decisionReason:e.decisionReason}));return}let t=i.getAppState(),a=await n.description(r,{isNonInteractiveSession:i.options.isNonInteractiveSession,toolPermissionContext:t.toolPermissionContext,tools:i.options.tools});if(!l.resolveIfAborted(c))switch(e.behavior){case`deny`:Ys({tool:n,input:r,toolUseContext:i,messageId:l.messageId,toolUseID:o},{decision:`reject`,source:`config`}),e.decisionReason?.type===`classifier`&&e.decisionReason.classifier===`auto-mode`&&(J_({toolName:n.name,display:a,reason:e.decisionReason.reason??``,timestamp:Date.now()}),i.addNotification?.({key:`auto-mode-denied`,priority:`immediate`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(T,{color:`error`,children:[n.userFacingName(r).toLowerCase(),` denied by auto mode`]}),(0,$.jsx)(T,{dimColor:!0,children:` · /permissions`})]})})),c(e);return;case`ask`:if(t.toolPermissionContext.awaitAutomatedChecksBeforeDialog){let n=await UO({ctx:l,updatedInput:e.updatedInput,suggestions:e.suggestions,permissionMode:t.toolPermissionContext.mode});if(n){c(n);return}}if(l.resolveIfAborted(c))return;$O({ctx:l,description:a,result:e,awaitAutomatedChecksBeforeDialog:t.toolPermissionContext.awaitAutomatedChecksBeforeDialog,bridgeCallbacks:t.replBridgePermissionCallbacks},c);return}}).catch(e=>{e instanceof af||e instanceof sf?(Y(`Permission check threw ${e.constructor.name} for tool=${n.name}: ${e.message}`),l.logCancelled(),c(l.cancelAndAbort(void 0,!0))):(X(e),c(l.cancelAndAbort(void 0,!0)))}).finally(()=>{Qi(o)})}),[e,t])}mh(),Cp(),Zi(),Ft(),qd(),of(),Si(),ef(),ap(),jr(),lm();function tk(){sn(0)}async function nk(e){let{helpers:t,queryGuard:n,isExternalLoading:r=!1,commands:i,onInputChange:a,setPastedContents:o,setToolJSX:s,getToolUseContext:c,messages:l,mainLoopModel:u,ideSelection:d,setUserInputOnProcessing:f,setAbortController:p,onQuery:m,setAppState:h,onBeforeQuery:g,canUseTool:_,queuedCommands:v,uuid:y,skipSlashCommands:b,bridgeOrigin:x}=e,{setCursorOffset:S,clearBuffer:C,resetHistory:w}=t;if(v?.length){id(),await rk({queuedCommands:v,messages:l,mainLoopModel:u,ideSelection:d,querySource:e.querySource,commands:i,queryGuard:n,setToolJSX:s,getToolUseContext:c,setUserInputOnProcessing:f,setAbortController:p,onQuery:m,setAppState:h,onBeforeQuery:g,resetHistory:w,canUseTool:_,onInputChange:a});return}let T=e.input??``,E=e.mode??`prompt`,D=e.pastedContents??{},O=new Set(li(T).map(e=>e.id)),k=Object.fromEntries(Object.entries(D).filter(([,e])=>e.type!==`image`||O.has(e.id))),A=Object.values(k).some(Fd);if(T.trim()===``)return;if(!b&&[`exit`,`quit`,`:q`,`:q!`,`:wq`,`:wq!`].includes(T.trim())){i.find(e=>e.name===`exit`)?nk({...e,input:`/exit`}):tk();return}let j=ja(T,k),M=li(T).filter(e=>k[e.id]?.type===`text`),N=M.length;if(Z(`tengu_paste_text`,{pastedTextCount:N,pastedTextBytes:M.reduce((e,t)=>e+(k[t.id]?.content.length??0),0)}),!b&&j.trim().startsWith(`/`)){let t=j.trim(),d=t.indexOf(` `),f=d===-1?t.slice(1):t.slice(1,d),p=d===-1?``:t.slice(d+1).trim(),m=i.find(e=>e.immediate&&Zu(e)&&(e.name===f||e.aliases?.includes(f)||Ss(e)===f));if(m&&m.type===`local-jsx`&&(n.isActive||r)){Z(`tengu_immediate_command_executed`,{commandName:m.name}),a(``),S(0),o({}),C();let t=c(l,[],Lc(),u),n=!1,r=await(await m.load()).call((t,r)=>{n=!0,s({jsx:null,shouldHidePromptInput:!1,clearLocalJSX:!0}),t&&r?.display!==`skip`&&e.addNotification&&e.addNotification({key:`immediate-${m.name}`,text:t,priority:`immediate`}),r?.nextInput&&(r.submitNextInput?io({value:r.nextInput,mode:`prompt`}):a(r.nextInput))},t,p);r&&!n&&s({jsx:r,shouldHidePromptInput:!1,isLocalJSXCommand:!0,isImmediate:!0});return}}if(n.isActive||r){if(E!==`prompt`&&E!==`bash`)return;e.hasInterruptibleToolInProgress&&(Y(`[interrupt] Aborting current turn: streamMode=${e.streamMode}`),Z(`tengu_cancel`,{source:`interrupt_on_submit`,streamMode:e.streamMode}),e.abortController?.abort(`interrupt`)),io({value:j.trim(),preExpansionValue:T.trim(),mode:E,pastedContents:A?k:void 0,skipSlashCommands:b,bridgeOrigin:x,uuid:y}),a(``),S(0),o({}),w(),C();return}id(),await rk({queuedCommands:[{value:j,preExpansionValue:T,mode:E,pastedContents:A?k:void 0,skipSlashCommands:b,bridgeOrigin:x,uuid:y}],messages:l,mainLoopModel:u,ideSelection:d,querySource:e.querySource,commands:i,queryGuard:n,setToolJSX:s,getToolUseContext:c,setUserInputOnProcessing:f,setAbortController:p,onQuery:m,setAppState:h,onBeforeQuery:g,resetHistory:w,canUseTool:_,onInputChange:a})}async function rk(e){let{messages:t,mainLoopModel:n,ideSelection:r,querySource:i,queryGuard:a,setToolJSX:o,getToolUseContext:s,setUserInputOnProcessing:c,setAbortController:l,onQuery:u,setAppState:d,onBeforeQuery:f,resetHistory:p,canUseTool:m,queuedCommands:h}=e,g=Lc();l(g);function _(){return s(t,[],g,n)}try{a.reserve(),fl(`query_process_user_input_start`);let s=[],v=!1,y,b,x,S,C,w=h??[],T=await kd(w);w=T.attachmentCommands;let E=T.claimedCommands;if(w.length===0){l(null);return}let D=w[0]?.workload,O=D!==void 0&&w.every(e=>e.workload===D)?D:void 0,k=new Set,A;try{await pm(O,async()=>{for(let e=0;e<w.length;e++){let n=w[e],a=e===0,l=n.autonomy?.runId,u=await xg({input:n.value,preExpansionInput:n.preExpansionValue,mode:n.mode,setToolJSX:o,context:_(),pastedContents:a?n.pastedContents:void 0,messages:t,setUserInputOnProcessing:a?c:void 0,isAlreadyProcessing:!a,querySource:i,canUseTool:m,uuid:n.uuid,ideSelection:a?r:void 0,skipSlashCommands:n.skipSlashCommands,bridgeOrigin:n.bridgeOrigin,isMeta:n.isMeta,skipAttachments:!a,autonomy:n.autonomy});l&&u.deferAutonomyCompletion&&k.add(l);let d=n.origin??(n.mode===`task-notification`?{kind:`task-notification`}:void 0);if(d)for(let e of u.messages)e.type===`user`&&(e.origin=d);s.push(...u.messages),a&&(v=u.shouldQuery,y=u.allowedTools,b=u.model,x=u.effort,S=u.nextInput,C=u.submitNextInput)}if(fl(`query_process_user_input_end`),Kd()&&(fl(`query_file_history_snapshot_start`),s.filter(bg).forEach(e=>{lr(e=>{d(t=>({...t,fileHistory:e(t.fileHistory)}))},e.uuid)}),fl(`query_file_history_snapshot_end`)),s.length){p(),o({jsx:null,shouldHidePromptInput:!1,clearLocalJSX:!0});let e=w[0],t=e?.mode??`prompt`,r=e&&typeof e.value==`string`?e.value:void 0,i=t===`prompt`;await u(s,g,v,y??[],b?Jp(b,n):n,i?f:void 0,r,x)}else a.cancelReservation(),o({jsx:null,shouldHidePromptInput:!1,clearLocalJSX:!0}),p(),l(null);S&&(C?io({value:S,mode:`prompt`}):e.onInputChange(S))})}catch(e){A=e}if(E.length){let e=E.filter(e=>{let t=e.autonomy?.runId;return!t||!k.has(t)});if(A)try{await _s({commands:e,outcome:{type:`failed`,error:A},currentDir:Jd(),priority:`later`,workload:O})}catch(e){X(Qd(e))}else try{let t=await _s({commands:e,outcome:{type:`completed`},currentDir:Jd(),priority:`later`,workload:O});for(let e of t)io(e)}catch(e){X(Qd(e))}}if(A)throw A}finally{a.cancelReservation(),c(void 0)}}jr();function ik(e){if(typeof e.value==`string`)return e.value.trim().startsWith(`/`)&&(!e.skipSlashCommands||e.bridgeOrigin===!0);for(let t of e.value)if(t.type===`text`)return t.text.trim().startsWith(`/`)&&(!e.skipSlashCommands||e.bridgeOrigin===!0);return!1}function ak({executeInput:e}){let t=e=>e.agentId===void 0,n=Ko(t);if(!n)return{processed:!1};if(ik(n)||n.mode===`bash`)return e([Wd(t)]),{processed:!0};let r=n.mode,i=Jt(e=>t(e)&&!ik(e)&&e.mode===r);return i.length===0?{processed:!1}:(e(i),{processed:!0})}jr();function ok({executeQueuedInput:e,hasActiveLocalJsxUI:t,queryGuard:n}){let r=(0,Q.useSyncExternalStore)(n.subscribe,n.getSnapshot),i=(0,Q.useSyncExternalStore)(Bs,qn);(0,Q.useEffect)(()=>{r||t||i.length!==0&&ak({executeInput:e})},[i,r,e,t,n])}function sk({isLoading:e,onSubmitMessage:t}){let n=dd();(0,Q.useEffect)(()=>{if(e)return;let r=n.poll();r&&t(r.content)},[e,(0,Q.useSyncExternalStore)((0,Q.useMemo)(()=>n.subscribe.bind(n),[n]),(0,Q.useCallback)(()=>n.revision,[n])),n,t])}function ck(e,t){return e&&t&&t.length>0?Sr([...e,...t],`name`):e||[]}function lk(e,t){return(0,Q.useMemo)(()=>ck(e,t),[e,t])}Tl(),yg(),Kg(),iu();function uk(e,t){return(0,Q.useMemo)(()=>t.length>0?Sr([...e,...t],`name`):e,[e,t])}Zi(),ap();function dk(e,t){let n=(0,Q.useCallback)(async()=>{if(e)try{$a(),t(await lu(e))}catch(e){e instanceof Error&&X(e)}},[e,t]);(0,Q.useEffect)(()=>Ig.subscribe(n),[n])}ap(),Ee(),Ei(),Fp();var fk=Pp(()=>De({method:Ce(`selection_changed`),params:De({selection:De({start:De({line:be(),character:be()}),end:De({line:be(),character:be()})}).nullable().optional(),text:ye().optional(),filePath:ye().optional()})}));function pk(e,t){let n=(0,Q.useRef)(!1),r=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{let i=ya(e);if(r.current!==(i??null)&&(n.current=!1,r.current=i||null,t({lineCount:0,lineStart:void 0,text:void 0,filePath:void 0})),n.current||!i)return;let a=e=>{if(e.selection?.start&&e.selection?.end){let{start:n,end:r}=e.selection,i=r.line-n.line+1;r.character===0&&i--,t({lineCount:i,lineStart:n.line,text:e.text,filePath:e.filePath})}};i.client.setNotificationHandler(fk(),e=>{if(r.current===i)try{let t=e.params;t.selection&&t.selection.start&&t.selection.end?a(t):t.text!==void 0&&a({selection:null,text:t.text,filePath:t.filePath})}catch(e){X(e)}}),n.current=!0},[e,t])}Zc(),B(),cv(),q(),kp();function mk({task:e,selected:t}){let n=dv(e.startTime,e.status===`running`),r=e.progress?.tokenCount??0;return(0,$.jsxs)(b,{flexDirection:`row`,width:`100%`,justifyContent:`space-between`,children:[(0,$.jsxs)(b,{flexDirection:`row`,flexShrink:1,children:[(0,$.jsx)(T,{color:e.status===`running`?`success`:void 0,children:t?`● `:`○ `}),(0,$.jsxs)(T,{bold:t,wrap:`truncate-end`,children:[e.agentType,` `,(0,$.jsx)(T,{dimColor:!0,children:e.description})]})]}),(0,$.jsx)(b,{flexShrink:0,children:(0,$.jsxs)(T,{dimColor:!0,children:[n,` · ↓ `,Np(r),` tokens`]})})]})}function hk(e,t){return e?`↑/↓ to select · Enter to view`:t?t.status===`running`?`shift+↓ to manage · x to stop`:`shift+↓ to manage · x to clear`:`shift+↓ to manage background agents`}function gk(){let e=IC(),t=J(e=>e.viewingAgentTaskId),n=J(e=>e.footerSelection),r=J(e=>e.selectedBgAgentIndex);if(e.length===0)return null;let i=n===`bg_agent`,a=i?r===-1?null:e[r]?.agentId??null:t??null,o=i?r===-1:t===void 0,s=t?e.find(e=>e.agentId===t)??null:null;return(0,$.jsxs)(b,{flexDirection:`column`,width:`100%`,children:[(0,$.jsxs)(b,{flexDirection:`row`,width:`100%`,justifyContent:`space-between`,children:[(0,$.jsxs)(T,{bold:o,children:[o?`● `:`○ `,`main`]}),(0,$.jsx)(T,{dimColor:!0,children:hk(i,s)})]}),e.map(e=>(0,$.jsx)(mk,{task:e,selected:e.agentId===a},e.agentId))]})}of(),Cr();var _k=1e3;function vk({taskListId:e,isLoading:t,onSubmitTask:n}){let r=(0,Q.useRef)(null),i=(0,Q.useRef)(null),a=(0,Q.useRef)(t);a.current=t;let o=(0,Q.useRef)(n);o.current=n;let s=e!==void 0,c=e??`tasklist`,l=(0,Q.useRef)(async()=>{});l.current=async()=>{if(!s||a.current)return;let t=await wo(e);if(r.current!==null){let e=t.find(e=>e.id===r.current);if(!e||e.status===`completed`)Y(`[TaskListWatcher] Task #${r.current} is marked complete, ready for next task`),r.current=null;else return}let n=yk(t);if(!n)return;Y(`[TaskListWatcher] Found available task #${n.id}: ${n.subject}`);let i=await Qn(e,n.id,c);if(!i.success){Y(`[TaskListWatcher] Failed to claim task #${n.id}: ${i.reason}`);return}r.current=n.id;let l=bk(n);Y(`[TaskListWatcher] Submitting task #${n.id} as prompt`),o.current(l)||(Y(`[TaskListWatcher] Failed to submit task #${n.id}, releasing claim`),await qi(e,n.id,{owner:void 0}),r.current=null)};let u=(0,Q.useRef)(()=>{});(0,Q.useEffect)(()=>{if(!s)return;co(e);let t=au(e),n=null,r=()=>{i.current&&clearTimeout(i.current),i.current=setTimeout(e=>void e.current(),_k,l)};u.current=r;try{n=Rv(t,r),n.unref(),Y(`[TaskListWatcher] Watching for tasks in ${t}`)}catch(e){Y(`[TaskListWatcher] Failed to watch ${t}: ${e}`)}return r(),()=>{u.current=()=>{},n&&n.close(),i.current&&clearTimeout(i.current)}},[s,e]),(0,Q.useEffect)(()=>{s&&(t||u.current())},[s,t])}function yk(e){let t=new Set(e.filter(e=>e.status!==`completed`).map(e=>e.id));return e.find(e=>e.status!==`pending`||e.owner?!1:e.blockedBy.every(e=>!t.has(e)))}function bk(e){let t=`Complete all open tasks. Start with task #${e.id}: \n\n ${e.subject}`;return e.description&&(t+=`\n\n${e.description}`),t}Vf(),s(),Ei();function xk({autoConnectIdeFlag:e,ideToInstallExtension:t,setDynamicMcpConfig:n,setShowIdeOnboarding:r,setIDEInstallationState:o}){(0,Q.useEffect)(()=>{function s(r){r&&(Bf().autoConnectIde||e||gi()||process.env.CLAUDE_CODE_SSE_PORT||t||a(process.env.CLAUDE_CODE_AUTO_CONNECT_IDE))&&!i(process.env.CLAUDE_CODE_AUTO_CONNECT_IDE)&&n(e=>e?.ide?e:{...e,ide:{type:r.url.startsWith(`ws:`)?`ws-ide`:`sse-ide`,url:r.url,ideName:r.name,authToken:r.authToken,ideRunningInWindows:r.ideRunningInWindows,scope:`dynamic`}})}Xc(s,t,()=>r(!0),e=>o(e))},[e,t,n,r,o])}M_(),Rh(),B(),zh(),Pa(),q(),Vf(),Ef(),s();function Sk({onBackgroundSession:e,isLoading:t}){let n=Qs(),r=js(),[i,o]=(0,Q.useState)(!1),s=ie(o,e,()=>{}),c=(0,Q.useCallback)(()=>{a(process.env.CLAUDE_CODE_DISABLE_BACKGROUND_TASKS)||(ka(r.getState())?(hd(()=>r.getState(),n),Bf().hasUsedBackgroundTask||zf(e=>e.hasUsedBackgroundTask?e:{...e,hasUsedBackgroundTask:!0})):a(`false`)&&t&&s())},[n,r,t,s]),l=J(ka),u=a(`false`);j(`task:background`,c,{context:`Task`,isActive:l||u&&t});let d=lo(`task:background`,`Task`,`ctrl+b`),f=_f.terminal===`tmux`&&d===`ctrl+b`?`ctrl+b ctrl+b`:d;return!t||!i?null:(0,$.jsx)(b,{paddingLeft:2,children:(0,$.jsx)(T,{dimColor:!0,children:(0,$.jsx)(h,{shortcut:f,action:`background`})})})}q();function Ck({setMessages:e,setIsLoading:t,resetLoadingState:n,setAbortController:r,onBackgroundQuery:i}){let a=J(e=>e.foregroundedTaskId),o=J(e=>e.foregroundedTaskId?e.tasks[e.foregroundedTaskId]:void 0),s=Qs(),c=(0,Q.useRef)(0),l=(0,Q.useCallback)(()=>{if(a){s(e=>{let t=e.foregroundedTaskId;if(!t)return e;let n=e.tasks[t];return n?{...e,foregroundedTaskId:void 0,tasks:{...e.tasks,[t]:{...n,isBackgrounded:!0}}}:{...e,foregroundedTaskId:void 0}}),e([]),n(),r(null);return}i()},[a,s,e,n,r,i]);return(0,Q.useEffect)(()=>{if(!a){c.current=0;return}if(!o||o.type!==`local_agent`){s(e=>({...e,foregroundedTaskId:void 0})),n(),c.current=0;return}let i=o.messages??[];if(i.length!==c.current&&(c.current=i.length,e([...i])),o.status===`running`){let e=o.abortController;if(e?.signal.aborted){s(e=>{if(!e.foregroundedTaskId)return e;let t=e.tasks[e.foregroundedTaskId];return t?{...e,foregroundedTaskId:void 0,tasks:{...e.tasks,[e.foregroundedTaskId]:{...t,isBackgrounded:!0}}}:{...e,foregroundedTaskId:void 0}}),n(),r(null),c.current=0;return}t(!0),e&&r(e)}else s(e=>{let t=e.foregroundedTaskId;if(!t)return e;let n=e.tasks[t];return n?{...e,foregroundedTaskId:void 0,tasks:{...e.tasks,[t]:{...n,isBackgrounded:!0}}}:{...e,foregroundedTaskId:void 0}}),n(),r(null),c.current=0},[a,o,s,e,t,n,r]),{handleBackgroundSession:l}}Ld(),B(),am(),Vf(),lm(),Nf(),Pi(),S_(),n_();var wk=3e4;function Tk({model:e,onDone:t}){let n=K(),r=(0,Q.useRef)(t);(0,Q.useEffect)(()=>{r.current=t});let i=(0,Q.useCallback)(()=>{r.current(`dismiss`)},[]);(0,Q.useEffect)(()=>{kk()},[]),(0,Q.useEffect)(()=>{let e=setTimeout(i,wk);return()=>clearTimeout(e)},[i]);let a=Zn(e),o=a?Ga(a):`high`,s=(0,Q.useCallback)(e=>{Lf(`userSettings`,{effortLevel:gu(e===o?void 0:e)}),r.current(e)},[o]),c=[{label:(0,$.jsx)(Dk,{level:`medium`,text:`Medium (recommended)`}),value:`medium`},{label:(0,$.jsx)(Dk,{level:`high`,text:`High`}),value:`high`},{label:(0,$.jsx)(Dk,{level:`low`,text:`Low`}),value:`low`}];return(0,$.jsx)(i_,{title:n.dialogTitle,children:(0,$.jsxs)(b,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsx)(b,{marginBottom:1,flexDirection:`column`,children:(0,$.jsx)(T,{children:n.dialogDescription})}),(0,$.jsx)(b,{marginBottom:1,children:(0,$.jsxs)(T,{dimColor:!0,children:[(0,$.jsx)(Ek,{level:`low`}),` low `,`·`,` `,(0,$.jsx)(Ek,{level:`medium`}),` medium `,`·`,` `,(0,$.jsx)(Ek,{level:`high`}),` high`]})}),(0,$.jsx)(pi,{options:c,onChange:s,onCancel:i})]})})}function Ek({level:e}){return(0,$.jsx)(T,{color:`suggestion`,children:__(e)})}function Dk({level:e,text:t}){return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ek,{level:e}),` `,t]})}function Ok(e){if(!Kp(e).toLowerCase().includes(`opus-4-6`))return!1;let t=Bf();return t.effortCalloutV2Dismissed?!1:t.numStartups<=1?(kk(),!1):hm()?t.effortCalloutDismissed?(kk(),!1):K().enabled:cm()||wm()?K().enabled:(kk(),!1)}function kk(){zf(e=>e.effortCalloutV2Dismissed?e:{...e,effortCalloutV2Dismissed:!0})}fg(),a_();function Ak(e,t){return t}async function jk(e,t,n){try{Y(`Collecting transcript for sharing`,{level:`info`});let r=Or(e),i=await kr(Wl(e)),a;try{let e=xn(),{size:t}=await Hv(e);t<=52428800?a=await Vv(e,`utf-8`):Y(`Skipping raw transcript read: file too large (${t} bytes)`,{level:`warn`})}catch{}let o=z_($d({trigger:t,version:`0.0.2`,platform:process.platform,transcript:r,subagentTranscripts:Object.keys(i).length>0?i:void 0,rawTranscriptJsonl:a}));await vm();let s=gm();if(s.error)return{success:!1};let c={"Content-Type":`application/json`,"User-Agent":Tm(),...s.headers},l=await f.post(`https://api.anthropic.com/api/claude_code_shared_session_transcripts`,{content:o,appearance_id:n},{headers:c,timeout:3e4});if(l.status===200||l.status===201){let e=l.data;return Y(`Transcript shared successfully`,{level:`info`}),{success:!0,transcriptId:e?.transcript_id}}return{success:!1}}catch(e){return Y(df(e),{level:`error`}),{success:!1}}}var Mk=t((()=>{p(),am(),of(),ef(),Vd(),Wc(),Xd()}));Lh(),Mk();function Nk({hideThanksAfterMs:e,onOpen:t,onSelect:n,shouldShowTranscriptPrompt:r,onTranscriptPromptShown:i,onTranscriptSelect:a}){let[o,s]=(0,Q.useState)(`closed`),[c,l]=(0,Q.useState)(null),u=(0,Q.useRef)(Bv()),d=(0,Q.useRef)(null),f=(0,Q.useCallback)(()=>{s(`thanks`),setTimeout((e,t)=>{e(`closed`),t(null)},e,s,l)},[e]),p=(0,Q.useCallback)(()=>{s(`submitted`),setTimeout(s,e,`closed`)},[e]);return{state:o,lastResponse:c,open:(0,Q.useCallback)(()=>{o===`closed`&&(s(`open`),u.current=Bv(),t(u.current))},[o,t]),handleSelect:(0,Q.useCallback)(e=>{if(l(e),d.current=e,n(u.current,e),e===`dismissed`)s(`closed`),l(null);else if(r?.(e))return s(`transcript_prompt`),i?.(u.current,e),!0;else f();return!1},[f,n,r,i]),handleTranscriptSelect:(0,Q.useCallback)(e=>{switch(e){case`yes`:s(`submitting`),(async()=>{try{await a?.(u.current,e,d.current)?p():f()}catch{f()}})();break;case`no`:case`dont_ask_again`:a?.(u.current,e,d.current),f();break}},[f,p,a])}}Cp(),Vf(),s(),Vd(),lm(),Nf();var Pk={minTimeBeforeFeedbackMs:6e5,minTimeBetweenFeedbackMs:36e5,minTimeBetweenGlobalFeedbackMs:1e8,minUserTurnsBeforeFeedback:5,minUserTurnsBetweenFeedback:10,hideThanksAfterMs:3e3,onForModels:[`*`],probability:.005},Fk={probability:0};function Ik(e,t,n,r=`session`,i=!1){let o=(0,Q.useRef)(`unknown`);o.current=$c(e)?.message?.id||`unknown`;let[s,c]=(0,Q.useState)(()=>({timeLastShown:null,submitCountAtLastAppearance:null})),l=Ak(`tengu_feedback_survey_config`,Pk),u=Ak(`tengu_bad_survey_transcript_ask_config`,Fk),d=Ak(`tengu_good_survey_transcript_ask_config`,Fk),f=Ff().feedbackSurveyRate,p=(0,Q.useRef)(Date.now()),m=(0,Q.useRef)(n),h=(0,Q.useRef)(n);h.current=n;let g=(0,Q.useRef)(e);g.current=e;let _=(0,Q.useRef)(!1),v=(0,Q.useRef)(null),y=(0,Q.useCallback)((e,t)=>{c(n=>n.timeLastShown===e&&n.submitCountAtLastAppearance===t?n:{timeLastShown:e,submitCountAtLastAppearance:t}),Bf().feedbackSurveyState?.lastShownTime!==e&&zf(t=>({...t,feedbackSurveyState:{lastShownTime:e}}))},[]),b=(0,Q.useCallback)(e=>{y(Date.now(),h.current),Z(`tengu_feedback_survey_event`,{event_type:`appeared`,appearance_id:e,last_assistant_message_id:o.current,survey_type:r}),xh(`feedback_survey`,{event_type:`appeared`,appearance_id:e,survey_type:r})},[y,r]),x=(0,Q.useCallback)((e,t)=>{y(Date.now(),h.current),Z(`tengu_feedback_survey_event`,{event_type:`responded`,appearance_id:e,response:t,last_assistant_message_id:o.current,survey_type:r}),xh(`feedback_survey`,{event_type:`responded`,appearance_id:e,response:t,survey_type:r})},[y,r]),S=(0,Q.useCallback)(e=>{if(e!==`bad`&&e!==`good`||Bf().transcriptShareDismissed||!Na(`allow_product_feedback`))return!1;let t=e===`bad`?u.probability:d.probability;return Math.random()<=t},[u.probability,d.probability]),C=(0,Q.useCallback)((e,t)=>{let n=t===`good`?`good_feedback_survey`:`bad_feedback_survey`;Z(`tengu_feedback_survey_event`,{event_type:`transcript_prompt_appeared`,appearance_id:e,last_assistant_message_id:o.current,survey_type:r,trigger:n}),xh(`feedback_survey`,{event_type:`transcript_prompt_appeared`,appearance_id:e,survey_type:r})},[r]),w=(0,Q.useCallback)(async(e,t,n)=>{let i=n===`good`?`good_feedback_survey`:`bad_feedback_survey`;if(Z(`tengu_feedback_survey_event`,{event_type:`transcript_share_${t}`,appearance_id:e,last_assistant_message_id:o.current,survey_type:r,trigger:i}),t===`dont_ask_again`&&zf(e=>({...e,transcriptShareDismissed:!0})),t===`yes`){let t=await jk(g.current,i,e);return Z(`tengu_feedback_survey_event`,{event_type:t.success?`transcript_share_submitted`:`transcript_share_failed`,appearance_id:e,trigger:i}),t.success}return!1},[r]),{state:T,lastResponse:E,open:D,handleSelect:O,handleTranscriptSelect:k}=Nk({hideThanksAfterMs:l.hideThanksAfterMs,onOpen:b,onSelect:x,shouldShowTranscriptPrompt:S,onTranscriptPromptShown:C,onTranscriptSelect:w}),A=Fm(),j=(0,Q.useMemo)(()=>l.onForModels.length===0?!1:l.onForModels.includes(`*`)?!0:l.onForModels.includes(A),[l.onForModels,A]),M=(0,Q.useMemo)(()=>{if(T!==`closed`||t||i)return!1;if(process.env.CLAUDE_FORCE_DISPLAY_SURVEY&&!s.timeLastShown)return!0;if(!j||a(process.env.CLAUDE_CODE_DISABLE_FEEDBACK_SURVEY)||Ih()||!Na(`allow_product_feedback`))return!1;if(s.timeLastShown){if(Date.now()-s.timeLastShown<l.minTimeBetweenFeedbackMs||s.submitCountAtLastAppearance!==null&&n<s.submitCountAtLastAppearance+l.minUserTurnsBetweenFeedback)return!1}else if(Date.now()-p.current<l.minTimeBeforeFeedbackMs||n<m.current+l.minUserTurnsBeforeFeedback)return!1;if(v.current!==n&&(v.current=n,_.current=Math.random()<=(f??l.probability)),!_.current)return!1;let e=Bf().feedbackSurveyState;return!(e?.lastShownTime&&Date.now()-e.lastShownTime<l.minTimeBetweenGlobalFeedbackMs)},[T,t,i,j,s.timeLastShown,s.submitCountAtLastAppearance,n,l.minTimeBetweenFeedbackMs,l.minTimeBetweenGlobalFeedbackMs,l.minUserTurnsBetweenFeedback,l.minTimeBeforeFeedbackMs,l.minUserTurnsBeforeFeedback,l.probability,f]);return(0,Q.useEffect)(()=>{M&&D()},[M,D]),{state:T,lastResponse:E,handleSelect:O,handleTranscriptSelect:k}}Lh(),Cp(),qa(),Vf(),s(),Vd(),wh(),Mk();var Lk=3e3,Rk=`tengu_memory_survey_event`,zk=`memory_survey`;function Bk(e,t,n=!1,{enabled:r=!0}={}){let i=(0,Q.useRef)(new Set),a=(0,Q.useRef)(!1),o=(0,Q.useRef)(e);o.current=e;let{state:s,lastResponse:c,open:l,handleSelect:u,handleTranscriptSelect:d}=Nk({hideThanksAfterMs:Lk,onOpen:(0,Q.useCallback)(e=>{Z(Rk,{event_type:`appeared`,appearance_id:e}),xh(`feedback_survey`,{event_type:`appeared`,appearance_id:e,survey_type:`memory`})},[]),onSelect:(0,Q.useCallback)((e,t)=>{Z(Rk,{event_type:`responded`,appearance_id:e,response:t}),xh(`feedback_survey`,{event_type:`responded`,appearance_id:e,response:t,survey_type:`memory`})},[]),shouldShowTranscriptPrompt:(0,Q.useCallback)(e=>!(process.env.USER_TYPE!==`ant`||e!==`bad`&&e!==`good`||Bf().transcriptShareDismissed||!Na(`allow_product_feedback`)),[]),onTranscriptPromptShown:(0,Q.useCallback)(e=>{Z(Rk,{event_type:`transcript_prompt_appeared`,appearance_id:e,trigger:zk}),xh(`feedback_survey`,{event_type:`transcript_prompt_appeared`,appearance_id:e,survey_type:`memory`})},[]),onTranscriptSelect:(0,Q.useCallback)(async(e,t)=>{if(Z(Rk,{event_type:`transcript_share_${t}`,appearance_id:e,trigger:zk}),t===`dont_ask_again`&&zf(e=>({...e,transcriptShareDismissed:!0})),t===`yes`){let t=await jk(o.current,zk,e);return Z(Rk,{event_type:t.success?`transcript_share_submitted`:`transcript_share_failed`,appearance_id:e,trigger:zk}),t.success}return!1},[])});return(0,Q.useEffect)(()=>{if(r&&e.length===0){a.current=!1,i.current.clear();return}},[r,s,t,n,(0,Q.useMemo)(()=>$c(e),[e]),e,l]),{state:s,lastResponse:c,handleSelect:u,handleTranscriptSelect:d}}Lh(),Cp(),s(),Vd(),wh();var Vk=3e3,Hk=.2;function Uk(e,t){let n=e.findIndex(e=>e.uuid===t);if(n===-1)return!1;for(let t=n+1;t<e.length;t++){let n=e[t];if(n&&(n.type===`user`||n.type===`assistant`))return!0}return!1}function Wk(e,t,n=!1,{enabled:r=!0}={}){let[i,o]=(0,Q.useState)(null),s=(0,Q.useRef)(new Set),c=(0,Q.useRef)(null),{state:l,lastResponse:u,open:d,handleSelect:f}=Nk({hideThanksAfterMs:Vk,onOpen:(0,Q.useCallback)(e=>{Z(`tengu_post_compact_survey_event`,{event_type:`appeared`,appearance_id:e,session_memory_compaction_enabled:$u()}),xh(`feedback_survey`,{event_type:`appeared`,appearance_id:e,survey_type:`post_compact`})},[]),onSelect:(0,Q.useCallback)((e,t)=>{Z(`tengu_post_compact_survey_event`,{event_type:`responded`,appearance_id:e,response:t,session_memory_compaction_enabled:$u()}),xh(`feedback_survey`,{event_type:`responded`,appearance_id:e,response:t,survey_type:`post_compact`})},[])});(0,Q.useEffect)(()=>{r&&o(!1)},[r]);let p=(0,Q.useMemo)(()=>new Set(e.filter(e=>Gt(e)).map(e=>e.uuid)),[e]);return(0,Q.useEffect)(()=>{if(!r||l!==`closed`||t||n||i!==!0||Ih()||a(process.env.CLAUDE_CODE_DISABLE_FEEDBACK_SURVEY))return;if(c.current!==null&&Uk(e,c.current)){c.current=null,Math.random()<Hk&&d();return}let o=Array.from(p).filter(e=>!s.current.has(e));o.length>0&&(s.current=new Set(p),c.current=o[o.length-1])},[r,p,l,t,n,i,e,d]),{state:l,lastResponse:u,handleSelect:f}}vf(),B();var Gk=[`1`,`2`,`3`],Kk={1:`yes`,2:`no`,3:`dont_ask_again`},qk=e=>Gk.includes(e);function Jk({onSelect:e,inputValue:t,setInputValue:n}){return xO({inputValue:t,setInputValue:n,isValidDigit:qk,onDigit:t=>e(Kk[t])}),(0,$.jsxs)(b,{flexDirection:`column`,marginTop:1,children:[(0,$.jsxs)(b,{children:[(0,$.jsxs)(T,{color:`ansi:cyan`,children:[Sf,` `]}),(0,$.jsx)(T,{bold:!0,children:`Can Anthropic look at your session transcript to help us improve Claude Code?`})]}),(0,$.jsx)(b,{marginLeft:2,children:(0,$.jsx)(T,{dimColor:!0,children:`Learn more: https://code.claude.com/docs/en/data-usage#session-quality-surveys`})}),(0,$.jsxs)(b,{marginLeft:2,children:[(0,$.jsx)(b,{width:10,children:(0,$.jsxs)(T,{children:[(0,$.jsx)(T,{color:`ansi:cyan`,children:`1`}),`: Yes`]})}),(0,$.jsx)(b,{width:10,children:(0,$.jsxs)(T,{children:[(0,$.jsx)(T,{color:`ansi:cyan`,children:`2`}),`: No`]})}),(0,$.jsx)(b,{children:(0,$.jsxs)(T,{children:[(0,$.jsx)(T,{color:`ansi:cyan`,children:`3`}),`: Don't ask again`]})})]})]})}Cp(),B();function Yk({state:e,lastResponse:t,handleSelect:n,handleTranscriptSelect:r,inputValue:i,setInputValue:a,onRequestFeedback:o,message:s}){return e===`closed`?null:e===`thanks`?(0,$.jsx)(Zk,{lastResponse:t,inputValue:i,setInputValue:a,onRequestFeedback:o}):e===`submitted`?(0,$.jsx)(b,{marginTop:1,children:(0,$.jsxs)(T,{color:`success`,children:[`✓`,` Thanks for sharing your transcript!`]})}):e===`submitting`?(0,$.jsx)(b,{marginTop:1,children:(0,$.jsxs)(T,{dimColor:!0,children:[`Sharing transcript`,`…`]})}):e===`transcript_prompt`?!r||i&&![`1`,`2`,`3`].includes(i)?null:(0,$.jsx)(Jk,{onSelect:r,inputValue:i,setInputValue:a}):i&&!wO(i)?null:(0,$.jsx)(EO,{onSelect:n,inputValue:i,setInputValue:a,message:s})}var Xk=e=>e===`1`;function Zk({lastResponse:e,inputValue:t,setInputValue:n,onRequestFeedback:r}){let i=r&&e===`good`;xO({inputValue:t,setInputValue:n,isValidDigit:Xk,enabled:!!i,once:!0,onDigit:()=>{Z(`tengu_feedback_survey_event`,{event_type:`followup_accepted`,response:e}),r?.()}});let a=process.env.USER_TYPE===`ant`?`/issue`:`/feedback`;return(0,$.jsxs)(b,{marginTop:1,flexDirection:`column`,children:[(0,$.jsx)(T,{color:`success`,children:`Thanks for the feedback!`}),i?(0,$.jsxs)(T,{dimColor:!0,children:[`(Optional) Press [`,(0,$.jsx)(T,{color:`ansi:cyan`,children:`1`}),`] to tell us what went well `,` · `,a]}):e===`bad`?(0,$.jsx)(T,{dimColor:!0,children:`Use /issue to report model behavior issues.`}):(0,$.jsxs)(T,{dimColor:!0,children:[`Use `,a,` to share detailed feedback anytime.`]})]})}ag(),cg(),rt(),Ll(),ap();function Qk(e){let{addNotification:t}=Au(),n=(0,Q.useRef)(!1),r=(0,Q.useRef)(e);r.current=e,(0,Q.useEffect)(()=>{ke()||n.current||(n.current=!0,Promise.resolve().then(()=>r.current()).then(e=>{if(e)for(let n of Array.isArray(e)?e:[e])t(n)}).catch(X))},[t])}function $k(){Qk(async()=>(await sg()).map((e,t)=>{let n=`low`;return e.type===`error`||e.userActionRequired?n=`high`:(e.type===`path`||e.type===`alias`)&&(n=`medium`),{key:`install-message-${t}-${e.type}`,text:e.message,priority:n,color:e.type===`error`?`error`:`warning`}}))}tf(),of(),Vd(),lm(),Ms(),Ev(),qs(),B(),Vd();function eA(e,t,n){(0,Q.useRef)(null),(0,Q.useRef)(null);let r=(0,Q.useRef)(e),i=(0,Q.useRef)(n),a=(0,Q.useRef)(!1),o=(0,Q.useRef)(null);r.current=e,i.current=n,(0,Q.useEffect)(()=>{},[!1,t]),(0,Q.useEffect)(()=>{if(n||!a.current)return;let e=I();e!==`blurred`&&e!==`unknown`||o.current?.()},[n]),(0,Q.useEffect)(()=>{I()},[n,!1])}Cp(),Vf(),of(),s(),ef(),ap();function tA(){return a(process.env.CLAUDE_CODE_DISABLE_OFFICIAL_MARKETPLACE_AUTOINSTALL)}var nA={MAX_ATTEMPTS:10,INITIAL_DELAY_MS:3600*1e3,BACKOFF_MULTIPLIER:2,MAX_DELAY_MS:10080*60*1e3};function rA(e){let t=nA.INITIAL_DELAY_MS*nA.BACKOFF_MULTIPLIER**e;return Math.min(t,nA.MAX_DELAY_MS)}function iA(e){if(!e.officialMarketplaceAutoInstallAttempted)return!0;if(e.officialMarketplaceAutoInstalled)return!1;let t=e.officialMarketplaceAutoInstallFailReason,n=e.officialMarketplaceAutoInstallRetryCount||0,r=e.officialMarketplaceAutoInstallNextRetryTime,i=Date.now();return n>=nA.MAX_ATTEMPTS||t===`policy_blocked`||r&&i<r?!1:t===`unknown`||t===`git_unavailable`||t===`gcs_unavailable`||t===void 0}async function aA(){let e=Bf();if(!iA(e)){let t=e.officialMarketplaceAutoInstallFailReason??`already_attempted`;return Y(`Official marketplace auto-install skipped: ${t}`),{installed:!1,skipped:!0,reason:t}}try{if(tA())return Y(`Official marketplace auto-install disabled via env var, skipping`),zf(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!1,officialMarketplaceAutoInstallFailReason:`policy_blocked`})),Z(`tengu_official_marketplace_auto_install`,{installed:!1,skipped:!0,policy_blocked:!0}),{installed:!1,skipped:!0,reason:`policy_blocked`};if((await ar())[`claude-plugins-official`])return Y(`Official marketplace '${Jl}' already installed, skipping`),zf(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!0})),{installed:!1,skipped:!0,reason:`already_installed`};if(!Bl(hl))return Y(`Official marketplace blocked by enterprise policy, skipping`),zf(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!1,officialMarketplaceAutoInstallFailReason:`policy_blocked`})),Z(`tengu_official_marketplace_auto_install`,{installed:!1,skipped:!0,policy_blocked:!0}),{installed:!1,skipped:!0,reason:`policy_blocked`};let t=Ud(),n=Nv(t,Jl);if(await Uo(n,t)!==null){let e=await ar();return e[Jl]={source:hl,installLocation:n,lastUpdated:new Date().toISOString()},await Ar(e),zf(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!0,officialMarketplaceAutoInstallFailReason:void 0,officialMarketplaceAutoInstallRetryCount:void 0,officialMarketplaceAutoInstallLastAttemptTime:void 0,officialMarketplaceAutoInstallNextRetryTime:void 0})),Z(`tengu_official_marketplace_auto_install`,{installed:!0,skipped:!1,via_gcs:!0}),{installed:!0,skipped:!1}}if(!await Ou()){Y(`Git not available, skipping official marketplace auto-install`);let t=(e.officialMarketplaceAutoInstallRetryCount||0)+1,n=Date.now(),r=n+rA(t),i=!1;try{zf(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!1,officialMarketplaceAutoInstallFailReason:`git_unavailable`,officialMarketplaceAutoInstallRetryCount:t,officialMarketplaceAutoInstallLastAttemptTime:n,officialMarketplaceAutoInstallNextRetryTime:r}))}catch(e){i=!0,X(Qd(e)),Y(`Failed to save marketplace auto-install git_unavailable state: ${e}`,{level:`error`})}return Z(`tengu_official_marketplace_auto_install`,{installed:!1,skipped:!0,git_unavailable:!0,retry_count:t}),{installed:!1,skipped:!0,reason:`git_unavailable`,configSaveFailed:i}}Y(`Attempting to auto-install official marketplace`),await Pn(hl),Y(`Successfully auto-installed official marketplace`);let r=e.officialMarketplaceAutoInstallRetryCount||0;return zf(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!0,officialMarketplaceAutoInstallFailReason:void 0,officialMarketplaceAutoInstallRetryCount:void 0,officialMarketplaceAutoInstallLastAttemptTime:void 0,officialMarketplaceAutoInstallNextRetryTime:void 0})),Z(`tengu_official_marketplace_auto_install`,{installed:!0,skipped:!1,retry_count:r}),{installed:!0,skipped:!1}}catch(t){let n=t instanceof Error?t.message:String(t);if(n.includes(`xcrun: error:`))return il(),Y(`Official marketplace auto-install: git is a non-functional macOS xcrun shim, treating as git_unavailable`),Z(`tengu_official_marketplace_auto_install`,{installed:!1,skipped:!0,git_unavailable:!0,macos_xcrun_shim:!0}),{installed:!1,skipped:!0,reason:`git_unavailable`};Y(`Failed to auto-install official marketplace: ${n}`,{level:`error`}),X(Qd(t));let r=(e.officialMarketplaceAutoInstallRetryCount||0)+1,i=Date.now(),a=i+rA(r),o=!1;try{zf(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!1,officialMarketplaceAutoInstallFailReason:`unknown`,officialMarketplaceAutoInstallRetryCount:r,officialMarketplaceAutoInstallLastAttemptTime:i,officialMarketplaceAutoInstallNextRetryTime:a}))}catch(e){o=!0,X(Qd(e)),Y(`Failed to save marketplace auto-install failure state: ${e}`,{level:`error`})}return Z(`tengu_official_marketplace_auto_install`,{installed:!1,skipped:!0,failed:!0,retry_count:r}),{installed:!1,skipped:!0,reason:`unknown`,configSaveFailed:o}}}B(),of();function oA(){Qk(async()=>{let e=await aA(),t=[];return e.configSaveFailed&&(Y(`Showing marketplace config save failure notification`),t.push({key:`marketplace-config-save-failed`,jsx:(0,$.jsx)(T,{color:`error`,children:`Failed to save marketplace retry info · Check ~/.claude.json permissions`}),priority:`immediate`,timeoutMs:1e4})),e.installed?(Y(`Showing marketplace installation success notification`),t.push({key:`marketplace-installed`,jsx:(0,$.jsx)(T,{color:`success`,children:`✓ Anthropic marketplace installed · /plugin to see available plugins`}),priority:`immediate`,timeoutMs:7e3})):e.skipped&&e.reason===`unknown`&&(Y(`Showing marketplace installation failure notification`),t.push({key:`marketplace-install-failed`,jsx:(0,$.jsx)(T,{color:`warning`,children:`Failed to install Anthropic marketplace · Will retry on next startup`}),priority:`immediate`,timeoutMs:8e3})),t})}Nf(),Cp();function sA(e){if(e.length===0)return;if(e.length===1)return e[0];let t=e.map(e=>({tip:e,sessions:vv(e.id)}));return t.sort((e,t)=>t.sessions-e.sessions),t[0]?.tip}async function cA(e){if(jf().spinnerTipsEnabled===!1)return;let t=await xv(e);if(t.length!==0)return sA(t)}function lA(e){gv(e.id),Z(`tengu_tip_shown`,{tipIdLength:e.id,cooldownSessions:e.cooldownSessions})}ef(),ap(),rt(),q(),Xt();var uA=!1;async function dA(e,t,n){{if(uA)return;uA=!0;let{updateContext:r,notification:i}=await ur(e,n);t(e=>{let t=r(e.toolPermissionContext),n=t===e.toolPermissionContext?e:{...e,toolPermissionContext:t};return i?{...n,notifications:{...n.notifications,queue:[...n.notifications.queue,{key:`auto-mode-gate-notification`,text:i,color:`warning`,priority:`high`}]}}:n})}}function fA(){uA=!1}function pA(){let e=J(e=>e.mainLoopModel),t=J(e=>e.mainLoopModelForSession),n=J(e=>e.fastMode),r=Qs(),i=js(),a=(0,Q.useRef)(!0);(0,Q.useEffect)(()=>{ke()||(a.current?a.current=!1:fA(),dA(i.getState().toolPermissionContext,r,n).catch(e=>{X(Error(`Auto mode gate check failed`,{cause:Qd(e)}))}))},[e,t,n])}Yn();function mA(e,t,n){let r=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{!Kd()||r.current||(r.current=!0,e&&Wa(e,n))},[t,e,n])}B(),dr(),Cp(),Pi(),n_();function hA({hostPattern:{host:e},onUserResponse:t}){function n(n){switch(process.env.USER_TYPE===`ant`&&Z(`tengu_sandbox_network_dialog_result`,{host:e,result:n}),n){case`yes`:t({allow:!0,persistToSettings:!1});break;case`yes-dont-ask-again`:t({allow:!0,persistToSettings:!0});break;case`no`:t({allow:!1,persistToSettings:!1});break}}let r=[{label:`Yes`,value:`yes`},...jd()?[]:[{label:(0,$.jsxs)(T,{children:[`Yes, and don't ask again for `,(0,$.jsx)(T,{bold:!0,children:e})]}),value:`yes-dont-ask-again`}],{label:(0,$.jsxs)(T,{children:[`No, and tell Claude what to do differently `,(0,$.jsx)(T,{bold:!0,children:`(esc)`})]}),value:`no`}];return(0,$.jsx)(i_,{title:`Network request outside of sandbox`,children:(0,$.jsxs)(b,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsxs)(b,{children:[(0,$.jsx)(T,{dimColor:!0,children:`Host:`}),(0,$.jsxs)(T,{children:[` `,e]})]}),(0,$.jsx)(b,{marginTop:1,children:(0,$.jsx)(T,{children:`Do you want to allow this connection?`})}),(0,$.jsx)(b,{children:(0,$.jsx)(pi,{options:r,onChange:n,onCancel:()=>{process.env.USER_TYPE===`ant`&&Z(`tengu_sandbox_network_dialog_result`,{host:e,result:`cancel`}),t({allow:!1,persistToSettings:!1})}})})]})})}B(),dr(),dp();function gA(e){return`${e.getHours()%12||12}:${String(e.getMinutes()).padStart(2,`0`)}:${String(e.getSeconds()).padStart(2,`0`)}${e.getHours()<12?`am`:`pm`}`}function _A(){let[e,t]=(0,Q.useState)([]),[n,r]=(0,Q.useState)(0);return(0,Q.useEffect)(()=>{let e=fi.getSandboxViolationStore();return e.subscribe(n=>{t(n.slice(-10)),r(e.getTotalCount())})},[]),!fi.isSandboxingEnabled()||up()===`linux`||n===0?null:(0,$.jsxs)(b,{flexDirection:`column`,marginTop:1,children:[(0,$.jsx)(b,{marginLeft:0,children:(0,$.jsxs)(T,{color:`permission`,children:[`⧈ Sandbox blocked `,n,` total `,n===1?`operation`:`operations`]})}),e.map((e,t)=>(0,$.jsx)(b,{paddingLeft:2,children:(0,$.jsxs)(T,{dimColor:!0,children:[gA(e.timestamp),e.command?` ${e.command}:`:``,` `,e.line]})},`${e.timestamp.getTime()}-${t}`)),(0,$.jsx)(b,{paddingLeft:2,children:(0,$.jsxs)(T,{dimColor:!0,children:[`… showing last `,Math.min(10,e.length),` of `,n]})})]})}k_(),Ll(),rt(),B();var vA=[];function yA({mcpClients:e=vA}){let{addNotification:t}=Au();(0,Q.useEffect)(()=>{if(ke())return;let n=e.filter(e=>e.type===`failed`&&e.config.type!==`sse-ide`&&e.config.type!==`ws-ide`&&e.config.type!==`claudeai-proxy`),r=e.filter(e=>e.type===`failed`&&e.config.type===`claudeai-proxy`&&Ct(e.name)),i=e.filter(e=>e.type===`needs-auth`&&e.config.type!==`claudeai-proxy`),a=e.filter(e=>e.type===`needs-auth`&&e.config.type===`claudeai-proxy`&&Ct(e.name));n.length===0&&r.length===0&&i.length===0&&a.length===0||(n.length>0&&t({key:`mcp-failed`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(T,{color:`error`,children:[n.length,` MCP `,n.length===1?`server`:`servers`,` failed`]}),(0,$.jsx)(T,{dimColor:!0,children:` · /mcp`})]}),priority:`medium`}),r.length>0&&t({key:`mcp-claudeai-failed`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(T,{color:`error`,children:[r.length,` claude.ai `,r.length===1?`connector`:`connectors`,` `,`unavailable`]}),(0,$.jsx)(T,{dimColor:!0,children:` · /mcp`})]}),priority:`medium`}),i.length>0&&t({key:`mcp-needs-auth`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(T,{color:`warning`,children:[i.length,` MCP `,i.length===1?`server needs`:`servers need`,` `,`auth`]}),(0,$.jsx)(T,{dimColor:!0,children:` · /mcp`})]}),priority:`medium`}),a.length>0&&t({key:`mcp-claudeai-needs-auth`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(T,{color:`warning`,children:[a.length,` claude.ai`,` `,a.length===1?`connector needs`:`connectors need`,` auth`]}),(0,$.jsx)(T,{dimColor:!0,children:` · /mcp`})]}),priority:`medium`}))},[t,e])}B(),Nf(),ri();var bA=`Auto mode lets Claude handle permission prompts automatically — Claude checks each tool call for risky actions and prompt injection before executing. Actions Claude identifies as safe are executed, while actions Claude identifies as risky are blocked and Claude may try a different approach. Ideal for long-running tasks. Sessions are slightly more expensive. Claude can make mistakes that allow harmful commands to run, it's recommended to only use in isolated environments. Shift+Tab to change mode.`;me(),rt(),Ll(),B(),q(),of(),s();var xA=5e3;function SA(){let{addNotification:e}=Au(),t=Qs(),[n,r]=Q.useState(()=>a(`true`)),i=Q.useRef(new Set),o=Q.useCallback((n,r)=>{let a=`${n}:${r}`;if(i.current.has(a))return;i.current.add(a),Y(`LSP error: ${n} - ${r}`),t(e=>{let t=new Set(e.plugins.errors.map(e=>e.type===`generic-error`?`generic-error:${e.source}:${e.error}`:`${e.type}:${e.source}`)),i=`generic-error:${n}:${r}`;return t.has(i)?e:{...e,plugins:{...e.plugins,errors:[...e.plugins.errors,{type:`generic-error`,source:n,error:r}]}}});let o=n.startsWith(`plugin:`)?n.split(`:`)[1]??n:n;e({key:`lsp-error-${n}`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(T,{color:`error`,children:[`LSP for `,o,` failed`]}),(0,$.jsx)(T,{dimColor:!0,children:` · /plugin for details`})]}),priority:`medium`,timeoutMs:8e3})},[e,t]),s=Q.useCallback(()=>{if(ke()||Ke())return;let e=xc();if(e.status===`failed`){o(`lsp-manager`,e.error.message),r(!1);return}if(e.status===`pending`||e.status===`not-started`)return;let t=lc();if(t){let e=t.getAllServers();for(let[t,n]of e)n.state===`error`&&n.lastError&&o(t,n.lastError.message)}},[o]);ne(s,n?xA:null),Q.useEffect(()=>{ke()||!n||s()},[s,n])}of();var CA=new Map;async function wA(e){if(!e||!e.trim())return Y(`[binaryCheck] Empty command provided, returning false`),!1;let t=e.trim(),n=CA.get(t);if(n!==void 0)return Y(`[binaryCheck] Cache hit for '${t}': ${n}`),n;let r=!1;return await cp(t).catch(()=>null)&&(r=!0),CA.set(t,r),Y(`[binaryCheck] Binary '${t}' ${r?`found`:`not found`}`),r}Vf(),of(),no();var TA=5;function EA(e){return Mf.has(e.toLowerCase())}function DA(e){if(!e)return null;if(typeof e==`string`)return Y(`[lspRecommendation] Skipping string path lspServers (not readable from marketplace)`),null;if(Array.isArray(e)){for(let t of e){if(typeof t==`string`)continue;let e=kA(t);if(e)return e}return null}return kA(e)}function OA(e){return typeof e==`object`&&!!e}function kA(e){let t=new Set,n=null;for(let[r,i]of Object.entries(e)){if(!OA(i))continue;!n&&typeof i.command==`string`&&(n=i.command);let e=i.extensionToLanguage;if(OA(e))for(let n of Object.keys(e))t.add(n.toLowerCase())}return!n||t.size===0?null:{extensions:t,command:n}}async function AA(){let e=new Map;try{let t=await ar();for(let n of Object.keys(t))try{let t=await ma(n),r=EA(n);for(let i of t.plugins){if(!i.lspServers)continue;let t=DA(i.lspServers);if(!t)continue;let a=`${i.name}@${n}`;e.set(a,{entry:i,marketplaceName:n,extensions:t.extensions,command:t.command,isOfficial:r})}}catch(e){Y(`[lspRecommendation] Failed to load marketplace ${n}: ${e}`)}}catch(e){Y(`[lspRecommendation] Failed to load marketplaces config: ${e}`)}return e}async function jA(e){if(PA())return Y(`[lspRecommendation] Recommendations are disabled`),[];let t=Mv(e).toLowerCase();if(!t)return Y(`[lspRecommendation] No file extension found`),[];Y(`[lspRecommendation] Looking for LSP plugins for ${t}`);let n=await AA(),r=Bf().lspRecommendationNeverPlugins??[],i=[];for(let[e,a]of n)if(a.extensions.has(t)){if(r.includes(e)){Y(`[lspRecommendation] Skipping ${e} (in never suggest list)`);continue}if(Mt(e)){Y(`[lspRecommendation] Skipping ${e} (already installed)`);continue}i.push({info:a,pluginId:e})}let a=[];for(let{info:e,pluginId:t}of i)await wA(e.command)?(a.push({info:e,pluginId:t}),Y(`[lspRecommendation] Binary '${e.command}' found for ${t}`)):Y(`[lspRecommendation] Skipping ${t} (binary '${e.command}' not found)`);return a.sort((e,t)=>e.info.isOfficial&&!t.info.isOfficial?-1:!e.info.isOfficial&&t.info.isOfficial?1:0),a.map(({info:e,pluginId:t})=>({pluginId:t,pluginName:e.entry.name,marketplaceName:e.marketplaceName,description:e.entry.description,isOfficial:e.isOfficial,extensions:Array.from(e.extensions),command:e.command}))}function MA(e){zf(t=>{let n=t.lspRecommendationNeverPlugins??[];return n.includes(e)?t:{...t,lspRecommendationNeverPlugins:[...n,e]}}),Y(`[lspRecommendation] Added ${e} to never suggest`)}function NA(){zf(e=>{let t=(e.lspRecommendationIgnoredCount??0)+1;return{...e,lspRecommendationIgnoredCount:t}}),Y(`[lspRecommendation] Incremented ignored count`)}function PA(){let e=Bf();return e.lspRecommendationDisabled===!0||(e.lspRecommendationIgnoredCount??0)>=TA}u(),rt(),B(),ap(),no();function FA(){let[e,t]=Q.useState(null),n=Q.useRef(!1),r=Q.useCallback(r=>{ke()||e||n.current||(n.current=!0,r().then(e=>{e&&t(e)}).catch(X).finally(()=>{n.current=!1}))},[e]);return{recommendation:e,clearRecommendation:Q.useCallback(()=>t(null),[]),tryResolve:r}}async function IA(e,t,n,r,i){try{let a=await qt(e);if(!a)throw Error(`Plugin ${e} not found in marketplace`);await i(a),r({key:`${n}-installed`,jsx:(0,$.jsxs)(T,{color:`success`,children:[d.tick,` `,t,` installed · restart to apply`]}),priority:`immediate`,timeoutMs:5e3})}catch(e){X(e),r({key:`${n}-install-failed`,jsx:(0,$.jsxs)(T,{color:`error`,children:[`Failed to install `,t]}),priority:`immediate`,timeoutMs:5e3})}}rt(),Ll(),q(),Vf(),of(),ap(),Nf();var LA=28e3;function RA(){let e=J(e=>e.fileHistory.trackedFiles),{addNotification:t}=Au(),n=Q.useRef(new Set),{recommendation:r,clearRecommendation:i,tryResolve:a}=FA();return Q.useEffect(()=>{a(async()=>{if(Qe())return null;let t=[];for(let r of e)n.current.has(r)||(n.current.add(r),t.push(r));for(let e of t)try{let t=(await jA(e))[0];if(t)return Y(`[useLspPluginRecommendation] Found match: ${t.pluginName} for ${e}`),Pe(!0),{pluginId:t.pluginId,pluginName:t.pluginName,pluginDescription:t.description,fileExtension:Mv(e),shownAt:Date.now()}}catch(e){X(e)}return null})},[e,a]),{recommendation:r,handleResponse:Q.useCallback(e=>{if(!r)return;let{pluginId:n,pluginName:a,shownAt:o}=r;switch(Y(`[useLspPluginRecommendation] User response: ${e} for ${a}`),e){case`yes`:IA(n,a,`lsp-plugin`,t,async e=>{Y(`[useLspPluginRecommendation] Installing plugin: ${n}`);let t=typeof e.entry.source==`string`?Nv(e.marketplaceInstallLocation,e.entry.source):void 0;await dc(n,e.entry,`user`,void 0,t),Lf(`userSettings`,{enabledPlugins:{...Of(`userSettings`)?.enabledPlugins,[n]:!0}}),Y(`[useLspPluginRecommendation] Plugin installed: ${n}`)});break;case`no`:{let e=Date.now()-o;e>=LA&&(Y(`[useLspPluginRecommendation] Timeout detected (${e}ms), incrementing ignored count`),NA());break}case`never`:MA(n);break;case`disable`:zf(e=>e.lspRecommendationDisabled?e:{...e,lspRecommendationDisabled:!0});break}i()},[r,t,i])}}B(),Pi(),n_();var zA=3e4;function BA({pluginName:e,pluginDescription:t,fileExtension:n,onResponse:r}){let i=Q.useRef(r);i.current=r,Q.useEffect(()=>{let e=setTimeout(e=>e.current(`no`),zA,i);return()=>clearTimeout(e)},[]);function a(e){switch(e){case`yes`:r(`yes`);break;case`no`:r(`no`);break;case`never`:r(`never`);break;case`disable`:r(`disable`);break}}return(0,$.jsx)(i_,{title:`LSP Plugin Recommendation`,children:(0,$.jsxs)(b,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsx)(b,{marginBottom:1,children:(0,$.jsx)(T,{dimColor:!0,children:`LSP provides code intelligence like go-to-definition and error checking`})}),(0,$.jsxs)(b,{children:[(0,$.jsx)(T,{dimColor:!0,children:`Plugin:`}),(0,$.jsxs)(T,{children:[` `,e]})]}),t&&(0,$.jsx)(b,{children:(0,$.jsx)(T,{dimColor:!0,children:t})}),(0,$.jsxs)(b,{children:[(0,$.jsx)(T,{dimColor:!0,children:`Triggered by:`}),(0,$.jsxs)(T,{children:[` `,n,` files`]})]}),(0,$.jsx)(b,{marginTop:1,children:(0,$.jsx)(T,{children:`Would you like to install this LSP plugin?`})}),(0,$.jsx)(b,{children:(0,$.jsx)(pi,{options:[{label:(0,$.jsxs)(T,{children:[`Yes, install `,(0,$.jsx)(T,{bold:!0,children:e})]}),value:`yes`},{label:`No, not now`,value:`no`},{label:(0,$.jsxs)(T,{children:[`Never for `,(0,$.jsx)(T,{bold:!0,children:e})]}),value:`never`},{label:`Disable all LSP recommendations`,value:`disable`}],onChange:a,onCancel:()=>r(`no`)})})]})})}Ll(),Cp(),of(),cd();function VA(){let e=Q.useSyncExternalStore(Fs,ws),{addNotification:t}=Au(),{recommendation:n,clearRecommendation:r,tryResolve:i}=FA();return Q.useEffect(()=>{e&&i(async()=>{let t=await Mc(e);return t&&(Y(`[useClaudeCodeHintRecommendation] surfacing ${t.pluginId} from ${t.sourceCommand}`),ed()),ws()===e&&Iu(),t})},[e,i]),{recommendation:n,handleResponse:Q.useCallback(e=>{if(n){switch(Su(n.pluginId),Z(`tengu_plugin_hint_response`,{_PROTO_plugin_name:n.pluginName,_PROTO_marketplace_name:n.marketplaceName,response:e}),e){case`yes`:{let{pluginId:e,pluginName:r,marketplaceName:i}=n;IA(e,r,`hint-plugin`,t,async t=>{let n=await Dd({pluginId:e,entry:t.entry,marketplaceName:i,scope:`user`,trigger:`hint`});if(!n.success)throw Error(n.success?`Unknown error`:n.error)});break}case`disable`:Wu();break;case`no`:break}r()}},[n,t,r])}}B(),Pi(),n_();var HA=3e4;function UA({pluginName:e,pluginDescription:t,marketplaceName:n,sourceCommand:r,onResponse:i}){let a=Q.useRef(i);a.current=i,Q.useEffect(()=>{let e=setTimeout(e=>e.current(`no`),HA,a);return()=>clearTimeout(e)},[]);function o(e){switch(e){case`yes`:i(`yes`);break;case`disable`:i(`disable`);break;default:i(`no`)}}return(0,$.jsx)(i_,{title:`Plugin Recommendation`,children:(0,$.jsxs)(b,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsx)(b,{marginBottom:1,children:(0,$.jsxs)(T,{dimColor:!0,children:[`The `,(0,$.jsx)(T,{bold:!0,children:r}),` command suggests installing a plugin.`]})}),(0,$.jsxs)(b,{children:[(0,$.jsx)(T,{dimColor:!0,children:`Plugin:`}),(0,$.jsxs)(T,{children:[` `,e]})]}),(0,$.jsxs)(b,{children:[(0,$.jsx)(T,{dimColor:!0,children:`Marketplace:`}),(0,$.jsxs)(T,{children:[` `,n]})]}),t&&(0,$.jsx)(b,{children:(0,$.jsx)(T,{dimColor:!0,children:t})}),(0,$.jsx)(b,{marginTop:1,children:(0,$.jsx)(T,{children:`Would you like to install it?`})}),(0,$.jsx)(b,{children:(0,$.jsx)(pi,{options:[{label:(0,$.jsxs)(T,{children:[`Yes, install `,(0,$.jsx)(T,{bold:!0,children:e})]}),value:`yes`},{label:`No`,value:`no`},{label:`No, and don't show plugin installation hints again`,value:`disable`}],onChange:o,onCancel:()=>i(`no`)})})]})})}Pi(),n_();var WA=3e4;function GA({tools:e,onSelect:t,onDismiss:n}){let r=Q.useRef(t),i=Q.useRef(n);r.current=t,i.current=n,Q.useEffect(()=>{let e=setTimeout(e=>e.current(),WA,i);return()=>clearTimeout(e)},[]);let a=e.map(e=>({label:`${e.name} — ${e.description.slice(0,60)} (score: ${e.score.toFixed(2)})`,value:e.name}));return a.push({label:`Dismiss`,value:`__dismiss__`}),(0,$.jsx)(i_,{title:`Tool Recommendation`,children:(0,$.jsx)(pi,{options:a,onChange:e=>{e===`__dismiss__`?i.current():(i.current(),r.current(e))}})})}mo();var KA=.15,qA=3;function JA(){let e=Q.useSyncExternalStore(Hn,La),t=Q.useMemo(()=>e.length===0?[]:e.slice(0,qA).map(e=>({name:e.name,description:e.description.slice(0,60),score:e.score})),[e]);return{tools:t,visible:t.length>0&&(t[0]?.score??0)>=KA,handleSelect:Q.useCallback(e=>{rr()},[]),handleDismiss:Q.useCallback(()=>{rr()},[])}}rt(),Ll(),B(),q(),of(),Up();function YA(){let{addNotification:e}=Au(),t=J(e=>e.plugins.installationStatus),{totalFailed:n,failedMarketplacesCount:r,failedPluginsCount:i}=(0,Q.useMemo)(()=>{if(!t)return{totalFailed:0,failedMarketplacesCount:0,failedPluginsCount:0};let e=t.marketplaces.filter(e=>e.status===`failed`),n=t.plugins.filter(e=>e.status===`failed`);return{totalFailed:e.length+n.length,failedMarketplacesCount:e.length,failedPluginsCount:n.length}},[t]);(0,Q.useEffect)(()=>{if(!ke()){if(!t){Y(`No installation status to monitor`);return}n!==0&&(Y(`Plugin installation status: ${r} failed marketplaces, ${i} failed plugins`),n!==0&&(Y(`Adding notification for ${n} failed installations`),e({key:`plugin-install-failed`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(T,{color:`error`,children:[n,` `,Hp(n,`plugin`),` failed to install`]}),(0,$.jsx)(T,{dimColor:!0,children:` · /plugin for details`})]}),priority:`medium`})))}},[e,n,r,i])}rt(),Ll(),B(),of(),G_();function XA(){let{addNotification:e}=Au(),[t,n]=(0,Q.useState)([]);(0,Q.useEffect)(()=>{if(!ke())return K_(e=>{Y(`Plugin autoupdate notification: ${e.length} plugin(s) updated`),n(e)})},[]),(0,Q.useEffect)(()=>{if(ke()||t.length===0)return;let n=t.map(e=>{let t=e.indexOf(`@`);return t>0?e.substring(0,t):e}),r=n.length<=2?n.join(` and `):`${n.length} plugins`;e({key:`plugin-autoupdate-restart`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(T,{color:`success`,children:[n.length===1?`Plugin`:`Plugins`,` updated: `,r]}),(0,$.jsx)(T,{dimColor:!0,children:` · Run /reload-plugins to apply`})]}),priority:`low`,timeoutMs:1e4}),Y(`Showing plugin autoupdate notification for: ${n.join(`, `)}`)},[t,e])}of(),ap(),no(),Rg(),Cp();function ZA(e,t,n,r){e(e=>({...e,plugins:{...e.plugins,installationStatus:{...e.plugins.installationStatus,marketplaces:e.plugins.installationStatus.marketplaces.map(e=>e.name===t?{...e,status:n,error:r}:e)}}}))}async function QA(e){Y(`performBackgroundPluginInstallations called`);try{let t=_g($r(),await ar().catch(()=>({}))),n=[...t.missing,...t.sourceChanged.map(e=>e.name)];if(e(e=>({...e,plugins:{...e.plugins,installationStatus:{marketplaces:n.map(e=>({name:e,status:`pending`})),plugins:[]}}})),n.length===0)return;Y(`Installing ${n.length} marketplace(s) in background`);let r=await hg({onProgress:t=>{switch(t.type){case`installing`:ZA(e,t.name,`installing`);break;case`installed`:ZA(e,t.name,`installed`);break;case`failed`:ZA(e,t.name,`failed`,t.error);break}}}),i={installed_count:r.installed.length,updated_count:r.updated.length,failed_count:r.failed.length,up_to_date_count:r.upToDate.length};if(Z(`tengu_marketplace_background_install`,i),Wf(`info`,`tengu_marketplace_background_install`,i),r.installed.length>0){G(),Y(`Auto-refreshing plugins after ${r.installed.length} new marketplace(s) installed`);try{await Lg(e)}catch(t){X(t),Y(`Auto-refresh failed, falling back to needsRefresh: ${t}`,{level:`warn`}),Es(`performBackgroundPluginInstallations: auto-refresh failed`),e(e=>e.plugins.needsRefresh?e:{...e,plugins:{...e.plugins,needsRefresh:!0}})}}else r.updated.length>0&&(G(),Es(`performBackgroundPluginInstallations: marketplaces reconciled`),e(e=>e.plugins.needsRefresh?e:{...e,plugins:{...e.plugins,needsRefresh:!0}}))}catch(e){X(e)}}Vf(),of(),no(),ic();async function $A(e){if(Y(`performStartupChecks called`),!Uf()){Y(`Trust not accepted for current directory - skipping plugin installations`);return}try{Y(`Starting background plugin installations`),await Br()&&(G(),Es(`performStartupChecks: seed marketplaces changed`),e(e=>e.plugins.needsRefresh?e:{...e,plugins:{...e.plugins,needsRefresh:!0}})),await QA(e)}catch(e){Y(`Error initiating background plugin installations: ${e}`)}}B();var ej=/https?:\/\/\S+/;function tj(){let[e,t]=(0,Q.useState)(nm.getInstance().getStatus());return(0,Q.useEffect)(()=>nm.getInstance().subscribe(t),[]),!e.isAuthenticating&&!e.error&&e.output.length===0||!e.isAuthenticating&&!e.error?null:(0,$.jsxs)(b,{flexDirection:`column`,borderStyle:`round`,borderColor:`permission`,paddingX:1,marginY:1,children:[(0,$.jsx)(T,{bold:!0,color:`permission`,children:`Cloud Authentication`}),e.output.length>0&&(0,$.jsx)(b,{flexDirection:`column`,marginTop:1,children:e.output.slice(-5).map((e,t)=>{let n=e.match(ej);if(!n)return(0,$.jsx)(T,{dimColor:!0,children:e},t);let r=n[0],i=n.index??0,a=e.slice(0,i),o=e.slice(i+r.length);return(0,$.jsxs)(T,{dimColor:!0,children:[a,(0,$.jsx)(C,{url:r,children:r}),o]},t)})}),e.error&&(0,$.jsx)(b,{marginTop:1,children:(0,$.jsx)(T,{color:`error`,children:e.error})})]})}Ll(),B(),Rl(),xu(),am(),fm(),rt();function nj(e){let{addNotification:t}=Au(),n=jc(),r=(0,Q.useMemo)(()=>xs(n,e),[n,e]),i=(0,Q.useMemo)(()=>ol(n),[n]),a=(0,Q.useRef)(null),o=Qp(),s=Dm(),c=o===`team`||o===`enterprise`,[l,u]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{ke()||(n.isUsingOverage&&!l&&(!c||s)?(t({key:`limit-reached`,text:i,priority:`immediate`}),u(!0)):!n.isUsingOverage&&l&&u(!1))},[n.isUsingOverage,i,l,t,s,c]),(0,Q.useEffect)(()=>{ke()||r&&r!==a.current&&(a.current=r,t({key:`rate-limit-warning`,jsx:(0,$.jsx)(T,{children:(0,$.jsx)(T,{color:`warning`,children:r})}),priority:`high`}))},[r,t])}Ll(),rt();function rj(e){let{addNotification:t}=Au(),n=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{if(ke())return;let r=_v(e);r&&r!==n.current&&(n.current=r,t({key:`model-deprecation-warning`,text:r,color:`warning`,priority:`high`})),r||(n.current=null)},[e,t])}s();var ij=``;function aj(){Qk(async()=>Rp()||a(process.env.DISABLE_INSTALLATION_CHECKS)||await og()===`development`?null:{timeoutMs:15e3,key:`npm-deprecation-warning`,text:ij,color:`warning`,priority:`high`})}Ll(),B(),Vf(),Ei(),rt();var oj=5;function sj({ideSelection:e,mcpClients:t,ideInstallationStatus:n}){let{addNotification:r,removeNotification:i}=Au(),{status:a,ideName:o}=vC(t),s=(0,Q.useRef)(!1),c=n?Vc(n?.ideType):!1,l=n?.error||c,u=a===`connected`&&(e?.filePath||e?.text&&e.lineCount>0),d=a===`connected`&&!u,f=l&&!c&&!d&&!u,p=l&&c&&!d&&!u;(0,Q.useEffect)(()=>{if(ke())return;if(gi()||a!==null||p){i(`ide-status-hint`);return}if(s.current||(Bf().ideHintShownCount??0)>=oj)return;let e=setTimeout((e,t)=>{hs(!0).then(n=>{let r=n[0]?.name;r&&!e.current&&(e.current=!0,zf(e=>({...e,ideHintShownCount:(e.ideHintShownCount??0)+1})),t({key:`ide-status-hint`,jsx:(0,$.jsxs)(T,{dimColor:!0,children:[`/ide for `,(0,$.jsx)(T,{color:`ide`,children:r})]}),priority:`low`}))})},3e3,s,r);return()=>clearTimeout(e)},[r,i,a,p]),(0,Q.useEffect)(()=>{if(!ke()){if(f||p||a!==`disconnected`||!o){i(`ide-status-disconnected`);return}r({key:`ide-status-disconnected`,text:`${o} disconnected`,color:`error`,priority:`medium`})}},[r,i,a,o,f,p]),(0,Q.useEffect)(()=>{if(!ke()){if(!p){i(`ide-status-jetbrains-disconnected`);return}r({key:`ide-status-jetbrains-disconnected`,text:`IDE plugin not connected · /status for info`,priority:`medium`})}},[r,i,p]),(0,Q.useEffect)(()=>{if(!ke()){if(!f){i(`ide-status-install-error`);return}r({key:`ide-status-install-error`,text:`IDE extension install failed (see /status for info)`,color:`error`,priority:`medium`})}},[r,i,f])}Vf();var cj=[e=>{if(uj(e.sonnet45To46MigrationTimestamp))return{key:`sonnet-46-update`,text:`Model updated to Sonnet 4.6`,color:`suggestion`,priority:`high`,timeoutMs:3e3}},e=>{let t=!!e.legacyOpusMigrationTimestamp;if(uj(e.legacyOpusMigrationTimestamp??e.opusProMigrationTimestamp))return{key:`opus-pro-update`,text:t?`Model updated to Opus 4.7 · Set CLAUDE_CODE_DISABLE_LEGACY_MODEL_REMAP=1 to opt out`:`Model updated to Opus 4.7`,color:`suggestion`,priority:`high`,timeoutMs:t?8e3:3e3}}];function lj(){Qk(()=>{let e=Bf(),t=[];for(let n of cj){let r=n(e);r&&t.push(r)}return t.length>0?t:null})}function uj(e){return e!==void 0&&Date.now()-e<3e3}am(),B(),Cp(),Vf();var dj=3;function fj(){Qk(async()=>{if((Bf().subscriptionNoticeCount??0)>=dj)return null;let e=await pj();return e===null?null:(zf(e=>({...e,subscriptionNoticeCount:(e.subscriptionNoticeCount??0)+1})),Z(`tengu_switch_to_subscription_notice_shown`,{}),{key:`switch-to-subscription`,jsx:(0,$.jsxs)(T,{color:`suggestion`,children:[`Use your existing Claude `,e,` plan with Claude Code`,(0,$.jsxs)(T,{color:`text`,dimColor:!0,children:[` `,`· /login to activate`]})]}),priority:`low`})})}async function pj(){if($p())return null;let e=await om();return e?e.account.has_claude_max?`Max`:e.account.has_claude_pro?`Pro`:null:null}Ll(),q(),Pm(),kp(),rt();var mj=`fast-mode-cooldown-started`,hj=`fast-mode-cooldown-expired`,gj=`fast-mode-org-changed`,_j=`fast-mode-overage-rejected`;function vj(){let{addNotification:e}=Au(),t=J(e=>e.fastMode),n=Qs();(0,Q.useEffect)(()=>{if(!ke()&&bm())return Sm(r=>{r?e({key:gj,color:`fastMode`,priority:`immediate`,text:`Fast mode is now available · /fast to turn on`}):t&&(n(e=>({...e,fastMode:!1})),e({key:gj,color:`warning`,priority:`immediate`,text:`Fast mode has been disabled by your organization`}))})},[e,t,n]),(0,Q.useEffect)(()=>{if(!ke()&&bm())return mm(t=>{n(e=>({...e,fastMode:!1})),e({key:_j,color:`warning`,priority:`immediate`,text:t})})},[e,n]),(0,Q.useEffect)(()=>{if(ke()||!t)return;let n=Nm((t,n)=>{let r=yj(n,Mp(t-Date.now(),{hideTrailingZeros:!0}));e({key:mj,invalidates:[hj],text:r,color:`warning`,priority:`immediate`})}),r=Om(()=>{e({key:hj,invalidates:[mj],color:`fastMode`,text:`Fast limit reset · now using fast mode`,priority:`immediate`})});return()=>{n(),r()}},[e,t])}function yj(e,t){switch(e){case`overloaded`:return`Fast mode overloaded and is temporarily unavailable · resets in ${t}`;case`rate_limit`:return`Fast limit reached and temporarily disabled · resets in ${t}`}}B(),zh();function bj({onRun:e,onCancel:t,reason:n}){let r=(0,Q.useRef)(!1);return j(`confirm:no`,t,{context:`Confirmation`}),(0,Q.useEffect)(()=>{r.current||(r.current=!0,e())},[e]),(0,$.jsxs)(b,{flexDirection:`column`,marginTop:1,children:[(0,$.jsx)(b,{children:(0,$.jsx)(T,{bold:!0,children:`Running feedback capture...`})}),(0,$.jsx)(b,{children:(0,$.jsxs)(T,{dimColor:!0,children:[`Press `,(0,$.jsx)(h,{shortcut:`Esc`,action:`cancel`}),` anytime`]})}),(0,$.jsx)(b,{children:(0,$.jsxs)(T,{dimColor:!0,children:[`Reason: `,n]})})]})}function xj(e){if(process.env.USER_TYPE!==`ant`)return!1;switch(e){case`feedback_survey_bad`:return!1;case`feedback_survey_good`:return!1;default:return!1}}function Sj(e){return process.env.USER_TYPE===`ant`&&e===`feedback_survey_good`?`/good-claude`:`/issue`}function Cj(e){switch(e){case`feedback_survey_bad`:return`You responded "Bad" to the feedback survey`;case`feedback_survey_good`:return`You responded "Good" to the feedback survey`;default:return`Unknown reason`}}var wj=()=>null;vf(),B();function Tj(){return process.env.USER_TYPE===`ant`?(0,$.jsxs)(b,{flexDirection:`row`,marginTop:1,width:`100%`,children:[(0,$.jsx)(b,{minWidth:2,children:(0,$.jsx)(T,{color:`warning`,children:`⚑`})}),(0,$.jsxs)(T,{children:[(0,$.jsx)(T,{dimColor:!0,children:`[ANT-ONLY] `}),(0,$.jsx)(T,{color:`warning`,bold:!0,children:`Something off with Claude?`}),(0,$.jsx)(T,{dimColor:!0,children:` /issue to report it`})]})]}):null}Zm(),Vd();var Ej=[/\bcurl\b/,/\bwget\b/,/\bssh\b/,/\bkubectl\b/,/\bsrun\b/,/\bdocker\b/,/\bbq\b/,/\bgsutil\b/,/\bgcloud\b/,/\baws\b/,/\bgit\s+push\b/,/\bgit\s+pull\b/,/\bgit\s+fetch\b/,/\bgh\s+(pr|issue)\b/,/\bnc\b/,/\bncat\b/,/\btelnet\b/,/\bftp\b/],Dj=[/^no[,!]\s/i,/\bthat'?s (wrong|incorrect|not (what|right|correct))\b/i,/\bnot what I (asked|wanted|meant|said)\b/i,/\bI (said|asked|wanted|told you|already said)\b/i,/\bwhy did you\b/i,/\byou should(n'?t| not)? have\b/i,/\byou were supposed to\b/i,/\btry again\b/i,/\b(undo|revert) (that|this|it|what you)\b/i];function Oj(e){for(let t of e){if(t.type!==`assistant`)continue;let e=t.message.content;if(Array.isArray(e))for(let t of e){if(t.type!==`tool_use`||!(`name`in t))continue;let e=t.name;if(e.startsWith(`mcp__`))return!1;if(e===`Bash`){let e=t.input?.command||``;if(Ej.some(t=>t.test(e)))return!1}}}return!0}function kj(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n.type!==`user`)continue;let r=Mn(n);if(r)return Dj.some(e=>e.test(r))}return!1}var Aj=3,jj=1800*1e3;function Mj(e,t){let n=(0,Q.useRef)(0),r=(0,Q.useRef)(-1),i=(0,Q.useMemo)(()=>Oj(e)&&kj(e),[e]);return process.env.USER_TYPE===`ant`?r.current===t?!0:Date.now()-n.current<jj||t<Aj||!i?!1:(n.current=Date.now(),r.current=t,!0):!1}rt(),B();function Nj(){return process.env.USER_TYPE===`ant`}function Pj(){let[e,t]=(0,Q.useState)(_t);return ae(()=>{t(_t())},Nj()?500:null),!Nj()||e.length===0?null:(0,$.jsxs)(T,{wrap:`truncate-end`,color:`warning`,children:[`[ANT-ONLY] slow sync: `,e.slice(-3).map(e=>`${e.operation} (${Math.round(e.durationMs)}ms)`).join(` · `)]})}u(),B(),wa(),Pi(),Zh(),q(),rt(),m_(),Vd(),jr(),qd(),fp(),Wc(),Gr();var Fj=24,Ij=11;function Lj(){return new Date().toISOString().split(`T`)[0]}function Rj({plan:e,sessionId:t,taskId:n,setMessages:r,readFileState:i,memorySelector:a,getAppState:o,setConversationId:s,resultDedupState:c}){Rt(`ultraplan-choice`);let l=Qs(),{rows:u,columns:f}=de(),p=Q.useMemo(()=>Math.min(Fj,Math.max(1,Math.floor(u/2)-Ij)),[u]),m=Q.useMemo(()=>w(e,Math.max(1,f-4),`wrap`).split(`
|
|
85
85
|
`),[e,f]),h=Math.max(0,m.length-p),[g,_]=Q.useState(0);Q.useEffect(()=>{_(e=>Math.min(e,h))},[h]);let v=m.length>p;oe((e,t)=>{if(!v)return;let n=Math.max(1,Math.floor(p/2));if(t.ctrl&&e===`d`||t.wheelDown){let e=t.wheelDown?3:n;_(t=>Math.min(t+e,h))}else if(t.ctrl&&e===`u`||t.wheelUp){let e=t.wheelUp?3:n;_(t=>Math.max(t-e,0))}});let y=m.slice(g,g+p).join(`
|
|
86
86
|
`),x=g>0,S=g<h,C=Q.useCallback(async a=>{switch(a){case`here`:sr({value:[`Ultraplan approved in browser. Here is the plan:`,``,`<ultraplan>`,e,`</ultraplan>`,``,`The user approved this plan in the remote session. Give them a brief summary, then start implementing.`].join(`
|
|
87
87
|
`),mode:`task-notification`});break;case`fresh`:let t=at(),n=await Hv(xn()).then(()=>!0,()=>!1);await g_({setMessages:r,readFileState:i,getAppState:o,setAppState:l,setConversationId:s}),n&&r(e=>[...e,Ed(`Previous session saved · resume with: claude --resume ${t}`,`suggestion`)]),sr({value:`Here is the approved implementation plan:\n\n${e}\n\nImplement this plan.`,mode:`prompt`});break;case`cancel`:{let t=Nv(Jd(),`${Lj()}-ultraplan.md`);await Uv(t,e,{encoding:`utf-8`}),r(e=>[...e,Ed(`Ultraplan rejected · Plan saved to ${mp(t)}`,`suggestion`)]);break}}Yu(n,l,e=>e.status===`running`?{...e,status:`completed`,endTime:Date.now()}:e),l(e=>e.ultraplanPendingChoice?{...e,ultraplanPendingChoice:void 0,ultraplanSessionUrl:void 0}:e),Kn(t)},[e,t,n,r,o,l,i,s]),E=Q.useMemo(()=>[{label:`Implement here`,value:`here`,description:`Inject plan into the current conversation`},{label:`Start new session`,value:`fresh`,description:`Clear conversation and start with only the plan`},{label:`Cancel`,value:`cancel`,description:`Don't implement — save plan and return`}],[]);return(0,$.jsx)(ge,{title:`Ultraplan approved`,subtitle:`How should the plan be implemented?`,onCancel:()=>{},hideInputGuide:!0,children:(0,$.jsxs)(b,{flexDirection:`column`,marginBottom:1,children:[(0,$.jsxs)(b,{flexDirection:`column`,marginBottom:1,children:[(0,$.jsx)(T,{children:y}),v&&(0,$.jsxs)(T,{dimColor:!0,children:[x?d.arrowUp:` `,S?d.arrowDown:` `,` `,g+1,`–`,Math.min(g+p,m.length),` of `,m.length,` · ctrl+u/ctrl+d to scroll`]})]}),(0,$.jsx)(pi,{options:E,onChange:e=>void C(e)})]})})}B(),Pi(),Zh(),q(),Vf(),El();function zj(){return!Bf().hasSeenUltraplanTerms}function Bj(){return zl()}function Vj({onChoice:e}){let[t]=Q.useState(zj),[n]=Q.useState(Bj),r=Q.useMemo(()=>is(n),[n]),i=J(e=>e.replBridgeEnabled),a=Qs(),o=Q.useCallback(r=>{let o=r===`run`&&i;o&&a(e=>e.replBridgeEnabled?{...e,replBridgeEnabled:!1,replBridgeExplicit:!1,replBridgeOutboundOnly:!1}:e),r!==`cancel`&&t&&zf(e=>e.hasSeenUltraplanTerms?e:{...e,hasSeenUltraplanTerms:!0}),e(r,{disconnectedBridge:o,promptIdentifier:n})},[e,i,a,t]),s=Q.useCallback(()=>{o(`cancel`)},[o]),c=[{label:`Run ultraplan`,value:`run`,description:i?`Disable remote control and launch in Claude Code on the web`:`launch in Claude Code on the web`},{label:`Not now`,value:`cancel`}];return(0,$.jsx)(ge,{title:`Run ultraplan in the cloud?`,subtitle:r.timeEstimate,onCancel:s,children:(0,$.jsxs)(b,{flexDirection:`column`,gap:1,children:[(0,$.jsxs)(b,{flexDirection:`column`,children:[(0,$.jsx)(T,{dimColor:!0,children:r.dialogBody}),t?(0,$.jsxs)(T,{dimColor:!0,children:[`For more information on Claude Code on the web:`,(0,$.jsx)(C,{url:Hu,children:Hu})]}):null]}),(0,$.jsx)(T,{dimColor:!0,children:i?`This will disable Remote Control for this session.`:r.dialogPipeline}),(0,$.jsx)(pi,{options:c,onChange:o})]})})}Z_(),B(),Vf(),$s();function Hj(e,t,n){let r=(0,Q.useRef)(!1),i=(0,Q.useRef)(n);i.current=n,(0,Q.useEffect)(()=>{if(t)return e.subscribe(()=>{let t=e.getState(),n=e.hasSelection();if(t?.isDragging){r.current=!1;return}if(!n){r.current=!1;return}if(r.current||!(Bf().copyOnSelect??!0))return;let a=e.copySelectionNoClear();if(!a||!a.trim()){r.current=!0;return}r.current=!0,i.current?.(a)})},[t,e])}function Uj(e){let[t]=y();(0,Q.useEffect)(()=>{e.setSelectionBgColor(Ns(t).selectionBg)},[e,t])}Ll(),B(),zh(),of();var Wj=40,Gj=.3,Kj=6,qj=200,Jj=15,Yj=15,Xj=3,Zj=1500,Qj=150,$j=5,eM=5,tM=80,nM=3,rM=6,iM=500;function aM(e){return!(e.wheelUp||e.wheelDown||(e.leftArrow||e.rightArrow||e.upArrow||e.downArrow||e.home||e.end||e.pageUp||e.pageDown)&&(e.shift||e.meta||e.super))}function oM(e){return!e.shift||e.meta?null:e.leftArrow?`left`:e.rightArrow?`right`:e.upArrow?`up`:e.downArrow?`down`:e.home?`lineStart`:e.end?`lineEnd`:null}function sM(e,t,n){if(!e.xtermJs){if(e.wheelMode&&n-e.time>Zj&&(e.wheelMode=!1,e.burstCount=0,e.mult=e.base),e.pendingFlip){if(e.pendingFlip=!1,t!==e.dir||n-e.time>qj)return e.dir=t,e.time=n,e.mult=e.base,Math.floor(e.mult);e.wheelMode=!0}let r=n-e.time;if(t!==e.dir&&e.dir!==0)return e.pendingFlip=!0,e.time=n,0;if(e.dir=t,e.time=n,e.wheelMode)if(r<eM)if(++e.burstCount>=5)e.wheelMode=!1,e.burstCount=0,e.mult=e.base;else return 1;else e.burstCount=0;if(e.wheelMode){let t=.5**(r/Qj),n=Math.max(Yj,e.base*2),i=1+(e.mult-1)*t+Jj*t;return e.mult=Math.min(n,i,e.mult+Xj),Math.floor(e.mult)}if(r>Wj)e.mult=e.base;else{let t=Math.max(Kj,e.base*2);e.mult=Math.min(t,e.mult+Gj)}return Math.floor(e.mult)}let r=n-e.time,i=t===e.dir;if(e.time=n,e.dir=t,i&&r<eM)return 1;if(!i||r>iM)e.mult=2,e.frac=0;else{let t=.5**(r/Qj);e.mult=Math.min(r>=tM?nM:rM,1+(e.mult-1)*t+$j*t)}let a=e.mult+e.frac,o=Math.floor(a);return e.frac=a-o,o}function cM(){let e=process.env.CLAUDE_CODE_SCROLL_SPEED;if(!e)return 1;let t=parseFloat(e);return Number.isNaN(t)||t<=0?1:Math.min(t,20)}function lM(e=!1,t=1){return{time:0,mult:t,dir:0,xtermJs:e,frac:0,base:t,pendingFlip:!1,wheelMode:!1,burstCount:0}}function uM(){let e=se(),t=cM();return Y(`wheel accel: ${e?`decay (xterm.js)`:`window (native)`} · base=${t} · TERM_PROGRAM=${process.env.TERM_PROGRAM??`unset`}`),lM(e,t)}var dM=2,fM=50,pM=200;function mM({scrollRef:e,isActive:t,onScroll:n,isModal:r=!1}){let i=ue(),{addNotification:a}=Au(),o=(0,Q.useRef)(null);function s(e){let t=le(),n=e.length,r;switch(t){case`native`:r=`copied ${n} chars to clipboard`;break;case`tmux-buffer`:r=`copied ${n} chars to tmux buffer · paste with prefix + ]`;break;case`osc52`:r=`sent ${n} chars via OSC 52 · check terminal clipboard settings if paste fails`;break}a({key:`selection-copied`,text:r,color:`suggestion`,priority:`immediate`,timeoutMs:t===`native`?2e3:4e3})}function c(){let e=i.copySelection();e&&s(e)}function l(e,t){let n=i.getState();if(!n?.anchor||!n.focus)return;let r=e.getViewportTop(),a=r+e.getViewportHeight()-1;if(n.anchor.row<r||n.anchor.row>a||n.focus.row<r||n.focus.row>a)return;let o=Math.max(0,e.getScrollHeight()-e.getViewportHeight()),s=e.getScrollTop()+e.getPendingDelta(),c=Math.max(0,Math.min(o,s+t))-s;if(c!==0)if(c>0)i.captureScrolledRows(r,r+c-1,`above`),i.shiftSelection(-c,r,a);else{let e=-c;i.captureScrolledRows(a-e+1,a,`below`),i.shiftSelection(e,r,a)}}return v({"scroll:pageUp":()=>{let t=e.current;if(!t)return;let r=-Math.max(1,Math.floor(t.getViewportHeight()/2));l(t,r);let i=_M(t,r);n?.(i,t)},"scroll:pageDown":()=>{let t=e.current;if(!t)return;let r=Math.max(1,Math.floor(t.getViewportHeight()/2));l(t,r);let i=_M(t,r);n?.(i,t)},"scroll:lineUp":()=>{i.clearSelection();let t=e.current;if(!t||t.getScrollHeight()<=t.getViewportHeight())return!1;o.current??(o.current=uM()),yM(t,sM(o.current,-1,performance.now())),n?.(!1,t)},"scroll:lineDown":()=>{i.clearSelection();let t=e.current;if(!t||t.getScrollHeight()<=t.getViewportHeight())return!1;o.current??(o.current=uM());let r=vM(t,sM(o.current,1,performance.now()));n?.(r,t)},"scroll:top":()=>{let t=e.current;t&&(l(t,-(t.getScrollTop()+t.getPendingDelta())),t.scrollTo(0),n?.(!1,t))},"scroll:bottom":()=>{let t=e.current;if(!t)return;let r=Math.max(0,t.getScrollHeight()-t.getViewportHeight());l(t,r-(t.getScrollTop()+t.getPendingDelta())),t.scrollTo(r),t.scrollToBottom(),n?.(!0,t)},"selection:copy":c},{context:`Scroll`,isActive:t}),v({"scroll:halfPageUp":()=>{let t=e.current;if(!t)return;let r=-Math.max(1,Math.floor(t.getViewportHeight()/2));l(t,r);let i=_M(t,r);n?.(i,t)},"scroll:halfPageDown":()=>{let t=e.current;if(!t)return;let r=Math.max(1,Math.floor(t.getViewportHeight()/2));l(t,r);let i=_M(t,r);n?.(i,t)},"scroll:fullPageUp":()=>{let t=e.current;if(!t)return;let r=-Math.max(1,t.getViewportHeight());l(t,r);let i=_M(t,r);n?.(i,t)},"scroll:fullPageDown":()=>{let t=e.current;if(!t)return;let r=Math.max(1,t.getViewportHeight());l(t,r);let i=_M(t,r);n?.(i,t)}},{context:`Scroll`,isActive:t}),oe((t,r,i)=>{let a=e.current;if(!a)return;let o=xM(a,bM(t,r),e=>l(a,e));o!==null&&(n?.(o,a),i.stopImmediatePropagation())},{isActive:t&&r}),oe((e,t,n)=>{if(!i.hasSelection())return;if(t.escape){i.clearSelection(),n.stopImmediatePropagation();return}if(t.ctrl&&!t.shift&&!t.meta&&e===`c`){c(),n.stopImmediatePropagation();return}let r=oM(t);if(r){i.moveFocus(r),n.stopImmediatePropagation();return}aM(t)&&i.clearSelection()},{isActive:t}),hM(e,i,t,n),Hj(i,t,s),Uj(i),null}function hM(e,t,n,r){let i=(0,Q.useRef)(null),a=(0,Q.useRef)(0),o=(0,Q.useRef)(0),s=(0,Q.useRef)(0),c=(0,Q.useRef)(r);c.current=r,(0,Q.useEffect)(()=>{if(!n)return;function r(){a.current=0,i.current&&(clearInterval(i.current),i.current=null)}function l(){let n=t.getState(),i=e.current,o=a.current;if(!n?.isDragging||!n.focus||!i||o===0||++s.current>pM){r();return}if(i.getPendingDelta()!==0)return;let l=i.getViewportTop(),u=l+i.getViewportHeight()-1;if(o<0){if(i.getScrollTop()<=0){r();return}let e=Math.min(dM,i.getScrollTop());t.captureScrolledRows(u-e+1,u,`below`),t.shiftAnchor(e,0,u),i.scrollBy(-2)}else{let e=Math.max(0,i.getScrollHeight()-i.getViewportHeight());if(i.getScrollTop()>=e){r();return}let n=Math.min(dM,e-i.getScrollTop());t.captureScrolledRows(l,l+n-1,`above`),t.shiftAnchor(-n,l,u),i.scrollBy(dM)}c.current?.(!1,i)}function u(e){o.current=e,a.current!==e&&(r(),a.current=e,s.current=0,l(),a.current===e&&(i.current=setInterval(l,fM)))}function d(){let n=e.current;if(!n){r();return}let i=n.getViewportTop(),a=i+n.getViewportHeight()-1,s=t.getState();(!s?.isDragging||s.scrolledOffAbove.length===0&&s.scrolledOffBelow.length===0)&&(o.current=0);let c=gM(s,i,a,o.current);if(c===0){if(o.current!==0&&s?.focus){let e=s.focus.row<i?-1:+(s.focus.row>a);e!==0&&e!==o.current&&(s.scrolledOffAbove=[],s.scrolledOffBelow=[],s.scrolledOffAboveSW=[],s.scrolledOffBelowSW=[],o.current=0)}r()}else u(c)}let f=t.subscribe(d);return()=>{f(),r(),o.current=0}},[n,e,t])}function gM(e,t,n,r=0){if(!e?.isDragging||!e.anchor||!e.focus)return 0;let i=e.focus.row,a=i<t?-1:+(i>n);return r===0?e.anchor.row<t||e.anchor.row>n?0:a:a===r?a:0}function _M(e,t){let n=Math.max(0,e.getScrollHeight()-e.getViewportHeight()),r=e.getScrollTop()+e.getPendingDelta()+t;return r>=n?(e.scrollTo(n),e.scrollToBottom(),!0):(e.scrollTo(Math.max(0,r)),!1)}function vM(e,t){let n=Math.max(0,e.getScrollHeight()-e.getViewportHeight());return e.getScrollTop()+e.getPendingDelta()+t>=n?(e.scrollToBottom(),!0):(e.scrollBy(t),!1)}function yM(e,t){if(e.getScrollTop()+e.getPendingDelta()-t<=0){e.scrollTo(0);return}e.scrollBy(-t)}function bM(e,t){if(t.meta)return null;if(!t.ctrl&&!t.shift){if(t.upArrow)return`lineUp`;if(t.downArrow)return`lineDown`;if(t.home)return`top`;if(t.end)return`bottom`}if(t.ctrl){if(t.shift)return null;switch(e){case`u`:return`halfPageUp`;case`d`:return`halfPageDown`;case`b`:return`fullPageUp`;case`f`:return`fullPageDown`;case`n`:return`lineDown`;case`p`:return`lineUp`;default:return null}}let n=e[0];if(!n||e!==n.repeat(e.length))return null;if(n===`G`||n===`g`&&t.shift)return`bottom`;if(t.shift)return null;switch(n){case`g`:return`top`;case`j`:return`lineDown`;case`k`:return`lineUp`;case` `:return`fullPageDown`;case`b`:return`fullPageUp`;default:return null}}function xM(e,t,n){switch(t){case null:return null;case`lineUp`:case`lineDown`:{let r=t===`lineDown`?1:-1;return n(r),_M(e,r)}case`halfPageUp`:case`halfPageDown`:{let r=Math.max(1,Math.floor(e.getViewportHeight()/2)),i=t===`halfPageDown`?r:-r;return n(i),_M(e,i)}case`fullPageUp`:case`fullPageDown`:{let r=Math.max(1,e.getViewportHeight()),i=t===`fullPageDown`?r:-r;return n(i),_M(e,i)}case`top`:return n(-(e.getScrollTop()+e.getPendingDelta())),e.scrollTo(0),!1;case`bottom`:{let t=Math.max(0,e.getScrollHeight()-e.getViewportHeight());return n(t-(e.getScrollTop()+e.getPendingDelta())),e.scrollTo(t),e.scrollToBottom(),!0}}}var SM=r({useFrustrationDetection:()=>wM});function CM(e){return e.filter(e=>`isApiErrorMessage`in e&&e.isApiErrorMessage===!0).length>=2}function wM(e,t,n,r){let[i,a]=(0,TM.useState)(`closed`),o=Bf(),s=Na(`product_feedback`),c=o.transcriptShareDismissed||!s||t||n||r,l=CM(e);return{state:c?`closed`:l&&i===`closed`?`transcript_prompt`:i,handleTranscriptSelect:t=>{c||(t===`yes`?(jk(e,`frustration`,crypto.randomUUID()),a(`submitted`)):(zf(e=>({...e,transcriptShareDismissed:!0})),a(`closed`)))}}}var TM,EM=t((()=>{TM=n(z(),1),Vf(),qa(),Mk()})),DM=r({useAntOrgWarningNotification:()=>OM});function OM(){}t((()=>{}));var kM=r({useProactive:()=>AM});function AM(e){let t=(0,jM.useRef)(e);t.current=e,(0,jM.useEffect)(()=>{if(!yh())return;let e=null,n=!1,r=!1;function i(){vh(Date.now()+MM),e=setTimeout(()=>{if(e=null,!fh()){i();return}let{isLoading:a,queuedCommandsLength:o,hasActiveLocalJsxUI:s,isInPlanMode:c}=t.current;if(a||c||s||o>0||r){i();return}r=!0,(async()=>{let e=await Sa({basePrompt:`<${np}>${new Date().toLocaleTimeString()}</${np}>`,currentDir:Jd(),shouldCreate:()=>!n});if(n){await ud({commands:e});return}let r=[];try{for(let n of e)t.current.onQueueTick(n),r.push(n)}catch(t){throw await ud({commands:e.filter(e=>!r.includes(e))}),t}})().catch(e=>Y(`[Proactive] failed to create tick: ${e}`,{level:`error`})).finally(()=>{r=!1}),i()},MM)}return i(),()=>{n=!0,e!==null&&(clearTimeout(e),e=null),vh(null)}},[yh(),dh(),ph()])}var jM,MM,NM=t((()=>{jM=n(z(),1),rp(),qd(),Sd(),of(),MM=3e4}));function PM(e){if(e.tokenBudget!==null){let t=Math.max(0,e.tokenBudget-e.tokensUsed);return`Tokens used: ${e.tokensUsed} / ${e.tokenBudget} (${t} remaining)`}return`Tokens used: ${e.tokensUsed}`}function FM(e){let t=rc(e),n=PM(e),r=`Continuation turns executed: ${e.turnsExecuted}`;return`<goal-steering type="continuation">
|
|
@@ -134,9 +134,9 @@ Instead, provide a brief summary:
|
|
|
134
134
|
3. Any blockers or issues encountered.
|
|
135
135
|
|
|
136
136
|
Then use the GoalTool to mark the goal as complete (if truly done) or leave it in its current state for the user to decide.
|
|
137
|
-
</goal-steering>`}var LM=t((()=>{})),RM=r({useGoalContinuation:()=>BM});function zM(e){Y(`[goal] hook: ${e}`)}function BM(e){let t=(0,VM.useRef)(e);t.current=e;let n=(0,VM.useRef)(!1),r=(0,VM.useRef)(!1);(0,VM.useLayoutEffect)(()=>{if(e.isLoading){n.current=!1;return}if(e.isQueryActiveNow?.()){zM(`skip: queryActiveNow=true`);return}if(e.wasAborted){zM(`skip: wasAborted=true`);return}if(n.current)return;if(qn().length>0){zM(`skip: yielding to queued user messages`);return}if(e.hasActiveLocalJsxUI){zM(`skip: activeLocalJsxUI`);return}if(e.isInPlanMode){zM(`skip: planMode`);return}let t=xl();if(!t){r.current=!1;return}if(t.status===`active`&&(r.current=!1),t.status===`budget_limited`&&!r.current){r.current=!0,n.current=!0;let e=IM(t);Y(`[goal] hook: budget limit reached, injecting wrap-up prompt`),io({value:e,mode:`prompt`,priority:`now`,isMeta:!0,origin:`goal-budget-limit`,skipSlashCommands:!0});return}if(t.status!==`active`){zM(`skip: status="${t.status}" (not active)`);return}if(t.turnsExecuted>=150){sd()&&(kc(),e.onMaxTurnsReached?.()),Y(`[goal] hook: MAX_GOAL_TURNS (150) reached, stopping`);return}n.current=!0;let i=uc();kc();let a=FM(t);Y(`[goal] hook: enqueuing turn ${i} for "${t.objective.slice(0,60)}"`),io({value:a,mode:`prompt`,priority:`now`,isMeta:!0,origin:`goal-continuation`,skipSlashCommands:!0}),e.onContinuationEnqueued?.({turn:i,objective:t.objective})},[e.isLoading,e.wasAborted,e.queuedCommandsLength,e.hasActiveLocalJsxUI,e.isInPlanMode])}var VM,HM=t((()=>{VM=n(z(),1),of(),Zo(),LM(),jr()})),UM=r({AntModelSwitchCallout:()=>WM,shouldShowModelSwitchCallout:()=>GM});function WM(e){return null}function GM(){return!1}t((()=>{}));var KM=r({UndercoverAutoCallout:()=>qM});function qM({onDone:e}){return(0,JM.useEffect)(()=>{e()},[e]),null}var JM,YM=t((()=>{JM=n(z(),1)}));rt(),uu(),Df(),u(),B(),wa(),qg(),Ll(),of(),s(),kp(),Sd(),Nt(),Zi(),wg(),Ul(),Ft(),ga(),Pa(),mu(),ef(),ap(),qd(),Lt(),Xt(),fc(),Vf(),fm(),Cp(),Vd(),tg(),rp(),Si(),Lu(),nv(),lg(),Xl(),Td(),e_(),q(),ui(),Wc(),Yn(),Ei(),Cn(),jr(),ql(),us(),dr(),El(),Os();var XM=process.env.USER_TYPE===`ant`?(EM(),e(SM)).useFrustrationDetection:()=>({state:`closed`,handleTranscriptSelect:()=>{}}),ZM=process.env.USER_TYPE===`ant`?e(DM).useAntOrgWarningNotification:()=>{},QM=(bh(),e(lh)),$M=e=>()=>{},eN=()=>!1,tN=()=>null,nN=(e,t)=>!1,rN=(NM(),e(kM)).useProactive,iN=(HM(),e(RM)).useGoalContinuation,aN=()=>({relayPipeMessage:()=>!1,pipeReturnHadErrorRef:{current:!1}}),oN=()=>({routeToSelectedPipes:()=>!1}),sN=process.env.USER_TYPE===`ant`?e(UM).AntModelSwitchCallout:null,cN=process.env.USER_TYPE===`ant`?e(UM).shouldShowModelSwitchCallout:()=>!1,lN=process.env.USER_TYPE===`ant`?(YM(),e(KM)).UndercoverAutoCallout:null,uN=[],dN=3e3;function fN(e){let t=[...e].sort((e,t)=>e-t),n=Math.floor(t.length/2);return t.length%2==0?Math.round((t[n-1]+t[n])/2):t[n]}function pN({showAllInTranscript:e,virtualScroll:t,searchBadge:n,suppressShowAll:r=!1,status:i}){let a=lo(`app:toggleTranscript`,`Global`,`ctrl+o`),o=lo(`transcript:toggleShowAll`,`Transcript`,`ctrl+e`);return(0,$.jsxs)(b,{noSelect:!0,alignItems:`center`,alignSelf:`center`,borderTopDimColor:!0,borderBottom:!1,borderLeft:!1,borderRight:!1,borderStyle:`single`,marginTop:1,paddingLeft:2,width:`100%`,children:[(0,$.jsxs)(T,{dimColor:!0,children:[`Showing detailed transcript · `,a,` to toggle`,n?` · n/N to navigate`:t?` · ${d.arrowUp}${d.arrowDown} scroll · home/end top/bottom`:r?``:` · ${o} to ${e?`collapse`:`show all`}`]}),i?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(b,{flexGrow:1}),(0,$.jsxs)(T,{children:[i,` `]})]}):n?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(b,{flexGrow:1}),(0,$.jsxs)(T,{dimColor:!0,children:[n.current,`/`,n.count,` `]})]}):null]})}function mN({jumpRef:e,count:t,current:n,onClose:r,onCancel:i,setHighlight:a,initialQuery:o}){let{query:s,cursorOffset:c}=w_({isActive:!0,initialQuery:o,onExit:()=>r(s),onCancel:i}),[l,u]=Q.useState(`building`);Q.useEffect(()=>{let t=!0,n,r=e.current?.warmSearchIndex;if(!r){u(null);return}return u(`building`),r().then(e=>{t&&(e<20?u(null):(u({ms:e}),n=setTimeout(()=>t&&u(null),2e3)))}),()=>{t=!1,n&&clearTimeout(n)}},[e]);let d=l!==`building`;(0,Q.useEffect)(()=>{d&&(e.current?.setSearchQuery(s),a(s))},[e,s,a,d]);let f=c,p=f<s.length?s[f]:` `;return(0,$.jsxs)(b,{borderTopDimColor:!0,borderBottom:!1,borderLeft:!1,borderRight:!1,borderStyle:`single`,marginTop:1,paddingLeft:2,width:`100%`,noSelect:!0,children:[(0,$.jsx)(T,{children:`/`}),(0,$.jsx)(T,{children:s.slice(0,f)}),(0,$.jsx)(T,{inverse:!0,children:p}),f<s.length&&(0,$.jsx)(T,{children:s.slice(f+1)}),(0,$.jsx)(b,{flexGrow:1}),l===`building`?(0,$.jsx)(T,{dimColor:!0,children:`indexing… `}):l?(0,$.jsxs)(T,{dimColor:!0,children:[`indexed in `,l.ms,`ms `]}):t===0&&s?(0,$.jsx)(T,{color:`error`,children:`no matches `}):t>0?(0,$.jsxs)(T,{dimColor:!0,children:[n,`/`,t,` `]}):null]})}var hN=[`⠂`,`⠐`],gN=`✳`,_N=960;function vN({isAnimating:e,title:t,disabled:n,noPrefix:r}){let i=M(),[a,o]=(0,Q.useState)(0);(0,Q.useEffect)(()=>{if(n||r||!e||!i)return;let t=setInterval(e=>e(e=>(e+1)%hN.length),_N,o);return()=>clearInterval(t)},[n,r,e,i]);let s=e?hN[a]??gN:gN;return ee(n?null:r?t:`${s} ${t}`),null}var yN=`<${ip}>`;function bN(e){return e.type===`text`&&typeof e.text==`string`&&e.text.includes(yN)}function xN({commands:t,debug:n,initialTools:r,initialMessages:i,pendingHookMessages:o,initialFileHistorySnapshots:s,initialContentReplacements:c,initialAgentName:l,initialAgentColor:u,mcpClients:d,dynamicMcpConfig:f,autoConnectIdeFlag:p,strictMcpConfig:m=!1,systemPrompt:h,appendSystemPrompt:g,onBeforeQuery:_,onTurnComplete:v,disabled:x=!1,mainThreadAgentDefinition:S,disableSlashCommands:C=!1,taskListId:w,remoteSessionConfig:D,directConnectConfig:O,sshSession:k,thinkingConfig:A}){let j=!!D,N=(0,Q.useMemo)(()=>a(process.env.CLAUDE_CODE_DISABLE_TERMINAL_TITLE),[]),ee=(0,Q.useMemo)(()=>process.env.USER_TYPE===`ant`&&a(process.env.CLAUDE_MORERIGHT),[]),P=(0,Q.useMemo)(()=>a(process.env.CLAUDE_CODE_DISABLE_VIRTUAL_SCROLL),[]);(0,Q.useMemo)(()=>a(process.env.CLAUDE_CODE_DISABLE_MESSAGE_ACTIONS),[]),(0,Q.useEffect)(()=>(Y(`[REPL:mount] REPL mounted, disabled=${x}`),()=>Y(`[REPL:unmount] REPL unmounting`)),[x]);let[I,ne]=(0,Q.useState)(S),L=J(e=>e.toolPermissionContext),R=J(e=>e.verbose),ie=J(e=>e.mcp),z=J(e=>e.plugins),ae=J(e=>e.agentDefinitions),se=J(e=>e.fileHistory),ce=J(e=>e.initialMessage),le=mC(),ue=J(e=>e.spinnerTip),pe=J(e=>e.expandedView)===`tasks`,B=J(e=>e.tasks),H=J(e=>e.elicitation),me=J(e=>e.ultraplanPendingChoice),he=J(e=>e.ultraplanLaunchPending),ge=J(e=>e.viewingAgentTaskId),U=Qs(),ve=ge?B[ge]:void 0,ye=Gc(ve)&&ve.retain&&!ve.diskLoaded;(0,Q.useEffect)(()=>{if(!ge||!ye)return;let e=ge;nd(hu(e)).then(t=>{U(n=>{let r=n.tasks[e];if(!Gc(r)||r.diskLoaded||!r.retain)return n;let i=r.messages??[],a=new Set(i.map(e=>e.uuid)),o=t?t.messages.filter(e=>!a.has(e.uuid)):[];return{...n,tasks:{...n.tasks,[e]:{...r,messages:[...o,...i],diskLoaded:!0}}}})})},[ge,ye,U]);let be=js(),xe=E(),Se=$g(),[Ce,we]=(0,Q.useState)(t);dk(j?void 0:lt(),we);let Te=Q.useSyncExternalStore(QM?.subscribeToProactiveChanges??$M,QM?.isProactiveActive??eN),Ee=Q.useSyncExternalStore(QM?.subscribeToProactiveChanges??$M,QM?.getNextTickAt??tN),De=J(e=>e.isBriefOnly),Oe=(0,Q.useMemo)(()=>Po(L),[L,Te,De]);pA();let[ke,Me]=(0,Q.useState)(f),Ne=(0,Q.useCallback)(e=>{Me(e)},[Me]),[Pe,Ie]=(0,Q.useState)(`prompt`),[Re,ze]=(0,Q.useState)(!1),[Be,He]=(0,Q.useState)(!1),[Ue,We]=(0,Q.useState)(``),Ke=(0,Q.useRef)(0),Ye=(0,Q.useRef)(void 0),Xe=(0,Q.useRef)(!1),{addNotification:Ze,removeNotification:Qe}=Au(),rt=nN,dt=lk(d,ie.clients),[ft,ht]=(0,Q.useState)(void 0),[_t,vt]=(0,Q.useState)(null),[bt,xt]=(0,Q.useState)(null),[Ct,wt]=(0,Q.useState)(!1),[Tt,Et]=(0,Q.useState)(()=>process.env.USER_TYPE===`ant`&&cN()),[Ot,jt]=(0,Q.useState)(()=>Ok(Se)),Mt=J(e=>e.showRemoteCallout),[Nt,Pt]=(0,Q.useState)(()=>Sv());lj(),fj(),sj({ideSelection:ft,mcpClients:dt,ideInstallationStatus:bt}),yA({mcpClients:dt}),YA(),XA(),O_(),nj(Se),vj(),rj(Se),aj(),ZM(),$k(),oA(),SA();let{recommendation:Ft,handleResponse:Lt}=RA(),{recommendation:Rt,handleResponse:zt}=VA(),Bt=JA(),Vt=(0,Q.useMemo)(()=>[...Oe,...r],[Oe,r]);dg({enabled:!j});let Ht=vc();(0,Q.useEffect)(()=>{j||$A(U)},[U,j]);let Wt=Gg(Vt,ie.tools,L),{tools:Kt,allowedAgentTypes:qt}=(0,Q.useMemo)(()=>{if(!I)return{tools:Wt,allowedAgentTypes:void 0};let e=kt(I,Wt,!1,!0);return{tools:e.resolvedTools,allowedAgentTypes:e.allowedAgentTypes}},[I,Wt]),Jt=uk(uk(Ce,z.commands),ie.commands),Yt=(0,Q.useMemo)(()=>C?[]:Jt,[C,Jt]);Hy(j?uN:ie.clients),pk(j?uN:ie.clients,ht);let[Xt,Zt]=(0,Q.useState)(`responding`),Qt=(0,Q.useRef)(Xt);Qt.current=Xt;let[$t,nn]=(0,Q.useState)([]),[an,on]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{if(an&&!an.isStreaming&&an.streamingEndedAt){let e=3e4-(Date.now()-an.streamingEndedAt);if(e>0){let t=setTimeout(on,e,null);return()=>clearTimeout(t)}else on(null)}},[an]);let[cn,ln]=(0,Q.useState)(null),un=(0,Q.useRef)(null);un.current=cn;let dn=(0,Q.useRef)(0),[fn,mn]=(0,Q.useState)(!1),hn=(0,Q.useRef)(()=>{}),gn=(0,Q.useRef)(()=>{}),vn=(0,Q.useRef)(null),yn=(0,Q.useRef)(null),xn=(0,Q.useRef)(0),Sn=Q.useRef(new Sy).current,Cn=Q.useSyncExternalStore(Sn.subscribe,Sn.getSnapshot),[wn,Tn]=Q.useState(D?.hasInitialPrompt??!1),W=Cn||wn,[Dn,On]=Q.useState(void 0),kn=Q.useRef(0),An=Q.useRef(!1),jn=Q.useRef(0),Mn=Q.useRef(0),Nn=Q.useRef(null),Pn=Q.useCallback(()=>{jn.current=Date.now(),Mn.current=0,Nn.current=null},[]),Fn=Q.useRef(!1);Cn&&!Fn.current&&Pn(),Fn.current=Cn;let In=Q.useCallback(e=>{Tn(e),e&&Pn()},[Pn]),Ln=Q.useRef(void 0),[zn,Bn]=Q.useState(!1),[Vn,Hn]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{Vn?.notifications&&Vn.notifications.forEach(e=>{Ze({key:`auto-updater-notification`,text:e,priority:`low`})})},[Vn,Ze]),(0,Q.useEffect)(()=>{pl()&&Rs().then(e=>{e&&Ze({key:`tmux-mouse-hint`,text:e,priority:`low`})})},[]);let[Un,Wn]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{process.env.USER_TYPE===`ant`&&(async()=>{let{isInternalModelRepo:e}=await import(`./commitAttribution-Lb3qUlAR.js`);await e();let{shouldShowUndercoverAutoNotice:t}=await import(`./undercover-B-kKUWtK.js`);t()&&Wn(!0)})()},[]);let[Gn,Kn]=(0,Q.useState)(null),qn=(0,Q.useRef)(null),Jn=(0,Q.useCallback)(e=>{if(e?.isLocalJSXCommand){let{clearLocalJSX:t,...n}=e;qn.current={...n,isLocalJSXCommand:!0},Kn(n);return}if(qn.current){if(e?.clearLocalJSX){qn.current=null,Kn(null),dn.current=Date.now();return}return}if(e?.clearLocalJSX){Kn(null);return}Kn(e)},[]),[Yn,Xn]=(0,Q.useState)([]),[Zn,Qn]=(0,Q.useState)(null),[$n,er]=(0,Q.useState)([]),[tr,nr]=(0,Q.useState)([]),rr=(0,Q.useRef)(new Map),ar=J(e=>e.settings.terminalTitleFromRename)===!1?void 0:Sl(at()),[or,sr]=(0,Q.useState)(),cr=(0,Q.useRef)((i?.length??0)>0),ur=I?.agentType,dr=ar??ur??or??`Claude Code`,fr=Yn.length>0||tr.length>0,pr=Gn?.isLocalJSXCommand===!0&&Gn?.jsx!=null,mr=W&&!fr&&!pr;(0,Q.useEffect)(()=>{if(W&&!fr&&!pr)return hy(),()=>gy()},[W,fr,pr]);let hr=fr||pr?`waiting`:W?`busy`:`idle`,_r=hr===`waiting`?Yn.length>0?`approve ${Yn[0].tool.name}`:pr?`dialog open`:`input needed`:void 0;(0,Q.useEffect)(()=>{Rd({status:hr,waitingFor:_r})},[hr,_r]),F(null);let[G,yr]=(0,Q.useState)(i??[]),br=(0,Q.useRef)(G),xr=(0,Q.useRef)(!1),K=(0,Q.useCallback)(e=>{let t=br.current,n=typeof e==`function`?e(br.current):e;if(br.current=n,n.length<kn.current)kn.current=0;else if(n.length>t.length&&An.current){let e=n.length-t.length;(t.length===0||n[0]===t[0]?n.slice(-e):n.slice(0,e)).some(ii)?An.current=!1:kn.current=n.length}yr(n)},[]),Sr=(0,Q.useCallback)(e=>{e===void 0?An.current=!1:(kn.current=br.current.length,An.current=!0),On(e)},[]),{dividerIndex:Cr,dividerYRef:wr,onScrollAway:Tr,onRepin:Or,jumpToNew:kr,shiftDivider:Ar}=rv(G.length);eA(G,K,W);let[jr,Nr]=(0,Q.useState)(null),Pr=(0,Q.useRef)(null),Ir=(0,Q.useMemo)(()=>ev(G,Cr),[Cr,G.length]),Lr=(0,Q.useCallback)(()=>{vn.current?.scrollToBottom(),Or(),Nr(null)},[Or,Nr]),Rr=G.at(-1),zr=Rr!=null&&ii(Rr);(0,Q.useEffect)(()=>{zr&&Lr()},[zr,Rr,Lr]);let{maybeLoadOlder:Br}=yO({config:D,setMessages:K,scrollRef:vn,onPrepend:Ar}),Wr=(0,Q.useCallback)((e,t)=>{xn.current=Date.now(),e?Or():(Tr(t),Br(t))},[Or,Tr,Br,U]),Gr=FO(o,K),Kr=(0,Q.useDeferredValue)(Q.useMemo(()=>G.length>500?G.slice(-500):G,[G])),qr=G.length-Kr.length;qr>0&&Y(`[useDeferredValue] Messages deferred by ${qr} (${Kr.length}→${G.length})`);let[Jr,Xr]=(0,Q.useState)(null),[Zr,Qr]=(0,Q.useState)(()=>hv()),$r=(0,Q.useRef)(Zr);$r.current=Zr;let ei=(0,Q.useRef)(null),ni=(0,Q.useCallback)(e=>{rt($r.current,e)||($r.current===``&&e!==``&&Date.now()-xn.current>=dN&&Lr(),$r.current=e,Qr(e),Bn(e.trim().length>0))},[Bn,Lr,rt]);(0,Q.useEffect)(()=>{if(Zr.trim().length===0)return;let e=setTimeout(Bn,1500,!1);return()=>clearTimeout(e)},[Zr]);let[ri,ai]=(0,Q.useState)(`prompt`),[oi,si]=(0,Q.useState)(),ci=(0,Q.useCallback)(e=>{let t=new Set(e);we(e=>e.filter(e=>t.has(e.name)||da.has(e)))},[we]),[ui,pi]=(0,Q.useState)(new Set),mi=(0,Q.useRef)(!1),hi=iO({config:D,setMessages:K,setIsLoading:In,onInit:ci,setToolUseConfirmQueue:Xn,tools:Vt,setStreamingToolUses:nn,setStreamMode:Zt,setInProgressToolUseIDs:pi}),gi=sO({config:O,setMessages:K,setIsLoading:In,setToolUseConfirmQueue:Xn,tools:Vt}),_i=cO({session:k,setMessages:K,setIsLoading:In,setToolUseConfirmQueue:Xn,tools:Vt}),vi=_i.isRemoteMode?_i:gi.isRemoteMode?gi:hi,[yi,Si]=(0,Q.useState)({}),[Ci,wi]=(0,Q.useState)(0),Ei=(0,Q.useRef)(0),Oi=(0,Q.useRef)([]),Ai=(0,Q.useCallback)(e=>{let t=Ei.current;if(Ei.current=e(t),Ei.current>t){let e=Oi.current;if(e.length>0){let t=e.at(-1);t.lastTokenTime=Date.now(),t.endResponseLength=Ei.current}}},[]),[ji,Mi]=(0,Q.useState)(null),Ni=!(J(e=>e.settings.prefersReducedMotion)??!1)&&!V(),Pi=(0,Q.useCallback)(e=>{Ni&&Mi(e)},[Ni]),Fi=ji&&Ni&&ji.substring(0,ji.lastIndexOf(`
|
|
138
|
-
`)+1)||null,[Ii,Li]=(0,Q.useState)(0),[Ri,Bi]=(0,Q.useState)(null),[Vi,Hi]=(0,Q.useState)(null),[Wi,Gi]=(0,Q.useState)(null),[Ki,qi]=(0,Q.useState)(!1),[Ji,Yi]=(0,Q.useState)(void 0),[Xi,Zi]=(0,Q.useState)(!1),[Qi,$i]=(0,Q.useState)(Bv()),[ta,na]=(0,Q.useState)(null),ia=(0,Q.useRef)(!1),oa=(0,Q.useRef)(Ii);oa.current=Ii;let[sa]=(0,Q.useState)(()=>({current:Eo(i,c)}));cc(()=>{sa.current=cu()});let[ca,la]=(0,Q.useState)(Bf().hasAcknowledgedCostThreshold),[fa,pa]=(0,Q.useState)(`INSERT`),[ma,ha]=(0,Q.useState)(!1),[ga,_a]=(0,Q.useState)(!1),[va,ba]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{me&&ma&&ha(!1)},[me,ma]);let Sa=M(),Ca=(0,Q.useRef)(Sa);Ca.current=Sa;let[wa]=y(),Ta=Q.useRef(!1),Ea=(0,Q.useCallback)(()=>{if(Ta.current)return;Ta.current=!0;let e=br.current.slice(Xa.current);for(let t of ml(e))Ya.current.add(t);Xa.current=br.current.length,cA({theme:wa,readFileState:Ja.current,bashTools:Ya.current}).then(async e=>{if(e){let t=await e.content({theme:wa});U(e=>({...e,spinnerTip:t})),lA(e)}else U(e=>e.spinnerTip===void 0?e:{...e,spinnerTip:void 0})})},[U,wa]),Da=(0,Q.useCallback)(()=>{In(!1),Sr(void 0),Ei.current=0,Oi.current=[],Mi(null),nn([]),Bi(null),Hi(null),Gi(null),Ea(),Ch(),tu()},[Ea]),Oa=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{{if(L.mode!==`auto`){Oa.current=!1;return}if(Oa.current||(Bf().autoPermissionsNotificationCount??0)>=3)return;let e=setTimeout((e,t)=>{e.current=!0,zf(e=>{let t=e.autoPermissionsNotificationCount??0;return t>=3?e:{...e,autoPermissionsNotificationCount:t+1}}),t(e=>[...e,Ed(bA,`warning`)])},800,Oa,K);return()=>clearTimeout(e)}},[L.mode,K]);let ka=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{if(ka.current)return;let e=rn();if(!e?.creationDurationMs||e.usedSparsePaths||e.creationDurationMs<15e3)return;ka.current=!0;let t=Math.round(e.creationDurationMs/1e3);K(e=>[...e,Ed(`Worktree creation took ${t}s. For large repos, set \`worktree.sparsePaths\` in .claude/settings.json to check out only the directories you need — e.g. \`{"worktree": {"sparsePaths": ["src", "packages/foo"]}}\`.`,`info`)])},[K]);let Ma=(0,Q.useMemo)(()=>{let e=G.findLast(e=>e.type===`assistant`);if(e?.type!==`assistant`)return!1;let t=e.message?.content,n=(Array.isArray(t)?t:[]).filter(e=>e.type===`tool_use`&&ui.has(e.id));return n.length>0&&n.every(e=>e.type===`tool_use`&&e.name===`Sleep`)},[G,ui]),{onBeforeQuery:Na,onTurnComplete:Pa,render:Fa}=MO({enabled:ee,setMessages:K,inputValue:Zr,setInputValue:ni,setToolJSX:Jn}),Ia=(!Gn||Gn.showSpinner===!0)&&Yn.length===0&&tr.length===0&&(W||Dn||yo()>0)&&!Ma&&(!Fi||De),La=Yn.length>0||tr.length>0||$n.length>0||H.queue.length>0,Ra=Ik(G,W,Ci,`session`,La),za=jO(K),Ba=Mj(G,Ci),Va=(0,Q.useMemo)(()=>({...Ra,handleSelect:e=>{so.current=!1;let t=Ra.handleSelect(e);e===`bad`&&!t&&xj(`feedback_survey_bad`)&&(ao(`feedback_survey_bad`),so.current=!0)}}),[Ra]),Ua=Wk(G,W,La,{enabled:!j}),Wa=Bk(G,W,La,{enabled:!j}),Ga=XM(G,W,La,Va.state!==`closed`||Ua.state!==`closed`||Wa.state!==`closed`);xk({autoConnectIdeFlag:p,ideToInstallExtension:_t,setDynamicMcpConfig:Me,setShowIdeOnboarding:wt,setIDEInstallationState:xt}),mA(s,se,e=>U(t=>({...t,fileHistory:e})));let Ka=(0,Q.useCallback)(async(t,n,r)=>{let i=performance.now();try{let a=zu(n.messages),o=Is();await Wo(`resume`,{getAppState:()=>be.getState(),setAppState:U,signal:AbortSignal.timeout(o),timeoutMs:o});let s=await nu(`resume`,{sessionId:t,agentType:I?.agentType,model:Se});a.push(...s),r===`fork`?En(n,Ec(t)):pn(n,Ec(t)),Ng(n,U),n.fileHistorySnapshots&&ti(n);let{agentDefinition:c}=jg(n.agentSetting,S,ae);ne(c),U(e=>({...e,agent:c?.agentType})),U(e=>({...e,standaloneAgentContext:Mg(n.agentName,n.agentColor)})),eo(n.agentName),$a(a,n.projectPath??ct()),Da(),ln(null),$i(t);let l=ls(t);Ts(),pt(),mt(Ec(t),n.fullPath?jv(n.fullPath):null);let{renameRecordingForSession:u}=await import(`./asciicast-DYbkzGCN.js`);if(await u(),await tc(),jl(),Ql(n),n.goal){let{hydrateGoalFromTranscript:r}=(yu(),e(Ol)),i=new Map;i.set(t,n.goal),r(i,t)}if(cr.current=!0,sr(void 0),r!==`fork`)Pg(),Fg(n.worktreeSession),Dr(),vo({abortController:new AbortController,getAppState:()=>be.getState(),setAppState:U});else{let e=rn();e&&en(e)}l&&tt(l),sa.current&&r!==`fork`&&(sa.current=Bo(a,n.contentReplacements??[])),K(()=>a),Jn(null),ni(``),Z(`tengu_session_resumed`,{entrypoint:r,success:!0,resume_duration_ms:Math.round(performance.now()-i)})}catch(e){throw Z(`tengu_session_resumed`,{entrypoint:r,success:!1}),e}},[Da,U]),[qa]=(0,Q.useState)(()=>oh(100)),Ja=(0,Q.useRef)(qa),Ya=(0,Q.useRef)(new Set),Xa=(0,Q.useRef)(0),Za=(0,Q.useRef)(new Set),Qa=(0,Q.useRef)(new Set),$a=(0,Q.useCallback)((e,t)=>{let n=hc(e,t,100);Ja.current=ch(Ja.current,n);for(let t of ml(e))Ya.current.add(t)},[]);(0,Q.useEffect)(()=>{i&&i.length>0&&($a(i,ct()),vo({abortController:new AbortController,getAppState:()=>be.getState(),setAppState:U}))},[]);let{status:to,reverify:no}=IO(),[ro,ao]=(0,Q.useState)(null),so=(0,Q.useRef)(!1),[co,lo]=(0,Q.useState)(null),[uo,fo]=(0,Q.useState)(!1),po=!W&Ξfunction mo(){if(uo||co)return;if(Ki)return`message-selector`;if(zn)return;if($n[0])return`sandbox-permission`;let e=!Gn||Gn.shouldContinueAnimation;if(e&&Yn[0])return`tool-permission`;if(e&&tr[0])return`prompt`;if(e&&H.queue[0])return`elicitation`;if(e&&po)return`cost`;if(e&&ta)return`idle-return`;if(e&&!W&&me)return`ultraplan-choice`;if(e&&!W&&he)return`ultraplan-launch`;if(e&&Ct)return`ide-onboarding`;if(process.env.USER_TYPE===`ant`&&e&&Tt)return`model-switch`;if(process.env.USER_TYPE===`ant`&&e&&Un)return`undercover-callout`;if(e&&Ot)return`effort-callout`;if(e&&Mt)return`remote-callout`;if(e&&Ft)return`lsp-recommendation`;if(e&&Rt)return`plugin-hint`;if(e&&Bt.visible)return`search-extra-tools-hint`;if(e&&Nt)return`desktop-upsell`}let ho=mo(),go=zn&&($n[0]||Yn[0]||tr[0]||H.queue[0]||po);Ln.current=ho,(0,Q.useEffect)(()=>{if(!W)return;let e=ho===`tool-permission`,t=Date.now();e&&Nn.current===null?Nn.current=t:!e&&Nn.current!==null&&(Mn.current+=t-Nn.current,Nn.current=null)},[ho,W]);let bo=(0,Q.useRef)(ho);(0,Q.useLayoutEffect)(()=>{bo.current===`tool-permission`!=(ho===`tool-permission`)&&Lr(),bo.current=ho},[ho,Lr]);function So(){if(ho!==`elicitation`){if(dn.current!==0&&Date.now()-dn.current<500){dn.current=0,Y(`[onCancel] suppressed: local-jsx panel just dismissed`);return}if(dn.current=0,Y(`[onCancel] focusedInputDialog=${ho} streamMode=${Xt}`),QM?.pauseProactive(),Sn.getSnapshot()){let{getGoal:t,pauseGoal:n}=(Zo(),e(Cc)),{persistCurrentGoal:r}=(yu(),e(Ol));t()?.status===`active`&&(n(),r())}if(mn(!0),Sn.forceEnd(),ia.current=!1,ji?.trim()&&K(e=>[...e,eu({content:ji})]),Da(),$e(null),ho===`tool-permission`)Yn[0]?.onAbort(),Xn([]);else if(ho===`prompt`){for(let e of tr)e.reject(Error(`Prompt cancelled by user`));nr([]),cn?.abort(`user-cancel`)}else vi.isRemoteMode?vi.cancelRequest():cn?.abort(`user-cancel`);ln(null),Pa(br.current,!0)}}let Co=(0,Q.useCallback)(()=>{let e=ra(Zr,0);e&&(ni(e.text),ai(`prompt`),e.images.length>0&&Si(t=>{let n={...t};for(let t of e.images)n[t.id]=t;return n}))},[ni,ai,Zr,Si]),wo={setToolUseConfirmQueue:Xn,onCancel:So,onAgentsKilled:()=>K(e=>[...e,td()]),isMessageSelectorVisible:Ki||!!ma,screen:Pe,abortSignal:cn?.signal,popCommandFromQueue:Co,vimMode:fa,isLocalJSXCommand:Gn?.isLocalJSXCommand,isSearchingHistory:ga,isHelpOpen:va,inputMode:ri,inputValue:Zr,streamMode:Xt};(0,Q.useEffect)(()=>{st()>=5&&!Xi&&!ca&&(Z(`tengu_cost_threshold_reached`,{}),la(!0),jm()&&Zi(!0))},[G,Xi,ca]);let To=(0,Q.useCallback)(async e=>new Promise(t=>{let n=!1;function r(e){n||(n=!0,t(e))}er(t=>[...t,{hostPattern:e,resolvePromise:r}]);{let t=be.getState().replBridgePermissionCallbacks;if(t){let n=Bv();t.sendRequest(n,mg,{host:e.host},Bv(),`Allow network connection to ${e.host}?`);let r=t.onResponse(n,t=>{r();let n=t.behavior===`allow`;er(t=>(t.filter(t=>t.hostPattern.host===e.host).forEach(e=>e.resolvePromise(n)),t.filter(t=>t.hostPattern.host!==e.host)));let i=rr.current.get(e.host);if(i){for(let e of i)e();rr.current.delete(e.host)}}),i=()=>{r(),t.cancelRequest(n)},a=rr.current.get(e.host)??[];a.push(i),rr.current.set(e.host,a)}}}),[U,be]);(0,Q.useEffect)(()=>{let e=fi.getSandboxUnavailableReason();if(e){if(fi.isSandboxRequired()){process.stderr.write(`\nError: sandbox required but unavailable: ${e}\n sandbox.failIfUnavailable is set — refusing to start without a working sandbox.\n\n`),sn(1,`other`);return}Y(`sandbox disabled: ${e}`,{level:`warn`}),Ze({key:`sandbox-unavailable`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(T,{color:`warning`,children:`sandbox disabled`}),(0,$.jsx)(T,{dimColor:!0,children:` · /sandbox`})]}),priority:`medium`})}},[Ze]),fi.isSandboxingEnabled()&&fi.initialize(To).catch(e=>{process.stderr.write(`\n❌ Sandbox Error: ${df(e)}\n`),sn(1,`other`)});let Do=(0,Q.useCallback)((e,t)=>{U(n=>({...n,toolPermissionContext:{...e,mode:t?.preserveMode?n.toolPermissionContext.mode:e.mode}})),setImmediate(e=>{e(e=>(e.forEach(e=>{e.recheckPermission()}),e))},Xn)},[U,Xn]),Oo=ek(Xn,Do),ko=(0,Q.useCallback)((e,t,r,i)=>{let a=be.getState(),o=()=>{let e=be.getState(),t=Vr(e.toolPermissionContext,e.mcp.tools),n=vg(Vt,t,e.toolPermissionContext.mode);return I?kt(I,n,!1,!0).resolvedTools:n};return{abortController:r,options:{commands:Yt,tools:o(),debug:n,verbose:a.verbose,mainLoopModel:i,thinkingConfig:a.thinkingEnabled===!1?{type:`disabled`}:A,mcpClients:ck(d,a.mcp.clients),mcpResources:a.mcp.resources,ideInstallationStatus:bt,isNonInteractiveSession:!1,dynamicMcpConfig:ke,theme:wa,agentDefinitions:qt?{...a.agentDefinitions,allowedAgentTypes:qt}:a.agentDefinitions,customSystemPrompt:h,appendSystemPrompt:g,refreshTools:o},getAppState:()=>be.getState(),setAppState:U,messages:e,setMessages:K,updateFileHistoryState(e){U(t=>{let n=e(t.fileHistory);return n===t.fileHistory?t:{...t,fileHistory:n}})},updateAttributionState(e){U(t=>{let n=e(t.attribution);return n===t.attribution?t:{...t,attribution:n}})},openMessageSelector:()=>{x||qi(!0)},onChangeAPIKey:no,readFileState:Ja.current,setToolJSX:Jn,addNotification:Ze,appendSystemMessage:e=>K(t=>[...t,e]),sendOSNotification:e=>{ry(e,xe)},onChangeDynamicMcpConfig:Ne,onInstallIDEExtension:vt,nestedMemoryAttachmentTriggers:new Set,loadedNestedMemoryPaths:Qa.current,dynamicSkillDirTriggers:new Set,discoveredSkillNames:Za.current,setResponseLength:Ai,pushApiMetricsEntry:process.env.USER_TYPE===`ant`?e=>{let t=Date.now(),n=Ei.current;Oi.current.push({ttftMs:e,firstTokenTime:t,lastTokenTime:t,responseLengthBaseline:n,endResponseLength:n})}:void 0,setStreamMode:Zt,onCompactProgress:e=>{switch(e.type){case`hooks_start`:Hi(`claudeBlue_FOR_SYSTEM_SPINNER`),Gi(`claudeBlueShimmer_FOR_SYSTEM_SPINNER`),Bi(e.hookType===`pre_compact`?`Running PreCompact hooks…`:e.hookType===`post_compact`?`Running PostCompact hooks…`:`Running SessionStart hooks…`);break;case`compact_start`:Bi(`Compacting conversation`);break;case`compact_end`:Bi(null),Hi(null),Gi(null);break}},setInProgressToolUseIDs:pi,setHasInterruptibleToolInProgress:e=>{mi.current=e},resume:Ka,setConversationId:$i,requestPrompt:void 0,contentReplacementState:sa.current}},[Yt,Vt,I,n,d,bt,ke,wa,qt,be,U,no,Ze,K,Ne,Ka,(0,Q.useCallback)((e,t)=>n=>new Promise((r,i)=>{nr(a=>[...a,{request:n,title:e,toolInputSummary:t,resolve:r,reject:i}])}),[]),x,h,g,$i]),{handleBackgroundSession:Ao}=Ck({setMessages:K,setIsLoading:In,resetLoadingState:Da,setAbortController:ln,onBackgroundQuery:(0,Q.useCallback)(()=>{cn?.abort(`background`);let e=Dt(e=>e.mode===`task-notification`);(async()=>{let t=ko(br.current,[],new AbortController,Se),[n,r,i]=await Promise.all([dl(t.options.tools,Se,Array.from(L.additionalWorkingDirectories.keys()),t.options.mcpClients),Fr(),Rn()]),a=_o({mainThreadAgentDefinition:I,toolUseContext:t,customSystemPrompt:h,defaultSystemPrompt:n,appendSystemPrompt:g});t.renderedSystemPrompt=a;let o=(await Ti(e).catch(()=>[])).map(_n),s=new Set;for(let e of br.current)e.type===`attachment`&&e.attachment.type===`queued_command`&&e.attachment.commandMode===`task-notification`&&typeof e.attachment.prompt==`string`&&s.add(e.attachment.prompt);let c=o.filter(e=>e.attachment.type===`queued_command`&&(typeof e.attachment.prompt!=`string`||!s.has(e.attachment.prompt)));ki({messages:[...br.current,...c],queryParams:{systemPrompt:a,userContext:r,systemContext:i,canUseTool:Oo,toolUseContext:t,querySource:Bu()},description:dr,setAppState:U,agentDefinition:I})})()},[cn,Se,L,I,ko,h,g,Oo,U])}),jo=(0,Q.useCallback)(t=>{gr(t,t=>{if(Gt(t)?(pl()?K(e=>{let n=At(e,{includeSnipped:!0});return[...n.length>500?n.slice(-500):n,t]}):K(()=>[t]),$i(Bv()),QM?.setContextBlocked(!1)):t.type===`progress`&&Ui(t.data?.type)?K(e=>{let n=t.data;for(let r=e.length-1;r>=0;r--){let i=e[r];if(i.type!==`progress`)break;let a=i.data;if(i.parentToolUseID===t.parentToolUseID&&a?.type===n.type){let n=e.slice();return n[r]=t,n}}return[...e,t]}):K(e=>[...e,t]),t.type===`assistant`&&`isApiErrorMessage`in t&&t.isApiErrorMessage?QM?.setContextBlocked(!0):t.type===`assistant`&&QM?.setContextBlocked(!1),t.type===`assistant`&&`isApiErrorMessage`in t&&t.isApiErrorMessage){let n=(Di(t.message?.content??``)??``).toLowerCase();if(n.includes(`connection error`)||n.includes(`fetch failed`)||n.includes(`network error`)||n.includes(`enotfound`)||n.includes(`econnreset`)||n.includes(`etimedout`)){let{getGoal:t,pauseGoal:n}=(Zo(),e(Cc)),{persistCurrentGoal:r}=(yu(),e(Ol));t()?.status===`active`&&(n(),r(),Ze({key:`goal-auto-paused-connectivity-error`,text:`Detected connection error. Active goal was auto-paused. Run /goal resume after network recovers.`,priority:`immediate`}))}}},e=>{Ai(t=>t+e.length)},Zt,nn,e=>{K(t=>t.filter(t=>t!==e)),cl(e.uuid)},on,e=>{let t=Date.now(),n=Ei.current;Oi.current.push({...e,firstTokenTime:t,lastTokenTime:t,responseLengthBaseline:n,endResponseLength:n})},Pi)},[K,Ai,Zt,nn,on,Pi]),Mo=(0,Q.useCallback)(async(e,t,n,r,i,a,o)=>{if(r){let e=ck(d,be.getState().mcp.clients);Ut.handleQueryStart(e);let t=ya(e);t&&wd(t)}if(Vh(),!N&&!ar&&!ur&&!cr.current){let e=t.find(e=>e.type===`user`&&!e.isMeta),n=e?.type===`user`?Di(e.message.content):null;n&&!n.startsWith(`<local-command-stdout>`)&&!n.startsWith(`<command-message>`)&&!n.startsWith(`<command-name>`)&&!n.startsWith(`<bash-input>`)&&(cr.current=!0,eg(n,new AbortController().signal).then(e=>{e?sr(e):cr.current=!1},()=>{cr.current=!1}))}if(be.setState(e=>{let t=e.toolPermissionContext.alwaysAllowRules.command;return t===i||t?.length===i.length&&t.every((e,t)=>e===i[t])?e:{...e,toolPermissionContext:{...e.toolPermissionContext,alwaysAllowRules:{...e.toolPermissionContext.alwaysAllowRules,command:i}}}}),!r){t.some(Gt)&&($i(Bv()),QM?.setContextBlocked(!1)),Da(),ln(null);return}let s=ko(e,t,n,a),{tools:c,mcpClients:l}=s.options;if(o!==void 0){let e=s.getAppState;s.getAppState=()=>({...e(),effortValue:o})}fl(`query_context_loading_start`);let[,,u,f,p]=await Promise.all([void 0,dA(L,U,be.getState().fastMode),dl(c,a,Array.from(L.additionalWorkingDirectories.keys()),l),Fr(),Rn()]),m={...f,...QM?.isProactiveActive()&&!Ca.current?{terminalFocus:`The terminal is unfocused — the user is not actively watching.`}:{}};fl(`query_context_loading_end`);let _=_o({mainThreadAgentDefinition:I,toolUseContext:s,customSystemPrompt:h,defaultSystemPrompt:u,appendSystemPrompt:g});s.renderedSystemPrompt=_,fl(`query_query_start`),it(),ut(),nt();for await(let t of zi({messages:e,systemPrompt:_,userContext:m,systemContext:p,canUseTool:Oo,toolUseContext:s,querySource:Bu()}))jo(t);if(fl(`query_end`),process.env.USER_TYPE===`ant`&&Oi.current.length>0){let e=Oi.current,t=e.map(e=>e.ttftMs),n=e.map(e=>{let t=Math.round((e.endResponseLength-e.responseLengthBaseline)/4),n=e.lastTokenTime-e.firstTokenTime;return n>0?Math.round(t/(n/1e3)):0}),r=e.length>1,i=qe(),a=Ae(),o=Je(),s=Ge(),c=yt(),l=Ve(),u=Date.now()-jn.current;K(e=>[...e,Ls({ttftMs:r?fN(t):t[0],otps:r?fN(n):n[0],isP50:r,hookDurationMs:i>0?i:void 0,hookCount:a>0?a:void 0,turnDurationMs:u>0?u:void 0,toolDurationMs:o>0?o:void 0,toolCount:s>0?s:void 0,classifierDurationMs:c>0?c:void 0,classifierCount:l>0?l:void 0,configWriteCount:Hf()})])}Da(),Ds(),await v?.(br.current)},[d,Da,ko,L,U,h,v,g,Oo,I,jo,ar,N]),No=(0,Q.useCallback)(async(e,t,n,r,i,a,o,s)=>{let c=Sn.tryStart();if(c===null)return Z(`tengu_concurrent_onquery_detected`,{}),e.filter(e=>e.type===`user`&&!e.isMeta).map(e=>Di(e.message.content)).filter(e=>e!==null).forEach((e,t)=>{io({value:e,mode:`prompt`}),t===0&&Z(`tengu_concurrent_onquery_enqueued`,{})}),!1;try{as.current=!1,mn(!1),Pn(),K(t=>[...t,...e]),Ei.current=0,$e((o?Er(o):null)??je()),Oi.current=[],nn([]),Mi(null);let c=br.current;if(o&&await Na(o,c,e.length),a&&o&&!await a(o,c))return!0;try{await Mo(c,e,t,n,r,i,s)}catch(e){throw e}}finally{if(Sn.end(c)){mn(t.signal.aborted),Li(Date.now()),ia.current=!1,Da(),await Pa(br.current,t.signal.aborted),hn.current(),process.env.USER_TYPE===`ant`&&!t.signal.aborted&&U(e=>e.tungstenActiveSession===void 0||e.tungstenPanelAutoHidden===!0?e:{...e,tungstenPanelAutoHidden:!0});let e;je()!==null&&je()>0&&!t.signal.aborted&&(e={tokens:Fe(),limit:je(),nudges:et()}),$e(null);let n=Date.now()-jn.current-Mn.current;(n>3e4||e!==void 0)&&!t.signal.aborted&&!Te&&K(t=>[...t,gs(n,e,Pf(t,vr))]),ln(null)}if(t.signal.reason===`user-cancel`&&!Sn.isActive&&$r.current===``&&yo()===0&&!be.getState().viewingAgentTaskId){let e=br.current,t=e.findLast(bg);t&&Sg(e,e.lastIndexOf(t))&&(bi(),gn.current(t))}}return!0},[Mo,U,Da,Sn,Na,Pa]),Fo=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{let e=ce;if(!e||W||Fo.current)return;Fo.current=!0;async function t(e){if(e.clearContext){let t=e.message.planContent?It():void 0,{clearConversation:n}=await import(`./conversation-oK3aFzqO.js`);await n({setMessages:K,readFileState:Ja.current,discoveredSkillNames:Za.current,loadedNestedMemoryPaths:Qa.current,getAppState:()=>be.getState(),setAppState:U,setConversationId:$i}),cr.current=!1,sr(void 0),Ya.current.clear(),Xa.current=0,t&&xi(at(),t)}U(t=>{let n=e.mode?Ur(t.toolPermissionContext,$x(e.mode,e.allowedPrompts)):t.toolPermissionContext;return e.mode===`auto`&&(n=di({...n,mode:`auto`,prePlanMode:void 0})),{...t,initialMessage:null,toolPermissionContext:n}}),Kd()&&lr(e=>{U(t=>({...t,fileHistory:e(t.fileHistory)}))},e.message.uuid),await Gr();let t=e.message.message.content;if(typeof t==`string`&&!e.message.planContent)Io(t,{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}});else{let t=Lc();ln(t),No([e.message],t,!0,[],Se)}setTimeout(e=>{e.current=!1},100,Fo)}t(e)},[ce,W,K,U,No,Se,Kt]);let Io=(0,Q.useCallback)(async(e,t,n,r)=>{if(Lr(),QM?.resumeProactive(),os(e)){let n=xa({content:e});K(e=>[...e,n]),r?.fromKeybinding||gd({display:Gd(e,ri),pastedContents:yi}),ni(``),t.setCursorOffset(0),t.clearBuffer(),Si({}),ai(`prompt`),ht(void 0);return}if(!n&&e.trim().startsWith(`/`)){let n=ja(e,yi).trim(),i=n.indexOf(` `),a=i===-1?n.slice(1):n.slice(1,i),o=i===-1?``:n.slice(i+1).trim(),s=Yt.find(e=>Zu(e)&&(e.name===a||e.aliases?.includes(a)||Ss(e)===a));s?.name===`clear`&&xr.current&&(Z(`tengu_idle_return_action`,{action:`hint_converted`,variant:xr.current,idleMinutes:Math.round((Date.now()-oa.current)/6e4),messageCount:br.current.length,totalInputTokens:ot()}),xr.current=!1);let c=Sn.isActive&&(s?.immediate||r?.fromKeybinding);if(s&&c&&s.type===`local-jsx`){e.trim()===$r.current.trim()&&(ni(``),t.setCursorOffset(0),t.clearBuffer(),Si({}));let n=li(e).filter(e=>yi[e.id]?.type===`text`),i=n.length;Z(`tengu_paste_text`,{pastedTextCount:i,pastedTextBytes:n.reduce((e,t)=>e+(yi[t.id]?.content.length??0),0)}),Z(`tengu_immediate_command_executed`,{commandName:s.name,fromKeybinding:r?.fromKeybinding??!1}),(async()=>{let e=!1,n=(n,r)=>{e=!0,Jn({jsx:null,shouldHidePromptInput:!1,clearLocalJSX:!0});let i=[];if(n&&r?.display!==`skip`&&(Ze({key:`immediate-${s.name}`,text:n,priority:`immediate`}),!pl())){let e=r?.displayArgs??o;i.push(Sc(bn(Ss(s),e)),Sc(`<${ep}>${Pl(n)}</${ep}>`))}r?.metaMessages?.length&&i.push(...r.metaMessages.map(e=>xa({content:e,isMeta:!0}))),i.length&&K(e=>[...e,...i]),oi!==void 0&&(ni(oi.text),t.setCursorOffset(oi.cursorOffset),Si(oi.pastedContents),si(void 0))},r=ko(br.current,[],Lc(),Se),i=await(await s.load()).call(n,r,o);i&&!e&&Jn({jsx:i,shouldHidePromptInput:!1,isLocalJSXCommand:!0})})();return}}if(vi.isRemoteMode&&!e.trim())return;Number(process.env.CLAUDE_CODE_IDLE_THRESHOLD_MINUTES??75),Number(process.env.CLAUDE_CODE_IDLE_TOKEN_THRESHOLD??1e5),r?.fromKeybinding||(gd({display:n?e:Gd(e,ri),pastedContents:n?{}:yi}),ri===`bash`&&vw(e.trim()));let i=!n&&e.trim().startsWith(`/`),a=!W||n||vi.isRemoteMode;if(oi!==void 0&&!i&&a?(ni(oi.text),t.setCursorOffset(oi.cursorOffset),Si(oi.pastedContents),si(void 0)):a&&(r?.fromKeybinding||(ni(``),t.setCursorOffset(0)),Si({})),a&&(ai(`prompt`),ht(void 0),wi(e=>e+1),t.clearBuffer(),Ta.current=!1,!i&&ri===`prompt`&&!n&&!vi.isRemoteMode&&(Sr(e),Pn()),U(e=>({...e,attribution:Oh(e.attribution,e=>{Us(e).catch(e=>{Y(`Attribution: Failed to save snapshot: ${e}`)})})}))),n){let{queryRequired:t}=await Zs(n.state,n.speculationSessionTimeSavedMs,n.setAppState,e,{setMessages:K,readFileState:Ja,cwd:ct()});if(t){let e=Lc();ln(e),No([],e,!0,[],Se)}return}if(vi.isRemoteMode&&!(i&&Yt.find(t=>{let n=e.trim().slice(1).split(/\s/)[0];return Zu(t)&&(t.name===n||t.aliases?.includes(n)||Ss(t)===n)})?.type===`local-jsx`)){let t=Object.values(yi),n=t.filter(e=>e.type===`image`),r=n.length>0?n.map(e=>e.id):void 0,i=e.trim(),a=e.trim();if(t.length>0){let n=[],r=[],o=e.trim();o&&(n.push({type:`text`,text:o}),r.push({type:`text`,text:o}));for(let e of t)if(e.type===`image`){let t={type:`base64`,media_type:e.mediaType??`image/png`,data:e.content};n.push({type:`image`,source:t}),r.push({type:`image`,source:t})}else n.push({type:`text`,text:e.content}),r.push({type:`text`,text:e.content});i=n,a=r}let o=xa({content:i,imagePasteIds:r});K(e=>[...e,o]),await vi.sendMessage(a,{uuid:o.uuid});return}await Gr(),await nk({input:e,helpers:t,queryGuard:Sn,isExternalLoading:wn,mode:ri,commands:Yt,onInputChange:ni,setPastedContents:Si,setToolJSX:Jn,getToolUseContext:ko,messages:br.current,mainLoopModel:Se,pastedContents:yi,ideSelection:ft,setUserInputOnProcessing:Sr,setAbortController:ln,abortController:cn,onQuery:No,setAppState:U,querySource:Bu(),onBeforeQuery:_,canUseTool:Oo,addNotification:Ze,setMessages:K,streamMode:Qt.current,hasInterruptibleToolInProgress:mi.current}),(i||W)&&oi!==void 0&&(ni(oi.text),t.setCursorOffset(oi.cursorOffset),Si(oi.pastedContents),si(void 0))},[Sn,W,wn,ri,Yt,ni,ai,Si,wi,ht,Jn,ko,Se,yi,ft,Sr,ln,Ze,No,oi,si,U,_,Oo,hi,K,Gr,Lr]),Lo=(0,Q.useCallback)(()=>{let e=ro?Sj(ro):`/issue`;ao(null),Io(e,{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}}).catch(t=>{Y(`Auto-run ${e} failed: ${df(t)}`)})},[Io,ro]),Ro=(0,Q.useCallback)(()=>{ao(null)},[]),zo=(0,Q.useCallback)(()=>{let e=process.env.USER_TYPE===`ant`?`/issue`:`/feedback`;Io(e,{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}}).catch(e=>{Y(`Survey feedback request failed: ${e instanceof Error?e.message:String(e)}`)})},[Io]),Vo=(0,Q.useRef)(Io);Vo.current=Io;let Ho=(0,Q.useCallback)(()=>{Vo.current(`/rate-limit-options`,{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}})},[]),Uo=(0,Q.useCallback)(async()=>{if(fo(!0),Yr()){Gv(`tmux`,[`detach-client`],{stdio:`ignore`}),fo(!1);return}if(rn()!==null){lo((0,$.jsx)(N_,{showWorktree:!0,onDone:()=>{},onCancel:()=>{lo(null),fo(!1)}}));return}let e=await(await Yl.load()).call(()=>{});lo(e),e===null&&fo(!1)},[]),Go=(0,Q.useCallback)(()=>{qi(e=>!e)},[]),Ko=(0,Q.useCallback)(e=>{let t=br.current,n=t.lastIndexOf(e);if(n===-1)return;Z(`tengu_conversation_rewind`,{preRewindMessageCount:t.length,postRewindMessageCount:n,messagesRemoved:t.length-n,rewindToMessageIndex:n}),K(t.slice(0,n)),$i(Bv()),ys();let r=e.permissionMode;U(e=>({...e,toolPermissionContext:r&&e.toolPermissionContext.mode!==r?{...e.toolPermissionContext,mode:r}:e.toolPermissionContext,promptSuggestion:{text:null,promptId:null,shownAt:0,acceptedAt:0,generationRequestId:null}}))},[K,U]),qo=(0,Q.useCallback)(e=>{Ko(e);let t=ea(e);if(t&&(ni(t.text),ai(t.mode)),Array.isArray(e.message.content)&&e.message.content.some(e=>e.type===`image`)){let t=e.message.content.filter(e=>e.type===`image`);if(t.length>0){let n={};t.forEach((t,r)=>{if(t.source.type===`base64`){let i=e.imagePasteIds?.[r]??r+1;n[i]={id:i,type:`image`,content:t.source.data,mediaType:t.source.media_type}}}),Si(n)}}},[Ko,ni]);gn.current=qo;let Jo=(0,Q.useCallback)(async e=>{setImmediate((e,t)=>e(t),qo,e)},[qo]),Xo=e=>{let t=e.slice(0,24);return G.findIndex(e=>e.uuid.slice(0,24)===t)},{enter:Qo,handlers:$o}=Aa(jr,Nr,Pr,{copy:e=>void re(e).then(e=>{e&&process.stdout.write(e),Ze({key:`selection-copied`,text:`copied`,color:`success`,priority:`immediate`,timeoutMs:2e3})}),edit:async e=>{let t=Xo(e.uuid),n=t>=0?G[t]:void 0;if(!n||!bg(n))return;let r=!await oo(se,n.uuid),i=Sg(G,t);r&&i?(So(),Jo(n)):(Yi(n),qi(!0))}});async function es(){no();let e=await St();if(e.length>0){let t=e.map(e=>` [${e.type}] ${e.path} (${e.content.length} chars)${e.parent?` (included by ${e.parent})`:``}`).join(`
|
|
137
|
+
</goal-steering>`}var LM=t((()=>{})),RM=r({useGoalContinuation:()=>BM});function zM(e){Y(`[goal] hook: ${e}`)}function BM(e){let t=(0,VM.useRef)(e);t.current=e;let n=(0,VM.useRef)(!1),r=(0,VM.useRef)(!1);(0,VM.useLayoutEffect)(()=>{if(e.isLoading){n.current=!1;return}if(e.isQueryActiveNow?.()){zM(`skip: queryActiveNow=true`);return}if(e.wasAborted){zM(`skip: wasAborted=true`);return}if(n.current)return;if(qn().length>0){zM(`skip: yielding to queued user messages`);return}if(e.hasActiveLocalJsxUI){zM(`skip: activeLocalJsxUI`);return}if(e.isInPlanMode){zM(`skip: planMode`);return}let t=xl();if(!t){r.current=!1;return}if(t.status===`active`&&(r.current=!1),t.status===`budget_limited`&&!r.current){r.current=!0,n.current=!0;let e=IM(t);Y(`[goal] hook: budget limit reached, injecting wrap-up prompt`),io({value:e,mode:`prompt`,priority:`now`,isMeta:!0,origin:`goal-budget-limit`,skipSlashCommands:!0});return}if(t.status!==`active`){zM(`skip: status="${t.status}" (not active)`);return}if(t.turnsExecuted>=150){sd()&&(kc(),e.onMaxTurnsReached?.()),Y(`[goal] hook: MAX_GOAL_TURNS (150) reached, stopping`);return}n.current=!0;let i=uc();kc();let a=FM(t);Y(`[goal] hook: enqueuing turn ${i} for "${t.objective.slice(0,60)}"`),io({value:a,mode:`prompt`,priority:`now`,isMeta:!0,origin:`goal-continuation`,skipSlashCommands:!0}),e.onContinuationEnqueued?.({turn:i,objective:t.objective})},[e.isLoading,e.wasAborted,e.queuedCommandsLength,e.hasActiveLocalJsxUI,e.isInPlanMode])}var VM,HM=t((()=>{VM=n(z(),1),of(),Zo(),LM(),jr()})),UM=r({AntModelSwitchCallout:()=>WM,shouldShowModelSwitchCallout:()=>GM});function WM(e){return null}function GM(){return!1}t((()=>{}));var KM=r({UndercoverAutoCallout:()=>qM});function qM({onDone:e}){return(0,JM.useEffect)(()=>{e()},[e]),null}var JM,YM=t((()=>{JM=n(z(),1)}));rt(),uu(),Df(),u(),B(),wa(),qg(),Ll(),of(),s(),kp(),Sd(),Nt(),Zi(),wg(),Ul(),Ft(),ga(),Pa(),mu(),ef(),ap(),qd(),Lt(),Xt(),fc(),Vf(),fm(),Cp(),Vd(),tg(),rp(),Si(),Lu(),nv(),lg(),Xl(),Td(),e_(),q(),ui(),Wc(),Yn(),Ei(),Cn(),jr(),ql(),us(),dr(),El(),Os();var XM=process.env.USER_TYPE===`ant`?(EM(),e(SM)).useFrustrationDetection:()=>({state:`closed`,handleTranscriptSelect:()=>{}}),ZM=process.env.USER_TYPE===`ant`?e(DM).useAntOrgWarningNotification:()=>{},QM=(bh(),e(lh)),$M=e=>()=>{},eN=()=>!1,tN=()=>null,nN=(e,t)=>!1,rN=(NM(),e(kM)).useProactive,iN=(HM(),e(RM)).useGoalContinuation,aN=()=>({relayPipeMessage:()=>!1,pipeReturnHadErrorRef:{current:!1}}),oN=()=>({routeToSelectedPipes:()=>!1}),sN=process.env.USER_TYPE===`ant`?e(UM).AntModelSwitchCallout:null,cN=process.env.USER_TYPE===`ant`?e(UM).shouldShowModelSwitchCallout:()=>!1,lN=process.env.USER_TYPE===`ant`?(YM(),e(KM)).UndercoverAutoCallout:null,uN=[],dN=3e3;function fN(e){let t=[...e].sort((e,t)=>e-t),n=Math.floor(t.length/2);return t.length%2==0?Math.round((t[n-1]+t[n])/2):t[n]}function pN({showAllInTranscript:e,virtualScroll:t,searchBadge:n,suppressShowAll:r=!1,status:i}){let a=lo(`app:toggleTranscript`,`Global`,`ctrl+o`),o=lo(`transcript:toggleShowAll`,`Transcript`,`ctrl+e`);return(0,$.jsxs)(b,{noSelect:!0,alignItems:`center`,alignSelf:`center`,borderTopDimColor:!0,borderBottom:!1,borderLeft:!1,borderRight:!1,borderStyle:`single`,marginTop:1,paddingLeft:2,width:`100%`,children:[(0,$.jsxs)(T,{dimColor:!0,children:[`Showing detailed transcript · `,a,` to toggle`,n?` · n/N to navigate`:t?` · ${d.arrowUp}${d.arrowDown} scroll · home/end top/bottom`:r?``:` · ${o} to ${e?`collapse`:`show all`}`]}),i?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(b,{flexGrow:1}),(0,$.jsxs)(T,{children:[i,` `]})]}):n?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(b,{flexGrow:1}),(0,$.jsxs)(T,{dimColor:!0,children:[n.current,`/`,n.count,` `]})]}):null]})}function mN({jumpRef:e,count:t,current:n,onClose:r,onCancel:i,setHighlight:a,initialQuery:o}){let{query:s,cursorOffset:c}=w_({isActive:!0,initialQuery:o,onExit:()=>r(s),onCancel:i}),[l,u]=Q.useState(`building`);Q.useEffect(()=>{let t=!0,n,r=e.current?.warmSearchIndex;if(!r){u(null);return}return u(`building`),r().then(e=>{t&&(e<20?u(null):(u({ms:e}),n=setTimeout(()=>t&&u(null),2e3)))}),()=>{t=!1,n&&clearTimeout(n)}},[e]);let d=l!==`building`;(0,Q.useEffect)(()=>{d&&(e.current?.setSearchQuery(s),a(s))},[e,s,a,d]);let f=c,p=f<s.length?s[f]:` `;return(0,$.jsxs)(b,{borderTopDimColor:!0,borderBottom:!1,borderLeft:!1,borderRight:!1,borderStyle:`single`,marginTop:1,paddingLeft:2,width:`100%`,noSelect:!0,children:[(0,$.jsx)(T,{children:`/`}),(0,$.jsx)(T,{children:s.slice(0,f)}),(0,$.jsx)(T,{inverse:!0,children:p}),f<s.length&&(0,$.jsx)(T,{children:s.slice(f+1)}),(0,$.jsx)(b,{flexGrow:1}),l===`building`?(0,$.jsx)(T,{dimColor:!0,children:`indexing… `}):l?(0,$.jsxs)(T,{dimColor:!0,children:[`indexed in `,l.ms,`ms `]}):t===0&&s?(0,$.jsx)(T,{color:`error`,children:`no matches `}):t>0?(0,$.jsxs)(T,{dimColor:!0,children:[n,`/`,t,` `]}):null]})}var hN=[`⠂`,`⠐`],gN=`✳`,_N=960;function vN({isAnimating:e,title:t,disabled:n,noPrefix:r}){let i=M(),[a,o]=(0,Q.useState)(0);(0,Q.useEffect)(()=>{if(n||r||!e||!i)return;let t=setInterval(e=>e(e=>(e+1)%hN.length),_N,o);return()=>clearInterval(t)},[n,r,e,i]);let s=e?hN[a]??gN:gN;return ee(n?null:r?t:`${s} ${t}`),null}var yN=`<${ip}>`;function bN(e){return e.type===`text`&&typeof e.text==`string`&&e.text.includes(yN)}function xN({commands:t,debug:n,initialTools:r,initialMessages:i,pendingHookMessages:o,initialFileHistorySnapshots:s,initialContentReplacements:c,initialAgentName:l,initialAgentColor:u,mcpClients:d,dynamicMcpConfig:f,autoConnectIdeFlag:p,strictMcpConfig:m=!1,systemPrompt:h,appendSystemPrompt:g,onBeforeQuery:_,onTurnComplete:v,disabled:x=!1,mainThreadAgentDefinition:S,disableSlashCommands:C=!1,taskListId:w,remoteSessionConfig:D,directConnectConfig:O,sshSession:k,thinkingConfig:A}){let j=!!D,N=(0,Q.useMemo)(()=>a(process.env.CLAUDE_CODE_DISABLE_TERMINAL_TITLE),[]),ee=(0,Q.useMemo)(()=>process.env.USER_TYPE===`ant`&&a(process.env.CLAUDE_MORERIGHT),[]),P=(0,Q.useMemo)(()=>a(process.env.CLAUDE_CODE_DISABLE_VIRTUAL_SCROLL),[]);(0,Q.useMemo)(()=>a(process.env.CLAUDE_CODE_DISABLE_MESSAGE_ACTIONS),[]),(0,Q.useEffect)(()=>(Y(`[REPL:mount] REPL mounted, disabled=${x}`),()=>Y(`[REPL:unmount] REPL unmounting`)),[x]);let[I,ne]=(0,Q.useState)(S),L=J(e=>e.toolPermissionContext),R=J(e=>e.verbose),ie=J(e=>e.mcp),z=J(e=>e.plugins),ae=J(e=>e.agentDefinitions),se=J(e=>e.fileHistory),ce=J(e=>e.initialMessage),le=mC(),ue=J(e=>e.spinnerTip),pe=J(e=>e.expandedView)===`tasks`,B=J(e=>e.tasks),H=J(e=>e.elicitation),me=J(e=>e.ultraplanPendingChoice),he=J(e=>e.ultraplanLaunchPending),ge=J(e=>e.viewingAgentTaskId),U=Qs(),ve=ge?B[ge]:void 0,ye=Gc(ve)&&ve.retain&&!ve.diskLoaded;(0,Q.useEffect)(()=>{if(!ge||!ye)return;let e=ge;nd(hu(e)).then(t=>{U(n=>{let r=n.tasks[e];if(!Gc(r)||r.diskLoaded||!r.retain)return n;let i=r.messages??[],a=new Set(i.map(e=>e.uuid)),o=t?t.messages.filter(e=>!a.has(e.uuid)):[];return{...n,tasks:{...n.tasks,[e]:{...r,messages:[...o,...i],diskLoaded:!0}}}})})},[ge,ye,U]);let be=js(),xe=E(),Se=$g(),[Ce,we]=(0,Q.useState)(t);dk(j?void 0:lt(),we);let Te=Q.useSyncExternalStore(QM?.subscribeToProactiveChanges??$M,QM?.isProactiveActive??eN),Ee=Q.useSyncExternalStore(QM?.subscribeToProactiveChanges??$M,QM?.getNextTickAt??tN),De=J(e=>e.isBriefOnly),Oe=(0,Q.useMemo)(()=>Po(L),[L,Te,De]);pA();let[ke,Me]=(0,Q.useState)(f),Ne=(0,Q.useCallback)(e=>{Me(e)},[Me]),[Pe,Ie]=(0,Q.useState)(`prompt`),[Re,ze]=(0,Q.useState)(!1),[Be,He]=(0,Q.useState)(!1),[Ue,We]=(0,Q.useState)(``),Ke=(0,Q.useRef)(0),Ye=(0,Q.useRef)(void 0),Xe=(0,Q.useRef)(!1),{addNotification:Ze,removeNotification:Qe}=Au(),rt=nN,dt=lk(d,ie.clients),[ft,ht]=(0,Q.useState)(void 0),[_t,vt]=(0,Q.useState)(null),[bt,xt]=(0,Q.useState)(null),[Ct,wt]=(0,Q.useState)(!1),[Tt,Et]=(0,Q.useState)(()=>process.env.USER_TYPE===`ant`&&cN()),[Ot,jt]=(0,Q.useState)(()=>Ok(Se)),Mt=J(e=>e.showRemoteCallout),[Nt,Pt]=(0,Q.useState)(()=>Sv());lj(),fj(),sj({ideSelection:ft,mcpClients:dt,ideInstallationStatus:bt}),yA({mcpClients:dt}),YA(),XA(),O_(),nj(Se),vj(),rj(Se),aj(),ZM(),$k(),oA(),SA();let{recommendation:Ft,handleResponse:Lt}=RA(),{recommendation:Rt,handleResponse:zt}=VA(),Bt=JA(),Vt=(0,Q.useMemo)(()=>[...Oe,...r],[Oe,r]);dg({enabled:!j});let Ht=vc();(0,Q.useEffect)(()=>{j||$A(U)},[U,j]);let Wt=Gg(Vt,ie.tools,L),{tools:Kt,allowedAgentTypes:qt}=(0,Q.useMemo)(()=>{if(!I)return{tools:Wt,allowedAgentTypes:void 0};let e=kt(I,Wt,!1,!0);return{tools:e.resolvedTools,allowedAgentTypes:e.allowedAgentTypes}},[I,Wt]),Jt=uk(uk(Ce,z.commands),ie.commands),Yt=(0,Q.useMemo)(()=>C?[]:Jt,[C,Jt]);Hy(j?uN:ie.clients),pk(j?uN:ie.clients,ht);let[Xt,Zt]=(0,Q.useState)(`responding`),Qt=(0,Q.useRef)(Xt);Qt.current=Xt;let[$t,nn]=(0,Q.useState)([]),[an,on]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{if(an&&!an.isStreaming&&an.streamingEndedAt){let e=3e4-(Date.now()-an.streamingEndedAt);if(e>0){let t=setTimeout(on,e,null);return()=>clearTimeout(t)}else on(null)}},[an]);let[cn,ln]=(0,Q.useState)(null),un=(0,Q.useRef)(null);un.current=cn;let dn=(0,Q.useRef)(0),[fn,mn]=(0,Q.useState)(!1),hn=(0,Q.useRef)(()=>{}),gn=(0,Q.useRef)(()=>{}),vn=(0,Q.useRef)(null),yn=(0,Q.useRef)(null),xn=(0,Q.useRef)(0),Sn=Q.useRef(new Sy).current,Cn=Q.useSyncExternalStore(Sn.subscribe,Sn.getSnapshot),[wn,Tn]=Q.useState(D?.hasInitialPrompt??!1),W=Cn||wn,[Dn,On]=Q.useState(void 0),kn=Q.useRef(0),An=Q.useRef(!1),jn=Q.useRef(0),Mn=Q.useRef(0),Nn=Q.useRef(null),Pn=Q.useCallback(()=>{jn.current=Date.now(),Mn.current=0,Nn.current=null},[]),Fn=Q.useRef(!1);Cn&&!Fn.current&&Pn(),Fn.current=Cn;let In=Q.useCallback(e=>{Tn(e),e&&Pn()},[Pn]),Ln=Q.useRef(void 0),[zn,Bn]=Q.useState(!1),[Vn,Hn]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{Vn?.notifications&&Vn.notifications.forEach(e=>{Ze({key:`auto-updater-notification`,text:e,priority:`low`})})},[Vn,Ze]),(0,Q.useEffect)(()=>{pl()&&Rs().then(e=>{e&&Ze({key:`tmux-mouse-hint`,text:e,priority:`low`})})},[]);let[Un,Wn]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{process.env.USER_TYPE===`ant`&&(async()=>{let{isInternalModelRepo:e}=await import(`./commitAttribution-D7NrwLhc.js`);await e();let{shouldShowUndercoverAutoNotice:t}=await import(`./undercover-6UUO38fQ.js`);t()&&Wn(!0)})()},[]);let[Gn,Kn]=(0,Q.useState)(null),qn=(0,Q.useRef)(null),Jn=(0,Q.useCallback)(e=>{if(e?.isLocalJSXCommand){let{clearLocalJSX:t,...n}=e;qn.current={...n,isLocalJSXCommand:!0},Kn(n);return}if(qn.current){if(e?.clearLocalJSX){qn.current=null,Kn(null),dn.current=Date.now();return}return}if(e?.clearLocalJSX){Kn(null);return}Kn(e)},[]),[Yn,Xn]=(0,Q.useState)([]),[Zn,Qn]=(0,Q.useState)(null),[$n,er]=(0,Q.useState)([]),[tr,nr]=(0,Q.useState)([]),rr=(0,Q.useRef)(new Map),ar=J(e=>e.settings.terminalTitleFromRename)===!1?void 0:Sl(at()),[or,sr]=(0,Q.useState)(),cr=(0,Q.useRef)((i?.length??0)>0),ur=I?.agentType,dr=ar??ur??or??`Work Mate`,fr=Yn.length>0||tr.length>0,pr=Gn?.isLocalJSXCommand===!0&&Gn?.jsx!=null,mr=W&&!fr&&!pr;(0,Q.useEffect)(()=>{if(W&&!fr&&!pr)return hy(),()=>gy()},[W,fr,pr]);let hr=fr||pr?`waiting`:W?`busy`:`idle`,_r=hr===`waiting`?Yn.length>0?`approve ${Yn[0].tool.name}`:pr?`dialog open`:`input needed`:void 0;(0,Q.useEffect)(()=>{Rd({status:hr,waitingFor:_r})},[hr,_r]),F(null);let[G,yr]=(0,Q.useState)(i??[]),br=(0,Q.useRef)(G),xr=(0,Q.useRef)(!1),K=(0,Q.useCallback)(e=>{let t=br.current,n=typeof e==`function`?e(br.current):e;if(br.current=n,n.length<kn.current)kn.current=0;else if(n.length>t.length&&An.current){let e=n.length-t.length;(t.length===0||n[0]===t[0]?n.slice(-e):n.slice(0,e)).some(ii)?An.current=!1:kn.current=n.length}yr(n)},[]),Sr=(0,Q.useCallback)(e=>{e===void 0?An.current=!1:(kn.current=br.current.length,An.current=!0),On(e)},[]),{dividerIndex:Cr,dividerYRef:wr,onScrollAway:Tr,onRepin:Or,jumpToNew:kr,shiftDivider:Ar}=rv(G.length);eA(G,K,W);let[jr,Nr]=(0,Q.useState)(null),Pr=(0,Q.useRef)(null),Ir=(0,Q.useMemo)(()=>ev(G,Cr),[Cr,G.length]),Lr=(0,Q.useCallback)(()=>{vn.current?.scrollToBottom(),Or(),Nr(null)},[Or,Nr]),Rr=G.at(-1),zr=Rr!=null&&ii(Rr);(0,Q.useEffect)(()=>{zr&&Lr()},[zr,Rr,Lr]);let{maybeLoadOlder:Br}=yO({config:D,setMessages:K,scrollRef:vn,onPrepend:Ar}),Wr=(0,Q.useCallback)((e,t)=>{xn.current=Date.now(),e?Or():(Tr(t),Br(t))},[Or,Tr,Br,U]),Gr=FO(o,K),Kr=(0,Q.useDeferredValue)(Q.useMemo(()=>G.length>500?G.slice(-500):G,[G])),qr=G.length-Kr.length;qr>0&&Y(`[useDeferredValue] Messages deferred by ${qr} (${Kr.length}→${G.length})`);let[Jr,Xr]=(0,Q.useState)(null),[Zr,Qr]=(0,Q.useState)(()=>hv()),$r=(0,Q.useRef)(Zr);$r.current=Zr;let ei=(0,Q.useRef)(null),ni=(0,Q.useCallback)(e=>{rt($r.current,e)||($r.current===``&&e!==``&&Date.now()-xn.current>=dN&&Lr(),$r.current=e,Qr(e),Bn(e.trim().length>0))},[Bn,Lr,rt]);(0,Q.useEffect)(()=>{if(Zr.trim().length===0)return;let e=setTimeout(Bn,1500,!1);return()=>clearTimeout(e)},[Zr]);let[ri,ai]=(0,Q.useState)(`prompt`),[oi,si]=(0,Q.useState)(),ci=(0,Q.useCallback)(e=>{let t=new Set(e);we(e=>e.filter(e=>t.has(e.name)||da.has(e)))},[we]),[ui,pi]=(0,Q.useState)(new Set),mi=(0,Q.useRef)(!1),hi=iO({config:D,setMessages:K,setIsLoading:In,onInit:ci,setToolUseConfirmQueue:Xn,tools:Vt,setStreamingToolUses:nn,setStreamMode:Zt,setInProgressToolUseIDs:pi}),gi=sO({config:O,setMessages:K,setIsLoading:In,setToolUseConfirmQueue:Xn,tools:Vt}),_i=cO({session:k,setMessages:K,setIsLoading:In,setToolUseConfirmQueue:Xn,tools:Vt}),vi=_i.isRemoteMode?_i:gi.isRemoteMode?gi:hi,[yi,Si]=(0,Q.useState)({}),[Ci,wi]=(0,Q.useState)(0),Ei=(0,Q.useRef)(0),Oi=(0,Q.useRef)([]),Ai=(0,Q.useCallback)(e=>{let t=Ei.current;if(Ei.current=e(t),Ei.current>t){let e=Oi.current;if(e.length>0){let t=e.at(-1);t.lastTokenTime=Date.now(),t.endResponseLength=Ei.current}}},[]),[ji,Mi]=(0,Q.useState)(null),Ni=!(J(e=>e.settings.prefersReducedMotion)??!1)&&!V(),Pi=(0,Q.useCallback)(e=>{Ni&&Mi(e)},[Ni]),Fi=ji&&Ni&&ji.substring(0,ji.lastIndexOf(`
|
|
138
|
+
`)+1)||null,[Ii,Li]=(0,Q.useState)(0),[Ri,Bi]=(0,Q.useState)(null),[Vi,Hi]=(0,Q.useState)(null),[Wi,Gi]=(0,Q.useState)(null),[Ki,qi]=(0,Q.useState)(!1),[Ji,Yi]=(0,Q.useState)(void 0),[Xi,Zi]=(0,Q.useState)(!1),[Qi,$i]=(0,Q.useState)(Bv()),[ta,na]=(0,Q.useState)(null),ia=(0,Q.useRef)(!1),oa=(0,Q.useRef)(Ii);oa.current=Ii;let[sa]=(0,Q.useState)(()=>({current:Eo(i,c)}));cc(()=>{sa.current=cu()});let[ca,la]=(0,Q.useState)(Bf().hasAcknowledgedCostThreshold),[fa,pa]=(0,Q.useState)(`INSERT`),[ma,ha]=(0,Q.useState)(!1),[ga,_a]=(0,Q.useState)(!1),[va,ba]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{me&&ma&&ha(!1)},[me,ma]);let Sa=M(),Ca=(0,Q.useRef)(Sa);Ca.current=Sa;let[wa]=y(),Ta=Q.useRef(!1),Ea=(0,Q.useCallback)(()=>{if(Ta.current)return;Ta.current=!0;let e=br.current.slice(Xa.current);for(let t of ml(e))Ya.current.add(t);Xa.current=br.current.length,cA({theme:wa,readFileState:Ja.current,bashTools:Ya.current}).then(async e=>{if(e){let t=await e.content({theme:wa});U(e=>({...e,spinnerTip:t})),lA(e)}else U(e=>e.spinnerTip===void 0?e:{...e,spinnerTip:void 0})})},[U,wa]),Da=(0,Q.useCallback)(()=>{In(!1),Sr(void 0),Ei.current=0,Oi.current=[],Mi(null),nn([]),Bi(null),Hi(null),Gi(null),Ea(),Ch(),tu()},[Ea]),Oa=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{{if(L.mode!==`auto`){Oa.current=!1;return}if(Oa.current||(Bf().autoPermissionsNotificationCount??0)>=3)return;let e=setTimeout((e,t)=>{e.current=!0,zf(e=>{let t=e.autoPermissionsNotificationCount??0;return t>=3?e:{...e,autoPermissionsNotificationCount:t+1}}),t(e=>[...e,Ed(bA,`warning`)])},800,Oa,K);return()=>clearTimeout(e)}},[L.mode,K]);let ka=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{if(ka.current)return;let e=rn();if(!e?.creationDurationMs||e.usedSparsePaths||e.creationDurationMs<15e3)return;ka.current=!0;let t=Math.round(e.creationDurationMs/1e3);K(e=>[...e,Ed(`Worktree creation took ${t}s. For large repos, set \`worktree.sparsePaths\` in .claude/settings.json to check out only the directories you need — e.g. \`{"worktree": {"sparsePaths": ["src", "packages/foo"]}}\`.`,`info`)])},[K]);let Ma=(0,Q.useMemo)(()=>{let e=G.findLast(e=>e.type===`assistant`);if(e?.type!==`assistant`)return!1;let t=e.message?.content,n=(Array.isArray(t)?t:[]).filter(e=>e.type===`tool_use`&&ui.has(e.id));return n.length>0&&n.every(e=>e.type===`tool_use`&&e.name===`Sleep`)},[G,ui]),{onBeforeQuery:Na,onTurnComplete:Pa,render:Fa}=MO({enabled:ee,setMessages:K,inputValue:Zr,setInputValue:ni,setToolJSX:Jn}),Ia=(!Gn||Gn.showSpinner===!0)&&Yn.length===0&&tr.length===0&&(W||Dn||yo()>0)&&!Ma&&(!Fi||De),La=Yn.length>0||tr.length>0||$n.length>0||H.queue.length>0,Ra=Ik(G,W,Ci,`session`,La),za=jO(K),Ba=Mj(G,Ci),Va=(0,Q.useMemo)(()=>({...Ra,handleSelect:e=>{so.current=!1;let t=Ra.handleSelect(e);e===`bad`&&!t&&xj(`feedback_survey_bad`)&&(ao(`feedback_survey_bad`),so.current=!0)}}),[Ra]),Ua=Wk(G,W,La,{enabled:!j}),Wa=Bk(G,W,La,{enabled:!j}),Ga=XM(G,W,La,Va.state!==`closed`||Ua.state!==`closed`||Wa.state!==`closed`);xk({autoConnectIdeFlag:p,ideToInstallExtension:_t,setDynamicMcpConfig:Me,setShowIdeOnboarding:wt,setIDEInstallationState:xt}),mA(s,se,e=>U(t=>({...t,fileHistory:e})));let Ka=(0,Q.useCallback)(async(t,n,r)=>{let i=performance.now();try{let a=zu(n.messages),o=Is();await Wo(`resume`,{getAppState:()=>be.getState(),setAppState:U,signal:AbortSignal.timeout(o),timeoutMs:o});let s=await nu(`resume`,{sessionId:t,agentType:I?.agentType,model:Se});a.push(...s),r===`fork`?En(n,Ec(t)):pn(n,Ec(t)),Ng(n,U),n.fileHistorySnapshots&&ti(n);let{agentDefinition:c}=jg(n.agentSetting,S,ae);ne(c),U(e=>({...e,agent:c?.agentType})),U(e=>({...e,standaloneAgentContext:Mg(n.agentName,n.agentColor)})),eo(n.agentName),$a(a,n.projectPath??ct()),Da(),ln(null),$i(t);let l=ls(t);Ts(),pt(),mt(Ec(t),n.fullPath?jv(n.fullPath):null);let{renameRecordingForSession:u}=await import(`./asciicast-BIr75_x9.js`);if(await u(),await tc(),jl(),Ql(n),n.goal){let{hydrateGoalFromTranscript:r}=(yu(),e(Ol)),i=new Map;i.set(t,n.goal),r(i,t)}if(cr.current=!0,sr(void 0),r!==`fork`)Pg(),Fg(n.worktreeSession),Dr(),vo({abortController:new AbortController,getAppState:()=>be.getState(),setAppState:U});else{let e=rn();e&&en(e)}l&&tt(l),sa.current&&r!==`fork`&&(sa.current=Bo(a,n.contentReplacements??[])),K(()=>a),Jn(null),ni(``),Z(`tengu_session_resumed`,{entrypoint:r,success:!0,resume_duration_ms:Math.round(performance.now()-i)})}catch(e){throw Z(`tengu_session_resumed`,{entrypoint:r,success:!1}),e}},[Da,U]),[qa]=(0,Q.useState)(()=>oh(100)),Ja=(0,Q.useRef)(qa),Ya=(0,Q.useRef)(new Set),Xa=(0,Q.useRef)(0),Za=(0,Q.useRef)(new Set),Qa=(0,Q.useRef)(new Set),$a=(0,Q.useCallback)((e,t)=>{let n=hc(e,t,100);Ja.current=ch(Ja.current,n);for(let t of ml(e))Ya.current.add(t)},[]);(0,Q.useEffect)(()=>{i&&i.length>0&&($a(i,ct()),vo({abortController:new AbortController,getAppState:()=>be.getState(),setAppState:U}))},[]);let{status:to,reverify:no}=IO(),[ro,ao]=(0,Q.useState)(null),so=(0,Q.useRef)(!1),[co,lo]=(0,Q.useState)(null),[uo,fo]=(0,Q.useState)(!1),po=!W&Ξfunction mo(){if(uo||co)return;if(Ki)return`message-selector`;if(zn)return;if($n[0])return`sandbox-permission`;let e=!Gn||Gn.shouldContinueAnimation;if(e&&Yn[0])return`tool-permission`;if(e&&tr[0])return`prompt`;if(e&&H.queue[0])return`elicitation`;if(e&&po)return`cost`;if(e&&ta)return`idle-return`;if(e&&!W&&me)return`ultraplan-choice`;if(e&&!W&&he)return`ultraplan-launch`;if(e&&Ct)return`ide-onboarding`;if(process.env.USER_TYPE===`ant`&&e&&Tt)return`model-switch`;if(process.env.USER_TYPE===`ant`&&e&&Un)return`undercover-callout`;if(e&&Ot)return`effort-callout`;if(e&&Mt)return`remote-callout`;if(e&&Ft)return`lsp-recommendation`;if(e&&Rt)return`plugin-hint`;if(e&&Bt.visible)return`search-extra-tools-hint`;if(e&&Nt)return`desktop-upsell`}let ho=mo(),go=zn&&($n[0]||Yn[0]||tr[0]||H.queue[0]||po);Ln.current=ho,(0,Q.useEffect)(()=>{if(!W)return;let e=ho===`tool-permission`,t=Date.now();e&&Nn.current===null?Nn.current=t:!e&&Nn.current!==null&&(Mn.current+=t-Nn.current,Nn.current=null)},[ho,W]);let bo=(0,Q.useRef)(ho);(0,Q.useLayoutEffect)(()=>{bo.current===`tool-permission`!=(ho===`tool-permission`)&&Lr(),bo.current=ho},[ho,Lr]);function So(){if(ho!==`elicitation`){if(dn.current!==0&&Date.now()-dn.current<500){dn.current=0,Y(`[onCancel] suppressed: local-jsx panel just dismissed`);return}if(dn.current=0,Y(`[onCancel] focusedInputDialog=${ho} streamMode=${Xt}`),QM?.pauseProactive(),Sn.getSnapshot()){let{getGoal:t,pauseGoal:n}=(Zo(),e(Cc)),{persistCurrentGoal:r}=(yu(),e(Ol));t()?.status===`active`&&(n(),r())}if(mn(!0),Sn.forceEnd(),ia.current=!1,ji?.trim()&&K(e=>[...e,eu({content:ji})]),Da(),$e(null),ho===`tool-permission`)Yn[0]?.onAbort(),Xn([]);else if(ho===`prompt`){for(let e of tr)e.reject(Error(`Prompt cancelled by user`));nr([]),cn?.abort(`user-cancel`)}else vi.isRemoteMode?vi.cancelRequest():cn?.abort(`user-cancel`);ln(null),Pa(br.current,!0)}}let Co=(0,Q.useCallback)(()=>{let e=ra(Zr,0);e&&(ni(e.text),ai(`prompt`),e.images.length>0&&Si(t=>{let n={...t};for(let t of e.images)n[t.id]=t;return n}))},[ni,ai,Zr,Si]),wo={setToolUseConfirmQueue:Xn,onCancel:So,onAgentsKilled:()=>K(e=>[...e,td()]),isMessageSelectorVisible:Ki||!!ma,screen:Pe,abortSignal:cn?.signal,popCommandFromQueue:Co,vimMode:fa,isLocalJSXCommand:Gn?.isLocalJSXCommand,isSearchingHistory:ga,isHelpOpen:va,inputMode:ri,inputValue:Zr,streamMode:Xt};(0,Q.useEffect)(()=>{st()>=5&&!Xi&&!ca&&(Z(`tengu_cost_threshold_reached`,{}),la(!0),jm()&&Zi(!0))},[G,Xi,ca]);let To=(0,Q.useCallback)(async e=>new Promise(t=>{let n=!1;function r(e){n||(n=!0,t(e))}er(t=>[...t,{hostPattern:e,resolvePromise:r}]);{let t=be.getState().replBridgePermissionCallbacks;if(t){let n=Bv();t.sendRequest(n,mg,{host:e.host},Bv(),`Allow network connection to ${e.host}?`);let r=t.onResponse(n,t=>{r();let n=t.behavior===`allow`;er(t=>(t.filter(t=>t.hostPattern.host===e.host).forEach(e=>e.resolvePromise(n)),t.filter(t=>t.hostPattern.host!==e.host)));let i=rr.current.get(e.host);if(i){for(let e of i)e();rr.current.delete(e.host)}}),i=()=>{r(),t.cancelRequest(n)},a=rr.current.get(e.host)??[];a.push(i),rr.current.set(e.host,a)}}}),[U,be]);(0,Q.useEffect)(()=>{let e=fi.getSandboxUnavailableReason();if(e){if(fi.isSandboxRequired()){process.stderr.write(`\nError: sandbox required but unavailable: ${e}\n sandbox.failIfUnavailable is set — refusing to start without a working sandbox.\n\n`),sn(1,`other`);return}Y(`sandbox disabled: ${e}`,{level:`warn`}),Ze({key:`sandbox-unavailable`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(T,{color:`warning`,children:`sandbox disabled`}),(0,$.jsx)(T,{dimColor:!0,children:` · /sandbox`})]}),priority:`medium`})}},[Ze]),fi.isSandboxingEnabled()&&fi.initialize(To).catch(e=>{process.stderr.write(`\n❌ Sandbox Error: ${df(e)}\n`),sn(1,`other`)});let Do=(0,Q.useCallback)((e,t)=>{U(n=>({...n,toolPermissionContext:{...e,mode:t?.preserveMode?n.toolPermissionContext.mode:e.mode}})),setImmediate(e=>{e(e=>(e.forEach(e=>{e.recheckPermission()}),e))},Xn)},[U,Xn]),Oo=ek(Xn,Do),ko=(0,Q.useCallback)((e,t,r,i)=>{let a=be.getState(),o=()=>{let e=be.getState(),t=Vr(e.toolPermissionContext,e.mcp.tools),n=vg(Vt,t,e.toolPermissionContext.mode);return I?kt(I,n,!1,!0).resolvedTools:n};return{abortController:r,options:{commands:Yt,tools:o(),debug:n,verbose:a.verbose,mainLoopModel:i,thinkingConfig:a.thinkingEnabled===!1?{type:`disabled`}:A,mcpClients:ck(d,a.mcp.clients),mcpResources:a.mcp.resources,ideInstallationStatus:bt,isNonInteractiveSession:!1,dynamicMcpConfig:ke,theme:wa,agentDefinitions:qt?{...a.agentDefinitions,allowedAgentTypes:qt}:a.agentDefinitions,customSystemPrompt:h,appendSystemPrompt:g,refreshTools:o},getAppState:()=>be.getState(),setAppState:U,messages:e,setMessages:K,updateFileHistoryState(e){U(t=>{let n=e(t.fileHistory);return n===t.fileHistory?t:{...t,fileHistory:n}})},updateAttributionState(e){U(t=>{let n=e(t.attribution);return n===t.attribution?t:{...t,attribution:n}})},openMessageSelector:()=>{x||qi(!0)},onChangeAPIKey:no,readFileState:Ja.current,setToolJSX:Jn,addNotification:Ze,appendSystemMessage:e=>K(t=>[...t,e]),sendOSNotification:e=>{ry(e,xe)},onChangeDynamicMcpConfig:Ne,onInstallIDEExtension:vt,nestedMemoryAttachmentTriggers:new Set,loadedNestedMemoryPaths:Qa.current,dynamicSkillDirTriggers:new Set,discoveredSkillNames:Za.current,setResponseLength:Ai,pushApiMetricsEntry:process.env.USER_TYPE===`ant`?e=>{let t=Date.now(),n=Ei.current;Oi.current.push({ttftMs:e,firstTokenTime:t,lastTokenTime:t,responseLengthBaseline:n,endResponseLength:n})}:void 0,setStreamMode:Zt,onCompactProgress:e=>{switch(e.type){case`hooks_start`:Hi(`claudeBlue_FOR_SYSTEM_SPINNER`),Gi(`claudeBlueShimmer_FOR_SYSTEM_SPINNER`),Bi(e.hookType===`pre_compact`?`Running PreCompact hooks…`:e.hookType===`post_compact`?`Running PostCompact hooks…`:`Running SessionStart hooks…`);break;case`compact_start`:Bi(`Compacting conversation`);break;case`compact_end`:Bi(null),Hi(null),Gi(null);break}},setInProgressToolUseIDs:pi,setHasInterruptibleToolInProgress:e=>{mi.current=e},resume:Ka,setConversationId:$i,requestPrompt:void 0,contentReplacementState:sa.current}},[Yt,Vt,I,n,d,bt,ke,wa,qt,be,U,no,Ze,K,Ne,Ka,(0,Q.useCallback)((e,t)=>n=>new Promise((r,i)=>{nr(a=>[...a,{request:n,title:e,toolInputSummary:t,resolve:r,reject:i}])}),[]),x,h,g,$i]),{handleBackgroundSession:Ao}=Ck({setMessages:K,setIsLoading:In,resetLoadingState:Da,setAbortController:ln,onBackgroundQuery:(0,Q.useCallback)(()=>{cn?.abort(`background`);let e=Dt(e=>e.mode===`task-notification`);(async()=>{let t=ko(br.current,[],new AbortController,Se),[n,r,i]=await Promise.all([dl(t.options.tools,Se,Array.from(L.additionalWorkingDirectories.keys()),t.options.mcpClients),Fr(),Rn()]),a=_o({mainThreadAgentDefinition:I,toolUseContext:t,customSystemPrompt:h,defaultSystemPrompt:n,appendSystemPrompt:g});t.renderedSystemPrompt=a;let o=(await Ti(e).catch(()=>[])).map(_n),s=new Set;for(let e of br.current)e.type===`attachment`&&e.attachment.type===`queued_command`&&e.attachment.commandMode===`task-notification`&&typeof e.attachment.prompt==`string`&&s.add(e.attachment.prompt);let c=o.filter(e=>e.attachment.type===`queued_command`&&(typeof e.attachment.prompt!=`string`||!s.has(e.attachment.prompt)));ki({messages:[...br.current,...c],queryParams:{systemPrompt:a,userContext:r,systemContext:i,canUseTool:Oo,toolUseContext:t,querySource:Bu()},description:dr,setAppState:U,agentDefinition:I})})()},[cn,Se,L,I,ko,h,g,Oo,U])}),jo=(0,Q.useCallback)(t=>{gr(t,t=>{if(Gt(t)?(pl()?K(e=>{let n=At(e,{includeSnipped:!0});return[...n.length>500?n.slice(-500):n,t]}):K(()=>[t]),$i(Bv()),QM?.setContextBlocked(!1)):t.type===`progress`&&Ui(t.data?.type)?K(e=>{let n=t.data;for(let r=e.length-1;r>=0;r--){let i=e[r];if(i.type!==`progress`)break;let a=i.data;if(i.parentToolUseID===t.parentToolUseID&&a?.type===n.type){let n=e.slice();return n[r]=t,n}}return[...e,t]}):K(e=>[...e,t]),t.type===`assistant`&&`isApiErrorMessage`in t&&t.isApiErrorMessage?QM?.setContextBlocked(!0):t.type===`assistant`&&QM?.setContextBlocked(!1),t.type===`assistant`&&`isApiErrorMessage`in t&&t.isApiErrorMessage){let n=(Di(t.message?.content??``)??``).toLowerCase();if(n.includes(`connection error`)||n.includes(`fetch failed`)||n.includes(`network error`)||n.includes(`enotfound`)||n.includes(`econnreset`)||n.includes(`etimedout`)){let{getGoal:t,pauseGoal:n}=(Zo(),e(Cc)),{persistCurrentGoal:r}=(yu(),e(Ol));t()?.status===`active`&&(n(),r(),Ze({key:`goal-auto-paused-connectivity-error`,text:`Detected connection error. Active goal was auto-paused. Run /goal resume after network recovers.`,priority:`immediate`}))}}},e=>{Ai(t=>t+e.length)},Zt,nn,e=>{K(t=>t.filter(t=>t!==e)),cl(e.uuid)},on,e=>{let t=Date.now(),n=Ei.current;Oi.current.push({...e,firstTokenTime:t,lastTokenTime:t,responseLengthBaseline:n,endResponseLength:n})},Pi)},[K,Ai,Zt,nn,on,Pi]),Mo=(0,Q.useCallback)(async(e,t,n,r,i,a,o)=>{if(r){let e=ck(d,be.getState().mcp.clients);Ut.handleQueryStart(e);let t=ya(e);t&&wd(t)}if(Vh(),!N&&!ar&&!ur&&!cr.current){let e=t.find(e=>e.type===`user`&&!e.isMeta),n=e?.type===`user`?Di(e.message.content):null;n&&!n.startsWith(`<local-command-stdout>`)&&!n.startsWith(`<command-message>`)&&!n.startsWith(`<command-name>`)&&!n.startsWith(`<bash-input>`)&&(cr.current=!0,eg(n,new AbortController().signal).then(e=>{e?sr(e):cr.current=!1},()=>{cr.current=!1}))}if(be.setState(e=>{let t=e.toolPermissionContext.alwaysAllowRules.command;return t===i||t?.length===i.length&&t.every((e,t)=>e===i[t])?e:{...e,toolPermissionContext:{...e.toolPermissionContext,alwaysAllowRules:{...e.toolPermissionContext.alwaysAllowRules,command:i}}}}),!r){t.some(Gt)&&($i(Bv()),QM?.setContextBlocked(!1)),Da(),ln(null);return}let s=ko(e,t,n,a),{tools:c,mcpClients:l}=s.options;if(o!==void 0){let e=s.getAppState;s.getAppState=()=>({...e(),effortValue:o})}fl(`query_context_loading_start`);let[,,u,f,p]=await Promise.all([void 0,dA(L,U,be.getState().fastMode),dl(c,a,Array.from(L.additionalWorkingDirectories.keys()),l),Fr(),Rn()]),m={...f,...QM?.isProactiveActive()&&!Ca.current?{terminalFocus:`The terminal is unfocused — the user is not actively watching.`}:{}};fl(`query_context_loading_end`);let _=_o({mainThreadAgentDefinition:I,toolUseContext:s,customSystemPrompt:h,defaultSystemPrompt:u,appendSystemPrompt:g});s.renderedSystemPrompt=_,fl(`query_query_start`),it(),ut(),nt();for await(let t of zi({messages:e,systemPrompt:_,userContext:m,systemContext:p,canUseTool:Oo,toolUseContext:s,querySource:Bu()}))jo(t);if(fl(`query_end`),process.env.USER_TYPE===`ant`&&Oi.current.length>0){let e=Oi.current,t=e.map(e=>e.ttftMs),n=e.map(e=>{let t=Math.round((e.endResponseLength-e.responseLengthBaseline)/4),n=e.lastTokenTime-e.firstTokenTime;return n>0?Math.round(t/(n/1e3)):0}),r=e.length>1,i=qe(),a=Ae(),o=Je(),s=Ge(),c=yt(),l=Ve(),u=Date.now()-jn.current;K(e=>[...e,Ls({ttftMs:r?fN(t):t[0],otps:r?fN(n):n[0],isP50:r,hookDurationMs:i>0?i:void 0,hookCount:a>0?a:void 0,turnDurationMs:u>0?u:void 0,toolDurationMs:o>0?o:void 0,toolCount:s>0?s:void 0,classifierDurationMs:c>0?c:void 0,classifierCount:l>0?l:void 0,configWriteCount:Hf()})])}Da(),Ds(),await v?.(br.current)},[d,Da,ko,L,U,h,v,g,Oo,I,jo,ar,N]),No=(0,Q.useCallback)(async(e,t,n,r,i,a,o,s)=>{let c=Sn.tryStart();if(c===null)return Z(`tengu_concurrent_onquery_detected`,{}),e.filter(e=>e.type===`user`&&!e.isMeta).map(e=>Di(e.message.content)).filter(e=>e!==null).forEach((e,t)=>{io({value:e,mode:`prompt`}),t===0&&Z(`tengu_concurrent_onquery_enqueued`,{})}),!1;try{as.current=!1,mn(!1),Pn(),K(t=>[...t,...e]),Ei.current=0,$e((o?Er(o):null)??je()),Oi.current=[],nn([]),Mi(null);let c=br.current;if(o&&await Na(o,c,e.length),a&&o&&!await a(o,c))return!0;try{await Mo(c,e,t,n,r,i,s)}catch(e){throw e}}finally{if(Sn.end(c)){mn(t.signal.aborted),Li(Date.now()),ia.current=!1,Da(),await Pa(br.current,t.signal.aborted),hn.current(),process.env.USER_TYPE===`ant`&&!t.signal.aborted&&U(e=>e.tungstenActiveSession===void 0||e.tungstenPanelAutoHidden===!0?e:{...e,tungstenPanelAutoHidden:!0});let e;je()!==null&&je()>0&&!t.signal.aborted&&(e={tokens:Fe(),limit:je(),nudges:et()}),$e(null);let n=Date.now()-jn.current-Mn.current;(n>3e4||e!==void 0)&&!t.signal.aborted&&!Te&&K(t=>[...t,gs(n,e,Pf(t,vr))]),ln(null)}if(t.signal.reason===`user-cancel`&&!Sn.isActive&&$r.current===``&&yo()===0&&!be.getState().viewingAgentTaskId){let e=br.current,t=e.findLast(bg);t&&Sg(e,e.lastIndexOf(t))&&(bi(),gn.current(t))}}return!0},[Mo,U,Da,Sn,Na,Pa]),Fo=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{let e=ce;if(!e||W||Fo.current)return;Fo.current=!0;async function t(e){if(e.clearContext){let t=e.message.planContent?It():void 0,{clearConversation:n}=await import(`./conversation-DLLIOKYV.js`);await n({setMessages:K,readFileState:Ja.current,discoveredSkillNames:Za.current,loadedNestedMemoryPaths:Qa.current,getAppState:()=>be.getState(),setAppState:U,setConversationId:$i}),cr.current=!1,sr(void 0),Ya.current.clear(),Xa.current=0,t&&xi(at(),t)}U(t=>{let n=e.mode?Ur(t.toolPermissionContext,$x(e.mode,e.allowedPrompts)):t.toolPermissionContext;return e.mode===`auto`&&(n=di({...n,mode:`auto`,prePlanMode:void 0})),{...t,initialMessage:null,toolPermissionContext:n}}),Kd()&&lr(e=>{U(t=>({...t,fileHistory:e(t.fileHistory)}))},e.message.uuid),await Gr();let t=e.message.message.content;if(typeof t==`string`&&!e.message.planContent)Io(t,{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}});else{let t=Lc();ln(t),No([e.message],t,!0,[],Se)}setTimeout(e=>{e.current=!1},100,Fo)}t(e)},[ce,W,K,U,No,Se,Kt]);let Io=(0,Q.useCallback)(async(e,t,n,r)=>{if(Lr(),QM?.resumeProactive(),os(e)){let n=xa({content:e});K(e=>[...e,n]),r?.fromKeybinding||gd({display:Gd(e,ri),pastedContents:yi}),ni(``),t.setCursorOffset(0),t.clearBuffer(),Si({}),ai(`prompt`),ht(void 0);return}if(!n&&e.trim().startsWith(`/`)){let n=ja(e,yi).trim(),i=n.indexOf(` `),a=i===-1?n.slice(1):n.slice(1,i),o=i===-1?``:n.slice(i+1).trim(),s=Yt.find(e=>Zu(e)&&(e.name===a||e.aliases?.includes(a)||Ss(e)===a));s?.name===`clear`&&xr.current&&(Z(`tengu_idle_return_action`,{action:`hint_converted`,variant:xr.current,idleMinutes:Math.round((Date.now()-oa.current)/6e4),messageCount:br.current.length,totalInputTokens:ot()}),xr.current=!1);let c=Sn.isActive&&(s?.immediate||r?.fromKeybinding);if(s&&c&&s.type===`local-jsx`){e.trim()===$r.current.trim()&&(ni(``),t.setCursorOffset(0),t.clearBuffer(),Si({}));let n=li(e).filter(e=>yi[e.id]?.type===`text`),i=n.length;Z(`tengu_paste_text`,{pastedTextCount:i,pastedTextBytes:n.reduce((e,t)=>e+(yi[t.id]?.content.length??0),0)}),Z(`tengu_immediate_command_executed`,{commandName:s.name,fromKeybinding:r?.fromKeybinding??!1}),(async()=>{let e=!1,n=(n,r)=>{e=!0,Jn({jsx:null,shouldHidePromptInput:!1,clearLocalJSX:!0});let i=[];if(n&&r?.display!==`skip`&&(Ze({key:`immediate-${s.name}`,text:n,priority:`immediate`}),!pl())){let e=r?.displayArgs??o;i.push(Sc(bn(Ss(s),e)),Sc(`<${ep}>${Pl(n)}</${ep}>`))}r?.metaMessages?.length&&i.push(...r.metaMessages.map(e=>xa({content:e,isMeta:!0}))),i.length&&K(e=>[...e,...i]),oi!==void 0&&(ni(oi.text),t.setCursorOffset(oi.cursorOffset),Si(oi.pastedContents),si(void 0))},r=ko(br.current,[],Lc(),Se),i=await(await s.load()).call(n,r,o);i&&!e&&Jn({jsx:i,shouldHidePromptInput:!1,isLocalJSXCommand:!0})})();return}}if(vi.isRemoteMode&&!e.trim())return;Number(process.env.CLAUDE_CODE_IDLE_THRESHOLD_MINUTES??75),Number(process.env.CLAUDE_CODE_IDLE_TOKEN_THRESHOLD??1e5),r?.fromKeybinding||(gd({display:n?e:Gd(e,ri),pastedContents:n?{}:yi}),ri===`bash`&&vw(e.trim()));let i=!n&&e.trim().startsWith(`/`),a=!W||n||vi.isRemoteMode;if(oi!==void 0&&!i&&a?(ni(oi.text),t.setCursorOffset(oi.cursorOffset),Si(oi.pastedContents),si(void 0)):a&&(r?.fromKeybinding||(ni(``),t.setCursorOffset(0)),Si({})),a&&(ai(`prompt`),ht(void 0),wi(e=>e+1),t.clearBuffer(),Ta.current=!1,!i&&ri===`prompt`&&!n&&!vi.isRemoteMode&&(Sr(e),Pn()),U(e=>({...e,attribution:Oh(e.attribution,e=>{Us(e).catch(e=>{Y(`Attribution: Failed to save snapshot: ${e}`)})})}))),n){let{queryRequired:t}=await Zs(n.state,n.speculationSessionTimeSavedMs,n.setAppState,e,{setMessages:K,readFileState:Ja,cwd:ct()});if(t){let e=Lc();ln(e),No([],e,!0,[],Se)}return}if(vi.isRemoteMode&&!(i&&Yt.find(t=>{let n=e.trim().slice(1).split(/\s/)[0];return Zu(t)&&(t.name===n||t.aliases?.includes(n)||Ss(t)===n)})?.type===`local-jsx`)){let t=Object.values(yi),n=t.filter(e=>e.type===`image`),r=n.length>0?n.map(e=>e.id):void 0,i=e.trim(),a=e.trim();if(t.length>0){let n=[],r=[],o=e.trim();o&&(n.push({type:`text`,text:o}),r.push({type:`text`,text:o}));for(let e of t)if(e.type===`image`){let t={type:`base64`,media_type:e.mediaType??`image/png`,data:e.content};n.push({type:`image`,source:t}),r.push({type:`image`,source:t})}else n.push({type:`text`,text:e.content}),r.push({type:`text`,text:e.content});i=n,a=r}let o=xa({content:i,imagePasteIds:r});K(e=>[...e,o]),await vi.sendMessage(a,{uuid:o.uuid});return}await Gr(),await nk({input:e,helpers:t,queryGuard:Sn,isExternalLoading:wn,mode:ri,commands:Yt,onInputChange:ni,setPastedContents:Si,setToolJSX:Jn,getToolUseContext:ko,messages:br.current,mainLoopModel:Se,pastedContents:yi,ideSelection:ft,setUserInputOnProcessing:Sr,setAbortController:ln,abortController:cn,onQuery:No,setAppState:U,querySource:Bu(),onBeforeQuery:_,canUseTool:Oo,addNotification:Ze,setMessages:K,streamMode:Qt.current,hasInterruptibleToolInProgress:mi.current}),(i||W)&&oi!==void 0&&(ni(oi.text),t.setCursorOffset(oi.cursorOffset),Si(oi.pastedContents),si(void 0))},[Sn,W,wn,ri,Yt,ni,ai,Si,wi,ht,Jn,ko,Se,yi,ft,Sr,ln,Ze,No,oi,si,U,_,Oo,hi,K,Gr,Lr]),Lo=(0,Q.useCallback)(()=>{let e=ro?Sj(ro):`/issue`;ao(null),Io(e,{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}}).catch(t=>{Y(`Auto-run ${e} failed: ${df(t)}`)})},[Io,ro]),Ro=(0,Q.useCallback)(()=>{ao(null)},[]),zo=(0,Q.useCallback)(()=>{let e=process.env.USER_TYPE===`ant`?`/issue`:`/feedback`;Io(e,{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}}).catch(e=>{Y(`Survey feedback request failed: ${e instanceof Error?e.message:String(e)}`)})},[Io]),Vo=(0,Q.useRef)(Io);Vo.current=Io;let Ho=(0,Q.useCallback)(()=>{Vo.current(`/rate-limit-options`,{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}})},[]),Uo=(0,Q.useCallback)(async()=>{if(fo(!0),Yr()){Gv(`tmux`,[`detach-client`],{stdio:`ignore`}),fo(!1);return}if(rn()!==null){lo((0,$.jsx)(N_,{showWorktree:!0,onDone:()=>{},onCancel:()=>{lo(null),fo(!1)}}));return}let e=await(await Yl.load()).call(()=>{});lo(e),e===null&&fo(!1)},[]),Go=(0,Q.useCallback)(()=>{qi(e=>!e)},[]),Ko=(0,Q.useCallback)(e=>{let t=br.current,n=t.lastIndexOf(e);if(n===-1)return;Z(`tengu_conversation_rewind`,{preRewindMessageCount:t.length,postRewindMessageCount:n,messagesRemoved:t.length-n,rewindToMessageIndex:n}),K(t.slice(0,n)),$i(Bv()),ys();let r=e.permissionMode;U(e=>({...e,toolPermissionContext:r&&e.toolPermissionContext.mode!==r?{...e.toolPermissionContext,mode:r}:e.toolPermissionContext,promptSuggestion:{text:null,promptId:null,shownAt:0,acceptedAt:0,generationRequestId:null}}))},[K,U]),qo=(0,Q.useCallback)(e=>{Ko(e);let t=ea(e);if(t&&(ni(t.text),ai(t.mode)),Array.isArray(e.message.content)&&e.message.content.some(e=>e.type===`image`)){let t=e.message.content.filter(e=>e.type===`image`);if(t.length>0){let n={};t.forEach((t,r)=>{if(t.source.type===`base64`){let i=e.imagePasteIds?.[r]??r+1;n[i]={id:i,type:`image`,content:t.source.data,mediaType:t.source.media_type}}}),Si(n)}}},[Ko,ni]);gn.current=qo;let Jo=(0,Q.useCallback)(async e=>{setImmediate((e,t)=>e(t),qo,e)},[qo]),Xo=e=>{let t=e.slice(0,24);return G.findIndex(e=>e.uuid.slice(0,24)===t)},{enter:Qo,handlers:$o}=Aa(jr,Nr,Pr,{copy:e=>void re(e).then(e=>{e&&process.stdout.write(e),Ze({key:`selection-copied`,text:`copied`,color:`success`,priority:`immediate`,timeoutMs:2e3})}),edit:async e=>{let t=Xo(e.uuid),n=t>=0?G[t]:void 0;if(!n||!bg(n))return;let r=!await oo(se,n.uuid),i=Sg(G,t);r&&i?(So(),Jo(n)):(Yi(n),qi(!0))}});async function es(){no();let e=await St();if(e.length>0){let t=e.map(e=>` [${e.type}] ${e.path} (${e.content.length} chars)${e.parent?` (included by ${e.parent})`:``}`).join(`
|
|
139
139
|
`);Y(`Loaded ${e.length} CLAUDE.md/rules files:\n${t}`)}else Y(`No CLAUDE.md/rules files found`);for(let t of e)Ja.current.set(t.path,{content:t.contentDiffersFromDisk?t.rawContent??t.content:t.content,timestamp:Date.now(),offset:void 0,limit:void 0,isPartialView:t.contentDiffersFromDisk})}NO(mv()),Cy(G,G.length===i?.length);let{sendBridgeResult:ts}=By(G,K,un,Yt,Se);hn.current=ts,PO();let ns=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{if(le.length<1){ns.current=!1;return}ns.current||(ns.current=!0,zf(e=>({...e,promptQueueUseCount:(e.promptQueueUseCount??0)+1})))},[le.length]),ok({executeQueuedInput:(0,Q.useCallback)(async e=>{await nk({helpers:{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}},queryGuard:Sn,commands:Yt,onInputChange:()=>{},setPastedContents:()=>{},setToolJSX:Jn,getToolUseContext:ko,messages:G,mainLoopModel:Se,ideSelection:ft,setUserInputOnProcessing:Sr,setAbortController:ln,onQuery:No,setAppState:U,querySource:Bu(),onBeforeQuery:_,canUseTool:Oo,addNotification:Ze,setMessages:K,queuedCommands:e})},[Sn,Yt,Jn,ko,G,Se,ft,Sr,Oo,ln,No,Ze,U,_]),hasActiveLocalJsxUI:pr,queryGuard:Sn}),(0,Q.useEffect)(()=>{ps.recordUserActivity(),gt(!0)},[Zr,Ci]),(0,Q.useEffect)(()=>{Ci===1&&Tv()},[Ci]),(0,Q.useEffect)(()=>{if(W||Ci===0||Ii===0)return;let e=setTimeout((e,t,n,r,i)=>{if(Le()>e)return;let a=Date.now()-e;!t&&!n&&r.current===void 0&&a>=Bf().messageIdleNotifThresholdMs&&ry({message:`Claude is waiting for your input`,notificationType:`idle_prompt`},i)},Bf().messageIdleNotifThresholdMs,Ii,W,Gn,Ln,xe);return()=>clearTimeout(e)},[W,Gn,Ci,Ii,xe]),(0,Q.useEffect)(()=>{},[Ii,W,Ze,Qe]);let rs=(0,Q.useCallback)((e,t)=>{if(Sn.isActive||Ha().some(e=>e.mode===`prompt`||e.mode===`bash`))return!1;let n=typeof e==`string`?{value:e,mode:`prompt`,isMeta:t?.isMeta?!0:void 0}:e;return(async()=>{let e=await kd([n]),t=e.attachmentCommands[0];if(!t)return;let r=Lc();ln(r);let i=xa({content:t.value,isMeta:t.isMeta?!0:void 0,origin:t.origin}),a=!1;try{a=await No([i],r,!0,[],Se)!==!1}catch(t){try{await _s({commands:e.claimedCommands,outcome:{type:`failed`,error:t},currentDir:Jd(),priority:`later`})}catch(e){X(Qd(e))}X(Qd(t));return}if(a)try{let t=await _s({commands:e.claimedCommands,outcome:{type:`completed`},currentDir:Jd(),priority:`later`});for(let e of t)io(e)}catch(e){X(Qd(e))}})().catch(e=>{X(Qd(e))}),!0},[No,Se,be]),{relayPipeMessage:is,pipeReturnHadErrorRef:as}=aN();sk({isLoading:W,onSubmitMessage:rs}),J(e=>ug(e));let{routeToSelectedPipes:os}=oN({store:be,setAppState:U,addNotification:Ze});process.env.USER_TYPE===`ant`&&vk({taskListId:w,isLoading:W,onSubmitTask:rs}),rN?.({isLoading:W||ce!==null,queuedCommandsLength:le.length,hasActiveLocalJsxUI:pr,isInPlanMode:L.mode===`plan`,onQueueTick:e=>io(e)}),iN?.({isLoading:W||ce!==null,wasAborted:fn,queuedCommandsLength:le.length,hasActiveLocalJsxUI:pr,isInPlanMode:L.mode===`plan`,isQueryActiveNow:Sn.getSnapshot,onContinuationEnqueued:({turn:e,objective:t})=>{let n=`Goal auto-continue (${e}/1): continue advancing "${t}".`;K(e=>[...e,xa({content:n,isVisibleInTranscriptOnly:!0})])},onMaxTurnsReached:()=>{Ze({key:`goal-max-turns-reached`,text:`Goal reached max continuation turns (1). Run /goal continue to reset turn counter and continue.`,priority:`immediate`})}}),(0,Q.useEffect)(()=>{if(!Te){hh(null);return}if(!W){if(Ee!==null&&le.length===0&&!pr&&L.mode!==`plan`&&ce===null){hh({enabled:!0,phase:`standby`,next_tick_at:Ee,sleep_until:null});return}hh({enabled:!0,phase:null,next_tick_at:null,sleep_until:null})}},[ce,W,pr,Te,Ee,le.length,L.mode]),(0,Q.useEffect)(()=>{le.some(e=>e.priority===`now`)&&un.current?.abort(`interrupt`)},[le]);let ss=(0,Q.useRef)(es);ss.current=es;let cs=(0,Q.useRef)(Ut);cs.current=Ut,(0,Q.useEffect)(()=>(ss.current(),()=>{cs.current.shutdown()}),[]);let{internal_eventEmitter:us}=te(),[ds,fs]=(0,Q.useState)(0);(0,Q.useEffect)(()=>{let e=()=>{process.stdout.write(`
|
|
140
140
|
Claude Code has been suspended. Run \`fg\` to bring Claude Code back.
|
|
141
141
|
Note: ctrl + z now suspends Claude Code, ctrl + _ undoes input.
|
|
142
|
-
`)},t=()=>{fs(e=>e+1)};return us?.on(`suspend`,e),us?.on(`resume`,t),()=>{us?.off(`suspend`,e),us?.off(`resume`,t)}},[us]);let ms=(0,Q.useMemo)(()=>{if(!W)return null;let e=G.filter(e=>{if(e.type!==`progress`)return!1;let t=e.data;return t.type===`hook_progress`&&(t.hookEvent===`Stop`||t.hookEvent===`SubagentStop`)});if(e.length===0)return null;let t=e.at(-1)?.toolUseID;if(!t||G.some(e=>e.type===`system`&&e.subtype===`stop_hook_summary`&&e.toolUseID===t))return null;let n=e.filter(e=>e.toolUseID===t),r=n.length,i=Pf(G,e=>{if(e.type!==`attachment`)return!1;let n=e.attachment;return`hookEvent`in n&&(n.hookEvent===`Stop`||n.hookEvent===`SubagentStop`)&&`toolUseID`in n&&n.toolUseID===t}),a=n.find(e=>e.data.statusMessage)?.data.statusMessage;if(a)return r===1?`${a}…`:`${a}… ${i}/${r}`;let o=n[0]?.data.hookEvent===`SubagentStop`?`subagent stop`:`stop`;if(process.env.USER_TYPE===`ant`){let e=n[i]?.data.command,t=e?` '${Op(e,40)}'`:``;return r===1?`running ${o} hook${t}`:`running ${o} hook${t}\u2026 ${i}/${r}`}return r===1?`running ${o} hook`:`running stop hooks… ${i}/${r}`},[G,W]),hs=(0,Q.useCallback)(()=>{Xr({messagesLength:G.length,streamingToolUsesLength:$t.length})},[G.length,$t.length]),vs=(0,Q.useCallback)(()=>{Xr(null)},[]),bs=pl()&&!P,xs=(0,Q.useRef)(null),[Cs,ws]=(0,Q.useState)(!1),[Es,Os]=(0,Q.useState)(``),[ks,As]=(0,Q.useState)(0),[Ms,Ns]=(0,Q.useState)(0),Ps=(0,Q.useCallback)((e,t)=>{As(e),Ns(t)},[]);oe((e,t,n)=>{if(t.ctrl||t.meta)return;if(e===`/`){xs.current?.setAnchor(),ws(!0),n.stopImmediatePropagation();return}let r=e[0];if((r===`n`||r===`N`)&&e===r.repeat(e.length)&&ks>0){let t=r===`n`?xs.current?.nextMatch:xs.current?.prevMatch;if(t)for(let n=0;n<e.length;n++)t();n.stopImmediatePropagation()}},{isActive:Pe===`transcript`&&bs&&!Cs&&!Be});let{setQuery:Fs,scanElement:zs,setPositions:Bs}=fe(),Hs=de().columns,Ws=Q.useRef(Hs);Q.useEffect(()=>{Ws.current!==Hs&&(Ws.current=Hs,(Es||Cs)&&(ws(!1),Os(``),As(0),Ns(0),xs.current?.disarmSearch(),Fs(``)))},[Hs,Es,Cs,Fs]),oe((e,t,n)=>{if(!(t.ctrl||t.meta)){if(e===`q`){vs(),n.stopImmediatePropagation();return}if(e===`[`&&!Be)He(!0),ze(!0),n.stopImmediatePropagation();else if(e===`v`){if(n.stopImmediatePropagation(),Xe.current)return;Xe.current=!0;let e=Ke.current,t=t=>{e===Ke.current&&(clearTimeout(Ye.current),We(t))};t(`rendering ${Kr.length} messages…`),(async()=>{try{let e=Math.max(80,(process.stdout.columns??80)-6),n=(await $v(Kr,Kt,e)).replace(/[ \t]+$/gm,``),r=Nv(Ov(),`cc-transcript-${Date.now()}.txt`);await Uv(r,n);let i=Xg(r);t(i?`opening ${r}`:`wrote ${r} · no $VISUAL/$EDITOR set`)}catch(e){t(`render failed: ${e instanceof Error?e.message:String(e)}`)}Xe.current=!1,e===Ke.current&&(Ye.current=setTimeout(e=>e(``),4e3,We))})()}}},{isActive:Pe===`transcript`&&bs&&!Cs});let Gs=Pe===`transcript`&&bs;(0,Q.useEffect)(()=>{Gs||(Os(``),As(0),Ns(0),ws(!1),Ke.current++,clearTimeout(Ye.current),He(!1),We(``))},[Gs]),(0,Q.useEffect)(()=>{Fs(Gs?Es:``),Gs||Bs(null)},[Gs,Es,Fs,Bs]);let Ks={screen:Pe,setScreen:Ie,showAllInTranscript:Re,setShowAllInTranscript:ze,messageCount:G.length,onEnterTranscript:hs,onExitTranscript:vs,virtualScrollActive:bs,searchBarOpen:Cs},qs=Jr?Kr.slice(0,Jr.messagesLength):Kr,Js=Jr?$t.slice(0,Jr.streamingToolUsesLength):$t;HO({onOpenBackgroundTasks:pr?void 0:()=>ha(!0),onTogglePipeSelector:()=>{U(e=>{let t=e.pipeIpc??{};return{...e,pipeIpc:{...t,selectorOpen:!t.selectorOpen}}})}});let Ys=ge?B[ge]:void 0,Xs=Ys&&Gc(Ys)?Ys:void 0,$s=Ni||!W,ec=Xs?.messages,nc=(0,Q.useMemo)(()=>{if(!Xs)return;let e=ec??[];if(!Gc(Xs)||Xs.agentType!==`fork`||!Xs.prompt)return e;let t=Xs.prompt.trim(),n=-1,r=-1,i=!1;for(let a=0;a<e.length;a++){let o=e[a];if(o.type===`user`&&Array.isArray(o.message?.content)){if(o.message.content.some(bN))n=a;else if(!i){let e=o.message.content.find(e=>e.type===`text`&&typeof e.text==`string`);e&&e.text.trim()===t&&(i=!0)}continue}o.type===`assistant`&&Array.isArray(o.message?.content)&&o.message.content.some(e=>e.type===`tool_use`)&&(r=a)}let a=n===-1?e:e.map((e,t)=>t!==n||!Array.isArray(e.message?.content)?e:{...e,message:{...e.message,content:e.message.content.filter(e=>!bN(e))}});if(i)return a;let o=n===-1?r+1:n+1,s=xa({content:Xs.prompt,timestamp:new Date(Xs.startTime).toISOString()});return[...a.slice(0,o),s,...a.slice(o)]},[Xs,ec]),rc=Xs?nc??[]:$s?G:Kr;if(Pe===`transcript`){let e=pl()&&!P&&!Be?vn:void 0,t=(0,$.jsx)(ov,{messages:qs,tools:Kt,commands:Yt,verbose:!0,toolJSX:null,toolUseConfirmQueue:[],inProgressToolUseIDs:ui,isMessageSelectorVisible:!1,conversationId:Qi,screen:Pe,agentDefinitions:ae,streamingToolUses:Js,showAllInTranscript:Re,onOpenRateLimitOptions:Ho,isLoading:W,hidePastThinking:!0,streamingThinking:an,scrollRef:e,jumpRef:xs,onSearchMatchesChange:Ps,scanElement:zs,setPositions:Bs,disableRenderCap:Be}),n=Gn&&(0,$.jsx)(b,{flexDirection:`column`,width:`100%`,children:Gn.jsx}),r=(0,$.jsxs)(Mr,{children:[(0,$.jsx)(vN,{isAnimating:mr,title:dr,disabled:N,noPrefix:!1}),(0,$.jsx)(LO,{...Ks}),(0,$.jsx)(zO,{onSubmit:Io,isActive:!Gn?.isLocalJSXCommand}),e?(0,$.jsx)(mM,{scrollRef:vn,isActive:ho!==`ultraplan-choice`,isModal:!Cs,onScroll:()=>xs.current?.disarmSearch()}):null,(0,$.jsx)(VO,{...wo}),e?(0,$.jsx)(iv,{scrollRef:vn,scrollable:(0,$.jsxs)($.Fragment,{children:[t,n,(0,$.jsx)(_A,{})]}),bottom:Cs?(0,$.jsx)(mN,{jumpRef:xs,initialQuery:``,count:ks,current:Ms,onClose:e=>{Os(ks>0?e:``),ws(!1),e||(As(0),Ns(0),xs.current?.setSearchQuery(``))},onCancel:()=>{ws(!1),xs.current?.setSearchQuery(``),xs.current?.setSearchQuery(Es),Fs(Es)},setHighlight:Fs}):(0,$.jsx)(pN,{showAllInTranscript:Re,virtualScroll:!0,status:Ue||void 0,searchBadge:Es&&ks>0?{current:Ms,count:ks}:void 0})}):(0,$.jsxs)($.Fragment,{children:[t,n,(0,$.jsx)(_A,{}),(0,$.jsx)(pN,{showAllInTranscript:Re,virtualScroll:!1,suppressShowAll:Be,status:Ue||void 0})]})]});return e?(0,$.jsx)(_e,{mouseTracking:ad(),children:r}):r}let ic=Dn&&!Xs&&rc.length<=kn.current?Dn:void 0,ac=ho===`tool-permission`?(0,$.jsx)(US,{onDone:()=>Xn(([e,...t])=>t),onReject:Co,toolUseConfirm:Yn[0],toolUseContext:ko(G,G,cn??Lc(),Se),verbose:R,setStickyFooter:pl()?Qn:void 0},Yn[0]?.toolUseID):null,oc=pl()&&Gn?.isLocalJSXCommand===!0,lc=oc?Gn.jsx:null,uc=(0,$.jsxs)(Mr,{children:[(0,$.jsx)(vN,{isAnimating:mr,title:dr,disabled:N,noPrefix:!1}),(0,$.jsx)(LO,{...Ks}),(0,$.jsx)(zO,{onSubmit:Io,isActive:!Gn?.isLocalJSXCommand}),(0,$.jsx)(mM,{scrollRef:vn,isActive:pl()&&(lc!=null||!ho||ho===`tool-permission`),onScroll:Wr}),null,(0,$.jsx)(VO,{...wo}),(0,$.jsx)(pg,{dynamicMcpConfig:ke,isStrictMcpConfig:m,children:(0,$.jsx)(iv,{scrollRef:vn,overlay:ac,modal:lc,modalScrollRef:yn,dividerYRef:wr,hidePill:!!Xs,newMessageCount:Ir?.count??0,onPillClick:()=>{Nr(null),kr(vn.current)},scrollable:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ov,{messages:rc,tools:Kt,commands:Yt,verbose:R,toolJSX:Gn,toolUseConfirmQueue:Yn,inProgressToolUseIDs:ui,isMessageSelectorVisible:Ki,conversationId:Qi,screen:Pe,streamingToolUses:$t,showAllInTranscript:Re,agentDefinitions:ae,onOpenRateLimitOptions:Ho,isLoading:W,streamingText:W&&!Xs?Fi:null,isBriefOnly:!Xs&&De,unseenDivider:Xs?void 0:Ir,scrollRef:pl()?vn:void 0,trackStickyPrompt:pl()?!0:void 0,cursor:jr,setCursor:Nr,cursorNavRef:Pr}),(0,$.jsx)(tj,{}),!x&&ic&&!lc&&(0,$.jsx)(ir,{param:{text:ic,type:`text`},addMargin:!0,verbose:R}),Gn&&!(Gn.isLocalJSXCommand&&Gn.isImmediate)&&!oc&&(0,$.jsx)(b,{flexDirection:`column`,width:`100%`,children:Gn.jsx}),process.env.USER_TYPE===`ant`&&(0,$.jsx)(wj,{}),(0,$.jsx)(b,{flexGrow:1}),Ia&&(0,$.jsx)(Vs,{mode:Xt,spinnerTip:ue,responseLengthRef:Ei,apiMetricsRef:Oi,overrideMessage:Ri,spinnerSuffix:ms,verbose:R,loadingStartTimeRef:jn,totalPausedMsRef:Mn,pauseStartTimeRef:Nn,overrideColor:Vi,overrideShimmerColor:Wi,hasActiveTools:ui.size>0,leaderIsIdle:!W}),!Ia&&!W&&!Dn&&De&&!Xs&&(0,$.jsx)(aa,{})]}),bottom:(0,$.jsx)(b,{flexDirection:`row`,width:`100%`,alignItems:`flex-end`,children:(0,$.jsxs)(b,{flexDirection:`column`,flexGrow:1,children:[pl()&&(0,$.jsx)(TD,{}),Zn,Gn?.isLocalJSXCommand&&Gn.isImmediate&&!oc&&(0,$.jsx)(b,{flexDirection:`column`,width:`100%`,children:Gn.jsx}),!Ia&&!Gn?.isLocalJSXCommand&&pe&&Ht&&Ht.length>0&&(0,$.jsx)(b,{width:`100%`,flexDirection:`column`,children:(0,$.jsx)(sc,{tasks:Ht,isStandalone:!0})}),ho===`sandbox-permission`&&(0,$.jsx)(hA,{hostPattern:$n[0].hostPattern,onUserResponse:e=>{let{allow:t,persistToSettings:n}=e,r=$n[0];if(!r)return;let i=r.hostPattern.host;er(e=>(e.filter(e=>e.hostPattern.host===i).forEach(e=>e.resolvePromise(t)),e.filter(e=>e.hostPattern.host!==i)));let a=rr.current.get(i);if(a){for(let e of a)e();rr.current.delete(i)}}},$n[0].hostPattern.host),ho===`prompt`&&(0,$.jsx)(pC,{title:tr[0].title,toolInputSummary:tr[0].toolInputSummary,request:tr[0].request,onRespond:e=>{let t=tr[0];t&&(t.resolve({prompt_response:t.request.prompt,selected:e}),nr(([,...e])=>e))},onAbort:()=>{let e=tr[0];e&&(e.reject(Error(`Prompt cancelled by user`)),nr(([,...e])=>e))}},tr[0].request.prompt),ho===`elicitation`&&(0,$.jsx)(uC,{event:H.queue[0],onResponse:(e,t)=>{let n=H.queue[0];n&&(n.respond({action:e,content:t}),n.params.mode===`url`&&e===`accept`||U(e=>({...e,elicitation:{queue:e.elicitation.queue.slice(1)}})))},onWaitingDismiss:e=>{let t=H.queue[0];U(e=>({...e,elicitation:{queue:e.elicitation.queue.slice(1)}})),t?.onWaitingDismiss?.(e)}},H.queue[0].serverName+`:`+String(H.queue[0].requestId)),ho===`cost`&&(0,$.jsx)(ey,{onDone:()=>{Zi(!1),la(!0),zf(e=>({...e,hasAcknowledgedCostThreshold:!0})),Z(`tengu_cost_threshold_acknowledged`,{})}}),ho===`idle-return`&&ta&&(0,$.jsx)(ty,{idleMinutes:ta.idleMinutes,totalInputTokens:ot(),onDone:async e=>{let t=ta;if(na(null),Z(`tengu_idle_return_action`,{action:e,idleMinutes:Math.round(t.idleMinutes),messageCount:br.current.length,totalInputTokens:ot()}),e===`dismiss`){ni(t.input);return}if(e===`never`&&zf(e=>e.idleReturnDismissed?e:{...e,idleReturnDismissed:!0}),e===`clear`){let{clearConversation:e}=await import(`./conversation-oK3aFzqO.js`);await e({setMessages:K,readFileState:Ja.current,discoveredSkillNames:Za.current,loadedNestedMemoryPaths:Qa.current,getAppState:()=>be.getState(),setAppState:U,setConversationId:$i}),cr.current=!1,sr(void 0),Ya.current.clear(),Xa.current=0}ia.current=!0,Vo.current(t.input,{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}})}}),ho===`ide-onboarding`&&(0,$.jsx)(ua,{onDone:()=>wt(!1),installationStatus:bt}),process.env.USER_TYPE===`ant`&&ho===`model-switch`&&sN&&(0,$.jsx)(sN,{onDone:(e,t)=>{Et(!1),e===`switch`&&t&&U(e=>({...e,mainLoopModel:t,mainLoopModelForSession:null}))}}),process.env.USER_TYPE===`ant`&&ho===`undercover-callout`&&lN&&(0,$.jsx)(lN,{onDone:()=>Wn(!1)}),ho===`effort-callout`&&(0,$.jsx)(Tk,{model:Se,onDone:e=>{jt(!1),e!==`dismiss`&&U(t=>({...t,effortValue:e}))}}),ho===`remote-callout`&&(0,$.jsx)(o_,{onDone:e=>{U(t=>t.showRemoteCallout?{...t,showRemoteCallout:!1,...e===`enable`&&{replBridgeEnabled:!0,replBridgeExplicit:!0,replBridgeOutboundOnly:!1}}:t)}}),co,ho===`plugin-hint`&&Rt&&(0,$.jsx)(UA,{pluginName:Rt.pluginName,pluginDescription:Rt.pluginDescription,marketplaceName:Rt.marketplaceName,sourceCommand:Rt.sourceCommand,onResponse:zt}),ho===`search-extra-tools-hint`&&Bt.visible&&(0,$.jsx)(GA,{tools:Bt.tools,onSelect:Bt.handleSelect,onDismiss:Bt.handleDismiss}),ho===`lsp-recommendation`&&Ft&&(0,$.jsx)(BA,{pluginName:Ft.pluginName,pluginDescription:Ft.pluginDescription,fileExtension:Ft.fileExtension,onResponse:Lt}),ho===`desktop-upsell`&&(0,$.jsx)(bv,{onDone:()=>Pt(!1)}),ho===`ultraplan-choice`&&me&&(0,$.jsx)(Rj,{plan:me.plan,sessionId:me.sessionId,taskId:me.taskId,setMessages:K,readFileState:Ja.current,getAppState:()=>be.getState(),setConversationId:$i}),ho===`ultraplan-launch`&&he&&(0,$.jsx)(Vj,{onChoice:(e,t)=>{let n=he.blurb;if(U(e=>e.ultraplanLaunchPending?{...e,ultraplanLaunchPending:void 0}:e),e===`cancel`)return;K(e=>[...e,Sc(bn(`ultraplan`,n))]);let r=e=>K(t=>[...t,Sc(`<local-command-stdout>${Pl(e)}</local-command-stdout>`)]);_u({blurb:n,promptIdentifier:t?.promptIdentifier,getAppState:()=>be.getState(),setAppState:U,signal:Lc().signal,disconnectedBridge:t?.disconnectedBridge,onSessionReady:e=>{if(!Sn.isActive){r(e);return}let t=Sn.subscribe(()=>{Sn.isActive||(t(),be.getState().ultraplanSessionUrl&&r(e))})}}).then(r).catch(X)}}),Fa(),!Gn?.shouldHidePromptInput&&!ho&&!uo&&!x&&!jr&&(0,$.jsxs)($.Fragment,{children:[ro&&(0,$.jsx)(bj,{onRun:Lo,onCancel:Ro,reason:Cj(ro)}),Ua.state===`closed`?Wa.state===`closed`?(0,$.jsx)(Yk,{state:Va.state,lastResponse:Va.lastResponse,handleSelect:Va.handleSelect,handleTranscriptSelect:Va.handleTranscriptSelect,inputValue:Zr,setInputValue:ni,onRequestFeedback:so.current?void 0:zo}):(0,$.jsx)(Yk,{state:Wa.state,lastResponse:Wa.lastResponse,handleSelect:Wa.handleSelect,handleTranscriptSelect:Wa.handleTranscriptSelect,inputValue:Zr,setInputValue:ni,onRequestFeedback:zo,message:`How well did Claude use its memory? (optional)`}):(0,$.jsx)(Yk,{state:Ua.state,lastResponse:Ua.lastResponse,handleSelect:Ua.handleSelect,inputValue:Zr,setInputValue:ni,onRequestFeedback:zo}),Ga.state!==`closed`&&(0,$.jsx)(Yk,{state:Ga.state,lastResponse:null,handleSelect:()=>{},handleTranscriptSelect:Ga.handleTranscriptSelect,inputValue:Zr,setInputValue:ni}),za.suggestion&&(0,$.jsx)(DO,{isOpen:za.isOpen,skillName:za.suggestion.skillName,updates:za.suggestion.updates,handleSelect:za.handleSelect,inputValue:Zr,setInputValue:ni}),Ba&&(0,$.jsx)(Tj,{}),(0,$.jsx)(WD,{debug:n,ideSelection:ft,hasSuppressedDialogs:!!go,isLocalJSXCommandActive:pr,getToolUseContext:ko,toolPermissionContext:L,setToolPermissionContext:Do,apiKeyStatus:to,commands:Yt,agents:ae.activeAgents,isLoading:W,onExit:Uo,verbose:R,messages:G,onAutoUpdaterResult:Hn,autoUpdaterResult:Vn,input:Zr,onInputChange:ni,mode:ri,onModeChange:ai,stashedPrompt:oi,setStashedPrompt:si,submitCount:Ci,onShowMessageSelector:Go,onMessageActionsEnter:void 0,mcpClients:dt,pastedContents:yi,setPastedContents:Si,vimMode:fa,setVimMode:pa,showBashesDialog:ma,setShowBashesDialog:ha,onSubmit:Io,isSearchingHistory:ga,setIsSearchingHistory:_a,helpOpen:va,setHelpOpen:ba,insertTextRef:ei}),(0,$.jsx)(Sk,{onBackgroundSession:Ao,isLoading:W}),(0,$.jsx)(gk,{})]}),jr&&(0,$.jsx)(Od,{cursor:jr}),ho===`message-selector`&&(0,$.jsx)(Tg,{messages:G,preselectedMessage:Ji,onPreRestore:So,onRestoreCode:async e=>{await xo(e=>{U(t=>({...t,fileHistory:e(t.fileHistory)}))},e.uuid)},onSummarize:async(e,t,n=`from`)=>{let r=At(G),i=r.indexOf(e);if(i===-1){K(e=>[...e,Ed(`That message is no longer in the active context (snipped or pre-compact). Choose a more recent message.`,`warning`)]);return}let a=Lc(),o=ko(r,[],a,Se),s=o.getAppState(),c=await dl(o.options.tools,o.options.mainLoopModel,Array.from(s.toolPermissionContext.additionalWorkingDirectories.keys()),o.options.mcpClients),l=_o({mainThreadAgentDefinition:void 0,toolUseContext:o,customSystemPrompt:o.options.customSystemPrompt,defaultSystemPrompt:c,appendSystemPrompt:o.options.appendSystemPrompt}),[u,d]=await Promise.all([Fr(),Rn()]),f=await tn(r,i,o,{systemPrompt:l,userContext:u,systemContext:d,toolUseContext:o,forkContextMessages:r},t,n),p=f.messagesToKeep??[],m=n===`up_to`?[...f.summaryMessages,...p]:[...p,...f.summaryMessages],h=[f.boundaryMarker,...m,...f.attachments,...f.hookResults];if(pl()&&n===`from`?K(t=>{let n=t.findIndex(t=>t.uuid===e.uuid);return[...t.slice(0,n===-1?0:n),...h]}):K(h),QM?.setContextBlocked(!1),$i(Bv()),Yo(o.options.querySource),n===`from`){let t=ea(e);t&&(ni(t.text),ai(t.mode))}let g=Hr(`app:toggleTranscript`,`Global`,`ctrl+o`);Ze({key:`summarize-ctrl-o-hint`,text:`Conversation summarized (${g} for history)`,priority:`medium`,timeoutMs:8e3})},onRestoreMessage:Jo,onClose:()=>{qi(!1),Yi(void 0)}}),process.env.USER_TYPE===`ant`&&(0,$.jsx)(Pj,{})]})})})},ds)]});return pl()?(0,$.jsx)(_e,{mouseTracking:ad(),children:uc}):uc}export{xN as t};
|
|
142
|
+
`)},t=()=>{fs(e=>e+1)};return us?.on(`suspend`,e),us?.on(`resume`,t),()=>{us?.off(`suspend`,e),us?.off(`resume`,t)}},[us]);let ms=(0,Q.useMemo)(()=>{if(!W)return null;let e=G.filter(e=>{if(e.type!==`progress`)return!1;let t=e.data;return t.type===`hook_progress`&&(t.hookEvent===`Stop`||t.hookEvent===`SubagentStop`)});if(e.length===0)return null;let t=e.at(-1)?.toolUseID;if(!t||G.some(e=>e.type===`system`&&e.subtype===`stop_hook_summary`&&e.toolUseID===t))return null;let n=e.filter(e=>e.toolUseID===t),r=n.length,i=Pf(G,e=>{if(e.type!==`attachment`)return!1;let n=e.attachment;return`hookEvent`in n&&(n.hookEvent===`Stop`||n.hookEvent===`SubagentStop`)&&`toolUseID`in n&&n.toolUseID===t}),a=n.find(e=>e.data.statusMessage)?.data.statusMessage;if(a)return r===1?`${a}…`:`${a}… ${i}/${r}`;let o=n[0]?.data.hookEvent===`SubagentStop`?`subagent stop`:`stop`;if(process.env.USER_TYPE===`ant`){let e=n[i]?.data.command,t=e?` '${Op(e,40)}'`:``;return r===1?`running ${o} hook${t}`:`running ${o} hook${t}\u2026 ${i}/${r}`}return r===1?`running ${o} hook`:`running stop hooks… ${i}/${r}`},[G,W]),hs=(0,Q.useCallback)(()=>{Xr({messagesLength:G.length,streamingToolUsesLength:$t.length})},[G.length,$t.length]),vs=(0,Q.useCallback)(()=>{Xr(null)},[]),bs=pl()&&!P,xs=(0,Q.useRef)(null),[Cs,ws]=(0,Q.useState)(!1),[Es,Os]=(0,Q.useState)(``),[ks,As]=(0,Q.useState)(0),[Ms,Ns]=(0,Q.useState)(0),Ps=(0,Q.useCallback)((e,t)=>{As(e),Ns(t)},[]);oe((e,t,n)=>{if(t.ctrl||t.meta)return;if(e===`/`){xs.current?.setAnchor(),ws(!0),n.stopImmediatePropagation();return}let r=e[0];if((r===`n`||r===`N`)&&e===r.repeat(e.length)&&ks>0){let t=r===`n`?xs.current?.nextMatch:xs.current?.prevMatch;if(t)for(let n=0;n<e.length;n++)t();n.stopImmediatePropagation()}},{isActive:Pe===`transcript`&&bs&&!Cs&&!Be});let{setQuery:Fs,scanElement:zs,setPositions:Bs}=fe(),Hs=de().columns,Ws=Q.useRef(Hs);Q.useEffect(()=>{Ws.current!==Hs&&(Ws.current=Hs,(Es||Cs)&&(ws(!1),Os(``),As(0),Ns(0),xs.current?.disarmSearch(),Fs(``)))},[Hs,Es,Cs,Fs]),oe((e,t,n)=>{if(!(t.ctrl||t.meta)){if(e===`q`){vs(),n.stopImmediatePropagation();return}if(e===`[`&&!Be)He(!0),ze(!0),n.stopImmediatePropagation();else if(e===`v`){if(n.stopImmediatePropagation(),Xe.current)return;Xe.current=!0;let e=Ke.current,t=t=>{e===Ke.current&&(clearTimeout(Ye.current),We(t))};t(`rendering ${Kr.length} messages…`),(async()=>{try{let e=Math.max(80,(process.stdout.columns??80)-6),n=(await $v(Kr,Kt,e)).replace(/[ \t]+$/gm,``),r=Nv(Ov(),`cc-transcript-${Date.now()}.txt`);await Uv(r,n);let i=Xg(r);t(i?`opening ${r}`:`wrote ${r} · no $VISUAL/$EDITOR set`)}catch(e){t(`render failed: ${e instanceof Error?e.message:String(e)}`)}Xe.current=!1,e===Ke.current&&(Ye.current=setTimeout(e=>e(``),4e3,We))})()}}},{isActive:Pe===`transcript`&&bs&&!Cs});let Gs=Pe===`transcript`&&bs;(0,Q.useEffect)(()=>{Gs||(Os(``),As(0),Ns(0),ws(!1),Ke.current++,clearTimeout(Ye.current),He(!1),We(``))},[Gs]),(0,Q.useEffect)(()=>{Fs(Gs?Es:``),Gs||Bs(null)},[Gs,Es,Fs,Bs]);let Ks={screen:Pe,setScreen:Ie,showAllInTranscript:Re,setShowAllInTranscript:ze,messageCount:G.length,onEnterTranscript:hs,onExitTranscript:vs,virtualScrollActive:bs,searchBarOpen:Cs},qs=Jr?Kr.slice(0,Jr.messagesLength):Kr,Js=Jr?$t.slice(0,Jr.streamingToolUsesLength):$t;HO({onOpenBackgroundTasks:pr?void 0:()=>ha(!0),onTogglePipeSelector:()=>{U(e=>{let t=e.pipeIpc??{};return{...e,pipeIpc:{...t,selectorOpen:!t.selectorOpen}}})}});let Ys=ge?B[ge]:void 0,Xs=Ys&&Gc(Ys)?Ys:void 0,$s=Ni||!W,ec=Xs?.messages,nc=(0,Q.useMemo)(()=>{if(!Xs)return;let e=ec??[];if(!Gc(Xs)||Xs.agentType!==`fork`||!Xs.prompt)return e;let t=Xs.prompt.trim(),n=-1,r=-1,i=!1;for(let a=0;a<e.length;a++){let o=e[a];if(o.type===`user`&&Array.isArray(o.message?.content)){if(o.message.content.some(bN))n=a;else if(!i){let e=o.message.content.find(e=>e.type===`text`&&typeof e.text==`string`);e&&e.text.trim()===t&&(i=!0)}continue}o.type===`assistant`&&Array.isArray(o.message?.content)&&o.message.content.some(e=>e.type===`tool_use`)&&(r=a)}let a=n===-1?e:e.map((e,t)=>t!==n||!Array.isArray(e.message?.content)?e:{...e,message:{...e.message,content:e.message.content.filter(e=>!bN(e))}});if(i)return a;let o=n===-1?r+1:n+1,s=xa({content:Xs.prompt,timestamp:new Date(Xs.startTime).toISOString()});return[...a.slice(0,o),s,...a.slice(o)]},[Xs,ec]),rc=Xs?nc??[]:$s?G:Kr;if(Pe===`transcript`){let e=pl()&&!P&&!Be?vn:void 0,t=(0,$.jsx)(ov,{messages:qs,tools:Kt,commands:Yt,verbose:!0,toolJSX:null,toolUseConfirmQueue:[],inProgressToolUseIDs:ui,isMessageSelectorVisible:!1,conversationId:Qi,screen:Pe,agentDefinitions:ae,streamingToolUses:Js,showAllInTranscript:Re,onOpenRateLimitOptions:Ho,isLoading:W,hidePastThinking:!0,streamingThinking:an,scrollRef:e,jumpRef:xs,onSearchMatchesChange:Ps,scanElement:zs,setPositions:Bs,disableRenderCap:Be}),n=Gn&&(0,$.jsx)(b,{flexDirection:`column`,width:`100%`,children:Gn.jsx}),r=(0,$.jsxs)(Mr,{children:[(0,$.jsx)(vN,{isAnimating:mr,title:dr,disabled:N,noPrefix:!1}),(0,$.jsx)(LO,{...Ks}),(0,$.jsx)(zO,{onSubmit:Io,isActive:!Gn?.isLocalJSXCommand}),e?(0,$.jsx)(mM,{scrollRef:vn,isActive:ho!==`ultraplan-choice`,isModal:!Cs,onScroll:()=>xs.current?.disarmSearch()}):null,(0,$.jsx)(VO,{...wo}),e?(0,$.jsx)(iv,{scrollRef:vn,scrollable:(0,$.jsxs)($.Fragment,{children:[t,n,(0,$.jsx)(_A,{})]}),bottom:Cs?(0,$.jsx)(mN,{jumpRef:xs,initialQuery:``,count:ks,current:Ms,onClose:e=>{Os(ks>0?e:``),ws(!1),e||(As(0),Ns(0),xs.current?.setSearchQuery(``))},onCancel:()=>{ws(!1),xs.current?.setSearchQuery(``),xs.current?.setSearchQuery(Es),Fs(Es)},setHighlight:Fs}):(0,$.jsx)(pN,{showAllInTranscript:Re,virtualScroll:!0,status:Ue||void 0,searchBadge:Es&&ks>0?{current:Ms,count:ks}:void 0})}):(0,$.jsxs)($.Fragment,{children:[t,n,(0,$.jsx)(_A,{}),(0,$.jsx)(pN,{showAllInTranscript:Re,virtualScroll:!1,suppressShowAll:Be,status:Ue||void 0})]})]});return e?(0,$.jsx)(_e,{mouseTracking:ad(),children:r}):r}let ic=Dn&&!Xs&&rc.length<=kn.current?Dn:void 0,ac=ho===`tool-permission`?(0,$.jsx)(US,{onDone:()=>Xn(([e,...t])=>t),onReject:Co,toolUseConfirm:Yn[0],toolUseContext:ko(G,G,cn??Lc(),Se),verbose:R,setStickyFooter:pl()?Qn:void 0},Yn[0]?.toolUseID):null,oc=pl()&&Gn?.isLocalJSXCommand===!0,lc=oc?Gn.jsx:null,uc=(0,$.jsxs)(Mr,{children:[(0,$.jsx)(vN,{isAnimating:mr,title:dr,disabled:N,noPrefix:!1}),(0,$.jsx)(LO,{...Ks}),(0,$.jsx)(zO,{onSubmit:Io,isActive:!Gn?.isLocalJSXCommand}),(0,$.jsx)(mM,{scrollRef:vn,isActive:pl()&&(lc!=null||!ho||ho===`tool-permission`),onScroll:Wr}),null,(0,$.jsx)(VO,{...wo}),(0,$.jsx)(pg,{dynamicMcpConfig:ke,isStrictMcpConfig:m,children:(0,$.jsx)(iv,{scrollRef:vn,overlay:ac,modal:lc,modalScrollRef:yn,dividerYRef:wr,hidePill:!!Xs,newMessageCount:Ir?.count??0,onPillClick:()=>{Nr(null),kr(vn.current)},scrollable:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ov,{messages:rc,tools:Kt,commands:Yt,verbose:R,toolJSX:Gn,toolUseConfirmQueue:Yn,inProgressToolUseIDs:ui,isMessageSelectorVisible:Ki,conversationId:Qi,screen:Pe,streamingToolUses:$t,showAllInTranscript:Re,agentDefinitions:ae,onOpenRateLimitOptions:Ho,isLoading:W,streamingText:W&&!Xs?Fi:null,isBriefOnly:!Xs&&De,unseenDivider:Xs?void 0:Ir,scrollRef:pl()?vn:void 0,trackStickyPrompt:pl()?!0:void 0,cursor:jr,setCursor:Nr,cursorNavRef:Pr}),(0,$.jsx)(tj,{}),!x&&ic&&!lc&&(0,$.jsx)(ir,{param:{text:ic,type:`text`},addMargin:!0,verbose:R}),Gn&&!(Gn.isLocalJSXCommand&&Gn.isImmediate)&&!oc&&(0,$.jsx)(b,{flexDirection:`column`,width:`100%`,children:Gn.jsx}),process.env.USER_TYPE===`ant`&&(0,$.jsx)(wj,{}),(0,$.jsx)(b,{flexGrow:1}),Ia&&(0,$.jsx)(Vs,{mode:Xt,spinnerTip:ue,responseLengthRef:Ei,apiMetricsRef:Oi,overrideMessage:Ri,spinnerSuffix:ms,verbose:R,loadingStartTimeRef:jn,totalPausedMsRef:Mn,pauseStartTimeRef:Nn,overrideColor:Vi,overrideShimmerColor:Wi,hasActiveTools:ui.size>0,leaderIsIdle:!W}),!Ia&&!W&&!Dn&&De&&!Xs&&(0,$.jsx)(aa,{})]}),bottom:(0,$.jsx)(b,{flexDirection:`row`,width:`100%`,alignItems:`flex-end`,children:(0,$.jsxs)(b,{flexDirection:`column`,flexGrow:1,children:[pl()&&(0,$.jsx)(TD,{}),Zn,Gn?.isLocalJSXCommand&&Gn.isImmediate&&!oc&&(0,$.jsx)(b,{flexDirection:`column`,width:`100%`,children:Gn.jsx}),!Ia&&!Gn?.isLocalJSXCommand&&pe&&Ht&&Ht.length>0&&(0,$.jsx)(b,{width:`100%`,flexDirection:`column`,children:(0,$.jsx)(sc,{tasks:Ht,isStandalone:!0})}),ho===`sandbox-permission`&&(0,$.jsx)(hA,{hostPattern:$n[0].hostPattern,onUserResponse:e=>{let{allow:t,persistToSettings:n}=e,r=$n[0];if(!r)return;let i=r.hostPattern.host;er(e=>(e.filter(e=>e.hostPattern.host===i).forEach(e=>e.resolvePromise(t)),e.filter(e=>e.hostPattern.host!==i)));let a=rr.current.get(i);if(a){for(let e of a)e();rr.current.delete(i)}}},$n[0].hostPattern.host),ho===`prompt`&&(0,$.jsx)(pC,{title:tr[0].title,toolInputSummary:tr[0].toolInputSummary,request:tr[0].request,onRespond:e=>{let t=tr[0];t&&(t.resolve({prompt_response:t.request.prompt,selected:e}),nr(([,...e])=>e))},onAbort:()=>{let e=tr[0];e&&(e.reject(Error(`Prompt cancelled by user`)),nr(([,...e])=>e))}},tr[0].request.prompt),ho===`elicitation`&&(0,$.jsx)(uC,{event:H.queue[0],onResponse:(e,t)=>{let n=H.queue[0];n&&(n.respond({action:e,content:t}),n.params.mode===`url`&&e===`accept`||U(e=>({...e,elicitation:{queue:e.elicitation.queue.slice(1)}})))},onWaitingDismiss:e=>{let t=H.queue[0];U(e=>({...e,elicitation:{queue:e.elicitation.queue.slice(1)}})),t?.onWaitingDismiss?.(e)}},H.queue[0].serverName+`:`+String(H.queue[0].requestId)),ho===`cost`&&(0,$.jsx)(ey,{onDone:()=>{Zi(!1),la(!0),zf(e=>({...e,hasAcknowledgedCostThreshold:!0})),Z(`tengu_cost_threshold_acknowledged`,{})}}),ho===`idle-return`&&ta&&(0,$.jsx)(ty,{idleMinutes:ta.idleMinutes,totalInputTokens:ot(),onDone:async e=>{let t=ta;if(na(null),Z(`tengu_idle_return_action`,{action:e,idleMinutes:Math.round(t.idleMinutes),messageCount:br.current.length,totalInputTokens:ot()}),e===`dismiss`){ni(t.input);return}if(e===`never`&&zf(e=>e.idleReturnDismissed?e:{...e,idleReturnDismissed:!0}),e===`clear`){let{clearConversation:e}=await import(`./conversation-DLLIOKYV.js`);await e({setMessages:K,readFileState:Ja.current,discoveredSkillNames:Za.current,loadedNestedMemoryPaths:Qa.current,getAppState:()=>be.getState(),setAppState:U,setConversationId:$i}),cr.current=!1,sr(void 0),Ya.current.clear(),Xa.current=0}ia.current=!0,Vo.current(t.input,{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}})}}),ho===`ide-onboarding`&&(0,$.jsx)(ua,{onDone:()=>wt(!1),installationStatus:bt}),process.env.USER_TYPE===`ant`&&ho===`model-switch`&&sN&&(0,$.jsx)(sN,{onDone:(e,t)=>{Et(!1),e===`switch`&&t&&U(e=>({...e,mainLoopModel:t,mainLoopModelForSession:null}))}}),process.env.USER_TYPE===`ant`&&ho===`undercover-callout`&&lN&&(0,$.jsx)(lN,{onDone:()=>Wn(!1)}),ho===`effort-callout`&&(0,$.jsx)(Tk,{model:Se,onDone:e=>{jt(!1),e!==`dismiss`&&U(t=>({...t,effortValue:e}))}}),ho===`remote-callout`&&(0,$.jsx)(o_,{onDone:e=>{U(t=>t.showRemoteCallout?{...t,showRemoteCallout:!1,...e===`enable`&&{replBridgeEnabled:!0,replBridgeExplicit:!0,replBridgeOutboundOnly:!1}}:t)}}),co,ho===`plugin-hint`&&Rt&&(0,$.jsx)(UA,{pluginName:Rt.pluginName,pluginDescription:Rt.pluginDescription,marketplaceName:Rt.marketplaceName,sourceCommand:Rt.sourceCommand,onResponse:zt}),ho===`search-extra-tools-hint`&&Bt.visible&&(0,$.jsx)(GA,{tools:Bt.tools,onSelect:Bt.handleSelect,onDismiss:Bt.handleDismiss}),ho===`lsp-recommendation`&&Ft&&(0,$.jsx)(BA,{pluginName:Ft.pluginName,pluginDescription:Ft.pluginDescription,fileExtension:Ft.fileExtension,onResponse:Lt}),ho===`desktop-upsell`&&(0,$.jsx)(bv,{onDone:()=>Pt(!1)}),ho===`ultraplan-choice`&&me&&(0,$.jsx)(Rj,{plan:me.plan,sessionId:me.sessionId,taskId:me.taskId,setMessages:K,readFileState:Ja.current,getAppState:()=>be.getState(),setConversationId:$i}),ho===`ultraplan-launch`&&he&&(0,$.jsx)(Vj,{onChoice:(e,t)=>{let n=he.blurb;if(U(e=>e.ultraplanLaunchPending?{...e,ultraplanLaunchPending:void 0}:e),e===`cancel`)return;K(e=>[...e,Sc(bn(`ultraplan`,n))]);let r=e=>K(t=>[...t,Sc(`<local-command-stdout>${Pl(e)}</local-command-stdout>`)]);_u({blurb:n,promptIdentifier:t?.promptIdentifier,getAppState:()=>be.getState(),setAppState:U,signal:Lc().signal,disconnectedBridge:t?.disconnectedBridge,onSessionReady:e=>{if(!Sn.isActive){r(e);return}let t=Sn.subscribe(()=>{Sn.isActive||(t(),be.getState().ultraplanSessionUrl&&r(e))})}}).then(r).catch(X)}}),Fa(),!Gn?.shouldHidePromptInput&&!ho&&!uo&&!x&&!jr&&(0,$.jsxs)($.Fragment,{children:[ro&&(0,$.jsx)(bj,{onRun:Lo,onCancel:Ro,reason:Cj(ro)}),Ua.state===`closed`?Wa.state===`closed`?(0,$.jsx)(Yk,{state:Va.state,lastResponse:Va.lastResponse,handleSelect:Va.handleSelect,handleTranscriptSelect:Va.handleTranscriptSelect,inputValue:Zr,setInputValue:ni,onRequestFeedback:so.current?void 0:zo}):(0,$.jsx)(Yk,{state:Wa.state,lastResponse:Wa.lastResponse,handleSelect:Wa.handleSelect,handleTranscriptSelect:Wa.handleTranscriptSelect,inputValue:Zr,setInputValue:ni,onRequestFeedback:zo,message:`How well did Claude use its memory? (optional)`}):(0,$.jsx)(Yk,{state:Ua.state,lastResponse:Ua.lastResponse,handleSelect:Ua.handleSelect,inputValue:Zr,setInputValue:ni,onRequestFeedback:zo}),Ga.state!==`closed`&&(0,$.jsx)(Yk,{state:Ga.state,lastResponse:null,handleSelect:()=>{},handleTranscriptSelect:Ga.handleTranscriptSelect,inputValue:Zr,setInputValue:ni}),za.suggestion&&(0,$.jsx)(DO,{isOpen:za.isOpen,skillName:za.suggestion.skillName,updates:za.suggestion.updates,handleSelect:za.handleSelect,inputValue:Zr,setInputValue:ni}),Ba&&(0,$.jsx)(Tj,{}),(0,$.jsx)(WD,{debug:n,ideSelection:ft,hasSuppressedDialogs:!!go,isLocalJSXCommandActive:pr,getToolUseContext:ko,toolPermissionContext:L,setToolPermissionContext:Do,apiKeyStatus:to,commands:Yt,agents:ae.activeAgents,isLoading:W,onExit:Uo,verbose:R,messages:G,onAutoUpdaterResult:Hn,autoUpdaterResult:Vn,input:Zr,onInputChange:ni,mode:ri,onModeChange:ai,stashedPrompt:oi,setStashedPrompt:si,submitCount:Ci,onShowMessageSelector:Go,onMessageActionsEnter:void 0,mcpClients:dt,pastedContents:yi,setPastedContents:Si,vimMode:fa,setVimMode:pa,showBashesDialog:ma,setShowBashesDialog:ha,onSubmit:Io,isSearchingHistory:ga,setIsSearchingHistory:_a,helpOpen:va,setHelpOpen:ba,insertTextRef:ei}),(0,$.jsx)(Sk,{onBackgroundSession:Ao,isLoading:W}),(0,$.jsx)(gk,{})]}),jr&&(0,$.jsx)(Od,{cursor:jr}),ho===`message-selector`&&(0,$.jsx)(Tg,{messages:G,preselectedMessage:Ji,onPreRestore:So,onRestoreCode:async e=>{await xo(e=>{U(t=>({...t,fileHistory:e(t.fileHistory)}))},e.uuid)},onSummarize:async(e,t,n=`from`)=>{let r=At(G),i=r.indexOf(e);if(i===-1){K(e=>[...e,Ed(`That message is no longer in the active context (snipped or pre-compact). Choose a more recent message.`,`warning`)]);return}let a=Lc(),o=ko(r,[],a,Se),s=o.getAppState(),c=await dl(o.options.tools,o.options.mainLoopModel,Array.from(s.toolPermissionContext.additionalWorkingDirectories.keys()),o.options.mcpClients),l=_o({mainThreadAgentDefinition:void 0,toolUseContext:o,customSystemPrompt:o.options.customSystemPrompt,defaultSystemPrompt:c,appendSystemPrompt:o.options.appendSystemPrompt}),[u,d]=await Promise.all([Fr(),Rn()]),f=await tn(r,i,o,{systemPrompt:l,userContext:u,systemContext:d,toolUseContext:o,forkContextMessages:r},t,n),p=f.messagesToKeep??[],m=n===`up_to`?[...f.summaryMessages,...p]:[...p,...f.summaryMessages],h=[f.boundaryMarker,...m,...f.attachments,...f.hookResults];if(pl()&&n===`from`?K(t=>{let n=t.findIndex(t=>t.uuid===e.uuid);return[...t.slice(0,n===-1?0:n),...h]}):K(h),QM?.setContextBlocked(!1),$i(Bv()),Yo(o.options.querySource),n===`from`){let t=ea(e);t&&(ni(t.text),ai(t.mode))}let g=Hr(`app:toggleTranscript`,`Global`,`ctrl+o`);Ze({key:`summarize-ctrl-o-hint`,text:`Conversation summarized (${g} for history)`,priority:`medium`,timeoutMs:8e3})},onRestoreMessage:Jo,onClose:()=>{qi(!1),Yi(void 0)}}),process.env.USER_TYPE===`ant`&&(0,$.jsx)(Pj,{})]})})})},ds)]});return pl()?(0,$.jsx)(_e,{mouseTracking:ad(),children:uc}):uc}export{xN as t};
|