@readmagic/workmate 0.0.24 → 0.0.25
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-Y5S_lMjD.js +1 -0
- package/dist/chunks/AgentsMdExternalIncludesDialog-Bnb1jWcg.js +1 -0
- package/dist/chunks/AgentsMdExternalIncludesDialog-DVbU-BaD.js +1 -0
- package/dist/chunks/App-B8q8PV77.js +1 -0
- package/dist/chunks/BackgroundTasksDialog-i0TkZgQp.js +2 -0
- package/dist/chunks/BypassPermissionsModeDialog-DjqGAL4C.js +1 -0
- package/dist/chunks/CustomSelect-BvTftqEH.js +1 -0
- package/dist/chunks/DiffDialog-v5r8cBKW.js +6 -0
- package/dist/chunks/Doctor-DKpBnbuI.js +1 -0
- package/dist/chunks/Doctor-uvO6NM5m.js +3 -0
- package/dist/chunks/ExitFlow-Dh9QdaYK.js +2 -0
- package/dist/chunks/InvalidConfigDialog-C9boykQn.js +1 -0
- package/dist/chunks/{InvalidSettingsDialog-iwh8H52b.js → InvalidSettingsDialog-UN5mleCK.js} +1 -1
- package/dist/chunks/KeybindingProviderSetup-DsJqfEt-.js +1 -0
- package/dist/chunks/MCPConnectionManager-DkZVxLEj.js +1 -0
- package/dist/chunks/MCPToolListView-De1W4jpj.js +1 -0
- package/dist/chunks/McpParsingWarnings-zkM_lGd0.js +1 -0
- package/dist/chunks/MessageSelector-DW_itlX-.js +3 -0
- package/dist/chunks/Messages-BFsCpACq.js +10 -0
- package/dist/chunks/Onboarding-BT90cFkn.js +1 -0
- package/dist/chunks/PromptInputFooterSuggestions-CCTZYbWI.js +1 -0
- package/dist/chunks/PromptInputHelpMenu-Bm5KY0Ma.js +1 -0
- package/dist/chunks/{ProviderSetup-BCSPsvfv.js → ProviderSetup-yIj8YOKF.js} +1 -1
- package/dist/chunks/QueryEngine-egz5mbaW.js +1 -0
- package/dist/chunks/REPL-D27CE4WN.js +124 -0
- package/dist/chunks/REPL-e8wAT1wN.js +1 -0
- package/dist/chunks/ResumeConversation-CWA27Lke.js +1 -0
- package/dist/chunks/SearchExtraToolsTool-BRchtZ9Q.js +1 -0
- package/dist/chunks/{SelectMulti-BQRHed-d.js → SelectMulti-BW7Ffk1G.js} +1 -1
- package/dist/chunks/Settings-axHLvYIy.js +3 -0
- package/dist/chunks/Spinner-VjwI7m_g.js +1 -0
- package/dist/chunks/{SpinnerGlyph-CmkRUvHe.js → SpinnerGlyph-CqrOK3Mx.js} +1 -1
- package/dist/chunks/TextInput-Cev5Awdd.js +22 -0
- package/dist/chunks/ThemePicker-CtQYHmOr.js +1 -0
- package/dist/chunks/TrustDialog-8Sjmuu0e.js +1 -0
- package/dist/chunks/{ValidationErrorsList-DgNzJQUP.js → ValidationErrorsList-INwwoerV.js} +1 -1
- package/dist/chunks/_baseEach-DrPH_FGo.js +1 -0
- package/dist/chunks/add-dir-D3RMaYxy.js +1 -0
- package/dist/chunks/{agentDisplay-M4pfwbMC.js → agentDisplay-B3npXoCS.js} +1 -1
- package/dist/chunks/{agents-DddX7lLX.js → agents-2mPGmeq6.js} +1 -1
- package/dist/chunks/agents-DEnmg8Xo.js +101 -0
- package/dist/chunks/allErrors-C9kx6lnk.js +1 -0
- package/dist/chunks/analytics-COpjZpvd.js +1 -0
- package/dist/chunks/{appleTerminalBackup-BArZWB21.js → appleTerminalBackup-CT7g8yOs.js} +1 -1
- package/dist/chunks/backgroundHousekeeping-BkFxfjOf.js +1 -0
- package/dist/chunks/backgroundHousekeeping-CvWfd99M.js +1 -0
- package/dist/chunks/banner-DHpTmEO7.js +2 -0
- package/dist/chunks/branch-Be_yDFU8.js +2 -0
- package/dist/chunks/{break-cache-BMXqFTeS.js → break-cache-UUt6Dkf2.js} +2 -2
- package/dist/chunks/btw-DUml5L1w.js +1 -0
- package/dist/chunks/caches-DWjwe-DN.js +1 -0
- package/dist/chunks/caches-VLs1tQkZ.js +1 -0
- package/dist/chunks/{claudeDesktop-D8ml2767.js → claudeDesktop-mBGFDbI6.js} +1 -1
- package/dist/chunks/{clear-B8ZtFPOK.js → clear-CrGjNe6E.js} +1 -1
- package/dist/chunks/{client-CpTCeWba.js → client-BDuhbzLD.js} +1 -1
- package/dist/chunks/{client-4iqhC8xq.js → client-BYFVVMcf.js} +1 -1
- package/dist/chunks/client-CO_6v4yl.js +1 -0
- package/dist/chunks/client-DO-O441l.js +1 -0
- package/dist/chunks/commands-Cn1P7Tms.js +1 -0
- package/dist/chunks/compact-DGUhdXcc.js +2 -0
- package/dist/chunks/config-C7GTF4iI.js +1 -0
- package/dist/chunks/config-CWPHVTic.js +3 -0
- package/dist/chunks/config-Cox0TM2Z.js +1 -0
- package/dist/chunks/context-mV5zjqmc.js +1 -0
- package/dist/chunks/context-noninteractive--OuiZUzL.js +1 -0
- package/dist/chunks/{context-noninteractive-C7wrRZnM.js → context-noninteractive-DvfVvmSE.js} +2 -2
- package/dist/chunks/conversation--y8PD2Lk.js +1 -0
- package/dist/chunks/conversation-BIPJEOwO.js +1 -0
- package/dist/chunks/conversationRecovery-BBJzrA0g.js +1 -0
- package/dist/chunks/crossProjectResume-CwZb3cEU.js +40 -0
- package/dist/chunks/cwd-BZMp3CZ8.js +1 -0
- package/dist/chunks/cwd-BvNt_018.js +1 -0
- package/dist/chunks/debug-CRnGsZOV.js +39 -0
- package/dist/chunks/{detectRepository-CfX8Lc0A.js → detectRepository-CsJLbVEe.js} +1 -1
- package/dist/chunks/{diff-DdpHThJ7.js → diff-DUEoNCnJ.js} +1 -1
- package/dist/chunks/{directoryCompletion-D_Rtg-4j.js → directoryCompletion-Bgi8DBT5.js} +1 -1
- package/dist/chunks/doctor-4NiE46ZG.js +1 -0
- package/dist/chunks/entry-D1iD76SW.js +13 -0
- package/dist/chunks/{esm-CGx9qY3q.js → esm-DUH16IqH.js} +1 -1
- package/dist/chunks/execAsync-D6SA-YsV.js +1 -0
- package/dist/chunks/{execFileNoThrow-BTachNBI.js → execFileNoThrow-BgRsj_SW.js} +3 -3
- package/dist/chunks/exit-CrsQsjbx.js +1 -0
- package/dist/chunks/extraUsage-BtHE-SBX.js +1 -0
- package/dist/chunks/extractMemories-kogJzpit.js +1 -0
- package/dist/chunks/fast-CuNVwVTr.js +1 -0
- package/dist/chunks/fast-RlFnwGRV.js +1 -0
- package/dist/chunks/fetchModelList-Cjow_QGy.js +1 -0
- package/dist/chunks/fetchModelList-uiCPVqbJ.js +1 -0
- package/dist/chunks/fileSuggestions-C96V9-Ne.js +3 -0
- package/dist/chunks/firstPartyEventLogger-CN9UOmEC.js +1 -0
- package/dist/chunks/firstPartyEventLogger-RR5rvDtk.js +1 -0
- package/dist/chunks/{gemini-C_ApXgwc.js → gemini-4YGElN3H.js} +2 -2
- package/dist/chunks/generateSessionName-BHIKyXpz.js +1 -0
- package/dist/chunks/{genericProcessUtils-DwQFuna9.js → genericProcessUtils-BNlr-QxM.js} +1 -1
- package/dist/chunks/getMachineId-bsd-DTYGimUN.js +1 -0
- package/dist/chunks/getMachineId-darwin-DqIFUVvd.js +2 -0
- package/dist/chunks/getMachineId-linux-CnCTmdzd.js +1 -0
- package/dist/chunks/getMachineId-unsupported-Cx21ssu1.js +1 -0
- package/dist/chunks/getMachineId-win-vZhex7KX.js +1 -0
- package/dist/chunks/goal-ePK_jLo3.js +3 -0
- package/dist/chunks/grok-DnmklTrm.js +1 -0
- package/dist/chunks/help-B7xRle-V.js +1 -0
- package/dist/chunks/history-kOw3CcLT.js +1 -0
- package/dist/chunks/hooks-BDY1jMbS.js +1 -0
- package/dist/chunks/{hooks-DR3IYPJ3.js → hooks-BN5f58HY.js} +2 -2
- package/dist/chunks/install-DrMiHa2Q.js +1 -0
- package/dist/chunks/instrumentation-Oj5xagJG.js +21 -0
- package/dist/chunks/{job-YhJQWgE0.js → job-D9ypO0cd.js} +1 -1
- package/dist/chunks/keybindings-BRRN_eap.js +1 -0
- package/dist/chunks/launchLocalMemory-DliLezJw.js +3 -0
- package/dist/chunks/launchOnboarding-A-kk-7ID.js +8 -0
- package/dist/chunks/loadAgentsDir-CJAK4kif.js +1 -0
- package/dist/chunks/{loadAgentsDir-B0Anodo0.js → loadAgentsDir-DGozQu_6.js} +550 -550
- package/dist/chunks/{loadPluginHooks-BSwCtQ6T.js → loadPluginHooks-BiHPKDaY.js} +1 -1
- package/dist/chunks/{loader-CICGtLp2.js → loader-CtoR-vO-.js} +1 -1
- package/dist/chunks/{localSearch-BxLYi6w_.js → localSearch-BU02Qsv9.js} +1 -1
- package/dist/chunks/localSearch-DyaB2Rm-.js +1 -0
- package/dist/chunks/{log-D2TIwHBV.js → log-DoSpAwRP.js} +1 -1
- package/dist/chunks/logoUtils-DLd6JKqW.js +1 -0
- package/dist/chunks/{magicDocs-Bkz7ZcmL.js → magicDocs-Bj8LYrN2.js} +2 -2
- package/dist/chunks/main-B_09WbaG.js +345 -0
- package/dist/chunks/managedEnv-BJGfe3m7.js +1 -0
- package/dist/chunks/{managedEnv-OPlzUPbJ.js → managedEnv-CIWJsuty.js} +1 -1
- package/dist/chunks/mcp-1nBvcNxw.js +1 -0
- package/dist/chunks/mcp-7DXpXMdT.js +2 -0
- package/dist/chunks/mcp-kw99WVi2.js +6 -0
- package/dist/chunks/memory-CjWvzR_9.js +1 -0
- package/dist/chunks/mode-CBKawxnD.js +2 -0
- package/dist/chunks/model-DpZaKZMb.js +1 -0
- package/dist/chunks/model-DwbqvCY2.js +1 -0
- package/dist/chunks/modelOptions-CXBfKFXA.js +1 -0
- package/dist/chunks/nativeInstaller-SmPeEisk.js +1 -0
- package/dist/chunks/{notifications-Bc6k-Ozy.js → notifications-ql0eSo0Y.js} +1 -1
- package/dist/chunks/onChangeAppState-D85b33R5.js +1 -0
- package/dist/chunks/open-Cyrr4E5x.js +1 -0
- package/dist/chunks/openai-D_j7-KW6.js +2 -0
- package/dist/chunks/overlayContext-CLjlCFBl.js +1 -0
- package/dist/chunks/{panel-CVS4SK_E.js → panel-DMZkOEiU.js} +1 -1
- package/dist/chunks/parser-2usBI4G-.js +1 -0
- package/dist/chunks/{parser-Cg6hSCmn.js → parser-UqADrvxF.js} +1 -1
- package/dist/chunks/partition-CwxTlmMd.js +1 -0
- package/dist/chunks/{pasteStore-P0zP-ch0.js → pasteStore-ovtxMVR5.js} +1 -1
- package/dist/chunks/permissions-CgsvWOk_.js +3 -0
- package/dist/chunks/pidLock-B-SW3Nhx.js +3 -0
- package/dist/chunks/plan-BJrWtXEh.js +1 -0
- package/dist/chunks/platform-DsMIk3eq.js +2 -0
- package/dist/chunks/plugin-D97VJAxW.js +17 -0
- package/dist/chunks/{pluginAutoupdate-ennb9k8_.js → pluginAutoupdate-DQqYDPVg.js} +1 -1
- package/dist/chunks/{pluginBlocklist-9OrNEh--.js → pluginBlocklist-BAr9WTup.js} +1 -1
- package/dist/chunks/pluginCliCommands-CUGPc853.js +1 -0
- package/dist/chunks/{pluginFlagging-js_-WmYj.js → pluginFlagging-BO_3qjfs.js} +1 -1
- package/dist/chunks/pluginOperations-rTrzu6Vg.js +2 -0
- package/dist/chunks/pluginStartupCheck-BRHnXlym.js +1 -0
- package/dist/chunks/{pluginStartupCheck-SRXOyqr7.js → pluginStartupCheck-BX6cv-vs.js} +1 -1
- package/dist/chunks/plugins-9crasx2V.js +4 -0
- package/dist/chunks/poorMode-BaS0DBUO.js +1 -0
- package/dist/chunks/{poorMode-B0QGV6Ci.js → poorMode-DmvzFAz_.js} +1 -1
- package/dist/chunks/print-Bi3xVdB3.js +13 -0
- package/dist/chunks/processBashCommand-BBtnCx-7.js +1 -0
- package/dist/chunks/processSlashCommand-jzF0GmLO.js +5 -0
- package/dist/chunks/{projectOnboardingState-B5YATuc6.js → projectOnboardingState--L3BKjOE.js} +1 -1
- package/dist/chunks/prompt-CmijKW7G.js +1 -0
- package/dist/chunks/prompt-DYBx_D0H.js +1 -0
- package/dist/chunks/{prompt-CJ1l3XXk.js → prompt-DzO1um1h.js} +4 -4
- package/dist/chunks/{promptEditor-DoGHJN_W.js → promptEditor-B6S_Rzcu.js} +2 -2
- package/dist/chunks/protocolHandler-BWgH1jaF.js +13 -0
- package/dist/chunks/{proxy-CDBfZjO7.js → proxy-BjkGlmBu.js} +1 -1
- package/dist/chunks/reconciler-CVMmAaCy.js +1 -0
- package/dist/chunks/refresh-CAGv8BJY.js +1 -0
- package/dist/chunks/reject-CEUkoI2G.js +1 -0
- package/dist/chunks/{reload-plugins-CQZFQLWP.js → reload-plugins-DeyJTx4s.js} +1 -1
- package/dist/chunks/rename-DPFis9g_.js +1 -0
- package/dist/chunks/{renderOptions-DV0dn0IW.js → renderOptions-DRS2EslG.js} +1 -1
- package/dist/chunks/resume-N4O5YI-S.js +2 -0
- package/dist/chunks/ripgrep-3omwGI-l.js +1 -0
- package/dist/chunks/ripgrep-CgQrN3XX.js +5 -0
- package/dist/chunks/{runtimeObserver-DEuR8z0f.js → runtimeObserver-C0CJvA3q.js} +1 -1
- package/dist/chunks/{runtimeObserver-PJ1o8GRA.js → runtimeObserver-DMSzdFWt.js} +4 -4
- package/dist/chunks/sandbox-adapter-D15jjHJR.js +1 -0
- package/dist/chunks/sandbox-toggle-Tbbaw18C.js +1 -0
- package/dist/chunks/searchExtraTools-BoFc__Eg.js +1 -0
- package/dist/chunks/select-Fq6g2Ejk.js +1 -0
- package/dist/chunks/sessionFileAccessHooks-Rgsp4_Ex.js +1 -0
- package/dist/chunks/{sessionObserver-BtKjvteq.js → sessionObserver-CRie77tp.js} +2 -2
- package/dist/chunks/sessionObserver-PcaVCVkX.js +1 -0
- package/dist/chunks/sessionStorage-Dkf7FRgA.js +1 -0
- package/dist/chunks/sessionTracing-D7rekMdW.js +11 -0
- package/dist/chunks/settings-8fwIkMDV.js +1 -0
- package/dist/chunks/settings-CodSADx8.js +24 -0
- package/dist/chunks/setup-DBiIrXrh.js +3 -0
- package/dist/chunks/{shadowedRuleDetection-Bg_aIc5Z.js → shadowedRuleDetection-CTnYVrmP.js} +1 -1
- package/dist/chunks/{sideQuestion-D49GsfH7.js → sideQuestion-Cl8m2qYx.js} +3 -3
- package/dist/chunks/sinks-CiupmfTg.js +1 -0
- package/dist/chunks/sinks-DH83d_kd.js +1 -0
- package/dist/chunks/skillChangeDetector-BrrZaFkT.js +1 -0
- package/dist/chunks/{skillGapStore-CcFoHNLl.js → skillGapStore-es3K-aYe.js} +2 -2
- package/dist/chunks/{skillLifecycle-Bnz_4wE5.js → skillLifecycle-BcgoOQBk.js} +2 -2
- package/dist/chunks/{skillSearchPanel-C_5yUhqn.js → skillSearchPanel-CuDDb1L-.js} +4 -4
- package/dist/chunks/skills-BRtgqnLz.js +1 -0
- package/dist/chunks/{src-CiJCsqUl.js → src-C8gyNm5a.js} +1 -1
- package/dist/chunks/src-Db7K3F_i.js +3 -0
- package/dist/chunks/startupProfiler-D1NRu2nj.js +1 -0
- package/dist/chunks/startupProfiler-DF0AjiDf.js +3 -0
- package/dist/chunks/{state-B4jiUise.js → state-BQ4BEGin.js} +1 -1
- package/dist/chunks/state-D3gvDiu8.js +1 -0
- package/dist/chunks/status-WXA16wIM.js +1 -0
- package/dist/chunks/statusNoticeHelpers-BfmIub5L.js +1 -0
- package/dist/chunks/{stringUtils-C718f5ey.js → stringUtils-Bu_lJH5c.js} +1 -1
- package/dist/chunks/switcher-5gilU5_R.js +1 -0
- package/dist/chunks/{switcher-DZwUo5Ed.js → switcher-DMfuKuw_.js} +1 -1
- package/dist/chunks/{tasks-DdcUQEeD.js → tasks-B6gYXxOx.js} +1 -1
- package/dist/chunks/{templateJobs-C8qsPrLj.js → templateJobs-BW6TaqEC.js} +1 -1
- package/dist/chunks/{terminalSetup-B_10N_gE.js → terminalSetup-BgIXFBpd.js} +4 -4
- package/dist/chunks/{terminalSetup-qc2PlvOm.js → terminalSetup-C-g9Xvj3.js} +1 -1
- package/dist/chunks/{theme-f1h2QI8J.js → theme-9AZceq_m.js} +1 -1
- package/dist/chunks/tipRegistry-DtO1H_Wo.js +2 -0
- package/dist/chunks/{toolEventObserver-7QP38x4t.js → toolEventObserver-DTuJcREC.js} +1 -1
- package/dist/chunks/toolPool-DHS8jWaL.js +1 -0
- package/dist/chunks/{types-Dx7P7JLQ.js → types-97nL3naE.js} +16 -16
- package/dist/chunks/{udsClient-cQz6nJ_T.js → udsClient-CmYHFiBD.js} +1 -1
- package/dist/chunks/{use-select-navigation-hWL5VHnL.js → use-select-navigation-BStVRvcX.js} +1 -1
- package/dist/chunks/useExitOnCtrlCDWithKeybindings-DWRFdFoU.js +1 -0
- package/dist/chunks/useMainLoopModel-DSN5HjV1.js +1 -0
- package/dist/chunks/useManagePlugins-ntnOf5OU.js +1 -0
- package/dist/chunks/useMergedTools-C5Yns9Ij.js +1 -0
- package/dist/chunks/useSearchInput-B_mY9wBq.js +1 -0
- package/dist/chunks/useSettingsErrors-CM7tThcp.js +1 -0
- package/dist/chunks/util-Bb2S6g9N.js +1 -0
- package/dist/chunks/{validatePlugin-BMSoeb_b.js → validatePlugin-D8WQ5z4W.js} +1 -1
- package/dist/chunks/vim-Dpnhgoz_.js +1 -0
- package/dist/chunks/worktree-a5oOPSYl.js +1 -0
- package/dist/cli.js +1 -1
- package/package.json +1 -12
- package/dist/chunks/AddWorkspaceDirectory-Ch8IcWXO.js +0 -1
- package/dist/chunks/AgentsMdExternalIncludesDialog-Cyia0s4g.js +0 -1
- package/dist/chunks/AgentsMdExternalIncludesDialog-LjI_H_Au.js +0 -1
- package/dist/chunks/App-BOqh_1tN.js +0 -1
- package/dist/chunks/BackgroundTasksDialog-CSEuuoq9.js +0 -2
- package/dist/chunks/BypassPermissionsModeDialog-CwfCwUr9.js +0 -1
- package/dist/chunks/CustomSelect-wmZ9jz0W.js +0 -1
- package/dist/chunks/DiffDialog-BpXIEWiE.js +0 -6
- package/dist/chunks/Doctor-CMpr7tdf.js +0 -1
- package/dist/chunks/Doctor-DqW6j3_B.js +0 -3
- package/dist/chunks/ExitFlow-DacaBTlk.js +0 -2
- package/dist/chunks/Grove-CNqYPWI6.js +0 -11
- package/dist/chunks/InvalidConfigDialog-0TMJItCC.js +0 -1
- package/dist/chunks/KeybindingProviderSetup-D49HHTXD.js +0 -1
- package/dist/chunks/MCPConnectionManager-Cie77ZAK.js +0 -1
- package/dist/chunks/MCPToolListView-B4ehtkXd.js +0 -1
- package/dist/chunks/McpParsingWarnings-Bff66RtJ.js +0 -1
- package/dist/chunks/MessageSelector-Dpd6Iywp.js +0 -3
- package/dist/chunks/Messages-DN7M3oS_.js +0 -10
- package/dist/chunks/Onboarding-CQmE3rUf.js +0 -1
- package/dist/chunks/PromptInputFooterSuggestions-HI6HH3TP.js +0 -1
- package/dist/chunks/PromptInputHelpMenu-3QNUC2Cg.js +0 -1
- package/dist/chunks/QueryEngine-DdLWvJv6.js +0 -1
- package/dist/chunks/REPL-BqO9KcK_.js +0 -124
- package/dist/chunks/REPL-CmZmypfF.js +0 -1
- package/dist/chunks/ResumeConversation-DBqX7gva.js +0 -1
- package/dist/chunks/SearchExtraToolsTool-BsSoILFj.js +0 -1
- package/dist/chunks/Settings-B-7yBewS.js +0 -3
- package/dist/chunks/Spinner-ByQXTvAA.js +0 -1
- package/dist/chunks/TextInput-B8ruWRf2.js +0 -22
- package/dist/chunks/ThemePicker-BQErFFW1.js +0 -1
- package/dist/chunks/TrustDialog-BIhz6AZE.js +0 -1
- package/dist/chunks/_baseEach-CsIRoaTH.js +0 -1
- package/dist/chunks/add-dir-CrUDs19x.js +0 -1
- package/dist/chunks/agents-CGaCQeLw.js +0 -101
- package/dist/chunks/allErrors-BF73lon8.js +0 -1
- package/dist/chunks/analytics-DJobLaWP.js +0 -1
- package/dist/chunks/backgroundHousekeeping-Bq3LMsVR.js +0 -17
- package/dist/chunks/backgroundHousekeeping-Cl3Ox7Qh.js +0 -1
- package/dist/chunks/banner-Cu2-XUek.js +0 -2
- package/dist/chunks/branch-Yg_taNlT.js +0 -2
- package/dist/chunks/btw-udbprVvu.js +0 -1
- package/dist/chunks/caches-ChjIEcdd.js +0 -1
- package/dist/chunks/caches-DLJ6urv-.js +0 -1
- package/dist/chunks/client-BiqbIkwr.js +0 -1
- package/dist/chunks/client-CZ8nyVh5.js +0 -1
- package/dist/chunks/commands-CVCpJo7M.js +0 -1
- package/dist/chunks/compact-izk6RKHQ.js +0 -2
- package/dist/chunks/config-C-Y2qtB2.js +0 -3
- package/dist/chunks/config-CFqpXMFX.js +0 -1
- package/dist/chunks/config-DD8fCYXn.js +0 -1
- package/dist/chunks/context-BbVm4SWK.js +0 -1
- package/dist/chunks/context-noninteractive-x0HAzWhc.js +0 -1
- package/dist/chunks/conversation-DouVzO0K.js +0 -1
- package/dist/chunks/conversation-DrVkifKy.js +0 -1
- package/dist/chunks/conversationRecovery-DliPBo_z.js +0 -1
- package/dist/chunks/crossProjectResume-DxMy05_P.js +0 -40
- package/dist/chunks/cwd-Dc3NV7s8.js +0 -1
- package/dist/chunks/cwd-Pa83R95t.js +0 -1
- package/dist/chunks/datadog-Cu3s7P48.js +0 -1
- package/dist/chunks/debug-Bglx1aTu.js +0 -39
- package/dist/chunks/doctor-D_kV_D_l.js +0 -1
- package/dist/chunks/entry-Bxseqbi_.js +0 -13
- package/dist/chunks/esm-BXTZz3av.js +0 -1
- package/dist/chunks/execAsync-Bv2yxuGe.js +0 -1
- package/dist/chunks/exit-C_R_FgzR.js +0 -1
- package/dist/chunks/extraUsage-xMuDiNKh.js +0 -1
- package/dist/chunks/extractMemories-D4Dl1itt.js +0 -1
- package/dist/chunks/fast-DH-C5IZs.js +0 -1
- package/dist/chunks/fast-bopOPrtf.js +0 -1
- package/dist/chunks/fetchModelList-DC4VQpqa.js +0 -1
- package/dist/chunks/fetchModelList-FE8tzTDc.js +0 -1
- package/dist/chunks/fileSuggestions-C-9unnoJ.js +0 -3
- package/dist/chunks/firstPartyEventLogger-QmjjQmgt.js +0 -3
- package/dist/chunks/firstPartyEventLogger-lFeqhtfh.js +0 -1
- package/dist/chunks/generateSessionName-CQ03xlYI.js +0 -1
- package/dist/chunks/getMachineId-bsd-Cut1kHoA.js +0 -1
- package/dist/chunks/getMachineId-darwin-CsRhaP3y.js +0 -2
- package/dist/chunks/getMachineId-linux-Bd7UBNRQ.js +0 -1
- package/dist/chunks/getMachineId-unsupported-vFGP8E_8.js +0 -1
- package/dist/chunks/getMachineId-win-DamF2CH_.js +0 -1
- package/dist/chunks/goal-CdL29Y8C.js +0 -3
- package/dist/chunks/grok-C6WAslUT.js +0 -1
- package/dist/chunks/grove-O6qp7ITR.js +0 -1
- package/dist/chunks/help-DxanITNN.js +0 -1
- package/dist/chunks/history-BMycjPTT.js +0 -1
- package/dist/chunks/hooks-D9ApLkBp.js +0 -1
- package/dist/chunks/install-0D9u2dZw.js +0 -1
- package/dist/chunks/instrumentation-BFiGwntt.js +0 -21
- package/dist/chunks/keybindings-DZrF9iNd.js +0 -1
- package/dist/chunks/launchLocalMemory-DhJ56KDc.js +0 -3
- package/dist/chunks/launchOnboarding-DmMoZwv5.js +0 -8
- package/dist/chunks/loadAgentsDir-BbUR6pqH.js +0 -1
- package/dist/chunks/localSearch-zfn7jgrh.js +0 -1
- package/dist/chunks/logoUtils-CRxTutvr.js +0 -1
- package/dist/chunks/main-9ksgUUY_.js +0 -345
- package/dist/chunks/managedEnv-BEqrGqn1.js +0 -1
- package/dist/chunks/mcp-ChF12reQ.js +0 -1
- package/dist/chunks/mcp-DoEl5uah.js +0 -2
- package/dist/chunks/mcp-hp9qqjAy.js +0 -6
- package/dist/chunks/memory-Qv-wGNQ5.js +0 -1
- package/dist/chunks/mode-bFXPCR2P.js +0 -2
- package/dist/chunks/model-6lkW4o2c.js +0 -1
- package/dist/chunks/model-BvQFFOf8.js +0 -1
- package/dist/chunks/modelOptions-BBvF3wHK.js +0 -1
- package/dist/chunks/nativeInstaller-CdjmE9Zy.js +0 -1
- package/dist/chunks/onChangeAppState-DLjZ1x95.js +0 -1
- package/dist/chunks/open-BtQHzzL9.js +0 -1
- package/dist/chunks/openai-D46QvESE.js +0 -2
- package/dist/chunks/overlayContext-8--_fbvY.js +0 -1
- package/dist/chunks/parser-CG5RuOCK.js +0 -1
- package/dist/chunks/partition-DznN4XZH.js +0 -1
- package/dist/chunks/permissions-DmGFViHI.js +0 -3
- package/dist/chunks/pidLock-Cm4sW35f.js +0 -3
- package/dist/chunks/plan-CzGBz_87.js +0 -1
- package/dist/chunks/platform-BacQ6ACS.js +0 -2
- package/dist/chunks/plugin-CluR79xX.js +0 -17
- package/dist/chunks/pluginCliCommands-CJv5uhOG.js +0 -1
- package/dist/chunks/pluginOperations-CcUSHAIa.js +0 -2
- package/dist/chunks/pluginStartupCheck-CRBUO9gP.js +0 -1
- package/dist/chunks/plugins-IwwaCDba.js +0 -4
- package/dist/chunks/poorMode-G-pnu6NM.js +0 -1
- package/dist/chunks/print-CgszM1ea.js +0 -13
- package/dist/chunks/processBashCommand-D098WsqY.js +0 -1
- package/dist/chunks/processSlashCommand-DOQFjJ88.js +0 -5
- package/dist/chunks/prompt-BKPmDAuL.js +0 -1
- package/dist/chunks/prompt-CgOklk7z.js +0 -1
- package/dist/chunks/protocolHandler-DjQALaU2.js +0 -13
- package/dist/chunks/reconciler-ykkSPR-i.js +0 -1
- package/dist/chunks/refresh-Dn_I1R4v.js +0 -1
- package/dist/chunks/registerProtocol-CAsDme_E.js +0 -1
- package/dist/chunks/reject-DtcCfuZV.js +0 -1
- package/dist/chunks/rename-DyEfsZiq.js +0 -1
- package/dist/chunks/resume-BcXEDUqZ.js +0 -2
- package/dist/chunks/ripgrep-DLs8MraF.js +0 -1
- package/dist/chunks/ripgrep-Dl3y5r4m.js +0 -5
- package/dist/chunks/sandbox-adapter-DfB9kgQD.js +0 -1
- package/dist/chunks/sandbox-toggle-D9GDUsTl.js +0 -1
- package/dist/chunks/searchExtraTools-D4gMMQv0.js +0 -1
- package/dist/chunks/select-DIxfl_VN.js +0 -1
- package/dist/chunks/sessionFileAccessHooks-lbgHnVvi.js +0 -1
- package/dist/chunks/sessionObserver-D6qzEdGJ.js +0 -1
- package/dist/chunks/sessionStorage-C_7gow_z.js +0 -1
- package/dist/chunks/sessionTracing-CtbeAD0s.js +0 -11
- package/dist/chunks/settings-B2jvL8Dp.js +0 -24
- package/dist/chunks/settings-CisDe8DB.js +0 -1
- package/dist/chunks/setup-qecdf-ES.js +0 -3
- package/dist/chunks/sinks-C-lP7uyO.js +0 -1
- package/dist/chunks/sinks-De-B1lPQ.js +0 -1
- package/dist/chunks/skillChangeDetector-DkOJoNhT.js +0 -1
- package/dist/chunks/skills-BE5scC-g.js +0 -1
- package/dist/chunks/src-CHw1lvBc.js +0 -3
- package/dist/chunks/startupProfiler-BH0FoI66.js +0 -1
- package/dist/chunks/startupProfiler-CJdr3SxP.js +0 -3
- package/dist/chunks/state-BhOKSFi5.js +0 -1
- package/dist/chunks/status-Dw09WZLd.js +0 -1
- package/dist/chunks/statusNoticeHelpers-BRQpUIlH.js +0 -1
- package/dist/chunks/switcher-CgZVah7U.js +0 -1
- package/dist/chunks/tipRegistry-B71o4qWr.js +0 -2
- package/dist/chunks/toolPool-V-7Yv0GA.js +0 -1
- package/dist/chunks/useExitOnCtrlCDWithKeybindings-BKwzUpgb.js +0 -1
- package/dist/chunks/useMainLoopModel-DxvV70Ru.js +0 -1
- package/dist/chunks/useManagePlugins-BXLXazrR.js +0 -1
- package/dist/chunks/useMergedTools-CCgnBJzO.js +0 -1
- package/dist/chunks/useSearchInput-CzopttqC.js +0 -1
- package/dist/chunks/useSettingsErrors-SFPWfxsA.js +0 -1
- package/dist/chunks/util-Cbb3S6SX.js +0 -1
- package/dist/chunks/vim-CoRp9lY1.js +0 -1
- package/dist/chunks/worktree-Vm-SNY5x.js +0 -1
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import{a as e,n as t,o as n}from"./rolldown-runtime-DaDcL9Zw.js";import{c as r,i,l as a,o}from"./envUtils-DfkgIdYf.js";import{n as s,t as c}from"./defineProperty-C-QyHrDq.js";import{n as l,t as u}from"./figures-5ThXQEtq.js";import{C as d,D as f,Ft as p,Gr as m,Gt as h,H as g,I as _,Kr as v,Kt as y,Lt as b,P as x,Pn as S,Rn as C,T as w,Tt as T,Vn as E,Wt as D,Xn as O,Xt as k,Y as A,Yt as j,Z as M,Zn as N,_n as ee,ai as P,bn as F,ct as I,di as L,dr as te,et as ne,fi as R,hn as re,ir as z,j as ie,lr as B,lt as ae,ot as V,q as oe,qr as se,t as H,tr as ce,vn as le,x as U,y as ue,yn as W,yt as de}from"./src-DL3w8VPk.js";import{t as fe}from"./jsx-runtime-Bb4Xn-E0.js";import{B as pe,C as me,H as he,T as ge,U as _e,W as ve,X as ye,b as be,d as xe,g as Se,h as Ce,k as we,l as Te,o as Ee,s as De}from"./types-97nL3naE.js";import{Cn as Oe,Ft as ke,Gn as Ae,Gt as je,Hn as Me,I as Ne,Kn as Pe,Kt as Fe,Pt as Ie,Qt as Le,Tt as Re,Un as ze,Ut as Be,Vn as Ve,W as He,Wt as Ue,X as We,_n as Ge,_t as Ke,at as qe,bt as Je,ft as Ye,gt as Xe,in as Ze,jt as Qe,kt as $e,q as et,rt as tt,vt as nt,w as rt,wn as it,xt as at,y as ot,yt as st,z as ct}from"./state-BQ4BEGin.js";import{$a as lt,$c as ut,$f as dt,$g as ft,$h as pt,$l as mt,$p as ht,$s as gt,$w as _t,A as vt,AC as yt,A_ as bt,Aa as xt,Ab as St,Ac as Ct,Af as wt,Ag as Tt,Am as Et,Ap as Dt,As as Ot,Au as kt,B as At,BS as jt,B_ as Mt,Ba as Nt,Bb as Pt,Bh as Ft,Bm as It,Bn as Lt,Bp as G,Bt as Rt,Bx as zt,C as Bt,C_ as Vt,Cb as Ht,Cc as Ut,Cf as Wt,Cg as Gt,Ci as Kt,Cl as qt,Cm as Jt,Cp as Yt,Cs as Xt,Cu as Zt,Cw as Qt,DC as $t,Db as en,Dc as tn,Df as nn,Dg as rn,Di as an,Eb as on,Ec as sn,Ef as cn,Eg as ln,Ei as un,Em as dn,Ew as fn,F_ as pn,Fb as mn,Fc as hn,Fg as gn,Fh as _n,Fi as vn,Fm as yn,Fp as bn,Fx as xn,G_ as Sn,Gg as Cn,Gu as wn,H_ as Tn,Hb as En,Hg as Dn,Hh as On,Hm as kn,Hp as An,Hu as jn,I_ as Mn,Ic as Nn,Id as Pn,Ig as Fn,Ih as In,Ii as Ln,In as Rn,Ip as zn,Is as Bn,J as Vn,J_ as Hn,Jb as Un,Jd as Wn,Jf as Gn,Ji as Kn,Jo as qn,Jp as Jn,Js as Yn,Jw as Xn,K as Zn,K_ as Qn,Kb as $n,Kf as K,Kg as er,Kr as tr,Ku as nr,Lb as rr,Lc as ir,Ld as q,Lf as ar,Li as or,Lm as sr,Lp as cr,Lr as lr,Ls as ur,MS as dr,Mb as fr,Mc as pr,Md as mr,Mf as hr,Mg as gr,Mh as _r,Mi as vr,Ml as yr,Mm as br,Mp as xr,Ms as Sr,Mt as Cr,Mu as wr,Mw as Tr,NC as Er,NS as Dr,N_ as Or,Nc as kr,Nd as Ar,Ng as jr,Ni as Mr,Nl as Nr,Nn as Pr,Np as Fr,Nu as Ir,Nx as Lr,O as Rr,O_ as zr,Oa as Br,Ob as Vr,Oc as Hr,Of as Ur,On as Wr,Oo as Gr,Op as Kr,PC as qr,PS as Jr,P_ as Yr,Pa as Xr,Pb as Zr,Pc as Qr,Pg as $r,Ph as ei,Pm as ti,Pn as ni,Pp as ri,Pu as ii,Px as ai,Qc as oi,Qg as si,Ql as ci,Qm as li,Qo as ui,R_ as di,Ra as fi,Rb as pi,Rc as mi,Rf as hi,Rg as gi,Rm as _i,Rs as vi,Ru as yi,SS as bi,S_ as xi,Sb as Si,Sf as Ci,Sg as wi,Sl as Ti,Sm as Ei,Sp as Di,St as Oi,Su as ki,Sw as Ai,Tb as ji,Tg as Mi,Ti as Ni,Tl as Pi,Tm as Fi,Tw as Ii,U as Li,U_ as Ri,Ug as zi,Uh as Bi,Um as Vi,Uu as Hi,V as Ui,VS as Wi,V_ as Gi,Va as Ki,Vb as qi,Vm as Ji,Vp as Yi,Vt as Xi,Vu as Zi,Vx as Qi,W as $i,W_ as ea,Wg as ta,Wh as na,Wm as ra,Wn as ia,Wr as aa,Wu as oa,X as sa,X_ as ca,Xd as la,Xg as ua,Xp as da,Xr as fa,Xs as pa,Xt as ma,Xw as ha,Ya as ga,Yb as _a,Yd as va,Yf as ya,Yg as ba,Yi as xa,Yo as Sa,Yp as Ca,Yr as wa,Yw as Ta,Z as Ea,Zb as Da,Zd as Oa,Zg as ka,Zi as Aa,Zl as ja,Zm as Ma,Zn as Na,Zp as Pa,Zr as Fa,Zs as Ia,Zw as La,_c as Ra,_l as za,_o as Ba,_p as Va,_r as Ha,_s as Ua,_u as Wa,_w as Ga,aS as Ka,a_ as qa,ai as Ja,al as Ya,am as Xa,ao as Za,as as Qa,aw as $a,b as eo,b_ as to,bc as no,bg as ro,bo as io,bp as ao,bs as oo,bu as so,bw as co,cb as lo,cf as uo,cl as fo,cm as po,co as mo,cw as ho,cy as go,dS as _o,d_ as vo,dd as yo,dg as bo,dl as xo,do as So,dx as Co,eT as wo,e_ as To,ec as Eo,ei as Do,el as Oo,ep as ko,er as Ao,es as jo,eu as Mo,ew as No,f_ as Po,fd as Fo,fg as Io,fp as Lo,fr as Ro,fu as zo,fx as Bo,ga as Vo,gb as Ho,gf as Uo,gi as Wo,gl as Go,gp as Ko,gr as qo,gs as Jo,gu as Yo,gw as Xo,hd as Zo,hf as Qo,hi as $o,hl as es,hm as ts,ho as ns,hp as rs,hs as is,hu as as,hw as os,iS as ss,i_ as cs,im as ls,io as us,iw as ds,jS as fs,jb as ps,jc as ms,jf as hs,jg as gs,jh as _s,ji as vs,jm as ys,jn as bs,jp as xs,ju as Ss,k as Cs,kC as ws,kb as Ts,kf as Es,kg as Ds,ko as Os,kp as ks,ks as As,kw as js,lS as Ms,l_ as Ns,la as Ps,lb as Fs,ld as Is,lf as Ls,lg as Rs,ll as zs,lm as Bs,lo as Vs,lr as Hs,lw as Us,ly as Ws,mS as Gs,m_ as Ks,mb as qs,md as Js,mf as Ys,mm as Xs,mn as Zs,ms as Qs,mu as $s,n_ as ec,nc as tc,nd as nc,nh as rc,nm as ic,np as ac,nw as oc,oS as sc,o_ as cc,od as lc,of as uc,oi as dc,om as fc,on as pc,oo as mc,os as hc,ot as gc,ow as _c,pC as vc,pS as yc,pb as bc,pd as xc,pf as Sc,pm as Cc,pp as wc,ps as Tc,pu as Ec,q as Dc,q_ as Oc,qb as kc,qf as Ac,qg as jc,qo as Mc,qp as Nc,qs as Pc,qt as Fc,qw as Ic,rS as Lc,r_ as Rc,rm as zc,rp as Bc,rw as Vc,s_ as Hc,sb as Uc,sd as Wc,sf as Gc,sg as Kc,sl as qc,sm as Jc,so as Yc,st as Xc,sw as Zc,t_ as Qc,tc as $c,td as el,th as tl,tm as nl,tp as rl,ts as il,uS as al,u_ as ol,ub as sl,uf as cl,ul as ll,um as ul,uo as dl,uu as fl,uw as pl,vS as ml,vb as hl,vc as gl,vl as _l,vm as vl,vp as yl,vs as bl,vu as xl,vw as Sl,wb as Cl,wf as wl,wg as Tl,wl as El,wm as Dl,wp as Ol,ww as kl,xS as Al,x_ as jl,xg as Ml,xo as Nl,xp as Pl,xr as Fl,xs as Il,yS as Ll,yc as Rl,yg as zl,yl as Bl,ym as Vl,yp as Hl,yr as Ul,ys as Wl,yt as Gl,yu as Kl,yw as ql,z_ as Jl,zb as Yl,zc as Xl,zf as Zl,zp as J,zs as Ql,zu as $l,zx as eu}from"./loadAgentsDir-DGozQu_6.js";import{n as tu,t as nu}from"./cwd-BvNt_018.js";import{$ as ru,C as iu,E as au,H as ou,I as su,M as cu,R as lu,S as uu,V as du,Y as fu,c as Y,et as pu,f as mu,g as hu,i as gu,u as _u,x as vu}from"./debug-CRnGsZOV.js";import{Ar as yu,At as bu,Gt as xu,Hn as Su,Ir as Cu,It as wu,Jr as Tu,Ln as Eu,Lt as Du,Mr as Ou,Mt as ku,R as Au,Rn as ju,Rt as Mu,Un as Nu,V as Pu,Vn as Fu,Wt as Iu,Yr as Lu,_t as Ru,b as zu,d as Bu,er as Vu,h as Hu,jt as Uu,kr as Wu,ln as Gu,nr as Ku,on as qu,qt as Ju,s as Yu,st as Xu,tr as Zu,wn as Qu,xn as $u,zn as ed}from"./settings-CodSADx8.js";import{d as td,h as nd,o as rd,t as id}from"./config-CWPHVTic.js";import{i as ad,t as od}from"./execFileNoThrow-BgRsj_SW.js";import{B as sd,F as cd,H as ld,L as ud,R as dd,j as fd,o as pd,q as md,s as X}from"./log-DoSpAwRP.js";import{_ as hd,a as gd,d as _d,h as vd,l as yd,m as bd,o as xd,r as Sd,v as Cd}from"./stringUtils-Bu_lJH5c.js";import{i as wd,n as Td}from"./platform-DsMIk3eq.js";import{n as Ed}from"./analytics-COpjZpvd.js";import{n as Dd,o as Od,s as kd,t as Ad}from"./intl-D2kgJmX7.js";import{S as jd,_ as Md,d as Nd,g as Pd,l as Fd,u as Id}from"./startupProfiler-DF0AjiDf.js";import{$ as Ld,At as Rd,S as zd,at as Bd,b as Vd,et as Hd,f as Ud,g as Wd,h as Gd,jt as Kd,l as qd,s as Jd,u as Yd}from"./model-DpZaKZMb.js";import{Rt as Xd,St as Zd,fn as Qd,in as $d,ln as ef,pn as tf,rn as nf,tt as rf,un as af,xt as of,zt as sf}from"./prompt-DzO1um1h.js";import{i as cf,r as lf}from"./projectOnboardingState--L3BKjOE.js";import{a as uf}from"./ripgrep-CgQrN3XX.js";import{a as df}from"./loader-CtoR-vO-.js";import{n as ff,r as pf}from"./switcher-DMfuKuw_.js";import{B as mf,L as hf,c as gf,r as _f}from"./sessionTracing-D7rekMdW.js";import{i as vf,n as yf,r as bf}from"./parser-UqADrvxF.js";import{n as xf,t as Sf}from"./poorMode-DmvzFAz_.js";import{C as Cf,D as wf,E as Tf,O as Ef,S as Df,T as Of,a as kf,c as Af,d as jf,f as Mf,i as Nf,l as Pf,m as Ff,n as If,o as Lf,p as Rf,r as zf,s as Bf,t as Vf,w as Hf,x as Uf}from"./TextInput-Cev5Awdd.js";import{n as Wf,t as Gf}from"./notifications-ql0eSo0Y.js";import{i as Kf,n as qf}from"./terminalSetup-BgIXFBpd.js";import{a as Jf,c as Yf,i as Xf,l as Zf,n as Qf,o as $f,r as ep,s as tp,t as np,u as rp}from"./history-kOw3CcLT.js";import{t as ip}from"./useDoublePress-C9xxQzh1.js";import{i as ap,n as op,r as sp,t as cp}from"./overlayContext-CLjlCFBl.js";import{t as lp}from"./SelectMulti-BW7Ffk1G.js";import{t as up}from"./KeybindingProviderSetup-DsJqfEt-.js";import{t as dp}from"./useManagePlugins-ntnOf5OU.js";import{n as fp,t as pp}from"./MCPConnectionManager-DkZVxLEj.js";import{n as mp,t as hp}from"./toolPool-DHS8jWaL.js";import{t as gp}from"./conversationRecovery-BBJzrA0g.js";import{a as _p,i as vp,o as yp,r as bp,t as xp}from"./MessageSelector-DW_itlX-.js";import{n as Sp,t as Cp}from"./useExitOnCtrlCDWithKeybindings-DWRFdFoU.js";import{n as wp,t as Tp}from"./select-Fq6g2Ejk.js";import{a as Ep,c as Dp,d as Op,f as kp,i as Ap,l as jp,n as Mp,o as Np,r as Pp,s as Fp,u as Ip}from"./Spinner-VjwI7m_g.js";import{l as Lp,u as Rp}from"./SpinnerGlyph-CqrOK3Mx.js";import{n as zp,r as Bp}from"./sessionTitle-k4wpUS5l.js";import{n as Vp,t as Hp}from"./sideQuestion-Cl8m2qYx.js";import{a as Up,n as Wp,o as Gp,r as Kp,s as qp,t as Jp}from"./skillChangeDetector-BrrZaFkT.js";import{n as Yp,t as Xp}from"./reconciler-CVMmAaCy.js";import{n as Zp,t as Qp}from"./refresh-CAGv8BJY.js";import{i as $p,n as em,r as tm,t as nm}from"./directoryCompletion-Bgi8DBT5.js";import{r as rm,t as im}from"./PromptInputFooterSuggestions-CCTZYbWI.js";import{n as am,t as om}from"./useMergedTools-C5Yns9Ij.js";import{a as sm,i as cm,n as lm,o as um,r as dm,t as fm}from"./promptEditor-B6S_Rzcu.js";import{n as pm,t as mm}from"./useMainLoopModel-DSN5HjV1.js";import{a as hm,i as gm,o as _m,r as vm,s as ym,t as bm}from"./fileSuggestions-C96V9-Ne.js";import{E as xm,T as Sm,g as Cm,m as wm}from"./pidLock-B-SW3Nhx.js";import{n as Tm,t as Em}from"./nativeInstaller-SmPeEisk.js";import{t as Dm}from"./CustomSelect-BvTftqEH.js";import{i as Om,n as km,r as Am,t as jm}from"./extraUsage-BtHE-SBX.js";import{n as Mm,t as Nm}from"./useSearchInput-B_mY9wBq.js";import{n as Pm,t as Fm}from"./staticRender-BVWx0IM1.js";import{n as Im,t as Lm}from"./useSettingsErrors-CM7tThcp.js";import{n as Rm,t as zm}from"./shadowedRuleDetection-CTnYVrmP.js";import{n as Bm,t as Vm}from"./ExitFlow-Dh9QdaYK.js";import{a as Hm,i as Um,r as Wm,t as Gm}from"./fast-CuNVwVTr.js";import{i as Km,n as qm,r as Jm,t as Ym}from"./PermissionDialog-BaibiQae.js";import{a as Xm,i as Zm,n as Qm,r as $m,t as eh}from"./PromptInputHelpMenu-Bm5KY0Ma.js";import{n as th,r as nh}from"./pluginAutoupdate-DQqYDPVg.js";import{n as rh,t as ih}from"./generateSessionName-BHIKyXpz.js";import{a as ah,c as oh,i as sh,l as ch,n as lh,o as uh,r as dh,s as fh,t as ph}from"./Messages-BFsCpACq.js";import{a as mh,i as hh,n as gh,o as _h,r as vh,t as yh}from"./BackgroundTasksDialog-i0TkZgQp.js";import{n as bh}from"./fpsMetrics-wxj9GAsd.js";import{a as xh,i as Sh,n as Ch,r as wh,t as Th}from"./tipRegistry-DtO1H_Wo.js";import{t as Eh}from"./earlyInput-IghoCjG5.js";import{t as Dh}from"./backgroundHousekeeping-BkFxfjOf.js";import{homedir as Oh,tmpdir as kh}from"os";import*as Ah from"path";import{basename as jh,dirname as Mh,extname as Nh,join as Ph,relative as Fh,sep as Ih}from"path";import{dirname as Lh,join as Rh}from"node:path";import{createHash as zh}from"node:crypto";import{randomUUID as Bh}from"crypto";import{writeFile as Vh}from"fs/promises";import{spawn as Hh,spawnSync as Uh}from"child_process";import{mkdir as Wh,readFile as Gh,rename as Kh,writeFile as qh}from"node:fs/promises";function Jh(e){return Array.isArray?Array.isArray(e):ig(e)===`[object Array]`}function Yh(e){if(typeof e==`string`)return e;if(typeof e==`bigint`)return e.toString();let t=e+``;return t==`0`&&1/e==-1/0?`-0`:t}function Xh(e){return e==null?``:Yh(e)}function Zh(e){return typeof e==`string`}function Qh(e){return typeof e==`number`}function $h(e){return e===!0||e===!1||tg(e)&&ig(e)==`[object Boolean]`}function eg(e){return typeof e==`object`}function tg(e){return eg(e)&&e!==null}function ng(e){return e!=null}function rg(e){return!e.trim().length}function ig(e){return e==null?e===void 0?`[object Undefined]`:`[object Null]`:Object.prototype.toString.call(e)}function ag(e){let t=null,n=null,r=null,i=1,a=null;if(Zh(e)||Jh(e))r=e,t=og(e),n=sg(e);else{if(!Ug.call(e,`name`))throw Error(Bg(`name`));let o=e.name;if(r=o,Ug.call(e,`weight`)&&e.weight!==void 0&&(i=e.weight,i<=0))throw Error(Vg(sg(o)));t=og(o),n=sg(o),a=e.getFn??null}return{path:t,id:n,weight:i,src:r,getFn:a}}function og(e){return Jh(e)?e:e.split(`.`)}function sg(e){return Jh(e)?e.join(`.`):e}function cg(e,t){let n=[],r=!1,i=(e,t,a,o)=>{if(ng(e))if(!t[a])n.push(o===void 0?e:{v:e,i:o});else{let s=e[t[a]];if(!ng(s))return;if(a===t.length-1&&(Zh(s)||Qh(s)||$h(s)||typeof s==`bigint`))n.push(o===void 0?Xh(s):{v:Xh(s),i:o});else if(Jh(s)){r=!0;for(let e=0,n=s.length;e<n;e+=1)i(s[e],t,a+1,e)}else t.length&&i(s,t,a+1,o)}};return i(e,Zh(t)?t.split(`.`):t,0),r?n:n[0]}function lg(e=1,t=3){let n=new Map,r=10**t;return{get(t){let i=1,a=!1;for(let e=0;e<t.length;e++)t.charCodeAt(e)===32?a||(i++,a=!0):a=!1;if(n.has(i))return n.get(i);let o=Math.round(r/i**(.5*e))/r;return n.set(i,o),o},clear(){n.clear()}}}function ug(e,t,{getFn:n=Z.getFn,fieldNormWeight:r=Z.fieldNormWeight}={}){let i=new Yg({getFn:n,fieldNormWeight:r});return i.setKeys(e.map(ag)),i.setSources(t),i.create(),i}function dg(e,{getFn:t=Z.getFn,fieldNormWeight:n=Z.fieldNormWeight}={}){let{keys:r,records:i}=e,a=new Yg({getFn:t,fieldNormWeight:n});return a.setKeys(r),a.setIndexRecords(i),a}function fg(e=[],t=Z.minMatchCharLength){let n=[],r=-1,i=-1,a=0;for(let o=e.length;a<o;a+=1){let o=e[a];o&&r===-1?r=a:!o&&r!==-1&&(i=a-1,i-r+1>=t&&n.push([r,i]),r=-1)}return e[a-1]&&a-r>=t&&n.push([r,a-1]),n}function pg(e,t,n,{location:r=Z.location,distance:i=Z.distance,threshold:a=Z.threshold,findAllMatches:o=Z.findAllMatches,minMatchCharLength:s=Z.minMatchCharLength,includeMatches:c=Z.includeMatches,ignoreLocation:l=Z.ignoreLocation}={}){if(t.length>32)throw Error(zg(32));let u=t.length,d=e.length,f=Math.max(0,Math.min(r,d)),p=a,m=f,h=(e,t)=>{let n=e/u;if(l)return n;let r=Math.abs(f-t);return i?n+r/i:r?1:n},g=s>1||c,_=g?Array(d):[],v;for(;(v=e.indexOf(t,m))>-1;){let e=h(0,v);if(p=Math.min(e,p),m=v+u,g){let e=0;for(;e<u;)_[v+e]=1,e+=1}}m=-1;let y=[],b=1,x=0,S=u+d,C=1<<u-1;for(let t=0;t<u;t+=1){let r=0,i=S;for(;r<i;)h(t,f+i)<=p?r=i:S=i,i=Math.floor((S-r)/2+r);S=i;let a=Math.max(1,f-i+1),s=o?d:Math.min(f+i,d)+u,c=Array(s+2);c[s+1]=(1<<t)-1;for(let r=s;r>=a;--r){let i=r-1,o=n[e[i]];if(c[r]=(c[r+1]<<1|1)&o,t&&(c[r]|=(y[r+1]|y[r])<<1|1|y[r+1]),c[r]&C&&(b=h(t,i),b<=p)){if(p=b,m=i,x=t,m<=f)break;a=Math.max(1,2*f-m)}}if(h(t+1,f)>p)break;y=c}if(g&&m>=0){let t=Math.min(d-1,m+u-1+x);for(let r=m;r<=t;r+=1)n[e[r]]&&(_[r]=1)}let w={isMatch:m>=0,score:Math.max(.001,b)};if(g){let e=fg(_,s);e.length?c&&(w.indices=e):w.isMatch=!1}return w}function mg(e){let t={};for(let n=0,r=e.length;n<r;n+=1){let i=e.charAt(n);t[i]=(t[i]||0)|1<<r-n-1}return t}function hg(e){if(e.length<=1)return e;e.sort((e,t)=>e[0]-t[0]||e[1]-t[1]);let t=[e[0]];for(let n=1,r=e.length;n<r;n+=1){let r=t[t.length-1],i=e[n];i[0]<=r[1]+1?r[1]=Math.max(r[1],i[1]):t.push(i)}return t}function gg(e){return e.startsWith(`inverse`)}function _g(e){let t=[],n=e.length,r=0;for(;r<n;){for(;r<n&&e[r]===` `;)r++;if(r>=n)break;let i=r;for(;i<n&&e[i]!==` `&&e[i]!==`"`;)i++;if(i<n&&e[i]===`"`){for(i++;i<n;){if(e[i]===`"`){let t=i+1;if(t>=n||e[t]===` `){i++;break}if(e[t]===`$`&&(t+1>=n||e[t+1]===` `)){i+=2;break}}i++}t.push(e.substring(r,i)),r=i}else{for(;i<n&&e[i]!==` `;)i++;t.push(e.substring(r,i)),r=i}}return t}function vg(e,t){let n=e.match(t);return n?n[1]:null}function yg(e,t={}){return e.replace(/\\\|/g,r_).split(i_).map(e=>{let n=_g(e.replace(/\u0000/g,`|`).trim()).filter(e=>e&&!!e.trim()),r=[];for(let e=0,i=n.length;e<i;e+=1){let i=n[e],a=!1,o=-1;for(;!a&&++o<n_;){let e=t_[o],n=vg(i,e.multiRegex);n&&(r.push(e.create(n,t)),a=!0)}if(!a)for(o=-1;++o<n_;){let e=t_[o],n=vg(i,e.singleRegex);if(n){r.push(e.create(n,t));break}}}return r})}function bg(...e){o_.push(...e)}function xg(e,t){for(let n=0,r=o_.length;n<r;n+=1){let r=o_[n];if(r.condition(e,t))return new r(e,t)}return new $g(e,t)}function Sg(e,t,{auto:n=!0}={}){let r=e=>{if(Zh(e)){let r={keyId:null,pattern:e};return n&&(r.searcher=xg(e,t)),r}let i=Object.keys(e),a=u_(e);if(!a&&i.length>1&&!l_(e))return r(f_(e));if(d_(e)){let r=a?e[c_.PATH]:i[0],o=a?e[c_.PATTERN]:e[r];if(!Zh(o))throw Error(Rg(r));let s={keyId:sg(r),pattern:o};return n&&(s.searcher=xg(o,t)),s}let o={children:[],operator:i[0]};return i.forEach(t=>{let n=e[t];Jh(n)&&n.forEach(e=>{o.children.push(r(e))})}),o};return l_(e)||(e=f_(e)),r(e)}function Cg(e,{ignoreFieldNorm:t=Z.ignoreFieldNorm}){let n=1;return e.forEach(({key:e,norm:r,score:i})=>{let a=e?e.weight:null;n*=(i===0&&a?2**-52:i)**+((a||1)*(t?1:r))}),n}function wg(e,{ignoreFieldNorm:t=Z.ignoreFieldNorm}){e.forEach(e=>{e.score=Cg(e.matches,{ignoreFieldNorm:t})})}function Tg(e){let t=[];return e.matches.forEach(e=>{if(!ng(e.indices)||!e.indices.length)return;let n={indices:e.indices,value:e.value};e.key&&(n.key=e.key.id),e.idx>-1&&(n.refIndex=e.idx),t.push(n)}),t}function Eg(e,t,{includeMatches:n=Z.includeMatches,includeScore:r=Z.includeScore}={}){return e.map(e=>{let{idx:i}=e,a={item:t[i],refIndex:i};return n&&(a.matches=Tg(e)),r&&(a.score=e.score),a})}function Dg(e){h_.has(e)||(h_.add(e),console.warn(`[Fuse] tokenize regex ${e} lacks the global flag; only the first match per text will be returned. Add the 'g' flag.`))}function Og(e){if(typeof e==`function`){let t=!1;return n=>{let r=e(n);if(!t&&(t=!0,!Array.isArray(r)||r.some(e=>typeof e!=`string`)))throw Error(`[Fuse] tokenize function must return string[]; received ${Array.isArray(r)?`array containing non-strings`:typeof r}.`);return r}}return e instanceof RegExp?(e.global||Dg(e),t=>t.match(e)||[]):e=>e.match(m_)||[]}function kg({isCaseSensitive:e=!1,ignoreDiacritics:t=!1,tokenize:n}={}){let r=Og(n);return{tokenize(n){return e||(n=n.toLowerCase()),t&&(n=Qg(n)),r(n)}}}function Ag(e,t,n,r){let i=r.tokenize(t);if(!i.length)return;e.fieldCount++,e.docFieldCount.set(n,(e.docFieldCount.get(n)||0)+1);let a=new Set(i),o=e.docTermFieldHits.get(n);o||(o=new Map,e.docTermFieldHits.set(n,o));for(let t of a)o.set(t,(o.get(t)||0)+1),e.df.set(t,(e.df.get(t)||0)+1)}function jg(e,t,n,r){let{i,v:a,$:o}=t;if(a!==void 0){Ag(e,a,i,r);return}if(o)for(let t=0;t<n;t++){let n=o[t];if(n)if(Array.isArray(n))for(let t of n)Ag(e,t.v,i,r);else Ag(e,n.v,i,r)}}function Mg(e,t,n){let r={fieldCount:0,df:new Map,docFieldCount:new Map,docTermFieldHits:new Map};for(let i of e)jg(r,i,t,n);return r}function Ng(e,t,n,r){jg(e,t,n,r)}function Pg(e,t){let n=e.docFieldCount.get(t);if(n===void 0)return;e.fieldCount-=n,e.docFieldCount.delete(t);let r=e.docTermFieldHits.get(t);if(r){for(let[t,n]of r){let r=(e.df.get(t)||0)-n;r<=0?e.df.delete(t):e.df.set(t,r)}e.docTermFieldHits.delete(t)}}function Fg(e,t){if(t.length===0)return;let n=Array.from(new Set(t)).sort((e,t)=>e-t);for(let t of n)Pg(e,t);let r=e=>{let t=0,r=n.length;for(;t<r;){let i=t+r>>>1;n[i]<e?t=i+1:r=i}return e-t},i=n[0],a=new Map;for(let[t,n]of e.docFieldCount)a.set(t>i?r(t):t,n);e.docFieldCount=a;let o=new Map;for(let[t,n]of e.docTermFieldHits)o.set(t>i?r(t):t,n);e.docTermFieldHits=o}var Ig,Lg,Rg,zg,Bg,Vg,Hg,Ug,Wg,Gg,Kg,qg,Jg,Z,Yg,Xg,Zg,Qg,$g,e_,t_,n_,r_,i_,a_,o_,s_,c_,l_,u_,d_,f_,p_,m_,h_,g_,__,v_,y_=t((()=>{Ig=`Incorrect 'index' type`,Lg=`Invalid doc index: must be a non-negative integer within the bounds of the docs array`,Rg=e=>`Invalid value for key ${e}`,zg=e=>`Pattern length exceeds max of ${e}.`,Bg=e=>`Missing ${e} property in key`,Vg=e=>`Property 'weight' in key '${e}' must be a positive integer`,Hg=`Fuse.match does not support useTokenSearch: token search requires corpus-level statistics (df, fieldCount) that a one-off string comparison does not have. Use new Fuse(...).search(...) instead.`,Ug=Object.prototype.hasOwnProperty,Wg=class{constructor(e){this._keys=[],this._keyMap={};let t=0;e.forEach(e=>{let n=ag(e);this._keys.push(n),this._keyMap[n.id]=n,t+=n.weight}),this._keys.forEach(e=>{e.weight/=t})}get(e){return this._keyMap[e]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}},Gg={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},Kg={isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(e,t)=>e.score===t.score?e.idx<t.idx?-1:1:e.score<t.score?-1:1},qg={location:0,threshold:.6,distance:100},Jg={useExtendedSearch:!1,useTokenSearch:!1,tokenize:void 0,tokenMatch:`any`,getFn:cg,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1},Z=Object.freeze({...Kg,...Gg,...qg,...Jg}),Yg=class{constructor({getFn:e=Z.getFn,fieldNormWeight:t=Z.fieldNormWeight}={}){this.norm=lg(t,3),this.getFn=e,this.isCreated=!1,this.docs=[],this.keys=[],this._keysMap={},this.setIndexRecords()}setSources(e=[]){this.docs=e}setIndexRecords(e=[]){this.records=e}setKeys(e=[]){this.keys=e,this._keysMap={},e.forEach((e,t)=>{this._keysMap[e.id]=t})}create(){if(this.isCreated||!this.docs.length)return;this.isCreated=!0;let e=this.docs.length;this.records=Array(e);let t=0;if(Zh(this.docs[0]))for(let n=0;n<e;n++){let e=this._createStringRecord(this.docs[n],n);e&&(this.records[t++]=e)}else for(let n=0;n<e;n++)this.records[t++]=this._createObjectRecord(this.docs[n],n);this.records.length=t,this.norm.clear()}add(e,t){if(!Number.isInteger(t)||t<0)throw Error(Lg);if(Zh(e)){let n=this._createStringRecord(e,t);return n&&this.records.push(n),n}let n=this._createObjectRecord(e,t);return this.records.push(n),n}removeAt(e){if(!Number.isInteger(e)||e<0)throw Error(Lg);for(let t=0,n=this.records.length;t<n;t+=1)if(this.records[t].i===e){this.records.splice(t,1);break}for(let t=0,n=this.records.length;t<n;t+=1)this.records[t].i>e&&--this.records[t].i}removeAll(e){let t=new Set;for(let n of e)Number.isInteger(n)&&n>=0&&t.add(n);if(t.size===0)return;this.records=this.records.filter(e=>!t.has(e.i));let n=Array.from(t).sort((e,t)=>e-t);for(let e of this.records){let t=0,r=n.length;for(;t<r;){let i=t+r>>>1;n[i]<e.i?t=i+1:r=i}e.i-=t}}getValueForItemAtKeyId(e,t){return e[this._keysMap[t]]}size(){return this.records.length}_createStringRecord(e,t){return!ng(e)||rg(e)?null:{v:e,i:t,n:this.norm.get(e)}}_createObjectRecord(e,t){let n={i:t,$:{}};for(let t=0,r=this.keys.length;t<r;t++){let r=this.keys[t],i=r.getFn?r.getFn(e):this.getFn(e,r.path);if(ng(i)){if(Jh(i)){let e=[];for(let t=0,n=i.length;t<n;t+=1){let n=i[t];if(ng(n)){if(Zh(n)){if(!rg(n)){let r={v:n,i:t,n:this.norm.get(n)};e.push(r)}}else if(ng(n.v)){let t=Zh(n.v)?n.v:Xh(n.v);if(!rg(t)){let r={v:t,i:n.i,n:this.norm.get(t)};e.push(r)}}}}n.$[t]=e}else if(Zh(i)&&!rg(i)){let e={v:i,n:this.norm.get(i)};n.$[t]=e}}}return n}toJSON(){return{keys:this.keys.map(({getFn:e,...t})=>t),records:this.records}}},Xg={ł:`l`,Ł:`L`,đ:`d`,Đ:`D`,ø:`o`,Ø:`O`,ħ:`h`,Ħ:`H`,ŧ:`t`,Ŧ:`T`,ı:`i`,ß:`ss`},Zg=RegExp(`[`+Object.keys(Xg).join(``)+`]`,`g`),Qg=typeof String.prototype.normalize==`function`?e=>e.normalize(`NFD`).replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,``).replace(Zg,e=>Xg[e]):e=>e,$g=class{constructor(e,{location:t=Z.location,threshold:n=Z.threshold,distance:r=Z.distance,includeMatches:i=Z.includeMatches,findAllMatches:a=Z.findAllMatches,minMatchCharLength:o=Z.minMatchCharLength,isCaseSensitive:s=Z.isCaseSensitive,ignoreDiacritics:c=Z.ignoreDiacritics,ignoreLocation:l=Z.ignoreLocation}={}){if(this.options={location:t,threshold:n,distance:r,includeMatches:i,findAllMatches:a,minMatchCharLength:o,isCaseSensitive:s,ignoreDiacritics:c,ignoreLocation:l},e=s?e:e.toLowerCase(),e=c?Qg(e):e,this.pattern=e,this.chunks=[],!this.pattern.length)return;let u=(e,t)=>{this.chunks.push({pattern:e,alphabet:mg(e),startIndex:t})},d=this.pattern.length;if(d>32){let e=0,t=d%32,n=d-t;for(;e<n;)u(this.pattern.substr(e,32),e),e+=32;if(t){let e=d-32;u(this.pattern.substr(e),e)}}else u(this.pattern,0)}searchIn(e){let{isCaseSensitive:t,ignoreDiacritics:n,includeMatches:r}=this.options;if(e=t?e:e.toLowerCase(),e=n?Qg(e):e,this.pattern===e){let t={isMatch:!0,score:0};return r&&(t.indices=[[0,e.length-1]]),t}let{location:i,distance:a,threshold:o,findAllMatches:s,minMatchCharLength:c,ignoreLocation:l}=this.options,u=[],d=0,f=!1;this.chunks.forEach(({pattern:t,alphabet:n,startIndex:p})=>{let{isMatch:m,score:h,indices:g}=pg(e,t,n,{location:i+p,distance:a,threshold:o,findAllMatches:s,minMatchCharLength:c,includeMatches:r,ignoreLocation:l});m&&(f=!0),d+=h,m&&g&&u.push(...g)});let p={isMatch:f,score:f?d/this.chunks.length:1};return f&&r&&(p.indices=hg(u)),p}},e_=new Set([`fuzzy`,`include`]),t_=[{type:`exact`,multiRegex:/^="(.*)"$/,singleRegex:/^=(.*)$/,create:e=>({type:`exact`,search(t){let n=t===e;return{isMatch:n,score:+!n,indices:[0,e.length-1]}}})},{type:`include`,multiRegex:/^'"(.*)"$/,singleRegex:/^'(.*)$/,create:e=>({type:`include`,search(t){let n=0,r,i=[],a=e.length;for(;(r=t.indexOf(e,n))>-1;)n=r+a,i.push([r,n-1]);let o=!!i.length;return{isMatch:o,score:+!o,indices:i}}})},{type:`prefix-exact`,multiRegex:/^\^"(.*)"$/,singleRegex:/^\^(.*)$/,create:e=>({type:`prefix-exact`,search(t){let n=t.startsWith(e);return{isMatch:n,score:+!n,indices:[0,e.length-1]}}})},{type:`inverse-prefix-exact`,multiRegex:/^!\^"(.*)"$/,singleRegex:/^!\^(.*)$/,create:e=>({type:`inverse-prefix-exact`,search(t){let n=!t.startsWith(e);return{isMatch:n,score:+!n,indices:[0,t.length-1]}}})},{type:`inverse-suffix-exact`,multiRegex:/^!"(.*)"\$$/,singleRegex:/^!(.*)\$$/,create:e=>({type:`inverse-suffix-exact`,search(t){let n=!t.endsWith(e);return{isMatch:n,score:+!n,indices:[0,t.length-1]}}})},{type:`suffix-exact`,multiRegex:/^"(.*)"\$$/,singleRegex:/^(.*)\$$/,create:e=>({type:`suffix-exact`,search(t){let n=t.endsWith(e);return{isMatch:n,score:+!n,indices:[t.length-e.length,t.length-1]}}})},{type:`inverse-exact`,multiRegex:/^!"(.*)"$/,singleRegex:/^!(.*)$/,create:e=>({type:`inverse-exact`,search(t){let n=t.indexOf(e)===-1;return{isMatch:n,score:+!n,indices:[0,t.length-1]}}})},{type:`fuzzy`,multiRegex:/^"(.*)"$/,singleRegex:/^(.*)$/,create:(e,t={})=>{let n=new $g(e,{location:t.location??Z.location,threshold:t.threshold??Z.threshold,distance:t.distance??Z.distance,includeMatches:t.includeMatches??Z.includeMatches,findAllMatches:t.findAllMatches??Z.findAllMatches,minMatchCharLength:t.minMatchCharLength??Z.minMatchCharLength,isCaseSensitive:t.isCaseSensitive??Z.isCaseSensitive,ignoreDiacritics:t.ignoreDiacritics??Z.ignoreDiacritics,ignoreLocation:t.ignoreLocation??Z.ignoreLocation});return{type:`fuzzy`,search(e){return n.searchIn(e)}}}}],n_=t_.length,r_=`\0`,i_=`|`,a_=class{constructor(e,{isCaseSensitive:t=Z.isCaseSensitive,ignoreDiacritics:n=Z.ignoreDiacritics,includeMatches:r=Z.includeMatches,minMatchCharLength:i=Z.minMatchCharLength,ignoreLocation:a=Z.ignoreLocation,findAllMatches:o=Z.findAllMatches,location:s=Z.location,threshold:c=Z.threshold,distance:l=Z.distance}={}){this.query=null,this.options={isCaseSensitive:t,ignoreDiacritics:n,includeMatches:r,minMatchCharLength:i,findAllMatches:o,ignoreLocation:a,location:s,threshold:c,distance:l},e=t?e:e.toLowerCase(),e=n?Qg(e):e,this.pattern=e,this.query=yg(this.pattern,this.options)}static condition(e,t){return t.useExtendedSearch}searchIn(e){let t=this.query;if(!t)return{isMatch:!1,score:1};let{includeMatches:n,isCaseSensitive:r,ignoreDiacritics:i}=this.options;e=r?e:e.toLowerCase(),e=i?Qg(e):e;let a=0,o=[],s=0,c=!1;for(let r=0,i=t.length;r<i;r+=1){let i=t[r];o.length=0,a=0,c=!1;for(let t=0,r=i.length;t<r;t+=1){let r=i[t],{isMatch:l,indices:u,score:d}=r.search(e);if(l)a+=1,s+=d,gg(r.type)&&(c=!0),n&&(e_.has(r.type)?o.push(...u):o.push(u));else{s=0,a=0,o.length=0,c=!1;break}}if(a){let e={isMatch:!0,score:s/a};return c&&(e.hasInverse=!0),n&&(e.indices=hg(o)),e}}return{isMatch:!1,score:1}}},o_=[],s_={AND:`$and`,OR:`$or`},c_={PATH:`$path`,PATTERN:`$val`},l_=e=>!!(e[s_.AND]||e[s_.OR]),u_=e=>!!e[c_.PATH],d_=e=>!Jh(e)&&eg(e)&&!l_(e),f_=e=>({[s_.AND]:Object.keys(e).map(t=>({[t]:e[t]}))}),p_=class{constructor(e){this.limit=e,this.heap=[]}get size(){return this.heap.length}shouldInsert(e){return this.size<this.limit||e<this.heap[0].score}insert(e){this.size<this.limit?(this.heap.push(e),this._bubbleUp(this.size-1)):e.score<this.heap[0].score&&(this.heap[0]=e,this._sinkDown(0))}extractSorted(e){return this.heap.sort(e)}_bubbleUp(e){let t=this.heap;for(;e>0;){let n=e-1>>1;if(t[e].score<=t[n].score)break;let r=t[e];t[e]=t[n],t[n]=r,e=n}}_sinkDown(e){let t=this.heap,n=t.length,r=e;do{e=r;let i=2*e+1,a=2*e+2;if(i<n&&t[i].score>t[r].score&&(r=i),a<n&&t[a].score>t[r].score&&(r=a),r!==e){let n=t[e];t[e]=t[r],t[r]=n}}while(r!==e)}},m_=/[\p{L}\p{M}\p{N}_]+/gu,h_=new WeakSet,g_=class{static condition(e,t){return t.useTokenSearch}constructor(e,t){this.options=t,this.analyzer=kg({isCaseSensitive:t.isCaseSensitive,ignoreDiacritics:t.ignoreDiacritics,tokenize:t.tokenize});let n=this.analyzer.tokenize(e),{df:r,fieldCount:i}=t._invertedIndex;this.termSearchers=[],this.idfWeights=[];for(let e of n){this.termSearchers.push(new $g(e,{location:t.location,threshold:t.threshold,distance:t.distance,includeMatches:t.includeMatches,findAllMatches:t.findAllMatches,minMatchCharLength:t.minMatchCharLength,isCaseSensitive:t.isCaseSensitive,ignoreDiacritics:t.ignoreDiacritics,ignoreLocation:!0}));let n=r.get(e)||0,a=Math.log(1+(i-n+.5)/(n+.5));this.idfWeights.push(a)}this.combineAll=t.tokenMatch===`all`,this.numTerms=this.termSearchers.length,this.useMask=this.numTerms<=31}searchIn(e){if(!this.termSearchers.length)return{isMatch:!1,score:1};let t=[],n=0,r=0,i=0,a=0,o=this.combineAll&&!this.useMask?new Set:null;for(let s=0;s<this.termSearchers.length;s++){let c=this.termSearchers[s].searchIn(e),l=this.idfWeights[s];r+=l,c.isMatch&&(i++,n+=l*(1-c.score),c.indices&&t.push(...c.indices),this.combineAll&&(this.useMask?a|=1<<s:o.add(s)))}if(i===0)return{isMatch:!1,score:1};let s=r>0?1-n/r:0,c={isMatch:!0,score:Math.max(.001,s)};return this.options.includeMatches&&t.length&&(c.indices=hg(t)),this.combineAll&&(this.useMask?c.matchedMask=a:c.matchedTerms=o,c.termCount=this.numTerms),c}},__=class{constructor(e,t,n){this.options={...Z,...t},this.options.useExtendedSearch,this.options.useTokenSearch,this._keyStore=new Wg(this.options.keys),this._docs=e,this._myIndex=null,this._invertedIndex=null,this.setCollection(e,n),this._lastQuery=null,this._lastSearcher=null}_getSearcher(e){if(this._lastQuery===e)return this._lastSearcher;let t=xg(e,this._invertedIndex?{...this.options,_invertedIndex:this._invertedIndex}:this.options);return this._lastQuery=e,this._lastSearcher=t,t}setCollection(e,t){if(this._docs=e,t&&!(t instanceof Yg))throw Error(Ig);if(this._myIndex=t||ug(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight}),this.options.useTokenSearch){let e=kg({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});this._invertedIndex=Mg(this._myIndex.records,this._myIndex.keys.length,e)}this._invalidateSearcherCache()}add(e){if(!ng(e))return;this._docs.push(e);let t=this._myIndex.add(e,this._docs.length-1);if(this._invertedIndex&&t){let e=kg({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});Ng(this._invertedIndex,t,this._myIndex.keys.length,e)}this._invalidateSearcherCache()}remove(e=()=>!1){let t=[],n=[];for(let r=0,i=this._docs.length;r<i;r+=1)e(this._docs[r],r)&&(t.push(this._docs[r]),n.push(r));if(n.length){this._invertedIndex&&Fg(this._invertedIndex,n);let e=new Set(n);this._docs=this._docs.filter((t,n)=>!e.has(n)),this._myIndex.removeAll(n),this._invalidateSearcherCache()}return t}removeAt(e){if(!Number.isInteger(e)||e<0||e>=this._docs.length)throw Error(Lg);this._invertedIndex&&Fg(this._invertedIndex,[e]);let t=this._docs.splice(e,1)[0];return this._myIndex.removeAt(e),this._invalidateSearcherCache(),t}_invalidateSearcherCache(){this._lastQuery=null,this._lastSearcher=null}getIndex(){return this._myIndex}search(e,t){let{limit:n=-1}=t||{},{includeMatches:r,includeScore:i,shouldSort:a,sortFn:o,ignoreFieldNorm:s}=this.options;if(Zh(e)&&!e.trim()){let e=this._docs.map((e,t)=>({item:e,refIndex:t}));return Qh(n)&&n>-1&&(e=e.slice(0,n)),e}let c=Qh(n)&&n>0&&Zh(e),l;if(c){let t=new p_(n);Zh(this._docs[0])?this._searchStringList(e,{heap:t,ignoreFieldNorm:s}):this._searchObjectList(e,{heap:t,ignoreFieldNorm:s}),l=t.extractSorted(o)}else l=Zh(e)?Zh(this._docs[0])?this._searchStringList(e):this._searchObjectList(e):this._searchLogical(e),wg(l,{ignoreFieldNorm:s}),a&&l.sort(o),Qh(n)&&n>-1&&(l=l.slice(0,n));return Eg(l,this._docs,{includeMatches:r,includeScore:i})}_searchStringList(e,{heap:t,ignoreFieldNorm:n}={}){let r=this._getSearcher(e),i=this.options.useTokenSearch&&this.options.tokenMatch===`all`,{records:a}=this._myIndex,o=t?null:[];return a.forEach(({v:e,i:a,n:s})=>{if(!ng(e))return;let c=r.searchIn(e);if(c.isMatch){let r={score:c.score,value:e,norm:s,indices:c.indices};i&&(r.matchedMask=c.matchedMask,r.matchedTerms=c.matchedTerms,r.termCount=c.termCount);let l=[r];if(!i||this._coversAllTokens(l)){let r={item:e,idx:a,matches:l};t?(r.score=Cg(r.matches,{ignoreFieldNorm:n}),t.shouldInsert(r.score)&&t.insert(r)):o.push(r)}}}),o}_searchLogical(e){let t=Sg(e,this.options),n=(e,t,r)=>{if(!(`children`in e)){let{keyId:n,searcher:i}=e,a;return n===null?(a=[],this._myIndex.keys.forEach((e,n)=>{a.push(...this._findMatches({key:e,value:t[n],searcher:i}))})):a=this._findMatches({key:this._keyStore.get(n),value:this._myIndex.getValueForItemAtKeyId(t,n),searcher:i}),a&&a.length?[{idx:r,item:t,matches:a}]:[]}let{children:i,operator:a}=e,o=[];for(let e=0,s=i.length;e<s;e+=1){let s=i[e],c=n(s,t,r);if(c.length)o.push(...c);else if(a===s_.AND)return[]}return o},r=this._myIndex.records,i=new Map,a=[];return r.forEach(({$:e,i:r})=>{if(ng(e)){let o=n(t,e,r);o.length&&(i.has(r)||(i.set(r,{idx:r,item:e,matches:[]}),a.push(i.get(r))),o.forEach(({matches:e})=>{i.get(r).matches.push(...e)}))}}),a}_searchObjectList(e,{heap:t,ignoreFieldNorm:n}={}){let r=this._getSearcher(e),i=this.options.useTokenSearch&&this.options.tokenMatch===`all`,{keys:a,records:o}=this._myIndex,s=t?null:[];return o.forEach(({$:e,i:o})=>{if(!ng(e))return;let c=[],l=!1,u=!1;if(a.forEach((t,n)=>{let i=this._findMatches({key:t,value:e[n],searcher:r});i.length?(c.push(...i),i[0].hasInverse&&(u=!0)):l=!0}),!(u&&l)&&c.length&&(!i||this._coversAllTokens(c))){let r={idx:o,item:e,matches:c};t?(r.score=Cg(r.matches,{ignoreFieldNorm:n}),t.shouldInsert(r.score)&&t.insert(r)):s.push(r)}}),s}_findMatches({key:e,value:t,searcher:n}){if(!ng(t))return[];let r=[];if(Jh(t))t.forEach(({v:t,i,n:a})=>{if(!ng(t))return;let o=n.searchIn(t);if(o.isMatch){let n={score:o.score,key:e,value:t,idx:i,norm:a,indices:o.indices,hasInverse:o.hasInverse};o.termCount!==void 0&&(n.matchedMask=o.matchedMask,n.matchedTerms=o.matchedTerms,n.termCount=o.termCount),r.push(n)}});else{let{v:i,n:a}=t,o=n.searchIn(i);if(o.isMatch){let t={score:o.score,key:e,value:i,norm:a,indices:o.indices,hasInverse:o.hasInverse};o.termCount!==void 0&&(t.matchedMask=o.matchedMask,t.matchedTerms=o.matchedTerms,t.termCount=o.termCount),r.push(t)}}return r}_coversAllTokens(e){let t=e.length?e[0].termCount:void 0;if(t===void 0)return!0;if(t<=31){let n=0;for(let t=0;t<e.length;t++)n|=e[t].matchedMask||0;return n===2**t-1}let n=new Set;for(let t=0;t<e.length;t++){let r=e[t].matchedTerms;if(r)for(let e of r)n.add(e)}return n.size===t}},__.version=`7.4.2`,__.createIndex=ug,__.parseIndex=dg,__.config=Z,__.match=function(e,t,n){if(n&&n.useTokenSearch)throw Error(Hg);return xg(e,{...Z,...n}).searchIn(t)},__.parseQuery=Sg,bg(a_),bg(g_),__.use=function(...e){e.forEach(e=>bg(e))},v_=__}));s(),le(),l(),H(),Pe(),Ie(),Su(),Od(),Ts(),$c(),jf(),Nm();var Q=n(P(),1);v(),lh(),on(),js(),J(),Fm();var $=fe();function b_({children:e}){let{bindings:t}=Tr(),n=(0,Q.useRef)(null),r=(0,Q.useRef)(new Map),i=(0,Q.useRef)(new Set).current;return(0,$.jsx)(y,{bindings:t,pendingChordRef:n,pendingChord:null,setPendingChord:()=>{},activeContexts:i,registerActiveContext:()=>{},unregisterActiveContext:()=>{},handlerRegistryRef:r,children:e})}function x_(e){if(!(`message`in e))return 1;let t=e.message.content;return Array.isArray(t)?t.length:1}async function S_(e,t,n,{columns:r,verbose:i=!1,chunkSize:a=40,onProgress:o}={}){let s=n=>Pm((0,$.jsx)(cr,{children:(0,$.jsx)(b_,{children:(0,$.jsx)(ph,{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+=x_(t);for(let e=0;e<c;e+=a){let t=await s([e,e+a]);if(se(t).trim()===``)break;await n(t),o?.(e+a)}}async function C_(e,t=[],n){let r=[];return await S_(e,t,e=>void r.push(se(e)),{columns:n}),r.join(``)}o(),R(),be(),tu(),ru(),ou(),su(),vu(),mu(),gu(),Tu(),md(),pd(),ad(),Ce(),hd(),Cu(),wd(),Ku(),Ed(),ju(),Qu(),Te(),Md(),Gu(),Ee(),bd(),Ju(),Uu(),Ru(),Au(),xd(),Hu(),td(),tf(),Bd(),Ud(),$d(),_t(),Xo(),oc(),Er(),uf(),ws(),hf(),Qi(),ai(),Co(),_a(),$n(),En(),Yl(),mn(),ps(),St(),Cl(),Ht(),hl(),lo(),sf(),Ws(),Hn(),Jl(),bt(),Vt(),to(),Po(),Hc(),Rc(),ft(),Zd(),rf(),ka(),Cn(),zi(),Tt(),ro(),bo(),pt(),na(),Ft(),In(),tl(),Ma(),bf(),Vi(),sr(),br(),dn(),Dl(),vl(),ts(),po(),Xa(),Jn(),bn(),xs(),Dt(),Bc(),ko(),ya(),Ac(),hi(),hr(),wt(),cn(),Ci(),Qo(),Sc(),Ls(),xc(),yo(),wn(),Ir(),Ss(),Mo(),ci(),Pi(),qt(),_l(),Go(),Xl(),tn(),gf(),Ra(),pa(),Pc(),vi(),Ot(),Xt(),Wl(),Tc(),Qa(),il(),Gr(),Nl(),dl(),ga(),Nt(),Xr(),Br(),Kn(),or(),vr(),Wo(),qo(),bs(),Zs(),sa(),Dc(),Li(),Ui(),eo(),sm(),Dm();function w_({onDone:e}){return(0,$.jsxs)(ue,{title:`You've spent $5 on the API this session.`,onCancel:e,children:[(0,$.jsxs)(_,{flexDirection:`column`,children:[(0,$.jsx)(x,{children:`Learn more about how to monitor your spending:`}),(0,$.jsx)(b,{url:`https://code.workmate.com/docs/en/costs`})]}),(0,$.jsx)(Tp,{options:[{value:`ok`,label:`Got it, thanks!`}],onChange:e})]})}wp(),H(),Dm();function T_({idleMinutes:e,totalInputTokens:t,onDone:n}){return(0,$.jsxs)(ue,{title:`You've been away ${E_(e)} and this conversation is ${Pd(t)} tokens.`,onCancel:()=>n(`dismiss`),children:[(0,$.jsx)(_,{flexDirection:`column`,children:(0,$.jsx)(x,{children:`If this is a new task, clearing context will save usage and be faster.`})}),(0,$.jsx)(Tp,{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 E_(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`}Gf();async function D_(e,t){let n=rd().preferredNotifChannel;await Rt(e),await k_(n,e,t),Iu.terminal}var O_=`Work Mate`;async function k_(e,t,n){let r=t.title||O_;try{switch(e){case`auto`:return A_(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:j_()}),`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 A_(e,t){let n=e.title||O_;switch(Iu.terminal){case`Apple_Terminal`:return await M_()?(t.notifyBell(),`terminal_bell`):`no_method_available`;case`iTerm.app`:return t.notifyITerm2(e),`iterm2`;case`kitty`:return t.notifyKitty({...e,title:n,id:j_()}),`kitty`;case`ghostty`:return t.notifyGhostty({...e,title:n}),`ghostty`;default:return`no_method_available`}}function j_(){return Math.floor(Math.random()*1e4)}async function M_(){try{if(Iu.terminal!==`Apple_Terminal`)return!1;let e=(await od(`osascript`,[`-e`,`tell application "Terminal" to name of current settings of front window`])).stdout.trim();if(!e)return!1;let t=await od(`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 N_=300,P_=240*1e3,F_=null,I_=null,L_=0,R_=!1;function z_(){L_++,L_===1&&(W_(),H_())}function B_(){L_>0&&L_--,L_===0&&(U_(),G_())}function V_(){L_=0,U_(),G_()}function H_(){process.platform===`darwin`&&I_===null&&(I_=setInterval(()=>{L_>0&&(Y(`Restarting caffeinate to maintain sleep prevention`),G_(),W_())},P_),I_.unref())}function U_(){I_!==null&&(clearInterval(I_),I_=null)}function W_(){if(process.platform===`darwin`&&F_===null){R_||(R_=!0,pu(async()=>{V_()}));try{F_=Hh(`caffeinate`,[`-i`,`-t`,String(N_)],{stdio:`ignore`}),F_.unref();let e=F_;F_.on(`error`,t=>{Y(`caffeinate spawn error: ${t.message}`),F_===e&&(F_=null)}),F_.on(`exit`,()=>{F_===e&&(F_=null)}),Y(`Started caffeinate to prevent sleep`)}catch{F_=null}}}function G_(){if(F_!==null){let e=F_;F_=null;try{e.kill(`SIGKILL`),Y(`Stopped caffeinate, allowing sleep`)}catch{}}}var K_=class{constructor(){c(this,`_status`,`idle`),c(this,`_generation`,0),c(this,`_changed`,Ae()),c(this,`subscribe`,this._changed.subscribe),c(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 q_(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(aa(f,{},p,e).then(e=>{m===a.current&&e&&!l&&(r.current=e)}),l||c||u){let t=Lt(f,e).findLast(Ha);t&&(r.current=t.uuid)}n.current=e.length,i.current=o},[e,t])}Cp(),kp(),Ip(),Np(),Pp(),bp(),Ed();var J_=De(()=>ve({method:pe(`log_event`),params:ve({eventName:ye(),eventData:ve({}).passthrough()})}));function Y_(e){(0,Q.useEffect)(()=>{if(!e.length)return;let t=pn(e);t&&t.client.setNotificationHandler(J_(),e=>{let{eventName:t,eventData:n}=e.params;`${t}`})},[e])}H();var X_=6e3;function Z_(){return Date.now()-ct()}function Q_(e){return Z_()<e}function $_(e){return!Q_(e)}function ev(e,t){let n=S();(0,Q.useEffect)(()=>{ze(!0)},[]),(0,Q.useEffect)(()=>{let r=!1,i=setInterval(()=>{$_(6e3)&&!r&&(r=!0,clearInterval(i),D_({message:e,notificationType:t},n))},X_);return()=>clearInterval(i)},[e,t,n])}lf(),Vr(),sl(),yi(),Nn(),kr(),Ct(),Ef(),Of(),Cf(),Kf(),tp(),ip(),Bf(),Nf(),If(),dm(),Km(),H(),bc();var tv={topLeft:`┌`,topRight:`┐`,bottomLeft:`└`,bottomRight:`┘`,horizontal:`─`,vertical:`│`,teeLeft:`├`,teeRight:`┤`};function nv(e){return zn().syntaxHighlightingDisabled?(0,$.jsx)(iv,{...e,highlight:null}):(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(iv,{...e,highlight:null}),children:(0,$.jsx)(rv,{...e})})}function rv(e){let t=(0,Q.use)(Kr());return(0,$.jsx)(iv,{...e,highlight:t})}function iv({content:e,maxLines:t,minHeight:n,minWidth:r=40,maxWidth:i,highlight:a}){let{columns:o}=V(),[s]=g(),c=i??o-4,l=t??20,u=(0,Q.useMemo)(()=>Fo(e,s,a),[e,s,a]).split(`
|
|
2
|
+
`),d=u.length>l,f=d?u.slice(0,l):u,h=Math.max(0,Math.min(n??0,l)-f.length-+!!d),v=h>0?[...f,...Array(h).fill(``)]:f,y=Math.max(r,...v.map(e=>m(e))),b=Math.min(y+4,c),S=b-4,C=`${tv.topLeft}${tv.horizontal.repeat(b-2)}${tv.topRight}`,w=`${tv.bottomLeft}${tv.horizontal.repeat(b-2)}${tv.bottomRight}`,T=d?(()=>{let e=u.length-l,t=`${tv.horizontal.repeat(3)} \u2702 ${tv.horizontal.repeat(3)} ${e} lines hidden `,n=m(t),r=Math.max(0,b-2-n);return`${tv.teeLeft}${t}${tv.horizontal.repeat(r)}${tv.teeRight}`})():null;return(0,$.jsxs)(_,{flexDirection:`column`,children:[(0,$.jsx)(x,{dimColor:!0,children:C}),v.map((e,t)=>{let n=m(e)>S?qs(e,0,S):e,r=` `.repeat(Math.max(0,S-m(n)));return(0,$.jsxs)(_,{flexDirection:`row`,children:[(0,$.jsxs)(x,{dimColor:!0,children:[tv.vertical,` `]}),(0,$.jsx)(p,{children:n}),(0,$.jsxs)(x,{dimColor:!0,children:[r,` `,tv.vertical]})]},t)}),T&&(0,$.jsx)(x,{color:`warning`,children:T}),(0,$.jsx)(x,{dimColor:!0,children:w})]})}Ts(),H(),Md();function av({questions:e,currentQuestionIndex:t,answers:n,hideSubmitTab:r=!1}){let{columns:i}=V(),a=(0,Q.useMemo)(()=>{let n=r?``:` ${u.tick} Submit `,a=m(`← `)+m(` →`)+m(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+m(e)).reduce((e,t)=>e+t,0)<=o)return s;let c=4+m(s[t]||``),l=Math.min(c,o/2),d=o-l,f=e.length-1,p=Math.max(6,Math.floor(d/Math.max(f,1)));return s.map((e,n)=>n===t?jd(e,l-2-2):jd(e,p-2-2))},[e,t,i,r]),o=e.length===1&&r;return(0,$.jsxs)(_,{flexDirection:`row`,marginBottom:1,children:[!o&&(0,$.jsx)(x,{color:t===0?`inactive`:void 0,children:`← `}),e.map((e,r)=>{let i=r===t,o=e?.question&&n[e.question]?u.checkboxOn:u.checkboxOff,s=a[r]||e?.header||`Q${r+1}`;return(0,$.jsx)(_,{children:i?(0,$.jsxs)(x,{backgroundColor:`permission`,color:`inverseText`,children:[` `,o,` `,s,` `]}):(0,$.jsxs)(x,{children:[` `,o,` `,s,` `]})},e?.question||`question-${r}`)}),!r&&(0,$.jsx)(_,{children:t===e.length?(0,$.jsxs)(x,{backgroundColor:`permission`,color:`inverseText`,children:[` `,u.tick,` Submit`,` `]}):(0,$.jsxs)(x,{children:[` `,u.tick,` Submit `]})},`submit`),!o&&(0,$.jsx)(x,{color:t===e.length?`inactive`:void 0,children:` →`})]})}l(),Ts(),H(),J(),Jl();function ov({question:e,questions:t,currentQuestionIndex:n,answers:r,questionStates:i,hideSubmitTab:a=!1,minContentHeight:o,minContentWidth:s,onUpdateQuestionState:c,onAnswer:l,onTextInputFocus:f,onCancel:p,onTabPrev:m,onTabNext:g,onRespondToClaude:v,onFinishPlanInterview:y}){let b=G(e=>e.toolPermissionContext.mode)===`plan`,[S,C]=(0,Q.useState)(!1),[w,T]=(0,Q.useState)(0),[E,O]=(0,Q.useState)(!1),[k,A]=(0,Q.useState)(0),j=cm(),M=j?ea(j):null,N=e.question,ee=i[N],P=e.options,[F,I]=(0,Q.useState)(0),L=(0,Q.useRef)(N);if(L.current!==N){L.current=N;let e=ee?.selectedValue,t=e?P.findIndex(t=>t.label===e):-1;I(t>=0?t:0)}let te=P[F],ne=ee?.selectedValue,R=ee?.textInputValue||``,re=(0,Q.useCallback)(e=>{let t=P[e];t&&(I(e),c(N,{selectedValue:t.label},!1),l(N,t.label))},[P,N,c,l]),z=(0,Q.useCallback)(e=>{if(E)return;let t;t=typeof e==`number`?e:e===`up`?F>0?F-1:F:F<P.length-1?F+1:F,t>=0&&t<P.length&&I(t)},[F,P.length,E]);D(`chat:externalEditor`,async()=>{let e=ee?.textInputValue||``,t=await lm(e);t.content!==null&&t.content!==e&&c(N,{textInputValue:t.content},!1)},{context:`Chat`,isActive:E&&!!j}),h({"tabs:previous":()=>m?.(),"tabs:next":()=>g?.()},{context:`Tabs`,isActive:!E&&!S});let ie=(0,Q.useCallback)(()=>{O(!1),f(!1),ne&&l(N,ne)},[ne,N,l,f]),B=(0,Q.useCallback)(()=>{C(!0)},[]),ae=(0,Q.useCallback)(()=>{C(!1)},[]),oe=(0,Q.useCallback)(e=>{if(S){if(e.key===`up`||e.ctrl&&e.key===`p`){e.preventDefault(),w===0?ae():T(0);return}if(e.key===`down`||e.ctrl&&e.key===`n`){e.preventDefault(),b&&w===0&&T(1);return}if(e.key===`return`){e.preventDefault(),w===0?v():y();return}e.key===`escape`&&(e.preventDefault(),p());return}if(E){e.key===`escape`&&(e.preventDefault(),ie());return}if(e.key===`up`||e.ctrl&&e.key===`p`)e.preventDefault(),F>0&&z(`up`);else if(e.key===`down`||e.ctrl&&e.key===`n`)e.preventDefault(),F===P.length-1?B():z(`down`);else if(e.key===`return`)e.preventDefault(),re(F);else if(e.key===`n`&&!e.ctrl&&!e.meta)e.preventDefault(),O(!0),f(!0);else if(e.key===`escape`)e.preventDefault(),p();else if(e.key.length===1&&e.key>=`1`&&e.key<=`9`){e.preventDefault();let t=parseInt(e.key,10)-1;t<P.length&&z(t)}},[S,w,b,E,F,P.length,ae,B,z,re,ie,v,y,p,f]),se=te?.preview||null,{columns:H}=V(),ce=H-30-4,le=(0,Q.useMemo)(()=>o?Math.max(1,o-11):void 0,[o]);return(0,$.jsxs)(_,{flexDirection:`column`,marginTop:1,tabIndex:0,autoFocus:!0,onKeyDown:oe,children:[(0,$.jsx)(d,{color:`inactive`}),(0,$.jsxs)(_,{flexDirection:`column`,paddingTop:0,children:[(0,$.jsx)(av,{questions:t,currentQuestionIndex:n,answers:r,hideSubmitTab:a}),(0,$.jsx)(Jm,{title:e.question,color:`text`}),(0,$.jsxs)(_,{flexDirection:`column`,minHeight:o,children:[(0,$.jsxs)(_,{marginTop:1,flexDirection:`row`,gap:4,children:[(0,$.jsx)(_,{flexDirection:`column`,width:30,children:P.map((e,t)=>{let n=F===t,r=ne===e.label;return(0,$.jsxs)(_,{flexDirection:`row`,children:[n?(0,$.jsx)(x,{color:`suggestion`,children:u.pointer}):(0,$.jsx)(x,{children:` `}),(0,$.jsxs)(x,{dimColor:!0,children:[` `,t+1,`.`]}),(0,$.jsxs)(x,{color:r?`success`:n?`suggestion`:void 0,bold:n,children:[` `,e.label]}),r&&(0,$.jsxs)(x,{color:`success`,children:[` `,u.tick]})]},e.label)})}),(0,$.jsxs)(_,{flexDirection:`column`,flexGrow:1,children:[(0,$.jsx)(nv,{content:se||`No preview available`,maxLines:le,minWidth:s,maxWidth:ce}),(0,$.jsxs)(_,{marginTop:1,flexDirection:`row`,gap:1,children:[(0,$.jsx)(x,{color:`suggestion`,children:`Notes:`}),E?(0,$.jsx)(Vf,{value:R,placeholder:`Add notes on this design…`,onChange:e=>{c(N,{textInputValue:e},!1)},onSubmit:ie,onExit:ie,focus:!0,showCursor:!0,columns:60,cursorOffset:k,onChangeCursorOffset:A}):(0,$.jsx)(x,{dimColor:!0,italic:!0,children:R||`press n to add notes`})]})]})]}),(0,$.jsxs)(_,{flexDirection:`column`,marginTop:1,children:[(0,$.jsx)(d,{color:`inactive`}),(0,$.jsxs)(_,{flexDirection:`row`,gap:1,children:[S&&w===0?(0,$.jsx)(x,{color:`suggestion`,children:u.pointer}):(0,$.jsx)(x,{children:` `}),(0,$.jsx)(x,{color:S&&w===0?`suggestion`:void 0,children:`Chat about this`})]}),b&&(0,$.jsxs)(_,{flexDirection:`row`,gap:1,children:[S&&w===1?(0,$.jsx)(x,{color:`suggestion`,children:u.pointer}):(0,$.jsx)(x,{children:` `}),(0,$.jsx)(x,{color:S&&w===1?`suggestion`:void 0,children:`Skip interview and plan immediately`})]})]}),(0,$.jsx)(_,{marginTop:1,children:(0,$.jsxs)(x,{color:`inactive`,dimColor:!0,children:[`Enter to select · `,u.arrowUp,`/`,u.arrowDown,` to navigate · n to add notes`,t.length>1&&(0,$.jsx)($.Fragment,{children:` · Tab to switch questions`}),E&&M&&(0,$.jsxs)($.Fragment,{children:[` · ctrl+g to edit in `,M]}),` · Esc to cancel`]})})]})]})]})}l(),H(),J(),sm(),Jl(),dm(),Dm(),Km();function sv({question:e,questions:t,currentQuestionIndex:n,answers:r,questionStates:i,hideSubmitTab:a=!1,planFilePath:o,minContentHeight:s,minContentWidth:c,onUpdateQuestionState:l,onAnswer:f,onTextInputFocus:p,onCancel:m,onSubmit:h,onTabPrev:g,onTabNext:v,onRespondToClaude:y,onFinishPlanInterview:b,onImagePaste:S,pastedContents:C,onRemoveImage:w}){let T=G(e=>e.toolPermissionContext.mode)===`plan`,[E,D]=(0,Q.useState)(!1),[O,k]=(0,Q.useState)(0),[A,j]=(0,Q.useState)(!1),M=cm(),N=M?ea(M):null,ee=(0,Q.useCallback)(e=>{let t=e===`__other__`;j(t),p(t)},[p]),P=(0,Q.useCallback)(()=>{D(!0)},[]),F=(0,Q.useCallback)(()=>{D(!1)},[]),I=(0,Q.useCallback)(e=>{if(E){if(e.key===`up`||e.ctrl&&e.key===`p`){e.preventDefault(),O===0?F():k(0);return}if(e.key===`down`||e.ctrl&&e.key===`n`){e.preventDefault(),T&&O===0&&k(1);return}if(e.key===`return`){e.preventDefault(),O===0?y():b();return}e.key===`escape`&&(e.preventDefault(),m())}},[E,O,T,F,y,b,m]),L=e.options.map(e=>({type:`text`,value:e.label,label:e.label,description:e.description})),te=e.question,ne=i[te],R=(0,Q.useCallback)(async(t,n)=>{let r=await lm(t);r.content!==null&&r.content!==t&&(n(r.content),l(te,{textInputValue:r.content},e.multiSelect??!1))},[te,l,e.multiSelect]),re={type:`input`,value:`__other__`,label:`Other`,placeholder:e.multiSelect?`Type something`:`Type something.`,initialValue:ne?.textInputValue??``,onChange:t=>{l(te,{textInputValue:t},e.multiSelect??!1)}},z=[...L,re];return!e.multiSelect&&e.options.some(e=>e.preview)?(0,$.jsx)(ov,{question:e,questions:t,currentQuestionIndex:n,answers:r,questionStates:i,hideSubmitTab:a,minContentHeight:s,minContentWidth:c,onUpdateQuestionState:l,onAnswer:f,onTextInputFocus:p,onCancel:m,onTabPrev:g,onTabNext:v,onRespondToClaude:y,onFinishPlanInterview:b}):(0,$.jsxs)(_,{flexDirection:`column`,marginTop:0,tabIndex:0,autoFocus:!0,onKeyDown:I,children:[T&&o&&(0,$.jsxs)(_,{flexDirection:`column`,gap:0,children:[(0,$.jsx)(d,{color:`inactive`}),(0,$.jsxs)(x,{color:`inactive`,children:[`Planning: `,(0,$.jsx)(Fs,{filePath:o})]})]}),(0,$.jsx)(_,{marginTop:-1,children:(0,$.jsx)(d,{color:`inactive`})}),(0,$.jsxs)(_,{flexDirection:`column`,paddingTop:0,children:[(0,$.jsx)(av,{questions:t,currentQuestionIndex:n,answers:r,hideSubmitTab:a}),(0,$.jsx)(Jm,{title:e.question,color:`text`}),(0,$.jsxs)(_,{flexDirection:`column`,minHeight:s,children:[(0,$.jsx)(_,{marginTop:1,children:e.multiSelect?(0,$.jsx)(lp,{options:z,defaultValue:i[e.question]?.selectedValue,onChange:e=>{l(te,{selectedValue:e},!0);let t=e.includes(`__other__`)?i[te]?.textInputValue:void 0,n=e.filter(e=>e!==`__other__`).concat(t?[t]:[]);f(te,n,void 0,!1)},onFocus:ee,onCancel:m,submitButtonText:n===t.length-1?`Submit`:`Next`,onSubmit:h,onDownFromLastItem:P,isDisabled:E,onOpenEditor:R,onImagePaste:S,pastedContents:C,onRemoveImage:w},e.question):(0,$.jsx)(Tp,{options:z,defaultValue:i[e.question]?.selectedValue,onChange:e=>{l(te,{selectedValue:e},!1);let t=e===`__other__`?i[te]?.textInputValue:void 0;f(te,e,t)},onFocus:ee,onCancel:m,onDownFromLastItem:P,isDisabled:E,layout:`compact-vertical`,onOpenEditor:R,onImagePaste:S,pastedContents:C,onRemoveImage:w},e.question)}),(0,$.jsxs)(_,{flexDirection:`column`,children:[(0,$.jsx)(d,{color:`inactive`}),(0,$.jsxs)(_,{flexDirection:`row`,gap:1,children:[E&&O===0?(0,$.jsx)(x,{color:`suggestion`,children:u.pointer}):(0,$.jsx)(x,{children:` `}),(0,$.jsxs)(x,{color:E&&O===0?`suggestion`:void 0,children:[z.length+1,`. Chat about this`]})]}),T&&(0,$.jsxs)(_,{flexDirection:`row`,gap:1,children:[E&&O===1?(0,$.jsx)(x,{color:`suggestion`,children:u.pointer}):(0,$.jsx)(x,{children:` `}),(0,$.jsxs)(x,{color:E&&O===1?`suggestion`:void 0,children:[z.length+2,`. Skip interview and plan immediately`]})]})]}),(0,$.jsx)(_,{marginTop:1,children:(0,$.jsxs)(x,{color:`inactive`,dimColor:!0,children:[`Enter to select ·`,` `,t.length===1?(0,$.jsxs)($.Fragment,{children:[u.arrowUp,`/`,u.arrowDown,` to navigate`]}):`Tab/Arrow keys to navigate`,A&&N&&(0,$.jsxs)($.Fragment,{children:[` · ctrl+g to edit in `,N]}),` · Esc to cancel`]})})]})]})]})}H(),xl(),J();function cv(e,t){if(!e)return null;switch(e.type){case`rule`:return{reasonString:`Permission rule ${L.bold(Pu(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?` ${L.dim(`[${e.hookSource}]`)}`:``;return{reasonString:`Hook ${L.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 lv({permissionResult:e,toolType:t}){let n=G(e=>e.toolPermissionContext.mode),r=cv(e?.decisionReason,t);if(!r)return null;let i=r.themeColor??(e?.decisionReason?.type===`hook`&&n===`auto`?`warning`:void 0);return(0,$.jsxs)(_,{marginBottom:1,flexDirection:`column`,children:[i?(0,$.jsx)(x,{color:i,children:r.reasonString}):(0,$.jsx)(x,{children:(0,$.jsx)(p,{children:r.reasonString})}),r.configString&&(0,$.jsx)(x,{dimColor:!0,children:r.configString})]})}l(),H(),Dm(),Km();function uv({questions:e,currentQuestionIndex:t,answers:n,allQuestionsAnswered:r,permissionResult:i,minContentHeight:a,onFinalResponse:o}){return(0,$.jsxs)(_,{flexDirection:`column`,marginTop:1,children:[(0,$.jsx)(d,{color:`inactive`}),(0,$.jsxs)(_,{flexDirection:`column`,borderTop:!0,borderColor:`inactive`,paddingTop:0,children:[(0,$.jsx)(av,{questions:e,currentQuestionIndex:t,answers:n}),(0,$.jsx)(Jm,{title:`Review your answers`,color:`text`}),(0,$.jsxs)(_,{flexDirection:`column`,marginTop:1,minHeight:a,children:[!r&&(0,$.jsx)(_,{marginBottom:1,children:(0,$.jsxs)(x,{color:`warning`,children:[u.warning,` You have not answered all questions`]})}),Object.keys(n).length>0&&(0,$.jsx)(_,{flexDirection:`column`,marginBottom:1,children:e.filter(e=>e?.question&&n[e.question]).map(e=>{let t=n[e?.question];return(0,$.jsxs)(_,{flexDirection:`column`,marginLeft:1,children:[(0,$.jsxs)(x,{children:[u.bullet,` `,e?.question||`Question`]}),(0,$.jsx)(_,{marginLeft:2,children:(0,$.jsxs)(x,{color:`success`,children:[u.arrowRight,` `,t]})})]},e?.question||`answer`)})}),(0,$.jsx)(lv,{permissionResult:i,toolType:`tool`}),(0,$.jsx)(x,{color:`inactive`,children:`Ready to submit your answers?`}),(0,$.jsx)(_,{marginTop:1,children:(0,$.jsx)(Tp,{options:[{type:`text`,label:`Submit answers`,value:`submit`},{type:`text`,label:`Cancel`,value:`cancel`}],onChange:e=>o(e),onCancel:()=>o(`cancel`)})})]})]})]})}function dv(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 fv={currentQuestionIndex:0,answers:{},questionStates:{},isInTextInput:!1};function pv(){let[e,t]=(0,Q.useReducer)(dv,fv),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}}bn(),Ts(),H(),Ht(),Ed(),J(),Dt(),pd(),xc();var mv=12,hv=40,gv=15;function _v(e){return zn().syntaxHighlightingDisabled?(0,$.jsx)(yv,{...e,highlight:null}):(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(yv,{...e,highlight:null}),children:(0,$.jsx)(vv,{...e})})}function vv(e){let t=(0,Q.use)(Kr());return(0,$.jsx)(yv,{...e,highlight:t})}function yv({toolUseConfirm:e,onDone:t,onReject:n,highlight:r}){let i=(0,Q.useMemo)(()=>Ti.inputSchema.safeParse(e.input),[e.input]),a=i.success&&i.data.questions||[],{rows:o}=V(),[s]=g(),{globalContentHeight:c,globalContentWidth:l}=(0,Q.useMemo)(()=>{let e=0,t=0,n=Math.max(mv,o-gv);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=Fo(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,m(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,mv),n),globalContentWidth:Math.max(t,hv)}},[a,o,s,r]),u=i.success?i.data.metadata?.source:void 0,[d,f]=(0,Q.useState)({}),p=(0,Q.useRef)(0);function _(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};ii(s),$l(s),f(t=>({...t,[e]:{...t[e]??{},[o]:s}}))}let v=(0,Q.useCallback)((e,t)=>{f(n=>{let r={...n[e]??{}};return delete r[t],{...n,[e]:r}})},[]),y=Object.values(d).flatMap(e=>Object.values(e)).filter(e=>e.type===`image`),b=G(e=>e.toolPermissionContext.mode)===`plan`,x=b?ha():void 0,{currentQuestionIndex:S,answers:C,questionStates:w,isInTextInput:T,nextQuestion:E,prevQuestion:D,updateQuestionState:O,setAnswer:k,setTextInputMode:A}=pv(),j=S<(a?.length||0)?a?.[S]:null,M=S===(a?.length||0),N=a?.every(e=>e?.question&&!!C[e.question])??!1,ee=a.length===1&&!a[0]?.multiSelect,P=(0,Q.useCallback)(()=>{u&&(a.length,b&&Bl()),t(),n(),e.onReject()},[t,n,e,u,a.length,b]),F=(0,Q.useCallback)(async()=>{let n=`The user wants to clarify these questions.
|
|
4
|
+
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&&(a.length,b&&Bl());let r=await bv(y);t(),e.onReject(n,r&&r.length>0?r:void 0)},[a,C,t,e,u,b,y]),I=(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&&(a.length,b&&Bl());let r=await bv(y);t(),e.onReject(n,r&&r.length>0?r:void 0)},[a,C,t,e,u,b,y]),L=(0,Q.useCallback)(async n=>{u&&(a.length,Object.keys(n).length,b&&Bl());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 bv(y);t(),e.onAllow(i,[],void 0,o&&o.length>0?o:void 0)},[e,t,u,a,w,b,y]),te=(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};L(t).catch(X);return}k(e,i,r)},[k,a.length,C,L,d]);function ne(e){if(e===`cancel`){P();return}e===`submit`&&L(C).catch(X)}let R=ee?(a?.length||1)-1:a?.length||0,re=(0,Q.useCallback)(()=>{S>0&&D()},[S,D]),z=(0,Q.useCallback)(()=>{S<R&&E()},[S,R,E]);return h({"tabs:previous":re,"tabs:next":z},{context:`Tabs`,isActive:!(T&&!M)}),j?(0,$.jsx)(sv,{question:j,questions:a,currentQuestionIndex:S,answers:C,questionStates:w,hideSubmitTab:ee,minContentHeight:c,minContentWidth:l,planFilePath:x,onUpdateQuestionState:O,onAnswer:te,onTextInputFocus:A,onCancel:P,onSubmit:E,onTabPrev:re,onTabNext:z,onRespondToClaude:F,onFinishPlanInterview:I,onImagePaste:(e,t,n,r,i)=>_(j.question,e,t,n,r,i),pastedContents:d[j.question]??{},onRemoveImage:e=>v(j.question,e)}):M?(0,$.jsx)(uv,{questions:a,currentQuestionIndex:S,answers:C,allQuestionsAnswered:N,permissionResult:e.permissionResult,minContentHeight:c,onFinalResponse:ne}):null}async function bv(e){if(e.length!==0)return Promise.all(e.map(async e=>(await Bo({type:`image`,source:{type:`base64`,media_type:e.mediaType||`image/png`,data:e.content}})).block))}var xv=[`http://`,`https://`,`ftp://`],Sv={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},Cv=e=>Array.isArray(e)?e:[e];function wv(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 Tv(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(`-`)?!wv(t,n):!1}function Ev(e,t){for(let n=0;n<e.length;n++){let r=e[n];if(r){if(r.startsWith(`-`)){Tv(r,e[n+1],t)&&n++;continue}if(!t?.subcommands?.length||wv(r,t))return r}}}async function Dv(e,t,n){let r=await Ov(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&&Cv(e.args).some(e=>e?.isCommand||e?.isModule)){i.push(c);continue}}if(a&&!o){Tv(c,t[s+1],n)&&s++;continue}break}if(await kv(c,t.slice(0,s),n))break;a&&!o&&(o=wv(c,n)),i.push(c)}return i.join(` `)}async function Ov(e,t,n){let r=Ev(t,n),i=e.toLowerCase(),a=r?`${i} ${r.toLowerCase()}`:i;if(Sv[a])return Sv[a];if(Sv[i])return Sv[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&&Cv(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=Cv(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=Cv(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&&Cv(n.args).some(e=>e?.isDangerous)?3:2}async function kv(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=xv.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&&Cv(e.args).some(e=>e?.isModule))return!1}return!0}var Av=[{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 jv(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 Mv=Se(async e=>Av.find(t=>t.name===e)||await jv(e)||null,e=>e),Nv=/^\d+$/,Pv=/^[A-Za-z_][A-Za-z0-9_]*=/,Fv=new Set([`nice`]),Iv=e=>Array.isArray(e)?e:[e];function Lv(e,t){return t?.subcommands?.length?t.subcommands.some(t=>Array.isArray(t.name)?t.name.includes(e):t.name===e):!1}async function Rv(e,t=0,n=0){if(n>2||t>10)return null;let r=await vf(e);if(!r)return null;if(!r.commandNode)return{commandPrefix:null};let{envVars:i,commandNode:a}=r,[o,...s]=yf(a);if(!o)return{commandPrefix:null};let c=await Mv(o),l=Fv.has(o)||c?.args&&Iv(c.args).some(e=>e?.isCommand);l&&s[0]&&Lv(s[0],c)&&(l=!1);let u=l?await zv(o,s,t,n):await Dv(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 zv(e,t,n,r){let i=await Mv(e);if(i?.args){let a=Iv(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 Rv(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(`-`)&&!Pv.test(t[e])&&i.push(t[e])}}let a=t.find(e=>!e.startsWith(`-`)&&!Nv.test(e)&&!Pv.test(e));if(!a)return e;let o=await Rv(t.slice(t.indexOf(a)).join(` `),n+1,r+1);return o?.commandPrefix?`${e} ${o.commandPrefix}`:null}async function Bv(e,t){let n=Vn(e);if(n.length<=1){let t=await Rv(e);return t?.commandPrefix?[t.commandPrefix]:[]}let r=[];for(let e of n){let n=e.trim();if(t?.(n))continue;let i=await Rv(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(Vv(e));return a}function Vv(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(` `)}Ed();async function Hv(e){e.event,e.completion_type,await e.metadata.language_name,e.metadata.message_id,e.metadata.platform,{...e.metadata.hasFeedback!==void 0&&{hasFeedback:e.metadata.hasFeedback}}}Ed(),J(),Ju();function Uv(e,t){let n=An(),r=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{r.current!==e.toolUseID&&(r.current=e.toolUseID,n(e=>({...e,attribution:{...e.attribution,permissionPromptCount:e.attribution.permissionPromptCount+1}})),e.assistantMessage.message.id,mf(e.tool.name),e.tool.isMcp,e.permissionResult.decisionReason?.type,$t.isSandboxingEnabled(),Hv({completion_type:t.completion_type,event:`response`,metadata:{language_name:t.language_name,message_id:e.assistantMessage.message.id,platform:Iu.platform}}))},[e,t,n])}R(),l(),H(),J(),Au(),Rm(),ws();function Wv(e){switch(e.type){case`rule`:return`${L.bold(Pu(e.rule.ruleValue))} rule from ${qu(e.rule.source)}`;case`mode`:return`${Du(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`${L.bold(e.permissionPromptToolName)} permission prompt tool`;case`hook`:return e.reason?`${L.bold(e.hookName)} hook: ${e.reason}`:`${L.bold(e.hookName)} hook`;case`asyncAgent`:return e.reason;default:return``}}function Gv({title:e,decisionReason:t}){let[n]=g();function r(){switch(t.type){case`subcommandResults`:return(0,$.jsx)(_,{flexDirection:`column`,children:Array.from(t.reasons.entries()).map(([e,t])=>(0,$.jsxs)(_,{flexDirection:`column`,children:[(0,$.jsxs)(x,{children:[t.behavior===`allow`?ie(`success`,n)(u.tick):ie(`error`,n)(u.cross),` `,e]}),t.decisionReason!==void 0&&t.decisionReason.type!==`subcommandResults`&&(0,$.jsxs)(x,{children:[(0,$.jsxs)(x,{dimColor:!0,children:[` `,`⎿`,` `]}),(0,$.jsx)(p,{children:Wv(t.decisionReason)})]}),t.behavior===`ask`&&(0,$.jsx)(Kv,{suggestions:t.suggestions})]},e))});default:return(0,$.jsx)(x,{children:(0,$.jsx)(p,{children:Wv(t)})})}}return(0,$.jsxs)(_,{flexDirection:`column`,children:[e&&(0,$.jsx)(x,{children:e}),r()]})}function Kv({suggestions:e}){let t=ys(e);return t.length===0?null:(0,$.jsxs)(x,{children:[(0,$.jsxs)(x,{dimColor:!0,children:[` `,`⎿`,` `]}),`Suggested rules: `,(0,$.jsx)(p,{children:t.map(e=>L.bold(Pu(e))).join(`, `)})]})}function qv(e){return e?e.flatMap(e=>{switch(e.type){case`addDirectories`:return e.directories;default:return[]}}):[]}function Jv(e){if(!e)return;let t=e.findLast(e=>e.type===`setMode`);return t?.type===`setMode`?t.mode:void 0}function Yv({suggestions:e,width:t}){if(!e||e.length===0)return(0,$.jsxs)(_,{flexDirection:`row`,children:[(0,$.jsx)(_,{justifyContent:`flex-end`,minWidth:t,children:(0,$.jsx)(x,{dimColor:!0,children:`Suggestions `})}),(0,$.jsx)(x,{children:`None`})]});let n=ys(e),r=qv(e),i=Jv(e);return n.length===0&&r.length===0&&!i?(0,$.jsxs)(_,{flexDirection:`row`,children:[(0,$.jsx)(_,{justifyContent:`flex-end`,minWidth:t,children:(0,$.jsx)(x,{dimColor:!0,children:`Suggestion `})}),(0,$.jsx)(x,{children:`None`})]}):(0,$.jsxs)(_,{flexDirection:`column`,children:[(0,$.jsxs)(_,{flexDirection:`row`,children:[(0,$.jsx)(_,{justifyContent:`flex-end`,minWidth:t,children:(0,$.jsx)(x,{dimColor:!0,children:`Suggestions `})}),(0,$.jsx)(x,{children:` `})]}),n.length>0&&(0,$.jsxs)(_,{flexDirection:`row`,children:[(0,$.jsx)(_,{justifyContent:`flex-end`,minWidth:t,children:(0,$.jsx)(x,{dimColor:!0,children:` Rules `})}),(0,$.jsx)(_,{flexDirection:`column`,children:n.map((e,t)=>(0,$.jsxs)(x,{children:[u.bullet,` `,Pu(e)]},t))})]}),r.length>0&&(0,$.jsxs)(_,{flexDirection:`row`,children:[(0,$.jsx)(_,{justifyContent:`flex-end`,minWidth:t,children:(0,$.jsx)(x,{dimColor:!0,children:` Directories `})}),(0,$.jsx)(_,{flexDirection:`column`,children:r.map((e,t)=>(0,$.jsxs)(x,{children:[u.bullet,` `,e]},t))})]}),i&&(0,$.jsxs)(_,{flexDirection:`row`,children:[(0,$.jsx)(_,{justifyContent:`flex-end`,minWidth:t,children:(0,$.jsx)(x,{dimColor:!0,children:` Mode `})}),(0,$.jsx)(x,{children:Du(i)})]})]})}function Xv({permissionResult:e,toolName:t}){let n=G(e=>e.toolPermissionContext),r=e.decisionReason,i=`suggestions`in e?e.suggestions:void 0,a=(0,Q.useMemo)(()=>{let e=$t.isSandboxingEnabled()&&$t.isAutoAllowBashIfSandboxedEnabled(),r=zm(n,{sandboxAutoAllowEnabled:e}),a=ys(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)(_,{flexDirection:`column`,children:[(0,$.jsxs)(_,{flexDirection:`row`,children:[(0,$.jsx)(_,{justifyContent:`flex-end`,minWidth:10,children:(0,$.jsx)(x,{dimColor:!0,children:`Behavior `})}),(0,$.jsx)(x,{children:e.behavior})]}),e.behavior!==`allow`&&(0,$.jsxs)(_,{flexDirection:`row`,children:[(0,$.jsx)(_,{justifyContent:`flex-end`,minWidth:10,children:(0,$.jsx)(x,{dimColor:!0,children:`Message `})}),(0,$.jsx)(x,{children:e.message})]}),(0,$.jsxs)(_,{flexDirection:`row`,children:[(0,$.jsx)(_,{justifyContent:`flex-end`,minWidth:10,children:(0,$.jsx)(x,{dimColor:!0,children:`Reason `})}),r===void 0?(0,$.jsx)(x,{children:`undefined`}):(0,$.jsx)(Gv,{decisionReason:r})]}),(0,$.jsx)(Yv,{suggestions:i,width:10}),a.length>0&&(0,$.jsxs)(_,{flexDirection:`column`,marginTop:1,children:[(0,$.jsxs)(x,{color:`warning`,children:[u.warning,` Unreachable Rules (`,a.length,`)`]}),a.map((e,t)=>(0,$.jsxs)(_,{flexDirection:`column`,marginLeft:2,children:[(0,$.jsx)(x,{color:`warning`,children:Pu(e.rule.ruleValue)}),(0,$.jsxs)(x,{dimColor:!0,children:[` `,e.reason]}),(0,$.jsxs)(x,{dimColor:!0,children:[` `,`Fix: `,e.fix]})]},t))]})]})}qm(),be(),Ed(),hf(),td(),gu(),Ee(),pd(),Sf(),jt();var Zv={LOW:1,MEDIUM:2,HIGH:3},Qv=`Analyze shell commands and explain what they do, why you're running them, and potential risks.`,$v={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`]}},ey=De(()=>ve({riskLevel:we([`LOW`,`MEDIUM`,`HIGH`]),explanation:ye(),reasoning:ye(),risk:ye()}));function ty(e){if(typeof e==`string`)return e;try{return iu(e,null,2)}catch{return String(e)}}function ny(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(`
|
|
14
|
+
|
|
15
|
+
`)}function ry(){return rd().permissionExplainerEnabled!==!1}async function iy({toolName:e,toolInput:t,toolDescription:n,messages:r,signal:i}){if(!ry())return null;let a=Date.now();try{let o=ty(t),s=r?.length?ny(r):``,c=`Tool: ${e}
|
|
16
|
+
${n?`Description: ${n}\n`:``}
|
|
17
|
+
Input:
|
|
18
|
+
${o}
|
|
19
|
+
${s?`\nRecent conversation context:\n${s}`:``}
|
|
20
|
+
|
|
21
|
+
Explain this command in context.`,l=await Wi({model:xf()?Yd():Jd(),system:Qv,messages:[{role:`user`,content:c}],tools:[$v],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: ${iu(d.input).slice(0,500)}`);let t=ey().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 mf(e),Zv[n.riskLevel],Y(`Permission explainer: ${n.riskLevel} risk for ${e} (${u}ms)`),n}}return mf(e),Y(`Permission explainer: no parsed output in response`),null}catch(t){return Date.now()-a,i.aborted?(Y(`Permission explainer: request aborted for ${e}`),null):(Y(`Permission explainer error: ${cu(t)}`),X(t),mf(e),t instanceof Error&&t.name,null)}}H(),Ht(),Ed(),Lf(),Ap();var ay=`Loading explanation…`;function oy(){let[e,t]=Ep(`responding`,ay,!1);return(0,$.jsx)(_,{ref:e,children:(0,$.jsx)(x,{children:ay.split(``).map((e,n)=>(0,$.jsx)(kf,{char:e,index:n,glimmerIndex:t,messageColor:`inactive`,shimmerColor:`text`},n))})})}function sy(e){switch(e){case`LOW`:return`success`;case`MEDIUM`:return`warning`;case`HIGH`:return`error`}}function cy(e){switch(e){case`LOW`:return`Low risk`;case`MEDIUM`:return`Med risk`;case`HIGH`:return`High risk`}}function ly(e){return iy({toolName:e.toolName,toolInput:e.toolInput,toolDescription:e.toolDescription,messages:e.messages,signal:new AbortController().signal}).catch(()=>null)}function uy(e){let t=ry(),[n,r]=(0,Q.useState)(!1),[i,a]=(0,Q.useState)(null);return D(`confirm:toggleExplanation`,()=>{n||i||a(ly(e)),r(e=>!e)},{context:`Confirmation`,isActive:t}),{visible:n,enabled:t,promise:i}}function dy({promise:e}){let t=(0,Q.use)(e);return t?(0,$.jsxs)(_,{flexDirection:`column`,marginTop:1,children:[(0,$.jsx)(x,{children:t.explanation}),(0,$.jsx)(_,{marginTop:1,children:(0,$.jsx)(x,{children:t.reasoning})}),(0,$.jsx)(_,{marginTop:1,children:(0,$.jsxs)(x,{children:[(0,$.jsxs)(x,{color:sy(t.riskLevel),children:[cy(t.riskLevel),`:`]}),(0,$.jsxs)(x,{children:[` `,t.risk]})]})})]}):(0,$.jsx)(_,{marginTop:1,children:(0,$.jsx)(x,{dimColor:!0,children:`Explanation unavailable`})})}function fy({visible:e,promise:t}){return!e||!t?null:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(_,{marginTop:1,children:(0,$.jsx)(oy,{})}),children:(0,$.jsx)(dy,{promise:t})})}Ts(),H(),pd(),rs(),ao();function py(e){let[t]=(0,Q.useState)(()=>gy(e.file_path,e.edits));return(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(hy,{placeholder:!0}),children:(0,$.jsx)(my,{promise:t,file_path:e.file_path})})}function my({promise:e,file_path:t}){let{patch:n,firstLine:r,fileContent:i}=(0,Q.use)(e),{columns:a}=V();return(0,$.jsx)(hy,{children:(0,$.jsx)(Hl,{hunks:n,dim:!1,width:a,filePath:t,firstLine:r,fileContent:i})})}function hy({children:e,placeholder:t}){return(0,$.jsx)(_,{flexDirection:`column`,children:(0,$.jsx)(_,{borderColor:`subtle`,borderStyle:`dashed`,flexDirection:`column`,borderLeft:!1,borderRight:!1,children:t?(0,$.jsx)(x,{dimColor:!0,children:`…`}):e})})}async function gy(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 _y(e,[r]);try{let t=await Ko(e);if(t===null)return _y(e,n);try{if(!r||r.old_string===``){let r=await Va(t);return r===null?_y(e,n):{patch:qa({filePath:e,fileContents:r,edits:n.map(e=>vy(r,e))}),firstLine:gd(r),fileContent:r}}let i=await yl(t,r.old_string,3);if(i.truncated||i.content===``)return _y(e,[r]);let a=vy(i.content,r);return{patch:cs(qa({filePath:e,fileContents:i.content,edits:[a]}),i.lineOffset-1),firstLine:i.lineOffset===1?gd(i.content):null,fileContent:i.content}}finally{await t.close()}}catch(t){return X(t),_y(e,n)}}function _y(e,t){return{patch:t.flatMap(t=>qa({filePath:e,fileContents:t.old_string,edits:[t]})),firstLine:null,fileContent:void 0}}function vy(e,t){let n=To(e,t.old_string)||t.old_string;return{...t,old_string:n}}Di(),Ed(),Rc(),td(),Hc(),su(),Jl(),pd();function yy({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)(()=>Bh().slice(0,6),[]),l=(0,Q.useMemo)(()=>`✻ [Work Mate] ${jh(n)} (${c}) ⧉`,[n,c]),u=di(t.options.mcpClients)&&rd().diffTool===`auto`&&!n.endsWith(`.ipynb`),d=Mn(t.options.mcpClients)??`IDE`;async function f(){if(u)try{let{oldContent:o,newContent:s}=await xy(n,r,t,l);if(a.current)return;let c=by(n,o,s,i);if(c.length===0){let i=pn(t.options.mcpClients);i&&await Sy(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=pn(t.options.mcpClients);return e?Sy(l,e):Promise.resolve()},showingDiffInIDE:u&&!o,ideName:d,hasError:o}}function by(e,t,n,r){let i=r===`single`,a=cc({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.`)),Qc(a))}async function xy(e,t,n,r){let i=!1,a=Vu(e),o=``;try{o=ed(a)}catch(e){if(!lu(e))throw e}async function s(){if(!i){i=!0;try{await Sy(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=pn(n.options.mcpClients);try{let{updatedFile:e}=ec({filePath:a,fileContents:o,edits:t});if(c?.type!==`connected`)throw Error(`IDE client not available`);let n=a,i=c.config.ideRunningInWindows===!0;Td()===`wsl`&&i&&process.env.WSL_DISTRO_NAME&&(n=new Oc(process.env.WSL_DISTRO_NAME).toIDEPath(a));let l=await ca(`openDiff`,{old_file_path:n,new_file_path:n,new_file_contents:e,tab_name:r},c),u=Array.isArray(l)?l:[l];if(Ty(u))return s(),{oldContent:o,newContent:u[1].text};if(Cy(u))return s(),{oldContent:o,newContent:e};if(wy(u))return s(),{oldContent:o,newContent:o};throw Error(`Not accepted`)}catch(e){throw X(e),s(),e}}async function Sy(e,t){try{if(t?.type!==`connected`)throw Error(`IDE client not available`);await ca(`close_tab`,{tab_name:e},t)}catch(e){X(e)}}function Cy(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 wy(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 Ty(e){return Array.isArray(e)&&e[0]?.type===`text`&&e[0].text===`FILE_SAVED`&&typeof e[1].text==`string`}H(),Jl(),Dm();function Ey({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)(U,{color:`permission`,children:(0,$.jsxs)(_,{flexDirection:`column`,gap:1,children:[(0,$.jsxs)(x,{bold:!0,color:`permission`,children:[`Opened changes in `,i,` ⧉`]}),a&&(0,$.jsx)(x,{color:`warning`,children:Fh(nu(),a).startsWith(`..`)?`This will modify ${a} (outside working directory) via a symlink`:`Symlink target: ${a}`}),Ri()&&(0,$.jsx)(x,{dimColor:!0,children:`Save file to continue…`}),(0,$.jsxs)(_,{flexDirection:`column`,children:[(0,$.jsxs)(x,{children:[`Do you want to make this edit to `,(0,$.jsx)(x,{bold:!0,children:jh(r)}),`?`]}),(0,$.jsx)(Tp,{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)(_,{marginTop:1,children:(0,$.jsxs)(x,{dimColor:!0,children:[`Esc to cancel`,(u===`yes`&&!d||u===`no`&&!f)&&` · Tab to amend`]})})]})})}Ie(),H(),Ku();function Dy(e){let t=Vu(e),n=Vu(`${et()}/.workmate`),r=Pr(t),i=Pr(n);return r.startsWith(i+Ih.toLowerCase())||r.startsWith(`${i}/`)}function Oy(e){let t=Vu(e),n=Ph(Oh(),`.workmate`),r=Pr(t),i=Pr(n);return r.startsWith(i+Ih.toLowerCase())||r.startsWith(`${i}/`)}function ky({filePath:e,toolPermissionContext:t,operationType:n=`write`,onRejectFeedbackChange:r,onAcceptFeedbackChange:i,yesInputMode:a=!1,noInputMode:o=!1}){let s=[],c=en(`chat:cycleMode`,`Chat`,`shift+tab`);a&&i?s.push({type:`input`,label:`Yes`,value:`yes`,placeholder:`and tell Work Mate what to do next`,onChange:i,allowEmptySubmitToCancel:!0,option:{type:`accept-once`}}):s.push({label:`Yes`,value:`yes`,option:{type:`accept-once`}});let l=ni(e,t),u=Dy(e),d=Oy(e);if((u||d)&&n!==`read`)s.push({label:`Yes, allow edits to .workmate/ 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)(x,{children:[`Yes, allow all edits during this session `,(0,$.jsxs)(x,{bold:!0,children:[`(`,c,`)`]})]});else{let r=jh(Zu(e))||`this directory`;t=n===`read`?(0,$.jsxs)(x,{children:[`Yes, allow reading from `,(0,$.jsxs)(x,{bold:!0,children:[r,`/`]}),` during this session`]}):(0,$.jsxs)(x,{children:[`Yes, allow all edits in `,(0,$.jsxs)(x,{bold:!0,children:[r,`/`]}),` during this session`,` `,(0,$.jsxs)(x,{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 Work Mate what to do differently`,onChange:r,allowEmptySubmitToCancel:!0,option:{type:`reject`}}):s.push({label:`No`,value:`no`,option:{type:`reject`}}),s}Ed(),hf(),Ju(),bs();function Ay(e,t,n,r,i){Hv({completion_type:t,event:e,metadata:{language_name:n,message_id:r,platform:Iu.platform,hasFeedback:i??!1}})}function jy(e,t){let{messageId:n,toolUseConfirm:r,onDone:i,completionType:a,languageName:o}=e;Ay(`accept`,a,o,n),mf(r.tool.name),r.tool.isMcp,t?.feedback,t?.feedback?.length,t?.enteredFeedbackMode,i(),r.onAllow(r.input,[],t?.feedback)}function My(e,t){let{messageId:n,path:r,toolUseConfirm:i,toolPermissionContext:a,onDone:o,completionType:s,languageName:c,operationType:l}=e;if(Ay(`accept`,s,c,n),t?.scope===`claude-folder`||t?.scope===`global-claude-folder`){let e=[{type:`addRules`,rules:[{toolName:af,ruleContent:t.scope===`global-claude-folder`?Qd:ef}],behavior:`allow`,destination:`session`}];o(),i.onAllow(i.input,e);return}let u=r?Wr(r,l,a):[];o(),i.onAllow(i.input,u)}function Ny(e,t){let{messageId:n,toolUseConfirm:r,onDone:i,onReject:a,completionType:o,languageName:s}=e;Ay(`reject`,o,s,n,t?.hasFeedback),mf(r.tool.name),r.tool.isMcp,t?.feedback,t?.feedback?.length,t?.enteredFeedbackMode,i(),a(),r.onReject(t?.feedback)}var Py={"accept-once":jy,"accept-session":My,reject:Ny};J(),Ht(),Ed(),hf();function Fy({filePath:e,completionType:t,languageName:n,toolUseConfirm:r,onDone:i,onReject:a,parseInput:o,operationType:s=`write`}){let c=G(e=>e.toolPermissionContext),[l,u]=(0,Q.useState)(``),[d,f]=(0,Q.useState)(``),[p,m]=(0,Q.useState)(`yes`),[g,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(!1),[b,x]=(0,Q.useState)(!1),[S,C]=(0,Q.useState)(!1),w=(0,Q.useMemo)(()=>ky({filePath:e,toolPermissionContext:c,operationType:s,onRejectFeedbackChange:f,onAcceptFeedbackChange:u,yesInputMode:g,noInputMode:v}),[e,c,s,g,v]),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=Py[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 h({"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`&&g&&!l.trim()&&_(!1),e!==`no`&&v&&!d.trim()&&y(!1),m(e)},[g,v,l,d]),handleInputModeToggle:(0,Q.useCallback)(e=>{mf(r.tool.name),r.tool.isMcp,e===`yes`?g?_(!1):(_(!0),x(!0)):e===`no`&&(v?y(!1):(y(!0),C(!0)))},[g,v,r]),yesInputMode:g,noInputMode:v}}H(),Dt(),tu(),Ku(),Dm();function Iy({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?ks(l):`none`),[p,l]);Uv(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=Vu(l),{resolvedPath:t,isSymlink:n}=hu(_u(),e);return n?t:null},[l,d]),g=Fy({filePath:l||``,completionType:c,languageName:m,toolUseConfirm:e,onDone:n,onReject:r,parseInput:u,operationType:d}),{options:v,acceptFeedback:y,rejectFeedback:b,setFocusedOption:S,handleInputModeToggle:C,focusedOption:w,yesInputMode:T,noInputMode:E}=g,D=u(e.input),O=(0,Q.useMemo)(()=>f?f.getConfig(u(e.input)):null,[f,e.input]),{closeTabInIDE:k,showingDiffInIDE:A,ideName:j}=yy(O?{onChange:(e,t)=>{let n=f.applyChanges(D,t.edits);g.onChange(e,n)},toolUseContext:t,filePath:O.filePath,edits:(O.edits||[]).map(e=>({old_string:e.old_string,new_string:e.new_string,replace_all:e.replace_all||!1})),editMode:O.editMode||`single`}:{onChange:()=>{},toolUseContext:t,filePath:``,edits:[],editMode:`single`}),M=(e,t)=>{k?.(),g.onChange(e,D,t?.trim())};if(A&&O&&l)return(0,$.jsx)(Ey,{onChange:(e,t,n)=>M(e,n),options:v,filePath:l,input:D,ideName:j,symlinkTarget:h,rejectFeedback:b,acceptFeedback:y,setFocusedOption:S,onInputModeToggle:C,focusedOption:w,yesInputMode:T,noInputMode:E});let N=h!=null&&Fh(nu(),h).startsWith(`..`);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(Ym,{title:i,subtitle:a,innerPaddingX:0,children:[h?(0,$.jsx)(_,{paddingX:1,marginBottom:1,children:(0,$.jsx)(x,{color:`warning`,children:N?`This will modify ${h} (outside working directory) via a symlink`:`Symlink target: ${h}`})}):null,s,(0,$.jsxs)(_,{flexDirection:`column`,paddingX:1,children:[typeof o==`string`?(0,$.jsx)(x,{children:o}):o,(0,$.jsx)(Tp,{options:v,inlineDescriptions:!0,onChange:e=>{let t=v.find(t=>t.value===e);if(t){if(t.option.type===`reject`){let e=b.trim();M(t.option,e||void 0);return}if(t.option.type===`accept-once`){let e=y.trim();M(t.option,e||void 0);return}M(t.option)}},onCancel:()=>M({type:`reject`}),onFocus:e=>S(e),onInputModeToggle:C})]})]}),(0,$.jsx)(_,{paddingX:1,marginTop:1,children:(0,$.jsxs)(x,{dimColor:!0,children:[`Esc to reject`,(w===`yes`&&!T||w===`no`&&!E)&&` · Tab to add feedback`]})})]})}tu(),su(),ju(),mu(),H();function Ly({sedInfo:e,...t}){let{filePath:n}=e;return(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Ry,{sedInfo:e,contentPromise:(0,Q.useMemo)(()=>(async()=>{let e=Eu(n);return{oldContent:(await _u().readFile(n,{encoding:e})).replaceAll(`\r
|
|
22
|
+
`,`
|
|
23
|
+
`),fileExists:!0}})().catch(e=>{if(!lu(e))throw e;return{oldContent:``,fileExists:!1}}),[n]),...t})})}function Ry({sedInfo:e,contentPromise:t,...n}){let{filePath:r}=e,{oldContent:i,fileExists:a}=(0,Q.use)(t),o=(0,Q.useMemo)(()=>ar(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)(Iy,{toolUseConfirm:n.toolUseConfirm,toolUseContext:n.toolUseContext,onDone:n.onDone,onReject:n.onReject,title:`Edit file`,subtitle:Fh(nu(),r),question:(0,$.jsxs)(x,{children:[`Do you want to make this edit to `,(0,$.jsx)(x,{bold:!0,children:jh(r)}),`?`]}),content:s.length>0?(0,$.jsx)(py,{file_path:r,edits:s}):(0,$.jsx)(x,{dimColor:!0,children:c}),path:r,completionType:`str_replace_single`,parseInput:e=>({...hs.inputSchema.parse(e),_simulatedSedEdit:{filePath:r,newContent:o}})})}Ju();function zy(e,{assistantMessage:{message:{id:t}}},n,r){Hv({completion_type:e,event:n,metadata:{language_name:`none`,message_id:t,platform:xu(),hasFeedback:r??!1}})}Ed(),hf(),J();function By({toolUseConfirm:e,onDone:t,onReject:n,explainerVisible:r}){let i=An(),[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(),mf(e.tool.name),e.tool.isMcp,t===`yes`?l?u(!1):(u(!0),g(!0)):t===`no`&&(d?f(!1):(f(!0),v(!0)))}function b(r){let a=r?.trim(),o=!!a;o||i(e=>({...e,attribution:{...e.attribution,escapeCount:e.attribution.escapeCount+1}})),zy(`tool_use_single`,e,`reject`,o),a?e.onReject(a):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}}Ie(),H();function Vy(e){switch(e.length){case 0:return``;case 1:return(0,$.jsx)(x,{bold:!0,children:e[0]});case 2:return(0,$.jsxs)(x,{children:[(0,$.jsx)(x,{bold:!0,children:e[0]}),` and `,(0,$.jsx)(x,{bold:!0,children:e[1]})]});default:return(0,$.jsxs)(x,{children:[(0,$.jsx)(x,{bold:!0,children:e.slice(0,-1).join(`, `)}),`, and `,(0,$.jsx)(x,{bold:!0,children:e.slice(-1)[0]})]})}}function Hy(e){return e.join(`, `).length>50?`similar`:Vy(e)}function Uy(e){if(e.length===0)return``;let t=e.map(e=>jh(e)||e);return t.length===1?(0,$.jsxs)(x,{children:[(0,$.jsx)(x,{bold:!0,children:t[0]}),Ih]}):t.length===2?(0,$.jsxs)(x,{children:[(0,$.jsx)(x,{bold:!0,children:t[0]}),Ih,` and `,(0,$.jsx)(x,{bold:!0,children:t[1]}),Ih]}):(0,$.jsxs)(x,{children:[(0,$.jsx)(x,{bold:!0,children:t[0]}),Ih,`, `,(0,$.jsx)(x,{bold:!0,children:t[1]}),Ih,` and `,e.length-2,` more`]})}function Wy(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=fr(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)(x,{children:[`Yes, allow reading from `,(0,$.jsx)(x,{bold:!0,children:jh(e)||e}),Ih,` from this project`]})}return(0,$.jsxs)(x,{children:[`Yes, allow reading from `,Uy(s),` from this project`]})}if(l&&!u&&!d){if(o.length===1){let e=o[0];return(0,$.jsxs)(x,{children:[`Yes, and always allow access to `,(0,$.jsx)(x,{bold:!0,children:jh(e)||e}),Ih,` from this project`]})}return(0,$.jsxs)(x,{children:[`Yes, and always allow access to `,Uy(o),` from this project`]})}if(d&&!l&&!u)return(0,$.jsxs)(x,{children:[`Yes, and don't ask again for `,Hy(c),` commands in `,(0,$.jsx)(x,{bold:!0,children:et()})]});if((l||u)&&!d){let e=[...o,...s];if(l&&u)return(0,$.jsxs)(x,{children:[`Yes, and always allow access to `,Uy(e),` from this project`]})}if((l||u)&&d){let e=[...o,...s];return e.length===1&&c.length===1?(0,$.jsxs)(x,{children:[`Yes, and allow access to `,Uy(e),` and `,Hy(c),` commands`]}):(0,$.jsxs)(x,{children:[`Yes, and allow `,Uy(e),` access and `,Hy(c),` commands`]})}return null}Dc();function Gy(e){let{commandWithoutRedirections:t,redirections:n}=Zn(e);return n.length>0?t:e}function Ky({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 Work Mate what to do next`,onChange:r,allowEmptySubmitToCancel:!0}):f.push({label:`Yes`,value:`yes`}),_i()){let t=e.some(e=>e.type===`addDirectories`||e.type===`addRules`&&e.rules?.some(e=>e.toolName!==`Bash`));if(u!==void 0&&d&&!t&&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=Wy(e,nf,Gy);t&&f.push({label:t,value:`yes-apply-suggestions`})}}return l?f.push({type:`input`,label:`No`,value:`no`,placeholder:`and tell Work Mate what to do differently`,onChange:n,allowEmptySubmitToCancel:!0}):f.push({label:`No`,value:`no`}),f}H(),Ht(),Ed(),hf(),J(),hr(),hi(),br(),ws(),qm();function qy(e){let{toolUseConfirm:t,toolUseContext:n,onDone:r,onReject:i,verbose:a}=e,{command:o,description:s}=hs.inputSchema.parse(t.input),c=Zl(o);return c?(0,$.jsx)(Ly,{toolUseConfirm:t,toolUseContext:n,onDone:r,onReject:i,verbose:a,sedInfo:c}):(0,$.jsx)(Jy,{toolUseConfirm:t,toolUseContext:n,onDone:r,onReject:i,verbose:a,command:o,description:s})}function Jy({toolUseConfirm:e,toolUseContext:t,onDone:n,onReject:r,verbose:i,command:a,description:o}){let[s]=g(),c=G(e=>e.toolPermissionContext),l=uy({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:v,setRejectFeedback:y,focusedOption:b,handleInputModeToggle:S,handleReject:C,handleFocus:w}=By({toolUseConfirm:e,onDone:n,onReject:r,explainerVisible:l.visible}),[T,E]=(0,Q.useState)(!1),[O,k]=(0,Q.useState)(o||``),[A,j]=(0,Q.useState)(!o?.trim());(0,Q.useEffect)(()=>{if(!ra())return;let e=new AbortController;return Ji(a,o,e.signal).then(t=>{t&&!e.signal.aborted&&(k(t),j(!1))}).catch(()=>{}),()=>e.abort()},[a,o]);let M=e.permissionResult.decisionReason?.type===`subcommandResults`,[N,ee]=(0,Q.useState)(()=>{if(M){let t=ys(`suggestions`in e.permissionResult?e.permissionResult.suggestions:void 0).filter(e=>e.toolName===hs.name&&e.ruleContent);return t.length===1?t[0].ruleContent:void 0}let t=Es(a);if(t)return`${t}:*`;let n=Ur(a);return n?`${n}:*`:a}),P=(0,Q.useRef)(!1),F=(0,Q.useCallback)(e=>{P.current=!0,ee(e)},[]);(0,Q.useEffect)(()=>{if(M)return;let e=!1;return Bv(a,e=>hs.isReadOnly({command:e})).then(t=>{e||P.current||t.length>0&&ee(`${t[0]}:*`)}).catch(()=>{}),()=>{e=!0}},[a,M]);let{destructiveWarning:I,sandboxingEnabled:L,isSandboxed:te}=(0,Q.useMemo)(()=>{let t=$t.isSandboxingEnabled();return{destructiveWarning:null,sandboxingEnabled:t,isSandboxed:t&&$i(e.input)}},[a,e.input]);Uv(e,(0,Q.useMemo)(()=>({completion_type:`tool_use_single`,language_name:`none`}),[]));let ne=(0,Q.useMemo)(()=>kn(c),[c]),R=(0,Q.useMemo)(()=>Ky({suggestions:e.permissionResult.behavior===`ask`?e.permissionResult.suggestions:void 0,decisionReason:e.permissionResult.decisionReason,onRejectFeedbackChange:y,onAcceptFeedbackChange:v,onClassifierDescriptionChange:k,classifierDescription:O,initialClassifierDescriptionEmpty:A,existingAllowDescriptions:ne,yesInputMode:u,noInputMode:d,editablePrefix:N,onEditablePrefixChange:F}),[e,O,A,ne,u,d,N,F]);D(`permission:toggleDebug`,(0,Q.useCallback)(()=>{E(e=>!e)},[]),{context:`Confirmation`}),D(`confirm:no`,(0,Q.useCallback)(()=>{e.onDismissCheckmark?.()},[e]),{context:`Confirmation`,isActive:!1});function re(t){if({yes:1,"yes-apply-suggestions":2,"yes-prefix-edited":2,no:3}[t],l.visible,mf(e.tool.name),t===`yes-prefix-edited`){let t=(N??``).trim();if(zy(`tool_use_single`,e,`accept`),!t)e.onAllow(e.input,[]);else{let n=[{type:`addRules`,rules:[{toolName:hs.name,ruleContent:t}],behavior:`allow`,destination:`localSettings`}];e.onAllow(e.input,n)}n();return}switch(t){case`yes`:{let t=m.trim();zy(`tool_use_single`,e,`accept`),e.tool.isMcp,t.length,e.onAllow(e.input,[],t||void 0),n();break}case`yes-apply-suggestions`:{zy(`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();e.tool.isMcp,t.length,C(t||void 0);break}}}return(0,$.jsxs)(Ym,{title:L&&!te?`Bash command (unsandboxed)`:`Bash command`,children:[(0,$.jsxs)(_,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsx)(x,{dimColor:l.visible,children:hs.renderToolUseMessage({command:a,description:o},{theme:s,verbose:!0})}),!l.visible&&(0,$.jsx)(x,{dimColor:!0,children:e.description}),(0,$.jsx)(fy,{visible:l.visible,promise:l.promise})]}),T?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Xv,{permissionResult:e.permissionResult,toolName:`Bash`}),t.options.debug&&(0,$.jsx)(_,{justifyContent:`flex-end`,marginTop:1,children:(0,$.jsx)(x,{dimColor:!0,children:`Ctrl-D to hide debug info`})})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(_,{flexDirection:`column`,children:[(0,$.jsx)(lv,{permissionResult:e.permissionResult,toolType:`command`}),I&&(0,$.jsx)(_,{marginBottom:1,children:(0,$.jsx)(x,{color:`warning`,dimColor:!1,children:I})}),(0,$.jsx)(x,{dimColor:!1,children:`Do you want to proceed?`}),(0,$.jsx)(Tp,{options:R,isDisabled:!1,inlineDescriptions:!0,onChange:re,onCancel:()=>C(),onFocus:w,onInputModeToggle:S})]}),(0,$.jsxs)(_,{justifyContent:`space-between`,marginTop:1,children:[(0,$.jsxs)(x,{dimColor:!0,children:[`Esc to reject`,(b===`yes`&&!u||b===`no`&&!d)&&` · Tab to add feedback`,l.enabled&&` · ctrl+e to ${l.visible?`hide`:`explain`}`]}),t.options.debug&&(0,$.jsx)(x,{dimColor:!0,children:`Ctrl+d to show debug info`})]})]})]})}Ie(),H(),Ed(),J(),_l(),Dm(),qm();function Yy({toolUseConfirm:e,onDone:t,onReject:n}){let r=G(e=>e.toolPermissionContext.mode);function i(i){i===`yes`?(Bl(),$e(r,`plan`),t(),e.onAllow({},[{type:`setMode`,mode:`plan`,destination:`session`}])):(t(),n(),e.onReject())}return(0,$.jsx)(Ym,{color:`planMode`,title:`Enter plan mode?`,children:(0,$.jsxs)(_,{flexDirection:`column`,marginTop:1,paddingX:1,children:[(0,$.jsx)(x,{children:`Work Mate wants to enter plan mode to explore and design an implementation approach.`}),(0,$.jsxs)(_,{marginTop:1,flexDirection:`column`,children:[(0,$.jsx)(x,{dimColor:!0,children:`In plan mode, Work Mate will:`}),(0,$.jsx)(x,{dimColor:!0,children:` · Explore the codebase thoroughly`}),(0,$.jsx)(x,{dimColor:!0,children:` · Identify existing patterns`}),(0,$.jsx)(x,{dimColor:!0,children:` · Design an implementation strategy`}),(0,$.jsx)(x,{dimColor:!0,children:` · Present a plan for your approval`})]}),(0,$.jsx)(_,{marginTop:1,children:(0,$.jsx)(x,{dimColor:!0,children:`No code changes will be made until you approve the plan.`})}),(0,$.jsx)(_,{marginTop:1,children:(0,$.jsx)(Tp,{options:[{label:`Yes, enter plan mode`,value:`yes`},{label:`No, start implementing now`,value:`no`}],onChange:i,onCancel:()=>i(`no`)})})]})})}l(),Ed(),J(),Ie(),rh(),H(),sm(),Jl(),pd(),Ud(),Vi(),Uu(),_l(),_t(),dm(),qo(),Dm(),qm(),Co(),yi();function Xy(e,t){let n=[{type:`setMode`,mode:Mu(e),destination:`session`}];return ra()&&t&&t.length>0&&n.push({type:`addRules`,rules:t.map(e=>({toolName:e.tool,ruleContent:It(e.prompt)})),behavior:`allow`,destination:`session`}),n}function Zy(e,t,n){ke()||Bu()?.cleanupPeriodDays===0||!n&&Ao(qe())||ih([Al({content:e.slice(0,1e3)})],new AbortController().signal).then(async e=>{if(!e||Ao(qe()))return;let n=qe(),r=Ro();await Do(n,e,r,`auto`),await Fa(n,e,r,`auto`),t(t=>t.standaloneAgentContext?.name===e?t:{...t,standaloneAgentContext:{...t.standaloneAgentContext,name:e}})}).catch(X)}function Qy({toolUseConfirm:e,onDone:t,onReject:n,setStickyFooter:r}){let i=G(e=>e.toolPermissionContext),a=An();Yi();let{addNotification:o}=Wf(),[s,c]=(0,Q.useState)(``),[l,d]=(0,Q.useState)({}),f=(0,Q.useRef)(0),p=G(e=>e.settings.showClearContextOnPlanAccept)??!1,m=e.assistantMessage.message.usage,{mode:h,isAutoModeAvailable:g,isBypassPermissionsModeAvailable:v}=i,y=(0,Q.useMemo)(()=>$y({showClearContext:p,usedPercent:p?eb(m,h):null,isAutoModeAvailable:g,isBypassPermissionsModeAvailable:v,onFeedbackChange:c}),[p,m,h,g,v]);function b(e,t,n,r,i){let a=f.current++,o={id:a,type:`image`,content:e,mediaType:t||`image/png`,filename:n||`Pasted image`,dimensions:r};ii(o),$l(o),d(e=>({...e,[a]:o}))}let S=(0,Q.useCallback)(e=>{d(t=>{let n={...t};return delete n[e],n})},[]),C=Object.values(l).filter(e=>e.type===`image`),w=C.length>0,T=ha(),E=e.input.allowedPrompts,D=Ta(),O=!D||D.trim()===``,[k]=(0,Q.useState)(()=>za()??void 0),[A,j]=(0,Q.useState)(()=>Ta()??`No plan found. Please write your plan to the plan file first.`),[M,N]=(0,Q.useState)(!1),[ee,P]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{if(M){let e=setTimeout(N,5e3,!1);return()=>clearTimeout(e)}},[M]);let F=e=>{if(e.ctrl&&e.key===`g`){e.preventDefault(),(async()=>{let e=await fm(T);e.error&&o({key:`external-editor-error`,text:e.error,color:`warning`,priority:`high`}),e.content!==null&&(e.content!==A&&P(!0),j(e.content),N(!0))})();return}if(e.shift&&e.key===`tab`){e.preventDefault(),I(p?`yes-accept-edits`:`yes-accept-edits-keep-context`);return}};async function I(r){let o=s.trim(),c=o||void 0,l=ee?{plan:A}:{};{let e=(r===`yes-resume-auto-mode`||r===`yes-auto-clear-context`)&&Bt(),t=er();r!==`no`&&!e&&t&&(jc(!1),Oe(!0),a(e=>({...e,toolPermissionContext:{...Rr(e.toolPermissionContext),prePlanMode:void 0}})))}let u=r===`yes-accept-edits-keep-context`||r===`yes-default-keep-context`||r===`yes-resume-auto-mode`;if(r!==`no`&&Zy(A,a,!u),r!==`no`&&!u){let i=`default`;r===`yes-bypass-permissions`?i=`bypassPermissions`:r===`yes-accept-edits`?i=`acceptEdits`:r===`yes-auto-clear-context`&&Bt()&&(i=`auto`,jc(!0)),A.length,Bl();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: ${Ro()}`,s=c?`\n\nUser feedback on this plan: ${c}`:``;a(e=>({...e,initialMessage:{message:{...Al({content:`Implement the following plan:\n\n${A}${o}${s}`}),planContent:A},clearContext:!0,mode:i,allowedPrompts:E}})),Ze(!0),it(!0),t(),n(),e.onReject();return}if(r===`yes-resume-auto-mode`&&Bt()){A.length,Bl(),Ze(!0),it(!0),jc(!0),a(e=>({...e,toolPermissionContext:Cs({...e.toolPermissionContext,mode:`auto`,prePlanMode:void 0})})),t(),e.onAllow(l,[],c);return}let d={"yes-accept-edits-keep-context":i.isBypassPermissionsModeAvailable?`bypassPermissions`:`acceptEdits`,"yes-default-keep-context":`default`,"yes-resume-auto-mode":`default`}[r];if(d){A.length,Bl(),Ze(!0),it(!0),t(),e.onAllow(l,Xy(d,E),c);return}let f={"yes-bypass-permissions":`bypassPermissions`,"yes-accept-edits":`acceptEdits`}[r];if(f){A.length,Bl(),Ze(!0),it(!0),t(),e.onAllow(l,Xy(f,E),c);return}if(r===`no`){if(!o&&!w)return;A.length,Bl();let r;w&&(r=await Promise.all(C.map(async e=>(await Bo({type:`image`,source:{type:`base64`,media_type:e.mediaType||`image/png`,data:e.content}})).block))),t(),n(),e.onReject(o||(w?`(See attached image)`:void 0),r&&r.length>0?r:void 0)}}let L=cm(),te=L?ea(L):null,ne=(0,Q.useRef)(I);ne.current=I;let R=(0,Q.useRef)(void 0);R.current=()=>{A.length,Bl(),t(),n(),e.onReject()};let re=!O&&!!r;if((0,Q.useLayoutEffect)(()=>{if(re)return r((0,$.jsxs)(_,{flexDirection:`column`,borderStyle:`round`,borderColor:`planMode`,borderLeft:!1,borderRight:!1,borderBottom:!1,paddingX:1,children:[(0,$.jsx)(x,{dimColor:!0,children:`Would you like to proceed?`}),(0,$.jsx)(_,{marginTop:1,children:(0,$.jsx)(Tp,{options:y,onChange:e=>void ne.current(e),onCancel:()=>R.current?.(),onImagePaste:b,pastedContents:l,onRemoveImage:S})}),te&&(0,$.jsxs)(_,{flexDirection:`row`,gap:1,marginTop:1,children:[(0,$.jsx)(x,{dimColor:!0,children:`ctrl-g to edit in `}),(0,$.jsx)(x,{bold:!0,dimColor:!0,children:te}),(0,$.jsxs)(x,{dimColor:!0,children:[` · `,$u(T)]}),M&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(x,{dimColor:!0,children:` · `}),(0,$.jsxs)(x,{color:`success`,children:[u.tick,`Plan saved!`]})]})]})]})),()=>r(null)},[re,r,y,l,te,T,M]),O){function r(r){r===`yes`?(Bl(),er()&&(jc(!1),Oe(!0),a(e=>({...e,toolPermissionContext:{...Rr(e.toolPermissionContext),prePlanMode:void 0}}))),Ze(!0),it(!0),t(),e.onAllow({},[{type:`setMode`,mode:`default`,destination:`session`}])):(Bl(),t(),n(),e.onReject())}return(0,$.jsx)(Ym,{color:`planMode`,title:`Exit plan mode?`,children:(0,$.jsxs)(_,{flexDirection:`column`,paddingX:1,marginTop:1,children:[(0,$.jsx)(x,{children:`Work Mate wants to exit plan mode`}),(0,$.jsx)(_,{marginTop:1,children:(0,$.jsx)(Tp,{options:[{label:`Yes`,value:`yes`},{label:`No`,value:`no`}],onChange:r,onCancel:()=>{Bl(),t(),n(),e.onReject()}})})]})})}return(0,$.jsxs)(_,{flexDirection:`column`,tabIndex:0,autoFocus:!0,onKeyDown:F,children:[(0,$.jsx)(Ym,{color:`planMode`,title:`Ready to code?`,innerPaddingX:0,children:(0,$.jsxs)(_,{flexDirection:`column`,marginTop:1,children:[(0,$.jsx)(_,{paddingX:1,flexDirection:`column`,children:(0,$.jsx)(x,{children:`Here is Work Mate's plan:`})}),(0,$.jsx)(_,{borderColor:`subtle`,borderStyle:`dashed`,flexDirection:`column`,borderLeft:!1,borderRight:!1,paddingX:1,marginBottom:1,overflow:`hidden`,children:(0,$.jsx)(Is,{children:A})}),(0,$.jsxs)(_,{flexDirection:`column`,paddingX:1,children:[(0,$.jsx)(lv,{permissionResult:e.permissionResult,toolType:`tool`}),ra()&&E&&E.length>0&&(0,$.jsxs)(_,{flexDirection:`column`,marginBottom:1,children:[(0,$.jsx)(x,{bold:!0,children:`Requested permissions:`}),E.map((e,t)=>(0,$.jsxs)(x,{dimColor:!0,children:[` `,`· `,e.tool,`(`,`prompt:`,` `,e.prompt,`)`]},t))]}),!re&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(x,{dimColor:!0,children:`Work Mate has written up a plan and is ready to execute. Would you like to proceed?`}),(0,$.jsx)(_,{marginTop:1,children:(0,$.jsx)(Tp,{options:y,onChange:I,onCancel:()=>R.current?.(),onImagePaste:b,pastedContents:l,onRemoveImage:S})})]})]})]})}),!re&&te&&(0,$.jsxs)(_,{flexDirection:`row`,gap:1,paddingX:1,marginTop:1,children:[(0,$.jsxs)(_,{children:[(0,$.jsx)(x,{dimColor:!0,children:`ctrl-g to edit in `}),(0,$.jsx)(x,{bold:!0,dimColor:!0,children:te}),(0,$.jsxs)(x,{dimColor:!0,children:[` · `,$u(T)]})]}),M&&(0,$.jsxs)(_,{children:[(0,$.jsx)(x,{dimColor:!0,children:` · `}),(0,$.jsxs)(x,{color:`success`,children:[u.tick,`Plan saved!`]})]})]})]})}function $y({showClearContext:e,usedPercent:t,isAutoModeAvailable:n,isBypassPermissionsModeAvailable:r,onFeedbackChange:i}){let a=[],o=t===null?``:` (${t}% used)`;return e&&(n?a.push({label:`Yes, clear context${o} and use auto mode`,value:`yes-auto-clear-context`}):r?a.push({label:`Yes, clear context${o} and bypass permissions`,value:`yes-bypass-permissions`}):a.push({label:`Yes, clear context${o} and auto-accept edits`,value:`yes-accept-edits`})),n?a.push({label:`Yes, and use auto mode`,value:`yes-resume-auto-mode`}):r?a.push({label:`Yes, and bypass permissions`,value:`yes-accept-edits-keep-context`}):a.push({label:`Yes, auto-accept edits`,value:`yes-accept-edits-keep-context`}),a.push({label:`Yes, manually approve edits`,value:`yes-default-keep-context`}),a.push({type:`input`,label:`No, keep planning`,value:`no`,placeholder:`Tell Work Mate what to change`,description:`shift+tab to approve with this feedback`,onChange:i}),a}function eb(e,t){if(!e)return null;let n=Hd(qd({permissionMode:t,mainLoopModel:Jd(),exceeds200kTokens:!1}),tt()),{used:r}=Ld({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}Bp(),H(),Ht(),Ed(),J(),wp();var tb={accept:`tell Work Mate what to do next`,reject:`tell Work Mate what to do differently`};function nb({options:e,onSelect:t,onCancel:n,question:r=`Do you want to proceed?`,toolAnalyticsContext:i}){let a=An(),[o,s]=(0,Q.useState)(``),[c,l]=(0,Q.useState)(``),[u,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(!1),[m,g]=(0,Q.useState)(null),[v,y]=(0,Q.useState)(!1),[b,S]=(0,Q.useState)(!1),C=e.find(e=>e.value===m)?.feedbackConfig?.type,w=C===`accept`&&!u||C===`reject`&&!f,T=(0,Q.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=tb[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,Q.useCallback)(t=>{let n=e.find(e=>e.value===t);if(!n?.feedbackConfig)return;let{type:r}=n.feedbackConfig;i?.toolName,i?.isMcp,r===`accept`?u?d(!1):(d(!0),y(!0)):r===`reject`&&(f?p(!1):(p(!0),S(!0)))},[e,u,f,i]),D=(0,Q.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),i?.toolName,i?.isMcp,e?.length,r.feedbackConfig.type,r.feedbackConfig.type===`accept`||r.feedbackConfig.type}t(n,a)},[e,o,c,t,i,v,b]);h((0,Q.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,Q.useCallback)(()=>{a(e=>({...e,attribution:{...e.attribution,escapeCount:e.attribution.escapeCount+1}})),n?.()},[n,a]);return(0,$.jsxs)(_,{flexDirection:`column`,children:[typeof r==`string`?(0,$.jsx)(x,{children:r}):r,(0,$.jsx)(Tp,{options:T,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),g(t)},onInputModeToggle:E}),(0,$.jsx)(_,{marginTop:1,children:(0,$.jsxs)(x,{dimColor:!0,children:[`Esc to cancel`,w&&` · Tab to amend`]})})]})}Ie(),H(),hf(),Ju(),sr(),xd(),qm();function rb({toolUseConfirm:e,onDone:t,onReject:n,verbose:r}){let[i]=g(),a=e.tool.userFacingName(e.input),o=a.endsWith(` (MCP)`)?a.slice(0,-6):a;Uv(e,(0,Q.useMemo)(()=>({completion_type:`tool_use_single`,language_name:`none`}),[]));let s=(0,Q.useCallback)((r,i)=>{switch(r){case`yes`:Hv({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id,platform:Iu.platform}}),e.onAllow(e.input,[],i),t();break;case`yes-dont-ask-again`:Hv({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id,platform:Iu.platform}}),e.onAllow(e.input,[{type:`addRules`,rules:[{toolName:e.tool.name}],behavior:`allow`,destination:`localSettings`}]),t();break;case`no`:Hv({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id,platform:Iu.platform}}),e.onReject(i),n(),t();break}},[e,t,n]),c=(0,Q.useCallback)(()=>{Hv({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id,platform:Iu.platform}}),e.onReject(),n(),t()},[e,t,n]),l=et(),u=_i(),d=(0,Q.useMemo)(()=>{let e=[{label:`Yes`,value:`yes`,feedbackConfig:{type:`accept`}}];return u&&e.push({label:(0,$.jsxs)(x,{children:[`Yes, and don't ask again for `,(0,$.jsx)(x,{bold:!0,children:o}),` commands in`,` `,(0,$.jsx)(x,{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:mf(e.tool.name),isMcp:e.tool.isMcp??!1}),[e.tool.name,e.tool.isMcp]);return(0,$.jsxs)(Ym,{title:`Tool use`,children:[(0,$.jsxs)(_,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsxs)(x,{children:[o,`(`,e.tool.renderToolUseMessage(e.input,{theme:i,verbose:!0}),`)`,a.endsWith(` (MCP)`)?(0,$.jsx)(x,{dimColor:!0,children:` (MCP)`}):``]}),(0,$.jsx)(x,{dimColor:!0,children:_d(e.description,3)})]}),(0,$.jsxs)(_,{flexDirection:`column`,children:[(0,$.jsx)(lv,{permissionResult:e.permissionResult,toolType:`tool`}),(0,$.jsx)(nb,{options:d,onSelect:s,onCancel:c,toolAnalyticsContext:f})]})]})}function ib(e,t,n,r){return{filePath:e,edits:[{old_string:t,new_string:n,replace_all:r}],editMode:`single`}}tu(),H();var ab={getConfig:e=>ib(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 ob(e){let t=e=>wr.inputSchema.parse(e),{file_path:n,old_string:r,new_string:i,replace_all:a}=t(e.toolUseConfirm.input);return(0,$.jsx)(Iy,{toolUseConfirm:e.toolUseConfirm,toolUseContext:e.toolUseContext,onDone:e.onDone,onReject:e.onReject,title:`Edit file`,subtitle:Fh(nu(),n),question:(0,$.jsxs)(x,{children:[`Do you want to make this edit to `,(0,$.jsx)(x,{bold:!0,children:jh(n)}),`?`]}),content:(0,$.jsx)(py,{file_path:n,edits:[{old_string:r,new_string:i,replace_all:a||!1}]}),path:n,completionType:`str_replace_single`,parseInput:t,ideDiffSupport:ab})}H();function sb(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 cb({toolUseConfirm:e,onDone:t,onReject:n,verbose:r,toolUseContext:i}){let[a]=g(),o=sb(e),s=e.tool.userFacingName(e.input),c=e.tool.isReadOnly(e.input),l=`${c?`Read`:`Edit`} file`;return o?(0,$.jsx)(Iy,{toolUseConfirm:e,toolUseContext:i,onDone:t,onReject:n,title:l,content:(0,$.jsx)(_,{flexDirection:`column`,paddingX:2,paddingY:1,children:(0,$.jsxs)(x,{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)(rb,{toolUseConfirm:e,toolUseContext:i,onDone:t,onReject:n,verbose:r})}Ts(),H(),Hc(),Ol();function lb({file_path:e,content:t,fileExists:n,oldContent:r}){let{columns:i}=V(),a=(0,Q.useMemo)(()=>n?qa({filePath:e,fileContents:r,edits:[{old_string:r,new_string:t,replace_all:!1}]}):null,[n,e,r,t]),o=t.split(`
|
|
24
|
+
`)[0]??null;return(0,$.jsx)(_,{flexDirection:`column`,children:(0,$.jsx)(_,{borderColor:`subtle`,borderStyle:`dashed`,flexDirection:`column`,borderLeft:!1,borderRight:!1,paddingX:1,children:a?Nu(a.map(t=>(0,$.jsx)(Pl,{patch:t,dim:!1,filePath:e,firstLine:o,fileContent:r,width:i-2},t.newStart)),e=>(0,$.jsx)(T,{fromLeftEdge:!0,children:(0,$.jsx)(x,{dimColor:!0,children:`...`})},`ellipsis-${e}`)):(0,$.jsx)(Yt,{code:t||`(No content)`,filePath:e})})})}H(),tu(),su(),ju();var ub={getConfig:e=>{let t;try{t=ed(e.file_path)}catch(e){if(!lu(e))throw e;t=``}return ib(e.file_path,t,e.content,!1)},applyChanges:(e,t)=>{let n=t[0];return n?{...e,content:n.new_string}:e}};function db(e){let t=e=>dt.inputSchema.parse(e),{file_path:n,content:r}=t(e.toolUseConfirm.input),{fileExists:i,oldContent:a}=(0,Q.useMemo)(()=>{try{return{fileExists:!0,oldContent:ed(n)}}catch(e){if(!lu(e))throw e;return{fileExists:!1,oldContent:``}}},[n]),o=i?`overwrite`:`create`;return(0,$.jsx)(Iy,{toolUseConfirm:e.toolUseConfirm,toolUseContext:e.toolUseContext,onDone:e.onDone,onReject:e.onReject,title:i?`Overwrite file`:`Create file`,subtitle:Fh(nu(),n),question:(0,$.jsxs)(x,{children:[`Do you want to `,o,` `,(0,$.jsx)(x,{bold:!0,children:jh(n)}),`?`]}),content:(0,$.jsx)(lb,{file_path:n,content:r,fileExists:i,oldContent:a}),path:n,completionType:`write_file_single`,parseInput:t,ideDiffSupport:ub})}H(),Su(),tu(),Hc(),mu(),Ol(),Di();function fb(e){let t=(0,Q.useMemo)(()=>_u().readFile(e.notebook_path,{encoding:`utf-8`}).then(e=>xe(e)).catch(()=>null),[e.notebook_path]);return(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(pb,{...e,promise:t})})}function pb({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=Pt(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:qa({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)(_,{flexDirection:`column`,children:(0,$.jsxs)(_,{borderStyle:`round`,flexDirection:`column`,paddingX:1,children:[(0,$.jsxs)(_,{paddingBottom:1,flexDirection:`column`,children:[(0,$.jsx)(x,{bold:!0,children:a?e:Fh(nu(),e)}),(0,$.jsxs)(x,{dimColor:!0,children:[d,` for cell `,t,r?` (${r})`:``]})]}),i===`delete`?(0,$.jsx)(_,{flexDirection:`column`,paddingLeft:2,children:(0,$.jsx)(Yt,{code:l,filePath:e})}):i===`insert`?(0,$.jsx)(_,{flexDirection:`column`,paddingLeft:2,children:(0,$.jsx)(Yt,{code:n,filePath:r===`markdown`?`file.md`:e})}):u?Nu(u.map(t=>(0,$.jsx)(Pl,{patch:t,dim:!1,width:o,filePath:e,firstLine:n.split(`
|
|
25
|
+
`)[0]??null,fileContent:l},t.newStart)),e=>(0,$.jsx)(T,{fromLeftEdge:!0,children:(0,$.jsx)(x,{dimColor:!0,children:`...`})},`ellipsis-${e}`)):(0,$.jsx)(Yt,{code:n,filePath:r===`markdown`?`file.md`:e})]})})}H(),pd();function mb(e){let t=e=>{let t=kt.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)(Iy,{toolUseConfirm:e.toolUseConfirm,toolUseContext:e.toolUseContext,onDone:e.onDone,onReject:e.onReject,title:`Edit notebook`,question:(0,$.jsxs)(x,{children:[`Do you want to `,s,` `,(0,$.jsx)(x,{bold:!0,children:jh(r)}),`?`]}),content:(0,$.jsx)(fb,{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})}xd(),pr();async function hb(e){if(e.nameType===`application`)return null;let t=e.name;if(!t||ms.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 Mv(n),i=await Dv(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||Sv[n])?null:i}async function gb(e,t){let n=await ir(e);if(!n.valid)return[];let r=hn(n).filter(e=>e.elementType===`CommandAst`);if(r.length<=1){let e=r[0]?await hb(r[0]):null;return e?[e]:[]}let i=[];for(let e of r){if(t?.(e))continue;let n=await hb(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=_b(t);(n===``?0:Sd(n,` `)+1)<=1&&((await Mv(e))?.subcommands?.length||Sv[e])||o.push(n)}return o}function _b(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(` `)}sr();function vb({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 Work Mate what to do next`,onChange:n,allowEmptySubmitToCancel:!0}):s.push({label:`Yes`,value:`yes`}),_i()&&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=Wy(e,of);t&&s.push({label:t,value:`yes-apply-suggestions`})}}return i?s.push({type:`input`,label:`No`,value:`no`,placeholder:`and tell Work Mate what to do differently`,onChange:t,allowEmptySubmitToCancel:!0}):s.push({label:`No`,value:`no`}),s}H(),Ht(),Ed(),hf(),wp(),qm();function yb(e){let{toolUseConfirm:t,toolUseContext:n,onDone:r,onReject:i}=e,{command:a,description:o}=Hr.inputSchema.parse(t.input),[s]=g(),c=uy({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:v,focusedOption:y,handleInputModeToggle:b,handleReject:S,handleFocus:C}=By({toolUseConfirm:t,onDone:r,onReject:i,explainerVisible:c.visible}),[w,T]=(0,Q.useState)(!1),[E,O]=(0,Q.useState)(a.includes(`
|
|
26
|
+
`)?void 0:a),k=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{let e=!1;return gb(a,e=>Qr(e,e.text)).then(t=>{e||k.current||t.length>0&&O(`${t[0]}:*`)}).catch(()=>{}),()=>{e=!0}},[a]);let A=(0,Q.useCallback)(e=>{k.current=!0,O(e)},[]);Uv(t,(0,Q.useMemo)(()=>({completion_type:`tool_use_single`,language_name:`none`}),[]));let j=(0,Q.useMemo)(()=>vb({suggestions:t.permissionResult.behavior===`ask`?t.permissionResult.suggestions:void 0,onRejectFeedbackChange:v,onAcceptFeedbackChange:h,yesInputMode:l,noInputMode:u,editablePrefix:E,onEditablePrefixChange:A}),[t,l,u,E,A]);D(`permission:toggleDebug`,(0,Q.useCallback)(()=>{T(e=>!e)},[]),{context:`Confirmation`});function M(e){if({yes:1,"yes-apply-suggestions":2,"yes-prefix-edited":2,no:3}[e],c.visible,mf(t.tool.name),e===`yes-prefix-edited`){let e=(E??``).trim();if(zy(`tool_use_single`,t,`accept`),!e)t.onAllow(t.input,[]);else{let n=[{type:`addRules`,rules:[{toolName:Hr.name,ruleContent:e}],behavior:`allow`,destination:`localSettings`}];t.onAllow(t.input,n)}r();return}switch(e){case`yes`:{let e=p.trim();zy(`tool_use_single`,t,`accept`),t.tool.isMcp,e.length,t.onAllow(t.input,[],e||void 0),r();break}case`yes-apply-suggestions`:{zy(`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();t.tool.isMcp,e.length,S(e||void 0);break}}}return(0,$.jsxs)(Ym,{title:`PowerShell command`,children:[(0,$.jsxs)(_,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsx)(x,{dimColor:c.visible,children:Hr.renderToolUseMessage({command:a,description:o},{theme:s,verbose:!0})}),!c.visible&&(0,$.jsx)(x,{dimColor:!0,children:t.description}),(0,$.jsx)(fy,{visible:c.visible,promise:c.promise})]}),w?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Xv,{permissionResult:t.permissionResult,toolName:`PowerShell`}),n.options.debug&&(0,$.jsx)(_,{justifyContent:`flex-end`,marginTop:1,children:(0,$.jsx)(x,{dimColor:!0,children:`Ctrl-D to hide debug info`})})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(_,{flexDirection:`column`,children:[(0,$.jsx)(lv,{permissionResult:t.permissionResult,toolType:`command`}),null,(0,$.jsx)(x,{children:`Do you want to proceed?`}),(0,$.jsx)(Tp,{options:j,inlineDescriptions:!0,onChange:M,onCancel:()=>S(),onFocus:C,onInputModeToggle:b})]}),(0,$.jsxs)(_,{justifyContent:`space-between`,marginTop:1,children:[(0,$.jsxs)(x,{dimColor:!0,children:[`Esc to cancel`,(y===`yes`&&!l||y===`no`&&!u)&&` · Tab to amend`,c.enabled&&` · ctrl+e to ${c.visible?`hide`:`explain`}`]}),n.options.debug&&(0,$.jsx)(x,{dimColor:!0,children:`Ctrl+d to show debug info`})]})]})]})}pd(),Ie(),H(),hf(),Ju(),sr(),qm();function bb(e){let{toolUseConfirm:t,onDone:n,onReject:r,verbose:i}=e,a=(e=>{let t=ja.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;Uv(t,(0,Q.useMemo)(()=>({completion_type:`tool_use_single`,language_name:`none`}),[]));let s=et(),c=_i(),l=(0,Q.useMemo)(()=>{let e=[{label:`Yes`,value:`yes`,feedbackConfig:{type:`accept`}}],t=[];if(c){t.push({label:(0,$.jsxs)(x,{children:[`Yes, and don't ask again for `,(0,$.jsx)(x,{bold:!0,children:a}),` in `,(0,$.jsx)(x,{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)(x,{children:[`Yes, and don't ask again for `,(0,$.jsx)(x,{bold:!0,children:`${n}:*`}),` commands in`,` `,(0,$.jsx)(x,{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:mf(t.tool.name),isMcp:t.tool.isMcp??!1}),[t.tool.name,t.tool.isMcp]),d=(0,Q.useCallback)((e,i)=>{switch(e){case`yes`:Hv({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:t.assistantMessage.message.id,platform:Iu.platform}}),t.onAllow(t.input,[],i),n();break;case`yes-exact`:Hv({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:t.assistantMessage.message.id,platform:Iu.platform}}),t.onAllow(t.input,[{type:`addRules`,rules:[{toolName:Xd,ruleContent:a}],behavior:`allow`,destination:`localSettings`}]),n();break;case`yes-prefix`:{Hv({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:t.assistantMessage.message.id,platform:Iu.platform}});let e=a.indexOf(` `),r=e>0?a.substring(0,e):a;t.onAllow(t.input,[{type:`addRules`,rules:[{toolName:Xd,ruleContent:`${r}:*`}],behavior:`allow`,destination:`localSettings`}]),n();break}case`no`:Hv({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:t.assistantMessage.message.id,platform:Iu.platform}}),t.onReject(i),r(),n();break}},[t,n,r,a]),f=(0,Q.useCallback)(()=>{Hv({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:t.assistantMessage.message.id,platform:Iu.platform}}),t.onReject(),r(),n()},[t,n,r]);return(0,$.jsxs)(Ym,{title:`Use skill "${a}"?`,children:[(0,$.jsx)(x,{children:`Work Mate may use instructions, code, or files from this Skill.`}),(0,$.jsx)(_,{flexDirection:`column`,paddingX:2,paddingY:1,children:(0,$.jsx)(x,{dimColor:!0,children:o?.description})}),(0,$.jsxs)(_,{flexDirection:`column`,children:[(0,$.jsx)(lv,{permissionResult:t.permissionResult,toolType:`tool`}),(0,$.jsx)(nb,{options:l,onSelect:d,onCancel:f,toolAnalyticsContext:u})]})]})}H(),Rp(),Ju(),sr(),qm();function xb({toolUseConfirm:e,onDone:t,onReject:n}){let[r]=g(),i=Lp(r),a=e.input,o=(0,Q.useMemo)(()=>_i(),[]),s=(0,Q.useMemo)(()=>{let t=[{label:`Yes`,value:`yes`,feedbackConfig:{type:`accept`}}];return o&&t.push({label:(0,$.jsxs)(x,{children:[`Yes, and don`,`’`,`t ask again for `,(0,$.jsx)(x,{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,Q.useCallback)((r,i)=>{switch(r){case`yes`:Hv({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id??``,platform:Iu.platform}}),e.onAllow(e.input,[],i),t();break;case`yes-dont-ask-again`:Hv({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id??``,platform:Iu.platform}}),e.onAllow(e.input,[{type:`addRules`,rules:[{toolName:e.tool.name}],behavior:`allow`,destination:`localSettings`}]),t();break;case`no`:Hv({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id??``,platform:Iu.platform}}),e.onReject(i),n(),t();break}},[e,t,n]),l=(0,Q.useCallback)(()=>{Hv({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id??``,platform:Iu.platform}}),e.onReject(),n(),t()},[e,t,n]);return(0,$.jsx)(Ym,{title:`Workflow`,children:(0,$.jsxs)(_,{flexDirection:`column`,gap:1,children:[(0,$.jsxs)(_,{flexDirection:`column`,children:[(0,$.jsxs)(x,{bold:!0,color:i.permission,children:[`Execute workflow: `,a.workflow]}),a.args&&(0,$.jsxs)(x,{dimColor:!0,children:[`Arguments: `,a.args]})]}),(0,$.jsx)(lv,{permissionResult:e.permissionResult,toolType:`command`}),(0,$.jsx)(nb,{options:s,onSelect:c,onCancel:l})]})})}Ht(),qt(),hr(),Ir(),ko(),Ss(),Ct(),ci();var Sb=mi();function Cb(e){switch(e){case wr:return ob;case dt:return db;case hs:return qy;case Hr:return yb;case kt:return mb;case El:return Qy;case es:return Yy;case ja:return bb;case Ti:return _v;case Sb:return xb??rb;case K:case Gn:case Uc:return cb;default:return rb}}function wb(e){let t=e.tool.userFacingName(e.input);return e.tool===El?`Work Mate needs your approval for the plan`:e.tool===es?`Work Mate wants to enter plan mode`:!t||t.trim()===``?`Work Mate needs your attention`:`Work Mate needs your permission to use ${t}`}function Tb({toolUseConfirm:e,toolUseContext:t,onDone:n,onReject:r,verbose:i,setStickyFooter:a}){return D(`app:interrupt`,()=>{n(),r(),e.onReject()},{context:`Confirmation`}),ev(wb(e),`permission_prompt`),(0,$.jsx)(Cb(e.tool),{toolUseContext:t,toolUseConfirm:e,onDone:n,onReject:r,verbose:i,setStickyFooter:a})}Kl(),cp(),pd(),Kn();async function Eb(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=vc([`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:
|
|
27
|
+
- Current date and time: ${i} (UTC)
|
|
28
|
+
- Local timezone: ${c}
|
|
29
|
+
- Day of week: ${l}
|
|
30
|
+
|
|
31
|
+
User input: "${e}"
|
|
32
|
+
|
|
33
|
+
Output format: ${t===`date`?`YYYY-MM-DD (date only, no time)`:`YYYY-MM-DDTHH:MM:SS${c} (full date-time with timezone)`}
|
|
34
|
+
|
|
35
|
+
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 Ea({systemPrompt:u,userPrompt:d,signal:n,options:{querySource:`mcp_datetime_parse`,agents:[],isNonInteractiveSession:!1,hasAppendSystemPrompt:!1,mcpTools:[],enablePromptCaching:!1}}),t=Lc(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 Db(e){return/^\d{4}-\d{2}-\d{2}(T|$)/.test(e.trim())}be(),vu(),xd();var Ob=e=>e.type===`string`&&(`enum`in e||`oneOf`in e);function kb(e){return e.type===`array`&&`items`in e&&typeof e.items==`object`&&e.items!==null&&(`enum`in e.items||`anyOf`in e.items)}function Ab(e){return`anyOf`in e.items?e.items.anyOf.map(e=>e.const):`enum`in e.items?e.items.enum:[]}function jb(e){return`anyOf`in e.items?e.items.anyOf.map(e=>e.title):`enum`in e.items?e.items.enum:[]}function Mb(e,t){let n=Ab(e).indexOf(t);return n>=0?jb(e)[n]??t:t}function Nb(e){return`oneOf`in e?e.oneOf.map(e=>e.const):`enum`in e?e.enum:[]}function Pb(e){return`oneOf`in e?e.oneOf.map(e=>e.title):`enum`in e?(`enumNames`in e?e.enumNames:void 0)??e.enum:[]}function Fb(e,t){let n=Nb(e).indexOf(t);return n>=0?Pb(e)[n]??t:t}function Ib(e){if(Ob(e)){let[t,...n]=Nb(e);return t?we([t,...n]):he()}if(e.type===`string`){let t=ye();switch(e.minLength!==void 0&&(t=t.min(e.minLength,{message:`Must be at least ${e.minLength} ${yd(e.minLength,`character`)}`})),e.maxLength!==void 0&&(t=t.max(e.maxLength,{message:`Must be at most ${e.maxLength} ${yd(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=ge({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 me();throw Error(`Unsupported schema: ${iu(e)}`)}function Lb(e,t){let n=Ib(t).safeParse(e);return n.success?{value:n.data,isValid:!0}:{isValid:!1,error:n.error.issues.map(e=>e.message).join(`; `)}}function Rb(e){return e.type===`string`&&`format`in e&&(e.format===`date`||e.format===`date-time`)}async function zb(e,t,n){let r=Lb(e,t);if(r.isValid)return r;if(Rb(t)&&!Db(e)){let r=await Eb(e,t.format,n);if(r.success){let e=Lb(r.value,t);if(e.isValid)return e}}return r}l(),Ts(),H(),Ht(),xd(),Zo(),If();var Bb=e=>[`string`,`number`,`integer`].includes(e.type),Vb=`⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏`,Hb=e=>(e+1)%10;function Ub(e){e.buffer=``,e.timer=void 0}function Wb(){let[e,t]=(0,Q.useState)(0);return(0,Q.useEffect)(()=>{let e=setInterval(t,80,Hb);return()=>clearInterval(e)},[]),(0,$.jsx)(x,{color:`warning`,children:Vb[e]})}function Gb(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 Kb({event:e,onResponse:t,onWaitingDismiss:n}){return e.params.mode===`url`?(0,$.jsx)(Jb,{event:e,onResponse:t,onWaitingDismiss:n}):(0,$.jsx)(qb,{event:e,onResponse:t})}function qb({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,d]=(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}),[p,m]=(0,Q.useState)(()=>{let e={};for(let[t,n]of Object.entries(a.properties))if(Bb(n)&&n?.default!==void 0){let r=Lb(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 h=(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,v]=(0,Q.useState)(o?0:void 0),[y,b]=(0,Q.useState)(()=>{let e=h[0];if(e&&Bb(e.schema)){let t=l[e.name];return t===void 0?``:String(t)}return``}),[S,C]=(0,Q.useState)(y.length),[T,E]=(0,Q.useState)(()=>new Set),[O,k]=(0,Q.useState)(),[A,j]=(0,Q.useState)(0),M=(0,Q.useRef)(void 0),N=(0,Q.useRef)(new Map),ee=(0,Q.useRef)({buffer:``,timer:void 0});(0,Q.useEffect)(()=>()=>{M.current!==void 0&&clearTimeout(M.current);let e=ee.current;e.timer!==void 0&&clearTimeout(e.timer);for(let e of N.current.values())e.abort();N.current.clear()},[]);let{columns:P,rows:F}=V(),I=g===void 0?void 0:h[g],L=I!==void 0&&Bb(I.schema)&&!Ob(I.schema)&&!s;ap(`elicitation`),ev(`Work Mate needs your input`,`elicitation_dialog`);let te=(0,Q.useCallback)(e=>{if(e===void 0){b(``),C(0);return}let t=h[e];if(t&&Bb(t.schema)&&!Ob(t.schema)){let e=l[t.name],n=e===void 0?``:String(e);b(n),C(n.length)}},[h,l]);function ne(e,t){if(!kb(t))return;let n=l[e]??[],r=h.find(t=>t.name===e)?.isRequired??!1,i=t.minItems,a=t.maxItems;i!==void 0&&n.length<i&&(n.length>0||r)?ie(e,`Select at least ${i} ${yd(i,`item`)}`):a!==void 0&&n.length>a?ie(e,`Select at most ${a} ${yd(a,`item`)}`):ie(e)}function R(e){I&&kb(I.schema)?(ne(I.name,I.schema),k(void 0)):I&&Ob(I.schema)&&k(void 0),L&&I&&(ae(I.name,I.schema,y),M.current!==void 0&&(clearTimeout(M.current),M.current=void 0),Rb(I.schema)&&y.trim()!==``&&p[I.name]&&oe(I.name,I.schema,y));let t=h.length+2,n=g??(s===`accept`?h.length:s===`decline`?h.length+1:void 0),r=n===void 0?0:(n+(e===`up`?t-1:1))%t;r<h.length?(v(r),c(null),te(r)):(v(void 0),c(r===h.length?`accept`:`decline`),b(``))}function z(e,t){d(n=>{let r={...n};return t===void 0?delete r[e]:r[e]=t,r}),t!==void 0&&p[e]===`This field is required`&&ie(e)}function ie(e,t){m(n=>{let r={...n};return t?r[e]=t:delete r[e],r})}function B(e){e&&(z(e,void 0),ie(e),b(``),C(0))}function ae(e,t,n){let r=n.trim();if(r===``&&(t.type!==`string`||`format`in t&&t.format!==void 0)){B(e);return}if(r===``){l[e]!==void 0&&z(e,``);return}let i=Lb(n,t);z(e,i.isValid?i.value:n),ie(e,i.isValid?void 0:i.error)}function oe(e,t,n){if(!r)return;let i=N.current.get(e);i&&i.abort();let a=new AbortController;N.current.set(e,a),E(t=>new Set(t).add(e)),zb(n,t,a.signal).then(t=>{if(N.current.delete(e),E(t=>{let n=new Set(t);return n.delete(e),n}),!a.signal.aborted)if(t.isValid){z(e,t.value),ie(e);let r=String(t.value);b(e=>e===n?(C(r.length),r):e)}else ie(e,t.error)},()=>{N.current.delete(e),E(t=>{let n=new Set(t);return n.delete(e),n})})}function se(e){if(b(e),I&&(ae(I.name,I.schema,e),M.current!==void 0&&(clearTimeout(M.current),M.current=void 0),Rb(I.schema)&&e.trim()!==``&&p[I.name])){let t=I.name,n=I.schema;M.current=setTimeout((e,t,n,r,i)=>{e.current=void 0,t(n,r,i)},2e3,M,oe,t,n,e)}}function H(){R(`down`)}function ce(e,t,n){let r=ee.current;r.timer!==void 0&&clearTimeout(r.timer),r.buffer+=e.toLowerCase(),r.timer=setTimeout(Ub,2e3,r);let i=t.findIndex(e=>e.startsWith(r.buffer));i!==-1&&n(i)}D(`confirm:no`,()=>{if(L&&I){let e=l[I.name];b(e===void 0?``:String(e)),C(0)}t(`cancel`)},{context:`Settings`,isActive:!!I&&!s&&!O}),re((e,n)=>{if(L&&!n.upArrow&&!n.downArrow&&!n.return&&!n.backspace)return;if(O&&I&&kb(I.schema)){let t=I.schema,r=Ab(t),i=l[I.name]??[];if(n.leftArrow||n.escape){k(void 0),ne(I.name,t);return}if(n.upArrow){A===0?(k(void 0),ne(I.name,t)):j(A-1);return}if(n.downArrow){A>=r.length-1?(k(void 0),R(`down`)):j(A+1);return}if(e===` `){let e=r[A];if(e!==void 0){let n=i.includes(e)?i.filter(t=>t!==e):[...i,e],r=n.length>0?n:void 0;z(I.name,r);let a=t.minItems,o=t.maxItems;a!==void 0&&n.length<a&&(n.length>0||I.isRequired)?ie(I.name,`Select at least ${a} ${yd(a,`item`)}`):o!==void 0&&n.length>o?ie(I.name,`Select at most ${o} ${yd(o,`item`)}`):ie(I.name)}return}if(n.return){let e=r[A];e!==void 0&&!i.includes(e)&&z(I.name,[...i,e]),k(void 0),R(`down`);return}if(e){ce(e,r.map(e=>Mb(t,e).toLowerCase()),j);return}return}if(O&&I&&Ob(I.schema)){let t=I.schema,r=Nb(t);if(n.leftArrow||n.escape){k(void 0);return}if(n.upArrow){A===0?k(void 0):j(A-1);return}if(n.downArrow){A>=r.length-1?(k(void 0),R(`down`)):j(A+1);return}if(e===` `){let e=r[A];e!==void 0&&z(I.name,e),k(void 0);return}if(n.return){let e=r[A];e!==void 0&&z(I.name,e),k(void 0),R(`down`);return}if(e){ce(e,r.map(e=>Fb(t,e).toLowerCase()),j);return}return}if(n.return&&s===`accept`){if(le()&&Object.keys(p).length===0)t(`accept`,l);else{let e=a.required||[];for(let t of e)l[t]===void 0&&ie(t,`This field is required`);let t=h.findIndex(t=>e.includes(t.name)&&l[t.name]===void 0||p[t.name]!==void 0);t!==-1&&(v(t),c(null),te(t))}return}if(n.return&&s===`decline`){t(`decline`);return}if(n.upArrow||n.downArrow){let e=ee.current;e.buffer=``,e.timer!==void 0&&(clearTimeout(e.timer),e.timer=void 0),R(n.upArrow?`up`:`down`);return}if(s&&(n.leftArrow||n.rightArrow)){c(s===`accept`?`decline`:`accept`);return}if(!I)return;let{schema:r,name:i}=I,o=l[i];if(r.type===`boolean`){if(e===` `){z(i,o===void 0||!o);return}if(n.return){R(`down`);return}if(n.backspace&&o!==void 0){B(i);return}if(e&&!n.return){ce(e,[`yes`,`no`],e=>z(i,e===0));return}return}if(Ob(r)||kb(r)){if(n.return){R(`down`);return}if(n.backspace&&o!==void 0){B(i);return}let t,a=0;if(Ob(r)){let e=Nb(r);t=e.map(e=>Fb(r,e).toLowerCase()),o!==void 0&&(a=Math.max(0,e.indexOf(o)))}else t=Ab(r).map(e=>Mb(r,e).toLowerCase());if(n.rightArrow){k(i),j(a);return}if(e&&!n.leftArrow){ce(e,t,e=>{k(i),j(e)});return}return}if(n.backspace&&L&&y===``){B(i);return}},{isActive:!0});function le(){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 U=Math.max(2,Math.floor((F-14)/3)),W=(0,Q.useMemo)(()=>{let e=h.length;if(e<=U)return{start:0,end:e};let t=g??e-1,n=Math.max(0,t-Math.floor(U/2)),r=Math.min(n+U,e);return n=Math.max(0,r-U),{start:n,end:r}},[h.length,U,g]),de=W.start>0,fe=W.end<h.length;function pe(){return h.length?(0,$.jsxs)(_,{flexDirection:`column`,children:[de&&(0,$.jsx)(_,{marginLeft:2,children:(0,$.jsxs)(x,{dimColor:!0,children:[u.arrowUp,` `,W.start,` more above`]})}),h.slice(W.start,W.end).map((e,t)=>{let n=W.start+t,{name:r,schema:i,isRequired:a}=e,o=n===g&&!s,c=l[r],d=c!==void 0&&(!Array.isArray(c)||c.length>0),f=p[r],m=T.has(r)?(0,$.jsx)(Wb,{}):f?(0,$.jsx)(x,{color:`error`,children:u.warning}):d?(0,$.jsx)(x,{color:`success`,dimColor:!o,children:u.tick}):a?(0,$.jsx)(x,{color:`error`,children:`*`}):(0,$.jsx)(x,{children:` `}),h=f?`error`:d?`success`:a?`error`:`suggestion`,v=o?h:void 0,b=(0,$.jsx)(x,{color:v,bold:o,children:i.title||r}),w,E=null;if(kb(i)){let e=Ab(i),t=c??[];if(O===r&&o)w=(0,$.jsx)(x,{dimColor:!0,children:u.triangleDownSmall}),E=(0,$.jsx)(_,{flexDirection:`column`,marginLeft:6,children:e.map((e,n)=>{let r=Mb(i,e),a=t.includes(e),o=n===A;return(0,$.jsxs)(_,{gap:1,children:[(0,$.jsx)(x,{color:`suggestion`,children:o?u.pointer:` `}),(0,$.jsx)(x,{color:a?`success`:void 0,children:a?u.checkboxOn:u.checkboxOff}),(0,$.jsx)(x,{color:o?`suggestion`:void 0,bold:o,children:r})]},e)})});else{let e=o?(0,$.jsxs)(x,{dimColor:!0,children:[u.triangleRightSmall,` `]}):null;w=t.length>0?(0,$.jsxs)(x,{children:[e,(0,$.jsx)(x,{color:v,bold:o,children:t.map(e=>Mb(i,e)).join(`, `)})]}):(0,$.jsxs)(x,{children:[e,(0,$.jsx)(x,{dimColor:!0,italic:!0,children:`not set`})]})}}else if(Ob(i)){let e=Nb(i);if(O===r&&o)w=(0,$.jsx)(x,{dimColor:!0,children:u.triangleDownSmall}),E=(0,$.jsx)(_,{flexDirection:`column`,marginLeft:6,children:e.map((e,t)=>{let n=Fb(i,e),r=c===e,a=t===A;return(0,$.jsxs)(_,{gap:1,children:[(0,$.jsx)(x,{color:`suggestion`,children:a?u.pointer:` `}),(0,$.jsx)(x,{color:r?`success`:void 0,children:r?u.radioOn:u.radioOff}),(0,$.jsx)(x,{color:a?`suggestion`:void 0,bold:a,children:n})]},e)})});else{let e=o?(0,$.jsxs)(x,{dimColor:!0,children:[u.triangleRightSmall,` `]}):null;w=d?(0,$.jsxs)(x,{children:[e,(0,$.jsx)(x,{color:v,bold:o,children:Fb(i,c)})]}):(0,$.jsxs)(x,{children:[e,(0,$.jsx)(x,{dimColor:!0,italic:!0,children:`not set`})]})}}else if(i.type===`boolean`)w=o?d?(0,$.jsx)(x,{color:v,bold:!0,children:c?u.checkboxOn:u.checkboxOff}):(0,$.jsx)(x,{dimColor:!0,children:u.checkboxOff}):d?(0,$.jsx)(x,{children:c?u.checkboxOn:u.checkboxOff}):(0,$.jsx)(x,{dimColor:!0,italic:!0,children:`not set`});else if(Bb(i))if(o)w=(0,$.jsx)(Vf,{value:y,onChange:se,onSubmit:H,placeholder:`Type something…`,columns:Math.min(P-20,60),cursorOffset:S,onChangeCursorOffset:C,focus:!0,showCursor:!0});else{let e=d&&Rb(i)?Gb(String(c),i):String(c);w=d?(0,$.jsx)(x,{children:e}):(0,$.jsx)(x,{dimColor:!0,italic:!0,children:`not set`})}else w=d?(0,$.jsx)(x,{children:String(c)}):(0,$.jsx)(x,{dimColor:!0,italic:!0,children:`not set`});return(0,$.jsxs)(_,{flexDirection:`column`,children:[(0,$.jsxs)(_,{gap:1,children:[(0,$.jsx)(x,{color:h,children:o?u.pointer:` `}),m,(0,$.jsxs)(_,{children:[b,(0,$.jsx)(x,{color:v,children:`: `}),w]})]}),E,i.description&&(0,$.jsx)(_,{marginLeft:6,children:(0,$.jsx)(x,{dimColor:!0,children:i.description})}),(0,$.jsx)(_,{marginLeft:6,height:1,children:f?(0,$.jsx)(x,{color:`error`,italic:!0,children:f}):(0,$.jsx)(x,{children:` `})})]},r)}),fe&&(0,$.jsx)(_,{marginLeft:2,children:(0,$.jsxs)(x,{dimColor:!0,children:[u.arrowDown,` `,h.length-W.end,` more below`]})})]}):null}return(0,$.jsx)(ue,{title:`MCP server \u201c${n}\u201d requests your input`,subtitle:`\n${i}`,color:`permission`,onCancel:()=>t(`cancel`),isCancelActive:(!I||!!s)&&!O,inputGuide:e=>e.pending?(0,$.jsxs)(x,{children:[`Press `,e.keyName,` again to exit`]}):(0,$.jsxs)(w,{children:[(0,$.jsx)(Js,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`}),(0,$.jsx)(f,{shortcut:`↑↓`,action:`navigate`}),I&&(0,$.jsx)(f,{shortcut:`Backspace`,action:`unset`}),I&&I.schema.type===`boolean`&&(0,$.jsx)(f,{shortcut:`Space`,action:`toggle`}),I&&Ob(I.schema)&&(O?(0,$.jsx)(f,{shortcut:`Space`,action:`select`}):(0,$.jsx)(f,{shortcut:`→`,action:`expand`})),I&&kb(I.schema)&&(O?(0,$.jsx)(f,{shortcut:`Space`,action:`toggle`}):(0,$.jsx)(f,{shortcut:`→`,action:`expand`}))]}),children:(0,$.jsxs)(_,{flexDirection:`column`,children:[pe(),(0,$.jsxs)(_,{children:[(0,$.jsx)(x,{color:`success`,children:s===`accept`?u.pointer:` `}),(0,$.jsx)(x,{bold:s===`accept`,color:s===`accept`?`success`:void 0,dimColor:s!==`accept`,children:` Accept `}),(0,$.jsx)(x,{color:`error`,children:s===`decline`?u.pointer:` `}),(0,$.jsx)(x,{bold:s===`decline`,color:s===`decline`?`error`:void 0,dimColor:s!==`decline`,children:` Decline`})]})]})})}function Jb({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`),d=(0,Q.useRef)(`prompt`),[p,m]=(0,Q.useState)(`accept`),h=a?.showCancel??!1;ev(`Work Mate needs your input`,`elicitation_url_dialog`),ap(`elicitation-url`),d.current=c;let g=(0,Q.useRef)(n);g.current=n,(0,Q.useEffect)(()=>{let e=()=>{d.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=``,b=``;try{v=new URL(s).hostname;let e=s.indexOf(v);y=s.slice(0,e),b=s.slice(e+v.length)}catch{v=s}(0,Q.useEffect)(()=>{c===`waiting`&&e.completed&&n?.(h?`retry`:`dismiss`)},[c,e.completed,n,h]);let S=(0,Q.useCallback)(()=>{so(s),t(`accept`),l(`waiting`),d.current=`waiting`,m(`open`)},[t,s]);if(re((e,r)=>{if(c===`prompt`){if(r.leftArrow||r.rightArrow){m(e=>e===`accept`?`decline`:`accept`);return}r.return&&(p===`accept`?S():t(`decline`))}else{let e=h?[`open`,`action`,`cancel`]:[`open`,`action`];if(r.leftArrow||r.rightArrow){m(t=>{let n=e.indexOf(t),i=r.rightArrow?1:-1;return e[(n+i+e.length)%e.length]});return}r.return&&(p===`open`?so(s):p===`cancel`?n?.(`cancel`):n?.(h?`retry`:`dismiss`))}}),c===`waiting`){let e=a?.actionLabel??`Continue without waiting`;return(0,$.jsx)(ue,{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)(x,{children:[`Press `,e.keyName,` again to exit`]}):(0,$.jsxs)(w,{children:[(0,$.jsx)(Js,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`}),(0,$.jsx)(f,{shortcut:`\\u2190\\u2192`,action:`switch`})]}),children:(0,$.jsxs)(_,{flexDirection:`column`,children:[(0,$.jsx)(_,{marginBottom:1,flexDirection:`column`,children:(0,$.jsxs)(x,{children:[y,(0,$.jsx)(x,{bold:!0,children:v}),b]})}),(0,$.jsx)(_,{marginBottom:1,children:(0,$.jsx)(x,{dimColor:!0,italic:!0,children:`Waiting for the server to confirm completion…`})}),(0,$.jsxs)(_,{children:[(0,$.jsx)(x,{color:`success`,children:p===`open`?u.pointer:` `}),(0,$.jsx)(x,{bold:p===`open`,color:p===`open`?`success`:void 0,dimColor:p!==`open`,children:` Reopen URL `}),(0,$.jsx)(x,{color:`success`,children:p===`action`?u.pointer:` `}),(0,$.jsx)(x,{bold:p===`action`,color:p===`action`?`success`:void 0,dimColor:p!==`action`,children:` ${e}`}),h&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(x,{children:` `}),(0,$.jsx)(x,{color:`error`,children:p===`cancel`?u.pointer:` `}),(0,$.jsx)(x,{bold:p===`cancel`,color:p===`cancel`?`error`:void 0,dimColor:p!==`cancel`,children:` Cancel`})]})]})]})})}return(0,$.jsx)(ue,{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)(x,{children:[`Press `,e.keyName,` again to exit`]}):(0,$.jsxs)(w,{children:[(0,$.jsx)(Js,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`}),(0,$.jsx)(f,{shortcut:`\\u2190\\u2192`,action:`switch`})]}),children:(0,$.jsxs)(_,{flexDirection:`column`,children:[(0,$.jsx)(_,{marginBottom:1,flexDirection:`column`,children:(0,$.jsxs)(x,{children:[y,(0,$.jsx)(x,{bold:!0,children:v}),b]})}),(0,$.jsxs)(_,{children:[(0,$.jsx)(x,{color:`success`,children:p===`accept`?u.pointer:` `}),(0,$.jsx)(x,{bold:p===`accept`,color:p===`accept`?`success`:void 0,dimColor:p!==`accept`,children:` Accept `}),(0,$.jsx)(x,{color:`error`,children:p===`decline`?u.pointer:` `}),(0,$.jsx)(x,{bold:p===`decline`,color:p===`decline`?`error`:void 0,dimColor:p!==`decline`,children:` Decline`})]})]})})}H(),Ht(),wp(),qm();function Yb({title:e,toolInputSummary:t,request:n,onRespond:r,onAbort:i}){D(`app:interrupt`,i,{isActive:!0});let a=n.options.map(e=>({label:e.label,value:e.key,description:e.description}));return(0,$.jsx)(Ym,{title:e,subtitle:n.message,titleRight:t?(0,$.jsx)(x,{dimColor:!0,children:t}):void 0,children:(0,$.jsx)(_,{flexDirection:`column`,paddingY:1,children:(0,$.jsx)(Tp,{options:a,onChange:e=>{r(e)}})})})}function Xb(){return(0,Q.useSyncExternalStore)(Fn,rn)}pd(),be(),Jl(),Ee();var Zb=`at_mentioned`,Qb=De(()=>ve({method:pe(Zb),params:ve({filePath:ye(),lineStart:_e().optional(),lineEnd:_e().optional()})}));function $b(e,t){let n=(0,Q.useRef)(void 0);(0,Q.useEffect)(()=>{let r=pn(e);n.current!==r&&(n.current=r),r&&r.client.setNotificationHandler(Qb(),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])}Hm(),Wm(),fh();function ex(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])}mm();function tx(){let[e,t]=(0,Q.useState)({...Bn});return(0,Q.useEffect)(()=>{let e=e=>{t({...e})};return Ql.add(e),()=>{Ql.delete(e)}},[]),e}H();function nx({ideSelection:e,mcpClients:t}){let{status:n}=ex(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)(x,{color:`ide`,wrap:`truncate`,children:[`⧉ `,e.lineCount,` `,e.lineCount===1?`line`:`lines`,` selected`]},`selection-indicator`);if(e.filePath)return(0,$.jsxs)(x,{color:`ide`,wrap:`truncate`,children:[`⧉ In `,jh(e.filePath)]},`selection-indicator`)}function rx(){return(0,Q.useSyncExternalStore)(Bi.subscribe,Bi.getState)}H(),nc();function ix({tokenUsage:e,model:t}){let{percentLeft:n,isAboveWarningThreshold:r,isAboveErrorThreshold:i}=Ys(e,t),a=rx();if(!r||a)return null;let o=Uo(),s=el(`warning`),c=`${n}% until auto-compact`;return(0,$.jsx)(_,{flexDirection:`row`,children:o?(0,$.jsx)(x,{dimColor:!0,wrap:`truncate`,children:s?`${c} \u00b7 ${s}`:c}):(0,$.jsx)(x,{color:i?`error`:`warning`,wrap:`truncate`,children:s?`Context low (${n}% remaining) \u00b7 ${s}`:`Context low (${n}% remaining) \u00b7 Run /compact to compact & continue`})})}H(),ws();function ax(){let[e,t]=(0,Q.useState)(0),n=(0,Q.useRef)(null),r=ji(`app:toggleTranscript`,`Global`,`ctrl+o`);return(0,Q.useEffect)(()=>{if(!$t.isSandboxingEnabled())return;let e=$t.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)}},[]),!$t.isSandboxingEnabled()||e===0?null:(0,$.jsx)(_,{paddingX:0,paddingY:0,children:(0,$.jsxs)(x,{color:`inactive`,wrap:`truncate`,children:[`⧈ Sandbox blocked `,e,` `,e===1?`operation`:`operations`,` ·`,` `,r,` for details · /sandbox to disable`]})})}Gf(),Ed(),J(),H(),Qo(),sm(),Jl(),Kn(),Zo();var ox=5e3;function sx({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)(()=>Io(sc(a)),[a]),p=pm(),m=Ys(f,p).isAboveWarningThreshold,{status:h}=ex(l),g=G(e=>e.notifications),{addNotification:v,removeNotification:y}=Wf(),b=tx();(0,Q.useEffect)(()=>(Da((e,t)=>{v({key:`env-hook`,text:e,color:t?`error`:void 0,priority:t?`medium`:`low`,timeoutMs:t?8e3:5e3})}),()=>Da(null)),[v]),h===`connected`&&(c?.filePath||c?.text&&c.lineCount);let S=b.isUsingOverage,C=cm(),w=u&&!m&&e!==`invalid`&&e!==`missing`&&C!==void 0;return(0,Q.useEffect)(()=>{w&&C?v({key:`external-editor-hint`,jsx:(0,$.jsx)(x,{dimColor:!0,children:(0,$.jsx)(Js,{action:`chat:externalEditor`,context:`Chat`,fallback:`ctrl+g`,description:`edit in ${ea(C)}`})}),priority:`immediate`,timeoutMs:5e3}):y(`external-editor-hint`)},[w,C,v,y]),(0,$.jsx)(_,{flexDirection:`column`,alignItems:d?`flex-start`:`flex-end`,flexShrink:0,overflowX:`hidden`,children:(0,$.jsx)(cx,{ideSelection:c,mcpClients:l,notifications:g,isInOverageMode:S??!1,apiKeyStatus:e,debug:n,verbose:i,tokenUsage:f,mainLoopModel:p})})}function cx({ideSelection:e,mcpClients:t,notifications:n,isInOverageMode:r,apiKeyStatus:i,debug:o,verbose:s,tokenUsage:c,mainLoopModel:l}){return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(nx,{ideSelection:e,mcpClients:t}),n.current&&(`jsx`in n.current?(0,$.jsx)(x,{wrap:`truncate`,children:n.current.jsx},n.current.key):(0,$.jsx)(x,{color:n.current.color,dimColor:!n.current.color,wrap:`truncate`,children:n.current.text})),r&&(0,$.jsx)(_,{children:(0,$.jsx)(x,{dimColor:!0,wrap:`truncate`,children:`Now using extra usage`})}),(i===`invalid`||i===`missing`)&&(0,$.jsx)(_,{children:(0,$.jsx)(x,{color:`error`,wrap:`truncate`,children:a(process.env.CLAUDE_CODE_REMOTE)?`Authentication error · Try again`:`Not logged in`})}),o&&(0,$.jsx)(_,{children:(0,$.jsx)(x,{color:`warning`,wrap:`truncate`,children:`Debug mode`})}),i!==`invalid`&&i!==`missing`&&s&&(0,$.jsx)(_,{children:(0,$.jsxs)(x,{dimColor:!0,wrap:`truncate`,children:[c,` tokens`]})}),(0,$.jsx)(ix,{tokenUsage:c,model:l}),(0,$.jsx)(ax,{})]})}Gf(),Zo(),H();var lx=10,ux=null,dx=0,fx;async function px(e,t){let n=Math.ceil(e/lx)*lx;if(ux&&dx>=n&&fx===t)return ux;ux&&await ux,dx=n,fx=t,ux=(async()=>{let e=[],n=0;for await(let r of Jf())if(!(t&&Uf(r.display)!==t)&&(e.push(r),n++,n>=dx))break;return e})();try{return await ux}finally{ux=null,dx=0,fx=void 0}}function mx(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}=Wf(),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?.display)return;let n=Uf(e.display),r=n===`bash`?e.display.slice(1):e.display;y(r,n,e.pastedContents??{},t)},[y]),S=(0,Q.useCallback)(()=>{u({key:`search-history-hint`,jsx:(0,$.jsx)(x,{dimColor:!0,children:(0,$.jsx)(Js,{action:`history:search`,context:`Global`,fallback:`ctrl+r`,description:`search history`})}),priority:`immediate`,timeoutMs:ox})},[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 px(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,S())})()},[b,S]),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])}}J();function hx(){let e=G(e=>e.tasks);return(0,Q.useMemo)(()=>{let t=Date.now();return Object.values(e).filter(Qs).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])}Cf(),tp(),H(),Ht();function gx(e,t,n,r,i,a,o,s,c,l,u){let[d,f]=(0,Q.useState)(``),[p,m]=(0,Q.useState)(!1),[g,_]=(0,Q.useState)(``),[v,y]=(0,Q.useState)(0),[b,x]=(0,Q.useState)(`prompt`),[S,C]=(0,Q.useState)({}),[w,T]=(0,Q.useState)(void 0),O=(0,Q.useRef)(void 0),k=(0,Q.useRef)(new Set),A=(0,Q.useRef)(null),j=(0,Q.useCallback)(()=>{O.current&&(O.current.return(void 0),O.current=void 0)},[]),M=(0,Q.useCallback)(()=>{c(!1),f(``),m(!1),_(``),y(0),x(`prompt`),C({}),T(void 0),j(),k.current.clear()},[c,j]),N=(0,Q.useCallback)(async(e,t)=>{if(s){if(d.length===0){j(),k.current.clear(),T(void 0),m(!1),n(g),r(v),a(b),l(S);return}if(e||(j(),O.current=Yf(),k.current.clear()),O.current)for(;;){if(t?.aborted)return;let e=await O.current.next();if(e.done){m(!0);return}let i=e.value.display,o=i.lastIndexOf(d);if(o!==-1&&!k.current.has(i)){k.current.add(i),T(e.value),m(!1),a(Uf(i)),n(i),l(e.value.pastedContents);let t=Df(i).lastIndexOf(d);r(t===-1?o:t);return}}}},[s,d,j,n,r,a,l,g,v,b,S]),ee=(0,Q.useCallback)(()=>{c(!0),_(t),y(i),x(o),C(u),O.current=Yf(),k.current.clear()},[c,t,i,o,u]),P=(0,Q.useCallback)(()=>{N(!0)},[N]),F=(0,Q.useCallback)(()=>{if(w){let e=Uf(w.display);n(Df(w.display)),a(e),l(w.pastedContents)}else l(S);M()},[w,n,a,l,S,M]),I=(0,Q.useCallback)(()=>{n(g),r(v),l(S),M()},[n,r,l,g,v,S,M]),L=(0,Q.useCallback)(()=>{if(d.length===0)e({display:g,pastedContents:S});else if(w){let t=Uf(w.display),n=Df(w.display);a(t),e({display:n,pastedContents:w.pastedContents})}M()},[d,w,e,a,g,S,M]);D(`history:search`,ee,{context:`Global`,isActive:!s}),h((0,Q.useMemo)(()=>({"historySearch:next":P,"historySearch:accept":F,"historySearch:cancel":I,"historySearch:execute":L}),[P,F,I,L]),{context:`HistorySearch`,isActive:s});let te=e=>{s&&e.key===`backspace`&&d===``&&(e.preventDefault(),I())};re((e,t,n)=>{te(new E(n.keypress))},{isActive:s});let ne=(0,Q.useRef)(N);return ne.current=N,(0,Q.useEffect)(()=>{A.current?.abort();let e=new AbortController;return A.current=e,ne.current(!1,e.signal),()=>{e.abort()}},[d]),{historyQuery:d,setHistoryQuery:f,historyMatch:w,historyFailedMatch:p,handleKeyDown:te}}function _x({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}}H(),Ed(),J();function vx({inputValue:e,isAssistantResponding:t}){let n=G(e=>e.promptSuggestion),r=An(),i=O(),{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)(()=>{Ua(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();({...l&&{generationRequestId:l},...r&&{acceptMethod:n?`tab`:`enter`},...r&&{timeToAcceptMs:i-s},...!r&&{timeToIgnoreMs:i-s},...f.current>0&&{timeToFirstKeystrokeMs:f.current-s}}),p.current,Math.round(e.length/(a?.length||1)*100)/100,t?.skipReset||h()},[d,c,s,a,o,l,h])}}qn(),gu(),xm();var yx=15,bx=1e3,xx=[`|`,`||`,`&&`,`;`];function Sx(e){return typeof e==`object`&&!!e&&`op`in e&&xx.includes(e.op)}function Cx(e){return e.startsWith(`$`)?`variable`:e.includes(`/`)||e.startsWith(`~`)||e.startsWith(`.`)?`file`:`command`}function wx(e){let t=e.findLastIndex(e=>typeof e==`string`);return t===-1?null:{token:e[t],index:t}}function Tx(e,t){if(t===0)return!0;let n=e[t-1];return n!==void 0&&Sx(n)}function Ex(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=Un(n);if(!i.success){let e=n.split(/\s+/),t=e[e.length-1]||``;return{prefix:t,completionType:e.length===1&&!n.includes(` `)?`command`:Cx(t)}}let a=wx(i.tokens);if(!a){let e=i.tokens[i.tokens.length-1];return{prefix:``,completionType:(e&&Sx(e),`command`)}}if(n.endsWith(` `))return{prefix:``,completionType:`file`};let o=Cx(a.token);if(o===`variable`||o===`file`)return{prefix:a.token,completionType:o};let s=Tx(i.tokens,a.index)?`command`:`file`;return{prefix:a.token,completionType:s}}function Dx(e,t){return t===`variable`?`compgen -v ${kc([e.slice(1)])} 2>/dev/null`:t===`file`?`compgen -f ${kc([e])} 2>/dev/null | head -${yx} | while IFS= read -r f; do [ -d "$f" ] && echo "$f/" || echo "$f "; done`:`compgen -c ${kc([e])} 2>/dev/null`}function Ox(e,t){return t===`variable`?`print -rl -- \${(k)parameters[(I)${kc([e.slice(1)])}*]} 2>/dev/null`:t===`file`?`for f in ${kc([e])}*(N[1,${yx}]); do [[ -d "$f" ]] && echo "$f/" || echo "$f "; done`:`print -rl -- \${(k)commands[(I)${kc([e])}*]} 2>/dev/null`}async function kx(e,t,n,r){let i;if(e===`bash`)i=Dx(t,n);else if(e===`zsh`)i=Ox(t,n);else return[];return(await(await qi(i,r,`bash`,{timeout:bx})).result).stdout.split(`
|
|
36
|
+
`).filter(e=>e.trim()).slice(0,yx).map(e=>({id:e,displayText:e,description:void 0,metadata:{completionType:n}}))}async function Ax(e,t,n){let r=Sm();if(r!==`bash`&&r!==`zsh`)return[];try{let{prefix:i,completionType:a}=Ex(e,t);return i?(await kx(r,i,a,n)).map(t=>({...t,metadata:{...t.metadata,inputSnapshot:e}})):[]}catch(e){return Y(`Shell completion failed: ${e}`),[]}}y_();var jx=/[:_-]/g,Mx=null;function Nx(e){if(Mx?.commands===e)return Mx.fuse;let t=new v_(e.filter(e=>!e.isHidden).map(e=>{let t=Mr(e),n=t.split(jx).filter(Boolean);return{descriptionKey:(e.description??``).split(` `).map(e=>Gx(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 Mx={commands:e,fuse:t},t}function Px(e){return typeof e==`object`&&!!e&&`name`in e&&typeof e.name==`string`&&`type`in e}function Fx(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 Ix(e,t){if(!e)return null;let n=Ux(`/${e}`,t);if(n.length===0)return null;let r=e.toLowerCase();for(let t of n){if(!Px(t.metadata))continue;let n=Mr(t.metadata);if(n.toLowerCase().startsWith(r)){let t=n.slice(e.length);if(t)return{suffix:t,fullCommand:n}}}return null}function Lx(e){return e.startsWith(`/`)}function Rx(e){return!(!Lx(e)||!e.includes(` `)||e.endsWith(` `))}function zx(e){return`/${e} `}function Bx(e){let t=Mr(e);return e.type===`prompt`?e.source===`plugin`&&e.pluginInfo?.repository?`${t}:${e.source}:${e.pluginInfo.repository}`:`${t}:${e.source}`:`${t}:${e.type}`}function Vx(e,t){if(!(!t||t.length===0||e===``))return t.find(t=>t.toLowerCase().startsWith(e))}function Hx(e,t){let n=Mr(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:Ni(e))+(e.type===`prompt`&&e.argNames?.length?` (arguments: ${e.argNames.join(`, `)})`:``);return{id:Bx(e),displayText:`/${n}${r}`,tag:i?`workflow`:a,description:o,metadata:e}}function Ux(e,t){if(!Lx(e)||Rx(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:mt(Mr(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=>Bx(e))),a=[],o=[],s=[],c=[],l=[];e.forEach(e=>{i.has(Bx(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)=>Mr(e).localeCompare(Mr(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=>Hx(e))}let r=t.find(e=>e.isHidden&&Mr(e).toLowerCase()===n);r&&t.some(e=>!e.isHidden&&Mr(e).toLowerCase()===n)&&(r=void 0);let i=Nx(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`?mt(Mr(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 Hx(t,Vx(n,t.aliases))});if(r){let e=Bx(r);if(!i.some(t=>t.id===e))return[Hx(r),...i]}return i}function Wx(e,t,n,r,i,a){let o,s;if(typeof e==`string`)o=e,s=t?un(o,n):void 0;else{if(!Px(e.metadata))return;o=Mr(e.metadata),s=e.metadata}let c=zx(o);r(c),i(c.length),t&&s&&(s.type!==`prompt`||(s.argNames??[]).length===0)&&a(c,!0)}function Gx(e){return e.toLowerCase().replace(/[^a-z0-9]/g,``)}function Kx(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}tm(),tp(),gu();var qx=null,Jx=0,Yx=6e4;async function Xx(){let e=Date.now();if(qx&&e-Jx<Yx)return qx;let t=[],n=new Set;try{for await(let e of Jf()){if(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 qx=t,Jx=e,t}function Zx(e){if(!qx)return;let t=qx.indexOf(e);t!==-1&&qx.splice(t,1),qx.unshift(e)}async function Qx(e){if(!e||e.length<2||!e.trim())return null;let t=await Xx();for(let n of t)if(n.startsWith(e)&&n!==e)return{fullCommand:n,suffix:n.slice(e.length)};return null}df(),gu(),Ee(),Pe(),vu();var $x=`slack_search_channels`,eS=new Map,tS=new Set,nS=0,rS=Ae(),iS=rS.subscribe,aS=null,oS=null;function sS(e){return e.find(e=>e.type===`connected`&&e.name.includes(`slack`))}async function cS(e,t){let n=sS(e);if(n?.type!==`connected`)return[];try{let e=(await n.client.callTool({name:$x,arguments:{query:t,limit:20,channel_types:`public_channel,private_channel`}},void 0,{timeout:5e3})).content;return Array.isArray(e)?dS(uS(e.filter(e=>e.type===`text`).map(e=>e.text).join(`
|
|
37
|
+
`))):[]}catch(e){return Y(`Failed to fetch Slack channels: ${e}`),[]}}var lS=De(()=>ve({results:ye()}));function uS(e){let t=e.trim();if(!t.startsWith(`{`))return e;try{let e=lS().safeParse(uu(t));if(e.success)return e.data.results}catch{}return e}function dS(e){let t=[],n=new Set;for(let r of e.split(`
|
|
38
|
+
`)){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 fS(e){return sS(e)!==void 0}function pS(){return nS}function mS(e){let t=[],n=/(^|\s)#([a-z0-9][a-z0-9_-]{0,79})(?=\s|$)/g,r;for(;(r=n.exec(e))!==null;){if(!tS.has(r[2]))continue;let e=r.index+r[1].length;t.push({start:e,end:e+1+r[2].length})}return t}function hS(e){let t=Math.max(e.lastIndexOf(`-`),e.lastIndexOf(`_`));return t>0?e.slice(0,t):e}function gS(e,t){let n,r=0;for(let[i,a]of eS)e.startsWith(i)&&i.length>r&&a.some(e=>e.startsWith(t))&&(n=a,r=i.length);return n}async function _S(e,t){if(!t)return[];let n=hS(t),r=t.toLowerCase(),i=eS.get(n)??gS(n,r);if(!i)if(aS===n&&oS)i=await oS;else{aS=n,oS=cS(e,n),i=await oS,eS.set(n,i);let t=tS.size;for(let e of i)tS.add(e);tS.size!==t&&(nS++,rS.emit()),eS.size>50&&eS.delete(eS.keys().next().value),aS===n&&(aS=null,oS=null)}return i.filter(e=>e.startsWith(r)).sort().slice(0,10).map(e=>({id:`slack-channel-${e}`,displayText:`#${e}`}))}y_(),hm(),q(),Md(),pd();function vS(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 yS=15,bS=60;function xS(e){return jd(e,bS)}function SS(e,t,n=!1){if(!t&&!n)return[];try{let n=e.map(e=>({type:`agent`,displayText:`${e.agentType} (agent)`,description:xS(e.whenToUse),agentType:e.agentType,color:Pn(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 CS(e,t,n,r=!1){if(!e&&!r)return[];let[i,a]=await Promise.all([gm(e,r),Promise.resolve(SS(n,e,r))]),o=i.map(e=>({type:`file`,displayText:e.displayText,description:e.description,path:e.displayText,filename:jh(e.displayText),score:e.metadata?.score})),s=Object.values(t).flat().map(e=>({type:`mcp_resource`,displayText:`${e.server}:${e.uri}`,description:xS(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,yS).map(vS);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 v_(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:yS});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,yS).map(e=>e.source).map(vS)}Gf(),H(),Ed(),vr(),Cf(),cp(),on(),Ht(),Cl(),J(),Md(),qo(),hm();var wS=/^@[\p{L}\p{N}\p{M}_\-./\\()[\]~:]*/u,TS=/^[\p{L}\p{N}\p{M}_\-./\\()[\]~:]+/u,ES=/(@[\p{L}\p{N}\p{M}_\-./\\()[\]~:]*|[\p{L}\p{N}\p{M}_\-./\\()[\]~:]+)$/u,DS=/[\p{L}\p{N}\p{M}_\-./\\()[\]~:]+$/u,OS=/(^|\s)@([\p{L}\p{N}\p{M}_\-./\\()[\]~:]*|"[^"]*"?)$/u,kS=/(^|\s)#([a-z0-9][a-z0-9_-]*)$/;function AS(e){return typeof e==`object`&&!!e&&`type`in e&&(e.type===`directory`||e.type===`file`)}function jS(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 MS(e){let t=e.metadata;return t?.sessionId?`/resume ${t.sessionId}`:`/resume ${e.displayText}`}function NS(e){return e.isQuoted?e.token.slice(2).replace(/"$/,``):e.token.startsWith(`@`)?e.token.substring(1):e.token}function PS(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 FS(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 IS=/(^|\s)@[\w-]*$/;function LS(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 RS=null;async function zS(e,t){try{return RS&&RS.abort(),RS=new AbortController,await Ax(e,t,RS.signal)}catch{return[]}}function BS(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 VS(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(wS);if(a&&a[0].length===i.length){let r=e.substring(t).match(TS),i=r?r[0]:``;return{token:a[0]+i,startPos:n,isQuoted:!1}}}}let i=n?ES:DS,a=r.match(i);if(!a||a.index===void 0)return null;let o=e.substring(t).match(TS),s=o?o[0]:``;return{token:a[0]+s,startPos:a.index,isQuoted:!1}}function HS(e){if(Lx(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 US(e,t){return!e&&t.includes(` `)&&!t.endsWith(` `)}function WS({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:g}=Wf(),_=ji(`chat:thinkingToggle`,`Chat`,`alt+t`),[v,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=Mr(e);return t?t.length:0}))+6},[e]),[S,C]=(0,Q.useState)(void 0),w=G(e=>e.mcp.resources),T=Yi(),D=G(e=>e.promptSuggestion),O=G(e=>!!e.viewingAgentTaskId),A=j(),[M,N]=(0,Q.useState)(void 0),ee=(0,Q.useMemo)(()=>{if(o!==`prompt`||f)return;let t=Fx(i,a);if(!t)return;let n=Ix(t.partialCommand,e);if(n)return{text:n.suffix,fullCommand:n.fullCommand,insertPosition:t.startPos+1+t.partialCommand.length}},[i,a,o,e,f]),P=f?void 0:o===`prompt`?ee:M,F=(0,Q.useRef)(a);F.current=a;let I=(0,Q.useRef)(null),L=(0,Q.useRef)(``),te=(0,Q.useRef)(``),ne=(0,Q.useRef)(``),R=(0,Q.useRef)(``),z=(0,Q.useRef)(l);z.current=l;let ie=(0,Q.useRef)(null),B=(0,Q.useCallback)(()=>{c(()=>({commandArgumentHint:void 0,suggestions:[],selectedSuggestion:-1})),y(`none`),C(void 0),N(void 0)},[c]),ae=(0,Q.useCallback)(async(e,t=!1)=>{I.current=e;let n=await CS(e,w,s,t);if(I.current===e){if(n.length===0){c(()=>({commandArgumentHint:void 0,suggestions:[],selectedSuggestion:-1})),y(`none`),C(void 0);return}c(e=>({commandArgumentHint:void 0,suggestions:n,selectedSuggestion:jS(e.suggestions,e.selectedSuggestion,n)})),y(n.length>0?`file`:`none`),C(void 0)}},[w,c,y,C,s]);(0,Q.useEffect)(()=>(ym(),_m(()=>{let e=I.current;e!==null&&(I.current=null,ae(e,e===``))})),[ae]);let V=W(ae,50),oe=W((0,Q.useCallback)(async e=>{R.current=e;let t=await _S(T.getState().mcp.clients,e);R.current===e&&(c(e=>({commandArgumentHint:void 0,suggestions:t,selectedSuggestion:jS(e.suggestions,e.selectedSuggestion,t)})),y(t.length>0?`slack-channel`:`none`),C(void 0))},[c]),150),se=(0,Q.useCallback)(async(t,n)=>{let r=n??F.current;if(f){V.cancel(),B();return}if(o===`prompt`){let n=Fx(t,r);if(n&&Ix(n.partialCommand,e)){c(()=>({commandArgumentHint:void 0,suggestions:[],selectedSuggestion:-1})),y(`none`),C(void 0);return}}if(o===`bash`&&t.trim()){ne.current=t;let e=await Qx(t);if(ne.current!==t)return;if(e){N({text:e.suffix,fullCommand:e.fullCommand,insertPosition:t.length}),c(()=>({commandArgumentHint:void 0,suggestions:[],selectedSuggestion:-1})),y(`none`),C(void 0);return}else N(void 0)}let i=o===`bash`?null:t.substring(0,r).match(/(^|\s)@([\w-]*)$/);if(i){let e=(i[2]??``).toLowerCase(),t=T.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){V.cancel(),c(e=>({commandArgumentHint:void 0,suggestions:n,selectedSuggestion:jS(e.suggestions,e.selectedSuggestion,n)})),y(`agent`),C(void 0);return}}if(o===`prompt`){let e=t.substring(0,r).match(kS);if(e&&fS(T.getState().mcp.clients)){oe(e[2]);return}else v===`slack-channel`&&(oe.cancel(),B())}let a=t.substring(0,r).match(OS),s=r===t.length&&r>0&&t.length>0&&t[r-1]===` `;if(o===`prompt`&&Lx(t)&&r>0){let e=HS(t);if(e&&e.commandName===`add-dir`&&e.args){let{args:t}=e;if(t.match(/\s+$/)){V.cancel(),B();return}let n=await nm(t);if(n.length>0){c(e=>({suggestions:n,selectedSuggestion:jS(e.suggestions,e.selectedSuggestion,n),commandArgumentHint:void 0})),y(`directory`);return}V.cancel(),B();return}if(e&&e.commandName===`resume`&&e.args!==void 0&&t.includes(` `)){let{args:t}=e,n=(await dc(t,{limit:10})).map(e=>{let t=Hs(e);return{id:`resume-title-${t}`,displayText:e.customTitle,description:Nd(e),metadata:{sessionId:t}}});if(n.length>0){c(e=>({suggestions:n,selectedSuggestion:jS(e.suggestions,e.selectedSuggestion,n),commandArgumentHint:void 0})),y(`custom-title`);return}B();return}}let l=t.substring(0,r);if(o===`prompt`&&Lx(l)&&r>0&&!US(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=Mr(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=Sa(l.slice(n+1));t=Mc(o.argNames,e)}c(()=>({commandArgumentHint:t,suggestions:[],selectedSuggestion:-1})),y(`none`),C(void 0);return}}}let n=Ux(l,e);c(()=>({commandArgumentHint:t,suggestions:n,selectedSuggestion:n.length>0?0:-1})),y(n.length>0?`command`:`none`),n.length>0&&C(b);return}if(v===`command`?(V.cancel(),B()):Lx(l)&&US(s,l)&&c(e=>e.commandArgumentHint?{...e,commandArgumentHint:void 0}:e),v===`custom-title`&&B(),v===`agent`&&z.current.some(e=>e.id?.startsWith(`dm-`))&&(t.substring(0,r).match(/(^|\s)@([\w-]*)$/)||B()),a&&o!==`bash`){let e=VS(t,r,!0);if(e?.token.startsWith(`@`)){let t=NS(e);if($p(t)){te.current=t;let e=await em(t,{maxResults:10});if(te.current!==t)return;if(e.length>0){c(t=>({suggestions:e,selectedSuggestion:jS(t.suggestions,t.selectedSuggestion,e),commandArgumentHint:void 0})),y(`directory`);return}}if(I.current===t)return;V(t,!0);return}}if(v===`file`){let e=VS(t,r,!0);if(e){let t=NS(e);if(I.current===t)return;V(t,!1)}else V.cancel(),B()}if(v===`shell`){let e=z.current[0]?.metadata?.inputSnapshot;(o!==`bash`||t!==e)&&(V.cancel(),B())}},[v,e,c,B,V,oe,o,f,b]);(0,Q.useEffect)(()=>{ie.current!==i&&(L.current!==i&&(L.current=i,I.current=null),ie.current=null,se(i))},[i,se]);let H=(0,Q.useCallback)(async()=>{if(P){if(o===`bash`){t(P.fullCommand),r(P.fullCommand.length),N(void 0);return}let e=Fx(i,a);if(e){let n=i.slice(0,e.startPos),a=i.slice(e.startPos+e.token.length),o=`${n}/${P.fullCommand} ${a}`,s=e.startPos+1+P.fullCommand.length+1;t(o),r(s);return}}if(l.length>0){V.cancel(),oe.cancel();let e=u===-1?0:u,n=l[e];if(v===`command`&&e<l.length){if(n){let e=n.metadata;if(e&&typeof e==`object`&&`name`in e&&`type`in e){let n=`/${Mr(e)} `;t(n+i.slice(a)),r(n.length)}B()}}else if(v===`custom-title`&&l.length>0){if(n){let e=MS(n);t(e),r(e.length),B()}}else if(v===`directory`&&l.length>0){let n=l[e];if(n){let e=Lx(i),o;if(e){let e=i.indexOf(` `),a=i.slice(0,e+1),s=AS(n.metadata)&&n.metadata.type===`directory`?`/`:` `;o=a+n.id+s,t(o),r(o.length),AS(n.metadata)&&n.metadata.type===`directory`?(c(e=>({...e,commandArgumentHint:void 0})),se(o,o.length)):B()}else{let e=VS(i,a,!0)??VS(i,a,!1);if(e){let a=AS(n.metadata)&&n.metadata.type===`directory`,s=BS(i,n.id,e.startPos,e.token.length,a);o=s.newInput,t(o),r(s.cursorPos),a?(c(e=>({...e,commandArgumentHint:void 0})),se(o,s.cursorPos)):B()}else B()}}}else if(v===`shell`&&l.length>0){let n=l[e];if(n){let e=n.metadata;FS(n,i,a,t,r,e?.completionType),B()}}else if(v===`agent`&&l.length>0&&l[e]?.id?.startsWith(`dm-`)){let n=l[e];n&&(LS(n,i,a,IS,t,r),B())}else if(v===`slack-channel`&&l.length>0){let n=l[e];n&&(LS(n,i,a,kS,t,r),B())}else if(v===`file`&&l.length>0){let n=VS(i,a,!0);if(!n){B();return}let s=vm(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=PS({displayText:s,mode:o,hasAtPrefix:c,needsQuotes:!1,isQuoted:n.isQuoted,isComplete:!1});bm(e,i,n.token,n.startPos,t,r),se(i.replace(n.token,e),a)}else if(e<l.length){let a=l[e];if(a){let e=a.displayText.includes(` `);bm(PS({displayText:a.displayText,mode:o,hasAtPrefix:c,needsQuotes:e,isQuoted:n.isQuoted,isComplete:!0}),i,n.token,n.startPos,t,r),B()}}}}else if(i.trim()!==``){let e,n;if(o===`bash`){e=`shell`;let o=await zS(i,a);if(o.length===1){let e=o[0];if(e){let n=e.metadata;FS(e,i,a,t,r,n?.completionType)}n=[]}else n=o}else{e=`file`;let t=VS(i,a,!0);if(t){let e=t.token.startsWith(`@`);n=await CS(e?t.token.substring(1):t.token,w,s,e)}else n=[]}n.length>0&&(c(e=>({commandArgumentHint:void 0,suggestions:n,selectedSuggestion:jS(e.suggestions,e.selectedSuggestion,n)})),y(e),C(void 0))}},[l,u,i,v,e,o,t,r,n,B,a,se,w,c,s,V,oe,P]),ce=(0,Q.useCallback)(()=>{if(u<0||l.length===0)return;let s=l[u];if(v===`command`&&u<l.length)s&&(Wx(s,!0,e,t,r,n),V.cancel(),B());else if(v===`custom-title`&&u<l.length){if(s){let e=MS(s);t(e),r(e.length),n(e,!0),V.cancel(),B()}}else if(v===`shell`&&u<l.length){let e=l[u];if(e){let n=e.metadata;FS(e,i,a,t,r,n?.completionType),V.cancel(),B()}}else if(v===`agent`&&u<l.length&&s?.id?.startsWith(`dm-`))LS(s,i,a,IS,t,r),V.cancel(),B();else if(v===`slack-channel`&&u<l.length)s&&(LS(s,i,a,kS,t,r),oe.cancel(),B());else if(v===`file`&&u<l.length){let e=VS(i,a,!0);if(e&&s){let n=e.token.startsWith(`@`),a=s.displayText.includes(` `);bm(PS({displayText:s.displayText,mode:o,hasAtPrefix:n,needsQuotes:a,isQuoted:e.isQuoted,isComplete:!0}),i,e.token,e.startPos,t,r),V.cancel(),B()}}else if(v===`directory`&&u<l.length&&s){if(Lx(i)){V.cancel(),B();return}let e=VS(i,a,!0)??VS(i,a,!1);if(e){let n=AS(s.metadata)&&s.metadata.type===`directory`,a=BS(i,s.id,e.startPos,e.token.length,n);t(a.newInput),r(a.cursorPos)}V.cancel(),B()}},[l,u,v,e,i,a,o,t,r,n,B,V,oe]),le=(0,Q.useCallback)(()=>{H()},[H]),U=(0,Q.useCallback)(()=>{V.cancel(),oe.cancel(),B(),ie.current=i},[V,oe,B,i]),ue=(0,Q.useCallback)(()=>{c(e=>({...e,selectedSuggestion:e.selectedSuggestion<=0?l.length-1:e.selectedSuggestion-1}))},[l.length,c]),de=(0,Q.useCallback)(()=>{c(e=>({...e,selectedSuggestion:e.selectedSuggestion>=l.length-1?0:e.selectedSuggestion+1}))},[l.length,c]),fe=(0,Q.useMemo)(()=>({"autocomplete:accept":le,"autocomplete:dismiss":U,"autocomplete:previous":ue,"autocomplete:next":de}),[le,U,ue,de]),pe=l.length>0||!!P,me=op();ap(`autocomplete`,pe),k(`Autocomplete`,pe),h(fe,{context:`Autocomplete`,isActive:pe&&!me});function he(e){let n=Uf(e);if(n!==`prompt`&&m){m(n);let i=Df(e);t(i),r(i.length)}else t(e),r(e.length)}let ge=e=>{if(e.key===`right`&&!O){let t=D.text,n=D.shownAt;if(t&&n>0&&i===``){p(),he(t),e.stopImmediatePropagation();return}}if(e.key===`tab`&&!e.shift){if(l.length>0||P)return;let t=D.text,n=D.shownAt;if(t&&n>0&&i===``&&!O){e.preventDefault(),p(),he(t);return}i.trim()===``&&(e.preventDefault(),g({key:`thinking-toggle-hint`,jsx:(0,$.jsxs)(x,{dimColor:!0,children:[`Use `,_,` to toggle thinking`]}),priority:`immediate`,timeoutMs:3e3}));return}if(l.length===0)return;let t=A?.pendingChord!=null;if(e.ctrl&&e.key===`n`&&!t){e.preventDefault(),de();return}if(e.ctrl&&e.key===`p`&&!t){e.preventDefault(),ue();return}e.key===`return`&&!e.shift&&!e.meta&&(e.preventDefault(),ce())};return re((e,t,n)=>{let r=new E(n.keypress);ge(r),r.didStopImmediatePropagation()&&n.stopImmediatePropagation()}),{suggestions:l,selectedSuggestion:u,suggestionType:v,maxColumnWidth:S,commandArgumentHint:d,inlineGhostText:P,handleKeyDown:ge}}jm();var GS={"†":`alt+t`,π:`alt+p`,ø:`alt+o`};function KS(e){return e in GS}eo();function qS(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 JS(e){let t=qS(e);return{nextMode:t,context:vt(e.mode,t,e)}}Vp(),H(),cp(),Ts(),H(),tu(),sm(),Md(),bs(),cp(),tp(),Ts(),H(),Md(),Om(),cp(),hm(),Ts(),H(),tu(),sm(),Md(),St(),H(),Ht(),Zo(),Dm();function YS({currentValue:e,onSelect:t,onCancel:n,isMidConversation:r}){let i=Sp(),[a,o]=(0,Q.useState)(null),s=[{value:`true`,label:`Enabled`,description:`Work Mate will think before responding`},{value:`false`,label:`Disabled`,description:`Work Mate will respond without extended thinking`}];D(`confirm:no`,()=>{a===null?n?.():o(null)},{context:`Confirmation`}),D(`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)(U,{color:`permission`,children:[(0,$.jsxs)(_,{flexDirection:`column`,children:[(0,$.jsxs)(_,{marginBottom:1,flexDirection:`column`,children:[(0,$.jsx)(x,{color:`remember`,bold:!0,children:`Toggle thinking mode`}),(0,$.jsx)(x,{dimColor:!0,children:`Enable or disable thinking for this session.`})]}),a===null?(0,$.jsx)(_,{flexDirection:`column`,marginBottom:1,children:(0,$.jsx)(Tp,{defaultValue:e?`true`:`false`,defaultFocusValue:e?`true`:`false`,options:s,onChange:c,onCancel:n??(()=>{}),visibleOptionCount:2})}):(0,$.jsxs)(_,{flexDirection:`column`,marginBottom:1,gap:1,children:[(0,$.jsx)(x,{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)(x,{color:`warning`,children:`Do you want to proceed?`})]})]}),(0,$.jsx)(x,{dimColor:!0,italic:!0,children:i.pending?(0,$.jsxs)($.Fragment,{children:[`Press `,i.keyName,` again to exit`]}):a===null?(0,$.jsxs)(w,{children:[(0,$.jsx)(f,{shortcut:`Enter`,action:`confirm`}),(0,$.jsx)(Js,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`exit`})]}):(0,$.jsxs)(w,{children:[(0,$.jsx)(f,{shortcut:`Enter`,action:`confirm`}),(0,$.jsx)(Js,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]})})]})}Yo(),vh(),gh();function XS(e,t,n){let r=t;for(let t=0;t<n;t++){let t=ZS(e,r);if(t.equals(r))break;r=t}return r}function ZS(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 QS(e){return`eE$`.includes(e)}function $S(e){return`jkG`.includes(e)||e===`gg`}var eC={"(":[`(`,`)`],")":[`(`,`)`],b:[`(`,`)`],"[":[`[`,`]`],"]":[`[`,`]`],"{":[`{`,`}`],"}":[`{`,`}`],B:[`{`,`}`],"<":[`<`,`>`],">":[`<`,`>`],'"':[`"`,`"`],"'":[`'`,`'`],"`":["`","`"]};function tC(e,t,n,r){if(n===`w`)return nC(e,t,r,Ff);if(n===`W`)return nC(e,t,r,e=>!Rf(e));let i=eC[n];if(i){let[n,a]=i;return n===a?rC(e,t,n,r):iC(e,t,n,a,r)}return null}function nC(e,t,n,r){let i=[];for(let{segment:t,index:n}of Dd().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=>Rf(o(e)),l=e=>r(o(e)),u=e=>Mf(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 rC(e,t,n,r){let i=e.lastIndexOf(`
|
|
39
|
+
`,t-1)+1,a=e.indexOf(`
|
|
40
|
+
`,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 iC(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}}jf(),Od(),xd();function aC(e,t,n,r){let i=XS(t,r.cursor,n);if(i.equals(r.cursor))return;let a=_C(r.cursor,i,t,e,n);yC(e,a.from,a.to,r,a.linewise),r.recordChange({type:`operator`,op:e,motion:t,count:n})}function oC(e,t,n,r,i){let a=i.cursor.findCharacter(n,t,r);if(a===null)return;let o=new Pf(i.cursor.measuredText,a),s=vC(i.cursor,o,t);yC(e,s.from,s.to,i),i.setLastFind(t,n),i.recordChange({type:`operatorFind`,op:e,find:t,char:n,count:r})}function sC(e,t,n,r,i){let a=tC(i.text,i.cursor.offset,n,t===`inner`);a&&(yC(e,a.start,a.end,i),i.recordChange({type:`operatorTextObj`,op:e,objType:n,scope:t,count:r}))}function cC(e,t,n){let r=n.text,i=r.split(`
|
|
41
|
+
`),a=Sd(r.slice(0,n.cursor.offset),`
|
|
42
|
+
`),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(`
|
|
43
|
+
`,c);c=e===-1?r.length:e+1}let l=r.slice(s,c);if(l.endsWith(`
|
|
44
|
+
`)||(l=`${l}\n`),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]===`
|
|
45
|
+
`&&--e;let i=r.slice(0,e)+r.slice(t);n.setText(i||``);let a=Math.max(0,i.length-(kd(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(`
|
|
46
|
+
`);n.setText(r),n.enterInsert(s)}n.recordChange({type:`operator`,op:e,motion:e[0],count:t})}function lC(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-(kd(o).length||1));t.setOffset(Math.min(n,s)),t.recordChange({type:`x`,count:e})}function uC(e,t,n){let r=n.cursor.offset,i=n.text;for(let n=0;n<t&&r<i.length;n++){let t=Ad(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 dC(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=Ad(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 fC(e,t){let n=t.text.split(`
|
|
47
|
+
`),{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(`
|
|
48
|
+
`);t.setText(c),t.setOffset(gC(s,r)+o),t.recordChange({type:`join`,count:e})}function pC(e,t,n){let r=n.getRegister();if(!r)return;let i=r.endsWith(`
|
|
49
|
+
`),a=i?r.slice(0,-1):r;if(i){let r=n.text.split(`
|
|
50
|
+
`),{line:i}=n.cursor.getPosition(),o=e?i+1:i,s=a.split(`
|
|
51
|
+
`),c=[];for(let e=0;e<t;e++)c.push(...s);let l=[...r.slice(0,o),...c,...r.slice(o)],u=l.join(`
|
|
52
|
+
`);n.setText(u),n.setOffset(gC(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=kd(r),c=i+r.length-(s.length||1);n.setText(o),n.setOffset(Math.max(i,c))}}function mC(e,t,n){let r=n.text.split(`
|
|
53
|
+
`),{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(`
|
|
54
|
+
`),s=((r[i]??``).match(/^\s*/)?.[0]??``).length;n.setText(o),n.setOffset(gC(r,i)+s),n.recordChange({type:`indent`,dir:e,count:t})}function hC(e,t){let n=t.text.split(`
|
|
55
|
+
`),{line:r}=t.cursor.getPosition(),i=e===`below`?r+1:r,a=[...n.slice(0,i),``,...n.slice(i)],o=a.join(`
|
|
56
|
+
`);t.setText(o),t.enterInsert(gC(a,i)),t.recordChange({type:`openLine`,direction:e})}function gC(e,t){return e.slice(0,t).join(`
|
|
57
|
+
`).length+ +(t>0)}function _C(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($S(n)){s=!0;let t=e.text,n=t.indexOf(`
|
|
58
|
+
`,o);n===-1?(o=t.length,a>0&&t[a-1]===`
|
|
59
|
+
`&&--a):o=n+1}else QS(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 vC(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 yC(e,t,n,r,i=!1){let a=r.text.slice(t,n);if(i&&!a.endsWith(`
|
|
60
|
+
`)&&(a=`${a}\n`),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-(kd(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 bC(e,t,n){let r=t===1?n.cursor.startOfLastLine():n.cursor.goToLine(t);if(r.equals(n.cursor))return;let i=_C(n.cursor,r,`G`,e,t);yC(e,i.from,i.to,n,i.linewise),n.recordChange({type:`operator`,op:e,motion:`G`,count:t})}function xC(e,t,n){let r=t===1?n.cursor.startOfFirstLine():n.cursor.goToLine(t);if(r.equals(n.cursor))return;let i=_C(n.cursor,r,`gg`,e,t);yC(e,i.from,i.to,n,i.linewise),n.recordChange({type:`operator`,op:e,motion:`gg`,count:t})}var SC={d:`delete`,c:`change`,y:`yank`};function CC(e){return e in SC}var wC=new Set([`h`,`l`,`j`,`k`,`w`,`b`,`e`,`W`,`B`,`E`,`0`,`^`,`$`]),TC=new Set([`f`,`F`,`t`,`T`]),EC={i:`inner`,a:`around`};function DC(e){return e in EC}var OC=new Set([`w`,`W`,`"`,`'`,"`",`(`,`)`,`b`,`[`,`]`,`{`,`}`,`B`,`<`,`>`]),kC=1e4;function AC(){return{mode:`INSERT`,insertedText:``}}function jC(){return{lastChange:null,lastFind:null,register:``,registerIsLinewise:!1}}function MC(e,t,n){switch(e.type){case`idle`:return FC(t,n);case`count`:return IC(e,t,n);case`operator`:return LC(e,t,n);case`operatorCount`:return RC(e,t,n);case`operatorFind`:return zC(e,t,n);case`operatorTextObj`:return BC(e,t,n);case`find`:return VC(e,t,n);case`g`:return HC(e,t,n);case`operatorG`:return UC(e,t,n);case`replace`:return WC(e,t,n);case`indent`:return GC(e,t,n)}}function NC(e,t,n){return CC(e)?{next:{type:`operator`,op:SC[e],count:t}}:wC.has(e)?{execute:()=>{let r=XS(e,n.cursor,t);n.setOffset(r.offset)}}:TC.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:()=>dC(t,n)}:e===`x`?{execute:()=>lC(t,n)}:e===`J`?{execute:()=>fC(t,n)}:e===`p`||e===`P`?{execute:()=>pC(e===`p`,t,n)}:e===`D`?{execute:()=>aC(`delete`,`$`,1,n)}:e===`C`?{execute:()=>aC(`change`,`$`,1,n)}:e===`Y`?{execute:()=>cC(`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:()=>KC(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:()=>hC(`below`,n)}:e===`O`?{execute:()=>hC(`above`,n)}:null}function PC(e,t,n,r){return DC(n)?{next:{type:`operatorTextObj`,op:e,count:t,scope:EC[n]}}:TC.has(n)?{next:{type:`operatorFind`,op:e,count:t,find:n}}:wC.has(n)?{execute:()=>aC(e,n,t,r)}:n===`G`?{execute:()=>bC(e,t,r)}:n===`g`?{next:{type:`operatorG`,op:e,count:t}}:null}function FC(e,t){return/[1-9]/.test(e)?{next:{type:`count`,digits:e}}:e===`0`?{execute:()=>t.setOffset(t.cursor.startOfLogicalLine().offset)}:NC(e,1,t)||{}}function IC(e,t,n){if(/[0-9]/.test(t)){let n=e.digits+t;return{next:{type:`count`,digits:String(Math.min(parseInt(n,10),kC))}}}return NC(t,parseInt(e.digits,10),n)||{next:{type:`idle`}}}function LC(e,t,n){return t===e.op[0]?{execute:()=>cC(e.op,e.count,n)}:/[0-9]/.test(t)?{next:{type:`operatorCount`,op:e.op,count:e.count,digits:t}}:PC(e.op,e.count,t,n)||{next:{type:`idle`}}}function RC(e,t,n){if(/[0-9]/.test(t)){let n=e.digits+t,r=Math.min(parseInt(n,10),kC);return{next:{...e,digits:String(r)}}}let r=parseInt(e.digits,10),i=e.count*r;return PC(e.op,i,t,n)||{next:{type:`idle`}}}function zC(e,t,n){return{execute:()=>oC(e.op,e.find,t,e.count,n)}}function BC(e,t,n){return OC.has(t)?{execute:()=>sC(e.op,e.scope,t,e.count,n)}:{next:{type:`idle`}}}function VC(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 HC(e,t,n){return t===`j`||t===`k`?{execute:()=>{let r=XS(`g${t}`,n.cursor,e.count);n.setOffset(r.offset)}}:t===`g`?e.count>1?{execute:()=>{let t=n.text.split(`
|
|
61
|
+
`),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 UC(e,t,n){return t===`j`||t===`k`?{execute:()=>aC(e.op,`g${t}`,e.count,n)}:t===`g`?{execute:()=>xC(e.op,e.count,n)}:{next:{type:`idle`}}}function WC(e,t,n){return t===``?{next:{type:`idle`}}:{execute:()=>uC(t,e.count,n)}}function GC(e,t,n){return t===e.dir?{execute:()=>mC(e.dir,e.count,n)}:{next:{type:`idle`}}}function KC(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)}jf(),Od();function qC(e){let t=Q.useRef(AC()),[n,r]=(0,Q.useState)(`INSERT`),i=Q.useRef(jC()),a=Af({...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]!==`
|
|
62
|
+
`&&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=Pf.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`:lC(t.count,r);break;case`replace`:uC(t.char,t.count,r);break;case`toggleCase`:dC(t.count,r);break;case`indent`:mC(t.dir,t.count,r);break;case`join`:fC(t.count,r);break;case`openLine`:hC(t.direction,r);break;case`operator`:aC(t.op,t.motion,t.count,r);break;case`operatorFind`:oC(t.op,t.find,t.char,t.count,r);break;case`operatorTextObj`:sC(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=Pf.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,-(kd(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=MC(i.command,h,p);g.execute&&g.execute(),t.current.mode===`NORMAL`&&(g.next?t.current={mode:`NORMAL`,command:g.next}:g.execute&&(t.current={mode:`NORMAL`,command:{type:`idle`}})),c===`?`&&i.mode===`NORMAL`&&i.command.type===`idle`&&e.onChange(`?`)}let p=(0,Q.useCallback)(e=>{e===`INSERT`?t.current={mode:`INSERT`,insertedText:``}:t.current={mode:`NORMAL`,command:{type:`idle`}},r(e),o?.(e)},[o]);return{...a,onInput:f,mode:n,setMode:p}}R(),H();function JC(e){let[t]=g(),n=O();Tf(n,!!e.onImagePaste);let r=qC({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?L.inverse:e=>e,themeText:ie(`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)(_,{flexDirection:`column`,children:(0,$.jsx)(zf,{inputState:r,terminalFocus:n,highlights:e.highlights,...e})})}Oi(),$m(),o();function YC(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 XC(e){return`${e.input_tokens}|${e.cache_creation_input_tokens}|${e.cache_read_input_tokens}`}function ZC(e){let t=zh(`sha256`).update(e).digest(`hex`).slice(0,16);return Rh(i(),`cache-stats`,`${t}.json`)}var QC={version:1,signature:null,lastResetAt:null,lastHitRate:null};function $C(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 ew(e){try{let t=await Gh(e,`utf8`),n=JSON.parse(t);return $C(n)?n:{...QC}}catch{return{...QC}}}async function tw(e,t){await Wh(Lh(e),{recursive:!0});let n=`${e}.${process.pid}.tmp`;try{await qh(n,JSON.stringify(t),`utf8`),await Kh(n,e)}catch{}}var nw={signature:null,lastResetAt:null,lastHitRate:null},rw=null;async function iw(e){rw=e;let t=await ew(ZC(e));nw={signature:t.signature,lastResetAt:t.lastResetAt,lastHitRate:t.lastHitRate}}function aw(e){let t=XC(e),n=YC(e);return t!==nw.signature&&(nw={signature:t,lastResetAt:Date.now(),lastHitRate:n},rw!==null&&tw(ZC(rw),{version:1,signature:t,lastResetAt:nw.lastResetAt,lastHitRate:n})),{...nw}}function ow(){return{...nw}}H(),Md(),Ts();function sw(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 cw(){return(0,$.jsx)(x,{dimColor:!0,children:` │ `})}function lw({modelName:e,contextUsedPct:t,usedTokens:n,contextWindowSize:r,totalCostUsd:i,rateLimits:a}){let{columns:o}=V(),[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=`${Pd(n)}/${Pd(r)}`;return(0,$.jsxs)(_,{children:[(0,$.jsx)(x,{children:u}),(0,$.jsx)(cw,{}),(0,$.jsx)(x,{dimColor:!0,children:`Context `}),(0,$.jsxs)(x,{children:[t,`%`]}),!d&&(0,$.jsxs)(x,{dimColor:!0,children:[` (`,g,`)`]}),f&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(cw,{}),(0,$.jsx)(x,{dimColor:!0,children:`Session `}),(0,$.jsxs)(x,{children:[m,`%`]}),!d&&a.five_hour.resets_at>0&&(0,$.jsxs)(x,{dimColor:!0,children:[` `,sw(a.five_hour.resets_at)]})]}),p&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(cw,{}),(0,$.jsx)(x,{dimColor:!0,children:`Weekly `}),(0,$.jsxs)(x,{children:[h,`%`]}),!d&&a.seven_day.resets_at>0&&(0,$.jsxs)(x,{dimColor:!0,children:[` `,sw(a.seven_day.resets_at)]})]}),i>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(cw,{}),(0,$.jsx)(x,{children:Ns(i)})]})]})}var uw=Q.memo(lw);Ed(),J(),Ie(),Gf(),Po(),mm(),bn(),H(),vi(),td(),Bd(),tu(),gu(),Zs(),Kn(),Ud(),qo(),bo(),Md();var dw=3600*1e3;function fw(e){return String(Math.floor(e)).padStart(2,`0`)}function pw(e){if(e<=0)return`exp`;let t=Math.floor(e/6e4),n=Math.floor(e%6e4/1e3);return`${fw(t)}:${fw(n)}`}function mw({messages:e}){let[t,n]=(0,Q.useState)(()=>Date.now()),[r,i]=(0,Q.useState)(!0),a=Rs(e),o=(0,Q.useRef)(null);if(a!==null){let e=XC(a);e!==o.current&&(o.current=e,aw(a))}let{lastResetAt:s,lastHitRate:c}=ow(),l=s===null?null:t-s,u=l===null?null:dw-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,iw(qe()))},[]);let h=a===null?c:YC(a);if(h===null&&s===null)return(0,$.jsx)(x,{dimColor:!0,children:` Cache --% --:--`});let g=u===null?`--:--`:pw(u),_=h===null?`--%`:`${h}%`,v;return v=f||d===null?`inactive`:d<20?`success`:d<40?`warning`:`error`,(0,$.jsxs)(x,{children:[(0,$.jsx)(x,{dimColor:!0,children:` Cache `}),(0,$.jsx)(x,{color:h!==null&&h>=50?`success`:`inactive`,children:_}),(0,$.jsxs)(x,{color:v,dimColor:p&&!r,children:[` `,g]})]})}function hw(){return null}function gw(e){return e?.statusLineEnabled===!1?!1:e?.statusLineEnabled===!0||!!e?.statusLine?.command}function _w(e,t,n,r,i,a,o){let s=He(),c=Gl(),l=qd({permissionMode:e,mainLoopModel:a,exceeds200kTokens:t}),u=n?.outputStyle||`default`,d=Rs(r),f=Hd(l,tt()),p=Ld(d,f),m=Ao(qe()),h=ur(),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{...Cr(),...m&&{session_name:m},model:{id:l,display_name:Vd(l)},workspace:{current_dir:nu(),project_dir:et(),added_dirs:i},version:`0.0.25`,output_style:{name:u},cost:{total_cost_usd:Xe(),total_duration_ms:Ke(),total_api_duration_ms:Ye(),total_lines_added:st(),total_lines_removed:Je()},context_window:{total_input_tokens:nt(),total_output_tokens:at(),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},...Xm()&&{vim:{mode:o??`INSERT`}},...s&&{agent:{name:s}},...c&&{worktree:{name:c.worktreeName,path:c.worktreePath,branch:c.worktreeBranch,original_cwd:c.originalCwd,original_branch:c.originalBranch}}}}function vw(e){return Ka(e)?.uuid??null}function yw({messagesRef:e,lastAssistantMessageId:t,vimMode:n}){let r=(0,Q.useRef)(void 0),i=G(e=>e.toolPermissionContext.mode),a=G(e=>e.toolPermissionContext.additionalWorkingDirectories),o=G(e=>e.statusLineText),s=An(),c=zn(),{addNotification:l}=Wf(),u=pm(),d=(0,Q.useRef)(c);d.current=c;let f=(0,Q.useRef)(n);f.current=n;let m=(0,Q.useRef)(i);m.current=i;let h=(0,Q.useRef)(a);h.current=a;let g=(0,Q.useRef)(u);g.current=u;let v=(0,Q.useRef)({messageId:null,exceeds200kTokens:!1,permissionMode:i,vimMode:n,mainLoopModel:u}),y=(0,Q.useRef)(void 0),b=(0,Q.useRef)(!0),S=(0,Q.useCallback)(async()=>{r.current?.abort();let t=new AbortController;r.current=t;let n=e.current,i=b.current;if(b.current=!1,d.current?.statusLine?.command)try{let e=v.current.exceeds200kTokens,r=vw(n);r!==v.current.messageId&&(e=Kc(n),v.current.messageId=r,v.current.exceeds200kTokens=e);let a=await ma(_w(m.current,e,d.current,n,Array.from(h.current.keys()),g.current,f.current),t.signal,void 0,i);t.signal.aborted||s(e=>e.statusLineText===a?e:{...e,statusLineText:a})}catch{}},[e,s]),C=(0,Q.useCallback)(()=>{y.current!==void 0&&clearTimeout(y.current),y.current=setTimeout((e,t)=>{e.current=void 0,t()},300,y,S)},[S]);(0,Q.useEffect)(()=>{(t!==v.current.messageId||i!==v.current.permissionMode||n!==v.current.vimMode||u!==v.current.mainLoopModel)&&(v.current.permissionMode=i,v.current.vimMode=n,v.current.mainLoopModel=u,C())},[t,i,n,u,C]);let w=c?.statusLine?.command,T=(0,Q.useRef)(!0);(0,Q.useEffect)(()=>{if(T.current){T.current=!1;return}b.current=!0,S()},[w,S]),(0,Q.useEffect)(()=>{let e=c?.statusLine;e&&(e.command.length,e.padding,c.disableAllHooks===!0&&Y(`Status line is configured but disableAllHooks is true`,{level:`warn`}),id()||(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)(()=>(S(),()=>{r.current?.abort(),y.current!==void 0&&clearTimeout(y.current)}),[]);let E=c?.statusLine?.padding??0,D=qd({permissionMode:i,mainLoopModel:u,exceeds200kTokens:v.current.exceeds200kTokens}),O=Hd(D,tt()),k=Rs(e.current),A=k?k.input_tokens+k.cache_creation_input_tokens+k.cache_read_input_tokens:0,j=k?Math.round(Ld(k,O).used??0):0,M=ur(),N={...M.five_hour&&{five_hour:{utilization:M.five_hour.utilization,resets_at:M.five_hour.resets_at}},...M.seven_day&&{seven_day:{utilization:M.seven_day.utilization,resets_at:M.seven_day.resets_at}}},ee=c?.statusLineEnabled===!0,P=!!c?.statusLine?.command;return(0,$.jsxs)(_,{flexDirection:`column`,paddingX:E,children:[ee&&(0,$.jsxs)(_,{gap:2,children:[(0,$.jsx)(uw,{modelName:Vd(D),contextUsedPct:j,usedTokens:A,contextWindowSize:O,totalCostUsd:Xe(),rateLimits:N}),(0,$.jsx)(hw,{}),(0,$.jsx)(mw,{messages:e.current})]}),o?(0,$.jsx)(x,{dimColor:!0,wrap:`truncate`,children:(0,$.jsx)(p,{children:o})}):P&&xr()?(0,$.jsx)(x,{children:` `}):null]})}var bw=(0,Q.memo)(yw);l(),J(),$s(),H();function xw({tasksSelected:e,onOpenDialog:t}){let n=G(e=>e.tasks),r=(0,Q.useMemo)(()=>Object.values(n??{}).filter(e=>Wa(e)),[n]);return hh(n??{},!1)||r.length===0?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Sw,{selected:e,onClick:t,children:Ec(r)}),as(r)&&(0,$.jsxs)(x,{dimColor:!0,children:[` · `,u.arrowDown,` to view`]})]})}function Sw({selected:e,onClick:t,children:n}){let[r,i]=(0,Q.useState)(!1),a=(0,$.jsx)(x,{color:`background`,inverse:e||r,children:n});return t?(0,$.jsx)(_,{onClick:t,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),children:a}):a}H(),If();function Cw({value:e,onChange:t,historyFailedMatch:n}){return(0,$.jsxs)(_,{gap:1,children:[(0,$.jsx)(x,{dimColor:!0,children:n?`no matching prompt:`:`search prompts:`}),(0,$.jsx)(Vf,{value:e,onChange:t,cursorOffset:e.length,onChangeCursorOffset:()=>{},columns:m(e)+1,focus:!0,showCursor:!0,multiline:!1,dimColor:!0})]})}ad(),vu();var ww=5e3;function Tw(e,t){if(e)return`draft`;switch(t){case`APPROVED`:return`approved`;case`CHANGES_REQUESTED`:return`changes_requested`;default:return`pending`}}async function Ew(){if(!await Ou())return null;let[e,t]=await Promise.all([Wu(),yu()]);if(e===t)return null;let{stdout:n,code:r}=await od(`gh`,[`pr`,`view`,`--json`,`number,url,reviewDecision,isDraft,headRefName,state`],{timeout:ww,preserveOutputOnError:!1});if(r!==0||!n.trim())return null;try{let e=uu(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:Tw(e.isDraft,e.reviewDecision)}}catch{return null}}Ie();var Dw=6e4,Ow=4e3,kw=60*6e4,Aw={number:null,url:null,reviewState:null,lastUpdated:0};function jw(e,t=!0){let[n,r]=(0,Q.useState)(Aw),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=ct();if(n!==t)n=t,s=Date.now();else if(Date.now()-s>=kw)return;let l=Date.now(),u=await Ew();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>Ow){a.current=!0;return}e||(i.current=setTimeout(c,Dw))}}let l=Date.now()-o.current;return l>=Dw?c():i.current=setTimeout(c,Dw-l),()=>{e=!0,i.current&&(clearTimeout(i.current),i.current=null)}},[e,t]),n}H(),$m(),Cl(),Uu(),Yo(),Su(),vh(),J(),Ts(),Md(),xs(),Ud(),pf(),td(),wd(),Zt();var Mw=()=>null,Nw=5e3,Pw=1e3;function Fw(){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=Id(e*1024*1024);t(e=>e?.text===r?e:{text:r,level:n})}e();let n=setInterval(e,Nw);return()=>clearInterval(n)},[]),e}function Iw(){let e=(0,Q.useSyncExternalStore)(fn,os,Mw),[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)(x,{dimColor:!0,children:[`waiting `,Fd(t*1e3,{mostSignificantOnly:!0})]})}function Lw(){let[t,n]=(0,Q.useState)(0);(0,Q.useEffect)(()=>{let e=setInterval(()=>n(e=>e+1),Pw);return()=>clearInterval(e)},[]);let r=(ll(),e(fo)),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)(x,{color:d,children:[`goal (`,u,`)`]})}function Rw({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)(x,{dimColor:!0,children:[`Press `,e.key,` again to exit`]},`exit-message`);if(c)return(0,$.jsx)(x,{dimColor:!0,children:`Pasting text…`},`pasting-message`);let m=Xm()&&t===`INSERT`&&!l;return(0,$.jsxs)(_,{justifyContent:`flex-start`,gap:1,children:[l&&(0,$.jsx)(Cw,{value:u,onChange:d,historyFailedMatch:f}),m?(0,$.jsx)(x,{dimColor:!0,children:`-- INSERT --`},`vim-insert`):null,(0,$.jsx)(zw,{mode:n,toolPermissionContext:r,showHint:!i&&!m,isLoading:a,tasksSelected:o,tmuxSelected:s,onOpenTasksDialog:p})]})}function zw({mode:t,toolPermissionContext:n,showHint:r,isLoading:i,tasksSelected:a,tmuxSelected:o,onOpenTasksDialog:s}){let{columns:c}=V(),l=ji(`chat:cycleMode`,`Chat`,`shift+tab`),u=G(e=>e.tasks);Yi();let d=jw(i,Vw()),p=(0,Q.useSyncExternalStore)(fn,os,Mw),m=I(),h=ae().getState,g=p!==null,v=(0,Q.useMemo)(()=>Fu(Object.values(u),e=>Wa(e)),[u]),y=Fp(),b=y!==void 0&&y.length>0,S=ji(`chat:cancel`,`Chat`,`esc`).toLowerCase(),C=ji(`app:toggleTodos`,`Global`,`ctrl+t`),T=ji(`chat:killAgents`,`Chat`,`ctrl+x ctrl+k`),E=G(e=>e.notifications.current?.key===`kill-agents-confirm`),D=Fw(),O=(0,Q.useMemo)(()=>Vd(Jd()),[G(e=>e.mainLoopModel)]),k=ff();if(t===`bash`)return(0,$.jsx)(x,{color:`bashBorder`,children:`! for bash mode`});let A=n?.mode,j=!ku(A),M=v>0,N=+!!j+ +!!M,ee=Vw()&&d.number!==null&&d.reviewState!==null&&d.url!==null&&N<2&&(N===0||c>=80),P=N<2,F=A&&j?(0,$.jsxs)(x,{color:bu(A),children:[wu(A),` `,Du(A).toLowerCase(),` on`,P&&(0,$.jsxs)(x,{dimColor:!0,children:[` `,(0,$.jsx)(f,{shortcut:l,action:`cycle`,parens:!0})]})]},`mode`):null,L=[...ee?[(0,$.jsx)(ki,{number:d.number,url:d.url,reviewState:d.reviewState},`pr-status`)]:[],...D?[(0,$.jsxs)(x,{dimColor:D.level===`normal`,color:D.level===`error`?`error`:D.level===`warning`?`warning`:void 0,children:[D.text,` · pid:`,process.pid,` · `,O,k?` · ${k}`:``]},`rss`)]:[],...(ll(),e(fo)).getGoal()?[(0,$.jsx)(Lw,{},`goal-elapsed`)]:[]],te=Object.values(u).some(e=>e.type===`local_agent`&&e.status===`running`),ne=r?Bw(i,S,C,T,b,te,E):[];g?L.push((0,$.jsx)(Iw,{},`proactive`)):r&&L.push(...ne);let R=M&&!hh(u,!1)?(0,$.jsx)(xw,{tasksSelected:a,onOpenDialog:s}):null;L.length===0&&!R&&!F&&r&&L.push((0,$.jsx)(x,{dimColor:!0,children:`? for shortcuts`},`shortcuts-hint`));let re=rd().copyOnSelect??!0,ie=m&&(!re||z());if(xr()&&ie){let e=Td()===`macos`,t=e&&(h()?.lastPressHadAlt??!1);L.push((0,$.jsx)(x,{dimColor:!0,children:(0,$.jsxs)(w,{children:[!re&&(0,$.jsx)(f,{shortcut:`ctrl+c`,action:`copy`}),z()&&(t?(0,$.jsx)(x,{children:`set macOptionClickForcesSelection in VS Code settings`}):(0,$.jsx)(f,{shortcut:e?`option+click`:`shift+click`,action:`native select`}))]})},`selection-copy`))}return R&&r&&L.push((0,$.jsx)(x,{dimColor:!0,children:a?(0,$.jsx)(f,{shortcut:`Enter`,action:`view tasks`}):(0,$.jsx)(f,{shortcut:`↓`,action:`manage`})},`manage-tasks`)),L.length===0&&!R&&!F?xr()?(0,$.jsx)(x,{children:` `}):null:(0,$.jsxs)(_,{height:1,overflow:`hidden`,children:[F&&(0,$.jsxs)(_,{flexShrink:0,children:[F,(R||L.length>0)&&(0,$.jsx)(x,{dimColor:!0,children:` · `})]}),R&&(0,$.jsxs)(_,{flexShrink:0,children:[R,L.length>0&&(0,$.jsx)(x,{dimColor:!0,children:` · `})]}),L.length>0&&(0,$.jsx)(x,{wrap:`truncate`,children:(0,$.jsx)(w,{children:L})})]})}function Bw(e,t,n,r,i,a,o){let s=i;return[...e?[(0,$.jsx)(x,{dimColor:!0,children:(0,$.jsx)(f,{shortcut:t,action:`interrupt`})},`esc`)]:[],...!e&&a&&!o?[(0,$.jsx)(x,{dimColor:!0,children:(0,$.jsx)(f,{shortcut:r,action:`stop agents`})},`kill-agents`)]:[],...s?[(0,$.jsx)(x,{dimColor:!0,children:(0,$.jsx)(f,{shortcut:n,action:`show tasks`})},`toggle-tasks`)]:[]]}function Vw(){return rd().prStatusFooterEnabled??!0}bn(),Ts(),H(),xs(),rm(),Qm();function Hw({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:v,tmuxSelected:y,ideSelection:b,mcpClients:x,isPasting:S=!1,isInputWrapped:C=!1,messages:w,isSearching:T,historyQuery:E,setHistoryQuery:D,historyFailedMatch:O,onOpenTasksDialog:k}){let A=zn(),{columns:j,rows:M}=V(),N=(0,Q.useRef)(w);N.current=w;let ee=(0,Q.useMemo)(()=>vw(w),[w]),P=j<80,F=xr(),I=F&&M<24,L=v,te=h||gw(A)||T;return oh((0,Q.useMemo)(()=>F&&u.length?{suggestions:u,selectedSuggestion:d,maxColumnWidth:f}:null,[F,u,d,f])),u.length&&!F?(0,$.jsx)(_,{paddingX:2,paddingY:0,children:(0,$.jsx)(im,{suggestions:u,selectedSuggestion:d,maxColumnWidth:f})}):m?(0,$.jsx)(eh,{dimColor:!0,fixedWidth:!0,paddingX:2}):(0,$.jsxs)(_,{flexDirection:P?`column`:`row`,justifyContent:P?`flex-start`:`space-between`,paddingX:2,gap:+!P,children:[(0,$.jsxs)(_,{flexDirection:`column`,flexShrink:+!P,children:[i===`prompt`&&!I&&!n.show&&!S&&gw(A)&&(0,$.jsx)(bw,{messagesRef:N,lastAssistantMessageId:ee,vimMode:r}),(0,$.jsx)(Ww,{}),(0,$.jsx)(Rw,{exitMessage:n,vimMode:r,mode:i,toolPermissionContext:p,suppressHint:te,isLoading:g,tasksSelected:L,tmuxSelected:y,isPasting:S,isSearching:T,historyQuery:E,setHistoryQuery:D,historyFailedMatch:O,onOpenTasksDialog:k})]}),(0,$.jsx)(_,{flexShrink:1,gap:1,children:F?null:(0,$.jsx)(sx,{apiKeyStatus:e,autoUpdaterResult:a,debug:t,isAutoUpdating:o,verbose:s,messages:w,onAutoUpdaterResult:c,onChangeIsUpdating:l,ideSelection:b,mcpClients:x,isInputWrapped:C,isNarrow:P})})]})}var Uw=(0,Q.memo)(Hw);function Ww(){return null}l(),H();function Gw({isLoading:e}){return(0,$.jsxs)(x,{dimColor:e,children:[u.pointer,`\xA0`]})}function Kw({mode:e,isLoading:t}){return(0,$.jsx)(_,{alignItems:`flex-start`,alignSelf:`flex-start`,flexWrap:`nowrap`,justifyContent:`flex-start`,children:e===`bash`?(0,$.jsx)(x,{color:`bashBorder`,dimColor:t,children:`!\xA0`}):(0,$.jsx)(Gw,{isLoading:t})})}H();var qw=Q.createContext(void 0),Jw=2;function Yw({isFirst:e,children:t}){let n=Jw,r=Q.useMemo(()=>({isQueued:!0,isFirst:e,paddingWidth:n*2}),[e,n]);return(0,$.jsx)(qw.Provider,{value:r,children:(0,$.jsx)(_,{paddingX:n,children:t})})}H(),J(),Tt(),Kn(),vu(),zo();var Xw=new Set;function Zw(e){try{return uu(e)?.type===`idle_notification`}catch{return!1}}var Qw=3;function $w(e){return`<${sd}>
|
|
63
|
+
<${dd}>+${e} more tasks completed</${dd}>
|
|
64
|
+
<${ud}>completed</${ud}>
|
|
65
|
+
</${sd}>`}function eT(e){let t=e.filter(e=>typeof e.value!=`string`||!Zw(e.value)),n=t.filter(e=>e.mode===`task-notification`),r=t.filter(e=>e.mode!==`task-notification`);if(n.length<=Qw)return[...r,...n];let i=n.slice(0,Qw-1),a={value:$w(n.length-(Qw-1)),mode:`task-notification`};return[...r,...i,a]}function tT(){let e=Xb(),t=G(e=>!!e.viewingAgentTaskId),n=(0,Q.useMemo)(()=>{if(e.length===0)return null;let t=e.filter(gr);return t.length===0?null:Ps(eT(t).map(e=>{let t=e.value;return e.mode===`bash`&&typeof t==`string`&&(t=`<bash-input>${t}</bash-input>`),Al({content:t})}))},[e]);return t||n===null?null:(0,$.jsx)(_,{marginTop:1,flexDirection:`column`,children:n.map((e,t)=>(0,$.jsx)(Yw,{isFirst:t===0,children:(0,$.jsx)(fl,{message:e,lookups:Aa,addMargin:!1,tools:[],commands:[],verbose:!1,inProgressToolUseIDs:Xw,progressMessagesForMessage:[],shouldAnimate:!1,shouldShowDot:!1,isTranscriptMode:!1,isStatic:!0})},t))})}var nT=Q.memo(tT);jn(),l(),H();function rT({hasStash:e}){return e?(0,$.jsx)(_,{paddingLeft:2,children:(0,$.jsxs)(x,{dimColor:!0,children:[u.pointerSmall,` Stashed (auto-restores after submit)`]})}):null}tp();var iT=1e4,aT=1e3;function oT(e,t){if(e.length<=iT)return{truncatedText:e,placeholderContent:``};let n=Math.floor(aT/2),r=e.slice(0,n),i=e.slice(-500),a=e.slice(n,-500);return{truncatedText:r+sT(t,$f(a))+i,placeholderContent:a}}function sT(e,t){return`[...Truncated text #${e} +${t} lines...]`}function cT(e,t){let n=Object.keys(t).map(Number),r=n.length>0?Math.max(...n)+1:1,{truncatedText:i,placeholderContent:a}=oT(e,r);return a?{newInput:i,newPastedContents:{...t,[r]:{id:r,type:`text`,content:a}}}:{newInput:e,newPastedContents:t}}function lT({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}=cT(e,t);n(s),r(s.length),i(c),o(!0)},[e,a,t,n,i,r]),(0,Q.useEffect)(()=>{e===``&&o(!1)},[e])}J(),td(),Tt(),Xo();var uT=3;function dT({input:e,submitCount:t}){let n=Xb(),r=G(e=>e.promptSuggestionEnabled);return(0,Q.useMemo)(()=>{if(e===``){if(n.some(gs)&&(rd().queuedCommandUpHintCount||0)<uT)return`Press up to edit queued messages`;if(t<1&&r&&!Sl())return xh()}},[e,n,t,r])}var fT=5e3,pT=!1;function mT(e){let[t,n]=(0,Q.useState)(!1);return(0,Q.useEffect)(()=>{if(pT||!e)return;pT=!0,n(!0);let t=setTimeout(n,fT,!1);return()=>{clearTimeout(t),n(!1)}},[e]),t}R(),Gf(),Ed(),J(),tu(),Tt(),v(),vr(),cp(),fh(),tp(),mm(),Ts(),H(),on(),Vr(),Ht(),Wl(),Su(),jf(),td(),gu(),Ju(),su(),xs(),yi(),pd(),Ud(),wd(),dm(),Zo(),If(),vh(),Cf(),$m();var hT=5,gT=3;function _T({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:g,stashedPrompt:v,setStashedPrompt:y,submitCount:b,onShowMessageSelector:S,onMessageActionsEnter:C,mcpClients:w,pastedContents:T,setPastedContents:E,vimMode:O,setVimMode:k,showBashesDialog:A,setShowBashesDialog:M,onExit:N,getToolUseContext:ee,onSubmit:P,isSearchingHistory:F,setIsSearchingHistory:I,onDismissSideQuestion:L,isSideQuestionVisible:te,helpOpen:R,setHelpOpen:z,hasSuppressedDialogs:ie,isLocalJSXCommandActive:B=!1,insertTextRef:ae}){let oe=pm(),H=op()||B,[ce,le]=(0,Q.useState)(!1),[U,ue]=(0,Q.useState)({show:!1}),[W,de]=(0,Q.useState)(f.length),fe=Q.useRef(f);f!==fe.current&&(de(f.length),fe.current=f);let pe=Q.useCallback(e=>{fe.current=e,p(e)},[p]);ae&&(ae.current={cursorOffset:W,insert:e=>{let t=W===f.length&&f.length>0&&!/\s$/.test(f)?` ${e}`:e,n=f.slice(0,W)+t+f.slice(W);fe.current=n,p(n),de(W+t.length)},setInputWithCursor:(e,t)=>{fe.current=e,p(e),de(t)}});let me=Yi(),he=An(),ge=G(e=>e.tasks),_e=Xb(),ve=G(e=>e.promptSuggestion),ye=G(e=>e.speculation),be=G(e=>e.speculationSessionTimeSavedMs),xe=G(e=>e.mainLoopModel),Se=G(e=>e.mainLoopModelForSession),Ce=G(e=>e.thinkingEnabled),we=G(e=>$a()?e.fastMode:!1),Te=G(e=>e.viewingAgentTaskId);G(e=>e.viewSelectionMode);let{historyQuery:Ee,setHistoryQuery:De,historyMatch:Oe,historyFailedMatch:ke}=gx(e=>{E(e.pastedContents),Ut(e.display)},f,pe,de,W,g,m,F,I,E,T),Ae=(0,Q.useRef)(-1);Ae.current===-1&&(Ae.current=vT(l));let je=(0,Q.useRef)(!1),Me=G(e=>e.selectedBgAgentIndex),Ne=(0,Q.useCallback)(e=>he(t=>{let n=typeof e==`function`?e(t.selectedBgAgentIndex):e;return n===t.selectedBgAgentIndex?t:{...t,selectedBgAgentIndex:n}}),[he]),[Pe,Fe]=(0,Q.useState)(!1),[Ie,Le]=(0,Q.useState)(!1),[Re,ze]=(0,Q.useState)(!1),[Be,Ve]=(0,Q.useState)(!1),[He,Ue]=(0,Q.useState)(!1),[We,Ge]=(0,Q.useState)(!1),[Ke,qe]=(0,Q.useState)(!1),[Je,Ye]=(0,Q.useState)(!1),Xe=(0,Q.useMemo)(()=>{let e=f.indexOf(`
|
|
66
|
+
`);return e===-1||W<=e},[f,W]),Ze=(0,Q.useMemo)(()=>{let e=f.lastIndexOf(`
|
|
67
|
+
`);return e===-1||W>e},[f,W]),Qe=(0,Q.useMemo)(()=>Fu(Object.values(ge),e=>e.status===`running`),[ge])>0&&!hh(ge,!1),$e=hx(),et=$e.length>0,tt=(0,Q.useMemo)(()=>[et&&`bg_agent`,Qe&&`tasks`].filter(Boolean),[et,Qe]),nt=G(e=>e.footerSelection),rt=nt&&tt.includes(nt)?nt:null;(0,Q.useEffect)(()=>{nt&&!rt&&he(e=>e.footerSelection===null?e:{...e,footerSelection:null})},[nt,rt,he]);let it=rt===`tasks`,at=rt===`tmux`,ot=rt===`bg_agent`;function st(e){he(t=>t.footerSelection===e?t:{...t,footerSelection:e}),e===`bg_agent`&&Ne(-1)}function ct(e,t=!1){let n=rt?tt.indexOf(rt):-1,r=tt[n+e];return r?(st(r),!0):e<0&&t?(st(null),!0):!1}let{suggestion:lt,markAccepted:ut,logOutcomeAtSubmission:dt,markShown:ft}=vx({inputValue:f,isAssistantResponding:s}),pt=(0,Q.useMemo)(()=>F&&Oe?Df(typeof Oe==`string`?Oe:Oe.display):f,[F,Oe,f]),mt=(0,Q.useMemo)(()=>Hi(pt),[pt]),ht=(0,Q.useMemo)(()=>Hp(pt),[pt]),gt=(0,Q.useMemo)(()=>Kx(pt).filter(e=>vs(pt.slice(e.start+1,e.end),a)),[pt,a]),_t=(0,Q.useMemo)(()=>[],[pt]),vt=(0,Q.useMemo)(()=>fS(me.getState().mcp.clients)?mS(pt):[],[pt,(0,Q.useSyncExternalStore)(iS,pS)]),yt=(0,Q.useMemo)(()=>Zf(pt).filter(e=>e.match.startsWith(`[Image`)).map(e=>({start:e.index,end:e.index+e.match.length})),[pt]),bt=yt.some(e=>e.start===W);(0,Q.useEffect)(()=>{let e=yt.find(e=>W>e.start&&W<e.end);if(e){let t=(e.start+e.end)/2;de(W<t?e.start:e.end)}},[W,yt,de]);let xt=(0,Q.useMemo)(()=>{let e=[];for(let t of yt)W===t.start&&e.push({start:t.start,end:t.end,color:void 0,inverse:!0,priority:8});F&&Oe&&!ke&&e.push({start:W,end:W+Ee.length,color:`warning`,priority:20});for(let t of ht)e.push({start:t.start,end:t.end,color:`warning`,priority:15});for(let t of gt)e.push({start:t.start,end:t.end,color:`suggestion`,priority:5});for(let t of _t)e.push({start:t.start,end:t.end,color:`suggestion`,priority:5});for(let t of vt)e.push({start:t.start,end:t.end,color:`suggestion`,priority:5});if(nr())for(let t of mt)for(let n=t.start;n<t.end;n++)e.push({start:n,end:n+1,color:oa(n-t.start),shimmerColor:oa(n-t.start,!0),priority:10});return e},[F,Ee,Oe,ke,W,ht,yt,gt,_t,vt,pt,mt]),{addNotification:St,removeNotification:Ct}=Wf();(0,Q.useEffect)(()=>{mt.length&&nr()?St({key:`ultrathink-active`,text:`Ultrathink active for this turn`,priority:`immediate`,timeoutMs:5e3}):Ct(`ultrathink-active`)},[St,Ct,mt.length]);let wt=(0,Q.useRef)(f.length),Tt=(0,Q.useRef)(f.length),Et=(0,Q.useCallback)(()=>{Ct(`stash-hint`)},[Ct]);(0,Q.useEffect)(()=>{let e=wt.current,t=Tt.current,n=f.length;if(wt.current=n,n>t){Tt.current=n;return}if(n===0){Tt.current=0;return}t>=20&&n<=5&&!(e>=20&&n<=5)&&(rd().hasUsedStash||St({key:`stash-hint`,jsx:(0,$.jsxs)(x,{dimColor:!0,children:[`Tip: `,(0,$.jsx)(Js,{action:`chat:stash`,context:`Chat`,fallback:`ctrl+s`,description:`stash`})]}),priority:`immediate`,timeoutMs:ox}),Tt.current=n)},[f.length,St]);let{pushToBuffer:Dt,undo:Ot,canUndo:kt,clearBuffer:At}=_x({maxBufferSize:50,debounceMs:1e3});lT({input:f,pastedContents:T,onInputChange:pe,setCursorOffset:de,setPastedContents:E});let jt=dT({input:f,submitCount:b}),Mt=(0,Q.useCallback)(e=>{if(e===`?`){z(e=>!e);return}z(!1),Et(),As(),Ua(he);let t=e.length===f.length+1,n=W===0,r=Uf(e);if(n&&r!==`prompt`){if(t){g(r);return}if(f.length===0){g(r);let t=Df(e).replaceAll(` `,` `);Dt(f,W,T),pe(t),de(t.length);return}}let i=e.replaceAll(` `,` `);f!==i&&Dt(f,W,T),he(e=>e.footerSelection===null?e:{...e,footerSelection:null}),pe(i)},[pe,g,f,W,Dt,T,Et,he]),{resetHistory:Nt,onHistoryUp:Pt,onHistoryDown:Ft,dismissSearchHint:It,historyIndex:Lt}=mx((e,t,n)=>{Mt(e),g(t),E(n)},f,T,de,m);(0,Q.useEffect)(()=>{F&&It()},[F,It]);function Rt(){if(!(Wt.length>1)&&Xe){if(_e.some(gs)){nn();return}Pt()}}function zt(){if(!(Wt.length>1)&&Ze&&Ft()&&tt.length>0){let e=tt[0];st(e),e===`tasks`&&!rd().hasSeenTasksHint&&nd(e=>e.hasSeenTasksHint?e:{...e,hasSeenTasksHint:!0})}}let[Bt,Vt]=(0,Q.useState)({suggestions:[],selectedSuggestion:-1,commandArgumentHint:void 0}),Ht=(0,Q.useCallback)(e=>{Vt(t=>typeof e==`function`?e(t):e)},[]),Ut=(0,Q.useCallback)(async(e,t=!1)=>{e=e.trimEnd();let n=me.getState();if(n.footerSelection&&tt.includes(n.footerSelection)||n.viewSelectionMode===`selecting-agent`)return;let r=Object.values(T).some(e=>e.type===`image`),i=ve.text;if((e.trim()===``||e===i)&&i&&!r&&!n.viewingAgentTaskId){if(ye.status===`active`){ut(),dt(i,{skipReset:!0}),P(i,{setCursorOffset:de,clearBuffer:At,resetHistory:Nt},{state:ye,speculationSessionTimeSavedMs:be,setAppState:he});return}ve.shownAt>0&&(ut(),e=i)}if(e.trim()===``&&!r)return;let a=Bt.suggestions.length>0&&Bt.suggestions.every(e=>e.description===`directory`);if(Bt.suggestions.length>0&&!t&&!a){Y(`[onSubmit] early return: suggestions showing (count=${Bt.suggestions.length})`);return}ve.text&&ve.shownAt>0&&dt(e),Ct(`stash-hint`),await P(e,{setCursorOffset:de,clearBuffer:At,resetHistory:Nt})},[ve,ye,be,me,tt,Bt.suggestions,P,At,Nt,dt,he,ut,T,Ct]),{suggestions:Wt,selectedSuggestion:Gt,commandArgumentHint:Kt,inlineGhostText:qt,maxColumnWidth:Jt}=WS({commands:a,onInputChange:pe,onSubmit:Ut,setCursorOffset:de,input:f,cursorOffset:W,mode:m,agents:o,setSuggestionsState:Ht,suggestionsState:Bt,suppressSuggestions:F||Lt>0,markAccepted:ut,onModeChange:g}),Yt=m===`prompt`&&Wt.length===0&<&&!Te;Yt&&ft(),ve.text&&!lt&&ve.shownAt===0&&!Te&&(Sr(`timing`,ve.text),he(e=>({...e,promptSuggestion:{text:null,promptId:null,shownAt:0,acceptedAt:0,generationRequestId:null}})));function Xt(e,t,n,r,i){g(`prompt`);let a=Ae.current++,o={id:a,type:`image`,content:e,mediaType:t||`image/png`,filename:n||`Pasted image`,dimensions:r,sourcePath:i};ii(o),$l(o),E(e=>({...e,[a]:o})),$t((je.current?` `:``)+ep(a)),je.current=!0}(0,Q.useEffect)(()=>{let e=new Set(Zf(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 Zt(e){je.current=!1;let t=se(e).replace(/\r/g,`
|
|
68
|
+
`).replaceAll(` `,` `);if(f.length===0){let e=Uf(t);e!==`prompt`&&(g(e),t=Df(t))}let n=$f(t),r=Math.min(vn-10,2);if(t.length>800||n>r){let e=Ae.current++,r={id:e,type:`text`,content:t};E(t=>({...t,[e]:r})),$t(Xf(e,n))}else $t(t)}let Qt=(0,Q.useCallback)((e,t)=>je.current?(je.current=!1,Zm(e,t)?` ${e}`:e):e,[]);function $t(e){Dt(f,W,T);let t=f.slice(0,W)+e+f.slice(W);pe(t),de(W+e.length)}let tn=ne(()=>{},()=>S()),nn=(0,Q.useCallback)(()=>{let e=$r(f,W);return e?(pe(e.text),g(`prompt`),de(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},[pe,g,f,W,E]);$b(w,e=>{let t,n=Ah.relative(nu(),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[W-1]??` `;/\s/.test(r)||(t=` ${t}`),$t(t)});let rn=(0,Q.useCallback)(()=>{if(kt){let e=Ot();e&&(pe(e.text),de(e.cursorOffset),E(e.pastedContents))}},[kt,Ot,pe,E]),an=(0,Q.useCallback)(()=>{Dt(f,W,T);let e=`${f.slice(0,W)}\n${f.slice(W)}`;pe(e),de(W+1)},[f,W,pe,de,Dt,T]),on=(0,Q.useCallback)(async()=>{Le(!0);try{let e=await lm(f,T);e.error&&St({key:`external-editor-error`,text:e.error,color:`warning`,priority:`high`}),e.content!==null&&e.content!==f&&(Dt(f,W,T),pe(e.content),de(e.content.length))}catch(e){e instanceof Error&&X(e),St({key:`external-editor-error`,text:`External editor failed: ${cu(e)}`,color:`warning`,priority:`high`})}finally{Le(!1)}},[f,W,T,Dt,pe,St]),sn=(0,Q.useCallback)(()=>{f.trim()===``&&v!==void 0?(pe(v.text),de(v.cursorOffset),E(v.pastedContents),y(void 0)):f.trim()!==``&&(y({text:f,cursorOffset:W,pastedContents:T}),pe(``),de(0),E({}),nd(e=>e.hasUsedStash?e:{...e,hasUsedStash:!0}))},[f,W,v,pe,y,T,E]),cn=(0,Q.useCallback)(()=>{ze(e=>!e),R&&z(!1)},[R]),ln=(0,Q.useCallback)(()=>{qe(e=>!e),R&&z(!1)},[R]),un=(0,Q.useCallback)(()=>{Ye(e=>!e),R&&z(!1)},[R]),dn=(0,Q.useCallback)(()=>{Y(`[auto-mode] handleCycleMode: currentMode=${n.mode}`);let e=qS(n),{context:t}=JS(n);e===`plan`&&nd(e=>({...e,lastPlanModeUse:Date.now()})),he(n=>({...n,toolPermissionContext:{...t,mode:e}})),r({...t,mode:e}),R&&z(!1)},[n,he,r,R]),fn=(0,Q.useCallback)(()=>{wf().then(e=>{if(e)Xt(e.base64,e.mediaType);else{let e=en(`chat:imagePaste`,`Chat`,`ctrl+v`),t=Iu.isSSH()?`No image found in clipboard. You're SSH'd; try scp?`:`No image found in clipboard. Use ${e} to paste images.`;St({key:`no-image-in-clipboard`,text:t,priority:`immediate`,timeoutMs:1e3})}})},[St,Xt]),pn=j();(0,Q.useEffect)(()=>{if(!(!pn||H))return pn.registerHandler({action:`chat:submit`,context:`Chat`,handler:()=>{Ut(f)}})},[pn,H,Ut,f]),h((0,Q.useMemo)(()=>({"chat:undo":rn,"chat:newline":an,"chat:externalEditor":on,"chat:stash":sn,"chat:modelPicker":cn,"chat:thinkingToggle":un,"chat:cycleMode":dn,"chat:imagePaste":fn}),[rn,an,on,sn,cn,un,dn,fn]),{context:`Chat`,isActive:!H}),D(`chat:messageActions`,()=>C?.(),{context:`Chat`,isActive:!H&&!F}),D(`chat:fastMode`,ln,{context:`Chat`,isActive:!H&&$a()&&Vc()}),D(`help:dismiss`,()=>{z(!1)},{context:`Help`,isActive:R}),D(`app:quickOpen`,()=>{},{context:`Global`,isActive:!1}),D(`app:globalSearch`,()=>{},{context:`Global`,isActive:!1}),D(`history:search`,()=>{},{context:`Global`,isActive:!1}),D(`app:interrupt`,()=>{Ua(he)},{context:`Global`,isActive:!s&&ye.status===`active`}),h({"footer:up":()=>{if(ot){Me>-1?Ne(e=>e-1):st(null);return}ct(-1,!0)},"footer:down":()=>{if(ot){Me<$e.length-1&&Ne(e=>e+1);return}if(it){M(!0),st(null);return}ct(1)},"footer:next":()=>{ct(1)},"footer:previous":()=>{ct(-1)},"footer:openSelected":()=>{switch(rt){case`tasks`:M(!0),st(null);break;case`tmux`:break;case`bg_agent`:break}},"footer:clearSelection":()=>{st(null)},"footer:close":()=>!1},{context:`Footer`,isActive:!!rt&&!H}),re((e,t)=>{if(!(Be||He||We)){if(Td()===`macos`&&KS(e)){let t=GS[e],n=qf();St({key:`option-meta-hint`,jsx:n?(0,$.jsxs)(x,{dimColor:!0,children:[`To enable `,t,`, set `,(0,$.jsx)(x,{bold:!0,children:`Option as Meta`}),` in `,n,` preferences (⌘,)`]}):(0,$.jsxs)(x,{dimColor:!0,children:[`To enable `,t,`, run /terminal-setup`]}),priority:`immediate`,timeoutMs:5e3})}if(rt&&e&&!t.ctrl&&!t.meta&&!t.escape&&!t.return){Mt(f.slice(0,W)+e+f.slice(W)),de(W+e.length);return}if(W===0&&(t.escape||t.backspace||t.delete||t.ctrl&&e===`u`)&&(g(`prompt`),z(!1)),R&&f===``&&(t.backspace||t.delete)&&z(!1),t.escape){if(ye.status===`active`){Ua(he);return}if(te&&L){L();return}if(R){z(!1);return}if(rt)return;if(_e.some(gs)){nn();return}l.length>0&&!f&&!s&&tn()}t.return&&R&&z(!1)}});let mn=$a()?ds():!1,hn=$a()?we&&(Vc()||mn):!1,gn=mT(hn??!1),{columns:_n,rows:vn}=V(),yn=_n-3,bn=xr()?Math.max(gT,Math.floor(vn/2)-hT):void 0,xn=(0,Q.useCallback)(e=>{if(!f||F)return;let t=Pf.fromText(f,yn,W),n=t.getViewportStartLine(bn),r=t.measuredText.getOffsetFromPosition({line:e.localRow+n,column:e.localCol});de(r)},[f,yn,F,W,bn]),Sn=(0,Q.useCallback)(e=>M(e??!0),[M]),Cn=Yt&<?lt:jt,wn=(0,Q.useMemo)(()=>f.includes(`
|
|
69
|
+
`),[f]),Tn=(0,Q.useCallback)(e=>{let t=!1;he(n=>(t=$a()&&!_c(e)&&!!n.fastMode,{...n,mainLoopModel:e,mainLoopModelForSession:null,...t&&{fastMode:!1}})),ze(!1);let n=(we??!1)&&!t,r=`Model set to ${Wd(e)}`;km(e,n,Gd())&&(r+=` · Billed as extra usage`),t&&(r+=` · Fast mode OFF`),St({key:`model-switched`,jsx:(0,$.jsx)(x,{children:r}),priority:`immediate`,timeoutMs:3e3})},[he,St,we]),En=(0,Q.useCallback)(()=>{ze(!1)},[]),Dn=(0,Q.useMemo)(()=>Re?(0,$.jsx)(_,{flexDirection:`column`,marginTop:1,children:(0,$.jsx)(Am,{initial:xe,sessionModel:Se,onSelect:Tn,onCancel:En,isStandaloneCommand:!0,showFastModeNotice:$a()&&we&&_c(xe)&&Vc()})}):null,[Re,xe,Se,Tn,En]),On=(0,Q.useCallback)(e=>{qe(!1),e&&St({key:`fast-mode-toggled`,jsx:(0,$.jsx)(x,{children:e}),priority:`immediate`,timeoutMs:3e3})},[St]),kn=(0,Q.useMemo)(()=>Ke?(0,$.jsx)(_,{flexDirection:`column`,marginTop:1,children:(0,$.jsx)(Gm,{onDone:On,unavailableReason:No()})}):null,[Ke,On]),jn=(0,Q.useCallback)(e=>{he(t=>({...t,thinkingEnabled:e})),Ye(!1),St({key:`thinking-toggled-hotkey`,jsx:(0,$.jsxs)(x,{color:e?`suggestion`:void 0,dimColor:!e,children:[`Thinking `,e?`on`:`off`]}),priority:`immediate`,timeoutMs:3e3})},[he,St]),Mn=(0,Q.useCallback)(()=>{Ye(!1)},[]),Nn=(0,Q.useMemo)(()=>Je?(0,$.jsx)(_,{flexDirection:`column`,marginTop:1,children:(0,$.jsx)(YS,{currentValue:Ce??!0,onSelect:jn,onCancel:Mn,isMidConversation:l.some(e=>e.type===`assistant`)})}):null,[Je,Ce,jn,Mn,l.length]);if(ch(null),A)return(0,$.jsx)(yh,{onDone:()=>M(!1),toolUseContext:ee(l,[],new AbortController,oe),initialDetailTaskId:typeof A==`string`?A:void 0});if(Dn)return Dn;if(kn)return kn;if(Nn)return Nn;let Pn={multiline:!0,onSubmit:Ut,onChange:Mt,value:Oe?Df(typeof Oe==`string`?Oe:Oe.display):f,onHistoryUp:Rt,onHistoryDown:zt,onHistoryReset:Nt,placeholder:Cn,onExit:N,onExitMessage:(e,t)=>ue({show:e,key:t}),onImagePaste:Xt,columns:yn,maxVisibleLines:bn,disableCursorMovementForUpDownKeys:Wt.length>0||!!rt,disableEscapeDoublePress:Wt.length>0,cursorOffset:W,onChangeCursorOffset:de,onPaste:Zt,onIsPastingChange:Fe,focus:!F&&!H&&!rt,showCursor:!rt&&!F&&!bt,argumentHint:Kt,onUndo:kt?()=>{let e=Ot();e&&(pe(e.text),de(e.cursorOffset),E(e.pastedContents))}:void 0,highlights:xt,inlineGhostText:qt,inputFilter:Qt},Fn=()=>{let e={bash:`bashBorder`};return e[m]?e[m]:`promptBorder`};if(Ie)return(0,$.jsx)(_,{flexDirection:`row`,alignItems:`center`,justifyContent:`center`,borderColor:Fn(),borderStyle:`round`,borderLeft:!1,borderRight:!1,borderBottom:!0,width:`100%`,children:(0,$.jsx)(x,{dimColor:!0,italic:!0,children:`Save and close editor to continue...`})});let In=Xm()?(0,$.jsx)(JC,{...Pn,initialMode:O,onModeChange:k}):(0,$.jsx)(Vf,{...Pn});return(0,$.jsxs)(_,{flexDirection:`column`,marginTop:1,children:[!xr()&&(0,$.jsx)(nT,{}),ie&&(0,$.jsx)(_,{marginTop:1,marginLeft:2,children:(0,$.jsx)(x,{dimColor:!0,children:`Waiting for permission…`})}),(0,$.jsx)(rT,{hasStash:v!==void 0}),(0,$.jsxs)(_,{flexDirection:`row`,alignItems:`flex-start`,justifyContent:`flex-start`,borderColor:Fn(),borderStyle:`round`,borderLeft:!1,borderRight:!1,borderBottom:!0,width:`100%`,borderText:yT(hn??!1,gn,mn),children:[(0,$.jsx)(Kw,{mode:m,isLoading:s}),(0,$.jsx)(_,{flexGrow:1,flexShrink:1,onClick:xn,children:In})]}),(0,$.jsx)(Uw,{apiKeyStatus:i,debug:e,exitMessage:U,vimMode:Xm()?O:void 0,mode:m,autoUpdaterResult:d,isAutoUpdating:ce,verbose:c,onAutoUpdaterResult:u,onChangeIsUpdating:le,suggestions:Wt,selectedSuggestion:Gt,maxColumnWidth:Jt,toolPermissionContext:n,helpOpen:R,suppressHint:f.length>0,isLoading:s,tasksSelected:it,tmuxSelected:at,ideSelection:t,mcpClients:w,isPasting:Pe,isInputWrapped:wn,messages:l,isSearching:F,historyQuery:Ee,setHistoryQuery:De,historyFailedMatch:ke,onOpenTasksDialog:xr()?Sn:void 0}),xr()?(0,$.jsx)(_,{position:`absolute`,marginTop:-1,height:+(Wt.length===0),width:`100%`,paddingLeft:2,paddingRight:1,flexDirection:`column`,justifyContent:`flex-end`,overflow:`hidden`,children:(0,$.jsx)(sx,{apiKeyStatus:i,autoUpdaterResult:d,debug:e,isAutoUpdating:ce,verbose:c,messages:l,onAutoUpdaterResult:u,onChangeIsUpdating:le,ideSelection:t,mcpClients:w,isInputWrapped:wn})}):null]})}function vT(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=Zf(e.text);for(let e of n)e.id>t&&(t=e.id)}}}return t+1}function yT(e,t,n){if(e)return{content:` ${t?`${Um(!0,n)} ${L.dim(`/fast`)}`:Um(!0,n)} `,position:`top`,align:`end`,offset:0}}var bT=Q.memo(_T);function xT(e){return{onBeforeQuery:async()=>!0,onTurnComplete:async()=>{},render:()=>null}}gi(),_r(),Xc();function ST(){return!1}function CT(){return!1}Po();function wT(e){(0,Q.useEffect)(()=>{let t=()=>{ST()&&process.stdout.write(`\n${ol()}\n`),Ks(e?.())};return process.on(`exit`,t),()=>{process.off(`exit`,t)}},[])}function TT(){(0,Q.useEffect)(()=>{},[])}function ET(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])}function DT(){let[e]=(0,Q.useState)(`valid`),[t]=(0,Q.useState)(null);return{status:e,reverify:(0,Q.useCallback)(async()=>{},[]),error:t}}H(),Ht(),Ed(),J();function OT({screen:e,setScreen:t,showAllInTranscript:n,setShowAllInTranscript:r,messageCount:i,onEnterTranscript:a,onExitTranscript:o,virtualScrollActive:s,searchBarOpen:c=!1}){let l=G(e=>e.expandedView),u=An(),d=(0,Q.useCallback)(()=>{u(e=>({...e,expandedView:e.expandedView===`tasks`?`none`:`tasks`}))},[l,u]),f=(0,Q.useCallback)(()=>{let n=e!==`transcript`;t(e=>e===`transcript`?`prompt`:`transcript`),r(!1),n&&a&&a(),!n&&o&&o()},[e,t,n,r,i,u,a,o]),p=(0,Q.useCallback)(()=>{r(e=>!e)},[n,r,i]),m=(0,Q.useCallback)(()=>{t(`prompt`),r(!1),o&&o()},[t,n,r,i,o]);D(`app:toggleTodos`,d,{context:`Global`}),D(`app:toggleTranscript`,f,{context:`Global`}),D(`app:toggleTerminal`,(0,Q.useCallback)(()=>{},[]),{context:`Global`}),D(`app:redraw`,(0,Q.useCallback)(()=>{C.get(process.stdout)?.forceRedraw()},[]),{context:`Global`});let h=e===`transcript`;return D(`transcript:toggleShowAll`,p,{context:`Transcript`,isActive:h&&!s}),D(`transcript:exit`,m,{context:`Transcript`,isActive:h&&!c}),null}cp(),on(),Ht();var kT={setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}};function AT({onSubmit:e,isActive:t=!0}){let n=j(),r=op(),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 h((0,Q.useMemo)(()=>{let t={};for(let n of i){let r=n.slice(8);t[n]=()=>{e(`/${r}`,kT,void 0,{fromKeybinding:!0})}}return t},[i,e]),{context:`Chat`,isActive:t&&!r}),null}Ed(),J(),$m(),Gf(),cp(),Vr(),Ht(),Tc(),Tt();var jT=3e3;function MT(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=Yi(),g=An(),_=Xb().length,{addNotification:v,removeNotification:y}=Wf(),b=(0,Q.useRef)(0),x=(0,Q.useCallback)(()=>{if(o!==void 0&&!o.aborted){t(()=>[]),n();return}if(Ds()&&s){s();return}t(()=>[]),n()},[o,s,t,n,m]),S=sp(),C=o!==void 0&&!o.aborted,w=_>0,T=f!==void 0&&f!==`prompt`&&!p,E=a!==`transcript`&&!u&&!i&&!l&&!d&&!S&&!(Xm()&&c===`INSERT`),O=E&&(C||w)&&!T,k=E&&(C||w);D(`chat:cancel`,x,{context:`Chat`,isActive:O});let A=(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;is(e,g);let n=[];for(let[e,r]of t)Jo(e,g),n.push(r.description),zl(e,`stopped`,{toolUseId:r.toolUseId,summary:r.description});return Mi({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 D(`app:interrupt`,(0,Q.useCallback)(()=>{(C||w)&&x()},[C,w,x]),{context:`Global`,isActive:k}),D(`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<=jT){b.current=0,y(`kill-agents-confirm`),Ml(),A();return}b.current=t;let n=en(`chat:killAgents`,`Chat`,`ctrl+x ctrl+k`);v({key:`kill-agents-confirm`,text:`Press ${n} again to stop background agents`,priority:`immediate`,timeoutMs:jT})},[h,v,y,A]),{context:`Chat`}),null}H(),J(),Yo();function NT(e){let t=G(e=>e.tasks),n=Object.values(t).some(Wa),r=t=>{if(t.shift&&(t.key===`up`||t.key===`down`)){t.preventDefault(),n&&e?.onOpenBackgroundTasks?.();return}};return re((e,t,n)=>{r(new E(n.keypress))}),{handleKeyDown:r}}pd();async function PT(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}Ed(),hf(),gu(),Zs(),Kn(),br(),la();function FT(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 IT(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){Oa({tool:e,input:a?.input??t,toolUseContext:n,messageId:s,toolUseID:i},r,a?.permissionPromptStartTimeMs)},logCancelled(){mf(e.name)},async persistPermissions(e){return e.length===0?!1:(ti(e),a(Et(n.getAppState().toolPermissionContext,e)),e.some(e=>yn(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?Jr:dr}${t}`:a?Dr:fs,s=a?o:Vo(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 Xi(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 LT(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))}}}function RT(e,t){let{ctx:n,description:r,result:i,awaitAutomatedChecksBeforeDialog:a}=e,{resolve:o,isResolved:s,claim:c}=FT(t),l,u,d=Date.now(),f=i.updatedInput??n.input,p={assistantMessage:n.assistantMessage,tool:n.tool,description:r,input:f,toolUseContext:n.toolUseContext,toolUseID:n.toolUseID,permissionResult:i,permissionPromptStartTimeMs:d,onUserInteraction(){Date.now()-d<200||n.toolUseID},onDismissCheckmark(){l&&(clearTimeout(l),l=void 0,u&&(n.toolUseContext.abortController.signal.removeEventListener(`abort`,u),u=void 0),n.removeFromQueue())},onAbort(){c()&&(n.logCancelled(),n.logDecision({decision:`reject`,source:{type:`user_abort`}},{permissionPromptStartTimeMs:d}),o(n.cancelAndAbort(void 0,!0)))},async onAllow(e,t,r,a){c()&&o(await n.handleUserAllow(e,t,r,d,a,i.decisionReason))},onReject(e,t){c()&&(n.logDecision({decision:`reject`,source:{type:`user_reject`,hasFeedback:!!e}},{permissionPromptStartTimeMs:d}),o(n.cancelAndAbort(e,void 0,t)))},async recheckPermission(){if(s())return;let e=await At(n.tool,n.input,n.toolUseContext,n.assistantMessage,n.toolUseID);if(e.behavior===`allow`){if(!c())return;n.removeFromQueue(),n.logDecision({decision:`accept`,source:`config`}),o(n.buildAllow(e.updatedInput??n.input))}}};n.pushToQueue(p),a||(async()=>{if(s())return;let e=n.toolUseContext.getAppState(),t=await n.runHooks(e.toolPermissionContext.mode,i.suggestions,i.updatedInput,d);!t||!c()||(n.removeFromQueue(),o(t))})()}cn(),gu(),su(),pd(),Ui(),la();function zT(e,t){return(0,Q.useCallback)(async(n,r,i,a,o,s)=>new Promise(c=>{let l=IT(n,r,i,a,o,t,LT(e));if(!l.resolveIfAborted(c))return(s===void 0?At(n,r,i,a,o):Promise.resolve(s)).then(async e=>{if(e.behavior===`allow`){if(l.resolveIfAborted(c))return;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`:Oa({tool:n,input:r,toolUseContext:i,messageId:l.messageId,toolUseID:o},{decision:`reject`,source:`config`}),c(e);return;case`ask`:if(t.toolPermissionContext.awaitAutomatedChecksBeforeDialog){let n=await PT({ctx:l,updatedInput:e.updatedInput,suggestions:e.suggestions,permissionMode:t.toolPermissionContext.mode});if(n){c(n);return}}if(l.resolveIfAborted(c))return;RT({ctx:l,description:a,result:e,awaitAutomatedChecksBeforeDialog:t.toolPermissionContext.awaitAutomatedChecksBeforeDialog},c);return}}).catch(e=>{e instanceof au||e instanceof fu?(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(()=>{})}),[e,t])}yr(),Ed(),vr(),tp(),tu(),gu(),su(),pd(),Tt(),Ud(),Rd();function BT(){$o(0)}async function VT(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){no(),await HT({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(Zf(T).map(e=>e.id)),k=Object.fromEntries(Object.entries(D).filter(([,e])=>e.type!==`image`||O.has(e.id))),A=Object.values(k).some(jl);if(T.trim()===``)return;if(!b&&[`exit`,`quit`,`:q`,`:q!`,`:wq`,`:wq!`].includes(T.trim())){i.find(e=>e.name===`exit`)?VT({...e,input:`/exit`}):BT();return}let j=Qf(T,k),M=Zf(T).filter(e=>k[e.id]?.type===`text`);if(M.length,M.reduce((e,t)=>e+(k[t.id]?.content.length??0),0),!b&&j.trim().startsWith(`/`)){let t=j.trim(),d=t.indexOf(` `),f=d===-1?t.slice(1):t.slice(1,d),p=d===-1?``:t.slice(d+1).trim(),m=i.find(e=>e.immediate&&vn(e)&&(e.name===f||e.aliases?.includes(f)||Mr(e)===f));if(m&&m.type===`local-jsx`&&(n.isActive||r)){m.name,a(``),S(0),o({}),C();let t=c(l,[],go(),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?Tl({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}`),e.streamMode,e.abortController?.abort(`interrupt`)),Tl({value:j.trim(),preExpansionValue:T.trim(),mode:E,pastedContents:A?k:void 0,skipSlashCommands:b,bridgeOrigin:x,uuid:y}),a(``),S(0),o({}),w(),C();return}no(),await HT({queuedCommands:[{value:j,preExpansionValue:T,mode:E,pastedContents:A?k:void 0,skipSlashCommands:b,bridgeOrigin:x,uuid:y}],messages:l,mainLoopModel:u,ideSelection:d,querySource:e.querySource,commands:i,queryGuard:n,setToolJSX:s,getToolUseContext:c,setUserInputOnProcessing:f,setAbortController:p,onQuery:m,setAppState:h,onBeforeQuery:g,resetHistory:w,canUseTool:_,onInputChange:a})}async function HT(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=go();l(g);function _(){return s(t,[],g,n)}try{a.reserve(),Rl(`query_process_user_input_start`);let s=[],v=!1,y,b,x,S,C=h??[],w=await Gc(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 Kd(D,async()=>{for(let e=0;e<C.length;e++){let n=C[e],a=e===0,l=n.autonomy?.runId,u=await yp({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(Rl(`query_process_user_input_end`),ht()&&(Rl(`query_file_history_snapshot_start`),s.filter(_p).forEach(e=>{ic(e=>{d(t=>({...t,fileHistory:e(t.fileHistory)}))},e.uuid)}),Rl(`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?zd(b,n):n,i?f:void 0,r)}else a.cancelReservation(),o({jsx:null,shouldHidePromptInput:!1,clearLocalJSX:!0}),p(),l(null);x&&(S?Tl({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 uo({commands:e,outcome:{type:`failed`,error:k},currentDir:nu(),priority:`later`,workload:D})}catch(e){X(du(e))}else try{let t=await uo({commands:e,outcome:{type:`completed`},currentDir:nu(),priority:`later`,workload:D});for(let e of t)Tl(e)}catch(e){X(du(e))}}if(k)throw k}finally{a.cancelReservation(),c(void 0)}}Tt();function UT(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 WT({executeInput:e}){let t=e=>e.agentId===void 0,n=jr(t);if(!n)return{processed:!1};if(UT(n)||n.mode===`bash`)return e([wi(t)]),{processed:!0};let r=n.mode,i=Gt(e=>t(e)&&!UT(e)&&e.mode===r);return i.length===0?{processed:!1}:(e(i),{processed:!0})}Tt();function GT({executeQueuedInput:e,hasActiveLocalJsxUI:t,queryGuard:n}){let r=(0,Q.useSyncExternalStore)(n.subscribe,n.getSnapshot),i=(0,Q.useSyncExternalStore)(Fn,rn);(0,Q.useEffect)(()=>{r||t||i.length!==0&&WT({executeInput:e})},[i,r,e,t,n])}function KT(e,t){return e&&t&&t.length>0?qr([...e,...t],`name`):e||[]}function qT(e,t){return(0,Q.useMemo)(()=>KT(e,t),[e,t])}va(),hp(),om(),Er();function JT(e,t){return(0,Q.useMemo)(()=>t.length>0?qr([...e,...t],`name`):e,[e,t])}vr(),pd();function YT(e,t){let n=(0,Q.useCallback)(async()=>{if(e)try{Kt(),t(await an(e))}catch(e){e instanceof Error&&X(e)}},[e,t]);(0,Q.useEffect)(()=>Jp.subscribe(n),[n])}pd(),be(),Jl(),Ee();var XT=De(()=>ve({method:pe(`selection_changed`),params:ve({selection:ve({start:ve({line:_e(),character:_e()}),end:ve({line:_e(),character:_e()})}).nullable().optional(),text:ye().optional(),filePath:ye().optional()})}));function ZT(e,t){let n=(0,Q.useRef)(!1),r=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{let i=pn(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(XT(),e=>{if(r.current===i)try{let t=e.params;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])}wc(),mr(),H(),mh(),J(),Md();function QT({task:e,selected:t}){let n=_h(e.startTime,e.status===`running`),r=e.progress?.tokenCount??0;return(0,$.jsxs)(_,{flexDirection:`row`,width:`100%`,justifyContent:`space-between`,children:[(0,$.jsxs)(_,{flexDirection:`row`,flexShrink:1,children:[(0,$.jsx)(x,{color:e.status===`running`?`success`:void 0,children:t?`● `:`○ `}),(0,$.jsxs)(x,{bold:t,wrap:`truncate-end`,children:[e.agentType,` `,(0,$.jsx)(x,{dimColor:!0,children:e.description})]})]}),(0,$.jsx)(_,{flexShrink:0,children:(0,$.jsxs)(x,{dimColor:!0,children:[n,` · ↓ `,Pd(r),` tokens`]})})]})}function $T(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 eE(){let e=hx(),t=G(e=>e.viewingAgentTaskId),n=G(e=>e.footerSelection),r=G(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)(_,{flexDirection:`column`,width:`100%`,children:[(0,$.jsxs)(_,{flexDirection:`row`,width:`100%`,justifyContent:`space-between`,children:[(0,$.jsxs)(x,{bold:o,children:[o?`● `:`○ `,`main`]}),(0,$.jsx)(x,{dimColor:!0,children:$T(i,s)})]}),e.map(e=>(0,$.jsx)(QT,{task:e,selected:e.agentId===a},e.agentId))]})}md(),tu(),Ls(),gu(),Xo();var tE=3e4;function nE(e){let t=(0,Q.useRef)(e);t.current=e,(0,Q.useEffect)(()=>{if(!Sl())return;let e=null,n=!1,r=!1;function i(){kl(Date.now()+tE),e=setTimeout(()=>{if(e=null,!Ii()){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 cl({basePrompt:`<${ld}>${new Date().toLocaleTimeString()}</${ld}>`,currentDir:nu(),shouldCreate:()=>!n});if(n){await uc({commands:e});return}let r=[];try{for(let n of e)t.current.onQueueTick(n),r.push(n)}catch(t){throw await uc({commands:e.filter(e=>!r.includes(e))}),t}})().catch(e=>Y(`[Proactive] failed to create tick: ${e}`,{level:`error`})).finally(()=>{r=!1}),i()},tE)}return i(),()=>{n=!0,e!==null&&(clearTimeout(e),e=null),kl(null)}},[Sl(),ql(),Ga()])}ut(),ll();function rE(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 iE(e){let t=Ya(e),n=rE(e),r=`Continuation turns executed: ${e.turnsExecuted}`;return`<goal-steering type="continuation">
|
|
70
|
+
You have an active goal to work on. Continue making progress.
|
|
71
|
+
|
|
72
|
+
## Active Goal
|
|
73
|
+
${e.objective}
|
|
74
|
+
|
|
75
|
+
## Status
|
|
76
|
+
- Elapsed active time: ${t}
|
|
77
|
+
- ${n}
|
|
78
|
+
- ${r}
|
|
79
|
+
|
|
80
|
+
## Instructions
|
|
81
|
+
|
|
82
|
+
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.
|
|
83
|
+
|
|
84
|
+
When you believe the goal is fully achieved, use the GoalTool to mark it complete. Before doing so, perform a strict Completion Audit:
|
|
85
|
+
|
|
86
|
+
### Completion Audit
|
|
87
|
+
1. Derive concrete requirements from the objective and any referenced files.
|
|
88
|
+
2. Preserve the original scope — do not redefine success around what is already done.
|
|
89
|
+
3. For every explicit requirement, identify authoritative evidence (test output, file content, command result).
|
|
90
|
+
4. Treat tests, manifests, and verifiers as evidence only after confirming they actually cover the requirement.
|
|
91
|
+
5. Treat uncertain or indirect evidence as "not achieved".
|
|
92
|
+
6. The audit must PROVE completion, not merely fail to find remaining work.
|
|
93
|
+
|
|
94
|
+
### Blocked Audit
|
|
95
|
+
If you encounter an obstacle you genuinely cannot overcome:
|
|
96
|
+
- Do NOT mark blocked on the first encounter.
|
|
97
|
+
- The same blocking condition must persist for at least 3 consecutive continuation turns before you may mark blocked.
|
|
98
|
+
- "Difficult", "slow", or "partially incomplete" is NOT blocked.
|
|
99
|
+
- If blocked, use the GoalTool with status "blocked" and a clear reason.
|
|
100
|
+
|
|
101
|
+
Resume working now.
|
|
102
|
+
</goal-steering>`}function aE(e){return`<goal-steering type="budget_limit">
|
|
103
|
+
## Token Budget Reached
|
|
104
|
+
|
|
105
|
+
Your token budget for this goal has been exhausted.
|
|
106
|
+
|
|
107
|
+
- Goal: ${e.objective}
|
|
108
|
+
- Tokens used: ${e.tokensUsed}${e.tokenBudget===null?``:` / ${e.tokenBudget}`}
|
|
109
|
+
- Active time: ${Ya(e)}
|
|
110
|
+
|
|
111
|
+
**Stop all substantive work immediately.** Do NOT start new file edits, tool calls, or explorations.
|
|
112
|
+
|
|
113
|
+
Instead, provide a brief summary:
|
|
114
|
+
1. What has been accomplished so far.
|
|
115
|
+
2. What remains to be done.
|
|
116
|
+
3. Any blockers or issues encountered.
|
|
117
|
+
|
|
118
|
+
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.
|
|
119
|
+
</goal-steering>`}gu(),ll(),Tt();function oE(e){Y(`[goal] hook: ${e}`)}function sE(e){let t=(0,Q.useRef)(e);t.current=e;let n=(0,Q.useRef)(!1),r=(0,Q.useRef)(!1);(0,Q.useLayoutEffect)(()=>{if(e.isLoading){n.current=!1;return}if(e.isQueryActiveNow?.()){oE(`skip: queryActiveNow=true`);return}if(e.wasAborted){oE(`skip: wasAborted=true`);return}if(n.current)return;if(rn().length>0){oE(`skip: yielding to queued user messages`);return}if(e.hasActiveLocalJsxUI){oE(`skip: activeLocalJsxUI`);return}if(e.isInPlanMode){oE(`skip: planMode`);return}let t=qc();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=aE(t);Y(`[goal] hook: budget limit reached, injecting wrap-up prompt`),Tl({value:e,mode:`prompt`,priority:`now`,isMeta:!0,origin:`goal-budget-limit`,skipSlashCommands:!0});return}if(t.status!==`active`){oE(`skip: status="${t.status}" (not active)`);return}if(t.turnsExecuted>=150){xo()&&(Oo(),e.onMaxTurnsReached?.()),Y(`[goal] hook: MAX_GOAL_TURNS (150) reached, stopping`);return}n.current=!0;let i=zs();Oo();let a=iE(t);Y(`[goal] hook: enqueuing turn ${i} for "${t.objective.slice(0,60)}"`),Tl({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])}td(),o(),Jl();function cE({autoConnectIdeFlag:e,ideToInstallExtension:t,setDynamicMcpConfig:n,setShowIdeOnboarding:i,setIDEInstallationState:o}){(0,Q.useEffect)(()=>{function s(i){i&&(rd().autoConnectIde||e||Tn()||process.env.CLAUDE_CODE_SSE_PORT||t||a(process.env.CLAUDE_CODE_AUTO_CONNECT_IDE))&&!r(process.env.CLAUDE_CODE_AUTO_CONNECT_IDE)&&n(e=>e?.ide?e:{...e,ide:{type:i.url.startsWith(`ws:`)?`ws-ide`:`sse-ide`,url:i.url,ideName:i.name,authToken:i.authToken,ideRunningInWindows:i.ideRunningInWindows,scope:`dynamic`}})}Mt(s,t,()=>i(!0),e=>o(e))},[e,t,n,i,o])}Bm(),ip(),H(),Ht(),Cl(),J(),td(),Ju(),o();function lE({onBackgroundSession:e,isLoading:t}){let n=An(),r=Yi(),[i,o]=(0,Q.useState)(!1),s=ne(o,e,()=>{}),c=(0,Q.useCallback)(()=>{a(process.env.CLAUDE_CODE_DISABLE_BACKGROUND_TASKS)||(Xs(r.getState())?(Cc(()=>r.getState(),n),rd().hasUsedBackgroundTask||nd(e=>e.hasUsedBackgroundTask?e:{...e,hasUsedBackgroundTask:!0})):a(`false`)&&t&&s())},[n,r,t,s]),l=G(Xs),u=a(`false`);D(`task:background`,c,{context:`Task`,isActive:l||u&&t});let d=ji(`task:background`,`Task`,`ctrl+b`),p=Iu.terminal===`tmux`&&d===`ctrl+b`?`ctrl+b ctrl+b`:d;return!t||!i?null:(0,$.jsx)(_,{paddingLeft:2,children:(0,$.jsx)(x,{dimColor:!0,children:(0,$.jsx)(f,{shortcut:p,action:`background`})})})}J();function uE({setMessages:e,setIsLoading:t,resetLoadingState:n,setAbortController:r,onBackgroundQuery:i}){let a=G(e=>e.foregroundedTaskId),o=G(e=>e.foregroundedTaskId?e.tasks[e.foregroundedTaskId]:void 0),s=An(),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?.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}}Qn(),fp(),Cm(),Em(),Gf(),pd();function dE(e){let{addNotification:t}=Wf(),n=(0,Q.useRef)(!1),r=(0,Q.useRef)(e);r.current=e,(0,Q.useEffect)(()=>{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 fE(){dE(async()=>(await Tm()).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`}}))}td(),ou(),gu(),Kn(),Ud(),ft(),sa(),H(),Kn();function pE(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=N();e!==`blurred`&&e!==`unknown`||o.current?.()},[n]),(0,Q.useEffect)(()=>{N()},[n,!1])}Ed(),td(),gu(),o(),su(),pd();function mE(){return a(process.env.CLAUDE_CODE_DISABLE_OFFICIAL_MARKETPLACE_AUTOINSTALL)}var hE={MAX_ATTEMPTS:10,INITIAL_DELAY_MS:3600*1e3,BACKOFF_MULTIPLIER:2,MAX_DELAY_MS:10080*60*1e3};function gE(e){let t=hE.INITIAL_DELAY_MS*hE.BACKOFF_MULTIPLIER**e;return Math.min(t,hE.MAX_DELAY_MS)}function _E(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>=hE.MAX_ATTEMPTS||t===`policy_blocked`||r&&i<r?!1:t===`unknown`||t===`git_unavailable`||t===`gcs_unavailable`||t===void 0}async function vE(){let e=rd();if(!_E(e)){let t=e.officialMarketplaceAutoInstallFailReason??`already_attempted`;return Y(`Official marketplace auto-install skipped: ${t}`),{installed:!1,skipped:!0,reason:t}}try{if(mE())return Y(`Official marketplace auto-install disabled via env var, skipping`),nd(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!1,officialMarketplaceAutoInstallFailReason:`policy_blocked`})),{installed:!1,skipped:!0,reason:`policy_blocked`};if((await So())[`claude-plugins-official`])return Y(`Official marketplace '${eu}' already installed, skipping`),nd(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!0})),{installed:!1,skipped:!0,reason:`already_installed`};if(!Os(zt))return Y(`Official marketplace blocked by enterprise policy, skipping`),nd(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!1,officialMarketplaceAutoInstallFailReason:`policy_blocked`})),{installed:!1,skipped:!0,reason:`policy_blocked`};let t=mo(),n=Ph(t,eu);if(await io(n,t)!==null){let e=await So();return e[eu]={source:zt,installLocation:n,lastUpdated:new Date().toISOString()},await Ba(e),nd(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!0,officialMarketplaceAutoInstallFailReason:void 0,officialMarketplaceAutoInstallRetryCount:void 0,officialMarketplaceAutoInstallLastAttemptTime:void 0,officialMarketplaceAutoInstallNextRetryTime:void 0})),{installed:!0,skipped:!1}}if(!await Lr()){Y(`Git not available, skipping official marketplace auto-install`);let t=(e.officialMarketplaceAutoInstallRetryCount||0)+1,n=Date.now(),r=n+gE(t),i=!1;try{nd(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!1,officialMarketplaceAutoInstallFailReason:`git_unavailable`,officialMarketplaceAutoInstallRetryCount:t,officialMarketplaceAutoInstallLastAttemptTime:n,officialMarketplaceAutoInstallNextRetryTime:r}))}catch(e){i=!0,X(du(e)),Y(`Failed to save marketplace auto-install git_unavailable state: ${e}`,{level:`error`})}return{installed:!1,skipped:!0,reason:`git_unavailable`,configSaveFailed:i}}return Y(`Attempting to auto-install official marketplace`),await us(zt),Y(`Successfully auto-installed official marketplace`),e.officialMarketplaceAutoInstallRetryCount,nd(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!0,officialMarketplaceAutoInstallFailReason:void 0,officialMarketplaceAutoInstallRetryCount:void 0,officialMarketplaceAutoInstallLastAttemptTime:void 0,officialMarketplaceAutoInstallNextRetryTime:void 0})),{installed:!0,skipped:!1}}catch(t){let n=t instanceof Error?t.message:String(t);if(n.includes(`xcrun: error:`))return xn(),Y(`Official marketplace auto-install: git is a non-functional macOS xcrun shim, treating as git_unavailable`),{installed:!1,skipped:!0,reason:`git_unavailable`};Y(`Failed to auto-install official marketplace: ${n}`,{level:`error`}),X(du(t));let r=(e.officialMarketplaceAutoInstallRetryCount||0)+1,i=Date.now(),a=i+gE(r),o=!1;try{nd(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!1,officialMarketplaceAutoInstallFailReason:`unknown`,officialMarketplaceAutoInstallRetryCount:r,officialMarketplaceAutoInstallLastAttemptTime:i,officialMarketplaceAutoInstallNextRetryTime:a}))}catch(e){o=!0,X(du(e)),Y(`Failed to save marketplace auto-install failure state: ${e}`,{level:`error`})}return{installed:!1,skipped:!0,reason:`unknown`,configSaveFailed:o}}}H(),gu();function yE(){dE(async()=>{let e=await vE(),t=[];return e.configSaveFailed&&(Y(`Showing marketplace config save failure notification`),t.push({key:`marketplace-config-save-failed`,jsx:(0,$.jsx)(x,{color:`error`,children:`Failed to save marketplace retry info · Check ~/.workmate.json permissions`}),priority:`immediate`,timeoutMs:1e4})),e.installed?(Y(`Showing marketplace installation success notification`),t.push({key:`marketplace-installed`,jsx:(0,$.jsx)(x,{color:`success`,children:`✓ Official 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)(x,{color:`warning`,children:`Failed to install official marketplace · Will retry on next startup`}),priority:`immediate`,timeoutMs:8e3})),t})}Hu(),Ed();function bE(e){if(e.length===0)return;if(e.length===1)return e[0];let t=e.map(e=>({tip:e,sessions:Ch(e.id)}));return t.sort((e,t)=>t.sessions-e.sessions),t[0]?.tip}async function xE(e){if(Bu().spinnerTipsEnabled===!1)return;let t=await Th(e);if(t.length!==0)return bE(t)}function SE(e){wh(e.id),e.id,e.cooldownSessions}su(),pd(),J();async function CE(e,t,n){}function wE(){let e=G(e=>e.mainLoopModel),t=G(e=>e.mainLoopModelForSession),n=G(e=>e.fastMode),r=An(),i=Yi(),a=(0,Q.useRef)(!0);(0,Q.useEffect)(()=>{a.current&&(a.current=!1),CE(i.getState().toolPermissionContext,r,n).catch(e=>{X(Error(`Auto mode gate check failed`,{cause:du(e)}))})},[e,t,n])}Xa();function TE(e,t,n){let r=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{!ht()||r.current||(r.current=!0,e&&zc(e,n))},[t,e,n])}H(),ws(),wp(),qm();function EE({hostPattern:{host:e},onUserResponse:t}){function n(e){switch(e){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`},...yt()?[]:[{label:(0,$.jsxs)(x,{children:[`Yes, and don't ask again for `,(0,$.jsx)(x,{bold:!0,children:e})]}),value:`yes-dont-ask-again`}],{label:(0,$.jsxs)(x,{children:[`No, and tell Work Mate what to do differently `,(0,$.jsx)(x,{bold:!0,children:`(esc)`})]}),value:`no`}];return(0,$.jsx)(Ym,{title:`Network request outside of sandbox`,children:(0,$.jsxs)(_,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsxs)(_,{children:[(0,$.jsx)(x,{dimColor:!0,children:`Host:`}),(0,$.jsxs)(x,{children:[` `,e]})]}),(0,$.jsx)(_,{marginTop:1,children:(0,$.jsx)(x,{children:`Do you want to allow this connection?`})}),(0,$.jsx)(_,{children:(0,$.jsx)(Tp,{options:r,onChange:n,onCancel:()=>{t({allow:!1,persistToSettings:!1})}})})]})})}H(),ws(),wd();function DE(e){return`${e.getHours()%12||12}:${String(e.getMinutes()).padStart(2,`0`)}:${String(e.getSeconds()).padStart(2,`0`)}${e.getHours()<12?`am`:`pm`}`}function OE(){let[e,t]=(0,Q.useState)([]),[n,r]=(0,Q.useState)(0);return(0,Q.useEffect)(()=>{let e=$t.getSandboxViolationStore();return e.subscribe(n=>{t(n.slice(-10)),r(e.getTotalCount())})},[]),!$t.isSandboxingEnabled()||Td()===`linux`||n===0?null:(0,$.jsxs)(_,{flexDirection:`column`,marginTop:1,children:[(0,$.jsx)(_,{marginLeft:0,children:(0,$.jsxs)(x,{color:`permission`,children:[`⧈ Sandbox blocked `,n,` total `,n===1?`operation`:`operations`]})}),e.map((e,t)=>(0,$.jsx)(_,{paddingLeft:2,children:(0,$.jsxs)(x,{dimColor:!0,children:[DE(e.timestamp),e.command?` ${e.command}:`:``,` `,e.line]})},`${e.timestamp.getTime()}-${t}`)),(0,$.jsx)(_,{paddingLeft:2,children:(0,$.jsxs)(x,{dimColor:!0,children:[`… showing last `,Math.min(10,e.length),` of `,n]})})]})}Lm(),Gf(),H();var kE=[];function AE({mcpClients:e=kE}){let{addNotification:t}=Wf();(0,Q.useEffect)(()=>{let n=e.filter(e=>e.type===`failed`&&e.config.type!==`sse-ide`&&e.config.type!==`ws-ide`),r=e.filter(e=>e.type===`needs-auth`);n.length===0&&r.length===0||(n.length>0&&t({key:`mcp-failed`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(x,{color:`error`,children:[n.length,` MCP `,n.length===1?`server`:`servers`,` failed`]}),(0,$.jsx)(x,{dimColor:!0,children:` · /mcp`})]}),priority:`medium`}),r.length>0&&t({key:`mcp-needs-auth`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(x,{color:`warning`,children:[r.length,` MCP `,r.length===1?`server needs`:`servers need`,` `,`auth`]}),(0,$.jsx)(x,{dimColor:!0,children:` · /mcp`})]}),priority:`medium`}))},[t,e])}H(),Hu(),Dm();var jE=`Auto mode lets Work Mate handle permission prompts automatically — Work Mate checks each tool call for risky actions and prompt injection before executing. Actions Work Mate identifies as safe are executed, while actions Work Mate identifies as risky are blocked and Work Mate may try a different approach. Ideal for long-running tasks. Sessions are slightly more expensive. Work Mate can make mistakes that allow harmful commands to run, it's recommended to only use in isolated environments. Shift+Tab to change mode.`;le(),Ie(),Gf(),H(),J(),gu(),o();var ME=5e3;function NE(){let{addNotification:e}=Wf(),t=An(),[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)(x,{color:`error`,children:[`LSP for `,o,` failed`]}),(0,$.jsx)(x,{dimColor:!0,children:` · /plugin for details`})]}),priority:`medium`,timeoutMs:8e3})},[e,t]),s=Q.useCallback(()=>{if(Ne())return;let e=rl();if(e.status===`failed`){o(`lsp-manager`,e.error.message),r(!1);return}if(e.status===`pending`||e.status===`not-started`)return;let t=ac();if(t){let e=t.getAllServers();for(let[t,n]of e)n.state===`error`&&n.lastError&&o(t,n.lastError.message)}},[o]);F(s,n?ME:null),Q.useEffect(()=>{n&&s()},[s,n])}gu();var PE=new Map;async function FE(e){if(!e?.trim())return Y(`[binaryCheck] Empty command provided, returning false`),!1;let t=e.trim(),n=PE.get(t);if(n!==void 0)return Y(`[binaryCheck] Cache hit for '${t}': ${n}`),n;let r=!1;return await Cd(t).catch(()=>null)&&(r=!0),PE.set(t,r),Y(`[binaryCheck] Binary '${t}' ${r?`found`:`not found`}`),r}td(),gu(),dl();var IE=5;function LE(e){return Xu.has(e.toLowerCase())}function RE(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=BE(t);if(e)return e}return null}return BE(e)}function zE(e){return typeof e==`object`&&!!e}function BE(e){let t=new Set,n=null;for(let[r,i]of Object.entries(e)){if(!zE(i))continue;!n&&typeof i.command==`string`&&(n=i.command);let e=i.extensionToLanguage;if(zE(e))for(let n of Object.keys(e))t.add(n.toLowerCase())}return!n||t.size===0?null:{extensions:t,command:n}}async function VE(){let e=new Map;try{let t=await So();for(let n of Object.keys(t))try{let t=await Yc(n),r=LE(n);for(let i of t.plugins){if(!i.lspServers)continue;let t=RE(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 HE(e){if(GE())return Y(`[lspRecommendation] Recommendations are disabled`),[];let t=Nh(e).toLowerCase();if(!t)return Y(`[lspRecommendation] No file extension found`),[];Y(`[lspRecommendation] Looking for LSP plugins for ${t}`);let n=await VE(),r=rd().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(lt(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 FE(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 UE(e){nd(t=>{let n=t.lspRecommendationNeverPlugins??[];return n.includes(e)?t:{...t,lspRecommendationNeverPlugins:[...n,e]}}),Y(`[lspRecommendation] Added ${e} to never suggest`)}function WE(){nd(e=>{let t=(e.lspRecommendationIgnoredCount??0)+1;return{...e,lspRecommendationIgnoredCount:t}}),Y(`[lspRecommendation] Incremented ignored count`)}function GE(){let e=rd();return e.lspRecommendationDisabled===!0||(e.lspRecommendationIgnoredCount??0)>=IE}l(),H(),pd(),dl();function KE(){let[e,t]=Q.useState(null),n=Q.useRef(!1),r=Q.useCallback(r=>{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 qE(e,t,n,r,i){try{let a=await Vs(e);if(!a)throw Error(`Plugin ${e} not found in marketplace`);await i(a),r({key:`${n}-installed`,jsx:(0,$.jsxs)(x,{color:`success`,children:[u.tick,` `,t,` installed · restart to apply`]}),priority:`immediate`,timeoutMs:5e3})}catch(e){X(e),r({key:`${n}-install-failed`,jsx:(0,$.jsxs)(x,{color:`error`,children:[`Failed to install `,t]}),priority:`immediate`,timeoutMs:5e3})}}Ie(),Gf(),J(),td(),gu(),pd(),Hu();var JE=28e3;function YE(){let e=G(e=>e.fileHistory.trackedFiles),{addNotification:t}=Wf(),n=Q.useRef(new Set),{recommendation:r,clearRecommendation:i,tryResolve:a}=KE();return Q.useEffect(()=>{a(async()=>{if(Qe())return null;let t=[];for(let r of e)n.current.has(r)||(n.current.add(r),t.push(r));for(let e of t)try{let t=(await HE(e))[0];if(t)return Y(`[useLspPluginRecommendation] Found match: ${t.pluginName} for ${e}`),Ge(!0),{pluginId:t.pluginId,pluginName:t.pluginName,pluginDescription:t.description,fileExtension:Nh(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`:qE(n,a,`lsp-plugin`,t,async e=>{Y(`[useLspPluginRecommendation] Installing plugin: ${n}`);let t=typeof e.entry.source==`string`?Ph(e.marketplaceInstallLocation,e.entry.source):void 0;await fi(n,e.entry,`user`,void 0,t),zu(`userSettings`,{enabledPlugins:{...Yu(`userSettings`)?.enabledPlugins,[n]:!0}}),Y(`[useLspPluginRecommendation] Plugin installed: ${n}`)});break;case`no`:{let e=Date.now()-o;e>=JE&&(Y(`[useLspPluginRecommendation] Timeout detected (${e}ms), incrementing ignored count`),WE());break}case`never`:UE(n);break;case`disable`:nd(e=>e.lspRecommendationDisabled?e:{...e,lspRecommendationDisabled:!0});break}i()},[r,t,i])}}H(),wp(),qm();var XE=3e4;function ZE({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`),XE,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)(Ym,{title:`LSP Plugin Recommendation`,children:(0,$.jsxs)(_,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsx)(_,{marginBottom:1,children:(0,$.jsx)(x,{dimColor:!0,children:`LSP provides code intelligence like go-to-definition and error checking`})}),(0,$.jsxs)(_,{children:[(0,$.jsx)(x,{dimColor:!0,children:`Plugin:`}),(0,$.jsxs)(x,{children:[` `,e]})]}),t&&(0,$.jsx)(_,{children:(0,$.jsx)(x,{dimColor:!0,children:t})}),(0,$.jsxs)(_,{children:[(0,$.jsx)(x,{dimColor:!0,children:`Triggered by:`}),(0,$.jsxs)(x,{children:[` `,n,` files`]})]}),(0,$.jsx)(_,{marginTop:1,children:(0,$.jsx)(x,{children:`Would you like to install this LSP plugin?`})}),(0,$.jsx)(_,{children:(0,$.jsx)(Tp,{options:[{label:(0,$.jsxs)(x,{children:[`Yes, install `,(0,$.jsx)(x,{bold:!0,children:e})]}),value:`yes`},{label:`No, not now`,value:`no`},{label:(0,$.jsxs)(x,{children:[`Never for `,(0,$.jsx)(x,{bold:!0,children:e})]}),value:`never`},{label:`Disable all LSP recommendations`,value:`disable`}],onChange:a,onCancel:()=>r(`no`)})})]})})}Gf(),Ed(),gu(),Nt();function QE(){let e=Q.useSyncExternalStore(ul,Jc),{addNotification:t}=Wf(),{recommendation:n,clearRecommendation:r,tryResolve:i}=KE();return Q.useEffect(()=>{e&&i(async()=>{let t=await da(e);return t&&(Y(`[useClaudeCodeHintRecommendation] surfacing ${t.pluginId} from ${t.sourceCommand}`),Bs()),Jc()===e&&fc(),t})},[e,i]),{recommendation:n,handleResponse:Q.useCallback(e=>{if(n){switch(Ca(n.pluginId),n.pluginName,n.marketplaceName,e){case`yes`:{let{pluginId:e,pluginName:r,marketplaceName:i}=n;qE(e,r,`hint-plugin`,t,async t=>{let n=await Ki({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`:Nc();break;case`no`:break}r()}},[n,t,r])}}H(),wp(),qm();var $E=3e4;function eD({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`),$E,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)(Ym,{title:`Plugin Recommendation`,children:(0,$.jsxs)(_,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsx)(_,{marginBottom:1,children:(0,$.jsxs)(x,{dimColor:!0,children:[`The `,(0,$.jsx)(x,{bold:!0,children:r}),` command suggests installing a plugin.`]})}),(0,$.jsxs)(_,{children:[(0,$.jsx)(x,{dimColor:!0,children:`Plugin:`}),(0,$.jsxs)(x,{children:[` `,e]})]}),(0,$.jsxs)(_,{children:[(0,$.jsx)(x,{dimColor:!0,children:`Marketplace:`}),(0,$.jsxs)(x,{children:[` `,n]})]}),t&&(0,$.jsx)(_,{children:(0,$.jsx)(x,{dimColor:!0,children:t})}),(0,$.jsx)(_,{marginTop:1,children:(0,$.jsx)(x,{children:`Would you like to install it?`})}),(0,$.jsx)(_,{children:(0,$.jsx)(Tp,{options:[{label:(0,$.jsxs)(x,{children:[`Yes, install `,(0,$.jsx)(x,{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`)})})]})})}wp(),qm();var tD=3e4;function nD({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(),tD,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)(Ym,{title:`Tool Recommendation`,children:(0,$.jsx)(Tp,{options:a,onChange:e=>{e===`__dismiss__`?i.current():(i.current(),r.current(e))}})})}var rD=.15,iD=3;function aD(){let e=Q.useSyncExternalStore(si,ua),t=Q.useMemo(()=>e.length===0?[]:e.slice(0,iD).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)>=rD,handleSelect:Q.useCallback(e=>{ba()},[]),handleDismiss:Q.useCallback(()=>{ba()},[])}}Gf(),H(),J(),gu(),xd();function oD(){let{addNotification:e}=Wf(),t=G(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(!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)(x,{color:`error`,children:[n,` `,yd(n,`plugin`),` failed to install`]}),(0,$.jsx)(x,{dimColor:!0,children:` · /plugin for details`})]}),priority:`medium`})))},[e,n,r,i])}Gf(),H(),gu(),th();function sD(){let{addNotification:e}=Wf(),[t,n]=(0,Q.useState)([]);(0,Q.useEffect)(()=>nh(e=>{Y(`Plugin autoupdate notification: ${e.length} plugin(s) updated`),n(e)}),[]),(0,Q.useEffect)(()=>{if(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)(x,{color:`success`,children:[n.length===1?`Plugin`:`Plugins`,` updated: `,r]}),(0,$.jsx)(x,{dimColor:!0,children:` · Run /reload-plugins to apply`})]}),priority:`low`,timeoutMs:1e4}),Y(`Showing plugin autoupdate notification for: ${n.join(`, `)}`)},[t,e])}gu(),pd(),dl(),Qp(),Ed();function cD(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 lD(e){Y(`performBackgroundPluginInstallations called`);try{let t=Xp(mc(),await So().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 Yp({onProgress:t=>{switch(t.type){case`installing`:cD(e,t.name,`installing`);break;case`installed`:cD(e,t.name,`installed`);break;case`failed`:cD(e,t.name,`failed`,t.error);break}}});if(Lu(`info`,`tengu_marketplace_background_install`,{installed_count:r.installed.length,updated_count:r.updated.length,failed_count:r.failed.length,up_to_date_count:r.upToDate.length}),r.installed.length>0){Za(),Y(`Auto-refreshing plugins after ${r.installed.length} new marketplace(s) installed`);try{await Zp(e)}catch(t){X(t),Y(`Auto-refresh failed, falling back to needsRefresh: ${t}`,{level:`warn`}),xt(`performBackgroundPluginInstallations: auto-refresh failed`),e(e=>e.plugins.needsRefresh?e:{...e,plugins:{...e.plugins,needsRefresh:!0}})}}else r.updated.length>0&&(Za(),xt(`performBackgroundPluginInstallations: marketplaces reconciled`),e(e=>e.plugins.needsRefresh?e:{...e,plugins:{...e.plugins,needsRefresh:!0}}))}catch(e){X(e)}}td(),gu(),dl(),Xr();async function uD(e){if(Y(`performStartupChecks called`),!id()){Y(`Trust not accepted for current directory - skipping plugin installations`);return}try{Y(`Starting background plugin installations`),await ns()&&(Za(),xt(`performStartupChecks: seed marketplaces changed`),e(e=>e.plugins.needsRefresh?e:{...e,plugins:{...e.plugins,needsRefresh:!0}})),await lD(e)}catch(e){Y(`Error initiating background plugin installations: ${e}`)}}Gf(),H(),vi();function dD(e){let{addNotification:t}=Wf(),n=tx(),r=(0,Q.useMemo)(()=>lc(n,e),[n,e]),i=(0,Q.useMemo)(()=>Wc(n),[n]),a=(0,Q.useRef)(null),o=CT(),[s,c]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{n.isUsingOverage&&!s&&o?(t({key:`limit-reached`,text:i,priority:`immediate`}),c(!0)):!n.isUsingOverage&&s&&c(!1)},[n.isUsingOverage,i,s,t,o]),(0,Q.useEffect)(()=>{r&&r!==a.current&&(a.current=r,t({key:`rate-limit-warning`,jsx:(0,$.jsx)(x,{children:(0,$.jsx)(x,{color:`warning`,children:r})}),priority:`high`}))},[r,t])}Gf();function fD(e){let{addNotification:t}=Wf(),n=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{let r=Sh(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])}o();var pD=``;function mD(){dE(async()=>vd()||a(process.env.DISABLE_INSTALLATION_CHECKS)||await wm()===`development`?null:{timeoutMs:15e3,key:`npm-deprecation-warning`,text:pD,color:`warning`,priority:`high`})}Gf(),H(),td(),Jl();var hD=5;function gD({ideSelection:e,mcpClients:t,ideInstallationStatus:n}){let{addNotification:r,removeNotification:i}=Wf(),{status:a,ideName:o}=ex(t),s=(0,Q.useRef)(!1),c=n?Gi(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(Tn()||a!==null||p){i(`ide-status-hint`);return}if(s.current||(rd().ideHintShownCount??0)>=hD)return;let e=setTimeout((e,t)=>{Yr(!0).then(n=>{let r=n[0]?.name;r&&!e.current&&(e.current=!0,nd(e=>({...e,ideHintShownCount:(e.ideHintShownCount??0)+1})),t({key:`ide-status-hint`,jsx:(0,$.jsxs)(x,{dimColor:!0,children:[`/ide for `,(0,$.jsx)(x,{color:`ide`,children:r})]}),priority:`low`}))})},3e3,s,r);return()=>clearTimeout(e)},[r,i,a,p]),(0,Q.useEffect)(()=>{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(!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(!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])}td();var _D=[e=>{if(yD(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(yD(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 vD(){dE(()=>{let e=rd(),t=[];for(let n of _D){let r=n(e);r&&t.push(r)}return t.length>0?t:null})}function yD(e){return e!==void 0&&Date.now()-e<3e3}Gf(),J(),oc(),Md();var bD=`fast-mode-cooldown-started`,xD=`fast-mode-cooldown-expired`,SD=`fast-mode-org-changed`,CD=`fast-mode-overage-rejected`;function wD(){let{addNotification:e}=Wf(),t=G(e=>e.fastMode),n=An();(0,Q.useEffect)(()=>{if($a())return pl(r=>{r?e({key:SD,color:`fastMode`,priority:`immediate`,text:`Fast mode is now available · /fast to turn on`}):t&&(n(e=>({...e,fastMode:!1})),e({key:SD,color:`warning`,priority:`immediate`,text:`Fast mode has been disabled by your organization`}))})},[e,t,n]),(0,Q.useEffect)(()=>{if($a())return Us(t=>{n(e=>({...e,fastMode:!1})),e({key:CD,color:`warning`,priority:`immediate`,text:t})})},[e,n]),(0,Q.useEffect)(()=>{if(!t)return;let n=ho((t,n)=>{let r=TD(n,Fd(t-Date.now(),{hideTrailingZeros:!0}));e({key:bD,invalidates:[xD],text:r,color:`warning`,priority:`immediate`})}),r=Zc(()=>{e({key:xD,invalidates:[bD],color:`fastMode`,text:`Fast limit reset · now using fast mode`,priority:`immediate`})});return()=>{n(),r()}},[e,t])}function TD(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}`}}ah(),H(),td(),Rp();function ED(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||!(rd().copyOnSelect??!0))return;let a=e.copySelectionNoClear();if(!a?.trim()){r.current=!0;return}r.current=!0,i.current?.(a)})},[t,e])}function DD(e){let[t]=g();(0,Q.useEffect)(()=>{e.setSelectionBgColor(Lp(t).selectionBg)},[e,t])}Gf(),H(),Ht(),gu();var OD=40,kD=.3,AD=6,jD=200,MD=15,ND=15,PD=3,FD=1500,ID=150,LD=5,RD=5,zD=80,BD=3,VD=6,HD=500;function UD(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 WD(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 GD(e,t,n){if(!e.xtermJs){if(e.wheelMode&&n-e.time>FD&&(e.wheelMode=!1,e.burstCount=0,e.mult=e.base),e.pendingFlip){if(e.pendingFlip=!1,t!==e.dir||n-e.time>jD)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<RD)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/ID),n=Math.max(ND,e.base*2),i=1+(e.mult-1)*t+MD*t;return e.mult=Math.min(n,i,e.mult+PD),Math.floor(e.mult)}if(r>OD)e.mult=e.base;else{let t=Math.max(AD,e.base*2);e.mult=Math.min(t,e.mult+kD)}return Math.floor(e.mult)}let r=n-e.time,i=t===e.dir;if(e.time=n,e.dir=t,i&&r<RD)return 1;if(!i||r>HD)e.mult=2,e.frac=0;else{let t=.5**(r/ID);e.mult=Math.min(r>=zD?BD:VD,1+(e.mult-1)*t+LD*t)}let a=e.mult+e.frac,o=Math.floor(a);return e.frac=a-o,o}function KD(){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 qD(e=!1,t=1){return{time:0,mult:t,dir:0,xtermJs:e,frac:0,base:t,pendingFlip:!1,wheelMode:!1,burstCount:0}}function JD(){let e=z(),t=KD();return Y(`wheel accel: ${e?`decay (xterm.js)`:`window (native)`} · base=${t} · TERM_PROGRAM=${process.env.TERM_PROGRAM??`unset`}`),qD(e,t)}var YD=2,XD=50,ZD=200;function QD({scrollRef:e,isActive:t,onScroll:n,isModal:r=!1}){let i=ae(),{addNotification:a}=Wf(),o=(0,Q.useRef)(null);function s(e){let t=B(),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 h({"scroll:pageUp":()=>{let t=e.current;if(!t)return;let r=-Math.max(1,Math.floor(t.getViewportHeight()/2));l(t,r);let i=tO(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=tO(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=JD()),rO(t,GD(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=JD());let r=nO(t,GD(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}),h({"scroll:halfPageUp":()=>{let t=e.current;if(!t)return;let r=-Math.max(1,Math.floor(t.getViewportHeight()/2));l(t,r);let i=tO(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=tO(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=tO(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=tO(t,r);n?.(i,t)}},{context:`Scroll`,isActive:t}),re((t,r,i)=>{let a=e.current;if(!a)return;let o=aO(a,iO(t,r),e=>l(a,e));o!==null&&(n?.(o,a),i.stopImmediatePropagation())},{isActive:t&&r}),re((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=WD(t);if(r){i.moveFocus(r),n.stopImmediatePropagation();return}UD(t)&&i.clearSelection()},{isActive:t}),$D(e,i,t,n),ED(i,t,s),DD(i),null}function $D(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>ZD){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(YD,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(YD,e-i.getScrollTop());t.captureScrolledRows(l,l+n-1,`above`),t.shiftAnchor(-n,l,u),i.scrollBy(YD)}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,XD)))}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=eO(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 eO(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 tO(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 nO(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 rO(e,t){if(e.getScrollTop()+e.getPendingDelta()-t<=0){e.scrollTo(0);return}e.scrollBy(-t)}function iO(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 aO(e,t,n){switch(t){case null:return null;case`lineUp`:case`lineDown`:{let r=t===`lineDown`?1:-1;return n(r),tO(e,r)}case`halfPageUp`:case`halfPageDown`:{let r=Math.max(1,Math.floor(e.getViewportHeight()/2)),i=t===`halfPageDown`?r:-r;return n(i),tO(e,i)}case`fullPageUp`:case`fullPageDown`:{let r=Math.max(1,e.getViewportHeight()),i=t===`fullPageDown`?r:-r;return n(i),tO(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}}}Ie(),$c(),Su(),l(),H(),Ts(),sm(),Gf(),gu(),o(),Md(),Tc(),vr(),bp(),Po(),tp(),Cf(),Cl(),Vr(),su(),br(),eo(),wt(),td(),Ed(),Kn(),md(),Wo(),Ra(),lh(),Np(),Zs(),mm(),J(),_t(),qo(),Xa(),Xo(),Jl(),Oi(),Tt(),Wl(),Ws(),ws(),xs();var oO=3e3;function sO({showAllInTranscript:e,virtualScroll:t,searchBadge:n,suppressShowAll:r=!1,status:i}){let a=ji(`app:toggleTranscript`,`Global`,`ctrl+o`),o=ji(`transcript:toggleShowAll`,`Transcript`,`ctrl+e`);return(0,$.jsxs)(_,{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)(x,{dimColor:!0,children:[`Showing detailed transcript · `,a,` to toggle`,n?` · n/N to navigate`:t?` · ${u.arrowUp}${u.arrowDown} scroll · home/end top/bottom`:r?``:` · ${o} to ${e?`collapse`:`show all`}`]}),i?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(_,{flexGrow:1}),(0,$.jsxs)(x,{children:[i,` `]})]}):n?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(_,{flexGrow:1}),(0,$.jsxs)(x,{dimColor:!0,children:[n.current,`/`,n.count,` `]})]}):null]})}function cO({jumpRef:e,count:t,current:n,onClose:r,onCancel:i,setHighlight:a,initialQuery:o}){let{query:s,cursorOffset:c}=Mm({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)(_,{borderTopDimColor:!0,borderBottom:!1,borderLeft:!1,borderRight:!1,borderStyle:`single`,marginTop:1,paddingLeft:2,width:`100%`,noSelect:!0,children:[(0,$.jsx)(x,{children:`/`}),(0,$.jsx)(x,{children:s.slice(0,f)}),(0,$.jsx)(x,{inverse:!0,children:p}),f<s.length&&(0,$.jsx)(x,{children:s.slice(f+1)}),(0,$.jsx)(_,{flexGrow:1}),l===`building`?(0,$.jsx)(x,{dimColor:!0,children:`indexing… `}):l?(0,$.jsxs)(x,{dimColor:!0,children:[`indexed in `,l.ms,`ms `]}):t===0&&s?(0,$.jsx)(x,{color:`error`,children:`no matches `}):t>0?(0,$.jsxs)(x,{dimColor:!0,children:[n,`/`,t,` `]}):null]})}var lO=[`⠂`,`⠐`],uO=`✳`,dO=960;function fO({isAnimating:e,title:t,disabled:n,noPrefix:r}){let i=O(),[a,o]=(0,Q.useState)(0);(0,Q.useEffect)(()=>{if(n||r||!e||!i)return;let t=setInterval(e=>e(e=>(e+1)%lO.length),dO,o);return()=>clearInterval(t)},[n,r,e,i]);let s=e?lO[a]??uO:uO;return A(n?null:r?t:`${s} ${t}`),null}var pO=`<${fd}>`;function mO(e){return e.type===`text`&&typeof e.text==`string`&&e.text.includes(pO)}function hO({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:v,onBeforeQuery:y,onTurnComplete:b,disabled:C=!1,mainThreadAgentDefinition:w,disableSlashCommands:T=!1,taskListId:E,thinkingConfig:D}){let k=(0,Q.useMemo)(()=>a(process.env.CLAUDE_CODE_DISABLE_TERMINAL_TITLE),[]),A=(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=${C}`),()=>Y(`[REPL:unmount] REPL unmounting`)),[C]);let[j,N]=(0,Q.useState)(w),P=G(e=>e.toolPermissionContext),F=G(e=>e.verbose),I=G(e=>e.mcp),L=G(e=>e.plugins),ne=G(e=>e.agentDefinitions),R=G(e=>e.fileHistory),z=G(e=>e.initialMessage),ie=Xb(),B=G(e=>e.spinnerTip),ae=G(e=>e.expandedView)===`tasks`,se=G(e=>e.tasks),H=G(e=>e.elicitation),le=G(e=>e.viewingAgentTaskId),U=An(),ue=le?se[le]:void 0,W=Qs(ue)&&ue.retain&&!ue.diskLoaded;(0,Q.useEffect)(()=>{if(!le||!W)return;let e=le;Na(Ei(e)).then(t=>{U(n=>{let r=n.tasks[e];if(!Qs(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}}}})})},[le,W,U]);let fe=Yi(),pe=S(),me=pm(),[he,ge]=(0,Q.useState)(t);YT(We(),ge);let _e=Q.useSyncExternalStore(fn,Sl),ve=Q.useSyncExternalStore(fn,os),ye=(0,Q.useMemo)(()=>sn(P),[P,_e]);wE();let[be,xe]=(0,Q.useState)(f),Se=(0,Q.useCallback)(e=>{xe(e)},[xe]),[Ce,we]=(0,Q.useState)(`prompt`),[Te,Ee]=(0,Q.useState)(!1),[De,Oe]=(0,Q.useState)(!1),[ke,Ae]=(0,Q.useState)(``),Ne=(0,Q.useRef)(0),Pe=(0,Q.useRef)(void 0),Ie=(0,Q.useRef)(!1),{addNotification:He,removeNotification:Ge}=Wf(),Ke=qT(d,I.clients),[Je,Ye]=(0,Q.useState)(void 0),[Ze,Qe]=(0,Q.useState)(null),[$e,tt]=(0,Q.useState)(null),[it,at]=(0,Q.useState)(!1);vD(),gD({ideSelection:Je,mcpClients:Ke,ideInstallationStatus:$e}),AE({mcpClients:Ke}),oD(),sD(),Im(),dD(me),wD(),fD(me),mD(),fE(),yE(),NE();let{recommendation:st,handleResponse:lt}=YE(),{recommendation:dt,handleResponse:ft}=QE(),pt=aD(),mt=(0,Q.useMemo)(()=>[...ye,...r],[ye,r]);dp({enabled:!0});let _t=Dp();(0,Q.useEffect)(()=>{uD(U)},[U]);let vt=am(mt,I.tools,P),{tools:yt,allowedAgentTypes:bt}=(0,Q.useMemo)(()=>{if(!j)return{tools:vt,allowedAgentTypes:void 0};let e=Ar(j,vt,!1,!0);return{tools:e.resolvedTools,allowedAgentTypes:e.allowedAgentTypes}},[j,vt]),xt=JT(JT(he,L.commands),I.commands),St=(0,Q.useMemo)(()=>T?[]:xt,[T,xt]);Y_(I.clients),ZT(I.clients,Ye);let[Ct,wt]=(0,Q.useState)(`responding`),Tt=(0,Q.useRef)(Ct);Tt.current=Ct;let[Dt,Ot]=(0,Q.useState)([]),[kt,At]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{if(kt&&!kt.isStreaming&&kt.streamingEndedAt){let e=3e4-(Date.now()-kt.streamingEndedAt);if(e>0){let t=setTimeout(At,e,null);return()=>clearTimeout(t)}else At(null)}},[kt]);let[jt,Mt]=(0,Q.useState)(null),Nt=(0,Q.useRef)(null);Nt.current=jt;let Pt=(0,Q.useRef)(0),[Ft,It]=(0,Q.useState)(!1),Lt=(0,Q.useRef)(()=>{}),Rt=(0,Q.useRef)(null),zt=(0,Q.useRef)(null),Bt=(0,Q.useRef)(0),Vt=Q.useRef(new K_).current,Ht=Q.useSyncExternalStore(Vt.subscribe,Vt.getSnapshot),[Gt,Kt]=Q.useState(!1),qt=Ht||Gt,[Yt,Xt]=Q.useState(void 0),Zt=Q.useRef(0),tn=Q.useRef(!1),rn=Q.useRef(0),an=Q.useRef(0),on=Q.useRef(null),cn=Q.useCallback(()=>{rn.current=Date.now(),an.current=0,on.current=null},[]),un=Q.useRef(!1);Ht&&!un.current&&cn(),un.current=Ht;let dn=Q.useCallback(e=>{Kt(e),e&&cn()},[cn]),mn=Q.useRef(void 0),[hn,yn]=Q.useState(!1),[bn,xn]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{bn?.notifications&&bn.notifications.forEach(e=>{He({key:`auto-updater-notification`,text:e,priority:`low`})})},[bn,He]),(0,Q.useEffect)(()=>{xr()&&ri().then(e=>{e&&He({key:`tmux-mouse-hint`,text:e,priority:`low`})})},[]);let[Cn,wn]=(0,Q.useState)(null),Tn=(0,Q.useRef)(null),En=(0,Q.useCallback)(e=>{if(e?.isLocalJSXCommand){let{clearLocalJSX:t,...n}=e;Tn.current={...n,isLocalJSXCommand:!0},wn(n);return}if(Tn.current){if(e?.clearLocalJSX){Tn.current=null,wn(null),Pt.current=Date.now();return}return}if(e?.clearLocalJSX){wn(null);return}wn(e)},[]),[kn,jn]=(0,Q.useState)([]),[Mn,Nn]=(0,Q.useState)(null),[Pn,Fn]=(0,Q.useState)([]),[In,zn]=(0,Q.useState)([]),Bn=G(e=>e.settings.terminalTitleFromRename)===!1?void 0:Ao(qe()),[Vn,Hn]=(0,Q.useState)(),Un=(0,Q.useRef)((i?.length??0)>0),Gn=j?.agentType,Kn=Bn??Gn??Vn??`Work Mate`,qn=kn.length>0||In.length>0,Jn=Cn?.isLocalJSXCommand===!0&&Cn?.jsx!=null,Zn=qt&&!qn&&!Jn;(0,Q.useEffect)(()=>{if(qt&&!qn&&!Jn)return z_(),()=>B_()},[qt,qn,Jn]);let Qn=qn||Jn?`waiting`:qt?`busy`:`idle`,$n=Qn===`waiting`?kn.length>0?`approve ${kn[0].tool.name}`:Jn?`dialog open`:`input needed`:void 0;(0,Q.useEffect)(()=>{gt({status:Qn,waitingFor:$n})},[Qn,$n]),M(null);let[K,er]=(0,Q.useState)(i??[]),nr=(0,Q.useRef)(K),ir=(0,Q.useRef)(!1),q=(0,Q.useCallback)(e=>{let t=nr.current,n=typeof e==`function`?e(nr.current):e;if(nr.current=n,n.length<Zt.current)Zt.current=0;else if(n.length>t.length&&tn.current){let e=n.length-t.length;(t.length===0||n[0]===t[0]?n.slice(-e):n.slice(0,e)).some(hc)?tn.current=!1:Zt.current=n.length}er(n)},[]),ar=(0,Q.useCallback)(e=>{e===void 0?tn.current=!1:(Zt.current=nr.current.length,tn.current=!0),Xt(e)},[]),{dividerIndex:or,dividerYRef:sr,onScrollAway:cr,onRepin:ur,jumpToNew:dr,shiftDivider:fr}=uh(K.length);pE(K,q,qt);let[pr,mr]=(0,Q.useState)(null),hr=(0,Q.useRef)(null),gr=(0,Q.useMemo)(()=>sh(K,or),[or,K.length]),_r=(0,Q.useCallback)(()=>{Rt.current?.scrollToBottom(),ur(),mr(null)},[ur,mr]),vr=K.at(-1),yr=vr!=null&&hc(vr);(0,Q.useEffect)(()=>{yr&&_r()},[yr,vr,_r]);let br=(0,Q.useCallback)((e,t)=>{Bt.current=Date.now(),e?ur():cr(t)},[ur,cr,U]),Sr=ET(o,q),Cr=(0,Q.useDeferredValue)(Q.useMemo(()=>K.length>500?K.slice(-500):K,[K])),wr=K.length-Cr.length;wr>0&&Y(`[useDeferredValue] Messages deferred by ${wr} (${Cr.length}→${K.length})`);let[Tr,Er]=(0,Q.useState)(null),[Dr,kr]=(0,Q.useState)(()=>Eh()),jr=(0,Q.useRef)(Dr);jr.current=Dr;let Pr=(0,Q.useRef)(null),Ir=(0,Q.useCallback)(e=>{jr.current===``&&e!==``&&Date.now()-Bt.current>=oO&&_r(),jr.current=e,kr(e),yn(e.trim().length>0)},[yn,_r]);(0,Q.useEffect)(()=>{if(Dr.trim().length===0)return;let e=setTimeout(yn,1500,!1);return()=>clearTimeout(e)},[Dr]);let[Lr,Rr]=(0,Q.useState)(`prompt`),[Br,Vr]=(0,Q.useState)(),[Hr,Ur]=(0,Q.useState)(new Set),Wr=(0,Q.useRef)(!1),[Gr,Kr]=(0,Q.useState)({}),[qr,Jr]=(0,Q.useState)(0),Yr=(0,Q.useRef)(0),Xr=(0,Q.useRef)([]),Qr=(0,Q.useCallback)(e=>{let t=Yr.current;if(Yr.current=e(t),Yr.current>t){let e=Xr.current;if(e.length>0){let t=e.at(-1);t.lastTokenTime=Date.now(),t.endResponseLength=Yr.current}}},[]),[ti,ni]=(0,Q.useState)(null),ii=!(G(e=>e.settings.prefersReducedMotion)??!1)&&!ce(),ai=(0,Q.useCallback)(e=>{ii&&ni(e)},[ii]),si=ti&&ii&&ti.substring(0,ti.lastIndexOf(`
|
|
120
|
+
`)+1)||null,[ci,di]=(0,Q.useState)(0),[fi,mi]=(0,Q.useState)(null),[hi,gi]=(0,Q.useState)(null),[_i,vi]=(0,Q.useState)(null),[yi,Ci]=(0,Q.useState)(!1),[wi,Ti]=(0,Q.useState)(void 0),[Di,Oi]=(0,Q.useState)(!1),[ki,ji]=(0,Q.useState)(Bh()),[Mi,Ni]=(0,Q.useState)(null),Pi=(0,Q.useRef)(!1),Ii=(0,Q.useRef)(ci);Ii.current=ci;let[Li]=(0,Q.useState)(()=>({current:rr(i,c)}));Wt(()=>{Li.current=Zr()});let[Ri,zi]=(0,Q.useState)(rd().hasAcknowledgedCostThreshold),[Bi,Vi]=(0,Q.useState)(`INSERT`),[Hi,Ui]=(0,Q.useState)(!1),[Wi,Gi]=(0,Q.useState)(!1),[Ki,qi]=(0,Q.useState)(!1),Ji=O(),Xi=(0,Q.useRef)(Ji);Xi.current=Ji;let[Qi]=g(),$i=Q.useRef(!1),ea=(0,Q.useCallback)(()=>{if($i.current)return;$i.current=!0;let e=nr.current.slice(ga.current);for(let t of oo(e))ha.current.add(t);ga.current=nr.current.length,xE({theme:Qi,readFileState:ma.current,bashTools:ha.current}).then(async e=>{if(e){let t=await e.content({theme:Qi});U(e=>({...e,spinnerTip:t})),SE(e)}else U(e=>e.spinnerTip===void 0?e:{...e,spinnerTip:void 0})})},[U,Qi]),na=(0,Q.useCallback)(()=>{dn(!1),ar(void 0),Yr.current=0,Xr.current=[],ni(null),Ot([]),mi(null),gi(null),vi(null),ea(),_f(),nn()},[ea]),ra=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{if(P.mode!==`auto`){ra.current=!1;return}if(ra.current||(rd().autoPermissionsNotificationCount??0)>=3)return;let e=setTimeout((e,t)=>{e.current=!0,nd(e=>{let t=e.autoPermissionsNotificationCount??0;return t>=3?e:{...e,autoPermissionsNotificationCount:t+1}}),t(e=>[...e,ml(jE,`warning`)])},800,ra,q);return()=>clearTimeout(e)},[P.mode,q]);let aa=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{if(aa.current)return;let e=Gl();if(!e?.creationDurationMs||e.usedSparsePaths||e.creationDurationMs<15e3)return;aa.current=!0;let t=Math.round(e.creationDurationMs/1e3);q(e=>[...e,ml(`Worktree creation took ${t}s. For large repos, set \`worktree.sparsePaths\` in .workmate/settings.json to check out only the directories you need — e.g. \`{"worktree": {"sparsePaths": ["src", "packages/foo"]}}\`.`,`info`)])},[q]);let oa=(0,Q.useMemo)(()=>{let e=K.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`&&Hr.has(e.id));return n.length>0&&n.every(e=>e.type===`tool_use`&&e.name===`Sleep`)},[K,Hr]),{onBeforeQuery:sa,onTurnComplete:ca,render:la}=xT({enabled:!1,setMessages:q,inputValue:Dr,setInputValue:Ir,setToolJSX:En}),ua=(!Cn||Cn.showSpinner===!0)&&kn.length===0&&In.length===0&&(qt||Yt||ln()>0)&&!oa&&!si;kn.length>0||In.length>0||Pn.length>0||H.queue.length,cE({autoConnectIdeFlag:p,ideToInstallExtension:Ze,setDynamicMcpConfig:xe,setShowIdeOnboarding:at,setIDEInstallationState:tt}),TE(s,R,e=>U(t=>({...t,fileHistory:e})));let da=(0,Q.useCallback)(async(t,n,r)=>{let i=performance.now();try{let a=gp(n.messages),o=pc();await Fc(`resume`,{getAppState:()=>fe.getState(),setAppState:U,signal:AbortSignal.timeout(o),timeoutMs:o});let s=await rc(`resume`,{sessionId:t,agentType:j?.agentType,model:me});a.push(...s),r===`fork`?Ic(n,Jt(t)):Xn(n,Jt(t)),Gp(n,U),n.fileHistorySnapshots&&Pa(n);let{agentDefinition:c}=Up(n.agentSetting,w,ne);N(c),U(e=>({...e,agent:c?.agentType})),U(e=>({...e,standaloneAgentContext:Wp(n.agentName,n.agentColor)})),Eo(n.agentName),ya(a,n.projectPath??et()),na(),Mt(null),ji(t);let l=vo(t);if(Ks(),Be(),Me(Jt(t),n.fullPath?Mh(n.fullPath):null),await wa(),ia(),fa(n),n.goal){let{hydrateGoalFromTranscript:r}=(ut(),e(oi)),i=new Map;i.set(t,n.goal),r(i,t)}if(Un.current=!0,Hn(void 0),r!==`fork`)Kp(),qp(n.worktreeSession),Rn();else{let e=Gl();e&&Ja(e)}l&&Le(l),Li.current&&r!==`fork`&&(Li.current=pi(a,n.contentReplacements??[])),q(()=>a),En(null),Ir(``),Math.round(performance.now()-i)}catch(e){throw e}},[na,U]),[pa]=(0,Q.useState)(()=>Dn(100)),ma=(0,Q.useRef)(pa),ha=(0,Q.useRef)(new Set),ga=(0,Q.useRef)(0),_a=(0,Q.useRef)(new Set),va=(0,Q.useRef)(new Set),ya=(0,Q.useCallback)((e,t)=>{let n=Il(e,t,100);ma.current=ta(ma.current,n);for(let t of oo(e))ha.current.add(t)},[]);(0,Q.useEffect)(()=>{i&&i.length>0&&ya(i,et())},[]);let{status:ba,reverify:Sa}=DT(),[Ca,Ta]=(0,Q.useState)(null),[Ea,Da]=(0,Q.useState)(!1),Oa=!qt&&Di;function ka(){if(Ea||Ca)return;if(yi)return`message-selector`;if(hn)return;if(Pn[0])return`sandbox-permission`;let e=!Cn||Cn.shouldContinueAnimation;if(e&&kn[0])return`tool-permission`;if(e&&In[0])return`prompt`;if(e&&H.queue[0])return`elicitation`;if(e&&Oa)return`cost`;if(e&&Mi)return`idle-return`;if(e&&it)return`ide-onboarding`;if(e&&st)return`lsp-recommendation`;if(e&&dt)return`plugin-hint`;if(e&&pt.visible)return`search-extra-tools-hint`}let Aa=ka(),ja=hn&&(Pn[0]||kn[0]||In[0]||H.queue[0]||Oa);mn.current=Aa,(0,Q.useEffect)(()=>{if(!qt)return;let e=Aa===`tool-permission`,t=Date.now();e&&on.current===null?on.current=t:!e&&on.current!==null&&(an.current+=t-on.current,on.current=null)},[Aa,qt]);let Ma=(0,Q.useRef)(Aa);(0,Q.useLayoutEffect)(()=>{Ma.current===`tool-permission`!=(Aa===`tool-permission`)&&_r(),Ma.current=Aa},[Aa,_r]);function Fa(){if(Aa!==`elicitation`){if(Pt.current!==0&&Date.now()-Pt.current<500){Pt.current=0,Y(`[onCancel] suppressed: local-jsx panel just dismissed`);return}if(Pt.current=0,Y(`[onCancel] focusedInputDialog=${Aa} streamMode=${Ct}`),co(),Vt.getSnapshot()){let{getGoal:t,pauseGoal:n}=(ll(),e(fo)),{persistCurrentGoal:r}=(ut(),e(oi));t()?.status===`active`&&(n(),r())}if(It(!0),Vt.forceEnd(),Pi.current=!1,ti?.trim()&&q(e=>[...e,yc({content:ti})]),na(),Ve(null),Aa===`tool-permission`)kn[0]?.onAbort(),jn([]);else if(Aa===`prompt`){for(let e of In)e.reject(Error(`Prompt cancelled by user`));zn([]),jt?.abort(`user-cancel`)}else jt?.abort(`user-cancel`);Mt(null),ca(nr.current,!0)}}let Ra=(0,Q.useCallback)(()=>{let e=$r(Dr,0);e&&(Ir(e.text),Rr(`prompt`),e.images.length>0&&Kr(t=>{let n={...t};for(let t of e.images)n[t.id]=t;return n}))},[Ir,Rr,Dr,Kr]),za={setToolUseConfirmQueue:jn,onCancel:Fa,onAgentsKilled:()=>q(e=>[...e,_o()]),isMessageSelectorVisible:yi||!!Hi,screen:Ce,abortSignal:jt?.signal,popCommandFromQueue:Ra,vimMode:Bi,isLocalJSXCommand:Cn?.isLocalJSXCommand,isSearchingHistory:Wi,isHelpOpen:Ki,inputMode:Lr,inputValue:Dr,streamMode:Ct};(0,Q.useEffect)(()=>{Xe()>=5&&!Di&&!Ri&&(zi(!0),ST()&&Oi(!0))},[K,Di,Ri]);let Ba=(0,Q.useCallback)(async e=>new Promise(t=>{let n=!1;function r(e){n||(n=!0,t(e))}Fn(t=>[...t,{hostPattern:e,resolvePromise:r}])}),[U,fe]);(0,Q.useEffect)(()=>{let e=$t.getSandboxUnavailableReason();if(e){if($t.isSandboxRequired()){process.stderr.write(`\nError: sandbox required but unavailable: ${e}\n sandbox.failIfUnavailable is set — refusing to start without a working sandbox.\n\n`),$o(1,`other`);return}Y(`sandbox disabled: ${e}`,{level:`warn`}),He({key:`sandbox-unavailable`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(x,{color:`warning`,children:`sandbox disabled`}),(0,$.jsx)(x,{dimColor:!0,children:` · /sandbox`})]}),priority:`medium`})}},[He]),$t.isSandboxingEnabled()&&$t.initialize(Ba).catch(e=>{process.stderr.write(`\n❌ Sandbox Error: ${cu(e)}\n`),$o(1,`other`)});let Va=(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]),Ha=zT(jn,Va),Ua=(0,Q.useCallback)((e,t,r,i)=>{let a=fe.getState(),o=()=>{let e=fe.getState(),t=Ut(e.toolPermissionContext,e.mcp.tools),n=mp(mt,t,e.toolPermissionContext.mode);return j?Ar(j,n,!1,!0).resolvedTools:n};return{abortController:r,options:{commands:St,tools:o(),debug:n,verbose:a.verbose,mainLoopModel:i,thinkingConfig:a.thinkingEnabled===!1?{type:`disabled`}:D,mcpClients:KT(d,a.mcp.clients),mcpResources:a.mcp.resources,ideInstallationStatus:$e,isNonInteractiveSession:!1,dynamicMcpConfig:be,theme:Qi,agentDefinitions:bt?{...a.agentDefinitions,allowedAgentTypes:bt}:a.agentDefinitions,customSystemPrompt:h,appendSystemPrompt:v,refreshTools:o},getAppState:()=>fe.getState(),setAppState:U,messages:e,setMessages:q,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:()=>{C||Ci(!0)},onChangeAPIKey:Sa,readFileState:ma.current,setToolJSX:En,addNotification:He,appendSystemMessage:e=>q(t=>[...t,e]),sendOSNotification:e=>{D_(e,pe)},onChangeDynamicMcpConfig:Se,onInstallIDEExtension:Qe,nestedMemoryAttachmentTriggers:new Set,loadedNestedMemoryPaths:va.current,dynamicSkillDirTriggers:new Set,discoveredSkillNames:_a.current,setResponseLength:Qr,pushApiMetricsEntry:void 0,setStreamMode:wt,onCompactProgress:e=>{switch(e.type){case`hooks_start`:gi(`claudeBlue_FOR_SYSTEM_SPINNER`),vi(`claudeBlueShimmer_FOR_SYSTEM_SPINNER`),mi(e.hookType===`pre_compact`?`Running PreCompact hooks…`:e.hookType===`post_compact`?`Running PostCompact hooks…`:`Running SessionStart hooks…`);break;case`compact_start`:mi(`Compacting conversation`);break;case`compact_end`:mi(null),gi(null),vi(null);break}},setInProgressToolUseIDs:Ur,setHasInterruptibleToolInProgress:e=>{Wr.current=e},resume:da,setConversationId:ji,requestPrompt:void 0,contentReplacementState:Li.current}},[St,mt,j,n,d,$e,be,Qi,bt,fe,U,Sa,He,q,Se,da,(0,Q.useCallback)((e,t)=>n=>new Promise((r,i)=>{zn(a=>[...a,{request:n,title:e,toolInputSummary:t,resolve:r,reject:i}])}),[]),C,h,v,ji]),{handleBackgroundSession:Wa}=uE({setMessages:q,setIsLoading:dn,resetLoadingState:na,setAbortController:Mt,onBackgroundQuery:(0,Q.useCallback)(()=>{jt?.abort(`background`);let e=gn(e=>e.mode===`task-notification`);(async()=>{let t=Ua(nr.current,[],new AbortController,me),[n,r,i]=await Promise.all([gc(t.options.tools,me,Array.from(P.additionalWorkingDirectories.keys()),t.options.mcpClients),_n(),ei()]),a=_s({mainThreadAgentDefinition:j,toolUseContext:t,customSystemPrompt:h,defaultSystemPrompt:n,appendSystemPrompt:v});t.renderedSystemPrompt=a;let o=(await jo(e).catch(()=>[])).map(ui),s=new Set;for(let e of nr.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)));Vl({messages:[...nr.current,...c],queryParams:{systemPrompt:a,userContext:r,systemContext:i,canUseTool:Ha,toolUseContext:t,querySource:Wn()},description:Kn,setAppState:U,agentDefinition:j})})()},[jt,me,P,j,Ua,h,v,Ha,U])}),Ga=(0,Q.useCallback)(t=>{xa(t,t=>{if(Ms(t)?(xr()?q(e=>{let n=sc(e,{includeSnipped:!0});return[...n.length>500?n.slice(-500):n,t]}):q(()=>[t]),ji(Bh()),Qt(!1)):t.type===`progress`&&Ul(t.data?.type)?q(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]}):q(e=>[...e,t]),t.type===`assistant`&&`isApiErrorMessage`in t&&t.isApiErrorMessage?Qt(!0):t.type===`assistant`&&Qt(!1),t.type===`assistant`&&`isApiErrorMessage`in t&&t.isApiErrorMessage){let n=(ss(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}=(ll(),e(fo)),{persistCurrentGoal:r}=(ut(),e(oi));t()?.status===`active`&&(n(),r(),He({key:`goal-auto-paused-connectivity-error`,text:`Detected connection error. Active goal was auto-paused. Run /goal resume after network recovers.`,priority:`immediate`}))}}},e=>{Qr(t=>t+e.length)},wt,Ot,e=>{q(t=>t.filter(t=>t!==e)),tr(e.uuid)},At,e=>{let t=Date.now(),n=Yr.current;Xr.current.push({...e,firstTokenTime:t,lastTokenTime:t,responseLengthBaseline:n,endResponseLength:n})},ai)},[q,Qr,wt,Ot,At,ai]),Ka=(0,Q.useCallback)(async(e,t,n,r,i,a)=>{if(r){let e=KT(d,fe.getState().mcp.clients);xi.handleQueryStart(e);let t=pn(e);t&&Or(t)}if(cf(),!k&&!Bn&&!Gn&&!Un.current){let e=t.find(e=>e.type===`user`&&!e.isMeta),n=e?.type===`user`?ss(e.message.content):null;n&&!n.startsWith(`<local-command-stdout>`)&&!n.startsWith(`<command-message>`)&&!n.startsWith(`<command-name>`)&&!n.startsWith(`<bash-input>`)&&(Un.current=!0,zp(n,new AbortController().signal).then(e=>{e?Hn(e):Un.current=!1},()=>{Un.current=!1}))}if(fe.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(Ms)&&(ji(Bh()),Qt(!1)),na(),Mt(null);return}let o=Ua(e,t,n,a),{tools:s,mcpClients:c}=o.options;Rl(`query_context_loading_start`);let[,,l,u,f]=await Promise.all([void 0,CE(P,U,fe.getState().fastMode),gc(s,a,Array.from(P.additionalWorkingDirectories.keys()),c),_n(),ei()]),p={...u,...Sl()&&!Xi.current?{terminalFocus:`The terminal is unfocused — the user is not actively watching.`}:{}};Rl(`query_context_loading_end`);let m=_s({mainThreadAgentDefinition:j,toolUseContext:o,customSystemPrompt:h,defaultSystemPrompt:l,appendSystemPrompt:v});o.renderedSystemPrompt=m,Rl(`query_query_start`),je(),Fe(),Ue();for await(let t of Yn({messages:e,systemPrompt:m,userContext:p,systemContext:f,canUseTool:Ha,toolUseContext:o,querySource:Wn()}))Ga(t);Rl(`query_end`),na(),gl(),await b?.(nr.current)},[d,na,Ua,P,U,h,b,v,Ha,j,Ga,Bn,k]),qa=(0,Q.useCallback)(async(e,t,n,r,i,a,o)=>{let s=Vt.tryStart();if(s===null)return e.filter(e=>e.type===`user`&&!e.isMeta).map(e=>ss(e.message.content)).filter(e=>e!==null).forEach((e,t)=>{Tl({value:e,mode:`prompt`})}),!1;try{It(!1),cn(),q(t=>[...t,...e]),Yr.current=0,Ve((o?tc(o):null)??rt()),Xr.current=[],Ot([]),ni(null);let s=nr.current;if(o&&await sa(o,s,e.length),a&&o&&!await a(o,s))return!0;await Ka(s,e,t,n,r,i)}finally{if(Vt.end(s)){It(t.signal.aborted),di(Date.now()),Pi.current=!1,na(),await ca(nr.current,t.signal.aborted);let e;rt()!==null&&rt()>0&&!t.signal.aborted&&(e={tokens:Re(),limit:rt(),nudges:ot()}),Ve(null);let n=Date.now()-rn.current-an.current;(n>3e4||e!==void 0)&&!t.signal.aborted&&!_e&&q(t=>[...t,Ll(n,e,Fu(t,Fl))]),Mt(null)}if(t.signal.reason===`user-cancel`&&!Vt.isActive&&jr.current===``&&ln()===0&&!fe.getState().viewingAgentTaskId){let e=nr.current,t=e.findLast(_p);t&&vp(e,e.lastIndexOf(t))&&(rp(),Lt.current(t))}}return!0},[Ka,U,na,Vt,sa,ca]),Ya=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{let e=z;if(!e||qt||Ya.current)return;Ya.current=!0;async function t(e){if(e.clearContext){let t=e.message.planContent?La():void 0,{clearConversation:n}=await import(`./conversation-BIPJEOwO.js`);await n({setMessages:q,readFileState:ma.current,discoveredSkillNames:_a.current,loadedNestedMemoryPaths:va.current,getAppState:()=>fe.getState(),setAppState:U,setConversationId:ji}),Un.current=!1,Hn(void 0),ha.current.clear(),ga.current=0,t&&wo(qe(),t)}U(t=>{let n=e.mode?Et(t.toolPermissionContext,Xy(e.mode,e.allowedPrompts)):t.toolPermissionContext;return e.mode===`auto`&&(n=Cs({...n,mode:`auto`,prePlanMode:void 0})),{...t,initialMessage:null,toolPermissionContext:n}}),ht()&&ic(e=>{U(t=>({...t,fileHistory:e(t.fileHistory)}))},e.message.uuid),await Sr();let t=e.message.message.content;if(typeof t==`string`&&!e.message.planContent)Xa(t,{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}});else{let t=go();Mt(t),qa([e.message],t,!0,[],me)}setTimeout(e=>{e.current=!1},100,Ya)}t(e)},[z,qt,q,U,qa,me,yt]);let Xa=(0,Q.useCallback)(async(e,t,n,r)=>{if(_r(),Ai(),!n&&e.trim().startsWith(`/`)){let n=Qf(e,Gr).trim(),i=n.indexOf(` `),a=i===-1?n.slice(1):n.slice(1,i),o=i===-1?``:n.slice(i+1).trim(),s=St.find(e=>vn(e)&&(e.name===a||e.aliases?.includes(a)||Mr(e)===a));s?.name===`clear`&&ir.current&&(ir.current,Math.round((Date.now()-Ii.current)/6e4),nr.current.length,nt(),ir.current=!1);let c=Vt.isActive&&(s?.immediate||r?.fromKeybinding);if(s&&c&&s.type===`local-jsx`){e.trim()===jr.current.trim()&&(Ir(``),t.setCursorOffset(0),t.clearBuffer(),Kr({}));let n=Zf(e).filter(e=>Gr[e.id]?.type===`text`);n.length,n.reduce((e,t)=>e+(Gr[t.id]?.content.length??0),0),s.name,r?.fromKeybinding,(async()=>{let e=!1,n=(n,r)=>{e=!0,En({jsx:null,shouldHidePromptInput:!1,clearLocalJSX:!0});let i=[];if(n&&r?.display!==`skip`&&(He({key:`immediate-${s.name}`,text:n,priority:`immediate`}),!xr())){let e=r?.displayArgs??o;i.push(Gs(bi(Mr(s),e)),Gs(`<${cd}>${Fi(n)}</${cd}>`))}r?.metaMessages?.length&&i.push(...r.metaMessages.map(e=>Al({content:e,isMeta:!0}))),i.length&&q(e=>[...e,...i]),Br!==void 0&&(Ir(Br.text),t.setCursorOffset(Br.cursorOffset),Kr(Br.pastedContents),Vr(void 0))},r=Ua(nr.current,[],go(),me),i=await(await s.load()).call(n,r,o);i&&!e&&En({jsx:i,shouldHidePromptInput:!1,isLocalJSXCommand:!0})})();return}}Number(process.env.CLAUDE_CODE_IDLE_THRESHOLD_MINUTES??75),Number(process.env.CLAUDE_CODE_IDLE_TOKEN_THRESHOLD??1e5),r?.fromKeybinding||(np({display:n?e:Hf(e,Lr),pastedContents:n?{}:Gr}),Lr===`bash`&&Zx(e.trim()));let i=!n&&e.trim().startsWith(`/`),a=!qt||n;if(Br!==void 0&&!i&&a?(Ir(Br.text),t.setCursorOffset(Br.cursorOffset),Kr(Br.pastedContents),Vr(void 0)):a&&(r?.fromKeybinding||(Ir(``),t.setCursorOffset(0)),Kr({})),a&&(Rr(`prompt`),Ye(void 0),Jr(e=>e+1),t.clearBuffer(),$i.current=!1,!i&&Lr===`prompt`&&!n&&(ar(e),cn()),U(e=>({...e,attribution:Lo(e.attribution,e=>{lr(e).catch(e=>{Y(`Attribution: Failed to save snapshot: ${e}`)})})}))),n){let{queryRequired:t}=await bl(n.state,n.speculationSessionTimeSavedMs,n.setAppState,e,{setMessages:q,readFileState:ma,cwd:et()});if(t){let e=go();Mt(e),qa([],e,!0,[],me)}return}await Sr(),await VT({input:e,helpers:t,queryGuard:Vt,isExternalLoading:Gt,mode:Lr,commands:St,onInputChange:Ir,setPastedContents:Kr,setToolJSX:En,getToolUseContext:Ua,messages:nr.current,mainLoopModel:me,pastedContents:Gr,ideSelection:Je,setUserInputOnProcessing:ar,setAbortController:Mt,abortController:jt,onQuery:qa,setAppState:U,querySource:Wn(),onBeforeQuery:y,canUseTool:Ha,addNotification:He,setMessages:q,streamMode:Tt.current,hasInterruptibleToolInProgress:Wr.current}),(i||qt)&&Br!==void 0&&(Ir(Br.text),t.setCursorOffset(Br.cursorOffset),Kr(Br.pastedContents),Vr(void 0))},[Vt,qt,Gt,Lr,St,Ir,Rr,Kr,Jr,Ye,En,Ua,me,Gr,Je,ar,Mt,He,qa,Br,Vr,U,y,Ha,q,Sr,_r]),Za=(0,Q.useRef)(Xa);Za.current=Xa;let Qa=(0,Q.useCallback)(async()=>{if(Da(!0),Ia()){Uh(`tmux`,[`detach-client`],{stdio:`ignore`}),Da(!1);return}if(Gl()!==null){Ta((0,$.jsx)(Vm,{showWorktree:!0,onDone:()=>{},onCancel:()=>{Ta(null),Da(!1)}}));return}let e=await(await Ln.load()).call(()=>{});Ta(e),e===null&&Da(!1)},[]),$a=(0,Q.useCallback)(()=>{Ci(e=>!e)},[]),eo=(0,Q.useCallback)(e=>{let t=nr.current,n=t.lastIndexOf(e);if(n===-1)return;t.length,t.length-n,q(t.slice(0,n)),ji(Bh()),On();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}}))},[q,U]),to=(0,Q.useCallback)(e=>{eo(e);let t=al(e);if(t&&(Ir(t.text),Rr(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}}}),Kr(n)}}},[eo,Ir]);Lt.current=to;let no=(0,Q.useCallback)(async e=>{setImmediate((e,t)=>e(t),to,e)},[to]),ro=e=>{let t=e.slice(0,24);return K.findIndex(e=>e.uuid.slice(0,24)===t)},{enter:io,handlers:ao}=Si(pr,mr,hr,{copy:e=>void te(e).then(e=>{e&&process.stdout.write(e),He({key:`selection-copied`,text:`copied`,color:`success`,priority:`immediate`,timeoutMs:2e3})}),edit:async e=>{let t=ro(e.uuid),n=t>=0?K[t]:void 0;if(!n||!_p(n))return;let r=!await nl(R,n.uuid),i=vp(K,t);r&&i?(Fa(),no(n)):(Ti(n),Ci(!0))}});async function so(){Sa();let e=await zr();if(e.length>0){let t=e.map(e=>` [${e.type}] ${e.path} (${e.content.length} chars)${e.parent?` (included by ${e.parent})`:``}`).join(`
|
|
121
|
+
`);Y(`Loaded ${e.length} AGENTS.md/rules files:\n${t}`)}else Y(`No AGENTS.md/rules files found`);for(let t of e)ma.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})}wT(bh()),q_(K,K.length===i?.length),TT();let lo=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{if(ie.length<1){lo.current=!1;return}lo.current||(lo.current=!0,nd(e=>({...e,promptQueueUseCount:(e.promptQueueUseCount??0)+1})))},[ie.length]),GT({executeQueuedInput:(0,Q.useCallback)(async e=>{await VT({helpers:{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}},queryGuard:Vt,commands:St,onInputChange:()=>{},setPastedContents:()=>{},setToolJSX:En,getToolUseContext:Ua,messages:K,mainLoopModel:me,ideSelection:Je,setUserInputOnProcessing:ar,setAbortController:Mt,onQuery:qa,setAppState:U,querySource:Wn(),onBeforeQuery:y,canUseTool:Ha,addNotification:He,setMessages:q,queuedCommands:e})},[Vt,St,En,Ua,K,me,Je,ar,Ha,Mt,qa,He,U,y]),hasActiveLocalJsxUI:Jn,queryGuard:Vt}),(0,Q.useEffect)(()=>{Op.recordUserActivity(),ze(!0)},[Dr,qr]),(0,Q.useEffect)(()=>{qr===1&&Dh()},[qr]),(0,Q.useEffect)(()=>{if(qt||qr===0||ci===0)return;let e=setTimeout((e,t,n,r,i)=>{if(ct()>e)return;let a=Date.now()-e;!t&&!n&&r.current===void 0&&a>=rd().messageIdleNotifThresholdMs&&D_({message:`Work Mate is waiting for your input`,notificationType:`idle_prompt`},i)},rd().messageIdleNotifThresholdMs,ci,qt,Cn,mn,pe);return()=>clearTimeout(e)},[qt,Cn,qr,ci,pe]),(0,Q.useEffect)(()=>{},[ci,qt,He,Ge]),nE({isLoading:qt||z!==null,queuedCommandsLength:ie.length,hasActiveLocalJsxUI:Jn,isInPlanMode:P.mode===`plan`,onQueueTick:e=>Tl(e)}),sE({isLoading:qt||z!==null,wasAborted:Ft,queuedCommandsLength:ie.length,hasActiveLocalJsxUI:Jn,isInPlanMode:P.mode===`plan`,isQueryActiveNow:Vt.getSnapshot,onContinuationEnqueued:({turn:e,objective:t})=>{let n=`Goal auto-continue (${e}/1): continue advancing "${t}".`;q(e=>[...e,Al({content:n,isVisibleInTranscriptOnly:!0})])},onMaxTurnsReached:()=>{He({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(!_e){Nr(null);return}if(!qt){if(ve!==null&&ie.length===0&&!Jn&&P.mode!==`plan`&&z===null){Nr({enabled:!0,phase:`standby`,next_tick_at:ve,sleep_until:null});return}Nr({enabled:!0,phase:null,next_tick_at:null,sleep_until:null})}},[z,qt,Jn,_e,ve,ie.length,P.mode]),(0,Q.useEffect)(()=>{ie.some(e=>e.priority===`now`)&&Nt.current?.abort(`interrupt`)},[ie]);let uo=(0,Q.useRef)(so);uo.current=so;let po=(0,Q.useRef)(xi);po.current=xi,(0,Q.useEffect)(()=>(uo.current(),()=>{po.current.shutdown()}),[]);let{internal_eventEmitter:mo}=ee(),[ho,yo]=(0,Q.useState)(0);(0,Q.useEffect)(()=>{let e=()=>{process.stdout.write(`
|
|
122
|
+
Work Mate has been suspended. Run \`fg\` to bring Work Mate back.
|
|
123
|
+
Note: ctrl + z now suspends Work Mate, ctrl + _ undoes input.
|
|
124
|
+
`)},t=()=>{yo(e=>e+1)};return mo?.on(`suspend`,e),mo?.on(`resume`,t),()=>{mo?.off(`suspend`,e),mo?.off(`resume`,t)}},[mo]);let bo=(0,Q.useMemo)(()=>{if(!qt)return null;let e=K.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||K.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=Fu(K,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`;return r===1?`running ${o} hook`:`running stop hooks… ${i}/${r}`},[K,qt]),xo=(0,Q.useCallback)(()=>{Er({messagesLength:K.length,streamingToolUsesLength:Dt.length})},[K.length,Dt.length]),So=(0,Q.useCallback)(()=>{Er(null)},[]),Co=xr()&&!A,To=(0,Q.useRef)(null),[Do,Oo]=(0,Q.useState)(!1),[ko,Mo]=(0,Q.useState)(``),[No,Po]=(0,Q.useState)(0),[Fo,Io]=(0,Q.useState)(0),Ro=(0,Q.useCallback)((e,t)=>{Po(e),Io(t)},[]);re((e,t,n)=>{if(t.ctrl||t.meta)return;if(e===`/`){To.current?.setAnchor(),Oo(!0),n.stopImmediatePropagation();return}let r=e[0];if((r===`n`||r===`N`)&&e===r.repeat(e.length)&&No>0){let t=r===`n`?To.current?.nextMatch:To.current?.prevMatch;if(t)for(let n=0;n<e.length;n++)t();n.stopImmediatePropagation()}},{isActive:Ce===`transcript`&&Co&&!Do&&!De});let{setQuery:zo,scanElement:Bo,setPositions:Vo}=oe(),Uo=V().columns,Wo=Q.useRef(Uo);Q.useEffect(()=>{Wo.current!==Uo&&(Wo.current=Uo,(ko||Do)&&(Oo(!1),Mo(``),Po(0),Io(0),To.current?.disarmSearch(),zo(``)))},[Uo,ko,Do,zo]),re((e,t,n)=>{if(!(t.ctrl||t.meta)){if(e===`q`){So(),n.stopImmediatePropagation();return}if(e===`[`&&!De)Oe(!0),Ee(!0),n.stopImmediatePropagation();else if(e===`v`){if(n.stopImmediatePropagation(),Ie.current)return;Ie.current=!0;let e=Ne.current,t=t=>{e===Ne.current&&(clearTimeout(Pe.current),Ae(t))};t(`rendering ${Cr.length} messages…`),(async()=>{try{let e=Math.max(80,(process.stdout.columns??80)-6),n=(await C_(Cr,yt,e)).replace(/[ \t]+$/gm,``),r=Ph(kh(),`cc-transcript-${Date.now()}.txt`);await Vh(r,n);let i=um(r);t(i?`opening ${r}`:`wrote ${r} · no $VISUAL/$EDITOR set`)}catch(e){t(`render failed: ${e instanceof Error?e.message:String(e)}`)}Ie.current=!1,e===Ne.current&&(Pe.current=setTimeout(e=>e(``),4e3,Ae))})()}}},{isActive:Ce===`transcript`&&Co&&!Do});let Go=Ce===`transcript`&&Co;(0,Q.useEffect)(()=>{Go||(Mo(``),Po(0),Io(0),Oo(!1),Ne.current++,clearTimeout(Pe.current),Oe(!1),Ae(``))},[Go]),(0,Q.useEffect)(()=>{zo(Go?ko:``),Go||Vo(null)},[Go,ko,zo,Vo]);let Ko={screen:Ce,setScreen:we,showAllInTranscript:Te,setShowAllInTranscript:Ee,messageCount:K.length,onEnterTranscript:xo,onExitTranscript:So,virtualScrollActive:Co,searchBarOpen:Do},qo=Tr?Cr.slice(0,Tr.messagesLength):Cr,Jo=Tr?Dt.slice(0,Tr.streamingToolUsesLength):Dt;NT({onOpenBackgroundTasks:Jn?void 0:()=>Ui(!0)});let Yo=le?se[le]:void 0,Xo=Yo&&Qs(Yo)?Yo:void 0,Zo=ii||!qt,Qo=Xo?.messages,es=(0,Q.useMemo)(()=>{if(!Xo)return;let e=Qo??[];if(!Qs(Xo)||Xo.agentType!==`fork`||!Xo.prompt)return e;let t=Xo.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(mO))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=>!mO(e))}});if(i)return a;let o=n===-1?r+1:n+1,s=Al({content:Xo.prompt,timestamp:new Date(Xo.startTime).toISOString()});return[...a.slice(0,o),s,...a.slice(o)]},[Xo,Qo]),ts=Xo?es??[]:Zo?K:Cr;if(Ce===`transcript`){let e=xr()&&!A&&!De?Rt:void 0,t=(0,$.jsx)(ph,{messages:qo,tools:yt,commands:St,verbose:!0,toolJSX:null,toolUseConfirmQueue:[],inProgressToolUseIDs:Hr,isMessageSelectorVisible:!1,conversationId:ki,screen:Ce,agentDefinitions:ne,streamingToolUses:Jo,showAllInTranscript:Te,isLoading:qt,hidePastThinking:!0,streamingThinking:kt,scrollRef:e,jumpRef:To,onSearchMatchesChange:Ro,scanElement:Bo,setPositions:Vo,disableRenderCap:De}),n=Cn&&(0,$.jsx)(_,{flexDirection:`column`,width:`100%`,children:Cn.jsx}),r=(0,$.jsxs)(up,{children:[(0,$.jsx)(fO,{isAnimating:Zn,title:Kn,disabled:k,noPrefix:!1}),(0,$.jsx)(OT,{...Ko}),(0,$.jsx)(AT,{onSubmit:Xa,isActive:!Cn?.isLocalJSXCommand}),e?(0,$.jsx)(QD,{scrollRef:Rt,isActive:!0,isModal:!Do,onScroll:()=>To.current?.disarmSearch()}):null,(0,$.jsx)(MT,{...za}),e?(0,$.jsx)(dh,{scrollRef:Rt,scrollable:(0,$.jsxs)($.Fragment,{children:[t,n,(0,$.jsx)(OE,{})]}),bottom:Do?(0,$.jsx)(cO,{jumpRef:To,initialQuery:``,count:No,current:Fo,onClose:e=>{Mo(No>0?e:``),Oo(!1),e||(Po(0),Io(0),To.current?.setSearchQuery(``))},onCancel:()=>{Oo(!1),To.current?.setSearchQuery(``),To.current?.setSearchQuery(ko),zo(ko)},setHighlight:zo}):(0,$.jsx)(sO,{showAllInTranscript:Te,virtualScroll:!0,status:ke||void 0,searchBadge:ko&&No>0?{current:Fo,count:No}:void 0})}):(0,$.jsxs)($.Fragment,{children:[t,n,(0,$.jsx)(OE,{}),(0,$.jsx)(sO,{showAllInTranscript:Te,virtualScroll:!1,suppressShowAll:De,status:ke||void 0})]})]});return e?(0,$.jsx)(de,{mouseTracking:Fr(),children:r}):r}let ns=Yt&&!Xo&&ts.length<=Zt.current?Yt:void 0,rs=Aa===`tool-permission`?(0,$.jsx)(Tb,{onDone:()=>jn(([e,...t])=>t),onReject:Ra,toolUseConfirm:kn[0],toolUseContext:Ua(K,K,jt??go(),me),verbose:F,setStickyFooter:xr()?Nn:void 0},kn[0]?.toolUseID):null,is=xr()&&Cn?.isLocalJSXCommand===!0,as=is?Cn.jsx:null,cs=(0,$.jsxs)(up,{children:[(0,$.jsx)(fO,{isAnimating:Zn,title:Kn,disabled:k,noPrefix:!1}),(0,$.jsx)(OT,{...Ko}),(0,$.jsx)(AT,{onSubmit:Xa,isActive:!Cn?.isLocalJSXCommand}),(0,$.jsx)(QD,{scrollRef:Rt,isActive:xr()&&(as!=null||!Aa||Aa===`tool-permission`),onScroll:br}),null,(0,$.jsx)(MT,{...za}),(0,$.jsx)(pp,{dynamicMcpConfig:be,isStrictMcpConfig:m,children:(0,$.jsx)(dh,{scrollRef:Rt,overlay:rs,modal:as,modalScrollRef:zt,dividerYRef:sr,hidePill:!!Xo,newMessageCount:gr?.count??0,onPillClick:()=>{mr(null),dr(Rt.current)},scrollable:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ph,{messages:ts,tools:yt,commands:St,verbose:F,toolJSX:Cn,toolUseConfirmQueue:kn,inProgressToolUseIDs:Hr,isMessageSelectorVisible:yi,conversationId:ki,screen:Ce,streamingToolUses:Dt,showAllInTranscript:Te,agentDefinitions:ne,isLoading:qt,streamingText:qt&&!Xo?si:null,unseenDivider:Xo?void 0:gr,scrollRef:xr()?Rt:void 0,trackStickyPrompt:xr()?!0:void 0,cursor:pr,setCursor:mr,cursorNavRef:hr}),!C&&ns&&!as&&(0,$.jsx)(Zi,{param:{text:ns,type:`text`},addMargin:!0,verbose:F}),Cn&&!(Cn.isLocalJSXCommand&&Cn.isImmediate)&&!is&&(0,$.jsx)(_,{flexDirection:`column`,width:`100%`,children:Cn.jsx}),(0,$.jsx)(_,{flexGrow:1}),ua&&(0,$.jsx)(Mp,{mode:Ct,spinnerTip:B,responseLengthRef:Yr,apiMetricsRef:Xr,overrideMessage:fi,spinnerSuffix:bo,verbose:F,loadingStartTimeRef:rn,totalPausedMsRef:an,pauseStartTimeRef:on,overrideColor:hi,overrideShimmerColor:_i,hasActiveTools:Hr.size>0,leaderIsIdle:!qt})]}),bottom:(0,$.jsx)(_,{flexDirection:`row`,width:`100%`,alignItems:`flex-end`,children:(0,$.jsxs)(_,{flexDirection:`column`,flexGrow:1,children:[xr()&&(0,$.jsx)(nT,{}),Mn,Cn?.isLocalJSXCommand&&Cn.isImmediate&&!is&&(0,$.jsx)(_,{flexDirection:`column`,width:`100%`,children:Cn.jsx}),!ua&&!Cn?.isLocalJSXCommand&&ae&&_t&&_t.length>0&&(0,$.jsx)(_,{width:`100%`,flexDirection:`column`,children:(0,$.jsx)(jp,{tasks:_t,isStandalone:!0})}),Aa===`sandbox-permission`&&(0,$.jsx)(EE,{hostPattern:Pn[0].hostPattern,onUserResponse:e=>{let{allow:t,persistToSettings:n}=e,r=Pn[0];if(!r)return;let i=r.hostPattern.host;Fn(e=>(e.filter(e=>e.hostPattern.host===i).forEach(e=>e.resolvePromise(t)),e.filter(e=>e.hostPattern.host!==i)))}},Pn[0].hostPattern.host),Aa===`prompt`&&(0,$.jsx)(Yb,{title:In[0].title,toolInputSummary:In[0].toolInputSummary,request:In[0].request,onRespond:e=>{let t=In[0];t&&(t.resolve({prompt_response:t.request.prompt,selected:e}),zn(([,...e])=>e))},onAbort:()=>{let e=In[0];e&&(e.reject(Error(`Prompt cancelled by user`)),zn(([,...e])=>e))}},In[0].request.prompt),Aa===`elicitation`&&(0,$.jsx)(Kb,{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)}`),Aa===`cost`&&(0,$.jsx)(w_,{onDone:()=>{Oi(!1),zi(!0),nd(e=>({...e,hasAcknowledgedCostThreshold:!0}))}}),Aa===`idle-return`&&Mi&&(0,$.jsx)(T_,{idleMinutes:Mi.idleMinutes,totalInputTokens:nt(),onDone:async e=>{let t=Mi;if(Ni(null),Math.round(t.idleMinutes),nr.current.length,nt(),e===`dismiss`){Ir(t.input);return}if(e===`never`&&nd(e=>e.idleReturnDismissed?e:{...e,idleReturnDismissed:!0}),e===`clear`){let{clearConversation:e}=await import(`./conversation-BIPJEOwO.js`);await e({setMessages:q,readFileState:ma.current,discoveredSkillNames:_a.current,loadedNestedMemoryPaths:va.current,getAppState:()=>fe.getState(),setAppState:U,setConversationId:ji}),Un.current=!1,Hn(void 0),ha.current.clear(),ga.current=0}Pi.current=!0,Za.current(t.input,{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}})}}),Aa===`ide-onboarding`&&(0,$.jsx)(Sn,{onDone:()=>at(!1),installationStatus:$e}),Ca,Aa===`plugin-hint`&&dt&&(0,$.jsx)(eD,{pluginName:dt.pluginName,pluginDescription:dt.pluginDescription,marketplaceName:dt.marketplaceName,sourceCommand:dt.sourceCommand,onResponse:ft}),Aa===`search-extra-tools-hint`&&pt.visible&&(0,$.jsx)(nD,{tools:pt.tools,onSelect:pt.handleSelect,onDismiss:pt.handleDismiss}),Aa===`lsp-recommendation`&&st&&(0,$.jsx)(ZE,{pluginName:st.pluginName,pluginDescription:st.pluginDescription,fileExtension:st.fileExtension,onResponse:lt}),la(),!Cn?.shouldHidePromptInput&&!Aa&&!Ea&&!C&&!pr&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(bT,{debug:n,ideSelection:Je,hasSuppressedDialogs:!!ja,isLocalJSXCommandActive:Jn,getToolUseContext:Ua,toolPermissionContext:P,setToolPermissionContext:Va,apiKeyStatus:ba,commands:St,agents:ne.activeAgents,isLoading:qt,onExit:Qa,verbose:F,messages:K,onAutoUpdaterResult:xn,autoUpdaterResult:bn,input:Dr,onInputChange:Ir,mode:Lr,onModeChange:Rr,stashedPrompt:Br,setStashedPrompt:Vr,submitCount:qr,onShowMessageSelector:$a,onMessageActionsEnter:void 0,mcpClients:Ke,pastedContents:Gr,setPastedContents:Kr,vimMode:Bi,setVimMode:Vi,showBashesDialog:Hi,setShowBashesDialog:Ui,onSubmit:Xa,isSearchingHistory:Wi,setIsSearchingHistory:Gi,helpOpen:Ki,setHelpOpen:qi,insertTextRef:Pr}),(0,$.jsx)(lE,{onBackgroundSession:Wa,isLoading:qt}),(0,$.jsx)(eE,{})]}),pr&&(0,$.jsx)(Ho,{cursor:pr}),Aa===`message-selector`&&(0,$.jsx)(xp,{messages:K,preselectedMessage:wi,onPreRestore:Fa,onRestoreCode:async e=>{await ls(e=>{U(t=>({...t,fileHistory:e(t.fileHistory)}))},e.uuid)},onSummarize:async(e,t,n=`from`)=>{let r=sc(K),i=r.indexOf(e);if(i===-1){q(e=>[...e,ml(`That message is no longer in the active context (snipped or pre-compact). Choose a more recent message.`,`warning`)]);return}let a=go(),o=Ua(r,[],a,me),s=o.getAppState(),c=await gc(o.options.tools,o.options.mainLoopModel,Array.from(s.toolPermissionContext.additionalWorkingDirectories.keys()),o.options.mcpClients),l=_s({mainThreadAgentDefinition:void 0,toolUseContext:o,customSystemPrompt:o.options.customSystemPrompt,defaultSystemPrompt:c,appendSystemPrompt:o.options.appendSystemPrompt}),[u,d]=await Promise.all([_n(),ei()]),f=await li(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(xr()&&n===`from`?q(t=>{let n=t.findIndex(t=>t.uuid===e.uuid);return[...t.slice(0,n===-1?0:n),...h]}):q(h),Qt(!1),ji(Bh()),wl(o.options.querySource),n===`from`){let t=al(e);t&&(Ir(t.text),Rr(t.mode))}let g=en(`app:toggleTranscript`,`Global`,`ctrl+o`);He({key:`summarize-ctrl-o-hint`,text:`Conversation summarized (${g} for history)`,priority:`medium`,timeoutMs:8e3})},onRestoreMessage:no,onClose:()=>{Ci(!1),Ti(void 0)}})]})})})},ho)]});return xr()?(0,$.jsx)(de,{mouseTracking:Fr(),children:cs}):cs}export{hO as t};
|