@zds-ai/cli 0.1.6 → 0.1.8
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/agent/llm-agent.d.ts +1 -0
- package/dist/agent/llm-agent.js +13 -2
- package/dist/agent/llm-agent.js.map +1 -1
- package/dist/agent/prompt-variables.d.ts +10 -0
- package/dist/agent/prompt-variables.js +56 -2
- package/dist/agent/prompt-variables.js.map +1 -1
- package/dist/agent/streaming-agent.d.ts +33 -0
- package/dist/agent/streaming-agent.js +629 -0
- package/dist/agent/streaming-agent.js.map +1 -0
- package/dist/bin/encode-speech.sh +64 -0
- package/dist/bin/extract-text.sh +66 -0
- package/dist/bin/generate_image_sd.sh +4 -0
- package/dist/bin/talking-agents.sh +291 -0
- package/dist/grok/client.d.ts +2 -0
- package/dist/grok/client.js +47 -2
- package/dist/grok/client.js.map +1 -1
- package/dist/grok/tools.js +57 -4
- package/dist/grok/tools.js.map +1 -1
- package/dist/hooks/use-enhanced-input.js +3 -1
- package/dist/hooks/use-enhanced-input.js.map +1 -1
- package/dist/hooks/use-input-handler.js +6 -0
- package/dist/hooks/use-input-handler.js.map +1 -1
- package/dist/tools/audio-tool.d.ts +13 -0
- package/dist/tools/audio-tool.js +55 -0
- package/dist/tools/audio-tool.js.map +1 -0
- package/dist/tools/image-tool.d.ts +10 -0
- package/dist/tools/image-tool.js +92 -12
- package/dist/tools/image-tool.js.map +1 -1
- package/dist/tools/index.d.ts +11 -10
- package/dist/tools/index.js +11 -10
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/introspect-tool.js +224 -2
- package/dist/tools/introspect-tool.js.map +1 -1
- package/dist/ui/components/chat-input.js +1 -1
- package/dist/ui/components/chat-input.js.map +1 -1
- package/dist/ui/components/chat-interface.js +1 -1
- package/dist/ui/components/chat-interface.js.map +1 -1
- package/dist/ui/utils/markdown-renderer.js +2 -2
- package/dist/utils/hook-executor.js +3 -3
- package/dist/utils/hook-executor.js.map +1 -1
- package/dist/utils/path-utils.d.ts +2 -1
- package/dist/utils/path-utils.js +25 -4
- package/dist/utils/path-utils.js.map +1 -1
- package/dist/utils/startup-hook.d.ts +1 -1
- package/dist/utils/startup-hook.js +1 -1
- package/dist/utils/startup-hook.js.map +1 -1
- package/package.json +23 -20
|
@@ -0,0 +1,629 @@
|
|
|
1
|
+
import { LLMAgent } from "./llm-agent.js";
|
|
2
|
+
import { getAllLLMTools } from "../grok/tools.js";
|
|
3
|
+
import { parseImagesFromMessage, hasImageReferences } from "../utils/image-encoder.js";
|
|
4
|
+
import { getTextContent } from "../utils/content-utils.js";
|
|
5
|
+
import { Variable } from "./prompt-variables.js";
|
|
6
|
+
import { getSettingsManager } from "../utils/settings-manager.js";
|
|
7
|
+
import { executeOperationHook, applyHookCommands } from "../utils/hook-executor.js";
|
|
8
|
+
// Interval (ms) between token count updates when streaming
|
|
9
|
+
const TOKEN_UPDATE_INTERVAL_MS = 250;
|
|
10
|
+
/**
|
|
11
|
+
* Threshold used to determine whether an AI response is "substantial" (in characters).
|
|
12
|
+
*/
|
|
13
|
+
const SUBSTANTIAL_RESPONSE_THRESHOLD = 50;
|
|
14
|
+
/**
|
|
15
|
+
* Extracts the first complete JSON object from a string.
|
|
16
|
+
* Handles duplicate/concatenated JSON objects (LLM bug) like: {"key":"val"}{"key":"val"}
|
|
17
|
+
*/
|
|
18
|
+
function extractFirstJsonObject(jsonString) {
|
|
19
|
+
if (!jsonString.includes('}{'))
|
|
20
|
+
return jsonString;
|
|
21
|
+
try {
|
|
22
|
+
let depth = 0;
|
|
23
|
+
let firstObjEnd = -1;
|
|
24
|
+
for (let i = 0; i < jsonString.length; i++) {
|
|
25
|
+
if (jsonString[i] === "{")
|
|
26
|
+
depth++;
|
|
27
|
+
if (jsonString[i] === "}") {
|
|
28
|
+
depth--;
|
|
29
|
+
if (depth === 0) {
|
|
30
|
+
firstObjEnd = i + 1;
|
|
31
|
+
break;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
if (firstObjEnd > 0 && firstObjEnd < jsonString.length) {
|
|
36
|
+
const firstObj = jsonString.substring(0, firstObjEnd);
|
|
37
|
+
JSON.parse(firstObj); // Validate it's valid JSON
|
|
38
|
+
return firstObj;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
// If extraction fails, return the original string
|
|
43
|
+
}
|
|
44
|
+
return jsonString;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Cleans up LLM-generated JSON argument strings for tool calls.
|
|
48
|
+
*/
|
|
49
|
+
function sanitizeToolArguments(args) {
|
|
50
|
+
let argsString = args?.trim() || "{}";
|
|
51
|
+
const extractedArgsString = extractFirstJsonObject(argsString);
|
|
52
|
+
if (extractedArgsString !== argsString) {
|
|
53
|
+
argsString = extractedArgsString;
|
|
54
|
+
}
|
|
55
|
+
return argsString;
|
|
56
|
+
}
|
|
57
|
+
export class StreamingLLMAgent extends LLMAgent {
|
|
58
|
+
/**
|
|
59
|
+
* Streaming version of processUserMessage that yields chunks as they're processed
|
|
60
|
+
*/
|
|
61
|
+
async *processUserMessageStream(message) {
|
|
62
|
+
// Detect rephrase commands
|
|
63
|
+
let isRephraseCommand = false;
|
|
64
|
+
let isSystemRephrase = false;
|
|
65
|
+
let messageToSend = message;
|
|
66
|
+
let messageType = "user";
|
|
67
|
+
let prefillText;
|
|
68
|
+
if (message.startsWith("/system rephrase")) {
|
|
69
|
+
isRephraseCommand = true;
|
|
70
|
+
isSystemRephrase = true;
|
|
71
|
+
messageToSend = message.substring(8).trim();
|
|
72
|
+
messageType = "system";
|
|
73
|
+
const prefillMatch = message.match(/^\/system rephrase\s+(.+)$/);
|
|
74
|
+
if (prefillMatch) {
|
|
75
|
+
prefillText = prefillMatch[1];
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
else if (message.startsWith("/rephrase")) {
|
|
79
|
+
isRephraseCommand = true;
|
|
80
|
+
messageToSend = message;
|
|
81
|
+
messageType = "user";
|
|
82
|
+
const prefillMatch = message.match(/^\/rephrase\s+(.+)$/);
|
|
83
|
+
if (prefillMatch) {
|
|
84
|
+
prefillText = prefillMatch[1];
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
// Handle rephrase state
|
|
88
|
+
if (isRephraseCommand) {
|
|
89
|
+
let lastAssistantIndex = -1;
|
|
90
|
+
for (let i = this.getChatHistory().length - 1; i >= 0; i--) {
|
|
91
|
+
if (this.getChatHistory()[i].type === "assistant") {
|
|
92
|
+
lastAssistantIndex = i;
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
if (lastAssistantIndex === -1) {
|
|
97
|
+
throw new Error("No previous assistant message to rephrase");
|
|
98
|
+
}
|
|
99
|
+
this.setRephraseState(lastAssistantIndex, this.getChatHistory().length, -1, messageType, prefillText);
|
|
100
|
+
}
|
|
101
|
+
// Handle incomplete tool calls from previous interrupted turn
|
|
102
|
+
const messages = this.getMessages();
|
|
103
|
+
const lastMessage = messages[messages.length - 1];
|
|
104
|
+
if (lastMessage?.role === "assistant" && lastMessage.tool_calls) {
|
|
105
|
+
const toolCallIds = new Set(lastMessage.tool_calls.map((tc) => tc.id));
|
|
106
|
+
const completedToolCallIds = new Set();
|
|
107
|
+
for (let i = messages.length - 1; i >= 0; i--) {
|
|
108
|
+
const msg = messages[i];
|
|
109
|
+
if (msg.role === "tool" && msg.tool_call_id) {
|
|
110
|
+
completedToolCallIds.add(msg.tool_call_id);
|
|
111
|
+
}
|
|
112
|
+
if (messages[i] === lastMessage)
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
for (const toolCallId of toolCallIds) {
|
|
116
|
+
if (!completedToolCallIds.has(toolCallId)) {
|
|
117
|
+
console.error(`Adding cancelled result for incomplete tool call: ${toolCallId}`);
|
|
118
|
+
this.addMessage({
|
|
119
|
+
role: "tool",
|
|
120
|
+
content: "[Cancelled by user]",
|
|
121
|
+
tool_call_id: toolCallId,
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
// Clear one-shot variables and execute hooks
|
|
127
|
+
Variable.clearOneShot();
|
|
128
|
+
if (!this.getHasRunInstanceHook()) {
|
|
129
|
+
this.setHasRunInstanceHook(true);
|
|
130
|
+
const settings = getSettingsManager();
|
|
131
|
+
const instanceHookPath = settings.getInstanceHook();
|
|
132
|
+
if (instanceHookPath) {
|
|
133
|
+
const hookResult = await executeOperationHook(instanceHookPath, "instance", {}, 30000, false, this.getCurrentTokenCount(), this.getMaxContextSize());
|
|
134
|
+
if (hookResult.approved && hookResult.commands && hookResult.commands.length > 0) {
|
|
135
|
+
const results = applyHookCommands(hookResult.commands);
|
|
136
|
+
for (const [varName, value] of results.promptVars.entries()) {
|
|
137
|
+
Variable.set(varName, value);
|
|
138
|
+
}
|
|
139
|
+
await this.processHookCommands(results);
|
|
140
|
+
if (results.system) {
|
|
141
|
+
this.addMessage({
|
|
142
|
+
role: 'system',
|
|
143
|
+
content: results.system
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
if (results.prefill) {
|
|
147
|
+
this.setHookPrefillText(results.prefill);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
// Parse images and set variables
|
|
153
|
+
const parsed = hasImageReferences(messageToSend)
|
|
154
|
+
? parseImagesFromMessage(messageToSend)
|
|
155
|
+
: { text: messageToSend, images: [] };
|
|
156
|
+
Variable.set("USER:PROMPT", parsed.text);
|
|
157
|
+
// Execute prePrompt hook
|
|
158
|
+
const hookPath = getSettingsManager().getPrePromptHook();
|
|
159
|
+
if (hookPath) {
|
|
160
|
+
const hookResult = await executeOperationHook(hookPath, "prePrompt", { USER_MESSAGE: parsed.text }, 30000, false, this.getCurrentTokenCount(), this.getMaxContextSize());
|
|
161
|
+
if (hookResult.approved && hookResult.commands) {
|
|
162
|
+
const results = applyHookCommands(hookResult.commands);
|
|
163
|
+
for (const [varName, value] of results.promptVars.entries()) {
|
|
164
|
+
Variable.set(varName, value);
|
|
165
|
+
}
|
|
166
|
+
await this.processHookCommands(results);
|
|
167
|
+
if (results.prefill) {
|
|
168
|
+
this.setHookPrefillText(results.prefill);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
// Assemble final message
|
|
173
|
+
const assembledMessage = Variable.renderFull("USER");
|
|
174
|
+
const supportsVision = this.getLLMClient().getSupportsVision();
|
|
175
|
+
let messageContent = assembledMessage;
|
|
176
|
+
if (messageType === "user" && parsed.images.length > 0 && supportsVision) {
|
|
177
|
+
messageContent = [
|
|
178
|
+
{ type: "text", text: assembledMessage },
|
|
179
|
+
...parsed.images
|
|
180
|
+
];
|
|
181
|
+
}
|
|
182
|
+
const userEntry = {
|
|
183
|
+
type: messageType,
|
|
184
|
+
content: messageContent,
|
|
185
|
+
originalContent: messageType === "user" ? (parsed.images.length > 0 && supportsVision
|
|
186
|
+
? [{ type: "text", text: parsed.text }, ...parsed.images]
|
|
187
|
+
: parsed.text) : undefined,
|
|
188
|
+
timestamp: new Date(),
|
|
189
|
+
};
|
|
190
|
+
this.addToChatHistory(userEntry);
|
|
191
|
+
if (messageType === "user") {
|
|
192
|
+
this.addMessage({ role: "user", content: messageContent });
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
this.addMessage({ role: "system", content: typeof messageContent === "string" ? messageContent : assembledMessage });
|
|
196
|
+
}
|
|
197
|
+
await this.emitContextChange();
|
|
198
|
+
yield {
|
|
199
|
+
type: "user_message",
|
|
200
|
+
userEntry: userEntry,
|
|
201
|
+
};
|
|
202
|
+
const maxToolRounds = this.getMaxToolRounds();
|
|
203
|
+
let toolRounds = 0;
|
|
204
|
+
let inputTokens = this.getTokenCounter().countMessageTokens(this.getMessages());
|
|
205
|
+
let totalOutputTokens = 0;
|
|
206
|
+
let lastTokenUpdate = 0;
|
|
207
|
+
try {
|
|
208
|
+
// Handle prefill text
|
|
209
|
+
if (this.getRephraseState()?.prefillText) {
|
|
210
|
+
this.addMessage({
|
|
211
|
+
role: "assistant",
|
|
212
|
+
content: this.getRephraseState().prefillText
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
if (this.getHookPrefillText()) {
|
|
216
|
+
this.addMessage({
|
|
217
|
+
role: "assistant",
|
|
218
|
+
content: this.getHookPrefillText()
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
const supportsTools = this.getLLMClient().getSupportsTools();
|
|
222
|
+
// Agent loop
|
|
223
|
+
while (toolRounds < maxToolRounds) {
|
|
224
|
+
// Check for cancellation
|
|
225
|
+
if (this.getAbortController()?.signal.aborted) {
|
|
226
|
+
yield {
|
|
227
|
+
type: "content",
|
|
228
|
+
content: "\n\n[Operation cancelled by user]",
|
|
229
|
+
};
|
|
230
|
+
yield { type: "done" };
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
// Update system message with current token count
|
|
234
|
+
this.updateSystemMessageTokenCount(inputTokens);
|
|
235
|
+
// Stream response
|
|
236
|
+
const stream = this.getLLMClient().chatStream(this.getMessages(), supportsTools ? await getAllLLMTools() : [], undefined, this.isGrokModel() && this.shouldUseSearchFor(message)
|
|
237
|
+
? { search_parameters: { mode: "auto" } }
|
|
238
|
+
: { search_parameters: { mode: "off" } }, this.getTemperature(), this.getAbortController()?.signal, this.getMaxTokens());
|
|
239
|
+
let accumulatedMessage = {};
|
|
240
|
+
let accumulatedContent = "";
|
|
241
|
+
let tool_calls_yielded = false;
|
|
242
|
+
let streamFinished = false;
|
|
243
|
+
let insideThinkTag = false;
|
|
244
|
+
// Handle prefill text
|
|
245
|
+
if (this.getRephraseState()?.prefillText) {
|
|
246
|
+
yield {
|
|
247
|
+
type: "content",
|
|
248
|
+
content: this.getRephraseState().prefillText,
|
|
249
|
+
};
|
|
250
|
+
accumulatedContent = this.getRephraseState().prefillText;
|
|
251
|
+
}
|
|
252
|
+
if (this.getHookPrefillText()) {
|
|
253
|
+
yield {
|
|
254
|
+
type: "content",
|
|
255
|
+
content: this.getHookPrefillText(),
|
|
256
|
+
};
|
|
257
|
+
accumulatedContent = this.getHookPrefillText();
|
|
258
|
+
this.setHookPrefillText(null);
|
|
259
|
+
}
|
|
260
|
+
try {
|
|
261
|
+
for await (const chunk of stream) {
|
|
262
|
+
if (this.getAbortController()?.signal.aborted) {
|
|
263
|
+
yield {
|
|
264
|
+
type: "content",
|
|
265
|
+
content: "\n\n[Operation cancelled by user]",
|
|
266
|
+
};
|
|
267
|
+
yield { type: "done" };
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
if (!chunk.choices?.[0])
|
|
271
|
+
continue;
|
|
272
|
+
if (chunk.choices?.[0]?.finish_reason === "stop" || chunk.choices?.[0]?.finish_reason === "tool_calls") {
|
|
273
|
+
streamFinished = true;
|
|
274
|
+
}
|
|
275
|
+
accumulatedMessage = this.messageReducer(accumulatedMessage, chunk);
|
|
276
|
+
// Yield tool calls when complete
|
|
277
|
+
if (!tool_calls_yielded && accumulatedMessage.tool_calls?.length > 0) {
|
|
278
|
+
const hasCompleteTool = accumulatedMessage.tool_calls.some((tc) => tc.function?.name);
|
|
279
|
+
if (hasCompleteTool) {
|
|
280
|
+
yield {
|
|
281
|
+
type: "tool_calls",
|
|
282
|
+
tool_calls: accumulatedMessage.tool_calls,
|
|
283
|
+
};
|
|
284
|
+
tool_calls_yielded = true;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
// Stream content
|
|
288
|
+
if (chunk.choices[0].delta?.content && !streamFinished) {
|
|
289
|
+
let deltaContent = chunk.choices[0].delta.content;
|
|
290
|
+
// Handle thinking tags
|
|
291
|
+
deltaContent = deltaContent.replace(/<think>[\s\S]*?<\/think>/g, '');
|
|
292
|
+
if (deltaContent.includes('<think>')) {
|
|
293
|
+
insideThinkTag = true;
|
|
294
|
+
deltaContent = deltaContent.substring(0, deltaContent.indexOf('<think>'));
|
|
295
|
+
}
|
|
296
|
+
if (insideThinkTag) {
|
|
297
|
+
if (deltaContent.includes('</think>')) {
|
|
298
|
+
const closeIndex = deltaContent.indexOf('</think>');
|
|
299
|
+
deltaContent = deltaContent.substring(closeIndex + 8);
|
|
300
|
+
insideThinkTag = false;
|
|
301
|
+
}
|
|
302
|
+
else {
|
|
303
|
+
deltaContent = '';
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
if (deltaContent === '')
|
|
307
|
+
continue;
|
|
308
|
+
accumulatedContent += deltaContent;
|
|
309
|
+
const currentOutputTokens = this.getTokenCounter().estimateStreamingTokens(accumulatedContent) +
|
|
310
|
+
(accumulatedMessage.tool_calls
|
|
311
|
+
? this.getTokenCounter().countTokens(JSON.stringify(accumulatedMessage.tool_calls))
|
|
312
|
+
: 0);
|
|
313
|
+
totalOutputTokens = currentOutputTokens;
|
|
314
|
+
yield {
|
|
315
|
+
type: "content",
|
|
316
|
+
content: deltaContent,
|
|
317
|
+
};
|
|
318
|
+
const now = Date.now();
|
|
319
|
+
if (now - lastTokenUpdate > TOKEN_UPDATE_INTERVAL_MS) {
|
|
320
|
+
lastTokenUpdate = now;
|
|
321
|
+
yield {
|
|
322
|
+
type: "token_count",
|
|
323
|
+
tokenCount: inputTokens + totalOutputTokens,
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
catch (streamError) {
|
|
330
|
+
if (this.getAbortController()?.signal.aborted || streamError.name === 'AbortError' || streamError.code === 'ABORT_ERR') {
|
|
331
|
+
yield {
|
|
332
|
+
type: "content",
|
|
333
|
+
content: "\n\n[Operation cancelled by user]",
|
|
334
|
+
};
|
|
335
|
+
yield { type: "done" };
|
|
336
|
+
return;
|
|
337
|
+
}
|
|
338
|
+
throw streamError;
|
|
339
|
+
}
|
|
340
|
+
// Parse XML tool calls
|
|
341
|
+
accumulatedMessage = this.parseXMLToolCalls(accumulatedMessage);
|
|
342
|
+
// Clean up tool call arguments
|
|
343
|
+
const cleanedToolCalls = accumulatedMessage.tool_calls?.map(toolCall => {
|
|
344
|
+
let argsString = sanitizeToolArguments(toolCall.function.arguments);
|
|
345
|
+
return {
|
|
346
|
+
...toolCall,
|
|
347
|
+
function: {
|
|
348
|
+
...toolCall.function,
|
|
349
|
+
arguments: argsString
|
|
350
|
+
}
|
|
351
|
+
};
|
|
352
|
+
});
|
|
353
|
+
// Add to conversation
|
|
354
|
+
this.addMessage({
|
|
355
|
+
role: "assistant",
|
|
356
|
+
content: accumulatedMessage.content || "(Calling tools to perform this request)",
|
|
357
|
+
tool_calls: cleanedToolCalls,
|
|
358
|
+
});
|
|
359
|
+
const assistantEntry = {
|
|
360
|
+
type: "assistant",
|
|
361
|
+
content: accumulatedMessage.content || "(Calling tools to perform this request)",
|
|
362
|
+
timestamp: new Date(),
|
|
363
|
+
tool_calls: accumulatedMessage.tool_calls,
|
|
364
|
+
};
|
|
365
|
+
this.addToChatHistory(assistantEntry);
|
|
366
|
+
await this.emitContextChange();
|
|
367
|
+
// Update rephrase state if no tool calls
|
|
368
|
+
if (this.getRephraseState() && this.getRephraseState().newResponseIndex === -1 && (!accumulatedMessage.tool_calls || accumulatedMessage.tool_calls.length === 0)) {
|
|
369
|
+
const newResponseIndex = this.getChatHistory().length - 1;
|
|
370
|
+
this.setRephraseState(this.getRephraseState().originalAssistantMessageIndex, this.getRephraseState().rephraseRequestIndex, newResponseIndex, this.getRephraseState().messageType);
|
|
371
|
+
}
|
|
372
|
+
// Handle tool calls
|
|
373
|
+
if (accumulatedMessage.tool_calls?.length > 0) {
|
|
374
|
+
toolRounds++;
|
|
375
|
+
if (!tool_calls_yielded) {
|
|
376
|
+
yield {
|
|
377
|
+
type: "tool_calls",
|
|
378
|
+
tool_calls: accumulatedMessage.tool_calls,
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
// Add tool_call entries to chatHistory
|
|
382
|
+
cleanedToolCalls.forEach((toolCall) => {
|
|
383
|
+
const toolCallEntry = {
|
|
384
|
+
type: "tool_call",
|
|
385
|
+
content: "Executing...",
|
|
386
|
+
timestamp: new Date(),
|
|
387
|
+
toolCall: toolCall,
|
|
388
|
+
};
|
|
389
|
+
this.addToChatHistory(toolCallEntry);
|
|
390
|
+
});
|
|
391
|
+
// Execute tools
|
|
392
|
+
let toolIndex = 0;
|
|
393
|
+
const completedToolCallIds = new Set();
|
|
394
|
+
try {
|
|
395
|
+
for (const toolCall of cleanedToolCalls) {
|
|
396
|
+
if (this.getAbortController()?.signal.aborted) {
|
|
397
|
+
console.error(`Tool execution cancelled after ${toolIndex}/${cleanedToolCalls.length} tools`);
|
|
398
|
+
for (let i = toolIndex; i < cleanedToolCalls.length; i++) {
|
|
399
|
+
const remainingToolCall = cleanedToolCalls[i];
|
|
400
|
+
this.addMessage({
|
|
401
|
+
role: "tool",
|
|
402
|
+
content: "[Cancelled by user]",
|
|
403
|
+
tool_call_id: remainingToolCall.id,
|
|
404
|
+
});
|
|
405
|
+
completedToolCallIds.add(remainingToolCall.id);
|
|
406
|
+
}
|
|
407
|
+
yield {
|
|
408
|
+
type: "content",
|
|
409
|
+
content: "\n\n[Operation cancelled by user]",
|
|
410
|
+
};
|
|
411
|
+
yield { type: "done" };
|
|
412
|
+
return;
|
|
413
|
+
}
|
|
414
|
+
const chatHistoryLengthBefore = this.getChatHistory().length;
|
|
415
|
+
const result = await this.executeTool(toolCall);
|
|
416
|
+
// Collect new system messages
|
|
417
|
+
const newSystemMessages = [];
|
|
418
|
+
for (let i = chatHistoryLengthBefore; i < this.getChatHistory().length; i++) {
|
|
419
|
+
if (this.getChatHistory()[i].type === "system") {
|
|
420
|
+
newSystemMessages.push(this.getChatHistory()[i]);
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
yield {
|
|
424
|
+
type: "tool_result",
|
|
425
|
+
toolCall,
|
|
426
|
+
toolResult: result,
|
|
427
|
+
systemMessages: newSystemMessages.length > 0 ? newSystemMessages : undefined,
|
|
428
|
+
};
|
|
429
|
+
// Update chatHistory entry
|
|
430
|
+
const entryIndex = this.getChatHistory().findIndex((entry) => entry.type === "tool_call" && entry.toolCall?.id === toolCall.id);
|
|
431
|
+
if (entryIndex !== -1) {
|
|
432
|
+
this.updateChatHistoryEntry(entryIndex, {
|
|
433
|
+
...this.getChatHistory()[entryIndex],
|
|
434
|
+
type: "tool_result",
|
|
435
|
+
content: result.success
|
|
436
|
+
? (result.output?.trim() || "Success")
|
|
437
|
+
: (result.error?.trim() || "Error occurred"),
|
|
438
|
+
toolResult: result,
|
|
439
|
+
});
|
|
440
|
+
}
|
|
441
|
+
// Add tool result to messages
|
|
442
|
+
this.addMessage({
|
|
443
|
+
role: "tool",
|
|
444
|
+
content: result.success
|
|
445
|
+
? result.output || "Success"
|
|
446
|
+
: result.error || "Error",
|
|
447
|
+
tool_call_id: toolCall.id,
|
|
448
|
+
});
|
|
449
|
+
completedToolCallIds.add(toolCall.id);
|
|
450
|
+
toolIndex++;
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
finally {
|
|
454
|
+
// Ensure all tool calls have results
|
|
455
|
+
for (const toolCall of cleanedToolCalls) {
|
|
456
|
+
if (!completedToolCallIds.has(toolCall.id)) {
|
|
457
|
+
this.addMessage({
|
|
458
|
+
role: "tool",
|
|
459
|
+
content: "[Error: Tool execution interrupted]",
|
|
460
|
+
tool_call_id: toolCall.id,
|
|
461
|
+
});
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
// Add system messages to this.messages
|
|
466
|
+
let assistantIndex = -1;
|
|
467
|
+
for (let i = this.getChatHistory().length - 1; i >= 0; i--) {
|
|
468
|
+
const entry = this.getChatHistory()[i];
|
|
469
|
+
if (entry.type === "assistant" && entry.tool_calls && entry.tool_calls.length > 0) {
|
|
470
|
+
assistantIndex = i;
|
|
471
|
+
break;
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
if (assistantIndex !== -1) {
|
|
475
|
+
for (let i = assistantIndex + 1; i < this.getChatHistory().length; i++) {
|
|
476
|
+
const entry = this.getChatHistory()[i];
|
|
477
|
+
const content = getTextContent(entry.content);
|
|
478
|
+
if (entry.type === 'system' && content && content.trim()) {
|
|
479
|
+
this.addMessage({
|
|
480
|
+
role: 'system',
|
|
481
|
+
content: content
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
if (entry.type === 'assistant' || entry.type === 'user') {
|
|
485
|
+
break;
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
// Update token count
|
|
490
|
+
inputTokens = this.getTokenCounter().countMessageTokens(this.getMessages());
|
|
491
|
+
yield {
|
|
492
|
+
type: "token_count",
|
|
493
|
+
tokenCount: inputTokens + totalOutputTokens,
|
|
494
|
+
};
|
|
495
|
+
}
|
|
496
|
+
else {
|
|
497
|
+
// No tool calls, we're done
|
|
498
|
+
break;
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
if (toolRounds >= maxToolRounds) {
|
|
502
|
+
yield {
|
|
503
|
+
type: "content",
|
|
504
|
+
content: "\n\nMaximum tool execution rounds reached. Stopping to prevent infinite loops.",
|
|
505
|
+
};
|
|
506
|
+
}
|
|
507
|
+
this.setFirstMessageProcessed(true);
|
|
508
|
+
const supportsToolsAfter = this.getLLMClient().getSupportsTools();
|
|
509
|
+
if (!supportsToolsAfter && supportsTools) {
|
|
510
|
+
await this.buildSystemMessage();
|
|
511
|
+
}
|
|
512
|
+
yield { type: "done" };
|
|
513
|
+
}
|
|
514
|
+
catch (error) {
|
|
515
|
+
if (this.getAbortController()?.signal.aborted || error.name === 'AbortError' || error.code === 'ABORT_ERR') {
|
|
516
|
+
yield {
|
|
517
|
+
type: "content",
|
|
518
|
+
content: "\n\n[Operation cancelled by user]",
|
|
519
|
+
};
|
|
520
|
+
yield { type: "done" };
|
|
521
|
+
return;
|
|
522
|
+
}
|
|
523
|
+
// Handle context too large error
|
|
524
|
+
if (error.message && error.message.startsWith('CONTEXT_TOO_LARGE:')) {
|
|
525
|
+
const beforeCount = this.getChatHistory().length;
|
|
526
|
+
this.compactContext(20);
|
|
527
|
+
const afterCount = this.getChatHistory().length;
|
|
528
|
+
const removedCount = beforeCount - afterCount;
|
|
529
|
+
yield {
|
|
530
|
+
type: "content",
|
|
531
|
+
content: `Context was too large for backend. Automatically compacted: removed ${removedCount} older messages, keeping last 20 messages. Please retry your request.`,
|
|
532
|
+
};
|
|
533
|
+
this.setFirstMessageProcessed(true);
|
|
534
|
+
yield { type: "done" };
|
|
535
|
+
return;
|
|
536
|
+
}
|
|
537
|
+
yield {
|
|
538
|
+
type: "content",
|
|
539
|
+
content: `Sorry, I encountered an error: ${error.message}`,
|
|
540
|
+
};
|
|
541
|
+
this.setFirstMessageProcessed(true);
|
|
542
|
+
yield { type: "done" };
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
/**
|
|
546
|
+
* Non-streaming wrapper that collects all chunks into ChatEntry array
|
|
547
|
+
*/
|
|
548
|
+
async processUserMessage(message) {
|
|
549
|
+
const entries = [];
|
|
550
|
+
for await (const chunk of this.processUserMessageStream(message)) {
|
|
551
|
+
if (chunk.type === "user_message" && chunk.userEntry) {
|
|
552
|
+
entries.push(chunk.userEntry);
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
// Return the entries that were added to chatHistory during streaming
|
|
556
|
+
// Filter to only return entries that were added during this call
|
|
557
|
+
const currentHistory = this.getChatHistory();
|
|
558
|
+
const startIndex = Math.max(0, currentHistory.length - entries.length - 10); // Buffer for safety
|
|
559
|
+
return currentHistory.slice(startIndex);
|
|
560
|
+
}
|
|
561
|
+
// Protected methods to access parent class private members
|
|
562
|
+
getLLMClient() {
|
|
563
|
+
return this.llmClient;
|
|
564
|
+
}
|
|
565
|
+
getMessages() {
|
|
566
|
+
return this.messages;
|
|
567
|
+
}
|
|
568
|
+
addMessage(message) {
|
|
569
|
+
this.messages.push(message);
|
|
570
|
+
}
|
|
571
|
+
getChatHistory() {
|
|
572
|
+
return this.chatHistory;
|
|
573
|
+
}
|
|
574
|
+
addToChatHistory(entry) {
|
|
575
|
+
this.chatHistory.push(entry);
|
|
576
|
+
}
|
|
577
|
+
updateChatHistoryEntry(index, entry) {
|
|
578
|
+
this.chatHistory[index] = entry;
|
|
579
|
+
}
|
|
580
|
+
getMaxToolRounds() {
|
|
581
|
+
return this.maxToolRounds;
|
|
582
|
+
}
|
|
583
|
+
getTokenCounter() {
|
|
584
|
+
return this.tokenCounter;
|
|
585
|
+
}
|
|
586
|
+
getAbortController() {
|
|
587
|
+
return this.abortController;
|
|
588
|
+
}
|
|
589
|
+
getTemperature() {
|
|
590
|
+
return this.temperature;
|
|
591
|
+
}
|
|
592
|
+
getMaxTokens() {
|
|
593
|
+
return this.maxTokens;
|
|
594
|
+
}
|
|
595
|
+
setFirstMessageProcessed(value) {
|
|
596
|
+
this.firstMessageProcessed = value;
|
|
597
|
+
}
|
|
598
|
+
updateSystemMessageTokenCount(tokenCount) {
|
|
599
|
+
const messages = this.getMessages();
|
|
600
|
+
if (messages.length > 0 && messages[0].role === 'system' && typeof messages[0].content === 'string') {
|
|
601
|
+
messages[0].content = messages[0].content.replace(/Current conversation token usage: .*/, `Current conversation token usage: ${tokenCount}`);
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
messageReducer(previous, item) {
|
|
605
|
+
return this.messageReducer(previous, item);
|
|
606
|
+
}
|
|
607
|
+
parseXMLToolCalls(message) {
|
|
608
|
+
return this.parseXMLToolCalls(message);
|
|
609
|
+
}
|
|
610
|
+
isGrokModel() {
|
|
611
|
+
return this.isGrokModel();
|
|
612
|
+
}
|
|
613
|
+
shouldUseSearchFor(message) {
|
|
614
|
+
return this.shouldUseSearchFor(message);
|
|
615
|
+
}
|
|
616
|
+
getHasRunInstanceHook() {
|
|
617
|
+
return this.hasRunInstanceHook;
|
|
618
|
+
}
|
|
619
|
+
setHasRunInstanceHook(value) {
|
|
620
|
+
this.hasRunInstanceHook = value;
|
|
621
|
+
}
|
|
622
|
+
getHookPrefillText() {
|
|
623
|
+
return this.hookPrefillText;
|
|
624
|
+
}
|
|
625
|
+
setHookPrefillText(value) {
|
|
626
|
+
this.hookPrefillText = value;
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
//# sourceMappingURL=streaming-agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"streaming-agent.js","sourceRoot":"","sources":["../../src/agent/streaming-agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAA6B,MAAM,gBAAgB,CAAC;AAGrE,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AACvF,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAEpF,2DAA2D;AAC3D,MAAM,wBAAwB,GAAG,GAAG,CAAC;AAErC;;GAEG;AACH,MAAM,8BAA8B,GAAG,EAAE,CAAC;AAE1C;;;GAGG;AACH,SAAS,sBAAsB,CAAC,UAAkB;IAChD,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC;QAAE,OAAO,UAAU,CAAC;IAClD,IAAI,CAAC;QACH,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,IAAI,WAAW,GAAG,CAAC,CAAC,CAAC;QACrB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAC3C,IAAI,UAAU,CAAC,CAAC,CAAC,KAAK,GAAG;gBAAE,KAAK,EAAE,CAAC;YACnC,IAAI,UAAU,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;gBAC1B,KAAK,EAAE,CA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