@readmagic/workmate 0.0.22 → 0.0.23
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-DWgTWJ7R.js → AddWorkspaceDirectory-OgcBcK5A.js} +1 -1
- package/dist/chunks/AgentsMdExternalIncludesDialog-CDNd5-7E.js +1 -0
- package/dist/chunks/{AgentsMdExternalIncludesDialog-s0Orgord.js → AgentsMdExternalIncludesDialog-CNEifEyV.js} +1 -1
- package/dist/chunks/App-B-3tPQ3k.js +1 -0
- package/dist/chunks/BackgroundTasksDialog-COuhHcey.js +2 -0
- package/dist/chunks/{BypassPermissionsModeDialog-D2Gesf-u.js → BypassPermissionsModeDialog-bJek4siJ.js} +1 -1
- package/dist/chunks/CustomSelect-DoeEXOIP.js +1 -0
- package/dist/chunks/{DiffDialog-v2IiYyi3.js → DiffDialog-B3X9FMpO.js} +5 -5
- package/dist/chunks/Doctor-6PXyjIi6.js +3 -0
- package/dist/chunks/Doctor-DNgkgYhB.js +1 -0
- package/dist/chunks/{ExitFlow-BasHk1mk.js → ExitFlow-DgAZp_8U.js} +2 -2
- package/dist/chunks/Grove-CHatOzcE.js +11 -0
- package/dist/chunks/{InvalidConfigDialog-DYVQK5js.js → InvalidConfigDialog-DXL92MN9.js} +1 -1
- package/dist/chunks/{InvalidSettingsDialog-Dg6OiStR.js → InvalidSettingsDialog-Dtmpzeps.js} +1 -1
- package/dist/chunks/{KeybindingProviderSetup-Bn1jzN5F.js → KeybindingProviderSetup-DA37QUFs.js} +1 -1
- package/dist/chunks/MCPConnectionManager-thZd-xA_.js +1 -0
- package/dist/chunks/MCPToolListView-CpY-YJg4.js +1 -0
- package/dist/chunks/{McpParsingWarnings-DZejAh8b.js → McpParsingWarnings-JvChf3xr.js} +1 -1
- package/dist/chunks/MessageSelector-C0_iw7SI.js +3 -0
- package/dist/chunks/Messages-K4DDsDP9.js +10 -0
- package/dist/chunks/Onboarding-C1UdzM-1.js +1 -0
- package/dist/chunks/{PromptInputFooterSuggestions-lkr_A5jQ.js → PromptInputFooterSuggestions-AyLog8p7.js} +1 -1
- package/dist/chunks/{PromptInputHelpMenu-DaQKKyM5.js → PromptInputHelpMenu-oyic20ip.js} +1 -1
- package/dist/chunks/ProviderSetup-XcBHjUnd.js +1 -0
- package/dist/chunks/QueryEngine-DYxBjJ4i.js +1 -0
- package/dist/chunks/REPL-CQBJRrT0.js +124 -0
- package/dist/chunks/REPL-CrVuMQY2.js +1 -0
- package/dist/chunks/ResumeConversation-Dl8H9Gfy.js +1 -0
- package/dist/chunks/SearchExtraToolsTool-lv7VE50N.js +1 -0
- package/dist/chunks/{SelectMulti-CNE06VAN.js → SelectMulti-Bc6l11_K.js} +1 -1
- package/dist/chunks/Settings-TGp3fPrS.js +3 -0
- package/dist/chunks/Spinner-zYPFVFHN.js +1 -0
- package/dist/chunks/{SpinnerGlyph-A6G-gloN.js → SpinnerGlyph-CmkRUvHe.js} +1 -1
- package/dist/chunks/{TextInput-7uqPhq9T.js → TextInput-CD9iau2k.js} +5 -5
- package/dist/chunks/{ThemePicker-DT9zVy-0.js → ThemePicker-0F0hZYPX.js} +1 -1
- package/dist/chunks/TrustDialog-C76YiMKz.js +1 -0
- package/dist/chunks/{ValidationErrorsList-BLtP647v.js → ValidationErrorsList-DgNzJQUP.js} +1 -1
- package/dist/chunks/_baseEach-4ff-vRlp.js +1 -0
- package/dist/chunks/add-dir-JMsRLGfx.js +1 -0
- package/dist/chunks/{agentDisplay-vLQHFrmq.js → agentDisplay-BReJUBWg.js} +1 -1
- package/dist/chunks/agents-9qQ8I6zW.js +101 -0
- package/dist/chunks/{agents-DLz0kfsr.js → agents-B3x8yJ_r.js} +1 -1
- package/dist/chunks/allErrors-DfWylHSw.js +1 -0
- package/dist/chunks/{appleTerminalBackup-BYKdf3of.js → appleTerminalBackup-BArZWB21.js} +1 -1
- package/dist/chunks/backgroundHousekeeping-BGxHB_OX.js +1 -0
- package/dist/chunks/backgroundHousekeeping-CVNIhQg8.js +17 -0
- package/dist/chunks/banner-Cu2-XUek.js +2 -0
- package/dist/chunks/{bedrockClient-DxE_mHFI.js → bedrockClient-CfiDN-kF.js} +2 -2
- package/dist/chunks/branch-C4TsMEkx.js +2 -0
- package/dist/chunks/{break-cache-BL2gnDLX.js → break-cache-BMXqFTeS.js} +2 -2
- package/dist/chunks/btw-Dn1eYFAz.js +1 -0
- package/dist/chunks/caches-BGzKwpnc.js +1 -0
- package/dist/chunks/caches-DArHxBgL.js +1 -0
- package/dist/chunks/{claudeDesktop-D3PEgx3U.js → claudeDesktop-D8ml2767.js} +1 -1
- package/dist/chunks/{clear-CXfhVRp8.js → clear-Bdhb6b39.js} +1 -1
- package/dist/chunks/{client-DdenNfkQ.js → client-4iqhC8xq.js} +1 -1
- package/dist/chunks/client-BiqbIkwr.js +1 -0
- package/dist/chunks/client-CZ8nyVh5.js +1 -0
- package/dist/chunks/{client-DvhWKIOx.js → client-CpTCeWba.js} +1 -1
- package/dist/chunks/commands-QepeBbFn.js +1 -0
- package/dist/chunks/compact-Bu9BUpxV.js +2 -0
- package/dist/chunks/config-C-Y2qtB2.js +3 -0
- package/dist/chunks/config-D58C3_Lu.js +1 -0
- package/dist/chunks/config-DD8fCYXn.js +1 -0
- package/dist/chunks/{context-3s9wtn4L.js → context-CY_yfdYa.js} +1 -1
- package/dist/chunks/context-noninteractive-BDDi3NLF.js +1 -0
- package/dist/chunks/{context-noninteractive-CJhUu_4y.js → context-noninteractive-Dd4xIoP1.js} +5 -5
- package/dist/chunks/conversation-B0wxBwzv.js +1 -0
- package/dist/chunks/conversation-DUu9qBnq.js +1 -0
- package/dist/chunks/conversationRecovery-2ft8sCPE.js +1 -0
- package/dist/chunks/crossProjectResume-6boHMUBx.js +40 -0
- package/dist/chunks/cwd-Dc3NV7s8.js +1 -0
- package/dist/chunks/cwd-Pa83R95t.js +1 -0
- package/dist/chunks/{datadog-v_mXWncN.js → datadog-BPuGcxxC.js} +1 -1
- package/dist/chunks/{debug-8DCufdSp.js → debug-Bglx1aTu.js} +5 -5
- package/dist/chunks/{detectRepository-DfX8xXw2.js → detectRepository-CfX8Lc0A.js} +1 -1
- package/dist/chunks/{diff-DJSt7QO6.js → diff-BOAElpfQ.js} +1 -1
- package/dist/chunks/{directoryCompletion-CT6YVeg7.js → directoryCompletion-D_Rtg-4j.js} +1 -1
- package/dist/chunks/dist-es-B3-7VFf2.js +1 -0
- package/dist/chunks/dist-es-B7j_mv242.js +1 -0
- package/dist/chunks/dist-es-BSKD_hOQ.js +1 -0
- package/dist/chunks/dist-es-BSRN-2nA.js +9 -0
- package/dist/chunks/{dist-es-yHGBqhBe.js → dist-es-BXXmyhQ2.js} +1 -1
- package/dist/chunks/{dist-es-C3reqy7X.js → dist-es-BaQndfvh2.js} +1 -1
- package/dist/chunks/dist-es-CzTYn7xo.js +1 -0
- package/dist/chunks/dist-es-DSkyibcN.js +1 -0
- package/dist/chunks/{dist-es-BOPBJQo3.js → dist-es-_UNJQniz.js} +1 -1
- package/dist/chunks/dist-es-hwK6468D.js +1 -0
- package/dist/chunks/dist-es-ovsdbtwh.js +1 -0
- package/dist/chunks/doctor-CkLzqAMd.js +1 -0
- package/dist/chunks/{entry-ex0-RyYV.js → entry-TNOoyy7_.js} +4 -4
- package/dist/chunks/{envUtils-DcaKZlRU.js → envUtils-DfkgIdYf.js} +1 -1
- package/dist/chunks/esm-eTAUP-La.js +1 -0
- package/dist/chunks/{execFileNoThrow-BsfuytkN.js → execFileNoThrow-BTachNBI.js} +1 -1
- package/dist/chunks/exit-DXApFJIP.js +1 -0
- package/dist/chunks/extraUsage-CmQaLPV1.js +1 -0
- package/dist/chunks/extractMemories-xP63mv6R.js +1 -0
- package/dist/chunks/fast-C5nQH8rm.js +1 -0
- package/dist/chunks/fast-eGx2IxD7.js +1 -0
- package/dist/chunks/fetchModelList-CxLsVNsu.js +1 -0
- package/dist/chunks/fetchModelList-D24lRIgR.js +1 -0
- package/dist/chunks/{fileSuggestions-B-SLfb-o.js → fileSuggestions-DHxdwq28.js} +2 -2
- package/dist/chunks/firstPartyEventLogger-BVAogAX8.js +1 -0
- package/dist/chunks/firstPartyEventLogger-M6UMli2c.js +3 -0
- package/dist/chunks/{gemini-BC9kHhwe.js → gemini-D_ORb_L6.js} +2 -2
- package/dist/chunks/generateSessionName-BQoDduyA.js +1 -0
- package/dist/chunks/{genericProcessUtils-BYi0OefF.js → genericProcessUtils-DwQFuna9.js} +1 -1
- package/dist/chunks/goal-D7c2mSds.js +3 -0
- package/dist/chunks/grok-B2-ZbUiR.js +1 -0
- package/dist/chunks/grove-O6qp7ITR.js +1 -0
- package/dist/chunks/{help-CK90i4hE.js → help-CZJdRviD.js} +1 -1
- package/dist/chunks/history-CQiUERTL.js +1 -0
- package/dist/chunks/hooks-BNuUlMzL.js +1 -0
- package/dist/chunks/{hooks-BRFDg9DV.js → hooks-DIvN6gdv.js} +3 -3
- package/dist/chunks/{install-ZMll-dAa.js → install-T_CV1Slu.js} +1 -1
- package/dist/chunks/instrumentation-BjqUZ383.js +21 -0
- package/dist/chunks/{job-G_ukhLc4.js → job-R6c4-3c8.js} +1 -1
- package/dist/chunks/keybindings-CLRaiL_Z.js +1 -0
- package/dist/chunks/{launchLocalMemory-BcRlXLm6.js → launchLocalMemory-DrbKrwXc.js} +2 -2
- package/dist/chunks/launchOnboarding-tqsMD8ni.js +8 -0
- package/dist/chunks/loadAgentsDir-CcmY8zCj.js +1 -0
- package/dist/chunks/{loadAgentsDir-C1LkW7gl.js → loadAgentsDir-DlPbtIsS.js} +540 -543
- package/dist/chunks/loadPluginHooks-C_msxVIc.js +1 -0
- package/dist/chunks/{loader-C61fB6vU.js → loader-CICGtLp2.js} +1 -1
- package/dist/chunks/{localSearch-DFo_WTMm.js → localSearch-CK-sFzPm.js} +1 -1
- package/dist/chunks/localSearch-DrUj0B-d.js +1 -0
- package/dist/chunks/{log-DaILwWJa.js → log-D2TIwHBV.js} +1 -1
- package/dist/chunks/logoUtils-x2pHV-Nl.js +1 -0
- package/dist/chunks/{magicDocs-DYc9TFmI.js → magicDocs-BEF8D3if.js} +3 -3
- package/dist/chunks/main-kOVUGxOS.js +345 -0
- package/dist/chunks/managedEnv-BEqrGqn1.js +1 -0
- package/dist/chunks/managedEnv-OPlzUPbJ.js +1 -0
- package/dist/chunks/mcp-BNd29r6p.js +6 -0
- package/dist/chunks/mcp-D0wAJrRT.js +1 -0
- package/dist/chunks/mcp-mgOlm1cY.js +2 -0
- package/dist/chunks/memory-DDLk9_LJ.js +1 -0
- package/dist/chunks/{mode-Pan-Q2c4.js → mode-CcNsWgK3.js} +2 -2
- package/dist/chunks/model-BwBG0V1u.js +1 -0
- package/dist/chunks/model-DzCP4K-9.js +1 -0
- package/dist/chunks/modelOptions-DRaG3bo0.js +1 -0
- package/dist/chunks/nativeInstaller-C3pVPqrZ.js +1 -0
- package/dist/chunks/notifications-4wP1Tx9Y.js +1 -0
- package/dist/chunks/onChangeAppState-BlaoFbYF.js +1 -0
- package/dist/chunks/openai-CDN71NdX.js +2 -0
- package/dist/chunks/{overlayContext-CMV7nYR9.js → overlayContext-BT2Lq8ei.js} +1 -1
- package/dist/chunks/{panel-D9fGQgln.js → panel-CVS4SK_E.js} +1 -1
- package/dist/chunks/parser-CG5RuOCK.js +1 -0
- package/dist/chunks/{parser-D8slvrJP.js → parser-Cg6hSCmn.js} +1 -1
- package/dist/chunks/partition-CIl_ORUT.js +1 -0
- package/dist/chunks/{pasteStore-DNV1M5Xd.js → pasteStore-P0zP-ch0.js} +1 -1
- package/dist/chunks/permissions-zSNOZSwr.js +3 -0
- package/dist/chunks/pidLock-BTqO-h7Y.js +3 -0
- package/dist/chunks/{plan-CQLnPLuE.js → plan-Bs6em6lk.js} +1 -1
- package/dist/chunks/{platform-Dzff1WWw.js → platform-BacQ6ACS.js} +1 -1
- package/dist/chunks/plugin-DDDxjBa0.js +17 -0
- package/dist/chunks/{pluginAutoupdate-BJaAqwTH.js → pluginAutoupdate-8qugAFhb.js} +1 -1
- package/dist/chunks/pluginBlocklist-q01ackCf.js +1 -0
- package/dist/chunks/pluginCliCommands-DXZfCZsv.js +1 -0
- package/dist/chunks/{pluginFlagging-DQP8tBi2.js → pluginFlagging-BG2MHCQJ.js} +1 -1
- package/dist/chunks/pluginOperations-hXYLrzM2.js +2 -0
- package/dist/chunks/{pluginStartupCheck-CfRvCrFg.js → pluginStartupCheck-DTMa6TgL.js} +1 -1
- package/dist/chunks/pluginStartupCheck-HS1ZceZa.js +1 -0
- package/dist/chunks/plugins-COoGBYk6.js +4 -0
- package/dist/chunks/{poorMode-J5SYJvoY.js → poorMode-B0QGV6Ci.js} +1 -1
- package/dist/chunks/poorMode-G-pnu6NM.js +1 -0
- package/dist/chunks/print-BASybEtO.js +13 -0
- package/dist/chunks/processBashCommand-DDi_Pymt.js +1 -0
- package/dist/chunks/processSlashCommand-Cq9kaoSF.js +5 -0
- package/dist/chunks/{projectContext-Bw3o5BrN.js → projectContext-5fmRr6Sd.js} +1 -1
- package/dist/chunks/{projectContext-BN2ZWzOG.js → projectContext-DhtjLv3k.js} +1 -1
- package/dist/chunks/{projectOnboardingState-CJycxw5P.js → projectOnboardingState-B5YATuc6.js} +1 -1
- package/dist/chunks/prompt-CHobfCB1.js +1 -0
- package/dist/chunks/prompt-CMm6RHHc.js +1 -0
- package/dist/chunks/{prompt-BGqgPgCU.js → prompt-mM79EGnT.js} +1 -1
- package/dist/chunks/{promptEditor-CmQ9p4oe.js → promptEditor-DLGN_eLu.js} +1 -1
- package/dist/chunks/{protocolHandler-CJo9-PfZ.js → protocolHandler-DjQALaU2.js} +1 -1
- package/dist/chunks/{proxy-CB17QimU.js → proxy-CDBfZjO7.js} +2 -2
- package/dist/chunks/reconciler-CeXqh95g.js +1 -0
- package/dist/chunks/refresh-Ce2yk28a.js +1 -0
- package/dist/chunks/{registerProtocol-CLIpzVwF.js → registerProtocol-CAsDme_E.js} +1 -1
- package/dist/chunks/reject-Bld5E-bn.js +1 -0
- package/dist/chunks/{reload-plugins-DjugL8jH.js → reload-plugins-C42xSB5l.js} +1 -1
- package/dist/chunks/rename-CtBghpxZ.js +1 -0
- package/dist/chunks/{renderOptions-Zqfm2U1y.js → renderOptions-DV0dn0IW.js} +1 -1
- package/dist/chunks/resume-BWkaTDqd.js +2 -0
- package/dist/chunks/ripgrep-DLs8MraF.js +1 -0
- package/dist/chunks/{ripgrep-BuzOTf1S.js → ripgrep-Dl3y5r4m.js} +1 -1
- package/dist/chunks/{runtimeObserver-CK_iZ6OB.js → runtimeObserver-1wQO8HSZ.js} +1 -1
- package/dist/chunks/{runtimeObserver-CpP0L9T9.js → runtimeObserver-XQrOux41.js} +4 -4
- package/dist/chunks/sandbox-adapter-8GO6eJxw.js +1 -0
- package/dist/chunks/{sandbox-toggle-KOHYvbQT.js → sandbox-toggle-Dir9Polo.js} +1 -1
- package/dist/chunks/searchExtraTools-BhDq8DTJ.js +1 -0
- package/dist/chunks/{select-C_KXmqbI.js → select-Bxf5-5sI.js} +1 -1
- package/dist/chunks/sessionFileAccessHooks-CozocHQE.js +1 -0
- package/dist/chunks/sessionObserver-DGEQM4cO.js +1 -0
- package/dist/chunks/{sessionObserver-WOYv2n7C.js → sessionObserver-DS4G6mb9.js} +2 -2
- package/dist/chunks/sessionStorage-BcAscOGE.js +1 -0
- package/dist/chunks/sessionTracing-BoDDYLxW.js +11 -0
- package/dist/chunks/settings-B2jvL8Dp.js +24 -0
- package/dist/chunks/settings-CisDe8DB.js +1 -0
- package/dist/chunks/setup-BRypY6iT.js +3 -0
- package/dist/chunks/{shadowedRuleDetection-Df-kZ_pK.js → shadowedRuleDetection-BRxZjobz.js} +1 -1
- package/dist/chunks/{sideQuestion-CMB8hfgX.js → sideQuestion-DLJxyrlp.js} +3 -3
- package/dist/chunks/sinks-CGdKmq_8.js +1 -0
- package/dist/chunks/sinks-Cz2HfgMU.js +1 -0
- package/dist/chunks/skillChangeDetector-xviGstqm.js +1 -0
- package/dist/chunks/{skillGapStore-CfmlO6pb.js → skillGapStore-CKN_d3pO.js} +2 -2
- package/dist/chunks/{skillLifecycle-BQ2LMfMx.js → skillLifecycle-BMY2JGGG.js} +2 -2
- package/dist/chunks/{skillSearchPanel-BwYuwLFs.js → skillSearchPanel-D9trHULQ.js} +2 -2
- package/dist/chunks/{skills-BVHPQma0.js → skills-CX_AvwLG.js} +1 -1
- package/dist/chunks/startupProfiler-BH0FoI66.js +1 -0
- package/dist/chunks/{startupProfiler-DTs9w9EN.js → startupProfiler-CJdr3SxP.js} +2 -2
- package/dist/chunks/state-B4jiUise.js +1 -0
- package/dist/chunks/state-BhOKSFi5.js +1 -0
- package/dist/chunks/status-Daaak6Bo.js +1 -0
- package/dist/chunks/statusNoticeHelpers-vFVgIYuw.js +1 -0
- package/dist/chunks/{stringUtils-BQm3OfeJ.js → stringUtils-C718f5ey.js} +1 -1
- package/dist/chunks/sts-ei3CGBNu.js +1 -0
- package/dist/chunks/switcher-BpgmH4AI.js +1 -0
- package/dist/chunks/{switcher-Bq1Ct_Sn.js → switcher-CAajZeNL.js} +1 -1
- package/dist/chunks/{tasks-0c8Uy04D.js → tasks-BWNQr2d3.js} +1 -1
- package/dist/chunks/{templateJobs-BdFzE9XG.js → templateJobs-gUET39Ho.js} +1 -1
- package/dist/chunks/{terminalSetup-Cf_r6pwK.js → terminalSetup-B_10N_gE.js} +3 -3
- package/dist/chunks/{terminalSetup-D7J6bxcn.js → terminalSetup-qc2PlvOm.js} +1 -1
- package/dist/chunks/{theme-Bby4fssR.js → theme-B7fKI6E5.js} +1 -1
- package/dist/chunks/tipRegistry-DamZr34w.js +2 -0
- package/dist/chunks/{toolEventObserver-CzFZUIsM.js → toolEventObserver-BL06sDI4.js} +1 -1
- package/dist/chunks/toolPool-CX5wDBi1.js +1 -0
- package/dist/chunks/{types-zk5Ltv5q.js → types-Dx7P7JLQ.js} +2 -2
- package/dist/chunks/udsClient-cQz6nJ_T.js +1 -0
- package/dist/chunks/{use-select-navigation-DMaC_3iw.js → use-select-navigation-BiUJdWai.js} +1 -1
- package/dist/chunks/{useExitOnCtrlCDWithKeybindings-CjW3gUOt.js → useExitOnCtrlCDWithKeybindings-C9BYG8Bo.js} +1 -1
- package/dist/chunks/useMainLoopModel-DwjSVzzO.js +1 -0
- package/dist/chunks/useManagePlugins-BqfIVa6E.js +1 -0
- package/dist/chunks/{useMergedTools-DarmnCEw.js → useMergedTools-Bw8FchX8.js} +1 -1
- package/dist/chunks/{useSearchInput-C2JuUW3g.js → useSearchInput-B25K1RnK.js} +1 -1
- package/dist/chunks/useSettingsErrors-DYQ44kX4.js +1 -0
- package/dist/chunks/{util-Bq5l7FF5.js → util-CtlC2dsN.js} +1 -1
- package/dist/chunks/validatePlugin-D6tFo87L.js +1 -0
- package/dist/chunks/vim-CoRp9lY1.js +1 -0
- package/dist/chunks/worktree-B8apCnVe.js +1 -0
- package/dist/cli.js +1 -1
- package/package.json +1 -5
- package/dist/chunks/AgentsMdExternalIncludesDialog-DCvgQ6n3.js +0 -1
- package/dist/chunks/App-BcEI6U5j.js +0 -1
- package/dist/chunks/ApproveApiKey-DegdTXZl.js +0 -1
- package/dist/chunks/ApproveApiKey-_VXIMSwY.js +0 -1
- package/dist/chunks/BackgroundTasksDialog-CjBt1L0p.js +0 -2
- package/dist/chunks/CustomSelect-B46Eh0gU.js +0 -1
- package/dist/chunks/Doctor-BP0Rqraa.js +0 -1
- package/dist/chunks/Doctor-By_y3C2V.js +0 -3
- package/dist/chunks/Grove-C3mhgshv.js +0 -11
- package/dist/chunks/MCPConnectionManager-ChN4Ayjk.js +0 -1
- package/dist/chunks/MCPToolListView-DLSrQHDc.js +0 -1
- package/dist/chunks/MessageSelector-CdDlJE48.js +0 -3
- package/dist/chunks/Messages-DuL_r1Or.js +0 -10
- package/dist/chunks/Onboarding-CE2GNA-h.js +0 -1
- package/dist/chunks/QueryEngine-DNNy1UCD.js +0 -1
- package/dist/chunks/REPL-CEhW-C41.js +0 -1
- package/dist/chunks/REPL-CkSL4C_8.js +0 -124
- package/dist/chunks/ResumeConversation-BMCO_3X7.js +0 -1
- package/dist/chunks/SearchExtraToolsTool-DSy_jDhf.js +0 -1
- package/dist/chunks/Settings-mDykHLok.js +0 -2
- package/dist/chunks/Spinner-DwsJJUtn.js +0 -1
- package/dist/chunks/TrustDialog-G4jM9IfM.js +0 -1
- package/dist/chunks/add-dir-7RfQAC3h.js +0 -1
- package/dist/chunks/agents-BNg_skSm.js +0 -101
- package/dist/chunks/allErrors-DaztSMrw.js +0 -1
- package/dist/chunks/auth-BTB00dq5.js +0 -10
- package/dist/chunks/auth-Bbc0Ny8i.js +0 -1
- package/dist/chunks/backgroundHousekeeping-DYz83_8C.js +0 -1
- package/dist/chunks/backgroundHousekeeping-bEZtlJSf.js +0 -17
- package/dist/chunks/banner-mqZEluky.js +0 -2
- package/dist/chunks/branch-exFKkymg.js +0 -2
- package/dist/chunks/btw-3l78DYET.js +0 -1
- package/dist/chunks/caches-6Nx6tsk9.js +0 -1
- package/dist/chunks/caches-ouaWB9bY.js +0 -1
- package/dist/chunks/client-C01Bnxxv.js +0 -1
- package/dist/chunks/client-DYRgRQsr.js +0 -1
- package/dist/chunks/commands-BoxOw75F.js +0 -1
- package/dist/chunks/compact-BOYr105K.js +0 -2
- package/dist/chunks/config-BddEvZZl.js +0 -3
- package/dist/chunks/config-GEv9hUzz.js +0 -1
- package/dist/chunks/config-kw4xg7Nk.js +0 -1
- package/dist/chunks/context-noninteractive-DFvoZ2L9.js +0 -1
- package/dist/chunks/conversation-CoGharlH.js +0 -1
- package/dist/chunks/conversation-MxEVm54C.js +0 -1
- package/dist/chunks/conversationRecovery-Da_8uldZ.js +0 -1
- package/dist/chunks/crossProjectResume-CzPCHq_K.js +0 -40
- package/dist/chunks/cwd-BcO6WHKo.js +0 -1
- package/dist/chunks/cwd-CDUelriw.js +0 -1
- package/dist/chunks/dist-es-5t7v8oaj.js +0 -1
- package/dist/chunks/dist-es-BIjDeceU.js +0 -1
- package/dist/chunks/dist-es-C-OjW2Ao.js +0 -1
- package/dist/chunks/dist-es-CEk66gUu.js +0 -1
- package/dist/chunks/dist-es-CIULjvtA2.js +0 -1
- package/dist/chunks/dist-es-CMtO44xC.js +0 -1
- package/dist/chunks/dist-es-CYPVg66r.js +0 -9
- package/dist/chunks/dist-es-D1Y8zSMI.js +0 -1
- package/dist/chunks/dist-es-Gt_DpXlP.js +0 -1
- package/dist/chunks/dist-es-kj-F5A132.js +0 -1
- package/dist/chunks/doctor-DWvioSU9.js +0 -1
- package/dist/chunks/esm-BQY8jJNR.js +0 -1
- package/dist/chunks/exit-BxC_ZEtO.js +0 -1
- package/dist/chunks/extraUsage-DYm33Occ.js +0 -1
- package/dist/chunks/extractMemories-CzN3Ax2B.js +0 -1
- package/dist/chunks/fast-DqUpl_Lr.js +0 -1
- package/dist/chunks/fast-NUdUyAaM.js +0 -1
- package/dist/chunks/fetchModelList-CqsTAWEN.js +0 -1
- package/dist/chunks/fetchModelList-DBMHE6Ng.js +0 -1
- package/dist/chunks/firstPartyEventLogger-C0q45h_4.js +0 -3
- package/dist/chunks/firstPartyEventLogger-CP8hCBDj.js +0 -1
- package/dist/chunks/generateSessionName-ChvKBVxB.js +0 -1
- package/dist/chunks/goal-ByyimpVU.js +0 -3
- package/dist/chunks/grok-DenjixMl.js +0 -1
- package/dist/chunks/grove-Dq8QbQ9o.js +0 -7
- package/dist/chunks/history-CNQNd6hT.js +0 -1
- package/dist/chunks/hooks-BaYwmkxD.js +0 -1
- package/dist/chunks/instrumentation-BwVyvRfY.js +0 -21
- package/dist/chunks/keybindings-wNxBzDVQ.js +0 -1
- package/dist/chunks/launchOnboarding-CDjQ64RO.js +0 -8
- package/dist/chunks/loadAgentsDir-DKXap_Om.js +0 -1
- package/dist/chunks/loadPluginHooks-DtmHtEiS.js +0 -1
- package/dist/chunks/localSearch-BB9x5C2N.js +0 -1
- package/dist/chunks/logoUtils-Dj_2SWmO.js +0 -1
- package/dist/chunks/main-BRg8L_aw.js +0 -346
- package/dist/chunks/managedEnv-DsqAYOJ4.js +0 -1
- package/dist/chunks/managedEnv-lybrMred.js +0 -1
- package/dist/chunks/mcp-Bsw3cMiJ.js +0 -6
- package/dist/chunks/mcp-DDdud6Y7.js +0 -1
- package/dist/chunks/mcp-DbgTDUt7.js +0 -2
- package/dist/chunks/memory-CzwTzihf.js +0 -1
- package/dist/chunks/model-BYfmXKHf.js +0 -1
- package/dist/chunks/model-BwBE0Pt5.js +0 -1
- package/dist/chunks/modelOptions-DvNBapgG.js +0 -1
- package/dist/chunks/nativeInstaller-DnSNJWIi.js +0 -1
- package/dist/chunks/notifications-B0DTaYoy.js +0 -1
- package/dist/chunks/omit-Dl1Us_PY.js +0 -1
- package/dist/chunks/onChangeAppState-4KOJMN82.js +0 -1
- package/dist/chunks/openai-C_6C1_0N.js +0 -10
- package/dist/chunks/parser-BKAVMTyD.js +0 -1
- package/dist/chunks/partition-B504IgAa.js +0 -1
- package/dist/chunks/permissions-CLFMhdRk.js +0 -3
- package/dist/chunks/pidLock-D9do1Afy.js +0 -3
- package/dist/chunks/plugin-BYdF7uob.js +0 -17
- package/dist/chunks/pluginBlocklist-DKKmOnWM.js +0 -1
- package/dist/chunks/pluginCliCommands-z8TtJMKH.js +0 -1
- package/dist/chunks/pluginOperations-BcfJCDco.js +0 -2
- package/dist/chunks/pluginStartupCheck-Cq4PvULa.js +0 -1
- package/dist/chunks/plugins-CTM8jpOw.js +0 -4
- package/dist/chunks/policyLimits-a7ix6GnU.js +0 -1
- package/dist/chunks/poorMode-C11JEH3d.js +0 -1
- package/dist/chunks/print-u6MzL5Cr.js +0 -13
- package/dist/chunks/processBashCommand-DIwrI2QC.js +0 -1
- package/dist/chunks/processSlashCommand-B-Gujpxm.js +0 -5
- package/dist/chunks/prompt-BPJDGlx5.js +0 -1
- package/dist/chunks/prompt-DEdZzkEz.js +0 -1
- package/dist/chunks/reconciler-DSKLuOS7.js +0 -1
- package/dist/chunks/refresh-BbZFCNpn.js +0 -1
- package/dist/chunks/rename-DOtCOtEr.js +0 -1
- package/dist/chunks/resume-BB4T4WIV.js +0 -2
- package/dist/chunks/ripgrep-CZ2CqaHb.js +0 -1
- package/dist/chunks/sandbox-adapter-DhJJ6WOV.js +0 -1
- package/dist/chunks/searchExtraTools-CdJghGkj.js +0 -1
- package/dist/chunks/sessionFileAccessHooks-D7KbWFp7.js +0 -1
- package/dist/chunks/sessionObserver-DB-sLv-X.js +0 -1
- package/dist/chunks/sessionStorage-sgOAbDn7.js +0 -1
- package/dist/chunks/sessionTracing-yBre24PH.js +0 -11
- package/dist/chunks/settings-C-KNkvsM.js +0 -1
- package/dist/chunks/settings-DKN4xSpQ.js +0 -24
- package/dist/chunks/setup-CN_Pk7AR.js +0 -3
- package/dist/chunks/sinks-BS17vtN0.js +0 -1
- package/dist/chunks/sinks-D1EjkHb4.js +0 -1
- package/dist/chunks/skillChangeDetector-CBKuGuEi.js +0 -1
- package/dist/chunks/startupProfiler-B_U4QDtf.js +0 -1
- package/dist/chunks/state-BowF111d.js +0 -1
- package/dist/chunks/state-CGuyDES7.js +0 -1
- package/dist/chunks/status-BurdTfyz.js +0 -2
- package/dist/chunks/status-DMq1An5h.js +0 -1
- package/dist/chunks/statusNoticeHelpers-X75JNlx5.js +0 -1
- package/dist/chunks/sts-C2Gf2WYN.js +0 -1
- package/dist/chunks/switcher-DGD4ORVf.js +0 -1
- package/dist/chunks/tipRegistry-CyRXWWTz.js +0 -2
- package/dist/chunks/toolPool-CnrZcprA.js +0 -1
- package/dist/chunks/udsClient-ftP0yIpe.js +0 -1
- package/dist/chunks/useMainLoopModel-DWscpA9I.js +0 -1
- package/dist/chunks/useManagePlugins-CYXVcql2.js +0 -1
- package/dist/chunks/useSettingsErrors-DutJBiKZ.js +0 -1
- package/dist/chunks/validatePlugin-DIdEydz_.js +0 -1
- package/dist/chunks/vim-D8prM2IH.js +0 -1
- package/dist/chunks/worktree-Caqt2WRZ.js +0 -1
- /package/dist/chunks/{dist-es-Cgsa8pb82.js → dist-es-Cgsa8pb8.js} +0 -0
- /package/dist/chunks/{dist-es-Cwru7c2B2.js → dist-es-Cwru7c2B.js} +0 -0
- /package/dist/chunks/{dist-es-DXIR5NLi2.js → dist-es-DXIR5NLi.js} +0 -0
|
@@ -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{t as d}from"./semver-DQo45qGo.js";import{et as f,rt as p}from"./esm-eTAUP-La.js";import{n as m,t as h}from"./axios-DaWTGg7G.js";import{$C as g,$c as _,$f as v,$g as y,$l as b,$m as x,$o as S,$s as C,$y as w,A as T,A_ as E,Ab as D,Ac as O,Ag as k,Ap as A,Au as j,Aw as M,B as ee,B_ as te,Bb as N,Bg as P,Bh as ne,Bm as F,Bt as I,Bu as re,C as L,CS as ie,Cb as ae,Cf as oe,Cg as se,Cl as R,Cm as z,D_ as ce,Dc as le,Df as B,Dg as ue,Di as de,Dm as fe,Do as pe,Dp as me,Dw as he,Dx as ge,ES as _e,E_ as ve,Eb as ye,Ec as be,Ef as xe,Eg as Se,Ei as Ce,Ep as we,Ew as Te,Ex as Ee,F_ as De,Fa as Oe,Fc as ke,Ff as Ae,Fg as je,Fm as Me,Fn as Ne,Fs as Pe,G_ as Fe,Gd as Ie,Gf as Le,Gg as Re,Gn as ze,Gp as Be,Gr as Ve,Gu as He,H_ as Ue,Ha as We,Hb as Ge,Hu as Ke,I_ as qe,Ic as Je,If as Ye,Ig as Xe,Ii as Ze,Ip as V,Is as Qe,J as $e,JC as et,Ja as tt,Jg as nt,Jm as rt,Jn as it,Jo as at,K as ot,KC as st,Kd as ct,Kf as lt,Kg as ut,Ko as dt,Kp as ft,Ks as pt,Kt as mt,L_ as ht,Lb as gt,Lc as _t,Lh as vt,Li as yt,Lm as bt,Ln as xt,Lp as H,Ls as St,Lu as Ct,MS as wt,Mb as Tt,Mc as Et,Md as Dt,Mg as Ot,Mh as kt,Mi as At,Ml as jt,Mm as Mt,Mn as Nt,Mp as Pt,Mu as Ft,Mx as U,NS as It,N_ as Lt,Nb as Rt,Nc as zt,Nd as Bt,Ng as Vt,Nh as Ht,Ni as Ut,Np as Wt,Nr as Gt,Nu as Kt,Nx as qt,O as Jt,OC as Yt,O_ as Xt,Ob as Zt,Od as Qt,Of as $t,Oh as en,Oi as tn,Om as nn,Oo as rn,Op as an,Os as on,Ow as sn,P_ as cn,Pc as ln,Pf as un,Pg as dn,Pi as fn,Pm as pn,Pn as mn,Pp as hn,Qa as gn,Qc as _n,Qf as vn,Qg as yn,Qi as bn,Ql as xn,Qm as Sn,Qn as Cn,Qp as wn,Qr as Tn,Qs as En,Qx as Dn,Qy as On,R_ as kn,Rb as An,Rc as jn,Rg as W,Ri as Mn,Rm as Nn,Rp as Pn,Rr as Fn,Rs as In,Ru as G,SC as Ln,Sb as Rn,Sc as zn,Sg as Bn,Sl as Vn,Sm as Hn,Sr as Un,Ss as Wn,Su as Gn,TS as Kn,T_ as qn,Tb as Jn,Tc as Yn,Tf as Xn,Tg as Zn,Tp as Qn,Tw as $n,Tx as er,U as tr,U_ as nr,Uf as rr,Ug as ir,Uu as ar,V as or,V_ as sr,Va as cr,Vg as lr,Vh as ur,Vm as dr,Vn as fr,Vu as pr,W as mr,Wd as hr,Wf as gr,Wg as _r,Wp as vr,Wu as yr,X as br,XC as xr,Xf as Sr,Xg as Cr,Xh as wr,Xi as Tr,Xl as Er,Xp as Dr,Xr as Or,Xs as kr,Xx as Ar,YC as jr,Yg as Mr,Yi as Nr,Ym as Pr,Ys as Fr,Yt as Ir,Yx as Lr,Z as Rr,ZC as zr,Zc as Br,Zf as Vr,Zg as Hr,Zl as Ur,Zn as Wr,Zo as Gr,Zr as Kr,Zx as qr,__ as Jr,_a as Yr,_b as Xr,_c as Zr,_i as Qr,_l as $r,_m as ei,_p as ti,_r as ni,_s as ri,_u as ii,aC as ai,aS as oi,a_ as si,ab as ci,ad as li,af as ui,am as di,ao as fi,as as pi,at as mi,b as hi,bb as gi,bf as _i,bg as vi,bm as yi,bo as bi,bp as xi,br as Si,bs as Ci,bw as wi,c_ as Ti,cd as Ei,cl as Di,cm as Oi,co as ki,dS as Ai,d_ as ji,da as Mi,dd as Ni,df as Pi,dg as Fi,du as Ii,e_ as Li,eb as Ri,ec as zi,ed as Bi,em as Vi,ep as Hi,es as Ui,ew as Wi,ex as Gi,f_ as Ki,fd as qi,ff as Ji,fg as Yi,fm as Xi,fp as Zi,fs as Qi,fu as $i,gC as ea,gb as ta,gc as na,gi as ra,gl as ia,go as aa,gp as oa,gs as sa,gu as ca,hb as la,hg as ua,hi as da,hl as fa,hp as pa,hs as ma,hu as ha,i_ as ga,ib as _a,if as va,il as ya,im as ba,io as xa,is as Sa,it as Ca,ix as wa,j_ as Ta,ja as Ea,jb as Da,jc as Oa,jg as ka,jh as Aa,jl as ja,jm as Ma,jp as Na,js as Pa,jt as Fa,ju as Ia,jw as La,jx as Ra,k as za,kC as Ba,k_ as Va,ka as Ha,kb as Ua,kc as Wa,kd as Ga,kf as Ka,kg as qa,kh as Ja,km as Ya,kn as Xa,kp as Za,ks as Qa,ku as $a,l_ as eo,lb as to,lf as no,lg as ro,ll as io,lm as ao,lo as oo,lp as so,lu as co,lw as lo,mS as uo,mb as fo,md as po,mf as mo,ml as ho,mm as go,mn as _o,mo as vo,mp as yo,ms as bo,mu as xo,nS as So,nf as Co,nm as wo,nw as To,ny as Eo,oS as Do,o_ as Oo,od as ko,of as Ao,oi as jo,ol as Mo,om as No,on as Po,oo as Fo,ow as Io,pS as Lo,pb as Ro,pd as zo,pf as Bo,pm as Vo,pp as Ho,pr as Uo,ps as Wo,pu as Go,q as Ko,qC as qo,qd as Jo,qg as Yo,qo as Xo,qp as Zo,qr as Qo,qs as $o,rS as es,r_ as ts,rf as ns,rm as rs,ro as is,rw as as,rx as os,sb as ss,sg as cs,si as ls,sl as us,sm as ds,so as fs,tS as ps,t_ as ms,tb as hs,tc as gs,td as _s,ti as vs,tm as ys,tr as bs,tw as xs,ty as Ss,uS as Cs,u_ as ws,ua as Ts,ud as Es,uf as Ds,ul as Os,uo as ks,up as As,ur as js,vb as Ms,vc as Ns,vl as Ps,vm as Fs,vp as Is,vr as Ls,vs as Rs,vt as zs,vu as Bs,wS as Vs,wf as Hs,wg as Us,wi as Ws,wl as Gs,ww as Ks,xb as qs,xf as Js,xg as Ys,xl as Xs,xm as Zs,xp as Qs,xt as $s,xu as ec,yC as tc,y_ as nc,yb as rc,yc as ic,yf as ac,yg as oc,ym as sc,yo as cc,yp as lc,ys as uc,yu as dc,yw as fc,z_ as pc,za as mc,zb as hc,zg as gc,zh as _c,zm as vc,zp as yc,zt as bc}from"./loadAgentsDir-DlPbtIsS.js";import{C as xc,D as Sc,Ft as Cc,Gr as wc,Gt as Tc,H as Ec,I as K,Kr as Dc,Kt as Oc,Lt as kc,P as q,Pn as Ac,Rn as jc,T as Mc,Tt as Nc,Vn as Pc,Wt as Fc,Xn as Ic,Xt as Lc,Y as Rc,Yt as zc,Z as Bc,Zn as Vc,_n as Hc,ai as Uc,bn as Wc,ct as Gc,di as Kc,dr as qc,et as Jc,fi as Yc,hn as Xc,ir as Zc,j as Qc,lr as $c,lt as el,ot as tl,p as nl,q as rl,qr as il,t as J,tr as al,vn as ol,x as sl,y as cl,yn as ll,yt as ul}from"./src-DL3w8VPk.js";import{t as dl}from"./jsx-runtime-Bb4Xn-E0.js";import{A as fl,E as pl,G as ml,U as hl,V as gl,W as _l,Z as vl,_ as yl,f as bl,g as xl,l as Sl,o as Cl,s as wl,w as Tl,x as El}from"./types-Dx7P7JLQ.js";import{B as Dl,Ct as Ol,Dt as kl,En as Al,G as jl,Gn as Ml,Gt as Nl,It as Pl,J as Fl,Jn as Il,Jt as Ll,Kt as Rl,L as zl,Lt as Bl,Nt as Vl,Q as Hl,St as Ul,T as Wl,Tn as Gl,Un as Kl,Wn as ql,at as Jl,bt as Yl,en as Xl,jt as Zl,mt as Ql,on as $l,qn as eu,qt as tu,st as nu,vt as ru,xt as iu,y as au,yn as ou,yt as su}from"./state-B4jiUise.js";import{n as cu,t as lu}from"./cwd-Pa83R95t.js";import{$ as uu,C as du,E as fu,H as pu,I as mu,M as hu,R as gu,S as _u,V as vu,Y as yu,c as Y,et as bu,f as xu,g as Su,i as Cu,u as wu,x as Tu}from"./debug-Bglx1aTu.js";import{Ar as Eu,At as Du,Gt as Ou,Hn as ku,Ht as Au,It as ju,Ln as Mu,Lr as Nu,Lt as Pu,Mr as Fu,Mt as Iu,R as Lu,Rn as Ru,Rt as zu,Un as Bu,V as Vu,Vn as Hu,Vt as Uu,Wt as Wu,Xr as Gu,Yr as Ku,_t as qu,b as Ju,d as Yu,er as Xu,h as Zu,jt as Qu,kn as $u,kr as ed,ln as td,nr as nd,on as rd,qt as id,s as ad,st as od,t as sd,tr as cd,wn as ld,xn as ud,zn as dd}from"./settings-B2jvL8Dp.js";import{O as fd,_ as pd,n as md,p as hd,s as gd}from"./config-C-Y2qtB2.js";import{i as _d,t as vd}from"./execFileNoThrow-BTachNBI.js";import{B as yd,F as bd,H as xd,L as Sd,R as Cd,j as wd,o as Td,q as Ed,s as Dd}from"./log-D2TIwHBV.js";import{_ as Od,a as kd,d as Ad,h as jd,l as Md,m as Nd,o as Pd,r as Fd,s as Id,v as Ld}from"./stringUtils-C718f5ey.js";import{i as Rd,o as zd}from"./platform-BacQ6ACS.js";import{n as Bd,r as X}from"./analytics-DJobLaWP.js";import{n as Vd,o as Hd,s as Ud,t as Wd}from"./intl-D2kgJmX7.js";import{S as Gd,_ as Kd,d as qd,g as Jd,l as Yd,u as Xd}from"./startupProfiler-CJdr3SxP.js";import{At as Zd,Dt as Qd,G as $d,H as ef,J as tf,Jt as nf,K as rf,R as af,U as of,W as sf,X as cf,Y as lf,bt as uf,c as df,d as ff,h as pf,ht as mf,kt as hf,l as gf,m as _f,mt as vf,o as yf,q as bf,qt as xf,x as Sf,y as Cf}from"./model-BwBG0V1u.js";import{Rt as wf,St as Tf,fn as Ef,in as Df,ln as Of,pn as kf,rn as Af,tn as jf,tt as Mf,un as Nf,xt as Pf,zt as Ff}from"./prompt-mM79EGnT.js";import{i as If,r as Lf}from"./projectOnboardingState-B5YATuc6.js";import{a as Rf}from"./ripgrep-Dl3y5r4m.js";import{a as zf}from"./loader-CICGtLp2.js";import{n as Bf,r as Vf}from"./switcher-CAajZeNL.js";import{d as Hf,n as Uf,p as Wf}from"./firstPartyEventLogger-M6UMli2c.js";import{i as Gf,n as Kf,r as qf}from"./parser-Cg6hSCmn.js";import{T as Jf,c as Yf,r as Xf,w as Zf}from"./sessionTracing-BoDDYLxW.js";import{n as Qf,t as $f}from"./poorMode-B0QGV6Ci.js";import{C as ep,D as tp,E as np,O as rp,S as ip,T as ap,a as op,c as sp,d as cp,f as lp,i as up,l as dp,m as fp,n as pp,o as mp,p as hp,r as gp,s as _p,t as vp,w as yp,x as bp}from"./TextInput-CD9iau2k.js";import{n as xp,t as Sp}from"./notifications-4wP1Tx9Y.js";import{i as Cp,n as wp}from"./terminalSetup-B_10N_gE.js";import{a as Tp,c as Ep,i as Dp,l as Op,n as kp,o as Ap,r as jp,s as Mp,t as Np,u as Pp}from"./history-CQiUERTL.js";import{t as Fp}from"./useDoublePress-C9xxQzh1.js";import{i as Ip,n as Lp,r as Rp,t as zp}from"./overlayContext-BT2Lq8ei.js";import{t as Bp}from"./SelectMulti-Bc6l11_K.js";import{t as Vp}from"./KeybindingProviderSetup-DA37QUFs.js";import{t as Hp}from"./useManagePlugins-BqfIVa6E.js";import{n as Up,t as Wp}from"./MCPConnectionManager-thZd-xA_.js";import{n as Gp,t as Kp}from"./toolPool-CX5wDBi1.js";import{t as qp}from"./conversationRecovery-2ft8sCPE.js";import{a as Jp,i as Yp,o as Xp,r as Zp,t as Qp}from"./MessageSelector-C0_iw7SI.js";import{n as $p,t as em}from"./useExitOnCtrlCDWithKeybindings-C9BYG8Bo.js";import{n as tm,t as nm}from"./select-Bxf5-5sI.js";import{a as rm,c as im,d as am,f as om,i as sm,l as cm,n as lm,o as um,r as dm,s as fm,u as pm}from"./Spinner-zYPFVFHN.js";import{l as mm,u as hm}from"./SpinnerGlyph-CmkRUvHe.js";import{n as gm,r as _m}from"./sessionTitle-k4wpUS5l.js";import{n as vm,t as ym}from"./sideQuestion-DLJxyrlp.js";import{a as bm,n as xm,o as Sm,r as Cm,s as wm,t as Tm}from"./skillChangeDetector-xviGstqm.js";import{n as Em,t as Dm}from"./reconciler-CeXqh95g.js";import{n as Om,t as km}from"./refresh-Ce2yk28a.js";import{i as Am,n as jm,r as Mm,t as Nm}from"./directoryCompletion-D_Rtg-4j.js";import{r as Pm,t as Fm}from"./PromptInputFooterSuggestions-AyLog8p7.js";import{n as Im,t as Lm}from"./useMergedTools-Bw8FchX8.js";import{a as Rm,i as zm,n as Bm,o as Vm,r as Hm,t as Um}from"./promptEditor-DLGN_eLu.js";import{n as Wm,t as Gm}from"./useMainLoopModel-DwjSVzzO.js";import{a as Km,i as qm,o as Jm,r as Ym,s as Xm,t as Zm}from"./fileSuggestions-DHxdwq28.js";import{E as Qm,T as $m,g as eh,m as th}from"./pidLock-BTqO-h7Y.js";import{n as nh,t as rh}from"./nativeInstaller-C3pVPqrZ.js";import{t as ih}from"./CustomSelect-DoeEXOIP.js";import{i as ah,n as oh,r as sh,t as ch}from"./extraUsage-CmQaLPV1.js";import{n as lh,t as uh}from"./useSearchInput-B25K1RnK.js";import{n as dh,t as fh}from"./staticRender-BVWx0IM1.js";import{n as ph,t as mh}from"./useSettingsErrors-DYQ44kX4.js";import{n as hh,t as gh}from"./shadowedRuleDetection-BRxZjobz.js";import{n as _h,t as vh}from"./ExitFlow-DgAZp_8U.js";import{a as yh,i as bh,r as xh,t as Sh}from"./fast-eGx2IxD7.js";import{i as Ch,n as wh,r as Th,t as Eh}from"./PermissionDialog-BaibiQae.js";import{a as Dh,i as Oh,n as kh,r as Ah,t as jh}from"./PromptInputHelpMenu-oyic20ip.js";import{n as Mh,r as Nh}from"./pluginAutoupdate-8qugAFhb.js";import{n as Ph,t as Fh}from"./generateSessionName-BQoDduyA.js";import{a as Ih,c as Lh,i as Rh,l as zh,n as Bh,o as Vh,r as Hh,s as Uh,t as Wh}from"./Messages-K4DDsDP9.js";import{a as Gh,i as Kh,n as qh,o as Jh,r as Yh,t as Xh}from"./BackgroundTasksDialog-COuhHcey.js";import{n as Zh}from"./fpsMetrics-wxj9GAsd.js";import{a as Qh,c as $h,i as eg,n as tg,r as ng,t as rg}from"./tipRegistry-DamZr34w.js";import{t as ig}from"./earlyInput-IghoCjG5.js";import{n as ag,t as og}from"./backgroundHousekeeping-CVNIhQg8.js";import{homedir as sg,tmpdir as cg}from"os";import*as lg from"path";import{basename as ug,dirname as dg,extname as fg,join as pg,relative as mg,sep as hg}from"path";import{dirname as gg,join as _g}from"node:path";import{createHash as vg}from"node:crypto";import{randomUUID as yg}from"crypto";import{readFile as bg,readdir as xg,stat as Sg,writeFile as Cg}from"fs/promises";import{spawn as wg,spawnSync as Tg}from"child_process";import{mkdir as Eg,readFile as Dg,rename as Og,writeFile as kg}from"node:fs/promises";function Ag(e){return Array.isArray?Array.isArray(e):Bg(e)===`[object Array]`}function jg(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 Mg(e){return e==null?``:jg(e)}function Ng(e){return typeof e==`string`}function Pg(e){return typeof e==`number`}function Fg(e){return e===!0||e===!1||Lg(e)&&Bg(e)==`[object Boolean]`}function Ig(e){return typeof e==`object`}function Lg(e){return Ig(e)&&e!==null}function Rg(e){return e!=null}function zg(e){return!e.trim().length}function Bg(e){return e==null?e===void 0?`[object Undefined]`:`[object Null]`:Object.prototype.toString.call(e)}function Vg(e){let t=null,n=null,r=null,i=1,a=null;if(Ng(e)||Ag(e))r=e,t=Hg(e),n=Ug(e);else{if(!T_.call(e,`name`))throw Error(S_(`name`));let o=e.name;if(r=o,T_.call(e,`weight`)&&e.weight!==void 0&&(i=e.weight,i<=0))throw Error(C_(Ug(o)));t=Hg(o),n=Ug(o),a=e.getFn??null}return{path:t,id:n,weight:i,src:r,getFn:a}}function Hg(e){return Ag(e)?e:e.split(`.`)}function Ug(e){return Ag(e)?e.join(`.`):e}function Wg(e,t){let n=[],r=!1,i=(e,t,a,o)=>{if(Rg(e))if(!t[a])n.push(o===void 0?e:{v:e,i:o});else{let s=e[t[a]];if(!Rg(s))return;if(a===t.length-1&&(Ng(s)||Pg(s)||Fg(s)||typeof s==`bigint`))n.push(o===void 0?Mg(s):{v:Mg(s),i:o});else if(Ag(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,Ng(t)?t.split(`.`):t,0),r?n:n[0]}function Gg(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 Kg(e,t,{getFn:n=Z.getFn,fieldNormWeight:r=Z.fieldNormWeight}={}){let i=new j_({getFn:n,fieldNormWeight:r});return i.setKeys(e.map(Vg)),i.setSources(t),i.create(),i}function qg(e,{getFn:t=Z.getFn,fieldNormWeight:n=Z.fieldNormWeight}={}){let{keys:r,records:i}=e,a=new j_({getFn:t,fieldNormWeight:n});return a.setKeys(r),a.setIndexRecords(i),a}function Jg(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 Yg(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(x_(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=Jg(_,s);e.length?c&&(w.indices=e):w.isMatch=!1}return w}function Xg(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 Zg(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 Qg(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 e_(e,t){let n=e.match(t);return n?n[1]:null}function t_(e,t={}){return e.replace(/\\\|/g,z_).split(B_).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<R_;){let e=L_[o],n=e_(i,e.multiRegex);n&&(r.push(e.create(n,t)),a=!0)}if(!a)for(o=-1;++o<R_;){let e=L_[o],n=e_(i,e.singleRegex);if(n){r.push(e.create(n,t));break}}}return r})}function n_(...e){H_.push(...e)}function r_(e,t){for(let n=0,r=H_.length;n<r;n+=1){let r=H_[n];if(r.condition(e,t))return new r(e,t)}return new F_(e,t)}function i_(e,t,{auto:n=!0}={}){let r=e=>{if(Ng(e)){let r={keyId:null,pattern:e};return n&&(r.searcher=r_(e,t)),r}let i=Object.keys(e),a=K_(e);if(!a&&i.length>1&&!G_(e))return r(J_(e));if(q_(e)){let r=a?e[W_.PATH]:i[0],o=a?e[W_.PATTERN]:e[r];if(!Ng(o))throw Error(b_(r));let s={keyId:Ug(r),pattern:o};return n&&(s.searcher=r_(o,t)),s}let o={children:[],operator:i[0]};return i.forEach(t=>{let n=e[t];Ag(n)&&n.forEach(e=>{o.children.push(r(e))})}),o};return G_(e)||(e=J_(e)),r(e)}function a_(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 o_(e,{ignoreFieldNorm:t=Z.ignoreFieldNorm}){e.forEach(e=>{e.score=a_(e.matches,{ignoreFieldNorm:t})})}function s_(e){let t=[];return e.matches.forEach(e=>{if(!Rg(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 c_(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=s_(e)),r&&(a.score=e.score),a})}function l_(e){Z_.has(e)||(Z_.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 u_(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||l_(e),t=>t.match(e)||[]):e=>e.match(X_)||[]}function d_({isCaseSensitive:e=!1,ignoreDiacritics:t=!1,tokenize:n}={}){let r=u_(n);return{tokenize(n){return e||(n=n.toLowerCase()),t&&(n=P_(n)),r(n)}}}function f_(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 p_(e,t,n,r){let{i,v:a,$:o}=t;if(a!==void 0){f_(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)f_(e,t.v,i,r);else f_(e,n.v,i,r)}}function m_(e,t,n){let r={fieldCount:0,df:new Map,docFieldCount:new Map,docTermFieldHits:new Map};for(let i of e)p_(r,i,t,n);return r}function h_(e,t,n,r){p_(e,t,n,r)}function g_(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 __(e,t){if(t.length===0)return;let n=Array.from(new Set(t)).sort((e,t)=>e-t);for(let t of n)g_(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 v_,y_,b_,x_,S_,C_,w_,T_,E_,D_,O_,k_,A_,Z,j_,M_,N_,P_,F_,I_,L_,R_,z_,B_,V_,H_,U_,W_,G_,K_,q_,J_,Y_,X_,Z_,Q_,$_,ev,tv=t((()=>{v_=`Incorrect 'index' type`,y_=`Invalid doc index: must be a non-negative integer within the bounds of the docs array`,b_=e=>`Invalid value for key ${e}`,x_=e=>`Pattern length exceeds max of ${e}.`,S_=e=>`Missing ${e} property in key`,C_=e=>`Property 'weight' in key '${e}' must be a positive integer`,w_=`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.`,T_=Object.prototype.hasOwnProperty,E_=class{constructor(e){this._keys=[],this._keyMap={};let t=0;e.forEach(e=>{let n=Vg(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)}},D_={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},O_={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},k_={location:0,threshold:.6,distance:100},A_={useExtendedSearch:!1,useTokenSearch:!1,tokenize:void 0,tokenMatch:`any`,getFn:Wg,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1},Z=Object.freeze({...O_,...D_,...k_,...A_}),j_=class{constructor({getFn:e=Z.getFn,fieldNormWeight:t=Z.fieldNormWeight}={}){this.norm=Gg(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(Ng(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(y_);if(Ng(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(y_);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!Rg(e)||zg(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(Rg(i)){if(Ag(i)){let e=[];for(let t=0,n=i.length;t<n;t+=1){let n=i[t];if(Rg(n)){if(Ng(n)){if(!zg(n)){let r={v:n,i:t,n:this.norm.get(n)};e.push(r)}}else if(Rg(n.v)){let t=Ng(n.v)?n.v:Mg(n.v);if(!zg(t)){let r={v:t,i:n.i,n:this.norm.get(t)};e.push(r)}}}}n.$[t]=e}else if(Ng(i)&&!zg(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}}},M_={ł:`l`,Ł:`L`,đ:`d`,Đ:`D`,ø:`o`,Ø:`O`,ħ:`h`,Ħ:`H`,ŧ:`t`,Ŧ:`T`,ı:`i`,ß:`ss`},N_=RegExp(`[`+Object.keys(M_).join(``)+`]`,`g`),P_=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(N_,e=>M_[e]):e=>e,F_=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?P_(e):e,this.pattern=e,this.chunks=[],!this.pattern.length)return;let u=(e,t)=>{this.chunks.push({pattern:e,alphabet:Xg(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?P_(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}=Yg(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=Zg(u)),p}},I_=new Set([`fuzzy`,`include`]),L_=[{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 F_(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)}}}}],R_=L_.length,z_=`\0`,B_=`|`,V_=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?P_(e):e,this.pattern=e,this.query=t_(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?P_(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,Qg(r.type)&&(c=!0),n&&(I_.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=Zg(o)),e}}return{isMatch:!1,score:1}}},H_=[],U_={AND:`$and`,OR:`$or`},W_={PATH:`$path`,PATTERN:`$val`},G_=e=>!!(e[U_.AND]||e[U_.OR]),K_=e=>!!e[W_.PATH],q_=e=>!Ag(e)&&Ig(e)&&!G_(e),J_=e=>({[U_.AND]:Object.keys(e).map(t=>({[t]:e[t]}))}),Y_=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)}},X_=/[\p{L}\p{M}\p{N}_]+/gu,Z_=new WeakSet,Q_=class{static condition(e,t){return t.useTokenSearch}constructor(e,t){this.options=t,this.analyzer=d_({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 F_(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=Zg(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 E_(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=r_(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 j_))throw Error(v_);if(this._myIndex=t||Kg(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight}),this.options.useTokenSearch){let e=d_({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});this._invertedIndex=m_(this._myIndex.records,this._myIndex.keys.length,e)}this._invalidateSearcherCache()}add(e){if(!Rg(e))return;this._docs.push(e);let t=this._myIndex.add(e,this._docs.length-1);if(this._invertedIndex&&t){let e=d_({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});h_(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&&__(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(y_);this._invertedIndex&&__(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(Ng(e)&&!e.trim()){let e=this._docs.map((e,t)=>({item:e,refIndex:t}));return Pg(n)&&n>-1&&(e=e.slice(0,n)),e}let c=Pg(n)&&n>0&&Ng(e),l;if(c){let t=new Y_(n);Ng(this._docs[0])?this._searchStringList(e,{heap:t,ignoreFieldNorm:s}):this._searchObjectList(e,{heap:t,ignoreFieldNorm:s}),l=t.extractSorted(o)}else l=Ng(e)?Ng(this._docs[0])?this._searchStringList(e):this._searchObjectList(e):this._searchLogical(e),o_(l,{ignoreFieldNorm:s}),a&&l.sort(o),Pg(n)&&n>-1&&(l=l.slice(0,n));return c_(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(!Rg(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=a_(r.matches,{ignoreFieldNorm:n}),t.shouldInsert(r.score)&&t.insert(r)):o.push(r)}}}),o}_searchLogical(e){let t=i_(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===U_.AND)return[]}return o},r=this._myIndex.records,i=new Map,a=[];return r.forEach(({$:e,i:r})=>{if(Rg(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(!Rg(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=a_(r.matches,{ignoreFieldNorm:n}),t.shouldInsert(r.score)&&t.insert(r)):s.push(r)}}),s}_findMatches({key:e,value:t,searcher:n}){if(!Rg(t))return[];let r=[];if(Ag(t))t.forEach(({v:t,i,n:a})=>{if(!Rg(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=Kg,$_.parseIndex=qg,$_.config=Z,$_.match=function(e,t,n){if(n&&n.useTokenSearch)throw Error(w_);return r_(e,{...Z,...n}).searchIn(t)},$_.parseQuery=i_,n_(V_),n_(Q_),$_.use=function(...e){e.forEach(e=>n_(e))},ev=$_}));s();var nv=d();ol(),l(),J(),Il(),Pl(),ku(),Hd(),gi(),zi(),cp(),uh();var Q=n(Uc(),1);Dc(),Bh(),Xr(),Io(),V(),fh();var $=dl();function rv({children:e}){let{bindings:t}=lo(),n=(0,Q.useRef)(null),r=(0,Q.useRef)(new Map),i=(0,Q.useRef)(new Set).current;return(0,$.jsx)(Oc,{bindings:t,pendingChordRef:n,pendingChord:null,setPendingChord:()=>{},activeContexts:i,registerActiveContext:()=>{},unregisterActiveContext:()=>{},handlerRegistryRef:r,children:e})}function iv(e){if(!(`message`in e))return 1;let t=e.message.content;return Array.isArray(t)?t.length:1}async function av(e,t,n,{columns:r,verbose:i=!1,chunkSize:a=40,onProgress:o}={}){let s=n=>dh((0,$.jsx)(hn,{children:(0,$.jsx)(rv,{children:(0,$.jsx)(Wh,{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+=iv(t);for(let e=0;e<c;e+=a){let t=await s([e,e+a]);if(il(t).trim()===``)break;await n(t),o?.(e+a)}}async function ov(e,t=[],n){let r=[];return await av(e,t,e=>void r.push(il(e)),{columns:n}),r.join(``)}o(),Yc(),El(),cu(),uu(),pu(),mu(),Tu(),xu(),Cu(),Ku(),Ed(),Td(),_d(),xl(),Od(),Nu(),zd(),nd(),Bd(),Ru(),ld(),Sl(),Kd(),td(),Cl(),Nd(),id(),Au(),Qu(),qu(),Lu(),Pd(),Zu(),fd(),xf(),hd(),kf(),Zd(),uf(),ef(),ff(),Df(),jf(),M(),wi(),qo(),Yt(),Rf(),tc(),f(),qt(),Ee(),os(),Gi(),N(),gt(),Rt(),D(),ye(),Rn(),qs(),la(),fo(),to(),w(),Ff(),Eo(),nr(),cn(),ve(),nc(),Ki(),eo(),Oo(),ms(),Hr(),Yo(),Tf(),Mf(),Re(),gc(),k(),vi(),ua(),Fi(),wr(),ur(),vt(),Ht(),Sn(),rt(),qf(),F(),pn(),Ya(),z(),Zs(),ei(),go(),ds(),ba(),Be(),Pt(),an(),me(),Hi(),Vr(),lt(),gr(),Ae(),Ka(),B(),oe(),Zf(),ac(),Bo(),Pi(),no(),ui(),qi(),Es(),yr(),Ft(),j(),b(),Ur(),Gs(),Vn(),$r(),fa(),jn(),be(),Yf(),na(),Fr(),pt(),St(),Qa(),Wn(),Rs(),Qi(),Sa(),Ui(),pe(),bi(),oo(),tt(),cr(),Oe(),Ha(),Nr(),Mn(),Ut(),Hf(),Uf(),Qr(),ni(),Nt(),_o(),br(),Ko(),tr(),or(),hi(),Rm(),ih();function sv({onDone:e}){return(0,$.jsxs)(cl,{title:`You've spent $5 on the API this session.`,onCancel:e,children:[(0,$.jsxs)(K,{flexDirection:`column`,children:[(0,$.jsx)(q,{children:`Learn more about how to monitor your spending:`}),(0,$.jsx)(kc,{url:`https://code.workmate.com/docs/en/costs`})]}),(0,$.jsx)(nm,{options:[{value:`ok`,label:`Got it, thanks!`}],onChange:e})]})}tm(),J(),ih();function cv({idleMinutes:e,totalInputTokens:t,onDone:n}){return(0,$.jsxs)(cl,{title:`You've been away ${lv(e)} and this conversation is ${Jd(t)} tokens.`,onCancel:()=>n(`dismiss`),children:[(0,$.jsx)(K,{flexDirection:`column`,children:(0,$.jsx)(q,{children:`If this is a new task, clearing context will save usage and be faster.`})}),(0,$.jsx)(nm,{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 lv(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`}Sp();async function uv(e,t){let n=gd().preferredNotifChannel;await bc(e),X(`tengu_notification_method_used`,{configured_channel:n,method_used:await fv(n,e,t),term:Wu.terminal})}var dv=`Work Mate`;async function fv(e,t,n){let r=t.title||dv;try{switch(e){case`auto`:return pv(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:mv()}),`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 pv(e,t){let n=e.title||dv;switch(Wu.terminal){case`Apple_Terminal`:return await hv()?(t.notifyBell(),`terminal_bell`):`no_method_available`;case`iTerm.app`:return t.notifyITerm2(e),`iterm2`;case`kitty`:return t.notifyKitty({...e,title:n,id:mv()}),`kitty`;case`ghostty`:return t.notifyGhostty({...e,title:n}),`ghostty`;default:return`no_method_available`}}function mv(){return Math.floor(Math.random()*1e4)}async function hv(){try{if(Wu.terminal!==`Apple_Terminal`)return!1;let e=(await vd(`osascript`,[`-e`,`tell application "Terminal" to name of current settings of front window`])).stdout.trim();if(!e)return!1;let t=await vd(`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 Dd(e),!1}}var gv=300,_v=240*1e3,vv=null,yv=null,bv=0,xv=!1;function Sv(){bv++,bv===1&&(Dv(),Tv())}function Cv(){bv>0&&bv--,bv===0&&(Ev(),Ov())}function wv(){bv=0,Ev(),Ov()}function Tv(){process.platform===`darwin`&&yv===null&&(yv=setInterval(()=>{bv>0&&(Y(`Restarting caffeinate to maintain sleep prevention`),Ov(),Dv())},_v),yv.unref())}function Ev(){yv!==null&&(clearInterval(yv),yv=null)}function Dv(){if(process.platform===`darwin`&&vv===null){xv||(xv=!0,bu(async()=>{wv()}));try{vv=wg(`caffeinate`,[`-i`,`-t`,String(gv)],{stdio:`ignore`}),vv.unref();let e=vv;vv.on(`error`,t=>{Y(`caffeinate spawn error: ${t.message}`),vv===e&&(vv=null)}),vv.on(`exit`,()=>{vv===e&&(vv=null)}),Y(`Started caffeinate to prevent sleep`)}catch{vv=null}}}function Ov(){if(vv!==null){let e=vv;vv=null;try{e.kill(`SIGKILL`),Y(`Stopped caffeinate, allowing sleep`)}catch{}}}var kv=class{constructor(){c(this,`_status`,`idle`),c(this,`_generation`,0),c(this,`_changed`,eu()),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 Av(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(Ve(f,{},p,e).then(e=>{m===a.current&&e&&!l&&(r.current=e)}),l||c||u){let t=fr(f,e).findLast(Ls);t&&(r.current=t.uuid)}n.current=e.length,i.current=o},[e,t])}em(),om(),pm(),um(),dm(),Zp(),Bd();var jv=wl(()=>ml({method:gl(`log_event`),params:ml({eventName:vl(),eventData:ml({}).passthrough()})}));function Mv(e){(0,Q.useEffect)(()=>{if(!e.length)return;let t=E(e);t&&t.client.setNotificationHandler(jv(),e=>{let{eventName:t,eventData:n}=e.params;X(`tengu_ide_${t}`,n)})},[e])}J();var Nv=6e3;function Pv(){return Date.now()-Dl()}function Fv(e){return Pv()<e}function Iv(e){return!Fv(e)}function Lv(e,t){let n=Ac();(0,Q.useEffect)(()=>{Ml(!0)},[]),(0,Q.useEffect)(()=>{let r=!1,i=setInterval(()=>{Iv(6e3)&&!r&&(r=!0,clearInterval(i),uv({message:e,notificationType:t},n))},Nv);return()=>clearInterval(i)},[e,t,n])}Lf(),rc(),hs(),Ct(),ke(),Et(),Wa(),rp(),ap(),ep(),Cp(),Mp(),Fp(),_p(),up(),pp(),Hm(),Ch(),J(),_a();var Rv={topLeft:`┌`,topRight:`┐`,bottomLeft:`└`,bottomRight:`┘`,horizontal:`─`,vertical:`│`,teeLeft:`├`,teeRight:`┤`};function zv(e){return Wt().syntaxHighlightingDisabled?(0,$.jsx)(Vv,{...e,highlight:null}):(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(Vv,{...e,highlight:null}),children:(0,$.jsx)(Bv,{...e})})}function Bv(e){let t=(0,Q.use)(Qn());return(0,$.jsx)(Vv,{...e,highlight:t})}function Vv({content:e,maxLines:t,minHeight:n,minWidth:r=40,maxWidth:i,highlight:a}){let{columns:o}=tl(),[s]=Ec(),c=i??o-4,l=t??20,u=(0,Q.useMemo)(()=>Ni(e,s,a),[e,s,a]).split(`
|
|
2
|
+
`),d=u.length>l,f=d?u.slice(0,l):u,p=Math.max(0,Math.min(n??0,l)-f.length-+!!d),m=p>0?[...f,...Array(p).fill(``)]:f,h=Math.max(r,...m.map(e=>wc(e))),g=Math.min(h+4,c),_=g-4,v=`${Rv.topLeft}${Rv.horizontal.repeat(g-2)}${Rv.topRight}`,y=`${Rv.bottomLeft}${Rv.horizontal.repeat(g-2)}${Rv.bottomRight}`,b=d?(()=>{let e=u.length-l,t=`${Rv.horizontal.repeat(3)} \u2702 ${Rv.horizontal.repeat(3)} ${e} lines hidden `,n=wc(t),r=Math.max(0,g-2-n);return`${Rv.teeLeft}${t}${Rv.horizontal.repeat(r)}${Rv.teeRight}`})():null;return(0,$.jsxs)(K,{flexDirection:`column`,children:[(0,$.jsx)(q,{dimColor:!0,children:v}),m.map((e,t)=>{let n=wc(e)>_?ci(e,0,_):e,r=` `.repeat(Math.max(0,_-wc(n)));return(0,$.jsxs)(K,{flexDirection:`row`,children:[(0,$.jsxs)(q,{dimColor:!0,children:[Rv.vertical,` `]}),(0,$.jsx)(Cc,{children:n}),(0,$.jsxs)(q,{dimColor:!0,children:[r,` `,Rv.vertical]})]},t)}),b&&(0,$.jsx)(q,{color:`warning`,children:b}),(0,$.jsx)(q,{dimColor:!0,children:y})]})}gi(),J(),Kd();function Hv({questions:e,currentQuestionIndex:t,answers:n,hideSubmitTab:r=!1}){let{columns:i}=tl(),a=(0,Q.useMemo)(()=>{let n=r?``:` ${u.tick} Submit `,a=wc(`← `)+wc(` →`)+wc(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+wc(e)).reduce((e,t)=>e+t,0)<=o)return s;let c=4+wc(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?Gd(e,l-2-2):Gd(e,p-2-2))},[e,t,i,r]),o=e.length===1&&r;return(0,$.jsxs)(K,{flexDirection:`row`,marginBottom:1,children:[!o&&(0,$.jsx)(q,{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)(K,{children:i?(0,$.jsxs)(q,{backgroundColor:`permission`,color:`inverseText`,children:[` `,o,` `,s,` `]}):(0,$.jsxs)(q,{children:[` `,o,` `,s,` `]})},e?.question||`question-${r}`)}),!r&&(0,$.jsx)(K,{children:t===e.length?(0,$.jsxs)(q,{backgroundColor:`permission`,color:`inverseText`,children:[` `,u.tick,` Submit`,` `]}):(0,$.jsxs)(q,{children:[` `,u.tick,` Submit `]})},`submit`),!o&&(0,$.jsx)(q,{color:t===e.length?`inactive`:void 0,children:` →`})]})}l(),gi(),J(),V(),cn();function Uv({question:e,questions:t,currentQuestionIndex:n,answers:r,questionStates:i,hideSubmitTab:a=!1,minContentHeight:o,minContentWidth:s,onUpdateQuestionState:c,onAnswer:l,onTextInputFocus:d,onCancel:f,onTabPrev:p,onTabNext:m,onRespondToClaude:h,onFinishPlanInterview:g}){let _=H(e=>e.toolPermissionContext.mode)===`plan`,[v,y]=(0,Q.useState)(!1),[b,x]=(0,Q.useState)(0),[S,C]=(0,Q.useState)(!1),[w,T]=(0,Q.useState)(0),E=zm(),D=E?pc(E):null,O=e.question,k=i[O],A=e.options,[j,M]=(0,Q.useState)(0),ee=(0,Q.useRef)(O);if(ee.current!==O){ee.current=O;let e=k?.selectedValue,t=e?A.findIndex(t=>t.label===e):-1;M(t>=0?t:0)}let te=A[j],N=k?.selectedValue,P=k?.textInputValue||``,ne=(0,Q.useCallback)(e=>{let t=A[e];t&&(M(e),c(O,{selectedValue:t.label},!1),l(O,t.label))},[A,O,c,l]),F=(0,Q.useCallback)(e=>{if(S)return;let t;t=typeof e==`number`?e:e===`up`?j>0?j-1:j:j<A.length-1?j+1:j,t>=0&&t<A.length&&M(t)},[j,A.length,S]);Fc(`chat:externalEditor`,async()=>{let e=k?.textInputValue||``,t=await Bm(e);t.content!==null&&t.content!==e&&c(O,{textInputValue:t.content},!1)},{context:`Chat`,isActive:S&&!!E}),Tc({"tabs:previous":()=>p?.(),"tabs:next":()=>m?.()},{context:`Tabs`,isActive:!S&&!v});let I=(0,Q.useCallback)(()=>{C(!1),d(!1),N&&l(O,N)},[N,O,l,d]),re=(0,Q.useCallback)(()=>{y(!0)},[]),L=(0,Q.useCallback)(()=>{y(!1)},[]),ie=(0,Q.useCallback)(e=>{if(v){if(e.key===`up`||e.ctrl&&e.key===`p`){e.preventDefault(),b===0?L():x(0);return}if(e.key===`down`||e.ctrl&&e.key===`n`){e.preventDefault(),_&&b===0&&x(1);return}if(e.key===`return`){e.preventDefault(),b===0?h():g();return}e.key===`escape`&&(e.preventDefault(),f());return}if(S){e.key===`escape`&&(e.preventDefault(),I());return}if(e.key===`up`||e.ctrl&&e.key===`p`)e.preventDefault(),j>0&&F(`up`);else if(e.key===`down`||e.ctrl&&e.key===`n`)e.preventDefault(),j===A.length-1?re():F(`down`);else if(e.key===`return`)e.preventDefault(),ne(j);else if(e.key===`n`&&!e.ctrl&&!e.meta)e.preventDefault(),C(!0),d(!0);else if(e.key===`escape`)e.preventDefault(),f();else if(e.key.length===1&&e.key>=`1`&&e.key<=`9`){e.preventDefault();let t=parseInt(e.key,10)-1;t<A.length&&F(t)}},[v,b,_,S,j,A.length,L,re,F,ne,I,h,g,f,d]),ae=te?.preview||null,{columns:oe}=tl(),se=oe-30-4,R=(0,Q.useMemo)(()=>o?Math.max(1,o-11):void 0,[o]);return(0,$.jsxs)(K,{flexDirection:`column`,marginTop:1,tabIndex:0,autoFocus:!0,onKeyDown:ie,children:[(0,$.jsx)(xc,{color:`inactive`}),(0,$.jsxs)(K,{flexDirection:`column`,paddingTop:0,children:[(0,$.jsx)(Hv,{questions:t,currentQuestionIndex:n,answers:r,hideSubmitTab:a}),(0,$.jsx)(Th,{title:e.question,color:`text`}),(0,$.jsxs)(K,{flexDirection:`column`,minHeight:o,children:[(0,$.jsxs)(K,{marginTop:1,flexDirection:`row`,gap:4,children:[(0,$.jsx)(K,{flexDirection:`column`,width:30,children:A.map((e,t)=>{let n=j===t,r=N===e.label;return(0,$.jsxs)(K,{flexDirection:`row`,children:[n?(0,$.jsx)(q,{color:`suggestion`,children:u.pointer}):(0,$.jsx)(q,{children:` `}),(0,$.jsxs)(q,{dimColor:!0,children:[` `,t+1,`.`]}),(0,$.jsxs)(q,{color:r?`success`:n?`suggestion`:void 0,bold:n,children:[` `,e.label]}),r&&(0,$.jsxs)(q,{color:`success`,children:[` `,u.tick]})]},e.label)})}),(0,$.jsxs)(K,{flexDirection:`column`,flexGrow:1,children:[(0,$.jsx)(zv,{content:ae||`No preview available`,maxLines:R,minWidth:s,maxWidth:se}),(0,$.jsxs)(K,{marginTop:1,flexDirection:`row`,gap:1,children:[(0,$.jsx)(q,{color:`suggestion`,children:`Notes:`}),S?(0,$.jsx)(vp,{value:P,placeholder:`Add notes on this design…`,onChange:e=>{c(O,{textInputValue:e},!1)},onSubmit:I,onExit:I,focus:!0,showCursor:!0,columns:60,cursorOffset:w,onChangeCursorOffset:T}):(0,$.jsx)(q,{dimColor:!0,italic:!0,children:P||`press n to add notes`})]})]})]}),(0,$.jsxs)(K,{flexDirection:`column`,marginTop:1,children:[(0,$.jsx)(xc,{color:`inactive`}),(0,$.jsxs)(K,{flexDirection:`row`,gap:1,children:[v&&b===0?(0,$.jsx)(q,{color:`suggestion`,children:u.pointer}):(0,$.jsx)(q,{children:` `}),(0,$.jsx)(q,{color:v&&b===0?`suggestion`:void 0,children:`Chat about this`})]}),_&&(0,$.jsxs)(K,{flexDirection:`row`,gap:1,children:[v&&b===1?(0,$.jsx)(q,{color:`suggestion`,children:u.pointer}):(0,$.jsx)(q,{children:` `}),(0,$.jsx)(q,{color:v&&b===1?`suggestion`:void 0,children:`Skip interview and plan immediately`})]})]}),(0,$.jsx)(K,{marginTop:1,children:(0,$.jsxs)(q,{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`}),S&&D&&(0,$.jsxs)($.Fragment,{children:[` · ctrl+g to edit in `,D]}),` · Esc to cancel`]})})]})]})]})}l(),J(),V(),Rm(),cn(),Hm(),ih(),Ch();function Wv({question:e,questions:t,currentQuestionIndex:n,answers:r,questionStates:i,hideSubmitTab:a=!1,planFilePath:o,minContentHeight:s,minContentWidth:c,onUpdateQuestionState:l,onAnswer:d,onTextInputFocus:f,onCancel:p,onSubmit:m,onTabPrev:h,onTabNext:g,onRespondToClaude:_,onFinishPlanInterview:v,onImagePaste:y,pastedContents:b,onRemoveImage:x}){let S=H(e=>e.toolPermissionContext.mode)===`plan`,[C,w]=(0,Q.useState)(!1),[T,E]=(0,Q.useState)(0),[D,O]=(0,Q.useState)(!1),k=zm(),A=k?pc(k):null,j=(0,Q.useCallback)(e=>{let t=e===`__other__`;O(t),f(t)},[f]),M=(0,Q.useCallback)(()=>{w(!0)},[]),ee=(0,Q.useCallback)(()=>{w(!1)},[]),te=(0,Q.useCallback)(e=>{if(C){if(e.key===`up`||e.ctrl&&e.key===`p`){e.preventDefault(),T===0?ee():E(0);return}if(e.key===`down`||e.ctrl&&e.key===`n`){e.preventDefault(),S&&T===0&&E(1);return}if(e.key===`return`){e.preventDefault(),T===0?_():v();return}e.key===`escape`&&(e.preventDefault(),p())}},[C,T,S,ee,_,v,p]),N=e.options.map(e=>({type:`text`,value:e.label,label:e.label,description:e.description})),P=e.question,ne=i[P],F=(0,Q.useCallback)(async(t,n)=>{let r=await Bm(t);r.content!==null&&r.content!==t&&(n(r.content),l(P,{textInputValue:r.content},e.multiSelect??!1))},[P,l,e.multiSelect]),I={type:`input`,value:`__other__`,label:`Other`,placeholder:e.multiSelect?`Type something`:`Type something.`,initialValue:ne?.textInputValue??``,onChange:t=>{l(P,{textInputValue:t},e.multiSelect??!1)}},re=[...N,I];return!e.multiSelect&&e.options.some(e=>e.preview)?(0,$.jsx)(Uv,{question:e,questions:t,currentQuestionIndex:n,answers:r,questionStates:i,hideSubmitTab:a,minContentHeight:s,minContentWidth:c,onUpdateQuestionState:l,onAnswer:d,onTextInputFocus:f,onCancel:p,onTabPrev:h,onTabNext:g,onRespondToClaude:_,onFinishPlanInterview:v}):(0,$.jsxs)(K,{flexDirection:`column`,marginTop:0,tabIndex:0,autoFocus:!0,onKeyDown:te,children:[S&&o&&(0,$.jsxs)(K,{flexDirection:`column`,gap:0,children:[(0,$.jsx)(xc,{color:`inactive`}),(0,$.jsxs)(q,{color:`inactive`,children:[`Planning: `,(0,$.jsx)(Ri,{filePath:o})]})]}),(0,$.jsx)(K,{marginTop:-1,children:(0,$.jsx)(xc,{color:`inactive`})}),(0,$.jsxs)(K,{flexDirection:`column`,paddingTop:0,children:[(0,$.jsx)(Hv,{questions:t,currentQuestionIndex:n,answers:r,hideSubmitTab:a}),(0,$.jsx)(Th,{title:e.question,color:`text`}),(0,$.jsxs)(K,{flexDirection:`column`,minHeight:s,children:[(0,$.jsx)(K,{marginTop:1,children:e.multiSelect?(0,$.jsx)(Bp,{options:re,defaultValue:i[e.question]?.selectedValue,onChange:e=>{l(P,{selectedValue:e},!0);let t=e.includes(`__other__`)?i[P]?.textInputValue:void 0,n=e.filter(e=>e!==`__other__`).concat(t?[t]:[]);d(P,n,void 0,!1)},onFocus:j,onCancel:p,submitButtonText:n===t.length-1?`Submit`:`Next`,onSubmit:m,onDownFromLastItem:M,isDisabled:C,onOpenEditor:F,onImagePaste:y,pastedContents:b,onRemoveImage:x},e.question):(0,$.jsx)(nm,{options:re,defaultValue:i[e.question]?.selectedValue,onChange:e=>{l(P,{selectedValue:e},!1);let t=e===`__other__`?i[P]?.textInputValue:void 0;d(P,e,t)},onFocus:j,onCancel:p,onDownFromLastItem:M,isDisabled:C,layout:`compact-vertical`,onOpenEditor:F,onImagePaste:y,pastedContents:b,onRemoveImage:x},e.question)}),(0,$.jsxs)(K,{flexDirection:`column`,children:[(0,$.jsx)(xc,{color:`inactive`}),(0,$.jsxs)(K,{flexDirection:`row`,gap:1,children:[C&&T===0?(0,$.jsx)(q,{color:`suggestion`,children:u.pointer}):(0,$.jsx)(q,{children:` `}),(0,$.jsxs)(q,{color:C&&T===0?`suggestion`:void 0,children:[re.length+1,`. Chat about this`]})]}),S&&(0,$.jsxs)(K,{flexDirection:`row`,gap:1,children:[C&&T===1?(0,$.jsx)(q,{color:`suggestion`,children:u.pointer}):(0,$.jsx)(q,{children:` `}),(0,$.jsxs)(q,{color:C&&T===1?`suggestion`:void 0,children:[re.length+2,`. Skip interview and plan immediately`]})]})]}),(0,$.jsx)(K,{marginTop:1,children:(0,$.jsxs)(q,{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`,D&&A&&(0,$.jsxs)($.Fragment,{children:[` · ctrl+g to edit in `,A]}),` · Esc to cancel`]})})]})]})]})}J(),ii(),V();function Gv(e,t){if(!e)return null;switch(e.type){case`rule`:return{reasonString:`Permission rule ${Kc.bold(Vu(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?` ${Kc.dim(`[${e.hookSource}]`)}`:``;return{reasonString:`Hook ${Kc.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 Kv({permissionResult:e,toolType:t}){let n=H(e=>e.toolPermissionContext.mode),r=Gv(e?.decisionReason,t);if(!r)return null;let i=r.themeColor??(e?.decisionReason?.type===`hook`&&n===`auto`?`warning`:void 0);return(0,$.jsxs)(K,{marginBottom:1,flexDirection:`column`,children:[i?(0,$.jsx)(q,{color:i,children:r.reasonString}):(0,$.jsx)(q,{children:(0,$.jsx)(Cc,{children:r.reasonString})}),r.configString&&(0,$.jsx)(q,{dimColor:!0,children:r.configString})]})}l(),J(),ih(),Ch();function qv({questions:e,currentQuestionIndex:t,answers:n,allQuestionsAnswered:r,permissionResult:i,minContentHeight:a,onFinalResponse:o}){return(0,$.jsxs)(K,{flexDirection:`column`,marginTop:1,children:[(0,$.jsx)(xc,{color:`inactive`}),(0,$.jsxs)(K,{flexDirection:`column`,borderTop:!0,borderColor:`inactive`,paddingTop:0,children:[(0,$.jsx)(Hv,{questions:e,currentQuestionIndex:t,answers:n}),(0,$.jsx)(Th,{title:`Review your answers`,color:`text`}),(0,$.jsxs)(K,{flexDirection:`column`,marginTop:1,minHeight:a,children:[!r&&(0,$.jsx)(K,{marginBottom:1,children:(0,$.jsxs)(q,{color:`warning`,children:[u.warning,` You have not answered all questions`]})}),Object.keys(n).length>0&&(0,$.jsx)(K,{flexDirection:`column`,marginBottom:1,children:e.filter(e=>e?.question&&n[e.question]).map(e=>{let t=n[e?.question];return(0,$.jsxs)(K,{flexDirection:`column`,marginLeft:1,children:[(0,$.jsxs)(q,{children:[u.bullet,` `,e?.question||`Question`]}),(0,$.jsx)(K,{marginLeft:2,children:(0,$.jsxs)(q,{color:`success`,children:[u.arrowRight,` `,t]})})]},e?.question||`answer`)})}),(0,$.jsx)(Kv,{permissionResult:i,toolType:`tool`}),(0,$.jsx)(q,{color:`inactive`,children:`Ready to submit your answers?`}),(0,$.jsx)(K,{marginTop:1,children:(0,$.jsx)(nm,{options:[{type:`text`,label:`Submit answers`,value:`submit`},{type:`text`,label:`Cancel`,value:`cancel`}],onChange:e=>o(e),onCancel:()=>o(`cancel`)})})]})]})]})}function Jv(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 Yv={currentQuestionIndex:0,answers:{},questionStates:{},isInTextInput:!1};function Xv(){let[e,t]=(0,Q.useReducer)(Jv,Yv),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}}Pt(),gi(),J(),fo(),Bd(),V(),me(),Td(),qi();var Zv=12,Qv=40,$v=15;function ey(e){return Wt().syntaxHighlightingDisabled?(0,$.jsx)(ny,{...e,highlight:null}):(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(ny,{...e,highlight:null}),children:(0,$.jsx)(ty,{...e})})}function ty(e){let t=(0,Q.use)(Qn());return(0,$.jsx)(ny,{...e,highlight:t})}function ny({toolUseConfirm:e,onDone:t,onReject:n,highlight:r}){let i=(0,Q.useMemo)(()=>Xs.inputSchema.safeParse(e.input),[e.input]),a=i.success&&i.data.questions||[],{rows:o}=tl(),[s]=Ec(),{globalContentHeight:c,globalContentWidth:l}=(0,Q.useMemo)(()=>{let e=0,t=0,n=Math.max(Zv,o-$v);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=Ni(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,wc(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,Zv),n),globalContentWidth:Math.max(t,Qv)}},[a,o,s,r]),u=i.success?i.data.metadata?.source:void 0,[d,f]=(0,Q.useState)({}),p=(0,Q.useRef)(0);function m(e,t,n,r,i,a){let o=p.current++,s={id:o,type:`image`,content:t,mediaType:n||`image/png`,filename:r||`Pasted image`,dimensions:i};Kt(s),G(s),f(t=>({...t,[e]:{...t[e]??{},[o]:s}}))}let h=(0,Q.useCallback)((e,t)=>{f(n=>{let r={...n[e]??{}};return delete r[t],{...n,[e]:r}})},[]),g=Object.values(d).flatMap(e=>Object.values(e)).filter(e=>e.type===`image`),_=H(e=>e.toolPermissionContext.mode)===`plan`,v=_?he():void 0,{currentQuestionIndex:y,answers:b,questionStates:x,isInTextInput:S,nextQuestion:C,prevQuestion:w,updateQuestionState:T,setAnswer:E,setTextInputMode:D}=Xv(),O=y<(a?.length||0)?a?.[y]:null,k=y===(a?.length||0),A=a?.every(e=>e?.question&&!!b[e.question])??!1,j=a.length===1&&!a[0]?.multiSelect,M=(0,Q.useCallback)(()=>{u&&X(`tengu_ask_user_question_rejected`,{source:u,questionCount:a.length,isInPlanMode:_,interviewPhaseEnabled:_&&Ps()}),t(),n(),e.onReject()},[t,n,e,u,a.length,_]),ee=(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=b[e.question];return t?`- "${e.question}"\n Answer: ${t}`:`- "${e.question}"\n (No answer provided)`}).join(`
|
|
9
|
+
`)}`;u&&X(`tengu_ask_user_question_respond_to_claude`,{source:u,questionCount:a.length,isInPlanMode:_,interviewPhaseEnabled:_&&Ps()});let r=await ry(g);t(),e.onReject(n,r&&r.length>0?r:void 0)},[a,b,t,e,u,_,g]),te=(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=b[e.question];return t?`- "${e.question}"\n Answer: ${t}`:`- "${e.question}"\n (No answer provided)`}).join(`
|
|
13
|
+
`)}`;u&&X(`tengu_ask_user_question_finish_plan_interview`,{source:u,questionCount:a.length,isInPlanMode:_,interviewPhaseEnabled:_&&Ps()});let r=await ry(g);t(),e.onReject(n,r&&r.length>0?r:void 0)},[a,b,t,e,u,_,g]),N=(0,Q.useCallback)(async n=>{u&&X(`tengu_ask_user_question_accepted`,{source:u,questionCount:a.length,answerCount:Object.keys(n).length,isInPlanMode:_,interviewPhaseEnabled:_&&Ps()});let r={};for(let e of a){let t=n[e.question],i=x[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 ry(g);t(),e.onAllow(i,[],void 0,o&&o.length>0?o:void 0)},[e,t,u,a,x,_,g]),P=(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={...b,[e]:i};N(t).catch(Dd);return}E(e,i,r)},[E,a.length,b,N,d]);function ne(e){if(e===`cancel`){M();return}e===`submit`&&N(b).catch(Dd)}let F=j?(a?.length||1)-1:a?.length||0,I=(0,Q.useCallback)(()=>{y>0&&w()},[y,w]),re=(0,Q.useCallback)(()=>{y<F&&C()},[y,F,C]);return Tc({"tabs:previous":I,"tabs:next":re},{context:`Tabs`,isActive:!(S&&!k)}),O?(0,$.jsx)(Wv,{question:O,questions:a,currentQuestionIndex:y,answers:b,questionStates:x,hideSubmitTab:j,minContentHeight:c,minContentWidth:l,planFilePath:v,onUpdateQuestionState:T,onAnswer:P,onTextInputFocus:D,onCancel:M,onSubmit:C,onTabPrev:I,onTabNext:re,onRespondToClaude:ee,onFinishPlanInterview:te,onImagePaste:(e,t,n,r,i)=>m(O.question,e,t,n,r,i),pastedContents:d[O.question]??{},onRemoveImage:e=>h(O.question,e)}):k?(0,$.jsx)(qv,{questions:a,currentQuestionIndex:y,answers:b,allQuestionsAnswered:A,permissionResult:e.permissionResult,minContentHeight:c,onFinalResponse:ne}):null}async function ry(e){if(e.length!==0)return Promise.all(e.map(async e=>(await wa({type:`image`,source:{type:`base64`,media_type:e.mediaType||`image/png`,data:e.content}})).block))}var iy=[`http://`,`https://`,`ftp://`],ay={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},oy=e=>Array.isArray(e)?e:[e];function sy(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 cy(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(`-`)?!sy(t,n):!1}function ly(e,t){for(let n=0;n<e.length;n++){let r=e[n];if(r){if(r.startsWith(`-`)){cy(r,e[n+1],t)&&n++;continue}if(!t?.subcommands?.length||sy(r,t))return r}}}async function uy(e,t,n){let r=await dy(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&&oy(e.args).some(e=>e?.isCommand||e?.isModule)){i.push(c);continue}}if(a&&!o){cy(c,t[s+1],n)&&s++;continue}break}if(await fy(c,t.slice(0,s),n))break;a&&!o&&(o=sy(c,n)),i.push(c)}return i.join(` `)}async function dy(e,t,n){let r=ly(t,n),i=e.toLowerCase(),a=r?`${i} ${r.toLowerCase()}`:i;if(ay[a])return ay[a];if(ay[i])return ay[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&&oy(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=oy(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=oy(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&&oy(n.args).some(e=>e?.isDangerous)?3:2}async function fy(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=iy.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&&oy(e.args).some(e=>e?.isModule))return!1}return!0}var py=[{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 my(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 hy=yl(async e=>py.find(t=>t.name===e)||await my(e)||null,e=>e),gy=/^\d+$/,_y=/^[A-Za-z_][A-Za-z0-9_]*=/,vy=new Set([`nice`]),yy=e=>Array.isArray(e)?e:[e];function by(e,t){return t?.subcommands?.length?t.subcommands.some(t=>Array.isArray(t.name)?t.name.includes(e):t.name===e):!1}async function xy(e,t=0,n=0){if(n>2||t>10)return null;let r=await Gf(e);if(!r)return null;if(!r.commandNode)return{commandPrefix:null};let{envVars:i,commandNode:a}=r,[o,...s]=Kf(a);if(!o)return{commandPrefix:null};let c=await hy(o),l=vy.has(o)||c?.args&&yy(c.args).some(e=>e?.isCommand);l&&s[0]&&by(s[0],c)&&(l=!1);let u=l?await Sy(o,s,t,n):await uy(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 Sy(e,t,n,r){let i=await hy(e);if(i?.args){let a=yy(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 xy(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(`-`)&&!_y.test(t[e])&&i.push(t[e])}}let a=t.find(e=>!e.startsWith(`-`)&&!gy.test(e)&&!_y.test(e));if(!a)return e;let o=await xy(t.slice(t.indexOf(a)).join(` `),n+1,r+1);return o?.commandPrefix?`${e} ${o.commandPrefix}`:null}async function Cy(e,t){let n=$e(e);if(n.length<=1){let t=await xy(e);return t?.commandPrefix?[t.commandPrefix]:[]}let r=[];for(let e of n){let n=e.trim();if(t?.(n))continue;let i=await xy(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(wy(e));return a}function wy(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(` `)}mp(),sm(),Bd();async function Ty(e){X(`tengu_unary_event`,{event:e.event,completion_type:e.completion_type,language_name:await e.metadata.language_name,message_id:e.metadata.message_id,platform:e.metadata.platform,...e.metadata.hasFeedback!==void 0&&{hasFeedback:e.metadata.hasFeedback}})}Bd(),V(),id();function Ey(e,t){let n=yc(),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}})),X(`tengu_tool_use_show_permission_request`,{messageID:e.assistantMessage.message.id,toolName:p(e.tool.name),isMcp:e.tool.isMcp??!1,decisionReasonType:e.permissionResult.decisionReason?.type,sandboxEnabled:ea.isSandboxingEnabled()}),Ty({completion_type:t.completion_type,event:`response`,metadata:{language_name:t.language_name,message_id:e.assistantMessage.message.id,platform:Wu.platform}}))},[e,t,n])}Yc(),l(),J(),V(),Lu(),hh(),tc();function Dy(e){switch(e.type){case`rule`:return`${Kc.bold(Vu(e.rule.ruleValue))} rule from ${rd(e.rule.source)}`;case`mode`:return`${Pu(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`${Kc.bold(e.permissionPromptToolName)} permission prompt tool`;case`hook`:return e.reason?`${Kc.bold(e.hookName)} hook: ${e.reason}`:`${Kc.bold(e.hookName)} hook`;case`asyncAgent`:return e.reason;default:return``}}function Oy({title:e,decisionReason:t}){let[n]=Ec();function r(){switch(t.type){case`subcommandResults`:return(0,$.jsx)(K,{flexDirection:`column`,children:Array.from(t.reasons.entries()).map(([e,t])=>(0,$.jsxs)(K,{flexDirection:`column`,children:[(0,$.jsxs)(q,{children:[t.behavior===`allow`?Qc(`success`,n)(u.tick):Qc(`error`,n)(u.cross),` `,e]}),t.decisionReason!==void 0&&t.decisionReason.type!==`subcommandResults`&&(0,$.jsxs)(q,{children:[(0,$.jsxs)(q,{dimColor:!0,children:[` `,`⎿`,` `]}),(0,$.jsx)(Cc,{children:Dy(t.decisionReason)})]}),t.behavior===`ask`&&(0,$.jsx)(ky,{suggestions:t.suggestions})]},e))});default:return(0,$.jsx)(q,{children:(0,$.jsx)(Cc,{children:Dy(t)})})}}return(0,$.jsxs)(K,{flexDirection:`column`,children:[e&&(0,$.jsx)(q,{children:e}),r()]})}function ky({suggestions:e}){let t=nn(e);return t.length===0?null:(0,$.jsxs)(q,{children:[(0,$.jsxs)(q,{dimColor:!0,children:[` `,`⎿`,` `]}),`Suggested rules: `,(0,$.jsx)(Cc,{children:t.map(e=>Kc.bold(Vu(e))).join(`, `)})]})}function Ay(e){return e?e.flatMap(e=>{switch(e.type){case`addDirectories`:return e.directories;default:return[]}}):[]}function jy(e){if(!e)return;let t=e.findLast(e=>e.type===`setMode`);return t?.type===`setMode`?t.mode:void 0}function My({suggestions:e,width:t}){if(!e||e.length===0)return(0,$.jsxs)(K,{flexDirection:`row`,children:[(0,$.jsx)(K,{justifyContent:`flex-end`,minWidth:t,children:(0,$.jsx)(q,{dimColor:!0,children:`Suggestions `})}),(0,$.jsx)(q,{children:`None`})]});let n=nn(e),r=Ay(e),i=jy(e);return n.length===0&&r.length===0&&!i?(0,$.jsxs)(K,{flexDirection:`row`,children:[(0,$.jsx)(K,{justifyContent:`flex-end`,minWidth:t,children:(0,$.jsx)(q,{dimColor:!0,children:`Suggestion `})}),(0,$.jsx)(q,{children:`None`})]}):(0,$.jsxs)(K,{flexDirection:`column`,children:[(0,$.jsxs)(K,{flexDirection:`row`,children:[(0,$.jsx)(K,{justifyContent:`flex-end`,minWidth:t,children:(0,$.jsx)(q,{dimColor:!0,children:`Suggestions `})}),(0,$.jsx)(q,{children:` `})]}),n.length>0&&(0,$.jsxs)(K,{flexDirection:`row`,children:[(0,$.jsx)(K,{justifyContent:`flex-end`,minWidth:t,children:(0,$.jsx)(q,{dimColor:!0,children:` Rules `})}),(0,$.jsx)(K,{flexDirection:`column`,children:n.map((e,t)=>(0,$.jsxs)(q,{children:[u.bullet,` `,Vu(e)]},t))})]}),r.length>0&&(0,$.jsxs)(K,{flexDirection:`row`,children:[(0,$.jsx)(K,{justifyContent:`flex-end`,minWidth:t,children:(0,$.jsx)(q,{dimColor:!0,children:` Directories `})}),(0,$.jsx)(K,{flexDirection:`column`,children:r.map((e,t)=>(0,$.jsxs)(q,{children:[u.bullet,` `,e]},t))})]}),i&&(0,$.jsxs)(K,{flexDirection:`row`,children:[(0,$.jsx)(K,{justifyContent:`flex-end`,minWidth:t,children:(0,$.jsx)(q,{dimColor:!0,children:` Mode `})}),(0,$.jsx)(q,{children:Pu(i)})]})]})}function Ny({permissionResult:e,toolName:t}){let n=H(e=>e.toolPermissionContext),r=e.decisionReason,i=`suggestions`in e?e.suggestions:void 0,a=(0,Q.useMemo)(()=>{let e=ea.isSandboxingEnabled()&&ea.isAutoAllowBashIfSandboxedEnabled(),r=gh(n,{sandboxAutoAllowEnabled:e}),a=nn(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)(K,{flexDirection:`column`,children:[(0,$.jsxs)(K,{flexDirection:`row`,children:[(0,$.jsx)(K,{justifyContent:`flex-end`,minWidth:10,children:(0,$.jsx)(q,{dimColor:!0,children:`Behavior `})}),(0,$.jsx)(q,{children:e.behavior})]}),e.behavior!==`allow`&&(0,$.jsxs)(K,{flexDirection:`row`,children:[(0,$.jsx)(K,{justifyContent:`flex-end`,minWidth:10,children:(0,$.jsx)(q,{dimColor:!0,children:`Message `})}),(0,$.jsx)(q,{children:e.message})]}),(0,$.jsxs)(K,{flexDirection:`row`,children:[(0,$.jsx)(K,{justifyContent:`flex-end`,minWidth:10,children:(0,$.jsx)(q,{dimColor:!0,children:`Reason `})}),r===void 0?(0,$.jsx)(q,{children:`undefined`}):(0,$.jsx)(Oy,{decisionReason:r})]}),(0,$.jsx)(My,{suggestions:i,width:10}),a.length>0&&(0,$.jsxs)(K,{flexDirection:`column`,marginTop:1,children:[(0,$.jsxs)(q,{color:`warning`,children:[u.warning,` Unreachable Rules (`,a.length,`)`]}),a.map((e,t)=>(0,$.jsxs)(K,{flexDirection:`column`,marginLeft:2,children:[(0,$.jsx)(q,{color:`warning`,children:Vu(e.rule.ruleValue)}),(0,$.jsxs)(q,{dimColor:!0,children:[` `,e.reason]}),(0,$.jsxs)(q,{dimColor:!0,children:[` `,`Fix: `,e.fix]})]},t))]})]})}wh(),El(),Bd(),f(),hd(),Cu(),Cl(),Td(),$f(),wt();var Py={LOW:1,MEDIUM:2,HIGH:3},Fy=1,Iy=2,Ly=3,Ry=`Analyze shell commands and explain what they do, why you're running them, and potential risks.`,zy={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`]}},By=wl(()=>ml({riskLevel:fl([`LOW`,`MEDIUM`,`HIGH`]),explanation:vl(),reasoning:vl(),risk:vl()}));function Vy(e){if(typeof e==`string`)return e;try{return du(e,null,2)}catch{return String(e)}}function Hy(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 Uy(){return gd().permissionExplainerEnabled!==!1}async function Wy({toolName:e,toolInput:t,toolDescription:n,messages:r,signal:i}){if(!Uy())return null;let a=Date.now();try{let o=Vy(t),s=r?.length?Hy(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 It({model:Qf()?gf():yf(),system:Ry,messages:[{role:`user`,content:c}],tools:[zy],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: ${du(d.input).slice(0,500)}`);let t=By().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 X(`tengu_permission_explainer_generated`,{tool_name:p(e),risk_level:Py[n.riskLevel],latency_ms:u}),Y(`Permission explainer: ${n.riskLevel} risk for ${e} (${u}ms)`),n}}return X(`tengu_permission_explainer_error`,{tool_name:p(e),error_type:Fy,latency_ms:u}),Y(`Permission explainer: no parsed output in response`),null}catch(t){let n=Date.now()-a;return i.aborted?(Y(`Permission explainer: request aborted for ${e}`),null):(Y(`Permission explainer error: ${hu(t)}`),Dd(t),X(`tengu_permission_explainer_error`,{tool_name:p(e),error_type:t instanceof Error&&t.name===`AbortError`?Iy:Ly,latency_ms:n}),null)}}J(),fo(),Bd();var Gy=`Loading explanation…`;function Ky(){let[e,t]=rm(`responding`,Gy,!1);return(0,$.jsx)(K,{ref:e,children:(0,$.jsx)(q,{children:Gy.split(``).map((e,n)=>(0,$.jsx)(op,{char:e,index:n,glimmerIndex:t,messageColor:`inactive`,shimmerColor:`text`},n))})})}function qy(e){switch(e){case`LOW`:return`success`;case`MEDIUM`:return`warning`;case`HIGH`:return`error`}}function Jy(e){switch(e){case`LOW`:return`Low risk`;case`MEDIUM`:return`Med risk`;case`HIGH`:return`High risk`}}function Yy(e){return Wy({toolName:e.toolName,toolInput:e.toolInput,toolDescription:e.toolDescription,messages:e.messages,signal:new AbortController().signal}).catch(()=>null)}function Xy(e){let t=Uy(),[n,r]=(0,Q.useState)(!1),[i,a]=(0,Q.useState)(null);return Fc(`confirm:toggleExplanation`,()=>{n||(X(`tengu_permission_explainer_shortcut_used`,{}),i||a(Yy(e))),r(e=>!e)},{context:`Confirmation`,isActive:t}),{visible:n,enabled:t,promise:i}}function Zy({promise:e}){let t=(0,Q.use)(e);return t?(0,$.jsxs)(K,{flexDirection:`column`,marginTop:1,children:[(0,$.jsx)(q,{children:t.explanation}),(0,$.jsx)(K,{marginTop:1,children:(0,$.jsx)(q,{children:t.reasoning})}),(0,$.jsx)(K,{marginTop:1,children:(0,$.jsxs)(q,{children:[(0,$.jsxs)(q,{color:qy(t.riskLevel),children:[Jy(t.riskLevel),`:`]}),(0,$.jsxs)(q,{children:[` `,t.risk]})]})})]}):(0,$.jsx)(K,{marginTop:1,children:(0,$.jsx)(q,{dimColor:!0,children:`Explanation unavailable`})})}function Qy({visible:e,promise:t}){return!e||!t?null:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(K,{marginTop:1,children:(0,$.jsx)(Ky,{})}),children:(0,$.jsx)(Zy,{promise:t})})}gi(),J(),Td(),Zi(),ti();function $y(e){let[t]=(0,Q.useState)(()=>nb(e.file_path,e.edits));return(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(tb,{placeholder:!0}),children:(0,$.jsx)(eb,{promise:t,file_path:e.file_path})})}function eb({promise:e,file_path:t}){let{patch:n,firstLine:r,fileContent:i}=(0,Q.use)(e),{columns:a}=tl();return(0,$.jsx)(tb,{children:(0,$.jsx)(oa,{hunks:n,dim:!1,width:a,filePath:t,firstLine:r,fileContent:i})})}function tb({children:e,placeholder:t}){return(0,$.jsx)(K,{flexDirection:`column`,children:(0,$.jsx)(K,{borderColor:`subtle`,borderStyle:`dashed`,flexDirection:`column`,borderLeft:!1,borderRight:!1,children:t?(0,$.jsx)(q,{dimColor:!0,children:`…`}):e})})}async function nb(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 rb(e,[r]);try{let t=await Ho(e);if(t===null)return rb(e,n);try{if(!r||r.old_string===``){let r=await yo(t);return r===null?rb(e,n):{patch:y({filePath:e,fileContents:r,edits:n.map(e=>ib(r,e))}),firstLine:kd(r),fileContent:r}}let i=await pa(t,r.old_string,3);if(i.truncated||i.content===``)return rb(e,[r]);let a=ib(i.content,r);return{patch:yn(y({filePath:e,fileContents:i.content,edits:[a]}),i.lineOffset-1),firstLine:i.lineOffset===1?kd(i.content):null,fileContent:i.content}}finally{await t.close()}}catch(t){return Dd(t),rb(e,n)}}function rb(e,t){return{patch:t.flatMap(t=>y({filePath:e,fileContents:t.old_string,edits:[t]})),firstLine:null,fileContent:void 0}}function ib(e,t){let n=nt(e,t.old_string)||t.old_string;return{...t,old_string:n}}lc(),Bd(),Hr(),hd(),ms(),mu(),cn(),Td();function ab({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)(()=>yg().slice(0,6),[]),l=(0,Q.useMemo)(()=>`✻ [Work Mate] ${ug(n)} (${c}) ⧉`,[n,c]),u=Lt(t.options.mcpClients)&&gd().diffTool===`auto`&&!n.endsWith(`.ipynb`),d=Ta(t.options.mcpClients)??`IDE`;async function f(){if(u)try{X(`tengu_ext_will_show_diff`,{});let{oldContent:o,newContent:s}=await sb(n,r,t,l);if(a.current)return;X(`tengu_ext_diff_accepted`,{});let c=ob(n,o,s,i);if(c.length===0){X(`tengu_ext_diff_rejected`,{});let i=E(t.options.mcpClients);i&&await cb(l,i),e({type:`reject`},{file_path:n,edits:r});return}e({type:`accept-once`},{file_path:n,edits:c})}catch(e){Dd(e),s(!0)}}return(0,Q.useEffect)(()=>(f(),()=>{a.current=!0}),[]),{closeTabInIDE(){let e=E(t.options.mcpClients);return e?cb(l,e):Promise.resolve()},showingDiffInIDE:u&&!o,ideName:d,hasError:o}}function ob(e,t,n,r){let i=r===`single`,a=Li({filePath:e,oldContent:t,newContent:n,singleHunk:i});return a.length===0?[]:(i&&a.length>1&&Dd(Error(`Unexpected number of hunks: ${a.length}. Expected 1 hunk.`)),Mr(a))}async function sb(e,t,n,r){let i=!1,a=Xu(e),o=``;try{o=dd(a)}catch(e){if(!gu(e))throw e}async function s(){if(!i){i=!0;try{await cb(r,c)}catch(e){Dd(e)}process.off(`beforeExit`,s),n.abortController.signal.removeEventListener(`abort`,s)}}n.abortController.signal.addEventListener(`abort`,s),process.on(`beforeExit`,s);let c=E(n.options.mcpClients);try{let{updatedFile:e}=Cr({filePath:a,fileContents:o,edits:t});if(c?.type!==`connected`)throw Error(`IDE client not available`);let n=a,i=c.config.ideRunningInWindows===!0;Rd()===`wsl`&&i&&process.env.WSL_DISTRO_NAME&&(n=new Ue(process.env.WSL_DISTRO_NAME).toIDEPath(a));let l=await Fe(`openDiff`,{old_file_path:n,new_file_path:n,new_file_contents:e,tab_name:r},c),u=Array.isArray(l)?l:[l];if(db(u))return s(),{oldContent:o,newContent:u[1].text};if(lb(u))return s(),{oldContent:o,newContent:e};if(ub(u))return s(),{oldContent:o,newContent:o};throw Error(`Not accepted`)}catch(e){throw Dd(e),s(),e}}async function cb(e,t){try{if(t?.type!==`connected`)throw Error(`IDE client not available`);await Fe(`close_tab`,{tab_name:e},t)}catch(e){Dd(e)}}function lb(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 ub(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 db(e){return Array.isArray(e)&&e[0]?.type===`text`&&e[0].text===`FILE_SAVED`&&typeof e[1].text==`string`}J(),cn(),ih();function fb({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)(sl,{color:`permission`,children:(0,$.jsxs)(K,{flexDirection:`column`,gap:1,children:[(0,$.jsxs)(q,{bold:!0,color:`permission`,children:[`Opened changes in `,i,` ⧉`]}),a&&(0,$.jsx)(q,{color:`warning`,children:mg(lu(),a).startsWith(`..`)?`This will modify ${a} (outside working directory) via a symlink`:`Symlink target: ${a}`}),kn()&&(0,$.jsx)(q,{dimColor:!0,children:`Save file to continue…`}),(0,$.jsxs)(K,{flexDirection:`column`,children:[(0,$.jsxs)(q,{children:[`Do you want to make this edit to `,(0,$.jsx)(q,{bold:!0,children:ug(r)}),`?`]}),(0,$.jsx)(nm,{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)(K,{marginTop:1,children:(0,$.jsxs)(q,{dimColor:!0,children:[`Esc to cancel`,(u===`yes`&&!d||u===`no`&&!f)&&` · Tab to amend`]})})]})})}Pl(),J(),nd();function pb(e){let t=Xu(e),n=Xu(`${Fl()}/.workmate`),r=mn(t),i=mn(n);return r.startsWith(i+hg.toLowerCase())||r.startsWith(`${i}/`)}function mb(e){let t=Xu(e),n=pg(sg(),`.workmate`),r=mn(t),i=mn(n);return r.startsWith(i+hg.toLowerCase())||r.startsWith(`${i}/`)}function hb({filePath:e,toolPermissionContext:t,operationType:n=`write`,onRejectFeedbackChange:r,onAcceptFeedbackChange:i,yesInputMode:a=!1,noInputMode:o=!1}){let s=[],c=Ms(`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=Ne(e,t),u=pb(e),d=mb(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)(q,{children:[`Yes, allow all edits during this session `,(0,$.jsxs)(q,{bold:!0,children:[`(`,c,`)`]})]});else{let r=ug(cd(e))||`this directory`;t=n===`read`?(0,$.jsxs)(q,{children:[`Yes, allow reading from `,(0,$.jsxs)(q,{bold:!0,children:[r,`/`]}),` during this session`]}):(0,$.jsxs)(q,{children:[`Yes, allow all edits in `,(0,$.jsxs)(q,{bold:!0,children:[r,`/`]}),` during this session`,` `,(0,$.jsxs)(q,{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}Bd(),f(),id(),Nt();function gb(e,t,n,r,i){Ty({completion_type:t,event:e,metadata:{language_name:n,message_id:r,platform:Wu.platform,hasFeedback:i??!1}})}function _b(e,t){let{messageId:n,toolUseConfirm:r,onDone:i,completionType:a,languageName:o}=e;gb(`accept`,a,o,n),X(`tengu_accept_submitted`,{toolName:p(r.tool.name),isMcp:r.tool.isMcp??!1,has_instructions:!!t?.feedback,instructions_length:t?.feedback?.length??0,entered_feedback_mode:t?.enteredFeedbackMode??!1}),i(),r.onAllow(r.input,[],t?.feedback)}function vb(e,t){let{messageId:n,path:r,toolUseConfirm:i,toolPermissionContext:a,onDone:o,completionType:s,languageName:c,operationType:l}=e;if(gb(`accept`,s,c,n),t?.scope===`claude-folder`||t?.scope===`global-claude-folder`){let e=[{type:`addRules`,rules:[{toolName:Nf,ruleContent:t.scope===`global-claude-folder`?Ef:Of}],behavior:`allow`,destination:`session`}];o(),i.onAllow(i.input,e);return}let u=r?Xa(r,l,a):[];o(),i.onAllow(i.input,u)}function yb(e,t){let{messageId:n,toolUseConfirm:r,onDone:i,onReject:a,completionType:o,languageName:s}=e;gb(`reject`,o,s,n,t?.hasFeedback),X(`tengu_reject_submitted`,{toolName:p(r.tool.name),isMcp:r.tool.isMcp??!1,has_instructions:!!t?.feedback,instructions_length:t?.feedback?.length??0,entered_feedback_mode:t?.enteredFeedbackMode??!1}),i(),a(),r.onReject(t?.feedback)}var bb={"accept-once":_b,"accept-session":vb,reject:yb};V(),fo(),Bd(),f();function xb({filePath:e,completionType:t,languageName:n,toolUseConfirm:r,onDone:i,onReject:a,parseInput:o,operationType:s=`write`}){let c=H(e=>e.toolPermissionContext),[l,u]=(0,Q.useState)(``),[d,f]=(0,Q.useState)(``),[m,h]=(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)(()=>hb({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=bb[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 Tc({"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:m,setFocusedOption:(0,Q.useCallback)(e=>{e!==`yes`&&g&&!l.trim()&&_(!1),e!==`no`&&v&&!d.trim()&&y(!1),h(e)},[g,v,l,d]),handleInputModeToggle:(0,Q.useCallback)(e=>{let t={toolName:p(r.tool.name),isMcp:r.tool.isMcp??!1};e===`yes`?g?(_(!1),X(`tengu_accept_feedback_mode_collapsed`,t)):(_(!0),x(!0),X(`tengu_accept_feedback_mode_entered`,t)):e===`no`&&(v?(y(!1),X(`tengu_reject_feedback_mode_collapsed`,t)):(y(!0),C(!0),X(`tengu_reject_feedback_mode_entered`,t)))},[g,v,r]),yesInputMode:g,noInputMode:v}}J(),me(),cu(),nd(),ih();function Sb({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?we(l):`none`),[p,l]);Ey(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=Xu(l),{resolvedPath:t,isSymlink:n}=Su(wu(),e);return n?t:null},[l,d]),g=xb({filePath:l||``,completionType:c,languageName:m,toolUseConfirm:e,onDone:n,onReject:r,parseInput:u,operationType:d}),{options:_,acceptFeedback:v,rejectFeedback:y,setFocusedOption:b,handleInputModeToggle:x,focusedOption:S,yesInputMode:C,noInputMode:w}=g,T=u(e.input),E=(0,Q.useMemo)(()=>f?f.getConfig(u(e.input)):null,[f,e.input]),{closeTabInIDE:D,showingDiffInIDE:O,ideName:k}=ab(E?{onChange:(e,t)=>{let n=f.applyChanges(T,t.edits);g.onChange(e,n)},toolUseContext:t,filePath:E.filePath,edits:(E.edits||[]).map(e=>({old_string:e.old_string,new_string:e.new_string,replace_all:e.replace_all||!1})),editMode:E.editMode||`single`}:{onChange:()=>{},toolUseContext:t,filePath:``,edits:[],editMode:`single`}),A=(e,t)=>{D?.(),g.onChange(e,T,t?.trim())};if(O&&E&&l)return(0,$.jsx)(fb,{onChange:(e,t,n)=>A(e,n),options:_,filePath:l,input:T,ideName:k,symlinkTarget:h,rejectFeedback:y,acceptFeedback:v,setFocusedOption:b,onInputModeToggle:x,focusedOption:S,yesInputMode:C,noInputMode:w});let j=h!=null&&mg(lu(),h).startsWith(`..`);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(Eh,{title:i,subtitle:a,innerPaddingX:0,children:[h?(0,$.jsx)(K,{paddingX:1,marginBottom:1,children:(0,$.jsx)(q,{color:`warning`,children:j?`This will modify ${h} (outside working directory) via a symlink`:`Symlink target: ${h}`})}):null,s,(0,$.jsxs)(K,{flexDirection:`column`,paddingX:1,children:[typeof o==`string`?(0,$.jsx)(q,{children:o}):o,(0,$.jsx)(nm,{options:_,inlineDescriptions:!0,onChange:e=>{let t=_.find(t=>t.value===e);if(t){if(t.option.type===`reject`){let e=y.trim();A(t.option,e||void 0);return}if(t.option.type===`accept-once`){let e=v.trim();A(t.option,e||void 0);return}A(t.option)}},onCancel:()=>A({type:`reject`}),onFocus:e=>b(e),onInputModeToggle:x})]})]}),(0,$.jsx)(K,{paddingX:1,marginTop:1,children:(0,$.jsxs)(q,{dimColor:!0,children:[`Esc to reject`,(S===`yes`&&!C||S===`no`&&!w)&&` · Tab to add feedback`]})})]})}cu(),mu(),Ru(),xu(),J();function Cb({sedInfo:e,...t}){let{filePath:n}=e;return(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(wb,{sedInfo:e,contentPromise:(0,Q.useMemo)(()=>(async()=>{let e=Mu(n);return{oldContent:(await wu().readFile(n,{encoding:e})).replaceAll(`\r
|
|
22
|
+
`,`
|
|
23
|
+
`),fileExists:!0}})().catch(e=>{if(!gu(e))throw e;return{oldContent:``,fileExists:!1}}),[n]),...t})})}function wb({sedInfo:e,contentPromise:t,...n}){let{filePath:r}=e,{oldContent:i,fileExists:a}=(0,Q.use)(t),o=(0,Q.useMemo)(()=>un(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)(Sb,{toolUseConfirm:n.toolUseConfirm,toolUseContext:n.toolUseContext,onDone:n.onDone,onReject:n.onReject,title:`Edit file`,subtitle:mg(lu(),r),question:(0,$.jsxs)(q,{children:[`Do you want to make this edit to `,(0,$.jsx)(q,{bold:!0,children:ug(r)}),`?`]}),content:s.length>0?(0,$.jsx)($y,{file_path:r,edits:s}):(0,$.jsx)(q,{dimColor:!0,children:c}),path:r,completionType:`str_replace_single`,parseInput:e=>({...$t.inputSchema.parse(e),_simulatedSedEdit:{filePath:r,newContent:o}})})}id();function Tb(e,{assistantMessage:{message:{id:t}}},n,r){Ty({completion_type:e,event:n,metadata:{language_name:`none`,message_id:t,platform:Ou(),hasFeedback:r??!1}})}Bd(),f(),V();function Eb({toolUseConfirm:e,onDone:t,onReject:n,explainerVisible:r}){let i=yc(),[a,o]=(0,Q.useState)(``),[s,c]=(0,Q.useState)(``),[l,u]=(0,Q.useState)(!1),[d,f]=(0,Q.useState)(!1),[m,h]=(0,Q.useState)(`yes`),[g,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(!1);function b(t){e.onUserInteraction();let n={toolName:p(e.tool.name),isMcp:e.tool.isMcp??!1};t===`yes`?l?(u(!1),X(`tengu_accept_feedback_mode_collapsed`,n)):(u(!0),_(!0),X(`tengu_accept_feedback_mode_entered`,n)):t===`no`&&(d?(f(!1),X(`tengu_reject_feedback_mode_collapsed`,n)):(f(!0),y(!0),X(`tengu_reject_feedback_mode_entered`,n)))}function x(a){let o=a?.trim(),s=!!o;s||(X(`tengu_permission_request_escape`,{explainer_visible:r}),i(e=>({...e,attribution:{...e.attribution,escapeCount:e.attribution.escapeCount+1}}))),Tb(`tool_use_single`,e,`reject`,s),o?e.onReject(o):e.onReject(),n(),t()}function S(t){t!==m&&e.onUserInteraction(),t!==`yes`&&l&&!s.trim()&&u(!1),t!==`no`&&d&&!a.trim()&&f(!1),h(t)}return{yesInputMode:l,noInputMode:d,yesFeedbackModeEntered:g,noFeedbackModeEntered:v,acceptFeedback:s,rejectFeedback:a,setAcceptFeedback:c,setRejectFeedback:o,focusedOption:m,handleInputModeToggle:b,handleReject:x,handleFocus:S}}Pl(),J();function Db(e){switch(e.length){case 0:return``;case 1:return(0,$.jsx)(q,{bold:!0,children:e[0]});case 2:return(0,$.jsxs)(q,{children:[(0,$.jsx)(q,{bold:!0,children:e[0]}),` and `,(0,$.jsx)(q,{bold:!0,children:e[1]})]});default:return(0,$.jsxs)(q,{children:[(0,$.jsx)(q,{bold:!0,children:e.slice(0,-1).join(`, `)}),`, and `,(0,$.jsx)(q,{bold:!0,children:e.slice(-1)[0]})]})}}function Ob(e){return e.join(`, `).length>50?`similar`:Db(e)}function kb(e){if(e.length===0)return``;let t=e.map(e=>ug(e)||e);return t.length===1?(0,$.jsxs)(q,{children:[(0,$.jsx)(q,{bold:!0,children:t[0]}),hg]}):t.length===2?(0,$.jsxs)(q,{children:[(0,$.jsx)(q,{bold:!0,children:t[0]}),hg,` and `,(0,$.jsx)(q,{bold:!0,children:t[1]}),hg]}):(0,$.jsxs)(q,{children:[(0,$.jsx)(q,{bold:!0,children:t[0]}),hg,`, `,(0,$.jsx)(q,{bold:!0,children:t[1]}),hg,` and `,e.length-2,` more`]})}function Ab(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=ae(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)(q,{children:[`Yes, allow reading from `,(0,$.jsx)(q,{bold:!0,children:ug(e)||e}),hg,` from this project`]})}return(0,$.jsxs)(q,{children:[`Yes, allow reading from `,kb(s),` from this project`]})}if(l&&!u&&!d){if(o.length===1){let e=o[0];return(0,$.jsxs)(q,{children:[`Yes, and always allow access to `,(0,$.jsx)(q,{bold:!0,children:ug(e)||e}),hg,` from this project`]})}return(0,$.jsxs)(q,{children:[`Yes, and always allow access to `,kb(o),` from this project`]})}if(d&&!l&&!u)return(0,$.jsxs)(q,{children:[`Yes, and don't ask again for `,Ob(c),` commands in `,(0,$.jsx)(q,{bold:!0,children:Fl()})]});if((l||u)&&!d){let e=[...o,...s];if(l&&u)return(0,$.jsxs)(q,{children:[`Yes, and always allow access to `,kb(e),` from this project`]})}if((l||u)&&d){let e=[...o,...s];return e.length===1&&c.length===1?(0,$.jsxs)(q,{children:[`Yes, and allow access to `,kb(e),` and `,Ob(c),` commands`]}):(0,$.jsxs)(q,{children:[`Yes, and allow `,kb(e),` access and `,Ob(c),` commands`]})}return null}Ko();function jb(e){let{commandWithoutRedirections:t,redirections:n}=ot(e);return n.length>0?t:e}function Mb({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`}),Me()){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=Ab(e,Af,jb);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}J(),fo(),Bd(),f(),V(),Ka(),Ae(),Ya(),tc(),mp(),sm(),wh();function Nb(e){let{toolUseConfirm:t,toolUseContext:n,onDone:r,onReject:i,verbose:a}=e,{command:o,description:s}=$t.inputSchema.parse(t.input),c=Ye(o);return c?(0,$.jsx)(Cb,{toolUseConfirm:t,toolUseContext:n,onDone:r,onReject:i,verbose:a,sedInfo:c}):(0,$.jsx)(Pb,{toolUseConfirm:t,toolUseContext:n,onDone:r,onReject:i,verbose:a,command:o,description:s})}function Pb({toolUseConfirm:e,toolUseContext:t,onDone:n,onReject:r,verbose:i,command:a,description:o}){let[s]=Ec(),c=H(e=>e.toolPermissionContext),l=Xy({toolName:e.tool.name,toolInput:e.input,toolDescription:e.description,messages:t.messages}),{yesInputMode:u,noInputMode:d,yesFeedbackModeEntered:f,noFeedbackModeEntered:m,acceptFeedback:h,rejectFeedback:g,setAcceptFeedback:_,setRejectFeedback:v,focusedOption:y,handleInputModeToggle:b,handleReject:x,handleFocus:S}=Eb({toolUseConfirm:e,onDone:n,onReject:r,explainerVisible:l.visible}),[C,w]=(0,Q.useState)(!1),[T,E]=(0,Q.useState)(o||``),[D,O]=(0,Q.useState)(!o?.trim());(0,Q.useEffect)(()=>{if(!dr())return;let e=new AbortController;return Nn(a,o,e.signal).then(t=>{t&&!e.signal.aborted&&(E(t),O(!1))}).catch(()=>{}),()=>e.abort()},[a,o]);let k=e.permissionResult.decisionReason?.type===`subcommandResults`,[A,j]=(0,Q.useState)(()=>{if(k){let t=nn(`suggestions`in e.permissionResult?e.permissionResult.suggestions:void 0).filter(e=>e.toolName===$t.name&&e.ruleContent);return t.length===1?t[0].ruleContent:void 0}let t=xe(a);if(t)return`${t}:*`;let n=Xn(a);return n?`${n}:*`:a}),M=(0,Q.useRef)(!1),ee=(0,Q.useCallback)(e=>{M.current=!0,j(e)},[]);(0,Q.useEffect)(()=>{if(k)return;let e=!1;return Cy(a,e=>$t.isReadOnly({command:e})).then(t=>{e||M.current||t.length>0&&j(`${t[0]}:*`)}).catch(()=>{}),()=>{e=!0}},[a,k]);let[te]=(0,Q.useState)(!1),{destructiveWarning:N,sandboxingEnabled:P,isSandboxed:ne}=(0,Q.useMemo)(()=>{let t=ea.isSandboxingEnabled();return{destructiveWarning:null,sandboxingEnabled:t,isSandboxed:t&&mr(e.input)}},[a,e.input]);Ey(e,(0,Q.useMemo)(()=>({completion_type:`tool_use_single`,language_name:`none`}),[]));let F=(0,Q.useMemo)(()=>vc(c),[c]),I=(0,Q.useMemo)(()=>Mb({suggestions:e.permissionResult.behavior===`ask`?e.permissionResult.suggestions:void 0,decisionReason:e.permissionResult.decisionReason,onRejectFeedbackChange:v,onAcceptFeedbackChange:_,onClassifierDescriptionChange:E,classifierDescription:T,initialClassifierDescriptionEmpty:D,existingAllowDescriptions:F,yesInputMode:u,noInputMode:d,editablePrefix:A,onEditablePrefixChange:ee}),[e,T,D,F,u,d,A,ee]);Fc(`permission:toggleDebug`,(0,Q.useCallback)(()=>{w(e=>!e)},[]),{context:`Confirmation`}),Fc(`confirm:no`,(0,Q.useCallback)(()=>{e.onDismissCheckmark?.()},[e]),{context:`Confirmation`,isActive:!1});function re(t){X(`tengu_permission_request_option_selected`,{option_index:{yes:1,"yes-apply-suggestions":2,"yes-prefix-edited":2,no:3}[t],explainer_visible:l.visible});let r=p(e.tool.name);if(t===`yes-prefix-edited`){let t=(A??``).trim();if(Tb(`tool_use_single`,e,`accept`),!t)e.onAllow(e.input,[]);else{let n=[{type:`addRules`,rules:[{toolName:$t.name,ruleContent:t}],behavior:`allow`,destination:`localSettings`}];e.onAllow(e.input,n)}n();return}switch(t){case`yes`:{let t=h.trim();Tb(`tool_use_single`,e,`accept`),X(`tengu_accept_submitted`,{toolName:r,isMcp:e.tool.isMcp??!1,has_instructions:!!t,instructions_length:t.length,entered_feedback_mode:f}),e.onAllow(e.input,[],t||void 0),n();break}case`yes-apply-suggestions`:{Tb(`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=g.trim();X(`tengu_reject_submitted`,{toolName:r,isMcp:e.tool.isMcp??!1,has_instructions:!!t,instructions_length:t.length,entered_feedback_mode:m}),x(t||void 0);break}}}return(0,$.jsxs)(Eh,{title:P&&!ne?`Bash command (unsandboxed)`:`Bash command`,subtitle:void 0,children:[(0,$.jsxs)(K,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsx)(q,{dimColor:l.visible,children:$t.renderToolUseMessage({command:a,description:o},{theme:s,verbose:!0})}),!l.visible&&(0,$.jsx)(q,{dimColor:!0,children:e.description}),(0,$.jsx)(Qy,{visible:l.visible,promise:l.promise})]}),C?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ny,{permissionResult:e.permissionResult,toolName:`Bash`}),t.options.debug&&(0,$.jsx)(K,{justifyContent:`flex-end`,marginTop:1,children:(0,$.jsx)(q,{dimColor:!0,children:`Ctrl-D to hide debug info`})})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(K,{flexDirection:`column`,children:[(0,$.jsx)(Kv,{permissionResult:e.permissionResult,toolType:`command`}),N&&(0,$.jsx)(K,{marginBottom:1,children:(0,$.jsx)(q,{color:`warning`,dimColor:!1,children:N})}),(0,$.jsx)(q,{dimColor:!1,children:`Do you want to proceed?`}),(0,$.jsx)(nm,{options:I,isDisabled:!1,inlineDescriptions:!0,onChange:re,onCancel:()=>x(),onFocus:S,onInputModeToggle:b})]}),(0,$.jsxs)(K,{justifyContent:`space-between`,marginTop:1,children:[(0,$.jsxs)(q,{dimColor:!0,children:[`Esc to reject`,(y===`yes`&&!u||y===`no`&&!d)&&` · Tab to add feedback`,l.enabled&&` · ctrl+e to ${l.visible?`hide`:`explain`}`]}),t.options.debug&&(0,$.jsx)(q,{dimColor:!0,children:`Ctrl+d to show debug info`})]})]})]})}Pl(),J(),Bd(),V(),$r(),ih(),wh();function Fb({toolUseConfirm:e,onDone:t,onReject:n}){let r=H(e=>e.toolPermissionContext.mode);function i(i){i===`yes`?(X(`tengu_plan_enter`,{interviewPhaseEnabled:Ps(),entryMethod:`tool`}),Zl(r,`plan`),t(),e.onAllow({},[{type:`setMode`,mode:`plan`,destination:`session`}])):(t(),n(),e.onReject())}return(0,$.jsx)(Eh,{color:`planMode`,title:`Enter plan mode?`,children:(0,$.jsxs)(K,{flexDirection:`column`,marginTop:1,paddingX:1,children:[(0,$.jsx)(q,{children:`Work Mate wants to enter plan mode to explore and design an implementation approach.`}),(0,$.jsxs)(K,{marginTop:1,flexDirection:`column`,children:[(0,$.jsx)(q,{dimColor:!0,children:`In plan mode, Work Mate will:`}),(0,$.jsx)(q,{dimColor:!0,children:` · Explore the codebase thoroughly`}),(0,$.jsx)(q,{dimColor:!0,children:` · Identify existing patterns`}),(0,$.jsx)(q,{dimColor:!0,children:` · Design an implementation strategy`}),(0,$.jsx)(q,{dimColor:!0,children:` · Present a plan for your approval`})]}),(0,$.jsx)(K,{marginTop:1,children:(0,$.jsx)(q,{dimColor:!0,children:`No code changes will be made until you approve the plan.`})}),(0,$.jsx)(K,{marginTop:1,children:(0,$.jsx)(nm,{options:[{label:`Yes, enter plan mode`,value:`yes`},{label:`No, start implementing now`,value:`no`}],onChange:i,onCancel:()=>i(`no`)})})]})})}l(),Bd(),V(),Pl(),Ph(),J(),Rm(),cn(),Td(),ff(),F(),Qu(),$r(),M(),Hm(),ni(),ih(),wh(),os(),Ct();function Ib(e,t){let n=[{type:`setMode`,mode:zu(e),destination:`session`}];return dr()&&t&&t.length>0&&n.push({type:`addRules`,rules:t.map(e=>({toolName:e.tool,ruleContent:bt(e.prompt)})),behavior:`allow`,destination:`session`}),n}function Lb(e,t,n){Bl()||Yu()?.cleanupPeriodDays===0||!n&&bs(nu())||Fh([Lo({content:e.slice(0,1e3)})],new AbortController().signal).then(async e=>{if(!e||bs(nu()))return;let n=nu(),r=Uo();await vs(n,e,r,`auto`),await Tn(n,e,r,`auto`),t(t=>t.standaloneAgentContext?.name===e?t:{...t,standaloneAgentContext:{...t.standaloneAgentContext,name:e}})}).catch(Dd)}function Rb({toolUseConfirm:e,onDone:t,onReject:n,setStickyFooter:r}){let i=H(e=>e.toolPermissionContext),a=yc();Pn();let{addNotification:o}=xp(),[s,c]=(0,Q.useState)(``),[l,d]=(0,Q.useState)({}),f=(0,Q.useRef)(0),p=H(e=>e.settings.showClearContextOnPlanAccept)??!1,m=e.assistantMessage.message.usage,{mode:h,isAutoModeAvailable:g,isBypassPermissionsModeAvailable:_}=i,v=(0,Q.useMemo)(()=>zb({showClearContext:p,usedPercent:p?Bb(m,h):null,isAutoModeAvailable:g,isBypassPermissionsModeAvailable:_,onFeedbackChange:c}),[p,m,h,g,_]);function y(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};Kt(o),G(o),d(e=>({...e,[a]:o}))}let b=(0,Q.useCallback)(e=>{d(t=>{let n={...t};return delete n[e],n})},[]),x=Object.values(l).filter(e=>e.type===`image`),S=x.length>0,C=he(),w=e.input.allowedPrompts,T=Te(),E=!T||T.trim()===``,[D]=(0,Q.useState)(()=>ia()??void 0),[O,k]=(0,Q.useState)(()=>Te()??`No plan found. Please write your plan to the plan file first.`),[A,j]=(0,Q.useState)(!1),[M,ee]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{if(A){let e=setTimeout(j,5e3,!1);return()=>clearTimeout(e)}},[A]);let te=e=>{if(e.ctrl&&e.key===`g`){e.preventDefault(),X(`tengu_plan_external_editor_used`,{}),(async()=>{let e=await Um(C);e.error&&o({key:`external-editor-error`,text:e.error,color:`warning`,priority:`high`}),e.content!==null&&(e.content!==O&&ee(!0),k(e.content),j(!0))})();return}if(e.shift&&e.key===`tab`){e.preventDefault(),N(p?`yes-accept-edits`:`yes-accept-edits-keep-context`);return}};async function N(r){let o=s.trim(),c=o||void 0,l=M?{plan:O}:{};{let e=(r===`yes-resume-auto-mode`||r===`yes-auto-clear-context`)&&L(),t=P();r!==`no`&&!e&&t&&(lr(!1),Gl(!0),a(e=>({...e,toolPermissionContext:{...Jt(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`&&Lb(O,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`&&L()&&(i=`auto`,lr(!0)),X(`tengu_plan_exit`,{planLengthChars:O.length,outcome:r,clearContext:!0,interviewPhaseEnabled:Ps(),planStructureVariant:D,hasFeedback:!!c});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: ${Uo()}`,s=c?`\n\nUser feedback on this plan: ${c}`:``;a(e=>({...e,initialMessage:{message:{...Lo({content:`Implement the following plan:\n\n${O}${o}${s}`}),planContent:O},clearContext:!0,mode:i,allowedPrompts:w}})),$l(!0),Al(!0),t(),n(),e.onReject();return}if(r===`yes-resume-auto-mode`&&L()){X(`tengu_plan_exit`,{planLengthChars:O.length,outcome:r,clearContext:!1,interviewPhaseEnabled:Ps(),planStructureVariant:D,hasFeedback:!!c}),$l(!0),Al(!0),lr(!0),a(e=>({...e,toolPermissionContext:za({...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){X(`tengu_plan_exit`,{planLengthChars:O.length,outcome:r,clearContext:!1,interviewPhaseEnabled:Ps(),planStructureVariant:D,hasFeedback:!!c}),$l(!0),Al(!0),t(),e.onAllow(l,Ib(d,w),c);return}let f={"yes-bypass-permissions":`bypassPermissions`,"yes-accept-edits":`acceptEdits`}[r];if(f){X(`tengu_plan_exit`,{planLengthChars:O.length,outcome:r,interviewPhaseEnabled:Ps(),planStructureVariant:D,hasFeedback:!!c}),$l(!0),Al(!0),t(),e.onAllow(l,Ib(f,w),c);return}if(r===`no`){if(!o&&!S)return;X(`tengu_plan_exit`,{planLengthChars:O.length,outcome:`no`,interviewPhaseEnabled:Ps(),planStructureVariant:D});let r;S&&(r=await Promise.all(x.map(async e=>(await wa({type:`image`,source:{type:`base64`,media_type:e.mediaType||`image/png`,data:e.content}})).block))),t(),n(),e.onReject(o||(S?`(See attached image)`:void 0),r&&r.length>0?r:void 0)}}let ne=zm(),F=ne?pc(ne):null,I=(0,Q.useRef)(N);I.current=N;let re=(0,Q.useRef)(void 0);re.current=()=>{X(`tengu_plan_exit`,{planLengthChars:O.length,outcome:`no`,interviewPhaseEnabled:Ps(),planStructureVariant:D}),t(),n(),e.onReject()};let ie=!E&&!!r;if((0,Q.useLayoutEffect)(()=>{if(ie)return r((0,$.jsxs)(K,{flexDirection:`column`,borderStyle:`round`,borderColor:`planMode`,borderLeft:!1,borderRight:!1,borderBottom:!1,paddingX:1,children:[(0,$.jsx)(q,{dimColor:!0,children:`Would you like to proceed?`}),(0,$.jsx)(K,{marginTop:1,children:(0,$.jsx)(nm,{options:v,onChange:e=>void I.current(e),onCancel:()=>re.current?.(),onImagePaste:y,pastedContents:l,onRemoveImage:b})}),F&&(0,$.jsxs)(K,{flexDirection:`row`,gap:1,marginTop:1,children:[(0,$.jsx)(q,{dimColor:!0,children:`ctrl-g to edit in `}),(0,$.jsx)(q,{bold:!0,dimColor:!0,children:F}),(0,$.jsxs)(q,{dimColor:!0,children:[` · `,ud(C)]}),A&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(q,{dimColor:!0,children:` · `}),(0,$.jsxs)(q,{color:`success`,children:[u.tick,`Plan saved!`]})]})]})]})),()=>r(null)},[ie,r,v,l,F,C,A]),E){function r(r){r===`yes`?(X(`tengu_plan_exit`,{planLengthChars:0,outcome:`yes-default`,interviewPhaseEnabled:Ps(),planStructureVariant:D}),P()&&(lr(!1),Gl(!0),a(e=>({...e,toolPermissionContext:{...Jt(e.toolPermissionContext),prePlanMode:void 0}}))),$l(!0),Al(!0),t(),e.onAllow({},[{type:`setMode`,mode:`default`,destination:`session`}])):(X(`tengu_plan_exit`,{planLengthChars:0,outcome:`no`,interviewPhaseEnabled:Ps(),planStructureVariant:D}),t(),n(),e.onReject())}return(0,$.jsx)(Eh,{color:`planMode`,title:`Exit plan mode?`,children:(0,$.jsxs)(K,{flexDirection:`column`,paddingX:1,marginTop:1,children:[(0,$.jsx)(q,{children:`Work Mate wants to exit plan mode`}),(0,$.jsx)(K,{marginTop:1,children:(0,$.jsx)(nm,{options:[{label:`Yes`,value:`yes`},{label:`No`,value:`no`}],onChange:r,onCancel:()=>{X(`tengu_plan_exit`,{planLengthChars:0,outcome:`no`,interviewPhaseEnabled:Ps(),planStructureVariant:D}),t(),n(),e.onReject()}})})]})})}return(0,$.jsxs)(K,{flexDirection:`column`,tabIndex:0,autoFocus:!0,onKeyDown:te,children:[(0,$.jsx)(Eh,{color:`planMode`,title:`Ready to code?`,innerPaddingX:0,children:(0,$.jsxs)(K,{flexDirection:`column`,marginTop:1,children:[(0,$.jsx)(K,{paddingX:1,flexDirection:`column`,children:(0,$.jsx)(q,{children:`Here is Work Mate's plan:`})}),(0,$.jsx)(K,{borderColor:`subtle`,borderStyle:`dashed`,flexDirection:`column`,borderLeft:!1,borderRight:!1,paddingX:1,marginBottom:1,overflow:`hidden`,children:(0,$.jsx)(Ei,{children:O})}),(0,$.jsxs)(K,{flexDirection:`column`,paddingX:1,children:[(0,$.jsx)(Kv,{permissionResult:e.permissionResult,toolType:`tool`}),dr()&&w&&w.length>0&&(0,$.jsxs)(K,{flexDirection:`column`,marginBottom:1,children:[(0,$.jsx)(q,{bold:!0,children:`Requested permissions:`}),w.map((e,t)=>(0,$.jsxs)(q,{dimColor:!0,children:[` `,`· `,e.tool,`(`,`prompt:`,` `,e.prompt,`)`]},t))]}),!ie&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(q,{dimColor:!0,children:`Work Mate has written up a plan and is ready to execute. Would you like to proceed?`}),(0,$.jsx)(K,{marginTop:1,children:(0,$.jsx)(nm,{options:v,onChange:N,onCancel:()=>re.current?.(),onImagePaste:y,pastedContents:l,onRemoveImage:b})})]})]})]})}),!ie&&F&&(0,$.jsxs)(K,{flexDirection:`row`,gap:1,paddingX:1,marginTop:1,children:[(0,$.jsxs)(K,{children:[(0,$.jsx)(q,{dimColor:!0,children:`ctrl-g to edit in `}),(0,$.jsx)(q,{bold:!0,dimColor:!0,children:F}),(0,$.jsxs)(q,{dimColor:!0,children:[` · `,ud(C)]})]}),A&&(0,$.jsxs)(K,{children:[(0,$.jsx)(q,{dimColor:!0,children:` · `}),(0,$.jsxs)(q,{color:`success`,children:[u.tick,`Plan saved!`]})]})]})]})}function zb({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 Bb(e,t){if(!e)return null;let n=mf(df({permissionMode:t,mainLoopModel:yf(),exceeds200kTokens:!1}),Jl()),{used:r}=vf({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}_m(),J(),fo(),Bd(),V(),tm();var Vb={accept:`tell Work Mate what to do next`,reject:`tell Work Mate what to do differently`};function Hb({options:e,onSelect:t,onCancel:n,question:r=`Do you want to proceed?`,toolAnalyticsContext:i}){let a=yc(),[o,s]=(0,Q.useState)(``),[c,l]=(0,Q.useState)(``),[u,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(!1),[m,h]=(0,Q.useState)(null),[g,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(!1),b=e.find(e=>e.value===m)?.feedbackConfig?.type,x=b===`accept`&&!u||b===`reject`&&!f,S=(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=Vb[i];return o?{type:`input`,label:n,value:t,placeholder:a??d,onChange:c,allowEmptySubmitToCancel:!0}:{label:n,value:t}}),[e,u,f]),C=(0,Q.useCallback)(t=>{let n=e.find(e=>e.value===t);if(!n?.feedbackConfig)return;let{type:r}=n.feedbackConfig,a={toolName:i?.toolName,isMcp:i?.isMcp??!1};r===`accept`?u?(d(!1),X(`tengu_accept_feedback_mode_collapsed`,a)):(d(!0),_(!0),X(`tengu_accept_feedback_mode_entered`,a)):r===`reject`&&(f?(p(!1),X(`tengu_reject_feedback_mode_collapsed`,a)):(p(!0),y(!0),X(`tengu_reject_feedback_mode_entered`,a)))},[e,u,f,i]),w=(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);let t={toolName:i?.toolName,isMcp:i?.isMcp??!1,has_instructions:!!e,instructions_length:e?.length??0,entered_feedback_mode:r.feedbackConfig.type===`accept`?g:v};r.feedbackConfig.type===`accept`?X(`tengu_accept_submitted`,t):r.feedbackConfig.type===`reject`&&X(`tengu_reject_submitted`,t)}t(n,a)},[e,o,c,t,i,g,v]);Tc((0,Q.useMemo)(()=>{let t={};for(let n of e)n.keybinding&&(t[n.keybinding]=()=>w(n.value));return t},[e,w]),{context:`Confirmation`});let T=(0,Q.useCallback)(()=>{X(`tengu_permission_request_escape`,{}),a(e=>({...e,attribution:{...e.attribution,escapeCount:e.attribution.escapeCount+1}})),n?.()},[n,a]);return(0,$.jsxs)(K,{flexDirection:`column`,children:[typeof r==`string`?(0,$.jsx)(q,{children:r}):r,(0,$.jsx)(nm,{options:S,inlineDescriptions:!0,onChange:w,onCancel:T,onFocus:t=>{let n=e.find(e=>e.value===t);n?.feedbackConfig?.type!==`accept`&&u&&!o.trim()&&d(!1),n?.feedbackConfig?.type!==`reject`&&f&&!c.trim()&&p(!1),h(t)},onInputModeToggle:C}),(0,$.jsx)(K,{marginTop:1,children:(0,$.jsxs)(q,{dimColor:!0,children:[`Esc to cancel`,x&&` · Tab to amend`]})})]})}Pl(),J(),f(),id(),pn(),Pd(),wh();function Ub({toolUseConfirm:e,onDone:t,onReject:n,verbose:r}){let[i]=Ec(),a=e.tool.userFacingName(e.input),o=a.endsWith(` (MCP)`)?a.slice(0,-6):a;Ey(e,(0,Q.useMemo)(()=>({completion_type:`tool_use_single`,language_name:`none`}),[]));let s=(0,Q.useCallback)((r,i)=>{switch(r){case`yes`:Ty({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id,platform:Wu.platform}}),e.onAllow(e.input,[],i),t();break;case`yes-dont-ask-again`:Ty({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id,platform:Wu.platform}}),e.onAllow(e.input,[{type:`addRules`,rules:[{toolName:e.tool.name}],behavior:`allow`,destination:`localSettings`}]),t();break;case`no`:Ty({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id,platform:Wu.platform}}),e.onReject(i),n(),t();break}},[e,t,n]),c=(0,Q.useCallback)(()=>{Ty({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id,platform:Wu.platform}}),e.onReject(),n(),t()},[e,t,n]),l=Fl(),u=Me(),d=(0,Q.useMemo)(()=>{let e=[{label:`Yes`,value:`yes`,feedbackConfig:{type:`accept`}}];return u&&e.push({label:(0,$.jsxs)(q,{children:[`Yes, and don't ask again for `,(0,$.jsx)(q,{bold:!0,children:o}),` commands in`,` `,(0,$.jsx)(q,{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:p(e.tool.name),isMcp:e.tool.isMcp??!1}),[e.tool.name,e.tool.isMcp]);return(0,$.jsxs)(Eh,{title:`Tool use`,children:[(0,$.jsxs)(K,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsxs)(q,{children:[o,`(`,e.tool.renderToolUseMessage(e.input,{theme:i,verbose:!0}),`)`,a.endsWith(` (MCP)`)?(0,$.jsx)(q,{dimColor:!0,children:` (MCP)`}):``]}),(0,$.jsx)(q,{dimColor:!0,children:Ad(e.description,3)})]}),(0,$.jsxs)(K,{flexDirection:`column`,children:[(0,$.jsx)(Kv,{permissionResult:e.permissionResult,toolType:`tool`}),(0,$.jsx)(Hb,{options:d,onSelect:s,onCancel:c,toolAnalyticsContext:f})]})]})}function Wb(e,t,n,r){return{filePath:e,edits:[{old_string:t,new_string:n,replace_all:r}],editMode:`single`}}cu(),J();var Gb={getConfig:e=>Wb(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 Kb(e){let t=e=>Ia.inputSchema.parse(e),{file_path:n,old_string:r,new_string:i,replace_all:a}=t(e.toolUseConfirm.input);return(0,$.jsx)(Sb,{toolUseConfirm:e.toolUseConfirm,toolUseContext:e.toolUseContext,onDone:e.onDone,onReject:e.onReject,title:`Edit file`,subtitle:mg(lu(),n),question:(0,$.jsxs)(q,{children:[`Do you want to make this edit to `,(0,$.jsx)(q,{bold:!0,children:ug(n)}),`?`]}),content:(0,$.jsx)($y,{file_path:n,edits:[{old_string:r,new_string:i,replace_all:a||!1}]}),path:n,completionType:`str_replace_single`,parseInput:t,ideDiffSupport:Gb})}J();function qb(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 Jb({toolUseConfirm:e,onDone:t,onReject:n,verbose:r,toolUseContext:i}){let[a]=Ec(),o=qb(e),s=e.tool.userFacingName(e.input),c=e.tool.isReadOnly(e.input),l=`${c?`Read`:`Edit`} file`;return o?(0,$.jsx)(Sb,{toolUseConfirm:e,toolUseContext:i,onDone:t,onReject:n,title:l,content:(0,$.jsx)(K,{flexDirection:`column`,paddingX:2,paddingY:1,children:(0,$.jsxs)(q,{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)(Ub,{toolUseConfirm:e,toolUseContext:i,onDone:t,onReject:n,verbose:r})}gi(),J(),ms(),Qs();function Yb({file_path:e,content:t,fileExists:n,oldContent:r}){let{columns:i}=tl(),a=(0,Q.useMemo)(()=>n?y({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)(K,{flexDirection:`column`,children:(0,$.jsx)(K,{borderColor:`subtle`,borderStyle:`dashed`,flexDirection:`column`,borderLeft:!1,borderRight:!1,paddingX:1,children:a?Bu(a.map(t=>(0,$.jsx)(Is,{patch:t,dim:!1,filePath:e,firstLine:o,fileContent:r,width:i-2},t.newStart)),e=>(0,$.jsx)(Nc,{fromLeftEdge:!0,children:(0,$.jsx)(q,{dimColor:!0,children:`...`})},`ellipsis-${e}`)):(0,$.jsx)(xi,{code:t||`(No content)`,filePath:e})})})}J(),cu(),mu(),Ru();var Xb={getConfig:e=>{let t;try{t=dd(e.file_path)}catch(e){if(!gu(e))throw e;t=``}return Wb(e.file_path,t,e.content,!1)},applyChanges:(e,t)=>{let n=t[0];return n?{...e,content:n.new_string}:e}};function Zb(e){let t=e=>Sr.inputSchema.parse(e),{file_path:n,content:r}=t(e.toolUseConfirm.input),{fileExists:i,oldContent:a}=(0,Q.useMemo)(()=>{try{return{fileExists:!0,oldContent:dd(n)}}catch(e){if(!gu(e))throw e;return{fileExists:!1,oldContent:``}}},[n]),o=i?`overwrite`:`create`;return(0,$.jsx)(Sb,{toolUseConfirm:e.toolUseConfirm,toolUseContext:e.toolUseContext,onDone:e.onDone,onReject:e.onReject,title:i?`Overwrite file`:`Create file`,subtitle:mg(lu(),n),question:(0,$.jsxs)(q,{children:[`Do you want to `,o,` `,(0,$.jsx)(q,{bold:!0,children:ug(n)}),`?`]}),content:(0,$.jsx)(Yb,{file_path:n,content:r,fileExists:i,oldContent:a}),path:n,completionType:`write_file_single`,parseInput:t,ideDiffSupport:Xb})}J(),ku(),cu(),ms(),xu(),Qs(),lc();function Qb(e){let t=(0,Q.useMemo)(()=>wu().readFile(e.notebook_path,{encoding:`utf-8`}).then(e=>bl(e)).catch(()=>null),[e.notebook_path]);return(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)($b,{...e,promise:t})})}function $b({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=Da(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:y({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)(K,{flexDirection:`column`,children:(0,$.jsxs)(K,{borderStyle:`round`,flexDirection:`column`,paddingX:1,children:[(0,$.jsxs)(K,{paddingBottom:1,flexDirection:`column`,children:[(0,$.jsx)(q,{bold:!0,children:a?e:mg(lu(),e)}),(0,$.jsxs)(q,{dimColor:!0,children:[d,` for cell `,t,r?` (${r})`:``]})]}),i===`delete`?(0,$.jsx)(K,{flexDirection:`column`,paddingLeft:2,children:(0,$.jsx)(xi,{code:l,filePath:e})}):i===`insert`?(0,$.jsx)(K,{flexDirection:`column`,paddingLeft:2,children:(0,$.jsx)(xi,{code:n,filePath:r===`markdown`?`file.md`:e})}):u?Bu(u.map(t=>(0,$.jsx)(Is,{patch:t,dim:!1,width:o,filePath:e,firstLine:n.split(`
|
|
25
|
+
`)[0]??null,fileContent:l},t.newStart)),e=>(0,$.jsx)(Nc,{fromLeftEdge:!0,children:(0,$.jsx)(q,{dimColor:!0,children:`...`})},`ellipsis-${e}`)):(0,$.jsx)(xi,{code:n,filePath:r===`markdown`?`file.md`:e})]})})}J(),Td();function ex(e){let t=e=>{let t=$a.inputSchema.safeParse(e);return t.success?t.data:(Dd(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)(Sb,{toolUseConfirm:e.toolUseConfirm,toolUseContext:e.toolUseContext,onDone:e.onDone,onReject:e.onReject,title:`Edit notebook`,question:(0,$.jsxs)(q,{children:[`Do you want to `,s,` `,(0,$.jsx)(q,{bold:!0,children:ug(r)}),`?`]}),content:(0,$.jsx)(Qb,{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})}Pd(),Oa();async function tx(e){if(e.nameType===`application`)return null;let t=e.name;if(!t||O.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 hy(n),i=await uy(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||ay[n])?null:i}async function nx(e,t){let n=await Je(e);if(!n.valid)return[];let r=ln(n).filter(e=>e.elementType===`CommandAst`);if(r.length<=1){let e=r[0]?await tx(r[0]):null;return e?[e]:[]}let i=[];for(let e of r){if(t?.(e))continue;let n=await tx(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=rx(t);(n===``?0:Fd(n,` `)+1)<=1&&((await hy(e))?.subcommands?.length||ay[e])||o.push(n)}return o}function rx(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(` `)}pn();function ix({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`}),Me()&&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=Ab(e,Pf);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}J(),fo(),Bd(),f(),tm(),wh();function ax(e){let{toolUseConfirm:t,toolUseContext:n,onDone:r,onReject:i}=e,{command:a,description:o}=le.inputSchema.parse(t.input),[s]=Ec(),c=Xy({toolName:t.tool.name,toolInput:t.input,toolDescription:t.description,messages:n.messages}),{yesInputMode:l,noInputMode:u,yesFeedbackModeEntered:d,noFeedbackModeEntered:f,acceptFeedback:m,rejectFeedback:h,setAcceptFeedback:g,setRejectFeedback:_,focusedOption:v,handleInputModeToggle:y,handleReject:b,handleFocus:x}=Eb({toolUseConfirm:t,onDone:r,onReject:i,explainerVisible:c.visible}),[S,C]=(0,Q.useState)(!1),[w,T]=(0,Q.useState)(a.includes(`
|
|
26
|
+
`)?void 0:a),E=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{let e=!1;return nx(a,e=>zt(e,e.text)).then(t=>{e||E.current||t.length>0&&T(`${t[0]}:*`)}).catch(()=>{}),()=>{e=!0}},[a]);let D=(0,Q.useCallback)(e=>{E.current=!0,T(e)},[]);Ey(t,(0,Q.useMemo)(()=>({completion_type:`tool_use_single`,language_name:`none`}),[]));let O=(0,Q.useMemo)(()=>ix({suggestions:t.permissionResult.behavior===`ask`?t.permissionResult.suggestions:void 0,onRejectFeedbackChange:_,onAcceptFeedbackChange:g,yesInputMode:l,noInputMode:u,editablePrefix:w,onEditablePrefixChange:D}),[t,l,u,w,D]);Fc(`permission:toggleDebug`,(0,Q.useCallback)(()=>{C(e=>!e)},[]),{context:`Confirmation`});function k(e){X(`tengu_permission_request_option_selected`,{option_index:{yes:1,"yes-apply-suggestions":2,"yes-prefix-edited":2,no:3}[e],explainer_visible:c.visible});let n=p(t.tool.name);if(e===`yes-prefix-edited`){let e=(w??``).trim();if(Tb(`tool_use_single`,t,`accept`),!e)t.onAllow(t.input,[]);else{let n=[{type:`addRules`,rules:[{toolName:le.name,ruleContent:e}],behavior:`allow`,destination:`localSettings`}];t.onAllow(t.input,n)}r();return}switch(e){case`yes`:{let e=m.trim();Tb(`tool_use_single`,t,`accept`),X(`tengu_accept_submitted`,{toolName:n,isMcp:t.tool.isMcp??!1,has_instructions:!!e,instructions_length:e.length,entered_feedback_mode:d}),t.onAllow(t.input,[],e||void 0),r();break}case`yes-apply-suggestions`:{Tb(`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=h.trim();X(`tengu_reject_submitted`,{toolName:n,isMcp:t.tool.isMcp??!1,has_instructions:!!e,instructions_length:e.length,entered_feedback_mode:f}),b(e||void 0);break}}}return(0,$.jsxs)(Eh,{title:`PowerShell command`,children:[(0,$.jsxs)(K,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsx)(q,{dimColor:c.visible,children:le.renderToolUseMessage({command:a,description:o},{theme:s,verbose:!0})}),!c.visible&&(0,$.jsx)(q,{dimColor:!0,children:t.description}),(0,$.jsx)(Qy,{visible:c.visible,promise:c.promise})]}),S?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ny,{permissionResult:t.permissionResult,toolName:`PowerShell`}),n.options.debug&&(0,$.jsx)(K,{justifyContent:`flex-end`,marginTop:1,children:(0,$.jsx)(q,{dimColor:!0,children:`Ctrl-D to hide debug info`})})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(K,{flexDirection:`column`,children:[(0,$.jsx)(Kv,{permissionResult:t.permissionResult,toolType:`command`}),null,(0,$.jsx)(q,{children:`Do you want to proceed?`}),(0,$.jsx)(nm,{options:O,inlineDescriptions:!0,onChange:k,onCancel:()=>b(),onFocus:x,onInputModeToggle:y})]}),(0,$.jsxs)(K,{justifyContent:`space-between`,marginTop:1,children:[(0,$.jsxs)(q,{dimColor:!0,children:[`Esc to cancel`,(v===`yes`&&!l||v===`no`&&!u)&&` · Tab to amend`,c.enabled&&` · ctrl+e to ${c.visible?`hide`:`explain`}`]}),n.options.debug&&(0,$.jsx)(q,{dimColor:!0,children:`Ctrl+d to show debug info`})]})]})]})}Td(),Pl(),J(),f(),id(),pn(),wh();function ox(e){let{toolUseConfirm:t,onDone:n,onReject:r,verbose:i}=e,a=(e=>{let t=Er.inputSchema.safeParse(e);return t.success?t.data.skill:(Dd(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;Ey(t,(0,Q.useMemo)(()=>({completion_type:`tool_use_single`,language_name:`none`}),[]));let s=Fl(),c=Me(),l=(0,Q.useMemo)(()=>{let e=[{label:`Yes`,value:`yes`,feedbackConfig:{type:`accept`}}],t=[];if(c){t.push({label:(0,$.jsxs)(q,{children:[`Yes, and don't ask again for `,(0,$.jsx)(q,{bold:!0,children:a}),` in `,(0,$.jsx)(q,{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)(q,{children:[`Yes, and don't ask again for `,(0,$.jsx)(q,{bold:!0,children:`${n}:*`}),` commands in`,` `,(0,$.jsx)(q,{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:p(t.tool.name),isMcp:t.tool.isMcp??!1}),[t.tool.name,t.tool.isMcp]),d=(0,Q.useCallback)((e,i)=>{switch(e){case`yes`:Ty({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:t.assistantMessage.message.id,platform:Wu.platform}}),t.onAllow(t.input,[],i),n();break;case`yes-exact`:Ty({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:t.assistantMessage.message.id,platform:Wu.platform}}),t.onAllow(t.input,[{type:`addRules`,rules:[{toolName:wf,ruleContent:a}],behavior:`allow`,destination:`localSettings`}]),n();break;case`yes-prefix`:{Ty({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:t.assistantMessage.message.id,platform:Wu.platform}});let e=a.indexOf(` `),r=e>0?a.substring(0,e):a;t.onAllow(t.input,[{type:`addRules`,rules:[{toolName:wf,ruleContent:`${r}:*`}],behavior:`allow`,destination:`localSettings`}]),n();break}case`no`:Ty({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:t.assistantMessage.message.id,platform:Wu.platform}}),t.onReject(i),r(),n();break}},[t,n,r,a]),f=(0,Q.useCallback)(()=>{Ty({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:t.assistantMessage.message.id,platform:Wu.platform}}),t.onReject(),r(),n()},[t,n,r]);return(0,$.jsxs)(Eh,{title:`Use skill "${a}"?`,children:[(0,$.jsx)(q,{children:`Work Mate may use instructions, code, or files from this Skill.`}),(0,$.jsx)(K,{flexDirection:`column`,paddingX:2,paddingY:1,children:(0,$.jsx)(q,{dimColor:!0,children:o?.description})}),(0,$.jsxs)(K,{flexDirection:`column`,children:[(0,$.jsx)(Kv,{permissionResult:t.permissionResult,toolType:`tool`}),(0,$.jsx)(Hb,{options:l,onSelect:d,onCancel:f,toolAnalyticsContext:u})]})]})}J(),hm(),id(),pn(),wh();function sx({toolUseConfirm:e,onDone:t,onReject:n}){let[r]=Ec(),i=mm(r),a=e.input,o=(0,Q.useMemo)(()=>Me(),[]),s=(0,Q.useMemo)(()=>{let t=[{label:`Yes`,value:`yes`,feedbackConfig:{type:`accept`}}];return o&&t.push({label:(0,$.jsxs)(q,{children:[`Yes, and don`,`’`,`t ask again for `,(0,$.jsx)(q,{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`:Ty({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id??``,platform:Wu.platform}}),e.onAllow(e.input,[],i),t();break;case`yes-dont-ask-again`:Ty({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id??``,platform:Wu.platform}}),e.onAllow(e.input,[{type:`addRules`,rules:[{toolName:e.tool.name}],behavior:`allow`,destination:`localSettings`}]),t();break;case`no`:Ty({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id??``,platform:Wu.platform}}),e.onReject(i),n(),t();break}},[e,t,n]),l=(0,Q.useCallback)(()=>{Ty({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id??``,platform:Wu.platform}}),e.onReject(),n(),t()},[e,t,n]);return(0,$.jsx)(Eh,{title:`Workflow`,children:(0,$.jsxs)(K,{flexDirection:`column`,gap:1,children:[(0,$.jsxs)(K,{flexDirection:`column`,children:[(0,$.jsxs)(q,{bold:!0,color:i.permission,children:[`Execute workflow: `,a.workflow]}),a.args&&(0,$.jsxs)(q,{dimColor:!0,children:[`Arguments: `,a.args]})]}),(0,$.jsx)(Kv,{permissionResult:e.permissionResult,toolType:`command`}),(0,$.jsx)(Hb,{options:s,onSelect:c,onCancel:l})]})})}fo(),Vn(),Ka(),Ft(),Vr(),j(),Wa(),Ur();var cx=_t();function lx(e){switch(e){case Ia:return Kb;case Sr:return Zb;case $t:return Nb;case le:return ax;case $a:return ex;case R:return Rb;case ho:return Fb;case Er:return ox;case Xs:return ey;case cx:return sx??Ub;case rr:case Le:case On:return Jb;default:return Ub}}function ux(e){let t=e.tool.userFacingName(e.input);return e.tool===R?`Work Mate needs your approval for the plan`:e.tool===ho?`Work Mate wants to enter plan mode`:!t||t.trim()===``?`Work Mate needs your attention`:`Work Mate needs your permission to use ${t}`}function dx({toolUseConfirm:e,toolUseContext:t,onDone:n,onReject:r,verbose:i,setStickyFooter:a}){return Fc(`app:interrupt`,()=>{n(),r(),e.onReject()},{context:`Confirmation`}),Lv(ux(e),`permission_prompt`),(0,$.jsx)(lx(e.tool),{toolUseContext:t,toolUseConfirm:e,onDone:n,onReject:r,verbose:i,setStickyFooter:a})}Bs(),zp(),Td(),Nr();async function fx(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=ai([`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 Rr({systemPrompt:u,userPrompt:d,signal:n,options:{querySource:`mcp_datetime_parse`,agents:[],isNonInteractiveSession:!1,hasAppendSystemPrompt:!1,mcpTools:[],enablePromptCaching:!1}}),t=Lr(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 Dd(e),{success:!1,error:`Unable to parse date/time. Please enter in ISO 8601 format manually.`}}}function px(e){return/^\d{4}-\d{2}-\d{2}(T|$)/.test(e.trim())}El(),Tu(),Pd();var mx=e=>e.type===`string`&&(`enum`in e||`oneOf`in e);function hx(e){return e.type===`array`&&`items`in e&&typeof e.items==`object`&&e.items!==null&&(`enum`in e.items||`anyOf`in e.items)}function gx(e){return`anyOf`in e.items?e.items.anyOf.map(e=>e.const):`enum`in e.items?e.items.enum:[]}function _x(e){return`anyOf`in e.items?e.items.anyOf.map(e=>e.title):`enum`in e.items?e.items.enum:[]}function vx(e,t){let n=gx(e).indexOf(t);return n>=0?_x(e)[n]??t:t}function yx(e){return`oneOf`in e?e.oneOf.map(e=>e.const):`enum`in e?e.enum:[]}function bx(e){return`oneOf`in e?e.oneOf.map(e=>e.title):`enum`in e?(`enumNames`in e?e.enumNames:void 0)??e.enum:[]}function xx(e,t){let n=yx(e).indexOf(t);return n>=0?bx(e)[n]??t:t}function Sx(e){if(mx(e)){let[t,...n]=yx(e);return t?fl([t,...n]):hl()}if(e.type===`string`){let t=vl();switch(e.minLength!==void 0&&(t=t.min(e.minLength,{message:`Must be at least ${e.minLength} ${Md(e.minLength,`character`)}`})),e.maxLength!==void 0&&(t=t.max(e.maxLength,{message:`Must be at most ${e.maxLength} ${Md(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=pl({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 Tl();throw Error(`Unsupported schema: ${du(e)}`)}function Cx(e,t){let n=Sx(t).safeParse(e);return n.success?{value:n.data,isValid:!0}:{isValid:!1,error:n.error.issues.map(e=>e.message).join(`; `)}}function wx(e){return e.type===`string`&&`format`in e&&(e.format===`date`||e.format===`date-time`)}async function Tx(e,t,n){let r=Cx(e,t);if(r.isValid)return r;if(wx(t)&&!px(e)){let r=await fx(e,t.format,n);if(r.success){let e=Cx(r.value,t);if(e.isValid)return e}}return r}l(),gi(),J(),fo(),Pd(),po(),pp();var Ex=e=>[`string`,`number`,`integer`].includes(e.type),Dx=`⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏`,Ox=e=>(e+1)%10;function kx(e){e.buffer=``,e.timer=void 0}function Ax(){let[e,t]=(0,Q.useState)(0);return(0,Q.useEffect)(()=>{let e=setInterval(t,80,Ox);return()=>clearInterval(e)},[]),(0,$.jsx)(q,{color:`warning`,children:Dx[e]})}function jx(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 Mx({event:e,onResponse:t,onWaitingDismiss:n}){return e.params.mode===`url`?(0,$.jsx)(Px,{event:e,onResponse:t,onWaitingDismiss:n}):(0,$.jsx)(Nx,{event:e,onResponse:t})}function Nx({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}),[f,p]=(0,Q.useState)(()=>{let e={};for(let[t,n]of Object.entries(a.properties))if(Ex(n)&&n?.default!==void 0){let r=Cx(String(n.default),n);!r.isValid&&r.error&&(e[t]=r.error)}return e});(0,Q.useEffect)(()=>{if(!r)return;let e=()=>{t(`cancel`)};if(r.aborted){e();return}return r.addEventListener(`abort`,e),()=>{r.removeEventListener(`abort`,e)}},[r,t]);let m=(0,Q.useMemo)(()=>{let e=a.required??[];return Object.entries(a.properties).map(([t,n])=>({name:t,schema:n,isRequired:e.includes(t)}))},[a]),[h,g]=(0,Q.useState)(o?0:void 0),[_,v]=(0,Q.useState)(()=>{let e=m[0];if(e&&Ex(e.schema)){let t=l[e.name];return t===void 0?``:String(t)}return``}),[y,b]=(0,Q.useState)(_.length),[x,S]=(0,Q.useState)(()=>new Set),[C,w]=(0,Q.useState)(),[T,E]=(0,Q.useState)(0),D=(0,Q.useRef)(void 0),O=(0,Q.useRef)(new Map),k=(0,Q.useRef)({buffer:``,timer:void 0});(0,Q.useEffect)(()=>()=>{D.current!==void 0&&clearTimeout(D.current);let e=k.current;e.timer!==void 0&&clearTimeout(e.timer);for(let e of O.current.values())e.abort();O.current.clear()},[]);let{columns:A,rows:j}=tl(),M=h===void 0?void 0:m[h],ee=M!==void 0&&Ex(M.schema)&&!mx(M.schema)&&!s;Ip(`elicitation`),Lv(`Work Mate needs your input`,`elicitation_dialog`);let te=(0,Q.useCallback)(e=>{if(e===void 0){v(``),b(0);return}let t=m[e];if(t&&Ex(t.schema)&&!mx(t.schema)){let e=l[t.name],n=e===void 0?``:String(e);v(n),b(n.length)}},[m,l]);function N(e,t){if(!hx(t))return;let n=l[e]??[],r=m.find(t=>t.name===e)?.isRequired??!1,i=t.minItems,a=t.maxItems;i!==void 0&&n.length<i&&(n.length>0||r)?F(e,`Select at least ${i} ${Md(i,`item`)}`):a!==void 0&&n.length>a?F(e,`Select at most ${a} ${Md(a,`item`)}`):F(e)}function P(e){M&&hx(M.schema)?(N(M.name,M.schema),w(void 0)):M&&mx(M.schema)&&w(void 0),ee&&M&&(re(M.name,M.schema,_),D.current!==void 0&&(clearTimeout(D.current),D.current=void 0),wx(M.schema)&&_.trim()!==``&&f[M.name]&&L(M.name,M.schema,_));let t=m.length+2,n=h??(s===`accept`?m.length:s===`decline`?m.length+1:void 0),r=n===void 0?0:(n+(e===`up`?t-1:1))%t;r<m.length?(g(r),c(null),te(r)):(g(void 0),c(r===m.length?`accept`:`decline`),v(``))}function ne(e,t){d(n=>{let r={...n};return t===void 0?delete r[e]:r[e]=t,r}),t!==void 0&&f[e]===`This field is required`&&F(e)}function F(e,t){p(n=>{let r={...n};return t?r[e]=t:delete r[e],r})}function I(e){e&&(ne(e,void 0),F(e),v(``),b(0))}function re(e,t,n){let r=n.trim();if(r===``&&(t.type!==`string`||`format`in t&&t.format!==void 0)){I(e);return}if(r===``){l[e]!==void 0&&ne(e,``);return}let i=Cx(n,t);ne(e,i.isValid?i.value:n),F(e,i.isValid?void 0:i.error)}function L(e,t,n){if(!r)return;let i=O.current.get(e);i&&i.abort();let a=new AbortController;O.current.set(e,a),S(t=>new Set(t).add(e)),Tx(n,t,a.signal).then(t=>{if(O.current.delete(e),S(t=>{let n=new Set(t);return n.delete(e),n}),!a.signal.aborted)if(t.isValid){ne(e,t.value),F(e);let r=String(t.value);v(e=>e===n?(b(r.length),r):e)}else F(e,t.error)},()=>{O.current.delete(e),S(t=>{let n=new Set(t);return n.delete(e),n})})}function ie(e){if(v(e),M&&(re(M.name,M.schema,e),D.current!==void 0&&(clearTimeout(D.current),D.current=void 0),wx(M.schema)&&e.trim()!==``&&f[M.name])){let t=M.name,n=M.schema;D.current=setTimeout((e,t,n,r,i)=>{e.current=void 0,t(n,r,i)},2e3,D,L,t,n,e)}}function ae(){P(`down`)}function oe(e,t,n){let r=k.current;r.timer!==void 0&&clearTimeout(r.timer),r.buffer+=e.toLowerCase(),r.timer=setTimeout(kx,2e3,r);let i=t.findIndex(e=>e.startsWith(r.buffer));i!==-1&&n(i)}Fc(`confirm:no`,()=>{if(ee&&M){let e=l[M.name];v(e===void 0?``:String(e)),b(0)}t(`cancel`)},{context:`Settings`,isActive:!!M&&!s&&!C}),Xc((e,n)=>{if(ee&&!n.upArrow&&!n.downArrow&&!n.return&&!n.backspace)return;if(C&&M&&hx(M.schema)){let t=M.schema,r=gx(t),i=l[M.name]??[];if(n.leftArrow||n.escape){w(void 0),N(M.name,t);return}if(n.upArrow){T===0?(w(void 0),N(M.name,t)):E(T-1);return}if(n.downArrow){T>=r.length-1?(w(void 0),P(`down`)):E(T+1);return}if(e===` `){let e=r[T];if(e!==void 0){let n=i.includes(e)?i.filter(t=>t!==e):[...i,e],r=n.length>0?n:void 0;ne(M.name,r);let a=t.minItems,o=t.maxItems;a!==void 0&&n.length<a&&(n.length>0||M.isRequired)?F(M.name,`Select at least ${a} ${Md(a,`item`)}`):o!==void 0&&n.length>o?F(M.name,`Select at most ${o} ${Md(o,`item`)}`):F(M.name)}return}if(n.return){let e=r[T];e!==void 0&&!i.includes(e)&&ne(M.name,[...i,e]),w(void 0),P(`down`);return}if(e){oe(e,r.map(e=>vx(t,e).toLowerCase()),E);return}return}if(C&&M&&mx(M.schema)){let t=M.schema,r=yx(t);if(n.leftArrow||n.escape){w(void 0);return}if(n.upArrow){T===0?w(void 0):E(T-1);return}if(n.downArrow){T>=r.length-1?(w(void 0),P(`down`)):E(T+1);return}if(e===` `){let e=r[T];e!==void 0&&ne(M.name,e),w(void 0);return}if(n.return){let e=r[T];e!==void 0&&ne(M.name,e),w(void 0),P(`down`);return}if(e){oe(e,r.map(e=>xx(t,e).toLowerCase()),E);return}return}if(n.return&&s===`accept`){if(se()&&Object.keys(f).length===0)t(`accept`,l);else{let e=a.required||[];for(let t of e)l[t]===void 0&&F(t,`This field is required`);let t=m.findIndex(t=>e.includes(t.name)&&l[t.name]===void 0||f[t.name]!==void 0);t!==-1&&(g(t),c(null),te(t))}return}if(n.return&&s===`decline`){t(`decline`);return}if(n.upArrow||n.downArrow){let e=k.current;e.buffer=``,e.timer!==void 0&&(clearTimeout(e.timer),e.timer=void 0),P(n.upArrow?`up`:`down`);return}if(s&&(n.leftArrow||n.rightArrow)){c(s===`accept`?`decline`:`accept`);return}if(!M)return;let{schema:r,name:i}=M,o=l[i];if(r.type===`boolean`){if(e===` `){ne(i,o===void 0||!o);return}if(n.return){P(`down`);return}if(n.backspace&&o!==void 0){I(i);return}if(e&&!n.return){oe(e,[`yes`,`no`],e=>ne(i,e===0));return}return}if(mx(r)||hx(r)){if(n.return){P(`down`);return}if(n.backspace&&o!==void 0){I(i);return}let t,a=0;if(mx(r)){let e=yx(r);t=e.map(e=>xx(r,e).toLowerCase()),o!==void 0&&(a=Math.max(0,e.indexOf(o)))}else t=gx(r).map(e=>vx(r,e).toLowerCase());if(n.rightArrow){w(i),E(a);return}if(e&&!n.leftArrow){oe(e,t,e=>{w(i),E(e)});return}return}if(n.backspace&&ee&&_===``){I(i);return}},{isActive:!0});function se(){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 R=Math.max(2,Math.floor((j-14)/3)),z=(0,Q.useMemo)(()=>{let e=m.length;if(e<=R)return{start:0,end:e};let t=h??e-1,n=Math.max(0,t-Math.floor(R/2)),r=Math.min(n+R,e);return n=Math.max(0,r-R),{start:n,end:r}},[m.length,R,h]),ce=z.start>0,le=z.end<m.length;function B(){return m.length?(0,$.jsxs)(K,{flexDirection:`column`,children:[ce&&(0,$.jsx)(K,{marginLeft:2,children:(0,$.jsxs)(q,{dimColor:!0,children:[u.arrowUp,` `,z.start,` more above`]})}),m.slice(z.start,z.end).map((e,t)=>{let n=z.start+t,{name:r,schema:i,isRequired:a}=e,o=n===h&&!s,c=l[r],d=c!==void 0&&(!Array.isArray(c)||c.length>0),p=f[r],m=x.has(r)?(0,$.jsx)(Ax,{}):p?(0,$.jsx)(q,{color:`error`,children:u.warning}):d?(0,$.jsx)(q,{color:`success`,dimColor:!o,children:u.tick}):a?(0,$.jsx)(q,{color:`error`,children:`*`}):(0,$.jsx)(q,{children:` `}),g=p?`error`:d?`success`:a?`error`:`suggestion`,v=o?g:void 0,S=(0,$.jsx)(q,{color:v,bold:o,children:i.title||r}),w,E=null;if(hx(i)){let e=gx(i),t=c??[];if(C===r&&o)w=(0,$.jsx)(q,{dimColor:!0,children:u.triangleDownSmall}),E=(0,$.jsx)(K,{flexDirection:`column`,marginLeft:6,children:e.map((e,n)=>{let r=vx(i,e),a=t.includes(e),o=n===T;return(0,$.jsxs)(K,{gap:1,children:[(0,$.jsx)(q,{color:`suggestion`,children:o?u.pointer:` `}),(0,$.jsx)(q,{color:a?`success`:void 0,children:a?u.checkboxOn:u.checkboxOff}),(0,$.jsx)(q,{color:o?`suggestion`:void 0,bold:o,children:r})]},e)})});else{let e=o?(0,$.jsxs)(q,{dimColor:!0,children:[u.triangleRightSmall,` `]}):null;w=t.length>0?(0,$.jsxs)(q,{children:[e,(0,$.jsx)(q,{color:v,bold:o,children:t.map(e=>vx(i,e)).join(`, `)})]}):(0,$.jsxs)(q,{children:[e,(0,$.jsx)(q,{dimColor:!0,italic:!0,children:`not set`})]})}}else if(mx(i)){let e=yx(i);if(C===r&&o)w=(0,$.jsx)(q,{dimColor:!0,children:u.triangleDownSmall}),E=(0,$.jsx)(K,{flexDirection:`column`,marginLeft:6,children:e.map((e,t)=>{let n=xx(i,e),r=c===e,a=t===T;return(0,$.jsxs)(K,{gap:1,children:[(0,$.jsx)(q,{color:`suggestion`,children:a?u.pointer:` `}),(0,$.jsx)(q,{color:r?`success`:void 0,children:r?u.radioOn:u.radioOff}),(0,$.jsx)(q,{color:a?`suggestion`:void 0,bold:a,children:n})]},e)})});else{let e=o?(0,$.jsxs)(q,{dimColor:!0,children:[u.triangleRightSmall,` `]}):null;w=d?(0,$.jsxs)(q,{children:[e,(0,$.jsx)(q,{color:v,bold:o,children:xx(i,c)})]}):(0,$.jsxs)(q,{children:[e,(0,$.jsx)(q,{dimColor:!0,italic:!0,children:`not set`})]})}}else if(i.type===`boolean`)w=o?d?(0,$.jsx)(q,{color:v,bold:!0,children:c?u.checkboxOn:u.checkboxOff}):(0,$.jsx)(q,{dimColor:!0,children:u.checkboxOff}):d?(0,$.jsx)(q,{children:c?u.checkboxOn:u.checkboxOff}):(0,$.jsx)(q,{dimColor:!0,italic:!0,children:`not set`});else if(Ex(i))if(o)w=(0,$.jsx)(vp,{value:_,onChange:ie,onSubmit:ae,placeholder:`Type something…`,columns:Math.min(A-20,60),cursorOffset:y,onChangeCursorOffset:b,focus:!0,showCursor:!0});else{let e=d&&wx(i)?jx(String(c),i):String(c);w=d?(0,$.jsx)(q,{children:e}):(0,$.jsx)(q,{dimColor:!0,italic:!0,children:`not set`})}else w=d?(0,$.jsx)(q,{children:String(c)}):(0,$.jsx)(q,{dimColor:!0,italic:!0,children:`not set`});return(0,$.jsxs)(K,{flexDirection:`column`,children:[(0,$.jsxs)(K,{gap:1,children:[(0,$.jsx)(q,{color:g,children:o?u.pointer:` `}),m,(0,$.jsxs)(K,{children:[S,(0,$.jsx)(q,{color:v,children:`: `}),w]})]}),E,i.description&&(0,$.jsx)(K,{marginLeft:6,children:(0,$.jsx)(q,{dimColor:!0,children:i.description})}),(0,$.jsx)(K,{marginLeft:6,height:1,children:p?(0,$.jsx)(q,{color:`error`,italic:!0,children:p}):(0,$.jsx)(q,{children:` `})})]},r)}),le&&(0,$.jsx)(K,{marginLeft:2,children:(0,$.jsxs)(q,{dimColor:!0,children:[u.arrowDown,` `,m.length-z.end,` more below`]})})]}):null}return(0,$.jsx)(cl,{title:`MCP server \u201c${n}\u201d requests your input`,subtitle:`\n${i}`,color:`permission`,onCancel:()=>t(`cancel`),isCancelActive:(!M||!!s)&&!C,inputGuide:e=>e.pending?(0,$.jsxs)(q,{children:[`Press `,e.keyName,` again to exit`]}):(0,$.jsxs)(Mc,{children:[(0,$.jsx)(zo,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`}),(0,$.jsx)(Sc,{shortcut:`↑↓`,action:`navigate`}),M&&(0,$.jsx)(Sc,{shortcut:`Backspace`,action:`unset`}),M&&M.schema.type===`boolean`&&(0,$.jsx)(Sc,{shortcut:`Space`,action:`toggle`}),M&&mx(M.schema)&&(C?(0,$.jsx)(Sc,{shortcut:`Space`,action:`select`}):(0,$.jsx)(Sc,{shortcut:`→`,action:`expand`})),M&&hx(M.schema)&&(C?(0,$.jsx)(Sc,{shortcut:`Space`,action:`toggle`}):(0,$.jsx)(Sc,{shortcut:`→`,action:`expand`}))]}),children:(0,$.jsxs)(K,{flexDirection:`column`,children:[B(),(0,$.jsxs)(K,{children:[(0,$.jsx)(q,{color:`success`,children:s===`accept`?u.pointer:` `}),(0,$.jsx)(q,{bold:s===`accept`,color:s===`accept`?`success`:void 0,dimColor:s!==`accept`,children:` Accept `}),(0,$.jsx)(q,{color:`error`,children:s===`decline`?u.pointer:` `}),(0,$.jsx)(q,{bold:s===`decline`,color:s===`decline`?`error`:void 0,dimColor:s!==`decline`,children:` Decline`})]})]})})}function Px({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`),[f,p]=(0,Q.useState)(`accept`),m=a?.showCancel??!1;Lv(`Work Mate needs your input`,`elicitation_url_dialog`),Ip(`elicitation-url`),d.current=c;let h=(0,Q.useRef)(n);h.current=n,(0,Q.useEffect)(()=>{let e=()=>{d.current===`waiting`?h.current?.(`cancel`):t(`cancel`)};if(i.aborted){e();return}return i.addEventListener(`abort`,e),()=>i.removeEventListener(`abort`,e)},[i,t]);let g=``,_=``,v=``;try{g=new URL(s).hostname;let e=s.indexOf(g);_=s.slice(0,e),v=s.slice(e+g.length)}catch{g=s}(0,Q.useEffect)(()=>{c===`waiting`&&e.completed&&n?.(m?`retry`:`dismiss`)},[c,e.completed,n,m]);let y=(0,Q.useCallback)(()=>{dc(s),t(`accept`),l(`waiting`),d.current=`waiting`,p(`open`)},[t,s]);if(Xc((e,r)=>{if(c===`prompt`){if(r.leftArrow||r.rightArrow){p(e=>e===`accept`?`decline`:`accept`);return}r.return&&(f===`accept`?y():t(`decline`))}else{let e=m?[`open`,`action`,`cancel`]:[`open`,`action`];if(r.leftArrow||r.rightArrow){p(t=>{let n=e.indexOf(t),i=r.rightArrow?1:-1;return e[(n+i+e.length)%e.length]});return}r.return&&(f===`open`?dc(s):f===`cancel`?n?.(`cancel`):n?.(m?`retry`:`dismiss`))}}),c===`waiting`){let e=a?.actionLabel??`Continue without waiting`;return(0,$.jsx)(cl,{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)(q,{children:[`Press `,e.keyName,` again to exit`]}):(0,$.jsxs)(Mc,{children:[(0,$.jsx)(zo,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`}),(0,$.jsx)(Sc,{shortcut:`\\u2190\\u2192`,action:`switch`})]}),children:(0,$.jsxs)(K,{flexDirection:`column`,children:[(0,$.jsx)(K,{marginBottom:1,flexDirection:`column`,children:(0,$.jsxs)(q,{children:[_,(0,$.jsx)(q,{bold:!0,children:g}),v]})}),(0,$.jsx)(K,{marginBottom:1,children:(0,$.jsx)(q,{dimColor:!0,italic:!0,children:`Waiting for the server to confirm completion…`})}),(0,$.jsxs)(K,{children:[(0,$.jsx)(q,{color:`success`,children:f===`open`?u.pointer:` `}),(0,$.jsx)(q,{bold:f===`open`,color:f===`open`?`success`:void 0,dimColor:f!==`open`,children:` Reopen URL `}),(0,$.jsx)(q,{color:`success`,children:f===`action`?u.pointer:` `}),(0,$.jsx)(q,{bold:f===`action`,color:f===`action`?`success`:void 0,dimColor:f!==`action`,children:` ${e}`}),m&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(q,{children:` `}),(0,$.jsx)(q,{color:`error`,children:f===`cancel`?u.pointer:` `}),(0,$.jsx)(q,{bold:f===`cancel`,color:f===`cancel`?`error`:void 0,dimColor:f!==`cancel`,children:` Cancel`})]})]})]})})}return(0,$.jsx)(cl,{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)(q,{children:[`Press `,e.keyName,` again to exit`]}):(0,$.jsxs)(Mc,{children:[(0,$.jsx)(zo,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`}),(0,$.jsx)(Sc,{shortcut:`\\u2190\\u2192`,action:`switch`})]}),children:(0,$.jsxs)(K,{flexDirection:`column`,children:[(0,$.jsx)(K,{marginBottom:1,flexDirection:`column`,children:(0,$.jsxs)(q,{children:[_,(0,$.jsx)(q,{bold:!0,children:g}),v]})}),(0,$.jsxs)(K,{children:[(0,$.jsx)(q,{color:`success`,children:f===`accept`?u.pointer:` `}),(0,$.jsx)(q,{bold:f===`accept`,color:f===`accept`?`success`:void 0,dimColor:f!==`accept`,children:` Accept `}),(0,$.jsx)(q,{color:`error`,children:f===`decline`?u.pointer:` `}),(0,$.jsx)(q,{bold:f===`decline`,color:f===`decline`?`error`:void 0,dimColor:f!==`decline`,children:` Decline`})]})]})})}J(),fo(),tm(),wh();function Fx({title:e,toolInputSummary:t,request:n,onRespond:r,onAbort:i}){Fc(`app:interrupt`,i,{isActive:!0});let a=n.options.map(e=>({label:e.label,value:e.key,description:e.description}));return(0,$.jsx)(Eh,{title:e,subtitle:n.message,titleRight:t?(0,$.jsx)(q,{dimColor:!0,children:t}):void 0,children:(0,$.jsx)(K,{flexDirection:`column`,paddingY:1,children:(0,$.jsx)(nm,{options:a,onChange:e=>{r(e)}})})})}function Ix(){return(0,Q.useSyncExternalStore)(Xe,ue)}Td(),El(),cn(),Cl();var Lx=`at_mentioned`,Rx=wl(()=>ml({method:gl(Lx),params:ml({filePath:vl(),lineStart:_l().optional(),lineEnd:_l().optional()})}));function zx(e,t){let n=(0,Q.useRef)(void 0);(0,Q.useEffect)(()=>{let r=E(e);n.current!==r&&(n.current=r),r&&r.client.setNotificationHandler(Rx(),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){Dd(e)}})},[e,t])}yh(),xh(),Uh();function Bx(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])}Gm();function Vx(){let[e,t]=(0,Q.useState)({...Pe});return(0,Q.useEffect)(()=>{let e=e=>{t({...e})};return In.add(e),()=>{In.delete(e)}},[]),e}J();function Hx({ideSelection:e,mcpClients:t}){let{status:n}=Bx(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)(q,{color:`ide`,wrap:`truncate`,children:[`⧉ `,e.lineCount,` `,e.lineCount===1?`line`:`lines`,` selected`]},`selection-indicator`);if(e.filePath)return(0,$.jsxs)(q,{color:`ide`,wrap:`truncate`,children:[`⧉ In `,ug(e.filePath)]},`selection-indicator`)}function Ux(){return(0,Q.useSyncExternalStore)(ne.subscribe,ne.getState)}J(),_s();function Wx({tokenUsage:e,model:t}){let{percentLeft:n,isAboveWarningThreshold:r,isAboveErrorThreshold:i}=Ds(e,t),a=Ux();if(!r||a)return null;let o=Ji(),s=Bi(`warning`),c=`${n}% until auto-compact`;return(0,$.jsx)(K,{flexDirection:`row`,children:o?(0,$.jsx)(q,{dimColor:!0,wrap:`truncate`,children:s?`${c} \u00b7 ${s}`:c}):(0,$.jsx)(q,{color:i?`error`:`warning`,wrap:`truncate`,children:s?`Context low (${n}% remaining) \u00b7 ${s}`:`Context low (${n}% remaining) \u00b7 Run /compact to compact & continue`})})}J(),tc();function Gx(){let[e,t]=(0,Q.useState)(0),n=(0,Q.useRef)(null),r=ta(`app:toggleTranscript`,`Global`,`ctrl+o`);return(0,Q.useEffect)(()=>{if(!ea.isSandboxingEnabled())return;let e=ea.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)}},[]),!ea.isSandboxingEnabled()||e===0?null:(0,$.jsx)(K,{paddingX:0,paddingY:0,children:(0,$.jsxs)(q,{color:`inactive`,wrap:`truncate`,children:[`⧈ Sandbox blocked `,e,` `,e===1?`operation`:`operations`,` ·`,` `,r,` for details · /sandbox to disable`]})})}Sp(),Bd(),V(),J(),Pi(),Rm(),cn(),Nr(),po();var Kx=5e3;function qx({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)(()=>Yi(Dn(a)),[a]),p=Wm(),m=Ds(f,p).isAboveWarningThreshold,{status:h}=Bx(l),g=H(e=>e.notifications),{addNotification:_,removeNotification:v}=xp(),y=Vx();(0,Q.useEffect)(()=>(Ge((e,t)=>{_({key:`env-hook`,text:e,color:t?`error`:void 0,priority:t?`medium`:`low`,timeoutMs:t?8e3:5e3})}),()=>Ge(null)),[_]),h===`connected`&&(c?.filePath||c?.text&&c.lineCount);let b=y.isUsingOverage,x=zm(),S=u&&!m&&e!==`invalid`&&e!==`missing`&&x!==void 0;return(0,Q.useEffect)(()=>{S&&x?(X(`tengu_external_editor_hint_shown`,{}),_({key:`external-editor-hint`,jsx:(0,$.jsx)(q,{dimColor:!0,children:(0,$.jsx)(zo,{action:`chat:externalEditor`,context:`Chat`,fallback:`ctrl+g`,description:`edit in ${pc(x)}`})}),priority:`immediate`,timeoutMs:5e3})):v(`external-editor-hint`)},[S,x,_,v]),(0,$.jsx)(K,{flexDirection:`column`,alignItems:d?`flex-start`:`flex-end`,flexShrink:0,overflowX:`hidden`,children:(0,$.jsx)(Jx,{ideSelection:c,mcpClients:l,notifications:g,isInOverageMode:b??!1,apiKeyStatus:e,debug:n,verbose:i,tokenUsage:f,mainLoopModel:p})})}function Jx({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)(Hx,{ideSelection:e,mcpClients:t}),n.current&&(`jsx`in n.current?(0,$.jsx)(q,{wrap:`truncate`,children:n.current.jsx},n.current.key):(0,$.jsx)(q,{color:n.current.color,dimColor:!n.current.color,wrap:`truncate`,children:n.current.text})),r&&(0,$.jsx)(K,{children:(0,$.jsx)(q,{dimColor:!0,wrap:`truncate`,children:`Now using extra usage`})}),(i===`invalid`||i===`missing`)&&(0,$.jsx)(K,{children:(0,$.jsx)(q,{color:`error`,wrap:`truncate`,children:a(process.env.CLAUDE_CODE_REMOTE)?`Authentication error · Try again`:`Not logged in`})}),o&&(0,$.jsx)(K,{children:(0,$.jsx)(q,{color:`warning`,wrap:`truncate`,children:`Debug mode`})}),i!==`invalid`&&i!==`missing`&&s&&(0,$.jsx)(K,{children:(0,$.jsxs)(q,{dimColor:!0,wrap:`truncate`,children:[c,` tokens`]})}),(0,$.jsx)(Wx,{tokenUsage:c,model:l}),(0,$.jsx)(Gx,{})]})}Sp(),po(),J();var Yx=10,Xx=null,Zx=0,Qx;async function $x(e,t){let n=Math.ceil(e/Yx)*Yx;if(Xx&&Zx>=n&&Qx===t)return Xx;Xx&&await Xx,Zx=n,Qx=t,Xx=(async()=>{let e=[],n=0;for await(let r of Tp())if(!(t&&bp(r.display)!==t)&&(e.push(r),n++,n>=Zx))break;return e})();try{return await Xx}finally{Xx=null,Zx=0,Qx=void 0}}function eS(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}=xp(),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=bp(e.display),r=n===`bash`?e.display.slice(1):e.display;y(r,n,e.pastedContents??{},t)},[y]),x=(0,Q.useCallback)(()=>{u({key:`search-history-hint`,jsx:(0,$.jsx)(q,{dimColor:!0,children:(0,$.jsx)(zo,{action:`history:search`,context:`Global`,fallback:`ctrl+r`,description:`search history`})}),priority:`immediate`,timeoutMs:Kx})},[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 $x(t,i);e.length>f.current.length&&(f.current=e)}if(e>=f.current.length){m.current--;return}let n=e+1;o(n),b(f.current[e],!0),n>=2&&!l.current&&(l.current=!0,x())})()},[b,x]),onHistoryDown:(0,Q.useCallback)(()=>{let e=m.current;if(e>1)m.current--,o(e-1),b(f.current[e-2]);else if(e===1)if(m.current=0,o(0),s){let e=s.mode;e?y(s.display,e,s.pastedContents??{}):b(s)}else y(``,h.current??`prompt`,{});return e<=0},[s,b,y]),resetHistory:(0,Q.useCallback)(()=>{c(void 0),o(0),m.current=0,h.current=void 0,d(`search-history-hint`),f.current=[],p.current=void 0},[d]),dismissSearchHint:(0,Q.useCallback)(()=>{d(`search-history-hint`)},[d])}}V();function tS(){let e=H(e=>e.tasks);return(0,Q.useMemo)(()=>{let t=Date.now();return Object.values(e).filter(Wo).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])}ep(),Mp(),J(),fo();function nS(e,t,n,r,i,a,o,s,c,l,u){let[d,f]=(0,Q.useState)(``),[p,m]=(0,Q.useState)(!1),[h,g]=(0,Q.useState)(``),[_,v]=(0,Q.useState)(0),[y,b]=(0,Q.useState)(`prompt`),[x,S]=(0,Q.useState)({}),[C,w]=(0,Q.useState)(void 0),T=(0,Q.useRef)(void 0),E=(0,Q.useRef)(new Set),D=(0,Q.useRef)(null),O=(0,Q.useCallback)(()=>{T.current&&(T.current.return(void 0),T.current=void 0)},[]),k=(0,Q.useCallback)(()=>{c(!1),f(``),m(!1),g(``),v(0),b(`prompt`),S({}),w(void 0),O(),E.current.clear()},[c,O]),A=(0,Q.useCallback)(async(e,t)=>{if(s){if(d.length===0){O(),E.current.clear(),w(void 0),m(!1),n(h),r(_),a(y),l(x);return}if(e||(O(),T.current=Ep(),E.current.clear()),T.current)for(;;){if(t?.aborted)return;let e=await T.current.next();if(e.done){m(!0);return}let i=e.value.display,o=i.lastIndexOf(d);if(o!==-1&&!E.current.has(i)){E.current.add(i),w(e.value),m(!1),a(bp(i)),n(i),l(e.value.pastedContents);let t=ip(i).lastIndexOf(d);r(t===-1?o:t);return}}}},[s,d,O,n,r,a,l,h,_,y,x]),j=(0,Q.useCallback)(()=>{c(!0),g(t),v(i),b(o),S(u),T.current=Ep(),E.current.clear()},[c,t,i,o,u]),M=(0,Q.useCallback)(()=>{A(!0)},[A]),ee=(0,Q.useCallback)(()=>{if(C){let e=bp(C.display);n(ip(C.display)),a(e),l(C.pastedContents)}else l(x);k()},[C,n,a,l,x,k]),te=(0,Q.useCallback)(()=>{n(h),r(_),l(x),k()},[n,r,l,h,_,x,k]),N=(0,Q.useCallback)(()=>{if(d.length===0)e({display:h,pastedContents:x});else if(C){let t=bp(C.display),n=ip(C.display);a(t),e({display:n,pastedContents:C.pastedContents})}k()},[d,C,e,a,h,x,k]);Fc(`history:search`,j,{context:`Global`,isActive:!s}),Tc((0,Q.useMemo)(()=>({"historySearch:next":M,"historySearch:accept":ee,"historySearch:cancel":te,"historySearch:execute":N}),[M,ee,te,N]),{context:`HistorySearch`,isActive:s});let P=e=>{s&&e.key===`backspace`&&d===``&&(e.preventDefault(),te())};Xc((e,t,n)=>{P(new Pc(n.keypress))},{isActive:s});let ne=(0,Q.useRef)(A);return ne.current=A,(0,Q.useEffect)(()=>{D.current?.abort();let e=new AbortController;return D.current=e,ne.current(!1,e.signal),()=>{e.abort()}},[d]),{historyQuery:d,setHistoryQuery:f,historyMatch:C,historyFailedMatch:p,handleKeyDown:P}}function rS({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}}J(),Bd(),V();function iS({inputValue:e,isAssistantResponding:t}){let n=H(e=>e.promptSuggestion),r=yc(),i=Ic(),{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)(()=>{sa(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();X(`tengu_prompt_suggestion`,{source:`cli`,outcome:r?`accepted`:`ignored`,prompt_id:o,...l&&{generationRequestId:l},...r&&{acceptMethod:n?`tab`:`enter`},...r&&{timeToAcceptMs:i-s},...!r&&{timeToIgnoreMs:i-s},...f.current>0&&{timeToFirstKeystrokeMs:f.current-s},wasFocusedWhenShown:p.current,similarity:Math.round(e.length/(a?.length||1)*100)/100}),t?.skipReset||h()},[d,c,s,a,o,l,h])}}Xo(),Cu(),Qm();var aS=15,oS=1e3,sS=[`|`,`||`,`&&`,`;`];function cS(e){return typeof e==`object`&&!!e&&`op`in e&&sS.includes(e.op)}function lS(e){return e.startsWith(`$`)?`variable`:e.includes(`/`)||e.startsWith(`~`)||e.startsWith(`.`)?`file`:`command`}function uS(e){let t=e.findLastIndex(e=>typeof e==`string`);return t===-1?null:{token:e[t],index:t}}function dS(e,t){if(t===0)return!0;let n=e[t-1];return n!==void 0&&cS(n)}function fS(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=hc(n);if(!i.success){let e=n.split(/\s+/),t=e[e.length-1]||``;return{prefix:t,completionType:e.length===1&&!n.includes(` `)?`command`:lS(t)}}let a=uS(i.tokens);if(!a){let e=i.tokens[i.tokens.length-1];return{prefix:``,completionType:(e&&cS(e),`command`)}}if(n.endsWith(` `))return{prefix:``,completionType:`file`};let o=lS(a.token);if(o===`variable`||o===`file`)return{prefix:a.token,completionType:o};let s=dS(i.tokens,a.index)?`command`:`file`;return{prefix:a.token,completionType:s}}function pS(e,t){return t===`variable`?`compgen -v ${An([e.slice(1)])} 2>/dev/null`:t===`file`?`compgen -f ${An([e])} 2>/dev/null | head -${aS} | while IFS= read -r f; do [ -d "$f" ] && echo "$f/" || echo "$f "; done`:`compgen -c ${An([e])} 2>/dev/null`}function mS(e,t){return t===`variable`?`print -rl -- \${(k)parameters[(I)${An([e.slice(1)])}*]} 2>/dev/null`:t===`file`?`for f in ${An([e])}*(N[1,${aS}]); do [[ -d "$f" ]] && echo "$f/" || echo "$f "; done`:`print -rl -- \${(k)commands[(I)${An([e])}*]} 2>/dev/null`}async function hS(e,t,n,r){let i;if(e===`bash`)i=pS(t,n);else if(e===`zsh`)i=mS(t,n);else return[];return(await(await Tt(i,r,`bash`,{timeout:oS})).result).stdout.split(`
|
|
36
|
+
`).filter(e=>e.trim()).slice(0,aS).map(e=>({id:e,displayText:e,description:void 0,metadata:{completionType:n}}))}async function gS(e,t,n){let r=$m();if(r!==`bash`&&r!==`zsh`)return[];try{let{prefix:i,completionType:a}=fS(e,t);return i?(await hS(r,i,a,n)).map(t=>({...t,metadata:{...t.metadata,inputSnapshot:e}})):[]}catch(e){return Y(`Shell completion failed: ${e}`),[]}}tv();var _S=/[:_-]/g,vS=null;function yS(e){if(vS?.commands===e)return vS.fuse;let t=new ev(e.filter(e=>!e.isHidden).map(e=>{let t=fn(e),n=t.split(_S).filter(Boolean);return{descriptionKey:(e.description??``).split(` `).map(e=>jS(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 vS={commands:e,fuse:t},t}function bS(e){return typeof e==`object`&&!!e&&`name`in e&&typeof e.name==`string`&&`type`in e}function xS(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 SS(e,t){if(!e)return null;let n=kS(`/${e}`,t);if(n.length===0)return null;let r=e.toLowerCase();for(let t of n){if(!bS(t.metadata))continue;let n=fn(t.metadata);if(n.toLowerCase().startsWith(r)){let t=n.slice(e.length);if(t)return{suffix:t,fullCommand:n}}}return null}function CS(e){return e.startsWith(`/`)}function wS(e){return!(!CS(e)||!e.includes(` `)||e.endsWith(` `))}function TS(e){return`/${e} `}function ES(e){let t=fn(e);return e.type===`prompt`?e.source===`plugin`&&e.pluginInfo?.repository?`${t}:${e.source}:${e.pluginInfo.repository}`:`${t}:${e.source}`:`${t}:${e.type}`}function DS(e,t){if(!(!t||t.length===0||e===``))return t.find(t=>t.toLowerCase().startsWith(e))}function OS(e,t){let n=fn(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:Ce(e))+(e.type===`prompt`&&e.argNames?.length?` (arguments: ${e.argNames.join(`, `)})`:``);return{id:ES(e),displayText:`/${n}${r}`,tag:i?`workflow`:a,description:o,metadata:e}}function kS(e,t){if(!CS(e)||wS(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:xn(fn(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=>ES(e))),a=[],o=[],s=[],c=[],l=[];e.forEach(e=>{i.has(ES(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)=>fn(e).localeCompare(fn(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=>OS(e))}let r=t.find(e=>e.isHidden&&fn(e).toLowerCase()===n);r&&t.some(e=>!e.isHidden&&fn(e).toLowerCase()===n)&&(r=void 0);let i=yS(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`?xn(fn(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 OS(t,DS(n,t.aliases))});if(r){let e=ES(r);if(!i.some(t=>t.id===e))return[OS(r),...i]}return i}function AS(e,t,n,r,i,a){let o,s;if(typeof e==`string`)o=e,s=t?de(o,n):void 0;else{if(!bS(e.metadata))return;o=fn(e.metadata),s=e.metadata}let c=TS(o);r(c),i(c.length),t&&s&&(s.type!==`prompt`||(s.argNames??[]).length===0)&&a(c,!0)}function jS(e){return e.toLowerCase().replace(/[^a-z0-9]/g,``)}function MS(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}Mm(),Mp(),Cu();var NS=null,PS=0,FS=6e4;async function IS(){let e=Date.now();if(NS&&e-PS<FS)return NS;let t=[],n=new Set;try{for await(let e of Tp()){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 NS=t,PS=e,t}function LS(e){if(!NS)return;let t=NS.indexOf(e);t!==-1&&NS.splice(t,1),NS.unshift(e)}async function RS(e){if(!e||e.length<2||!e.trim())return null;let t=await IS();for(let n of t)if(n.startsWith(e)&&n!==e)return{fullCommand:n,suffix:n.slice(e.length)};return null}zf(),Cu(),Cl(),Il(),Tu();var zS=`slack_search_channels`,BS=new Map,VS=new Set,HS=0,US=eu(),WS=US.subscribe,GS=null,KS=null;function qS(e){return e.find(e=>e.type===`connected`&&e.name.includes(`slack`))}async function JS(e,t){let n=qS(e);if(n?.type!==`connected`)return[];try{let e=(await n.client.callTool({name:zS,arguments:{query:t,limit:20,channel_types:`public_channel,private_channel`}},void 0,{timeout:5e3})).content;return Array.isArray(e)?ZS(XS(e.filter(e=>e.type===`text`).map(e=>e.text).join(`
|
|
37
|
+
`))):[]}catch(e){return Y(`Failed to fetch Slack channels: ${e}`),[]}}var YS=wl(()=>ml({results:vl()}));function XS(e){let t=e.trim();if(!t.startsWith(`{`))return e;try{let e=YS().safeParse(_u(t));if(e.success)return e.data.results}catch{}return e}function ZS(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 QS(e){return qS(e)!==void 0}function $S(){return HS}function eC(e){let t=[],n=/(^|\s)#([a-z0-9][a-z0-9_-]{0,79})(?=\s|$)/g,r;for(;(r=n.exec(e))!==null;){if(!VS.has(r[2]))continue;let e=r.index+r[1].length;t.push({start:e,end:e+1+r[2].length})}return t}function tC(e){let t=Math.max(e.lastIndexOf(`-`),e.lastIndexOf(`_`));return t>0?e.slice(0,t):e}function nC(e,t){let n,r=0;for(let[i,a]of BS)e.startsWith(i)&&i.length>r&&a.some(e=>e.startsWith(t))&&(n=a,r=i.length);return n}async function rC(e,t){if(!t)return[];let n=tC(t),r=t.toLowerCase(),i=BS.get(n)??nC(n,r);if(!i)if(GS===n&&KS)i=await KS;else{GS=n,KS=JS(e,n),i=await KS,BS.set(n,i);let t=VS.size;for(let e of i)VS.add(e);VS.size!==t&&(HS++,US.emit()),BS.size>50&&BS.delete(BS.keys().next().value),GS===n&&(GS=null,KS=null)}return i.filter(e=>e.startsWith(r)).sort().slice(0,10).map(e=>({id:`slack-channel-${e}`,displayText:`#${e}`}))}tv(),Km(),Bt(),Kd(),Td();function iC(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 aC=15,oC=60;function sC(e){return Gd(e,oC)}function cC(e,t,n=!1){if(!t&&!n)return[];try{let n=e.map(e=>({type:`agent`,displayText:`${e.agentType} (agent)`,description:sC(e.whenToUse),agentType:e.agentType,color:Dt(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 Dd(e),[]}}async function lC(e,t,n,r=!1){if(!e&&!r)return[];let[i,a]=await Promise.all([qm(e,r),Promise.resolve(cC(n,e,r))]),o=i.map(e=>({type:`file`,displayText:e.displayText,description:e.description,path:e.displayText,filename:ug(e.displayText),score:e.metadata?.score})),s=Object.values(t).flat().map(e=>({type:`mcp_resource`,displayText:`${e.server}:${e.uri}`,description:sC(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,aC).map(iC);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 ev(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:aC});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,aC).map(e=>e.source).map(iC)}Sp(),J(),Bd(),Ut(),ep(),zp(),Xr(),fo(),la(),V(),Kd(),ni(),Km();var uC=/^@[\p{L}\p{N}\p{M}_\-./\\()[\]~:]*/u,dC=/^[\p{L}\p{N}\p{M}_\-./\\()[\]~:]+/u,fC=/(@[\p{L}\p{N}\p{M}_\-./\\()[\]~:]*|[\p{L}\p{N}\p{M}_\-./\\()[\]~:]+)$/u,pC=/[\p{L}\p{N}\p{M}_\-./\\()[\]~:]+$/u,mC=/(^|\s)@([\p{L}\p{N}\p{M}_\-./\\()[\]~:]*|"[^"]*"?)$/u,hC=/(^|\s)#([a-z0-9][a-z0-9_-]*)$/;function gC(e){return typeof e==`object`&&!!e&&`type`in e&&(e.type===`directory`||e.type===`file`)}function _C(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 vC(e){let t=e.metadata;return t?.sessionId?`/resume ${t.sessionId}`:`/resume ${e.displayText}`}function yC(e){return e.isQuoted?e.token.slice(2).replace(/"$/,``):e.token.startsWith(`@`)?e.token.substring(1):e.token}function bC(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 xC(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 SC=/(^|\s)@[\w-]*$/;function CC(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 wC=null;async function TC(e,t){try{return wC&&wC.abort(),wC=new AbortController,await gS(e,t,wC.signal)}catch{return X(`tengu_shell_completion_failed`,{}),[]}}function EC(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 DC(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(uC);if(a&&a[0].length===i.length){let r=e.substring(t).match(dC),i=r?r[0]:``;return{token:a[0]+i,startPos:n,isQuoted:!1}}}}let i=n?fC:pC,a=r.match(i);if(!a||a.index===void 0)return null;let o=e.substring(t).match(dC),s=o?o[0]:``;return{token:a[0]+s,startPos:a.index,isQuoted:!1}}function OC(e){if(CS(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 kC(e,t){return!e&&t.includes(` `)&&!t.endsWith(` `)}function AC({commands:e,onInputChange:t,onSubmit:n,setCursorOffset:r,input:i,cursorOffset:a,mode:o,agents:s,setSuggestionsState:c,suggestionsState:{suggestions:l,selectedSuggestion:u,commandArgumentHint:d},suppressSuggestions:f=!1,markAccepted:p,onModeChange:m}){let{addNotification:h}=xp(),g=ta(`chat:thinkingToggle`,`Chat`,`alt+t`),[_,v]=(0,Q.useState)(`none`),y=(0,Q.useMemo)(()=>{let t=e.filter(e=>!e.isHidden);if(t.length!==0)return Math.max(...t.map(e=>{let t=fn(e);return t?t.length:0}))+6},[e]),[b,x]=(0,Q.useState)(void 0),S=H(e=>e.mcp.resources),C=Pn(),w=H(e=>e.promptSuggestion),T=H(e=>!!e.viewingAgentTaskId),E=zc(),[D,O]=(0,Q.useState)(void 0),k=(0,Q.useMemo)(()=>{if(o!==`prompt`||f)return;let t=xS(i,a);if(!t)return;let n=SS(t.partialCommand,e);if(n)return{text:n.suffix,fullCommand:n.fullCommand,insertPosition:t.startPos+1+t.partialCommand.length}},[i,a,o,e,f]),A=f?void 0:o===`prompt`?k:D,j=(0,Q.useRef)(a);j.current=a;let M=(0,Q.useRef)(null),ee=(0,Q.useRef)(``),te=(0,Q.useRef)(``),N=(0,Q.useRef)(``),P=(0,Q.useRef)(``),ne=(0,Q.useRef)(l);ne.current=l;let F=(0,Q.useRef)(null),I=(0,Q.useCallback)(()=>{c(()=>({commandArgumentHint:void 0,suggestions:[],selectedSuggestion:-1})),v(`none`),x(void 0),O(void 0)},[c]),re=(0,Q.useCallback)(async(e,t=!1)=>{M.current=e;let n=await lC(e,S,s,t);if(M.current===e){if(n.length===0){c(()=>({commandArgumentHint:void 0,suggestions:[],selectedSuggestion:-1})),v(`none`),x(void 0);return}c(e=>({commandArgumentHint:void 0,suggestions:n,selectedSuggestion:_C(e.suggestions,e.selectedSuggestion,n)})),v(n.length>0?`file`:`none`),x(void 0)}},[S,c,v,x,s]);(0,Q.useEffect)(()=>(Xm(),Jm(()=>{let e=M.current;e!==null&&(M.current=null,re(e,e===``))})),[re]);let L=ll(re,50),ie=ll((0,Q.useCallback)(async e=>{P.current=e;let t=await rC(C.getState().mcp.clients,e);P.current===e&&(c(e=>({commandArgumentHint:void 0,suggestions:t,selectedSuggestion:_C(e.suggestions,e.selectedSuggestion,t)})),v(t.length>0?`slack-channel`:`none`),x(void 0))},[c]),150),ae=(0,Q.useCallback)(async(t,n)=>{let r=n??j.current;if(f){L.cancel(),I();return}if(o===`prompt`){let n=xS(t,r);if(n&&SS(n.partialCommand,e)){c(()=>({commandArgumentHint:void 0,suggestions:[],selectedSuggestion:-1})),v(`none`),x(void 0);return}}if(o===`bash`&&t.trim()){N.current=t;let e=await RS(t);if(N.current!==t)return;if(e){O({text:e.suffix,fullCommand:e.fullCommand,insertPosition:t.length}),c(()=>({commandArgumentHint:void 0,suggestions:[],selectedSuggestion:-1})),v(`none`),x(void 0);return}else O(void 0)}let i=o===`bash`?null:t.substring(0,r).match(/(^|\s)@([\w-]*)$/);if(i){let e=(i[2]??``).toLowerCase(),t=C.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){L.cancel(),c(e=>({commandArgumentHint:void 0,suggestions:n,selectedSuggestion:_C(e.suggestions,e.selectedSuggestion,n)})),v(`agent`),x(void 0);return}}if(o===`prompt`){let e=t.substring(0,r).match(hC);if(e&&QS(C.getState().mcp.clients)){ie(e[2]);return}else _===`slack-channel`&&(ie.cancel(),I())}let a=t.substring(0,r).match(mC),s=r===t.length&&r>0&&t.length>0&&t[r-1]===` `;if(o===`prompt`&&CS(t)&&r>0){let e=OC(t);if(e&&e.commandName===`add-dir`&&e.args){let{args:t}=e;if(t.match(/\s+$/)){L.cancel(),I();return}let n=await Nm(t);if(n.length>0){c(e=>({suggestions:n,selectedSuggestion:_C(e.suggestions,e.selectedSuggestion,n),commandArgumentHint:void 0})),v(`directory`);return}L.cancel(),I();return}if(e&&e.commandName===`resume`&&e.args!==void 0&&t.includes(` `)){let{args:t}=e,n=(await ls(t,{limit:10})).map(e=>{let t=js(e);return{id:`resume-title-${t}`,displayText:e.customTitle,description:qd(e),metadata:{sessionId:t}}});if(n.length>0){c(e=>({suggestions:n,selectedSuggestion:_C(e.suggestions,e.selectedSuggestion,n),commandArgumentHint:void 0})),v(`custom-title`);return}I();return}}let l=t.substring(0,r);if(o===`prompt`&&CS(l)&&r>0&&!kC(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=fn(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=at(l.slice(n+1));t=dt(o.argNames,e)}c(()=>({commandArgumentHint:t,suggestions:[],selectedSuggestion:-1})),v(`none`),x(void 0);return}}}let n=kS(l,e);c(()=>({commandArgumentHint:t,suggestions:n,selectedSuggestion:n.length>0?0:-1})),v(n.length>0?`command`:`none`),n.length>0&&x(y);return}if(_===`command`?(L.cancel(),I()):CS(l)&&kC(s,l)&&c(e=>e.commandArgumentHint?{...e,commandArgumentHint:void 0}:e),_===`custom-title`&&I(),_===`agent`&&ne.current.some(e=>e.id?.startsWith(`dm-`))&&(t.substring(0,r).match(/(^|\s)@([\w-]*)$/)||I()),a&&o!==`bash`){let e=DC(t,r,!0);if(e?.token.startsWith(`@`)){let t=yC(e);if(Am(t)){te.current=t;let e=await jm(t,{maxResults:10});if(te.current!==t)return;if(e.length>0){c(t=>({suggestions:e,selectedSuggestion:_C(t.suggestions,t.selectedSuggestion,e),commandArgumentHint:void 0})),v(`directory`);return}}if(M.current===t)return;L(t,!0);return}}if(_===`file`){let e=DC(t,r,!0);if(e){let t=yC(e);if(M.current===t)return;L(t,!1)}else L.cancel(),I()}if(_===`shell`){let e=ne.current[0]?.metadata?.inputSnapshot;(o!==`bash`||t!==e)&&(L.cancel(),I())}},[_,e,c,I,L,ie,o,f,y]);(0,Q.useEffect)(()=>{F.current!==i&&(ee.current!==i&&(ee.current=i,M.current=null),F.current=null,ae(i))},[i,ae]);let oe=(0,Q.useCallback)(async()=>{if(A){if(o===`bash`){t(A.fullCommand),r(A.fullCommand.length),O(void 0);return}let e=xS(i,a);if(e){let n=i.slice(0,e.startPos),a=i.slice(e.startPos+e.token.length),o=`${n}/${A.fullCommand} ${a}`,s=e.startPos+1+A.fullCommand.length+1;t(o),r(s);return}}if(l.length>0){L.cancel(),ie.cancel();let e=u===-1?0:u,n=l[e];if(_===`command`&&e<l.length){if(n){let e=n.metadata;if(e&&typeof e==`object`&&`name`in e&&`type`in e){let n=`/${fn(e)} `;t(n+i.slice(a)),r(n.length)}I()}}else if(_===`custom-title`&&l.length>0){if(n){let e=vC(n);t(e),r(e.length),I()}}else if(_===`directory`&&l.length>0){let n=l[e];if(n){let e=CS(i),o;if(e){let e=i.indexOf(` `),a=i.slice(0,e+1),s=gC(n.metadata)&&n.metadata.type===`directory`?`/`:` `;o=a+n.id+s,t(o),r(o.length),gC(n.metadata)&&n.metadata.type===`directory`?(c(e=>({...e,commandArgumentHint:void 0})),ae(o,o.length)):I()}else{let e=DC(i,a,!0)??DC(i,a,!1);if(e){let a=gC(n.metadata)&&n.metadata.type===`directory`,s=EC(i,n.id,e.startPos,e.token.length,a);o=s.newInput,t(o),r(s.cursorPos),a?(c(e=>({...e,commandArgumentHint:void 0})),ae(o,s.cursorPos)):I()}else I()}}}else if(_===`shell`&&l.length>0){let n=l[e];if(n){let e=n.metadata;xC(n,i,a,t,r,e?.completionType),I()}}else if(_===`agent`&&l.length>0&&l[e]?.id?.startsWith(`dm-`)){let n=l[e];n&&(CC(n,i,a,SC,t,r),I())}else if(_===`slack-channel`&&l.length>0){let n=l[e];n&&(CC(n,i,a,hC,t,r),I())}else if(_===`file`&&l.length>0){let n=DC(i,a,!0);if(!n){I();return}let s=Ym(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=bC({displayText:s,mode:o,hasAtPrefix:c,needsQuotes:!1,isQuoted:n.isQuoted,isComplete:!1});Zm(e,i,n.token,n.startPos,t,r),ae(i.replace(n.token,e),a)}else if(e<l.length){let a=l[e];if(a){let e=a.displayText.includes(` `);Zm(bC({displayText:a.displayText,mode:o,hasAtPrefix:c,needsQuotes:e,isQuoted:n.isQuoted,isComplete:!0}),i,n.token,n.startPos,t,r),I()}}}}else if(i.trim()!==``){let e,n;if(o===`bash`){e=`shell`;let o=await TC(i,a);if(o.length===1){let e=o[0];if(e){let n=e.metadata;xC(e,i,a,t,r,n?.completionType)}n=[]}else n=o}else{e=`file`;let t=DC(i,a,!0);if(t){let e=t.token.startsWith(`@`);n=await lC(e?t.token.substring(1):t.token,S,s,e)}else n=[]}n.length>0&&(c(e=>({commandArgumentHint:void 0,suggestions:n,selectedSuggestion:_C(e.suggestions,e.selectedSuggestion,n)})),v(e),x(void 0))}},[l,u,i,_,e,o,t,r,n,I,a,ae,S,c,s,L,ie,A]),se=(0,Q.useCallback)(()=>{if(u<0||l.length===0)return;let s=l[u];if(_===`command`&&u<l.length)s&&(AS(s,!0,e,t,r,n),L.cancel(),I());else if(_===`custom-title`&&u<l.length){if(s){let e=vC(s);t(e),r(e.length),n(e,!0),L.cancel(),I()}}else if(_===`shell`&&u<l.length){let e=l[u];if(e){let n=e.metadata;xC(e,i,a,t,r,n?.completionType),L.cancel(),I()}}else if(_===`agent`&&u<l.length&&s?.id?.startsWith(`dm-`))CC(s,i,a,SC,t,r),L.cancel(),I();else if(_===`slack-channel`&&u<l.length)s&&(CC(s,i,a,hC,t,r),ie.cancel(),I());else if(_===`file`&&u<l.length){let e=DC(i,a,!0);if(e&&s){let n=e.token.startsWith(`@`),a=s.displayText.includes(` `);Zm(bC({displayText:s.displayText,mode:o,hasAtPrefix:n,needsQuotes:a,isQuoted:e.isQuoted,isComplete:!0}),i,e.token,e.startPos,t,r),L.cancel(),I()}}else if(_===`directory`&&u<l.length&&s){if(CS(i)){L.cancel(),I();return}let e=DC(i,a,!0)??DC(i,a,!1);if(e){let n=gC(s.metadata)&&s.metadata.type===`directory`,a=EC(i,s.id,e.startPos,e.token.length,n);t(a.newInput),r(a.cursorPos)}L.cancel(),I()}},[l,u,_,e,i,a,o,t,r,n,I,L,ie]),R=(0,Q.useCallback)(()=>{oe()},[oe]),z=(0,Q.useCallback)(()=>{L.cancel(),ie.cancel(),I(),F.current=i},[L,ie,I,i]),ce=(0,Q.useCallback)(()=>{c(e=>({...e,selectedSuggestion:e.selectedSuggestion<=0?l.length-1:e.selectedSuggestion-1}))},[l.length,c]),le=(0,Q.useCallback)(()=>{c(e=>({...e,selectedSuggestion:e.selectedSuggestion>=l.length-1?0:e.selectedSuggestion+1}))},[l.length,c]),B=(0,Q.useMemo)(()=>({"autocomplete:accept":R,"autocomplete:dismiss":z,"autocomplete:previous":ce,"autocomplete:next":le}),[R,z,ce,le]),ue=l.length>0||!!A,de=Lp();Ip(`autocomplete`,ue),Lc(`Autocomplete`,ue),Tc(B,{context:`Autocomplete`,isActive:ue&&!de});function fe(e){let n=bp(e);if(n!==`prompt`&&m){m(n);let i=ip(e);t(i),r(i.length)}else t(e),r(e.length)}let pe=e=>{if(e.key===`right`&&!T){let t=w.text,n=w.shownAt;if(t&&n>0&&i===``){p(),fe(t),e.stopImmediatePropagation();return}}if(e.key===`tab`&&!e.shift){if(l.length>0||A)return;let t=w.text,n=w.shownAt;if(t&&n>0&&i===``&&!T){e.preventDefault(),p(),fe(t);return}i.trim()===``&&(e.preventDefault(),h({key:`thinking-toggle-hint`,jsx:(0,$.jsxs)(q,{dimColor:!0,children:[`Use `,g,` to toggle thinking`]}),priority:`immediate`,timeoutMs:3e3}));return}if(l.length===0)return;let t=E?.pendingChord!=null;if(e.ctrl&&e.key===`n`&&!t){e.preventDefault(),le();return}if(e.ctrl&&e.key===`p`&&!t){e.preventDefault(),ce();return}e.key===`return`&&!e.shift&&!e.meta&&(e.preventDefault(),se())};return Xc((e,t,n)=>{let r=new Pc(n.keypress);pe(r),r.didStopImmediatePropagation()&&n.stopImmediatePropagation()}),{suggestions:l,selectedSuggestion:u,suggestionType:_,maxColumnWidth:b,commandArgumentHint:d,inlineGhostText:A,handleKeyDown:pe}}ch();var jC={"†":`alt+t`,π:`alt+p`,ø:`alt+o`};function MC(e){return e in jC}hi();function NC(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 PC(e){let t=NC(e);return{nextMode:t,context:T(e.mode,t,e)}}vm(),J(),zp(),gi(),J(),cu(),Rm(),Kd(),Nt(),zp(),Mp(),gi(),J(),Kd(),ah(),zp(),Km(),gi(),J(),cu(),Rm(),Kd(),qs(),J(),fo(),po(),ih();function FC({currentValue:e,onSelect:t,onCancel:n,isMidConversation:r}){let i=$p(),[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`}];Fc(`confirm:no`,()=>{a===null?n?.():o(null)},{context:`Confirmation`}),Fc(`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)(sl,{color:`permission`,children:[(0,$.jsxs)(K,{flexDirection:`column`,children:[(0,$.jsxs)(K,{marginBottom:1,flexDirection:`column`,children:[(0,$.jsx)(q,{color:`remember`,bold:!0,children:`Toggle thinking mode`}),(0,$.jsx)(q,{dimColor:!0,children:`Enable or disable thinking for this session.`})]}),a===null?(0,$.jsx)(K,{flexDirection:`column`,marginBottom:1,children:(0,$.jsx)(nm,{defaultValue:e?`true`:`false`,defaultFocusValue:e?`true`:`false`,options:s,onChange:c,onCancel:n??(()=>{}),visibleOptionCount:2})}):(0,$.jsxs)(K,{flexDirection:`column`,marginBottom:1,gap:1,children:[(0,$.jsx)(q,{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)(q,{color:`warning`,children:`Do you want to proceed?`})]})]}),(0,$.jsx)(q,{dimColor:!0,italic:!0,children:i.pending?(0,$.jsxs)($.Fragment,{children:[`Press `,i.keyName,` again to exit`]}):a===null?(0,$.jsxs)(Mc,{children:[(0,$.jsx)(Sc,{shortcut:`Enter`,action:`confirm`}),(0,$.jsx)(zo,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`exit`})]}):(0,$.jsxs)(Mc,{children:[(0,$.jsx)(Sc,{shortcut:`Enter`,action:`confirm`}),(0,$.jsx)(zo,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]})})]})}ha(),Yh(),qh();function IC(e,t,n){let r=t;for(let t=0;t<n;t++){let t=LC(e,r);if(t.equals(r))break;r=t}return r}function LC(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 RC(e){return`eE$`.includes(e)}function zC(e){return`jkG`.includes(e)||e===`gg`}var BC={"(":[`(`,`)`],")":[`(`,`)`],b:[`(`,`)`],"[":[`[`,`]`],"]":[`[`,`]`],"{":[`{`,`}`],"}":[`{`,`}`],B:[`{`,`}`],"<":[`<`,`>`],">":[`<`,`>`],'"':[`"`,`"`],"'":[`'`,`'`],"`":["`","`"]};function VC(e,t,n,r){if(n===`w`)return HC(e,t,r,fp);if(n===`W`)return HC(e,t,r,e=>!hp(e));let i=BC[n];if(i){let[n,a]=i;return n===a?UC(e,t,n,r):WC(e,t,n,a,r)}return null}function HC(e,t,n,r){let i=[];for(let{segment:t,index:n}of Vd().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=>hp(o(e)),l=e=>r(o(e)),u=e=>lp(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 UC(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 WC(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}}cp(),Hd(),Pd();function GC(e,t,n,r){let i=IC(t,r.cursor,n);if(i.equals(r.cursor))return;let a=rw(r.cursor,i,t,e,n);aw(e,a.from,a.to,r,a.linewise),r.recordChange({type:`operator`,op:e,motion:t,count:n})}function KC(e,t,n,r,i){let a=i.cursor.findCharacter(n,t,r);if(a===null)return;let o=new dp(i.cursor.measuredText,a),s=iw(i.cursor,o,t);aw(e,s.from,s.to,i),i.setLastFind(t,n),i.recordChange({type:`operatorFind`,op:e,find:t,char:n,count:r})}function qC(e,t,n,r,i){let a=VC(i.text,i.cursor.offset,n,t===`inner`);a&&(aw(e,a.start,a.end,i),i.recordChange({type:`operatorTextObj`,op:e,objType:n,scope:t,count:r}))}function JC(e,t,n){let r=n.text,i=r.split(`
|
|
41
|
+
`),a=Fd(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-(Ud(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 YC(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-(Ud(o).length||1));t.setOffset(Math.min(n,s)),t.recordChange({type:`x`,count:e})}function XC(e,t,n){let r=n.cursor.offset,i=n.text;for(let n=0;n<t&&r<i.length;n++){let t=Wd(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 ZC(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=Wd(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 QC(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(nw(s,r)+o),t.recordChange({type:`join`,count:e})}function $C(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(nw(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=Ud(r),c=i+r.length-(s.length||1);n.setText(o),n.setOffset(Math.max(i,c))}}function ew(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(nw(r,i)+s),n.recordChange({type:`indent`,dir:e,count:t})}function tw(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(nw(a,i)),t.recordChange({type:`openLine`,direction:e})}function nw(e,t){return e.slice(0,t).join(`
|
|
57
|
+
`).length+ +(t>0)}function rw(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(zC(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 RC(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 iw(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 aw(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-(Ud(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 ow(e,t,n){let r=t===1?n.cursor.startOfLastLine():n.cursor.goToLine(t);if(r.equals(n.cursor))return;let i=rw(n.cursor,r,`G`,e,t);aw(e,i.from,i.to,n,i.linewise),n.recordChange({type:`operator`,op:e,motion:`G`,count:t})}function sw(e,t,n){let r=t===1?n.cursor.startOfFirstLine():n.cursor.goToLine(t);if(r.equals(n.cursor))return;let i=rw(n.cursor,r,`gg`,e,t);aw(e,i.from,i.to,n,i.linewise),n.recordChange({type:`operator`,op:e,motion:`gg`,count:t})}var cw={d:`delete`,c:`change`,y:`yank`};function lw(e){return e in cw}var uw=new Set([`h`,`l`,`j`,`k`,`w`,`b`,`e`,`W`,`B`,`E`,`0`,`^`,`$`]),dw=new Set([`f`,`F`,`t`,`T`]),fw={i:`inner`,a:`around`};function pw(e){return e in fw}var mw=new Set([`w`,`W`,`"`,`'`,"`",`(`,`)`,`b`,`[`,`]`,`{`,`}`,`B`,`<`,`>`]),hw=1e4;function gw(){return{mode:`INSERT`,insertedText:``}}function _w(){return{lastChange:null,lastFind:null,register:``,registerIsLinewise:!1}}function vw(e,t,n){switch(e.type){case`idle`:return xw(t,n);case`count`:return Sw(e,t,n);case`operator`:return Cw(e,t,n);case`operatorCount`:return ww(e,t,n);case`operatorFind`:return Tw(e,t,n);case`operatorTextObj`:return Ew(e,t,n);case`find`:return Dw(e,t,n);case`g`:return Ow(e,t,n);case`operatorG`:return kw(e,t,n);case`replace`:return Aw(e,t,n);case`indent`:return jw(e,t,n)}}function yw(e,t,n){return lw(e)?{next:{type:`operator`,op:cw[e],count:t}}:uw.has(e)?{execute:()=>{let r=IC(e,n.cursor,t);n.setOffset(r.offset)}}:dw.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:()=>ZC(t,n)}:e===`x`?{execute:()=>YC(t,n)}:e===`J`?{execute:()=>QC(t,n)}:e===`p`||e===`P`?{execute:()=>$C(e===`p`,t,n)}:e===`D`?{execute:()=>GC(`delete`,`$`,1,n)}:e===`C`?{execute:()=>GC(`change`,`$`,1,n)}:e===`Y`?{execute:()=>JC(`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:()=>Mw(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:()=>tw(`below`,n)}:e===`O`?{execute:()=>tw(`above`,n)}:null}function bw(e,t,n,r){return pw(n)?{next:{type:`operatorTextObj`,op:e,count:t,scope:fw[n]}}:dw.has(n)?{next:{type:`operatorFind`,op:e,count:t,find:n}}:uw.has(n)?{execute:()=>GC(e,n,t,r)}:n===`G`?{execute:()=>ow(e,t,r)}:n===`g`?{next:{type:`operatorG`,op:e,count:t}}:null}function xw(e,t){return/[1-9]/.test(e)?{next:{type:`count`,digits:e}}:e===`0`?{execute:()=>t.setOffset(t.cursor.startOfLogicalLine().offset)}:yw(e,1,t)||{}}function Sw(e,t,n){if(/[0-9]/.test(t)){let n=e.digits+t;return{next:{type:`count`,digits:String(Math.min(parseInt(n,10),hw))}}}return yw(t,parseInt(e.digits,10),n)||{next:{type:`idle`}}}function Cw(e,t,n){return t===e.op[0]?{execute:()=>JC(e.op,e.count,n)}:/[0-9]/.test(t)?{next:{type:`operatorCount`,op:e.op,count:e.count,digits:t}}:bw(e.op,e.count,t,n)||{next:{type:`idle`}}}function ww(e,t,n){if(/[0-9]/.test(t)){let n=e.digits+t,r=Math.min(parseInt(n,10),hw);return{next:{...e,digits:String(r)}}}let r=parseInt(e.digits,10),i=e.count*r;return bw(e.op,i,t,n)||{next:{type:`idle`}}}function Tw(e,t,n){return{execute:()=>KC(e.op,e.find,t,e.count,n)}}function Ew(e,t,n){return mw.has(t)?{execute:()=>qC(e.op,e.scope,t,e.count,n)}:{next:{type:`idle`}}}function Dw(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 Ow(e,t,n){return t===`j`||t===`k`?{execute:()=>{let r=IC(`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 kw(e,t,n){return t===`j`||t===`k`?{execute:()=>GC(e.op,`g${t}`,e.count,n)}:t===`g`?{execute:()=>sw(e.op,e.count,n)}:{next:{type:`idle`}}}function Aw(e,t,n){return t===``?{next:{type:`idle`}}:{execute:()=>XC(t,e.count,n)}}function jw(e,t,n){return t===e.dir?{execute:()=>ew(e.dir,e.count,n)}:{next:{type:`idle`}}}function Mw(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)}cp(),Hd();function Nw(e){let t=Q.useRef(gw()),[n,r]=(0,Q.useState)(`INSERT`),i=Q.useRef(_w()),a=sp({...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=dp.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`:YC(t.count,r);break;case`replace`:XC(t.char,t.count,r);break;case`toggleCase`:ZC(t.count,r);break;case`indent`:ew(t.dir,t.count,r);break;case`join`:QC(t.count,r);break;case`openLine`:tw(t.direction,r);break;case`operator`:GC(t.op,t.motion,t.count,r);break;case`operatorFind`:KC(t.op,t.find,t.char,t.count,r);break;case`operatorTextObj`:qC(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=dp.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,-(Ud(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=vw(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}}Yc(),J();function Pw(e){let[t]=Ec(),n=Ic();np(n,!!e.onImagePaste);let r=Nw({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?Kc.inverse:e=>e,themeText:Qc(`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)(K,{flexDirection:`column`,children:(0,$.jsx)(gp,{inputState:r,terminalFocus:n,highlights:e.highlights,...e})})}$s(),Ah(),o();function Fw(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 Iw(e){return`${e.input_tokens}|${e.cache_creation_input_tokens}|${e.cache_read_input_tokens}`}function Lw(e){let t=vg(`sha256`).update(e).digest(`hex`).slice(0,16);return _g(i(),`cache-stats`,`${t}.json`)}var Rw={version:1,signature:null,lastResetAt:null,lastHitRate:null};function zw(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 Bw(e){try{let t=await Dg(e,`utf8`),n=JSON.parse(t);return zw(n)?n:{...Rw}}catch{return{...Rw}}}async function Vw(e,t){await Eg(gg(e),{recursive:!0});let n=`${e}.${process.pid}.tmp`;try{await kg(n,JSON.stringify(t),`utf8`),await Og(n,e)}catch{}}var Hw={signature:null,lastResetAt:null,lastHitRate:null},Uw=null;async function Ww(e){Uw=e;let t=await Bw(Lw(e));Hw={signature:t.signature,lastResetAt:t.lastResetAt,lastHitRate:t.lastHitRate}}function Gw(e){let t=Iw(e),n=Fw(e);return t!==Hw.signature&&(Hw={signature:t,lastResetAt:Date.now(),lastHitRate:n},Uw!==null&&Vw(Lw(Uw),{version:1,signature:t,lastResetAt:Hw.lastResetAt,lastHitRate:n})),{...Hw}}function Kw(){return{...Hw}}J(),Kd(),gi();function qw(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 Jw(){return(0,$.jsx)(q,{dimColor:!0,children:` │ `})}function Yw({modelName:e,contextUsedPct:t,usedTokens:n,contextWindowSize:r,totalCostUsd:i,rateLimits:a}){let{columns:o}=tl(),[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=`${Jd(n)}/${Jd(r)}`;return(0,$.jsxs)(K,{children:[(0,$.jsx)(q,{children:u}),(0,$.jsx)(Jw,{}),(0,$.jsx)(q,{dimColor:!0,children:`Context `}),(0,$.jsxs)(q,{children:[t,`%`]}),!d&&(0,$.jsxs)(q,{dimColor:!0,children:[` (`,g,`)`]}),f&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Jw,{}),(0,$.jsx)(q,{dimColor:!0,children:`Session `}),(0,$.jsxs)(q,{children:[m,`%`]}),!d&&a.five_hour.resets_at>0&&(0,$.jsxs)(q,{dimColor:!0,children:[` `,qw(a.five_hour.resets_at)]})]}),p&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Jw,{}),(0,$.jsx)(q,{dimColor:!0,children:`Weekly `}),(0,$.jsxs)(q,{children:[h,`%`]}),!d&&a.seven_day.resets_at>0&&(0,$.jsxs)(q,{dimColor:!0,children:[` `,qw(a.seven_day.resets_at)]})]}),i>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Jw,{}),(0,$.jsx)(q,{children:ts(i)})]})]})}var Xw=Q.memo(Yw);Bd(),V(),Pl(),Sp(),Oo(),Gm(),Pt(),J(),St(),hd(),uf(),cu(),Cu(),_o(),Nr(),ff(),ni(),Fi(),Kd();var Zw=3600*1e3;function Qw(e){return String(Math.floor(e)).padStart(2,`0`)}function $w(e){if(e<=0)return`exp`;let t=Math.floor(e/6e4),n=Math.floor(e%6e4/1e3);return`${Qw(t)}:${Qw(n)}`}function eT({messages:e}){let[t,n]=(0,Q.useState)(()=>Date.now()),[r,i]=(0,Q.useState)(!0),a=ro(e),o=(0,Q.useRef)(null);if(a!==null){let e=Iw(a);e!==o.current&&(o.current=e,Gw(a))}let{lastResetAt:s,lastHitRate:c}=Kw(),l=s===null?null:t-s,u=l===null?null:Zw-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,Ww(nu()))},[]);let h=a===null?c:Fw(a);if(h===null&&s===null)return(0,$.jsx)(q,{dimColor:!0,children:` Cache --% --:--`});let g=u===null?`--:--`:$w(u),_=h===null?`--%`:`${h}%`,v;return v=f||d===null?`inactive`:d<20?`success`:d<40?`warning`:`error`,(0,$.jsxs)(q,{children:[(0,$.jsx)(q,{dimColor:!0,children:` Cache `}),(0,$.jsx)(q,{color:h!==null&&h>=50?`success`:`inactive`,children:_}),(0,$.jsxs)(q,{color:v,dimColor:p&&!r,children:[` `,g]})]})}function tT(){return null}function nT(e){return e?.statusLineEnabled===!1?!1:e?.statusLineEnabled===!0||!!e?.statusLine?.command}function rT(e,t,n,r,i,a,o){let s=jl(),c=zs(),l=df({permissionMode:e,mainLoopModel:a,exceeds200kTokens:t}),u=n?.outputStyle||`default`,d=ro(r),f=mf(l,Jl()),p=vf(d,f),m=bs(nu()),h=Qe(),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{...Fa(),...m&&{session_name:m},model:{id:l,display_name:Cf(l)},workspace:{current_dir:lu(),project_dir:Fl(),added_dirs:i},version:`0.0.23`,output_style:{name:u},cost:{total_cost_usd:ru(),total_duration_ms:su(),total_api_duration_ms:Ql(),total_lines_added:iu(),total_lines_removed:Ul()},context_window:{total_input_tokens:Yl(),total_output_tokens:Ol(),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},...Dh()&&{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 iT(e){return qr(e)?.uuid??null}function aT({messagesRef:e,lastAssistantMessageId:t,vimMode:n}){let r=(0,Q.useRef)(void 0),i=H(e=>e.toolPermissionContext.mode),a=H(e=>e.toolPermissionContext.additionalWorkingDirectories),o=H(e=>e.statusLineText),s=yc(),c=Wt(),{addNotification:l}=xp(),u=Wm(),d=(0,Q.useRef)(c);d.current=c;let f=(0,Q.useRef)(n);f.current=n;let p=(0,Q.useRef)(i);p.current=i;let m=(0,Q.useRef)(a);m.current=a;let h=(0,Q.useRef)(u);h.current=u;let g=(0,Q.useRef)({messageId:null,exceeds200kTokens:!1,permissionMode:i,vimMode:n,mainLoopModel:u}),_=(0,Q.useRef)(void 0),v=(0,Q.useRef)(!0),y=(0,Q.useCallback)(async()=>{r.current?.abort();let t=new AbortController;r.current=t;let n=e.current,i=v.current;if(v.current=!1,d.current?.statusLine?.command)try{let e=g.current.exceeds200kTokens,r=iT(n);r!==g.current.messageId&&(e=cs(n),g.current.messageId=r,g.current.exceeds200kTokens=e);let a=await Ir(rT(p.current,e,d.current,n,Array.from(m.current.keys()),h.current,f.current),t.signal,void 0,i);t.signal.aborted||s(e=>e.statusLineText===a?e:{...e,statusLineText:a})}catch{}},[e,s]),b=(0,Q.useCallback)(()=>{_.current!==void 0&&clearTimeout(_.current),_.current=setTimeout((e,t)=>{e.current=void 0,t()},300,_,y)},[y]);(0,Q.useEffect)(()=>{(t!==g.current.messageId||i!==g.current.permissionMode||n!==g.current.vimMode||u!==g.current.mainLoopModel)&&(g.current.permissionMode=i,g.current.vimMode=n,g.current.mainLoopModel=u,b())},[t,i,n,u,b]);let x=c?.statusLine?.command,S=(0,Q.useRef)(!0);(0,Q.useEffect)(()=>{if(S.current){S.current=!1;return}v.current=!0,y()},[x,y]),(0,Q.useEffect)(()=>{let e=c?.statusLine;e&&(X(`tengu_status_line_mount`,{command_length:e.command.length,padding:e.padding}),c.disableAllHooks===!0&&Y(`Status line is configured but disableAllHooks is true`,{level:`warn`}),md()||(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)(()=>(y(),()=>{r.current?.abort(),_.current!==void 0&&clearTimeout(_.current)}),[]);let C=c?.statusLine?.padding??0,w=df({permissionMode:i,mainLoopModel:u,exceeds200kTokens:g.current.exceeds200kTokens}),T=mf(w,Jl()),E=ro(e.current),D=E?E.input_tokens+E.cache_creation_input_tokens+E.cache_read_input_tokens:0,O=E?Math.round(vf(E,T).used??0):0,k=Qe(),A={...k.five_hour&&{five_hour:{utilization:k.five_hour.utilization,resets_at:k.five_hour.resets_at}},...k.seven_day&&{seven_day:{utilization:k.seven_day.utilization,resets_at:k.seven_day.resets_at}}},j=c?.statusLineEnabled===!0,M=!!c?.statusLine?.command;return(0,$.jsxs)(K,{flexDirection:`column`,paddingX:C,children:[j&&(0,$.jsxs)(K,{gap:2,children:[(0,$.jsx)(Xw,{modelName:Cf(w),contextUsedPct:O,usedTokens:D,contextWindowSize:T,totalCostUsd:ru(),rateLimits:A}),(0,$.jsx)(tT,{}),(0,$.jsx)(eT,{messages:e.current})]}),o?(0,$.jsx)(q,{dimColor:!0,wrap:`truncate`,children:(0,$.jsx)(Cc,{children:o})}):M&&Za()?(0,$.jsx)(q,{children:` `}):null]})}var oT=(0,Q.memo)(aT);l(),V(),Go(),J();function sT({tasksSelected:e,onOpenDialog:t}){let n=H(e=>e.tasks),r=(0,Q.useMemo)(()=>Object.values(n??{}).filter(e=>ca(e)),[n]);return Kh(n??{},!1)||r.length===0?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(cT,{selected:e,onClick:t,children:$i(r)}),xo(r)&&(0,$.jsxs)(q,{dimColor:!0,children:[` · `,u.arrowDown,` to view`]})]})}function cT({selected:e,onClick:t,children:n}){let[r,i]=(0,Q.useState)(!1),a=(0,$.jsx)(q,{color:`background`,inverse:e||r,children:n});return t?(0,$.jsx)(K,{onClick:t,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),children:a}):a}J(),pp();function lT({value:e,onChange:t,historyFailedMatch:n}){return(0,$.jsxs)(K,{gap:1,children:[(0,$.jsx)(q,{dimColor:!0,children:n?`no matching prompt:`:`search prompts:`}),(0,$.jsx)(vp,{value:e,onChange:t,cursorOffset:e.length,onChangeCursorOffset:()=>{},columns:wc(e)+1,focus:!0,showCursor:!0,multiline:!1,dimColor:!0})]})}_d(),Tu();var uT=5e3;function dT(e,t){if(e)return`draft`;switch(t){case`APPROVED`:return`approved`;case`CHANGES_REQUESTED`:return`changes_requested`;default:return`pending`}}async function fT(){if(!await Fu())return null;let[e,t]=await Promise.all([ed(),Eu()]);if(e===t)return null;let{stdout:n,code:r}=await vd(`gh`,[`pr`,`view`,`--json`,`number,url,reviewDecision,isDraft,headRefName,state`],{timeout:uT,preserveOutputOnError:!1});if(r!==0||!n.trim())return null;try{let e=_u(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:dT(e.isDraft,e.reviewDecision)}}catch{return null}}Pl();var pT=6e4,mT=4e3,hT=60*6e4,gT={number:null,url:null,reviewState:null,lastUpdated:0};function _T(e,t=!0){let[n,r]=(0,Q.useState)(gT),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=Dl();if(n!==t)n=t,s=Date.now();else if(Date.now()-s>=hT)return;let l=Date.now(),u=await fT();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>mT){a.current=!0;return}e||(i.current=setTimeout(c,pT))}}let l=Date.now()-o.current;return l>=pT?c():i.current=setTimeout(c,pT-l),()=>{e=!0,i.current&&(clearTimeout(i.current),i.current=null)}},[e,t]),n}J(),Ah(),la(),Qu(),ha(),ku(),Yh(),V(),gi(),Kd(),an(),ff(),Vf(),hd(),zd(),Gn();var vT=()=>null,yT=5e3,bT=1e3;function xT(){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=Xd(e*1024*1024);t(e=>e?.text===r?e:{text:r,level:n})}e();let n=setInterval(e,yT);return()=>clearInterval(n)},[]),e}function ST(){let e=(0,Q.useSyncExternalStore)(as,st,vT),[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)(q,{dimColor:!0,children:[`waiting `,Yd(t*1e3,{mostSignificantOnly:!0})]})}function CT(){let[t,n]=(0,Q.useState)(0);(0,Q.useEffect)(()=>{let e=setInterval(()=>n(e=>e+1),bT);return()=>clearInterval(e)},[]);let r=(io(),e(us)),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)(q,{color:d,children:[`goal (`,u,`)`]})}function wT({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)(q,{dimColor:!0,children:[`Press `,e.key,` again to exit`]},`exit-message`);if(c)return(0,$.jsx)(q,{dimColor:!0,children:`Pasting text…`},`pasting-message`);let m=Dh()&&t===`INSERT`&&!l;return(0,$.jsxs)(K,{justifyContent:`flex-start`,gap:1,children:[l&&(0,$.jsx)(lT,{value:u,onChange:d,historyFailedMatch:f}),m?(0,$.jsx)(q,{dimColor:!0,children:`-- INSERT --`},`vim-insert`):null,(0,$.jsx)(TT,{mode:n,toolPermissionContext:r,showHint:!i&&!m,isLoading:a,tasksSelected:o,tmuxSelected:s,onOpenTasksDialog:p})]})}function TT({mode:t,toolPermissionContext:n,showHint:r,isLoading:i,tasksSelected:a,tmuxSelected:o,onOpenTasksDialog:s}){let{columns:c}=tl(),l=ta(`chat:cycleMode`,`Chat`,`shift+tab`),u=H(e=>e.tasks);Pn();let d=_T(i,DT()),f=(0,Q.useSyncExternalStore)(as,st,vT),p=Gc(),m=el().getState,h=f!==null,g=(0,Q.useMemo)(()=>Hu(Object.values(u),e=>ca(e)),[u]),_=fm(),v=_!==void 0&&_.length>0,y=ta(`chat:cancel`,`Chat`,`esc`).toLowerCase(),b=ta(`app:toggleTodos`,`Global`,`ctrl+t`),x=ta(`chat:killAgents`,`Chat`,`ctrl+x ctrl+k`),S=H(e=>e.notifications.current?.key===`kill-agents-confirm`),C=xT(),w=(0,Q.useMemo)(()=>Cf(yf()),[H(e=>e.mainLoopModel)]),T=Bf();if(t===`bash`)return(0,$.jsx)(q,{color:`bashBorder`,children:`! for bash mode`});let E=n?.mode,D=!Iu(E),O=g>0,k=+!!D+ +!!O,A=DT()&&d.number!==null&&d.reviewState!==null&&d.url!==null&&k<2&&(k===0||c>=80),j=k<2,M=E&&D?(0,$.jsxs)(q,{color:Du(E),children:[ju(E),` `,Pu(E).toLowerCase(),` on`,j&&(0,$.jsxs)(q,{dimColor:!0,children:[` `,(0,$.jsx)(Sc,{shortcut:l,action:`cycle`,parens:!0})]})]},`mode`):null,ee=[...A?[(0,$.jsx)(ec,{number:d.number,url:d.url,reviewState:d.reviewState},`pr-status`)]:[],...C?[(0,$.jsxs)(q,{dimColor:C.level===`normal`,color:C.level===`error`?`error`:C.level===`warning`?`warning`:void 0,children:[C.text,` · pid:`,process.pid,` · `,w,T?` · ${T}`:``]},`rss`)]:[],...(io(),e(us)).getGoal()?[(0,$.jsx)(CT,{},`goal-elapsed`)]:[]],te=Object.values(u).some(e=>e.type===`local_agent`&&e.status===`running`),N=r?ET(i,y,b,x,v,te,S):[];h?ee.push((0,$.jsx)(ST,{},`proactive`)):r&&ee.push(...N);let P=O&&!Kh(u,!1)?(0,$.jsx)(sT,{tasksSelected:a,onOpenDialog:s}):null;ee.length===0&&!P&&!M&&r&&ee.push((0,$.jsx)(q,{dimColor:!0,children:`? for shortcuts`},`shortcuts-hint`));let ne=gd().copyOnSelect??!0,F=p&&(!ne||Zc());if(Za()&&F){let e=Rd()===`macos`,t=e&&(m()?.lastPressHadAlt??!1);ee.push((0,$.jsx)(q,{dimColor:!0,children:(0,$.jsxs)(Mc,{children:[!ne&&(0,$.jsx)(Sc,{shortcut:`ctrl+c`,action:`copy`}),Zc()&&(t?(0,$.jsx)(q,{children:`set macOptionClickForcesSelection in VS Code settings`}):(0,$.jsx)(Sc,{shortcut:e?`option+click`:`shift+click`,action:`native select`}))]})},`selection-copy`))}return P&&r&&ee.push((0,$.jsx)(q,{dimColor:!0,children:a?(0,$.jsx)(Sc,{shortcut:`Enter`,action:`view tasks`}):(0,$.jsx)(Sc,{shortcut:`↓`,action:`manage`})},`manage-tasks`)),ee.length===0&&!P&&!M?Za()?(0,$.jsx)(q,{children:` `}):null:(0,$.jsxs)(K,{height:1,overflow:`hidden`,children:[M&&(0,$.jsxs)(K,{flexShrink:0,children:[M,(P||ee.length>0)&&(0,$.jsx)(q,{dimColor:!0,children:` · `})]}),P&&(0,$.jsxs)(K,{flexShrink:0,children:[P,ee.length>0&&(0,$.jsx)(q,{dimColor:!0,children:` · `})]}),ee.length>0&&(0,$.jsx)(q,{wrap:`truncate`,children:(0,$.jsx)(Mc,{children:ee})})]})}function ET(e,t,n,r,i,a,o){let s=i;return[...e?[(0,$.jsx)(q,{dimColor:!0,children:(0,$.jsx)(Sc,{shortcut:t,action:`interrupt`})},`esc`)]:[],...!e&&a&&!o?[(0,$.jsx)(q,{dimColor:!0,children:(0,$.jsx)(Sc,{shortcut:r,action:`stop agents`})},`kill-agents`)]:[],...s?[(0,$.jsx)(q,{dimColor:!0,children:(0,$.jsx)(Sc,{shortcut:n,action:`show tasks`})},`toggle-tasks`)]:[]]}function DT(){return gd().prStatusFooterEnabled??!0}Pt(),gi(),J(),an(),Pm(),kh();function OT({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:_,tmuxSelected:v,ideSelection:y,mcpClients:b,isPasting:x=!1,isInputWrapped:S=!1,messages:C,isSearching:w,historyQuery:T,setHistoryQuery:E,historyFailedMatch:D,onOpenTasksDialog:O}){let k=Wt(),{columns:A,rows:j}=tl(),M=(0,Q.useRef)(C);M.current=C;let ee=(0,Q.useMemo)(()=>iT(C),[C]),te=A<80,N=Za(),P=N&&j<24,ne=_,F=h||nT(k)||w;return Lh((0,Q.useMemo)(()=>N&&u.length?{suggestions:u,selectedSuggestion:d,maxColumnWidth:f}:null,[N,u,d,f])),u.length&&!N?(0,$.jsx)(K,{paddingX:2,paddingY:0,children:(0,$.jsx)(Fm,{suggestions:u,selectedSuggestion:d,maxColumnWidth:f})}):m?(0,$.jsx)(jh,{dimColor:!0,fixedWidth:!0,paddingX:2}):(0,$.jsxs)(K,{flexDirection:te?`column`:`row`,justifyContent:te?`flex-start`:`space-between`,paddingX:2,gap:+!te,children:[(0,$.jsxs)(K,{flexDirection:`column`,flexShrink:+!te,children:[i===`prompt`&&!P&&!n.show&&!x&&nT(k)&&(0,$.jsx)(oT,{messagesRef:M,lastAssistantMessageId:ee,vimMode:r}),(0,$.jsx)(AT,{}),(0,$.jsx)(wT,{exitMessage:n,vimMode:r,mode:i,toolPermissionContext:p,suppressHint:F,isLoading:g,tasksSelected:ne,tmuxSelected:v,isPasting:x,isSearching:w,historyQuery:T,setHistoryQuery:E,historyFailedMatch:D,onOpenTasksDialog:O})]}),(0,$.jsx)(K,{flexShrink:1,gap:1,children:N?null:(0,$.jsx)(qx,{apiKeyStatus:e,autoUpdaterResult:a,debug:t,isAutoUpdating:o,verbose:s,messages:C,onAutoUpdaterResult:c,onChangeIsUpdating:l,ideSelection:y,mcpClients:b,isInputWrapped:S,isNarrow:te})})]})}var kT=(0,Q.memo)(OT);function AT(){return null}l(),J();function jT({isLoading:e}){return(0,$.jsxs)(q,{dimColor:e,children:[u.pointer,`\xA0`]})}function MT({mode:e,isLoading:t}){return(0,$.jsx)(K,{alignItems:`flex-start`,alignSelf:`flex-start`,flexWrap:`nowrap`,justifyContent:`flex-start`,children:e===`bash`?(0,$.jsx)(q,{color:`bashBorder`,dimColor:t,children:`!\xA0`}):(0,$.jsx)(jT,{isLoading:t})})}J();var NT=Q.createContext(void 0),PT=2;function FT({isFirst:e,children:t}){let n=PT,r=Q.useMemo(()=>({isQueued:!0,isFirst:e,paddingWidth:n*2}),[e,n]);return(0,$.jsx)(NT.Provider,{value:r,children:(0,$.jsx)(K,{paddingX:n,children:t})})}J(),V(),k(),Nr(),Tu(),Ii();var IT=new Set;function LT(e){try{return _u(e)?.type===`idle_notification`}catch{return!1}}var RT=3;function zT(e){return`<${yd}>
|
|
63
|
+
<${Cd}>+${e} more tasks completed</${Cd}>
|
|
64
|
+
<${Sd}>completed</${Sd}>
|
|
65
|
+
</${yd}>`}function BT(e){let t=e.filter(e=>typeof e.value!=`string`||!LT(e.value)),n=t.filter(e=>e.mode===`task-notification`),r=t.filter(e=>e.mode!==`task-notification`);if(n.length<=RT)return[...r,...n];let i=n.slice(0,RT-1),a={value:zT(n.length-(RT-1)),mode:`task-notification`};return[...r,...i,a]}function VT(){let e=Ix(),t=H(e=>!!e.viewingAgentTaskId),n=(0,Q.useMemo)(()=>{if(e.length===0)return null;let t=e.filter(Ot);return t.length===0?null:Ts(BT(t).map(e=>{let t=e.value;return e.mode===`bash`&&typeof t==`string`&&(t=`<bash-input>${t}</bash-input>`),Lo({content:t})}))},[e]);return t||n===null?null:(0,$.jsx)(K,{marginTop:1,flexDirection:`column`,children:n.map((e,t)=>(0,$.jsx)(FT,{isFirst:t===0,children:(0,$.jsx)(co,{message:e,lookups:bn,addMargin:!1,tools:[],commands:[],verbose:!1,inProgressToolUseIDs:IT,progressMessagesForMessage:[],shouldAnimate:!1,shouldShowDot:!1,isTranscriptMode:!1,isStatic:!0})},t))})}var HT=Q.memo(VT);pr(),l(),J();function UT({hasStash:e}){return e?(0,$.jsx)(K,{paddingLeft:2,children:(0,$.jsxs)(q,{dimColor:!0,children:[u.pointerSmall,` Stashed (auto-restores after submit)`]})}):null}Mp();var WT=1e4,GT=1e3;function KT(e,t){if(e.length<=WT)return{truncatedText:e,placeholderContent:``};let n=Math.floor(GT/2),r=e.slice(0,n),i=e.slice(-500),a=e.slice(n,-500);return{truncatedText:r+qT(t,Ap(a))+i,placeholderContent:a}}function qT(e,t){return`[...Truncated text #${e} +${t} lines...]`}function JT(e,t){let n=Object.keys(t).map(Number),r=n.length>0?Math.max(...n)+1:1,{truncatedText:i,placeholderContent:a}=KT(e,r);return a?{newInput:i,newPastedContents:{...t,[r]:{id:r,type:`text`,content:a}}}:{newInput:e,newPastedContents:t}}function YT({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}=JT(e,t);n(s),r(s.length),i(c),o(!0)},[e,a,t,n,i,r]),(0,Q.useEffect)(()=>{e===``&&o(!1)},[e])}V(),hd(),k(),qo();var XT=3;function ZT({input:e,submitCount:t}){let n=Ix(),r=H(e=>e.promptSuggestionEnabled);return(0,Q.useMemo)(()=>{if(e===``){if(n.some(ka)&&(gd().queuedCommandUpHintCount||0)<XT)return`Press up to edit queued messages`;if(t<1&&r&&!jr())return Qh()}},[e,n,t,r])}var QT=5e3,$T=!1;function eE(e){let[t,n]=(0,Q.useState)(!1);return(0,Q.useEffect)(()=>{if($T||!e)return;$T=!0,n(!0);let t=setTimeout(n,QT,!1);return()=>{clearTimeout(t),n(!1)}},[e]),t}Yc(),Sp(),Bd(),V(),cu(),k(),Dc(),Ut(),zp(),Uh(),Mp(),Gm(),gi(),J(),Xr(),rc(),fo(),Rs(),ku(),cp(),hd(),Cu(),id(),mu(),an(),Ct(),Td(),ff(),zd(),Hm(),po(),pp(),Yh(),ep(),Ah();var tE=5,nE=3;function rE({debug:e,ideSelection:t,toolPermissionContext:n,setToolPermissionContext:r,apiKeyStatus:i,commands:a,agents:o,isLoading:s,verbose:c,messages:l,onAutoUpdaterResult:u,autoUpdaterResult:d,input:f,onInputChange:p,mode:m,onModeChange:h,stashedPrompt:g,setStashedPrompt:_,submitCount:v,onShowMessageSelector:y,onMessageActionsEnter:b,mcpClients:x,pastedContents:S,setPastedContents:C,vimMode:w,setVimMode:T,showBashesDialog:E,setShowBashesDialog:D,onExit:O,getToolUseContext:k,onSubmit:A,isSearchingHistory:j,setIsSearchingHistory:M,onDismissSideQuestion:ee,isSideQuestionVisible:te,helpOpen:N,setHelpOpen:P,hasSuppressedDialogs:ne,isLocalJSXCommandActive:F=!1,insertTextRef:I}){let re=Wm(),L=Lp()||F,[ie,ae]=(0,Q.useState)(!1),[oe,se]=(0,Q.useState)({show:!1}),[R,z]=(0,Q.useState)(f.length),ce=Q.useRef(f);f!==ce.current&&(z(f.length),ce.current=f);let le=Q.useCallback(e=>{ce.current=e,p(e)},[p]);I&&(I.current={cursorOffset:R,insert:e=>{let t=R===f.length&&f.length>0&&!/\s$/.test(f)?` ${e}`:e,n=f.slice(0,R)+t+f.slice(R);ce.current=n,p(n),z(R+t.length)},setInputWithCursor:(e,t)=>{ce.current=e,p(e),z(t)}});let B=Pn(),ue=yc(),de=H(e=>e.tasks),fe=Ix(),pe=H(e=>e.promptSuggestion),me=H(e=>e.speculation),he=H(e=>e.speculationSessionTimeSavedMs),ge=H(e=>e.mainLoopModel),_e=H(e=>e.mainLoopModelForSession),ve=H(e=>e.thinkingEnabled),ye=H(e=>$d()?e.fastMode:!1),be=H(e=>e.viewingAgentTaskId);H(e=>e.viewSelectionMode);let{historyQuery:xe,setHistoryQuery:Se,historyMatch:Ce,historyFailedMatch:we}=nS(e=>{C(e.pastedContents),zt(e.display)},f,le,z,R,h,m,j,M,C,S),Te=(0,Q.useRef)(-1);Te.current===-1&&(Te.current=iE(l));let Ee=(0,Q.useRef)(!1),De=H(e=>e.selectedBgAgentIndex),Oe=(0,Q.useCallback)(e=>ue(t=>{let n=typeof e==`function`?e(t.selectedBgAgentIndex):e;return n===t.selectedBgAgentIndex?t:{...t,selectedBgAgentIndex:n}}),[ue]),[ke,Ae]=(0,Q.useState)(!1),[je,Me]=(0,Q.useState)(!1),[Ne,Pe]=(0,Q.useState)(!1),[Fe,Ie]=(0,Q.useState)(!1),[Le,Re]=(0,Q.useState)(!1),[ze,Be]=(0,Q.useState)(!1),[Ve,Ue]=(0,Q.useState)(!1),[We,Ge]=(0,Q.useState)(!1),qe=(0,Q.useMemo)(()=>{let e=f.indexOf(`
|
|
66
|
+
`);return e===-1||R<=e},[f,R]),Je=(0,Q.useMemo)(()=>{let e=f.lastIndexOf(`
|
|
67
|
+
`);return e===-1||R>e},[f,R]),Ye=(0,Q.useMemo)(()=>Hu(Object.values(de),e=>e.status===`running`),[de])>0&&!Kh(de,!1),Xe=tS(),Ze=Xe.length>0,V=(0,Q.useMemo)(()=>[Ze&&`bg_agent`,Ye&&`tasks`].filter(Boolean),[Ze,Ye]),Qe=H(e=>e.footerSelection),$e=Qe&&V.includes(Qe)?Qe:null;(0,Q.useEffect)(()=>{Qe&&!$e&&ue(e=>e.footerSelection===null?e:{...e,footerSelection:null})},[Qe,$e,ue]);let et=$e===`tasks`,tt=$e===`tmux`,nt=$e===`bg_agent`;function rt(e){ue(t=>t.footerSelection===e?t:{...t,footerSelection:e}),e===`bg_agent`&&Oe(-1)}function it(e,t=!1){let n=$e?V.indexOf($e):-1,r=V[n+e];return r?(rt(r),!0):e<0&&t?(rt(null),!0):!1}let{suggestion:at,markAccepted:ot,logOutcomeAtSubmission:st,markShown:ct}=iS({inputValue:f,isAssistantResponding:s}),lt=(0,Q.useMemo)(()=>j&&Ce?ip(typeof Ce==`string`?Ce:Ce.display):f,[j,Ce,f]),ut=(0,Q.useMemo)(()=>Ke(lt),[lt]),dt=(0,Q.useMemo)(()=>ym(lt),[lt]),ft=(0,Q.useMemo)(()=>MS(lt).filter(e=>At(lt.slice(e.start+1,e.end),a)),[lt,a]),pt=(0,Q.useMemo)(()=>[],[lt]),mt=(0,Q.useMemo)(()=>QS(B.getState().mcp.clients)?eC(lt):[],[lt,(0,Q.useSyncExternalStore)(WS,$S)]),ht=(0,Q.useMemo)(()=>Op(lt).filter(e=>e.match.startsWith(`[Image`)).map(e=>({start:e.index,end:e.index+e.match.length})),[lt]),gt=ht.some(e=>e.start===R);(0,Q.useEffect)(()=>{let e=ht.find(e=>R>e.start&&R<e.end);if(e){let t=(e.start+e.end)/2;z(R<t?e.start:e.end)}},[R,ht,z]);let _t=(0,Q.useMemo)(()=>{let e=[];for(let t of ht)R===t.start&&e.push({start:t.start,end:t.end,color:void 0,inverse:!0,priority:8});j&&Ce&&!we&&e.push({start:R,end:R+xe.length,color:`warning`,priority:20});for(let t of dt)e.push({start:t.start,end:t.end,color:`warning`,priority:15});for(let t of ft)e.push({start:t.start,end:t.end,color:`suggestion`,priority:5});for(let t of pt)e.push({start:t.start,end:t.end,color:`suggestion`,priority:5});for(let t of mt)e.push({start:t.start,end:t.end,color:`suggestion`,priority:5});if(He())for(let t of ut)for(let n=t.start;n<t.end;n++)e.push({start:n,end:n+1,color:ar(n-t.start),shimmerColor:ar(n-t.start,!0),priority:10});return e},[j,xe,Ce,we,R,dt,ht,ft,pt,mt,lt,ut]),{addNotification:vt,removeNotification:yt}=xp();(0,Q.useEffect)(()=>{ut.length&&He()?vt({key:`ultrathink-active`,text:`Ultrathink active for this turn`,priority:`immediate`,timeoutMs:5e3}):yt(`ultrathink-active`)},[vt,yt,ut.length]);let bt=(0,Q.useRef)(f.length),xt=(0,Q.useRef)(f.length),St=(0,Q.useCallback)(()=>{yt(`stash-hint`)},[yt]);(0,Q.useEffect)(()=>{let e=bt.current,t=xt.current,n=f.length;if(bt.current=n,n>t){xt.current=n;return}if(n===0){xt.current=0;return}t>=20&&n<=5&&!(e>=20&&n<=5)&&(gd().hasUsedStash||vt({key:`stash-hint`,jsx:(0,$.jsxs)(q,{dimColor:!0,children:[`Tip: `,(0,$.jsx)(zo,{action:`chat:stash`,context:`Chat`,fallback:`ctrl+s`,description:`stash`})]}),priority:`immediate`,timeoutMs:Kx}),xt.current=n)},[f.length,vt]);let{pushToBuffer:Ct,undo:wt,canUndo:Tt,clearBuffer:Et}=rS({maxBufferSize:50,debounceMs:1e3});YT({input:f,pastedContents:S,onInputChange:le,setCursorOffset:z,setPastedContents:C});let Dt=ZT({input:f,submitCount:v}),Ot=(0,Q.useCallback)(e=>{if(e===`?`){X(`tengu_help_toggled`,{}),P(e=>!e);return}P(!1),St(),on(),sa(ue);let t=e.length===f.length+1,n=R===0,r=bp(e);if(n&&r!==`prompt`){if(t){h(r);return}if(f.length===0){h(r);let t=ip(e).replaceAll(` `,` `);Ct(f,R,S),le(t),z(t.length);return}}let i=e.replaceAll(` `,` `);f!==i&&Ct(f,R,S),ue(e=>e.footerSelection===null?e:{...e,footerSelection:null}),le(i)},[le,h,f,R,Ct,S,St,ue]),{resetHistory:kt,onHistoryUp:jt,onHistoryDown:Mt,dismissSearchHint:Nt,historyIndex:Pt}=eS((e,t,n)=>{Ot(e),h(t),C(n)},f,S,z,m);(0,Q.useEffect)(()=>{j&&Nt()},[j,Nt]);function Ft(){if(!(Bt.length>1)&&qe){if(fe.some(ka)){Qt();return}jt()}}function U(){if(!(Bt.length>1)&&Je&&Mt()&&V.length>0){let e=V[0];rt(e),e===`tasks`&&!gd().hasSeenTasksHint&&pd(e=>e.hasSeenTasksHint?e:{...e,hasSeenTasksHint:!0})}}let[It,Lt]=(0,Q.useState)({suggestions:[],selectedSuggestion:-1,commandArgumentHint:void 0}),Rt=(0,Q.useCallback)(e=>{Lt(t=>typeof e==`function`?e(t):e)},[]),zt=(0,Q.useCallback)(async(e,t=!1)=>{e=e.trimEnd();let n=B.getState();if(n.footerSelection&&V.includes(n.footerSelection)||n.viewSelectionMode===`selecting-agent`)return;let r=Object.values(S).some(e=>e.type===`image`),i=pe.text;if((e.trim()===``||e===i)&&i&&!r&&!n.viewingAgentTaskId){if(me.status===`active`){ot(),st(i,{skipReset:!0}),A(i,{setCursorOffset:z,clearBuffer:Et,resetHistory:kt},{state:me,speculationSessionTimeSavedMs:he,setAppState:ue});return}pe.shownAt>0&&(ot(),e=i)}if(e.trim()===``&&!r)return;let a=It.suggestions.length>0&&It.suggestions.every(e=>e.description===`directory`);if(It.suggestions.length>0&&!t&&!a){Y(`[onSubmit] early return: suggestions showing (count=${It.suggestions.length})`);return}pe.text&&pe.shownAt>0&&st(e),yt(`stash-hint`),await A(e,{setCursorOffset:z,clearBuffer:Et,resetHistory:kt})},[pe,me,he,B,V,It.suggestions,A,Et,kt,st,ue,ot,S,yt]),{suggestions:Bt,selectedSuggestion:Vt,commandArgumentHint:Ht,inlineGhostText:Ut,maxColumnWidth:Wt}=AC({commands:a,onInputChange:le,onSubmit:zt,setCursorOffset:z,input:f,cursorOffset:R,mode:m,agents:o,setSuggestionsState:Rt,suggestionsState:It,suppressSuggestions:j||Pt>0,markAccepted:ot,onModeChange:h}),Gt=m===`prompt`&&Bt.length===0&&at&&!be;Gt&&ct(),pe.text&&!at&&pe.shownAt===0&&!be&&(Pa(`timing`,pe.text),ue(e=>({...e,promptSuggestion:{text:null,promptId:null,shownAt:0,acceptedAt:0,generationRequestId:null}})));function qt(e,t,n,r,i){X(`tengu_paste_image`,{}),h(`prompt`);let a=Te.current++,o={id:a,type:`image`,content:e,mediaType:t||`image/png`,filename:n||`Pasted image`,dimensions:r,sourcePath:i};Kt(o),G(o),C(e=>({...e,[a]:o})),Xt((Ee.current?` `:``)+jp(a)),Ee.current=!0}(0,Q.useEffect)(()=>{let e=new Set(Op(f).map(e=>e.id));C(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,C]);function Jt(e){Ee.current=!1;let t=il(e).replace(/\r/g,`
|
|
68
|
+
`).replaceAll(` `,` `);if(f.length===0){let e=bp(t);e!==`prompt`&&(h(e),t=ip(t))}let n=Ap(t),r=Math.min(gn-10,2);if(t.length>800||n>r){let e=Te.current++,r={id:e,type:`text`,content:t};C(t=>({...t,[e]:r})),Xt(Dp(e,n))}else Xt(t)}let Yt=(0,Q.useCallback)((e,t)=>Ee.current?(Ee.current=!1,Oh(e,t)?` ${e}`:e):e,[]);function Xt(e){Ct(f,R,S);let t=f.slice(0,R)+e+f.slice(R);le(t),z(R+e.length)}let Zt=Jc(()=>{},()=>y()),Qt=(0,Q.useCallback)(()=>{let e=dn(f,R);return e?(le(e.text),h(`prompt`),z(e.cursorOffset),e.images.length>0&&C(t=>{let n={...t};for(let t of e.images)n[t.id]=t;return n}),!0):!1},[le,h,f,R,C]);zx(x,e=>{X(`tengu_ext_at_mentioned`,{});let t,n=lg.relative(lu(),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[R-1]??` `;/\s/.test(r)||(t=` ${t}`),Xt(t)});let $t=(0,Q.useCallback)(()=>{if(Tt){let e=wt();e&&(le(e.text),z(e.cursorOffset),C(e.pastedContents))}},[Tt,wt,le,C]),en=(0,Q.useCallback)(()=>{Ct(f,R,S);let e=`${f.slice(0,R)}\n${f.slice(R)}`;le(e),z(R+1)},[f,R,le,z,Ct,S]),tn=(0,Q.useCallback)(async()=>{X(`tengu_external_editor_used`,{}),Me(!0);try{let e=await Bm(f,S);e.error&&vt({key:`external-editor-error`,text:e.error,color:`warning`,priority:`high`}),e.content!==null&&e.content!==f&&(Ct(f,R,S),le(e.content),z(e.content.length))}catch(e){e instanceof Error&&Dd(e),vt({key:`external-editor-error`,text:`External editor failed: ${hu(e)}`,color:`warning`,priority:`high`})}finally{Me(!1)}},[f,R,S,Ct,le,vt]),nn=(0,Q.useCallback)(()=>{f.trim()===``&&g!==void 0?(le(g.text),z(g.cursorOffset),C(g.pastedContents),_(void 0)):f.trim()!==``&&(_({text:f,cursorOffset:R,pastedContents:S}),le(``),z(0),C({}),pd(e=>e.hasUsedStash?e:{...e,hasUsedStash:!0}))},[f,R,g,le,_,S,C]),rn=(0,Q.useCallback)(()=>{Pe(e=>!e),N&&P(!1)},[N]),an=(0,Q.useCallback)(()=>{Ue(e=>!e),N&&P(!1)},[N]),sn=(0,Q.useCallback)(()=>{Ge(e=>!e),N&&P(!1)},[N]),cn=(0,Q.useCallback)(()=>{Y(`[auto-mode] handleCycleMode: currentMode=${n.mode}`);let e=NC(n),{context:t}=PC(n);X(`tengu_mode_cycle`,{to:e}),e===`plan`&&pd(e=>({...e,lastPlanModeUse:Date.now()})),ue(n=>({...n,toolPermissionContext:{...t,mode:e}})),r({...t,mode:e}),N&&P(!1)},[n,ue,r,N]),ln=(0,Q.useCallback)(()=>{tp().then(e=>{if(e)qt(e.base64,e.mediaType);else{let e=Ms(`chat:imagePaste`,`Chat`,`ctrl+v`),t=Wu.isSSH()?`No image found in clipboard. You're SSH'd; try scp?`:`No image found in clipboard. Use ${e} to paste images.`;vt({key:`no-image-in-clipboard`,text:t,priority:`immediate`,timeoutMs:1e3})}})},[vt,qt]),un=zc();(0,Q.useEffect)(()=>{if(!(!un||L))return un.registerHandler({action:`chat:submit`,context:`Chat`,handler:()=>{zt(f)}})},[un,L,zt,f]),Tc((0,Q.useMemo)(()=>({"chat:undo":$t,"chat:newline":en,"chat:externalEditor":tn,"chat:stash":nn,"chat:modelPicker":rn,"chat:thinkingToggle":sn,"chat:cycleMode":cn,"chat:imagePaste":ln}),[$t,en,tn,nn,rn,sn,cn,ln]),{context:`Chat`,isActive:!L}),Fc(`chat:messageActions`,()=>b?.(),{context:`Chat`,isActive:!L&&!j}),Fc(`chat:fastMode`,an,{context:`Chat`,isActive:!L&&$d()&&of()}),Fc(`help:dismiss`,()=>{P(!1)},{context:`Help`,isActive:N}),Fc(`app:quickOpen`,()=>{},{context:`Global`,isActive:!1}),Fc(`app:globalSearch`,()=>{},{context:`Global`,isActive:!1}),Fc(`history:search`,()=>{},{context:`Global`,isActive:!1}),Fc(`app:interrupt`,()=>{sa(ue)},{context:`Global`,isActive:!s&&me.status===`active`}),Tc({"footer:up":()=>{if(nt){De>-1?Oe(e=>e-1):rt(null);return}it(-1,!0)},"footer:down":()=>{if(nt){De<Xe.length-1&&Oe(e=>e+1);return}if(et){D(!0),rt(null);return}it(1)},"footer:next":()=>{it(1)},"footer:previous":()=>{it(-1)},"footer:openSelected":()=>{switch($e){case`tasks`:D(!0),rt(null);break;case`tmux`:break;case`bg_agent`:break}},"footer:clearSelection":()=>{rt(null)},"footer:close":()=>!1},{context:`Footer`,isActive:!!$e&&!L}),Xc((e,t)=>{if(!(Fe||Le||ze)){if(Rd()===`macos`&&MC(e)){let t=jC[e],n=wp();vt({key:`option-meta-hint`,jsx:n?(0,$.jsxs)(q,{dimColor:!0,children:[`To enable `,t,`, set `,(0,$.jsx)(q,{bold:!0,children:`Option as Meta`}),` in `,n,` preferences (⌘,)`]}):(0,$.jsxs)(q,{dimColor:!0,children:[`To enable `,t,`, run /terminal-setup`]}),priority:`immediate`,timeoutMs:5e3})}if($e&&e&&!t.ctrl&&!t.meta&&!t.escape&&!t.return){Ot(f.slice(0,R)+e+f.slice(R)),z(R+e.length);return}if(R===0&&(t.escape||t.backspace||t.delete||t.ctrl&&e===`u`)&&(h(`prompt`),P(!1)),N&&f===``&&(t.backspace||t.delete)&&P(!1),t.escape){if(me.status===`active`){sa(ue);return}if(te&&ee){ee();return}if(N){P(!1);return}if($e)return;if(fe.some(ka)){Qt();return}l.length>0&&!f&&!s&&Zt()}t.return&&N&&P(!1)}});let fn=$d()?sf():!1,pn=$d()?ye&&(of()||fn):!1,mn=eE(pn??!1),{columns:hn,rows:gn}=tl(),_n=hn-3,vn=Za()?Math.max(nE,Math.floor(gn/2)-tE):void 0,yn=(0,Q.useCallback)(e=>{if(!f||j)return;let t=dp.fromText(f,_n,R),n=t.getViewportStartLine(vn),r=t.measuredText.getOffsetFromPosition({line:e.localRow+n,column:e.localCol});z(r)},[f,_n,j,R,vn]),bn=(0,Q.useCallback)(e=>D(e??!0),[D]),xn=Gt&&at?at:Dt,Sn=(0,Q.useMemo)(()=>f.includes(`
|
|
69
|
+
`),[f]),Cn=(0,Q.useCallback)(e=>{let t=!1;ue(n=>(t=$d()&&!rf(e)&&!!n.fastMode,{...n,mainLoopModel:e,mainLoopModelForSession:null,...t&&{fastMode:!1}})),Pe(!1);let n=(ye??!1)&&!t,r=`Model set to ${pf(e)}`;oh(e,n,_f())&&(r+=` · Billed as extra usage`),t&&(r+=` · Fast mode OFF`),vt({key:`model-switched`,jsx:(0,$.jsx)(q,{children:r}),priority:`immediate`,timeoutMs:3e3}),X(`tengu_model_picker_hotkey`,{model:e})},[ue,vt,ye]),wn=(0,Q.useCallback)(()=>{Pe(!1)},[]),Tn=(0,Q.useMemo)(()=>Ne?(0,$.jsx)(K,{flexDirection:`column`,marginTop:1,children:(0,$.jsx)(sh,{initial:ge,sessionModel:_e,onSelect:Cn,onCancel:wn,isStandaloneCommand:!0,showFastModeNotice:$d()&&ye&&rf(ge)&&of()})}):null,[Ne,ge,_e,Cn,wn]),En=(0,Q.useCallback)(e=>{Ue(!1),e&&vt({key:`fast-mode-toggled`,jsx:(0,$.jsx)(q,{children:e}),priority:`immediate`,timeoutMs:3e3})},[vt]),Dn=(0,Q.useMemo)(()=>Ve?(0,$.jsx)(K,{flexDirection:`column`,marginTop:1,children:(0,$.jsx)(Sh,{onDone:En,unavailableReason:af()})}):null,[Ve,En]),On=(0,Q.useCallback)(e=>{ue(t=>({...t,thinkingEnabled:e})),Ge(!1),X(`tengu_thinking_toggled_hotkey`,{enabled:e}),vt({key:`thinking-toggled-hotkey`,jsx:(0,$.jsxs)(q,{color:e?`suggestion`:void 0,dimColor:!e,children:[`Thinking `,e?`on`:`off`]}),priority:`immediate`,timeoutMs:3e3})},[ue,vt]),kn=(0,Q.useCallback)(()=>{Ge(!1)},[]),An=(0,Q.useMemo)(()=>We?(0,$.jsx)(K,{flexDirection:`column`,marginTop:1,children:(0,$.jsx)(FC,{currentValue:ve??!0,onSelect:On,onCancel:kn,isMidConversation:l.some(e=>e.type===`assistant`)})}):null,[We,ve,On,kn,l.length]);if(zh(null),E)return(0,$.jsx)(Xh,{onDone:()=>D(!1),toolUseContext:k(l,[],new AbortController,re),initialDetailTaskId:typeof E==`string`?E:void 0});if(Tn)return Tn;if(Dn)return Dn;if(An)return An;let jn={multiline:!0,onSubmit:zt,onChange:Ot,value:Ce?ip(typeof Ce==`string`?Ce:Ce.display):f,onHistoryUp:Ft,onHistoryDown:U,onHistoryReset:kt,placeholder:xn,onExit:O,onExitMessage:(e,t)=>se({show:e,key:t}),onImagePaste:qt,columns:_n,maxVisibleLines:vn,disableCursorMovementForUpDownKeys:Bt.length>0||!!$e,disableEscapeDoublePress:Bt.length>0,cursorOffset:R,onChangeCursorOffset:z,onPaste:Jt,onIsPastingChange:Ae,focus:!j&&!L&&!$e,showCursor:!$e&&!j&&!gt,argumentHint:Ht,onUndo:Tt?()=>{let e=wt();e&&(le(e.text),z(e.cursorOffset),C(e.pastedContents))}:void 0,highlights:_t,inlineGhostText:Ut,inputFilter:Yt},W=()=>{let e={bash:`bashBorder`};return e[m]?e[m]:`promptBorder`};if(je)return(0,$.jsx)(K,{flexDirection:`row`,alignItems:`center`,justifyContent:`center`,borderColor:W(),borderStyle:`round`,borderLeft:!1,borderRight:!1,borderBottom:!0,width:`100%`,children:(0,$.jsx)(q,{dimColor:!0,italic:!0,children:`Save and close editor to continue...`})});let Mn=Dh()?(0,$.jsx)(Pw,{...jn,initialMode:w,onModeChange:T}):(0,$.jsx)(vp,{...jn});return(0,$.jsxs)(K,{flexDirection:`column`,marginTop:1,children:[!Za()&&(0,$.jsx)(HT,{}),ne&&(0,$.jsx)(K,{marginTop:1,marginLeft:2,children:(0,$.jsx)(q,{dimColor:!0,children:`Waiting for permission…`})}),(0,$.jsx)(UT,{hasStash:g!==void 0}),(0,$.jsxs)(K,{flexDirection:`row`,alignItems:`flex-start`,justifyContent:`flex-start`,borderColor:W(),borderStyle:`round`,borderLeft:!1,borderRight:!1,borderBottom:!0,width:`100%`,borderText:aE(pn??!1,mn,fn),children:[(0,$.jsx)(MT,{mode:m,isLoading:s}),(0,$.jsx)(K,{flexGrow:1,flexShrink:1,onClick:yn,children:Mn})]}),(0,$.jsx)(kT,{apiKeyStatus:i,debug:e,exitMessage:oe,vimMode:Dh()?w:void 0,mode:m,autoUpdaterResult:d,isAutoUpdating:ie,verbose:c,onAutoUpdaterResult:u,onChangeIsUpdating:ae,suggestions:Bt,selectedSuggestion:Vt,maxColumnWidth:Wt,toolPermissionContext:n,helpOpen:N,suppressHint:f.length>0,isLoading:s,tasksSelected:et,tmuxSelected:tt,ideSelection:t,mcpClients:x,isPasting:ke,isInputWrapped:Sn,messages:l,isSearching:j,historyQuery:xe,setHistoryQuery:Se,historyFailedMatch:we,onOpenTasksDialog:Za()?bn:void 0}),Za()?(0,$.jsx)(K,{position:`absolute`,marginTop:-1,height:+(Bt.length===0),width:`100%`,paddingLeft:2,paddingRight:1,flexDirection:`column`,justifyContent:`flex-end`,overflow:`hidden`,children:(0,$.jsx)(qx,{apiKeyStatus:i,autoUpdaterResult:d,debug:e,isAutoUpdating:ie,verbose:c,messages:l,onAutoUpdaterResult:u,onChangeIsUpdating:ae,ideSelection:t,mcpClients:x,isInputWrapped:Sn})}):null]})}function iE(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=Op(e.text);for(let e of n)e.id>t&&(t=e.id)}}}return t+1}function aE(e,t,n){if(e)return{content:` ${t?`${bh(!0,n)} ${Kc.dim(`/fast`)}`:bh(!0,n)} `,position:`top`,align:`end`,offset:0}}var oE=Q.memo(rE);Pd();var sE=400;function cE({inputValue:e,setInputValue:t,isValidDigit:n,onDigit:r,enabled:i=!0,once:a=!1,debounceMs:o=sE}){let s=(0,Q.useRef)(e),c=(0,Q.useRef)(!1),l=(0,Q.useRef)(null),u=(0,Q.useRef)({setInputValue:t,isValidDigit:n,onDigit:r});u.current={setInputValue:t,isValidDigit:n,onDigit:r},(0,Q.useEffect)(()=>{if(!(!i||a&&c.current)){if(l.current!==null&&(clearTimeout(l.current),l.current=null),e!==s.current){let t=Id(e.slice(-1));if(u.current.isValidDigit(t)){let n=e.slice(0,-1);l.current=setTimeout((e,t,n,r,i)=>{e.current=null,t.current=!0,n.current.setInputValue(r),n.current.onDigit(i)},o,l,c,u,n,t)}}return()=>{l.current!==null&&(clearTimeout(l.current),l.current=null)}}},[e,i,a,o])}J();var lE=[`0`,`1`,`2`,`3`],uE={0:`dismissed`,1:`bad`,2:`fine`,3:`good`},dE=e=>lE.includes(e),fE=`How is Work Mate doing this session? (optional)`;function pE({onSelect:e,inputValue:t,setInputValue:n,message:r=fE}){return cE({inputValue:t,setInputValue:n,isValidDigit:dE,onDigit:t=>e(uE[t])}),(0,$.jsxs)(K,{flexDirection:`column`,marginTop:1,children:[(0,$.jsxs)(K,{children:[(0,$.jsx)(q,{color:`ansi:cyan`,children:`● `}),(0,$.jsx)(q,{bold:!0,children:r})]}),(0,$.jsxs)(K,{marginLeft:2,children:[(0,$.jsx)(K,{width:10,children:(0,$.jsxs)(q,{children:[(0,$.jsx)(q,{color:`ansi:cyan`,children:`1`}),`: Bad`]})}),(0,$.jsx)(K,{width:10,children:(0,$.jsxs)(q,{children:[(0,$.jsx)(q,{color:`ansi:cyan`,children:`2`}),`: Fine`]})}),(0,$.jsx)(K,{width:10,children:(0,$.jsxs)(q,{children:[(0,$.jsx)(q,{color:`ansi:cyan`,children:`3`}),`: Good`]})}),(0,$.jsx)(K,{children:(0,$.jsxs)(q,{children:[(0,$.jsx)(q,{color:`ansi:cyan`,children:`0`}),`: Dismiss`]})})]})]})}J(),Pd();function mE({isOpen:e,skillName:t,updates:n,handleSelect:r,inputValue:i,setInputValue:a}){return!e||i&&!dE(i)?null:(0,$.jsx)(_E,{skillName:t,updates:n,onSelect:r,inputValue:i,setInputValue:a})}var hE=[`0`,`1`];function gE(e){return hE.includes(e)}function _E({skillName:e,updates:t,onSelect:n,inputValue:r,setInputValue:i}){let a=(0,Q.useRef)(r);return(0,Q.useEffect)(()=>{if(r!==a.current){let e=Id(r.slice(-1));gE(e)&&(i(r.slice(0,-1)),n(e===`1`?`good`:`dismissed`))}},[r,n,i]),(0,$.jsxs)(K,{flexDirection:`column`,marginTop:1,children:[(0,$.jsxs)(K,{children:[(0,$.jsxs)(q,{color:`ansi:cyan`,children:[Uu,` `]}),(0,$.jsxs)(q,{bold:!0,children:[`Skill improvement suggested for "`,e,`"`]})]}),(0,$.jsx)(K,{flexDirection:`column`,marginLeft:2,children:t.map((e,t)=>(0,$.jsxs)(q,{dimColor:!0,children:[`∙`,` `,e.change]},t))}),(0,$.jsxs)(K,{marginLeft:2,marginTop:1,children:[(0,$.jsx)(K,{width:12,children:(0,$.jsxs)(q,{children:[(0,$.jsx)(q,{color:`ansi:cyan`,children:`1`}),`: Apply`]})}),(0,$.jsx)(K,{width:14,children:(0,$.jsxs)(q,{children:[(0,$.jsx)(q,{color:`ansi:cyan`,children:`0`}),`: Dismiss`]})})]})]})}Bd(),V(),Nr();function vE(e){let t=H(e=>e.skillImprovement.suggestion),n=yc(),[r,i]=(0,Q.useState)(!1),a=(0,Q.useRef)(t),o=(0,Q.useRef)(!1);t&&(a.current=t),t&&!r&&(i(!0),o.current||(o.current=!0,X(`tengu_skill_improvement_survey`,{event_type:`appeared`,_PROTO_skill_name:t.skillName??`unknown`})));let s=(0,Q.useCallback)(t=>{let r=a.current;if(!r)return;let s=t!==`dismissed`;X(`tengu_skill_improvement_survey`,{event_type:`responded`,response:s?`applied`:`dismissed`,_PROTO_skill_name:r.skillName}),s&&ag(r.skillName,r.updates).then(()=>{e(e=>[...e,Cs(`Skill "${r.skillName}" updated with improvements.`,`suggestion`)])}),i(!1),o.current=!1,n(e=>e.skillImprovement.suggestion?{...e,skillImprovement:{suggestion:null}}:e)},[n,e]);return{isOpen:r,suggestion:a.current,handleSelect:s}}function yE(e){return{onBeforeQuery:async()=>!0,onTurnComplete:async()=>{},render:()=>null}}W(),Ja(),mi();function bE(){return!1}function xE(){return!1}Oo();function SE(e){(0,Q.useEffect)(()=>{let t=()=>{bE()&&process.stdout.write(`\n${ga()}\n`),Ti(e?.())};return process.on(`exit`,t),()=>{process.off(`exit`,t)}},[])}function CE(){(0,Q.useEffect)(()=>{},[])}function wE(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 TE(){let[e]=(0,Q.useState)(`valid`),[t]=(0,Q.useState)(null);return{status:e,reverify:(0,Q.useCallback)(async()=>{},[]),error:t}}Pl(),J(),cu(),Cu(),J(),fo(),Bd(),V();function EE({screen:e,setScreen:t,showAllInTranscript:n,setShowAllInTranscript:r,messageCount:i,onEnterTranscript:a,onExitTranscript:o,virtualScrollActive:s,searchBarOpen:c=!1}){let l=H(e=>e.expandedView),u=yc(),d=(0,Q.useCallback)(()=>{X(`tengu_toggle_todos`,{is_expanded:l===`tasks`}),u(e=>({...e,expandedView:e.expandedView===`tasks`?`none`:`tasks`}))},[l,u]),f=(0,Q.useCallback)(()=>{let s=e!==`transcript`;X(`tengu_toggle_transcript`,{is_entering:s,show_all:n,message_count:i}),t(e=>e===`transcript`?`prompt`:`transcript`),r(!1),s&&a&&a(),!s&&o&&o()},[e,t,n,r,i,u,a,o]),p=(0,Q.useCallback)(()=>{X(`tengu_transcript_toggle_show_all`,{is_expanding:!n,message_count:i}),r(e=>!e)},[n,r,i]),m=(0,Q.useCallback)(()=>{X(`tengu_transcript_exit`,{show_all:n,message_count:i}),t(`prompt`),r(!1),o&&o()},[t,n,r,i,o]);Fc(`app:toggleTodos`,d,{context:`Global`}),Fc(`app:toggleTranscript`,f,{context:`Global`}),Fc(`app:toggleTerminal`,(0,Q.useCallback)(()=>{},[]),{context:`Global`}),Fc(`app:redraw`,(0,Q.useCallback)(()=>{jc.get(process.stdout)?.forceRedraw()},[]),{context:`Global`});let h=e===`transcript`;return Fc(`transcript:toggleShowAll`,p,{context:`Transcript`,isActive:h&&!s}),Fc(`transcript:exit`,m,{context:`Transcript`,isActive:h&&!c}),null}zp(),Xr(),fo();var DE={setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}};function OE({onSubmit:e,isActive:t=!0}){let n=zc(),r=Lp(),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 Tc((0,Q.useMemo)(()=>{let t={};for(let n of i){let r=n.slice(8);t[n]=()=>{e(`/${r}`,DE,void 0,{fromKeybinding:!0})}}return t},[i,e]),{context:`Chat`,isActive:t&&!r}),null}Bd(),V(),Ah(),Sp(),zp(),rc(),fo(),Qi(),k();var kE=3e3;function AE(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=Pn(),g=yc(),_=Ix().length,{addNotification:v,removeNotification:y}=xp(),b=(0,Q.useRef)(0),x=(0,Q.useCallback)(()=>{let e={source:`escape`,streamMode:m};if(o!==void 0&&!o.aborted){X(`tengu_cancel`,e),t(()=>[]),n();return}if(qa()&&s){s();return}X(`tengu_cancel`,e),t(()=>[]),n()},[o,s,t,n,m]),S=Rp(),C=o!==void 0&&!o.aborted,w=_>0,T=f!==void 0&&f!==`prompt`&&!p,E=a!==`transcript`&&!u&&!i&&!l&&!d&&!S&&!(Dh()&&c===`INSERT`),D=E&&(C||w)&&!T,O=E&&(C||w);Fc(`chat:cancel`,x,{context:`Chat`,isActive:D});let k=(0,Q.useCallback)(()=>{let e=h.getState().tasks,t=Object.entries(e).filter(([,e])=>e.type===`local_agent`&&e.status===`running`);if(t.length===0)return!1;bo(e,g);let n=[];for(let[e,r]of t)ma(e,g),n.push(r.description),oc(e,`stopped`,{toolUseId:r.toolUseId,summary:r.description});return Zn({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 Fc(`app:interrupt`,(0,Q.useCallback)(()=>{(C||w)&&x()},[C,w,x]),{context:`Global`,isActive:O}),Fc(`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<=kE){b.current=0,y(`kill-agents-confirm`),X(`tengu_cancel`,{source:`kill_agents`}),Ys(),k();return}b.current=t;let n=Ms(`chat:killAgents`,`Chat`,`ctrl+x ctrl+k`);v({key:`kill-agents-confirm`,text:`Press ${n} again to stop background agents`,priority:`immediate`,timeoutMs:kE})},[h,v,y,k]),{context:`Chat`}),null}J(),V(),ha();function jE(e){let t=H(e=>e.tasks),n=Object.values(t).some(ca),r=t=>{if(t.shift&&(t.key===`up`||t.key===`down`)){t.preventDefault(),n&&e?.onOpenBackgroundTasks?.();return}};return Xc((e,t,n)=>{r(new Pc(n.keypress))}),{handleKeyDown:r}}Td();async function ME(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?Dd(e):Dd(Error(`Automated permission check failed: ${String(e)}`))}return null}Bd(),f(),B(),Cu(),_o(),Nr(),Ya(),ct();function NE(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 PE(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){Jo({tool:e,input:a?.input??t,toolUseContext:n,messageId:s,toolUseID:i},r,a?.permissionPromptStartTimeMs)},logCancelled(){X(`tengu_tool_use_cancelled`,{messageID:s,toolName:p(e.name)})},async persistPermissions(e){return e.length===0?!1:(Ma(e),a(fe(n.getAppState().toolPermissionContext,e)),e.some(e=>Mt(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?_e:Vs}${t}`:a?Kn:ie,s=a?o:Yr(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 I(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 FE(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))}}}Cu(),J(),B(),oe(),mu();function IE(e,t){let{ctx:n,description:r,result:i,awaitAutomatedChecksBeforeDialog:a}=e,{resolve:o,isResolved:s,claim:c}=NE(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 ee(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))})()}J(),B(),oe(),Cu(),mu(),Td(),or(),ct();function LE(e,t){return(0,Q.useCallback)(async(n,r,i,a,o,s)=>new Promise(c=>{let l=PE(n,r,i,a,o,t,FE(e));if(!l.resolveIfAborted(c))return(s===void 0?ee(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`:Jo({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 ME({ctx:l,updatedInput:e.updatedInput,suggestions:e.suggestions,permissionMode:t.toolPermissionContext.mode});if(n){c(n);return}}if(l.resolveIfAborted(c))return;IE({ctx:l,description:a,result:e,awaitAutomatedChecksBeforeDialog:t.toolPermissionContext.awaitAutomatedChecksBeforeDialog},c);return}}).catch(e=>{e instanceof fu||e instanceof yu?(Y(`Permission check threw ${e.constructor.name} for tool=${n.name}: ${e.message}`),l.logCancelled(),c(l.cancelAndAbort(void 0,!0))):(Dd(e),c(l.cancelAndAbort(void 0,!0)))}).finally(()=>{})}),[e,t])}ja(),Bd(),Ut(),Mp(),cu(),Cu(),mu(),Td(),k(),ff();function RE(){ra(0)}async function zE(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){ic(),await BE({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(Op(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(ws);if(T.trim()===``)return;if(!b&&[`exit`,`quit`,`:q`,`:q!`,`:wq`,`:wq!`].includes(T.trim())){i.find(e=>e.name===`exit`)?zE({...e,input:`/exit`}):RE();return}let j=kp(T,k),M=Op(T).filter(e=>k[e.id]?.type===`text`),ee=M.length;if(X(`tengu_paste_text`,{pastedTextCount:ee,pastedTextBytes:M.reduce((e,t)=>e+(k[t.id]?.content.length??0),0)}),!b&&j.trim().startsWith(`/`)){let t=j.trim(),d=t.indexOf(` `),f=d===-1?t.slice(1):t.slice(1,d),p=d===-1?``:t.slice(d+1).trim(),m=i.find(e=>e.immediate&&Ze(e)&&(e.name===f||e.aliases?.includes(f)||fn(e)===f));if(m&&m.type===`local-jsx`&&(n.isActive||r)){X(`tengu_immediate_command_executed`,{commandName:m.name}),a(``),S(0),o({}),C();let t=c(l,[],Ss(),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?Us({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}`),X(`tengu_cancel`,{source:`interrupt_on_submit`,streamMode:e.streamMode}),e.abortController?.abort(`interrupt`)),Us({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}ic(),await BE({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 BE(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=Ss();l(g);function _(){return s(t,[],g,n)}try{a.reserve(),Ns(`query_process_user_input_start`);let s=[],v=!1,y,b,x,S,C=h??[],w=await ns(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 nf(D,async()=>{for(let e=0;e<C.length;e++){let n=C[e],a=e===0,l=n.autonomy?.runId,u=await Xp({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(Ns(`query_process_user_input_end`),wn()&&(Ns(`query_file_history_snapshot_start`),s.filter(Jp).forEach(e=>{ys(e=>{d(t=>({...t,fileHistory:e(t.fileHistory)}))},e.uuid)}),Ns(`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?Sf(b,n):n,i?f:void 0,r)}else a.cancelReservation(),o({jsx:null,shouldHidePromptInput:!1,clearLocalJSX:!0}),p(),l(null);x&&(S?Us({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 va({commands:e,outcome:{type:`failed`,error:k},currentDir:lu(),priority:`later`,workload:D})}catch(e){Dd(vu(e))}else try{let t=await va({commands:e,outcome:{type:`completed`},currentDir:lu(),priority:`later`,workload:D});for(let e of t)Us(e)}catch(e){Dd(vu(e))}}if(k)throw k}finally{a.cancelReservation(),c(void 0)}}k();function VE(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 HE({executeInput:e}){let t=e=>e.agentId===void 0,n=Vt(t);if(!n)return{processed:!1};if(VE(n)||n.mode===`bash`)return e([Bn(t)]),{processed:!0};let r=n.mode,i=se(e=>t(e)&&!VE(e)&&e.mode===r);return i.length===0?{processed:!1}:(e(i),{processed:!0})}k();function UE({executeQueuedInput:e,hasActiveLocalJsxUI:t,queryGuard:n}){let r=(0,Q.useSyncExternalStore)(n.subscribe,n.getSnapshot),i=(0,Q.useSyncExternalStore)(Xe,ue);(0,Q.useEffect)(()=>{r||t||i.length!==0&&HE({executeInput:e})},[i,r,e,t,n])}function WE(e,t){return e&&t&&t.length>0?Ba([...e,...t],`name`):e||[]}function GE(e,t){return(0,Q.useMemo)(()=>WE(e,t),[e,t])}Ie(),Kp(),Lm(),Yt();function KE(e,t){return(0,Q.useMemo)(()=>t.length>0?Ba([...e,...t],`name`):e,[e,t])}Ut(),Td();function qE(e,t){let n=(0,Q.useCallback)(async()=>{if(e)try{Ws(),t(await tn(e))}catch(e){e instanceof Error&&Dd(e)}},[e,t]);(0,Q.useEffect)(()=>Tm.subscribe(n),[n])}Td(),El(),cn(),Cl();var JE=wl(()=>ml({method:gl(`selection_changed`),params:ml({selection:ml({start:ml({line:_l(),character:_l()}),end:ml({line:_l(),character:_l()})}).nullable().optional(),text:vl().optional(),filePath:vl().optional()})}));function YE(e,t){let n=(0,Q.useRef)(!1),r=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{let i=E(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(JE(),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){Dd(e)}}),n.current=!0},[e,t])}As(),Qt(),J(),Gh(),V(),Kd();function XE({task:e,selected:t}){let n=Jh(e.startTime,e.status===`running`),r=e.progress?.tokenCount??0;return(0,$.jsxs)(K,{flexDirection:`row`,width:`100%`,justifyContent:`space-between`,children:[(0,$.jsxs)(K,{flexDirection:`row`,flexShrink:1,children:[(0,$.jsx)(q,{color:e.status===`running`?`success`:void 0,children:t?`● `:`○ `}),(0,$.jsxs)(q,{bold:t,wrap:`truncate-end`,children:[e.agentType,` `,(0,$.jsx)(q,{dimColor:!0,children:e.description})]})]}),(0,$.jsx)(K,{flexShrink:0,children:(0,$.jsxs)(q,{dimColor:!0,children:[n,` · ↓ `,Jd(r),` tokens`]})})]})}function ZE(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 QE(){let e=tS(),t=H(e=>e.viewingAgentTaskId),n=H(e=>e.footerSelection),r=H(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)(K,{flexDirection:`column`,width:`100%`,children:[(0,$.jsxs)(K,{flexDirection:`row`,width:`100%`,justifyContent:`space-between`,children:[(0,$.jsxs)(q,{bold:o,children:[o?`● `:`○ `,`main`]}),(0,$.jsx)(q,{dimColor:!0,children:ZE(i,s)})]}),e.map(e=>(0,$.jsx)(XE,{task:e,selected:e.agentId===a},e.agentId))]})}Ed(),cu(),ui(),Cu(),qo();var $E=3e4;function eD(e){let t=(0,Q.useRef)(e);t.current=e,(0,Q.useEffect)(()=>{if(!jr())return;let e=null,n=!1,r=!1;function i(){xs(Date.now()+$E),e=setTimeout(()=>{if(e=null,!To()){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 Ao({basePrompt:`<${xd}>${new Date().toLocaleTimeString()}</${xd}>`,currentDir:lu(),shouldCreate:()=>!n});if(n){await Co({commands:e});return}let r=[];try{for(let n of e)t.current.onQueueTick(n),r.push(n)}catch(t){throw await Co({commands:e.filter(e=>!r.includes(e))}),t}})().catch(e=>Y(`[Proactive] failed to create tick: ${e}`,{level:`error`})).finally(()=>{r=!1}),i()},$E)}return i(),()=>{n=!0,e!==null&&(clearTimeout(e),e=null),xs(null)}},[jr(),xr(),et()])}_n(),io();function tD(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 nD(e){let t=ya(e),n=tD(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 rD(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>`}Cu(),io(),k();function iD(e){Y(`[goal] hook: ${e}`)}function aD(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?.()){iD(`skip: queryActiveNow=true`);return}if(e.wasAborted){iD(`skip: wasAborted=true`);return}if(n.current)return;if(ue().length>0){iD(`skip: yielding to queued user messages`);return}if(e.hasActiveLocalJsxUI){iD(`skip: activeLocalJsxUI`);return}if(e.isInPlanMode){iD(`skip: planMode`);return}let t=Mo();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=rD(t);Y(`[goal] hook: budget limit reached, injecting wrap-up prompt`),Us({value:e,mode:`prompt`,priority:`now`,isMeta:!0,origin:`goal-budget-limit`,skipSlashCommands:!0});return}if(t.status!==`active`){iD(`skip: status="${t.status}" (not active)`);return}if(t.turnsExecuted>=150){Os()&&(_(),e.onMaxTurnsReached?.()),Y(`[goal] hook: MAX_GOAL_TURNS (150) reached, stopping`);return}n.current=!0;let i=Di();_();let a=nD(t);Y(`[goal] hook: enqueuing turn ${i} for "${t.objective.slice(0,60)}"`),Us({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])}hd(),o(),cn();function oD({autoConnectIdeFlag:e,ideToInstallExtension:t,setDynamicMcpConfig:n,setShowIdeOnboarding:i,setIDEInstallationState:o}){(0,Q.useEffect)(()=>{function s(i){i&&(gd().autoConnectIde||e||ht()||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`}})}De(s,t,()=>i(!0),e=>o(e))},[e,t,n,i,o])}_h(),Fp(),J(),fo(),la(),V(),hd(),id(),o();function sD({onBackgroundSession:e,isLoading:t}){let n=yc(),r=Pn(),[i,o]=(0,Q.useState)(!1),s=Jc(o,e,()=>{}),c=(0,Q.useCallback)(()=>{a(process.env.CLAUDE_CODE_DISABLE_BACKGROUND_TASKS)||(Vo(r.getState())?(Xi(()=>r.getState(),n),gd().hasUsedBackgroundTask||pd(e=>e.hasUsedBackgroundTask?e:{...e,hasUsedBackgroundTask:!0})):a(`false`)&&t&&s())},[n,r,t,s]),l=H(Vo),u=a(`false`);Fc(`task:background`,c,{context:`Task`,isActive:l||u&&t});let d=ta(`task:background`,`Task`,`ctrl+b`),f=Wu.terminal===`tmux`&&d===`ctrl+b`?`ctrl+b ctrl+b`:d;return!t||!i?null:(0,$.jsx)(K,{paddingLeft:2,children:(0,$.jsx)(q,{dimColor:!0,children:(0,$.jsx)(Sc,{shortcut:f,action:`background`})})})}V();function cD({setMessages:e,setIsLoading:t,resetLoadingState:n,setAbortController:r,onBackgroundQuery:i}){let a=H(e=>e.foregroundedTaskId),o=H(e=>e.foregroundedTaskId?e.tasks[e.foregroundedTaskId]:void 0),s=yc(),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}}sr(),Up();function lD(e,t){return t}Pl(),Nr(),gi(),J(),fo(),br(),Bs(),Cu(),id(),Nu(),Td(),ni(),Tu(),Yo(),po(),pp();function uD(e){let t=e;return t=t.replace(/"(sk-ant[^\s"']{24,})"/g,`"[REDACTED_API_KEY]"`),t=t.replace(/(?<![A-Za-z0-9"'])(sk-ant-?[A-Za-z0-9_-]{10,})(?![A-Za-z0-9"'])/g,`[REDACTED_API_KEY]`),t=t.replace(/AWS key: "(AWS[A-Z0-9]{20,})"/g,`AWS key: "[REDACTED_AWS_KEY]"`),t=t.replace(/(AKIA[A-Z0-9]{16})/g,`[REDACTED_AWS_KEY]`),t=t.replace(/(?<![A-Za-z0-9])(AIza[A-Za-z0-9_-]{35})(?![A-Za-z0-9])/g,`[REDACTED_GCP_KEY]`),t=t.replace(/(?<![A-Za-z0-9])([a-z0-9-]+@[a-z0-9-]+\.iam\.gserviceaccount\.com)(?![A-Za-z0-9])/g,`[REDACTED_GCP_SERVICE_ACCOUNT]`),t=t.replace(/(["']?x-api-key["']?\s*[:=]\s*["']?)[^"',\s)}\]]+/gi,`$1[REDACTED_API_KEY]`),t=t.replace(/(["']?authorization["']?\s*[:=]\s*["']?(bearer\s+)?)[^"',\s)}\]]+/gi,`$1[REDACTED_TOKEN]`),t=t.replace(/(AWS[_-][A-Za-z0-9_]+\s*[=:]\s*)["']?[^"',\s)}\]]+["']?/gi,`$1[REDACTED_AWS_VALUE]`),t=t.replace(/(GOOGLE[_-][A-Za-z0-9_]+\s*[=:]\s*)["']?[^"',\s)}\]]+["']?/gi,`$1[REDACTED_GCP_VALUE]`),t=t.replace(/((API[-_]?KEY|TOKEN|SECRET|PASSWORD)\s*[=:]\s*)["']?[^"',\s)}\]]+["']?/gi,`$1[REDACTED]`),t}h(),Cu(),mu(),Zd(),Nr(),ni(),Tu();async function dD(e,t,n){try{Y(`Collecting transcript for sharing`,{level:`info`});let r=Mi(e),i=await Gt(it(e)),a;try{let e=Uo(),{size:t}=await Sg(e);t<=52428800?a=await bg(e,`utf-8`):Y(`Skipping raw transcript read: file too large (${t} bytes)`,{level:`warn`})}catch{}let o=uD(du({trigger:t,version:`0.0.23`,platform:process.platform,transcript:r,subagentTranscripts:Object.keys(i).length>0?i:void 0,rawTranscriptJsonl:a})),s=Qd();if(s.error)return{success:!1};let c={"Content-Type":`application/json`,"User-Agent":hf(),...s.headers},l=await m.post(`https://api.anthropic.com/api/claude_code_shared_session_transcripts`,{content:o,appearance_id:n},{headers:c,timeout:3e4});if(l.status===200||l.status===201){let e=l.data;return Y(`Transcript shared successfully`,{level:`info`}),{success:!0,transcriptId:e?.transcript_id}}return{success:!1}}catch(e){return Y(hu(e),{level:`error`}),{success:!1}}}function fD({hideThanksAfterMs:e,onOpen:t,onSelect:n,shouldShowTranscriptPrompt:r,onTranscriptPromptShown:i,onTranscriptSelect:a}){let[o,s]=(0,Q.useState)(`closed`),[c,l]=(0,Q.useState)(null),u=(0,Q.useRef)(yg()),d=(0,Q.useRef)(null),f=(0,Q.useCallback)(()=>{s(`thanks`),setTimeout((e,t)=>{e(`closed`),t(null)},e,s,l)},[e]),p=(0,Q.useCallback)(()=>{s(`submitted`),setTimeout(s,e,`closed`)},[e]);return{state:o,lastResponse:c,open:(0,Q.useCallback)(()=>{o===`closed`&&(s(`open`),u.current=yg(),t(u.current))},[o,t]),handleSelect:(0,Q.useCallback)(e=>{if(l(e),d.current=e,n(u.current,e),e===`dismissed`)s(`closed`),l(null);else if(r?.(e))return s(`transcript_prompt`),i?.(u.current,e),!0;else f();return!1},[f,n,r,i]),handleTranscriptSelect:(0,Q.useCallback)(e=>{switch(e){case`yes`:s(`submitting`),(async()=>{try{await a?.(u.current,e,d.current)?p():f()}catch{f()}})();break;case`no`:case`dont_ask_again`:a?.(u.current,e,d.current),f();break}},[f,p,a])}}Bd(),hd(),o(),Nr(),ff(),Zu();var pD={minTimeBeforeFeedbackMs:6e5,minTimeBetweenFeedbackMs:36e5,minTimeBetweenGlobalFeedbackMs:1e8,minUserTurnsBeforeFeedback:5,minUserTurnsBetweenFeedback:10,hideThanksAfterMs:3e3,onForModels:[`*`],probability:.005},mD={probability:0};function hD(e,t,n,r=`session`,i=!1){let o=(0,Q.useRef)(`unknown`);o.current=qr(e)?.message?.id||`unknown`;let[s,c]=(0,Q.useState)(()=>({timeLastShown:null,submitCountAtLastAppearance:null})),l=lD(`tengu_feedback_survey_config`,pD),u=lD(`tengu_bad_survey_transcript_ask_config`,mD),d=lD(`tengu_good_survey_transcript_ask_config`,mD),f=sd().feedbackSurveyRate,p=(0,Q.useRef)(Date.now()),m=(0,Q.useRef)(n),h=(0,Q.useRef)(n);h.current=n;let g=(0,Q.useRef)(e);g.current=e;let _=(0,Q.useRef)(!1),v=(0,Q.useRef)(null),y=(0,Q.useCallback)((e,t)=>{c(n=>n.timeLastShown===e&&n.submitCountAtLastAppearance===t?n:{timeLastShown:e,submitCountAtLastAppearance:t}),gd().feedbackSurveyState?.lastShownTime!==e&&pd(t=>({...t,feedbackSurveyState:{lastShownTime:e}}))},[]),b=(0,Q.useCallback)(e=>{y(Date.now(),h.current),X(`tengu_feedback_survey_event`,{event_type:`appeared`,appearance_id:e,last_assistant_message_id:o.current,survey_type:r}),Jf(`feedback_survey`,{event_type:`appeared`,appearance_id:e,survey_type:r})},[y,r]),x=(0,Q.useCallback)((e,t)=>{y(Date.now(),h.current),X(`tengu_feedback_survey_event`,{event_type:`responded`,appearance_id:e,response:t,last_assistant_message_id:o.current,survey_type:r}),Jf(`feedback_survey`,{event_type:`responded`,appearance_id:e,response:t,survey_type:r})},[y,r]),S=(0,Q.useCallback)(e=>{if(e!==`bad`&&e!==`good`||gd().transcriptShareDismissed||!$h(`allow_product_feedback`))return!1;let t=e===`bad`?u.probability:d.probability;return Math.random()<=t},[u.probability,d.probability]),C=(0,Q.useCallback)((e,t)=>{let n=t===`good`?`good_feedback_survey`:`bad_feedback_survey`;X(`tengu_feedback_survey_event`,{event_type:`transcript_prompt_appeared`,appearance_id:e,last_assistant_message_id:o.current,survey_type:r,trigger:n}),Jf(`feedback_survey`,{event_type:`transcript_prompt_appeared`,appearance_id:e,survey_type:r})},[r]),w=(0,Q.useCallback)(async(e,t,n)=>{let i=n===`good`?`good_feedback_survey`:`bad_feedback_survey`;if(X(`tengu_feedback_survey_event`,{event_type:`transcript_share_${t}`,appearance_id:e,last_assistant_message_id:o.current,survey_type:r,trigger:i}),t===`dont_ask_again`&&pd(e=>({...e,transcriptShareDismissed:!0})),t===`yes`){let t=await dD(g.current,i,e);return X(`tengu_feedback_survey_event`,{event_type:t.success?`transcript_share_submitted`:`transcript_share_failed`,appearance_id:e,trigger:i}),t.success}return!1},[r]),{state:T,lastResponse:E,open:D,handleSelect:O,handleTranscriptSelect:k}=fD({hideThanksAfterMs:l.hideThanksAfterMs,onOpen:b,onSelect:x,shouldShowTranscriptPrompt:S,onTranscriptPromptShown:C,onTranscriptSelect:w}),A=yf(),j=(0,Q.useMemo)(()=>l.onForModels.length===0?!1:l.onForModels.includes(`*`)?!0:l.onForModels.includes(A),[l.onForModels,A]),M=(0,Q.useMemo)(()=>{if(T!==`closed`||t||i)return!1;if(process.env.CLAUDE_FORCE_DISPLAY_SURVEY&&!s.timeLastShown)return!0;if(!j||a(process.env.CLAUDE_CODE_DISABLE_FEEDBACK_SURVEY)||Wf()||!$h(`allow_product_feedback`))return!1;if(s.timeLastShown){if(Date.now()-s.timeLastShown<l.minTimeBetweenFeedbackMs||s.submitCountAtLastAppearance!==null&&n<s.submitCountAtLastAppearance+l.minUserTurnsBetweenFeedback)return!1}else if(Date.now()-p.current<l.minTimeBeforeFeedbackMs||n<m.current+l.minUserTurnsBeforeFeedback)return!1;if(v.current!==n&&(v.current=n,_.current=Math.random()<=(f??l.probability)),!_.current)return!1;let e=gd().feedbackSurveyState;return!(e?.lastShownTime&&Date.now()-e.lastShownTime<l.minTimeBetweenGlobalFeedbackMs)},[T,t,i,j,s.timeLastShown,s.submitCountAtLastAppearance,n,l.minTimeBetweenFeedbackMs,l.minTimeBetweenGlobalFeedbackMs,l.minUserTurnsBetweenFeedback,l.minTimeBeforeFeedbackMs,l.minUserTurnsBeforeFeedback,l.probability,f]);return(0,Q.useEffect)(()=>{M&&D()},[M,D]),{state:T,lastResponse:E,handleSelect:O,handleTranscriptSelect:k}}Hf(),Bd(),hd(),o(),Nr(),Zf();var gD=3e3,_D=`tengu_memory_survey_event`,vD=`memory_survey`;function yD(e,t,n=!1,{enabled:r=!0}={}){let i=(0,Q.useRef)(new Set),a=(0,Q.useRef)(!1),o=(0,Q.useRef)(e);o.current=e;let{state:s,lastResponse:c,open:l,handleSelect:u,handleTranscriptSelect:d}=fD({hideThanksAfterMs:gD,onOpen:(0,Q.useCallback)(e=>{X(_D,{event_type:`appeared`,appearance_id:e}),Jf(`feedback_survey`,{event_type:`appeared`,appearance_id:e,survey_type:`memory`})},[]),onSelect:(0,Q.useCallback)((e,t)=>{X(_D,{event_type:`responded`,appearance_id:e,response:t}),Jf(`feedback_survey`,{event_type:`responded`,appearance_id:e,response:t,survey_type:`memory`})},[]),shouldShowTranscriptPrompt:(0,Q.useCallback)(e=>!1,[]),onTranscriptPromptShown:(0,Q.useCallback)(e=>{X(_D,{event_type:`transcript_prompt_appeared`,appearance_id:e,trigger:vD}),Jf(`feedback_survey`,{event_type:`transcript_prompt_appeared`,appearance_id:e,survey_type:`memory`})},[]),onTranscriptSelect:(0,Q.useCallback)(async(e,t)=>{if(X(_D,{event_type:`transcript_share_${t}`,appearance_id:e,trigger:vD}),t===`dont_ask_again`&&pd(e=>({...e,transcriptShareDismissed:!0})),t===`yes`){let t=await dD(o.current,vD,e);return X(_D,{event_type:t.success?`transcript_share_submitted`:`transcript_share_failed`,appearance_id:e,trigger:vD}),t.success}return!1},[])});return(0,Q.useEffect)(()=>{if(r&&e.length===0){a.current=!1,i.current.clear();return}},[r,s,t,n,(0,Q.useMemo)(()=>qr(e),[e]),e,l]),{state:s,lastResponse:c,handleSelect:u,handleTranscriptSelect:d}}Hf(),Bd(),o(),Nr(),Zf();var bD=3e3,xD=.2;function SD(e,t){let n=e.findIndex(e=>e.uuid===t);if(n===-1)return!1;for(let t=n+1;t<e.length;t++){let n=e[t];if(n&&(n.type===`user`||n.type===`assistant`))return!0}return!1}function CD(e,t,n=!1,{enabled:r=!0}={}){let[i,o]=(0,Q.useState)(null),s=(0,Q.useRef)(new Set),c=(0,Q.useRef)(null),{state:l,lastResponse:u,open:d,handleSelect:f}=fD({hideThanksAfterMs:bD,onOpen:(0,Q.useCallback)(e=>{X(`tengu_post_compact_survey_event`,{event_type:`appeared`,appearance_id:e,session_memory_compaction_enabled:mo()}),Jf(`feedback_survey`,{event_type:`appeared`,appearance_id:e,survey_type:`post_compact`})},[]),onSelect:(0,Q.useCallback)((e,t)=>{X(`tengu_post_compact_survey_event`,{event_type:`responded`,appearance_id:e,response:t,session_memory_compaction_enabled:mo()}),Jf(`feedback_survey`,{event_type:`responded`,appearance_id:e,response:t,survey_type:`post_compact`})},[])});(0,Q.useEffect)(()=>{r&&o(!1)},[r]);let p=(0,Q.useMemo)(()=>new Set(e.filter(e=>ps(e)).map(e=>e.uuid)),[e]);return(0,Q.useEffect)(()=>{if(!r||l!==`closed`||t||n||i!==!0||Wf()||a(process.env.CLAUDE_CODE_DISABLE_FEEDBACK_SURVEY))return;if(c.current!==null&&SD(e,c.current)){c.current=null,Math.random()<xD&&d();return}let o=Array.from(p).filter(e=>!s.current.has(e));o.length>0&&(s.current=new Set(p),c.current=o[o.length-1])},[r,p,l,t,n,i,e,d]),{state:l,lastResponse:u,handleSelect:f}}Au(),J();var wD=[`1`,`2`,`3`],TD={1:`yes`,2:`no`,3:`dont_ask_again`},ED=e=>wD.includes(e);function DD({onSelect:e,inputValue:t,setInputValue:n}){return cE({inputValue:t,setInputValue:n,isValidDigit:ED,onDigit:t=>e(TD[t])}),(0,$.jsxs)(K,{flexDirection:`column`,marginTop:1,children:[(0,$.jsxs)(K,{children:[(0,$.jsxs)(q,{color:`ansi:cyan`,children:[Uu,` `]}),(0,$.jsx)(q,{bold:!0,children:`Can we look at your session transcript to help us improve Work Mate?`})]}),(0,$.jsx)(K,{marginLeft:2,children:(0,$.jsx)(q,{dimColor:!0,children:`Learn more: https://code.workmate.com/docs/en/data-usage#session-quality-surveys`})}),(0,$.jsxs)(K,{marginLeft:2,children:[(0,$.jsx)(K,{width:10,children:(0,$.jsxs)(q,{children:[(0,$.jsx)(q,{color:`ansi:cyan`,children:`1`}),`: Yes`]})}),(0,$.jsx)(K,{width:10,children:(0,$.jsxs)(q,{children:[(0,$.jsx)(q,{color:`ansi:cyan`,children:`2`}),`: No`]})}),(0,$.jsx)(K,{children:(0,$.jsxs)(q,{children:[(0,$.jsx)(q,{color:`ansi:cyan`,children:`3`}),`: Don't ask again`]})})]})]})}Bd(),J();function OD({state:e,lastResponse:t,handleSelect:n,handleTranscriptSelect:r,inputValue:i,setInputValue:a,onRequestFeedback:o,message:s}){return e===`closed`?null:e===`thanks`?(0,$.jsx)(AD,{lastResponse:t,inputValue:i,setInputValue:a,onRequestFeedback:o}):e===`submitted`?(0,$.jsx)(K,{marginTop:1,children:(0,$.jsxs)(q,{color:`success`,children:[`✓`,` Thanks for sharing your transcript!`]})}):e===`submitting`?(0,$.jsx)(K,{marginTop:1,children:(0,$.jsxs)(q,{dimColor:!0,children:[`Sharing transcript`,`…`]})}):e===`transcript_prompt`?!r||i&&![`1`,`2`,`3`].includes(i)?null:(0,$.jsx)(DD,{onSelect:r,inputValue:i,setInputValue:a}):i&&!dE(i)?null:(0,$.jsx)(pE,{onSelect:n,inputValue:i,setInputValue:a,message:s})}var kD=e=>e===`1`;function AD({lastResponse:e,inputValue:t,setInputValue:n,onRequestFeedback:r}){let i=r&&e===`good`;return cE({inputValue:t,setInputValue:n,isValidDigit:kD,enabled:!!i,once:!0,onDigit:()=>{X(`tengu_feedback_survey_event`,{event_type:`followup_accepted`,response:e}),r?.()}}),(0,$.jsxs)(K,{marginTop:1,flexDirection:`column`,children:[(0,$.jsx)(q,{color:`success`,children:`Thanks for the feedback!`}),i?(0,$.jsxs)(q,{dimColor:!0,children:[`(Optional) Press [`,(0,$.jsx)(q,{color:`ansi:cyan`,children:`1`}),`] to tell us what went well `,` · `,`/issue`]}):e===`bad`?(0,$.jsx)(q,{dimColor:!0,children:`Use /issue to report model behavior issues.`}):(0,$.jsx)(q,{dimColor:!0,children:`Use /issue to share detailed feedback anytime.`})]})}eh(),rh(),Sp(),Td();function jD(e){let{addNotification:t}=xp(),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(Dd))},[t])}function MD(){jD(async()=>(await nh()).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`}}))}hd(),pu(),Cu(),Nr(),ff(),Yo(),br(),J(),Nr();function ND(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=Vc();e!==`blurred`&&e!==`unknown`||o.current?.()},[n]),(0,Q.useEffect)(()=>{Vc()},[n,!1])}Bd(),hd(),Cu(),o(),mu(),Td();function PD(){return a(process.env.CLAUDE_CODE_DISABLE_OFFICIAL_MARKETPLACE_AUTOINSTALL)}var FD={MAX_ATTEMPTS:10,INITIAL_DELAY_MS:3600*1e3,BACKOFF_MULTIPLIER:2,MAX_DELAY_MS:10080*60*1e3};function ID(e){let t=FD.INITIAL_DELAY_MS*FD.BACKOFF_MULTIPLIER**e;return Math.min(t,FD.MAX_DELAY_MS)}function LD(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>=FD.MAX_ATTEMPTS||t===`policy_blocked`||r&&i<r?!1:t===`unknown`||t===`git_unavailable`||t===`gcs_unavailable`||t===void 0}async function RD(){let e=gd();if(!LD(e)){let t=e.officialMarketplaceAutoInstallFailReason??`already_attempted`;return Y(`Official marketplace auto-install skipped: ${t}`),{installed:!1,skipped:!0,reason:t}}try{if(PD())return Y(`Official marketplace auto-install disabled via env var, skipping`),pd(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!1,officialMarketplaceAutoInstallFailReason:`policy_blocked`})),X(`tengu_official_marketplace_auto_install`,{installed:!1,skipped:!0,policy_blocked:!0}),{installed:!1,skipped:!0,reason:`policy_blocked`};if((await ks())[`claude-plugins-official`])return Y(`Official marketplace '${Ra}' already installed, skipping`),pd(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!0})),{installed:!1,skipped:!0,reason:`already_installed`};if(!rn(U))return Y(`Official marketplace blocked by enterprise policy, skipping`),pd(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!1,officialMarketplaceAutoInstallFailReason:`policy_blocked`})),X(`tengu_official_marketplace_auto_install`,{installed:!1,skipped:!0,policy_blocked:!0}),{installed:!1,skipped:!0,reason:`policy_blocked`};let t=fs(),n=pg(t,Ra);if(await cc(n,t)!==null){let e=await ks();return e[Ra]={source:U,installLocation:n,lastUpdated:new Date().toISOString()},await aa(e),pd(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!0,officialMarketplaceAutoInstallFailReason:void 0,officialMarketplaceAutoInstallRetryCount:void 0,officialMarketplaceAutoInstallLastAttemptTime:void 0,officialMarketplaceAutoInstallNextRetryTime:void 0})),X(`tengu_official_marketplace_auto_install`,{installed:!0,skipped:!1,via_gcs:!0}),{installed:!0,skipped:!1}}if(!await er()){Y(`Git not available, skipping official marketplace auto-install`);let t=(e.officialMarketplaceAutoInstallRetryCount||0)+1,n=Date.now(),r=n+ID(t),i=!1;try{pd(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!1,officialMarketplaceAutoInstallFailReason:`git_unavailable`,officialMarketplaceAutoInstallRetryCount:t,officialMarketplaceAutoInstallLastAttemptTime:n,officialMarketplaceAutoInstallNextRetryTime:r}))}catch(e){i=!0,Dd(vu(e)),Y(`Failed to save marketplace auto-install git_unavailable state: ${e}`,{level:`error`})}return X(`tengu_official_marketplace_auto_install`,{installed:!1,skipped:!0,git_unavailable:!0,retry_count:t}),{installed:!1,skipped:!0,reason:`git_unavailable`,configSaveFailed:i}}Y(`Attempting to auto-install official marketplace`),await is(U),Y(`Successfully auto-installed official marketplace`);let r=e.officialMarketplaceAutoInstallRetryCount||0;return pd(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!0,officialMarketplaceAutoInstallFailReason:void 0,officialMarketplaceAutoInstallRetryCount:void 0,officialMarketplaceAutoInstallLastAttemptTime:void 0,officialMarketplaceAutoInstallNextRetryTime:void 0})),X(`tengu_official_marketplace_auto_install`,{installed:!0,skipped:!1,retry_count:r}),{installed:!0,skipped:!1}}catch(t){let n=t instanceof Error?t.message:String(t);if(n.includes(`xcrun: error:`))return ge(),Y(`Official marketplace auto-install: git is a non-functional macOS xcrun shim, treating as git_unavailable`),X(`tengu_official_marketplace_auto_install`,{installed:!1,skipped:!0,git_unavailable:!0,macos_xcrun_shim:!0}),{installed:!1,skipped:!0,reason:`git_unavailable`};Y(`Failed to auto-install official marketplace: ${n}`,{level:`error`}),Dd(vu(t));let r=(e.officialMarketplaceAutoInstallRetryCount||0)+1,i=Date.now(),a=i+ID(r),o=!1;try{pd(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!1,officialMarketplaceAutoInstallFailReason:`unknown`,officialMarketplaceAutoInstallRetryCount:r,officialMarketplaceAutoInstallLastAttemptTime:i,officialMarketplaceAutoInstallNextRetryTime:a}))}catch(e){o=!0,Dd(vu(e)),Y(`Failed to save marketplace auto-install failure state: ${e}`,{level:`error`})}return X(`tengu_official_marketplace_auto_install`,{installed:!1,skipped:!0,failed:!0,retry_count:r}),{installed:!1,skipped:!0,reason:`unknown`,configSaveFailed:o}}}J(),Cu();function zD(){jD(async()=>{let e=await RD(),t=[];return e.configSaveFailed&&(Y(`Showing marketplace config save failure notification`),t.push({key:`marketplace-config-save-failed`,jsx:(0,$.jsx)(q,{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)(q,{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)(q,{color:`warning`,children:`Failed to install official marketplace · Will retry on next startup`}),priority:`immediate`,timeoutMs:8e3})),t})}Zu(),Bd();function BD(e){if(e.length===0)return;if(e.length===1)return e[0];let t=e.map(e=>({tip:e,sessions:tg(e.id)}));return t.sort((e,t)=>t.sessions-e.sessions),t[0]?.tip}async function VD(e){if(Yu().spinnerTipsEnabled===!1)return;let t=await rg(e);if(t.length!==0)return BD(t)}function HD(e){ng(e.id),X(`tengu_tip_shown`,{tipIdLength:e.id,cooldownSessions:e.cooldownSessions})}mu(),Td(),V(),hi();async function UD(e,t,n){}function WD(){let e=H(e=>e.mainLoopModel),t=H(e=>e.mainLoopModelForSession),n=H(e=>e.fastMode),r=yc(),i=Pn(),a=(0,Q.useRef)(!0);(0,Q.useEffect)(()=>{a.current&&(a.current=!1),UD(i.getState().toolPermissionContext,r,n).catch(e=>{Dd(Error(`Auto mode gate check failed`,{cause:vu(e)}))})},[e,t,n])}ba();function GD(e,t,n){let r=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{!wn()||r.current||(r.current=!0,e&&wo(e,n))},[t,e,n])}J(),tc(),tm(),wh();function KD({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`},...Ln()?[]:[{label:(0,$.jsxs)(q,{children:[`Yes, and don't ask again for `,(0,$.jsx)(q,{bold:!0,children:e})]}),value:`yes-dont-ask-again`}],{label:(0,$.jsxs)(q,{children:[`No, and tell Work Mate what to do differently `,(0,$.jsx)(q,{bold:!0,children:`(esc)`})]}),value:`no`}];return(0,$.jsx)(Eh,{title:`Network request outside of sandbox`,children:(0,$.jsxs)(K,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsxs)(K,{children:[(0,$.jsx)(q,{dimColor:!0,children:`Host:`}),(0,$.jsxs)(q,{children:[` `,e]})]}),(0,$.jsx)(K,{marginTop:1,children:(0,$.jsx)(q,{children:`Do you want to allow this connection?`})}),(0,$.jsx)(K,{children:(0,$.jsx)(nm,{options:r,onChange:n,onCancel:()=>{t({allow:!1,persistToSettings:!1})}})})]})})}J(),tc(),zd();function qD(e){return`${e.getHours()%12||12}:${String(e.getMinutes()).padStart(2,`0`)}:${String(e.getSeconds()).padStart(2,`0`)}${e.getHours()<12?`am`:`pm`}`}function JD(){let[e,t]=(0,Q.useState)([]),[n,r]=(0,Q.useState)(0);return(0,Q.useEffect)(()=>{let e=ea.getSandboxViolationStore();return e.subscribe(n=>{t(n.slice(-10)),r(e.getTotalCount())})},[]),!ea.isSandboxingEnabled()||Rd()===`linux`||n===0?null:(0,$.jsxs)(K,{flexDirection:`column`,marginTop:1,children:[(0,$.jsx)(K,{marginLeft:0,children:(0,$.jsxs)(q,{color:`permission`,children:[`⧈ Sandbox blocked `,n,` total `,n===1?`operation`:`operations`]})}),e.map((e,t)=>(0,$.jsx)(K,{paddingLeft:2,children:(0,$.jsxs)(q,{dimColor:!0,children:[qD(e.timestamp),e.command?` ${e.command}:`:``,` `,e.line]})},`${e.timestamp.getTime()}-${t}`)),(0,$.jsx)(K,{paddingLeft:2,children:(0,$.jsxs)(q,{dimColor:!0,children:[`… showing last `,Math.min(10,e.length),` of `,n]})})]})}mh(),Sp(),J();var YD=[];function XD({mcpClients:e=YD}){let{addNotification:t}=xp();(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)(q,{color:`error`,children:[n.length,` MCP `,n.length===1?`server`:`servers`,` failed`]}),(0,$.jsx)(q,{dimColor:!0,children:` · /mcp`})]}),priority:`medium`}),r.length>0&&t({key:`mcp-needs-auth`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(q,{color:`warning`,children:[r.length,` MCP `,r.length===1?`server needs`:`servers need`,` `,`auth`]}),(0,$.jsx)(q,{dimColor:!0,children:` · /mcp`})]}),priority:`medium`}))},[t,e])}J(),Zu(),ih();var ZD=`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.`;ol(),Pl(),Sp(),J(),V(),Cu(),o();var QD=5e3;function $D(){let{addNotification:e}=xp(),t=yc(),[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)(q,{color:`error`,children:[`LSP for `,o,` failed`]}),(0,$.jsx)(q,{dimColor:!0,children:` · /plugin for details`})]}),priority:`medium`,timeoutMs:8e3})},[e,t]),s=Q.useCallback(()=>{if(zl())return;let e=vn();if(e.status===`failed`){o(`lsp-manager`,e.error.message),r(!1);return}if(e.status===`pending`||e.status===`not-started`)return;let t=v();if(t){let e=t.getAllServers();for(let[t,n]of e)n.state===`error`&&n.lastError&&o(t,n.lastError.message)}},[o]);Wc(s,n?QD:null),Q.useEffect(()=>{n&&s()},[s,n])}Cu();var eO=new Map;async function tO(e){if(!e?.trim())return Y(`[binaryCheck] Empty command provided, returning false`),!1;let t=e.trim(),n=eO.get(t);if(n!==void 0)return Y(`[binaryCheck] Cache hit for '${t}': ${n}`),n;let r=!1;return await Ld(t).catch(()=>null)&&(r=!0),eO.set(t,r),Y(`[binaryCheck] Binary '${t}' ${r?`found`:`not found`}`),r}hd(),Cu(),oo();var nO=5;function rO(e){return od.has(e.toLowerCase())}function iO(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=oO(t);if(e)return e}return null}return oO(e)}function aO(e){return typeof e==`object`&&!!e}function oO(e){let t=new Set,n=null;for(let[r,i]of Object.entries(e)){if(!aO(i))continue;!n&&typeof i.command==`string`&&(n=i.command);let e=i.extensionToLanguage;if(aO(e))for(let n of Object.keys(e))t.add(n.toLowerCase())}return!n||t.size===0?null:{extensions:t,command:n}}async function sO(){let e=new Map;try{let t=await ks();for(let n of Object.keys(t))try{let t=await Fo(n),r=rO(n);for(let i of t.plugins){if(!i.lspServers)continue;let t=iO(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 cO(e){if(dO())return Y(`[lspRecommendation] Recommendations are disabled`),[];let t=fg(e).toLowerCase();if(!t)return Y(`[lspRecommendation] No file extension found`),[];Y(`[lspRecommendation] Looking for LSP plugins for ${t}`);let n=await sO(),r=gd().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(gn(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 tO(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 lO(e){pd(t=>{let n=t.lspRecommendationNeverPlugins??[];return n.includes(e)?t:{...t,lspRecommendationNeverPlugins:[...n,e]}}),Y(`[lspRecommendation] Added ${e} to never suggest`)}function uO(){pd(e=>{let t=(e.lspRecommendationIgnoredCount??0)+1;return{...e,lspRecommendationIgnoredCount:t}}),Y(`[lspRecommendation] Incremented ignored count`)}function dO(){let e=gd();return e.lspRecommendationDisabled===!0||(e.lspRecommendationIgnoredCount??0)>=nO}l(),J(),Td(),oo();function fO(){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(Dd).finally(()=>{n.current=!1}))},[e]);return{recommendation:e,clearRecommendation:Q.useCallback(()=>t(null),[]),tryResolve:r}}async function pO(e,t,n,r,i){try{let a=await ki(e);if(!a)throw Error(`Plugin ${e} not found in marketplace`);await i(a),r({key:`${n}-installed`,jsx:(0,$.jsxs)(q,{color:`success`,children:[u.tick,` `,t,` installed · restart to apply`]}),priority:`immediate`,timeoutMs:5e3})}catch(e){Dd(e),r({key:`${n}-install-failed`,jsx:(0,$.jsxs)(q,{color:`error`,children:[`Failed to install `,t]}),priority:`immediate`,timeoutMs:5e3})}}Pl(),Sp(),V(),hd(),Cu(),Td(),Zu();var mO=28e3;function hO(){let e=H(e=>e.fileHistory.trackedFiles),{addNotification:t}=xp(),n=Q.useRef(new Set),{recommendation:r,clearRecommendation:i,tryResolve:a}=fO();return Q.useEffect(()=>{a(async()=>{if(Vl())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 cO(e))[0];if(t)return Y(`[useLspPluginRecommendation] Found match: ${t.pluginName} for ${e}`),ou(!0),{pluginId:t.pluginId,pluginName:t.pluginName,pluginDescription:t.description,fileExtension:fg(e),shownAt:Date.now()}}catch(e){Dd(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`:pO(n,a,`lsp-plugin`,t,async e=>{Y(`[useLspPluginRecommendation] Installing plugin: ${n}`);let t=typeof e.entry.source==`string`?pg(e.marketplaceInstallLocation,e.entry.source):void 0;await mc(n,e.entry,`user`,void 0,t),Ju(`userSettings`,{enabledPlugins:{...ad(`userSettings`)?.enabledPlugins,[n]:!0}}),Y(`[useLspPluginRecommendation] Plugin installed: ${n}`)});break;case`no`:{let e=Date.now()-o;e>=mO&&(Y(`[useLspPluginRecommendation] Timeout detected (${e}ms), incrementing ignored count`),uO());break}case`never`:lO(n);break;case`disable`:pd(e=>e.lspRecommendationDisabled?e:{...e,lspRecommendationDisabled:!0});break}i()},[r,t,i])}}J(),tm(),wh();var gO=3e4;function _O({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`),gO,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)(Eh,{title:`LSP Plugin Recommendation`,children:(0,$.jsxs)(K,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsx)(K,{marginBottom:1,children:(0,$.jsx)(q,{dimColor:!0,children:`LSP provides code intelligence like go-to-definition and error checking`})}),(0,$.jsxs)(K,{children:[(0,$.jsx)(q,{dimColor:!0,children:`Plugin:`}),(0,$.jsxs)(q,{children:[` `,e]})]}),t&&(0,$.jsx)(K,{children:(0,$.jsx)(q,{dimColor:!0,children:t})}),(0,$.jsxs)(K,{children:[(0,$.jsx)(q,{dimColor:!0,children:`Triggered by:`}),(0,$.jsxs)(q,{children:[` `,n,` files`]})]}),(0,$.jsx)(K,{marginTop:1,children:(0,$.jsx)(q,{children:`Would you like to install this LSP plugin?`})}),(0,$.jsx)(K,{children:(0,$.jsx)(nm,{options:[{label:(0,$.jsxs)(q,{children:[`Yes, install `,(0,$.jsx)(q,{bold:!0,children:e})]}),value:`yes`},{label:`No, not now`,value:`no`},{label:(0,$.jsxs)(q,{children:[`Never for `,(0,$.jsx)(q,{bold:!0,children:e})]}),value:`never`},{label:`Disable all LSP recommendations`,value:`disable`}],onChange:a,onCancel:()=>r(`no`)})})]})})}Sp(),Bd(),Cu(),cr();function vO(){let e=Q.useSyncExternalStore(ao,No),{addNotification:t}=xp(),{recommendation:n,clearRecommendation:r,tryResolve:i}=fO();return Q.useEffect(()=>{e&&i(async()=>{let t=await Zo(e);return t&&(Y(`[useClaudeCodeHintRecommendation] surfacing ${t.pluginId} from ${t.sourceCommand}`),Oi()),No()===e&&di(),t})},[e,i]),{recommendation:n,handleResponse:Q.useCallback(e=>{if(n){switch(ft(n.pluginId),X(`tengu_plugin_hint_response`,{_PROTO_plugin_name:n.pluginName,_PROTO_marketplace_name:n.marketplaceName,response:e}),e){case`yes`:{let{pluginId:e,pluginName:r,marketplaceName:i}=n;pO(e,r,`hint-plugin`,t,async t=>{let n=await We({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`:vr();break;case`no`:break}r()}},[n,t,r])}}J(),tm(),wh();var yO=3e4;function bO({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`),yO,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)(Eh,{title:`Plugin Recommendation`,children:(0,$.jsxs)(K,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsx)(K,{marginBottom:1,children:(0,$.jsxs)(q,{dimColor:!0,children:[`The `,(0,$.jsx)(q,{bold:!0,children:r}),` command suggests installing a plugin.`]})}),(0,$.jsxs)(K,{children:[(0,$.jsx)(q,{dimColor:!0,children:`Plugin:`}),(0,$.jsxs)(q,{children:[` `,e]})]}),(0,$.jsxs)(K,{children:[(0,$.jsx)(q,{dimColor:!0,children:`Marketplace:`}),(0,$.jsxs)(q,{children:[` `,n]})]}),t&&(0,$.jsx)(K,{children:(0,$.jsx)(q,{dimColor:!0,children:t})}),(0,$.jsx)(K,{marginTop:1,children:(0,$.jsx)(q,{children:`Would you like to install it?`})}),(0,$.jsx)(K,{children:(0,$.jsx)(nm,{options:[{label:(0,$.jsxs)(q,{children:[`Yes, install `,(0,$.jsx)(q,{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`)})})]})})}tm(),wh();var xO=3e4;function SO({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(),xO,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)(Eh,{title:`Tool Recommendation`,children:(0,$.jsx)(nm,{options:a,onChange:e=>{e===`__dismiss__`?i.current():(i.current(),r.current(e))}})})}var CO=.15,wO=3;function TO(){let e=Q.useSyncExternalStore(ut,_r),t=Q.useMemo(()=>e.length===0?[]:e.slice(0,wO).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)>=CO,handleSelect:Q.useCallback(e=>{ir()},[]),handleDismiss:Q.useCallback(()=>{ir()},[])}}Pl(),cu(),Cu(),_d(),ld();var EO=`1.1.2396`;function DO(){let e=[process.argv[1]||``,process.execPath||``],t=[`/build-ant/`,`/build-ant-native/`,`/build-external/`,`/build-external-native/`];return e.some(e=>t.some(t=>e.includes(t)))}function OO(e){let t=DO()?`claude-dev`:`claude`,n=new URL(`${t}://resume`);return n.searchParams.set(`session`,e),n.searchParams.set(`cwd`,lu()),n.toString()}async function kO(){if(DO())return!0;let e=process.platform;if(e===`darwin`)return $u(`/Applications/Work Mate.app`);if(e===`linux`){let{code:e,stdout:t}=await vd(`xdg-mime`,[`query`,`default`,`x-scheme-handler/claude`]);return e===0&&t.trim().length>0}else if(e===`win32`){let{code:e}=await vd(`reg`,[`query`,`HKEY_CLASSES_ROOT\\claude`,`/ve`]);return e===0}return!1}async function AO(){let e=process.platform;if(e===`darwin`){let{code:e,stdout:t}=await vd(`defaults`,[`read`,`/Applications/Work Mate.app/Contents/Info.plist`,`CFBundleShortVersionString`]);if(e!==0)return null;let n=t.trim();return n.length>0?n:null}else if(e===`win32`){let e=process.env.LOCALAPPDATA;if(!e)return null;let t=pg(e,`AnthropicClaude`);try{let e=(await xg(t)).filter(e=>e.startsWith(`app-`)).map(e=>e.slice(4)).filter(e=>(0,nv.coerce)(e)!==null).sort((e,t)=>{let n=(0,nv.coerce)(e),r=(0,nv.coerce)(t);return n.compare(r)});return e.length>0?e[e.length-1]:null}catch{return null}}return null}async function jO(){if(!await kO())return{status:`not-installed`};let e;try{e=await AO()}catch{return{status:`ready`,version:`unknown`}}if(!e)return{status:`ready`,version:`unknown`};let t=(0,nv.coerce)(e);return!t||!fc(t.version,EO)?{status:`version-too-old`,version:e}:{status:`ready`,version:e}}async function MO(e){let t=process.platform;if(Y(`Opening deep link: ${e}`),t===`darwin`){if(DO()){let{code:t}=await vd(`osascript`,[`-e`,`tell application "Electron" to open location "${e}"`]);return t===0}let{code:t}=await vd(`open`,[e]);return t===0}else if(t===`linux`){let{code:t}=await vd(`xdg-open`,[e]);return t===0}else if(t===`win32`){let{code:t}=await vd(`cmd`,[`/c`,`start`,``,e]);return t===0}return!1}async function NO(){let e=nu();if(!await kO())return{success:!1,error:`Work Mate Desktop is not installed. Install it from https://claude.ai/download`};let t=OO(e);return await MO(t)?{success:!0,deepLinkUrl:t}:{success:!1,error:`Failed to open Work Mate Desktop. Please try opening it manually.`,deepLinkUrl:t}}J(),Bs(),mu(),Qr(),ni();var PO=`https://clau.de/desktop`;function FO(){switch(process.platform){case`win32`:return`https://claude.ai/api/desktop/win32/x64/exe/latest/redirect`;default:return`https://claude.ai/api/desktop/darwin/universal/dmg/latest/redirect`}}function IO({onDone:e}){let[t,n]=(0,Q.useState)(`checking`),[r,i]=(0,Q.useState)(null),[a,o]=(0,Q.useState)(``);return Xc(n=>{if(t===`error`){e(r??`Unknown error`,{display:`system`});return}t===`prompt-download`&&(n===`y`||n===`Y`?(dc(FO()).catch(()=>{}),e(`Starting download. Re-run /desktop once you\u2019ve installed the app.\nLearn more at ${PO}`,{display:`system`})):(n===`n`||n===`N`)&&e(`The desktop app is required for /desktop. Learn more at ${PO}`,{display:`system`}))}),(0,Q.useEffect)(()=>{async function t(){n(`checking`);let t=await jO();if(t.status===`not-installed`){o(`Work Mate Desktop is not installed.`),n(`prompt-download`);return}if(t.status===`version-too-old`){o(`Work Mate Desktop needs to be updated (found v${t.version}, need v1.1.2396+).`),n(`prompt-download`);return}n(`flushing`),await Wr(),n(`opening`);let r=await NO();if(!r.success){i(r.error??`Failed to open Work Mate Desktop`),n(`error`);return}n(`success`),setTimeout(async e=>{e(`Session transferred to Work Mate Desktop`,{display:`system`}),await da(0,`other`)},500,e)}t().catch(e=>{i(hu(e)),n(`error`)})},[e]),t===`error`?(0,$.jsxs)(K,{flexDirection:`column`,paddingX:2,children:[(0,$.jsxs)(q,{color:`error`,children:[`Error: `,r]}),(0,$.jsx)(q,{dimColor:!0,children:`Press any key to continue…`})]}):t===`prompt-download`?(0,$.jsxs)(K,{flexDirection:`column`,paddingX:2,children:[(0,$.jsx)(q,{children:a}),(0,$.jsx)(q,{children:`Download now? (y/n)`})]}):(0,$.jsx)(nl,{message:{checking:`Checking for Work Mate Desktop…`,flushing:`Saving session…`,opening:`Opening Work Mate Desktop…`,success:`Opening in Work Mate Desktop…`}[t]})}J(),Bd(),hd(),tm(),wh();var LO={enable_shortcut_tip:!1,enable_startup_dialog:!1};function RO(){return LO}function zO(){return process.platform===`darwin`||process.platform===`win32`&&process.arch===`x64`}function BO(){if(!zO()||!RO().enable_startup_dialog)return!1;let e=gd();return!(e.desktopUpsellDismissed||(e.desktopUpsellSeenCount??0)>=3)}function VO({onDone:e}){let[t,n]=(0,Q.useState)(!1);if((0,Q.useEffect)(()=>{let e=(gd().desktopUpsellSeenCount??0)+1;pd(t=>(t.desktopUpsellSeenCount??0)>=e?t:{...t,desktopUpsellSeenCount:e}),X(`tengu_desktop_upsell_shown`,{seen_count:e})},[]),t)return(0,$.jsx)(IO,{onDone:()=>e()});function r(t){switch(t){case`try`:n(!0);return;case`never`:pd(e=>e.desktopUpsellDismissed?e:{...e,desktopUpsellDismissed:!0}),e();return;case`not-now`:e();return}}return(0,$.jsx)(Eh,{title:`Try Work Mate Desktop`,children:(0,$.jsxs)(K,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsx)(K,{marginBottom:1,children:(0,$.jsx)(q,{children:`Same Work Mate with visual diffs, live app preview, parallel sessions, and more.`})}),(0,$.jsx)(nm,{options:[{label:`Open in Work Mate Desktop`,value:`try`},{label:`Not now`,value:`not-now`},{label:`Don't ask again`,value:`never`}],onChange:r,onCancel:()=>r(`not-now`)})]})})}Sp(),J(),V(),Cu(),Pd();function HO(){let{addNotification:e}=xp(),t=H(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)(q,{color:`error`,children:[n,` `,Md(n,`plugin`),` failed to install`]}),(0,$.jsx)(q,{dimColor:!0,children:` · /plugin for details`})]}),priority:`medium`})))},[e,n,r,i])}Sp(),J(),Cu(),Mh();function UO(){let{addNotification:e}=xp(),[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)(q,{color:`success`,children:[n.length===1?`Plugin`:`Plugins`,` updated: `,r]}),(0,$.jsx)(q,{dimColor:!0,children:` · Run /reload-plugins to apply`})]}),priority:`low`,timeoutMs:1e4}),Y(`Showing plugin autoupdate notification for: ${n.join(`, `)}`)},[t,e])}Cu(),Td(),oo(),km(),Bd();function WO(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 GO(e){Y(`performBackgroundPluginInstallations called`);try{let t=Dm(fi(),await ks().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 Em({onProgress:t=>{switch(t.type){case`installing`:WO(e,t.name,`installing`);break;case`installed`:WO(e,t.name,`installed`);break;case`failed`:WO(e,t.name,`failed`,t.error);break}}}),i={installed_count:r.installed.length,updated_count:r.updated.length,failed_count:r.failed.length,up_to_date_count:r.upToDate.length};if(X(`tengu_marketplace_background_install`,i),Gu(`info`,`tengu_marketplace_background_install`,i),r.installed.length>0){xa(),Y(`Auto-refreshing plugins after ${r.installed.length} new marketplace(s) installed`);try{await Om(e)}catch(t){Dd(t),Y(`Auto-refresh failed, falling back to needsRefresh: ${t}`,{level:`warn`}),Ea(`performBackgroundPluginInstallations: auto-refresh failed`),e(e=>e.plugins.needsRefresh?e:{...e,plugins:{...e.plugins,needsRefresh:!0}})}}else r.updated.length>0&&(xa(),Ea(`performBackgroundPluginInstallations: marketplaces reconciled`),e(e=>e.plugins.needsRefresh?e:{...e,plugins:{...e.plugins,needsRefresh:!0}}))}catch(e){Dd(e)}}hd(),Cu(),oo(),Oe();async function KO(e){if(Y(`performStartupChecks called`),!md()){Y(`Trust not accepted for current directory - skipping plugin installations`);return}try{Y(`Starting background plugin installations`),await vo()&&(xa(),Ea(`performStartupChecks: seed marketplaces changed`),e(e=>e.plugins.needsRefresh?e:{...e,plugins:{...e.plugins,needsRefresh:!0}})),await GO(e)}catch(e){Y(`Error initiating background plugin installations: ${e}`)}}Sp(),J(),St();function qO(e){let{addNotification:t}=xp(),n=Vx(),r=(0,Q.useMemo)(()=>li(n,e),[n,e]),i=(0,Q.useMemo)(()=>ko(n),[n]),a=(0,Q.useRef)(null),o=xE(),[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)(q,{children:(0,$.jsx)(q,{color:`warning`,children:r})}),priority:`high`}))},[r,t])}Sp();function JO(e){let{addNotification:t}=xp(),n=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{let r=eg(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 YO=``;function XO(){jD(async()=>jd()||a(process.env.DISABLE_INSTALLATION_CHECKS)||await th()===`development`?null:{timeoutMs:15e3,key:`npm-deprecation-warning`,text:YO,color:`warning`,priority:`high`})}Sp(),J(),hd(),cn();var ZO=5;function QO({ideSelection:e,mcpClients:t,ideInstallationStatus:n}){let{addNotification:r,removeNotification:i}=xp(),{status:a,ideName:o}=Bx(t),s=(0,Q.useRef)(!1),c=n?qe(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(ht()||a!==null||p){i(`ide-status-hint`);return}if(s.current||(gd().ideHintShownCount??0)>=ZO)return;let e=setTimeout((e,t)=>{Va(!0).then(n=>{let r=n[0]?.name;r&&!e.current&&(e.current=!0,pd(e=>({...e,ideHintShownCount:(e.ideHintShownCount??0)+1})),t({key:`ide-status-hint`,jsx:(0,$.jsxs)(q,{dimColor:!0,children:[`/ide for `,(0,$.jsx)(q,{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])}hd();var $O=[e=>{if(tk(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(tk(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 ek(){jD(()=>{let e=gd(),t=[];for(let n of $O){let r=n(e);r&&t.push(r)}return t.length>0?t:null})}function tk(e){return e!==void 0&&Date.now()-e<3e3}Sp(),V(),ef(),Kd();var nk=`fast-mode-cooldown-started`,rk=`fast-mode-cooldown-expired`,ik=`fast-mode-org-changed`,ak=`fast-mode-overage-rejected`;function ok(){let{addNotification:e}=xp(),t=H(e=>e.fastMode),n=yc();(0,Q.useEffect)(()=>{if($d())return cf(r=>{r?e({key:ik,color:`fastMode`,priority:`immediate`,text:`Fast mode is now available · /fast to turn on`}):t&&(n(e=>({...e,fastMode:!1})),e({key:ik,color:`warning`,priority:`immediate`,text:`Fast mode has been disabled by your organization`}))})},[e,t,n]),(0,Q.useEffect)(()=>{if($d())return lf(t=>{n(e=>({...e,fastMode:!1})),e({key:ak,color:`warning`,priority:`immediate`,text:t})})},[e,n]),(0,Q.useEffect)(()=>{if(!t)return;let n=tf((t,n)=>{let r=sk(n,Yd(t-Date.now(),{hideTrailingZeros:!0}));e({key:nk,invalidates:[rk],text:r,color:`warning`,priority:`immediate`})}),r=bf(()=>{e({key:rk,invalidates:[nk],color:`fastMode`,text:`Fast limit reset · now using fast mode`,priority:`immediate`})});return()=>{n(),r()}},[e,t])}function sk(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}`}}J(),fo();function ck({onRun:e,onCancel:t,reason:n}){let r=(0,Q.useRef)(!1);return Fc(`confirm:no`,t,{context:`Confirmation`}),(0,Q.useEffect)(()=>{r.current||(r.current=!0,e())},[e]),(0,$.jsxs)(K,{flexDirection:`column`,marginTop:1,children:[(0,$.jsx)(K,{children:(0,$.jsx)(q,{bold:!0,children:`Running feedback capture...`})}),(0,$.jsx)(K,{children:(0,$.jsxs)(q,{dimColor:!0,children:[`Press `,(0,$.jsx)(Sc,{shortcut:`Esc`,action:`cancel`}),` anytime`]})}),(0,$.jsx)(K,{children:(0,$.jsxs)(q,{dimColor:!0,children:[`Reason: `,n]})})]})}function lk(e){switch(e){case`feedback_survey_bad`:return!1;case`feedback_survey_good`:return!1;default:return!1}}function uk(e){return`/issue`}function dk(e){switch(e){case`feedback_survey_bad`:return`You responded "Bad" to the feedback survey`;case`feedback_survey_good`:return`You responded "Good" to the feedback survey`;default:return`Unknown reason`}}function fk(){return null}function pk(e,t){return!1}Ih(),J(),hd(),hm();function mk(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||!(gd().copyOnSelect??!0))return;let a=e.copySelectionNoClear();if(!a?.trim()){r.current=!0;return}r.current=!0,i.current?.(a)})},[t,e])}function hk(e){let[t]=Ec();(0,Q.useEffect)(()=>{e.setSelectionBgColor(mm(t).selectionBg)},[e,t])}Sp(),J(),fo(),Cu();var gk=40,_k=.3,vk=6,yk=200,bk=15,xk=15,Sk=3,Ck=1500,wk=150,Tk=5,Ek=5,Dk=80,Ok=3,kk=6,Ak=500;function jk(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 Mk(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 Nk(e,t,n){if(!e.xtermJs){if(e.wheelMode&&n-e.time>Ck&&(e.wheelMode=!1,e.burstCount=0,e.mult=e.base),e.pendingFlip){if(e.pendingFlip=!1,t!==e.dir||n-e.time>yk)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<Ek)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/wk),n=Math.max(xk,e.base*2),i=1+(e.mult-1)*t+bk*t;return e.mult=Math.min(n,i,e.mult+Sk),Math.floor(e.mult)}if(r>gk)e.mult=e.base;else{let t=Math.max(vk,e.base*2);e.mult=Math.min(t,e.mult+_k)}return Math.floor(e.mult)}let r=n-e.time,i=t===e.dir;if(e.time=n,e.dir=t,i&&r<Ek)return 1;if(!i||r>Ak)e.mult=2,e.frac=0;else{let t=.5**(r/wk);e.mult=Math.min(r>=Dk?Ok:kk,1+(e.mult-1)*t+Tk*t)}let a=e.mult+e.frac,o=Math.floor(a);return e.frac=a-o,o}function Pk(){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 Fk(e=!1,t=1){return{time:0,mult:t,dir:0,xtermJs:e,frac:0,base:t,pendingFlip:!1,wheelMode:!1,burstCount:0}}function Ik(){let e=Zc(),t=Pk();return Y(`wheel accel: ${e?`decay (xterm.js)`:`window (native)`} · base=${t} · TERM_PROGRAM=${process.env.TERM_PROGRAM??`unset`}`),Fk(e,t)}var Lk=2,Rk=50,zk=200;function Bk({scrollRef:e,isActive:t,onScroll:n,isModal:r=!1}){let i=el(),{addNotification:a}=xp(),o=(0,Q.useRef)(null);function s(e){let t=$c(),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 Tc({"scroll:pageUp":()=>{let t=e.current;if(!t)return;let r=-Math.max(1,Math.floor(t.getViewportHeight()/2));l(t,r);let i=Uk(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=Uk(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=Ik()),Gk(t,Nk(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=Ik());let r=Wk(t,Nk(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}),Tc({"scroll:halfPageUp":()=>{let t=e.current;if(!t)return;let r=-Math.max(1,Math.floor(t.getViewportHeight()/2));l(t,r);let i=Uk(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=Uk(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=Uk(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=Uk(t,r);n?.(i,t)}},{context:`Scroll`,isActive:t}),Xc((t,r,i)=>{let a=e.current;if(!a)return;let o=qk(a,Kk(t,r),e=>l(a,e));o!==null&&(n?.(o,a),i.stopImmediatePropagation())},{isActive:t&&r}),Xc((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=Mk(t);if(r){i.moveFocus(r),n.stopImmediatePropagation();return}jk(t)&&i.clearSelection()},{isActive:t}),Vk(e,i,t,n),mk(i,t,s),hk(i),null}function Vk(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>zk){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(Lk,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(Lk,e-i.getScrollTop());t.captureScrolledRows(l,l+n-1,`above`),t.shiftAnchor(-n,l,u),i.scrollBy(Lk)}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,Rk)))}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=Hk(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 Hk(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 Uk(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 Wk(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 Gk(e,t){if(e.getScrollTop()+e.getPendingDelta()-t<=0){e.scrollTo(0);return}e.scrollBy(-t)}function Kk(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 qk(e,t,n){switch(t){case null:return null;case`lineUp`:case`lineDown`:{let r=t===`lineDown`?1:-1;return n(r),Uk(e,r)}case`halfPageUp`:case`halfPageDown`:{let r=Math.max(1,Math.floor(e.getViewportHeight()/2)),i=t===`halfPageDown`?r:-r;return n(i),Uk(e,i)}case`fullPageUp`:case`fullPageDown`:{let r=Math.max(1,e.getViewportHeight()),i=t===`fullPageDown`?r:-r;return n(i),Uk(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}}}Pl(),zi(),ku(),l(),J(),gi(),Rm(),Sp(),Cu(),o(),Kd(),Qi(),Ut(),Zp(),Oo(),Mp(),ep(),la(),rc(),mu(),Ya(),hi(),B(),hd(),Bd(),Nr(),Ed(),Qr(),na(),Bh(),um(),_o(),Gm(),V(),M(),ni(),ba(),qo(),cn(),$s(),k(),Rs(),Eo(),tc(),an();var Jk=3e3;function Yk({showAllInTranscript:e,virtualScroll:t,searchBadge:n,suppressShowAll:r=!1,status:i}){let a=ta(`app:toggleTranscript`,`Global`,`ctrl+o`),o=ta(`transcript:toggleShowAll`,`Transcript`,`ctrl+e`);return(0,$.jsxs)(K,{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)(q,{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)(K,{flexGrow:1}),(0,$.jsxs)(q,{children:[i,` `]})]}):n?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(K,{flexGrow:1}),(0,$.jsxs)(q,{dimColor:!0,children:[n.current,`/`,n.count,` `]})]}):null]})}function Xk({jumpRef:e,count:t,current:n,onClose:r,onCancel:i,setHighlight:a,initialQuery:o}){let{query:s,cursorOffset:c}=lh({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)(K,{borderTopDimColor:!0,borderBottom:!1,borderLeft:!1,borderRight:!1,borderStyle:`single`,marginTop:1,paddingLeft:2,width:`100%`,noSelect:!0,children:[(0,$.jsx)(q,{children:`/`}),(0,$.jsx)(q,{children:s.slice(0,f)}),(0,$.jsx)(q,{inverse:!0,children:p}),f<s.length&&(0,$.jsx)(q,{children:s.slice(f+1)}),(0,$.jsx)(K,{flexGrow:1}),l===`building`?(0,$.jsx)(q,{dimColor:!0,children:`indexing… `}):l?(0,$.jsxs)(q,{dimColor:!0,children:[`indexed in `,l.ms,`ms `]}):t===0&&s?(0,$.jsx)(q,{color:`error`,children:`no matches `}):t>0?(0,$.jsxs)(q,{dimColor:!0,children:[n,`/`,t,` `]}):null]})}var Zk=[`⠂`,`⠐`],Qk=`✳`,$k=960;function eA({isAnimating:e,title:t,disabled:n,noPrefix:r}){let i=Ic(),[a,o]=(0,Q.useState)(0);(0,Q.useEffect)(()=>{if(n||r||!e||!i)return;let t=setInterval(e=>e(e=>(e+1)%Zk.length),$k,o);return()=>clearInterval(t)},[n,r,e,i]);let s=e?Zk[a]??Qk:Qk;return Rc(n?null:r?t:`${s} ${t}`),null}var tA=`<${wd}>`;function nA(e){return e.type===`text`&&typeof e.text==`string`&&e.text.includes(tA)}function rA({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:_,onBeforeQuery:v,onTurnComplete:y,disabled:b=!1,mainThreadAgentDefinition:w,disableSlashCommands:T=!1,taskListId:D,thinkingConfig:O}){let k=(0,Q.useMemo)(()=>a(process.env.CLAUDE_CODE_DISABLE_TERMINAL_TITLE),[]),j=(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=${b}`),()=>Y(`[REPL:unmount] REPL unmounting`)),[b]);let[M,ee]=(0,Q.useState)(w),N=H(e=>e.toolPermissionContext),P=H(e=>e.verbose),ne=H(e=>e.mcp),F=H(e=>e.plugins),I=H(e=>e.agentDefinitions),L=H(e=>e.fileHistory),ie=H(e=>e.initialMessage),ae=Ix(),oe=H(e=>e.spinnerTip),se=H(e=>e.expandedView)===`tasks`,R=H(e=>e.tasks),z=H(e=>e.elicitation),le=H(e=>e.viewingAgentTaskId),B=yc(),ue=le?R[le]:void 0,de=Wo(ue)&&ue.retain&&!ue.diskLoaded;(0,Q.useEffect)(()=>{if(!le||!de)return;let e=le;Cn(sc(e)).then(t=>{B(n=>{let r=n.tasks[e];if(!Wo(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,de,B]);let pe=Pn(),me=Ac(),he=Wm(),[ge,_e]=(0,Q.useState)(t);qE(Hl(),_e);let ve=Q.useSyncExternalStore(as,jr),ye=Q.useSyncExternalStore(as,st),be=(0,Q.useMemo)(()=>Yn(N),[N,ve]);WD();let[xe,Ce]=(0,Q.useState)(f),we=(0,Q.useCallback)(e=>{Ce(e)},[Ce]),[Te,Ee]=(0,Q.useState)(`prompt`),[De,Oe]=(0,Q.useState)(!1),[ke,Ae]=(0,Q.useState)(!1),[Me,Ne]=(0,Q.useState)(``),Pe=(0,Q.useRef)(0),Fe=(0,Q.useRef)(void 0),Ie=(0,Q.useRef)(!1),{addNotification:Le,removeNotification:Re}=xp(),Be=GE(d,ne.clients),[Ve,He]=(0,Q.useState)(void 0),[Ue,We]=(0,Q.useState)(null),[Ge,Ke]=(0,Q.useState)(null),[qe,Je]=(0,Q.useState)(!1),[Ye,Xe]=(0,Q.useState)(()=>BO());ek(),QO({ideSelection:Ve,mcpClients:Be,ideInstallationStatus:Ge}),XD({mcpClients:Be}),HO(),UO(),ph(),qO(he),ok(),JO(he),XO(),MD(),zD(),$D();let{recommendation:V,handleResponse:Qe}=hO(),{recommendation:$e,handleResponse:et}=vO(),tt=TO(),nt=(0,Q.useMemo)(()=>[...be,...r],[be,r]);Hp({enabled:!0});let rt=im();(0,Q.useEffect)(()=>{KO(B)},[B]);let it=Im(nt,ne.tools,N),{tools:at,allowedAgentTypes:ot}=(0,Q.useMemo)(()=>{if(!M)return{tools:it,allowedAgentTypes:void 0};let e=Ga(M,it,!1,!0);return{tools:e.resolvedTools,allowedAgentTypes:e.allowedAgentTypes}},[M,it]),ct=KE(KE(ge,F.commands),ne.commands),lt=(0,Q.useMemo)(()=>T?[]:ct,[T,ct]);Mv(ne.clients),YE(ne.clients,He);let[ut,dt]=(0,Q.useState)(`responding`),ft=(0,Q.useRef)(ut);ft.current=ut;let[pt,ht]=(0,Q.useState)([]),[gt,_t]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{if(gt&&!gt.isStreaming&>.streamingEndedAt){let e=3e4-(Date.now()-gt.streamingEndedAt);if(e>0){let t=setTimeout(_t,e,null);return()=>clearTimeout(t)}else _t(null)}},[gt]);let[vt,bt]=(0,Q.useState)(null),St=(0,Q.useRef)(null);St.current=vt;let Ct=(0,Q.useRef)(0),[wt,Tt]=(0,Q.useState)(!1),Et=(0,Q.useRef)(()=>{}),Dt=(0,Q.useRef)(null),Ot=(0,Q.useRef)(null),At=(0,Q.useRef)(0),Mt=Q.useRef(new kv).current,Nt=Q.useSyncExternalStore(Mt.subscribe,Mt.getSnapshot),[Pt,Ft]=Q.useState(!1),U=Nt||Pt,[It,Lt]=Q.useState(void 0),Rt=Q.useRef(0),zt=Q.useRef(!1),Bt=Q.useRef(0),Vt=Q.useRef(0),Ht=Q.useRef(null),Ut=Q.useCallback(()=>{Bt.current=Date.now(),Vt.current=0,Ht.current=null},[]),Wt=Q.useRef(!1);Nt&&!Wt.current&&Ut(),Wt.current=Nt;let Gt=Q.useCallback(e=>{Ft(e),e&&Ut()},[Ut]),Kt=Q.useRef(void 0),[qt,Jt]=Q.useState(!1),[Yt,Qt]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{Yt?.notifications&&Yt.notifications.forEach(e=>{Le({key:`auto-updater-notification`,text:e,priority:`low`})})},[Yt,Le]),(0,Q.useEffect)(()=>{Za()&&Na().then(e=>{e&&Le({key:`tmux-mouse-hint`,text:e,priority:`low`})})},[]);let[$t,tn]=(0,Q.useState)(null),nn=(0,Q.useRef)(null),rn=(0,Q.useCallback)(e=>{if(e?.isLocalJSXCommand){let{clearLocalJSX:t,...n}=e;nn.current={...n,isLocalJSXCommand:!0},tn(n);return}if(nn.current){if(e?.clearLocalJSX){nn.current=null,tn(null),Ct.current=Date.now();return}return}if(e?.clearLocalJSX){tn(null);return}tn(e)},[]),[an,on]=(0,Q.useState)([]),[cn,ln]=(0,Q.useState)(null),[un,pn]=(0,Q.useState)([]),[mn,hn]=(0,Q.useState)([]),gn=H(e=>e.settings.terminalTitleFromRename)===!1?void 0:bs(nu()),[vn,yn]=(0,Q.useState)(),bn=(0,Q.useRef)((i?.length??0)>0),xn=M?.agentType,Sn=gn??xn??vn??`Work Mate`,Tn=an.length>0||mn.length>0,On=$t?.isLocalJSXCommand===!0&&$t?.jsx!=null,kn=U&&!Tn&&!On;(0,Q.useEffect)(()=>{if(U&&!Tn&&!On)return Sv(),()=>Cv()},[U,Tn,On]);let An=Tn||On?`waiting`:U?`busy`:`idle`,jn=An===`waiting`?an.length>0?`approve ${an[0].tool.name}`:On?`dialog open`:`input needed`:void 0;(0,Q.useEffect)(()=>{En({status:An,waitingFor:jn})},[An,jn]),Bc(null);let[W,Mn]=(0,Q.useState)(i??[]),Nn=(0,Q.useRef)(W),In=(0,Q.useRef)(!1),G=(0,Q.useCallback)(e=>{let t=Nn.current,n=typeof e==`function`?e(Nn.current):e;if(Nn.current=n,n.length<Rt.current)Rt.current=0;else if(n.length>t.length&&zt.current){let e=n.length-t.length;(t.length===0||n[0]===t[0]?n.slice(-e):n.slice(0,e)).some(pi)?zt.current=!1:Rt.current=n.length}Mn(n)},[]),Ln=(0,Q.useCallback)(e=>{e===void 0?zt.current=!1:(Rt.current=Nn.current.length,zt.current=!0),Lt(e)},[]),{dividerIndex:Rn,dividerYRef:Bn,onScrollAway:Vn,onRepin:Wn,jumpToNew:Gn,shiftDivider:Kn}=Vh(W.length);ND(W,G,U);let[Xn,Zn]=(0,Q.useState)(null),Qn=(0,Q.useRef)(null),er=(0,Q.useMemo)(()=>Rh(W,Rn),[Rn,W.length]),tr=(0,Q.useCallback)(()=>{Dt.current?.scrollToBottom(),Wn(),Zn(null)},[Wn,Zn]),nr=W.at(-1),rr=nr!=null&&pi(nr);(0,Q.useEffect)(()=>{rr&&tr()},[rr,nr,tr]);let ir=(0,Q.useCallback)((e,t)=>{At.current=Date.now(),e?Wn():Vn(t)},[Wn,Vn,B]),ar=wE(o,G),or=(0,Q.useDeferredValue)(Q.useMemo(()=>W.length>500?W.slice(-500):W,[W])),sr=W.length-or.length;sr>0&&Y(`[useDeferredValue] Messages deferred by ${sr} (${or.length}→${W.length})`);let[cr,lr]=(0,Q.useState)(null),[ur,dr]=(0,Q.useState)(()=>ig()),fr=(0,Q.useRef)(ur);fr.current=ur;let pr=(0,Q.useRef)(null),mr=(0,Q.useCallback)(e=>{fr.current===``&&e!==``&&Date.now()-At.current>=Jk&&tr(),fr.current=e,dr(e),Jt(e.trim().length>0)},[Jt,tr]);(0,Q.useEffect)(()=>{if(ur.trim().length===0)return;let e=setTimeout(Jt,1500,!1);return()=>clearTimeout(e)},[ur]);let[gr,_r]=(0,Q.useState)(`prompt`),[vr,yr]=(0,Q.useState)(),[br,xr]=(0,Q.useState)(new Set),Sr=(0,Q.useRef)(!1),[Cr,wr]=(0,Q.useState)({}),[Er,Mr]=(0,Q.useState)(0),Nr=(0,Q.useRef)(0),Fr=(0,Q.useRef)([]),Ir=(0,Q.useCallback)(e=>{let t=Nr.current;if(Nr.current=e(t),Nr.current>t){let e=Fr.current;if(e.length>0){let t=e.at(-1);t.lastTokenTime=Date.now(),t.endResponseLength=Nr.current}}},[]),[Lr,Rr]=(0,Q.useState)(null),Vr=!(H(e=>e.settings.prefersReducedMotion)??!1)&&!al(),Hr=(0,Q.useCallback)(e=>{Vr&&Rr(e)},[Vr]),Ur=Lr&&Vr&&Lr.substring(0,Lr.lastIndexOf(`
|
|
120
|
+
`)+1)||null,[Wr,qr]=(0,Q.useState)(0),[Yr,Xr]=(0,Q.useState)(null),[Qr,$r]=(0,Q.useState)(null),[ei,ti]=(0,Q.useState)(null),[ni,ii]=(0,Q.useState)(!1),[ai,ci]=(0,Q.useState)(void 0),[li,ui]=(0,Q.useState)(!1),[di,fi]=(0,Q.useState)(yg()),[mi,hi]=(0,Q.useState)(null),gi=(0,Q.useRef)(!1),vi=(0,Q.useRef)(Wr);vi.current=Wr;let[bi]=(0,Q.useState)(()=>({current:Zt(i,c)}));_i(()=>{bi.current=Jn()});let[xi,wi]=(0,Q.useState)(gd().hasAcknowledgedCostThreshold),[Ei,Di]=(0,Q.useState)(`INSERT`),[Oi,ki]=(0,Q.useState)(!1),[Mi,Ni]=(0,Q.useState)(!1),[Pi,Fi]=(0,Q.useState)(!1),Ii=Ic(),Li=(0,Q.useRef)(Ii);Li.current=Ii;let[Ri]=Ec(),zi=Q.useRef(!1),Bi=(0,Q.useCallback)(()=>{if(zi.current)return;zi.current=!0;let e=Nn.current.slice(ua.current);for(let t of uc(e))la.current.add(t);ua.current=Nn.current.length,VD({theme:Ri,readFileState:ca.current,bashTools:la.current}).then(async e=>{if(e){let t=await e.content({theme:Ri});B(e=>({...e,spinnerTip:t})),HD(e)}else B(e=>e.spinnerTip===void 0?e:{...e,spinnerTip:void 0})})},[B,Ri]),Hi=(0,Q.useCallback)(()=>{Gt(!1),Ln(void 0),Nr.current=0,Fr.current=[],Rr(null),ht([]),Xr(null),$r(null),ti(null),Bi(),Xf(),Hs()},[Bi]),Ui=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{if(N.mode!==`auto`){Ui.current=!1;return}if(Ui.current||(gd().autoPermissionsNotificationCount??0)>=3)return;let e=setTimeout((e,t)=>{e.current=!0,pd(e=>{let t=e.autoPermissionsNotificationCount??0;return t>=3?e:{...e,autoPermissionsNotificationCount:t+1}}),t(e=>[...e,Cs(ZD,`warning`)])},800,Ui,G);return()=>clearTimeout(e)},[N.mode,G]);let Gi=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{if(Gi.current)return;let e=zs();if(!e?.creationDurationMs||e.usedSparsePaths||e.creationDurationMs<15e3)return;Gi.current=!0;let t=Math.round(e.creationDurationMs/1e3);G(e=>[...e,Cs(`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`)])},[G]);let Ki=(0,Q.useMemo)(()=>{let e=W.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`&&br.has(e.id));return n.length>0&&n.every(e=>e.type===`tool_use`&&e.name===`Sleep`)},[W,br]),{onBeforeQuery:qi,onTurnComplete:Ji,render:Yi}=yE({enabled:!1,setMessages:G,inputValue:ur,setInputValue:mr,setToolJSX:rn}),Xi=(!$t||$t.showSpinner===!0)&&an.length===0&&mn.length===0&&(U||It||Se()>0)&&!Ki&&!Ur,Zi=an.length>0||mn.length>0||un.length>0||z.queue.length>0,Qi=hD(W,U,Er,`session`,Zi),$i=vE(G),ta=pk(W,Er),na=(0,Q.useMemo)(()=>({...Qi,handleSelect:e=>{va.current=!1;let t=Qi.handleSelect(e);e===`bad`&&!t&&lk(`feedback_survey_bad`)&&(_a(`feedback_survey_bad`),va.current=!0)}}),[Qi]),ia=CD(W,U,Zi,{enabled:!0}),aa=yD(W,U,Zi,{enabled:!0});oD({autoConnectIdeFlag:p,ideToInstallExtension:Ue,setDynamicMcpConfig:Ce,setShowIdeOnboarding:Je,setIDEInstallationState:Ke}),GD(s,L,e=>B(t=>({...t,fileHistory:e})));let oa=(0,Q.useCallback)(async(t,n,r)=>{let i=performance.now();try{let a=qp(n.messages),o=Po();await mt(`resume`,{getAppState:()=>pe.getState(),setAppState:B,signal:AbortSignal.timeout(o),timeoutMs:o});let s=await x(`resume`,{sessionId:t,agentType:M?.agentType,model:he});a.push(...s),r===`fork`?Ks(n,yi(t)):$n(n,yi(t)),Sm(n,B),n.fileHistorySnapshots&&Dr(n);let{agentDefinition:c}=bm(n.agentSetting,w,I);ee(c),B(e=>({...e,agent:c?.agentType})),B(e=>({...e,standaloneAgentContext:xm(n.agentName,n.agentColor)})),C(n.agentName),pa(a,n.projectPath??Fl()),Hi(),bt(null),fi(t);let l=si(t);if(Ti(),Nl(),ql(yi(t),n.fullPath?dg(n.fullPath):null),await Or(),ze(),Kr(n),n.goal){let{hydrateGoalFromTranscript:r}=(_n(),e(Br)),i=new Map;i.set(t,n.goal),r(i,t)}if(bn.current=!0,yn(void 0),r!==`fork`)Cm(),wm(n.worktreeSession),xt();else{let e=zs();e&&jo(e)}l&&Xl(l),bi.current&&r!==`fork`&&(bi.current=Ua(a,n.contentReplacements??[])),G(()=>a),rn(null),mr(``),X(`tengu_session_resumed`,{entrypoint:r,success:!0,resume_duration_ms:Math.round(performance.now()-i)})}catch(e){throw X(`tengu_session_resumed`,{entrypoint:r,success:!1}),e}},[Hi,B]),[sa]=(0,Q.useState)(()=>qn(100)),ca=(0,Q.useRef)(sa),la=(0,Q.useRef)(new Set),ua=(0,Q.useRef)(0),da=(0,Q.useRef)(new Set),fa=(0,Q.useRef)(new Set),pa=(0,Q.useCallback)((e,t)=>{let n=Ci(e,t,100);ca.current=ce(ca.current,n);for(let t of uc(e))la.current.add(t)},[]);(0,Q.useEffect)(()=>{i&&i.length>0&&pa(i,Fl())},[]);let{status:ma,reverify:ha}=TE(),[ga,_a]=(0,Q.useState)(null),va=(0,Q.useRef)(!1),[ya,ba]=(0,Q.useState)(null),[xa,Sa]=(0,Q.useState)(!1),wa=!U&&li;function Ta(){if(xa||ya)return;if(ni)return`message-selector`;if(qt)return;if(un[0])return`sandbox-permission`;let e=!$t||$t.shouldContinueAnimation;if(e&&an[0])return`tool-permission`;if(e&&mn[0])return`prompt`;if(e&&z.queue[0])return`elicitation`;if(e&&wa)return`cost`;if(e&&mi)return`idle-return`;if(e&&qe)return`ide-onboarding`;if(e&&V)return`lsp-recommendation`;if(e&&$e)return`plugin-hint`;if(e&&tt.visible)return`search-extra-tools-hint`;if(e&&Ye)return`desktop-upsell`}let Ea=Ta(),Da=qt&&(un[0]||an[0]||mn[0]||z.queue[0]||wa);Kt.current=Ea,(0,Q.useEffect)(()=>{if(!U)return;let e=Ea===`tool-permission`,t=Date.now();e&&Ht.current===null?Ht.current=t:!e&&Ht.current!==null&&(Vt.current+=t-Ht.current,Ht.current=null)},[Ea,U]);let Oa=(0,Q.useRef)(Ea);(0,Q.useLayoutEffect)(()=>{Oa.current===`tool-permission`!=(Ea===`tool-permission`)&&tr(),Oa.current=Ea},[Ea,tr]);function ka(){if(Ea!==`elicitation`){if(Ct.current!==0&&Date.now()-Ct.current<500){Ct.current=0,Y(`[onCancel] suppressed: local-jsx panel just dismissed`);return}if(Ct.current=0,Y(`[onCancel] focusedInputDialog=${Ea} streamMode=${ut}`),zr(),Mt.getSnapshot()){let{getGoal:t,pauseGoal:n}=(io(),e(us)),{persistCurrentGoal:r}=(_n(),e(Br));t()?.status===`active`&&(n(),r())}if(Tt(!0),Mt.forceEnd(),gi.current=!1,Lr?.trim()&&G(e=>[...e,oi({content:Lr})]),Hi(),Kl(null),Ea===`tool-permission`)an[0]?.onAbort(),on([]);else if(Ea===`prompt`){for(let e of mn)e.reject(Error(`Prompt cancelled by user`));hn([]),vt?.abort(`user-cancel`)}else vt?.abort(`user-cancel`);bt(null),Ji(Nn.current,!0)}}let ja=(0,Q.useCallback)(()=>{let e=dn(ur,0);e&&(mr(e.text),_r(`prompt`),e.images.length>0&&wr(t=>{let n={...t};for(let t of e.images)n[t.id]=t;return n}))},[mr,_r,ur,wr]),Ma={setToolUseConfirmQueue:on,onCancel:ka,onAgentsKilled:()=>G(e=>[...e,es()]),isMessageSelectorVisible:ni||!!Oi,screen:Te,abortSignal:vt?.signal,popCommandFromQueue:ja,vimMode:Ei,isLocalJSXCommand:$t?.isLocalJSXCommand,isSearchingHistory:Mi,isHelpOpen:Pi,inputMode:gr,inputValue:ur,streamMode:ut};(0,Q.useEffect)(()=>{ru()>=5&&!li&&!xi&&(X(`tengu_cost_threshold_reached`,{}),wi(!0),bE()&&ui(!0))},[W,li,xi]);let Pa=(0,Q.useCallback)(async e=>new Promise(t=>{let n=!1;function r(e){n||(n=!0,t(e))}pn(t=>[...t,{hostPattern:e,resolvePromise:r}])}),[B,pe]);(0,Q.useEffect)(()=>{let e=ea.getSandboxUnavailableReason();if(e){if(ea.isSandboxRequired()){process.stderr.write(`\nError: sandbox required but unavailable: ${e}\n sandbox.failIfUnavailable is set — refusing to start without a working sandbox.\n\n`),ra(1,`other`);return}Y(`sandbox disabled: ${e}`,{level:`warn`}),Le({key:`sandbox-unavailable`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(q,{color:`warning`,children:`sandbox disabled`}),(0,$.jsx)(q,{dimColor:!0,children:` · /sandbox`})]}),priority:`medium`})}},[Le]),ea.isSandboxingEnabled()&&ea.initialize(Pa).catch(e=>{process.stderr.write(`\n❌ Sandbox Error: ${hu(e)}\n`),ra(1,`other`)});let Fa=(0,Q.useCallback)((e,t)=>{B(n=>({...n,toolPermissionContext:{...e,mode:t?.preserveMode?n.toolPermissionContext.mode:e.mode}})),setImmediate(e=>{e(e=>(e.forEach(e=>{e.recheckPermission()}),e))},on)},[B,on]),Ia=LE(on,Fa),Ra=(0,Q.useCallback)((e,t,r,i)=>{let a=pe.getState(),o=()=>{let e=pe.getState(),t=zn(e.toolPermissionContext,e.mcp.tools),n=Gp(nt,t,e.toolPermissionContext.mode);return M?Ga(M,n,!1,!0).resolvedTools:n};return{abortController:r,options:{commands:lt,tools:o(),debug:n,verbose:a.verbose,mainLoopModel:i,thinkingConfig:a.thinkingEnabled===!1?{type:`disabled`}:O,mcpClients:WE(d,a.mcp.clients),mcpResources:a.mcp.resources,ideInstallationStatus:Ge,isNonInteractiveSession:!1,dynamicMcpConfig:xe,theme:Ri,agentDefinitions:ot?{...a.agentDefinitions,allowedAgentTypes:ot}:a.agentDefinitions,customSystemPrompt:h,appendSystemPrompt:_,refreshTools:o},getAppState:()=>pe.getState(),setAppState:B,messages:e,setMessages:G,updateFileHistoryState(e){B(t=>{let n=e(t.fileHistory);return n===t.fileHistory?t:{...t,fileHistory:n}})},updateAttributionState(e){B(t=>{let n=e(t.attribution);return n===t.attribution?t:{...t,attribution:n}})},openMessageSelector:()=>{b||ii(!0)},onChangeAPIKey:ha,readFileState:ca.current,setToolJSX:rn,addNotification:Le,appendSystemMessage:e=>G(t=>[...t,e]),sendOSNotification:e=>{uv(e,me)},onChangeDynamicMcpConfig:we,onInstallIDEExtension:We,nestedMemoryAttachmentTriggers:new Set,loadedNestedMemoryPaths:fa.current,dynamicSkillDirTriggers:new Set,discoveredSkillNames:da.current,setResponseLength:Ir,pushApiMetricsEntry:void 0,setStreamMode:dt,onCompactProgress:e=>{switch(e.type){case`hooks_start`:$r(`claudeBlue_FOR_SYSTEM_SPINNER`),ti(`claudeBlueShimmer_FOR_SYSTEM_SPINNER`),Xr(e.hookType===`pre_compact`?`Running PreCompact hooks…`:e.hookType===`post_compact`?`Running PostCompact hooks…`:`Running SessionStart hooks…`);break;case`compact_start`:Xr(`Compacting conversation`);break;case`compact_end`:Xr(null),$r(null),ti(null);break}},setInProgressToolUseIDs:xr,setHasInterruptibleToolInProgress:e=>{Sr.current=e},resume:oa,setConversationId:fi,requestPrompt:void 0,contentReplacementState:bi.current}},[lt,nt,M,n,d,Ge,xe,Ri,ot,pe,B,ha,Le,G,we,oa,(0,Q.useCallback)((e,t)=>n=>new Promise((r,i)=>{hn(a=>[...a,{request:n,title:e,toolInputSummary:t,resolve:r,reject:i}])}),[]),b,h,_,fi]),{handleBackgroundSession:Ba}=cD({setMessages:G,setIsLoading:Gt,resetLoadingState:Hi,setAbortController:bt,onBackgroundQuery:(0,Q.useCallback)(()=>{vt?.abort(`background`);let e=je(e=>e.mode===`task-notification`);(async()=>{let t=Ra(Nn.current,[],new AbortController,he),[n,r,i]=await Promise.all([Ca(t.options.tools,he,Array.from(N.additionalWorkingDirectories.keys()),t.options.mcpClients),kt(),Aa()]),a=en({mainThreadAgentDefinition:M,toolUseContext:t,customSystemPrompt:h,defaultSystemPrompt:n,appendSystemPrompt:_});t.renderedSystemPrompt=a;let o=(await S(e).catch(()=>[])).map(Gr),s=new Set;for(let e of Nn.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)));Fs({messages:[...Nn.current,...c],queryParams:{systemPrompt:a,userContext:r,systemContext:i,canUseTool:Ia,toolUseContext:t,querySource:hr()},description:Sn,setAppState:B,agentDefinition:M})})()},[vt,he,N,M,Ra,h,_,Ia,B])}),Va=(0,Q.useCallback)(t=>{Tr(t,t=>{if(ps(t)?(Za()?G(e=>{let n=Dn(e,{includeSnipped:!0});return[...n.length>500?n.slice(-500):n,t]}):G(()=>[t]),fi(yg()),Wi(!1)):t.type===`progress`&&Si(t.data?.type)?G(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]}):G(e=>[...e,t]),t.type===`assistant`&&`isApiErrorMessage`in t&&t.isApiErrorMessage?Wi(!0):t.type===`assistant`&&Wi(!1),t.type===`assistant`&&`isApiErrorMessage`in t&&t.isApiErrorMessage){let n=(Ar(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}=(io(),e(us)),{persistCurrentGoal:r}=(_n(),e(Br));t()?.status===`active`&&(n(),r(),Le({key:`goal-auto-paused-connectivity-error`,text:`Detected connection error. Active goal was auto-paused. Run /goal resume after network recovers.`,priority:`immediate`}))}}},e=>{Ir(t=>t+e.length)},dt,ht,e=>{G(t=>t.filter(t=>t!==e)),Qo(e.uuid)},_t,e=>{let t=Date.now(),n=Nr.current;Fr.current.push({...e,firstTokenTime:t,lastTokenTime:t,responseLengthBaseline:n,endResponseLength:n})},Hr)},[G,Ir,dt,ht,_t,Hr]),Ha=(0,Q.useCallback)(async(e,t,n,r,i,a)=>{if(r){let e=WE(d,pe.getState().mcp.clients);ji.handleQueryStart(e);let t=E(e);t&&Xt(t)}if(If(),!k&&!gn&&!xn&&!bn.current){let e=t.find(e=>e.type===`user`&&!e.isMeta),n=e?.type===`user`?Ar(e.message.content):null;n&&!n.startsWith(`<local-command-stdout>`)&&!n.startsWith(`<command-message>`)&&!n.startsWith(`<command-name>`)&&!n.startsWith(`<bash-input>`)&&(bn.current=!0,gm(n,new AbortController().signal).then(e=>{e?yn(e):bn.current=!1},()=>{bn.current=!1}))}if(pe.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(ps)&&(fi(yg()),Wi(!1)),Hi(),bt(null);return}let o=Ra(e,t,n,a),{tools:s,mcpClients:c}=o.options;Ns(`query_context_loading_start`);let[,,l,u,f]=await Promise.all([void 0,UD(N,B,pe.getState().fastMode),Ca(s,a,Array.from(N.additionalWorkingDirectories.keys()),c),kt(),Aa()]),p={...u,...jr()&&!Li.current?{terminalFocus:`The terminal is unfocused — the user is not actively watching.`}:{}};Ns(`query_context_loading_end`);let m=en({mainThreadAgentDefinition:M,toolUseContext:o,customSystemPrompt:h,defaultSystemPrompt:l,appendSystemPrompt:_});o.renderedSystemPrompt=m,Ns(`query_query_start`),tu(),Ll(),Rl();for await(let t of $o({messages:e,systemPrompt:m,userContext:p,systemContext:f,canUseTool:Ia,toolUseContext:o,querySource:hr()}))Va(t);Ns(`query_end`),Hi(),Zr(),await y?.(Nn.current)},[d,Hi,Ra,N,B,h,y,_,Ia,M,Va,gn,k]),Wa=(0,Q.useCallback)(async(e,t,n,r,i,a,o)=>{let s=Mt.tryStart();if(s===null)return X(`tengu_concurrent_onquery_detected`,{}),e.filter(e=>e.type===`user`&&!e.isMeta).map(e=>Ar(e.message.content)).filter(e=>e!==null).forEach((e,t)=>{Us({value:e,mode:`prompt`}),t===0&&X(`tengu_concurrent_onquery_enqueued`,{})}),!1;try{Tt(!1),Ut(),G(t=>[...t,...e]),Nr.current=0,Kl((o?gs(o):null)??Wl()),Fr.current=[],ht([]),Rr(null);let s=Nn.current;if(o&&await qi(o,s,e.length),a&&o&&!await a(o,s))return!0;await Ha(s,e,t,n,r,i)}finally{if(Mt.end(s)){Tt(t.signal.aborted),qr(Date.now()),gi.current=!1,Hi(),await Ji(Nn.current,t.signal.aborted);let e;Wl()!==null&&Wl()>0&&!t.signal.aborted&&(e={tokens:kl(),limit:Wl(),nudges:au()}),Kl(null);let n=Date.now()-Bt.current-Vt.current;(n>3e4||e!==void 0)&&!t.signal.aborted&&!ve&&G(t=>[...t,Ai(n,e,Hu(t,Un))]),bt(null)}if(t.signal.reason===`user-cancel`&&!Mt.isActive&&fr.current===``&&Se()===0&&!pe.getState().viewingAgentTaskId){let e=Nn.current,t=e.findLast(Jp);t&&Yp(e,e.lastIndexOf(t))&&(Pp(),Et.current(t))}}return!0},[Ha,B,Hi,Mt,qi,Ji]),Ka=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{let e=ie;if(!e||U||Ka.current)return;Ka.current=!0;async function t(e){if(e.clearContext){let t=e.message.planContent?sn():void 0,{clearConversation:n}=await import(`./conversation-B0wxBwzv.js`);await n({setMessages:G,readFileState:ca.current,discoveredSkillNames:da.current,loadedNestedMemoryPaths:fa.current,getAppState:()=>pe.getState(),setAppState:B,setConversationId:fi}),bn.current=!1,yn(void 0),la.current.clear(),ua.current=0,t&&La(nu(),t)}B(t=>{let n=e.mode?fe(t.toolPermissionContext,Ib(e.mode,e.allowedPrompts)):t.toolPermissionContext;return e.mode===`auto`&&(n=za({...n,mode:`auto`,prePlanMode:void 0})),{...t,initialMessage:null,toolPermissionContext:n}}),wn()&&ys(e=>{B(t=>({...t,fileHistory:e(t.fileHistory)}))},e.message.uuid),await ar();let t=e.message.message.content;if(typeof t==`string`&&!e.message.planContent)qa(t,{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}});else{let t=Ss();bt(t),Wa([e.message],t,!0,[],he)}setTimeout(e=>{e.current=!1},100,Ka)}t(e)},[ie,U,G,B,Wa,he,at]);let qa=(0,Q.useCallback)(async(e,t,n,r)=>{if(tr(),g(),!n&&e.trim().startsWith(`/`)){let n=kp(e,Cr).trim(),i=n.indexOf(` `),a=i===-1?n.slice(1):n.slice(1,i),o=i===-1?``:n.slice(i+1).trim(),s=lt.find(e=>Ze(e)&&(e.name===a||e.aliases?.includes(a)||fn(e)===a));s?.name===`clear`&&In.current&&(X(`tengu_idle_return_action`,{action:`hint_converted`,variant:In.current,idleMinutes:Math.round((Date.now()-vi.current)/6e4),messageCount:Nn.current.length,totalInputTokens:Yl()}),In.current=!1);let c=Mt.isActive&&(s?.immediate||r?.fromKeybinding);if(s&&c&&s.type===`local-jsx`){e.trim()===fr.current.trim()&&(mr(``),t.setCursorOffset(0),t.clearBuffer(),wr({}));let n=Op(e).filter(e=>Cr[e.id]?.type===`text`),i=n.length;X(`tengu_paste_text`,{pastedTextCount:i,pastedTextBytes:n.reduce((e,t)=>e+(Cr[t.id]?.content.length??0),0)}),X(`tengu_immediate_command_executed`,{commandName:s.name,fromKeybinding:r?.fromKeybinding??!1}),(async()=>{let e=!1,n=(n,r)=>{e=!0,rn({jsx:null,shouldHidePromptInput:!1,clearLocalJSX:!0});let i=[];if(n&&r?.display!==`skip`&&(Le({key:`immediate-${s.name}`,text:n,priority:`immediate`}),!Za())){let e=r?.displayArgs??o;i.push(Do(uo(fn(s),e)),Do(`<${bd}>${Hn(n)}</${bd}>`))}r?.metaMessages?.length&&i.push(...r.metaMessages.map(e=>Lo({content:e,isMeta:!0}))),i.length&&G(e=>[...e,...i]),vr!==void 0&&(mr(vr.text),t.setCursorOffset(vr.cursorOffset),wr(vr.pastedContents),yr(void 0))},r=Ra(Nn.current,[],Ss(),he),i=await(await s.load()).call(n,r,o);i&&!e&&rn({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:yp(e,gr),pastedContents:n?{}:Cr}),gr===`bash`&&LS(e.trim()));let i=!n&&e.trim().startsWith(`/`),a=!U||n;if(vr!==void 0&&!i&&a?(mr(vr.text),t.setCursorOffset(vr.cursorOffset),wr(vr.pastedContents),yr(void 0)):a&&(r?.fromKeybinding||(mr(``),t.setCursorOffset(0)),wr({})),a&&(_r(`prompt`),He(void 0),Mr(e=>e+1),t.clearBuffer(),zi.current=!1,!i&&gr===`prompt`&&!n&&(Ln(e),Ut()),B(e=>({...e,attribution:so(e.attribution,e=>{Fn(e).catch(e=>{Y(`Attribution: Failed to save snapshot: ${e}`)})})}))),n){let{queryRequired:t}=await ri(n.state,n.speculationSessionTimeSavedMs,n.setAppState,e,{setMessages:G,readFileState:ca,cwd:Fl()});if(t){let e=Ss();bt(e),Wa([],e,!0,[],he)}return}await ar(),await zE({input:e,helpers:t,queryGuard:Mt,isExternalLoading:Pt,mode:gr,commands:lt,onInputChange:mr,setPastedContents:wr,setToolJSX:rn,getToolUseContext:Ra,messages:Nn.current,mainLoopModel:he,pastedContents:Cr,ideSelection:Ve,setUserInputOnProcessing:Ln,setAbortController:bt,abortController:vt,onQuery:Wa,setAppState:B,querySource:hr(),onBeforeQuery:v,canUseTool:Ia,addNotification:Le,setMessages:G,streamMode:ft.current,hasInterruptibleToolInProgress:Sr.current}),(i||U)&&vr!==void 0&&(mr(vr.text),t.setCursorOffset(vr.cursorOffset),wr(vr.pastedContents),yr(void 0))},[Mt,U,Pt,gr,lt,mr,_r,wr,Mr,He,rn,Ra,he,Cr,Ve,Ln,bt,Le,Wa,vr,yr,B,v,Ia,G,ar,tr]),Ja=(0,Q.useCallback)(()=>{let e=ga?uk(ga):`/issue`;_a(null),qa(e,{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}}).catch(t=>{Y(`Auto-run ${e} failed: ${hu(t)}`)})},[qa,ga]),Ya=(0,Q.useCallback)(()=>{_a(null)},[]),Xa=(0,Q.useCallback)(()=>{qa(`/issue`,{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}}).catch(e=>{Y(`Survey feedback request failed: ${e instanceof Error?e.message:String(e)}`)})},[qa]),Qa=(0,Q.useRef)(qa);Qa.current=qa;let $a=(0,Q.useCallback)(async()=>{if(Sa(!0),kr()){Tg(`tmux`,[`detach-client`],{stdio:`ignore`}),Sa(!1);return}if(zs()!==null){ba((0,$.jsx)(vh,{showWorktree:!0,onDone:()=>{},onCancel:()=>{ba(null),Sa(!1)}}));return}let e=await(await yt.load()).call(()=>{});ba(e),e===null&&Sa(!1)},[]),eo=(0,Q.useCallback)(()=>{ii(e=>!e)},[]),to=(0,Q.useCallback)(e=>{let t=Nn.current,n=t.lastIndexOf(e);if(n===-1)return;X(`tengu_conversation_rewind`,{preRewindMessageCount:t.length,postRewindMessageCount:n,messagesRemoved:t.length-n,rewindToMessageIndex:n}),G(t.slice(0,n)),fi(yg()),_c();let r=e.permissionMode;B(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}}))},[G,B]),no=(0,Q.useCallback)(e=>{to(e);let t=So(e);if(t&&(mr(t.text),_r(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}}}),wr(n)}}},[to,mr]);Et.current=no;let ro=(0,Q.useCallback)(async e=>{setImmediate((e,t)=>e(t),no,e)},[no]),ao=e=>{let t=e.slice(0,24);return W.findIndex(e=>e.uuid.slice(0,24)===t)},{enter:oo,handlers:co}=Ro(Xn,Zn,Qn,{copy:e=>void qc(e).then(e=>{e&&process.stdout.write(e),Le({key:`selection-copied`,text:`copied`,color:`success`,priority:`immediate`,timeoutMs:2e3})}),edit:async e=>{let t=ao(e.uuid),n=t>=0?W[t]:void 0;if(!n||!Jp(n))return;let r=!await Vi(L,n.uuid),i=Yp(W,t);r&&i?(ka(),ro(n)):(ci(n),ii(!0))}});async function lo(){ha();let e=await Jr();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)ca.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})}SE(Zh()),Av(W,W.length===i?.length),CE();let fo=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{if(ae.length<1){fo.current=!1;return}fo.current||(fo.current=!0,pd(e=>({...e,promptQueueUseCount:(e.promptQueueUseCount??0)+1})))},[ae.length]),UE({executeQueuedInput:(0,Q.useCallback)(async e=>{await zE({helpers:{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}},queryGuard:Mt,commands:lt,onInputChange:()=>{},setPastedContents:()=>{},setToolJSX:rn,getToolUseContext:Ra,messages:W,mainLoopModel:he,ideSelection:Ve,setUserInputOnProcessing:Ln,setAbortController:bt,onQuery:Wa,setAppState:B,querySource:hr(),onBeforeQuery:v,canUseTool:Ia,addNotification:Le,setMessages:G,queuedCommands:e})},[Mt,lt,rn,Ra,W,he,Ve,Ln,Ia,bt,Wa,Le,B,v]),hasActiveLocalJsxUI:On,queryGuard:Mt}),(0,Q.useEffect)(()=>{am.recordUserActivity(),Ml(!0)},[ur,Er]),(0,Q.useEffect)(()=>{Er===1&&og()},[Er]),(0,Q.useEffect)(()=>{if(U||Er===0||Wr===0)return;let e=setTimeout((e,t,n,r,i)=>{if(Dl()>e)return;let a=Date.now()-e;!t&&!n&&r.current===void 0&&a>=gd().messageIdleNotifThresholdMs&&uv({message:`Work Mate is waiting for your input`,notificationType:`idle_prompt`},i)},gd().messageIdleNotifThresholdMs,Wr,U,$t,Kt,me);return()=>clearTimeout(e)},[U,$t,Er,Wr,me]),(0,Q.useEffect)(()=>{},[Wr,U,Le,Re]),eD({isLoading:U||ie!==null,queuedCommandsLength:ae.length,hasActiveLocalJsxUI:On,isInPlanMode:N.mode===`plan`,onQueueTick:e=>Us(e)}),aD({isLoading:U||ie!==null,wasAborted:wt,queuedCommandsLength:ae.length,hasActiveLocalJsxUI:On,isInPlanMode:N.mode===`plan`,isQueryActiveNow:Mt.getSnapshot,onContinuationEnqueued:({turn:e,objective:t})=>{let n=`Goal auto-continue (${e}/1): continue advancing "${t}".`;G(e=>[...e,Lo({content:n,isVisibleInTranscriptOnly:!0})])},onMaxTurnsReached:()=>{Le({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(!ve){jt(null);return}if(!U){if(ye!==null&&ae.length===0&&!On&&N.mode!==`plan`&&ie===null){jt({enabled:!0,phase:`standby`,next_tick_at:ye,sleep_until:null});return}jt({enabled:!0,phase:null,next_tick_at:null,sleep_until:null})}},[ie,U,On,ve,ye,ae.length,N.mode]),(0,Q.useEffect)(()=>{ae.some(e=>e.priority===`now`)&&St.current?.abort(`interrupt`)},[ae]);let po=(0,Q.useRef)(lo);po.current=lo;let mo=(0,Q.useRef)(ji);mo.current=ji,(0,Q.useEffect)(()=>(po.current(),()=>{mo.current.shutdown()}),[]);let{internal_eventEmitter:ho}=Hc(),[go,_o]=(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=()=>{_o(e=>e+1)};return ho?.on(`suspend`,e),ho?.on(`resume`,t),()=>{ho?.off(`suspend`,e),ho?.off(`resume`,t)}},[ho]);let vo=(0,Q.useMemo)(()=>{if(!U)return null;let e=W.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||W.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=Hu(W,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}`},[W,U]),yo=(0,Q.useCallback)(()=>{lr({messagesLength:W.length,streamingToolUsesLength:pt.length})},[W.length,pt.length]),bo=(0,Q.useCallback)(()=>{lr(null)},[]),xo=Za()&&!j,Co=(0,Q.useRef)(null),[wo,To]=(0,Q.useState)(!1),[Eo,Oo]=(0,Q.useState)(``),[ko,Ao]=(0,Q.useState)(0),[Mo,No]=(0,Q.useState)(0),Fo=(0,Q.useCallback)((e,t)=>{Ao(e),No(t)},[]);Xc((e,t,n)=>{if(t.ctrl||t.meta)return;if(e===`/`){Co.current?.setAnchor(),To(!0),n.stopImmediatePropagation();return}let r=e[0];if((r===`n`||r===`N`)&&e===r.repeat(e.length)&&ko>0){let t=r===`n`?Co.current?.nextMatch:Co.current?.prevMatch;if(t)for(let n=0;n<e.length;n++)t();n.stopImmediatePropagation()}},{isActive:Te===`transcript`&&xo&&!wo&&!ke});let{setQuery:Io,scanElement:zo,setPositions:Bo}=rl(),Vo=tl().columns,Ho=Q.useRef(Vo);Q.useEffect(()=>{Ho.current!==Vo&&(Ho.current=Vo,(Eo||wo)&&(To(!1),Oo(``),Ao(0),No(0),Co.current?.disarmSearch(),Io(``)))},[Vo,Eo,wo,Io]),Xc((e,t,n)=>{if(!(t.ctrl||t.meta)){if(e===`q`){bo(),n.stopImmediatePropagation();return}if(e===`[`&&!ke)Ae(!0),Oe(!0),n.stopImmediatePropagation();else if(e===`v`){if(n.stopImmediatePropagation(),Ie.current)return;Ie.current=!0;let e=Pe.current,t=t=>{e===Pe.current&&(clearTimeout(Fe.current),Ne(t))};t(`rendering ${or.length} messages…`),(async()=>{try{let e=Math.max(80,(process.stdout.columns??80)-6),n=(await ov(or,at,e)).replace(/[ \t]+$/gm,``),r=pg(cg(),`cc-transcript-${Date.now()}.txt`);await Cg(r,n);let i=Vm(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===Pe.current&&(Fe.current=setTimeout(e=>e(``),4e3,Ne))})()}}},{isActive:Te===`transcript`&&xo&&!wo});let Uo=Te===`transcript`&&xo;(0,Q.useEffect)(()=>{Uo||(Oo(``),Ao(0),No(0),To(!1),Pe.current++,clearTimeout(Fe.current),Ae(!1),Ne(``))},[Uo]),(0,Q.useEffect)(()=>{Io(Uo?Eo:``),Uo||Bo(null)},[Uo,Eo,Io,Bo]);let Go={screen:Te,setScreen:Ee,showAllInTranscript:De,setShowAllInTranscript:Oe,messageCount:W.length,onEnterTranscript:yo,onExitTranscript:bo,virtualScrollActive:xo,searchBarOpen:wo},Ko=cr?or.slice(0,cr.messagesLength):or,qo=cr?pt.slice(0,cr.streamingToolUsesLength):pt;jE({onOpenBackgroundTasks:On?void 0:()=>ki(!0)});let Jo=le?R[le]:void 0,Yo=Jo&&Wo(Jo)?Jo:void 0,Xo=Vr||!U,Zo=Yo?.messages,ts=(0,Q.useMemo)(()=>{if(!Yo)return;let e=Zo??[];if(!Wo(Yo)||Yo.agentType!==`fork`||!Yo.prompt)return e;let t=Yo.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(nA))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=>!nA(e))}});if(i)return a;let o=n===-1?r+1:n+1,s=Lo({content:Yo.prompt,timestamp:new Date(Yo.startTime).toISOString()});return[...a.slice(0,o),s,...a.slice(o)]},[Yo,Zo]),ns=Yo?ts??[]:Xo?W:or;if(Te===`transcript`){let e=Za()&&!j&&!ke?Dt:void 0,t=(0,$.jsx)(Wh,{messages:Ko,tools:at,commands:lt,verbose:!0,toolJSX:null,toolUseConfirmQueue:[],inProgressToolUseIDs:br,isMessageSelectorVisible:!1,conversationId:di,screen:Te,agentDefinitions:I,streamingToolUses:qo,showAllInTranscript:De,isLoading:U,hidePastThinking:!0,streamingThinking:gt,scrollRef:e,jumpRef:Co,onSearchMatchesChange:Fo,scanElement:zo,setPositions:Bo,disableRenderCap:ke}),n=$t&&(0,$.jsx)(K,{flexDirection:`column`,width:`100%`,children:$t.jsx}),r=(0,$.jsxs)(Vp,{children:[(0,$.jsx)(eA,{isAnimating:kn,title:Sn,disabled:k,noPrefix:!1}),(0,$.jsx)(EE,{...Go}),(0,$.jsx)(OE,{onSubmit:qa,isActive:!$t?.isLocalJSXCommand}),e?(0,$.jsx)(Bk,{scrollRef:Dt,isActive:!0,isModal:!wo,onScroll:()=>Co.current?.disarmSearch()}):null,(0,$.jsx)(AE,{...Ma}),e?(0,$.jsx)(Hh,{scrollRef:Dt,scrollable:(0,$.jsxs)($.Fragment,{children:[t,n,(0,$.jsx)(JD,{})]}),bottom:wo?(0,$.jsx)(Xk,{jumpRef:Co,initialQuery:``,count:ko,current:Mo,onClose:e=>{Oo(ko>0?e:``),To(!1),e||(Ao(0),No(0),Co.current?.setSearchQuery(``))},onCancel:()=>{To(!1),Co.current?.setSearchQuery(``),Co.current?.setSearchQuery(Eo),Io(Eo)},setHighlight:Io}):(0,$.jsx)(Yk,{showAllInTranscript:De,virtualScroll:!0,status:Me||void 0,searchBadge:Eo&&ko>0?{current:Mo,count:ko}:void 0})}):(0,$.jsxs)($.Fragment,{children:[t,n,(0,$.jsx)(JD,{}),(0,$.jsx)(Yk,{showAllInTranscript:De,virtualScroll:!1,suppressShowAll:ke,status:Me||void 0})]})]});return e?(0,$.jsx)(ul,{mouseTracking:A(),children:r}):r}let is=It&&!Yo&&ns.length<=Rt.current?It:void 0,os=Ea===`tool-permission`?(0,$.jsx)(dx,{onDone:()=>on(([e,...t])=>t),onReject:ja,toolUseConfirm:an[0],toolUseContext:Ra(W,W,vt??Ss(),he),verbose:P,setStickyFooter:Za()?ln:void 0},an[0]?.toolUseID):null,cs=Za()&&$t?.isLocalJSXCommand===!0,ls=cs?$t.jsx:null,ds=(0,$.jsxs)(Vp,{children:[(0,$.jsx)(eA,{isAnimating:kn,title:Sn,disabled:k,noPrefix:!1}),(0,$.jsx)(EE,{...Go}),(0,$.jsx)(OE,{onSubmit:qa,isActive:!$t?.isLocalJSXCommand}),(0,$.jsx)(Bk,{scrollRef:Dt,isActive:Za()&&(ls!=null||!Ea||Ea===`tool-permission`),onScroll:ir}),null,(0,$.jsx)(AE,{...Ma}),(0,$.jsx)(Wp,{dynamicMcpConfig:xe,isStrictMcpConfig:m,children:(0,$.jsx)(Hh,{scrollRef:Dt,overlay:os,modal:ls,modalScrollRef:Ot,dividerYRef:Bn,hidePill:!!Yo,newMessageCount:er?.count??0,onPillClick:()=>{Zn(null),Gn(Dt.current)},scrollable:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Wh,{messages:ns,tools:at,commands:lt,verbose:P,toolJSX:$t,toolUseConfirmQueue:an,inProgressToolUseIDs:br,isMessageSelectorVisible:ni,conversationId:di,screen:Te,streamingToolUses:pt,showAllInTranscript:De,agentDefinitions:I,isLoading:U,streamingText:U&&!Yo?Ur:null,unseenDivider:Yo?void 0:er,scrollRef:Za()?Dt:void 0,trackStickyPrompt:Za()?!0:void 0,cursor:Xn,setCursor:Zn,cursorNavRef:Qn}),!b&&is&&!ls&&(0,$.jsx)(re,{param:{text:is,type:`text`},addMargin:!0,verbose:P}),$t&&!($t.isLocalJSXCommand&&$t.isImmediate)&&!cs&&(0,$.jsx)(K,{flexDirection:`column`,width:`100%`,children:$t.jsx}),(0,$.jsx)(K,{flexGrow:1}),Xi&&(0,$.jsx)(lm,{mode:ut,spinnerTip:oe,responseLengthRef:Nr,apiMetricsRef:Fr,overrideMessage:Yr,spinnerSuffix:vo,verbose:P,loadingStartTimeRef:Bt,totalPausedMsRef:Vt,pauseStartTimeRef:Ht,overrideColor:Qr,overrideShimmerColor:ei,hasActiveTools:br.size>0,leaderIsIdle:!U})]}),bottom:(0,$.jsx)(K,{flexDirection:`row`,width:`100%`,alignItems:`flex-end`,children:(0,$.jsxs)(K,{flexDirection:`column`,flexGrow:1,children:[Za()&&(0,$.jsx)(HT,{}),cn,$t?.isLocalJSXCommand&&$t.isImmediate&&!cs&&(0,$.jsx)(K,{flexDirection:`column`,width:`100%`,children:$t.jsx}),!Xi&&!$t?.isLocalJSXCommand&&se&&rt&&rt.length>0&&(0,$.jsx)(K,{width:`100%`,flexDirection:`column`,children:(0,$.jsx)(cm,{tasks:rt,isStandalone:!0})}),Ea===`sandbox-permission`&&(0,$.jsx)(KD,{hostPattern:un[0].hostPattern,onUserResponse:e=>{let{allow:t,persistToSettings:n}=e,r=un[0];if(!r)return;let i=r.hostPattern.host;pn(e=>(e.filter(e=>e.hostPattern.host===i).forEach(e=>e.resolvePromise(t)),e.filter(e=>e.hostPattern.host!==i)))}},un[0].hostPattern.host),Ea===`prompt`&&(0,$.jsx)(Fx,{title:mn[0].title,toolInputSummary:mn[0].toolInputSummary,request:mn[0].request,onRespond:e=>{let t=mn[0];t&&(t.resolve({prompt_response:t.request.prompt,selected:e}),hn(([,...e])=>e))},onAbort:()=>{let e=mn[0];e&&(e.reject(Error(`Prompt cancelled by user`)),hn(([,...e])=>e))}},mn[0].request.prompt),Ea===`elicitation`&&(0,$.jsx)(Mx,{event:z.queue[0],onResponse:(e,t)=>{let n=z.queue[0];n&&(n.respond({action:e,content:t}),n.params.mode===`url`&&e===`accept`||B(e=>({...e,elicitation:{queue:e.elicitation.queue.slice(1)}})))},onWaitingDismiss:e=>{let t=z.queue[0];B(e=>({...e,elicitation:{queue:e.elicitation.queue.slice(1)}})),t?.onWaitingDismiss?.(e)}},`${z.queue[0].serverName}:${String(z.queue[0].requestId)}`),Ea===`cost`&&(0,$.jsx)(sv,{onDone:()=>{ui(!1),wi(!0),pd(e=>({...e,hasAcknowledgedCostThreshold:!0})),X(`tengu_cost_threshold_acknowledged`,{})}}),Ea===`idle-return`&&mi&&(0,$.jsx)(cv,{idleMinutes:mi.idleMinutes,totalInputTokens:Yl(),onDone:async e=>{let t=mi;if(hi(null),X(`tengu_idle_return_action`,{action:e,idleMinutes:Math.round(t.idleMinutes),messageCount:Nn.current.length,totalInputTokens:Yl()}),e===`dismiss`){mr(t.input);return}if(e===`never`&&pd(e=>e.idleReturnDismissed?e:{...e,idleReturnDismissed:!0}),e===`clear`){let{clearConversation:e}=await import(`./conversation-B0wxBwzv.js`);await e({setMessages:G,readFileState:ca.current,discoveredSkillNames:da.current,loadedNestedMemoryPaths:fa.current,getAppState:()=>pe.getState(),setAppState:B,setConversationId:fi}),bn.current=!1,yn(void 0),la.current.clear(),ua.current=0}gi.current=!0,Qa.current(t.input,{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}})}}),Ea===`ide-onboarding`&&(0,$.jsx)(te,{onDone:()=>Je(!1),installationStatus:Ge}),ya,Ea===`plugin-hint`&&$e&&(0,$.jsx)(bO,{pluginName:$e.pluginName,pluginDescription:$e.pluginDescription,marketplaceName:$e.marketplaceName,sourceCommand:$e.sourceCommand,onResponse:et}),Ea===`search-extra-tools-hint`&&tt.visible&&(0,$.jsx)(SO,{tools:tt.tools,onSelect:tt.handleSelect,onDismiss:tt.handleDismiss}),Ea===`lsp-recommendation`&&V&&(0,$.jsx)(_O,{pluginName:V.pluginName,pluginDescription:V.pluginDescription,fileExtension:V.fileExtension,onResponse:Qe}),Ea===`desktop-upsell`&&(0,$.jsx)(VO,{onDone:()=>Xe(!1)}),Yi(),!$t?.shouldHidePromptInput&&!Ea&&!xa&&!b&&!Xn&&(0,$.jsxs)($.Fragment,{children:[ga&&(0,$.jsx)(ck,{onRun:Ja,onCancel:Ya,reason:dk(ga)}),ia.state===`closed`?aa.state===`closed`?(0,$.jsx)(OD,{state:na.state,lastResponse:na.lastResponse,handleSelect:na.handleSelect,handleTranscriptSelect:na.handleTranscriptSelect,inputValue:ur,setInputValue:mr,onRequestFeedback:va.current?void 0:Xa}):(0,$.jsx)(OD,{state:aa.state,lastResponse:aa.lastResponse,handleSelect:aa.handleSelect,handleTranscriptSelect:aa.handleTranscriptSelect,inputValue:ur,setInputValue:mr,onRequestFeedback:Xa,message:`How well did Work Mate use its memory? (optional)`}):(0,$.jsx)(OD,{state:ia.state,lastResponse:ia.lastResponse,handleSelect:ia.handleSelect,inputValue:ur,setInputValue:mr,onRequestFeedback:Xa}),$i.suggestion&&(0,$.jsx)(mE,{isOpen:$i.isOpen,skillName:$i.suggestion.skillName,updates:$i.suggestion.updates,handleSelect:$i.handleSelect,inputValue:ur,setInputValue:mr}),ta&&(0,$.jsx)(fk,{}),(0,$.jsx)(oE,{debug:n,ideSelection:Ve,hasSuppressedDialogs:!!Da,isLocalJSXCommandActive:On,getToolUseContext:Ra,toolPermissionContext:N,setToolPermissionContext:Fa,apiKeyStatus:ma,commands:lt,agents:I.activeAgents,isLoading:U,onExit:$a,verbose:P,messages:W,onAutoUpdaterResult:Qt,autoUpdaterResult:Yt,input:ur,onInputChange:mr,mode:gr,onModeChange:_r,stashedPrompt:vr,setStashedPrompt:yr,submitCount:Er,onShowMessageSelector:eo,onMessageActionsEnter:void 0,mcpClients:Be,pastedContents:Cr,setPastedContents:wr,vimMode:Ei,setVimMode:Di,showBashesDialog:Oi,setShowBashesDialog:ki,onSubmit:qa,isSearchingHistory:Mi,setIsSearchingHistory:Ni,helpOpen:Pi,setHelpOpen:Fi,insertTextRef:pr}),(0,$.jsx)(sD,{onBackgroundSession:Ba,isLoading:U}),(0,$.jsx)(QE,{})]}),Xn&&(0,$.jsx)(ss,{cursor:Xn}),Ea===`message-selector`&&(0,$.jsx)(Qp,{messages:W,preselectedMessage:ai,onPreRestore:ka,onRestoreCode:async e=>{await rs(e=>{B(t=>({...t,fileHistory:e(t.fileHistory)}))},e.uuid)},onSummarize:async(e,t,n=`from`)=>{let r=Dn(W),i=r.indexOf(e);if(i===-1){G(e=>[...e,Cs(`That message is no longer in the active context (snipped or pre-compact). Choose a more recent message.`,`warning`)]);return}let a=Ss(),o=Ra(r,[],a,he),s=o.getAppState(),c=await Ca(o.options.tools,o.options.mainLoopModel,Array.from(s.toolPermissionContext.additionalWorkingDirectories.keys()),o.options.mcpClients),l=en({mainThreadAgentDefinition:void 0,toolUseContext:o,customSystemPrompt:o.options.customSystemPrompt,defaultSystemPrompt:c,appendSystemPrompt:o.options.appendSystemPrompt}),[u,d]=await Promise.all([kt(),Aa()]),f=await Pr(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(Za()&&n===`from`?G(t=>{let n=t.findIndex(t=>t.uuid===e.uuid);return[...t.slice(0,n===-1?0:n),...h]}):G(h),Wi(!1),fi(yg()),Js(o.options.querySource),n===`from`){let t=So(e);t&&(mr(t.text),_r(t.mode))}let g=Ms(`app:toggleTranscript`,`Global`,`ctrl+o`);Le({key:`summarize-ctrl-o-hint`,text:`Conversation summarized (${g} for history)`,priority:`medium`,timeoutMs:8e3})},onRestoreMessage:ro,onClose:()=>{ii(!1),ci(void 0)}})]})})})},go)]});return Za()?(0,$.jsx)(ul,{mouseTracking:A(),children:ds}):ds}export{rA as t};
|