@readmagic/workmate 0.0.3 → 0.0.5
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-mANiG0xj.js → AddWorkspaceDirectory-DJRkEz7o.js} +1 -1
- package/dist/chunks/{App-aUVaOLeo.js → App-iJu5qyiF.js} +1 -1
- package/dist/chunks/ApproveApiKey-CKfn7U1R.js +1 -0
- package/dist/chunks/{ApproveApiKey-36iUE5CW.js → ApproveApiKey-CRejTHUw.js} +1 -1
- package/dist/chunks/{AssistantSessionChooser-BLcvdkgb.js → AssistantSessionChooser-CBLQ1v-J.js} +1 -1
- package/dist/chunks/BackgroundTasksDialog-CyoLEYWH.js +2 -0
- package/dist/chunks/{BypassPermissionsModeDialog-CTlpvTuz.js → BypassPermissionsModeDialog-D1FCKVOi.js} +1 -1
- package/dist/chunks/{ClaudeMdExternalIncludesDialog-5pipE8m8.js → ClaudeMdExternalIncludesDialog-CI0yF6sZ.js} +1 -1
- package/dist/chunks/ClaudeMdExternalIncludesDialog-TypH-X8e.js +1 -0
- package/dist/chunks/ConsoleOAuthFlow-wGQuFt41.js +1 -0
- package/dist/chunks/{DesktopHandoff-Blg1TVut.js → DesktopHandoff-D1rrMxeP.js} +1 -1
- package/dist/chunks/{DiffDialog-CUEpuocY.js → DiffDialog-BKcfKx7O.js} +2 -2
- package/dist/chunks/Doctor-CcJUwSQn.js +1 -0
- package/dist/chunks/Doctor-Yco1McrL.js +3 -0
- package/dist/chunks/ExitFlow-D3csukbB.js +2 -0
- package/dist/chunks/{Feedback-CDTqPqsM.js → Feedback-bEUtrHia.js} +2 -2
- package/dist/chunks/Grove-DPkIjqg8.js +1 -0
- package/dist/chunks/{Grove-D9lSG_Lh.js → Grove-Dsd7F39b.js} +1 -1
- package/dist/chunks/{HybridTransport-8j0AviF6.js → HybridTransport-9fTBC2Pv.js} +1 -1
- package/dist/chunks/{InvalidConfigDialog-I3t-0nU3.js → InvalidConfigDialog-9M-1nfZ6.js} +1 -1
- package/dist/chunks/{InvalidSettingsDialog-BnthOxGT.js → InvalidSettingsDialog-B2F6pryH.js} +1 -1
- package/dist/chunks/MCPConnectionManager-MWpKjeZT.js +1 -0
- package/dist/chunks/{McpParsingWarnings-D0XvLirX.js → McpParsingWarnings-BPBb7Npe.js} +1 -1
- package/dist/chunks/MessageSelector-DsQmqFt2.js +3 -0
- package/dist/chunks/Messages-B3sGRx5A.js +11 -0
- package/dist/chunks/{Onboarding-B1WRpoBI.js → Onboarding-cHcnsBGp.js} +1 -1
- package/dist/chunks/{OverageCreditUpsell-BSmgq089.js → OverageCreditUpsell-CWCD_RpM.js} +1 -1
- package/dist/chunks/PluginSettings-B0jbwB2M.js +17 -0
- package/dist/chunks/{PromptInputFooterSuggestions-3rjz6zhK.js → PromptInputFooterSuggestions-D5sAO6y-.js} +1 -1
- package/dist/chunks/{PromptInputHelpMenu-DgDJHZqC.js → PromptInputHelpMenu-n6hAdsto.js} +1 -1
- package/dist/chunks/QueryEngine-cwdsr4dr.js +1 -0
- package/dist/chunks/REPL-CJzScgbZ.js +142 -0
- package/dist/chunks/REPL-DlBJIPCw.js +1 -0
- package/dist/chunks/{RemoteCallout-BFzCx_Pn.js → RemoteCallout-CiA4rCEs.js} +1 -1
- package/dist/chunks/RemoteSessionManager-zdHfmvfj.js +2 -0
- package/dist/chunks/ResumeConversation-Rxwd6HAJ.js +1 -0
- package/dist/chunks/{SSETransport-DGIytG74.js → SSETransport-BPbhCa2f.js} +3 -3
- package/dist/chunks/SearchExtraToolsTool-VP87ErGx.js +1 -0
- package/dist/chunks/Settings-CxI_KHUj.js +2 -0
- package/dist/chunks/{TeleportProgress-Bens06DU.js → TeleportProgress-DrulEQ7z.js} +1 -1
- package/dist/chunks/{TeleportRepoMismatchDialog-BtLBCZUe.js → TeleportRepoMismatchDialog-D3FOLr0P.js} +1 -1
- package/dist/chunks/{TeleportResumeWrapper-t50LfWyN.js → TeleportResumeWrapper-DI5iRFND.js} +1 -1
- package/dist/chunks/{ThemePicker-BTfuZZ7E.js → ThemePicker-CQ7dfFtv.js} +1 -1
- package/dist/chunks/{TrustDialog-CgE_pYUK.js → TrustDialog-CnVKrdxQ.js} +1 -1
- package/dist/chunks/{ValidationErrorsList-Bl68E-2-.js → ValidationErrorsList-CPYeuppg.js} +1 -1
- package/dist/chunks/{WelcomeV2-C93xQYAF.js → WelcomeV2-C-UXdIng.js} +1 -1
- package/dist/chunks/{add-dir-C3IhJYVH.js → add-dir-xTz4COgn.js} +1 -1
- package/dist/chunks/{agentDisplay-Cju-aXCx.js → agentDisplay-BuSReYxu.js} +1 -1
- package/dist/chunks/{agents-Du3FQ82k.js → agents-CiLlKN2I.js} +1 -1
- package/dist/chunks/agents-Du9KYHqN.js +103 -0
- package/dist/chunks/allErrors-P3utlEeA.js +1 -0
- package/dist/chunks/{ant-CVvy4SuO.js → ant-CBIfqmAb.js} +1 -1
- package/dist/chunks/api-B-5jqiMg.js +1 -0
- package/dist/chunks/api-BiwZmmsh.js +1 -0
- package/dist/chunks/{assistant-C_SkUDk_.js → assistant-XOnU01yl.js} +1 -1
- package/dist/chunks/auth-BQa4kzQo.js +1 -0
- package/dist/chunks/auth-DT2yxy94.js +15 -0
- package/dist/chunks/auth-UAJhZNmZ.js +1 -0
- package/dist/chunks/{autoMode-CZyb-mMY.js → autoMode-CEMflt3g.js} +1 -1
- package/dist/chunks/{autonomy-DJZ25xZp.js → autonomy-Cg5zweUa.js} +7 -7
- package/dist/chunks/{autonomy-BpINX4jw.js → autonomy-_N8aDaA8.js} +1 -1
- package/dist/chunks/{autonomyPanel-ssoiIOx5.js → autonomyPanel-I4yCy3Fr.js} +1 -1
- package/dist/chunks/backgroundHousekeeping-BUUZ7Csq.js +1 -0
- package/dist/chunks/backgroundHousekeeping-DhF2lrQ9.js +17 -0
- package/dist/chunks/{branch-BXo5z2al.js → branch-BIX-pyHp.js} +1 -1
- package/dist/chunks/{bridge-CbKc1HeD.js → bridge-CYskzVt8.js} +2 -2
- package/dist/chunks/{bridgeConfig-DbqUHe0H.js → bridgeConfig-5p_w4s5r.js} +1 -1
- package/dist/chunks/bridgeConfig-DWEqKbXk.js +1 -0
- package/dist/chunks/bridgeEnabled-CjVCMwnq.js +1 -0
- package/dist/chunks/bridgeEnabled-DhFrLTbG.js +1 -0
- package/dist/chunks/bridgeMain-6lollTtZ.js +1 -0
- package/dist/chunks/bridgeMain-BX2AkLPs.js +68 -0
- package/dist/chunks/{bridgeMessaging-lfa_v3oi.js → bridgeMessaging-B5Lbzr8e.js} +1 -1
- package/dist/chunks/{btw-Cp0whJaJ.js → btw-CWWFO7u8.js} +1 -1
- package/dist/chunks/caches-C46fa77L.js +1 -0
- package/dist/chunks/{caches-CmW7idg5.js → caches-DPqPIogk.js} +2 -2
- package/dist/chunks/{ccrClient-BPXmxWHw.js → ccrClient-CTLnU9Y1.js} +1 -1
- package/dist/chunks/{clear-DjGPxX7T.js → clear-DCAgZwc4.js} +1 -1
- package/dist/chunks/client-Bup0Sgcn.js +1 -0
- package/dist/chunks/{color-DYYBN52b.js → color-CmJGInHL.js} +1 -1
- package/dist/chunks/commands-BdB1eFvP.js +1 -0
- package/dist/chunks/{commitAttribution-Bmzgtqc6.js → commitAttribution-CGZr7XNO.js} +2 -2
- package/dist/chunks/commitAttribution-D6J3NuhB.js +1 -0
- package/dist/chunks/compact-C6-lMHgn.js +2 -0
- package/dist/chunks/{config-DiT2Z8dY.js → config-3m_9zSrj.js} +1 -1
- package/dist/chunks/config-Bxt1UH1T.js +1 -0
- package/dist/chunks/config-CjjXZfNi.js +1 -0
- package/dist/chunks/{context-Bh_iUj76.js → context-C9V4GF0n.js} +1 -1
- package/dist/chunks/{context-noninteractive-Cb3EM2Oz.js → context-noninteractive-BmC4o5xo.js} +2 -2
- package/dist/chunks/context-noninteractive-DvGo1l7b.js +1 -0
- package/dist/chunks/conversation-CH9ouFai.js +1 -0
- package/dist/chunks/conversation-CYqqk0o7.js +1 -0
- package/dist/chunks/{createSSHSession-B0s839mX.js → createSSHSession-BL6j0AU5.js} +1 -1
- package/dist/chunks/createSession-DUfOAeyE.js +1 -0
- package/dist/chunks/{createSession-VMTMXOHu.js → createSession-D_sgO1Xy.js} +1 -1
- package/dist/chunks/crossProjectResume-D5hTOfnE.js +40 -0
- package/dist/chunks/{datadog-D9rlcN12.js → datadog-UkGdjL8-.js} +1 -1
- package/dist/chunks/{desktop-DidI-4N5.js → desktop-HbYKh-VK.js} +1 -1
- package/dist/chunks/{diff-CZg5qL2n.js → diff-nTV17iWX.js} +1 -1
- package/dist/chunks/doctor-7fgVhEKL.js +1 -0
- package/dist/chunks/{entry-dA1UCfC0.js → entry-CCFI6-gM.js} +3 -3
- package/dist/chunks/envLessBridgeConfig-B2HYnEKo.js +1 -0
- package/dist/chunks/{envLessBridgeConfig-BFjJ8Kt4.js → envLessBridgeConfig-DXd10GXD.js} +1 -1
- package/dist/chunks/{esm-DjGYYlQe.js → esm-CGoYrggU.js} +1 -1
- package/dist/chunks/exit-ropaQiOr.js +1 -0
- package/dist/chunks/extra-usage-CLhv1Z4g.js +1 -0
- package/dist/chunks/{extra-usage-core-RZMzaH0L.js → extra-usage-core-DLYHAInT.js} +1 -1
- package/dist/chunks/{extra-usage-BTv_OwGN.js → extra-usage-g2Pw4zt_.js} +1 -1
- package/dist/chunks/{extra-usage-noninteractive-BB-BQ3kh.js → extra-usage-noninteractive-D8iszH3c.js} +1 -1
- package/dist/chunks/extraUsage-C2Ylufhj.js +1 -0
- package/dist/chunks/extractMemories-B2IAvbXM.js +1 -0
- package/dist/chunks/{fast-CNXgsvnE.js → fast-Dx2fTmWr.js} +1 -1
- package/dist/chunks/fast-_G6zcFye.js +1 -0
- package/dist/chunks/{feedback-DeJ2gvw2.js → feedback-DCQ4pJ3v.js} +1 -1
- package/dist/chunks/{firstPartyEventLogger-CQdJn3LV.js → firstPartyEventLogger-BNGPPBNP.js} +2 -2
- package/dist/chunks/firstPartyEventLogger-C9LzVy6y.js +1 -0
- package/dist/chunks/{flushGate-CJ73xcaK.js → flushGate-XaheIZZT.js} +1 -1
- package/dist/chunks/{gemini-Cn9bMXwP.js → gemini-BCCLHK3K.js} +1 -1
- package/dist/chunks/{generateRecap-BO9kzRon.js → generateRecap-BhvbixY2.js} +1 -1
- package/dist/chunks/{generateSessionName-CGpL6ATy.js → generateSessionName-CN1oh7Fa.js} +1 -1
- package/dist/chunks/{githubRepoPathMapping-C4umZ1oC.js → githubRepoPathMapping-B4AM8luI.js} +1 -1
- package/dist/chunks/{goal-C8Qzl7_i.js → goal-Bp6fyGqo.js} +3 -3
- package/dist/chunks/{grok-CDT9P_BL.js → grok-ax26ju8y.js} +1 -1
- package/dist/chunks/{grove-BGXzEyH9.js → grove-DrBVaZSN.js} +2 -2
- package/dist/chunks/{heapdump-CFHvdSZv.js → heapdump-JseysNDr.js} +1 -1
- package/dist/chunks/{help-DUZ7Y7Em.js → help-DR9hKneR.js} +1 -1
- package/dist/chunks/hooks-BUJLxdFJ.js +1 -0
- package/dist/chunks/{hooks-RHwUCXcT.js → hooks-C5n23H1E.js} +2 -2
- package/dist/chunks/inboundAttachments-C0nMTtCi.js +1 -0
- package/dist/chunks/{inboundAttachments-Cfl4_n0S.js → inboundAttachments-Cp8XvLMZ.js} +1 -1
- package/dist/chunks/initReplBridge-DJs28ZkI.js +1 -0
- package/dist/chunks/{install-OkuNmjmB.js → install-C7qTB0V5.js} +1 -1
- package/dist/chunks/{instrumentation-hrXeo-G4.js → instrumentation-CLZttr_u.js} +4 -4
- package/dist/chunks/{job-DjmIpwJl.js → job-BhiazwPH.js} +1 -1
- package/dist/chunks/keybindings-CkL8BzUt.js +2 -0
- package/dist/chunks/{language-BA5WprZv.js → language-DIw2871r.js} +1 -1
- package/dist/chunks/language-DfOAuDFc.js +1 -0
- package/dist/chunks/launchAgentsPlatform-j-mWpwW1.js +1 -0
- package/dist/chunks/{launchLocalMemory-CgXtGng1.js → launchLocalMemory-DmoXp0Xo.js} +2 -2
- package/dist/chunks/{launchLocalVault-Bs6Km3Ua.js → launchLocalVault-1uKe0HjA.js} +3 -3
- package/dist/chunks/launchMemoryStores-SxDKjHJ3.js +1 -0
- package/dist/chunks/{launchOnboarding-Cn0t_o2k.js → launchOnboarding-CTtpnXcs.js} +1 -1
- package/dist/chunks/launchSchedule-BDVnGhaL.js +1 -0
- package/dist/chunks/launchSkillStore-SmMLxp4K.js +1 -0
- package/dist/chunks/{launchTeleport-Ba_Hj13c.js → launchTeleport-B472ZSGz.js} +3 -3
- package/dist/chunks/launchVault-CsyBgxle.js +1 -0
- package/dist/chunks/{loadAgentsDir-DrDu5yYy.js → loadAgentsDir-Clu7Uk6a.js} +629 -629
- package/dist/chunks/loadAgentsDir-DTbJJff-.js +1 -0
- package/dist/chunks/loadPluginHooks-Cvd5VdjQ.js +1 -0
- package/dist/chunks/localSearch-DKv8PRLD.js +1 -0
- package/dist/chunks/{localSearch-_bQhk9W6.js → localSearch-iA6JTk19.js} +1 -1
- package/dist/chunks/{logoV2Utils-CoC4nheD.js → logoV2Utils-YHBJLIrC.js} +1 -1
- package/dist/chunks/{magicDocs-kMjYpjCA.js → magicDocs-Bf1fqnHN.js} +3 -3
- package/dist/chunks/{main-C_rVSWfm.js → main-gtV_TqXP.js} +84 -84
- package/dist/chunks/{mappers-D0CNXG32.js → mappers-C8lYERPX.js} +1 -1
- package/dist/chunks/{mcp-DtxIl6aN.js → mcp-CNuhEGP6.js} +4 -4
- package/dist/chunks/mcp-Ci0OPVrR.js +1 -0
- package/dist/chunks/mcp-CwIYauZl.js +2 -0
- package/dist/chunks/memory-DCGqfQ1U.js +1 -0
- package/dist/chunks/{mode-B4WIxCMW.js → mode-DO6g7nkX.js} +2 -2
- package/dist/chunks/model-BQF64tZx.js +1 -0
- package/dist/chunks/model-DLXL0CNu.js +1 -0
- package/dist/chunks/model-DvrvG6BB.js +1 -0
- package/dist/chunks/{nativeInstaller-DktvrWRd.js → nativeInstaller-OPuO2sm_.js} +1 -1
- package/dist/chunks/{onChangeAppState-CGVeNkt7.js → onChangeAppState-CHhRDkM7.js} +1 -1
- package/dist/chunks/openai-HOebt-8k.js +10 -0
- package/dist/chunks/{overageCreditGrant-BVxlYgeU.js → overageCreditGrant-Bi1CTBAx.js} +1 -1
- package/dist/chunks/{panelCall-Cp6fpQeL.js → panelCall-D0eURklm.js} +1 -1
- package/dist/chunks/{partition-RjCtgt9J.js → partition-C8RSL3SQ.js} +1 -1
- package/dist/chunks/{passes-ByTLy6pj.js → passes-BJci5SM_.js} +1 -1
- package/dist/chunks/permissions-JU9CGHgI.js +3 -0
- package/dist/chunks/{pidLock-CdNZ0Wfg.js → pidLock-Bd2e6xuT.js} +2 -2
- package/dist/chunks/{plan-BxTA-b4l.js → plan-D4gMsK7i.js} +1 -1
- package/dist/chunks/{plugin-DOpl5e1t.js → plugin-CwCo5Kik.js} +1 -1
- package/dist/chunks/{pluginAutoupdate-L09CQ-ph.js → pluginAutoupdate-CO-n9bqe.js} +1 -1
- package/dist/chunks/{pluginBlocklist-B32eWmzn.js → pluginBlocklist-5qbaTRbV.js} +1 -1
- package/dist/chunks/pluginCliCommands-I-lsw_us.js +1 -0
- package/dist/chunks/{pluginFlagging-3FQGvIfq.js → pluginFlagging-DNPBbJZo.js} +1 -1
- package/dist/chunks/{pluginOperations-ClzXYNQe.js → pluginOperations-Cz6eQ0Vu.js} +2 -2
- package/dist/chunks/pluginStartupCheck-CoW7073W.js +1 -0
- package/dist/chunks/{pluginStartupCheck-BNd2QNzZ.js → pluginStartupCheck-DJ9fslCK.js} +1 -1
- package/dist/chunks/plugins-CzJIuPfb.js +4 -0
- package/dist/chunks/policyLimits-BkjgMQD0.js +1 -0
- package/dist/chunks/{poor-DekfGNT7.js → poor-Dha9p9RF.js} +1 -1
- package/dist/chunks/{poorMode-CtcqaiwD.js → poorMode-1NLYiS3Y.js} +1 -1
- package/dist/chunks/poorMode-qlxqU8Hm.js +1 -0
- package/dist/chunks/print-BL4EUT5Z.js +23 -0
- package/dist/chunks/{privacy-settings-ChNsgGUs.js → privacy-settings-6ZWxR4Qt.js} +1 -1
- package/dist/chunks/processBashCommand-BZs9wggV.js +1 -0
- package/dist/chunks/processSlashCommand-D8lKLNzM.js +5 -0
- package/dist/chunks/{prompt-C0nU0VK3.js → prompt-Bg_1U0gO.js} +1 -1
- package/dist/chunks/prompt-CN7gBNKS.js +1 -0
- package/dist/chunks/prompt-D-zHhqp8.js +1 -0
- package/dist/chunks/{promptEditor-Cumef6hJ.js → promptEditor-BhYDmwdS.js} +2 -2
- package/dist/chunks/{protocolHandler-z2zxAtB1.js → protocolHandler-Dnb7lITm.js} +1 -1
- package/dist/chunks/rate-limit-options-DVzT3eWH.js +1 -0
- package/dist/chunks/{rcDebugLog-2-1XSyFV.js → rcDebugLog-VKwMl0yg.js} +1 -1
- package/dist/chunks/reconciler-BdRXZTJf.js +4 -0
- package/dist/chunks/{referral-DrebVwqx.js → referral-BlrMpBAV.js} +1 -1
- package/dist/chunks/{refresh-pFezssA8.js → refresh-jwqnoK2h.js} +1 -1
- package/dist/chunks/{registerProtocol-CukLQuxJ.js → registerProtocol-CuKZAiCc.js} +1 -1
- package/dist/chunks/{release-notes-D7vrFNXp.js → release-notes-BgP8u7NE.js} +1 -1
- package/dist/chunks/{releaseNotes-CDx2P0fb.js → releaseNotes-CunqVlbU.js} +2 -2
- package/dist/chunks/{reload-plugins-CltHfg-l.js → reload-plugins-CD9TzvFm.js} +1 -1
- package/dist/chunks/{remote-env-SvvSuP0J.js → remote-env-QaP_W_sv.js} +1 -1
- package/dist/chunks/{remoteBridgeCore-BOeljn2c.js → remoteBridgeCore-9-HVMo63.js} +1 -1
- package/dist/chunks/{remoteManagedSettings-CaY_ZH8r.js → remoteManagedSettings-jZ6u8ZBT.js} +1 -1
- package/dist/chunks/{rename-CbqrCCBO.js → rename-29qxHf8W.js} +1 -1
- package/dist/chunks/{resume-DockJaY9.js → resume-D-SpOy_1.js} +2 -2
- package/dist/chunks/{runtimeObserver-DSUuYKfs.js → runtimeObserver-DOEcrylu.js} +1 -1
- package/dist/chunks/{runtimeObserver-XufSllVw.js → runtimeObserver-Dm3LIUMp.js} +3 -3
- package/dist/chunks/sandbox-adapter-LzTcKwBp.js +1 -0
- package/dist/chunks/{sandbox-toggle-CZI5fuK3.js → sandbox-toggle-B61AeBor.js} +1 -1
- package/dist/chunks/searchExtraTools-CbJJQqzH.js +1 -0
- package/dist/chunks/{session-B-Z3DU9o.js → session-RwJCIIcs.js} +2 -2
- package/dist/chunks/{sessionDiscovery-C3pMZkBM.js → sessionDiscovery-dkFeWcA3.js} +1 -1
- package/dist/chunks/sessionFileAccessHooks-B_nNW0zE.js +1 -0
- package/dist/chunks/sessionMemory-C4JAUZ6V.js +1 -0
- package/dist/chunks/sessionMemory-btARBn8H.js +1 -0
- package/dist/chunks/sessionMemoryUtils-BlqAy8oR.js +1 -0
- package/dist/chunks/{sessionObserver-B_09FQKV.js → sessionObserver-CSOYgsvH.js} +1 -1
- package/dist/chunks/sessionObserver-DMvWci8-.js +1 -0
- package/dist/chunks/sessionStorage-Diyuvt20.js +1 -0
- package/dist/chunks/{sessionTitle-CmLWNFuX.js → sessionTitle-CLOlPZ_M.js} +1 -1
- package/dist/chunks/{sessionTracing-lArOaj9u.js → sessionTracing-D8wr9j4X.js} +1 -1
- package/dist/chunks/{settings-DfWP5y6X.js → settings-Dlp5JTa_.js} +1 -1
- package/dist/chunks/settingsSync-QWA0VZSu.js +1 -0
- package/dist/chunks/setup-UI9uv2-K.js +3 -0
- package/dist/chunks/{shadowedRuleDetection-E2wF1UjU.js → shadowedRuleDetection-CXsmUY2o.js} +1 -1
- package/dist/chunks/{sideQuestion-BjHCLSR9.js → sideQuestion-CHpOVzY5.js} +1 -1
- package/dist/chunks/{sinks-Cb--pqr-.js → sinks-1hFrW9HK.js} +2 -2
- package/dist/chunks/sinks-CXq8-7Qn.js +1 -0
- package/dist/chunks/{skill-learning-B0dyBT1_.js → skill-learning-Ck17rwH8.js} +1 -1
- package/dist/chunks/skillChangeDetector-s0F9Yf9a.js +1 -0
- package/dist/chunks/{skillGapStore-D2fqmnKx.js → skillGapStore-BJ1h2LVr.js} +1 -1
- package/dist/chunks/{skillGapStore-75ZYlfwi.js → skillGapStore-DyqNKuNy.js} +2 -2
- package/dist/chunks/{skillGenerator-CwXUfM4Y.js → skillGenerator-BT8NGzXT.js} +2 -2
- package/dist/chunks/skillLearning-1ZfYIzfL.js +1 -0
- package/dist/chunks/{skillLearning-CB-5fdMl.js → skillLearning-Cn9Uw0Kd.js} +1 -1
- package/dist/chunks/{skillPanel-Bum7xpgo.js → skillPanel-N0GoWjIi.js} +3 -3
- package/dist/chunks/{skillSearchPanel-LSPwZIOw.js → skillSearchPanel-CTwtgTzy.js} +3 -3
- package/dist/chunks/{skills-G8WBeffd.js → skills-Bv3lH-aA.js} +1 -1
- package/dist/chunks/{stats-DmFubHpI.js → stats-C1Ff6w4i.js} +1 -1
- package/dist/chunks/{status-ClSsvm1N.js → status-DyXiBa0m.js} +2 -2
- package/dist/chunks/{status-i5beKggW.js → status-FD7HVYS7.js} +1 -1
- package/dist/chunks/{statusNoticeHelpers-BK-54uGY.js → statusNoticeHelpers-kTp9Rdk6.js} +1 -1
- package/dist/chunks/{tag-DYYq4H_i.js → tag-RzOSA5T0.js} +2 -2
- package/dist/chunks/{tasks-BySzm_YJ.js → tasks-eJrOcdhB.js} +1 -1
- package/dist/chunks/teleport-ABA-hdmP.js +1 -0
- package/dist/chunks/{templateJobs-CT5VxeRr.js → templateJobs-BnOBSFtq.js} +1 -1
- package/dist/chunks/{terminalSetup-RDKg8dVa.js → terminalSetup-BfvmoJaK.js} +1 -1
- package/dist/chunks/{terminalSetup-BNs9nLbT.js → terminalSetup-D_P5iZmq.js} +1 -1
- package/dist/chunks/{theme-CVTVsRwt.js → theme-S0kVMVt4.js} +1 -1
- package/dist/chunks/thinkback-C6gV2LpU.js +1 -0
- package/dist/chunks/thinkback-HyW_R_88.js +1 -0
- package/dist/chunks/{thinkback-play-BhfCaIye.js → thinkback-play-H6md4czq.js} +1 -1
- package/dist/chunks/{toolEventObserver--4fqXxQZ.js → toolEventObserver--Z6jENks.js} +1 -1
- package/dist/chunks/{toolEventObserver-DdhPsAs1.js → toolEventObserver-BAFzvePj.js} +1 -1
- package/dist/chunks/toolPool-CR61XXm3.js +1 -0
- package/dist/chunks/trustedDevice-DUrFWupL.js +1 -0
- package/dist/chunks/{trustedDevice-DvpN4J1F.js → trustedDevice-Dn4rXbxT.js} +1 -1
- package/dist/chunks/types-Bh9S_JG5.js +3 -0
- package/dist/chunks/types-DHkZVzJe.js +1 -0
- package/dist/chunks/{ultrareviewCommand-i3PfFKly.js → ultrareviewCommand-mYDTBCFD.js} +2 -2
- package/dist/chunks/{undercover-Q24TWRw0.js → undercover-CdapzvNH.js} +1 -1
- package/dist/chunks/undercover-k3JoOKAb.js +1 -0
- package/dist/chunks/{updateCCB-CEXA6dax.js → updateCCB-DPShheOr.js} +1 -1
- package/dist/chunks/upgrade-BOeakAP6.js +1 -0
- package/dist/chunks/upgrade-D7iGU0PQ.js +1 -0
- package/dist/chunks/{upload-B-lNHpWe.js → upload-BXQsDtLW.js} +1 -1
- package/dist/chunks/usage-DbRdMJog.js +1 -0
- package/dist/chunks/usage-iNQzY960.js +1 -0
- package/dist/chunks/{useExitOnCtrlCDWithKeybindings-CzFtdlnD.js → useExitOnCtrlCDWithKeybindings-CntByfTQ.js} +1 -1
- package/dist/chunks/useMainLoopModel-DHkRIgNs.js +1 -0
- package/dist/chunks/useManagePlugins-B8HD0RUh.js +1 -0
- package/dist/chunks/{useMergedTools-DMGRA1ga.js → useMergedTools-DfchLQZC.js} +1 -1
- package/dist/chunks/{useSearchInput-D5VU9IDU.js → useSearchInput-H-8hJeFD.js} +1 -1
- package/dist/chunks/useSettingsErrors-BF5i5Xju.js +1 -0
- package/dist/chunks/{util-CNa1ib_4.js → util-CoicMvOv.js} +1 -1
- package/dist/chunks/validatePlugin-z2fcngf8.js +1 -0
- package/dist/chunks/{vim-C0KTnJJs.js → vim-DdvQlLDm.js} +1 -1
- package/dist/chunks/{workerRegistry-B2QD2sKq.js → workerRegistry-CzqQwCHC.js} +1 -1
- package/dist/chunks/worktree-DMhP5T0p.js +1 -0
- package/dist/cli.js +1 -1
- package/package.json +2 -6
- package/dist/chunks/ApproveApiKey-DPdcp1CQ.js +0 -1
- package/dist/chunks/BackgroundTasksDialog-DyjVt81B.js +0 -2
- package/dist/chunks/ClaudeMdExternalIncludesDialog-Dn7Le--z.js +0 -1
- package/dist/chunks/ConsoleOAuthFlow-BDr1Vx5K.js +0 -1
- package/dist/chunks/Doctor-B540I-gq.js +0 -1
- package/dist/chunks/Doctor-DlE1Mbb9.js +0 -3
- package/dist/chunks/ExitFlow-DCIhnP5h.js +0 -2
- package/dist/chunks/Grove-DLYXL8hv.js +0 -1
- package/dist/chunks/MCPConnectionManager-zdocEDgk.js +0 -1
- package/dist/chunks/MessageSelector-BBhCstBa.js +0 -3
- package/dist/chunks/Messages-Dv2VrytX.js +0 -11
- package/dist/chunks/PluginSettings-DN9rpwc_.js +0 -17
- package/dist/chunks/QueryEngine-BnaHDZVZ.js +0 -1
- package/dist/chunks/REPL-B3RbzeV7.js +0 -1
- package/dist/chunks/REPL-CA8FEO7J.js +0 -142
- package/dist/chunks/RemoteSessionManager-BhUrtejX.js +0 -2
- package/dist/chunks/ResumeConversation-BseKUFRI.js +0 -1
- package/dist/chunks/SearchExtraToolsTool-h6OunbMd.js +0 -1
- package/dist/chunks/Settings-BvhG1XoW.js +0 -2
- package/dist/chunks/agents-Bhg0CtXR.js +0 -103
- package/dist/chunks/allErrors-DJYCAtab.js +0 -1
- package/dist/chunks/api-CI8HXREw.js +0 -1
- package/dist/chunks/api-gJBnC8z3.js +0 -1
- package/dist/chunks/auth-B9V3i5oZ.js +0 -1
- package/dist/chunks/auth-CgEABs3i.js +0 -15
- package/dist/chunks/auth-fSFfSKy_.js +0 -1
- package/dist/chunks/backgroundHousekeeping-BHncba6e.js +0 -17
- package/dist/chunks/backgroundHousekeeping-QK8iEXoI.js +0 -1
- package/dist/chunks/bridgeConfig-CLHy-BiF.js +0 -1
- package/dist/chunks/bridgeEnabled-BWSUZ7Xg.js +0 -1
- package/dist/chunks/bridgeEnabled-CM3SaumJ.js +0 -1
- package/dist/chunks/bridgeMain-BESKzpm0.js +0 -1
- package/dist/chunks/bridgeMain-CzhBVCsN.js +0 -68
- package/dist/chunks/caches-CpqTC0Lb.js +0 -1
- package/dist/chunks/client-DPUvQ6Rf.js +0 -1
- package/dist/chunks/commands-D7l3P1k9.js +0 -1
- package/dist/chunks/commitAttribution-B7NUPJ8E.js +0 -1
- package/dist/chunks/compact-D6xqZN4Q.js +0 -2
- package/dist/chunks/config-huQaTcNb.js +0 -1
- package/dist/chunks/config-qLaiAn7z.js +0 -1
- package/dist/chunks/context-noninteractive-CNot6jbs.js +0 -1
- package/dist/chunks/conversation-CSpwF3Ha.js +0 -1
- package/dist/chunks/conversation-CvCQta8e.js +0 -1
- package/dist/chunks/createSession-GNSNbUbN.js +0 -1
- package/dist/chunks/crossProjectResume-DGpgCUfk.js +0 -40
- package/dist/chunks/doctor-CKUXGCri.js +0 -1
- package/dist/chunks/effort-BcvNemuq.js +0 -9
- package/dist/chunks/envLessBridgeConfig-bei51W3H.js +0 -1
- package/dist/chunks/exit-COMnVxzw.js +0 -1
- package/dist/chunks/extra-usage-By33zGLT.js +0 -1
- package/dist/chunks/extraUsage-CTn9FWSk.js +0 -1
- package/dist/chunks/extractMemories-CXGZGe0h.js +0 -1
- package/dist/chunks/fast-BXzdzzXU.js +0 -1
- package/dist/chunks/firstPartyEventLogger-CdLshdJY.js +0 -1
- package/dist/chunks/hooks-fZ1r0jUF.js +0 -1
- package/dist/chunks/inboundAttachments-YMxf4fmR.js +0 -1
- package/dist/chunks/initReplBridge-GH3-LHF4.js +0 -1
- package/dist/chunks/keybindings-B8U17bhs.js +0 -2
- package/dist/chunks/language-BbaOTWm3.js +0 -1
- package/dist/chunks/launchAgentsPlatform-DnxH2SAn.js +0 -1
- package/dist/chunks/launchMemoryStores-DxVAIJuB.js +0 -1
- package/dist/chunks/launchSchedule-Chwr3Nzd.js +0 -1
- package/dist/chunks/launchSkillStore-6zxJfWVU.js +0 -1
- package/dist/chunks/launchVault-hGVrHy33.js +0 -1
- package/dist/chunks/loadAgentsDir-BHOyHxwz.js +0 -1
- package/dist/chunks/loadPluginHooks-s7bvGtns.js +0 -1
- package/dist/chunks/localSearch-CebU5BA9.js +0 -1
- package/dist/chunks/mcp-1ZuFesM9.js +0 -2
- package/dist/chunks/mcp-CKvGBEjz.js +0 -1
- package/dist/chunks/memory-DE2jtkd_.js +0 -1
- package/dist/chunks/model-C4RHNhDQ.js +0 -1
- package/dist/chunks/model-fi472PRc.js +0 -1
- package/dist/chunks/model-j9GNZDFr.js +0 -1
- package/dist/chunks/openai-BSVjSJiF.js +0 -10
- package/dist/chunks/permissions-B3df_htx.js +0 -3
- package/dist/chunks/pluginCliCommands-CDMWnO3d.js +0 -1
- package/dist/chunks/pluginStartupCheck-RiZxW-WU.js +0 -1
- package/dist/chunks/plugins-CcDG95Bs.js +0 -4
- package/dist/chunks/policyLimits-Bwi9VqDF.js +0 -1
- package/dist/chunks/poorMode-AE4WNYZo.js +0 -1
- package/dist/chunks/print-Cc_QOSPF.js +0 -23
- package/dist/chunks/processBashCommand-Bx6_oZoE.js +0 -1
- package/dist/chunks/processSlashCommand-AltWgIFt.js +0 -5
- package/dist/chunks/prompt-CYx145pp.js +0 -1
- package/dist/chunks/prompt-DH3lKFag.js +0 -1
- package/dist/chunks/rate-limit-options-VL7S3SCx.js +0 -1
- package/dist/chunks/reconciler-DHRE_gV2.js +0 -4
- package/dist/chunks/sandbox-adapter-CEZnHq0U.js +0 -1
- package/dist/chunks/searchExtraTools-iQfI39wB.js +0 -1
- package/dist/chunks/sessionFileAccessHooks-DyrZmoA7.js +0 -1
- package/dist/chunks/sessionMemory-CqRpgwtU.js +0 -1
- package/dist/chunks/sessionMemory-D_HQmhj7.js +0 -1
- package/dist/chunks/sessionMemoryUtils-CZOIKrn0.js +0 -1
- package/dist/chunks/sessionObserver-B400YG3s.js +0 -1
- package/dist/chunks/sessionStorage-DRnvtrpU.js +0 -1
- package/dist/chunks/settingsSync-BlDk6rsM.js +0 -1
- package/dist/chunks/setup-DdbmxSZh.js +0 -3
- package/dist/chunks/sinks-DbwDBd-E.js +0 -1
- package/dist/chunks/skillChangeDetector-DQof8SUY.js +0 -1
- package/dist/chunks/skillLearning-CSY5R5Jn.js +0 -1
- package/dist/chunks/teleport-dxtBcM01.js +0 -1
- package/dist/chunks/thinkback-B-GpXG9U.js +0 -1
- package/dist/chunks/thinkback-CXsRbDYN.js +0 -1
- package/dist/chunks/toolPool-DvHECcbN.js +0 -1
- package/dist/chunks/trustedDevice-e6iF1X7C.js +0 -1
- package/dist/chunks/types-BUyOCzUt.js +0 -1
- package/dist/chunks/types-Czs-_G1S.js +0 -3
- package/dist/chunks/undercover-CPvoDtJ1.js +0 -1
- package/dist/chunks/upgrade-7OrBbrzS.js +0 -1
- package/dist/chunks/upgrade-uR7SIVtx.js +0 -1
- package/dist/chunks/usage-7jOeIVv9.js +0 -1
- package/dist/chunks/usage-CZdPfUqP.js +0 -1
- package/dist/chunks/useMainLoopModel-DegH12LZ.js +0 -1
- package/dist/chunks/useManagePlugins-BkK1zydO.js +0 -1
- package/dist/chunks/useSettingsErrors-B5PSF1va.js +0 -1
- package/dist/chunks/validatePlugin-Dw-RGCrm.js +0 -1
- package/dist/chunks/worktree-D38cJ23W.js +0 -1
|
@@ -0,0 +1,142 @@
|
|
|
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 ee,Wt as A,Xn as j,Xt as M,Y as te,Yt as N,Z as P,Zn as F,_n as ne,bn as re,ct as I,di as L,dr as ie,et as R,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{E as ye,M as be,S as xe,T as Se,a as Ce,d as we,n as Te,r as Ee,s as De,t as Oe,w as ke}from"./lazySchema-DcIJE_0i.js";import{At as Ae,B as je,Bt as Me,D as Ne,Dn as Pe,H as Fe,Hn as Ie,Ht as Le,Jn as Re,K as ze,Mt as Be,Nt as Ve,Pt as He,Rt as Ue,Sr as We,Tt as Ge,Un as Ke,Ut as qe,V as Je,Vt as Ye,Wt as Xe,Yn as Ze,Yt as Qe,Z as $e,Zt as et,_r as tt,b as nt,bn as rt,dn as it,en as at,fn as ot,ht as st,jt as ct,kt as lt,nt as ut,ot as dt,pn as ft,pt,tn as mt,un as ht,vr as gt,xr as _t,yr as vt,yt,z as bt,zt as xt}from"./state-ix0xIunV.js";import{$D as St,$d as Ct,$f as wt,$m as Tt,AC as Et,AS as Dt,AT as Ot,Af as kt,Ag as At,Ah as jt,Ao as Mt,Ap as Nt,As as Pt,Au as Ft,Ax as It,BC as Lt,BS as Rt,BT as zt,Bc as Bt,Bd as Vt,Bf 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,CE as Zt,CS as Qt,Cb as $t,Cf as en,Cg as tn,Ci as nn,Cl as rn,Cr as an,Ct as on,Cw as sn,Cx as cn,D as ln,DC as un,DE as dn,DS as fn,DT as pn,Dg as mn,Du as hn,Dy as gn,E as _n,EC as vn,ES as yn,ET as bn,Ec as xn,Ef as Sn,Eg as W,Em as Cn,Eo as wn,Er as Tn,Es as En,Et as Dn,Eu as On,Ew as kn,Ex as An,FC as jn,FT as Mn,Fb as Nn,Fd as Pn,Ff as Fn,Fg as In,Fh as Ln,Fm as Rn,Fo as zn,Fp as Bn,Fs as Vn,Ft as Hn,Fw as Un,Fx as Wn,G as Gn,GC as Kn,GS as qn,GT as Jn,Gb as Yn,Gd as Xn,Gf as Zn,Gl as Qn,Gm as $n,Gt as er,Gu as tr,Gw as nr,Gx as rr,HS as ir,Hd as ar,Hf as or,Hl as sr,Hm as cr,Hs as lr,Hw as ur,Hx as dr,Hy as fr,I as pr,IC as mr,IT as G,Ib as hr,Id as gr,If as _r,Ig as vr,Il as K,Im as yr,Io as br,Ip as xr,Ir as Sr,Is as Cr,Iw as wr,Ix as Tr,J as Er,JC as Dr,JD as Or,JE as kr,JT as Ar,Jb as jr,Jf as Mr,Jl as Nr,Jn as Pr,Jo as Fr,Jr as Ir,Js as Lr,Jx as Rr,KC as zr,KE as Br,KS as Vr,KT as Hr,Kb as Ur,Kf as Wr,Kg as Gr,Ki as Kr,Kl as qr,Ks as Jr,Ku as Yr,Kx as Xr,Ky as Zr,LC as Qr,LT as $r,Lb as ei,Ld as ti,Lf as ni,Lg as ri,Ll as ii,Lm as ai,Ln as oi,Lp as si,Ls as ci,Lw as li,Lx as ui,M as di,MC as fi,ME as pi,MS as mi,Mb as hi,Mc as gi,Mf as _i,Mg as vi,Mp as yi,Mr as bi,Mu as xi,Mw as Si,N as Ci,NC as wi,ND as Ti,NE as Ei,NT as Di,Nd as Oi,Nf as ki,Nl as Ai,Np as ji,Nu as Mi,OC as Ni,OE as Pi,OT as Fi,Ob as Ii,Oc as Li,Og as Ri,Oo as zi,Op as Bi,Ou as Vi,Ow as Hi,P as Ui,PC as Wi,PD as Gi,PT as Ki,Pb as qi,Pd as Ji,Pf as Yi,Ph as Xi,Pl as Zi,Pm as Qi,Pn as $i,Pp as ea,Pr as ta,Pu as na,Pw as ra,Px as ia,Q as aa,Qa as oa,Qd as sa,Qf as ca,Qi as la,Qm as ua,Qn as da,Qo as fa,Qs as pa,Qu as ma,RC as ha,RT as ga,Ra as _a,Rb as va,Rc as ya,Rg as ba,Ri as xa,Rm as Sa,Rp as Ca,Rs as wa,Rw as Ta,Rx as Ea,SC as Da,SD as Oa,SS as ka,Sb as Aa,Sf as ja,Sg as Ma,Sl as Na,So as Pa,Sx as Fa,Sy as Ia,TD as La,TE as Ra,TS as za,TT as Ba,Tb as Va,Tf as Ha,Tm as Ua,To as Wa,Tu as Ga,Tw as Ka,Tx as qa,Ty as Ja,UC as Ya,US as q,Ua as Xa,Ud as Za,Uf as Qa,Ug as $a,Ul as eo,Um as to,Up as no,Ut as ro,Uu as io,Uw as ao,Ux as oo,VC as so,VE as co,VS as lo,Va as uo,Vc as fo,Vd as po,Vf as mo,Vi as ho,Vl as go,Vm as _o,Vs as vo,Vu as yo,Vw as bo,Vx as xo,Vy as So,W as Co,WC as wo,WS as J,Wd as To,Wf as Eo,Wg as Do,Wi as Oo,Wl as ko,Wm as Ao,Wp as jo,Wu as Mo,Ww as No,Wx as Po,X as Fo,XE as Io,X_ as Lo,Xb as Ro,Xm as zo,Xu as Bo,Xx as Vo,YC as Ho,YD as Uo,YE as Wo,YT as Go,Y_ as Ko,Yb as qo,Yu as Jo,Yx as Yo,Z as Xo,ZC as Zo,ZT as Qo,Zb as $o,Zi as es,Zm as ts,Zs as ns,Zt as rs,Zu as is,Zx as as,_S as os,_b as ss,_l as cs,_m as ls,_p as us,_u as ds,_v as fs,_x as ps,aC as ms,aS as hs,aT as gs,aa as _s,ac as vs,af as ys,ao as bs,ap as xs,ax as Ss,b as Cs,bS as ws,bf as Ts,bg as Es,bo as Ds,bw as Os,bx as ks,cC as As,cS as js,cT as Ms,ca as Ns,cb as Ps,cl as Fs,cm as Is,cp as Ls,cs as Rs,cu as zs,cw as Bs,cx as Vs,dS as Hs,dh as Us,dm as Ws,dn as Gs,do as Ks,eE as qs,eO as Js,eh as Ys,ei as Xs,en as Zs,ep as Qs,es as $s,et as ec,ex as tc,fS as nc,fb as rc,fh as ic,fi as ac,fm as oc,fp as sc,fs as cc,fv as lc,fw as uc,fx as dc,gS as fc,gl as pc,gm as mc,gp as hc,gs as gc,gu as _c,hi as vc,hl as yc,hm as bc,ho as xc,hp as Sc,hu as Cc,hv as wc,hw as Tc,hx as Ec,iC as Dc,iS as Oc,iT as kc,ib as Ac,id as jc,if as Mc,ih as Nc,im as Pc,io as Fc,ip as Ic,it as Lc,iu as Rc,ix as zc,jC as Bc,jE as Vc,jT as Hc,jc as Uc,jf as Wc,jg as Gc,jm as Kc,jp as qc,jr as Jc,ju as Yc,jw as Xc,kT as Zc,kb as Qc,kc as $c,kh as el,km as tl,ko as nl,kw as rl,kx as il,lS as al,lb as ol,lh as sl,li as cl,ll,lm as ul,lt as dl,lu as fl,lw as pl,lx as ml,ly as hl,mE as gl,ma as _l,mm as vl,mo as yl,mp as bl,mr as xl,mu as Sl,mx as Cl,na as wl,nb as Tl,nd as El,nm as Dl,no as Ol,nr as kl,nx as Al,oC as jl,oS as Ml,oT as Nl,oa as Pl,ob as Fl,oc as Il,od as Ll,ol as Rl,op as zl,or as Bl,os as Vl,ow as Hl,pS as Ul,pT as Wl,pa as Gl,pb as Kl,ph as ql,pi as Jl,pm as Yl,po as Xl,pu as Zl,pv as Ql,pw as $l,px as eu,q as tu,qC as nu,qD as ru,qb as iu,qf as au,qg as ou,qi as su,ql as cu,qo as lu,qy as uu,rC as du,ra as fu,rd as pu,rg as mu,rh as hu,rm as gu,ro as _u,rp as vu,sC as yu,sS as bu,sT as xu,sa as Su,sb as Cu,sd as wu,sh as Tu,si as Eu,sl as Du,sm as Ou,su as ku,sw as Au,sx as ju,tE as Mu,tO as Nu,ta as Pu,tm as Fu,tp as Iu,tt as Lu,tx as Ru,uS as zu,ua as Bu,ub as Vu,uh as Hu,ul as Uu,um as Wu,uo as Gu,ur as Ku,ut as qu,uu as Ju,uy as Yu,vS as Xu,vi as Zu,vp as Qu,vs as $u,vu as ed,vx as td,wC as nd,wS as rd,wT as id,wb as ad,wf as od,wi as sd,wu as cd,ww as ld,wx as ud,wy as dd,x as fd,xS as pd,xb as md,xf as hd,xv as gd,xw as _d,xx as vd,yD as yd,yS as bd,yb as xd,yf as Sd,yg as Cd,yn as wd,yo as Td,ys as Ed,yx as Dd,zC as Od,zE as kd,zT as Ad,za as jd,zb as Md,zc as Nd,zf as Pd,zg as Fd,zl as Id,zm as Ld,zn as Rd,zo as zd,zp as Bd,zs as Vd,zw as Hd,zx as Ud}from"./loadAgentsDir-Clu7Uk6a.js";import{n as Wd,t as Gd}from"./cwd-CYmmnQVS.js";import{C as Kd,D as qd,F as Jd,G as Yd,Q as Xd,S as Zd,V as Qd,W as $d,_ as ef,a as tf,d as nf,l as Y,nt as rf,p as af,rt as of,w as sf,z as cf}from"./debug-BrXObCdR.js";import{B as lf,Bt as uf,Ft as df,Ht as ff,It as pf,Jt as mf,Kt as hf,L as gf,Pt as _f,St as vf,Ut as yf,Vt as bf,Wt as xf,Xt as Sf,Zt as Cf,_n as wf,c as Tf,cn as Ef,dn as Df,f as Of,ft as kf,g as Af,gn as jf,n as Mf,vn as Nf,y as Pf}from"./settings-Dlp5JTa_.js";import{P as Ff,b as If,c as Lf,g as Rf,l as zf,n as Bf}from"./config-3m_9zSrj.js";import{M as Vf,_ as Hf,a as Uf,d as Wf,i as Gf,j as Kf}from"./git-Do0wJvux.js";import{r as qf,t as Jf}from"./execFileNoThrow-D244NytW.js";import{B as Yf,L as Xf,N as Zf,R as Qf,U as $f,Y as ep,k as tp,o as np,s as X}from"./log-BMCygSzM.js";import{n as rp,t as ip}from"./memoize-B0zhbT8Z.js";import{n as ap,t as op}from"./which-CKQnSouy.js";import{i as sp,o as cp}from"./platform-BrYefG_2.js";import{i as lp,n as up,o as dp,r as fp}from"./path-D5U-tm91.js";import{D as pp,E as mp,T as hp,f as gp,l as _p}from"./file-DcZWPH2V.js";import{s as vp,u as yp}from"./types-C-MRCL8J.js";import{n as bp,r as Z}from"./analytics-BotDBGh0.js";import{c as xp,n as Sp,s as Cp,t as wp}from"./intl-cKc-V6Mq.js";import{T as Tp,b as Ep,d as Dp,f as Op,u as kp,y as Ap}from"./startupProfiler-xa3NmN7Z.js";import{l as jp,u as Mp}from"./oauth-BqJqV-2M.js";import{n as Np,t as Pp}from"./bundledMode--fG1S62b.js";import{a as Fp,d as Ip,l as Lp,o as Rp,r as zp,s as Bp}from"./stringUtils-DGLPkqJ4.js";import{$n as Vp,At as Hp,Bn as Up,Bt as Wp,Ct as Gp,D as Kp,Et as qp,Ft as Jp,Gr as Yp,Gt as Xp,Ht as Zp,Kn as Qp,St as $p,T as em,Vn as tm,X as nm,_ as rm,at as im,b as am,bi as om,br as sm,ct as cm,et as lm,h as um,it as dm,m as fm,mt as pm,ni as mm,nt as hm,ot as gm,qr as _m,ri as vm,rr as ym,rt as bm,st as xm,ti as Sm,tr as Cm,tt as wm,u as Tm,x as Em,xi as Dm,xr as Om}from"./model-BQF64tZx.js";import{At as km,Cn as Am,Et as jm,Ht as Mm,Tn as Nm,Tt as Pm,Ut as Fm,an as Im,bn as Lm,dn as Rm,fn as zm,hn as Bm,jt as Vm,mn as Hm,st as Um,yn as Wm}from"./prompt-Bg_1U0gO.js";import{et as Gm,rt as Km}from"./esm-CGoYrggU.js";import{a as qm,i as Jm,r as Ym}from"./shellQuote-DkSy9MYE.js";import{a as Xm}from"./ripgrep-BXmXjAzA.js";import{a as Zm,o as Qm,s as $m}from"./fileStateCache-DDW5toIs.js";import{C as eh,N as th,S as nh,T as rh,b as ih,d as ah,f as oh,j as sh,st as ch,w as lh,x as uh,y as dh}from"./rcDebugLog-VKwMl0yg.js";import{T as fh,c as ph,r as mh,w as hh}from"./sessionTracing-D8wr9j4X.js";import{i as gh,n as _h,r as vh}from"./parser-DFwaTGf7.js";import{c as yh,l as bh}from"./commitAttribution-CGZr7XNO.js";import{n as xh,t as Sh}from"./poorMode-1NLYiS3Y.js";import{a as Ch,f as wh,l as Th,o as Eh}from"./api-B-5jqiMg.js";import{f as Dh,m as Oh}from"./firstPartyEventLogger-BNGPPBNP.js";import{l as kh,u as Ah}from"./referral-BlrMpBAV.js";import{i as jh,m as Mh,n as Nh,p as Ph}from"./terminalSetup-D_P5iZmq.js";import{n as Fh,t as Ih}from"./browser-BmZuQom6.js";import{i as Lh,r as Rh}from"./bridgeEnabled-DhFrLTbG.js";import{n as zh,r as Bh}from"./undercover-CdapzvNH.js";import{t as Vh}from"./Dialog-vfLXEPed.js";import{t as Hh}from"./lib-BlVGipXx.js";import{n as Uh,t as Wh}from"./mappers-C8lYERPX.js";import{n as Gh,r as Kh}from"./sessionTitle-CLOlPZ_M.js";import{t as qh}from"./bridgeMessaging-B5Lbzr8e.js";import{C as Jh,S as Yh,d as Xh,l as Zh}from"./pidLock-Bd2e6xuT.js";import{n as Qh,t as $h}from"./nativeInstaller-OPuO2sm_.js";import{r as eg,t as tg}from"./pipeTransport-CqCnc-Ys.js";import{t as ng}from"./useManagePlugins-B8HD0RUh.js";import{n as rg,t as ig}from"./MCPConnectionManager-MWpKjeZT.js";import{i as ag,n as og,r as sg,t as cg}from"./reconciler-BdRXZTJf.js";import{n as lg,t as ug}from"./toolPool-CR61XXm3.js";import{a as dg,c as fg,i as pg,l as mg,r as hg,t as gg,u as _g}from"./MessageSelector-DsQmqFt2.js";import{n as vg,t as yg}from"./useExitOnCtrlCDWithKeybindings-CntByfTQ.js";import{n as bg,t as xg}from"./sideQuestion-CHpOVzY5.js";import{a as Sg,n as Cg,o as wg,r as Tg,s as Eg,t as Dg}from"./skillChangeDetector-s0F9Yf9a.js";import{n as Og,t as kg}from"./refresh-jwqnoK2h.js";import{i as Ag,n as jg,r as Mg,t as Ng}from"./directoryCompletion-CW2ckkQg.js";import{r as Pg,t as Fg}from"./PromptInputFooterSuggestions-D5sAO6y-.js";import{n as Ig,t as Lg}from"./useMergedTools-DfchLQZC.js";import{a as Rg,i as zg,n as Bg,o as Vg,r as Hg,t as Ug}from"./promptEditor-BhYDmwdS.js";import{n as Wg,t as Gg}from"./useMainLoopModel-DHkRIgNs.js";import{i as Kg,n as qg,r as Jg,t as Yg}from"./PermissionDialog-0ya1CU5k.js";import{n as Xg,t as Zg}from"./RemoteCallout-CiA4rCEs.js";import{a as Qg,c as $g,i as e_,o as t_,r as n_,s as r_}from"./caches-DPqPIogk.js";import{i as i_,n as a_,r as o_,t as s_}from"./conversation-CYqqk0o7.js";import{i as c_,n as l_,r as u_,t as d_}from"./extraUsage-C2Ylufhj.js";import{n as f_,t as p_}from"./useSearchInput-H-8hJeFD.js";import{n as m_,t as h_}from"./staticRender-BIxpgNUq.js";import{n as g_,t as __}from"./useSettingsErrors-BF5i5Xju.js";import{n as v_,t as y_}from"./shadowedRuleDetection-CXsmUY2o.js";import{n as b_,t as x_}from"./ExitFlow-D3csukbB.js";import{a as S_,i as C_,r as w_,t as T_}from"./fast-Dx2fTmWr.js";import{n as E_,r as D_}from"./Feedback-bEUtrHia.js";import{a as O_,i as k_,n as A_,r as j_,t as M_}from"./PromptInputHelpMenu-n6hAdsto.js";import{n as N_,r as P_}from"./pluginAutoupdate-CO-n9bqe.js";import{n as F_,r as I_}from"./autoModeDenials-BxNzGJdR.js";import{n as L_,t as R_}from"./generateSessionName-CN1oh7Fa.js";import{a as z_,c as B_,d as V_,i as H_,l as U_,n as W_,o as G_,r as K_,s as q_,t as J_,u as Y_}from"./Messages-B3sGRx5A.js";import{a as X_,i as Z_,n as Q_,o as $_,r as ev,t as tv}from"./BackgroundTasksDialog-CyoLEYWH.js";import{n as nv}from"./fpsMetrics-Cf_hdtiJ.js";import{t as rv}from"./earlyInput-BTC_Wucv.js";import{a as iv,c as av,i as ov,l as sv,o as cv,r as lv,s as uv,t as dv}from"./RemoteSessionManager-zdHfmvfj.js";import{n as fv,t as pv}from"./backgroundHousekeeping-DhF2lrQ9.js";import{n as mv}from"./language-DIw2871r.js";import{homedir as hv,tmpdir as gv}from"os";import*as _v from"path";import{basename as vv,dirname as yv,extname as bv,join as xv,relative as Sv,sep as Cv}from"path";import{dirname as wv,join as Tv}from"node:path";import{watch as Ev}from"fs";import{createHash as Dv}from"node:crypto";import{randomUUID as Ov}from"crypto";import{readFile as kv,stat as Av,writeFile as jv}from"fs/promises";import{spawn as Mv,spawnSync as Nv}from"child_process";import{mkdir as Pv,readFile as Fv,rename as Iv,writeFile as Lv}from"node:fs/promises";s(),c(),p(),L(),me(),u(),B(),Ee(),We(),at(),Wd(),rf(),Yd(),cf(),Zd(),af(),tf(),Kf(),ep(),np(),qf(),ip(),op(),Hf(),cp(),lp(),mp(),wf(),bp(),gp(),vp(),Cp(),Ep(),Df(),Oe(),Mp(),Pp(),Cf(),hf(),df(),vf(),gf(),Rp(),Af(),Ff(),om(),Nm(),Rf(),Lm(),Bm(),vm(),_m(),Om(),ym(),Qp(),Wp(),lm(),rm(),Im(),Gm(),Nu(),Or(),Ti(),Xm(),Oa(),Fm(),Vm(),jm(),Um(),Io(),Br(),Qm(),co(),Ei(),dn(),gl(),qs(),Qo(),Hr(),Ki(),Wl(),xu(),nr(),hh(),vh(),Ym(),li(),Xc(),kn(),Os(),$l(),Bs(),Zo(),nu(),th(),Ya(),so(),Od(),Wi(),Ni(),As(),ms(),Ah(),du(),Rt(),fn(),za(),ka(),ws(),Xu(),Ph(),jh(),zu(),Rr(),dr(),kh(),Yt(),ui(),Wn(),cn(),Fa(),Cl(),Ur(),Va(),rc(),Tl(),Zr(),Yu(),Ih(),Lo(),Do(),Fd(),mn(),Tt(),_o(),ai(),Cn(),ls(),ul(),Dl(),jo(),Bd(),us(),zl(),Iu(),ni(),ki(),Wc(),Sn(),od(),hd(),Ts(),Rh(),Za(),po(),gr(),Ji(),dh(),pu(),Bo(),yo(),Ft(),hn(),On(),ed(),_c(),ph(),ku(),Rc(),cu(),K(),Ai(),Na(),yc(),ll(),Du(),fo(),ya(),Uc(),$c(),vs(),pa(),vo(),En(),$u(),cc(),Vl(),zd(),uo(),_l(),la(),Jc(),oi(),wd(),ec(),Xo(),tu(),Gn(),Xt(),Kg(),qg(),p_(),E_();var Q=n(z(),1);x(),W_(),qa(),Dt(),q(),h_();var $=ve();function Rv({children:e}){let{bindings:t}=mi(),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 Bv(e,t,n,{columns:r,verbose:i=!1,chunkSize:a=40,onProgress:o}={}){let s=n=>m_((0,$.jsx)(ir,{children:(0,$.jsx)(Rv,{children:(0,$.jsx)(J_,{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 Vv(e,t=[],n){let r=[];return await Bv(e,t,e=>void r.push(pe(e)),{columns:n}),r.join(``)}ao(),fs(),Us(),sl(),Rg(),dc();function Hv({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)(eu,{options:[{value:`ok`,label:`Got it, thanks!`}],onChange:e})]})}B(),dc();function Uv({idleMinutes:e,totalInputTokens:t,onDone:n}){return(0,$.jsxs)(ge,{title:`You've been away ${Wv(e)} and this conversation is ${Ap(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)(eu,{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 Wv(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 Gv(e,t){let n=Lf().preferredNotifChannel;await ro(e),Z(`tengu_notification_method_used`,{configured_channel:n,method_used:await qv(n,e,t),term:mf.terminal})}var Kv=`Work Mate`;async function qv(e,t,n){let r=t.title||Kv;try{switch(e){case`auto`:return Jv(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:Yv()}),`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 Jv(e,t){let n=e.title||Kv;switch(mf.terminal){case`Apple_Terminal`:return await Xv()?(t.notifyBell(),`terminal_bell`):`no_method_available`;case`iTerm.app`:return t.notifyITerm2(e),`iterm2`;case`kitty`:return t.notifyKitty({...e,title:n,id:Yv()}),`kitty`;case`ghostty`:return t.notifyGhostty({...e,title:n}),`ghostty`;default:return`no_method_available`}}function Yv(){return Math.floor(Math.random()*1e4)}async function Xv(){try{if(mf.terminal!==`Apple_Terminal`)return!1;let e=(await Jf(`osascript`,[`-e`,`tell application "Terminal" to name of current settings of front window`])).stdout.trim();if(!e)return!1;let t=await Jf(`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 Zv=300,Qv=240*1e3,$v=null,ey=null,ty=0,ny=!1;function ry(){ty++,ty===1&&(cy(),oy())}function iy(){ty>0&&ty--,ty===0&&(sy(),ly())}function ay(){ty=0,sy(),ly()}function oy(){process.platform===`darwin`&&ey===null&&(ey=setInterval(()=>{ty>0&&(Y(`Restarting caffeinate to maintain sleep prevention`),ly(),cy())},Qv),ey.unref())}function sy(){ey!==null&&(clearInterval(ey),ey=null)}function cy(){if(process.platform===`darwin`&&$v===null){ny||(ny=!0,of(async()=>{ay()}));try{$v=Mv(`caffeinate`,[`-i`,`-t`,String(Zv)],{stdio:`ignore`}),$v.unref();let e=$v;$v.on(`error`,t=>{Y(`caffeinate spawn error: ${t.message}`),$v===e&&($v=null)}),$v.on(`exit`,()=>{$v===e&&($v=null)}),Y(`Started caffeinate to prevent sleep`)}catch{$v=null}}}function ly(){if($v!==null){let e=$v;$v=null;try{e.kill(`SIGKILL`),Y(`Stopped caffeinate, allowing sleep`)}catch{}}}var uy=class{constructor(){l(this,`_status`,`idle`),l(this,`_generation`,0),l(this,`_changed`,_t()),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 dy(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(Eu(f,{},p,e).then(e=>{m===a.current&&e&&!l&&(r.current=e)}),l||c||u){let t=da(f,e).findLast(bi);t&&(r.current=t.uuid)}n.current=e.length,i.current=o},[e,t])}function fy(e){return!e||typeof e!=`object`?!1:`behavior`in e&&(e.behavior===`allow`||e.behavior===`deny`)}function py(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 my(e){let t=e.response;if(!t||typeof t!=`object`)return null;if(t.subtype===`success`&&`response`in t&&fy(t.response))return t.response;if(t.subtype!==`error`)return null;let n=`response`in t&&fy(t.response)?t.response:void 0,r=py(t,n);return n?r?{...n,message:r}:n:r?{behavior:`deny`,message:r}:null}function hy(t){{let{pauseProactive:t}=(dh(),e(eh));t()}t?.abort()}function gy(e,t){return e<t}function _y(e,t){return e&&t===0}function vy({hasHandle:e,isConnected:t,lastWrittenIndex:n,messageCount:r}){return!e||!t||gy(n,r)}ml(),o_();function yy(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 by(e,t){return e.id.localeCompare(t.id)}function xy(e,t){return{task_list_id:e,tasks:t.filter(e=>!e.metadata?._internal).map(yy).sort(by)}}function Sy(e,t){return JSON.stringify(xy(e,t))}function Cy(e,t){let n=xy(e,t);return{type:`task_state`,uuid:Ov(),...n}}B(),q(),tf();var wy=50,Ty=5e3,Ey=1e4,Dy=3;function Oy(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=Vr(),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 _=qn(),{addNotification:v}=lo(),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>=Dy){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-DJs28ZkI.js`),{shouldShowAppUpgradeMessage:y}=await import(`./envLessBridgeConfig-B2HYnEKo.js`),b=!1;{let{isAssistantMode:e}=await import(`./assistant-z2o4-UJe.js`);b=e()}async function x(e){try{let t=sg(e);if(!t)return;let{uuid:n}=t,{resolveAndPrepend:r}=await import(`./inboundAttachments-C0nMTtCi.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}`:``}`),pn({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!==``?Ss(o.environmentId,o.sessionIngressUrl):e.replBridgeConnectUrl,n=o?wi(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,Td(`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))},Ey);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=my(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(){hy(n.current)},onSetModel(e){let t=e==="default"?null:e??null;Ke(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(ln())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`&&!_n()){let e=fd();return{ok:!1,error:e?`Cannot set permission mode to auto: ${Cs(e)}`:`Cannot set permission mode to auto`}}return p(t=>{let n=t.toolPermissionContext.mode;if(n===e)return t;let r=Ui(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))},Ey);return}if(a.current=D,i_(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=wi(D.bridgeSessionId,D.sessionIngressUrl),r=D.environmentId===``?void 0:Ss(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,yl(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=Jd(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))},Ey),r||t(e=>[...e,Td(`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,i_(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&&_y(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=Ev(e,u),r.unref()}catch{}}},l=async()=>{let t=a.current;if(!t)return;let n=vn();c(un(n));try{let r=await Et(n);if(e||a.current!==t)return;let i=Sy(n,r);if(i===o&&t===s)return;t.writeSdkMessages([Cy(n,r)]),o=i,s=t}catch(e){Y(`[bridge:repl] Failed to publish task_state: ${Jd(e)}`,{level:`error`})}},u=()=>{t&&clearTimeout(t),t=setTimeout(()=>{t=void 0,l()},wy),t.unref?.()};l();let d=Bc(u);return n=setInterval(()=>{l()},Ty),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(_y(l.current,g.current.length)){l.current=!1,c.current=!1,e.sendResult();return}if(l.current||vy({hasHandle:!0,isConnected:b,lastWrittenIndex:s.current,messageCount:g.current.length})){c.current=!0;return}e.sendResult()}},[b])}}Ru(),$o(),iu(),hr(),Nn(),yg(),hg(),bp();var ky=Te(()=>ye({method:xe(`log_event`),params:ye({eventName:be(),eventData:ye({}).passthrough()})}));function Ay(e){(0,Q.useEffect)(()=>{if(!e.length)return;let t=Ma(e);t&&t.client.setNotificationHandler(ky(),e=>{let{eventName:t,eventData:n}=e.params;Z(`tengu_ide_${t}`,n)})},[e])}at(),B();var jy=6e3;function My(){return Date.now()-ze()}function Ny(e){return My()<e}function Py(e){return!Ny(e)}function Fy(e,t){let n=E();(0,Q.useEffect)(()=>{vt(!0)},[]),(0,Q.useEffect)(()=>{let r=!1,i=setInterval(()=>{Py(6e3)&&!r&&(r=!0,clearInterval(i),Gv({message:e,notificationType:t},n))},jy);return()=>clearInterval(i)},[e,t,n])}il(),ts(),xr(),ji(),Nt(),Hg(),B(),lc();var Iy={topLeft:`┌`,topRight:`┐`,bottomLeft:`└`,bottomRight:`┘`,horizontal:`─`,vertical:`│`,teeLeft:`├`,teeRight:`┤`};function Ly(e){return pd().syntaxHighlightingDisabled?(0,$.jsx)(zy,{...e,highlight:null}):(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(zy,{...e,highlight:null}),children:(0,$.jsx)(Ry,{...e})})}function Ry(e){let t=(0,Q.use)(bo());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)(()=>Hu(e,s,a),[e,s,a]).split(`
|
|
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=`${Iy.topLeft}${Iy.horizontal.repeat(v-2)}${Iy.topRight}`,C=`${Iy.bottomLeft}${Iy.horizontal.repeat(v-2)}${Iy.bottomRight}`,w=d?(()=>{let e=u.length-l,t=`${Iy.horizontal.repeat(3)} \u2702 ${Iy.horizontal.repeat(3)} ${e} lines hidden `,n=_(t),r=Math.max(0,v-2-n);return`${Iy.teeLeft}${t}${Iy.horizontal.repeat(r)}${Iy.teeRight}`})():null;return(0,$.jsxs)(b,{flexDirection:`column`,children:[(0,$.jsx)(T,{dimColor:!0,children:S}),m.map((e,t)=>{let n=_(e)>x?Ql(e,0,x):e,r=` `.repeat(Math.max(0,x-_(n)));return(0,$.jsxs)(b,{flexDirection:`row`,children:[(0,$.jsxs)(T,{dimColor:!0,children:[Iy.vertical,` `]}),(0,$.jsx)(g,{children:n}),(0,$.jsxs)(T,{dimColor:!0,children:[r,` `,Iy.vertical]})]},t)}),w&&(0,$.jsx)(T,{color:`warning`,children:w}),(0,$.jsx)(T,{dimColor:!0,children:C})]})}ms(),B(),Ep();function By({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?Tp(e,l-2-2):Tp(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(),ms(),B(),q(),mn();function Vy({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),ee=zg(),j=ee?In(ee):null,M=e.question,te=i[M],N=e.options,[P,F]=(0,Q.useState)(0),ne=(0,Q.useRef)(M);if(ne.current!==M){ne.current=M;let e=te?.selectedValue,t=e?N.findIndex(t=>t.label===e):-1;F(t>=0?t:0)}let re=N[P],I=te?.selectedValue,L=te?.textInputValue||``,ie=(0,Q.useCallback)(e=>{let t=N[e];t&&(F(e),c(M,{selectedValue:t.label},!1),l(M,t.label))},[N,M,c,l]),R=(0,Q.useCallback)(e=>{if(E)return;let t;t=typeof e==`number`?e:e===`up`?P>0?P-1:P:P<N.length-1?P+1:P,t>=0&&t<N.length&&F(t)},[P,N.length,E]);A(`chat:externalEditor`,async()=>{let e=te?.textInputValue||``,t=await Bg(e);t.content!==null&&t.content!==e&&c(M,{textInputValue:t.content},!1)},{context:`Chat`,isActive:E&&!!ee}),v({"tabs:previous":()=>p?.(),"tabs:next":()=>h?.()},{context:`Tabs`,isActive:!E&&!x});let z=(0,Q.useCallback)(()=>{D(!1),u(!1),I&&l(M,I)},[I,M,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(),P>0&&R(`up`);else if(e.key===`down`||e.ctrl&&e.key===`n`)e.preventDefault(),P===N.length-1?ae():R(`down`);else if(e.key===`return`)e.preventDefault(),ie(P);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<N.length&&R(t)}},[x,C,y,E,P,N.length,oe,ae,R,ie,z,g,_,f,u]),ce=re?.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)(By,{questions:t,currentQuestionIndex:n,answers:r,hideSubmitTab:a}),(0,$.jsx)(Jg,{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:N.map((e,t)=>{let n=P===t,r=I===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)(Ly,{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)(ia,{value:L,placeholder:`Add notes on this design…`,onChange:e=>{c(M,{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:L||`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&&j&&(0,$.jsxs)($.Fragment,{children:[` · ctrl+g to edit in `,j]}),` · Esc to cancel`]})})]})]})]})}u(),B(),q(),Rg(),mn(),Hg(),dc(),Kg();function Hy({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),[ee,A]=(0,Q.useState)(!1),j=zg(),M=j?In(j):null,te=(0,Q.useCallback)(e=>{let t=e===`__other__`;A(t),f(t)},[f]),N=(0,Q.useCallback)(()=>{D(!0)},[]),P=(0,Q.useCallback)(()=>{D(!1)},[]),F=(0,Q.useCallback)(e=>{if(E){if(e.key===`up`||e.ctrl&&e.key===`p`){e.preventDefault(),O===0?P():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,P,v,y,p]),ne=e.options.map(e=>({type:`text`,value:e.label,label:e.label,description:e.description})),re=e.question,I=i[re],L=(0,Q.useCallback)(async(t,n)=>{let r=await Bg(t);r.content!==null&&r.content!==t&&(n(r.content),l(re,{textInputValue:r.content},e.multiSelect??!1))},[re,l,e.multiSelect]),ie={type:`input`,value:`__other__`,label:`Other`,placeholder:e.multiSelect?`Type something`:`Type something.`,initialValue:I?.textInputValue??``,onChange:t=>{l(re,{textInputValue:t},e.multiSelect??!1)}},R=[...ne,ie];return!e.multiSelect&&e.options.some(e=>e.preview)?(0,$.jsx)(Vy,{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:F,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)(zo,{filePath:o})]})]}),(0,$.jsx)(b,{marginTop:-1,children:(0,$.jsx)(m,{color:`inactive`})}),(0,$.jsxs)(b,{flexDirection:`column`,paddingTop:0,children:[(0,$.jsx)(By,{questions:t,currentQuestionIndex:n,answers:r,hideSubmitTab:a}),(0,$.jsx)(Jg,{title:e.question,color:`text`}),(0,$.jsxs)(b,{flexDirection:`column`,minHeight:s,children:[(0,$.jsx)(b,{marginTop:1,children:e.multiSelect?(0,$.jsx)(Ec,{options:R,defaultValue:i[e.question]?.selectedValue,onChange:e=>{l(re,{selectedValue:e},!0);let t=e.includes(`__other__`)?i[re]?.textInputValue:void 0,n=e.filter(e=>e!==`__other__`).concat(t?[t]:[]);u(re,n,void 0,!1)},onFocus:te,onCancel:p,submitButtonText:n===t.length-1?`Submit`:`Next`,onSubmit:h,onDownFromLastItem:N,isDisabled:E,onOpenEditor:L,onImagePaste:x,pastedContents:S,onRemoveImage:C},e.question):(0,$.jsx)(eu,{options:R,defaultValue:i[e.question]?.selectedValue,onChange:e=>{l(re,{selectedValue:e},!1);let t=e===`__other__`?i[re]?.textInputValue:void 0;u(re,e,t)},onFocus:te,onCancel:p,onDownFromLastItem:N,isDisabled:E,layout:`compact-vertical`,onOpenEditor:L,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:[R.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:[R.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`,ee&&M&&(0,$.jsxs)($.Fragment,{children:[` · ctrl+g to edit in `,M]}),` · Esc to cancel`]})})]})]})]})}function Uy(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(lf(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 Wy({permissionResult:e,toolType:t}){let n=J(e=>e.toolPermissionContext.mode),r=Uy(e?.decisionReason,t);if(!r)return null;let i=r.themeColor??(e?.decisionReason?.type===`hook`&&n===`auto`?`warning`:void 0);return(0,Gy.jsxs)(b,{marginBottom:1,flexDirection:`column`,children:[i?(0,Gy.jsx)(T,{color:i,children:r.reasonString}):(0,Gy.jsx)(T,{children:(0,Gy.jsx)(g,{children:r.reasonString})}),r.configString&&(0,Gy.jsx)(T,{dimColor:!0,children:r.configString})]})}var Gy,Ky=t((()=>{z(),B(),q(),Gy=ve()}));u(),B(),dc(),Kg(),Ky();function qy({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)(By,{questions:e,currentQuestionIndex:t,answers:n}),(0,$.jsx)(Jg,{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)(Wy,{permissionResult:i,toolType:`tool`}),(0,$.jsx)(T,{color:`inactive`,children:`Ready to submit your answers?`}),(0,$.jsx)(b,{marginTop:1,children:(0,$.jsx)(eu,{options:[{type:`text`,label:`Submit answers`,value:`submit`},{type:`text`,label:`Cancel`,value:`cancel`}],onChange:e=>o(e),onCancel:()=>o(`cancel`)})})]})]})]})}function Jy(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 Yy={currentQuestionIndex:0,answers:{},questionStates:{},isInTextInput:!1};function Xy(){let[e,t]=(0,Q.useReducer)(Jy,Yy),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}}ws(),ms(),B(),Ah(),bp(),q(),ao(),np(),Us();var Zy=12,Qy=40,$y=15;function eb(e){return pd().syntaxHighlightingDisabled?(0,$.jsx)(nb,{...e,highlight:null}):(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(nb,{...e,highlight:null}),children:(0,$.jsx)(tb,{...e})})}function tb(e){let t=(0,Q.use)(bo());return(0,$.jsx)(nb,{...e,highlight:t})}function nb({toolUseConfirm:e,onDone:t,onReject:n,highlight:r}){let i=(0,Q.useMemo)(()=>Vt.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(Zy,o-$y);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=Hu(e.preview,s,r).split(`
|
|
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,Zy),n),globalContentWidth:Math.max(t,Qy)}},[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};An(s),It(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?ol():void 0,{currentQuestionIndex:S,answers:C,questionStates:w,isInTextInput:T,nextQuestion:E,prevQuestion:D,updateQuestionState:O,setAnswer:k,setTextInputMode:ee}=Xy(),A=S<(a?.length||0)?a?.[S]:null,j=S===(a?.length||0),M=a?.every(e=>e?.question&&!!C[e.question])??!1,te=a.length===1&&!a[0]?.multiSelect,N=(0,Q.useCallback)(()=>{u&&Z(`tengu_ask_user_question_rejected`,{source:u,questionCount:a.length,isInPlanMode:b,interviewPhaseEnabled:b&&ti()}),t(),n(),e.onReject()},[t,n,e,u,a.length,b]),P=(0,Q.useCallback)(async()=>{let n=`The user wants to clarify these questions.
|
|
4
|
+
This means they may have additional information, context or questions for you.
|
|
5
|
+
Take their response into account and then reformulate the questions if appropriate.
|
|
6
|
+
Start by asking them what they would like to clarify.
|
|
7
|
+
|
|
8
|
+
Questions asked:\n${a.map(e=>{let t=C[e.question];return t?`- "${e.question}"\n Answer: ${t}`:`- "${e.question}"\n (No answer provided)`}).join(`
|
|
9
|
+
`)}`;u&&Z(`tengu_ask_user_question_respond_to_claude`,{source:u,questionCount:a.length,isInPlanMode:b,interviewPhaseEnabled:b&&ti()});let r=await rb(g);t(),e.onReject(n,r&&r.length>0?r:void 0)},[a,C,t,e,u,b,g]),F=(0,Q.useCallback)(async()=>{let n=`The user has indicated they have provided enough answers for the plan interview.
|
|
10
|
+
Stop asking clarifying questions and proceed to finish the plan with the information you have.
|
|
11
|
+
|
|
12
|
+
Questions asked and answers provided:\n${a.map(e=>{let t=C[e.question];return t?`- "${e.question}"\n Answer: ${t}`:`- "${e.question}"\n (No answer provided)`}).join(`
|
|
13
|
+
`)}`;u&&Z(`tengu_ask_user_question_finish_plan_interview`,{source:u,questionCount:a.length,isInPlanMode:b,interviewPhaseEnabled:b&&ti()});let r=await rb(g);t(),e.onReject(n,r&&r.length>0?r:void 0)},[a,C,t,e,u,b,g]),ne=(0,Q.useCallback)(async n=>{u&&Z(`tengu_ask_user_question_accepted`,{source:u,questionCount:a.length,answerCount:Object.keys(n).length,isInPlanMode:b,interviewPhaseEnabled:b&&ti()});let r={};for(let e of a){let t=n[e.question],i=w[e.question]?.textInputValue,a=(t?e.options.find(e=>e.label===t):void 0)?.preview;(a||i?.trim())&&(r[e.question]={...a&&{preview:a},...i?.trim()&&{notes:i.trim()}})}let i={...e.input,answers:n,...Object.keys(r).length>0&&{annotations:r}},o=await rb(g);t(),e.onAllow(i,[],void 0,o&&o.length>0?o:void 0)},[e,t,u,a,w,b,g]),re=(0,Q.useCallback)((e,t,n,r=!0)=>{let i,o=Array.isArray(t);i=o?t.join(`, `):n?Object.values(d[e]??{}).filter(e=>e.type===`image`).length>0?`${n} (Image attached)`:n:t===`__other__`&&Object.values(d[e]??{}).filter(e=>e.type===`image`).length>0?`(Image attached)`:t;let s=a.length===1;if(!o&&s&&r){let t={...C,[e]:i};ne(t).catch(X);return}k(e,i,r)},[k,a.length,C,ne,d]);function I(e){if(e===`cancel`){N();return}e===`submit`&&ne(C).catch(X)}let L=te?(a?.length||1)-1:a?.length||0,ie=(0,Q.useCallback)(()=>{S>0&&D()},[S,D]),R=(0,Q.useCallback)(()=>{S<L&&E()},[S,L,E]);return v({"tabs:previous":ie,"tabs:next":R},{context:`Tabs`,isActive:!(T&&!j)}),A?(0,$.jsx)($.Fragment,{children:(0,$.jsx)(Hy,{question:A,questions:a,currentQuestionIndex:S,answers:C,questionStates:w,hideSubmitTab:te,minContentHeight:c,minContentWidth:l,planFilePath:x,onUpdateQuestionState:O,onAnswer:re,onTextInputFocus:ee,onCancel:N,onSubmit:E,onTabPrev:ie,onTabNext:R,onRespondToClaude:P,onFinishPlanInterview:F,onImagePaste:(e,t,n,r,i)=>m(A.question,e,t,n,r,i),pastedContents:d[A.question]??{},onRemoveImage:e=>h(A.question,e)})}):j?(0,$.jsx)($.Fragment,{children:(0,$.jsx)(qy,{questions:a,currentQuestionIndex:S,answers:C,allQuestionsAnswered:M,permissionResult:e.permissionResult,minContentHeight:c,onFinalResponse:I})}):null}async function rb(e){if(e.length!==0)return Promise.all(e.map(async e=>(await Mu({type:`image`,source:{type:`base64`,media_type:e.mediaType||`image/png`,data:e.content}})).block))}var ib=[`http://`,`https://`,`ftp://`],ab={rg:2,"pre-commit":2,gcloud:4,"gcloud compute":6,"gcloud beta":6,aws:4,az:4,kubectl:3,docker:3,dotnet:3,"git push":2},ob=e=>Array.isArray(e)?e:[e];function sb(e,t){if(!t?.subcommands?.length)return!1;let n=e.toLowerCase();return t.subcommands.some(e=>Array.isArray(e.name)?e.name.some(e=>e.toLowerCase()===n):e.name.toLowerCase()===n)}function cb(e,t,n){if(n?.options){let t=n.options.find(t=>Array.isArray(t.name)?t.name.includes(e):t.name===e);if(t)return!!t.args}return n?.subcommands?.length&&t&&!t.startsWith(`-`)?!sb(t,n):!1}function lb(e,t){for(let n=0;n<e.length;n++){let r=e[n];if(r){if(r.startsWith(`-`)){cb(r,e[n+1],t)&&n++;continue}if(!t?.subcommands?.length||sb(r,t))return r}}}async function ub(e,t,n){let r=await db(e,t,n),i=[e],a=!!n?.subcommands?.length,o=!1;for(let s=0;s<t.length;s++){let c=t[s];if(!c||i.length>=r)break;if(c.startsWith(`-`)){if(c===`-c`&&[`python`,`python3`].includes(e.toLowerCase()))break;if(n?.options){let e=n.options.find(e=>Array.isArray(e.name)?e.name.includes(c):e.name===c);if(e?.args&&ob(e.args).some(e=>e?.isCommand||e?.isModule)){i.push(c);continue}}if(a&&!o){cb(c,t[s+1],n)&&s++;continue}break}if(await fb(c,t.slice(0,s),n))break;a&&!o&&(o=sb(c,n)),i.push(c)}return i.join(` `)}async function db(e,t,n){let r=lb(t,n),i=e.toLowerCase(),a=r?`${i} ${r.toLowerCase()}`:i;if(ab[a])return ab[a];if(ab[i])return ab[i];if(!n)return 2;if(n.options&&t.some(e=>e?.startsWith(`-`)))for(let e of t){if(!e?.startsWith(`-`))continue;let t=n.options.find(t=>Array.isArray(t.name)?t.name.includes(e):t.name===e);if(t?.args&&ob(t.args).some(e=>e?.isCommand||e?.isModule))return 3}if(r&&n.subcommands?.length){let e=r.toLowerCase(),t=n.subcommands.find(t=>Array.isArray(t.name)?t.name.some(t=>t.toLowerCase()===e):t.name.toLowerCase()===e);if(t){if(t.args){let e=ob(t.args);if(e.some(e=>e?.isCommand))return 3;if(e.some(e=>e?.isVariadic))return 2}return t.subcommands?.length?4:t.args?3:2}}if(n.args){let e=ob(n.args);if(e.some(e=>e?.isCommand))return!Array.isArray(n.args)&&n.args.isCommand?2:Math.min(2+e.findIndex(e=>e?.isCommand),3);if(!n.subcommands?.length){if(e.some(e=>e?.isVariadic))return 1;if(e[0]&&!e[0].isOptional)return 2}}return n.args&&ob(n.args).some(e=>e?.isDangerous)?3:2}async function fb(e,t,n){if(e.startsWith(`-`))return!0;let r=e.lastIndexOf(`.`),i=r>0&&r<e.length-1&&!e.substring(r+1).includes(`:`),a=e.includes(`/`)||i,o=ib.some(t=>e.startsWith(t));if(!a&&!o)return!1;if(n?.options&&t.length>0&&t[t.length-1]===`-m`){let e=n.options.find(e=>Array.isArray(e.name)?e.name.includes(`-m`):e.name===`-m`);if(e?.args&&ob(e.args).some(e=>e?.isModule))return!1}return!0}var pb=[{name:`pyright`,description:`Type checker for Python`,options:[{name:[`--help`,`-h`],description:`Show help message`},{name:`--version`,description:`Print pyright version and exit`},{name:[`--watch`,`-w`],description:`Continue to run and watch for changes`},{name:[`--project`,`-p`],description:`Use the configuration file at this location`,args:{name:`FILE OR DIRECTORY`}},{name:`-`,description:`Read file or directory list from stdin`},{name:`--createstub`,description:`Create type stub file(s) for import`,args:{name:`IMPORT`}},{name:[`--typeshedpath`,`-t`],description:`Use typeshed type stubs at this location`,args:{name:`DIRECTORY`}},{name:`--verifytypes`,description:`Verify completeness of types in py.typed package`,args:{name:`IMPORT`}},{name:`--ignoreexternal`,description:`Ignore external imports for --verifytypes`},{name:`--pythonpath`,description:`Path to the Python interpreter`,args:{name:`FILE`}},{name:`--pythonplatform`,description:`Analyze for platform`,args:{name:`PLATFORM`}},{name:`--pythonversion`,description:`Analyze for Python version`,args:{name:`VERSION`}},{name:[`--venvpath`,`-v`],description:`Directory that contains virtual environments`,args:{name:`DIRECTORY`}},{name:`--outputjson`,description:`Output results in JSON format`},{name:`--verbose`,description:`Emit verbose diagnostics`},{name:`--stats`,description:`Print detailed performance stats`},{name:`--dependencies`,description:`Emit import dependency information`},{name:`--level`,description:`Minimum diagnostic level`,args:{name:`LEVEL`}},{name:`--skipunannotated`,description:`Skip type analysis of unannotated functions`},{name:`--warnings`,description:`Use exit code of 1 if warnings are reported`},{name:`--threads`,description:`Use up to N threads to parallelize type checking`,args:{name:`N`,isOptional:!0}}],args:{name:`files`,description:`Specify files or directories to analyze (overrides config file)`,isVariadic:!0,isOptional:!0}},{name:`timeout`,description:`Run a command with a time limit`,args:[{name:`duration`,description:`Duration to wait before timing out (e.g., 10, 5s, 2m)`,isOptional:!1},{name:`command`,description:`Command to run`,isCommand:!0}]},{name:`sleep`,description:`Delay for a specified amount of time`,args:{name:`duration`,description:`Duration to sleep (seconds or with suffix like 5s, 2m, 1h)`,isOptional:!1}},{name:`alias`,description:`Create or list command aliases`,args:{name:`definition`,description:`Alias definition in the form name=value`,isOptional:!0,isVariadic:!0}},{name:`nohup`,description:`Run a command immune to hangups`,args:{name:`command`,description:`Command to run with nohup`,isCommand:!0}},{name:`time`,description:`Time a command`,args:{name:`command`,description:`Command to time`,isCommand:!0}},{name:`srun`,description:`Run a command on SLURM cluster nodes`,options:[{name:[`-n`,`--ntasks`],description:`Number of tasks`,args:{name:`count`,description:`Number of tasks to run`}},{name:[`-N`,`--nodes`],description:`Number of nodes`,args:{name:`count`,description:`Number of nodes to allocate`}}],args:{name:`command`,description:`Command to run on the cluster`,isCommand:!0}}];async function mb(e){if(!e||e.includes(`/`)||e.includes(`\\`)||e.includes(`..`)||e.startsWith(`-`)&&e!==`-`)return null;try{let t=await import(`@withfig/autocomplete/build/${e}.js`);return t.default||t}catch{return null}}var hb=rp(async e=>pb.find(t=>t.name===e)||await mb(e)||null,e=>e),gb=/^\d+$/,_b=/^[A-Za-z_][A-Za-z0-9_]*=/,vb=new Set([`nice`]),yb=e=>Array.isArray(e)?e:[e];function bb(e,t){return t?.subcommands?.length?t.subcommands.some(t=>Array.isArray(t.name)?t.name.includes(e):t.name===e):!1}async function xb(e,t=0,n=0){if(n>2||t>10)return null;let r=await gh(e);if(!r)return null;if(!r.commandNode)return{commandPrefix:null};let{envVars:i,commandNode:a}=r,[o,...s]=_h(a);if(!o)return{commandPrefix:null};let c=await hb(o),l=vb.has(o)||c?.args&&yb(c.args).some(e=>e?.isCommand);l&&s[0]&&bb(s[0],c)&&(l=!1);let u=l?await Sb(o,s,t,n):await ub(o,s,c);if(u===null&&t===0&&l)return null;let d=i.length?`${i.join(` `)} `:``;return{commandPrefix:u?d+u:null}}async function Sb(e,t,n,r){let i=await hb(e);if(i?.args){let a=yb(i.args).findIndex(e=>e?.isCommand);if(a!==-1){let i=[e];for(let e=0;e<t.length&&e<=a;e++)if(e===a){let a=await xb(t.slice(e).join(` `),n+1,r+1);if(a?.commandPrefix)return i.push(...a.commandPrefix.split(` `)),i.join(` `);break}else t[e]&&!t[e].startsWith(`-`)&&!_b.test(t[e])&&i.push(t[e])}}let a=t.find(e=>!e.startsWith(`-`)&&!gb.test(e)&&!_b.test(e));if(!a)return e;let o=await xb(t.slice(t.indexOf(a)).join(` `),n+1,r+1);return o?.commandPrefix?`${e} ${o.commandPrefix}`:null}async function Cb(e,t){let n=aa(e);if(n.length<=1){let t=await xb(e);return t?.commandPrefix?[t.commandPrefix]:[]}let r=[];for(let e of n){let n=e.trim();if(t?.(n))continue;let i=await xb(n);i?.commandPrefix&&r.push(i.commandPrefix)}if(r.length===0)return[];let i=new Map;for(let e of r){let t=e.split(` `)[0],n=i.get(t);n?n.push(e):i.set(t,[e])}let a=[];for(let[,e]of i)a.push(wb(e));return a}function wb(e){if(e.length===0)return``;if(e.length===1)return e[0];let t=e[0].split(` `),n=t.length;for(let r=1;r<e.length;r++){let i=e[r].split(` `),a=0;for(;a<n&&a<i.length&&t[a]===i[a];)a++;n=a}return t.slice(0,Math.max(1,n)).join(` `)}async function Tb(e){Z(`tengu_unary_event`,{event:e.event,completion_type:e.completion_type,language_name:await e.metadata.language_name,message_id:e.metadata.message_id,platform:e.metadata.platform,...e.metadata.hasFeedback!==void 0&&{hasFeedback:e.metadata.hasFeedback}})}var Eb=t((()=>{bp()}));Ud(),va(),bp(),Xo(),gf(),q(),Cf(),Eb();function Db(e){switch(e.behavior){case`allow`:return`allow`;case`ask`:{let t=ld(e.suggestions),n=t.length>0?t.map(e=>lf(e)).join(`, `):`none`;return`ask: ${e.message},
|
|
14
|
+
suggestions: ${n}
|
|
15
|
+
reason: ${Ob(e.decisionReason)}`}case`deny`:return`deny: ${e.message},
|
|
16
|
+
reason: ${Ob(e.decisionReason)}`;case`passthrough`:{let t=ld(e.suggestions),n=t.length>0?t.map(e=>lf(e)).join(`, `):`none`;return`passthrough: ${e.message},
|
|
17
|
+
suggestions: ${n}
|
|
18
|
+
reason: ${Ob(e.decisionReason)}`}}}function Ob(e){if(!e)return`No decision reason`;if(e.type===`classifier`)return`Classifier: ${e.classifier}, Reason: ${e.reason}`;switch(e.type){case`rule`:return`Rule: ${lf(e.rule.ruleValue)}`;case`mode`:return`Mode: ${e.mode}`;case`subcommandResults`:return`Subcommand Results: ${Array.from(e.reasons.entries()).map(([e,t])=>`${e}: ${Db(t)}`).join(`,
|
|
19
|
+
`)}`;case`permissionPromptTool`:return`Permission Tool: ${e.permissionPromptToolName}, Result: ${sf(e.toolResult)}`;case`hook`:return`Hook: ${e.hookName}${e.reason?`, Reason: ${e.reason}`:``}`;case`workingDir`:return`Working Directory: ${e.reason}`;case`safetyCheck`:return`Safety check: ${e.reason}`;case`other`:return`Other: ${e.reason}`;default:return sf(e,null,2)}}function kb(e,t){let n=Vr(),r=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{if(r.current!==e.toolUseID){if(r.current=e.toolUseID,n(e=>({...e,attribution:{...e.attribution,permissionPromptCount:e.attribution.permissionPromptCount+1}})),Z(`tengu_tool_use_show_permission_request`,{messageID:e.assistantMessage.message.id,toolName:Km(e.tool.name),isMcp:e.tool.isMcp??!1,decisionReasonType:e.permissionResult.decisionReason?.type,sandboxEnabled:yd.isSandboxingEnabled()}),process.env.USER_TYPE===`ant`){let t=e.permissionResult;e.tool.name===ds.name&&t.behavior===`ask`&&!Ka(t.suggestions)&&Z(`tengu_internal_tool_use_permission_request_no_always_allow`,{messageID:e.assistantMessage.message.id,toolName:Km(e.tool.name),isMcp:e.tool.isMcp??!1,decisionReasonType:t.decisionReason?.type??`unknown`,sandboxEnabled:yd.isSandboxingEnabled(),decisionReasonDetails:Ob(t.decisionReason)})}if(process.env.USER_TYPE===`ant`){let t=ds.inputSchema.safeParse(e.input);if(e.tool.name===ds.name&&e.permissionResult.behavior===`ask`&&t.success){let n=[t.data.command];try{n=aa(t.data.command)}catch{}Z(`tengu_internal_bash_tool_use_permission_request`,{parts:sf(n),input:sf(e.input),decisionReasonType:e.permissionResult.decisionReason?.type,decisionReason:Ob(e.permissionResult.decisionReason)})}}Tb({completion_type:t.completion_type,event:`response`,metadata:{language_name:t.language_name,message_id:e.assistantMessage.message.id,platform:mf.platform}})}},[e,t,n])}L(),u(),B(),q(),kn(),gf(),v_(),Oa();function Ab(e){if(e.type===`classifier`)return`${H.bold(e.classifier)} classifier: ${e.reason}`;switch(e.type){case`rule`:return`${H.bold(lf(e.rule.ruleValue))} rule from ${Ef(e.rule.source)}`;case`mode`:return`${bf(e.mode)} mode`;case`sandboxOverride`:return`Requires permission to bypass sandbox`;case`workingDir`:return e.reason;case`safetyCheck`:case`other`:return e.reason;case`permissionPromptTool`:return`${H.bold(e.permissionPromptToolName)} permission prompt tool`;case`hook`:return e.reason?`${H.bold(e.hookName)} hook: ${e.reason}`:`${H.bold(e.hookName)} hook`;case`asyncAgent`:return e.reason;default:return``}}function jb({title:e,decisionReason:t}){let[n]=y();function r(){switch(t.type){case`subcommandResults`:return(0,$.jsx)(b,{flexDirection:`column`,children:Array.from(t.reasons.entries()).map(([e,t])=>(0,$.jsxs)(b,{flexDirection:`column`,children:[(0,$.jsxs)(T,{children:[t.behavior===`allow`?ce(`success`,n)(d.tick):ce(`error`,n)(d.cross),` `,e]}),t.decisionReason!==void 0&&t.decisionReason.type!==`subcommandResults`&&(0,$.jsxs)(T,{children:[(0,$.jsxs)(T,{dimColor:!0,children:[` `,`⎿`,` `]}),(0,$.jsx)(g,{children:Ab(t.decisionReason)})]}),t.behavior===`ask`&&(0,$.jsx)(Mb,{suggestions:t.suggestions})]},e))});default:return(0,$.jsx)(T,{children:(0,$.jsx)(g,{children:Ab(t)})})}}return(0,$.jsxs)(b,{flexDirection:`column`,children:[e&&(0,$.jsx)(T,{children:e}),r()]})}function Mb({suggestions:e}){let t=ld(e);return t.length===0?null:(0,$.jsxs)(T,{children:[(0,$.jsxs)(T,{dimColor:!0,children:[` `,`⎿`,` `]}),`Suggested rules: `,(0,$.jsx)(g,{children:t.map(e=>H.bold(lf(e))).join(`, `)})]})}function Nb(e){return e?e.flatMap(e=>{switch(e.type){case`addDirectories`:return e.directories;default:return[]}}):[]}function Pb(e){if(!e)return;let t=e.findLast(e=>e.type===`setMode`);return t?.type===`setMode`?t.mode:void 0}function Fb({suggestions:e,width:t}){if(!e||e.length===0)return(0,$.jsxs)(b,{flexDirection:`row`,children:[(0,$.jsx)(b,{justifyContent:`flex-end`,minWidth:t,children:(0,$.jsx)(T,{dimColor:!0,children:`Suggestions `})}),(0,$.jsx)(T,{children:`None`})]});let n=ld(e),r=Nb(e),i=Pb(e);return n.length===0&&r.length===0&&!i?(0,$.jsxs)(b,{flexDirection:`row`,children:[(0,$.jsx)(b,{justifyContent:`flex-end`,minWidth:t,children:(0,$.jsx)(T,{dimColor:!0,children:`Suggestion `})}),(0,$.jsx)(T,{children:`None`})]}):(0,$.jsxs)(b,{flexDirection:`column`,children:[(0,$.jsxs)(b,{flexDirection:`row`,children:[(0,$.jsx)(b,{justifyContent:`flex-end`,minWidth:t,children:(0,$.jsx)(T,{dimColor:!0,children:`Suggestions `})}),(0,$.jsx)(T,{children:` `})]}),n.length>0&&(0,$.jsxs)(b,{flexDirection:`row`,children:[(0,$.jsx)(b,{justifyContent:`flex-end`,minWidth:t,children:(0,$.jsx)(T,{dimColor:!0,children:` Rules `})}),(0,$.jsx)(b,{flexDirection:`column`,children:n.map((e,t)=>(0,$.jsxs)(T,{children:[d.bullet,` `,lf(e)]},t))})]}),r.length>0&&(0,$.jsxs)(b,{flexDirection:`row`,children:[(0,$.jsx)(b,{justifyContent:`flex-end`,minWidth:t,children:(0,$.jsx)(T,{dimColor:!0,children:` Directories `})}),(0,$.jsx)(b,{flexDirection:`column`,children:r.map((e,t)=>(0,$.jsxs)(T,{children:[d.bullet,` `,e]},t))})]}),i&&(0,$.jsxs)(b,{flexDirection:`row`,children:[(0,$.jsx)(b,{justifyContent:`flex-end`,minWidth:t,children:(0,$.jsx)(T,{dimColor:!0,children:` Mode `})}),(0,$.jsx)(T,{children:bf(i)})]})]})}function Ib({permissionResult:e,toolName:t}){let n=J(e=>e.toolPermissionContext),r=e.decisionReason,i=`suggestions`in e?e.suggestions:void 0,a=(0,Q.useMemo)(()=>{let e=yd.isSandboxingEnabled()&&yd.isAutoAllowBashIfSandboxedEnabled(),r=y_(n,{sandboxAutoAllowEnabled:e}),a=ld(i);return a.length>0?r.filter(e=>a.some(t=>t.toolName===e.rule.ruleValue.toolName&&t.ruleContent===e.rule.ruleValue.ruleContent)):t?r.filter(e=>e.rule.ruleValue.toolName===t):r},[n,t,i]);return(0,$.jsxs)(b,{flexDirection:`column`,children:[(0,$.jsxs)(b,{flexDirection:`row`,children:[(0,$.jsx)(b,{justifyContent:`flex-end`,minWidth:10,children:(0,$.jsx)(T,{dimColor:!0,children:`Behavior `})}),(0,$.jsx)(T,{children:e.behavior})]}),e.behavior!==`allow`&&(0,$.jsxs)(b,{flexDirection:`row`,children:[(0,$.jsx)(b,{justifyContent:`flex-end`,minWidth:10,children:(0,$.jsx)(T,{dimColor:!0,children:`Message `})}),(0,$.jsx)(T,{children:e.message})]}),(0,$.jsxs)(b,{flexDirection:`row`,children:[(0,$.jsx)(b,{justifyContent:`flex-end`,minWidth:10,children:(0,$.jsx)(T,{dimColor:!0,children:`Reason `})}),r===void 0?(0,$.jsx)(T,{children:`undefined`}):(0,$.jsx)(jb,{decisionReason:r})]}),(0,$.jsx)(Fb,{suggestions:i,width:10}),a.length>0&&(0,$.jsxs)(b,{flexDirection:`column`,marginTop:1,children:[(0,$.jsxs)(T,{color:`warning`,children:[d.warning,` Unreachable Rules (`,a.length,`)`]}),a.map((e,t)=>(0,$.jsxs)(b,{flexDirection:`column`,marginLeft:2,children:[(0,$.jsx)(T,{color:`warning`,children:lf(e.rule.ruleValue)}),(0,$.jsxs)(T,{dimColor:!0,children:[` `,e.reason]}),(0,$.jsxs)(T,{dimColor:!0,children:[` `,`Fix: `,e.fix]})]},t))]})]})}Ee(),bp(),Gm(),Rf(),tf(),cf(),Oe(),np(),Sh(),Xi(),Zd();var Lb={LOW:1,MEDIUM:2,HIGH:3},Rb=1,zb=2,Bb=3,Vb=`Analyze shell commands and explain what they do, why you're running them, and potential risks.`,Hb={name:`explain_command`,description:`Provide an explanation of a shell command`,input_schema:{type:`object`,properties:{explanation:{type:`string`,description:`What this command does (1-2 sentences)`},reasoning:{type:`string`,description:`Why YOU are running this command. Start with "I" - e.g. "I need to check the file contents"`},risk:{type:`string`,description:`What could go wrong, under 15 words`},riskLevel:{type:`string`,enum:[`LOW`,`MEDIUM`,`HIGH`],description:`LOW (safe dev workflows), MEDIUM (recoverable changes), HIGH (dangerous/irreversible)`}},required:[`explanation`,`reasoning`,`risk`,`riskLevel`]}},Ub=Te(()=>ye({riskLevel:we([`LOW`,`MEDIUM`,`HIGH`]),explanation:be(),reasoning:be(),risk:be()}));function Wb(e){if(typeof e==`string`)return e;try{return sf(e,null,2)}catch{return String(e)}}function Gb(e,t=1e3){let n=e.filter(e=>e.type===`assistant`).slice(-3),r=[],i=0;for(let e of n.reverse()){let n=(Array.isArray(e.message.content)?e.message.content:[]).filter(e=>e.type===`text`).map(e=>`text`in e?e.text:``).join(` `);if(n&&i<t){let e=t-i,a=n.length>e?n.slice(0,e)+`...`:n;r.unshift(a),i+=a.length}}return r.join(`
|
|
20
|
+
|
|
21
|
+
`)}function Kb(){return Lf().permissionExplainerEnabled!==!1}async function qb({toolName:e,toolInput:t,toolDescription:n,messages:r,signal:i}){if(!Kb())return null;let a=Date.now();try{let o=Wb(t),s=r?.length?Gb(r):``,c=`Tool: ${e}
|
|
22
|
+
${n?`Description: ${n}\n`:``}
|
|
23
|
+
Input:
|
|
24
|
+
${o}
|
|
25
|
+
${s?`\nRecent conversation context:\n${s}`:``}
|
|
26
|
+
|
|
27
|
+
Explain this command in context.`,l=await Ln({model:xh()?um():Tm(),system:Vb,messages:[{role:`user`,content:c}],tools:[Hb],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: ${sf(d.input).slice(0,500)}`);let t=Ub().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:Km(e),risk_level:Lb[n.riskLevel],latency_ms:u}),Y(`Permission explainer: ${n.riskLevel} risk for ${e} (${u}ms)`),n}}return Z(`tengu_permission_explainer_error`,{tool_name:Km(e),error_type:Rb,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: ${Jd(t)}`),X(t),Z(`tengu_permission_explainer_error`,{tool_name:Km(e),error_type:t instanceof Error&&t.name===`AbortError`?zb:Bb,latency_ms:n}),null)}}B(),Ah(),bp();var Jb=`Loading explanation…`;function Yb(){let[e,t]=Md(`responding`,Jb,!1);return(0,$.jsx)(b,{ref:e,children:(0,$.jsx)(T,{children:Jb.split(``).map((e,n)=>(0,$.jsx)(Ea,{char:e,index:n,glimmerIndex:t,messageColor:`inactive`,shimmerColor:`text`},n))})})}function Xb(e){switch(e){case`LOW`:return`success`;case`MEDIUM`:return`warning`;case`HIGH`:return`error`}}function Zb(e){switch(e){case`LOW`:return`Low risk`;case`MEDIUM`:return`Med risk`;case`HIGH`:return`High risk`}}function Qb(e){return qb({toolName:e.toolName,toolInput:e.toolInput,toolDescription:e.toolDescription,messages:e.messages,signal:new AbortController().signal}).catch(()=>null)}function $b(e){let t=Kb(),[n,r]=(0,Q.useState)(!1),[i,a]=(0,Q.useState)(null);return A(`confirm:toggleExplanation`,()=>{n||(Z(`tengu_permission_explainer_shortcut_used`,{}),i||a(Qb(e))),r(e=>!e)},{context:`Confirmation`,isActive:t}),{visible:n,enabled:t,promise:i}}function ex({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:Xb(t.riskLevel),children:[Zb(t.riskLevel),`:`]}),(0,$.jsxs)(T,{children:[` `,t.risk]})]})})]}):(0,$.jsx)(b,{marginTop:1,children:(0,$.jsx)(T,{dimColor:!0,children:`Explanation unavailable`})})}function tx({visible:e,promise:t}){return!e||!t?null:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(b,{marginTop:1,children:(0,$.jsx)(Yb,{})}),children:(0,$.jsx)(ex,{promise:t})})}ms(),B(),np(),Pd(),Eo();function nx(e){let[t]=(0,Q.useState)(()=>ax(e.file_path,e.edits));return(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(ix,{placeholder:!0}),children:(0,$.jsx)(rx,{promise:t,file_path:e.file_path})})}function rx({promise:e,file_path:t}){let{patch:n,firstLine:r,fileContent:i}=(0,Q.use)(e),{columns:a}=de();return(0,$.jsx)(ix,{children:(0,$.jsx)(Qa,{hunks:n,dim:!1,width:a,filePath:t,firstLine:r,fileContent:i})})}function ix({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 ax(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 ox(e,[r]);try{let t=await Ht(e);if(t===null)return ox(e,n);try{if(!r||r.old_string===``){let r=await mo(t);return r===null?ox(e,n):{patch:wt({filePath:e,fileContents:r,edits:n.map(e=>sx(r,e))}),firstLine:Fp(r),fileContent:r}}let i=await or(t,r.old_string,3);if(i.truncated||i.content===``)return ox(e,[r]);let a=sx(i.content,r);return{patch:ca(wt({filePath:e,fileContents:i.content,edits:[a]}),i.lineOffset-1),firstLine:i.lineOffset===1?Fp(i.content):null,fileContent:i.content}}finally{await t.close()}}catch(t){return X(t),ox(e,n)}}function ox(e,t){return{patch:t.flatMap(t=>wt({filePath:e,fileContents:t.old_string,edits:[t]})),firstLine:null,fileContent:void 0}}function sx(e,t){let n=Yi(e,t.old_string)||t.old_string;return{...t,old_string:n}}Wr(),bp(),ni(),Rf(),Iu(),cf(),mn(),np();function cx({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)(()=>Ov().slice(0,6),[]),l=(0,Q.useMemo)(()=>`✻ [Work Mate] ${vv(n)} (${c}) ⧉`,[n,c]),u=W(t.options.mcpClients)&&Lf().diffTool===`auto`&&!n.endsWith(`.ipynb`),d=tn(t.options.mcpClients)??`IDE`;async function f(){if(u)try{Z(`tengu_ext_will_show_diff`,{});let{oldContent:o,newContent:s}=await ux(n,r,t,l);if(a.current)return;Z(`tengu_ext_diff_accepted`,{});let c=lx(n,o,s,i);if(c.length===0){Z(`tengu_ext_diff_rejected`,{});let i=Ma(t.options.mcpClients);i&&await dx(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=Ma(t.options.mcpClients);return e?dx(l,e):Promise.resolve()},showingDiffInIDE:u&&!o,ideName:d,hasError:o}}function lx(e,t,n,r){let i=r===`single`,a=Qs({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.`)),Fn(a))}async function ux(e,t,n,r){let i=!1,a=up(e),o=``;try{o=pp(a)}catch(e){if(!Qd(e))throw e}async function s(){if(!i){i=!0;try{await dx(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=Ma(n.options.mcpClients);try{let{updatedFile:e}=_r({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;sp()===`wsl`&&i&&process.env.WSL_DISTRO_NAME&&(n=new ba(process.env.WSL_DISTRO_NAME).toIDEPath(a));let l=await mu(`openDiff`,{old_file_path:n,new_file_path:n,new_file_contents:e,tab_name:r},c),u=Array.isArray(l)?l:[l];if(mx(u))return s(),{oldContent:o,newContent:u[1].text};if(fx(u))return s(),{oldContent:o,newContent:e};if(px(u))return s(),{oldContent:o,newContent:o};throw Error(`Not accepted`)}catch(e){throw X(e),s(),e}}async function dx(e,t){try{if(!t||t.type!==`connected`)throw Error(`IDE client not available`);await mu(`close_tab`,{tab_name:e},t)}catch(e){X(e)}}function fx(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 px(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 mx(e){return Array.isArray(e)&&e[0]?.type===`text`&&e[0].text===`FILE_SAVED`&&typeof e[1].text==`string`}B(),Wd(),mn(),dc();function hx({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:Sv(Gd(),a).startsWith(`..`)?`This will modify ${a} (outside working directory) via a symlink`:`Symlink target: ${a}`}),vi()&&(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:vv(r)}),`?`]}),(0,$.jsx)(eu,{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`]})})]})})}at(),B(),lp();function gx(e){let t=up(e),n=up(`${ut()}/.claude`),r=Rd(t),i=Rd(n);return r.startsWith(i+Cv.toLowerCase())||r.startsWith(i+`/`)}function _x(e){let t=up(e),n=xv(hv(),`.claude`),r=Rd(t),i=Rd(n);return r.startsWith(i+Cv.toLowerCase())||r.startsWith(i+`/`)}function vx({filePath:e,toolPermissionContext:t,operationType:n=`write`,onRejectFeedbackChange:r,onAcceptFeedbackChange:i,yesInputMode:a=!1,noInputMode:o=!1}){let s=[],c=yn(`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=gx(e),d=_x(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=vv(fp(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}bp(),Gm(),Cf(),oi(),Eb();function yx(e,t,n,r,i){Tb({completion_type:t,event:e,metadata:{language_name:n,message_id:r,platform:mf.platform,hasFeedback:i??!1}})}function bx(e,t){let{messageId:n,toolUseConfirm:r,onDone:i,completionType:a,languageName:o}=e;yx(`accept`,a,o,n),Z(`tengu_accept_submitted`,{toolName:Km(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 xx(e,t){let{messageId:n,path:r,toolUseConfirm:i,toolPermissionContext:a,onDone:o,completionType:s,languageName:c,operationType:l}=e;if(yx(`accept`,s,c,n),t?.scope===`claude-folder`||t?.scope===`global-claude-folder`){let e=[{type:`addRules`,rules:[{toolName:zm,ruleContent:t.scope===`global-claude-folder`?Hm:Rm}],behavior:`allow`,destination:`session`}];o(),i.onAllow(i.input,e);return}let u=r?$i(r,l,a):[];o(),i.onAllow(i.input,u)}function Sx(e,t){let{messageId:n,toolUseConfirm:r,onDone:i,onReject:a,completionType:o,languageName:s}=e;yx(`reject`,o,s,n,t?.hasFeedback),Z(`tengu_reject_submitted`,{toolName:Km(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 Cx={"accept-once":bx,"accept-session":xx,reject:Sx};q(),Ah(),bp(),Gm();function wx({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)(()=>vx({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=Cx[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:Km(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(),ao(),Wd(),lp(),dc();function Tx({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?ur(l):`none`),[p,l]);kb(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=up(l),{resolvedPath:t,isSymlink:n}=ef(nf(),e);return n?t:null},[l,d]),g=wx({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:ee,ideName:A}=cx(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`}),j=(e,t)=>{k?.(),g.onChange(e,D,t?.trim())};if(ee&&O&&l)return(0,$.jsx)(hx,{onChange:(e,t,n)=>j(e,n),options:_,filePath:l,input:D,ideName:A,symlinkTarget:h,rejectFeedback:y,acceptFeedback:v,setFocusedOption:x,onInputModeToggle:S,focusedOption:C,yesInputMode:w,noInputMode:E});let M=h!=null&&Sv(Gd(),h).startsWith(`..`);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(Yg,{title:i,subtitle:a,innerPaddingX:0,children:[h?(0,$.jsx)(b,{paddingX:1,marginBottom:1,children:(0,$.jsx)(T,{color:`warning`,children:M?`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)(eu,{options:_,inlineDescriptions:!0,onChange:e=>{let t=_.find(t=>t.value===e);if(t){if(t.option.type===`reject`){let e=y.trim();j(t.option,e||void 0);return}if(t.option.type===`accept-once`){let e=v.trim();j(t.option,e||void 0);return}j(t.option)}},onCancel:()=>j({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`]})})]})}Wd(),cf(),mp(),af(),B(),ed();function Ex({sedInfo:e,...t}){let{filePath:n}=e;return(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Dx,{sedInfo:e,contentPromise:(0,Q.useMemo)(()=>(async()=>{let e=hp(n);return{oldContent:(await nf().readFile(n,{encoding:e})).replaceAll(`\r
|
|
28
|
+
`,`
|
|
29
|
+
`),fileExists:!0}})().catch(e=>{if(!Qd(e))throw e;return{oldContent:``,fileExists:!1}}),[n]),...t})})}function Dx({sedInfo:e,contentPromise:t,...n}){let{filePath:r}=e,{oldContent:i,fileExists:a}=(0,Q.use)(t),o=(0,Q.useMemo)(()=>Ca(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)(Tx,{toolUseConfirm:n.toolUseConfirm,toolUseContext:n.toolUseContext,onDone:n.onDone,onReject:n.onReject,title:`Edit file`,subtitle:Sv(Gd(),r),question:(0,$.jsxs)(T,{children:[`Do you want to make this edit to `,(0,$.jsx)(T,{bold:!0,children:vv(r)}),`?`]}),content:s.length>0?(0,$.jsx)(nx,{file_path:r,edits:s}):(0,$.jsx)(T,{dimColor:!0,children:c}),path:r,completionType:`str_replace_single`,parseInput:e=>({...ds.inputSchema.parse(e),_simulatedSedEdit:{filePath:r,newContent:o}})})}Cf(),Eb();function Ox(e,{assistantMessage:{message:{id:t}}},n,r){Tb({completion_type:e,event:n,metadata:{language_name:`none`,message_id:t,platform:Sf(),hasFeedback:r??!1}})}bp(),Gm(),q();function kx({toolUseConfirm:e,onDone:t,onReject:n,explainerVisible:r}){let i=Vr(),[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:Km(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}}))),Ox(`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}}at(),B();function Ax(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 jx(e){return e.join(`, `).length>50?`similar`:Ax(e)}function Mx(e){if(e.length===0)return``;let t=e.map(e=>vv(e)||e);return t.length===1?(0,$.jsxs)(T,{children:[(0,$.jsx)(T,{bold:!0,children:t[0]}),Cv]}):t.length===2?(0,$.jsxs)(T,{children:[(0,$.jsx)(T,{bold:!0,children:t[0]}),Cv,` and `,(0,$.jsx)(T,{bold:!0,children:t[1]}),Cv]}):(0,$.jsxs)(T,{children:[(0,$.jsx)(T,{bold:!0,children:t[0]}),Cv,`, `,(0,$.jsx)(T,{bold:!0,children:t[1]}),Cv,` and `,e.length-2,` more`]})}function Nx(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=_d(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:vv(e)||e}),Cv,` from this project`]})}return(0,$.jsxs)(T,{children:[`Yes, allow reading from `,Mx(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:vv(e)||e}),Cv,` from this project`]})}return(0,$.jsxs)(T,{children:[`Yes, and always allow access to `,Mx(o),` from this project`]})}if(d&&!l&&!u)return(0,$.jsxs)(T,{children:[`Yes, and don't ask again for `,jx(c),` commands in `,(0,$.jsx)(T,{bold:!0,children:ut()})]});if((l||u)&&!d){let e=[...o,...s];if(l&&u)return(0,$.jsxs)(T,{children:[`Yes, and always allow access to `,Mx(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 `,Mx(e),` and `,jx(c),` commands`]}):(0,$.jsxs)(T,{children:[`Yes, and allow `,Mx(e),` access and `,jx(c),` commands`]})}return null}Xo();function Px(e,t){let n=e.toLowerCase().trimEnd();return t.some(e=>e.toLowerCase().trimEnd()===n)}function Fx(e){let{commandWithoutRedirections:t,redirections:n}=Fo(e);return n.length>0?t:e}function Ix({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`}),Si()){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=Nx(e,Wm,Fx);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&&Ta()&&i&&!o&&!Px(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(),Ah(),bp(),Gm(),q(),ed(),Bd(),li(),kn(),Oa(),Ud(),va(),qg(),Ky();function Lx(e){let{toolUseConfirm:t,toolUseContext:n,onDone:r,onReject:i,verbose:a}=e,{command:o,description:s}=ds.inputSchema.parse(t.input),c=Kt(o);return c?(0,$.jsx)(Ex,{toolUseConfirm:t,toolUseContext:n,onDone:r,onReject:i,verbose:a,sedInfo:c}):(0,$.jsx)(Rx,{toolUseConfirm:t,toolUseContext:n,onDone:r,onReject:i,verbose:a,command:o,description:s})}function Rx({toolUseConfirm:e,toolUseContext:t,onDone:n,onReject:r,verbose:i,command:a,description:o}){let[s]=y(),c=J(e=>e.toolPermissionContext),l=$b({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}=kx({toolUseConfirm:e,onDone:n,onReject:r,explainerVisible:l.visible}),[w,E]=(0,Q.useState)(!1),[D,O]=(0,Q.useState)(o||``),[k,ee]=(0,Q.useState)(!o?.trim());(0,Q.useEffect)(()=>{if(!Ta())return;let e=new AbortController;return Un(a,o,e.signal).then(t=>{t&&!e.signal.aborted&&(O(t),ee(!1))}).catch(()=>{}),()=>e.abort()},[a,o]);let j=e.permissionResult.decisionReason?.type===`subcommandResults`,[M,te]=(0,Q.useState)(()=>{if(j){let t=ld(`suggestions`in e.permissionResult?e.permissionResult.suggestions:void 0).filter(e=>e.toolName===ds.name&&e.ruleContent);return t.length===1?t[0].ruleContent:void 0}let t=Cc(a);if(t)return`${t}:*`;let n=Sl(a);return n?`${n}:*`:a}),N=(0,Q.useRef)(!1),P=(0,Q.useCallback)(e=>{N.current=!0,te(e)},[]);(0,Q.useEffect)(()=>{if(j)return;let e=!1;return Cb(a,e=>ds.isReadOnly({command:e})).then(t=>{e||N.current||t.length>0&&te(`${t[0]}:*`)}).catch(()=>{}),()=>{e=!0}},[a,j]);let[F]=(0,Q.useState)(!1),{destructiveWarning:ne,sandboxingEnabled:re,isSandboxed:I}=(0,Q.useMemo)(()=>{let t=yd.isSandboxingEnabled();return{destructiveWarning:null,sandboxingEnabled:t,isSandboxed:t&&Er(e.input)}},[a,e.input]);kb(e,(0,Q.useMemo)(()=>({completion_type:`tool_use_single`,language_name:`none`}),[]));let L=(0,Q.useMemo)(()=>wr(c),[c]),ie=(0,Q.useMemo)(()=>Ix({suggestions:e.permissionResult.behavior===`ask`?e.permissionResult.suggestions:void 0,decisionReason:e.permissionResult.decisionReason,onRejectFeedbackChange:_,onAcceptFeedbackChange:g,onClassifierDescriptionChange:O,classifierDescription:D,initialClassifierDescriptionEmpty:k,existingAllowDescriptions:L,yesInputMode:u,noInputMode:d,editablePrefix:M,onEditablePrefixChange:P}),[e,D,k,L,u,d,M,P]);A(`permission:toggleDebug`,(0,Q.useCallback)(()=>{E(e=>!e)},[]),{context:`Confirmation`}),A(`confirm:no`,(0,Q.useCallback)(()=>{e.onDismissCheckmark?.()},[e]),{context:`Confirmation`,isActive:!1});function R(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=Km(e.tool.name);if(t===`yes-prefix-edited`){let t=(M??``).trim();if(Ox(`tool_use_single`,e,`accept`),!t)e.onAllow(e.input,[]);else{let n=[{type:`addRules`,rules:[{toolName:ds.name,ruleContent:t}],behavior:`allow`,destination:`localSettings`}];e.onAllow(e.input,n)}n();return}switch(t){case`yes`:{let t=m.trim();Ox(`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`:{Ox(`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)(Yg,{title:re&&!I?`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:ds.renderToolUseMessage({command:a,description:o},{theme:s,verbose:!0})}),!l.visible&&(0,$.jsx)(T,{dimColor:!0,children:e.description}),(0,$.jsx)(tx,{visible:l.visible,promise:l.promise})]}),w?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ib,{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)(Wy,{permissionResult:e.permissionResult,toolType:`command`}),ne&&(0,$.jsx)(b,{marginBottom:1,children:(0,$.jsx)(T,{color:`warning`,dimColor:!1,children:ne})}),(0,$.jsx)(T,{dimColor:!1,children:`Do you want to proceed?`}),(0,$.jsx)(eu,{options:ie,isDisabled:!1,inlineDescriptions:!0,onChange:R,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`})]})]})]})}at(),B(),bp(),q(),gr(),dc(),qg();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:ti(),entryMethod:`tool`}),Qe(r,`plan`),t(),e.onAllow({},[{type:`setMode`,mode:`plan`,destination:`session`}])):(t(),n(),e.onReject())}return(0,$.jsx)(Yg,{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)(eu,{options:[{label:`Yes, enter plan mode`,value:`yes`},{label:`No, start implementing now`,value:`no`}],onChange:i,onCancel:()=>i(`no`)})})]})})}u(),Rt(),bp(),q(),at(),L_(),wl(),B(),Rg(),mn(),np(),Ki(),zd(),rm(),li(),df(),Xt(),gr(),rc(),Hg(),Jc(),dc(),qg(),Ky(),qs(),il();var Bx=(Xn(),e(To));function Vx(e,t){let n=[{type:`setMode`,mode:ff(e),destination:`session`}];return Ta()&&t&&t.length>0&&n.push({type:`addRules`,rules:t.map(e=>({toolName:e.tool,ruleContent:ra(e.prompt)})),behavior:`allow`,destination:`session`}),n}function Hx(e,t,n){mt()||Of()?.cleanupPeriodDays===0||!n&&xl(st())||R_([Pa({content:e.slice(0,1e3)})],new AbortController().signal).then(async e=>{if(!e||xl(st()))return;let n=st(),r=Tn();await Zu(n,e,r,`auto`),await vc(n,e,r,`auto`),t(t=>t.standaloneAgentContext?.name===e?t:{...t,standaloneAgentContext:{...t.standaloneAgentContext,name:e}})}).catch(X)}function Ux({toolUseConfirm:e,onDone:t,onReject:n,setStickyFooter:r}){let i=J(e=>e.toolPermissionContext),a=Vr(),o=qn(),{addNotification:s}=lo(),[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)(()=>Wx({showClearContext:m,showUltraplan:_,usedPercent:m?Gx(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};An(o),It(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===Mm,ee=k?void 0:e.input.plan,A=k?ol():void 0,j=e.input.allowedPrompts,M=ee??Ps(),te=!M||M.trim()===``,[N]=(0,Q.useState)(()=>Pn()??void 0),[P,F]=(0,Q.useState)(()=>ee||(Ps()??`No plan found. Please write your plan to the plan file first.`)),[ne,re]=(0,Q.useState)(!1),[I,L]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{if(ne){let e=setTimeout(re,5e3,!1);return()=>clearTimeout(e)}},[ne]);let ie=e=>{if(e.ctrl&&e.key===`g`){e.preventDefault(),Z(`tengu_plan_external_editor_used`,{}),(async()=>{if(k&&A){let e=await Ug(A);e.error&&s({key:`external-editor-error`,text:e.error,color:`warning`,priority:`high`}),e.content!==null&&(e.content!==P&&L(!0),F(e.content),re(!0))}else{let e=await Bg(P);e.error&&s({key:`external-editor-error`,text:e.error,color:`warning`,priority:`high`}),e.content!==null&&e.content!==P&&(F(e.content),re(!0))}})();return}if(e.shift&&e.key===`tab`){e.preventDefault(),R(m?`yes-accept-edits`:`yes-accept-edits-keep-context`);return}};async function R(r){let s=c.trim(),l=s||void 0;if(r===`ultraplan`){Z(`tengu_plan_exit`,{planLengthChars:P.length,outcome:`ultraplan`,interviewPhaseEnabled:ti(),planStructureVariant:N}),t(),n(),e.onReject(`Plan being refined via Ultraplan — please wait for the result.`),fu({blurb:``,seedPlan:P,getAppState:o.getState,setAppState:o.setState,signal:new AbortController().signal}).then(e=>Fi({value:e,mode:`task-notification`})).catch(X);return}let u=k&&!I?{}:{plan:P};{let e=(r===`yes-resume-auto-mode`||r===`yes-auto-clear-context`)&&_n(),t=Bx?.isAutoModeActive()??!1;r!==`no`&&!e&&t&&(Bx?.setAutoModeActive(!1),Re(!0),a(e=>({...e,toolPermissionContext:{...di(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`&&Hx(P,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`&&_n()&&(i=`auto`,Bx?.setAutoModeActive(!0)),Z(`tengu_plan_exit`,{planLengthChars:P.length,outcome:r,clearContext:!0,interviewPhaseEnabled:ti(),planStructureVariant:N,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: ${Tn()}`,s=l?`\n\nUser feedback on this plan: ${l}`:``;a(e=>({...e,initialMessage:{message:{...Pa({content:`Implement the following plan:\n\n${P}${o}${s}`}),planContent:P},clearContext:!0,mode:i,allowedPrompts:j}})),Pe(!0),Ze(!0),t(),n(),e.onReject();return}if(r===`yes-resume-auto-mode`&&_n()){Z(`tengu_plan_exit`,{planLengthChars:P.length,outcome:r,clearContext:!1,interviewPhaseEnabled:ti(),planStructureVariant:N,hasFeedback:!!l}),Pe(!0),Ze(!0),Bx?.setAutoModeActive(!0),a(e=>({...e,toolPermissionContext:Ci({...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:P.length,outcome:r,clearContext:!1,interviewPhaseEnabled:ti(),planStructureVariant:N,hasFeedback:!!l}),Pe(!0),Ze(!0),t(),e.onAllow(u,Vx(f,j),l);return}let p={"yes-bypass-permissions":`bypassPermissions`,"yes-accept-edits":`acceptEdits`}[r];if(p){Z(`tengu_plan_exit`,{planLengthChars:P.length,outcome:r,interviewPhaseEnabled:ti(),planStructureVariant:N,hasFeedback:!!l}),Pe(!0),Ze(!0),t(),e.onAllow(u,Vx(p,j),l);return}if(r===`no`){if(!s&&!O)return;Z(`tengu_plan_exit`,{planLengthChars:P.length,outcome:`no`,interviewPhaseEnabled:ti(),planStructureVariant:N});let r;O&&(r=await Promise.all(D.map(async e=>(await Mu({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=zg(),ae=z?In(z):null,oe=(0,Q.useRef)(R);oe.current=R;let se=(0,Q.useRef)(void 0);se.current=()=>{Z(`tengu_plan_exit`,{planLengthChars:P.length,outcome:`no`,interviewPhaseEnabled:ti(),planStructureVariant:N}),t(),n(),e.onReject()};let ce=!te&&!!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)(eu,{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&&A&&(0,$.jsxs)(T,{dimColor:!0,children:[` · `,_p(A)]}),ne&&(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,A,ne]),te){function r(r){r===`yes`?(Z(`tengu_plan_exit`,{planLengthChars:0,outcome:`yes-default`,interviewPhaseEnabled:ti(),planStructureVariant:N}),(Bx?.isAutoModeActive()??!1)&&(Bx?.setAutoModeActive(!1),Re(!0),a(e=>({...e,toolPermissionContext:{...di(e.toolPermissionContext),prePlanMode:void 0}}))),Pe(!0),Ze(!0),t(),e.onAllow({},[{type:`setMode`,mode:`default`,destination:`session`}])):(Z(`tengu_plan_exit`,{planLengthChars:0,outcome:`no`,interviewPhaseEnabled:ti(),planStructureVariant:N}),t(),n(),e.onReject())}return(0,$.jsx)(Yg,{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)(eu,{options:[{label:`Yes`,value:`yes`},{label:`No`,value:`no`}],onChange:r,onCancel:()=>{Z(`tengu_plan_exit`,{planLengthChars:0,outcome:`no`,interviewPhaseEnabled:ti(),planStructureVariant:N}),t(),n(),e.onReject()}})})]})})}return(0,$.jsxs)(b,{flexDirection:`column`,tabIndex:0,autoFocus:!0,onKeyDown:ie,children:[(0,$.jsx)(Yg,{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)(Tu,{children:P})}),(0,$.jsxs)(b,{flexDirection:`column`,paddingX:1,children:[(0,$.jsx)(Wy,{permissionResult:e.permissionResult,toolType:`tool`}),Ta()&&j&&j.length>0&&(0,$.jsxs)(b,{flexDirection:`column`,marginBottom:1,children:[(0,$.jsx)(T,{bold:!0,children:`Requested permissions:`}),j.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)(eu,{options:C,onChange:R,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&&A&&(0,$.jsxs)(T,{dimColor:!0,children:[` · `,_p(A)]})]}),ne&&(0,$.jsxs)(b,{children:[(0,$.jsx)(T,{dimColor:!0,children:` · `}),(0,$.jsxs)(T,{color:`success`,children:[d.tick,`Plan saved!`]})]})]})]})}function Wx({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 Gx(e,t){if(!e)return null;let n=tm(fm({permissionMode:t,mainLoopModel:Tm(),exceeds200kTokens:!1}),pt()),{used:r}=Up({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 Kx({options:e,onSelect:t,onCancel:n,question:r=`Do you want to proceed?`,toolAnalyticsContext:i}){let a=Vr(),[o,s]=(0,qx.useState)(``),[c,l]=(0,qx.useState)(``),[u,d]=(0,qx.useState)(!1),[f,p]=(0,qx.useState)(!1),[m,h]=(0,qx.useState)(null),[g,_]=(0,qx.useState)(!1),[y,x]=(0,qx.useState)(!1),S=e.find(e=>e.value===m)?.feedbackConfig?.type,C=S===`accept`&&!u||S===`reject`&&!f,w=(0,qx.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=Yx[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,qx.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,qx.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,qx.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,qx.useCallback)(()=>{Z(`tengu_permission_request_escape`,{}),a(e=>({...e,attribution:{...e.attribution,escapeCount:e.attribution.escapeCount+1}})),n?.()},[n,a]);return(0,Jx.jsxs)(b,{flexDirection:`column`,children:[typeof r==`string`?(0,Jx.jsx)(T,{children:r}):r,(0,Jx.jsx)(eu,{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,Jx.jsx)(b,{marginTop:1,children:(0,Jx.jsxs)(T,{dimColor:!0,children:[`Esc to cancel`,C&&` · Tab to amend`]})})]})}var qx,Jx,Yx,Xx=t((()=>{qx=n(z(),1),B(),Ah(),bp(),q(),Cl(),Jx=ve(),Yx={accept:`tell Claude what to do next`,reject:`tell Claude what to do differently`}}));Eh(),Qc(),fr(),gn(),Ia(),Su(),Kh(),at(),B(),Gm(),Cf(),Xc(),Rp(),Eb(),qg(),Xx(),Ky();function Zx({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;kb(e,(0,Q.useMemo)(()=>({completion_type:`tool_use_single`,language_name:`none`}),[]));let s=(0,Q.useCallback)((r,i)=>{switch(r){case`yes`:Tb({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id,platform:mf.platform}}),e.onAllow(e.input,[],i),t();break;case`yes-dont-ask-again`:Tb({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id,platform:mf.platform}}),e.onAllow(e.input,[{type:`addRules`,rules:[{toolName:e.tool.name}],behavior:`allow`,destination:`localSettings`}]),t();break;case`no`:Tb({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id,platform:mf.platform}}),e.onReject(i),n(),t();break}},[e,t,n]),c=(0,Q.useCallback)(()=>{Tb({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id,platform:mf.platform}}),e.onReject(),n(),t()},[e,t,n]),l=ut(),u=Si(),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:Km(e.tool.name),isMcp:e.tool.isMcp??!1}),[e.tool.name,e.tool.isMcp]);return(0,$.jsxs)(Yg,{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:Ip(e.description,3)})]}),(0,$.jsxs)(b,{flexDirection:`column`,children:[(0,$.jsx)(Wy,{permissionResult:e.permissionResult,toolType:`tool`}),(0,$.jsx)(Kx,{options:d,onSelect:s,onCancel:c,toolAnalyticsContext:f})]})]})}function Qx(e,t,n,r){return{filePath:e,edits:[{old_string:t,new_string:n,replace_all:r}],editMode:`single`}}Wd(),B();var $x={getConfig:e=>Qx(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 eS(e){let t=e=>_i.inputSchema.parse(e),{file_path:n,old_string:r,new_string:i,replace_all:a}=t(e.toolUseConfirm.input);return(0,$.jsx)(Tx,{toolUseConfirm:e.toolUseConfirm,toolUseContext:e.toolUseContext,onDone:e.onDone,onReject:e.onReject,title:`Edit file`,subtitle:Sv(Gd(),n),question:(0,$.jsxs)(T,{children:[`Do you want to make this edit to `,(0,$.jsx)(T,{bold:!0,children:vv(n)}),`?`]}),content:(0,$.jsx)(nx,{file_path:n,edits:[{old_string:r,new_string:i,replace_all:a||!1}]}),path:n,completionType:`str_replace_single`,parseInput:t,ideDiffSupport:$x})}B();function tS(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 nS({toolUseConfirm:e,onDone:t,onReject:n,verbose:r,toolUseContext:i}){let[a]=y(),o=tS(e),s=e.tool.userFacingName(e.input),c=e.tool.isReadOnly(e.input),l=`${c?`Read`:`Edit`} file`;return o?(0,$.jsx)(Tx,{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)(Zx,{toolUseConfirm:e,toolUseContext:i,onDone:t,onReject:n,verbose:r})}ms(),B(),Iu(),Mr();function rS({file_path:e,content:t,fileExists:n,oldContent:r}){let{columns:i}=de(),a=(0,Q.useMemo)(()=>n?wt({filePath:e,fileContents:r,edits:[{old_string:r,new_string:t,replace_all:!1}]}):null,[n,e,r,t]),o=t.split(`
|
|
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?Nf(a.map(t=>(0,$.jsx)(Zn,{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)(au,{code:t||`(No content)`,filePath:e})})})}B(),Wd(),cf(),mp();var iS={getConfig:e=>{let t;try{t=pp(e.file_path)}catch(e){if(!Qd(e))throw e;t=``}return Qx(e.file_path,t,e.content,!1)},applyChanges:(e,t)=>{let n=t[0];return n?{...e,content:n.new_string}:e}};function aS(e){let t=e=>kt.inputSchema.parse(e),{file_path:n,content:r}=t(e.toolUseConfirm.input),{fileExists:i,oldContent:a}=(0,Q.useMemo)(()=>{try{return{fileExists:!0,oldContent:pp(n)}}catch(e){if(!Qd(e))throw e;return{fileExists:!1,oldContent:``}}},[n]),o=i?`overwrite`:`create`;return(0,$.jsx)(Tx,{toolUseConfirm:e.toolUseConfirm,toolUseContext:e.toolUseContext,onDone:e.onDone,onReject:e.onReject,title:i?`Overwrite file`:`Create file`,subtitle:Sv(Gd(),n),question:(0,$.jsxs)(T,{children:[`Do you want to `,o,` `,(0,$.jsx)(T,{bold:!0,children:vv(n)}),`?`]}),content:(0,$.jsx)(rS,{file_path:n,content:r,fileExists:i,oldContent:a}),path:n,completionType:`write_file_single`,parseInput:t,ideDiffSupport:iS})}B(),wf(),Wd(),Iu(),af(),Mr(),Wr();function oS(e){let t=(0,Q.useMemo)(()=>nf().readFile(e.notebook_path,{encoding:`utf-8`}).then(e=>yp(e)).catch(()=>null),[e.notebook_path]);return(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(sS,{...e,promise:t})})}function sS({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=ja(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:wt({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:Sv(Gd(),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)(au,{code:l,filePath:e})}):i===`insert`?(0,$.jsx)(b,{flexDirection:`column`,paddingLeft:2,children:(0,$.jsx)(au,{code:n,filePath:r===`markdown`?`file.md`:e})}):u?Nf(u.map(t=>(0,$.jsx)(Zn,{patch:t,dim:!1,width:o,filePath:e,firstLine:n.split(`
|
|
31
|
+
`)[0]??null,fileContent:l},t.newStart)),e=>(0,$.jsx)(k,{fromLeftEdge:!0,children:(0,$.jsx)(T,{dimColor:!0,children:`...`})},`ellipsis-${e}`)):(0,$.jsx)(au,{code:n,filePath:r===`markdown`?`file.md`:e})]})})}B(),np();function cS(e){let t=e=>{let t=Sd.inputSchema.safeParse(e);return t.success?t.data:(X(Error(`Failed to parse notebook edit input: ${t.error.message}`)),{notebook_path:``,new_source:``,cell_id:``})},n=t(e.toolUseConfirm.input),{notebook_path:r,edit_mode:i,cell_type:a}=n,o=a===`markdown`?`markdown`:`python`,s=i===`insert`?`insert this cell into`:i===`delete`?`delete this cell from`:`make this edit to`;return(0,$.jsx)(Tx,{toolUseConfirm:e.toolUseConfirm,toolUseContext:e.toolUseContext,onDone:e.onDone,onReject:e.onReject,title:`Edit notebook`,question:(0,$.jsxs)(T,{children:[`Do you want to `,s,` `,(0,$.jsx)(T,{bold:!0,children:vv(r)}),`?`]}),content:(0,$.jsx)(oS,{notebook_path:n.notebook_path,cell_id:n.cell_id,new_source:n.new_source,cell_type:n.cell_type,edit_mode:n.edit_mode,verbose:e.verbose,width:e.verbose?120:80}),path:r,completionType:`tool_use_single`,languageName:o,parseInput:t})}Rp(),yi();async function lS(e){if(e.nameType===`application`)return null;let t=e.name;if(!t||qc.has(t.toLowerCase()))return null;if(e.nameType===`cmdlet`)return t;if(e.elementTypes?.[0]!==`StringConstant`)return null;for(let t=0;t<e.args.length;t++){let n=e.elementTypes[t+1];if(n!==`StringConstant`&&n!==`Parameter`)return null}let n=t.toLowerCase(),r=await hb(n),i=await ub(t,e.args,r),a=0;for(let t of i.split(` `).slice(1)){if(t.includes(`\\`))return null;for(;a<e.args.length;){let n=e.args[a];if(n===t)break;if(n.startsWith(`-`)){if(a++,r?.options&&a<e.args.length&&e.args[a]!==t&&!e.args[a].startsWith(`-`)){let e=n.toLowerCase();r.options.find(t=>Array.isArray(t.name)?t.name.includes(e):t.name===e)?.args&&a++}continue}return null}if(a>=e.args.length)return null;a++}return!i.includes(` `)&&(r?.subcommands?.length||ab[n])?null:i}async function uS(e,t){let n=await si(e);if(!n.valid)return[];let r=Bn(n).filter(e=>e.elementType===`CommandAst`);if(r.length<=1){let e=r[0]?await lS(r[0]):null;return e?[e]:[]}let i=[];for(let e of r){if(t?.(e))continue;let n=await lS(e);n&&i.push(n)}if(i.length===0)return[];let a=new Map;for(let e of i){let t=e.split(` `)[0].toLowerCase(),n=a.get(t);n?n.push(e):a.set(t,[e])}let o=[];for(let[e,t]of a){let n=dS(t);(n===``?0:zp(n,` `)+1)<=1&&((await hb(e))?.subcommands?.length||ab[e])||o.push(n)}return o}function dS(e){if(e.length===0)return``;if(e.length===1)return e[0];let t=e[0].split(` `),n=t.length;for(let r=1;r<e.length;r++){let i=e[r].split(` `),a=0;for(;a<n&&a<i.length&&i[a].toLowerCase()===t[a].toLowerCase();)a++;if(n=a,n===0)break}return t.slice(0,n).join(` `)}Xc();function fS({suggestions:e=[],onRejectFeedbackChange:t,onAcceptFeedbackChange:n,yesInputMode:r=!1,noInputMode:i=!1,editablePrefix:a,onEditablePrefixChange:o}){let s=[];if(r?s.push({type:`input`,label:`Yes`,value:`yes`,placeholder:`and tell Claude what to do next`,onChange:n,allowEmptySubmitToCancel:!0}):s.push({label:`Yes`,value:`yes`}),Si()&&e.length>0){let t=e.some(e=>e.type===`addDirectories`||e.type===`addRules`&&e.rules?.some(e=>e.toolName!==`PowerShell`));if(a!==void 0&&o&&!t)s.push({type:`input`,label:`Yes, and don’t ask again for`,value:`yes-prefix-edited`,placeholder:`command prefix (e.g., Get-Process:*)`,initialValue:a,onChange:o,allowEmptySubmitToCancel:!0,showLabelWithValue:!0,labelValueSeparator:`: `,resetCursorOnUpdate:!0});else{let t=Nx(e,km);t&&s.push({label:t,value:`yes-apply-suggestions`})}}return i?s.push({type:`input`,label:`No`,value:`no`,placeholder:`and tell Claude what to do differently`,onChange:t,allowEmptySubmitToCancel:!0}):s.push({label:`No`,value:`no`}),s}B(),Ah(),bp(),Gm(),Cl(),qg(),Ky();function pS(e){let{toolUseConfirm:t,toolUseContext:n,onDone:r,onReject:i}=e,{command:a,description:o}=Bi.inputSchema.parse(t.input),[s]=y(),c=$b({toolName:t.tool.name,toolInput:t.input,toolDescription:t.description,messages:n.messages}),{yesInputMode:l,noInputMode:u,yesFeedbackModeEntered:d,noFeedbackModeEntered:f,acceptFeedback:p,rejectFeedback:m,setAcceptFeedback:h,setRejectFeedback:g,focusedOption:_,handleInputModeToggle:v,handleReject:x,handleFocus:S}=kx({toolUseConfirm:t,onDone:r,onReject:i,explainerVisible:c.visible}),[C,w]=(0,Q.useState)(!1),[E,D]=(0,Q.useState)(a.includes(`
|
|
32
|
+
`)?void 0:a),O=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{let e=!1;return uS(a,e=>ea(e,e.text)).then(t=>{e||O.current||t.length>0&&D(`${t[0]}:*`)}).catch(()=>{}),()=>{e=!0}},[a]);let k=(0,Q.useCallback)(e=>{O.current=!0,D(e)},[]);kb(t,(0,Q.useMemo)(()=>({completion_type:`tool_use_single`,language_name:`none`}),[]));let ee=(0,Q.useMemo)(()=>fS({suggestions:t.permissionResult.behavior===`ask`?t.permissionResult.suggestions:void 0,onRejectFeedbackChange:g,onAcceptFeedbackChange:h,yesInputMode:l,noInputMode:u,editablePrefix:E,onEditablePrefixChange:k}),[t,l,u,E,k]);A(`permission:toggleDebug`,(0,Q.useCallback)(()=>{w(e=>!e)},[]),{context:`Confirmation`});function j(e){Z(`tengu_permission_request_option_selected`,{option_index:{yes:1,"yes-apply-suggestions":2,"yes-prefix-edited":2,no:3}[e],explainer_visible:c.visible});let n=Km(t.tool.name);if(e===`yes-prefix-edited`){let e=(E??``).trim();if(Ox(`tool_use_single`,t,`accept`),!e)t.onAllow(t.input,[]);else{let n=[{type:`addRules`,rules:[{toolName:Bi.name,ruleContent:e}],behavior:`allow`,destination:`localSettings`}];t.onAllow(t.input,n)}r();return}switch(e){case`yes`:{let e=p.trim();Ox(`tool_use_single`,t,`accept`),Z(`tengu_accept_submitted`,{toolName:n,isMcp:t.tool.isMcp??!1,has_instructions:!!e,instructions_length:e.length,entered_feedback_mode:d}),t.onAllow(t.input,[],e||void 0),r();break}case`yes-apply-suggestions`:{Ox(`tool_use_single`,t,`accept`);let e=`suggestions`in t.permissionResult&&t.permissionResult.suggestions||[];t.onAllow(t.input,e),r();break}case`no`:{let e=m.trim();Z(`tengu_reject_submitted`,{toolName:n,isMcp:t.tool.isMcp??!1,has_instructions:!!e,instructions_length:e.length,entered_feedback_mode:f}),x(e||void 0);break}}}return(0,$.jsxs)(Yg,{title:`PowerShell command`,children:[(0,$.jsxs)(b,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsx)(T,{dimColor:c.visible,children:Bi.renderToolUseMessage({command:a,description:o},{theme:s,verbose:!0})}),!c.visible&&(0,$.jsx)(T,{dimColor:!0,children:t.description}),(0,$.jsx)(tx,{visible:c.visible,promise:c.promise})]}),C?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ib,{permissionResult:t.permissionResult,toolName:`PowerShell`}),n.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)(Wy,{permissionResult:t.permissionResult,toolType:`command`}),null,(0,$.jsx)(T,{children:`Do you want to proceed?`}),(0,$.jsx)(eu,{options:ee,inlineDescriptions:!0,onChange:j,onCancel:()=>x(),onFocus:S,onInputModeToggle:v})]}),(0,$.jsxs)(b,{justifyContent:`space-between`,marginTop:1,children:[(0,$.jsxs)(T,{dimColor:!0,children:[`Esc to cancel`,(_===`yes`&&!l||_===`no`&&!u)&&` · Tab to amend`,c.enabled&&` · ctrl+e to ${c.visible?`hide`:`explain`}`]}),n.options.debug&&(0,$.jsx)(T,{dimColor:!0,children:`Ctrl+d to show debug info`})]})]})]})}np(),at(),B(),Gm(),Cf(),Xc(),Eb(),qg(),Xx(),Ky();function mS(e){let{toolUseConfirm:t,onDone:n,onReject:r,verbose:i}=e,a=(e=>{let t=Ua.inputSchema.safeParse(e);return t.success?t.data.skill:(X(Error(`Failed to parse skill tool input: ${t.error.message}`)),``)})(t.input),o=t.permissionResult.behavior===`ask`&&t.permissionResult.metadata&&`command`in t.permissionResult.metadata?t.permissionResult.metadata.command:void 0;kb(t,(0,Q.useMemo)(()=>({completion_type:`tool_use_single`,language_name:`none`}),[]));let s=ut(),c=Si(),l=(0,Q.useMemo)(()=>{let e=[{label:`Yes`,value:`yes`,feedbackConfig:{type:`accept`}}],t=[];if(c){t.push({label:(0,$.jsxs)(T,{children:[`Yes, and don't ask again for `,(0,$.jsx)(T,{bold:!0,children:a}),` in `,(0,$.jsx)(T,{bold:!0,children:s})]}),value:`yes-exact`});let e=a.indexOf(` `);if(e>0){let n=a.substring(0,e);t.push({label:(0,$.jsxs)(T,{children:[`Yes, and don't ask again for `,(0,$.jsx)(T,{bold:!0,children:n+`:*`}),` commands in`,` `,(0,$.jsx)(T,{bold:!0,children:s})]}),value:`yes-prefix`})}}let n={label:`No`,value:`no`,feedbackConfig:{type:`reject`}};return[...e,...t,n]},[a,s,c]),u=(0,Q.useMemo)(()=>({toolName:Km(t.tool.name),isMcp:t.tool.isMcp??!1}),[t.tool.name,t.tool.isMcp]),d=(0,Q.useCallback)((e,i)=>{switch(e){case`yes`:Tb({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:t.assistantMessage.message.id,platform:mf.platform}}),t.onAllow(t.input,[],i),n();break;case`yes-exact`:Tb({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:t.assistantMessage.message.id,platform:mf.platform}}),t.onAllow(t.input,[{type:`addRules`,rules:[{toolName:Pm,ruleContent:a}],behavior:`allow`,destination:`localSettings`}]),n();break;case`yes-prefix`:{Tb({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:t.assistantMessage.message.id,platform:mf.platform}});let e=a.indexOf(` `),r=e>0?a.substring(0,e):a;t.onAllow(t.input,[{type:`addRules`,rules:[{toolName:Pm,ruleContent:`${r}:*`}],behavior:`allow`,destination:`localSettings`}]),n();break}case`no`:Tb({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:t.assistantMessage.message.id,platform:mf.platform}}),t.onReject(i),r(),n();break}},[t,n,r,a]),f=(0,Q.useCallback)(()=>{Tb({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:t.assistantMessage.message.id,platform:mf.platform}}),t.onReject(),r(),n()},[t,n,r]);return(0,$.jsxs)(Yg,{title:`Use skill "${a}"?`,children:[(0,$.jsx)(T,{children:`Claude may use instructions, code, or files from this Skill.`}),(0,$.jsx)(b,{flexDirection:`column`,paddingX:2,paddingY:1,children:(0,$.jsx)(T,{dimColor:!0,children:o?.description})}),(0,$.jsxs)(b,{flexDirection:`column`,children:[(0,$.jsx)(Wy,{permissionResult:t.permissionResult,toolType:`tool`}),(0,$.jsx)(Kx,{options:l,onSelect:d,onCancel:f,toolAnalyticsContext:u})]})]})}var hS=r({WorkflowPermissionRequest:()=>gS});function gS({toolUseConfirm:e,onDone:t,onReject:n}){let[r]=y(),i=Yn(r),a=e.input,o=(0,_S.useMemo)(()=>Si(),[]),s=(0,_S.useMemo)(()=>{let t=[{label:`Yes`,value:`yes`,feedbackConfig:{type:`accept`}}];return o&&t.push({label:(0,vS.jsxs)(T,{children:[`Yes, and don`,`’`,`t ask again for `,(0,vS.jsx)(T,{bold:!0,children:e.tool.name}),` commands`]}),value:`yes-dont-ask-again`}),t.push({label:`No`,value:`no`,feedbackConfig:{type:`reject`}}),t},[o,e.tool.name]),c=(0,_S.useCallback)((r,i)=>{switch(r){case`yes`:Tb({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id??``,platform:mf.platform}}),e.onAllow(e.input,[],i),t();break;case`yes-dont-ask-again`:Tb({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id??``,platform:mf.platform}}),e.onAllow(e.input,[{type:`addRules`,rules:[{toolName:e.tool.name}],behavior:`allow`,destination:`localSettings`}]),t();break;case`no`:Tb({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id??``,platform:mf.platform}}),e.onReject(i),n(),t();break}},[e,t,n]),l=(0,_S.useCallback)(()=>{Tb({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id??``,platform:mf.platform}}),e.onReject(),n(),t()},[e,t,n]);return(0,vS.jsx)(Yg,{title:`Workflow`,children:(0,vS.jsxs)(b,{flexDirection:`column`,gap:1,children:[(0,vS.jsxs)(b,{flexDirection:`column`,children:[(0,vS.jsxs)(T,{bold:!0,color:i.permission,children:[`Execute workflow: `,a.workflow]}),a.args&&(0,vS.jsxs)(T,{dimColor:!0,children:[`Arguments: `,a.args]})]}),(0,vS.jsx)(Wy,{permissionResult:e.permissionResult,toolType:`command`}),(0,vS.jsx)(Kx,{options:s,onSelect:c,onCancel:l})]})})}var _S,vS,yS=t((()=>{_S=n(z(),1),B(),Cf(),Xc(),Eb(),qg(),Xx(),Ky(),vS=ve()})),bS=r({MonitorPermissionRequest:()=>xS});function xS({toolUseConfirm:e,onDone:t,onReject:n}){let[r]=y(),i=Yn(r),a=e.input,o=(0,SS.useMemo)(()=>Si(),[]),s=(0,SS.useMemo)(()=>{let t=[{label:`Yes`,value:`yes`,feedbackConfig:{type:`accept`}}];return o&&t.push({label:(0,CS.jsxs)(T,{children:[`Yes, and don`,`’`,`t ask again for `,(0,CS.jsx)(T,{bold:!0,children:e.tool.name}),` commands`]}),value:`yes-dont-ask-again`}),t.push({label:`No`,value:`no`,feedbackConfig:{type:`reject`}}),t},[o,e.tool.name]),c=(0,SS.useCallback)((r,i)=>{switch(r){case`yes`:Tb({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id??``,platform:mf.platform}}),e.onAllow(e.input,[],i),t();break;case`yes-dont-ask-again`:Tb({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id??``,platform:mf.platform}}),e.onAllow(e.input,[{type:`addRules`,rules:[{toolName:e.tool.name}],behavior:`allow`,destination:`localSettings`}]),t();break;case`no`:Tb({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id??``,platform:mf.platform}}),e.onReject(i),n(),t();break}},[e,t,n]),l=(0,SS.useCallback)(()=>{Tb({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id??``,platform:mf.platform}}),e.onReject(),n(),t()},[e,t,n]);return(0,CS.jsx)(Yg,{title:`Monitor`,children:(0,CS.jsxs)(b,{flexDirection:`column`,gap:1,children:[(0,CS.jsxs)(b,{flexDirection:`column`,children:[(0,CS.jsx)(T,{bold:!0,color:i.permission,children:a.description}),(0,CS.jsx)(T,{dimColor:!0,children:Ip(a.command,5)})]}),(0,CS.jsx)(Wy,{permissionResult:e.permissionResult,toolType:`command`}),(0,CS.jsx)(Kx,{options:s,onSelect:c,onCancel:l})]})})}var SS,CS,wS=t((()=>{SS=n(z(),1),B(),Ur(),Cf(),Xc(),Rp(),Eb(),qg(),Xx(),Ky(),CS=ve()}));Ah(),po(),ed(),ki(),Wc(),Ts(),Nt(),Cn();var TS=(is(),e(ma)).createWorkflowToolCore(),ES=(yS(),e(hS)).WorkflowPermissionRequest,DS=(wu(),e(Ll)).MonitorTool,OS=(wS(),e(bS)).MonitorPermissionRequest;function kS(e){switch(e){case _i:return eS;case kt:return aS;case ds:return Lx;case Bi:return pS;case Sd:return cS;case ar:return Ux;case Oi:return zx;case Ua:return mS;case Vt:return eb;case TS:return ES??Zx;case DS:return OS??Zx;case en:case Ha:case Bt:return nS;default:return Zx}}function AS(e){let t=e.tool.userFacingName(e.input);return e.tool===ar?`Claude Code needs your approval for the plan`:e.tool===Oi?`Claude Code wants to enter plan mode`:!t||t.trim()===``?`Claude Code needs your attention`:`Claude needs your permission to use ${t}`}function jS({toolUseConfirm:e,toolUseContext:t,onDone:n,onReject:r,verbose:i,setStickyFooter:a}){return A(`app:interrupt`,()=>{n(),r(),e.onReject()},{context:`Confirmation`}),Fy(AS(e),`permission_prompt`),(0,$.jsx)(kS(e.tool),{toolUseContext:t,toolUseConfirm:e,onDone:n,onReject:r,verbose:i,setStickyFooter:a})}ps(),np(),zd();async function MS(e,t,n){let r=new Date,i=r.toISOString(),a=-r.getTimezoneOffset(),o=Math.floor(Math.abs(a)/60),s=Math.abs(a)%60,c=`${a>=0?`+`:`-`}${String(o).padStart(2,`0`)}:${String(s).padStart(2,`0`)}`,l=r.toLocaleDateString(`en-US`,{weekday:`long`}),u=ch([`You are a date/time parser that converts natural language into ISO 8601 format.`,`You MUST respond with ONLY the ISO 8601 formatted string, with no explanation or additional text.`,`If the input is ambiguous, prefer future dates over past dates.`,`For times without dates, use today's date.`,`For dates without times, do not include a time component.`,`If the input is incomplete or you cannot confidently parse it into a valid date, respond with exactly "INVALID" (nothing else).`,`Examples of INVALID input: partial dates like "2025-01-", lone numbers like "13", gibberish.`,`Examples of valid natural language: "tomorrow", "next Monday", "jan 1st 2025", "in 2 hours", "yesterday".`]),d=`Current context:
|
|
33
|
+
- Current date and time: ${i} (UTC)
|
|
34
|
+
- Local timezone: ${c}
|
|
35
|
+
- Day of week: ${l}
|
|
36
|
+
|
|
37
|
+
User input: "${e}"
|
|
38
|
+
|
|
39
|
+
Output format: ${t===`date`?`YYYY-MM-DD (date only, no time)`:`YYYY-MM-DDTHH:MM:SS${c} (full date-time with timezone)`}
|
|
40
|
+
|
|
41
|
+
Parse the user's input into ISO 8601 format. Return ONLY the formatted string, or "INVALID" if the input is incomplete or unparseable.`;try{let e=await Lu({systemPrompt:u,userPrompt:d,signal:n,options:{querySource:`mcp_datetime_parse`,agents:[],isNonInteractiveSession:!1,hasAppendSystemPrompt:!1,mcpTools:[],enablePromptCaching:!1}}),t=Wa(Array.isArray(e.message.content)?e.message.content:[]).trim();return!t||t===`INVALID`||!/^\d{4}/.test(t)?{success:!1,error:`Unable to parse date/time from input`}:{success:!0,value:t}}catch(e){return X(e),{success:!1,error:`Unable to parse date/time. Please enter in ISO 8601 format manually.`}}}function NS(e){return/^\d{4}-\d{2}-\d{2}(T|$)/.test(e.trim())}Ee(),Zd(),Rp();var PS=e=>e.type===`string`&&(`enum`in e||`oneOf`in e);function FS(e){return e.type===`array`&&`items`in e&&typeof e.items==`object`&&e.items!==null&&(`enum`in e.items||`anyOf`in e.items)}function IS(e){return`anyOf`in e.items?e.items.anyOf.map(e=>e.const):`enum`in e.items?e.items.enum:[]}function LS(e){return`anyOf`in e.items?e.items.anyOf.map(e=>e.title):`enum`in e.items?e.items.enum:[]}function RS(e,t){let n=IS(e).indexOf(t);return n>=0?LS(e)[n]??t:t}function zS(e){return`oneOf`in e?e.oneOf.map(e=>e.const):`enum`in e?e.enum:[]}function BS(e){return`oneOf`in e?e.oneOf.map(e=>e.title):`enum`in e?(`enumNames`in e?e.enumNames:void 0)??e.enum:[]}function VS(e,t){let n=zS(e).indexOf(t);return n>=0?BS(e)[n]??t:t}function HS(e){if(PS(e)){let[t,...n]=zS(e);return t?we([t,...n]):ke()}if(e.type===`string`){let t=be();switch(e.minLength!==void 0&&(t=t.min(e.minLength,{message:`Must be at least ${e.minLength} ${Lp(e.minLength,`character`)}`})),e.maxLength!==void 0&&(t=t.max(e.maxLength,{message:`Must be at most ${e.maxLength} ${Lp(e.maxLength,`character`)}`})),e.format){case`email`:t=t.email({message:`Must be a valid email address, e.g. user@example.com`});break;case`uri`:t=t.url({message:`Must be a valid URI, e.g. https://example.com`});break;case`date`:t=t.date(`Must be a valid date, e.g. 2024-03-15, today, next Monday`);break;case`date-time`:t=t.datetime({offset:!0,message:`Must be a valid date-time, e.g. 2024-03-15T14:30:00Z, tomorrow at 3pm`});break;default:break}return t}if(e.type===`number`||e.type===`integer`){let t=e.type===`integer`?`an integer`:`a number`,n=e.type===`integer`,r=e=>Number.isInteger(e)&&!n?`${e}.0`:String(e),i=e.minimum!==void 0&&e.maximum!==void 0?`Must be ${t} between ${r(e.minimum)} and ${r(e.maximum)}`:e.minimum===void 0?e.maximum===void 0?`Must be ${t}`:`Must be ${t} <= ${r(e.maximum)}`:`Must be ${t} >= ${r(e.minimum)}`,a=De({error:i});return e.type===`integer`&&(a=a.int({message:i})),e.minimum!==void 0&&(a=a.min(e.minimum,{message:i})),e.maximum!==void 0&&(a=a.max(e.maximum,{message:i})),a}if(e.type===`boolean`)return Ce();throw Error(`Unsupported schema: ${sf(e)}`)}function US(e,t){let n=HS(t).safeParse(e);return n.success?{value:n.data,isValid:!0}:{isValid:!1,error:n.error.issues.map(e=>e.message).join(`; `)}}function WS(e){return e.type===`string`&&`format`in e&&(e.format===`date`||e.format===`date-time`)}async function GS(e,t,n){let r=US(e,t);if(r.isValid)return r;if(WS(t)&&!NS(e)){let r=await MS(e,t.format,n);if(r.success){let e=US(r.value,t);if(e.isValid)return e}}return r}u(),ms(),B(),Ah(),Rp(),Wn();var KS=e=>[`string`,`number`,`integer`].includes(e.type),qS=`⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏`,JS=e=>(e+1)%10;function YS(e){e.buffer=``,e.timer=void 0}function XS(){let[e,t]=(0,Q.useState)(0);return(0,Q.useEffect)(()=>{let e=setInterval(t,80,JS);return()=>clearInterval(e)},[]),(0,$.jsx)(T,{color:`warning`,children:qS[e]})}function ZS(e,t){try{let n=new Date(e);if(Number.isNaN(n.getTime()))return e;if((`format`in t?t.format:void 0)===`date-time`)return n.toLocaleDateString(`en-US`,{weekday:`short`,year:`numeric`,month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`,timeZoneName:`short`});let r=e.split(`-`);return r.length===3?new Date(Number(r[0]),Number(r[1])-1,Number(r[2])).toLocaleDateString(`en-US`,{weekday:`short`,year:`numeric`,month:`short`,day:`numeric`}):e}catch{return e}}function QS({event:e,onResponse:t,onWaitingDismiss:n}){return e.params.mode===`url`?(0,$.jsx)(eC,{event:e,onResponse:t,onWaitingDismiss:n}):(0,$.jsx)($S,{event:e,onResponse:t})}function $S({event:e,onResponse:t}){let{serverName:n,signal:r}=e,{message:i,requestedSchema:a}=e.params,o=Object.keys(a.properties).length>0,[s,c]=(0,Q.useState)(o?null:`accept`),[l,u]=(0,Q.useState)(()=>{let e={};if(a.properties)for(let[t,n]of Object.entries(a.properties))typeof n==`object`&&n&&n.default!==void 0&&(e[t]=n.default);return e}),[f,p]=(0,Q.useState)(()=>{let e={};for(let[t,n]of Object.entries(a.properties))if(KS(n)&&n?.default!==void 0){let r=US(String(n.default),n);!r.isValid&&r.error&&(e[t]=r.error)}return e});(0,Q.useEffect)(()=>{if(!r)return;let e=()=>{t(`cancel`)};if(r.aborted){e();return}return r.addEventListener(`abort`,e),()=>{r.removeEventListener(`abort`,e)}},[r,t]);let m=(0,Q.useMemo)(()=>{let e=a.required??[];return Object.entries(a.properties).map(([t,n])=>({name:t,schema:n,isRequired:e.includes(t)}))},[a]),[g,_]=(0,Q.useState)(o?0:void 0),[v,y]=(0,Q.useState)(()=>{let e=m[0];if(e&&KS(e.schema)){let t=l[e.name];return t===void 0?``:String(t)}return``}),[x,S]=(0,Q.useState)(v.length),[C,w]=(0,Q.useState)(()=>new Set),[E,D]=(0,Q.useState)(),[k,ee]=(0,Q.useState)(0),j=(0,Q.useRef)(void 0),M=(0,Q.useRef)(new Map),te=(0,Q.useRef)({buffer:``,timer:void 0});(0,Q.useEffect)(()=>()=>{j.current!==void 0&&clearTimeout(j.current);let e=te.current;e.timer!==void 0&&clearTimeout(e.timer);for(let e of M.current.values())e.abort();M.current.clear()},[]);let{columns:N,rows:P}=de(),F=g===void 0?void 0:m[g],ne=F!==void 0&&KS(F.schema)&&!PS(F.schema)&&!s;ks(`elicitation`),Fy(`Claude Code needs your input`,`elicitation_dialog`);let re=(0,Q.useCallback)(e=>{if(e===void 0){y(``),S(0);return}let t=m[e];if(t&&KS(t.schema)&&!PS(t.schema)){let e=l[t.name],n=e===void 0?``:String(e);y(n),S(n.length)}},[m,l]);function I(e,t){if(!FS(t))return;let n=l[e]??[],r=m.find(t=>t.name===e)?.isRequired??!1,i=t.minItems,a=t.maxItems;i!==void 0&&n.length<i&&(n.length>0||r)?R(e,`Select at least ${i} ${Lp(i,`item`)}`):a!==void 0&&n.length>a?R(e,`Select at most ${a} ${Lp(a,`item`)}`):R(e)}function L(e){F&&FS(F.schema)?(I(F.name,F.schema),D(void 0)):F&&PS(F.schema)&&D(void 0),ne&&F&&(ae(F.name,F.schema,v),j.current!==void 0&&(clearTimeout(j.current),j.current=void 0),WS(F.schema)&&v.trim()!==``&&f[F.name]&&se(F.name,F.schema,v));let t=m.length+2,n=g??(s===`accept`?m.length:s===`decline`?m.length+1:void 0),r=n===void 0?0:(n+(e===`up`?t-1:1))%t;r<m.length?(_(r),c(null),re(r)):(_(void 0),c(r===m.length?`accept`:`decline`),y(``))}function ie(e,t){u(n=>{let r={...n};return t===void 0?delete r[e]:r[e]=t,r}),t!==void 0&&f[e]===`This field is required`&&R(e)}function R(e,t){p(n=>{let r={...n};return t?r[e]=t:delete r[e],r})}function z(e){e&&(ie(e,void 0),R(e),y(``),S(0))}function ae(e,t,n){let r=n.trim();if(r===``&&(t.type!==`string`||`format`in t&&t.format!==void 0)){z(e);return}if(r===``){l[e]!==void 0&&ie(e,``);return}let i=US(n,t);ie(e,i.isValid?i.value:n),R(e,i.isValid?void 0:i.error)}function se(e,t,n){if(!r)return;let i=M.current.get(e);i&&i.abort();let a=new AbortController;M.current.set(e,a),w(t=>new Set(t).add(e)),GS(n,t,a.signal).then(t=>{if(M.current.delete(e),w(t=>{let n=new Set(t);return n.delete(e),n}),!a.signal.aborted)if(t.isValid){ie(e,t.value),R(e);let r=String(t.value);y(e=>e===n?(S(r.length),r):e)}else R(e,t.error)},()=>{M.current.delete(e),w(t=>{let n=new Set(t);return n.delete(e),n})})}function ce(e){if(y(e),F&&(ae(F.name,F.schema,e),j.current!==void 0&&(clearTimeout(j.current),j.current=void 0),WS(F.schema)&&e.trim()!==``&&f[F.name])){let t=F.name,n=F.schema;j.current=setTimeout((e,t,n,r,i)=>{e.current=void 0,t(n,r,i)},2e3,j,se,t,n,e)}}function le(){L(`down`)}function ue(e,t,n){let r=te.current;r.timer!==void 0&&clearTimeout(r.timer),r.buffer+=e.toLowerCase(),r.timer=setTimeout(YS,2e3,r);let i=t.findIndex(e=>e.startsWith(r.buffer));i!==-1&&n(i)}A(`confirm:no`,()=>{if(ne&&F){let e=l[F.name];y(e===void 0?``:String(e)),S(0)}t(`cancel`)},{context:`Settings`,isActive:!!F&&!s&&!E}),oe((e,n)=>{if(ne&&!n.upArrow&&!n.downArrow&&!n.return&&!n.backspace)return;if(E&&F&&FS(F.schema)){let t=F.schema,r=IS(t),i=l[F.name]??[];if(n.leftArrow||n.escape){D(void 0),I(F.name,t);return}if(n.upArrow){k===0?(D(void 0),I(F.name,t)):ee(k-1);return}if(n.downArrow){k>=r.length-1?(D(void 0),L(`down`)):ee(k+1);return}if(e===` `){let e=r[k];if(e!==void 0){let n=i.includes(e)?i.filter(t=>t!==e):[...i,e],r=n.length>0?n:void 0;ie(F.name,r);let a=t.minItems,o=t.maxItems;a!==void 0&&n.length<a&&(n.length>0||F.isRequired)?R(F.name,`Select at least ${a} ${Lp(a,`item`)}`):o!==void 0&&n.length>o?R(F.name,`Select at most ${o} ${Lp(o,`item`)}`):R(F.name)}return}if(n.return){let e=r[k];e!==void 0&&!i.includes(e)&&ie(F.name,[...i,e]),D(void 0),L(`down`);return}if(e){ue(e,r.map(e=>RS(t,e).toLowerCase()),ee);return}return}if(E&&F&&PS(F.schema)){let t=F.schema,r=zS(t);if(n.leftArrow||n.escape){D(void 0);return}if(n.upArrow){k===0?D(void 0):ee(k-1);return}if(n.downArrow){k>=r.length-1?(D(void 0),L(`down`)):ee(k+1);return}if(e===` `){let e=r[k];e!==void 0&&ie(F.name,e),D(void 0);return}if(n.return){let e=r[k];e!==void 0&&ie(F.name,e),D(void 0),L(`down`);return}if(e){ue(e,r.map(e=>VS(t,e).toLowerCase()),ee);return}return}if(n.return&&s===`accept`){if(fe()&&Object.keys(f).length===0)t(`accept`,l);else{let e=a.required||[];for(let t of e)l[t]===void 0&&R(t,`This field is required`);let t=m.findIndex(t=>e.includes(t.name)&&l[t.name]===void 0||f[t.name]!==void 0);t!==-1&&(_(t),c(null),re(t))}return}if(n.return&&s===`decline`){t(`decline`);return}if(n.upArrow||n.downArrow){let e=te.current;e.buffer=``,e.timer!==void 0&&(clearTimeout(e.timer),e.timer=void 0),L(n.upArrow?`up`:`down`);return}if(s&&(n.leftArrow||n.rightArrow)){c(s===`accept`?`decline`:`accept`);return}if(!F)return;let{schema:r,name:i}=F,o=l[i];if(r.type===`boolean`){if(e===` `){ie(i,o===void 0||!o);return}if(n.return){L(`down`);return}if(n.backspace&&o!==void 0){z(i);return}if(e&&!n.return){ue(e,[`yes`,`no`],e=>ie(i,e===0));return}return}if(PS(r)||FS(r)){if(n.return){L(`down`);return}if(n.backspace&&o!==void 0){z(i);return}let t,a=0;if(PS(r)){let e=zS(r);t=e.map(e=>VS(r,e).toLowerCase()),o!==void 0&&(a=Math.max(0,e.indexOf(o)))}else t=IS(r).map(e=>RS(r,e).toLowerCase());if(n.rightArrow){D(i),ee(a);return}if(e&&!n.leftArrow){ue(e,t,e=>{D(i),ee(e)});return}return}if(n.backspace&&ne&&v===``){z(i);return}},{isActive:!0});function fe(){let e=a.required||[];for(let t of e){let e=l[t];if(e==null||e===``||Array.isArray(e)&&e.length===0)return!1}return!0}let pe=Math.max(2,Math.floor((P-14)/3)),B=(0,Q.useMemo)(()=>{let e=m.length;if(e<=pe)return{start:0,end:e};let t=g??e-1,n=Math.max(0,t-Math.floor(pe/2)),r=Math.min(n+pe,e);return n=Math.max(0,r-pe),{start:n,end:r}},[m.length,pe,g]),V=B.start>0,H=B.end<m.length;function me(){return m.length?(0,$.jsxs)(b,{flexDirection:`column`,children:[V&&(0,$.jsx)(b,{marginLeft:2,children:(0,$.jsxs)(T,{dimColor:!0,children:[d.arrowUp,` `,B.start,` more above`]})}),m.slice(B.start,B.end).map((e,t)=>{let n=B.start+t,{name:r,schema:i,isRequired:a}=e,o=n===g&&!s,c=l[r],u=c!==void 0&&(!Array.isArray(c)||c.length>0),p=f[r],m=C.has(r)?(0,$.jsx)(XS,{}):p?(0,$.jsx)(T,{color:`error`,children:d.warning}):u?(0,$.jsx)(T,{color:`success`,dimColor:!o,children:d.tick}):a?(0,$.jsx)(T,{color:`error`,children:`*`}):(0,$.jsx)(T,{children:` `}),h=p?`error`:u?`success`:a?`error`:`suggestion`,_=o?h:void 0,y=(0,$.jsx)(T,{color:_,bold:o,children:i.title||r}),w,D=null;if(FS(i)){let e=IS(i),t=c??[];if(E===r&&o)w=(0,$.jsx)(T,{dimColor:!0,children:d.triangleDownSmall}),D=(0,$.jsx)(b,{flexDirection:`column`,marginLeft:6,children:e.map((e,n)=>{let r=RS(i,e),a=t.includes(e),o=n===k;return(0,$.jsxs)(b,{gap:1,children:[(0,$.jsx)(T,{color:`suggestion`,children:o?d.pointer:` `}),(0,$.jsx)(T,{color:a?`success`:void 0,children:a?d.checkboxOn:d.checkboxOff}),(0,$.jsx)(T,{color:o?`suggestion`:void 0,bold:o,children:r})]},e)})});else{let e=o?(0,$.jsxs)(T,{dimColor:!0,children:[d.triangleRightSmall,` `]}):null;w=t.length>0?(0,$.jsxs)(T,{children:[e,(0,$.jsx)(T,{color:_,bold:o,children:t.map(e=>RS(i,e)).join(`, `)})]}):(0,$.jsxs)(T,{children:[e,(0,$.jsx)(T,{dimColor:!0,italic:!0,children:`not set`})]})}}else if(PS(i)){let e=zS(i);if(E===r&&o)w=(0,$.jsx)(T,{dimColor:!0,children:d.triangleDownSmall}),D=(0,$.jsx)(b,{flexDirection:`column`,marginLeft:6,children:e.map((e,t)=>{let n=VS(i,e),r=c===e,a=t===k;return(0,$.jsxs)(b,{gap:1,children:[(0,$.jsx)(T,{color:`suggestion`,children:a?d.pointer:` `}),(0,$.jsx)(T,{color:r?`success`:void 0,children:r?d.radioOn:d.radioOff}),(0,$.jsx)(T,{color:a?`suggestion`:void 0,bold:a,children:n})]},e)})});else{let e=o?(0,$.jsxs)(T,{dimColor:!0,children:[d.triangleRightSmall,` `]}):null;w=u?(0,$.jsxs)(T,{children:[e,(0,$.jsx)(T,{color:_,bold:o,children:VS(i,c)})]}):(0,$.jsxs)(T,{children:[e,(0,$.jsx)(T,{dimColor:!0,italic:!0,children:`not set`})]})}}else if(i.type===`boolean`)w=o?u?(0,$.jsx)(T,{color:_,bold:!0,children:c?d.checkboxOn:d.checkboxOff}):(0,$.jsx)(T,{dimColor:!0,children:d.checkboxOff}):u?(0,$.jsx)(T,{children:c?d.checkboxOn:d.checkboxOff}):(0,$.jsx)(T,{dimColor:!0,italic:!0,children:`not set`});else if(KS(i))if(o)w=(0,$.jsx)(ia,{value:v,onChange:ce,onSubmit:le,placeholder:`Type something…`,columns:Math.min(N-20,60),cursorOffset:x,onChangeCursorOffset:S,focus:!0,showCursor:!0});else{let e=u&&WS(i)?ZS(String(c),i):String(c);w=u?(0,$.jsx)(T,{children:e}):(0,$.jsx)(T,{dimColor:!0,italic:!0,children:`not set`})}else w=u?(0,$.jsx)(T,{children:String(c)}):(0,$.jsx)(T,{dimColor:!0,italic:!0,children:`not set`});return(0,$.jsxs)(b,{flexDirection:`column`,children:[(0,$.jsxs)(b,{gap:1,children:[(0,$.jsx)(T,{color:h,children:o?d.pointer:` `}),m,(0,$.jsxs)(b,{children:[y,(0,$.jsx)(T,{color:_,children:`: `}),w]})]}),D,i.description&&(0,$.jsx)(b,{marginLeft:6,children:(0,$.jsx)(T,{dimColor:!0,children:i.description})}),(0,$.jsx)(b,{marginLeft:6,height:1,children:p?(0,$.jsx)(T,{color:`error`,italic:!0,children:p}):(0,$.jsx)(T,{children:` `})})]},r)}),H&&(0,$.jsx)(b,{marginLeft:2,children:(0,$.jsxs)(T,{dimColor:!0,children:[d.arrowDown,` `,m.length-B.end,` more below`]})})]}):null}return(0,$.jsx)(ge,{title:`MCP server \u201c${n}\u201d requests your input`,subtitle:`\n${i}`,color:`permission`,onCancel:()=>t(`cancel`),isCancelActive:(!F||!!s)&&!E,inputGuide:e=>e.pending?(0,$.jsxs)(T,{children:[`Press `,e.keyName,` again to exit`]}):(0,$.jsxs)(O,{children:[(0,$.jsx)(vd,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`}),(0,$.jsx)(h,{shortcut:`↑↓`,action:`navigate`}),F&&(0,$.jsx)(h,{shortcut:`Backspace`,action:`unset`}),F&&F.schema.type===`boolean`&&(0,$.jsx)(h,{shortcut:`Space`,action:`toggle`}),F&&PS(F.schema)&&(E?(0,$.jsx)(h,{shortcut:`Space`,action:`select`}):(0,$.jsx)(h,{shortcut:`→`,action:`expand`})),F&&FS(F.schema)&&(E?(0,$.jsx)(h,{shortcut:`Space`,action:`toggle`}):(0,$.jsx)(h,{shortcut:`→`,action:`expand`}))]}),children:(0,$.jsxs)(b,{flexDirection:`column`,children:[me(),(0,$.jsxs)(b,{children:[(0,$.jsx)(T,{color:`success`,children:s===`accept`?d.pointer:` `}),(0,$.jsx)(T,{bold:s===`accept`,color:s===`accept`?`success`:void 0,dimColor:s!==`accept`,children:` Accept `}),(0,$.jsx)(T,{color:`error`,children:s===`decline`?d.pointer:` `}),(0,$.jsx)(T,{bold:s===`decline`,color:s===`decline`?`error`:void 0,dimColor:s!==`decline`,children:` Decline`})]})]})})}function eC({event:e,onResponse:t,onWaitingDismiss:n}){let{serverName:r,signal:i,waitingState:a}=e,{message:o,url:s}=e.params,[c,l]=(0,Q.useState)(`prompt`),u=(0,Q.useRef)(`prompt`),[f,p]=(0,Q.useState)(`accept`),m=a?.showCancel??!1;Fy(`Claude Code needs your input`,`elicitation_url_dialog`),ks(`elicitation-url`),u.current=c;let g=(0,Q.useRef)(n);g.current=n,(0,Q.useEffect)(()=>{let e=()=>{u.current===`waiting`?g.current?.(`cancel`):t(`cancel`)};if(i.aborted){e();return}return i.addEventListener(`abort`,e),()=>i.removeEventListener(`abort`,e)},[i,t]);let _=``,v=``,y=``;try{_=new URL(s).hostname;let e=s.indexOf(_);v=s.slice(0,e),y=s.slice(e+_.length)}catch{_=s}(0,Q.useEffect)(()=>{c===`waiting`&&e.completed&&n?.(m?`retry`:`dismiss`)},[c,e.completed,n,m]);let x=(0,Q.useCallback)(()=>{Fh(s),t(`accept`),l(`waiting`),u.current=`waiting`,p(`open`)},[t,s]);if(oe((e,r)=>{if(c===`prompt`){if(r.leftArrow||r.rightArrow){p(e=>e===`accept`?`decline`:`accept`);return}r.return&&(f===`accept`?x():t(`decline`))}else{let e=m?[`open`,`action`,`cancel`]:[`open`,`action`];if(r.leftArrow||r.rightArrow){p(t=>{let n=e.indexOf(t),i=r.rightArrow?1:-1;return e[(n+i+e.length)%e.length]});return}r.return&&(f===`open`?Fh(s):f===`cancel`?n?.(`cancel`):n?.(m?`retry`:`dismiss`))}}),c===`waiting`){let e=a?.actionLabel??`Continue without waiting`;return(0,$.jsx)(ge,{title:`MCP server \u201c${r}\u201d \u2014 waiting for completion`,subtitle:`\n${o}`,color:`permission`,onCancel:()=>n?.(`cancel`),isCancelActive:!0,inputGuide:e=>e.pending?(0,$.jsxs)(T,{children:[`Press `,e.keyName,` again to exit`]}):(0,$.jsxs)(O,{children:[(0,$.jsx)(vd,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`}),(0,$.jsx)(h,{shortcut:`\\u2190\\u2192`,action:`switch`})]}),children:(0,$.jsxs)(b,{flexDirection:`column`,children:[(0,$.jsx)(b,{marginBottom:1,flexDirection:`column`,children:(0,$.jsxs)(T,{children:[v,(0,$.jsx)(T,{bold:!0,children:_}),y]})}),(0,$.jsx)(b,{marginBottom:1,children:(0,$.jsx)(T,{dimColor:!0,italic:!0,children:`Waiting for the server to confirm completion…`})}),(0,$.jsxs)(b,{children:[(0,$.jsx)(T,{color:`success`,children:f===`open`?d.pointer:` `}),(0,$.jsx)(T,{bold:f===`open`,color:f===`open`?`success`:void 0,dimColor:f!==`open`,children:` Reopen URL `}),(0,$.jsx)(T,{color:`success`,children:f===`action`?d.pointer:` `}),(0,$.jsx)(T,{bold:f===`action`,color:f===`action`?`success`:void 0,dimColor:f!==`action`,children:` ${e}`}),m&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(T,{children:` `}),(0,$.jsx)(T,{color:`error`,children:f===`cancel`?d.pointer:` `}),(0,$.jsx)(T,{bold:f===`cancel`,color:f===`cancel`?`error`:void 0,dimColor:f!==`cancel`,children:` Cancel`})]})]})]})})}return(0,$.jsx)(ge,{title:`MCP server \u201c${r}\u201d wants to open a URL`,subtitle:`\n${o}`,color:`permission`,onCancel:()=>t(`cancel`),isCancelActive:!0,inputGuide:e=>e.pending?(0,$.jsxs)(T,{children:[`Press `,e.keyName,` again to exit`]}):(0,$.jsxs)(O,{children:[(0,$.jsx)(vd,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`}),(0,$.jsx)(h,{shortcut:`\\u2190\\u2192`,action:`switch`})]}),children:(0,$.jsxs)(b,{flexDirection:`column`,children:[(0,$.jsx)(b,{marginBottom:1,flexDirection:`column`,children:(0,$.jsxs)(T,{children:[v,(0,$.jsx)(T,{bold:!0,children:_}),y]})}),(0,$.jsxs)(b,{children:[(0,$.jsx)(T,{color:`success`,children:f===`accept`?d.pointer:` `}),(0,$.jsx)(T,{bold:f===`accept`,color:f===`accept`?`success`:void 0,dimColor:f!==`accept`,children:` Accept `}),(0,$.jsx)(T,{color:`error`,children:f===`decline`?d.pointer:` `}),(0,$.jsx)(T,{bold:f===`decline`,color:f===`decline`?`error`:void 0,dimColor:f!==`decline`,children:` Decline`})]})]})})}B(),Ah(),Cl(),qg();function tC({title:e,toolInputSummary:t,request:n,onRespond:r,onAbort:i}){A(`app:interrupt`,i,{isActive:!0});let a=n.options.map(e=>({label:e.label,value:e.key,description:e.description}));return(0,$.jsx)(Yg,{title:e,subtitle:n.message,titleRight:t?(0,$.jsx)(T,{dimColor:!0,children:t}):void 0,children:(0,$.jsx)(b,{flexDirection:`column`,paddingY:1,children:(0,$.jsx)(eu,{options:a,onChange:e=>{r(e)}})})})}Ki();function nC(){return(0,Q.useSyncExternalStore)(zt,Hc)}np(),Ee(),mn(),Oe();var rC=`at_mentioned`,iC=Te(()=>ye({method:xe(rC),params:ye({filePath:be(),lineStart:Se().optional(),lineEnd:Se().optional()})}));function aC(e,t){let n=(0,Q.useRef)(void 0);(0,Q.useEffect)(()=>{let r=Ma(e);n.current!==r&&(n.current=r),r&&r.client.setNotificationHandler(iC(),e=>{if(n.current===r)try{let n=e.params,r=n.lineStart===void 0?void 0:n.lineStart+1,i=n.lineEnd===void 0?void 0:n.lineEnd+1;t({filePath:n.filePath,lineStart:r,lineEnd:i})}catch(e){X(e)}})},[e,t])}_a(),S_(),w_(),q_();function oC(e){return(0,Q.useMemo)(()=>{let t=e?.find(e=>e.name===`ide`);if(!t)return{status:null,ideName:null};let n=t.config,r=n.type===`sse-ide`||n.type===`ws-ide`?n.ideName:null;return t.type===`connected`?{status:`connected`,ideName:r}:t.type===`pending`?{status:`pending`,ideName:r}:{status:`disconnected`,ideName:r}},[e])}hu(),Gg(),B();function sC({ideSelection:e,mcpClients:t}){let{status:n}=oC(t),r=n===`connected`&&(e?.filePath||e?.text&&e.lineCount>0);if(n===null||!r||!e)return null;if(e.text&&e.lineCount>0)return(0,$.jsxs)(T,{color:`ide`,wrap:`truncate`,children:[`⧉ `,e.lineCount,` `,e.lineCount===1?`line`:`lines`,` selected`]},`selection-indicator`);if(e.filePath)return(0,$.jsxs)(T,{color:`ide`,wrap:`truncate`,children:[`⧉ In `,vv(e.filePath)]},`selection-indicator`)}var cC=1.5*1024*1024*1024,lC=2.5*1024*1024*1024;function uC(){let[e,t]=(0,Q.useState)(null);return re(()=>{let e=process.memoryUsage().heapUsed,n=e>=lC?`critical`:e>=cC?`high`:`normal`;t(t=>n===`normal`?t===null?t:null:{heapUsed:e,status:n})},1e4),e}B(),Ep();function dC(){if(process.env.USER_TYPE!==`ant`)return null;let e=uC();if(!e)return null;let{heapUsed:t,status:n}=e;if(n===`normal`)return null;let r=Dp(t);return(0,$.jsx)(b,{children:(0,$.jsxs)(T,{color:n===`critical`?`error`:`warning`,wrap:`truncate`,children:[`High memory usage (`,r,`) · /heapdump`]})})}function fC(){return(0,Q.useSyncExternalStore)(Wo.subscribe,Wo.getState)}B(),ql();function pC({tokenUsage:e,model:t}){let{percentLeft:n,isAboveWarningThreshold:r,isAboveErrorThreshold:i}=Rl(e,t),a=fC();if(!r||a)return null;let o=Fs(),s=ic(`warning`),c=`${n}% until auto-compact`;return(0,$.jsx)(b,{flexDirection:`row`,children:o?(0,$.jsx)(T,{dimColor:!0,wrap:`truncate`,children:s?`${c} \u00b7 ${s}`:c}):(0,$.jsx)(T,{color:i?`error`:`warning`,wrap:`truncate`,children:s?`Context low (${n}% remaining) \u00b7 ${s}`:`Context low (${n}% remaining) \u00b7 Run /compact to compact & continue`})})}B(),Oa();function mC(){let[e,t]=(0,Q.useState)(0),n=(0,Q.useRef)(null),r=ud(`app:toggleTranscript`,`Global`,`ctrl+o`);return(0,Q.useEffect)(()=>{if(!yd.isSandboxingEnabled())return;let e=yd.getSandboxViolationStore(),r=e.getTotalCount(),i=e.subscribe(()=>{let i=e.getTotalCount(),a=i-r;a>0&&(t(a),r=i,n.current&&clearTimeout(n.current),n.current=setTimeout(t,5e3,0))});return()=>{i(),n.current&&clearTimeout(n.current)}},[]),!yd.isSandboxingEnabled()||e===0?null:(0,$.jsx)(b,{paddingX:0,paddingY:0,children:(0,$.jsxs)(T,{color:`inactive`,wrap:`truncate`,children:[`⧈ Sandbox blocked `,e,` `,e===1?`operation`:`operations`,` ·`,` `,r,` for details · /sandbox to disable`]})})}Rt(),bp(),q(),B(),Du(),Rg(),Ep(),mn(),zd(),Fa();var hC=5e3;function gC({apiKeyStatus:e,autoUpdaterResult:t,debug:n,isAutoUpdating:r,verbose:i,messages:a,onAutoUpdaterResult:o,onChangeIsUpdating:s,ideSelection:c,mcpClients:l,isInputWrapped:u=!1,isNarrow:d=!1}){let f=(0,Q.useMemo)(()=>Pi(Mt(a)),[a]),p=Wg(),m=Rl(f,p).isAboveWarningThreshold,{status:h}=oC(l),g=J(e=>e.notifications),{addNotification:_,removeNotification:v}=lo(),y=Nc();(0,Q.useEffect)(()=>(Ac((e,t)=>{_({key:`env-hook`,text:e,color:t?`error`:void 0,priority:t?`medium`:`low`,timeoutMs:t?8e3:5e3})}),()=>Ac(null)),[_]),h===`connected`&&(c?.filePath||c?.text&&c.lineCount);let x=y.isUsingOverage,S=Jp(),C=S===`team`||S===`enterprise`,w=zg(),E=u&&!m&&e!==`invalid`&&e!==`missing`&&w!==void 0;return(0,Q.useEffect)(()=>{E&&w?(Z(`tengu_external_editor_hint_shown`,{}),_({key:`external-editor-hint`,jsx:(0,$.jsx)(T,{dimColor:!0,children:(0,$.jsx)(vd,{action:`chat:externalEditor`,context:`Chat`,fallback:`ctrl+g`,description:`edit in ${In(w)}`})}),priority:`immediate`,timeoutMs:5e3})):v(`external-editor-hint`)},[E,w,_,v]),(0,$.jsx)(b,{flexDirection:`column`,alignItems:d?`flex-start`:`flex-end`,flexShrink:0,overflowX:`hidden`,children:(0,$.jsx)(_C,{ideSelection:c,mcpClients:l,notifications:g,isInOverageMode:x??!1,isTeamOrEnterprise:C,apiKeyStatus:e,debug:n,verbose:i,tokenUsage:f,mainLoopModel:p})})}function _C({ideSelection:e,mcpClients:t,notifications:n,isInOverageMode:r,isTeamOrEnterprise:i,apiKeyStatus:o,debug:s,verbose:c,tokenUsage:l,mainLoopModel:u}){let[d,f]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{if(!Hp())return;let e=setInterval(e=>{let t=qp(),n=t>=1e4?kp(t):null;e(e=>n===e?e:n)},1e3,f);return()=>clearInterval(e)},[]);let p=J(e=>e.isBriefOnly);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(sC,{ideSelection:e,mcpClients:t}),n.current&&(`jsx`in n.current?(0,$.jsx)(T,{wrap:`truncate`,children:n.current.jsx},n.current.key):(0,$.jsx)(T,{color:n.current.color,dimColor:!n.current.color,wrap:`truncate`,children:n.current.text})),r&&!i&&(0,$.jsx)(b,{children:(0,$.jsx)(T,{dimColor:!0,wrap:`truncate`,children:`Now using extra usage`})}),d&&(0,$.jsxs)(b,{children:[(0,$.jsxs)(T,{color:`warning`,wrap:`truncate`,children:[`apiKeyHelper is taking a while`,` `]}),(0,$.jsxs)(T,{dimColor:!0,wrap:`truncate`,children:[`(`,d,`)`]})]}),(o===`invalid`||o===`missing`)&&(0,$.jsx)(b,{children:(0,$.jsx)(T,{color:`error`,wrap:`truncate`,children:a(process.env.CLAUDE_CODE_REMOTE)?`Authentication error · Try again`:`Not logged in`})}),s&&(0,$.jsx)(b,{children:(0,$.jsx)(T,{color:`warning`,wrap:`truncate`,children:`Debug mode`})}),o!==`invalid`&&o!==`missing`&&c&&(0,$.jsx)(b,{children:(0,$.jsxs)(T,{dimColor:!0,wrap:`truncate`,children:[l,` tokens`]})}),!p&&(0,$.jsx)(pC,{tokenUsage:l,model:u}),(0,$.jsx)(dC,{}),(0,$.jsx)(mC,{})]})}Rt(),Fa(),B();var vC=10,yC=null,bC=0,xC;async function SC(e,t){let n=Math.ceil(e/vC)*vC;if(yC&&bC>=n&&xC===t)return yC;yC&&await yC,bC=n,xC=t,yC=(async()=>{let e=[],n=0;for await(let r of js())if(!(t&&fc(r.display)!==t)&&(e.push(r),n++,n>=bC))break;return e})();try{return await yC}finally{yC=null,bC=0,xC=void 0}}function CC(e,t,n,r,i){let[a,o]=(0,Q.useState)(0),[s,c]=(0,Q.useState)(void 0),l=(0,Q.useRef)(!1),{addNotification:u,removeNotification:d}=lo(),f=(0,Q.useRef)([]),p=(0,Q.useRef)(void 0),m=(0,Q.useRef)(0),h=(0,Q.useRef)(void 0),g=(0,Q.useRef)(t),_=(0,Q.useRef)(n),v=(0,Q.useRef)(i);g.current=t,_.current=n,v.current=i;let y=(0,Q.useCallback)((t,n,i,a=!1)=>{e(t,n,i),r?.(a?0:t.length)},[e,r]),b=(0,Q.useCallback)((e,t=!1)=>{if(!e||!e.display)return;let n=fc(e.display),r=n===`bash`?e.display.slice(1):e.display;y(r,n,e.pastedContents??{},t)},[y]),x=(0,Q.useCallback)(()=>{u({key:`search-history-hint`,jsx:(0,$.jsx)(T,{dimColor:!0,children:(0,$.jsx)(vd,{action:`history:search`,context:`Global`,fallback:`ctrl+r`,description:`search history`})}),priority:`immediate`,timeoutMs:hC})},[u]);return{historyIndex:a,setHistoryIndex:o,onHistoryUp:(0,Q.useCallback)(()=>{let e=m.current;m.current++;let t=g.current,n=_.current,r=v.current;if(e===0){h.current=r===`bash`?r:void 0;let e=t.trim()!==``;c(e?{display:t,pastedContents:n,mode:r}:void 0)}let i=h.current;(async()=>{let t=e+1;if(p.current!==i&&(f.current=[],p.current=i,m.current=0),f.current.length<t){let e=await SC(t,i);e.length>f.current.length&&(f.current=e)}if(e>=f.current.length){m.current--;return}let n=e+1;o(n),b(f.current[e],!0),n>=2&&!l.current&&(l.current=!0,x())})()},[b,x]),onHistoryDown:(0,Q.useCallback)(()=>{let e=m.current;if(e>1)m.current--,o(e-1),b(f.current[e-2]);else if(e===1)if(m.current=0,o(0),s){let e=s.mode;e?y(s.display,e,s.pastedContents??{}):b(s)}else y(``,h.current??`prompt`,{});return e<=0},[s,b,y]),resetHistory:(0,Q.useCallback)(()=>{c(void 0),o(0),m.current=0,h.current=void 0,d(`search-history-hint`),f.current=[],p.current=void 0},[d]),dismissSearchHint:(0,Q.useCallback)(()=>{d(`search-history-hint`)},[d])}}q();function wC(){let e=J(e=>e.tasks);return(0,Q.useMemo)(()=>{let t=Date.now();return Object.values(e).filter(Yc).filter(e=>e.agentType!==`main-session`).filter(e=>e.isBackgrounded!==!1).filter(e=>e.evictAfter===void 0||e.evictAfter>t).sort((e,t)=>e.startTime-t.startTime)},[e])}Xu(),zu(),B(),Ah();function TC(e,t,n,r,i,a,o,s,c,l,u){let[d,f]=(0,Q.useState)(``),[p,m]=(0,Q.useState)(!1),[h,g]=(0,Q.useState)(``),[_,y]=(0,Q.useState)(0),[b,x]=(0,Q.useState)(`prompt`),[S,C]=(0,Q.useState)({}),[w,T]=(0,Q.useState)(void 0),E=(0,Q.useRef)(void 0),D=(0,Q.useRef)(new Set),O=(0,Q.useRef)(null),k=(0,Q.useCallback)(()=>{E.current&&(E.current.return(void 0),E.current=void 0)},[]),j=(0,Q.useCallback)(()=>{c(!1),f(``),m(!1),g(``),y(0),x(`prompt`),C({}),T(void 0),k(),D.current.clear()},[c,k]),M=(0,Q.useCallback)(async(e,t)=>{if(s){if(d.length===0){k(),D.current.clear(),T(void 0),m(!1),n(h),r(_),a(b),l(S);return}if(e||(k(),E.current=Hs(),D.current.clear()),E.current)for(;;){if(t?.aborted)return;let e=await E.current.next();if(e.done){m(!0);return}let i=e.value.display,o=i.lastIndexOf(d);if(o!==-1&&!D.current.has(i)){D.current.add(i),T(e.value),m(!1),a(fc(i)),n(i),l(e.value.pastedContents);let t=os(i).lastIndexOf(d);r(t===-1?o:t);return}}}},[s,d,k,n,r,a,l,h,_,b,S]),te=(0,Q.useCallback)(()=>{c(!0),g(t),y(i),x(o),C(u),E.current=Hs(),D.current.clear()},[c,t,i,o,u]),N=(0,Q.useCallback)(()=>{M(!0)},[M]),P=(0,Q.useCallback)(()=>{if(w){let e=fc(w.display);n(os(w.display)),a(e),l(w.pastedContents)}else l(S);j()},[w,n,a,l,S,j]),F=(0,Q.useCallback)(()=>{n(h),r(_),l(S),j()},[n,r,l,h,_,S,j]),ne=(0,Q.useCallback)(()=>{if(d.length===0)e({display:h,pastedContents:S});else if(w){let t=fc(w.display),n=os(w.display);a(t),e({display:n,pastedContents:w.pastedContents})}j()},[d,w,e,a,h,S,j]);A(`history:search`,te,{context:`Global`,isActive:!s}),v((0,Q.useMemo)(()=>({"historySearch:next":N,"historySearch:accept":P,"historySearch:cancel":F,"historySearch:execute":ne}),[N,P,F,ne]),{context:`HistorySearch`,isActive:s});let re=e=>{s&&e.key===`backspace`&&d===``&&(e.preventDefault(),F())};oe((e,t,n)=>{re(new ee(n.keypress))},{isActive:s});let I=(0,Q.useRef)(M);return I.current=M,(0,Q.useEffect)(()=>{O.current?.abort();let e=new AbortController;return O.current=e,I.current(!1,e.signal),()=>{e.abort()}},[d]),{historyQuery:d,setHistoryQuery:f,historyMatch:w,historyFailedMatch:p,handleKeyDown:re}}function EC({maxBufferSize:e,debounceMs:t}){let[n,r]=(0,Q.useState)([]),[i,a]=(0,Q.useState)(-1),o=(0,Q.useRef)(0),s=(0,Q.useRef)(null),c=(0,Q.useCallback)((l,u,d={})=>{let f=Date.now();if(s.current&&(clearTimeout(s.current),s.current=null),f-o.current<t){s.current=setTimeout(c,t,l,u,d);return}o.current=f,r(t=>{let n=i>=0?t.slice(0,i+1):t,r=n[n.length-1];if(r&&r.text===l)return n;let a=[...n,{text:l,cursorOffset:u,pastedContents:d,timestamp:f}];return a.length>e?a.slice(-e):a}),a(t=>{let r=t>=0?t+1:n.length;return Math.min(r,e-1)})},[t,e,i,n.length]),l=(0,Q.useCallback)(()=>{if(i<0||n.length===0)return;let e=Math.max(0,i-1),t=n[e];if(t)return a(e),t},[n,i]),u=(0,Q.useCallback)(()=>{r([]),a(-1),o.current=0,s.current&&(clearTimeout(s.current),s.current=null)},[o,s]);return{pushToBuffer:c,undo:l,canUndo:i>0&&n.length>1,clearBuffer:u}}B(),bp(),q();function DC({inputValue:e,isAssistantResponding:t}){let n=J(e=>e.promptSuggestion),r=Vr(),i=j(),{text:a,promptId:o,shownAt:s,acceptedAt:c,generationRequestId:l}=n,u=t||e.length>0?null:a,d=a&&s>0,f=(0,Q.useRef)(0),p=(0,Q.useRef)(!0),m=(0,Q.useRef)(0);s>0&&s!==m.current?(m.current=s,p.current=i,f.current=0):s===0&&(m.current=0),e.length>0&&f.current===0&&d&&(f.current=Date.now());let h=(0,Q.useCallback)(()=>{Kn(r),r(e=>({...e,promptSuggestion:{text:null,promptId:null,shownAt:0,acceptedAt:0,generationRequestId:null}}))},[r]);return{suggestion:u,markAccepted:(0,Q.useCallback)(()=>{d&&r(e=>({...e,promptSuggestion:{...e.promptSuggestion,acceptedAt:Date.now()}}))},[d,r]),markShown:(0,Q.useCallback)(()=>{r(e=>e.promptSuggestion.shownAt!==0||!e.promptSuggestion.text?e:{...e,promptSuggestion:{...e.promptSuggestion,shownAt:Date.now()}})},[r]),logOutcomeAtSubmission:(0,Q.useCallback)((e,t)=>{if(!d)return;let n=c>s,r=n||e===a,i=r&&c||Date.now();Z(`tengu_prompt_suggestion`,{source:`cli`,outcome:r?`accepted`:`ignored`,prompt_id:o,...l&&{generationRequestId:l},...r&&{acceptMethod:n?`tab`:`enter`},...r&&{timeToAcceptMs:i-s},...!r&&{timeToIgnoreMs:i-s},...f.current>0&&{timeToFirstKeystrokeMs:f.current-s},wasFocusedWhenShown:p.current,similarity:Math.round(e.length/(a?.length||1)*100)/100,...process.env.USER_TYPE===`ant`&&{suggestion:a,userInput:e}}),t?.skipReset||h()},[d,c,s,a,o,l,h])}}Yl(),tf(),Jh();var OC=15,kC=1e3,AC=[`|`,`||`,`&&`,`;`];function jC(e){return typeof e==`object`&&!!e&&`op`in e&&AC.includes(e.op)}function MC(e){return e.startsWith(`$`)?`variable`:e.includes(`/`)||e.startsWith(`~`)||e.startsWith(`.`)?`file`:`command`}function NC(e){let t=e.findLastIndex(e=>typeof e==`string`);return t===-1?null:{token:e[t],index:t}}function PC(e,t){if(t===0)return!0;let n=e[t-1];return n!==void 0&&jC(n)}function FC(e,t){let n=e.slice(0,t),r=n.match(/\$[a-zA-Z_][a-zA-Z0-9_]*$/);if(r)return{prefix:r[0],completionType:`variable`};let i=qm(n);if(!i.success){let e=n.split(/\s+/),t=e[e.length-1]||``;return{prefix:t,completionType:e.length===1&&!n.includes(` `)?`command`:MC(t)}}let a=NC(i.tokens);if(!a){let e=i.tokens[i.tokens.length-1];return{prefix:``,completionType:(e&&jC(e),`command`)}}if(n.endsWith(` `))return{prefix:``,completionType:`file`};let o=MC(a.token);if(o===`variable`||o===`file`)return{prefix:a.token,completionType:o};let s=PC(i.tokens,a.index)?`command`:`file`;return{prefix:a.token,completionType:s}}function IC(e,t){return t===`variable`?`compgen -v ${Jm([e.slice(1)])} 2>/dev/null`:t===`file`?`compgen -f ${Jm([e])} 2>/dev/null | head -${OC} | while IFS= read -r f; do [ -d "$f" ] && echo "$f/" || echo "$f "; done`:`compgen -c ${Jm([e])} 2>/dev/null`}function LC(e,t){return t===`variable`?`print -rl -- \${(k)parameters[(I)${Jm([e.slice(1)])}*]} 2>/dev/null`:t===`file`?`for f in ${Jm([e])}*(N[1,${OC}]); do [[ -d "$f" ]] && echo "$f/" || echo "$f "; done`:`print -rl -- \${(k)commands[(I)${Jm([e])}*]} 2>/dev/null`}async function RC(e,t,n,r){let i;if(e===`bash`)i=IC(t,n);else if(e===`zsh`)i=LC(t,n);else return[];return(await(await no(i,r,`bash`,{timeout:kC})).result).stdout.split(`
|
|
42
|
+
`).filter(e=>e.trim()).slice(0,OC).map(e=>({id:e,displayText:e,description:void 0,metadata:{completionType:n}}))}async function zC(e,t,n){let r=Yh();if(r!==`bash`&&r!==`zsh`)return[];try{let{prefix:i,completionType:a}=FC(e,t);return i?(await RC(r,i,a,n)).map(t=>({...t,metadata:{...t.metadata,inputSnapshot:e}})):[]}catch(e){return Y(`Shell completion failed: ${e}`),[]}}V_(),la();var BC=/[:_-]/g,VC=null;function HC(e){if(VC?.commands===e)return VC.fuse;let t=new Y_(e.filter(e=>!e.isHidden).map(e=>{let t=Ns(e),n=t.split(BC).filter(Boolean);return{descriptionKey:(e.description??``).split(` `).map(e=>ew(e)).filter(Boolean),partKey:n.length>1?n:void 0,commandName:t,command:e,aliasKey:e.aliases}}),{includeScore:!0,threshold:.3,location:0,distance:100,keys:[{name:`commandName`,weight:3},{name:`partKey`,weight:2},{name:`aliasKey`,weight:2},{name:`descriptionKey`,weight:.5}]});return VC={commands:e,fuse:t},t}function UC(e){return typeof e==`object`&&!!e&&`name`in e&&typeof e.name==`string`&&`type`in e}function WC(e,t){if(e.startsWith(`/`))return null;let n=e.slice(0,t).match(/\s\/([a-zA-Z0-9_:-]*)$/);if(!n||n.index===void 0)return null;let r=n.index+1,i=e.slice(r+1).match(/^[a-zA-Z0-9_:-]*/),a=i?i[0]:``;return t>r+1+a.length?null:{token:`/`+a,startPos:r,partialCommand:a}}function GC(e,t){if(!e)return null;let n=QC(`/`+e,t);if(n.length===0)return null;let r=e.toLowerCase();for(let t of n){if(!UC(t.metadata))continue;let n=Ns(t.metadata);if(n.toLowerCase().startsWith(r)){let t=n.slice(e.length);if(t)return{suffix:t,fullCommand:n}}}return null}function KC(e){return e.startsWith(`/`)}function qC(e){return!(!KC(e)||!e.includes(` `)||e.endsWith(` `))}function JC(e){return`/${e} `}function YC(e){let t=Ns(e);return e.type===`prompt`?e.source===`plugin`&&e.pluginInfo?.repository?`${t}:${e.source}:${e.pluginInfo.repository}`:`${t}:${e.source}`:`${t}:${e.type}`}function XC(e,t){if(!(!t||t.length===0||e===``))return t.find(t=>t.toLowerCase().startsWith(e))}function ZC(e,t){let n=Ns(e),r=t?` (${t})`:``,i=e.type===`prompt`&&e.kind===`workflow`,a=e.type===`prompt`&&!i&&(e.source===`projectSettings`||e.source===`localSettings`)?`local`:void 0,o=(i?e.description:Oo(e))+(e.type===`prompt`&&e.argNames?.length?` (arguments: ${e.argNames.join(`, `)})`:``);return{id:YC(e),displayText:`/${n}${r}`,tag:i?`workflow`:a,description:o,metadata:e}}function QC(e,t){if(!KC(e)||qC(e))return[];let n=e.slice(1).toLowerCase().trim();if(n===``){let e=t.filter(e=>!e.isHidden),n=[],r=e.filter(e=>e.type===`prompt`).map(e=>({cmd:e,score:hl(Ns(e))})).filter(e=>e.score>0).sort((e,t)=>t.score-e.score);for(let e of r.slice(0,5))n.push(e.cmd);let i=new Set(n.map(e=>YC(e))),a=[],o=[],s=[],c=[],l=[];e.forEach(e=>{i.has(YC(e))||(e.type===`local`||e.type===`local-jsx`?a.push(e):e.type===`prompt`&&(e.source===`userSettings`||e.source===`localSettings`)?o.push(e):e.type===`prompt`&&e.source===`projectSettings`?s.push(e):e.type===`prompt`&&e.source===`policySettings`?c.push(e):l.push(e))});let u=(e,t)=>Ns(e).localeCompare(Ns(t));return a.sort(u),o.sort(u),s.sort(u),c.sort(u),l.sort(u),[...n,...a,...o,...s,...c,...l].map(e=>ZC(e))}let r=t.find(e=>e.isHidden&&Ns(e).toLowerCase()===n);r&&t.some(e=>!e.isHidden&&Ns(e).toLowerCase()===n)&&(r=void 0);let i=HC(t).search(n).map(e=>({r:e,name:e.item.commandName.toLowerCase(),aliases:e.item.aliasKey?.map(e=>e.toLowerCase())??[],usage:e.item.command.type===`prompt`?hl(Ns(e.item.command)):0})).sort((e,t)=>{let r=e.name,i=t.name,a=e.aliases,o=t.aliases,s=r===n,c=i===n;if(s&&!c)return-1;if(c&&!s)return 1;let l=a.some(e=>e===n),u=o.some(e=>e===n);if(l&&!u)return-1;if(u&&!l)return 1;let d=r.startsWith(n),f=i.startsWith(n);if(d&&!f)return-1;if(f&&!d)return 1;if(d&&f&&r.length!==i.length)return r.length-i.length;let p=a.find(e=>e.startsWith(n)),m=o.find(e=>e.startsWith(n));if(p&&!m)return-1;if(m&&!p)return 1;if(p&&m&&p.length!==m.length)return p.length-m.length;let h=(e.r.score??0)-(t.r.score??0);return Math.abs(h)>.1?h:t.usage-e.usage}).map(e=>{let t=e.r.item.command;return ZC(t,XC(n,t.aliases))});if(r){let e=YC(r);if(!i.some(t=>t.id===e))return[ZC(r),...i]}return i}function $C(e,t,n,r,i,a){let o,s;if(typeof e==`string`)o=e,s=t?Kr(o,n):void 0;else{if(!UC(e.metadata))return;o=Ns(e.metadata),s=e.metadata}let c=JC(o);r(c),i(c.length),t&&s&&(s.type!==`prompt`||(s.argNames??[]).length===0)&&a(c,!0)}function ew(e){return e.toLowerCase().replace(/[^a-z0-9]/g,``)}function tw(e){let t=[],n=/(^|[\s])(\/[a-zA-Z][a-zA-Z0-9:\-_]*)/g,r=null;for(;(r=n.exec(e))!==null;){let e=r[1]??``,n=r[2]??``,i=r.index+e.length;t.push({start:i,end:i+n.length})}return t}Mg(),zu(),tf();var nw=null,rw=0,iw=6e4;async function aw(){let e=Date.now();if(nw&&e-rw<iw)return nw;let t=[],n=new Set;try{for await(let e of js()){if(e.display&&e.display.startsWith(`!`)){let r=e.display.slice(1).trim();r&&!n.has(r)&&(n.add(r),t.push(r))}if(t.length>=50)break}}catch(e){Y(`Failed to read shell history: ${e}`)}return nw=t,rw=e,t}function ow(e){if(!nw)return;let t=nw.indexOf(e);t!==-1&&nw.splice(t,1),nw.unshift(e)}async function sw(e){if(!e||e.length<2||!e.trim())return null;let t=await aw();for(let n of t)if(n.startsWith(e)&&n!==e)return{fullCommand:n,suffix:n.slice(e.length)};return null}tf(),Oe(),We(),Zd();var cw=`slack_search_channels`,lw=new Map,uw=new Set,dw=0,fw=_t(),pw=fw.subscribe,mw=null,hw=null;function gw(e){return e.find(e=>e.type===`connected`&&e.name.includes(`slack`))}async function _w(e,t){let n=gw(e);if(!n||n.type!==`connected`)return[];try{let e=(await n.client.callTool({name:cw,arguments:{query:t,limit:20,channel_types:`public_channel,private_channel`}},void 0,{timeout:5e3})).content;return Array.isArray(e)?bw(yw(e.filter(e=>e.type===`text`).map(e=>e.text).join(`
|
|
43
|
+
`))):[]}catch(e){return Y(`Failed to fetch Slack channels: ${e}`),[]}}var vw=Te(()=>ye({results:be()}));function yw(e){let t=e.trim();if(!t.startsWith(`{`))return e;try{let e=vw().safeParse(Kd(t));if(e.success)return e.data.results}catch{}return e}function bw(e){let t=[],n=new Set;for(let r of e.split(`
|
|
44
|
+
`)){let e=r.match(/^Name:\s*#?([a-z0-9][a-z0-9_-]{0,79})\s*$/);e&&!n.has(e[1])&&(n.add(e[1]),t.push(e[1]))}return t}function xw(e){return gw(e)!==void 0}function Sw(){return dw}function Cw(e){let t=[],n=/(^|\s)#([a-z0-9][a-z0-9_-]{0,79})(?=\s|$)/g,r;for(;(r=n.exec(e))!==null;){if(!uw.has(r[2]))continue;let e=r.index+r[1].length;t.push({start:e,end:e+1+r[2].length})}return t}function ww(e){let t=Math.max(e.lastIndexOf(`-`),e.lastIndexOf(`_`));return t>0?e.slice(0,t):e}function Tw(e,t){let n,r=0;for(let[i,a]of lw)e.startsWith(i)&&i.length>r&&a.some(e=>e.startsWith(t))&&(n=a,r=i.length);return n}async function Ew(e,t){if(!t)return[];let n=ww(t),r=t.toLowerCase(),i=lw.get(n)??Tw(n,r);if(!i)if(mw===n&&hw)i=await hw;else{mw=n,hw=_w(e,n),i=await hw,lw.set(n,i);let t=uw.size;for(let e of i)uw.add(e);uw.size!==t&&(dw++,fw.emit()),lw.size>50&&lw.delete(lw.keys().next().value),mw===n&&(mw=null,hw=null)}return i.filter(e=>e.startsWith(r)).sort().slice(0,10).map(e=>({id:`slack-channel-${e}`,displayText:`#${e}`}))}V_(),t_(),Ct(),Ep(),np();function Dw(e){switch(e.type){case`file`:return{id:`file-${e.path}`,displayText:e.displayText,description:e.description};case`mcp_resource`:return{id:`mcp-resource-${e.server}__${e.uri}`,displayText:e.displayText,description:e.description};case`agent`:return{id:`agent-${e.agentType}`,displayText:e.displayText,description:e.description,color:e.color}}}var Ow=15,kw=60;function Aw(e){return Tp(e,kw)}function jw(e,t,n=!1){if(!t&&!n)return[];try{let n=e.map(e=>({type:`agent`,displayText:`${e.agentType} (agent)`,description:Aw(e.whenToUse),agentType:e.agentType,color:sa(e.agentType)}));if(!t)return n;let r=t.toLowerCase();return n.filter(e=>e.agentType.toLowerCase().includes(r)||e.displayText.toLowerCase().includes(r))}catch(e){return X(e),[]}}async function Mw(e,t,n,r=!1){if(!e&&!r)return[];let[i,a]=await Promise.all([Qg(e,r),Promise.resolve(jw(n,e,r))]),o=i.map(e=>({type:`file`,displayText:e.displayText,description:e.description,path:e.displayText,filename:vv(e.displayText),score:e.metadata?.score})),s=Object.values(t).flat().map(e=>({type:`mcp_resource`,displayText:`${e.server}:${e.uri}`,description:Aw(e.description||e.name||e.uri),server:e.server,uri:e.uri,name:e.name||e.uri}));if(!e)return[...o,...s,...a].slice(0,Ow).map(Dw);let c=[...s,...a],l=[];for(let e of o)l.push({source:e,score:e.score??.5});if(c.length>0){let t=new Y_(c,{includeScore:!0,threshold:.6,keys:[{name:`displayText`,weight:2},{name:`name`,weight:3},{name:`server`,weight:1},{name:`description`,weight:1},{name:`agentType`,weight:3}]}).search(e,{limit:Ow});for(let e of t)l.push({source:e.item,score:e.score??.5})}return l.sort((e,t)=>e.score-t.score),l.slice(0,Ow).map(e=>e.source).map(Dw)}Rt(),B(),bp(),me(),la(),Xu(),ps(),qa(),Ah(),cn(),q(),Ep(),Jc(),t_();var Nw=/^@[\p{L}\p{N}\p{M}_\-./\\()[\]~:]*/u,Pw=/^[\p{L}\p{N}\p{M}_\-./\\()[\]~:]+/u,Fw=/(@[\p{L}\p{N}\p{M}_\-./\\()[\]~:]*|[\p{L}\p{N}\p{M}_\-./\\()[\]~:]+)$/u,Iw=/[\p{L}\p{N}\p{M}_\-./\\()[\]~:]+$/u,Lw=/(^|\s)@([\p{L}\p{N}\p{M}_\-./\\()[\]~:]*|"[^"]*"?)$/u,Rw=/(^|\s)#([a-z0-9][a-z0-9_-]*)$/;function zw(e){return typeof e==`object`&&!!e&&`type`in e&&(e.type===`directory`||e.type===`file`)}function Bw(e,t,n){if(n.length===0)return-1;if(t<0)return 0;let r=e[t];if(!r)return 0;let i=n.findIndex(e=>e.id===r.id);return i>=0?i:0}function Vw(e){let t=e.metadata;return t?.sessionId?`/resume ${t.sessionId}`:`/resume ${e.displayText}`}function Hw(e){return e.isQuoted?e.token.slice(2).replace(/"$/,``):e.token.startsWith(`@`)?e.token.substring(1):e.token}function Uw(e){let{displayText:t,mode:n,hasAtPrefix:r,needsQuotes:i,isQuoted:a,isComplete:o}=e,s=o?` `:``;return a||i?n===`bash`?`"${t}"${s}`:`@"${t}"${s}`:r?n===`bash`?`${t}${s}`:`@${t}${s}`:t}function Ww(e,t,n,r,i,a){let o=t.slice(0,n).lastIndexOf(` `)+1,s;s=a===`variable`?`$`+e.displayText+` `:a===`command`?e.displayText+` `:e.displayText,r(t.slice(0,o)+s+t.slice(n)),i(o+s.length)}var Gw=/(^|\s)@[\w-]*$/;function Kw(e,t,n,r,i,a){let o=t.slice(0,n).match(r);if(!o||o.index===void 0)return;let s=o.index+(o[1]?.length??0),c=t.slice(0,s);i(c+e.displayText+` `+t.slice(n)),a(c.length+e.displayText.length+1)}var qw=null;async function Jw(e,t){try{return qw&&qw.abort(),qw=new AbortController,await zC(e,t,qw.signal)}catch{return Z(`tengu_shell_completion_failed`,{}),[]}}function Yw(e,t,n,r,i){let a=i?`/`:` `,o=e.slice(0,n),s=e.slice(n+r),c=`@`+t+a;return{newInput:o+c+s,cursorPos:o.length+c.length}}function Xw(e,t,n=!1){if(!e)return null;let r=e.substring(0,t);if(n){let n=r.match(/@"([^"]*)"?$/);if(n&&n.index!==void 0){let r=e.substring(t).match(/^[^"]*"?/),i=r?r[0]:``;return{token:n[0]+i,startPos:n.index,isQuoted:!0}}}if(n){let n=r.lastIndexOf(`@`);if(n>=0&&(n===0||/\s/.test(r[n-1]))){let i=r.substring(n),a=i.match(Nw);if(a&&a[0].length===i.length){let r=e.substring(t).match(Pw),i=r?r[0]:``;return{token:a[0]+i,startPos:n,isQuoted:!1}}}}let i=n?Fw:Iw,a=r.match(i);if(!a||a.index===void 0)return null;let o=e.substring(t).match(Pw),s=o?o[0]:``;return{token:a[0]+s,startPos:a.index,isQuoted:!1}}function Zw(e){if(KC(e)){let t=e.indexOf(` `);return t===-1?{commandName:e.slice(1),args:``}:{commandName:e.slice(1,t),args:e.slice(t+1)}}return null}function Qw(e,t){return!e&&t.includes(` `)&&!t.endsWith(` `)}function $w({commands:e,onInputChange:t,onSubmit:n,setCursorOffset:r,input:i,cursorOffset:a,mode:o,agents:s,setSuggestionsState:c,suggestionsState:{suggestions:l,selectedSuggestion:u,commandArgumentHint:d},suppressSuggestions:f=!1,markAccepted:p,onModeChange:m}){let{addNotification:h}=lo(),g=ud(`chat:thinkingToggle`,`Chat`,`alt+t`),[_,y]=(0,Q.useState)(`none`),b=(0,Q.useMemo)(()=>{let t=e.filter(e=>!e.isHidden);if(t.length!==0)return Math.max(...t.map(e=>{let t=Ns(e);return t?t.length:0}))+6},[e]),[x,S]=(0,Q.useState)(void 0),C=J(e=>e.mcp.resources),w=qn(),E=J(e=>e.promptSuggestion),D=J(e=>!!e.viewingAgentTaskId),O=N(),[k,A]=(0,Q.useState)(void 0),j=(0,Q.useMemo)(()=>{if(o!==`prompt`||f)return;let t=WC(i,a);if(!t)return;let n=GC(t.partialCommand,e);if(n)return{text:n.suffix,fullCommand:n.fullCommand,insertPosition:t.startPos+1+t.partialCommand.length}},[i,a,o,e,f]),te=f?void 0:o===`prompt`?j:k,P=(0,Q.useRef)(a);P.current=a;let F=(0,Q.useRef)(null),ne=(0,Q.useRef)(``),re=(0,Q.useRef)(``),I=(0,Q.useRef)(``),L=(0,Q.useRef)(``),ie=(0,Q.useRef)(l);ie.current=l;let R=(0,Q.useRef)(null),z=(0,Q.useCallback)(()=>{c(()=>({commandArgumentHint:void 0,suggestions:[],selectedSuggestion:-1})),y(`none`),S(void 0),A(void 0)},[c]),ae=(0,Q.useCallback)(async(e,t=!1)=>{F.current=e;let n=await Mw(e,C,s,t);if(F.current===e){if(n.length===0){c(()=>({commandArgumentHint:void 0,suggestions:[],selectedSuggestion:-1})),y(`none`),S(void 0);return}c(e=>({commandArgumentHint:void 0,suggestions:n,selectedSuggestion:Bw(e.suggestions,e.selectedSuggestion,n)})),y(n.length>0?`file`:`none`),S(void 0)}},[C,c,y,S,s]);(0,Q.useEffect)(()=>($g(),r_(()=>{let e=F.current;e!==null&&(F.current=null,ae(e,e===``))})),[ae]);let se=U(ae,50),ce=U((0,Q.useCallback)(async e=>{L.current=e;let t=await Ew(w.getState().mcp.clients,e);L.current===e&&(c(e=>({commandArgumentHint:void 0,suggestions:t,selectedSuggestion:Bw(e.suggestions,e.selectedSuggestion,t)})),y(t.length>0?`slack-channel`:`none`),S(void 0))},[c]),150),le=(0,Q.useCallback)(async(t,n)=>{let r=n??P.current;if(f){se.cancel(),z();return}if(o===`prompt`){let n=WC(t,r);if(n&&GC(n.partialCommand,e)){c(()=>({commandArgumentHint:void 0,suggestions:[],selectedSuggestion:-1})),y(`none`),S(void 0);return}}if(o===`bash`&&t.trim()){I.current=t;let e=await sw(t);if(I.current!==t)return;if(e){A({text:e.suffix,fullCommand:e.fullCommand,insertPosition:t.length}),c(()=>({commandArgumentHint:void 0,suggestions:[],selectedSuggestion:-1})),y(`none`),S(void 0);return}else A(void 0)}let i=o===`bash`?null:t.substring(0,r).match(/(^|\s)@([\w-]*)$/);if(i){let e=(i[2]??``).toLowerCase(),t=w.getState(),n=[],r=new Set;for(let[i,a]of t.agentNameRegistry){if(r.has(i)||!i.toLowerCase().startsWith(e))continue;let o=t.tasks[a]?.status;n.push({id:`dm-${i}`,displayText:`@${i}`,description:o?`send message · ${o}`:`send message`})}if(n.length>0){se.cancel(),c(e=>({commandArgumentHint:void 0,suggestions:n,selectedSuggestion:Bw(e.suggestions,e.selectedSuggestion,n)})),y(`agent`),S(void 0);return}}if(o===`prompt`){let e=t.substring(0,r).match(Rw);if(e&&xw(w.getState().mcp.clients)){ce(e[2]);return}else _===`slack-channel`&&(ce.cancel(),z())}let a=t.substring(0,r).match(Lw),s=r===t.length&&r>0&&t.length>0&&t[r-1]===` `;if(o===`prompt`&&KC(t)&&r>0){let e=Zw(t);if(e&&e.commandName===`add-dir`&&e.args){let{args:t}=e;if(t.match(/\s+$/)){se.cancel(),z();return}let n=await Ng(t);if(n.length>0){c(e=>({suggestions:n,selectedSuggestion:Bw(e.suggestions,e.selectedSuggestion,n),commandArgumentHint:void 0})),y(`directory`);return}se.cancel(),z();return}if(e&&e.commandName===`resume`&&e.args!==void 0&&t.includes(` `)){let{args:t}=e,n=(await sd(t,{limit:10})).map(e=>{let t=an(e);return{id:`resume-title-${t}`,displayText:e.customTitle,description:Op(e),metadata:{sessionId:t}}});if(n.length>0){c(e=>({suggestions:n,selectedSuggestion:Bw(e.suggestions,e.selectedSuggestion,n),commandArgumentHint:void 0})),y(`custom-title`);return}z();return}}let l=t.substring(0,r);if(o===`prompt`&&KC(l)&&r>0&&!Qw(s,l)){let t;if(l.length>1){let n=l.indexOf(` `),r=n===-1?l.slice(1):l.slice(1,n),i=n!==-1&&l.slice(n+1).trim().length>0,a=n!==-1&&l.length===n+1;if(n!==-1){let o=e.find(e=>{let t=Ns(e);return t&&t===r});if(o||i){if(o?.argumentHint&&a)t=o.argumentHint;else if(o?.type===`prompt`&&o.argNames?.length&&l.endsWith(` `)){let e=vl(l.slice(n+1));t=oc(o.argNames,e)}c(()=>({commandArgumentHint:t,suggestions:[],selectedSuggestion:-1})),y(`none`),S(void 0);return}}}let n=QC(l,e);c(()=>({commandArgumentHint:t,suggestions:n,selectedSuggestion:n.length>0?0:-1})),y(n.length>0?`command`:`none`),n.length>0&&S(b);return}if(_===`command`?(se.cancel(),z()):KC(l)&&Qw(s,l)&&c(e=>e.commandArgumentHint?{...e,commandArgumentHint:void 0}:e),_===`custom-title`&&z(),_===`agent`&&ie.current.some(e=>e.id?.startsWith(`dm-`))&&(t.substring(0,r).match(/(^|\s)@([\w-]*)$/)||z()),a&&o!==`bash`){let e=Xw(t,r,!0);if(e&&e.token.startsWith(`@`)){let t=Hw(e);if(Ag(t)){re.current=t;let e=await jg(t,{maxResults:10});if(re.current!==t)return;if(e.length>0){c(t=>({suggestions:e,selectedSuggestion:Bw(t.suggestions,t.selectedSuggestion,e),commandArgumentHint:void 0})),y(`directory`);return}}if(F.current===t)return;se(t,!0);return}}if(_===`file`){let e=Xw(t,r,!0);if(e){let t=Hw(e);if(F.current===t)return;se(t,!1)}else se.cancel(),z()}if(_===`shell`){let e=ie.current[0]?.metadata?.inputSnapshot;(o!==`bash`||t!==e)&&(se.cancel(),z())}},[_,e,c,z,se,ce,o,f,b]);(0,Q.useEffect)(()=>{R.current!==i&&(ne.current!==i&&(ne.current=i,F.current=null),R.current=null,le(i))},[i,le]);let ue=(0,Q.useCallback)(async()=>{if(te){if(o===`bash`){t(te.fullCommand),r(te.fullCommand.length),A(void 0);return}let e=WC(i,a);if(e){let n=i.slice(0,e.startPos),a=i.slice(e.startPos+e.token.length),o=n+`/`+te.fullCommand+` `+a,s=e.startPos+1+te.fullCommand.length+1;t(o),r(s);return}}if(l.length>0){se.cancel(),ce.cancel();let e=u===-1?0:u,n=l[e];if(_===`command`&&e<l.length){if(n){let e=n.metadata;if(e&&typeof e==`object`&&`name`in e&&`type`in e){let n=`/${Ns(e)} `;t(n+i.slice(a)),r(n.length)}z()}}else if(_===`custom-title`&&l.length>0){if(n){let e=Vw(n);t(e),r(e.length),z()}}else if(_===`directory`&&l.length>0){let n=l[e];if(n){let e=KC(i),o;if(e){let e=i.indexOf(` `),a=i.slice(0,e+1),s=zw(n.metadata)&&n.metadata.type===`directory`?`/`:` `;o=a+n.id+s,t(o),r(o.length),zw(n.metadata)&&n.metadata.type===`directory`?(c(e=>({...e,commandArgumentHint:void 0})),le(o,o.length)):z()}else{let e=Xw(i,a,!0)??Xw(i,a,!1);if(e){let a=zw(n.metadata)&&n.metadata.type===`directory`,s=Yw(i,n.id,e.startPos,e.token.length,a);o=s.newInput,t(o),r(s.cursorPos),a?(c(e=>({...e,commandArgumentHint:void 0})),le(o,s.cursorPos)):z()}else z()}}}else if(_===`shell`&&l.length>0){let n=l[e];if(n){let e=n.metadata;Ww(n,i,a,t,r,e?.completionType),z()}}else if(_===`agent`&&l.length>0&&l[e]?.id?.startsWith(`dm-`)){let n=l[e];n&&(Kw(n,i,a,Gw,t,r),z())}else if(_===`slack-channel`&&l.length>0){let n=l[e];n&&(Kw(n,i,a,Rw,t,r),z())}else if(_===`file`&&l.length>0){let n=Xw(i,a,!0);if(!n){z();return}let s=e_(l),c=n.token.startsWith(`@`),u;if(u=n.isQuoted?n.token.slice(2).replace(/"$/,``).length:c?n.token.length-1:n.token.length,s.length>u){let e=Uw({displayText:s,mode:o,hasAtPrefix:c,needsQuotes:!1,isQuoted:n.isQuoted,isComplete:!1});n_(e,i,n.token,n.startPos,t,r),le(i.replace(n.token,e),a)}else if(e<l.length){let a=l[e];if(a){let e=a.displayText.includes(` `);n_(Uw({displayText:a.displayText,mode:o,hasAtPrefix:c,needsQuotes:e,isQuoted:n.isQuoted,isComplete:!0}),i,n.token,n.startPos,t,r),z()}}}}else if(i.trim()!==``){let e,n;if(o===`bash`){e=`shell`;let o=await Jw(i,a);if(o.length===1){let e=o[0];if(e){let n=e.metadata;Ww(e,i,a,t,r,n?.completionType)}n=[]}else n=o}else{e=`file`;let t=Xw(i,a,!0);if(t){let e=t.token.startsWith(`@`);n=await Mw(e?t.token.substring(1):t.token,C,s,e)}else n=[]}n.length>0&&(c(e=>({commandArgumentHint:void 0,suggestions:n,selectedSuggestion:Bw(e.suggestions,e.selectedSuggestion,n)})),y(e),S(void 0))}},[l,u,i,_,e,o,t,r,n,z,a,le,C,c,s,se,ce,te]),de=(0,Q.useCallback)(()=>{if(u<0||l.length===0)return;let s=l[u];if(_===`command`&&u<l.length)s&&($C(s,!0,e,t,r,n),se.cancel(),z());else if(_===`custom-title`&&u<l.length){if(s){let e=Vw(s);t(e),r(e.length),n(e,!0),se.cancel(),z()}}else if(_===`shell`&&u<l.length){let e=l[u];if(e){let n=e.metadata;Ww(e,i,a,t,r,n?.completionType),se.cancel(),z()}}else if(_===`agent`&&u<l.length&&s?.id?.startsWith(`dm-`))Kw(s,i,a,Gw,t,r),se.cancel(),z();else if(_===`slack-channel`&&u<l.length)s&&(Kw(s,i,a,Rw,t,r),ce.cancel(),z());else if(_===`file`&&u<l.length){let e=Xw(i,a,!0);if(e&&s){let n=e.token.startsWith(`@`),a=s.displayText.includes(` `);n_(Uw({displayText:s.displayText,mode:o,hasAtPrefix:n,needsQuotes:a,isQuoted:e.isQuoted,isComplete:!0}),i,e.token,e.startPos,t,r),se.cancel(),z()}}else if(_===`directory`&&u<l.length&&s){if(KC(i)){se.cancel(),z();return}let e=Xw(i,a,!0)??Xw(i,a,!1);if(e){let n=zw(s.metadata)&&s.metadata.type===`directory`,a=Yw(i,s.id,e.startPos,e.token.length,n);t(a.newInput),r(a.cursorPos)}se.cancel(),z()}},[l,u,_,e,i,a,o,t,r,n,z,se,ce]),fe=(0,Q.useCallback)(()=>{ue()},[ue]),pe=(0,Q.useCallback)(()=>{se.cancel(),ce.cancel(),z(),R.current=i},[se,ce,z,i]),B=(0,Q.useCallback)(()=>{c(e=>({...e,selectedSuggestion:e.selectedSuggestion<=0?l.length-1:e.selectedSuggestion-1}))},[l.length,c]),V=(0,Q.useCallback)(()=>{c(e=>({...e,selectedSuggestion:e.selectedSuggestion>=l.length-1?0:e.selectedSuggestion+1}))},[l.length,c]),H=(0,Q.useMemo)(()=>({"autocomplete:accept":fe,"autocomplete:dismiss":pe,"autocomplete:previous":B,"autocomplete:next":V}),[fe,pe,B,V]),me=l.length>0||!!te,he=td();ks(`autocomplete`,me),M(`Autocomplete`,me),v(H,{context:`Autocomplete`,isActive:me&&!he});function ge(e){let n=fc(e);if(n!==`prompt`&&m){m(n);let i=os(e);t(i),r(i.length)}else t(e),r(e.length)}let _e=e=>{if(e.key===`right`&&!D){let t=E.text,n=E.shownAt;if(t&&n>0&&i===``){p(),ge(t),e.stopImmediatePropagation();return}}if(e.key===`tab`&&!e.shift){if(l.length>0||te)return;let t=E.text,n=E.shownAt;if(t&&n>0&&i===``&&!D){e.preventDefault(),p(),ge(t);return}i.trim()===``&&(e.preventDefault(),h({key:`thinking-toggle-hint`,jsx:(0,$.jsxs)(T,{dimColor:!0,children:[`Use `,g,` to toggle thinking`]}),priority:`immediate`,timeoutMs:3e3}));return}if(l.length===0)return;let t=O?.pendingChord!=null;if(e.ctrl&&e.key===`n`&&!t){e.preventDefault(),V();return}if(e.ctrl&&e.key===`p`&&!t){e.preventDefault(),B();return}e.key===`return`&&!e.shift&&!e.meta&&(e.preventDefault(),de())};return oe((e,t,n)=>{let r=new ee(n.keypress);_e(r),r.didStopImmediatePropagation()&&n.stopImmediatePropagation()}),{suggestions:l,selectedSuggestion:u,suggestionType:_,maxColumnWidth:x,commandArgumentHint:d,inlineGhostText:te,handleKeyDown:_e}}d_();var eT={"†":`alt+t`,π:`alt+p`,ø:`alt+o`};function tT(e){return e in eT}Xt();function nT(e){switch(e.mode){case`default`:return`acceptEdits`;case`acceptEdits`:return`plan`;case`plan`:return`auto`;case`auto`:return e.isBypassPermissionsModeAvailable?`bypassPermissions`:`default`;case`bypassPermissions`:return`default`;case`dontAsk`:return`default`;default:return`default`}}function rT(e){let t=nT(e);return{nextMode:t,context:Ui(e.mode,t,e)}}bg();var iT=Hh();at(),ml(),ps(),B(),Ah(),q(),Rf();function aT({onDone:e}){ks(`bridge-dialog`);let t=J(e=>e.replBridgeConnected),n=J(e=>e.replBridgeSessionActive),r=J(e=>e.replBridgeReconnecting),i=J(e=>e.replBridgeConnectUrl),a=J(e=>e.replBridgeSessionUrl),o=J(e=>e.replBridgeError),s=J(e=>e.replBridgeExplicit),c=J(e=>e.replBridgeEnvironmentId),l=J(e=>e.replBridgeSessionId),u=J(e=>e.verbose),d=Vr(),[f,p]=(0,Q.useState)(!1),[m,h]=(0,Q.useState)(``),[g,_]=(0,Q.useState)(``),y=vv(ut());(0,Q.useEffect)(()=>{Gf().then(_).catch(()=>{})},[]);let x=n?a:i;(0,Q.useEffect)(()=>{if(!f||!x){h(``);return}(0,iT.toString)(x,{type:`terminal`,errorCorrectionLevel:`L`,small:!0}).then(h).catch(()=>h(``))},[f,x]),v({"confirm:yes":e,"confirm:toggle":()=>{p(e=>!e)}},{context:`Confirmation`}),oe(t=>{t===`d`&&(s&&If(e=>e.remoteControlAtStartup===!1?e:{...e,remoteControlAtStartup:!1}),d(e=>e.replBridgeEnabled?{...e,replBridgeEnabled:!1}:e),e())});let{label:S,color:C}=Vs({error:o,connected:t,sessionActive:n,reconnecting:r}),w=o?`×`:xf,E=m?m.split(`
|
|
45
|
+
`).filter(e=>e.length>0):[],D=[];y&&D.push(y),g&&D.push(g);let O=D.length>0?` · `+D.join(` · `):``,k=o?Al:x?n?zc(x):ju(x):void 0;return(0,$.jsx)(ge,{title:`Remote Control`,onCancel:e,hideInputGuide:!0,children:(0,$.jsxs)(b,{flexDirection:`column`,gap:1,children:[(0,$.jsxs)(b,{flexDirection:`column`,children:[(0,$.jsxs)(T,{children:[(0,$.jsxs)(T,{color:C,children:[w,` `,S]}),(0,$.jsx)(T,{dimColor:!0,children:O})]}),o&&(0,$.jsx)(T,{color:`error`,children:o}),u&&c&&(0,$.jsxs)(T,{dimColor:!0,children:[`Environment: `,c]}),u&&l&&(0,$.jsxs)(T,{dimColor:!0,children:[`Session: `,l]})]}),f&&E.length>0&&(0,$.jsx)(b,{flexDirection:`column`,children:E.map((e,t)=>(0,$.jsx)(T,{children:e},t))}),k&&(0,$.jsx)(T,{dimColor:!0,children:k}),(0,$.jsx)(T,{dimColor:!0,children:`d to disconnect · space for QR code · Enter/Esc to close`})]})})}B(),ps(),ms(),B(),Wd(),Rg(),Ep(),oi(),ps(),zu(),ms(),B(),Ep(),c_(),ps(),t_(),ms(),B(),Wd(),Rg(),Ep(),Rc(),B(),Ah(),Fa(),dc();function oT({currentValue:e,onSelect:t,onCancel:n,isMidConversation:r}){let i=vg(),[a,o]=(0,Q.useState)(null),s=[{value:`true`,label:`Enabled`,description:`Claude will think before responding`},{value:`false`,label:`Disabled`,description:`Claude will respond without extended thinking`}];A(`confirm:no`,()=>{a===null?n?.():o(null)},{context:`Confirmation`}),A(`confirm:yes`,()=>{a!==null&&t(a)},{context:`Confirmation`,isActive:a!==null});function c(n){let i=n===`true`;r&&i!==e?o(i):t(i)}return(0,$.jsxs)(he,{color:`permission`,children:[(0,$.jsxs)(b,{flexDirection:`column`,children:[(0,$.jsxs)(b,{marginBottom:1,flexDirection:`column`,children:[(0,$.jsx)(T,{color:`remember`,bold:!0,children:`Toggle thinking mode`}),(0,$.jsx)(T,{dimColor:!0,children:`Enable or disable thinking for this session.`})]}),a===null?(0,$.jsx)(b,{flexDirection:`column`,marginBottom:1,children:(0,$.jsx)(eu,{defaultValue:e?`true`:`false`,defaultFocusValue:e?`true`:`false`,options:s,onChange:c,onCancel:n??(()=>{}),visibleOptionCount:2})}):(0,$.jsxs)(b,{flexDirection:`column`,marginBottom:1,gap:1,children:[(0,$.jsx)(T,{color:`warning`,children:`Changing thinking mode mid-conversation will increase latency and may reduce quality. For best results, set this at the start of a session.`}),(0,$.jsx)(T,{color:`warning`,children:`Do you want to proceed?`})]})]}),(0,$.jsx)(T,{dimColor:!0,italic:!0,children:i.pending?(0,$.jsxs)($.Fragment,{children:[`Press `,i.keyName,` again to exit`]}):a===null?(0,$.jsxs)(O,{children:[(0,$.jsx)(h,{shortcut:`Enter`,action:`confirm`}),(0,$.jsx)(vd,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`exit`})]}):(0,$.jsxs)(O,{children:[(0,$.jsx)(h,{shortcut:`Enter`,action:`confirm`}),(0,$.jsx)(vd,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]})})]})}ev(),Q_();function sT(e,t,n){let r=t;for(let t=0;t<n;t++){let t=cT(e,r);if(t.equals(r))break;r=t}return r}function cT(e,t){switch(e){case`h`:return t.left();case`l`:return t.right();case`j`:return t.downLogicalLine();case`k`:return t.upLogicalLine();case`gj`:return t.down();case`gk`:return t.up();case`w`:return t.nextVimWord();case`b`:return t.prevVimWord();case`e`:return t.endOfVimWord();case`W`:return t.nextWORD();case`B`:return t.prevWORD();case`E`:return t.endOfWORD();case`0`:return t.startOfLogicalLine();case`^`:return t.firstNonBlankInLogicalLine();case`$`:return t.endOfLogicalLine();case`G`:return t.startOfLastLine();default:return t}}function lT(e){return`eE$`.includes(e)}function uT(e){return`jkG`.includes(e)||e===`gg`}var dT={"(":[`(`,`)`],")":[`(`,`)`],b:[`(`,`)`],"[":[`[`,`]`],"]":[`[`,`]`],"{":[`{`,`}`],"}":[`{`,`}`],B:[`{`,`}`],"<":[`<`,`>`],">":[`<`,`>`],'"':[`"`,`"`],"'":[`'`,`'`],"`":["`","`"]};function fT(e,t,n,r){if(n===`w`)return pT(e,t,r,as);if(n===`W`)return pT(e,t,r,e=>!Vo(e));let i=dT[n];if(i){let[n,a]=i;return n===a?mT(e,t,n,r):hT(e,t,n,a,r)}return null}function pT(e,t,n,r){let i=[];for(let{segment:t,index:n}of Sp().segment(e))i.push({segment:t,index:n});let a=i.length-1;for(let n=0;n<i.length;n++){let r=i[n],o=n+1<i.length?i[n+1].index:e.length;if(t>=r.index&&t<o){a=n;break}}let o=e=>i[e]?.segment??``,s=t=>t<i.length?i[t].index:e.length,c=e=>Vo(o(e)),l=e=>r(o(e)),u=e=>Yo(o(e)),d=a,f=a;if(l(a)){for(;d>0&&l(d-1);)d--;for(;f<i.length&&l(f);)f++}else if(c(a)){for(;d>0&&c(d-1);)d--;for(;f<i.length&&c(f);)f++;return{start:s(d),end:s(f)}}else if(u(a)){for(;d>0&&u(d-1);)d--;for(;f<i.length&&u(f);)f++}if(!n){if(f<i.length&&c(f))for(;f<i.length&&c(f);)f++;else if(d>0&&c(d-1))for(;d>0&&c(d-1);)d--}return{start:s(d),end:s(f)}}function mT(e,t,n,r){let i=e.lastIndexOf(`
|
|
46
|
+
`,t-1)+1,a=e.indexOf(`
|
|
47
|
+
`,t),o=a===-1?e.length:a,s=e.slice(i,o),c=t-i,l=[];for(let e=0;e<s.length;e++)s[e]===n&&l.push(e);for(let e=0;e<l.length-1;e+=2){let t=l[e],n=l[e+1];if(t<=c&&c<=n)return r?{start:i+t+1,end:i+n}:{start:i+t,end:i+n+1}}return null}function hT(e,t,n,r,i){let a=0,o=-1;for(let i=t;i>=0;i--)if(e[i]===r&&i!==t)a++;else if(e[i]===n){if(a===0){o=i;break}a--}if(o===-1)return null;a=0;let s=-1;for(let t=o+1;t<e.length;t++)if(e[t]===n)a++;else if(e[t]===r){if(a===0){s=t;break}a--}return s===-1?null:i?{start:o+1,end:s}:{start:o,end:s+1}}Rr(),Cp(),Rp();function gT(e,t,n,r){let i=sT(t,r.cursor,n);if(i.equals(r.cursor))return;let a=OT(r.cursor,i,t,e,n);AT(e,a.from,a.to,r,a.linewise),r.recordChange({type:`operator`,op:e,motion:t,count:n})}function _T(e,t,n,r,i){let a=i.cursor.findCharacter(n,t,r);if(a===null)return;let o=new Xr(i.cursor.measuredText,a),s=kT(i.cursor,o,t);AT(e,s.from,s.to,i),i.setLastFind(t,n),i.recordChange({type:`operatorFind`,op:e,find:t,char:n,count:r})}function vT(e,t,n,r,i){let a=fT(i.text,i.cursor.offset,n,t===`inner`);a&&(AT(e,a.start,a.end,i),i.recordChange({type:`operatorTextObj`,op:e,objType:n,scope:t,count:r}))}function yT(e,t,n){let r=n.text,i=r.split(`
|
|
48
|
+
`),a=zp(r.slice(0,n.cursor.offset),`
|
|
49
|
+
`),o=Math.min(t,i.length-a),s=n.cursor.startOfLogicalLine().offset,c=s;for(let e=0;e<o;e++){let e=r.indexOf(`
|
|
50
|
+
`,c);c=e===-1?r.length:e+1}let l=r.slice(s,c);if(l.endsWith(`
|
|
51
|
+
`)||(l+=`
|
|
52
|
+
`),n.setRegister(l,!0),e===`yank`)n.setOffset(s);else if(e===`delete`){let e=s,t=c;t===r.length&&e>0&&r[e-1]===`
|
|
53
|
+
`&&--e;let i=r.slice(0,e)+r.slice(t);n.setText(i||``);let a=Math.max(0,i.length-(xp(i).length||1));n.setOffset(Math.min(e,a))}else if(e===`change`)if(i.length===1)n.setText(``),n.enterInsert(0);else{let e=i.slice(0,a),t=i.slice(a+o),r=[...e,``,...t].join(`
|
|
54
|
+
`);n.setText(r),n.enterInsert(s)}n.recordChange({type:`operator`,op:e,motion:e[0],count:t})}function bT(e,t){let n=t.cursor.offset;if(n>=t.text.length)return;let r=t.cursor;for(let t=0;t<e&&!r.isAtEnd();t++)r=r.right();let i=r.offset,a=t.text.slice(n,i),o=t.text.slice(0,n)+t.text.slice(i);t.setRegister(a,!1),t.setText(o);let s=Math.max(0,o.length-(xp(o).length||1));t.setOffset(Math.min(n,s)),t.recordChange({type:`x`,count:e})}function xT(e,t,n){let r=n.cursor.offset,i=n.text;for(let n=0;n<t&&r<i.length;n++){let t=wp(i.slice(r)).length||1;i=i.slice(0,r)+e+i.slice(r+t),r+=e.length}n.setText(i),n.setOffset(Math.max(0,r-e.length)),n.recordChange({type:`replace`,char:e,count:t})}function ST(e,t){let n=t.cursor.offset;if(n>=t.text.length)return;let r=t.text,i=n,a=0;for(;i<r.length&&a<e;){let e=wp(r.slice(i)),t=e.length,n=e===e.toUpperCase()?e.toLowerCase():e.toUpperCase();r=r.slice(0,i)+n+r.slice(i+t),i+=n.length,a++}t.setText(r),t.setOffset(i),t.recordChange({type:`toggleCase`,count:e})}function CT(e,t){let n=t.text.split(`
|
|
55
|
+
`),{line:r}=t.cursor.getPosition();if(r>=n.length-1)return;let i=Math.min(e,n.length-r-1),a=n[r],o=a.length;for(let e=1;e<=i;e++){let t=(n[r+e]??``).trimStart();t.length>0&&(!a.endsWith(` `)&&a.length>0&&(a+=` `),a+=t)}let s=[...n.slice(0,r),a,...n.slice(r+i+1)],c=s.join(`
|
|
56
|
+
`);t.setText(c),t.setOffset(DT(s,r)+o),t.recordChange({type:`join`,count:e})}function wT(e,t,n){let r=n.getRegister();if(!r)return;let i=r.endsWith(`
|
|
57
|
+
`),a=i?r.slice(0,-1):r;if(i){let r=n.text.split(`
|
|
58
|
+
`),{line:i}=n.cursor.getPosition(),o=e?i+1:i,s=a.split(`
|
|
59
|
+
`),c=[];for(let e=0;e<t;e++)c.push(...s);let l=[...r.slice(0,o),...c,...r.slice(o)],u=l.join(`
|
|
60
|
+
`);n.setText(u),n.setOffset(DT(l,o))}else{let r=a.repeat(t),i=e&&n.cursor.offset<n.text.length?n.cursor.measuredText.nextOffset(n.cursor.offset):n.cursor.offset,o=n.text.slice(0,i)+r+n.text.slice(i),s=xp(r),c=i+r.length-(s.length||1);n.setText(o),n.setOffset(Math.max(i,c))}}function TT(e,t,n){let r=n.text.split(`
|
|
61
|
+
`),{line:i}=n.cursor.getPosition(),a=Math.min(t,r.length-i);for(let t=0;t<a;t++){let n=i+t,a=r[n]??``;if(e===`>`)r[n]=` `+a;else if(a.startsWith(` `))r[n]=a.slice(2);else if(a.startsWith(` `))r[n]=a.slice(1);else{let e=0,t=0;for(;t<a.length&&e<2&&/\s/.test(a[t]);)e++,t++;r[n]=a.slice(t)}}let o=r.join(`
|
|
62
|
+
`),s=((r[i]??``).match(/^\s*/)?.[0]??``).length;n.setText(o),n.setOffset(DT(r,i)+s),n.recordChange({type:`indent`,dir:e,count:t})}function ET(e,t){let n=t.text.split(`
|
|
63
|
+
`),{line:r}=t.cursor.getPosition(),i=e===`below`?r+1:r,a=[...n.slice(0,i),``,...n.slice(i)],o=a.join(`
|
|
64
|
+
`);t.setText(o),t.enterInsert(DT(a,i)),t.recordChange({type:`openLine`,direction:e})}function DT(e,t){return e.slice(0,t).join(`
|
|
65
|
+
`).length+ +(t>0)}function OT(e,t,n,r,i){let a=Math.min(e.offset,t.offset),o=Math.max(e.offset,t.offset),s=!1;if(r===`change`&&(n===`w`||n===`W`)){let t=e;for(let e=0;e<i-1;e++)t=n===`w`?t.nextVimWord():t.nextWORD();let r=n===`w`?t.endOfVimWord():t.endOfWORD();o=e.measuredText.nextOffset(r.offset)}else if(uT(n)){s=!0;let t=e.text,n=t.indexOf(`
|
|
66
|
+
`,o);n===-1?(o=t.length,a>0&&t[a-1]===`
|
|
67
|
+
`&&--a):o=n+1}else lT(n)&&e.offset<=t.offset&&(o=e.measuredText.nextOffset(o));return a=e.snapOutOfImageRef(a,`start`),o=e.snapOutOfImageRef(o,`end`),{from:a,to:o,linewise:s}}function kT(e,t,n){let r=Math.min(e.offset,t.offset),i=Math.max(e.offset,t.offset);return{from:r,to:e.measuredText.nextOffset(i)}}function AT(e,t,n,r,i=!1){let a=r.text.slice(t,n);if(i&&!a.endsWith(`
|
|
68
|
+
`)&&(a+=`
|
|
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-(xp(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 jT(e,t,n){let r=t===1?n.cursor.startOfLastLine():n.cursor.goToLine(t);if(r.equals(n.cursor))return;let i=OT(n.cursor,r,`G`,e,t);AT(e,i.from,i.to,n,i.linewise),n.recordChange({type:`operator`,op:e,motion:`G`,count:t})}function MT(e,t,n){let r=t===1?n.cursor.startOfFirstLine():n.cursor.goToLine(t);if(r.equals(n.cursor))return;let i=OT(n.cursor,r,`gg`,e,t);AT(e,i.from,i.to,n,i.linewise),n.recordChange({type:`operator`,op:e,motion:`gg`,count:t})}var NT={d:`delete`,c:`change`,y:`yank`};function PT(e){return e in NT}var FT=new Set([`h`,`l`,`j`,`k`,`w`,`b`,`e`,`W`,`B`,`E`,`0`,`^`,`$`]),IT=new Set([`f`,`F`,`t`,`T`]),LT={i:`inner`,a:`around`};function RT(e){return e in LT}var zT=new Set([`w`,`W`,`"`,`'`,"`",`(`,`)`,`b`,`[`,`]`,`{`,`}`,`B`,`<`,`>`]),BT=1e4;function VT(){return{mode:`INSERT`,insertedText:``}}function HT(){return{lastChange:null,lastFind:null,register:``,registerIsLinewise:!1}}function UT(e,t,n){switch(e.type){case`idle`:return KT(t,n);case`count`:return qT(e,t,n);case`operator`:return JT(e,t,n);case`operatorCount`:return YT(e,t,n);case`operatorFind`:return XT(e,t,n);case`operatorTextObj`:return ZT(e,t,n);case`find`:return QT(e,t,n);case`g`:return $T(e,t,n);case`operatorG`:return eE(e,t,n);case`replace`:return tE(e,t,n);case`indent`:return nE(e,t,n)}}function WT(e,t,n){return PT(e)?{next:{type:`operator`,op:NT[e],count:t}}:FT.has(e)?{execute:()=>{let r=sT(e,n.cursor,t);n.setOffset(r.offset)}}:IT.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:()=>ST(t,n)}:e===`x`?{execute:()=>bT(t,n)}:e===`J`?{execute:()=>CT(t,n)}:e===`p`||e===`P`?{execute:()=>wT(e===`p`,t,n)}:e===`D`?{execute:()=>gT(`delete`,`$`,1,n)}:e===`C`?{execute:()=>gT(`change`,`$`,1,n)}:e===`Y`?{execute:()=>yT(`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:()=>rE(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:()=>ET(`below`,n)}:e===`O`?{execute:()=>ET(`above`,n)}:null}function GT(e,t,n,r){return RT(n)?{next:{type:`operatorTextObj`,op:e,count:t,scope:LT[n]}}:IT.has(n)?{next:{type:`operatorFind`,op:e,count:t,find:n}}:FT.has(n)?{execute:()=>gT(e,n,t,r)}:n===`G`?{execute:()=>jT(e,t,r)}:n===`g`?{next:{type:`operatorG`,op:e,count:t}}:null}function KT(e,t){return/[1-9]/.test(e)?{next:{type:`count`,digits:e}}:e===`0`?{execute:()=>t.setOffset(t.cursor.startOfLogicalLine().offset)}:WT(e,1,t)||{}}function qT(e,t,n){if(/[0-9]/.test(t)){let n=e.digits+t;return{next:{type:`count`,digits:String(Math.min(parseInt(n,10),BT))}}}return WT(t,parseInt(e.digits,10),n)||{next:{type:`idle`}}}function JT(e,t,n){return t===e.op[0]?{execute:()=>yT(e.op,e.count,n)}:/[0-9]/.test(t)?{next:{type:`operatorCount`,op:e.op,count:e.count,digits:t}}:GT(e.op,e.count,t,n)||{next:{type:`idle`}}}function YT(e,t,n){if(/[0-9]/.test(t)){let n=e.digits+t,r=Math.min(parseInt(n,10),BT);return{next:{...e,digits:String(r)}}}let r=parseInt(e.digits,10),i=e.count*r;return GT(e.op,i,t,n)||{next:{type:`idle`}}}function XT(e,t,n){return{execute:()=>_T(e.op,e.find,t,e.count,n)}}function ZT(e,t,n){return zT.has(t)?{execute:()=>vT(e.op,e.scope,t,e.count,n)}:{next:{type:`idle`}}}function QT(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 $T(e,t,n){return t===`j`||t===`k`?{execute:()=>{let r=sT(`g${t}`,n.cursor,e.count);n.setOffset(r.offset)}}:t===`g`?e.count>1?{execute:()=>{let t=n.text.split(`
|
|
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 eE(e,t,n){return t===`j`||t===`k`?{execute:()=>gT(e.op,`g${t}`,e.count,n)}:t===`g`?{execute:()=>MT(e.op,e.count,n)}:{next:{type:`idle`}}}function tE(e,t,n){return t===``?{next:{type:`idle`}}:{execute:()=>xT(t,e.count,n)}}function nE(e,t,n){return t===e.dir?{execute:()=>TT(e.dir,e.count,n)}:{next:{type:`idle`}}}function rE(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)}Rr(),Cp();function iE(e){let t=Q.useRef(VT()),[n,r]=(0,Q.useState)(`INSERT`),i=Q.useRef(HT()),a=xo({...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=Xr.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`:bT(t.count,r);break;case`replace`:xT(t.char,t.count,r);break;case`toggleCase`:ST(t.count,r);break;case`indent`:TT(t.dir,t.count,r);break;case`join`:CT(t.count,r);break;case`openLine`:ET(t.direction,r);break;case`operator`:gT(t.op,t.motion,t.count,r);break;case`operatorFind`:_T(t.op,t.find,t.char,t.count,r);break;case`operatorTextObj`:vT(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=Xr.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,-(xp(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=UT(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}}L(),B();function aE(e){let[t]=y(),n=j();Qt(n,!!e.onImagePaste);let r=iE({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)(Tr,{inputState:r,terminalFocus:n,highlights:e.highlights,...e})})}bh(),zh(),Dn(),eg(),j_(),s();function oE(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 sE(e){return`${e.input_tokens}|${e.cache_creation_input_tokens}|${e.cache_read_input_tokens}`}function cE(e){let t=Dv(`sha256`).update(e).digest(`hex`).slice(0,16);return Tv(o(),`cache-stats`,`${t}.json`)}var lE={version:1,signature:null,lastResetAt:null,lastHitRate:null};function uE(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 dE(e){try{let t=await Fv(e,`utf8`),n=JSON.parse(t);return uE(n)?n:{...lE}}catch{return{...lE}}}async function fE(e,t){await Pv(wv(e),{recursive:!0});let n=`${e}.${process.pid}.tmp`;try{await Lv(n,JSON.stringify(t),`utf8`),await Iv(n,e)}catch{}}var pE={signature:null,lastResetAt:null,lastHitRate:null},mE=null;async function hE(e){mE=e;let t=await dE(cE(e));pE={signature:t.signature,lastResetAt:t.lastResetAt,lastHitRate:t.lastHitRate}}function gE(e){let t=sE(e),n=oE(e);return t!==pE.signature&&(pE={signature:t,lastResetAt:Date.now(),lastHitRate:n},mE!==null&&fE(cE(mE),{version:1,signature:t,lastResetAt:pE.lastResetAt,lastHitRate:n})),{...pE}}function _E(){return{...pE}}B(),Ep(),ms();function vE(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 yE(){return(0,$.jsx)(T,{dimColor:!0,children:` │ `})}function bE({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=`${Ap(n)}/${Ap(r)}`;return(0,$.jsxs)(b,{children:[(0,$.jsx)(T,{children:u}),(0,$.jsx)(yE,{}),(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)(yE,{}),(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:[` `,vE(a.five_hour.resets_at)]})]}),p&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(yE,{}),(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:[` `,vE(a.seven_day.resets_at)]})]}),i>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(yE,{}),(0,$.jsx)(T,{children:vu(i)})]})]})}var xE=Q.memo(bE);bp(),q(),at(),Rt(),zl(),Gg(),ws(),B(),Rf(),Qp(),Wd(),tf(),wd(),zd(),rm(),Jc(),dn(),Ep();var SE=3600*1e3;function CE(e){return String(Math.floor(e)).padStart(2,`0`)}function wE(e){if(e<=0)return`exp`;let t=Math.floor(e/6e4),n=Math.floor(e%6e4/1e3);return`${CE(t)}:${CE(n)}`}function TE({messages:e}){let[t,n]=(0,Q.useState)(()=>Date.now()),[r,i]=(0,Q.useState)(!0),a=Ra(e),o=(0,Q.useRef)(null);if(a!==null){let e=sE(a);e!==o.current&&(o.current=e,gE(a))}let{lastResetAt:s,lastHitRate:c}=_E(),l=s===null?null:t-s,u=l===null?null:SE-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,hE(st()))},[]);let h=a===null?c:oE(a);if(h===null&&s===null)return(0,$.jsx)(T,{dimColor:!0,children:` Cache --% --:--`});let g=u===null?`--:--`:wE(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 EE(){let{getGoal:t,formatGoalStatusLabel:n}=(us(),e(Sc)),r=t();if(!r)return null;let i=r.objective.length>30?`${r.objective.slice(0,27)}…`:r.objective,a=r.tokenBudget===null?Ap(r.tokensUsed):`${Ap(r.tokensUsed)}/${Ap(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 DE(e){return Fe()||e?.statusLineEnabled===!1?!1:e?.statusLineEnabled===!0||!!e?.statusLine?.command}function OE(e,t,n,r,i,a,o){let s=$e(),c=on(),l=fm({permissionMode:e,mainLoopModel:a,exceeds200kTokens:t}),u=n?.outputStyle||`default`,d=Ra(r),f=tm(l,pt()),p=Up(d,f),m=xl(st()),h=Jn(),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{...Hn(),...m&&{session_name:m},model:{id:l,display_name:em(l)},workspace:{current_dir:Gd(),project_dir:ut(),added_dirs:i},version:`0.0.5`,output_style:{name:u},cost:{total_cost_usd:lt(),total_duration_ms:Ae(),total_api_duration_ms:Ge(),total_lines_added:Be(),total_lines_removed:Ve()},context_window:{total_input_tokens:ct(),total_output_tokens:He(),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},...O_()&&{vim:{mode:o??`INSERT`}},...s&&{agent:{name:s}},...je()&&{remote:{session_id:st()}},...c&&{worktree:{name:c.worktreeName,path:c.worktreePath,branch:c.worktreeBranch,original_cwd:c.originalCwd,original_branch:c.originalBranch}}}}function kE(e){return nl(e)?.uuid??null}function AE({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=Vr(),c=pd(),{addNotification:l}=lo(),u=Wg(),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=kE(n);r!==_.current.messageId&&(e=Zt(n),_.current.messageId=r,_.current.exceeds200kTokens=e);let a=await Zs(OE(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`}),Bf()||(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=fm({permissionMode:i,mainLoopModel:u,exceeds200kTokens:_.current.exceeds200kTokens}),O=tm(D,pt()),k=Ra(e.current),ee=k?k.input_tokens+k.cache_creation_input_tokens+k.cache_read_input_tokens:0,A=k?Math.round(Up(k,O).used??0):0,j=Jn(),M={...j.five_hour&&{five_hour:{utilization:j.five_hour.utilization,resets_at:j.five_hour.resets_at}},...j.seven_day&&{seven_day:{utilization:j.seven_day.utilization,resets_at:j.seven_day.resets_at}}},te=c?.statusLineEnabled===!0,N=!!c?.statusLine?.command;return(0,$.jsxs)(b,{flexDirection:`column`,paddingX:E,children:[te&&(0,$.jsxs)(b,{gap:2,children:[(0,$.jsx)(xE,{modelName:em(D),contextUsedPct:A,usedTokens:ee,contextWindowSize:O,totalCostUsd:lt(),rateLimits:M}),(0,$.jsx)(EE,{}),(0,$.jsx)(TE,{messages:e.current})]}),o?(0,$.jsx)(T,{dimColor:!0,wrap:`truncate`,children:(0,$.jsx)(g,{children:o})}):N&&oo()?(0,$.jsx)(T,{children:` `}):null]})}var jE=(0,Q.memo)(AE);u(),q(),Ft(),Rn(),B();function ME({tasksSelected:e,onOpenDialog:t}){let n=J(e=>e.tasks),r=(0,Q.useMemo)(()=>Object.values(n??{}).filter(e=>ei(e)&&!(process.env.USER_TYPE===`ant`&&xi(e))),[n]);return Z_(n??{},!1)||r.length===0?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(NE,{selected:e,onClick:t,children:Qi(r)}),yr(r)&&(0,$.jsxs)(T,{dimColor:!0,children:[` · `,d.arrowDown,` to view`]})]})}function NE({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(),Wn();function PE({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)(ia,{value:e,onChange:t,cursorOffset:e.length,onChangeCursorOffset:()=>{},columns:_(e)+1,focus:!0,showCursor:!0,multiline:!1,dimColor:!0})]})}qf(),Hf(),Zd();var FE=5e3;function IE(e,t){if(e)return`draft`;switch(t){case`APPROVED`:return`approved`;case`CHANGES_REQUESTED`:return`changes_requested`;default:return`pending`}}async function LE(){if(!await Wf())return null;let[e,t]=await Promise.all([Gf(),Uf()]);if(e===t)return null;let{stdout:n,code:r}=await Jf(`gh`,[`pr`,`view`,`--json`,`number,url,reviewDecision,isDraft,headRefName,state`],{timeout:FE,preserveOutputOnError:!1});if(r!==0||!n.trim())return null;try{let e=Kd(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:IE(e.isDraft,e.reviewDecision)}}catch{return null}}at();var RE=6e4,zE=4e3,BE=60*6e4,VE={number:null,url:null,reviewState:null,lastUpdated:0};function HE(e,t=!0){let[n,r]=(0,Q.useState)(VE),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=ze();if(n!==t)n=t,s=Date.now();else if(Date.now()-s>=BE)return;let l=Date.now(),u=await LE();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,RE))}}let l=Date.now()-o.current;return l>=RE?c():i.current=setTimeout(c,RE-l),()=>{e=!0,i.current&&(clearTimeout(i.current),i.current=null)}},[e,t]),n}B(),u(),j_(),cn(),df(),hr(),Ft(),wf(),ev(),q(),at(),ms(),Ep(),dr(),Rf(),cp(),Ld();var UE=(dh(),e(eh)),WE=e=>()=>{},GE=()=>null,KE=5e3,qE=1e3;function JE(){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=Dp(e*1024*1024);t(e=>e?.text===r?e:{text:r,level:n})}e();let n=setInterval(e,KE);return()=>clearInterval(n)},[]),e}function YE(){let e=(0,Q.useSyncExternalStore)(UE?.subscribeToProactiveChanges??WE,UE?.getNextTickAt??GE,GE),[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 `,kp(t*1e3,{mostSignificantOnly:!0})]})}function XE(){let[t,n]=(0,Q.useState)(0);(0,Q.useEffect)(()=>{let e=setInterval(()=>n(e=>e+1),qE);return()=>clearInterval(e)},[]);let r=(us(),e(Sc)),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 ZE({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=O_()&&t===`INSERT`&&!l;return(0,$.jsxs)(b,{justifyContent:`flex-start`,gap:1,children:[l&&(0,$.jsx)(PE,{value:u,onChange:d,historyFailedMatch:f}),m?(0,$.jsx)(T,{dimColor:!0,children:`-- INSERT --`},`vim-insert`):null,(0,$.jsx)(QE,{mode:n,toolPermissionContext:r,showHint:!i&&!m,isLoading:a,tasksSelected:o,tmuxSelected:s,onOpenTasksDialog:p})]})}function QE({mode:t,toolPermissionContext:n,showHint:r,isLoading:i,tasksSelected:a,tmuxSelected:o,onOpenTasksDialog:s}){let{columns:c}=de(),l=ud(`chat:cycleMode`,`Chat`,`shift+tab`),u=J(e=>e.tasks),f=qn(),[p]=(0,Q.useState)(()=>f.getState().remoteSessionUrl),m=HE(i,eD()),g=J(e=>process.env.USER_TYPE===`ant`&&e.tungstenActiveSession!==void 0),_=(0,Q.useSyncExternalStore)(UE?.subscribeToProactiveChanges??WE,UE?.getNextTickAt??GE,GE),v=I(),y=ue().getState,x=_!==null,S=(0,Q.useMemo)(()=>jf(Object.values(u),e=>ei(e)&&!(process.env.USER_TYPE===`ant`&&xi(e))),[u]),w=jr(),E=w!==void 0&&w.length>0,D=ud(`chat:cancel`,`Chat`,`esc`).toLowerCase(),k=ud(`app:toggleTodos`,`Global`,`ctrl+t`),ee=ud(`chat:killAgents`,`Chat`,`ctrl+x ctrl+k`),A=J(e=>e.notifications.current?.key===`kill-agents-confirm`),j=JE();if(t===`bash`)return(0,$.jsx)(T,{color:`bashBorder`,children:`! for bash mode`});let M=n?.mode,te=!pf(M),N=S>0,P=+!!te+ +!!N,F=eD()&&m.number!==null&&m.reviewState!==null&&m.url!==null&&P<2&&(P===0||c>=80),ne=P<2,re=M&&te&&!je()?(0,$.jsxs)(T,{color:_f(M),children:[uf(M),` `,bf(M).toLowerCase(),` on`,ne&&(0,$.jsxs)(T,{dimColor:!0,children:[` `,(0,$.jsx)(h,{shortcut:l,action:`cycle`,parens:!0})]})]},`mode`):null,L=[...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`)]:[],...F?[(0,$.jsx)(Sa,{number:m.number,url:m.url,reviewState:m.reviewState},`pr-status`)]:[],...j?[(0,$.jsxs)(T,{dimColor:j.level===`normal`,color:j.level===`error`?`error`:j.level===`warning`?`warning`:void 0,children:[j.text,` · pid:`,process.pid]},`rss`)]:[],...(us(),e(Sc)).getGoal()?[(0,$.jsx)(XE,{},`goal-elapsed`)]:[]],ie=Object.values(u).some(e=>e.type===`local_agent`&&e.status===`running`),R=r?$E(i,D,k,ee,E,ie,A):[];x?L.push((0,$.jsx)(YE,{},`proactive`)):r&&L.push(...R);let z=N&&!Z_(u,!1)?(0,$.jsx)(ME,{tasksSelected:a,onOpenDialog:s}):null;L.length===0&&!z&&!re&&r&&L.push((0,$.jsx)(T,{dimColor:!0,children:`? for shortcuts`},`shortcuts-hint`));let ae=Lf().copyOnSelect??!0,oe=v&&(!ae||se());if(oo()&&oe){let e=sp()===`macos`,t=e&&(y()?.lastPressHadAlt??!1);L.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&&L.push((0,$.jsx)(T,{dimColor:!0,children:a?(0,$.jsx)(h,{shortcut:`Enter`,action:`view tasks`}):(0,$.jsx)(h,{shortcut:`↓`,action:`manage`})},`manage-tasks`)),L.length===0&&!z&&!re?oo()?(0,$.jsx)(T,{children:` `}):null:(0,$.jsxs)(b,{height:1,overflow:`hidden`,children:[re&&(0,$.jsxs)(b,{flexShrink:0,children:[re,(z||L.length>0)&&(0,$.jsx)(T,{dimColor:!0,children:` · `})]}),z&&(0,$.jsxs)(b,{flexShrink:0,children:[z,L.length>0&&(0,$.jsx)(T,{dimColor:!0,children:` · `})]}),L.length>0&&(0,$.jsx)(T,{wrap:`truncate`,children:(0,$.jsx)(O,{children:L})})]})}function $E(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 eD(){return Lf().prStatusFooterEnabled??!0}ml(),ws(),ms(),B(),ps(),q(),dr(),Pg(),A_();function tD({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:ee,onOpenTasksDialog:A}){let j=pd(),{columns:M,rows:te}=de(),N=(0,Q.useRef)(E);N.current=E;let P=(0,Q.useMemo)(()=>kE(E),[E]),F=M<80,ne=oo(),re=ne&&te<24,I=_,L=h||DE(j)||D;return B_((0,Q.useMemo)(()=>ne&&u.length?{suggestions:u,selectedSuggestion:d,maxColumnWidth:f}:null,[ne,u,d,f])),u.length&&!ne?(0,$.jsx)(b,{paddingX:2,paddingY:0,children:(0,$.jsx)(Fg,{suggestions:u,selectedSuggestion:d,maxColumnWidth:f})}):m?(0,$.jsx)(M_,{dimColor:!0,fixedWidth:!0,paddingX:2}):(0,$.jsx)($.Fragment,{children:(0,$.jsxs)(b,{flexDirection:F?`column`:`row`,justifyContent:F?`flex-start`:`space-between`,paddingX:2,gap:+!F,children:[(0,$.jsxs)(b,{flexDirection:`column`,flexShrink:+!F,children:[i===`prompt`&&!re&&!n.show&&!C&&DE(j)&&(0,$.jsx)(jE,{messagesRef:N,lastAssistantMessageId:P,vimMode:r}),(0,$.jsx)(iD,{}),(0,$.jsx)(ZE,{exitMessage:n,vimMode:r,mode:i,toolPermissionContext:p,suppressHint:L,isLoading:g,tasksSelected:I,tmuxSelected:y,isPasting:C,isSearching:D,historyQuery:O,setHistoryQuery:k,historyFailedMatch:ee,onOpenTasksDialog:A})]}),(0,$.jsxs)(b,{flexShrink:1,gap:1,children:[ne?null:(0,$.jsx)(gC,{apiKeyStatus:e,autoUpdaterResult:a,debug:t,isAutoUpdating:o,verbose:s,messages:E,onAutoUpdaterResult:c,onChangeIsUpdating:l,ideSelection:x,mcpClients:S,isInputWrapped:w,isNarrow:F}),process.env.USER_TYPE===`ant`&&Bh()&&(0,$.jsx)(T,{dimColor:!0,children:`undercover`}),(0,$.jsx)(rD,{bridgeSelected:v})]})]})})}var nD=(0,Q.memo)(tD);function rD({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(!Lh()||!t)return null;let o=Vs({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 iD(){return null}u(),B();function aD({isLoading:e}){return(0,$.jsxs)(T,{color:process.env.USER_TYPE===`ant`?`subtle`:void 0,dimColor:e,children:[d.pointer,`\xA0`]})}function oD({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)(aD,{isLoading:t})})}B(),q(),$n(),Ki(),zd(),Zd(),Kc();var sD=new Set;function cD(e){try{return Kd(e)?.type===`idle_notification`}catch{return!1}}var lD=3;function uD(e){return`<${Yf}>
|
|
72
|
+
<${Qf}>+${e} more tasks completed</${Qf}>
|
|
73
|
+
<${Xf}>completed</${Xf}>
|
|
74
|
+
</${Yf}>`}function dD(e){let t=e.filter(e=>typeof e.value!=`string`||!cD(e.value)),n=t.filter(e=>e.mode===`task-notification`),r=t.filter(e=>e.mode!==`task-notification`);if(n.length<=lD)return[...r,...n];let i=n.slice(0,lD-1),a={value:uD(n.length-(lD-1)),mode:`task-notification`};return[...r,...i,a]}function fD(){let e=nC(),t=J(e=>!!e.viewingAgentTaskId),n=J(e=>e.isBriefOnly),r=(0,Q.useMemo)(()=>{if(e.length===0)return null;let t=e.filter(G);return t.length===0?null:lu(dD(t).map(e=>{let t=e.value;return e.mode===`bash`&&typeof t==`string`&&(t=`<bash-input>${t}</bash-input>`),Pa({content:t})}))},[e]);return t||r===null?null:(0,$.jsx)(b,{marginTop:1,flexDirection:`column`,children:r.map((e,t)=>(0,$.jsx)(Ao,{isFirst:t===0,useBriefLayout:n,children:(0,$.jsx)(tl,{message:e,lookups:oa,addMargin:!1,tools:[],commands:[],verbose:!1,inProgressToolUseIDs:sD,progressMessagesForMessage:[],shouldAnimate:!1,shouldShowDot:!1,isTranscriptMode:!1,isStatic:!0})},t))})}var pD=Q.memo(fD);to(),u(),B();function mD({hasStash:e}){return e?(0,$.jsx)(b,{paddingLeft:2,children:(0,$.jsxs)(T,{dimColor:!0,children:[d.pointerSmall,` Stashed (auto-restores after submit)`]})}):null}zu();var hD=1e4,gD=1e3;function _D(e,t){if(e.length<=hD)return{truncatedText:e,placeholderContent:``};let n=Math.floor(gD/2),r=e.slice(0,n),i=e.slice(-500),a=e.slice(n,-500);return{truncatedText:r+vD(t,al(a))+i,placeholderContent:a}}function vD(e,t){return`[...Truncated text #${e} +${t} lines...]`}function yD(e,t){let n=Object.keys(t).map(Number),r=n.length>0?Math.max(...n)+1:1,{truncatedText:i,placeholderContent:a}=_D(e,r);return a?{newInput:i,newPastedContents:{...t,[r]:{id:r,type:`text`,content:a}}}:{newInput:e,newPastedContents:t}}function bD({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}=yD(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(),Rf(),Ki();var xD=(dh(),e(eh)),SD=3;function CD({input:e,submitCount:t}){let n=nC(),r=J(e=>e.promptSuggestionEnabled);return(0,Q.useMemo)(()=>{if(e===``){if(n.some(Mn)&&(Lf().queuedCommandUpHintCount||0)<SD)return`Press up to edit queued messages`;if(t<1&&r&&!xD?.isProactiveActive())return sv()}},[e,n,t,r])}var wD=5e3,TD=!1;function ED(e){let[t,n]=(0,Q.useState)(!1);return(0,Q.useEffect)(()=>{if(TD||!e)return;TD=!0,n(!0);let t=setTimeout(n,wD,!1);return()=>{clearTimeout(t),n(!1)}},[e]),t}L(),Rt(),bp(),q(),Wd(),Ki(),x(),la(),ps(),q_(),zu(),Gg(),ms(),B(),qa(),fn(),Ah(),nu(),wf(),Rr(),Rf(),tf(),Cf(),cf(),dr(),il(),np(),rm(),cp(),Hg(),Fa(),Wn(),ev(),Xu(),j_();var DD=5,OD=3;function kD({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:ee,onExit:j,getToolUseContext:M,onSubmit:te,isSearchingHistory:P,setIsSearchingHistory:F,onDismissSideQuestion:ne,isSideQuestionVisible:re,helpOpen:I,setHelpOpen:L,hasSuppressedDialogs:ie,isLocalJSXCommandActive:z=!1,insertTextRef:ae}){let se=Wg(),ce=td()||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=qn(),U=Vr(),_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=nC(),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.viewingAgentTaskId);J(e=>e.viewSelectionMode);let{historyQuery:Fe,setHistoryQuery:Ie,historyMatch:Le,historyFailedMatch:Re}=TC(e=>{E(e.pastedContents),sn(e.display)},f,he,H,V,h,m,P,F,E,w),ze=(0,Q.useRef)(-1);ze.current===-1&&(ze.current=AD(l));let Be=(0,Q.useRef)(!1),[Ve,He]=(0,Q.useState)(!1),Ue=J(e=>e.selectedBgAgentIndex),We=(0,Q.useCallback)(e=>U(t=>{let n=typeof e==`function`?e(t.selectedBgAgentIndex):e;return n===t.selectedBgAgentIndex?t:{...t,selectedBgAgentIndex:n}}),[U]),[Ge,Ke]=(0,Q.useState)(!1),[qe,Je]=(0,Q.useState)(!1),[Ye,Xe]=(0,Q.useState)(!1),[Ze,Qe]=(0,Q.useState)(!1),[$e,et]=(0,Q.useState)(!1),[tt,nt]=(0,Q.useState)(!1),[rt,it]=(0,Q.useState)(!1),[at,ot]=(0,Q.useState)(!1),st=(0,Q.useMemo)(()=>{let e=f.indexOf(`
|
|
75
|
+
`);return e===-1||V<=e},[f,V]),ct=(0,Q.useMemo)(()=>{let e=f.lastIndexOf(`
|
|
76
|
+
`);return e===-1||V>e},[f,V]),lt=(0,Q.useMemo)(()=>jf(Object.values(_e),e=>e.status===`running`),[_e])>0&&!Z_(_e,!1),ut=wC(),dt=ut.length>0,ft=(0,Q.useMemo)(()=>[dt&&`bg_agent`,lt&&`tasks`,Ce&&`tmux`,we&&`bagel`,xe&&`bridge`].filter(Boolean),[dt,lt,Ce,we,xe]),pt=J(e=>e.footerSelection),mt=pt&&ft.includes(pt)?pt:null;(0,Q.useEffect)(()=>{pt&&!mt&&U(e=>e.footerSelection===null?e:{...e,footerSelection:null})},[pt,mt,U]);let ht=mt===`tasks`,gt=mt===`tmux`,_t=mt===`bridge`,vt=mt===`bg_agent`;function yt(e){U(t=>t.footerSelection===e?t:{...t,footerSelection:e}),e===`bg_agent`&&We(-1)}function bt(e,t=!1){let n=mt?ft.indexOf(mt):-1,r=ft[n+e];return r?(yt(r),!0):e<0&&t?(yt(null),!0):!1}let{suggestion:xt,markAccepted:St,logOutcomeAtSubmission:Ct,markShown:wt}=DC({inputValue:f,isAssistantResponding:s}),Tt=(0,Q.useMemo)(()=>P&&Le?os(typeof Le==`string`?Le:Le.display):f,[P,Le,f]),Et=(0,Q.useMemo)(()=>Hl(Tt),[Tt]),Dt=J(e=>e.ultraplanSessionUrl),Ot=J(e=>e.ultraplanLaunching),kt=(0,Q.useMemo)(()=>!Dt&&!Ot?mg(Tt):[],[Tt,Dt,Ot]),At=(0,Q.useMemo)(()=>jd()?_g(Tt):[],[Tt]),jt=(0,Q.useMemo)(()=>xg(Tt),[Tt]),Mt=(0,Q.useMemo)(()=>tw(Tt).filter(e=>es(Tt.slice(e.start+1,e.end),a)),[Tt,a]),Nt=(0,Q.useMemo)(()=>qr(Tt),[Tt]),Pt=(0,Q.useMemo)(()=>xw(ge.getState().mcp.clients)?Cw(Tt):[],[Tt,(0,Q.useSyncExternalStore)(pw,Sw)]),Ft=(0,Q.useMemo)(()=>nc(Tt).filter(e=>e.match.startsWith(`[Image`)).map(e=>({start:e.index,end:e.index+e.match.length})),[Tt]),Lt=Ft.some(e=>e.start===V);(0,Q.useEffect)(()=>{let e=Ft.find(e=>V>e.start&&V<e.end);if(e){let t=(e.start+e.end)/2;H(V<t?e.start:e.end)}},[V,Ft,H]);let Rt=(0,Q.useMemo)(()=>{let e=[];for(let t of Ft)V===t.start&&e.push({start:t.start,end:t.end,color:void 0,inverse:!0,priority:8});P&&Le&&!Re&&e.push({start:V,end:V+Fe.length,color:`warning`,priority:20});for(let t of jt)e.push({start:t.start,end:t.end,color:`warning`,priority:15});for(let t of Mt)e.push({start:t.start,end:t.end,color:`suggestion`,priority:5});for(let t of Nt)e.push({start:t.start,end:t.end,color:`suggestion`,priority:5});for(let t of Pt)e.push({start:t.start,end:t.end,color:`suggestion`,priority:5});if(pl())for(let t of Et)for(let n=t.start;n<t.end;n++)e.push({start:n,end:n+1,color:Au(n-t.start),shimmerColor:Au(n-t.start,!0),priority:10});for(let t of kt)for(let n=t.start;n<t.end;n++)e.push({start:n,end:n+1,color:Au(n-t.start),shimmerColor:Au(n-t.start,!0),priority:10});for(let t of At)for(let n=t.start;n<t.end;n++)e.push({start:n,end:n+1,color:Au(n-t.start),shimmerColor:Au(n-t.start,!0),priority:10});return e},[P,Fe,Le,Re,V,jt,Ft,Mt,Nt,Pt,Tt,Et,kt,At]),{addNotification:zt,removeNotification:Bt}=lo();(0,Q.useEffect)(()=>{Et.length&&pl()?zt({key:`ultrathink-active`,text:`Ultrathink active for this turn`,priority:`immediate`,timeoutMs:5e3}):Bt(`ultrathink-active`)},[zt,Bt,Et.length]),(0,Q.useEffect)(()=>{kt.length?zt({key:`ultraplan-active`,text:`This prompt will launch an ultraplan session in Claude Code on the web`,priority:`immediate`,timeoutMs:5e3}):Bt(`ultraplan-active`)},[zt,Bt,kt.length]),(0,Q.useEffect)(()=>{jd()&&At.length&&zt({key:`ultrareview-active`,text:`Run /ultrareview after Claude finishes to review these changes in the cloud`,priority:`immediate`,timeoutMs:5e3})},[zt,At.length]);let Vt=(0,Q.useRef)(f.length),Ht=(0,Q.useRef)(f.length),Ut=(0,Q.useCallback)(()=>{Bt(`stash-hint`)},[Bt]);(0,Q.useEffect)(()=>{let e=Vt.current,t=Ht.current,n=f.length;if(Vt.current=n,n>t){Ht.current=n;return}if(n===0){Ht.current=0;return}t>=20&&n<=5&&!(e>=20&&n<=5)&&(Lf().hasUsedStash||zt({key:`stash-hint`,jsx:(0,$.jsxs)(T,{dimColor:!0,children:[`Tip: `,(0,$.jsx)(vd,{action:`chat:stash`,context:`Chat`,fallback:`ctrl+s`,description:`stash`})]}),priority:`immediate`,timeoutMs:hC}),Ht.current=n)},[f.length,zt]);let{pushToBuffer:Wt,undo:Gt,canUndo:Kt,clearBuffer:qt}=EC({maxBufferSize:50,debounceMs:1e3});bD({input:f,pastedContents:w,onInputChange:he,setCursorOffset:H,setPastedContents:E});let Jt=CD({input:f,submitCount:y}),Yt=(0,Q.useCallback)(e=>{if(e===`?`){Z(`tengu_help_toggled`,{}),L(e=>!e);return}L(!1),Ut(),uc(),Kn(U);let t=e.length===f.length+1,n=V===0,r=fc(e);if(n&&r!==`prompt`){if(t){h(r);return}if(f.length===0){h(r);let t=os(e).replaceAll(` `,` `);Wt(f,V,w),he(t),H(t.length);return}}let i=e.replaceAll(` `,` `);f!==i&&Wt(f,V,w),U(e=>e.footerSelection===null?e:{...e,footerSelection:null}),he(i)},[he,h,f,V,Wt,w,Ut,U]),{resetHistory:Xt,onHistoryUp:Zt,onHistoryDown:Qt,dismissSearchHint:$t,historyIndex:en}=CC((e,t,n)=>{Yt(e),h(t),E(n)},f,w,H,m);(0,Q.useEffect)(()=>{P&&$t()},[P,$t]);function tn(){if(!(cn.length>1)&&st){if(Te.some(Mn)){bn();return}Zt()}}function nn(){if(!(cn.length>1)&&ct&&Qt()&&ft.length>0){let e=ft[0];yt(e),e===`tasks`&&!Lf().hasSeenTasksHint&&If(e=>e.hasSeenTasksHint?e:{...e,hasSeenTasksHint:!0})}}let[rn,an]=(0,Q.useState)({suggestions:[],selectedSuggestion:-1,commandArgumentHint:void 0}),on=(0,Q.useCallback)(e=>{an(t=>typeof e==`function`?e(t):e)},[]),sn=(0,Q.useCallback)(async(e,t=!1)=>{e=e.trimEnd();let n=ge.getState();if(n.footerSelection&&ft.includes(n.footerSelection)||n.viewSelectionMode===`selecting-agent`)return;let r=Object.values(w).some(e=>e.type===`image`),i=Ee.text;if((e.trim()===``||e===i)&&i&&!r&&!n.viewingAgentTaskId){if(De.status===`active`){St(),Ct(i,{skipReset:!0}),te(i,{setCursorOffset:H,clearBuffer:qt,resetHistory:Xt},{state:De,speculationSessionTimeSavedMs:Oe,setAppState:U});return}Ee.shownAt>0&&(St(),e=i)}if(e.trim()===``&&!r)return;let a=rn.suggestions.length>0&&rn.suggestions.every(e=>e.description===`directory`);if(rn.suggestions.length>0&&!t&&!a){Y(`[onSubmit] early return: suggestions showing (count=${rn.suggestions.length})`);return}Ee.text&&Ee.shownAt>0&&Ct(e),Bt(`stash-hint`),await te(e,{setCursorOffset:H,clearBuffer:qt,resetHistory:Xt})},[Ee,De,Oe,ge,ft,rn.suggestions,te,qt,Xt,Ct,U,St,w,Bt]),{suggestions:cn,selectedSuggestion:ln,commandArgumentHint:un,inlineGhostText:dn,maxColumnWidth:fn}=$w({commands:a,onInputChange:he,onSubmit:sn,setCursorOffset:H,input:f,cursorOffset:V,mode:m,agents:o,setSuggestionsState:on,suggestionsState:rn,suppressSuggestions:P||en>0,markAccepted:St,onModeChange:h}),pn=m===`prompt`&&cn.length===0&&xt&&!Pe;pn&&wt(),Ee.text&&!xt&&Ee.shownAt===0&&!Pe&&(Tc(`timing`,Ee.text),U(e=>({...e,promptSuggestion:{text:null,promptId:null,shownAt:0,acceptedAt:0,generationRequestId:null}})));function mn(e,t,n,r,i){Z(`tengu_paste_image`,{}),h(`prompt`);let a=ze.current++,o={id:a,type:`image`,content:e,mediaType:t||`image/png`,filename:n||`Pasted image`,dimensions:r,sourcePath:i};An(o),It(o),E(e=>({...e,[a]:o})),_n((Be.current?` `:``)+Ml(a)),Be.current=!0}(0,Q.useEffect)(()=>{let e=new Set(nc(f).map(e=>e.id));E(t=>{let n=Object.values(t).filter(t=>t.type===`image`&&!e.has(t.id));if(n.length===0)return t;let r={...t};for(let e of n)delete r[e.id];return r})},[f,E]);function hn(e){Be.current=!1;let t=pe(e).replace(/\r/g,`
|
|
77
|
+
`).replaceAll(` `,` `);if(f.length===0){let e=fc(t);e!==`prompt`&&(h(e),t=os(t))}let n=al(t),r=Math.min(In-10,2);if(t.length>800||n>r){let e=ze.current++,r={id:e,type:`text`,content:t};E(t=>({...t,[e]:r})),_n(bu(e,n))}else _n(t)}let gn=(0,Q.useCallback)((e,t)=>Be.current?(Be.current=!1,k_(e,t)?` `+e:e):e,[]);function _n(e){Wt(f,V,w);let t=f.slice(0,V)+e+f.slice(V);he(t),H(V+e.length)}let vn=R(()=>{},()=>x()),bn=(0,Q.useCallback)(()=>{let e=ga(f,V);return e?(he(e.text),h(`prompt`),H(e.cursorOffset),e.images.length>0&&E(t=>{let n={...t};for(let t of e.images)n[t.id]=t;return n}),!0):!1},[he,h,f,V,E]);aC(C,function(e){Z(`tengu_ext_at_mentioned`,{});let t,n=_v.relative(Gd(),e.filePath);t=e.lineStart&&e.lineEnd?e.lineStart===e.lineEnd?`@${n}#L${e.lineStart} `:`@${n}#L${e.lineStart}-${e.lineEnd} `:`@${n} `;let r=f[V-1]??` `;/\s/.test(r)||(t=` ${t}`),_n(t)});let xn=(0,Q.useCallback)(()=>{if(Kt){let e=Gt();e&&(he(e.text),H(e.cursorOffset),E(e.pastedContents))}},[Kt,Gt,he,E]),Sn=(0,Q.useCallback)(()=>{Wt(f,V,w);let e=f.slice(0,V)+`
|
|
78
|
+
`+f.slice(V);he(e),H(V+1)},[f,V,he,H,Wt,w]),W=(0,Q.useCallback)(async()=>{Z(`tengu_external_editor_used`,{}),Je(!0);try{let e=await Bg(f,w);e.error&&zt({key:`external-editor-error`,text:e.error,color:`warning`,priority:`high`}),e.content!==null&&e.content!==f&&(Wt(f,V,w),he(e.content),H(e.content.length))}catch(e){e instanceof Error&&X(e),zt({key:`external-editor-error`,text:`External editor failed: ${Jd(e)}`,color:`warning`,priority:`high`})}finally{Je(!1)}},[f,V,w,Wt,he,zt]),Cn=(0,Q.useCallback)(()=>{f.trim()===``&&g!==void 0?(he(g.text),H(g.cursorOffset),E(g.pastedContents),_(void 0)):f.trim()!==``&&(_({text:f,cursorOffset:V,pastedContents:w}),he(``),H(0),E({}),If(e=>e.hasUsedStash?e:{...e,hasUsedStash:!0}))},[f,V,g,he,_,w,E]),wn=(0,Q.useCallback)(()=>{Xe(e=>!e),I&&L(!1)},[I]),Tn=(0,Q.useCallback)(()=>{it(e=>!e),I&&L(!1)},[I]),En=(0,Q.useCallback)(()=>{ot(e=>!e),I&&L(!1)},[I]),Dn=(0,Q.useCallback)(()=>{Y(`[auto-mode] handleCycleMode: currentMode=${n.mode}`);let e=nT(n),{context:t}=rT(n);Z(`tengu_mode_cycle`,{to:e}),e===`plan`&&If(e=>({...e,lastPlanModeUse:Date.now()})),U(n=>({...n,toolPermissionContext:{...t,mode:e}})),r({...t,mode:e}),I&&L(!1)},[n,U,r,I]),On=(0,Q.useCallback)(()=>{rd().then(e=>{if(e)mn(e.base64,e.mediaType);else{let e=yn(`chat:imagePaste`,`Chat`,`ctrl+v`),t=mf.isSSH()?`No image found in clipboard. You're SSH'd; try scp?`:`No image found in clipboard. Use ${e} to paste images.`;zt({key:`no-image-in-clipboard`,text:t,priority:`immediate`,timeoutMs:1e3})}})},[zt,mn]),kn=N();(0,Q.useEffect)(()=>{if(!(!kn||ce))return kn.registerHandler({action:`chat:submit`,context:`Chat`,handler:()=>{sn(f)}})},[kn,ce,sn,f]),v((0,Q.useMemo)(()=>({"chat:undo":xn,"chat:newline":Sn,"chat:externalEditor":W,"chat:stash":Cn,"chat:modelPicker":wn,"chat:thinkingToggle":En,"chat:cycleMode":Dn,"chat:imagePaste":On}),[xn,Sn,W,Cn,wn,En,Dn,On]),{context:`Chat`,isActive:!ce}),A(`chat:messageActions`,()=>S?.(),{context:`Chat`,isActive:!ce&&!P}),A(`chat:fastMode`,Tn,{context:`Chat`,isActive:!ce&&bm()&&wm()}),A(`help:dismiss`,()=>{L(!1)},{context:`Help`,isActive:I}),A(`app:quickOpen`,()=>{},{context:`Global`,isActive:!1}),A(`app:globalSearch`,()=>{},{context:`Global`,isActive:!1}),A(`history:search`,()=>{},{context:`Global`,isActive:!1}),A(`app:interrupt`,()=>{Kn(U)},{context:`Global`,isActive:!s&&De.status===`active`}),v({"footer:up":()=>{if(vt){Ue>-1?We(e=>e-1):yt(null);return}bt(-1,!0)},"footer:down":()=>{if(vt){Ue<ut.length-1&&We(e=>e+1);return}if(ht){ee(!0),yt(null);return}bt(1)},"footer:next":()=>{bt(1)},"footer:previous":()=>{bt(-1)},"footer:openSelected":()=>{switch(mt){case`tasks`:ee(!0),yt(null);break;case`tmux`:process.env.USER_TYPE===`ant`&&U(e=>e.tungstenPanelAutoHidden?{...e,tungstenPanelAutoHidden:!1}:{...e,tungstenPanelVisible:!(e.tungstenPanelVisible??!0)});break;case`bagel`:break;case`bridge`:He(!0),yt(null);break;case`bg_agent`:break}},"footer:clearSelection":()=>{yt(null)},"footer:close":()=>!1},{context:`Footer`,isActive:!!mt&&!ce}),oe((e,t)=>{if(!(Ze||$e||tt)){if(sp()===`macos`&&tT(e)){let t=eT[e],n=Nh();zt({key:`option-meta-hint`,jsx:n?(0,$.jsxs)(T,{dimColor:!0,children:[`To enable `,t,`, set `,(0,$.jsx)(T,{bold:!0,children:`Option as Meta`}),` in `,n,` preferences (⌘,)`]}):(0,$.jsxs)(T,{dimColor:!0,children:[`To enable `,t,`, run /terminal-setup`]}),priority:`immediate`,timeoutMs:5e3})}if(mt&&e&&!t.ctrl&&!t.meta&&!t.escape&&!t.return){Yt(f.slice(0,V)+e+f.slice(V)),H(V+e.length);return}if(V===0&&(t.escape||t.backspace||t.delete||t.ctrl&&e===`u`)&&(h(`prompt`),L(!1)),I&&f===``&&(t.backspace||t.delete)&&L(!1),t.escape){if(De.status===`active`){Kn(U);return}if(re&&ne){ne();return}if(I){L(!1);return}if(mt)return;if(Te.some(Mn)){bn();return}l.length>0&&!f&&!s&&vn()}t.return&&I&&L(!1)}});let jn=bm()?hm():!1,Nn=bm()?Ne&&(wm()||jn):!1,Pn=ED(Nn??!1),{columns:Fn,rows:In}=de(),Ln=Fn-3,Rn=oo()?Math.max(OD,Math.floor(In/2)-DD):void 0,zn=(0,Q.useCallback)(e=>{if(!f||P)return;let t=Xr.fromText(f,Ln,V),n=t.getViewportStartLine(Rn),r=t.measuredText.getOffsetFromPosition({line:e.localRow+n,column:e.localCol});H(r)},[f,Ln,P,V,Rn]),Bn=(0,Q.useCallback)(e=>ee(e??!0),[ee]),Vn=pn&&xt?xt:Jt,Hn=(0,Q.useMemo)(()=>f.includes(`
|
|
79
|
+
`),[f]),Un=(0,Q.useCallback)(e=>{let t=!1;U(n=>(t=bm()&&!dm(e)&&!!n.fastMode,{...n,mainLoopModel:e,mainLoopModelForSession:null,...t&&{fastMode:!1}})),Xe(!1);let n=(Ne??!1)&&!t,r=`Model set to ${Em(e)}`;l_(e,n,am())&&(r+=` · Billed as extra usage`),t&&(r+=` · Fast mode OFF`),zt({key:`model-switched`,jsx:(0,$.jsx)(T,{children:r}),priority:`immediate`,timeoutMs:3e3}),Z(`tengu_model_picker_hotkey`,{model:e})},[U,zt,Ne]),Wn=(0,Q.useCallback)(()=>{Xe(!1)},[]),Gn=(0,Q.useMemo)(()=>Ye?(0,$.jsx)(b,{flexDirection:`column`,marginTop:1,children:(0,$.jsx)(u_,{initial:Ae,sessionModel:je,onSelect:Un,onCancel:Wn,isStandaloneCommand:!0,showFastModeNotice:bm()&&Ne&&dm(Ae)&&wm()})}):null,[Ye,Ae,je,Un,Wn]),Jn=(0,Q.useCallback)(e=>{it(!1),e&&zt({key:`fast-mode-toggled`,jsx:(0,$.jsx)(T,{children:e}),priority:`immediate`,timeoutMs:3e3})},[zt]),Yn=(0,Q.useMemo)(()=>rt?(0,$.jsx)(b,{flexDirection:`column`,marginTop:1,children:(0,$.jsx)(T_,{onDone:Jn,unavailableReason:nm()})}):null,[rt,Jn]),Xn=(0,Q.useCallback)(e=>{U(t=>({...t,thinkingEnabled:e})),ot(!1),Z(`tengu_thinking_toggled_hotkey`,{enabled:e}),zt({key:`thinking-toggled-hotkey`,jsx:(0,$.jsxs)(T,{color:e?`suggestion`:void 0,dimColor:!e,children:[`Thinking `,e?`on`:`off`]}),priority:`immediate`,timeoutMs:3e3})},[U,zt]),Zn=(0,Q.useCallback)(()=>{ot(!1)},[]),Qn=(0,Q.useMemo)(()=>at?(0,$.jsx)(b,{flexDirection:`column`,marginTop:1,children:(0,$.jsx)(oT,{currentValue:Me??!0,onSelect:Xn,onCancel:Zn,isMidConversation:l.some(e=>e.type===`assistant`)})}):null,[at,Me,Xn,Zn,l.length]);if(U_(null),k)return(0,$.jsx)(tv,{onDone:()=>ee(!1),toolUseContext:M(l,[],new AbortController,se),initialDetailTaskId:typeof k==`string`?k:void 0});if(Gn)return Gn;if(Yn)return Yn;if(Qn)return Qn;if(Ve)return(0,$.jsx)(aT,{onDone:()=>{He(!1),yt(null)}});let $n={multiline:!0,onSubmit:sn,onChange:Yt,value:Le?os(typeof Le==`string`?Le:Le.display):f,onHistoryUp:tn,onHistoryDown:nn,onHistoryReset:Xt,placeholder:Vn,onExit:j,onExitMessage:(e,t)=>B({show:e,key:t}),onImagePaste:mn,columns:Ln,maxVisibleLines:Rn,disableCursorMovementForUpDownKeys:cn.length>0||!!mt,disableEscapeDoublePress:cn.length>0,cursorOffset:V,onChangeCursorOffset:H,onPaste:hn,onIsPastingChange:Ke,focus:!P&&!ce&&!mt,showCursor:!mt&&!P&&!Lt,argumentHint:un,onUndo:Kt?()=>{let e=Gt();e&&(he(e.text),H(e.cursorOffset),E(e.pastedContents))}:void 0,highlights:Rt,inlineGhostText:dn,inputFilter:gn},er=()=>{let e={bash:`bashBorder`};return e[m]?e[m]:`promptBorder`};if(qe)return(0,$.jsx)(b,{flexDirection:`row`,alignItems:`center`,justifyContent:`center`,borderColor:er(),borderStyle:`round`,borderLeft:!1,borderRight:!1,borderBottom:!0,width:`100%`,children:(0,$.jsx)(T,{dimColor:!0,italic:!0,children:`Save and close editor to continue...`})});let tr=O_()?(0,$.jsx)(aE,{...$n,initialMode:D,onModeChange:O}):(0,$.jsx)(ia,{...$n});return(0,$.jsxs)(b,{flexDirection:`column`,marginTop:+!ke,children:[!oo()&&(0,$.jsx)(pD,{}),ie&&(0,$.jsx)(b,{marginTop:1,marginLeft:2,children:(0,$.jsx)(T,{dimColor:!0,children:`Waiting for permission…`})}),(0,$.jsx)(mD,{hasStash:g!==void 0}),(0,$.jsxs)(b,{flexDirection:`row`,alignItems:`flex-start`,justifyContent:`flex-start`,borderColor:er(),borderStyle:`round`,borderLeft:!1,borderRight:!1,borderBottom:!0,width:`100%`,borderText:jD(Nn??!1,Pn,jn),children:[(0,$.jsx)(oD,{mode:m,isLoading:s}),(0,$.jsx)(b,{flexGrow:1,flexShrink:1,onClick:zn,children:tr})]}),(0,$.jsx)(nD,{apiKeyStatus:i,debug:e,exitMessage:fe,vimMode:O_()?D:void 0,mode:m,autoUpdaterResult:d,isAutoUpdating:le,verbose:c,onAutoUpdaterResult:u,onChangeIsUpdating:ue,suggestions:cn,selectedSuggestion:ln,maxColumnWidth:fn,toolPermissionContext:n,helpOpen:I,suppressHint:f.length>0,isLoading:s,tasksSelected:ht,bridgeSelected:_t,tmuxSelected:gt,ideSelection:t,mcpClients:C,isPasting:Ge,isInputWrapped:Hn,messages:l,isSearching:P,historyQuery:Fe,setHistoryQuery:Ie,historyFailedMatch:Re,onOpenTasksDialog:oo()?Bn:void 0}),oo()?(0,$.jsx)(b,{position:`absolute`,marginTop:ke?-2:-1,height:+(cn.length===0),width:`100%`,paddingLeft:2,paddingRight:1,flexDirection:`column`,justifyContent:`flex-end`,overflow:`hidden`,children:(0,$.jsx)(gC,{apiKeyStatus:i,autoUpdaterResult:d,debug:e,isAutoUpdating:le,verbose:c,messages:l,onAutoUpdaterResult:u,onChangeIsUpdating:ue,ideSelection:t,mcpClients:C,isInputWrapped:Hn})}):null]})}function AD(e){let t=0;for(let n of e)if(n.type===`user`){if(n.imagePasteIds)for(let e of n.imagePasteIds)e>t&&(t=e);if(Array.isArray(n.message.content)){for(let e of n.message.content)if(e.type===`text`){let n=nc(e.text);for(let e of n)e.id>t&&(t=e.id)}}}return t+1}function jD(e,t,n){if(e)return{content:` ${t?`${C_(!0,n)} ${H.dim(`/fast`)}`:C_(!0,n)} `,position:`top`,align:`end`,offset:0}}var MD=Q.memo(kD);Zd();function ND(e,t){return{type:`assistant`,uuid:Ov(),message:{id:`remote-${t}`,type:`message`,role:`assistant`,content:[{type:`tool_use`,id:e.tool_use_id,name:e.tool_name,input:e.input}],model:``,stop_reason:null,stop_sequence:null,container:null,context_management:null,usage:{input_tokens:0,output_tokens:0,cache_creation_input_tokens:0,cache_read_input_tokens:0}},requestId:void 0,timestamp:new Date().toISOString()}}function PD(e){return{name:e,inputSchema:{},isEnabled:()=>!0,userFacingName:()=>e,renderToolUseMessage:e=>{let t=Object.entries(e);return t.length===0?``:t.slice(0,3).map(([e,t])=>`${e}: ${typeof t==`string`?t:sf(t)}`).join(`, `)},call:async()=>({data:``}),description:async()=>``,prompt:()=>``,isReadOnly:()=>!1,isMcp:!1,needsPermissions:()=>!0}}tf(),Uh(),zd();function FD(e){return{type:`assistant`,message:e.message,uuid:e.uuid,requestId:void 0,timestamp:new Date().toISOString(),error:e.error}}function ID(e){return{type:`stream_event`,event:e.event}}function LD(e){let t=e.subtype!==`success`;return{type:`system`,subtype:`informational`,content:t?e.errors?.join(`, `)||`Unknown error`:`Session completed successfully`,level:t?`warning`:`info`,uuid:e.uuid,timestamp:new Date().toISOString()}}function RD(e){return{type:`system`,subtype:`informational`,content:`Remote session initialized (model: ${e.model})`,level:`info`,uuid:e.uuid,timestamp:new Date().toISOString()}}function zD(e){return e.status?{type:`system`,subtype:`informational`,content:e.status===`compacting`?`Compacting conversation…`:`Status: ${e.status}`,level:`info`,uuid:e.uuid,timestamp:new Date().toISOString()}:null}function BD(e){return{type:`system`,subtype:`informational`,content:`Tool ${e.tool_name} running for ${e.elapsed_time_seconds}s…`,level:`info`,uuid:e.uuid,timestamp:new Date().toISOString(),toolUseID:e.tool_use_id}}function VD(e){return{type:`system`,subtype:`compact_boundary`,content:`Conversation compacted`,level:`info`,uuid:e.uuid,timestamp:new Date().toISOString(),compactMetadata:Wh(e.compact_metadata)}}function HD(e,t){switch(e.type){case`assistant`:return{type:`message`,message:FD(e)};case`user`:{let n=e,r=n.message?.content,i=Array.isArray(r)&&r.some(e=>e.type===`tool_result`);return t?.convertToolResults&&i||t?.convertUserTextMessages&&!i&&(typeof r==`string`||Array.isArray(r))?{type:`message`,message:Pa({content:r,toolUseResult:n.tool_use_result,uuid:n.uuid,timestamp:n.timestamp})}:{type:`ignored`}}case`stream_event`:return{type:`stream_event`,event:ID(e)};case`result`:return e.subtype===`success`?{type:`ignored`}:{type:`message`,message:LD(e)};case`system`:{let t=e;if(t.subtype===`init`)return{type:`message`,message:RD(t)};if(t.subtype===`status`){let t=zD(e);return t?{type:`message`,message:t}:{type:`ignored`}}return t.subtype===`compact_boundary`?{type:`message`,message:VD(e)}:(Y(`[sdkMessageAdapter] Ignoring system message subtype: ${t.subtype}`),{type:`ignored`})}case`tool_progress`:return{type:`message`,message:BD(e)};case`auth_status`:return Y(`[sdkMessageAdapter] Ignoring auth_status message`),{type:`ignored`};case`tool_use_summary`:return Y(`[sdkMessageAdapter] Ignoring tool_use_summary message`),{type:`ignored`};case`rate_limit_event`:return Y(`[sdkMessageAdapter] Ignoring rate_limit_event message`),{type:`ignored`};case`task_state`:return Y(`[sdkMessageAdapter] Ignoring task_state message`),{type:`ignored`};default:return Y(`[sdkMessageAdapter] Unknown message type: ${e.type}`),{type:`ignored`}}}function UD(e){return e.type===`result`}q(),tf(),Ep(),zd();var WD=6e4,GD=18e4;function KD({config:e,setMessages:t,setIsLoading:n,onInit:r,setToolUseConfirmQueue:i,tools:a,setStreamingToolUses:o,setStreamMode:s,setInProgressToolUseIDs:c}){let l=!!e,u=Vr(),d=(0,Q.useCallback)(e=>u(t=>t.remoteConnectionStatus===e?t:{...t,remoteConnectionStatus:e}),[u]),f=(0,Q.useRef)(new Set),p=(0,Q.useCallback)(()=>{let e=f.current.size;u(t=>t.remoteBackgroundTaskCount===e?t:{...t,remoteBackgroundTaskCount:e})},[u]),m=(0,Q.useRef)(null),h=(0,Q.useRef)(!1),g=(0,Q.useRef)(null),_=(0,Q.useRef)(!1),v=(0,Q.useRef)(new qh(50)),y=(0,Q.useRef)(a);(0,Q.useEffect)(()=>{y.current=a},[a]),(0,Q.useEffect)(()=>{if(!e)return;Y(`[useRemoteSession] Initializing for session ${e.sessionId}`);let a=new dv(e,{onMessage:i=>{let a=[`type=${i.type}`];if(`subtype`in i&&a.push(`subtype=${i.subtype}`),i.type===`user`){let e=i.message?.content;a.push(`content=${Array.isArray(e)?e.map(e=>e.type).join(`,`):typeof e}`)}if(Y(`[useRemoteSession] Received ${a.join(` `)}`),m.current&&(clearTimeout(m.current),m.current=null),i.type===`user`&&i.uuid&&v.current.has(i.uuid)){Y(`[useRemoteSession] Dropping echoed user message ${i.uuid}`);return}if(i.type===`system`&&i.subtype===`init`&&r){let e=i.slash_commands;Y(`[useRemoteSession] Init received with ${e.length} slash commands`),r(e)}if(i.type===`system`){if(i.subtype===`task_started`){f.current.add(i.task_id),p();return}if(i.subtype===`task_notification`){f.current.delete(i.task_id),p();return}if(i.subtype===`task_progress`)return;if(i.subtype===`status`){let e=h.current;if(h.current=i.status===`compacting`,e&&h.current)return}i.subtype===`compact_boundary`&&(h.current=!1)}if(UD(i)&&(h.current=!1,n(!1)),c&&i.type===`user`){let e=i.message?.content;if(Array.isArray(e)){let t=[];for(let n of e)n.type===`tool_result`&&t.push(n.tool_use_id);t.length>0&&c(e=>{let n=new Set(e);for(let e of t)n.delete(e);return n.size===e.size?e:n})}}let l=HD(i,e.viewerOnly?{convertToolResults:!0,convertUserTextMessages:!0}:void 0);if(l.type===`message`){if(o?.(e=>e.length>0?[]:e),c&&l.message.type===`assistant`){let e=(Array.isArray(l.message.message?.content)?l.message.message.content:[]).filter(e=>e.type===`tool_use`).map(e=>e.id);e.length>0&&c(t=>{let n=new Set(t);for(let t of e)n.add(t);return n})}t(e=>[...e,l.message])}else l.type===`stream_event`&&(o&&s?br(l.event,e=>t(t=>[...t,e]),()=>{},s,o):Y(`[useRemoteSession] Stream event received but streaming callbacks not provided`))},onPermissionRequest:(e,t)=>{Y(`[useRemoteSession] Permission request for tool: ${e.tool_name}`);let r=Am(y.current,e.tool_name)??PD(e.tool_name),o=ND(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:r,description:e.description??`${e.tool_name} requires permission`,input:e.input,toolUseContext:{},toolUseID:e.tool_use_id,permissionResult:s,permissionPromptStartTimeMs:Date.now(),onUserInteraction(){},onAbort(){a.respondToPermissionRequest(t,{behavior:`deny`,message:`User aborted`}),i(t=>t.filter(t=>t.toolUseID!==e.tool_use_id))},onAllow(r,o,s){let c={behavior:`allow`,updatedInput:r};a.respondToPermissionRequest(t,c),i(t=>t.filter(t=>t.toolUseID!==e.tool_use_id)),n(!0)},onReject(n){let r={behavior:`deny`,message:n??`User denied permission`};a.respondToPermissionRequest(t,r),i(t=>t.filter(t=>t.toolUseID!==e.tool_use_id))},async recheckPermission(){}};i(e=>[...e,c]),n(!1)},onPermissionCancelled:(e,t)=>{Y(`[useRemoteSession] Permission request cancelled: ${e}`);let r=t??e;i(e=>e.filter(e=>e.toolUseID!==r)),n(!0)},onConnected:()=>{Y(`[useRemoteSession] Connected`),d(`connected`)},onReconnecting:()=>{Y(`[useRemoteSession] Reconnecting`),d(`reconnecting`),f.current.clear(),p(),c?.(e=>e.size>0?new Set:e)},onDisconnected:()=>{Y(`[useRemoteSession] Disconnected`),d(`disconnected`),n(!1),f.current.clear(),p(),c?.(e=>e.size>0?new Set:e)},onError:e=>{Y(`[useRemoteSession] Error: ${e.message}`)}});return g.current=a,a.connect(),()=>{Y(`[useRemoteSession] Cleanup - disconnecting`),m.current&&(clearTimeout(m.current),m.current=null),a.disconnect(),g.current=null}},[e,t,n,r,i,o,s,c,d,p]);let b=(0,Q.useCallback)(async(r,i)=>{let a=g.current;if(!a)return Y(`[useRemoteSession] Cannot send - no manager`),!1;m.current&&clearTimeout(m.current),n(!0),i?.uuid&&v.current.add(i.uuid);let o=await a.sendMessage(r,i);if(!o)return n(!1),!1;if(!_.current&&e&&!e.hasInitialPrompt&&!e.viewerOnly){_.current=!0;let t=e.sessionId,n=typeof r==`string`?r:Wa(r,` `);n&&Gh(n,new AbortController().signal).then(e=>{wh(t,e??Tp(n,75))})}if(!e?.viewerOnly){let e=h.current?GD:WD;m.current=setTimeout((e,t)=>{Y(`[useRemoteSession] Response timeout - attempting reconnect`);let n=Td(`Remote session may be unresponsive. Attempting to reconnect…`,`warning`);e(e=>[...e,n]),t.reconnect()},e,t,a)}return o},[e,n,t]),x=(0,Q.useCallback)(()=>{m.current&&(clearTimeout(m.current),m.current=null),e?.viewerOnly||g.current?.cancelSession(),n(!1)},[e,n]),S=(0,Q.useCallback)(()=>{m.current&&(clearTimeout(m.current),m.current=null),g.current?.disconnect(),g.current=null},[]);return(0,Q.useMemo)(()=>({isRemoteMode:l,sendMessage:b,cancelRequest:x,disconnect:S}),[l,b,x,S])}tf(),Zd(),c();function qD(e){return typeof e==`object`&&!!e&&`type`in e&&typeof e.type==`string`}var JD=class{constructor(e,t){l(this,`ws`,null),l(this,`config`,void 0),l(this,`callbacks`,void 0),this.config=e,this.callbacks=t}connect(){let e={};this.config.authToken&&(e.authorization=`Bearer ${this.config.authToken}`),this.ws=new WebSocket(this.config.wsUrl,{headers:e}),this.ws.addEventListener(`open`,()=>{this.callbacks.onConnected?.()}),this.ws.addEventListener(`message`,e=>{let t=(typeof e.data==`string`?e.data:``).split(`
|
|
80
|
+
`).filter(e=>e.trim());for(let e of t){let t;try{t=Kd(e)}catch{continue}if(!qD(t))continue;let n=t;if(n.type===`control_request`){n.request.subtype===`can_use_tool`?this.callbacks.onPermissionRequest(n.request,n.request_id):(Y(`[DirectConnect] Unsupported control request subtype: ${n.request.subtype}`),this.sendErrorResponse(n.request_id,`Unsupported control request subtype: ${n.request.subtype}`));continue}n.type!==`control_response`&&n.type!==`keep_alive`&&n.type!==`control_cancel_request`&&n.type!==`streamlined_text`&&n.type!==`streamlined_tool_use_summary`&&!(n.type===`system`&&n.subtype===`post_turn_summary`)&&this.callbacks.onMessage(n)}}),this.ws.addEventListener(`close`,()=>{this.callbacks.onDisconnected?.()}),this.ws.addEventListener(`error`,()=>{this.callbacks.onError?.(Error(`WebSocket connection error`))})}sendMessage(e){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)return!1;let t=sf({type:`user`,message:{role:`user`,content:e},parent_tool_use_id:null,session_id:``});return this.ws.send(t),!0}respondToPermissionRequest(e,t){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)return;let n=sf({type:`control_response`,response:{subtype:`success`,request_id:e,response:{behavior:t.behavior,...t.behavior===`allow`?{updatedInput:t.updatedInput}:{message:t.message}}}});this.ws.send(n)}sendInterrupt(){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)return;let e=sf({type:`control_request`,request_id:crypto.randomUUID(),request:{subtype:`interrupt`}});this.ws.send(e)}sendErrorResponse(e,t){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)return;let n=sf({type:`control_response`,response:{subtype:`error`,request_id:e,error:t}});this.ws.send(n)}disconnect(){this.ws&&(this.ws.close(),this.ws=null)}isConnected(){return this.ws?.readyState===WebSocket.OPEN}};Nm(),tf();function YD({config: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(`[useDirectConnect] Connecting to ${e.wsUrl}`);let i=new JD(e,{onMessage:e=>{if(UD(e)&&n(!1),e.type===`system`&&e.subtype===`init`){if(s.current)return;s.current=!0}let r=HD(e,{convertToolResults:!0});r.type===`message`&&t(e=>[...e,r.message])},onPermissionRequest:(e,t)=>{Y(`[useDirectConnect] Permission request for tool: ${e.tool_name}`);let a=Am(l.current,e.tool_name)??PD(e.tool_name),o=ND(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,o,s){let c={behavior:`allow`,updatedInput:a};i.respondToPermissionRequest(t,c),r(t=>t.filter(t=>t.toolUseID!==e.tool_use_id)),n(!0)},onReject(n){let a={behavior:`deny`,message:n??`User denied permission`};i.respondToPermissionRequest(t,a),r(t=>t.filter(t=>t.toolUseID!==e.tool_use_id))},async recheckPermission(){}};r(e=>[...e,c]),n(!1)},onConnected:()=>{Y(`[useDirectConnect] Connected`),c.current=!0},onDisconnected:()=>{Y(`[useDirectConnect] Disconnected`),c.current?process.stderr.write(`
|
|
81
|
+
Server disconnected.
|
|
82
|
+
`):process.stderr.write(`\nFailed to connect to server at ${e.wsUrl}\n`),c.current=!1,jl(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])}Nm(),tf(),As();function XD({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(UD(e)&&n(!1),e.type===`system`&&e.subtype===`init`){if(s.current)return;s.current=!0}let r=HD(e,{convertToolResults:!0});r.type===`message`&&t(e=>[...e,r.message])},onPermissionRequest:(e,t)=>{Y(`[useSSHSession] permission request: ${e.tool_name}`);let a=Am(l.current,e.tool_name)??PD(e.tool_name),o=ND(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:Ov(),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}`),jl(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])}tf(),Eh();async function ZD(e){let{accessToken:t,orgUUID:n}=await Th();return{baseUrl:`${jp().BASE_API_URL}/v1/sessions/${e}/events`,headers:{...Ch(t),"anthropic-beta":`ccr-byoc-2025-07-29`,"x-organization-uuid":n}}}async function QD(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 $D(e,t=100){return QD(e,{limit:t,anchor_to_latest:!0},`fetchLatestEvents`)}async function eO(e,t,n=100){return QD(e,{limit:n,before_id:t},`fetchOlderEvents`)}tf();var tO=40,nO=10,rO=`loading older messages…`,iO=`failed to load older messages — scroll up to retry`,aO=`start of session`;function oO(e){let t=[];for(let n of e.events){let e=HD(n,{convertUserTextMessages:!0,convertToolResults:!0});e.type===`message`&&t.push(e.message)}return t}function sO({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)(Ov());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=oO(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(aO);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 ZD(e.sessionId).catch(()=>null);if(!n||t)return;o.current=n;let r=await $D(n);t||!r||(l.current=nO,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(rO),...t]});try{let r=await eO(n,e);if(!r){t(e=>{let t=e[0]?.uuid===u.current?e.slice(1):e;return[d(iO),...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()<tO&&p()},[p])}}Rp();var cO=400;function lO({inputValue:e,setInputValue:t,isValidDigit:n,onDigit:r,enabled:i=!0,once:a=!1,debounceMs:o=cO}){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=Bp(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 uO=[`0`,`1`,`2`,`3`],dO={0:`dismissed`,1:`bad`,2:`fine`,3:`good`},fO=e=>uO.includes(e),pO=`How is Claude doing this session? (optional)`;function mO({onSelect:e,inputValue:t,setInputValue:n,message:r=pO}){return lO({inputValue:t,setInputValue:n,isValidDigit:fO,onDigit:t=>e(dO[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`]})})]})]})}hf(),B(),Rp();function hO({isOpen:e,skillName:t,updates:n,handleSelect:r,inputValue:i,setInputValue:a}){return!e||i&&!fO(i)?null:(0,$.jsx)(vO,{skillName:t,updates:n,onSelect:r,inputValue:i,setInputValue:a})}var gO=[`0`,`1`];function _O(e){return gO.includes(e)}function vO({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=Bp(r.slice(-1));_O(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:[yf,` `]}),(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`]})})]})]})}bp(),q(),zd();function yO(e){let t=J(e=>e.skillImprovement.suggestion),n=Vr(),[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&&fv(r.skillName,r.updates).then(()=>{e(e=>[...e,Td(`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 bO(e){return{onBeforeQuery:async()=>!0,onTurnComplete:async()=>{},render:()=>null}}tr(),io(),qu(),zl();function xO(e){(0,Q.useEffect)(()=>{let t=()=>{mm()&&process.stdout.write(`
|
|
83
|
+
`+Ic()+`
|
|
84
|
+
`),Ls(e?.())};return process.on(`exit`,t),()=>{process.off(`exit`,t)}},[])}s();function SO(){(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 CO(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])}at(),ec(),Wp();function wO(){let[e,t]=(0,Q.useState)(()=>{if(!Zp()||Xp())return`valid`;let{key:e,source:t}=$p({skipRetrievingKeyFromApiKeyHelper:!0});return e||t===`apiKeyHelper`?`loading`:`missing`}),[n,r]=(0,Q.useState)(null);return{status:e,reverify:(0,Q.useCallback)(async()=>{if(!Zp()||Xp()){t(`valid`);return}await Gp(bt());let{key:e,source:n}=$p();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 Lc(e,!1)?`valid`:`invalid`;t(n);return}catch(e){r(e),t(`error`);return}},[]),error:n}}at(),B(),Wd(),tf(),B(),Ah(),bp(),q();function TO({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=Vr(),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}=(ys(),e(Mc));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}=(ys(),e(Mc));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]);A(`app:toggleTodos`,f,{context:`Global`}),A(`app:toggleTranscript`,m,{context:`Global`}),A(`app:toggleBrief`,_,{context:`Global`,isActive:!0}),A(`app:toggleTerminal`,(0,Q.useCallback)(()=>{},[]),{context:`Global`}),A(`app:redraw`,(0,Q.useCallback)(()=>{D.get(process.stdout)?.forceRedraw()},[]),{context:`Global`});let v=t===`transcript`;return A(`transcript:toggleShowAll`,h,{context:`Transcript`,isActive:v&&!c}),A(`transcript:exit`,g,{context:`Transcript`,isActive:v&&!l}),null}ps(),qa(),Ah();var EO={setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}};function DO({onSubmit:e,isActive:t=!0}){let n=N(),r=td(),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}`,EO,void 0,{fromKeybinding:!0})}}return t},[i,e]),{context:`Chat`,isActive:t&&!r}),null}bp(),q(),j_(),Rt(),ps(),fn(),Ah(),Ft(),Ki();var OO=3e3;function kO(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=qn(),g=Vr(),_=nC().length,{addNotification:v,removeNotification:y}=lo(),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(Di()&&s){s();return}Z(`tengu_cancel`,e),t(()=>[]),n()},[o,s,t,n,m]),S=Dd(),C=o!==void 0&&!o.aborted,w=_>0,T=f!==void 0&&f!==`prompt`&&!p,E=a!==`transcript`&&!u&&!i&&!l&&!d&&!S&&!(O_()&&c===`INSERT`),D=E&&(C||w)&&!T,O=E&&(C||w);A(`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;Mi(e,g);let n=[];for(let[e,r]of t)na(e,g),n.push(r.description),sh(e,`stopped`,{toolUseId:r.toolUseId,summary:r.description});return Fi({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 A(`app:interrupt`,(0,Q.useCallback)(()=>{(C||w)&&x()},[C,w,x]),{context:`Global`,isActive:O}),A(`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<=OO){b.current=0,y(`kill-agents-confirm`),Z(`tengu_cancel`,{source:`kill_agents`}),id(),k();return}b.current=t;let n=yn(`chat:killAgents`,`Chat`,`ctrl+x ctrl+k`);v({key:`kill-agents-confirm`,text:`Press ${n} again to stop background agents`,priority:`immediate`,timeoutMs:OO})},[h,v,y,k]),{context:`Chat`}),null}B(),q(),hr();function AO(e){let t=J(e=>e.tasks),n=J(e=>e.pipeIpc),r=Object.values(t).some(ei),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 ee(n.keypress))}),{handleKeyDown:i}}F_(),np();async function jO(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 MO=new Map,NO=null;function PO(){return NO??null}function FO(e,t){let n=PO();if(!n)return null;let r=Ov(),i={requestId:r,toolName:e.tool.name,toolUseID:e.toolUseID,description:e.description,input:e.input,permissionResult:e.permissionResult,permissionPromptStartTimeMs:e.permissionPromptStartTimeMs};return MO.set(r,{onResponse:t}),n({type:`permission_request`,data:JSON.stringify(i)}),r}function IO(e){e&&MO.delete(e)}function LO(e,t){if(!e)return;let n=PO();n&&n({type:`permission_cancel`,data:JSON.stringify({requestId:e,reason:t})})}bp(),Gm(),_c(),tf(),wd(),zd(),kn(),Hd();function RO(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){Jt({tool:e,input:a?.input??t,toolUseContext:n,messageId:s,toolUseID:i},r,a?.permissionPromptStartTimeMs)},logCancelled(){Z(`tengu_tool_use_cancelled`,{messageID:s,toolName:Km(e.name)})},async persistPermissions(e){return e.length===0?!1:(Hi(e),a(sn(n.getAppState().toolPermissionContext,e)),e.some(e=>rl(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?bs:_u}${t}`:a?Fc:Ol,s=a?o:$s(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 er(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 BO(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))}}}tf(),B(),_c(),Tt(),cf();function VO(e,t){let{ctx:n,description:r,result:i,awaitAutomatedChecksBeforeDialog:a,bridgeCallbacks:o}=e,{resolve:s,isResolved:c,claim:l}=RO(t),u,d,f=o?Ov():void 0,p=Date.now(),m=i.updatedInput??n.input,h=null;function g(e){LO(h,e),IO(h),h=null}function _(){IO(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||ua(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 Co(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=FO(v,e=>{l()&&(_(),ua(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),ua(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))})()}bp(),Gm(),B(),_c(),Tt(),tf(),cf(),np(),Gn(),Zd(),Hd();function HO(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,BO(e));if(!l.resolveIfAborted(c))return(s===void 0?Co(n,r,i,a,o):Promise.resolve(s)).then(async e=>{if(process.env.USER_TYPE===`ant`&&Z(`tengu_internal_tool_permission_decision`,{toolName:Km(n.name),behavior:e.behavior,input:sf(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`&&Ys(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`:Jt({tool:n,input:r,toolUseContext:i,messageId:l.messageId,toolUseID:o},{decision:`reject`,source:`config`}),e.decisionReason?.type===`classifier`&&e.decisionReason.classifier===`auto-mode`&&(I_({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 jO({ctx:l,updatedInput:e.updatedInput,suggestions:e.suggestions,permissionMode:t.toolPermissionContext.mode});if(n){c(n);return}}if(l.resolveIfAborted(c))return;VO({ctx:l,description:a,result:e,awaitAutomatedChecksBeforeDialog:t.toolPermissionContext.awaitAutomatedChecksBeforeDialog,bridgeCallbacks:t.replBridgePermissionCallbacks},c);return}}).catch(e=>{e instanceof qd||e instanceof Xd?(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(()=>{ua(o)})}),[e,t])}ah(),bp(),la(),zu(),Wd(),tf(),As(),cf(),np(),Ki(),rm();function UO(){yu(0)}async function WO(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){Ju(),await GO({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(nc(T).map(e=>e.id)),k=Object.fromEntries(Object.entries(D).filter(([,e])=>e.type!==`image`||O.has(e.id))),ee=Object.values(k).some(Nd);if(T.trim()===``)return;if(!b&&[`exit`,`quit`,`:q`,`:q!`,`:wq`,`:wq!`].includes(T.trim())){i.find(e=>e.name===`exit`)?WO({...e,input:`/exit`}):UO();return}let A=hs(T,k),j=nc(T).filter(e=>k[e.id]?.type===`text`),M=j.length;if(Z(`tengu_paste_text`,{pastedTextCount:M,pastedTextBytes:j.reduce((e,t)=>e+(k[t.id]?.content.length??0),0)}),!b&&A.trim().startsWith(`/`)){let t=A.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&&Bu(e)&&(e.name===f||e.aliases?.includes(f)||Ns(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,[],No(),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?pn({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`)),pn({value:A.trim(),preExpansionValue:T.trim(),mode:E,pastedContents:ee?k:void 0,skipSlashCommands:b,bridgeOrigin:x,uuid:y}),a(``),S(0),o({}),w(),C();return}Ju(),await GO({queuedCommands:[{value:A,preExpansionValue:T,mode:E,pastedContents:ee?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 GO(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=No();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=h??[],w=await gs(C);C=w.attachmentCommands;let T=w.claimedCommands;if(C.length===0){l(null);return}let E=C[0]?.workload,D=E!==void 0&&C.every(e=>e.workload===E)?E:void 0,O=new Set,k;try{await Dm(D,async()=>{for(let e=0;e<C.length;e++){let n=C[e],a=e===0,l=n.autonomy?.runId,u=await fg({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&&O.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.nextInput,S=u.submitNextInput)}if(fl(`query_process_user_input_end`),xd()&&(fl(`query_file_history_snapshot_start`),s.filter(dg).forEach(e=>{Aa(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=C[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?Kp(b,n):n,i?f:void 0,r)}else a.cancelReservation(),o({jsx:null,shouldHidePromptInput:!1,clearLocalJSX:!0}),p(),l(null);x&&(S?pn({value:x,mode:`prompt`}):e.onInputChange(x))})}catch(e){k=e}if(T.length){let e=T.filter(e=>{let t=e.autonomy?.runId;return!t||!O.has(t)});if(k)try{await Nl({commands:e,outcome:{type:`failed`,error:k},currentDir:Gd(),priority:`later`,workload:D})}catch(e){X($d(e))}else try{let t=await Nl({commands:e,outcome:{type:`completed`},currentDir:Gd(),priority:`later`,workload:D});for(let e of t)pn(e)}catch(e){X($d(e))}}if(k)throw k}finally{a.cancelReservation(),c(void 0)}}Ki();function KO(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 qO({executeInput:e}){let t=e=>e.agentId===void 0,n=$r(t);if(!n)return{processed:!1};if(KO(n)||n.mode===`bash`)return e([Ba(t)]),{processed:!0};let r=n.mode,i=bn(e=>t(e)&&!KO(e)&&e.mode===r);return i.length===0?{processed:!1}:(e(i),{processed:!0})}Ki();function JO({executeQueuedInput:e,hasActiveLocalJsxUI:t,queryGuard:n}){let r=(0,Q.useSyncExternalStore)(n.subscribe,n.getSnapshot),i=(0,Q.useSyncExternalStore)(zt,Hc);(0,Q.useEffect)(()=>{r||t||i.length!==0&&qO({executeInput:e})},[i,r,e,t,n])}function YO({isLoading:e,onSubmitMessage:t}){let n=Dc();(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 XO(e,t){return e&&t&&t.length>0?Gi([...e,...t],`name`):e||[]}function ZO(e,t){return(0,Q.useMemo)(()=>XO(e,t),[e,t])}mr(),ug(),Lg(),Ti();function QO(e,t){return(0,Q.useMemo)(()=>t.length>0?Gi([...e,...t],`name`):e,[e,t])}la(),np();function $O(e,t){let n=(0,Q.useCallback)(async()=>{if(e)try{ho(),t(await su(e))}catch(e){e instanceof Error&&X(e)}},[e,t]);(0,Q.useEffect)(()=>Dg.subscribe(n),[n])}np(),Ee(),mn(),Oe();var ek=Te(()=>ye({method:xe(`selection_changed`),params:ye({selection:ye({start:ye({line:Se(),character:Se()}),end:ye({line:Se(),character:Se()})}).nullable().optional(),text:be().optional(),filePath:be().optional()})}));function tk(e,t){let n=(0,Q.useRef)(!1),r=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{let i=Ma(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(ek(),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])}el(),B(),X_(),q(),Ep();function nk({task:e,selected:t}){let n=$_(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,` · ↓ `,Ap(r),` tokens`]})})]})}function rk(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 ik(){let e=wC(),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:rk(i,s)})]}),e.map(e=>(0,$.jsx)(nk,{task:e,selected:e.agentId===a},e.agentId))]})}tf(),Ni();var ak=1e3;function ok({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 Et(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=sk(t);if(!n)return;Y(`[TaskListWatcher] Found available task #${n.id}: ${n.subject}`);let i=await Da(e,n.id,c);if(!i.success){Y(`[TaskListWatcher] Failed to claim task #${n.id}: ${i.reason}`);return}r.current=n.id;let l=ck(n);Y(`[TaskListWatcher] Submitting task #${n.id} as prompt`),o.current(l)||(Y(`[TaskListWatcher] Failed to submit task #${n.id}, releasing claim`),await fi(e,n.id,{owner:void 0}),r.current=null)};let u=(0,Q.useRef)(()=>{});(0,Q.useEffect)(()=>{if(!s)return;nd(e);let t=un(e),n=null,r=()=>{i.current&&clearTimeout(i.current),i.current=setTimeout(e=>void e.current(),ak,l)};u.current=r;try{n=Ev(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 sk(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 ck(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}Rf(),s(),mn();function lk({autoConnectIdeFlag:e,ideToInstallExtension:t,setDynamicMcpConfig:n,setShowIdeOnboarding:r,setIDEInstallationState:o}){(0,Q.useEffect)(()=>{function s(r){r&&(Lf().autoConnectIde||e||Gc()||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`}})}Ri(s,t,()=>r(!0),e=>o(e))},[e,t,n,r,o])}b_(),kh(),B(),Ah(),cn(),q(),Rf(),Cf(),s();function uk({onBackgroundSession:e,isLoading:t}){let n=Vr(),r=qn(),[i,o]=(0,Q.useState)(!1),s=R(o,e,()=>{}),c=(0,Q.useCallback)(()=>{a(process.env.CLAUDE_CODE_DISABLE_BACKGROUND_TASKS)||(Ga(r.getState())?(cd(()=>r.getState(),n),Lf().hasUsedBackgroundTask||If(e=>e.hasUsedBackgroundTask?e:{...e,hasUsedBackgroundTask:!0})):a(`false`)&&t&&s())},[n,r,t,s]),l=J(Ga),u=a(`false`);A(`task:background`,c,{context:`Task`,isActive:l||u&&t});let d=ud(`task:background`,`Task`,`ctrl+b`),f=mf.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 dk({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=Vr(),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}}ri(),rg(),Xg();function fk(e,t){return t}async function pk(e,t,n){try{Y(`Collecting transcript for sharing`,{level:`info`});let r=Fr(e),i=await Ir(Bl(e)),a;try{let e=Tn(),{size:t}=await Av(e);t<=52428800?a=await kv(e,`utf-8`):Y(`Skipping raw transcript read: file too large (${t} bytes)`,{level:`warn`})}catch{}let o=D_(sf({trigger:t,version:`0.0.5`,platform:process.platform,transcript:r,subagentTranscripts:Object.keys(i).length>0?i:void 0,rawTranscriptJsonl:a}));await pm();let s=Vp();if(s.error)return{success:!1};let c={"Content-Type":`application/json`,"User-Agent":Cm(),...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(Jd(e),{level:`error`}),{success:!1}}}var mk=t((()=>{p(),Wp(),tf(),cf(),zd(),Jc(),Zd()}));Dh(),mk();function hk({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)(Ov()),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=Ov(),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])}}bp(),Rf(),s(),zd(),rm(),Af();var gk={minTimeBeforeFeedbackMs:6e5,minTimeBetweenFeedbackMs:36e5,minTimeBetweenGlobalFeedbackMs:1e8,minUserTurnsBeforeFeedback:5,minUserTurnsBetweenFeedback:10,hideThanksAfterMs:3e3,onForModels:[`*`],probability:.005},_k={probability:0};function vk(e,t,n,r=`session`,i=!1){let o=(0,Q.useRef)(`unknown`);o.current=nl(e)?.message?.id||`unknown`;let[s,c]=(0,Q.useState)(()=>({timeLastShown:null,submitCountAtLastAppearance:null})),l=fk(`tengu_feedback_survey_config`,gk),u=fk(`tengu_bad_survey_transcript_ask_config`,_k),d=fk(`tengu_good_survey_transcript_ask_config`,_k),f=Mf().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}),Lf().feedbackSurveyState?.lastShownTime!==e&&If(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}),fh(`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}),fh(`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`||Lf().transcriptShareDismissed||!Xa(`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}),fh(`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`&&If(e=>({...e,transcriptShareDismissed:!0})),t===`yes`){let t=await pk(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}=hk({hideThanksAfterMs:l.hideThanksAfterMs,onOpen:b,onSelect:x,shouldShowTranscriptPrompt:S,onTranscriptPromptShown:C,onTranscriptSelect:w}),ee=Tm(),A=(0,Q.useMemo)(()=>l.onForModels.length===0?!1:l.onForModels.includes(`*`)?!0:l.onForModels.includes(ee),[l.onForModels,ee]),j=(0,Q.useMemo)(()=>{if(T!==`closed`||t||i)return!1;if(process.env.CLAUDE_FORCE_DISPLAY_SURVEY&&!s.timeLastShown)return!0;if(!A||a(process.env.CLAUDE_CODE_DISABLE_FEEDBACK_SURVEY)||Oh()||!Xa(`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=Lf().feedbackSurveyState;return!(e?.lastShownTime&&Date.now()-e.lastShownTime<l.minTimeBetweenGlobalFeedbackMs)},[T,t,i,A,s.timeLastShown,s.submitCountAtLastAppearance,n,l.minTimeBetweenFeedbackMs,l.minTimeBetweenGlobalFeedbackMs,l.minUserTurnsBetweenFeedback,l.minTimeBeforeFeedbackMs,l.minUserTurnsBeforeFeedback,l.probability,f]);return(0,Q.useEffect)(()=>{j&&D()},[j,D]),{state:T,lastResponse:E,handleSelect:O,handleTranscriptSelect:k}}Dh(),bp(),uo(),Rf(),s(),zd(),hh(),mk();var yk=3e3,bk=`tengu_memory_survey_event`,xk=`memory_survey`;function Sk(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}=hk({hideThanksAfterMs:yk,onOpen:(0,Q.useCallback)(e=>{Z(bk,{event_type:`appeared`,appearance_id:e}),fh(`feedback_survey`,{event_type:`appeared`,appearance_id:e,survey_type:`memory`})},[]),onSelect:(0,Q.useCallback)((e,t)=>{Z(bk,{event_type:`responded`,appearance_id:e,response:t}),fh(`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`||Lf().transcriptShareDismissed||!Xa(`allow_product_feedback`)),[]),onTranscriptPromptShown:(0,Q.useCallback)(e=>{Z(bk,{event_type:`transcript_prompt_appeared`,appearance_id:e,trigger:xk}),fh(`feedback_survey`,{event_type:`transcript_prompt_appeared`,appearance_id:e,survey_type:`memory`})},[]),onTranscriptSelect:(0,Q.useCallback)(async(e,t)=>{if(Z(bk,{event_type:`transcript_share_${t}`,appearance_id:e,trigger:xk}),t===`dont_ask_again`&&If(e=>({...e,transcriptShareDismissed:!0})),t===`yes`){let t=await pk(o.current,xk,e);return Z(bk,{event_type:t.success?`transcript_share_submitted`:`transcript_share_failed`,appearance_id:e,trigger:xk}),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)(()=>nl(e),[e]),e,l]),{state:s,lastResponse:c,handleSelect:u,handleTranscriptSelect:d}}Dh(),bp(),s(),zd(),hh();var Ck=3e3,wk=.2;function Tk(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 Ek(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}=hk({hideThanksAfterMs:Ck,onOpen:(0,Q.useCallback)(e=>{Z(`tengu_post_compact_survey_event`,{event_type:`appeared`,appearance_id:e,session_memory_compaction_enabled:Uu()}),fh(`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:Uu()}),fh(`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||Oh()||a(process.env.CLAUDE_CODE_DISABLE_FEEDBACK_SURVEY))return;if(c.current!==null&&Tk(e,c.current)){c.current=null,Math.random()<wk&&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}}hf(),B();var Dk=[`1`,`2`,`3`],Ok={1:`yes`,2:`no`,3:`dont_ask_again`},kk=e=>Dk.includes(e);function Ak({onSelect:e,inputValue:t,setInputValue:n}){return lO({inputValue:t,setInputValue:n,isValidDigit:kk,onDigit:t=>e(Ok[t])}),(0,$.jsxs)(b,{flexDirection:`column`,marginTop:1,children:[(0,$.jsxs)(b,{children:[(0,$.jsxs)(T,{color:`ansi:cyan`,children:[yf,` `]}),(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`]})})]})]})}bp(),B();function jk({state:e,lastResponse:t,handleSelect:n,handleTranscriptSelect:r,inputValue:i,setInputValue:a,onRequestFeedback:o,message:s}){return e===`closed`?null:e===`thanks`?(0,$.jsx)(Nk,{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)(Ak,{onSelect:r,inputValue:i,setInputValue:a}):i&&!fO(i)?null:(0,$.jsx)(mO,{onSelect:n,inputValue:i,setInputValue:a,message:s})}var Mk=e=>e===`1`;function Nk({lastResponse:e,inputValue:t,setInputValue:n,onRequestFeedback:r}){let i=r&&e===`good`;lO({inputValue:t,setInputValue:n,isValidDigit:Mk,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.`]})]})}Xh(),$h(),at(),Rt(),np();function Pk(e){let{addNotification:t}=lo(),n=(0,Q.useRef)(!1),r=(0,Q.useRef)(e);r.current=e,(0,Q.useEffect)(()=>{je()||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 Fk(){Pk(async()=>(await Qh()).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`}}))}Yd(),tf(),zd(),rm(),Qo(),mv(),ec(),B(),zd();function Ik(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=F();e!==`blurred`&&e!==`unknown`||o.current?.()},[n]),(0,Q.useEffect)(()=>{F()},[n,!1])}bp(),Rf(),tf(),s(),cf(),np();function Lk(){return a(process.env.CLAUDE_CODE_DISABLE_OFFICIAL_MARKETPLACE_AUTOINSTALL)}var Rk={MAX_ATTEMPTS:10,INITIAL_DELAY_MS:3600*1e3,BACKOFF_MULTIPLIER:2,MAX_DELAY_MS:10080*60*1e3};function zk(e){let t=Rk.INITIAL_DELAY_MS*Rk.BACKOFF_MULTIPLIER**e;return Math.min(t,Rk.MAX_DELAY_MS)}function Bk(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>=Rk.MAX_ATTEMPTS||t===`policy_blocked`||r&&i<r?!1:t===`unknown`||t===`git_unavailable`||t===`gcs_unavailable`||t===void 0}async function Vk(){let e=Lf();if(!Bk(e)){let t=e.officialMarketplaceAutoInstallFailReason??`already_attempted`;return Y(`Official marketplace auto-install skipped: ${t}`),{installed:!1,skipped:!0,reason:t}}try{if(Lk())return Y(`Official marketplace auto-install disabled via env var, skipping`),If(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 lr())[`claude-plugins-official`])return Y(`Official marketplace '${St}' already installed, skipping`),If(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!0})),{installed:!1,skipped:!0,reason:`already_installed`};if(!Il(Js))return Y(`Official marketplace blocked by enterprise policy, skipping`),If(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=Vd(),n=xv(t,St);if(await ns(n,t)!==null){let e=await lr();return e[St]={source:Js,installLocation:n,lastUpdated:new Date().toISOString()},await Lr(e),If(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 ru()){Y(`Git not available, skipping official marketplace auto-install`);let t=(e.officialMarketplaceAutoInstallRetryCount||0)+1,n=Date.now(),r=n+zk(t),i=!1;try{If(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!1,officialMarketplaceAutoInstallFailReason:`git_unavailable`,officialMarketplaceAutoInstallRetryCount:t,officialMarketplaceAutoInstallLastAttemptTime:n,officialMarketplaceAutoInstallNextRetryTime:r}))}catch(e){i=!0,X($d(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 Vn(Js),Y(`Successfully auto-installed official marketplace`);let r=e.officialMarketplaceAutoInstallRetryCount||0;return If(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 Uo(),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($d(t));let r=(e.officialMarketplaceAutoInstallRetryCount||0)+1,i=Date.now(),a=i+zk(r),o=!1;try{If(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!1,officialMarketplaceAutoInstallFailReason:`unknown`,officialMarketplaceAutoInstallRetryCount:r,officialMarketplaceAutoInstallLastAttemptTime:i,officialMarketplaceAutoInstallNextRetryTime:a}))}catch(e){o=!0,X($d(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(),tf();function Hk(){Pk(async()=>{let e=await Vk(),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})}Af(),bp();function Uk(e){if(e.length===0)return;if(e.length===1)return e[0];let t=e.map(e=>({tip:e,sessions:ov(e.id)}));return t.sort((e,t)=>t.sessions-e.sessions),t[0]?.tip}async function Wk(e){if(Of().spinnerTipsEnabled===!1)return;let t=await lv(e);if(t.length!==0)return Uk(t)}function Gk(e){iv(e.id),Z(`tengu_tip_shown`,{tipIdLength:e.id,cooldownSessions:e.cooldownSessions})}cf(),np(),at(),q(),Xt();var Kk=!1;async function qk(e,t,n){{if(Kk)return;Kk=!0;let{updateContext:r,notification:i}=await pr(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 Jk(){Kk=!1}function Yk(){let e=J(e=>e.mainLoopModel),t=J(e=>e.mainLoopModelForSession),n=J(e=>e.fastMode),r=Vr(),i=qn(),a=(0,Q.useRef)(!0);(0,Q.useEffect)(()=>{je()||(a.current?a.current=!1:Jk(),qk(i.getState().toolPermissionContext,r,n).catch(e=>{X(Error(`Auto mode gate check failed`,{cause:$d(e)}))}))},[e,t,n])}Va();function Xk(e,t,n){let r=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{!xd()||r.current||(r.current=!0,e&&$t(e,n))},[t,e,n])}B(),Oa(),bp(),Cl(),qg();function Zk({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`},...La()?[]:[{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)(Yg,{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)(eu,{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(),Oa(),cp();function Qk(e){return`${e.getHours()%12||12}:${String(e.getMinutes()).padStart(2,`0`)}:${String(e.getSeconds()).padStart(2,`0`)}${e.getHours()<12?`am`:`pm`}`}function $k(){let[e,t]=(0,Q.useState)([]),[n,r]=(0,Q.useState)(0);return(0,Q.useEffect)(()=>{let e=yd.getSandboxViolationStore();return e.subscribe(n=>{t(n.slice(-10)),r(e.getTotalCount())})},[]),!yd.isSandboxingEnabled()||sp()===`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:[Qk(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]})})]})}__(),Rt(),at(),B();var eA=[];function tA({mcpClients:e=eA}){let{addNotification:t}=lo();(0,Q.useEffect)(()=>{if(je())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`&&Ko(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`&&Ko(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(),Af(),dc();var nA=`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(),at(),Rt(),B(),q(),tf(),s();var rA=5e3;function iA(){let{addNotification:e}=lo(),t=Vr(),[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(je()||Je())return;let e=bc();if(e.status===`failed`){o(`lsp-manager`,e.error.message),r(!1);return}if(e.status===`pending`||e.status===`not-started`)return;let t=mc();if(t){let e=t.getAllServers();for(let[t,n]of e)n.state===`error`&&n.lastError&&o(t,n.lastError.message)}},[o]);re(s,n?rA:null),Q.useEffect(()=>{je()||!n||s()},[s,n])}tf();var aA=new Map;async function oA(e){if(!e||!e.trim())return Y(`[binaryCheck] Empty command provided, returning false`),!1;let t=e.trim(),n=aA.get(t);if(n!==void 0)return Y(`[binaryCheck] Cache hit for '${t}': ${n}`),n;let r=!1;return await ap(t).catch(()=>null)&&(r=!0),aA.set(t,r),Y(`[binaryCheck] Binary '${t}' ${r?`found`:`not found`}`),r}Rf(),tf(),vo();var sA=5;function cA(e){return kf.has(e.toLowerCase())}function lA(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=dA(t);if(e)return e}return null}return dA(e)}function uA(e){return typeof e==`object`&&!!e}function dA(e){let t=new Set,n=null;for(let[r,i]of Object.entries(e)){if(!uA(i))continue;!n&&typeof i.command==`string`&&(n=i.command);let e=i.extensionToLanguage;if(uA(e))for(let n of Object.keys(e))t.add(n.toLowerCase())}return!n||t.size===0?null:{extensions:t,command:n}}async function fA(){let e=new Map;try{let t=await lr();for(let n of Object.keys(t))try{let t=await wa(n),r=cA(n);for(let i of t.plugins){if(!i.lspServers)continue;let t=lA(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 pA(e){if(gA())return Y(`[lspRecommendation] Recommendations are disabled`),[];let t=bv(e).toLowerCase();if(!t)return Y(`[lspRecommendation] No file extension found`),[];Y(`[lspRecommendation] Looking for LSP plugins for ${t}`);let n=await fA(),r=Lf().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(Pt(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 oA(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){If(t=>{let n=t.lspRecommendationNeverPlugins??[];return n.includes(e)?t:{...t,lspRecommendationNeverPlugins:[...n,e]}}),Y(`[lspRecommendation] Added ${e} to never suggest`)}function hA(){If(e=>{let t=(e.lspRecommendationIgnoredCount??0)+1;return{...e,lspRecommendationIgnoredCount:t}}),Y(`[lspRecommendation] Incremented ignored count`)}function gA(){let e=Lf();return e.lspRecommendationDisabled===!0||(e.lspRecommendationIgnoredCount??0)>=sA}u(),at(),B(),np(),vo();function _A(){let[e,t]=Q.useState(null),n=Q.useRef(!1),r=Q.useCallback(r=>{je()||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 vA(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})}}at(),Rt(),q(),Rf(),tf(),np(),Af();var yA=28e3;function bA(){let e=J(e=>e.fileHistory.trackedFiles),{addNotification:t}=lo(),n=Q.useRef(new Set),{recommendation:r,clearRecommendation:i,tryResolve:a}=_A();return Q.useEffect(()=>{a(async()=>{if(et())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 pA(e))[0];if(t)return Y(`[useLspPluginRecommendation] Found match: ${t.pluginName} for ${e}`),Ie(!0),{pluginId:t.pluginId,pluginName:t.pluginName,pluginDescription:t.description,fileExtension:bv(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`:vA(n,a,`lsp-plugin`,t,async e=>{Y(`[useLspPluginRecommendation] Installing plugin: ${n}`);let t=typeof e.entry.source==`string`?xv(e.marketplaceInstallLocation,e.entry.source):void 0;await gc(n,e.entry,`user`,void 0,t),Pf(`userSettings`,{enabledPlugins:{...Tf(`userSettings`)?.enabledPlugins,[n]:!0}}),Y(`[useLspPluginRecommendation] Plugin installed: ${n}`)});break;case`no`:{let e=Date.now()-o;e>=yA&&(Y(`[useLspPluginRecommendation] Timeout detected (${e}ms), incrementing ignored count`),hA());break}case`never`:mA(n);break;case`disable`:If(e=>e.lspRecommendationDisabled?e:{...e,lspRecommendationDisabled:!0});break}i()},[r,t,i])}}B(),Cl(),qg();var xA=3e4;function SA({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`),xA,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)(Yg,{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)(eu,{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`)})})]})})}Rt(),bp(),tf(),$u();function CA(){let e=Q.useSyncExternalStore(Ws,Is),{addNotification:t}=lo(),{recommendation:n,clearRecommendation:r,tryResolve:i}=_A();return Q.useEffect(()=>{e&&i(async()=>{let t=await Pc(e);return t&&(Y(`[useClaudeCodeHintRecommendation] surfacing ${t.pluginId} from ${t.sourceCommand}`),Wu()),Is()===e&&Ou(),t})},[e,i]),{recommendation:n,handleResponse:Q.useCallback(e=>{if(n){switch(gu(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;vA(e,r,`hint-plugin`,t,async t=>{let n=await Ed({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`:Fu();break;case`no`:break}r()}},[n,t,r])}}B(),Cl(),qg();var wA=3e4;function TA({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`),wA,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)(Yg,{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)(eu,{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`)})})]})})}Cl(),qg();var EA=3e4;function DA({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(),EA,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)(Yg,{title:`Tool Recommendation`,children:(0,$.jsx)(eu,{options:a,onChange:e=>{e===`__dismiss__`?i.current():(i.current(),r.current(e))}})})}ko();var OA=.15,kA=3;function AA(){let e=Q.useSyncExternalStore(Qn,eo),t=Q.useMemo(()=>e.length===0?[]:e.slice(0,kA).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)>=OA,handleSelect:Q.useCallback(e=>{sr()},[]),handleDismiss:Q.useCallback(()=>{sr()},[])}}at(),Rt(),B(),q(),tf(),Rp();function jA(){let{addNotification:e}=lo(),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(!je()){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,` `,Lp(n,`plugin`),` failed to install`]}),(0,$.jsx)(T,{dimColor:!0,children:` · /plugin for details`})]}),priority:`medium`})))}},[e,n,r,i])}at(),Rt(),B(),tf(),N_();function MA(){let{addNotification:e}=lo(),[t,n]=(0,Q.useState)([]);(0,Q.useEffect)(()=>{if(!je())return P_(e=>{Y(`Plugin autoupdate notification: ${e.length} plugin(s) updated`),n(e)})},[]),(0,Q.useEffect)(()=>{if(je()||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])}tf(),np(),vo(),kg(),bp();function NA(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 PA(e){Y(`performBackgroundPluginInstallations called`);try{let t=cg(ci(),await lr().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 og({onProgress:t=>{switch(t.type){case`installing`:NA(e,t.name,`installing`);break;case`installed`:NA(e,t.name,`installed`);break;case`failed`:NA(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),Vf(`info`,`tengu_marketplace_background_install`,i),r.installed.length>0){Cr(),Y(`Auto-refreshing plugins after ${r.installed.length} new marketplace(s) installed`);try{await Og(e)}catch(t){X(t),Y(`Auto-refresh failed, falling back to needsRefresh: ${t}`,{level:`warn`}),Rs(`performBackgroundPluginInstallations: auto-refresh failed`),e(e=>e.plugins.needsRefresh?e:{...e,plugins:{...e.plugins,needsRefresh:!0}})}}else r.updated.length>0&&(Cr(),Rs(`performBackgroundPluginInstallations: marketplaces reconciled`),e(e=>e.plugins.needsRefresh?e:{...e,plugins:{...e.plugins,needsRefresh:!0}}))}catch(e){X(e)}}Rf(),tf(),vo(),cc();async function FA(e){if(Y(`performStartupChecks called`),!Bf()){Y(`Trust not accepted for current directory - skipping plugin installations`);return}try{Y(`Starting background plugin installations`),await Jr()&&(Cr(),Rs(`performStartupChecks: seed marketplaces changed`),e(e=>e.plugins.needsRefresh?e:{...e,plugins:{...e.plugins,needsRefresh:!0}})),await PA(e)}catch(e){Y(`Error initiating background plugin installations: ${e}`)}}B();var IA=/https?:\/\/\S+/;function LA(){let[e,t]=(0,Q.useState)(sm.getInstance().getStatus());return(0,Q.useEffect)(()=>sm.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(IA);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})})]})}Rt(),B(),Hr(),hu(),Wp(),vm(),at();function RA(e){let{addNotification:t}=lo(),n=Nc(),r=(0,Q.useMemo)(()=>Ar(n,e),[n,e]),i=(0,Q.useMemo)(()=>Go(n),[n]),a=(0,Q.useRef)(null),o=Jp(),s=Sm(),c=o===`team`||o===`enterprise`,[l,u]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{je()||(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)(()=>{je()||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])}Rt(),at();function zA(e){let{addNotification:t}=lo(),n=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{if(je())return;let r=av(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 BA=``;function VA(){Pk(async()=>Np()||a(process.env.DISABLE_INSTALLATION_CHECKS)||await Zh()===`development`?null:{timeoutMs:15e3,key:`npm-deprecation-warning`,text:BA,color:`warning`,priority:`high`})}Rt(),B(),Rf(),mn(),at();var HA=5;function UA({ideSelection:e,mcpClients:t,ideInstallationStatus:n}){let{addNotification:r,removeNotification:i}=lo(),{status:a,ideName:o}=oC(t),s=(0,Q.useRef)(!1),c=n?At(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(je())return;if(Gc()||a!==null||p){i(`ide-status-hint`);return}if(s.current||(Lf().ideHintShownCount??0)>=HA)return;let e=setTimeout((e,t)=>{Es(!0).then(n=>{let r=n[0]?.name;r&&!e.current&&(e.current=!0,If(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(!je()){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(!je()){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(!je()){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])}Rf();var WA=[e=>{if(KA(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(KA(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 GA(){Pk(()=>{let e=Lf(),t=[];for(let n of WA){let r=n(e);r&&t.push(r)}return t.length>0?t:null})}function KA(e){return e!==void 0&&Date.now()-e<3e3}Wp(),B(),bp(),Rf();var qA=3;function JA(){Pk(async()=>{if((Lf().subscriptionNoticeCount??0)>=qA)return null;let e=await YA();return e===null?null:(If(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`]}),priority:`low`})})}async function YA(){if(Xp())return null;let e=await Yp();return e?e.account.has_claude_max?`Max`:e.account.has_claude_pro?`Pro`:null:null}Rt(),q(),lm(),Ep(),at();var XA=`fast-mode-cooldown-started`,ZA=`fast-mode-cooldown-expired`,QA=`fast-mode-org-changed`,$A=`fast-mode-overage-rejected`;function ej(){let{addNotification:e}=lo(),t=J(e=>e.fastMode),n=Vr();(0,Q.useEffect)(()=>{if(!je()&&bm())return cm(r=>{r?e({key:QA,color:`fastMode`,priority:`immediate`,text:`Fast mode is now available · /fast to turn on`}):t&&(n(e=>({...e,fastMode:!1})),e({key:QA,color:`warning`,priority:`immediate`,text:`Fast mode has been disabled by your organization`}))})},[e,t,n]),(0,Q.useEffect)(()=>{if(!je()&&bm())return xm(t=>{n(e=>({...e,fastMode:!1})),e({key:$A,color:`warning`,priority:`immediate`,text:t})})},[e,n]),(0,Q.useEffect)(()=>{if(je()||!t)return;let n=gm((t,n)=>{let r=tj(n,kp(t-Date.now(),{hideTrailingZeros:!0}));e({key:XA,invalidates:[ZA],text:r,color:`warning`,priority:`immediate`})}),r=im(()=>{e({key:ZA,invalidates:[XA],color:`fastMode`,text:`Fast limit reset · now using fast mode`,priority:`immediate`})});return()=>{n(),r()}},[e,t])}function tj(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(),Ah();function nj({onRun:e,onCancel:t,reason:n}){let r=(0,Q.useRef)(!1);return A(`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 rj(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 ij(e){return process.env.USER_TYPE===`ant`&&e===`feedback_survey_good`?`/good-claude`:`/issue`}function aj(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 oj=()=>null;hf(),B();function sj(){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}Lm(),zd();var cj=[/\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/],lj=[/^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 uj(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(cj.some(t=>t.test(e)))return!1}}}return!0}function dj(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n.type!==`user`)continue;let r=zn(n);if(r)return lj.some(e=>e.test(r))}return!1}var fj=3,pj=1800*1e3;function mj(e,t){let n=(0,Q.useRef)(0),r=(0,Q.useRef)(-1),i=(0,Q.useMemo)(()=>uj(e)&&dj(e),[e]);return process.env.USER_TYPE===`ant`?r.current===t?!0:Date.now()-n.current<pj||t<fj||!i?!1:(n.current=Date.now(),r.current=t,!0):!1}at(),B();function hj(){return process.env.USER_TYPE===`ant`}function gj(){let[e,t]=(0,Q.useState)(yt);return ae(()=>{t(yt())},hj()?500:null),!hj()||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(),ms(),Cl(),Vh(),q(),at(),a_(),zd(),Ki(),Wd(),lp(),Jc(),ps();var _j=24,vj=11;function yj(){return new Date().toISOString().split(`T`)[0]}function bj({plan:e,sessionId:t,taskId:n,setMessages:r,readFileState:i,memorySelector:a,getAppState:o,setConversationId:s,resultDedupState:c}){ks(`ultraplan-choice`);let l=Vr(),{rows:u,columns:f}=de(),p=Q.useMemo(()=>Math.min(_j,Math.max(1,Math.floor(u/2)-vj)),[u]),m=Q.useMemo(()=>w(e,Math.max(1,f-4),`wrap`).split(`
|
|
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
|
+
`),x=g>0,S=g<h,C=Q.useCallback(async a=>{switch(a){case`here`:Fi({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
|
+
`),mode:`task-notification`});break;case`fresh`:let t=st(),n=await Av(Tn()).then(()=>!0,()=>!1);await s_({setMessages:r,readFileState:i,getAppState:o,setAppState:l,setConversationId:s}),n&&r(e=>[...e,Td(`Previous session saved · resume with: claude --resume ${t}`,`suggestion`)]),Fi({value:`Here is the approved implementation plan:\n\n${e}\n\nImplement this plan.`,mode:`prompt`});break;case`cancel`:{let t=xv(Gd(),`${yj()}-ultraplan.md`);await jv(t,e,{encoding:`utf-8`}),r(e=>[...e,Td(`Ultraplan rejected · Plan saved to ${dp(t)}`,`suggestion`)]);break}}wo(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),Ja(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)(eu,{options:E,onChange:e=>void C(e)})]})})}B(),Cl(),Vh(),q(),Rf(),wl();function xj(){return!Lf().hasSeenUltraplanTerms}function Sj(){return Pl()}function Cj({onChoice:e}){let[t]=Q.useState(xj),[n]=Q.useState(Sj),r=Q.useMemo(()=>_s(n),[n]),i=J(e=>e.replBridgeEnabled),a=Vr(),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&&If(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:Pu,children:Pu})]}):null]}),(0,$.jsx)(T,{dimColor:!0,children:i?`This will disable Remote Control for this session.`:r.dialogPipeline}),(0,$.jsx)(eu,{options:c,onChange:o})]})})}z_(),B(),Rf(),Ur();function wj(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||!(Lf().copyOnSelect??!0))return;let a=e.copySelectionNoClear();if(!a||!a.trim()){r.current=!0;return}r.current=!0,i.current?.(a)})},[t,e])}function Tj(e){let[t]=y();(0,Q.useEffect)(()=>{e.setSelectionBgColor(Yn(t).selectionBg)},[e,t])}Rt(),B(),Ah(),tf();var Ej=40,Dj=.3,Oj=6,kj=200,Aj=15,jj=15,Mj=3,Nj=1500,Pj=150,Fj=5,Ij=5,Lj=80,Rj=3,zj=6,Bj=500;function Vj(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 Hj(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 Uj(e,t,n){if(!e.xtermJs){if(e.wheelMode&&n-e.time>Nj&&(e.wheelMode=!1,e.burstCount=0,e.mult=e.base),e.pendingFlip){if(e.pendingFlip=!1,t!==e.dir||n-e.time>kj)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<Ij)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/Pj),n=Math.max(jj,e.base*2),i=1+(e.mult-1)*t+Aj*t;return e.mult=Math.min(n,i,e.mult+Mj),Math.floor(e.mult)}if(r>Ej)e.mult=e.base;else{let t=Math.max(Oj,e.base*2);e.mult=Math.min(t,e.mult+Dj)}return Math.floor(e.mult)}let r=n-e.time,i=t===e.dir;if(e.time=n,e.dir=t,i&&r<Ij)return 1;if(!i||r>Bj)e.mult=2,e.frac=0;else{let t=.5**(r/Pj);e.mult=Math.min(r>=Lj?Rj:zj,1+(e.mult-1)*t+Fj*t)}let a=e.mult+e.frac,o=Math.floor(a);return e.frac=a-o,o}function Wj(){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 Gj(e=!1,t=1){return{time:0,mult:t,dir:0,xtermJs:e,frac:0,base:t,pendingFlip:!1,wheelMode:!1,burstCount:0}}function Kj(){let e=se(),t=Wj();return Y(`wheel accel: ${e?`decay (xterm.js)`:`window (native)`} · base=${t} · TERM_PROGRAM=${process.env.TERM_PROGRAM??`unset`}`),Gj(e,t)}var qj=2,Jj=50,Yj=200;function Xj({scrollRef:e,isActive:t,onScroll:n,isModal:r=!1}){let i=ue(),{addNotification:a}=lo(),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=$j(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=$j(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=Kj()),tM(t,Uj(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=Kj());let r=eM(t,Uj(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=$j(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=$j(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=$j(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=$j(t,r);n?.(i,t)}},{context:`Scroll`,isActive:t}),oe((t,r,i)=>{let a=e.current;if(!a)return;let o=rM(a,nM(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=Hj(t);if(r){i.moveFocus(r),n.stopImmediatePropagation();return}Vj(t)&&i.clearSelection()},{isActive:t}),Zj(e,i,t,n),wj(i,t,s),Tj(i),null}function Zj(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>Yj){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(qj,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(qj,e-i.getScrollTop());t.captureScrolledRows(l,l+n-1,`above`),t.shiftAnchor(-n,l,u),i.scrollBy(qj)}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,Jj)))}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=Qj(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 Qj(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 $j(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 eM(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 tM(e,t){if(e.getScrollTop()+e.getPendingDelta()-t<=0){e.scrollTo(0);return}e.scrollBy(-t)}function nM(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 rM(e,t,n){switch(t){case null:return null;case`lineUp`:case`lineDown`:{let r=t===`lineDown`?1:-1;return n(r),$j(e,r)}case`halfPageUp`:case`halfPageDown`:{let r=Math.max(1,Math.floor(e.getViewportHeight()/2)),i=t===`halfPageDown`?r:-r;return n(i),$j(e,i)}case`fullPageUp`:case`fullPageDown`:{let r=Math.max(1,e.getViewportHeight()),i=t===`fullPageDown`?r:-r;return n(i),$j(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 iM=r({useFrustrationDetection:()=>oM});function aM(e){return e.filter(e=>`isApiErrorMessage`in e&&e.isApiErrorMessage===!0).length>=2}function oM(e,t,n,r){let[i,a]=(0,sM.useState)(`closed`),o=Lf(),s=Xa(`product_feedback`),c=o.transcriptShareDismissed||!s||t||n||r,l=aM(e);return{state:c?`closed`:l&&i===`closed`?`transcript_prompt`:i,handleTranscriptSelect:t=>{c||(t===`yes`?(pk(e,`frustration`,crypto.randomUUID()),a(`submitted`)):(If(e=>({...e,transcriptShareDismissed:!0})),a(`closed`)))}}}var sM,cM=t((()=>{sM=n(z(),1),Rf(),uo(),mk()})),lM=r({useAntOrgWarningNotification:()=>uM});function uM(){}t((()=>{}));var dM=r({useProactive:()=>fM});function fM(e){let t=(0,pM.useRef)(e);t.current=e,(0,pM.useEffect)(()=>{if(!uh())return;let e=null,n=!1,r=!1;function i(){lh(Date.now()+mM),e=setTimeout(()=>{if(e=null,!rh()){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 Ms({basePrompt:`<${$f}>${new Date().toLocaleTimeString()}</${$f}>`,currentDir:Gd(),shouldCreate:()=>!n});if(n){await kc({commands:e});return}let r=[];try{for(let n of e)t.current.onQueueTick(n),r.push(n)}catch(t){throw await kc({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),lh(null)}},[uh(),nh(),ih()])}var pM,mM,hM=t((()=>{pM=n(z(),1),ep(),Wd(),xu(),tf(),mM=3e4}));function gM(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 _M(e){let t=sc(e),n=gM(e),r=`Continuation turns executed: ${e.turnsExecuted}`;return`<goal-steering type="continuation">
|
|
88
|
+
You have an active goal to work on. Continue making progress.
|
|
89
|
+
|
|
90
|
+
## Active Goal
|
|
91
|
+
${e.objective}
|
|
92
|
+
|
|
93
|
+
## Status
|
|
94
|
+
- Elapsed active time: ${t}
|
|
95
|
+
- ${n}
|
|
96
|
+
- ${r}
|
|
97
|
+
|
|
98
|
+
## Instructions
|
|
99
|
+
|
|
100
|
+
Continue working towards the goal. Do NOT narrow the scope of the goal — even if you cannot complete everything in one turn, maintain the full objective and make as much progress as possible.
|
|
101
|
+
|
|
102
|
+
When you believe the goal is fully achieved, use the GoalTool to mark it complete. Before doing so, perform a strict Completion Audit:
|
|
103
|
+
|
|
104
|
+
### Completion Audit
|
|
105
|
+
1. Derive concrete requirements from the objective and any referenced files.
|
|
106
|
+
2. Preserve the original scope — do not redefine success around what is already done.
|
|
107
|
+
3. For every explicit requirement, identify authoritative evidence (test output, file content, command result).
|
|
108
|
+
4. Treat tests, manifests, and verifiers as evidence only after confirming they actually cover the requirement.
|
|
109
|
+
5. Treat uncertain or indirect evidence as "not achieved".
|
|
110
|
+
6. The audit must PROVE completion, not merely fail to find remaining work.
|
|
111
|
+
|
|
112
|
+
### Blocked Audit
|
|
113
|
+
If you encounter an obstacle you genuinely cannot overcome:
|
|
114
|
+
- Do NOT mark blocked on the first encounter.
|
|
115
|
+
- The same blocking condition must persist for at least 3 consecutive continuation turns before you may mark blocked.
|
|
116
|
+
- "Difficult", "slow", or "partially incomplete" is NOT blocked.
|
|
117
|
+
- If blocked, use the GoalTool with status "blocked" and a clear reason.
|
|
118
|
+
|
|
119
|
+
Resume working now.
|
|
120
|
+
</goal-steering>`}function vM(e){return`<goal-steering type="budget_limit">
|
|
121
|
+
## Token Budget Reached
|
|
122
|
+
|
|
123
|
+
Your token budget for this goal has been exhausted.
|
|
124
|
+
|
|
125
|
+
- Goal: ${e.objective}
|
|
126
|
+
- Tokens used: ${e.tokensUsed}${e.tokenBudget===null?``:` / ${e.tokenBudget}`}
|
|
127
|
+
- Active time: ${sc(e)}
|
|
128
|
+
|
|
129
|
+
**Stop all substantive work immediately.** Do NOT start new file edits, tool calls, or explorations.
|
|
130
|
+
|
|
131
|
+
Instead, provide a brief summary:
|
|
132
|
+
1. What has been accomplished so far.
|
|
133
|
+
2. What remains to be done.
|
|
134
|
+
3. Any blockers or issues encountered.
|
|
135
|
+
|
|
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 yM=t((()=>{})),bM=r({useGoalContinuation:()=>SM});function xM(e){Y(`[goal] hook: ${e}`)}function SM(e){let t=(0,CM.useRef)(e);t.current=e;let n=(0,CM.useRef)(!1),r=(0,CM.useRef)(!1);(0,CM.useLayoutEffect)(()=>{if(e.isLoading){n.current=!1;return}if(e.isQueryActiveNow?.()){xM(`skip: queryActiveNow=true`);return}if(e.wasAborted){xM(`skip: wasAborted=true`);return}if(n.current)return;if(Hc().length>0){xM(`skip: yielding to queued user messages`);return}if(e.hasActiveLocalJsxUI){xM(`skip: activeLocalJsxUI`);return}if(e.isInPlanMode){xM(`skip: planMode`);return}let t=bl();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=vM(t);Y(`[goal] hook: budget limit reached, injecting wrap-up prompt`),pn({value:e,mode:`prompt`,priority:`now`,isMeta:!0,origin:`goal-budget-limit`,skipSlashCommands:!0});return}if(t.status!==`active`){xM(`skip: status="${t.status}" (not active)`);return}if(t.turnsExecuted>=150){Qu()&&(jc(),e.onMaxTurnsReached?.()),Y(`[goal] hook: MAX_GOAL_TURNS (150) reached, stopping`);return}n.current=!0;let i=hc();jc();let a=_M(t);Y(`[goal] hook: enqueuing turn ${i} for "${t.objective.slice(0,60)}"`),pn({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 CM,wM=t((()=>{CM=n(z(),1),tf(),us(),yM(),Ki()})),TM=r({AntModelSwitchCallout:()=>EM,shouldShowModelSwitchCallout:()=>DM});function EM(e){return null}function DM(){return!1}t((()=>{}));var OM=r({UndercoverAutoCallout:()=>kM});function kM({onDone:e}){return(0,AM.useEffect)(()=>{e()},[e]),null}var AM,jM=t((()=>{AM=n(z(),1)}));at(),cu(),wf(),u(),B(),ms(),Rg(),Rt(),tf(),s(),Ep(),xu(),Ft(),la(),hg(),zl(),zu(),Xu(),cn(),fn(),cf(),np(),Wd(),kn(),Xt(),_c(),Rf(),vm(),bp(),zd(),Kh(),ep(),As(),ku(),W_(),eg(),iu(),wd(),Gg(),q(),rc(),Jc(),Va(),mn(),Dn(),Ki(),nu(),nr(),Oa(),wl(),dr();var MM=process.env.USER_TYPE===`ant`?(cM(),e(iM)).useFrustrationDetection:()=>({state:`closed`,handleTranscriptSelect:()=>{}}),NM=process.env.USER_TYPE===`ant`?e(lM).useAntOrgWarningNotification:()=>{},PM=(dh(),e(eh)),FM=e=>()=>{},IM=()=>!1,LM=()=>null,RM=(e,t)=>!1,zM=(hM(),e(dM)).useProactive,BM=(wM(),e(bM)).useGoalContinuation,VM=()=>({relayPipeMessage:()=>!1,pipeReturnHadErrorRef:{current:!1}}),HM=()=>({routeToSelectedPipes:()=>!1}),UM=process.env.USER_TYPE===`ant`?e(TM).AntModelSwitchCallout:null,WM=process.env.USER_TYPE===`ant`?e(TM).shouldShowModelSwitchCallout:()=>!1,GM=process.env.USER_TYPE===`ant`?(jM(),e(OM)).UndercoverAutoCallout:null,KM=[],qM=3e3;function JM(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 YM({showAllInTranscript:e,virtualScroll:t,searchBadge:n,suppressShowAll:r=!1,status:i}){let a=ud(`app:toggleTranscript`,`Global`,`ctrl+o`),o=ud(`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 XM({jumpRef:e,count:t,current:n,onClose:r,onCancel:i,setHighlight:a,initialQuery:o}){let{query:s,cursorOffset:c}=f_({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 ZM=[`⠂`,`⠐`],QM=`✳`,$M=960;function eN({isAnimating:e,title:t,disabled:n,noPrefix:r}){let i=j(),[a,o]=(0,Q.useState)(0);(0,Q.useEffect)(()=>{if(n||r||!e||!i)return;let t=setInterval(e=>e(e=>(e+1)%ZM.length),$M,o);return()=>clearInterval(t)},[n,r,e,i]);let s=e?ZM[a]??QM:QM;return te(n?null:r?t:`${s} ${t}`),null}var tN=`<${tp}>`;function nN(e){return e.type===`text`&&typeof e.text==`string`&&e.text.includes(tN)}function rN({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:ee}){let A=!!D,M=(0,Q.useMemo)(()=>a(process.env.CLAUDE_CODE_DISABLE_TERMINAL_TITLE),[]),te=(0,Q.useMemo)(()=>process.env.USER_TYPE===`ant`&&a(process.env.CLAUDE_MORERIGHT),[]),N=(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[F,re]=(0,Q.useState)(S),I=J(e=>e.toolPermissionContext),L=J(e=>e.verbose),R=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=nC(),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=Vr(),ve=ge?B[ge]:void 0,ye=Yc(ve)&&ve.retain&&!ve.diskLoaded;(0,Q.useEffect)(()=>{if(!ge||!ye)return;let e=ge;Ku(Qr(e)).then(t=>{U(n=>{let r=n.tasks[e];if(!Yc(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=qn(),xe=E(),Se=Wg(),[Ce,we]=(0,Q.useState)(t);$O(A?void 0:dt(),we);let Te=Q.useSyncExternalStore(PM?.subscribeToProactiveChanges??FM,PM?.isProactiveActive??IM),Ee=Q.useSyncExternalStore(PM?.subscribeToProactiveChanges??FM,PM?.getNextTickAt??LM),De=J(e=>e.isBriefOnly),Oe=(0,Q.useMemo)(()=>Jo(I),[I,Te,De]);Yk();let[ke,Ae]=(0,Q.useState)(f),je=(0,Q.useCallback)(e=>{Ae(e)},[Ae]),[Pe,Fe]=(0,Q.useState)(`prompt`),[Ie,Re]=(0,Q.useState)(!1),[Be,Ve]=(0,Q.useState)(!1),[He,We]=(0,Q.useState)(``),Ge=(0,Q.useRef)(0),Ke=(0,Q.useRef)(void 0),Je=(0,Q.useRef)(!1),{addNotification:Ze,removeNotification:Qe}=lo(),$e=RM,et=ZO(d,R.clients),[at,pt]=(0,Q.useState)(void 0),[mt,_t]=(0,Q.useState)(null),[yt,bt]=(0,Q.useState)(null),[St,Ct]=(0,Q.useState)(!1),[wt,Tt]=(0,Q.useState)(()=>process.env.USER_TYPE===`ant`&&WM()),Et=J(e=>e.showRemoteCallout),[Dt,kt]=(0,Q.useState)(()=>uv());GA(),JA(),UA({ideSelection:at,mcpClients:et,ideInstallationStatus:yt}),tA({mcpClients:et}),jA(),MA(),g_(),RA(Se),ej(),zA(Se),VA(),NM(),Fk(),Hk(),iA();let{recommendation:At,handleResponse:Nt}=bA(),{recommendation:Pt,handleResponse:Ft}=CA(),It=AA(),Rt=(0,Q.useMemo)(()=>[...Oe,...r],[Oe,r]);ng({enabled:!A});let zt=qo();(0,Q.useEffect)(()=>{A||FA(U)},[U,A]);let Bt=Ig(Rt,R.tools,I),{tools:Vt,allowedAgentTypes:Ht}=(0,Q.useMemo)(()=>{if(!F)return{tools:Bt,allowedAgentTypes:void 0};let e=jt(F,Bt,!1,!0);return{tools:e.resolvedTools,allowedAgentTypes:e.allowedAgentTypes}},[F,Bt]),Wt=QO(QO(Ce,z.commands),R.commands),Kt=(0,Q.useMemo)(()=>C?[]:Wt,[C,Wt]);Ay(A?KM:R.clients),tk(A?KM:R.clients,pt);let[qt,Jt]=(0,Q.useState)(`responding`),Yt=(0,Q.useRef)(qt);Yt.current=qt;let[Xt,Zt]=(0,Q.useState)([]),[Qt,$t]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{if(Qt&&!Qt.isStreaming&&Qt.streamingEndedAt){let e=3e4-(Date.now()-Qt.streamingEndedAt);if(e>0){let t=setTimeout($t,e,null);return()=>clearTimeout(t)}else $t(null)}},[Qt]);let[en,tn]=(0,Q.useState)(null),an=(0,Q.useRef)(null);an.current=en;let cn=(0,Q.useRef)(0),[ln,un]=(0,Q.useState)(!1),dn=(0,Q.useRef)(()=>{}),fn=(0,Q.useRef)(()=>{}),mn=(0,Q.useRef)(null),hn=(0,Q.useRef)(null),gn=(0,Q.useRef)(0),_n=Q.useRef(new uy).current,vn=Q.useSyncExternalStore(_n.subscribe,_n.getSnapshot),[bn,Sn]=Q.useState(D?.hasInitialPrompt??!1),W=vn||bn,[Cn,Tn]=Q.useState(void 0),En=Q.useRef(0),Dn=Q.useRef(!1),On=Q.useRef(0),kn=Q.useRef(0),An=Q.useRef(null),Mn=Q.useCallback(()=>{On.current=Date.now(),kn.current=0,An.current=null},[]),Nn=Q.useRef(!1);vn&&!Nn.current&&Mn(),Nn.current=vn;let Pn=Q.useCallback(e=>{Sn(e),e&&Mn()},[Mn]),Fn=Q.useRef(void 0),[In,Ln]=Q.useState(!1),[Rn,zn]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{Rn?.notifications&&Rn.notifications.forEach(e=>{Ze({key:`auto-updater-notification`,text:e,priority:`low`})})},[Rn,Ze]),(0,Q.useEffect)(()=>{oo()&&rr().then(e=>{e&&Ze({key:`tmux-mouse-hint`,text:e,priority:`low`})})},[]);let[Bn,Vn]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{process.env.USER_TYPE===`ant`&&(async()=>{let{isInternalModelRepo:e}=await import(`./commitAttribution-D6J3NuhB.js`);await e();let{shouldShowUndercoverAutoNotice:t}=await import(`./undercover-k3JoOKAb.js`);t()&&Vn(!0)})()},[]);let[Hn,Un]=(0,Q.useState)(null),Wn=(0,Q.useRef)(null),Gn=(0,Q.useCallback)(e=>{if(e?.isLocalJSXCommand){let{clearLocalJSX:t,...n}=e;Wn.current={...n,isLocalJSXCommand:!0},Un(n);return}if(Wn.current){if(e?.clearLocalJSX){Wn.current=null,Un(null),cn.current=Date.now();return}return}if(e?.clearLocalJSX){Un(null);return}Un(e)},[]),[Kn,Jn]=(0,Q.useState)([]),[Yn,Xn]=(0,Q.useState)(null),[Zn,Qn]=(0,Q.useState)([]),[$n,er]=(0,Q.useState)([]),tr=(0,Q.useRef)(new Map),nr=J(e=>e.settings.terminalTitleFromRename)===!1?void 0:xl(st()),[ir,ar]=(0,Q.useState)(),or=(0,Q.useRef)((i?.length??0)>0),sr=F?.agentType,lr=nr??sr??ir??`Work Mate`,ur=Kn.length>0||$n.length>0,dr=Hn?.isLocalJSXCommand===!0&&Hn?.jsx!=null,fr=W&&!ur&&!dr;(0,Q.useEffect)(()=>{if(W&&!ur&&!dr)return ry(),()=>iy()},[W,ur,dr]);let pr=ur||dr?`waiting`:W?`busy`:`idle`,mr=pr===`waiting`?Kn.length>0?`approve ${Kn[0].tool.name}`:dr?`dialog open`:`input needed`:void 0;(0,Q.useEffect)(()=>{Id({status:pr,waitingFor:mr})},[pr,mr]),P(null);let[G,hr]=(0,Q.useState)(i??[]),gr=(0,Q.useRef)(G),_r=(0,Q.useRef)(!1),K=(0,Q.useCallback)(e=>{let t=gr.current,n=typeof e==`function`?e(gr.current):e;if(gr.current=n,n.length<En.current)En.current=0;else if(n.length>t.length&&Dn.current){let e=n.length-t.length;(t.length===0||n[0]===t[0]?n.slice(-e):n.slice(0,e)).some(gi)?Dn.current=!1:En.current=n.length}hr(n)},[]),yr=(0,Q.useCallback)(e=>{e===void 0?Dn.current=!1:(En.current=gr.current.length,Dn.current=!0),Tn(e)},[]),{dividerIndex:xr,dividerYRef:Cr,onScrollAway:wr,onRepin:Tr,jumpToNew:Er,shiftDivider:Or}=G_(G.length);Ik(G,K,W);let[Ar,jr]=(0,Q.useState)(null),Mr=(0,Q.useRef)(null),Fr=(0,Q.useMemo)(()=>H_(G,xr),[xr,G.length]),Ir=(0,Q.useCallback)(()=>{mn.current?.scrollToBottom(),Tr(),jr(null)},[Tr,jr]),Lr=G.at(-1),Rr=Lr!=null&&gi(Lr);(0,Q.useEffect)(()=>{Rr&&Ir()},[Rr,Lr,Ir]);let{maybeLoadOlder:Br}=sO({config:D,setMessages:K,scrollRef:mn,onPrepend:Or}),Hr=(0,Q.useCallback)((e,t)=>{gn.current=Date.now(),e?Tr():(wr(t),Br(t))},[Tr,wr,Br,U]),Ur=CO(o,K),Wr=(0,Q.useDeferredValue)(Q.useMemo(()=>G.length>500?G.slice(-500):G,[G])),Kr=G.length-Wr.length;Kr>0&&Y(`[useDeferredValue] Messages deferred by ${Kr} (${Wr.length}→${G.length})`);let[qr,Jr]=(0,Q.useState)(null),[Xr,Zr]=(0,Q.useState)(()=>rv()),$r=(0,Q.useRef)(Xr);$r.current=Xr;let ei=(0,Q.useRef)(null),ti=(0,Q.useCallback)(e=>{$e($r.current,e)||($r.current===``&&e!==``&&Date.now()-gn.current>=qM&&Ir(),$r.current=e,Zr(e),Ln(e.trim().length>0))},[Ln,Ir,$e]);(0,Q.useEffect)(()=>{if(Xr.trim().length===0)return;let e=setTimeout(Ln,1500,!1);return()=>clearTimeout(e)},[Xr]);let[ni,ri]=(0,Q.useState)(`prompt`),[ai,oi]=(0,Q.useState)(),si=(0,Q.useCallback)(e=>{let t=new Set(e);we(e=>e.filter(e=>t.has(e.name)||xa.has(e)))},[we]),[ci,li]=(0,Q.useState)(new Set),ui=(0,Q.useRef)(!1),di=KD({config:D,setMessages:K,setIsLoading:Pn,onInit:si,setToolUseConfirmQueue:Jn,tools:Rt,setStreamingToolUses:Zt,setStreamMode:Jt,setInProgressToolUseIDs:li}),fi=YD({config:O,setMessages:K,setIsLoading:Pn,setToolUseConfirmQueue:Jn,tools:Rt}),mi=XD({session:k,setMessages:K,setIsLoading:Pn,setToolUseConfirmQueue:Jn,tools:Rt}),_i=mi.isRemoteMode?mi:fi.isRemoteMode?fi:di,[vi,yi]=(0,Q.useState)({}),[bi,xi]=(0,Q.useState)(0),Si=(0,Q.useRef)(0),wi=(0,Q.useRef)([]),Ti=(0,Q.useCallback)(e=>{let t=Si.current;if(Si.current=e(t),Si.current>t){let e=wi.current;if(e.length>0){let t=e.at(-1);t.lastTokenTime=Date.now(),t.endResponseLength=Si.current}}},[]),[Ei,Di]=(0,Q.useState)(null),Oi=!(J(e=>e.settings.prefersReducedMotion)??!1)&&!V(),ki=(0,Q.useCallback)(e=>{Oi&&Di(e)},[Oi]),Ai=Ei&&Oi&&Ei.substring(0,Ei.lastIndexOf(`
|
|
138
|
+
`)+1)||null,[ji,Mi]=(0,Q.useState)(0),[Ni,Pi]=(0,Q.useState)(null),[Fi,Ri]=(0,Q.useState)(null),[Bi,Hi]=(0,Q.useState)(null),[Ui,Wi]=(0,Q.useState)(!1),[Gi,Ki]=(0,Q.useState)(void 0),[Ji,Yi]=(0,Q.useState)(!1),[Xi,Qi]=(0,Q.useState)(Ov()),[$i,ea]=(0,Q.useState)(null),na=(0,Q.useRef)(!1),ra=(0,Q.useRef)(ji);ra.current=ji;let[ia]=(0,Q.useState)(()=>({current:Gr(i,c)}));pc(()=>{ia.current=$a()});let[aa,oa]=(0,Q.useState)(Lf().hasAcknowledgedCostThreshold),[sa,ca]=(0,Q.useState)(`INSERT`),[la,ua]=(0,Q.useState)(!1),[da,pa]=(0,Q.useState)(!1),[ma,_a]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{me&&la&&ua(!1)},[me,la]);let va=j(),ya=(0,Q.useRef)(va);ya.current=va;let[ba]=y(),Sa=Q.useRef(!1),Ca=(0,Q.useCallback)(()=>{if(Sa.current)return;Sa.current=!0;let e=gr.current.slice(qa.current);for(let t of Dr(e))Ka.current.add(t);qa.current=gr.current.length,Wk({theme:ba,readFileState:Ga.current,bashTools:Ka.current}).then(async e=>{if(e){let t=await e.content({theme:ba});U(e=>({...e,spinnerTip:t})),Gk(e)}else U(e=>e.spinnerTip===void 0?e:{...e,spinnerTip:void 0})})},[U,ba]),wa=(0,Q.useCallback)(()=>{Pn(!1),yr(void 0),Si.current=0,wi.current=[],Di(null),Zt([]),Pi(null),Ri(null),Hi(null),Ca(),mh(),Zl()},[Ca]),Ta=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{{if(I.mode!==`auto`){Ta.current=!1;return}if(Ta.current||(Lf().autoPermissionsNotificationCount??0)>=3)return;let e=setTimeout((e,t)=>{e.current=!0,If(e=>{let t=e.autoPermissionsNotificationCount??0;return t>=3?e:{...e,autoPermissionsNotificationCount:t+1}}),t(e=>[...e,Td(nA,`warning`)])},800,Ta,K);return()=>clearTimeout(e)}},[I.mode,K]);let Ea=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{if(Ea.current)return;let e=on();if(!e?.creationDurationMs||e.usedSparsePaths||e.creationDurationMs<15e3)return;Ea.current=!0;let t=Math.round(e.creationDurationMs/1e3);K(e=>[...e,Td(`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 Da=(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`&&ci.has(e.id));return n.length>0&&n.every(e=>e.type===`tool_use`&&e.name===`Sleep`)},[G,ci]),{onBeforeQuery:Oa,onTurnComplete:ka,render:ja}=bO({enabled:te,setMessages:K,inputValue:Xr,setInputValue:ti,setToolJSX:Gn}),Na=(!Hn||Hn.showSpinner===!0)&&Kn.length===0&&$n.length===0&&(W||Cn||Ot()>0)&&!Da&&(!Ai||De),Fa=Kn.length>0||$n.length>0||Zn.length>0||H.queue.length>0,Ia=vk(G,W,bi,`session`,Fa),La=yO(K),Ra=mj(G,bi),za=(0,Q.useMemo)(()=>({...Ia,handleSelect:e=>{to.current=!1;let t=Ia.handleSelect(e);e===`bad`&&!t&&rj(`feedback_survey_bad`)&&(eo(`feedback_survey_bad`),to.current=!0)}}),[Ia]),Ba=Ek(G,W,Fa,{enabled:!A}),Va=Sk(G,W,Fa,{enabled:!A}),Ha=MM(G,W,Fa,za.state!==`closed`||Ba.state!==`closed`||Va.state!==`closed`);lk({autoConnectIdeFlag:p,ideToInstallExtension:mt,setDynamicMcpConfig:Ae,setShowIdeOnboarding:Ct,setIDEInstallationState:bt}),Xk(s,se,e=>U(t=>({...t,fileHistory:e})));let Ua=(0,Q.useCallback)(async(t,n,r)=>{let i=performance.now();try{let a=So(n.messages),o=Gs();await rs(`resume`,{getAppState:()=>be.getState(),setAppState:U,signal:AbortSignal.timeout(o),timeoutMs:o});let s=await uu(`resume`,{sessionId:t,agentType:F?.agentType,model:Se});a.push(...s),r===`fork`?Fl(n,ha(t)):Cu(n,ha(t)),wg(n,U),n.fileHistorySnapshots&&ss(n);let{agentDefinition:c}=Sg(n.agentSetting,S,ae);re(c),U(e=>({...e,agent:c?.agentType})),U(e=>({...e,standaloneAgentContext:Cg(n.agentName,n.agentColor)})),go(n.agentName),q(a,n.projectPath??ut()),wa(),tn(null),Qi(t);let l=xs(t);Ls(),ht(),gt(ha(t),n.fullPath?yv(n.fullPath):null);let{renameRecordingForSession:u}=await import(`./asciicast-BsWpcxrc.js`);if(await u(),await ac(),kl(),Jl(n),n.goal){let{hydrateGoalFromTranscript:r}=(pu(),e(El)),i=new Map;i.set(t,n.goal),r(i,t)}if(or.current=!0,ar(void 0),r!==`fork`)Tg(),Eg(n.worktreeSession),Pr(),dd({abortController:new AbortController,getAppState:()=>be.getState(),setAppState:U});else{let e=on();e&&nn(e)}l&&rt(l),ia.current&&r!==`fork`&&(ia.current=ou(a,n.contentReplacements??[])),K(()=>a),Gn(null),ti(``),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}},[wa,U]),[Wa]=(0,Q.useState)(()=>Zm(100)),Ga=(0,Q.useRef)(Wa),Ka=(0,Q.useRef)(new Set),qa=(0,Q.useRef)(0),Ja=(0,Q.useRef)(new Set),Ya=(0,Q.useRef)(new Set),q=(0,Q.useCallback)((e,t)=>{let n=Ho(e,t,100);Ga.current=$m(Ga.current,n);for(let t of Dr(e))Ka.current.add(t)},[]);(0,Q.useEffect)(()=>{i&&i.length>0&&(q(i,ut()),dd({abortController:new AbortController,getAppState:()=>be.getState(),setAppState:U}))},[]);let{status:Xa,reverify:Za}=wO(),[Qa,eo]=(0,Q.useState)(null),to=(0,Q.useRef)(!1),[no,ro]=(0,Q.useState)(null),[io,ao]=(0,Q.useState)(!1),so=!W&&Ji;function co(){if(io||no)return;if(Ui)return`message-selector`;if(In)return;if(Zn[0])return`sandbox-permission`;let e=!Hn||Hn.shouldContinueAnimation;if(e&&Kn[0])return`tool-permission`;if(e&&$n[0])return`prompt`;if(e&&H.queue[0])return`elicitation`;if(e&&so)return`cost`;if(e&&$i)return`idle-return`;if(e&&!W&&me)return`ultraplan-choice`;if(e&&!W&&he)return`ultraplan-launch`;if(e&&St)return`ide-onboarding`;if(process.env.USER_TYPE===`ant`&&e&&wt)return`model-switch`;if(process.env.USER_TYPE===`ant`&&e&&Bn)return`undercover-callout`;if(e&&Et)return`remote-callout`;if(e&&At)return`lsp-recommendation`;if(e&&Pt)return`plugin-hint`;if(e&&It.visible)return`search-extra-tools-hint`;if(e&&Dt)return`desktop-upsell`}let uo=co(),fo=In&&(Zn[0]||Kn[0]||$n[0]||H.queue[0]||so);Fn.current=uo,(0,Q.useEffect)(()=>{if(!W)return;let e=uo===`tool-permission`,t=Date.now();e&&An.current===null?An.current=t:!e&&An.current!==null&&(kn.current+=t-An.current,An.current=null)},[uo,W]);let po=(0,Q.useRef)(uo);(0,Q.useLayoutEffect)(()=>{po.current===`tool-permission`!=(uo===`tool-permission`)&&Ir(),po.current=uo},[uo,Ir]);function mo(){if(uo!==`elicitation`){if(cn.current!==0&&Date.now()-cn.current<500){cn.current=0,Y(`[onCancel] suppressed: local-jsx panel just dismissed`);return}if(cn.current=0,Y(`[onCancel] focusedInputDialog=${uo} streamMode=${qt}`),PM?.pauseProactive(),_n.getSnapshot()){let{getGoal:t,pauseGoal:n}=(us(),e(Sc)),{persistCurrentGoal:r}=(pu(),e(El));t()?.status===`active`&&(n(),r())}if(un(!0),_n.forceEnd(),na.current=!1,Ei?.trim()&&K(e=>[...e,Xl({content:Ei})]),wa(),tt(null),uo===`tool-permission`)Kn[0]?.onAbort(),Jn([]);else if(uo===`prompt`){for(let e of $n)e.reject(Error(`Prompt cancelled by user`));er([]),en?.abort(`user-cancel`)}else _i.isRemoteMode?_i.cancelRequest():en?.abort(`user-cancel`);tn(null),ka(gr.current,!0)}}let ho=(0,Q.useCallback)(()=>{let e=ga(Xr,0);e&&(ti(e.text),ri(`prompt`),e.images.length>0&&yi(t=>{let n={...t};for(let t of e.images)n[t.id]=t;return n}))},[ti,ri,Xr,yi]),_o={setToolUseConfirmQueue:Jn,onCancel:mo,onAgentsKilled:()=>K(e=>[...e,Gu()]),isMessageSelectorVisible:Ui||!!la,screen:Pe,abortSignal:en?.signal,popCommandFromQueue:ho,vimMode:sa,isLocalJSXCommand:Hn?.isLocalJSXCommand,isSearchingHistory:da,isHelpOpen:ma,inputMode:ni,inputValue:Xr,streamMode:qt};(0,Q.useEffect)(()=>{lt()>=5&&!Ji&&!aa&&(Z(`tengu_cost_threshold_reached`,{}),oa(!0),mm()&&Yi(!0))},[G,Ji,aa]);let vo=(0,Q.useCallback)(async e=>new Promise(t=>{let n=!1;function r(e){n||(n=!0,t(e))}Qn(t=>[...t,{hostPattern:e,resolvePromise:r}]);{let t=be.getState().replBridgePermissionCallbacks;if(t){let n=Ov();t.sendRequest(n,ag,{host:e.host},Ov(),`Allow network connection to ${e.host}?`);let r=t.onResponse(n,t=>{r();let n=t.behavior===`allow`;Qn(t=>(t.filter(t=>t.hostPattern.host===e.host).forEach(e=>e.resolvePromise(n)),t.filter(t=>t.hostPattern.host!==e.host)));let i=tr.current.get(e.host);if(i){for(let e of i)e();tr.current.delete(e.host)}}),i=()=>{r(),t.cancelRequest(n)},a=tr.current.get(e.host)??[];a.push(i),tr.current.set(e.host,a)}}}),[U,be]);(0,Q.useEffect)(()=>{let e=yd.getSandboxUnavailableReason();if(e){if(yd.isSandboxRequired()){process.stderr.write(`\nError: sandbox required but unavailable: ${e}\n sandbox.failIfUnavailable is set — refusing to start without a working sandbox.\n\n`),yu(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]),yd.isSandboxingEnabled()&&yd.initialize(vo).catch(e=>{process.stderr.write(`\n❌ Sandbox Error: ${Jd(e)}\n`),yu(1,`other`)});let yo=(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))},Jn)},[U,Jn]),bo=HO(Jn,yo),xo=(0,Q.useCallback)((e,t,r,i)=>{let a=be.getState(),o=()=>{let e=be.getState(),t=Yr(e.toolPermissionContext,e.mcp.tools),n=lg(Rt,t,e.toolPermissionContext.mode);return F?jt(F,n,!1,!0).resolvedTools:n};return{abortController:r,options:{commands:Kt,tools:o(),debug:n,verbose:a.verbose,mainLoopModel:i,thinkingConfig:a.thinkingEnabled===!1?{type:`disabled`}:ee,mcpClients:XO(d,a.mcp.clients),mcpResources:a.mcp.resources,ideInstallationStatus:yt,isNonInteractiveSession:!1,dynamicMcpConfig:ke,theme:ba,agentDefinitions:Ht?{...a.agentDefinitions,allowedAgentTypes:Ht}: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||Wi(!0)},onChangeAPIKey:Za,readFileState:Ga.current,setToolJSX:Gn,addNotification:Ze,appendSystemMessage:e=>K(t=>[...t,e]),sendOSNotification:e=>{Gv(e,xe)},onChangeDynamicMcpConfig:je,onInstallIDEExtension:_t,nestedMemoryAttachmentTriggers:new Set,loadedNestedMemoryPaths:Ya.current,dynamicSkillDirTriggers:new Set,discoveredSkillNames:Ja.current,setResponseLength:Ti,pushApiMetricsEntry:process.env.USER_TYPE===`ant`?e=>{let t=Date.now(),n=Si.current;wi.current.push({ttftMs:e,firstTokenTime:t,lastTokenTime:t,responseLengthBaseline:n,endResponseLength:n})}:void 0,setStreamMode:Jt,onCompactProgress:e=>{switch(e.type){case`hooks_start`:Ri(`claudeBlue_FOR_SYSTEM_SPINNER`),Hi(`claudeBlueShimmer_FOR_SYSTEM_SPINNER`),Pi(e.hookType===`pre_compact`?`Running PreCompact hooks…`:e.hookType===`post_compact`?`Running PostCompact hooks…`:`Running SessionStart hooks…`);break;case`compact_start`:Pi(`Compacting conversation`);break;case`compact_end`:Pi(null),Ri(null),Hi(null);break}},setInProgressToolUseIDs:li,setHasInterruptibleToolInProgress:e=>{ui.current=e},resume:Ua,setConversationId:Qi,requestPrompt:void 0,contentReplacementState:ia.current}},[Kt,Rt,F,n,d,yt,ke,ba,Ht,be,U,Za,Ze,K,je,Ua,(0,Q.useCallback)((e,t)=>n=>new Promise((r,i)=>{er(a=>[...a,{request:n,title:e,toolInputSummary:t,resolve:r,reject:i}])}),[]),x,h,g,Qi]),{handleBackgroundSession:Co}=dk({setMessages:K,setIsLoading:Pn,resetLoadingState:wa,setAbortController:tn,onBackgroundQuery:(0,Q.useCallback)(()=>{en?.abort(`background`);let e=Ad(e=>e.mode===`task-notification`);(async()=>{let t=xo(gr.current,[],new AbortController,Se),[n,r,i]=await Promise.all([dl(t.options.tools,Se,Array.from(I.additionalWorkingDirectories.keys()),t.options.mcpClients),pi(),Vc()]),a=Mo({mainThreadAgentDefinition:F,toolUseContext:t,customSystemPrompt:h,defaultSystemPrompt:n,appendSystemPrompt:g});t.renderedSystemPrompt=a;let o=(await Li(e).catch(()=>[])).map(xn),s=new Set;for(let e of gr.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)));Vi({messages:[...gr.current,...c],queryParams:{systemPrompt:a,userContext:r,systemContext:i,canUseTool:bo,toolUseContext:t,querySource:jn()},description:lr,setAppState:U,agentDefinition:F})})()},[en,Se,I,F,xo,h,g,bo,U])}),wo=(0,Q.useCallback)(t=>{br(t,t=>{if(Gt(t)?(oo()?K(e=>{let n=Mt(e,{includeSnipped:!0});return[...n.length>500?n.slice(-500):n,t]}):K(()=>[t]),Qi(Ov()),PM?.setContextBlocked(!1)):t.type===`progress`&&ta(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?PM?.setContextBlocked(!0):t.type===`assistant`&&PM?.setContextBlocked(!1),t.type===`assistant`&&`isApiErrorMessage`in t&&t.isApiErrorMessage){let n=(zi(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}=(us(),e(Sc)),{persistCurrentGoal:r}=(pu(),e(El));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=>{Ti(t=>t+e.length)},Jt,Zt,e=>{K(t=>t.filter(t=>t!==e)),cl(e.uuid)},$t,e=>{let t=Date.now(),n=Si.current;wi.current.push({...e,firstTokenTime:t,lastTokenTime:t,responseLengthBaseline:n,endResponseLength:n})},ki)},[K,Ti,Jt,Zt,$t,ki]),To=(0,Q.useCallback)(async(e,t,n,r,i,a)=>{if(r){let e=XO(d,be.getState().mcp.clients);Ut.handleQueryStart(e);let t=Ma(e);t&&Cd(t)}if(Mh(),!M&&!nr&&!sr&&!or.current){let e=t.find(e=>e.type===`user`&&!e.isMeta),n=e?.type===`user`?zi(e.message.content):null;n&&!n.startsWith(`<local-command-stdout>`)&&!n.startsWith(`<command-message>`)&&!n.startsWith(`<command-name>`)&&!n.startsWith(`<bash-input>`)&&(or.current=!0,Gh(n,new AbortController().signal).then(e=>{e?ar(e):or.current=!1},()=>{or.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)&&(Qi(Ov()),PM?.setContextBlocked(!1)),wa(),tn(null);return}let o=xo(e,t,n,a),{tools:s,mcpClients:c}=o.options;fl(`query_context_loading_start`);let[,,l,u,f]=await Promise.all([void 0,qk(I,U,be.getState().fastMode),dl(s,a,Array.from(I.additionalWorkingDirectories.keys()),c),pi(),Vc()]),p={...u,...PM?.isProactiveActive()&&!ya.current?{terminalFocus:`The terminal is unfocused — the user is not actively watching.`}:{}};fl(`query_context_loading_end`);let m=Mo({mainThreadAgentDefinition:F,toolUseContext:o,customSystemPrompt:h,defaultSystemPrompt:l,appendSystemPrompt:g});o.renderedSystemPrompt=m,fl(`query_query_start`),ot(),ft(),it();for await(let t of Zi({messages:e,systemPrompt:m,userContext:p,systemContext:f,canUseTool:bo,toolUseContext:o,querySource:jn()}))wo(t);if(fl(`query_end`),process.env.USER_TYPE===`ant`&&wi.current.length>0){let e=wi.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=Ye(),a=Me(),o=Xe(),s=qe(),c=xt(),l=Ue(),u=Date.now()-On.current;K(e=>[...e,Ks({ttftMs:r?JM(t):t[0],otps:r?JM(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:zf()})])}wa(),zs(),await v?.(gr.current)},[d,wa,xo,I,U,h,v,g,bo,F,wo,nr,M]),Eo=(0,Q.useCallback)(async(e,t,n,r,i,a,o)=>{let s=_n.tryStart();if(s===null)return Z(`tengu_concurrent_onquery_detected`,{}),e.filter(e=>e.type===`user`&&!e.isMeta).map(e=>zi(e.message.content)).filter(e=>e!==null).forEach((e,t)=>{pn({value:e,mode:`prompt`}),t===0&&Z(`tengu_concurrent_onquery_enqueued`,{})}),!1;try{es.current=!1,un(!1),Mn(),K(t=>[...t,...e]),Si.current=0,tt((o?Nr(o):null)??Ne()),wi.current=[],Zt([]),Di(null);let s=gr.current;if(o&&await Oa(o,s,e.length),a&&o&&!await a(o,s))return!0;try{await To(s,e,t,n,r,i)}catch(e){throw e}}finally{if(_n.end(s)){un(t.signal.aborted),Mi(Date.now()),na.current=!1,wa(),await ka(gr.current,t.signal.aborted),dn.current(),process.env.USER_TYPE===`ant`&&!t.signal.aborted&&U(e=>e.tungstenActiveSession===void 0||e.tungstenPanelAutoHidden===!0?e:{...e,tungstenPanelAutoHidden:!0});let e;Ne()!==null&&Ne()>0&&!t.signal.aborted&&(e={tokens:Le(),limit:Ne(),nudges:nt()}),tt(null);let n=Date.now()-On.current-kn.current;(n>3e4||e!==void 0)&&!t.signal.aborted&&!Te&&K(t=>[...t,Ds(n,e,jf(t,Sr))]),tn(null)}if(t.signal.reason===`user-cancel`&&!_n.isActive&&$r.current===``&&Ot()===0&&!be.getState().viewingAgentTaskId){let e=gr.current,t=e.findLast(dg);t&&pg(e,e.lastIndexOf(t))&&(Ul(),fn.current(t))}}return!0},[To,U,wa,_n,Oa,ka]),Do=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{let e=ce;if(!e||W||Do.current)return;Do.current=!0;async function t(e){if(e.clearContext){let t=e.message.planContent?Vu():void 0,{clearConversation:n}=await import(`./conversation-CH9ouFai.js`);await n({setMessages:K,readFileState:Ga.current,discoveredSkillNames:Ja.current,loadedNestedMemoryPaths:Ya.current,getAppState:()=>be.getState(),setAppState:U,setConversationId:Qi}),or.current=!1,ar(void 0),Ka.current.clear(),qa.current=0,t&&Kl(st(),t)}U(t=>{let n=e.mode?sn(t.toolPermissionContext,Vx(e.mode,e.allowedPrompts)):t.toolPermissionContext;return e.mode===`auto`&&(n=Ci({...n,mode:`auto`,prePlanMode:void 0})),{...t,initialMessage:null,toolPermissionContext:n}}),xd()&&Aa(e=>{U(t=>({...t,fileHistory:e(t.fileHistory)}))},e.message.uuid),await Ur();let t=e.message.message.content;if(typeof t==`string`&&!e.message.planContent)Oo(t,{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}});else{let t=No();tn(t),Eo([e.message],t,!0,[],Se)}setTimeout(e=>{e.current=!1},100,Do)}t(e)},[ce,W,K,U,Eo,Se,Vt]);let Oo=(0,Q.useCallback)(async(e,t,n,r)=>{if(Ir(),PM?.resumeProactive(),ts(e)){let n=Pa({content:e});K(e=>[...e,n]),r?.fromKeybinding||Oc({display:bd(e,ni),pastedContents:vi}),ti(``),t.setCursorOffset(0),t.clearBuffer(),yi({}),ri(`prompt`),pt(void 0);return}if(!n&&e.trim().startsWith(`/`)){let n=hs(e,vi).trim(),i=n.indexOf(` `),a=i===-1?n.slice(1):n.slice(1,i),o=i===-1?``:n.slice(i+1).trim(),s=Kt.find(e=>Bu(e)&&(e.name===a||e.aliases?.includes(a)||Ns(e)===a));s?.name===`clear`&&_r.current&&(Z(`tengu_idle_return_action`,{action:`hint_converted`,variant:_r.current,idleMinutes:Math.round((Date.now()-ra.current)/6e4),messageCount:gr.current.length,totalInputTokens:ct()}),_r.current=!1);let c=_n.isActive&&(s?.immediate||r?.fromKeybinding);if(s&&c&&s.type===`local-jsx`){e.trim()===$r.current.trim()&&(ti(``),t.setCursorOffset(0),t.clearBuffer(),yi({}));let n=nc(e).filter(e=>vi[e.id]?.type===`text`),i=n.length;Z(`tengu_paste_text`,{pastedTextCount:i,pastedTextBytes:n.reduce((e,t)=>e+(vi[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,Gn({jsx:null,shouldHidePromptInput:!1,clearLocalJSX:!0});let i=[];if(n&&r?.display!==`skip`&&(Ze({key:`immediate-${s.name}`,text:n,priority:`immediate`}),!oo())){let e=r?.displayArgs??o;i.push(xc(wn(Ns(s),e)),xc(`<${Zf}>${Lt(n)}</${Zf}>`))}r?.metaMessages?.length&&i.push(...r.metaMessages.map(e=>Pa({content:e,isMeta:!0}))),i.length&&K(e=>[...e,...i]),ai!==void 0&&(ti(ai.text),t.setCursorOffset(ai.cursorOffset),yi(ai.pastedContents),oi(void 0))},r=xo(gr.current,[],No(),Se),i=await(await s.load()).call(n,r,o);i&&!e&&Gn({jsx:i,shouldHidePromptInput:!1,isLocalJSXCommand:!0})})();return}}if(_i.isRemoteMode&&!e.trim())return;Number(process.env.CLAUDE_CODE_IDLE_THRESHOLD_MINUTES??75),Number(process.env.CLAUDE_CODE_IDLE_TOKEN_THRESHOLD??1e5),r?.fromKeybinding||(Oc({display:n?e:bd(e,ni),pastedContents:n?{}:vi}),ni===`bash`&&ow(e.trim()));let i=!n&&e.trim().startsWith(`/`),a=!W||n||_i.isRemoteMode;if(ai!==void 0&&!i&&a?(ti(ai.text),t.setCursorOffset(ai.cursorOffset),yi(ai.pastedContents),oi(void 0)):a&&(r?.fromKeybinding||(ti(``),t.setCursorOffset(0)),yi({})),a&&(ri(`prompt`),pt(void 0),xi(e=>e+1),t.clearBuffer(),Sa.current=!1,!i&&ni===`prompt`&&!n&&!_i.isRemoteMode&&(yr(e),Mn()),U(e=>({...e,attribution:yh(e.attribution,e=>{Xs(e).catch(e=>{Y(`Attribution: Failed to save snapshot: ${e}`)})})}))),n){let{queryRequired:t}=await zr(n.state,n.speculationSessionTimeSavedMs,n.setAppState,e,{setMessages:K,readFileState:Ga,cwd:ut()});if(t){let e=No();tn(e),Eo([],e,!0,[],Se)}return}if(_i.isRemoteMode&&!(i&&Kt.find(t=>{let n=e.trim().slice(1).split(/\s/)[0];return Bu(t)&&(t.name===n||t.aliases?.includes(n)||Ns(t)===n)})?.type===`local-jsx`)){let t=Object.values(vi),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=Pa({content:i,imagePasteIds:r});K(e=>[...e,o]),await _i.sendMessage(a,{uuid:o.uuid});return}await Ur(),await WO({input:e,helpers:t,queryGuard:_n,isExternalLoading:bn,mode:ni,commands:Kt,onInputChange:ti,setPastedContents:yi,setToolJSX:Gn,getToolUseContext:xo,messages:gr.current,mainLoopModel:Se,pastedContents:vi,ideSelection:at,setUserInputOnProcessing:yr,setAbortController:tn,abortController:en,onQuery:Eo,setAppState:U,querySource:jn(),onBeforeQuery:_,canUseTool:bo,addNotification:Ze,setMessages:K,streamMode:Yt.current,hasInterruptibleToolInProgress:ui.current}),(i||W)&&ai!==void 0&&(ti(ai.text),t.setCursorOffset(ai.cursorOffset),yi(ai.pastedContents),oi(void 0))},[_n,W,bn,ni,Kt,ti,ri,yi,xi,pt,Gn,xo,Se,vi,at,yr,tn,Ze,Eo,ai,oi,U,_,bo,di,K,Ur,Ir]),ko=(0,Q.useCallback)(()=>{let e=Qa?ij(Qa):`/issue`;eo(null),Oo(e,{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}}).catch(t=>{Y(`Auto-run ${e} failed: ${Jd(t)}`)})},[Oo,Qa]),Ao=(0,Q.useCallback)(()=>{eo(null)},[]),jo=(0,Q.useCallback)(()=>{let e=process.env.USER_TYPE===`ant`?`/issue`:`/feedback`;Oo(e,{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}}).catch(e=>{Y(`Survey feedback request failed: ${e instanceof Error?e.message:String(e)}`)})},[Oo]),Fo=(0,Q.useRef)(Oo);Fo.current=Oo;let Io=(0,Q.useCallback)(()=>{Fo.current(`/rate-limit-options`,{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}})},[]),Lo=(0,Q.useCallback)(async()=>{if(ao(!0),ii()){Nv(`tmux`,[`detach-client`],{stdio:`ignore`}),ao(!1);return}if(on()!==null){ro((0,$.jsx)(x_,{showWorktree:!0,onDone:()=>{},onCancel:()=>{ro(null),ao(!1)}}));return}let e=await(await Gl.load()).call(()=>{});ro(e),e===null&&ao(!1)},[]),zo=(0,Q.useCallback)(()=>{Wi(e=>!e)},[]),Bo=(0,Q.useCallback)(e=>{let t=gr.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)),Qi(Ov()),kr();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]),Vo=(0,Q.useCallback)(e=>{Bo(e);let t=fa(e);if(t&&(ti(t.text),ri(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}}}),yi(n)}}},[Bo,ti]);fn.current=Vo;let Uo=(0,Q.useCallback)(async e=>{setImmediate((e,t)=>e(t),Vo,e)},[Vo]),Wo=e=>{let t=e.slice(0,24);return G.findIndex(e=>e.uuid.slice(0,24)===t)},{enter:Go,handlers:Ko}=gd(Ar,jr,Mr,{copy:e=>void ie(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=Wo(e.uuid),n=t>=0?G[t]:void 0;if(!n||!dg(n))return;let r=!await md(se,n.uuid),i=pg(G,t);r&&i?(mo(),Uo(n)):(Ki(n),Wi(!0))}});async function Yo(){Za();let e=await kd();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
|
+
`);Y(`Loaded ${e.length} CLAUDE.md/rules files:\n${t}`)}else Y(`No CLAUDE.md/rules files found`);for(let t of e)Ga.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})}xO(nv()),dy(G,G.length===i?.length);let{sendBridgeResult:Xo}=Oy(G,K,an,Kt,Se);dn.current=Xo,SO();let Zo=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{if(le.length<1){Zo.current=!1;return}Zo.current||(Zo.current=!0,If(e=>({...e,promptQueueUseCount:(e.promptQueueUseCount??0)+1})))},[le.length]),JO({executeQueuedInput:(0,Q.useCallback)(async e=>{await WO({helpers:{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}},queryGuard:_n,commands:Kt,onInputChange:()=>{},setPastedContents:()=>{},setToolJSX:Gn,getToolUseContext:xo,messages:G,mainLoopModel:Se,ideSelection:at,setUserInputOnProcessing:yr,setAbortController:tn,onQuery:Eo,setAppState:U,querySource:jn(),onBeforeQuery:_,canUseTool:bo,addNotification:Ze,setMessages:K,queuedCommands:e})},[_n,Kt,Gn,xo,G,Se,at,yr,bo,tn,Eo,Ze,U,_]),hasActiveLocalJsxUI:dr,queryGuard:_n}),(0,Q.useEffect)(()=>{tc.recordUserActivity(),vt(!0)},[Xr,bi]),(0,Q.useEffect)(()=>{bi===1&&pv()},[bi]),(0,Q.useEffect)(()=>{if(W||bi===0||ji===0)return;let e=setTimeout((e,t,n,r,i)=>{if(ze()>e)return;let a=Date.now()-e;!t&&!n&&r.current===void 0&&a>=Lf().messageIdleNotifThresholdMs&&Gv({message:`Claude is waiting for your input`,notificationType:`idle_prompt`},i)},Lf().messageIdleNotifThresholdMs,ji,W,Hn,Fn,xe);return()=>clearTimeout(e)},[W,Hn,bi,ji,xe]),(0,Q.useEffect)(()=>{},[ji,W,Ze,Qe]);let Qo=(0,Q.useCallback)((e,t)=>{if(_n.isActive||Zc().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 gs([n]),t=e.attachmentCommands[0];if(!t)return;let r=No();tn(r);let i=Pa({content:t.value,isMeta:t.isMeta?!0:void 0,origin:t.origin}),a=!1;try{a=await Eo([i],r,!0,[],Se)!==!1}catch(t){try{await Nl({commands:e.claimedCommands,outcome:{type:`failed`,error:t},currentDir:Gd(),priority:`later`})}catch(e){X($d(e))}X($d(t));return}if(a)try{let t=await Nl({commands:e.claimedCommands,outcome:{type:`completed`},currentDir:Gd(),priority:`later`});for(let e of t)pn(e)}catch(e){X($d(e))}})().catch(e=>{X($d(e))}),!0},[Eo,Se,be]),{relayPipeMessage:$o,pipeReturnHadErrorRef:es}=VM();YO({isLoading:W,onSubmitMessage:Qo}),J(e=>tg(e));let{routeToSelectedPipes:ts}=HM({store:be,setAppState:U,addNotification:Ze});process.env.USER_TYPE===`ant`&&ok({taskListId:w,isLoading:W,onSubmitTask:Qo}),zM?.({isLoading:W||ce!==null,queuedCommandsLength:le.length,hasActiveLocalJsxUI:dr,isInPlanMode:I.mode===`plan`,onQueueTick:e=>pn(e)}),BM?.({isLoading:W||ce!==null,wasAborted:ln,queuedCommandsLength:le.length,hasActiveLocalJsxUI:dr,isInPlanMode:I.mode===`plan`,isQueryActiveNow:_n.getSnapshot,onContinuationEnqueued:({turn:e,objective:t})=>{let n=`Goal auto-continue (${e}/1): continue advancing "${t}".`;K(e=>[...e,Pa({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){oh(null);return}if(!W){if(Ee!==null&&le.length===0&&!dr&&I.mode!==`plan`&&ce===null){oh({enabled:!0,phase:`standby`,next_tick_at:Ee,sleep_until:null});return}oh({enabled:!0,phase:null,next_tick_at:null,sleep_until:null})}},[ce,W,dr,Te,Ee,le.length,I.mode]),(0,Q.useEffect)(()=>{le.some(e=>e.priority===`now`)&&an.current?.abort(`interrupt`)},[le]);let ns=(0,Q.useRef)(Yo);ns.current=Yo;let is=(0,Q.useRef)(Ut);is.current=Ut,(0,Q.useEffect)(()=>(ns.current(),()=>{is.current.shutdown()}),[]);let{internal_eventEmitter:as}=ne(),[os,ls]=(0,Q.useState)(0);(0,Q.useEffect)(()=>{let e=()=>{process.stdout.write(`
|
|
140
|
+
Claude Code has been suspended. Run \`fg\` to bring Claude Code back.
|
|
141
|
+
Note: ctrl + z now suspends Claude Code, ctrl + _ undoes input.
|
|
142
|
+
`)},t=()=>{ls(e=>e+1)};return as?.on(`suspend`,e),as?.on(`resume`,t),()=>{as?.off(`suspend`,e),as?.off(`resume`,t)}},[as]);let ds=(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=jf(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?` '${Tp(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]),fs=(0,Q.useCallback)(()=>{Jr({messagesLength:G.length,streamingToolUsesLength:Xt.length})},[G.length,Xt.length]),ps=(0,Q.useCallback)(()=>{Jr(null)},[]),ms=oo()&&!N,_s=(0,Q.useRef)(null),[vs,ys]=(0,Q.useState)(!1),[bs,Ss]=(0,Q.useState)(``),[Cs,ws]=(0,Q.useState)(0),[Ts,Es]=(0,Q.useState)(0),Os=(0,Q.useCallback)((e,t)=>{ws(e),Es(t)},[]);oe((e,t,n)=>{if(t.ctrl||t.meta)return;if(e===`/`){_s.current?.setAnchor(),ys(!0),n.stopImmediatePropagation();return}let r=e[0];if((r===`n`||r===`N`)&&e===r.repeat(e.length)&&Cs>0){let t=r===`n`?_s.current?.nextMatch:_s.current?.prevMatch;if(t)for(let n=0;n<e.length;n++)t();n.stopImmediatePropagation()}},{isActive:Pe===`transcript`&&ms&&!vs&&!Be});let{setQuery:ks,scanElement:As,setPositions:js}=fe(),Ms=de().columns,Ps=Q.useRef(Ms);Q.useEffect(()=>{Ps.current!==Ms&&(Ps.current=Ms,(bs||vs)&&(ys(!1),Ss(``),ws(0),Es(0),_s.current?.disarmSearch(),ks(``)))},[Ms,bs,vs,ks]),oe((e,t,n)=>{if(!(t.ctrl||t.meta)){if(e===`q`){ps(),n.stopImmediatePropagation();return}if(e===`[`&&!Be)Ve(!0),Re(!0),n.stopImmediatePropagation();else if(e===`v`){if(n.stopImmediatePropagation(),Je.current)return;Je.current=!0;let e=Ge.current,t=t=>{e===Ge.current&&(clearTimeout(Ke.current),We(t))};t(`rendering ${Wr.length} messages…`),(async()=>{try{let e=Math.max(80,(process.stdout.columns??80)-6),n=(await Vv(Wr,Vt,e)).replace(/[ \t]+$/gm,``),r=xv(gv(),`cc-transcript-${Date.now()}.txt`);await jv(r,n);let i=Vg(r);t(i?`opening ${r}`:`wrote ${r} · no $VISUAL/$EDITOR set`)}catch(e){t(`render failed: ${e instanceof Error?e.message:String(e)}`)}Je.current=!1,e===Ge.current&&(Ke.current=setTimeout(e=>e(``),4e3,We))})()}}},{isActive:Pe===`transcript`&&ms&&!vs});let Fs=Pe===`transcript`&&ms;(0,Q.useEffect)(()=>{Fs||(Ss(``),ws(0),Es(0),ys(!1),Ge.current++,clearTimeout(Ke.current),Ve(!1),We(``))},[Fs]),(0,Q.useEffect)(()=>{ks(Fs?bs:``),Fs||js(null)},[Fs,bs,ks,js]);let Is={screen:Pe,setScreen:Fe,showAllInTranscript:Ie,setShowAllInTranscript:Re,messageCount:G.length,onEnterTranscript:fs,onExitTranscript:ps,virtualScrollActive:ms,searchBarOpen:vs},Rs=qr?Wr.slice(0,qr.messagesLength):Wr,Bs=qr?Xt.slice(0,qr.streamingToolUsesLength):Xt;AO({onOpenBackgroundTasks:dr?void 0:()=>ua(!0),onTogglePipeSelector:()=>{U(e=>{let t=e.pipeIpc??{};return{...e,pipeIpc:{...t,selectorOpen:!t.selectorOpen}}})}});let Vs=ge?B[ge]:void 0,Hs=Vs&&Yc(Vs)?Vs:void 0,Us=Oi||!W,Ws=Hs?.messages,qs=(0,Q.useMemo)(()=>{if(!Hs)return;let e=Ws??[];if(!Yc(Hs)||Hs.agentType!==`fork`||!Hs.prompt)return e;let t=Hs.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(nN))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=>!nN(e))}});if(i)return a;let o=n===-1?r+1:n+1,s=Pa({content:Hs.prompt,timestamp:new Date(Hs.startTime).toISOString()});return[...a.slice(0,o),s,...a.slice(o)]},[Hs,Ws]),Js=Hs?qs??[]:Us?G:Wr;if(Pe===`transcript`){let e=oo()&&!N&&!Be?mn:void 0,t=(0,$.jsx)(J_,{messages:Rs,tools:Vt,commands:Kt,verbose:!0,toolJSX:null,toolUseConfirmQueue:[],inProgressToolUseIDs:ci,isMessageSelectorVisible:!1,conversationId:Xi,screen:Pe,agentDefinitions:ae,streamingToolUses:Bs,showAllInTranscript:Ie,onOpenRateLimitOptions:Io,isLoading:W,hidePastThinking:!0,streamingThinking:Qt,scrollRef:e,jumpRef:_s,onSearchMatchesChange:Os,scanElement:As,setPositions:js,disableRenderCap:Be}),n=Hn&&(0,$.jsx)(b,{flexDirection:`column`,width:`100%`,children:Hn.jsx}),r=(0,$.jsxs)(Ii,{children:[(0,$.jsx)(eN,{isAnimating:fr,title:lr,disabled:M,noPrefix:!1}),(0,$.jsx)(TO,{...Is}),(0,$.jsx)(DO,{onSubmit:Oo,isActive:!Hn?.isLocalJSXCommand}),e?(0,$.jsx)(Xj,{scrollRef:mn,isActive:uo!==`ultraplan-choice`,isModal:!vs,onScroll:()=>_s.current?.disarmSearch()}):null,(0,$.jsx)(kO,{..._o}),e?(0,$.jsx)(K_,{scrollRef:mn,scrollable:(0,$.jsxs)($.Fragment,{children:[t,n,(0,$.jsx)($k,{})]}),bottom:vs?(0,$.jsx)(XM,{jumpRef:_s,initialQuery:``,count:Cs,current:Ts,onClose:e=>{Ss(Cs>0?e:``),ys(!1),e||(ws(0),Es(0),_s.current?.setSearchQuery(``))},onCancel:()=>{ys(!1),_s.current?.setSearchQuery(``),_s.current?.setSearchQuery(bs),ks(bs)},setHighlight:ks}):(0,$.jsx)(YM,{showAllInTranscript:Ie,virtualScroll:!0,status:He||void 0,searchBadge:bs&&Cs>0?{current:Ts,count:Cs}:void 0})}):(0,$.jsxs)($.Fragment,{children:[t,n,(0,$.jsx)($k,{}),(0,$.jsx)(YM,{showAllInTranscript:Ie,virtualScroll:!1,suppressShowAll:Be,status:He||void 0})]})]});return e?(0,$.jsx)(_e,{mouseTracking:Po(),children:r}):r}let Ys=Cn&&!Hs&&Js.length<=En.current?Cn:void 0,Zs=uo===`tool-permission`?(0,$.jsx)(jS,{onDone:()=>Jn(([e,...t])=>t),onReject:ho,toolUseConfirm:Kn[0],toolUseContext:xo(G,G,en??No(),Se),verbose:L,setStickyFooter:oo()?Xn:void 0},Kn[0]?.toolUseID):null,Qs=oo()&&Hn?.isLocalJSXCommand===!0,$s=Qs?Hn.jsx:null,ec=(0,$.jsxs)(Ii,{children:[(0,$.jsx)(eN,{isAnimating:fr,title:lr,disabled:M,noPrefix:!1}),(0,$.jsx)(TO,{...Is}),(0,$.jsx)(DO,{onSubmit:Oo,isActive:!Hn?.isLocalJSXCommand}),(0,$.jsx)(Xj,{scrollRef:mn,isActive:oo()&&($s!=null||!uo||uo===`tool-permission`),onScroll:Hr}),null,(0,$.jsx)(kO,{..._o}),(0,$.jsx)(ig,{dynamicMcpConfig:ke,isStrictMcpConfig:m,children:(0,$.jsx)(K_,{scrollRef:mn,overlay:Zs,modal:$s,modalScrollRef:hn,dividerYRef:Cr,hidePill:!!Hs,newMessageCount:Fr?.count??0,onPillClick:()=>{jr(null),Er(mn.current)},scrollable:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(J_,{messages:Js,tools:Vt,commands:Kt,verbose:L,toolJSX:Hn,toolUseConfirmQueue:Kn,inProgressToolUseIDs:ci,isMessageSelectorVisible:Ui,conversationId:Xi,screen:Pe,streamingToolUses:Xt,showAllInTranscript:Ie,agentDefinitions:ae,onOpenRateLimitOptions:Io,isLoading:W,streamingText:W&&!Hs?Ai:null,isBriefOnly:!Hs&&De,unseenDivider:Hs?void 0:Fr,scrollRef:oo()?mn:void 0,trackStickyPrompt:oo()?!0:void 0,cursor:Ar,setCursor:jr,cursorNavRef:Mr}),(0,$.jsx)(LA,{}),!x&&Ys&&!$s&&(0,$.jsx)(cr,{param:{text:Ys,type:`text`},addMargin:!0,verbose:L}),Hn&&!(Hn.isLocalJSXCommand&&Hn.isImmediate)&&!Qs&&(0,$.jsx)(b,{flexDirection:`column`,width:`100%`,children:Hn.jsx}),process.env.USER_TYPE===`ant`&&(0,$.jsx)(oj,{}),(0,$.jsx)(b,{flexGrow:1}),Na&&(0,$.jsx)(qi,{mode:qt,spinnerTip:ue,responseLengthRef:Si,apiMetricsRef:wi,overrideMessage:Ni,spinnerSuffix:ds,verbose:L,loadingStartTimeRef:On,totalPausedMsRef:kn,pauseStartTimeRef:An,overrideColor:Fi,overrideShimmerColor:Bi,hasActiveTools:ci.size>0,leaderIsIdle:!W}),!Na&&!W&&!Cn&&De&&!Hs&&(0,$.jsx)(hi,{})]}),bottom:(0,$.jsx)(b,{flexDirection:`row`,width:`100%`,alignItems:`flex-end`,children:(0,$.jsxs)(b,{flexDirection:`column`,flexGrow:1,children:[oo()&&(0,$.jsx)(pD,{}),Yn,Hn?.isLocalJSXCommand&&Hn.isImmediate&&!Qs&&(0,$.jsx)(b,{flexDirection:`column`,width:`100%`,children:Hn.jsx}),!Na&&!Hn?.isLocalJSXCommand&&pe&&zt&&zt.length>0&&(0,$.jsx)(b,{width:`100%`,flexDirection:`column`,children:(0,$.jsx)(Ro,{tasks:zt,isStandalone:!0})}),uo===`sandbox-permission`&&(0,$.jsx)(Zk,{hostPattern:Zn[0].hostPattern,onUserResponse:e=>{let{allow:t,persistToSettings:n}=e,r=Zn[0];if(!r)return;let i=r.hostPattern.host;Qn(e=>(e.filter(e=>e.hostPattern.host===i).forEach(e=>e.resolvePromise(t)),e.filter(e=>e.hostPattern.host!==i)));let a=tr.current.get(i);if(a){for(let e of a)e();tr.current.delete(i)}}},Zn[0].hostPattern.host),uo===`prompt`&&(0,$.jsx)(tC,{title:$n[0].title,toolInputSummary:$n[0].toolInputSummary,request:$n[0].request,onRespond:e=>{let t=$n[0];t&&(t.resolve({prompt_response:t.request.prompt,selected:e}),er(([,...e])=>e))},onAbort:()=>{let e=$n[0];e&&(e.reject(Error(`Prompt cancelled by user`)),er(([,...e])=>e))}},$n[0].request.prompt),uo===`elicitation`&&(0,$.jsx)(QS,{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)),uo===`cost`&&(0,$.jsx)(Hv,{onDone:()=>{Yi(!1),oa(!0),If(e=>({...e,hasAcknowledgedCostThreshold:!0})),Z(`tengu_cost_threshold_acknowledged`,{})}}),uo===`idle-return`&&$i&&(0,$.jsx)(Uv,{idleMinutes:$i.idleMinutes,totalInputTokens:ct(),onDone:async e=>{let t=$i;if(ea(null),Z(`tengu_idle_return_action`,{action:e,idleMinutes:Math.round(t.idleMinutes),messageCount:gr.current.length,totalInputTokens:ct()}),e===`dismiss`){ti(t.input);return}if(e===`never`&&If(e=>e.idleReturnDismissed?e:{...e,idleReturnDismissed:!0}),e===`clear`){let{clearConversation:e}=await import(`./conversation-CH9ouFai.js`);await e({setMessages:K,readFileState:Ga.current,discoveredSkillNames:Ja.current,loadedNestedMemoryPaths:Ya.current,getAppState:()=>be.getState(),setAppState:U,setConversationId:Qi}),or.current=!1,ar(void 0),Ka.current.clear(),qa.current=0}na.current=!0,Fo.current(t.input,{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}})}}),uo===`ide-onboarding`&&(0,$.jsx)(vr,{onDone:()=>Ct(!1),installationStatus:yt}),process.env.USER_TYPE===`ant`&&uo===`model-switch`&&UM&&(0,$.jsx)(UM,{onDone:(e,t)=>{Tt(!1),e===`switch`&&t&&U(e=>({...e,mainLoopModel:t,mainLoopModelForSession:null}))}}),process.env.USER_TYPE===`ant`&&uo===`undercover-callout`&&GM&&(0,$.jsx)(GM,{onDone:()=>Vn(!1)}),uo===`remote-callout`&&(0,$.jsx)(Zg,{onDone:e=>{U(t=>t.showRemoteCallout?{...t,showRemoteCallout:!1,...e===`enable`&&{replBridgeEnabled:!0,replBridgeExplicit:!0,replBridgeOutboundOnly:!1}}:t)}}),no,uo===`plugin-hint`&&Pt&&(0,$.jsx)(TA,{pluginName:Pt.pluginName,pluginDescription:Pt.pluginDescription,marketplaceName:Pt.marketplaceName,sourceCommand:Pt.sourceCommand,onResponse:Ft}),uo===`search-extra-tools-hint`&&It.visible&&(0,$.jsx)(DA,{tools:It.tools,onSelect:It.handleSelect,onDismiss:It.handleDismiss}),uo===`lsp-recommendation`&&At&&(0,$.jsx)(SA,{pluginName:At.pluginName,pluginDescription:At.pluginDescription,fileExtension:At.fileExtension,onResponse:Nt}),uo===`desktop-upsell`&&(0,$.jsx)(cv,{onDone:()=>kt(!1)}),uo===`ultraplan-choice`&&me&&(0,$.jsx)(bj,{plan:me.plan,sessionId:me.sessionId,taskId:me.taskId,setMessages:K,readFileState:Ga.current,getAppState:()=>be.getState(),setConversationId:Qi}),uo===`ultraplan-launch`&&he&&(0,$.jsx)(Cj,{onChoice:(e,t)=>{let n=he.blurb;if(U(e=>e.ultraplanLaunchPending?{...e,ultraplanLaunchPending:void 0}:e),e===`cancel`)return;K(e=>[...e,xc(wn(`ultraplan`,n))]);let r=e=>K(t=>[...t,xc(`<local-command-stdout>${Lt(e)}</local-command-stdout>`)]);fu({blurb:n,promptIdentifier:t?.promptIdentifier,getAppState:()=>be.getState(),setAppState:U,signal:No().signal,disconnectedBridge:t?.disconnectedBridge,onSessionReady:e=>{if(!_n.isActive){r(e);return}let t=_n.subscribe(()=>{_n.isActive||(t(),be.getState().ultraplanSessionUrl&&r(e))})}}).then(r).catch(X)}}),ja(),!Hn?.shouldHidePromptInput&&!uo&&!io&&!x&&!Ar&&(0,$.jsxs)($.Fragment,{children:[Qa&&(0,$.jsx)(nj,{onRun:ko,onCancel:Ao,reason:aj(Qa)}),Ba.state===`closed`?Va.state===`closed`?(0,$.jsx)(jk,{state:za.state,lastResponse:za.lastResponse,handleSelect:za.handleSelect,handleTranscriptSelect:za.handleTranscriptSelect,inputValue:Xr,setInputValue:ti,onRequestFeedback:to.current?void 0:jo}):(0,$.jsx)(jk,{state:Va.state,lastResponse:Va.lastResponse,handleSelect:Va.handleSelect,handleTranscriptSelect:Va.handleTranscriptSelect,inputValue:Xr,setInputValue:ti,onRequestFeedback:jo,message:`How well did Claude use its memory? (optional)`}):(0,$.jsx)(jk,{state:Ba.state,lastResponse:Ba.lastResponse,handleSelect:Ba.handleSelect,inputValue:Xr,setInputValue:ti,onRequestFeedback:jo}),Ha.state!==`closed`&&(0,$.jsx)(jk,{state:Ha.state,lastResponse:null,handleSelect:()=>{},handleTranscriptSelect:Ha.handleTranscriptSelect,inputValue:Xr,setInputValue:ti}),La.suggestion&&(0,$.jsx)(hO,{isOpen:La.isOpen,skillName:La.suggestion.skillName,updates:La.suggestion.updates,handleSelect:La.handleSelect,inputValue:Xr,setInputValue:ti}),Ra&&(0,$.jsx)(sj,{}),(0,$.jsx)(MD,{debug:n,ideSelection:at,hasSuppressedDialogs:!!fo,isLocalJSXCommandActive:dr,getToolUseContext:xo,toolPermissionContext:I,setToolPermissionContext:yo,apiKeyStatus:Xa,commands:Kt,agents:ae.activeAgents,isLoading:W,onExit:Lo,verbose:L,messages:G,onAutoUpdaterResult:zn,autoUpdaterResult:Rn,input:Xr,onInputChange:ti,mode:ni,onModeChange:ri,stashedPrompt:ai,setStashedPrompt:oi,submitCount:bi,onShowMessageSelector:zo,onMessageActionsEnter:void 0,mcpClients:et,pastedContents:vi,setPastedContents:yi,vimMode:sa,setVimMode:ca,showBashesDialog:la,setShowBashesDialog:ua,onSubmit:Oo,isSearchingHistory:da,setIsSearchingHistory:pa,helpOpen:ma,setHelpOpen:_a,insertTextRef:ei}),(0,$.jsx)(uk,{onBackgroundSession:Co,isLoading:W}),(0,$.jsx)(ik,{})]}),Ar&&(0,$.jsx)(wc,{cursor:Ar}),uo===`message-selector`&&(0,$.jsx)(gg,{messages:G,preselectedMessage:Gi,onPreRestore:mo,onRestoreCode:async e=>{await ad(e=>{U(t=>({...t,fileHistory:e(t.fileHistory)}))},e.uuid)},onSummarize:async(e,t,n=`from`)=>{let r=Mt(G),i=r.indexOf(e);if(i===-1){K(e=>[...e,Td(`That message is no longer in the active context (snipped or pre-compact). Choose a more recent message.`,`warning`)]);return}let a=No(),o=xo(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=Mo({mainThreadAgentDefinition:void 0,toolUseContext:o,customSystemPrompt:o.options.customSystemPrompt,defaultSystemPrompt:c,appendSystemPrompt:o.options.appendSystemPrompt}),[u,d]=await Promise.all([pi(),Vc()]),f=await rn(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(oo()&&n===`from`?K(t=>{let n=t.findIndex(t=>t.uuid===e.uuid);return[...t.slice(0,n===-1?0:n),...h]}):K(h),PM?.setContextBlocked(!1),Qi(Ov()),cs(o.options.querySource),n===`from`){let t=fa(e);t&&(ti(t.text),ri(t.mode))}let g=yn(`app:toggleTranscript`,`Global`,`ctrl+o`);Ze({key:`summarize-ctrl-o-hint`,text:`Conversation summarized (${g} for history)`,priority:`medium`,timeoutMs:8e3})},onRestoreMessage:Uo,onClose:()=>{Wi(!1),Ki(void 0)}}),process.env.USER_TYPE===`ant`&&(0,$.jsx)(gj,{})]})})})},os)]});return oo()?(0,$.jsx)(_e,{mouseTracking:Po(),children:ec}):ec}export{rN as t};
|