@tyvm/knowhow 0.0.83 → 0.0.85
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/package.json +4 -2
- package/src/agents/base/base.ts +72 -62
- package/src/agents/index.ts +30 -14
- package/src/agents/researcher/researcher.ts +1 -2
- package/src/agents/tools/aiClient.ts +48 -0
- package/src/agents/tools/list.ts +57 -0
- package/src/agents/tools/startAgentTask.ts +3 -1
- package/src/chat/CliChatService.ts +20 -4
- package/src/chat/modules/AgentModule.ts +399 -357
- package/src/chat/modules/CustomCommandsModule.ts +0 -1
- package/src/chat/modules/InternalChatModule.ts +18 -2
- package/src/chat/modules/RendererModule.ts +109 -0
- package/src/chat/modules/SessionsModule.ts +854 -0
- package/src/chat/modules/SetupModule.ts +6 -8
- package/src/chat/modules/index.ts +1 -0
- package/src/chat/renderer/CompactRenderer.ts +209 -0
- package/src/chat/renderer/ConsoleRenderer.ts +141 -0
- package/src/chat/renderer/FancyRenderer.ts +421 -0
- package/src/chat/renderer/index.ts +5 -0
- package/src/chat/renderer/loadRenderer.ts +314 -0
- package/src/chat/renderer/messagesToRenderEvents.ts +96 -0
- package/src/chat/renderer/types.ts +88 -0
- package/src/chat/types.ts +5 -0
- package/src/chat.ts +69 -5
- package/src/cli.ts +24 -5
- package/src/clients/index.ts +91 -0
- package/src/clients/pricing/google.ts +81 -2
- package/src/clients/pricing/openai.ts +68 -0
- package/src/config.ts +15 -0
- package/src/plugins/AgentsMdPlugin.ts +1 -1
- package/src/plugins/GitPlugin.ts +20 -20
- package/src/plugins/PluginBase.ts +11 -0
- package/src/plugins/SkillsPlugin.ts +150 -0
- package/src/plugins/asana.ts +4 -4
- package/src/plugins/embedding.ts +3 -5
- package/src/plugins/exec.ts +3 -3
- package/src/plugins/figma.ts +3 -7
- package/src/plugins/github.ts +18 -29
- package/src/plugins/jira.ts +2 -2
- package/src/plugins/language.ts +4 -4
- package/src/plugins/linear.ts +4 -4
- package/src/plugins/notion.ts +6 -8
- package/src/plugins/plugins.ts +29 -3
- package/src/plugins/url.ts +2 -2
- package/src/plugins/vim.ts +4 -3
- package/src/services/AgentService.ts +17 -0
- package/src/services/AgentSyncFs.ts +3 -0
- package/src/services/EventService.ts +168 -27
- package/src/services/KnowhowClient.ts +1 -0
- package/src/services/SessionManager.ts +51 -1
- package/src/services/SyncedAgentWatcher.ts +397 -0
- package/src/services/SyncerService.ts +147 -0
- package/src/services/index.ts +2 -0
- package/src/services/modules/index.ts +14 -3
- package/src/types.ts +103 -5
- package/src/worker.ts +80 -2
- package/src/workers/auth/PasskeySetup.ts +185 -0
- package/src/workers/auth/WorkerPasskeyAuth.ts +190 -0
- package/src/workers/auth/types.ts +58 -0
- package/src/workers/tools/getChallenge.ts +33 -0
- package/src/workers/tools/index.ts +8 -0
- package/src/workers/tools/lock.ts +31 -0
- package/src/workers/tools/unlock.ts +116 -0
- package/tests/clients/pricing.test.ts +144 -0
- package/tests/unit/modules/moduleLoading.test.ts +226 -0
- package/tests/unit/plugins/pluginLoading.test.ts +151 -0
- package/ts_build/package.json +4 -2
- package/ts_build/src/agents/base/base.d.ts +4 -3
- package/ts_build/src/agents/base/base.js +54 -30
- package/ts_build/src/agents/base/base.js.map +1 -1
- package/ts_build/src/agents/index.d.ts +3 -0
- package/ts_build/src/agents/index.js +21 -11
- package/ts_build/src/agents/index.js.map +1 -1
- package/ts_build/src/agents/researcher/researcher.js +1 -1
- package/ts_build/src/agents/researcher/researcher.js.map +1 -1
- package/ts_build/src/agents/tools/aiClient.d.ts +3 -0
- package/ts_build/src/agents/tools/aiClient.js +31 -1
- package/ts_build/src/agents/tools/aiClient.js.map +1 -1
- package/ts_build/src/agents/tools/list.js +48 -0
- package/ts_build/src/agents/tools/list.js.map +1 -1
- package/ts_build/src/agents/tools/startAgentTask.js +2 -1
- package/ts_build/src/agents/tools/startAgentTask.js.map +1 -1
- package/ts_build/src/chat/CliChatService.js +16 -5
- package/ts_build/src/chat/CliChatService.js.map +1 -1
- package/ts_build/src/chat/modules/AgentModule.d.ts +34 -17
- package/ts_build/src/chat/modules/AgentModule.js +248 -258
- package/ts_build/src/chat/modules/AgentModule.js.map +1 -1
- package/ts_build/src/chat/modules/CustomCommandsModule.js.map +1 -1
- package/ts_build/src/chat/modules/InternalChatModule.d.ts +3 -0
- package/ts_build/src/chat/modules/InternalChatModule.js +16 -1
- package/ts_build/src/chat/modules/InternalChatModule.js.map +1 -1
- package/ts_build/src/chat/modules/RendererModule.d.ts +16 -0
- package/ts_build/src/chat/modules/RendererModule.js +76 -0
- package/ts_build/src/chat/modules/RendererModule.js.map +1 -0
- package/ts_build/src/chat/modules/SessionsModule.d.ts +33 -0
- package/ts_build/src/chat/modules/SessionsModule.js +582 -0
- package/ts_build/src/chat/modules/SessionsModule.js.map +1 -0
- package/ts_build/src/chat/modules/SetupModule.d.ts +3 -3
- package/ts_build/src/chat/modules/SetupModule.js +4 -6
- package/ts_build/src/chat/modules/SetupModule.js.map +1 -1
- package/ts_build/src/chat/modules/index.d.ts +1 -0
- package/ts_build/src/chat/modules/index.js +3 -1
- package/ts_build/src/chat/modules/index.js.map +1 -1
- package/ts_build/src/chat/renderer/CompactRenderer.d.ts +23 -0
- package/ts_build/src/chat/renderer/CompactRenderer.js +167 -0
- package/ts_build/src/chat/renderer/CompactRenderer.js.map +1 -0
- package/ts_build/src/chat/renderer/ConsoleRenderer.d.ts +22 -0
- package/ts_build/src/chat/renderer/ConsoleRenderer.js +110 -0
- package/ts_build/src/chat/renderer/ConsoleRenderer.js.map +1 -0
- package/ts_build/src/chat/renderer/FancyRenderer.d.ts +23 -0
- package/ts_build/src/chat/renderer/FancyRenderer.js +328 -0
- package/ts_build/src/chat/renderer/FancyRenderer.js.map +1 -0
- package/ts_build/src/chat/renderer/index.d.ts +5 -0
- package/ts_build/src/chat/renderer/index.js +29 -0
- package/ts_build/src/chat/renderer/index.js.map +1 -0
- package/ts_build/src/chat/renderer/loadRenderer.d.ts +4 -0
- package/ts_build/src/chat/renderer/loadRenderer.js +246 -0
- package/ts_build/src/chat/renderer/loadRenderer.js.map +1 -0
- package/ts_build/src/chat/renderer/messagesToRenderEvents.d.ts +15 -0
- package/ts_build/src/chat/renderer/messagesToRenderEvents.js +72 -0
- package/ts_build/src/chat/renderer/messagesToRenderEvents.js.map +1 -0
- package/ts_build/src/chat/renderer/types.d.ts +75 -0
- package/ts_build/src/chat/renderer/types.js +3 -0
- package/ts_build/src/chat/renderer/types.js.map +1 -0
- package/ts_build/src/chat/types.d.ts +5 -0
- package/ts_build/src/chat.js +46 -4
- package/ts_build/src/chat.js.map +1 -1
- package/ts_build/src/cli.js +18 -5
- package/ts_build/src/cli.js.map +1 -1
- package/ts_build/src/clients/gemini.d.ts +10 -10
- package/ts_build/src/clients/index.d.ts +10 -0
- package/ts_build/src/clients/index.js +58 -0
- package/ts_build/src/clients/index.js.map +1 -1
- package/ts_build/src/clients/pricing/google.d.ts +10 -10
- package/ts_build/src/clients/pricing/google.js +74 -2
- package/ts_build/src/clients/pricing/google.js.map +1 -1
- package/ts_build/src/clients/pricing/openai.js +65 -0
- package/ts_build/src/clients/pricing/openai.js.map +1 -1
- package/ts_build/src/config.d.ts +1 -0
- package/ts_build/src/config.js +17 -1
- package/ts_build/src/config.js.map +1 -1
- package/ts_build/src/plugins/AgentsMdPlugin.js +1 -1
- package/ts_build/src/plugins/AgentsMdPlugin.js.map +1 -1
- package/ts_build/src/plugins/GitPlugin.js +20 -20
- package/ts_build/src/plugins/GitPlugin.js.map +1 -1
- package/ts_build/src/plugins/PluginBase.d.ts +1 -0
- package/ts_build/src/plugins/PluginBase.js +13 -0
- package/ts_build/src/plugins/PluginBase.js.map +1 -1
- package/ts_build/src/plugins/SkillsPlugin.d.ts +13 -0
- package/ts_build/src/plugins/SkillsPlugin.js +149 -0
- package/ts_build/src/plugins/SkillsPlugin.js.map +1 -0
- package/ts_build/src/plugins/asana.js +4 -4
- package/ts_build/src/plugins/asana.js.map +1 -1
- package/ts_build/src/plugins/embedding.js +3 -3
- package/ts_build/src/plugins/embedding.js.map +1 -1
- package/ts_build/src/plugins/exec.js +3 -3
- package/ts_build/src/plugins/exec.js.map +1 -1
- package/ts_build/src/plugins/figma.js +3 -3
- package/ts_build/src/plugins/figma.js.map +1 -1
- package/ts_build/src/plugins/github.js +18 -18
- package/ts_build/src/plugins/github.js.map +1 -1
- package/ts_build/src/plugins/jira.js +2 -2
- package/ts_build/src/plugins/jira.js.map +1 -1
- package/ts_build/src/plugins/language.js +4 -4
- package/ts_build/src/plugins/language.js.map +1 -1
- package/ts_build/src/plugins/linear.js +4 -4
- package/ts_build/src/plugins/linear.js.map +1 -1
- package/ts_build/src/plugins/notion.js +6 -6
- package/ts_build/src/plugins/notion.js.map +1 -1
- package/ts_build/src/plugins/plugins.d.ts +3 -0
- package/ts_build/src/plugins/plugins.js +18 -3
- package/ts_build/src/plugins/plugins.js.map +1 -1
- package/ts_build/src/plugins/url.js +2 -2
- package/ts_build/src/plugins/url.js.map +1 -1
- package/ts_build/src/plugins/vim.js +2 -2
- package/ts_build/src/plugins/vim.js.map +1 -1
- package/ts_build/src/services/AgentService.d.ts +3 -0
- package/ts_build/src/services/AgentService.js +7 -0
- package/ts_build/src/services/AgentService.js.map +1 -1
- package/ts_build/src/services/AgentSyncFs.d.ts +1 -0
- package/ts_build/src/services/AgentSyncFs.js +2 -0
- package/ts_build/src/services/AgentSyncFs.js.map +1 -1
- package/ts_build/src/services/EventService.d.ts +25 -2
- package/ts_build/src/services/EventService.js +92 -14
- package/ts_build/src/services/EventService.js.map +1 -1
- package/ts_build/src/services/KnowhowClient.d.ts +1 -0
- package/ts_build/src/services/KnowhowClient.js.map +1 -1
- package/ts_build/src/services/SessionManager.d.ts +6 -0
- package/ts_build/src/services/SessionManager.js +39 -1
- package/ts_build/src/services/SessionManager.js.map +1 -1
- package/ts_build/src/services/SyncedAgentWatcher.d.ts +101 -0
- package/ts_build/src/services/SyncedAgentWatcher.js +312 -0
- package/ts_build/src/services/SyncedAgentWatcher.js.map +1 -0
- package/ts_build/src/services/SyncerService.d.ts +30 -0
- package/ts_build/src/services/SyncerService.js +72 -0
- package/ts_build/src/services/SyncerService.js.map +1 -0
- package/ts_build/src/services/index.d.ts +2 -0
- package/ts_build/src/services/index.js +2 -0
- package/ts_build/src/services/index.js.map +1 -1
- package/ts_build/src/services/modules/index.js +10 -2
- package/ts_build/src/services/modules/index.js.map +1 -1
- package/ts_build/src/types.d.ts +51 -2
- package/ts_build/src/types.js +73 -5
- package/ts_build/src/types.js.map +1 -1
- package/ts_build/src/worker.d.ts +2 -0
- package/ts_build/src/worker.js +59 -4
- package/ts_build/src/worker.js.map +1 -1
- package/ts_build/src/workers/auth/PasskeySetup.d.ts +10 -0
- package/ts_build/src/workers/auth/PasskeySetup.js +131 -0
- package/ts_build/src/workers/auth/PasskeySetup.js.map +1 -0
- package/ts_build/src/workers/auth/WorkerPasskeyAuth.d.ts +35 -0
- package/ts_build/src/workers/auth/WorkerPasskeyAuth.js +129 -0
- package/ts_build/src/workers/auth/WorkerPasskeyAuth.js.map +1 -0
- package/ts_build/src/workers/auth/types.d.ts +36 -0
- package/ts_build/src/workers/auth/types.js +3 -0
- package/ts_build/src/workers/auth/types.js.map +1 -0
- package/ts_build/src/workers/tools/getChallenge.d.ts +9 -0
- package/ts_build/src/workers/tools/getChallenge.js +27 -0
- package/ts_build/src/workers/tools/getChallenge.js.map +1 -0
- package/ts_build/src/workers/tools/index.d.ts +6 -0
- package/ts_build/src/workers/tools/index.js +10 -0
- package/ts_build/src/workers/tools/index.js.map +1 -1
- package/ts_build/src/workers/tools/lock.d.ts +9 -0
- package/ts_build/src/workers/tools/lock.js +27 -0
- package/ts_build/src/workers/tools/lock.js.map +1 -0
- package/ts_build/src/workers/tools/unlock.d.ts +18 -0
- package/ts_build/src/workers/tools/unlock.js +78 -0
- package/ts_build/src/workers/tools/unlock.js.map +1 -0
- package/ts_build/tests/clients/pricing.test.d.ts +1 -0
- package/ts_build/tests/clients/pricing.test.js +90 -0
- package/ts_build/tests/clients/pricing.test.js.map +1 -0
- package/ts_build/tests/unit/modules/moduleLoading.test.d.ts +1 -0
- package/ts_build/tests/unit/modules/moduleLoading.test.js +187 -0
- package/ts_build/tests/unit/modules/moduleLoading.test.js.map +1 -0
- package/ts_build/tests/unit/plugins/pluginLoading.test.d.ts +1 -0
- package/ts_build/tests/unit/plugins/pluginLoading.test.js +123 -0
- package/ts_build/tests/unit/plugins/pluginLoading.test.js.map +1 -0
|
@@ -24,30 +24,38 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.AgentModule = void 0;
|
|
27
|
+
const renderer_1 = require("../renderer");
|
|
27
28
|
const index_1 = require("../../services/index");
|
|
28
29
|
const fs = __importStar(require("fs"));
|
|
29
30
|
const fsPromises = __importStar(require("fs/promises"));
|
|
30
31
|
const path = __importStar(require("path"));
|
|
31
32
|
const BaseChatModule_1 = require("./BaseChatModule");
|
|
32
|
-
const index_2 = require("../../
|
|
33
|
+
const index_2 = require("../../services/index");
|
|
34
|
+
const index_3 = require("../../utils/index");
|
|
33
35
|
const TokenCompressor_1 = require("../../processors/TokenCompressor");
|
|
34
36
|
const ToolResponseCache_1 = require("../../processors/ToolResponseCache");
|
|
35
|
-
const
|
|
37
|
+
const index_4 = require("../../processors/index");
|
|
36
38
|
const agents_1 = require("../../agents");
|
|
37
39
|
const KnowhowClient_1 = require("../../services/KnowhowClient");
|
|
38
40
|
class AgentModule extends BaseChatModule_1.BaseChatModule {
|
|
39
41
|
name = "agent";
|
|
40
42
|
description = "Agent interaction functionality";
|
|
43
|
+
attachedAgent;
|
|
41
44
|
taskRegistry;
|
|
42
45
|
sessionManager;
|
|
43
|
-
|
|
44
|
-
|
|
46
|
+
syncer;
|
|
47
|
+
processStartTime = Date.now();
|
|
48
|
+
activeAgentTaskId;
|
|
49
|
+
activeSyncedWatcher;
|
|
50
|
+
_wireAgentEvents;
|
|
51
|
+
_wireTaskId;
|
|
52
|
+
_wireAgentName;
|
|
53
|
+
_wireEventTypes;
|
|
45
54
|
constructor() {
|
|
46
55
|
super();
|
|
47
56
|
this.taskRegistry = new index_1.TaskRegistry();
|
|
48
57
|
this.sessionManager = new index_1.SessionManager();
|
|
49
|
-
this.
|
|
50
|
-
this.fsSync = new index_1.AgentSyncFs();
|
|
58
|
+
this.syncer = new index_1.SyncerService();
|
|
51
59
|
}
|
|
52
60
|
getCommands() {
|
|
53
61
|
return [
|
|
@@ -62,28 +70,113 @@ class AgentModule extends BaseChatModule_1.BaseChatModule {
|
|
|
62
70
|
handler: this.handleAgentsCommand.bind(this),
|
|
63
71
|
},
|
|
64
72
|
{
|
|
65
|
-
name: "
|
|
66
|
-
description: "
|
|
67
|
-
|
|
73
|
+
name: "pause",
|
|
74
|
+
description: "Pause the currently attached agent",
|
|
75
|
+
modes: ["agent:attached"],
|
|
76
|
+
handler: async (_args) => {
|
|
77
|
+
if (this.attachedAgent) {
|
|
78
|
+
await this.attachedAgent.pause();
|
|
79
|
+
console.log("Agent paused.");
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
name: "unpause",
|
|
85
|
+
description: "Unpause the currently attached agent",
|
|
86
|
+
modes: ["agent:attached"],
|
|
87
|
+
handler: async (_args) => {
|
|
88
|
+
if (this.attachedAgent) {
|
|
89
|
+
await this.attachedAgent.unpause();
|
|
90
|
+
console.log("Agent unpaused.");
|
|
91
|
+
}
|
|
92
|
+
},
|
|
68
93
|
},
|
|
69
94
|
{
|
|
70
|
-
name: "
|
|
71
|
-
description: "
|
|
72
|
-
|
|
95
|
+
name: "kill",
|
|
96
|
+
description: "Kill the currently attached agent",
|
|
97
|
+
modes: ["agent:attached"],
|
|
98
|
+
handler: async (_args) => {
|
|
99
|
+
if (this.attachedAgent) {
|
|
100
|
+
await this.attachedAgent.kill();
|
|
101
|
+
console.log("Agent terminated.");
|
|
102
|
+
this.detachFromAgent();
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
name: "detach",
|
|
108
|
+
description: "Detach from the currently attached agent",
|
|
109
|
+
modes: ["agent:attached"],
|
|
110
|
+
handler: async (_args) => {
|
|
111
|
+
console.log("Detached from agent");
|
|
112
|
+
this.detachFromAgent();
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
name: "done",
|
|
117
|
+
description: "Exit the current agent interaction",
|
|
118
|
+
modes: ["agent:attached"],
|
|
119
|
+
handler: async (_args) => {
|
|
120
|
+
this.detachFromAgent();
|
|
121
|
+
},
|
|
73
122
|
},
|
|
74
123
|
];
|
|
75
124
|
}
|
|
125
|
+
detachFromAgent() {
|
|
126
|
+
this.attachedAgent = undefined;
|
|
127
|
+
this.unwireAgentRendering();
|
|
128
|
+
if (this.chatService) {
|
|
129
|
+
this.chatService.setMode("default");
|
|
130
|
+
}
|
|
131
|
+
if (this.activeSyncedWatcher) {
|
|
132
|
+
this.activeSyncedWatcher.stopWatching();
|
|
133
|
+
this.activeSyncedWatcher = undefined;
|
|
134
|
+
}
|
|
135
|
+
const context = this.chatService?.getContext();
|
|
136
|
+
if (context)
|
|
137
|
+
context.activeAgentTaskId = undefined;
|
|
138
|
+
}
|
|
76
139
|
getModes() {
|
|
77
140
|
return [
|
|
78
141
|
{
|
|
79
142
|
name: "agent",
|
|
80
143
|
description: "Agent interaction mode",
|
|
81
144
|
active: true,
|
|
145
|
+
promptText: () => {
|
|
146
|
+
const ctx = this.chatService?.getContext();
|
|
147
|
+
return ctx?.currentAgent
|
|
148
|
+
? `\nAsk knowhow ${ctx.currentAgent}: `
|
|
149
|
+
: `\nAsk knowhow: `;
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
name: "agent:attached",
|
|
154
|
+
description: "Attached to a running agent",
|
|
155
|
+
active: false,
|
|
156
|
+
promptText: () => this.attachedAgent
|
|
157
|
+
? `Enter command or message for ${this.attachedAgent.name}: `
|
|
158
|
+
: `Enter command or message for agent: `,
|
|
82
159
|
},
|
|
83
160
|
];
|
|
84
161
|
}
|
|
162
|
+
get renderer() {
|
|
163
|
+
return (this.chatService?.getContext()?.renderer ??
|
|
164
|
+
new renderer_1.ConsoleRenderer());
|
|
165
|
+
}
|
|
85
166
|
async initialize(service) {
|
|
86
167
|
await super.initialize(service);
|
|
168
|
+
const Events = (0, index_2.services)().Events;
|
|
169
|
+
Events.setListener({ key: "agentModule:pluginLog", event: Events.eventTypes.pluginLog }, (logEvent) => {
|
|
170
|
+
const activeTasks = this.taskRegistry.getAll();
|
|
171
|
+
this.renderer.render({
|
|
172
|
+
type: "log",
|
|
173
|
+
taskId: this.activeAgentTaskId,
|
|
174
|
+
agentName: logEvent.source,
|
|
175
|
+
message: logEvent.message,
|
|
176
|
+
level: logEvent.level || "info",
|
|
177
|
+
timestamp: logEvent.timestamp || new Date().toISOString(),
|
|
178
|
+
});
|
|
179
|
+
});
|
|
87
180
|
await this.handleAgentCommand(["Patcher"]);
|
|
88
181
|
}
|
|
89
182
|
async handleAgentCommand(args) {
|
|
@@ -127,32 +220,76 @@ class AgentModule extends BaseChatModule_1.BaseChatModule {
|
|
|
127
220
|
console.error(`Error selecting agent ${agentName}:`, error);
|
|
128
221
|
}
|
|
129
222
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
223
|
+
getTaskRegistry() {
|
|
224
|
+
return this.taskRegistry;
|
|
225
|
+
}
|
|
226
|
+
getSessionManager() {
|
|
227
|
+
return this.sessionManager;
|
|
228
|
+
}
|
|
229
|
+
getRenderer() {
|
|
230
|
+
return this.renderer;
|
|
231
|
+
}
|
|
232
|
+
getActiveSyncedWatcher() {
|
|
233
|
+
return this.activeSyncedWatcher;
|
|
234
|
+
}
|
|
235
|
+
setActiveSyncedWatcher(w) {
|
|
236
|
+
this.activeSyncedWatcher = w;
|
|
237
|
+
}
|
|
238
|
+
getActiveAgentTaskId() {
|
|
239
|
+
return this.activeAgentTaskId;
|
|
240
|
+
}
|
|
241
|
+
setActiveAgentTaskId(id) {
|
|
242
|
+
this.activeAgentTaskId = id;
|
|
243
|
+
}
|
|
244
|
+
wireAgentRendering(taskId, agentEvents, eventTypes, agentName) {
|
|
245
|
+
if (eventTypes.toolCall) {
|
|
246
|
+
agentEvents.setListener({ key: "agentModule:render:toolCall", event: eventTypes.toolCall }, (data) => this.renderer.render({
|
|
247
|
+
type: "toolCall",
|
|
248
|
+
taskId,
|
|
249
|
+
agentName,
|
|
250
|
+
toolCall: data.toolCall,
|
|
251
|
+
}));
|
|
150
252
|
}
|
|
151
|
-
|
|
152
|
-
|
|
253
|
+
if (eventTypes.toolUsed) {
|
|
254
|
+
agentEvents.setListener({ key: "agentModule:render:toolUsed", event: eventTypes.toolUsed }, (data) => this.renderer.render({
|
|
255
|
+
type: "toolResult",
|
|
256
|
+
taskId,
|
|
257
|
+
agentName,
|
|
258
|
+
toolCall: data.toolCall,
|
|
259
|
+
result: data.functionResp,
|
|
260
|
+
}));
|
|
261
|
+
}
|
|
262
|
+
if (eventTypes.agentSay) {
|
|
263
|
+
agentEvents.setListener({ key: "agentModule:render:agentSay", event: eventTypes.agentSay }, (data) => this.renderer.render({
|
|
264
|
+
type: "agentMessage",
|
|
265
|
+
taskId,
|
|
266
|
+
agentName,
|
|
267
|
+
message: data.message,
|
|
268
|
+
role: "assistant",
|
|
269
|
+
}));
|
|
270
|
+
}
|
|
271
|
+
this.activeAgentTaskId = taskId;
|
|
272
|
+
this.renderer.setActiveTaskId(taskId);
|
|
273
|
+
this._wireAgentEvents = agentEvents;
|
|
274
|
+
this._wireAgentName = agentName;
|
|
275
|
+
this._wireEventTypes = eventTypes;
|
|
276
|
+
this._wireTaskId = taskId;
|
|
153
277
|
}
|
|
154
|
-
|
|
155
|
-
this.
|
|
278
|
+
unwireAgentRendering() {
|
|
279
|
+
if (this._wireAgentEvents) {
|
|
280
|
+
this._wireAgentEvents.removeManagedListenersByPrefix("agentModule:render:");
|
|
281
|
+
this._wireAgentEvents = undefined;
|
|
282
|
+
}
|
|
283
|
+
this.activeAgentTaskId = undefined;
|
|
284
|
+
this.renderer.setActiveTaskId(undefined);
|
|
285
|
+
}
|
|
286
|
+
rewireAgentRendering() {
|
|
287
|
+
if (!this._wireAgentEvents ||
|
|
288
|
+
!this._wireTaskId ||
|
|
289
|
+
!this._wireEventTypes ||
|
|
290
|
+
!this._wireAgentName)
|
|
291
|
+
return;
|
|
292
|
+
this.wireAgentRendering(this._wireTaskId, this._wireAgentEvents, this._wireEventTypes, this._wireAgentName);
|
|
156
293
|
}
|
|
157
294
|
async handleAgentsCommand(args) {
|
|
158
295
|
try {
|
|
@@ -183,99 +320,8 @@ class AgentModule extends BaseChatModule_1.BaseChatModule {
|
|
|
183
320
|
console.log("Could not load agents list.");
|
|
184
321
|
}
|
|
185
322
|
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
const savedSessions = this.sessionManager.listAvailableSessions();
|
|
189
|
-
this.sessionManager.logSessionTable(runningTasks, savedSessions);
|
|
190
|
-
}
|
|
191
|
-
async handleSessionsCommand(args) {
|
|
192
|
-
try {
|
|
193
|
-
const runningTasks = this.taskRegistry.getAll();
|
|
194
|
-
const savedSessions = this.sessionManager.listAvailableSessions();
|
|
195
|
-
if (runningTasks.length === 0 && savedSessions.length === 0) {
|
|
196
|
-
console.log("No active tasks or saved sessions found.");
|
|
197
|
-
return;
|
|
198
|
-
}
|
|
199
|
-
await this.logSessionTable();
|
|
200
|
-
const allIds = [
|
|
201
|
-
...savedSessions.map((s) => s.sessionId),
|
|
202
|
-
...runningTasks.map((t) => t.taskId),
|
|
203
|
-
];
|
|
204
|
-
if (allIds.length > 0) {
|
|
205
|
-
const selectedId = await this.chatService?.getInput("Select a session/task to attach to (or press Enter to skip): ", allIds);
|
|
206
|
-
if (selectedId &&
|
|
207
|
-
selectedId.trim() &&
|
|
208
|
-
allIds.includes(selectedId.trim())) {
|
|
209
|
-
await this.handleAttachById(selectedId.trim());
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
catch (error) {
|
|
214
|
-
console.error("Error listing sessions and tasks:", error);
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
async handleAttachById(id) {
|
|
218
|
-
if (this.taskRegistry.has(id)) {
|
|
219
|
-
const taskInfo = this.taskRegistry.get(id);
|
|
220
|
-
if (taskInfo) {
|
|
221
|
-
const context = this.chatService?.getContext();
|
|
222
|
-
const allAgents = (0, agents_1.agents)();
|
|
223
|
-
const selectedAgent = allAgents[taskInfo.agentName];
|
|
224
|
-
if (context && selectedAgent) {
|
|
225
|
-
context.selectedAgent = selectedAgent;
|
|
226
|
-
context.agentMode = true;
|
|
227
|
-
context.currentAgent = taskInfo.agentName;
|
|
228
|
-
context.currentModel = selectedAgent.getModel();
|
|
229
|
-
context.currentProvider = selectedAgent.getProvider();
|
|
230
|
-
console.log(`🔄 Switched to agent mode with ${taskInfo.agentName}`);
|
|
231
|
-
console.log(`📋 Attached to running task: ${id}`);
|
|
232
|
-
console.log(`Task: ${taskInfo.initialInput}`);
|
|
233
|
-
console.log(`Status: ${taskInfo.status}`);
|
|
234
|
-
return;
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
console.log(index_2.Marked.parse(`**Attached to running task: ${id}**`));
|
|
238
|
-
return;
|
|
239
|
-
}
|
|
240
|
-
try {
|
|
241
|
-
const session = this.sessionManager.loadSession(id);
|
|
242
|
-
if (session) {
|
|
243
|
-
console.log(index_2.Marked.parse(`**Resuming saved session: ${id}**`));
|
|
244
|
-
const context = this.chatService?.getContext();
|
|
245
|
-
const allAgents = (0, agents_1.agents)();
|
|
246
|
-
const selectedAgent = allAgents[session.agentName];
|
|
247
|
-
if (context && selectedAgent) {
|
|
248
|
-
context.selectedAgent = selectedAgent;
|
|
249
|
-
context.agentMode = true;
|
|
250
|
-
context.currentModel = selectedAgent.getModel();
|
|
251
|
-
context.currentProvider = selectedAgent.getProvider();
|
|
252
|
-
console.log(`🔄 Switched to agent mode with ${session.agentName}`);
|
|
253
|
-
console.log(`📋 Resuming saved session: ${id}`);
|
|
254
|
-
console.log(`Original task: ${session.initialInput}`);
|
|
255
|
-
console.log(`Status: ${session.status}`);
|
|
256
|
-
const addedContext = await this.chatService.getInput("Add any additional context for resuming this session (or press Enter to skip): ");
|
|
257
|
-
await this.resumeSession(id);
|
|
258
|
-
return;
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
catch (error) {
|
|
263
|
-
}
|
|
264
|
-
console.log(index_2.Marked.parse(`**Session/Task ${id} not found.**`));
|
|
265
|
-
}
|
|
266
|
-
async listAvailableSessions() {
|
|
267
|
-
return this.sessionManager.listAvailableSessions();
|
|
268
|
-
}
|
|
269
|
-
async listSessionsAndTasks() {
|
|
270
|
-
const runningTasks = this.taskRegistry.getAll();
|
|
271
|
-
const savedSessions = this.sessionManager.listAvailableSessions();
|
|
272
|
-
return {
|
|
273
|
-
runningTasks,
|
|
274
|
-
savedSessions,
|
|
275
|
-
};
|
|
276
|
-
}
|
|
277
|
-
getTaskRegistry() {
|
|
278
|
-
return this.taskRegistry;
|
|
323
|
+
getProcessStartTime() {
|
|
324
|
+
return this.processStartTime;
|
|
279
325
|
}
|
|
280
326
|
async resumeSession(sessionId, resumeReason) {
|
|
281
327
|
try {
|
|
@@ -327,6 +373,13 @@ Please continue from where you left off and complete the original request.
|
|
|
327
373
|
}
|
|
328
374
|
async handleInput(input, context) {
|
|
329
375
|
if (context.agentMode && context.selectedAgent) {
|
|
376
|
+
if (this.attachedAgent) {
|
|
377
|
+
this.attachedAgent.addPendingUserMessage({
|
|
378
|
+
role: "user",
|
|
379
|
+
content: input,
|
|
380
|
+
});
|
|
381
|
+
return true;
|
|
382
|
+
}
|
|
330
383
|
const initialInteraction = {
|
|
331
384
|
input,
|
|
332
385
|
output: "",
|
|
@@ -343,12 +396,12 @@ Please continue from where you left off and complete the original request.
|
|
|
343
396
|
return false;
|
|
344
397
|
}
|
|
345
398
|
async setupAgent(options) {
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
throw new Error(`Agent "${options.agentName}" not found. Available agents: ${Object.keys(allAgents).join(", ")}`);
|
|
399
|
+
if (!agents_1.agentConstructors[options.agentName]) {
|
|
400
|
+
throw new Error(`Agent "${options.agentName}" not found. Available agents: ${Object.keys(agents_1.agentConstructors).join(", ")}`);
|
|
349
401
|
}
|
|
350
402
|
const { input, chatHistory = [], agentName } = options;
|
|
351
|
-
const
|
|
403
|
+
const agentContext = (0, index_2.services)().Agents.getAgentContext();
|
|
404
|
+
const agent = (0, agents_1.createAgent)(options.agentName, agentContext);
|
|
352
405
|
let done = false;
|
|
353
406
|
let output = "Done";
|
|
354
407
|
const taskId = options.taskId || this.sessionManager.generateTaskId(input);
|
|
@@ -371,38 +424,27 @@ Please continue from where you left off and complete the original request.
|
|
|
371
424
|
};
|
|
372
425
|
this.taskRegistry.register(taskId, taskInfo);
|
|
373
426
|
this.saveSession(taskId, taskInfo, []);
|
|
374
|
-
this.
|
|
375
|
-
this.
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
}
|
|
389
|
-
else if (!options.messageId || options.syncFs) {
|
|
390
|
-
console.log(`📁 Using filesystem-based synchronization for task: ${taskId}`);
|
|
391
|
-
const fsTaskId = await this.fsSync.createTask({
|
|
392
|
-
taskId,
|
|
393
|
-
prompt: input,
|
|
394
|
-
});
|
|
395
|
-
taskInfo.knowhowTaskId = fsTaskId;
|
|
396
|
-
this.taskRegistry.register(taskId, taskInfo);
|
|
397
|
-
await this.fsSync.setupAgentSync(agent, fsTaskId);
|
|
398
|
-
}
|
|
427
|
+
this.syncer.reset();
|
|
428
|
+
const syncTaskId = await this.syncer.createTask({
|
|
429
|
+
taskId,
|
|
430
|
+
prompt: input,
|
|
431
|
+
messageId: options.messageId,
|
|
432
|
+
syncFs: options.syncFs,
|
|
433
|
+
existingKnowhowTaskId: options.existingKnowhowTaskId,
|
|
434
|
+
agentName,
|
|
435
|
+
});
|
|
436
|
+
const webTaskId = this.syncer.getCreatedWebTaskId();
|
|
437
|
+
knowhowTaskId = webTaskId;
|
|
438
|
+
taskInfo.knowhowTaskId = webTaskId || syncTaskId;
|
|
439
|
+
this.taskRegistry.register(taskId, taskInfo);
|
|
440
|
+
await this.syncer.setupAgentSync(agent, syncTaskId);
|
|
399
441
|
const threadUpdateHandler = async (threadState) => {
|
|
400
442
|
this.updateSession(taskId, threadState);
|
|
401
443
|
taskInfo.totalCost = agent.getTotalCostUsd();
|
|
402
444
|
};
|
|
403
445
|
agent.agentEvents.on(agent.eventTypes.threadUpdate, threadUpdateHandler);
|
|
404
|
-
console.log(
|
|
405
|
-
console.log(
|
|
446
|
+
console.log(index_3.Marked.parse(`**Starting ${agent.name} with task ID: ${taskId}...**`));
|
|
447
|
+
console.log(index_3.Marked.parse(`**Task:** ${input}`));
|
|
406
448
|
await agent.newTask(taskId);
|
|
407
449
|
if (options.model) {
|
|
408
450
|
console.log("Setting model:", options.model);
|
|
@@ -418,7 +460,7 @@ Please continue from where you left off and complete the original request.
|
|
|
418
460
|
throw new Error("ChatService not available in tools context");
|
|
419
461
|
}
|
|
420
462
|
console.log("AI has asked: ");
|
|
421
|
-
console.log(
|
|
463
|
+
console.log(index_3.Marked.parse(question), "\n");
|
|
422
464
|
return await chatService.getInput("response: ");
|
|
423
465
|
}, 10);
|
|
424
466
|
const caching = [
|
|
@@ -426,53 +468,57 @@ Please continue from where you left off and complete the original request.
|
|
|
426
468
|
new TokenCompressor_1.TokenCompressor(agent.tools).createProcessor((msg) => Boolean(msg.role === "tool" && msg.tool_call_id)),
|
|
427
469
|
];
|
|
428
470
|
agent.messageProcessor.setProcessors("pre_call", [
|
|
429
|
-
new
|
|
471
|
+
new index_4.Base64ImageProcessor(agent.tools).createProcessor(),
|
|
430
472
|
...caching,
|
|
431
|
-
new
|
|
473
|
+
new index_4.CustomVariables(agent.tools).createProcessor(),
|
|
432
474
|
]);
|
|
433
475
|
agent.messageProcessor.setProcessors("post_call", [
|
|
434
|
-
new
|
|
435
|
-
new
|
|
476
|
+
new index_4.XmlToolCallProcessor().createProcessor(),
|
|
477
|
+
new index_4.HarmonyToolProcessor().createProcessor(),
|
|
436
478
|
]);
|
|
437
479
|
agent.messageProcessor.setProcessors("post_tools", [
|
|
438
|
-
new
|
|
480
|
+
new index_4.Base64ImageProcessor(agent.tools).createProcessor(),
|
|
439
481
|
...caching,
|
|
440
482
|
]);
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
483
|
+
const agentLogHandler = (logData) => {
|
|
484
|
+
this.renderer.render({
|
|
485
|
+
type: "log",
|
|
486
|
+
taskId,
|
|
487
|
+
agentName: logData.agentName,
|
|
488
|
+
message: logData.message,
|
|
489
|
+
level: logData.level,
|
|
490
|
+
timestamp: logData.timestamp,
|
|
445
491
|
});
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
492
|
+
};
|
|
493
|
+
const agentStatusHandler = (statusData) => {
|
|
494
|
+
this.renderer.render({
|
|
495
|
+
type: "agentStatus",
|
|
496
|
+
taskId,
|
|
497
|
+
agentName: statusData.agentName,
|
|
498
|
+
statusMessage: statusData.statusMessage,
|
|
499
|
+
details: statusData.details,
|
|
500
|
+
timestamp: statusData.timestamp,
|
|
452
501
|
});
|
|
453
|
-
}
|
|
502
|
+
};
|
|
503
|
+
agent.agentEvents.on(agent.eventTypes.agentLog, agentLogHandler);
|
|
504
|
+
agent.agentEvents.on(agent.eventTypes.agentStatus, agentStatusHandler);
|
|
454
505
|
const taskCompleted = new Promise((resolve) => {
|
|
455
506
|
agent.agentEvents.once(agent.eventTypes.done, async (doneMsg) => {
|
|
456
507
|
console.log("🎯 [AgentModule] Task Completed");
|
|
457
508
|
done = true;
|
|
458
509
|
output = doneMsg || "No response from the AI";
|
|
459
510
|
agent.agentEvents.removeListener(agent.eventTypes.threadUpdate, threadUpdateHandler);
|
|
511
|
+
agent.agentEvents.removeListener(agent.eventTypes.agentLog, agentLogHandler);
|
|
512
|
+
agent.agentEvents.removeListener(agent.eventTypes.agentStatus, agentStatusHandler);
|
|
460
513
|
taskInfo = this.taskRegistry.get(taskId);
|
|
461
|
-
|
|
462
|
-
console.log("🎯 [AgentModule] Waiting for web sync finalization...");
|
|
463
|
-
await this.webSync.waitForFinalization();
|
|
464
|
-
console.log("🎯 [AgentModule] Web sync finalization complete");
|
|
465
|
-
}
|
|
466
|
-
console.log("🎯 [AgentModule] Waiting for fs sync finalization...");
|
|
467
|
-
await this.fsSync.waitForFinalization();
|
|
468
|
-
console.log("🎯 [AgentModule] Fs sync finalization complete");
|
|
514
|
+
await this.syncer.waitForFinalization();
|
|
469
515
|
if (taskInfo) {
|
|
470
516
|
taskInfo.status = "completed";
|
|
471
517
|
taskInfo.totalCost = agent.getTotalCostUsd();
|
|
472
518
|
this.updateSession(taskId, agent.getThreads());
|
|
473
519
|
taskInfo.endTime = Date.now();
|
|
474
520
|
}
|
|
475
|
-
console.log(
|
|
521
|
+
console.log(index_3.Marked.parse(output));
|
|
476
522
|
console.log("🎯 [AgentModule] Task Complete");
|
|
477
523
|
resolve(doneMsg);
|
|
478
524
|
});
|
|
@@ -589,10 +635,10 @@ Please continue from where you left off and complete the original request.
|
|
|
589
635
|
}
|
|
590
636
|
attachToTask(taskId) {
|
|
591
637
|
if (this.taskRegistry.has(taskId)) {
|
|
592
|
-
console.log(
|
|
638
|
+
console.log(index_3.Marked.parse(`**Attached to agent task: ${taskId}**`));
|
|
593
639
|
return true;
|
|
594
640
|
}
|
|
595
|
-
console.log(
|
|
641
|
+
console.log(index_3.Marked.parse(`**Task ${taskId} not found or already completed.**`));
|
|
596
642
|
return false;
|
|
597
643
|
}
|
|
598
644
|
saveSession(taskId, taskInfo, threads) {
|
|
@@ -620,91 +666,35 @@ Please continue from where you left off and complete the original request.
|
|
|
620
666
|
}
|
|
621
667
|
async attachedAgentChatLoop(taskId, agent, initialInput) {
|
|
622
668
|
try {
|
|
623
|
-
let done = false;
|
|
624
|
-
let output = "Done";
|
|
625
669
|
let agentFinalOutput;
|
|
626
670
|
if (this.chatService) {
|
|
627
671
|
this.chatService.setMode("agent:attached");
|
|
628
672
|
}
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
"/pause",
|
|
635
|
-
"/unpause",
|
|
636
|
-
"/kill",
|
|
637
|
-
"/detach",
|
|
638
|
-
"/done",
|
|
639
|
-
];
|
|
640
|
-
const history = [];
|
|
641
|
-
let finished = false;
|
|
673
|
+
this.wireAgentRendering(taskId, agent.agentEvents, agent.eventTypes, agent.name);
|
|
674
|
+
const context = this.chatService?.getContext();
|
|
675
|
+
if (context)
|
|
676
|
+
context.activeAgentTaskId = taskId;
|
|
677
|
+
this.attachedAgent = agent;
|
|
642
678
|
const donePromise = new Promise((resolve) => {
|
|
643
679
|
agent.agentEvents.once(agent.eventTypes.done, (doneMsg) => {
|
|
644
680
|
agentFinalOutput = doneMsg || "No response from the AI";
|
|
645
681
|
console.log("Finished", taskId, `$${agent.getTotalCostUsd()}`);
|
|
646
|
-
|
|
682
|
+
const finalTaskInfo = this.taskRegistry.get(taskId);
|
|
683
|
+
if (finalTaskInfo) {
|
|
684
|
+
if (finalTaskInfo.status === "running") {
|
|
685
|
+
finalTaskInfo.status = "completed";
|
|
686
|
+
finalTaskInfo.totalCost = agent.getTotalCostUsd();
|
|
687
|
+
finalTaskInfo.endTime = Date.now();
|
|
688
|
+
}
|
|
689
|
+
}
|
|
647
690
|
resolve("done");
|
|
691
|
+
this.detachFromAgent();
|
|
648
692
|
});
|
|
649
693
|
});
|
|
650
694
|
if (initialInput) {
|
|
651
695
|
const taskInfo = this.taskRegistry.get(taskId);
|
|
652
696
|
agent.call(taskInfo?.formattedPrompt || taskInfo?.initialInput || initialInput);
|
|
653
697
|
}
|
|
654
|
-
let input = (await this.chatService?.getInput(`Enter command or message for ${agent.name}: `, commands)) || "";
|
|
655
|
-
history.push(input);
|
|
656
|
-
while (!done) {
|
|
657
|
-
switch (input) {
|
|
658
|
-
case "":
|
|
659
|
-
if (finished) {
|
|
660
|
-
output = "Agent has completed the task.";
|
|
661
|
-
done = true;
|
|
662
|
-
}
|
|
663
|
-
break;
|
|
664
|
-
case "/done":
|
|
665
|
-
output = "Exited agent interaction.";
|
|
666
|
-
done = true;
|
|
667
|
-
break;
|
|
668
|
-
case "/pause":
|
|
669
|
-
await agent.pause();
|
|
670
|
-
console.log("Agent paused.");
|
|
671
|
-
break;
|
|
672
|
-
case "/unpause":
|
|
673
|
-
await agent.unpause();
|
|
674
|
-
console.log("Agent unpaused.");
|
|
675
|
-
break;
|
|
676
|
-
case "/kill":
|
|
677
|
-
await agent.kill();
|
|
678
|
-
console.log("Agent terminated.");
|
|
679
|
-
done = true;
|
|
680
|
-
break;
|
|
681
|
-
case "/detach":
|
|
682
|
-
console.log("Detached from agent");
|
|
683
|
-
if (this.chatService) {
|
|
684
|
-
this.chatService.setMode("default");
|
|
685
|
-
}
|
|
686
|
-
return { result: true, finalOutput: agentFinalOutput };
|
|
687
|
-
default:
|
|
688
|
-
agent.addPendingUserMessage({
|
|
689
|
-
role: "user",
|
|
690
|
-
content: input,
|
|
691
|
-
});
|
|
692
|
-
}
|
|
693
|
-
if (!done) {
|
|
694
|
-
input = await this.chatService?.getInput(`Enter command or message for ${agent.name}: `, commands);
|
|
695
|
-
}
|
|
696
|
-
}
|
|
697
|
-
if (this.chatService) {
|
|
698
|
-
this.chatService.setMode("default");
|
|
699
|
-
}
|
|
700
|
-
const finalTaskInfo = this.taskRegistry.get(taskId);
|
|
701
|
-
if (finalTaskInfo) {
|
|
702
|
-
if (finalTaskInfo.status === "running") {
|
|
703
|
-
finalTaskInfo.status = "completed";
|
|
704
|
-
finalTaskInfo.totalCost = agent.getTotalCostUsd();
|
|
705
|
-
finalTaskInfo.endTime = Date.now();
|
|
706
|
-
}
|
|
707
|
-
}
|
|
708
698
|
return { result: true, finalOutput: agentFinalOutput };
|
|
709
699
|
}
|
|
710
700
|
catch (error) {
|