@readmagic/workmate 0.0.12 → 0.0.13
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-CtRxzRny.js → AddWorkspaceDirectory-BzNj9rS6.js} +1 -1
- package/dist/chunks/AgentsMdExternalIncludesDialog-CDZPR488.js +1 -0
- package/dist/chunks/{AgentsMdExternalIncludesDialog-_yJJ0wqu.js → AgentsMdExternalIncludesDialog-CH9x1Ngp.js} +1 -1
- package/dist/chunks/App-D-bYAYAl.js +1 -0
- package/dist/chunks/ApproveApiKey-BEGV9Zj9.js +1 -0
- package/dist/chunks/ApproveApiKey-CjacpIqq.js +1 -0
- package/dist/chunks/BackgroundTasksDialog-A9hw_SV0.js +2 -0
- package/dist/chunks/{BypassPermissionsModeDialog-COI_V57z.js → BypassPermissionsModeDialog-B0BizN_J.js} +1 -1
- package/dist/chunks/{DiffDialog-CRWtQ1R5.js → DiffDialog-mQ-5_TSv.js} +3 -3
- package/dist/chunks/Doctor-BC6IuQhd.js +3 -0
- package/dist/chunks/Doctor-i_5_AQd-.js +1 -0
- package/dist/chunks/ExitFlow-Bu2cVGpC.js +2 -0
- package/dist/chunks/{Grove-DRZrhbF0.js → Grove-D0nn8zOV.js} +2 -2
- package/dist/chunks/{HybridTransport-BadJQe6u.js → HybridTransport-BQNLZNa_.js} +2 -2
- package/dist/chunks/InvalidConfigDialog-C5CIiSIE.js +1 -0
- package/dist/chunks/{InvalidSettingsDialog-ISzcIGPU.js → InvalidSettingsDialog-Dq7hKXcO.js} +1 -1
- package/dist/chunks/MCPConnectionManager-aDDsYkGM.js +1 -0
- package/dist/chunks/MCPToolListView-Cr0MDkzT.js +1 -0
- package/dist/chunks/{McpParsingWarnings-xv0RZCSL.js → McpParsingWarnings-CUx2zexI.js} +1 -1
- package/dist/chunks/MessageSelector-DwGOWKKL.js +3 -0
- package/dist/chunks/Messages-C1jh4ixt.js +11 -0
- package/dist/chunks/Onboarding-t-P6Q5O6.js +1 -0
- package/dist/chunks/{PromptInputFooterSuggestions-8-awCxOn.js → PromptInputFooterSuggestions-R12fbdmp.js} +1 -1
- package/dist/chunks/PromptInputHelpMenu-BgADIzRj.js +1 -0
- package/dist/chunks/QueryEngine-HlLQJmsd.js +1 -0
- package/dist/chunks/REPL-Rs_JQkDc.js +1 -0
- package/dist/chunks/REPL-VKAmKkII.js +133 -0
- package/dist/chunks/RemoteSessionManager-BbgXeM-t.js +2 -0
- package/dist/chunks/ResumeConversation-66zbx12g.js +1 -0
- package/dist/chunks/{SSETransport-je346ofV.js → SSETransport-BBQkdn4e.js} +1 -1
- package/dist/chunks/SearchExtraToolsTool-Bq87I_vu.js +1 -0
- package/dist/chunks/Settings-BKdLcyXe.js +2 -0
- package/dist/chunks/{TeleportProgress-zmdAsogZ.js → TeleportProgress-3hmIApkj.js} +1 -1
- package/dist/chunks/{TeleportRepoMismatchDialog-CG32I4cO.js → TeleportRepoMismatchDialog-BA1a66RK.js} +1 -1
- package/dist/chunks/{TeleportResumeWrapper-2Yjr74Lq.js → TeleportResumeWrapper-BT4O-Wsi.js} +1 -1
- package/dist/chunks/{ThemePicker-p7_hHk1V.js → ThemePicker-DUlhcoso.js} +1 -1
- package/dist/chunks/{TrustDialog-BVcny9vs.js → TrustDialog-Dpk03V1Y.js} +1 -1
- package/dist/chunks/add-dir-BUr0z-VU.js +1 -0
- package/dist/chunks/{agentDisplay-CfMLGPGH.js → agentDisplay-D7bdOOG7.js} +1 -1
- package/dist/chunks/{agents-BT82hwBN.js → agents-22wiC58F.js} +1 -1
- package/dist/chunks/agents-8ELI8RJo.js +103 -0
- package/dist/chunks/{allErrors-CS77lRvU.js → allErrors-C1eMbHSv.js} +1 -1
- package/dist/chunks/api-DgjIFdMn.js +1 -0
- package/dist/chunks/{api-DAubp5q9.js → api-f3GN2I_J.js} +1 -1
- package/dist/chunks/auth-B73a4Cob.js +1 -0
- package/dist/chunks/{auth-yDsvFcM7.js → auth-Czy7GoRh.js} +1 -1
- package/dist/chunks/auth-D_0waidQ.js +1 -0
- package/dist/chunks/backgroundHousekeeping-C_ArdTFX.js +17 -0
- package/dist/chunks/backgroundHousekeeping-YJhvZ0dh.js +1 -0
- package/dist/chunks/{branch-DJiMa8td.js → branch-bb4-bErF.js} +2 -2
- package/dist/chunks/{bridgeConfig-BB6Hgali.js → bridgeConfig-B80T_lw7.js} +1 -1
- package/dist/chunks/bridgeConfig-DywkIo_k.js +1 -0
- package/dist/chunks/{bridgeMessaging-C9D0Lly2.js → bridgeMessaging-DyvHd16Z.js} +1 -1
- package/dist/chunks/{bridgeStatusUtil-D8UbcVrZ.js → bridgeStatusUtil-DStiD05t.js} +1 -1
- package/dist/chunks/{btw-BO2B23f-.js → btw-BRmV51bR.js} +1 -1
- package/dist/chunks/caches-C5DIVdvI.js +1 -0
- package/dist/chunks/caches-zDZEgNKq.js +1 -0
- package/dist/chunks/{ccrClient-BG9HU_fW.js → ccrClient-BALhzhPF.js} +1 -1
- package/dist/chunks/{clear-B4XN2fib.js → clear-B_yVyJXP.js} +1 -1
- package/dist/chunks/client-DVg8PpFX.js +1 -0
- package/dist/chunks/commands-ByFXqW43.js +1 -0
- package/dist/chunks/compact-BUShp2eQ.js +2 -0
- package/dist/chunks/config-BwHNU_pI.js +1 -0
- package/dist/chunks/{context-BY5oO5is.js → context-6Pk3iVhh.js} +1 -1
- package/dist/chunks/{context-noninteractive-mAQt1p9l.js → context-noninteractive-CHzerxnH.js} +2 -2
- package/dist/chunks/context-noninteractive-DFwRQyFE.js +1 -0
- package/dist/chunks/conversation-5zb5XkSA.js +1 -0
- package/dist/chunks/conversation-JP2ZXrwu.js +1 -0
- package/dist/chunks/{createSSHSession-DjLSGm-0.js → createSSHSession-XkHMiGRN.js} +1 -1
- package/dist/chunks/{createSession-CftIZ3aq.js → createSession-BNGm9fL4.js} +1 -1
- package/dist/chunks/createSession-VTqzWAu6.js +1 -0
- package/dist/chunks/crossProjectResume-DxgQVYSi.js +40 -0
- package/dist/chunks/{datadog-BGati3aQ.js → datadog-3WUWcCFn.js} +1 -1
- package/dist/chunks/{diff-1HsxKGBh.js → diff-CKlLimGq.js} +1 -1
- package/dist/chunks/doctor-Bvx0u0sO.js +1 -0
- package/dist/chunks/entry-DCbq734V.js +14 -0
- package/dist/chunks/{esm-BkOWaWVb.js → esm-CtQkOk5D.js} +1 -1
- package/dist/chunks/exit-DTsz5Lcb.js +1 -0
- package/dist/chunks/{extraUsage-0pUcYexI.js → extraUsage-C86bZVgt.js} +1 -1
- package/dist/chunks/extractMemories-6OnMgL2S.js +1 -0
- package/dist/chunks/fast-B2ziqJEA.js +1 -0
- package/dist/chunks/{fast-VOu2FUlV.js → fast-BkhjaTkZ.js} +1 -1
- package/dist/chunks/{fileSuggestions-Be-pyLLq.js → fileSuggestions-BalHmi1-.js} +2 -2
- package/dist/chunks/{firstPartyEventLogger-aFhcruXA.js → firstPartyEventLogger-1RTgXHSz.js} +2 -2
- package/dist/chunks/firstPartyEventLogger-CXMzhLrF.js +1 -0
- package/dist/chunks/{flushGate-BUSrMj_6.js → flushGate-DWL05x7v.js} +1 -1
- package/dist/chunks/{gemini-DB4M-MYv.js → gemini-BLpLJyli.js} +1 -1
- package/dist/chunks/generateSessionName-CdbMksHi.js +1 -0
- package/dist/chunks/goal-V3qix-i1.js +3 -0
- package/dist/chunks/grok-BLLATotv.js +1 -0
- package/dist/chunks/{grove-BnzBbGsX.js → grove-b9gGKgu4.js} +2 -2
- package/dist/chunks/{help-C5ankDi4.js → help-BR7UEr5R.js} +1 -1
- package/dist/chunks/{hooks-BZS105Rd.js → hooks-C-QMGvCg.js} +2 -2
- package/dist/chunks/hooks-D6wtd0Qq.js +1 -0
- package/dist/chunks/{initReplBridge-DL4klK0C.js → initReplBridge-DyScxedy.js} +1 -1
- package/dist/chunks/{install-NZvHd_40.js → install-DGH_bjUh.js} +1 -1
- package/dist/chunks/{instrumentation-CjBlVlFq.js → instrumentation-DQ705pC7.js} +3 -3
- package/dist/chunks/{job-D502Zf8J.js → job-BaMT6Lb2.js} +1 -1
- package/dist/chunks/keybindings-CG292HS1.js +2 -0
- package/dist/chunks/{launchLocalMemory-DxC3LojF.js → launchLocalMemory-CtZrkmaw.js} +2 -2
- package/dist/chunks/{launchOnboarding-BLp5k_H4.js → launchOnboarding-CyOtdZkT.js} +1 -1
- package/dist/chunks/loadAgentsDir-4UC4yLg1.js +1 -0
- package/dist/chunks/{loadAgentsDir-BXtV2jiO.js → loadAgentsDir-mcRW90aq.js} +389 -390
- package/dist/chunks/loadPluginHooks-CWI0RMUx.js +1 -0
- package/dist/chunks/{localSearch-CeP4ef0a.js → localSearch-CCCDKpYx.js} +1 -1
- package/dist/chunks/localSearch-D4hVR7-d.js +1 -0
- package/dist/chunks/{logoV2Utils-CEnU8qad.js → logoV2Utils--8OUQQPd.js} +1 -1
- package/dist/chunks/{magicDocs-YtfrqVC6.js → magicDocs-26J_l1De.js} +2 -2
- package/dist/chunks/main-DUjtDK1Q.js +513 -0
- package/dist/chunks/managedEnv-BuCurT_S.js +1 -0
- package/dist/chunks/{managedEnv-B-BNY0xC.js → managedEnv-Ds6MlFQE.js} +1 -1
- package/dist/chunks/{mappers-IuJeXgvr.js → mappers-DwZw084m.js} +1 -1
- package/dist/chunks/mcp-CEKR7PjL.js +6 -0
- package/dist/chunks/mcp-DCAf2hHD.js +1 -0
- package/dist/chunks/mcp-mCuc8dNe.js +2 -0
- package/dist/chunks/memory-B5SkpC7u.js +1 -0
- package/dist/chunks/{mode-GzBwK--u.js → mode-B80CHkqo.js} +2 -2
- package/dist/chunks/model-BqaneI4D.js +1 -0
- package/dist/chunks/{model-CDnVaVDR.js → model-C29_32BD.js} +1 -1
- package/dist/chunks/{model-BydaMaPr.js → model-NG8fvuT2.js} +1 -1
- package/dist/chunks/{modelOptions-ut0xePEe.js → modelOptions-CiZgZxZC.js} +1 -1
- package/dist/chunks/{nativeInstaller-fgCMR_c0.js → nativeInstaller-DqbEfGSX.js} +1 -1
- package/dist/chunks/{omit-D4Udf-p-.js → omit-KEhe84f4.js} +1 -1
- package/dist/chunks/{onChangeAppState-WbvtqDtk.js → onChangeAppState-Dq1tIEJI.js} +1 -1
- package/dist/chunks/{openai-DaVFXyBB.js → openai-BvnsYTpQ.js} +3 -3
- package/dist/chunks/{partition-CzW_31Y1.js → partition-DeT341qu.js} +1 -1
- package/dist/chunks/permissions-BPpeHxpk.js +3 -0
- package/dist/chunks/pidLock-DQGDoFQP.js +3 -0
- package/dist/chunks/{plan-M9DG3AqN.js → plan-BRiC5ujG.js} +1 -1
- package/dist/chunks/plugin-Dcg_GGR9.js +17 -0
- package/dist/chunks/{pluginAutoupdate-B5lel6s5.js → pluginAutoupdate-ByH9IPC9.js} +1 -1
- package/dist/chunks/pluginBlocklist-BfoLN9a-.js +1 -0
- package/dist/chunks/pluginCliCommands-Bc2Iybhz.js +1 -0
- package/dist/chunks/{pluginFlagging-CXSSOj4J.js → pluginFlagging-Cr0d0hBA.js} +1 -1
- package/dist/chunks/pluginOperations-CKNyYjS-.js +2 -0
- package/dist/chunks/pluginStartupCheck-B48_cGgo.js +1 -0
- package/dist/chunks/{pluginStartupCheck-BEd0VeQC.js → pluginStartupCheck-DiCDQQlr.js} +1 -1
- package/dist/chunks/plugins-BP_36tOl.js +4 -0
- package/dist/chunks/print-2uavraPq.js +26 -0
- package/dist/chunks/processBashCommand-g3sAMpHt.js +1 -0
- package/dist/chunks/processSlashCommand-tIbeCrv5.js +5 -0
- package/dist/chunks/{prompt-CRc2QEZ5.js → prompt-DIlq8NTy.js} +1 -1
- package/dist/chunks/prompt-DLv-Cd67.js +1 -0
- package/dist/chunks/prompt-DV5tCLRh.js +1 -0
- package/dist/chunks/{promptEditor-Bo1d8ZLq.js → promptEditor-BILqOGl1.js} +2 -2
- package/dist/chunks/{reconciler-BGav_ezX.js → reconciler-CDq6XgAS.js} +1 -1
- package/dist/chunks/refresh-ysrhoWCo.js +1 -0
- package/dist/chunks/{reload-plugins-DNEgQ5vo.js → reload-plugins-CGb0HTsH.js} +1 -1
- package/dist/chunks/{remoteBridgeCore-BGOqHADF.js → remoteBridgeCore-BmteXmI9.js} +1 -1
- package/dist/chunks/{remoteManagedSettings-26nhzuca.js → remoteManagedSettings-CwDGxL5p.js} +1 -1
- package/dist/chunks/rename-1GLIUlYk.js +1 -0
- package/dist/chunks/resume-DWtlUiHW.js +2 -0
- package/dist/chunks/{runtimeObserver-BZrF3GnQ.js → runtimeObserver-4ZqaCXYy.js} +4 -4
- package/dist/chunks/{runtimeObserver-CBV-7-w7.js → runtimeObserver-CtNY8Al2.js} +1 -1
- package/dist/chunks/sandbox-adapter-BzjRQh_r.js +1 -0
- package/dist/chunks/{sandbox-toggle-D61gVqcT.js → sandbox-toggle-Bz49-F6e.js} +1 -1
- package/dist/chunks/searchExtraTools-D6vj8qJ-.js +1 -0
- package/dist/chunks/{session-Dy-_R7KP.js → session-wb6X4Wrq.js} +1 -1
- package/dist/chunks/sessionFileAccessHooks-Da97UA2n.js +1 -0
- package/dist/chunks/{sessionObserver-CyLpHSkw.js → sessionObserver-BJQ5hwjU.js} +2 -2
- package/dist/chunks/sessionObserver-DXO4trhk.js +1 -0
- package/dist/chunks/{sessionState-DSWN4tMV.js → sessionState-Bn3ESS5f.js} +1 -1
- package/dist/chunks/sessionStorage-DlPVsQn9.js +1 -0
- package/dist/chunks/{sessionTitle-L5tyJgdU.js → sessionTitle-Cbzrb9jT.js} +2 -2
- package/dist/chunks/{sessionTracing-DpHGGIZm.js → sessionTracing-CEsm8pZL.js} +1 -1
- package/dist/chunks/{settingsSync-dBqlrbcU.js → settingsSync-eHaSngKo.js} +1 -1
- package/dist/chunks/setup-DeyiuGNX.js +3 -0
- package/dist/chunks/{shadowedRuleDetection-DZ0AA2Rw.js → shadowedRuleDetection-D5X5fhzj.js} +1 -1
- package/dist/chunks/{sideQuestion-BYT8FdPF.js → sideQuestion-BHRtwhyj.js} +3 -3
- package/dist/chunks/{sinks-mFsijQ_S.js → sinks-Bgy2UNK-.js} +2 -2
- package/dist/chunks/sinks-CgzLmim2.js +1 -0
- package/dist/chunks/skillChangeDetector-BlSP16j6.js +1 -0
- package/dist/chunks/{skillGapStore-DQXHqoP7.js → skillGapStore-BjQSSz2E.js} +2 -2
- package/dist/chunks/{skillLifecycle-BG_RnGSh.js → skillLifecycle-Sp8strFv.js} +2 -2
- package/dist/chunks/{skillSearchPanel-DxYP4Q6R.js → skillSearchPanel-3sYRez_Q.js} +4 -4
- package/dist/chunks/{skills-BD-2ofXA.js → skills-CJhWI8t1.js} +1 -1
- package/dist/chunks/{status-BmHu-c7I.js → status-CDCurOqs.js} +2 -2
- package/dist/chunks/{status-CrmnCDIE.js → status-yoQIQ2Ni.js} +1 -1
- package/dist/chunks/statusNoticeHelpers-Sl4jjauz.js +1 -0
- package/dist/chunks/switcher-C-m6MUwE.js +1 -0
- package/dist/chunks/{switcher-sYTxnJQA.js → switcher-uoQMHmEZ.js} +1 -1
- package/dist/chunks/{syncCache-BofuFJEe.js → syncCache-BooMjgU6.js} +1 -1
- package/dist/chunks/{tasks-NpI1iEem.js → tasks-CHG_6sXQ.js} +1 -1
- package/dist/chunks/teleport-C9KRE4X8.js +1 -0
- package/dist/chunks/{templateJobs-C94jEE6O.js → templateJobs-BYYfF4m5.js} +1 -1
- package/dist/chunks/{theme-CEi3b_8f.js → theme-MvX7hojJ.js} +1 -1
- package/dist/chunks/{toolEventObserver-DlL9CHmI.js → toolEventObserver-BFEl47bq.js} +1 -1
- package/dist/chunks/toolPool-Cq74Cvjp.js +1 -0
- package/dist/chunks/trustedDevice-BGwujSqc.js +1 -0
- package/dist/chunks/{trustedDevice-Bzz03jCy.js → trustedDevice-BLiKbGpG.js} +1 -1
- package/dist/chunks/{updateCCB-CzBxsuJe.js → updateCCB-CfckOy7T.js} +6 -6
- package/dist/chunks/{useExitOnCtrlCDWithKeybindings-BHQfwlAl.js → useExitOnCtrlCDWithKeybindings-CPLBDluY.js} +1 -1
- package/dist/chunks/useMainLoopModel-C00PbZ1Q.js +1 -0
- package/dist/chunks/useManagePlugins-DFaGntzJ.js +1 -0
- package/dist/chunks/{useMergedTools-CHxnwR7R.js → useMergedTools-DYobZ5N4.js} +1 -1
- package/dist/chunks/{useSearchInput-q2CFPU4W.js → useSearchInput-KFKh2ozY.js} +1 -1
- package/dist/chunks/useSettingsErrors-BRgjvaHd.js +1 -0
- package/dist/chunks/{userAgent-B7WkjI6I.js → userAgent-DUrr02yh.js} +1 -1
- package/dist/chunks/util-D7uwPgF1.js +1 -0
- package/dist/chunks/validatePlugin-VukX52bx.js +1 -0
- package/dist/chunks/{workerRegistry-Cfo7bKlm.js → workerRegistry-BA37PVbv.js} +3 -3
- package/dist/chunks/worktree-Lik8xuKd.js +1 -0
- package/dist/cli.js +1 -1
- package/package.json +1 -1
- package/dist/chunks/AgentsMdExternalIncludesDialog-_bI4jo_P.js +0 -1
- package/dist/chunks/App-DoAZ7CYS.js +0 -1
- package/dist/chunks/ApproveApiKey-C8LwmDM2.js +0 -1
- package/dist/chunks/ApproveApiKey-DQP3qmb0.js +0 -1
- package/dist/chunks/BackgroundTasksDialog-CDA2noEk.js +0 -2
- package/dist/chunks/ConsoleOAuthFlow-Dn8fO-o_.js +0 -1
- package/dist/chunks/Doctor-CZ513Df9.js +0 -3
- package/dist/chunks/Doctor-CzPvNZzF.js +0 -1
- package/dist/chunks/ExitFlow-BFeftDv0.js +0 -2
- package/dist/chunks/InvalidConfigDialog-DQaT6aen.js +0 -1
- package/dist/chunks/MCPConnectionManager-BpjC7CEo.js +0 -1
- package/dist/chunks/MCPToolListView-Rb1Q--jG.js +0 -1
- package/dist/chunks/MessageSelector-BHB55sZb.js +0 -3
- package/dist/chunks/Messages-CPX-nIdA.js +0 -11
- package/dist/chunks/Onboarding-CymgipoF.js +0 -1
- package/dist/chunks/PromptInputHelpMenu-BP3UgCdi.js +0 -1
- package/dist/chunks/QueryEngine-HkswHUNv.js +0 -1
- package/dist/chunks/REPL-CZfg65kg.js +0 -133
- package/dist/chunks/REPL-eZsYNBfl.js +0 -1
- package/dist/chunks/RemoteSessionManager-B4jqKVd3.js +0 -2
- package/dist/chunks/ResumeConversation-B03XN_SP.js +0 -1
- package/dist/chunks/SearchExtraToolsTool-C85Sanww.js +0 -1
- package/dist/chunks/Settings-C8GKWod1.js +0 -2
- package/dist/chunks/WelcomeV2-BnSYhyfu.js +0 -1
- package/dist/chunks/add-dir-Bd7pilVx.js +0 -1
- package/dist/chunks/agents-qR6r94-F.js +0 -103
- package/dist/chunks/api-C4VflFau.js +0 -1
- package/dist/chunks/auth-CNCehj7y.js +0 -1
- package/dist/chunks/auth-DrD9DW6X.js +0 -1
- package/dist/chunks/autoMode-C2lnBot9.js +0 -45
- package/dist/chunks/backgroundHousekeeping-DbpTGbwl.js +0 -1
- package/dist/chunks/backgroundHousekeeping-SpTxViUq.js +0 -17
- package/dist/chunks/bridgeConfig-Ccm79Jze.js +0 -1
- package/dist/chunks/caches-BQmbXerw.js +0 -1
- package/dist/chunks/caches-Dtjmjm6G.js +0 -1
- package/dist/chunks/client-B-2ccQZk.js +0 -1
- package/dist/chunks/commands-D_-v6_A0.js +0 -1
- package/dist/chunks/compact-kM0ETtB2.js +0 -2
- package/dist/chunks/config-Crf6Mzu3.js +0 -1
- package/dist/chunks/connectHeadless-CqRoEtrg.js +0 -1
- package/dist/chunks/context-noninteractive-tc4KTYfI.js +0 -1
- package/dist/chunks/conversation-CFIn-KsW.js +0 -1
- package/dist/chunks/conversation-DPI7VKBL.js +0 -1
- package/dist/chunks/createSession-CjdLcRec.js +0 -1
- package/dist/chunks/crossProjectResume-BJqXBzkf.js +0 -40
- package/dist/chunks/dangerousBackend-DwcP0P08.js +0 -1
- package/dist/chunks/doctor-CJfvt9zR.js +0 -1
- package/dist/chunks/entry-CrZCZQQC.js +0 -14
- package/dist/chunks/exit-B8MA4Ltm.js +0 -1
- package/dist/chunks/extractMemories-DqhN0lba.js +0 -1
- package/dist/chunks/fast-DT5WDe3L.js +0 -1
- package/dist/chunks/firstPartyEventLogger-B8RVGBQB.js +0 -1
- package/dist/chunks/generateSessionName-DhCypqJ_.js +0 -1
- package/dist/chunks/goal-TxXtfkQ6.js +0 -3
- package/dist/chunks/grok-D2a_J5wE.js +0 -1
- package/dist/chunks/hooks-D-twhU_z.js +0 -1
- package/dist/chunks/keybindings-D9Boc8FD.js +0 -2
- package/dist/chunks/loadAgentsDir-BjsAQWqt.js +0 -1
- package/dist/chunks/loadPluginHooks-Dt3XQ-3N.js +0 -1
- package/dist/chunks/localSearch-Cz8Ot7k2.js +0 -1
- package/dist/chunks/lockfile-D5-j7HOZ.js +0 -1
- package/dist/chunks/main-CkjTzYj1.js +0 -513
- package/dist/chunks/managedEnv-K9Si1UuL.js +0 -1
- package/dist/chunks/mcp-DMBoeQzm.js +0 -6
- package/dist/chunks/mcp-TMOPfLcW.js +0 -1
- package/dist/chunks/mcp-x5rgv-uv.js +0 -2
- package/dist/chunks/memory-DDUoR63T.js +0 -1
- package/dist/chunks/model-CIvbC7rW.js +0 -1
- package/dist/chunks/parseConnectUrl-BiyKR5-x.js +0 -1
- package/dist/chunks/permissions-BT3lxYBM.js +0 -3
- package/dist/chunks/pidLock-d1VPd6CG.js +0 -3
- package/dist/chunks/plugin-BiNHuq3h.js +0 -17
- package/dist/chunks/pluginBlocklist-CNGmIlwU.js +0 -1
- package/dist/chunks/pluginCliCommands-WLOEhb2M.js +0 -1
- package/dist/chunks/pluginOperations-BFbty6WT.js +0 -2
- package/dist/chunks/pluginStartupCheck-Bcdxg484.js +0 -1
- package/dist/chunks/plugins-BMZ3aYKP.js +0 -4
- package/dist/chunks/print-DmoLcwVq.js +0 -26
- package/dist/chunks/processBashCommand-B-VqME9O.js +0 -1
- package/dist/chunks/processSlashCommand-D6zEooTy.js +0 -5
- package/dist/chunks/prompt-C3RRe4kW.js +0 -1
- package/dist/chunks/prompt-EtAanewG.js +0 -1
- package/dist/chunks/refresh-DumNiLvM.js +0 -1
- package/dist/chunks/rename-BPknfVGF.js +0 -1
- package/dist/chunks/resume-DGz04xDh.js +0 -2
- package/dist/chunks/sandbox-adapter-DUqeqkQD.js +0 -1
- package/dist/chunks/searchExtraTools-CgsV6kb1.js +0 -1
- package/dist/chunks/server-LdbAb0sV.js +0 -1
- package/dist/chunks/serverBanner-BdExKFHT.js +0 -1
- package/dist/chunks/serverLog-BFmvyJ93.js +0 -1
- package/dist/chunks/sessionFileAccessHooks-BJlrZaRD.js +0 -1
- package/dist/chunks/sessionManager-CPa049BO.js +0 -1
- package/dist/chunks/sessionObserver-BGYoLRGx.js +0 -1
- package/dist/chunks/sessionStorage-zJ1esSCE.js +0 -1
- package/dist/chunks/setup-zf3v3ICe.js +0 -3
- package/dist/chunks/sinks-DppGvgz1.js +0 -1
- package/dist/chunks/skillChangeDetector-D-iq09Xs.js +0 -1
- package/dist/chunks/statusNoticeHelpers-DakAVtQO.js +0 -1
- package/dist/chunks/switcher-Dm646gO5.js +0 -1
- package/dist/chunks/teleport-Bs3kEipi.js +0 -1
- package/dist/chunks/toolPool-DIT_uhtD.js +0 -1
- package/dist/chunks/trustedDevice-BokywSKL.js +0 -1
- package/dist/chunks/useMainLoopModel-BkyIIW9t.js +0 -1
- package/dist/chunks/useManagePlugins-BWROoGDs.js +0 -1
- package/dist/chunks/useSettingsErrors-CPVQbsqq.js +0 -1
- package/dist/chunks/util-BfqXOA-P.js +0 -1
- package/dist/chunks/validatePlugin-jrcrYEIu.js +0 -1
- package/dist/chunks/worktree-D0k_pCEz.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./memoize-BK3gG5ob.js";import{n as r,t as i}from"./axios-DaWTGg7G.js";import{C as a,P as o,R as s,c,i as l,x as u}from"./debug-Dr1SjdXn.js";import{d,f}from"./log-27kCA_9u.js";import{l as p,u as m}from"./oauth-D38aRTUb.js";import{Bt as h,Cn as g,Sn as _,ft as v}from"./model-
|
|
1
|
+
import{a as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./memoize-BK3gG5ob.js";import{n as r,t as i}from"./axios-DaWTGg7G.js";import{C as a,P as o,R as s,c,i as l,x as u}from"./debug-Dr1SjdXn.js";import{d,f}from"./log-27kCA_9u.js";import{l as p,u as m}from"./oauth-D38aRTUb.js";import{Bt as h,Cn as g,Sn as _,ft as v}from"./model-C29_32BD.js";import{hostname as y}from"os";i(),n(),m(),l(),s(),d(),g(),u();var b=`tengu_sessions_elevated_auth_enforcement`;function x(){return!1}var S=t(()=>process.env.CLAUDE_TRUSTED_DEVICE_TOKEN||_().read()?.trustedDeviceToken);function C(){if(x())return S()}function w(){S.cache?.clear?.()}function T(){if(!x())return;let e=_();try{let t=e.read();t?.trustedDeviceToken&&(delete t.trustedDeviceToken,e.update(t))}catch{}S.cache?.clear?.()}async function E(){try{if(!await!1){c(`[trusted-device] Gate ${b} is off, skipping enrollment`);return}if(process.env.CLAUDE_TRUSTED_DEVICE_TOKEN){c(`[trusted-device] CLAUDE_TRUSTED_DEVICE_TOKEN env var is set, skipping enrollment (env var takes precedence)`);return}let{getClaudeAIOAuthTokens:t}=(h(),e(v)),n=t()?.accessToken;if(!n){c(`[trusted-device] No OAuth token, skipping enrollment`);return}let i=_();if(f()){c(`[trusted-device] Essential traffic only, skipping enrollment`);return}let s=p().BASE_API_URL,l;try{l=await r.post(`${s}/api/auth/trusted_devices`,{display_name:`Work Mate on ${y()} · ${process.platform}`},{headers:{Authorization:`Bearer ${n}`,"Content-Type":`application/json`},timeout:1e4,validateStatus:e=>e<500})}catch(e){c(`[trusted-device] Enrollment request failed: ${o(e)}`);return}if(l.status!==200&&l.status!==201){c(`[trusted-device] Enrollment failed ${l.status}: ${a(l.data).slice(0,200)}`);return}let u=l.data?.device_token;if(!u||typeof u!=`string`){c(`[trusted-device] Enrollment response missing device_token field`);return}try{let e=i.read();if(!e){c(`[trusted-device] Cannot read storage, skipping token persist`);return}e.trustedDeviceToken=u;let t=i.update(e);if(!t.success){c(`[trusted-device] Failed to persist token: ${t.warning??`unknown`}`);return}S.cache?.clear?.(),c(`[trusted-device] Enrolled device_id=${l.data.device_id??`unknown`}`)}catch(e){c(`[trusted-device] Storage write failed: ${o(e)}`)}}catch(e){c(`[trusted-device] Enrollment error: ${o(e)}`)}}export{C as i,w as n,E as r,T as t};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Yd as e,Zd as t}from"./loadAgentsDir-mcRW90aq.js";import{di as n,ui as r}from"./src-P_wYS_NJ2.js";import{c as i,i as a}from"./debug-Dr1SjdXn.js";import{n as o,o as s}from"./process-gEbdy6uY.js";import{n as c,r as l}from"./execFileNoThrow-mXq4K0rl.js";import{l as u,u as d}from"./ripgrep-DQ_ILUJV.js";import{join as f}from"node:path";import{execSync as p}from"node:child_process";import{existsSync as m,readFileSync as h}from"node:fs";import{homedir as g}from"node:os";n(),a(),d(),l(),t(),o();var _=`@readmagic/workmate`;function v(){try{let e=f(u,`..`,`package.json`);if(m(e)){let t=JSON.parse(h(e,`utf-8`));if(t.version)return t.version}}catch{}return`0.0.13`}function y(e){try{return p(`which ${e} 2>/dev/null`,{stdio:`pipe`}),!0}catch{return!1}}function b(){return!!(process.execPath.includes(`bun`)||m(f(f(g(),`.bun`,`install`,`global`),`node_modules`,_)))}async function x(){let e=await c(`npm`,[`view`,`${_}@latest`,`version`,`--prefer-online`],{abortSignal:AbortSignal.timeout(1e4),cwd:g()});return e.code===0?e.stdout.trim():(i(`npm view failed: ${e.stderr}`),null)}function S(e,t){let n=e=>e.replace(/^\D/,``).split(`.`).map(Number),r=n(e),i=n(t);for(let e=0;e<3;e++){if((r[e]??0)>(i[e]??0))return!0;if((r[e]??0)<(i[e]??0))return!1}return!0}async function C(){let t=v();s(`Current version: ${t}\n`);let n=y(`bun`),i=b()&&n?`bun`:`npm`;s(`Package manager: ${i}\n`),s(`Checking for updates...
|
|
2
2
|
`);let a=await x();if(!a){process.stderr.write(r.red(`Failed to check for updates`)+`
|
|
3
3
|
`),process.stderr.write(`Unable to fetch latest version from npm registry.
|
|
4
|
-
`),await
|
|
5
|
-
`),await
|
|
6
|
-
`)}catch(
|
|
7
|
-
`),process.stderr.write(`${
|
|
4
|
+
`),await e(1);return}if(a===t||S(t,a)){s(r.green(`ccb is up to date (${t})`)+`
|
|
5
|
+
`),await e(0);return}s(`New version available: ${a} (current: ${t})\n`),s(`Installing update via ${i}...\n`);try{p(i===`bun`?`bun install -g ${_}@latest`:`npm install -g ${_}@latest`,{stdio:`inherit`,cwd:g(),timeout:12e4}),s(r.green(`Successfully updated from ${t} to ${a}`)+`
|
|
6
|
+
`)}catch(t){process.stderr.write(r.red(`Update failed`)+`
|
|
7
|
+
`),process.stderr.write(`${t}\n`),process.stderr.write(`
|
|
8
8
|
`),process.stderr.write(`Try manually updating with:
|
|
9
9
|
`),i===`bun`?process.stderr.write(r.bold(` bun install -g ${_}@latest`)+`
|
|
10
10
|
`):process.stderr.write(r.bold(` npm install -g ${_}@latest`)+`
|
|
11
|
-
`),await
|
|
11
|
+
`),await e(1)}await e(0)}export{C as updateCCB};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{
|
|
1
|
+
import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{EC as n,md as r}from"./loadAgentsDir-mcRW90aq.js";import{Gt as i,et as a,fi as o,t as s,vt as c}from"./src-P_wYS_NJ2.js";function l(e,t,n,r=!0){let{exit:i}=c(),[o,s]=(0,u.useState)({pending:!1,keyName:null}),l=(0,u.useMemo)(()=>n??i,[n,i]),d=a(e=>s({pending:e,keyName:`Ctrl-C`}),l),f=a(e=>s({pending:e,keyName:`Ctrl-D`}),l),p=(0,u.useCallback)(()=>{t?.()||d()},[d,t]),m=(0,u.useCallback)(()=>{f()},[f]);return e((0,u.useMemo)(()=>({"app:interrupt":p,"app:exit":m}),[p,m]),{context:`Global`,isActive:r}),o}var u,d=e((()=>{u=t(o(),1),s(),r()}));function f(e,t,n){return l(i,t,e,n)}var p=e((()=>{n(),d()}));export{f as n,p as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{ng as t,rg as n}from"./loadAgentsDir-mcRW90aq.js";import{C as r,_ as i,s as a}from"./model-C29_32BD.js";function o(){let e=n(e=>e.mainLoopModel);return r(n(e=>e.mainLoopModelForSession)??e??a())}var s=e((()=>{t(),i()}));export{o as n,s as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{o as e}from"./rolldown-runtime-DaDcL9Zw.js";import{Ch as t,D_ as n,E_ as r,Jd as i,Ts as a,aS as o,ag as s,bs as c,do as l,iS as u,ng as d,qd as f,rg as p,uo as m,wh as h,ws as g,xh as _,yh as v,ys as y}from"./loadAgentsDir-mcRW90aq.js";import{fi as b}from"./src-P_wYS_NJ2.js";import{R as x,U as S,c as C,i as w}from"./debug-Dr1SjdXn.js";import{Ln as T,Rn as E}from"./settings-DiBMs2gM.js";import{O as D,k as O}from"./git-CoQQ6YEf.js";import{o as k,s as A}from"./log-27kCA_9u.js";import{n as j,r as M}from"./analytics-DJobLaWP.js";import{n as N,r as P}from"./pluginFlagging-Cr0d0hBA.js";import{t as F}from"./pluginBlocklist-BfoLN9a-.js";var I=e(b(),1);f(),j(),v(),d(),E(),w(),D(),x(),k(),g(),c(),r(),t(),u(),P(),m();function L({enabled:e=!0}={}){let t=s(),r=p(e=>e.plugins.needsRefresh),{addNotification:c}=i(),u=(0,I.useCallback)(async()=>{try{let{enabled:e,disabled:r,errors:i}=await l();await F();let s=N();Object.keys(s).length>0&&c({key:`plugin-delisted-flagged`,text:`Plugins flagged. Check /plugins`,color:`warning`,priority:`high`});let u=[],d=[];try{u=await y()}catch(e){let t=e instanceof Error?e.message:String(e);i.push({type:`generic-error`,source:`plugin-commands`,error:`Failed to load plugin commands: ${t}`})}try{d=await a()}catch(e){let t=e instanceof Error?e.message:String(e);i.push({type:`generic-error`,source:`plugin-agents`,error:`Failed to load plugin agents: ${t}`})}try{await n()}catch(e){let t=e instanceof Error?e.message:String(e);i.push({type:`generic-error`,source:`plugin-hooks`,error:`Failed to load plugin hooks: ${t}`})}let f=(await Promise.all(e.map(async e=>{if(e.mcpServers)return Object.keys(e.mcpServers).length;let t=await o(e,i);return t&&(e.mcpServers=t),t?Object.keys(t).length:0}))).reduce((e,t)=>e+t,0),p=(await Promise.all(e.map(async e=>{if(e.lspServers)return Object.keys(e.lspServers).length;let t=await h(e,i);return t&&(e.lspServers=t),t?Object.keys(t).length:0}))).reduce((e,t)=>e+t,0);_(),t(t=>{let n=t.plugins.errors.filter(e=>e.source===`lsp-manager`||e.source.startsWith(`plugin:`)),a=new Set(i.map(e=>e.type===`generic-error`?`generic-error:${e.source}:${e.error}`:`${e.type}:${e.source}`)),o=[...n.filter(e=>{let t=e.type===`generic-error`?`generic-error:${e.source}:${e.error}`:`${e.type}:${e.source}`;return!a.has(t)}),...i];return{...t,plugins:{...t.plugins,enabled:e,disabled:r,commands:u,errors:o}}}),C(`Loaded plugins - Enabled: ${e.length}, Disabled: ${r.length}, Commands: ${u.length}, Agents: ${d.length}, Errors: ${i.length}`);let m=e.reduce((e,t)=>t.hooksConfig?e+Object.values(t.hooksConfig).reduce((e,t)=>e+(t?.reduce((e,t)=>e+t.hooks.length,0)??0),0):e,0);return{enabled_count:e.length,disabled_count:r.length,inline_count:T(e,e=>e.source.endsWith(`@inline`)),marketplace_count:T(e,e=>!e.source.endsWith(`@inline`)),error_count:i.length,skill_count:u.length,agent_count:d.length,hook_count:m,mcp_count:f,lsp_count:p}}catch(e){let n=S(e);return A(n),C(`Error loading plugins: ${e}`),t(e=>{let t=e.plugins.errors.filter(e=>e.source===`lsp-manager`||e.source.startsWith(`plugin:`)),r={type:`generic-error`,source:`plugin-system`,error:n.message};return{...e,plugins:{...e.plugins,enabled:[],disabled:[],commands:[],errors:[...t,r]}}}),{enabled_count:0,disabled_count:0,inline_count:0,marketplace_count:0,error_count:1,skill_count:0,agent_count:0,hook_count:0,mcp_count:0,lsp_count:0,load_failed:!0,ant_enabled_names:void 0}}},[t,c]);(0,I.useEffect)(()=>{e&&u().then(e=>{let{ant_enabled_names:t,...n}=e,r={...n,has_custom_plugin_cache_dir:!!process.env.CLAUDE_CODE_PLUGIN_CACHE_DIR};M(`tengu_plugins_loaded`,{...r,...t!==void 0&&{enabled_names:t}}),O(`info`,`tengu_plugins_loaded`,r)})},[u,e]),(0,I.useEffect)(()=>{!e||!r||c({key:`plugin-reload-pending`,text:`Plugins changed. Run /reload-plugins to activate.`,color:`suggestion`,priority:`low`})},[e,r,c])}export{L as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{
|
|
1
|
+
import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{Xc as n,el as r}from"./loadAgentsDir-mcRW90aq.js";import{fi as i}from"./src-P_wYS_NJ2.js";import{n as a,t as o}from"./toolPool-Cq74Cvjp.js";function s(e,t,r){return(0,c.useMemo)(()=>a(e,n(r,t),r.mode),[e,t,r,!1,!1])}var c,l=e((()=>{c=t(i(),1),r(),o()}));export{s as n,l as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{Cd as n,
|
|
1
|
+
import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{Cd as n,Ed as r,MC as i,Sd as a,Td as o,_d as s,gd as c,hd as l,wd as u,xd as d}from"./loadAgentsDir-mcRW90aq.js";import{Vn as f,fi as p,hn as m,ot as h,t as g}from"./src-P_wYS_NJ2.js";function _(e){return!!(e.ctrl&&(e.key===`k`||e.key===`u`||e.key===`w`)||e.meta&&e.key===`backspace`)}function v(e){return(e.ctrl||e.meta)&&e.key===`y`}function y({isActive:e,onExit:t,onCancel:i,onExitUp:s,columns:p,passthroughCtrlKeys:g=[],initialQuery:y=``,backspaceExitsOnEmpty:S=!0}){let{columns:C}=h(),w=p??C,[T,E]=(0,b.useState)(y),[D,O]=(0,b.useState)(y.length),k=(0,b.useCallback)(e=>{E(e),O(e.length)},[]),A=f=>{if(!e)return;let p=l.fromText(T,w,D);if(!(f.ctrl&&g.includes(f.key.toLowerCase()))){if(_(f)||n(),v(f)||u(),f.key===`return`||f.key===`down`){f.preventDefault(),t();return}if(f.key===`up`){f.preventDefault(),s&&s();return}if(f.key===`escape`){f.preventDefault(),i?i():T.length>0?(E(``),O(0)):t();return}if(f.key===`backspace`){if(f.preventDefault(),f.meta){let{cursor:e,killed:t}=p.deleteWordBefore();d(t,`prepend`),E(e.text),O(e.offset);return}if(T.length===0){S&&(i??t)();return}let e=p.backspace();E(e.text),O(e.offset);return}if(f.key===`delete`){f.preventDefault();let e=p.del();E(e.text),O(e.offset);return}if(f.key===`left`&&(f.ctrl||f.meta||f.fn)){f.preventDefault();let e=p.prevWord();O(e.offset);return}if(f.key===`right`&&(f.ctrl||f.meta||f.fn)){f.preventDefault();let e=p.nextWord();O(e.offset);return}if(f.key===`left`){f.preventDefault();let e=p.left();O(e.offset);return}if(f.key===`right`){f.preventDefault();let e=p.right();O(e.offset);return}if(f.key===`home`){f.preventDefault(),O(0);return}if(f.key===`end`){f.preventDefault(),O(T.length);return}if(f.ctrl){switch(f.preventDefault(),f.key.toLowerCase()){case`a`:O(0);return;case`e`:O(T.length);return;case`b`:O(p.left().offset);return;case`f`:O(p.right().offset);return;case`d`:{if(T.length===0){(i??t)();return}let e=p.del();E(e.text),O(e.offset);return}case`h`:{if(T.length===0){S&&(i??t)();return}let e=p.backspace();E(e.text),O(e.offset);return}case`k`:{let{cursor:e,killed:t}=p.deleteToLineEnd();d(t,`append`),E(e.text),O(e.offset);return}case`u`:{let{cursor:e,killed:t}=p.deleteToLineStart();d(t,`prepend`),E(e.text),O(e.offset);return}case`w`:{let{cursor:e,killed:t}=p.deleteWordBefore();d(t,`prepend`),E(e.text),O(e.offset);return}case`y`:{let e=c();if(e.length>0){let t=p.offset,n=p.insert(e);a(t,e.length),E(n.text),O(n.offset)}return}case`g`:case`c`:if(i){i();return}}return}if(f.meta){switch(f.preventDefault(),f.key.toLowerCase()){case`b`:O(p.prevWord().offset);return;case`f`:O(p.nextWord().offset);return;case`d`:{let e=p.deleteWordAfter();E(e.text),O(e.offset);return}case`y`:{let e=r();if(e){let{text:t,start:n,length:r}=e,i=T.slice(0,n),a=T.slice(n+r),s=i+t+a,c=n+t.length;o(t.length),E(s),O(c)}return}}return}if(f.key!==`tab`&&f.key.length>=1&&!x.has(f.key)){f.preventDefault();let e=p.insert(f.key);E(e.text),O(e.offset)}}};return m((e,t,n)=>{A(new f(n.keypress))},{isActive:e}),{query:T,setQuery:k,cursorOffset:D,handleKeyDown:A}}var b,x,S=e((()=>{b=t(p(),1),g(),s(),i(),x=new Set([`pageup`,`pagedown`,`insert`,`wheelup`,`wheeldown`,`mouse`,`f1`,`f2`,`f3`,`f4`,`f5`,`f6`,`f7`,`f8`,`f9`,`f10`,`f11`,`f12`])}));export{y as n,S as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{Jd as n,cg as r,lg as i,qd as a}from"./loadAgentsDir-mcRW90aq.js";import{fi as o}from"./src-P_wYS_NJ2.js";import{B as s,Wt as c}from"./state-BPFYBqm1.js";import{n as l,t as u}from"./allErrors-C1eMbHSv.js";function d(){let{addNotification:e,removeNotification:t}=n(),[r,a]=(0,f.useState)(()=>{let{errors:e}=u();return e});return i((0,f.useCallback)(()=>{let{errors:e}=u();a(e)},[])),(0,f.useEffect)(()=>{if(!s())if(r.length>0){let t=`Found ${r.length} settings ${r.length===1?`issue`:`issues`} · /doctor for details`;e({key:p,text:t,color:`warning`,priority:`high`,timeoutMs:6e4})}else t(p)},[r,e,t]),r}var f,p,m=e((()=>{f=t(o(),1),a(),c(),l(),r(),p=`settings-errors`}));export{d as n,m as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";function t(){return`workmate/0.0.
|
|
1
|
+
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";function t(){return`workmate/0.0.13`}var n=e((()=>{}));export{n,t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{o as e}from"./rolldown-runtime-DaDcL9Zw.js";import{Du as t,Eu as n,ng as r,tg as i}from"./loadAgentsDir-mcRW90aq.js";import{fi as a}from"./src-P_wYS_NJ2.js";import{t as o}from"./jsx-runtime-Bb4Xn-E0.js";import{n as s,r as c}from"./analytics-DJobLaWP.js";import{t as l}from"./useManagePlugins-DFaGntzJ.js";import{n as u,t as d}from"./MCPConnectionManager-aDDsYkGM.js";import{cwd as f}from"process";var p=e(a(),1);t(),s(),u(),r();var m=o(),h=p.lazy(()=>import(`./Doctor-i_5_AQd-.js`).then(e=>({default:e.Doctor})));function g({onDone:e}){return l(),(0,m.jsx)(p.Suspense,{fallback:null,children:(0,m.jsx)(h,{onDone:e})})}async function _(e){c(`tengu_doctor_command`,{}),await new Promise(t=>{e.render((0,m.jsx)(i,{children:(0,m.jsx)(n,{children:(0,m.jsx)(d,{dynamicMcpConfig:void 0,isStrictMcpConfig:!1,children:(0,m.jsx)(g,{onDone:()=>{t()}})})})}))}),e.unmount(),process.exit(0)}async function v(e,t){let{setup:n}=await import(`./setup-DeyiuGNX.js`);await n(f(),`default`,!1,!1,void 0,!1);let{install:r}=await import(`./install-DGH_bjUh.js`);await new Promise(n=>{let i=[];e&&i.push(e),t.force&&i.push(`--force`),r.call(e=>{n(),process.exit(+!!e.includes(`failed`))},{},i)})}export{_ as doctorHandler,v as installHandler};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./axios-DaWTGg7G.js";import{Aw as r,DE as i,Fw as a,Iw as o,Lw as s,OE as ee,TE as c,kw as l,wE as u}from"./loadAgentsDir-mcRW90aq.js";import{p as d}from"./external-CEp-aPkt.js";import{r as te}from"./lazySchema-B4D4qJVE.js";import{B as f,C as p,F as m,P as h,R as g,S as _,c as v,f as y,i as b,u as x,x as S}from"./debug-Dr1SjdXn.js";import{_t as C,gt as ne,ht as w,pt as re,vt as ie}from"./settings-DiBMs2gM.js";import{o as ae,s as T}from"./log-27kCA_9u.js";import{homedir as oe}from"os";import*as E from"path";import{join as se,resolve as D}from"path";import{randomBytes as O}from"crypto";import{readFile as k,readdir as A,rename as j,stat as M,unlink as N,writeFile as P}from"fs/promises";function F(){return se(l(),H)}async function I(){let e=F();try{let t=_(await k(e,{encoding:`utf-8`}));if(typeof t!=`object`||!t||!(`version`in t)||!(`fetchedAt`in t)||!(`counts`in t))return v(`Install counts cache has invalid structure`),null;let n=t;if(n.version!==V)return v(`Install counts cache version mismatch (got ${n.version}, expected ${V})`),null;if(typeof n.fetchedAt!=`string`||!Array.isArray(n.counts))return v(`Install counts cache has invalid structure`),null;let r=new Date(n.fetchedAt).getTime();return Number.isNaN(r)?(v(`Install counts cache has invalid fetchedAt timestamp`),null):n.counts.every(e=>typeof e==`object`&&!!e&&typeof e.plugin==`string`&&typeof e.unique_installs==`number`)?Date.now()-r>W?(v(`Install counts cache is stale (>24h old)`),null):{version:n.version,fetchedAt:n.fetchedAt,counts:n.counts}:(v(`Install counts cache has malformed entries`),null)}catch(e){return m(e)!==`ENOENT`&&v(`Failed to load install counts cache: ${h(e)}`),null}}async function L(e){let t=F(),n=`${t}.${O(8).toString(`hex`)}.tmp`;try{let r=l();await x().mkdir(r),await P(n,p(e,null,2),{encoding:`utf-8`,mode:384}),await j(n,t),v(`Install counts cache saved successfully`)}catch(e){T(e);try{await N(n)}catch{}}}async function R(){v(`Fetching install counts from ${U}`);let e=performance.now();try{let n=await t.get(U,{timeout:1e4});if(!n.data?.plugins||!Array.isArray(n.data.plugins))throw Error(`Invalid response format from install counts API`);return s(`install_counts`,U,`success`,performance.now()-e),n.data.plugins}catch(t){throw s(`install_counts`,U,`failure`,performance.now()-e,a(t)),t}}async function z(){let e=await I();if(e){v(`Using cached install counts`),s(`install_counts`,U,`cache_hit`,0);let t=new Map;for(let n of e.counts)t.set(n.plugin,n.unique_installs);return t}try{let e=await R();await L({version:V,fetchedAt:new Date().toISOString(),counts:e});let t=new Map;for(let n of e)t.set(n.plugin,n.unique_installs);return t}catch(e){return T(e),v(`Failed to fetch install counts: ${h(e)}`),null}}function B(e){if(e<1e3)return String(e);if(e<1e6){let t=(e/1e3).toFixed(1);return t.endsWith(`.0`)?`${t.slice(0,-2)}K`:`${t}K`}let t=(e/1e6).toFixed(1);return t.endsWith(`.0`)?`${t.slice(0,-2)}M`:`${t}M`}var V,H,U,W,G=e((()=>{n(),b(),g(),y(),ae(),S(),o(),r(),V=1,H=`install-counts-cache.json`,U=`https://raw.githubusercontent.com/anthropics/claude-plugins-official/refs/heads/stats/stats/plugin-installs.json`,W=1440*60*1e3}));async function K(e){let t=e.trim(),n=x(),r=t.match(/^([a-zA-Z0-9._-]+@[^:]+:.+?(?:\.git)?)(#(.+))?$/);if(r?.[1]){let e=r[1],t=r[3];return t?{source:`git`,url:e,ref:t}:{source:`git`,url:e}}if(t.startsWith(`http://`)||t.startsWith(`https://`)){let e=t.match(/^([^#]+)(#(.+))?$/),n=e?.[1]||t,r=e?.[3];if(n.endsWith(`.git`)||n.includes(`/_git/`))return r?{source:`git`,url:n,ref:r}:{source:`git`,url:n};let i;try{i=new URL(n)}catch{return{source:`url`,url:n}}if((i.hostname===`github.com`||i.hostname===`www.github.com`)&&i.pathname.match(/^\/([^/]+\/[^/]+?)(\/|\.git|$)/)?.[1]){let e=n.endsWith(`.git`)?n:`${n}.git`;return r?{source:`git`,url:e,ref:r}:{source:`git`,url:e}}return{source:`url`,url:n}}let i=process.platform===`win32`&&(t.startsWith(`.\\`)||t.startsWith(`..\\`)||/^[a-zA-Z]:[/\\]/.test(t));if(t.startsWith(`./`)||t.startsWith(`../`)||t.startsWith(`/`)||t.startsWith(`~`)||i){let e=D(t.startsWith(`~`)?t.replace(/^~/,oe()):t),r;try{r=await n.stat(e)}catch(t){let n=m(t);return{error:n===`ENOENT`?`Path does not exist: ${e}`:`Cannot access path: ${e} (${n??t})`}}return r.isFile()?e.endsWith(`.json`)?{source:`file`,path:e}:{error:`File path must point to a .json file (marketplace.json), but got: ${e}`}:r.isDirectory()?{source:`directory`,path:e}:{error:`Path is neither a file nor a directory: ${e}`}}if(t.includes(`/`)&&!t.startsWith(`@`)){if(t.includes(`:`))return null;let e=t.match(/^([^#@]+)(?:[#@](.+))?$/),n=e?.[1]||t,r=e?.[2];return r?{source:`github`,repo:n,ref:r}:{source:`github`,repo:n}}return null}var ce=e((()=>{g(),y()}));function le(e){let t=E.basename(e),n=E.basename(E.dirname(e));return t===`plugin.json`?`plugin`:t===`marketplace.json`?`marketplace`:n===`.claude-plugin`?`plugin`:`unknown`}function q(e){return e.issues.map(e=>({path:e.path.join(`.`)||`root`,message:e.message,code:e.code}))}function J(e,t,n,r){e.includes(`..`)&&n.push({path:t,message:r?`Path contains "..": ${e}. ${r}`:`Path contains ".." which could be a path traversal attempt: ${e}`})}function ue(e){let t=e.replace(/^(\.\.\/)+/,``);return`Plugin source paths are resolved relative to the marketplace root (the directory containing .claude-plugin/), not relative to marketplace.json. Use "${t===e?`./plugins/my-plugin`:`./${t}`}" instead of "${e}".`}async function Y(e){let t=[],n=[],r=E.resolve(e),i;try{i=await k(r,{encoding:`utf-8`})}catch(e){let t=m(e),n;return n=t===`ENOENT`?`File not found: ${r}`:t===`EISDIR`?`Path is not a file: ${r}`:`Failed to read file: ${h(e)}`,{success:!1,errors:[{path:`file`,message:n,code:t}],warnings:[],filePath:r,fileType:`plugin`}}let a;try{a=_(i)}catch(e){return{success:!1,errors:[{path:`json`,message:`Invalid JSON syntax: ${h(e)}`}],warnings:[],filePath:r,fileType:`plugin`}}if(a&&typeof a==`object`){let e=a;e.commands&&(Array.isArray(e.commands)?e.commands:[e.commands]).forEach((e,n)=>{typeof e==`string`&&J(e,`commands[${n}]`,t)}),e.agents&&(Array.isArray(e.agents)?e.agents:[e.agents]).forEach((e,n)=>{typeof e==`string`&&J(e,`agents[${n}]`,t)}),e.skills&&(Array.isArray(e.skills)?e.skills:[e.skills]).forEach((e,n)=>{typeof e==`string`&&J(e,`skills[${n}]`,t)})}let o=a;if(typeof a==`object`&&a){let e=a,t=Object.keys(e).filter(e=>$.has(e));if(t.length>0){let r={...e};for(let e of t)delete r[e],n.push({path:e,message:`Field '${e}' belongs in the marketplace entry (marketplace.json), not plugin.json. It's harmless here but unused — Work Mate ignores it at load time.`});o=r}}let s=w().strict().safeParse(o);if(s.success||t.push(...q(s.error)),s.success){let e=s.data;/^[a-z0-9]+(-[a-z0-9]+)*$/.test(e.name)||n.push({path:`name`,message:`Plugin name "${e.name}" is not kebab-case. Work Mate accepts it, but the Claude.ai marketplace sync requires kebab-case (lowercase letters, digits, and hyphens only, e.g., "my-plugin").`}),e.version||n.push({path:`version`,message:`No version specified. Consider adding a version following semver (e.g., "1.0.0")`}),e.description||n.push({path:`description`,message:`No description provided. Adding a description helps users understand what your plugin does`}),e.author||n.push({path:`author`,message:`No author information provided. Consider adding author details for plugin attribution`})}return{success:t.length===0,errors:t,warnings:n,filePath:r,fileType:`plugin`}}async function X(e){let t=[],n=[],r=E.resolve(e),i;try{i=await k(r,{encoding:`utf-8`})}catch(e){let t=m(e),n;return n=t===`ENOENT`?`File not found: ${r}`:t===`EISDIR`?`Path is not a file: ${r}`:`Failed to read file: ${h(e)}`,{success:!1,errors:[{path:`file`,message:n,code:t}],warnings:[],filePath:r,fileType:`marketplace`}}let a;try{a=_(i)}catch(e){return{success:!1,errors:[{path:`json`,message:`Invalid JSON syntax: ${h(e)}`}],warnings:[],filePath:r,fileType:`marketplace`}}if(a&&typeof a==`object`){let e=a;Array.isArray(e.plugins)&&e.plugins.forEach((e,n)=>{if(e&&typeof e==`object`&&`source`in e){let r=e.source;typeof r==`string`&&J(r,`plugins[${n}].source`,t,ue(r)),r&&typeof r==`object`&&`path`in r&&typeof r.path==`string`&&J(r.path,`plugins[${n}].source.path`,t)}})}let o=C().extend({plugins:d(ne().strict())}).strict().safeParse(a);if(o.success||t.push(...q(o.error)),o.success){let e=o.data;if((!e.plugins||e.plugins.length===0)&&n.push({path:`plugins`,message:`Marketplace has no plugins defined`}),e.plugins){e.plugins.forEach((n,r)=>{e.plugins.filter(e=>e.name===n.name).length>1&&t.push({path:`plugins[${r}].name`,message:`Duplicate plugin name "${n.name}" found in marketplace`})});let i=E.dirname(r),a=E.basename(i)===`.claude-plugin`?E.dirname(i):i;for(let[t,r]of e.plugins.entries()){if(!r.version||typeof r.source!=`string`||!r.source.startsWith(`./`))continue;let e=E.join(a,r.source,`.claude-plugin`,`plugin.json`),i;try{let t=_(await k(e,{encoding:`utf-8`}));typeof t.version==`string`&&(i=t.version)}catch{continue}i&&i!==r.version&&n.push({path:`plugins[${t}].version`,message:`Entry declares version "${r.version}" but ${r.source}/.claude-plugin/plugin.json says "${i}". At install time, plugin.json wins (calculatePluginVersion precedence) — the entry version is silently ignored. Update this entry to "${i}" to match.`})}}e.metadata?.description||n.push({path:`metadata.description`,message:`No marketplace description provided. Adding a description helps users understand what this marketplace offers`})}return{success:t.length===0,errors:t,warnings:n,filePath:r,fileType:`marketplace`}}function de(e,t,n){let r=[],i=[],a=t.match(u);if(!a)return i.push({path:`frontmatter`,message:`No frontmatter block found. Add YAML frontmatter between --- delimiters at the top of the file to set description and other metadata.`}),{success:!0,errors:r,warnings:i,filePath:e,fileType:n};let o=a[1]||``,s;try{s=ee(o)}catch(t){return r.push({path:`frontmatter`,message:`YAML frontmatter failed to parse: ${h(t)}. At runtime this ${n} loads with empty metadata (all frontmatter fields silently dropped).`}),{success:!1,errors:r,warnings:i,filePath:e,fileType:n}}if(typeof s!=`object`||!s||Array.isArray(s))return r.push({path:`frontmatter`,message:`Frontmatter must be a YAML mapping (key: value pairs), got ${Array.isArray(s)?`an array`:s===null?`null`:typeof s}.`}),{success:!1,errors:r,warnings:i,filePath:e,fileType:n};let c=s;if(c.description!==void 0){let e=c.description;typeof e!=`string`&&typeof e!=`number`&&typeof e!=`boolean`&&e!==null&&r.push({path:`description`,message:`description must be a string, got ${Array.isArray(e)?`array`:typeof e}. At runtime this value is dropped.`})}else i.push({path:`description`,message:`No description in frontmatter. A description helps users and Claude understand when to use this ${n}.`});c.name!==void 0&&c.name!==null&&typeof c.name!=`string`&&r.push({path:`name`,message:`name must be a string, got ${typeof c.name}.`});let l=c[`allowed-tools`];l!=null&&(typeof l!=`string`&&!Array.isArray(l)?r.push({path:`allowed-tools`,message:`allowed-tools must be a string or array of strings, got ${typeof l}.`}):Array.isArray(l)&&l.some(e=>typeof e!=`string`)&&r.push({path:`allowed-tools`,message:`allowed-tools array must contain only strings.`}));let d=c.shell;if(d!=null)if(typeof d!=`string`)r.push({path:`shell`,message:`shell must be a string, got ${typeof d}.`});else{let e=d.trim().toLowerCase();e!==`bash`&&e!==`powershell`&&r.push({path:`shell`,message:`shell must be 'bash' or 'powershell', got '${d}'.`})}return{success:r.length===0,errors:r,warnings:i,filePath:e,fileType:n}}async function Z(e){let t;try{t=await k(e,{encoding:`utf-8`})}catch(t){return m(t)===`ENOENT`?{success:!0,errors:[],warnings:[],filePath:e,fileType:`hooks`}:{success:!1,errors:[{path:`file`,message:`Failed to read file: ${h(t)}`}],warnings:[],filePath:e,fileType:`hooks`}}let n;try{n=_(t)}catch(t){return{success:!1,errors:[{path:`json`,message:`Invalid JSON syntax: ${h(t)}. At runtime this breaks the entire plugin load.`}],warnings:[],filePath:e,fileType:`hooks`}}let r=re().safeParse(n);return r.success?{success:!0,errors:[],warnings:[],filePath:e,fileType:`hooks`}:{success:!1,errors:q(r.error),warnings:[],filePath:e,fileType:`hooks`}}async function Q(e,t){let n;try{n=await A(e,{withFileTypes:!0})}catch(e){let t=m(e);if(t===`ENOENT`||t===`ENOTDIR`)return[];throw e}if(t)return n.filter(e=>e.isDirectory()).map(t=>E.join(e,t.name,`SKILL.md`));let r=[];for(let t of n){let n=E.join(e,t.name);t.isDirectory()?r.push(...await Q(n,!1)):t.isFile()&&t.name.toLowerCase().endsWith(`.md`)&&r.push(n)}return r}async function fe(e){let t=[],n=[[`skill`,E.join(e,`skills`)],[`agent`,E.join(e,`agents`)],[`command`,E.join(e,`commands`)]];for(let[e,r]of n){let n=await Q(r,e===`skill`);for(let r of n){let n;try{n=await k(r,{encoding:`utf-8`})}catch(n){if(f(n))continue;t.push({success:!1,errors:[{path:`file`,message:`Failed to read: ${h(n)}`}],warnings:[],filePath:r,fileType:e});continue}let i=de(r,n,e);(i.errors.length>0||i.warnings.length>0)&&t.push(i)}}let r=await Z(E.join(e,`hooks`,`hooks.json`));return(r.errors.length>0||r.warnings.length>0)&&t.push(r),t}async function pe(e){let t=E.resolve(e),n=null;try{n=await M(t)}catch(e){if(!f(e))throw e}if(n?.isDirectory()){let e=await X(E.join(t,`.claude-plugin`,`marketplace.json`));if(e.errors[0]?.code!==`ENOENT`)return e;let n=await Y(E.join(t,`.claude-plugin`,`plugin.json`));return n.errors[0]?.code===`ENOENT`?{success:!1,errors:[{path:`directory`,message:`No manifest found in directory. Expected .claude-plugin/marketplace.json or .claude-plugin/plugin.json`}],warnings:[],filePath:t,fileType:`plugin`}:n}switch(le(e)){case`plugin`:return Y(e);case`marketplace`:return X(e);case`unknown`:try{let n=_(await k(t,{encoding:`utf-8`}));if(Array.isArray(n.plugins))return X(e)}catch(e){if(m(e)===`ENOENT`)return{success:!1,errors:[{path:`file`,message:`File not found: ${t}`}],warnings:[],filePath:t,fileType:`plugin`}}return Y(e)}}var $,me=e((()=>{te(),g(),c(),S(),i(),ie(),$=new Set([`category`,`source`,`tags`,`strict`,`id`])}));export{K as a,G as c,ce as i,pe as n,B as o,fe as r,z as s,me as t};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{l as e,o as t,u as n}from"./envUtils-DcaKZlRU.js";import{
|
|
1
|
+
import{l as e,o as t,u as n}from"./envUtils-DcaKZlRU.js";import{CS as r,SS as i,gt as a,kt as o,wt as s}from"./loadAgentsDir-mcRW90aq.js";import{t as c}from"./src-P_wYS_NJ2.js";import{C as l,P as u,R as d,S as f,c as p,i as m,x as h}from"./debug-Dr1SjdXn.js";import{Wt as g}from"./settings-DiBMs2gM.js";import{O as _,k as v}from"./git-CoQQ6YEf.js";import{o as y,s as b}from"./log-27kCA_9u.js";import{n as x,r as S}from"./analytics-DJobLaWP.js";import{C,l as w,v as T}from"./startupProfiler-Dc5r6LgE.js";import{Bt as E,Ot as D,_n as O,vn as k}from"./model-C29_32BD.js";import{i as ee,t as A}from"./sessionIdCompat-DMayYBrf.js";import{n as j}from"./firstPartyEventLogger-1RTgXHSz.js";import{t as te}from"./datadog-3WUWcCFn.js";import{n as M,o as N,r as P}from"./debugUtils-cK-iOsEV.js";import{t as F}from"./pollConfig-BgpfHQPJ.js";import{n as I,t as L}from"./rcDebugLog-DSchf3Hs.js";import{a as R,i as z,n as B,o as ne,r as re,s as V,t as H}from"./capacityWake-ByL6fM6I.js";import{a as ie,i as ae,n as oe,r as se,t as ce}from"./workSecret-XLodD7tw.js";import{i as U}from"./trustedDevice-BLiKbGpG.js";import{t as le}from"./jwtUtils-FQWtM6iM.js";import{n as W,r as G}from"./cliLaunch-OPOtzhvA.js";import"./bridgeStatusUtil-DStiD05t.js";import{t as K}from"./lib-BlVGipXx.js";import{hostname as q,tmpdir as ue}from"os";import{dirname as J,join as de,resolve as Y}from"path";import{createWriteStream as X}from"fs";import{randomUUID as Z}from"crypto";import{spawn as fe}from"child_process";import{createInterface as Q}from"readline";t(),d(),h(),_(),y(),x(),T(),O(),r(),te(),j(),s(),L(),K(),g(),c(),m(),A(),N();var pe=10,me=10;function he(e){return e.replace(/[^a-zA-Z0-9_-]/g,`_`)}var ge={Read:`Reading`,Write:`Writing`,Edit:`Editing`,MultiEdit:`Editing`,Bash:`Running`,Glob:`Searching`,Grep:`Searching`,WebFetch:`Fetching`,WebSearch:`Searching`,Task:`Running task`,FileReadTool:`Reading`,FileWriteTool:`Writing`,FileEditTool:`Editing`,GlobTool:`Searching`,GrepTool:`Searching`,BashTool:`Running`,NotebookEditTool:`Editing notebook`,LSP:`LSP`};function $(e,t){let n=ge[e]??e,r=t.file_path??t.filePath??t.pattern??t.command?.slice(0,60)??t.url??t.query??``;return r?`${n} ${r}`:n}function _e(e,t,n){let r;try{r=f(e)}catch{return[]}if(!r||typeof r!=`object`)return[];let i=r,a=[],o=Date.now();switch(i.type){case`assistant`:{let e=i.message;if(!e)break;let r=e.content;if(!Array.isArray(r))break;for(let e of r){if(!e||typeof e!=`object`)continue;let r=e;if(r.type===`tool_use`){let e=r.name??`Tool`,i=r.input??{},s=$(e,i);a.push({type:`tool_start`,summary:s,timestamp:o}),n(`[bridge:activity] sessionId=${t} tool_use name=${e} ${ye(i)}`)}else if(r.type===`text`){let e=r.text??``;e.length>0&&(a.push({type:`text`,summary:e.slice(0,80),timestamp:o}),n(`[bridge:activity] sessionId=${t} text "${e.slice(0,100)}"`))}}break}case`result`:{let e=i.subtype;if(e===`success`)a.push({type:`result`,summary:`Session completed`,timestamp:o}),n(`[bridge:activity] sessionId=${t} result subtype=success`);else if(e){let r=i.errors?.[0]??`Error: ${e}`;a.push({type:`error`,summary:r,timestamp:o}),n(`[bridge:activity] sessionId=${t} result subtype=${e} error="${r}"`)}else n(`[bridge:activity] sessionId=${t} result subtype=undefined`);break}default:break}return a}function ve(e){if(e.parent_tool_use_id!=null||e.isSynthetic||e.isReplay)return;let t=e.message?.content,n;if(typeof t==`string`)n=t;else if(Array.isArray(t)){for(let e of t)if(e&&typeof e==`object`&&e.type===`text`){n=e.text;break}}return n=n?.trim(),n||void 0}function ye(e){let t=[];for(let[n,r]of Object.entries(e))if(typeof r==`string`&&t.push(`${n}="${r.slice(0,100)}"`),t.length>=3)break;return t.join(` `)}function be(e){return{spawn(t,n){let r=he(t.sessionId),i;if(e.debugFile){let t=e.debugFile.lastIndexOf(`.`);i=t>0?`${e.debugFile.slice(0,t)}-${r}${e.debugFile.slice(t)}`:`${e.debugFile}-${r}`}else e.verbose&&(i=de(ue(),`claude`,`bridge-session-${r}.log`));let a=null,o;e.debugFile&&(o=de(J(e.debugFile),`bridge-transcript-${r}.jsonl`),a=X(o,{flags:`a`}),a.on(`error`,t=>{e.onDebug(`[bridge:session] Transcript write error: ${t.message}`),a=null}),e.onDebug(`[bridge:session] Transcript log: ${o}`));let s=[...e.scriptArgs,`--print`,`--sdk-url`,t.sdkUrl,`--session-id`,t.sessionId,`--input-format`,`stream-json`,`--output-format`,`stream-json`,`--replay-user-messages`,...e.verbose?[`--verbose`]:[],...i?[`--debug-file`,i]:[],...e.permissionMode?[`--permission-mode`,e.permissionMode]:[]],c={...e.env,CLAUDE_CODE_OAUTH_TOKEN:void 0,CLAUDE_CODE_ENVIRONMENT_KIND:`bridge`,...e.sandbox&&{CLAUDE_CODE_FORCE_SANDBOX:`1`},CLAUDE_CODE_SESSION_ACCESS_TOKEN:t.accessToken,CLAUDE_CODE_POST_FOR_SESSION_INGRESS_V2:`1`,...t.useCcrV2&&{CLAUDE_CODE_USE_CCR_V2:`1`,CLAUDE_CODE_WORKER_EPOCH:String(t.workerEpoch)}};e.onDebug(`[bridge:session] Spawning sessionId=${t.sessionId} sdkUrl=${t.sdkUrl} accessToken=${t.accessToken?`present`:`MISSING`}`),e.onDebug(`[bridge:session] Child args: ${s.join(` `)}`),i&&e.onDebug(`[bridge:session] Debug log: ${i}`);let u=fe(e.execPath,s,{cwd:n,stdio:[`pipe`,`pipe`,`pipe`],env:c,windowsHide:!0});e.onDebug(`[bridge:session] sessionId=${t.sessionId} pid=${u.pid}`);let d=[],p=null,m=[],h=!1,g=!1;u.stderr&&Q({input:u.stderr}).on(`line`,t=>{e.verbose&&process.stderr.write(t+`
|
|
2
2
|
`),m.length>=me&&m.shift(),m.push(t)}),u.stdout&&Q({input:u.stdout}).on(`line`,n=>{a&&a.write(n+`
|
|
3
3
|
`),e.onDebug(`[bridge:ws] sessionId=${t.sessionId} <<< ${M(n)}`),e.verbose&&process.stderr.write(n+`
|
|
4
4
|
`);let r=_e(n,t.sessionId,e.onDebug);for(let n of r)d.length>=pe&&d.shift(),d.push(n),p=n,e.onActivity?.(t.sessionId,n);{let r;try{r=f(n)}catch{}if(r&&typeof r==`object`){let n=r;if(n.type===`control_request`)n.request?.subtype===`can_use_tool`&&e.onPermissionRequest&&e.onPermissionRequest(t.sessionId,r,t.accessToken);else if(n.type===`user`&&!g&&t.onFirstUserMessage){let e=ve(n);e&&(g=!0,t.onFirstUserMessage(e))}}}});let _=new Promise(n=>{u.on(`close`,(r,i)=>{a&&(a.end(),a=null),i===`SIGTERM`||i===`SIGINT`?(e.onDebug(`[bridge:session] sessionId=${t.sessionId} interrupted signal=${i} pid=${u.pid}`),n(`interrupted`)):r===0?(e.onDebug(`[bridge:session] sessionId=${t.sessionId} completed exit_code=0 pid=${u.pid}`),n(`completed`)):(e.onDebug(`[bridge:session] sessionId=${t.sessionId} failed exit_code=${r} pid=${u.pid}`),n(`failed`))}),u.on(`error`,r=>{e.onDebug(`[bridge:session] sessionId=${t.sessionId} spawn error: ${r.message}`),n(`failed`)})}),v={sessionId:t.sessionId,done:_,activities:d,accessToken:t.accessToken,lastStderr:m,get currentActivity(){return p},kill(){u.killed||(e.onDebug(`[bridge:session] Sending SIGTERM to sessionId=${t.sessionId} pid=${u.pid}`),process.platform===`win32`?u.kill():u.kill(`SIGTERM`))},forceKill(){!h&&u.pid&&(h=!0,e.onDebug(`[bridge:session] Sending SIGKILL to sessionId=${t.sessionId} pid=${u.pid}`),process.platform===`win32`?u.kill():u.kill(`SIGKILL`))},writeStdin(n){u.stdin&&!u.stdin.destroyed&&(e.onDebug(`[bridge:ws] sessionId=${t.sessionId} >>> ${M(n)}`),u.stdin.write(n))},updateAccessToken(n){v.accessToken=n,v.writeStdin(l({type:`update_environment_variables`,variables:{CLAUDE_CODE_SESSION_ACCESS_TOKEN:n}})+`
|
|
5
|
-
`),e.onDebug(`[bridge:session] Sent token refresh via stdin for sessionId=${t.sessionId}`)}};return v}}}m(),N();var xe={connInitialMs:2e3,connCapMs:12e4,connGiveUpMs:6e5,generalInitialMs:500,generalCapMs:3e4,generalGiveUpMs:6e5},Se=1e3;function Ce(e){return e.connCapMs*2}function we(){let e=[...W()],t=G();return t&&e.push(t),e}function Te(e,t,n){try{return e.spawn(t,n)}catch(e){let t=u(e);return b(Error(`Session spawn failed: ${t}`)),t}}async function Ee(t,
|
|
6
|
-
`):void 0,P;switch(g){case`completed`:d.logSessionComplete(e,k);break;case`failed`:!h&&!y.aborted&&(P=ee??`Process exited with error`,d.logSessionFailed(e,P),b(Error(`Bridge session failed: ${P}`)));break;case`interrupted`:d.logVerbose(`Session ${e} interrupted`);break}g!==`interrupted`&&s&&(G(Me(c,i,s,d,m.stopWorkBaseDelayMs)),A.add(s));let F=j.get(e);if(F&&(j.delete(e),G(r(F.worktreePath,F.worktreeBranch,F.gitRoot,F.hookBased).catch(e=>d.logVerbose(`Failed to remove worktree ${F.worktreePath}: ${u(e)}`)))),g!==`interrupted`&&!y.aborted)if(t.spawnMode!==`single-session`)G(c.archiveSession(l).catch(t=>d.logVerbose(`Failed to archive session ${e}: ${u(t)}`))),p(`[bridge:session] Session ${g}, returning to idle (multi-session mode)`);else{p(`[bridge:session] Session ${g}, aborting poll loop to tear down environment`),_.abort();return}y.aborted||Q()}}for(h||Q();!y.aborted;){let f=F();try{I(`poll: envId=${i} activeSessions=${x.size}`);let g=await c.pollForWork(i,o,y,f.reclaim_older_than_ms);if(J!==null||Y!==null){let e=Date.now()-(J??Y??Date.now());d.logReconnected(e),p(`[bridge:poll] Reconnected after ${w(e)}`),S(`tengu_bridge_reconnected`,{disconnected_ms:e})}if(K=0,q=0,J=null,Y=null,X=null,!g){if(x.size>=t.maxSessions){let e=f.multisession_poll_interval_ms_at_capacity;if(f.non_exclusive_heartbeat_interval_ms>0){S(`tengu_bridge_heartbeat_mode_entered`,{active_sessions:x.size,heartbeat_interval_ms:f.non_exclusive_heartbeat_interval_ms});let n=e>0?Date.now()+e:null,r=`ok`,i=0;for(;!y.aborted&&x.size>=t.maxSessions&&(n===null||Date.now()<n);){let e=F();if(e.non_exclusive_heartbeat_interval_ms<=0)break;let t=N.signal();if(r=await L(),r===`auth_failed`||r===`fatal`){t.cleanup();break}i++,await k(e.non_exclusive_heartbeat_interval_ms,t.signal),t.cleanup()}let a=r===`auth_failed`||r===`fatal`?r:y.aborted?`shutdown`:x.size<t.maxSessions?`capacity_changed`:n!==null&&Date.now()>=n?`poll_due`:`config_disabled`;if(S(`tengu_bridge_heartbeat_mode_exited`,{reason:a,heartbeat_cycles:i,active_sessions:x.size}),a===`poll_due`&&p(`[bridge:poll] Heartbeat poll_due after ${i} cycles — falling through to pollForWork`),r===`auth_failed`||r===`fatal`){let t=N.signal();await k(e>0?e:f.non_exclusive_heartbeat_interval_ms,t.signal),t.cleanup()}}else if(e>0){let t=N.signal();await k(e,t.signal),t.cleanup()}}else await k(x.size>0?f.multisession_poll_interval_ms_partial_capacity:f.multisession_poll_interval_ms_not_at_capacity,y);continue}let _=x.size>=t.maxSessions;if(A.has(g.id)){if(p(`[bridge:work] Skipping already-completed workId=${g.id}`),_){let e=N.signal();f.non_exclusive_heartbeat_interval_ms>0?(await L(),await k(f.non_exclusive_heartbeat_interval_ms,e.signal)):f.multisession_poll_interval_ms_at_capacity>0&&await k(f.multisession_poll_interval_ms_at_capacity,e.signal),e.cleanup()}else await k(1e3,y);continue}let P;try{P=se(g.secret)}catch(e){let t=u(e);if(d.logError(`Failed to decode work secret for workId=${g.id}: ${t}`),S(`tengu_bridge_work_secret_failed`,{}),A.add(g.id),G(Me(c,i,g.id,d,m.stopWorkBaseDelayMs)),_){let e=N.signal();f.non_exclusive_heartbeat_interval_ms>0?(await L(),await k(f.non_exclusive_heartbeat_interval_ms,e.signal)):f.multisession_poll_interval_ms_at_capacity>0&&await k(f.multisession_poll_interval_ms_at_capacity,e.signal),e.cleanup()}continue}let R=async()=>{p(`[bridge:work] Acknowledging workId=${g.id}`);try{await c.acknowledgeWork(i,g.id,P.session_ingress_token)}catch(e){p(`[bridge:work] Acknowledge failed workId=${g.id}: ${u(e)}`)}},z=g.data.type;switch(g.data.type){case`healthcheck`:await R(),p(`[bridge:work] Healthcheck received`),d.logVerbose(`Healthcheck received`);break;case`session`:{let o=g.data.id;I(`work received: type=session sessionId=${o} workId=${g.id}`);try{ne(o,`session_id`)}catch{await R(),d.logError(`Invalid session_id received: ${o}`);break}let f=x.get(o);if(f){f.updateAccessToken(P.session_ingress_token),D.set(o,P.session_ingress_token),T.set(o,g.id),V?.schedule(o,P.session_ingress_token),p(`[bridge:work] Updated access token for existing sessionId=${o} workId=${g.id}`),await R();break}if(x.size>=t.maxSessions){p(`[bridge:work] At capacity (${x.size}/${t.maxSessions}), cannot spawn new session for workId=${g.id}`);break}await R();let _=Date.now(),w,N=!1,F;if(P.use_code_sessions===!0||e(process.env.CLAUDE_BRIDGE_USE_CCR_V2)){w=ce(t.apiBaseUrl,o);for(let e=1;e<=2;e++)try{F=await ae(w,P.session_ingress_token),N=!0,p(`[bridge:session] CCR v2: registered worker sessionId=${o} epoch=${F} attempt=${e}`);break}catch(t){let n=u(t);if(e<2){if(p(`[bridge:session] CCR v2: registerWorker attempt ${e} failed, retrying: ${n}`),await k(2e3,y),y.aborted)break;continue}d.logError(`CCR v2 worker registration failed for session ${o}: ${n}`),b(Error(`registerWorker failed: ${n}`)),A.add(g.id),G(Me(c,i,g.id,d,m.stopWorkBaseDelayMs))}if(!N)break}else w=oe(t.sessionIngressUrl,o);let L=t.spawnMode,z=t.dir,B=0;if(L===`worktree`&&(h===void 0||!ie(o,h))){let e=Date.now();try{let t=await s(`bridge-${he(o)}`);B=Date.now()-e,j.set(o,{worktreePath:t.worktreePath,worktreeBranch:t.worktreeBranch,gitRoot:t.gitRoot,hookBased:t.hookBased}),z=t.worktreePath,p(`[bridge:session] Created worktree for sessionId=${o} at ${t.worktreePath}`)}catch(e){let t=u(e);d.logError(`Failed to create worktree for session ${o}: ${t}`),b(Error(`Worktree creation failed: ${t}`)),A.add(g.id),G(Me(c,i,g.id,d,m.stopWorkBaseDelayMs));break}}p(`[bridge:session] Spawning sessionId=${o} sdkUrl=${w}`);let H=ee(o);I(`spawning session: sessionId=${o} sdkUrl=${w} useCcrV2=${N} workerEpoch=${F} dir=${z} accessToken=${P.session_ingress_token?P.session_ingress_token.slice(0,8)+`...`:`NONE`}`);let se=Te(l,{sessionId:o,sdkUrl:w,accessToken:P.session_ingress_token,useCcrV2:N,workerEpoch:F,onFirstUserMessage:e=>{if(M.has(H))return;M.add(H);let n=Fe(e);d.setSessionTitle(H,n),p(`[bridge:title] derived title for ${H}: ${n}`),import(`./createSession-CjdLcRec.js`).then(({updateBridgeSessionTitle:e})=>e(H,n,{baseUrl:t.apiBaseUrl})).catch(e=>p(`[bridge:title] failed to update title for ${H}: ${e}`,{level:`error`}))}},z);if(typeof se==`string`){d.logError(`Failed to spawn session ${o}: ${se}`);let e=j.get(o);e&&(j.delete(o),G(r(e.worktreePath,e.worktreeBranch,e.gitRoot,e.hookBased).catch(t=>d.logVerbose(`Failed to remove worktree ${e.worktreePath}: ${u(t)}`)))),A.add(g.id),G(Me(c,i,g.id,d,m.stopWorkBaseDelayMs));break}let U=se,le=Date.now()-_;S(`tengu_bridge_session_started`,{active_sessions:x.size,spawn_mode:L,in_worktree:j.has(o),spawn_duration_ms:le,worktree_create_ms:B,inProtectedNamespace:n()}),v(`info`,`bridge_session_started`,{spawn_mode:L,in_worktree:j.has(o),spawn_duration_ms:le,worktree_create_ms:B}),x.set(o,U),T.set(o,g.id),D.set(o,P.session_ingress_token),E.set(o,H);let W=Date.now();C.set(o,W),d.logSessionStart(o,`Session ${o}`);let K=he(o),q;if(t.debugFile){let e=t.debugFile.lastIndexOf(`.`);q=e>0?`${t.debugFile.slice(0,e)}-${K}${t.debugFile.slice(e)}`:`${t.debugFile}-${K}`}else t.verbose&&(q=de(ue(),`claude`,`bridge-session-${K}.log`));q&&d.logVerbose(`Debug log: ${q}`),d.addSession(H,a(H,t.sessionIngressUrl)),Q(),d.setAttached(H),Ie(H,t.apiBaseUrl).then(e=>{e&&x.has(o)&&(M.add(H),d.setSessionTitle(H,e),p(`[bridge:title] server title for ${H}: ${e}`))}).catch(e=>p(`[bridge:title] failed to fetch title for ${H}: ${e}`,{level:`error`}));let J=t.sessionTimeoutMs??864e5;if(J>0){let e=setTimeout(Ne,J,o,J,d,te,U);O.set(o,e)}N&&re.add(o),V?.schedule(o,P.session_ingress_token),U.done.then(me(o,W,U));break}default:await R(),p(`[bridge:work] Unknown work type: ${z}, skipping`);break}if(_){let e=N.signal();f.non_exclusive_heartbeat_interval_ms>0?(await L(),await k(f.non_exclusive_heartbeat_interval_ms,e.signal)):f.multisession_poll_interval_ms_at_capacity>0&&await k(f.multisession_poll_interval_ms_at_capacity,e.signal),e.cleanup()}}catch(e){if(y.aborted)break;if(e instanceof B){z(e.errorType)?d.logStatus(e.message):R(e)?p(`[bridge:work] Suppressed 403 error: ${e.message}`):(d.logError(e.message),b(e)),S(`tengu_bridge_fatal_error`,{status:e.status,error_type:e.errorType}),v(z(e.errorType)?`info`:`error`,`bridge_fatal_error`,{status:e.status,error_type:e.errorType});break}let t=P(e);if(I(`poll error: ${t} isConn=${Oe(e)} isServer=${ke(e)} activeSessions=${x.size}`),Oe(e)||ke(e)){let e=Date.now();X!==null&&e-X>Ce(m)&&(p(`[bridge:work] Detected system sleep (${Math.round((e-X)/1e3)}s gap), resetting error budget`),v(`info`,`bridge_poll_sleep_detected`,{gapMs:e-X}),J=null,K=0,Y=null,q=0),X=e,J||(J=e);let n=e-J;if(n>=m.connGiveUpMs){d.logError(`Server unreachable for ${Math.round(n/6e4)} minutes, giving up.`),S(`tengu_bridge_poll_give_up`,{error_type:`connection`,elapsed_ms:n}),v(`error`,`bridge_poll_give_up`,{error_type:`connection`,elapsed_ms:n});break}Y=null,q=0,K=K?Math.min(K*2,m.connCapMs):m.connInitialMs;let r=Ae(K);d.logVerbose(`Connection error, retrying in ${je(r)} (${Math.round(n/1e3)}s elapsed): ${t}`),d.updateReconnectingStatus(je(r),w(n)),F().non_exclusive_heartbeat_interval_ms>0&&await L(),await k(r,y)}else{let e=Date.now();X!==null&&e-X>Ce(m)&&(p(`[bridge:work] Detected system sleep (${Math.round((e-X)/1e3)}s gap), resetting error budget`),v(`info`,`bridge_poll_sleep_detected`,{gapMs:e-X}),J=null,K=0,Y=null,q=0),X=e,Y||(Y=e);let n=e-Y;if(n>=m.generalGiveUpMs){d.logError(`Persistent errors for ${Math.round(n/6e4)} minutes, giving up.`),S(`tengu_bridge_poll_give_up`,{error_type:`general`,elapsed_ms:n}),v(`error`,`bridge_poll_give_up`,{error_type:`general`,elapsed_ms:n});break}J=null,K=0,q=q?Math.min(q*2,m.generalCapMs):m.generalInitialMs;let r=Ae(q);d.logVerbose(`Poll failed, retrying in ${je(r)} (${Math.round(n/1e3)}s elapsed): ${t}`),d.updateReconnectingStatus(je(r),w(n)),F().non_exclusive_heartbeat_interval_ms>0&&await L(),await k(r,y)}}}pe(),d.clearStatus();let ge=Date.now()-U;S(`tengu_bridge_shutdown`,{active_sessions:x.size,loop_duration_ms:ge}),v(`info`,`bridge_shutdown`,{active_sessions:x.size,loop_duration_ms:ge});let $=new Set(x.keys());h&&$.add(h);let _e=new Map(E);if(x.size>0){p(`[bridge:shutdown] Shutting down ${x.size} active session(s)`),d.logStatus(`Shutting down ${x.size} active session(s)\u2026`);let e=new Map(T);for(let[e,t]of x.entries())p(`[bridge:shutdown] Sending SIGTERM to sessionId=${e}`),t.kill();let t=new AbortController;await Promise.race([Promise.allSettled([...x.values()].map(e=>e.done)),k(m.shutdownGraceMs??3e4,t.signal)]),t.abort();for(let[e,t]of x.entries())p(`[bridge:shutdown] Force-killing stuck sessionId=${e}`),t.forceKill();for(let e of O.values())clearTimeout(e);if(O.clear(),V?.cancelAll(),j.size>0){let e=[...j.values()];j.clear(),p(`[bridge:shutdown] Cleaning up ${e.length} worktree(s)`),await Promise.allSettled(e.map(e=>r(e.worktreePath,e.worktreeBranch,e.gitRoot,e.hookBased)))}await Promise.allSettled([...e.entries()].map(([e,t])=>c.stopWork(i,t,!0).catch(n=>d.logVerbose(`Failed to stop work ${t} for session ${e}: ${u(n)}`))))}W.size>0&&await Promise.allSettled([...W]),$.size>0&&(p(`[bridge:shutdown] Archiving ${$.size} session(s)`),await Promise.allSettled([...$].map(e=>c.archiveSession(_e.get(e)??ee(e)).catch(t=>d.logVerbose(`Failed to archive session ${e}: ${u(t)}`)))));try{await c.deregisterEnvironment(i),p(`[bridge:shutdown] Environment deregistered, bridge offline`),d.logVerbose(`Environment deregistered.`)}catch(e){d.logVerbose(`Failed to deregister environment: ${u(e)}`)}let{clearBridgePointer:ve}=await import(`./bridgePointer-DHWK3LEe.js`);await ve(t.dir),d.logVerbose(`Environment offline.`)}var De=new Set([`ECONNREFUSED`,`ECONNRESET`,`ETIMEDOUT`,`ENETUNREACH`,`EHOSTUNREACH`]);function Oe(e){return!!(e&&typeof e==`object`&&`code`in e&&typeof e.code==`string`&&De.has(e.code))}function ke(e){return!!e&&typeof e==`object`&&`code`in e&&typeof e.code==`string`&&e.code===`ERR_BAD_RESPONSE`}function Ae(e){return Math.max(0,e+e*.25*(2*Math.random()-1))}function je(e){return e>=1e3?`${(e/1e3).toFixed(1)}s`:`${Math.round(e)}ms`}async function Me(e,t,n,r,i=1e3){for(let a=1;a<=3;a++)try{await e.stopWork(t,n,!1),p(`[bridge:work] stopWork succeeded for workId=${n} on attempt ${a}/3`);return}catch(e){if(e instanceof B){R(e)?p(`[bridge:work] Suppressed stopWork 403 for ${n}: ${e.message}`):r.logError(`Failed to stop work ${n}: ${e.message}`),v(`error`,`bridge_stop_work_failed`,{attempts:a,fatal:!0});return}let t=u(e);if(a<3){let e=Ae(i*2**(a-1));r.logVerbose(`Failed to stop work ${n} (attempt ${a}/3), retrying in ${je(e)}: ${t}`),await k(e)}else r.logError(`Failed to stop work ${n} after 3 attempts: ${t}`),v(`error`,`bridge_stop_work_failed`,{attempts:3})}}function Ne(e,t,n,r,i){p(`[bridge:session] sessionId=${e} timed out after ${w(t)}`),S(`tengu_bridge_session_timeout`,{timeout_ms:t}),n.logSessionFailed(e,`Session timed out after ${w(t)}`),r.add(e),i.kill()}var Pe=80;function Fe(e){return C(e.replace(/\s+/g,` `).trim(),Pe)}async function Ie(e,t){let{getBridgeSession:n}=await import(`./createSession-CjdLcRec.js`);return(await n(e,{baseUrl:t}))?.title||void 0}var Le=class extends Error{constructor(e){super(e),this.name=`BridgeHeadlessPermanentError`}};async function Re(e,t){let{dir:n,log:r}=e;process.chdir(n);let{setOriginalCwd:i,setCwdState:a}=await import(`./state-CsdHk8n-.js`);i(n),a(n);let{enableConfigs:o,checkHasTrustDialogAccepted:s}=await import(`./config-DMKtiMzJ.js`);o();let{initSinks:c}=await import(`./sinks-DppGvgz1.js`);if(c(),!s())throw new Le(`Workspace not trusted: ${n}. Run \`claude\` in that directory first to accept the trust dialog.`);if(!e.getAccessToken())throw Error(V);let{getBridgeBaseUrl:l}=await import(`./bridgeConfig-Ccm79Jze.js`),d=l();if(d.startsWith(`http://`)&&!d.includes(`localhost`)&&!d.includes(`127.0.0.1`))throw new Le(`Remote Control base URL uses HTTP. Only HTTPS or localhost HTTP is allowed.`);let f=process.env.CLAUDE_BRIDGE_SESSION_INGRESS_URL||d,{getBranch:p,getRemoteUrl:m,findGitRoot:h}=await import(`./git-Bs1vtuvX.js`),{hasWorktreeCreateHook:g}=await import(`./hooks-D-twhU_z.js`);if(e.spawnMode===`worktree`&&!(g()||h(n)!==null))throw new Le(`Worktree mode requires a git repository or WorktreeCreate hooks. Directory ${n} has neither.`);let _=await p(),v=await m(),y=q(),b=Z(),x={dir:n,machineName:y,branch:_,gitRepoUrl:v,maxSessions:e.capacity,spawnMode:e.spawnMode,verbose:!1,sandbox:e.sandbox,bridgeId:b,workerType:`claude_code`,environmentId:Z(),apiBaseUrl:d,sessionIngressUrl:f,sessionTimeoutMs:e.sessionTimeoutMs},S=re({baseUrl:d,getAccessToken:e.getAccessToken,runnerVersion:`0.0.12`,onDebug:r,onAuth401:e.onAuth401,getTrustedDeviceToken:U}),C,w;try{let e=await S.registerBridgeEnvironment(x);C=e.environment_id,w=e.environment_secret}catch(e){throw Error(`Bridge registration failed: ${u(e)}`)}let T=be({execPath:process.execPath,scriptArgs:we(),env:process.env,verbose:!1,sandbox:e.sandbox,permissionMode:e.permissionMode,onDebug:r}),E=ze(r);E.printBanner(x,C);let D;if(e.createSessionOnStart){let{createBridgeSession:n}=await import(`./createSession-CjdLcRec.js`);try{let i=await n({environmentId:C,title:e.name,events:[],gitRepoUrl:v,branch:_,signal:t,baseUrl:d,getAccessToken:e.getAccessToken,permissionMode:e.permissionMode});i&&(D=i,r(`created initial session ${i}`))}catch(e){r(`session pre-creation failed (non-fatal): ${u(e)}`)}}await Ee(x,C,w,S,T,E,t,void 0,D,async()=>e.getAccessToken())}function ze(e){let t=()=>{};return{printBanner:(t,n)=>e(`registered environmentId=${n} dir=${t.dir} spawnMode=${t.spawnMode} capacity=${t.maxSessions}`),logSessionStart:(t,n)=>e(`session start ${t}`),logSessionComplete:(t,n)=>e(`session complete ${t} (${n}ms)`),logSessionFailed:(t,n)=>e(`session failed ${t}: ${n}`),logStatus:e,logVerbose:e,logError:t=>e(`error: ${t}`),logReconnected:t=>e(`reconnected after ${t}ms`),addSession:(t,n)=>e(`session attached ${t}`),removeSession:t=>e(`session detached ${t}`),updateIdleStatus:t,updateReconnectingStatus:t,updateSessionStatus:t,updateSessionActivity:t,updateSessionCount:t,updateFailedStatus:t,setSpawnModeDisplay:t,setRepoInfo:t,setDebugLogPath:t,setAttached:t,setSessionTitle:t,clearStatus:t,toggleQr:t,refreshDisplay:t}}E(),d();var Be=78,Ve=1;async function He(e){if(!e){console.error(`Error: --daemon-worker requires a worker kind`),process.exitCode=Be;return}switch(e){case`remoteControl`:await Ue();break;default:console.error(`Error: unknown daemon worker kind '${e}'`),process.exitCode=Be}}async function Ue(){let e=process.env.DAEMON_WORKER_DIR||Y(`.`),t=process.env.DAEMON_WORKER_NAME||void 0,n=process.env.DAEMON_WORKER_SPAWN_MODE||`same-dir`,r=parseInt(process.env.DAEMON_WORKER_CAPACITY||`4`,10),i=process.env.DAEMON_WORKER_PERMISSION||void 0,a=process.env.DAEMON_WORKER_SANDBOX===`1`,o=process.env.DAEMON_WORKER_TIMEOUT_MS?parseInt(process.env.DAEMON_WORKER_TIMEOUT_MS,10):void 0,s=process.env.DAEMON_WORKER_CREATE_SESSION!==`0`,c=new AbortController,l=()=>c.abort();process.on(`SIGTERM`,l),process.on(`SIGINT`,l);let d={dir:e,name:t,spawnMode:n,capacity:r,permissionMode:i,sandbox:a,sessionTimeoutMs:o,createSessionOnStart:s,getAccessToken:()=>D()?.accessToken,onAuth401:async e=>!!D()?.accessToken,log:e=>{console.log(`[remoteControl] ${e}`)}};try{await Re(d,c.signal)}catch(e){e instanceof Le?(console.error(`[remoteControl] permanent error: ${e.message}`),process.exitCode=Be):(console.error(`[remoteControl] transient error: ${u(e)}`),process.exitCode=Ve)}finally{process.off(`SIGTERM`,l),process.off(`SIGINT`,l)}}export{He as runDaemonWorker};
|
|
5
|
+
`),e.onDebug(`[bridge:session] Sent token refresh via stdin for sessionId=${t.sessionId}`)}};return v}}}m(),N();var xe={connInitialMs:2e3,connCapMs:12e4,connGiveUpMs:6e5,generalInitialMs:500,generalCapMs:3e4,generalGiveUpMs:6e5},Se=1e3;function Ce(e){return e.connCapMs*2}function we(){let e=[...W()],t=G();return t&&e.push(t),e}function Te(e,t,n){try{return e.spawn(t,n)}catch(e){let t=u(e);return b(Error(`Session spawn failed: ${t}`)),t}}async function Ee(t,r,s,c,l,d,f,m=xe,h,g){let _=new AbortController;f.aborted?_.abort():f.addEventListener(`abort`,()=>_.abort(),{once:!0});let y=_.signal,x=new Map,C=new Map,T=new Map,E=new Map,D=new Map,O=new Map,A=new Set,j=new Map,te=new Set,M=new Set,N=H(y);async function L(){I(`heartbeat: checking ${x.size} active session(s)`);let e=!1,t=!1,n=[];for(let[i]of x){let a=T.get(i),o=D.get(i);if(!(!a||!o))try{await c.heartbeatWork(r,a,o),e=!0}catch(e){p(`[bridge:heartbeat] Failed for sessionId=${i} workId=${a}: ${u(e)}`),e instanceof B&&(S(`tengu_bridge_heartbeat_error`,{status:e.status,error_type:e.status===401||e.status===403?`auth_failed`:`fatal`}),e.status===401||e.status===403?n.push(i):t=!0)}}for(let e of n){d.logVerbose(`Session ${e} token expired — re-queuing via bridge/reconnect`);try{await c.reconnectSession(r,e),p(`[bridge:heartbeat] Re-queued sessionId=${e} via bridge/reconnect`)}catch(t){d.logError(`Failed to refresh session ${e} token: ${u(t)}`),p(`[bridge:heartbeat] reconnectSession(${e}) failed: ${u(t)}`,{level:`error`})}}return t?`fatal`:n.length>0?`auth_failed`:e?`ok`:`failed`}let re=new Set,V=g?le({getAccessToken:g,onRefresh:(e,t)=>{let n=x.get(e);n&&(re.has(e)?(d.logVerbose(`Refreshing session ${e} token via bridge/reconnect`),c.reconnectSession(r,e).catch(t=>{d.logError(`Failed to refresh session ${e} token: ${u(t)}`),p(`[bridge:token] reconnectSession(${e}) failed: ${u(t)}`,{level:`error`})})):n.updateAccessToken(t))},label:`bridge`}):null,U=Date.now(),W=new Set;function G(e){W.add(e),e.finally(()=>W.delete(e))}let K=0,q=0,J=null,Y=null,X=null,Z=null;p(`[bridge:work] Starting poll loop spawnMode=${t.spawnMode} maxSessions=${t.maxSessions} environmentId=${r}`),v(`info`,`bridge_loop_started`,{max_sessions:t.maxSessions,spawn_mode:t.spawnMode}),d.printBanner(t,r),d.updateSessionCount(0,t.maxSessions,t.spawnMode),h&&d.setAttached(h);function fe(){d.updateSessionCount(x.size,t.maxSessions,t.spawnMode);for(let[e,t]of x){let n=t.currentActivity;n&&d.updateSessionActivity(E.get(e)??e,n)}if(x.size===0){d.updateIdleStatus();return}let[e,n]=[...x.entries()].pop(),r=C.get(e);if(!r)return;let i=n.currentActivity;if(!i||i.type===`result`||i.type===`error`){t.maxSessions>1&&d.refreshDisplay();return}let a=w(Date.now()-r),o=n.activities.filter(e=>e.type===`tool_start`).slice(-5).map(e=>e.summary);d.updateSessionStatus(e,a,i,o)}function Q(){pe(),fe(),Z=setInterval(fe,Se)}function pe(){Z&&(clearInterval(Z),Z=null)}function me(e,n,i){return a=>{let s=T.get(e);I(`session done: sessionId=${e} workId=${s??`none`} status=${a} wasTimedOut=${te.has(e)} duration=${Math.round((Date.now()-n)/1e3)}s stderr=${i.lastStderr.length>0?i.lastStderr.join(`\\n`).slice(0,500):`(none)`}`),x.delete(e),C.delete(e),T.delete(e),D.delete(e);let l=E.get(e)??e;E.delete(e),d.removeSession(l),M.delete(l),re.delete(e);let f=O.get(e);f&&(clearTimeout(f),O.delete(e)),V?.cancel(e),N.wake();let h=te.delete(e),g=h&&a===`interrupted`?`failed`:a,k=Date.now()-n;p(`[bridge:session] sessionId=${e} workId=${s??`unknown`} exited status=${g} duration=${w(k)}`),S(`tengu_bridge_session_done`,{status:g,duration_ms:k}),v(`info`,`bridge_session_done`,{status:g,duration_ms:k}),d.clearStatus(),pe();let ee=i.lastStderr.length>0?i.lastStderr.join(`
|
|
6
|
+
`):void 0,P;switch(g){case`completed`:d.logSessionComplete(e,k);break;case`failed`:!h&&!y.aborted&&(P=ee??`Process exited with error`,d.logSessionFailed(e,P),b(Error(`Bridge session failed: ${P}`)));break;case`interrupted`:d.logVerbose(`Session ${e} interrupted`);break}g!==`interrupted`&&s&&(G(Me(c,r,s,d,m.stopWorkBaseDelayMs)),A.add(s));let F=j.get(e);if(F&&(j.delete(e),G(o(F.worktreePath,F.worktreeBranch,F.gitRoot,F.hookBased).catch(e=>d.logVerbose(`Failed to remove worktree ${F.worktreePath}: ${u(e)}`)))),g!==`interrupted`&&!y.aborted)if(t.spawnMode!==`single-session`)G(c.archiveSession(l).catch(t=>d.logVerbose(`Failed to archive session ${e}: ${u(t)}`))),p(`[bridge:session] Session ${g}, returning to idle (multi-session mode)`);else{p(`[bridge:session] Session ${g}, aborting poll loop to tear down environment`),_.abort();return}y.aborted||Q()}}for(h||Q();!y.aborted;){let f=F();try{I(`poll: envId=${r} activeSessions=${x.size}`);let g=await c.pollForWork(r,s,y,f.reclaim_older_than_ms);if(J!==null||Y!==null){let e=Date.now()-(J??Y??Date.now());d.logReconnected(e),p(`[bridge:poll] Reconnected after ${w(e)}`),S(`tengu_bridge_reconnected`,{disconnected_ms:e})}if(K=0,q=0,J=null,Y=null,X=null,!g){if(x.size>=t.maxSessions){let e=f.multisession_poll_interval_ms_at_capacity;if(f.non_exclusive_heartbeat_interval_ms>0){S(`tengu_bridge_heartbeat_mode_entered`,{active_sessions:x.size,heartbeat_interval_ms:f.non_exclusive_heartbeat_interval_ms});let n=e>0?Date.now()+e:null,r=`ok`,i=0;for(;!y.aborted&&x.size>=t.maxSessions&&(n===null||Date.now()<n);){let e=F();if(e.non_exclusive_heartbeat_interval_ms<=0)break;let t=N.signal();if(r=await L(),r===`auth_failed`||r===`fatal`){t.cleanup();break}i++,await k(e.non_exclusive_heartbeat_interval_ms,t.signal),t.cleanup()}let a=r===`auth_failed`||r===`fatal`?r:y.aborted?`shutdown`:x.size<t.maxSessions?`capacity_changed`:n!==null&&Date.now()>=n?`poll_due`:`config_disabled`;if(S(`tengu_bridge_heartbeat_mode_exited`,{reason:a,heartbeat_cycles:i,active_sessions:x.size}),a===`poll_due`&&p(`[bridge:poll] Heartbeat poll_due after ${i} cycles — falling through to pollForWork`),r===`auth_failed`||r===`fatal`){let t=N.signal();await k(e>0?e:f.non_exclusive_heartbeat_interval_ms,t.signal),t.cleanup()}}else if(e>0){let t=N.signal();await k(e,t.signal),t.cleanup()}}else await k(x.size>0?f.multisession_poll_interval_ms_partial_capacity:f.multisession_poll_interval_ms_not_at_capacity,y);continue}let _=x.size>=t.maxSessions;if(A.has(g.id)){if(p(`[bridge:work] Skipping already-completed workId=${g.id}`),_){let e=N.signal();f.non_exclusive_heartbeat_interval_ms>0?(await L(),await k(f.non_exclusive_heartbeat_interval_ms,e.signal)):f.multisession_poll_interval_ms_at_capacity>0&&await k(f.multisession_poll_interval_ms_at_capacity,e.signal),e.cleanup()}else await k(1e3,y);continue}let P;try{P=se(g.secret)}catch(e){let t=u(e);if(d.logError(`Failed to decode work secret for workId=${g.id}: ${t}`),S(`tengu_bridge_work_secret_failed`,{}),A.add(g.id),G(Me(c,r,g.id,d,m.stopWorkBaseDelayMs)),_){let e=N.signal();f.non_exclusive_heartbeat_interval_ms>0?(await L(),await k(f.non_exclusive_heartbeat_interval_ms,e.signal)):f.multisession_poll_interval_ms_at_capacity>0&&await k(f.multisession_poll_interval_ms_at_capacity,e.signal),e.cleanup()}continue}let R=async()=>{p(`[bridge:work] Acknowledging workId=${g.id}`);try{await c.acknowledgeWork(r,g.id,P.session_ingress_token)}catch(e){p(`[bridge:work] Acknowledge failed workId=${g.id}: ${u(e)}`)}},z=g.data.type;switch(g.data.type){case`healthcheck`:await R(),p(`[bridge:work] Healthcheck received`),d.logVerbose(`Healthcheck received`);break;case`session`:{let s=g.data.id;I(`work received: type=session sessionId=${s} workId=${g.id}`);try{ne(s,`session_id`)}catch{await R(),d.logError(`Invalid session_id received: ${s}`);break}let f=x.get(s);if(f){f.updateAccessToken(P.session_ingress_token),D.set(s,P.session_ingress_token),T.set(s,g.id),V?.schedule(s,P.session_ingress_token),p(`[bridge:work] Updated access token for existing sessionId=${s} workId=${g.id}`),await R();break}if(x.size>=t.maxSessions){p(`[bridge:work] At capacity (${x.size}/${t.maxSessions}), cannot spawn new session for workId=${g.id}`);break}await R();let _=Date.now(),w,N=!1,F;if(P.use_code_sessions===!0||e(process.env.CLAUDE_BRIDGE_USE_CCR_V2)){w=ce(t.apiBaseUrl,s);for(let e=1;e<=2;e++)try{F=await ae(w,P.session_ingress_token),N=!0,p(`[bridge:session] CCR v2: registered worker sessionId=${s} epoch=${F} attempt=${e}`);break}catch(t){let n=u(t);if(e<2){if(p(`[bridge:session] CCR v2: registerWorker attempt ${e} failed, retrying: ${n}`),await k(2e3,y),y.aborted)break;continue}d.logError(`CCR v2 worker registration failed for session ${s}: ${n}`),b(Error(`registerWorker failed: ${n}`)),A.add(g.id),G(Me(c,r,g.id,d,m.stopWorkBaseDelayMs))}if(!N)break}else w=oe(t.sessionIngressUrl,s);let L=t.spawnMode,z=t.dir,B=0;if(L===`worktree`&&(h===void 0||!ie(s,h))){let e=Date.now();try{let t=await a(`bridge-${he(s)}`);B=Date.now()-e,j.set(s,{worktreePath:t.worktreePath,worktreeBranch:t.worktreeBranch,gitRoot:t.gitRoot,hookBased:t.hookBased}),z=t.worktreePath,p(`[bridge:session] Created worktree for sessionId=${s} at ${t.worktreePath}`)}catch(e){let t=u(e);d.logError(`Failed to create worktree for session ${s}: ${t}`),b(Error(`Worktree creation failed: ${t}`)),A.add(g.id),G(Me(c,r,g.id,d,m.stopWorkBaseDelayMs));break}}p(`[bridge:session] Spawning sessionId=${s} sdkUrl=${w}`);let H=ee(s);I(`spawning session: sessionId=${s} sdkUrl=${w} useCcrV2=${N} workerEpoch=${F} dir=${z} accessToken=${P.session_ingress_token?P.session_ingress_token.slice(0,8)+`...`:`NONE`}`);let se=Te(l,{sessionId:s,sdkUrl:w,accessToken:P.session_ingress_token,useCcrV2:N,workerEpoch:F,onFirstUserMessage:e=>{if(M.has(H))return;M.add(H);let n=Fe(e);d.setSessionTitle(H,n),p(`[bridge:title] derived title for ${H}: ${n}`),import(`./createSession-VTqzWAu6.js`).then(({updateBridgeSessionTitle:e})=>e(H,n,{baseUrl:t.apiBaseUrl})).catch(e=>p(`[bridge:title] failed to update title for ${H}: ${e}`,{level:`error`}))}},z);if(typeof se==`string`){d.logError(`Failed to spawn session ${s}: ${se}`);let e=j.get(s);e&&(j.delete(s),G(o(e.worktreePath,e.worktreeBranch,e.gitRoot,e.hookBased).catch(t=>d.logVerbose(`Failed to remove worktree ${e.worktreePath}: ${u(t)}`)))),A.add(g.id),G(Me(c,r,g.id,d,m.stopWorkBaseDelayMs));break}let U=se,le=Date.now()-_;S(`tengu_bridge_session_started`,{active_sessions:x.size,spawn_mode:L,in_worktree:j.has(s),spawn_duration_ms:le,worktree_create_ms:B,inProtectedNamespace:n()}),v(`info`,`bridge_session_started`,{spawn_mode:L,in_worktree:j.has(s),spawn_duration_ms:le,worktree_create_ms:B}),x.set(s,U),T.set(s,g.id),D.set(s,P.session_ingress_token),E.set(s,H);let W=Date.now();C.set(s,W),d.logSessionStart(s,`Session ${s}`);let K=he(s),q;if(t.debugFile){let e=t.debugFile.lastIndexOf(`.`);q=e>0?`${t.debugFile.slice(0,e)}-${K}${t.debugFile.slice(e)}`:`${t.debugFile}-${K}`}else t.verbose&&(q=de(ue(),`claude`,`bridge-session-${K}.log`));q&&d.logVerbose(`Debug log: ${q}`),d.addSession(H,i(H,t.sessionIngressUrl)),Q(),d.setAttached(H),Ie(H,t.apiBaseUrl).then(e=>{e&&x.has(s)&&(M.add(H),d.setSessionTitle(H,e),p(`[bridge:title] server title for ${H}: ${e}`))}).catch(e=>p(`[bridge:title] failed to fetch title for ${H}: ${e}`,{level:`error`}));let J=t.sessionTimeoutMs??864e5;if(J>0){let e=setTimeout(Ne,J,s,J,d,te,U);O.set(s,e)}N&&re.add(s),V?.schedule(s,P.session_ingress_token),U.done.then(me(s,W,U));break}default:await R(),p(`[bridge:work] Unknown work type: ${z}, skipping`);break}if(_){let e=N.signal();f.non_exclusive_heartbeat_interval_ms>0?(await L(),await k(f.non_exclusive_heartbeat_interval_ms,e.signal)):f.multisession_poll_interval_ms_at_capacity>0&&await k(f.multisession_poll_interval_ms_at_capacity,e.signal),e.cleanup()}}catch(e){if(y.aborted)break;if(e instanceof B){z(e.errorType)?d.logStatus(e.message):R(e)?p(`[bridge:work] Suppressed 403 error: ${e.message}`):(d.logError(e.message),b(e)),S(`tengu_bridge_fatal_error`,{status:e.status,error_type:e.errorType}),v(z(e.errorType)?`info`:`error`,`bridge_fatal_error`,{status:e.status,error_type:e.errorType});break}let t=P(e);if(I(`poll error: ${t} isConn=${Oe(e)} isServer=${ke(e)} activeSessions=${x.size}`),Oe(e)||ke(e)){let e=Date.now();X!==null&&e-X>Ce(m)&&(p(`[bridge:work] Detected system sleep (${Math.round((e-X)/1e3)}s gap), resetting error budget`),v(`info`,`bridge_poll_sleep_detected`,{gapMs:e-X}),J=null,K=0,Y=null,q=0),X=e,J||(J=e);let n=e-J;if(n>=m.connGiveUpMs){d.logError(`Server unreachable for ${Math.round(n/6e4)} minutes, giving up.`),S(`tengu_bridge_poll_give_up`,{error_type:`connection`,elapsed_ms:n}),v(`error`,`bridge_poll_give_up`,{error_type:`connection`,elapsed_ms:n});break}Y=null,q=0,K=K?Math.min(K*2,m.connCapMs):m.connInitialMs;let r=Ae(K);d.logVerbose(`Connection error, retrying in ${je(r)} (${Math.round(n/1e3)}s elapsed): ${t}`),d.updateReconnectingStatus(je(r),w(n)),F().non_exclusive_heartbeat_interval_ms>0&&await L(),await k(r,y)}else{let e=Date.now();X!==null&&e-X>Ce(m)&&(p(`[bridge:work] Detected system sleep (${Math.round((e-X)/1e3)}s gap), resetting error budget`),v(`info`,`bridge_poll_sleep_detected`,{gapMs:e-X}),J=null,K=0,Y=null,q=0),X=e,Y||(Y=e);let n=e-Y;if(n>=m.generalGiveUpMs){d.logError(`Persistent errors for ${Math.round(n/6e4)} minutes, giving up.`),S(`tengu_bridge_poll_give_up`,{error_type:`general`,elapsed_ms:n}),v(`error`,`bridge_poll_give_up`,{error_type:`general`,elapsed_ms:n});break}J=null,K=0,q=q?Math.min(q*2,m.generalCapMs):m.generalInitialMs;let r=Ae(q);d.logVerbose(`Poll failed, retrying in ${je(r)} (${Math.round(n/1e3)}s elapsed): ${t}`),d.updateReconnectingStatus(je(r),w(n)),F().non_exclusive_heartbeat_interval_ms>0&&await L(),await k(r,y)}}}pe(),d.clearStatus();let ge=Date.now()-U;S(`tengu_bridge_shutdown`,{active_sessions:x.size,loop_duration_ms:ge}),v(`info`,`bridge_shutdown`,{active_sessions:x.size,loop_duration_ms:ge});let $=new Set(x.keys());h&&$.add(h);let _e=new Map(E);if(x.size>0){p(`[bridge:shutdown] Shutting down ${x.size} active session(s)`),d.logStatus(`Shutting down ${x.size} active session(s)\u2026`);let e=new Map(T);for(let[e,t]of x.entries())p(`[bridge:shutdown] Sending SIGTERM to sessionId=${e}`),t.kill();let t=new AbortController;await Promise.race([Promise.allSettled([...x.values()].map(e=>e.done)),k(m.shutdownGraceMs??3e4,t.signal)]),t.abort();for(let[e,t]of x.entries())p(`[bridge:shutdown] Force-killing stuck sessionId=${e}`),t.forceKill();for(let e of O.values())clearTimeout(e);if(O.clear(),V?.cancelAll(),j.size>0){let e=[...j.values()];j.clear(),p(`[bridge:shutdown] Cleaning up ${e.length} worktree(s)`),await Promise.allSettled(e.map(e=>o(e.worktreePath,e.worktreeBranch,e.gitRoot,e.hookBased)))}await Promise.allSettled([...e.entries()].map(([e,t])=>c.stopWork(r,t,!0).catch(n=>d.logVerbose(`Failed to stop work ${t} for session ${e}: ${u(n)}`))))}W.size>0&&await Promise.allSettled([...W]),$.size>0&&(p(`[bridge:shutdown] Archiving ${$.size} session(s)`),await Promise.allSettled([...$].map(e=>c.archiveSession(_e.get(e)??ee(e)).catch(t=>d.logVerbose(`Failed to archive session ${e}: ${u(t)}`)))));try{await c.deregisterEnvironment(r),p(`[bridge:shutdown] Environment deregistered, bridge offline`),d.logVerbose(`Environment deregistered.`)}catch(e){d.logVerbose(`Failed to deregister environment: ${u(e)}`)}let{clearBridgePointer:ve}=await import(`./bridgePointer-DHWK3LEe.js`);await ve(t.dir),d.logVerbose(`Environment offline.`)}var De=new Set([`ECONNREFUSED`,`ECONNRESET`,`ETIMEDOUT`,`ENETUNREACH`,`EHOSTUNREACH`]);function Oe(e){return!!(e&&typeof e==`object`&&`code`in e&&typeof e.code==`string`&&De.has(e.code))}function ke(e){return!!e&&typeof e==`object`&&`code`in e&&typeof e.code==`string`&&e.code===`ERR_BAD_RESPONSE`}function Ae(e){return Math.max(0,e+e*.25*(2*Math.random()-1))}function je(e){return e>=1e3?`${(e/1e3).toFixed(1)}s`:`${Math.round(e)}ms`}async function Me(e,t,n,r,i=1e3){for(let a=1;a<=3;a++)try{await e.stopWork(t,n,!1),p(`[bridge:work] stopWork succeeded for workId=${n} on attempt ${a}/3`);return}catch(e){if(e instanceof B){R(e)?p(`[bridge:work] Suppressed stopWork 403 for ${n}: ${e.message}`):r.logError(`Failed to stop work ${n}: ${e.message}`),v(`error`,`bridge_stop_work_failed`,{attempts:a,fatal:!0});return}let t=u(e);if(a<3){let e=Ae(i*2**(a-1));r.logVerbose(`Failed to stop work ${n} (attempt ${a}/3), retrying in ${je(e)}: ${t}`),await k(e)}else r.logError(`Failed to stop work ${n} after 3 attempts: ${t}`),v(`error`,`bridge_stop_work_failed`,{attempts:3})}}function Ne(e,t,n,r,i){p(`[bridge:session] sessionId=${e} timed out after ${w(t)}`),S(`tengu_bridge_session_timeout`,{timeout_ms:t}),n.logSessionFailed(e,`Session timed out after ${w(t)}`),r.add(e),i.kill()}var Pe=80;function Fe(e){return C(e.replace(/\s+/g,` `).trim(),Pe)}async function Ie(e,t){let{getBridgeSession:n}=await import(`./createSession-VTqzWAu6.js`);return(await n(e,{baseUrl:t}))?.title||void 0}var Le=class extends Error{constructor(e){super(e),this.name=`BridgeHeadlessPermanentError`}};async function Re(e,t){let{dir:n,log:r}=e;process.chdir(n);let{setOriginalCwd:i,setCwdState:a}=await import(`./state-CsdHk8n-.js`);i(n),a(n);let{enableConfigs:o,checkHasTrustDialogAccepted:s}=await import(`./config-DMKtiMzJ.js`);o();let{initSinks:c}=await import(`./sinks-CgzLmim2.js`);if(c(),!s())throw new Le(`Workspace not trusted: ${n}. Run \`claude\` in that directory first to accept the trust dialog.`);if(!e.getAccessToken())throw Error(V);let{getBridgeBaseUrl:l}=await import(`./bridgeConfig-DywkIo_k.js`),d=l();if(d.startsWith(`http://`)&&!d.includes(`localhost`)&&!d.includes(`127.0.0.1`))throw new Le(`Remote Control base URL uses HTTP. Only HTTPS or localhost HTTP is allowed.`);let f=process.env.CLAUDE_BRIDGE_SESSION_INGRESS_URL||d,{getBranch:p,getRemoteUrl:m,findGitRoot:h}=await import(`./git-Bs1vtuvX.js`),{hasWorktreeCreateHook:g}=await import(`./hooks-D6wtd0Qq.js`);if(e.spawnMode===`worktree`&&!(g()||h(n)!==null))throw new Le(`Worktree mode requires a git repository or WorktreeCreate hooks. Directory ${n} has neither.`);let _=await p(),v=await m(),y=q(),b=Z(),x={dir:n,machineName:y,branch:_,gitRepoUrl:v,maxSessions:e.capacity,spawnMode:e.spawnMode,verbose:!1,sandbox:e.sandbox,bridgeId:b,workerType:`claude_code`,environmentId:Z(),apiBaseUrl:d,sessionIngressUrl:f,sessionTimeoutMs:e.sessionTimeoutMs},S=re({baseUrl:d,getAccessToken:e.getAccessToken,runnerVersion:`0.0.13`,onDebug:r,onAuth401:e.onAuth401,getTrustedDeviceToken:U}),C,w;try{let e=await S.registerBridgeEnvironment(x);C=e.environment_id,w=e.environment_secret}catch(e){throw Error(`Bridge registration failed: ${u(e)}`)}let T=be({execPath:process.execPath,scriptArgs:we(),env:process.env,verbose:!1,sandbox:e.sandbox,permissionMode:e.permissionMode,onDebug:r}),E=ze(r);E.printBanner(x,C);let D;if(e.createSessionOnStart){let{createBridgeSession:n}=await import(`./createSession-VTqzWAu6.js`);try{let i=await n({environmentId:C,title:e.name,events:[],gitRepoUrl:v,branch:_,signal:t,baseUrl:d,getAccessToken:e.getAccessToken,permissionMode:e.permissionMode});i&&(D=i,r(`created initial session ${i}`))}catch(e){r(`session pre-creation failed (non-fatal): ${u(e)}`)}}await Ee(x,C,w,S,T,E,t,void 0,D,async()=>e.getAccessToken())}function ze(e){let t=()=>{};return{printBanner:(t,n)=>e(`registered environmentId=${n} dir=${t.dir} spawnMode=${t.spawnMode} capacity=${t.maxSessions}`),logSessionStart:(t,n)=>e(`session start ${t}`),logSessionComplete:(t,n)=>e(`session complete ${t} (${n}ms)`),logSessionFailed:(t,n)=>e(`session failed ${t}: ${n}`),logStatus:e,logVerbose:e,logError:t=>e(`error: ${t}`),logReconnected:t=>e(`reconnected after ${t}ms`),addSession:(t,n)=>e(`session attached ${t}`),removeSession:t=>e(`session detached ${t}`),updateIdleStatus:t,updateReconnectingStatus:t,updateSessionStatus:t,updateSessionActivity:t,updateSessionCount:t,updateFailedStatus:t,setSpawnModeDisplay:t,setRepoInfo:t,setDebugLogPath:t,setAttached:t,setSessionTitle:t,clearStatus:t,toggleQr:t,refreshDisplay:t}}E(),d();var Be=78,Ve=1;async function He(e){if(!e){console.error(`Error: --daemon-worker requires a worker kind`),process.exitCode=Be;return}switch(e){case`remoteControl`:await Ue();break;default:console.error(`Error: unknown daemon worker kind '${e}'`),process.exitCode=Be}}async function Ue(){let e=process.env.DAEMON_WORKER_DIR||Y(`.`),t=process.env.DAEMON_WORKER_NAME||void 0,n=process.env.DAEMON_WORKER_SPAWN_MODE||`same-dir`,r=parseInt(process.env.DAEMON_WORKER_CAPACITY||`4`,10),i=process.env.DAEMON_WORKER_PERMISSION||void 0,a=process.env.DAEMON_WORKER_SANDBOX===`1`,o=process.env.DAEMON_WORKER_TIMEOUT_MS?parseInt(process.env.DAEMON_WORKER_TIMEOUT_MS,10):void 0,s=process.env.DAEMON_WORKER_CREATE_SESSION!==`0`,c=new AbortController,l=()=>c.abort();process.on(`SIGTERM`,l),process.on(`SIGINT`,l);let d={dir:e,name:t,spawnMode:n,capacity:r,permissionMode:i,sandbox:a,sessionTimeoutMs:o,createSessionOnStart:s,getAccessToken:()=>D()?.accessToken,onAuth401:async e=>!!D()?.accessToken,log:e=>{console.log(`[remoteControl] ${e}`)}};try{await Re(d,c.signal)}catch(e){e instanceof Le?(console.error(`[remoteControl] permanent error: ${e.message}`),process.exitCode=Be):(console.error(`[remoteControl] transient error: ${u(e)}`),process.exitCode=Ve)}finally{process.off(`SIGTERM`,l),process.off(`SIGINT`,l)}}export{He as runDaemonWorker};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{wt as e,yt as t}from"./loadAgentsDir-mcRW90aq.js";e();export{t as execIntoTmuxWorktree};
|
package/dist/cli.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
|
-
import{l as e,o as t}from"./chunks/envUtils-DcaKZlRU.js";var n=globalThis.performance,r=new Map,i=new Map;function a(){return n.now()}function o(e){return r.set(e,a()),{name:e,entryType:`mark`,startTime:r.get(e),duration:0}}function s(e,t,n){let o,s;if(typeof t==`string`){let e=r.get(t),i=n?r.get(n):a();o=e??a(),s=(i??a())-o}else t&&typeof t==`object`?(o=t.start??0,s=(t.end??a())-o):(o=0,s=a());i.set(e,{name:e,startTime:o,duration:s})}function c(e){return e===`mark`?[...r.entries()].map(([e,t])=>({name:e,entryType:`mark`,startTime:t,duration:0})):e===`measure`?[...i.values()].map(e=>({name:e.name,entryType:`measure`,startTime:e.startTime,duration:e.duration})):[]}function l(e,t){return c(t??`mark`).concat(t===void 0?c(`measure`):[]).filter(t=>t.name===e)}function u(e){e===void 0?r.clear():r.delete(e)}function d(e){e===void 0?i.clear():i.delete(e)}var f={now:a,mark:o,measure:s,getEntriesByType:c,getEntriesByName:l,clearMarks:u,clearMeasures:d,clearResourceTimings:(()=>{}),setResourceTimingBufferSize:(()=>{}),markResourceTiming:(()=>{}),get timeOrigin(){return n.timeOrigin},get onresourcetimingbufferfull(){return n.onresourcetimingbufferfull},set onresourcetimingbufferfull(e){},toJSON(){return n.toJSON()}};function p(){globalThis.__performanceShimInstalled||(globalThis.__performanceShimInstalled=!0,globalThis.performance=f)}if(p(),t(),globalThis.MACRO===void 0&&(globalThis.MACRO={VERSION:process.env.CLAUDE_CODE_VERSION||`2.1.888`,BUILD_TIME:new Date().toISOString(),FEEDBACK_CHANNEL:``,ISSUES_EXPLAINER:``,NATIVE_PACKAGE_URL:``,PACKAGE_URL:``,VERSION_CHANGELOG:``}),e(process.env.CLAUDE_CODE_FORCE_INTERACTIVE)){for(let e of[process.stdin,process.stdout,process.stderr])if(!e.isTTY)try{Object.defineProperty(e,"isTTY",{value:!0,configurable:!0})}catch{}}if(process.env.COREPACK_ENABLE_AUTO_PIN=`0`,process.env.CLAUDE_CODE_REMOTE===`true`){let e=process.env.NODE_OPTIONS||``;process.env.NODE_OPTIONS=e?`${e} --max-old-space-size=8192`:`--max-old-space-size=8192`}async function m(){let e=process.argv.slice(2);if(e.length===1&&(e[0]===`--version`||e[0]===`-v`||e[0]===`-V`)){console.log(`0.0.
|
|
2
|
+
import{l as e,o as t}from"./chunks/envUtils-DcaKZlRU.js";var n=globalThis.performance,r=new Map,i=new Map;function a(){return n.now()}function o(e){return r.set(e,a()),{name:e,entryType:`mark`,startTime:r.get(e),duration:0}}function s(e,t,n){let o,s;if(typeof t==`string`){let e=r.get(t),i=n?r.get(n):a();o=e??a(),s=(i??a())-o}else t&&typeof t==`object`?(o=t.start??0,s=(t.end??a())-o):(o=0,s=a());i.set(e,{name:e,startTime:o,duration:s})}function c(e){return e===`mark`?[...r.entries()].map(([e,t])=>({name:e,entryType:`mark`,startTime:t,duration:0})):e===`measure`?[...i.values()].map(e=>({name:e.name,entryType:`measure`,startTime:e.startTime,duration:e.duration})):[]}function l(e,t){return c(t??`mark`).concat(t===void 0?c(`measure`):[]).filter(t=>t.name===e)}function u(e){e===void 0?r.clear():r.delete(e)}function d(e){e===void 0?i.clear():i.delete(e)}var f={now:a,mark:o,measure:s,getEntriesByType:c,getEntriesByName:l,clearMarks:u,clearMeasures:d,clearResourceTimings:(()=>{}),setResourceTimingBufferSize:(()=>{}),markResourceTiming:(()=>{}),get timeOrigin(){return n.timeOrigin},get onresourcetimingbufferfull(){return n.onresourcetimingbufferfull},set onresourcetimingbufferfull(e){},toJSON(){return n.toJSON()}};function p(){globalThis.__performanceShimInstalled||(globalThis.__performanceShimInstalled=!0,globalThis.performance=f)}if(p(),t(),globalThis.MACRO===void 0&&(globalThis.MACRO={VERSION:process.env.CLAUDE_CODE_VERSION||`2.1.888`,BUILD_TIME:new Date().toISOString(),FEEDBACK_CHANNEL:``,ISSUES_EXPLAINER:``,NATIVE_PACKAGE_URL:``,PACKAGE_URL:``,VERSION_CHANGELOG:``}),e(process.env.CLAUDE_CODE_FORCE_INTERACTIVE)){for(let e of[process.stdin,process.stdout,process.stderr])if(!e.isTTY)try{Object.defineProperty(e,"isTTY",{value:!0,configurable:!0})}catch{}}if(process.env.COREPACK_ENABLE_AUTO_PIN=`0`,process.env.CLAUDE_CODE_REMOTE===`true`){let e=process.env.NODE_OPTIONS||``;process.env.NODE_OPTIONS=e?`${e} --max-old-space-size=8192`:`--max-old-space-size=8192`}async function m(){let e=process.argv.slice(2);if(e.length===1&&(e[0]===`--version`||e[0]===`-v`||e[0]===`-V`)){console.log(`0.0.13 (Work Mate)`);return}let{profileCheckpoint:t}=await import(`./chunks/startupProfiler-CUlV07MD.js`);if(t(`cli_entry`),process.argv[2]===`--acp`){t(`cli_acp_path`);let{runAcpAgent:e}=await import(`./chunks/entry-DCbq734V.js`);await e();return}if(e[0]===`--daemon-worker`||e[0]?.startsWith(`--daemon-worker=`)){let t=e[0]===`--daemon-worker`?e[1]:e[0].split(`=`)[1],{runDaemonWorker:n}=await import(`./chunks/workerRegistry-BA37PVbv.js`);await n(t);return}if(e[0]===`daemon`){t(`cli_daemon_path`);let{enableConfigs:n}=await import(`./chunks/config-DMKtiMzJ.js`);n();let{setShellIfWindows:r}=await import(`./chunks/windowsPaths-B8p9tFRF.js`);r();let{initSinks:i}=await import(`./chunks/sinks-CgzLmim2.js`);i();let{daemonMain:a}=await import(`./chunks/main-CGLCy2pM.js`);await a(e.slice(1));return}if(e.includes(`--bg`)||e.includes(`--background`)){t(`cli_daemon_path`);let{enableConfigs:n}=await import(`./chunks/config-DMKtiMzJ.js`);n();let{setShellIfWindows:r}=await import(`./chunks/windowsPaths-B8p9tFRF.js`);r(),await(await import(`./chunks/bg-Ci7pG4eo.js`)).handleBgStart(e.filter(e=>e!==`--bg`&&e!==`--background`));return}if(e[0]===`ps`||e[0]===`logs`||e[0]===`attach`||e[0]===`kill`){let n=e[0]===`ps`?`status`:e[0];console.error(`[deprecated] Use: claude daemon ${n}${e[1]?` `+e[1]:``}`),t(`cli_daemon_path`);let{enableConfigs:r}=await import(`./chunks/config-DMKtiMzJ.js`);r();let{setShellIfWindows:i}=await import(`./chunks/windowsPaths-B8p9tFRF.js`);i();let{initSinks:a}=await import(`./chunks/sinks-CgzLmim2.js`);a();let{daemonMain:o}=await import(`./chunks/main-CGLCy2pM.js`);await o([e[0]===`ps`?`status`:e[0],...e.slice(1)]);return}if(e[0]===`job`){t(`cli_templates_path`);let{templatesMain:n}=await import(`./chunks/templateJobs-BYYfF4m5.js`);await n(e.slice(1)),process.exit(0)}if(e[0]===`new`||e[0]===`list`||e[0]===`reply`){console.error(`[deprecated] Use: claude job ${e[0]} ${e.slice(1).join(` `)}`.trim()),t(`cli_templates_path`);let{templatesMain:n}=await import(`./chunks/templateJobs-BYYfF4m5.js`);await n(e),process.exit(0)}if((e.includes(`--tmux`)||e.includes(`--tmux=classic`))&&(e.includes(`-w`)||e.includes(`--worktree`)||e.some(e=>e.startsWith(`--worktree=`)))){t(`cli_tmux_worktree_fast_path`);let{enableConfigs:n}=await import(`./chunks/config-DMKtiMzJ.js`);n();let{isWorktreeModeEnabled:r}=await import(`./chunks/worktreeModeEnabled-D68iEHpC.js`);if(r()){let{execIntoTmuxWorktree:t}=await import(`./chunks/worktree-Lik8xuKd.js`),n=await t(e);if(n.handled)return;if(n.error){let{exitWithError:e}=await import(`./chunks/process-CNfq37LF.js`);e(n.error)}}}e.length===1&&(e[0]===`--update`||e[0]===`--upgrade`)&&(process.argv=[process.argv[0],process.argv[1],`update`]),e.includes(`--bare`)&&(process.env.CLAUDE_CODE_SIMPLE=`1`);let{startCapturingEarlyInput:n}=await import(`./chunks/earlyInput-BEjRkAtH.js`);n(),t(`cli_before_main_import`);let{main:r}=await import(`./chunks/main-DUjtDK1Q.js`);t(`cli_after_main_import`),await r(),t(`cli_after_main_complete`)}await m();export{};
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e,t}from"./AgentsMdExternalIncludesDialog-_yJJ0wqu.js";e();export{t as AgentsMdExternalIncludesDialog};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./rolldown-runtime-DaDcL9Zw.js";import{ag as e,og as t}from"./loadAgentsDir-BXtV2jiO.js";import{R as n,fi as r,t as i}from"./src-P_wYS_NJ2.js";import{t as a}from"./jsx-runtime-Bb4Xn-E0.js";import{c as o,h as s,y as c}from"./config-9rLTDOYW.js";import{n as l}from"./onChangeAppState-WbvtqDtk.js";import{t as u}from"./fpsMetrics-DffAomdg.js";import{t as d}from"./stats-BkadEKa-.js";r(),t(),i(),s();var f=a();function p({getFpsMetrics:t,stats:r,initialState:i,children:a}){return(0,f.jsx)(u,{getFpsMetrics:t,children:(0,f.jsx)(d,{store:r,children:(0,f.jsx)(e,{initialState:i,onChangeAppState:l,children:(0,f.jsx)(n,{initialState:o().theme,onThemeSave:e=>c(t=>({...t,theme:e})),children:a})})})})}export{p as App};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./rolldown-runtime-DaDcL9Zw.js";import{Xu as e,Zu as t}from"./loadAgentsDir-BXtV2jiO.js";import{P as n,fi as r,t as i,y as a}from"./src-P_wYS_NJ2.js";import{t as o}from"./jsx-runtime-Bb4Xn-E0.js";import{h as s,y as c}from"./config-9rLTDOYW.js";r(),i(),s(),e();var l=o();function u({customApiKeyTruncated:e,onDone:r}){function i(t){switch(t){case`yes`:c(t=>({...t,customApiKeyResponses:{...t.customApiKeyResponses,approved:[...t.customApiKeyResponses?.approved??[],e]}})),r(!0);break;case`no`:c(t=>({...t,customApiKeyResponses:{...t.customApiKeyResponses,rejected:[...t.customApiKeyResponses?.rejected??[],e]}})),r(!1);break}}return(0,l.jsxs)(a,{title:`Detected a custom API key in your environment`,color:`warning`,onCancel:()=>i(`no`),children:[(0,l.jsxs)(n,{children:[(0,l.jsx)(n,{bold:!0,children:`ANTHROPIC_API_KEY`}),(0,l.jsxs)(n,{children:[`: sk-ant-...`,e]})]}),(0,l.jsx)(n,{children:`Do you want to use this API key?`}),(0,l.jsx)(t,{defaultValue:`no`,defaultFocusValue:`no`,options:[{label:`Yes`,value:`yes`},{label:(0,l.jsxs)(n,{children:[`No (`,(0,l.jsx)(n,{bold:!0,children:`recommended`}),`)`]}),value:`no`}],onChange:e=>i(e),onCancel:()=>i(`no`)})]})}export{u as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./ApproveApiKey-C8LwmDM2.js";export{e as ApproveApiKey};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as e,n as t,o as n}from"./rolldown-runtime-DaDcL9Zw.js";import{n as r,t as i}from"./figures-5ThXQEtq.js";import{AC as a,Ba as o,Bf as s,Bg as c,Bs as l,Da as u,IC as d,If as f,Ja as p,Lg as ee,MC as m,Pf as h,Qu as g,Vf as _,Zu as v,bS as te,cu as y,dp as b,el as ne,eu as re,fu as ie,gp as ae,hf as oe,hp as se,id as ce,ig as x,iu as S,jC as C,jn as le,kn as ue,lg as de,mf as fe,nu as pe,og as me,ra as he,rg as ge,ru as _e,sg as ve,td as ye,tl as be,tu as xe,up as Se,xS as Ce,zs as we}from"./loadAgentsDir-BXtV2jiO.js";import{D as w,Gt as T,H as Te,I as E,Lt as Ee,P as D,T as O,fi as k,mt as De,ot as Oe,t as A,y as j}from"./src-P_wYS_NJ2.js";import{t as M}from"./jsx-runtime-Bb4Xn-E0.js";import{P as ke,R as Ae,_ as je,f as Me}from"./debug-Dr1SjdXn.js";import{Ln as N,Rn as Ne,Wt as P,zn as Pe}from"./settings-DiBMs2gM.js";import{C as Fe,b as F,f as Ie,l as Le,u as Re,v as I}from"./startupProfiler-Dc5r6LgE.js";import{l as L,o as ze}from"./stringUtils-Df-Lnjxd.js";import{bn as Be,jt as Ve,vn as He,yn as Ue}from"./prompt-CRc2QEZ5.js";import{i as We,n as Ge}from"./mappers-IuJeXgvr.js";function R(e,t,n=1e3,r=0,i){let a=()=>Le(Math.max(0,(i??Date.now())-e-r));return(0,Ke.useSyncExternalStore)((0,Ke.useCallback)(e=>{if(!t)return()=>{};let r=setInterval(e,n);return()=>clearInterval(r)},[t,n]),a,a)}var Ke,z=t((()=>{Ke=n(k(),1),I()}));function qe(e,t,n){let r=He(t,e.toolName);if(!r)return e.toolName;try{let t=r.inputSchema.safeParse(e.input),i=t.success?t.data:{},a=r.userFacingName(i);if(!a)return e.toolName;let o=r.renderToolUseMessage(i,{theme:n,verbose:!1});return o?(0,Je.jsxs)(D,{children:[a,`(`,o,`)`]}):a}catch{return e.toolName}}var Je,Ye=t((()=>{k(),A(),Be(),Je=M()}));function Xe(e,t){let{isIdle:n,awaitingApproval:r,hasError:a,shutdownRequested:o}=t??{};return a?i.cross:r?i.questionMarkPrefix:o?i.warning:e===`running`?n?i.ellipsis:i.play:e===`completed`?i.tick:e===`failed`||e===`killed`?i.cross:i.bullet}function Ze(e,t){let{isIdle:n,awaitingApproval:r,hasError:i,shutdownRequested:a}=t??{};return i?`error`:r||a?`warning`:n?`background`:e===`completed`?`success`:e===`failed`?`error`:e===`killed`?`warning`:`background`}function Qe(e,t){if(!t)return!1;let n=!1;for(let t of Object.values(e))if(_(t))return n=!0,!1;return n}var $e=t((()=>{r(),s()}));function et({agent:e,onDone:t,onKillAgent:n,onBack:r}){let[i]=Te(),a=(0,tt.useMemo)(()=>ne(Ue()),[]),o=R(e.startTime,e.status===`running`,1e3,e.totalPausedMs??0);T({"confirm:yes":t},{context:`Confirmation`});let s=i=>{i.key===` `?(i.preventDefault(),t()):i.key===`left`&&r?(i.preventDefault(),r()):i.key===`x`&&e.status===`running`&&n&&(i.preventDefault(),n())},c=u(e.prompt,`plan`),l=e.prompt.length>300?e.prompt.substring(0,297)+`…`:e.prompt,d=e.result?.totalTokens??e.progress?.tokenCount,f=e.result?.totalToolUseCount??e.progress?.toolUseCount;return(0,B.jsx)(E,{flexDirection:`column`,tabIndex:0,autoFocus:!0,onKeyDown:s,children:(0,B.jsx)(j,{title:(0,B.jsxs)(D,{children:[e.selectedAgent?.agentType??`agent`,` › `,e.description||`Async agent`]}),subtitle:(0,B.jsxs)(D,{children:[e.status!==`running`&&(0,B.jsxs)(D,{color:Ze(e.status),children:[Xe(e.status),` `,e.status===`completed`?`Completed`:e.status===`failed`?`Failed`:`Stopped`,` · `]}),(0,B.jsxs)(D,{dimColor:!0,children:[o,d!==void 0&&d>0&&(0,B.jsxs)(B.Fragment,{children:[` · `,Ie(d),` tokens`]}),f!==void 0&&f>0&&(0,B.jsxs)(B.Fragment,{children:[` `,`· `,f,` `,f===1?`tool`:`tools`]})]})]}),onCancel:t,color:`background`,inputGuide:t=>t.pending?(0,B.jsxs)(D,{children:[`Press `,t.keyName,` again to exit`]}):(0,B.jsxs)(O,{children:[r&&(0,B.jsx)(w,{shortcut:`←`,action:`go back`}),(0,B.jsx)(w,{shortcut:`Esc/Enter/Space`,action:`close`}),e.status===`running`&&n&&(0,B.jsx)(w,{shortcut:`x`,action:`stop`})]}),children:(0,B.jsxs)(E,{flexDirection:`column`,children:[e.status===`running`&&e.progress?.recentActivities&&e.progress.recentActivities.length>0&&(0,B.jsxs)(E,{flexDirection:`column`,children:[(0,B.jsx)(D,{bold:!0,dimColor:!0,children:`Progress`}),e.progress.recentActivities.map((t,n)=>(0,B.jsxs)(D,{dimColor:n<e.progress.recentActivities.length-1,wrap:`truncate-end`,children:[n===e.progress.recentActivities.length-1?`› `:` `,qe(t,a,i)]},n))]}),c?(0,B.jsx)(E,{marginTop:1,children:(0,B.jsx)(se,{addMargin:!1,planContent:c})}):(0,B.jsxs)(E,{flexDirection:`column`,marginTop:1,children:[(0,B.jsx)(D,{bold:!0,dimColor:!0,children:`Prompt`}),(0,B.jsx)(D,{wrap:`wrap`,children:l})]}),e.status===`failed`&&e.error&&(0,B.jsxs)(E,{flexDirection:`column`,marginTop:1,children:[(0,B.jsx)(D,{bold:!0,color:`error`,children:`Error`}),(0,B.jsx)(D,{color:`error`,wrap:`wrap`,children:e.error})]})]})})})}var tt,B,nt=t((()=>{tt=n(k(),1),z(),A(),a(),Be(),be(),I(),o(),ae(),Ye(),$e(),B=M()}));function rt(e,t,n,r){if(!e)return`${t} found · ${n} verified`;if(e===`synthesizing`){let e=[`${n} verified`];return r>0&&e.push(`${r} refuted`),e.push(`deduping`),e.join(` · `)}if(e===`verifying`){let e=[`${t} found`,`${n} verified`];return r>0&&e.push(`${r} refuted`),e.join(` · `)}return t>0?`${t} found`:`finding`}function it({text:e,phase:t=0}){return(0,V.jsx)(V.Fragment,{children:[...e].map((e,n)=>(0,V.jsx)(D,{color:Se(n+t),children:e},n))})}function at(e,t,n){let r=(0,ct.useRef)(e),i=(0,ct.useRef)(t);return n||e<r.current?r.current=e:e>r.current&&t!==i.current&&(r.current+=1,i.current=t),r.current}function ot({session:e}){let t=x().prefersReducedMotion??!1,n=e.reviewProgress,r=e.status===`running`,[,i]=De(r&&!t?lt:null),a=n?.bugsFound??0,o=n?.bugsVerified??0,s=n?.bugsRefuted??0,c=t||!r,l=at(a,i,c),u=at(o,i,c),d=at(s,i,c),f=Math.floor(i/(lt*3))%7;if(e.status===`completed`)return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(D,{color:`background`,children:[`◆`,` `]}),(0,V.jsx)(it,{text:`ultrareview`,phase:0}),(0,V.jsx)(D,{dimColor:!0,children:` ready · shift+↓ to view`})]});if(e.status===`failed`)return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(D,{color:`background`,children:[`◆`,` `]}),(0,V.jsx)(it,{text:`ultrareview`,phase:0}),(0,V.jsxs)(D,{color:`error`,dimColor:!0,children:[` · `,`error`]})]});let p=n?rt(n.stage,l,u,d):`setting up`;return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(D,{color:`background`,children:[`◇`,` `]}),(0,V.jsx)(it,{text:`ultrareview`,phase:r?f:0}),(0,V.jsxs)(D,{dimColor:!0,children:[` · `,p]})]})}function st({session:e}){if(e.isRemoteReview)return(0,V.jsx)(ot,{session:e});if(e.status===`completed`)return(0,V.jsx)(D,{bold:!0,color:`success`,dimColor:!0,children:`done`});if(e.status===`failed`)return(0,V.jsx)(D,{bold:!0,color:`error`,dimColor:!0,children:`error`});if(!e.todoList.length)return(0,V.jsxs)(D,{dimColor:!0,children:[e.status,`…`]});let t=N(e.todoList,e=>e.status===`completed`),n=e.todoList.length;return(0,V.jsxs)(D,{dimColor:!0,children:[t,`/`,n]})}var ct,V,lt,ut=t((()=>{ct=n(k(),1),P(),ge(),A(),Ne(),b(),V=M(),lt=80}));function H({status:e,label:t,suffix:n}){return(0,U.jsxs)(D,{color:e===`completed`?`success`:e===`failed`?`error`:e===`killed`?`warning`:void 0,dimColor:!0,children:[`(`,t??e,n,`)`]})}function dt({shell:e}){switch(e.status){case`completed`:return(0,U.jsx)(H,{status:`completed`,label:`done`});case`failed`:return(0,U.jsx)(H,{status:`failed`,label:`error`});case`killed`:return(0,U.jsx)(H,{status:`killed`,label:`stopped`});case`running`:case`pending`:return(0,U.jsx)(H,{status:`running`})}}var U,ft=t((()=>{A(),U=M()}));function pt({task:e,maxActivityWidth:t}){let n=t??40;switch(e.type){case`local_bash`:return(0,W.jsxs)(D,{children:[F(e.command,n,!0),` `,(0,W.jsx)(dt,{shell:e})]});case`remote_agent`:return e.isRemoteReview?(0,W.jsx)(D,{children:(0,W.jsx)(st,{session:e})}):(0,W.jsxs)(D,{children:[(0,W.jsxs)(D,{dimColor:!0,children:[e.status===`running`||e.status===`pending`?`◇`:`◆`,` `]}),F(e.title,n,!0),(0,W.jsx)(D,{dimColor:!0,children:` · `}),(0,W.jsx)(st,{session:e})]});case`local_agent`:return(0,W.jsxs)(D,{children:[F(e.description,n,!0),` `,(0,W.jsx)(H,{status:e.status,label:e.status===`completed`?`done`:void 0,suffix:e.status===`completed`&&!e.notified?`, unread`:void 0})]});case`local_workflow`:{let t=e;return(0,W.jsxs)(D,{children:[F(t.workflowName??e.summary??e.description,n,!0),` `,(0,W.jsx)(H,{status:e.status,label:e.status===`running`?`${t.agentCount} ${L(t.agentCount,`agent`)}`:e.status===`completed`?`done`:void 0,suffix:e.status===`completed`&&!e.notified?`, unread`:void 0})]})}case`dream`:{let t=e.filesTouched.length,n=e.phase===`updating`&&t>0?`${t} ${L(t,`file`)}`:`${e.sessionsReviewing} ${L(e.sessionsReviewing,`session`)}`;return(0,W.jsxs)(D,{children:[e.description,` `,(0,W.jsxs)(D,{dimColor:!0,children:[`· `,e.phase,` · `,n]}),` `,(0,W.jsx)(H,{status:e.status,label:e.status===`completed`?`done`:void 0,suffix:e.status===`completed`&&!e.notified?`, unread`:void 0})]})}}}var W,mt=t((()=>{k(),A(),I(),ze(),P(),ut(),ft(),W=M()}));function ht({task:e,onDone:t,onBack:n,onKill:r}){let i=R(e.startTime,e.status===`running`,1e3,0);T({"confirm:yes":t},{context:`Confirmation`});let a=i=>{i.key===` `?(i.preventDefault(),t()):i.key===`left`&&n?(i.preventDefault(),n()):i.key===`x`&&e.status===`running`&&r&&(i.preventDefault(),r())},o=e.turns.filter(e=>e.text!==``),s=o.slice(-6),c=o.length-s.length;return(0,G.jsx)(E,{flexDirection:`column`,tabIndex:0,autoFocus:!0,onKeyDown:a,children:(0,G.jsx)(j,{title:`Memory consolidation`,subtitle:(0,G.jsxs)(D,{dimColor:!0,children:[i,` · reviewing `,e.sessionsReviewing,` `,L(e.sessionsReviewing,`session`),e.filesTouched.length>0&&(0,G.jsxs)(G.Fragment,{children:[` `,`· `,e.filesTouched.length,` `,L(e.filesTouched.length,`file`),` touched`]})]}),onCancel:t,color:`background`,inputGuide:t=>t.pending?(0,G.jsxs)(D,{children:[`Press `,t.keyName,` again to exit`]}):(0,G.jsxs)(O,{children:[n&&(0,G.jsx)(w,{shortcut:`←`,action:`go back`}),(0,G.jsx)(w,{shortcut:`Esc/Enter/Space`,action:`close`}),e.status===`running`&&r&&(0,G.jsx)(w,{shortcut:`x`,action:`stop`})]}),children:(0,G.jsxs)(E,{flexDirection:`column`,gap:1,children:[(0,G.jsxs)(D,{children:[(0,G.jsx)(D,{bold:!0,children:`Status:`}),` `,e.status===`running`?(0,G.jsx)(D,{color:`background`,children:`running`}):e.status===`completed`?(0,G.jsx)(D,{color:`success`,children:e.status}):(0,G.jsx)(D,{color:`error`,children:e.status})]}),s.length===0?(0,G.jsx)(D,{dimColor:!0,children:e.status===`running`?`Starting…`:`(no text output)`}):(0,G.jsxs)(G.Fragment,{children:[c>0&&(0,G.jsxs)(D,{dimColor:!0,children:[`(`,c,` earlier `,L(c,`turn`),`)`]}),s.map((e,t)=>(0,G.jsxs)(E,{flexDirection:`column`,children:[(0,G.jsx)(D,{wrap:`wrap`,children:e.text}),e.toolUseCount>0&&(0,G.jsxs)(D,{dimColor:!0,children:[` `,`(`,e.toolUseCount,` `,L(e.toolUseCount,`tool`),`)`]})]},t))]})]})})})}var G,gt=t((()=>{k(),z(),A(),a(),ze(),G=M()}));function _t({stage:e,completed:t,hasProgress:n}){let r=e?xt.indexOf(e):-1,i=!t&&!n;return(0,q.jsxs)(D,{children:[i?(0,q.jsx)(D,{color:`background`,children:`Setup`}):(0,q.jsx)(D,{dimColor:!0,children:`Setup`}),(0,q.jsx)(D,{dimColor:!0,children:` → `}),xt.map((e,n)=>{let a=!t&&!i&&n===r;return(0,q.jsxs)(K.Fragment,{children:[n>0&&(0,q.jsx)(D,{dimColor:!0,children:` → `}),a?(0,q.jsx)(D,{color:`background`,children:St[e]}):(0,q.jsx)(D,{dimColor:!0,children:St[e]})]},e)}),t&&(0,q.jsx)(D,{color:`success`,children:` ✓`})]})}function vt(e){let t=e.reviewProgress;if(!t)return e.status===`completed`?`done`:`setting up`;let n=t.bugsVerified,r=t.bugsRefuted??0;if(e.status===`completed`){let e=[`${n} ${L(n,`finding`)}`];return r>0&&e.push(`${r} refuted`),e.join(` · `)}return rt(t.stage,t.bugsFound,n,r)}function yt({session:e,onDone:t,onBack:n,onKill:r}){let i=e.status===`completed`,a=e.status===`running`||e.status===`pending`,[o,s]=(0,K.useState)(!1),c=R(e.startTime,a,1e3,0,e.endTime),l=()=>t(`Remote session details dismissed`,{display:`system`}),u=n??l,d=_e(e.sessionId),f=i?`ready`:a?`running`:e.status;if(o)return(0,q.jsx)(j,{title:`Stop ultrareview?`,onCancel:()=>s(!1),color:`background`,children:(0,q.jsxs)(E,{flexDirection:`column`,gap:1,children:[(0,q.jsx)(D,{dimColor:!0,children:`This archives the remote session and stops local tracking. The review will not complete and any findings so far are discarded.`}),(0,q.jsx)(v,{options:[{label:`Stop ultrareview`,value:`stop`},{label:`Back`,value:`back`}],onChange:e=>{e===`stop`?(r?.(),u()):s(!1)}})]})});let p=i?[{label:`Open in Claude Code on the web`,value:`open`},{label:`Dismiss`,value:`dismiss`}]:[{label:`Open in Claude Code on the web`,value:`open`},...r&&a?[{label:`Stop ultrareview`,value:`stop`}]:[],{label:`Back`,value:`back`}];return(0,q.jsx)(j,{title:(0,q.jsxs)(D,{children:[(0,q.jsxs)(D,{color:`background`,children:[i?`◆`:`◇`,` `]}),(0,q.jsx)(D,{bold:!0,children:`ultrareview`}),(0,q.jsxs)(D,{dimColor:!0,children:[` · `,c,` · `,f]})]}),onCancel:u,color:`background`,inputGuide:e=>e.pending?(0,q.jsxs)(D,{children:[`Press `,e.keyName,` again to exit`]}):(0,q.jsxs)(O,{children:[(0,q.jsx)(w,{shortcut:`Enter`,action:`select`}),(0,q.jsx)(w,{shortcut:`Esc`,action:`go back`})]}),children:(0,q.jsxs)(E,{flexDirection:`column`,gap:1,children:[(0,q.jsx)(_t,{stage:e.reviewProgress?.stage,completed:i,hasProgress:!!e.reviewProgress}),(0,q.jsxs)(E,{flexDirection:`column`,children:[(0,q.jsx)(D,{children:vt(e)}),(0,q.jsx)(Ee,{url:d,children:(0,q.jsx)(D,{dimColor:!0,children:d})})]}),(0,q.jsx)(v,{options:p,onChange:e=>{switch(e){case`open`:Ce(d),t();break;case`stop`:s(!0);break;case`back`:u();break;case`dismiss`:l();break}}})]})})}function bt({session:e,toolUseContext:t,onDone:n,onBack:r,onKill:i}){let[a,o]=(0,K.useState)(!1),[s,c]=(0,K.useState)(null),l=(0,K.useMemo)(()=>e.isRemoteReview?[]:p(We(e.log)).filter(e=>e.type!==`progress`).slice(-3),[e]);if(e.isRemoteReview)return(0,q.jsx)(yt,{session:e,onDone:n,onBack:r,onKill:i});let u=()=>n(`Remote session details dismissed`,{display:`system`}),d=e=>{e.key===` `?(e.preventDefault(),n(`Remote session details dismissed`,{display:`system`})):e.key===`left`&&r?(e.preventDefault(),r()):e.key===`t`&&!a?(e.preventDefault(),f()):e.key===`return`&&(e.preventDefault(),u())};async function f(){o(!0),c(null);try{await ie(e.sessionId)}catch(e){c(ke(e))}finally{o(!1)}}let ee=Fe(e.title,50),m=e.status===`pending`?`starting`:e.status;return(0,q.jsx)(E,{flexDirection:`column`,tabIndex:0,autoFocus:!0,onKeyDown:d,children:(0,q.jsxs)(j,{title:`Remote session details`,onCancel:u,color:`background`,inputGuide:e=>e.pending?(0,q.jsxs)(D,{children:[`Press `,e.keyName,` again to exit`]}):(0,q.jsxs)(O,{children:[r&&(0,q.jsx)(w,{shortcut:`←`,action:`go back`}),(0,q.jsx)(w,{shortcut:`Esc/Enter/Space`,action:`close`}),!a&&(0,q.jsx)(w,{shortcut:`t`,action:`teleport`})]}),children:[(0,q.jsxs)(E,{flexDirection:`column`,children:[(0,q.jsxs)(D,{children:[(0,q.jsx)(D,{bold:!0,children:`Status`}),`:`,` `,m===`running`||m===`starting`?(0,q.jsx)(D,{color:`background`,children:m}):m===`completed`?(0,q.jsx)(D,{color:`success`,children:m}):(0,q.jsx)(D,{color:`error`,children:m})]}),(0,q.jsxs)(D,{children:[(0,q.jsx)(D,{bold:!0,children:`Runtime`}),`: `,Le((e.endTime??Date.now())-e.startTime)]}),(0,q.jsxs)(D,{wrap:`truncate-end`,children:[(0,q.jsx)(D,{bold:!0,children:`Title`}),`: `,ee]}),(0,q.jsxs)(D,{children:[(0,q.jsx)(D,{bold:!0,children:`Progress`}),`: `,(0,q.jsx)(st,{session:e})]}),(0,q.jsxs)(D,{children:[(0,q.jsx)(D,{bold:!0,children:`Session URL`}),`:`,` `,(0,q.jsx)(Ee,{url:_e(e.sessionId),children:(0,q.jsx)(D,{dimColor:!0,children:_e(e.sessionId)})})]})]}),e.log.length>0&&(0,q.jsxs)(E,{flexDirection:`column`,marginTop:1,children:[(0,q.jsxs)(D,{children:[(0,q.jsx)(D,{bold:!0,children:`Recent messages`}),`:`]}),(0,q.jsx)(E,{flexDirection:`column`,height:10,overflowY:`hidden`,children:l.map((e,n)=>(0,q.jsx)(h,{message:e,lookups:he,addMargin:n>0,tools:t.options.tools,commands:t.options.commands,verbose:t.options.verbose,inProgressToolUseIDs:new Set,progressMessagesForMessage:[],shouldAnimate:!1,shouldShowDot:!1,style:`condensed`,isTranscriptMode:!1,isStatic:!0},n))}),(0,q.jsx)(E,{marginTop:1,children:(0,q.jsxs)(D,{dimColor:!0,italic:!0,children:[`Showing last `,l.length,` of `,e.log.length,` messages`]})})]}),s&&(0,q.jsx)(E,{marginTop:1,children:(0,q.jsxs)(D,{color:`error`,children:[`Teleport failed: `,s]})}),a&&(0,q.jsx)(D,{color:`background`,children:`Teleporting to session…`})]})})}var K,q,xt,St,Ct=t((()=>{K=n(k(),1),P(),z(),A(),S(),Ve(),te(),Ae(),I(),Ge(),o(),ze(),y(),g(),f(),ut(),q=M(),xt=[`finding`,`verifying`,`synthesizing`],St={finding:`Find`,verifying:`Verify`,synthesizing:`Dedupe`}}));async function wt(e){let t=ue(e.id);try{let e=await je(t,Dt);return{content:e.content,bytesTotal:e.bytesTotal}}catch{return{content:``,bytesTotal:0}}}function Tt({shell:e,onDone:t,onKillShell:n,onBack:r}){let{columns:i}=Oe(),[a,o]=(0,J.useState)(()=>wt(e)),s=(0,J.useDeferredValue)(a);(0,J.useEffect)(()=>{if(e.status!==`running`)return;let t=setInterval((e,t)=>e(wt(t)),1e3,o,e);return()=>clearInterval(t)},[e.id,e.status]);let c=()=>t(`Shell details dismissed`,{display:`system`});T({"confirm:yes":c},{context:`Confirmation`});let l=i=>{i.key===` `?(i.preventDefault(),t(`Shell details dismissed`,{display:`system`})):i.key===`left`&&r?(i.preventDefault(),r()):i.key===`x`&&e.status===`running`&&n&&(i.preventDefault(),n())},u=Fe(e.command,280);return(0,Y.jsx)(E,{flexDirection:`column`,tabIndex:0,autoFocus:!0,onKeyDown:l,children:(0,Y.jsxs)(j,{title:`Shell details`,onCancel:c,color:`background`,inputGuide:t=>t.pending?(0,Y.jsxs)(D,{children:[`Press `,t.keyName,` again to exit`]}):(0,Y.jsxs)(O,{children:[r&&(0,Y.jsx)(w,{shortcut:`←`,action:`go back`}),(0,Y.jsx)(w,{shortcut:`Esc/Enter/Space`,action:`close`}),e.status===`running`&&n&&(0,Y.jsx)(w,{shortcut:`x`,action:`stop`})]}),children:[(0,Y.jsxs)(E,{flexDirection:`column`,children:[(0,Y.jsxs)(D,{children:[(0,Y.jsx)(D,{bold:!0,children:`Status:`}),` `,e.status===`running`?(0,Y.jsxs)(D,{color:`background`,children:[e.status,e.result?.code!==void 0&&` (exit code: ${e.result.code})`]}):e.status===`completed`?(0,Y.jsxs)(D,{color:`success`,children:[e.status,e.result?.code!==void 0&&` (exit code: ${e.result.code})`]}):(0,Y.jsxs)(D,{color:`error`,children:[e.status,e.result?.code!==void 0&&` (exit code: ${e.result.code})`]})]}),(0,Y.jsxs)(D,{children:[(0,Y.jsx)(D,{bold:!0,children:`Runtime:`}),` `,Le((e.endTime??Date.now())-e.startTime)]}),(0,Y.jsxs)(D,{wrap:`wrap`,children:[(0,Y.jsx)(D,{bold:!0,children:`Command:`}),` `,u]})]}),(0,Y.jsxs)(E,{flexDirection:`column`,children:[(0,Y.jsx)(D,{bold:!0,children:`Output:`}),(0,Y.jsx)(J.Suspense,{fallback:(0,Y.jsx)(D,{dimColor:!0,children:`Loading output…`}),children:(0,Y.jsx)(Et,{outputPromise:s,columns:i})})]})]})})}function Et({outputPromise:e,columns:t}){let{content:n,bytesTotal:r}=(0,J.use)(e);if(!n)return(0,Y.jsx)(D,{dimColor:!0,children:`No output available`});let i=[],a=n.length;for(let e=0;e<10&&a>0;e++){let e=n.lastIndexOf(`
|
|
2
|
-
`,a-1);i.push(e+1),a=e}i.reverse();let o=r>n.length,s=[];for(let e=0;e<i.length;e++){let t=i[e],r=e<i.length-1?i[e+1]-1:n.length,a=n.slice(t,r);a&&s.push(a)}return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(E,{borderStyle:`round`,paddingX:1,flexDirection:`column`,height:12,maxWidth:t-6,children:s.map((e,t)=>(0,Y.jsx)(D,{wrap:`truncate-end`,children:e},t))}),(0,Y.jsxs)(D,{dimColor:!0,italic:!0,children:[`Showing ${s.length} lines`,o?` of ${Re(r)}`:``]})]})}var J,Y,Dt,Ot=t((()=>{J=n(k(),1),d(),A(),a(),I(),Me(),le(),Y=M(),Dt=8192}));function kt(e,t){return Object.values(e??{}).filter(_).filter(e=>!(e.type===`local_agent`&&e.id===t))}function At({onDone:e,toolUseContext:t,initialDetailTaskId:n}){let r=ve(e=>e.tasks),i=ve(e=>e.foregroundedTaskId),a=de(),o=m(`chat:killAgents`,`Chat`,`ctrl+x ctrl+k`),s=r,c=(0,Z.useRef)(!1),[l,u]=(0,Z.useState)(()=>{if(n)return c.current=!0,{mode:`detail`,itemId:n};let e=kt(s,i);return e.length===1?(c.current=!0,{mode:`detail`,itemId:e[0].id}):{mode:`list`}}),[d,f]=(0,Z.useState)(0);ce(`background-tasks-dialog`);let{bashTasks:p,remoteSessions:h,agentTasks:g,workflowTasks:v,dreamTasks:te,allSelectableItems:y}=(0,Z.useMemo)(()=>{let e=Object.values(s??{}).filter(_).map(jt).sort((e,t)=>{let n=e.status,r=t.status;if(n===`running`&&r!==`running`)return-1;if(n!==`running`&&r===`running`)return 1;let i=`task`in e?e.task.startTime:0;return(`task`in t?t.task.startTime:0)-i}),t=e.filter(e=>e.type===`local_bash`),n=e.filter(e=>e.type===`remote_agent`),r=e.filter(e=>e.type===`local_agent`&&e.id!==i),a=e.filter(e=>e.type===`local_workflow`),o=e.filter(e=>e.type===`dream`);return{bashTasks:t,remoteSessions:n,agentTasks:r,workflowTasks:a,dreamTasks:o,allSelectableItems:[...t,...n,...r,...a,...o]}},[s,i]),b=y[d]??null;T({"confirm:previous":()=>f(e=>Math.max(0,e-1)),"confirm:next":()=>f(e=>Math.min(y.length-1,e+1)),"confirm:yes":()=>{let e=y[d];e&&u({mode:`detail`,itemId:e.id})}},{context:`Confirmation`,isActive:l.mode===`list`});let ne=t=>{if(l.mode!==`list`)return;if(t.key===`left`){t.preventDefault(),e(`Background tasks dialog dismissed`,{display:`system`});return}let n=y[d];n&&t.key===`x`&&(t.preventDefault(),n.type===`local_bash`&&n.status===`running`?re(n.id):n.type===`local_agent`&&n.status===`running`?ie(n.id):n.type===`local_workflow`&&n.status===`running`&&$?$(n.id,a):n.type===`dream`&&n.status===`running`?ae(n.id):n.type===`remote_agent`&&n.status===`running`&&oe(n.id))};async function re(e){await ee.kill(e,a)}async function ie(e){await we.kill(e,a)}async function ae(e){await fe.kill(e,a)}async function oe(e){await pe.kill(e,a)}let se=(0,Z.useEffectEvent)(e);(0,Z.useEffect)(()=>{if(l.mode!==`list`){let e=(s??{})[l.itemId];(!e||e.type!==`local_workflow`&&!_(e))&&(c.current?se(`Background tasks dialog dismissed`,{display:`system`}):u({mode:`list`}))}let e=y.length;d>=e&&e>0&&f(e-1)},[l,s,d,y,se]);let x=()=>{c.current&&y.length<=1?e(`Background tasks dialog dismissed`,{display:`system`}):(c.current=!1,u({mode:`list`}))};if(l.mode!==`list`&&s){let n=s[l.itemId];if(!n)return null;switch(n.type){case`local_bash`:return(0,Q.jsx)(Tt,{shell:n,onDone:e,onKillShell:()=>void re(n.id),onBack:x},`shell-${n.id}`);case`local_agent`:return(0,Q.jsx)(et,{agent:n,onDone:e,onKillAgent:()=>void ie(n.id),onBack:x},`agent-${n.id}`);case`remote_agent`:return(0,Q.jsx)(bt,{session:n,onDone:e,toolUseContext:t,onBack:x,onKill:n.status===`running`?()=>void oe(n.id):void 0},`session-${n.id}`);case`local_workflow`:{let e=n.status===`running`&&$?()=>$(n.id,a):void 0;return(0,Q.jsx)(E,{flexDirection:`column`,tabIndex:0,borderStyle:`round`,onKeyDown:t=>{t.key===`left`?(t.preventDefault(),x()):t.key===`x`&&e&&(t.preventDefault(),e())},children:(0,Q.jsx)(j,{title:n.workflowName,subtitle:(0,Q.jsxs)(D,{dimColor:!0,children:[n.status,n.summary?` · ${n.summary}`:``]}),onCancel:x,inputGuide:()=>(0,Q.jsxs)(O,{children:[(0,Q.jsx)(w,{shortcut:`←`,action:`go back`}),(0,Q.jsx)(w,{shortcut:`Esc`,action:`close`}),e&&(0,Q.jsx)(w,{shortcut:`x`,action:`stop`})]}),children:n.status===`failed`&&n.error?(0,Q.jsxs)(D,{color:`error`,children:[`失败原因:`,n.error]}):null})},`workflow-${n.id}`)}case`dream`:return(0,Q.jsx)(ht,{task:n,onDone:()=>e(`Background tasks dialog dismissed`,{display:`system`}),onBack:x,onKill:n.status===`running`?()=>void ae(n.id):void 0},`dream-${n.id}`)}}let S=N(p,e=>e.status===`running`),C=N(h,e=>e.status===`running`||e.status===`pending`)+N(g,e=>e.status===`running`),le=Pe([...S>0?[(0,Q.jsxs)(D,{children:[S,` `,S===1?`active shell`:`active shells`]},`shells`)]:[],...C>0?[(0,Q.jsxs)(D,{children:[C,` `,C===1?`active agent`:`active agents`]},`agents`)]:[]],e=>(0,Q.jsx)(D,{children:` · `},`separator-${e}`)),ue=[(0,Q.jsx)(w,{shortcut:`↑/↓`,action:`select`},`upDown`),(0,Q.jsx)(w,{shortcut:`Enter`,action:`view`},`enter`),...(b?.type===`local_bash`||b?.type===`local_agent`||b?.type===`local_workflow`||b?.type===`dream`||b?.type===`remote_agent`)&&b.status===`running`?[(0,Q.jsx)(w,{shortcut:`x`,action:`stop`},`kill`)]:[],...g.some(e=>e.status===`running`)?[(0,Q.jsx)(w,{shortcut:o,action:`stop all agents`},`kill-all`)]:[],(0,Q.jsx)(w,{shortcut:`←/Esc`,action:`close`},`esc`)],me=()=>e(`Background tasks dialog dismissed`,{display:`system`});function he(e){return e.pending?(0,Q.jsxs)(D,{children:[`Press `,e.keyName,` again to exit`]}):(0,Q.jsx)(O,{children:ue})}return(0,Q.jsx)(E,{flexDirection:`column`,tabIndex:0,autoFocus:!0,onKeyDown:ne,children:(0,Q.jsx)(j,{title:`Background tasks`,subtitle:(0,Q.jsx)(Q.Fragment,{children:le}),onCancel:me,color:`background`,inputGuide:he,children:y.length===0?(0,Q.jsx)(D,{dimColor:!0,children:`No tasks currently running`}):(0,Q.jsxs)(E,{flexDirection:`column`,children:[p.length>0&&(0,Q.jsxs)(E,{flexDirection:`column`,children:[(h.length>0||g.length>0)&&(0,Q.jsxs)(D,{dimColor:!0,children:[(0,Q.jsxs)(D,{bold:!0,children:[` `,`Shells`]}),` (`,p.length,`)`]}),(0,Q.jsx)(E,{flexDirection:`column`,children:p.map(e=>(0,Q.jsx)(X,{item:e,isSelected:e.id===b?.id},e.id))})]}),h.length>0&&(0,Q.jsxs)(E,{flexDirection:`column`,marginTop:+(p.length>0),children:[(0,Q.jsxs)(D,{dimColor:!0,children:[(0,Q.jsxs)(D,{bold:!0,children:[` `,`Remote agents`]}),` (`,h.length,`)`]}),(0,Q.jsx)(E,{flexDirection:`column`,children:h.map(e=>(0,Q.jsx)(X,{item:e,isSelected:e.id===b?.id},e.id))})]}),g.length>0&&(0,Q.jsxs)(E,{flexDirection:`column`,marginTop:+(p.length>0||h.length>0),children:[(0,Q.jsxs)(D,{dimColor:!0,children:[(0,Q.jsxs)(D,{bold:!0,children:[` `,`Local agents`]}),` (`,g.length,`)`]}),(0,Q.jsx)(E,{flexDirection:`column`,children:g.map(e=>(0,Q.jsx)(X,{item:e,isSelected:e.id===b?.id},e.id))})]}),v.length>0&&(0,Q.jsxs)(E,{flexDirection:`column`,marginTop:+(p.length>0||h.length>0||g.length>0),children:[(0,Q.jsxs)(D,{dimColor:!0,children:[(0,Q.jsxs)(D,{bold:!0,children:[` `,`Workflows`]}),` (`,v.length,`)`]}),(0,Q.jsx)(E,{flexDirection:`column`,children:v.map(e=>(0,Q.jsx)(X,{item:e,isSelected:e.id===b?.id},e.id))})]}),te.length>0&&(0,Q.jsx)(E,{flexDirection:`column`,marginTop:+(p.length>0||h.length>0||g.length>0||v.length>0),children:(0,Q.jsx)(E,{flexDirection:`column`,children:te.map(e=>(0,Q.jsx)(X,{item:e,isSelected:e.id===b?.id},e.id))})})]})})})}function jt(e){switch(e.type){case`local_bash`:return{id:e.id,type:`local_bash`,label:e.command,status:e.status,task:e};case`remote_agent`:return{id:e.id,type:`remote_agent`,label:e.title,status:e.status,task:e};case`local_agent`:return{id:e.id,type:`local_agent`,label:e.description,status:e.status,task:e};case`local_workflow`:return{id:e.id,type:`local_workflow`,label:e.summary??e.description,status:e.status,task:e};case`dream`:return{id:e.id,type:`dream`,label:e.description,status:e.status,task:e}}}function X({item:e,isSelected:t}){let{columns:n}=Oe(),r=Math.max(30,n-26);return(0,Q.jsxs)(E,{flexDirection:`row`,children:[(0,Q.jsx)(D,{children:t?i.pointer+` `:` `}),(0,Q.jsx)(D,{color:t?`suggestion`:void 0,children:(0,Q.jsx)(pt,{task:e.task,maxActivityWidth:r})})]})}var Z,Q,$,Mt=t((()=>{r(),Z=n(k(),1),d(),me(),oe(),l(),c(),S(),s(),Ne(),ye(),A(),a(),C(),nt(),mt(),gt(),Ct(),Ot(),Q=M(),$=(xe(),e(re))?.killWorkflowTask??null}));export{z as a,Qe as i,Mt as n,R as o,$e as r,At as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{ad as e,od as t}from"./loadAgentsDir-BXtV2jiO.js";t();export{e as ConsoleOAuthFlow};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{i as n,o as r}from"./envUtils-DcaKZlRU.js";import{n as i,t as a}from"./figures-5ThXQEtq.js";import{$T as o,$_ as s,AC as c,CT as l,Jl as u,QT as d,Q_ as f,XT as p,Yl as m,ZT as h,ab as g,bT as _,cw as v,dw as y,fw as ee,iT as b,ib as x,lw as te,na as S,og as C,ql as ne,rT as re,sb as ie,sg as w,ta as ae,tb as T,uw as oe}from"./loadAgentsDir-BXtV2jiO.js";import{Gt as se,I as E,P as D,fi as O,t as k,x as A}from"./src-P_wYS_NJ2.js";import{t as j}from"./jsx-runtime-Bb4Xn-E0.js";import{Wt as ce,et as le}from"./state-BPFYBqm1.js";import{H as M,g as N,kn as P,n as F,wn as I,z as L}from"./settings-DiBMs2gM.js";import{l as R,o as z}from"./stringUtils-Df-Lnjxd.js";import{Kn as B,Un as V,_ as H,u as U}from"./model-CDnVaVDR.js";import{n as W,t as ue}from"./ValidationErrorsList-DSSUWdgd.js";import{d as de,f as fe,h as pe,i as me,m as he,n as ge,o as _e,r as ve,u as G}from"./pidLock-d1VPd6CG.js";import{a as ye,i as be}from"./xdg-DcF9ejUM.js";import{n as xe,t as Se}from"./useExitOnCtrlCDWithKeybindings-BHQfwlAl.js";import{n as Ce,t as we}from"./McpParsingWarnings-xv0RZCSL.js";import{n as Te,t as Ee}from"./PressEnterToContinue-Dq0Imo9c.js";import{n as De,t as Oe}from"./useSettingsErrors-CPVQbsqq.js";import{n as ke,t as Ae}from"./shadowedRuleDetection-DZ0AA2Rw.js";import{n as je,r as Me,t as K}from"./statusNoticeHelpers-DakAVtQO.js";import{join as q}from"path";function Ne(){if(!o())return null;let e=p();if(e.length===0)return null;let t=e.filter(e=>e.severity===`error`),n=e.filter(e=>e.severity===`warning`);return(0,J.jsxs)(E,{flexDirection:`column`,marginTop:1,marginBottom:1,children:[(0,J.jsx)(D,{bold:!0,color:t.length>0?`error`:`warning`,children:`Keybinding Configuration Issues`}),(0,J.jsxs)(E,{children:[(0,J.jsx)(D,{dimColor:!0,children:`Location: `}),(0,J.jsx)(D,{dimColor:!0,children:h()})]}),(0,J.jsxs)(E,{marginLeft:1,flexDirection:`column`,marginTop:1,children:[t.map((e,t)=>(0,J.jsxs)(E,{flexDirection:`column`,children:[(0,J.jsxs)(E,{children:[(0,J.jsx)(D,{dimColor:!0,children:`└ `}),(0,J.jsx)(D,{color:`error`,children:`[Error]`}),(0,J.jsxs)(D,{dimColor:!0,children:[` `,e.message]})]}),e.suggestion&&(0,J.jsx)(E,{marginLeft:3,children:(0,J.jsxs)(D,{dimColor:!0,children:[`→ `,e.suggestion]})})]},`error-${t}`)),n.map((e,t)=>(0,J.jsxs)(E,{flexDirection:`column`,children:[(0,J.jsxs)(E,{children:[(0,J.jsx)(D,{dimColor:!0,children:`└ `}),(0,J.jsx)(D,{color:`warning`,children:`[Warning]`}),(0,J.jsxs)(D,{dimColor:!0,children:[` `,e.message]})]}),e.suggestion&&(0,J.jsx)(E,{marginLeft:3,children:(0,J.jsxs)(D,{dimColor:!0,children:[`→ `,e.suggestion]})})]},`warning-${t}`))]})]})}var J,Pe=e((()=>{O(),k(),d(),J=j()}));function Fe(){if(!_.isSupportedPlatform()||!_.isSandboxEnabledInSettings())return null;let e=_.checkDependencies(),t=e.errors.length>0,n=e.warnings.length>0;return!t&&!n?null:(0,Y.jsxs)(E,{flexDirection:`column`,children:[(0,Y.jsx)(D,{bold:!0,children:`Sandbox`}),(0,Y.jsxs)(D,{children:[`└ Status: `,(0,Y.jsx)(D,{color:t?`error`:`warning`,children:t?`Missing dependencies`:`Available (with warnings)`})]}),e.errors.map((e,t)=>(0,Y.jsxs)(D,{color:`error`,children:[`└ `,e]},t)),e.warnings.map((e,t)=>(0,Y.jsxs)(D,{color:`warning`,children:[`└ `,e]},t)),t&&(0,Y.jsx)(D,{dimColor:!0,children:`└ Run /sandbox for install instructions`})]})}var Y,Ie=e((()=>{O(),k(),l(),Y=j()}));async function Le(){let e=x(await g());if(e.length===0)return null;let t=e.sort((e,t)=>t.content.length-e.content.length).map(e=>`${e.path}: ${e.content.length.toLocaleString()} chars`);return{type:`agentsmd_files`,severity:`warning`,message:e.length===1?`Large AGENTS.md file detected (${e[0].content.length.toLocaleString()} chars > ${T.toLocaleString()})`:`${e.length} large AGENTS.md files detected (each > ${T.toLocaleString()} chars)`,details:t,currentValue:e.length,threshold:T}}async function X(e){if(!e)return null;let t=je(e);if(t<=15e3)return null;let n=e.activeAgents.filter(e=>e.source!==`built-in`).map(e=>{let t=`${e.agentType}: ${e.whenToUse}`;return{name:e.agentType,tokens:S(t)}}).sort((e,t)=>t.tokens-e.tokens),r=n.slice(0,5).map(e=>`${e.name}: ~${e.tokens.toLocaleString()} tokens`);return n.length>5&&r.push(`(${n.length-5} more custom agents)`),{type:`agent_descriptions`,severity:`warning`,message:`Large agent descriptions (~${t.toLocaleString()} tokens > ${K.toLocaleString()})`,details:r,currentValue:t,threshold:K}}async function Re(e,t,n){let r=e.filter(e=>e.isMcp);if(r.length===0)return null;try{let{mcpToolTokens:r,mcpToolDetails:i}=await f(e,t,n,U());if(r<=Z)return null;let a=new Map;for(let e of i){let t=e.name.split(`__`)[1]||`unknown`,n=a.get(t)||{count:0,tokens:0};a.set(t,{count:n.count+1,tokens:n.tokens+e.tokens})}let o=Array.from(a.entries()).sort((e,t)=>t[1].tokens-e[1].tokens),s=o.slice(0,5).map(([e,t])=>`${e}: ${t.count} tools (~${t.tokens.toLocaleString()} tokens)`);return o.length>5&&s.push(`(${o.length-5} more servers)`),{type:`mcp_tools`,severity:`warning`,message:`Large MCP tools context (~${r.toLocaleString()} tokens > ${Z.toLocaleString()})`,details:s,currentValue:r,threshold:Z}}catch{let e=r.reduce((e,t)=>e+S(((t.name?.length||0)+t.description.length).toString()),0);return e<=Z?null:{type:`mcp_tools`,severity:`warning`,message:`Large MCP tools context (~${e.toLocaleString()} tokens estimated > ${Z.toLocaleString()})`,details:[`${r.length} MCP tools detected (token count estimated)`],currentValue:e,threshold:Z}}}async function ze(e){let t=Ae(await e(),{sandboxAutoAllowEnabled:_.isSandboxingEnabled()&&_.isAutoAllowBashIfSandboxedEnabled()});if(t.length===0)return null;let n=t.flatMap(e=>[`${M(e.rule.ruleValue)}: ${e.reason}`,` Fix: ${e.fix}`]);return{type:`unreachable_rules`,severity:`warning`,message:`${t.length} ${R(t.length,`unreachable permission rule`)} detected`,details:n,currentValue:t.length,threshold:0}}async function Be(e,t,n){let[r,i,a,o]=await Promise.all([Le(),X(t),Re(e,n,t),ze(n)]);return{agentsMdWarning:r,agentWarning:i,mcpWarning:a,unreachableRulesWarning:o}}var Z,Ve=e((()=>{ae(),s(),ie(),H(),L(),ke(),l(),Me(),z(),Z=25e3}));function He({promise:e}){let t=(0,Q.use)(e);return t.latest?(0,$.jsxs)($.Fragment,{children:[t.stable&&(0,$.jsxs)(D,{children:[`└ Stable version: `,t.stable]}),(0,$.jsxs)(D,{children:[`└ Latest version: `,t.latest]})]}):(0,$.jsx)(D,{dimColor:!0,children:`└ Failed to fetch versions`})}function Ue({onDone:e}){let t=w(e=>e.agentDefinitions),r=w(e=>e.mcp.tools),i=w(e=>e.toolPermissionContext),o=w(e=>e.plugins.errors);xe();let s=(0,Q.useMemo)(()=>r||[],[r]),[c,l]=(0,Q.useState)(null),[d,f]=(0,Q.useState)(null),[p,m]=(0,Q.useState)(null),[h,g]=(0,Q.useState)(null),_=De(),y=(0,Q.useMemo)(()=>G().then(e=>(e.installationType===`native`?fe:he)().catch(()=>({latest:null,stable:null}))),[]),b=F()?.autoUpdatesChannel??`latest`,x=_.filter(e=>e.mcpErrorMetadata===void 0),S=(0,Q.useMemo)(()=>[{name:`BASH_MAX_OUTPUT_LENGTH`,default:v,upperLimit:te},{name:`TASK_MAX_OUTPUT_LENGTH`,default:ne,upperLimit:u},{name:`CLAUDE_CODE_MAX_OUTPUT_TOKENS`,...V(`claude-opus-4-7`)}].map(e=>{let t=process.env[e.name],n=ee(e.name,t,e.default,e.upperLimit);return{name:e.name,...n}}).filter(e=>e.status!==`valid`),[]);(0,Q.useEffect)(()=>{G().then(l),(async()=>{let e=q(n(),`agents`),r=q(le(),`.workmate`,`agents`),{activeAgents:a,allAgents:o,failedFiles:c}=t,[l,u]=await Promise.all([P(e),P(r)]),d={activeAgents:a.map(e=>({agentType:e.agentType,source:e.source})),userAgentsDir:e,projectAgentsDir:r,userDirExists:l,projectDirExists:u,failedFiles:c};f(d);let p=await Be(s,{activeAgents:a,allAgents:o,failedFiles:c},async()=>i);if(m(p),_e()){let e=q(be(),`claude`,`locks`),t=ge(e),n=ve(e);g({enabled:!0,locks:n,locksDir:e,staleLocksCleaned:t})}else g({enabled:!1,locks:[],locksDir:``,staleLocksCleaned:0})})()},[i,s,t]);let C=(0,Q.useCallback)(()=>{e(`Claude Code diagnostics dismissed`,{display:`system`})},[e]);return se({"confirm:yes":C,"confirm:no":C},{context:`Confirmation`}),c?(0,$.jsxs)(A,{children:[(0,$.jsxs)(E,{flexDirection:`column`,children:[(0,$.jsx)(D,{bold:!0,children:`Diagnostics`}),(0,$.jsxs)(D,{children:[`└ Currently running: `,c.installationType,` (`,c.version,`)`]}),c.packageManager&&(0,$.jsxs)(D,{children:[`└ Package manager: `,c.packageManager]}),(0,$.jsxs)(D,{children:[`└ Path: `,c.installationPath]}),(0,$.jsxs)(D,{children:[`└ Invoked: `,c.invokedBinary]}),(0,$.jsxs)(D,{children:[`└ Config install method: `,c.configInstallMethod]}),(0,$.jsxs)(D,{children:[`└ Search: `,c.ripgrepStatus.working?`OK`:`Not working`,` (`,c.ripgrepStatus.mode===`embedded`?`bundled`:c.ripgrepStatus.mode===`builtin`?`vendor`:c.ripgrepStatus.systemPath||`system`,`)`]}),c.ripgrepStatus.note&&(0,$.jsxs)(D,{color:`warning`,children:[`└ Note: `,c.ripgrepStatus.note]}),c.recommendation&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(D,{}),(0,$.jsxs)(D,{color:`warning`,children:[`Recommendation: `,c.recommendation.split(`
|
|
2
|
-
`)[0]]}),(0,$.jsx)(D,{dimColor:!0,children:c.recommendation.split(`
|
|
3
|
-
`)[1]})]}),c.multipleInstallations.length>1&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(D,{}),(0,$.jsx)(D,{color:`warning`,children:`Warning: Multiple installations found`}),c.multipleInstallations.map((e,t)=>(0,$.jsxs)(D,{children:[`└ `,e.type,` at `,e.path]},t))]}),c.warnings.length>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(D,{}),c.warnings.map((e,t)=>(0,$.jsxs)(E,{flexDirection:`column`,children:[(0,$.jsxs)(D,{color:`warning`,children:[`Warning: `,e.issue]}),(0,$.jsxs)(D,{children:[`Fix: `,e.fix]})]},t))]}),x.length>0&&(0,$.jsxs)(E,{flexDirection:`column`,marginTop:1,marginBottom:1,children:[(0,$.jsx)(D,{bold:!0,children:`Invalid Settings`}),(0,$.jsx)(ue,{errors:x})]})]}),(0,$.jsxs)(E,{flexDirection:`column`,children:[(0,$.jsx)(D,{bold:!0,children:`Updates`}),(0,$.jsxs)(D,{children:[`└ Auto-updates: `,c.packageManager?`Managed by package manager`:c.autoUpdates]}),c.hasUpdatePermissions!==null&&(0,$.jsxs)(D,{children:[`└ Update permissions: `,c.hasUpdatePermissions?`Yes`:`No (requires sudo)`]}),(0,$.jsxs)(D,{children:[`└ Auto-update channel: `,b]}),(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(He,{promise:y})})]}),(0,$.jsx)(Fe,{}),(0,$.jsx)(we,{}),(0,$.jsx)(Ne,{}),S.length>0&&(0,$.jsxs)(E,{flexDirection:`column`,children:[(0,$.jsx)(D,{bold:!0,children:`Environment Variables`}),S.map((e,t)=>(0,$.jsxs)(D,{children:[`└ `,e.name,`:`,` `,(0,$.jsx)(D,{color:e.status===`capped`?`warning`:`error`,children:e.message})]},t))]}),h?.enabled&&(0,$.jsxs)(E,{flexDirection:`column`,children:[(0,$.jsx)(D,{bold:!0,children:`Version Locks`}),h.staleLocksCleaned>0&&(0,$.jsxs)(D,{dimColor:!0,children:[`└ Cleaned `,h.staleLocksCleaned,` stale lock(s)`]}),h.locks.length===0?(0,$.jsx)(D,{dimColor:!0,children:`└ No active version locks`}):h.locks.map((e,t)=>(0,$.jsxs)(D,{children:[`└ `,e.version,`: PID `,e.pid,` `,e.isProcessRunning?(0,$.jsx)(D,{children:`(running)`}):(0,$.jsx)(D,{color:`warning`,children:`(stale)`})]},t))]}),d?.failedFiles&&d.failedFiles.length>0&&(0,$.jsxs)(E,{flexDirection:`column`,children:[(0,$.jsx)(D,{bold:!0,color:`error`,children:`Agent Parse Errors`}),(0,$.jsxs)(D,{color:`error`,children:[`└ Failed to parse `,d.failedFiles.length,` agent file(s):`]}),d.failedFiles.map((e,t)=>(0,$.jsxs)(D,{dimColor:!0,children:[` `,`└ `,e.path,`: `,e.error]},t))]}),o.length>0&&(0,$.jsxs)(E,{flexDirection:`column`,children:[(0,$.jsx)(D,{bold:!0,color:`error`,children:`Plugin Errors`}),(0,$.jsxs)(D,{color:`error`,children:[`└ `,o.length,` plugin error(s) detected:`]}),o.map((e,t)=>(0,$.jsxs)(D,{dimColor:!0,children:[` `,`└ `,e.source||`unknown`,`plugin`in e&&e.plugin?` [${e.plugin}]`:``,`: `,re(e)]},t))]}),p?.unreachableRulesWarning&&(0,$.jsxs)(E,{flexDirection:`column`,children:[(0,$.jsx)(D,{bold:!0,color:`warning`,children:`Unreachable Permission Rules`}),(0,$.jsxs)(D,{children:[`└`,` `,(0,$.jsxs)(D,{color:`warning`,children:[a.warning,` `,p.unreachableRulesWarning.message]})]}),p.unreachableRulesWarning.details.map((e,t)=>(0,$.jsxs)(D,{dimColor:!0,children:[` `,`└ `,e]},t))]}),p&&(p.agentsMdWarning||p.agentWarning||p.mcpWarning)&&(0,$.jsxs)(E,{flexDirection:`column`,children:[(0,$.jsx)(D,{bold:!0,children:`Context Usage Warnings`}),p.agentsMdWarning&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(D,{children:[`└`,` `,(0,$.jsxs)(D,{color:`warning`,children:[a.warning,` `,p.agentsMdWarning.message]})]}),(0,$.jsxs)(D,{children:[` `,`└ Files:`]}),p.agentsMdWarning.details.map((e,t)=>(0,$.jsxs)(D,{dimColor:!0,children:[` `,`└ `,e]},t))]}),p.agentWarning&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(D,{children:[`└`,` `,(0,$.jsxs)(D,{color:`warning`,children:[a.warning,` `,p.agentWarning.message]})]}),(0,$.jsxs)(D,{children:[` `,`└ Top contributors:`]}),p.agentWarning.details.map((e,t)=>(0,$.jsxs)(D,{dimColor:!0,children:[` `,`└ `,e]},t))]}),p.mcpWarning&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(D,{children:[`└`,` `,(0,$.jsxs)(D,{color:`warning`,children:[a.warning,` `,p.mcpWarning.message]})]}),(0,$.jsxs)(D,{children:[` `,`└ MCP servers:`]}),p.mcpWarning.details.map((e,t)=>(0,$.jsxs)(D,{dimColor:!0,children:[` `,`└ `,e]},t))]})]}),(0,$.jsx)(E,{children:(0,$.jsx)(Ee,{})})]}):(0,$.jsx)(A,{children:(0,$.jsx)(D,{dimColor:!0,children:`Checking installation status…`})})}var Q,$,We=e((()=>{i(),Q=t(O(),1),Pe(),Ce(),B(),r(),ce(),k(),Te(),Ie(),W(),Oe(),Se(),c(),C(),b(),pe(),Ve(),de(),y(),I(),me(),N(),oe(),m(),ye(),$=j()}));export{We as n,Ue as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e,t}from"./Doctor-CZ513Df9.js";e();export{t as Doctor};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as e,n as t,o as n}from"./rolldown-runtime-DaDcL9Zw.js";import{Cr as r,Dt as i,FT as a,Nu as o,Ot as s,PT as c,Qd as l,Qu as u,St as d,Tt as f,XC as p,Xd as m,YC as h,Zu as g,_E as _,_i as v,gE as y,ht as b,ju as x}from"./loadAgentsDir-BXtV2jiO.js";import{I as S,P as C,fi as w,t as T,y as E}from"./src-P_wYS_NJ2.js";import{t as D}from"./jsx-runtime-Bb4Xn-E0.js";import{c as O,i as k}from"./debug-Dr1SjdXn.js";import{r as A,t as j}from"./execFileNoThrow-mXq4K0rl.js";import{n as M,r as N}from"./analytics-DJobLaWP.js";function P(){(r(),e(v)).saveWorktreeState(null)}function F({onDone:e,onCancel:t}){let[n,r]=(0,I.useState)(`loading`),[a,o]=(0,I.useState)([]),[c,l]=(0,I.useState)(0),[u,f]=(0,I.useState)(),m=d();if((0,I.useEffect)(()=>{async function e(){let e=[],t=await j(`git`,[`status`,`--porcelain`]);if(t.stdout&&(e=t.stdout.split(`
|
|
2
|
-
`).filter(e=>e.trim()!==``),o(e)),m){let{stdout:t}=await j(`git`,[`rev-list`,`--count`,`${m.originalHeadCommit}..HEAD`]),n=parseInt(t.trim(),10)||0;if(l(n),e.length===0&&n===0){r(`removing`),b().then(()=>{process.chdir(m.originalCwd),p(m.originalCwd),P(),y.cache.clear?.(),f(`Worktree removed (no changes)`)}).catch(e=>{O(`Failed to clean up worktree: ${e}`,{level:`error`}),f(`Worktree cleanup failed, exiting anyway`)}).then(()=>{r(`done`)});return}else r(`asking`)}}e()},[m]),(0,I.useEffect)(()=>{n===`done`&&e(u)},[n,e,u]),!m)return e(`No active worktree session found`,{display:`system`}),null;if(n===`loading`||n===`done`)return null;async function h(e){if(!m)return;let t=!!m.tmuxSessionName;if(e===`keep`||e===`keep-with-tmux`)r(`keeping`),N(`tengu_worktree_kept`,{commits:c,changed_files:a.length}),await i(),process.chdir(m.originalCwd),p(m.originalCwd),P(),y.cache.clear?.(),f(t?`Worktree kept. Your work is saved at ${m.worktreePath} on branch ${m.worktreeBranch}. Reattach to tmux session with: tmux attach -t ${m.tmuxSessionName}`:`Worktree kept. Your work is saved at ${m.worktreePath} on branch ${m.worktreeBranch}`),r(`done`);else if(e===`keep-kill-tmux`)r(`keeping`),N(`tengu_worktree_kept`,{commits:c,changed_files:a.length}),m.tmuxSessionName&&await s(m.tmuxSessionName),await i(),process.chdir(m.originalCwd),p(m.originalCwd),P(),y.cache.clear?.(),f(`Worktree kept at ${m.worktreePath} on branch ${m.worktreeBranch}. Tmux session terminated.`),r(`done`);else if(e===`remove`||e===`remove-with-tmux`){r(`removing`),N(`tengu_worktree_removed`,{commits:c,changed_files:a.length}),m.tmuxSessionName&&await s(m.tmuxSessionName);try{await b(),process.chdir(m.originalCwd),p(m.originalCwd),P(),y.cache.clear?.()}catch(e){O(`Failed to clean up worktree: ${e}`,{level:`error`}),f(`Worktree cleanup failed, exiting anyway`),r(`done`);return}let e=t?` Tmux session terminated.`:``;c>0&&a.length>0?f(`Worktree removed. ${c} ${c===1?`commit`:`commits`} and uncommitted changes were discarded.${e}`):c>0?f(`Worktree removed. ${c} ${c===1?`commit`:`commits`} on ${m.worktreeBranch} ${c===1?`was`:`were`} discarded.${e}`):a.length>0?f(`Worktree removed. Uncommitted changes were discarded.${e}`):f(`Worktree removed.${e}`),r(`done`)}}if(n===`keeping`)return(0,L.jsxs)(S,{flexDirection:`row`,marginY:1,children:[(0,L.jsx)(x,{}),(0,L.jsx)(C,{children:`Keeping worktree…`})]});if(n===`removing`)return(0,L.jsxs)(S,{flexDirection:`row`,marginY:1,children:[(0,L.jsx)(x,{}),(0,L.jsx)(C,{children:`Removing worktree…`})]});let _=m.worktreeBranch,v=a.length>0,w=c>0,T=``;T=v&&w?`You have ${a.length} uncommitted ${a.length===1?`file`:`files`} and ${c} ${c===1?`commit`:`commits`} on ${_}. All will be lost if you remove.`:v?`You have ${a.length} uncommitted ${a.length===1?`file`:`files`}. These will be lost if you remove the worktree.`:w?`You have ${c} ${c===1?`commit`:`commits`} on ${_}. The branch will be deleted if you remove the worktree.`:`You are working in a worktree. Keep it to continue working there, or remove it to clean up.`;function D(){if(t){t();return}h(`keep`)}let k=v||w?`All changes and commits will be lost.`:`Clean up the worktree directory.`,A=!!m.tmuxSessionName,M=A?[{label:`Keep worktree and tmux session`,value:`keep-with-tmux`,description:`Stays at ${m.worktreePath}. Reattach with: tmux attach -t ${m.tmuxSessionName}`},{label:`Keep worktree, kill tmux session`,value:`keep-kill-tmux`,description:`Keeps worktree at ${m.worktreePath}, terminates tmux session.`},{label:`Remove worktree and tmux session`,value:`remove-with-tmux`,description:k}]:[{label:`Keep worktree`,value:`keep`,description:`Stays at ${m.worktreePath}`},{label:`Remove worktree`,value:`remove`,description:k}];return(0,L.jsx)(E,{title:`Exiting worktree session`,subtitle:T,onCancel:D,children:(0,L.jsx)(g,{defaultFocusValue:A?`keep-with-tmux`:`keep`,options:M,onChange:h})})}var I,L,R=t((()=>{I=n(w(),1),M(),k(),T(),A(),_(),h(),f(),u(),o(),L=D()}));function z(){return a(H)??`Goodbye!`}function B({showWorktree:e,onDone:t,onCancel:n}){async function r(e){t(e??z()),await m(0,`prompt_input_exit`)}return e?(0,V.jsx)(F,{onDone:r,onCancel:n}):null}var V,H,U=t((()=>{c(),w(),l(),R(),V=D(),H=[`Goodbye!`,`See ya!`,`Bye!`,`Catch you later!`]}));export{U as n,B as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./rolldown-runtime-DaDcL9Zw.js";import{Du as e,Ou as t,Xu as n,Zu as r,ag as i,og as a}from"./loadAgentsDir-BXtV2jiO.js";import{I as o,P as s,fi as c,kn as l,t as u,y as d}from"./src-P_wYS_NJ2.js";import{t as f}from"./jsx-runtime-Bb4Xn-E0.js";import{C as p,T as m,x as h}from"./debug-Dr1SjdXn.js";import{t as g}from"./renderOptions-45A-EdsK.js";c(),u(),t(),a(),h(),n();var _=f();function v({filePath:e,errorDescription:t,onExit:n,onReset:i}){return(0,_.jsxs)(d,{title:`Configuration Error`,color:`error`,onCancel:n,children:[(0,_.jsxs)(o,{flexDirection:`column`,gap:1,children:[(0,_.jsxs)(s,{children:[`The configuration file at `,(0,_.jsx)(s,{bold:!0,children:e}),` contains invalid JSON.`]}),(0,_.jsx)(s,{children:t})]}),(0,_.jsxs)(o,{flexDirection:`column`,children:[(0,_.jsx)(s,{bold:!0,children:`Choose an option:`}),(0,_.jsx)(r,{options:[{label:`Exit and fix manually`,value:`exit`},{label:`Reset with default configuration`,value:`reset`}],onChange:e=>{e===`exit`?n():i()},onCancel:n})]})]})}var y=`dark`;async function b({error:t}){let n={...g(!1),theme:y};await new Promise(async r=>{let{unmount:a}=await l((0,_.jsx)(i,{children:(0,_.jsx)(e,{children:(0,_.jsx)(v,{filePath:t.filePath,errorDescription:t.message,onExit:()=>{a(),r(),process.exit(1)},onReset:()=>{m(t.filePath,p(t.defaultConfig,null,2),{flush:!1,encoding:`utf8`}),a(),r(),process.exit(0)}})})}),n)})}export{b as showInvalidConfigDialog};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as e,n as t,o as n}from"./rolldown-runtime-DaDcL9Zw.js";import{Gb as r,Gx as i,Hb as a,IT as o,Jb as s,Jd as c,Kb as l,LT as u,Qx as d,Rx as f,Tx as p,Ub as m,Ux as h,Vb as g,Wx as _,Xb as ee,Xx as v,Yd as te,Zb as ne,Zx as y,cg as b,iS as x,jx as re,lg as ie,nC as ae,nS as S,oC as oe,oS as C,og as w,rC as se,rS as ce,sC as T,sg as E,zb as D}from"./loadAgentsDir-BXtV2jiO.js";import{fi as O}from"./src-P_wYS_NJ2.js";import{t as k}from"./jsx-runtime-Bb4Xn-E0.js";import{Wt as le,pt as ue}from"./state-BPFYBqm1.js";import{P as A,R as j,c as M,i as N}from"./debug-Dr1SjdXn.js";import{it as P,nt as F}from"./settings-DiBMs2gM.js";import{c as I,l as L,o as R}from"./log-27kCA_9u.js";import{n as z,r as B}from"./analytics-DJobLaWP.js";import{n as V,t as H}from"./omit-D4Udf-p-.js";import{o as de,s as fe}from"./localSearch-CeP4ef0a.js";function U(e){let t=`plugin`in e?e.plugin:`no-plugin`;return`${e.type}:${e.source}:${t}`}function W(e,t){t.length!==0&&e(e=>{let n=new Set(e.plugins.errors.map(e=>U(e))),r=t.filter(e=>!n.has(U(e)));return r.length===0?e:{...e,plugins:{...e.plugins,errors:[...e.plugins.errors,...r]}}})}function pe(e,t=!1){let n=b(),o=E(e=>e.authVersion),c=E(e=>e.mcp.pluginReconnectKey),l=ie(),f=(0,G.useRef)(new Map),{addNotification:ee}=te(),y=(0,G.useRef)([]),C=(0,G.useRef)(null),w=(0,G.useCallback)(()=>{C.current=null;let e=y.current;e.length!==0&&(y.current=[],l(t=>{let n=t.mcp;for(let t of e){let{tools:e,commands:r,resources:i,...a}=t,o=a.type===`disabled`||a.type===`failed`?e??[]:e,s=a.type===`disabled`||a.type===`failed`?r??[]:r,c=a.type===`disabled`||a.type===`failed`?i??[]:i,l=F(a.name),d=n.clients.findIndex(e=>e.name===a.name)===-1?[...n.clients,a]:n.clients.map(e=>e.name===a.name?a:e),f=o===void 0?n.tools:[...u(n.tools,e=>e.name?.startsWith(l)),...o],m=s===void 0?n.commands:[...u(n.commands,e=>p(e,a.name)),...s],h=c===void 0?n.resources:{...n.resources,...c.length>0?{[a.name]:c}:V(n.resources,a.name)};n={...n,clients:d,tools:f,commands:m,resources:h}}return{...t,mcp:n}}))},[l]),T=(0,G.useCallback)(e=>{y.current.push(e),C.current===null&&(C.current=setTimeout(w,16))},[w]),O=(0,G.useCallback)(({client:e,tools:t,commands:n,resources:r})=>{switch(T({...e,tools:t,commands:n,resources:r}),e.type){case`connected`:ne(e.client,e.name,l),e.client.onclose=()=>{let t=e.config.type??`stdio`;if(D(e.name,e.config).catch(()=>{M(`Failed to invalidate the server cache: ${e.name}`)}),d(e.name)){I(e.name,`Server is disabled, skipping automatic reconnection`);return}if(t!==`stdio`&&t!==`sdk`){let n=me(t);I(e.name,`${n} transport closed/disconnected, attempting automatic reconnection`);let r=f.current.get(e.name);r&&(clearTimeout(r),f.current.delete(e.name)),(async()=>{for(let t=1;t<=q;t++){if(d(e.name)){I(e.name,`Server disabled during reconnection, stopping retry`),f.current.delete(e.name);return}T({...e,type:`pending`,reconnectAttempt:t,maxReconnectAttempts:q});let r=Date.now();try{let i=await s(e.name,e.config),a=Date.now()-r;if(i.client.type===`connected`){I(e.name,`${n} reconnection successful after ${a}ms (attempt ${t})`),f.current.delete(e.name),O(i);return}if(I(e.name,`${n} reconnection attempt ${t} completed with status: ${i.client.type}`),t===q){I(e.name,`Max reconnection attempts (${q}) reached, giving up`),f.current.delete(e.name),O(i);return}}catch(i){let a=Date.now()-r;if(L(e.name,`${n} reconnection attempt ${t} failed after ${a}ms: ${i}`),t===q){I(e.name,`Max reconnection attempts (${q}) reached, giving up`),f.current.delete(e.name),T({...e,type:`failed`});return}}let i=Math.min(J*2**(t-1),Y);I(e.name,`Scheduling reconnection attempt ${t+1} in ${i}ms`),await new Promise(t=>{let n=setTimeout(t,i);f.current.set(e.name,n)})}})()}else T({...e,type:`failed`})},e.capabilities?.tools?.listChanged&&e.client.setNotificationHandler(oe,async()=>{I(e.name,`Received tools/list_changed notification, refreshing tools`);try{let t=m.cache.get(e.name);m.cache.delete(e.name);let n=await m(e),r=n.length;t?t.then(e=>{B(`tengu_mcp_list_changed`,{type:`tools`,previousCount:e.length,newCount:r})},()=>{B(`tengu_mcp_list_changed`,{type:`tools`,newCount:r})}):B(`tengu_mcp_list_changed`,{type:`tools`,newCount:r}),T({...e,tools:n})}catch(t){L(e.name,`Failed to refresh tools after list_changed notification: ${A(t)}`)}}),e.capabilities?.prompts?.listChanged&&e.client.setNotificationHandler(ae,async()=>{I(e.name,`Received prompts/list_changed notification, refreshing prompts`),B(`tengu_mcp_list_changed`,{type:`prompts`});try{g.cache.delete(e.name);let[t,n]=await Promise.all([g(e),Promise.resolve([])]);T({...e,commands:[...t,...n]}),K?.()}catch(t){L(e.name,`Failed to refresh prompts after list_changed notification: ${A(t)}`)}}),e.capabilities?.resources?.listChanged&&e.client.setNotificationHandler(se,async()=>{I(e.name,`Received resources/list_changed notification, refreshing resources`),B(`tengu_mcp_list_changed`,{type:`resources`});try{a.cache.delete(e.name);{let t=await a(e);T({...e,resources:t})}}catch(t){L(e.name,`Failed to refresh resources after list_changed notification: ${A(t)}`)}});break;case`needs-auth`:case`failed`:case`pending`:case`disabled`:break}},[T]),k=ue();return(0,G.useEffect)(()=>{async function n(){let{servers:n,errors:r}=t?{servers:{},errors:[]}:await v(e),i={...n,...e};W(l,r),l(e=>{let{stale:t,...n}=re(e.mcp,i);for(let e of t){let t=f.current.get(e.name);t&&(clearTimeout(t),f.current.delete(e.name)),e.type===`connected`&&(e.client.onclose=void 0,D(e.name,e.config).catch(()=>{}))}let r=new Set(n.clients.map(e=>e.name)),a=Object.entries(i).filter(([e])=>!r.has(e)).map(([e,t])=>({name:e,type:d(e)?`disabled`:`pending`,config:t}));return a.length===0&&t.length===0?e:{...e,mcp:{...e.mcp,...n,clients:[...n.clients,...a]}}})}n().catch(e=>{L(`useManageMCPConnections`,`Failed to initialize servers as pending: ${A(e)}`)})},[t,e,l,k,c]),(0,G.useEffect)(()=>{let n=!1;async function a(){let a;t||_()?a=Promise.resolve({}):(ce(),a=x());let{servers:o,errors:s}=t?{servers:{},errors:[]}:await v(e,a);if(n)return;W(l,s);let c={...o,...e},u=Object.fromEntries(Object.entries(c).filter(([e])=>!d(e)));r(O,u).catch(e=>{L(`useManageMcpConnections`,`Failed to get MCP resources: ${A(e)}`)});let f={};if(!t){if(f=i(await a).allowed,n)return;if(Object.keys(f).length>0){let{servers:e}=h(f,c);f=e}if(Object.keys(f).length>0){l(e=>{let t=new Set(e.mcp.clients.map(e=>e.name)),n=Object.entries(f).filter(([e])=>!t.has(e)).map(([e,t])=>({name:e,type:d(e)?`disabled`:`pending`,config:t}));return n.length===0?e:{...e,mcp:{...e.mcp,clients:[...e.mcp.clients,...n]}}});let e=Object.fromEntries(Object.entries(f).filter(([e])=>!d(e)));r(O,e).catch(e=>{L(`useManageMcpConnections`,`Failed to get claude.ai MCP resources: ${A(e)}`)})}}let p={...c,...f},m={enterprise:0,global:0,project:0,user:0,plugin:0,claudeai:0};for(let[e,t]of Object.entries(p))t.scope===`enterprise`?m.enterprise++:t.scope===`user`?m.global++:t.scope===`project`?m.project++:t.scope===`local`?m.user++:t.scope===`dynamic`?m.plugin++:t.scope===`claudeai`&&m.claudeai++;B(`tengu_mcp_servers`,{...m})}return a(),()=>{n=!0}},[t,e,O,l,o,k,c]),(0,G.useEffect)(()=>{let e=f.current;return()=>{for(let t of e.values())clearTimeout(t);e.clear(),C.current!==null&&(clearTimeout(C.current),C.current=null,w())}},[w]),{reconnectMcpServer:(0,G.useCallback)(async e=>{let t=n.getState().mcp.clients.find(t=>t.name===e);if(!t)throw Error(`MCP server ${e} not found`);let r=f.current.get(e);r&&(clearTimeout(r),f.current.delete(e));let i=await s(e,t.config);return O(i),i},[n,O]),toggleMcpServer:(0,G.useCallback)(async e=>{let t=n.getState().mcp.clients.find(t=>t.name===e);if(!t)throw Error(`MCP server ${e} not found`);if(t.type!==`disabled`){let n=f.current.get(e);n&&(clearTimeout(n),f.current.delete(e)),S(e,!1),t.type===`connected`&&await D(e,t.config),T({name:e,type:`disabled`,config:t.config})}else{S(e,!0),T({name:e,type:`pending`,config:t.config});let n=await s(e,t.config);O(n)}},[n,T,O])}}function me(e){switch(e){case`http`:return`HTTP`;case`ws`:case`ws-ide`:return`WebSocket`;default:return`SSE`}}var G,K,q,J,Y,X=t((()=>{G=n(O(),1),le(),l(),T(),H(),o(),z(),y(),N(),c(),w(),j(),R(),ee(),C(),P(),f(),K=(de(),e(fe)).clearSkillIndexCache,q=5,J=1e3,Y=3e4}));function he(){let e=(0,Z.useContext)($);if(!e)throw Error(`useMcpReconnect must be used within MCPConnectionManager`);return e.reconnectMcpServer}function ge(){let e=(0,Z.useContext)($);if(!e)throw Error(`useMcpToggleEnabled must be used within MCPConnectionManager`);return e.toggleMcpServer}function _e({children:e,dynamicMcpConfig:t,isStrictMcpConfig:n}){let{reconnectMcpServer:r,toggleMcpServer:i}=pe(t,n),a=(0,Z.useMemo)(()=>({reconnectMcpServer:r,toggleMcpServer:i}),[r,i]);return(0,Q.jsx)($.Provider,{value:a,children:e})}var Z,Q,$,ve=t((()=>{Z=n(O(),1),X(),Q=k(),$=(0,Z.createContext)(null)}));export{ge as i,ve as n,he as r,_e as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{n,t as r}from"./figures-5ThXQEtq.js";import{AC as i,Ax as a,Ex as o,Fx as s,IC as c,Kb as l,Mp as u,Mx as ee,Nu as d,Px as te,Rx as f,Xu as p,Zu as ne,Zx as m,bS as h,cd as g,fx as _,ix as re,jp as v,ju as y,kx as ie,lg as ae,lx as b,og as x,qx as oe,sd as se,sg as ce,ux as le,xS as ue,zb as de}from"./loadAgentsDir-BXtV2jiO.js";import{D as S,H as fe,I as C,Lt as pe,P as w,T,Wt as me,dr as he,fi as E,hn as ge,j as D,ot as _e,t as O,y as k}from"./src-P_wYS_NJ2.js";import{t as A}from"./jsx-runtime-Bb4Xn-E0.js";import{P as ve,R as j}from"./debug-Dr1SjdXn.js";import{et as M,it as N,tt as P}from"./settings-DiBMs2gM.js";import{c as ye,o as F}from"./log-27kCA_9u.js";import{n as I,r as L}from"./analytics-DJobLaWP.js";import{l as be,u as R}from"./oauth-D38aRTUb.js";import{l as xe,n as Se,o as z}from"./stringUtils-Df-Lnjxd.js";import{Bt as B,jt as Ce}from"./model-CDnVaVDR.js";import{i as we,n as V,r as Te}from"./MCPConnectionManager-BpjC7CEo.js";import{n as Ee,t as H}from"./useExitOnCtrlCDWithKeybindings-BHQfwlAl.js";function De({serverToolsCount:e,serverPromptsCount:t,serverResourcesCount:n}){let r=[];return e>0&&r.push(`tools`),n>0&&r.push(`resources`),t>0&&r.push(`prompts`),(0,U.jsxs)(C,{children:[(0,U.jsx)(w,{bold:!0,children:`Capabilities: `}),(0,U.jsx)(w,{color:`text`,children:r.length>0?(0,U.jsx)(T,{children:r}):`none`})]})}var U,Oe=e((()=>{E(),O(),U=A()}));function ke(e,t){switch(e.client.type){case`connected`:return{message:`Reconnected to ${t}.`,success:!0};case`needs-auth`:return{message:`${t} requires authentication. Use the 'Authenticate' option.`,success:!1};case`failed`:return{message:`Failed to reconnect to ${t}.`,success:!1};default:return{message:`Unknown result when reconnecting to ${t}.`,success:!1}}}function Ae(e,t){return`Error reconnecting to ${t}: ${e instanceof Error?e.message:String(e)}`}var W=e((()=>{}));function je({server:e,serverToolsCount:t,onViewTools:n,onCancel:i,onComplete:s,borderless:c=!1}){let[l]=fe(),u=Ee(),{columns:d}=_e(),[f,p]=G.useState(!1),[m,h]=G.useState(null),g=ce(e=>e.mcp),b=ae(),[x,oe]=G.useState(null),[E,O]=(0,G.useState)(!1),k=(0,G.useRef)(null),[A,j]=(0,G.useState)(!1),[M,N]=(0,G.useState)(null),[P,F]=(0,G.useState)(!1),[I,R]=(0,G.useState)(null),[xe,z]=(0,G.useState)(!1),[B,V]=(0,G.useState)(!1),H=(0,G.useRef)(void 0),U=(0,G.useRef)(!1),[Oe,W]=(0,G.useState)(``),[je,Me]=(0,G.useState)(0),[Ne,q]=(0,G.useState)(null);(0,G.useEffect)(()=>()=>{U.current=!0,k.current?.abort(),H.current!==void 0&&clearTimeout(H.current)},[]);let J=e.isAuthenticated||e.client.type===`connected`&&t>0,Y=Te(),Pe=G.useCallback(async()=>{j(!1),N(null),O(!0);try{let t=await Y(e.name),n=t.client.type===`connected`;L(`tengu_claudeai_mcp_auth_completed`,{success:n}),n?s?.(`Authentication successful. Connected to ${e.name}.`):t.client.type===`needs-auth`?s?.(`Authentication successful, but server still requires authentication. You may need to manually restart Claude Code.`):s?.(`Authentication successful, but server reconnection failed. You may need to manually restart Claude Code for the changes to take effect.`)}catch(t){L(`tengu_claudeai_mcp_auth_completed`,{success:!1}),s?.(Ae(t,e.name))}finally{O(!1)}},[Y,e.name,s]),X=G.useCallback(async()=>{await de(e.name,{...e.config,scope:e.scope}),b(t=>{let n=t.mcp.clients.map(t=>t.name===e.name?{...t,type:`needs-auth`}:t),r=ee(t.mcp.tools,e.name),i=ie(t.mcp.commands,e.name),o=a(t.mcp.resources,e.name);return{...t,mcp:{...t.mcp,clients:n,tools:r,commands:i,resources:o}}}),L(`tengu_claudeai_mcp_clear_auth_completed`,{}),s?.(`Disconnected from ${e.name}.`),F(!1),R(null),z(!1)},[e.name,e.config,e.scope,b,s]);me(`confirm:no`,()=>{k.current?.abort(),k.current=null,p(!1),oe(null)},{context:`Confirmation`,isActive:f}),me(`confirm:no`,()=>{j(!1),N(null)},{context:`Confirmation`,isActive:A}),me(`confirm:no`,()=>{F(!1),R(null),z(!1)},{context:`Confirmation`,isActive:P}),ge((e,t)=>{if(t.return&&A&&Pe(),t.return&&P)if(xe)X();else{let e=`${be().CLAUDE_AI_ORIGIN}/settings/connectors`;R(e),z(!0),ue(e)}if(e===`c`&&!B){let e=x||M||I;e&&he(e).then(e=>{U.current||(e&&process.stdout.write(e),V(!0),H.current!==void 0&&clearTimeout(H.current),H.current=setTimeout(V,2e3,!1))})}});let Z=Se(String(e.name)),Fe=te(g.commands,e.name).length,Ie=we(),Le=G.useCallback(async()=>{let t=be().CLAUDE_AI_ORIGIN,n=Ce()?.organizationUuid,r;r=n&&e.config.type===`claudeai-proxy`&&e.config.id?`${t}/api/organizations/${n}/mcp/start-auth/${e.config.id.startsWith(`mcprs`)?`mcpsrv`+e.config.id.slice(5):e.config.id}?product_surface=${encodeURIComponent(process.env.CLAUDE_CODE_ENTRYPOINT||`cli`)}`:`${t}/settings/connectors`,N(r),j(!0),L(`tengu_claudeai_mcp_auth_started`,{}),await ue(r)},[e.config]),Q=G.useCallback(()=>{F(!0),L(`tengu_claudeai_mcp_clear_auth_started`,{})},[]),Re=G.useCallback(async()=>{let t=e.client.type!==`disabled`;try{await Ie(e.name),e.config.type===`claudeai-proxy`&&L(`tengu_claudeai_mcp_toggle`,{new_state:t?`disabled`:`enabled`}),i()}catch(n){s?.(`Failed to ${t?`disable`:`enable`} MCP server '${e.name}': ${ve(n)}`)}},[e.client.type,e.config.type,e.name,Ie,i,s]),ze=G.useCallback(async()=>{if(e.config.type===`claudeai-proxy`)return;p(!0),h(null);let t=new AbortController;k.current=t;try{if(e.isAuthenticated&&e.config&&await _(e.name,e.config,{preserveStepUpState:!0}),e.config){await le(e.name,e.config,oe,t.signal,{onWaitingForCallback:e=>{q(()=>e)}}),L(`tengu_mcp_auth_config_authenticate`,{wasAuthenticated:e.isAuthenticated});let n=await Y(e.name);if(n.client.type===`connected`){let t=J?`Authentication successful. Reconnected to ${e.name}.`:`Authentication successful. Connected to ${e.name}.`;s?.(t)}else n.client.type===`needs-auth`?s?.(`Authentication successful, but server still requires authentication. You may need to manually restart Claude Code.`):(ye(e.name,`Reconnection failed after authentication`),s?.(`Authentication successful, but server reconnection failed. You may need to manually restart Claude Code for the changes to take effect.`))}}catch(e){e instanceof Error&&!(e instanceof re)&&h(e.message)}finally{p(!1),k.current=null,q(null),W(``)}},[e.isAuthenticated,e.config,e.name,s,Y,J]),Be=async()=>{e.config.type!==`claudeai-proxy`&&e.config&&(await _(e.name,e.config),L(`tengu_mcp_auth_config_clear`,{}),await de(e.name,{...e.config,scope:e.scope}),b(t=>{let n=t.mcp.clients.map(t=>t.name===e.name?{...t,type:`failed`}:t),r=ee(t.mcp.tools,e.name),i=ie(t.mcp.commands,e.name),o=a(t.mcp.resources,e.name);return{...t,mcp:{...t.mcp,clients:n,tools:r,commands:i,resources:o}}}),s?.(`Authentication cleared for ${e.name}.`))};if(f){let t=e.config.type!==`claudeai-proxy`&&e.config.oauth?.xaa?` Authenticating via your identity provider`:` A browser window will open for authentication`;return(0,K.jsxs)(C,{flexDirection:`column`,gap:1,padding:1,children:[(0,K.jsxs)(w,{color:`claude`,children:[`Authenticating with `,e.name,`…`]}),(0,K.jsxs)(C,{children:[(0,K.jsx)(y,{}),(0,K.jsx)(w,{children:t})]}),x&&(0,K.jsxs)(C,{flexDirection:`column`,children:[(0,K.jsxs)(C,{children:[(0,K.jsx)(w,{dimColor:!0,children:`If your browser doesn't open automatically, copy this URL manually `}),B?(0,K.jsx)(w,{color:`success`,children:`(Copied!)`}):(0,K.jsx)(w,{dimColor:!0,children:(0,K.jsx)(S,{shortcut:`c`,action:`copy`,parens:!0})})]}),(0,K.jsx)(pe,{url:x})]}),f&&x&&Ne&&(0,K.jsxs)(C,{flexDirection:`column`,marginTop:1,children:[(0,K.jsx)(w,{dimColor:!0,children:`If the redirect page shows a connection error, paste the URL from your browser's address bar:`}),(0,K.jsxs)(C,{children:[(0,K.jsxs)(w,{dimColor:!0,children:[`URL `,`>`,` `]}),(0,K.jsx)(se,{value:Oe,onChange:W,onSubmit:e=>{Ne(e.trim()),W(``)},cursorOffset:je,onChangeCursorOffset:Me,columns:d-8})]})]}),(0,K.jsx)(C,{marginLeft:3,children:(0,K.jsx)(w,{dimColor:!0,children:`Return here after authenticating in your browser. Press Esc to go back.`})})]})}if(A)return(0,K.jsxs)(C,{flexDirection:`column`,gap:1,padding:1,children:[(0,K.jsxs)(w,{color:`claude`,children:[`Authenticating with `,e.name,`…`]}),(0,K.jsxs)(C,{children:[(0,K.jsx)(y,{}),(0,K.jsx)(w,{children:` A browser window will open for authentication`})]}),M&&(0,K.jsxs)(C,{flexDirection:`column`,children:[(0,K.jsxs)(C,{children:[(0,K.jsx)(w,{dimColor:!0,children:`If your browser doesn't open automatically, copy this URL manually `}),B?(0,K.jsx)(w,{color:`success`,children:`(Copied!)`}):(0,K.jsx)(w,{dimColor:!0,children:(0,K.jsx)(S,{shortcut:`c`,action:`copy`,parens:!0})})]}),(0,K.jsx)(pe,{url:M})]}),(0,K.jsxs)(C,{marginLeft:3,flexDirection:`column`,children:[(0,K.jsxs)(w,{color:`permission`,children:[`Press `,(0,K.jsx)(w,{bold:!0,children:`Enter`}),` after authenticating in your browser.`]}),(0,K.jsx)(w,{dimColor:!0,italic:!0,children:(0,K.jsx)(v,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})})]})]});if(P)return(0,K.jsxs)(C,{flexDirection:`column`,gap:1,padding:1,children:[(0,K.jsxs)(w,{color:`claude`,children:[`Clear authentication for `,e.name]}),xe?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(w,{children:`Find the MCP server in the browser and click "Disconnect".`}),I&&(0,K.jsxs)(C,{flexDirection:`column`,children:[(0,K.jsxs)(C,{children:[(0,K.jsx)(w,{dimColor:!0,children:`If your browser didn't open automatically, copy this URL manually `}),B?(0,K.jsx)(w,{color:`success`,children:`(Copied!)`}):(0,K.jsx)(w,{dimColor:!0,children:(0,K.jsx)(S,{shortcut:`c`,action:`copy`,parens:!0})})]}),(0,K.jsx)(pe,{url:I})]}),(0,K.jsxs)(C,{marginLeft:3,flexDirection:`column`,children:[(0,K.jsxs)(w,{color:`permission`,children:[`Press `,(0,K.jsx)(w,{bold:!0,children:`Enter`}),` when done.`]}),(0,K.jsx)(w,{dimColor:!0,italic:!0,children:(0,K.jsx)(v,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})})]})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(w,{children:`This will open claude.ai in the browser. Find the MCP server in the list and click "Disconnect".`}),(0,K.jsxs)(C,{marginLeft:3,flexDirection:`column`,children:[(0,K.jsxs)(w,{color:`permission`,children:[`Press `,(0,K.jsx)(w,{bold:!0,children:`Enter`}),` to open the browser.`]}),(0,K.jsx)(w,{dimColor:!0,italic:!0,children:(0,K.jsx)(v,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})})]})]})]});if(E)return(0,K.jsxs)(C,{flexDirection:`column`,gap:1,padding:1,children:[(0,K.jsxs)(w,{color:`text`,children:[`Connecting to `,(0,K.jsx)(w,{bold:!0,children:e.name}),`…`]}),(0,K.jsxs)(C,{children:[(0,K.jsx)(y,{}),(0,K.jsx)(w,{children:` Establishing connection to MCP server`})]}),(0,K.jsx)(w,{dimColor:!0,children:`This may take a few moments.`})]});let $=[];return e.client.type===`disabled`&&$.push({label:`Enable`,value:`toggle-enabled`}),e.client.type===`connected`&&t>0&&$.push({label:`View tools`,value:`tools`}),e.config.type===`claudeai-proxy`?e.client.type===`connected`?$.push({label:`Clear authentication`,value:`claudeai-clear-auth`}):e.client.type!==`disabled`&&$.push({label:`Authenticate`,value:`claudeai-auth`}):(J&&($.push({label:`Re-authenticate`,value:`reauth`}),$.push({label:`Clear authentication`,value:`clear-auth`})),J||$.push({label:`Authenticate`,value:`auth`})),e.client.type!==`disabled`&&(e.client.type!==`needs-auth`&&$.push({label:`Reconnect`,value:`reconnectMcpServer`}),$.push({label:`Disable`,value:`toggle-enabled`})),$.length===0&&$.push({label:`Back`,value:`back`}),(0,K.jsxs)(C,{flexDirection:`column`,children:[(0,K.jsxs)(C,{flexDirection:`column`,paddingX:1,borderStyle:c?void 0:`round`,children:[(0,K.jsx)(C,{marginBottom:1,children:(0,K.jsxs)(w,{bold:!0,children:[Z,` MCP Server`]})}),(0,K.jsxs)(C,{flexDirection:`column`,gap:0,children:[(0,K.jsxs)(C,{children:[(0,K.jsx)(w,{bold:!0,children:`Status: `}),e.client.type===`disabled`?(0,K.jsxs)(w,{children:[D(`inactive`,l)(r.radioOff),` disabled`]}):e.client.type===`connected`?(0,K.jsxs)(w,{children:[D(`success`,l)(r.tick),` connected`]}):e.client.type===`pending`?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(w,{dimColor:!0,children:r.radioOff}),(0,K.jsx)(w,{children:` connecting…`})]}):e.client.type===`needs-auth`?(0,K.jsxs)(w,{children:[D(`warning`,l)(r.triangleUpOutline),` needs authentication`]}):(0,K.jsxs)(w,{children:[D(`error`,l)(r.cross),` failed`]})]}),e.transport!==`claudeai-proxy`&&(0,K.jsxs)(C,{children:[(0,K.jsx)(w,{bold:!0,children:`Auth: `}),J?(0,K.jsxs)(w,{children:[D(`success`,l)(r.tick),` authenticated`]}):(0,K.jsxs)(w,{children:[D(`error`,l)(r.cross),` not authenticated`]})]}),(0,K.jsxs)(C,{children:[(0,K.jsx)(w,{bold:!0,children:`URL: `}),(0,K.jsx)(w,{dimColor:!0,children:e.config.url})]}),(0,K.jsxs)(C,{children:[(0,K.jsx)(w,{bold:!0,children:`Config location: `}),(0,K.jsx)(w,{dimColor:!0,children:o(e.scope)})]}),e.client.type===`connected`&&(0,K.jsx)(De,{serverToolsCount:t,serverPromptsCount:Fe,serverResourcesCount:g.resources[e.name]?.length||0}),e.client.type===`connected`&&t>0&&(0,K.jsxs)(C,{children:[(0,K.jsx)(w,{bold:!0,children:`Tools: `}),(0,K.jsxs)(w,{dimColor:!0,children:[t,` tools`]})]})]}),m&&(0,K.jsx)(C,{marginTop:1,children:(0,K.jsxs)(w,{color:`error`,children:[`Error: `,m]})}),$.length>0&&(0,K.jsx)(C,{marginTop:1,children:(0,K.jsx)(ne,{options:$,onChange:async t=>{switch(t){case`tools`:n();break;case`auth`:case`reauth`:await ze();break;case`clear-auth`:await Be();break;case`claudeai-auth`:await Le();break;case`claudeai-clear-auth`:Q();break;case`reconnectMcpServer`:O(!0);try{let t=await Y(e.name);e.config.type===`claudeai-proxy`&&L(`tengu_claudeai_mcp_reconnect`,{success:t.client.type===`connected`});let{message:n}=ke(t,e.name);s?.(n)}catch(t){e.config.type===`claudeai-proxy`&&L(`tengu_claudeai_mcp_reconnect`,{success:!1}),s?.(Ae(t,e.name))}finally{O(!1)}break;case`toggle-enabled`:await Re();break;case`back`:i();break}},onCancel:i})})]}),(0,K.jsx)(C,{marginTop:1,children:(0,K.jsx)(w,{dimColor:!0,italic:!0,children:u.pending?(0,K.jsxs)(K.Fragment,{children:[`Press `,u.keyName,` again to exit`]}):(0,K.jsxs)(T,{children:[(0,K.jsx)(S,{shortcut:`↑↓`,action:`navigate`}),(0,K.jsx)(S,{shortcut:`Enter`,action:`select`}),(0,K.jsx)(v,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})})]})}var G,K,Me=e((()=>{n(),G=t(E(),1),I(),R(),H(),c(),O(),i(),b(),l(),V(),f(),x(),B(),h(),j(),F(),z(),u(),p(),d(),g(),Oe(),W(),K=A()}));function Ne({server:e,serverToolsCount:t,onViewTools:n,onCancel:i,onComplete:a,borderless:s=!1}){let[c]=fe(),l=Ee(),u=ce(e=>e.mcp),ee=Te(),d=we(),[f,p]=(0,q.useState)(!1),m=q.useCallback(async()=>{let t=e.client.type!==`disabled`;try{await d(e.name),i()}catch(n){a(`Failed to ${t?`disable`:`enable`} MCP server '${e.name}': ${ve(n)}`)}},[e.client.type,e.name,d,i,a]),h=Se(String(e.name)),g=te(u.commands,e.name).length,_=[];return e.client.type!==`disabled`&&t>0&&_.push({label:`View tools`,value:`tools`}),e.client.type!==`disabled`&&_.push({label:`Reconnect`,value:`reconnectMcpServer`}),_.push({label:e.client.type===`disabled`?`Enable`:`Disable`,value:`toggle-enabled`}),_.length===0&&_.push({label:`Back`,value:`back`}),f?(0,J.jsxs)(C,{flexDirection:`column`,gap:1,padding:1,children:[(0,J.jsxs)(w,{color:`text`,children:[`Reconnecting to `,(0,J.jsx)(w,{bold:!0,children:e.name})]}),(0,J.jsxs)(C,{children:[(0,J.jsx)(y,{}),(0,J.jsx)(w,{children:` Restarting MCP server process`})]}),(0,J.jsx)(w,{dimColor:!0,children:`This may take a few moments.`})]}):(0,J.jsxs)(C,{flexDirection:`column`,children:[(0,J.jsxs)(C,{flexDirection:`column`,paddingX:1,borderStyle:s?void 0:`round`,children:[(0,J.jsx)(C,{marginBottom:1,children:(0,J.jsxs)(w,{bold:!0,children:[h,` MCP Server`]})}),(0,J.jsxs)(C,{flexDirection:`column`,gap:0,children:[(0,J.jsxs)(C,{children:[(0,J.jsx)(w,{bold:!0,children:`Status: `}),e.client.type===`disabled`?(0,J.jsxs)(w,{children:[D(`inactive`,c)(r.radioOff),` disabled`]}):e.client.type===`connected`?(0,J.jsxs)(w,{children:[D(`success`,c)(r.tick),` connected`]}):e.client.type===`pending`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(w,{dimColor:!0,children:r.radioOff}),(0,J.jsx)(w,{children:` connecting…`})]}):(0,J.jsxs)(w,{children:[D(`error`,c)(r.cross),` failed`]})]}),(0,J.jsxs)(C,{children:[(0,J.jsx)(w,{bold:!0,children:`Command: `}),(0,J.jsx)(w,{dimColor:!0,children:e.config.command})]}),e.config.args&&e.config.args.length>0&&(0,J.jsxs)(C,{children:[(0,J.jsx)(w,{bold:!0,children:`Args: `}),(0,J.jsx)(w,{dimColor:!0,children:e.config.args.join(` `)})]}),(0,J.jsxs)(C,{children:[(0,J.jsx)(w,{bold:!0,children:`Config location: `}),(0,J.jsx)(w,{dimColor:!0,children:o(oe(e.name)?.scope??`dynamic`)})]}),e.client.type===`connected`&&(0,J.jsx)(De,{serverToolsCount:t,serverPromptsCount:g,serverResourcesCount:u.resources[e.name]?.length||0}),e.client.type===`connected`&&t>0&&(0,J.jsxs)(C,{children:[(0,J.jsx)(w,{bold:!0,children:`Tools: `}),(0,J.jsxs)(w,{dimColor:!0,children:[t,` tools`]})]})]}),_.length>0&&(0,J.jsx)(C,{marginTop:1,children:(0,J.jsx)(ne,{options:_,onChange:async t=>{if(t===`tools`)n();else if(t===`reconnectMcpServer`){p(!0);try{let{message:t}=ke(await ee(e.name),e.name);a?.(t)}catch(t){a?.(Ae(t,e.name))}finally{p(!1)}}else t===`toggle-enabled`?await m():t===`back`&&i()},onCancel:i})})]}),(0,J.jsx)(C,{marginTop:1,children:(0,J.jsx)(w,{dimColor:!0,italic:!0,children:l.pending?(0,J.jsxs)(J.Fragment,{children:[`Press `,l.keyName,` again to exit`]}):(0,J.jsxs)(T,{children:[(0,J.jsx)(S,{shortcut:`↑↓`,action:`navigate`}),(0,J.jsx)(S,{shortcut:`Enter`,action:`select`}),(0,J.jsx)(v,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})})]})}var q,J,Y=e((()=>{n(),q=t(E(),1),H(),O(),m(),V(),f(),x(),j(),z(),u(),p(),d(),Oe(),W(),J=A()}));function Pe({tool:e,server:t,onBack:n}){let[r,i]=X.useState(``),a=P(e.name,t.name),o=M(e.userFacingName?e.userFacingName({}):a),s=e.isReadOnly?.({})??!1,c=e.isDestructive?.({})??!1,l=e.isOpenWorld?.({})??!1;return X.useEffect(()=>{async function t(){try{let t=await e.description({},{isNonInteractiveSession:!1,toolPermissionContext:{mode:`default`,additionalWorkingDirectories:new Map,alwaysAllowRules:{},alwaysDenyRules:{},alwaysAskRules:{},isBypassPermissionsModeAvailable:!1},tools:[]});i(t)}catch{i(`Failed to load description`)}}t()},[e]),(0,Z.jsx)(k,{title:(0,Z.jsxs)(Z.Fragment,{children:[o,s&&(0,Z.jsx)(w,{color:`success`,children:` [read-only]`}),c&&(0,Z.jsx)(w,{color:`error`,children:` [destructive]`}),l&&(0,Z.jsx)(w,{dimColor:!0,children:` [open-world]`})]}),subtitle:t.name,onCancel:n,inputGuide:e=>e.pending?(0,Z.jsxs)(w,{children:[`Press `,e.keyName,` again to exit`]}):(0,Z.jsx)(v,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`}),children:(0,Z.jsxs)(C,{flexDirection:`column`,children:[(0,Z.jsxs)(C,{children:[(0,Z.jsx)(w,{bold:!0,children:`Tool name: `}),(0,Z.jsx)(w,{dimColor:!0,children:a})]}),(0,Z.jsxs)(C,{children:[(0,Z.jsx)(w,{bold:!0,children:`Full name: `}),(0,Z.jsx)(w,{dimColor:!0,children:e.name})]}),r&&(0,Z.jsxs)(C,{flexDirection:`column`,marginTop:1,children:[(0,Z.jsx)(w,{bold:!0,children:`Description:`}),(0,Z.jsx)(w,{wrap:`wrap`,children:r})]}),e.inputJSONSchema&&e.inputJSONSchema.properties&&Object.keys(e.inputJSONSchema.properties).length>0&&(0,Z.jsxs)(C,{flexDirection:`column`,marginTop:1,children:[(0,Z.jsx)(w,{bold:!0,children:`Parameters:`}),(0,Z.jsx)(C,{marginLeft:2,flexDirection:`column`,children:Object.entries(e.inputJSONSchema.properties).map(([t,n])=>{let r=(e.inputJSONSchema?.required)?.includes(t);return(0,Z.jsxs)(w,{children:[`• `,t,r&&(0,Z.jsx)(w,{dimColor:!0,children:` (required)`}),`:`,` `,(0,Z.jsx)(w,{dimColor:!0,children:typeof n==`object`&&n&&`type`in n?String(n.type):`unknown`}),typeof n==`object`&&n&&`description`in n&&(0,Z.jsxs)(w,{dimColor:!0,children:[` - `,String(n.description)]})]},t)})})]})]})})}var X,Z,Fe=e((()=>{X=t(E(),1),O(),N(),u(),Z=A()}));function Ie({server:e,onSelectTool:t,onBack:n}){let r=ce(e=>e.mcp.tools),i=Le.useMemo(()=>e.client.type===`connected`?s(r,e.name):[],[e,r]),a=i.map((t,n)=>{let r=P(t.name,e.name),i=M(t.userFacingName?t.userFacingName({}):r),a=t.isReadOnly?.({})??!1,o=t.isDestructive?.({})??!1,s=t.isOpenWorld?.({})??!1,c=[];return a&&c.push(`read-only`),o&&c.push(`destructive`),s&&c.push(`open-world`),{label:i,value:n.toString(),description:c.length>0?c.join(`, `):void 0,descriptionColor:o?`error`:a?`success`:void 0}});return(0,Q.jsx)(k,{title:`Tools for ${e.name}`,subtitle:`${i.length} ${xe(i.length,`tool`)}`,onCancel:n,inputGuide:e=>e.pending?(0,Q.jsxs)(w,{children:[`Press `,e.keyName,` again to exit`]}):(0,Q.jsxs)(T,{children:[(0,Q.jsx)(S,{shortcut:`↑↓`,action:`navigate`}),(0,Q.jsx)(S,{shortcut:`Enter`,action:`select`}),(0,Q.jsx)(v,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]}),children:i.length===0?(0,Q.jsx)(w,{dimColor:!0,children:`No tools available`}):(0,Q.jsx)(ne,{options:a,onChange:e=>{let n=parseInt(e,10),r=i[n];r&&t(r,n)},onCancel:n})})}var Le,Q,Re=e((()=>{Le=t(E(),1),O(),N(),f(),x(),z(),u(),p(),Q=A()}));export{Ne as a,Me as c,Fe as i,Re as n,Y as o,Pe as r,je as s,Ie as t};
|