@readmagic/workmate 0.0.28 → 0.0.29
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-Bmgh8VS3.js → AddWorkspaceDirectory-C0lrhffT.js} +1 -1
- package/dist/chunks/AgentsMdExternalIncludesDialog-DIahWLha.js +1 -0
- package/dist/chunks/{AgentsMdExternalIncludesDialog-BJfHqScU.js → AgentsMdExternalIncludesDialog-Dmjjx4ql.js} +1 -1
- package/dist/chunks/App-COz7knHS.js +1 -0
- package/dist/chunks/{BackgroundTasksDialog-WkoL4g5Q.js → BackgroundTasksDialog-5IkCQ8lN.js} +2 -2
- package/dist/chunks/{BypassPermissionsModeDialog-BT9yl0Qt.js → BypassPermissionsModeDialog-g1FMGfQF.js} +1 -1
- package/dist/chunks/{CustomSelect-t4wXuXWH.js → CustomSelect-BsEd2To5.js} +1 -1
- package/dist/chunks/{DiffDialog-CXZxnb7Y.js → DiffDialog-Cwf8CdxZ.js} +5 -5
- package/dist/chunks/Doctor-CcLoI7tF.js +1 -0
- package/dist/chunks/Doctor-GmT5aeAc.js +3 -0
- package/dist/chunks/ExitFlow-DPgUFqeC.js +2 -0
- package/dist/chunks/{InvalidConfigDialog-riLYEaUP.js → InvalidConfigDialog-Di6HZYDV.js} +1 -1
- package/dist/chunks/{InvalidSettingsDialog-BGXl3V1A.js → InvalidSettingsDialog-BHL-MERJ.js} +1 -1
- package/dist/chunks/{KeybindingProviderSetup-syiDgtpB.js → KeybindingProviderSetup-eE3o0bfp.js} +1 -1
- package/dist/chunks/MCPConnectionManager-D-qpUJLV.js +1 -0
- package/dist/chunks/MCPToolListView-DtHRw4jQ.js +1 -0
- package/dist/chunks/{McpParsingWarnings-Czze2JPd.js → McpParsingWarnings-ByyErvR3.js} +1 -1
- package/dist/chunks/MessageSelector-CFz30wBL.js +3 -0
- package/dist/chunks/Messages-CfY-Oj3M.js +10 -0
- package/dist/chunks/{Onboarding-CD_Uv5h9.js → Onboarding-BfWLRx3n.js} +1 -1
- package/dist/chunks/{PromptInputFooterSuggestions-CHXJsTtQ.js → PromptInputFooterSuggestions-BRyJj7XR.js} +1 -1
- package/dist/chunks/{PromptInputHelpMenu-BZIVCV7V.js → PromptInputHelpMenu-DLuRCXVS.js} +1 -1
- package/dist/chunks/{ProviderSetup-CwMvjmjh.js → ProviderSetup-CKZGG2B9.js} +1 -1
- package/dist/chunks/QueryEngine-B27MOtBA.js +1 -0
- package/dist/chunks/{REPL-CtFtb35A.js → REPL-DMRD5wSN.js} +23 -23
- package/dist/chunks/REPL-gzolQvzu.js +1 -0
- package/dist/chunks/ResumeConversation-7eURPHmQ.js +1 -0
- package/dist/chunks/SearchExtraToolsTool-BINZTstr.js +1 -0
- package/dist/chunks/Settings-4TNYpfUs.js +2 -0
- package/dist/chunks/Spinner-BgjmQLjw.js +1 -0
- package/dist/chunks/{TextInput-ou7ZhpVY.js → TextInput-BVEWdRz9.js} +5 -5
- package/dist/chunks/{ThemePicker-CVFWqSc7.js → ThemePicker-th2jdUjh.js} +1 -1
- package/dist/chunks/{TrustDialog-CGXv_LF4.js → TrustDialog-YsYqHyRR.js} +1 -1
- package/dist/chunks/{_baseEach-BYhqv77g.js → _baseEach-Bz5fQbIq.js} +1 -1
- package/dist/chunks/{add-dir-BSizpuef.js → add-dir-BsO6l8Ue.js} +1 -1
- package/dist/chunks/{agentDisplay-JKfYFD1m.js → agentDisplay-ChkgiTIH.js} +1 -1
- package/dist/chunks/{agents-MEaV8P2G.js → agents-BV1nan6b.js} +6 -6
- package/dist/chunks/{agents-BDTCH6YB.js → agents-DqEB6iwV.js} +1 -1
- package/dist/chunks/allErrors-CkdguCDv.js +1 -0
- package/dist/chunks/{backgroundHousekeeping-CsXlkIg3.js → backgroundHousekeeping-1VsWy8xd.js} +1 -1
- package/dist/chunks/backgroundHousekeeping-pMtrl4K2.js +1 -0
- package/dist/chunks/{branch-BllXcYwS.js → branch-CTIHtpwz.js} +2 -2
- package/dist/chunks/{bridgeControl-aDnUrYZR.js → bridgeControl-C8xaGuwO.js} +1 -1
- package/dist/chunks/{btw-DzaRBa6o.js → btw-BA39Zrhm.js} +1 -1
- package/dist/chunks/caches-DHZHqVhf.js +1 -0
- package/dist/chunks/caches-fqs-Y-kW.js +1 -0
- package/dist/chunks/channel-B5FkNSZ3.js +1 -0
- package/dist/chunks/{channel-Gw6skpUh.js → channel-C5yKM1wf.js} +1 -1
- package/dist/chunks/{clear-CDQs9_5P.js → clear-BmlaYYrD.js} +1 -1
- package/dist/chunks/commands-EUcHifS4.js +1 -0
- package/dist/chunks/compact-D3uePeI7.js +2 -0
- package/dist/chunks/config-GgGdlJ9h.js +1 -0
- package/dist/chunks/{context-TkdzCK3Y.js → context-CBEWyVpE.js} +1 -1
- package/dist/chunks/{context-noninteractive-BcBo64vo.js → context-noninteractive-B03nuxfN.js} +2 -2
- package/dist/chunks/context-noninteractive-BLCyyyGL.js +1 -0
- package/dist/chunks/conversation-BFL0rEIx.js +1 -0
- package/dist/chunks/conversation-D-ker4RO.js +1 -0
- package/dist/chunks/{conversationRecovery-_hWC7JBO.js → conversationRecovery-Bt84CYO6.js} +1 -1
- package/dist/chunks/crossProjectResume-DwlYY6lV.js +40 -0
- package/dist/chunks/{diff-BzVUPO4Z.js → diff-CewYzu3Y.js} +1 -1
- package/dist/chunks/doctor-CrQ0UfG2.js +1 -0
- package/dist/chunks/{entry-333L52Lo.js → entry-DdVUdGWV.js} +3 -3
- package/dist/chunks/exit-QwCo2aJo.js +1 -0
- package/dist/chunks/{extraUsage-CmgRR-zH.js → extraUsage-Cu0aV35i.js} +1 -1
- package/dist/chunks/extractMemories-DHlbRc5g.js +1 -0
- package/dist/chunks/{fast-D7oNjaZ3.js → fast-BlhpCQ2f.js} +1 -1
- package/dist/chunks/fast-C3JeBy3A.js +1 -0
- package/dist/chunks/{fetchModelList-Cv1vWIpC.js → fetchModelList-DjFCMjVN.js} +1 -1
- package/dist/chunks/fetchModelList-L2XarfAj.js +1 -0
- package/dist/chunks/{fileSuggestions-DF3HTRKr.js → fileSuggestions-BRwKV_KA.js} +2 -2
- package/dist/chunks/{gemini-ou7_YyXc.js → gemini-I-M5_sUA.js} +2 -2
- package/dist/chunks/{generateSessionName-CeN9EZNY.js → generateSessionName-CJ0sh6HD.js} +1 -1
- package/dist/chunks/{goal-CCxo4Wyf.js → goal-DIrBBT5J.js} +3 -3
- package/dist/chunks/{grok-BMmUcNbI.js → grok-ZLjJN6b9.js} +1 -1
- package/dist/chunks/{help-CYtogTZk.js → help-CDMjVOl6.js} +1 -1
- package/dist/chunks/{hooks-ByVkvodY.js → hooks-BNKCE023.js} +2 -2
- package/dist/chunks/hooks-ERYtmuNW.js +1 -0
- package/dist/chunks/{install-DIxyfdXG.js → install-xlfTw1j6.js} +1 -1
- package/dist/chunks/{instrumentation-BmHivmxs.js → instrumentation-DSt0UvGn.js} +3 -3
- package/dist/chunks/{job-D534P26R.js → job-BVElGsu0.js} +1 -1
- package/dist/chunks/{launchLocalMemory-CWXLb3KF.js → launchLocalMemory-DUkJCKmd.js} +2 -2
- package/dist/chunks/{launchOnboarding-CocPmwzz.js → launchOnboarding-BvD-E_jC.js} +1 -1
- package/dist/chunks/loadAgentsDir-BImZsKrh.js +1 -0
- package/dist/chunks/{loadAgentsDir-bmpKLPdG.js → loadAgentsDir-BfLCckVj.js} +22 -22
- package/dist/chunks/loadPluginHooks-BPwWtBzO.js +1 -0
- package/dist/chunks/{localSearch-Da8cVYoI.js → localSearch-BHG8sp8p.js} +1 -1
- package/dist/chunks/localSearch-D3rvcRRC.js +1 -0
- package/dist/chunks/{logoUtils-qNuBc2nI.js → logoUtils-BsNLv-qi.js} +1 -1
- package/dist/chunks/{magicDocs-BsEiBLQl.js → magicDocs-Bue9vxzY.js} +2 -2
- package/dist/chunks/{main-B31aPMPP.js → main-U71X4Thd.js} +22 -22
- package/dist/chunks/{mcp-Dd8TBfQQ.js → mcp-C4CxCMwJ.js} +3 -3
- package/dist/chunks/mcp-D9HFARDy.js +1 -0
- package/dist/chunks/mcp-De3QGKvT.js +2 -0
- package/dist/chunks/memory-DVRdJFfI.js +1 -0
- package/dist/chunks/{mode-SM8doWgC.js → mode-Bd5w-RBX.js} +2 -2
- package/dist/chunks/{model-C2r-PaR4.js → model-BCIcUhrc.js} +1 -1
- package/dist/chunks/{model-Dd3x121y.js → model-BIf2i1is.js} +1 -1
- package/dist/chunks/{modelOptions-BQL4gbNk.js → modelOptions-COIU5U3w.js} +1 -1
- package/dist/chunks/{nativeInstaller-DMkZdsof.js → nativeInstaller-CGSNzGNn.js} +1 -1
- package/dist/chunks/{notifications-BwS1XsnZ.js → notifications-B5gzCmPC.js} +1 -1
- package/dist/chunks/{onChangeAppState-C9cYQJPF.js → onChangeAppState-NWwSE-I4.js} +1 -1
- package/dist/chunks/{openai-Bea4I2Od.js → openai-CyJ3m4dI.js} +2 -2
- package/dist/chunks/{overlayContext-C5WPACKC.js → overlayContext-DYrGDe63.js} +1 -1
- package/dist/chunks/{partition-CKgWl7p4.js → partition-BavNaw1S.js} +1 -1
- package/dist/chunks/permissions-CLYcBXIu.js +3 -0
- package/dist/chunks/{pidLock-CqkC3-nD.js → pidLock-Bao7SU6Z.js} +2 -2
- package/dist/chunks/{plan-Ce6wfjjI.js → plan-Dwj_ZX8G.js} +1 -1
- package/dist/chunks/plugin-Cscvf8st.js +17 -0
- package/dist/chunks/{pluginAutoupdate-ByokIVEs.js → pluginAutoupdate-D5XyiZrP.js} +1 -1
- package/dist/chunks/pluginBlocklist-CpkjXXKQ.js +1 -0
- package/dist/chunks/pluginCliCommands-DmLsxs1M.js +1 -0
- package/dist/chunks/{pluginFlagging-B2ZX5_oB.js → pluginFlagging-CRuX6sHR.js} +1 -1
- package/dist/chunks/pluginOperations-orq3bOCp.js +2 -0
- package/dist/chunks/{pluginStartupCheck-QG0d95dE.js → pluginStartupCheck-DGDl1WOZ.js} +1 -1
- package/dist/chunks/pluginStartupCheck-GHO77nmg.js +1 -0
- package/dist/chunks/plugins-Cq5c-Qs1.js +4 -0
- package/dist/chunks/{print-dUT7E1g9.js → print-zo7Z--Ll.js} +9 -9
- package/dist/chunks/processBashCommand-C7oVqf0B.js +1 -0
- package/dist/chunks/processSlashCommand-CPQB5_0w.js +5 -0
- package/dist/chunks/prompt-CAzFDybL.js +1 -0
- package/dist/chunks/prompt-Cm8SKZXY.js +1 -0
- package/dist/chunks/{prompt-BnDapYGL.js → prompt-DaYH88Oe.js} +1 -1
- package/dist/chunks/{reconciler-C_HKsocm.js → reconciler-B5Kr4do0.js} +1 -1
- package/dist/chunks/refresh-DurNMJeS.js +1 -0
- package/dist/chunks/{reject-Tug1RmkE.js → reject-CzjtO3fU.js} +1 -1
- package/dist/chunks/{reload-plugins-CL9LWzpq.js → reload-plugins-C38i_Eb3.js} +1 -1
- package/dist/chunks/rename-BV-3ZpFx.js +1 -0
- package/dist/chunks/{resume-BZ42SpS2.js → resume-CUzQIor4.js} +2 -2
- package/dist/chunks/{runtimeObserver-DT5P2_XL.js → runtimeObserver-BKoQ5IEO.js} +4 -4
- package/dist/chunks/{runtimeObserver-BLq2guVy.js → runtimeObserver-Ess1Cn8Y.js} +1 -1
- package/dist/chunks/sandbox-adapter-ClRO21Ci.js +1 -0
- package/dist/chunks/{sandbox-toggle-DghmaJhK.js → sandbox-toggle-Bp6Xpjh3.js} +1 -1
- package/dist/chunks/searchExtraTools-CV_fkuD6.js +1 -0
- package/dist/chunks/{select-CaxQ-BVq.js → select-Bm29ymsI.js} +1 -1
- package/dist/chunks/sessionFileAccessHooks-B5kAD4ol.js +1 -0
- package/dist/chunks/{sessionObserver-DBoZUvWL.js → sessionObserver-CBlzrJt1.js} +1 -1
- package/dist/chunks/sessionObserver-CayxkuxO.js +1 -0
- package/dist/chunks/sessionStorage-vLxCo1Mh.js +1 -0
- package/dist/chunks/{sessionTracing-5a7HDF4e.js → sessionTracing-TDsq54Uc.js} +1 -1
- package/dist/chunks/setup-BbyfyeQk.js +3 -0
- package/dist/chunks/{shadowedRuleDetection-L3tnySui.js → shadowedRuleDetection-BG3jtA9Y.js} +1 -1
- package/dist/chunks/{sideQuestion-BJTVma-5.js → sideQuestion-C8GNVo4R.js} +3 -3
- package/dist/chunks/{sinks-CV0SWuZW.js → sinks-BafJR6Fw.js} +1 -1
- package/dist/chunks/sinks-CHtjg7sn.js +1 -0
- package/dist/chunks/skillChangeDetector-CY17weG4.js +1 -0
- package/dist/chunks/{skillGapStore-Cposc03e.js → skillGapStore-Cl4J1WoZ.js} +2 -2
- package/dist/chunks/{skillLifecycle-RXQp0JU7.js → skillLifecycle-DdfeUHBf.js} +2 -2
- package/dist/chunks/{skillSearchPanel-B2pjskqk.js → skillSearchPanel-DtQYF9gN.js} +4 -4
- package/dist/chunks/{skills-D2ZjMtv4.js → skills-Fd12LJal.js} +1 -1
- package/dist/chunks/status-CGEMRiPI.js +1 -0
- package/dist/chunks/statusNoticeHelpers-D0tonVy0.js +1 -0
- package/dist/chunks/{switcher-rep86o4_.js → switcher-BCq9Az_q.js} +1 -1
- package/dist/chunks/switcher-DQMr6Anx.js +1 -0
- package/dist/chunks/{tasks-B4coTfrq.js → tasks-DQmkY_xD.js} +1 -1
- package/dist/chunks/{templateJobs-C5ukh6H3.js → templateJobs-CEDUbFAY.js} +1 -1
- package/dist/chunks/{theme-7RmvErYJ.js → theme-DQjJ4R0o.js} +1 -1
- package/dist/chunks/tipRegistry-BwxZ_G0j.js +2 -0
- package/dist/chunks/{toolEventObserver-Dzwzi5Vi.js → toolEventObserver-DdZ30on9.js} +1 -1
- package/dist/chunks/toolPool-CWIXwdX7.js +1 -0
- package/dist/chunks/{useExitOnCtrlCDWithKeybindings-BT0nexZw.js → useExitOnCtrlCDWithKeybindings-ClrtNKJ6.js} +1 -1
- package/dist/chunks/useMainLoopModel-CULw8pB_.js +1 -0
- package/dist/chunks/{useManagePlugins-pGaGzsEg.js → useManagePlugins-CmsPSHor.js} +1 -1
- package/dist/chunks/useMergedTools-C8PxReh0.js +1 -0
- package/dist/chunks/{useSearchInput-j12K4wEo.js → useSearchInput-BZhTzjgN.js} +1 -1
- package/dist/chunks/useSettingsErrors-GWIxCYyd.js +1 -0
- package/dist/chunks/{util-CCEK8oze.js → util-Bih2g-pV.js} +1 -1
- package/dist/chunks/validatePlugin-BwcC_Wbr.js +1 -0
- package/dist/chunks/worktree-BB9lFWBB.js +1 -0
- package/dist/cli.js +1 -1
- package/package.json +1 -1
- package/dist/chunks/AgentsMdExternalIncludesDialog-BjbUilCE.js +0 -1
- package/dist/chunks/App-COdpsR2w.js +0 -1
- package/dist/chunks/Doctor-B6isid5K.js +0 -1
- package/dist/chunks/Doctor-COj-tZBc.js +0 -3
- package/dist/chunks/ExitFlow-CcMYH5iI.js +0 -2
- package/dist/chunks/MCPConnectionManager-C7RmKzJh.js +0 -1
- package/dist/chunks/MCPToolListView-CewNLJus.js +0 -1
- package/dist/chunks/MessageSelector-Kc6JlnDX.js +0 -3
- package/dist/chunks/Messages-BvFYO4Zn.js +0 -10
- package/dist/chunks/QueryEngine-DAwfp_ht.js +0 -1
- package/dist/chunks/REPL-tFT1FGQF.js +0 -1
- package/dist/chunks/ResumeConversation-CERzSBvg.js +0 -1
- package/dist/chunks/SearchExtraToolsTool-ndh4aEwQ.js +0 -1
- package/dist/chunks/Settings-CPaqWNdP.js +0 -2
- package/dist/chunks/Spinner-C0qHjfIY.js +0 -1
- package/dist/chunks/allErrors-Dhnf6rqg.js +0 -1
- package/dist/chunks/backgroundHousekeeping-Bu-zRFCx.js +0 -1
- package/dist/chunks/caches-CMF-MmR-.js +0 -1
- package/dist/chunks/caches-CW5YnYNS.js +0 -1
- package/dist/chunks/channel-DVx21qde.js +0 -1
- package/dist/chunks/commands-CfYMwgP7.js +0 -1
- package/dist/chunks/compact-6F2tuItE.js +0 -2
- package/dist/chunks/config-BDkzWBnL.js +0 -1
- package/dist/chunks/context-noninteractive-oFcnY1Er.js +0 -1
- package/dist/chunks/conversation-CYZyg1U1.js +0 -1
- package/dist/chunks/conversation-DXzlRhNw.js +0 -1
- package/dist/chunks/crossProjectResume-CCo3iZrB.js +0 -40
- package/dist/chunks/doctor-B4jQbGQr.js +0 -1
- package/dist/chunks/exit-D5DYnRvR.js +0 -1
- package/dist/chunks/extractMemories-CVUrBFMj.js +0 -1
- package/dist/chunks/fast-CRhW9zha.js +0 -1
- package/dist/chunks/fetchModelList-DIa1HwAJ.js +0 -1
- package/dist/chunks/hooks-CBGUcyCs.js +0 -1
- package/dist/chunks/loadAgentsDir-Zw648oQO.js +0 -1
- package/dist/chunks/loadPluginHooks-BIfM53-_.js +0 -1
- package/dist/chunks/localSearch-Dbj8cXyO.js +0 -1
- package/dist/chunks/mcp-BMeWtYCx.js +0 -2
- package/dist/chunks/mcp-CYbesbfl.js +0 -1
- package/dist/chunks/memory-DtQQGyPS.js +0 -1
- package/dist/chunks/permissions-Dv_PCfY0.js +0 -3
- package/dist/chunks/plugin-aK4tDrVg.js +0 -17
- package/dist/chunks/pluginBlocklist-ByRQaVPu.js +0 -1
- package/dist/chunks/pluginCliCommands-Dyk4HYHs.js +0 -1
- package/dist/chunks/pluginOperations-BCvJvfOC.js +0 -2
- package/dist/chunks/pluginStartupCheck-o_TC7wIt.js +0 -1
- package/dist/chunks/plugins-DzsTDNWJ.js +0 -4
- package/dist/chunks/processBashCommand-DtGCgTkF.js +0 -1
- package/dist/chunks/processSlashCommand-wXblpK2C.js +0 -5
- package/dist/chunks/prompt-BdH2zk0S.js +0 -1
- package/dist/chunks/prompt-D0TFER0A.js +0 -1
- package/dist/chunks/refresh-Cm4jZzLa.js +0 -1
- package/dist/chunks/rename-OfKJSazJ.js +0 -1
- package/dist/chunks/sandbox-adapter-982rx2cm.js +0 -1
- package/dist/chunks/searchExtraTools-B4N1bpy0.js +0 -1
- package/dist/chunks/sessionFileAccessHooks-BqQ58T7e.js +0 -1
- package/dist/chunks/sessionObserver-qYpA90El.js +0 -1
- package/dist/chunks/sessionStorage-CC0v4zMs.js +0 -1
- package/dist/chunks/setup-DVLnIlse.js +0 -3
- package/dist/chunks/sinks-C9NdbjLo.js +0 -1
- package/dist/chunks/skillChangeDetector-DlodgOyC.js +0 -1
- package/dist/chunks/status-BcSkj9nE.js +0 -1
- package/dist/chunks/statusNoticeHelpers-DsrqBOQt.js +0 -1
- package/dist/chunks/switcher-BietN6il.js +0 -1
- package/dist/chunks/tipRegistry-BYpJZIjR.js +0 -2
- package/dist/chunks/toolPool-BGfiNj6h.js +0 -1
- package/dist/chunks/useMainLoopModel-QuE7VkgX.js +0 -1
- package/dist/chunks/useMergedTools-BLsIT3R_.js +0 -1
- package/dist/chunks/useSettingsErrors-C8VIzdws.js +0 -1
- package/dist/chunks/validatePlugin-CTVnWx9H.js +0 -1
- package/dist/chunks/worktree-BWL0vR4o.js +0 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{i as n,o as r}from"./envUtils-QyzA_cFM.js";import{n as i,t as a}from"./figures-5ThXQEtq.js";import{C as o,D as s,I as c,P as l,T as u,Wt as d,ai as f,di as p,fi as m,t as h,y as g}from"./src-BX54x08P.js";import{t as _}from"./jsx-runtime-Bb4Xn-E0.js";import{$n as v,K as y,Qn as b,X as x,fn as ee,mn as S,nt as te,rn as C,rt as ne,tn as re}from"./settings-D4M13toi.js";import{hr as ie,mr as ae}from"./state-CXY-q5gr.js";import{
|
|
1
|
+
import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{i as n,o as r}from"./envUtils-QyzA_cFM.js";import{n as i,t as a}from"./figures-5ThXQEtq.js";import{C as o,D as s,I as c,P as l,T as u,Wt as d,ai as f,di as p,fi as m,t as h,y as g}from"./src-BX54x08P.js";import{t as _}from"./jsx-runtime-Bb4Xn-E0.js";import{$n as v,K as y,Qn as b,X as x,fn as ee,mn as S,nt as te,rn as C,rt as ne,tn as re}from"./settings-D4M13toi.js";import{hr as ie,mr as ae}from"./state-CXY-q5gr.js";import{Ap as oe,Bl as se,Bm as ce,Cp as le,Df as ue,Dl as de,Dm as fe,Ef as pe,El as me,Fm as he,Fu as ge,Hh as _e,Hv as ve,Hy as ye,Im as be,L_ as xe,Mp as Se,Mu as Ce,Nm as we,Nu as Te,Oc as Ee,Of as De,Ol as Oe,Om as ke,Pm as Ae,Pu as je,Q as Me,R_ as Ne,Sp as Pe,Tf as Fe,Tp as Ie,Vh as Le,Vl as Re,Vm as ze,Vv as Be,Vy as Ve,Wh as He,Xi as Ue,_d as w,bp as We,c as Ge,dd as Ke,et as qe,fa as Je,gd as T,gw as Ye,hw as Xe,it as Ze,kc as Qe,kl as $e,kp as et,l as tt,mw as nt,nf as rt,nt as it,o as at,pd as ot,qS as st,r as ct,rb as E,ry as lt,s as ut,t as dt,tS as ft,tf as pt,vm as mt,vp as ht,wp as gt,xp as _t,ym as vt,yp as yt}from"./loadAgentsDir-BfLCckVj.js";import{n as bt,t as xt}from"./cwd-DrEEb4f5.js";import{H as St,I as Ct,N as wt,S as Tt,V as Et,Y as Dt,x as Ot}from"./debug-2pVES-2G.js";import{C as kt,T as At}from"./config-Bio2EjUK.js";import{o as jt,s as Mt}from"./log-L1kqxa_P.js";import{n as Nt}from"./analytics-COpjZpvd.js";import{S as Pt,_ as Ft}from"./startupProfiler-B9Qv2QGH.js";import{l as It,n as Lt,o as Rt}from"./stringUtils-Cs6E5f-B.js";import{_n as zt,vn as Bt}from"./prompt-DaYH88Oe.js";import{n as Vt,t as Ht}from"./_baseSlice-D67_NpZ1.js";import{a as Ut,i as Wt,n as Gt,o as Kt,r as qt,t as Jt}from"./agentDisplay-ChkgiTIH.js";import{n as Yt,t as Xt}from"./useExitOnCtrlCDWithKeybindings-ClrtNKJ6.js";import{n as Zt,t as Qt}from"./TextInput-BVEWdRz9.js";import{n as $t,t as en}from"./select-Bm29ymsI.js";import{r as tn,t as nn}from"./Spinner-BgjmQLjw.js";import{n as rn,t as an}from"./useMergedTools-C8PxReh0.js";import{n as on,r as sn,t as cn}from"./promptEditor-14TB3MYt.js";import{n as ln,t as un}from"./useMainLoopModel-CULw8pB_.js";import{join as D}from"path";import{mkdir as dn,open as fn,unlink as pn}from"fs/promises";function mn(e,t,n){var r=e.length;return n=n===void 0?r:n,!t&&n>=r?e:Ht(e,t,n)}var hn=e((()=>{Vt()}));function gn(e){return _n.test(e)}var _n,vn=e((()=>{_n=RegExp(`[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]`)}));function yn(e){return e.split(``)}var bn=e((()=>{}));function xn(e){return e.match(Rn)||[]}var Sn,Cn,wn,Tn,En,Dn,On,kn,An,jn,Mn,Nn,Pn,Fn,In,Ln,Rn,zn=e((()=>{Sn=`\\ud800-\\udfff`,Cn=`\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff`,wn=`\\ufe0e\\ufe0f`,Tn=`[`+Sn+`]`,En=`[`+Cn+`]`,Dn=`\\ud83c[\\udffb-\\udfff]`,On=`(?:`+En+`|`+Dn+`)`,kn=`[^`+Sn+`]`,An=`(?:\\ud83c[\\udde6-\\uddff]){2}`,jn=`[\\ud800-\\udbff][\\udc00-\\udfff]`,Mn=`\\u200d`,Nn=On+`?`,Pn=`[`+wn+`]?`,Fn=`(?:`+Mn+`(?:`+[kn,An,jn].join(`|`)+`)`+Pn+Nn+`)*`,In=Pn+Nn+Fn,Ln=`(?:`+[kn+En+`?`,En,An,jn,Tn].join(`|`)+`)`,Rn=RegExp(Dn+`(?=`+Dn+`)|`+Ln+In,`g`)}));function Bn(e){return gn(e)?xn(e):yn(e)}var Vn=e((()=>{bn(),vn(),zn()}));function Hn(e){return function(t){t=ie(t);var n=gn(t)?Bn(t):void 0,r=n?n[0]:t.charAt(0),i=n?mn(n,1).join(``):t.slice(1);return r[e]()+i}}var Un=e((()=>{hn(),vn(),Vn(),ae()})),Wn,Gn=e((()=>{Un(),Wn=Hn(`toUpperCase`)}));function Kn(e){return Wn(ie(e).toLowerCase())}var qn=e((()=>{ae(),Gn()})),O,Jn=e((()=>{O={FOLDER_NAME:`.workmate`,AGENTS_DIR:`agents`}}));function Yn(e,t,n,r,i,a,o){return`---
|
|
2
2
|
name: ${e}
|
|
3
3
|
description: "${t.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`).replace(/\n/g,`\\\\n`)}"${n===void 0||n.length===1&&n[0]===`*`?``:`\ntools: ${n.join(`, `)}`}${a?`\nmodel: ${a}`:``}${i?`\ncolor: ${i}`:``}${o?`\nmemory: ${o}`:``}
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
${r}
|
|
7
|
-
`}function Xn(e){switch(e){case`flagSettings`:throw Error(`Cannot get directory path for ${e} agents`);case`userSettings`:return D(n(),O.AGENTS_DIR);case`projectSettings`:return D(xt(),O.FOLDER_NAME,O.AGENTS_DIR);case`policySettings`:return D(re(),O.FOLDER_NAME,O.AGENTS_DIR);case`localSettings`:return D(xt(),O.FOLDER_NAME,O.AGENTS_DIR)}}function Zn(e){switch(e){case`projectSettings`:return D(`.`,O.FOLDER_NAME,O.AGENTS_DIR);default:return Xn(e)}}function Qn(e){return D(Xn(e.source),`${e.agentType}.md`)}function $n(e){if(e.source===`built-in`)return`Built-in`;if(e.source===`plugin`)throw Error(`Cannot get file path for plugin agents`);return D(Xn(e.source),`${e.filename||e.agentType}.md`)}function er(e){return e.source===`built-in`?`Built-in`:D(Zn(e.source),`${e.agentType}.md`)}function tr(e){return ot(e)?`Built-in`:$e(e)?`Plugin: ${e.plugin||`Unknown`}`:e.source===`flagSettings`?`CLI argument`:D(Zn(e.source),`${e.filename||e.agentType}.md`)}async function nr(e){let t=Xn(e);return await dn(t,{recursive:!0}),t}async function rr(e,t,n,r,i,a=!0,o,s,c){if(e===`built-in`)throw Error(`Cannot save built-in agents`);await nr(e);let l=Qn({source:e,agentType:t}),u=Yn(t,n,r,i,o,s,c);try{await or(l,u,a?`wx`:`w`)}catch(e){throw wt(e)===`EEXIST`?Error(`Agent file already exists: ${l}`):e}}async function ir(e,t,n,r,i,a,o){if(e.source===`built-in`)throw Error(`Cannot update built-in agents`);await or($n(e),Yn(e.agentType,t,n,r,i,a,o))}async function ar(e){if(e.source===`built-in`)throw Error(`Cannot delete built-in agents`);let t=$n(e);try{await pn(t)}catch(e){if(wt(e)!==`ENOENT`)throw e}}async function or(e,t,n=`w`){let r=await fn(e,n);try{await r.writeFile(t,{encoding:`utf-8`}),await r.datasync()}finally{await r.close()}}var sr=e((()=>{C(),rt(),bt(),r(),Ct(),Jn()}));function cr({agent:e,tools:t,onBack:n}){let r=ut(e,t,!1),i=tr(e),o=pt(e.agentType);d(`confirm:no`,n,{context:`Confirmation`});let s=e=>{e.key===`return`&&(e.preventDefault(),n())};function u(){return r.hasWildcard?(0,k.jsx)(l,{children:`All tools`}):!e.tools||e.tools.length===0?(0,k.jsx)(l,{children:`None`}):(0,k.jsxs)(k.Fragment,{children:[r.validTools.length>0&&(0,k.jsx)(l,{children:r.validTools.join(`, `)}),r.invalidTools.length>0&&(0,k.jsxs)(l,{color:`warning`,children:[a.warning,` Unrecognized: `,r.invalidTools.join(`, `)]})]})}return(0,k.jsxs)(c,{flexDirection:`column`,gap:1,tabIndex:0,autoFocus:!0,onKeyDown:s,children:[(0,k.jsx)(l,{dimColor:!0,children:i}),(0,k.jsxs)(c,{flexDirection:`column`,children:[(0,k.jsxs)(l,{children:[(0,k.jsx)(l,{bold:!0,children:`Description`}),` (tells Work Mate when to use this agent):`]}),(0,k.jsx)(c,{marginLeft:2,children:(0,k.jsx)(l,{children:e.whenToUse})})]}),(0,k.jsxs)(c,{children:[(0,k.jsxs)(l,{children:[(0,k.jsx)(l,{bold:!0,children:`Tools`}),`:`,` `]}),u()]}),(0,k.jsxs)(l,{children:[(0,k.jsx)(l,{bold:!0,children:`Model`}),`: `,_e(e.model)]}),e.permissionMode&&(0,k.jsxs)(l,{children:[(0,k.jsx)(l,{bold:!0,children:`Permission mode`}),`: `,e.permissionMode]}),e.memory&&(0,k.jsxs)(l,{children:[(0,k.jsx)(l,{bold:!0,children:`Memory`}),`: `,Je(e.memory)]}),e.hooks&&Object.keys(e.hooks).length>0&&(0,k.jsxs)(l,{children:[(0,k.jsx)(l,{bold:!0,children:`Hooks`}),`: `,Object.keys(e.hooks).join(`, `)]}),e.skills&&e.skills.length>0&&(0,k.jsxs)(l,{children:[(0,k.jsx)(l,{bold:!0,children:`Skills`}),`:`,` `,e.skills.length>10?`${e.skills.length} skills`:e.skills.join(`, `)]}),o&&(0,k.jsx)(c,{children:(0,k.jsxs)(l,{children:[(0,k.jsx)(l,{bold:!0,children:`Color`}),`:`,` `,(0,k.jsxs)(l,{backgroundColor:o,color:`inverseText`,children:[` `,e.agentType,` `]})]})}),!ot(e)&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(c,{children:(0,k.jsxs)(l,{children:[(0,k.jsx)(l,{bold:!0,children:`System prompt`}),`:`]})}),(0,k.jsx)(c,{marginLeft:2,marginRight:2,children:(0,k.jsx)(et,{children:e.getSystemPrompt()})})]})]})}var k,lr=e((()=>{i(),h(),E(),Ie(),it(),He(),rt(),ce(),Ge(),sr(),k=_()}));function ur({agentName:e,currentColor:t=`automatic`,onConfirm:n}){let[r,i]=(0,dr.useState)(Math.max(0,j.indexOf(t))),o=e=>{if(e.key===`up`)e.preventDefault(),i(e=>e>0?e-1:j.length-1);else if(e.key===`down`)e.preventDefault(),i(e=>e<j.length-1?e+1:0);else if(e.key===`return`){e.preventDefault();let t=j[r];n(t===`automatic`?void 0:t)}},s=j[r];return(0,A.jsxs)(c,{flexDirection:`column`,gap:1,tabIndex:0,autoFocus:!0,onKeyDown:o,children:[(0,A.jsx)(c,{flexDirection:`column`,children:j.map((e,t)=>{let n=t===r;return(0,A.jsxs)(c,{flexDirection:`row`,gap:1,children:[(0,A.jsx)(l,{color:n?`suggestion`:void 0,children:n?a.pointer:` `}),e===`automatic`?(0,A.jsx)(l,{bold:n,children:`Automatic color`}):(0,A.jsxs)(c,{gap:1,children:[(0,A.jsx)(l,{backgroundColor:Ue[e],color:`inverseText`,children:` `}),(0,A.jsx)(l,{bold:n,children:Lt(e)})]})]},e)})}),(0,A.jsxs)(c,{marginTop:1,children:[(0,A.jsx)(l,{children:`Preview: `}),s===void 0||s===`automatic`?(0,A.jsxs)(l,{inverse:!0,bold:!0,children:[` `,`@`,e,` `]}):(0,A.jsxs)(l,{backgroundColor:Ue[s],color:`inverseText`,bold:!0,children:[` `,`@`,e,` `]})]})]})}var dr,A,j,fr=e((()=>{i(),dr=t(f(),1),h(),Ie(),Rt(),A=_(),j=[`automatic`,...mt]}));function pr({initialModel:e,onComplete:t,onCancel:n}){let r=mr.useMemo(()=>{let t=je();return e&&!t.some(t=>t.value===e)?[{value:e,label:e,description:`Current model (custom ID)`},...t]:t},[e]);return(0,hr.jsxs)(c,{flexDirection:`column`,children:[(0,hr.jsx)(c,{marginBottom:1,children:(0,hr.jsx)(l,{dimColor:!0,children:`Model determines the agent's reasoning capabilities and speed.`})}),(0,hr.jsx)(en,{options:r,defaultValue:e??`sonnet`,onChange:t,onCancel:()=>n?n():t(void 0)})]})}var mr,hr,gr=e((()=>{mr=t(f(),1),h(),ce(),$t(),hr=_()}));function _r(){return{READ_ONLY:{name:`Read-only tools`,toolNames:new Set([Ze.name,ke.name,ft.name,yt.name,ze.name,Pe.name,be.name,Le.name,pe.name])},EDIT:{name:`Edit tools`,toolNames:new Set([Oe.name,Fe.name,le.name])},EXECUTION:{name:`Execution tools`,toolNames:new Set([Ye.name])},MCP:{name:`MCP tools`,toolNames:new Set,isMcp:!0},OTHER:{name:`Other tools`,toolNames:new Set}}}function vr(e){let t=new Map;return e.forEach(e=>{if(Ke(e)){let n=ne(e.name);if(n?.serverName){let r=t.get(n.serverName)||[];r.push(e),t.set(n.serverName,r)}}}),Array.from(t.entries()).map(([e,t])=>({serverName:e,tools:t})).sort((e,t)=>e.serverName.localeCompare(t.serverName))}function yr({tools:e,initialTools:t,onComplete:n,onCancel:r}){let i=(0,M.useMemo)(()=>Xe({tools:e,isBuiltIn:!1,isAsync:!1}),[e]),[s,u]=(0,M.useState)(!t||t.includes(`*`)?i.map(e=>e.name):t),[f,p]=(0,M.useState)(0),[m,h]=(0,M.useState)(!1),g=(0,M.useMemo)(()=>{let e=new Set(i.map(e=>e.name));return s.filter(t=>e.has(t))},[s,i]),_=new Set(g),v=g.length===i.length&&i.length>0,y=e=>{e&&u(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},x=(e,t)=>{u(n=>{if(t){let t=e.filter(e=>!n.includes(e));return[...n,...t]}else return n.filter(t=>!e.includes(t))})},ee=()=>{let e=i.map(e=>e.name);n(g.length===e.length&&e.every(e=>g.includes(e))?void 0:g)},S=(0,M.useMemo)(()=>{let e=_r(),t={readOnly:[],edit:[],execution:[],mcp:[],other:[]};return i.forEach(n=>{Ke(n)?t.mcp.push(n):e.READ_ONLY.toolNames.has(n.name)?t.readOnly.push(n):e.EDIT.toolNames.has(n.name)?t.edit.push(n):e.EXECUTION.toolNames.has(n.name)?t.execution.push(n):n.name!==`Agent`&&t.other.push(n)}),t},[i]),te=e=>{let t=b(e,e=>_.has(e.name))<e.length;return()=>{let n=e.map(e=>e.name);x(n,t)}},C=[];C.push({id:`continue`,label:`Continue`,action:ee,isContinue:!0}),C.push({id:`bucket-all`,label:`${v?a.checkboxOn:a.checkboxOff} All tools`,action:()=>{let e=i.map(e=>e.name);x(e,!v)}});let re=_r();[{id:`bucket-readonly`,name:re.READ_ONLY.name,tools:S.readOnly},{id:`bucket-edit`,name:re.EDIT.name,tools:S.edit},{id:`bucket-execution`,name:re.EXECUTION.name,tools:S.execution},{id:`bucket-mcp`,name:re.MCP.name,tools:S.mcp},{id:`bucket-other`,name:re.OTHER.name,tools:S.other}].forEach(({id:e,name:t,tools:n})=>{if(n.length===0)return;let r=b(n,e=>_.has(e.name))===n.length;C.push({id:e,label:`${r?a.checkboxOn:a.checkboxOff} ${t}`,action:te(n)})});let ie=C.length;C.push({id:`toggle-individual`,label:m?`Hide advanced options`:`Show advanced options`,action:()=>{h(!m),m&&f>ie&&p(ie)},isToggle:!0});let ae=(0,M.useMemo)(()=>vr(i),[i]);return m&&(ae.length>0&&(C.push({id:`mcp-servers-header`,label:`MCP Servers:`,action:()=>{},isHeader:!0}),ae.forEach(({serverName:e,tools:t})=>{let n=b(t,e=>_.has(e.name))===t.length;C.push({id:`mcp-server-${e}`,label:`${n?a.checkboxOn:a.checkboxOff} ${e} (${t.length} ${It(t.length,`tool`)})`,action:()=>{let e=t.map(e=>e.name);x(e,!n)}})}),C.push({id:`tools-header`,label:`Individual Tools:`,action:()=>{},isHeader:!0})),i.forEach(e=>{let t=e.name;if(e.name.startsWith(`mcp__`)){let n=ne(e.name);t=n?`${n.toolName} (${n.serverName})`:e.name}C.push({id:`tool-${e.name}`,label:`${_.has(e.name)?a.checkboxOn:a.checkboxOff} ${t}`,action:()=>y(e.name)})})),d(`confirm:no`,(0,M.useCallback)(()=>{r?r():n(t)},[r,n,t]),{context:`Confirmation`}),(0,N.jsxs)(c,{flexDirection:`column`,marginTop:1,tabIndex:0,autoFocus:!0,onKeyDown:e=>{if(e.key===`return`){e.preventDefault();let t=C[f];t&&!t.isHeader&&t.action()}else if(e.key===`up`){e.preventDefault();let t=f-1;for(;t>0&&C[t]?.isHeader;)t--;p(Math.max(0,t))}else if(e.key===`down`){e.preventDefault();let t=f+1;for(;t<C.length-1&&C[t]?.isHeader;)t++;p(Math.min(C.length-1,t))}},children:[(0,N.jsxs)(l,{color:f===0?`suggestion`:void 0,bold:f===0,children:[f===0?`${a.pointer} `:` `,`[ Continue ]`]}),(0,N.jsx)(o,{width:40}),C.slice(1).map((e,t)=>{let n=t+1===f,r=e.isToggle,i=e.isHeader;return(0,N.jsxs)(M.Fragment,{children:[r&&(0,N.jsx)(o,{width:40}),i&&t>0&&(0,N.jsx)(c,{marginTop:1}),(0,N.jsxs)(l,{color:i?void 0:n?`suggestion`:void 0,dimColor:i,bold:r&&n,children:[i?``:n?`${a.pointer} `:` `,r?`[ ${e.label} ]`:e.label]})]},e.id)}),(0,N.jsx)(c,{marginTop:1,flexDirection:`column`,children:(0,N.jsx)(l,{dimColor:!0,children:v?`All tools selected`:`${_.size} of ${i.length} tools selected`})})]})}var M,N,br=e((()=>{i(),M=t(f(),1),te(),oe(),He(),x(),Ve(),Re(),Ae(),fe(),_t(),De(),Me(),ye(),Qe(),dt(),ge(),gt(),xe(),h(),E(),v(),Rt(),N=_()}));function xr(e){return e===`all`?`Agents`:e===`built-in`?`Built-in agents`:e===`plugin`?`Plugin agents`:Kn(ee(e))}var Sr=e((()=>{qn(),S()}));function Cr({agent:e,tools:t,onSaved:n,onBack:r}){let i=we(),[o,s]=(0,P.useState)(`menu`),[u,f]=(0,P.useState)(0),[m,h]=(0,P.useState)(null),[g,_]=(0,P.useState)(e.color),v=(0,P.useCallback)(async()=>{let t=await cn($n(e));t.error?h(t.error):n(`Opened ${e.agentType} in editor. If you made edits, restart to load the latest version.`)},[e,n]),y=(0,P.useCallback)(async(t={})=>{let{tools:r,color:a,model:o}=t,s=a??g,c=r!==void 0,l=o!==void 0,u=s!==e.color;if(!c&&!l&&!u)return!1;try{return!We(e)&&!$e(e)?!1:(await ir(e,e.whenToUse,r??e.tools,e.getSystemPrompt(),s,o??e.model),u&&s&&me(e.agentType,s),i(t=>{let n=t.agentDefinitions.allAgents.map(t=>t.agentType===e.agentType?{...t,tools:r??t.tools,color:s,model:o??t.model}:t);return{...t,agentDefinitions:{...t.agentDefinitions,activeAgents:at(n),allAgents:n}}}),n(`Updated agent: ${p.bold(e.agentType)}`),!0)}catch(e){return h(e instanceof Error?e.message:`Failed to save agent`),!1}},[e,g,n,i]),b=(0,P.useMemo)(()=>[{label:`Open in editor`,action:v},{label:`Edit tools`,action:()=>s(`edit-tools`)},{label:`Edit model`,action:()=>s(`edit-model`)},{label:`Edit color`,action:()=>s(`edit-color`)}],[v]),x=(0,P.useCallback)(()=>{h(null),o===`menu`?r():s(`menu`)},[o,r]),ee=(0,P.useCallback)(e=>{if(e.key===`up`)e.preventDefault(),f(e=>Math.max(0,e-1));else if(e.key===`down`)e.preventDefault(),f(e=>Math.min(b.length-1,e+1));else if(e.key===`return`){e.preventDefault();let t=b[u];t&&t.action()}},[b,u]);d(`confirm:no`,x,{context:`Confirmation`});let S=()=>(0,F.jsxs)(c,{flexDirection:`column`,tabIndex:0,autoFocus:!0,onKeyDown:ee,children:[(0,F.jsxs)(l,{dimColor:!0,children:[`Source: `,xr(e.source)]}),(0,F.jsx)(c,{marginTop:1,flexDirection:`column`,children:b.map((e,t)=>(0,F.jsxs)(l,{color:t===u?`suggestion`:void 0,children:[t===u?`${a.pointer} `:` `,e.label]},e.label))}),m&&(0,F.jsx)(c,{marginTop:1,children:(0,F.jsx)(l,{color:`error`,children:m})})]});switch(o){case`menu`:return S();case`edit-tools`:return(0,F.jsx)(yr,{tools:t,initialTools:e.tools,onComplete:async e=>{s(`menu`),await y({tools:e})}});case`edit-color`:return(0,F.jsx)(ur,{agentName:e.agentType,currentColor:g||e.color||`automatic`,onConfirm:async e=>{_(e),s(`menu`),await y({color:e})}});case`edit-model`:return(0,F.jsx)(pr,{initialModel:e.model,onComplete:async e=>{s(`menu`),await y({model:e})}});default:return null}}var P,F,wr=e((()=>{m(),i(),P=t(f(),1),ht(),h(),E(),Ie(),rt(),sn(),sr(),fr(),gr(),br(),Sr(),F=_()}));function Tr({instructions:e=`Press ↑↓ to navigate · Enter to select · Esc to go back`}){let t=Yt();return(0,Er.jsx)(c,{marginLeft:2,children:(0,Er.jsx)(l,{dimColor:!0,children:t.pending?`Press ${t.keyName} again to exit`:e})})}var Er,Dr=e((()=>{Xt(),h(),Er=_()}));function Or({source:e,agents:t,onBack:n,onSelect:r,onCreateNew:i,changes:s}){let[u,d]=kr.useState(null),[f,p]=kr.useState(!0),m=kr.useMemo(()=>[...t].sort(Gt),[t]),h=e=>({isOverridden:!!e.overriddenBy,overriddenBy:e.overriddenBy||null}),_=()=>(0,I.jsxs)(c,{children:[(0,I.jsx)(l,{color:f?`suggestion`:void 0,children:f?`${a.pointer} `:` `}),(0,I.jsx)(l,{color:f?`suggestion`:void 0,children:`Create new agent`})]}),v=e=>{let t=e.source===`built-in`,n=!t&&!f&&u?.agentType===e.agentType&&u?.source===e.source,{isOverridden:r,overriddenBy:i}=h(e),o=t||r,s=!t&&n?`suggestion`:void 0,d=Ut(e);return(0,I.jsxs)(c,{children:[(0,I.jsx)(l,{dimColor:o&&!n,color:s,children:t?``:n?`${a.pointer} `:` `}),(0,I.jsx)(l,{dimColor:o&&!n,color:s,children:e.agentType}),d&&(0,I.jsxs)(l,{dimColor:!0,color:s,children:[` · `,d]}),e.memory&&(0,I.jsxs)(l,{dimColor:!0,color:s,children:[` · `,e.memory,` memory`]}),i&&(0,I.jsxs)(l,{dimColor:!n,color:n?`warning`:void 0,children:[` `,a.warning,` shadowed by `,qt(i)]})]},`${e.agentType}-${e.source}`)},y=kr.useMemo(()=>{let t=m.filter(e=>e.source!==`built-in`);return e===`all`?Jt.filter(e=>e.source!==`built-in`).flatMap(({source:e})=>t.filter(t=>t.source===e)):t},[m,e]);kr.useEffect(()=>{!u&&!f&&y.length>0&&(i?p(!0):d(y[0]||null))},[y,u,f,i]);let x=e=>{if(e.key===`return`){e.preventDefault(),f&&i?i():u&&r(u);return}if(e.key!==`up`&&e.key!==`down`)return;e.preventDefault();let t=!!i,n=y.length+ +!!t;if(n===0)return;let a=0;if(!f&&u){let e=y.findIndex(e=>e.agentType===u.agentType&&e.source===u.source);e>=0&&(a=t?e+1:e)}let o=e.key===`up`?a===0?n-1:a-1:a===n-1?0:a+1;if(t&&o===0)p(!0),d(null);else{let e=t?o-1:o,n=y[e];n&&(p(!1),d(n))}},ee=(e=`Built-in (always available):`)=>{let t=m.filter(e=>e.source===`built-in`);return(0,I.jsxs)(c,{flexDirection:`column`,marginBottom:1,paddingLeft:2,children:[(0,I.jsx)(l,{bold:!0,dimColor:!0,children:e}),t.map(v)]})},S=(e,t)=>{if(!t.length)return null;let n=t[0]?.baseDir;return(0,I.jsxs)(c,{flexDirection:`column`,marginBottom:1,children:[(0,I.jsxs)(c,{paddingLeft:2,children:[(0,I.jsx)(l,{bold:!0,dimColor:!0,children:e}),n&&(0,I.jsxs)(l,{dimColor:!0,children:[` (`,n,`)`]})]}),t.map(e=>v(e))]})},te=xr(e),C=m.filter(e=>e.source===`built-in`);return!m.length||e!==`built-in`&&!m.some(e=>e.source!==`built-in`)?(0,I.jsx)(g,{title:te,subtitle:`No agents found`,onCancel:n,hideInputGuide:!0,children:(0,I.jsxs)(c,{flexDirection:`column`,gap:1,tabIndex:0,autoFocus:!0,onKeyDown:x,children:[i&&(0,I.jsx)(c,{children:_()}),(0,I.jsx)(l,{dimColor:!0,children:`No agents found. Create specialized subagents that Work Mate can delegate to.`}),(0,I.jsx)(l,{dimColor:!0,children:`Each subagent has its own context window, custom system prompt, and specific tools.`}),(0,I.jsx)(l,{dimColor:!0,children:`Try creating: Code Reviewer, Code Simplifier, Security Reviewer, Tech Lead, or UX Reviewer.`}),e!==`built-in`&&m.some(e=>e.source===`built-in`)&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(o,{}),ee()]})]})}):(0,I.jsxs)(g,{title:te,subtitle:`${b(m,e=>!e.overriddenBy)} agents`,onCancel:n,hideInputGuide:!0,children:[s&&s.length>0&&(0,I.jsx)(c,{marginTop:1,children:(0,I.jsx)(l,{dimColor:!0,children:s[s.length-1]})}),(0,I.jsxs)(c,{flexDirection:`column`,tabIndex:0,autoFocus:!0,onKeyDown:x,children:[i&&(0,I.jsx)(c,{marginBottom:1,children:_()}),e===`all`?(0,I.jsxs)(I.Fragment,{children:[Jt.filter(e=>e.source!==`built-in`).map(({label:e,source:t})=>(0,I.jsx)(kr.Fragment,{children:S(e,m.filter(e=>e.source===t))},t)),C.length>0&&(0,I.jsxs)(c,{flexDirection:`column`,marginBottom:1,paddingLeft:2,children:[(0,I.jsxs)(l,{dimColor:!0,children:[(0,I.jsx)(l,{bold:!0,children:`Built-in agents`}),` (always available)`]}),C.map(v)]})]}):e===`built-in`?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(l,{dimColor:!0,italic:!0,children:`Built-in agents are provided by default and cannot be modified.`}),(0,I.jsx)(c,{marginTop:1,flexDirection:`column`,children:m.map(e=>v(e))})]}):(0,I.jsxs)(I.Fragment,{children:[m.filter(e=>e.source!==`built-in`).map(e=>v(e)),m.some(e=>e.source===`built-in`)&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(o,{}),ee()]})]})]})]})}var kr,I,Ar=e((()=>{i(),kr=t(f(),1),h(),Wt(),v(),Sr(),I=_()}));function jr({steps:e,initialData:t={},onComplete:n,onCancel:r,children:i,title:a,showStepCounter:o=!0}){let[s,c]=(0,L.useState)(0),[l,u]=(0,L.useState)(t),[d,f]=(0,L.useState)(!1),[p,m]=(0,L.useState)([]);Yt(),(0,L.useEffect)(()=>{d&&(m([]),n(l))},[d,l,n]);let h=(0,L.useCallback)(()=>{s<e.length-1?(p.length>0&&m(e=>[...e,s]),c(e=>e+1)):f(!0)},[s,e.length,p]),g=(0,L.useCallback)(()=>{if(p.length>0){let e=p[p.length-1];e!==void 0&&(m(e=>e.slice(0,-1)),c(e))}else s>0?c(e=>e-1):r&&r()},[s,p,r]),_=(0,L.useCallback)(t=>{t>=0&&t<e.length&&(m(e=>[...e,s]),c(t))},[s,e.length]),v=(0,L.useCallback)(()=>{m([]),r&&r()},[r]),y=(0,L.useCallback)(e=>{u(t=>({...t,...e}))},[]),b=(0,L.useMemo)(()=>({currentStepIndex:s,totalSteps:e.length,wizardData:l,setWizardData:u,updateWizardData:y,goNext:h,goBack:g,goToStep:_,cancel:v,title:a,showStepCounter:o}),[s,e.length,l,y,h,g,_,v,a,o]),x=e[s];return!x||d?null:(0,Mr.jsx)(Nr.Provider,{value:b,children:i||(0,Mr.jsx)(x,{})})}var L,Mr,Nr,Pr=e((()=>{L=t(f(),1),Xt(),Mr=_(),Nr=(0,L.createContext)(null)}));function R(){let e=(0,Fr.useContext)(Nr);if(!e)throw Error(`useWizard must be used within a WizardProvider`);return e}var Fr,Ir=e((()=>{Fr=t(f(),1),Pr()}));function Lr({instructions:e=(0,z.jsxs)(u,{children:[(0,z.jsx)(s,{shortcut:`↑↓`,action:`navigate`}),(0,z.jsx)(s,{shortcut:`Enter`,action:`select`}),(0,z.jsx)(T,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]})}){let t=Yt();return(0,z.jsx)(c,{marginLeft:3,marginTop:1,children:(0,z.jsx)(l,{dimColor:!0,children:t.pending?`Press ${t.keyName} again to exit`:e})})}var z,Rr=e((()=>{Xt(),h(),w(),z=_()}));function B({title:e,color:t=`suggestion`,children:n,subtitle:r,footerText:i}){let{currentStepIndex:a,totalSteps:o,title:s,showStepCounter:c,goBack:l}=R();return(0,zr.jsxs)(zr.Fragment,{children:[(0,zr.jsx)(g,{title:`${e||s||`Wizard`}${c===!1?``:` (${a+1}/${o})`}`,subtitle:r,onCancel:l,color:t,hideInputGuide:!0,isCancelActive:!1,children:n}),(0,zr.jsx)(Lr,{instructions:i})]})}var zr,V=e((()=>{h(),Ir(),Rr(),zr=_()})),H=e((()=>{Ir(),V(),Rr(),Pr()}));function Br(){let{goNext:e,goBack:t,updateWizardData:n,wizardData:r}=R();return d(`confirm:no`,t,{context:`Confirmation`}),(0,U.jsx)(B,{subtitle:`Choose background color`,footerText:(0,U.jsxs)(u,{children:[(0,U.jsx)(s,{shortcut:`↑↓`,action:`navigate`}),(0,U.jsx)(s,{shortcut:`Enter`,action:`select`}),(0,U.jsx)(T,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]}),children:(0,U.jsx)(c,{children:(0,U.jsx)(ur,{agentName:r.agentType||`agent`,currentColor:`automatic`,onConfirm:t=>{n({selectedColor:t,finalAgent:{agentType:r.agentType,whenToUse:r.whenToUse,getSystemPrompt:()=>r.systemPrompt,tools:r.selectedTools,...r.selectedModel?{model:r.selectedModel}:{},...t?{color:t}:{},source:r.location}}),e()}})})})}var U,Vr=e((()=>{h(),E(),w(),H(),V(),fr(),U=_()}));function Hr(e){return e?/^[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]$/.test(e)?e.length<3?`Agent type must be at least 3 characters long`:e.length>50?`Agent type must be less than 50 characters`:null:`Agent type must start and end with alphanumeric characters and contain only letters, numbers, and hyphens`:`Agent type is required`}function Ur(e,t,n){let r=[],i=[];if(!e.agentType)r.push(`Agent type is required`);else{let t=Hr(e.agentType);t&&r.push(t);let i=n.find(t=>t.agentType===e.agentType&&t.source!==e.source);i&&r.push(`Agent type "${e.agentType}" already exists in ${xr(i.source)}`)}if(e.whenToUse?e.whenToUse.length<10?i.push(`Description should be more descriptive (at least 10 characters)`):e.whenToUse.length>5e3&&i.push(`Description is very long (over 5000 characters)`):r.push(`Description (description) is required`),e.tools!==void 0&&!Array.isArray(e.tools))r.push(`Tools must be an array`);else{e.tools===void 0?i.push(`Agent has access to all tools`):e.tools.length===0&&i.push(`No tools selected - agent will have very limited capabilities`);let n=ut(e,t,!1);n.invalidTools.length>0&&r.push(`Invalid tools: ${n.invalidTools.join(`, `)}`)}let a=e.getSystemPrompt();return a?a.length<20?r.push(`System prompt is too short (minimum 20 characters)`):a.length>1e4&&i.push(`System prompt is very long (over 10,000 characters)`):r.push(`System prompt is required`),{isValid:r.length===0,errors:r,warnings:i}}var Wr=e((()=>{He(),Sr()}));function Gr({tools:e,existingAgents:t,onSave:n,onSaveAndEdit:r,error:i}){let{goBack:a,wizardData:o}=R();d(`confirm:no`,a,{context:`Confirmation`});let f=e=>{e.key===`s`||e.key===`return`?(e.preventDefault(),n()):e.key===`e`&&(e.preventDefault(),r())},p=o.finalAgent,m=Ur(p,e,t),h=Pt(p.getSystemPrompt(),240),g=Pt(p.whenToUse,240),_=e=>e===void 0?`All tools`:e.length===0?`None`:e.length===1?e[0]||`None`:e.length===2?e.join(` and `):`${e.slice(0,-1).join(`, `)}, and ${e[e.length-1]}`,v=At()?(0,W.jsxs)(l,{children:[(0,W.jsx)(l,{bold:!0,children:`Memory`}),`: `,Je(p.memory)]}):null;return(0,W.jsx)(B,{subtitle:`Confirm and save`,footerText:(0,W.jsxs)(u,{children:[(0,W.jsx)(s,{shortcut:`s/Enter`,action:`save`}),(0,W.jsx)(s,{shortcut:`e`,action:`edit in your editor`}),(0,W.jsx)(T,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]}),children:(0,W.jsxs)(c,{flexDirection:`column`,tabIndex:0,autoFocus:!0,onKeyDown:f,children:[(0,W.jsxs)(l,{children:[(0,W.jsx)(l,{bold:!0,children:`Name`}),`: `,p.agentType]}),(0,W.jsxs)(l,{children:[(0,W.jsx)(l,{bold:!0,children:`Location`}),`:`,` `,er({source:o.location,agentType:p.agentType})]}),(0,W.jsxs)(l,{children:[(0,W.jsx)(l,{bold:!0,children:`Tools`}),`: `,_(p.tools)]}),(0,W.jsxs)(l,{children:[(0,W.jsx)(l,{bold:!0,children:`Model`}),`: `,_e(p.model)]}),v,(0,W.jsx)(c,{marginTop:1,children:(0,W.jsxs)(l,{children:[(0,W.jsx)(l,{bold:!0,children:`Description`}),` (tells Work Mate when to use this agent):`]})}),(0,W.jsx)(c,{marginLeft:2,marginTop:1,children:(0,W.jsx)(l,{children:g})}),(0,W.jsx)(c,{marginTop:1,children:(0,W.jsxs)(l,{children:[(0,W.jsx)(l,{bold:!0,children:`System prompt`}),`:`]})}),(0,W.jsx)(c,{marginLeft:2,marginTop:1,children:(0,W.jsx)(l,{children:h})}),m.warnings.length>0&&(0,W.jsxs)(c,{marginTop:1,flexDirection:`column`,children:[(0,W.jsx)(l,{color:`warning`,children:`Warnings:`}),m.warnings.map((e,t)=>(0,W.jsxs)(l,{dimColor:!0,children:[` `,`• `,e]},t))]}),m.errors.length>0&&(0,W.jsxs)(c,{marginTop:1,flexDirection:`column`,children:[(0,W.jsx)(l,{color:`error`,children:`Errors:`}),m.errors.map((e,t)=>(0,W.jsxs)(l,{color:`error`,children:[` `,`• `,e]},t))]}),i&&(0,W.jsx)(c,{marginTop:1,children:(0,W.jsx)(l,{color:`error`,children:i})}),(0,W.jsx)(c,{marginTop:2,children:(0,W.jsxs)(l,{color:`success`,children:[`Press `,(0,W.jsx)(l,{bold:!0,children:`s`}),` or `,(0,W.jsx)(l,{bold:!0,children:`Enter`}),` to save, `,(0,W.jsx)(l,{bold:!0,children:`e`}),` to save and edit`]})})]})})}var W,Kr=e((()=>{h(),E(),kt(),it(),Ft(),ce(),w(),H(),V(),sr(),Wr(),W=_()}));function qr({tools:e,existingAgents:t,onComplete:n}){let{wizardData:r}=R(),[i,a]=(0,Jr.useState)(null),o=we(),s=(0,Jr.useCallback)(async e=>{if(r?.finalAgent)try{await rr(r.location,r.finalAgent.agentType,r.finalAgent.whenToUse,r.finalAgent.tools,r.finalAgent.getSystemPrompt(),!0,r.finalAgent.color,r.finalAgent.model,r.finalAgent.memory),o(e=>{if(!r.finalAgent)return e;let t=e.agentDefinitions.allAgents.concat(r.finalAgent);return{...e,agentDefinitions:{...e.agentDefinitions,activeAgents:at(t),allAgents:t}}}),st(),e&&await cn(Qn({source:r.location,agentType:r.finalAgent.agentType})),r.finalAgent.agentType,r.wasGenerated,r.location,r.finalAgent.tools?.length,r.finalAgent.model,r.finalAgent.color,r.finalAgent.memory,r.finalAgent.memory,{...e?{opened_in_editor:!0}:{}},n(e?`Created agent: ${p.bold(r.finalAgent.agentType)} and opened in editor. If you made edits, restart to load the latest version.`:`Created agent: ${p.bold(r.finalAgent.agentType)}`)}catch(e){a(e instanceof Error?e.message:`Failed to save agent`)}},[r,n,o]);return(0,Yr.jsx)(Gr,{tools:e,existingAgents:t,onSave:(0,Jr.useCallback)(()=>s(!1),[s]),onSaveAndEdit:(0,Jr.useCallback)(()=>s(!0),[s]),error:i})}var Jr,Yr,Xr=e((()=>{m(),Jr=t(f(),1),Nt(),ht(),rt(),sn(),H(),sr(),Kr(),Yr=_()}));function Zr(){let{goNext:e,goBack:t,updateWizardData:n,wizardData:r}=R(),[i,a]=(0,Qr.useState)(r.whenToUse||``),[o,f]=(0,Qr.useState)(i.length),[p,m]=(0,Qr.useState)(null);return d(`confirm:no`,t,{context:`Settings`}),d(`chat:externalEditor`,(0,Qr.useCallback)(async()=>{let e=await on(i);e.content!==null&&(a(e.content),f(e.content.length))},[i]),{context:`Chat`}),(0,G.jsx)(B,{subtitle:`Description (tell Work Mate when to use this agent)`,footerText:(0,G.jsxs)(u,{children:[(0,G.jsx)(s,{shortcut:`Type`,action:`enter text`}),(0,G.jsx)(s,{shortcut:`Enter`,action:`continue`}),(0,G.jsx)(T,{action:`chat:externalEditor`,context:`Chat`,fallback:`ctrl+g`,description:`open in editor`}),(0,G.jsx)(T,{action:`confirm:no`,context:`Settings`,fallback:`Esc`,description:`go back`})]}),children:(0,G.jsxs)(c,{flexDirection:`column`,children:[(0,G.jsx)(l,{children:`When should Work Mate use this agent?`}),(0,G.jsx)(c,{marginTop:1,children:(0,G.jsx)(Qt,{value:i,onChange:a,onSubmit:t=>{let r=t.trim();if(!r){m(`Description is required`);return}m(null),n({whenToUse:r}),e()},placeholder:`e.g., use this agent after you're done writing code...`,columns:80,cursorOffset:o,onChangeCursorOffset:f,focus:!0,showCursor:!0})}),p&&(0,G.jsx)(c,{marginTop:1,children:(0,G.jsx)(l,{color:`error`,children:p})})]})})}var Qr,G,$r=e((()=>{Qr=t(f(),1),h(),E(),sn(),w(),Zt(),H(),V(),G=_()}));async function ei(e,t,n,r){let i=se({content:`Create an agent configuration based on this request: "${e}".${n.length>0?`\n\nIMPORTANT: The following identifiers already exist and must NOT be used: ${n.join(`, `)}`:``}
|
|
8
|
-
Return ONLY the JSON object, no other text.`}),a=await
|
|
9
|
-
`),u;try{u=Tt(l.trim())}catch{let e=l.match(/\{[\s\S]*\}/);if(!e)throw Error(`No JSON object found in response`);u=Tt(e[0])}if(!u.identifier||!u.whenToUse||!u.systemPrompt)throw Error(`Invalid agent configuration generated`);return u.identifier,{identifier:u.identifier,whenToUse:u.whenToUse,systemPrompt:u.systemPrompt}}var ti,ni,ri=e((()=>{
|
|
7
|
+
`}function Xn(e){switch(e){case`flagSettings`:throw Error(`Cannot get directory path for ${e} agents`);case`userSettings`:return D(n(),O.AGENTS_DIR);case`projectSettings`:return D(xt(),O.FOLDER_NAME,O.AGENTS_DIR);case`policySettings`:return D(re(),O.FOLDER_NAME,O.AGENTS_DIR);case`localSettings`:return D(xt(),O.FOLDER_NAME,O.AGENTS_DIR)}}function Zn(e){switch(e){case`projectSettings`:return D(`.`,O.FOLDER_NAME,O.AGENTS_DIR);default:return Xn(e)}}function Qn(e){return D(Xn(e.source),`${e.agentType}.md`)}function $n(e){if(e.source===`built-in`)return`Built-in`;if(e.source===`plugin`)throw Error(`Cannot get file path for plugin agents`);return D(Xn(e.source),`${e.filename||e.agentType}.md`)}function er(e){return e.source===`built-in`?`Built-in`:D(Zn(e.source),`${e.agentType}.md`)}function tr(e){return ut(e)?`Built-in`:tt(e)?`Plugin: ${e.plugin||`Unknown`}`:e.source===`flagSettings`?`CLI argument`:D(Zn(e.source),`${e.filename||e.agentType}.md`)}async function nr(e){let t=Xn(e);return await dn(t,{recursive:!0}),t}async function rr(e,t,n,r,i,a=!0,o,s,c){if(e===`built-in`)throw Error(`Cannot save built-in agents`);await nr(e);let l=Qn({source:e,agentType:t}),u=Yn(t,n,r,i,o,s,c);try{await or(l,u,a?`wx`:`w`)}catch(e){throw wt(e)===`EEXIST`?Error(`Agent file already exists: ${l}`):e}}async function ir(e,t,n,r,i,a,o){if(e.source===`built-in`)throw Error(`Cannot update built-in agents`);await or($n(e),Yn(e.agentType,t,n,r,i,a,o))}async function ar(e){if(e.source===`built-in`)throw Error(`Cannot delete built-in agents`);let t=$n(e);try{await pn(t)}catch(e){if(wt(e)!==`ENOENT`)throw e}}async function or(e,t,n=`w`){let r=await fn(e,n);try{await r.writeFile(t,{encoding:`utf-8`}),await r.datasync()}finally{await r.close()}}var sr=e((()=>{C(),at(),bt(),r(),Ct(),Jn()}));function cr({agent:e,tools:t,onBack:n}){let r=We(e,t,!1),i=tr(e),o=le(e.agentType);d(`confirm:no`,n,{context:`Confirmation`});let s=e=>{e.key===`return`&&(e.preventDefault(),n())};function u(){return r.hasWildcard?(0,k.jsx)(l,{children:`All tools`}):!e.tools||e.tools.length===0?(0,k.jsx)(l,{children:`None`}):(0,k.jsxs)(k.Fragment,{children:[r.validTools.length>0&&(0,k.jsx)(l,{children:r.validTools.join(`, `)}),r.invalidTools.length>0&&(0,k.jsxs)(l,{color:`warning`,children:[a.warning,` Unrecognized: `,r.invalidTools.join(`, `)]})]})}return(0,k.jsxs)(c,{flexDirection:`column`,gap:1,tabIndex:0,autoFocus:!0,onKeyDown:s,children:[(0,k.jsx)(l,{dimColor:!0,children:i}),(0,k.jsxs)(c,{flexDirection:`column`,children:[(0,k.jsxs)(l,{children:[(0,k.jsx)(l,{bold:!0,children:`Description`}),` (tells Work Mate when to use this agent):`]}),(0,k.jsx)(c,{marginLeft:2,children:(0,k.jsx)(l,{children:e.whenToUse})})]}),(0,k.jsxs)(c,{children:[(0,k.jsxs)(l,{children:[(0,k.jsx)(l,{bold:!0,children:`Tools`}),`:`,` `]}),u()]}),(0,k.jsxs)(l,{children:[(0,k.jsx)(l,{bold:!0,children:`Model`}),`: `,et(e.model)]}),e.permissionMode&&(0,k.jsxs)(l,{children:[(0,k.jsx)(l,{bold:!0,children:`Permission mode`}),`: `,e.permissionMode]}),e.memory&&(0,k.jsxs)(l,{children:[(0,k.jsx)(l,{bold:!0,children:`Memory`}),`: `,nt(e.memory)]}),e.hooks&&Object.keys(e.hooks).length>0&&(0,k.jsxs)(l,{children:[(0,k.jsx)(l,{bold:!0,children:`Hooks`}),`: `,Object.keys(e.hooks).join(`, `)]}),e.skills&&e.skills.length>0&&(0,k.jsxs)(l,{children:[(0,k.jsx)(l,{bold:!0,children:`Skills`}),`:`,` `,e.skills.length>10?`${e.skills.length} skills`:e.skills.join(`, `)]}),o&&(0,k.jsx)(c,{children:(0,k.jsxs)(l,{children:[(0,k.jsx)(l,{bold:!0,children:`Color`}),`:`,` `,(0,k.jsxs)(l,{backgroundColor:o,color:`inverseText`,children:[` `,e.agentType,` `]})]})}),!ut(e)&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(c,{children:(0,k.jsxs)(l,{children:[(0,k.jsx)(l,{bold:!0,children:`System prompt`}),`:`]})}),(0,k.jsx)(c,{marginLeft:2,marginRight:2,children:(0,k.jsx)(Ke,{children:e.getSystemPrompt()})})]})]})}var k,lr=e((()=>{i(),h(),E(),gt(),Xe(),yt(),at(),Se(),ot(),sr(),k=_()}));function ur({agentName:e,currentColor:t=`automatic`,onConfirm:n}){let[r,i]=(0,dr.useState)(Math.max(0,j.indexOf(t))),o=e=>{if(e.key===`up`)e.preventDefault(),i(e=>e>0?e-1:j.length-1);else if(e.key===`down`)e.preventDefault(),i(e=>e<j.length-1?e+1:0);else if(e.key===`return`){e.preventDefault();let t=j[r];n(t===`automatic`?void 0:t)}},s=j[r];return(0,A.jsxs)(c,{flexDirection:`column`,gap:1,tabIndex:0,autoFocus:!0,onKeyDown:o,children:[(0,A.jsx)(c,{flexDirection:`column`,children:j.map((e,t)=>{let n=t===r;return(0,A.jsxs)(c,{flexDirection:`row`,gap:1,children:[(0,A.jsx)(l,{color:n?`suggestion`:void 0,children:n?a.pointer:` `}),e===`automatic`?(0,A.jsx)(l,{bold:n,children:`Automatic color`}):(0,A.jsxs)(c,{gap:1,children:[(0,A.jsx)(l,{backgroundColor:Pe[e],color:`inverseText`,children:` `}),(0,A.jsx)(l,{bold:n,children:Lt(e)})]})]},e)})}),(0,A.jsxs)(c,{marginTop:1,children:[(0,A.jsx)(l,{children:`Preview: `}),s===void 0||s===`automatic`?(0,A.jsxs)(l,{inverse:!0,bold:!0,children:[` `,`@`,e,` `]}):(0,A.jsxs)(l,{backgroundColor:Pe[s],color:`inverseText`,bold:!0,children:[` `,`@`,e,` `]})]})]})}var dr,A,j,fr=e((()=>{i(),dr=t(f(),1),h(),gt(),Rt(),A=_(),j=[`automatic`,..._t]}));function pr({initialModel:e,onComplete:t,onCancel:n}){let r=mr.useMemo(()=>{let t=oe();return e&&!t.some(t=>t.value===e)?[{value:e,label:e,description:`Current model (custom ID)`},...t]:t},[e]);return(0,hr.jsxs)(c,{flexDirection:`column`,children:[(0,hr.jsx)(c,{marginBottom:1,children:(0,hr.jsx)(l,{dimColor:!0,children:`Model determines the agent's reasoning capabilities and speed.`})}),(0,hr.jsx)(en,{options:r,defaultValue:e??`sonnet`,onChange:t,onCancel:()=>n?n():t(void 0)})]})}var mr,hr,gr=e((()=>{mr=t(f(),1),h(),Se(),$t(),hr=_()}));function _r(){return{READ_ONLY:{name:`Read-only tools`,toolNames:new Set([we.name,he.name,me.name,Ve.name,fe.name,se.name,Oe.name,ue.name,Fe.name])},EDIT:{name:`Edit tools`,toolNames:new Set([je.name,ce.name,Ce.name])},EXECUTION:{name:`Execution tools`,toolNames:new Set([mt.name])},MCP:{name:`MCP tools`,toolNames:new Set,isMcp:!0},OTHER:{name:`Other tools`,toolNames:new Set}}}function vr(e){let t=new Map;return e.forEach(e=>{if(rt(e)){let n=ne(e.name);if(n?.serverName){let r=t.get(n.serverName)||[];r.push(e),t.set(n.serverName,r)}}}),Array.from(t.entries()).map(([e,t])=>({serverName:e,tools:t})).sort((e,t)=>e.serverName.localeCompare(t.serverName))}function yr({tools:e,initialTools:t,onComplete:n,onCancel:r}){let i=(0,M.useMemo)(()=>ht({tools:e,isBuiltIn:!1,isAsync:!1}),[e]),[s,u]=(0,M.useState)(!t||t.includes(`*`)?i.map(e=>e.name):t),[f,p]=(0,M.useState)(0),[m,h]=(0,M.useState)(!1),g=(0,M.useMemo)(()=>{let e=new Set(i.map(e=>e.name));return s.filter(t=>e.has(t))},[s,i]),_=new Set(g),v=g.length===i.length&&i.length>0,y=e=>{e&&u(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},x=(e,t)=>{u(n=>{if(t){let t=e.filter(e=>!n.includes(e));return[...n,...t]}else return n.filter(t=>!e.includes(t))})},ee=()=>{let e=i.map(e=>e.name);n(g.length===e.length&&e.every(e=>g.includes(e))?void 0:g)},S=(0,M.useMemo)(()=>{let e=_r(),t={readOnly:[],edit:[],execution:[],mcp:[],other:[]};return i.forEach(n=>{rt(n)?t.mcp.push(n):e.READ_ONLY.toolNames.has(n.name)?t.readOnly.push(n):e.EDIT.toolNames.has(n.name)?t.edit.push(n):e.EXECUTION.toolNames.has(n.name)?t.execution.push(n):n.name!==`Agent`&&t.other.push(n)}),t},[i]),te=e=>{let t=b(e,e=>_.has(e.name))<e.length;return()=>{let n=e.map(e=>e.name);x(n,t)}},C=[];C.push({id:`continue`,label:`Continue`,action:ee,isContinue:!0}),C.push({id:`bucket-all`,label:`${v?a.checkboxOn:a.checkboxOff} All tools`,action:()=>{let e=i.map(e=>e.name);x(e,!v)}});let re=_r();[{id:`bucket-readonly`,name:re.READ_ONLY.name,tools:S.readOnly},{id:`bucket-edit`,name:re.EDIT.name,tools:S.edit},{id:`bucket-execution`,name:re.EXECUTION.name,tools:S.execution},{id:`bucket-mcp`,name:re.MCP.name,tools:S.mcp},{id:`bucket-other`,name:re.OTHER.name,tools:S.other}].forEach(({id:e,name:t,tools:n})=>{if(n.length===0)return;let r=b(n,e=>_.has(e.name))===n.length;C.push({id:e,label:`${r?a.checkboxOn:a.checkboxOff} ${t}`,action:te(n)})});let ie=C.length;C.push({id:`toggle-individual`,label:m?`Hide advanced options`:`Show advanced options`,action:()=>{h(!m),m&&f>ie&&p(ie)},isToggle:!0});let ae=(0,M.useMemo)(()=>vr(i),[i]);return m&&(ae.length>0&&(C.push({id:`mcp-servers-header`,label:`MCP Servers:`,action:()=>{},isHeader:!0}),ae.forEach(({serverName:e,tools:t})=>{let n=b(t,e=>_.has(e.name))===t.length;C.push({id:`mcp-server-${e}`,label:`${n?a.checkboxOn:a.checkboxOff} ${e} (${t.length} ${It(t.length,`tool`)})`,action:()=>{let e=t.map(e=>e.name);x(e,!n)}})}),C.push({id:`tools-header`,label:`Individual Tools:`,action:()=>{},isHeader:!0})),i.forEach(e=>{let t=e.name;if(e.name.startsWith(`mcp__`)){let n=ne(e.name);t=n?`${n.toolName} (${n.serverName})`:e.name}C.push({id:`tool-${e.name}`,label:`${_.has(e.name)?a.checkboxOn:a.checkboxOff} ${t}`,action:()=>y(e.name)})})),d(`confirm:no`,(0,M.useCallback)(()=>{r?r():n(t)},[r,n,t]),{context:`Confirmation`}),(0,N.jsxs)(c,{flexDirection:`column`,marginTop:1,tabIndex:0,autoFocus:!0,onKeyDown:e=>{if(e.key===`return`){e.preventDefault();let t=C[f];t&&!t.isHeader&&t.action()}else if(e.key===`up`){e.preventDefault();let t=f-1;for(;t>0&&C[t]?.isHeader;)t--;p(Math.max(0,t))}else if(e.key===`down`){e.preventDefault();let t=f+1;for(;t<C.length-1&&C[t]?.isHeader;)t++;p(Math.min(C.length-1,t))}},children:[(0,N.jsxs)(l,{color:f===0?`suggestion`:void 0,bold:f===0,children:[f===0?`${a.pointer} `:` `,`[ Continue ]`]}),(0,N.jsx)(o,{width:40}),C.slice(1).map((e,t)=>{let n=t+1===f,r=e.isToggle,i=e.isHeader;return(0,N.jsxs)(M.Fragment,{children:[r&&(0,N.jsx)(o,{width:40}),i&&t>0&&(0,N.jsx)(c,{marginTop:1}),(0,N.jsxs)(l,{color:i?void 0:n?`suggestion`:void 0,dimColor:i,bold:r&&n,children:[i?``:n?`${a.pointer} `:` `,r?`[ ${e.label} ]`:e.label]})]},e.id)}),(0,N.jsx)(c,{marginTop:1,flexDirection:`column`,children:(0,N.jsx)(l,{dimColor:!0,children:v?`All tools selected`:`${_.size} of ${i.length} tools selected`})})]})}var M,N,br=e((()=>{i(),M=t(f(),1),te(),pt(),yt(),x(),vt(),de(),ge(),ye(),ze(),Ae(),be(),De(),Te(),pe(),$e(),Re(),ke(),h(),E(),v(),Rt(),N=_()}));function xr(e){return e===`all`?`Agents`:e===`built-in`?`Built-in agents`:e===`plugin`?`Plugin agents`:Kn(ee(e))}var Sr=e((()=>{qn(),S()}));function Cr({agent:e,tools:t,onSaved:n,onBack:r}){let i=He(),[o,s]=(0,P.useState)(`menu`),[u,f]=(0,P.useState)(0),[m,h]=(0,P.useState)(null),[g,_]=(0,P.useState)(e.color),v=(0,P.useCallback)(async()=>{let t=await cn($n(e));t.error?h(t.error):n(`Opened ${e.agentType} in editor. If you made edits, restart to load the latest version.`)},[e,n]),y=(0,P.useCallback)(async(t={})=>{let{tools:r,color:a,model:o}=t,s=a??g,c=r!==void 0,l=o!==void 0,u=s!==e.color;if(!c&&!l&&!u)return!1;try{return!Ge(e)&&!tt(e)?!1:(await ir(e,e.whenToUse,r??e.tools,e.getSystemPrompt(),s,o??e.model),u&&s&&Ie(e.agentType,s),i(t=>{let n=t.agentDefinitions.allAgents.map(t=>t.agentType===e.agentType?{...t,tools:r??t.tools,color:s,model:o??t.model}:t);return{...t,agentDefinitions:{...t.agentDefinitions,activeAgents:ct(n),allAgents:n}}}),n(`Updated agent: ${p.bold(e.agentType)}`),!0)}catch(e){return h(e instanceof Error?e.message:`Failed to save agent`),!1}},[e,g,n,i]),b=(0,P.useMemo)(()=>[{label:`Open in editor`,action:v},{label:`Edit tools`,action:()=>s(`edit-tools`)},{label:`Edit model`,action:()=>s(`edit-model`)},{label:`Edit color`,action:()=>s(`edit-color`)}],[v]),x=(0,P.useCallback)(()=>{h(null),o===`menu`?r():s(`menu`)},[o,r]),ee=(0,P.useCallback)(e=>{if(e.key===`up`)e.preventDefault(),f(e=>Math.max(0,e-1));else if(e.key===`down`)e.preventDefault(),f(e=>Math.min(b.length-1,e+1));else if(e.key===`return`){e.preventDefault();let t=b[u];t&&t.action()}},[b,u]);d(`confirm:no`,x,{context:`Confirmation`});let S=()=>(0,F.jsxs)(c,{flexDirection:`column`,tabIndex:0,autoFocus:!0,onKeyDown:ee,children:[(0,F.jsxs)(l,{dimColor:!0,children:[`Source: `,xr(e.source)]}),(0,F.jsx)(c,{marginTop:1,flexDirection:`column`,children:b.map((e,t)=>(0,F.jsxs)(l,{color:t===u?`suggestion`:void 0,children:[t===u?`${a.pointer} `:` `,e.label]},e.label))}),m&&(0,F.jsx)(c,{marginTop:1,children:(0,F.jsx)(l,{color:`error`,children:m})})]});switch(o){case`menu`:return S();case`edit-tools`:return(0,F.jsx)(yr,{tools:t,initialTools:e.tools,onComplete:async e=>{s(`menu`),await y({tools:e})}});case`edit-color`:return(0,F.jsx)(ur,{agentName:e.agentType,currentColor:g||e.color||`automatic`,onConfirm:async e=>{_(e),s(`menu`),await y({color:e})}});case`edit-model`:return(0,F.jsx)(pr,{initialModel:e.model,onComplete:async e=>{s(`menu`),await y({model:e})}});default:return null}}var P,F,wr=e((()=>{m(),i(),P=t(f(),1),Le(),h(),E(),gt(),at(),sn(),sr(),fr(),gr(),br(),Sr(),F=_()}));function Tr({instructions:e=`Press ↑↓ to navigate · Enter to select · Esc to go back`}){let t=Yt();return(0,Er.jsx)(c,{marginLeft:2,children:(0,Er.jsx)(l,{dimColor:!0,children:t.pending?`Press ${t.keyName} again to exit`:e})})}var Er,Dr=e((()=>{Xt(),h(),Er=_()}));function Or({source:e,agents:t,onBack:n,onSelect:r,onCreateNew:i,changes:s}){let[u,d]=kr.useState(null),[f,p]=kr.useState(!0),m=kr.useMemo(()=>[...t].sort(Gt),[t]),h=e=>({isOverridden:!!e.overriddenBy,overriddenBy:e.overriddenBy||null}),_=()=>(0,I.jsxs)(c,{children:[(0,I.jsx)(l,{color:f?`suggestion`:void 0,children:f?`${a.pointer} `:` `}),(0,I.jsx)(l,{color:f?`suggestion`:void 0,children:`Create new agent`})]}),v=e=>{let t=e.source===`built-in`,n=!t&&!f&&u?.agentType===e.agentType&&u?.source===e.source,{isOverridden:r,overriddenBy:i}=h(e),o=t||r,s=!t&&n?`suggestion`:void 0,d=Ut(e);return(0,I.jsxs)(c,{children:[(0,I.jsx)(l,{dimColor:o&&!n,color:s,children:t?``:n?`${a.pointer} `:` `}),(0,I.jsx)(l,{dimColor:o&&!n,color:s,children:e.agentType}),d&&(0,I.jsxs)(l,{dimColor:!0,color:s,children:[` · `,d]}),e.memory&&(0,I.jsxs)(l,{dimColor:!0,color:s,children:[` · `,e.memory,` memory`]}),i&&(0,I.jsxs)(l,{dimColor:!n,color:n?`warning`:void 0,children:[` `,a.warning,` shadowed by `,qt(i)]})]},`${e.agentType}-${e.source}`)},y=kr.useMemo(()=>{let t=m.filter(e=>e.source!==`built-in`);return e===`all`?Jt.filter(e=>e.source!==`built-in`).flatMap(({source:e})=>t.filter(t=>t.source===e)):t},[m,e]);kr.useEffect(()=>{!u&&!f&&y.length>0&&(i?p(!0):d(y[0]||null))},[y,u,f,i]);let x=e=>{if(e.key===`return`){e.preventDefault(),f&&i?i():u&&r(u);return}if(e.key!==`up`&&e.key!==`down`)return;e.preventDefault();let t=!!i,n=y.length+ +!!t;if(n===0)return;let a=0;if(!f&&u){let e=y.findIndex(e=>e.agentType===u.agentType&&e.source===u.source);e>=0&&(a=t?e+1:e)}let o=e.key===`up`?a===0?n-1:a-1:a===n-1?0:a+1;if(t&&o===0)p(!0),d(null);else{let e=t?o-1:o,n=y[e];n&&(p(!1),d(n))}},ee=(e=`Built-in (always available):`)=>{let t=m.filter(e=>e.source===`built-in`);return(0,I.jsxs)(c,{flexDirection:`column`,marginBottom:1,paddingLeft:2,children:[(0,I.jsx)(l,{bold:!0,dimColor:!0,children:e}),t.map(v)]})},S=(e,t)=>{if(!t.length)return null;let n=t[0]?.baseDir;return(0,I.jsxs)(c,{flexDirection:`column`,marginBottom:1,children:[(0,I.jsxs)(c,{paddingLeft:2,children:[(0,I.jsx)(l,{bold:!0,dimColor:!0,children:e}),n&&(0,I.jsxs)(l,{dimColor:!0,children:[` (`,n,`)`]})]}),t.map(e=>v(e))]})},te=xr(e),C=m.filter(e=>e.source===`built-in`);return!m.length||e!==`built-in`&&!m.some(e=>e.source!==`built-in`)?(0,I.jsx)(g,{title:te,subtitle:`No agents found`,onCancel:n,hideInputGuide:!0,children:(0,I.jsxs)(c,{flexDirection:`column`,gap:1,tabIndex:0,autoFocus:!0,onKeyDown:x,children:[i&&(0,I.jsx)(c,{children:_()}),(0,I.jsx)(l,{dimColor:!0,children:`No agents found. Create specialized subagents that Work Mate can delegate to.`}),(0,I.jsx)(l,{dimColor:!0,children:`Each subagent has its own context window, custom system prompt, and specific tools.`}),(0,I.jsx)(l,{dimColor:!0,children:`Try creating: Code Reviewer, Code Simplifier, Security Reviewer, Tech Lead, or UX Reviewer.`}),e!==`built-in`&&m.some(e=>e.source===`built-in`)&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(o,{}),ee()]})]})}):(0,I.jsxs)(g,{title:te,subtitle:`${b(m,e=>!e.overriddenBy)} agents`,onCancel:n,hideInputGuide:!0,children:[s&&s.length>0&&(0,I.jsx)(c,{marginTop:1,children:(0,I.jsx)(l,{dimColor:!0,children:s[s.length-1]})}),(0,I.jsxs)(c,{flexDirection:`column`,tabIndex:0,autoFocus:!0,onKeyDown:x,children:[i&&(0,I.jsx)(c,{marginBottom:1,children:_()}),e===`all`?(0,I.jsxs)(I.Fragment,{children:[Jt.filter(e=>e.source!==`built-in`).map(({label:e,source:t})=>(0,I.jsx)(kr.Fragment,{children:S(e,m.filter(e=>e.source===t))},t)),C.length>0&&(0,I.jsxs)(c,{flexDirection:`column`,marginBottom:1,paddingLeft:2,children:[(0,I.jsxs)(l,{dimColor:!0,children:[(0,I.jsx)(l,{bold:!0,children:`Built-in agents`}),` (always available)`]}),C.map(v)]})]}):e===`built-in`?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(l,{dimColor:!0,italic:!0,children:`Built-in agents are provided by default and cannot be modified.`}),(0,I.jsx)(c,{marginTop:1,flexDirection:`column`,children:m.map(e=>v(e))})]}):(0,I.jsxs)(I.Fragment,{children:[m.filter(e=>e.source!==`built-in`).map(e=>v(e)),m.some(e=>e.source===`built-in`)&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(o,{}),ee()]})]})]})]})}var kr,I,Ar=e((()=>{i(),kr=t(f(),1),h(),Wt(),v(),Sr(),I=_()}));function jr({steps:e,initialData:t={},onComplete:n,onCancel:r,children:i,title:a,showStepCounter:o=!0}){let[s,c]=(0,L.useState)(0),[l,u]=(0,L.useState)(t),[d,f]=(0,L.useState)(!1),[p,m]=(0,L.useState)([]);Yt(),(0,L.useEffect)(()=>{d&&(m([]),n(l))},[d,l,n]);let h=(0,L.useCallback)(()=>{s<e.length-1?(p.length>0&&m(e=>[...e,s]),c(e=>e+1)):f(!0)},[s,e.length,p]),g=(0,L.useCallback)(()=>{if(p.length>0){let e=p[p.length-1];e!==void 0&&(m(e=>e.slice(0,-1)),c(e))}else s>0?c(e=>e-1):r&&r()},[s,p,r]),_=(0,L.useCallback)(t=>{t>=0&&t<e.length&&(m(e=>[...e,s]),c(t))},[s,e.length]),v=(0,L.useCallback)(()=>{m([]),r&&r()},[r]),y=(0,L.useCallback)(e=>{u(t=>({...t,...e}))},[]),b=(0,L.useMemo)(()=>({currentStepIndex:s,totalSteps:e.length,wizardData:l,setWizardData:u,updateWizardData:y,goNext:h,goBack:g,goToStep:_,cancel:v,title:a,showStepCounter:o}),[s,e.length,l,y,h,g,_,v,a,o]),x=e[s];return!x||d?null:(0,Mr.jsx)(Nr.Provider,{value:b,children:i||(0,Mr.jsx)(x,{})})}var L,Mr,Nr,Pr=e((()=>{L=t(f(),1),Xt(),Mr=_(),Nr=(0,L.createContext)(null)}));function R(){let e=(0,Fr.useContext)(Nr);if(!e)throw Error(`useWizard must be used within a WizardProvider`);return e}var Fr,Ir=e((()=>{Fr=t(f(),1),Pr()}));function Lr({instructions:e=(0,z.jsxs)(u,{children:[(0,z.jsx)(s,{shortcut:`↑↓`,action:`navigate`}),(0,z.jsx)(s,{shortcut:`Enter`,action:`select`}),(0,z.jsx)(T,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]})}){let t=Yt();return(0,z.jsx)(c,{marginLeft:3,marginTop:1,children:(0,z.jsx)(l,{dimColor:!0,children:t.pending?`Press ${t.keyName} again to exit`:e})})}var z,Rr=e((()=>{Xt(),h(),w(),z=_()}));function B({title:e,color:t=`suggestion`,children:n,subtitle:r,footerText:i}){let{currentStepIndex:a,totalSteps:o,title:s,showStepCounter:c,goBack:l}=R();return(0,zr.jsxs)(zr.Fragment,{children:[(0,zr.jsx)(g,{title:`${e||s||`Wizard`}${c===!1?``:` (${a+1}/${o})`}`,subtitle:r,onCancel:l,color:t,hideInputGuide:!0,isCancelActive:!1,children:n}),(0,zr.jsx)(Lr,{instructions:i})]})}var zr,V=e((()=>{h(),Ir(),Rr(),zr=_()})),H=e((()=>{Ir(),V(),Rr(),Pr()}));function Br(){let{goNext:e,goBack:t,updateWizardData:n,wizardData:r}=R();return d(`confirm:no`,t,{context:`Confirmation`}),(0,U.jsx)(B,{subtitle:`Choose background color`,footerText:(0,U.jsxs)(u,{children:[(0,U.jsx)(s,{shortcut:`↑↓`,action:`navigate`}),(0,U.jsx)(s,{shortcut:`Enter`,action:`select`}),(0,U.jsx)(T,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]}),children:(0,U.jsx)(c,{children:(0,U.jsx)(ur,{agentName:r.agentType||`agent`,currentColor:`automatic`,onConfirm:t=>{n({selectedColor:t,finalAgent:{agentType:r.agentType,whenToUse:r.whenToUse,getSystemPrompt:()=>r.systemPrompt,tools:r.selectedTools,...r.selectedModel?{model:r.selectedModel}:{},...t?{color:t}:{},source:r.location}}),e()}})})})}var U,Vr=e((()=>{h(),E(),w(),H(),V(),fr(),U=_()}));function Hr(e){return e?/^[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]$/.test(e)?e.length<3?`Agent type must be at least 3 characters long`:e.length>50?`Agent type must be less than 50 characters`:null:`Agent type must start and end with alphanumeric characters and contain only letters, numbers, and hyphens`:`Agent type is required`}function Ur(e,t,n){let r=[],i=[];if(!e.agentType)r.push(`Agent type is required`);else{let t=Hr(e.agentType);t&&r.push(t);let i=n.find(t=>t.agentType===e.agentType&&t.source!==e.source);i&&r.push(`Agent type "${e.agentType}" already exists in ${xr(i.source)}`)}if(e.whenToUse?e.whenToUse.length<10?i.push(`Description should be more descriptive (at least 10 characters)`):e.whenToUse.length>5e3&&i.push(`Description is very long (over 5000 characters)`):r.push(`Description (description) is required`),e.tools!==void 0&&!Array.isArray(e.tools))r.push(`Tools must be an array`);else{e.tools===void 0?i.push(`Agent has access to all tools`):e.tools.length===0&&i.push(`No tools selected - agent will have very limited capabilities`);let n=We(e,t,!1);n.invalidTools.length>0&&r.push(`Invalid tools: ${n.invalidTools.join(`, `)}`)}let a=e.getSystemPrompt();return a?a.length<20?r.push(`System prompt is too short (minimum 20 characters)`):a.length>1e4&&i.push(`System prompt is very long (over 10,000 characters)`):r.push(`System prompt is required`),{isValid:r.length===0,errors:r,warnings:i}}var Wr=e((()=>{yt(),Sr()}));function Gr({tools:e,existingAgents:t,onSave:n,onSaveAndEdit:r,error:i}){let{goBack:a,wizardData:o}=R();d(`confirm:no`,a,{context:`Confirmation`});let f=e=>{e.key===`s`||e.key===`return`?(e.preventDefault(),n()):e.key===`e`&&(e.preventDefault(),r())},p=o.finalAgent,m=Ur(p,e,t),h=Pt(p.getSystemPrompt(),240),g=Pt(p.whenToUse,240),_=e=>e===void 0?`All tools`:e.length===0?`None`:e.length===1?e[0]||`None`:e.length===2?e.join(` and `):`${e.slice(0,-1).join(`, `)}, and ${e[e.length-1]}`,v=At()?(0,W.jsxs)(l,{children:[(0,W.jsx)(l,{bold:!0,children:`Memory`}),`: `,nt(p.memory)]}):null;return(0,W.jsx)(B,{subtitle:`Confirm and save`,footerText:(0,W.jsxs)(u,{children:[(0,W.jsx)(s,{shortcut:`s/Enter`,action:`save`}),(0,W.jsx)(s,{shortcut:`e`,action:`edit in your editor`}),(0,W.jsx)(T,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]}),children:(0,W.jsxs)(c,{flexDirection:`column`,tabIndex:0,autoFocus:!0,onKeyDown:f,children:[(0,W.jsxs)(l,{children:[(0,W.jsx)(l,{bold:!0,children:`Name`}),`: `,p.agentType]}),(0,W.jsxs)(l,{children:[(0,W.jsx)(l,{bold:!0,children:`Location`}),`:`,` `,er({source:o.location,agentType:p.agentType})]}),(0,W.jsxs)(l,{children:[(0,W.jsx)(l,{bold:!0,children:`Tools`}),`: `,_(p.tools)]}),(0,W.jsxs)(l,{children:[(0,W.jsx)(l,{bold:!0,children:`Model`}),`: `,et(p.model)]}),v,(0,W.jsx)(c,{marginTop:1,children:(0,W.jsxs)(l,{children:[(0,W.jsx)(l,{bold:!0,children:`Description`}),` (tells Work Mate when to use this agent):`]})}),(0,W.jsx)(c,{marginLeft:2,marginTop:1,children:(0,W.jsx)(l,{children:g})}),(0,W.jsx)(c,{marginTop:1,children:(0,W.jsxs)(l,{children:[(0,W.jsx)(l,{bold:!0,children:`System prompt`}),`:`]})}),(0,W.jsx)(c,{marginLeft:2,marginTop:1,children:(0,W.jsx)(l,{children:h})}),m.warnings.length>0&&(0,W.jsxs)(c,{marginTop:1,flexDirection:`column`,children:[(0,W.jsx)(l,{color:`warning`,children:`Warnings:`}),m.warnings.map((e,t)=>(0,W.jsxs)(l,{dimColor:!0,children:[` `,`• `,e]},t))]}),m.errors.length>0&&(0,W.jsxs)(c,{marginTop:1,flexDirection:`column`,children:[(0,W.jsx)(l,{color:`error`,children:`Errors:`}),m.errors.map((e,t)=>(0,W.jsxs)(l,{color:`error`,children:[` `,`• `,e]},t))]}),i&&(0,W.jsx)(c,{marginTop:1,children:(0,W.jsx)(l,{color:`error`,children:i})}),(0,W.jsx)(c,{marginTop:2,children:(0,W.jsxs)(l,{color:`success`,children:[`Press `,(0,W.jsx)(l,{bold:!0,children:`s`}),` or `,(0,W.jsx)(l,{bold:!0,children:`Enter`}),` to save, `,(0,W.jsx)(l,{bold:!0,children:`e`}),` to save and edit`]})})]})})}var W,Kr=e((()=>{h(),E(),kt(),Xe(),Ft(),Se(),w(),H(),V(),sr(),Wr(),W=_()}));function qr({tools:e,existingAgents:t,onComplete:n}){let{wizardData:r}=R(),[i,a]=(0,Jr.useState)(null),o=He(),s=(0,Jr.useCallback)(async e=>{if(r?.finalAgent)try{await rr(r.location,r.finalAgent.agentType,r.finalAgent.whenToUse,r.finalAgent.tools,r.finalAgent.getSystemPrompt(),!0,r.finalAgent.color,r.finalAgent.model,r.finalAgent.memory),o(e=>{if(!r.finalAgent)return e;let t=e.agentDefinitions.allAgents.concat(r.finalAgent);return{...e,agentDefinitions:{...e.agentDefinitions,activeAgents:ct(t),allAgents:t}}}),dt(),e&&await cn(Qn({source:r.location,agentType:r.finalAgent.agentType})),r.finalAgent.agentType,r.wasGenerated,r.location,r.finalAgent.tools?.length,r.finalAgent.model,r.finalAgent.color,r.finalAgent.memory,r.finalAgent.memory,{...e?{opened_in_editor:!0}:{}},n(e?`Created agent: ${p.bold(r.finalAgent.agentType)} and opened in editor. If you made edits, restart to load the latest version.`:`Created agent: ${p.bold(r.finalAgent.agentType)}`)}catch(e){a(e instanceof Error?e.message:`Failed to save agent`)}},[r,n,o]);return(0,Yr.jsx)(Gr,{tools:e,existingAgents:t,onSave:(0,Jr.useCallback)(()=>s(!1),[s]),onSaveAndEdit:(0,Jr.useCallback)(()=>s(!0),[s]),error:i})}var Jr,Yr,Xr=e((()=>{m(),Jr=t(f(),1),Nt(),Le(),at(),sn(),H(),sr(),Kr(),Yr=_()}));function Zr(){let{goNext:e,goBack:t,updateWizardData:n,wizardData:r}=R(),[i,a]=(0,Qr.useState)(r.whenToUse||``),[o,f]=(0,Qr.useState)(i.length),[p,m]=(0,Qr.useState)(null);return d(`confirm:no`,t,{context:`Settings`}),d(`chat:externalEditor`,(0,Qr.useCallback)(async()=>{let e=await on(i);e.content!==null&&(a(e.content),f(e.content.length))},[i]),{context:`Chat`}),(0,G.jsx)(B,{subtitle:`Description (tell Work Mate when to use this agent)`,footerText:(0,G.jsxs)(u,{children:[(0,G.jsx)(s,{shortcut:`Type`,action:`enter text`}),(0,G.jsx)(s,{shortcut:`Enter`,action:`continue`}),(0,G.jsx)(T,{action:`chat:externalEditor`,context:`Chat`,fallback:`ctrl+g`,description:`open in editor`}),(0,G.jsx)(T,{action:`confirm:no`,context:`Settings`,fallback:`Esc`,description:`go back`})]}),children:(0,G.jsxs)(c,{flexDirection:`column`,children:[(0,G.jsx)(l,{children:`When should Work Mate use this agent?`}),(0,G.jsx)(c,{marginTop:1,children:(0,G.jsx)(Qt,{value:i,onChange:a,onSubmit:t=>{let r=t.trim();if(!r){m(`Description is required`);return}m(null),n({whenToUse:r}),e()},placeholder:`e.g., use this agent after you're done writing code...`,columns:80,cursorOffset:o,onChangeCursorOffset:f,focus:!0,showCursor:!0})}),p&&(0,G.jsx)(c,{marginTop:1,children:(0,G.jsx)(l,{color:`error`,children:p})})]})})}var Qr,G,$r=e((()=>{Qr=t(f(),1),h(),E(),sn(),w(),Zt(),H(),V(),G=_()}));async function ei(e,t,n,r){let i=ft({content:`Create an agent configuration based on this request: "${e}".${n.length>0?`\n\nIMPORTANT: The following identifiers already exist and must NOT be used: ${n.join(`, `)}`:``}
|
|
8
|
+
Return ONLY the JSON object, no other text.`}),a=await xe(),o=Ze([i],a),s=At()?ti+ni:ti,c=await qe({messages:Je(o),systemPrompt:st([s]),thinkingConfig:{type:`disabled`},tools:[],signal:r,options:{getToolPermissionContext:async()=>zt(),model:t,toolChoice:void 0,agents:[],isNonInteractiveSession:!1,hasAppendSystemPrompt:!1,querySource:`agent_creation`,mcpTools:[]}}),l=(Array.isArray(c.message.content)?c.message.content:[]).filter(e=>e.type===`text`).map(e=>e.text).join(`
|
|
9
|
+
`),u;try{u=Tt(l.trim())}catch{let e=l.match(/\{[\s\S]*\}/);if(!e)throw Error(`No JSON object found in response`);u=Tt(e[0])}if(!u.identifier||!u.whenToUse||!u.systemPrompt)throw Error(`Invalid agent configuration generated`);return u.identifier,{identifier:u.identifier,whenToUse:u.whenToUse,systemPrompt:u.systemPrompt}}var ti,ni,ri=e((()=>{Ne(),Me(),Bt(),x(),it(),Ue(),kt(),Nt(),Ot(),lt(),ti=`You are an elite AI agent architect specializing in crafting high-performance agent configurations. Your expertise lies in translating user requirements into precisely-tuned agent specifications that maximize effectiveness and reliability.
|
|
10
10
|
|
|
11
11
|
**Important Context**: You may have access to project-specific instructions from AGENTS.md files and other context that may include coding standards, project structure, and custom requirements. Consider this context when creating agents to ensure they align with the project's established patterns and practices.
|
|
12
12
|
|
|
@@ -97,5 +97,5 @@ Remember: The agents you create should be autonomous experts capable of handling
|
|
|
97
97
|
- For a documentation writer: "Update your agent memory as you discover documentation patterns, API structures, and terminology conventions."
|
|
98
98
|
|
|
99
99
|
The memory instructions should be specific to what the agent would naturally learn while performing its core tasks.
|
|
100
|
-
`}));function ii(){let{updateWizardData:e,goBack:t,goToStep:n,wizardData:r}=R(),[i,a]=(0,K.useState)(r.generationPrompt||``),[o,s]=(0,K.useState)(!1),[f,p]=(0,K.useState)(null),[m,h]=(0,K.useState)(i.length),g=ln(),_=(0,K.useRef)(null);d(`confirm:no`,(0,K.useCallback)(()=>{_.current&&(_.current.abort(),_.current=null,s(!1),p(`Generation cancelled`))},[]),{context:`Settings`,isActive:o}),d(`chat:externalEditor`,(0,K.useCallback)(async()=>{let e=await on(i);e.content!==null&&(a(e.content),h(e.content.length))},[i]),{context:`Chat`,isActive:!o}),d(`confirm:no`,(0,K.useCallback)(()=>{e({generationPrompt:``,agentType:``,systemPrompt:``,whenToUse:``,generatedAgent:void 0,wasGenerated:!1}),a(``),p(null),t()},[e,t]),{context:`Settings`,isActive:!o});let v=async()=>{let t=i.trim();if(!t){p(`Please describe what the agent should do`);return}p(null),s(!0),e({generationPrompt:t,isGenerating:!0});let r=vt();_.current=r;try{let i=await ei(t,g,[],r.signal);e({agentType:i.identifier,whenToUse:i.whenToUse,systemPrompt:i.systemPrompt,generatedAgent:i,isGenerating:!1,wasGenerated:!0}),n(6)}catch(t){t instanceof Dt||t instanceof Error&&!t.message.includes(`No assistant message found`)&&p(t.message||`Failed to generate agent`),e({isGenerating:!1})}finally{s(!1),_.current=null}},y=`Describe what this agent should do and when it should be used (be comprehensive for best results)`;return o?(0,q.jsx)(B,{subtitle:y,footerText:(0,q.jsx)(T,{action:`confirm:no`,context:`Settings`,fallback:`Esc`,description:`cancel`}),children:(0,q.jsxs)(c,{flexDirection:`row`,alignItems:`center`,children:[(0,q.jsx)(nn,{}),(0,q.jsx)(l,{color:`suggestion`,children:` Generating agent from description...`})]})}):(0,q.jsx)(B,{subtitle:y,footerText:(0,q.jsxs)(u,{children:[(0,q.jsx)(T,{action:`confirm:yes`,context:`Confirmation`,fallback:`Enter`,description:`submit`}),(0,q.jsx)(T,{action:`chat:externalEditor`,context:`Chat`,fallback:`ctrl+g`,description:`open in editor`}),(0,q.jsx)(T,{action:`confirm:no`,context:`Settings`,fallback:`Esc`,description:`go back`})]}),children:(0,q.jsxs)(c,{flexDirection:`column`,children:[f&&(0,q.jsx)(c,{marginBottom:1,children:(0,q.jsx)(l,{color:`error`,children:f})}),(0,q.jsx)(Qt,{value:i,onChange:a,onSubmit:v,placeholder:`e.g., Help me write unit tests for my code...`,columns:80,cursorOffset:m,onChangeCursorOffset:h,focus:!0,showCursor:!0})]})})}var K,q,ai=e((()=>{St(),K=t(f(),1),un(),h(),E(),de(),sn(),w(),tn(),Zt(),H(),V(),ri(),q=_()}));function oi(){let{goNext:e,updateWizardData:t,cancel:n}=R();return(0,J.jsx)(B,{subtitle:`Choose location`,footerText:(0,J.jsxs)(u,{children:[(0,J.jsx)(s,{shortcut:`↑↓`,action:`navigate`}),(0,J.jsx)(s,{shortcut:`Enter`,action:`select`}),(0,J.jsx)(T,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]}),children:(0,J.jsx)(c,{children:(0,J.jsx)(en,{options:[{label:`Project (.workmate/agents/)`,value:`projectSettings`},{label:`Personal (~/.workmate/agents/)`,value:`userSettings`}],onChange:n=>{t({location:n}),e()},onCancel:()=>n()},`location-select`)})})}var J,si=e((()=>{h(),w(),$t(),H(),V(),J=_()}));function ci(){let{goNext:e,goBack:t,updateWizardData:n,wizardData:r}=R();d(`confirm:no`,t,{context:`Confirmation`});let i=r.location===`userSettings`?[{label:`User scope (~/.workmate/agent-memory/) (Recommended)`,value:`user`},{label:`None (no persistent memory)`,value:`none`},{label:`Project scope (.workmate/agent-memory/)`,value:`project`},{label:`Local scope (.workmate/agent-memory-local/)`,value:`local`}]:[{label:`Project scope (.workmate/agent-memory/) (Recommended)`,value:`project`},{label:`None (no persistent memory)`,value:`none`},{label:`User scope (~/.workmate/agent-memory/)`,value:`user`},{label:`Local scope (.workmate/agent-memory-local/)`,value:`local`}];return(0,Y.jsx)(B,{subtitle:`Configure agent memory`,footerText:(0,Y.jsxs)(u,{children:[(0,Y.jsx)(s,{shortcut:`↑↓`,action:`navigate`}),(0,Y.jsx)(s,{shortcut:`Enter`,action:`select`}),(0,Y.jsx)(T,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]}),children:(0,Y.jsx)(c,{children:(0,Y.jsx)(en,{options:i,onChange:t=>{let i=t===`none`?void 0:t,a=r.finalAgent?.agentType;n({selectedMemory:i,finalAgent:r.finalAgent?{...r.finalAgent,memory:i,getSystemPrompt:At()&&i&&a?()=>`${r.systemPrompt}\n\n${tt(a,i)}`:()=>r.systemPrompt}:void 0}),e()},onCancel:t},`memory-select`)})})}var Y,li=e((()=>{h(),E(),kt(),it(),w(),$t(),H(),V(),Y=_()}));function ui(){let{goNext:e,goBack:t,updateWizardData:n,goToStep:r}=R();return(0,X.jsx)(B,{subtitle:`Creation method`,footerText:(0,X.jsxs)(u,{children:[(0,X.jsx)(s,{shortcut:`↑↓`,action:`navigate`}),(0,X.jsx)(s,{shortcut:`Enter`,action:`select`}),(0,X.jsx)(T,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]}),children:(0,X.jsx)(c,{children:(0,X.jsx)(en,{options:[{label:`Generate with Work Mate (recommended)`,value:`generate`},{label:`Manual configuration`,value:`manual`}],onChange:t=>{let i=t;n({method:i,wasGenerated:i===`generate`}),i===`generate`?e():r(3)},onCancel:()=>t()},`method-select`)})})}var X,di=e((()=>{h(),w(),$t(),H(),V(),X=_()}));function fi(){let{goNext:e,goBack:t,updateWizardData:n,wizardData:r}=R();return(0,pi.jsx)(B,{subtitle:`Select model`,footerText:(0,pi.jsxs)(u,{children:[(0,pi.jsx)(s,{shortcut:`↑↓`,action:`navigate`}),(0,pi.jsx)(s,{shortcut:`Enter`,action:`select`}),(0,pi.jsx)(T,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]}),children:(0,pi.jsx)(pr,{initialModel:r.selectedModel,onComplete:t=>{n({selectedModel:t}),e()},onCancel:t})})}var pi,mi=e((()=>{w(),h(),H(),V(),gr(),pi=_()}));function hi(){let{goNext:e,goBack:t,updateWizardData:n,wizardData:r}=R(),[i,a]=(0,gi.useState)(r.systemPrompt||``),[o,f]=(0,gi.useState)(i.length),[p,m]=(0,gi.useState)(null);return d(`confirm:no`,t,{context:`Settings`}),d(`chat:externalEditor`,(0,gi.useCallback)(async()=>{let e=await on(i);e.content!==null&&(a(e.content),f(e.content.length))},[i]),{context:`Chat`}),(0,Z.jsx)(B,{subtitle:`System prompt`,footerText:(0,Z.jsxs)(u,{children:[(0,Z.jsx)(s,{shortcut:`Type`,action:`enter text`}),(0,Z.jsx)(s,{shortcut:`Enter`,action:`continue`}),(0,Z.jsx)(T,{action:`chat:externalEditor`,context:`Chat`,fallback:`ctrl+g`,description:`open in editor`}),(0,Z.jsx)(T,{action:`confirm:no`,context:`Settings`,fallback:`Esc`,description:`go back`})]}),children:(0,Z.jsxs)(c,{flexDirection:`column`,children:[(0,Z.jsx)(l,{children:`Enter the system prompt for your agent:`}),(0,Z.jsx)(l,{dimColor:!0,children:`Be comprehensive for best results`}),(0,Z.jsx)(c,{marginTop:1,children:(0,Z.jsx)(Qt,{value:i,onChange:a,onSubmit:()=>{let t=i.trim();if(!t){m(`System prompt is required`);return}m(null),n({systemPrompt:t}),e()},placeholder:`You are a helpful code reviewer who...`,columns:80,cursorOffset:o,onChangeCursorOffset:f,focus:!0,showCursor:!0})}),p&&(0,Z.jsx)(c,{marginTop:1,children:(0,Z.jsx)(l,{color:`error`,children:p})})]})})}var gi,Z,_i=e((()=>{gi=t(f(),1),h(),E(),sn(),w(),Zt(),H(),V(),Z=_()}));function vi({tools:e}){let{goNext:t,goBack:n,updateWizardData:r,wizardData:i}=R(),a=e=>{r({selectedTools:e}),t()},o=i.selectedTools;return(0,yi.jsx)(B,{subtitle:`Select tools`,footerText:(0,yi.jsxs)(u,{children:[(0,yi.jsx)(s,{shortcut:`Enter`,action:`toggle selection`}),(0,yi.jsx)(s,{shortcut:`↑↓`,action:`navigate`}),(0,yi.jsx)(T,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]}),children:(0,yi.jsx)(yr,{tools:e,initialTools:o,onComplete:a,onCancel:n})})}var yi,bi=e((()=>{h(),w(),H(),V(),br(),yi=_()}));function xi(e){let{goNext:t,goBack:n,updateWizardData:r,wizardData:i}=R(),[a,o]=(0,Si.useState)(i.agentType||``),[f,p]=(0,Si.useState)(null),[m,h]=(0,Si.useState)(a.length);return d(`confirm:no`,n,{context:`Settings`}),(0,Q.jsx)(B,{subtitle:`Agent type (identifier)`,footerText:(0,Q.jsxs)(u,{children:[(0,Q.jsx)(s,{shortcut:`Type`,action:`enter text`}),(0,Q.jsx)(s,{shortcut:`Enter`,action:`continue`}),(0,Q.jsx)(T,{action:`confirm:no`,context:`Settings`,fallback:`Esc`,description:`go back`})]}),children:(0,Q.jsxs)(c,{flexDirection:`column`,children:[(0,Q.jsx)(l,{children:`Enter a unique identifier for your agent:`}),(0,Q.jsx)(c,{marginTop:1,children:(0,Q.jsx)(Qt,{value:a,onChange:o,onSubmit:e=>{let n=e.trim(),i=Hr(n);if(i){p(i);return}p(null),r({agentType:n}),t()},placeholder:`e.g., test-runner, tech-lead, etc`,columns:60,cursorOffset:m,onChangeCursorOffset:h,focus:!0,showCursor:!0})}),f&&(0,Q.jsx)(c,{marginTop:1,children:(0,Q.jsx)(l,{color:`error`,children:f})})]})})}var Si,Q,Ci=e((()=>{Si=t(f(),1),h(),E(),w(),Zt(),H(),V(),Wr(),Q=_()}));function wi({tools:e,existingAgents:t,onComplete:n,onCancel:r}){return(0,Ti.jsx)(jr,{steps:[oi,ui,ii,()=>(0,Ti.jsx)(xi,{existingAgents:t}),hi,Zr,()=>(0,Ti.jsx)(vi,{tools:e}),fi,Br,...At()?[ci]:[],()=>(0,Ti.jsx)(qr,{tools:e,existingAgents:t,onComplete:n})],initialData:{},onComplete:()=>{},onCancel:r,title:`Create new agent`,showStepCounter:!1})}var Ti,Ei=e((()=>{kt(),H(),Vr(),Xr(),$r(),ai(),si(),li(),di(),mi(),_i(),bi(),Ci(),Ti=_()}));function Di({tools:e,onExit:t}){let[n,r]=(0,Oi.useState)({mode:`list-agents`,source:`all`}),i=ue(e=>e.agentDefinitions),a=ue(e=>e.mcp.tools),o=ue(e=>e.toolPermissionContext),s=we(),{allAgents:u,activeAgents:d}=i,[f,m]=(0,Oi.useState)([]),h=rn(e,a,o);Yt();let _=(0,Oi.useMemo)(()=>({"built-in":u.filter(e=>e.source===`built-in`),userSettings:u.filter(e=>e.source===`userSettings`),projectSettings:u.filter(e=>e.source===`projectSettings`),policySettings:u.filter(e=>e.source===`policySettings`),localSettings:u.filter(e=>e.source===`localSettings`),flagSettings:u.filter(e=>e.source===`flagSettings`),plugin:u.filter(e=>e.source===`plugin`),all:u}),[u]),v=(0,Oi.useCallback)(e=>{m(t=>[...t,e]),r({mode:`list-agents`,source:`all`})},[]),y=(0,Oi.useCallback)(async e=>{try{await ar(e),s(t=>{let n=t.agentDefinitions.allAgents.filter(t=>!(t.agentType===e.agentType&&t.source===e.source));return{...t,agentDefinitions:{...t.agentDefinitions,allAgents:n,activeAgents:at(n)}}}),m(t=>[...t,`Deleted agent: ${p.bold(e.agentType)}`]),r({mode:`list-agents`,source:`all`})}catch(e){Mt(Et(e))}},[s]);switch(n.mode){case`list-agents`:{let e=Kt(n.source===`all`?[..._[`built-in`],..._.userSettings,..._.projectSettings,..._.localSettings,..._.policySettings,..._.flagSettings,..._.plugin]:_[n.source],d);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Or,{source:n.source,agents:e,onBack:()=>{t((f.length>0?`Agent changes:\n${f.join(`
|
|
101
|
-
`)}`:void 0)??`Agents dialog dismissed`,{display:f.length===0?`system`:void 0})},onSelect:e=>r({mode:`agent-menu`,agent:e,previousMode:n}),onCreateNew:()=>r({mode:`create-agent`}),changes:f}),(0,$.jsx)(Tr,{})]})}case`create-agent`:return(0,$.jsx)(wi,{tools:h,existingAgents:d,onComplete:v,onCancel:()=>r({mode:`list-agents`,source:`all`})});case`agent-menu`:{let e=u.find(e=>e.agentType===n.agent.agentType&&e.source===n.agent.source)||n.agent,t=[{label:`View agent`,value:`view`},...e.source!==`built-in`&&e.source!==`plugin`&&e.source!==`flagSettings`?[{label:`Edit agent`,value:`edit`},{label:`Delete agent`,value:`delete`}]:[],{label:`Back`,value:`back`}];return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(g,{title:n.agent.agentType,onCancel:()=>r(n.previousMode),hideInputGuide:!0,children:(0,$.jsxs)(c,{flexDirection:`column`,children:[(0,$.jsx)(en,{options:t,onChange:t=>{switch(t){case`view`:r({mode:`view-agent`,agent:e,previousMode:n.previousMode});break;case`edit`:r({mode:`edit-agent`,agent:e,previousMode:n});break;case`delete`:r({mode:`delete-confirm`,agent:e,previousMode:n});break;case`back`:r(n.previousMode);break}},onCancel:()=>r(n.previousMode)}),f.length>0&&(0,$.jsx)(c,{marginTop:1,children:(0,$.jsx)(l,{dimColor:!0,children:f[f.length-1]})})]})}),(0,$.jsx)(Tr,{})]})}case`view-agent`:{let e=u.find(e=>e.agentType===n.agent.agentType&&e.source===n.agent.source)||n.agent;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(g,{title:e.agentType,onCancel:()=>r({mode:`agent-menu`,agent:e,previousMode:n.previousMode}),hideInputGuide:!0,children:(0,$.jsx)(cr,{agent:e,tools:h,allAgents:u,onBack:()=>r({mode:`agent-menu`,agent:e,previousMode:n.previousMode})})}),(0,$.jsx)(Tr,{instructions:`Press Enter or Esc to go back`})]})}case`delete-confirm`:return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(g,{title:`Delete agent`,onCancel:()=>{`previousMode`in n&&r(n.previousMode)},color:`error`,children:[(0,$.jsxs)(l,{children:[`Are you sure you want to delete the agent `,(0,$.jsx)(l,{bold:!0,children:n.agent.agentType}),`?`]}),(0,$.jsx)(c,{marginTop:1,children:(0,$.jsxs)(l,{dimColor:!0,children:[`Source: `,n.agent.source]})}),(0,$.jsx)(c,{marginTop:1,children:(0,$.jsx)(en,{options:[{label:`Yes, delete`,value:`yes`},{label:`No, cancel`,value:`no`}],onChange:e=>{e===`yes`?y(n.agent):`previousMode`in n&&r(n.previousMode)},onCancel:()=>{`previousMode`in n&&r(n.previousMode)}})})]}),(0,$.jsx)(Tr,{instructions:`Press ↑↓ to navigate, Enter to select, Esc to cancel`})]});case`edit-agent`:{let e=u.find(e=>e.agentType===n.agent.agentType&&e.source===n.agent.source)||n.agent;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(g,{title:`Edit agent: ${e.agentType}`,onCancel:()=>r(n.previousMode),hideInputGuide:!0,children:(0,$.jsx)(Cr,{agent:e,tools:h,onSaved:e=>{v(e),r(n.previousMode)},onBack:()=>r(n.previousMode)})}),(0,$.jsx)(Tr,{})]})}default:return null}}var Oi,$,ki=e((()=>{m(),Oi=t(f(),1),Xt(),an(),h(),
|
|
100
|
+
`}));function ii(){let{updateWizardData:e,goBack:t,goToStep:n,wizardData:r}=R(),[i,a]=(0,K.useState)(r.generationPrompt||``),[o,s]=(0,K.useState)(!1),[f,p]=(0,K.useState)(null),[m,h]=(0,K.useState)(i.length),g=ln(),_=(0,K.useRef)(null);d(`confirm:no`,(0,K.useCallback)(()=>{_.current&&(_.current.abort(),_.current=null,s(!1),p(`Generation cancelled`))},[]),{context:`Settings`,isActive:o}),d(`chat:externalEditor`,(0,K.useCallback)(async()=>{let e=await on(i);e.content!==null&&(a(e.content),h(e.content.length))},[i]),{context:`Chat`,isActive:!o}),d(`confirm:no`,(0,K.useCallback)(()=>{e({generationPrompt:``,agentType:``,systemPrompt:``,whenToUse:``,generatedAgent:void 0,wasGenerated:!1}),a(``),p(null),t()},[e,t]),{context:`Settings`,isActive:!o});let v=async()=>{let t=i.trim();if(!t){p(`Please describe what the agent should do`);return}p(null),s(!0),e({generationPrompt:t,isGenerating:!0});let r=Be();_.current=r;try{let i=await ei(t,g,[],r.signal);e({agentType:i.identifier,whenToUse:i.whenToUse,systemPrompt:i.systemPrompt,generatedAgent:i,isGenerating:!1,wasGenerated:!0}),n(6)}catch(t){t instanceof Dt||t instanceof Error&&!t.message.includes(`No assistant message found`)&&p(t.message||`Failed to generate agent`),e({isGenerating:!1})}finally{s(!1),_.current=null}},y=`Describe what this agent should do and when it should be used (be comprehensive for best results)`;return o?(0,q.jsx)(B,{subtitle:y,footerText:(0,q.jsx)(T,{action:`confirm:no`,context:`Settings`,fallback:`Esc`,description:`cancel`}),children:(0,q.jsxs)(c,{flexDirection:`row`,alignItems:`center`,children:[(0,q.jsx)(nn,{}),(0,q.jsx)(l,{color:`suggestion`,children:` Generating agent from description...`})]})}):(0,q.jsx)(B,{subtitle:y,footerText:(0,q.jsxs)(u,{children:[(0,q.jsx)(T,{action:`confirm:yes`,context:`Confirmation`,fallback:`Enter`,description:`submit`}),(0,q.jsx)(T,{action:`chat:externalEditor`,context:`Chat`,fallback:`ctrl+g`,description:`open in editor`}),(0,q.jsx)(T,{action:`confirm:no`,context:`Settings`,fallback:`Esc`,description:`go back`})]}),children:(0,q.jsxs)(c,{flexDirection:`column`,children:[f&&(0,q.jsx)(c,{marginBottom:1,children:(0,q.jsx)(l,{color:`error`,children:f})}),(0,q.jsx)(Qt,{value:i,onChange:a,onSubmit:v,placeholder:`e.g., Help me write unit tests for my code...`,columns:80,cursorOffset:m,onChangeCursorOffset:h,focus:!0,showCursor:!0})]})})}var K,q,ai=e((()=>{St(),K=t(f(),1),un(),h(),E(),ve(),sn(),w(),tn(),Zt(),H(),V(),ri(),q=_()}));function oi(){let{goNext:e,updateWizardData:t,cancel:n}=R();return(0,J.jsx)(B,{subtitle:`Choose location`,footerText:(0,J.jsxs)(u,{children:[(0,J.jsx)(s,{shortcut:`↑↓`,action:`navigate`}),(0,J.jsx)(s,{shortcut:`Enter`,action:`select`}),(0,J.jsx)(T,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]}),children:(0,J.jsx)(c,{children:(0,J.jsx)(en,{options:[{label:`Project (.workmate/agents/)`,value:`projectSettings`},{label:`Personal (~/.workmate/agents/)`,value:`userSettings`}],onChange:n=>{t({location:n}),e()},onCancel:()=>n()},`location-select`)})})}var J,si=e((()=>{h(),w(),$t(),H(),V(),J=_()}));function ci(){let{goNext:e,goBack:t,updateWizardData:n,wizardData:r}=R();d(`confirm:no`,t,{context:`Confirmation`});let i=r.location===`userSettings`?[{label:`User scope (~/.workmate/agent-memory/) (Recommended)`,value:`user`},{label:`None (no persistent memory)`,value:`none`},{label:`Project scope (.workmate/agent-memory/)`,value:`project`},{label:`Local scope (.workmate/agent-memory-local/)`,value:`local`}]:[{label:`Project scope (.workmate/agent-memory/) (Recommended)`,value:`project`},{label:`None (no persistent memory)`,value:`none`},{label:`User scope (~/.workmate/agent-memory/)`,value:`user`},{label:`Local scope (.workmate/agent-memory-local/)`,value:`local`}];return(0,Y.jsx)(B,{subtitle:`Configure agent memory`,footerText:(0,Y.jsxs)(u,{children:[(0,Y.jsx)(s,{shortcut:`↑↓`,action:`navigate`}),(0,Y.jsx)(s,{shortcut:`Enter`,action:`select`}),(0,Y.jsx)(T,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]}),children:(0,Y.jsx)(c,{children:(0,Y.jsx)(en,{options:i,onChange:t=>{let i=t===`none`?void 0:t,a=r.finalAgent?.agentType;n({selectedMemory:i,finalAgent:r.finalAgent?{...r.finalAgent,memory:i,getSystemPrompt:At()&&i&&a?()=>`${r.systemPrompt}\n\n${Ye(a,i)}`:()=>r.systemPrompt}:void 0}),e()},onCancel:t},`memory-select`)})})}var Y,li=e((()=>{h(),E(),kt(),Xe(),w(),$t(),H(),V(),Y=_()}));function ui(){let{goNext:e,goBack:t,updateWizardData:n,goToStep:r}=R();return(0,X.jsx)(B,{subtitle:`Creation method`,footerText:(0,X.jsxs)(u,{children:[(0,X.jsx)(s,{shortcut:`↑↓`,action:`navigate`}),(0,X.jsx)(s,{shortcut:`Enter`,action:`select`}),(0,X.jsx)(T,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]}),children:(0,X.jsx)(c,{children:(0,X.jsx)(en,{options:[{label:`Generate with Work Mate (recommended)`,value:`generate`},{label:`Manual configuration`,value:`manual`}],onChange:t=>{let i=t;n({method:i,wasGenerated:i===`generate`}),i===`generate`?e():r(3)},onCancel:()=>t()},`method-select`)})})}var X,di=e((()=>{h(),w(),$t(),H(),V(),X=_()}));function fi(){let{goNext:e,goBack:t,updateWizardData:n,wizardData:r}=R();return(0,pi.jsx)(B,{subtitle:`Select model`,footerText:(0,pi.jsxs)(u,{children:[(0,pi.jsx)(s,{shortcut:`↑↓`,action:`navigate`}),(0,pi.jsx)(s,{shortcut:`Enter`,action:`select`}),(0,pi.jsx)(T,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]}),children:(0,pi.jsx)(pr,{initialModel:r.selectedModel,onComplete:t=>{n({selectedModel:t}),e()},onCancel:t})})}var pi,mi=e((()=>{w(),h(),H(),V(),gr(),pi=_()}));function hi(){let{goNext:e,goBack:t,updateWizardData:n,wizardData:r}=R(),[i,a]=(0,gi.useState)(r.systemPrompt||``),[o,f]=(0,gi.useState)(i.length),[p,m]=(0,gi.useState)(null);return d(`confirm:no`,t,{context:`Settings`}),d(`chat:externalEditor`,(0,gi.useCallback)(async()=>{let e=await on(i);e.content!==null&&(a(e.content),f(e.content.length))},[i]),{context:`Chat`}),(0,Z.jsx)(B,{subtitle:`System prompt`,footerText:(0,Z.jsxs)(u,{children:[(0,Z.jsx)(s,{shortcut:`Type`,action:`enter text`}),(0,Z.jsx)(s,{shortcut:`Enter`,action:`continue`}),(0,Z.jsx)(T,{action:`chat:externalEditor`,context:`Chat`,fallback:`ctrl+g`,description:`open in editor`}),(0,Z.jsx)(T,{action:`confirm:no`,context:`Settings`,fallback:`Esc`,description:`go back`})]}),children:(0,Z.jsxs)(c,{flexDirection:`column`,children:[(0,Z.jsx)(l,{children:`Enter the system prompt for your agent:`}),(0,Z.jsx)(l,{dimColor:!0,children:`Be comprehensive for best results`}),(0,Z.jsx)(c,{marginTop:1,children:(0,Z.jsx)(Qt,{value:i,onChange:a,onSubmit:()=>{let t=i.trim();if(!t){m(`System prompt is required`);return}m(null),n({systemPrompt:t}),e()},placeholder:`You are a helpful code reviewer who...`,columns:80,cursorOffset:o,onChangeCursorOffset:f,focus:!0,showCursor:!0})}),p&&(0,Z.jsx)(c,{marginTop:1,children:(0,Z.jsx)(l,{color:`error`,children:p})})]})})}var gi,Z,_i=e((()=>{gi=t(f(),1),h(),E(),sn(),w(),Zt(),H(),V(),Z=_()}));function vi({tools:e}){let{goNext:t,goBack:n,updateWizardData:r,wizardData:i}=R(),a=e=>{r({selectedTools:e}),t()},o=i.selectedTools;return(0,yi.jsx)(B,{subtitle:`Select tools`,footerText:(0,yi.jsxs)(u,{children:[(0,yi.jsx)(s,{shortcut:`Enter`,action:`toggle selection`}),(0,yi.jsx)(s,{shortcut:`↑↓`,action:`navigate`}),(0,yi.jsx)(T,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]}),children:(0,yi.jsx)(yr,{tools:e,initialTools:o,onComplete:a,onCancel:n})})}var yi,bi=e((()=>{h(),w(),H(),V(),br(),yi=_()}));function xi(e){let{goNext:t,goBack:n,updateWizardData:r,wizardData:i}=R(),[a,o]=(0,Si.useState)(i.agentType||``),[f,p]=(0,Si.useState)(null),[m,h]=(0,Si.useState)(a.length);return d(`confirm:no`,n,{context:`Settings`}),(0,Q.jsx)(B,{subtitle:`Agent type (identifier)`,footerText:(0,Q.jsxs)(u,{children:[(0,Q.jsx)(s,{shortcut:`Type`,action:`enter text`}),(0,Q.jsx)(s,{shortcut:`Enter`,action:`continue`}),(0,Q.jsx)(T,{action:`confirm:no`,context:`Settings`,fallback:`Esc`,description:`go back`})]}),children:(0,Q.jsxs)(c,{flexDirection:`column`,children:[(0,Q.jsx)(l,{children:`Enter a unique identifier for your agent:`}),(0,Q.jsx)(c,{marginTop:1,children:(0,Q.jsx)(Qt,{value:a,onChange:o,onSubmit:e=>{let n=e.trim(),i=Hr(n);if(i){p(i);return}p(null),r({agentType:n}),t()},placeholder:`e.g., test-runner, tech-lead, etc`,columns:60,cursorOffset:m,onChangeCursorOffset:h,focus:!0,showCursor:!0})}),f&&(0,Q.jsx)(c,{marginTop:1,children:(0,Q.jsx)(l,{color:`error`,children:f})})]})})}var Si,Q,Ci=e((()=>{Si=t(f(),1),h(),E(),w(),Zt(),H(),V(),Wr(),Q=_()}));function wi({tools:e,existingAgents:t,onComplete:n,onCancel:r}){return(0,Ti.jsx)(jr,{steps:[oi,ui,ii,()=>(0,Ti.jsx)(xi,{existingAgents:t}),hi,Zr,()=>(0,Ti.jsx)(vi,{tools:e}),fi,Br,...At()?[ci]:[],()=>(0,Ti.jsx)(qr,{tools:e,existingAgents:t,onComplete:n})],initialData:{},onComplete:()=>{},onCancel:r,title:`Create new agent`,showStepCounter:!1})}var Ti,Ei=e((()=>{kt(),H(),Vr(),Xr(),$r(),ai(),si(),li(),di(),mi(),_i(),bi(),Ci(),Ti=_()}));function Di({tools:e,onExit:t}){let[n,r]=(0,Oi.useState)({mode:`list-agents`,source:`all`}),i=_e(e=>e.agentDefinitions),a=_e(e=>e.mcp.tools),o=_e(e=>e.toolPermissionContext),s=He(),{allAgents:u,activeAgents:d}=i,[f,m]=(0,Oi.useState)([]),h=rn(e,a,o);Yt();let _=(0,Oi.useMemo)(()=>({"built-in":u.filter(e=>e.source===`built-in`),userSettings:u.filter(e=>e.source===`userSettings`),projectSettings:u.filter(e=>e.source===`projectSettings`),policySettings:u.filter(e=>e.source===`policySettings`),localSettings:u.filter(e=>e.source===`localSettings`),flagSettings:u.filter(e=>e.source===`flagSettings`),plugin:u.filter(e=>e.source===`plugin`),all:u}),[u]),v=(0,Oi.useCallback)(e=>{m(t=>[...t,e]),r({mode:`list-agents`,source:`all`})},[]),y=(0,Oi.useCallback)(async e=>{try{await ar(e),s(t=>{let n=t.agentDefinitions.allAgents.filter(t=>!(t.agentType===e.agentType&&t.source===e.source));return{...t,agentDefinitions:{...t.agentDefinitions,allAgents:n,activeAgents:ct(n)}}}),m(t=>[...t,`Deleted agent: ${p.bold(e.agentType)}`]),r({mode:`list-agents`,source:`all`})}catch(e){Mt(Et(e))}},[s]);switch(n.mode){case`list-agents`:{let e=Kt(n.source===`all`?[..._[`built-in`],..._.userSettings,..._.projectSettings,..._.localSettings,..._.policySettings,..._.flagSettings,..._.plugin]:_[n.source],d);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Or,{source:n.source,agents:e,onBack:()=>{t((f.length>0?`Agent changes:\n${f.join(`
|
|
101
|
+
`)}`:void 0)??`Agents dialog dismissed`,{display:f.length===0?`system`:void 0})},onSelect:e=>r({mode:`agent-menu`,agent:e,previousMode:n}),onCreateNew:()=>r({mode:`create-agent`}),changes:f}),(0,$.jsx)(Tr,{})]})}case`create-agent`:return(0,$.jsx)(wi,{tools:h,existingAgents:d,onComplete:v,onCancel:()=>r({mode:`list-agents`,source:`all`})});case`agent-menu`:{let e=u.find(e=>e.agentType===n.agent.agentType&&e.source===n.agent.source)||n.agent,t=[{label:`View agent`,value:`view`},...e.source!==`built-in`&&e.source!==`plugin`&&e.source!==`flagSettings`?[{label:`Edit agent`,value:`edit`},{label:`Delete agent`,value:`delete`}]:[],{label:`Back`,value:`back`}];return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(g,{title:n.agent.agentType,onCancel:()=>r(n.previousMode),hideInputGuide:!0,children:(0,$.jsxs)(c,{flexDirection:`column`,children:[(0,$.jsx)(en,{options:t,onChange:t=>{switch(t){case`view`:r({mode:`view-agent`,agent:e,previousMode:n.previousMode});break;case`edit`:r({mode:`edit-agent`,agent:e,previousMode:n});break;case`delete`:r({mode:`delete-confirm`,agent:e,previousMode:n});break;case`back`:r(n.previousMode);break}},onCancel:()=>r(n.previousMode)}),f.length>0&&(0,$.jsx)(c,{marginTop:1,children:(0,$.jsx)(l,{dimColor:!0,children:f[f.length-1]})})]})}),(0,$.jsx)(Tr,{})]})}case`view-agent`:{let e=u.find(e=>e.agentType===n.agent.agentType&&e.source===n.agent.source)||n.agent;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(g,{title:e.agentType,onCancel:()=>r({mode:`agent-menu`,agent:e,previousMode:n.previousMode}),hideInputGuide:!0,children:(0,$.jsx)(cr,{agent:e,tools:h,allAgents:u,onBack:()=>r({mode:`agent-menu`,agent:e,previousMode:n.previousMode})})}),(0,$.jsx)(Tr,{instructions:`Press Enter or Esc to go back`})]})}case`delete-confirm`:return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(g,{title:`Delete agent`,onCancel:()=>{`previousMode`in n&&r(n.previousMode)},color:`error`,children:[(0,$.jsxs)(l,{children:[`Are you sure you want to delete the agent `,(0,$.jsx)(l,{bold:!0,children:n.agent.agentType}),`?`]}),(0,$.jsx)(c,{marginTop:1,children:(0,$.jsxs)(l,{dimColor:!0,children:[`Source: `,n.agent.source]})}),(0,$.jsx)(c,{marginTop:1,children:(0,$.jsx)(en,{options:[{label:`Yes, delete`,value:`yes`},{label:`No, cancel`,value:`no`}],onChange:e=>{e===`yes`?y(n.agent):`previousMode`in n&&r(n.previousMode)},onCancel:()=>{`previousMode`in n&&r(n.previousMode)}})})]}),(0,$.jsx)(Tr,{instructions:`Press ↑↓ to navigate, Enter to select, Esc to cancel`})]});case`edit-agent`:{let e=u.find(e=>e.agentType===n.agent.agentType&&e.source===n.agent.source)||n.agent;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(g,{title:`Edit agent: ${e.agentType}`,onCancel:()=>r(n.previousMode),hideInputGuide:!0,children:(0,$.jsx)(Cr,{agent:e,tools:h,onSaved:e=>{v(e),r(n.previousMode)},onBack:()=>r(n.previousMode)})}),(0,$.jsx)(Tr,{})]})}default:return null}}var Oi,$,ki=e((()=>{m(),Oi=t(f(),1),Xt(),an(),h(),Le(),Wt(),at(),Ct(),jt(),$t(),lr(),wr(),Dr(),Ar(),sr(),Ei(),$=_()}));async function Ai(e,t){let n=t.getAppState().toolPermissionContext;return(0,ji.jsx)(Di,{tools:Ee(n),onExit:e})}var ji;e((()=>{ki(),Qe(),ji=_()}))();export{Ai as call};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{i as e,o as t,r as n}from"./loadAgentsDir-
|
|
1
|
+
import{i as e,o as t,r as n}from"./loadAgentsDir-BfLCckVj.js";import{n as r,t as i}from"./cwd-DrEEb4f5.js";import{a,i as o,n as s,o as c,r as l,t as u}from"./agentDisplay-ChkgiTIH.js";o(),t(),r();function d(e){let t=a(e),n=[e.agentType];return t&&n.push(t),e.memory&&n.push(`${e.memory} memory`),n.join(` · `)}async function f(){let{allAgents:t}=await e(i()),r=c(t,n(t)),a=[],o=0;for(let{label:e,source:t}of u){let n=r.filter(e=>e.source===t).sort(s);if(n.length!==0){a.push(`${e}:`);for(let e of n)if(e.overriddenBy){let t=l(e.overriddenBy);a.push(` (shadowed by ${t}) ${d(e)}`)}else a.push(` ${d(e)}`),o++;a.push(``)}}a.length===0?console.log(`No agents found.`):(console.log(`${o} active agents\n`),console.log(a.join(`
|
|
2
2
|
`).trimEnd()))}export{f as agentsHandler};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{l as t,m as n}from"./settings-D4M13toi.js";import{ff as r,uf as i}from"./loadAgentsDir-BfLCckVj.js";function a(){let e=t(),n=[`user`,`project`,`local`].flatMap(e=>i(e).errors);return{settings:e.settings,errors:[...e.errors,...n]}}var o=e((()=>{r(),n()}));export{o as n,a as t};
|
package/dist/chunks/{backgroundHousekeeping-CsXlkIg3.js → backgroundHousekeeping-1VsWy8xd.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e,o as t}from"./envUtils-QyzA_cFM.js";import{_ as n,d as r,m as i}from"./settings-D4M13toi.js";import{P as a,Pt as o,z as s}from"./state-CXY-q5gr.js";import{
|
|
1
|
+
import{i as e,o as t}from"./envUtils-QyzA_cFM.js";import{_ as n,d as r,m as i}from"./settings-D4M13toi.js";import{P as a,Pt as o,z as s}from"./state-CXY-q5gr.js";import{Bu as c,Lu as l,ac as u,cr as d,hb as f,mt as p,oc as m,pb as h,vr as g,wt as _}from"./loadAgentsDir-BfLCckVj.js";import{c as v,f as y,i as b,u as x}from"./debug-2pVES-2G.js";import{_ as S,o as C,s as w,v as T}from"./log-L1kqxa_P.js";import{n as E}from"./analytics-COpjZpvd.js";import{r as D,t as O}from"./pasteStore-njJCBMKr.js";import{r as k}from"./magicDocs-Bue9vxzY.js";import{i as A,t as j}from"./nativeInstaller-CGSNzGNn.js";import{n as M,t as N}from"./allErrors-CkdguCDv.js";import{n as P,t as F}from"./pluginAutoupdate-D5XyiZrP.js";import{join as I}from"path";o(),m(),k(),E(),T(),b(),t(),y(),c(),C(),D(),g(),M(),i(),f(),_();var L=30;function R(){let e=((r()||{}).cleanupPeriodDays??L)*24*60*60*1e3;return new Date(Date.now()-e)}function z(e,t){return{messages:e.messages+t.messages,errors:e.errors+t.errors}}function B(e){let t=e.split(`.`)[0].replace(/T(\d{2})-(\d{2})-(\d{2})-(\d{3})Z/,`T$1:$2:$3.$4Z`);return new Date(t)}async function V(e,t,n){let r={messages:0,errors:0};try{let i=await x().readdir(e);for(let a of i)try{B(a.name)<t&&(await x().unlink(I(e,a.name)),n?r.messages++:r.errors++)}catch(e){w(e)}}catch(e){e instanceof Error&&`code`in e&&e.code!==`ENOENT`&&w(e)}return r}async function H(){let e=x(),t=R(),n=S.errors(),r=S.baseLogs(),i=await V(n,t,!1);try{let n;try{n=await e.readdir(r)}catch{return i}let a=n.filter(e=>e.isDirectory()&&e.name.startsWith(`mcp-logs-`)).map(e=>I(r,e.name));for(let n of a)i=z(i,await V(n,t,!0)),await W(n,e)}catch(e){e instanceof Error&&`code`in e&&e.code!==`ENOENT`&&w(e)}return i}async function U(e,t,n){return(await n.stat(e)).mtime<t?(await n.unlink(e),!0):!1}async function W(e,t){try{await t.rmdir(e)}catch{}}async function G(){let e=R(),t={messages:0,errors:0},n=d(),r=x(),i;try{i=await r.readdir(n)}catch{return t}for(let a of i){if(!a.isDirectory())continue;let i=I(n,a.name),o;try{o=await r.readdir(i)}catch{t.errors++;continue}for(let n of o)if(n.isFile()){if(!n.name.endsWith(`.jsonl`)&&!n.name.endsWith(`.cast`))continue;try{await U(I(i,n.name),e,r)&&t.messages++}catch{t.errors++}}else if(n.isDirectory()){let a=I(i,n.name),o=I(a,h),s;try{s=await r.readdir(o)}catch{await W(a,r);continue}for(let n of s)if(n.isFile())try{await U(I(o,n.name),e,r)&&t.messages++}catch{t.errors++}else if(n.isDirectory()){let i=I(o,n.name),a;try{a=await r.readdir(i)}catch{continue}for(let n of a)if(n.isFile())try{await U(I(i,n.name),e,r)&&t.messages++}catch{t.errors++}await W(i,r)}await W(o,r),await W(a,r)}await W(i,r)}return t}async function K(e,t,n=!0){let r=R(),i={messages:0,errors:0},a=x(),o;try{o=await a.readdir(e)}catch{return i}for(let n of o)if(!(!n.isFile()||!n.name.endsWith(t)))try{await U(I(e,n.name),r,a)&&i.messages++}catch{i.errors++}return n&&await W(e,a),i}function q(){return K(I(e(),`plans`),`.md`)}async function J(){let t=R(),n={messages:0,errors:0},r=x();try{let i=I(e(),`file-history`),a;try{a=await r.readdir(i)}catch{return n}let o=a.filter(e=>e.isDirectory()).map(e=>I(i,e.name));await Promise.all(o.map(async e=>{try{(await r.stat(e)).mtime<t&&(await r.rm(e,{recursive:!0,force:!0}),n.messages++)}catch{n.errors++}})),await W(i,r)}catch(e){w(e)}return n}async function Y(){let t=R(),n={messages:0,errors:0},r=x();try{let i=I(e(),`session-env`),a;try{a=await r.readdir(i)}catch{return n}let o=a.filter(e=>e.isDirectory()).map(e=>I(i,e.name));for(let e of o)try{(await r.stat(e)).mtime<t&&(await r.rm(e,{recursive:!0,force:!0}),n.messages++)}catch{n.errors++}await W(i,r)}catch(e){w(e)}return n}async function X(){let t=R(),n={messages:0,errors:0},r=x(),i=I(e(),`debug`),a;try{a=await r.readdir(i)}catch{return n}for(let e of a)if(!(!e.isFile()||!e.name.endsWith(`.txt`)||e.name===`latest`))try{await U(I(i,e.name),t,r)&&n.messages++}catch{n.errors++}return n}async function Z(){let{errors:e}=N();if(e.length>0&&n(`cleanupPeriodDays`)){v(`Skipping cleanup: settings have validation errors but cleanupPeriodDays was explicitly set. Fix settings errors to enable cleanup.`);return}await H(),await G(),await q(),await J(),await Y(),await X(),await l(),await O(R()),await p(R())}j(),P();var Q=600*1e3;function $(){import(`./extractMemories-DHlbRc5g.js`).then(({initExtractMemories:e})=>{e()}).catch(()=>{}),u(),F();let e=!0;async function t(){if(a()&&s()>Date.now()-1e3*60){setTimeout(t,Q).unref();return}if(e&&(e=!1,await Z()),a()&&s()>Date.now()-1e3*60){setTimeout(t,Q).unref();return}await A()}setTimeout(t,Q).unref()}export{$ as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./backgroundHousekeeping-1VsWy8xd.js";export{e as startBackgroundHousekeeping};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{vn as t,yn as n}from"./settings-D4M13toi.js";import{Pt as r,at as i,q as a}from"./state-CXY-q5gr.js";import{
|
|
2
|
-
`)}\n`,{encoding:`utf8`,mode:384}),{sessionId:t,title:e,forkPath:
|
|
1
|
+
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{vn as t,yn as n}from"./settings-D4M13toi.js";import{Pt as r,at as i,q as a}from"./state-CXY-q5gr.js";import{ci as o,hr as s,mr as c,ni as l,sr as u,vr as d,wr as f}from"./loadAgentsDir-BfLCckVj.js";import{C as p,x as m}from"./debug-2pVES-2G.js";import{n as h}from"./analytics-COpjZpvd.js";import{i as g,o as _}from"./stringUtils-Cs6E5f-B.js";import{randomUUID as v}from"crypto";import{mkdir as y,readFile as b,writeFile as x}from"fs/promises";function S(e){let t=e?.message?.content;if(!t)return`Branched conversation`;let n=typeof t==`string`?t:t.find(e=>e.type===`text`)?.text;return n&&n.replace(/\s+/g,` `).trim().slice(0,100)||`Branched conversation`}async function C(e){let t=v(),r=i(),o=u(a()),l=s(t),d=c();await y(o,{recursive:!0,mode:448});let m;try{m=await b(d)}catch{throw Error(`No conversation to branch`)}if(m.length===0)throw Error(`No conversation to branch`);let h=n(m),g=h.filter(e=>f(e)&&!e.isSidechain),_=h.filter(e=>e.type===`content-replacement`&&e.sessionId===r).flatMap(e=>e.replacements);if(g.length===0)throw Error(`No messages to branch`);let S=null,C=[],w=[];for(let e of g){let n={...e,sessionId:t,parentUuid:S,isSidechain:!1,forkedFrom:{sessionId:r,messageUuid:e.uuid}},i={...e,sessionId:t};w.push(i),C.push(p(n)),e.type!==`progress`&&(S=e.uuid)}if(_.length>0){let e={type:`content-replacement`,sessionId:t,replacements:_};C.push(p(e))}return await x(l,`${C.join(`
|
|
2
|
+
`)}\n`,{encoding:`utf8`,mode:384}),{sessionId:t,title:e,forkPath:l,serializedMessages:w,contentReplacementRecords:_}}async function w(e){let t=`${e} (Branch)`;if((await o(t,{exact:!0})).length===0)return t;let n=await o(`${e} (Branch`),r=new Set([1]),i=RegExp(`^${g(e)} \\(Branch(?: (\\d+))?\\)$`);for(let e of n){let t=e.customTitle?.match(i);t&&(t[1]?r.add(parseInt(t[1],10)):r.add(1))}let a=2;for(;r.has(a);)a++;return`${e} (Branch ${a})`}async function T(e,t,n){let r=n?.trim()||void 0,a=i();try{let{sessionId:n,title:i,forkPath:o,serializedMessages:s,contentReplacementRecords:c}=await C(r),u=new Date,d=S(s.find(e=>e.type===`user`)),f=await w(i??d);await l(n,f,o),s.length;let p={date:u.toISOString().split(`T`)[0],messages:s,fullPath:o,value:u.getTime(),created:u,modified:u,firstPrompt:d,messageCount:s.length,isSidechain:!1,sessionId:n,customTitle:f,contentReplacements:c},m=i?` "${i}"`:``,h=`Branched conversation${m}. You are now in the branch.${`\nTo resume the original: claude -r ${a}`}`;return t.resume?(await t.resume(n,p,`fork`),e(h,{display:`system`})):e(`Branched conversation${m}. Resume with: /resume ${n}`),null}catch(t){return e(`Failed to branch conversation: ${t instanceof Error?t.message:`Unknown error occurred`}`),null}}e((()=>{r(),h(),t(),d(),m(),_()}))();export{T as call,S as deriveFirstPrompt};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{i as t,o as n}from"./envUtils-QyzA_cFM.js";import{Gi as r,Ni as i,Vi as a,Wi as o,ea as s,ia as c,oa as l,ta as u}from"./settings-D4M13toi.js";import{c as d,i as f}from"./debug-2pVES-2G.js";import{o as p,s as m}from"./log-L1kqxa_P.js";import{join as h}from"node:path";import{spawn as g,spawnSync as _}from"node:child_process";import{chmodSync as v,existsSync as y,mkdirSync as b,readFileSync as x,renameSync as S,writeFileSync as C}from"node:fs";function w(){return h(t(),`channel`)}function T(){return h(w(),`dingtalk.json`)}function E(){return M.parse({})}function D(){let e=T();try{if(!y(e))return E();let t=x(e,`utf8`),n=JSON.parse(t);return M.parse(n)}catch(e){return m(e),E()}}function O(e){let t=T(),n=e(D());b(w(),{recursive:!0});let r=`${t}.${process.pid}.tmp`;C(r,`${JSON.stringify(n,null,2)}\n`,{mode:384}),S(r,t);try{v(t,384)}catch{}return n}function k(e){return e.channel?.enabled===!0&&e.channel?.activePlugin===`dingtalk`}function A(e){return e.permissionMode}var j,M,N=e((()=>{i(),n(),p(),j=u({workmateSessionId:l(),lastActiveAt:s(),senderId:l().optional()}),M=u({corpid:l().default(``),appKey:l().default(``),appSecret:l().default(``),robotName:l().default(`workmate`),cardTemplateId:l().default(``),permissionMode:a([`default`,`acceptEdits`,`bypassPermissions`,`plan`,`dontAsk`,`auto`]).default(`
|
|
1
|
+
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{i as t,o as n}from"./envUtils-QyzA_cFM.js";import{Gi as r,Ni as i,Vi as a,Wi as o,ea as s,ia as c,oa as l,ta as u}from"./settings-D4M13toi.js";import{c as d,i as f}from"./debug-2pVES-2G.js";import{o as p,s as m}from"./log-L1kqxa_P.js";import{join as h}from"node:path";import{spawn as g,spawnSync as _}from"node:child_process";import{chmodSync as v,existsSync as y,mkdirSync as b,readFileSync as x,renameSync as S,writeFileSync as C}from"node:fs";function w(){return h(t(),`channel`)}function T(){return h(w(),`dingtalk.json`)}function E(){return M.parse({})}function D(){let e=T();try{if(!y(e))return E();let t=x(e,`utf8`),n=JSON.parse(t);return M.parse(n)}catch(e){return m(e),E()}}function O(e){let t=T(),n=e(D());b(w(),{recursive:!0});let r=`${t}.${process.pid}.tmp`;C(r,`${JSON.stringify(n,null,2)}\n`,{mode:384}),S(r,t);try{v(t,384)}catch{}return n}function k(e){return e.channel?.enabled===!0&&e.channel?.activePlugin===`dingtalk`}function A(e){return e.permissionMode}var j,M,N=e((()=>{i(),n(),p(),j=u({workmateSessionId:l(),lastActiveAt:s(),senderId:l().optional()}),M=u({corpid:l().default(``),appKey:l().default(``),appSecret:l().default(``),robotName:l().default(`workmate`),cardTemplateId:l().default(``),permissionMode:a([`default`,`acceptEdits`,`bypassPermissions`,`plan`,`dontAsk`,`auto`]).default(`default`),sessionStrategy:a([`perConversation`,`perUser`,`shared`]).default(`perConversation`),confirmDangerous:r().default(!0),confirmTimeoutMs:s().default(300*1e3),admins:o(l()).default([]),sessions:c(l(),j).default({})})}));function P(){let e=R();if(e)return d(`[channel] bridge 已在运行,pid=${e}`,{level:`debug`}),{pid:e,started:!1};let t=process.argv[1],n=t&&/\.(cjs|js|mjs)$/.test(t)?[t,`channel`,`start`]:[`channel`,`start`],r=g(process.execPath,n,{detached:!0,stdio:`ignore`,cwd:process.cwd()});r.unref();let i=r.pid;return i?(d(`[channel] bridge 已启动,pid=${i}`,{level:`debug`}),{pid:i,started:!0}):{pid:0,started:!1}}function F(){let e=R();if(!e)return!1;try{return process.kill(e,`SIGTERM`),d(`[channel] 已发 SIGTERM 给 bridge pid=${e}`,{level:`debug`}),!0}catch(e){return m(e),!1}}function I(){return R()!==null}function L(){return R()}function R(){let e=_(`pgrep`,[`-f`,z],{encoding:`utf8`});if(e.status!==0||!e.stdout.trim())return null;let t=e.stdout.trim().split(`
|
|
2
2
|
`).map(Number).filter(e=>e&&e!==process.pid);return t.length?t[t.length-1]:null}var z,B=e((()=>{f(),p(),z=`channel start`}));export{F as a,N as c,P as i,k as l,B as n,D as o,I as r,A as s,L as t,O as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{I as n,P as r,ai as i,bn as a,ot as o,t as s,vn as c,xt as l}from"./src-BX54x08P.js";import{t as u}from"./jsx-runtime-Bb4Xn-E0.js";import{Gt as d}from"./settings-D4M13toi.js";import{
|
|
1
|
+
import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{I as n,P as r,ai as i,bn as a,ot as o,t as s,vn as c,xt as l}from"./src-BX54x08P.js";import{t as u}from"./jsx-runtime-Bb4Xn-E0.js";import{Gt as d}from"./settings-D4M13toi.js";import{Bx as f,Gs as p,Hv as m,I_ as h,Ks as g,L_ as _,R_ as v,Vv as y,Xi as b,ct as x,dd as S,lb as C,lt as w,pd as T,qS as E,ry as D}from"./loadAgentsDir-BfLCckVj.js";import{I as O,M as k}from"./debug-2pVES-2G.js";import{d as A,h as j}from"./config-Bio2EjUK.js";import{n as M,t as N}from"./SpinnerGlyph-BR_SiV9L.js";import{n as P,r as F}from"./sideQuestion-C8GNVo4R.js";import{i as I,n as L}from"./modalContext-sU2lfR08.js";function R({question:e,context:t,onDone:i}){let[s,c]=(0,H.useState)(null),[u,d]=(0,H.useState)(null),[f,p]=(0,H.useState)(0),m=(0,H.useRef)(null),{rows:h}=I(o());a(()=>p(e=>e+1),s||u?null:80);function g(e){if(e.key===`escape`||e.key===`return`||e.key===` `||e.ctrl&&(e.key===`c`||e.key===`d`)){e.preventDefault(),i(void 0,{display:`skip`});return}(e.key===`up`||e.ctrl&&e.key===`p`)&&(e.preventDefault(),m.current?.scrollBy(-3)),(e.key===`down`||e.ctrl&&e.key===`n`)&&(e.preventDefault(),m.current?.scrollBy(K))}(0,H.useEffect)(()=>{let n=y();async function r(){try{let r=await F({question:e,cacheSafeParams:await B(t)});n.signal.aborted||(r.response?c(r.response):d(`No response received`))}catch(e){n.signal.aborted||d(k(e)||`Failed to get response`)}}return r(),()=>{n.abort()}},[e,t]);let _=Math.max(5,h-W-G);return(0,U.jsxs)(n,{flexDirection:`column`,paddingLeft:2,marginTop:1,tabIndex:0,autoFocus:!0,onKeyDown:g,children:[(0,U.jsxs)(n,{children:[(0,U.jsxs)(r,{color:`warning`,bold:!0,children:[`/btw`,` `]}),(0,U.jsx)(r,{dimColor:!0,children:e})]}),(0,U.jsx)(n,{marginTop:1,marginLeft:2,maxHeight:_,children:(0,U.jsx)(l,{ref:m,flexDirection:`column`,flexGrow:1,children:u?(0,U.jsx)(r,{color:`error`,children:u}):s?(0,U.jsx)(S,{children:s}):(0,U.jsxs)(n,{children:[(0,U.jsx)(N,{frame:f,messageColor:`warning`}),(0,U.jsx)(r,{color:`warning`,children:`Answering...`})]})})}),(s||u)&&(0,U.jsx)(n,{marginTop:1,children:(0,U.jsxs)(r,{dimColor:!0,children:[`↑`,`/`,`↓`,` to scroll · Space, Enter, or Escape to dismiss`]})})]})}function z(e){let t=e.at(-1);return t?.type===`assistant`&&t.message.stop_reason===null?e.slice(0,-1):e}async function B(e){let t=f(z(e.messages)),n=p();if(n)return{systemPrompt:n.systemPrompt,userContext:n.userContext,systemContext:n.systemContext,toolUseContext:e,forkContextMessages:t};let[r,i,a]=await Promise.all([x(e.options.tools,e.options.mainLoopModel,[],e.options.mcpClients),_(),h()]);return{systemPrompt:E(r),userContext:i,systemContext:a,toolUseContext:e,forkContextMessages:t}}async function V(e,t,n){let r=n?.trim();return r?(j(e=>({...e,btwUseCount:e.btwUseCount+1})),(0,U.jsx)(R,{question:r,context:t,onDone:e})):(e(`Usage: /btw <your question>`,{display:`system`}),null)}var H,U,W,G,K;e((()=>{H=t(i(),1),c(),T(),M(),d(),w(),L(),v(),C(),s(),m(),A(),O(),g(),b(),P(),D(),U=u(),W=5,G=6,K=3}))();export{V as call};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,t}from"./caches-fqs-Y-kW.js";e();export{t as clearSessionCaches};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{ei as t,ii as n}from"./settings-D4M13toi.js";import{Pt as r,l as i,mn as a}from"./state-CXY-q5gr.js";import{B_ as o,Bu as s,F_ as c,Hi as l,I_ as u,Ki as d,L_ as f,My as p,Pi as m,Pp as h,R_ as g,Ru as _,Tb as v,Ti as y,V_ as b,Y as x,_p as S,dh as C,dm as w,fh as T,hp as E,is as D,jy as O,lm as k,q as A,rs as j,wb as M,z_ as N}from"./loadAgentsDir-BfLCckVj.js";import{a as P,n as F}from"./fileSuggestions-BRwKV_KA.js";import{r as I,t as L}from"./magicDocs-Bue9vxzY.js";import{r as R,t as z}from"./detectRepository--luIRv5H.js";function B(e=new Set){let n=e.size>0;f.cache.clear?.(),u.cache.clear?.(),c.cache.clear?.(),o.cache.clear?.(),F(),y(),n||S(),N(null),a(null),w(),D(),p(`session_start`),_(),z(),A(),i(e),t(),l(),T(),L(),M(),import(`./SearchExtraToolsTool-BINZTstr.js`).then(({clearSearchExtraToolsDescriptionCache:e})=>e()),import(`./loadAgentsDir-BImZsKrh.js`).then(({clearAgentDefinitionsCache:e})=>e()),import(`./prompt-CAzFDybL.js`).then(({clearPromptCache:e})=>e())}var V=e((()=>{r(),m(),b(),g(),P(),h(),E(),k(),C(),I(),d(),j(),x(),O(),R(),n(),s(),v()}));export{V as n,B as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,t}from"./defineProperty-C-QyHrDq.js";import{n,t as r}from"./axios-DaWTGg7G.js";import{n as i,r as a}from"./wrapper-DVKxC5fR.js";import{Pt as o,Vt as s}from"./settings-D4M13toi.js";import{U as c,W as l}from"./loadAgentsDir-BfLCckVj.js";import{c as u,i as d}from"./debug-2pVES-2G.js";import{d as f,o as p}from"./config-Bio2EjUK.js";import{o as m,s as h}from"./log-L1kqxa_P.js";import{c as g,l as _,n as v,o as y,r as b,s as x,t as S,u as C}from"./bridgeControl-C8xaGuwO.js";import{createInterface as w}from"node:readline";import{spawn as T}from"node:child_process";import{randomUUID as E}from"node:crypto";import{EventEmitter as D}from"node:events";import O from"events";m(),c(),g(),v(),d(),e();var k=`https://api.dingtalk.com`,A=`https://oapi.dingtalk.com`,j=`/gettoken`,M=`/v1.0/card/instances/createAndDeliver`,N=`/v1.0/card/streaming`,P=300*1e3,F=class{constructor(e){t(this,`opts`,void 0),t(this,`tokenCache`,null),this.opts=e}async getAccessToken(){if(this.tokenCache&&Date.now()<this.tokenCache.expiresAt-P)return this.tokenCache.token;let e=`${A}${j}?appkey=${encodeURIComponent(this.opts.appKey)}&appsecret=${encodeURIComponent(this.opts.appSecret)}`,t=await(await fetch(e)).json();if(t.errcode!==0||!t.access_token)throw Error(`gettoken 失败: errcode=${t.errcode} errmsg=${t.errmsg}`);return this.tokenCache={token:t.access_token,expiresAt:Date.now()+(t.expires_in??7200)*1e3},t.access_token}async createAndDeliverCard(e){let t=E(),n=e.conversationType===`2`,r=await this.getAccessToken(),i=n?`IM_GROUP`:`IM_ROBOT`,a=n?e.conversationId:e.senderStaffId,o={cardTemplateId:e.cardTemplateId,outTrackId:t,cardData:{cardParamMap:{content:e.initialMarkdown}},openSpaceId:`dtv1.card//${i}.${a}`};n?(o.imGroupOpenSpaceModel={supportForward:!0},o.imGroupOpenDeliverModel={robotCode:this.opts.robotCode}):(o.imRobotOpenSpaceModel={supportForward:!0},o.imRobotOpenDeliverModel={robotCode:this.opts.robotCode});let s=await fetch(`${k}${M}`,{method:`POST`,headers:{"Content-Type":`application/json`,"x-acs-dingtalk-access-token":r},body:JSON.stringify(o)});if(!s.ok){let e=await s.text();throw Error(`createAndDeliver 失败: ${s.status} ${e}`)}return u(`[channel] 卡片已创建 outTrackId=${t} ${n?`群聊`:`单聊`}`,{level:`debug`}),t}async streamingUpdate(e,t,n={}){let r=await this.getAccessToken(),i={outTrackId:e,guid:E(),key:`content`,content:t,isFull:!0,isFinalize:n.finalize??!1,isError:n.error??!1},a=await fetch(`${k}${N}`,{method:`PUT`,headers:{"Content-Type":`application/json`,"x-acs-dingtalk-access-token":r},body:JSON.stringify(i)});if(!a.ok){let e=await a.text();throw Error(`streaming 失败: ${a.status} ${e}`)}u(`[channel] streaming 推送 finalize=${n.finalize??!1} len=${t.length}`,{level:`debug`})}},I=`https://api.dingtalk.com/v1.0/gateway/connections/open`,L=`https://oapi.dingtalk.com/gettoken`,R=`/v1.0/im/bot/messages/get`;i(),r(),e();var z={autoReconnect:!0,keepAlive:!1,ua:``,subscriptions:[{type:`EVENT`,topic:`*`}]},B=class extends O{constructor(e){if(super(),t(this,`debug`,!1),t(this,`connected`,!1),t(this,`registered`,!1),t(this,`reconnecting`,!1),t(this,`userDisconnect`,!1),t(this,`reconnectBaseInterval`,1e3),t(this,`reconnectMaxInterval`,6e4),t(this,`reconnectAttempts`,0),t(this,`heartbeat_interval`,8e3),t(this,`heartbeatIntervallId`,void 0),t(this,`reconnectTimerId`,void 0),t(this,`isConnecting`,!1),t(this,`sslopts`,{rejectUnauthorized:!0}),t(this,`config`,void 0),t(this,`socket`,void 0),t(this,`dw_url`,void 0),t(this,`isAlive`,!1),t(this,`onEventReceived`,e=>({status:`SUCCESS`})),this.config={...z,...e},!this.config.clientId||!this.config.clientSecret)throw console.error(`clientId or clientSecret is null`),Error(`clientId or clientSecret is null`);this.config.debug!==void 0&&(this.debug=this.config.debug)}getConfig(){return{...this.config}}printDebug(e){if(this.debug){let t=`[`+new Date().toISOString()+`]`;console.info(t,e)}}registerAllEventListener(e){return this.onEventReceived=e,this}registerCallbackListener(e,t){if(!e||!t)throw console.error(`registerCallbackListener: eventId and callback must be defined`),Error(`registerCallbackListener: eventId and callback must be defined`);return this.config.subscriptions.find(t=>t.topic===e&&t.type===`CALLBACK`)||this.config.subscriptions.push({type:`CALLBACK`,topic:e}),this.on(e,t),this}async getAccessToken(){let e=await n.get(`${L}?appkey=${this.config.clientId}&appsecret=${this.config.clientSecret}`);if(e.status===200&&e.data.access_token)return this.config.access_token=e.data.access_token,e.data.access_token;throw Error(`getAccessToken: get access_token failed`)}async getEndpoint(){this.printDebug(`get connect endpoint by config`),this.printDebug(this.config);let e=await n({url:I,method:`POST`,responseType:`json`,data:{clientId:this.config.clientId,clientSecret:this.config.clientSecret,ua:this.config.ua,subscriptions:this.config.subscriptions},headers:{Accept:`application/json`}});if(this.printDebug(`res.data `+JSON.stringify(e.data)),e.data){this.config.endpoint=e.data;let{endpoint:t,ticket:n}=e.data;if(!t||!n)throw this.printDebug(`endpoint or ticket is null`),Error(`endpoint or ticket is null`);return this.dw_url=`${t}?ticket=${n}`,this}else throw Error(`build: get endpoint failed`)}cleanup(){this.heartbeatIntervallId!==void 0&&(clearInterval(this.heartbeatIntervallId),this.heartbeatIntervallId=void 0),this.socket&&(this.socket.removeAllListeners(),(this.socket.readyState===a.OPEN||this.socket.readyState===a.CONNECTING)&&this.socket.terminate(),this.socket=void 0)}scheduleReconnect(){if(!this.config.autoReconnect||this.userDisconnect||this.isConnecting)return;let e=Math.min(this.reconnectBaseInterval*2**this.reconnectAttempts+Math.random()*1e3,this.reconnectMaxInterval);this.reconnecting=!0,this.printDebug(`Reconnecting in `+(e/1e3).toFixed(1)+` seconds... (attempt `+(this.reconnectAttempts+1)+`)`),this.reconnectTimerId&&clearTimeout(this.reconnectTimerId),this.reconnectTimerId=setTimeout(()=>{this.reconnectTimerId=void 0,this.connect()},e)}_connect(){return new Promise((e,t)=>{this.printDebug(`Connecting to dingtalk websocket @ `+this.dw_url);try{this.socket=new a(this.dw_url,this.sslopts)}catch(e){this.printDebug(`WebSocket constructor error`),console.warn(`ERROR`,e),t(e);return}let n=!1;this.socket.on(`open`,()=>{this.connected=!0,this.reconnectAttempts=0,console.info(`[`+new Date().toISOString()+`] connect success`),this.config.keepAlive&&(this.isAlive=!0,this.heartbeatIntervallId=setInterval(()=>{var e;if(this.isAlive===!1)return console.error(`TERMINATE SOCKET: Ping Pong does not transfer heartbeat within heartbeat intervall`),this.socket?.terminate();this.isAlive=!1,(e=this.socket)==null||e.ping(``,!0)},this.heartbeat_interval)),n=!0,e()}),this.socket.on(`pong`,()=>{this.heartbeat()}),this.socket.on(`message`,e=>{this.onDownStream(e)}),this.socket.on(`close`,()=>{this.printDebug(`Socket closed`),this.connected=!1,this.registered=!1,this.heartbeatIntervallId!==void 0&&(clearInterval(this.heartbeatIntervallId),this.heartbeatIntervallId=void 0),n&&this.scheduleReconnect()}),this.socket.on(`error`,e=>{var r;this.printDebug(`SOCKET ERROR`),console.warn(`ERROR`,e),(r=this.socket)==null||r.terminate(),n||(n=!0,t(e))})})}async connect(){if(this.isConnecting){this.printDebug(`connect() already in progress, skipping`);return}this.userDisconnect=!1,this.isConnecting=!0;try{if(this.cleanup(),await this.getEndpoint(),this.userDisconnect)return;await this._connect()}catch(e){this.printDebug(`Connect failed: `+(e instanceof Error?e.message:String(e))),this.userDisconnect||(this.reconnectAttempts++,this.isConnecting=!1,this.scheduleReconnect());return}finally{this.isConnecting=!1}}disconnect(){console.info(`Disconnecting.`),this.userDisconnect=!0,this.reconnectTimerId&&(clearTimeout(this.reconnectTimerId),this.reconnectTimerId=void 0),this.reconnecting=!1,this.reconnectAttempts=0,this.cleanup(),this.connected=!1,this.registered=!1}heartbeat(){this.isAlive=!0,this.printDebug(`CLIENT-SIDE HEARTBEAT`)}onDownStream(e){this.printDebug(`Received message from dingtalk websocket server`);let t=JSON.parse(e);switch(this.printDebug(t),t.type){case`SYSTEM`:this.onSystem(t);break;case`EVENT`:this.onEvent(t);break;case`CALLBACK`:this.onCallback(t);break}}onSystem(e){var t;switch(e.headers.topic){case`CONNECTED`:this.printDebug(`CONNECTED`);break;case`REGISTERED`:this.registered=!0,this.reconnecting=!1;break;case`disconnect`:this.connected=!1,this.registered=!1;break;case`KEEPALIVE`:this.heartbeat();break;case`ping`:this.printDebug(`PING`),(t=this.socket)==null||t.send(JSON.stringify({code:200,headers:e.headers,message:`OK`,data:e.data}));break}}onEvent(e){var t;this.printDebug(`received event, message=`+JSON.stringify(e));let n=this.onEventReceived(e);(t=this.socket)==null||t.send(JSON.stringify({code:200,headers:{contentType:`application/json`,messageId:e.headers.messageId},message:`OK`,data:JSON.stringify(n)}))}onCallback(e){this.emit(e.headers.topic,e)}send(e,t){var n;if(!e)throw console.error(`send: messageId must be defined`),Error(`send: messageId must be defined`);let r={code:200,headers:{contentType:`application/json`,messageId:e},message:`OK`,data:JSON.stringify(t)};(n=this.socket)==null||n.send(JSON.stringify(r))}socketCallBackResponse(e,t){this.send(e,{response:t})}sendGraphAPIResponse(e,t){var n;if(!e)throw console.error(`send: messageId must be defined`),Error(`send: messageId must be defined`);let r={code:200,headers:{contentType:`application/json`,messageId:e},message:`OK`,data:JSON.stringify(t)};(n=this.socket)==null||n.send(JSON.stringify(r))}};i(),d(),e();var V=class{constructor(e){t(this,`opts`,void 0),t(this,`client`,void 0),t(this,`messageHandler`,void 0),this.opts=e,this.client=new B({clientId:e.appKey,clientSecret:e.appSecret,debug:!1,keepAlive:!0})}onMessage(e){this.messageHandler=e,this.client.registerCallbackListener(R,e=>{this.handleDownstream(e)})}handleDownstream(e){try{let t=JSON.parse(e.data);if(u(`[channel] downstream 到达: msgtype=${t.msgtype} sender=${t.senderNick} conv=${t.conversationId}`,{level:`debug`}),t.msgtype!==`text`||!t.text?.content){u(`[channel] 丢弃: msgtype=${t.msgtype} 非文本或空 content`,{level:`debug`});return}let n=t.text.content.trim(),r=this.stripMention(n);if(!r){u(`[channel] 丢弃: 纯 @ 无正文`,{level:`debug`});return}u(`[channel] 派发消息: text="${r.slice(0,50)}" sender=${t.senderNick}`,{level:`debug`}),this.messageHandler?.({conversationId:t.conversationId,senderStaffId:t.senderStaffId,senderNick:t.senderNick,conversationType:t.conversationType,text:r,msgId:t.msgId,sessionWebhook:t.sessionWebhook,sessionWebhookExpiredTime:t.sessionWebhookExpiredTime,isAdmin:t.isAdmin})}catch(e){h(e)}try{this.client.socketCallBackResponse(e.headers.messageId,{status:`SUCCESS`,message:`OK`})}catch{}}stripMention(e){if(!this.opts.robotName)return e;let t=this.opts.robotName.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);return e.replace(RegExp(`^@${t}\\s*`),``).trim()}async connect(){await this.client.connect(),u(`[channel] dingtalk stream 已连接`,{level:`debug`})}disconnect(){this.client.disconnect()}async sendText(e,t){if(e)try{await fetch(e,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({msgtype:`text`,text:{content:t}})})}catch(e){h(e)}}async sendMarkdown(e,t,n){if(e)try{await fetch(e,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({msgtype:`markdown`,markdown:{title:t,text:n}})})}catch(e){h(e)}}};d(),m(),o(),e();var H=1800*1e3;function U(e){let t=process.argv[1];return t&&/\.(cjs|js|mjs)$/.test(t)?{execPath:process.execPath,args:[t,...e]}:{execPath:process.execPath,args:e}}var W=class{constructor(e){t(this,`opts`,void 0),t(this,`proc`,null),t(this,`rl`,null),t(this,`emitter`,new D),t(this,`lastActiveAt`,Date.now()),t(this,`idleTimer`,null),t(this,`closed`,!1),this.opts=e}onEvent(e){this.emitter.on(`event`,e)}async start(){let e=[`--print`,`--input-format`,`stream-json`,`--output-format`,`stream-json`,`--verbose`,`--permission-mode`,s(this.opts.permissionMode)];this.opts.sessionId&&e.splice(1,0,`--resume`,this.opts.sessionId);let{execPath:t,args:n}=U(e);this.proc=T(t,n,{stdio:[`pipe`,`pipe`,`pipe`],env:{...process.env,WORKMATE_INCLUDE_PARTIAL_MESSAGES:`true`,WORKMATE_STREAMLINED_OUTPUT:`true`}}),this.proc.on(`exit`,e=>{this.closed=!0,this.emit({type:`exit`,code:e}),this.cleanup()}),this.proc.on(`error`,e=>{h(e),this.emit({type:`stderr`,data:String(e)})}),this.proc.stderr&&this.proc.stderr.on(`data`,e=>{let t=e.toString();u(`[channel] workmate stderr: ${t}`,{level:`debug`}),this.emit({type:`stderr`,data:t})}),this.proc.stdout&&(this.rl=w({input:this.proc.stdout,crlfDelay:1/0}),this.rl.on(`line`,e=>this.handleLine(e))),this.idleTimer=setInterval(()=>this.checkIdle(),6e4)}checkIdle(){this.closed||Date.now()-this.lastActiveAt>H&&(u(`[channel] workmate 子进程 idle 超时,回收`,{level:`debug`}),this.kill())}sendUserMessage(e){this.write({type:`user`,message:{role:`user`,content:e},parent_tool_use_id:null,priority:`now`}),this.lastActiveAt=Date.now()}respondPermission(e,t){this.write({type:`control_response`,response:{subtype:`success`,request_id:e,response:t}}),this.lastActiveAt=Date.now()}autoAllow(e){this.respondPermission(e,{behavior:`allow`})}interrupt(){this.write({type:`control_request`,request_id:E(),request:{subtype:`interrupt`}})}handleLine(e){let t=e.trim();if(!t)return;this.lastActiveAt=Date.now();let n;try{n=JSON.parse(t)}catch{return}switch(n.type){case`stream_event`:{let e=n.event;e?.type===`content_block_delta`&&e.delta?.type===`text_delta`&&typeof e.delta.text==`string`?this.emit({type:`text`,text:e.delta.text}):e?.type===`message_stop`&&this.emit({type:`message_end`});break}case`streamlined_text`:this.emit({type:`text`,text:String(n.text)}),this.emit({type:`message_end`});break;case`streamlined_tool_use_summary`:this.emit({type:`tool_summary`,summary:String(n.tool_summary)});break;case`control_request`:{let e=n.request;e?.subtype===`can_use_tool`&&this.emit({type:`permission_request`,requestId:String(n.request_id),toolName:String(e.tool_name??``),input:e.input??{},toolUseId:String(e.tool_use_id??``)});break}case`result`:this.emit({type:`turn_end`,subtype:n.subtype===`error`?`error`:`success`,resultText:typeof n.result==`string`?n.result:void 0,durationMs:typeof n.duration_ms==`number`?n.duration_ms:void 0,sessionId:typeof n.session_id==`string`?n.session_id:void 0});break;case`keep_alive`:break}}emit(e){this.emitter.emit(`event`,e)}write(e){!this.proc?.stdin?.writable||this.closed||this.proc.stdin.write(`${JSON.stringify(e)}\n`)}isAlive(){return!!this.proc&&!this.closed}kill(){if(!(this.closed||!this.proc)){try{this.proc.stdin?.end()}catch{}try{this.proc.kill(`SIGTERM`)}catch{}setTimeout(()=>{try{this.proc?.kill(`SIGKILL`)}catch{}},3e3)}}cleanup(){this.idleTimer&&(clearInterval(this.idleTimer),this.idleTimer=null),this.rl?.close(),this.rl=null,this.closed=!0}async stop(){this.kill(),this.proc&&await new Promise(e=>{if(this.closed)return e();this.proc.once(`exit`,()=>e()),setTimeout(e,5e3)}),this.cleanup()}};d(),m(),e();var G=400;function K(e,t){switch(t){case`perUser`:return`user:${e.senderStaffId}`;case`shared`:return`shared`;default:return`conv:${e.conversationId}`}}var q=class{constructor(e){t(this,`stream`,void 0),t(this,`sessions`,new Map),t(this,`config`,void 0),t(this,`running`,!1),t(this,`cardClient`,void 0),this.config=e??y(),this.stream=new V({appKey:this.config.appKey,appSecret:this.config.appSecret,robotName:this.config.robotName}),this.cardClient=this.config.cardTemplateId?new F({appKey:this.config.appKey,appSecret:this.config.appSecret,robotCode:this.config.appKey}):null}async start(){if(!this.config.appKey||!this.config.appSecret)throw Error(`钉钉 appKey/appSecret 未配置,请在 /channel 里填好`);this.stream.onMessage(e=>{this.handleMessage(e)}),await this.stream.connect(),this.running=!0;let e=()=>void this.stop();process.on(`SIGTERM`,e),process.on(`SIGINT`,e),u(`[channel] bridge 已启动,等待钉钉消息`,{level:`debug`})}async stop(){if(this.running){this.running=!1,this.stream.disconnect();for(let e of this.sessions.values())e.streamTimer&&clearTimeout(e.streamTimer),await e.driver.stop();this.sessions.clear(),u(`[channel] bridge 已停止`,{level:`debug`})}}async handleMessage(e){let t=K(e,this.config.sessionStrategy);u(`[channel] handleMessage: sender=${e.senderNick} conv=${e.conversationId} text="${e.text.slice(0,50)}"`,{level:`debug`});let n=this.sessions.get(t);if(n||(n=await this.createSession(t,e),this.sessions.set(t,n)),n.sessionWebhook=e.sessionWebhook,n.currentSenderStaffId=e.senderStaffId,n.pendingConfirm){let t=J(e.text);if(t!==null){let r=n.pendingConfirm;if(n.pendingConfirm=null,!this.canConfirm(e.senderStaffId,r.senderStaffId)){await this.stream.sendText(e.sessionWebhook,`⚠️ 只有任务发起人或管理员能确认`);return}t.behavior===`terminate`?(n.driver.respondPermission(r.requestId,{behavior:`deny`,message:`用户在钉钉终止任务`}),n.driver.interrupt(),await this.stream.sendText(e.sessionWebhook,`🛑 已终止整个任务`)):(n.driver.respondPermission(r.requestId,t),await this.stream.sendText(e.sessionWebhook,t.behavior===`allow`?`✅ 已同意,继续执行`:`❌ 已拒绝此工具,继续下一步`));return}n.pendingConfirm=null}n.textBuffer=``,n.turnInProgress=!0,n.cardOutTrackId=null,n.conversationType=e.conversationType,n.conversationId=e.conversationId,n.streamTimer&&(clearTimeout(n.streamTimer),n.streamTimer=null),n.driver.sendUserMessage(e.text),u(`[channel] 已发 driver.sendUserMessage`,{level:`debug`})}async createSession(e,t){let n=this.config.sessions[e]?.workmateSessionId??``;u(`[channel] ${n?`复用`:`新建`}会话: ${e} sid=${n||`(待 workmate 分配)`}`,{level:`debug`});let r=new W({sessionId:n||null,permissionMode:x(this.config)});return await r.start(),r.onEvent(t=>{this.handleDriverEvent(e,t)}),{driver:r,workmateSessionId:n,sessionWebhook:t.sessionWebhook,currentSenderStaffId:t.senderStaffId,conversationType:t.conversationType,conversationId:t.conversationId,textBuffer:``,turnInProgress:!1,pendingConfirm:null,cardOutTrackId:null,streamTimer:null}}async handleDriverEvent(e,t){let n=this.sessions.get(e);if(n)switch(t.type){case`text`:if(!n.cardOutTrackId&&this.cardClient&&n.turnInProgress)try{n.cardOutTrackId=await this.cardClient.createAndDeliverCard({conversationType:n.conversationType,conversationId:n.conversationId,senderStaffId:n.currentSenderStaffId,cardTemplateId:this.config.cardTemplateId,initialMarkdown:` `})}catch(e){h(e),u(`[channel] 卡片创建失败,回退整段 sendText`,{level:`debug`}),n.cardOutTrackId=null}n.textBuffer+=t.text,n.cardOutTrackId&&this.cardClient&&this.scheduleStreamPush(n);break;case`message_end`:if(n.streamTimer&&(clearTimeout(n.streamTimer),n.streamTimer=null),n.cardOutTrackId&&this.cardClient){let e=n.cardOutTrackId;n.cardOutTrackId=null;try{await this.cardClient.streamingUpdate(e,n.textBuffer,{finalize:!0})}catch(e){h(e),n.textBuffer.trim()&&await this.stream.sendText(n.sessionWebhook,n.textBuffer)}}else n.textBuffer.trim()&&await this.stream.sendText(n.sessionWebhook,n.textBuffer);n.textBuffer=``;break;case`tool_summary`:break;case`turn_end`:{n.turnInProgress=!1;let r=t.sessionId;if(r&&r!==n.workmateSessionId&&(n.workmateSessionId=r,C(t=>({...t,sessions:{...t.sessions,[e]:{workmateSessionId:r,lastActiveAt:Date.now(),senderId:n.currentSenderStaffId}}})),this.config=y()),n.streamTimer&&(clearTimeout(n.streamTimer),n.streamTimer=null),n.cardOutTrackId&&this.cardClient){let e=n.cardOutTrackId;n.cardOutTrackId=null;let r=n.textBuffer||t.resultText||``;n.textBuffer=``;try{await this.cardClient.streamingUpdate(e,r,{finalize:!0})}catch(e){h(e),r.trim()&&await this.stream.sendText(n.sessionWebhook,r)}}else if(n.textBuffer.trim()){let e=n.textBuffer;n.textBuffer=``,await this.stream.sendText(n.sessionWebhook,e)}else t.subtype===`success`&&t.resultText?.trim()&&await this.stream.sendText(n.sessionWebhook,t.resultText);u(`[channel] turn_end: subtype=${t.subtype} sid=${t.sessionId??`-`} resultText=${t.resultText?`"${t.resultText.slice(0,50)}"`:`(空)`}`,{level:`debug`});break}case`permission_request`:await this.handlePermissionRequest(n,t);break;case`stderr`:break;case`exit`:u(`[channel] workmate 子进程退出 code=${t.code},清会话 ${e}`,{level:`debug`}),n.streamTimer&&(clearTimeout(n.streamTimer),n.streamTimer=null),this.sessions.delete(e);break}}async handlePermissionRequest(e,t){if(l(t.toolName)){e.driver.autoAllow(t.requestId),u(`[channel] 只读工具 autoAllow: ${t.toolName}`,{level:`debug`});return}if(!this.config.confirmDangerous){e.driver.autoAllow(t.requestId);return}e.pendingConfirm={requestId:t.requestId,webhook:e.sessionWebhook,senderStaffId:e.currentSenderStaffId,toolName:t.toolName},u(`[channel] permission_request: tool=${t.toolName}`,{level:`debug`});let n=JSON.stringify(t.input,null,2).slice(0,500),r=Math.round(this.config.confirmTimeoutMs/6e4);await this.stream.sendMarkdown(e.sessionWebhook,`需要确认`,`### ⚠️ 需要确认:${t.toolName}\n\n**参数预览:**\n\`\`\`json\n${n}\n\`\`\`\n\n**选项:**\n- 回复「**同意**」→ 执行此工具\n- 回复「**拒绝**」→ 跳过此工具,继续下一步\n- 回复「**终止**」→ 终止整个任务\n\n⏰ ${r} 分钟无回复自动拒绝`),setTimeout(()=>{if(e.pendingConfirm?.requestId===t.requestId){e.pendingConfirm=null;try{e.driver.respondPermission(t.requestId,{behavior:`deny`,message:`确认超时`})}catch(e){h(e)}this.stream.sendText(e.sessionWebhook,`⏰ 确认超时,已拒绝执行`)}},this.config.confirmTimeoutMs)}scheduleStreamPush(e){e.streamTimer||(e.streamTimer=setTimeout(()=>{e.streamTimer=null,!(!e.cardOutTrackId||!this.cardClient)&&this.cardClient.streamingUpdate(e.cardOutTrackId,e.textBuffer).catch(e=>h(e))},G))}canConfirm(e,t){return!!(this.config.admins.includes(e)||t&&e===t||!t)}};function J(e){let t=e.trim().toLowerCase();return[`同意`,`yes`,`y`,`确认`,`ok`,`allow`,`同意了`].includes(t)?{behavior:`allow`}:[`拒绝`,`no`,`n`,`cancel`,`deny`,`不同意`,`拒绝执行`].includes(t)?{behavior:`deny`,message:`用户在钉钉拒绝`}:[`终止`,`stop`,`abort`,`中止`,`终止任务`,`终止整个任务`].includes(t)?{behavior:`terminate`}:null}g(),f(),m();async function Y(e){let t=e[0]??`start`;switch(t){case`start`:await X();break;case`status`:Z();break;case`stop`:console.log(`请在 workmate 交互会话里用 /channel 停止 bridge`);break;default:console.error(`未知子命令: ${t}。可用: start | status`),process.exit(1)}}async function X(){_(p())||(console.error(`channel 未启用。请在交互会话里运行 /channel,开启 channel 并选择 activePlugin=dingtalk`),process.exit(1));let e=new q;try{await e.start(),console.log(`[channel] bridge 已启动,Ctrl+C 退出`),await new Promise(()=>{})}catch(e){h(e),console.error(`bridge 启动失败: ${e instanceof Error?e.message:String(e)}`),process.exit(1)}}function Z(){let e=b(),t=S(),n=y(),r=_(p());console.log(`channel.enabled: ${r}`),console.log(`bridge.running: ${e}`),t&&console.log(`bridge.pid: ${t}`),console.log(`dingtalk.appKey: ${n.appKey?`已配置`:`未配置`}`),console.log(`dingtalk.robotName: ${n.robotName}`),console.log(`dingtalk.permissionMode: ${n.permissionMode}`),console.log(`dingtalk.sessionStrategy: ${n.sessionStrategy}`),console.log(`dingtalk.confirmDangerous: ${n.confirmDangerous}`),console.log(`sessions: ${Object.keys(n.sessions).length} 个`)}export{Y as channelMain};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{I as n,P as r,ai as i,t as a}from"./src-BX54x08P.js";import{t as o}from"./jsx-runtime-Bb4Xn-E0.js";import{d as s,h as c,o as l}from"./config-Bio2EjUK.js";import{n as u,t as d}from"./select-
|
|
1
|
+
import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{I as n,P as r,ai as i,t as a}from"./src-BX54x08P.js";import{t as o}from"./jsx-runtime-Bb4Xn-E0.js";import{d as s,h as c,o as l}from"./config-Bio2EjUK.js";import{n as u,t as d}from"./select-Bm29ymsI.js";import{a as f,c as p,i as m,n as h,o as g,r as _,t as v,u as y}from"./bridgeControl-C8xaGuwO.js";function b({onClose:e}){let[t,i]=(0,x.useState)(0),[a,o]=(0,x.useState)(``),s=l(),u=g(),p=s.channel?.enabled===!0,h=s.channel?.activePlugin??null,b=_(),T=v();function E(){i(e=>e+1)}function D(e,t){c(n=>({...n,channel:{enabled:e,activePlugin:t}})),E()}function O(e,t,n){let r=t[(t.indexOf(e)+1)%t.length];n(r),E()}let k=[{label:(0,S.jsxs)(r,{children:[`Channel 开关:`,(0,S.jsx)(r,{bold:!0,children:p?`on`:`off`})]}),value:`toggle-enabled`},{label:(0,S.jsxs)(r,{children:[`激活渠道:`,(0,S.jsx)(r,{bold:!0,children:h??`(无)`})]}),value:`set-plugin`},{label:(0,S.jsxs)(r,{children:[`钉钉 corpid:`,(0,S.jsx)(r,{dimColor:!0,children:u.corpid||`(空) 编辑 dingtalk.json`})]}),value:`noop:corpid`},{label:(0,S.jsxs)(r,{children:[`钉钉 AppKey:`,(0,S.jsx)(r,{dimColor:!0,children:u.appKey?`已配置`:`(空) 编辑 dingtalk.json`})]}),value:`noop:appKey`},{label:(0,S.jsxs)(r,{children:[`钉钉 AppSecret:`,(0,S.jsx)(r,{dimColor:!0,children:u.appSecret?`已配置`:`(空) 编辑 dingtalk.json`})]}),value:`noop:appSecret`},{label:(0,S.jsxs)(r,{children:[`机器人名:`,(0,S.jsx)(r,{bold:!0,children:u.robotName})]}),value:`noop:robotName`},{label:(0,S.jsxs)(r,{children:[`AI 卡片模板:`,(0,S.jsx)(r,{dimColor:!0,children:u.cardTemplateId?`已配置`:`(空) 编辑 dingtalk.json`})]}),value:`noop:cardTemplateId`},{label:(0,S.jsxs)(r,{children:[`权限模式:`,(0,S.jsx)(r,{bold:!0,children:u.permissionMode})]}),value:`cycle-permissionMode`},{label:(0,S.jsxs)(r,{children:[`会话策略:`,(0,S.jsx)(r,{bold:!0,children:u.sessionStrategy}),(0,S.jsx)(r,{dimColor:!0,children:` (perConversation=每群一会话 / perUser=每人一会话 / shared=共用)`})]}),value:`cycle-sessionStrategy`},{label:(0,S.jsxs)(r,{children:[`危险操作钉钉确认:`,(0,S.jsx)(r,{bold:!0,children:u.confirmDangerous?`on`:`off`})]}),value:`toggle-confirmDangerous`},{label:(0,S.jsxs)(r,{bold:b,children:[b?`▶ bridge 运行中`:`▶ 启动 bridge`,T?` (pid=${T})`:``]}),value:`action:start`},{label:(0,S.jsx)(r,{bold:b,children:`■ 停止 bridge`}),value:`action:stop`}];function A(e){switch(o(``),e){case`toggle-enabled`:D(!p,h??`dingtalk`);break;case`set-plugin`:D(!0,`dingtalk`);break;case`cycle-permissionMode`:O(u.permissionMode,C,e=>y(t=>({...t,permissionMode:e})));break;case`cycle-sessionStrategy`:O(u.sessionStrategy,w,e=>y(t=>({...t,sessionStrategy:e})));break;case`toggle-confirmDangerous`:y(e=>({...e,confirmDangerous:!e.confirmDangerous})),E();break;case`action:start`:{let e=m();o(e.started?`bridge 已启动 (pid=${e.pid})`:`bridge 已在运行 (pid=${e.pid})`),E();break}case`action:stop`:{let e=f();o(e?`已发停止信号`:`bridge 未运行`),E();break}default:e.startsWith(`noop:`)&&o(`请编辑 ~/.workmate/channel/dingtalk.json 填入该字段`)}}return(0,S.jsxs)(n,{flexDirection:`column`,padding:1,children:[(0,S.jsxs)(n,{marginBottom:1,flexDirection:`column`,children:[(0,S.jsx)(r,{bold:!0,children:`远程对话渠道(钉钉)`}),(0,S.jsx)(r,{dimColor:!0,children:`↑↓ 导航 · Enter 切换/执行 · Esc 退出`}),(0,S.jsx)(r,{dimColor:!0,children:`corpid/AppKey/AppSecret 请直接编辑 ~/.workmate/channel/dingtalk.json`})]}),(0,S.jsx)(d,{options:k,onChange:A,onCancel:e,visibleOptionCount:k.length},t),a&&(0,S.jsx)(n,{marginTop:1,children:(0,S.jsx)(r,{bold:!0,children:a})})]})}var x,S,C,w,T=e((()=>{a(),x=t(i(),1),u(),s(),p(),h(),S=o(),C=[`default`,`acceptEdits`,`bypassPermissions`,`plan`,`dontAsk`,`auto`],w=[`perConversation`,`perUser`,`shared`]})),E,D;e((()=>{T(),E=o(),D=async e=>(0,E.jsx)(b,{onClose:()=>e()})}))();export{D as call};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./conversation-
|
|
1
|
+
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./conversation-BFL0rEIx.js";var r;e((()=>{t(),r=async(e,t)=>(await n(t),{type:`text`,value:``})}))();export{r as call};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Pi as e,Ti as t,ki as n}from"./loadAgentsDir-BfLCckVj.js";e();export{t as clearCommandsCache,n as getCommands};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{di as t,fi as n}from"./src-BX54x08P.js";import{It as r,Pt as i}from"./state-CXY-q5gr.js";import{$g as a,Bx as o,H_ as s,I_ as c,K_ as l,L_ as u,N_ as d,P_ as f,Qg as p,R_ as m,U_ as h,Xg as g,Xi as _,Yg as v,am as y,cb as b,ct as x,dm as S,gn as C,gp as w,hp as T,id as E,im as D,lm as O,lt as k,q_ as A,rd as j,sb as M,sv as N,tv as P}from"./loadAgentsDir-BfLCckVj.js";import{F,I}from"./debug-2pVES-2G.js";import{o as L,s as R}from"./log-L1kqxa_P.js";function z(e,n){let r=j(`tip`),i=M(`app:toggleTranscript`,`Global`,`ctrl+o`),a=[...e.options.verbose?[]:[`(${i} to see full summary)`],...n?[n]:[],...r?[r]:[]];return t.dim(`Compacted ${a.join(`
|
|
2
|
+
`)}`)}async function B(e,t){let n=e.getAppState(),r=await x(e.options.tools,e.options.mainLoopModel,Array.from(n.toolPermissionContext.additionalWorkingDirectories.keys()),e.options.mcpClients),i=d({mainThreadAgentDefinition:void 0,toolUseContext:e,customSystemPrompt:e.options.customSystemPrompt,defaultSystemPrompt:r,appendSystemPrompt:e.options.appendSystemPrompt}),[a,o]=await Promise.all([u(),c()]);return{systemPrompt:i,userContext:a,systemContext:o,toolUseContext:e,forkContextMessages:t}}var V;e((()=>{n(),i(),k(),m(),b(),T(),a(),l(),s(),O(),D(),P(),I(),C(),L(),_(),E(),f(),V=async(e,t)=>{let{abortController:n}=t,{messages:i}=t;if(i=o(i),i.length===0)throw Error(`No messages to compact`);let a=e.trim();try{if(!a){let e=await y(i,t.agentId);if(e)return u.cache.clear?.(),S(),w(t.options.querySource??`compact`,t.agentId),r(),A(),{type:`compact`,compactionResult:e,displayText:z(t)}}let e=(await h(i,t)).messages,n=await p(e,t,await B(t,e),!1,a,!1);return N(void 0),A(),u.cache.clear?.(),S(),{type:`compact`,compactionResult:n,displayText:z(t,n.userDisplayMessage)}}catch(e){throw n.signal.aborted?Error(`Compaction canceled.`):F(e,`Not enough messages to compact. Send a few more messages first, then try again.`)?Error(g):F(e,`Compaction interrupted · This may be due to network issues — please try again.`)?Error(v):(R(e),Error(`Error during compaction: ${e}`))}}}))();export{V as call};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{t}from"./jsx-runtime-Bb4Xn-E0.js";import{n,t as r}from"./Settings-4TNYpfUs.js";var i,a;e((()=>{n(),i=t(),a=async(e,t)=>(0,i.jsx)(r,{onClose:e,context:t,defaultTab:`Config`})}))();export{a as call};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./figures-5ThXQEtq.js";import{I as r,P as i,s as a,t as o}from"./src-BX54x08P.js";import{t as s}from"./jsx-runtime-Bb4Xn-E0.js";import{In as c,Nn as l,mn as u,pn as d}from"./settings-D4M13toi.js";import{A_ as f,
|
|
1
|
+
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./figures-5ThXQEtq.js";import{I as r,P as i,s as a,t as o}from"./src-BX54x08P.js";import{t as s}from"./jsx-runtime-Bb4Xn-E0.js";import{In as c,Nn as l,mn as u,pn as d}from"./settings-D4M13toi.js";import{A_ as f,Bx as p,H_ as m,M_ as h,U_ as g,Xi as _}from"./loadAgentsDir-BfLCckVj.js";import{_ as v,g as y}from"./startupProfiler-B9Qv2QGH.js";import{At as b,Ot as x,Yt as S,in as C,rn as w,tn as T}from"./prompt-DaYH88Oe.js";import{n as E,t as D}from"./staticRender-Bt82RvGc.js";function O(e){let t=[];return k(e,t),A(e,t),M(e,t),ee(e,t),N(e,t),t.sort((e,t)=>e.severity===t.severity?(t.savingsTokens??0)-(e.savingsTokens??0):e.severity===`warning`?-1:1),t}function k(e,t){e.percentage>=L&&t.push({severity:`warning`,title:`Context is ${e.percentage}% full`,detail:e.isAutoCompactEnabled?`Autocompact will trigger soon, which discards older messages. Use /compact now to control what gets kept.`:`Autocompact is disabled. Use /compact to free space, or enable autocompact in /config.`})}function A(e,t){if(e.messageBreakdown)for(let n of e.messageBreakdown.toolCallsByType){let r=n.callTokens+n.resultTokens,i=r/e.rawMaxTokens*100;if(i<P||r<F)continue;let a=j(n.name,r,i);a&&t.push(a)}}function j(e,t,n){let r=y(t);switch(e){case w:return{severity:`warning`,title:`Bash results using ${r} tokens (${n.toFixed(0)}%)`,detail:`Pipe output through head, tail, or grep to reduce result size. Avoid cat on large files — use Read with offset/limit instead.`,savingsTokens:Math.floor(t*.5)};case S:return{severity:`info`,title:`Read results using ${r} tokens (${n.toFixed(0)}%)`,detail:`Use offset and limit parameters to read only the sections you need. Avoid re-reading entire files when you only need a few lines.`,savingsTokens:Math.floor(t*.3)};case x:return{severity:`info`,title:`Grep results using ${r} tokens (${n.toFixed(0)}%)`,detail:`Add more specific patterns or use the glob or type parameter to narrow file types. Consider Glob for file discovery instead of Grep.`,savingsTokens:Math.floor(t*.3)};default:return n>=20?{severity:`info`,title:`${e} using ${r} tokens (${n.toFixed(0)}%)`,detail:`This tool is consuming a significant portion of context.`,savingsTokens:Math.floor(t*.2)}:null}}function M(e,t){if(!e.messageBreakdown)return;let n=e.messageBreakdown.toolCallsByType.find(e=>e.name===S);if(!n)return;let r=n.callTokens+n.resultTokens,i=r/e.rawMaxTokens*100,a=n.resultTokens/e.rawMaxTokens*100;i>=P&&r>=F||a>=I&&n.resultTokens>=F&&t.push({severity:`info`,title:`File reads using ${y(n.resultTokens)} tokens (${a.toFixed(0)}%)`,detail:`If you are re-reading files, consider referencing earlier reads. Use offset/limit for large files.`,savingsTokens:Math.floor(n.resultTokens*.3)})}function ee(e,t){let n=e.memoryFiles.reduce((e,t)=>e+t.tokens,0),r=n/e.rawMaxTokens*100;if(r>=R&&n>=z){let i=[...e.memoryFiles].sort((e,t)=>t.tokens-e.tokens).slice(0,3).map(e=>`${l(e.path)} (${y(e.tokens)})`).join(`, `);t.push({severity:`info`,title:`Memory files using ${y(n)} tokens (${r.toFixed(0)}%)`,detail:`Largest: ${i}. Use /memory to review and prune stale entries.`,savingsTokens:Math.floor(n*.3)})}}function N(e,t){!e.isAutoCompactEnabled&&e.percentage>=50&&e.percentage<L&&t.push({severity:`info`,title:`Autocompact is disabled`,detail:`Without autocompact, you will hit context limits and lose the conversation. Enable it in /config or use /compact manually.`})}var P,F,I,L,R,z,B=e((()=>{C(),T(),b(),c(),v(),P=15,F=1e4,I=5,L=80,R=5,z=5e3}));function V({suggestions:e}){return e.length===0?null:(0,H.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,H.jsx)(i,{bold:!0,children:`Suggestions`}),e.map((e,t)=>(0,H.jsxs)(r,{flexDirection:`column`,marginTop:t===0?0:1,children:[(0,H.jsxs)(r,{children:[(0,H.jsx)(a,{status:e.severity,withSpace:!0}),(0,H.jsx)(i,{bold:!0,children:e.title}),e.savingsTokens?(0,H.jsxs)(i,{dimColor:!0,children:[` `,n.arrowRight,` save ~`,y(e.savingsTokens)]}):null]}),(0,H.jsx)(r,{marginLeft:2,children:(0,H.jsx)(i,{dimColor:!0,children:e.detail})})]},t))]})}var H,U=e((()=>{t(),o(),v(),H=s()}));function W(){return null}function G(e){let t=new Map;for(let n of e){let e=d(n.source),r=t.get(e)||[];r.push(n),t.set(e,r)}for(let[e,n]of t.entries())t.set(e,n.sort((e,t)=>t.tokens-e.tokens));let n=new Map;for(let e of Y){let r=t.get(e);r&&n.set(e,r)}return n}function K({data:e}){let{categories:t,totalTokens:n,rawMaxTokens:a,percentage:o,gridRows:s,model:c,memoryFiles:u,mcpTools:d,deferredBuiltinTools:f=[],agents:p,skills:m,cacheHitRate:h,cacheThreshold:g}=e,_=t.filter(e=>e.tokens>0&&e.name!==`Free space`&&e.name!==J&&!e.isDeferred),v=t.some(e=>e.isDeferred&&e.name.includes(`MCP`)),b=t.find(e=>e.name===J);return(0,q.jsxs)(r,{flexDirection:`column`,paddingLeft:1,children:[(0,q.jsx)(i,{bold:!0,children:`Context Usage`}),(0,q.jsxs)(r,{flexDirection:`row`,gap:2,children:[(0,q.jsx)(r,{flexDirection:`column`,flexShrink:0,children:s.map((e,t)=>(0,q.jsx)(r,{flexDirection:`row`,marginLeft:-1,children:e.map((e,t)=>e.categoryName===`Free space`?(0,q.jsx)(i,{dimColor:!0,children:`⛶ `},t):e.categoryName===J?(0,q.jsx)(i,{color:e.color,children:`⛝ `},t):(0,q.jsx)(i,{color:e.color,children:e.squareFullness>=.7?`⛁ `:`⛀ `},t))},t))}),(0,q.jsxs)(r,{flexDirection:`column`,gap:0,flexShrink:0,children:[(0,q.jsxs)(i,{dimColor:!0,children:[c,` · `,y(n),`/`,y(a),` tokens (`,o,`%)`]}),(0,q.jsx)(W,{}),h!==void 0&&g!==void 0&&(0,q.jsxs)(i,{color:h<g?`warning`:void 0,children:[`Cache hit rate: `,h.toFixed(0),`%`,h<g?` (below ${g}% threshold)`:``]}),(0,q.jsx)(i,{children:` `}),(0,q.jsx)(i,{dimColor:!0,italic:!0,children:`Estimated usage by category`}),_.map((e,t)=>{let n=y(e.tokens),o=e.isDeferred?`N/A`:`${(e.tokens/a*100).toFixed(1)}%`,s=e.name===J,c=e.name,l=e.isDeferred?` `:s?`⛝`:`⛁`;return(0,q.jsxs)(r,{children:[(0,q.jsx)(i,{color:e.color,children:l}),(0,q.jsxs)(i,{children:[` `,c,`: `]}),(0,q.jsxs)(i,{dimColor:!0,children:[n,` tokens (`,o,`)`]})]},t)}),(t.find(e=>e.name===`Free space`)?.tokens??0)>0&&(0,q.jsxs)(r,{children:[(0,q.jsx)(i,{dimColor:!0,children:`⛶`}),(0,q.jsx)(i,{children:` Free space: `}),(0,q.jsxs)(i,{dimColor:!0,children:[y(t.find(e=>e.name===`Free space`)?.tokens||0),` (`,((t.find(e=>e.name===`Free space`)?.tokens||0)/a*100).toFixed(1),`%)`]})]}),b&&b.tokens>0&&(0,q.jsxs)(r,{children:[(0,q.jsx)(i,{color:b.color,children:`⛝`}),(0,q.jsxs)(i,{dimColor:!0,children:[` `,b.name,`: `]}),(0,q.jsxs)(i,{dimColor:!0,children:[y(b.tokens),` tokens (`,(b.tokens/a*100).toFixed(1),`%)`]})]})]})]}),(0,q.jsxs)(r,{flexDirection:`column`,marginLeft:-1,children:[d.length>0&&(0,q.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,q.jsxs)(r,{children:[(0,q.jsx)(i,{bold:!0,children:`MCP tools`}),(0,q.jsxs)(i,{dimColor:!0,children:[` · /mcp`,v?` (loaded on-demand)`:``]})]}),d.some(e=>e.isLoaded)&&(0,q.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,q.jsx)(i,{dimColor:!0,children:`Loaded`}),d.filter(e=>e.isLoaded).map((e,t)=>(0,q.jsxs)(r,{children:[(0,q.jsxs)(i,{children:[`└ `,e.name,`: `]}),(0,q.jsxs)(i,{dimColor:!0,children:[y(e.tokens),` tokens`]})]},t))]}),v&&d.some(e=>!e.isLoaded)&&(0,q.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,q.jsx)(i,{dimColor:!0,children:`Available`}),d.filter(e=>!e.isLoaded).map((e,t)=>(0,q.jsx)(r,{children:(0,q.jsxs)(i,{dimColor:!0,children:[`└ `,e.name]})},t))]}),!v&&d.map((e,t)=>(0,q.jsxs)(r,{children:[(0,q.jsxs)(i,{children:[`└ `,e.name,`: `]}),(0,q.jsxs)(i,{dimColor:!0,children:[y(e.tokens),` tokens`]})]},t))]}),p.length>0&&(0,q.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,q.jsxs)(r,{children:[(0,q.jsx)(i,{bold:!0,children:`Custom agents`}),(0,q.jsx)(i,{dimColor:!0,children:` · /agents`})]}),Array.from(G(p).entries()).map(([e,t])=>(0,q.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,q.jsx)(i,{dimColor:!0,children:e}),t.map((e,t)=>(0,q.jsxs)(r,{children:[(0,q.jsxs)(i,{children:[`└ `,e.agentType,`: `]}),(0,q.jsxs)(i,{dimColor:!0,children:[y(e.tokens),` tokens`]})]},t))]},e))]}),u.length>0&&(0,q.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,q.jsxs)(r,{children:[(0,q.jsx)(i,{bold:!0,children:`Memory files`}),(0,q.jsx)(i,{dimColor:!0,children:` · /memory`})]}),u.map((e,t)=>(0,q.jsxs)(r,{children:[(0,q.jsxs)(i,{children:[`└ `,l(e.path),`: `]}),(0,q.jsxs)(i,{dimColor:!0,children:[y(e.tokens),` tokens`]})]},t))]}),m&&m.tokens>0&&(0,q.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,q.jsxs)(r,{children:[(0,q.jsx)(i,{bold:!0,children:`Skills`}),(0,q.jsx)(i,{dimColor:!0,children:` · /skills`})]}),Array.from(G(m.skillFrontmatter).entries()).map(([e,t])=>(0,q.jsxs)(r,{flexDirection:`column`,marginTop:1,children:[(0,q.jsx)(i,{dimColor:!0,children:e}),t.map((e,t)=>(0,q.jsxs)(r,{children:[(0,q.jsxs)(i,{children:[`└ `,e.name,`: `]}),(0,q.jsxs)(i,{dimColor:!0,children:[y(e.tokens),` tokens`]})]},t))]},e))]})]}),(0,q.jsx)(V,{suggestions:O(e)})]})}var q,J,Y,X=e((()=>{o(),B(),c(),v(),u(),U(),q=s(),J=`Autocompact buffer`,Y=[`Project`,`User`,`Managed`,`Plugin`,`Built-in`]}));function Z(e){return p(e)}async function Q(e,t){let{messages:n,getAppState:r,options:{mainLoopModel:i,tools:a}}=t,o=Z(n),{messages:s}=await g(o),c=process.stdout.columns||80,l=r();return e(await E((0,$.jsx)(K,{data:await f(s,i,async()=>l.toolPermissionContext,a,l.agentDefinitions,c,t,void 0,o)}))),null}var $;e((()=>{X(),m(),h(),_(),D(),$=s()}))();export{Q as call};
|
package/dist/chunks/{context-noninteractive-BcBo64vo.js → context-noninteractive-B03nuxfN.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{mn as t,pn as n}from"./settings-D4M13toi.js";import{A_ as r,
|
|
1
|
+
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{mn as t,pn as n}from"./settings-D4M13toi.js";import{A_ as r,Bx as i,H_ as a,M_ as o,U_ as s,Xi as c}from"./loadAgentsDir-BfLCckVj.js";import{_ as l,g as u}from"./startupProfiler-B9Qv2QGH.js";async function d(e){let{messages:t,getAppState:n,options:{mainLoopModel:a,tools:o,agentDefinitions:c,customSystemPrompt:l,appendSystemPrompt:u}}=e,d=i(t),{messages:f}=await s(d),p=n();return r(f,a,async()=>p.toolPermissionContext,o,c,void 0,{options:{customSystemPrompt:l,appendSystemPrompt:u}},void 0,d)}async function f(e,t){return{type:`text`,value:p(await d(t))}}function p(e){let{categories:t,totalTokens:r,rawMaxTokens:i,percentage:a,model:o,memoryFiles:s,mcpTools:c,agents:l,skills:d}=e,f=`## Context Usage
|
|
2
2
|
|
|
3
3
|
`;f+=`**Model:** ${o} \n`,f+=`**Tokens:** ${u(r)} / ${u(i)} (${a}%)\n`,f+=`
|
|
4
4
|
`;let p=t.filter(e=>e.tokens>0&&e.name!==`Free space`&&e.name!==`Autocompact buffer`);if(p.length>0){f+=`### Estimated usage by category
|
|
@@ -26,4 +26,4 @@ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{mn as t,pn as n}from".
|
|
|
26
26
|
`,f+=`| Skill | Source | Tokens |
|
|
27
27
|
`,f+=`|-------|--------|--------|
|
|
28
28
|
`;for(let e of d.skillFrontmatter)f+=`| ${e.name} | ${n(e.source)} | ${u(e.tokens)} |\n`;f+=`
|
|
29
|
-
`}return f}var m=e((()=>{
|
|
29
|
+
`}return f}var m=e((()=>{a(),o(),l(),c(),t()}));export{d as n,m as r,f as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,r as t,t as n}from"./context-noninteractive-B03nuxfN.js";t();export{n as call,e as collectContextData};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e,n as t}from"./rolldown-runtime-DaDcL9Zw.js";import{B as n,Pt as r,Ut as i,Vt as a,dn as o,pn as s,q as c,un as l}from"./state-CXY-q5gr.js";import{Cb as u,Dn as d,Eg as f,KC as p,Kn as m,On as h,Sb as g,Tn as _,Yt as v,ZC as y,Zr as b,cn as x,er as S,gn as C,gs as w,hh as T,hs as E,i_ as D,ph as O,r_ as k,rw as A,si as j,ui as M,uw as N,vg as P,vr as F,wg as I,wt as L,xt as R,yg as z}from"./loadAgentsDir-BfLCckVj.js";import{o as B,s as V}from"./log-L1kqxa_P.js";import{n as H}from"./analytics-COpjZpvd.js";import{n as U,t as W}from"./caches-fqs-Y-kW.js";import{randomUUID as G}from"crypto";async function K({setMessages:t,readFileState:r,discoveredSkillNames:f,loadedNestedMemoryPaths:h,getAppState:g,setAppState:C,setConversationId:T}){let E=x();await v(`clear`,{getAppState:g,setAppState:C,signal:AbortSignal.timeout(E),timeoutMs:E}),n();let k=new Set,N=[],P=e=>`isBackgrounded`in e&&e.isBackgrounded===!1;if(g)for(let e of Object.values(g().tasks))P(e)||w(e)&&(k.add(e.agentId),N.push(e));t(()=>[]);let{setContextBlocked:L}=(p(),e(y));L(!1),T&&T(G()),W(k),l(null),o(null),s(null),i(),u(c()),r.clear(),f?.clear(),h?.clear(),C&&C(e=>{let t={};for(let[n,r]of Object.entries(e.tasks)){if(!P(r)){t[n]=r;continue}try{r.status===`running`&&(z(r)&&(r.shellCommand?.kill(),r.shellCommand?.cleanup(),r.cleanupTimeoutId&&clearTimeout(r.cleanupTimeoutId)),`abortController`in r&&r.abortController?.abort(),`unregisterCleanup`in r&&r.unregisterCleanup?.())}catch(e){V(e)}_(n)}return{...e,tasks:t,attribution:O(),standaloneAgentContext:void 0,fileHistory:{snapshots:[],trackedFiles:new Set,snapshotSequence:0},mcp:{clients:[],tools:[],commands:[],resources:{},pluginReconnectKey:e.mcp.pluginReconnectKey}}}),A(),m(),a({setCurrentAsParent:!0}),await b();for(let e of N)e.status===`running`&&d(e.id,S(I(e.agentId)));let{saveMode:B}=(F(),e(M));B(`normal`);let H=R();H&&j(H);let U=await D(`clear`);U.length>0&&t(()=>U)}var q=t((()=>{r(),H(),E(),P(),f(),T(),C(),B(),N(),g(),k(),F(),h(),L(),U()}));export{q as n,K as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,t}from"./conversation-BFL0rEIx.js";e();export{t as clearConversation};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Ht as e,Ut as t}from"./settings-D4M13toi.js";import{Pt as n,t as r}from"./state-CXY-q5gr.js";import{$
|
|
1
|
+
import{Ht as e,Ut as t}from"./settings-D4M13toi.js";import{Pt as n,t as r}from"./state-CXY-q5gr.js";import{$h as i,Ar as a,Ea as o,Eg as s,Fr as c,Sr as l,Tg as u,Vn as d,Xi as f,as as p,aw as m,ba as h,ca as g,da as _,dr as v,i_ as y,ir as b,jr as x,os as S,qr as C,qx as w,r_ as T,rs as E,sg as D,tS as O,uS as k,uw as A,vr as j,ya as M,zn as N}from"./loadAgentsDir-BfLCckVj.js";import{n as P,t as F}from"./cwd-DrEEb4f5.js";import{o as I,s as L}from"./log-L1kqxa_P.js";import{relative as R}from"path";P(),n(),s(),t(),E(),D(),I(),f(),A(),T(),j();function z(e){if(e.type!==`attachment`)return e;let t=e.attachment;if(t.type===`new_file`)return{...e,attachment:{...t,type:`file`,displayPath:R(F(),t.filename)}};if(t.type===`new_directory`)return{...e,attachment:{...t,type:`directory`,displayPath:R(F(),t.path)}};if(!(`displayPath`in t)){let n=`filename`in t?t.filename:`path`in t?t.path:`skillDir`in t?t.skillDir:void 0;if(n)return{...e,attachment:{...t,displayPath:R(F(),n)}}}return e}function B(e){return V(e).messages}function V(t){try{let n=t.map(z),r=new Set(e);for(let e of n)e.type===`user`&&e.permissionMode!==void 0&&!r.has(e.permissionMode)&&(e.permissionMode=void 0);let i=g(M(h(n))),a=H(i),o;if(a.kind===`interrupted_turn`){let[e]=_([O({content:`Continue from where you left off.`,isMeta:!0})]);i.push(e),o={kind:`interrupted_prompt`,message:e}}else o=a;let s=i.findLastIndex(e=>e.type!==`system`&&e.type!==`progress`);return s!==-1&&i[s].type===`user`&&i.splice(s+1,0,w({content:k})),{messages:i,turnInterruptionState:o}}catch(e){throw L(e),e}}function H(e){if(e.length===0)return{kind:`none`};let t=e.findLastIndex(e=>e.type!==`system`&&e.type!==`progress`&&!(e.type===`assistant`&&e.isApiErrorMessage)),n=t===-1?void 0:e[t];return!n||n.type===`assistant`?{kind:`none`}:n.type===`user`?n.isMeta||n.isCompactSummary?{kind:`none`}:o(n)?{kind:`interrupted_turn`}:{kind:`interrupted_prompt`,message:n}:n.type===`attachment`?{kind:`interrupted_turn`}:{kind:`none`}}function U(e){for(let t of e)if(t.type===`attachment`){if(t.attachment.type===`invoked_skills`){let e=t.attachment.skills;for(let t of e)t.name&&t.path&&t.content&&r(t.name,t.path,t.content,null)}t.attachment.type===`skill_listing`&&S()}S(),p()}async function W(e){let{messages:t,leafUuids:n}=await c(e),r=null,i=0;for(let e of t.values()){if(e.isSidechain||!n.has(e.uuid))continue;let t=new Date(e.timestamp).getTime();t>i&&(i=t,r=e)}return r?{messages:C(N(t,r)),sessionId:r.sessionId}:{messages:[],sessionId:void 0}}async function G(e,t){try{let n=null,r=null,o;if(e===void 0){let e=x(),t=new Set;try{let{listAllLiveSessions:e}=await import(`./udsClient-CWeoNrm3.js`),n=await e();t=new Set(n.flatMap(e=>e.kind&&e.kind!==`interactive`&&e.sessionId?[e.sessionId]:[]))}catch{}n=(await e).find(e=>{let n=v(e);return!n||!t.has(n)})??null}else if(t){let e=await W(t);r=e.messages,o=e.sessionId}else typeof e==`string`?(n=await b(e),o=e):n=e;if(!n&&!r)return null;n&&(l(n)&&(n=await a(n)),o||(o=v(n)),o&&await m(n,u(o)),i(n),r=n.messages,d(r)),U(r);let s=V(r);r=s.messages;let c=await y(`resume`,{sessionId:o});return r.push(...c),{messages:r,turnInterruptionState:s.turnInterruptionState,fileHistorySnapshots:n?.fileHistorySnapshots,attributionSnapshots:n?.attributionSnapshots,contentReplacements:n?.contentReplacements,contextCollapseCommits:n?.contextCollapseCommits,contextCollapseSnapshot:n?.contextCollapseSnapshot,sessionId:o,agentName:n?.agentName,agentColor:n?.agentColor,agentSetting:n?.agentSetting,customTitle:n?.customTitle,tag:n?.tag,mode:n?.mode,worktreeSession:n?.worktreeSession,prNumber:n?.prNumber,prUrl:n?.prUrl,prRepository:n?.prRepository,fullPath:n?.fullPath,goal:n?.goal}}catch(e){throw L(e),e}}export{G as n,B as t};
|